{"version":3,"file":"CryptoKeyStore.js","sources":["../../src/cache/CryptoKeyStore.ts"],"sourcesContent":["/*\r\n * Copyright (c) Microsoft Corporation. All rights reserved.\r\n * Licensed under the MIT License.\r\n */\r\n\r\nimport { Logger } from \"@azure/msal-common\";\r\nimport { CachedKeyPair } from \"../crypto/CryptoOps\";\r\nimport { AsyncMemoryStorage } from \"./AsyncMemoryStorage\";\r\n\r\nexport enum CryptoKeyStoreNames {\r\n asymmetricKeys = \"asymmetricKeys\",\r\n symmetricKeys = \"symmetricKeys\"\r\n}\r\n/**\r\n * MSAL CryptoKeyStore DB Version 2\r\n */\r\nexport class CryptoKeyStore {\r\n public asymmetricKeys: AsyncMemoryStorage;\r\n public symmetricKeys: AsyncMemoryStorage;\r\n public logger: Logger;\r\n\r\n constructor(logger: Logger){\r\n this.logger = logger;\r\n this.asymmetricKeys = new AsyncMemoryStorage(this.logger, CryptoKeyStoreNames.asymmetricKeys);\r\n this.symmetricKeys = new AsyncMemoryStorage(this.logger, CryptoKeyStoreNames.symmetricKeys);\r\n }\r\n\r\n async clear(): Promise {\r\n // Delete in-memory keystores\r\n this.asymmetricKeys.clearInMemory();\r\n\t this.symmetricKeys.clearInMemory();\r\n\t\t\r\n /**\r\n * There is only one database, so calling clearPersistent on asymmetric keystore takes care of\r\n * every persistent keystore\r\n */\r\n try {\r\n await this.asymmetricKeys.clearPersistent();\r\n return true;\r\n } catch (e) {\r\n if (e instanceof Error) {\r\n this.logger.error(`Clearing keystore failed with error: ${e.message}`);\r\n } else {\r\n this.logger.error(\"Clearing keystore failed with unknown error\");\r\n }\r\n \r\n return false;\r\n }\r\n }\r\n}\r\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;;;;"}