@azure/msal-browser 2.32.2 → 2.34.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.
Files changed (117) hide show
  1. package/README.md +1 -1
  2. package/dist/_virtual/_tslib.js +1 -1
  3. package/dist/app/ClientApplication.d.ts +3 -0
  4. package/dist/app/ClientApplication.d.ts.map +1 -1
  5. package/dist/app/ClientApplication.js +75 -26
  6. package/dist/app/ClientApplication.js.map +1 -1
  7. package/dist/app/IPublicClientApplication.js +1 -1
  8. package/dist/app/PublicClientApplication.d.ts +2 -0
  9. package/dist/app/PublicClientApplication.d.ts.map +1 -1
  10. package/dist/app/PublicClientApplication.js +37 -15
  11. package/dist/app/PublicClientApplication.js.map +1 -1
  12. package/dist/broker/nativeBroker/NativeMessageHandler.d.ts +10 -7
  13. package/dist/broker/nativeBroker/NativeMessageHandler.d.ts.map +1 -1
  14. package/dist/broker/nativeBroker/NativeMessageHandler.js +18 -8
  15. package/dist/broker/nativeBroker/NativeMessageHandler.js.map +1 -1
  16. package/dist/cache/AsyncMemoryStorage.js +1 -1
  17. package/dist/cache/BrowserCacheManager.js +1 -1
  18. package/dist/cache/BrowserStorage.js +1 -1
  19. package/dist/cache/CryptoKeyStore.js +1 -1
  20. package/dist/cache/DatabaseStorage.js +1 -1
  21. package/dist/cache/MemoryStorage.js +1 -1
  22. package/dist/cache/TokenCache.js +1 -1
  23. package/dist/config/Configuration.js +1 -1
  24. package/dist/crypto/BrowserCrypto.js +1 -1
  25. package/dist/crypto/CryptoOps.js +1 -1
  26. package/dist/crypto/GuidGenerator.js +1 -1
  27. package/dist/crypto/ModernBrowserCrypto.js +1 -1
  28. package/dist/crypto/MsBrowserCrypto.js +1 -1
  29. package/dist/crypto/MsrBrowserCrypto.js +1 -1
  30. package/dist/crypto/PkceGenerator.js +1 -1
  31. package/dist/crypto/SignedHttpRequest.js +1 -1
  32. package/dist/encode/Base64Decode.js +1 -1
  33. package/dist/encode/Base64Encode.js +1 -1
  34. package/dist/error/BrowserAuthError.d.ts +8 -0
  35. package/dist/error/BrowserAuthError.d.ts.map +1 -1
  36. package/dist/error/BrowserAuthError.js +11 -1
  37. package/dist/error/BrowserAuthError.js.map +1 -1
  38. package/dist/error/BrowserConfigurationAuthError.js +1 -1
  39. package/dist/error/NativeAuthError.js +1 -1
  40. package/dist/event/EventHandler.js +1 -1
  41. package/dist/event/EventMessage.js +1 -1
  42. package/dist/event/EventType.js +1 -1
  43. package/dist/index.cjs.js +1683 -979
  44. package/dist/index.cjs.js.map +1 -1
  45. package/dist/index.js +1 -1
  46. package/dist/interaction_client/BaseInteractionClient.d.ts.map +1 -1
  47. package/dist/interaction_client/BaseInteractionClient.js +3 -2
  48. package/dist/interaction_client/BaseInteractionClient.js.map +1 -1
  49. package/dist/interaction_client/HybridSpaAuthorizationCodeClient.js +1 -1
  50. package/dist/interaction_client/NativeInteractionClient.d.ts +66 -3
  51. package/dist/interaction_client/NativeInteractionClient.d.ts.map +1 -1
  52. package/dist/interaction_client/NativeInteractionClient.js +174 -68
  53. package/dist/interaction_client/NativeInteractionClient.js.map +1 -1
  54. package/dist/interaction_client/PopupClient.d.ts.map +1 -1
  55. package/dist/interaction_client/PopupClient.js +9 -2
  56. package/dist/interaction_client/PopupClient.js.map +1 -1
  57. package/dist/interaction_client/RedirectClient.d.ts.map +1 -1
  58. package/dist/interaction_client/RedirectClient.js +13 -5
  59. package/dist/interaction_client/RedirectClient.js.map +1 -1
  60. package/dist/interaction_client/SilentAuthCodeClient.d.ts.map +1 -1
  61. package/dist/interaction_client/SilentAuthCodeClient.js +7 -3
  62. package/dist/interaction_client/SilentAuthCodeClient.js.map +1 -1
  63. package/dist/interaction_client/SilentCacheClient.d.ts.map +1 -1
  64. package/dist/interaction_client/SilentCacheClient.js +7 -2
  65. package/dist/interaction_client/SilentCacheClient.js.map +1 -1
  66. package/dist/interaction_client/SilentIframeClient.d.ts.map +1 -1
  67. package/dist/interaction_client/SilentIframeClient.js +21 -4
  68. package/dist/interaction_client/SilentIframeClient.js.map +1 -1
  69. package/dist/interaction_client/SilentRefreshClient.d.ts.map +1 -1
  70. package/dist/interaction_client/SilentRefreshClient.js +9 -3
  71. package/dist/interaction_client/SilentRefreshClient.js.map +1 -1
  72. package/dist/interaction_client/StandardInteractionClient.d.ts.map +1 -1
  73. package/dist/interaction_client/StandardInteractionClient.js +16 -5
  74. package/dist/interaction_client/StandardInteractionClient.js.map +1 -1
  75. package/dist/interaction_handler/InteractionHandler.d.ts +3 -2
  76. package/dist/interaction_handler/InteractionHandler.d.ts.map +1 -1
  77. package/dist/interaction_handler/InteractionHandler.js +12 -4
  78. package/dist/interaction_handler/InteractionHandler.js.map +1 -1
  79. package/dist/interaction_handler/RedirectHandler.d.ts +2 -2
  80. package/dist/interaction_handler/RedirectHandler.d.ts.map +1 -1
  81. package/dist/interaction_handler/RedirectHandler.js +3 -3
  82. package/dist/interaction_handler/RedirectHandler.js.map +1 -1
  83. package/dist/interaction_handler/SilentHandler.d.ts +2 -2
  84. package/dist/interaction_handler/SilentHandler.d.ts.map +1 -1
  85. package/dist/interaction_handler/SilentHandler.js +13 -15
  86. package/dist/interaction_handler/SilentHandler.js.map +1 -1
  87. package/dist/internals.d.ts +5 -0
  88. package/dist/internals.d.ts.map +1 -1
  89. package/dist/internals.js +4 -1
  90. package/dist/internals.js.map +1 -1
  91. package/dist/navigation/NavigationClient.js +1 -1
  92. package/dist/network/FetchClient.js +1 -1
  93. package/dist/network/XhrClient.js +1 -1
  94. package/dist/packageMetadata.d.ts +1 -1
  95. package/dist/packageMetadata.js +2 -2
  96. package/dist/packageMetadata.js.map +1 -1
  97. package/dist/request/EndSessionPopupRequest.d.ts +1 -1
  98. package/dist/request/EndSessionPopupRequest.d.ts.map +1 -1
  99. package/dist/request/EndSessionRequest.d.ts +1 -1
  100. package/dist/request/EndSessionRequest.d.ts.map +1 -1
  101. package/dist/telemetry/BrowserPerformanceClient.d.ts +20 -1
  102. package/dist/telemetry/BrowserPerformanceClient.d.ts.map +1 -1
  103. package/dist/telemetry/BrowserPerformanceClient.js +80 -3
  104. package/dist/telemetry/BrowserPerformanceClient.js.map +1 -1
  105. package/dist/telemetry/BrowserPerformanceMeasurement.d.ts +14 -5
  106. package/dist/telemetry/BrowserPerformanceMeasurement.d.ts.map +1 -1
  107. package/dist/telemetry/BrowserPerformanceMeasurement.js +36 -4
  108. package/dist/telemetry/BrowserPerformanceMeasurement.js.map +1 -1
  109. package/dist/utils/BrowserConstants.js +1 -1
  110. package/dist/utils/BrowserProtocolUtils.js +1 -1
  111. package/dist/utils/BrowserStringUtils.js +1 -1
  112. package/dist/utils/BrowserUtils.js +1 -1
  113. package/dist/utils/MathUtils.js +1 -1
  114. package/lib/msal-browser.js +1683 -979
  115. package/lib/msal-browser.js.map +1 -1
  116. package/lib/msal-browser.min.js +43 -44
  117. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /*! @azure/msal-browser v2.32.2 2023-01-10 */
1
+ /*! @azure/msal-browser v2.34.0 2023-03-07 */
2
2
  'use strict';
3
3
  import * as internals from './internals.js';
4
4
  export { internals };
@@ -1 +1 @@
1
- {"version":3,"file":"BaseInteractionClient.d.ts","sourceRoot":"","sources":["../../src/interaction_client/BaseInteractionClient.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,EAAE,oBAAoB,EAAE,WAAW,EAAiB,eAAe,EAAmC,sBAAsB,EAAiE,SAAS,EAAsC,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AACnU,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AACnE,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAC7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AgB,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,CAAC;CAiBxF"}
@@ -1,7 +1,7 @@
1
- /*! @azure/msal-browser v2.32.2 2023-01-10 */
1
+ /*! @azure/msal-browser v2.34.0 2023-03-07 */
2
2
  'use strict';
3
3
  import { __awaiter, __generator, __spread, __assign } from '../_virtual/_tslib.js';
4
- import { AccountEntity, AuthenticationScheme, ClientConfigurationError, StringUtils, UrlString, ServerTelemetryManager, AuthorityFactory } from '@azure/msal-common';
4
+ import { AccountEntity, PerformanceEvents, AuthenticationScheme, ClientConfigurationError, StringUtils, UrlString, ServerTelemetryManager, AuthorityFactory } from '@azure/msal-common';
5
5
  import { version } from '../packageMetadata.js';
6
6
  import { BrowserConstants } from '../utils/BrowserConstants.js';
7
7
  import { BrowserUtils } from '../utils/BrowserUtils.js';
@@ -79,6 +79,7 @@ var BaseInteractionClient = /** @class */ (function () {
79
79
  return __generator(this, function (_b) {
80
80
  switch (_b.label) {
81
81
  case 0:
82
+ this.performanceClient.addQueueMeasurement(PerformanceEvents.InitializeBaseRequest, request.correlationId);
82
83
  this.logger.verbose("Initializing BaseAuthRequest");
83
84
  authority = request.authority || this.config.auth.authority;
84
85
  scopes = __spread(((request && request.scopes) || []));
@@ -1 +1 @@
1
- {"version":3,"file":"BaseInteractionClient.js","sources":["../../src/interaction_client/BaseInteractionClient.ts"],"sourcesContent":["/*\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ICrypto, INetworkModule, Logger, AuthenticationResult, AccountInfo, AccountEntity, BaseAuthRequest, AuthenticationScheme, UrlString, ServerTelemetryManager, ServerTelemetryRequest, ClientConfigurationError, StringUtils, Authority, AuthorityOptions, AuthorityFactory, IPerformanceClient } from \"@azure/msal-common\";\nimport { BrowserConfiguration } from \"../config/Configuration\";\nimport { BrowserCacheManager } from \"../cache/BrowserCacheManager\";\nimport { EventHandler } from \"../event/EventHandler\";\nimport { EndSessionRequest } from \"../request/EndSessionRequest\";\nimport { RedirectRequest } from \"../request/RedirectRequest\";\nimport { PopupRequest } from \"../request/PopupRequest\";\nimport { SsoSilentRequest } from \"../request/SsoSilentRequest\";\nimport { version } from \"../packageMetadata\";\nimport { BrowserConstants } from \"../utils/BrowserConstants\";\nimport { BrowserUtils } from \"../utils/BrowserUtils\";\nimport { INavigationClient } from \"../navigation/INavigationClient\";\nimport { NativeMessageHandler } from \"../broker/nativeBroker/NativeMessageHandler\";\n\nexport abstract class BaseInteractionClient {\n\n protected config: BrowserConfiguration;\n protected browserStorage: BrowserCacheManager;\n protected browserCrypto: ICrypto;\n protected networkClient: INetworkModule;\n protected logger: Logger;\n protected eventHandler: EventHandler;\n protected navigationClient: INavigationClient;\n protected nativeMessageHandler: NativeMessageHandler | undefined;\n protected correlationId: string;\n protected performanceClient: IPerformanceClient;\n\n constructor(config: BrowserConfiguration, storageImpl: BrowserCacheManager, browserCrypto: ICrypto, logger: Logger, eventHandler: EventHandler, navigationClient: INavigationClient, performanceClient: IPerformanceClient, nativeMessageHandler?: NativeMessageHandler, correlationId?: string) {\n this.config = config;\n this.browserStorage = storageImpl;\n this.browserCrypto = browserCrypto;\n this.networkClient = this.config.system.networkClient;\n this.eventHandler = eventHandler;\n this.navigationClient = navigationClient;\n this.nativeMessageHandler = nativeMessageHandler;\n this.correlationId = correlationId || this.browserCrypto.createNewGuid();\n this.logger = logger.clone(BrowserConstants.MSAL_SKU, version, this.correlationId);\n this.performanceClient = performanceClient;\n }\n\n abstract acquireToken(request: RedirectRequest|PopupRequest|SsoSilentRequest): Promise<AuthenticationResult|void>;\n\n abstract logout(request: EndSessionRequest): Promise<void>;\n\n protected async clearCacheOnLogout(account?: AccountInfo| null): Promise<void> {\n if (account) {\n if (AccountEntity.accountInfoIsEqual(account, this.browserStorage.getActiveAccount(), false)) {\n this.logger.verbose(\"Setting active account to null\");\n this.browserStorage.setActiveAccount(null);\n }\n // Clear given account.\n try {\n await this.browserStorage.removeAccount(AccountEntity.generateAccountCacheKey(account));\n this.logger.verbose(\"Cleared cache items belonging to the account provided in the logout request.\");\n } catch (error) {\n this.logger.error(\"Account provided in logout request was not found. Local cache unchanged.\");\n }\n } else {\n try {\n this.logger.verbose(\"No account provided in logout request, clearing all cache items.\", this.correlationId);\n // Clear all accounts and tokens\n await this.browserStorage.clear();\n // Clear any stray keys from IndexedDB\n await this.browserCrypto.clearKeystore();\n } catch(e) {\n this.logger.error(\"Attempted to clear all MSAL cache items and failed. Local cache unchanged.\");\n }\n }\n }\n\n /**\n * Initializer function for all request APIs\n * @param request\n */\n protected async initializeBaseRequest(request: Partial<BaseAuthRequest>): Promise<BaseAuthRequest> {\n this.logger.verbose(\"Initializing BaseAuthRequest\");\n const authority = request.authority || this.config.auth.authority;\n\n const scopes = [...((request && request.scopes) || [])];\n\n const validatedRequest: BaseAuthRequest = {\n ...request,\n correlationId: this.correlationId,\n authority,\n scopes\n };\n\n // Set authenticationScheme to BEARER if not explicitly set in the request\n if (!validatedRequest.authenticationScheme) {\n validatedRequest.authenticationScheme = AuthenticationScheme.BEARER;\n this.logger.verbose(\"Authentication Scheme wasn't explicitly set in request, defaulting to \\\"Bearer\\\" request\");\n } else {\n if (validatedRequest.authenticationScheme === AuthenticationScheme.SSH) {\n if (!request.sshJwk) {\n throw ClientConfigurationError.createMissingSshJwkError();\n }\n if(!request.sshKid) {\n throw ClientConfigurationError.createMissingSshKidError();\n }\n }\n this.logger.verbose(`Authentication Scheme set to \"${validatedRequest.authenticationScheme}\" as configured in Auth request`);\n }\n\n // Set requested claims hash if claims were requested\n if (request.claims && !StringUtils.isEmpty(request.claims)) {\n validatedRequest.requestedClaimsHash = await this.browserCrypto.hashString(request.claims);\n }\n\n return validatedRequest;\n }\n\n /**\n *\n * Use to get the redirect uri configured in MSAL or null.\n * @param requestRedirectUri\n * @returns Redirect URL\n *\n */\n getRedirectUri(requestRedirectUri?: string): string {\n this.logger.verbose(\"getRedirectUri called\");\n const redirectUri = requestRedirectUri || this.config.auth.redirectUri || BrowserUtils.getCurrentUri();\n return UrlString.getAbsoluteUrl(redirectUri, BrowserUtils.getCurrentUri());\n }\n\n /**\n *\n * @param apiId\n * @param correlationId\n * @param forceRefresh\n */\n protected initializeServerTelemetryManager(apiId: number, forceRefresh?: boolean): ServerTelemetryManager {\n this.logger.verbose(\"initializeServerTelemetryManager called\");\n const telemetryPayload: ServerTelemetryRequest = {\n clientId: this.config.auth.clientId,\n correlationId: this.correlationId,\n apiId: apiId,\n forceRefresh: forceRefresh || false,\n wrapperSKU: this.browserStorage.getWrapperMetadata()[0],\n wrapperVer: this.browserStorage.getWrapperMetadata()[1]\n };\n\n return new ServerTelemetryManager(telemetryPayload, this.browserStorage);\n }\n\n /**\n * Used to get a discovered version of the default authority.\n * @param requestAuthority\n * @param requestCorrelationId\n */\n protected async getDiscoveredAuthority(requestAuthority?: string): Promise<Authority> {\n this.logger.verbose(\"getDiscoveredAuthority called\");\n const authorityOptions: AuthorityOptions = {\n protocolMode: this.config.auth.protocolMode,\n knownAuthorities: this.config.auth.knownAuthorities,\n cloudDiscoveryMetadata: this.config.auth.cloudDiscoveryMetadata,\n authorityMetadata: this.config.auth.authorityMetadata\n };\n\n if (requestAuthority) {\n this.logger.verbose(\"Creating discovered authority with request authority\");\n return await AuthorityFactory.createDiscoveredInstance(requestAuthority, this.config.system.networkClient, this.browserStorage, authorityOptions, this.logger);\n }\n\n this.logger.verbose(\"Creating discovered authority with configured authority\");\n return await AuthorityFactory.createDiscoveredInstance(this.config.auth.authority, this.config.system.networkClient, this.browserStorage, authorityOptions, this.logger);\n }\n}\n"],"names":[],"mappings":";;;;;;;;AAAA;;;;;IAgCI,+BAAY,MAA4B,EAAE,WAAgC,EAAE,aAAsB,EAAE,MAAc,EAAE,YAA0B,EAAE,gBAAmC,EAAE,iBAAqC,EAAE,oBAA2C,EAAE,aAAsB;QAC3R,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,cAAc,GAAG,WAAW,CAAC;QAClC,I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4BACvC,YAAY,EAAE,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,YAAY;4BAC3C,gBAAgB,EAAE,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,gBAAgB;4BACnD,sBAAsB,EAAE,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,sBAAsB;4BAC/D,iBAAiB,EAAE,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,iBAAiB;yBACxD,CAAC;6BAEE,gBAAgB,EAAhB,wBAAgB;wBAChB,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,sDAAsD,CAAC,CAAC;wBACrE,qBAAM,gBAAgB,CAAC,wBAAwB,CAAC,gBAAgB,EAAE,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,aAAa,EAAE,IAAI,CAAC,cAAc,EAAE,gBAAgB,EAAE,IAAI,CAAC,MAAM,CAAC,EAAA;4BAA9J,sBAAO,SAAuJ,EAAC;;wBAGnK,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,yDAAyD,CAAC,CAAC;wBACxE,qBAAM,gBAAgB,CAAC,wBAAwB,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,aAAa,EAAE,IAAI,CAAC,cAAc,EAAE,gBAAgB,EAAE,IAAI,CAAC,MAAM,CAAC,EAAA;4BAAxK,sBAAO,SAAiK,EAAC;;;;KAC5K;IACL,4BAAC;AAAD,CAAC;;;;"}
1
+ {"version":3,"file":"BaseInteractionClient.js","sources":["../../src/interaction_client/BaseInteractionClient.ts"],"sourcesContent":["/*\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ICrypto, INetworkModule, Logger, AuthenticationResult, AccountInfo, AccountEntity, BaseAuthRequest, AuthenticationScheme, UrlString, ServerTelemetryManager, ServerTelemetryRequest, ClientConfigurationError, StringUtils, Authority, AuthorityOptions, AuthorityFactory, IPerformanceClient, PerformanceEvents } from \"@azure/msal-common\";\nimport { BrowserConfiguration } from \"../config/Configuration\";\nimport { BrowserCacheManager } from \"../cache/BrowserCacheManager\";\nimport { EventHandler } from \"../event/EventHandler\";\nimport { EndSessionRequest } from \"../request/EndSessionRequest\";\nimport { RedirectRequest } from \"../request/RedirectRequest\";\nimport { PopupRequest } from \"../request/PopupRequest\";\nimport { SsoSilentRequest } from \"../request/SsoSilentRequest\";\nimport { version } from \"../packageMetadata\";\nimport { BrowserConstants } from \"../utils/BrowserConstants\";\nimport { BrowserUtils } from \"../utils/BrowserUtils\";\nimport { INavigationClient } from \"../navigation/INavigationClient\";\nimport { NativeMessageHandler } from \"../broker/nativeBroker/NativeMessageHandler\";\n\nexport abstract class BaseInteractionClient {\n\n protected config: BrowserConfiguration;\n protected browserStorage: BrowserCacheManager;\n protected browserCrypto: ICrypto;\n protected networkClient: INetworkModule;\n protected logger: Logger;\n protected eventHandler: EventHandler;\n protected navigationClient: INavigationClient;\n protected nativeMessageHandler: NativeMessageHandler | undefined;\n protected correlationId: string;\n protected performanceClient: IPerformanceClient;\n\n constructor(config: BrowserConfiguration, storageImpl: BrowserCacheManager, browserCrypto: ICrypto, logger: Logger, eventHandler: EventHandler, navigationClient: INavigationClient, performanceClient: IPerformanceClient, nativeMessageHandler?: NativeMessageHandler, correlationId?: string) {\n this.config = config;\n this.browserStorage = storageImpl;\n this.browserCrypto = browserCrypto;\n this.networkClient = this.config.system.networkClient;\n this.eventHandler = eventHandler;\n this.navigationClient = navigationClient;\n this.nativeMessageHandler = nativeMessageHandler;\n this.correlationId = correlationId || this.browserCrypto.createNewGuid();\n this.logger = logger.clone(BrowserConstants.MSAL_SKU, version, this.correlationId);\n this.performanceClient = performanceClient;\n }\n\n abstract acquireToken(request: RedirectRequest|PopupRequest|SsoSilentRequest): Promise<AuthenticationResult|void>;\n\n abstract logout(request: EndSessionRequest): Promise<void>;\n\n protected async clearCacheOnLogout(account?: AccountInfo| null): Promise<void> {\n if (account) {\n if (AccountEntity.accountInfoIsEqual(account, this.browserStorage.getActiveAccount(), false)) {\n this.logger.verbose(\"Setting active account to null\");\n this.browserStorage.setActiveAccount(null);\n }\n // Clear given account.\n try {\n await this.browserStorage.removeAccount(AccountEntity.generateAccountCacheKey(account));\n this.logger.verbose(\"Cleared cache items belonging to the account provided in the logout request.\");\n } catch (error) {\n this.logger.error(\"Account provided in logout request was not found. Local cache unchanged.\");\n }\n } else {\n try {\n this.logger.verbose(\"No account provided in logout request, clearing all cache items.\", this.correlationId);\n // Clear all accounts and tokens\n await this.browserStorage.clear();\n // Clear any stray keys from IndexedDB\n await this.browserCrypto.clearKeystore();\n } catch(e) {\n this.logger.error(\"Attempted to clear all MSAL cache items and failed. Local cache unchanged.\");\n }\n }\n }\n\n /**\n * Initializer function for all request APIs\n * @param request\n */\n protected async initializeBaseRequest(request: Partial<BaseAuthRequest>): Promise<BaseAuthRequest> {\n this.performanceClient.addQueueMeasurement(PerformanceEvents.InitializeBaseRequest, request.correlationId);\n this.logger.verbose(\"Initializing BaseAuthRequest\");\n const authority = request.authority || this.config.auth.authority;\n\n const scopes = [...((request && request.scopes) || [])];\n\n const validatedRequest: BaseAuthRequest = {\n ...request,\n correlationId: this.correlationId,\n authority,\n scopes\n };\n\n // Set authenticationScheme to BEARER if not explicitly set in the request\n if (!validatedRequest.authenticationScheme) {\n validatedRequest.authenticationScheme = AuthenticationScheme.BEARER;\n this.logger.verbose(\"Authentication Scheme wasn't explicitly set in request, defaulting to \\\"Bearer\\\" request\");\n } else {\n if (validatedRequest.authenticationScheme === AuthenticationScheme.SSH) {\n if (!request.sshJwk) {\n throw ClientConfigurationError.createMissingSshJwkError();\n }\n if(!request.sshKid) {\n throw ClientConfigurationError.createMissingSshKidError();\n }\n }\n this.logger.verbose(`Authentication Scheme set to \"${validatedRequest.authenticationScheme}\" as configured in Auth request`);\n }\n\n // Set requested claims hash if claims were requested\n if (request.claims && !StringUtils.isEmpty(request.claims)) {\n validatedRequest.requestedClaimsHash = await this.browserCrypto.hashString(request.claims);\n }\n\n return validatedRequest;\n }\n\n /**\n *\n * Use to get the redirect uri configured in MSAL or null.\n * @param requestRedirectUri\n * @returns Redirect URL\n *\n */\n getRedirectUri(requestRedirectUri?: string): string {\n this.logger.verbose(\"getRedirectUri called\");\n const redirectUri = requestRedirectUri || this.config.auth.redirectUri || BrowserUtils.getCurrentUri();\n return UrlString.getAbsoluteUrl(redirectUri, BrowserUtils.getCurrentUri());\n }\n\n /**\n *\n * @param apiId\n * @param correlationId\n * @param forceRefresh\n */\n protected initializeServerTelemetryManager(apiId: number, forceRefresh?: boolean): ServerTelemetryManager {\n this.logger.verbose(\"initializeServerTelemetryManager called\");\n const telemetryPayload: ServerTelemetryRequest = {\n clientId: this.config.auth.clientId,\n correlationId: this.correlationId,\n apiId: apiId,\n forceRefresh: forceRefresh || false,\n wrapperSKU: this.browserStorage.getWrapperMetadata()[0],\n wrapperVer: this.browserStorage.getWrapperMetadata()[1]\n };\n\n return new ServerTelemetryManager(telemetryPayload, this.browserStorage);\n }\n\n /**\n * Used to get a discovered version of the default authority.\n * @param requestAuthority\n * @param requestCorrelationId\n */\n protected async getDiscoveredAuthority(requestAuthority?: string): Promise<Authority> {\n this.logger.verbose(\"getDiscoveredAuthority called\");\n const authorityOptions: AuthorityOptions = {\n protocolMode: this.config.auth.protocolMode,\n knownAuthorities: this.config.auth.knownAuthorities,\n cloudDiscoveryMetadata: this.config.auth.cloudDiscoveryMetadata,\n authorityMetadata: this.config.auth.authorityMetadata\n };\n\n if (requestAuthority) {\n this.logger.verbose(\"Creating discovered authority with request authority\");\n return await AuthorityFactory.createDiscoveredInstance(requestAuthority, this.config.system.networkClient, this.browserStorage, authorityOptions, this.logger);\n }\n\n this.logger.verbose(\"Creating discovered authority with configured authority\");\n return await AuthorityFactory.createDiscoveredInstance(this.config.auth.authority, this.config.system.networkClient, this.browserStorage, authorityOptions, this.logger);\n }\n}\n"],"names":[],"mappings":";;;;;;;;AAAA;;;;;IAgCI,+BAAY,MAA4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@@ -1,4 +1,4 @@
1
- /*! @azure/msal-browser v2.32.2 2023-01-10 */
1
+ /*! @azure/msal-browser v2.34.0 2023-03-07 */
2
2
  'use strict';
3
3
  import { __extends } from '../_virtual/_tslib.js';
4
4
  import { AuthorizationCodeClient } from '@azure/msal-common';
@@ -1,4 +1,4 @@
1
- import { AuthenticationResult, Logger, ICrypto, IPerformanceClient } from "@azure/msal-common";
1
+ import { AuthenticationResult, Logger, ICrypto, AuthToken, AccountEntity, ScopeSet, IPerformanceClient } from "@azure/msal-common";
2
2
  import { BaseInteractionClient } from "./BaseInteractionClient";
3
3
  import { BrowserConfiguration } from "../config/Configuration";
4
4
  import { BrowserCacheManager } from "../cache/BrowserCacheManager";
@@ -9,7 +9,7 @@ import { SsoSilentRequest } from "../request/SsoSilentRequest";
9
9
  import { NativeMessageHandler } from "../broker/nativeBroker/NativeMessageHandler";
10
10
  import { ApiId } from "../utils/BrowserConstants";
11
11
  import { NativeTokenRequest } from "../broker/nativeBroker/NativeRequest";
12
- import { NativeResponse } from "../broker/nativeBroker/NativeResponse";
12
+ import { MATS, NativeResponse } from "../broker/nativeBroker/NativeResponse";
13
13
  import { RedirectRequest } from "../request/RedirectRequest";
14
14
  import { INavigationClient } from "../navigation/INavigationClient";
15
15
  import { SilentCacheClient } from "./SilentCacheClient";
@@ -60,6 +60,69 @@ export declare class NativeInteractionClient extends BaseInteractionClient {
60
60
  * @param reqTimestamp
61
61
  */
62
62
  protected handleNativeResponse(response: NativeResponse, request: NativeTokenRequest, reqTimestamp: number): Promise<AuthenticationResult>;
63
+ /**
64
+ * Create an idToken Object (not entity)
65
+ * @param response
66
+ * @returns
67
+ */
68
+ protected createIdTokenObj(response: NativeResponse): AuthToken;
69
+ /**
70
+ * creates an homeAccountIdentifier for the account
71
+ * @param response
72
+ * @param idTokenObj
73
+ * @returns
74
+ */
75
+ protected createHomeAccountIdentifier(response: NativeResponse, idTokenObj: AuthToken): string;
76
+ /**
77
+ * Creates account entity
78
+ * @param response
79
+ * @param homeAccountIdentifier
80
+ * @param idTokenObj
81
+ * @param authority
82
+ * @returns
83
+ */
84
+ protected createAccountEntity(response: NativeResponse, homeAccountIdentifier: string, idTokenObj: AuthToken, authority: string): AccountEntity;
85
+ /**
86
+ * Helper to generate scopes
87
+ * @param response
88
+ * @param request
89
+ * @returns
90
+ */
91
+ generateScopes(response: NativeResponse, request: NativeTokenRequest): ScopeSet;
92
+ /**
93
+ * If PoP token is requesred, records the PoP token if returned from the WAM, else generates one in the browser
94
+ * @param request
95
+ * @param response
96
+ */
97
+ generatePopAccessToken(response: NativeResponse, request: NativeTokenRequest): Promise<string>;
98
+ /**
99
+ * Generates authentication result
100
+ * @param response
101
+ * @param request
102
+ * @param idTokenObj
103
+ * @param accountEntity
104
+ * @param authority
105
+ * @param reqTimestamp
106
+ * @returns
107
+ */
108
+ protected generateAuthenticationResult(response: NativeResponse, request: NativeTokenRequest, idTokenObj: AuthToken, accountEntity: AccountEntity, authority: string, reqTimestamp: number): Promise<AuthenticationResult>;
109
+ /**
110
+ * cache the account entity in browser storage
111
+ * @param accountEntity
112
+ */
113
+ cacheAccount(accountEntity: AccountEntity): void;
114
+ /**
115
+ * Stores the access_token and id_token in inmemory storage
116
+ * @param response
117
+ * @param request
118
+ * @param homeAccountIdentifier
119
+ * @param idTokenObj
120
+ * @param responseAccessToken
121
+ * @param tenantId
122
+ * @param reqTimestamp
123
+ */
124
+ cacheNativeTokens(response: NativeResponse, request: NativeTokenRequest, homeAccountIdentifier: string, idTokenObj: AuthToken, responseAccessToken: string, tenantId: string, reqTimestamp: number): void;
125
+ protected addTelemetryFromNativeResponse(response: NativeResponse): MATS | null;
63
126
  /**
64
127
  * Validates native platform response before processing
65
128
  * @param response
@@ -76,7 +139,7 @@ export declare class NativeInteractionClient extends BaseInteractionClient {
76
139
  * @param response
77
140
  * @returns
78
141
  */
79
- private isResponseFromCache;
142
+ protected isResponseFromCache(mats: MATS): boolean;
80
143
  /**
81
144
  * Translates developer provided request object into NativeRequest object
82
145
  * @param request
@@ -1 +1 @@
1
- {"version":3,"file":"NativeInteractionClient.d.ts","sourceRoot":"","sources":["../../src/interaction_client/NativeInteractionClient.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,oBAAoB,EAAE,MAAM,EAAE,OAAO,EAA8L,kBAAkB,EAAyH,MAAM,oBAAoB,CAAC;AAClZ,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AACnE,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EAAE,oBAAoB,EAAE,MAAM,6CAA6C,CAAC;AACnF,OAAO,EAAyB,KAAK,EAAuC,MAAM,2BAA2B,CAAC;AAC9G,OAAO,EAA8B,kBAAkB,EAAE,MAAM,sCAAsC,CAAC;AACtG,OAAO,EAAQ,cAAc,EAAE,MAAM,uCAAuC,CAAC;AAE7E,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAE7D,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AAEpE,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAExD,qBAAa,uBAAwB,SAAQ,qBAAqB;IAC9D,SAAS,CAAC,KAAK,EAAE,KAAK,CAAC;IACvB,SAAS,CAAC,SAAS,EAAE,MAAM,CAAC;IAC5B,SAAS,CAAC,oBAAoB,EAAE,oBAAoB,CAAC;IACrD,SAAS,CAAC,iBAAiB,EAAE,iBAAiB,CAAC;IAC/C,SAAS,CAAC,oBAAoB,EAAE,mBAAmB,CAAC;gBAExC,MA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;IAK/I;;;;;OAKG;IACH,cAAc,CAAC,QAAQ,EAAE,cAAc,EAAE,OAAO,EAAE,kBAAkB,GAAG,QAAQ;IAI/E;;;;OAIG;IACG,sBAAsB,CAAC,QAAQ,EAAE,cAAc,EAAE,OAAO,EAAE,kBAAkB,GAAG,OAAO,CAAC,MAAM,CAAC;IAoCpG;;;;;;;;;OASG;cACa,4BAA4B,CAAC,QAAQ,EAAE,cAAc,EAAE,OAAO,EAAE,kBAAkB,EAAE,UAAU,EAAE,SAAS,EAAE,aAAa,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAoChO;;;OAGG;IACH,YAAY,CAAC,aAAa,EAAE,aAAa,GAAG,IAAI;IAUhD;;;;;;;;;OASG;IACH,iBAAiB,CAAC,QAAQ,EAAE,cAAc,EAAE,OAAO,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,MAAM,EAAE,UAAU,EAAE,SAAS,EAAE,mBAAmB,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,IAAI;IAoCzM,SAAS,CAAC,8BAA8B,CAAC,QAAQ,EAAE,cAAc,GAAG,IAAI,GAAG,IAAI;IA6B/E;;;OAGG;IACH,OAAO,CAAC,sBAAsB;IAe9B;;;;OAIG;IACH,OAAO,CAAC,mBAAmB;IAY3B;;;;OAIG;IACH,SAAS,CAAC,mBAAmB,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO;IASlD;;;OAGG;cACa,uBAAuB,CAAC,OAAO,EAAE,YAAY,GAAC,gBAAgB,GAAG,OAAO,CAAC,kBAAkB,CAAC;CAiF/G"}
@@ -1,7 +1,7 @@
1
- /*! @azure/msal-browser v2.32.2 2023-01-10 */
1
+ /*! @azure/msal-browser v2.34.0 2023-03-07 */
2
2
  'use strict';
3
3
  import { __extends, __awaiter, __generator, __rest, __assign } from '../_virtual/_tslib.js';
4
- import { PerformanceEvents, TimeUtils, ScopeSet, ClientAuthError, IdTokenEntity, Constants, AccessTokenEntity, AuthenticationScheme, PopTokenGenerator, AccountEntity, AuthorityType, AuthToken, UrlString, OIDC_DEFAULT_SCOPES, PromptValue } from '@azure/msal-common';
4
+ import { ScopeSet, AuthToken, Constants, AccountEntity, AuthorityType, IdTokenEntity, AccessTokenEntity, PerformanceEvents, TimeUtils, ClientAuthError, AuthenticationScheme, PopTokenGenerator, UrlString, OIDC_DEFAULT_SCOPES, PromptValue } from '@azure/msal-common';
5
5
  import { BaseInteractionClient } from './BaseInteractionClient.js';
6
6
  import { TemporaryCacheKeys, NativeExtensionMethod, NativeConstants, ApiId } from '../utils/BrowserConstants.js';
7
7
  import { NativeAuthError } from '../error/NativeAuthError.js';
@@ -249,60 +249,96 @@ var NativeInteractionClient = /** @class */ (function (_super) {
249
249
  */
250
250
  NativeInteractionClient.prototype.handleNativeResponse = function (response, request, reqTimestamp) {
251
251
  return __awaiter(this, void 0, void 0, function () {
252
- var mats, idTokenObj, authority, authorityPreferredCache, homeAccountIdentifier, accountEntity, responseScopes, accountProperties, uid, tid, responseAccessToken, responseTokenType, _a, popTokenGenerator, shrParameters, result, idTokenEntity, expiresIn, tokenExpirationSeconds, accessTokenEntity;
253
- var _this = this;
254
- return __generator(this, function (_b) {
255
- switch (_b.label) {
252
+ var authority, authorityPreferredCache, idTokenObj, homeAccountIdentifier, accountEntity, result;
253
+ return __generator(this, function (_a) {
254
+ switch (_a.label) {
256
255
  case 0:
257
256
  this.logger.trace("NativeInteractionClient - handleNativeResponse called.");
258
- mats = this.getMATSFromResponse(response);
259
- this.performanceClient.addStaticFields({
260
- extensionId: this.nativeMessageHandler.getExtensionId(),
261
- extensionVersion: this.nativeMessageHandler.getExtensionVersion(),
262
- matsBrokerVersion: mats ? mats.broker_version : undefined,
263
- matsAccountJoinOnStart: mats ? mats.account_join_on_start : undefined,
264
- matsAccountJoinOnEnd: mats ? mats.account_join_on_end : undefined,
265
- matsDeviceJoin: mats ? mats.device_join : undefined,
266
- matsPromptBehavior: mats ? mats.prompt_behavior : undefined,
267
- matsApiErrorCode: mats ? mats.api_error_code : undefined,
268
- matsUiVisible: mats ? mats.ui_visible : undefined,
269
- matsSilentCode: mats ? mats.silent_code : undefined,
270
- matsSilentBiSubCode: mats ? mats.silent_bi_sub_code : undefined,
271
- matsSilentMessage: mats ? mats.silent_message : undefined,
272
- matsSilentStatus: mats ? mats.silent_status : undefined,
273
- matsHttpStatus: mats ? mats.http_status : undefined,
274
- matsHttpEventCount: mats ? mats.http_event_count : undefined
275
- }, this.correlationId);
276
257
  if (response.account.id !== request.accountId) {
277
258
  // User switch in native broker prompt is not supported. All users must first sign in through web flow to ensure server state is in sync
278
259
  throw NativeAuthError.createUserSwitchError();
279
260
  }
280
- idTokenObj = new AuthToken(response.id_token || Constants.EMPTY_STRING, this.browserCrypto);
261
+ if (response.account.id !== request.accountId) {
262
+ // User switch in native broker prompt is not supported. All users must first sign in through web flow to ensure server state is in sync
263
+ throw NativeAuthError.createUserSwitchError();
264
+ }
281
265
  return [4 /*yield*/, this.getDiscoveredAuthority(request.authority)];
282
266
  case 1:
283
- authority = _b.sent();
267
+ authority = _a.sent();
284
268
  authorityPreferredCache = authority.getPreferredCache();
285
- homeAccountIdentifier = AccountEntity.generateHomeAccountId(response.client_info || Constants.EMPTY_STRING, AuthorityType.Default, this.logger, this.browserCrypto, idTokenObj);
286
- accountEntity = AccountEntity.createAccount(response.client_info, homeAccountIdentifier, idTokenObj, undefined, undefined, undefined, authorityPreferredCache, response.account.id);
287
- this.browserStorage.setAccount(accountEntity);
288
- responseScopes = response.scope ? ScopeSet.fromString(response.scope) : ScopeSet.fromString(request.scope);
289
- accountProperties = response.account.properties || {};
290
- uid = accountProperties["UID"] || idTokenObj.claims.oid || idTokenObj.claims.sub || Constants.EMPTY_STRING;
291
- tid = accountProperties["TenantId"] || idTokenObj.claims.tid || Constants.EMPTY_STRING;
292
- responseTokenType = AuthenticationScheme.BEARER;
293
- _a = request.tokenType;
294
- switch (_a) {
295
- case AuthenticationScheme.POP: return [3 /*break*/, 2];
296
- }
297
- return [3 /*break*/, 4];
269
+ idTokenObj = this.createIdTokenObj(response);
270
+ homeAccountIdentifier = this.createHomeAccountIdentifier(response, idTokenObj);
271
+ accountEntity = this.createAccountEntity(response, homeAccountIdentifier, idTokenObj, authorityPreferredCache);
272
+ return [4 /*yield*/, this.generateAuthenticationResult(response, request, idTokenObj, accountEntity, authority.canonicalAuthority, reqTimestamp)];
298
273
  case 2:
299
- // Set the token type to POP in the response
300
- responseTokenType = AuthenticationScheme.POP;
274
+ result = _a.sent();
275
+ // cache accounts and tokens in the appropriate storage
276
+ this.cacheAccount(accountEntity);
277
+ this.cacheNativeTokens(response, request, homeAccountIdentifier, idTokenObj, result.accessToken, result.tenantId, reqTimestamp);
278
+ return [2 /*return*/, result];
279
+ }
280
+ });
281
+ });
282
+ };
283
+ /**
284
+ * Create an idToken Object (not entity)
285
+ * @param response
286
+ * @returns
287
+ */
288
+ NativeInteractionClient.prototype.createIdTokenObj = function (response) {
289
+ return new AuthToken(response.id_token || Constants.EMPTY_STRING, this.browserCrypto);
290
+ };
291
+ /**
292
+ * creates an homeAccountIdentifier for the account
293
+ * @param response
294
+ * @param idTokenObj
295
+ * @returns
296
+ */
297
+ NativeInteractionClient.prototype.createHomeAccountIdentifier = function (response, idTokenObj) {
298
+ // Save account in browser storage
299
+ var homeAccountIdentifier = AccountEntity.generateHomeAccountId(response.client_info || Constants.EMPTY_STRING, AuthorityType.Default, this.logger, this.browserCrypto, idTokenObj);
300
+ return homeAccountIdentifier;
301
+ };
302
+ /**
303
+ * Creates account entity
304
+ * @param response
305
+ * @param homeAccountIdentifier
306
+ * @param idTokenObj
307
+ * @param authority
308
+ * @returns
309
+ */
310
+ NativeInteractionClient.prototype.createAccountEntity = function (response, homeAccountIdentifier, idTokenObj, authority) {
311
+ return AccountEntity.createAccount(response.client_info, homeAccountIdentifier, idTokenObj, undefined, undefined, undefined, authority, response.account.id);
312
+ };
313
+ /**
314
+ * Helper to generate scopes
315
+ * @param response
316
+ * @param request
317
+ * @returns
318
+ */
319
+ NativeInteractionClient.prototype.generateScopes = function (response, request) {
320
+ return response.scope ? ScopeSet.fromString(response.scope) : ScopeSet.fromString(request.scope);
321
+ };
322
+ /**
323
+ * If PoP token is requesred, records the PoP token if returned from the WAM, else generates one in the browser
324
+ * @param request
325
+ * @param response
326
+ */
327
+ NativeInteractionClient.prototype.generatePopAccessToken = function (response, request) {
328
+ return __awaiter(this, void 0, void 0, function () {
329
+ var popTokenGenerator, shrParameters;
330
+ return __generator(this, function (_a) {
331
+ switch (_a.label) {
332
+ case 0:
333
+ if (!(request.tokenType === AuthenticationScheme.POP)) return [3 /*break*/, 2];
334
+ /**
335
+ * This code prioritizes SHR returned from the native layer. In case of error/SHR not calculated from WAM and the AT
336
+ * is still received, SHR is calculated locally
337
+ */
301
338
  // Check if native layer returned an SHR token
302
339
  if (response.shr) {
303
340
  this.logger.trace("handleNativeServerResponse: SHR is enabled in native layer");
304
- responseAccessToken = response.shr;
305
- return [3 /*break*/, 5];
341
+ return [2 /*return*/, response.shr];
306
342
  }
307
343
  popTokenGenerator = new PopTokenGenerator(this.browserCrypto);
308
344
  shrParameters = {
@@ -319,17 +355,39 @@ var NativeInteractionClient = /** @class */ (function (_super) {
319
355
  throw ClientAuthError.createKeyIdMissingError();
320
356
  }
321
357
  return [4 /*yield*/, popTokenGenerator.signPopToken(response.access_token, request.keyId, shrParameters)];
322
- case 3:
323
- responseAccessToken = _b.sent();
324
- return [3 /*break*/, 5];
325
- case 4:
326
- {
327
- responseAccessToken = response.access_token;
328
- }
329
- _b.label = 5;
330
- case 5:
358
+ case 1: return [2 /*return*/, _a.sent()];
359
+ case 2: return [2 /*return*/, response.access_token];
360
+ }
361
+ });
362
+ });
363
+ };
364
+ /**
365
+ * Generates authentication result
366
+ * @param response
367
+ * @param request
368
+ * @param idTokenObj
369
+ * @param accountEntity
370
+ * @param authority
371
+ * @param reqTimestamp
372
+ * @returns
373
+ */
374
+ NativeInteractionClient.prototype.generateAuthenticationResult = function (response, request, idTokenObj, accountEntity, authority, reqTimestamp) {
375
+ return __awaiter(this, void 0, void 0, function () {
376
+ var mats, responseScopes, accountProperties, uid, tid, responseAccessToken, tokenType, result;
377
+ return __generator(this, function (_a) {
378
+ switch (_a.label) {
379
+ case 0:
380
+ mats = this.addTelemetryFromNativeResponse(response);
381
+ responseScopes = response.scope ? ScopeSet.fromString(response.scope) : ScopeSet.fromString(request.scope);
382
+ accountProperties = response.account.properties || {};
383
+ uid = accountProperties["UID"] || idTokenObj.claims.oid || idTokenObj.claims.sub || Constants.EMPTY_STRING;
384
+ tid = accountProperties["TenantId"] || idTokenObj.claims.tid || Constants.EMPTY_STRING;
385
+ return [4 /*yield*/, this.generatePopAccessToken(response, request)];
386
+ case 1:
387
+ responseAccessToken = _a.sent();
388
+ tokenType = (request.tokenType === AuthenticationScheme.POP) ? AuthenticationScheme.POP : AuthenticationScheme.BEARER;
331
389
  result = {
332
- authority: authority.canonicalAuthority,
390
+ authority: authority,
333
391
  uniqueId: uid,
334
392
  tenantId: tid,
335
393
  scopes: responseScopes.asArray(),
@@ -339,30 +397,78 @@ var NativeInteractionClient = /** @class */ (function (_super) {
339
397
  accessToken: responseAccessToken,
340
398
  fromCache: mats ? this.isResponseFromCache(mats) : false,
341
399
  expiresOn: new Date(Number(reqTimestamp + response.expires_in) * 1000),
342
- tokenType: responseTokenType,
400
+ tokenType: tokenType,
343
401
  correlationId: this.correlationId,
344
402
  state: response.state,
345
403
  fromNativeBroker: true
346
404
  };
347
- idTokenEntity = IdTokenEntity.createIdTokenEntity(homeAccountIdentifier, request.authority, response.id_token || Constants.EMPTY_STRING, request.clientId, idTokenObj.claims.tid || Constants.EMPTY_STRING);
348
- this.nativeStorageManager.setIdTokenCredential(idTokenEntity);
349
- expiresIn = (responseTokenType === AuthenticationScheme.POP)
350
- ? Constants.SHR_NONCE_VALIDITY
351
- : (typeof response.expires_in === "string"
352
- ? parseInt(response.expires_in, 10)
353
- : response.expires_in) || 0;
354
- tokenExpirationSeconds = reqTimestamp + expiresIn;
355
- accessTokenEntity = AccessTokenEntity.createAccessTokenEntity(homeAccountIdentifier, request.authority, responseAccessToken, request.clientId, tid, responseScopes.printScopes(), tokenExpirationSeconds, 0, this.browserCrypto);
356
- this.nativeStorageManager.setAccessTokenCredential(accessTokenEntity);
357
- // Remove any existing cached tokens for this account in browser storage
358
- this.browserStorage.removeAccountContext(accountEntity).catch(function (e) {
359
- _this.logger.error("Error occurred while removing account context from browser storage. " + e);
360
- });
361
405
  return [2 /*return*/, result];
362
406
  }
363
407
  });
364
408
  });
365
409
  };
410
+ /**
411
+ * cache the account entity in browser storage
412
+ * @param accountEntity
413
+ */
414
+ NativeInteractionClient.prototype.cacheAccount = function (accountEntity) {
415
+ var _this = this;
416
+ // Store the account info and hence `nativeAccountId` in browser cache
417
+ this.browserStorage.setAccount(accountEntity);
418
+ // Remove any existing cached tokens for this account in browser storage
419
+ this.browserStorage.removeAccountContext(accountEntity).catch(function (e) {
420
+ _this.logger.error("Error occurred while removing account context from browser storage. " + e);
421
+ });
422
+ };
423
+ /**
424
+ * Stores the access_token and id_token in inmemory storage
425
+ * @param response
426
+ * @param request
427
+ * @param homeAccountIdentifier
428
+ * @param idTokenObj
429
+ * @param responseAccessToken
430
+ * @param tenantId
431
+ * @param reqTimestamp
432
+ */
433
+ NativeInteractionClient.prototype.cacheNativeTokens = function (response, request, homeAccountIdentifier, idTokenObj, responseAccessToken, tenantId, reqTimestamp) {
434
+ // cache idToken in inmemory storage
435
+ var idTokenEntity = IdTokenEntity.createIdTokenEntity(homeAccountIdentifier, request.authority, response.id_token || Constants.EMPTY_STRING, request.clientId, idTokenObj.claims.tid || Constants.EMPTY_STRING);
436
+ this.nativeStorageManager.setIdTokenCredential(idTokenEntity);
437
+ // cache accessToken in inmemory storage
438
+ var expiresIn = (request.tokenType === AuthenticationScheme.POP)
439
+ ? Constants.SHR_NONCE_VALIDITY
440
+ : (typeof response.expires_in === "string"
441
+ ? parseInt(response.expires_in, 10)
442
+ : response.expires_in) || 0;
443
+ var tokenExpirationSeconds = reqTimestamp + expiresIn;
444
+ var responseScopes = this.generateScopes(response, request);
445
+ var accessTokenEntity = AccessTokenEntity.createAccessTokenEntity(homeAccountIdentifier, request.authority, responseAccessToken, request.clientId, tenantId, responseScopes.printScopes(), tokenExpirationSeconds, 0, this.browserCrypto);
446
+ this.nativeStorageManager.setAccessTokenCredential(accessTokenEntity);
447
+ };
448
+ NativeInteractionClient.prototype.addTelemetryFromNativeResponse = function (response) {
449
+ var mats = this.getMATSFromResponse(response);
450
+ if (!mats) {
451
+ return null;
452
+ }
453
+ this.performanceClient.addStaticFields({
454
+ extensionId: this.nativeMessageHandler.getExtensionId(),
455
+ extensionVersion: this.nativeMessageHandler.getExtensionVersion(),
456
+ matsBrokerVersion: mats.broker_version,
457
+ matsAccountJoinOnStart: mats.account_join_on_start,
458
+ matsAccountJoinOnEnd: mats.account_join_on_end,
459
+ matsDeviceJoin: mats.device_join,
460
+ matsPromptBehavior: mats.prompt_behavior,
461
+ matsApiErrorCode: mats.api_error_code,
462
+ matsUiVisible: mats.ui_visible,
463
+ matsSilentCode: mats.silent_code,
464
+ matsSilentBiSubCode: mats.silent_bi_sub_code,
465
+ matsSilentMessage: mats.silent_message,
466
+ matsSilentStatus: mats.silent_status,
467
+ matsHttpStatus: mats.http_status,
468
+ matsHttpEventCount: mats.http_event_count
469
+ }, this.correlationId);
470
+ return mats;
471
+ };
366
472
  /**
367
473
  * Validates native platform response before processing
368
474
  * @param response