{"version":3,"file":"CryptoKeyStore.js","sources":["../../src/cache/CryptoKeyStore.ts"],"sourcesContent":["/*\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { Logger } from \"@azure/msal-common\";\nimport { CachedKeyPair } from \"../crypto/CryptoOps\";\nimport { AsyncMemoryStorage } from \"./AsyncMemoryStorage\";\n\nexport enum CryptoKeyStoreNames {\n asymmetricKeys = \"asymmetricKeys\",\n symmetricKeys = \"symmetricKeys\"\n}\n/**\n * MSAL CryptoKeyStore DB Version 2\n */\nexport class CryptoKeyStore {\n public asymmetricKeys: AsyncMemoryStorage;\n public symmetricKeys: AsyncMemoryStorage;\n public logger: Logger;\n\n constructor(logger: Logger){\n this.logger = logger;\n this.asymmetricKeys = new AsyncMemoryStorage(this.logger, CryptoKeyStoreNames.asymmetricKeys);\n this.symmetricKeys = new AsyncMemoryStorage(this.logger, CryptoKeyStoreNames.symmetricKeys);\n }\n\n async clear(): Promise {\n // Delete in-memory keystores\n this.asymmetricKeys.clearInMemory();\n\t this.symmetricKeys.clearInMemory();\n\t\t\n /**\n * There is only one database, so calling clearPersistent on asymmetric keystore takes care of\n * every persistent keystore\n */\n try {\n await this.asymmetricKeys.clearPersistent();\n return true;\n } catch (e) {\n if (e instanceof Error) {\n this.logger.error(`Clearing keystore failed with error: ${e.message}`);\n } else {\n this.logger.error(\"Clearing keystore failed with unknown error\");\n }\n \n return false;\n }\n }\n}\n"],"names":[],"mappings":";;;;;AAAA;;;;IASY;AAAZ,WAAY,mBAAmB;IAC3B,wDAAiC,CAAA;IACjC,sDAA+B,CAAA;AACnC,CAAC,EAHW,mBAAmB,KAAnB,mBAAmB,QAG9B;AACD;;;;IAQI,wBAAY,MAAc;QACtB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,cAAc,GAAG,IAAI,kBAAkB,CAAgB,IAAI,CAAC,MAAM,EAAE,mBAAmB,CAAC,cAAc,CAAC,CAAC;QAC7G,IAAI,CAAC,aAAa,GAAG,IAAI,kBAAkB,CAAY,IAAI,CAAC,MAAM,EAAE,mBAAmB,CAAC,aAAa,CAAC,CAAC;KAC1G;IAEK,8BAAK,GAAX;;;;;;;wBAEI,IAAI,CAAC,cAAc,CAAC,aAAa,EAAE,CAAC;wBACvC,IAAI,CAAC,aAAa,CAAC,aAAa,EAAE,CAAC;;;;wBAO5B,qBAAM,IAAI,CAAC,cAAc,CAAC,eAAe,EAAE,EAAA;;wBAA3C,SAA2C,CAAC;wBAC5C,sBAAO,IAAI,EAAC;;;wBAEZ,IAAI,GAAC,YAAY,KAAK,EAAE;4BACpB,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,0CAAwC,GAAC,CAAC,OAAS,CAAC,CAAC;yBAC1E;6BAAM;4BACH,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,6CAA6C,CAAC,CAAC;yBACpE;wBAED,sBAAO,KAAK,EAAC;;;;;KAEpB;IACL,qBAAC;AAAD,CAAC;;;;"}