Commit 3a84cbd5 authored by Ahmet Turan Koçak's avatar Ahmet Turan Koçak
Browse files

Initial commit

parents
import { ExternalTokenResponse, AuthenticationResult } from "@azure/msal-common";
import { SilentRequest } from "../request/SilentRequest";
import { LoadTokenOptions } from "./TokenCache";
export interface ITokenCache {
/**
* API to side-load tokens to MSAL cache
* @returns `AuthenticationResult` for the response that was loaded.
*/
loadExternalTokens(request: SilentRequest, response: ExternalTokenResponse, options: LoadTokenOptions): AuthenticationResult;
}
//# sourceMappingURL=ITokenCache.d.ts.map
\ No newline at end of file
{"version":3,"file":"ITokenCache.d.ts","sourceRoot":"","sources":["../../src/cache/ITokenCache.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AACjF,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAEhD,MAAM,WAAW,WAAW;IAExB;;;OAGG;IACH,kBAAkB,CAAC,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,qBAAqB,EAAE,OAAO,EAAE,gBAAgB,GAAG,oBAAoB,CAAC;CAEhI"}
\ No newline at end of file
export interface IWindowStorage<T> {
/**
* Get the item from the window storage object matching the given key.
* @param key
*/
getItem(key: string): T | null;
/**
* Sets the item in the window storage object with the given key.
* @param key
* @param value
*/
setItem(key: string, value: T): void;
/**
* Removes the item in the window storage object matching the given key.
* @param key
*/
removeItem(key: string): void;
/**
* Get all the keys from the window storage object as an iterable array of strings.
*/
getKeys(): string[];
/**
* Returns true or false if the given key is present in the cache.
* @param key
*/
containsKey(key: string): boolean;
}
//# sourceMappingURL=IWindowStorage.d.ts.map
\ No newline at end of file
{"version":3,"file":"IWindowStorage.d.ts","sourceRoot":"","sources":["../../src/cache/IWindowStorage.ts"],"names":[],"mappings":"AAKA,MAAM,WAAW,cAAc,CAAC,CAAC;IAC7B;;;OAGG;IACH,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,CAAC,GAAG,IAAI,CAAC;IAE/B;;;;OAIG;IACH,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,GAAG,IAAI,CAAC;IAErC;;;OAGG;IACH,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IAE9B;;OAEG;IACH,OAAO,IAAI,MAAM,EAAE,CAAC;IAEpB;;;OAGG;IACH,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACrC"}
\ No newline at end of file
import { IWindowStorage } from "./IWindowStorage";
export declare class MemoryStorage<T> implements IWindowStorage<T> {
private cache;
constructor();
getItem(key: string): T | null;
setItem(key: string, value: T): void;
removeItem(key: string): void;
getKeys(): string[];
containsKey(key: string): boolean;
clear(): void;
}
//# sourceMappingURL=MemoryStorage.d.ts.map
\ No newline at end of file
{"version":3,"file":"MemoryStorage.d.ts","sourceRoot":"","sources":["../../src/cache/MemoryStorage.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD,qBAAa,aAAa,CAAC,CAAC,CAAE,YAAW,cAAc,CAAC,CAAC,CAAC;IAEtD,OAAO,CAAC,KAAK,CAAiB;;IAM9B,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,CAAC,GAAG,IAAI;IAI9B,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,GAAG,IAAI;IAIpC,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;IAI7B,OAAO,IAAI,MAAM,EAAE;IAQnB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO;IAIjC,KAAK,IAAI,IAAI;CAGhB"}
\ No newline at end of file
/*! @azure/msal-browser v2.32.1 2022-12-07 */
'use strict';
/*
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License.
*/
var MemoryStorage = /** @class */ (function () {
function MemoryStorage() {
this.cache = new Map();
}
MemoryStorage.prototype.getItem = function (key) {
return this.cache.get(key) || null;
};
MemoryStorage.prototype.setItem = function (key, value) {
this.cache.set(key, value);
};
MemoryStorage.prototype.removeItem = function (key) {
this.cache.delete(key);
};
MemoryStorage.prototype.getKeys = function () {
var cacheKeys = [];
this.cache.forEach(function (value, key) {
cacheKeys.push(key);
});
return cacheKeys;
};
MemoryStorage.prototype.containsKey = function (key) {
return this.cache.has(key);
};
MemoryStorage.prototype.clear = function () {
this.cache.clear();
};
return MemoryStorage;
}());
export { MemoryStorage };
//# sourceMappingURL=MemoryStorage.js.map
{"version":3,"file":"MemoryStorage.js","sources":["../../src/cache/MemoryStorage.ts"],"sourcesContent":["/*\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IWindowStorage } from \"./IWindowStorage\";\n\nexport class MemoryStorage<T> implements IWindowStorage<T> {\n\n private cache: Map<string, T>;\n\n constructor() {\n this.cache = new Map<string, T>();\n }\n\n getItem(key: string): T | null {\n return this.cache.get(key) || null;\n }\n\n setItem(key: string, value: T): void {\n this.cache.set(key, value);\n }\n\n removeItem(key: string): void {\n this.cache.delete(key);\n }\n\n getKeys(): string[] {\n const cacheKeys: string[] = [];\n this.cache.forEach((value: T, key: string) => {\n cacheKeys.push(key);\n });\n return cacheKeys;\n }\n\n containsKey(key: string): boolean {\n return this.cache.has(key);\n }\n\n clear() :void {\n this.cache.clear();\n }\n}\n"],"names":[],"mappings":";;AAAA;;;;;IAWI;QACI,IAAI,CAAC,KAAK,GAAG,IAAI,GAAG,EAAa,CAAC;KACrC;IAED,+BAAO,GAAP,UAAQ,GAAW;QACf,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,IAAI,CAAC;KACtC;IAED,+BAAO,GAAP,UAAQ,GAAW,EAAE,KAAQ;QACzB,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;KAC9B;IAED,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MAAM,CAAS;IAEvB,OAAO,CAAC,SAAS,CAAU;gBAEf,aAAa,EAAE,oBAAoB,EAAE,OAAO,EAAE,mBAAmB,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,OAAO;IAUjH;;;;;;OAMG;IACH,kBAAkB,CAAC,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,qBAAqB,EAAE,OAAO,EAAE,gBAAgB,GAAG,oBAAoB;IA6D5H;;;;;;;;OAQG;IACH,OAAO,CAAC,WAAW;IA2BnB;;;;;;;OAOG;IACH,OAAO,CAAC,WAAW;IAanB;;;;;;;;OAQG;IACH,OAAO,CAAC,eAAe;IA8BvB;;;;;;;OAOG;IACH,OAAO,CAAC,gBAAgB;IAkBxB;;;;;;;OAOG;IACH,OAAO,CAAC,4BAA4B;CA4CvC"}
\ No newline at end of file
/*! @azure/msal-browser v2.32.1 2022-12-07 */
'use strict';
import { AuthToken, CacheRecord, Authority, AccountEntity, IdTokenEntity, ScopeSet, AccessTokenEntity, RefreshTokenEntity, Constants } from '@azure/msal-common';
import { BrowserAuthError } from '../error/BrowserAuthError.js';
/*
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License.
*/
/**
* Token cache manager
*/
var TokenCache = /** @class */ (function () {
function TokenCache(configuration, storage, logger, cryptoObj) {
this.isBrowserEnvironment = typeof window !== "undefined";
this.config = configuration;
this.storage = storage;
this.logger = logger;
this.cryptoObj = cryptoObj;
}
// Move getAllAccounts here and cache utility APIs
/**
* API to load tokens to msal-browser cache.
* @param request
* @param response
* @param options
* @returns `AuthenticationResult` for the response that was loaded.
*/
TokenCache.prototype.loadExternalTokens = function (request, response, options) {
this.logger.info("TokenCache - loadExternalTokens called");
if (!response.id_token) {
throw BrowserAuthError.createUnableToLoadTokenError("Please ensure server response includes id token.");
}
var idToken = new AuthToken(response.id_token, this.cryptoObj);
var cacheRecord;
var authority;
if (request.account) {
var cacheRecordAccount = this.loadAccount(idToken, request.account.environment, undefined, undefined, request.account.homeAccountId);
cacheRecord = new CacheRecord(cacheRecordAccount, this.loadIdToken(idToken, cacheRecordAccount.homeAccountId, request.account.environment, request.account.tenantId), this.loadAccessToken(request, response, cacheRecordAccount.homeAccountId, request.account.environment, request.account.tenantId, options), this.loadRefreshToken(request, response, cacheRecordAccount.homeAccountId, request.account.environment));
}
else if (request.authority) {
var authorityUrl = Authority.generateAuthority(request.authority, request.azureCloudOptions);
var authorityOptions = {
protocolMode: this.config.auth.protocolMode,
knownAuthorities: this.config.auth.knownAuthorities,
cloudDiscoveryMetadata: this.config.auth.cloudDiscoveryMetadata,
authorityMetadata: this.config.auth.authorityMetadata,
skipAuthorityMetadataCache: this.config.auth.skipAuthorityMetadataCache,
};
authority = new Authority(authorityUrl, this.config.system.networkClient, this.storage, authorityOptions, this.logger);
// "clientInfo" from options takes precedence over "clientInfo" in response
if (options.clientInfo) {
this.logger.trace("TokenCache - homeAccountId from options");
var cacheRecordAccount = this.loadAccount(idToken, authority.hostnameAndPort, options.clientInfo, authority.authorityType);
cacheRecord = new CacheRecord(cacheRecordAccount, this.loadIdToken(idToken, cacheRecordAccount.homeAccountId, authority.hostnameAndPort, authority.tenant), this.loadAccessToken(request, response, cacheRecordAccount.homeAccountId, authority.hostnameAndPort, authority.tenant, options), this.loadRefreshToken(request, response, cacheRecordAccount.homeAccountId, authority.hostnameAndPort));
}
else if (response.client_info) {
this.logger.trace("TokenCache - homeAccountId from response");
var cacheRecordAccount = this.loadAccount(idToken, authority.hostnameAndPort, response.client_info, authority.authorityType);
cacheRecord = new CacheRecord(cacheRecordAccount, this.loadIdToken(idToken, cacheRecordAccount.homeAccountId, authority.hostnameAndPort, authority.tenant), this.loadAccessToken(request, response, cacheRecordAccount.homeAccountId, authority.hostnameAndPort, authority.tenant, options), this.loadRefreshToken(request, response, cacheRecordAccount.homeAccountId, authority.hostnameAndPort));
}
else {
throw BrowserAuthError.createUnableToLoadTokenError("Please provide clientInfo in the response or options.");
}
}
else {
throw BrowserAuthError.createUnableToLoadTokenError("Please provide a request with an account or a request with authority.");
}
return this.generateAuthenticationResult(request, idToken, cacheRecord, authority);
};
/**
* Helper function to load account to msal-browser cache
* @param idToken
* @param environment
* @param clientInfo
* @param authorityType
* @param requestHomeAccountId
* @returns `AccountEntity`
*/
TokenCache.prototype.loadAccount = function (idToken, environment, clientInfo, authorityType, requestHomeAccountId) {
var homeAccountId;
if (requestHomeAccountId) {
homeAccountId = requestHomeAccountId;
}
else if (authorityType !== undefined && clientInfo) {
homeAccountId = AccountEntity.generateHomeAccountId(clientInfo, authorityType, this.logger, this.cryptoObj, idToken);
}
if (!homeAccountId) {
throw BrowserAuthError.createUnableToLoadTokenError("Unexpected missing homeAccountId");
}
var accountEntity = clientInfo ?
AccountEntity.createAccount(clientInfo, homeAccountId, idToken, undefined, undefined, undefined, environment) :
AccountEntity.createGenericAccount(homeAccountId, idToken, undefined, undefined, undefined, environment);
if (this.isBrowserEnvironment) {
this.logger.verbose("TokenCache - loading account");
this.storage.setAccount(accountEntity);
return accountEntity;
}
else {
throw BrowserAuthError.createUnableToLoadTokenError("loadExternalTokens is designed to work in browser environments only.");
}
};
/**
* Helper function to load id tokens to msal-browser cache
* @param idToken
* @param homeAccountId
* @param environment
* @param tenantId
* @returns `IdTokenEntity`
*/
TokenCache.prototype.loadIdToken = function (idToken, homeAccountId, environment, tenantId) {
var idTokenEntity = IdTokenEntity.createIdTokenEntity(homeAccountId, environment, idToken.rawToken, this.config.auth.clientId, tenantId);
if (this.isBrowserEnvironment) {
this.logger.verbose("TokenCache - loading id token");
this.storage.setIdTokenCredential(idTokenEntity);
return idTokenEntity;
}
else {
throw BrowserAuthError.createUnableToLoadTokenError("loadExternalTokens is designed to work in browser environments only.");
}
};
/**
* Helper function to load access tokens to msal-browser cache
* @param request
* @param response
* @param homeAccountId
* @param environment
* @param tenantId
* @returns `AccessTokenEntity`
*/
TokenCache.prototype.loadAccessToken = function (request, response, homeAccountId, environment, tenantId, options) {
if (!response.access_token) {
this.logger.verbose("TokenCache - No access token provided for caching");
return null;
}
if (!response.expires_in) {
throw BrowserAuthError.createUnableToLoadTokenError("Please ensure server response includes expires_in value.");
}
if (!options.extendedExpiresOn) {
throw BrowserAuthError.createUnableToLoadTokenError("Please provide an extendedExpiresOn value in the options.");
}
var scopes = new ScopeSet(request.scopes).printScopes();
var expiresOn = options.expiresOn || (response.expires_in + new Date().getTime() / 1000);
var extendedExpiresOn = options.extendedExpiresOn;
var accessTokenEntity = AccessTokenEntity.createAccessTokenEntity(homeAccountId, environment, response.access_token, this.config.auth.clientId, tenantId, scopes, expiresOn, extendedExpiresOn, this.cryptoObj);
if (this.isBrowserEnvironment) {
this.logger.verbose("TokenCache - loading access token");
this.storage.setAccessTokenCredential(accessTokenEntity);
return accessTokenEntity;
}
else {
throw BrowserAuthError.createUnableToLoadTokenError("loadExternalTokens is designed to work in browser environments only.");
}
};
/**
* Helper function to load refresh tokens to msal-browser cache
* @param request
* @param response
* @param homeAccountId
* @param environment
* @returns `RefreshTokenEntity`
*/
TokenCache.prototype.loadRefreshToken = function (request, response, homeAccountId, environment) {
if (!response.refresh_token) {
this.logger.verbose("TokenCache - No refresh token provided for caching");
return null;
}
var refreshTokenEntity = RefreshTokenEntity.createRefreshTokenEntity(homeAccountId, environment, response.refresh_token, this.config.auth.clientId);
if (this.isBrowserEnvironment) {
this.logger.verbose("TokenCache - loading refresh token");
this.storage.setRefreshTokenCredential(refreshTokenEntity);
return refreshTokenEntity;
}
else {
throw BrowserAuthError.createUnableToLoadTokenError("loadExternalTokens is designed to work in browser environments only.");
}
};
/**
* Helper function to generate an `AuthenticationResult` for the result.
* @param request
* @param idTokenObj
* @param cacheRecord
* @param authority
* @returns `AuthenticationResult`
*/
TokenCache.prototype.generateAuthenticationResult = function (request, idTokenObj, cacheRecord, authority) {
var _a, _b, _c;
var accessToken = Constants.EMPTY_STRING;
var responseScopes = [];
var expiresOn = null;
var extExpiresOn;
if (cacheRecord === null || cacheRecord === void 0 ? void 0 : cacheRecord.accessToken) {
accessToken = cacheRecord.accessToken.secret;
responseScopes = ScopeSet.fromString(cacheRecord.accessToken.target).asArray();
expiresOn = new Date(Number(cacheRecord.accessToken.expiresOn) * 1000);
extExpiresOn = new Date(Number(cacheRecord.accessToken.extendedExpiresOn) * 1000);
}
var uid = (idTokenObj === null || idTokenObj === void 0 ? void 0 : idTokenObj.claims.oid) || (idTokenObj === null || idTokenObj === void 0 ? void 0 : idTokenObj.claims.sub) || Constants.EMPTY_STRING;
var tid = (idTokenObj === null || idTokenObj === void 0 ? void 0 : idTokenObj.claims.tid) || Constants.EMPTY_STRING;
return {
authority: authority ? authority.canonicalAuthority : Constants.EMPTY_STRING,
uniqueId: uid,
tenantId: tid,
scopes: responseScopes,
account: (cacheRecord === null || cacheRecord === void 0 ? void 0 : cacheRecord.account) ? cacheRecord.account.getAccountInfo() : null,
idToken: idTokenObj ? idTokenObj.rawToken : Constants.EMPTY_STRING,
idTokenClaims: idTokenObj ? idTokenObj.claims : {},
accessToken: accessToken,
fromCache: true,
expiresOn: expiresOn,
correlationId: request.correlationId || Constants.EMPTY_STRING,
requestId: Constants.EMPTY_STRING,
extExpiresOn: extExpiresOn,
familyId: Constants.EMPTY_STRING,
tokenType: ((_a = cacheRecord === null || cacheRecord === void 0 ? void 0 : cacheRecord.accessToken) === null || _a === void 0 ? void 0 : _a.tokenType) || Constants.EMPTY_STRING,
state: Constants.EMPTY_STRING,
cloudGraphHostName: ((_b = cacheRecord === null || cacheRecord === void 0 ? void 0 : cacheRecord.account) === null || _b === void 0 ? void 0 : _b.cloudGraphHostName) || Constants.EMPTY_STRING,
msGraphHost: ((_c = cacheRecord === null || cacheRecord === void 0 ? void 0 : cacheRecord.account) === null || _c === void 0 ? void 0 : _c.msGraphHost) || Constants.EMPTY_STRING,
code: undefined,
fromNativeBroker: false
};
};
return TokenCache;
}());
export { TokenCache };
//# sourceMappingURL=TokenCache.js.map
{"version":3,"file":"TokenCache.js","sources":["../../src/cache/TokenCache.ts"],"sourcesContent":["/*\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { AccessTokenEntity, ICrypto, IdTokenEntity, Logger, ScopeSet, Authority, AuthorityOptions, ExternalTokenResponse, AccountEntity, AuthToken, RefreshTokenEntity , AuthorityType, CacheRecord, AuthenticationResult, Constants } from \"@azure/msal-common\";\nimport { BrowserConfiguration } from \"../config/Configuration\";\nimport { SilentRequest } from \"../request/SilentRequest\";\nimport { BrowserCacheManager } from \"./BrowserCacheManager\";\nimport { ITokenCache } from \"./ITokenCache\";\nimport { BrowserAuthError } from \"../error/BrowserAuthError\";\n\nexport type LoadTokenOptions = {\n clientInfo?: string,\n expiresOn?: number,\n extendedExpiresOn?: number\n};\n\n/**\n * Token cache manager\n */\nexport class TokenCache implements ITokenCache {\n // Flag to indicate if in browser environment\n public isBrowserEnvironment: boolean;\n // Input configuration by developer/user\n protected config: BrowserConfiguration;\n // Browser cache storage\n private storage: BrowserCacheManager;\n // Logger\n private logger: Logger;\n // Crypto class\n private cryptoObj: ICrypto;\n\n constructor(configuration: BrowserConfiguration, storage: BrowserCacheManager, logger: Logger, cryptoObj: ICrypto) {\n this.isBrowserEnvironment = typeof window !== \"undefined\";\n this.config = configuration;\n this.storage = storage;\n this.logger = logger;\n this.cryptoObj = cryptoObj;\n }\n\n // Move getAllAccounts here and cache utility APIs\n\n /**\n * API to load tokens to msal-browser cache.\n * @param request\n * @param response\n * @param options\n * @returns `AuthenticationResult` for the response that was loaded.\n */\n loadExternalTokens(request: SilentRequest, response: ExternalTokenResponse, options: LoadTokenOptions): AuthenticationResult {\n this.logger.info(\"TokenCache - loadExternalTokens called\");\n\n if (!response.id_token) {\n throw BrowserAuthError.createUnableToLoadTokenError(\"Please ensure server response includes id token.\");\n }\n\n const idToken = new AuthToken(response.id_token, this.cryptoObj);\n\n let cacheRecord: CacheRecord | undefined;\n let authority: Authority | undefined;\n\n if (request.account) {\n const cacheRecordAccount = this.loadAccount(idToken, request.account.environment, undefined, undefined, request.account.homeAccountId);\n cacheRecord = new CacheRecord(\n cacheRecordAccount,\n this.loadIdToken(idToken, cacheRecordAccount.homeAccountId, request.account.environment, request.account.tenantId),\n this.loadAccessToken(request, response, cacheRecordAccount.homeAccountId, request.account.environment, request.account.tenantId, options),\n this.loadRefreshToken(request, response, cacheRecordAccount.homeAccountId, request.account.environment)\n );\n } else if (request.authority) {\n\n const authorityUrl = Authority.generateAuthority(request.authority, request.azureCloudOptions);\n const authorityOptions: AuthorityOptions = {\n protocolMode: this.config.auth.protocolMode,\n knownAuthorities: this.config.auth.knownAuthorities,\n cloudDiscoveryMetadata: this.config.auth.cloudDiscoveryMetadata,\n authorityMetadata: this.config.auth.authorityMetadata,\n skipAuthorityMetadataCache: this.config.auth.skipAuthorityMetadataCache,\n };\n authority = new Authority(authorityUrl, this.config.system.networkClient, this.storage, authorityOptions, this.logger);\n\n // \"clientInfo\" from options takes precedence over \"clientInfo\" in response\n if (options.clientInfo) {\n this.logger.trace(\"TokenCache - homeAccountId from options\");\n const cacheRecordAccount = this.loadAccount(idToken, authority.hostnameAndPort, options.clientInfo, authority.authorityType);\n cacheRecord = new CacheRecord(\n cacheRecordAccount,\n this.loadIdToken(idToken, cacheRecordAccount.homeAccountId, authority.hostnameAndPort, authority.tenant),\n this.loadAccessToken(request, response, cacheRecordAccount.homeAccountId, authority.hostnameAndPort, authority.tenant, options),\n this.loadRefreshToken(request, response, cacheRecordAccount.homeAccountId, authority.hostnameAndPort)\n );\n } else if (response.client_info) {\n this.logger.trace(\"TokenCache - homeAccountId from response\");\n const cacheRecordAccount = this.loadAccount(idToken, authority.hostnameAndPort, response.client_info, authority.authorityType);\n cacheRecord = new CacheRecord(\n cacheRecordAccount,\n this.loadIdToken(idToken, cacheRecordAccount.homeAccountId, authority.hostnameAndPort, authority.tenant),\n this.loadAccessToken(request, response, cacheRecordAccount.homeAccountId, authority.hostnameAndPort, authority.tenant, options),\n this.loadRefreshToken(request, response, cacheRecordAccount.homeAccountId, authority.hostnameAndPort)\n );\n } else {\n throw BrowserAuthError.createUnableToLoadTokenError(\"Please provide clientInfo in the response or options.\");\n }\n } else {\n throw BrowserAuthError.createUnableToLoadTokenError(\"Please provide a request with an account or a request with authority.\");\n }\n\n return this.generateAuthenticationResult(request, idToken, cacheRecord, authority);\n }\n\n /**\n * Helper function to load account to msal-browser cache\n * @param idToken\n * @param environment\n * @param clientInfo\n * @param authorityType\n * @param requestHomeAccountId\n * @returns `AccountEntity`\n */\n private loadAccount(idToken: AuthToken, environment: string, clientInfo?: string, authorityType?: AuthorityType, requestHomeAccountId?: string): AccountEntity {\n\n let homeAccountId;\n if (requestHomeAccountId) {\n homeAccountId = requestHomeAccountId;\n } else if (authorityType !== undefined && clientInfo) {\n homeAccountId = AccountEntity.generateHomeAccountId(clientInfo, authorityType, this.logger, this.cryptoObj, idToken);\n }\n\n if (!homeAccountId) {\n throw BrowserAuthError.createUnableToLoadTokenError(\"Unexpected missing homeAccountId\");\n }\n\n const accountEntity = clientInfo ?\n AccountEntity.createAccount(clientInfo, homeAccountId, idToken, undefined, undefined, undefined, environment) :\n AccountEntity.createGenericAccount(homeAccountId, idToken, undefined, undefined, undefined, environment);\n\n if (this.isBrowserEnvironment) {\n this.logger.verbose(\"TokenCache - loading account\");\n\n this.storage.setAccount(accountEntity);\n return accountEntity;\n } else {\n throw BrowserAuthError.createUnableToLoadTokenError(\"loadExternalTokens is designed to work in browser environments only.\");\n }\n }\n\n /**\n * Helper function to load id tokens to msal-browser cache\n * @param idToken\n * @param homeAccountId\n * @param environment\n * @param tenantId\n * @returns `IdTokenEntity`\n */\n private loadIdToken(idToken: AuthToken, homeAccountId: string, environment: string, tenantId: string): IdTokenEntity {\n\n const idTokenEntity = IdTokenEntity.createIdTokenEntity(homeAccountId, environment, idToken.rawToken, this.config.auth.clientId, tenantId);\n\n if (this.isBrowserEnvironment) {\n this.logger.verbose(\"TokenCache - loading id token\");\n this.storage.setIdTokenCredential(idTokenEntity);\n return idTokenEntity;\n } else {\n throw BrowserAuthError.createUnableToLoadTokenError(\"loadExternalTokens is designed to work in browser environments only.\");\n }\n }\n\n /**\n * Helper function to load access tokens to msal-browser cache\n * @param request\n * @param response\n * @param homeAccountId\n * @param environment\n * @param tenantId\n * @returns `AccessTokenEntity`\n */\n private loadAccessToken(request: SilentRequest, response: ExternalTokenResponse, homeAccountId: string, environment: string, tenantId: string, options: LoadTokenOptions): AccessTokenEntity | null {\n\n if (!response.access_token) {\n this.logger.verbose(\"TokenCache - No access token provided for caching\");\n return null;\n }\n\n if (!response.expires_in) {\n throw BrowserAuthError.createUnableToLoadTokenError(\"Please ensure server response includes expires_in value.\");\n }\n\n if (!options.extendedExpiresOn) {\n throw BrowserAuthError.createUnableToLoadTokenError(\"Please provide an extendedExpiresOn value in the options.\");\n }\n\n const scopes = new ScopeSet(request.scopes).printScopes();\n const expiresOn = options.expiresOn || (response.expires_in + new Date().getTime() / 1000);\n const extendedExpiresOn = options.extendedExpiresOn;\n\n const accessTokenEntity = AccessTokenEntity.createAccessTokenEntity(homeAccountId, environment, response.access_token, this.config.auth.clientId, tenantId, scopes, expiresOn, extendedExpiresOn, this.cryptoObj);\n\n if (this.isBrowserEnvironment) {\n this.logger.verbose(\"TokenCache - loading access token\");\n this.storage.setAccessTokenCredential(accessTokenEntity);\n return accessTokenEntity;\n } else {\n throw BrowserAuthError.createUnableToLoadTokenError(\"loadExternalTokens is designed to work in browser environments only.\");\n }\n }\n\n /**\n * Helper function to load refresh tokens to msal-browser cache\n * @param request\n * @param response\n * @param homeAccountId\n * @param environment\n * @returns `RefreshTokenEntity`\n */\n private loadRefreshToken(request: SilentRequest, response: ExternalTokenResponse, homeAccountId: string, environment: string): RefreshTokenEntity | null {\n\n if (!response.refresh_token) {\n this.logger.verbose(\"TokenCache - No refresh token provided for caching\");\n return null;\n }\n\n const refreshTokenEntity = RefreshTokenEntity.createRefreshTokenEntity(homeAccountId, environment, response.refresh_token, this.config.auth.clientId);\n\n if (this.isBrowserEnvironment) {\n this.logger.verbose(\"TokenCache - loading refresh token\");\n this.storage.setRefreshTokenCredential(refreshTokenEntity);\n return refreshTokenEntity;\n } else {\n throw BrowserAuthError.createUnableToLoadTokenError(\"loadExternalTokens is designed to work in browser environments only.\");\n }\n }\n\n /**\n * Helper function to generate an `AuthenticationResult` for the result.\n * @param request\n * @param idTokenObj\n * @param cacheRecord\n * @param authority\n * @returns `AuthenticationResult`\n */\n private generateAuthenticationResult(\n request: SilentRequest,\n idTokenObj: AuthToken,\n cacheRecord?: CacheRecord,\n authority?: Authority,\n ): AuthenticationResult {\n let accessToken: string = Constants.EMPTY_STRING;\n let responseScopes: Array<string> = [];\n let expiresOn: Date | null = null;\n let extExpiresOn: Date | undefined;\n\n if (cacheRecord?.accessToken) {\n accessToken = cacheRecord.accessToken.secret;\n responseScopes = ScopeSet.fromString(cacheRecord.accessToken.target).asArray();\n expiresOn = new Date(Number(cacheRecord.accessToken.expiresOn) * 1000);\n extExpiresOn = new Date(Number(cacheRecord.accessToken.extendedExpiresOn) * 1000);\n }\n\n const uid = idTokenObj?.claims.oid || idTokenObj?.claims.sub || Constants.EMPTY_STRING;\n const tid = idTokenObj?.claims.tid || Constants.EMPTY_STRING;\n\n return {\n authority: authority ? authority.canonicalAuthority : Constants.EMPTY_STRING,\n uniqueId: uid,\n tenantId: tid,\n scopes: responseScopes,\n account: cacheRecord?.account ? cacheRecord.account.getAccountInfo() : null,\n idToken: idTokenObj ? idTokenObj.rawToken : Constants.EMPTY_STRING,\n idTokenClaims: idTokenObj ? idTokenObj.claims : {},\n accessToken: accessToken,\n fromCache: true,\n expiresOn: expiresOn,\n correlationId: request.correlationId || Constants.EMPTY_STRING,\n requestId: Constants.EMPTY_STRING,\n extExpiresOn: extExpiresOn,\n familyId: Constants.EMPTY_STRING,\n tokenType: cacheRecord?.accessToken?.tokenType || Constants.EMPTY_STRING,\n state: Constants.EMPTY_STRING,\n cloudGraphHostName: cacheRecord?.account?.cloudGraphHostName || Constants.EMPTY_STRING,\n msGra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U,GAAG,UAAU,CAAC,MAAM,GAAG,EAAE;YAClD,WAAW,EAAE,WAAW;YACxB,SAAS,EAAE,IAAI;YACf,SAAS,EAAE,SAAS;YACpB,aAAa,EAAE,OAAO,CAAC,aAAa,IAAI,SAAS,CAAC,YAAY;YAC9D,SAAS,EAAE,SAAS,CAAC,YAAY;YACjC,YAAY,EAAE,YAAY;YAC1B,QAAQ,EAAE,SAAS,CAAC,YAAY;YAChC,SAAS,EAAE,OAAA,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,WAAW,0CAAE,SAAS,KAAI,SAAS,CAAC,YAAY;YACxE,KAAK,EAAE,SAAS,CAAC,YAAY;YAC7B,kBAAkB,EAAE,OAAA,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,OAAO,0CAAE,kBAAkB,KAAI,SAAS,CAAC,YAAY;YACtF,WAAW,EAAE,OAAA,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,OAAO,0CAAE,WAAW,KAAI,SAAS,CAAC,YAAY;YACxE,IAAI,EAAE,SAAS;YACf,gBAAgB,EAAE,KAAK;SAC1B,CAAC;KACL;IACL,iBAAC;AAAD,CAAC;;;;"}
\ No newline at end of file
import { SystemOptions, LoggerOptions, INetworkModule, ProtocolMode, AzureCloudOptions, ApplicationTelemetry } from "@azure/msal-common";
import { BrowserCacheLocation } from "../utils/BrowserConstants";
import { INavigationClient } from "../navigation/INavigationClient";
export declare const DEFAULT_POPUP_TIMEOUT_MS = 60000;
export declare const DEFAULT_IFRAME_TIMEOUT_MS = 6000;
export declare const DEFAULT_REDIRECT_TIMEOUT_MS = 30000;
export declare const DEFAULT_NATIVE_BROKER_HANDSHAKE_TIMEOUT_MS = 2000;
/**
* Use this to configure the auth options in the Configuration object
*/
export declare type BrowserAuthOptions = {
/**
* Client ID of your app registered with our Application registration portal : https://portal.azure.com/#blade/Microsoft_AAD_IAM/ActiveDirectoryMenuBlade/RegisteredAppsPreview in Microsoft Identity Platform
*/
clientId: string;
/**
* You can configure a specific authority, defaults to " " or "https://login.microsoftonline.com/common"
*/
authority?: string;
/**
* An array of URIs that are known to be valid. Used in B2C scenarios.
*/
knownAuthorities?: Array<string>;
/**
* A string containing the cloud discovery response. Used in AAD scenarios.
*/
cloudDiscoveryMetadata?: string;
/**
* A string containing the .well-known/openid-configuration endpoint response
*/
authorityMetadata?: string;
/**
* The redirect URI where authentication responses can be received by your application. It must exactly match one of the redirect URIs registered in the Azure portal.
*/
redirectUri?: string;
/**
* The redirect URI where the window navigates after a successful logout.
*/
postLogoutRedirectUri?: string | null;
/**
* Boolean indicating whether to navigate to the original request URL after the auth server navigates to the redirect URL.
*/
navigateToLoginRequestUrl?: boolean;
/**
* Array of capabilities which will be added to the claims.access_token.xms_cc request property on every network request.
*/
clientCapabilities?: Array<string>;
/**
* Enum that represents the protocol that msal follows. Used for configuring proper endpoints.
*/
protocolMode?: ProtocolMode;
/**
* Enum that represents the Azure Cloud to use.
*/
azureCloudOptions?: AzureCloudOptions;
/**
* Flag of whether to use the local metadata cache
*/
skipAuthorityMetadataCache?: boolean;
};
/**
* Use this to configure the below cache configuration options:
*/
export declare type CacheOptions = {
/**
* Used to specify the cacheLocation user wants to set. Valid values are "localStorage" and "sessionStorage"
*/
cacheLocation?: BrowserCacheLocation | string;
/**
* If set, MSAL stores the auth request state required for validation of the auth flows in the browser cookies. By default this flag is set to false.
*/
storeAuthStateInCookie?: boolean;
/**
* If set, MSAL sets the "Secure" flag on cookies so they can only be sent over HTTPS. By default this flag is set to false.
*/
secureCookies?: boolean;
};
export declare type BrowserSystemOptions = SystemOptions & {
/**
* Used to initialize the Logger object (See ClientConfiguration.ts)
*/
loggerOptions?: LoggerOptions;
/**
* Network interface implementation
*/
networkClient?: INetworkModule;
/**
* Override the methods used to navigate to other webpages. Particularly useful if you are using a client-side router
*/
navigationClient?: INavigationClient;
/**
* Sets the timeout for waiting for a response hash in a popup. Will take precedence over loadFrameTimeout if both are set.
*/
windowHashTimeout?: number;
/**
* Sets the timeout for waiting for a response hash in an iframe. Will take precedence over loadFrameTimeout if both are set.
*/
iframeHashTimeout?: number;
/**
* Sets the timeout for waiting for a response hash in an iframe or popup
*/
loadFrameTimeout?: number;
/**
* Maximum time the library should wait for a frame to load
*/
navigateFrameWait?: number;
/**
* Time to wait for redirection to occur before resolving promise
*/
redirectNavigationTimeout?: number;
/**
* Sets whether popups are opened asynchronously. By default, this flag is set to false. When set to false, blank popups are opened before anything else happens. When set to true, popups are opened when making the network request.
*/
asyncPopups?: boolean;
/**
* Flag to enable redirect opertaions when the app is rendered in an iframe (to support scenarios such as embedded B2C login).
*/
allowRedirectInIframe?: boolean;
/**
* Flag to enable native broker support (e.g. acquiring tokens from WAM on Windows)
*/
allowNativeBroker?: boolean;
/**
* Sets the timeout for waiting for the native broker handshake to resolve
*/
nativeBrokerHandshakeTimeout?: number;
/**
* Options related to browser crypto APIs
*/
cryptoOptions?: CryptoOptions;
/**
* Sets the interval length in milliseconds for polling the location attribute in popup windows (default is 30ms)
*/
pollIntervalMilliseconds?: number;
};
export declare type CryptoOptions = {
/**
* Enables the application to use the MSR Crypto interface, if available (and other interfaces are not)
* @type {?boolean}
*/
useMsrCrypto?: boolean;
/**
* Entropy to seed browser crypto API (needed for MSR Crypto). Must be cryptographically strong random numbers (e.g. crypto.randomBytes(48) from Node)
* @type {?Uint8Array}
*/
entropy?: Uint8Array;
};
/**
* Telemetry Options
*/
export declare type BrowserTelemetryOptions = {
/**
* Telemetry information sent on request
* - appName: Unique string name of an application
* - appVersion: Version of the application using MSAL
*/
application?: ApplicationTelemetry;
};
/**
* This object allows you to configure important elements of MSAL functionality and is passed into the constructor of PublicClientApplication
*/
export declare type Configuration = {
/**
* This is where you configure auth elements like clientID, authority used for authenticating against the Microsoft Identity Platform
*/
auth: BrowserAuthOptions;
/**
* This is where you configure cache location and whether to store cache in cookies
*/
cache?: CacheOptions;
/**
* This is where you can configure the network client, logger, token renewal offset
*/
system?: BrowserSystemOptions;
/**
* This is where you can configure telemetry data and options
*/
telemetry?: BrowserTelemetryOptions;
};
export declare type BrowserConfiguration = {
auth: Required<BrowserAuthOptions>;
cache: Required<CacheOptions>;
system: Required<BrowserSystemOptions>;
telemetry: Required<BrowserTelemetryOptions>;
};
/**
* MSAL function that sets the default options when not explicitly configured from app developer
*
* @param auth
* @param cache
* @param system
*
* @returns Configuration object
*/
export declare function buildConfiguration({ auth: userInputAuth, cache: userInputCache, system: userInputSystem, telemetry: userInputTelemetry }: Configuration, isBrowserEnvironment: boolean): BrowserConfiguration;
//# sourceMappingURL=Configuration.d.ts.map
\ No newline at end of file
{"version":3,"file":"Configuration.d.ts","sourceRoot":"","sources":["../../src/config/Configuration.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,cAAc,EAAqC,YAAY,EAAsD,iBAAiB,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAEhO,OAAO,EAAE,oBAAoB,EAAoB,MAAM,2BAA2B,CAAC;AACnF,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AAIpE,eAAO,MAAM,wBAAwB,QAAQ,CAAC;AAC9C,eAAO,MAAM,yBAAyB,OAAO,CAAC;AAC9C,eAAO,MAAM,2BAA2B,QAAQ,CAAC;AACjD,eAAO,MAAM,0CAA0C,OAAO,CAAC;AAE/D;;GAEG;AACH,oBAAY,kBAAkB,GAAG;IAC7B;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAC;IACjB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;OAEG;IACH,gBAAgB,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACjC;;OAEG;IACH,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC;;OAEG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;OAEG;IACH,qBAAqB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;I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E,MAAM,CAAC;CACrC,CAAC;AAEF,oBAAY,aAAa,GAAG;IAExB;;;OAGG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;IAEvB;;;OAGG;IACH,OAAO,CAAC,EAAE,UAAU,CAAC;CACxB,CAAC;AAEF;;GAEG;AACH,oBAAY,uBAAuB,GAAG;IAClC;;;;OAIG;IACH,WAAW,CAAC,EAAE,oBAAoB,CAAC;CACtC,CAAC;AAEF;;GAEG;AACH,oBAAY,aAAa,GAAG;IACxB;;OAEG;IACH,IAAI,EAAE,kBAAkB,CAAC;IACzB;;OAEG;IACH,KAAK,CAAC,EAAE,YAAY,CAAC;IACrB;;OAEG;IACH,MAAM,CAAC,EAAE,oBAAoB,CAAC;IAC9B;;OAEG;IACH,SAAS,CAAC,EAAE,uBAAuB,CAAA;CACtC,CAAC;AAEF,oBAAY,oBAAoB,GAAG;IAC/B,IAAI,EAAE,QAAQ,CAAC,kBAAkB,CAAC,CAAC;IACnC,KAAK,EAAE,QAAQ,CAAC,YAAY,CAAC,CAAC;IAC9B,MAAM,EAAE,QAAQ,CAAC,oBAAoB,CAAC,CAAC;IACvC,SAAS,EAAE,QAAQ,CAAC,uBAAuB,CAAC,CAAA;CAC/C,CAAC;AAEF;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,CAAC,EAAE,IAAI,EAAE,aAAa,EAAE,KAAK,EAAE,cAAc,EAAE,MAAM,EAAE,eAAe,EAAE,SAAS,EAAE,kBAAkB,EAAE,EAAE,aAAa,EAAE,oBAAoB,EAAE,OAAO,GAAG,oBAAoB,CAyE7M"}
\ No newline at end of file
/*! @azure/msal-browser v2.32.1 2022-12-07 */
'use strict';
import { __assign } from '../_virtual/_tslib.js';
import { DEFAULT_SYSTEM_OPTIONS, StubbedNetworkModule, Constants, ProtocolMode, AzureCloudInstance, LogLevel } from '@azure/msal-common';
import { BrowserUtils } from '../utils/BrowserUtils.js';
import { BrowserConstants, BrowserCacheLocation } from '../utils/BrowserConstants.js';
import { NavigationClient } from '../navigation/NavigationClient.js';
/*
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License.
*/
// Default timeout for popup windows and iframes in milliseconds
var DEFAULT_POPUP_TIMEOUT_MS = 60000;
var DEFAULT_IFRAME_TIMEOUT_MS = 6000;
var DEFAULT_REDIRECT_TIMEOUT_MS = 30000;
var DEFAULT_NATIVE_BROKER_HANDSHAKE_TIMEOUT_MS = 2000;
/**
* MSAL function that sets the default options when not explicitly configured from app developer
*
* @param auth
* @param cache
* @param system
*
* @returns Configuration object
*/
function buildConfiguration(_a, isBrowserEnvironment) {
var userInputAuth = _a.auth, userInputCache = _a.cache, userInputSystem = _a.system, userInputTelemetry = _a.telemetry;
// Default auth options for browser
var DEFAULT_AUTH_OPTIONS = {
clientId: Constants.EMPTY_STRING,
authority: "" + Constants.DEFAULT_AUTHORITY,
knownAuthorities: [],
cloudDiscoveryMetadata: Constants.EMPTY_STRING,
authorityMetadata: Constants.EMPTY_STRING,
redirectUri: Constants.EMPTY_STRING,
postLogoutRedirectUri: Constants.EMPTY_STRING,
navigateToLoginRequestUrl: true,
clientCapabilities: [],
protocolMode: ProtocolMode.AAD,
azureCloudOptions: {
azureCloudInstance: AzureCloudInstance.None,
tenant: Constants.EMPTY_STRING
},
skipAuthorityMetadataCache: false,
};
// Default cache options for browser
var DEFAULT_CACHE_OPTIONS = {
cacheLocation: BrowserCacheLocation.SessionStorage,
storeAuthStateInCookie: false,
secureCookies: false
};
// Default logger options for browser
var DEFAULT_LOGGER_OPTIONS = {
// eslint-disable-next-line @typescript-eslint/no-empty-function
loggerCallback: function () { },
logLevel: LogLevel.Info,
piiLoggingEnabled: false
};
// Default system options for browser
var DEFAULT_BROWSER_SYSTEM_OPTIONS = __assign(__assign({}, DEFAULT_SYSTEM_OPTIONS), { loggerOptions: DEFAULT_LOGGER_OPTIONS, networkClient: isBrowserEnvironment ? BrowserUtils.getBrowserNetworkClient() : StubbedNetworkModule, navigationClient: new NavigationClient(), loadFrameTimeout: 0,
// If loadFrameTimeout is provided, use that as default.
windowHashTimeout: (userInputSystem === null || userInputSystem === void 0 ? void 0 : userInputSystem.loadFrameTimeout) || DEFAULT_POPUP_TIMEOUT_MS, iframeHashTimeout: (userInputSystem === null || userInputSystem === void 0 ? void 0 : userInputSystem.loadFrameTimeout) || DEFAULT_IFRAME_TIMEOUT_MS, navigateFrameWait: isBrowserEnvironment && BrowserUtils.detectIEOrEdge() ? 500 : 0, redirectNavigationTimeout: DEFAULT_REDIRECT_TIMEOUT_MS, asyncPopups: false, allowRedirectInIframe: false, allowNativeBroker: false, nativeBrokerHandshakeTimeout: (userInputSystem === null || userInputSystem === void 0 ? void 0 : userInputSystem.nativeBrokerHandshakeTimeout) || DEFAULT_NATIVE_BROKER_HANDSHAKE_TIMEOUT_MS, pollIntervalMilliseconds: BrowserConstants.DEFAULT_POLL_INTERVAL_MS, cryptoOptions: {
useMsrCrypto: false,
entropy: undefined
} });
var DEFAULT_TELEMETRY_OPTIONS = {
application: {
appName: Constants.EMPTY_STRING,
appVersion: Constants.EMPTY_STRING
}
};
var overlayedConfig = {
auth: __assign(__assign({}, DEFAULT_AUTH_OPTIONS), userInputAuth),
cache: __assign(__assign({}, DEFAULT_CACHE_OPTIONS), userInputCache),
system: __assign(__assign({}, DEFAULT_BROWSER_SYSTEM_OPTIONS), userInputSystem),
telemetry: __assign(__assign({}, DEFAULT_TELEMETRY_OPTIONS), userInputTelemetry)
};
return overlayedConfig;
}
export { DEFAULT_IFRAME_TIMEOUT_MS, DEFAULT_NATIVE_BROKER_HANDSHAKE_TIMEOUT_MS, DEFAULT_POPUP_TIMEOUT_MS, DEFAULT_REDIRECT_TIMEOUT_MS, buildConfiguration };
//# sourceMappingURL=Configuration.js.map
{"version":3,"file":"Configuration.js","sources":["../../src/config/Configuration.ts"],"sourcesContent":["/*\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { SystemOptions, LoggerOptions, INetworkModule, DEFAULT_SYSTEM_OPTIONS, Constants, ProtocolMode, LogLevel, StubbedNetworkModule, AzureCloudInstance, AzureCloudOptions, ApplicationTelemetry } from \"@azure/msal-common\";\nimport { BrowserUtils } from \"../utils/BrowserUtils\";\nimport { BrowserCacheLocation, BrowserConstants } from \"../utils/BrowserConstants\";\nimport { INavigationClient } from \"../navigation/INavigationClient\";\nimport { NavigationClient } from \"../navigation/NavigationClient\";\n\n// Default timeout for popup windows and iframes in milliseconds\nexport const DEFAULT_POPUP_TIMEOUT_MS = 60000;\nexport const DEFAULT_IFRAME_TIMEOUT_MS = 6000;\nexport const DEFAULT_REDIRECT_TIMEOUT_MS = 30000;\nexport const DEFAULT_NATIVE_BROKER_HANDSHAKE_TIMEOUT_MS = 2000;\n\n/**\n * Use this to configure the auth options in the Configuration object\n */\nexport type BrowserAuthOptions = {\n /**\n * Client ID of your app registered with our Application registration portal : https://portal.azure.com/#blade/Microsoft_AAD_IAM/ActiveDirectoryMenuBlade/RegisteredAppsPreview in Microsoft Identity Platform\n */\n clientId: string;\n /**\n * You can configure a specific authority, defaults to \" \" or \"https://login.microsoftonline.com/common\"\n */\n authority?: string;\n /**\n * An array of URIs that are known to be valid. Used in B2C scenarios.\n */\n knownAuthorities?: Array<string>;\n /**\n * A string containing the cloud discovery response. Used in AAD scenarios.\n */\n cloudDiscoveryMetadata?: string;\n /**\n * A string containing the .well-known/openid-configuration endpoint response\n */\n authorityMetadata?: string;\n /**\n * The redirect URI where authentication responses can be received by your application. It must exactly match one of the redirect URIs registered in the Azure portal.\n */\n redirectUri?: string;\n /**\n * The redirect URI where the window navigates after a successful logout.\n */\n postLogoutRedirectUri?: string | null;\n /**\n * Boolean indicating whether to navigate to the original request URL after the auth server navigates to the redirect URL.\n */\n navigateToLoginRequestUrl?: boolean;\n /**\n * Array of capabilities which will be added to the claims.access_token.xms_cc request property on every network request.\n */\n clientCapabilities?: Array<string>;\n /**\n * Enum that represents the protocol that msal follows. Used for configuring proper endpoints.\n */\n protocolMode?: ProtocolMode;\n /**\n * Enum that represents the Azure Cloud to use.\n */\n azureCloudOptions?: AzureCloudOptions;\n /**\n * Flag of whether to use the local metadata cache\n */\n skipAuthorityMetadataCache?: boolean;\n};\n\n/**\n * Use this to configure the below cache configuration options:\n */\nexport type CacheOptions = {\n /**\n * Used to specify the cacheLocation user wants to set. Valid values are \"localStorage\" and \"sessionStorage\"\n */\n cacheLocation?: BrowserCacheLocation | string;\n /**\n * If set, MSAL stores the auth request state required for validation of the auth flows in the browser cookies. By default this flag is set to false.\n */\n storeAuthStateInCookie?: boolean;\n /**\n * If set, MSAL sets the \"Secure\" flag on cookies so they can only be sent over HTTPS. By default this flag is set to false.\n */\n secureCookies?: boolean;\n};\n\nexport type BrowserSystemOptions = SystemOptions & {\n /**\n * Used to initialize the Logger object (See ClientConfiguration.ts)\n */\n loggerOptions?: LoggerOptions;\n /**\n * Network interface implementation\n */\n networkClient?: INetworkModule;\n /**\n * Override the methods used to navigate to other webpages. Particularly useful if you are using a client-side router\n */\n navigationClient?: INavigationClient;\n /**\n * Sets the timeout for waiting for a response hash in a popup. Will take precedence over loadFrameTimeout if both are set.\n */\n windowHashTimeout?: number;\n /**\n * Sets the timeout for waiting for a response hash in an iframe. Will take precedence over loadFrameTimeout if both are set.\n */\n iframeHashTimeout?: number;\n /**\n * Sets the timeout for waiting for a response hash in an iframe or popup\n */\n loadFrameTimeout?: number;\n /**\n * Maximum time the library should wait for a frame to load\n */\n navigateFrameWait?: number;\n /**\n * Time to wait for redirection to occur before resolving promise\n */\n redirectNavigationTimeout?: number;\n /**\n * Sets whether popups are opened asynchronously. By default, this flag is set to false. When set to false, blank popups are opened before anything else happens. When set to true, popups are opened when making the network request.\n */\n asyncPopups?: boolean;\n /**\n * Flag to enable redirect opertaions when the app is rendered in an iframe (to support scenarios such as embedded B2C login).\n */\n allowRedirectInIframe?: boolean;\n /**\n * Flag to enable native broker support (e.g. acquiring tokens from WAM on Windows)\n */\n allowNativeBroker?: boolean;\n /**\n * Sets the timeout for waiting for the native broker handshake to resolve\n */\n nativeBrokerHandshakeTimeout?: number;\n /**\n * Options related to browser crypto APIs\n */\n cryptoOptions?: CryptoOptions;\n /**\n * Sets the interval length in milliseconds for polling the location attribute in popup windows (default is 30ms)\n */\n pollIntervalMilliseconds?: number;\n};\n\nexport type CryptoOptions = {\n \n /**\n * Enables the application to use the MSR Crypto interface, if available (and other interfaces are not)\n * @type {?boolean}\n */\n useMsrCrypto?: boolean;\n \n /**\n * Entropy to seed browser crypto API (needed for MSR Crypto). Must be cryptographically strong random numbers (e.g. crypto.randomBytes(48) from Node)\n * @type {?Uint8Array}\n */\n entropy?: Uint8Array;\n};\n\n/**\n * Telemetry Options\n */\nexport type BrowserTelemetryOptions = {\n /**\n * Telemetry information sent on request\n * - appName: Unique string name of an application\n * - appVersion: Version of the application using MSAL\n */\n application?: ApplicationTelemetry;\n};\n\n/**\n * This object allows you to configure important elements of MSAL functionality and is passed into the constructor of PublicClientApplication\n */\nexport type Configuration = {\n /**\n * This is where you configure auth elements like clientID, authority used for authenticating against the Microsoft Identity Platform\n */\n auth: BrowserAuthOptions,\n /**\n * This is where you configure cache location and whether to store cache in cookies\n */\n cache?: CacheOptions,\n /**\n * This is where you can configure the network client, logger, token renewal offset\n */\n system?: BrowserSystemOptions,\n /**\n * This is where you can configure telemetry data and options\n */\n telemetry?: BrowserTelemetryOptions\n};\n\nexport type BrowserConfiguration = {\n auth: Required<BrowserAuthOptions>,\n cache: Required<CacheOptions>,\n system: Required<BrowserSystemOptions>,\n telemetry: Required<BrowserTelemetryOptions>\n};\n\n/**\n * MSAL function that sets the default options when not explicitly configured from app developer\n *\n * @param auth\n * @param cache\n * @param system\n *\n * @returns Configuration object\n */\nexport function buildConfiguration({ auth: userInputAuth, cache: userInputCache, system: userInputSystem, telemetry: userInputTelemetry }: Configuration, isBrowserEnvironment: boolean): BrowserConfiguration {\n\n // Default auth options for browser\n const DEFAULT_AUTH_OPTIONS: Required<BrowserAuthOptions> = {\n clientId: Constants.EMPTY_STRING,\n authority: `${Constants.DEFAULT_AUTHORITY}`,\n knownAuthorities: [],\n cloudDiscoveryMetadata: Constants.EMPTY_STRING,\n authorityMetadata: Constants.EMPTY_STRING,\n redirectUri: Constants.EMPTY_STRING,\n postLogoutRedirectUri: Constants.EMPTY_STRING,\n navigateToLoginRequestUrl: true,\n clientCapabilities: [],\n protocolMode: ProtocolMode.AAD,\n azureCloudOptions: {\n azureCloudInstance: AzureCloudInstance.None,\n tenant: Constants.EMPTY_STRING\n },\n skipAuthorityMetadataCache: false,\n };\n\n // Default cache options for browser\n const DEFAULT_CACHE_OPTIONS: Required<CacheOptions> = {\n cacheLocation: BrowserCacheLocation.SessionStorage,\n storeAuthStateInCookie: false,\n secureCookies: false\n };\n\n // Default logger options for browser\n const DEFAULT_LOGGER_OPTIONS: LoggerOptions = {\n // eslint-disable-next-line @typescript-eslint/no-empty-function\n loggerCallback: (): void => {},\n logLevel: LogLevel.Info,\n piiLoggingEnabled: false\n };\n\n // Default system options for browser\n const DEFAULT_BROWSER_SYSTEM_OPTIONS: Required<BrowserSystemOptions> = {\n ...DEFAULT_SYSTEM_OPTIONS,\n loggerOptions: DEFAULT_LOGGER_OPTIONS,\n networkClient: isBrowserEnvironment ? BrowserUtils.getBrowserNetworkClient() : StubbedNetworkModule,\n navigationClient: new NavigationClient(),\n loadFrameTimeout: 0,\n // If loadFrameTimeout is provided, use that as default.\n windowHashTimeout: userInputSystem?.loadFrameTimeout || DEFAULT_POPUP_TIMEOUT_MS,\n iframeHashTimeout: userInputSystem?.loadFrameTimeout || DEFAULT_IFRAME_TIMEOUT_MS,\n navigateFrameWait: isBrowserEnvironment && BrowserUtils.detectIEOrEdge() ? 500 : 0,\n redirectNavigationTimeout: DEFAULT_REDIRECT_TIMEOUT_MS,\n asyncPopups: false,\n allowRedirectInIframe: false,\n allowNativeBroker: false,\n nativeBrokerHandshakeTimeout: userInputSystem?.nativeBrokerHandshakeTimeout || DEFAULT_NATIVE_BROKER_HANDSHAKE_TIMEOUT_MS,\n pollIntervalMilliseconds: BrowserConstants.DEFAULT_POLL_INTERVAL_MS,\n cryptoOptions: {\n useMsrCrypto: false,\n entropy: undefined\n }\n };\n\n const DEFAULT_TELEMETRY_OPTIONS: Required<BrowserTelemetryOptions> = {\n application: {\n appName: Constants.EMPTY_STRING,\n appVersion: Constants.EMPTY_STRING\n }\n };\n\n const overlayedConfig: BrowserConfiguration = {\n auth: { ...DEFAULT_AUTH_OPTIONS, ...userInputAuth },\n cache: { ...DEFAULT_CACHE_OPTIONS, ...userInputCache },\n system: { ...DEFAULT_BROWSER_SYSTEM_OPTIONS, ...userInputSystem },\n telemetry: { ...DEFAULT_TELEMETRY_OPTIONS, ...userInputTelemetry }\n };\n return overlayedConfig;\n}\n\n"],"names":[],"mappings":";;;;;;;;AAAA;;;;AAWA;IACa,wBAAwB,GAAG,MAAM;IACjC,yBAAyB,GAAG,KAAK;IACjC,2BAA2B,GAAG,MAAM;IACpC,0CAA0C,GAAG,KAAK;AA6L/D;;;;;;;;;SASgB,kBAAkB,CAAC,EAAqH,EAAE,oBAA6B;QAA5I,aAAa,UAAA,EAAS,cAAc,WAAA,EAAU,eAAe,YAAA,EAAa,kBAAkB,eAAA;;IAGnI,IAAM,oBAAoB,GAAiC;QACvD,QAAQ,EAAE,SAAS,CAAC,YAAY;QAChC,SAAS,EAAE,KAAG,SAAS,CAAC,iBAAmB;QAC3C,gBAAgB,EAAE,EAAE;QACpB,sBAAsB,EAAE,SAAS,CAAC,YAAY;QAC9C,iBAAiB,EAAE,SAAS,CAAC,YAAY;QACzC,WAAW,EAAE,SAAS,CAAC,YAAY;QACnC,qBAAqB,EAAE,SAAS,CAAC,YAAY;QAC7C,yBAAyB,EAAE,IAAI;QAC/B,kBAAkB,EAAE,EAAE;QACtB,YAAY,EAAE,YAAY,CAAC,GAAG;QAC9B,iBAAiB,EAAE;YACf,kBAAkB,EAAE,kBAAkB,CAAC,IAAI;YAC3C,MAAM,EAAE,SAAS,CAAC,YAAY;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EF,IAAM,eAAe,GAAyB;QAC1C,IAAI,wBAAO,oBAAoB,GAAK,aAAa,CAAE;QACnD,KAAK,wBAAO,qBAAqB,GAAK,cAAc,CAAE;QACtD,MAAM,wBAAO,8BAA8B,GAAK,eAAe,CAAE;QACjE,SAAS,wBAAO,yBAAyB,GAAK,kBAAkB,CAAE;KACrE,CAAC;IACF,OAAO,eAAe,CAAC;AAC3B;;;;"}
\ No newline at end of file
import { Logger } from "@azure/msal-common";
import { CryptoOptions } from "../config/Configuration";
/**
* This class implements functions used by the browser library to perform cryptography operations such as
* hashing and encoding. It also has helper functions to validate the availability of specific APIs.
*/
export declare class BrowserCrypto {
private keygenAlgorithmOptions;
private subtleCrypto;
private logger;
private cryptoOptions?;
constructor(logger: Logger, cryptoOptions?: CryptoOptions);
/**
* Check whether IE crypto or other browser cryptography is available.
*/
private hasIECrypto;
/**
* Check whether browser crypto is available.
*/
private hasBrowserCrypto;
/**
* Check whether MSR crypto polyfill is available
*/
private hasMsrCrypto;
/**
* Returns a sha-256 hash of the given dataString as an ArrayBuffer.
* @param dataString
*/
sha256Digest(dataString: string): Promise<ArrayBuffer>;
/**
* Populates buffer with cryptographically random values.
* @param dataBuffer
*/
getRandomValues(dataBuffer: Uint8Array): Uint8Array;
/**
* Generates a keypair based on current keygen algorithm config.
* @param extractable
* @param usages
*/
generateKeyPair(extractable: boolean, usages: Array<KeyUsage>): Promise<CryptoKeyPair>;
/**
* Export key as Json Web Key (JWK)
* @param key
* @param format
*/
exportJwk(key: CryptoKey): Promise<JsonWebKey>;
/**
* Imports key as Json Web Key (JWK), can set extractable and usages.
* @param key
* @param format
* @param extractable
* @param usages
*/
importJwk(key: JsonWebKey, extractable: boolean, usages: Array<KeyUsage>): Promise<CryptoKey>;
/**
* Signs given data with given key
* @param key
* @param data
*/
sign(key: CryptoKey, data: ArrayBuffer): Promise<ArrayBuffer>;
}
//# sourceMappingURL=BrowserCrypto.d.ts.map
\ No newline at end of file
{"version":3,"file":"BrowserCrypto.d.ts","sourceRoot":"","sources":["../../src/crypto/BrowserCrypto.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAE5C,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAaxD;;;GAGG;AACH,qBAAa,aAAa;IAEtB,OAAO,CAAC,sBAAsB,CAAwB;IACtD,OAAO,CAAC,YAAY,CAAgB;IACpC,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,aAAa,CAAC,CAAgB;gBAE1B,MAAM,EAAE,MAAM,EAAE,aAAa,CAAC,EAAE,aAAa;IA6CzD;;OAEG;IACH,OAAO,CAAC,WAAW;IAInB;;OAEG;IACH,OAAO,CAAC,gBAAgB;IAIxB;;OAEG;IACH,OAAO,CAAC,YAAY;IAIpB;;;OAGG;IACG,YAAY,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC;IAM5D;;;OAGG;IACH,eAAe,CAAC,UAAU,EAAE,UAAU,GAAG,UAAU;IAInD;;;;OAIG;IACG,eAAe,CAAC,WAAW,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,QAAQ,CAAC,GAAG,OAAO,CAAC,aAAa,CAAC;IAI5F;;;;OAIG;IACG,SAAS,CAAC,GAAG,EAAE,SAAS,GAAG,OAAO,CAAC,UAAU,CAAC;IAIpD;;;;;;OAMG;IACG,SAAS,CAAC,GAAG,EAAE,UAAU,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,QAAQ,CAAC,GAAG,OAAO,CAAC,SAAS,CAAC;IAInG;;;;OAIG;IACG,IAAI,CAAC,GAAG,EAAE,SAAS,EAAE,IAAI,EAAE,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC;CAGtE"}
\ No newline at end of file
/*! @azure/msal-browser v2.32.1 2022-12-07 */
'use strict';
import { __awaiter, __generator } from '../_virtual/_tslib.js';
import { BrowserStringUtils } from '../utils/BrowserStringUtils.js';
import { BrowserAuthError } from '../error/BrowserAuthError.js';
import { ModernBrowserCrypto } from './ModernBrowserCrypto.js';
import { MsrBrowserCrypto } from './MsrBrowserCrypto.js';
import { MsBrowserCrypto } from './MsBrowserCrypto.js';
import { BrowserConfigurationAuthError } from '../error/BrowserConfigurationAuthError.js';
/*
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License.
*/
/**
* See here for more info on RsaHashedKeyGenParams: https://developer.mozilla.org/en-US/docs/Web/API/RsaHashedKeyGenParams
*/
// RSA KeyGen Algorithm
var PKCS1_V15_KEYGEN_ALG = "RSASSA-PKCS1-v1_5";
// SHA-256 hashing algorithm
var S256_HASH_ALG = "SHA-256";
// MOD length for PoP tokens
var MODULUS_LENGTH = 2048;
// Public Exponent
var PUBLIC_EXPONENT = new Uint8Array([0x01, 0x00, 0x01]);
/**
* This class implements functions used by the browser library to perform cryptography operations such as
* hashing and encoding. It also has helper functions to validate the availability of specific APIs.
*/
var BrowserCrypto = /** @class */ (function () {
function BrowserCrypto(logger, cryptoOptions) {
var _a, _b;
this.logger = logger;
this.cryptoOptions = cryptoOptions;
if (this.hasBrowserCrypto()) {
// Use standard modern web crypto if available
this.logger.verbose("BrowserCrypto: modern crypto interface available");
this.subtleCrypto = new ModernBrowserCrypto();
}
else if (this.hasIECrypto()) {
// For IE11, use msCrypto interface
this.logger.verbose("BrowserCrypto: MS crypto interface available");
this.subtleCrypto = new MsBrowserCrypto();
}
else if (this.hasMsrCrypto() && ((_a = this.cryptoOptions) === null || _a === void 0 ? void 0 : _a.useMsrCrypto)) {
// For other browsers, use MSR Crypto if found
this.logger.verbose("BrowserCrypto: MSR crypto interface available");
this.subtleCrypto = new MsrBrowserCrypto();
}
else {
if (this.hasMsrCrypto()) {
this.logger.info("BrowserCrypto: MSR Crypto interface available but system.cryptoOptions.useMsrCrypto not enabled");
}
this.logger.error("BrowserCrypto: No crypto interfaces available.");
throw BrowserAuthError.createCryptoNotAvailableError("Browser crypto, msCrypto, or msrCrypto interfaces not available.");
}
// Mainly needed for MSR Crypto: https://github.com/microsoft/MSR-JavaScript-Crypto#random-number-generator-prng
if (this.subtleCrypto.initPrng) {
this.logger.verbose("BrowserCrypto: Interface requires entropy");
if (!((_b = this.cryptoOptions) === null || _b === void 0 ? void 0 : _b.entropy)) {
this.logger.error("BrowserCrypto: Interface requires entropy but none provided.");
throw BrowserConfigurationAuthError.createEntropyNotProvided();
}
this.logger.verbose("BrowserCrypto: Entropy provided");
this.subtleCrypto.initPrng(this.cryptoOptions.entropy);
}
this.keygenAlgorithmOptions = {
name: PKCS1_V15_KEYGEN_ALG,
hash: S256_HASH_ALG,
modulusLength: MODULUS_LENGTH,
publicExponent: PUBLIC_EXPONENT
};
}
/**
* Check whether IE crypto or other browser cryptography is available.
*/
BrowserCrypto.prototype.hasIECrypto = function () {
return "msCrypto" in window;
};
/**
* Check whether browser crypto is available.
*/
BrowserCrypto.prototype.hasBrowserCrypto = function () {
return "crypto" in window;
};
/**
* Check whether MSR crypto polyfill is available
*/
BrowserCrypto.prototype.hasMsrCrypto = function () {
return "msrCrypto" in window;
};
/**
* Returns a sha-256 hash of the given dataString as an ArrayBuffer.
* @param dataString
*/
BrowserCrypto.prototype.sha256Digest = function (dataString) {
return __awaiter(this, void 0, void 0, function () {
var data;
return __generator(this, function (_a) {
data = BrowserStringUtils.stringToUtf8Arr(dataString);
// MSR Crypto wants object with name property, instead of string
return [2 /*return*/, this.subtleCrypto.digest({ name: S256_HASH_ALG }, data)];
});
});
};
/**
* Populates buffer with cryptographically random values.
* @param dataBuffer
*/
BrowserCrypto.prototype.getRandomValues = function (dataBuffer) {
return this.subtleCrypto.getRandomValues(dataBuffer);
};
/**
* Generates a keypair based on current keygen algorithm config.
* @param extractable
* @param usages
*/
BrowserCrypto.prototype.generateKeyPair = function (extractable, usages) {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2 /*return*/, this.subtleCrypto.generateKey(this.keygenAlgorithmOptions, extractable, usages)];
});
});
};
/**
* Export key as Json Web Key (JWK)
* @param key
* @param format
*/
BrowserCrypto.prototype.exportJwk = function (key) {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2 /*return*/, this.subtleCrypto.exportKey(key)];
});
});
};
/**
* Imports key as Json Web Key (JWK), can set extractable and usages.
* @param key
* @param format
* @param extractable
* @param usages
*/
BrowserCrypto.prototype.importJwk = function (key, extractable, usages) {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2 /*return*/, this.subtleCrypto.importKey(key, this.keygenAlgorithmOptions, extractable, usages)];
});
});
};
/**
* Signs given data with given key
* @param key
* @param data
*/
BrowserCrypto.prototype.sign = function (key, data) {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2 /*return*/, this.subtleCrypto.sign(this.keygenAlgorithmOptions, key, data)];
});
});
};
return BrowserCrypto;
}());
export { BrowserCrypto };
//# sourceMappingURL=BrowserCrypto.js.map
{"version":3,"file":"BrowserCrypto.js","sources":["../../src/crypto/BrowserCrypto.ts"],"sourcesContent":["/*\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { BrowserStringUtils } from \"../utils/BrowserStringUtils\";\nimport { BrowserAuthError } from \"../error/BrowserAuthError\";\nimport { ISubtleCrypto } from \"./ISubtleCrypto\";\nimport { ModernBrowserCrypto } from \"./ModernBrowserCrypto\";\nimport { MsrBrowserCrypto } from \"./MsrBrowserCrypto\";\nimport { MsBrowserCrypto } from \"./MsBrowserCrypto\";\nimport { Logger } from \"@azure/msal-common\";\nimport { BrowserConfigurationAuthError } from \"../error/BrowserConfigurationAuthError\";\nimport { CryptoOptions } from \"../config/Configuration\";\n/**\n * See here for more info on RsaHashedKeyGenParams: https://developer.mozilla.org/en-US/docs/Web/API/RsaHashedKeyGenParams\n */\n// RSA KeyGen Algorithm\nconst PKCS1_V15_KEYGEN_ALG = \"RSASSA-PKCS1-v1_5\";\n// SHA-256 hashing algorithm\nconst S256_HASH_ALG = \"SHA-256\";\n// MOD length for PoP tokens\nconst MODULUS_LENGTH = 2048;\n// Public Exponent\nconst PUBLIC_EXPONENT: Uint8Array = new Uint8Array([0x01, 0x00, 0x01]);\n\n/**\n * This class implements functions used by the browser library to perform cryptography operations such as\n * hashing and encoding. It also has helper functions to validate the availability of specific APIs.\n */\nexport class BrowserCrypto {\n\n private keygenAlgorithmOptions: RsaHashedKeyGenParams;\n private subtleCrypto: ISubtleCrypto;\n private logger: Logger;\n private cryptoOptions?: CryptoOptions;\n\n constructor(logger: Logger, cryptoOptions?: CryptoOptions) {\n this.logger = logger;\n this.cryptoOptions = cryptoOptions;\n\n if (this.hasBrowserCrypto()) {\n // Use standard modern web crypto if available\n this.logger.verbose(\"BrowserCrypto: modern crypto interface available\");\n this.subtleCrypto = new ModernBrowserCrypto();\n } else if (this.hasIECrypto()) {\n // For IE11, use msCrypto interface\n this.logger.verbose(\"BrowserCrypto: MS crypto interface available\");\n this.subtleCrypto = new MsBrowserCrypto();\n } else if (this.hasMsrCrypto() && this.cryptoOptions?.useMsrCrypto) {\n // For other browsers, use MSR Crypto if found\n this.logger.verbose(\"BrowserCrypto: MSR crypto interface available\");\n this.subtleCrypto = new MsrBrowserCrypto();\n } else {\n if (this.hasMsrCrypto()) {\n this.logger.info(\"BrowserCrypto: MSR Crypto interface available but system.cryptoOptions.useMsrCrypto not enabled\");\n }\n this.logger.error(\"BrowserCrypto: No crypto interfaces available.\");\n throw BrowserAuthError.createCryptoNotAvailableError(\"Browser crypto, msCrypto, or msrCrypto interfaces not available.\");\n }\n\n // Mainly needed for MSR Crypto: https://github.com/microsoft/MSR-JavaScript-Crypto#random-number-generator-prng\n if (this.subtleCrypto.initPrng) {\n this.logger.verbose(\"BrowserCrypto: Interface requires entropy\");\n\n if (!this.cryptoOptions?.entropy) {\n this.logger.error(\"BrowserCrypto: Interface requires entropy but none provided.\");\n throw BrowserConfigurationAuthError.createEntropyNotProvided();\n }\n\n this.logger.verbose(\"BrowserCrypto: Entropy provided\");\n this.subtleCrypto.initPrng(this.cryptoOptions.entropy);\n }\n\n this.keygenAlgorithmOptions = {\n name: PKCS1_V15_KEYGEN_ALG,\n hash: S256_HASH_ALG,\n modulusLength: MODULUS_LENGTH,\n publicExponent: PUBLIC_EXPONENT\n };\n }\n\n /**\n * Check whether IE crypto or other browser cryptography is available.\n */\n private hasIECrypto(): boolean {\n return \"msCrypto\" in window;\n }\n\n /**\n * Check whether browser crypto is available.\n */\n private hasBrowserCrypto(): boolean {\n return \"crypto\" in window;\n }\n\n /**\n * Check whether MSR crypto polyfill is available\n */\n private hasMsrCrypto(): boolean {\n return \"msrCrypto\" in window;\n }\n\n /**\n * Returns a sha-256 hash of the given dataString as an ArrayBuffer.\n * @param dataString \n */\n async sha256Digest(dataString: string): Promise<ArrayBuffer> {\n const data = BrowserStringUtils.stringToUtf8Arr(dataString);\n // MSR Crypto wants object with name property, instead of string\n return this.subtleCrypto.digest({ name: S256_HASH_ALG }, data);\n }\n\n /**\n * Populates buffer with cryptographically random values.\n * @param dataBuffer \n */\n getRandomValues(dataBuffer: Uint8Array): Uint8Array {\n return this.subtleCrypto.getRandomValues(dataBuffer);\n }\n\n /**\n * Generates a keypair based on current keygen algorithm config.\n * @param extractable \n * @param usages \n */\n async generateKeyPair(extractable: boolean, usages: Array<KeyUsage>): Promise<CryptoKeyPair> {\n return this.subtleCrypto.generateKey(this.keygenAlgorithmOptions, extractable, usages);\n }\n\n /**\n * Export key as Json Web Key (JWK)\n * @param key \n * @param format \n */\n async exportJwk(key: CryptoKey): Promise<JsonWebKey> {\n return this.subtleCrypto.exportKey(key);\n }\n\n /**\n * Imports key as Json Web Key (JWK), can set extractable and usages.\n * @param key \n * @param format \n * @param extractable \n * @param usages \n */\n async importJwk(key: JsonWebKey, extractable: boolean, usages: Array<KeyUsage>): Promise<CryptoKey> {\n return this.subtleCrypto.importKey(key, this.keygenAlgorithmOptions, extractable, usages);\n }\n\n /**\n * Signs given data with given key\n * @param key \n * @param data \n */\n async sign(key: CryptoKey, data: ArrayBuffer): Promise<ArrayBuffer> {\n return this.subtleCrypto.sign(this.keygenAlgorithmOptions, key, data);\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;AAAA;;;;AAcA;;;AAGA;AACA,IAAM,oBAAoB,GAAG,mBAAmB,CAAC;AACjD;AACA,IAAM,aAAa,GAAG,SAAS,CAAC;AAChC;AACA,IAAM,cAAc,GAAG,IAAI,CAAC;AAC5B;AACA,IAAM,eAAe,GAAe,IAAI,UAAU,CAAC,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;AAEvE;;;;;IAWI,uBAAY,MAAc,EAAE,aAA6B;;QACrD,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;QAEnC,IAAI,IAAI,CAAC,gBAAgB,EAAE,EAAE;;YAEzB,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,kDAAkD,CAAC,CAAC;YACxE,IAAI,CAAC,YAAY,GAAG,IAAI,mBAAmB,EAAE,CAAC;SACjD;aAAM,IAAI,IAAI,CAAC,WAAW,EAAE,EAAE;;YAE3B,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,8CAA8C,CAAC,CAAC;YACpE,IAAI,CAAC,YAAY,GAAG,IAAI,eAAe,EAAE,CAAC;SAC7C;aAAM,IAAI,IAAI,CAAC,YAAY,EAAE,WAAI,IAAI,CAAC,aAAa,0CAAE,YAAY,CAAA,EAAE;;YAEhE,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,+CAA+C,CAAC,CAAC;YACrE,IAAI,CAAC,YAAY,GAAG,IAAI,gBAAgB,EAAE,CAAC;SAC9C;aAAM;YACH,IAAI,IAAI,CAAC,YAAY,EAAE,EAAE;gBACrB,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,iGAAiG,CAAC,CAAC;aACvH;YACD,IAAI,CAAC,MAAM,CAAC,KAAK,CAA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AOK,uCAAe,GAArB,UAAsB,WAAoB,EAAE,MAAuB;;;gBAC/D,sBAAO,IAAI,CAAC,YAAY,CAAC,WAAW,CAAC,IAAI,CAAC,sBAAsB,EAAE,WAAW,EAAE,MAAM,CAAC,EAAC;;;KAC1F;;;;;;IAOK,iCAAS,GAAf,UAAgB,GAAc;;;gBAC1B,sBAAO,IAAI,CAAC,YAAY,CAAC,SAAS,CAAC,GAAG,CAAC,EAAC;;;KAC3C;;;;;;;;IASK,iCAAS,GAAf,UAAgB,GAAe,EAAE,WAAoB,EAAE,MAAuB;;;gBAC1E,sBAAO,IAAI,CAAC,YAAY,CAAC,SAAS,CAAC,GAAG,EAAE,IAAI,CAAC,sBAAsB,EAAE,WAAW,EAAE,MAAM,CAAC,EAAC;;;KAC7F;;;;;;IAOK,4BAAI,GAAV,UAAW,GAAc,EAAE,IAAiB;;;gBACxC,sBAAO,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,sBAAsB,EAAE,GAAG,EAAE,IAAI,CAAC,EAAC;;;KACzE;IACL,oBAAC;AAAD,CAAC;;;;"}
\ No newline at end of file
import { ICrypto, IPerformanceClient, Logger, PkceCodes, SignedHttpRequest, SignedHttpRequestParameters } from "@azure/msal-common";
import { CryptoOptions } from "../config/Configuration";
export declare type CachedKeyPair = {
publicKey: CryptoKey;
privateKey: CryptoKey;
requestMethod?: string;
requestUri?: string;
};
/**
* This class implements MSAL's crypto interface, which allows it to perform base64 encoding and decoding, generating cryptographically random GUIDs and
* implementing Proof Key for Code Exchange specs for the OAuth Authorization Code Flow using PKCE (rfc here: https://tools.ietf.org/html/rfc7636).
*/
export declare class CryptoOps implements ICrypto {
private browserCrypto;
private guidGenerator;
private b64Encode;
private b64Decode;
private pkceGenerator;
private logger;
/**
* CryptoOps can be used in contexts outside a PCA instance,
* meaning there won't be a performance manager available.
*/
private performanceClient;
private static POP_KEY_USAGES;
private static EXTRACTABLE;
private cache;
constructor(logger: Logger, performanceClient?: IPerformanceClient, cryptoConfig?: CryptoOptions);
/**
* Creates a new random GUID - used to populate state and nonce.
* @returns string (GUID)
*/
createNewGuid(): string;
/**
* Encodes input string to base64.
* @param input
*/
base64Encode(input: string): string;
/**
* Decodes input string from base64.
* @param input
*/
base64Decode(input: string): string;
/**
* Generates PKCE codes used in Authorization Code Flow.
*/
generatePkceCodes(): Promise<PkceCodes>;
/**
* Generates a keypair, stores it and returns a thumbprint
* @param request
*/
getPublicKeyThumbprint(request: SignedHttpRequestParameters): Promise<string>;
/**
* Removes cryptographic keypair from key store matching the keyId passed in
* @param kid
*/
removeTokenBindingKey(kid: string): Promise<boolean>;
/**
* Removes all cryptographic keys from IndexedDB storage
*/
clearKeystore(): Promise<boolean>;
/**
* Signs the given object as a jwt payload with private key retrieved by given kid.
* @param payload
* @param kid
*/
signJwt(payload: SignedHttpRequest, kid: string, correlationId?: string): Promise<string>;
/**
* Returns the SHA-256 hash of an input string
* @param plainText
*/
hashString(plainText: string): Promise<string>;
}
//# sourceMappingURL=CryptoOps.d.ts.map
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment