modules inc

This commit is contained in:
nannal
2021-07-15 23:10:20 +03:00
parent 6bb353de89
commit 5921b02b7c
845 changed files with 105299 additions and 121 deletions

View File

@@ -0,0 +1,360 @@
import { AccountCache, AccountFilter, CredentialFilter, CredentialCache, AppMetadataFilter, AppMetadataCache } from "./utils/CacheTypes";
import { CacheRecord } from "./entities/CacheRecord";
import { CredentialEntity } from "./entities/CredentialEntity";
import { ScopeSet } from "../request/ScopeSet";
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";
/**
* 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(): void;
/**
* Returns all accounts in cache
*/
getAllAccounts(): AccountInfo[];
/**
* saves a cache record
* @param cacheRecord
*/
saveCacheRecord(cacheRecord: CacheRecord): 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
*/
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(): boolean;
/**
* returns a boolean if the given account is removed
* @param account
*/
removeAccount(accountKey: string): boolean;
/**
* returns a boolean if the given account is removed
* @param account
*/
removeAccountContext(account: AccountEntity): boolean;
/**
* returns a boolean if the given credential is removed
* @param credential
*/
removeCredential(credential: CredentialEntity): 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
*/
readCacheRecord(account: AccountInfo, clientId: string, scopes: ScopeSet, environment: string): CacheRecord;
/**
* Retrieve AccountEntity from cache
* @param account
*/
readAccountFromCache(account: AccountInfo): 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 inputRealm
*/
readAccessTokenFromCache(clientId: string, account: AccountInfo, scopes: ScopeSet): 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 matchOboAssertion;
/**
* 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;
/**
* Returns true if the target scopes are a subset of the current entity's scopes, false otherwise.
* @param entity
* @param target
*/
private matchTarget;
/**
* 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(): void;
}
//# sourceMappingURL=CacheManager.d.ts.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,53 @@
import { CredentialEntity } from "./CredentialEntity";
/**
* 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?: 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, tokenType?: string, oboAssertion?: string): AccessTokenEntity;
/**
* Validates an entity: checks for all expected params
* @param entity
*/
static isAccessTokenEntity(entity: object): boolean;
}
//# sourceMappingURL=AccessTokenEntity.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"AccessTokenEntity.d.ts","sourceRoot":"","sources":["../../../src/cache/entities/AccessTokenEntity.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAKtD;;;;;;;;;;;;;;;;;;;;;;;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,MAAM,CAAC;IAEnB;;;;;;;;;;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,SAAS,CAAC,EAAE,MAAM,EAClB,YAAY,CAAC,EAAE,MAAM,GACtB,iBAAiB;IA2BpB;;;OAGG;IACH,MAAM,CAAC,mBAAmB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO;CAiBtD"}

View File

@@ -0,0 +1,100 @@
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:
* oboAssertion: access token passed in as part of OBO request
* idTokenClaims: Object containing claims parsed from ID token
* }
*/
export declare class AccountEntity {
homeAccountId: string;
environment: string;
realm: string;
localAccountId: string;
username: string;
authorityType: string;
name?: string;
clientInfo?: string;
lastModificationTime?: string;
lastModificationApp?: string;
oboAssertion?: string;
cloudGraphHostName?: string;
msGraphHost?: string;
idTokenClaims?: TokenClaims;
/**
* 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, authority: Authority, idToken: AuthToken, oboAssertion?: string, cloudGraphHostName?: string, msGraphHost?: string): AccountEntity;
/**
* Builds non-AAD/ADFS account.
* @param authority
* @param idToken
*/
static createGenericAccount(authority: Authority, homeAccountId: string, idToken: AuthToken, oboAssertion?: string, cloudGraphHostName?: string, msGraphHost?: 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 accounts are equal
* Used to avoid unnecessary state updates
* @param arrayA
* @param arrayB
*/
static accountInfoIsEqual(accountA: AccountInfo | null, accountB: AccountInfo | null): boolean;
}
//# sourceMappingURL=AccountEntity.d.ts.map

View File

@@ -0,0 +1 @@
{"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,CAAC,EAAE,MAAM,CAAC;IAC9B,mBAAmB,CAAC,EAAE,MAAM,CAAC;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G,OAAO;CAUjG"}

View File

@@ -0,0 +1,40 @@
/**
* 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
* }
*/
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

View File

@@ -0,0 +1 @@
{"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"}

View File

@@ -0,0 +1,47 @@
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;
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

View File

@@ -0,0 +1 @@
{"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,EAAE,MAAM,CAAC;IAC7B,MAAM,EAAE,MAAM,CAAC;IACf,kBAAkB,EAAE,OAAO,CAAC;IAC5B,oBAAoB,EAAE,OAAO,CAAC;IAC9B,SAAS,EAAE,MAAM,CAAC;;IAMlB;;;;OAIG;IACH,4BAA4B,CAAC,QAAQ,EAAE,sBAAsB,EAAE,WAAW,EAAE,OAAO;IAOnF;;;;OAIG;IACH,sBAAsB,CAAC,QAAQ,EAAE,oBAAoB,EAAE,WAAW,EAAE,OAAO;IAQ3E;;;OAGG;IACH,wBAAwB,CAAC,SAAS,EAAE,MAAM;IAI1C;;OAEG;IACH,cAAc;IAId;;OAEG;IACH,SAAS,IAAI,OAAO;IAIpB;;;OAGG;IACH,MAAM,CAAC,yBAAyB,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO;CAqBzE"}

View File

@@ -0,0 +1,14 @@
import { IdTokenEntity } from "./IdTokenEntity";
import { AccessTokenEntity } from "./AccessTokenEntity";
import { RefreshTokenEntity } from "./RefreshTokenEntity";
import { AccountEntity } from "./AccountEntity";
import { AppMetadataEntity } from "./AppMetadataEntity";
export declare class CacheRecord {
account: AccountEntity | null;
idToken: IdTokenEntity | null;
accessToken: AccessTokenEntity | null;
refreshToken: RefreshTokenEntity | null;
appMetadata: AppMetadataEntity | null;
constructor(accountEntity?: AccountEntity | null, idTokenEntity?: IdTokenEntity | null, accessTokenEntity?: AccessTokenEntity | null, refreshTokenEntity?: RefreshTokenEntity | null, appMetadataEntity?: AppMetadataEntity | null);
}
//# sourceMappingURL=CacheRecord.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"CacheRecord.d.ts","sourceRoot":"","sources":["../../../src/cache/entities/CacheRecord.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAExD,qBAAa,WAAW;IACpB,OAAO,EAAE,aAAa,GAAG,IAAI,CAAC;IAC9B,OAAO,EAAE,aAAa,GAAG,IAAI,CAAC;IAC9B,WAAW,EAAE,iBAAiB,GAAG,IAAI,CAAC;IACtC,YAAY,EAAE,kBAAkB,GAAG,IAAI,CAAC;IACxC,WAAW,EAAE,iBAAiB,GAAG,IAAI,CAAC;gBAE1B,aAAa,CAAC,EAAE,aAAa,GAAG,IAAI,EAAE,aAAa,CAAC,EAAE,aAAa,GAAG,IAAI,EAAE,iBAAiB,CAAC,EAAE,iBAAiB,GAAG,IAAI,EAAE,kBAAkB,CAAC,EAAE,kBAAkB,GAAG,IAAI,EAAE,iBAAiB,CAAC,EAAE,iBAAiB,GAAG,IAAI;CAOrO"}

View File

@@ -0,0 +1,80 @@
import { CredentialType } from "../../utils/Constants";
/**
* Base type for credentials to be stored in the cache: eg: ACCESS_TOKEN, ID_TOKEN etc
*
* Key:Value Schema:
*
* Key: <home_account_id*>-<environment>-<credential_type>-<client_id>-<realm*>-<target*>
*
* 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.
* oboAssertion: access token passed in as part of OBO request
* }
*/
export declare class CredentialEntity {
homeAccountId: string;
environment: string;
credentialType: CredentialType;
clientId: string;
secret: string;
familyId?: string;
realm?: string;
target?: string;
oboAssertion?: string;
/**
* Generate Account Id key component as per the schema: <home_account_id>-<environment>
*/
generateAccountId(): string;
/**
* Generate Credential Id key component as per the schema: <credential_type>-<client_id>-<realm>
*/
generateCredentialId(): string;
/**
* Generate target key component as per schema: <target>
*/
generateTarget(): string;
/**
* generates credential key
*/
generateCredentialKey(): string;
/**
* returns the type of the cache (in this case credential)
*/
generateType(): number;
/**
* helper function to return `CredentialType`
* @param key
*/
static getCredentialType(key: string): string;
/**
* generates credential key
*/
static generateCredentialCacheKey(homeAccountId: string, environment: string, credentialType: CredentialType, clientId: string, realm?: string, target?: string, familyId?: string): string;
/**
* generates Account Id for keys
* @param homeAccountId
* @param environment
*/
private static generateAccountIdForCacheKey;
/**
* Generates Credential Id for keys
* @param credentialType
* @param realm
* @param clientId
* @param familyId
*/
private static generateCredentialIdForCacheKey;
/**
* Generate target key component as per schema: <target>
*/
private static generateTargetForCacheKey;
}
//# sourceMappingURL=CredentialEntity.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"CredentialEntity.d.ts","sourceRoot":"","sources":["../../../src/cache/entities/CredentialEntity.ts"],"names":[],"mappings":"AAKA,OAAO,EAAc,cAAc,EAAwB,MAAM,uBAAuB,CAAC;AAGzF;;;;;;;;;;;;;;;;;;;GAmBG;AACH,qBAAa,gBAAgB;IACzB,aAAa,EAAE,MAAM,CAAC;IACtB,WAAW,EAAE,MAAM,CAAC;IACpB,cAAc,EAAE,cAAc,CAAC;IAC/B,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB;;OAEG;IACH,iBAAiB,IAAI,MAAM;IAI3B;;OAEG;IACH,oBAAoB,IAAI,MAAM;IAS9B;;OAEG;IACH,cAAc,IAAI,MAAM;IAIxB;;OAEG;IACH,qBAAqB,IAAI,MAAM;IAY/B;;OAEG;IACH,YAAY,IAAI,MAAM;IActB;;;OAGG;IACH,MAAM,CAAC,iBAAiB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM;IAY7C;;OAEG;IACH,MAAM,CAAC,0BAA0B,CAC7B,aAAa,EAAE,MAAM,EACrB,WAAW,EAAE,MAAM,EACnB,cAAc,EAAE,cAAc,EAC9B,QAAQ,EAAE,MAAM,EAChB,KAAK,CAAC,EAAE,MAAM,EACd,MAAM,CAAC,EAAE,MAAM,EACf,QAAQ,CAAC,EAAE,MAAM,GAClB,MAAM;IAUT;;;;OAIG;IACH,OAAO,CAAC,MAAM,CAAC,4BAA4B;IAQ3C;;;;;;OAMG;IACH,OAAO,CAAC,MAAM,CAAC,+BAA+B;IAmB9C;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,yBAAyB;CAG3C"}

View File

@@ -0,0 +1,35 @@
import { CredentialEntity } from "./CredentialEntity";
/**
* ID_TOKEN Cache
*
* Key:Value Schema:
*
* Key Example: uid.utid-login.microsoftonline.com-idtoken-clientId-contoso.com-
*
* 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
* realm: Full tenant or organizational identifier that the account belongs to
* }
*/
export declare class IdTokenEntity extends CredentialEntity {
realm: string;
/**
* Create IdTokenEntity
* @param homeAccountId
* @param authenticationResult
* @param clientId
* @param authority
*/
static createIdTokenEntity(homeAccountId: string, environment: string, idToken: string, clientId: string, tenantId: string, oboAssertion?: string): IdTokenEntity;
/**
* Validates an entity: checks for all expected params
* @param entity
*/
static isIdTokenEntity(entity: object): boolean;
}
//# sourceMappingURL=IdTokenEntity.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"IdTokenEntity.d.ts","sourceRoot":"","sources":["../../../src/cache/entities/IdTokenEntity.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAGtD;;;;;;;;;;;;;;;;GAgBG;AACH,qBAAa,aAAc,SAAQ,gBAAgB;IAC/C,KAAK,EAAE,MAAM,CAAC;IAEd;;;;;;OAMG;IACH,MAAM,CAAC,mBAAmB,CACtB,aAAa,EAAE,MAAM,EACrB,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM,EAChB,YAAY,CAAC,EAAE,MAAM,GACtB,aAAa;IAchB;;;OAGG;IACH,MAAM,CAAC,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO;CAgBlD"}

View File

@@ -0,0 +1,37 @@
import { CredentialEntity } from "./CredentialEntity";
/**
* REFRESH_TOKEN Cache
*
* Key:Value Schema:
*
* Key Example: uid.utid-login.microsoftonline.com-refreshtoken-clientId--
*
* Value:
* {
* 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, '1' represents Microsoft Family
* 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.
* }
*/
export declare class RefreshTokenEntity extends CredentialEntity {
familyId?: string;
/**
* Create RefreshTokenEntity
* @param homeAccountId
* @param authenticationResult
* @param clientId
* @param authority
*/
static createRefreshTokenEntity(homeAccountId: string, environment: string, refreshToken: string, clientId: string, familyId?: string, oboAssertion?: string): RefreshTokenEntity;
/**
* Validates an entity: checks for all expected params
* @param entity
*/
static isRefreshTokenEntity(entity: object): boolean;
}
//# sourceMappingURL=RefreshTokenEntity.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"RefreshTokenEntity.d.ts","sourceRoot":"","sources":["../../../src/cache/entities/RefreshTokenEntity.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAGtD;;;;;;;;;;;;;;;;;;GAkBG;AACH,qBAAa,kBAAmB,SAAQ,gBAAgB;IACpD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB;;;;;;OAMG;IACH,MAAM,CAAC,wBAAwB,CAC3B,aAAa,EAAE,MAAM,EACrB,WAAW,EAAE,MAAM,EACnB,YAAY,EAAE,MAAM,EACpB,QAAQ,EAAE,MAAM,EAChB,QAAQ,CAAC,EAAE,MAAM,EACjB,YAAY,CAAC,EAAE,MAAM,GACtB,kBAAkB;IAgBrB;;;OAGG;IACH,MAAM,CAAC,oBAAoB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO;CAevD"}

View File

@@ -0,0 +1,13 @@
export declare class ServerTelemetryEntity {
failedRequests: Array<string | number>;
errors: string[];
cacheHits: number;
constructor();
/**
* validates if a given cache entry is "Telemetry", parses <key,value>
* @param key
* @param entity
*/
static isServerTelemetryEntity(key: string, entity?: object): boolean;
}
//# sourceMappingURL=ServerTelemetryEntity.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"ServerTelemetryEntity.d.ts","sourceRoot":"","sources":["../../../src/cache/entities/ServerTelemetryEntity.ts"],"names":[],"mappings":"AAOA,qBAAa,qBAAqB;IAC9B,cAAc,EAAE,KAAK,CAAC,MAAM,GAAC,MAAM,CAAC,CAAC;IACrC,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;;IAQlB;;;;OAIG;IACH,MAAM,CAAC,uBAAuB,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO;CAcxE"}

View File

@@ -0,0 +1,14 @@
export declare class ThrottlingEntity {
throttleTime: number;
error?: string;
errorCodes?: Array<string>;
errorMessage?: string;
subError?: string;
/**
* validates if a given cache entry is "Throttling", parses <key,value>
* @param key
* @param entity
*/
static isThrottlingEntity(key: string, entity?: object): boolean;
}
//# sourceMappingURL=ThrottlingEntity.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"ThrottlingEntity.d.ts","sourceRoot":"","sources":["../../../src/cache/entities/ThrottlingEntity.ts"],"names":[],"mappings":"AAOA,qBAAa,gBAAgB;IAEzB,YAAY,EAAE,MAAM,CAAC;IAErB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAC3B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB;;;;OAIG;IACH,MAAM,CAAC,kBAAkB,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO;CAcnE"}

View File

@@ -0,0 +1,157 @@
import { CredentialEntity } from "../entities/CredentialEntity";
import { AccountCache, CredentialCache, AccountFilter, CredentialFilter } from "../utils/CacheTypes";
import { CacheRecord } from "../entities/CacheRecord";
import { AccountEntity } from "../entities/AccountEntity";
import { AccountInfo } from "../../account/AccountInfo";
import { AppMetadataEntity } from "../entities/AppMetadataEntity";
import { ServerTelemetryEntity } from "../entities/ServerTelemetryEntity";
import { ThrottlingEntity } from "../entities/ThrottlingEntity";
import { IdTokenEntity } from "../entities/IdTokenEntity";
import { AccessTokenEntity } from "../entities/AccessTokenEntity";
import { RefreshTokenEntity } from "../entities/RefreshTokenEntity";
import { AuthorityMetadataEntity } from "../entities/AuthorityMetadataEntity";
export interface ICacheManager {
/**
* fetch the account entity from the platform cache
* @param accountKey
*/
getAccount(accountKey: string): AccountEntity | null;
/**
* set account entity in the platform cache
* @param account
*/
setAccount(account: AccountEntity): void;
/**
* fetch the idToken entity from the platform cache
* @param idTokenKey
*/
getIdTokenCredential(idTokenKey: string): IdTokenEntity | null;
/**
* set idToken entity to the platform cache
* @param idToken
*/
setIdTokenCredential(idToken: IdTokenEntity): void;
/**
* fetch the idToken entity from the platform cache
* @param accessTokenKey
*/
getAccessTokenCredential(accessTokenKey: string): AccessTokenEntity | null;
/**
* set idToken entity to the platform cache
* @param accessToken
*/
setAccessTokenCredential(accessToken: AccessTokenEntity): void;
/**
* fetch the idToken entity from the platform cache
* @param refreshTokenKey
*/
getRefreshTokenCredential(refreshTokenKey: string): RefreshTokenEntity | null;
/**
* set idToken entity to the platform cache
* @param refreshToken
*/
setRefreshTokenCredential(refreshToken: RefreshTokenEntity): void;
/**
* fetch appMetadata entity from the platform cache
* @param appMetadataKey
*/
getAppMetadata(appMetadataKey: string): AppMetadataEntity | null;
/**
* set appMetadata entity to the platform cache
* @param appMetadata
*/
setAppMetadata(appMetadata: AppMetadataEntity): void;
/**
* fetch server telemetry entity from the platform cache
* @param serverTelemetryKey
*/
getServerTelemetry(serverTelemetryKey: string): ServerTelemetryEntity | null;
/**
* set server telemetry entity to the platform cache
* @param serverTelemetryKey
* @param serverTelemetry
*/
setServerTelemetry(serverTelemetryKey: string, serverTelemetry: ServerTelemetryEntity): void;
/**
* fetch cloud discovery metadata entity from the platform cache
* @param key
*/
getAuthorityMetadata(key: string): AuthorityMetadataEntity | null;
/**
* Get cache keys for authority metadata
*/
getAuthorityMetadataKeys(): Array<string>;
/**
* set cloud discovery metadata entity to the platform cache
* @param key
* @param value
*/
setAuthorityMetadata(key: string, value: AuthorityMetadataEntity): void;
/**
* Provide an alias to find a matching AuthorityMetadataEntity in cache
* @param host
*/
getAuthorityMetadataByAlias(host: string): AuthorityMetadataEntity | null;
/**
* given an authority generates the cache key for authorityMetadata
* @param authority
*/
generateAuthorityMetadataCacheKey(authority: string): string;
/**
* fetch throttling entity from the platform cache
* @param throttlingCacheKey
*/
getThrottlingCache(throttlingCacheKey: string): ThrottlingEntity | null;
/**
* set throttling entity to the platform cache
* @param throttlingCacheKey
* @param throttlingCache
*/
setThrottlingCache(throttlingCacheKey: string, throttlingCache: ThrottlingEntity): void;
/**
* Returns all accounts in cache
*/
getAllAccounts(): AccountInfo[];
/**
* saves a cache record
* @param cacheRecord
*/
saveCacheRecord(cacheRecord: CacheRecord): void;
/**
* retrieve accounts matching all provided filters; if no filter is set, get all accounts
* @param homeAccountId
* @param environment
* @param realm
*/
getAccountsFilteredBy(filter: AccountFilter): AccountCache;
/**
* retrieve credentials 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;
/**
* Removes all accounts and related tokens from cache.
*/
removeAllAccounts(): boolean;
/**
* returns a boolean if the given account is removed
* @param account
*/
removeAccount(accountKey: string): boolean;
/**
* returns a boolean if the given account is removed
* @param account
*/
removeAccountContext(account: AccountEntity): boolean;
/**
* returns a boolean if the given credential is removed
* @param credential
*/
removeCredential(credential: CredentialEntity): boolean;
}
//# sourceMappingURL=ICacheManager.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"ICacheManager.d.ts","sourceRoot":"","sources":["../../../src/cache/interface/ICacheManager.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAChE,OAAO,EACH,YAAY,EACZ,eAAe,EACf,aAAa,EACb,gBAAgB,EACnB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC1D,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxD,OAAO,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAClE,OAAO,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;AAC1E,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAChE,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC1D,OAAO,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAClE,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AACpE,OAAO,EAAE,uBAAuB,EAAE,MAAM,qCAAqC,CAAC;AAE9E,MAAM,WAAW,aAAa;IAE1B;;;O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AI,EAAE,MAAM,GAAG,uBAAuB,GAAG,IAAI,CAAC;IAE1E;;;OAGG;IACH,iCAAiC,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAAC;IAE7D;;;OAGG;IACH,kBAAkB,CAAC,kBAAkB,EAAE,MAAM,GAAG,gBAAgB,GAAG,IAAI,CAAC;IAExE;;;;OAIG;IACH,kBAAkB,CAAC,kBAAkB,EAAE,MAAM,EAAE,eAAe,EAAE,gBAAgB,GAAG,IAAI,CAAC;IAExF;;OAEG;IACH,cAAc,IAAI,WAAW,EAAE,CAAC;IAEhC;;;OAGG;IACH,eAAe,CAAC,WAAW,EAAE,WAAW,GAAG,IAAI,CAAC;IAEhD;;;;;OAKG;IACH,qBAAqB,CAAC,MAAM,EAAE,aAAa,GAAG,YAAY,CAAC;IAE3D;;;;;;;;OAQG;IACH,wBAAwB,CAAC,MAAM,EAAE,gBAAgB,GAAG,eAAe,CAAC;IAEpE;;OAEG;IACH,iBAAiB,IAAI,OAAO,CAAC;IAE7B;;;OAGG;IACH,aAAa,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC;IAE3C;;;OAGG;IACH,oBAAoB,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC;IAEtD;;;OAGG;IACH,gBAAgB,CAAC,UAAU,EAAE,gBAAgB,GAAG,OAAO,CAAC;CAC3D"}

View File

@@ -0,0 +1,6 @@
import { TokenCacheContext } from "../persistence/TokenCacheContext";
export interface ICachePlugin {
beforeCacheAccess: (tokenCacheContext: TokenCacheContext) => Promise<void>;
afterCacheAccess: (tokenCacheContext: TokenCacheContext) => Promise<void>;
}
//# sourceMappingURL=ICachePlugin.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"ICachePlugin.d.ts","sourceRoot":"","sources":["../../../src/cache/interface/ICachePlugin.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AAErE,MAAM,WAAW,YAAY;IACzB,iBAAiB,EAAE,CAAC,iBAAiB,EAAE,iBAAiB,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC3E,gBAAgB,EAAE,CAAC,iBAAiB,EAAE,iBAAiB,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CAC7E"}

View File

@@ -0,0 +1,5 @@
export interface ISerializableTokenCache {
deserialize: (cache: string) => void;
serialize: () => string;
}
//# sourceMappingURL=ISerializableTokenCache.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"ISerializableTokenCache.d.ts","sourceRoot":"","sources":["../../../src/cache/interface/ISerializableTokenCache.ts"],"names":[],"mappings":"AAKA,MAAM,WAAW,uBAAuB;IACpC,WAAW,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACrC,SAAS,EAAE,MAAM,MAAM,CAAC;CAC3B"}

View File

@@ -0,0 +1,24 @@
import { ISerializableTokenCache } from "../interface/ISerializableTokenCache";
/**
* This class instance helps track the memory changes facilitating
* decisions to read from and write to the persistent cache
*/ export declare class TokenCacheContext {
/**
* boolean indicating cache change
*/
hasChanged: boolean;
/**
* serializable token cache interface
*/
cache: ISerializableTokenCache;
constructor(tokenCache: ISerializableTokenCache, hasChanged: boolean);
/**
* boolean which indicates the changes in cache
*/
get cacheHasChanged(): boolean;
/**
* function to retrieve the token cache
*/
get tokenCache(): ISerializableTokenCache;
}
//# sourceMappingURL=TokenCacheContext.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"TokenCacheContext.d.ts","sourceRoot":"","sources":["../../../src/cache/persistence/TokenCacheContext.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,uBAAuB,EAAE,MAAM,sCAAsC,CAAC;AAE/E;;;GAGG,CAAA,qBAAa,iBAAiB;IAC7B;;OAEG;IACH,UAAU,EAAE,OAAO,CAAC;IACpB;;OAEG;IACH,KAAK,EAAE,uBAAuB,CAAC;gBAEnB,UAAU,EAAE,uBAAuB,EAAE,UAAU,EAAE,OAAO;IAKpE;;OAEG;IACH,IAAI,eAAe,IAAI,OAAO,CAE7B;IAED;;OAEG;IACH,IAAI,UAAU,IAAI,uBAAuB,CAExC;CACJ"}

View File

@@ -0,0 +1,55 @@
import { AccountEntity } from "../entities/AccountEntity";
import { IdTokenEntity } from "../entities/IdTokenEntity";
import { AccessTokenEntity } from "../entities/AccessTokenEntity";
import { RefreshTokenEntity } from "../entities/RefreshTokenEntity";
import { AppMetadataEntity } from "../entities/AppMetadataEntity";
import { ServerTelemetryEntity } from "../entities/ServerTelemetryEntity";
import { ThrottlingEntity } from "../entities/ThrottlingEntity";
import { AuthorityMetadataEntity } from "../entities/AuthorityMetadataEntity";
export declare type AccountCache = Record<string, AccountEntity>;
export declare type IdTokenCache = Record<string, IdTokenEntity>;
export declare type AccessTokenCache = Record<string, AccessTokenEntity>;
export declare type RefreshTokenCache = Record<string, RefreshTokenEntity>;
export declare type AppMetadataCache = Record<string, AppMetadataEntity>;
export declare type CredentialCache = {
idTokens: IdTokenCache;
accessTokens: AccessTokenCache;
refreshTokens: RefreshTokenCache;
};
/**
* Object type of all accepted cache types
*/
export declare type ValidCacheType = AccountEntity | IdTokenEntity | AccessTokenEntity | RefreshTokenEntity | AppMetadataEntity | AuthorityMetadataEntity | ServerTelemetryEntity | ThrottlingEntity | string;
/**
* Object type of all credential types
*/
export declare type ValidCredentialType = IdTokenEntity | AccessTokenEntity | RefreshTokenEntity;
/**
* Account: <home_account_id>-<environment>-<realm*>
*/
export declare type AccountFilter = {
homeAccountId?: string;
environment?: string;
realm?: string;
};
/**
* Credential: <home_account_id*>-<environment>-<credential_type>-<client_id>-<realm*>-<target*>
*/
export declare type CredentialFilter = {
homeAccountId?: string;
environment?: string;
credentialType?: string;
clientId?: string;
familyId?: string;
realm?: string;
target?: string;
oboAssertion?: string;
};
/**
* AppMetadata: appmetadata-<environment>-<client_id>
*/
export declare type AppMetadataFilter = {
environment?: string;
clientId?: string;
};
//# sourceMappingURL=CacheTypes.d.ts.map

View File

@@ -0,0 +1 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