@azure/msal-common 14.0.3 → 14.1.0-alpha.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 (296) hide show
  1. package/dist/account/AccountInfo.d.ts +32 -32
  2. package/dist/account/AuthToken.d.ts +17 -17
  3. package/dist/account/AuthToken.d.ts.map +1 -1
  4. package/dist/account/AuthToken.mjs +60 -59
  5. package/dist/account/AuthToken.mjs.map +1 -1
  6. package/dist/account/CcsCredential.d.ts +9 -9
  7. package/dist/account/CcsCredential.mjs +8 -8
  8. package/dist/account/ClientCredentials.d.ts +14 -14
  9. package/dist/account/ClientInfo.d.ts +19 -19
  10. package/dist/account/ClientInfo.d.ts.map +1 -1
  11. package/dist/account/ClientInfo.mjs +39 -38
  12. package/dist/account/ClientInfo.mjs.map +1 -1
  13. package/dist/account/TokenClaims.d.ts +65 -65
  14. package/dist/authority/Authority.d.ts +235 -235
  15. package/dist/authority/Authority.d.ts.map +1 -1
  16. package/dist/authority/Authority.mjs +743 -765
  17. package/dist/authority/Authority.mjs.map +1 -1
  18. package/dist/authority/AuthorityFactory.d.ts +31 -31
  19. package/dist/authority/AuthorityFactory.d.ts.map +1 -1
  20. package/dist/authority/AuthorityFactory.mjs +52 -50
  21. package/dist/authority/AuthorityFactory.mjs.map +1 -1
  22. package/dist/authority/AuthorityMetadata.d.ts +623 -623
  23. package/dist/authority/AuthorityMetadata.mjs +884 -884
  24. package/dist/authority/AuthorityOptions.d.ts +21 -21
  25. package/dist/authority/AuthorityOptions.mjs +18 -18
  26. package/dist/authority/AuthorityType.d.ts +10 -10
  27. package/dist/authority/AuthorityType.mjs +13 -13
  28. package/dist/authority/AzureRegion.d.ts +1 -1
  29. package/dist/authority/AzureRegionConfiguration.d.ts +5 -5
  30. package/dist/authority/CloudDiscoveryMetadata.d.ts +5 -5
  31. package/dist/authority/CloudInstanceDiscoveryErrorResponse.d.ts +13 -13
  32. package/dist/authority/CloudInstanceDiscoveryErrorResponse.mjs +8 -8
  33. package/dist/authority/CloudInstanceDiscoveryResponse.d.ts +9 -9
  34. package/dist/authority/CloudInstanceDiscoveryResponse.mjs +8 -8
  35. package/dist/authority/ImdsOptions.d.ts +5 -5
  36. package/dist/authority/OIDCOptions.d.ts +8 -8
  37. package/dist/authority/OpenIdConfigResponse.d.ts +11 -11
  38. package/dist/authority/OpenIdConfigResponse.mjs +10 -10
  39. package/dist/authority/ProtocolMode.d.ts +8 -8
  40. package/dist/authority/ProtocolMode.mjs +11 -11
  41. package/dist/authority/RegionDiscovery.d.ts +32 -30
  42. package/dist/authority/RegionDiscovery.d.ts.map +1 -1
  43. package/dist/authority/RegionDiscovery.mjs +107 -108
  44. package/dist/authority/RegionDiscovery.mjs.map +1 -1
  45. package/dist/authority/RegionDiscoveryMetadata.d.ts +6 -6
  46. package/dist/broker/nativeBroker/INativeBrokerPlugin.d.ts +15 -15
  47. package/dist/cache/CacheManager.d.ts +446 -446
  48. package/dist/cache/CacheManager.d.ts.map +1 -1
  49. package/dist/cache/CacheManager.mjs +1000 -1024
  50. package/dist/cache/CacheManager.mjs.map +1 -1
  51. package/dist/cache/entities/AccessTokenEntity.d.ts +56 -56
  52. package/dist/cache/entities/AccessTokenEntity.d.ts.map +1 -1
  53. package/dist/cache/entities/AccessTokenEntity.mjs +111 -110
  54. package/dist/cache/entities/AccessTokenEntity.mjs.map +1 -1
  55. package/dist/cache/entities/AccountEntity.d.ts +101 -101
  56. package/dist/cache/entities/AccountEntity.d.ts.map +1 -1
  57. package/dist/cache/entities/AccountEntity.mjs +222 -221
  58. package/dist/cache/entities/AccountEntity.mjs.map +1 -1
  59. package/dist/cache/entities/AppMetadataEntity.d.ts +39 -39
  60. package/dist/cache/entities/AppMetadataEntity.mjs +66 -66
  61. package/dist/cache/entities/AuthorityMetadataEntity.d.ts +48 -48
  62. package/dist/cache/entities/AuthorityMetadataEntity.mjs +78 -78
  63. package/dist/cache/entities/CacheRecord.d.ts +14 -14
  64. package/dist/cache/entities/CacheRecord.mjs +14 -14
  65. package/dist/cache/entities/CredentialEntity.d.ts +88 -88
  66. package/dist/cache/entities/CredentialEntity.d.ts.map +1 -1
  67. package/dist/cache/entities/CredentialEntity.mjs +138 -137
  68. package/dist/cache/entities/CredentialEntity.mjs.map +1 -1
  69. package/dist/cache/entities/IdTokenEntity.d.ts +34 -34
  70. package/dist/cache/entities/IdTokenEntity.mjs +56 -56
  71. package/dist/cache/entities/RefreshTokenEntity.d.ts +36 -36
  72. package/dist/cache/entities/RefreshTokenEntity.mjs +59 -59
  73. package/dist/cache/entities/ServerTelemetryEntity.d.ts +12 -12
  74. package/dist/cache/entities/ServerTelemetryEntity.mjs +27 -27
  75. package/dist/cache/entities/ThrottlingEntity.d.ts +13 -13
  76. package/dist/cache/entities/ThrottlingEntity.mjs +23 -23
  77. package/dist/cache/interface/ICacheManager.d.ts +166 -166
  78. package/dist/cache/interface/ICachePlugin.d.ts +5 -5
  79. package/dist/cache/interface/ISerializableTokenCache.d.ts +4 -4
  80. package/dist/cache/persistence/TokenCacheContext.d.ts +23 -23
  81. package/dist/cache/persistence/TokenCacheContext.mjs +25 -25
  82. package/dist/cache/utils/CacheTypes.d.ts +69 -69
  83. package/dist/client/AuthorizationCodeClient.d.ts +73 -73
  84. package/dist/client/AuthorizationCodeClient.d.ts.map +1 -1
  85. package/dist/client/AuthorizationCodeClient.mjs +411 -410
  86. package/dist/client/AuthorizationCodeClient.mjs.map +1 -1
  87. package/dist/client/BaseClient.d.ts +51 -51
  88. package/dist/client/BaseClient.d.ts.map +1 -1
  89. package/dist/client/BaseClient.mjs +100 -99
  90. package/dist/client/BaseClient.mjs.map +1 -1
  91. package/dist/client/RefreshTokenClient.d.ts +35 -35
  92. package/dist/client/RefreshTokenClient.d.ts.map +1 -1
  93. package/dist/client/RefreshTokenClient.mjs +185 -234
  94. package/dist/client/RefreshTokenClient.mjs.map +1 -1
  95. package/dist/client/SilentFlowClient.d.ts +26 -25
  96. package/dist/client/SilentFlowClient.d.ts.map +1 -1
  97. package/dist/client/SilentFlowClient.mjs +127 -103
  98. package/dist/client/SilentFlowClient.mjs.map +1 -1
  99. package/dist/config/AppTokenProvider.d.ts +38 -38
  100. package/dist/config/ClientConfiguration.d.ts +150 -150
  101. package/dist/config/ClientConfiguration.d.ts.map +1 -1
  102. package/dist/config/ClientConfiguration.mjs +99 -100
  103. package/dist/config/ClientConfiguration.mjs.map +1 -1
  104. package/dist/crypto/ICrypto.d.ts +62 -62
  105. package/dist/crypto/ICrypto.d.ts.map +1 -1
  106. package/dist/crypto/ICrypto.mjs +35 -43
  107. package/dist/crypto/ICrypto.mjs.map +1 -1
  108. package/dist/crypto/IGuidGenerator.d.ts +4 -4
  109. package/dist/crypto/JoseHeader.d.ts +22 -22
  110. package/dist/crypto/JoseHeader.d.ts.map +1 -1
  111. package/dist/crypto/JoseHeader.mjs +39 -38
  112. package/dist/crypto/JoseHeader.mjs.map +1 -1
  113. package/dist/crypto/PopTokenGenerator.d.ts +60 -59
  114. package/dist/crypto/PopTokenGenerator.d.ts.map +1 -1
  115. package/dist/crypto/PopTokenGenerator.mjs +83 -83
  116. package/dist/crypto/PopTokenGenerator.mjs.map +1 -1
  117. package/dist/crypto/SignedHttpRequest.d.ts +11 -11
  118. package/dist/error/AuthError.d.ts +44 -47
  119. package/dist/error/AuthError.d.ts.map +1 -1
  120. package/dist/error/AuthError.mjs +50 -52
  121. package/dist/error/AuthError.mjs.map +1 -1
  122. package/dist/error/AuthErrorCodes.d.ts +6 -0
  123. package/dist/error/AuthErrorCodes.d.ts.map +1 -0
  124. package/dist/error/AuthErrorCodes.mjs +14 -0
  125. package/dist/error/AuthErrorCodes.mjs.map +1 -0
  126. package/dist/error/ClientAuthError.d.ts +232 -412
  127. package/dist/error/ClientAuthError.d.ts.map +1 -1
  128. package/dist/error/ClientAuthError.mjs +248 -520
  129. package/dist/error/ClientAuthError.mjs.map +1 -1
  130. package/dist/error/ClientAuthErrorCodes.d.ts +44 -0
  131. package/dist/error/ClientAuthErrorCodes.d.ts.map +1 -0
  132. package/dist/error/ClientAuthErrorCodes.mjs +52 -0
  133. package/dist/error/ClientAuthErrorCodes.mjs.map +1 -0
  134. package/dist/error/ClientConfigurationError.d.ts +128 -222
  135. package/dist/error/ClientConfigurationError.d.ts.map +1 -1
  136. package/dist/error/ClientConfigurationError.mjs +140 -281
  137. package/dist/error/ClientConfigurationError.mjs.map +1 -1
  138. package/dist/error/ClientConfigurationErrorCodes.d.ts +23 -0
  139. package/dist/error/ClientConfigurationErrorCodes.d.ts.map +1 -0
  140. package/dist/error/ClientConfigurationErrorCodes.mjs +31 -0
  141. package/dist/error/ClientConfigurationErrorCodes.mjs.map +1 -0
  142. package/dist/error/InteractionRequiredAuthError.d.ts +57 -59
  143. package/dist/error/InteractionRequiredAuthError.d.ts.map +1 -1
  144. package/dist/error/InteractionRequiredAuthError.mjs +80 -79
  145. package/dist/error/InteractionRequiredAuthError.mjs.map +1 -1
  146. package/dist/error/InteractionRequiredAuthErrorCodes.d.ts +6 -0
  147. package/dist/error/InteractionRequiredAuthErrorCodes.d.ts.map +1 -0
  148. package/dist/error/InteractionRequiredAuthErrorCodes.mjs +16 -0
  149. package/dist/error/InteractionRequiredAuthErrorCodes.mjs.map +1 -0
  150. package/dist/error/JoseHeaderError.d.ts +15 -28
  151. package/dist/error/JoseHeaderError.d.ts.map +1 -1
  152. package/dist/error/JoseHeaderError.mjs +24 -40
  153. package/dist/error/JoseHeaderError.mjs.map +1 -1
  154. package/dist/error/JoseHeaderErrorCodes.d.ts +3 -0
  155. package/dist/error/JoseHeaderErrorCodes.d.ts.map +1 -0
  156. package/dist/error/JoseHeaderErrorCodes.mjs +11 -0
  157. package/dist/error/JoseHeaderErrorCodes.mjs.map +1 -0
  158. package/dist/error/ServerError.d.ts +7 -7
  159. package/dist/error/ServerError.mjs +14 -14
  160. package/dist/index.cjs +8715 -9047
  161. package/dist/index.cjs.map +1 -1
  162. package/dist/index.d.ts +96 -96
  163. package/dist/index.d.ts.map +1 -1
  164. package/dist/index.mjs +13 -5
  165. package/dist/index.mjs.map +1 -1
  166. package/dist/logger/Logger.d.ts +95 -95
  167. package/dist/logger/Logger.mjs +188 -188
  168. package/dist/network/INetworkModule.d.ts +29 -29
  169. package/dist/network/INetworkModule.d.ts.map +1 -1
  170. package/dist/network/INetworkModule.mjs +14 -15
  171. package/dist/network/INetworkModule.mjs.map +1 -1
  172. package/dist/network/NetworkManager.d.ts +33 -33
  173. package/dist/network/NetworkManager.d.ts.map +1 -1
  174. package/dist/network/NetworkManager.mjs +36 -35
  175. package/dist/network/NetworkManager.mjs.map +1 -1
  176. package/dist/network/RequestThumbprint.d.ts +16 -16
  177. package/dist/network/ThrottlingUtils.d.ts +42 -42
  178. package/dist/network/ThrottlingUtils.mjs +95 -95
  179. package/dist/packageMetadata.d.ts +2 -2
  180. package/dist/packageMetadata.mjs +3 -3
  181. package/dist/request/AuthenticationHeaderParser.d.ts +19 -19
  182. package/dist/request/AuthenticationHeaderParser.d.ts.map +1 -1
  183. package/dist/request/AuthenticationHeaderParser.mjs +58 -57
  184. package/dist/request/AuthenticationHeaderParser.mjs.map +1 -1
  185. package/dist/request/BaseAuthRequest.d.ts +40 -40
  186. package/dist/request/CommonAuthorizationCodeRequest.d.ts +27 -27
  187. package/dist/request/CommonAuthorizationUrlRequest.d.ts +50 -50
  188. package/dist/request/CommonClientCredentialRequest.d.ts +17 -17
  189. package/dist/request/CommonDeviceCodeRequest.d.ts +21 -21
  190. package/dist/request/CommonEndSessionRequest.d.ts +21 -21
  191. package/dist/request/CommonOnBehalfOfRequest.d.ts +13 -13
  192. package/dist/request/CommonRefreshTokenRequest.d.ts +19 -19
  193. package/dist/request/CommonSilentFlowRequest.d.ts +18 -18
  194. package/dist/request/CommonUsernamePasswordRequest.d.ts +17 -17
  195. package/dist/request/NativeRequest.d.ts +19 -19
  196. package/dist/request/NativeSignOutRequest.d.ts +5 -5
  197. package/dist/request/RequestParameterBuilder.d.ts +217 -217
  198. package/dist/request/RequestParameterBuilder.d.ts.map +1 -1
  199. package/dist/request/RequestParameterBuilder.mjs +383 -382
  200. package/dist/request/RequestParameterBuilder.mjs.map +1 -1
  201. package/dist/request/RequestValidator.d.ts +33 -33
  202. package/dist/request/RequestValidator.d.ts.map +1 -1
  203. package/dist/request/RequestValidator.mjs +83 -82
  204. package/dist/request/RequestValidator.mjs.map +1 -1
  205. package/dist/request/ScopeSet.d.ts +88 -88
  206. package/dist/request/ScopeSet.d.ts.map +1 -1
  207. package/dist/request/ScopeSet.mjs +201 -199
  208. package/dist/request/ScopeSet.mjs.map +1 -1
  209. package/dist/request/StoreInCache.d.ts +8 -8
  210. package/dist/response/AuthenticationResult.d.ts +41 -41
  211. package/dist/response/AuthorizationCodePayload.d.ts +13 -13
  212. package/dist/response/DeviceCodeResponse.d.ts +25 -25
  213. package/dist/response/ExternalTokenResponse.d.ts +15 -15
  214. package/dist/response/IMDSBadResponse.d.ts +4 -4
  215. package/dist/response/ResponseHandler.d.ts +67 -67
  216. package/dist/response/ResponseHandler.d.ts.map +1 -1
  217. package/dist/response/ResponseHandler.mjs +314 -313
  218. package/dist/response/ResponseHandler.mjs.map +1 -1
  219. package/dist/response/ServerAuthorizationCodeResponse.d.ts +25 -25
  220. package/dist/response/ServerAuthorizationTokenResponse.d.ts +46 -46
  221. package/dist/telemetry/performance/IPerformanceClient.d.ts +51 -51
  222. package/dist/telemetry/performance/IPerformanceMeasurement.d.ts +5 -5
  223. package/dist/telemetry/performance/PerformanceClient.d.ts +191 -191
  224. package/dist/telemetry/performance/PerformanceClient.d.ts.map +1 -1
  225. package/dist/telemetry/performance/PerformanceClient.mjs +409 -408
  226. package/dist/telemetry/performance/PerformanceClient.mjs.map +1 -1
  227. package/dist/telemetry/performance/PerformanceEvent.d.ts +433 -433
  228. package/dist/telemetry/performance/PerformanceEvent.mjs +234 -234
  229. package/dist/telemetry/performance/StubPerformanceClient.d.ts +24 -24
  230. package/dist/telemetry/performance/StubPerformanceClient.mjs +76 -76
  231. package/dist/telemetry/server/ServerTelemetryManager.d.ts +66 -66
  232. package/dist/telemetry/server/ServerTelemetryManager.d.ts.map +1 -1
  233. package/dist/telemetry/server/ServerTelemetryManager.mjs +197 -197
  234. package/dist/telemetry/server/ServerTelemetryManager.mjs.map +1 -1
  235. package/dist/telemetry/server/ServerTelemetryRequest.d.ts +8 -8
  236. package/dist/url/IUri.d.ts +12 -12
  237. package/dist/url/UrlString.d.ts +83 -83
  238. package/dist/url/UrlString.d.ts.map +1 -1
  239. package/dist/url/UrlString.mjs +283 -281
  240. package/dist/url/UrlString.mjs.map +1 -1
  241. package/dist/utils/Constants.d.ts +366 -363
  242. package/dist/utils/Constants.d.ts.map +1 -1
  243. package/dist/utils/Constants.mjs +376 -368
  244. package/dist/utils/Constants.mjs.map +1 -1
  245. package/dist/utils/FunctionWrappers.d.ts +27 -27
  246. package/dist/utils/FunctionWrappers.mjs +85 -85
  247. package/dist/utils/MsalTypes.d.ts +6 -6
  248. package/dist/utils/ProtocolUtils.d.ts +42 -42
  249. package/dist/utils/ProtocolUtils.d.ts.map +1 -1
  250. package/dist/utils/ProtocolUtils.mjs +71 -70
  251. package/dist/utils/ProtocolUtils.mjs.map +1 -1
  252. package/dist/utils/StringUtils.d.ts +40 -40
  253. package/dist/utils/StringUtils.mjs +95 -95
  254. package/dist/utils/TimeUtils.d.ts +27 -27
  255. package/dist/utils/TimeUtils.mjs +45 -45
  256. package/package.json +1 -1
  257. package/src/account/AuthToken.ts +8 -7
  258. package/src/account/ClientInfo.ts +9 -6
  259. package/src/authority/Authority.ts +76 -94
  260. package/src/authority/AuthorityFactory.ts +21 -9
  261. package/src/authority/RegionDiscovery.ts +21 -18
  262. package/src/cache/CacheManager.ts +37 -77
  263. package/src/cache/entities/AccessTokenEntity.ts +7 -2
  264. package/src/cache/entities/AccountEntity.ts +7 -2
  265. package/src/cache/entities/CredentialEntity.ts +7 -2
  266. package/src/client/AuthorizationCodeClient.ts +32 -10
  267. package/src/client/BaseClient.ts +7 -4
  268. package/src/client/RefreshTokenClient.ts +81 -124
  269. package/src/client/SilentFlowClient.ts +72 -19
  270. package/src/config/ClientConfiguration.ts +6 -7
  271. package/src/crypto/ICrypto.ts +13 -28
  272. package/src/crypto/JoseHeader.ts +6 -3
  273. package/src/crypto/PopTokenGenerator.ts +10 -5
  274. package/src/error/AuthError.ts +24 -26
  275. package/src/error/AuthErrorCodes.ts +10 -0
  276. package/src/error/ClientAuthError.ts +227 -632
  277. package/src/error/ClientAuthErrorCodes.ts +51 -0
  278. package/src/error/ClientConfigurationError.ts +146 -332
  279. package/src/error/ClientConfigurationErrorCodes.ts +28 -0
  280. package/src/error/InteractionRequiredAuthError.ts +60 -55
  281. package/src/error/InteractionRequiredAuthErrorCodes.ts +13 -0
  282. package/src/error/JoseHeaderError.ts +11 -31
  283. package/src/error/JoseHeaderErrorCodes.ts +7 -0
  284. package/src/index.ts +12 -1
  285. package/src/network/INetworkModule.ts +10 -7
  286. package/src/network/NetworkManager.ts +5 -5
  287. package/src/request/AuthenticationHeaderParser.ts +11 -8
  288. package/src/request/RequestParameterBuilder.ts +10 -3
  289. package/src/request/RequestValidator.ts +19 -6
  290. package/src/request/ScopeSet.ts +23 -7
  291. package/src/response/ResponseHandler.ts +37 -17
  292. package/src/telemetry/performance/PerformanceClient.ts +2 -1
  293. package/src/telemetry/server/ServerTelemetryManager.ts +1 -1
  294. package/src/url/UrlString.ts +26 -16
  295. package/src/utils/Constants.ts +11 -3
  296. package/src/utils/ProtocolUtils.ts +8 -12
@@ -5,14 +5,16 @@
5
5
 
6
6
  import { Constants } from "../utils/Constants";
7
7
  import { AuthError } from "./AuthError";
8
+ import * as InteractionRequiredAuthErrorCodes from "./InteractionRequiredAuthErrorCodes";
9
+ export { InteractionRequiredAuthErrorCodes };
8
10
 
9
11
  /**
10
12
  * InteractionRequiredServerErrorMessage contains string constants used by error codes and messages returned by the server indicating interaction is required
11
13
  */
12
14
  export const InteractionRequiredServerErrorMessage = [
13
- "interaction_required",
14
- "consent_required",
15
- "login_required",
15
+ InteractionRequiredAuthErrorCodes.interactionRequired,
16
+ InteractionRequiredAuthErrorCodes.consentRequired,
17
+ InteractionRequiredAuthErrorCodes.loginRequired,
16
18
  ];
17
19
 
18
20
  export const InteractionRequiredAuthSubErrorMessage = [
@@ -23,17 +25,29 @@ export const InteractionRequiredAuthSubErrorMessage = [
23
25
  "consent_required",
24
26
  ];
25
27
 
28
+ const InteractionRequiredAuthErrorMessages = {
29
+ [InteractionRequiredAuthErrorCodes.noTokensFound]:
30
+ "No refresh token found in the cache. Please sign-in.",
31
+ [InteractionRequiredAuthErrorCodes.nativeAccountUnavailable]:
32
+ "The requested account is not available in the native broker. It may have been deleted or logged out. Please sign-in again using an interactive API.",
33
+ };
34
+
26
35
  /**
27
36
  * Interaction required errors defined by the SDK
37
+ * @deprecated Use InteractionRequiredAuthErrorCodes instead
28
38
  */
29
39
  export const InteractionRequiredAuthErrorMessage = {
30
40
  noTokensFoundError: {
31
- code: "no_tokens_found",
32
- desc: "No refresh token found in the cache. Please sign-in.",
41
+ code: InteractionRequiredAuthErrorCodes.noTokensFound,
42
+ desc: InteractionRequiredAuthErrorMessages[
43
+ InteractionRequiredAuthErrorCodes.noTokensFound
44
+ ],
33
45
  },
34
46
  native_account_unavailable: {
35
- code: "native_account_unavailable",
36
- desc: "The requested account is not available in the native broker. It may have been deleted or logged out. Please sign-in again using an interactive API.",
47
+ code: InteractionRequiredAuthErrorCodes.nativeAccountUnavailable,
48
+ desc: InteractionRequiredAuthErrorMessages[
49
+ InteractionRequiredAuthErrorCodes.nativeAccountUnavailable
50
+ ],
37
51
  },
38
52
  };
39
53
 
@@ -80,55 +94,46 @@ export class InteractionRequiredAuthError extends AuthError {
80
94
  this.claims = claims || Constants.EMPTY_STRING;
81
95
  this.name = "InteractionRequiredAuthError";
82
96
  }
97
+ }
83
98
 
84
- /**
85
- * Helper function used to determine if an error thrown by the server requires interaction to resolve
86
- * @param errorCode
87
- * @param errorString
88
- * @param subError
89
- */
90
- static isInteractionRequiredError(
91
- errorCode?: string,
92
- errorString?: string,
93
- subError?: string
94
- ): boolean {
95
- const isInteractionRequiredErrorCode =
96
- !!errorCode &&
97
- InteractionRequiredServerErrorMessage.indexOf(errorCode) > -1;
98
- const isInteractionRequiredSubError =
99
- !!subError &&
100
- InteractionRequiredAuthSubErrorMessage.indexOf(subError) > -1;
101
- const isInteractionRequiredErrorDesc =
102
- !!errorString &&
103
- InteractionRequiredServerErrorMessage.some((irErrorCode) => {
104
- return errorString.indexOf(irErrorCode) > -1;
105
- });
106
-
107
- return (
108
- isInteractionRequiredErrorCode ||
109
- isInteractionRequiredErrorDesc ||
110
- isInteractionRequiredSubError
111
- );
112
- }
99
+ /**
100
+ * Helper function used to determine if an error thrown by the server requires interaction to resolve
101
+ * @param errorCode
102
+ * @param errorString
103
+ * @param subError
104
+ */
105
+ export function isInteractionRequiredError(
106
+ errorCode?: string,
107
+ errorString?: string,
108
+ subError?: string
109
+ ): boolean {
110
+ const isInteractionRequiredErrorCode =
111
+ !!errorCode &&
112
+ InteractionRequiredServerErrorMessage.indexOf(errorCode) > -1;
113
+ const isInteractionRequiredSubError =
114
+ !!subError &&
115
+ InteractionRequiredAuthSubErrorMessage.indexOf(subError) > -1;
116
+ const isInteractionRequiredErrorDesc =
117
+ !!errorString &&
118
+ InteractionRequiredServerErrorMessage.some((irErrorCode) => {
119
+ return errorString.indexOf(irErrorCode) > -1;
120
+ });
113
121
 
114
- /**
115
- * Creates an error thrown when the authorization code required for a token request is null or empty.
116
- */
117
- static createNoTokensFoundError(): InteractionRequiredAuthError {
118
- return new InteractionRequiredAuthError(
119
- InteractionRequiredAuthErrorMessage.noTokensFoundError.code,
120
- InteractionRequiredAuthErrorMessage.noTokensFoundError.desc
121
- );
122
- }
122
+ return (
123
+ isInteractionRequiredErrorCode ||
124
+ isInteractionRequiredErrorDesc ||
125
+ isInteractionRequiredSubError
126
+ );
127
+ }
123
128
 
124
- /**
125
- * Creates an error thrown when the native broker returns ACCOUNT_UNAVAILABLE status, indicating that the account was removed and interactive sign-in is required
126
- * @returns
127
- */
128
- static createNativeAccountUnavailableError(): InteractionRequiredAuthError {
129
- return new InteractionRequiredAuthError(
130
- InteractionRequiredAuthErrorMessage.native_account_unavailable.code,
131
- InteractionRequiredAuthErrorMessage.native_account_unavailable.desc
132
- );
133
- }
129
+ /**
130
+ * Creates an InteractionRequiredAuthError
131
+ */
132
+ export function createInteractionRequiredAuthError(
133
+ errorCode: string
134
+ ): InteractionRequiredAuthError {
135
+ return new InteractionRequiredAuthError(
136
+ errorCode,
137
+ InteractionRequiredAuthErrorMessages[errorCode]
138
+ );
134
139
  }
@@ -0,0 +1,13 @@
1
+ /*
2
+ * Copyright (c) Microsoft Corporation. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+
6
+ // Codes defined by MSAL
7
+ export const noTokensFound = "no_tokens_found";
8
+ export const nativeAccountUnavailable = "native_account_unavailable";
9
+
10
+ // Codes potentially returned by server
11
+ export const interactionRequired = "interaction_required";
12
+ export const consentRequired = "consent_required";
13
+ export const loginRequired = "login_required";
@@ -4,19 +4,14 @@
4
4
  */
5
5
 
6
6
  import { AuthError } from "./AuthError";
7
+ import * as JoseHeaderErrorCodes from "./JoseHeaderErrorCodes";
8
+ export { JoseHeaderErrorCodes };
7
9
 
8
- /**
9
- * ClientAuthErrorMessage class containing string constants used by error codes and messages.
10
- */
11
- export const JoseHeaderErrorMessage = {
12
- missingKidError: {
13
- code: "missing_kid_error",
14
- desc: "The JOSE Header for the requested JWT, JWS or JWK object requires a keyId to be configured as the 'kid' header claim. No 'kid' value was provided.",
15
- },
16
- missingAlgError: {
17
- code: "missing_alg_error",
18
- desc: "The JOSE Header for the requested JWT, JWS or JWK object requires an algorithm to be specified as the 'alg' header claim. No 'alg' value was provided.",
19
- },
10
+ export const JoseHeaderErrorMessages = {
11
+ [JoseHeaderErrorCodes.missingKidError]:
12
+ "The JOSE Header for the requested JWT, JWS or JWK object requires a keyId to be configured as the 'kid' header claim. No 'kid' value was provided.",
13
+ [JoseHeaderErrorCodes.missingAlgError]:
14
+ "The JOSE Header for the requested JWT, JWS or JWK object requires an algorithm to be specified as the 'alg' header claim. No 'alg' value was provided.",
20
15
  };
21
16
 
22
17
  /**
@@ -29,24 +24,9 @@ export class JoseHeaderError extends AuthError {
29
24
 
30
25
  Object.setPrototypeOf(this, JoseHeaderError.prototype);
31
26
  }
27
+ }
32
28
 
33
- /**
34
- * Creates an error thrown when keyId isn't set on JOSE header.
35
- */
36
- static createMissingKidError(): JoseHeaderError {
37
- return new JoseHeaderError(
38
- JoseHeaderErrorMessage.missingKidError.code,
39
- JoseHeaderErrorMessage.missingKidError.desc
40
- );
41
- }
42
-
43
- /**
44
- * Creates an error thrown when algorithm isn't set on JOSE header.
45
- */
46
- static createMissingAlgError(): JoseHeaderError {
47
- return new JoseHeaderError(
48
- JoseHeaderErrorMessage.missingAlgError.code,
49
- JoseHeaderErrorMessage.missingAlgError.desc
50
- );
51
- }
29
+ /** Returns JoseHeaderError object */
30
+ export function createJoseHeaderError(code: string): JoseHeaderError {
31
+ return new JoseHeaderError(code, JoseHeaderErrorMessages[code]);
52
32
  }
@@ -0,0 +1,7 @@
1
+ /*
2
+ * Copyright (c) Microsoft Corporation. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+
6
+ export const missingKidError = "missing_kid_error";
7
+ export const missingAlgError = "missing_alg_error";
package/src/index.ts CHANGED
@@ -137,17 +137,28 @@ export { ILoggerCallback, LogLevel, Logger } from "./logger/Logger";
137
137
  // Errors
138
138
  export {
139
139
  InteractionRequiredAuthError,
140
+ InteractionRequiredAuthErrorCodes,
140
141
  InteractionRequiredAuthErrorMessage,
142
+ createInteractionRequiredAuthError,
141
143
  } from "./error/InteractionRequiredAuthError";
142
- export { AuthError, AuthErrorMessage } from "./error/AuthError";
144
+ export {
145
+ AuthError,
146
+ AuthErrorMessage,
147
+ AuthErrorCodes,
148
+ createAuthError,
149
+ } from "./error/AuthError";
143
150
  export { ServerError } from "./error/ServerError";
144
151
  export {
145
152
  ClientAuthError,
146
153
  ClientAuthErrorMessage,
154
+ ClientAuthErrorCodes,
155
+ createClientAuthError,
147
156
  } from "./error/ClientAuthError";
148
157
  export {
149
158
  ClientConfigurationError,
150
159
  ClientConfigurationErrorMessage,
160
+ ClientConfigurationErrorCodes,
161
+ createClientConfigurationError,
151
162
  } from "./error/ClientConfigurationError";
152
163
  // Constants and Utils
153
164
  export {
@@ -3,7 +3,10 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
 
6
- import { AuthError } from "../error/AuthError";
6
+ import {
7
+ ClientAuthErrorCodes,
8
+ createClientAuthError,
9
+ } from "../error/ClientAuthError";
7
10
  import { NetworkResponse } from "./NetworkManager";
8
11
 
9
12
  /**
@@ -45,13 +48,13 @@ export interface INetworkModule {
45
48
 
46
49
  export const StubbedNetworkModule: INetworkModule = {
47
50
  sendGetRequestAsync: () => {
48
- const notImplErr =
49
- "Network interface - sendGetRequestAsync() has not been implemented for the Network interface.";
50
- return Promise.reject(AuthError.createUnexpectedError(notImplErr));
51
+ return Promise.reject(
52
+ createClientAuthError(ClientAuthErrorCodes.methodNotImplemented)
53
+ );
51
54
  },
52
55
  sendPostRequestAsync: () => {
53
- const notImplErr =
54
- "Network interface - sendPostRequestAsync() has not been implemented for the Network interface.";
55
- return Promise.reject(AuthError.createUnexpectedError(notImplErr));
56
+ return Promise.reject(
57
+ createClientAuthError(ClientAuthErrorCodes.methodNotImplemented)
58
+ );
56
59
  },
57
60
  };
@@ -8,7 +8,10 @@ import { RequestThumbprint } from "./RequestThumbprint";
8
8
  import { ThrottlingUtils } from "./ThrottlingUtils";
9
9
  import { CacheManager } from "../cache/CacheManager";
10
10
  import { AuthError } from "../error/AuthError";
11
- import { ClientAuthError } from "../error/ClientAuthError";
11
+ import {
12
+ ClientAuthErrorCodes,
13
+ createClientAuthError,
14
+ } from "../error/ClientAuthError";
12
15
  import { ServerAuthorizationTokenResponse } from "../response/ServerAuthorizationTokenResponse";
13
16
 
14
17
  export type NetworkResponse<T> = {
@@ -62,10 +65,7 @@ export class NetworkManager {
62
65
  if (e instanceof AuthError) {
63
66
  throw e;
64
67
  } else {
65
- throw ClientAuthError.createNetworkError(
66
- tokenEndpoint,
67
- e as string
68
- );
68
+ throw createClientAuthError(ClientAuthErrorCodes.networkError);
69
69
  }
70
70
  }
71
71
 
@@ -3,7 +3,10 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
 
6
- import { ClientConfigurationError } from "../error/ClientConfigurationError";
6
+ import {
7
+ createClientConfigurationError,
8
+ ClientConfigurationErrorCodes,
9
+ } from "../error/ClientConfigurationError";
7
10
  import { Constants, HeaderNames } from "../utils/Constants";
8
11
 
9
12
  type WWWAuthenticateChallenges = {
@@ -40,9 +43,8 @@ export class AuthenticationHeaderParser {
40
43
  if (authenticationInfoChallenges.nextnonce) {
41
44
  return authenticationInfoChallenges.nextnonce;
42
45
  }
43
- throw ClientConfigurationError.createInvalidAuthenticationHeaderError(
44
- HeaderNames.AuthenticationInfo,
45
- "nextnonce challenge is missing."
46
+ throw createClientConfigurationError(
47
+ ClientConfigurationErrorCodes.invalidAuthenticationHeader
46
48
  );
47
49
  }
48
50
 
@@ -56,14 +58,15 @@ export class AuthenticationHeaderParser {
56
58
  if (wwwAuthenticateChallenges.nonce) {
57
59
  return wwwAuthenticateChallenges.nonce;
58
60
  }
59
- throw ClientConfigurationError.createInvalidAuthenticationHeaderError(
60
- HeaderNames.WWWAuthenticate,
61
- "nonce challenge is missing."
61
+ throw createClientConfigurationError(
62
+ ClientConfigurationErrorCodes.invalidAuthenticationHeader
62
63
  );
63
64
  }
64
65
 
65
66
  // If neither header is present, throw missing headers error
66
- throw ClientConfigurationError.createMissingNonceAuthenticationHeadersError();
67
+ throw createClientConfigurationError(
68
+ ClientConfigurationErrorCodes.missingNonceAuthenticationHeader
69
+ );
67
70
  }
68
71
 
69
72
  /**
@@ -17,7 +17,10 @@ import {
17
17
  HeaderNames,
18
18
  } from "../utils/Constants";
19
19
  import { ScopeSet } from "./ScopeSet";
20
- import { ClientConfigurationError } from "../error/ClientConfigurationError";
20
+ import {
21
+ createClientConfigurationError,
22
+ ClientConfigurationErrorCodes,
23
+ } from "../error/ClientConfigurationError";
21
24
  import { StringDict } from "../utils/MsalTypes";
22
25
  import { RequestValidator } from "./RequestValidator";
23
26
  import {
@@ -330,7 +333,9 @@ export class RequestParameterBuilder {
330
333
  encodeURIComponent(codeChallengeMethod)
331
334
  );
332
335
  } else {
333
- throw ClientConfigurationError.createInvalidCodeChallengeParamsError();
336
+ throw createClientConfigurationError(
337
+ ClientConfigurationErrorCodes.pkceParamsMissing
338
+ );
334
339
  }
335
340
  }
336
341
 
@@ -480,7 +485,9 @@ export class RequestParameterBuilder {
480
485
  try {
481
486
  mergedClaims = JSON.parse(claims);
482
487
  } catch (e) {
483
- throw ClientConfigurationError.createInvalidClaimsRequestError();
488
+ throw createClientConfigurationError(
489
+ ClientConfigurationErrorCodes.invalidClaims
490
+ );
484
491
  }
485
492
  }
486
493
 
@@ -3,7 +3,10 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
 
6
- import { ClientConfigurationError } from "../error/ClientConfigurationError";
6
+ import {
7
+ createClientConfigurationError,
8
+ ClientConfigurationErrorCodes,
9
+ } from "../error/ClientConfigurationError";
7
10
  import { PromptValue, CodeChallengeMethodValues } from "../utils/Constants";
8
11
  import { StringDict } from "../utils/MsalTypes";
9
12
 
@@ -17,7 +20,9 @@ export class RequestValidator {
17
20
  */
18
21
  static validateRedirectUri(redirectUri: string): void {
19
22
  if (!redirectUri) {
20
- throw ClientConfigurationError.createRedirectUriEmptyError();
23
+ throw createClientConfigurationError(
24
+ ClientConfigurationErrorCodes.redirectUriEmpty
25
+ );
21
26
  }
22
27
  }
23
28
 
@@ -33,7 +38,9 @@ export class RequestValidator {
33
38
  }
34
39
 
35
40
  if (promptValues.indexOf(prompt) < 0) {
36
- throw ClientConfigurationError.createInvalidPromptError(prompt);
41
+ throw createClientConfigurationError(
42
+ ClientConfigurationErrorCodes.invalidPromptValue
43
+ );
37
44
  }
38
45
  }
39
46
 
@@ -41,7 +48,9 @@ export class RequestValidator {
41
48
  try {
42
49
  JSON.parse(claims);
43
50
  } catch (e) {
44
- throw ClientConfigurationError.createInvalidClaimsRequestError();
51
+ throw createClientConfigurationError(
52
+ ClientConfigurationErrorCodes.invalidClaims
53
+ );
45
54
  }
46
55
  }
47
56
 
@@ -55,7 +64,9 @@ export class RequestValidator {
55
64
  codeChallengeMethod: string
56
65
  ): void {
57
66
  if (!codeChallenge || !codeChallengeMethod) {
58
- throw ClientConfigurationError.createInvalidCodeChallengeParamsError();
67
+ throw createClientConfigurationError(
68
+ ClientConfigurationErrorCodes.pkceParamsMissing
69
+ );
59
70
  } else {
60
71
  this.validateCodeChallengeMethod(codeChallengeMethod);
61
72
  }
@@ -72,7 +83,9 @@ export class RequestValidator {
72
83
  CodeChallengeMethodValues.S256,
73
84
  ].indexOf(codeChallengeMethod) < 0
74
85
  ) {
75
- throw ClientConfigurationError.createInvalidCodeChallengeMethodError();
86
+ throw createClientConfigurationError(
87
+ ClientConfigurationErrorCodes.invalidCodeChallengeMethod
88
+ );
76
89
  }
77
90
  }
78
91
 
@@ -3,9 +3,15 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
 
6
- import { ClientConfigurationError } from "../error/ClientConfigurationError";
6
+ import {
7
+ createClientConfigurationError,
8
+ ClientConfigurationErrorCodes,
9
+ } from "../error/ClientConfigurationError";
7
10
  import { StringUtils } from "../utils/StringUtils";
8
- import { ClientAuthError } from "../error/ClientAuthError";
11
+ import {
12
+ ClientAuthErrorCodes,
13
+ createClientAuthError,
14
+ } from "../error/ClientAuthError";
9
15
  import { Constants, OIDC_SCOPES } from "../utils/Constants";
10
16
 
11
17
  /**
@@ -69,7 +75,9 @@ export class ScopeSet {
69
75
  private validateInputScopes(inputScopes: Array<string>): void {
70
76
  // Check if scopes are required but not given or is an empty array
71
77
  if (!inputScopes || inputScopes.length < 1) {
72
- throw ClientConfigurationError.createEmptyScopesArrayError();
78
+ throw createClientConfigurationError(
79
+ ClientConfigurationErrorCodes.emptyInputScopesError
80
+ );
73
81
  }
74
82
  }
75
83
 
@@ -133,7 +141,9 @@ export class ScopeSet {
133
141
  try {
134
142
  newScopes.forEach((newScope) => this.appendScope(newScope));
135
143
  } catch (e) {
136
- throw ClientAuthError.createAppendScopeSetError(e as string);
144
+ throw createClientAuthError(
145
+ ClientAuthErrorCodes.cannotAppendScopeSet
146
+ );
137
147
  }
138
148
  }
139
149
 
@@ -143,7 +153,9 @@ export class ScopeSet {
143
153
  */
144
154
  removeScope(scope: string): void {
145
155
  if (!scope) {
146
- throw ClientAuthError.createRemoveEmptyScopeFromSetError(scope);
156
+ throw createClientAuthError(
157
+ ClientAuthErrorCodes.cannotRemoveEmptyScope
158
+ );
147
159
  }
148
160
  this.scopes.delete(scope.trim());
149
161
  }
@@ -164,7 +176,9 @@ export class ScopeSet {
164
176
  */
165
177
  unionScopeSets(otherScopes: ScopeSet): Set<string> {
166
178
  if (!otherScopes) {
167
- throw ClientAuthError.createEmptyInputScopeSetError();
179
+ throw createClientAuthError(
180
+ ClientAuthErrorCodes.emptyInputScopeSet
181
+ );
168
182
  }
169
183
  const unionScopes = new Set<string>(); // Iterator in constructor not supported in IE11
170
184
  otherScopes.scopes.forEach((scope) =>
@@ -180,7 +194,9 @@ export class ScopeSet {
180
194
  */
181
195
  intersectingScopeSets(otherScopes: ScopeSet): boolean {
182
196
  if (!otherScopes) {
183
- throw ClientAuthError.createEmptyInputScopeSetError();
197
+ throw createClientAuthError(
198
+ ClientAuthErrorCodes.emptyInputScopeSet
199
+ );
184
200
  }
185
201
 
186
202
  // Do not allow OIDC scopes to be the only intersecting scopes
@@ -6,7 +6,10 @@
6
6
  import { ServerAuthorizationTokenResponse } from "./ServerAuthorizationTokenResponse";
7
7
  import { buildClientInfo } from "../account/ClientInfo";
8
8
  import { ICrypto } from "../crypto/ICrypto";
9
- import { ClientAuthError } from "../error/ClientAuthError";
9
+ import {
10
+ ClientAuthErrorCodes,
11
+ createClientAuthError,
12
+ } from "../error/ClientAuthError";
10
13
  import { ServerAuthorizationCodeResponse } from "./ServerAuthorizationCodeResponse";
11
14
  import { Logger } from "../logger/Logger";
12
15
  import { ServerError } from "../error/ServerError";
@@ -17,7 +20,10 @@ import { Authority } from "../authority/Authority";
17
20
  import { IdTokenEntity } from "../cache/entities/IdTokenEntity";
18
21
  import { AccessTokenEntity } from "../cache/entities/AccessTokenEntity";
19
22
  import { RefreshTokenEntity } from "../cache/entities/RefreshTokenEntity";
20
- import { InteractionRequiredAuthError } from "../error/InteractionRequiredAuthError";
23
+ import {
24
+ InteractionRequiredAuthError,
25
+ isInteractionRequiredError,
26
+ } from "../error/InteractionRequiredAuthError";
21
27
  import { CacheRecord } from "../cache/entities/CacheRecord";
22
28
  import { CacheManager } from "../cache/CacheManager";
23
29
  import { ProtocolUtils, RequestStateObject } from "../utils/ProtocolUtils";
@@ -84,8 +90,14 @@ export class ResponseHandler {
84
90
  ): void {
85
91
  if (!serverResponseHash.state || !cachedState) {
86
92
  throw serverResponseHash.state
87
- ? ClientAuthError.createStateNotFoundError("Cached State")
88
- : ClientAuthError.createStateNotFoundError("Server State");
93
+ ? createClientAuthError(
94
+ ClientAuthErrorCodes.stateNotFound,
95
+ "Cached State"
96
+ )
97
+ : createClientAuthError(
98
+ ClientAuthErrorCodes.stateNotFound,
99
+ "Server State"
100
+ );
89
101
  }
90
102
 
91
103
  let decodedServerResponseHash: string;
@@ -96,23 +108,23 @@ export class ResponseHandler {
96
108
  serverResponseHash.state
97
109
  );
98
110
  } catch (e) {
99
- throw ClientAuthError.createInvalidStateError(
100
- serverResponseHash.state,
101
- `Server response hash URI could not be decoded`
111
+ throw createClientAuthError(
112
+ ClientAuthErrorCodes.invalidState,
113
+ serverResponseHash.state
102
114
  );
103
115
  }
104
116
 
105
117
  try {
106
118
  decodedCachedState = decodeURIComponent(cachedState);
107
119
  } catch (e) {
108
- throw ClientAuthError.createInvalidStateError(
109
- serverResponseHash.state,
110
- `Cached state URI could not be decoded`
120
+ throw createClientAuthError(
121
+ ClientAuthErrorCodes.invalidState,
122
+ serverResponseHash.state
111
123
  );
112
124
  }
113
125
 
114
126
  if (decodedServerResponseHash !== decodedCachedState) {
115
- throw ClientAuthError.createStateMismatchError();
127
+ throw createClientAuthError(ClientAuthErrorCodes.stateMismatch);
116
128
  }
117
129
 
118
130
  // Check for error
@@ -122,7 +134,7 @@ export class ResponseHandler {
122
134
  serverResponseHash.suberror
123
135
  ) {
124
136
  if (
125
- InteractionRequiredAuthError.isInteractionRequiredError(
137
+ isInteractionRequiredError(
126
138
  serverResponseHash.error,
127
139
  serverResponseHash.error_description,
128
140
  serverResponseHash.suberror
@@ -202,7 +214,7 @@ export class ResponseHandler {
202
214
  }
203
215
 
204
216
  if (
205
- InteractionRequiredAuthError.isInteractionRequiredError(
217
+ isInteractionRequiredError(
206
218
  serverResponse.error,
207
219
  serverResponse.error_description,
208
220
  serverResponse.suberror
@@ -255,7 +267,9 @@ export class ResponseHandler {
255
267
  // token nonce check (TODO: Add a warning if no nonce is given?)
256
268
  if (authCodePayload && authCodePayload.nonce) {
257
269
  if (idTokenClaims.nonce !== authCodePayload.nonce) {
258
- throw ClientAuthError.createNonceMismatchError();
270
+ throw createClientAuthError(
271
+ ClientAuthErrorCodes.nonceMismatch
272
+ );
259
273
  }
260
274
  }
261
275
 
@@ -263,7 +277,9 @@ export class ResponseHandler {
263
277
  if (request.maxAge || request.maxAge === 0) {
264
278
  const authTime = idTokenClaims.auth_time;
265
279
  if (!authTime) {
266
- throw ClientAuthError.createAuthTimeNotFoundError();
280
+ throw createClientAuthError(
281
+ ClientAuthErrorCodes.authTimeNotFound
282
+ );
267
283
  }
268
284
 
269
285
  checkMaxAge(authTime, request.maxAge);
@@ -389,7 +405,9 @@ export class ResponseHandler {
389
405
  ): CacheRecord {
390
406
  const env = authority.getPreferredCache();
391
407
  if (!env) {
392
- throw ClientAuthError.createInvalidCacheEnvironmentError();
408
+ throw createClientAuthError(
409
+ ClientAuthErrorCodes.invalidCacheEnvironment
410
+ );
393
411
  }
394
412
 
395
413
  // IdToken: non AAD scenarios can have empty realm
@@ -537,7 +555,9 @@ export class ResponseHandler {
537
555
  const { secret, keyId } = cacheRecord.accessToken;
538
556
 
539
557
  if (!keyId) {
540
- throw ClientAuthError.createKeyIdMissingError();
558
+ throw createClientAuthError(
559
+ ClientAuthErrorCodes.keyIdMissing
560
+ );
541
561
  }
542
562
 
543
563
  accessToken = await popTokenGenerator.signPopToken(