@azure/msal-browser 2.22.1 → 2.23.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/_virtual/_tslib.js +1 -1
- package/dist/app/ClientApplication.d.ts +24 -1
- package/dist/app/ClientApplication.d.ts.map +1 -1
- package/dist/app/ClientApplication.js +137 -36
- package/dist/app/ClientApplication.js.map +1 -1
- package/dist/app/IPublicClientApplication.d.ts +3 -1
- package/dist/app/IPublicClientApplication.d.ts.map +1 -1
- package/dist/app/IPublicClientApplication.js +7 -1
- package/dist/app/IPublicClientApplication.js.map +1 -1
- package/dist/app/PublicClientApplication.d.ts.map +1 -1
- package/dist/app/PublicClientApplication.js +51 -15
- package/dist/app/PublicClientApplication.js.map +1 -1
- package/dist/cache/AsyncMemoryStorage.d.ts +3 -2
- package/dist/cache/AsyncMemoryStorage.d.ts.map +1 -1
- package/dist/cache/AsyncMemoryStorage.js +17 -6
- package/dist/cache/AsyncMemoryStorage.js.map +1 -1
- package/dist/cache/BrowserCacheManager.js +7 -7
- package/dist/cache/BrowserCacheManager.js.map +1 -1
- package/dist/cache/BrowserStorage.js +1 -1
- package/dist/cache/DatabaseStorage.d.ts +5 -0
- package/dist/cache/DatabaseStorage.d.ts.map +1 -1
- package/dist/cache/DatabaseStorage.js +65 -13
- package/dist/cache/DatabaseStorage.js.map +1 -1
- package/dist/cache/MemoryStorage.js +1 -1
- package/dist/cache/TokenCache.js +1 -1
- package/dist/config/Configuration.d.ts +14 -2
- package/dist/config/Configuration.d.ts.map +1 -1
- package/dist/config/Configuration.js +16 -9
- package/dist/config/Configuration.js.map +1 -1
- package/dist/crypto/BrowserCrypto.d.ts.map +1 -1
- package/dist/crypto/BrowserCrypto.js +7 -6
- package/dist/crypto/BrowserCrypto.js.map +1 -1
- package/dist/crypto/CryptoOps.d.ts +12 -3
- package/dist/crypto/CryptoOps.d.ts.map +1 -1
- package/dist/crypto/CryptoOps.js +71 -36
- package/dist/crypto/CryptoOps.js.map +1 -1
- package/dist/crypto/GuidGenerator.d.ts +3 -2
- package/dist/crypto/GuidGenerator.d.ts.map +1 -1
- package/dist/crypto/GuidGenerator.js +4 -3
- package/dist/crypto/GuidGenerator.js.map +1 -1
- package/dist/crypto/PkceGenerator.js +1 -1
- package/dist/crypto/SignedHttpRequest.js +1 -1
- package/dist/encode/Base64Decode.d.ts.map +1 -1
- package/dist/encode/Base64Decode.js +3 -2
- package/dist/encode/Base64Decode.js.map +1 -1
- package/dist/encode/Base64Encode.d.ts.map +1 -1
- package/dist/encode/Base64Encode.js +5 -4
- package/dist/encode/Base64Encode.js.map +1 -1
- package/dist/error/BrowserAuthError.js +1 -1
- package/dist/error/BrowserConfigurationAuthError.js +1 -1
- package/dist/event/EventHandler.js +1 -1
- package/dist/event/EventMessage.js +1 -1
- package/dist/event/EventType.js +1 -1
- package/dist/index.cjs.js +1071 -258
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -2
- package/dist/index.js.map +1 -1
- package/dist/interaction_client/BaseInteractionClient.d.ts +3 -2
- package/dist/interaction_client/BaseInteractionClient.d.ts.map +1 -1
- package/dist/interaction_client/BaseInteractionClient.js +4 -3
- package/dist/interaction_client/BaseInteractionClient.js.map +1 -1
- package/dist/interaction_client/HybridSpaAuthorizationCodeClient.js +1 -1
- package/dist/interaction_client/PopupClient.d.ts.map +1 -1
- package/dist/interaction_client/PopupClient.js +3 -3
- package/dist/interaction_client/PopupClient.js.map +1 -1
- package/dist/interaction_client/RedirectClient.d.ts.map +1 -1
- package/dist/interaction_client/RedirectClient.js +4 -4
- package/dist/interaction_client/RedirectClient.js.map +1 -1
- package/dist/interaction_client/SilentAuthCodeClient.d.ts +2 -2
- package/dist/interaction_client/SilentAuthCodeClient.d.ts.map +1 -1
- package/dist/interaction_client/SilentAuthCodeClient.js +5 -5
- package/dist/interaction_client/SilentAuthCodeClient.js.map +1 -1
- package/dist/interaction_client/SilentCacheClient.d.ts.map +1 -1
- package/dist/interaction_client/SilentCacheClient.js +11 -3
- package/dist/interaction_client/SilentCacheClient.js.map +1 -1
- package/dist/interaction_client/SilentIframeClient.d.ts +2 -2
- package/dist/interaction_client/SilentIframeClient.d.ts.map +1 -1
- package/dist/interaction_client/SilentIframeClient.js +21 -7
- package/dist/interaction_client/SilentIframeClient.js.map +1 -1
- package/dist/interaction_client/SilentRefreshClient.d.ts.map +1 -1
- package/dist/interaction_client/SilentRefreshClient.js +16 -4
- package/dist/interaction_client/SilentRefreshClient.js.map +1 -1
- package/dist/interaction_client/StandardInteractionClient.d.ts +2 -2
- package/dist/interaction_client/StandardInteractionClient.d.ts.map +1 -1
- package/dist/interaction_client/StandardInteractionClient.js +30 -16
- package/dist/interaction_client/StandardInteractionClient.js.map +1 -1
- package/dist/interaction_handler/InteractionHandler.js +1 -1
- package/dist/interaction_handler/PopupHandler.js +1 -1
- package/dist/interaction_handler/RedirectHandler.js +1 -1
- package/dist/interaction_handler/SilentHandler.js +1 -1
- package/dist/navigation/NavigationClient.js +1 -1
- package/dist/network/FetchClient.d.ts.map +1 -1
- package/dist/network/FetchClient.js +3 -2
- package/dist/network/FetchClient.js.map +1 -1
- package/dist/network/XhrClient.js +1 -1
- package/dist/packageMetadata.d.ts +1 -1
- package/dist/packageMetadata.js +2 -2
- package/dist/packageMetadata.js.map +1 -1
- package/dist/telemetry/BrowserPerformanceClient.d.ts +19 -0
- package/dist/telemetry/BrowserPerformanceClient.d.ts.map +1 -0
- package/dist/telemetry/BrowserPerformanceClient.js +52 -0
- package/dist/telemetry/BrowserPerformanceClient.js.map +1 -0
- package/dist/telemetry/BrowserPerformanceMeasurement.d.ts +13 -0
- package/dist/telemetry/BrowserPerformanceMeasurement.d.ts.map +1 -0
- package/dist/telemetry/BrowserPerformanceMeasurement.js +66 -0
- package/dist/telemetry/BrowserPerformanceMeasurement.js.map +1 -0
- package/dist/utils/BrowserConstants.js +1 -1
- package/dist/utils/BrowserProtocolUtils.js +1 -1
- package/dist/utils/BrowserStringUtils.d.ts.map +1 -1
- package/dist/utils/BrowserStringUtils.js +4 -2
- package/dist/utils/BrowserStringUtils.js.map +1 -1
- package/dist/utils/BrowserUtils.js +2 -2
- package/dist/utils/BrowserUtils.js.map +1 -1
- package/dist/utils/MathUtils.js +1 -1
- package/dist/utils/PopupUtils.js +1 -1
- package/lib/msal-browser.js +1071 -258
- package/lib/msal-browser.js.map +1 -1
- package/lib/msal-browser.min.js +41 -36
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DatabaseStorage.js","sources":["../../src/cache/DatabaseStorage.ts"],"sourcesContent":["/*\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { BrowserAuthError } from \"../error/BrowserAuthError\";\nimport { DB_NAME, DB_TABLE_NAME, DB_VERSION } from \"../utils/BrowserConstants\";\nimport { IAsyncStorage } from \"./IAsyncMemoryStorage\";\n\ninterface IDBOpenDBRequestEvent extends Event {\n target: IDBOpenDBRequest & EventTarget;\n}\n\ninterface IDBOpenOnUpgradeNeededEvent extends IDBVersionChangeEvent {\n target: IDBOpenDBRequest & EventTarget;\n}\n\ninterface IDBRequestEvent extends Event {\n target: IDBRequest & EventTarget;\n}\n\n/**\n * Storage wrapper for IndexedDB storage in browsers: https://developer.mozilla.org/en-US/docs/Web/API/IndexedDB_API\n */\nexport class DatabaseStorage<T> implements IAsyncStorage<T> {\n private db: IDBDatabase|undefined;\n private dbName: string;\n private tableName: string;\n private version: number;\n private dbOpen: boolean;\n\n constructor() {\n this.dbName = DB_NAME;\n this.version = DB_VERSION;\n this.tableName = DB_TABLE_NAME;\n this.dbOpen = false;\n }\n\n /**\n * Opens IndexedDB instance.\n */\n async open(): Promise<void> {\n return new Promise((resolve, reject) => {\n const openDB = window.indexedDB.open(this.dbName, this.version);\n openDB.addEventListener(\"upgradeneeded\", (e: IDBVersionChangeEvent) => {\n const event = e as IDBOpenOnUpgradeNeededEvent;\n event.target.result.createObjectStore(this.tableName);\n });\n openDB.addEventListener(\"success\", (e: Event) => {\n const event = e as IDBOpenDBRequestEvent;\n this.db = event.target.result;\n this.dbOpen = true;\n resolve();\n });\n openDB.addEventListener(\"error\", () => reject(BrowserAuthError.createDatabaseUnavailableError()));\n });\n }\n\n /**\n * Opens database if it's not already open\n */\n private async validateDbIsOpen(): Promise<void> {\n if (!this.dbOpen) {\n return await this.open();\n }\n }\n\n /**\n * Retrieves item from IndexedDB instance.\n * @param key \n */\n async getItem(key: string): Promise<T | null> {\n await this.validateDbIsOpen();\n\n return new Promise<T>((resolve, reject) => {\n // TODO: Add timeouts?\n if (!this.db) {\n return reject(BrowserAuthError.createDatabaseNotOpenError());\n }\n const transaction = this.db.transaction([this.tableName], \"readonly\");\n const objectStore = transaction.objectStore(this.tableName);\n const dbGet = objectStore.get(key);\n dbGet.addEventListener(\"success\", (e: Event) => {\n const event = e as IDBRequestEvent;\n resolve(event.target.result);\n });\n dbGet.addEventListener(\"error\", (e) => reject(e));\n });\n }\n\n /**\n * Adds item to IndexedDB under given key\n * @param key \n * @param payload \n */\n async setItem(key: string, payload: T): Promise<void> {\n await this.validateDbIsOpen();\n\n return new Promise<void>((resolve: Function, reject: Function) => {\n // TODO: Add timeouts?\n if (!this.db) {\n return reject(BrowserAuthError.createDatabaseNotOpenError());\n }\n const transaction = this.db.transaction([this.tableName], \"readwrite\");\n\n const objectStore = transaction.objectStore(this.tableName);\n\n const dbPut = objectStore.put(payload, key);\n\n dbPut.addEventListener(\"success\", () => resolve());\n dbPut.addEventListener(\"error\", (e) => reject(e));\n });\n }\n\n /**\n * Removes item from IndexedDB under given key\n * @param key\n */\n async removeItem(key: string): Promise<void> {\n await this.validateDbIsOpen();\n\n return new Promise<void>((resolve: Function, reject: Function) => {\n if (!this.db) {\n return reject(BrowserAuthError.createDatabaseNotOpenError());\n }\n const transaction = this.db.transaction([this.tableName], \"readwrite\");\n const objectStore = transaction.objectStore(this.tableName);\n const dbDelete = objectStore.delete(key);\n dbDelete.addEventListener(\"success\", () => resolve());\n dbDelete.addEventListener(\"error\", (e) => reject(e));\n });\n }\n\n /**\n * Get all the keys from the storage object as an iterable array of strings.\n */\n async getKeys(): Promise<string[]> {\n await this.validateDbIsOpen();\n\n return new Promise<string[]>((resolve: Function, reject: Function) => {\n if (!this.db) {\n return reject(BrowserAuthError.createDatabaseNotOpenError());\n }\n\n const transaction = this.db.transaction([this.tableName], \"readonly\");\n const objectStore = transaction.objectStore(this.tableName);\n const dbGetKeys = objectStore.getAllKeys();\n dbGetKeys.addEventListener(\"success\", (e: Event) => {\n const event = e as IDBRequestEvent;\n resolve(event.target.result);\n });\n dbGetKeys.addEventListener(\"error\", (e: Event) => reject(e));\n });\n }\n\n /**\n * \n * Checks whether there is an object under the search key in the object store\n */\n async containsKey(key: string): Promise<boolean> {\n await this.validateDbIsOpen();\n\n return new Promise<boolean>((resolve: Function, reject: Function) => {\n if (!this.db) {\n return reject(BrowserAuthError.createDatabaseNotOpenError());\n }\n const transaction = this.db.transaction([this.tableName], \"readonly\");\n const objectStore = transaction.objectStore(this.tableName);\n const dbContainsKey = objectStore.count(key);\n dbContainsKey.addEventListener(\"success\", (e: Event) => {\n const event = e as IDBRequestEvent;\n resolve(event.target.result === 1);\n });\n dbContainsKey.addEventListener(\"error\", (e: Event) => reject(e));\n });\n }\n\n /**\n * Deletes the MSAL database. The database is deleted rather than cleared to make it possible\n * for client applications to downgrade to a previous MSAL version without worrying about forward compatibility issues\n * with IndexedDB database versions.\n */\n async deleteDatabase(): Promise<boolean> {\n return new Promise<boolean>((resolve: Function, reject: Function) => {\n const deleteDbRequest = window.indexedDB.deleteDatabase(DB_NAME);\n deleteDbRequest.addEventListener(\"success\", () => resolve(true));\n deleteDbRequest.addEventListener(\"error\", () => reject(false));\n });\n }\n}\n"],"names":[],"mappings":";;;;;;AAAA;;;;AAqBA;;;;IAUI;QACI,IAAI,CAAC,MAAM,G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CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;gCAC7C,aAAa,CAAC,gBAAgB,CAAC,SAAS,EAAE,UAAC,CAAQ;oCAC/C,IAAM,KAAK,GAAG,CAAoB,CAAC;oCACnC,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC;iCACtC,CAAC,CAAC;gCACH,aAAa,CAAC,gBAAgB,CAAC,OAAO,EAAE,UAAC,CAAQ,IAAK,OAAA,MAAM,CAAC,CAAC,CAAC,GAAA,CAAC,CAAC;6BACpE,CAAC,EAAC;;;;KACN;;;;;;IAOK,wCAAc,GAApB;;;gBACI,sBAAO,IAAI,OAAO,CAAU,UAAC,OAAiB,EAAE,MAAgB;wBAC5D,IAAM,eAAe,GAAG,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;wBACjE,eAAe,CAAC,gBAAgB,CAAC,SAAS,EAAE,cAAM,OAAA,OAAO,CAAC,IAAI,CAAC,GAAA,CAAC,CAAC;wBACjE,eAAe,CAAC,gBAAgB,CAAC,OAAO,EAAE,cAAM,OAAA,MAAM,CAAC,KAAK,CAAC,GAAA,CAAC,CAAC;qBAClE,CAAC,EAAC;;;KACN;IACL,sBAAC;AAAD,CAAC;;;;"}
|
|
1
|
+
{"version":3,"file":"DatabaseStorage.js","sources":["../../src/cache/DatabaseStorage.ts"],"sourcesContent":["/*\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { BrowserAuthError } from \"../error/BrowserAuthError\";\nimport { DB_NAME, DB_TABLE_NAME, DB_VERSION } from \"../utils/BrowserConstants\";\nimport { IAsyncStorage } from \"./IAsyncMemoryStorage\";\n\ninterface IDBOpenDBRequestEvent extends Event {\n target: IDBOpenDBRequest & EventTarget;\n}\n\ninterface IDBOpenOnUpgradeNeededEvent extends IDBVersionChangeEvent {\n target: IDBOpenDBRequest & EventTarget;\n}\n\ninterface IDBRequestEvent extends Event {\n target: IDBRequest & EventTarget;\n}\n\ninterface IDBDatabaseInfo {\n name?: string;\n version?: number;\n}\n\n/**\n * Storage wrapper for IndexedDB storage in browsers: https://developer.mozilla.org/en-US/docs/Web/API/IndexedDB_API\n */\nexport class DatabaseStorage<T> implements IAsyncStorage<T> {\n private db: IDBDatabase|undefined;\n private dbName: string;\n private tableName: string;\n private version: number;\n private dbOpen: boolean;\n\n constructor() {\n this.dbName = DB_NAME;\n this.version = DB_VERSION;\n this.tableName = DB_TABLE_NAME;\n this.dbOpen = false;\n }\n\n /**\n * Opens IndexedDB instance.\n */\n async open(): Promise<void> {\n return new Promise((resolve, reject) => {\n const openDB = window.indexedDB.open(this.dbName, this.version);\n openDB.addEventListener(\"upgradeneeded\", (e: IDBVersionChangeEvent) => {\n const event = e as IDBOpenOnUpgradeNeededEvent;\n event.target.result.createObjectStore(this.tableName);\n });\n openDB.addEventListener(\"success\", (e: Event) => {\n const event = e as IDBOpenDBRequestEvent;\n this.db = event.target.result;\n this.dbOpen = true;\n resolve();\n });\n openDB.addEventListener(\"error\", () => reject(BrowserAuthError.createDatabaseUnavailableError()));\n });\n }\n\n /**\n * Closes the connection to IndexedDB database when all pending transactions\n * complete.\n */\n closeConnection(): void {\n const db = this.db;\n if (db && this.dbOpen) {\n db.close();\n this.dbOpen = false;\n }\n }\n\n /**\n * Opens database if it's not already open\n */\n private async validateDbIsOpen(): Promise<void> {\n if (!this.dbOpen) {\n return await this.open();\n }\n }\n\n /**\n * Retrieves item from IndexedDB instance.\n * @param key \n */\n async getItem(key: string): Promise<T | null> {\n await this.validateDbIsOpen();\n return new Promise<T>((resolve, reject) => {\n // TODO: Add timeouts?\n if (!this.db) {\n return reject(BrowserAuthError.createDatabaseNotOpenError());\n }\n const transaction = this.db.transaction([this.tableName], \"readonly\");\n const objectStore = transaction.objectStore(this.tableName);\n const dbGet = objectStore.get(key);\n \n dbGet.addEventListener(\"success\", (e: Event) => {\n const event = e as IDBRequestEvent;\n this.closeConnection();\n resolve(event.target.result);\n });\n\n dbGet.addEventListener(\"error\", (e: Event) => {\n this.closeConnection();\n reject(e);\n });\n });\n }\n\n /**\n * Adds item to IndexedDB under given key\n * @param key \n * @param payload \n */\n async setItem(key: string, payload: T): Promise<void> {\n await this.validateDbIsOpen();\n return new Promise<void>((resolve: Function, reject: Function) => {\n // TODO: Add timeouts?\n if (!this.db) {\n return reject(BrowserAuthError.createDatabaseNotOpenError());\n }\n const transaction = this.db.transaction([this.tableName], \"readwrite\");\n\n const objectStore = transaction.objectStore(this.tableName);\n\n const dbPut = objectStore.put(payload, key);\n\n dbPut.addEventListener(\"success\", () => {\n this.closeConnection();\n resolve();\n });\n\n dbPut.addEventListener(\"error\", (e) => {\n this.closeConnection();\n reject(e);\n });\n });\n }\n\n /**\n * Removes item from IndexedDB under given key\n * @param key\n */\n async removeItem(key: string): Promise<void> {\n await this.validateDbIsOpen();\n return new Promise<void>((resolve: Function, reject: Function) => {\n if (!this.db) {\n return reject(BrowserAuthError.createDatabaseNotOpenError());\n }\n\n const transaction = this.db.transaction([this.tableName], \"readwrite\");\n const objectStore = transaction.objectStore(this.tableName);\n const dbDelete = objectStore.delete(key);\n\n dbDelete.addEventListener(\"success\", () => {\n this.closeConnection();\n resolve();\n });\n\n dbDelete.addEventListener(\"error\", (e) => {\n this.closeConnection();\n reject(e);\n });\n });\n }\n\n /**\n * Get all the keys from the storage object as an iterable array of strings.\n */\n async getKeys(): Promise<string[]> {\n await this.validateDbIsOpen();\n return new Promise<string[]>((resolve: Function, reject: Function) => {\n if (!this.db) {\n return reject(BrowserAuthError.createDatabaseNotOpenError());\n }\n\n const transaction = this.db.transaction([this.tableName], \"readonly\");\n const objectStore = transaction.objectStore(this.tableName);\n const dbGetKeys = objectStore.getAllKeys();\n\n dbGetKeys.addEventListener(\"success\", (e: Event) => {\n const event = e as IDBRequestEvent;\n this.closeConnection();\n resolve(event.target.result);\n });\n\n dbGetKeys.addEventListener(\"error\", (e: Event) => {\n this.closeConnection();\n reject(e);\n });\n });\n }\n\n /**\n * \n * Checks whether there is an object under the search key in the object store\n */\n async containsKey(key: string): Promise<boolean> {\n await this.validateDbIsOpen();\n\n return new Promise<boolean>((resolve: Function, reject: Function) => {\n if (!this.db) {\n return reject(BrowserAuthError.createDatabaseNotOpenError());\n }\n\n const transaction = this.db.transaction([this.tableName], \"readonly\");\n const objectStore = transaction.objectStore(this.tableName);\n const dbContainsKey = objectStore.count(key);\n\n dbContainsKey.addEventListener(\"success\", (e: Event) => {\n const event = e as IDBRequestEvent;\n this.closeConnection();\n resolve(event.target.result === 1);\n });\n\n dbContainsKey.addEventListener(\"error\", (e: Event) => {\n this.closeConnection();\n reject(e);\n });\n });\n }\n\n /**\n * Deletes the MSAL database. The database is deleted rather than cleared to make it possible\n * for client applications to downgrade to a previous MSAL version without worrying about forward compatibility issues\n * with IndexedDB database versions.\n */\n async deleteDatabase(): Promise<boolean> {\n // Check if database being deleted exists\n\n if (this.db && this.dbOpen) {\n this.closeConnection();\n }\n \n // @ts-ignore\n const existingDatabases = await window.indexedDB.databases();\n const database = existingDatabases.find((database: IDBDatabaseInfo) => database.name === DB_NAME );\n\n // If database exists, delete it\n if (database) {\n return new Promise<boolean>((resolve: Function, reject: Function) => {\n const deleteDbRequest = window.indexedDB.deleteDatabase(DB_NAME);\n deleteDbRequest.addEventListener(\"success\", () => resolve(true));\n deleteDbRequest.addEventListener(\"error\", () => reject(false));\n });\n }\n\n // Database doesn't exist, return true\n return true;\n }\n}\n"],"names":[],"mappings":";;;;;;AAAA;;;;AA0BA;;;;IAUI;QACI,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC;QACtB,IAAI,CAAC,OAAO,GAAG,UAAU,CAAC;QAC1B,IAAI,CAAC,SAAS,GAAG,aAAa,CAAC;QAC/B,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;KACvB;;;;IAKK,8BAAI,GAAV;;;;gBACI,sBAAO,IAAI,OAAO,CAAC,UAAC,OAAO,EAAE,MAAM;wBAC/B,IAAM,MAAM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jE,eAAe,CAAC,gBAAgB,CAAC,SAAS,EAAE,cAAM,OAAA,OAAO,CAAC,IAAI,CAAC,GAAA,CAAC,CAAC;oCACjE,eAAe,CAAC,gBAAgB,CAAC,OAAO,EAAE,cAAM,OAAA,MAAM,CAAC,KAAK,CAAC,GAAA,CAAC,CAAC;iCAClE,CAAC,EAAC;yBACN;;wBAGD,sBAAO,IAAI,EAAC;;;;KACf;IACL,sBAAC;AAAD,CAAC;;;;"}
|
package/dist/cache/TokenCache.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @azure/msal-browser v2.
|
|
1
|
+
/*! @azure/msal-browser v2.23.0 2022-04-04 */
|
|
2
2
|
'use strict';
|
|
3
3
|
import { Authority, IdTokenEntity, AuthToken, AccountEntity, ScopeSet, AccessTokenEntity } from '@azure/msal-common';
|
|
4
4
|
import { BrowserAuthError } from '../error/BrowserAuthError.js';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { SystemOptions, LoggerOptions, INetworkModule, ProtocolMode, AzureCloudOptions } from "@azure/msal-common";
|
|
1
|
+
import { SystemOptions, LoggerOptions, INetworkModule, ProtocolMode, AzureCloudOptions, ApplicationTelemetry } from "@azure/msal-common";
|
|
2
2
|
import { BrowserCacheLocation } from "../utils/BrowserConstants";
|
|
3
3
|
import { INavigationClient } from "../navigation/INavigationClient";
|
|
4
4
|
export declare const DEFAULT_POPUP_TIMEOUT_MS = 60000;
|
|
@@ -68,6 +68,15 @@ export declare type BrowserSystemOptions = SystemOptions & {
|
|
|
68
68
|
asyncPopups?: boolean;
|
|
69
69
|
allowRedirectInIframe?: boolean;
|
|
70
70
|
};
|
|
71
|
+
/**
|
|
72
|
+
* Telemetry Options
|
|
73
|
+
* - application: Telemetry information sent on request
|
|
74
|
+
* - appName: Unique string name of an application
|
|
75
|
+
* - appVersion: Version of the application using MSAL
|
|
76
|
+
*/
|
|
77
|
+
export declare type BrowserTelemetryOptions = {
|
|
78
|
+
application?: ApplicationTelemetry;
|
|
79
|
+
};
|
|
71
80
|
/**
|
|
72
81
|
* Use the configuration object to configure MSAL and initialize the UserAgentApplication.
|
|
73
82
|
*
|
|
@@ -75,16 +84,19 @@ export declare type BrowserSystemOptions = SystemOptions & {
|
|
|
75
84
|
* - auth: this is where you configure auth elements like clientID, authority used for authenticating against the Microsoft Identity Platform
|
|
76
85
|
* - cache: this is where you configure cache location and whether to store cache in cookies
|
|
77
86
|
* - system: this is where you can configure the network client, logger, token renewal offset
|
|
87
|
+
* - telemetry: this is where you can configure telemetry data and options
|
|
78
88
|
*/
|
|
79
89
|
export declare type Configuration = {
|
|
80
90
|
auth: BrowserAuthOptions;
|
|
81
91
|
cache?: CacheOptions;
|
|
82
92
|
system?: BrowserSystemOptions;
|
|
93
|
+
telemetry?: BrowserTelemetryOptions;
|
|
83
94
|
};
|
|
84
95
|
export declare type BrowserConfiguration = {
|
|
85
96
|
auth: Required<BrowserAuthOptions>;
|
|
86
97
|
cache: Required<CacheOptions>;
|
|
87
98
|
system: Required<BrowserSystemOptions>;
|
|
99
|
+
telemetry: Required<BrowserTelemetryOptions>;
|
|
88
100
|
};
|
|
89
101
|
/**
|
|
90
102
|
* MSAL function that sets the default options when not explicitly configured from app developer
|
|
@@ -95,5 +107,5 @@ export declare type BrowserConfiguration = {
|
|
|
95
107
|
*
|
|
96
108
|
* @returns Configuration object
|
|
97
109
|
*/
|
|
98
|
-
export declare function buildConfiguration({ auth: userInputAuth, cache: userInputCache, system: userInputSystem }: Configuration, isBrowserEnvironment: boolean): BrowserConfiguration;
|
|
110
|
+
export declare function buildConfiguration({ auth: userInputAuth, cache: userInputCache, system: userInputSystem, telemetry: userInputTelemetry }: Configuration, isBrowserEnvironment: boolean): BrowserConfiguration;
|
|
99
111
|
//# sourceMappingURL=Configuration.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Configuration.d.ts","sourceRoot":"","sources":["../../src/config/Configuration.ts"],"names":[],"mappings":"AAKA,OAAO,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@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @azure/msal-browser v2.
|
|
1
|
+
/*! @azure/msal-browser v2.23.0 2022-04-04 */
|
|
2
2
|
'use strict';
|
|
3
3
|
import { __assign } from '../_virtual/_tslib.js';
|
|
4
4
|
import { DEFAULT_SYSTEM_OPTIONS, StubbedNetworkModule, Constants, ProtocolMode, AzureCloudInstance, LogLevel } from '@azure/msal-common';
|
|
@@ -24,22 +24,22 @@ var DEFAULT_REDIRECT_TIMEOUT_MS = 30000;
|
|
|
24
24
|
* @returns Configuration object
|
|
25
25
|
*/
|
|
26
26
|
function buildConfiguration(_a, isBrowserEnvironment) {
|
|
27
|
-
var userInputAuth = _a.auth, userInputCache = _a.cache, userInputSystem = _a.system;
|
|
27
|
+
var userInputAuth = _a.auth, userInputCache = _a.cache, userInputSystem = _a.system, userInputTelemetry = _a.telemetry;
|
|
28
28
|
// Default auth options for browser
|
|
29
29
|
var DEFAULT_AUTH_OPTIONS = {
|
|
30
|
-
clientId:
|
|
30
|
+
clientId: Constants.EMPTY_STRING,
|
|
31
31
|
authority: "" + Constants.DEFAULT_AUTHORITY,
|
|
32
32
|
knownAuthorities: [],
|
|
33
|
-
cloudDiscoveryMetadata:
|
|
34
|
-
authorityMetadata:
|
|
35
|
-
redirectUri:
|
|
36
|
-
postLogoutRedirectUri:
|
|
33
|
+
cloudDiscoveryMetadata: Constants.EMPTY_STRING,
|
|
34
|
+
authorityMetadata: Constants.EMPTY_STRING,
|
|
35
|
+
redirectUri: Constants.EMPTY_STRING,
|
|
36
|
+
postLogoutRedirectUri: Constants.EMPTY_STRING,
|
|
37
37
|
navigateToLoginRequestUrl: true,
|
|
38
38
|
clientCapabilities: [],
|
|
39
39
|
protocolMode: ProtocolMode.AAD,
|
|
40
40
|
azureCloudOptions: {
|
|
41
41
|
azureCloudInstance: AzureCloudInstance.None,
|
|
42
|
-
tenant:
|
|
42
|
+
tenant: Constants.EMPTY_STRING
|
|
43
43
|
},
|
|
44
44
|
};
|
|
45
45
|
// Default cache options for browser
|
|
@@ -59,10 +59,17 @@ function buildConfiguration(_a, isBrowserEnvironment) {
|
|
|
59
59
|
var DEFAULT_BROWSER_SYSTEM_OPTIONS = __assign(__assign({}, DEFAULT_SYSTEM_OPTIONS), { loggerOptions: DEFAULT_LOGGER_OPTIONS, networkClient: isBrowserEnvironment ? BrowserUtils.getBrowserNetworkClient() : StubbedNetworkModule, navigationClient: new NavigationClient(), loadFrameTimeout: 0,
|
|
60
60
|
// If loadFrameTimeout is provided, use that as default.
|
|
61
61
|
windowHashTimeout: (userInputSystem && userInputSystem.loadFrameTimeout) || DEFAULT_POPUP_TIMEOUT_MS, iframeHashTimeout: (userInputSystem && userInputSystem.loadFrameTimeout) || DEFAULT_IFRAME_TIMEOUT_MS, navigateFrameWait: isBrowserEnvironment && BrowserUtils.detectIEOrEdge() ? 500 : 0, redirectNavigationTimeout: DEFAULT_REDIRECT_TIMEOUT_MS, asyncPopups: false, allowRedirectInIframe: false });
|
|
62
|
+
var DEFAULT_TELEMETRY_OPTIONS = {
|
|
63
|
+
application: {
|
|
64
|
+
appName: Constants.EMPTY_STRING,
|
|
65
|
+
appVersion: Constants.EMPTY_STRING
|
|
66
|
+
}
|
|
67
|
+
};
|
|
62
68
|
var overlayedConfig = {
|
|
63
69
|
auth: __assign(__assign({}, DEFAULT_AUTH_OPTIONS), userInputAuth),
|
|
64
70
|
cache: __assign(__assign({}, DEFAULT_CACHE_OPTIONS), userInputCache),
|
|
65
|
-
system: __assign(__assign({}, DEFAULT_BROWSER_SYSTEM_OPTIONS), userInputSystem)
|
|
71
|
+
system: __assign(__assign({}, DEFAULT_BROWSER_SYSTEM_OPTIONS), userInputSystem),
|
|
72
|
+
telemetry: __assign(__assign({}, DEFAULT_TELEMETRY_OPTIONS), userInputTelemetry)
|
|
66
73
|
};
|
|
67
74
|
return overlayedConfig;
|
|
68
75
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Configuration.js","sources":["../../src/config/Configuration.ts"],"sourcesContent":["/*\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { SystemOptions, LoggerOptions, INetworkModule, DEFAULT_SYSTEM_OPTIONS, Constants, ProtocolMode, LogLevel, StubbedNetworkModule, AzureCloudInstance, AzureCloudOptions } from \"@azure/msal-common\";\nimport { BrowserUtils } from \"../utils/BrowserUtils\";\nimport { BrowserCacheLocation } from \"../utils/BrowserConstants\";\nimport { INavigationClient } from \"../navigation/INavigationClient\";\nimport { NavigationClient } from \"../navigation/NavigationClient\";\n\n// Default timeout for popup windows and iframes in milliseconds\nexport const DEFAULT_POPUP_TIMEOUT_MS = 60000;\nexport const DEFAULT_IFRAME_TIMEOUT_MS = 6000;\nexport const DEFAULT_REDIRECT_TIMEOUT_MS = 30000;\n\n/**\n * Use this to configure the auth options in the Configuration object\n *\n * - clientId - Client ID of your app registered with our Application registration portal : https://portal.azure.com/#blade/Microsoft_AAD_IAM/ActiveDirectoryMenuBlade/RegisteredAppsPreview in Microsoft Identity Platform\n * - authority - You can configure a specific authority, defaults to \" \" or \"https://login.microsoftonline.com/common\"\n * - knownAuthorities - An array of URIs that are known to be valid. Used in B2C scenarios.\n * - cloudDiscoveryMetadata - A string containing the cloud discovery response. Used in AAD scenarios.\n * - redirectUri - The redirect URI where authentication responses can be received by your application. It must exactly match one of the redirect URIs registered in the Azure portal.\n * - postLogoutRedirectUri - The redirect URI where the window navigates after a successful logout.\n * - navigateToLoginRequestUrl - Boolean indicating whether to navigate to the original request URL after the auth server navigates to the redirect URL.\n * - clientCapabilities - Array of capabilities which will be added to the claims.access_token.xms_cc request property on every network request.\n * - protocolMode - Enum that represents the protocol that msal follows. Used for configuring proper endpoints.\n */\nexport type BrowserAuthOptions = {\n clientId: string;\n authority?: string;\n knownAuthorities?: Array<string>;\n cloudDiscoveryMetadata?: string;\n authorityMetadata?: string;\n redirectUri?: string;\n postLogoutRedirectUri?: string | null;\n navigateToLoginRequestUrl?: boolean;\n clientCapabilities?: Array<string>;\n protocolMode?: ProtocolMode;\n azureCloudOptions?: AzureCloudOptions;\n};\n\n/**\n * Use this to configure the below cache configuration options:\n *\n * - cacheLocation - Used to specify the cacheLocation user wants to set. Valid values are \"localStorage\" and \"sessionStorage\"\n * - storeAuthStateInCookie - If set, MSAL stores the auth request state required for validation of the auth flows in the browser cookies. By default this flag is set to false.\n * - secureCookies - If set, MSAL sets the \"Secure\" flag on cookies so they can only be sent over HTTPS. By default this flag is set to false.\n */\nexport type CacheOptions = {\n cacheLocation?: BrowserCacheLocation | string;\n storeAuthStateInCookie?: boolean;\n secureCookies?: boolean;\n};\n\n/**\n * Library Specific Options\n *\n * - tokenRenewalOffsetSeconds - Sets the window of offset needed to renew the token before expiry\n * - loggerOptions - Used to initialize the Logger object (See ClientConfiguration.ts)\n * - networkClient - Network interface implementation\n * - windowHashTimeout - Sets the timeout for waiting for a response hash in a popup. Will take precedence over loadFrameTimeout if both are set.\n * - iframeHashTimeout - Sets the timeout for waiting for a response hash in an iframe. Will take precedence over loadFrameTimeout if both are set.\n * - loadFrameTimeout - Sets the timeout for waiting for a response hash in an iframe or popup\n * - navigateFrameWait - Maximum time the library should wait for a frame to load\n * - redirectNavigationTimeout - Time to wait for redirection to occur before resolving promise\n * - asyncPopups - Sets whether popups are opened asynchronously. By default, this flag is set to false. When set to false, blank popups are opened before anything else happens. When set to true, popups are opened when making the network request.\n * - allowRedirectInIframe - Flag to enable redirect opertaions when the app is rendered in an iframe (to support scenarios such as embedded B2C login).\n */\nexport type BrowserSystemOptions = SystemOptions & {\n loggerOptions?: LoggerOptions;\n networkClient?: INetworkModule;\n navigationClient?: INavigationClient;\n windowHashTimeout?: number;\n iframeHashTimeout?: number;\n loadFrameTimeout?: number;\n navigateFrameWait?: number;\n redirectNavigationTimeout?: number;\n asyncPopups?: boolean;\n allowRedirectInIframe?: boolean;\n};\n\n/**\n * Use the configuration object to configure MSAL and initialize the UserAgentApplication.\n *\n * This object allows you to configure important elements of MSAL functionality:\n * - auth: this is where you configure auth elements like clientID, authority used for authenticating against the Microsoft Identity Platform\n * - cache: this is where you configure cache location and whether to store cache in cookies\n * - system: this is where you can configure the network client, logger, token renewal offset\n */\nexport type Configuration = {\n auth: BrowserAuthOptions,\n cache?: CacheOptions,\n system?: BrowserSystemOptions\n};\n\nexport type BrowserConfiguration = {\n auth: Required<BrowserAuthOptions>,\n cache: Required<CacheOptions>,\n system: Required<BrowserSystemOptions>\n};\n\n/**\n * MSAL function that sets the default options when not explicitly configured from app developer\n *\n * @param auth\n * @param cache\n * @param system\n *\n * @returns Configuration object\n */\nexport function buildConfiguration({ auth: userInputAuth, cache: userInputCache, system: userInputSystem }: Configuration, isBrowserEnvironment: boolean): BrowserConfiguration {\n\n // Default auth options for browser\n const DEFAULT_AUTH_OPTIONS: Required<BrowserAuthOptions> = {\n clientId: \"\",\n authority: `${Constants.DEFAULT_AUTHORITY}`,\n knownAuthorities: [],\n cloudDiscoveryMetadata: \"\",\n authorityMetadata: \"\",\n redirectUri: \"\",\n postLogoutRedirectUri: \"\",\n navigateToLoginRequestUrl: true,\n clientCapabilities: [],\n protocolMode: ProtocolMode.AAD,\n azureCloudOptions: {\n azureCloudInstance: AzureCloudInstance.None,\n tenant: \"\"\n },\n };\n\n // Default cache options for browser\n const DEFAULT_CACHE_OPTIONS: Required<CacheOptions> = {\n cacheLocation: BrowserCacheLocation.SessionStorage,\n storeAuthStateInCookie: false,\n secureCookies: false\n };\n\n // Default logger options for browser\n const DEFAULT_LOGGER_OPTIONS: LoggerOptions = {\n // eslint-disable-next-line @typescript-eslint/no-empty-function\n loggerCallback: (): void => {},\n logLevel: LogLevel.Info,\n piiLoggingEnabled: false\n };\n\n // Default system options for browser\n const DEFAULT_BROWSER_SYSTEM_OPTIONS: Required<BrowserSystemOptions> = {\n ...DEFAULT_SYSTEM_OPTIONS,\n loggerOptions: DEFAULT_LOGGER_OPTIONS,\n networkClient: isBrowserEnvironment ? BrowserUtils.getBrowserNetworkClient() : StubbedNetworkModule,\n navigationClient: new NavigationClient(),\n loadFrameTimeout: 0,\n // If loadFrameTimeout is provided, use that as default.\n windowHashTimeout: (userInputSystem && userInputSystem.loadFrameTimeout) || DEFAULT_POPUP_TIMEOUT_MS,\n iframeHashTimeout: (userInputSystem && userInputSystem.loadFrameTimeout) || DEFAULT_IFRAME_TIMEOUT_MS,\n navigateFrameWait: isBrowserEnvironment && BrowserUtils.detectIEOrEdge() ? 500 : 0,\n redirectNavigationTimeout: DEFAULT_REDIRECT_TIMEOUT_MS,\n asyncPopups: false,\n allowRedirectInIframe: false\n };\n\n const overlayedConfig: BrowserConfiguration = {\n auth: { ...DEFAULT_AUTH_OPTIONS, ...userInputAuth },\n cache: { ...DEFAULT_CACHE_OPTIONS, ...userInputCache },\n system: { ...DEFAULT_BROWSER_SYSTEM_OPTIONS, ...userInputSystem }\n };\n return overlayedConfig;\n}\n"],"names":[],"mappings":";;;;;;;;AAAA;;;;AAWA;IACa,wBAAwB,GAAG,MAAM;IACjC,yBAAyB,GAAG,KAAK;IACjC,2BAA2B,GAAG,MAAM;AAyFjD;;;;;;;;;SASgB,kBAAkB,CAAC,EAAsF,EAAE,oBAA6B;QAA7G,aAAa,UAAA,EAAS,cAAc,WAAA,EAAU,eAAe,YAAA;;IAGpG,IAAM,oBAAoB,GAAiC;QACvD,QAAQ,EAAE,EAAE;QACZ,SAAS,EAAE,KAAG,SAAS,CAAC,iBAAmB;QAC3C,gBAAgB,EAAE,EAAE;QACpB,sBAAsB,EAAE,EAAE;QAC1B,iBAAiB,EAAE,EAAE;QACrB,WAAW,EAAE,EAAE;QACf,qBAAqB,EAAE,EAAE;QACzB,yBAAyB,EAAE,IAAI;QAC/B,kBAAkB,EAAE,EAAE;QACtB,YAAY,EAAE,YAAY,CAAC,GAAG;QAC9B,iBAAiB,EAAE;YACf,kBAAkB,EAAE,kBAAkB,CAAC,IAAI;YAC3C,MAAM,EAAE,EAAE;SACb;KACJ,CAAC;;IAGF,IAAM,qBAAqB,GAA2B;QAClD,aAAa,EAAE,oBAAoB,CAAC,cAAc;QAClD,sBAAsB,EAAE,KAAK;QAC7B,aAAa,EAAE,KAAK;KACvB,CAAC;;IAGF,IAAM,sBAAsB,GAAkB;;QAE1C,cAAc,EAAE,eAAc;QAC9B,QAAQ,EAAE,QAAQ,CAAC,IAAI;QACvB,iBAAiB,EAAE,KAAK;KAC3B,CAAC;;IAGF,IAAM,8BAA8B,yBAC7B,sBAAsB,KACzB,aAAa,EAAE,sBAAsB,EACrC,aAAa,EAAE,oBAAoB,GAAG,YAAY,CAAC,uBAAuB,EAAE,GAAG,oBAAoB,EACnG,gBAAgB,EAAE,IAAI,gBAAgB,EAAE,EACxC,gBAAgB,EAAE,CAAC;;QAEnB,iBAAiB,EAAE,CAAC,eAAe,IAAI,eAAe,CAAC,gBAAgB,KAAK,wBAAwB,EACpG,iBAAiB,EAAE,CAAC,eAAe,IAAI,eAAe,CAAC,gBAAgB,KAAK,yBAAyB,EACrG,iBAAiB,EAAE,oBAAoB,IAAI,YAAY,CAAC,cAAc,EAAE,GAAG,GAAG,GAAG,CAAC,EAClF,yBAAyB,EAAE,2BAA2B,EACtD,WAAW,EAAE,KAAK,EAClB,qBAAqB,EAAE,KAAK,GAC/B,CAAC;IAEF,IAAM,eAAe,GAAyB;QAC1C,IAAI,wBAAO,oBAAoB,GAAK,aAAa,CAAE;QACnD,KAAK,wBAAO,qBAAqB,GAAK,cAAc,CAAE;QACtD,MAAM,wBAAO,8BAA8B,GAAK,eAAe,CAAE;KACpE,CAAC;IACF,OAAO,eAAe,CAAC;AAC3B;;;;"}
|
|
1
|
+
{"version":3,"file":"Configuration.js","sources":["../../src/config/Configuration.ts"],"sourcesContent":["/*\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { SystemOptions, LoggerOptions, INetworkModule, DEFAULT_SYSTEM_OPTIONS, Constants, ProtocolMode, LogLevel, StubbedNetworkModule, AzureCloudInstance, AzureCloudOptions, ApplicationTelemetry } from \"@azure/msal-common\";\nimport { BrowserUtils } from \"../utils/BrowserUtils\";\nimport { BrowserCacheLocation } from \"../utils/BrowserConstants\";\nimport { INavigationClient } from \"../navigation/INavigationClient\";\nimport { NavigationClient } from \"../navigation/NavigationClient\";\n\n// Default timeout for popup windows and iframes in milliseconds\nexport const DEFAULT_POPUP_TIMEOUT_MS = 60000;\nexport const DEFAULT_IFRAME_TIMEOUT_MS = 6000;\nexport const DEFAULT_REDIRECT_TIMEOUT_MS = 30000;\n\n/**\n * Use this to configure the auth options in the Configuration object\n *\n * - clientId - Client ID of your app registered with our Application registration portal : https://portal.azure.com/#blade/Microsoft_AAD_IAM/ActiveDirectoryMenuBlade/RegisteredAppsPreview in Microsoft Identity Platform\n * - authority - You can configure a specific authority, defaults to \" \" or \"https://login.microsoftonline.com/common\"\n * - knownAuthorities - An array of URIs that are known to be valid. Used in B2C scenarios.\n * - cloudDiscoveryMetadata - A string containing the cloud discovery response. Used in AAD scenarios.\n * - redirectUri - The redirect URI where authentication responses can be received by your application. It must exactly match one of the redirect URIs registered in the Azure portal.\n * - postLogoutRedirectUri - The redirect URI where the window navigates after a successful logout.\n * - navigateToLoginRequestUrl - Boolean indicating whether to navigate to the original request URL after the auth server navigates to the redirect URL.\n * - clientCapabilities - Array of capabilities which will be added to the claims.access_token.xms_cc request property on every network request.\n * - protocolMode - Enum that represents the protocol that msal follows. Used for configuring proper endpoints.\n */\nexport type BrowserAuthOptions = {\n clientId: string;\n authority?: string;\n knownAuthorities?: Array<string>;\n cloudDiscoveryMetadata?: string;\n authorityMetadata?: string;\n redirectUri?: string;\n postLogoutRedirectUri?: string | null;\n navigateToLoginRequestUrl?: boolean;\n clientCapabilities?: Array<string>;\n protocolMode?: ProtocolMode;\n azureCloudOptions?: AzureCloudOptions;\n};\n\n/**\n * Use this to configure the below cache configuration options:\n *\n * - cacheLocation - Used to specify the cacheLocation user wants to set. Valid values are \"localStorage\" and \"sessionStorage\"\n * - storeAuthStateInCookie - If set, MSAL stores the auth request state required for validation of the auth flows in the browser cookies. By default this flag is set to false.\n * - secureCookies - If set, MSAL sets the \"Secure\" flag on cookies so they can only be sent over HTTPS. By default this flag is set to false.\n */\nexport type CacheOptions = {\n cacheLocation?: BrowserCacheLocation | string;\n storeAuthStateInCookie?: boolean;\n secureCookies?: boolean;\n};\n\n/**\n * Library Specific Options\n *\n * - tokenRenewalOffsetSeconds - Sets the window of offset needed to renew the token before expiry\n * - loggerOptions - Used to initialize the Logger object (See ClientConfiguration.ts)\n * - networkClient - Network interface implementation\n * - windowHashTimeout - Sets the timeout for waiting for a response hash in a popup. Will take precedence over loadFrameTimeout if both are set.\n * - iframeHashTimeout - Sets the timeout for waiting for a response hash in an iframe. Will take precedence over loadFrameTimeout if both are set.\n * - loadFrameTimeout - Sets the timeout for waiting for a response hash in an iframe or popup\n * - navigateFrameWait - Maximum time the library should wait for a frame to load\n * - redirectNavigationTimeout - Time to wait for redirection to occur before resolving promise\n * - asyncPopups - Sets whether popups are opened asynchronously. By default, this flag is set to false. When set to false, blank popups are opened before anything else happens. When set to true, popups are opened when making the network request.\n * - allowRedirectInIframe - Flag to enable redirect opertaions when the app is rendered in an iframe (to support scenarios such as embedded B2C login).\n */\nexport type BrowserSystemOptions = SystemOptions & {\n loggerOptions?: LoggerOptions;\n networkClient?: INetworkModule;\n navigationClient?: INavigationClient;\n windowHashTimeout?: number;\n iframeHashTimeout?: number;\n loadFrameTimeout?: number;\n navigateFrameWait?: number;\n redirectNavigationTimeout?: number;\n asyncPopups?: boolean;\n allowRedirectInIframe?: boolean;\n};\n\n/**\n * Telemetry Options\n * - application: Telemetry information sent on request\n * - appName: Unique string name of an application\n * - appVersion: Version of the application using MSAL\n */\nexport type BrowserTelemetryOptions = {\n application?: ApplicationTelemetry;\n};\n\n/**\n * Use the configuration object to configure MSAL and initialize the UserAgentApplication.\n *\n * This object allows you to configure important elements of MSAL functionality:\n * - auth: this is where you configure auth elements like clientID, authority used for authenticating against the Microsoft Identity Platform\n * - cache: this is where you configure cache location and whether to store cache in cookies\n * - system: this is where you can configure the network client, logger, token renewal offset\n * - telemetry: this is where you can configure telemetry data and options\n */\nexport type Configuration = {\n auth: BrowserAuthOptions,\n cache?: CacheOptions,\n system?: BrowserSystemOptions,\n telemetry?: BrowserTelemetryOptions\n};\n\nexport type BrowserConfiguration = {\n auth: Required<BrowserAuthOptions>,\n cache: Required<CacheOptions>,\n system: Required<BrowserSystemOptions>,\n telemetry: Required<BrowserTelemetryOptions>\n};\n\n/**\n * MSAL function that sets the default options when not explicitly configured from app developer\n *\n * @param auth\n * @param cache\n * @param system\n *\n * @returns Configuration object\n */\nexport function buildConfiguration({ auth: userInputAuth, cache: userInputCache, system: userInputSystem, telemetry: userInputTelemetry }: Configuration, isBrowserEnvironment: boolean): BrowserConfiguration {\n\n // Default auth options for browser\n const DEFAULT_AUTH_OPTIONS: Required<BrowserAuthOptions> = {\n clientId: Constants.EMPTY_STRING,\n authority: `${Constants.DEFAULT_AUTHORITY}`,\n knownAuthorities: [],\n cloudDiscoveryMetadata: Constants.EMPTY_STRING,\n authorityMetadata: Constants.EMPTY_STRING,\n redirectUri: Constants.EMPTY_STRING,\n postLogoutRedirectUri: Constants.EMPTY_STRING,\n navigateToLoginRequestUrl: true,\n clientCapabilities: [],\n protocolMode: ProtocolMode.AAD,\n azureCloudOptions: {\n azureCloudInstance: AzureCloudInstance.None,\n tenant: Constants.EMPTY_STRING\n },\n };\n\n // Default cache options for browser\n const DEFAULT_CACHE_OPTIONS: Required<CacheOptions> = {\n cacheLocation: BrowserCacheLocation.SessionStorage,\n storeAuthStateInCookie: false,\n secureCookies: false\n };\n\n // Default logger options for browser\n const DEFAULT_LOGGER_OPTIONS: LoggerOptions = {\n // eslint-disable-next-line @typescript-eslint/no-empty-function\n loggerCallback: (): void => {},\n logLevel: LogLevel.Info,\n piiLoggingEnabled: false\n };\n\n // Default system options for browser\n const DEFAULT_BROWSER_SYSTEM_OPTIONS: Required<BrowserSystemOptions> = {\n ...DEFAULT_SYSTEM_OPTIONS,\n loggerOptions: DEFAULT_LOGGER_OPTIONS,\n networkClient: isBrowserEnvironment ? BrowserUtils.getBrowserNetworkClient() : StubbedNetworkModule,\n navigationClient: new NavigationClient(),\n loadFrameTimeout: 0,\n // If loadFrameTimeout is provided, use that as default.\n windowHashTimeout: (userInputSystem && userInputSystem.loadFrameTimeout) || DEFAULT_POPUP_TIMEOUT_MS,\n iframeHashTimeout: (userInputSystem && userInputSystem.loadFrameTimeout) || DEFAULT_IFRAME_TIMEOUT_MS,\n navigateFrameWait: isBrowserEnvironment && BrowserUtils.detectIEOrEdge() ? 500 : 0,\n redirectNavigationTimeout: DEFAULT_REDIRECT_TIMEOUT_MS,\n asyncPopups: false,\n allowRedirectInIframe: false\n };\n\n const DEFAULT_TELEMETRY_OPTIONS: Required<BrowserTelemetryOptions> = {\n application: {\n appName: Constants.EMPTY_STRING,\n appVersion: Constants.EMPTY_STRING\n }\n };\n\n const overlayedConfig: BrowserConfiguration = {\n auth: { ...DEFAULT_AUTH_OPTIONS, ...userInputAuth },\n cache: { ...DEFAULT_CACHE_OPTIONS, ...userInputCache },\n system: { ...DEFAULT_BROWSER_SYSTEM_OPTIONS, ...userInputSystem },\n telemetry: { ...DEFAULT_TELEMETRY_OPTIONS, ...userInputTelemetry }\n };\n return overlayedConfig;\n}\n"],"names":[],"mappings":";;;;;;;;AAAA;;;;AAWA;IACa,wBAAwB,GAAG,MAAM;IACjC,yBAAyB,GAAG,KAAK;IACjC,2BAA2B,GAAG,MAAM;AAsGjD;;;;;;;;;SASgB,kBAAkB,CAAC,EAAqH,EAAE,oBAA6B;QAA5I,aAAa,UAAA,EAAS,cAAc,WAAA,EAAU,eAAe,YAAA,EAAa,kBAAkB,eAAA;;IAGnI,IAAM,oBAAoB,GAAiC;QACvD,QAAQ,EAAE,SAAS,CAAC,YAAY;QAChC,SAAS,EAAE,KAAG,SAAS,CAAC,iBAAmB;QAC3C,gBAAgB,EAAE,EAAE;QACp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Y;YAC/B,UAAU,EAAE,SAAS,CAAC,YAAY;SACrC;KACJ,CAAC;IAEF,IAAM,eAAe,GAAyB;QAC1C,IAAI,wBAAO,oBAAoB,GAAK,aAAa,CAAE;QACnD,KAAK,wBAAO,qBAAqB,GAAK,cAAc,CAAE;QACtD,MAAM,wBAAO,8BAA8B,GAAK,eAAe,CAAE;QACjE,SAAS,wBAAO,yBAAyB,GAAK,kBAAkB,CAAE;KACrE,CAAC;IACF,OAAO,eAAe,CAAC;AAC3B;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BrowserCrypto.d.ts","sourceRoot":"","sources":["../../src/crypto/BrowserCrypto.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,MAAM,EAAE,MAAM,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"BrowserCrypto.d.ts","sourceRoot":"","sources":["../../src/crypto/BrowserCrypto.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,MAAM,EAAE,MAAM,IAAI,CAAC;AAc5B;;;GAGG;AACH,qBAAa,aAAa;IAEtB,OAAO,CAAC,uBAAuB,CAAwB;IACvD,OAAO,CAAC,MAAM,CAAS;gBAEX,MAAM,EAAE,MAAM;IAe1B;;;OAGG;IACG,YAAY,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC;IAM5D;;;OAGG;IACH,eAAe,CAAC,UAAU,EAAE,UAAU,GAAG,IAAI;IAQ7C;;;;OAIG;IACG,eAAe,CAAC,WAAW,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,QAAQ,CAAC,GAAG,OAAO,CAAC,aAAa,CAAC;IAQ5F;;;;OAIG;IACG,SAAS,CAAC,GAAG,EAAE,SAAS,GAAG,OAAO,CAAC,UAAU,CAAC;IAIpD;;;;;;OAMG;IACG,SAAS,CAAC,GAAG,EAAE,UAAU,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,QAAQ,CAAC,GAAG,OAAO,CAAC,SAAS,CAAC;IASnG;;;;OAIG;IACG,IAAI,CAAC,GAAG,EAAE,SAAS,EAAE,IAAI,EAAE,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC;IAMnE;;OAEG;IACH,OAAO,CAAC,YAAY;IAIpB;;OAEG;IACH,OAAO,CAAC,WAAW;IAInB;;OAEG;IACH,OAAO,CAAC,gBAAgB;IAIxB;;;;OAIG;YACW,qBAAqB;IAInC;;;;OAIG;YACW,iBAAiB;IAY/B;;;;OAIG;YACW,mBAAmB;IAajC;;;;OAIG;YACW,iBAAiB;IA0B/B;;;;;;OAMG;YACW,iBAAiB;IAa/B;;;;OAIG;YACW,YAAY;IAa1B;;;OAGG;IACH,MAAM,CAAC,YAAY,CAAC,GAAG,EAAE,UAAU,GAAG,MAAM;CAG/C"}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
/*! @azure/msal-browser v2.
|
|
1
|
+
/*! @azure/msal-browser v2.23.0 2022-04-04 */
|
|
2
2
|
'use strict';
|
|
3
3
|
import { __awaiter, __generator } from '../_virtual/_tslib.js';
|
|
4
4
|
import { BrowserStringUtils } from '../utils/BrowserStringUtils.js';
|
|
5
5
|
import { BrowserAuthError } from '../error/BrowserAuthError.js';
|
|
6
6
|
import { KEY_FORMAT_JWK } from '../utils/BrowserConstants.js';
|
|
7
|
+
import { Constants } from '@azure/msal-common';
|
|
7
8
|
|
|
8
9
|
/*
|
|
9
10
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -204,11 +205,11 @@ var BrowserCrypto = /** @class */ (function () {
|
|
|
204
205
|
msExportKey.addEventListener("complete", function (e) {
|
|
205
206
|
var resultBuffer = e.target.result;
|
|
206
207
|
var resultString = BrowserStringUtils.utf8ArrToString(new Uint8Array(resultBuffer))
|
|
207
|
-
.replace(/\r/g,
|
|
208
|
-
.replace(/\n/g,
|
|
209
|
-
.replace(/\t/g,
|
|
210
|
-
.split(" ").join(
|
|
211
|
-
.replace("\u0000",
|
|
208
|
+
.replace(/\r/g, Constants.EMPTY_STRING)
|
|
209
|
+
.replace(/\n/g, Constants.EMPTY_STRING)
|
|
210
|
+
.replace(/\t/g, Constants.EMPTY_STRING)
|
|
211
|
+
.split(" ").join(Constants.EMPTY_STRING)
|
|
212
|
+
.replace("\u0000", Constants.EMPTY_STRING);
|
|
212
213
|
try {
|
|
213
214
|
resolve(JSON.parse(resultString));
|
|
214
215
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BrowserCrypto.js","sources":["../../src/crypto/BrowserCrypto.ts"],"sourcesContent":["/*\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { BrowserStringUtils } from \"../utils/BrowserStringUtils\";\nimport { BrowserAuthError } from \"../error/BrowserAuthError\";\nimport { KEY_FORMAT_JWK } from \"../utils/BrowserConstants\";\nimport { Logger } from \"..\";\n/**\n * See here for more info on RsaHashedKeyGenParams: https://developer.mozilla.org/en-US/docs/Web/API/RsaHashedKeyGenParams\n */\n// RSA KeyGen Algorithm\nconst PKCS1_V15_KEYGEN_ALG = \"RSASSA-PKCS1-v1_5\";\n// SHA-256 hashing algorithm\nconst S256_HASH_ALG = \"SHA-256\";\n// MOD length for PoP tokens\nconst MODULUS_LENGTH = 2048;\n// Public Exponent\nconst PUBLIC_EXPONENT: Uint8Array = new Uint8Array([0x01, 0x00, 0x01]);\n\n/**\n * This class implements functions used by the browser library to perform cryptography operations such as\n * hashing and encoding. It also has helper functions to validate the availability of specific APIs.\n */\nexport class BrowserCrypto {\n\n private _keygenAlgorithmOptions: RsaHashedKeyGenParams;\n private logger: Logger;\n\n constructor(logger: Logger) {\n this.logger = logger;\n \n if (!(this.hasCryptoAPI())) {\n throw BrowserAuthError.createCryptoNotAvailableError(\"Browser crypto or msCrypto object not available.\");\n }\n\n this._keygenAlgorithmOptions = {\n name: PKCS1_V15_KEYGEN_ALG,\n hash: S256_HASH_ALG,\n modulusLength: MODULUS_LENGTH,\n publicExponent: PUBLIC_EXPONENT\n };\n }\n\n /**\n * Returns a sha-256 hash of the given dataString as an ArrayBuffer.\n * @param dataString \n */\n async sha256Digest(dataString: string): Promise<ArrayBuffer> {\n const data = BrowserStringUtils.stringToUtf8Arr(dataString);\n\n return this.hasIECrypto() ? this.getMSCryptoDigest(S256_HASH_ALG, data) : this.getSubtleCryptoDigest(S256_HASH_ALG, data);\n }\n\n /**\n * Populates buffer with cryptographically random values.\n * @param dataBuffer \n */\n getRandomValues(dataBuffer: Uint8Array): void {\n const cryptoObj = window[\"msCrypto\"] || window.crypto;\n if (!cryptoObj.getRandomValues) {\n throw BrowserAuthError.createCryptoNotAvailableError(\"getRandomValues does not exist.\");\n }\n cryptoObj.getRandomValues(dataBuffer);\n }\n\n /**\n * Generates a keypair based on current keygen algorithm config.\n * @param extractable \n * @param usages \n */\n async generateKeyPair(extractable: boolean, usages: Array<KeyUsage>): Promise<CryptoKeyPair> {\n return (\n this.hasIECrypto() ? \n this.msCryptoGenerateKey(extractable, usages) \n : window.crypto.subtle.generateKey(this._keygenAlgorithmOptions, extractable, usages)\n ) as Promise<CryptoKeyPair>;\n }\n\n /**\n * Export key as Json Web Key (JWK)\n * @param key \n * @param format \n */\n async exportJwk(key: CryptoKey): Promise<JsonWebKey> {\n return this.hasIECrypto() ? this.msCryptoExportJwk(key) : window.crypto.subtle.exportKey(KEY_FORMAT_JWK, key);\n }\n\n /**\n * Imports key as Json Web Key (JWK), can set extractable and usages.\n * @param key \n * @param format \n * @param extractable \n * @param usages \n */\n async importJwk(key: JsonWebKey, extractable: boolean, usages: Array<KeyUsage>): Promise<CryptoKey> {\n const keyString = BrowserCrypto.getJwkString(key);\n const keyBuffer = BrowserStringUtils.stringToArrayBuffer(keyString);\n\n return this.hasIECrypto() ? \n this.msCryptoImportKey(keyBuffer, extractable, usages) \n : window.crypto.subtle.importKey(KEY_FORMAT_JWK, key, this._keygenAlgorithmOptions, extractable, usages);\n }\n\n /**\n * Signs given data with given key\n * @param key \n * @param data \n */\n async sign(key: CryptoKey, data: ArrayBuffer): Promise<ArrayBuffer> {\n return this.hasIECrypto() ?\n this.msCryptoSign(key, data)\n : window.crypto.subtle.sign(this._keygenAlgorithmOptions, key, data);\n }\n\n /**\n * Check whether IE crypto or other browser cryptography is available.\n */\n private hasCryptoAPI(): boolean {\n return this.hasIECrypto() || this.hasBrowserCrypto();\n }\n\n /**\n * Checks whether IE crypto (AKA msCrypto) is available.\n */\n private hasIECrypto(): boolean {\n return \"msCrypto\" in window;\n }\n\n /**\n * Check whether browser crypto is available.\n */\n private hasBrowserCrypto(): boolean {\n return \"crypto\" in window;\n }\n\n /**\n * Helper function for SHA digest.\n * @param algorithm \n * @param data \n */\n private async getSubtleCryptoDigest(algorithm: string, data: Uint8Array): Promise<ArrayBuffer> {\n return window.crypto.subtle.digest(algorithm, data);\n }\n\n /**\n * IE Helper function for SHA digest.\n * @param algorithm \n * @param data \n */\n private async getMSCryptoDigest(algorithm: string, data: Uint8Array): Promise<ArrayBuffer> {\n return new Promise((resolve, reject) => {\n const digestOperation = window[\"msCrypto\"].subtle.digest(algorithm, data.buffer);\n digestOperation.addEventListener(\"complete\", (e: { target: { result: ArrayBuffer | PromiseLike<ArrayBuffer>; }; }) => {\n resolve(e.target.result);\n });\n digestOperation.addEventListener(\"error\", (error: string) => {\n reject(error);\n });\n });\n }\n\n /**\n * IE Helper function for generating a keypair\n * @param extractable \n * @param usages \n */\n private async msCryptoGenerateKey(extractable: boolean, usages: Array<KeyUsage>): Promise<CryptoKeyPair> {\n return new Promise((resolve: Function, reject: Function) => {\n const msGenerateKey = window[\"msCrypto\"].subtle.generateKey(this._keygenAlgorithmOptions, extractable, usages);\n msGenerateKey.addEventListener(\"complete\", (e: { target: { result: CryptoKeyPair | PromiseLike<CryptoKeyPair>; }; }) => {\n resolve(e.target.result);\n });\n\n msGenerateKey.addEventListener(\"error\", (error: string) => {\n reject(error);\n });\n });\n }\n\n /**\n * IE Helper function for exportKey\n * @param key \n * @param format \n */\n private async msCryptoExportJwk(key: CryptoKey): Promise<JsonWebKey> {\n return new Promise((resolve: Function, reject: Function) => {\n const msExportKey = window[\"msCrypto\"].subtle.exportKey(KEY_FORMAT_JWK, key);\n msExportKey.addEventListener(\"complete\", (e: { target: { result: ArrayBuffer; }; }) => {\n const resultBuffer: ArrayBuffer = e.target.result;\n\n const resultString = BrowserStringUtils.utf8ArrToString(new Uint8Array(resultBuffer))\n .replace(/\\r/g, \"\")\n .replace(/\\n/g, \"\")\n .replace(/\\t/g, \"\")\n .split(\" \").join(\"\")\n .replace(\"\\u0000\", \"\");\n\n try {\n resolve(JSON.parse(resultString));\n } catch (e) {\n reject(e);\n }\n });\n\n msExportKey.addEventListener(\"error\", (error: string) => {\n reject(error);\n });\n });\n }\n\n /**\n * IE Helper function for importKey\n * @param key \n * @param format \n * @param extractable \n * @param usages \n */\n private async msCryptoImportKey(keyBuffer: ArrayBuffer, extractable: boolean, usages: Array<KeyUsage>): Promise<CryptoKey> {\n return new Promise((resolve: Function, reject: Function) => {\n const msImportKey = window[\"msCrypto\"].subtle.importKey(KEY_FORMAT_JWK, keyBuffer, this._keygenAlgorithmOptions, extractable, usages);\n msImportKey.addEventListener(\"complete\", (e: { target: { result: CryptoKey | PromiseLike<CryptoKey>; }; }) => {\n resolve(e.target.result);\n });\n\n msImportKey.addEventListener(\"error\", (error: string) => {\n reject(error);\n });\n });\n }\n\n /**\n * IE Helper function for sign JWT\n * @param key \n * @param data \n */\n private async msCryptoSign(key: CryptoKey, data: ArrayBuffer): Promise<ArrayBuffer> {\n return new Promise((resolve: Function, reject: Function) => {\n const msSign = window[\"msCrypto\"].subtle.sign(this._keygenAlgorithmOptions, key, data);\n msSign.addEventListener(\"complete\", (e: { target: { result: ArrayBuffer | PromiseLike<ArrayBuffer>; }; }) => {\n resolve(e.target.result);\n });\n\n msSign.addEventListener(\"error\", (error: string) => {\n reject(error);\n });\n });\n }\n\n /**\n * Returns stringified jwk.\n * @param jwk \n */\n static getJwkString(j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,CAAC;;;;"}
|
|
1
|
+
{"version":3,"file":"BrowserCrypto.js","sources":["../../src/crypto/BrowserCrypto.ts"],"sourcesContent":["/*\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { BrowserStringUtils } from \"../utils/BrowserStringUtils\";\nimport { BrowserAuthError } from \"../error/BrowserAuthError\";\nimport { KEY_FORMAT_JWK } from \"../utils/BrowserConstants\";\nimport { Logger } from \"..\";\nimport { Constants } from \"@azure/msal-common\";\n/**\n * See here for more info on RsaHashedKeyGenParams: https://developer.mozilla.org/en-US/docs/Web/API/RsaHashedKeyGenParams\n */\n// RSA KeyGen Algorithm\nconst PKCS1_V15_KEYGEN_ALG = \"RSASSA-PKCS1-v1_5\";\n// SHA-256 hashing algorithm\nconst S256_HASH_ALG = \"SHA-256\";\n// MOD length for PoP tokens\nconst MODULUS_LENGTH = 2048;\n// Public Exponent\nconst PUBLIC_EXPONENT: Uint8Array = new Uint8Array([0x01, 0x00, 0x01]);\n\n/**\n * This class implements functions used by the browser library to perform cryptography operations such as\n * hashing and encoding. It also has helper functions to validate the availability of specific APIs.\n */\nexport class BrowserCrypto {\n\n private _keygenAlgorithmOptions: RsaHashedKeyGenParams;\n private logger: Logger;\n\n constructor(logger: Logger) {\n this.logger = logger;\n \n if (!(this.hasCryptoAPI())) {\n throw BrowserAuthError.createCryptoNotAvailableError(\"Browser crypto or msCrypto object not available.\");\n }\n\n this._keygenAlgorithmOptions = {\n name: PKCS1_V15_KEYGEN_ALG,\n hash: S256_HASH_ALG,\n modulusLength: MODULUS_LENGTH,\n publicExponent: PUBLIC_EXPONENT\n };\n }\n\n /**\n * Returns a sha-256 hash of the given dataString as an ArrayBuffer.\n * @param dataString \n */\n async sha256Digest(dataString: string): Promise<ArrayBuffer> {\n const data = BrowserStringUtils.stringToUtf8Arr(dataString);\n\n return this.hasIECrypto() ? this.getMSCryptoDigest(S256_HASH_ALG, data) : this.getSubtleCryptoDigest(S256_HASH_ALG, data);\n }\n\n /**\n * Populates buffer with cryptographically random values.\n * @param dataBuffer \n */\n getRandomValues(dataBuffer: Uint8Array): void {\n const cryptoObj = window[\"msCrypto\"] || window.crypto;\n if (!cryptoObj.getRandomValues) {\n throw BrowserAuthError.createCryptoNotAvailableError(\"getRandomValues does not exist.\");\n }\n cryptoObj.getRandomValues(dataBuffer);\n }\n\n /**\n * Generates a keypair based on current keygen algorithm config.\n * @param extractable \n * @param usages \n */\n async generateKeyPair(extractable: boolean, usages: Array<KeyUsage>): Promise<CryptoKeyPair> {\n return (\n this.hasIECrypto() ? \n this.msCryptoGenerateKey(extractable, usages) \n : window.crypto.subtle.generateKey(this._keygenAlgorithmOptions, extractable, usages)\n ) as Promise<CryptoKeyPair>;\n }\n\n /**\n * Export key as Json Web Key (JWK)\n * @param key \n * @param format \n */\n async exportJwk(key: CryptoKey): Promise<JsonWebKey> {\n return this.hasIECrypto() ? this.msCryptoExportJwk(key) : window.crypto.subtle.exportKey(KEY_FORMAT_JWK, key);\n }\n\n /**\n * Imports key as Json Web Key (JWK), can set extractable and usages.\n * @param key \n * @param format \n * @param extractable \n * @param usages \n */\n async importJwk(key: JsonWebKey, extractable: boolean, usages: Array<KeyUsage>): Promise<CryptoKey> {\n const keyString = BrowserCrypto.getJwkString(key);\n const keyBuffer = BrowserStringUtils.stringToArrayBuffer(keyString);\n\n return this.hasIECrypto() ? \n this.msCryptoImportKey(keyBuffer, extractable, usages) \n : window.crypto.subtle.importKey(KEY_FORMAT_JWK, key, this._keygenAlgorithmOptions, extractable, usages);\n }\n\n /**\n * Signs given data with given key\n * @param key \n * @param data \n */\n async sign(key: CryptoKey, data: ArrayBuffer): Promise<ArrayBuffer> {\n return this.hasIECrypto() ?\n this.msCryptoSign(key, data)\n : window.crypto.subtle.sign(this._keygenAlgorithmOptions, key, data);\n }\n\n /**\n * Check whether IE crypto or other browser cryptography is available.\n */\n private hasCryptoAPI(): boolean {\n return this.hasIECrypto() || this.hasBrowserCrypto();\n }\n\n /**\n * Checks whether IE crypto (AKA msCrypto) is available.\n */\n private hasIECrypto(): boolean {\n return \"msCrypto\" in window;\n }\n\n /**\n * Check whether browser crypto is available.\n */\n private hasBrowserCrypto(): boolean {\n return \"crypto\" in window;\n }\n\n /**\n * Helper function for SHA digest.\n * @param algorithm \n * @param data \n */\n private async getSubtleCryptoDigest(algorithm: string, data: Uint8Array): Promise<ArrayBuffer> {\n return window.crypto.subtle.digest(algorithm, data);\n }\n\n /**\n * IE Helper function for SHA digest.\n * @param algorithm \n * @param data \n */\n private async getMSCryptoDigest(algorithm: string, data: Uint8Array): Promise<ArrayBuffer> {\n return new Promise((resolve, reject) => {\n const digestOperation = window[\"msCrypto\"].subtle.digest(algorithm, data.buffer);\n digestOperation.addEventListener(\"complete\", (e: { target: { result: ArrayBuffer | PromiseLike<ArrayBuffer>; }; }) => {\n resolve(e.target.result);\n });\n digestOperation.addEventListener(\"error\", (error: string) => {\n reject(error);\n });\n });\n }\n\n /**\n * IE Helper function for generating a keypair\n * @param extractable \n * @param usages \n */\n private async msCryptoGenerateKey(extractable: boolean, usages: Array<KeyUsage>): Promise<CryptoKeyPair> {\n return new Promise((resolve: Function, reject: Function) => {\n const msGenerateKey = window[\"msCrypto\"].subtle.generateKey(this._keygenAlgorithmOptions, extractable, usages);\n msGenerateKey.addEventListener(\"complete\", (e: { target: { result: CryptoKeyPair | PromiseLike<CryptoKeyPair>; }; }) => {\n resolve(e.target.result);\n });\n\n msGenerateKey.addEventListener(\"error\", (error: string) => {\n reject(error);\n });\n });\n }\n\n /**\n * IE Helper function for exportKey\n * @param key \n * @param format \n */\n private async msCryptoExportJwk(key: CryptoKey): Promise<JsonWebKey> {\n return new Promise((resolve: Function, reject: Function) => {\n const msExportKey = window[\"msCrypto\"].subtle.exportKey(KEY_FORMAT_JWK, key);\n msExportKey.addEventListener(\"complete\", (e: { target: { result: ArrayBuffer; }; }) => {\n const resultBuffer: ArrayBuffer = e.target.result;\n\n const resultString = BrowserStringUtils.utf8ArrToString(new Uint8Array(resultBuffer))\n .replace(/\\r/g, Constants.EMPTY_STRING)\n .replace(/\\n/g, Constants.EMPTY_STRING)\n .replace(/\\t/g, Constants.EMPTY_STRING)\n .split(\" \").join(Constants.EMPTY_STRING)\n .replace(\"\\u0000\", Constants.EMPTY_STRING);\n\n try {\n resolve(JSON.parse(resultString));\n } catch (e) {\n reject(e);\n }\n });\n\n msExportKey.addEventListener(\"error\", (error: string) => {\n reject(error);\n });\n });\n }\n\n /**\n * IE Helper function for importKey\n * @param key \n * @param format \n * @param extractable \n * @param usages \n */\n private async msCryptoImportKey(keyBuffer: ArrayBuffer, extractable: boolean, usages: Array<KeyUsage>): Promise<CryptoKey> {\n return new Promise((resolve: Function, reject: Function) => {\n const msImportKey = window[\"msCrypto\"].subtle.importKey(KEY_FORMAT_JWK, keyBuffer, this._keygenAlgorithmOptions, extractable, usages);\n msImportKey.addEventListener(\"complete\", (e: { target: { result: CryptoKey | PromiseLike<CryptoKey>; }; }) => {\n resolve(e.target.result);\n });\n\n msImportKey.addEventListener(\"error\", (error: string) => {\n reject(error);\n });\n });\n }\n\n /**\n * IE Helper function for sign JWT\n * @param key \n * @param data \n */\n private async msCryptoSign(key: CryptoKey, data: ArrayBuffer): Promise<ArrayBuffer> {\n return new Promise((resolve: Function, reject: Function) => {\n const msSign = window[\"msCrypto\"].subtle.sign(this._keygenAlgorithmOptions, key, data);\n msSign.addEventListener(\"complete\", (e: { target: { result: ArrayBuffer | PromiseLike<ArrayBuffer>; }; }) => {\n resolve(e.target.result);\n });\n\n msSign.addEventListener(\"error\", (error: string) => {\n reject(error);\n });\n });\n }\n\n /**\n * Returns stringified jwk.\n * @param jwk \n */\n static getJwkString(jwk: JsonWebKey): string {\n return JSON.stringify(jwk, Object.keys(jwk).sort());\n }\n}\n"],"names":[],"mappings":";;;;;;;;AAAA;;;;AAUA;;;AAGA;AACA,IAAM,oBAAoB,GAAG,mBAAmB,CAAC;AACjD;AACA,IAAM,aAAa,GAAG,SAAS,CA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
1
|
+
import { ICrypto, IPerformanceClient, Logger, PkceCodes, SignedHttpRequest, SignedHttpRequestParameters } from "@azure/msal-common";
|
|
2
2
|
import { AsyncMemoryStorage } from "../cache/AsyncMemoryStorage";
|
|
3
3
|
export declare type CachedKeyPair = {
|
|
4
4
|
publicKey: CryptoKey;
|
|
@@ -13,6 +13,10 @@ export declare type CryptoKeyStore = {
|
|
|
13
13
|
asymmetricKeys: AsyncMemoryStorage<CachedKeyPair>;
|
|
14
14
|
symmetricKeys: AsyncMemoryStorage<CryptoKey>;
|
|
15
15
|
};
|
|
16
|
+
export declare enum CryptoKeyStoreNames {
|
|
17
|
+
asymmetricKeys = "asymmetricKeys",
|
|
18
|
+
symmetricKeys = "symmetricKeys"
|
|
19
|
+
}
|
|
16
20
|
/**
|
|
17
21
|
* This class implements MSAL's crypto interface, which allows it to perform base64 encoding and decoding, generating cryptographically random GUIDs and
|
|
18
22
|
* implementing Proof Key for Code Exchange specs for the OAuth Authorization Code Flow using PKCE (rfc here: https://tools.ietf.org/html/rfc7636).
|
|
@@ -24,10 +28,15 @@ export declare class CryptoOps implements ICrypto {
|
|
|
24
28
|
private b64Decode;
|
|
25
29
|
private pkceGenerator;
|
|
26
30
|
private logger;
|
|
31
|
+
/**
|
|
32
|
+
* CryptoOps can be used in contexts outside a PCA instance,
|
|
33
|
+
* meaning there won't be a performance manager available.
|
|
34
|
+
*/
|
|
35
|
+
private performanceClient;
|
|
27
36
|
private static POP_KEY_USAGES;
|
|
28
37
|
private static EXTRACTABLE;
|
|
29
38
|
private cache;
|
|
30
|
-
constructor(logger: Logger);
|
|
39
|
+
constructor(logger: Logger, performanceClient?: IPerformanceClient);
|
|
31
40
|
/**
|
|
32
41
|
* Creates a new random GUID - used to populate state and nonce.
|
|
33
42
|
* @returns string (GUID)
|
|
@@ -66,7 +75,7 @@ export declare class CryptoOps implements ICrypto {
|
|
|
66
75
|
* @param payload
|
|
67
76
|
* @param kid
|
|
68
77
|
*/
|
|
69
|
-
signJwt(payload: SignedHttpRequest, kid: string): Promise<string>;
|
|
78
|
+
signJwt(payload: SignedHttpRequest, kid: string, correlationId?: string): Promise<string>;
|
|
70
79
|
/**
|
|
71
80
|
* Returns the SHA-256 hash of an input string
|
|
72
81
|
* @param plainText
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CryptoOps.d.ts","sourceRoot":"","sources":["../../src/crypto/CryptoOps.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"CryptoOps.d.ts","sourceRoot":"","sources":["../../src/crypto/CryptoOps.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,OAAO,EAAE,kBAAkB,EAAE,MAAM,EAAqB,SAAS,EAAE,iBAAiB,EAAE,2BAA2B,EAAE,MAAM,oBAAoB,CAAC;AASvJ,OAAO,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AAEjE,oBAAY,aAAa,GAAG;IACxB,SAAS,EAAE,SAAS,CAAC;IACrB,UAAU,EAAE,SAAS,CAAC;IACtB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,UAAU,CAAC,EAAE,MAAM,CAAA;CACtB,CAAC;AAEF;;GAEG;AACH,oBAAY,cAAc,GAAG;IACzB,cAAc,EAAE,kBAAkB,CAAC,aAAa,CAAC,CAAC;IAClD,aAAa,EAAE,kBAAkB,CAAC,SAAS,CAAC,CAAC;CAChD,CAAC;AAEF,oBAAY,mBAAmB;IAC3B,cAAc,mBAAmB;IACjC,aAAa,kBAAkB;CAClC;AAED;;;GAGG;AACH,qBAAa,SAAU,YAAW,OAAO;IAErC,OAAO,CAAC,aAAa,CAAgB;IACrC,OAAO,CAAC,aAAa,CAAgB;IACrC,OAAO,CAAC,SAAS,CAAe;IAChC,OAAO,CAAC,SAAS,CAAe;IAChC,OAAO,CAAC,aAAa,CAAgB;IACrC,OAAO,CAAC,MAAM,CAAS;IAEvB;;;OAGG;IACH,OAAO,CAAC,iBAAiB,CAAiC;IAE1D,OAAO,CAAC,MAAM,CAAC,cAAc,CAAuC;IACpE,OAAO,CAAC,MAAM,CAAC,WAAW,CAAiB;IAC3C,OAAO,CAAC,KAAK,CAAiB;gBAElB,MAAM,EAAE,MAAM,EAAE,iBAAiB,CAAC,EAAE,kBAAkB;IAelE;;;OAGG;IACH,aAAa,IAAI,MAAM;IAIvB;;;OAGG;IACH,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM;IAInC;;;OAGG;IACH,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM;IAInC;;OAEG;IACG,iBAAiB,IAAI,OAAO,CAAC,SAAS,CAAC;IAI7C;;;OAGG;IACG,sBAAsB,CAAC,OAAO,EAAE,2BAA2B,GAAG,OAAO,CAAC,MAAM,CAAC;IA2CnF;;;OAGG;IACG,qBAAqB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAM1D;;OAEG;IACG,aAAa,IAAI,OAAO,CAAC,OAAO,CAAC;IAoBvC;;;;OAIG;IACG,OAAO,CAAC,OAAO,EAAE,iBAAiB,EAAE,GAAG,EAAE,MAAM,EAAE,aAAa,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IA4C/F;;;OAGG;IACG,UAAU,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;CAKvD"}
|
package/dist/crypto/CryptoOps.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
/*! @azure/msal-browser v2.
|
|
1
|
+
/*! @azure/msal-browser v2.23.0 2022-04-04 */
|
|
2
2
|
'use strict';
|
|
3
3
|
import { __awaiter, __generator } from '../_virtual/_tslib.js';
|
|
4
|
+
import { PerformanceEvents } from '@azure/msal-common';
|
|
4
5
|
import { GuidGenerator } from './GuidGenerator.js';
|
|
5
6
|
import { Base64Encode } from '../encode/Base64Encode.js';
|
|
6
7
|
import { Base64Decode } from '../encode/Base64Decode.js';
|
|
@@ -15,12 +16,17 @@ import { AsyncMemoryStorage } from '../cache/AsyncMemoryStorage.js';
|
|
|
15
16
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
16
17
|
* Licensed under the MIT License.
|
|
17
18
|
*/
|
|
19
|
+
var CryptoKeyStoreNames;
|
|
20
|
+
(function (CryptoKeyStoreNames) {
|
|
21
|
+
CryptoKeyStoreNames["asymmetricKeys"] = "asymmetricKeys";
|
|
22
|
+
CryptoKeyStoreNames["symmetricKeys"] = "symmetricKeys";
|
|
23
|
+
})(CryptoKeyStoreNames || (CryptoKeyStoreNames = {}));
|
|
18
24
|
/**
|
|
19
25
|
* This class implements MSAL's crypto interface, which allows it to perform base64 encoding and decoding, generating cryptographically random GUIDs and
|
|
20
26
|
* implementing Proof Key for Code Exchange specs for the OAuth Authorization Code Flow using PKCE (rfc here: https://tools.ietf.org/html/rfc7636).
|
|
21
27
|
*/
|
|
22
28
|
var CryptoOps = /** @class */ (function () {
|
|
23
|
-
function CryptoOps(logger) {
|
|
29
|
+
function CryptoOps(logger, performanceClient) {
|
|
24
30
|
this.logger = logger;
|
|
25
31
|
// Browser crypto needs to be validated first before any other classes can be set.
|
|
26
32
|
this.browserCrypto = new BrowserCrypto(this.logger);
|
|
@@ -29,9 +35,10 @@ var CryptoOps = /** @class */ (function () {
|
|
|
29
35
|
this.guidGenerator = new GuidGenerator(this.browserCrypto);
|
|
30
36
|
this.pkceGenerator = new PkceGenerator(this.browserCrypto);
|
|
31
37
|
this.cache = {
|
|
32
|
-
asymmetricKeys: new AsyncMemoryStorage(this.logger),
|
|
33
|
-
symmetricKeys: new AsyncMemoryStorage(this.logger)
|
|
38
|
+
asymmetricKeys: new AsyncMemoryStorage(this.logger, CryptoKeyStoreNames.asymmetricKeys),
|
|
39
|
+
symmetricKeys: new AsyncMemoryStorage(this.logger, CryptoKeyStoreNames.symmetricKeys)
|
|
34
40
|
};
|
|
41
|
+
this.performanceClient = performanceClient;
|
|
35
42
|
}
|
|
36
43
|
/**
|
|
37
44
|
* Creates a new random GUID - used to populate state and nonce.
|
|
@@ -69,16 +76,19 @@ var CryptoOps = /** @class */ (function () {
|
|
|
69
76
|
* @param request
|
|
70
77
|
*/
|
|
71
78
|
CryptoOps.prototype.getPublicKeyThumbprint = function (request) {
|
|
79
|
+
var _a;
|
|
72
80
|
return __awaiter(this, void 0, void 0, function () {
|
|
73
|
-
var keyPair, publicKeyJwk, pubKeyThumprintObj, publicJwkString, publicJwkHash, privateKeyJwk, unextractablePrivateKey;
|
|
74
|
-
return __generator(this, function (
|
|
75
|
-
switch (
|
|
76
|
-
case 0:
|
|
81
|
+
var publicKeyThumbMeasurement, keyPair, publicKeyJwk, pubKeyThumprintObj, publicJwkString, publicJwkHash, privateKeyJwk, unextractablePrivateKey;
|
|
82
|
+
return __generator(this, function (_b) {
|
|
83
|
+
switch (_b.label) {
|
|
84
|
+
case 0:
|
|
85
|
+
publicKeyThumbMeasurement = (_a = this.performanceClient) === null || _a === void 0 ? void 0 : _a.startMeasurement(PerformanceEvents.CryptoOptsGetPublicKeyThumbprint, request.correlationId);
|
|
86
|
+
return [4 /*yield*/, this.browserCrypto.generateKeyPair(CryptoOps.EXTRACTABLE, CryptoOps.POP_KEY_USAGES)];
|
|
77
87
|
case 1:
|
|
78
|
-
keyPair =
|
|
88
|
+
keyPair = _b.sent();
|
|
79
89
|
return [4 /*yield*/, this.browserCrypto.exportJwk(keyPair.publicKey)];
|
|
80
90
|
case 2:
|
|
81
|
-
publicKeyJwk =
|
|
91
|
+
publicKeyJwk = _b.sent();
|
|
82
92
|
pubKeyThumprintObj = {
|
|
83
93
|
e: publicKeyJwk.e,
|
|
84
94
|
kty: publicKeyJwk.kty,
|
|
@@ -87,13 +97,13 @@ var CryptoOps = /** @class */ (function () {
|
|
|
87
97
|
publicJwkString = BrowserCrypto.getJwkString(pubKeyThumprintObj);
|
|
88
98
|
return [4 /*yield*/, this.hashString(publicJwkString)];
|
|
89
99
|
case 3:
|
|
90
|
-
publicJwkHash =
|
|
100
|
+
publicJwkHash = _b.sent();
|
|
91
101
|
return [4 /*yield*/, this.browserCrypto.exportJwk(keyPair.privateKey)];
|
|
92
102
|
case 4:
|
|
93
|
-
privateKeyJwk =
|
|
103
|
+
privateKeyJwk = _b.sent();
|
|
94
104
|
return [4 /*yield*/, this.browserCrypto.importJwk(privateKeyJwk, false, ["sign"])];
|
|
95
105
|
case 5:
|
|
96
|
-
unextractablePrivateKey =
|
|
106
|
+
unextractablePrivateKey = _b.sent();
|
|
97
107
|
// Store Keypair data in keystore
|
|
98
108
|
return [4 /*yield*/, this.cache.asymmetricKeys.setItem(publicJwkHash, {
|
|
99
109
|
privateKey: unextractablePrivateKey,
|
|
@@ -103,7 +113,12 @@ var CryptoOps = /** @class */ (function () {
|
|
|
103
113
|
})];
|
|
104
114
|
case 6:
|
|
105
115
|
// Store Keypair data in keystore
|
|
106
|
-
|
|
116
|
+
_b.sent();
|
|
117
|
+
if (publicKeyThumbMeasurement) {
|
|
118
|
+
publicKeyThumbMeasurement.endMeasurement({
|
|
119
|
+
success: true
|
|
120
|
+
});
|
|
121
|
+
}
|
|
107
122
|
return [2 /*return*/, publicJwkHash];
|
|
108
123
|
}
|
|
109
124
|
});
|
|
@@ -134,21 +149,32 @@ var CryptoOps = /** @class */ (function () {
|
|
|
134
149
|
*/
|
|
135
150
|
CryptoOps.prototype.clearKeystore = function () {
|
|
136
151
|
return __awaiter(this, void 0, void 0, function () {
|
|
137
|
-
var
|
|
138
|
-
return __generator(this, function (
|
|
139
|
-
switch (
|
|
152
|
+
var e_1;
|
|
153
|
+
return __generator(this, function (_a) {
|
|
154
|
+
switch (_a.label) {
|
|
140
155
|
case 0:
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
return [4 /*yield*/, databaseStorage.deleteDatabase()];
|
|
156
|
+
_a.trys.push([0, 3, , 4]);
|
|
157
|
+
this.logger.verbose("Deleting in-memory and persistent asymmetric key stores");
|
|
158
|
+
return [4 /*yield*/, this.cache.asymmetricKeys.clear()];
|
|
145
159
|
case 1:
|
|
146
|
-
_a
|
|
147
|
-
|
|
160
|
+
_a.sent();
|
|
161
|
+
this.logger.verbose("Successfully deleted asymmetric key stores");
|
|
162
|
+
this.logger.verbose("Deleting in-memory and persistent symmetric key stores");
|
|
163
|
+
return [4 /*yield*/, this.cache.symmetricKeys.clear()];
|
|
148
164
|
case 2:
|
|
149
|
-
_a
|
|
150
|
-
|
|
151
|
-
|
|
165
|
+
_a.sent();
|
|
166
|
+
this.logger.verbose("Successfully deleted symmetric key stores");
|
|
167
|
+
return [2 /*return*/, true];
|
|
168
|
+
case 3:
|
|
169
|
+
e_1 = _a.sent();
|
|
170
|
+
if (e_1 instanceof Error) {
|
|
171
|
+
this.logger.error("Clearing keystore failed with error: " + e_1.message);
|
|
172
|
+
}
|
|
173
|
+
else {
|
|
174
|
+
this.logger.error("Clearing keystore failed with unknown error");
|
|
175
|
+
}
|
|
176
|
+
return [2 /*return*/, false];
|
|
177
|
+
case 4: return [2 /*return*/];
|
|
152
178
|
}
|
|
153
179
|
});
|
|
154
180
|
});
|
|
@@ -158,20 +184,23 @@ var CryptoOps = /** @class */ (function () {
|
|
|
158
184
|
* @param payload
|
|
159
185
|
* @param kid
|
|
160
186
|
*/
|
|
161
|
-
CryptoOps.prototype.signJwt = function (payload, kid) {
|
|
187
|
+
CryptoOps.prototype.signJwt = function (payload, kid, correlationId) {
|
|
188
|
+
var _a;
|
|
162
189
|
return __awaiter(this, void 0, void 0, function () {
|
|
163
|
-
var cachedKeyPair, publicKeyJwk, publicKeyJwkString, header, encodedHeader, encodedPayload, tokenString, tokenBuffer, signatureBuffer, encodedSignature;
|
|
164
|
-
return __generator(this, function (
|
|
165
|
-
switch (
|
|
166
|
-
case 0:
|
|
190
|
+
var signJwtMeasurement, cachedKeyPair, publicKeyJwk, publicKeyJwkString, header, encodedHeader, encodedPayload, tokenString, tokenBuffer, signatureBuffer, encodedSignature, signedJwt;
|
|
191
|
+
return __generator(this, function (_b) {
|
|
192
|
+
switch (_b.label) {
|
|
193
|
+
case 0:
|
|
194
|
+
signJwtMeasurement = (_a = this.performanceClient) === null || _a === void 0 ? void 0 : _a.startMeasurement(PerformanceEvents.CryptoOptsSignJwt, correlationId);
|
|
195
|
+
return [4 /*yield*/, this.cache.asymmetricKeys.getItem(kid)];
|
|
167
196
|
case 1:
|
|
168
|
-
cachedKeyPair =
|
|
197
|
+
cachedKeyPair = _b.sent();
|
|
169
198
|
if (!cachedKeyPair) {
|
|
170
199
|
throw BrowserAuthError.createSigningKeyNotFoundInStorageError(kid);
|
|
171
200
|
}
|
|
172
201
|
return [4 /*yield*/, this.browserCrypto.exportJwk(cachedKeyPair.publicKey)];
|
|
173
202
|
case 2:
|
|
174
|
-
publicKeyJwk =
|
|
203
|
+
publicKeyJwk = _b.sent();
|
|
175
204
|
publicKeyJwkString = BrowserCrypto.getJwkString(publicKeyJwk);
|
|
176
205
|
header = {
|
|
177
206
|
alg: publicKeyJwk.alg,
|
|
@@ -187,9 +216,15 @@ var CryptoOps = /** @class */ (function () {
|
|
|
187
216
|
tokenBuffer = BrowserStringUtils.stringToArrayBuffer(tokenString);
|
|
188
217
|
return [4 /*yield*/, this.browserCrypto.sign(cachedKeyPair.privateKey, tokenBuffer)];
|
|
189
218
|
case 3:
|
|
190
|
-
signatureBuffer =
|
|
219
|
+
signatureBuffer = _b.sent();
|
|
191
220
|
encodedSignature = this.b64Encode.urlEncodeArr(new Uint8Array(signatureBuffer));
|
|
192
|
-
|
|
221
|
+
signedJwt = tokenString + "." + encodedSignature;
|
|
222
|
+
if (signJwtMeasurement) {
|
|
223
|
+
signJwtMeasurement.endMeasurement({
|
|
224
|
+
success: true
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
return [2 /*return*/, signedJwt];
|
|
193
228
|
}
|
|
194
229
|
});
|
|
195
230
|
});
|
|
@@ -217,5 +252,5 @@ var CryptoOps = /** @class */ (function () {
|
|
|
217
252
|
return CryptoOps;
|
|
218
253
|
}());
|
|
219
254
|
|
|
220
|
-
export { CryptoOps };
|
|
255
|
+
export { CryptoKeyStoreNames, CryptoOps };
|
|
221
256
|
//# sourceMappingURL=CryptoOps.js.map
|