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

Initial commit

parents
{"version":3,"file":"OpenIdConfigResponse.d.ts","sourceRoot":"","sources":["../../src/authority/OpenIdConfigResponse.ts"],"names":[],"mappings":"AAKA;;GAEG;AACH,oBAAY,oBAAoB,GAAG;IAC/B,sBAAsB,EAAE,MAAM,CAAC;IAC/B,cAAc,EAAE,MAAM,CAAC;IACvB,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,wBAAgB,sBAAsB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAOhE"}
\ No newline at end of file
/*! @azure/msal-common v9.0.1 2022-12-07 */
'use strict';
/*
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License.
*/
function isOpenIdConfigResponse(response) {
return (response.hasOwnProperty("authorization_endpoint") &&
response.hasOwnProperty("token_endpoint") &&
response.hasOwnProperty("issuer") &&
response.hasOwnProperty("jwks_uri"));
}
export { isOpenIdConfigResponse };
//# sourceMappingURL=OpenIdConfigResponse.js.map
{"version":3,"file":"OpenIdConfigResponse.js","sources":["../../src/authority/OpenIdConfigResponse.ts"],"sourcesContent":["/*\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/**\n * Tenant Discovery Response which contains the relevant OAuth endpoints and data needed for authentication and authorization.\n */\nexport type OpenIdConfigResponse = {\n authorization_endpoint: string;\n token_endpoint: string;\n end_session_endpoint?: string;\n issuer: string;\n jwks_uri: string;\n};\n\nexport function isOpenIdConfigResponse(response: object): boolean {\n return (\n response.hasOwnProperty(\"authorization_endpoint\") &&\n response.hasOwnProperty(\"token_endpoint\") && \n response.hasOwnProperty(\"issuer\") &&\n response.hasOwnProperty(\"jwks_uri\")\n );\n}\n"],"names":[],"mappings":";;AAAA;;;AAGG;AAaG,SAAU,sBAAsB,CAAC,QAAgB,EAAA;AACnD,IAAA,QACI,QAAQ,CAAC,cAAc,CAAC,wBAAwB,CAAC;AACjD,QAAA,QAAQ,CAAC,cAAc,CAAC,gBAAgB,CAAC;AACzC,QAAA,QAAQ,CAAC,cAAc,CAAC,QAAQ,CAAC;AACjC,QAAA,QAAQ,CAAC,cAAc,CAAC,UAAU,CAAC,EACrC;AACN;;;;"}
\ No newline at end of file
{"version":3,"file":"ProtocolMode.d.ts","sourceRoot":"","sources":["../../src/authority/ProtocolMode.ts"],"names":[],"mappings":"AAKA;;GAEG;AACH,oBAAY,YAAY;IACpB,GAAG,QAAQ;IACX,IAAI,SAAS;CAChB"}
\ No newline at end of file
/*! @azure/msal-common v9.0.1 2022-12-07 */
'use strict';
/*
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License.
*/
/**
* Protocol modes supported by MSAL.
*/
var ProtocolMode;
(function (ProtocolMode) {
ProtocolMode["AAD"] = "AAD";
ProtocolMode["OIDC"] = "OIDC";
})(ProtocolMode || (ProtocolMode = {}));
export { ProtocolMode };
//# sourceMappingURL=ProtocolMode.js.map
{"version":3,"file":"ProtocolMode.js","sources":["../../src/authority/ProtocolMode.ts"],"sourcesContent":["/*\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/**\n * Protocol modes supported by MSAL.\n */\nexport enum ProtocolMode {\n AAD = \"AAD\",\n OIDC = \"OIDC\"\n}\n"],"names":[],"mappings":";;AAAA;;;AAGG;AAEH;;AAEG;IACS,aAGX;AAHD,CAAA,UAAY,YAAY,EAAA;AACpB,IAAA,YAAA,CAAA,KAAA,CAAA,GAAA,KAAW,CAAA;AACX,IAAA,YAAA,CAAA,MAAA,CAAA,GAAA,MAAa,CAAA;AACjB,CAAC,EAHW,YAAY,KAAZ,YAAY,GAGvB,EAAA,CAAA,CAAA;;;;"}
\ No newline at end of file
{"version":3,"file":"RegionDiscovery.d.ts","sourceRoot":"","sources":["../../src/authority/RegionDiscovery.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAI3D,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AACpE,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C,qBAAa,eAAe;IAExB,SAAS,CAAC,gBAAgB,EAAE,cAAc,CAAC;IAE3C,SAAS,CAAC,MAAM,CAAC,YAAY,EAAE,WAAW,CAIxC;gBAEU,gBAAgB,EAAE,cAAc;IAI5C;;;;OAIG;IACU,YAAY,CAAC,iBAAiB,EAAE,MAAM,GAAG,SAAS,EAAE,uBAAuB,EAAE,uBAAuB,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IAgD5J;;;;;OAKG;YACW,iBAAiB;IAI/B;;;;OAIG;YACW,iBAAiB;CAclC"}
\ No newline at end of file
/*! @azure/msal-common v9.0.1 2022-12-07 */
'use strict';
import { __awaiter, __generator } from '../_virtual/_tslib.js';
import { RegionDiscoverySources, ResponseCodes, Constants } from '../utils/Constants.js';
/*
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License.
*/
var RegionDiscovery = /** @class */ (function () {
function RegionDiscovery(networkInterface) {
this.networkInterface = networkInterface;
}
/**
* Detect the region from the application's environment.
*
* @returns Promise<string | null>
*/
RegionDiscovery.prototype.detectRegion = function (environmentRegion, regionDiscoveryMetadata, proxyUrl) {
return __awaiter(this, void 0, void 0, function () {
var autodetectedRegionName, options, localIMDSVersionResponse, currentIMDSVersion, currentIMDSVersionResponse;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
autodetectedRegionName = environmentRegion;
if (!!autodetectedRegionName) return [3 /*break*/, 8];
options = RegionDiscovery.IMDS_OPTIONS;
if (proxyUrl) {
options.proxyUrl = proxyUrl;
}
_a.label = 1;
case 1:
_a.trys.push([1, 6, , 7]);
return [4 /*yield*/, this.getRegionFromIMDS(Constants.IMDS_VERSION, options)];
case 2:
localIMDSVersionResponse = _a.sent();
if (localIMDSVersionResponse.status === ResponseCodes.httpSuccess) {
autodetectedRegionName = localIMDSVersionResponse.body;
regionDiscoveryMetadata.region_source = RegionDiscoverySources.IMDS;
}
if (!(localIMDSVersionResponse.status === ResponseCodes.httpBadRequest)) return [3 /*break*/, 5];
return [4 /*yield*/, this.getCurrentVersion(options)];
case 3:
currentIMDSVersion = _a.sent();
if (!currentIMDSVersion) {
regionDiscoveryMetadata.region_source = RegionDiscoverySources.FAILED_AUTO_DETECTION;
return [2 /*return*/, null];
}
return [4 /*yield*/, this.getRegionFromIMDS(currentIMDSVersion, options)];
case 4:
currentIMDSVersionResponse = _a.sent();
if (currentIMDSVersionResponse.status === ResponseCodes.httpSuccess) {
autodetectedRegionName = currentIMDSVersionResponse.body;
regionDiscoveryMetadata.region_source = RegionDiscoverySources.IMDS;
}
_a.label = 5;
case 5: return [3 /*break*/, 7];
case 6:
_a.sent();
regionDiscoveryMetadata.region_source = RegionDiscoverySources.FAILED_AUTO_DETECTION;
return [2 /*return*/, null];
case 7: return [3 /*break*/, 9];
case 8:
regionDiscoveryMetadata.region_source = RegionDiscoverySources.ENVIRONMENT_VARIABLE;
_a.label = 9;
case 9:
// If no region was auto detected from the environment or from the IMDS endpoint, mark the attempt as a FAILED_AUTO_DETECTION
if (!autodetectedRegionName) {
regionDiscoveryMetadata.region_source = RegionDiscoverySources.FAILED_AUTO_DETECTION;
}
return [2 /*return*/, autodetectedRegionName || null];
}
});
});
};
/**
* Make the call to the IMDS endpoint
*
* @param imdsEndpointUrl
* @returns Promise<NetworkResponse<string>>
*/
RegionDiscovery.prototype.getRegionFromIMDS = function (version, options) {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2 /*return*/, this.networkInterface.sendGetRequestAsync(Constants.IMDS_ENDPOINT + "?api-version=" + version + "&format=text", options, Constants.IMDS_TIMEOUT)];
});
});
};
/**
* Get the most recent version of the IMDS endpoint available
*
* @returns Promise<string | null>
*/
RegionDiscovery.prototype.getCurrentVersion = function (options) {
return __awaiter(this, void 0, void 0, function () {
var response;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
_a.trys.push([0, 2, , 3]);
return [4 /*yield*/, this.networkInterface.sendGetRequestAsync(Constants.IMDS_ENDPOINT + "?format=json", options)];
case 1:
response = _a.sent();
// When IMDS endpoint is called without the api version query param, bad request response comes back with latest version.
if (response.status === ResponseCodes.httpBadRequest && response.body && response.body["newest-versions"] && response.body["newest-versions"].length > 0) {
return [2 /*return*/, response.body["newest-versions"][0]];
}
return [2 /*return*/, null];
case 2:
_a.sent();
return [2 /*return*/, null];
case 3: return [2 /*return*/];
}
});
});
};
// Options for the IMDS endpoint request
RegionDiscovery.IMDS_OPTIONS = {
headers: {
Metadata: "true",
},
};
return RegionDiscovery;
}());
export { RegionDiscovery };
//# sourceMappingURL=RegionDiscovery.js.map
{"version":3,"file":"RegionDiscovery.js","sources":["../../src/authority/RegionDiscovery.ts"],"sourcesContent":["/*\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { INetworkModule } from \"../network/INetworkModule\";\nimport { NetworkResponse } from \"../network/NetworkManager\";\nimport { IMDSBadResponse } from \"../response/IMDSBadResponse\";\nimport { Constants, RegionDiscoverySources, ResponseCodes } from \"../utils/Constants\";\nimport { RegionDiscoveryMetadata } from \"./RegionDiscoveryMetadata\";\nimport { ImdsOptions } from \"./ImdsOptions\";\n\nexport class RegionDiscovery {\n // Network interface to make requests with.\n protected networkInterface: INetworkModule;\n // Options for the IMDS endpoint request\n protected static IMDS_OPTIONS: ImdsOptions = {\n headers: {\n Metadata: \"true\",\n },\n };\n\n constructor(networkInterface: INetworkModule) {\n this.networkInterface = networkInterface;\n }\n\n /**\n * Detect the region from the application's environment.\n * \n * @returns Promise<string | null>\n */\n public async detectRegion(environmentRegion: string | undefined, regionDiscoveryMetadata: RegionDiscoveryMetadata, proxyUrl: string): Promise<string | null> {\n // Initialize auto detected region with the region from the envrionment \n let autodetectedRegionName = environmentRegion;\n\n // Check if a region was detected from the environment, if not, attempt to get the region from IMDS \n if (!autodetectedRegionName) {\n const options = RegionDiscovery.IMDS_OPTIONS;\n if (proxyUrl) {\n options.proxyUrl = proxyUrl;\n }\n\n try {\n const localIMDSVersionResponse = await this.getRegionFromIMDS(Constants.IMDS_VERSION, options);\n if (localIMDSVersionResponse.status === ResponseCodes.httpSuccess) {\n autodetectedRegionName = localIMDSVersionResponse.body;\n regionDiscoveryMetadata.region_source = RegionDiscoverySources.IMDS;\n } \n \n // If the response using the local IMDS version failed, try to fetch the current version of IMDS and retry. \n if (localIMDSVersionResponse.status === ResponseCodes.httpBadRequest) {\n const currentIMDSVersion = await this.getCurrentVersion(options);\n if (!currentIMDSVersion) {\n regionDiscoveryMetadata.region_source = RegionDiscoverySources.FAILED_AUTO_DETECTION;\n return null;\n }\n\n const currentIMDSVersionResponse = await this.getRegionFromIMDS(currentIMDSVersion, options);\n if (currentIMDSVersionResponse.status === ResponseCodes.httpSuccess) {\n autodetectedRegionName = currentIMDSVersionResponse.body;\n regionDiscoveryMetadata.region_source = RegionDiscoverySources.IMDS;\n }\n }\n } catch(e) {\n regionDiscoveryMetadata.region_source = RegionDiscoverySources.FAILED_AUTO_DETECTION;\n return null;\n } \n } else {\n regionDiscoveryMetadata.region_source = RegionDiscoverySources.ENVIRONMENT_VARIABLE;\n }\n\n // If no region was auto detected from the environment or from the IMDS endpoint, mark the attempt as a FAILED_AUTO_DETECTION\n if (!autodetectedRegionName) {\n regionDiscoveryMetadata.region_source = RegionDiscoverySources.FAILED_AUTO_DETECTION;\n }\n\n return autodetectedRegionName || null;\n }\n\n /**\n * Make the call to the IMDS endpoint\n * \n * @param imdsEndpointUrl\n * @returns Promise<NetworkResponse<string>>\n */\n private async getRegionFromIMDS(version: string, options: ImdsOptions): Promise<NetworkResponse<string>> {\n return this.networkInterface.sendGetRequestAsync<string>(`${Constants.IMDS_ENDPOINT}?api-version=${version}&format=text`, options, Constants.IMDS_TIMEOUT);\n }\n\n /**\n * Get the most recent version of the IMDS endpoint available\n * \n * @returns Promise<string | null>\n */\n private async getCurrentVersion(options: ImdsOptions): Promise<string | null> {\n try {\n const response = await this.networkInterface.sendGetRequestAsync<IMDSBadResponse>(`${Constants.IMDS_ENDPOINT}?format=json`, options);\n\n // When IMDS endpoint is called without the api version query param, bad request response comes back with latest version.\n if (response.status === ResponseCodes.httpBadRequest && response.body && response.body[\"newest-versions\"] && response.body[\"newest-versions\"].length > 0) {\n return response.body[\"newest-versions\"][0];\n }\n\n return null;\n } catch (e) {\n return null;\n }\n }\n}\n"],"names":[],"mappings":";;;;;AAAA;;;AAGG;AASH,IAAA,eAAA,kBAAA,YAAA;AAUI,IAAA,SAAA,eAAA,CAAY,gBAAgC,EAAA;AACxC,QAAA,IAAI,CAAC,gBAAgB,GAAG,gBAAgB,CAAC;KAC5C;AAED;;;;AAIG;AACU,IAAA,eAAA,CAAA,SAAA,CAAA,YAAY,GAAzB,UAA0B,iBAAqC,EAAE,uBAAgD,EAAE,QAAgB,EAAA;;;;;;wBAE3H,sBAAsB,GAAG,iBAAiB,CAAC;6BAG3C,CAAC,sBAAsB,EAAvB,OAAuB,CAAA,CAAA,YAAA,CAAA,CAAA,CAAA;AACjB,wBAAA,OAAO,GAAG,eAAe,CAAC,YAAY,CAAC;AAC7C,wBAAA,IAAI,QAAQ,EAAE;AACV,4BAAA,OAAO,CAAC,QAAQ,GAAG,QAAQ,CAAC;AAC/B,yBAAA;;;;wBAGoC,OAAM,CAAA,CAAA,YAAA,IAAI,CAAC,iBAAiB,CAAC,SAAS,CAAC,YAAY,EAAE,OAAO,CAAC,CAAA,CAAA;;AAAxF,wBAAA,wBAAwB,GAAG,EAA6D,CAAA,IAAA,EAAA,CAAA;AAC9F,wBAAA,IAAI,wBAAwB,CAAC,MAAM,KAAK,aAAa,CAAC,WAAW,EAAE;AAC/D,4BAAA,sBAAsB,GAAG,wBAAwB,CAAC,IAAI,CAAC;AACv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AAA;AAAA,CAhGD,EAgGC;;;;"}
\ No newline at end of file
{"version":3,"file":"RegionDiscoveryMetadata.d.ts","sourceRoot":"","sources":["../../src/authority/RegionDiscoveryMetadata.ts"],"names":[],"mappings":"AAKA,OAAO,EACH,uBAAuB,EACvB,sBAAsB,EACzB,MAAM,oBAAoB,CAAC;AAE5B,oBAAY,uBAAuB,GAAG;IAClC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,aAAa,CAAC,EAAE,sBAAsB,CAAC;IACvC,cAAc,CAAC,EAAE,uBAAuB,CAAC;CAC5C,CAAC"}
\ No newline at end of file
{"version":3,"file":"CacheManager.d.ts","sourceRoot":"","sources":["../../src/cache/CacheManager.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,gBAAgB,EAAE,eAAe,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAC9J,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAErD,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAE/D,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AAEnE,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAE1D,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,EAAE,qBAAqB,EAAE,MAAM,kCAAkC,CAAC;AACzE,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAE/D,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAE,uBAA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IAAI;IAI5B,oBAAoB,IAAI,aAAa;IAIrC,wBAAwB,IAAI,IAAI;IAIhC,wBAAwB,IAAI,iBAAiB;IAI7C,yBAAyB,IAAI,IAAI;IAIjC,yBAAyB,IAAI,kBAAkB;IAI/C,cAAc,IAAI,IAAI;IAItB,cAAc,IAAI,iBAAiB;IAInC,kBAAkB,IAAI,IAAI;IAI1B,kBAAkB,IAAI,qBAAqB;IAI3C,oBAAoB,IAAI,IAAI;IAI5B,oBAAoB,IAAI,uBAAuB,GAAG,IAAI;IAItD,wBAAwB,IAAI,KAAK,CAAC,MAAM,CAAC;IAIzC,kBAAkB,IAAI,IAAI;IAI1B,kBAAkB,IAAI,gBAAgB;IAItC,UAAU,IAAI,OAAO;IAIrB,WAAW,IAAI,OAAO;IAItB,OAAO,IAAI,MAAM,EAAE;IAIb,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAI5B,wBAAwB,IAAI,MAAM;CAIrC"}
\ No newline at end of file
/*! @azure/msal-common v9.0.1 2022-12-07 */
'use strict';
import { __awaiter, __generator, __extends } from '../_virtual/_tslib.js';
import { Constants, CredentialType, AuthenticationScheme, CacheSchemaType, THE_FAMILY_ID, APP_METADATA, AUTHORITY_METADATA_CONSTANTS } from '../utils/Constants.js';
import { CredentialEntity } from './entities/CredentialEntity.js';
import { ScopeSet } from '../request/ScopeSet.js';
import { AccountEntity } from './entities/AccountEntity.js';
import { AuthError } from '../error/AuthError.js';
import { ClientAuthError } from '../error/ClientAuthError.js';
import { AuthToken } from '../account/AuthToken.js';
/*
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License.
*/
/**
* Interface class which implement cache storage functions used by MSAL to perform validity checks, and store tokens.
*/
var CacheManager = /** @class */ (function () {
function CacheManager(clientId, cryptoImpl) {
this.clientId = clientId;
this.cryptoImpl = cryptoImpl;
}
/**
* Returns all accounts in cache
*/
CacheManager.prototype.getAllAccounts = function () {
var _this = this;
var currentAccounts = this.getAccountsFilteredBy();
var accountValues = Object.keys(currentAccounts).map(function (accountKey) { return currentAccounts[accountKey]; });
var numAccounts = accountValues.length;
if (numAccounts < 1) {
return [];
}
else {
var allAccounts = accountValues.map(function (value) {
var accountEntity = CacheManager.toObject(new AccountEntity(), value);
var accountInfo = accountEntity.getAccountInfo();
var idToken = _this.readIdTokenFromCache(_this.clientId, accountInfo);
if (idToken && !accountInfo.idTokenClaims) {
accountInfo.idToken = idToken.secret;
accountInfo.idTokenClaims = new AuthToken(idToken.secret, _this.cryptoImpl).claims;
}
return accountInfo;
});
return allAccounts;
}
};
/**
* saves a cache record
* @param cacheRecord
*/
CacheManager.prototype.saveCacheRecord = function (cacheRecord) {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
if (!cacheRecord) {
throw ClientAuthError.createNullOrUndefinedCacheRecord();
}
if (!!cacheRecord.account) {
this.setAccount(cacheRecord.account);
}
if (!!cacheRecord.idToken) {
this.setIdTokenCredential(cacheRecord.idToken);
}
if (!!!cacheRecord.accessToken) return [3 /*break*/, 2];
return [4 /*yield*/, this.saveAccessToken(cacheRecord.accessToken)];
case 1:
_a.sent();
_a.label = 2;
case 2:
if (!!cacheRecord.refreshToken) {
this.setRefreshTokenCredential(cacheRecord.refreshToken);
}
if (!!cacheRecord.appMetadata) {
this.setAppMetadata(cacheRecord.appMetadata);
}
return [2 /*return*/];
}
});
});
};
/**
* saves access token credential
* @param credential
*/
CacheManager.prototype.saveAccessToken = function (credential) {
return __awaiter(this, void 0, void 0, function () {
var currentTokenCache, currentScopes, currentAccessTokens, removedAccessTokens_1;
var _this = this;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
currentTokenCache = this.getCredentialsFilteredBy({
clientId: credential.clientId,
credentialType: credential.credentialType,
environment: credential.environment,
homeAccountId: credential.homeAccountId,
realm: credential.realm,
tokenType: credential.tokenType,
requestedClaimsHash: credential.requestedClaimsHash
});
currentScopes = ScopeSet.fromString(credential.target);
currentAccessTokens = Object.keys(currentTokenCache.accessTokens).map(function (key) { return currentTokenCache.accessTokens[key]; });
if (!currentAccessTokens) return [3 /*break*/, 2];
removedAccessTokens_1 = [];
currentAccessTokens.forEach(function (tokenEntity) {
var tokenScopeSet = ScopeSet.fromString(tokenEntity.target);
if (tokenScopeSet.intersectingScopeSets(currentScopes)) {
removedAccessTokens_1.push(_this.removeCredential(tokenEntity));
}
});
return [4 /*yield*/, Promise.all(removedAccessTokens_1)];
case 1:
_a.sent();
_a.label = 2;
case 2:
this.setAccessTokenCredential(credential);
return [2 /*return*/];
}
});
});
};
/**
* retrieve accounts matching all provided filters; if no filter is set, get all accounts
* not checking for casing as keys are all generated in lower case, remember to convert to lower case if object properties are compared
* @param homeAccountId
* @param environment
* @param realm
*/
CacheManager.prototype.getAccountsFilteredBy = function (accountFilter) {
return this.getAccountsFilteredByInternal(accountFilter ? accountFilter.homeAccountId : Constants.EMPTY_STRING, accountFilter ? accountFilter.environment : Constants.EMPTY_STRING, accountFilter ? accountFilter.realm : Constants.EMPTY_STRING, accountFilter ? accountFilter.nativeAccountId : Constants.EMPTY_STRING);
};
/**
* retrieve accounts matching all provided filters; if no filter is set, get all accounts
* not checking for casing as keys are all generated in lower case, remember to convert to lower case if object properties are compared
* @param homeAccountId
* @param environment
* @param realm
*/
CacheManager.prototype.getAccountsFilteredByInternal = function (homeAccountId, environment, realm, nativeAccountId) {
var _this = this;
var allCacheKeys = this.getKeys();
var matchingAccounts = {};
allCacheKeys.forEach(function (cacheKey) {
var entity = _this.getAccount(cacheKey);
if (!entity) {
return;
}
if (!!homeAccountId && !_this.matchHomeAccountId(entity, homeAccountId)) {
return;
}
if (!!environment && !_this.matchEnvironment(entity, environment)) {
return;
}
if (!!realm && !_this.matchRealm(entity, realm)) {
return;
}
if (!!nativeAccountId && !_this.matchNativeAccountId(entity, nativeAccountId)) {
return;
}
matchingAccounts[cacheKey] = entity;
});
return matchingAccounts;
};
/**
* retrieve credentails matching all provided filters; if no filter is set, get all credentials
* @param homeAccountId
* @param environment
* @param credentialType
* @param clientId
* @param realm
* @param target
*/
CacheManager.prototype.getCredentialsFilteredBy = function (filter) {
return this.getCredentialsFilteredByInternal(filter.homeAccountId, filter.environment, filter.credentialType, filter.clientId, filter.familyId, filter.realm, filter.target, filter.userAssertionHash, filter.tokenType, filter.keyId, filter.requestedClaimsHash);
};
/**
* Support function to help match credentials
* @param homeAccountId
* @param environment
* @param credentialType
* @param clientId
* @param realm
* @param target
* @param userAssertionHash
* @param tokenType
*/
CacheManager.prototype.getCredentialsFilteredByInternal = function (homeAccountId, environment, credentialType, clientId, familyId, realm, target, userAssertionHash, tokenType, keyId, requestedClaimsHash) {
var _this = this;
var allCacheKeys = this.getKeys();
var matchingCredentials = {
idTokens: {},
accessTokens: {},
refreshTokens: {},
};
allCacheKeys.forEach(function (cacheKey) {
// don't parse any non-credential type cache entities
var credType = CredentialEntity.getCredentialType(cacheKey);
if (credType === Constants.NOT_DEFINED) {
return;
}
// Attempt retrieval
var entity = _this.getSpecificCredential(cacheKey, credType);
if (!entity) {
return;
}
if (!!userAssertionHash && !_this.matchUserAssertionHash(entity, userAssertionHash)) {
return;
}
/*
* homeAccountId can undefined, and we want to filter out cached items that have a homeAccountId of ""
* because we don't want a client_credential request to return a cached token that has a homeAccountId
*/
if ((typeof homeAccountId === "string") && !_this.matchHomeAccountId(entity, homeAccountId)) {
return;
}
if (!!environment && !_this.matchEnvironment(entity, environment)) {
return;
}
if (!!realm && !_this.matchRealm(entity, realm)) {
return;
}
if (!!credentialType && !_this.matchCredentialType(entity, credentialType)) {
return;
}
if (!!clientId && !_this.matchClientId(entity, clientId)) {
return;
}
if (!!familyId && !_this.matchFamilyId(entity, familyId)) {
return;
}
/*
* idTokens do not have "target", target specific refreshTokens do exist for some types of authentication
* Resource specific refresh tokens case will be added when the support is deemed necessary
*/
if (!!target && !_this.matchTarget(entity, target)) {
return;
}
// If request OR cached entity has requested Claims Hash, check if they match
if (requestedClaimsHash || entity.requestedClaimsHash) {
// Don't match if either is undefined or they are different
if (entity.requestedClaimsHash !== requestedClaimsHash) {
return;
}
}
// Access Token with Auth Scheme specific matching
if (credentialType === CredentialType.ACCESS_TOKEN_WITH_AUTH_SCHEME) {
if (!!tokenType && !_this.matchTokenType(entity, tokenType)) {
return;
}
// KeyId (sshKid) in request must match cached SSH certificate keyId because SSH cert is bound to a specific key
if (tokenType === AuthenticationScheme.SSH) {
if (keyId && !_this.matchKeyId(entity, keyId)) {
return;
}
}
}
// At this point, the entity matches the request, update cache key if key schema has changed
var updatedCacheKey = _this.updateCredentialCacheKey(cacheKey, entity);
switch (credType) {
case CredentialType.ID_TOKEN:
matchingCredentials.idTokens[updatedCacheKey] = entity;
break;
case CredentialType.ACCESS_TOKEN:
case CredentialType.ACCESS_TOKEN_WITH_AUTH_SCHEME:
matchingCredentials.accessTokens[updatedCacheKey] = entity;
break;
case CredentialType.REFRESH_TOKEN:
matchingCredentials.refreshTokens[updatedCacheKey] = entity;
break;
}
});
return matchingCredentials;
};
/**
* retrieve appMetadata matching all provided filters; if no filter is set, get all appMetadata
* @param filter
*/
CacheManager.prototype.getAppMetadataFilteredBy = function (filter) {
return this.getAppMetadataFilteredByInternal(filter.environment, filter.clientId);
};
/**
* Support function to help match appMetadata
* @param environment
* @param clientId
*/
CacheManager.prototype.getAppMetadataFilteredByInternal = function (environment, clientId) {
var _this = this;
var allCacheKeys = this.getKeys();
var matchingAppMetadata = {};
allCacheKeys.forEach(function (cacheKey) {
// don't parse any non-appMetadata type cache entities
if (!_this.isAppMetadata(cacheKey)) {
return;
}
// Attempt retrieval
var entity = _this.getAppMetadata(cacheKey);
if (!entity) {
return;
}
if (!!environment && !_this.matchEnvironment(entity, environment)) {
return;
}
if (!!clientId && !_this.matchClientId(entity, clientId)) {
return;
}
matchingAppMetadata[cacheKey] = entity;
});
return matchingAppMetadata;
};
/**
* retrieve authorityMetadata that contains a matching alias
* @param filter
*/
CacheManager.prototype.getAuthorityMetadataByAlias = function (host) {
var _this = this;
var allCacheKeys = this.getAuthorityMetadataKeys();
var matchedEntity = null;
allCacheKeys.forEach(function (cacheKey) {
// don't parse any non-authorityMetadata type cache entities
if (!_this.isAuthorityMetadata(cacheKey) || cacheKey.indexOf(_this.clientId) === -1) {
return;
}
// Attempt retrieval
var entity = _this.getAuthorityMetadata(cacheKey);
if (!entity) {
return;
}
if (entity.aliases.indexOf(host) === -1) {
return;
}
matchedEntity = entity;
});
return matchedEntity;
};
/**
* Removes all accounts and related tokens from cache.
*/
CacheManager.prototype.removeAllAccounts = function () {
return __awaiter(this, void 0, void 0, function () {
var allCacheKeys, removedAccounts;
var _this = this;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
allCacheKeys = this.getKeys();
removedAccounts = [];
allCacheKeys.forEach(function (cacheKey) {
var entity = _this.getAccount(cacheKey);
if (!entity) {
return;
}
removedAccounts.push(_this.removeAccount(cacheKey));
});
return [4 /*yield*/, Promise.all(removedAccounts)];
case 1:
_a.sent();
return [2 /*return*/, true];
}
});
});
};
/**
* returns a boolean if the given account is removed
* @param account
*/
CacheManager.prototype.removeAccount = function (accountKey) {
return __awaiter(this, void 0, void 0, function () {
var account;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
account = this.getAccount(accountKey);
if (!account) {
throw ClientAuthError.createNoAccountFoundError();
}
return [4 /*yield*/, this.removeAccountContext(account)];
case 1: return [2 /*return*/, ((_a.sent()) && this.removeItem(accountKey, CacheSchemaType.ACCOUNT))];
}
});
});
};
/**
* Removes credentials associated with the provided account
* @param account
*/
CacheManager.prototype.removeAccountContext = function (account) {
return __awaiter(this, void 0, void 0, function () {
var allCacheKeys, accountId, removedCredentials;
var _this = this;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
allCacheKeys = this.getKeys();
accountId = account.generateAccountId();
removedCredentials = [];
allCacheKeys.forEach(function (cacheKey) {
// don't parse any non-credential type cache entities
var credType = CredentialEntity.getCredentialType(cacheKey);
if (credType === Constants.NOT_DEFINED) {
return;
}
var cacheEntity = _this.getSpecificCredential(cacheKey, credType);
if (!!cacheEntity && accountId === cacheEntity.generateAccountId()) {
removedCredentials.push(_this.removeCredential(cacheEntity));
}
});
return [4 /*yield*/, Promise.all(removedCredentials)];
case 1:
_a.sent();
return [2 /*return*/, true];
}
});
});
};
/**
* returns a boolean if the given credential is removed
* @param credential
*/
CacheManager.prototype.removeCredential = function (credential) {
return __awaiter(this, void 0, void 0, function () {
var key, accessTokenWithAuthSchemeEntity, kid;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
key = credential.generateCredentialKey();
if (!(credential.credentialType.toLowerCase() === CredentialType.ACCESS_TOKEN_WITH_AUTH_SCHEME.toLowerCase())) return [3 /*break*/, 4];
if (!(credential.tokenType === AuthenticationScheme.POP)) return [3 /*break*/, 4];
accessTokenWithAuthSchemeEntity = credential;
kid = accessTokenWithAuthSchemeEntity.keyId;
if (!kid) return [3 /*break*/, 4];
_a.label = 1;
case 1:
_a.trys.push([1, 3, , 4]);
return [4 /*yield*/, this.cryptoImpl.removeTokenBindingKey(kid)];
case 2:
_a.sent();
return [3 /*break*/, 4];
case 3:
_a.sent();
throw ClientAuthError.createBindingKeyNotRemovedError();
case 4: return [2 /*return*/, this.removeItem(key, CacheSchemaType.CREDENTIAL)];
}
});
});
};
/**
* Removes all app metadata objects from cache.
*/
CacheManager.prototype.removeAppMetadata = function () {
var _this = this;
var allCacheKeys = this.getKeys();
allCacheKeys.forEach(function (cacheKey) {
if (_this.isAppMetadata(cacheKey)) {
_this.removeItem(cacheKey, CacheSchemaType.APP_METADATA);
}
});
return true;
};
/**
* Retrieve the cached credentials into a cacherecord
* @param account
* @param clientId
* @param scopes
* @param environment
* @param authScheme
*/
CacheManager.prototype.readCacheRecord = function (account, clientId, request, environment) {
var cachedAccount = this.readAccountFromCache(account);
var cachedIdToken = this.readIdTokenFromCache(clientId, account);
var cachedAccessToken = this.readAccessTokenFromCache(clientId, account, request);
var cachedRefreshToken = this.readRefreshTokenFromCache(clientId, account, false);
var cachedAppMetadata = this.readAppMetadataFromCache(environment, clientId);
if (cachedAccount && cachedIdToken) {
cachedAccount.idTokenClaims = new AuthToken(cachedIdToken.secret, this.cryptoImpl).claims;
}
return {
account: cachedAccount,
idToken: cachedIdToken,
accessToken: cachedAccessToken,
refreshToken: cachedRefreshToken,
appMetadata: cachedAppMetadata,
};
};
/**
* Retrieve AccountEntity from cache
* @param account
*/
CacheManager.prototype.readAccountFromCache = function (account) {
var accountKey = AccountEntity.generateAccountCacheKey(account);
return this.getAccount(accountKey);
};
/**
* Retrieve AccountEntity from cache
* @param nativeAccountId
* @returns AccountEntity or Null
*/
CacheManager.prototype.readAccountFromCacheWithNativeAccountId = function (nativeAccountId) {
// fetch account from memory
var accountFilter = {
nativeAccountId: nativeAccountId
};
var accountCache = this.getAccountsFilteredBy(accountFilter);
var accounts = Object.keys(accountCache).map(function (key) { return accountCache[key]; });
if (accounts.length < 1) {
return null;
}
else if (accounts.length > 1) {
throw ClientAuthError.createMultipleMatchingAccountsInCacheError();
}
return accountCache[0];
};
/**
* Retrieve IdTokenEntity from cache
* @param clientId
* @param account
* @param inputRealm
*/
CacheManager.prototype.readIdTokenFromCache = function (clientId, account) {
var idTokenFilter = {
homeAccountId: account.homeAccountId,
environment: account.environment,
credentialType: CredentialType.ID_TOKEN,
clientId: clientId,
realm: account.tenantId,
};
var credentialCache = this.getCredentialsFilteredBy(idTokenFilter);
var idTokens = Object.keys(credentialCache.idTokens).map(function (key) { return credentialCache.idTokens[key]; });
var numIdTokens = idTokens.length;
if (numIdTokens < 1) {
return null;
}
else if (numIdTokens > 1) {
throw ClientAuthError.createMultipleMatchingTokensInCacheError();
}
return idTokens[0];
};
/**
* Retrieve AccessTokenEntity from cache
* @param clientId
* @param account
* @param scopes
* @param authScheme
*/
CacheManager.prototype.readAccessTokenFromCache = function (clientId, account, request) {
var scopes = new ScopeSet(request.scopes || []);
var authScheme = request.authenticationScheme || AuthenticationScheme.BEARER;
/*
* Distinguish between Bearer and PoP/SSH token cache types
* Cast to lowercase to handle "bearer" from ADFS
*/
var credentialType = (authScheme && authScheme.toLowerCase() !== AuthenticationScheme.BEARER.toLowerCase()) ? CredentialType.ACCESS_TOKEN_WITH_AUTH_SCHEME : CredentialType.ACCESS_TOKEN;
var accessTokenFilter = {
homeAccountId: account.homeAccountId,
environment: account.environment,
credentialType: credentialType,
clientId: clientId,
realm: account.tenantId,
target: scopes.printScopesLowerCase(),
tokenType: authScheme,
keyId: request.sshKid,
requestedClaimsHash: request.requestedClaimsHash,
};
var credentialCache = this.getCredentialsFilteredBy(accessTokenFilter);
var accessTokens = Object.keys(credentialCache.accessTokens).map(function (key) { return credentialCache.accessTokens[key]; });
var numAccessTokens = accessTokens.length;
if (numAccessTokens < 1) {
return null;
}
else if (numAccessTokens > 1) {
throw ClientAuthError.createMultipleMatchingTokensInCacheError();
}
return accessTokens[0];
};
/**
* Helper to retrieve the appropriate refresh token from cache
* @param clientId
* @param account
* @param familyRT
*/
CacheManager.prototype.readRefreshTokenFromCache = function (clientId, account, familyRT) {
var id = familyRT ? THE_FAMILY_ID : undefined;
var refreshTokenFilter = {
homeAccountId: account.homeAccountId,
environment: account.environment,
credentialType: CredentialType.REFRESH_TOKEN,
clientId: clientId,
familyId: id,
};
var credentialCache = this.getCredentialsFilteredBy(refreshTokenFilter);
var refreshTokens = Object.keys(credentialCache.refreshTokens).map(function (key) { return credentialCache.refreshTokens[key]; });
var numRefreshTokens = refreshTokens.length;
if (numRefreshTokens < 1) {
return null;
}
// address the else case after remove functions address environment aliases
return refreshTokens[0];
};
/**
* Retrieve AppMetadataEntity from cache
*/
CacheManager.prototype.readAppMetadataFromCache = function (environment, clientId) {
var appMetadataFilter = {
environment: environment,
clientId: clientId,
};
var appMetadata = this.getAppMetadataFilteredBy(appMetadataFilter);
var appMetadataEntries = Object.keys(appMetadata).map(function (key) { return appMetadata[key]; });
var numAppMetadata = appMetadataEntries.length;
if (numAppMetadata < 1) {
return null;
}
else if (numAppMetadata > 1) {
throw ClientAuthError.createMultipleMatchingAppMetadataInCacheError();
}
return appMetadataEntries[0];
};
/**
* Return the family_id value associated with FOCI
* @param environment
* @param clientId
*/
CacheManager.prototype.isAppMetadataFOCI = function (environment, clientId) {
var appMetadata = this.readAppMetadataFromCache(environment, clientId);
return !!(appMetadata && appMetadata.familyId === THE_FAMILY_ID);
};
/**
* helper to match account ids
* @param value
* @param homeAccountId
*/
CacheManager.prototype.matchHomeAccountId = function (entity, homeAccountId) {
return !!((typeof entity.homeAccountId === "string") && (homeAccountId === entity.homeAccountId));
};
/**
* helper to match assertion
* @param value
* @param oboAssertion
*/
CacheManager.prototype.matchUserAssertionHash = function (entity, userAssertionHash) {
return !!(entity.userAssertionHash && userAssertionHash === entity.userAssertionHash);
};
/**
* helper to match environment
* @param value
* @param environment
*/
CacheManager.prototype.matchEnvironment = function (entity, environment) {
var cloudMetadata = this.getAuthorityMetadataByAlias(environment);
if (cloudMetadata && cloudMetadata.aliases.indexOf(entity.environment) > -1) {
return true;
}
return false;
};
/**
* helper to match credential type
* @param entity
* @param credentialType
*/
CacheManager.prototype.matchCredentialType = function (entity, credentialType) {
return (entity.credentialType && credentialType.toLowerCase() === entity.credentialType.toLowerCase());
};
/**
* helper to match client ids
* @param entity
* @param clientId
*/
CacheManager.prototype.matchClientId = function (entity, clientId) {
return !!(entity.clientId && clientId === entity.clientId);
};
/**
* helper to match family ids
* @param entity
* @param familyId
*/
CacheManager.prototype.matchFamilyId = function (entity, familyId) {
return !!(entity.familyId && familyId === entity.familyId);
};
/**
* helper to match realm
* @param entity
* @param realm
*/
CacheManager.prototype.matchRealm = function (entity, realm) {
return !!(entity.realm && realm === entity.realm);
};
/**
* helper to match nativeAccountId
* @param entity
* @param nativeAccountId
* @returns boolean indicating the match result
*/
CacheManager.prototype.matchNativeAccountId = function (entity, nativeAccountId) {
return !!(entity.nativeAccountId && nativeAccountId === entity.nativeAccountId);
};
/**
* Returns true if the target scopes are a subset of the current entity's scopes, false otherwise.
* @param entity
* @param target
*/
CacheManager.prototype.matchTarget = function (entity, target) {
var isNotAccessTokenCredential = (entity.credentialType !== CredentialType.ACCESS_TOKEN && entity.credentialType !== CredentialType.ACCESS_TOKEN_WITH_AUTH_SCHEME);
if (isNotAccessTokenCredential || !entity.target) {
return false;
}
var entityScopeSet = ScopeSet.fromString(entity.target);
var requestTargetScopeSet = ScopeSet.fromString(target);
if (!requestTargetScopeSet.containsOnlyOIDCScopes()) {
requestTargetScopeSet.removeOIDCScopes(); // ignore OIDC scopes
}
else {
requestTargetScopeSet.removeScope(Constants.OFFLINE_ACCESS_SCOPE);
}
return entityScopeSet.containsScopeSet(requestTargetScopeSet);
};
/**
* Returns true if the credential's tokenType or Authentication Scheme matches the one in the request, false otherwise
* @param entity
* @param tokenType
*/
CacheManager.prototype.matchTokenType = function (entity, tokenType) {
return !!(entity.tokenType && entity.tokenType === tokenType);
};
/**
* Returns true if the credential's keyId matches the one in the request, false otherwise
* @param entity
* @param tokenType
*/
CacheManager.prototype.matchKeyId = function (entity, keyId) {
return !!(entity.keyId && entity.keyId === keyId);
};
/**
* returns if a given cache entity is of the type appmetadata
* @param key
*/
CacheManager.prototype.isAppMetadata = function (key) {
return key.indexOf(APP_METADATA) !== -1;
};
/**
* returns if a given cache entity is of the type authoritymetadata
* @param key
*/
CacheManager.prototype.isAuthorityMetadata = function (key) {
return key.indexOf(AUTHORITY_METADATA_CONSTANTS.CACHE_KEY) !== -1;
};
/**
* returns cache key used for cloud instance metadata
*/
CacheManager.prototype.generateAuthorityMetadataCacheKey = function (authority) {
return AUTHORITY_METADATA_CONSTANTS.CACHE_KEY + "-" + this.clientId + "-" + authority;
};
/**
* Returns the specific credential (IdToken/AccessToken/RefreshToken) from the cache
* @param key
* @param credType
*/
CacheManager.prototype.getSpecificCredential = function (key, credType) {
switch (credType) {
case CredentialType.ID_TOKEN: {
return this.getIdTokenCredential(key);
}
case CredentialType.ACCESS_TOKEN:
case CredentialType.ACCESS_TOKEN_WITH_AUTH_SCHEME: {
return this.getAccessTokenCredential(key);
}
case CredentialType.REFRESH_TOKEN: {
return this.getRefreshTokenCredential(key);
}
default:
return null;
}
};
/**
* Helper to convert serialized data to object
* @param obj
* @param json
*/
CacheManager.toObject = function (obj, json) {
for (var propertyName in json) {
obj[propertyName] = json[propertyName];
}
return obj;
};
return CacheManager;
}());
var DefaultStorageClass = /** @class */ (function (_super) {
__extends(DefaultStorageClass, _super);
function DefaultStorageClass() {
return _super !== null && _super.apply(this, arguments) || this;
}
DefaultStorageClass.prototype.setAccount = function () {
var notImplErr = "Storage interface - setAccount() has not been implemented for the cacheStorage interface.";
throw AuthError.createUnexpectedError(notImplErr);
};
DefaultStorageClass.prototype.getAccount = function () {
var notImplErr = "Storage interface - getAccount() has not been implemented for the cacheStorage interface.";
throw AuthError.createUnexpectedError(notImplErr);
};
DefaultStorageClass.prototype.setIdTokenCredential = function () {
var notImplErr = "Storage interface - setIdTokenCredential() has not been implemented for the cacheStorage interface.";
throw AuthError.createUnexpectedError(notImplErr);
};
DefaultStorageClass.prototype.getIdTokenCredential = function () {
var notImplErr = "Storage interface - getIdTokenCredential() has not been implemented for the cacheStorage interface.";
throw AuthError.createUnexpectedError(notImplErr);
};
DefaultStorageClass.prototype.setAccessTokenCredential = function () {
var notImplErr = "Storage interface - setAccessTokenCredential() has not been implemented for the cacheStorage interface.";
throw AuthError.createUnexpectedError(notImplErr);
};
DefaultStorageClass.prototype.getAccessTokenCredential = function () {
var notImplErr = "Storage interface - getAccessTokenCredential() has not been implemented for the cacheStorage interface.";
throw AuthError.createUnexpectedError(notImplErr);
};
DefaultStorageClass.prototype.setRefreshTokenCredential = function () {
var notImplErr = "Storage interface - setRefreshTokenCredential() has not been implemented for the cacheStorage interface.";
throw AuthError.createUnexpectedError(notImplErr);
};
DefaultStorageClass.prototype.getRefreshTokenCredential = function () {
var notImplErr = "Storage interface - getRefreshTokenCredential() has not been implemented for the cacheStorage interface.";
throw AuthError.createUnexpectedError(notImplErr);
};
DefaultStorageClass.prototype.setAppMetadata = function () {
var notImplErr = "Storage interface - setAppMetadata() has not been implemented for the cacheStorage interface.";
throw AuthError.createUnexpectedError(notImplErr);
};
DefaultStorageClass.prototype.getAppMetadata = function () {
var notImplErr = "Storage interface - getAppMetadata() has not been implemented for the cacheStorage interface.";
throw AuthError.createUnexpectedError(notImplErr);
};
DefaultStorageClass.prototype.setServerTelemetry = function () {
var notImplErr = "Storage interface - setServerTelemetry() has not been implemented for the cacheStorage interface.";
throw AuthError.createUnexpectedError(notImplErr);
};
DefaultStorageClass.prototype.getServerTelemetry = function () {
var notImplErr = "Storage interface - getServerTelemetry() has not been implemented for the cacheStorage interface.";
throw AuthError.createUnexpectedError(notImplErr);
};
DefaultStorageClass.prototype.setAuthorityMetadata = function () {
var notImplErr = "Storage interface - setAuthorityMetadata() has not been implemented for the cacheStorage interface.";
throw AuthError.createUnexpectedError(notImplErr);
};
DefaultStorageClass.prototype.getAuthorityMetadata = function () {
var notImplErr = "Storage interface - getAuthorityMetadata() has not been implemented for the cacheStorage interface.";
throw AuthError.createUnexpectedError(notImplErr);
};
DefaultStorageClass.prototype.getAuthorityMetadataKeys = function () {
var notImplErr = "Storage interface - getAuthorityMetadataKeys() has not been implemented for the cacheStorage interface.";
throw AuthError.createUnexpectedError(notImplErr);
};
DefaultStorageClass.prototype.setThrottlingCache = function () {
var notImplErr = "Storage interface - setThrottlingCache() has not been implemented for the cacheStorage interface.";
throw AuthError.createUnexpectedError(notImplErr);
};
DefaultStorageClass.prototype.getThrottlingCache = function () {
var notImplErr = "Storage interface - getThrottlingCache() has not been implemented for the cacheStorage interface.";
throw AuthError.createUnexpectedError(notImplErr);
};
DefaultStorageClass.prototype.removeItem = function () {
var notImplErr = "Storage interface - removeItem() has not been implemented for the cacheStorage interface.";
throw AuthError.createUnexpectedError(notImplErr);
};
DefaultStorageClass.prototype.containsKey = function () {
var notImplErr = "Storage interface - containsKey() has not been implemented for the cacheStorage interface.";
throw AuthError.createUnexpectedError(notImplErr);
};
DefaultStorageClass.prototype.getKeys = function () {
var notImplErr = "Storage interface - getKeys() has not been implemented for the cacheStorage interface.";
throw AuthError.createUnexpectedError(notImplErr);
};
DefaultStorageClass.prototype.clear = function () {
return __awaiter(this, void 0, void 0, function () {
var notImplErr;
return __generator(this, function (_a) {
notImplErr = "Storage interface - clear() has not been implemented for the cacheStorage interface.";
throw AuthError.createUnexpectedError(notImplErr);
});
});
};
DefaultStorageClass.prototype.updateCredentialCacheKey = function () {
var notImplErr = "Storage interface - updateCredentialCacheKey() has not been implemented for the cacheStorage interface.";
throw AuthError.createUnexpectedError(notImplErr);
};
return DefaultStorageClass;
}(CacheManager));
export { CacheManager, DefaultStorageClass };
//# sourceMappingURL=CacheManager.js.map
{"version":3,"file":"CacheManager.js","sources":["../../src/cache/CacheManager.ts"],"sourcesContent":["/*\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { AccountCache, AccountFilter, CredentialFilter, CredentialCache, ValidCredentialType, AppMetadataFilter, AppMetadataCache } from \"./utils/CacheTypes\";\nimport { CacheRecord } from \"./entities/CacheRecord\";\nimport { CacheSchemaType, CredentialType, Constants, APP_METADATA, THE_FAMILY_ID, AUTHORITY_METADATA_CONSTANTS, AuthenticationScheme } from \"../utils/Constants\";\nimport { CredentialEntity } from \"./entities/CredentialEntity\";\nimport { ScopeSet } from \"../request/ScopeSet\";\nimport { AccountEntity } from \"./entities/AccountEntity\";\nimport { AccessTokenEntity } from \"./entities/AccessTokenEntity\";\nimport { IdTokenEntity } from \"./entities/IdTokenEntity\";\nimport { RefreshTokenEntity } from \"./entities/RefreshTokenEntity\";\nimport { AuthError } from \"../error/AuthError\";\nimport { ICacheManager } from \"./interface/ICacheManager\";\nimport { ClientAuthError } from \"../error/ClientAuthError\";\nimport { AccountInfo } from \"../account/AccountInfo\";\nimport { AppMetadataEntity } from \"./entities/AppMetadataEntity\";\nimport { ServerTelemetryEntity } from \"./entities/ServerTelemetryEntity\";\nimport { ThrottlingEntity } from \"./entities/ThrottlingEntity\";\nimport { AuthToken } from \"../account/AuthToken\";\nimport { ICrypto } from \"../crypto/ICrypto\";\nimport { AuthorityMetadataEntity } from \"./entities/AuthorityMetadataEntity\";\nimport { BaseAuthRequest } from \"../request/BaseAuthRequest\";\n\n/**\n * Interface class which implement cache storage functions used by MSAL to perform validity checks, and store tokens.\n */\nexport abstract class CacheManager implements ICacheManager {\n protected clientId: string;\n protected cryptoImpl: ICrypto;\n\n constructor(clientId: string, cryptoImpl: ICrypto) {\n this.clientId = clientId;\n this.cryptoImpl = cryptoImpl;\n }\n\n /**\n * fetch the account entity from the platform cache\n * @param accountKey\n */\n abstract getAccount(accountKey: string): AccountEntity | null;\n\n /**\n * set account entity in the platform cache\n * @param account\n */\n abstract setAccount(account: AccountEntity): void;\n\n /**\n * fetch the idToken entity from the platform cache\n * @param idTokenKey\n */\n abstract getIdTokenCredential(idTokenKey: string): IdTokenEntity | null;\n\n /**\n * set idToken entity to the platform cache\n * @param idToken\n */\n abstract setIdTokenCredential(idToken: IdTokenEntity): void;\n\n /**\n * fetch the idToken entity from the platform cache\n * @param accessTokenKey\n */\n abstract getAccessTokenCredential(accessTokenKey: string): AccessTokenEntity | null;\n\n /**\n * set idToken entity to the platform cache\n * @param accessToken\n */\n abstract setAccessTokenCredential(accessToken: AccessTokenEntity): void;\n\n /**\n * fetch the idToken entity from the platform cache\n * @param refreshTokenKey\n */\n abstract getRefreshTokenCredential(refreshTokenKey: string): RefreshTokenEntity | null;\n\n /**\n * set idToken entity to the platform cache\n * @param refreshToken\n */\n abstract setRefreshTokenCredential(refreshToken: RefreshTokenEntity): void;\n\n /**\n * fetch appMetadata entity from the platform cache\n * @param appMetadataKey\n */\n abstract getAppMetadata(appMetadataKey: string): AppMetadataEntity | null;\n\n /**\n * set appMetadata entity to the platform cache\n * @param appMetadata\n */\n abstract setAppMetadata(appMetadata: AppMetadataEntity): void;\n\n /**\n * fetch server telemetry entity from the platform cache\n * @param serverTelemetryKey\n */\n abstract getServerTelemetry(serverTelemetryKey: string): ServerTelemetryEntity | null;\n\n /**\n * set server telemetry entity to the platform cache\n * @param serverTelemetryKey\n * @param serverTelemetry\n */\n abstract setServerTelemetry(serverTelemetryKey: string, serverTelemetry: ServerTelemetryEntity): void;\n\n /**\n * fetch cloud discovery metadata entity from the platform cache\n * @param key\n */\n abstract getAuthorityMetadata(key: string): AuthorityMetadataEntity | null;\n\n /**\n *\n */\n abstract getAuthorityMetadataKeys(): Array<string>;\n\n /**\n * set cloud discovery metadata entity to the platform cache\n * @param key\n * @param value\n */\n abstract setAuthorityMetadata(key: string, value: AuthorityMetadataEntity): void;\n\n /**\n * fetch throttling entity from the platform cache\n * @param throttlingCacheKey\n */\n abstract getThrottlingCache(throttlingCacheKey: string): ThrottlingEntity | null;\n\n /**\n * set throttling entity to the platform cache\n * @param throttlingCacheKey\n * @param throttlingCache\n */\n abstract setThrottlingCache(throttlingCacheKey: string, throttlingCache: ThrottlingEntity): void;;\n\n /**\n * Function to remove an item from cache given its key.\n * @param key\n */\n abstract removeItem(key: string, type?: string): boolean;\n\n /**\n * Function which returns boolean whether cache contains a specific key.\n * @param key\n */\n abstract containsKey(key: string, type?: string): boolean;\n\n /**\n * Function which retrieves all current keys from the cache.\n */\n abstract getKeys(): string[];\n\n /**\n * Function which clears cache.\n */\n abstract clear(): Promise<void>;\n\n /**\n * Function which updates an outdated credential cache key\n */\n abstract updateCredentialCacheKey(currentCacheKey: string, credential: ValidCredentialType): string;\n\n /**\n * Returns all accounts in cache\n */\n getAllAccounts(): AccountInfo[] {\n const currentAccounts: AccountCache = this.getAccountsFilteredBy();\n const accountValues: AccountEntity[] = Object.keys(currentAccounts).map(accountKey => currentAccounts[accountKey]);\n const numAccounts = accountValues.length;\n if (numAccounts < 1) {\n return [];\n } else {\n const allAccounts = accountValues.map<AccountInfo>((value) => {\n const accountEntity = CacheManager.toObject<AccountEntity>(new AccountEntity(), value);\n const accountInfo = accountEntity.getAccountInfo();\n const idToken = this.readIdTokenFromCache(this.clientId, accountInfo);\n if (idToken && !accountInfo.idTokenClaims) {\n accountInfo.idToken = idToken.secret;\n accountInfo.idTokenClaims = new AuthToken(idToken.secret, this.cryptoImpl).claims;\n }\n\n return accountInfo;\n\n });\n return allAccounts;\n }\n }\n\n /**\n * saves a cache record\n * @param cacheRecord\n */\n async saveCacheRecord(cacheRecord: CacheRecord): Promise<void> {\n if (!cacheRecord) {\n throw ClientAuthError.createNullOrUndefinedCacheRecord();\n }\n\n if (!!cacheRecord.account) {\n this.setAccount(cacheRecord.account);\n }\n\n if (!!cacheRecord.idToken) {\n this.setIdTokenCredential(cacheRecord.idToken);\n }\n\n if (!!cacheRecord.accessToken) {\n await this.saveAccessToken(cacheRecord.accessToken);\n }\n\n if (!!cacheRecord.refreshToken) {\n this.setRefreshTokenCredential(cacheRecord.refreshToken);\n }\n\n if (!!cacheRecord.appMetadata) {\n this.setAppMetadata(cacheRecord.appMetadata);\n }\n }\n\n /**\n * saves access token credential\n * @param credential\n */\n private async saveAccessToken(credential: AccessTokenEntity): Promise<void> {\n const currentTokenCache = this.getCredentialsFilteredBy({\n clientId: credential.clientId,\n credentialType: credential.credentialType,\n environment: credential.environment,\n homeAccountId: credential.homeAccountId,\n realm: credential.realm,\n tokenType: credential.tokenType,\n requestedClaimsHash: credential.requestedClaimsHash\n });\n\n const currentScopes = ScopeSet.fromString(credential.target);\n const currentAccessTokens: AccessTokenEntity[] = Object.keys(currentTokenCache.accessTokens).map(key => currentTokenCache.accessTokens[key]);\n\n if (currentAccessTokens) {\n const removedAccessTokens: Array<Promise<boolean>> = [];\n currentAccessTokens.forEach((tokenEntity) => {\n const tokenScopeSet = ScopeSet.fromString(tokenEntity.target);\n if (tokenScopeSet.intersectingScopeSets(currentScopes)) {\n removedAccessTokens.push(this.removeCredential(tokenEntity));\n }\n });\n await Promise.all(removedAccessTokens);\n }\n this.setAccessTokenCredential(credential);\n }\n\n /**\n * retrieve accounts matching all provided filters; if no filter is set, get all accounts\n * not checking for casing as keys are all generated in lower case, remember to convert to lower case if object properties are compared\n * @param homeAccountId\n * @param environment\n * @param realm\n */\n getAccountsFilteredBy(accountFilter?: AccountFilter): AccountCache {\n return this.getAccountsFilteredByInternal(\n accountFilter ? accountFilter.homeAccountId : Constants.EMPTY_STRING,\n accountFilter ? accountFilter.environment : Constants.EMPTY_STRING,\n accountFilter ? accountFilter.realm : Constants.EMPTY_STRING,\n accountFilter ? accountFilter.nativeAccountId: Constants.EMPTY_STRING,\n );\n }\n\n /**\n * retrieve accounts matching all provided filters; if no filter is set, get all accounts\n * not checking for casing as keys are all generated in lower case, remember to convert to lower case if object properties are compared\n * @param homeAccountId\n * @param environment\n * @param realm\n */\n private getAccountsFilteredByInternal(\n homeAccountId?: string,\n environment?: string,\n realm?: string,\n nativeAccountId?: string,\n ): AccountCache {\n const allCacheKeys = this.getKeys();\n const matchingAccounts: AccountCache = {};\n\n allCacheKeys.forEach((cacheKey) => {\n const entity: AccountEntity | null = this.getAccount(cacheKey);\n\n if (!entity) {\n return;\n }\n\n if (!!homeAccountId && !this.matchHomeAccountId(entity, homeAccountId)) {\n return;\n }\n\n if (!!environment && !this.matchEnvironment(entity, environment)) {\n return;\n }\n\n if (!!realm && !this.matchRealm(entity, realm)) {\n return;\n }\n\n if (!!nativeAccountId && !this.matchNativeAccountId(entity, nativeAccountId)) {\n return;\n }\n\n matchingAccounts[cacheKey] = entity;\n });\n\n return matchingAccounts;\n }\n\n /**\n * retrieve credentails matching all provided filters; if no filter is set, get all credentials\n * @param homeAccountId\n * @param environment\n * @param credentialType\n * @param clientId\n * @param realm\n * @param target\n */\n getCredentialsFilteredBy(filter: CredentialFilter): CredentialCache {\n return this.getCredentialsFilteredByInternal(\n filter.homeAccountId,\n filter.environment,\n filter.credentialType,\n filter.clientId,\n filter.familyId,\n filter.realm,\n filter.target,\n filter.userAssertionHash,\n filter.tokenType,\n filter.keyId,\n filter.requestedClaimsHash\n );\n }\n\n /**\n * Support function to help match credentials\n * @param homeAccountId\n * @param environment\n * @param credentialType\n * @param clientId\n * @param realm\n * @param target\n * @param userAssertionHash\n * @param tokenType\n */\n private getCredentialsFilteredByInternal(\n homeAccountId?: string,\n environment?: string,\n credentialType?: string,\n clientId?: string,\n familyId?: string,\n realm?: string,\n target?: string,\n userAssertionHash?: string,\n tokenType?: AuthenticationScheme,\n keyId?: string,\n requestedClaimsHash?: string\n ): CredentialCache {\n const allCacheKeys = this.getKeys();\n const matchingCredentials: CredentialCache = {\n idTokens: {},\n accessTokens: {},\n refreshTokens: {},\n };\n\n allCacheKeys.forEach((cacheKey) => {\n // don't parse any non-credential type cache entities\n const credType = CredentialEntity.getCredentialType(cacheKey);\n\n if (credType === Constants.NOT_DEFINED) {\n return;\n }\n\n // Attempt retrieval\n const entity = this.getSpecificCredential(cacheKey, credType);\n\n if (!entity) {\n return;\n }\n\n if (!!userAssertionHash && !this.matchUserAssertionHash(entity, userAssertionHash)) {\n return;\n }\n\n /*\n * homeAccountId can undefined, and we want to filter out cached items that have a homeAccountId of \"\"\n * because we don't want a client_credential request to return a cached token that has a homeAccountId\n */\n if ((typeof homeAccountId === \"string\") && !this.matchHomeAccountId(entity, homeAccountId)) {\n return;\n }\n\n if (!!environment && !this.matchEnvironment(entity, environment)) {\n return;\n }\n\n if (!!realm && !this.matchRealm(entity, realm)) {\n return;\n }\n\n if (!!credentialType && !this.matchCredentialType(entity, credentialType)) {\n return;\n }\n\n if (!!clientId && !this.matchClientId(entity, clientId)) {\n return;\n }\n\n if (!!familyId && !this.matchFamilyId(entity, familyId)) {\n return;\n }\n\n /*\n * idTokens do not have \"target\", target specific refreshTokens do exist for some types of authentication\n * Resource specific refresh tokens case will be added when the support is deemed necessary\n */\n if (!!target && !this.matchTarget(entity, target)) {\n return;\n }\n\n // If request OR cached entity has requested Claims Hash, check if they match\n if (requestedClaimsHash || entity.requestedClaimsHash) {\n // Don't match if either is undefined or they are different\n if (entity.requestedClaimsHash !== requestedClaimsHash) {\n return;\n }\n }\n\n // Access Token with Auth Scheme specific matching\n if (credentialType === CredentialType.ACCESS_TOKEN_WITH_AUTH_SCHEME) {\n if(!!tokenType && !this.matchTokenType(entity, tokenType)) {\n return;\n }\n\n // KeyId (sshKid) in request must match cached SSH certificate keyId because SSH cert is bound to a specific key\n if (tokenType === AuthenticationScheme.SSH) {\n if(keyId && !this.matchKeyId(entity, keyId)) {\n return;\n }\n }\n }\n\n // At this point, the entity matches the request, update cache key if key schema has changed\n const updatedCacheKey = this.updateCredentialCacheKey(cacheKey, entity);\n\n switch (credType) {\n case CredentialType.ID_TOKEN:\n matchingCredentials.idTokens[updatedCacheKey] = entity as IdTokenEntity;\n break;\n case CredentialType.ACCESS_TOKEN:\n case CredentialType.ACCESS_TOKEN_WITH_AUTH_SCHEME:\n matchingCredentials.accessTokens[updatedCacheKey] = entity as AccessTokenEntity;\n break;\n case CredentialType.REFRESH_TOKEN:\n matchingCredentials.refreshTokens[updatedCacheKey] = entity as RefreshTokenEntity;\n break;\n }\n });\n\n return matchingCredentials;\n }\n\n /**\n * retrieve appMetadata matching all provided filters; if no filter is set, get all appMetadata\n * @param filter\n */\n getAppMetadataFilteredBy(filter: AppMetadataFilter): AppMetadataCache {\n return this.getAppMetadataFilteredByInternal(\n filter.environment,\n filter.clientId,\n );\n }\n\n /**\n * Support function to help match appMetadata\n * @param environment\n * @param clientId\n */\n private getAppMetadataFilteredByInternal(\n environment?: string,\n clientId?: string\n ): AppMetadataCache {\n\n const allCacheKeys = this.getKeys();\n const matchingAppMetadata: AppMetadataCache = {};\n\n allCacheKeys.forEach((cacheKey) => {\n // don't parse any non-appMetadata type cache entities\n if (!this.isAppMetadata(cacheKey)) {\n return;\n }\n\n // Attempt retrieval\n const entity = this.getAppMetadata(cacheKey);\n\n if (!entity) {\n return;\n }\n\n if (!!environment && !this.matchEnvironment(entity, environment)) {\n return;\n }\n\n if (!!clientId && !this.matchClientId(entity, clientId)) {\n return;\n }\n\n matchingAppMetadata[cacheKey] = entity;\n\n });\n\n return matchingAppMetadata;\n }\n\n /**\n * retrieve authorityMetadata that contains a matching alias\n * @param filter\n */\n getAuthorityMetadataByAlias(host: string): AuthorityMetadataEntity | null {\n const allCacheKeys = this.getAuthorityMetadataKeys();\n let matchedEntity = null;\n\n allCacheKeys.forEach((cacheKey) => {\n // don't parse any non-authorityMetadata type cache entities\n if (!this.isAuthorityMetadata(cacheKey) || cacheKey.indexOf(this.clientId) === -1) {\n return;\n }\n\n // Attempt retrieval\n const entity = this.getAuthorityMetadata(cacheKey);\n\n if (!entity) {\n return;\n }\n\n if (entity.aliases.indexOf(host) === -1) {\n return;\n }\n\n matchedEntity = entity;\n\n });\n\n return matchedEntity;\n }\n\n /**\n * Removes all accounts and related tokens from cache.\n */\n async removeAllAccounts(): Promise<boolean> {\n const allCacheKeys = this.getKeys();\n const removedAccounts: Array<Promise<boolean>> = [];\n\n allCacheKeys.forEach((cacheKey) => {\n const entity = this.getAccount(cacheKey);\n if (!entity) {\n return;\n }\n removedAccounts.push(this.removeAccount(cacheKey));\n });\n\n await Promise.all(removedAccounts);\n return true;\n }\n\n /**\n * returns a boolean if the given account is removed\n * @param account\n */\n async removeAccount(accountKey: string): Promise<boolean> {\n const account = this.getAccount(accountKey);\n if (!account) {\n throw ClientAuthError.createNoAccountFoundError();\n }\n return (await this.removeAccountContext(account) && this.removeItem(accountKey, CacheSchemaType.ACCOUNT));\n }\n\n /**\n * Removes credentials associated with the provided account\n * @param account\n */\n async removeAccountContext(account: AccountEntity): Promise<boolean> {\n const allCacheKeys = this.getKeys();\n const accountId = account.generateAccountId();\n const removedCredentials: Array<Promise<boolean>> = [];\n\n allCacheKeys.forEach((cacheKey) => {\n // don't parse any non-credential type cache entities\n const credType = CredentialEntity.getCredentialType(cacheKey);\n if (credType === Constants.NOT_DEFINED) {\n return;\n }\n\n const cacheEntity = this.getSpecificCredential(cacheKey, credType);\n if (!!cacheEntity && accountId === cacheEntity.generateAccountId()) {\n removedCredentials.push(this.removeCredential(cacheEntity));\n }\n });\n\n await Promise.all(removedCredentials);\n return true;\n }\n\n /**\n * returns a boolean if the given credential is removed\n * @param credential\n */\n async removeCredential(credential: CredentialEntity): Promise<boolean> {\n const key = credential.generateCredentialKey();\n\n // Remove Token Binding Key from key store for PoP Tokens Credentials\n if (credential.credentialType.toLowerCase() === CredentialType.ACCESS_TOKEN_WITH_AUTH_SCHEME.toLowerCase()) {\n if(credential.tokenType === AuthenticationScheme.POP) {\n const accessTokenWithAuthSchemeEntity = credential as AccessTokenEntity;\n const kid = accessTokenWithAuthSchemeEntity.keyId;\n\n if (kid) {\n try {\n await this.cryptoImpl.removeTokenBindingKey(kid);\n } catch (error) {\n throw ClientAuthError.createBindingKeyNotRemovedError();\n }\n }\n }\n }\n\n return this.removeItem(key, CacheSchemaType.CREDENTIAL);\n }\n\n /**\n * Removes all app metadata objects from cache.\n */\n removeAppMetadata(): boolean {\n const allCacheKeys = this.getKeys();\n allCacheKeys.forEach((cacheKey) => {\n if (this.isAppMetadata(cacheKey)) {\n this.removeItem(cacheKey, CacheSchemaType.APP_METADATA);\n }\n });\n\n return true;\n }\n\n /**\n * Retrieve the cached credentials into a cacherecord\n * @param account\n * @param clientId\n * @param scopes\n * @param environment\n * @param authScheme\n */\n readCacheRecord(account: AccountInfo, clientId: string, request: BaseAuthRequest, environment: string): CacheRecord {\n\n const cachedAccount = this.readAccountFromCache(account);\n const cachedIdToken = this.readIdTokenFromCache(clientId, account);\n const cachedAccessToken = this.readAccessTokenFromCache(clientId, account, request);\n const cachedRefreshToken = this.readRefreshTokenFromCache(clientId, account, false);\n const cachedAppMetadata = this.readAppMetadataFromCache(environment, clientId);\n\n if (cachedAccount && cachedIdToken) {\n cachedAccount.idTokenClaims = new AuthToken(cachedIdToken.secret, this.cryptoImpl).claims;\n }\n\n return {\n account: cachedAccount,\n idToken: cachedIdToken,\n accessToken: cachedAccessToken,\n refreshToken: cachedRefreshToken,\n appMetadata: cachedAppMetadata,\n };\n }\n\n /**\n * Retrieve AccountEntity from cache\n * @param account\n */\n readAccountFromCache(account: AccountInfo): AccountEntity | null {\n const accountKey: string = AccountEntity.generateAccountCacheKey(account);\n return this.getAccount(accountKey);\n }\n\n /**\n * Retrieve AccountEntity from cache\n * @param nativeAccountId\n * @returns AccountEntity or Null\n */\n readAccountFromCacheWithNativeAccountId(nativeAccountId: string): AccountEntity | null {\n // fetch account from memory\n const accountFilter: AccountFilter = {\n nativeAccountId\n };\n const accountCache: AccountCache = this.getAccountsFilteredBy(accountFilter);\n const accounts = Object.keys(accountCache).map((key) => accountCache[key]);\n\n if (accounts.length < 1) {\n return null;\n } else if (accounts.length > 1) {\n throw ClientAuthError.createMultipleMatchingAccountsInCacheError();\n }\n\n return accountCache[0];\n }\n\n /**\n * Retrieve IdTokenEntity from cache\n * @param clientId\n * @param account\n * @param inputRealm\n */\n readIdTokenFromCache(clientId: string, account: AccountInfo): IdTokenEntity | null {\n const idTokenFilter: CredentialFilter = {\n homeAccountId: account.homeAccountId,\n environment: account.environment,\n credentialType: CredentialType.ID_TOKEN,\n clientId: clientId,\n realm: account.tenantId,\n };\n\n const credentialCache: CredentialCache = this.getCredentialsFilteredBy(idTokenFilter);\n const idTokens = Object.keys(credentialCache.idTokens).map((key) => credentialCache.idTokens[key]);\n const numIdTokens = idTokens.length;\n\n if (numIdTokens < 1) {\n return null;\n } else if (numIdTokens > 1) {\n throw ClientAuthError.createMultipleMatchingTokensInCacheError();\n }\n\n return idTokens[0] as IdTokenEntity;\n }\n\n /**\n * Retrieve AccessTokenEntity from cache\n * @param clientId\n * @param account\n * @param scopes\n * @param authScheme\n */\n readAccessTokenFromCache(clientId: string, account: AccountInfo, request: BaseAuthRequest): AccessTokenEntity | null {\n const scopes = new ScopeSet(request.scopes || []);\n const authScheme = request.authenticationScheme || AuthenticationScheme.BEARER;\n /*\n * Distinguish between Bearer and PoP/SSH token cache types\n * Cast to lowercase to handle \"bearer\" from ADFS\n */\n const credentialType = (authScheme && authScheme.toLowerCase() !== AuthenticationScheme.BEARER.toLowerCase()) ? CredentialType.ACCESS_TOKEN_WITH_AUTH_SCHEME : CredentialType.ACCESS_TOKEN;\n\n const accessTokenFilter: CredentialFilter = {\n homeAccountId: account.homeAccountId,\n environment: account.environment,\n credentialType: credentialType,\n clientId,\n realm: account.tenantId,\n target: scopes.printScopesLowerCase(),\n tokenType: authScheme,\n keyId: request.sshKid,\n requestedClaimsHash: request.requestedClaimsHash,\n };\n\n const credentialCache: CredentialCache = this.getCredentialsFilteredBy(accessTokenFilter);\n\n const accessTokens = Object.keys(credentialCache.accessTokens).map((key) => credentialCache.accessTokens[key]);\n\n const numAccessTokens = accessTokens.length;\n if (numAccessTokens < 1) {\n return null;\n } else if (numAccessTokens > 1) {\n throw ClientAuthError.createMultipleMatchingTokensInCacheError();\n }\n\n return accessTokens[0] as AccessTokenEntity;\n }\n\n /**\n * Helper to retrieve the appropriate refresh token from cache\n * @param clientId\n * @param account\n * @param familyRT\n */\n readRefreshTokenFromCache(clientId: string, account: AccountInfo, familyRT: boolean): RefreshTokenEntity | null {\n const id = familyRT ? THE_FAMILY_ID : undefined;\n const refreshTokenFilter: CredentialFilter = {\n homeAccountId: account.homeAccountId,\n environment: account.environment,\n credentialType: CredentialType.REFRESH_TOKEN,\n clientId: clientId,\n familyId: id,\n };\n\n const credentialCache: CredentialCache = this.getCredentialsFilteredBy(refreshTokenFilter);\n const refreshTokens = Object.keys(credentialCache.refreshTokens).map((key) => credentialCache.refreshTokens[key]);\n\n const numRefreshTokens = refreshTokens.length;\n if (numRefreshTokens < 1) {\n return null;\n }\n // address the else case after remove functions address environment aliases\n\n return refreshTokens[0] as RefreshTokenEntity;\n }\n\n /**\n * Retrieve AppMetadataEntity from cache\n */\n readAppMetadataFromCache(environment: string, clientId: string): AppMetadataEntity | null {\n const appMetadataFilter: AppMetadataFilter = {\n environment,\n clientId,\n };\n\n const appMetadata: AppMetadataCache = this.getAppMetadataFilteredBy(appMetadataFilter);\n const appMetadataEntries: AppMetadataEntity[] = Object.keys(appMetadata).map((key) => appMetadata[key]);\n\n const numAppMetadata = appMetadataEntries.length;\n if (numAppMetadata < 1) {\n return null;\n } else if (numAppMetadata > 1) {\n throw ClientAuthError.createMultipleMatchingAppMetadataInCacheError();\n }\n\n return appMetadataEntries[0] as AppMetadataEntity;\n }\n\n /**\n * Return the family_id value associated with FOCI\n * @param environment\n * @param clientId\n */\n isAppMetadataFOCI(environment: string, clientId: string): boolean {\n const appMetadata = this.readAppMetadataFromCache(environment, clientId);\n return !!(appMetadata && appMetadata.familyId === THE_FAMILY_ID);\n }\n\n /**\n * helper to match account ids\n * @param value\n * @param homeAccountId\n */\n private matchHomeAccountId(entity: AccountEntity | CredentialEntity, homeAccountId: string): boolean {\n return !!((typeof entity.homeAccountId === \"string\") && (homeAccountId === entity.homeAccountId));\n }\n\n /**\n * helper to match assertion\n * @param value\n * @param oboAssertion\n */\n private matchUserAssertionHash(entity: CredentialEntity, userAssertionHash: string): boolean {\n return !!(entity.userAssertionHash && userAssertionHash === entity.userAssertionHash);\n }\n\n /**\n * helper to match environment\n * @param value\n * @param environment\n */\n private matchEnvironment(entity: AccountEntity | CredentialEntity | AppMetadataEntity, environment: string): boolean {\n const cloudMetadata = this.getAuthorityMetadataByAlias(environment);\n if (cloudMetadata && cloudMetadata.aliases.indexOf(entity.environment) > -1) {\n return true;\n }\n\n return false;\n }\n\n /**\n * helper to match credential type\n * @param entity\n * @param credentialType\n */\n private matchCredentialType(entity: CredentialEntity, credentialType: string): boolean {\n return (entity.credentialType && credentialType.toLowerCase() === entity.credentialType.toLowerCase());\n }\n\n /**\n * helper to match client ids\n * @param entity\n * @param clientId\n */\n private matchClientId(entity: CredentialEntity | AppMetadataEntity, clientId: string): boolean {\n return !!(entity.clientId && clientId === entity.clientId);\n }\n\n /**\n * helper to match family ids\n * @param entity\n * @param familyId\n */\n private matchFamilyId(entity: CredentialEntity | AppMetadataEntity, familyId: string): boolean {\n return !!(entity.familyId && familyId === entity.familyId);\n }\n\n /**\n * helper to match realm\n * @param entity\n * @param realm\n */\n private matchRealm(entity: AccountEntity | CredentialEntity, realm: string): boolean {\n return !!(entity.realm && realm === entity.realm);\n }\n\n /**\n * helper to match nativeAccountId\n * @param entity\n * @param nativeAccountId\n * @returns boolean indicating the match result\n */\n private matchNativeAccountId(entity: AccountEntity, nativeAccountId: string): boolean {\n return !!(entity.nativeAccountId && nativeAccountId === entity.nativeAccountId);\n }\n\n /**\n * Returns true if the target scopes are a subset of the current entity's scopes, false otherwise.\n * @param entity\n * @param target\n */\n private matchTarget(entity: CredentialEntity, target: string): boolean {\n const isNotAccessTokenCredential = (entity.credentialType !== CredentialType.ACCESS_TOKEN && entity.credentialType !== CredentialType.ACCESS_TOKEN_WITH_AUTH_SCHEME);\n\n if ( isNotAccessTokenCredential || !entity.target) {\n return false;\n }\n\n const entityScopeSet: ScopeSet = ScopeSet.fromString(entity.target);\n const requestTargetScopeSet: ScopeSet = ScopeSet.fromString(target);\n\n if (!requestTargetScopeSet.containsOnlyOIDCScopes()) {\n requestTargetScopeSet.removeOIDCScopes(); // ignore OIDC scopes\n } else {\n requestTargetScopeSet.removeScope(Constants.OFFLINE_ACCESS_SCOPE);\n }\n return entityScopeSet.containsScopeSet(requestTargetScopeSet);\n }\n\n /**\n * Returns true if the credential's tokenType or Authentication Scheme matches the one in the request, false otherwise\n * @param entity\n * @param tokenType\n */\n private matchTokenType(entity: CredentialEntity, tokenType: AuthenticationScheme): boolean {\n return !!(entity.tokenType && entity.tokenType === tokenType);\n }\n\n /**\n * Returns true if the credential's keyId matches the one in the request, false otherwise\n * @param entity\n * @param tokenType\n */\n private matchKeyId(entity: CredentialEntity, keyId: string): boolean {\n return !!(entity.keyId && entity.keyId === keyId);\n }\n\n /**\n * returns if a given cache entity is of the type appmetadata\n * @param key\n */\n private isAppMetadata(key: string): boolean {\n return key.indexOf(APP_METADATA) !== -1;\n }\n\n /**\n * returns if a given cache entity is of the type authoritymetadata\n * @param key\n */\n protected isAuthorityMetadata(key: string): boolean {\n return key.indexOf(AUTHORITY_METADATA_CONSTANTS.CACHE_KEY) !== -1;\n }\n\n /**\n * returns cache key used for cloud instance metadata\n */\n generateAuthorityMetadataCacheKey(authority: string): string {\n return `${AUTHORITY_METADATA_CONSTANTS.CACHE_KEY}-${this.clientId}-${authority}`;\n }\n\n /**\n * Returns the specific credential (IdToken/AccessToken/RefreshToken) from the cache\n * @param key\n * @param credType\n */\n private getSpecificCredential(key: string, credType: string): ValidCredentialType | null {\n switch (credType) {\n case CredentialType.ID_TOKEN: {\n return this.getIdTokenCredential(key);\n }\n case CredentialType.ACCESS_TOKEN:\n case CredentialType.ACCESS_TOKEN_WITH_AUTH_SCHEME: {\n return this.getAccessTokenCredential(key);\n }\n case CredentialType.REFRESH_TOKEN: {\n return this.getRefreshTokenCredential(key);\n }\n default:\n return null;\n }\n }\n\n /**\n * Helper to convert serialized data to object\n * @param obj\n * @param json\n */\n static toObject<T>(obj: T, json: object): T {\n for (const propertyName in json) {\n obj[propertyName] = json[propertyName];\n }\n return obj;\n }\n}\n\nexport class DefaultStorageClass extends CacheManager {\n setAccount(): void {\n const notImplErr = \"Storage interface - setAccount() has not been implemented for the cacheStorage interface.\";\n throw AuthError.createUnexpectedError(notImplErr);\n }\n getAccount(): AccountEntity {\n const notImplErr = \"Storage interface - getAccount() has not been implemented for the cacheStorage interface.\";\n throw AuthError.createUnexpectedError(notImplErr);\n }\n setIdTokenCredential(): void {\n const notImplErr = \"Storage interface - setIdTokenCredential() has not been implemented for the cacheStorage interface.\";\n throw AuthError.createUnexpectedError(notImplErr);\n }\n getIdTokenCredential(): IdTokenEntity {\n const notImplErr = \"Storage interface - getIdTokenCredential() has not been implemented for the cacheStorage interface.\";\n throw AuthError.createUnexpectedError(notImplErr);\n }\n setAccessTokenCredential(): void {\n const notImplErr = \"Storage interface - setAccessTokenCredential() has not been implemented for the cacheStorage interface.\";\n throw AuthError.createUnexpectedError(notImplErr);\n }\n getAccessTokenCredential(): AccessTokenEntity {\n const notImplErr = \"Storage interface - getAccessTokenCredential() has not been implemented for the cacheStorage interface.\";\n throw AuthError.createUnexpectedError(notImplErr);\n }\n setRefreshTokenCredential(): void {\n const notImplErr = \"Storage interface - setRefreshTokenCredential() has not been implemented for the cacheStorage interface.\";\n throw AuthError.createUnexpectedError(notImplErr);\n }\n getRefreshTokenCredential(): RefreshTokenEntity {\n const notImplErr = \"Storage interface - getRefreshTokenCredential() has not been implemented for the cacheStorage interface.\";\n throw AuthError.createUnexpectedError(notImplErr);\n }\n setAppMetadata(): void {\n const notImplErr = \"Storage interface - setAppMetadata() has not been implemented for the cacheStorage interface.\";\n throw AuthError.createUnexpectedError(notImplErr);\n }\n getAppMetadata(): AppMetadataEntity {\n const notImplErr = \"Storage interface - getAppMetadata() has not been implemented for the cacheStorage interface.\";\n throw AuthError.createUnexpectedError(notImplErr);\n }\n setServerTelemetry(): void {\n const notImplErr = \"Storage interface - setServerTelemetry() has not been implemented for the cacheStorage interface.\";\n throw AuthError.createUnexpectedError(notImplErr);\n }\n getServerTelemetry(): ServerTelemetryEntity {\n const notImplErr = \"Storage interface - getServerTelemetry() has not been implemented for the cacheStorage interface.\";\n throw AuthError.createUnexpectedError(notImplErr);\n }\n setAuthorityMetadata(): void {\n const notImplErr = \"Storage interface - setAuthorityMetadata() has not been implemented for the cacheStorage interface.\";\n throw AuthError.createUnexpectedError(notImplErr);\n }\n getAuthorityMetadata(): AuthorityMetadataEntity | null {\n const notImplErr = \"Storage interface - getAuthorityMetadata() has not been implemented for the cacheStorage interface.\";\n throw AuthError.createUnexpectedError(notImplErr);\n }\n getAuthorityMetadataKeys(): Array<string> {\n const notImplErr = \"Storage interface - getAuthorityMetadataKeys() has not been implemented for the cacheStorage interface.\";\n throw AuthError.createUnexpectedError(notImplErr);\n }\n setThrottlingCache(): void {\n const notImplErr = \"Storage interface - setThrottlingCache() has not been implemented for the cacheStorage interface.\";\n throw AuthError.createUnexpectedError(notImplErr);\n }\n getThrottlingCache(): ThrottlingEntity {\n const notImplErr = \"Storage interface - getThrottlingCache() has not been implemented for the cacheStorage interface.\";\n throw AuthError.createUnexpectedError(notImplErr);\n }\n removeItem(): boolean {\n const notImplErr = \"Storage interface - removeItem() has not been implemented for the cacheStorage interface.\";\n throw AuthError.createUnexpectedError(notImplErr);\n }\n containsKey(): boolean {\n const notImplErr = \"Storage interface - containsKey() has not been implemented for the cacheStorage interface.\";\n throw AuthError.createUnexpectedError(notImplErr);\n }\n getKeys(): string[] {\n const notImplErr = \"Storage interface - getKeys() has not been implemented for the cacheStorage interface.\";\n throw AuthError.createUnexpectedError(notImplErr);\n }\n async clear(): Promise<void> {\n const notImplErr = \"Storage interface - clear() has not been implemented for the cacheStorage interface.\";\n throw AuthError.createUnexpectedError(notImplErr);\n }\n updateCredentialCacheKey(): string {\n const notImplErr = \"Storage interface - updateCredentialCacheKey() has not been implemented for the cacheStorage interface.\";\n throw AuthError.createUnexpectedError(notImplErr);\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;AAAA;;;AAGG;AAuBH;;AAEG;AACH,IAAA,YAAA,kBAAA,YAAA;IAII,SAAY,YAAA,CAAA,QAAgB,EAAE,UAAmB,EAAA;AAC7C,QAAA,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;AACzB,QAAA,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;KAChC;AAqID;;AAEG;AACH,IAAA,YAAA,CAAA,SAAA,CAAA,cAAc,GAAd,YAAA;QAAA,IAqBC,KAAA,GAAA,IAAA,CAAA;AApBG,QAAA,IAAM,eAAe,GAAiB,IAAI,CAAC,qBAAqB,EAAE,CAAC;QACnE,IAAM,aAAa,GAAoB,MAAM,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC,GAAG,CAAC,UAAA,UAAU,EAAA,EAAI,OAAA,eAAe,CAAC,UAAU,CAAC,CAAA,EAAA,CAAC,CAAC;AACnH,QAAA,IAAM,WAAW,GAAG,aAAa,CAAC,MAAM,CAAC;QACzC,IAAI,WAAW,GAAG,CAAC,EAAE;AACjB,YAAA,OAAO,EAAE,CAAC;AACb,SAAA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U,CAAC,CAAC;KACrD,CAAA;AACK,IAAA,mBAAA,CAAA,SAAA,CAAA,KAAK,GAAX,YAAA;;;;gBACU,UAAU,GAAG,sFAAsF,CAAC;AAC1G,gBAAA,MAAM,SAAS,CAAC,qBAAqB,CAAC,UAAU,CAAC,CAAC;;;AACrD,KAAA,CAAA;AACD,IAAA,mBAAA,CAAA,SAAA,CAAA,wBAAwB,GAAxB,YAAA;QACI,IAAM,UAAU,GAAG,yGAAyG,CAAC;AAC7H,QAAA,MAAM,SAAS,CAAC,qBAAqB,CAAC,UAAU,CAAC,CAAC;KACrD,CAAA;IACL,OAAC,mBAAA,CAAA;AAAD,CAzFA,CAAyC,YAAY,CAyFpD;;;;"}
\ No newline at end of file
import { CredentialEntity } from "./CredentialEntity";
import { AuthenticationScheme } from "../../utils/Constants";
import { ICrypto } from "../../crypto/ICrypto";
/**
* ACCESS_TOKEN Credential Type
*
* Key:Value Schema:
*
* Key Example: uid.utid-login.microsoftonline.com-accesstoken-clientId-contoso.com-user.read
*
* Value Schema:
* {
* homeAccountId: home account identifier for the auth scheme,
* environment: entity that issued the token, represented as a full host
* credentialType: Type of credential as a string, can be one of the following: RefreshToken, AccessToken, IdToken, Password, Cookie, Certificate, Other
* clientId: client ID of the application
* secret: Actual credential as a string
* familyId: Family ID identifier, usually only used for refresh tokens
* realm: Full tenant or organizational identifier that the account belongs to
* target: Permissions that are included in the token, or for refresh tokens, the resource identifier.
* cachedAt: Absolute device time when entry was created in the cache.
* expiresOn: Token expiry time, calculated based on current UTC time in seconds. Represented as a string.
* extendedExpiresOn: Additional extended expiry time until when token is valid in case of server-side outage. Represented as string in UTC seconds.
* keyId: used for POP and SSH tokenTypes
* tokenType: Type of the token issued. Usually "Bearer"
* }
*/
export declare class AccessTokenEntity extends CredentialEntity {
realm: string;
target: string;
cachedAt: string;
expiresOn: string;
extendedExpiresOn?: string;
refreshOn?: string;
keyId?: string;
tokenType?: AuthenticationScheme;
requestedClaims?: string;
requestedClaimsHash?: string;
/**
* Create AccessTokenEntity
* @param homeAccountId
* @param environment
* @param accessToken
* @param clientId
* @param tenantId
* @param scopes
* @param expiresOn
* @param extExpiresOn
*/
static createAccessTokenEntity(homeAccountId: string, environment: string, accessToken: string, clientId: string, tenantId: string, scopes: string, expiresOn: number, extExpiresOn: number, cryptoUtils: ICrypto, refreshOn?: number, tokenType?: AuthenticationScheme, userAssertionHash?: string, keyId?: string, requestedClaims?: string, requestedClaimsHash?: string): AccessTokenEntity;
/**
* Validates an entity: checks for all expected params
* @param entity
*/
static isAccessTokenEntity(entity: object): boolean;
}
//# sourceMappingURL=AccessTokenEntity.d.ts.map
\ No newline at end of file
{"version":3,"file":"AccessTokenEntity.d.ts","sourceRoot":"","sources":["../../../src/cache/entities/AccessTokenEntity.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAkB,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAG7E,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAK/C;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,qBAAa,iBAAkB,SAAQ,gBAAgB;IACnD,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,oBAAoB,CAAC;IACjC,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAE7B;;;;;;;;;;OAUG;IACH,MAAM,CAAC,uBAAuB,CAC1B,aAAa,EAAE,MAAM,EACrB,WAAW,EAAE,MAAM,EACnB,WAAW,EAAE,MAAM,EACnB,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,EACjB,YAAY,EAAE,MAAM,EACpB,WAAW,EAAE,OAAO,EACpB,SAAS,CAAC,EAAE,MAAM,EAClB,SAAS,CAAC,EAAE,oBAAoB,EAChC,iBAAiB,CAAC,EAAC,MAAM,EACzB,KAAK,CAAC,EAAE,MAAM,EACd,eAAe,CAAC,EAAE,MAAM,EACxB,mBAAmB,CAAC,EAAE,MAAM,GAC7B,iBAAiB;IAwDpB;;;OAGG;IACH,MAAM,CAAC,mBAAmB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO;CAiBtD"}
\ No newline at end of file
/*! @azure/msal-common v9.0.1 2022-12-07 */
'use strict';
import { __extends } from '../../_virtual/_tslib.js';
import { CredentialEntity } from './CredentialEntity.js';
import { CredentialType, AuthenticationScheme } from '../../utils/Constants.js';
import { TimeUtils } from '../../utils/TimeUtils.js';
import { StringUtils } from '../../utils/StringUtils.js';
import { AuthToken } from '../../account/AuthToken.js';
import { ClientAuthError } from '../../error/ClientAuthError.js';
/*
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License.
*/
/**
* ACCESS_TOKEN Credential Type
*
* Key:Value Schema:
*
* Key Example: uid.utid-login.microsoftonline.com-accesstoken-clientId-contoso.com-user.read
*
* Value Schema:
* {
* homeAccountId: home account identifier for the auth scheme,
* environment: entity that issued the token, represented as a full host
* credentialType: Type of credential as a string, can be one of the following: RefreshToken, AccessToken, IdToken, Password, Cookie, Certificate, Other
* clientId: client ID of the application
* secret: Actual credential as a string
* familyId: Family ID identifier, usually only used for refresh tokens
* realm: Full tenant or organizational identifier that the account belongs to
* target: Permissions that are included in the token, or for refresh tokens, the resource identifier.
* cachedAt: Absolute device time when entry was created in the cache.
* expiresOn: Token expiry time, calculated based on current UTC time in seconds. Represented as a string.
* extendedExpiresOn: Additional extended expiry time until when token is valid in case of server-side outage. Represented as string in UTC seconds.
* keyId: used for POP and SSH tokenTypes
* tokenType: Type of the token issued. Usually "Bearer"
* }
*/
var AccessTokenEntity = /** @class */ (function (_super) {
__extends(AccessTokenEntity, _super);
function AccessTokenEntity() {
return _super !== null && _super.apply(this, arguments) || this;
}
/**
* Create AccessTokenEntity
* @param homeAccountId
* @param environment
* @param accessToken
* @param clientId
* @param tenantId
* @param scopes
* @param expiresOn
* @param extExpiresOn
*/
AccessTokenEntity.createAccessTokenEntity = function (homeAccountId, environment, accessToken, clientId, tenantId, scopes, expiresOn, extExpiresOn, cryptoUtils, refreshOn, tokenType, userAssertionHash, keyId, requestedClaims, requestedClaimsHash) {
var _a, _b;
var atEntity = new AccessTokenEntity();
atEntity.homeAccountId = homeAccountId;
atEntity.credentialType = CredentialType.ACCESS_TOKEN;
atEntity.secret = accessToken;
var currentTime = TimeUtils.nowSeconds();
atEntity.cachedAt = currentTime.toString();
/*
* Token expiry time.
* This value should be  calculated based on the current UTC time measured locally and the value  expires_in Represented as a string in JSON.
*/
atEntity.expiresOn = expiresOn.toString();
atEntity.extendedExpiresOn = extExpiresOn.toString();
if (refreshOn) {
atEntity.refreshOn = refreshOn.toString();
}
atEntity.environment = environment;
atEntity.clientId = clientId;
atEntity.realm = tenantId;
atEntity.target = scopes;
atEntity.userAssertionHash = userAssertionHash;
atEntity.tokenType = StringUtils.isEmpty(tokenType) ? AuthenticationScheme.BEARER : tokenType;
if (requestedClaims) {
atEntity.requestedClaims = requestedClaims;
atEntity.requestedClaimsHash = requestedClaimsHash;
}
/*
* Create Access Token With Auth Scheme instead of regular access token
* Cast to lower to handle "bearer" from ADFS
*/
if (((_a = atEntity.tokenType) === null || _a === void 0 ? void 0 : _a.toLowerCase()) !== AuthenticationScheme.BEARER.toLowerCase()) {
atEntity.credentialType = CredentialType.ACCESS_TOKEN_WITH_AUTH_SCHEME;
switch (atEntity.tokenType) {
case AuthenticationScheme.POP:
// Make sure keyId is present and add it to credential
var tokenClaims = AuthToken.extractTokenClaims(accessToken, cryptoUtils);
if (!((_b = tokenClaims === null || tokenClaims === void 0 ? void 0 : tokenClaims.cnf) === null || _b === void 0 ? void 0 : _b.kid)) {
throw ClientAuthError.createTokenClaimsRequiredError();
}
atEntity.keyId = tokenClaims.cnf.kid;
break;
case AuthenticationScheme.SSH:
atEntity.keyId = keyId;
}
}
return atEntity;
};
/**
* Validates an entity: checks for all expected params
* @param entity
*/
AccessTokenEntity.isAccessTokenEntity = function (entity) {
if (!entity) {
return false;
}
return (entity.hasOwnProperty("homeAccountId") &&
entity.hasOwnProperty("environment") &&
entity.hasOwnProperty("credentialType") &&
entity.hasOwnProperty("realm") &&
entity.hasOwnProperty("clientId") &&
entity.hasOwnProperty("secret") &&
entity.hasOwnProperty("target") &&
(entity["credentialType"] === CredentialType.ACCESS_TOKEN || entity["credentialType"] === CredentialType.ACCESS_TOKEN_WITH_AUTH_SCHEME));
};
return AccessTokenEntity;
}(CredentialEntity));
export { AccessTokenEntity };
//# sourceMappingURL=AccessTokenEntity.js.map
{"version":3,"file":"AccessTokenEntity.js","sources":["../../../src/cache/entities/AccessTokenEntity.ts"],"sourcesContent":["/*\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { CredentialEntity } from \"./CredentialEntity\";\nimport { CredentialType, AuthenticationScheme } from \"../../utils/Constants\";\nimport { TimeUtils } from \"../../utils/TimeUtils\";\nimport { StringUtils } from \"../../utils/StringUtils\";\nimport { ICrypto } from \"../../crypto/ICrypto\";\nimport { TokenClaims } from \"../../account/TokenClaims\";\nimport { AuthToken } from \"../../account/AuthToken\";\nimport { ClientAuthError } from \"../../error/ClientAuthError\";\n\n/**\n * ACCESS_TOKEN Credential Type\n *\n * Key:Value Schema:\n *\n * Key Example: uid.utid-login.microsoftonline.com-accesstoken-clientId-contoso.com-user.read\n *\n * Value Schema:\n * {\n * homeAccountId: home account identifier for the auth scheme,\n * environment: entity that issued the token, represented as a full host\n * credentialType: Type of credential as a string, can be one of the following: RefreshToken, AccessToken, IdToken, Password, Cookie, Certificate, Other\n * clientId: client ID of the application\n * secret: Actual credential as a string\n * familyId: Family ID identifier, usually only used for refresh tokens\n * realm: Full tenant or organizational identifier that the account belongs to\n * target: Permissions that are included in the token, or for refresh tokens, the resource identifier.\n * cachedAt: Absolute device time when entry was created in the cache.\n * expiresOn: Token expiry time, calculated based on current UTC time in seconds. Represented as a string.\n * extendedExpiresOn: Additional extended expiry time until when token is valid in case of server-side outage. Represented as string in UTC seconds.\n * keyId: used for POP and SSH tokenTypes\n * tokenType: Type of the token issued. Usually \"Bearer\"\n * }\n */\nexport class AccessTokenEntity extends CredentialEntity {\n realm: string;\n target: string;\n cachedAt: string;\n expiresOn: string;\n extendedExpiresOn?: string;\n refreshOn?: string;\n keyId?: string; // for POP and SSH tokenTypes\n tokenType?: AuthenticationScheme;\n requestedClaims?: string;\n requestedClaimsHash?: string;\n\n /**\n * Create AccessTokenEntity\n * @param homeAccountId\n * @param environment\n * @param accessToken\n * @param clientId\n * @param tenantId\n * @param scopes\n * @param expiresOn\n * @param extExpiresOn\n */\n static createAccessTokenEntity(\n homeAccountId: string,\n environment: string,\n accessToken: string,\n clientId: string,\n tenantId: string,\n scopes: string,\n expiresOn: number,\n extExpiresOn: number,\n cryptoUtils: ICrypto,\n refreshOn?: number,\n tokenType?: AuthenticationScheme,\n userAssertionHash?:string,\n keyId?: string,\n requestedClaims?: string,\n requestedClaimsHash?: string\n ): AccessTokenEntity {\n const atEntity: AccessTokenEntity = new AccessTokenEntity();\n\n atEntity.homeAccountId = homeAccountId;\n atEntity.credentialType = CredentialType.ACCESS_TOKEN;\n atEntity.secret = accessToken;\n\n const currentTime = TimeUtils.nowSeconds();\n atEntity.cachedAt = currentTime.toString();\n\n /*\n * Token expiry time.\n * This value should be  calculated based on the current UTC time measured locally and the value  expires_in Represented as a string in JSON.\n */\n atEntity.expiresOn = expiresOn.toString();\n atEntity.extendedExpiresOn = extExpiresOn.toString();\n if (refreshOn) {\n atEntity.refreshOn = refreshOn.toString();\n }\n\n atEntity.environment = environment;\n atEntity.clientId = clientId;\n atEntity.realm = tenantId;\n atEntity.target = scopes;\n atEntity.userAssertionHash = userAssertionHash;\n\n atEntity.tokenType = StringUtils.isEmpty(tokenType) ? AuthenticationScheme.BEARER : tokenType;\n\n if (requestedClaims) {\n atEntity.requestedClaims = requestedClaims;\n atEntity.requestedClaimsHash = requestedClaimsHash;\n }\n\n /*\n * Create Access Token With Auth Scheme instead of regular access token\n * Cast to lower to handle \"bearer\" from ADFS\n */\n if (atEntity.tokenType?.toLowerCase() !== AuthenticationScheme.BEARER.toLowerCase()) {\n atEntity.credentialType = CredentialType.ACCESS_TOKEN_WITH_AUTH_SCHEME;\n switch (atEntity.tokenType) {\n case AuthenticationScheme.POP:\n // Make sure keyId is present and add it to credential\n const tokenClaims: TokenClaims | null = AuthToken.extractTokenClaims(accessToken, cryptoUtils);\n if (!tokenClaims?.cnf?.kid) {\n throw ClientAuthError.createTokenClaimsRequiredError();\n }\n atEntity.keyId = tokenClaims.cnf.kid;\n break;\n case AuthenticationScheme.SSH:\n atEntity.keyId = keyId;\n }\n }\n\n return atEntity;\n }\n\n /**\n * Validates an entity: checks for all expected params\n * @param entity\n */\n static isAccessTokenEntity(entity: object): boolean {\n\n if (!entity) {\n return false;\n }\n\n return (\n entity.hasOwnProperty(\"homeAccountId\") &&\n entity.hasOwnProperty(\"environment\") &&\n entity.hasOwnProperty(\"credentialType\") &&\n entity.hasOwnProperty(\"realm\") &&\n entity.hasOwnProperty(\"clientId\") &&\n entity.hasOwnProperty(\"secret\") &&\n entity.hasOwnProperty(\"target\") &&\n (entity[\"credentialType\"] === CredentialType.ACCESS_TOKEN || entity[\"credentialType\"] === CredentialType.ACCESS_TOKEN_WITH_AUTH_SCHEME)\n );\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;AAAA;;;AAGG;AAWH;;;;;;;;;;;;;;;;;;;;;;;AAuBG;AACH,IAAA,iBAAA,kBAAA,UAAA,MAAA,EAAA;IAAuC,SAAgB,CAAA,iBAAA,E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GAA1B,UAA2B,MAAc,EAAA;QAErC,IAAI,CAAC,MAAM,EAAE;AACT,YAAA,OAAO,KAAK,CAAC;AAChB,SAAA;AAED,QAAA,QACI,MAAM,CAAC,cAAc,CAAC,eAAe,CAAC;AACtC,YAAA,MAAM,CAAC,cAAc,CAAC,aAAa,CAAC;AACpC,YAAA,MAAM,CAAC,cAAc,CAAC,gBAAgB,CAAC;AACvC,YAAA,MAAM,CAAC,cAAc,CAAC,OAAO,CAAC;AAC9B,YAAA,MAAM,CAAC,cAAc,CAAC,UAAU,CAAC;AACjC,YAAA,MAAM,CAAC,cAAc,CAAC,QAAQ,CAAC;AAC/B,YAAA,MAAM,CAAC,cAAc,CAAC,QAAQ,CAAC;AAC/B,aAAC,MAAM,CAAC,gBAAgB,CAAC,KAAK,cAAc,CAAC,YAAY,IAAI,MAAM,CAAC,gBAAgB,CAAC,KAAK,cAAc,CAAC,6BAA6B,CAAC,EACzI;KACL,CAAA;IACL,OAAC,iBAAA,CAAA;AAAD,CApHA,CAAuC,gBAAgB,CAoHtD;;;;"}
\ No newline at end of file
import { Authority } from "../../authority/Authority";
import { AuthToken } from "../../account/AuthToken";
import { ICrypto } from "../../crypto/ICrypto";
import { AccountInfo } from "../../account/AccountInfo";
import { AuthorityType } from "../../authority/AuthorityType";
import { Logger } from "../../logger/Logger";
import { TokenClaims } from "../../account/TokenClaims";
/**
* Type that defines required and optional parameters for an Account field (based on universal cache schema implemented by all MSALs).
*
* Key : Value Schema
*
* Key: <home_account_id>-<environment>-<realm*>
*
* Value Schema:
* {
* homeAccountId: home account identifier for the auth scheme,
* environment: entity that issued the token, represented as a full host
* realm: Full tenant or organizational identifier that the account belongs to
* localAccountId: Original tenant-specific accountID, usually used for legacy cases
* username: primary username that represents the user, usually corresponds to preferred_username in the v2 endpt
* authorityType: Accounts authority type as a string
* name: Full name for the account, including given name and family name,
* clientInfo: Full base64 encoded client info received from ESTS
* lastModificationTime: last time this entity was modified in the cache
* lastModificationApp:
* idTokenClaims: Object containing claims parsed from ID token
* nativeAccountId: Account identifier on the native device
* }
*/
export declare class AccountEntity {
homeAccountId: string;
environment: string;
realm: string;
localAccountId: string;
username: string;
authorityType: string;
name?: string;
clientInfo?: string;
lastModificationTime?: string;
lastModificationApp?: string;
cloudGraphHostName?: string;
msGraphHost?: string;
idTokenClaims?: TokenClaims;
nativeAccountId?: string;
/**
* Generate Account Id key component as per the schema: <home_account_id>-<environment>
*/
generateAccountId(): string;
/**
* Generate Account Cache Key as per the schema: <home_account_id>-<environment>-<realm*>
*/
generateAccountKey(): string;
/**
* returns the type of the cache (in this case account)
*/
generateType(): number;
/**
* Returns the AccountInfo interface for this account.
*/
getAccountInfo(): AccountInfo;
/**
* Generates account key from interface
* @param accountInterface
*/
static generateAccountCacheKey(accountInterface: AccountInfo): string;
/**
* Build Account cache from IdToken, clientInfo and authority/policy. Associated with AAD.
* @param clientInfo
* @param authority
* @param idToken
* @param policy
*/
static createAccount(clientInfo: string, homeAccountId: string, idToken: AuthToken, authority?: Authority, cloudGraphHostName?: string, msGraphHost?: string, environment?: string, nativeAccountId?: string): AccountEntity;
/**
* Builds non-AAD/ADFS account.
* @param authority
* @param idToken
*/
static createGenericAccount(homeAccountId: string, idToken: AuthToken, authority?: Authority, cloudGraphHostName?: string, msGraphHost?: string, environment?: string): AccountEntity;
/**
* Generate HomeAccountId from server response
* @param serverClientInfo
* @param authType
*/
static generateHomeAccountId(serverClientInfo: string, authType: AuthorityType, logger: Logger, cryptoObj: ICrypto, idToken?: AuthToken): string;
/**
* Validates an entity: checks for all expected params
* @param entity
*/
static isAccountEntity(entity: object): boolean;
/**
* Helper function to determine whether 2 accountInfo objects represent the same account
* @param accountA
* @param accountB
* @param compareClaims - If set to true idTokenClaims will also be compared to determine account equality
*/
static accountInfoIsEqual(accountA: AccountInfo | null, accountB: AccountInfo | null, compareClaims?: boolean): boolean;
}
//# sourceMappingURL=AccountEntity.d.ts.map
\ No newline at end of file
{"version":3,"file":"AccountEntity.d.ts","source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U,EAAE,MAAM,EAClB,aAAa,EAAE,MAAM,EACrB,OAAO,EAAE,SAAS,EAClB,SAAS,CAAC,EAAE,SAAS,EACrB,kBAAkB,CAAC,EAAE,MAAM,EAC3B,WAAW,CAAC,EAAE,MAAM,EACpB,WAAW,CAAC,EAAE,MAAM,EACpB,eAAe,CAAC,EAAE,MAAM,GACzB,aAAa;IA0ChB;;;;OAIG;IACH,MAAM,CAAC,oBAAoB,CACvB,aAAa,EAAE,MAAM,EACrB,OAAO,EAAE,SAAS,EAClB,SAAS,CAAC,EAAE,SAAS,EACrB,kBAAkB,CAAC,EAAE,MAAM,EAC3B,WAAW,CAAC,EAAE,MAAM,EACpB,WAAW,CAAC,EAAE,MAAM,GACrB,aAAa;IAwChB;;;;OAIG;IACH,MAAM,CAAC,qBAAqB,CACxB,gBAAgB,EAAE,MAAM,EACxB,QAAQ,EAAE,aAAa,EACvB,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,OAAO,EAClB,OAAO,CAAC,EAAE,SAAS,GACpB,MAAM;IAwBT;;;OAGG;IACH,MAAM,CAAC,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO;IAgB/C;;;;;OAKG;IACH,MAAM,CAAC,kBAAkB,CAAC,QAAQ,EAAE,WAAW,GAAG,IAAI,EAAE,QAAQ,EAAE,WAAW,GAAG,IAAI,EAAE,aAAa,CAAC,EAAE,OAAO,GAAG,OAAO;CAuB1H"}
\ No newline at end of file
/*! @azure/msal-common v9.0.1 2022-12-07 */
'use strict';
import { Separators, CacheAccountType, CacheType, Constants } from '../../utils/Constants.js';
import { buildClientInfo } from '../../account/ClientInfo.js';
import { StringUtils } from '../../utils/StringUtils.js';
import { ClientAuthError } from '../../error/ClientAuthError.js';
import { AuthorityType } from '../../authority/AuthorityType.js';
/*
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License.
*/
/**
* Type that defines required and optional parameters for an Account field (based on universal cache schema implemented by all MSALs).
*
* Key : Value Schema
*
* Key: <home_account_id>-<environment>-<realm*>
*
* Value Schema:
* {
* homeAccountId: home account identifier for the auth scheme,
* environment: entity that issued the token, represented as a full host
* realm: Full tenant or organizational identifier that the account belongs to
* localAccountId: Original tenant-specific accountID, usually used for legacy cases
* username: primary username that represents the user, usually corresponds to preferred_username in the v2 endpt
* authorityType: Accounts authority type as a string
* name: Full name for the account, including given name and family name,
* clientInfo: Full base64 encoded client info received from ESTS
* lastModificationTime: last time this entity was modified in the cache
* lastModificationApp:
* idTokenClaims: Object containing claims parsed from ID token
* nativeAccountId: Account identifier on the native device
* }
*/
var AccountEntity = /** @class */ (function () {
function AccountEntity() {
}
/**
* Generate Account Id key component as per the schema: <home_account_id>-<environment>
*/
AccountEntity.prototype.generateAccountId = function () {
var accountId = [this.homeAccountId, this.environment];
return accountId.join(Separators.CACHE_KEY_SEPARATOR).toLowerCase();
};
/**
* Generate Account Cache Key as per the schema: <home_account_id>-<environment>-<realm*>
*/
AccountEntity.prototype.generateAccountKey = function () {
return AccountEntity.generateAccountCacheKey({
homeAccountId: this.homeAccountId,
environment: this.environment,
tenantId: this.realm,
username: this.username,
localAccountId: this.localAccountId
});
};
/**
* returns the type of the cache (in this case account)
*/
AccountEntity.prototype.generateType = function () {
switch (this.authorityType) {
case CacheAccountType.ADFS_ACCOUNT_TYPE:
return CacheType.ADFS;
case CacheAccountType.MSAV1_ACCOUNT_TYPE:
return CacheType.MSA;
case CacheAccountType.MSSTS_ACCOUNT_TYPE:
return CacheType.MSSTS;
case CacheAccountType.GENERIC_ACCOUNT_TYPE:
return CacheType.GENERIC;
default: {
throw ClientAuthError.createUnexpectedAccountTypeError();
}
}
};
/**
* Returns the AccountInfo interface for this account.
*/
AccountEntity.prototype.getAccountInfo = function () {
return {
homeAccountId: this.homeAccountId,
environment: this.environment,
tenantId: this.realm,
username: this.username,
localAccountId: this.localAccountId,
name: this.name,
idTokenClaims: this.idTokenClaims,
nativeAccountId: this.nativeAccountId
};
};
/**
* Generates account key from interface
* @param accountInterface
*/
AccountEntity.generateAccountCacheKey = function (accountInterface) {
var accountKey = [
accountInterface.homeAccountId,
accountInterface.environment || Constants.EMPTY_STRING,
accountInterface.tenantId || Constants.EMPTY_STRING,
];
return accountKey.join(Separators.CACHE_KEY_SEPARATOR).toLowerCase();
};
/**
* Build Account cache from IdToken, clientInfo and authority/policy. Associated with AAD.
* @param clientInfo
* @param authority
* @param idToken
* @param policy
*/
AccountEntity.createAccount = function (clientInfo, homeAccountId, idToken, authority, cloudGraphHostName, msGraphHost, environment, nativeAccountId) {
var _a, _b, _c, _d, _e, _f;
var account = new AccountEntity();
account.authorityType = CacheAccountType.MSSTS_ACCOUNT_TYPE;
account.clientInfo = clientInfo;
account.homeAccountId = homeAccountId;
account.nativeAccountId = nativeAccountId;
var env = environment || (authority && authority.getPreferredCache());
if (!env) {
throw ClientAuthError.createInvalidCacheEnvironmentError();
}
account.environment = env;
// non AAD scenarios can have empty realm
account.realm = ((_a = idToken === null || idToken === void 0 ? void 0 : idToken.claims) === null || _a === void 0 ? void 0 : _a.tid) || Constants.EMPTY_STRING;
if (idToken) {
account.idTokenClaims = idToken.claims;
// How do you account for MSA CID here?
account.localAccountId = ((_b = idToken === null || idToken === void 0 ? void 0 : idToken.claims) === null || _b === void 0 ? void 0 : _b.oid) || ((_c = idToken === null || idToken === void 0 ? void 0 : idToken.claims) === null || _c === void 0 ? void 0 : _c.sub) || Constants.EMPTY_STRING;
/*
* In B2C scenarios the emails claim is used instead of preferred_username and it is an array.
* In most cases it will contain a single email. This field should not be relied upon if a custom
* policy is configured to return more than 1 email.
*/
var preferredUsername = (_d = idToken === null || idToken === void 0 ? void 0 : idToken.claims) === null || _d === void 0 ? void 0 : _d.preferred_username;
var email = ((_e = idToken === null || idToken === void 0 ? void 0 : idToken.claims) === null || _e === void 0 ? void 0 : _e.emails) ? idToken.claims.emails[0] : null;
account.username = preferredUsername || email || Constants.EMPTY_STRING;
account.name = (_f = idToken === null || idToken === void 0 ? void 0 : idToken.claims) === null || _f === void 0 ? void 0 : _f.name;
}
account.cloudGraphHostName = cloudGraphHostName;
account.msGraphHost = msGraphHost;
return account;
};
/**
* Builds non-AAD/ADFS account.
* @param authority
* @param idToken
*/
AccountEntity.createGenericAccount = function (homeAccountId, idToken, authority, cloudGraphHostName, msGraphHost, environment) {
var _a, _b, _c, _d;
var account = new AccountEntity();
account.authorityType = (authority &&
authority.authorityType === AuthorityType.Adfs) ? CacheAccountType.ADFS_ACCOUNT_TYPE : CacheAccountType.GENERIC_ACCOUNT_TYPE;
account.homeAccountId = homeAccountId;
// non AAD scenarios can have empty realm
account.realm = Constants.EMPTY_STRING;
var env = environment || authority && authority.getPreferredCache();
if (!env) {
throw ClientAuthError.createInvalidCacheEnvironmentError();
}
if (idToken) {
// How do you account for MSA CID here?
account.localAccountId = ((_a = idToken === null || idToken === void 0 ? void 0 : idToken.claims) === null || _a === void 0 ? void 0 : _a.oid) || ((_b = idToken === null || idToken === void 0 ? void 0 : idToken.claims) === null || _b === void 0 ? void 0 : _b.sub) || Constants.EMPTY_STRING;
// upn claim for most ADFS scenarios
account.username = ((_c = idToken === null || idToken === void 0 ? void 0 : idToken.claims) === null || _c === void 0 ? void 0 : _c.upn) || Constants.EMPTY_STRING;
account.name = ((_d = idToken === null || idToken === void 0 ? void 0 : idToken.claims) === null || _d === void 0 ? void 0 : _d.name) || Constants.EMPTY_STRING;
account.idTokenClaims = idToken === null || idToken === void 0 ? void 0 : idToken.claims;
}
account.environment = env;
account.cloudGraphHostName = cloudGraphHostName;
account.msGraphHost = msGraphHost;
/*
* add uniqueName to claims
* account.name = idToken.claims.uniqueName;
*/
return account;
};
/**
* Generate HomeAccountId from server response
* @param serverClientInfo
* @param authType
*/
AccountEntity.generateHomeAccountId = function (serverClientInfo, authType, logger, cryptoObj, idToken) {
var _a;
var accountId = ((_a = idToken === null || idToken === void 0 ? void 0 : idToken.claims) === null || _a === void 0 ? void 0 : _a.sub) ? idToken.claims.sub : Constants.EMPTY_STRING;
// since ADFS does not have tid and does not set client_info
if (authType === AuthorityType.Adfs || authType === AuthorityType.Dsts) {
return accountId;
}
// for cases where there is clientInfo
if (serverClientInfo) {
try {
var clientInfo = buildClientInfo(serverClientInfo, cryptoObj);
if (!StringUtils.isEmpty(clientInfo.uid) && !StringUtils.isEmpty(clientInfo.utid)) {
return "" + clientInfo.uid + Separators.CLIENT_INFO_SEPARATOR + clientInfo.utid;
}
}
catch (e) { }
}
// default to "sub" claim
logger.verbose("No client info in response");
return accountId;
};
/**
* Validates an entity: checks for all expected params
* @param entity
*/
AccountEntity.isAccountEntity = function (entity) {
if (!entity) {
return false;
}
return (entity.hasOwnProperty("homeAccountId") &&
entity.hasOwnProperty("environment") &&
entity.hasOwnProperty("realm") &&
entity.hasOwnProperty("localAccountId") &&
entity.hasOwnProperty("username") &&
entity.hasOwnProperty("authorityType"));
};
/**
* Helper function to determine whether 2 accountInfo objects represent the same account
* @param accountA
* @param accountB
* @param compareClaims - If set to true idTokenClaims will also be compared to determine account equality
*/
AccountEntity.accountInfoIsEqual = function (accountA, accountB, compareClaims) {
if (!accountA || !accountB) {
return false;
}
var claimsMatch = true; // default to true so as to not fail comparison below if compareClaims: false
if (compareClaims) {
var accountAClaims = (accountA.idTokenClaims || {});
var accountBClaims = (accountB.idTokenClaims || {});
// issued at timestamp and nonce are expected to change each time a new id token is acquired
claimsMatch = (accountAClaims.iat === accountBClaims.iat) &&
(accountAClaims.nonce === accountBClaims.nonce);
}
return (accountA.homeAccountId === accountB.homeAccountId) &&
(accountA.localAccountId === accountB.localAccountId) &&
(accountA.username === accountB.username) &&
(accountA.tenantId === accountB.tenantId) &&
(accountA.environment === accountB.environment) &&
(accountA.nativeAccountId === accountB.nativeAccountId) &&
claimsMatch;
};
return AccountEntity;
}());
export { AccountEntity };
//# sourceMappingURL=AccountEntity.js.map
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