@azure/msal-common 14.0.3 → 14.1.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 (226) hide show
  1. package/dist/account/AccountInfo.d.ts +0 -1
  2. package/dist/account/AccountInfo.d.ts.map +1 -1
  3. package/dist/account/AuthToken.d.ts.map +1 -1
  4. package/dist/account/AuthToken.mjs +7 -6
  5. package/dist/account/AuthToken.mjs.map +1 -1
  6. package/dist/account/CcsCredential.mjs +1 -1
  7. package/dist/account/ClientInfo.d.ts.map +1 -1
  8. package/dist/account/ClientInfo.mjs +6 -5
  9. package/dist/account/ClientInfo.mjs.map +1 -1
  10. package/dist/authority/Authority.d.ts.map +1 -1
  11. package/dist/authority/Authority.mjs +28 -50
  12. package/dist/authority/Authority.mjs.map +1 -1
  13. package/dist/authority/AuthorityFactory.d.ts.map +1 -1
  14. package/dist/authority/AuthorityFactory.mjs +9 -7
  15. package/dist/authority/AuthorityFactory.mjs.map +1 -1
  16. package/dist/authority/AuthorityMetadata.mjs +1 -1
  17. package/dist/authority/AuthorityOptions.mjs +1 -1
  18. package/dist/authority/AuthorityType.mjs +1 -1
  19. package/dist/authority/CloudInstanceDiscoveryErrorResponse.mjs +1 -1
  20. package/dist/authority/CloudInstanceDiscoveryResponse.mjs +1 -1
  21. package/dist/authority/OpenIdConfigResponse.mjs +1 -1
  22. package/dist/authority/ProtocolMode.mjs +1 -1
  23. package/dist/authority/RegionDiscovery.d.ts +3 -1
  24. package/dist/authority/RegionDiscovery.d.ts.map +1 -1
  25. package/dist/authority/RegionDiscovery.mjs +7 -8
  26. package/dist/authority/RegionDiscovery.mjs.map +1 -1
  27. package/dist/cache/CacheManager.d.ts +25 -7
  28. package/dist/cache/CacheManager.d.ts.map +1 -1
  29. package/dist/cache/CacheManager.mjs +98 -71
  30. package/dist/cache/CacheManager.mjs.map +1 -1
  31. package/dist/cache/entities/AccessTokenEntity.d.ts.map +1 -1
  32. package/dist/cache/entities/AccessTokenEntity.mjs +4 -3
  33. package/dist/cache/entities/AccessTokenEntity.mjs.map +1 -1
  34. package/dist/cache/entities/AccountEntity.d.ts.map +1 -1
  35. package/dist/cache/entities/AccountEntity.mjs +4 -3
  36. package/dist/cache/entities/AccountEntity.mjs.map +1 -1
  37. package/dist/cache/entities/AppMetadataEntity.mjs +1 -1
  38. package/dist/cache/entities/AuthorityMetadataEntity.mjs +1 -1
  39. package/dist/cache/entities/CacheRecord.mjs +1 -1
  40. package/dist/cache/entities/CredentialEntity.d.ts.map +1 -1
  41. package/dist/cache/entities/CredentialEntity.mjs +4 -3
  42. package/dist/cache/entities/CredentialEntity.mjs.map +1 -1
  43. package/dist/cache/entities/IdTokenEntity.mjs +1 -1
  44. package/dist/cache/entities/RefreshTokenEntity.mjs +1 -1
  45. package/dist/cache/entities/ServerTelemetryEntity.mjs +1 -1
  46. package/dist/cache/entities/ThrottlingEntity.mjs +1 -1
  47. package/dist/cache/persistence/TokenCacheContext.mjs +1 -1
  48. package/dist/cache/utils/CacheTypes.d.ts +3 -6
  49. package/dist/cache/utils/CacheTypes.d.ts.map +1 -1
  50. package/dist/client/AuthorizationCodeClient.d.ts.map +1 -1
  51. package/dist/client/AuthorizationCodeClient.mjs +13 -11
  52. package/dist/client/AuthorizationCodeClient.mjs.map +1 -1
  53. package/dist/client/BaseClient.d.ts.map +1 -1
  54. package/dist/client/BaseClient.mjs +5 -4
  55. package/dist/client/BaseClient.mjs.map +1 -1
  56. package/dist/client/RefreshTokenClient.d.ts.map +1 -1
  57. package/dist/client/RefreshTokenClient.mjs +33 -74
  58. package/dist/client/RefreshTokenClient.mjs.map +1 -1
  59. package/dist/client/SilentFlowClient.d.ts +2 -1
  60. package/dist/client/SilentFlowClient.d.ts.map +1 -1
  61. package/dist/client/SilentFlowClient.mjs +43 -19
  62. package/dist/client/SilentFlowClient.mjs.map +1 -1
  63. package/dist/config/ClientConfiguration.d.ts.map +1 -1
  64. package/dist/config/ClientConfiguration.mjs +5 -6
  65. package/dist/config/ClientConfiguration.mjs.map +1 -1
  66. package/dist/crypto/ICrypto.d.ts +0 -4
  67. package/dist/crypto/ICrypto.d.ts.map +1 -1
  68. package/dist/crypto/ICrypto.mjs +11 -22
  69. package/dist/crypto/ICrypto.mjs.map +1 -1
  70. package/dist/crypto/JoseHeader.d.ts.map +1 -1
  71. package/dist/crypto/JoseHeader.mjs +5 -4
  72. package/dist/crypto/JoseHeader.mjs.map +1 -1
  73. package/dist/crypto/PopTokenGenerator.d.ts +2 -1
  74. package/dist/crypto/PopTokenGenerator.d.ts.map +1 -1
  75. package/dist/crypto/PopTokenGenerator.mjs +4 -4
  76. package/dist/crypto/PopTokenGenerator.mjs.map +1 -1
  77. package/dist/error/AuthError.d.ts +8 -11
  78. package/dist/error/AuthError.d.ts.map +1 -1
  79. package/dist/error/AuthError.mjs +19 -21
  80. package/dist/error/AuthError.mjs.map +1 -1
  81. package/dist/error/AuthErrorCodes.d.ts +6 -0
  82. package/dist/error/AuthErrorCodes.d.ts.map +1 -0
  83. package/dist/error/AuthErrorCodes.mjs +14 -0
  84. package/dist/error/AuthErrorCodes.mjs.map +1 -0
  85. package/dist/error/ClientAuthError.d.ts +54 -234
  86. package/dist/error/ClientAuthError.d.ts.map +1 -1
  87. package/dist/error/ClientAuthError.mjs +149 -421
  88. package/dist/error/ClientAuthError.mjs.map +1 -1
  89. package/dist/error/ClientAuthErrorCodes.d.ts +44 -0
  90. package/dist/error/ClientAuthErrorCodes.d.ts.map +1 -0
  91. package/dist/error/ClientAuthErrorCodes.mjs +52 -0
  92. package/dist/error/ClientAuthErrorCodes.mjs.map +1 -0
  93. package/dist/error/ClientConfigurationError.d.ts +31 -125
  94. package/dist/error/ClientConfigurationError.d.ts.map +1 -1
  95. package/dist/error/ClientConfigurationError.mjs +81 -222
  96. package/dist/error/ClientConfigurationError.mjs.map +1 -1
  97. package/dist/error/ClientConfigurationErrorCodes.d.ts +23 -0
  98. package/dist/error/ClientConfigurationErrorCodes.d.ts.map +1 -0
  99. package/dist/error/ClientConfigurationErrorCodes.mjs +31 -0
  100. package/dist/error/ClientConfigurationErrorCodes.mjs.map +1 -0
  101. package/dist/error/InteractionRequiredAuthError.d.ts +14 -16
  102. package/dist/error/InteractionRequiredAuthError.d.ts.map +1 -1
  103. package/dist/error/InteractionRequiredAuthError.mjs +42 -41
  104. package/dist/error/InteractionRequiredAuthError.mjs.map +1 -1
  105. package/dist/error/InteractionRequiredAuthErrorCodes.d.ts +6 -0
  106. package/dist/error/InteractionRequiredAuthErrorCodes.d.ts.map +1 -0
  107. package/dist/error/InteractionRequiredAuthErrorCodes.mjs +16 -0
  108. package/dist/error/InteractionRequiredAuthErrorCodes.mjs.map +1 -0
  109. package/dist/error/JoseHeaderError.d.ts +7 -20
  110. package/dist/error/JoseHeaderError.d.ts.map +1 -1
  111. package/dist/error/JoseHeaderError.mjs +10 -26
  112. package/dist/error/JoseHeaderError.mjs.map +1 -1
  113. package/dist/error/JoseHeaderErrorCodes.d.ts +3 -0
  114. package/dist/error/JoseHeaderErrorCodes.d.ts.map +1 -0
  115. package/dist/error/JoseHeaderErrorCodes.mjs +11 -0
  116. package/dist/error/JoseHeaderErrorCodes.mjs.map +1 -0
  117. package/dist/error/ServerError.mjs +1 -1
  118. package/dist/index.cjs +942 -1210
  119. package/dist/index.cjs.map +1 -1
  120. package/dist/index.d.ts +5 -5
  121. package/dist/index.d.ts.map +1 -1
  122. package/dist/index.mjs +13 -5
  123. package/dist/index.mjs.map +1 -1
  124. package/dist/logger/Logger.mjs +1 -1
  125. package/dist/network/INetworkModule.d.ts.map +1 -1
  126. package/dist/network/INetworkModule.mjs +5 -6
  127. package/dist/network/INetworkModule.mjs.map +1 -1
  128. package/dist/network/NetworkManager.d.ts.map +1 -1
  129. package/dist/network/NetworkManager.mjs +4 -3
  130. package/dist/network/NetworkManager.mjs.map +1 -1
  131. package/dist/network/ThrottlingUtils.mjs +1 -1
  132. package/dist/packageMetadata.d.ts +1 -1
  133. package/dist/packageMetadata.mjs +2 -2
  134. package/dist/request/AuthenticationHeaderParser.d.ts.map +1 -1
  135. package/dist/request/AuthenticationHeaderParser.mjs +7 -6
  136. package/dist/request/AuthenticationHeaderParser.mjs.map +1 -1
  137. package/dist/request/CommonRefreshTokenRequest.d.ts +3 -0
  138. package/dist/request/CommonRefreshTokenRequest.d.ts.map +1 -1
  139. package/dist/request/CommonSilentFlowRequest.d.ts +2 -0
  140. package/dist/request/CommonSilentFlowRequest.d.ts.map +1 -1
  141. package/dist/request/RequestParameterBuilder.d.ts.map +1 -1
  142. package/dist/request/RequestParameterBuilder.mjs +5 -4
  143. package/dist/request/RequestParameterBuilder.mjs.map +1 -1
  144. package/dist/request/RequestValidator.d.ts.map +1 -1
  145. package/dist/request/RequestValidator.mjs +8 -7
  146. package/dist/request/RequestValidator.mjs.map +1 -1
  147. package/dist/request/ScopeSet.d.ts.map +1 -1
  148. package/dist/request/ScopeSet.mjs +10 -8
  149. package/dist/request/ScopeSet.mjs.map +1 -1
  150. package/dist/response/ResponseHandler.d.ts.map +1 -1
  151. package/dist/response/ResponseHandler.mjs +15 -14
  152. package/dist/response/ResponseHandler.mjs.map +1 -1
  153. package/dist/telemetry/performance/PerformanceClient.d.ts.map +1 -1
  154. package/dist/telemetry/performance/PerformanceClient.mjs +3 -2
  155. package/dist/telemetry/performance/PerformanceClient.mjs.map +1 -1
  156. package/dist/telemetry/performance/PerformanceEvent.d.ts +8 -0
  157. package/dist/telemetry/performance/PerformanceEvent.d.ts.map +1 -1
  158. package/dist/telemetry/performance/PerformanceEvent.mjs +9 -1
  159. package/dist/telemetry/performance/PerformanceEvent.mjs.map +1 -1
  160. package/dist/telemetry/performance/StubPerformanceClient.mjs +1 -1
  161. package/dist/telemetry/server/ServerTelemetryManager.d.ts.map +1 -1
  162. package/dist/telemetry/server/ServerTelemetryManager.mjs +2 -2
  163. package/dist/telemetry/server/ServerTelemetryManager.mjs.map +1 -1
  164. package/dist/url/UrlString.d.ts.map +1 -1
  165. package/dist/url/UrlString.mjs +13 -11
  166. package/dist/url/UrlString.mjs.map +1 -1
  167. package/dist/utils/Constants.d.ts +6 -3
  168. package/dist/utils/Constants.d.ts.map +1 -1
  169. package/dist/utils/Constants.mjs +12 -4
  170. package/dist/utils/Constants.mjs.map +1 -1
  171. package/dist/utils/FunctionWrappers.d.ts.map +1 -1
  172. package/dist/utils/FunctionWrappers.mjs +1 -2
  173. package/dist/utils/FunctionWrappers.mjs.map +1 -1
  174. package/dist/utils/ProtocolUtils.d.ts.map +1 -1
  175. package/dist/utils/ProtocolUtils.mjs +7 -6
  176. package/dist/utils/ProtocolUtils.mjs.map +1 -1
  177. package/dist/utils/StringUtils.mjs +1 -1
  178. package/dist/utils/TimeUtils.mjs +1 -1
  179. package/package.json +1 -1
  180. package/src/account/AccountInfo.ts +0 -1
  181. package/src/account/AuthToken.ts +8 -7
  182. package/src/account/ClientInfo.ts +9 -6
  183. package/src/authority/Authority.ts +76 -94
  184. package/src/authority/AuthorityFactory.ts +21 -9
  185. package/src/authority/RegionDiscovery.ts +21 -18
  186. package/src/cache/CacheManager.ts +133 -95
  187. package/src/cache/entities/AccessTokenEntity.ts +7 -2
  188. package/src/cache/entities/AccountEntity.ts +7 -2
  189. package/src/cache/entities/CredentialEntity.ts +7 -2
  190. package/src/cache/utils/CacheTypes.ts +6 -6
  191. package/src/client/AuthorizationCodeClient.ts +35 -11
  192. package/src/client/BaseClient.ts +7 -4
  193. package/src/client/RefreshTokenClient.ts +100 -126
  194. package/src/client/SilentFlowClient.ts +72 -19
  195. package/src/config/ClientConfiguration.ts +6 -7
  196. package/src/crypto/ICrypto.ts +12 -34
  197. package/src/crypto/JoseHeader.ts +6 -3
  198. package/src/crypto/PopTokenGenerator.ts +10 -5
  199. package/src/error/AuthError.ts +24 -26
  200. package/src/error/AuthErrorCodes.ts +10 -0
  201. package/src/error/ClientAuthError.ts +227 -632
  202. package/src/error/ClientAuthErrorCodes.ts +51 -0
  203. package/src/error/ClientConfigurationError.ts +146 -332
  204. package/src/error/ClientConfigurationErrorCodes.ts +28 -0
  205. package/src/error/InteractionRequiredAuthError.ts +60 -55
  206. package/src/error/InteractionRequiredAuthErrorCodes.ts +13 -0
  207. package/src/error/JoseHeaderError.ts +11 -31
  208. package/src/error/JoseHeaderErrorCodes.ts +7 -0
  209. package/src/index.ts +13 -1
  210. package/src/network/INetworkModule.ts +10 -7
  211. package/src/network/NetworkManager.ts +5 -5
  212. package/src/packageMetadata.ts +1 -1
  213. package/src/request/AuthenticationHeaderParser.ts +11 -8
  214. package/src/request/CommonRefreshTokenRequest.ts +3 -0
  215. package/src/request/CommonSilentFlowRequest.ts +2 -0
  216. package/src/request/RequestParameterBuilder.ts +10 -3
  217. package/src/request/RequestValidator.ts +19 -6
  218. package/src/request/ScopeSet.ts +23 -7
  219. package/src/response/ResponseHandler.ts +37 -17
  220. package/src/telemetry/performance/PerformanceClient.ts +2 -1
  221. package/src/telemetry/performance/PerformanceEvent.ts +9 -0
  222. package/src/telemetry/server/ServerTelemetryManager.ts +1 -1
  223. package/src/url/UrlString.ts +26 -16
  224. package/src/utils/Constants.ts +11 -3
  225. package/src/utils/FunctionWrappers.ts +0 -1
  226. 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
@@ -54,6 +54,7 @@ export { INativeBrokerPlugin } from "./broker/nativeBroker/INativeBrokerPlugin";
54
54
  export { CacheManager, DefaultStorageClass } from "./cache/CacheManager";
55
55
  export {
56
56
  AccountCache,
57
+ AccountFilter,
57
58
  AccessTokenCache,
58
59
  IdTokenCache,
59
60
  RefreshTokenCache,
@@ -137,17 +138,28 @@ export { ILoggerCallback, LogLevel, Logger } from "./logger/Logger";
137
138
  // Errors
138
139
  export {
139
140
  InteractionRequiredAuthError,
141
+ InteractionRequiredAuthErrorCodes,
140
142
  InteractionRequiredAuthErrorMessage,
143
+ createInteractionRequiredAuthError,
141
144
  } from "./error/InteractionRequiredAuthError";
142
- export { AuthError, AuthErrorMessage } from "./error/AuthError";
145
+ export {
146
+ AuthError,
147
+ AuthErrorMessage,
148
+ AuthErrorCodes,
149
+ createAuthError,
150
+ } from "./error/AuthError";
143
151
  export { ServerError } from "./error/ServerError";
144
152
  export {
145
153
  ClientAuthError,
146
154
  ClientAuthErrorMessage,
155
+ ClientAuthErrorCodes,
156
+ createClientAuthError,
147
157
  } from "./error/ClientAuthError";
148
158
  export {
149
159
  ClientConfigurationError,
150
160
  ClientConfigurationErrorMessage,
161
+ ClientConfigurationErrorCodes,
162
+ createClientConfigurationError,
151
163
  } from "./error/ClientConfigurationError";
152
164
  // Constants and Utils
153
165
  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
 
@@ -1,3 +1,3 @@
1
1
  /* eslint-disable header/header */
2
2
  export const name = "@azure/msal-common";
3
- export const version = "14.0.3";
3
+ export const version = "14.1.0";
@@ -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
  /**
@@ -5,6 +5,7 @@
5
5
 
6
6
  import { BaseAuthRequest } from "./BaseAuthRequest";
7
7
  import { CcsCredential } from "../account/CcsCredential";
8
+ import { StringDict } from "../utils/MsalTypes";
8
9
 
9
10
  /**
10
11
  * CommonRefreshTokenRequest
@@ -22,4 +23,6 @@ export type CommonRefreshTokenRequest = BaseAuthRequest & {
22
23
  refreshToken: string;
23
24
  ccsCredential?: CcsCredential;
24
25
  forceCache?: boolean;
26
+ tokenBodyParameters?: StringDict;
27
+ redirectUri?: string;
25
28
  };
@@ -4,6 +4,7 @@
4
4
  */
5
5
 
6
6
  import { AccountInfo } from "../account/AccountInfo";
7
+ import { StringDict } from "../utils/MsalTypes";
7
8
  import { BaseAuthRequest } from "./BaseAuthRequest";
8
9
 
9
10
  /**
@@ -21,4 +22,5 @@ import { BaseAuthRequest } from "./BaseAuthRequest";
21
22
  export type CommonSilentFlowRequest = BaseAuthRequest & {
22
23
  account: AccountInfo;
23
24
  forceRefresh: boolean;
25
+ tokenBodyParameters?: StringDict;
24
26
  };
@@ -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