@azure/msal-common 16.11.3 → 16.13.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.mjs +1 -1
- package/dist/account/AuthToken.mjs +1 -1
- package/dist/account/CcsCredential.mjs +1 -1
- package/dist/account/ClientInfo.mjs +1 -1
- package/dist/account/TokenClaims.mjs +1 -1
- package/dist/authority/Authority.mjs +1 -1
- package/dist/authority/AuthorityFactory.mjs +1 -1
- package/dist/authority/AuthorityMetadata.mjs +2 -5
- package/dist/authority/AuthorityMetadata.mjs.map +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.mjs +1 -1
- package/dist/cache/CacheManager.mjs +55 -19
- package/dist/cache/CacheManager.mjs.map +1 -1
- package/dist/cache/persistence/TokenCacheContext.mjs +1 -1
- package/dist/cache/utils/AccountEntityUtils.mjs +1 -1
- package/dist/cache/utils/CacheHelpers.mjs +24 -4
- package/dist/cache/utils/CacheHelpers.mjs.map +1 -1
- package/dist/client/AuthorizationCodeClient.mjs +10 -4
- package/dist/client/AuthorizationCodeClient.mjs.map +1 -1
- package/dist/client/RefreshTokenClient.mjs +10 -4
- package/dist/client/RefreshTokenClient.mjs.map +1 -1
- package/dist/client/SilentFlowClient.mjs +5 -2
- package/dist/client/SilentFlowClient.mjs.map +1 -1
- package/dist/config/ClientConfiguration.mjs +4 -2
- package/dist/config/ClientConfiguration.mjs.map +1 -1
- package/dist/constants/AADServerParamKeys.mjs +4 -3
- package/dist/constants/AADServerParamKeys.mjs.map +1 -1
- package/dist/crypto/ICrypto.mjs +16 -11
- package/dist/crypto/ICrypto.mjs.map +1 -1
- package/dist/crypto/ITokenBindingKeyManager.mjs +28 -0
- package/dist/crypto/ITokenBindingKeyManager.mjs.map +1 -0
- package/dist/crypto/JoseHeader.mjs +38 -11
- package/dist/crypto/JoseHeader.mjs.map +1 -1
- package/dist/crypto/PopTokenGenerator.mjs +28 -5
- package/dist/crypto/PopTokenGenerator.mjs.map +1 -1
- package/dist/error/AuthError.mjs +1 -1
- package/dist/error/AuthErrorCodes.mjs +1 -1
- package/dist/error/CacheError.mjs +1 -1
- package/dist/error/CacheErrorCodes.mjs +1 -1
- package/dist/error/ClientAuthError.mjs +1 -1
- package/dist/error/ClientAuthErrorCodes.mjs +1 -1
- package/dist/error/ClientConfigurationError.mjs +1 -1
- package/dist/error/ClientConfigurationErrorCodes.mjs +3 -2
- package/dist/error/ClientConfigurationErrorCodes.mjs.map +1 -1
- package/dist/error/InteractionRequiredAuthError.mjs +1 -1
- package/dist/error/InteractionRequiredAuthErrorCodes.mjs +1 -1
- package/dist/error/JoseHeaderError.mjs +1 -1
- package/dist/error/JoseHeaderErrorCodes.mjs +5 -3
- package/dist/error/JoseHeaderErrorCodes.mjs.map +1 -1
- package/dist/error/NetworkError.mjs +1 -1
- package/dist/error/PlatformBrokerError.mjs +1 -1
- package/dist/error/ServerError.mjs +1 -1
- package/dist/index-node.mjs +3 -2
- package/dist/index-node.mjs.map +1 -1
- package/dist/index.mjs +3 -2
- package/dist/index.mjs.map +1 -1
- package/dist/logger/Logger.mjs +1 -1
- package/dist/network/INetworkModule.mjs +1 -1
- package/dist/network/RequestThumbprint.mjs +4 -1
- package/dist/network/RequestThumbprint.mjs.map +1 -1
- package/dist/network/ThrottlingUtils.mjs +1 -1
- package/dist/packageMetadata.mjs +2 -2
- package/dist/protocol/Authorize.mjs +1 -1
- package/dist/protocol/Token.mjs +1 -1
- package/dist/request/AuthenticationHeaderParser.mjs +1 -1
- package/dist/request/BaseAuthRequest.mjs +1 -1
- package/dist/request/BaseAuthRequest.mjs.map +1 -1
- package/dist/request/RequestParameterBuilder.mjs +94 -26
- package/dist/request/RequestParameterBuilder.mjs.map +1 -1
- package/dist/request/ScopeSet.mjs +1 -1
- package/dist/response/ResponseHandler.mjs +30 -8
- package/dist/response/ResponseHandler.mjs.map +1 -1
- package/dist/telemetry/performance/PerformanceClient.mjs +1 -1
- package/dist/telemetry/performance/PerformanceEvent.mjs +1 -1
- package/dist/telemetry/performance/PerformanceEvent.mjs.map +1 -1
- package/dist/telemetry/performance/PerformanceEvents.mjs +1 -1
- package/dist/telemetry/performance/StubPerformanceClient.mjs +1 -1
- package/dist/telemetry/server/ServerTelemetryManager.mjs +1 -1
- package/dist/url/UrlString.mjs +1 -1
- package/dist/utils/ClientAssertionUtils.mjs +1 -1
- package/dist/utils/Constants.mjs +2 -1
- package/dist/utils/Constants.mjs.map +1 -1
- package/dist/utils/FunctionWrappers.mjs +1 -1
- package/dist/utils/ObjectUtils.mjs +28 -0
- package/dist/utils/ObjectUtils.mjs.map +1 -0
- package/dist/utils/ProtocolUtils.mjs +1 -1
- package/dist/utils/StringUtils.mjs +1 -1
- package/dist/utils/TimeUtils.mjs +1 -1
- package/dist/utils/UrlUtils.mjs +1 -1
- package/dist-browser/account/AccountInfo.mjs +1 -1
- package/dist-browser/account/AuthToken.mjs +1 -1
- package/dist-browser/account/CcsCredential.mjs +1 -1
- package/dist-browser/account/ClientInfo.mjs +1 -1
- package/dist-browser/account/TokenClaims.mjs +1 -1
- package/dist-browser/authority/Authority.mjs +1 -1
- package/dist-browser/authority/AuthorityFactory.mjs +1 -1
- package/dist-browser/authority/AuthorityMetadata.mjs +2 -5
- package/dist-browser/authority/AuthorityMetadata.mjs.map +1 -1
- package/dist-browser/authority/AuthorityOptions.mjs +1 -1
- package/dist-browser/authority/AuthorityType.mjs +1 -1
- package/dist-browser/authority/CloudInstanceDiscoveryErrorResponse.mjs +1 -1
- package/dist-browser/authority/CloudInstanceDiscoveryResponse.mjs +1 -1
- package/dist-browser/authority/OpenIdConfigResponse.mjs +1 -1
- package/dist-browser/authority/ProtocolMode.mjs +1 -1
- package/dist-browser/authority/RegionDiscovery.mjs +1 -1
- package/dist-browser/cache/CacheManager.mjs +55 -19
- package/dist-browser/cache/CacheManager.mjs.map +1 -1
- package/dist-browser/cache/persistence/TokenCacheContext.mjs +1 -1
- package/dist-browser/cache/utils/AccountEntityUtils.mjs +1 -1
- package/dist-browser/cache/utils/CacheHelpers.mjs +24 -4
- package/dist-browser/cache/utils/CacheHelpers.mjs.map +1 -1
- package/dist-browser/client/AuthorizationCodeClient.mjs +10 -4
- package/dist-browser/client/AuthorizationCodeClient.mjs.map +1 -1
- package/dist-browser/client/RefreshTokenClient.mjs +10 -4
- package/dist-browser/client/RefreshTokenClient.mjs.map +1 -1
- package/dist-browser/client/SilentFlowClient.mjs +5 -2
- package/dist-browser/client/SilentFlowClient.mjs.map +1 -1
- package/dist-browser/config/ClientConfiguration.mjs +4 -2
- package/dist-browser/config/ClientConfiguration.mjs.map +1 -1
- package/dist-browser/constants/AADServerParamKeys.mjs +4 -3
- package/dist-browser/constants/AADServerParamKeys.mjs.map +1 -1
- package/dist-browser/crypto/ICrypto.mjs +16 -11
- package/dist-browser/crypto/ICrypto.mjs.map +1 -1
- package/dist-browser/crypto/ITokenBindingKeyManager.mjs +28 -0
- package/dist-browser/crypto/ITokenBindingKeyManager.mjs.map +1 -0
- package/dist-browser/crypto/JoseHeader.mjs +38 -11
- package/dist-browser/crypto/JoseHeader.mjs.map +1 -1
- package/dist-browser/crypto/PopTokenGenerator.mjs +28 -5
- package/dist-browser/crypto/PopTokenGenerator.mjs.map +1 -1
- package/dist-browser/error/AuthError.mjs +1 -1
- package/dist-browser/error/AuthErrorCodes.mjs +1 -1
- package/dist-browser/error/CacheError.mjs +1 -1
- package/dist-browser/error/CacheErrorCodes.mjs +1 -1
- package/dist-browser/error/ClientAuthError.mjs +1 -1
- package/dist-browser/error/ClientAuthErrorCodes.mjs +1 -1
- package/dist-browser/error/ClientConfigurationError.mjs +1 -1
- package/dist-browser/error/ClientConfigurationErrorCodes.mjs +3 -2
- package/dist-browser/error/ClientConfigurationErrorCodes.mjs.map +1 -1
- package/dist-browser/error/InteractionRequiredAuthError.mjs +1 -1
- package/dist-browser/error/InteractionRequiredAuthErrorCodes.mjs +1 -1
- package/dist-browser/error/JoseHeaderError.mjs +1 -1
- package/dist-browser/error/JoseHeaderErrorCodes.mjs +5 -3
- package/dist-browser/error/JoseHeaderErrorCodes.mjs.map +1 -1
- package/dist-browser/error/NetworkError.mjs +1 -1
- package/dist-browser/error/PlatformBrokerError.mjs +1 -1
- package/dist-browser/error/ServerError.mjs +1 -1
- package/dist-browser/index-browser.mjs +3 -2
- package/dist-browser/index-browser.mjs.map +1 -1
- package/dist-browser/index.mjs +3 -2
- package/dist-browser/index.mjs.map +1 -1
- package/dist-browser/log-strings-mapping.json +2 -2
- package/dist-browser/logger/Logger.mjs +1 -1
- package/dist-browser/network/INetworkModule.mjs +1 -1
- package/dist-browser/network/RequestThumbprint.mjs +4 -1
- package/dist-browser/network/RequestThumbprint.mjs.map +1 -1
- package/dist-browser/network/ThrottlingUtils.mjs +1 -1
- package/dist-browser/packageMetadata.mjs +2 -2
- package/dist-browser/protocol/Authorize.mjs +1 -1
- package/dist-browser/protocol/Token.mjs +1 -1
- package/dist-browser/request/AuthenticationHeaderParser.mjs +1 -1
- package/dist-browser/request/BaseAuthRequest.mjs +1 -1
- package/dist-browser/request/BaseAuthRequest.mjs.map +1 -1
- package/dist-browser/request/RequestParameterBuilder.mjs +94 -26
- package/dist-browser/request/RequestParameterBuilder.mjs.map +1 -1
- package/dist-browser/request/ScopeSet.mjs +1 -1
- package/dist-browser/response/ResponseHandler.mjs +30 -8
- package/dist-browser/response/ResponseHandler.mjs.map +1 -1
- package/dist-browser/telemetry/performance/PerformanceClient.mjs +1 -1
- package/dist-browser/telemetry/performance/PerformanceEvent.mjs +1 -1
- package/dist-browser/telemetry/performance/PerformanceEvent.mjs.map +1 -1
- package/dist-browser/telemetry/performance/PerformanceEvents.mjs +1 -1
- package/dist-browser/telemetry/performance/StubPerformanceClient.mjs +1 -1
- package/dist-browser/telemetry/server/ServerTelemetryManager.mjs +1 -1
- package/dist-browser/url/UrlString.mjs +1 -1
- package/dist-browser/utils/ClientAssertionUtils.mjs +1 -1
- package/dist-browser/utils/Constants.mjs +2 -1
- package/dist-browser/utils/Constants.mjs.map +1 -1
- package/dist-browser/utils/FunctionWrappers.mjs +1 -1
- package/dist-browser/utils/ObjectUtils.mjs +28 -0
- package/dist-browser/utils/ObjectUtils.mjs.map +1 -0
- package/dist-browser/utils/ProtocolUtils.mjs +1 -1
- package/dist-browser/utils/StringUtils.mjs +1 -1
- package/dist-browser/utils/TimeUtils.mjs +1 -1
- package/dist-browser/utils/UrlUtils.mjs +1 -1
- package/lib/index-browser.cjs +5 -67
- package/lib/index-browser.cjs.map +1 -1
- package/lib/{index-node-JVUj78ag.js → index-node-BaODPZEy.js} +404 -75
- package/lib/index-node-BaODPZEy.js.map +1 -0
- package/lib/index-node.cjs +4 -2
- package/lib/index-node.cjs.map +1 -1
- package/lib/index.cjs +5 -3
- package/lib/index.cjs.map +1 -1
- package/package.json +1 -1
- package/src/authority/AuthorityMetadata.ts +1 -4
- package/src/cache/CacheManager.ts +100 -29
- package/src/cache/interface/ICacheManager.ts +7 -4
- package/src/cache/utils/CacheHelpers.ts +28 -1
- package/src/client/AuthorizationCodeClient.ts +16 -1
- package/src/client/RefreshTokenClient.ts +16 -1
- package/src/client/SilentFlowClient.ts +4 -1
- package/src/config/ClientConfiguration.ts +10 -0
- package/src/constants/AADServerParamKeys.ts +1 -0
- package/src/crypto/DpopProofGenerator.ts +52 -59
- package/src/crypto/ICrypto.ts +31 -26
- package/src/crypto/ITokenBindingKeyManager.ts +84 -0
- package/src/crypto/JoseHeader.ts +74 -14
- package/src/crypto/PopTokenGenerator.ts +62 -18
- package/src/error/ClientConfigurationErrorCodes.ts +2 -0
- package/src/error/JoseHeaderErrorCodes.ts +2 -0
- package/src/exports-common.ts +7 -0
- package/src/network/RequestThumbprint.ts +5 -0
- package/src/packageMetadata.ts +1 -1
- package/src/request/BaseAuthRequest.ts +4 -0
- package/src/request/RequestParameterBuilder.ts +119 -26
- package/src/response/ResponseHandler.ts +56 -15
- package/src/telemetry/performance/PerformanceEvent.ts +15 -0
- package/src/utils/Constants.ts +1 -0
- package/src/utils/ObjectUtils.ts +31 -0
- package/types/authority/AuthorityMetadata.d.ts.map +1 -1
- package/types/cache/CacheManager.d.ts +14 -7
- package/types/cache/CacheManager.d.ts.map +1 -1
- package/types/cache/interface/ICacheManager.d.ts +6 -4
- package/types/cache/interface/ICacheManager.d.ts.map +1 -1
- package/types/cache/utils/CacheHelpers.d.ts +7 -0
- package/types/cache/utils/CacheHelpers.d.ts.map +1 -1
- package/types/client/AuthorizationCodeClient.d.ts.map +1 -1
- package/types/client/RefreshTokenClient.d.ts.map +1 -1
- package/types/client/SilentFlowClient.d.ts.map +1 -1
- package/types/config/ClientConfiguration.d.ts +5 -1
- package/types/config/ClientConfiguration.d.ts.map +1 -1
- package/types/constants/AADServerParamKeys.d.ts +1 -0
- package/types/constants/AADServerParamKeys.d.ts.map +1 -1
- package/types/crypto/DpopProofGenerator.d.ts +10 -36
- package/types/crypto/DpopProofGenerator.d.ts.map +1 -1
- package/types/crypto/ICrypto.d.ts +10 -9
- package/types/crypto/ICrypto.d.ts.map +1 -1
- package/types/crypto/ITokenBindingKeyManager.d.ts +41 -0
- package/types/crypto/ITokenBindingKeyManager.d.ts.map +1 -0
- package/types/crypto/JoseHeader.d.ts +17 -5
- package/types/crypto/JoseHeader.d.ts.map +1 -1
- package/types/crypto/PopTokenGenerator.d.ts +3 -1
- package/types/crypto/PopTokenGenerator.d.ts.map +1 -1
- package/types/error/ClientConfigurationErrorCodes.d.ts +1 -0
- package/types/error/ClientConfigurationErrorCodes.d.ts.map +1 -1
- package/types/error/JoseHeaderErrorCodes.d.ts +2 -0
- package/types/error/JoseHeaderErrorCodes.d.ts.map +1 -1
- package/types/exports-common.d.ts +3 -2
- package/types/exports-common.d.ts.map +1 -1
- package/types/network/RequestThumbprint.d.ts +1 -0
- package/types/network/RequestThumbprint.d.ts.map +1 -1
- package/types/packageMetadata.d.ts +1 -1
- package/types/request/BaseAuthRequest.d.ts +4 -0
- package/types/request/BaseAuthRequest.d.ts.map +1 -1
- package/types/request/RequestParameterBuilder.d.ts +22 -4
- package/types/request/RequestParameterBuilder.d.ts.map +1 -1
- package/types/response/ResponseHandler.d.ts +12 -2
- package/types/response/ResponseHandler.d.ts.map +1 -1
- package/types/telemetry/performance/PerformanceEvent.d.ts +12 -0
- package/types/telemetry/performance/PerformanceEvent.d.ts.map +1 -1
- package/types/utils/Constants.d.ts +1 -0
- package/types/utils/Constants.d.ts.map +1 -1
- package/types/utils/ObjectUtils.d.ts +6 -0
- package/types/utils/ObjectUtils.d.ts.map +1 -0
- package/lib/index-node-JVUj78ag.js.map +0 -1
package/src/crypto/ICrypto.ts
CHANGED
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
createClientAuthError,
|
|
9
9
|
} from "../error/ClientAuthError.js";
|
|
10
10
|
import type { BaseAuthRequest } from "../request/BaseAuthRequest.js";
|
|
11
|
-
import type {
|
|
11
|
+
import type { JoseHeader } from "./JoseHeader.js";
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* PKCE code verifier and challenge pair used by authorization code flows.
|
|
@@ -35,9 +35,11 @@ export type SignedHttpRequestParameters = Pick<
|
|
|
35
35
|
|
|
36
36
|
/**
|
|
37
37
|
* Shared JOSE algorithm literals used by MSAL package internals.
|
|
38
|
+
* @internal
|
|
38
39
|
*/
|
|
39
40
|
export const JsonWebTokenAlgorithms = {
|
|
40
41
|
ES256: "ES256",
|
|
42
|
+
RS256: "RS256",
|
|
41
43
|
} as const;
|
|
42
44
|
/**
|
|
43
45
|
* Interface for crypto functions used by library
|
|
@@ -67,13 +69,6 @@ export interface ICrypto {
|
|
|
67
69
|
* @returns Base64Url encoded public key
|
|
68
70
|
*/
|
|
69
71
|
encodeKid(inputKid: string): string;
|
|
70
|
-
/**
|
|
71
|
-
* Generates an JWK RSA S256 Thumbprint
|
|
72
|
-
* @param request
|
|
73
|
-
*/
|
|
74
|
-
getPublicKeyThumbprint(
|
|
75
|
-
request: SignedHttpRequestParameters
|
|
76
|
-
): Promise<string>;
|
|
77
72
|
/**
|
|
78
73
|
* Removes cryptographic keypair from key store matching the keyId passed in
|
|
79
74
|
* @param kid
|
|
@@ -86,14 +81,18 @@ export interface ICrypto {
|
|
|
86
81
|
*/
|
|
87
82
|
clearKeystore(correlationId: string): Promise<boolean>;
|
|
88
83
|
/**
|
|
89
|
-
*
|
|
90
|
-
* @
|
|
84
|
+
* Signs a compact JWT with the token-binding key identified by kid.
|
|
85
|
+
* @internal
|
|
86
|
+
* @param header
|
|
87
|
+
* @param payload
|
|
88
|
+
* @param kid
|
|
89
|
+
* @param correlationId
|
|
91
90
|
*/
|
|
92
|
-
|
|
93
|
-
|
|
91
|
+
signTokenBindingJwt(
|
|
92
|
+
header: JoseHeader,
|
|
93
|
+
payload: object,
|
|
94
94
|
kid: string,
|
|
95
|
-
|
|
96
|
-
correlationId?: string
|
|
95
|
+
correlationId: string
|
|
97
96
|
): Promise<string>;
|
|
98
97
|
/**
|
|
99
98
|
* Returns the SHA-256 hash of an input string
|
|
@@ -137,28 +136,34 @@ export const DEFAULT_CRYPTO_IMPLEMENTATION: ICrypto = {
|
|
|
137
136
|
""
|
|
138
137
|
);
|
|
139
138
|
},
|
|
140
|
-
async
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
},
|
|
146
|
-
async removeTokenBindingKey(): Promise<void> {
|
|
139
|
+
async removeTokenBindingKey(
|
|
140
|
+
kid: string,
|
|
141
|
+
correlationId: string
|
|
142
|
+
): Promise<void> {
|
|
143
|
+
void kid;
|
|
147
144
|
throw createClientAuthError(
|
|
148
145
|
ClientAuthErrorCodes.methodNotImplemented,
|
|
149
|
-
|
|
146
|
+
correlationId
|
|
150
147
|
);
|
|
151
148
|
},
|
|
152
|
-
async clearKeystore(): Promise<boolean> {
|
|
149
|
+
async clearKeystore(correlationId: string): Promise<boolean> {
|
|
153
150
|
throw createClientAuthError(
|
|
154
151
|
ClientAuthErrorCodes.methodNotImplemented,
|
|
155
|
-
|
|
152
|
+
correlationId
|
|
156
153
|
);
|
|
157
154
|
},
|
|
158
|
-
async
|
|
155
|
+
async signTokenBindingJwt(
|
|
156
|
+
header: JoseHeader,
|
|
157
|
+
payload: object,
|
|
158
|
+
kid: string,
|
|
159
|
+
correlationId: string
|
|
160
|
+
): Promise<string> {
|
|
161
|
+
void header;
|
|
162
|
+
void payload;
|
|
163
|
+
void kid;
|
|
159
164
|
throw createClientAuthError(
|
|
160
165
|
ClientAuthErrorCodes.methodNotImplemented,
|
|
161
|
-
|
|
166
|
+
correlationId
|
|
162
167
|
);
|
|
163
168
|
},
|
|
164
169
|
async hashString(): Promise<string> {
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import {
|
|
7
|
+
ClientAuthErrorCodes,
|
|
8
|
+
createClientAuthError,
|
|
9
|
+
} from "../error/ClientAuthError.js";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Parameters used by token-binding key managers to provision browser-managed
|
|
13
|
+
* token-binding keys. Callers own the protocol policy (key type and JOSE
|
|
14
|
+
* algorithm); implementations generate, store, retrieve, and use the requested
|
|
15
|
+
* key material by key identifier.
|
|
16
|
+
*/
|
|
17
|
+
export type TokenBindingKeyProvisioningParameters = {
|
|
18
|
+
tokenBindingKeyType: string;
|
|
19
|
+
tokenBindingKeyAlgorithm: string;
|
|
20
|
+
correlationId: string;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Internal key lifecycle abstraction for browser token-binding keys.
|
|
25
|
+
* @internal
|
|
26
|
+
*/
|
|
27
|
+
export interface ITokenBindingKeyManager {
|
|
28
|
+
/**
|
|
29
|
+
* Provisions a token-binding key and returns the key identifier.
|
|
30
|
+
* @param request - Key provisioning policy.
|
|
31
|
+
*/
|
|
32
|
+
provisionTokenBindingKey(
|
|
33
|
+
request: TokenBindingKeyProvisioningParameters
|
|
34
|
+
): Promise<string>;
|
|
35
|
+
/**
|
|
36
|
+
* Removes a token-binding key by identifier.
|
|
37
|
+
* @param kid - Token-binding key identifier.
|
|
38
|
+
* @param correlationId - Request correlation identifier.
|
|
39
|
+
*/
|
|
40
|
+
removeTokenBindingKey(kid: string, correlationId: string): Promise<void>;
|
|
41
|
+
/**
|
|
42
|
+
* Gets a token-binding public key as a JWK by identifier.
|
|
43
|
+
* @param kid - Token-binding key identifier.
|
|
44
|
+
* @param correlationId - Request correlation identifier.
|
|
45
|
+
*/
|
|
46
|
+
getTokenBindingPublicKeyJwk(
|
|
47
|
+
kid: string,
|
|
48
|
+
correlationId: string
|
|
49
|
+
): Promise<JsonWebKey>;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Default token-binding key manager used when a platform-specific implementation
|
|
54
|
+
* has not been provided.
|
|
55
|
+
* @internal
|
|
56
|
+
*/
|
|
57
|
+
export const DEFAULT_TOKEN_BINDING_KEY_MANAGER: ITokenBindingKeyManager = {
|
|
58
|
+
async provisionTokenBindingKey(
|
|
59
|
+
request: TokenBindingKeyProvisioningParameters
|
|
60
|
+
): Promise<string> {
|
|
61
|
+
throw createClientAuthError(
|
|
62
|
+
ClientAuthErrorCodes.methodNotImplemented,
|
|
63
|
+
request.correlationId
|
|
64
|
+
);
|
|
65
|
+
},
|
|
66
|
+
async removeTokenBindingKey(
|
|
67
|
+
_kid: string,
|
|
68
|
+
correlationId: string
|
|
69
|
+
): Promise<void> {
|
|
70
|
+
throw createClientAuthError(
|
|
71
|
+
ClientAuthErrorCodes.methodNotImplemented,
|
|
72
|
+
correlationId
|
|
73
|
+
);
|
|
74
|
+
},
|
|
75
|
+
async getTokenBindingPublicKeyJwk(
|
|
76
|
+
_kid: string,
|
|
77
|
+
correlationId: string
|
|
78
|
+
): Promise<JsonWebKey> {
|
|
79
|
+
throw createClientAuthError(
|
|
80
|
+
ClientAuthErrorCodes.methodNotImplemented,
|
|
81
|
+
correlationId
|
|
82
|
+
);
|
|
83
|
+
},
|
|
84
|
+
};
|
package/src/crypto/JoseHeader.ts
CHANGED
|
@@ -7,40 +7,57 @@ import {
|
|
|
7
7
|
JoseHeaderErrorCodes,
|
|
8
8
|
createJoseHeaderError,
|
|
9
9
|
} from "../error/JoseHeaderError.js";
|
|
10
|
+
import { isPlainObject } from "../utils/ObjectUtils.js";
|
|
10
11
|
import { JsonWebTokenTypes } from "../utils/Constants.js";
|
|
11
12
|
|
|
12
13
|
export type JoseHeaderOptions = {
|
|
13
14
|
typ?: JsonWebTokenTypes;
|
|
14
15
|
alg?: string;
|
|
15
16
|
kid?: string;
|
|
17
|
+
jwk?: JsonWebKey;
|
|
16
18
|
};
|
|
17
19
|
|
|
18
20
|
/** @internal */
|
|
19
21
|
export class JoseHeader {
|
|
20
22
|
public typ?: JsonWebTokenTypes;
|
|
21
|
-
public alg
|
|
23
|
+
public alg: string;
|
|
22
24
|
public kid?: string;
|
|
25
|
+
public jwk?: JsonWebKey;
|
|
26
|
+
|
|
27
|
+
constructor(
|
|
28
|
+
options: JoseHeaderOptions & { alg: string },
|
|
29
|
+
correlationId: string
|
|
30
|
+
) {
|
|
31
|
+
if (typeof options.alg !== "string" || !options.alg) {
|
|
32
|
+
throw createJoseHeaderError(
|
|
33
|
+
JoseHeaderErrorCodes.missingAlgError,
|
|
34
|
+
correlationId
|
|
35
|
+
);
|
|
36
|
+
}
|
|
23
37
|
|
|
24
|
-
constructor(options: JoseHeaderOptions) {
|
|
25
38
|
this.typ = options.typ;
|
|
26
39
|
this.alg = options.alg;
|
|
27
40
|
this.kid = options.kid;
|
|
41
|
+
this.jwk = options.jwk;
|
|
28
42
|
}
|
|
29
43
|
|
|
30
44
|
/**
|
|
31
45
|
* Builds SignedHttpRequest formatted JOSE Header from the
|
|
32
|
-
* JOSE Header options provided or previously set on the object
|
|
33
|
-
* the stringified header object.
|
|
46
|
+
* JOSE Header options provided or previously set on the object.
|
|
34
47
|
* Throws if keyId or algorithm aren't provided since they are required for Access Token Binding.
|
|
35
48
|
* @param shrHeaderOptions
|
|
49
|
+
* @param correlationId
|
|
36
50
|
* @returns
|
|
37
51
|
*/
|
|
38
|
-
static
|
|
52
|
+
static getShrHeader(
|
|
53
|
+
shrHeaderOptions: JoseHeaderOptions,
|
|
54
|
+
correlationId: string
|
|
55
|
+
): JoseHeader {
|
|
39
56
|
// KeyID is required on the SHR header
|
|
40
57
|
if (!shrHeaderOptions.kid) {
|
|
41
58
|
throw createJoseHeaderError(
|
|
42
59
|
JoseHeaderErrorCodes.missingKidError,
|
|
43
|
-
|
|
60
|
+
correlationId
|
|
44
61
|
);
|
|
45
62
|
}
|
|
46
63
|
|
|
@@ -48,17 +65,60 @@ export class JoseHeader {
|
|
|
48
65
|
if (!shrHeaderOptions.alg) {
|
|
49
66
|
throw createJoseHeaderError(
|
|
50
67
|
JoseHeaderErrorCodes.missingAlgError,
|
|
51
|
-
|
|
68
|
+
correlationId
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
return new JoseHeader(
|
|
73
|
+
{
|
|
74
|
+
// Access Token PoP headers must have type pop, but the type header can be overriden for special cases
|
|
75
|
+
typ: shrHeaderOptions.typ || JsonWebTokenTypes.Pop,
|
|
76
|
+
kid: shrHeaderOptions.kid,
|
|
77
|
+
alg: shrHeaderOptions.alg,
|
|
78
|
+
},
|
|
79
|
+
correlationId
|
|
80
|
+
);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Builds a DPoP formatted JOSE Header from the JOSE Header options provided.
|
|
85
|
+
* Throws if public JWK or algorithm aren't provided since they are required for DPoP.
|
|
86
|
+
* @param dpopHeaderOptions
|
|
87
|
+
* @param correlationId
|
|
88
|
+
* @returns
|
|
89
|
+
*/
|
|
90
|
+
static getDpopHeader(
|
|
91
|
+
dpopHeaderOptions: JoseHeaderOptions,
|
|
92
|
+
correlationId: string
|
|
93
|
+
): JoseHeader {
|
|
94
|
+
if (!isPlainObject(dpopHeaderOptions.jwk)) {
|
|
95
|
+
throw createJoseHeaderError(
|
|
96
|
+
JoseHeaderErrorCodes.missingJwkError,
|
|
97
|
+
correlationId
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
if (!dpopHeaderOptions.alg) {
|
|
102
|
+
throw createJoseHeaderError(
|
|
103
|
+
JoseHeaderErrorCodes.missingAlgError,
|
|
104
|
+
correlationId
|
|
52
105
|
);
|
|
53
106
|
}
|
|
54
107
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
}
|
|
108
|
+
if (Object.keys(dpopHeaderOptions.jwk).length === 0) {
|
|
109
|
+
throw createJoseHeaderError(
|
|
110
|
+
JoseHeaderErrorCodes.invalidJwkError,
|
|
111
|
+
correlationId
|
|
112
|
+
);
|
|
113
|
+
}
|
|
61
114
|
|
|
62
|
-
return
|
|
115
|
+
return new JoseHeader(
|
|
116
|
+
{
|
|
117
|
+
typ: JsonWebTokenTypes.Dpop,
|
|
118
|
+
alg: dpopHeaderOptions.alg,
|
|
119
|
+
jwk: dpopHeaderOptions.jwk,
|
|
120
|
+
},
|
|
121
|
+
correlationId
|
|
122
|
+
);
|
|
63
123
|
}
|
|
64
124
|
}
|
|
@@ -3,13 +3,20 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import {
|
|
6
|
+
import {
|
|
7
|
+
ICrypto,
|
|
8
|
+
JsonWebTokenAlgorithms,
|
|
9
|
+
SignedHttpRequestParameters,
|
|
10
|
+
} from "./ICrypto.js";
|
|
7
11
|
import * as TimeUtils from "../utils/TimeUtils.js";
|
|
8
12
|
import { UrlString } from "../url/UrlString.js";
|
|
9
13
|
import { IPerformanceClient } from "../telemetry/performance/IPerformanceClient.js";
|
|
10
14
|
import * as PerformanceEvents from "../telemetry/performance/PerformanceEvents.js";
|
|
11
15
|
import { invokeAsync } from "../utils/FunctionWrappers.js";
|
|
12
16
|
import { Logger } from "../logger/Logger.js";
|
|
17
|
+
import { JoseHeader } from "./JoseHeader.js";
|
|
18
|
+
import { SignedHttpRequest } from "./SignedHttpRequest.js";
|
|
19
|
+
import { ITokenBindingKeyManager } from "./ITokenBindingKeyManager.js";
|
|
13
20
|
|
|
14
21
|
/**
|
|
15
22
|
* See eSTS docs for more info.
|
|
@@ -34,13 +41,22 @@ const KeyLocation = {
|
|
|
34
41
|
} as const;
|
|
35
42
|
export type KeyLocation = (typeof KeyLocation)[keyof typeof KeyLocation];
|
|
36
43
|
|
|
44
|
+
const SHR_TOKEN_BINDING_KEY_TYPE = "shr";
|
|
45
|
+
const SHR_TOKEN_BINDING_KEY_ALGORITHM = JsonWebTokenAlgorithms.RS256;
|
|
46
|
+
|
|
37
47
|
/** @internal */
|
|
38
48
|
export class PopTokenGenerator {
|
|
39
49
|
private cryptoUtils: ICrypto;
|
|
50
|
+
private tokenBindingKeyManager: ITokenBindingKeyManager;
|
|
40
51
|
private performanceClient: IPerformanceClient;
|
|
41
52
|
|
|
42
|
-
constructor(
|
|
53
|
+
constructor(
|
|
54
|
+
cryptoUtils: ICrypto,
|
|
55
|
+
tokenBindingKeyManager: ITokenBindingKeyManager,
|
|
56
|
+
performanceClient: IPerformanceClient
|
|
57
|
+
) {
|
|
43
58
|
this.cryptoUtils = cryptoUtils;
|
|
59
|
+
this.tokenBindingKeyManager = tokenBindingKeyManager;
|
|
44
60
|
this.performanceClient = performanceClient;
|
|
45
61
|
}
|
|
46
62
|
|
|
@@ -77,9 +93,12 @@ export class PopTokenGenerator {
|
|
|
77
93
|
* @returns
|
|
78
94
|
*/
|
|
79
95
|
async generateKid(request: SignedHttpRequestParameters): Promise<ReqCnf> {
|
|
80
|
-
const kidThumbprint =
|
|
81
|
-
|
|
82
|
-
|
|
96
|
+
const kidThumbprint =
|
|
97
|
+
await this.tokenBindingKeyManager.provisionTokenBindingKey({
|
|
98
|
+
correlationId: request.correlationId,
|
|
99
|
+
tokenBindingKeyType: SHR_TOKEN_BINDING_KEY_TYPE,
|
|
100
|
+
tokenBindingKeyAlgorithm: SHR_TOKEN_BINDING_KEY_ALGORITHM,
|
|
101
|
+
});
|
|
83
102
|
|
|
84
103
|
return {
|
|
85
104
|
kid: kidThumbprint,
|
|
@@ -128,22 +147,47 @@ export class PopTokenGenerator {
|
|
|
128
147
|
? new UrlString(resourceRequestUri, request.correlationId)
|
|
129
148
|
: undefined;
|
|
130
149
|
const resourceUrlComponents = resourceUrlString?.getUrlComponents();
|
|
131
|
-
|
|
150
|
+
const publicKeyJwk =
|
|
151
|
+
await this.tokenBindingKeyManager.getTokenBindingPublicKeyJwk(
|
|
152
|
+
keyId,
|
|
153
|
+
request.correlationId
|
|
154
|
+
);
|
|
155
|
+
const encodedKeyIdThumbprint = this.cryptoUtils.base64UrlEncode(
|
|
156
|
+
JSON.stringify({ kid: keyId })
|
|
157
|
+
);
|
|
158
|
+
const shrAlgorithm =
|
|
159
|
+
shrOptions?.header?.alg ||
|
|
160
|
+
publicKeyJwk.alg ||
|
|
161
|
+
SHR_TOKEN_BINDING_KEY_ALGORITHM;
|
|
162
|
+
const shrHeader = JoseHeader.getShrHeader(
|
|
132
163
|
{
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
u: resourceUrlComponents?.HostNameAndPort,
|
|
137
|
-
nonce: shrNonce || this.cryptoUtils.createNewGuid(),
|
|
138
|
-
p: resourceUrlComponents?.AbsolutePath,
|
|
139
|
-
q: resourceUrlComponents?.QueryString
|
|
140
|
-
? [[], resourceUrlComponents.QueryString]
|
|
141
|
-
: undefined,
|
|
142
|
-
client_claims: shrClaims || undefined,
|
|
143
|
-
...claims,
|
|
164
|
+
...shrOptions?.header,
|
|
165
|
+
alg: shrAlgorithm,
|
|
166
|
+
kid: encodedKeyIdThumbprint,
|
|
144
167
|
},
|
|
168
|
+
request.correlationId
|
|
169
|
+
);
|
|
170
|
+
const shrPayload: SignedHttpRequest = {
|
|
171
|
+
at: payload,
|
|
172
|
+
ts: TimeUtils.nowSeconds(),
|
|
173
|
+
m: resourceRequestMethod?.toUpperCase(),
|
|
174
|
+
u: resourceUrlComponents?.HostNameAndPort,
|
|
175
|
+
nonce: shrNonce || this.cryptoUtils.createNewGuid(),
|
|
176
|
+
p: resourceUrlComponents?.AbsolutePath,
|
|
177
|
+
q: resourceUrlComponents?.QueryString
|
|
178
|
+
? [[], resourceUrlComponents.QueryString]
|
|
179
|
+
: undefined,
|
|
180
|
+
client_claims: shrClaims || undefined,
|
|
181
|
+
...claims,
|
|
182
|
+
cnf: {
|
|
183
|
+
jwk: publicKeyJwk,
|
|
184
|
+
},
|
|
185
|
+
};
|
|
186
|
+
|
|
187
|
+
return this.cryptoUtils.signTokenBindingJwt(
|
|
188
|
+
shrHeader,
|
|
189
|
+
shrPayload,
|
|
145
190
|
keyId,
|
|
146
|
-
shrOptions,
|
|
147
191
|
request.correlationId
|
|
148
192
|
);
|
|
149
193
|
}
|
|
@@ -19,6 +19,8 @@ export const invalidAuthorityMetadata = "invalid_authority_metadata";
|
|
|
19
19
|
export const untrustedAuthority = "untrusted_authority";
|
|
20
20
|
export const missingSshJwk = "missing_ssh_jwk";
|
|
21
21
|
export const missingSshKid = "missing_ssh_kid";
|
|
22
|
+
export const unsupportedAuthenticationScheme =
|
|
23
|
+
"unsupported_authentication_scheme";
|
|
22
24
|
export const missingNonceAuthenticationHeader =
|
|
23
25
|
"missing_nonce_authentication_header";
|
|
24
26
|
export const invalidAuthenticationHeader = "invalid_authentication_header";
|
package/src/exports-common.ts
CHANGED
|
@@ -104,7 +104,13 @@ export {
|
|
|
104
104
|
PkceCodes,
|
|
105
105
|
DEFAULT_CRYPTO_IMPLEMENTATION,
|
|
106
106
|
SignedHttpRequestParameters,
|
|
107
|
+
JsonWebTokenAlgorithms,
|
|
107
108
|
} from "./crypto/ICrypto.js";
|
|
109
|
+
export {
|
|
110
|
+
ITokenBindingKeyManager,
|
|
111
|
+
DEFAULT_TOKEN_BINDING_KEY_MANAGER,
|
|
112
|
+
TokenBindingKeyProvisioningParameters,
|
|
113
|
+
} from "./crypto/ITokenBindingKeyManager.js";
|
|
108
114
|
|
|
109
115
|
export * as AuthorizeProtocol from "./protocol/Authorize.js";
|
|
110
116
|
export * as TokenProtocol from "./protocol/Token.js";
|
|
@@ -127,6 +133,7 @@ export { AuthorizationCodePayload } from "./response/AuthorizationCodePayload.js
|
|
|
127
133
|
export { AuthorizeResponse } from "./response/AuthorizeResponse.js";
|
|
128
134
|
export { ServerAuthorizationTokenResponse } from "./response/ServerAuthorizationTokenResponse.js";
|
|
129
135
|
export {
|
|
136
|
+
GenerateAuthenticationResultOptions,
|
|
130
137
|
ResponseHandler,
|
|
131
138
|
buildAccountToCache,
|
|
132
139
|
} from "./response/ResponseHandler.js";
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
import { ShrOptions } from "../crypto/SignedHttpRequest.js";
|
|
7
7
|
import { BaseAuthRequest } from "../request/BaseAuthRequest.js";
|
|
8
8
|
import { AuthenticationScheme } from "../utils/Constants.js";
|
|
9
|
+
import * as CacheHelpers from "../cache/utils/CacheHelpers.js";
|
|
9
10
|
|
|
10
11
|
/**
|
|
11
12
|
* Type representing a unique request thumbprint.
|
|
@@ -24,6 +25,7 @@ export type RequestThumbprint = {
|
|
|
24
25
|
shrOptions?: ShrOptions;
|
|
25
26
|
embeddedClientId?: string;
|
|
26
27
|
resource?: string;
|
|
28
|
+
attributeTokens?: string;
|
|
27
29
|
};
|
|
28
30
|
|
|
29
31
|
export function getRequestThumbprint(
|
|
@@ -45,5 +47,8 @@ export function getRequestThumbprint(
|
|
|
45
47
|
embeddedClientId:
|
|
46
48
|
request.embeddedClientId || request.extraParameters?.clientId,
|
|
47
49
|
resource: request.resource,
|
|
50
|
+
attributeTokens: CacheHelpers.serializeAttributeTokens(
|
|
51
|
+
request.attributeTokens
|
|
52
|
+
),
|
|
48
53
|
};
|
|
49
54
|
}
|
package/src/packageMetadata.ts
CHANGED
|
@@ -111,6 +111,10 @@ export type BaseAuthRequest = {
|
|
|
111
111
|
* String to string map of custom parameters added to outgoing token service requests.
|
|
112
112
|
*/
|
|
113
113
|
extraParameters?: StringDict;
|
|
114
|
+
/**
|
|
115
|
+
* Optional caller-provided attribute tokens (opaque assertions from external Attribute Authorities).
|
|
116
|
+
*/
|
|
117
|
+
attributeTokens?: Array<string>;
|
|
114
118
|
};
|
|
115
119
|
|
|
116
120
|
/**
|