@azure/msal-browser 3.2.0 → 3.4.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 (224) hide show
  1. package/dist/app/IPublicClientApplication.mjs +1 -1
  2. package/dist/app/PublicClientApplication.d.ts.map +1 -1
  3. package/dist/app/PublicClientApplication.mjs +3 -4
  4. package/dist/app/PublicClientApplication.mjs.map +1 -1
  5. package/dist/app/PublicClientNext.d.ts +274 -0
  6. package/dist/app/PublicClientNext.d.ts.map +1 -0
  7. package/dist/app/PublicClientNext.mjs +360 -0
  8. package/dist/app/PublicClientNext.mjs.map +1 -0
  9. package/dist/broker/nativeBroker/NativeMessageHandler.mjs +1 -1
  10. package/dist/broker/nativeBroker/NativeStatusCodes.mjs +1 -1
  11. package/dist/cache/AsyncMemoryStorage.mjs +1 -1
  12. package/dist/cache/BrowserCacheManager.d.ts +2 -13
  13. package/dist/cache/BrowserCacheManager.d.ts.map +1 -1
  14. package/dist/cache/BrowserCacheManager.mjs +26 -83
  15. package/dist/cache/BrowserCacheManager.mjs.map +1 -1
  16. package/dist/cache/BrowserStorage.mjs +1 -1
  17. package/dist/cache/CryptoKeyStore.mjs +1 -1
  18. package/dist/cache/DatabaseStorage.mjs +1 -1
  19. package/dist/cache/MemoryStorage.mjs +1 -1
  20. package/dist/cache/TokenCache.d.ts.map +1 -1
  21. package/dist/cache/TokenCache.mjs +5 -5
  22. package/dist/cache/TokenCache.mjs.map +1 -1
  23. package/dist/config/Configuration.d.ts +4 -0
  24. package/dist/config/Configuration.d.ts.map +1 -1
  25. package/dist/config/Configuration.mjs +2 -1
  26. package/dist/config/Configuration.mjs.map +1 -1
  27. package/dist/controllers/ControllerFactory.d.ts +2 -7
  28. package/dist/controllers/ControllerFactory.d.ts.map +1 -1
  29. package/dist/controllers/ControllerFactory.mjs +24 -34
  30. package/dist/controllers/ControllerFactory.mjs.map +1 -1
  31. package/dist/controllers/IController.d.ts +1 -2
  32. package/dist/controllers/IController.d.ts.map +1 -1
  33. package/dist/controllers/NestedAppAuthController.d.ts +96 -0
  34. package/dist/controllers/NestedAppAuthController.d.ts.map +1 -0
  35. package/dist/controllers/NestedAppAuthController.mjs +345 -0
  36. package/dist/controllers/NestedAppAuthController.mjs.map +1 -0
  37. package/dist/controllers/StandardController.d.ts +4 -4
  38. package/dist/controllers/StandardController.d.ts.map +1 -1
  39. package/dist/controllers/StandardController.mjs +43 -42
  40. package/dist/controllers/StandardController.mjs.map +1 -1
  41. package/dist/controllers/UnknownOperatingContextController.d.ts +88 -0
  42. package/dist/controllers/UnknownOperatingContextController.d.ts.map +1 -0
  43. package/dist/controllers/UnknownOperatingContextController.mjs +275 -0
  44. package/dist/controllers/UnknownOperatingContextController.mjs.map +1 -0
  45. package/dist/crypto/BrowserCrypto.d.ts.map +1 -1
  46. package/dist/crypto/BrowserCrypto.mjs +3 -3
  47. package/dist/crypto/BrowserCrypto.mjs.map +1 -1
  48. package/dist/crypto/CryptoOps.d.ts.map +1 -1
  49. package/dist/crypto/CryptoOps.mjs +8 -5
  50. package/dist/crypto/CryptoOps.mjs.map +1 -1
  51. package/dist/crypto/PkceGenerator.mjs +1 -1
  52. package/dist/crypto/SignedHttpRequest.mjs +1 -1
  53. package/dist/encode/Base64Decode.mjs +1 -1
  54. package/dist/encode/Base64Encode.mjs +1 -1
  55. package/dist/error/BrowserAuthError.mjs +1 -1
  56. package/dist/error/BrowserAuthErrorCodes.mjs +1 -1
  57. package/dist/error/BrowserConfigurationAuthError.mjs +1 -1
  58. package/dist/error/BrowserConfigurationAuthErrorCodes.mjs +1 -1
  59. package/dist/error/NativeAuthError.mjs +1 -1
  60. package/dist/error/NativeAuthErrorCodes.mjs +1 -1
  61. package/dist/error/NestedAppAuthError.d.ts +15 -0
  62. package/dist/error/NestedAppAuthError.d.ts.map +1 -0
  63. package/dist/error/NestedAppAuthError.mjs +30 -0
  64. package/dist/error/NestedAppAuthError.mjs.map +1 -0
  65. package/dist/event/EventHandler.mjs +1 -1
  66. package/dist/event/EventMessage.mjs +1 -1
  67. package/dist/event/EventType.mjs +1 -1
  68. package/dist/index.d.ts +3 -5
  69. package/dist/index.d.ts.map +1 -1
  70. package/dist/index.mjs +4 -2
  71. package/dist/index.mjs.map +1 -1
  72. package/dist/interaction_client/BaseInteractionClient.mjs +4 -4
  73. package/dist/interaction_client/HybridSpaAuthorizationCodeClient.mjs +1 -1
  74. package/dist/interaction_client/NativeInteractionClient.d.ts.map +1 -1
  75. package/dist/interaction_client/NativeInteractionClient.mjs +18 -7
  76. package/dist/interaction_client/NativeInteractionClient.mjs.map +1 -1
  77. package/dist/interaction_client/PopupClient.d.ts +1 -2
  78. package/dist/interaction_client/PopupClient.d.ts.map +1 -1
  79. package/dist/interaction_client/PopupClient.mjs +13 -25
  80. package/dist/interaction_client/PopupClient.mjs.map +1 -1
  81. package/dist/interaction_client/RedirectClient.d.ts.map +1 -1
  82. package/dist/interaction_client/RedirectClient.mjs +17 -25
  83. package/dist/interaction_client/RedirectClient.mjs.map +1 -1
  84. package/dist/interaction_client/SilentAuthCodeClient.d.ts.map +1 -1
  85. package/dist/interaction_client/SilentAuthCodeClient.mjs +6 -8
  86. package/dist/interaction_client/SilentAuthCodeClient.mjs.map +1 -1
  87. package/dist/interaction_client/SilentCacheClient.d.ts.map +1 -1
  88. package/dist/interaction_client/SilentCacheClient.mjs +4 -3
  89. package/dist/interaction_client/SilentCacheClient.mjs.map +1 -1
  90. package/dist/interaction_client/SilentIframeClient.d.ts.map +1 -1
  91. package/dist/interaction_client/SilentIframeClient.mjs +28 -19
  92. package/dist/interaction_client/SilentIframeClient.mjs.map +1 -1
  93. package/dist/interaction_client/SilentRefreshClient.d.ts.map +1 -1
  94. package/dist/interaction_client/SilentRefreshClient.mjs +2 -12
  95. package/dist/interaction_client/SilentRefreshClient.mjs.map +1 -1
  96. package/dist/interaction_client/StandardInteractionClient.mjs +5 -5
  97. package/dist/interaction_handler/InteractionHandler.d.ts +6 -13
  98. package/dist/interaction_handler/InteractionHandler.d.ts.map +1 -1
  99. package/dist/interaction_handler/InteractionHandler.mjs +29 -56
  100. package/dist/interaction_handler/InteractionHandler.mjs.map +1 -1
  101. package/dist/interaction_handler/RedirectHandler.d.ts +14 -7
  102. package/dist/interaction_handler/RedirectHandler.d.ts.map +1 -1
  103. package/dist/interaction_handler/RedirectHandler.mjs +28 -9
  104. package/dist/interaction_handler/RedirectHandler.mjs.map +1 -1
  105. package/dist/interaction_handler/SilentHandler.d.ts +13 -47
  106. package/dist/interaction_handler/SilentHandler.d.ts.map +1 -1
  107. package/dist/interaction_handler/SilentHandler.mjs +120 -155
  108. package/dist/interaction_handler/SilentHandler.mjs.map +1 -1
  109. package/dist/naa/AccountInfo.d.ts +13 -0
  110. package/dist/naa/AccountInfo.d.ts.map +1 -0
  111. package/dist/naa/AccountRequests.d.ts +10 -0
  112. package/dist/naa/AccountRequests.d.ts.map +1 -0
  113. package/dist/naa/AuthBridge.d.ts +6 -0
  114. package/dist/naa/AuthBridge.d.ts.map +1 -0
  115. package/dist/naa/BridgeCapabilities.d.ts +4 -0
  116. package/dist/naa/BridgeCapabilities.d.ts.map +1 -0
  117. package/dist/naa/BridgeError.d.ts +10 -0
  118. package/dist/naa/BridgeError.d.ts.map +1 -0
  119. package/dist/naa/BridgeError.mjs +12 -0
  120. package/dist/naa/BridgeError.mjs.map +1 -0
  121. package/dist/naa/BridgeProxy.d.ts +72 -0
  122. package/dist/naa/BridgeProxy.d.ts.map +1 -0
  123. package/dist/naa/BridgeProxy.mjs +154 -0
  124. package/dist/naa/BridgeProxy.mjs.map +1 -0
  125. package/dist/naa/BridgeRequest.d.ts +7 -0
  126. package/dist/naa/BridgeRequest.d.ts.map +1 -0
  127. package/dist/naa/BridgeRequestEnvelope.d.ts +14 -0
  128. package/dist/naa/BridgeRequestEnvelope.d.ts.map +1 -0
  129. package/dist/naa/BridgeResponseEnvelope.d.ts +11 -0
  130. package/dist/naa/BridgeResponseEnvelope.d.ts.map +1 -0
  131. package/dist/naa/BridgeStatusCode.d.ts +11 -0
  132. package/dist/naa/BridgeStatusCode.d.ts.map +1 -0
  133. package/dist/naa/BridgeStatusCode.mjs +20 -0
  134. package/dist/naa/BridgeStatusCode.mjs.map +1 -0
  135. package/dist/naa/IBridgeProxy.d.ts +11 -0
  136. package/dist/naa/IBridgeProxy.d.ts.map +1 -0
  137. package/dist/naa/InitializeBridgeResponse.d.ts +7 -0
  138. package/dist/naa/InitializeBridgeResponse.d.ts.map +1 -0
  139. package/dist/naa/TokenRequest.d.ts +22 -0
  140. package/dist/naa/TokenRequest.d.ts.map +1 -0
  141. package/dist/naa/TokenResponse.d.ts +17 -0
  142. package/dist/naa/TokenResponse.d.ts.map +1 -0
  143. package/dist/naa/mapping/NestedAppAuthAdapter.d.ts +26 -0
  144. package/dist/naa/mapping/NestedAppAuthAdapter.d.ts.map +1 -0
  145. package/dist/naa/mapping/NestedAppAuthAdapter.mjs +178 -0
  146. package/dist/naa/mapping/NestedAppAuthAdapter.mjs.map +1 -0
  147. package/dist/navigation/NavigationClient.mjs +1 -1
  148. package/dist/network/FetchClient.mjs +1 -1
  149. package/dist/operatingcontext/BaseOperatingContext.mjs +1 -1
  150. package/dist/operatingcontext/StandardOperatingContext.mjs +1 -1
  151. package/dist/operatingcontext/TeamsAppOperatingContext.d.ts +7 -0
  152. package/dist/operatingcontext/TeamsAppOperatingContext.d.ts.map +1 -1
  153. package/dist/operatingcontext/TeamsAppOperatingContext.mjs +45 -4
  154. package/dist/operatingcontext/TeamsAppOperatingContext.mjs.map +1 -1
  155. package/dist/operatingcontext/UnknownOperatingContext.d.ts +26 -0
  156. package/dist/operatingcontext/UnknownOperatingContext.d.ts.map +1 -0
  157. package/dist/operatingcontext/UnknownOperatingContext.mjs +49 -0
  158. package/dist/operatingcontext/UnknownOperatingContext.mjs.map +1 -0
  159. package/dist/packageMetadata.d.ts +1 -1
  160. package/dist/packageMetadata.mjs +2 -2
  161. package/dist/telemetry/BrowserPerformanceClient.mjs +1 -1
  162. package/dist/telemetry/BrowserPerformanceMeasurement.mjs +1 -1
  163. package/dist/utils/BrowserConstants.mjs +1 -1
  164. package/dist/utils/BrowserProtocolUtils.mjs +1 -1
  165. package/dist/utils/BrowserUtils.d.ts +54 -53
  166. package/dist/utils/BrowserUtils.d.ts.map +1 -1
  167. package/dist/utils/BrowserUtils.mjs +114 -102
  168. package/dist/utils/BrowserUtils.mjs.map +1 -1
  169. package/lib/msal-browser.cjs +13221 -12385
  170. package/lib/msal-browser.cjs.map +1 -1
  171. package/lib/msal-browser.js +13221 -12385
  172. package/lib/msal-browser.js.map +1 -1
  173. package/lib/msal-browser.min.js +67 -68
  174. package/package.json +2 -2
  175. package/src/app/PublicClientApplication.ts +4 -3
  176. package/src/app/PublicClientNext.ts +444 -0
  177. package/src/cache/BrowserCacheManager.ts +33 -140
  178. package/src/cache/TokenCache.ts +5 -4
  179. package/src/config/Configuration.ts +5 -0
  180. package/src/controllers/ControllerFactory.ts +35 -43
  181. package/src/controllers/IController.ts +0 -6
  182. package/src/controllers/NestedAppAuthController.ts +525 -0
  183. package/src/controllers/StandardController.ts +50 -52
  184. package/src/controllers/UnknownOperatingContextController.ts +383 -0
  185. package/src/crypto/BrowserCrypto.ts +2 -2
  186. package/src/crypto/CryptoOps.ts +8 -5
  187. package/src/error/NestedAppAuthError.ts +32 -0
  188. package/src/index.ts +3 -10
  189. package/src/interaction_client/BaseInteractionClient.ts +1 -1
  190. package/src/interaction_client/NativeInteractionClient.ts +23 -6
  191. package/src/interaction_client/PopupClient.ts +41 -61
  192. package/src/interaction_client/RedirectClient.ts +42 -47
  193. package/src/interaction_client/SilentAuthCodeClient.ts +6 -16
  194. package/src/interaction_client/SilentCacheClient.ts +11 -3
  195. package/src/interaction_client/SilentIframeClient.ts +54 -34
  196. package/src/interaction_client/SilentRefreshClient.ts +5 -19
  197. package/src/interaction_client/StandardInteractionClient.ts +1 -1
  198. package/src/interaction_handler/InteractionHandler.ts +34 -104
  199. package/src/interaction_handler/RedirectHandler.ts +48 -22
  200. package/src/interaction_handler/SilentHandler.ts +177 -233
  201. package/src/naa/AccountInfo.ts +17 -0
  202. package/src/naa/AccountRequests.ts +16 -0
  203. package/src/naa/AuthBridge.ts +16 -0
  204. package/src/naa/BridgeCapabilities.ts +8 -0
  205. package/src/naa/BridgeError.ts +18 -0
  206. package/src/naa/BridgeProxy.ts +230 -0
  207. package/src/naa/BridgeRequest.ts +12 -0
  208. package/src/naa/BridgeRequestEnvelope.ts +46 -0
  209. package/src/naa/BridgeResponseEnvelope.ts +21 -0
  210. package/src/naa/BridgeStatusCode.ts +15 -0
  211. package/src/naa/IBridgeProxy.ts +25 -0
  212. package/src/naa/InitializeBridgeResponse.ts +12 -0
  213. package/src/naa/TokenRequest.ts +26 -0
  214. package/src/naa/TokenResponse.ts +61 -0
  215. package/src/naa/mapping/NestedAppAuthAdapter.ts +252 -0
  216. package/src/operatingcontext/TeamsAppOperatingContext.ts +43 -3
  217. package/src/operatingcontext/UnknownOperatingContext.ts +48 -0
  218. package/src/packageMetadata.ts +1 -1
  219. package/src/utils/BrowserUtils.ts +133 -125
  220. package/dist/utils/BrowserStringUtils.d.ts +0 -22
  221. package/dist/utils/BrowserStringUtils.d.ts.map +0 -1
  222. package/dist/utils/BrowserStringUtils.mjs +0 -144
  223. package/dist/utils/BrowserStringUtils.mjs.map +0 -1
  224. package/src/utils/BrowserStringUtils.ts +0 -143
@@ -35,6 +35,8 @@ import {
35
35
  ClientAuthErrorCodes,
36
36
  PerformanceEvents,
37
37
  IPerformanceClient,
38
+ StaticAuthorityOptions,
39
+ CacheHelpers,
38
40
  } from "@azure/msal-common";
39
41
  import { CacheOptions } from "../config/Configuration";
40
42
  import {
@@ -85,9 +87,10 @@ export class BrowserCacheManager extends CacheManager {
85
87
  clientId: string,
86
88
  cacheConfig: Required<CacheOptions>,
87
89
  cryptoImpl: ICrypto,
88
- logger: Logger
90
+ logger: Logger,
91
+ staticAuthorityOptions?: StaticAuthorityOptions
89
92
  ) {
90
- super(clientId, cryptoImpl, logger);
93
+ super(clientId, cryptoImpl, logger, staticAuthorityOptions);
91
94
  this.cacheConfig = cacheConfig;
92
95
  this.logger = logger;
93
96
  this.internalStorage = new MemoryStorage();
@@ -232,17 +235,15 @@ export class BrowserCacheManager extends CacheManager {
232
235
  if (credObj && credObj.hasOwnProperty("credentialType")) {
233
236
  switch (credObj["credentialType"]) {
234
237
  case CredentialType.ID_TOKEN:
235
- if (IdTokenEntity.isIdTokenEntity(credObj)) {
238
+ if (CacheHelpers.isIdTokenEntity(credObj)) {
236
239
  this.logger.trace(
237
240
  "BrowserCacheManager:createKeyMaps - idToken found, saving key to token key map"
238
241
  );
239
242
  this.logger.tracePii(
240
243
  `BrowserCacheManager:createKeyMaps - idToken with key: ${key} found, saving key to token key map`
241
244
  );
242
- const idTokenEntity = CacheManager.toObject(
243
- new IdTokenEntity(),
244
- credObj
245
- );
245
+ const idTokenEntity =
246
+ credObj as IdTokenEntity;
246
247
  const newKey =
247
248
  this.updateCredentialCacheKey(
248
249
  key,
@@ -264,11 +265,7 @@ export class BrowserCacheManager extends CacheManager {
264
265
  break;
265
266
  case CredentialType.ACCESS_TOKEN:
266
267
  case CredentialType.ACCESS_TOKEN_WITH_AUTH_SCHEME:
267
- if (
268
- AccessTokenEntity.isAccessTokenEntity(
269
- credObj
270
- )
271
- ) {
268
+ if (CacheHelpers.isAccessTokenEntity(credObj)) {
272
269
  this.logger.trace(
273
270
  "BrowserCacheManager:createKeyMaps - accessToken found, saving key to token key map"
274
271
  );
@@ -276,10 +273,7 @@ export class BrowserCacheManager extends CacheManager {
276
273
  `BrowserCacheManager:createKeyMaps - accessToken with key: ${key} found, saving key to token key map`
277
274
  );
278
275
  const accessTokenEntity =
279
- CacheManager.toObject(
280
- new AccessTokenEntity(),
281
- credObj
282
- );
276
+ credObj as AccessTokenEntity;
283
277
  const newKey =
284
278
  this.updateCredentialCacheKey(
285
279
  key,
@@ -301,9 +295,7 @@ export class BrowserCacheManager extends CacheManager {
301
295
  break;
302
296
  case CredentialType.REFRESH_TOKEN:
303
297
  if (
304
- RefreshTokenEntity.isRefreshTokenEntity(
305
- credObj
306
- )
298
+ CacheHelpers.isRefreshTokenEntity(credObj)
307
299
  ) {
308
300
  this.logger.trace(
309
301
  "BrowserCacheManager:createKeyMaps - refreshToken found, saving key to token key map"
@@ -312,10 +304,7 @@ export class BrowserCacheManager extends CacheManager {
312
304
  `BrowserCacheManager:createKeyMaps - refreshToken with key: ${key} found, saving key to token key map`
313
305
  );
314
306
  const refreshTokenEntity =
315
- CacheManager.toObject(
316
- new RefreshTokenEntity(),
317
- credObj
318
- );
307
+ credObj as RefreshTokenEntity;
319
308
  const newKey =
320
309
  this.updateCredentialCacheKey(
321
310
  key,
@@ -716,7 +705,7 @@ export class BrowserCacheManager extends CacheManager {
716
705
  }
717
706
 
718
707
  const parsedIdToken = this.validateAndParseJson(value);
719
- if (!parsedIdToken || !IdTokenEntity.isIdTokenEntity(parsedIdToken)) {
708
+ if (!parsedIdToken || !CacheHelpers.isIdTokenEntity(parsedIdToken)) {
720
709
  this.logger.trace(
721
710
  "BrowserCacheManager.getIdTokenCredential: called, no cache hit"
722
711
  );
@@ -727,7 +716,7 @@ export class BrowserCacheManager extends CacheManager {
727
716
  this.logger.trace(
728
717
  "BrowserCacheManager.getIdTokenCredential: cache hit"
729
718
  );
730
- return CacheManager.toObject(new IdTokenEntity(), parsedIdToken);
719
+ return parsedIdToken as IdTokenEntity;
731
720
  }
732
721
 
733
722
  /**
@@ -736,7 +725,7 @@ export class BrowserCacheManager extends CacheManager {
736
725
  */
737
726
  setIdTokenCredential(idToken: IdTokenEntity): void {
738
727
  this.logger.trace("BrowserCacheManager.setIdTokenCredential called");
739
- const idTokenKey = idToken.generateCredentialKey();
728
+ const idTokenKey = CacheHelpers.generateCredentialKey(idToken);
740
729
 
741
730
  this.setItem(idTokenKey, JSON.stringify(idToken));
742
731
 
@@ -759,7 +748,7 @@ export class BrowserCacheManager extends CacheManager {
759
748
  const parsedAccessToken = this.validateAndParseJson(value);
760
749
  if (
761
750
  !parsedAccessToken ||
762
- !AccessTokenEntity.isAccessTokenEntity(parsedAccessToken)
751
+ !CacheHelpers.isAccessTokenEntity(parsedAccessToken)
763
752
  ) {
764
753
  this.logger.trace(
765
754
  "BrowserCacheManager.getAccessTokenCredential: called, no cache hit"
@@ -771,10 +760,7 @@ export class BrowserCacheManager extends CacheManager {
771
760
  this.logger.trace(
772
761
  "BrowserCacheManager.getAccessTokenCredential: cache hit"
773
762
  );
774
- return CacheManager.toObject(
775
- new AccessTokenEntity(),
776
- parsedAccessToken
777
- );
763
+ return parsedAccessToken as AccessTokenEntity;
778
764
  }
779
765
 
780
766
  /**
@@ -785,7 +771,7 @@ export class BrowserCacheManager extends CacheManager {
785
771
  this.logger.trace(
786
772
  "BrowserCacheManager.setAccessTokenCredential called"
787
773
  );
788
- const accessTokenKey = accessToken.generateCredentialKey();
774
+ const accessTokenKey = CacheHelpers.generateCredentialKey(accessToken);
789
775
  this.setItem(accessTokenKey, JSON.stringify(accessToken));
790
776
 
791
777
  this.addTokenKey(accessTokenKey, CredentialType.ACCESS_TOKEN);
@@ -809,7 +795,7 @@ export class BrowserCacheManager extends CacheManager {
809
795
  const parsedRefreshToken = this.validateAndParseJson(value);
810
796
  if (
811
797
  !parsedRefreshToken ||
812
- !RefreshTokenEntity.isRefreshTokenEntity(parsedRefreshToken)
798
+ !CacheHelpers.isRefreshTokenEntity(parsedRefreshToken)
813
799
  ) {
814
800
  this.logger.trace(
815
801
  "BrowserCacheManager.getRefreshTokenCredential: called, no cache hit"
@@ -821,10 +807,7 @@ export class BrowserCacheManager extends CacheManager {
821
807
  this.logger.trace(
822
808
  "BrowserCacheManager.getRefreshTokenCredential: cache hit"
823
809
  );
824
- return CacheManager.toObject(
825
- new RefreshTokenEntity(),
826
- parsedRefreshToken
827
- );
810
+ return parsedRefreshToken as RefreshTokenEntity;
828
811
  }
829
812
 
830
813
  /**
@@ -835,7 +818,8 @@ export class BrowserCacheManager extends CacheManager {
835
818
  this.logger.trace(
836
819
  "BrowserCacheManager.setRefreshTokenCredential called"
837
820
  );
838
- const refreshTokenKey = refreshToken.generateCredentialKey();
821
+ const refreshTokenKey =
822
+ CacheHelpers.generateCredentialKey(refreshToken);
839
823
  this.setItem(refreshTokenKey, JSON.stringify(refreshToken));
840
824
 
841
825
  this.addTokenKey(refreshTokenKey, CredentialType.REFRESH_TOKEN);
@@ -1028,10 +1012,9 @@ export class BrowserCacheManager extends CacheManager {
1028
1012
  );
1029
1013
  return null;
1030
1014
  }
1031
- const activeAccount =
1032
- this.getAccountInfoByFilter({
1033
- localAccountId: activeAccountValueLocal,
1034
- })[0] || null;
1015
+ const activeAccount = this.getAccountInfoFilteredBy({
1016
+ localAccountId: activeAccountValueLocal,
1017
+ });
1035
1018
  if (activeAccount) {
1036
1019
  this.logger.trace(
1037
1020
  "BrowserCacheManager.getActiveAccount: Legacy active account cache schema found"
@@ -1051,12 +1034,10 @@ export class BrowserCacheManager extends CacheManager {
1051
1034
  this.logger.trace(
1052
1035
  "BrowserCacheManager.getActiveAccount: Active account filters schema found"
1053
1036
  );
1054
- return (
1055
- this.getAccountInfoByFilter({
1056
- homeAccountId: activeAccountValueObj.homeAccountId,
1057
- localAccountId: activeAccountValueObj.localAccountId,
1058
- })[0] || null
1059
- );
1037
+ return this.getAccountInfoFilteredBy({
1038
+ homeAccountId: activeAccountValueObj.homeAccountId,
1039
+ localAccountId: activeAccountValueObj.localAccountId,
1040
+ });
1060
1041
  }
1061
1042
  this.logger.trace(
1062
1043
  "BrowserCacheManager.getActiveAccount: No active account found"
@@ -1098,94 +1079,6 @@ export class BrowserCacheManager extends CacheManager {
1098
1079
  }
1099
1080
  }
1100
1081
 
1101
- /**
1102
- * Gets a list of accounts that match all of the filters provided
1103
- * @param account
1104
- */
1105
- getAccountInfoByFilter(
1106
- accountFilter: Partial<Omit<AccountInfo, "idTokenClaims" | "name">>
1107
- ): AccountInfo[] {
1108
- const allAccounts = this.getAllAccounts();
1109
- this.logger.trace(
1110
- `BrowserCacheManager.getAccountInfoByFilter: total ${allAccounts.length} accounts found`
1111
- );
1112
-
1113
- return allAccounts.filter((accountObj) => {
1114
- if (
1115
- accountFilter.username &&
1116
- accountFilter.username.toLowerCase() !==
1117
- accountObj.username.toLowerCase()
1118
- ) {
1119
- return false;
1120
- }
1121
-
1122
- if (
1123
- accountFilter.homeAccountId &&
1124
- accountFilter.homeAccountId !== accountObj.homeAccountId
1125
- ) {
1126
- return false;
1127
- }
1128
-
1129
- if (
1130
- accountFilter.localAccountId &&
1131
- accountFilter.localAccountId !== accountObj.localAccountId
1132
- ) {
1133
- return false;
1134
- }
1135
-
1136
- if (
1137
- accountFilter.tenantId &&
1138
- accountFilter.tenantId !== accountObj.tenantId
1139
- ) {
1140
- return false;
1141
- }
1142
-
1143
- if (
1144
- accountFilter.environment &&
1145
- accountFilter.environment !== accountObj.environment
1146
- ) {
1147
- return false;
1148
- }
1149
-
1150
- return true;
1151
- });
1152
- }
1153
-
1154
- /**
1155
- * Checks the cache for accounts matching loginHint or SID
1156
- * @param loginHint
1157
- * @param sid
1158
- */
1159
- getAccountInfoByHints(
1160
- loginHint?: string,
1161
- sid?: string
1162
- ): AccountInfo | null {
1163
- const matchingAccounts = this.getAllAccounts().filter((accountInfo) => {
1164
- if (sid) {
1165
- const accountSid =
1166
- accountInfo.idTokenClaims &&
1167
- accountInfo.idTokenClaims["sid"];
1168
- return sid === accountSid;
1169
- }
1170
-
1171
- if (loginHint) {
1172
- return loginHint === accountInfo.username;
1173
- }
1174
-
1175
- return false;
1176
- });
1177
-
1178
- if (matchingAccounts.length === 1) {
1179
- return matchingAccounts[0];
1180
- } else if (matchingAccounts.length > 1) {
1181
- throw createClientAuthError(
1182
- ClientAuthErrorCodes.multipleMatchingAccounts
1183
- );
1184
- }
1185
-
1186
- return null;
1187
- }
1188
-
1189
1082
  /**
1190
1083
  * fetch throttling entity from the platform cache
1191
1084
  * @param throttlingCacheKey
@@ -1893,7 +1786,7 @@ export class BrowserCacheManager extends CacheManager {
1893
1786
  currentCacheKey: string,
1894
1787
  credential: ValidCredentialType
1895
1788
  ): string {
1896
- const updatedCacheKey = credential.generateCredentialKey();
1789
+ const updatedCacheKey = CacheHelpers.generateCredentialKey(credential);
1897
1790
 
1898
1791
  if (currentCacheKey !== updatedCacheKey) {
1899
1792
  const cacheItem = this.getItem(currentCacheKey);
@@ -1949,7 +1842,7 @@ export class BrowserCacheManager extends CacheManager {
1949
1842
  | RedirectRequest
1950
1843
  | PopupRequest
1951
1844
  ): Promise<void> {
1952
- const idTokenEntity = IdTokenEntity.createIdTokenEntity(
1845
+ const idTokenEntity = CacheHelpers.createIdTokenEntity(
1953
1846
  result.account?.homeAccountId,
1954
1847
  result.account?.environment,
1955
1848
  result.idToken,
@@ -1961,7 +1854,7 @@ export class BrowserCacheManager extends CacheManager {
1961
1854
  if (request.claims) {
1962
1855
  claimsHash = await this.cryptoImpl.hashString(request.claims);
1963
1856
  }
1964
- const accessTokenEntity = AccessTokenEntity.createAccessTokenEntity(
1857
+ const accessTokenEntity = CacheHelpers.createAccessTokenEntity(
1965
1858
  result.account?.homeAccountId,
1966
1859
  result.account.environment,
1967
1860
  result.accessToken,
@@ -1970,7 +1863,7 @@ export class BrowserCacheManager extends CacheManager {
1970
1863
  result.scopes.join(" "),
1971
1864
  result.expiresOn?.getTime() || 0,
1972
1865
  result.extExpiresOn?.getTime() || 0,
1973
- this.cryptoImpl,
1866
+ base64Decode,
1974
1867
  undefined, // refreshOn
1975
1868
  result.tokenType as AuthenticationScheme,
1976
1869
  undefined, // userAssertionHash
@@ -18,6 +18,7 @@ import {
18
18
  Constants,
19
19
  CacheRecord,
20
20
  TokenClaims,
21
+ CacheHelpers,
21
22
  } from "@azure/msal-common";
22
23
  import { BrowserConfiguration } from "../config/Configuration";
23
24
  import { SilentRequest } from "../request/SilentRequest";
@@ -294,7 +295,7 @@ export class TokenCache implements ITokenCache {
294
295
  environment: string,
295
296
  tenantId: string
296
297
  ): IdTokenEntity {
297
- const idTokenEntity = IdTokenEntity.createIdTokenEntity(
298
+ const idTokenEntity = CacheHelpers.createIdTokenEntity(
298
299
  homeAccountId,
299
300
  environment,
300
301
  idToken,
@@ -355,7 +356,7 @@ export class TokenCache implements ITokenCache {
355
356
  response.expires_in + new Date().getTime() / 1000;
356
357
  const extendedExpiresOn = options.extendedExpiresOn;
357
358
 
358
- const accessTokenEntity = AccessTokenEntity.createAccessTokenEntity(
359
+ const accessTokenEntity = CacheHelpers.createAccessTokenEntity(
359
360
  homeAccountId,
360
361
  environment,
361
362
  response.access_token,
@@ -364,7 +365,7 @@ export class TokenCache implements ITokenCache {
364
365
  scopes,
365
366
  expiresOn,
366
367
  extendedExpiresOn,
367
- this.cryptoObj
368
+ base64Decode
368
369
  );
369
370
 
370
371
  if (this.isBrowserEnvironment) {
@@ -399,7 +400,7 @@ export class TokenCache implements ITokenCache {
399
400
  return null;
400
401
  }
401
402
 
402
- const refreshTokenEntity = RefreshTokenEntity.createRefreshTokenEntity(
403
+ const refreshTokenEntity = CacheHelpers.createRefreshTokenEntity(
403
404
  homeAccountId,
404
405
  environment,
405
406
  response.refresh_token,
@@ -93,6 +93,10 @@ export type BrowserAuthOptions = {
93
93
  * Flag of whether to use the local metadata cache
94
94
  */
95
95
  skipAuthorityMetadataCache?: boolean;
96
+ /**
97
+ * App supports nested app auth or not; defaults to false
98
+ */
99
+ supportsNestedAppAuth?: boolean;
96
100
  };
97
101
 
98
102
  /** @internal */
@@ -273,6 +277,7 @@ export function buildConfiguration(
273
277
  tenant: Constants.EMPTY_STRING,
274
278
  },
275
279
  skipAuthorityMetadataCache: false,
280
+ supportsNestedAppAuth: false,
276
281
  };
277
282
 
278
283
  // Default cache options for browser
@@ -6,50 +6,42 @@
6
6
  import { TeamsAppOperatingContext } from "../operatingcontext/TeamsAppOperatingContext";
7
7
  import { StandardOperatingContext } from "../operatingcontext/StandardOperatingContext";
8
8
  import { IController } from "./IController";
9
- import { Logger } from "@azure/msal-common";
10
9
  import { Configuration } from "../config/Configuration";
11
- import { version, name } from "../packageMetadata";
12
-
13
- export class ControllerFactory {
14
- protected config: Configuration;
15
- protected logger: Logger;
16
-
17
- constructor(config: Configuration) {
18
- this.config = config;
19
- const loggerOptions = {
20
- loggerCallback: undefined,
21
- piiLoggingEnabled: false,
22
- logLevel: undefined,
23
- correlationId: undefined,
24
- };
25
- this.logger = new Logger(loggerOptions, name, version);
26
- }
27
10
 
28
- async createController(): Promise<IController> {
29
- const standard = new StandardOperatingContext(this.config);
30
- const metaOS = new TeamsAppOperatingContext(this.config);
31
-
32
- const operatingContexts = [standard.initialize(), metaOS.initialize()];
33
-
34
- return Promise.all(operatingContexts).then(async () => {
35
- if (metaOS.isAvailable()) {
36
- /*
37
- * pull down metaos module
38
- * create associated controller
39
- */
40
- // return await StandardController.createController(standard);
41
- const controller = await import("./StandardController");
42
- return await controller.StandardController.createController(
43
- standard
44
- );
45
- } else if (standard.isAvailable()) {
46
- const controller = await import("./StandardController");
47
- return await controller.StandardController.createController(
48
- standard
49
- );
50
- }
51
-
52
- throw new Error("No controller found.");
53
- });
11
+ export async function createV3Controller(
12
+ config: Configuration
13
+ ): Promise<IController> {
14
+ const standard = new StandardOperatingContext(config);
15
+
16
+ await standard.initialize();
17
+
18
+ const controller = await import("./StandardController");
19
+ return await controller.StandardController.createController(standard);
20
+ }
21
+
22
+ export async function createController(
23
+ config: Configuration
24
+ ): Promise<IController | null> {
25
+ const standard = new StandardOperatingContext(config);
26
+ const teamsApp = new TeamsAppOperatingContext(config);
27
+
28
+ const operatingContexts = [standard.initialize(), teamsApp.initialize()];
29
+
30
+ await Promise.all(operatingContexts);
31
+
32
+ if (
33
+ teamsApp.isAvailable() &&
34
+ teamsApp.getConfig().auth.supportsNestedAppAuth
35
+ ) {
36
+ const controller = await import("./NestedAppAuthController");
37
+ return await controller.NestedAppAuthController.createController(
38
+ teamsApp
39
+ );
40
+ } else if (standard.isAvailable()) {
41
+ const controller = await import("./StandardController");
42
+ return await controller.StandardController.createController(standard);
43
+ } else {
44
+ // Since neither of the actual operating contexts are available keep the UnknownOperatingContextController
45
+ return null;
54
46
  }
55
47
  }
@@ -8,7 +8,6 @@ import {
8
8
  Logger,
9
9
  PerformanceCallbackFunction,
10
10
  IPerformanceClient,
11
- CommonSilentFlowRequest,
12
11
  AccountFilter,
13
12
  } from "@azure/msal-common";
14
13
  import { RedirectRequest } from "../request/RedirectRequest";
@@ -48,11 +47,6 @@ export interface IController {
48
47
  accountId?: string
49
48
  ): Promise<AuthenticationResult>;
50
49
 
51
- acquireTokenByRefreshToken(
52
- commonRequest: CommonSilentFlowRequest,
53
- silentRequest: SilentRequest
54
- ): Promise<AuthenticationResult>;
55
-
56
50
  addEventCallback(callback: EventCallbackFunction): string | null;
57
51
 
58
52
  removeEventCallback(callbackId: string): void;