@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
@@ -0,0 +1,51 @@
1
+ /*
2
+ * Copyright (c) Microsoft Corporation. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+
6
+ export const clientInfoDecodingError = "client_info_decoding_error";
7
+ export const clientInfoEmptyError = "client_info_empty_error";
8
+ export const tokenParsingError = "token_parsing_error";
9
+ export const nullOrEmptyToken = "null_or_empty_token";
10
+ export const endpointResolutionError = "endpoints_resolution_error";
11
+ export const networkError = "network_error";
12
+ export const openIdConfigError = "openid_config_error";
13
+ export const hashNotDeserialized = "hash_not_deserialized";
14
+ export const invalidState = "invalid_state";
15
+ export const stateMismatch = "state_mismatch";
16
+ export const stateNotFound = "state_not_found";
17
+ export const nonceMismatch = "nonce_mismatch";
18
+ export const authTimeNotFound = "auth_time_not_found";
19
+ export const maxAgeTranspired = "max_age_transpired";
20
+ export const multipleMatchingTokens = "multiple_matching_tokens";
21
+ export const multipleMatchingAccounts = "multiple_matching_accounts";
22
+ export const multipleMatchingAppMetadata = "multiple_matching_appMetadata";
23
+ export const requestCannotBeMade = "request_cannot_be_made";
24
+ export const cannotRemoveEmptyScope = "cannot_remove_empty_scope";
25
+ export const cannotAppendScopeSet = "cannot_append_scopeset";
26
+ export const emptyInputScopeSet = "empty_input_scopeset";
27
+ export const deviceCodePollingCancelled = "device_code_polling_cancelled";
28
+ export const deviceCodeExpired = "device_code_expired";
29
+ export const deviceCodeUnknownError = "device_code_unknown_error";
30
+ export const noAccountInSilentRequest = "no_account_in_silent_request";
31
+ export const invalidCacheRecord = "invalid_cache_record";
32
+ export const invalidCacheEnvironment = "invalid_cache_environment";
33
+ export const noAccountFound = "no_account_found";
34
+ export const noCryptoObject = "no_crypto_object";
35
+ export const unexpectedCredentialType = "unexpected_credential_type";
36
+ export const invalidAssertion = "invalid_assertion";
37
+ export const invalidClientCredential = "invalid_client_credential";
38
+ export const tokenRefreshRequired = "token_refresh_required";
39
+ export const userTimeoutReached = "user_timeout_reached";
40
+ export const tokenClaimsCnfRequiredForSignedJwt =
41
+ "token_claims_cnf_required_for_signedjwt";
42
+ export const authorizationCodeMissingFromServerResponse =
43
+ "authorization_code_missing_from_server_response";
44
+ export const bindingKeyNotRemoved = "binding_key_not_removed";
45
+ export const endSessionEndpointNotSupported =
46
+ "end_session_endpoint_not_supported";
47
+ export const keyIdMissing = "key_id_missing";
48
+ export const noNetworkConnectivity = "no_network_connectivity";
49
+ export const userCanceled = "user_canceled";
50
+ export const missingTenantIdError = "missing_tenant_id_error";
51
+ export const methodNotImplemented = "method_not_implemented";
@@ -3,394 +3,208 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
 
6
- import { ClientAuthError } from "./ClientAuthError";
6
+ import { AuthError } from "./AuthError";
7
+ import * as ClientConfigurationErrorCodes from "./ClientConfigurationErrorCodes";
8
+ export { ClientConfigurationErrorCodes };
9
+
10
+ export const ClientConfigurationErrorMessages = {
11
+ [ClientConfigurationErrorCodes.redirectUriEmpty]:
12
+ "A redirect URI is required for all calls, and none has been set.",
13
+ [ClientConfigurationErrorCodes.claimsRequestParsingError]:
14
+ "Could not parse the given claims request object.",
15
+ [ClientConfigurationErrorCodes.authorityUriInsecure]:
16
+ "Authority URIs must use https. Please see here for valid authority configuration options: https://docs.microsoft.com/en-us/azure/active-directory/develop/msal-js-initializing-client-applications#configuration-options",
17
+ [ClientConfigurationErrorCodes.urlParseError]:
18
+ "URL could not be parsed into appropriate segments.",
19
+ [ClientConfigurationErrorCodes.urlEmptyError]: "URL was empty or null.",
20
+ [ClientConfigurationErrorCodes.emptyInputScopesError]:
21
+ "Scopes cannot be passed as null, undefined or empty array because they are required to obtain an access token.",
22
+ [ClientConfigurationErrorCodes.invalidPromptValue]:
23
+ "Please see here for valid configuration options: https://azuread.github.io/microsoft-authentication-library-for-js/ref/modules/_azure_msal_common.html#commonauthorizationurlrequest",
24
+ [ClientConfigurationErrorCodes.invalidClaims]:
25
+ "Given claims parameter must be a stringified JSON object.",
26
+ [ClientConfigurationErrorCodes.tokenRequestEmpty]:
27
+ "Token request was empty and not found in cache.",
28
+ [ClientConfigurationErrorCodes.logoutRequestEmpty]:
29
+ "The logout request was null or undefined.",
30
+ [ClientConfigurationErrorCodes.invalidCodeChallengeMethod]:
31
+ 'code_challenge_method passed is invalid. Valid values are "plain" and "S256".',
32
+ [ClientConfigurationErrorCodes.pkceParamsMissing]:
33
+ "Both params: code_challenge and code_challenge_method are to be passed if to be sent in the request",
34
+ [ClientConfigurationErrorCodes.invalidCloudDiscoveryMetadata]:
35
+ "Invalid cloudDiscoveryMetadata provided. Must be a stringified JSON object containing tenant_discovery_endpoint and metadata fields",
36
+ [ClientConfigurationErrorCodes.invalidAuthorityMetadata]:
37
+ "Invalid authorityMetadata provided. Must by a stringified JSON object containing authorization_endpoint, token_endpoint, issuer fields.",
38
+ [ClientConfigurationErrorCodes.untrustedAuthority]:
39
+ "The provided authority is not a trusted authority. Please include this authority in the knownAuthorities config parameter.",
40
+ [ClientConfigurationErrorCodes.missingSshJwk]:
41
+ "Missing sshJwk in SSH certificate request. A stringified JSON Web Key is required when using the SSH authentication scheme.",
42
+ [ClientConfigurationErrorCodes.missingSshKid]:
43
+ "Missing sshKid in SSH certificate request. A string that uniquely identifies the public SSH key is required when using the SSH authentication scheme.",
44
+ [ClientConfigurationErrorCodes.missingNonceAuthenticationHeader]:
45
+ "Unable to find an authentication header containing server nonce. Either the Authentication-Info or WWW-Authenticate headers must be present in order to obtain a server nonce.",
46
+ [ClientConfigurationErrorCodes.invalidAuthenticationHeader]:
47
+ "Invalid authentication header provided",
48
+ [ClientConfigurationErrorCodes.cannotSetOIDCOptions]:
49
+ "Cannot set OIDCOptions parameter. Please change the protocol mode to OIDC or use a non-Microsoft authority.",
50
+ [ClientConfigurationErrorCodes.cannotAllowNativeBroker]:
51
+ "Cannot set allowNativeBroker parameter to true when not in AAD protocol mode.",
52
+ [ClientConfigurationErrorCodes.authorityMismatch]:
53
+ "Authority mismatch error. Authority provided in login request or PublicClientApplication config does not match the environment of the provided account. Please use a matching account or make an interactive request to login to this authority.",
54
+ };
7
55
 
8
56
  /**
9
57
  * ClientConfigurationErrorMessage class containing string constants used by error codes and messages.
58
+ * @deprecated Use ClientConfigurationErrorCodes instead
10
59
  */
11
60
  export const ClientConfigurationErrorMessage = {
12
61
  redirectUriNotSet: {
13
- code: "redirect_uri_empty",
14
- desc: "A redirect URI is required for all calls, and none has been set.",
15
- },
16
- postLogoutUriNotSet: {
17
- code: "post_logout_uri_empty",
18
- desc: "A post logout redirect has not been set.",
62
+ code: ClientConfigurationErrorCodes.redirectUriEmpty,
63
+ desc: ClientConfigurationErrorMessages[
64
+ ClientConfigurationErrorCodes.redirectUriEmpty
65
+ ],
19
66
  },
20
67
  claimsRequestParsingError: {
21
- code: "claims_request_parsing_error",
22
- desc: "Could not parse the given claims request object.",
68
+ code: ClientConfigurationErrorCodes.claimsRequestParsingError,
69
+ desc: ClientConfigurationErrorMessages[
70
+ ClientConfigurationErrorCodes.claimsRequestParsingError
71
+ ],
23
72
  },
24
73
  authorityUriInsecure: {
25
- code: "authority_uri_insecure",
26
- desc: "Authority URIs must use https. Please see here for valid authority configuration options: https://docs.microsoft.com/en-us/azure/active-directory/develop/msal-js-initializing-client-applications#configuration-options",
74
+ code: ClientConfigurationErrorCodes.authorityUriInsecure,
75
+ desc: ClientConfigurationErrorMessages[
76
+ ClientConfigurationErrorCodes.authorityUriInsecure
77
+ ],
27
78
  },
28
79
  urlParseError: {
29
- code: "url_parse_error",
30
- desc: "URL could not be parsed into appropriate segments.",
80
+ code: ClientConfigurationErrorCodes.urlParseError,
81
+ desc: ClientConfigurationErrorMessages[
82
+ ClientConfigurationErrorCodes.urlParseError
83
+ ],
31
84
  },
32
85
  urlEmptyError: {
33
- code: "empty_url_error",
34
- desc: "URL was empty or null.",
86
+ code: ClientConfigurationErrorCodes.urlEmptyError,
87
+ desc: ClientConfigurationErrorMessages[
88
+ ClientConfigurationErrorCodes.urlEmptyError
89
+ ],
35
90
  },
36
91
  emptyScopesError: {
37
- code: "empty_input_scopes_error",
38
- desc: "Scopes cannot be passed as null, undefined or empty array because they are required to obtain an access token.",
39
- },
40
- nonArrayScopesError: {
41
- code: "nonarray_input_scopes_error",
42
- desc: "Scopes cannot be passed as non-array.",
43
- },
44
- clientIdSingleScopeError: {
45
- code: "clientid_input_scopes_error",
46
- desc: "Client ID can only be provided as a single scope.",
92
+ code: ClientConfigurationErrorCodes.emptyInputScopesError,
93
+ desc: ClientConfigurationErrorMessages[
94
+ ClientConfigurationErrorCodes.emptyInputScopesError
95
+ ],
47
96
  },
48
97
  invalidPrompt: {
49
- code: "invalid_prompt_value",
50
- desc: "Supported prompt values are 'login', 'select_account', 'consent', 'create', 'none' and 'no_session'. Please see here for valid configuration options: https://azuread.github.io/microsoft-authentication-library-for-js/ref/modules/_azure_msal_common.html#commonauthorizationurlrequest",
98
+ code: ClientConfigurationErrorCodes.invalidPromptValue,
99
+ desc: ClientConfigurationErrorMessages[
100
+ ClientConfigurationErrorCodes.invalidPromptValue
101
+ ],
51
102
  },
52
103
  invalidClaimsRequest: {
53
- code: "invalid_claims",
54
- desc: "Given claims parameter must be a stringified JSON object.",
104
+ code: ClientConfigurationErrorCodes.invalidClaims,
105
+ desc: ClientConfigurationErrorMessages[
106
+ ClientConfigurationErrorCodes.invalidClaims
107
+ ],
55
108
  },
56
109
  tokenRequestEmptyError: {
57
- code: "token_request_empty",
58
- desc: "Token request was empty and not found in cache.",
110
+ code: ClientConfigurationErrorCodes.tokenRequestEmpty,
111
+ desc: ClientConfigurationErrorMessages[
112
+ ClientConfigurationErrorCodes.tokenRequestEmpty
113
+ ],
59
114
  },
60
115
  logoutRequestEmptyError: {
61
- code: "logout_request_empty",
62
- desc: "The logout request was null or undefined.",
116
+ code: ClientConfigurationErrorCodes.logoutRequestEmpty,
117
+ desc: ClientConfigurationErrorMessages[
118
+ ClientConfigurationErrorCodes.logoutRequestEmpty
119
+ ],
63
120
  },
64
121
  invalidCodeChallengeMethod: {
65
- code: "invalid_code_challenge_method",
66
- desc: 'code_challenge_method passed is invalid. Valid values are "plain" and "S256".',
122
+ code: ClientConfigurationErrorCodes.invalidCodeChallengeMethod,
123
+ desc: ClientConfigurationErrorMessages[
124
+ ClientConfigurationErrorCodes.invalidCodeChallengeMethod
125
+ ],
67
126
  },
68
127
  invalidCodeChallengeParams: {
69
- code: "pkce_params_missing",
70
- desc: "Both params: code_challenge and code_challenge_method are to be passed if to be sent in the request",
128
+ code: ClientConfigurationErrorCodes.pkceParamsMissing,
129
+ desc: ClientConfigurationErrorMessages[
130
+ ClientConfigurationErrorCodes.pkceParamsMissing
131
+ ],
71
132
  },
72
133
  invalidCloudDiscoveryMetadata: {
73
- code: "invalid_cloud_discovery_metadata",
74
- desc: "Invalid cloudDiscoveryMetadata provided. Must be a stringified JSON object containing tenant_discovery_endpoint and metadata fields",
134
+ code: ClientConfigurationErrorCodes.invalidCloudDiscoveryMetadata,
135
+ desc: ClientConfigurationErrorMessages[
136
+ ClientConfigurationErrorCodes.invalidCloudDiscoveryMetadata
137
+ ],
75
138
  },
76
139
  invalidAuthorityMetadata: {
77
- code: "invalid_authority_metadata",
78
- desc: "Invalid authorityMetadata provided. Must by a stringified JSON object containing authorization_endpoint, token_endpoint, issuer fields.",
140
+ code: ClientConfigurationErrorCodes.invalidAuthorityMetadata,
141
+ desc: ClientConfigurationErrorMessages[
142
+ ClientConfigurationErrorCodes.invalidAuthorityMetadata
143
+ ],
79
144
  },
80
145
  untrustedAuthority: {
81
- code: "untrusted_authority",
82
- desc: "The provided authority is not a trusted authority. Please include this authority in the knownAuthorities config parameter.",
83
- },
84
- invalidAzureCloudInstance: {
85
- code: "invalid_azure_cloud_instance",
86
- desc: "Invalid AzureCloudInstance provided. Please refer MSAL JS docs: aks.ms/msaljs/azure_cloud_instance for valid values",
146
+ code: ClientConfigurationErrorCodes.untrustedAuthority,
147
+ desc: ClientConfigurationErrorMessages[
148
+ ClientConfigurationErrorCodes.untrustedAuthority
149
+ ],
87
150
  },
88
151
  missingSshJwk: {
89
- code: "missing_ssh_jwk",
90
- desc: "Missing sshJwk in SSH certificate request. A stringified JSON Web Key is required when using the SSH authentication scheme.",
152
+ code: ClientConfigurationErrorCodes.missingSshJwk,
153
+ desc: ClientConfigurationErrorMessages[
154
+ ClientConfigurationErrorCodes.missingSshJwk
155
+ ],
91
156
  },
92
157
  missingSshKid: {
93
- code: "missing_ssh_kid",
94
- desc: "Missing sshKid in SSH certificate request. A string that uniquely identifies the public SSH key is required when using the SSH authentication scheme.",
158
+ code: ClientConfigurationErrorCodes.missingSshKid,
159
+ desc: ClientConfigurationErrorMessages[
160
+ ClientConfigurationErrorCodes.missingSshKid
161
+ ],
95
162
  },
96
163
  missingNonceAuthenticationHeader: {
97
- code: "missing_nonce_authentication_header",
98
- desc: "Unable to find an authentication header containing server nonce. Either the Authentication-Info or WWW-Authenticate headers must be present in order to obtain a server nonce.",
164
+ code: ClientConfigurationErrorCodes.missingNonceAuthenticationHeader,
165
+ desc: ClientConfigurationErrorMessages[
166
+ ClientConfigurationErrorCodes.missingNonceAuthenticationHeader
167
+ ],
99
168
  },
100
169
  invalidAuthenticationHeader: {
101
- code: "invalid_authentication_header",
102
- desc: "Invalid authentication header provided",
170
+ code: ClientConfigurationErrorCodes.invalidAuthenticationHeader,
171
+ desc: ClientConfigurationErrorMessages[
172
+ ClientConfigurationErrorCodes.invalidAuthenticationHeader
173
+ ],
103
174
  },
104
175
  cannotSetOIDCOptions: {
105
- code: "cannot_set_OIDCOptions",
106
- desc: "Cannot set OIDCOptions parameter. Please change the protocol mode to OIDC or use a non-Microsoft authority.",
176
+ code: ClientConfigurationErrorCodes.cannotSetOIDCOptions,
177
+ desc: ClientConfigurationErrorMessages[
178
+ ClientConfigurationErrorCodes.cannotSetOIDCOptions
179
+ ],
107
180
  },
108
181
  cannotAllowNativeBroker: {
109
- code: "cannot_allow_native_broker",
110
- desc: "Cannot set allowNativeBroker parameter to true when not in AAD protocol mode.",
182
+ code: ClientConfigurationErrorCodes.cannotAllowNativeBroker,
183
+ desc: ClientConfigurationErrorMessages[
184
+ ClientConfigurationErrorCodes.cannotAllowNativeBroker
185
+ ],
111
186
  },
112
187
  authorityMismatch: {
113
- code: "authority_mismatch",
114
- desc: "Authority mismatch error. Authority provided in login request or PublicClientApplication config does not match the environment of the provided account. Please use a matching account or make an interactive request to login to this authority.",
188
+ code: ClientConfigurationErrorCodes.authorityMismatch,
189
+ desc: ClientConfigurationErrorMessages[
190
+ ClientConfigurationErrorCodes.authorityMismatch
191
+ ],
115
192
  },
116
193
  };
117
194
 
118
195
  /**
119
196
  * Error thrown when there is an error in configuration of the MSAL.js library.
120
197
  */
121
- export class ClientConfigurationError extends ClientAuthError {
122
- constructor(errorCode: string, errorMessage?: string) {
123
- super(errorCode, errorMessage);
198
+ export class ClientConfigurationError extends AuthError {
199
+ constructor(errorCode: string) {
200
+ super(errorCode, ClientConfigurationErrorMessages[errorCode]);
124
201
  this.name = "ClientConfigurationError";
125
202
  Object.setPrototypeOf(this, ClientConfigurationError.prototype);
126
203
  }
204
+ }
127
205
 
128
- /**
129
- * Creates an error thrown when the redirect uri is empty (not set by caller)
130
- */
131
- static createRedirectUriEmptyError(): ClientConfigurationError {
132
- return new ClientConfigurationError(
133
- ClientConfigurationErrorMessage.redirectUriNotSet.code,
134
- ClientConfigurationErrorMessage.redirectUriNotSet.desc
135
- );
136
- }
137
-
138
- /**
139
- * Creates an error thrown when the post-logout redirect uri is empty (not set by caller)
140
- */
141
- static createPostLogoutRedirectUriEmptyError(): ClientConfigurationError {
142
- return new ClientConfigurationError(
143
- ClientConfigurationErrorMessage.postLogoutUriNotSet.code,
144
- ClientConfigurationErrorMessage.postLogoutUriNotSet.desc
145
- );
146
- }
147
-
148
- /**
149
- * Creates an error thrown when the claims request could not be successfully parsed
150
- */
151
- static createClaimsRequestParsingError(
152
- claimsRequestParseError: string
153
- ): ClientConfigurationError {
154
- return new ClientConfigurationError(
155
- ClientConfigurationErrorMessage.claimsRequestParsingError.code,
156
- `${ClientConfigurationErrorMessage.claimsRequestParsingError.desc} Given value: ${claimsRequestParseError}`
157
- );
158
- }
159
-
160
- /**
161
- * Creates an error thrown if authority uri is given an insecure protocol.
162
- * @param urlString
163
- */
164
- static createInsecureAuthorityUriError(
165
- urlString: string
166
- ): ClientConfigurationError {
167
- return new ClientConfigurationError(
168
- ClientConfigurationErrorMessage.authorityUriInsecure.code,
169
- `${ClientConfigurationErrorMessage.authorityUriInsecure.desc} Given URI: ${urlString}`
170
- );
171
- }
172
-
173
- /**
174
- * Creates an error thrown if URL string does not parse into separate segments.
175
- * @param urlString
176
- */
177
- static createUrlParseError(
178
- urlParseError: string
179
- ): ClientConfigurationError {
180
- return new ClientConfigurationError(
181
- ClientConfigurationErrorMessage.urlParseError.code,
182
- `${ClientConfigurationErrorMessage.urlParseError.desc} Given Error: ${urlParseError}`
183
- );
184
- }
185
-
186
- /**
187
- * Creates an error thrown if URL string is empty or null.
188
- * @param urlString
189
- */
190
- static createUrlEmptyError(): ClientConfigurationError {
191
- return new ClientConfigurationError(
192
- ClientConfigurationErrorMessage.urlEmptyError.code,
193
- ClientConfigurationErrorMessage.urlEmptyError.desc
194
- );
195
- }
196
-
197
- /**
198
- * Error thrown when scopes are empty.
199
- * @param scopesValue
200
- */
201
- static createEmptyScopesArrayError(): ClientConfigurationError {
202
- return new ClientConfigurationError(
203
- ClientConfigurationErrorMessage.emptyScopesError.code,
204
- `${ClientConfigurationErrorMessage.emptyScopesError.desc}`
205
- );
206
- }
207
-
208
- /**
209
- * Error thrown when client id scope is not provided as single scope.
210
- * @param inputScopes
211
- */
212
- static createClientIdSingleScopeError(
213
- inputScopes: Array<string>
214
- ): ClientConfigurationError {
215
- return new ClientConfigurationError(
216
- ClientConfigurationErrorMessage.clientIdSingleScopeError.code,
217
- `${ClientConfigurationErrorMessage.clientIdSingleScopeError.desc} Given Scopes: ${inputScopes}`
218
- );
219
- }
220
-
221
- /**
222
- * Error thrown when prompt is not an allowed type.
223
- * @param promptValue
224
- */
225
- static createInvalidPromptError(
226
- promptValue: string
227
- ): ClientConfigurationError {
228
- return new ClientConfigurationError(
229
- ClientConfigurationErrorMessage.invalidPrompt.code,
230
- `${ClientConfigurationErrorMessage.invalidPrompt.desc} Given value: ${promptValue}`
231
- );
232
- }
233
-
234
- /**
235
- * Creates error thrown when claims parameter is not a stringified JSON object
236
- */
237
- static createInvalidClaimsRequestError(): ClientConfigurationError {
238
- return new ClientConfigurationError(
239
- ClientConfigurationErrorMessage.invalidClaimsRequest.code,
240
- ClientConfigurationErrorMessage.invalidClaimsRequest.desc
241
- );
242
- }
243
-
244
- /**
245
- * Throws error when token request is empty and nothing cached in storage.
246
- */
247
- static createEmptyLogoutRequestError(): ClientConfigurationError {
248
- return new ClientConfigurationError(
249
- ClientConfigurationErrorMessage.logoutRequestEmptyError.code,
250
- ClientConfigurationErrorMessage.logoutRequestEmptyError.desc
251
- );
252
- }
253
-
254
- /**
255
- * Throws error when token request is empty and nothing cached in storage.
256
- */
257
- static createEmptyTokenRequestError(): ClientConfigurationError {
258
- return new ClientConfigurationError(
259
- ClientConfigurationErrorMessage.tokenRequestEmptyError.code,
260
- ClientConfigurationErrorMessage.tokenRequestEmptyError.desc
261
- );
262
- }
263
-
264
- /**
265
- * Throws error when an invalid code_challenge_method is passed by the user
266
- */
267
- static createInvalidCodeChallengeMethodError(): ClientConfigurationError {
268
- return new ClientConfigurationError(
269
- ClientConfigurationErrorMessage.invalidCodeChallengeMethod.code,
270
- ClientConfigurationErrorMessage.invalidCodeChallengeMethod.desc
271
- );
272
- }
273
-
274
- /**
275
- * Throws error when both params: code_challenge and code_challenge_method are not passed together
276
- */
277
- static createInvalidCodeChallengeParamsError(): ClientConfigurationError {
278
- return new ClientConfigurationError(
279
- ClientConfigurationErrorMessage.invalidCodeChallengeParams.code,
280
- ClientConfigurationErrorMessage.invalidCodeChallengeParams.desc
281
- );
282
- }
283
-
284
- /**
285
- * Throws an error when the user passes invalid cloudDiscoveryMetadata
286
- */
287
- static createInvalidCloudDiscoveryMetadataError(): ClientConfigurationError {
288
- return new ClientConfigurationError(
289
- ClientConfigurationErrorMessage.invalidCloudDiscoveryMetadata.code,
290
- ClientConfigurationErrorMessage.invalidCloudDiscoveryMetadata.desc
291
- );
292
- }
293
-
294
- /**
295
- * Throws an error when the user passes invalid cloudDiscoveryMetadata
296
- */
297
- static createInvalidAuthorityMetadataError(): ClientConfigurationError {
298
- return new ClientConfigurationError(
299
- ClientConfigurationErrorMessage.invalidAuthorityMetadata.code,
300
- ClientConfigurationErrorMessage.invalidAuthorityMetadata.desc
301
- );
302
- }
303
-
304
- /**
305
- * Throws error when provided authority is not a member of the trusted host list
306
- */
307
- static createUntrustedAuthorityError(): ClientConfigurationError {
308
- return new ClientConfigurationError(
309
- ClientConfigurationErrorMessage.untrustedAuthority.code,
310
- ClientConfigurationErrorMessage.untrustedAuthority.desc
311
- );
312
- }
313
-
314
- /**
315
- * Throws error when the AzureCloudInstance is set to an invalid value
316
- */
317
- static createInvalidAzureCloudInstanceError(): ClientConfigurationError {
318
- return new ClientConfigurationError(
319
- ClientConfigurationErrorMessage.invalidAzureCloudInstance.code,
320
- ClientConfigurationErrorMessage.invalidAzureCloudInstance.desc
321
- );
322
- }
323
-
324
- /**
325
- * Throws an error when the authentication scheme is set to SSH but the SSH public key is omitted from the request
326
- */
327
- static createMissingSshJwkError(): ClientConfigurationError {
328
- return new ClientConfigurationError(
329
- ClientConfigurationErrorMessage.missingSshJwk.code,
330
- ClientConfigurationErrorMessage.missingSshJwk.desc
331
- );
332
- }
333
-
334
- /**
335
- * Throws an error when the authentication scheme is set to SSH but the SSH public key ID is omitted from the request
336
- */
337
- static createMissingSshKidError(): ClientConfigurationError {
338
- return new ClientConfigurationError(
339
- ClientConfigurationErrorMessage.missingSshKid.code,
340
- ClientConfigurationErrorMessage.missingSshKid.desc
341
- );
342
- }
343
-
344
- /**
345
- * Throws error when provided headers don't contain a header that a server nonce can be extracted from
346
- */
347
- static createMissingNonceAuthenticationHeadersError(): ClientConfigurationError {
348
- return new ClientConfigurationError(
349
- ClientConfigurationErrorMessage.missingNonceAuthenticationHeader.code,
350
- ClientConfigurationErrorMessage.missingNonceAuthenticationHeader.desc
351
- );
352
- }
353
-
354
- /**
355
- * Throws error when a provided header is invalid in any way
356
- */
357
- static createInvalidAuthenticationHeaderError(
358
- invalidHeaderName: string,
359
- details: string
360
- ): ClientConfigurationError {
361
- return new ClientConfigurationError(
362
- ClientConfigurationErrorMessage.invalidAuthenticationHeader.code,
363
- `${ClientConfigurationErrorMessage.invalidAuthenticationHeader.desc}. Invalid header: ${invalidHeaderName}. Details: ${details}`
364
- );
365
- }
366
-
367
- /**
368
- * Throws error when provided non-default OIDCOptions when not in OIDC protocol mode
369
- */
370
- static createCannotSetOIDCOptionsError(): ClientConfigurationError {
371
- return new ClientConfigurationError(
372
- ClientConfigurationErrorMessage.cannotSetOIDCOptions.code,
373
- ClientConfigurationErrorMessage.cannotSetOIDCOptions.desc
374
- );
375
- }
376
-
377
- /**
378
- * Throws error when allowNativeBroker is set to true when not in AAD protocol mode
379
- */
380
- static createCannotAllowNativeBrokerError(): ClientConfigurationError {
381
- return new ClientConfigurationError(
382
- ClientConfigurationErrorMessage.cannotAllowNativeBroker.code,
383
- ClientConfigurationErrorMessage.cannotAllowNativeBroker.desc
384
- );
385
- }
386
-
387
- /**
388
- * Create an error when the authority provided in request does not match authority provided in account or MSAL.js configuration.
389
- */
390
- static createAuthorityMismatchError(): ClientConfigurationError {
391
- return new ClientConfigurationError(
392
- ClientConfigurationErrorMessage.authorityMismatch.code,
393
- ClientConfigurationErrorMessage.authorityMismatch.desc
394
- );
395
- }
206
+ export function createClientConfigurationError(
207
+ errorCode: string
208
+ ): ClientConfigurationError {
209
+ return new ClientConfigurationError(errorCode);
396
210
  }
@@ -0,0 +1,28 @@
1
+ /*
2
+ * Copyright (c) Microsoft Corporation. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+
6
+ export const redirectUriEmpty = "redirect_uri_empty";
7
+ export const claimsRequestParsingError = "claims_request_parsing_error";
8
+ export const authorityUriInsecure = "authority_uri_insecure";
9
+ export const urlParseError = "url_parse_error";
10
+ export const urlEmptyError = "empty_url_error";
11
+ export const emptyInputScopesError = "empty_input_scopes_error";
12
+ export const invalidPromptValue = "invalid_prompt_value";
13
+ export const invalidClaims = "invalid_claims";
14
+ export const tokenRequestEmpty = "token_request_empty";
15
+ export const logoutRequestEmpty = "logout_request_empty";
16
+ export const invalidCodeChallengeMethod = "invalid_code_challenge_method";
17
+ export const pkceParamsMissing = "pkce_params_missing";
18
+ export const invalidCloudDiscoveryMetadata = "invalid_cloud_discovery_metadata";
19
+ export const invalidAuthorityMetadata = "invalid_authority_metadata";
20
+ export const untrustedAuthority = "untrusted_authority";
21
+ export const missingSshJwk = "missing_ssh_jwk";
22
+ export const missingSshKid = "missing_ssh_kid";
23
+ export const missingNonceAuthenticationHeader =
24
+ "missing_nonce_authentication_header";
25
+ export const invalidAuthenticationHeader = "invalid_authentication_header";
26
+ export const cannotSetOIDCOptions = "cannot_set_OIDCOptions";
27
+ export const cannotAllowNativeBroker = "cannot_allow_native_broker";
28
+ export const authorityMismatch = "authority_mismatch";