@azure/msal-browser 3.1.0 → 3.2.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 (180) hide show
  1. package/dist/app/IPublicClientApplication.d.ts.map +1 -1
  2. package/dist/app/IPublicClientApplication.mjs +20 -19
  3. package/dist/app/IPublicClientApplication.mjs.map +1 -1
  4. package/dist/app/PublicClientApplication.d.ts +14 -6
  5. package/dist/app/PublicClientApplication.d.ts.map +1 -1
  6. package/dist/app/PublicClientApplication.mjs +17 -7
  7. package/dist/app/PublicClientApplication.mjs.map +1 -1
  8. package/dist/broker/nativeBroker/NativeMessageHandler.d.ts +3 -4
  9. package/dist/broker/nativeBroker/NativeMessageHandler.d.ts.map +1 -1
  10. package/dist/broker/nativeBroker/NativeMessageHandler.mjs +13 -13
  11. package/dist/broker/nativeBroker/NativeMessageHandler.mjs.map +1 -1
  12. package/dist/broker/nativeBroker/NativeStatusCodes.d.ts +8 -0
  13. package/dist/broker/nativeBroker/NativeStatusCodes.d.ts.map +1 -0
  14. package/dist/broker/nativeBroker/NativeStatusCodes.mjs +16 -0
  15. package/dist/broker/nativeBroker/NativeStatusCodes.mjs.map +1 -0
  16. package/dist/cache/AsyncMemoryStorage.mjs +1 -1
  17. package/dist/cache/BrowserCacheManager.d.ts +3 -3
  18. package/dist/cache/BrowserCacheManager.d.ts.map +1 -1
  19. package/dist/cache/BrowserCacheManager.mjs +8 -7
  20. package/dist/cache/BrowserCacheManager.mjs.map +1 -1
  21. package/dist/cache/BrowserStorage.d.ts.map +1 -1
  22. package/dist/cache/BrowserStorage.mjs +7 -9
  23. package/dist/cache/BrowserStorage.mjs.map +1 -1
  24. package/dist/cache/CryptoKeyStore.mjs +1 -1
  25. package/dist/cache/DatabaseStorage.mjs +1 -1
  26. package/dist/cache/MemoryStorage.mjs +1 -1
  27. package/dist/cache/TokenCache.mjs +1 -1
  28. package/dist/config/Configuration.d.ts.map +1 -1
  29. package/dist/config/Configuration.mjs +7 -7
  30. package/dist/config/Configuration.mjs.map +1 -1
  31. package/dist/controllers/ControllerFactory.mjs +1 -1
  32. package/dist/controllers/IController.d.ts +3 -2
  33. package/dist/controllers/IController.d.ts.map +1 -1
  34. package/dist/controllers/StandardController.d.ts +11 -6
  35. package/dist/controllers/StandardController.d.ts.map +1 -1
  36. package/dist/controllers/StandardController.mjs +53 -34
  37. package/dist/controllers/StandardController.mjs.map +1 -1
  38. package/dist/crypto/BrowserCrypto.d.ts +44 -49
  39. package/dist/crypto/BrowserCrypto.d.ts.map +1 -1
  40. package/dist/crypto/BrowserCrypto.mjs +76 -76
  41. package/dist/crypto/BrowserCrypto.mjs.map +1 -1
  42. package/dist/crypto/CryptoOps.d.ts +1 -7
  43. package/dist/crypto/CryptoOps.d.ts.map +1 -1
  44. package/dist/crypto/CryptoOps.mjs +11 -19
  45. package/dist/crypto/CryptoOps.mjs.map +1 -1
  46. package/dist/crypto/PkceGenerator.d.ts +6 -21
  47. package/dist/crypto/PkceGenerator.d.ts.map +1 -1
  48. package/dist/crypto/PkceGenerator.mjs +45 -46
  49. package/dist/crypto/PkceGenerator.mjs.map +1 -1
  50. package/dist/crypto/SignedHttpRequest.mjs +1 -1
  51. package/dist/encode/Base64Decode.d.ts.map +1 -1
  52. package/dist/encode/Base64Decode.mjs +18 -2
  53. package/dist/encode/Base64Decode.mjs.map +1 -1
  54. package/dist/encode/Base64Encode.mjs +1 -1
  55. package/dist/error/BrowserAuthError.d.ts +10 -1
  56. package/dist/error/BrowserAuthError.d.ts.map +1 -1
  57. package/dist/error/BrowserAuthError.mjs +12 -3
  58. package/dist/error/BrowserAuthError.mjs.map +1 -1
  59. package/dist/error/BrowserAuthErrorCodes.d.ts +1 -0
  60. package/dist/error/BrowserAuthErrorCodes.d.ts.map +1 -1
  61. package/dist/error/BrowserAuthErrorCodes.mjs +3 -2
  62. package/dist/error/BrowserAuthErrorCodes.mjs.map +1 -1
  63. package/dist/error/BrowserConfigurationAuthError.d.ts +9 -46
  64. package/dist/error/BrowserConfigurationAuthError.d.ts.map +1 -1
  65. package/dist/error/BrowserConfigurationAuthError.mjs +20 -73
  66. package/dist/error/BrowserConfigurationAuthError.mjs.map +1 -1
  67. package/dist/error/BrowserConfigurationAuthErrorCodes.d.ts +4 -0
  68. package/dist/error/BrowserConfigurationAuthErrorCodes.d.ts.map +1 -0
  69. package/dist/error/BrowserConfigurationAuthErrorCodes.mjs +12 -0
  70. package/dist/error/BrowserConfigurationAuthErrorCodes.mjs.map +1 -0
  71. package/dist/error/NativeAuthError.d.ts +17 -45
  72. package/dist/error/NativeAuthError.d.ts.map +1 -1
  73. package/dist/error/NativeAuthError.mjs +47 -78
  74. package/dist/error/NativeAuthError.mjs.map +1 -1
  75. package/dist/error/NativeAuthErrorCodes.d.ts +3 -0
  76. package/dist/error/NativeAuthErrorCodes.d.ts.map +1 -0
  77. package/dist/error/NativeAuthErrorCodes.mjs +11 -0
  78. package/dist/error/NativeAuthErrorCodes.mjs.map +1 -0
  79. package/dist/event/EventHandler.d.ts.map +1 -1
  80. package/dist/event/EventHandler.mjs +3 -2
  81. package/dist/event/EventHandler.mjs.map +1 -1
  82. package/dist/event/EventMessage.mjs +1 -1
  83. package/dist/event/EventType.mjs +1 -1
  84. package/dist/index.d.ts +2 -2
  85. package/dist/index.d.ts.map +1 -1
  86. package/dist/index.mjs +4 -2
  87. package/dist/index.mjs.map +1 -1
  88. package/dist/interaction_client/BaseInteractionClient.d.ts.map +1 -1
  89. package/dist/interaction_client/BaseInteractionClient.mjs +7 -8
  90. package/dist/interaction_client/BaseInteractionClient.mjs.map +1 -1
  91. package/dist/interaction_client/HybridSpaAuthorizationCodeClient.mjs +1 -1
  92. package/dist/interaction_client/NativeInteractionClient.d.ts.map +1 -1
  93. package/dist/interaction_client/NativeInteractionClient.mjs +12 -10
  94. package/dist/interaction_client/NativeInteractionClient.mjs.map +1 -1
  95. package/dist/interaction_client/PopupClient.mjs +1 -1
  96. package/dist/interaction_client/RedirectClient.mjs +1 -1
  97. package/dist/interaction_client/SilentAuthCodeClient.d.ts.map +1 -1
  98. package/dist/interaction_client/SilentAuthCodeClient.mjs +5 -8
  99. package/dist/interaction_client/SilentAuthCodeClient.mjs.map +1 -1
  100. package/dist/interaction_client/SilentCacheClient.d.ts.map +1 -1
  101. package/dist/interaction_client/SilentCacheClient.mjs +10 -18
  102. package/dist/interaction_client/SilentCacheClient.mjs.map +1 -1
  103. package/dist/interaction_client/SilentIframeClient.mjs +2 -2
  104. package/dist/interaction_client/SilentRefreshClient.d.ts.map +1 -1
  105. package/dist/interaction_client/SilentRefreshClient.mjs +8 -18
  106. package/dist/interaction_client/SilentRefreshClient.mjs.map +1 -1
  107. package/dist/interaction_client/StandardInteractionClient.d.ts.map +1 -1
  108. package/dist/interaction_client/StandardInteractionClient.mjs +12 -33
  109. package/dist/interaction_client/StandardInteractionClient.mjs.map +1 -1
  110. package/dist/interaction_handler/InteractionHandler.d.ts.map +1 -1
  111. package/dist/interaction_handler/InteractionHandler.mjs +6 -9
  112. package/dist/interaction_handler/InteractionHandler.mjs.map +1 -1
  113. package/dist/interaction_handler/RedirectHandler.d.ts.map +1 -1
  114. package/dist/interaction_handler/RedirectHandler.mjs +3 -3
  115. package/dist/interaction_handler/RedirectHandler.mjs.map +1 -1
  116. package/dist/interaction_handler/SilentHandler.d.ts.map +1 -1
  117. package/dist/interaction_handler/SilentHandler.mjs +3 -4
  118. package/dist/interaction_handler/SilentHandler.mjs.map +1 -1
  119. package/dist/navigation/NavigationClient.mjs +1 -1
  120. package/dist/network/FetchClient.mjs +1 -1
  121. package/dist/operatingcontext/BaseOperatingContext.mjs +1 -1
  122. package/dist/operatingcontext/StandardOperatingContext.mjs +1 -1
  123. package/dist/operatingcontext/TeamsAppOperatingContext.mjs +1 -1
  124. package/dist/packageMetadata.d.ts +1 -1
  125. package/dist/packageMetadata.mjs +2 -2
  126. package/dist/telemetry/BrowserPerformanceClient.mjs +1 -1
  127. package/dist/telemetry/BrowserPerformanceMeasurement.mjs +1 -1
  128. package/dist/utils/BrowserConstants.mjs +1 -1
  129. package/dist/utils/BrowserProtocolUtils.d.ts.map +1 -1
  130. package/dist/utils/BrowserProtocolUtils.mjs +3 -3
  131. package/dist/utils/BrowserProtocolUtils.mjs.map +1 -1
  132. package/dist/utils/BrowserStringUtils.mjs +1 -1
  133. package/dist/utils/BrowserUtils.mjs +1 -1
  134. package/lib/msal-browser.cjs +1413 -1727
  135. package/lib/msal-browser.cjs.map +1 -1
  136. package/lib/msal-browser.js +1413 -1727
  137. package/lib/msal-browser.js.map +1 -1
  138. package/lib/msal-browser.min.js +68 -65
  139. package/package.json +2 -2
  140. package/src/app/IPublicClientApplication.ts +55 -18
  141. package/src/app/PublicClientApplication.ts +18 -6
  142. package/src/broker/nativeBroker/NativeMessageHandler.ts +12 -15
  143. package/src/broker/nativeBroker/NativeStatusCodes.ts +13 -0
  144. package/src/cache/BrowserCacheManager.ts +21 -6
  145. package/src/cache/BrowserStorage.ts +9 -11
  146. package/src/config/Configuration.ts +16 -8
  147. package/src/controllers/IController.ts +4 -1
  148. package/src/controllers/StandardController.ts +155 -92
  149. package/src/crypto/BrowserCrypto.ts +118 -102
  150. package/src/crypto/CryptoOps.ts +10 -22
  151. package/src/crypto/PkceGenerator.ts +93 -54
  152. package/src/encode/Base64Decode.ts +21 -1
  153. package/src/error/BrowserAuthError.ts +13 -1
  154. package/src/error/BrowserAuthErrorCodes.ts +1 -0
  155. package/src/error/BrowserConfigurationAuthError.ts +33 -102
  156. package/src/error/BrowserConfigurationAuthErrorCodes.ts +9 -0
  157. package/src/error/NativeAuthError.ts +73 -101
  158. package/src/error/NativeAuthErrorCodes.ts +7 -0
  159. package/src/event/EventHandler.ts +2 -1
  160. package/src/index.ts +5 -0
  161. package/src/interaction_client/BaseInteractionClient.ts +13 -7
  162. package/src/interaction_client/NativeInteractionClient.ts +29 -11
  163. package/src/interaction_client/SilentAuthCodeClient.ts +18 -16
  164. package/src/interaction_client/SilentCacheClient.ts +22 -30
  165. package/src/interaction_client/SilentIframeClient.ts +1 -1
  166. package/src/interaction_client/SilentRefreshClient.ts +26 -28
  167. package/src/interaction_client/StandardInteractionClient.ts +36 -67
  168. package/src/interaction_handler/InteractionHandler.ts +20 -15
  169. package/src/interaction_handler/RedirectHandler.ts +6 -2
  170. package/src/interaction_handler/SilentHandler.ts +6 -3
  171. package/src/packageMetadata.ts +1 -1
  172. package/src/utils/BrowserProtocolUtils.ts +3 -2
  173. package/dist/crypto/ISubtleCrypto.d.ts +0 -10
  174. package/dist/crypto/ISubtleCrypto.d.ts.map +0 -1
  175. package/dist/crypto/ModernBrowserCrypto.d.ts +0 -10
  176. package/dist/crypto/ModernBrowserCrypto.d.ts.map +0 -1
  177. package/dist/crypto/ModernBrowserCrypto.mjs +0 -31
  178. package/dist/crypto/ModernBrowserCrypto.mjs.map +0 -1
  179. package/src/crypto/ISubtleCrypto.ts +0 -30
  180. package/src/crypto/ModernBrowserCrypto.ts +0 -69
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.1.0",
13
+ "version": "3.2.0",
14
14
  "description": "Microsoft Authentication Library for js",
15
15
  "keywords": [
16
16
  "implicit",
@@ -100,6 +100,6 @@
100
100
  "typescript": "^4.9.5"
101
101
  },
102
102
  "dependencies": {
103
- "@azure/msal-common": "14.0.3"
103
+ "@azure/msal-common": "14.1.0"
104
104
  }
105
105
  }
@@ -13,7 +13,10 @@ import { PopupRequest } from "../request/PopupRequest";
13
13
  import { SilentRequest } from "../request/SilentRequest";
14
14
  import { SsoSilentRequest } from "../request/SsoSilentRequest";
15
15
  import { EndSessionRequest } from "../request/EndSessionRequest";
16
- import { BrowserConfigurationAuthError } from "../error/BrowserConfigurationAuthError";
16
+ import {
17
+ BrowserConfigurationAuthErrorCodes,
18
+ createBrowserConfigurationAuthError,
19
+ } from "../error/BrowserConfigurationAuthError";
17
20
  import { WrapperSKU } from "../utils/BrowserConstants";
18
21
  import { INavigationClient } from "../navigation/INavigationClient";
19
22
  import { EndSessionPopupRequest } from "../request/EndSessionPopupRequest";
@@ -74,27 +77,37 @@ export interface IPublicClientApplication {
74
77
  export const stubbedPublicClientApplication: IPublicClientApplication = {
75
78
  initialize: () => {
76
79
  return Promise.reject(
77
- BrowserConfigurationAuthError.createStubPcaInstanceCalledError()
80
+ createBrowserConfigurationAuthError(
81
+ BrowserConfigurationAuthErrorCodes.stubbedPublicClientApplicationCalled
82
+ )
78
83
  );
79
84
  },
80
85
  acquireTokenPopup: () => {
81
86
  return Promise.reject(
82
- BrowserConfigurationAuthError.createStubPcaInstanceCalledError()
87
+ createBrowserConfigurationAuthError(
88
+ BrowserConfigurationAuthErrorCodes.stubbedPublicClientApplicationCalled
89
+ )
83
90
  );
84
91
  },
85
92
  acquireTokenRedirect: () => {
86
93
  return Promise.reject(
87
- BrowserConfigurationAuthError.createStubPcaInstanceCalledError()
94
+ createBrowserConfigurationAuthError(
95
+ BrowserConfigurationAuthErrorCodes.stubbedPublicClientApplicationCalled
96
+ )
88
97
  );
89
98
  },
90
99
  acquireTokenSilent: () => {
91
100
  return Promise.reject(
92
- BrowserConfigurationAuthError.createStubPcaInstanceCalledError()
101
+ createBrowserConfigurationAuthError(
102
+ BrowserConfigurationAuthErrorCodes.stubbedPublicClientApplicationCalled
103
+ )
93
104
  );
94
105
  },
95
106
  acquireTokenByCode: () => {
96
107
  return Promise.reject(
97
- BrowserConfigurationAuthError.createStubPcaInstanceCalledError()
108
+ createBrowserConfigurationAuthError(
109
+ BrowserConfigurationAuthErrorCodes.stubbedPublicClientApplicationCalled
110
+ )
98
111
  );
99
112
  },
100
113
  getAllAccounts: () => {
@@ -111,37 +124,51 @@ export const stubbedPublicClientApplication: IPublicClientApplication = {
111
124
  },
112
125
  handleRedirectPromise: () => {
113
126
  return Promise.reject(
114
- BrowserConfigurationAuthError.createStubPcaInstanceCalledError()
127
+ createBrowserConfigurationAuthError(
128
+ BrowserConfigurationAuthErrorCodes.stubbedPublicClientApplicationCalled
129
+ )
115
130
  );
116
131
  },
117
132
  loginPopup: () => {
118
133
  return Promise.reject(
119
- BrowserConfigurationAuthError.createStubPcaInstanceCalledError()
134
+ createBrowserConfigurationAuthError(
135
+ BrowserConfigurationAuthErrorCodes.stubbedPublicClientApplicationCalled
136
+ )
120
137
  );
121
138
  },
122
139
  loginRedirect: () => {
123
140
  return Promise.reject(
124
- BrowserConfigurationAuthError.createStubPcaInstanceCalledError()
141
+ createBrowserConfigurationAuthError(
142
+ BrowserConfigurationAuthErrorCodes.stubbedPublicClientApplicationCalled
143
+ )
125
144
  );
126
145
  },
127
146
  logout: () => {
128
147
  return Promise.reject(
129
- BrowserConfigurationAuthError.createStubPcaInstanceCalledError()
148
+ createBrowserConfigurationAuthError(
149
+ BrowserConfigurationAuthErrorCodes.stubbedPublicClientApplicationCalled
150
+ )
130
151
  );
131
152
  },
132
153
  logoutRedirect: () => {
133
154
  return Promise.reject(
134
- BrowserConfigurationAuthError.createStubPcaInstanceCalledError()
155
+ createBrowserConfigurationAuthError(
156
+ BrowserConfigurationAuthErrorCodes.stubbedPublicClientApplicationCalled
157
+ )
135
158
  );
136
159
  },
137
160
  logoutPopup: () => {
138
161
  return Promise.reject(
139
- BrowserConfigurationAuthError.createStubPcaInstanceCalledError()
162
+ createBrowserConfigurationAuthError(
163
+ BrowserConfigurationAuthErrorCodes.stubbedPublicClientApplicationCalled
164
+ )
140
165
  );
141
166
  },
142
167
  ssoSilent: () => {
143
168
  return Promise.reject(
144
- BrowserConfigurationAuthError.createStubPcaInstanceCalledError()
169
+ createBrowserConfigurationAuthError(
170
+ BrowserConfigurationAuthErrorCodes.stubbedPublicClientApplicationCalled
171
+ )
145
172
  );
146
173
  },
147
174
  addEventCallback: () => {
@@ -163,10 +190,14 @@ export const stubbedPublicClientApplication: IPublicClientApplication = {
163
190
  return;
164
191
  },
165
192
  getTokenCache: () => {
166
- throw BrowserConfigurationAuthError.createStubPcaInstanceCalledError();
193
+ throw createBrowserConfigurationAuthError(
194
+ BrowserConfigurationAuthErrorCodes.stubbedPublicClientApplicationCalled
195
+ );
167
196
  },
168
197
  getLogger: () => {
169
- throw BrowserConfigurationAuthError.createStubPcaInstanceCalledError();
198
+ throw createBrowserConfigurationAuthError(
199
+ BrowserConfigurationAuthErrorCodes.stubbedPublicClientApplicationCalled
200
+ );
170
201
  },
171
202
  setLogger: () => {
172
203
  return;
@@ -184,16 +215,22 @@ export const stubbedPublicClientApplication: IPublicClientApplication = {
184
215
  return;
185
216
  },
186
217
  getConfiguration: () => {
187
- throw BrowserConfigurationAuthError.createStubPcaInstanceCalledError();
218
+ throw createBrowserConfigurationAuthError(
219
+ BrowserConfigurationAuthErrorCodes.stubbedPublicClientApplicationCalled
220
+ );
188
221
  },
189
222
  hydrateCache: () => {
190
223
  return Promise.reject(
191
- BrowserConfigurationAuthError.createStubPcaInstanceCalledError()
224
+ createBrowserConfigurationAuthError(
225
+ BrowserConfigurationAuthErrorCodes.stubbedPublicClientApplicationCalled
226
+ )
192
227
  );
193
228
  },
194
229
  clearCache: () => {
195
230
  return Promise.reject(
196
- BrowserConfigurationAuthError.createStubPcaInstanceCalledError()
231
+ createBrowserConfigurationAuthError(
232
+ BrowserConfigurationAuthErrorCodes.stubbedPublicClientApplicationCalled
233
+ )
197
234
  );
198
235
  },
199
236
  };
@@ -15,6 +15,7 @@ import { IController } from "../controllers/IController";
15
15
  import {
16
16
  PerformanceCallbackFunction,
17
17
  AccountInfo,
18
+ AccountFilter,
18
19
  Logger,
19
20
  } from "@azure/msal-common";
20
21
  import { EndSessionRequest } from "../request/EndSessionRequest";
@@ -188,12 +189,22 @@ export class PublicClientApplication implements IPublicClientApplication {
188
189
  this.controller.disableAccountStorageEvents();
189
190
  }
190
191
 
192
+ /**
193
+ * Returns the first account found in the cache that matches the account filter passed in.
194
+ * @param accountFilter
195
+ * @returns The first account found in the cache matching the provided filter or null if no account could be found.
196
+ */
197
+ getAccount(accountFilter: AccountFilter): AccountInfo | null {
198
+ return this.controller.getAccount(accountFilter);
199
+ }
200
+
191
201
  /**
192
202
  * Returns the signed in account matching homeAccountId.
193
203
  * (the account object is created at the time of successful login)
194
204
  * or null when no matching account is found
195
205
  * @param homeAccountId
196
206
  * @returns The account object stored in MSAL
207
+ * @deprecated - Use getAccount instead
197
208
  */
198
209
  getAccountByHomeId(homeAccountId: string): AccountInfo | null {
199
210
  return this.controller.getAccountByHomeId(homeAccountId);
@@ -205,6 +216,7 @@ export class PublicClientApplication implements IPublicClientApplication {
205
216
  * or null when no matching account is found
206
217
  * @param localAccountId
207
218
  * @returns The account object stored in MSAL
219
+ * @deprecated - Use getAccount instead
208
220
  */
209
221
  getAccountByLocalId(localId: string): AccountInfo | null {
210
222
  return this.controller.getAccountByLocalId(localId);
@@ -217,19 +229,19 @@ export class PublicClientApplication implements IPublicClientApplication {
217
229
  * This API is provided for convenience but getAccountById should be used for best reliability
218
230
  * @param userName
219
231
  * @returns The account object stored in MSAL
232
+ * @deprecated - Use getAccount instead
220
233
  */
221
234
  getAccountByUsername(userName: string): AccountInfo | null {
222
235
  return this.controller.getAccountByUsername(userName);
223
236
  }
224
237
 
225
238
  /**
226
- * Returns all accounts that MSAL currently has data for.
227
- * (the account object is created at the time of successful login)
228
- * or empty array when no accounts are found
229
- * @returns Array of account objects in cache
239
+ * Returns all the accounts in the cache that match the optional filter. If no filter is provided, all accounts are returned.
240
+ * @param accountFilter - (Optional) filter to narrow down the accounts returned
241
+ * @returns Array of AccountInfo objects in cache
230
242
  */
231
- getAllAccounts(): AccountInfo[] {
232
- return this.controller.getAllAccounts();
243
+ getAllAccounts(accountFilter?: AccountFilter): AccountInfo[] {
244
+ return this.controller.getAllAccounts(accountFilter);
233
245
  }
234
246
 
235
247
  /**
@@ -10,22 +10,24 @@ import {
10
10
  import {
11
11
  Logger,
12
12
  AuthError,
13
+ createAuthError,
14
+ AuthErrorCodes,
13
15
  AuthenticationScheme,
14
16
  InProgressPerformanceEvent,
15
17
  PerformanceEvents,
16
18
  IPerformanceClient,
17
- ICrypto,
18
19
  } from "@azure/msal-common";
19
20
  import {
20
21
  NativeExtensionRequest,
21
22
  NativeExtensionRequestBody,
22
23
  } from "./NativeRequest";
23
- import { NativeAuthError } from "../../error/NativeAuthError";
24
+ import { createNativeAuthError } from "../../error/NativeAuthError";
24
25
  import {
25
26
  createBrowserAuthError,
26
27
  BrowserAuthErrorCodes,
27
28
  } from "../../error/BrowserAuthError";
28
29
  import { BrowserConfiguration } from "../../config/Configuration";
30
+ import { createNewGuid } from "../../crypto/BrowserCrypto";
29
31
 
30
32
  type ResponseResolvers<T> = {
31
33
  resolve: (value: T | PromiseLike<T>) => void;
@@ -38,7 +40,6 @@ export class NativeMessageHandler {
38
40
  private extensionId: string | undefined;
39
41
  private extensionVersion: string | undefined;
40
42
  private logger: Logger;
41
- private crypto: ICrypto;
42
43
  private readonly handshakeTimeoutMs: number;
43
44
  private timeoutId: number | undefined;
44
45
  private resolvers: Map<string, ResponseResolvers<object>>;
@@ -52,7 +53,6 @@ export class NativeMessageHandler {
52
53
  logger: Logger,
53
54
  handshakeTimeoutMs: number,
54
55
  performanceClient: IPerformanceClient,
55
- crypto: ICrypto,
56
56
  extensionId?: string
57
57
  ) {
58
58
  this.logger = logger;
@@ -66,7 +66,6 @@ export class NativeMessageHandler {
66
66
  this.handshakeEvent = performanceClient.startMeasurement(
67
67
  PerformanceEvents.NativeMessageHandlerHandshake
68
68
  );
69
- this.crypto = crypto;
70
69
  }
71
70
 
72
71
  /**
@@ -78,7 +77,7 @@ export class NativeMessageHandler {
78
77
  const req: NativeExtensionRequest = {
79
78
  channel: NativeConstants.CHANNEL_ID,
80
79
  extensionId: this.extensionId,
81
- responseId: this.crypto.createNewGuid(),
80
+ responseId: createNewGuid(),
82
81
  body: body,
83
82
  };
84
83
 
@@ -107,8 +106,7 @@ export class NativeMessageHandler {
107
106
  static async createProvider(
108
107
  logger: Logger,
109
108
  handshakeTimeoutMs: number,
110
- performanceClient: IPerformanceClient,
111
- crypto: ICrypto
109
+ performanceClient: IPerformanceClient
112
110
  ): Promise<NativeMessageHandler> {
113
111
  logger.trace("NativeMessageHandler - createProvider called.");
114
112
  try {
@@ -116,7 +114,6 @@ export class NativeMessageHandler {
116
114
  logger,
117
115
  handshakeTimeoutMs,
118
116
  performanceClient,
119
- crypto,
120
117
  NativeConstants.PREFERRED_EXTENSION_ID
121
118
  );
122
119
  await preferredProvider.sendHandshakeRequest();
@@ -126,8 +123,7 @@ export class NativeMessageHandler {
126
123
  const backupProvider = new NativeMessageHandler(
127
124
  logger,
128
125
  handshakeTimeoutMs,
129
- performanceClient,
130
- crypto
126
+ performanceClient
131
127
  );
132
128
  await backupProvider.sendHandshakeRequest();
133
129
  return backupProvider;
@@ -147,7 +143,7 @@ export class NativeMessageHandler {
147
143
  const req: NativeExtensionRequest = {
148
144
  channel: NativeConstants.CHANNEL_ID,
149
145
  extensionId: this.extensionId,
150
- responseId: this.crypto.createNewGuid(),
146
+ responseId: createNewGuid(),
151
147
  body: {
152
148
  method: NativeExtensionMethod.HandshakeRequest,
153
149
  },
@@ -283,7 +279,7 @@ export class NativeMessageHandler {
283
279
  );
284
280
  if (response.status !== "Success") {
285
281
  resolver.reject(
286
- NativeAuthError.createError(
282
+ createNativeAuthError(
287
283
  response.code,
288
284
  response.description,
289
285
  response.ext
@@ -295,7 +291,7 @@ export class NativeMessageHandler {
295
291
  response.result["description"]
296
292
  ) {
297
293
  resolver.reject(
298
- NativeAuthError.createError(
294
+ createNativeAuthError(
299
295
  response.result["code"],
300
296
  response.result["description"],
301
297
  response.result["ext"]
@@ -305,7 +301,8 @@ export class NativeMessageHandler {
305
301
  resolver.resolve(response.result);
306
302
  }
307
303
  } else {
308
- throw AuthError.createUnexpectedError(
304
+ throw createAuthError(
305
+ AuthErrorCodes.unexpectedError,
309
306
  "Event does not contain result."
310
307
  );
311
308
  }
@@ -0,0 +1,13 @@
1
+ /*
2
+ * Copyright (c) Microsoft Corporation. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+
6
+ // Status Codes that can be thrown by WAM
7
+ export const USER_INTERACTION_REQUIRED = "USER_INTERACTION_REQUIRED";
8
+ export const USER_CANCEL = "USER_CANCEL";
9
+ export const NO_NETWORK = "NO_NETWORK";
10
+ export const TRANSIENT_ERROR = "TRANSIENT_ERROR";
11
+ export const PERSISTENT_ERROR = "PERSISTENT_ERROR";
12
+ export const DISABLED = "DISABLED";
13
+ export const ACCOUNT_UNAVAILABLE = "ACCOUNT_UNAVAILABLE";
@@ -27,11 +27,14 @@ import {
27
27
  CcsCredentialType,
28
28
  AuthToken,
29
29
  ValidCredentialType,
30
- ClientAuthError,
31
30
  TokenKeys,
32
31
  CredentialType,
33
32
  CacheRecord,
34
33
  AuthenticationScheme,
34
+ createClientAuthError,
35
+ ClientAuthErrorCodes,
36
+ PerformanceEvents,
37
+ IPerformanceClient,
35
38
  } from "@azure/msal-common";
36
39
  import { CacheOptions } from "../config/Configuration";
37
40
  import {
@@ -614,7 +617,9 @@ export class BrowserCacheManager extends CacheManager {
614
617
  this.logger.error(
615
618
  `BrowserCacheManager:addTokenKey - CredentialType provided invalid. CredentialType: ${type}`
616
619
  );
617
- ClientAuthError.createUnexpectedCredentialTypeError();
620
+ throw createClientAuthError(
621
+ ClientAuthErrorCodes.unexpectedCredentialType
622
+ );
618
623
  }
619
624
 
620
625
  this.setItem(
@@ -685,7 +690,9 @@ export class BrowserCacheManager extends CacheManager {
685
690
  this.logger.error(
686
691
  `BrowserCacheManager:removeTokenKey - CredentialType provided invalid. CredentialType: ${type}`
687
692
  );
688
- ClientAuthError.createUnexpectedCredentialTypeError();
693
+ throw createClientAuthError(
694
+ ClientAuthErrorCodes.unexpectedCredentialType
695
+ );
689
696
  }
690
697
 
691
698
  this.setItem(
@@ -1171,7 +1178,9 @@ export class BrowserCacheManager extends CacheManager {
1171
1178
  if (matchingAccounts.length === 1) {
1172
1179
  return matchingAccounts[0];
1173
1180
  } else if (matchingAccounts.length > 1) {
1174
- throw ClientAuthError.createMultipleMatchingAccountsInCacheError();
1181
+ throw createClientAuthError(
1182
+ ClientAuthErrorCodes.multipleMatchingAccounts
1183
+ );
1175
1184
  }
1176
1185
 
1177
1186
  return null;
@@ -1353,10 +1362,16 @@ export class BrowserCacheManager extends CacheManager {
1353
1362
 
1354
1363
  /**
1355
1364
  * Clears all access tokes that have claims prior to saving the current one
1356
- * @param credential
1365
+ * @param performanceClient {IPerformanceClient}
1357
1366
  * @returns
1358
1367
  */
1359
- async clearTokensAndKeysWithClaims(): Promise<void> {
1368
+ async clearTokensAndKeysWithClaims(
1369
+ performanceClient: IPerformanceClient
1370
+ ): Promise<void> {
1371
+ performanceClient.addQueueMeasurement(
1372
+ PerformanceEvents.ClearTokensAndKeysWithClaims
1373
+ );
1374
+
1360
1375
  const tokenKeys = this.getTokenKeys();
1361
1376
 
1362
1377
  const removedAccessTokens: Array<Promise<void>> = [];
@@ -3,7 +3,10 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
 
6
- import { BrowserConfigurationAuthError } from "../error/BrowserConfigurationAuthError";
6
+ import {
7
+ BrowserConfigurationAuthErrorCodes,
8
+ createBrowserConfigurationAuthError,
9
+ } from "../error/BrowserConfigurationAuthError";
7
10
  import { BrowserCacheLocation } from "../utils/BrowserConstants";
8
11
  import { IWindowStorage } from "./IWindowStorage";
9
12
 
@@ -17,17 +20,12 @@ export class BrowserStorage implements IWindowStorage<string> {
17
20
 
18
21
  private validateWindowStorage(cacheLocation: string): void {
19
22
  if (
20
- cacheLocation !== BrowserCacheLocation.LocalStorage &&
21
- cacheLocation !== BrowserCacheLocation.SessionStorage
23
+ (cacheLocation !== BrowserCacheLocation.LocalStorage &&
24
+ cacheLocation !== BrowserCacheLocation.SessionStorage) ||
25
+ !window[cacheLocation]
22
26
  ) {
23
- throw BrowserConfigurationAuthError.createStorageNotSupportedError(
24
- cacheLocation
25
- );
26
- }
27
- const storageSupported = !!window[cacheLocation];
28
- if (!storageSupported) {
29
- throw BrowserConfigurationAuthError.createStorageNotSupportedError(
30
- cacheLocation
27
+ throw createBrowserConfigurationAuthError(
28
+ BrowserConfigurationAuthErrorCodes.storageNotSupported
31
29
  );
32
30
  }
33
31
  }
@@ -17,9 +17,11 @@ import {
17
17
  AzureCloudInstance,
18
18
  AzureCloudOptions,
19
19
  ApplicationTelemetry,
20
- ClientConfigurationError,
20
+ createClientConfigurationError,
21
+ ClientConfigurationErrorCodes,
21
22
  IPerformanceClient,
22
23
  StubPerformanceClient,
24
+ Logger,
23
25
  } from "@azure/msal-common";
24
26
  import {
25
27
  BrowserCacheLocation,
@@ -323,7 +325,8 @@ export function buildConfiguration(
323
325
  pollIntervalMilliseconds: BrowserConstants.DEFAULT_POLL_INTERVAL_MS,
324
326
  };
325
327
 
326
- const providedSystemOptions: BrowserSystemOptions = {
328
+ const providedSystemOptions: Required<BrowserSystemOptions> = {
329
+ ...DEFAULT_BROWSER_SYSTEM_OPTIONS,
327
330
  ...userInputSystem,
328
331
  loggerOptions: userInputSystem?.loggerOptions || DEFAULT_LOGGER_OPTIONS,
329
332
  };
@@ -341,10 +344,13 @@ export function buildConfiguration(
341
344
  userInputAuth?.protocolMode !== ProtocolMode.OIDC &&
342
345
  userInputAuth?.OIDCOptions
343
346
  ) {
344
- // Logger has not been created yet
345
- // eslint-disable-next-line no-console
346
- console.warn(
347
- ClientConfigurationError.createCannotSetOIDCOptionsError()
347
+ const logger = new Logger(providedSystemOptions.loggerOptions);
348
+ logger.warning(
349
+ JSON.stringify(
350
+ createClientConfigurationError(
351
+ ClientConfigurationErrorCodes.cannotSetOIDCOptions
352
+ )
353
+ )
348
354
  );
349
355
  }
350
356
 
@@ -354,7 +360,9 @@ export function buildConfiguration(
354
360
  userInputAuth.protocolMode !== ProtocolMode.AAD &&
355
361
  providedSystemOptions?.allowNativeBroker
356
362
  ) {
357
- throw ClientConfigurationError.createCannotAllowNativeBrokerError();
363
+ throw createClientConfigurationError(
364
+ ClientConfigurationErrorCodes.cannotAllowNativeBroker
365
+ );
358
366
  }
359
367
 
360
368
  const overlayedConfig: BrowserConfiguration = {
@@ -367,7 +375,7 @@ export function buildConfiguration(
367
375
  },
368
376
  },
369
377
  cache: { ...DEFAULT_CACHE_OPTIONS, ...userInputCache },
370
- system: { ...DEFAULT_BROWSER_SYSTEM_OPTIONS, ...providedSystemOptions },
378
+ system: providedSystemOptions,
371
379
  telemetry: { ...DEFAULT_TELEMETRY_OPTIONS, ...userInputTelemetry },
372
380
  };
373
381
 
@@ -9,6 +9,7 @@ import {
9
9
  PerformanceCallbackFunction,
10
10
  IPerformanceClient,
11
11
  CommonSilentFlowRequest,
12
+ AccountFilter,
12
13
  } from "@azure/msal-common";
13
14
  import { RedirectRequest } from "../request/RedirectRequest";
14
15
  import { PopupRequest } from "../request/PopupRequest";
@@ -64,13 +65,15 @@ export interface IController {
64
65
 
65
66
  disableAccountStorageEvents(): void;
66
67
 
68
+ getAccount(accountFilter: AccountFilter): AccountInfo | null;
69
+
67
70
  getAccountByHomeId(homeAccountId: string): AccountInfo | null;
68
71
 
69
72
  getAccountByLocalId(localId: string): AccountInfo | null;
70
73
 
71
74
  getAccountByUsername(userName: string): AccountInfo | null;
72
75
 
73
- getAllAccounts(): AccountInfo[];
76
+ getAllAccounts(accountFilter?: AccountFilter): AccountInfo[];
74
77
 
75
78
  handleRedirectPromise(hash?: string): Promise<AuthenticationResult | null>;
76
79