@azure/msal-node 2.1.0 → 2.2.0-alpha.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/cache/ITokenCache.d.ts +15 -15
- package/dist/cache/NodeStorage.cjs +401 -401
- package/dist/cache/NodeStorage.d.ts +182 -182
- package/dist/cache/NodeStorage.mjs +401 -401
- package/dist/cache/TokenCache.cjs +265 -265
- package/dist/cache/TokenCache.d.ts +90 -90
- package/dist/cache/TokenCache.mjs +265 -265
- package/dist/cache/distributed/DistributedCachePlugin.cjs +26 -26
- package/dist/cache/distributed/DistributedCachePlugin.d.ts +10 -10
- package/dist/cache/distributed/DistributedCachePlugin.mjs +26 -26
- package/dist/cache/distributed/ICacheClient.d.ts +17 -17
- package/dist/cache/distributed/IPartitionManager.d.ts +28 -28
- package/dist/cache/serializer/Deserializer.cjs +173 -173
- package/dist/cache/serializer/Deserializer.d.ts +42 -42
- package/dist/cache/serializer/Deserializer.mjs +173 -173
- package/dist/cache/serializer/Serializer.cjs +134 -134
- package/dist/cache/serializer/Serializer.d.ts +39 -39
- package/dist/cache/serializer/Serializer.mjs +134 -134
- package/dist/cache/serializer/SerializerTypes.d.ts +101 -101
- package/dist/client/ClientApplication.cjs +333 -333
- package/dist/client/ClientApplication.cjs.map +1 -1
- package/dist/client/ClientApplication.d.ts +142 -142
- package/dist/client/ClientApplication.d.ts.map +1 -1
- package/dist/client/ClientApplication.mjs +334 -334
- package/dist/client/ClientApplication.mjs.map +1 -1
- package/dist/client/ClientAssertion.cjs +116 -116
- package/dist/client/ClientAssertion.cjs.map +1 -1
- package/dist/client/ClientAssertion.d.ts +46 -46
- package/dist/client/ClientAssertion.d.ts.map +1 -1
- package/dist/client/ClientAssertion.mjs +117 -117
- package/dist/client/ClientAssertion.mjs.map +1 -1
- package/dist/client/ClientCredentialClient.cjs +189 -190
- package/dist/client/ClientCredentialClient.cjs.map +1 -1
- package/dist/client/ClientCredentialClient.d.ts +33 -34
- package/dist/client/ClientCredentialClient.d.ts.map +1 -1
- package/dist/client/ClientCredentialClient.mjs +190 -191
- package/dist/client/ClientCredentialClient.mjs.map +1 -1
- package/dist/client/ConfidentialClientApplication.cjs +163 -163
- package/dist/client/ConfidentialClientApplication.cjs.map +1 -1
- package/dist/client/ConfidentialClientApplication.d.ts +58 -58
- package/dist/client/ConfidentialClientApplication.d.ts.map +1 -1
- package/dist/client/ConfidentialClientApplication.mjs +164 -164
- package/dist/client/ConfidentialClientApplication.mjs.map +1 -1
- package/dist/client/DeviceCodeClient.cjs +207 -207
- package/dist/client/DeviceCodeClient.cjs.map +1 -1
- package/dist/client/DeviceCodeClient.d.ts +53 -53
- package/dist/client/DeviceCodeClient.d.ts.map +1 -1
- package/dist/client/DeviceCodeClient.mjs +208 -208
- package/dist/client/DeviceCodeClient.mjs.map +1 -1
- package/dist/client/IConfidentialClientApplication.d.ts +39 -39
- package/dist/client/IPublicClientApplication.d.ts +42 -42
- package/dist/client/OnBehalfOfClient.cjs +202 -202
- package/dist/client/OnBehalfOfClient.cjs.map +1 -1
- package/dist/client/OnBehalfOfClient.d.ts +47 -47
- package/dist/client/OnBehalfOfClient.d.ts.map +1 -1
- package/dist/client/OnBehalfOfClient.mjs +203 -203
- package/dist/client/OnBehalfOfClient.mjs.map +1 -1
- package/dist/client/PublicClientApplication.cjs +229 -182
- package/dist/client/PublicClientApplication.cjs.map +1 -1
- package/dist/client/PublicClientApplication.d.ts +71 -65
- package/dist/client/PublicClientApplication.d.ts.map +1 -1
- package/dist/client/PublicClientApplication.mjs +231 -184
- package/dist/client/PublicClientApplication.mjs.map +1 -1
- package/dist/client/UsernamePasswordClient.cjs +95 -95
- package/dist/client/UsernamePasswordClient.d.ts +25 -25
- package/dist/client/UsernamePasswordClient.mjs +95 -95
- package/dist/config/Configuration.cjs +72 -72
- package/dist/config/Configuration.d.ts +107 -107
- package/dist/config/Configuration.mjs +72 -72
- package/dist/crypto/CryptoProvider.cjs +75 -75
- package/dist/crypto/CryptoProvider.d.ts +52 -52
- package/dist/crypto/CryptoProvider.mjs +75 -75
- package/dist/crypto/GuidGenerator.cjs +22 -22
- package/dist/crypto/GuidGenerator.d.ts +14 -14
- package/dist/crypto/GuidGenerator.mjs +22 -22
- package/dist/crypto/HashUtils.cjs +13 -13
- package/dist/crypto/HashUtils.d.ts +8 -8
- package/dist/crypto/HashUtils.mjs +13 -13
- package/dist/crypto/PkceGenerator.cjs +49 -49
- package/dist/crypto/PkceGenerator.d.ts +22 -22
- package/dist/crypto/PkceGenerator.mjs +49 -49
- package/dist/error/NodeAuthError.cjs +85 -85
- package/dist/error/NodeAuthError.d.ts +65 -65
- package/dist/error/NodeAuthError.mjs +85 -85
- package/dist/index.cjs +17 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +42 -42
- package/dist/index.d.ts.map +1 -1
- package/dist/index.mjs +2 -2
- package/dist/internals.cjs +8 -8
- package/dist/internals.d.ts +6 -6
- package/dist/internals.mjs +8 -8
- package/dist/network/HttpClient.cjs +276 -276
- package/dist/network/HttpClient.d.ts +25 -25
- package/dist/network/HttpClient.mjs +276 -276
- package/dist/network/ILoopbackClient.d.ts +10 -10
- package/dist/network/LoopbackClient.cjs +75 -84
- package/dist/network/LoopbackClient.cjs.map +1 -1
- package/dist/network/LoopbackClient.d.ts +21 -21
- package/dist/network/LoopbackClient.d.ts.map +1 -1
- package/dist/network/LoopbackClient.mjs +76 -85
- package/dist/network/LoopbackClient.mjs.map +1 -1
- package/dist/packageMetadata.cjs +3 -3
- package/dist/packageMetadata.d.ts +2 -2
- package/dist/packageMetadata.mjs +3 -3
- package/dist/request/AuthorizationCodeRequest.d.ts +21 -21
- package/dist/request/AuthorizationUrlRequest.d.ts +33 -33
- package/dist/request/ClientCredentialRequest.d.ts +14 -14
- package/dist/request/DeviceCodeRequest.d.ts +15 -15
- package/dist/request/InteractiveRequest.d.ts +22 -22
- package/dist/request/OnBehalfOfRequest.d.ts +14 -14
- package/dist/request/RefreshTokenRequest.d.ts +17 -17
- package/dist/request/SignOutRequest.d.ts +5 -5
- package/dist/request/SilentFlowRequest.d.ts +16 -16
- package/dist/request/UsernamePasswordRequest.d.ts +19 -19
- package/dist/utils/Constants.cjs +80 -80
- package/dist/utils/Constants.d.ts +86 -86
- package/dist/utils/Constants.mjs +80 -80
- package/dist/utils/EncodingUtils.cjs +44 -44
- package/dist/utils/EncodingUtils.d.ts +26 -26
- package/dist/utils/EncodingUtils.mjs +44 -44
- package/dist/utils/NetworkUtils.cjs +38 -38
- package/dist/utils/NetworkUtils.d.ts +5 -5
- package/dist/utils/NetworkUtils.mjs +38 -38
- package/package.json +2 -2
- package/src/client/ClientApplication.ts +3 -2
- package/src/client/ClientAssertion.ts +7 -2
- package/src/client/ClientCredentialClient.ts +32 -34
- package/src/client/ConfidentialClientApplication.ts +11 -4
- package/src/client/DeviceCodeClient.ts +16 -7
- package/src/client/OnBehalfOfClient.ts +11 -4
- package/src/client/PublicClientApplication.ts +69 -13
- package/src/index.ts +4 -0
- package/src/network/LoopbackClient.ts +17 -33
|
@@ -1,196 +1,195 @@
|
|
|
1
|
-
/*! @azure/msal-node v2.
|
|
1
|
+
/*! @azure/msal-node v2.2.0-alpha.0 2023-09-20 */
|
|
2
2
|
'use strict';
|
|
3
|
-
import { BaseClient, ScopeSet, CacheOutcome, TokenCacheContext, TimeUtils, ResponseHandler, Constants, CredentialType,
|
|
3
|
+
import { BaseClient, ScopeSet, CacheOutcome, TokenCacheContext, TimeUtils, ResponseHandler, Constants, CredentialType, createClientAuthError, ClientAuthErrorCodes, UrlString, RequestParameterBuilder, GrantType, StringUtils, AuthenticationScheme } from '@azure/msal-common';
|
|
4
4
|
|
|
5
|
-
/*
|
|
6
|
-
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
7
|
-
* Licensed under the MIT License.
|
|
8
|
-
*/
|
|
9
|
-
/**
|
|
10
|
-
* OAuth2.0 client credential grant
|
|
11
|
-
*/
|
|
12
|
-
class ClientCredentialClient extends BaseClient {
|
|
13
|
-
constructor(configuration, appTokenProvider) {
|
|
14
|
-
super(configuration);
|
|
15
|
-
this.appTokenProvider = appTokenProvider;
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* Public API to acquire a token with ClientCredential Flow for Confidential clients
|
|
19
|
-
* @param request
|
|
20
|
-
*/
|
|
21
|
-
async acquireToken(request) {
|
|
22
|
-
this.scopeSet = new ScopeSet(request.scopes || []);
|
|
23
|
-
if (request.skipCache) {
|
|
24
|
-
return await this.executeTokenRequest(request, this.authority);
|
|
25
|
-
}
|
|
26
|
-
const cachedAuthenticationResult = await this.getCachedAuthenticationResult(request);
|
|
27
|
-
if (cachedAuthenticationResult) {
|
|
28
|
-
// if the token is not expired but must be refreshed; get a new one in the background
|
|
29
|
-
if (
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
return
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
this.config.persistencePlugin
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
this.
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
*
|
|
110
|
-
* @param
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
let
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
const
|
|
135
|
-
const
|
|
136
|
-
const
|
|
137
|
-
const
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
serverTokenResponse = response.
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
responseHandler.
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
*
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
parameterBuilder.
|
|
166
|
-
parameterBuilder.
|
|
167
|
-
parameterBuilder.
|
|
168
|
-
parameterBuilder.
|
|
169
|
-
parameterBuilder.
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
parameterBuilder.
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
}
|
|
5
|
+
/*
|
|
6
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
7
|
+
* Licensed under the MIT License.
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* OAuth2.0 client credential grant
|
|
11
|
+
*/
|
|
12
|
+
class ClientCredentialClient extends BaseClient {
|
|
13
|
+
constructor(configuration, appTokenProvider) {
|
|
14
|
+
super(configuration);
|
|
15
|
+
this.appTokenProvider = appTokenProvider;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Public API to acquire a token with ClientCredential Flow for Confidential clients
|
|
19
|
+
* @param request
|
|
20
|
+
*/
|
|
21
|
+
async acquireToken(request) {
|
|
22
|
+
this.scopeSet = new ScopeSet(request.scopes || []);
|
|
23
|
+
if (request.skipCache) {
|
|
24
|
+
return await this.executeTokenRequest(request, this.authority);
|
|
25
|
+
}
|
|
26
|
+
const [cachedAuthenticationResult, lastCacheOutcome] = await this.getCachedAuthenticationResult(request);
|
|
27
|
+
if (cachedAuthenticationResult) {
|
|
28
|
+
// if the token is not expired but must be refreshed; get a new one in the background
|
|
29
|
+
if (lastCacheOutcome === CacheOutcome.PROACTIVELY_REFRESHED) {
|
|
30
|
+
this.logger.info("ClientCredentialClient:getCachedAuthenticationResult - Cached access token's refreshOn property has been exceeded'. It's not expired, but must be refreshed.");
|
|
31
|
+
// refresh the access token in the background
|
|
32
|
+
const refreshAccessToken = true;
|
|
33
|
+
await this.executeTokenRequest(request, this.authority, refreshAccessToken);
|
|
34
|
+
}
|
|
35
|
+
// return the cached token
|
|
36
|
+
return cachedAuthenticationResult;
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
return await this.executeTokenRequest(request, this.authority);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* looks up cache if the tokens are cached already
|
|
44
|
+
*/
|
|
45
|
+
async getCachedAuthenticationResult(request) {
|
|
46
|
+
let lastCacheOutcome = CacheOutcome.NOT_APPLICABLE;
|
|
47
|
+
// read the user-supplied cache into memory, if applicable
|
|
48
|
+
let cacheContext;
|
|
49
|
+
if (this.config.serializableCache && this.config.persistencePlugin) {
|
|
50
|
+
cacheContext = new TokenCacheContext(this.config.serializableCache, false);
|
|
51
|
+
await this.config.persistencePlugin.beforeCacheAccess(cacheContext);
|
|
52
|
+
}
|
|
53
|
+
const cachedAccessToken = this.readAccessTokenFromCache();
|
|
54
|
+
if (this.config.serializableCache &&
|
|
55
|
+
this.config.persistencePlugin &&
|
|
56
|
+
cacheContext) {
|
|
57
|
+
await this.config.persistencePlugin.afterCacheAccess(cacheContext);
|
|
58
|
+
}
|
|
59
|
+
// must refresh due to non-existent access_token
|
|
60
|
+
if (!cachedAccessToken) {
|
|
61
|
+
this.serverTelemetryManager?.setCacheOutcome(CacheOutcome.NO_CACHED_ACCESS_TOKEN);
|
|
62
|
+
return [null, CacheOutcome.NO_CACHED_ACCESS_TOKEN];
|
|
63
|
+
}
|
|
64
|
+
// must refresh due to the expires_in value
|
|
65
|
+
if (TimeUtils.isTokenExpired(cachedAccessToken.expiresOn, this.config.systemOptions.tokenRenewalOffsetSeconds)) {
|
|
66
|
+
this.serverTelemetryManager?.setCacheOutcome(CacheOutcome.CACHED_ACCESS_TOKEN_EXPIRED);
|
|
67
|
+
return [null, CacheOutcome.CACHED_ACCESS_TOKEN_EXPIRED];
|
|
68
|
+
}
|
|
69
|
+
// must refresh (in the background) due to the refresh_in value
|
|
70
|
+
if (cachedAccessToken.refreshOn &&
|
|
71
|
+
TimeUtils.isTokenExpired(cachedAccessToken.refreshOn.toString(), 0)) {
|
|
72
|
+
lastCacheOutcome = CacheOutcome.PROACTIVELY_REFRESHED;
|
|
73
|
+
this.serverTelemetryManager?.setCacheOutcome(CacheOutcome.PROACTIVELY_REFRESHED);
|
|
74
|
+
}
|
|
75
|
+
return [
|
|
76
|
+
await ResponseHandler.generateAuthenticationResult(this.cryptoUtils, this.authority, {
|
|
77
|
+
account: null,
|
|
78
|
+
idToken: null,
|
|
79
|
+
accessToken: cachedAccessToken,
|
|
80
|
+
refreshToken: null,
|
|
81
|
+
appMetadata: null,
|
|
82
|
+
}, true, request),
|
|
83
|
+
lastCacheOutcome,
|
|
84
|
+
];
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Reads access token from the cache
|
|
88
|
+
*/
|
|
89
|
+
readAccessTokenFromCache() {
|
|
90
|
+
const accessTokenFilter = {
|
|
91
|
+
homeAccountId: Constants.EMPTY_STRING,
|
|
92
|
+
environment: this.authority.canonicalAuthorityUrlComponents.HostNameAndPort,
|
|
93
|
+
credentialType: CredentialType.ACCESS_TOKEN,
|
|
94
|
+
clientId: this.config.authOptions.clientId,
|
|
95
|
+
realm: this.authority.tenant,
|
|
96
|
+
target: ScopeSet.createSearchScopes(this.scopeSet.asArray()),
|
|
97
|
+
};
|
|
98
|
+
const accessTokens = this.cacheManager.getAccessTokensByFilter(accessTokenFilter);
|
|
99
|
+
if (accessTokens.length < 1) {
|
|
100
|
+
return null;
|
|
101
|
+
}
|
|
102
|
+
else if (accessTokens.length > 1) {
|
|
103
|
+
throw createClientAuthError(ClientAuthErrorCodes.multipleMatchingTokens);
|
|
104
|
+
}
|
|
105
|
+
return accessTokens[0];
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Makes a network call to request the token from the service
|
|
109
|
+
* @param request
|
|
110
|
+
* @param authority
|
|
111
|
+
*/
|
|
112
|
+
async executeTokenRequest(request, authority, refreshAccessToken) {
|
|
113
|
+
let serverTokenResponse;
|
|
114
|
+
let reqTimestamp;
|
|
115
|
+
if (this.appTokenProvider) {
|
|
116
|
+
this.logger.info("Using appTokenProvider extensibility.");
|
|
117
|
+
const appTokenPropviderParameters = {
|
|
118
|
+
correlationId: request.correlationId,
|
|
119
|
+
tenantId: this.config.authOptions.authority.tenant,
|
|
120
|
+
scopes: request.scopes,
|
|
121
|
+
claims: request.claims,
|
|
122
|
+
};
|
|
123
|
+
reqTimestamp = TimeUtils.nowSeconds();
|
|
124
|
+
const appTokenProviderResult = await this.appTokenProvider(appTokenPropviderParameters);
|
|
125
|
+
serverTokenResponse = {
|
|
126
|
+
access_token: appTokenProviderResult.accessToken,
|
|
127
|
+
expires_in: appTokenProviderResult.expiresInSeconds,
|
|
128
|
+
refresh_in: appTokenProviderResult.refreshInSeconds,
|
|
129
|
+
token_type: AuthenticationScheme.BEARER,
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
else {
|
|
133
|
+
const queryParametersString = this.createTokenQueryParameters(request);
|
|
134
|
+
const endpoint = UrlString.appendQueryString(authority.tokenEndpoint, queryParametersString);
|
|
135
|
+
const requestBody = this.createTokenRequestBody(request);
|
|
136
|
+
const headers = this.createTokenRequestHeaders();
|
|
137
|
+
const thumbprint = {
|
|
138
|
+
clientId: this.config.authOptions.clientId,
|
|
139
|
+
authority: request.authority,
|
|
140
|
+
scopes: request.scopes,
|
|
141
|
+
claims: request.claims,
|
|
142
|
+
authenticationScheme: request.authenticationScheme,
|
|
143
|
+
resourceRequestMethod: request.resourceRequestMethod,
|
|
144
|
+
resourceRequestUri: request.resourceRequestUri,
|
|
145
|
+
shrClaims: request.shrClaims,
|
|
146
|
+
sshKid: request.sshKid,
|
|
147
|
+
};
|
|
148
|
+
reqTimestamp = TimeUtils.nowSeconds();
|
|
149
|
+
const response = await this.executePostToTokenEndpoint(endpoint, requestBody, headers, thumbprint, request.correlationId);
|
|
150
|
+
serverTokenResponse = response.body;
|
|
151
|
+
serverTokenResponse.status = response.status;
|
|
152
|
+
}
|
|
153
|
+
const responseHandler = new ResponseHandler(this.config.authOptions.clientId, this.cacheManager, this.cryptoUtils, this.logger, this.config.serializableCache, this.config.persistencePlugin);
|
|
154
|
+
responseHandler.validateTokenResponse(serverTokenResponse, refreshAccessToken);
|
|
155
|
+
const tokenResponse = await responseHandler.handleServerTokenResponse(serverTokenResponse, this.authority, reqTimestamp, request);
|
|
156
|
+
return tokenResponse;
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* generate the request to the server in the acceptable format
|
|
160
|
+
* @param request
|
|
161
|
+
*/
|
|
162
|
+
createTokenRequestBody(request) {
|
|
163
|
+
const parameterBuilder = new RequestParameterBuilder();
|
|
164
|
+
parameterBuilder.addClientId(this.config.authOptions.clientId);
|
|
165
|
+
parameterBuilder.addScopes(request.scopes, false);
|
|
166
|
+
parameterBuilder.addGrantType(GrantType.CLIENT_CREDENTIALS_GRANT);
|
|
167
|
+
parameterBuilder.addLibraryInfo(this.config.libraryInfo);
|
|
168
|
+
parameterBuilder.addApplicationTelemetry(this.config.telemetry.application);
|
|
169
|
+
parameterBuilder.addThrottling();
|
|
170
|
+
if (this.serverTelemetryManager) {
|
|
171
|
+
parameterBuilder.addServerTelemetry(this.serverTelemetryManager);
|
|
172
|
+
}
|
|
173
|
+
const correlationId = request.correlationId ||
|
|
174
|
+
this.config.cryptoInterface.createNewGuid();
|
|
175
|
+
parameterBuilder.addCorrelationId(correlationId);
|
|
176
|
+
if (this.config.clientCredentials.clientSecret) {
|
|
177
|
+
parameterBuilder.addClientSecret(this.config.clientCredentials.clientSecret);
|
|
178
|
+
}
|
|
179
|
+
// Use clientAssertion from request, fallback to client assertion in base configuration
|
|
180
|
+
const clientAssertion = request.clientAssertion ||
|
|
181
|
+
this.config.clientCredentials.clientAssertion;
|
|
182
|
+
if (clientAssertion) {
|
|
183
|
+
parameterBuilder.addClientAssertion(clientAssertion.assertion);
|
|
184
|
+
parameterBuilder.addClientAssertionType(clientAssertion.assertionType);
|
|
185
|
+
}
|
|
186
|
+
if (!StringUtils.isEmptyObj(request.claims) ||
|
|
187
|
+
(this.config.authOptions.clientCapabilities &&
|
|
188
|
+
this.config.authOptions.clientCapabilities.length > 0)) {
|
|
189
|
+
parameterBuilder.addClaims(request.claims, this.config.authOptions.clientCapabilities);
|
|
190
|
+
}
|
|
191
|
+
return parameterBuilder.createQueryString();
|
|
192
|
+
}
|
|
194
193
|
}
|
|
195
194
|
|
|
196
195
|
export { ClientCredentialClient };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ClientCredentialClient.mjs","sources":["../../src/client/ClientCredentialClient.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;AAKA;
|
|
1
|
+
{"version":3,"file":"ClientCredentialClient.mjs","sources":["../../src/client/ClientCredentialClient.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;AAKA;AA2BA;;AAEG;;AAGC;AAGI;AAOJ,MAAA,sBAAA,SAAA,UAAA,CAAA;;;AAGG,QAAA,IAAA,CAAA,gBAAA,GAAA,gBAAA,CAAA;KACsB;AAmCzB;;AAEG;;AA4EH,IAAA,MAAA,YAAA,CAAA,OAAA,EAAA;;AAEG,QAAA,IAAA,OAAA,CAAA,SAAA,EAAA;AACH,YAAQ,OAAwB,MAAA,IAAA,CAAA,mBAAA,CAAA,OAAA,EAAA,IAAA,CAAA,SAAA,CAAA,CAAA;AAuBhC,SAAA;;;;AAIG,YAAA,IAAA,gBAAA,KAAA,YAAA,CAAA,qBAAA,EAAA;gBAC8B,IAAA,CAAA,MAAA,CAAA,IAAA,CAAA,8JAAA,CAAA,CAAA;AAwFjC;;;AAGG,aAAA;AACH;AA0DH,YAAA,OAAA,0BAAA,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|