@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.
- package/dist/account/AccountInfo.d.ts +0 -1
- package/dist/account/AccountInfo.d.ts.map +1 -1
- package/dist/account/AuthToken.d.ts.map +1 -1
- package/dist/account/AuthToken.mjs +7 -6
- package/dist/account/AuthToken.mjs.map +1 -1
- package/dist/account/CcsCredential.mjs +1 -1
- package/dist/account/ClientInfo.d.ts.map +1 -1
- package/dist/account/ClientInfo.mjs +6 -5
- package/dist/account/ClientInfo.mjs.map +1 -1
- package/dist/authority/Authority.d.ts.map +1 -1
- package/dist/authority/Authority.mjs +28 -50
- package/dist/authority/Authority.mjs.map +1 -1
- package/dist/authority/AuthorityFactory.d.ts.map +1 -1
- package/dist/authority/AuthorityFactory.mjs +9 -7
- package/dist/authority/AuthorityFactory.mjs.map +1 -1
- package/dist/authority/AuthorityMetadata.mjs +1 -1
- package/dist/authority/AuthorityOptions.mjs +1 -1
- package/dist/authority/AuthorityType.mjs +1 -1
- package/dist/authority/CloudInstanceDiscoveryErrorResponse.mjs +1 -1
- package/dist/authority/CloudInstanceDiscoveryResponse.mjs +1 -1
- package/dist/authority/OpenIdConfigResponse.mjs +1 -1
- package/dist/authority/ProtocolMode.mjs +1 -1
- package/dist/authority/RegionDiscovery.d.ts +3 -1
- package/dist/authority/RegionDiscovery.d.ts.map +1 -1
- package/dist/authority/RegionDiscovery.mjs +7 -8
- package/dist/authority/RegionDiscovery.mjs.map +1 -1
- package/dist/cache/CacheManager.d.ts +25 -7
- package/dist/cache/CacheManager.d.ts.map +1 -1
- package/dist/cache/CacheManager.mjs +98 -71
- package/dist/cache/CacheManager.mjs.map +1 -1
- package/dist/cache/entities/AccessTokenEntity.d.ts.map +1 -1
- package/dist/cache/entities/AccessTokenEntity.mjs +4 -3
- package/dist/cache/entities/AccessTokenEntity.mjs.map +1 -1
- package/dist/cache/entities/AccountEntity.d.ts.map +1 -1
- package/dist/cache/entities/AccountEntity.mjs +4 -3
- package/dist/cache/entities/AccountEntity.mjs.map +1 -1
- package/dist/cache/entities/AppMetadataEntity.mjs +1 -1
- package/dist/cache/entities/AuthorityMetadataEntity.mjs +1 -1
- package/dist/cache/entities/CacheRecord.mjs +1 -1
- package/dist/cache/entities/CredentialEntity.d.ts.map +1 -1
- package/dist/cache/entities/CredentialEntity.mjs +4 -3
- package/dist/cache/entities/CredentialEntity.mjs.map +1 -1
- package/dist/cache/entities/IdTokenEntity.mjs +1 -1
- package/dist/cache/entities/RefreshTokenEntity.mjs +1 -1
- package/dist/cache/entities/ServerTelemetryEntity.mjs +1 -1
- package/dist/cache/entities/ThrottlingEntity.mjs +1 -1
- package/dist/cache/persistence/TokenCacheContext.mjs +1 -1
- package/dist/cache/utils/CacheTypes.d.ts +3 -6
- package/dist/cache/utils/CacheTypes.d.ts.map +1 -1
- package/dist/client/AuthorizationCodeClient.d.ts.map +1 -1
- package/dist/client/AuthorizationCodeClient.mjs +13 -11
- package/dist/client/AuthorizationCodeClient.mjs.map +1 -1
- package/dist/client/BaseClient.d.ts.map +1 -1
- package/dist/client/BaseClient.mjs +5 -4
- package/dist/client/BaseClient.mjs.map +1 -1
- package/dist/client/RefreshTokenClient.d.ts.map +1 -1
- package/dist/client/RefreshTokenClient.mjs +33 -74
- package/dist/client/RefreshTokenClient.mjs.map +1 -1
- package/dist/client/SilentFlowClient.d.ts +2 -1
- package/dist/client/SilentFlowClient.d.ts.map +1 -1
- package/dist/client/SilentFlowClient.mjs +43 -19
- package/dist/client/SilentFlowClient.mjs.map +1 -1
- package/dist/config/ClientConfiguration.d.ts.map +1 -1
- package/dist/config/ClientConfiguration.mjs +5 -6
- package/dist/config/ClientConfiguration.mjs.map +1 -1
- package/dist/crypto/ICrypto.d.ts +0 -4
- package/dist/crypto/ICrypto.d.ts.map +1 -1
- package/dist/crypto/ICrypto.mjs +11 -22
- package/dist/crypto/ICrypto.mjs.map +1 -1
- package/dist/crypto/JoseHeader.d.ts.map +1 -1
- package/dist/crypto/JoseHeader.mjs +5 -4
- package/dist/crypto/JoseHeader.mjs.map +1 -1
- package/dist/crypto/PopTokenGenerator.d.ts +2 -1
- package/dist/crypto/PopTokenGenerator.d.ts.map +1 -1
- package/dist/crypto/PopTokenGenerator.mjs +4 -4
- package/dist/crypto/PopTokenGenerator.mjs.map +1 -1
- package/dist/error/AuthError.d.ts +8 -11
- package/dist/error/AuthError.d.ts.map +1 -1
- package/dist/error/AuthError.mjs +19 -21
- package/dist/error/AuthError.mjs.map +1 -1
- package/dist/error/AuthErrorCodes.d.ts +6 -0
- package/dist/error/AuthErrorCodes.d.ts.map +1 -0
- package/dist/error/AuthErrorCodes.mjs +14 -0
- package/dist/error/AuthErrorCodes.mjs.map +1 -0
- package/dist/error/ClientAuthError.d.ts +54 -234
- package/dist/error/ClientAuthError.d.ts.map +1 -1
- package/dist/error/ClientAuthError.mjs +149 -421
- package/dist/error/ClientAuthError.mjs.map +1 -1
- package/dist/error/ClientAuthErrorCodes.d.ts +44 -0
- package/dist/error/ClientAuthErrorCodes.d.ts.map +1 -0
- package/dist/error/ClientAuthErrorCodes.mjs +52 -0
- package/dist/error/ClientAuthErrorCodes.mjs.map +1 -0
- package/dist/error/ClientConfigurationError.d.ts +31 -125
- package/dist/error/ClientConfigurationError.d.ts.map +1 -1
- package/dist/error/ClientConfigurationError.mjs +81 -222
- package/dist/error/ClientConfigurationError.mjs.map +1 -1
- package/dist/error/ClientConfigurationErrorCodes.d.ts +23 -0
- package/dist/error/ClientConfigurationErrorCodes.d.ts.map +1 -0
- package/dist/error/ClientConfigurationErrorCodes.mjs +31 -0
- package/dist/error/ClientConfigurationErrorCodes.mjs.map +1 -0
- package/dist/error/InteractionRequiredAuthError.d.ts +14 -16
- package/dist/error/InteractionRequiredAuthError.d.ts.map +1 -1
- package/dist/error/InteractionRequiredAuthError.mjs +42 -41
- package/dist/error/InteractionRequiredAuthError.mjs.map +1 -1
- package/dist/error/InteractionRequiredAuthErrorCodes.d.ts +6 -0
- package/dist/error/InteractionRequiredAuthErrorCodes.d.ts.map +1 -0
- package/dist/error/InteractionRequiredAuthErrorCodes.mjs +16 -0
- package/dist/error/InteractionRequiredAuthErrorCodes.mjs.map +1 -0
- package/dist/error/JoseHeaderError.d.ts +7 -20
- package/dist/error/JoseHeaderError.d.ts.map +1 -1
- package/dist/error/JoseHeaderError.mjs +10 -26
- package/dist/error/JoseHeaderError.mjs.map +1 -1
- package/dist/error/JoseHeaderErrorCodes.d.ts +3 -0
- package/dist/error/JoseHeaderErrorCodes.d.ts.map +1 -0
- package/dist/error/JoseHeaderErrorCodes.mjs +11 -0
- package/dist/error/JoseHeaderErrorCodes.mjs.map +1 -0
- package/dist/error/ServerError.mjs +1 -1
- package/dist/index.cjs +942 -1210
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +5 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.mjs +13 -5
- package/dist/index.mjs.map +1 -1
- package/dist/logger/Logger.mjs +1 -1
- package/dist/network/INetworkModule.d.ts.map +1 -1
- package/dist/network/INetworkModule.mjs +5 -6
- package/dist/network/INetworkModule.mjs.map +1 -1
- package/dist/network/NetworkManager.d.ts.map +1 -1
- package/dist/network/NetworkManager.mjs +4 -3
- package/dist/network/NetworkManager.mjs.map +1 -1
- package/dist/network/ThrottlingUtils.mjs +1 -1
- package/dist/packageMetadata.d.ts +1 -1
- package/dist/packageMetadata.mjs +2 -2
- package/dist/request/AuthenticationHeaderParser.d.ts.map +1 -1
- package/dist/request/AuthenticationHeaderParser.mjs +7 -6
- package/dist/request/AuthenticationHeaderParser.mjs.map +1 -1
- package/dist/request/CommonRefreshTokenRequest.d.ts +3 -0
- package/dist/request/CommonRefreshTokenRequest.d.ts.map +1 -1
- package/dist/request/CommonSilentFlowRequest.d.ts +2 -0
- package/dist/request/CommonSilentFlowRequest.d.ts.map +1 -1
- package/dist/request/RequestParameterBuilder.d.ts.map +1 -1
- package/dist/request/RequestParameterBuilder.mjs +5 -4
- package/dist/request/RequestParameterBuilder.mjs.map +1 -1
- package/dist/request/RequestValidator.d.ts.map +1 -1
- package/dist/request/RequestValidator.mjs +8 -7
- package/dist/request/RequestValidator.mjs.map +1 -1
- package/dist/request/ScopeSet.d.ts.map +1 -1
- package/dist/request/ScopeSet.mjs +10 -8
- package/dist/request/ScopeSet.mjs.map +1 -1
- package/dist/response/ResponseHandler.d.ts.map +1 -1
- package/dist/response/ResponseHandler.mjs +15 -14
- package/dist/response/ResponseHandler.mjs.map +1 -1
- package/dist/telemetry/performance/PerformanceClient.d.ts.map +1 -1
- package/dist/telemetry/performance/PerformanceClient.mjs +3 -2
- package/dist/telemetry/performance/PerformanceClient.mjs.map +1 -1
- package/dist/telemetry/performance/PerformanceEvent.d.ts +8 -0
- package/dist/telemetry/performance/PerformanceEvent.d.ts.map +1 -1
- package/dist/telemetry/performance/PerformanceEvent.mjs +9 -1
- package/dist/telemetry/performance/PerformanceEvent.mjs.map +1 -1
- package/dist/telemetry/performance/StubPerformanceClient.mjs +1 -1
- package/dist/telemetry/server/ServerTelemetryManager.d.ts.map +1 -1
- package/dist/telemetry/server/ServerTelemetryManager.mjs +2 -2
- package/dist/telemetry/server/ServerTelemetryManager.mjs.map +1 -1
- package/dist/url/UrlString.d.ts.map +1 -1
- package/dist/url/UrlString.mjs +13 -11
- package/dist/url/UrlString.mjs.map +1 -1
- package/dist/utils/Constants.d.ts +6 -3
- package/dist/utils/Constants.d.ts.map +1 -1
- package/dist/utils/Constants.mjs +12 -4
- package/dist/utils/Constants.mjs.map +1 -1
- package/dist/utils/FunctionWrappers.d.ts.map +1 -1
- package/dist/utils/FunctionWrappers.mjs +1 -2
- package/dist/utils/FunctionWrappers.mjs.map +1 -1
- package/dist/utils/ProtocolUtils.d.ts.map +1 -1
- package/dist/utils/ProtocolUtils.mjs +7 -6
- package/dist/utils/ProtocolUtils.mjs.map +1 -1
- package/dist/utils/StringUtils.mjs +1 -1
- package/dist/utils/TimeUtils.mjs +1 -1
- package/package.json +1 -1
- package/src/account/AccountInfo.ts +0 -1
- package/src/account/AuthToken.ts +8 -7
- package/src/account/ClientInfo.ts +9 -6
- package/src/authority/Authority.ts +76 -94
- package/src/authority/AuthorityFactory.ts +21 -9
- package/src/authority/RegionDiscovery.ts +21 -18
- package/src/cache/CacheManager.ts +133 -95
- package/src/cache/entities/AccessTokenEntity.ts +7 -2
- package/src/cache/entities/AccountEntity.ts +7 -2
- package/src/cache/entities/CredentialEntity.ts +7 -2
- package/src/cache/utils/CacheTypes.ts +6 -6
- package/src/client/AuthorizationCodeClient.ts +35 -11
- package/src/client/BaseClient.ts +7 -4
- package/src/client/RefreshTokenClient.ts +100 -126
- package/src/client/SilentFlowClient.ts +72 -19
- package/src/config/ClientConfiguration.ts +6 -7
- package/src/crypto/ICrypto.ts +12 -34
- package/src/crypto/JoseHeader.ts +6 -3
- package/src/crypto/PopTokenGenerator.ts +10 -5
- package/src/error/AuthError.ts +24 -26
- package/src/error/AuthErrorCodes.ts +10 -0
- package/src/error/ClientAuthError.ts +227 -632
- package/src/error/ClientAuthErrorCodes.ts +51 -0
- package/src/error/ClientConfigurationError.ts +146 -332
- package/src/error/ClientConfigurationErrorCodes.ts +28 -0
- package/src/error/InteractionRequiredAuthError.ts +60 -55
- package/src/error/InteractionRequiredAuthErrorCodes.ts +13 -0
- package/src/error/JoseHeaderError.ts +11 -31
- package/src/error/JoseHeaderErrorCodes.ts +7 -0
- package/src/index.ts +13 -1
- package/src/network/INetworkModule.ts +10 -7
- package/src/network/NetworkManager.ts +5 -5
- package/src/packageMetadata.ts +1 -1
- package/src/request/AuthenticationHeaderParser.ts +11 -8
- package/src/request/CommonRefreshTokenRequest.ts +3 -0
- package/src/request/CommonSilentFlowRequest.ts +2 -0
- package/src/request/RequestParameterBuilder.ts +10 -3
- package/src/request/RequestValidator.ts +19 -6
- package/src/request/ScopeSet.ts +23 -7
- package/src/response/ResponseHandler.ts +37 -17
- package/src/telemetry/performance/PerformanceClient.ts +2 -1
- package/src/telemetry/performance/PerformanceEvent.ts +9 -0
- package/src/telemetry/server/ServerTelemetryManager.ts +1 -1
- package/src/url/UrlString.ts +26 -16
- package/src/utils/Constants.ts +11 -3
- package/src/utils/FunctionWrappers.ts +0 -1
- 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
|
-
|
|
14
|
-
|
|
15
|
-
|
|
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:
|
|
32
|
-
desc:
|
|
41
|
+
code: InteractionRequiredAuthErrorCodes.noTokensFound,
|
|
42
|
+
desc: InteractionRequiredAuthErrorMessages[
|
|
43
|
+
InteractionRequiredAuthErrorCodes.noTokensFound
|
|
44
|
+
],
|
|
33
45
|
},
|
|
34
46
|
native_account_unavailable: {
|
|
35
|
-
code:
|
|
36
|
-
desc:
|
|
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
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
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
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
InteractionRequiredAuthErrorMessage.noTokensFoundError.desc
|
|
121
|
-
);
|
|
122
|
-
}
|
|
122
|
+
return (
|
|
123
|
+
isInteractionRequiredErrorCode ||
|
|
124
|
+
isInteractionRequiredErrorDesc ||
|
|
125
|
+
isInteractionRequiredSubError
|
|
126
|
+
);
|
|
127
|
+
}
|
|
123
128
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
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
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
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
|
-
|
|
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
|
}
|
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 {
|
|
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 {
|
|
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
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
+
return Promise.reject(
|
|
52
|
+
createClientAuthError(ClientAuthErrorCodes.methodNotImplemented)
|
|
53
|
+
);
|
|
51
54
|
},
|
|
52
55
|
sendPostRequestAsync: () => {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
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 {
|
|
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
|
|
66
|
-
tokenEndpoint,
|
|
67
|
-
e as string
|
|
68
|
-
);
|
|
68
|
+
throw createClientAuthError(ClientAuthErrorCodes.networkError);
|
|
69
69
|
}
|
|
70
70
|
}
|
|
71
71
|
|
package/src/packageMetadata.ts
CHANGED
|
@@ -3,7 +3,10 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import {
|
|
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
|
|
44
|
-
|
|
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
|
|
60
|
-
|
|
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
|
|
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 {
|
|
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
|
|
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
|
|
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 {
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
86
|
+
throw createClientConfigurationError(
|
|
87
|
+
ClientConfigurationErrorCodes.invalidCodeChallengeMethod
|
|
88
|
+
);
|
|
76
89
|
}
|
|
77
90
|
}
|
|
78
91
|
|
package/src/request/ScopeSet.ts
CHANGED
|
@@ -3,9 +3,15 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import {
|
|
6
|
+
import {
|
|
7
|
+
createClientConfigurationError,
|
|
8
|
+
ClientConfigurationErrorCodes,
|
|
9
|
+
} from "../error/ClientConfigurationError";
|
|
7
10
|
import { StringUtils } from "../utils/StringUtils";
|
|
8
|
-
import {
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
197
|
+
throw createClientAuthError(
|
|
198
|
+
ClientAuthErrorCodes.emptyInputScopeSet
|
|
199
|
+
);
|
|
184
200
|
}
|
|
185
201
|
|
|
186
202
|
// Do not allow OIDC scopes to be the only intersecting scopes
|