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

Initial commit

parents
import { AccountCache, AccountFilter, CredentialFilter, CredentialCache, ValidCredentialType, AppMetadataFilter, AppMetadataCache } from "./utils/CacheTypes";
import { CacheRecord } from "./entities/CacheRecord";
import { CredentialEntity } from "./entities/CredentialEntity";
import { AccountEntity } from "./entities/AccountEntity";
import { AccessTokenEntity } from "./entities/AccessTokenEntity";
import { IdTokenEntity } from "./entities/IdTokenEntity";
import { RefreshTokenEntity } from "./entities/RefreshTokenEntity";
import { ICacheManager } from "./interface/ICacheManager";
import { AccountInfo } from "../account/AccountInfo";
import { AppMetadataEntity } from "./entities/AppMetadataEntity";
import { ServerTelemetryEntity } from "./entities/ServerTelemetryEntity";
import { ThrottlingEntity } from "./entities/ThrottlingEntity";
import { ICrypto } from "../crypto/ICrypto";
import { AuthorityMetadataEntity } from "./entities/AuthorityMetadataEntity";
import { BaseAuthRequest } from "../request/BaseAuthRequest";
/**
* Interface class which implement cache storage functions used by MSAL to perform validity checks, and store tokens.
*/
export declare abstract class CacheManager implements ICacheManager {
protected clientId: string;
protected cryptoImpl: ICrypto;
constructor(clientId: string, cryptoImpl: ICrypto);
/**
* fetch the account entity from the platform cache
* @param accountKey
*/
abstract getAccount(accountKey: string): AccountEntity | null;
/**
* set account entity in the platform cache
* @param account
*/
abstract setAccount(account: AccountEntity): void;
/**
* fetch the idToken entity from the platform cache
* @param idTokenKey
*/
abstract getIdTokenCredential(idTokenKey: string): IdTokenEntity | null;
/**
* set idToken entity to the platform cache
* @param idToken
*/
abstract setIdTokenCredential(idToken: IdTokenEntity): void;
/**
* fetch the idToken entity from the platform cache
* @param accessTokenKey
*/
abstract getAccessTokenCredential(accessTokenKey: string): AccessTokenEntity | null;
/**
* set idToken entity to the platform cache
* @param accessToken
*/
abstract setAccessTokenCredential(accessToken: AccessTokenEntity): void;
/**
* fetch the idToken entity from the platform cache
* @param refreshTokenKey
*/
abstract getRefreshTokenCredential(refreshTokenKey: string): RefreshTokenEntity | null;
/**
* set idToken entity to the platform cache
* @param refreshToken
*/
abstract setRefreshTokenCredential(refreshToken: RefreshTokenEntity): void;
/**
* fetch appMetadata entity from the platform cache
* @param appMetadataKey
*/
abstract getAppMetadata(appMetadataKey: string): AppMetadataEntity | null;
/**
* set appMetadata entity to the platform cache
* @param appMetadata
*/
abstract setAppMetadata(appMetadata: AppMetadataEntity): void;
/**
* fetch server telemetry entity from the platform cache
* @param serverTelemetryKey
*/
abstract getServerTelemetry(serverTelemetryKey: string): ServerTelemetryEntity | null;
/**
* set server telemetry entity to the platform cache
* @param serverTelemetryKey
* @param serverTelemetry
*/
abstract setServerTelemetry(serverTelemetryKey: string, serverTelemetry: ServerTelemetryEntity): void;
/**
* fetch cloud discovery metadata entity from the platform cache
* @param key
*/
abstract getAuthorityMetadata(key: string): AuthorityMetadataEntity | null;
/**
*
*/
abstract getAuthorityMetadataKeys(): Array<string>;
/**
* set cloud discovery metadata entity to the platform cache
* @param key
* @param value
*/
abstract setAuthorityMetadata(key: string, value: AuthorityMetadataEntity): void;
/**
* fetch throttling entity from the platform cache
* @param throttlingCacheKey
*/
abstract getThrottlingCache(throttlingCacheKey: string): ThrottlingEntity | null;
/**
* set throttling entity to the platform cache
* @param throttlingCacheKey
* @param throttlingCache
*/
abstract setThrottlingCache(throttlingCacheKey: string, throttlingCache: ThrottlingEntity): void;
/**
* Function to remove an item from cache given its key.
* @param key
*/
abstract removeItem(key: string, type?: string): boolean;
/**
* Function which returns boolean whether cache contains a specific key.
* @param key
*/
abstract containsKey(key: string, type?: string): boolean;
/**
* Function which retrieves all current keys from the cache.
*/
abstract getKeys(): string[];
/**
* Function which clears cache.
*/
abstract clear(): Promise<void>;
/**
* Function which updates an outdated credential cache key
*/
abstract updateCredentialCacheKey(currentCacheKey: string, credential: ValidCredentialType): string;
/**
* Returns all accounts in cache
*/
getAllAccounts(): AccountInfo[];
/**
* saves a cache record
* @param cacheRecord
*/
saveCacheRecord(cacheRecord: CacheRecord): Promise<void>;
/**
* saves access token credential
* @param credential
*/
private saveAccessToken;
/**
* 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
*/
getAccountsFilteredBy(accountFilter?: AccountFilter): AccountCache;
/**
* 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
*/
private getAccountsFilteredByInternal;
/**
* 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
*/
getCredentialsFilteredBy(filter: CredentialFilter): CredentialCache;
/**
* Support function to help match credentials
* @param homeAccountId
* @param environment
* @param credentialType
* @param clientId
* @param realm
* @param target
* @param userAssertionHash
* @param tokenType
*/
private getCredentialsFilteredByInternal;
/**
* retrieve appMetadata matching all provided filters; if no filter is set, get all appMetadata
* @param filter
*/
getAppMetadataFilteredBy(filter: AppMetadataFilter): AppMetadataCache;
/**
* Support function to help match appMetadata
* @param environment
* @param clientId
*/
private getAppMetadataFilteredByInternal;
/**
* retrieve authorityMetadata that contains a matching alias
* @param filter
*/
getAuthorityMetadataByAlias(host: string): AuthorityMetadataEntity | null;
/**
* Removes all accounts and related tokens from cache.
*/
removeAllAccounts(): Promise<boolean>;
/**
* returns a boolean if the given account is removed
* @param account
*/
removeAccount(accountKey: string): Promise<boolean>;
/**
* Removes credentials associated with the provided account
* @param account
*/
removeAccountContext(account: AccountEntity): Promise<boolean>;
/**
* returns a boolean if the given credential is removed
* @param credential
*/
removeCredential(credential: CredentialEntity): Promise<boolean>;
/**
* Removes all app metadata objects from cache.
*/
removeAppMetadata(): boolean;
/**
* Retrieve the cached credentials into a cacherecord
* @param account
* @param clientId
* @param scopes
* @param environment
* @param authScheme
*/
readCacheRecord(account: AccountInfo, clientId: string, request: BaseAuthRequest, environment: string): CacheRecord;
/**
* Retrieve AccountEntity from cache
* @param account
*/
readAccountFromCache(account: AccountInfo): AccountEntity | null;
/**
* Retrieve AccountEntity from cache
* @param nativeAccountId
* @returns AccountEntity or Null
*/
readAccountFromCacheWithNativeAccountId(nativeAccountId: string): AccountEntity | null;
/**
* Retrieve IdTokenEntity from cache
* @param clientId
* @param account
* @param inputRealm
*/
readIdTokenFromCache(clientId: string, account: AccountInfo): IdTokenEntity | null;
/**
* Retrieve AccessTokenEntity from cache
* @param clientId
* @param account
* @param scopes
* @param authScheme
*/
readAccessTokenFromCache(clientId: string, account: AccountInfo, request: BaseAuthRequest): AccessTokenEntity | null;
/**
* Helper to retrieve the appropriate refresh token from cache
* @param clientId
* @param account
* @param familyRT
*/
readRefreshTokenFromCache(clientId: string, account: AccountInfo, familyRT: boolean): RefreshTokenEntity | null;
/**
* Retrieve AppMetadataEntity from cache
*/
readAppMetadataFromCache(environment: string, clientId: string): AppMetadataEntity | null;
/**
* Return the family_id value associated with FOCI
* @param environment
* @param clientId
*/
isAppMetadataFOCI(environment: string, clientId: string): boolean;
/**
* helper to match account ids
* @param value
* @param homeAccountId
*/
private matchHomeAccountId;
/**
* helper to match assertion
* @param value
* @param oboAssertion
*/
private matchUserAssertionHash;
/**
* helper to match environment
* @param value
* @param environment
*/
private matchEnvironment;
/**
* helper to match credential type
* @param entity
* @param credentialType
*/
private matchCredentialType;
/**
* helper to match client ids
* @param entity
* @param clientId
*/
private matchClientId;
/**
* helper to match family ids
* @param entity
* @param familyId
*/
private matchFamilyId;
/**
* helper to match realm
* @param entity
* @param realm
*/
private matchRealm;
/**
* helper to match nativeAccountId
* @param entity
* @param nativeAccountId
* @returns boolean indicating the match result
*/
private matchNativeAccountId;
/**
* Returns true if the target scopes are a subset of the current entity's scopes, false otherwise.
* @param entity
* @param target
*/
private matchTarget;
/**
* Returns true if the credential's tokenType or Authentication Scheme matches the one in the request, false otherwise
* @param entity
* @param tokenType
*/
private matchTokenType;
/**
* Returns true if the credential's keyId matches the one in the request, false otherwise
* @param entity
* @param tokenType
*/
private matchKeyId;
/**
* returns if a given cache entity is of the type appmetadata
* @param key
*/
private isAppMetadata;
/**
* returns if a given cache entity is of the type authoritymetadata
* @param key
*/
protected isAuthorityMetadata(key: string): boolean;
/**
* returns cache key used for cloud instance metadata
*/
generateAuthorityMetadataCacheKey(authority: string): string;
/**
* Returns the specific credential (IdToken/AccessToken/RefreshToken) from the cache
* @param key
* @param credType
*/
private getSpecificCredential;
/**
* Helper to convert serialized data to object
* @param obj
* @param json
*/
static toObject<T>(obj: T, json: object): T;
}
export declare class DefaultStorageClass extends CacheManager {
setAccount(): void;
getAccount(): AccountEntity;
setIdTokenCredential(): void;
getIdTokenCredential(): IdTokenEntity;
setAccessTokenCredential(): void;
getAccessTokenCredential(): AccessTokenEntity;
setRefreshTokenCredential(): void;
getRefreshTokenCredential(): RefreshTokenEntity;
setAppMetadata(): void;
getAppMetadata(): AppMetadataEntity;
setServerTelemetry(): void;
getServerTelemetry(): ServerTelemetryEntity;
setAuthorityMetadata(): void;
getAuthorityMetadata(): AuthorityMetadataEntity | null;
getAuthorityMetadataKeys(): Array<string>;
setThrottlingCache(): void;
getThrottlingCache(): ThrottlingEntity;
removeItem(): boolean;
containsKey(): boolean;
getKeys(): string[];
clear(): Promise<void>;
updateCredentialCacheKey(): string;
}
//# sourceMappingURL=CacheManager.d.ts.map
\ 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,CAA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CAAC,cAAc;IAItB;;;;OAIG;IACH,OAAO,CAAC,UAAU;IAIlB;;;OAGG;IACH,OAAO,CAAC,aAAa;IAIrB;;;OAGG;IACH,SAAS,CAAC,mBAAmB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO;IAInD;;OAEG;IACH,iCAAiC,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM;IAI5D;;;;OAIG;IACH,OAAO,CAAC,qBAAqB;IAiB7B;;;;OAIG;IACH,MAAM,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,GAAG,CAAC;CAM9C;AAED,qBAAa,mBAAoB,SAAQ,YAAY;IACjD,UAAU,IAAI,IAAI;IAIlB,UAAU,IAAI,aAAa;IAI3B,oBAAoB,IAAI,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,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AAC,CAAC;KACrD,CAAA;AACD,IAAA,mBAAA,CAAA,SAAA,CAAA,UAAU,GAAV,YAAA;QACI,IAAM,UAAU,GAAG,2FAA2F,CAAC;AAC/G,QAAA,MAAM,SAAS,CAAC,qBAAqB,CAAC,UAAU,CAAC,CAAC;KACrD,CAAA;AACD,IAAA,mBAAA,CAAA,SAAA,CAAA,WAAW,GAAX,YAAA;QACI,IAAM,UAAU,GAAG,4FAA4F,CAAC;AAChH,QAAA,MAAM,SAAS,CAAC,qBAAqB,CAAC,UAAU,CAAC,CAAC;KACrD,CAAA;AACD,IAAA,mBAAA,CAAA,SAAA,CAAA,OAAO,GAAP,YAAA;QACI,IAAM,UAAU,GAAG,wFAAwF,CAAC;AAC5G,QAAA,MAAM,SAAS,CAAC,qBAAqB,CAAC,UAAU,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,EAAA,MAAA,CAAA,CAAA;AAAvD,IAAA,SAAA,iBAAA,GAAA;;KAoHC;AAxGG;;;;;;;;;;AAUG;AACI,IAAA,iBAAA,CAAA,uBAAuB,GAA9B,UACI,aAAqB,EACrB,WAAmB,EACnB,WAAmB,EACnB,QAAgB,EAChB,QAAgB,EAChB,MAAc,EACd,SAAiB,EACjB,YAAoB,EACpB,WAAoB,EACpB,SAAkB,EAClB,SAAgC,EAChC,iBAAyB,EACzB,KAAc,EACd,eAAwB,EACxB,mBAA4B,EAAA;;AAE5B,QAAA,IAAM,QAAQ,GAAsB,IAAI,iBAAiB,EAAE,CAAC;AAE5D,QAAA,QAAQ,CAAC,aAAa,GAAG,aAAa,CAAC;AACvC,QAAA,QAAQ,CAAC,cAAc,GAAG,cAAc,CAAC,YAAY,CAAC;AACtD,QAAA,QAAQ,CAAC,MAAM,GAAG,WAAW,CAAC;AAE9B,QAAA,IAAM,WAAW,GAAG,SAAS,CAAC,UAAU,EAAE,CAAC;AAC3C,QAAA,QAAQ,CAAC,QAAQ,GAAG,WAAW,CAAC,QAAQ,EAAE,CAAC;AAE3C;;;AAGG;AACH,QAAA,QAAQ,CAAC,SAAS,GAAG,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AW,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAX,WAAW,CAAE,GAAG,MAAA,IAAA,IAAA,EAAA,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAA,EAAA,CAAE,GAAG,CAAA,EAAE;AACxB,wBAAA,MAAM,eAAe,CAAC,8BAA8B,EAAE,CAAC;AAC1D,qBAAA;oBACD,QAAQ,CAAC,KAAK,GAAG,WAAW,CAAC,GAAG,CAAC,GAAG,CAAC;oBACrC,MAAM;gBACV,KAAK,oBAAoB,CAAC,GAAG;AACzB,oBAAA,QAAQ,CAAC,KAAK,GAAG,KAAK,CAAC;AAC9B,aAAA;AACJ,SAAA;AAED,QAAA,OAAO,QAAQ,CAAC;KACnB,CAAA;AAED;;;AAGG;IACI,iBAAmB,CAAA,mBAAA,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","sourceRoot":"","sources":["../../../src/cache/entities/AccountEntity.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AACtD,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACpD,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAG/C,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAExD,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAC9D,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAExD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,qBAAa,aAAa;IACtB,aAAa,EAAE,MAAM,CAAC;IACtB,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,cAAc,EAAE,MAAM,CAAC;IACvB,QAAQ,EAAE,MAAM,CAAC;IACjB,aAAa,EAAE,MAAM,CAAC;IACtB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,oBAAoB,CAA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H,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
{"version":3,"file":"AccountEntity.js","sources":["../../../src/cache/entities/AccountEntity.ts"],"sourcesContent":["/*\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n Separators,\n CacheAccountType,\n CacheType,\n Constants,\n} from \"../../utils/Constants\";\nimport { Authority } from \"../../authority/Authority\";\nimport { AuthToken } from \"../../account/AuthToken\";\nimport { ICrypto } from \"../../crypto/ICrypto\";\nimport { buildClientInfo } from \"../../account/ClientInfo\";\nimport { StringUtils } from \"../../utils/StringUtils\";\nimport { AccountInfo } from \"../../account/AccountInfo\";\nimport { ClientAuthError } from \"../../error/ClientAuthError\";\nimport { AuthorityType } from \"../../authority/AuthorityType\";\nimport { Logger } from \"../../logger/Logger\";\nimport { TokenClaims } from \"../../account/TokenClaims\";\n\n/**\n * Type that defines required and optional parameters for an Account field (based on universal cache schema implemented by all MSALs).\n *\n * Key : Value Schema\n *\n * Key: <home_account_id>-<environment>-<realm*>\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 * realm: Full tenant or organizational identifier that the account belongs to\n * localAccountId: Original tenant-specific accountID, usually used for legacy cases\n * username: primary username that represents the user, usually corresponds to preferred_username in the v2 endpt\n * authorityType: Accounts authority type as a string\n * name: Full name for the account, including given name and family name,\n * clientInfo: Full base64 encoded client info received from ESTS\n * lastModificationTime: last time this entity was modified in the cache\n * lastModificationApp:\n * idTokenClaims: Object containing claims parsed from ID token\n * nativeAccountId: Account identifier on the native device\n * }\n */\nexport class AccountEntity {\n homeAccountId: string;\n environment: string;\n realm: string;\n localAccountId: string;\n username: string;\n authorityType: string;\n name?: string;\n clientInfo?: string;\n lastModificationTime?: string;\n lastModificationApp?: string;\n cloudGraphHostName?: string;\n msGraphHost?: string;\n idTokenClaims?: TokenClaims;\n nativeAccountId?: string;\n\n /**\n * Generate Account Id key component as per the schema: <home_account_id>-<environment>\n */\n generateAccountId(): string {\n const accountId: Array<string> = [this.homeAccountId, this.environment];\n return accountId.join(Separators.CACHE_KEY_SEPARATOR).toLowerCase();\n }\n\n /**\n * Generate Account Cache Key as per the schema: <home_account_id>-<environment>-<realm*>\n */\n generateAccountKey(): string {\n return AccountEntity.generateAccountCacheKey({\n homeAccountId: this.homeAccountId,\n environment: this.environment,\n tenantId: this.realm,\n username: this.username,\n localAccountId: this.localAccountId\n });\n }\n\n /**\n * returns the type of the cache (in this case account)\n */\n generateType(): number {\n switch (this.authorityType) {\n case CacheAccountType.ADFS_ACCOUNT_TYPE:\n return CacheType.ADFS;\n case CacheAccountType.MSAV1_ACCOUNT_TYPE:\n return CacheType.MSA;\n case CacheAccountType.MSSTS_ACCOUNT_TYPE:\n return CacheType.MSSTS;\n case CacheAccountType.GENERIC_ACCOUNT_TYPE:\n return CacheType.GENERIC;\n default: {\n throw ClientAuthError.createUnexpectedAccountTypeError();\n }\n }\n }\n\n /**\n * Returns the AccountInfo interface for this account.\n */\n getAccountInfo(): AccountInfo {\n return {\n homeAccountId: this.homeAccountId,\n environment: this.environment,\n tenantId: this.realm,\n username: this.username,\n localAccountId: this.localAccountId,\n name: this.name,\n idTokenClaims: this.idTokenClaims,\n nativeAccountId: this.nativeAccountId\n };\n }\n\n /**\n * Generates account key from interface\n * @param accountInterface\n */\n static generateAccountCacheKey(accountInterface: AccountInfo): string {\n const accountKey = [\n accountInterface.homeAccountId,\n accountInterface.environment || Constants.EMPTY_STRING,\n accountInterface.tenantId || Constants.EMPTY_STRING,\n ];\n\n return accountKey.join(Separators.CACHE_KEY_SEPARATOR).toLowerCase();\n }\n\n /**\n * Build Account cache from IdToken, clientInfo and authority/policy. Associated with AAD.\n * @param clientInfo\n * @param authority\n * @param idToken\n * @param policy\n */\n static createAccount(\n clientInfo: string,\n homeAccountId: string,\n idToken: AuthToken,\n authority?: Authority,\n cloudGraphHostName?: string,\n msGraphHost?: string,\n environment?: string,\n nativeAccountId?: string\n ): AccountEntity {\n const account: AccountEntity = new AccountEntity();\n\n account.authorityType = CacheAccountType.MSSTS_ACCOUNT_TYPE;\n account.clientInfo = clientInfo;\n account.homeAccountId = homeAccountId;\n account.nativeAccountId = nativeAccountId;\n\n const env = environment || (authority && authority.getPreferredCache());\n\n if (!env) {\n throw ClientAuthError.createInvalidCacheEnvironmentError();\n }\n\n account.environment = env;\n // non AAD scenarios can have empty realm\n account.realm = idToken?.claims?.tid || Constants.EMPTY_STRING;\n\n if (idToken) {\n account.idTokenClaims = idToken.claims;\n\n // How do you account for MSA CID here?\n account.localAccountId = idToken?.claims?.oid || idToken?.claims?.sub || Constants.EMPTY_STRING;\n\n /*\n * In B2C scenarios the emails claim is used instead of preferred_username and it is an array.\n * In most cases it will contain a single email. This field should not be relied upon if a custom \n * policy is configured to return more than 1 email.\n */\n const preferredUsername = idToken?.claims?.preferred_username;\n const email = (idToken?.claims?.emails) ? idToken.claims.emails[0] : null;\n \n account.username = preferredUsername || email || Constants.EMPTY_STRING;\n account.name = idToken?.claims?.name;\n }\n\n account.cloudGraphHostName = cloudGraphHostName;\n account.msGraphHost = msGraphHost;\n\n return account;\n }\n\n /**\n * Builds non-AAD/ADFS account.\n * @param authority\n * @param idToken\n */\n static createGenericAccount(\n homeAccountId: string,\n idToken: AuthToken,\n authority?: Authority,\n cloudGraphHostName?: string,\n msGraphHost?: string,\n environment?: string\n ): AccountEntity {\n const account: AccountEntity = new AccountEntity();\n\n account.authorityType = (\n authority &&\n authority.authorityType === AuthorityType.Adfs\n ) ? CacheAccountType.ADFS_ACCOUNT_TYPE : CacheAccountType.GENERIC_ACCOUNT_TYPE;\n \n account.homeAccountId = homeAccountId;\n // non AAD scenarios can have empty realm\n account.realm = Constants.EMPTY_STRING;\n\n const env = environment || authority && authority.getPreferredCache();\n\n if (!env) {\n throw ClientAuthError.createInvalidCacheEnvironmentError();\n }\n\n if (idToken) {\n // How do you account for MSA CID here?\n account.localAccountId = idToken?.claims?.oid || idToken?.claims?.sub || Constants.EMPTY_STRING;\n // upn claim for most ADFS scenarios\n account.username = idToken?.claims?.upn || Constants.EMPTY_STRING;\n account.name = idToken?.claims?.name || Constants.EMPTY_STRING;\n account.idTokenClaims = idToken?.claims;\n }\n\n account.environment = env;\n\n account.cloudGraphHostName = cloudGraphHostName;\n account.msGraphHost = msGraphHost;\n\n /*\n * add uniqueName to claims\n * account.name = idToken.claims.uniqueName;\n */\n\n return account;\n }\n\n /**\n * Generate HomeAccountId from server response\n * @param serverClientInfo\n * @param authType\n */\n static generateHomeAccountId(\n serverClientInfo: string,\n authType: AuthorityType,\n logger: Logger,\n cryptoObj: ICrypto,\n idToken?: AuthToken\n ): string {\n\n const accountId = idToken?.claims?.sub ? idToken.claims.sub : Constants.EMPTY_STRING;\n\n // since ADFS does not have tid and does not set client_info\n if (authType === AuthorityType.Adfs || authType === AuthorityType.Dsts) {\n return accountId;\n }\n\n // for cases where there is clientInfo\n if (serverClientInfo) {\n try {\n const clientInfo = buildClientInfo(serverClientInfo, cryptoObj);\n if (!StringUtils.isEmpty(clientInfo.uid) && !StringUtils.isEmpty(clientInfo.utid)) {\n return `${clientInfo.uid}${Separators.CLIENT_INFO_SEPARATOR}${clientInfo.utid}`;\n }\n } catch (e) {}\n }\n\n // default to \"sub\" claim\n logger.verbose(\"No client info in response\");\n return accountId;\n }\n\n /**\n * Validates an entity: checks for all expected params\n * @param entity\n */\n static isAccountEntity(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(\"realm\") &&\n entity.hasOwnProperty(\"localAccountId\") &&\n entity.hasOwnProperty(\"username\") &&\n entity.hasOwnProperty(\"authorityType\")\n );\n }\n\n /**\n * Helper function to determine whether 2 accountInfo objects represent the same account\n * @param accountA\n * @param accountB\n * @param compareClaims - If set to true idTokenClaims will also be compared to determine account equality\n */\n static accountInfoIsEqual(accountA: AccountInfo | null, accountB: AccountInfo | null, compareClaims?: boolean): boolean {\n if (!accountA || !accountB) {\n return false;\n }\n\n let claimsMatch = true; // default to true so as to not fail comparison below if compareClaims: false\n if (compareClaims) {\n const accountAClaims = (accountA.idTokenClaims || {}) as TokenClaims;\n const accountBClaims = (accountB.idTokenClaims || {}) as TokenClaims;\n\n // issued at timestamp and nonce are expected to change each time a new id token is acquired\n claimsMatch = (accountAClaims.iat === accountBClaims.iat) &&\n (accountAClaims.nonce === accountBClaims.nonce);\n }\n\n return (accountA.homeAccountId === accountB.homeAccountId) &&\n (accountA.localAccountId === accountB.localAccountId) &&\n (accountA.username === accountB.username) &&\n (accountA.tenantId === accountB.tenantId) &&\n (accountA.environment === accountB.environment) &&\n (accountA.nativeAccountId === accountB.nativeAccountId) &&\n claimsMatch;\n }\n}\n"],"names":[],"mappings":";;;;;;;;AAAA;;;AAGG;AAmBH;;;;;;;;;;;;;;;;;;;;;;AAsBG;AACH,IAAA,aAAA,kBAAA,YAAA;AAAA,IAAA,SAAA,aAAA,GAAA;KAwRC;AAxQG;;AAEG;AACH,IAAA,aAAA,CAAA,SAAA,CAAA,iBAAiB,GAAjB,YAAA;QACI,IAAM,SAAS,GAAkB,CAAC,IAAI,CAAC,aAAa,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC;QACxE,OAAO,SAAS,CAAC,IAAI,CAAC,UAAU,CAAC,mBAAmB,CAAC,CAAC,WAAW,EAAE,CAAC;KACvE,C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_METADATA Cache
*
* Key:Value Schema:
*
* Key: appmetadata-<environment>-<client_id>
*
* Value:
* {
* clientId: client ID of the application
* environment: entity that issued the token, represented as a full host
* familyId: Family ID identifier, '1' represents Microsoft Family
* }
*/
export declare class AppMetadataEntity {
clientId: string;
environment: string;
familyId?: string;
/**
* Generate AppMetadata Cache Key as per the schema: appmetadata-<environment>-<client_id>
*/
generateAppMetadataKey(): string;
/**
* Generate AppMetadata Cache Key
*/
static generateAppMetadataCacheKey(environment: string, clientId: string): string;
/**
* Creates AppMetadataEntity
* @param clientId
* @param environment
* @param familyId
*/
static createAppMetadataEntity(clientId: string, environment: string, familyId?: string): AppMetadataEntity;
/**
* Validates an entity: checks for all expected params
* @param entity
*/
static isAppMetadataEntity(key: string, entity: object): boolean;
}
//# sourceMappingURL=AppMetadataEntity.d.ts.map
\ No newline at end of file
{"version":3,"file":"AppMetadataEntity.d.ts","sourceRoot":"","sources":["../../../src/cache/entities/AppMetadataEntity.ts"],"names":[],"mappings":"AAOA;;;;;;;;;;;;;GAaG;AACH,qBAAa,iBAAiB;IAC1B,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB;;OAEG;IACH,sBAAsB,IAAI,MAAM;IAIhC;;OAEG;IACH,MAAM,CAAC,2BAA2B,CAAC,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM;IASjF;;;;;OAKG;IACH,MAAM,CAAC,uBAAuB,CAAC,QAAQ,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,iBAAiB;IAY3G;;;OAGG;IACH,MAAM,CAAC,mBAAmB,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO;CAYnE"}
\ No newline at end of file
/*! @azure/msal-common v9.0.1 2022-12-07 */
'use strict';
import { Separators, APP_METADATA } from '../../utils/Constants.js';
/*
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License.
*/
/**
* APP_METADATA Cache
*
* Key:Value Schema:
*
* Key: appmetadata-<environment>-<client_id>
*
* Value:
* {
* clientId: client ID of the application
* environment: entity that issued the token, represented as a full host
* familyId: Family ID identifier, '1' represents Microsoft Family
* }
*/
var AppMetadataEntity = /** @class */ (function () {
function AppMetadataEntity() {
}
/**
* Generate AppMetadata Cache Key as per the schema: appmetadata-<environment>-<client_id>
*/
AppMetadataEntity.prototype.generateAppMetadataKey = function () {
return AppMetadataEntity.generateAppMetadataCacheKey(this.environment, this.clientId);
};
/**
* Generate AppMetadata Cache Key
*/
AppMetadataEntity.generateAppMetadataCacheKey = function (environment, clientId) {
var appMetaDataKeyArray = [
APP_METADATA,
environment,
clientId,
];
return appMetaDataKeyArray.join(Separators.CACHE_KEY_SEPARATOR).toLowerCase();
};
/**
* Creates AppMetadataEntity
* @param clientId
* @param environment
* @param familyId
*/
AppMetadataEntity.createAppMetadataEntity = function (clientId, environment, familyId) {
var appMetadata = new AppMetadataEntity();
appMetadata.clientId = clientId;
appMetadata.environment = environment;
if (familyId) {
appMetadata.familyId = familyId;
}
return appMetadata;
};
/**
* Validates an entity: checks for all expected params
* @param entity
*/
AppMetadataEntity.isAppMetadataEntity = function (key, entity) {
if (!entity) {
return false;
}
return (key.indexOf(APP_METADATA) === 0 &&
entity.hasOwnProperty("clientId") &&
entity.hasOwnProperty("environment"));
};
return AppMetadataEntity;
}());
export { AppMetadataEntity };
//# sourceMappingURL=AppMetadataEntity.js.map
{"version":3,"file":"AppMetadataEntity.js","sources":["../../../src/cache/entities/AppMetadataEntity.ts"],"sourcesContent":["/*\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { APP_METADATA, Separators } from \"../../utils/Constants\";\n\n/**\n * APP_METADATA Cache\n *\n * Key:Value Schema:\n *\n * Key: appmetadata-<environment>-<client_id>\n *\n * Value:\n * {\n * clientId: client ID of the application\n * environment: entity that issued the token, represented as a full host\n * familyId: Family ID identifier, '1' represents Microsoft Family\n * }\n */\nexport class AppMetadataEntity {\n clientId: string;\n environment: string;\n familyId?: string;\n\n /**\n * Generate AppMetadata Cache Key as per the schema: appmetadata-<environment>-<client_id>\n */\n generateAppMetadataKey(): string {\n return AppMetadataEntity.generateAppMetadataCacheKey(this.environment, this.clientId);\n }\n\n /**\n * Generate AppMetadata Cache Key\n */\n static generateAppMetadataCacheKey(environment: string, clientId: string): string {\n const appMetaDataKeyArray: Array<string> = [\n APP_METADATA,\n environment,\n clientId,\n ];\n return appMetaDataKeyArray.join(Separators.CACHE_KEY_SEPARATOR).toLowerCase();\n }\n\n /**\n * Creates AppMetadataEntity\n * @param clientId\n * @param environment\n * @param familyId\n */\n static createAppMetadataEntity(clientId: string, environment: string, familyId?: string): AppMetadataEntity {\n const appMetadata = new AppMetadataEntity();\n\n appMetadata.clientId = clientId;\n appMetadata.environment = environment;\n if (familyId) {\n appMetadata.familyId = familyId;\n }\n\n return appMetadata;\n }\n\n /**\n * Validates an entity: checks for all expected params\n * @param entity\n */\n static isAppMetadataEntity(key: string, entity: object): boolean {\n\n if (!entity) {\n return false;\n }\n\n return (\n key.indexOf(APP_METADATA) === 0 &&\n entity.hasOwnProperty(\"clientId\") &&\n entity.hasOwnProperty(\"environment\")\n );\n }\n}\n"],"names":[],"mappings":";;;;AAAA;;;AAGG;AAIH;;;;;;;;;;;;;AAaG;AACH,IAAA,iBAAA,kBAAA,YAAA;AAAA,IAAA,SAAA,iBAAA,GAAA;KA0DC;AArDG;;AAEG;AACH,IAAA,iBAAA,CAAA,SAAA,CAAA,sBAAsB,GAAtB,YAAA;AACI,QAAA,OAAO,iBAAiB,CAAC,2BAA2B,CAAC,IAAI,CAAC,WAAW,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC;KACzF,CAAA;AAED;;AAEG;AACI,IAAA,iBAAA,CAAA,2BAA2B,GAAlC,UAAmC,WAAmB,EAAE,QAAgB,EAAA;AACpE,QAAA,IAAM,mBAAmB,GAAkB;YACvC,YAAY;YACZ,WAAW;YACX,QAAQ;SACX,CAAC;QACF,OAAO,mBAAmB,CAAC,IAAI,CAAC,UAAU,CAAC,mBAAmB,CAAC,CAAC,WAAW,EAAE,CAAC;KACjF,CAAA;AAED;;;;;AAKG;AACI,IAAA,iBAAA,CAAA,uBAAuB,GAA9B,UAA+B,QAAgB,EAAE,WAAmB,EAAE,QAAiB,EAAA;AACnF,QAAA,IAAM,WAAW,GAAG,IAAI,iBAAiB,EAAE,CAAC;AAE5C,QAAA,WAAW,CAAC,QAAQ,GAAG,QAAQ,CAAC;AAChC,QAAA,WAAW,CAAC,WAAW,GAAG,WAAW,CAAC;AACtC,QAAA,IAAI,QAAQ,EAAE;AACV,YAAA,WAAW,CAAC,QAAQ,GAAG,QAAQ,CAAC;AACnC,SAAA;AAED,QAAA,OAAO,WAAW,CAAC;KACtB,CAAA;AAED;;;AAGG;AACI,IAAA,iBAAA,CAAA,mBAAmB,GAA1B,UAA2B,GAAW,EAAE,MAAc,EAAA;QAElD,IAAI,CAAC,MAAM,EAAE;AACT,YAAA,OAAO,KAAK,CAAC;AAChB,SAAA;QAED,QACI,GAAG,CAAC,OAAO,CAAC,YAAY,CAAC,KAAK,CAAC;AAC/B,YAAA,MAAM,CAAC,cAAc,CAAC,UAAU,CAAC;AACjC,YAAA,MAAM,CAAC,cAAc,CAAC,aAAa,CAAC,EACtC;KACL,CAAA;IACL,OAAC,iBAAA,CAAA;AAAD,CAAC,EAAA;;;;"}
\ No newline at end of file
import { CloudDiscoveryMetadata } from "../../authority/CloudDiscoveryMetadata";
import { OpenIdConfigResponse } from "../../authority/OpenIdConfigResponse";
export declare class AuthorityMetadataEntity {
aliases: Array<string>;
preferred_cache: string;
preferred_network: string;
canonical_authority: string;
authorization_endpoint: string;
token_endpoint: string;
end_session_endpoint?: string;
issuer: string;
aliasesFromNetwork: boolean;
endpointsFromNetwork: boolean;
expiresAt: number;
jwks_uri: string;
constructor();
/**
* Update the entity with new aliases, preferred_cache and preferred_network values
* @param metadata
* @param fromNetwork
*/
updateCloudDiscoveryMetadata(metadata: CloudDiscoveryMetadata, fromNetwork: boolean): void;
/**
* Update the entity with new endpoints
* @param metadata
* @param fromNetwork
*/
updateEndpointMetadata(metadata: OpenIdConfigResponse, fromNetwork: boolean): void;
/**
* Save the authority that was used to create this cache entry
* @param authority
*/
updateCanonicalAuthority(authority: string): void;
/**
* Reset the exiresAt value
*/
resetExpiresAt(): void;
/**
* Returns whether or not the data needs to be refreshed
*/
isExpired(): boolean;
/**
* Validates an entity: checks for all expected params
* @param entity
*/
static isAuthorityMetadataEntity(key: string, entity: object): boolean;
}
//# sourceMappingURL=AuthorityMetadataEntity.d.ts.map
\ No newline at end of file
{"version":3,"file":"AuthorityMetadataEntity.d.ts","sourceRoot":"","sources":["../../../src/cache/entities/AuthorityMetadataEntity.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,sBAAsB,EAAE,MAAM,wCAAwC,CAAC;AAChF,OAAO,EAAE,oBAAoB,EAAE,MAAM,sCAAsC,CAAC;AAI5E,qBAAa,uBAAuB;IAChC,OAAO,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACvB,eAAe,EAAE,MAAM,CAAC;IACxB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,mBAAmB,EAAE,MAAM,CAAC;IAC5B,sBAAsB,EAAE,MAAM,CAAC;IAC/B,cAAc,EAAE,MAAM,CAAC;IACvB,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,MAAM,EAAE,MAAM,CAAC;IACf,kBAAkB,EAAE,OAAO,CAAC;IAC5B,oBAAoB,EAAE,OAAO,CAAC;IAC9B,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;;IAMjB;;;;OAIG;IACH,4BAA4B,CAAC,QAAQ,EAAE,sBAAsB,EAAE,WAAW,EAAE,OAAO,GAAG,IAAI;IAO1F;;;;OAIG;IACH,sBAAsB,CAAC,QAAQ,EAAE,oBAAoB,EAAE,WAAW,EAAE,OAAO,GAAG,IAAI;IASlF;;;OAGG;IACH,wBAAwB,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI;IAIjD;;OAEG;IACH,cAAc,IAAI,IAAI;IAItB;;OAEG;IACH,SAAS,IAAI,OAAO;IAIpB;;;OAGG;IACH,MAAM,CAAC,yBAAyB,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO;CAqBzE"}
\ No newline at end of file
/*! @azure/msal-common v9.0.1 2022-12-07 */
'use strict';
import { AUTHORITY_METADATA_CONSTANTS } from '../../utils/Constants.js';
import { TimeUtils } from '../../utils/TimeUtils.js';
/*
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License.
*/
var AuthorityMetadataEntity = /** @class */ (function () {
function AuthorityMetadataEntity() {
this.expiresAt = TimeUtils.nowSeconds() + AUTHORITY_METADATA_CONSTANTS.REFRESH_TIME_SECONDS;
}
/**
* Update the entity with new aliases, preferred_cache and preferred_network values
* @param metadata
* @param fromNetwork
*/
AuthorityMetadataEntity.prototype.updateCloudDiscoveryMetadata = function (metadata, fromNetwork) {
this.aliases = metadata.aliases;
this.preferred_cache = metadata.preferred_cache;
this.preferred_network = metadata.preferred_network;
this.aliasesFromNetwork = fromNetwork;
};
/**
* Update the entity with new endpoints
* @param metadata
* @param fromNetwork
*/
AuthorityMetadataEntity.prototype.updateEndpointMetadata = function (metadata, fromNetwork) {
this.authorization_endpoint = metadata.authorization_endpoint;
this.token_endpoint = metadata.token_endpoint;
this.end_session_endpoint = metadata.end_session_endpoint;
this.issuer = metadata.issuer;
this.endpointsFromNetwork = fromNetwork;
this.jwks_uri = metadata.jwks_uri;
};
/**
* Save the authority that was used to create this cache entry
* @param authority
*/
AuthorityMetadataEntity.prototype.updateCanonicalAuthority = function (authority) {
this.canonical_authority = authority;
};
/**
* Reset the exiresAt value
*/
AuthorityMetadataEntity.prototype.resetExpiresAt = function () {
this.expiresAt = TimeUtils.nowSeconds() + AUTHORITY_METADATA_CONSTANTS.REFRESH_TIME_SECONDS;
};
/**
* Returns whether or not the data needs to be refreshed
*/
AuthorityMetadataEntity.prototype.isExpired = function () {
return this.expiresAt <= TimeUtils.nowSeconds();
};
/**
* Validates an entity: checks for all expected params
* @param entity
*/
AuthorityMetadataEntity.isAuthorityMetadataEntity = function (key, entity) {
if (!entity) {
return false;
}
return (key.indexOf(AUTHORITY_METADATA_CONSTANTS.CACHE_KEY) === 0 &&
entity.hasOwnProperty("aliases") &&
entity.hasOwnProperty("preferred_cache") &&
entity.hasOwnProperty("preferred_network") &&
entity.hasOwnProperty("canonical_authority") &&
entity.hasOwnProperty("authorization_endpoint") &&
entity.hasOwnProperty("token_endpoint") &&
entity.hasOwnProperty("issuer") &&
entity.hasOwnProperty("aliasesFromNetwork") &&
entity.hasOwnProperty("endpointsFromNetwork") &&
entity.hasOwnProperty("expiresAt") &&
entity.hasOwnProperty("jwks_uri"));
};
return AuthorityMetadataEntity;
}());
export { AuthorityMetadataEntity };
//# sourceMappingURL=AuthorityMetadataEntity.js.map
{"version":3,"file":"AuthorityMetadataEntity.js","sources":["../../../src/cache/entities/AuthorityMetadataEntity.ts"],"sourcesContent":["/*\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { CloudDiscoveryMetadata } from \"../../authority/CloudDiscoveryMetadata\";\nimport { OpenIdConfigResponse } from \"../../authority/OpenIdConfigResponse\";\nimport { AUTHORITY_METADATA_CONSTANTS } from \"../../utils/Constants\";\nimport { TimeUtils } from \"../../utils/TimeUtils\";\n\nexport class AuthorityMetadataEntity {\n aliases: Array<string>;\n preferred_cache: string;\n preferred_network: string;\n canonical_authority: string;\n authorization_endpoint: string;\n token_endpoint: string;\n end_session_endpoint?: string;\n issuer: string;\n aliasesFromNetwork: boolean;\n endpointsFromNetwork: boolean;\n expiresAt: number;\n jwks_uri: string;\n\n constructor() {\n this.expiresAt = TimeUtils.nowSeconds() + AUTHORITY_METADATA_CONSTANTS.REFRESH_TIME_SECONDS;\n }\n\n /**\n * Update the entity with new aliases, preferred_cache and preferred_network values\n * @param metadata \n * @param fromNetwork \n */\n updateCloudDiscoveryMetadata(metadata: CloudDiscoveryMetadata, fromNetwork: boolean): void {\n this.aliases = metadata.aliases;\n this.preferred_cache = metadata.preferred_cache;\n this.preferred_network = metadata.preferred_network;\n this.aliasesFromNetwork = fromNetwork;\n }\n\n /**\n * Update the entity with new endpoints\n * @param metadata \n * @param fromNetwork \n */\n updateEndpointMetadata(metadata: OpenIdConfigResponse, fromNetwork: boolean): void {\n this.authorization_endpoint = metadata.authorization_endpoint;\n this.token_endpoint = metadata.token_endpoint;\n this.end_session_endpoint = metadata.end_session_endpoint;\n this.issuer = metadata.issuer;\n this.endpointsFromNetwork = fromNetwork;\n this.jwks_uri = metadata.jwks_uri;\n }\n\n /**\n * Save the authority that was used to create this cache entry\n * @param authority \n */\n updateCanonicalAuthority(authority: string): void {\n this.canonical_authority = authority;\n }\n\n /**\n * Reset the exiresAt value\n */\n resetExpiresAt(): void {\n this.expiresAt = TimeUtils.nowSeconds() + AUTHORITY_METADATA_CONSTANTS.REFRESH_TIME_SECONDS;\n }\n\n /**\n * Returns whether or not the data needs to be refreshed\n */\n isExpired(): boolean {\n return this.expiresAt <= TimeUtils.nowSeconds();\n }\n\n /**\n * Validates an entity: checks for all expected params\n * @param entity\n */\n static isAuthorityMetadataEntity(key: string, entity: object): boolean {\n\n if (!entity) {\n return false;\n }\n\n return (\n key.indexOf(AUTHORITY_METADATA_CONSTANTS.CACHE_KEY) === 0 &&\n entity.hasOwnProperty(\"aliases\") &&\n entity.hasOwnProperty(\"preferred_cache\") &&\n entity.hasOwnProperty(\"preferred_network\") &&\n entity.hasOwnProperty(\"canonical_authority\") &&\n entity.hasOwnProperty(\"authorization_endpoint\") &&\n entity.hasOwnProperty(\"token_endpoint\") &&\n entity.hasOwnProperty(\"issuer\") &&\n entity.hasO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"}
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment