{"version":3,"file":"AccountEntity.js","sources":["../../../src/cache/entities/AccountEntity.ts"],"sourcesContent":["/*\r\n * Copyright (c) Microsoft Corporation. All rights reserved.\r\n * Licensed under the MIT License.\r\n */\r\n\r\nimport {\r\n Separators,\r\n CacheAccountType,\r\n CacheType,\r\n Constants,\r\n} from \"../../utils/Constants\";\r\nimport { Authority } from \"../../authority/Authority\";\r\nimport { AuthToken } from \"../../account/AuthToken\";\r\nimport { ICrypto } from \"../../crypto/ICrypto\";\r\nimport { buildClientInfo } from \"../../account/ClientInfo\";\r\nimport { StringUtils } from \"../../utils/StringUtils\";\r\nimport { AccountInfo } from \"../../account/AccountInfo\";\r\nimport { ClientAuthError } from \"../../error/ClientAuthError\";\r\nimport { AuthorityType } from \"../../authority/AuthorityType\";\r\nimport { Logger } from \"../../logger/Logger\";\r\nimport { TokenClaims } from \"../../account/TokenClaims\";\r\n\r\n/**\r\n * Type that defines required and optional parameters for an Account field (based on universal cache schema implemented by all MSALs).\r\n *\r\n * Key : Value Schema\r\n *\r\n * Key: --\r\n *\r\n * Value Schema:\r\n * {\r\n * homeAccountId: home account identifier for the auth scheme,\r\n * environment: entity that issued the token, represented as a full host\r\n * realm: Full tenant or organizational identifier that the account belongs to\r\n * localAccountId: Original tenant-specific accountID, usually used for legacy cases\r\n * username: primary username that represents the user, usually corresponds to preferred_username in the v2 endpt\r\n * authorityType: Accounts authority type as a string\r\n * name: Full name for the account, including given name and family name,\r\n * clientInfo: Full base64 encoded client info received from ESTS\r\n * lastModificationTime: last time this entity was modified in the cache\r\n * lastModificationApp:\r\n * idTokenClaims: Object containing claims parsed from ID token\r\n * nativeAccountId: Account identifier on the native device\r\n * }\r\n */\r\nexport class AccountEntity {\r\n homeAccountId: string;\r\n environment: string;\r\n realm: string;\r\n localAccountId: string;\r\n username: string;\r\n authorityType: string;\r\n name?: string;\r\n clientInfo?: string;\r\n lastModificationTime?: string;\r\n lastModificationApp?: string;\r\n cloudGraphHostName?: string;\r\n msGraphHost?: string;\r\n idTokenClaims?: TokenClaims;\r\n nativeAccountId?: string;\r\n\r\n /**\r\n * Generate Account Id key component as per the schema: -\r\n */\r\n generateAccountId(): string {\r\n const accountId: Array = [this.homeAccountId, this.environment];\r\n return accountId.join(Separators.CACHE_KEY_SEPARATOR).toLowerCase();\r\n }\r\n\r\n /**\r\n * Generate Account Cache Key as per the schema: --\r\n */\r\n generateAccountKey(): string {\r\n return AccountEntity.generateAccountCacheKey({\r\n homeAccountId: this.homeAccountId,\r\n environment: this.environment,\r\n tenantId: this.realm,\r\n username: this.username,\r\n localAccountId: this.localAccountId\r\n });\r\n }\r\n\r\n /**\r\n * returns the type of the cache (in this case account)\r\n */\r\n generateType(): number {\r\n switch (this.authorityType) {\r\n case CacheAccountType.ADFS_ACCOUNT_TYPE:\r\n return CacheType.ADFS;\r\n case CacheAccountType.MSAV1_ACCOUNT_TYPE:\r\n return CacheType.MSA;\r\n case CacheAccountType.MSSTS_ACCOUNT_TYPE:\r\n return CacheType.MSSTS;\r\n case CacheAccountType.GENERIC_ACCOUNT_TYPE:\r\n return CacheType.GENERIC;\r\n default: {\r\n throw ClientAuthError.createUnexpectedAccountTypeError();\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Returns the AccountInfo interface for this account.\r\n */\r\n getAccountInfo(): AccountInfo {\r\n return {\r\n homeAccountId: this.homeAccountId,\r\n environment: this.environment,\r\n tenantId: this.realm,\r\n username: this.username,\r\n localAccountId: this.localAccountId,\r\n name: this.name,\r\n idTokenClaims: this.idTokenClaims,\r\n nativeAccountId: this.nativeAccountId\r\n };\r\n }\r\n\r\n /**\r\n * Generates account key from interface\r\n * @param accountInterface\r\n */\r\n static generateAccountCacheKey(accountInterface: AccountInfo): string {\r\n const accountKey = [\r\n accountInterface.homeAccountId,\r\n accountInterface.environment || Constants.EMPTY_STRING,\r\n accountInterface.tenantId || Constants.EMPTY_STRING,\r\n ];\r\n\r\n return accountKey.join(Separators.CACHE_KEY_SEPARATOR).toLowerCase();\r\n }\r\n\r\n /**\r\n * Build Account cache from IdToken, clientInfo and authority/policy. Associated with AAD.\r\n * @param clientInfo\r\n * @param authority\r\n * @param idToken\r\n * @param policy\r\n */\r\n static createAccount(\r\n clientInfo: string,\r\n homeAccountId: string,\r\n idToken: AuthToken,\r\n authority?: Authority,\r\n cloudGraphHostName?: string,\r\n msGraphHost?: string,\r\n environment?: string,\r\n nativeAccountId?: string\r\n ): AccountEntity {\r\n const account: AccountEntity = new AccountEntity();\r\n\r\n account.authorityType = CacheAccountType.MSSTS_ACCOUNT_TYPE;\r\n account.clientInfo = clientInfo;\r\n account.homeAccountId = homeAccountId;\r\n account.nativeAccountId = nativeAccountId;\r\n\r\n const env = environment || (authority && authority.getPreferredCache());\r\n\r\n if (!env) {\r\n throw ClientAuthError.createInvalidCacheEnvironmentError();\r\n }\r\n\r\n account.environment = env;\r\n // non AAD scenarios can have empty realm\r\n account.realm = idToken?.claims?.tid || Constants.EMPTY_STRING;\r\n\r\n if (idToken) {\r\n account.idTokenClaims = idToken.claims;\r\n\r\n // How do you account for MSA CID here?\r\n account.localAccountId = idToken?.claims?.oid || idToken?.claims?.sub || Constants.EMPTY_STRING;\r\n\r\n /*\r\n * In B2C scenarios the emails claim is used instead of preferred_username and it is an array.\r\n * In most cases it will contain a single email. This field should not be relied upon if a custom \r\n * policy is configured to return more than 1 email.\r\n */\r\n const preferredUsername = idToken?.claims?.preferred_username;\r\n const email = (idToken?.claims?.emails) ? idToken.claims.emails[0] : null;\r\n \r\n account.username = preferredUsername || email || Constants.EMPTY_STRING;\r\n account.name = idToken?.claims?.name;\r\n }\r\n\r\n account.cloudGraphHostName = cloudGraphHostName;\r\n account.msGraphHost = msGraphHost;\r\n\r\n return account;\r\n }\r\n\r\n /**\r\n * Builds non-AAD/ADFS account.\r\n * @param authority\r\n * @param idToken\r\n */\r\n static createGenericAccount(\r\n homeAccountId: string,\r\n idToken: AuthToken,\r\n authority?: Authority,\r\n cloudGraphHostName?: string,\r\n msGraphHost?: string,\r\n environment?: string\r\n ): AccountEntity {\r\n const account: AccountEntity = new AccountEntity();\r\n\r\n account.authorityType = (\r\n authority &&\r\n authority.authorityType === AuthorityType.Adfs\r\n ) ? CacheAccountType.ADFS_ACCOUNT_TYPE : CacheAccountType.GENERIC_ACCOUNT_TYPE;\r\n \r\n account.homeAccountId = homeAccountId;\r\n // non AAD scenarios can have empty realm\r\n account.realm = Constants.EMPTY_STRING;\r\n\r\n const env = environment || authority && authority.getPreferredCache();\r\n\r\n if (!env) {\r\n throw ClientAuthError.createInvalidCacheEnvironmentError();\r\n }\r\n\r\n if (idToken) {\r\n // How do you account for MSA CID here?\r\n account.localAccountId = idToken?.claims?.oid || idToken?.claims?.sub || Constants.EMPTY_STRING;\r\n // upn claim for most ADFS scenarios\r\n account.username = idToken?.claims?.upn || Constants.EMPTY_STRING;\r\n account.name = idToken?.claims?.name || Constants.EMPTY_STRING;\r\n account.idTokenClaims = idToken?.claims;\r\n }\r\n\r\n account.environment = env;\r\n\r\n account.cloudGraphHostName = cloudGraphHostName;\r\n account.msGraphHost = msGraphHost;\r\n\r\n /*\r\n * add uniqueName to claims\r\n * account.name = idToken.claims.uniqueName;\r\n */\r\n\r\n return account;\r\n }\r\n\r\n /**\r\n * Generate HomeAccountId from server response\r\n * @param serverClientInfo\r\n * @param authType\r\n */\r\n static generateHomeAccountId(\r\n serverClientInfo: string,\r\n authType: AuthorityType,\r\n logger: Logger,\r\n cryptoObj: ICrypto,\r\n idToken?: AuthToken\r\n ): string {\r\n\r\n const accountId = idToken?.claims?.sub ? idToken.claims.sub : Constants.EMPTY_STRING;\r\n\r\n // since ADFS does not have tid and does not set client_info\r\n if (authType === AuthorityType.Adfs || authType === AuthorityType.Dsts) {\r\n return accountId;\r\n }\r\n\r\n // for cases where there is clientInfo\r\n if (serverClientInfo) {\r\n try {\r\n const clientInfo = buildClientInfo(serverClientInfo, cryptoObj);\r\n if (!StringUtils.isEmpty(clientInfo.uid) && !StringUtils.isEmpty(clientInfo.utid)) {\r\n return `${clientInfo.uid}${Separators.CLIENT_INFO_SEPARATOR}${clientInfo.utid}`;\r\n }\r\n } catch (e) {}\r\n }\r\n\r\n // default to \"sub\" claim\r\n logger.verbose(\"No client info in response\");\r\n return accountId;\r\n }\r\n\r\n /**\r\n * Validates an entity: checks for all expected params\r\n * @param entity\r\n */\r\n static isAccountEntity(entity: object): boolean {\r\n\r\n if (!entity) {\r\n return false;\r\n }\r\n\r\n return (\r\n entity.hasOwnProperty(\"homeAccountId\") &&\r\n entity.hasOwnProperty(\"environment\") &&\r\n entity.hasOwnProperty(\"realm\") &&\r\n entity.hasOwnProperty(\"localAccountId\") &&\r\n entity.hasOwnProperty(\"username\") &&\r\n entity.hasOwnProperty(\"authorityType\")\r\n );\r\n }\r\n\r\n /**\r\n * Helper function to determine whether 2 accountInfo objects represent the same account\r\n * @param accountA\r\n * @param accountB\r\n * @param compareClaims - If set to true idTokenClaims will also be compared to determine account equality\r\n */\r\n static accountInfoIsEqual(accountA: AccountInfo | null, accountB: AccountInfo | null, compareClaims?: boolean): boolean {\r\n if (!accountA || !accountB) {\r\n return false;\r\n }\r\n\r\n let claimsMatch = true; // default to true so as to not fail comparison below if compareClaims: false\r\n if (compareClaims) {\r\n const accountAClaims = (accountA.idTokenClaims || {}) as TokenClaims;\r\n const accountBClaims = (accountB.idTokenClaims || {}) as TokenClaims;\r\n\r\n // issued at timestamp and nonce are expected to change each time a new id token is acquired\r\n claimsMatch = (accountAClaims.iat === accountBClaims.iat) &&\r\n (accountAClaims.nonce === accountBClaims.nonce);\r\n }\r\n\r\n return (accountA.homeAccountId === accountB.homeAccountId) &&\r\n (accountA.localAccountId === accountB.localAccountId) &&\r\n (accountA.username === accountB.username) &&\r\n (accountA.tenantId === accountB.tenantId) &&\r\n (accountA.environment === accountB.environment) &&\r\n (accountA.nativeAccountId === accountB.nativeAccountId) &&\r\n claimsMatch;\r\n }\r\n}\r\n"],"names":[],"mappings":";;;;;;;;AAAA;;;AAGG;AAmBH;;;;;;;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