{"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--\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--\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 = [\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,iB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