@azure/msal-browser 3.13.0 → 3.15.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 (153) hide show
  1. package/dist/app/IPublicClientApplication.d.ts +2 -1
  2. package/dist/app/IPublicClientApplication.d.ts.map +1 -1
  3. package/dist/app/IPublicClientApplication.mjs +4 -1
  4. package/dist/app/IPublicClientApplication.mjs.map +1 -1
  5. package/dist/app/PublicClientApplication.d.ts +17 -0
  6. package/dist/app/PublicClientApplication.d.ts.map +1 -1
  7. package/dist/app/PublicClientApplication.mjs +37 -9
  8. package/dist/app/PublicClientApplication.mjs.map +1 -1
  9. package/dist/app/PublicClientNext.d.ts +3 -0
  10. package/dist/app/PublicClientNext.d.ts.map +1 -1
  11. package/dist/app/PublicClientNext.mjs +4 -1
  12. package/dist/app/PublicClientNext.mjs.map +1 -1
  13. package/dist/broker/nativeBroker/NativeMessageHandler.mjs +1 -1
  14. package/dist/broker/nativeBroker/NativeStatusCodes.mjs +1 -1
  15. package/dist/cache/AccountManager.d.ts +49 -0
  16. package/dist/cache/AccountManager.d.ts.map +1 -0
  17. package/dist/cache/AccountManager.mjs +131 -0
  18. package/dist/cache/AccountManager.mjs.map +1 -0
  19. package/dist/cache/AsyncMemoryStorage.mjs +1 -1
  20. package/dist/cache/BrowserCacheManager.d.ts.map +1 -1
  21. package/dist/cache/BrowserCacheManager.mjs +9 -2
  22. package/dist/cache/BrowserCacheManager.mjs.map +1 -1
  23. package/dist/cache/BrowserStorage.mjs +1 -1
  24. package/dist/cache/DatabaseStorage.mjs +1 -1
  25. package/dist/cache/MemoryStorage.mjs +1 -1
  26. package/dist/cache/TokenCache.mjs +1 -1
  27. package/dist/config/Configuration.d.ts +3 -1
  28. package/dist/config/Configuration.d.ts.map +1 -1
  29. package/dist/config/Configuration.mjs +1 -1
  30. package/dist/config/Configuration.mjs.map +1 -1
  31. package/dist/controllers/ControllerFactory.d.ts.map +1 -1
  32. package/dist/controllers/ControllerFactory.mjs +10 -12
  33. package/dist/controllers/ControllerFactory.mjs.map +1 -1
  34. package/dist/controllers/NestedAppAuthController.d.ts +118 -10
  35. package/dist/controllers/NestedAppAuthController.d.ts.map +1 -1
  36. package/dist/controllers/NestedAppAuthController.mjs +227 -83
  37. package/dist/controllers/NestedAppAuthController.mjs.map +1 -1
  38. package/dist/controllers/StandardController.d.ts.map +1 -1
  39. package/dist/controllers/StandardController.mjs +98 -115
  40. package/dist/controllers/StandardController.mjs.map +1 -1
  41. package/dist/controllers/UnknownOperatingContextController.mjs +1 -1
  42. package/dist/crypto/BrowserCrypto.mjs +1 -1
  43. package/dist/crypto/CryptoOps.mjs +1 -1
  44. package/dist/crypto/PkceGenerator.mjs +1 -1
  45. package/dist/crypto/SignedHttpRequest.mjs +1 -1
  46. package/dist/encode/Base64Decode.mjs +1 -1
  47. package/dist/encode/Base64Encode.mjs +1 -1
  48. package/dist/error/BrowserAuthError.mjs +1 -1
  49. package/dist/error/BrowserAuthErrorCodes.mjs +1 -1
  50. package/dist/error/BrowserConfigurationAuthError.mjs +1 -1
  51. package/dist/error/BrowserConfigurationAuthErrorCodes.mjs +1 -1
  52. package/dist/error/NativeAuthError.mjs +1 -1
  53. package/dist/error/NativeAuthErrorCodes.mjs +1 -1
  54. package/dist/error/NestedAppAuthError.mjs +1 -1
  55. package/dist/event/EventHandler.mjs +1 -1
  56. package/dist/event/EventMessage.mjs +1 -1
  57. package/dist/event/EventType.mjs +1 -1
  58. package/dist/index.d.ts +1 -1
  59. package/dist/index.d.ts.map +1 -1
  60. package/dist/index.mjs +2 -2
  61. package/dist/interaction_client/BaseInteractionClient.mjs +1 -1
  62. package/dist/interaction_client/HybridSpaAuthorizationCodeClient.mjs +1 -1
  63. package/dist/interaction_client/NativeInteractionClient.mjs +1 -1
  64. package/dist/interaction_client/PopupClient.mjs +1 -1
  65. package/dist/interaction_client/RedirectClient.d.ts +4 -5
  66. package/dist/interaction_client/RedirectClient.d.ts.map +1 -1
  67. package/dist/interaction_client/RedirectClient.mjs +5 -8
  68. package/dist/interaction_client/RedirectClient.mjs.map +1 -1
  69. package/dist/interaction_client/SilentAuthCodeClient.mjs +1 -1
  70. package/dist/interaction_client/SilentCacheClient.mjs +1 -1
  71. package/dist/interaction_client/SilentIframeClient.mjs +1 -1
  72. package/dist/interaction_client/SilentRefreshClient.mjs +1 -1
  73. package/dist/interaction_client/StandardInteractionClient.mjs +1 -1
  74. package/dist/interaction_handler/InteractionHandler.mjs +1 -1
  75. package/dist/interaction_handler/RedirectHandler.mjs +1 -1
  76. package/dist/interaction_handler/SilentHandler.mjs +1 -1
  77. package/dist/naa/BridgeAccountContext.d.ts +13 -0
  78. package/dist/naa/BridgeAccountContext.d.ts.map +1 -0
  79. package/dist/naa/BridgeCapabilities.d.ts +1 -1
  80. package/dist/naa/BridgeCapabilities.d.ts.map +1 -1
  81. package/dist/naa/BridgeError.mjs +1 -1
  82. package/dist/naa/BridgeProxy.d.ts +3 -2
  83. package/dist/naa/BridgeProxy.d.ts.map +1 -1
  84. package/dist/naa/BridgeProxy.mjs +9 -7
  85. package/dist/naa/BridgeProxy.mjs.map +1 -1
  86. package/dist/naa/BridgeRequestEnvelope.d.ts +1 -1
  87. package/dist/naa/BridgeRequestEnvelope.d.ts.map +1 -1
  88. package/dist/naa/BridgeStatusCode.mjs +1 -1
  89. package/dist/naa/IBridgeProxy.d.ts +2 -2
  90. package/dist/naa/IBridgeProxy.d.ts.map +1 -1
  91. package/dist/naa/InitContext.d.ts +2 -0
  92. package/dist/naa/InitContext.d.ts.map +1 -1
  93. package/dist/naa/mapping/NestedAppAuthAdapter.d.ts +12 -2
  94. package/dist/naa/mapping/NestedAppAuthAdapter.d.ts.map +1 -1
  95. package/dist/naa/mapping/NestedAppAuthAdapter.mjs +43 -6
  96. package/dist/naa/mapping/NestedAppAuthAdapter.mjs.map +1 -1
  97. package/dist/navigation/NavigationClient.mjs +1 -1
  98. package/dist/network/FetchClient.mjs +1 -1
  99. package/dist/operatingcontext/BaseOperatingContext.mjs +1 -1
  100. package/dist/operatingcontext/{TeamsAppOperatingContext.d.ts → NestedAppOperatingContext.d.ts} +8 -6
  101. package/dist/operatingcontext/NestedAppOperatingContext.d.ts.map +1 -0
  102. package/dist/operatingcontext/{TeamsAppOperatingContext.mjs → NestedAppOperatingContext.mjs} +21 -35
  103. package/dist/operatingcontext/NestedAppOperatingContext.mjs.map +1 -0
  104. package/dist/operatingcontext/StandardOperatingContext.d.ts.map +1 -1
  105. package/dist/operatingcontext/StandardOperatingContext.mjs +1 -1
  106. package/dist/operatingcontext/StandardOperatingContext.mjs.map +1 -1
  107. package/dist/operatingcontext/UnknownOperatingContext.d.ts +5 -5
  108. package/dist/operatingcontext/UnknownOperatingContext.d.ts.map +1 -1
  109. package/dist/operatingcontext/UnknownOperatingContext.mjs +8 -8
  110. package/dist/operatingcontext/UnknownOperatingContext.mjs.map +1 -1
  111. package/dist/packageMetadata.d.ts +1 -1
  112. package/dist/packageMetadata.mjs +2 -2
  113. package/dist/request/RequestHelpers.mjs +1 -1
  114. package/dist/response/ResponseHandler.mjs +1 -1
  115. package/dist/telemetry/BrowserPerformanceClient.mjs +1 -1
  116. package/dist/telemetry/BrowserPerformanceMeasurement.mjs +1 -1
  117. package/dist/utils/BrowserConstants.mjs +1 -1
  118. package/dist/utils/BrowserProtocolUtils.mjs +1 -1
  119. package/dist/utils/BrowserUtils.d.ts +3 -0
  120. package/dist/utils/BrowserUtils.d.ts.map +1 -1
  121. package/dist/utils/BrowserUtils.mjs +2 -1
  122. package/dist/utils/BrowserUtils.mjs.map +1 -1
  123. package/lib/msal-browser.cjs +10568 -10231
  124. package/lib/msal-browser.cjs.map +1 -1
  125. package/lib/msal-browser.js +10568 -10231
  126. package/lib/msal-browser.js.map +1 -1
  127. package/lib/msal-browser.min.js +69 -68
  128. package/package.json +6 -4
  129. package/src/app/IPublicClientApplication.ts +5 -0
  130. package/src/app/PublicClientApplication.ts +43 -8
  131. package/src/app/PublicClientNext.ts +3 -0
  132. package/src/cache/AccountManager.ts +184 -0
  133. package/src/cache/BrowserCacheManager.ts +11 -2
  134. package/src/config/Configuration.ts +3 -1
  135. package/src/controllers/ControllerFactory.ts +9 -14
  136. package/src/controllers/NestedAppAuthController.ts +375 -82
  137. package/src/controllers/StandardController.ts +125 -149
  138. package/src/index.ts +5 -1
  139. package/src/interaction_client/RedirectClient.ts +6 -12
  140. package/src/naa/BridgeAccountContext.ts +17 -0
  141. package/src/naa/BridgeCapabilities.ts +2 -1
  142. package/src/naa/BridgeProxy.ts +11 -6
  143. package/src/naa/BridgeRequestEnvelope.ts +1 -6
  144. package/src/naa/IBridgeProxy.ts +2 -2
  145. package/src/naa/InitContext.ts +2 -0
  146. package/src/naa/mapping/NestedAppAuthAdapter.ts +68 -2
  147. package/src/operatingcontext/{TeamsAppOperatingContext.ts → NestedAppOperatingContext.ts} +23 -31
  148. package/src/operatingcontext/StandardOperatingContext.ts +1 -0
  149. package/src/operatingcontext/UnknownOperatingContext.ts +8 -7
  150. package/src/packageMetadata.ts +1 -1
  151. package/src/utils/BrowserUtils.ts +4 -1
  152. package/dist/operatingcontext/TeamsAppOperatingContext.d.ts.map +0 -1
  153. package/dist/operatingcontext/TeamsAppOperatingContext.mjs.map +0 -1
package/package.json CHANGED
@@ -10,7 +10,7 @@
10
10
  "type": "git",
11
11
  "url": "https://github.com/AzureAD/microsoft-authentication-library-for-js.git"
12
12
  },
13
- "version": "3.13.0",
13
+ "version": "3.15.0",
14
14
  "description": "Microsoft Authentication Library for js",
15
15
  "keywords": [
16
16
  "implicit",
@@ -69,7 +69,8 @@
69
69
  "build": "npm run clean && npm run build:modules",
70
70
  "prepack": "npm run build:all",
71
71
  "format:check": "prettier --ignore-path .gitignore --check src test",
72
- "format:fix": "prettier --ignore-path .gitignore --write src test"
72
+ "format:fix": "prettier --ignore-path .gitignore --write src test",
73
+ "apiExtractor": "api-extractor run"
73
74
  },
74
75
  "devDependencies": {
75
76
  "@azure/storage-blob": "^12.2.1",
@@ -78,6 +79,7 @@
78
79
  "@babel/plugin-proposal-object-rest-spread": "^7.6.2",
79
80
  "@babel/preset-env": "^7.7.1",
80
81
  "@babel/preset-typescript": "^7.7.2",
82
+ "@microsoft/api-extractor": "^7.43.4",
81
83
  "@rollup/plugin-node-resolve": "^15.0.1",
82
84
  "@rollup/plugin-terser": "^0.4.0",
83
85
  "@rollup/plugin-typescript": "^11.0.0",
@@ -90,7 +92,7 @@
90
92
  "jest": "^29.5.0",
91
93
  "jest-environment-jsdom": "^29.5.0",
92
94
  "msal-test-utils": "file:../../shared-test-utils",
93
- "prettier": "2.8.7",
95
+ "prettier": "^2.8.7",
94
96
  "rimraf": "^3.0.0",
95
97
  "rollup": "^3.14.0",
96
98
  "shx": "^0.3.2",
@@ -101,6 +103,6 @@
101
103
  "typescript": "^4.9.5"
102
104
  },
103
105
  "dependencies": {
104
- "@azure/msal-common": "14.9.0"
106
+ "@azure/msal-common": "14.10.0"
105
107
  }
106
108
  }
@@ -4,6 +4,7 @@
4
4
  */
5
5
 
6
6
  import {
7
+ AccountFilter,
7
8
  AccountInfo,
8
9
  Logger,
9
10
  PerformanceCallbackFunction,
@@ -43,6 +44,7 @@ export interface IPublicClientApplication {
43
44
  removePerformanceCallback(callbackId: string): boolean;
44
45
  enableAccountStorageEvents(): void;
45
46
  disableAccountStorageEvents(): void;
47
+ getAccount(accountFilter: AccountFilter): AccountInfo | null;
46
48
  getAccountByHomeId(homeAccountId: string): AccountInfo | null;
47
49
  getAccountByLocalId(localId: string): AccountInfo | null;
48
50
  getAccountByUsername(userName: string): AccountInfo | null;
@@ -113,6 +115,9 @@ export const stubbedPublicClientApplication: IPublicClientApplication = {
113
115
  getAllAccounts: () => {
114
116
  return [];
115
117
  },
118
+ getAccount: () => {
119
+ return null;
120
+ },
116
121
  getAccountByHomeId: () => {
117
122
  return null;
118
123
  },
@@ -28,6 +28,8 @@ import { AuthenticationResult } from "../response/AuthenticationResult";
28
28
  import { EventCallbackFunction } from "../event/EventMessage";
29
29
  import { ClearCacheRequest } from "../request/ClearCacheRequest";
30
30
  import { EndSessionPopupRequest } from "../request/EndSessionPopupRequest";
31
+ import { NestedAppAuthController } from "../controllers/NestedAppAuthController";
32
+ import { NestedAppOperatingContext } from "../operatingcontext/NestedAppOperatingContext";
31
33
 
32
34
  /**
33
35
  * The PublicClientApplication class is the object exposed by the library to perform authentication and authorization functions in Single Page Applications
@@ -36,6 +38,7 @@ import { EndSessionPopupRequest } from "../request/EndSessionPopupRequest";
36
38
  export class PublicClientApplication implements IPublicClientApplication {
37
39
  protected controller: IController;
38
40
 
41
+ // creates StandardController and passes it to the PublicClientApplication
39
42
  public static async createPublicClientApplication(
40
43
  configuration: Configuration
41
44
  ): Promise<IPublicClientApplication> {
@@ -70,14 +73,9 @@ export class PublicClientApplication implements IPublicClientApplication {
70
73
  * @param IController Optional parameter to explictly set the controller. (Will be removed when we remove public constructor)
71
74
  */
72
75
  public constructor(configuration: Configuration, controller?: IController) {
73
- if (controller) {
74
- this.controller = controller;
75
- } else {
76
- const standardOperatingContext = new StandardOperatingContext(
77
- configuration
78
- );
79
- this.controller = new StandardController(standardOperatingContext);
80
- }
76
+ this.controller =
77
+ controller ||
78
+ new StandardController(new StandardOperatingContext(configuration));
81
79
  }
82
80
 
83
81
  /**
@@ -417,3 +415,40 @@ export class PublicClientApplication implements IPublicClientApplication {
417
415
  return this.controller.clearCache(logoutRequest);
418
416
  }
419
417
  }
418
+
419
+ /**
420
+ * creates NestedAppAuthController and passes it to the PublicClientApplication,
421
+ * falls back to StandardController if NestedAppAuthController is not available
422
+ *
423
+ * @param configuration
424
+ * @returns IPublicClientApplication
425
+ *
426
+ */
427
+ export async function createNestablePublicClientApplication(
428
+ configuration: Configuration
429
+ ): Promise<IPublicClientApplication> {
430
+ const nestedAppAuth = new NestedAppOperatingContext(configuration);
431
+ await nestedAppAuth.initialize();
432
+
433
+ if (nestedAppAuth.isAvailable()) {
434
+ const controller = new NestedAppAuthController(nestedAppAuth);
435
+ return new PublicClientApplication(configuration, controller);
436
+ }
437
+
438
+ return createStandardPublicClientApplication(configuration);
439
+ }
440
+
441
+ /**
442
+ * creates PublicClientApplication using StandardController
443
+ *
444
+ * @param configuration
445
+ * @returns IPublicClientApplication
446
+ *
447
+ */
448
+ export async function createStandardPublicClientApplication(
449
+ configuration: Configuration
450
+ ): Promise<IPublicClientApplication> {
451
+ const pca = new PublicClientApplication(configuration);
452
+ await pca.initialize();
453
+ return pca;
454
+ }
@@ -35,6 +35,9 @@ import { UnknownOperatingContext } from "../operatingcontext/UnknownOperatingCon
35
35
  * The goals of these changes are to provide a clean separation of behavior between different operating contexts (Nested App Auth, Platform Brokers, Plain old Browser, etc.)
36
36
  * while still providing a consistent API surface for developers.
37
37
  *
38
+ * Please use PublicClientApplication for any prod/real-world scenarios.
39
+ * Note: PublicClientNext is experimental and subject to breaking changes without following semver
40
+ *
38
41
  */
39
42
  export class PublicClientNext implements IPublicClientApplication {
40
43
  /*
@@ -0,0 +1,184 @@
1
+ /*
2
+ * Copyright (c) Microsoft Corporation. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+
6
+ import { AccountInfo, AccountFilter, Logger } from "@azure/msal-common";
7
+ import { BrowserCacheManager } from "./BrowserCacheManager";
8
+
9
+ /**
10
+ * Returns all the accounts in the cache that match the optional filter. If no filter is provided, all accounts are returned.
11
+ * @param accountFilter - (Optional) filter to narrow down the accounts returned
12
+ * @returns Array of AccountInfo objects in cache
13
+ */
14
+ export function getAllAccounts(
15
+ logger: Logger,
16
+ browserStorage: BrowserCacheManager,
17
+ isInBrowser: boolean,
18
+ accountFilter?: AccountFilter
19
+ ): AccountInfo[] {
20
+ logger.verbose("getAllAccounts called");
21
+ return isInBrowser ? browserStorage.getAllAccounts(accountFilter) : [];
22
+ }
23
+
24
+ /**
25
+ * Returns the first account found in the cache that matches the account filter passed in.
26
+ * @param accountFilter
27
+ * @returns The first account found in the cache matching the provided filter or null if no account could be found.
28
+ */
29
+ export function getAccount(
30
+ accountFilter: AccountFilter,
31
+ logger: Logger,
32
+ browserStorage: BrowserCacheManager
33
+ ): AccountInfo | null {
34
+ logger.trace("getAccount called");
35
+ if (Object.keys(accountFilter).length === 0) {
36
+ logger.warning("getAccount: No accountFilter provided");
37
+ return null;
38
+ }
39
+
40
+ const account: AccountInfo | null =
41
+ browserStorage.getAccountInfoFilteredBy(accountFilter);
42
+
43
+ if (account) {
44
+ logger.verbose(
45
+ "getAccount: Account matching provided filter found, returning"
46
+ );
47
+ return account;
48
+ } else {
49
+ logger.verbose("getAccount: No matching account found, returning null");
50
+ return null;
51
+ }
52
+ }
53
+
54
+ /**
55
+ * Returns the signed in account matching username.
56
+ * (the account object is created at the time of successful login)
57
+ * or null when no matching account is found.
58
+ * This API is provided for convenience but getAccountById should be used for best reliability
59
+ * @param username
60
+ * @returns The account object stored in MSAL
61
+ */
62
+ export function getAccountByUsername(
63
+ username: string,
64
+ logger: Logger,
65
+ browserStorage: BrowserCacheManager
66
+ ): AccountInfo | null {
67
+ logger.trace("getAccountByUsername called");
68
+ if (!username) {
69
+ logger.warning("getAccountByUsername: No username provided");
70
+ return null;
71
+ }
72
+
73
+ const account = browserStorage.getAccountInfoFilteredBy({
74
+ username,
75
+ });
76
+ if (account) {
77
+ logger.verbose(
78
+ "getAccountByUsername: Account matching username found, returning"
79
+ );
80
+ logger.verbosePii(
81
+ `getAccountByUsername: Returning signed-in accounts matching username: ${username}`
82
+ );
83
+ return account;
84
+ } else {
85
+ logger.verbose(
86
+ "getAccountByUsername: No matching account found, returning null"
87
+ );
88
+ return null;
89
+ }
90
+ }
91
+
92
+ /**
93
+ * Returns the signed in account matching homeAccountId.
94
+ * (the account object is created at the time of successful login)
95
+ * or null when no matching account is found
96
+ * @param homeAccountId
97
+ * @returns The account object stored in MSAL
98
+ */
99
+ export function getAccountByHomeId(
100
+ homeAccountId: string,
101
+ logger: Logger,
102
+ browserStorage: BrowserCacheManager
103
+ ): AccountInfo | null {
104
+ logger.trace("getAccountByHomeId called");
105
+ if (!homeAccountId) {
106
+ logger.warning("getAccountByHomeId: No homeAccountId provided");
107
+ return null;
108
+ }
109
+
110
+ const account = browserStorage.getAccountInfoFilteredBy({
111
+ homeAccountId,
112
+ });
113
+ if (account) {
114
+ logger.verbose(
115
+ "getAccountByHomeId: Account matching homeAccountId found, returning"
116
+ );
117
+ logger.verbosePii(
118
+ `getAccountByHomeId: Returning signed-in accounts matching homeAccountId: ${homeAccountId}`
119
+ );
120
+ return account;
121
+ } else {
122
+ logger.verbose(
123
+ "getAccountByHomeId: No matching account found, returning null"
124
+ );
125
+ return null;
126
+ }
127
+ }
128
+
129
+ /**
130
+ * Returns the signed in account matching localAccountId.
131
+ * (the account object is created at the time of successful login)
132
+ * or null when no matching account is found
133
+ * @param localAccountId
134
+ * @returns The account object stored in MSAL
135
+ */
136
+ export function getAccountByLocalId(
137
+ localAccountId: string,
138
+ logger: Logger,
139
+ browserStorage: BrowserCacheManager
140
+ ): AccountInfo | null {
141
+ logger.trace("getAccountByLocalId called");
142
+ if (!localAccountId) {
143
+ logger.warning("getAccountByLocalId: No localAccountId provided");
144
+ return null;
145
+ }
146
+
147
+ const account = browserStorage.getAccountInfoFilteredBy({
148
+ localAccountId,
149
+ });
150
+ if (account) {
151
+ logger.verbose(
152
+ "getAccountByLocalId: Account matching localAccountId found, returning"
153
+ );
154
+ logger.verbosePii(
155
+ `getAccountByLocalId: Returning signed-in accounts matching localAccountId: ${localAccountId}`
156
+ );
157
+ return account;
158
+ } else {
159
+ logger.verbose(
160
+ "getAccountByLocalId: No matching account found, returning null"
161
+ );
162
+ return null;
163
+ }
164
+ }
165
+
166
+ /**
167
+ * Sets the account to use as the active account. If no account is passed to the acquireToken APIs, then MSAL will use this active account.
168
+ * @param account
169
+ */
170
+ export function setActiveAccount(
171
+ account: AccountInfo | null,
172
+ browserStorage: BrowserCacheManager
173
+ ): void {
174
+ browserStorage.setActiveAccount(account);
175
+ }
176
+
177
+ /**
178
+ * Gets the currently active account
179
+ */
180
+ export function getActiveAccount(
181
+ browserStorage: BrowserCacheManager
182
+ ): AccountInfo | null {
183
+ return browserStorage.getActiveAccount();
184
+ }
@@ -1837,6 +1837,15 @@ export class BrowserCacheManager extends CacheManager {
1837
1837
  if (request.claims) {
1838
1838
  claimsHash = await this.cryptoImpl.hashString(request.claims);
1839
1839
  }
1840
+
1841
+ /**
1842
+ * meta data for cache stores time in seconds from epoch
1843
+ * AuthenticationResult returns expiresOn and extExpiresOn in milliseconds (as a Date object which is in ms)
1844
+ * We need to map these for the cache when building tokens from AuthenticationResult
1845
+ *
1846
+ * The next MSAL VFuture should map these both to same value if possible
1847
+ */
1848
+
1840
1849
  const accessTokenEntity = CacheHelpers.createAccessTokenEntity(
1841
1850
  result.account?.homeAccountId,
1842
1851
  result.account.environment,
@@ -1844,8 +1853,8 @@ export class BrowserCacheManager extends CacheManager {
1844
1853
  this.clientId,
1845
1854
  result.tenantId,
1846
1855
  result.scopes.join(" "),
1847
- result.expiresOn?.getTime() || 0,
1848
- result.extExpiresOn?.getTime() || 0,
1856
+ result.expiresOn ? result.expiresOn.getTime() / 1000 : 0,
1857
+ result.extExpiresOn ? result.extExpiresOn.getTime() / 1000 : 0,
1849
1858
  base64Decode,
1850
1859
  undefined, // refreshOn
1851
1860
  result.tokenType as AuthenticationScheme,
@@ -94,7 +94,9 @@ export type BrowserAuthOptions = {
94
94
  */
95
95
  skipAuthorityMetadataCache?: boolean;
96
96
  /**
97
- * App supports nested app auth or not; defaults to false
97
+ * App supports nested app auth or not; defaults to
98
+ *
99
+ * @deprecated This flag is deprecated and will be removed in the next major version. createNestablePublicClientApplication should be used instead.
98
100
  */
99
101
  supportsNestedAppAuth?: boolean;
100
102
  };
@@ -3,10 +3,12 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
 
6
- import { TeamsAppOperatingContext } from "../operatingcontext/TeamsAppOperatingContext";
6
+ import { NestedAppOperatingContext } from "../operatingcontext/NestedAppOperatingContext";
7
7
  import { StandardOperatingContext } from "../operatingcontext/StandardOperatingContext";
8
8
  import { IController } from "./IController";
9
9
  import { Configuration } from "../config/Configuration";
10
+ import { StandardController } from "./StandardController";
11
+ import { NestedAppAuthController } from "./NestedAppAuthController";
10
12
 
11
13
  export async function createV3Controller(
12
14
  config: Configuration
@@ -14,30 +16,23 @@ export async function createV3Controller(
14
16
  const standard = new StandardOperatingContext(config);
15
17
 
16
18
  await standard.initialize();
17
-
18
- const controller = await import("./StandardController");
19
- return controller.StandardController.createController(standard);
19
+ return StandardController.createController(standard);
20
20
  }
21
21
 
22
22
  export async function createController(
23
23
  config: Configuration
24
24
  ): Promise<IController | null> {
25
25
  const standard = new StandardOperatingContext(config);
26
- const teamsApp = new TeamsAppOperatingContext(config);
26
+ const nestedApp = new NestedAppOperatingContext(config);
27
27
 
28
- const operatingContexts = [standard.initialize(), teamsApp.initialize()];
28
+ const operatingContexts = [standard.initialize(), nestedApp.initialize()];
29
29
 
30
30
  await Promise.all(operatingContexts);
31
31
 
32
- if (
33
- teamsApp.isAvailable() &&
34
- teamsApp.getConfig().auth.supportsNestedAppAuth
35
- ) {
36
- const controller = await import("./NestedAppAuthController");
37
- return controller.NestedAppAuthController.createController(teamsApp);
32
+ if (nestedApp.isAvailable() && config.auth.supportsNestedAppAuth) {
33
+ return NestedAppAuthController.createController(nestedApp);
38
34
  } else if (standard.isAvailable()) {
39
- const controller = await import("./StandardController");
40
- return controller.StandardController.createController(standard);
35
+ return StandardController.createController(standard);
41
36
  } else {
42
37
  // Since neither of the actual operating contexts are available keep the UnknownOperatingContextController
43
38
  return null;