{"version":3,"file":"IdTokenEntity.js","sources":["../../../src/cache/entities/IdTokenEntity.ts"],"sourcesContent":["/*\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { CredentialEntity } from \"./CredentialEntity\";\nimport { CredentialType } from \"../../utils/Constants\";\n\n/**\n * ID_TOKEN Cache\n *\n * Key:Value Schema:\n *\n * Key Example: uid.utid-login.microsoftonline.com-idtoken-clientId-contoso.com-\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 * realm: Full tenant or organizational identifier that the account belongs to\n * }\n */\nexport class IdTokenEntity extends CredentialEntity {\n realm: string;\n\n /**\n * Create IdTokenEntity\n * @param homeAccountId\n * @param authenticationResult\n * @param clientId\n * @param authority\n */\n static createIdTokenEntity(\n homeAccountId: string,\n environment: string,\n idToken: string,\n clientId: string,\n tenantId: string,\n ): IdTokenEntity {\n const idTokenEntity = new IdTokenEntity();\n\n idTokenEntity.credentialType = CredentialType.ID_TOKEN;\n idTokenEntity.homeAccountId = homeAccountId;\n idTokenEntity.environment = environment;\n idTokenEntity.clientId = clientId;\n idTokenEntity.secret = idToken;\n idTokenEntity.realm = tenantId;\n\n return idTokenEntity;\n }\n\n /**\n * Validates an entity: checks for all expected params\n * @param entity\n */\n static isIdTokenEntity(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[\"credentialType\"] === CredentialType.ID_TOKEN\n );\n }\n}\n"],"names":[],"mappings":";;;;;;AAAA;;;AAGG;AAKH;;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