@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
|
@@ -6,7 +6,10 @@
|
|
|
6
6
|
import { ServerAuthorizationTokenResponse } from "./ServerAuthorizationTokenResponse";
|
|
7
7
|
import { buildClientInfo } from "../account/ClientInfo";
|
|
8
8
|
import { ICrypto } from "../crypto/ICrypto";
|
|
9
|
-
import {
|
|
9
|
+
import {
|
|
10
|
+
ClientAuthErrorCodes,
|
|
11
|
+
createClientAuthError,
|
|
12
|
+
} from "../error/ClientAuthError";
|
|
10
13
|
import { ServerAuthorizationCodeResponse } from "./ServerAuthorizationCodeResponse";
|
|
11
14
|
import { Logger } from "../logger/Logger";
|
|
12
15
|
import { ServerError } from "../error/ServerError";
|
|
@@ -17,7 +20,10 @@ import { Authority } from "../authority/Authority";
|
|
|
17
20
|
import { IdTokenEntity } from "../cache/entities/IdTokenEntity";
|
|
18
21
|
import { AccessTokenEntity } from "../cache/entities/AccessTokenEntity";
|
|
19
22
|
import { RefreshTokenEntity } from "../cache/entities/RefreshTokenEntity";
|
|
20
|
-
import {
|
|
23
|
+
import {
|
|
24
|
+
InteractionRequiredAuthError,
|
|
25
|
+
isInteractionRequiredError,
|
|
26
|
+
} from "../error/InteractionRequiredAuthError";
|
|
21
27
|
import { CacheRecord } from "../cache/entities/CacheRecord";
|
|
22
28
|
import { CacheManager } from "../cache/CacheManager";
|
|
23
29
|
import { ProtocolUtils, RequestStateObject } from "../utils/ProtocolUtils";
|
|
@@ -84,8 +90,14 @@ export class ResponseHandler {
|
|
|
84
90
|
): void {
|
|
85
91
|
if (!serverResponseHash.state || !cachedState) {
|
|
86
92
|
throw serverResponseHash.state
|
|
87
|
-
?
|
|
88
|
-
|
|
93
|
+
? createClientAuthError(
|
|
94
|
+
ClientAuthErrorCodes.stateNotFound,
|
|
95
|
+
"Cached State"
|
|
96
|
+
)
|
|
97
|
+
: createClientAuthError(
|
|
98
|
+
ClientAuthErrorCodes.stateNotFound,
|
|
99
|
+
"Server State"
|
|
100
|
+
);
|
|
89
101
|
}
|
|
90
102
|
|
|
91
103
|
let decodedServerResponseHash: string;
|
|
@@ -96,23 +108,23 @@ export class ResponseHandler {
|
|
|
96
108
|
serverResponseHash.state
|
|
97
109
|
);
|
|
98
110
|
} catch (e) {
|
|
99
|
-
throw
|
|
100
|
-
|
|
101
|
-
|
|
111
|
+
throw createClientAuthError(
|
|
112
|
+
ClientAuthErrorCodes.invalidState,
|
|
113
|
+
serverResponseHash.state
|
|
102
114
|
);
|
|
103
115
|
}
|
|
104
116
|
|
|
105
117
|
try {
|
|
106
118
|
decodedCachedState = decodeURIComponent(cachedState);
|
|
107
119
|
} catch (e) {
|
|
108
|
-
throw
|
|
109
|
-
|
|
110
|
-
|
|
120
|
+
throw createClientAuthError(
|
|
121
|
+
ClientAuthErrorCodes.invalidState,
|
|
122
|
+
serverResponseHash.state
|
|
111
123
|
);
|
|
112
124
|
}
|
|
113
125
|
|
|
114
126
|
if (decodedServerResponseHash !== decodedCachedState) {
|
|
115
|
-
throw
|
|
127
|
+
throw createClientAuthError(ClientAuthErrorCodes.stateMismatch);
|
|
116
128
|
}
|
|
117
129
|
|
|
118
130
|
// Check for error
|
|
@@ -122,7 +134,7 @@ export class ResponseHandler {
|
|
|
122
134
|
serverResponseHash.suberror
|
|
123
135
|
) {
|
|
124
136
|
if (
|
|
125
|
-
|
|
137
|
+
isInteractionRequiredError(
|
|
126
138
|
serverResponseHash.error,
|
|
127
139
|
serverResponseHash.error_description,
|
|
128
140
|
serverResponseHash.suberror
|
|
@@ -202,7 +214,7 @@ export class ResponseHandler {
|
|
|
202
214
|
}
|
|
203
215
|
|
|
204
216
|
if (
|
|
205
|
-
|
|
217
|
+
isInteractionRequiredError(
|
|
206
218
|
serverResponse.error,
|
|
207
219
|
serverResponse.error_description,
|
|
208
220
|
serverResponse.suberror
|
|
@@ -255,7 +267,9 @@ export class ResponseHandler {
|
|
|
255
267
|
// token nonce check (TODO: Add a warning if no nonce is given?)
|
|
256
268
|
if (authCodePayload && authCodePayload.nonce) {
|
|
257
269
|
if (idTokenClaims.nonce !== authCodePayload.nonce) {
|
|
258
|
-
throw
|
|
270
|
+
throw createClientAuthError(
|
|
271
|
+
ClientAuthErrorCodes.nonceMismatch
|
|
272
|
+
);
|
|
259
273
|
}
|
|
260
274
|
}
|
|
261
275
|
|
|
@@ -263,7 +277,9 @@ export class ResponseHandler {
|
|
|
263
277
|
if (request.maxAge || request.maxAge === 0) {
|
|
264
278
|
const authTime = idTokenClaims.auth_time;
|
|
265
279
|
if (!authTime) {
|
|
266
|
-
throw
|
|
280
|
+
throw createClientAuthError(
|
|
281
|
+
ClientAuthErrorCodes.authTimeNotFound
|
|
282
|
+
);
|
|
267
283
|
}
|
|
268
284
|
|
|
269
285
|
checkMaxAge(authTime, request.maxAge);
|
|
@@ -389,7 +405,9 @@ export class ResponseHandler {
|
|
|
389
405
|
): CacheRecord {
|
|
390
406
|
const env = authority.getPreferredCache();
|
|
391
407
|
if (!env) {
|
|
392
|
-
throw
|
|
408
|
+
throw createClientAuthError(
|
|
409
|
+
ClientAuthErrorCodes.invalidCacheEnvironment
|
|
410
|
+
);
|
|
393
411
|
}
|
|
394
412
|
|
|
395
413
|
// IdToken: non AAD scenarios can have empty realm
|
|
@@ -537,7 +555,9 @@ export class ResponseHandler {
|
|
|
537
555
|
const { secret, keyId } = cacheRecord.accessToken;
|
|
538
556
|
|
|
539
557
|
if (!keyId) {
|
|
540
|
-
throw
|
|
558
|
+
throw createClientAuthError(
|
|
559
|
+
ClientAuthErrorCodes.keyIdMissing
|
|
560
|
+
);
|
|
541
561
|
}
|
|
542
562
|
|
|
543
563
|
accessToken = await popTokenGenerator.signPopToken(
|
|
@@ -227,7 +227,8 @@ export abstract class PerformanceClient implements IPerformanceClient {
|
|
|
227
227
|
|
|
228
228
|
const queueMeasurement: QueueMeasurement = {
|
|
229
229
|
eventName,
|
|
230
|
-
|
|
230
|
+
// Always default queue time to 0 for manually completed (improperly instrumented)
|
|
231
|
+
queueTime: manuallyCompleted ? 0 : queueTime,
|
|
231
232
|
manuallyCompleted,
|
|
232
233
|
};
|
|
233
234
|
|
|
@@ -268,6 +268,15 @@ export const PerformanceEvents = {
|
|
|
268
268
|
* Cache operations
|
|
269
269
|
*/
|
|
270
270
|
ClearTokensAndKeysWithClaims: "clearTokensAndKeysWithClaims",
|
|
271
|
+
|
|
272
|
+
/**
|
|
273
|
+
* Crypto Operations
|
|
274
|
+
*/
|
|
275
|
+
GeneratePkceCodes: "generatePkceCodes",
|
|
276
|
+
GenerateCodeVerifier: "generateCodeVerifier",
|
|
277
|
+
GenerateCodeChallengeFromVerifier: "generateCodeChallengeFromVerifier",
|
|
278
|
+
Sha256Digest: "sha256Digest",
|
|
279
|
+
GetRandomValues: "getRandomValues",
|
|
271
280
|
} as const;
|
|
272
281
|
export type PerformanceEvents =
|
|
273
282
|
(typeof PerformanceEvents)[keyof typeof PerformanceEvents];
|
|
@@ -28,7 +28,7 @@ export class ServerTelemetryManager {
|
|
|
28
28
|
private regionUsed: string | undefined;
|
|
29
29
|
private regionSource: RegionDiscoverySources | undefined;
|
|
30
30
|
private regionOutcome: RegionDiscoveryOutcomes | undefined;
|
|
31
|
-
private cacheOutcome: CacheOutcome = CacheOutcome.
|
|
31
|
+
private cacheOutcome: CacheOutcome = CacheOutcome.NOT_APPLICABLE;
|
|
32
32
|
|
|
33
33
|
constructor(
|
|
34
34
|
telemetryRequest: ServerTelemetryRequest,
|
package/src/url/UrlString.ts
CHANGED
|
@@ -4,8 +4,14 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import { ServerAuthorizationCodeResponse } from "../response/ServerAuthorizationCodeResponse";
|
|
7
|
-
import {
|
|
8
|
-
|
|
7
|
+
import {
|
|
8
|
+
createClientConfigurationError,
|
|
9
|
+
ClientConfigurationErrorCodes,
|
|
10
|
+
} from "../error/ClientConfigurationError";
|
|
11
|
+
import {
|
|
12
|
+
ClientAuthErrorCodes,
|
|
13
|
+
createClientAuthError,
|
|
14
|
+
} from "../error/ClientAuthError";
|
|
9
15
|
import { StringUtils } from "../utils/StringUtils";
|
|
10
16
|
import { IUri } from "./IUri";
|
|
11
17
|
import {
|
|
@@ -28,7 +34,9 @@ export class UrlString {
|
|
|
28
34
|
this._urlString = url;
|
|
29
35
|
if (!this._urlString) {
|
|
30
36
|
// Throws error if url is empty
|
|
31
|
-
throw
|
|
37
|
+
throw createClientConfigurationError(
|
|
38
|
+
ClientConfigurationErrorCodes.urlEmptyError
|
|
39
|
+
);
|
|
32
40
|
}
|
|
33
41
|
|
|
34
42
|
if (!this.getHash()) {
|
|
@@ -69,13 +77,15 @@ export class UrlString {
|
|
|
69
77
|
try {
|
|
70
78
|
components = this.getUrlComponents();
|
|
71
79
|
} catch (e) {
|
|
72
|
-
throw
|
|
80
|
+
throw createClientConfigurationError(
|
|
81
|
+
ClientConfigurationErrorCodes.urlParseError
|
|
82
|
+
);
|
|
73
83
|
}
|
|
74
84
|
|
|
75
85
|
// Throw error if URI or path segments are not parseable.
|
|
76
86
|
if (!components.HostNameAndPort || !components.PathSegments) {
|
|
77
|
-
throw
|
|
78
|
-
|
|
87
|
+
throw createClientConfigurationError(
|
|
88
|
+
ClientConfigurationErrorCodes.urlParseError
|
|
79
89
|
);
|
|
80
90
|
}
|
|
81
91
|
|
|
@@ -84,8 +94,8 @@ export class UrlString {
|
|
|
84
94
|
!components.Protocol ||
|
|
85
95
|
components.Protocol.toLowerCase() !== "https:"
|
|
86
96
|
) {
|
|
87
|
-
throw
|
|
88
|
-
|
|
97
|
+
throw createClientConfigurationError(
|
|
98
|
+
ClientConfigurationErrorCodes.authorityUriInsecure
|
|
89
99
|
);
|
|
90
100
|
}
|
|
91
101
|
}
|
|
@@ -152,8 +162,8 @@ export class UrlString {
|
|
|
152
162
|
// If url string does not match regEx, we throw an error
|
|
153
163
|
const match = this.urlString.match(regEx);
|
|
154
164
|
if (!match) {
|
|
155
|
-
throw
|
|
156
|
-
|
|
165
|
+
throw createClientConfigurationError(
|
|
166
|
+
ClientConfigurationErrorCodes.urlParseError
|
|
157
167
|
);
|
|
158
168
|
}
|
|
159
169
|
|
|
@@ -187,8 +197,8 @@ export class UrlString {
|
|
|
187
197
|
const match = url.match(regEx);
|
|
188
198
|
|
|
189
199
|
if (!match) {
|
|
190
|
-
throw
|
|
191
|
-
|
|
200
|
+
throw createClientConfigurationError(
|
|
201
|
+
ClientConfigurationErrorCodes.urlParseError
|
|
192
202
|
);
|
|
193
203
|
}
|
|
194
204
|
|
|
@@ -290,8 +300,8 @@ export class UrlString {
|
|
|
290
300
|
);
|
|
291
301
|
// Check if deserialization didn't work
|
|
292
302
|
if (!deserializedHash) {
|
|
293
|
-
throw
|
|
294
|
-
|
|
303
|
+
throw createClientAuthError(
|
|
304
|
+
ClientAuthErrorCodes.hashNotDeserialized
|
|
295
305
|
);
|
|
296
306
|
}
|
|
297
307
|
return deserializedHash;
|
|
@@ -316,8 +326,8 @@ export class UrlString {
|
|
|
316
326
|
);
|
|
317
327
|
// Check if deserialization didn't work
|
|
318
328
|
if (!deserializedQueryString) {
|
|
319
|
-
throw
|
|
320
|
-
|
|
329
|
+
throw createClientAuthError(
|
|
330
|
+
ClientAuthErrorCodes.hashNotDeserialized
|
|
321
331
|
);
|
|
322
332
|
}
|
|
323
333
|
return deserializedQueryString;
|
package/src/utils/Constants.ts
CHANGED
|
@@ -417,12 +417,20 @@ export const RegionDiscoveryOutcomes = {
|
|
|
417
417
|
export type RegionDiscoveryOutcomes =
|
|
418
418
|
(typeof RegionDiscoveryOutcomes)[keyof typeof RegionDiscoveryOutcomes];
|
|
419
419
|
|
|
420
|
+
/**
|
|
421
|
+
* Specifies the reason for fetching the access token from the identity provider
|
|
422
|
+
*/
|
|
420
423
|
export const CacheOutcome = {
|
|
421
|
-
|
|
422
|
-
|
|
424
|
+
// When a token is found in the cache or the cache is not supposed to be hit when making the request
|
|
425
|
+
NOT_APPLICABLE: "0",
|
|
426
|
+
// When the token request goes to the identity provider because force_refresh was set to true. Also occurs if claims were requested
|
|
427
|
+
FORCE_REFRESH_OR_CLAIMS: "1",
|
|
428
|
+
// When the token request goes to the identity provider because no cached access token exists
|
|
423
429
|
NO_CACHED_ACCESS_TOKEN: "2",
|
|
430
|
+
// When the token request goes to the identity provider because cached access token expired
|
|
424
431
|
CACHED_ACCESS_TOKEN_EXPIRED: "3",
|
|
425
|
-
|
|
432
|
+
// When the token request goes to the identity provider because refresh_in was used and the existing token needs to be refreshed
|
|
433
|
+
PROACTIVELY_REFRESHED: "4",
|
|
426
434
|
} as const;
|
|
427
435
|
export type CacheOutcome = (typeof CacheOutcome)[keyof typeof CacheOutcome];
|
|
428
436
|
|
|
@@ -5,7 +5,10 @@
|
|
|
5
5
|
|
|
6
6
|
import { Constants } from "./Constants";
|
|
7
7
|
import { ICrypto } from "../crypto/ICrypto";
|
|
8
|
-
import {
|
|
8
|
+
import {
|
|
9
|
+
ClientAuthErrorCodes,
|
|
10
|
+
createClientAuthError,
|
|
11
|
+
} from "../error/ClientAuthError";
|
|
9
12
|
|
|
10
13
|
/**
|
|
11
14
|
* Type which defines the object that is stringified, encoded and sent in the state value.
|
|
@@ -60,9 +63,7 @@ export class ProtocolUtils {
|
|
|
60
63
|
meta?: Record<string, string>
|
|
61
64
|
): string {
|
|
62
65
|
if (!cryptoObj) {
|
|
63
|
-
throw
|
|
64
|
-
"generateLibraryState"
|
|
65
|
-
);
|
|
66
|
+
throw createClientAuthError(ClientAuthErrorCodes.noCryptoObject);
|
|
66
67
|
}
|
|
67
68
|
|
|
68
69
|
// Create a state object containing a unique id and the timestamp of the request creation
|
|
@@ -89,16 +90,11 @@ export class ProtocolUtils {
|
|
|
89
90
|
state: string
|
|
90
91
|
): RequestStateObject {
|
|
91
92
|
if (!cryptoObj) {
|
|
92
|
-
throw
|
|
93
|
-
"parseRequestState"
|
|
94
|
-
);
|
|
93
|
+
throw createClientAuthError(ClientAuthErrorCodes.noCryptoObject);
|
|
95
94
|
}
|
|
96
95
|
|
|
97
96
|
if (!state) {
|
|
98
|
-
throw
|
|
99
|
-
state,
|
|
100
|
-
"Null, undefined or empty state"
|
|
101
|
-
);
|
|
97
|
+
throw createClientAuthError(ClientAuthErrorCodes.invalidState);
|
|
102
98
|
}
|
|
103
99
|
|
|
104
100
|
try {
|
|
@@ -118,7 +114,7 @@ export class ProtocolUtils {
|
|
|
118
114
|
libraryState: libraryStateObj,
|
|
119
115
|
};
|
|
120
116
|
} catch (e) {
|
|
121
|
-
throw
|
|
117
|
+
throw createClientAuthError(ClientAuthErrorCodes.invalidState);
|
|
122
118
|
}
|
|
123
119
|
}
|
|
124
120
|
}
|