@azure/msal-browser 3.5.1-beta.1 → 3.7.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 (290) hide show
  1. package/dist/app/IPublicClientApplication.d.ts +51 -51
  2. package/dist/app/IPublicClientApplication.mjs +102 -102
  3. package/dist/app/IPublicClientApplication.mjs.map +1 -1
  4. package/dist/app/PublicClientApplication.d.ts +269 -268
  5. package/dist/app/PublicClientApplication.d.ts.map +1 -1
  6. package/dist/app/PublicClientApplication.mjs +333 -333
  7. package/dist/app/PublicClientApplication.mjs.map +1 -1
  8. package/dist/app/PublicClientNext.d.ts +273 -273
  9. package/dist/app/PublicClientNext.mjs +351 -351
  10. package/dist/app/PublicClientNext.mjs.map +1 -1
  11. package/dist/broker/nativeBroker/NativeMessageHandler.d.ts +62 -62
  12. package/dist/broker/nativeBroker/NativeMessageHandler.mjs +254 -254
  13. package/dist/broker/nativeBroker/NativeMessageHandler.mjs.map +1 -1
  14. package/dist/broker/nativeBroker/NativeRequest.d.ts +44 -44
  15. package/dist/broker/nativeBroker/NativeResponse.d.ts +48 -48
  16. package/dist/broker/nativeBroker/NativeStatusCodes.d.ts +7 -7
  17. package/dist/broker/nativeBroker/NativeStatusCodes.mjs +11 -11
  18. package/dist/broker/nativeBroker/NativeStatusCodes.mjs.map +1 -1
  19. package/dist/cache/AsyncMemoryStorage.d.ts +51 -51
  20. package/dist/cache/AsyncMemoryStorage.mjs +132 -132
  21. package/dist/cache/AsyncMemoryStorage.mjs.map +1 -1
  22. package/dist/cache/BrowserCacheManager.d.ts +395 -383
  23. package/dist/cache/BrowserCacheManager.d.ts.map +1 -1
  24. package/dist/cache/BrowserCacheManager.mjs +1283 -1263
  25. package/dist/cache/BrowserCacheManager.mjs.map +1 -1
  26. package/dist/cache/BrowserStorage.d.ts +11 -11
  27. package/dist/cache/BrowserStorage.mjs +32 -32
  28. package/dist/cache/BrowserStorage.mjs.map +1 -1
  29. package/dist/cache/CryptoKeyStore.d.ts +18 -18
  30. package/dist/cache/CryptoKeyStore.mjs +40 -40
  31. package/dist/cache/CryptoKeyStore.mjs.map +1 -1
  32. package/dist/cache/DatabaseStorage.d.ts +56 -56
  33. package/dist/cache/DatabaseStorage.mjs +190 -190
  34. package/dist/cache/DatabaseStorage.mjs.map +1 -1
  35. package/dist/cache/IAsyncMemoryStorage.d.ts +27 -27
  36. package/dist/cache/ITokenCache.d.ts +11 -11
  37. package/dist/cache/IWindowStorage.d.ts +27 -27
  38. package/dist/cache/MemoryStorage.d.ts +11 -11
  39. package/dist/cache/MemoryStorage.mjs +31 -31
  40. package/dist/cache/MemoryStorage.mjs.map +1 -1
  41. package/dist/cache/TokenCache.d.ts +77 -77
  42. package/dist/cache/TokenCache.d.ts.map +1 -1
  43. package/dist/cache/TokenCache.mjs +223 -225
  44. package/dist/cache/TokenCache.mjs.map +1 -1
  45. package/dist/config/Configuration.d.ts +206 -206
  46. package/dist/config/Configuration.d.ts.map +1 -1
  47. package/dist/config/Configuration.mjs +128 -128
  48. package/dist/config/Configuration.mjs.map +1 -1
  49. package/dist/controllers/ControllerFactory.d.ts +4 -4
  50. package/dist/controllers/ControllerFactory.d.ts.map +1 -1
  51. package/dist/controllers/ControllerFactory.mjs +29 -29
  52. package/dist/controllers/ControllerFactory.mjs.map +1 -1
  53. package/dist/controllers/IController.d.ts +61 -61
  54. package/dist/controllers/NestedAppAuthController.d.ts +95 -95
  55. package/dist/controllers/NestedAppAuthController.mjs +334 -334
  56. package/dist/controllers/NestedAppAuthController.mjs.map +1 -1
  57. package/dist/controllers/StandardController.d.ts +407 -407
  58. package/dist/controllers/StandardController.d.ts.map +1 -1
  59. package/dist/controllers/StandardController.mjs +1307 -1294
  60. package/dist/controllers/StandardController.mjs.map +1 -1
  61. package/dist/controllers/UnknownOperatingContextController.d.ts +87 -87
  62. package/dist/controllers/UnknownOperatingContextController.mjs +264 -264
  63. package/dist/controllers/UnknownOperatingContextController.mjs.map +1 -1
  64. package/dist/crypto/BrowserCrypto.d.ts +44 -44
  65. package/dist/crypto/BrowserCrypto.mjs +93 -93
  66. package/dist/crypto/BrowserCrypto.mjs.map +1 -1
  67. package/dist/crypto/CryptoOps.d.ts +63 -63
  68. package/dist/crypto/CryptoOps.mjs +145 -145
  69. package/dist/crypto/CryptoOps.mjs.map +1 -1
  70. package/dist/crypto/PkceGenerator.d.ts +8 -8
  71. package/dist/crypto/PkceGenerator.mjs +54 -54
  72. package/dist/crypto/PkceGenerator.mjs.map +1 -1
  73. package/dist/crypto/SignedHttpRequest.d.ts +30 -30
  74. package/dist/crypto/SignedHttpRequest.mjs +39 -39
  75. package/dist/crypto/SignedHttpRequest.mjs.map +1 -1
  76. package/dist/encode/Base64Decode.d.ts +9 -9
  77. package/dist/encode/Base64Decode.mjs +36 -36
  78. package/dist/encode/Base64Decode.mjs.map +1 -1
  79. package/dist/encode/Base64Encode.d.ts +19 -19
  80. package/dist/encode/Base64Encode.mjs +43 -43
  81. package/dist/encode/Base64Encode.mjs.map +1 -1
  82. package/dist/error/BrowserAuthError.d.ts +250 -250
  83. package/dist/error/BrowserAuthError.mjs +258 -258
  84. package/dist/error/BrowserAuthError.mjs.map +1 -1
  85. package/dist/error/BrowserAuthErrorCodes.d.ts +45 -45
  86. package/dist/error/BrowserAuthErrorCodes.mjs +49 -49
  87. package/dist/error/BrowserAuthErrorCodes.mjs.map +1 -1
  88. package/dist/error/BrowserConfigurationAuthError.d.ts +33 -33
  89. package/dist/error/BrowserConfigurationAuthError.mjs +40 -40
  90. package/dist/error/BrowserConfigurationAuthError.mjs.map +1 -1
  91. package/dist/error/BrowserConfigurationAuthErrorCodes.d.ts +3 -3
  92. package/dist/error/BrowserConfigurationAuthErrorCodes.mjs +7 -7
  93. package/dist/error/BrowserConfigurationAuthErrorCodes.mjs.map +1 -1
  94. package/dist/error/NativeAuthError.d.ts +29 -29
  95. package/dist/error/NativeAuthError.mjs +60 -60
  96. package/dist/error/NativeAuthError.mjs.map +1 -1
  97. package/dist/error/NativeAuthErrorCodes.d.ts +2 -2
  98. package/dist/error/NativeAuthErrorCodes.mjs +6 -6
  99. package/dist/error/NativeAuthErrorCodes.mjs.map +1 -1
  100. package/dist/error/NestedAppAuthError.d.ts +14 -14
  101. package/dist/error/NestedAppAuthError.mjs +23 -23
  102. package/dist/error/NestedAppAuthError.mjs.map +1 -1
  103. package/dist/event/EventHandler.d.ts +41 -41
  104. package/dist/event/EventHandler.mjs +119 -119
  105. package/dist/event/EventHandler.mjs.map +1 -1
  106. package/dist/event/EventMessage.d.ts +25 -25
  107. package/dist/event/EventMessage.mjs +68 -68
  108. package/dist/event/EventMessage.mjs.map +1 -1
  109. package/dist/event/EventType.d.ts +28 -28
  110. package/dist/event/EventType.mjs +31 -31
  111. package/dist/event/EventType.mjs.map +1 -1
  112. package/dist/index.d.ts +39 -39
  113. package/dist/index.d.ts.map +1 -1
  114. package/dist/index.mjs +1 -1
  115. package/dist/interaction_client/BaseInteractionClient.d.ts +54 -54
  116. package/dist/interaction_client/BaseInteractionClient.mjs +152 -152
  117. package/dist/interaction_client/BaseInteractionClient.mjs.map +1 -1
  118. package/dist/interaction_client/HybridSpaAuthorizationCodeClient.d.ts +4 -4
  119. package/dist/interaction_client/HybridSpaAuthorizationCodeClient.mjs +10 -10
  120. package/dist/interaction_client/HybridSpaAuthorizationCodeClient.mjs.map +1 -1
  121. package/dist/interaction_client/NativeInteractionClient.d.ts +140 -140
  122. package/dist/interaction_client/NativeInteractionClient.d.ts.map +1 -1
  123. package/dist/interaction_client/NativeInteractionClient.mjs +541 -549
  124. package/dist/interaction_client/NativeInteractionClient.mjs.map +1 -1
  125. package/dist/interaction_client/PopupClient.d.ts +105 -105
  126. package/dist/interaction_client/PopupClient.mjs +432 -432
  127. package/dist/interaction_client/PopupClient.mjs.map +1 -1
  128. package/dist/interaction_client/RedirectClient.d.ts +49 -49
  129. package/dist/interaction_client/RedirectClient.mjs +311 -311
  130. package/dist/interaction_client/RedirectClient.mjs.map +1 -1
  131. package/dist/interaction_client/SilentAuthCodeClient.d.ts +23 -23
  132. package/dist/interaction_client/SilentAuthCodeClient.mjs +57 -57
  133. package/dist/interaction_client/SilentAuthCodeClient.mjs.map +1 -1
  134. package/dist/interaction_client/SilentCacheClient.d.ts +24 -24
  135. package/dist/interaction_client/SilentCacheClient.mjs +61 -61
  136. package/dist/interaction_client/SilentCacheClient.mjs.map +1 -1
  137. package/dist/interaction_client/SilentIframeClient.d.ts +32 -32
  138. package/dist/interaction_client/SilentIframeClient.mjs +96 -96
  139. package/dist/interaction_client/SilentIframeClient.mjs.map +1 -1
  140. package/dist/interaction_client/SilentRefreshClient.d.ts +20 -20
  141. package/dist/interaction_client/SilentRefreshClient.d.ts.map +1 -1
  142. package/dist/interaction_client/SilentRefreshClient.mjs +47 -43
  143. package/dist/interaction_client/SilentRefreshClient.mjs.map +1 -1
  144. package/dist/interaction_client/StandardInteractionClient.d.ts +54 -54
  145. package/dist/interaction_client/StandardInteractionClient.mjs +222 -222
  146. package/dist/interaction_client/StandardInteractionClient.mjs.map +1 -1
  147. package/dist/interaction_handler/InteractionHandler.d.ts +33 -33
  148. package/dist/interaction_handler/InteractionHandler.mjs +93 -93
  149. package/dist/interaction_handler/InteractionHandler.mjs.map +1 -1
  150. package/dist/interaction_handler/RedirectHandler.d.ts +32 -32
  151. package/dist/interaction_handler/RedirectHandler.mjs +134 -134
  152. package/dist/interaction_handler/RedirectHandler.mjs.map +1 -1
  153. package/dist/interaction_handler/SilentHandler.d.ts +13 -13
  154. package/dist/interaction_handler/SilentHandler.mjs +133 -133
  155. package/dist/interaction_handler/SilentHandler.mjs.map +1 -1
  156. package/dist/naa/AccountInfo.d.ts +11 -11
  157. package/dist/naa/AuthBridge.d.ts +8 -5
  158. package/dist/naa/AuthBridge.d.ts.map +1 -1
  159. package/dist/naa/AuthResult.d.ts +7 -0
  160. package/dist/naa/AuthResult.d.ts.map +1 -0
  161. package/dist/naa/BridgeCapabilities.d.ts +3 -3
  162. package/dist/naa/BridgeError.d.ts +9 -9
  163. package/dist/naa/BridgeError.mjs +7 -7
  164. package/dist/naa/BridgeError.mjs.map +1 -1
  165. package/dist/naa/BridgeProxy.d.ts +68 -72
  166. package/dist/naa/BridgeProxy.d.ts.map +1 -1
  167. package/dist/naa/BridgeProxy.mjs +155 -152
  168. package/dist/naa/BridgeProxy.mjs.map +1 -1
  169. package/dist/naa/BridgeRequest.d.ts +7 -6
  170. package/dist/naa/BridgeRequest.d.ts.map +1 -1
  171. package/dist/naa/BridgeRequestEnvelope.d.ts +12 -13
  172. package/dist/naa/BridgeRequestEnvelope.d.ts.map +1 -1
  173. package/dist/naa/BridgeResponseEnvelope.d.ts +13 -10
  174. package/dist/naa/BridgeResponseEnvelope.d.ts.map +1 -1
  175. package/dist/naa/BridgeStatusCode.d.ts +11 -10
  176. package/dist/naa/BridgeStatusCode.d.ts.map +1 -1
  177. package/dist/naa/BridgeStatusCode.mjs +15 -16
  178. package/dist/naa/BridgeStatusCode.mjs.map +1 -1
  179. package/dist/naa/IBridgeProxy.d.ts +10 -12
  180. package/dist/naa/IBridgeProxy.d.ts.map +1 -1
  181. package/dist/naa/{InitializeBridgeResponse.d.ts → InitContext.d.ts} +7 -7
  182. package/dist/naa/InitContext.d.ts.map +1 -0
  183. package/dist/naa/TokenRequest.d.ts +18 -19
  184. package/dist/naa/TokenRequest.d.ts.map +1 -1
  185. package/dist/naa/TokenResponse.d.ts +13 -15
  186. package/dist/naa/TokenResponse.d.ts.map +1 -1
  187. package/dist/naa/mapping/NestedAppAuthAdapter.d.ts +23 -23
  188. package/dist/naa/mapping/NestedAppAuthAdapter.d.ts.map +1 -1
  189. package/dist/naa/mapping/NestedAppAuthAdapter.mjs +141 -141
  190. package/dist/naa/mapping/NestedAppAuthAdapter.mjs.map +1 -1
  191. package/dist/navigation/INavigationClient.d.ts +16 -16
  192. package/dist/navigation/NavigationClient.d.ts +22 -22
  193. package/dist/navigation/NavigationClient.mjs +40 -40
  194. package/dist/navigation/NavigationClient.mjs.map +1 -1
  195. package/dist/navigation/NavigationOptions.d.ts +12 -12
  196. package/dist/network/FetchClient.d.ts +26 -26
  197. package/dist/network/FetchClient.mjs +99 -99
  198. package/dist/network/FetchClient.mjs.map +1 -1
  199. package/dist/operatingcontext/BaseOperatingContext.d.ts +41 -40
  200. package/dist/operatingcontext/BaseOperatingContext.d.ts.map +1 -1
  201. package/dist/operatingcontext/BaseOperatingContext.mjs +96 -45
  202. package/dist/operatingcontext/BaseOperatingContext.mjs.map +1 -1
  203. package/dist/operatingcontext/StandardOperatingContext.d.ts +25 -25
  204. package/dist/operatingcontext/StandardOperatingContext.mjs +43 -43
  205. package/dist/operatingcontext/StandardOperatingContext.mjs.map +1 -1
  206. package/dist/operatingcontext/TeamsAppOperatingContext.d.ts +32 -32
  207. package/dist/operatingcontext/TeamsAppOperatingContext.mjs +85 -85
  208. package/dist/operatingcontext/TeamsAppOperatingContext.mjs.map +1 -1
  209. package/dist/operatingcontext/UnknownOperatingContext.d.ts +25 -25
  210. package/dist/operatingcontext/UnknownOperatingContext.mjs +42 -42
  211. package/dist/operatingcontext/UnknownOperatingContext.mjs.map +1 -1
  212. package/dist/packageMetadata.d.ts +2 -2
  213. package/dist/packageMetadata.d.ts.map +1 -1
  214. package/dist/packageMetadata.mjs +4 -4
  215. package/dist/packageMetadata.mjs.map +1 -1
  216. package/dist/request/AuthorizationCodeRequest.d.ts +8 -8
  217. package/dist/request/AuthorizationUrlRequest.d.ts +8 -8
  218. package/dist/request/ClearCacheRequest.d.ts +10 -10
  219. package/dist/request/EndSessionPopupRequest.d.ts +18 -18
  220. package/dist/request/EndSessionRequest.d.ts +15 -15
  221. package/dist/request/PopupRequest.d.ts +34 -34
  222. package/dist/request/PopupWindowAttributes.d.ts +15 -15
  223. package/dist/request/RedirectRequest.d.ts +35 -35
  224. package/dist/request/SilentRequest.d.ts +32 -32
  225. package/dist/request/SsoSilentRequest.d.ts +29 -29
  226. package/dist/response/AuthenticationResult.d.ts +4 -4
  227. package/dist/response/ResponseHandler.d.ts +7 -7
  228. package/dist/response/ResponseHandler.mjs +36 -36
  229. package/dist/response/ResponseHandler.mjs.map +1 -1
  230. package/dist/telemetry/BrowserPerformanceClient.d.ts +34 -36
  231. package/dist/telemetry/BrowserPerformanceClient.d.ts.map +1 -1
  232. package/dist/telemetry/BrowserPerformanceClient.mjs +163 -126
  233. package/dist/telemetry/BrowserPerformanceClient.mjs.map +1 -1
  234. package/dist/telemetry/BrowserPerformanceMeasurement.d.ts +21 -21
  235. package/dist/telemetry/BrowserPerformanceMeasurement.mjs +92 -92
  236. package/dist/telemetry/BrowserPerformanceMeasurement.mjs.map +1 -1
  237. package/dist/utils/BrowserConstants.d.ts +180 -176
  238. package/dist/utils/BrowserConstants.d.ts.map +1 -1
  239. package/dist/utils/BrowserConstants.mjs +213 -205
  240. package/dist/utils/BrowserConstants.mjs.map +1 -1
  241. package/dist/utils/BrowserProtocolUtils.d.ts +11 -11
  242. package/dist/utils/BrowserProtocolUtils.mjs +21 -21
  243. package/dist/utils/BrowserProtocolUtils.mjs.map +1 -1
  244. package/dist/utils/BrowserUtils.d.ts +56 -56
  245. package/dist/utils/BrowserUtils.mjs +125 -125
  246. package/dist/utils/BrowserUtils.mjs.map +1 -1
  247. package/lib/msal-browser.cjs +18304 -17929
  248. package/lib/msal-browser.cjs.map +1 -1
  249. package/lib/msal-browser.js +18304 -17929
  250. package/lib/msal-browser.js.map +1 -1
  251. package/lib/msal-browser.min.js +66 -68
  252. package/package.json +103 -102
  253. package/src/app/PublicClientApplication.ts +2 -1
  254. package/src/cache/BrowserCacheManager.ts +38 -23
  255. package/src/cache/DatabaseStorage.ts +1 -1
  256. package/src/cache/TokenCache.ts +34 -29
  257. package/src/config/Configuration.ts +1 -1
  258. package/src/controllers/ControllerFactory.ts +3 -5
  259. package/src/controllers/StandardController.ts +53 -26
  260. package/src/crypto/CryptoOps.ts +1 -1
  261. package/src/crypto/SignedHttpRequest.ts +1 -1
  262. package/src/index.ts +1 -0
  263. package/src/interaction_client/BaseInteractionClient.ts +2 -2
  264. package/src/interaction_client/NativeInteractionClient.ts +24 -20
  265. package/src/interaction_client/PopupClient.ts +1 -1
  266. package/src/interaction_client/RedirectClient.ts +3 -3
  267. package/src/interaction_client/SilentAuthCodeClient.ts +1 -1
  268. package/src/interaction_client/SilentRefreshClient.ts +8 -0
  269. package/src/interaction_client/StandardInteractionClient.ts +1 -1
  270. package/src/interaction_handler/SilentHandler.ts +2 -2
  271. package/src/naa/AuthBridge.ts +3 -2
  272. package/src/naa/AuthResult.ts +12 -0
  273. package/src/naa/BridgeProxy.ts +64 -71
  274. package/src/naa/BridgeRequest.ts +6 -2
  275. package/src/naa/BridgeRequestEnvelope.ts +1 -13
  276. package/src/naa/BridgeResponseEnvelope.ts +5 -7
  277. package/src/naa/BridgeStatusCode.ts +12 -10
  278. package/src/naa/IBridgeProxy.ts +3 -14
  279. package/src/naa/{InitializeBridgeResponse.ts → InitContext.ts} +1 -1
  280. package/src/naa/TokenRequest.ts +1 -2
  281. package/src/naa/TokenResponse.ts +1 -4
  282. package/src/naa/mapping/NestedAppAuthAdapter.ts +19 -19
  283. package/src/operatingcontext/BaseOperatingContext.ts +64 -7
  284. package/src/packageMetadata.ts +1 -1
  285. package/src/telemetry/BrowserPerformanceClient.ts +95 -42
  286. package/src/utils/BrowserConstants.ts +11 -0
  287. package/dist/naa/AccountRequests.d.ts +0 -10
  288. package/dist/naa/AccountRequests.d.ts.map +0 -1
  289. package/dist/naa/InitializeBridgeResponse.d.ts.map +0 -1
  290. package/src/naa/AccountRequests.ts +0 -16
@@ -283,7 +283,7 @@ export abstract class BaseInteractionClient {
283
283
  this.logger.verbose(
284
284
  "Creating discovered authority with request authority"
285
285
  );
286
- return await AuthorityFactory.createDiscoveredInstance(
286
+ return AuthorityFactory.createDiscoveredInstance(
287
287
  requestAuthority,
288
288
  this.config.system.networkClient,
289
289
  this.browserStorage,
@@ -295,7 +295,7 @@ export abstract class BaseInteractionClient {
295
295
  this.logger.verbose(
296
296
  "Creating discovered authority with configured authority"
297
297
  );
298
- return await AuthorityFactory.createDiscoveredInstance(
298
+ return AuthorityFactory.createDiscoveredInstance(
299
299
  this.config.auth.authority,
300
300
  this.config.system.networkClient,
301
301
  this.browserStorage,
@@ -33,7 +33,9 @@ import {
33
33
  invokeAsync,
34
34
  createAuthError,
35
35
  AuthErrorCodes,
36
+ updateAccountTenantProfileData,
36
37
  CacheHelpers,
38
+ buildAccountToCache,
37
39
  } from "@azure/msal-common";
38
40
  import { BaseInteractionClient } from "./BaseInteractionClient";
39
41
  import { BrowserConfiguration } from "../config/Configuration";
@@ -372,7 +374,7 @@ export class NativeInteractionClient extends BaseInteractionClient {
372
374
  reqTimestamp
373
375
  );
374
376
  this.browserStorage.setInteractionInProgress(false);
375
- return result;
377
+ return await result;
376
378
  } catch (e) {
377
379
  this.browserStorage.setInteractionInProgress(false);
378
380
  throw e;
@@ -420,14 +422,19 @@ export class NativeInteractionClient extends BaseInteractionClient {
420
422
  response,
421
423
  idTokenClaims
422
424
  );
423
- const accountEntity = AccountEntity.createAccount(
424
- {
425
- homeAccountId: homeAccountIdentifier,
426
- idTokenClaims: idTokenClaims,
427
- clientInfo: response.client_info,
428
- nativeAccountId: response.account.id,
429
- },
430
- authority
425
+
426
+ const baseAccount = buildAccountToCache(
427
+ this.browserStorage,
428
+ authority,
429
+ homeAccountIdentifier,
430
+ idTokenClaims,
431
+ base64Decode,
432
+ response.client_info,
433
+ undefined, // environment
434
+ idTokenClaims.tid,
435
+ undefined, // auth code payload
436
+ response.account.id,
437
+ this.logger
431
438
  );
432
439
 
433
440
  // generate authenticationResult
@@ -435,13 +442,13 @@ export class NativeInteractionClient extends BaseInteractionClient {
435
442
  response,
436
443
  request,
437
444
  idTokenClaims,
438
- accountEntity,
445
+ baseAccount,
439
446
  authority.canonicalAuthority,
440
447
  reqTimestamp
441
448
  );
442
449
 
443
450
  // cache accounts and tokens in the appropriate storage
444
- this.cacheAccount(accountEntity);
451
+ this.cacheAccount(baseAccount);
445
452
  this.cacheNativeTokens(
446
453
  response,
447
454
  request,
@@ -533,7 +540,7 @@ export class NativeInteractionClient extends BaseInteractionClient {
533
540
  if (!request.keyId) {
534
541
  throw createClientAuthError(ClientAuthErrorCodes.keyIdMissing);
535
542
  }
536
- return await popTokenGenerator.signPopToken(
543
+ return popTokenGenerator.signPopToken(
537
544
  response.access_token,
538
545
  request.keyId,
539
546
  shrParameters
@@ -580,14 +587,11 @@ export class NativeInteractionClient extends BaseInteractionClient {
580
587
  idTokenClaims.tid ||
581
588
  Constants.EMPTY_STRING;
582
589
 
583
- const fullAccountEntity: AccountEntity = idTokenClaims
584
- ? Object.assign(new AccountEntity(), {
585
- ...accountEntity,
586
- idTokenClaims: idTokenClaims,
587
- })
588
- : accountEntity;
589
-
590
- const accountInfo = fullAccountEntity.getAccountInfo();
590
+ const accountInfo: AccountInfo | null = updateAccountTenantProfileData(
591
+ accountEntity.getAccountInfo(),
592
+ undefined, // tenantProfile optional
593
+ idTokenClaims
594
+ );
591
595
 
592
596
  // generate PoP token as needed
593
597
  const responseAccessToken = await this.generatePopAccessToken(
@@ -339,7 +339,7 @@ export class PopupClient extends StandardInteractionClient {
339
339
  this.browserCrypto,
340
340
  validRequest.state
341
341
  );
342
- return nativeInteractionClient.acquireToken({
342
+ return await nativeInteractionClient.acquireToken({
343
343
  ...validRequest,
344
344
  state: userRequestState,
345
345
  prompt: undefined, // Server should handle the prompt, ideally native broker can do this part silently
@@ -254,7 +254,7 @@ export class RedirectClient extends StandardInteractionClient {
254
254
  this.logger.verbose(
255
255
  "NavigateToLoginRequestUrl set to false, handling response"
256
256
  );
257
- return this.handleResponse(
257
+ return await this.handleResponse(
258
258
  serverParams,
259
259
  serverTelemetryManager
260
260
  );
@@ -313,7 +313,7 @@ export class RedirectClient extends StandardInteractionClient {
313
313
 
314
314
  // If navigateInternal implementation returns false, handle the hash now
315
315
  if (!processHashOnRedirect) {
316
- return this.handleResponse(
316
+ return await this.handleResponse(
317
317
  serverParams,
318
318
  serverTelemetryManager
319
319
  );
@@ -483,7 +483,7 @@ export class RedirectClient extends StandardInteractionClient {
483
483
  this.logger,
484
484
  this.performanceClient
485
485
  );
486
- return await interactionHandler.handleCodeResponse(serverParams, state);
486
+ return interactionHandler.handleCodeResponse(serverParams, state);
487
487
  }
488
488
 
489
489
  /**
@@ -114,7 +114,7 @@ export class SilentAuthCodeClient extends StandardInteractionClient {
114
114
  );
115
115
 
116
116
  // Handle auth code parameters from request
117
- return invokeAsync(
117
+ return await invokeAsync(
118
118
  interactionHandler.handleCodeResponseFromServer.bind(
119
119
  interactionHandler
120
120
  ),
@@ -44,6 +44,14 @@ export class SilentRefreshClient extends StandardInteractionClient {
44
44
  ...request,
45
45
  ...baseRequest,
46
46
  };
47
+
48
+ if (request.redirectUri) {
49
+ // Make sure any passed redirectUri is converted to an absolute URL - redirectUri is not a required parameter for refresh token redemption so only include if explicitly provided
50
+ silentRequest.redirectUri = this.getRedirectUri(
51
+ request.redirectUri
52
+ );
53
+ }
54
+
47
55
  const serverTelemetryManager = this.initializeServerTelemetryManager(
48
56
  ApiId.acquireTokenSilent_silentFlow
49
57
  );
@@ -319,7 +319,7 @@ export abstract class StandardInteractionClient extends BaseInteractionClient {
319
319
  userAuthority,
320
320
  requestAzureCloudOptions || this.config.auth.azureCloudOptions
321
321
  );
322
- return await invokeAsync(
322
+ return invokeAsync(
323
323
  AuthorityFactory.createDiscoveredInstance.bind(AuthorityFactory),
324
324
  PerformanceEvents.AuthorityFactoryCreateDiscoveredInstance,
325
325
  this.logger,
@@ -40,7 +40,7 @@ export async function initiateAuthRequest(
40
40
  throw createBrowserAuthError(BrowserAuthErrorCodes.emptyNavigateUri);
41
41
  }
42
42
  if (navigateFrameWait) {
43
- return await invokeAsync(
43
+ return invokeAsync(
44
44
  loadFrame,
45
45
  PerformanceEvents.SilentHandlerLoadFrame,
46
46
  logger,
@@ -203,7 +203,7 @@ function createHiddenIframe(): HTMLIFrameElement {
203
203
  "sandbox",
204
204
  "allow-scripts allow-same-origin allow-forms"
205
205
  );
206
- document.getElementsByTagName("body")[0].appendChild(authFrame);
206
+ document.body.appendChild(authFrame);
207
207
 
208
208
  return authFrame;
209
209
  }
@@ -3,14 +3,15 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
 
6
+ export type AuthBridgeResponse = string | { data: string };
6
7
  export interface AuthBridge {
7
8
  addEventListener: (
8
9
  eventName: string,
9
- callback: (response: string) => void
10
+ callback: (response: AuthBridgeResponse) => void
10
11
  ) => void;
11
12
  postMessage: (message: string) => void;
12
13
  removeEventListener: (
13
14
  eventName: string,
14
- callback: (response: string) => void
15
+ callback: (response: AuthBridgeResponse) => void
15
16
  ) => void;
16
17
  }
@@ -0,0 +1,12 @@
1
+ /*
2
+ * Copyright (c) Microsoft Corporation. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+
6
+ import { AccountInfo } from "./AccountInfo";
7
+ import { TokenResponse } from "./TokenResponse";
8
+
9
+ export type AuthResult = {
10
+ token: TokenResponse;
11
+ account: AccountInfo;
12
+ };
@@ -4,20 +4,17 @@
4
4
  */
5
5
 
6
6
  import { AccountInfo } from "./AccountInfo";
7
- import {
8
- AccountByHomeIdRequest,
9
- AccountByLocalIdRequest,
10
- AccountByUsernameRequest,
11
- } from "./AccountRequests";
12
- import { AuthBridge } from "./AuthBridge";
7
+ import { AuthBridge, AuthBridgeResponse } from "./AuthBridge";
8
+ import { AuthResult } from "./AuthResult";
13
9
  import { BridgeCapabilities } from "./BridgeCapabilities";
10
+ import { BridgeError } from "./BridgeError";
14
11
  import { BridgeRequest } from "./BridgeRequest";
15
12
  import { BridgeRequestEnvelope, BridgeMethods } from "./BridgeRequestEnvelope";
16
13
  import { BridgeResponseEnvelope } from "./BridgeResponseEnvelope";
14
+ import { BridgeStatusCode } from "./BridgeStatusCode";
17
15
  import { IBridgeProxy } from "./IBridgeProxy";
18
- import { InitializeBridgeResponse } from "./InitializeBridgeResponse";
16
+ import { InitContext } from "./InitContext";
19
17
  import { TokenRequest } from "./TokenRequest";
20
- import { TokenResponse } from "./TokenResponse";
21
18
 
22
19
  declare global {
23
20
  interface Window {
@@ -31,8 +28,7 @@ declare global {
31
28
  * platform broker
32
29
  */
33
30
  export class BridgeProxy implements IBridgeProxy {
34
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
35
- static bridgeRequests: any[] = [];
31
+ static bridgeRequests: BridgeRequest[] = [];
36
32
  static crypto: Crypto;
37
33
  sdkName: string;
38
34
  sdkVersion: string;
@@ -44,7 +40,7 @@ export class BridgeProxy implements IBridgeProxy {
44
40
  * @remarks This method will be called by the create factory method
45
41
  * @remarks If the bridge is not available, this method will throw an error
46
42
  */
47
- protected static async initializeNestedAppAuthBridge(): Promise<InitializeBridgeResponse> {
43
+ protected static async initializeNestedAppAuthBridge(): Promise<InitContext> {
48
44
  if (window === undefined) {
49
45
  throw new Error("window is undefined");
50
46
  }
@@ -60,9 +56,11 @@ export class BridgeProxy implements IBridgeProxy {
60
56
 
61
57
  window.nestedAppAuthBridge.addEventListener(
62
58
  "message",
63
- (response: string) => {
59
+ (response: AuthBridgeResponse) => {
60
+ const responsePayload =
61
+ typeof response === "string" ? response : response.data;
64
62
  const responseEnvelope: BridgeResponseEnvelope =
65
- JSON.parse(response);
63
+ JSON.parse(responsePayload);
66
64
  const request = BridgeProxy.bridgeRequests.find(
67
65
  (element) =>
68
66
  element.requestId === responseEnvelope.requestId
@@ -73,22 +71,22 @@ export class BridgeProxy implements IBridgeProxy {
73
71
  1
74
72
  );
75
73
  if (responseEnvelope.success) {
76
- request.resolve(responseEnvelope.body);
74
+ request.resolve(responseEnvelope);
77
75
  } else {
78
- request.reject(responseEnvelope.body);
76
+ request.reject(responseEnvelope.error);
79
77
  }
80
78
  }
81
79
  }
82
80
  );
83
81
 
84
- const promise = new Promise<InitializeBridgeResponse>(
82
+ const bridgeResponse = await new Promise<BridgeResponseEnvelope>(
85
83
  (resolve, reject) => {
86
84
  const message: BridgeRequestEnvelope = {
87
85
  messageType: "NestedAppAuthRequest",
88
86
  method: "GetInitContext",
89
87
  requestId: BridgeProxy.getRandomId(),
90
88
  };
91
- const request: BridgeRequest<InitializeBridgeResponse> = {
89
+ const request: BridgeRequest = {
92
90
  requestId: message.requestId,
93
91
  method: message.method,
94
92
  resolve: resolve,
@@ -101,7 +99,9 @@ export class BridgeProxy implements IBridgeProxy {
101
99
  }
102
100
  );
103
101
 
104
- return promise;
102
+ return BridgeProxy.validateBridgeResultOrThrow(
103
+ bridgeResponse.initContext
104
+ );
105
105
  } catch (error) {
106
106
  window.console.log(error);
107
107
  throw error;
@@ -115,51 +115,37 @@ export class BridgeProxy implements IBridgeProxy {
115
115
  /**
116
116
  * getTokenInteractive - Attempts to get a token interactively from the bridge
117
117
  * @param request A token request
118
- * @returns a promise that resolves to a token response or rejects with a BridgeError
118
+ * @returns a promise that resolves to an auth result or rejects with a BridgeError
119
119
  */
120
- public getTokenInteractive(request: TokenRequest): Promise<TokenResponse> {
121
- return this.sendRequest<TokenResponse>("GetTokenPopup", request);
120
+ public getTokenInteractive(request: TokenRequest): Promise<AuthResult> {
121
+ return this.getToken("GetTokenPopup", request);
122
122
  }
123
123
 
124
124
  /**
125
125
  * getTokenSilent Attempts to get a token silently from the bridge
126
126
  * @param request A token request
127
- * @returns a promise that resolves to a token response or rejects with a BridgeError
127
+ * @returns a promise that resolves to an auth result or rejects with a BridgeError
128
128
  */
129
- public getTokenSilent(request: TokenRequest): Promise<TokenResponse> {
130
- return this.sendRequest<TokenResponse>("GetToken", request);
129
+ public getTokenSilent(request: TokenRequest): Promise<AuthResult> {
130
+ return this.getToken("GetToken", request);
131
131
  }
132
132
 
133
- /**
134
- * getAccountInfo - Gets account information from the bridge
135
- *
136
- * @param request A request for account information
137
- */
138
- public getAccountInfo(
139
- request:
140
- | AccountByHomeIdRequest
141
- | AccountByLocalIdRequest
142
- | AccountByUsernameRequest
143
- ): Promise<AccountInfo> {
144
- let method: BridgeMethods = "GetAccountByHomeId";
145
-
146
- if ((request as AccountByHomeIdRequest).homeAccountId !== undefined) {
147
- method = "GetAccountByHomeId";
148
- }
149
-
150
- if ((request as AccountByLocalIdRequest).localAccountId !== undefined) {
151
- method = "GetAccountByLocalId";
152
- }
153
-
154
- if ((request as AccountByUsernameRequest).username !== undefined) {
155
- method = "GetAccountByUsername";
156
- }
157
-
158
- return this.sendRequest<AccountInfo>(method, request);
133
+ private async getToken(
134
+ requestType: BridgeMethods,
135
+ request: TokenRequest
136
+ ): Promise<AuthResult> {
137
+ const result = await this.sendRequest(requestType, {
138
+ tokenParams: request,
139
+ });
140
+ return {
141
+ token: BridgeProxy.validateBridgeResultOrThrow(result.token),
142
+ account: BridgeProxy.validateBridgeResultOrThrow(result.account),
143
+ };
159
144
  }
160
145
 
161
- public getActiveAccount(): Promise<AccountInfo> {
162
- return this.sendRequest<AccountInfo>("GetActiveAccount", undefined);
146
+ public async getActiveAccount(): Promise<AccountInfo> {
147
+ const result = await this.sendRequest("GetActiveAccount");
148
+ return BridgeProxy.validateBridgeResultOrThrow(result.account);
163
149
  }
164
150
 
165
151
  public getHostCapabilities(): BridgeCapabilities | null {
@@ -171,36 +157,43 @@ export class BridgeProxy implements IBridgeProxy {
171
157
  * @param request A token request
172
158
  * @returns a promise that resolves to a response of provided type or rejects with a BridgeError
173
159
  */
174
- private sendRequest<TResponse>(
160
+ private sendRequest(
175
161
  method: BridgeMethods,
176
- request:
177
- | TokenRequest
178
- | AccountByHomeIdRequest
179
- | AccountByLocalIdRequest
180
- | AccountByUsernameRequest
181
- | undefined
182
- ): Promise<TResponse> {
162
+ requestParams?: Partial<BridgeRequestEnvelope>
163
+ ): Promise<BridgeResponseEnvelope> {
183
164
  const message: BridgeRequestEnvelope = {
184
165
  messageType: "NestedAppAuthRequest",
185
166
  method: method,
186
167
  requestId: BridgeProxy.getRandomId(),
187
- body: request,
168
+ ...requestParams,
188
169
  };
189
170
 
190
- const promise = new Promise<TResponse>((resolve, reject) => {
191
- const request: BridgeRequest<TResponse> = {
192
- requestId: message.requestId,
193
- method: message.method,
194
- resolve: resolve,
195
- reject: reject,
196
- };
197
- BridgeProxy.bridgeRequests.push(request);
198
- window.nestedAppAuthBridge.postMessage(JSON.stringify(message));
199
- });
171
+ const promise = new Promise<BridgeResponseEnvelope>(
172
+ (resolve, reject) => {
173
+ const request: BridgeRequest = {
174
+ requestId: message.requestId,
175
+ method: message.method,
176
+ resolve: resolve,
177
+ reject: reject,
178
+ };
179
+ BridgeProxy.bridgeRequests.push(request);
180
+ window.nestedAppAuthBridge.postMessage(JSON.stringify(message));
181
+ }
182
+ );
200
183
 
201
184
  return promise;
202
185
  }
203
186
 
187
+ private static validateBridgeResultOrThrow<T>(input: T | undefined): T {
188
+ if (input === undefined) {
189
+ const bridgeError: BridgeError = {
190
+ status: BridgeStatusCode.NestedAppAuthUnavailable,
191
+ };
192
+ throw bridgeError;
193
+ }
194
+ return input;
195
+ }
196
+
204
197
  /**
205
198
  * Private constructor for BridgeProxy
206
199
  * @param sdkName The name of the SDK being used to make requests on behalf of the app
@@ -3,10 +3,14 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
 
6
- export type BridgeRequest<TResponse> = {
6
+ import { BridgeResponseEnvelope } from "./BridgeResponseEnvelope";
7
+
8
+ export type BridgeRequest = {
7
9
  requestId: string;
8
10
  method: string;
9
- resolve: (value: TResponse | PromiseLike<TResponse>) => void;
11
+ resolve: (
12
+ value: BridgeResponseEnvelope | PromiseLike<BridgeResponseEnvelope>
13
+ ) => void;
10
14
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
11
15
  reject: (reason?: any) => void;
12
16
  };
@@ -4,19 +4,11 @@
4
4
  */
5
5
 
6
6
  import { TokenRequest } from "./TokenRequest";
7
- import {
8
- AccountByHomeIdRequest,
9
- AccountByLocalIdRequest,
10
- AccountByUsernameRequest,
11
- } from "./AccountRequests";
12
7
 
13
8
  export type BridgeMethods =
14
9
  | "GetToken"
15
10
  | "GetActiveAccount"
16
11
  | "GetAllAccounts"
17
- | "GetAccountByHomeId"
18
- | "GetAccountByLocalId"
19
- | "GetAccountByUsername"
20
12
  | "GetInitContext"
21
13
  | "GetTokenPopup";
22
14
 
@@ -27,11 +19,7 @@ export type BridgeRequestEnvelope = {
27
19
  clientLibrary?: string;
28
20
  clientLibraryVersion?: string;
29
21
  requestId: string;
30
- body?:
31
- | TokenRequest
32
- | AccountByHomeIdRequest
33
- | AccountByLocalIdRequest
34
- | AccountByUsernameRequest;
22
+ tokenParams?: TokenRequest;
35
23
  };
36
24
 
37
25
  export function isBridgeRequestEnvelope(
@@ -6,16 +6,14 @@
6
6
  import { BridgeError } from "./BridgeError";
7
7
  import { TokenResponse } from "./TokenResponse";
8
8
  import { AccountInfo } from "./AccountInfo";
9
- import { InitializeBridgeResponse } from "./InitializeBridgeResponse";
9
+ import { InitContext } from "./InitContext";
10
10
 
11
11
  export type BridgeResponseEnvelope = {
12
12
  messageType: "NestedAppAuthResponse";
13
13
  requestId: string;
14
14
  success: boolean; // false if body is error
15
- body:
16
- | TokenResponse
17
- | BridgeError
18
- | AccountInfo
19
- | AccountInfo[]
20
- | InitializeBridgeResponse;
15
+ token?: TokenResponse;
16
+ error?: BridgeError;
17
+ account?: AccountInfo;
18
+ initContext?: InitContext;
21
19
  };
@@ -3,13 +3,15 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
 
6
- export enum BridgeStatusCode {
7
- USER_INTERACTION_REQUIRED = "USER_INTERACTION_REQUIRED",
8
- USER_CANCEL = "USER_CANCEL",
9
- NO_NETWORK = "NO_NETWORK",
10
- TRANSIENT_ERROR = "TRANSIENT_ERROR",
11
- PERSISTENT_ERROR = "PERSISTENT_ERROR",
12
- DISABLED = "DISABLED",
13
- ACCOUNT_UNAVAILABLE = "ACCOUNT_UNAVAILABLE",
14
- NESTED_APP_AUTH_UNAVAILABLE = "NESTED_APP_AUTH_UNAVAILABLE", // NAA is unavailable in the current context, can retry with standard browser based auth
15
- }
6
+ export const BridgeStatusCode = {
7
+ UserInteractionRequired: "USER_INTERACTION_REQUIRED",
8
+ UserCancel: "USER_CANCEL",
9
+ NoNetwork: "NO_NETWORK",
10
+ TransientError: "TRANSIENT_ERROR",
11
+ PersistentError: "PERSISTENT_ERROR",
12
+ Disabled: "DISABLED",
13
+ AccountUnavailable: "ACCOUNT_UNAVAILABLE",
14
+ NestedAppAuthUnavailable: "NESTED_APP_AUTH_UNAVAILABLE", // NAA is unavailable in the current context, can retry with standard browser based auth
15
+ } as const;
16
+ export type BridgeStatusCode =
17
+ (typeof BridgeStatusCode)[keyof typeof BridgeStatusCode];
@@ -4,24 +4,13 @@
4
4
  */
5
5
 
6
6
  import { AccountInfo } from "./AccountInfo";
7
- import {
8
- AccountByHomeIdRequest,
9
- AccountByLocalIdRequest,
10
- AccountByUsernameRequest,
11
- } from "./AccountRequests";
7
+ import { AuthResult } from "./AuthResult";
12
8
  import { BridgeCapabilities } from "./BridgeCapabilities";
13
9
  import { TokenRequest } from "./TokenRequest";
14
- import { TokenResponse } from "./TokenResponse";
15
10
 
16
11
  export interface IBridgeProxy {
17
- getTokenInteractive(request: TokenRequest): Promise<TokenResponse>;
18
- getTokenSilent(request: TokenRequest): Promise<TokenResponse>;
19
- getAccountInfo(
20
- request:
21
- | AccountByHomeIdRequest
22
- | AccountByLocalIdRequest
23
- | AccountByUsernameRequest
24
- ): Promise<AccountInfo>;
12
+ getTokenInteractive(request: TokenRequest): Promise<AuthResult>;
13
+ getTokenSilent(request: TokenRequest): Promise<AuthResult>;
25
14
  getActiveAccount(): Promise<AccountInfo>;
26
15
  getHostCapabilities(): BridgeCapabilities | null;
27
16
  }
@@ -5,7 +5,7 @@
5
5
 
6
6
  import { BridgeCapabilities } from "./BridgeCapabilities";
7
7
 
8
- export interface InitializeBridgeResponse {
8
+ export interface InitContext {
9
9
  capabilities?: BridgeCapabilities;
10
10
  sdkName: string;
11
11
  sdkVersion: string;
@@ -4,12 +4,11 @@
4
4
  */
5
5
 
6
6
  export type TokenRequest = {
7
- userObjectId?: string; // Account identifier used by OneAuth
7
+ platformBrokerId?: string; // Account identifier used by OneAuth
8
8
  clientId: string;
9
9
  authority?: string;
10
10
  scope: string;
11
11
  correlationId: string;
12
- nonce?: string;
13
12
  claims?: string;
14
13
  state?: string;
15
14
  reqCnf?: string; // Having OneAuth own the keypair is better for hardware token binding support
@@ -3,15 +3,12 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
 
6
- import { AccountInfo } from "./AccountInfo";
7
-
8
6
  export type TokenResponse = {
9
7
  access_token: string;
10
- account: AccountInfo;
11
8
  expires_in: number;
12
9
  id_token: string;
13
10
  properties: TokenResponseProperties | null;
14
- scope: string;
11
+ scope?: string;
15
12
  shr?: string; // token binding enabled at native layer it is the access token, not the signing keys
16
13
  extendedLifetimeToken?: boolean;
17
14
  authority?: string;