@azure/msal-common 14.0.0-alpha.2 → 14.0.0-beta.1
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/AuthToken.js +1 -1
- package/dist/account/CcsCredential.d.ts +5 -4
- package/dist/account/CcsCredential.d.ts.map +1 -1
- package/dist/account/CcsCredential.js +5 -6
- package/dist/account/CcsCredential.js.map +1 -1
- package/dist/account/ClientInfo.js +1 -1
- package/dist/authority/Authority.d.ts +1 -0
- package/dist/authority/Authority.d.ts.map +1 -1
- package/dist/authority/Authority.js +15 -27
- package/dist/authority/Authority.js.map +1 -1
- package/dist/authority/AuthorityFactory.js +1 -1
- package/dist/authority/AuthorityMetadata.js +1 -1
- package/dist/authority/AuthorityOptions.d.ts +9 -8
- package/dist/authority/AuthorityOptions.d.ts.map +1 -1
- package/dist/authority/AuthorityOptions.js +9 -10
- package/dist/authority/AuthorityOptions.js.map +1 -1
- package/dist/authority/AuthorityType.d.ts +7 -6
- package/dist/authority/AuthorityType.d.ts.map +1 -1
- package/dist/authority/AuthorityType.js +7 -8
- package/dist/authority/AuthorityType.js.map +1 -1
- package/dist/authority/CloudInstanceDiscoveryErrorResponse.js +1 -1
- package/dist/authority/CloudInstanceDiscoveryResponse.js +1 -1
- package/dist/authority/OpenIdConfigResponse.js +1 -1
- package/dist/authority/ProtocolMode.d.ts +5 -4
- package/dist/authority/ProtocolMode.d.ts.map +1 -1
- package/dist/authority/ProtocolMode.js +5 -6
- package/dist/authority/ProtocolMode.js.map +1 -1
- package/dist/authority/RegionDiscovery.js +1 -1
- package/dist/cache/CacheManager.js +1 -1
- package/dist/cache/entities/AccessTokenEntity.js +1 -1
- package/dist/cache/entities/AccountEntity.js +1 -1
- package/dist/cache/entities/AppMetadataEntity.js +1 -1
- package/dist/cache/entities/AuthorityMetadataEntity.js +1 -1
- package/dist/cache/entities/CacheRecord.js +1 -1
- package/dist/cache/entities/CredentialEntity.js +1 -1
- package/dist/cache/entities/IdTokenEntity.js +1 -1
- package/dist/cache/entities/RefreshTokenEntity.js +1 -1
- package/dist/cache/entities/ServerTelemetryEntity.js +1 -1
- package/dist/cache/entities/ThrottlingEntity.js +1 -1
- package/dist/cache/persistence/TokenCacheContext.js +1 -1
- package/dist/client/AuthorizationCodeClient.js +1 -1
- package/dist/client/BaseClient.js +1 -1
- package/dist/client/RefreshTokenClient.js +1 -1
- package/dist/client/SilentFlowClient.d.ts.map +1 -1
- package/dist/client/SilentFlowClient.js +8 -1
- package/dist/client/SilentFlowClient.js.map +1 -1
- package/dist/config/ClientConfiguration.d.ts +11 -1
- package/dist/config/ClientConfiguration.d.ts.map +1 -1
- package/dist/config/ClientConfiguration.js +6 -2
- package/dist/config/ClientConfiguration.js.map +1 -1
- package/dist/crypto/ICrypto.js +1 -1
- package/dist/crypto/JoseHeader.js +1 -1
- package/dist/crypto/PopTokenGenerator.d.ts +5 -4
- package/dist/crypto/PopTokenGenerator.d.ts.map +1 -1
- package/dist/crypto/PopTokenGenerator.js +5 -6
- package/dist/crypto/PopTokenGenerator.js.map +1 -1
- package/dist/error/AuthError.js +1 -1
- package/dist/error/ClientAuthError.js +1 -1
- package/dist/error/ClientConfigurationError.d.ts +8 -0
- package/dist/error/ClientConfigurationError.d.ts.map +1 -1
- package/dist/error/ClientConfigurationError.js +12 -2
- package/dist/error/ClientConfigurationError.js.map +1 -1
- package/dist/error/InteractionRequiredAuthError.js +1 -1
- package/dist/error/JoseHeaderError.js +1 -1
- package/dist/error/ServerError.js +1 -1
- package/dist/index.cjs.js +548 -571
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/logger/Logger.js +1 -1
- package/dist/network/INetworkModule.js +1 -1
- package/dist/network/NetworkManager.js +1 -1
- package/dist/network/ThrottlingUtils.js +1 -1
- package/dist/packageMetadata.d.ts +1 -1
- package/dist/packageMetadata.d.ts.map +1 -1
- package/dist/packageMetadata.js +2 -2
- package/dist/request/AuthenticationHeaderParser.js +1 -1
- package/dist/request/RequestParameterBuilder.js +1 -1
- package/dist/request/RequestValidator.js +2 -3
- package/dist/request/RequestValidator.js.map +1 -1
- package/dist/request/ScopeSet.js +1 -1
- package/dist/response/ResponseHandler.js +1 -1
- package/dist/telemetry/performance/PerformanceClient.js +1 -1
- package/dist/telemetry/performance/PerformanceEvent.d.ts +73 -71
- package/dist/telemetry/performance/PerformanceEvent.d.ts.map +1 -1
- package/dist/telemetry/performance/PerformanceEvent.js +72 -74
- package/dist/telemetry/performance/PerformanceEvent.js.map +1 -1
- package/dist/telemetry/performance/StubPerformanceClient.d.ts +3 -7
- package/dist/telemetry/performance/StubPerformanceClient.d.ts.map +1 -1
- package/dist/telemetry/performance/StubPerformanceClient.js +7 -21
- package/dist/telemetry/performance/StubPerformanceClient.js.map +1 -1
- package/dist/telemetry/server/ServerTelemetryManager.js +1 -1
- package/dist/url/UrlString.js +1 -1
- package/dist/utils/Constants.d.ts +193 -179
- package/dist/utils/Constants.d.ts.map +1 -1
- package/dist/utils/Constants.js +174 -194
- package/dist/utils/Constants.js.map +1 -1
- package/dist/utils/ProtocolUtils.js +1 -1
- package/dist/utils/StringUtils.js +1 -1
- package/dist/utils/TimeUtils.js +1 -1
- package/package.json +14 -7
package/dist/index.cjs.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @azure/msal-common v14.0.0-
|
|
1
|
+
/*! @azure/msal-common v14.0.0-beta.1 2023-07-06 */
|
|
2
2
|
'use strict';
|
|
3
3
|
'use strict';
|
|
4
4
|
|
|
@@ -74,100 +74,95 @@ const OIDC_SCOPES = [...OIDC_DEFAULT_SCOPES, Constants.EMAIL_SCOPE];
|
|
|
74
74
|
/**
|
|
75
75
|
* Request header names
|
|
76
76
|
*/
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
})(exports.HeaderNames || (exports.HeaderNames = {}));
|
|
77
|
+
const HeaderNames = {
|
|
78
|
+
CONTENT_TYPE: "Content-Type",
|
|
79
|
+
RETRY_AFTER: "Retry-After",
|
|
80
|
+
CCS_HEADER: "X-AnchorMailbox",
|
|
81
|
+
WWWAuthenticate: "WWW-Authenticate",
|
|
82
|
+
AuthenticationInfo: "Authentication-Info",
|
|
83
|
+
X_MS_REQUEST_ID: "x-ms-request-id",
|
|
84
|
+
X_MS_HTTP_VERSION: "x-ms-httpver",
|
|
85
|
+
};
|
|
87
86
|
/**
|
|
88
87
|
* Persistent cache keys MSAL which stay while user is logged in.
|
|
89
88
|
*/
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
})(exports.PersistentCacheKeys || (exports.PersistentCacheKeys = {}));
|
|
89
|
+
const PersistentCacheKeys = {
|
|
90
|
+
ID_TOKEN: "idtoken",
|
|
91
|
+
CLIENT_INFO: "client.info",
|
|
92
|
+
ADAL_ID_TOKEN: "adal.idtoken",
|
|
93
|
+
ERROR: "error",
|
|
94
|
+
ERROR_DESC: "error.description",
|
|
95
|
+
ACTIVE_ACCOUNT: "active-account",
|
|
96
|
+
ACTIVE_ACCOUNT_FILTERS: "active-account-filters", // new cache entry for active_account for a more robust version for browser
|
|
97
|
+
};
|
|
100
98
|
/**
|
|
101
99
|
* String constants related to AAD Authority
|
|
102
100
|
*/
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
})(exports.AADAuthorityConstants || (exports.AADAuthorityConstants = {}));
|
|
101
|
+
const AADAuthorityConstants = {
|
|
102
|
+
COMMON: "common",
|
|
103
|
+
ORGANIZATIONS: "organizations",
|
|
104
|
+
CONSUMERS: "consumers",
|
|
105
|
+
};
|
|
109
106
|
/**
|
|
110
107
|
* Keys in the hashParams sent by AAD Server
|
|
111
108
|
*/
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
})(exports.AADServerParamKeys || (exports.AADServerParamKeys = {}));
|
|
109
|
+
const AADServerParamKeys = {
|
|
110
|
+
CLIENT_ID: "client_id",
|
|
111
|
+
REDIRECT_URI: "redirect_uri",
|
|
112
|
+
RESPONSE_TYPE: "response_type",
|
|
113
|
+
RESPONSE_MODE: "response_mode",
|
|
114
|
+
GRANT_TYPE: "grant_type",
|
|
115
|
+
CLAIMS: "claims",
|
|
116
|
+
SCOPE: "scope",
|
|
117
|
+
ERROR: "error",
|
|
118
|
+
ERROR_DESCRIPTION: "error_description",
|
|
119
|
+
ACCESS_TOKEN: "access_token",
|
|
120
|
+
ID_TOKEN: "id_token",
|
|
121
|
+
REFRESH_TOKEN: "refresh_token",
|
|
122
|
+
EXPIRES_IN: "expires_in",
|
|
123
|
+
STATE: "state",
|
|
124
|
+
NONCE: "nonce",
|
|
125
|
+
PROMPT: "prompt",
|
|
126
|
+
SESSION_STATE: "session_state",
|
|
127
|
+
CLIENT_INFO: "client_info",
|
|
128
|
+
CODE: "code",
|
|
129
|
+
CODE_CHALLENGE: "code_challenge",
|
|
130
|
+
CODE_CHALLENGE_METHOD: "code_challenge_method",
|
|
131
|
+
CODE_VERIFIER: "code_verifier",
|
|
132
|
+
CLIENT_REQUEST_ID: "client-request-id",
|
|
133
|
+
X_CLIENT_SKU: "x-client-SKU",
|
|
134
|
+
X_CLIENT_VER: "x-client-VER",
|
|
135
|
+
X_CLIENT_OS: "x-client-OS",
|
|
136
|
+
X_CLIENT_CPU: "x-client-CPU",
|
|
137
|
+
X_CLIENT_CURR_TELEM: "x-client-current-telemetry",
|
|
138
|
+
X_CLIENT_LAST_TELEM: "x-client-last-telemetry",
|
|
139
|
+
X_MS_LIB_CAPABILITY: "x-ms-lib-capability",
|
|
140
|
+
X_APP_NAME: "x-app-name",
|
|
141
|
+
X_APP_VER: "x-app-ver",
|
|
142
|
+
POST_LOGOUT_URI: "post_logout_redirect_uri",
|
|
143
|
+
ID_TOKEN_HINT: "id_token_hint",
|
|
144
|
+
DEVICE_CODE: "device_code",
|
|
145
|
+
CLIENT_SECRET: "client_secret",
|
|
146
|
+
CLIENT_ASSERTION: "client_assertion",
|
|
147
|
+
CLIENT_ASSERTION_TYPE: "client_assertion_type",
|
|
148
|
+
TOKEN_TYPE: "token_type",
|
|
149
|
+
REQ_CNF: "req_cnf",
|
|
150
|
+
OBO_ASSERTION: "assertion",
|
|
151
|
+
REQUESTED_TOKEN_USE: "requested_token_use",
|
|
152
|
+
ON_BEHALF_OF: "on_behalf_of",
|
|
153
|
+
FOCI: "foci",
|
|
154
|
+
CCS_HEADER: "X-AnchorMailbox",
|
|
155
|
+
RETURN_SPA_CODE: "return_spa_code",
|
|
156
|
+
NATIVE_BROKER: "nativebroker",
|
|
157
|
+
LOGOUT_HINT: "logout_hint",
|
|
158
|
+
};
|
|
163
159
|
/**
|
|
164
160
|
* Claims request keys
|
|
165
161
|
*/
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
})(exports.ClaimsRequestKeys || (exports.ClaimsRequestKeys = {}));
|
|
162
|
+
const ClaimsRequestKeys = {
|
|
163
|
+
ACCESS_TOKEN: "access_token",
|
|
164
|
+
XMS_CC: "xms_cc",
|
|
165
|
+
};
|
|
171
166
|
/**
|
|
172
167
|
* we considered making this "enum" in the request instead of string, however it looks like the allowed list of
|
|
173
168
|
* prompt values kept changing over past couple of years. There are some undocumented prompt values for some
|
|
@@ -184,18 +179,17 @@ const PromptValue = {
|
|
|
184
179
|
/**
|
|
185
180
|
* SSO Types - generated to populate hints
|
|
186
181
|
*/
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
})(exports.SSOTypes || (exports.SSOTypes = {}));
|
|
182
|
+
const SSOTypes = {
|
|
183
|
+
ACCOUNT: "account",
|
|
184
|
+
SID: "sid",
|
|
185
|
+
LOGIN_HINT: "login_hint",
|
|
186
|
+
ID_TOKEN: "id_token",
|
|
187
|
+
DOMAIN_HINT: "domain_hint",
|
|
188
|
+
ORGANIZATIONS: "organizations",
|
|
189
|
+
CONSUMERS: "consumers",
|
|
190
|
+
ACCOUNT_ID: "accountIdentifier",
|
|
191
|
+
HOMEACCOUNT_ID: "homeAccountIdentifier",
|
|
192
|
+
};
|
|
199
193
|
/**
|
|
200
194
|
* allowed values for codeVerifier
|
|
201
195
|
*/
|
|
@@ -203,80 +197,65 @@ const CodeChallengeMethodValues = {
|
|
|
203
197
|
PLAIN: "plain",
|
|
204
198
|
S256: "S256",
|
|
205
199
|
};
|
|
206
|
-
/**
|
|
207
|
-
* The method used to encode the code verifier for the code challenge parameter. can be one
|
|
208
|
-
* of plain or s256. if excluded, code challenge is assumed to be plaintext. for more
|
|
209
|
-
* information, see the pkce rcf: https://tools.ietf.org/html/rfc7636
|
|
210
|
-
*/
|
|
211
|
-
[
|
|
212
|
-
CodeChallengeMethodValues.PLAIN,
|
|
213
|
-
CodeChallengeMethodValues.S256,
|
|
214
|
-
];
|
|
215
200
|
/**
|
|
216
201
|
* allowed values for response_mode
|
|
217
202
|
*/
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
})(exports.ResponseMode || (exports.ResponseMode = {}));
|
|
203
|
+
const ResponseMode = {
|
|
204
|
+
QUERY: "query",
|
|
205
|
+
FRAGMENT: "fragment",
|
|
206
|
+
FORM_POST: "form_post",
|
|
207
|
+
};
|
|
224
208
|
/**
|
|
225
209
|
* allowed grant_type
|
|
226
210
|
*/
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
})(exports.GrantType || (exports.GrantType = {}));
|
|
211
|
+
const GrantType = {
|
|
212
|
+
IMPLICIT_GRANT: "implicit",
|
|
213
|
+
AUTHORIZATION_CODE_GRANT: "authorization_code",
|
|
214
|
+
CLIENT_CREDENTIALS_GRANT: "client_credentials",
|
|
215
|
+
RESOURCE_OWNER_PASSWORD_GRANT: "password",
|
|
216
|
+
REFRESH_TOKEN_GRANT: "refresh_token",
|
|
217
|
+
DEVICE_CODE_GRANT: "device_code",
|
|
218
|
+
JWT_BEARER: "urn:ietf:params:oauth:grant-type:jwt-bearer",
|
|
219
|
+
};
|
|
237
220
|
/**
|
|
238
221
|
* Account types in Cache
|
|
239
222
|
*/
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
})(exports.CacheAccountType || (exports.CacheAccountType = {}));
|
|
223
|
+
const CacheAccountType = {
|
|
224
|
+
MSSTS_ACCOUNT_TYPE: "MSSTS",
|
|
225
|
+
ADFS_ACCOUNT_TYPE: "ADFS",
|
|
226
|
+
MSAV1_ACCOUNT_TYPE: "MSA",
|
|
227
|
+
GENERIC_ACCOUNT_TYPE: "Generic", // NTLM, Kerberos, FBA, Basic etc
|
|
228
|
+
};
|
|
247
229
|
/**
|
|
248
230
|
* Separators used in cache
|
|
249
231
|
*/
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
})(Separators || (Separators = {}));
|
|
232
|
+
const Separators = {
|
|
233
|
+
CACHE_KEY_SEPARATOR: "-",
|
|
234
|
+
CLIENT_INFO_SEPARATOR: ".",
|
|
235
|
+
};
|
|
255
236
|
/**
|
|
256
237
|
* Credential Type stored in the cache
|
|
257
238
|
*/
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
})(exports.CredentialType || (exports.CredentialType = {}));
|
|
239
|
+
const CredentialType = {
|
|
240
|
+
ID_TOKEN: "IdToken",
|
|
241
|
+
ACCESS_TOKEN: "AccessToken",
|
|
242
|
+
ACCESS_TOKEN_WITH_AUTH_SCHEME: "AccessToken_With_AuthScheme",
|
|
243
|
+
REFRESH_TOKEN: "RefreshToken",
|
|
244
|
+
};
|
|
265
245
|
/**
|
|
266
246
|
* Combine all cache types
|
|
267
247
|
*/
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
})(exports.CacheType || (exports.CacheType = {}));
|
|
248
|
+
const CacheType = {
|
|
249
|
+
ADFS: 1001,
|
|
250
|
+
MSA: 1002,
|
|
251
|
+
MSSTS: 1003,
|
|
252
|
+
GENERIC: 1004,
|
|
253
|
+
ACCESS_TOKEN: 2001,
|
|
254
|
+
REFRESH_TOKEN: 2002,
|
|
255
|
+
ID_TOKEN: 2003,
|
|
256
|
+
APP_METADATA: 3001,
|
|
257
|
+
UNDEFINED: 9999,
|
|
258
|
+
};
|
|
280
259
|
/**
|
|
281
260
|
* More Cache related constants
|
|
282
261
|
*/
|
|
@@ -287,13 +266,12 @@ const AUTHORITY_METADATA_CONSTANTS = {
|
|
|
287
266
|
CACHE_KEY: "authority-metadata",
|
|
288
267
|
REFRESH_TIME_SECONDS: 3600 * 24, // 24 Hours
|
|
289
268
|
};
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
})(AuthorityMetadataSource || (AuthorityMetadataSource = {}));
|
|
269
|
+
const AuthorityMetadataSource = {
|
|
270
|
+
CONFIG: "config",
|
|
271
|
+
CACHE: "cache",
|
|
272
|
+
NETWORK: "network",
|
|
273
|
+
HARDCODED_VALUES: "hardcoded_values",
|
|
274
|
+
};
|
|
297
275
|
const SERVER_TELEM_CONSTANTS = {
|
|
298
276
|
SCHEMA_VERSION: 5,
|
|
299
277
|
MAX_CUR_HEADER_BYTES: 80,
|
|
@@ -309,12 +287,11 @@ const SERVER_TELEM_CONSTANTS = {
|
|
|
309
287
|
/**
|
|
310
288
|
* Type of the authentication request
|
|
311
289
|
*/
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
})(exports.AuthenticationScheme || (exports.AuthenticationScheme = {}));
|
|
290
|
+
const AuthenticationScheme = {
|
|
291
|
+
BEARER: "Bearer",
|
|
292
|
+
POP: "pop",
|
|
293
|
+
SSH: "ssh-cert",
|
|
294
|
+
};
|
|
318
295
|
/**
|
|
319
296
|
* Constants related to throttling
|
|
320
297
|
*/
|
|
@@ -335,54 +312,48 @@ const Errors = {
|
|
|
335
312
|
/**
|
|
336
313
|
* Password grant parameters
|
|
337
314
|
*/
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
})(exports.PasswordGrantConstants || (exports.PasswordGrantConstants = {}));
|
|
315
|
+
const PasswordGrantConstants = {
|
|
316
|
+
username: "username",
|
|
317
|
+
password: "password",
|
|
318
|
+
};
|
|
343
319
|
/**
|
|
344
320
|
* Response codes
|
|
345
321
|
*/
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
})(ResponseCodes || (ResponseCodes = {}));
|
|
322
|
+
const ResponseCodes = {
|
|
323
|
+
httpSuccess: 200,
|
|
324
|
+
httpBadRequest: 400,
|
|
325
|
+
};
|
|
351
326
|
/**
|
|
352
327
|
* Region Discovery Sources
|
|
353
328
|
*/
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
})(RegionDiscoverySources || (RegionDiscoverySources = {}));
|
|
329
|
+
const RegionDiscoverySources = {
|
|
330
|
+
FAILED_AUTO_DETECTION: "1",
|
|
331
|
+
INTERNAL_CACHE: "2",
|
|
332
|
+
ENVIRONMENT_VARIABLE: "3",
|
|
333
|
+
IMDS: "4",
|
|
334
|
+
};
|
|
361
335
|
/**
|
|
362
336
|
* Region Discovery Outcomes
|
|
363
337
|
*/
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
JsonTypes["Jwk"] = "JWK";
|
|
384
|
-
JsonTypes["Pop"] = "pop";
|
|
385
|
-
})(JsonTypes || (JsonTypes = {}));
|
|
338
|
+
const RegionDiscoveryOutcomes = {
|
|
339
|
+
CONFIGURED_MATCHES_DETECTED: "1",
|
|
340
|
+
CONFIGURED_NO_AUTO_DETECTION: "2",
|
|
341
|
+
CONFIGURED_NOT_DETECTED: "3",
|
|
342
|
+
AUTO_DETECTION_REQUESTED_SUCCESSFUL: "4",
|
|
343
|
+
AUTO_DETECTION_REQUESTED_FAILED: "5",
|
|
344
|
+
};
|
|
345
|
+
const CacheOutcome = {
|
|
346
|
+
NO_CACHE_HIT: "0",
|
|
347
|
+
FORCE_REFRESH: "1",
|
|
348
|
+
NO_CACHED_ACCESS_TOKEN: "2",
|
|
349
|
+
CACHED_ACCESS_TOKEN_EXPIRED: "3",
|
|
350
|
+
REFRESH_CACHED_ACCESS_TOKEN: "4",
|
|
351
|
+
};
|
|
352
|
+
const JsonTypes = {
|
|
353
|
+
Jwt: "JWT",
|
|
354
|
+
Jwk: "JWK",
|
|
355
|
+
Pop: "pop",
|
|
356
|
+
};
|
|
386
357
|
const ONE_DAY_IN_MS = 86400000;
|
|
387
358
|
|
|
388
359
|
/*
|
|
@@ -1325,27 +1296,26 @@ class Logger {
|
|
|
1325
1296
|
|
|
1326
1297
|
/* eslint-disable header/header */
|
|
1327
1298
|
const name = "@azure/msal-common";
|
|
1328
|
-
const version = "14.0.0-
|
|
1299
|
+
const version = "14.0.0-beta.1";
|
|
1329
1300
|
|
|
1330
1301
|
/*
|
|
1331
1302
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
1332
1303
|
* Licensed under the MIT License.
|
|
1333
1304
|
*/
|
|
1334
|
-
|
|
1335
|
-
(function (AzureCloudInstance) {
|
|
1305
|
+
const AzureCloudInstance = {
|
|
1336
1306
|
// AzureCloudInstance is not specified.
|
|
1337
|
-
|
|
1307
|
+
None: "none",
|
|
1338
1308
|
// Microsoft Azure public cloud
|
|
1339
|
-
|
|
1309
|
+
AzurePublic: "https://login.microsoftonline.com",
|
|
1340
1310
|
// Microsoft PPE
|
|
1341
|
-
|
|
1311
|
+
AzurePpe: "https://login.windows-ppe.net",
|
|
1342
1312
|
// Microsoft Chinese national cloud
|
|
1343
|
-
|
|
1313
|
+
AzureChina: "https://login.chinacloudapi.cn",
|
|
1344
1314
|
// Microsoft German national cloud ("Black Forest")
|
|
1345
|
-
|
|
1315
|
+
AzureGermany: "https://login.microsoftonline.de",
|
|
1346
1316
|
// US Government cloud
|
|
1347
|
-
|
|
1348
|
-
}
|
|
1317
|
+
AzureUsGovernment: "https://login.microsoftonline.us",
|
|
1318
|
+
};
|
|
1349
1319
|
|
|
1350
1320
|
/*
|
|
1351
1321
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -1445,8 +1415,12 @@ const ClientConfigurationErrorMessage = {
|
|
|
1445
1415
|
},
|
|
1446
1416
|
invalidAuthenticationHeader: {
|
|
1447
1417
|
code: "invalid_authentication_header",
|
|
1448
|
-
desc: "Invalid authentication header provided"
|
|
1418
|
+
desc: "Invalid authentication header provided"
|
|
1449
1419
|
},
|
|
1420
|
+
authorityMismatch: {
|
|
1421
|
+
code: "authority_mismatch",
|
|
1422
|
+
desc: "Authority mismatch error. Authority provided in login request or PublicClientApplication config does not match the environment of the provided account. Please use a matching account or make an interactive request to login to this authority."
|
|
1423
|
+
}
|
|
1450
1424
|
};
|
|
1451
1425
|
/**
|
|
1452
1426
|
* Error thrown when there is an error in configuration of the MSAL.js library.
|
|
@@ -1595,6 +1569,12 @@ class ClientConfigurationError extends ClientAuthError {
|
|
|
1595
1569
|
static createInvalidAuthenticationHeaderError(invalidHeaderName, details) {
|
|
1596
1570
|
return new ClientConfigurationError(ClientConfigurationErrorMessage.invalidAuthenticationHeader.code, `${ClientConfigurationErrorMessage.invalidAuthenticationHeader.desc}. Invalid header: ${invalidHeaderName}. Details: ${details}`);
|
|
1597
1571
|
}
|
|
1572
|
+
/**
|
|
1573
|
+
* Create an error when the authority provided in request does not match authority provided in account or MSAL.js configuration.
|
|
1574
|
+
*/
|
|
1575
|
+
static createAuthorityMismatchError() {
|
|
1576
|
+
return new ClientConfigurationError(ClientConfigurationErrorMessage.authorityMismatch.code, ClientConfigurationErrorMessage.authorityMismatch.desc);
|
|
1577
|
+
}
|
|
1598
1578
|
}
|
|
1599
1579
|
|
|
1600
1580
|
/*
|
|
@@ -1840,13 +1820,12 @@ function buildClientInfoFromHomeAccountId(homeAccountId) {
|
|
|
1840
1820
|
/**
|
|
1841
1821
|
* Authority types supported by MSAL.
|
|
1842
1822
|
*/
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
})(exports.AuthorityType || (exports.AuthorityType = {}));
|
|
1823
|
+
const AuthorityType = {
|
|
1824
|
+
Default: 0,
|
|
1825
|
+
Adfs: 1,
|
|
1826
|
+
Dsts: 2,
|
|
1827
|
+
Ciam: 3
|
|
1828
|
+
};
|
|
1850
1829
|
|
|
1851
1830
|
/*
|
|
1852
1831
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -1900,14 +1879,14 @@ class AccountEntity {
|
|
|
1900
1879
|
*/
|
|
1901
1880
|
generateType() {
|
|
1902
1881
|
switch (this.authorityType) {
|
|
1903
|
-
case
|
|
1904
|
-
return
|
|
1905
|
-
case
|
|
1906
|
-
return
|
|
1907
|
-
case
|
|
1908
|
-
return
|
|
1909
|
-
case
|
|
1910
|
-
return
|
|
1882
|
+
case CacheAccountType.ADFS_ACCOUNT_TYPE:
|
|
1883
|
+
return CacheType.ADFS;
|
|
1884
|
+
case CacheAccountType.MSAV1_ACCOUNT_TYPE:
|
|
1885
|
+
return CacheType.MSA;
|
|
1886
|
+
case CacheAccountType.MSSTS_ACCOUNT_TYPE:
|
|
1887
|
+
return CacheType.MSSTS;
|
|
1888
|
+
case CacheAccountType.GENERIC_ACCOUNT_TYPE:
|
|
1889
|
+
return CacheType.GENERIC;
|
|
1911
1890
|
default: {
|
|
1912
1891
|
throw ClientAuthError.createUnexpectedAccountTypeError();
|
|
1913
1892
|
}
|
|
@@ -1949,7 +1928,7 @@ class AccountEntity {
|
|
|
1949
1928
|
*/
|
|
1950
1929
|
static createAccount(clientInfo, homeAccountId, idToken, authority, cloudGraphHostName, msGraphHost, environment, nativeAccountId) {
|
|
1951
1930
|
const account = new AccountEntity();
|
|
1952
|
-
account.authorityType =
|
|
1931
|
+
account.authorityType = CacheAccountType.MSSTS_ACCOUNT_TYPE;
|
|
1953
1932
|
account.clientInfo = clientInfo;
|
|
1954
1933
|
account.homeAccountId = homeAccountId;
|
|
1955
1934
|
account.nativeAccountId = nativeAccountId;
|
|
@@ -1992,9 +1971,9 @@ class AccountEntity {
|
|
|
1992
1971
|
static createGenericAccount(homeAccountId, idToken, authority, cloudGraphHostName, msGraphHost, environment) {
|
|
1993
1972
|
const account = new AccountEntity();
|
|
1994
1973
|
account.authorityType =
|
|
1995
|
-
authority && authority.authorityType ===
|
|
1996
|
-
?
|
|
1997
|
-
:
|
|
1974
|
+
authority && authority.authorityType === AuthorityType.Adfs
|
|
1975
|
+
? CacheAccountType.ADFS_ACCOUNT_TYPE
|
|
1976
|
+
: CacheAccountType.GENERIC_ACCOUNT_TYPE;
|
|
1998
1977
|
account.homeAccountId = homeAccountId;
|
|
1999
1978
|
// non AAD scenarios can have empty realm
|
|
2000
1979
|
account.realm = Constants.EMPTY_STRING;
|
|
@@ -2032,8 +2011,8 @@ class AccountEntity {
|
|
|
2032
2011
|
? idToken.claims.sub
|
|
2033
2012
|
: Constants.EMPTY_STRING;
|
|
2034
2013
|
// since ADFS does not have tid and does not set client_info
|
|
2035
|
-
if (authType ===
|
|
2036
|
-
authType ===
|
|
2014
|
+
if (authType === AuthorityType.Adfs ||
|
|
2015
|
+
authType === AuthorityType.Dsts) {
|
|
2037
2016
|
return accountId;
|
|
2038
2017
|
}
|
|
2039
2018
|
// for cases where there is clientInfo
|
|
@@ -2343,20 +2322,20 @@ class CacheManager {
|
|
|
2343
2322
|
}
|
|
2344
2323
|
const lowerCaseKey = key.toLowerCase();
|
|
2345
2324
|
// Credential keys must indicate what credential type they represent
|
|
2346
|
-
if (lowerCaseKey.indexOf(
|
|
2325
|
+
if (lowerCaseKey.indexOf(CredentialType.ID_TOKEN.toLowerCase()) ===
|
|
2347
2326
|
-1 &&
|
|
2348
|
-
lowerCaseKey.indexOf(
|
|
2327
|
+
lowerCaseKey.indexOf(CredentialType.ACCESS_TOKEN.toLowerCase()) ===
|
|
2349
2328
|
-1 &&
|
|
2350
|
-
lowerCaseKey.indexOf(
|
|
2351
|
-
lowerCaseKey.indexOf(
|
|
2329
|
+
lowerCaseKey.indexOf(CredentialType.ACCESS_TOKEN_WITH_AUTH_SCHEME.toLowerCase()) === -1 &&
|
|
2330
|
+
lowerCaseKey.indexOf(CredentialType.REFRESH_TOKEN.toLowerCase()) ===
|
|
2352
2331
|
-1) {
|
|
2353
2332
|
return false;
|
|
2354
2333
|
}
|
|
2355
|
-
if (lowerCaseKey.indexOf(
|
|
2334
|
+
if (lowerCaseKey.indexOf(CredentialType.REFRESH_TOKEN.toLowerCase()) >
|
|
2356
2335
|
-1) {
|
|
2357
2336
|
// Refresh tokens must contain the client id or family id
|
|
2358
|
-
const clientIdValidation = `${
|
|
2359
|
-
const familyIdValidation = `${
|
|
2337
|
+
const clientIdValidation = `${CredentialType.REFRESH_TOKEN}${Separators.CACHE_KEY_SEPARATOR}${this.clientId}${Separators.CACHE_KEY_SEPARATOR}`;
|
|
2338
|
+
const familyIdValidation = `${CredentialType.REFRESH_TOKEN}${Separators.CACHE_KEY_SEPARATOR}${THE_FAMILY_ID}${Separators.CACHE_KEY_SEPARATOR}`;
|
|
2360
2339
|
if (lowerCaseKey.indexOf(clientIdValidation.toLowerCase()) === -1 &&
|
|
2361
2340
|
lowerCaseKey.indexOf(familyIdValidation.toLowerCase()) === -1) {
|
|
2362
2341
|
return false;
|
|
@@ -2420,13 +2399,13 @@ class CacheManager {
|
|
|
2420
2399
|
}
|
|
2421
2400
|
// Access Token with Auth Scheme specific matching
|
|
2422
2401
|
if (entity.credentialType ===
|
|
2423
|
-
|
|
2402
|
+
CredentialType.ACCESS_TOKEN_WITH_AUTH_SCHEME) {
|
|
2424
2403
|
if (!!filter.tokenType &&
|
|
2425
2404
|
!this.matchTokenType(entity, filter.tokenType)) {
|
|
2426
2405
|
return false;
|
|
2427
2406
|
}
|
|
2428
2407
|
// KeyId (sshKid) in request must match cached SSH certificate keyId because SSH cert is bound to a specific key
|
|
2429
|
-
if (filter.tokenType ===
|
|
2408
|
+
if (filter.tokenType === AuthenticationScheme.SSH) {
|
|
2430
2409
|
if (filter.keyId && !this.matchKeyId(entity, filter.keyId)) {
|
|
2431
2410
|
return false;
|
|
2432
2411
|
}
|
|
@@ -2553,8 +2532,8 @@ class CacheManager {
|
|
|
2553
2532
|
}
|
|
2554
2533
|
// Remove Token Binding Key from key store for PoP Tokens Credentials
|
|
2555
2534
|
if (credential.credentialType.toLowerCase() ===
|
|
2556
|
-
|
|
2557
|
-
if (credential.tokenType ===
|
|
2535
|
+
CredentialType.ACCESS_TOKEN_WITH_AUTH_SCHEME.toLowerCase()) {
|
|
2536
|
+
if (credential.tokenType === AuthenticationScheme.POP) {
|
|
2558
2537
|
const accessTokenWithAuthSchemeEntity = credential;
|
|
2559
2538
|
const kid = accessTokenWithAuthSchemeEntity.keyId;
|
|
2560
2539
|
if (kid) {
|
|
@@ -2626,7 +2605,7 @@ class CacheManager {
|
|
|
2626
2605
|
const idTokenFilter = {
|
|
2627
2606
|
homeAccountId: account.homeAccountId,
|
|
2628
2607
|
environment: account.environment,
|
|
2629
|
-
credentialType:
|
|
2608
|
+
credentialType: CredentialType.ID_TOKEN,
|
|
2630
2609
|
clientId: this.clientId,
|
|
2631
2610
|
realm: account.tenantId,
|
|
2632
2611
|
};
|
|
@@ -2706,16 +2685,16 @@ class CacheManager {
|
|
|
2706
2685
|
getAccessToken(account, request, tokenKeys) {
|
|
2707
2686
|
this.commonLogger.trace("CacheManager - getAccessToken called");
|
|
2708
2687
|
const scopes = ScopeSet.createSearchScopes(request.scopes);
|
|
2709
|
-
const authScheme = request.authenticationScheme ||
|
|
2688
|
+
const authScheme = request.authenticationScheme || AuthenticationScheme.BEARER;
|
|
2710
2689
|
/*
|
|
2711
2690
|
* Distinguish between Bearer and PoP/SSH token cache types
|
|
2712
2691
|
* Cast to lowercase to handle "bearer" from ADFS
|
|
2713
2692
|
*/
|
|
2714
2693
|
const credentialType = authScheme &&
|
|
2715
2694
|
authScheme.toLowerCase() !==
|
|
2716
|
-
|
|
2717
|
-
?
|
|
2718
|
-
:
|
|
2695
|
+
AuthenticationScheme.BEARER.toLowerCase()
|
|
2696
|
+
? CredentialType.ACCESS_TOKEN_WITH_AUTH_SCHEME
|
|
2697
|
+
: CredentialType.ACCESS_TOKEN;
|
|
2719
2698
|
const accessTokenFilter = {
|
|
2720
2699
|
homeAccountId: account.homeAccountId,
|
|
2721
2700
|
environment: account.environment,
|
|
@@ -2825,7 +2804,7 @@ class CacheManager {
|
|
|
2825
2804
|
const refreshTokenFilter = {
|
|
2826
2805
|
homeAccountId: account.homeAccountId,
|
|
2827
2806
|
environment: account.environment,
|
|
2828
|
-
credentialType:
|
|
2807
|
+
credentialType: CredentialType.REFRESH_TOKEN,
|
|
2829
2808
|
clientId: this.clientId,
|
|
2830
2809
|
familyId: id,
|
|
2831
2810
|
};
|
|
@@ -3002,9 +2981,9 @@ class CacheManager {
|
|
|
3002
2981
|
* @param target
|
|
3003
2982
|
*/
|
|
3004
2983
|
matchTarget(entity, target) {
|
|
3005
|
-
const isNotAccessTokenCredential = entity.credentialType !==
|
|
2984
|
+
const isNotAccessTokenCredential = entity.credentialType !== CredentialType.ACCESS_TOKEN &&
|
|
3006
2985
|
entity.credentialType !==
|
|
3007
|
-
|
|
2986
|
+
CredentialType.ACCESS_TOKEN_WITH_AUTH_SCHEME;
|
|
3008
2987
|
if (isNotAccessTokenCredential || !entity.target) {
|
|
3009
2988
|
return false;
|
|
3010
2989
|
}
|
|
@@ -3176,6 +3155,9 @@ const DEFAULT_LOGGER_IMPLEMENTATION = {
|
|
|
3176
3155
|
logLevel: exports.LogLevel.Info,
|
|
3177
3156
|
correlationId: Constants.EMPTY_STRING,
|
|
3178
3157
|
};
|
|
3158
|
+
const DEFAULT_CACHE_OPTIONS = {
|
|
3159
|
+
claimsBasedCachingEnabled: false,
|
|
3160
|
+
};
|
|
3179
3161
|
const DEFAULT_NETWORK_IMPLEMENTATION = {
|
|
3180
3162
|
async sendGetRequestAsync() {
|
|
3181
3163
|
const notImplErr = "Network interface - sendGetRequestAsync() has not been implemented";
|
|
@@ -3197,7 +3179,7 @@ const DEFAULT_CLIENT_CREDENTIALS = {
|
|
|
3197
3179
|
clientAssertion: undefined,
|
|
3198
3180
|
};
|
|
3199
3181
|
const DEFAULT_AZURE_CLOUD_OPTIONS = {
|
|
3200
|
-
azureCloudInstance:
|
|
3182
|
+
azureCloudInstance: AzureCloudInstance.None,
|
|
3201
3183
|
tenant: `${Constants.DEFAULT_COMMON_TENANT}`,
|
|
3202
3184
|
};
|
|
3203
3185
|
const DEFAULT_TELEMETRY_OPTIONS = {
|
|
@@ -3213,7 +3195,7 @@ const DEFAULT_TELEMETRY_OPTIONS = {
|
|
|
3213
3195
|
*
|
|
3214
3196
|
* @returns Configuration
|
|
3215
3197
|
*/
|
|
3216
|
-
function buildClientConfiguration({ authOptions: userAuthOptions, systemOptions: userSystemOptions, loggerOptions: userLoggerOption, storageInterface: storageImplementation, networkInterface: networkImplementation, cryptoInterface: cryptoImplementation, clientCredentials: clientCredentials, libraryInfo: libraryInfo, telemetry: telemetry, serverTelemetryManager: serverTelemetryManager, persistencePlugin: persistencePlugin, serializableCache: serializableCache, }) {
|
|
3198
|
+
function buildClientConfiguration({ authOptions: userAuthOptions, systemOptions: userSystemOptions, loggerOptions: userLoggerOption, cacheOptions: userCacheOptions, storageInterface: storageImplementation, networkInterface: networkImplementation, cryptoInterface: cryptoImplementation, clientCredentials: clientCredentials, libraryInfo: libraryInfo, telemetry: telemetry, serverTelemetryManager: serverTelemetryManager, persistencePlugin: persistencePlugin, serializableCache: serializableCache, }) {
|
|
3217
3199
|
const loggerOptions = {
|
|
3218
3200
|
...DEFAULT_LOGGER_IMPLEMENTATION,
|
|
3219
3201
|
...userLoggerOption,
|
|
@@ -3222,6 +3204,7 @@ function buildClientConfiguration({ authOptions: userAuthOptions, systemOptions:
|
|
|
3222
3204
|
authOptions: buildAuthOptions(userAuthOptions),
|
|
3223
3205
|
systemOptions: { ...DEFAULT_SYSTEM_OPTIONS, ...userSystemOptions },
|
|
3224
3206
|
loggerOptions: loggerOptions,
|
|
3207
|
+
cacheOptions: { ...DEFAULT_CACHE_OPTIONS, ...userCacheOptions },
|
|
3225
3208
|
storageInterface: storageImplementation ||
|
|
3226
3209
|
new DefaultStorageClass(userAuthOptions.clientId, DEFAULT_CRYPTO_IMPLEMENTATION, new Logger(loggerOptions)),
|
|
3227
3210
|
networkInterface: networkImplementation || DEFAULT_NETWORK_IMPLEMENTATION,
|
|
@@ -3300,7 +3283,7 @@ class ThrottlingUtils {
|
|
|
3300
3283
|
if (ThrottlingUtils.checkResponseStatus(response) ||
|
|
3301
3284
|
ThrottlingUtils.checkResponseForRetryAfter(response)) {
|
|
3302
3285
|
const thumbprintValue = {
|
|
3303
|
-
throttleTime: ThrottlingUtils.calculateThrottleTime(parseInt(response.headers[
|
|
3286
|
+
throttleTime: ThrottlingUtils.calculateThrottleTime(parseInt(response.headers[HeaderNames.RETRY_AFTER])),
|
|
3304
3287
|
error: response.body.error,
|
|
3305
3288
|
errorCodes: response.body.error_codes,
|
|
3306
3289
|
errorMessage: response.body.error_description,
|
|
@@ -3323,7 +3306,7 @@ class ThrottlingUtils {
|
|
|
3323
3306
|
*/
|
|
3324
3307
|
static checkResponseForRetryAfter(response) {
|
|
3325
3308
|
if (response.headers) {
|
|
3326
|
-
return (response.headers.hasOwnProperty(
|
|
3309
|
+
return (response.headers.hasOwnProperty(HeaderNames.RETRY_AFTER) &&
|
|
3327
3310
|
(response.status < 200 || response.status >= 300));
|
|
3328
3311
|
}
|
|
3329
3312
|
return false;
|
|
@@ -3395,11 +3378,10 @@ class NetworkManager {
|
|
|
3395
3378
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3396
3379
|
* Licensed under the MIT License.
|
|
3397
3380
|
*/
|
|
3398
|
-
|
|
3399
|
-
|
|
3400
|
-
|
|
3401
|
-
|
|
3402
|
-
})(exports.CcsCredentialType || (exports.CcsCredentialType = {}));
|
|
3381
|
+
const CcsCredentialType = {
|
|
3382
|
+
HOME_ACCOUNT_ID: "home_account_id",
|
|
3383
|
+
UPN: "UPN",
|
|
3384
|
+
};
|
|
3403
3385
|
|
|
3404
3386
|
/*
|
|
3405
3387
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -3480,8 +3462,7 @@ class RequestValidator {
|
|
|
3480
3462
|
}
|
|
3481
3463
|
});
|
|
3482
3464
|
// remove empty string parameters
|
|
3483
|
-
return Object.fromEntries(Object.entries(eQParams).filter(
|
|
3484
|
-
);
|
|
3465
|
+
return Object.fromEntries(Object.entries(eQParams).filter(kv => kv[1] !== ""));
|
|
3485
3466
|
}
|
|
3486
3467
|
}
|
|
3487
3468
|
|
|
@@ -3497,26 +3478,26 @@ class RequestParameterBuilder {
|
|
|
3497
3478
|
* add response_type = code
|
|
3498
3479
|
*/
|
|
3499
3480
|
addResponseTypeCode() {
|
|
3500
|
-
this.parameters.set(
|
|
3481
|
+
this.parameters.set(AADServerParamKeys.RESPONSE_TYPE, encodeURIComponent(Constants.CODE_RESPONSE_TYPE));
|
|
3501
3482
|
}
|
|
3502
3483
|
/**
|
|
3503
3484
|
* add response_type = token id_token
|
|
3504
3485
|
*/
|
|
3505
3486
|
addResponseTypeForTokenAndIdToken() {
|
|
3506
|
-
this.parameters.set(
|
|
3487
|
+
this.parameters.set(AADServerParamKeys.RESPONSE_TYPE, encodeURIComponent(`${Constants.TOKEN_RESPONSE_TYPE} ${Constants.ID_TOKEN_RESPONSE_TYPE}`));
|
|
3507
3488
|
}
|
|
3508
3489
|
/**
|
|
3509
3490
|
* add response_mode. defaults to query.
|
|
3510
3491
|
* @param responseMode
|
|
3511
3492
|
*/
|
|
3512
3493
|
addResponseMode(responseMode) {
|
|
3513
|
-
this.parameters.set(
|
|
3494
|
+
this.parameters.set(AADServerParamKeys.RESPONSE_MODE, encodeURIComponent(responseMode ? responseMode : ResponseMode.QUERY));
|
|
3514
3495
|
}
|
|
3515
3496
|
/**
|
|
3516
3497
|
* Add flag to indicate STS should attempt to use WAM if available
|
|
3517
3498
|
*/
|
|
3518
3499
|
addNativeBroker() {
|
|
3519
|
-
this.parameters.set(
|
|
3500
|
+
this.parameters.set(AADServerParamKeys.NATIVE_BROKER, encodeURIComponent("1"));
|
|
3520
3501
|
}
|
|
3521
3502
|
/**
|
|
3522
3503
|
* add scopes. set addOidcScopes to false to prevent default scopes in non-user scenarios
|
|
@@ -3528,14 +3509,14 @@ class RequestParameterBuilder {
|
|
|
3528
3509
|
? [...(scopes || []), ...OIDC_DEFAULT_SCOPES]
|
|
3529
3510
|
: scopes || [];
|
|
3530
3511
|
const scopeSet = new ScopeSet(requestScopes);
|
|
3531
|
-
this.parameters.set(
|
|
3512
|
+
this.parameters.set(AADServerParamKeys.SCOPE, encodeURIComponent(scopeSet.printScopes()));
|
|
3532
3513
|
}
|
|
3533
3514
|
/**
|
|
3534
3515
|
* add clientId
|
|
3535
3516
|
* @param clientId
|
|
3536
3517
|
*/
|
|
3537
3518
|
addClientId(clientId) {
|
|
3538
|
-
this.parameters.set(
|
|
3519
|
+
this.parameters.set(AADServerParamKeys.CLIENT_ID, encodeURIComponent(clientId));
|
|
3539
3520
|
}
|
|
3540
3521
|
/**
|
|
3541
3522
|
* add redirect_uri
|
|
@@ -3543,7 +3524,7 @@ class RequestParameterBuilder {
|
|
|
3543
3524
|
*/
|
|
3544
3525
|
addRedirectUri(redirectUri) {
|
|
3545
3526
|
RequestValidator.validateRedirectUri(redirectUri);
|
|
3546
|
-
this.parameters.set(
|
|
3527
|
+
this.parameters.set(AADServerParamKeys.REDIRECT_URI, encodeURIComponent(redirectUri));
|
|
3547
3528
|
}
|
|
3548
3529
|
/**
|
|
3549
3530
|
* add post logout redirectUri
|
|
@@ -3551,49 +3532,49 @@ class RequestParameterBuilder {
|
|
|
3551
3532
|
*/
|
|
3552
3533
|
addPostLogoutRedirectUri(redirectUri) {
|
|
3553
3534
|
RequestValidator.validateRedirectUri(redirectUri);
|
|
3554
|
-
this.parameters.set(
|
|
3535
|
+
this.parameters.set(AADServerParamKeys.POST_LOGOUT_URI, encodeURIComponent(redirectUri));
|
|
3555
3536
|
}
|
|
3556
3537
|
/**
|
|
3557
3538
|
* add id_token_hint to logout request
|
|
3558
3539
|
* @param idTokenHint
|
|
3559
3540
|
*/
|
|
3560
3541
|
addIdTokenHint(idTokenHint) {
|
|
3561
|
-
this.parameters.set(
|
|
3542
|
+
this.parameters.set(AADServerParamKeys.ID_TOKEN_HINT, encodeURIComponent(idTokenHint));
|
|
3562
3543
|
}
|
|
3563
3544
|
/**
|
|
3564
3545
|
* add domain_hint
|
|
3565
3546
|
* @param domainHint
|
|
3566
3547
|
*/
|
|
3567
3548
|
addDomainHint(domainHint) {
|
|
3568
|
-
this.parameters.set(
|
|
3549
|
+
this.parameters.set(SSOTypes.DOMAIN_HINT, encodeURIComponent(domainHint));
|
|
3569
3550
|
}
|
|
3570
3551
|
/**
|
|
3571
3552
|
* add login_hint
|
|
3572
3553
|
* @param loginHint
|
|
3573
3554
|
*/
|
|
3574
3555
|
addLoginHint(loginHint) {
|
|
3575
|
-
this.parameters.set(
|
|
3556
|
+
this.parameters.set(SSOTypes.LOGIN_HINT, encodeURIComponent(loginHint));
|
|
3576
3557
|
}
|
|
3577
3558
|
/**
|
|
3578
3559
|
* Adds the CCS (Cache Credential Service) query parameter for login_hint
|
|
3579
3560
|
* @param loginHint
|
|
3580
3561
|
*/
|
|
3581
3562
|
addCcsUpn(loginHint) {
|
|
3582
|
-
this.parameters.set(
|
|
3563
|
+
this.parameters.set(HeaderNames.CCS_HEADER, encodeURIComponent(`UPN:${loginHint}`));
|
|
3583
3564
|
}
|
|
3584
3565
|
/**
|
|
3585
3566
|
* Adds the CCS (Cache Credential Service) query parameter for account object
|
|
3586
3567
|
* @param loginHint
|
|
3587
3568
|
*/
|
|
3588
3569
|
addCcsOid(clientInfo) {
|
|
3589
|
-
this.parameters.set(
|
|
3570
|
+
this.parameters.set(HeaderNames.CCS_HEADER, encodeURIComponent(`Oid:${clientInfo.uid}@${clientInfo.utid}`));
|
|
3590
3571
|
}
|
|
3591
3572
|
/**
|
|
3592
3573
|
* add sid
|
|
3593
3574
|
* @param sid
|
|
3594
3575
|
*/
|
|
3595
3576
|
addSid(sid) {
|
|
3596
|
-
this.parameters.set(
|
|
3577
|
+
this.parameters.set(SSOTypes.SID, encodeURIComponent(sid));
|
|
3597
3578
|
}
|
|
3598
3579
|
/**
|
|
3599
3580
|
* add claims
|
|
@@ -3602,14 +3583,14 @@ class RequestParameterBuilder {
|
|
|
3602
3583
|
addClaims(claims, clientCapabilities) {
|
|
3603
3584
|
const mergedClaims = this.addClientCapabilitiesToClaims(claims, clientCapabilities);
|
|
3604
3585
|
RequestValidator.validateClaims(mergedClaims);
|
|
3605
|
-
this.parameters.set(
|
|
3586
|
+
this.parameters.set(AADServerParamKeys.CLAIMS, encodeURIComponent(mergedClaims));
|
|
3606
3587
|
}
|
|
3607
3588
|
/**
|
|
3608
3589
|
* add correlationId
|
|
3609
3590
|
* @param correlationId
|
|
3610
3591
|
*/
|
|
3611
3592
|
addCorrelationId(correlationId) {
|
|
3612
|
-
this.parameters.set(
|
|
3593
|
+
this.parameters.set(AADServerParamKeys.CLIENT_REQUEST_ID, encodeURIComponent(correlationId));
|
|
3613
3594
|
}
|
|
3614
3595
|
/**
|
|
3615
3596
|
* add library info query params
|
|
@@ -3617,13 +3598,13 @@ class RequestParameterBuilder {
|
|
|
3617
3598
|
*/
|
|
3618
3599
|
addLibraryInfo(libraryInfo) {
|
|
3619
3600
|
// Telemetry Info
|
|
3620
|
-
this.parameters.set(
|
|
3621
|
-
this.parameters.set(
|
|
3601
|
+
this.parameters.set(AADServerParamKeys.X_CLIENT_SKU, libraryInfo.sku);
|
|
3602
|
+
this.parameters.set(AADServerParamKeys.X_CLIENT_VER, libraryInfo.version);
|
|
3622
3603
|
if (libraryInfo.os) {
|
|
3623
|
-
this.parameters.set(
|
|
3604
|
+
this.parameters.set(AADServerParamKeys.X_CLIENT_OS, libraryInfo.os);
|
|
3624
3605
|
}
|
|
3625
3606
|
if (libraryInfo.cpu) {
|
|
3626
|
-
this.parameters.set(
|
|
3607
|
+
this.parameters.set(AADServerParamKeys.X_CLIENT_CPU, libraryInfo.cpu);
|
|
3627
3608
|
}
|
|
3628
3609
|
}
|
|
3629
3610
|
/**
|
|
@@ -3632,10 +3613,10 @@ class RequestParameterBuilder {
|
|
|
3632
3613
|
*/
|
|
3633
3614
|
addApplicationTelemetry(appTelemetry) {
|
|
3634
3615
|
if (appTelemetry?.appName) {
|
|
3635
|
-
this.parameters.set(
|
|
3616
|
+
this.parameters.set(AADServerParamKeys.X_APP_NAME, appTelemetry.appName);
|
|
3636
3617
|
}
|
|
3637
3618
|
if (appTelemetry?.appVersion) {
|
|
3638
|
-
this.parameters.set(
|
|
3619
|
+
this.parameters.set(AADServerParamKeys.X_APP_VER, appTelemetry.appVersion);
|
|
3639
3620
|
}
|
|
3640
3621
|
}
|
|
3641
3622
|
/**
|
|
@@ -3644,7 +3625,7 @@ class RequestParameterBuilder {
|
|
|
3644
3625
|
*/
|
|
3645
3626
|
addPrompt(prompt) {
|
|
3646
3627
|
RequestValidator.validatePrompt(prompt);
|
|
3647
|
-
this.parameters.set(`${
|
|
3628
|
+
this.parameters.set(`${AADServerParamKeys.PROMPT}`, encodeURIComponent(prompt));
|
|
3648
3629
|
}
|
|
3649
3630
|
/**
|
|
3650
3631
|
* add state
|
|
@@ -3652,7 +3633,7 @@ class RequestParameterBuilder {
|
|
|
3652
3633
|
*/
|
|
3653
3634
|
addState(state) {
|
|
3654
3635
|
if (!StringUtils.isEmpty(state)) {
|
|
3655
|
-
this.parameters.set(
|
|
3636
|
+
this.parameters.set(AADServerParamKeys.STATE, encodeURIComponent(state));
|
|
3656
3637
|
}
|
|
3657
3638
|
}
|
|
3658
3639
|
/**
|
|
@@ -3660,7 +3641,7 @@ class RequestParameterBuilder {
|
|
|
3660
3641
|
* @param nonce
|
|
3661
3642
|
*/
|
|
3662
3643
|
addNonce(nonce) {
|
|
3663
|
-
this.parameters.set(
|
|
3644
|
+
this.parameters.set(AADServerParamKeys.NONCE, encodeURIComponent(nonce));
|
|
3664
3645
|
}
|
|
3665
3646
|
/**
|
|
3666
3647
|
* add code_challenge and code_challenge_method
|
|
@@ -3671,8 +3652,8 @@ class RequestParameterBuilder {
|
|
|
3671
3652
|
addCodeChallengeParams(codeChallenge, codeChallengeMethod) {
|
|
3672
3653
|
RequestValidator.validateCodeChallengeParams(codeChallenge, codeChallengeMethod);
|
|
3673
3654
|
if (codeChallenge && codeChallengeMethod) {
|
|
3674
|
-
this.parameters.set(
|
|
3675
|
-
this.parameters.set(
|
|
3655
|
+
this.parameters.set(AADServerParamKeys.CODE_CHALLENGE, encodeURIComponent(codeChallenge));
|
|
3656
|
+
this.parameters.set(AADServerParamKeys.CODE_CHALLENGE_METHOD, encodeURIComponent(codeChallengeMethod));
|
|
3676
3657
|
}
|
|
3677
3658
|
else {
|
|
3678
3659
|
throw ClientConfigurationError.createInvalidCodeChallengeParamsError();
|
|
@@ -3683,35 +3664,35 @@ class RequestParameterBuilder {
|
|
|
3683
3664
|
* @param code
|
|
3684
3665
|
*/
|
|
3685
3666
|
addAuthorizationCode(code) {
|
|
3686
|
-
this.parameters.set(
|
|
3667
|
+
this.parameters.set(AADServerParamKeys.CODE, encodeURIComponent(code));
|
|
3687
3668
|
}
|
|
3688
3669
|
/**
|
|
3689
3670
|
* add the `authorization_code` passed by the user to exchange for a token
|
|
3690
3671
|
* @param code
|
|
3691
3672
|
*/
|
|
3692
3673
|
addDeviceCode(code) {
|
|
3693
|
-
this.parameters.set(
|
|
3674
|
+
this.parameters.set(AADServerParamKeys.DEVICE_CODE, encodeURIComponent(code));
|
|
3694
3675
|
}
|
|
3695
3676
|
/**
|
|
3696
3677
|
* add the `refreshToken` passed by the user
|
|
3697
3678
|
* @param refreshToken
|
|
3698
3679
|
*/
|
|
3699
3680
|
addRefreshToken(refreshToken) {
|
|
3700
|
-
this.parameters.set(
|
|
3681
|
+
this.parameters.set(AADServerParamKeys.REFRESH_TOKEN, encodeURIComponent(refreshToken));
|
|
3701
3682
|
}
|
|
3702
3683
|
/**
|
|
3703
3684
|
* add the `code_verifier` passed by the user to exchange for a token
|
|
3704
3685
|
* @param codeVerifier
|
|
3705
3686
|
*/
|
|
3706
3687
|
addCodeVerifier(codeVerifier) {
|
|
3707
|
-
this.parameters.set(
|
|
3688
|
+
this.parameters.set(AADServerParamKeys.CODE_VERIFIER, encodeURIComponent(codeVerifier));
|
|
3708
3689
|
}
|
|
3709
3690
|
/**
|
|
3710
3691
|
* add client_secret
|
|
3711
3692
|
* @param clientSecret
|
|
3712
3693
|
*/
|
|
3713
3694
|
addClientSecret(clientSecret) {
|
|
3714
|
-
this.parameters.set(
|
|
3695
|
+
this.parameters.set(AADServerParamKeys.CLIENT_SECRET, encodeURIComponent(clientSecret));
|
|
3715
3696
|
}
|
|
3716
3697
|
/**
|
|
3717
3698
|
* add clientAssertion for confidential client flows
|
|
@@ -3719,7 +3700,7 @@ class RequestParameterBuilder {
|
|
|
3719
3700
|
*/
|
|
3720
3701
|
addClientAssertion(clientAssertion) {
|
|
3721
3702
|
if (!StringUtils.isEmpty(clientAssertion)) {
|
|
3722
|
-
this.parameters.set(
|
|
3703
|
+
this.parameters.set(AADServerParamKeys.CLIENT_ASSERTION, encodeURIComponent(clientAssertion));
|
|
3723
3704
|
}
|
|
3724
3705
|
}
|
|
3725
3706
|
/**
|
|
@@ -3728,7 +3709,7 @@ class RequestParameterBuilder {
|
|
|
3728
3709
|
*/
|
|
3729
3710
|
addClientAssertionType(clientAssertionType) {
|
|
3730
3711
|
if (!StringUtils.isEmpty(clientAssertionType)) {
|
|
3731
|
-
this.parameters.set(
|
|
3712
|
+
this.parameters.set(AADServerParamKeys.CLIENT_ASSERTION_TYPE, encodeURIComponent(clientAssertionType));
|
|
3732
3713
|
}
|
|
3733
3714
|
}
|
|
3734
3715
|
/**
|
|
@@ -3736,21 +3717,21 @@ class RequestParameterBuilder {
|
|
|
3736
3717
|
* @param clientAssertion
|
|
3737
3718
|
*/
|
|
3738
3719
|
addOboAssertion(oboAssertion) {
|
|
3739
|
-
this.parameters.set(
|
|
3720
|
+
this.parameters.set(AADServerParamKeys.OBO_ASSERTION, encodeURIComponent(oboAssertion));
|
|
3740
3721
|
}
|
|
3741
3722
|
/**
|
|
3742
3723
|
* add grant type
|
|
3743
3724
|
* @param grantType
|
|
3744
3725
|
*/
|
|
3745
3726
|
addRequestTokenUse(tokenUse) {
|
|
3746
|
-
this.parameters.set(
|
|
3727
|
+
this.parameters.set(AADServerParamKeys.REQUESTED_TOKEN_USE, encodeURIComponent(tokenUse));
|
|
3747
3728
|
}
|
|
3748
3729
|
/**
|
|
3749
3730
|
* add grant type
|
|
3750
3731
|
* @param grantType
|
|
3751
3732
|
*/
|
|
3752
3733
|
addGrantType(grantType) {
|
|
3753
|
-
this.parameters.set(
|
|
3734
|
+
this.parameters.set(AADServerParamKeys.GRANT_TYPE, encodeURIComponent(grantType));
|
|
3754
3735
|
}
|
|
3755
3736
|
/**
|
|
3756
3737
|
* add client info
|
|
@@ -3784,12 +3765,12 @@ class RequestParameterBuilder {
|
|
|
3784
3765
|
}
|
|
3785
3766
|
}
|
|
3786
3767
|
if (clientCapabilities && clientCapabilities.length > 0) {
|
|
3787
|
-
if (!mergedClaims.hasOwnProperty(
|
|
3768
|
+
if (!mergedClaims.hasOwnProperty(ClaimsRequestKeys.ACCESS_TOKEN)) {
|
|
3788
3769
|
// Add access_token key to claims object
|
|
3789
|
-
mergedClaims[
|
|
3770
|
+
mergedClaims[ClaimsRequestKeys.ACCESS_TOKEN] = {};
|
|
3790
3771
|
}
|
|
3791
3772
|
// Add xms_cc claim with provided clientCapabilities to access_token key
|
|
3792
|
-
mergedClaims[
|
|
3773
|
+
mergedClaims[ClaimsRequestKeys.ACCESS_TOKEN][ClaimsRequestKeys.XMS_CC] = {
|
|
3793
3774
|
values: clientCapabilities,
|
|
3794
3775
|
};
|
|
3795
3776
|
}
|
|
@@ -3800,14 +3781,14 @@ class RequestParameterBuilder {
|
|
|
3800
3781
|
* @param username
|
|
3801
3782
|
*/
|
|
3802
3783
|
addUsername(username) {
|
|
3803
|
-
this.parameters.set(
|
|
3784
|
+
this.parameters.set(PasswordGrantConstants.username, encodeURIComponent(username));
|
|
3804
3785
|
}
|
|
3805
3786
|
/**
|
|
3806
3787
|
* adds `password` for Password Grant flow
|
|
3807
3788
|
* @param password
|
|
3808
3789
|
*/
|
|
3809
3790
|
addPassword(password) {
|
|
3810
|
-
this.parameters.set(
|
|
3791
|
+
this.parameters.set(PasswordGrantConstants.password, encodeURIComponent(password));
|
|
3811
3792
|
}
|
|
3812
3793
|
/**
|
|
3813
3794
|
* add pop_jwk to query params
|
|
@@ -3815,8 +3796,8 @@ class RequestParameterBuilder {
|
|
|
3815
3796
|
*/
|
|
3816
3797
|
addPopToken(cnfString) {
|
|
3817
3798
|
if (!StringUtils.isEmpty(cnfString)) {
|
|
3818
|
-
this.parameters.set(
|
|
3819
|
-
this.parameters.set(
|
|
3799
|
+
this.parameters.set(AADServerParamKeys.TOKEN_TYPE, AuthenticationScheme.POP);
|
|
3800
|
+
this.parameters.set(AADServerParamKeys.REQ_CNF, encodeURIComponent(cnfString));
|
|
3820
3801
|
}
|
|
3821
3802
|
}
|
|
3822
3803
|
/**
|
|
@@ -3824,8 +3805,8 @@ class RequestParameterBuilder {
|
|
|
3824
3805
|
*/
|
|
3825
3806
|
addSshJwk(sshJwkString) {
|
|
3826
3807
|
if (!StringUtils.isEmpty(sshJwkString)) {
|
|
3827
|
-
this.parameters.set(
|
|
3828
|
-
this.parameters.set(
|
|
3808
|
+
this.parameters.set(AADServerParamKeys.TOKEN_TYPE, AuthenticationScheme.SSH);
|
|
3809
|
+
this.parameters.set(AADServerParamKeys.REQ_CNF, encodeURIComponent(sshJwkString));
|
|
3829
3810
|
}
|
|
3830
3811
|
}
|
|
3831
3812
|
/**
|
|
@@ -3833,20 +3814,20 @@ class RequestParameterBuilder {
|
|
|
3833
3814
|
* @param serverTelemetryManager
|
|
3834
3815
|
*/
|
|
3835
3816
|
addServerTelemetry(serverTelemetryManager) {
|
|
3836
|
-
this.parameters.set(
|
|
3837
|
-
this.parameters.set(
|
|
3817
|
+
this.parameters.set(AADServerParamKeys.X_CLIENT_CURR_TELEM, serverTelemetryManager.generateCurrentRequestHeaderValue());
|
|
3818
|
+
this.parameters.set(AADServerParamKeys.X_CLIENT_LAST_TELEM, serverTelemetryManager.generateLastRequestHeaderValue());
|
|
3838
3819
|
}
|
|
3839
3820
|
/**
|
|
3840
3821
|
* Adds parameter that indicates to the server that throttling is supported
|
|
3841
3822
|
*/
|
|
3842
3823
|
addThrottling() {
|
|
3843
|
-
this.parameters.set(
|
|
3824
|
+
this.parameters.set(AADServerParamKeys.X_MS_LIB_CAPABILITY, ThrottlingConstants.X_MS_LIB_CAPABILITY_VALUE);
|
|
3844
3825
|
}
|
|
3845
3826
|
/**
|
|
3846
3827
|
* Adds logout_hint parameter for "silent" logout which prevent server account picker
|
|
3847
3828
|
*/
|
|
3848
3829
|
addLogoutHint(logoutHint) {
|
|
3849
|
-
this.parameters.set(
|
|
3830
|
+
this.parameters.set(AADServerParamKeys.LOGOUT_HINT, encodeURIComponent(logoutHint));
|
|
3850
3831
|
}
|
|
3851
3832
|
/**
|
|
3852
3833
|
* Utility to create a URL from the params map
|
|
@@ -3893,21 +3874,21 @@ class BaseClient {
|
|
|
3893
3874
|
*/
|
|
3894
3875
|
createTokenRequestHeaders(ccsCred) {
|
|
3895
3876
|
const headers = {};
|
|
3896
|
-
headers[
|
|
3877
|
+
headers[HeaderNames.CONTENT_TYPE] = Constants.URL_FORM_CONTENT_TYPE;
|
|
3897
3878
|
if (!this.config.systemOptions.preventCorsPreflight && ccsCred) {
|
|
3898
3879
|
switch (ccsCred.type) {
|
|
3899
|
-
case
|
|
3880
|
+
case CcsCredentialType.HOME_ACCOUNT_ID:
|
|
3900
3881
|
try {
|
|
3901
3882
|
const clientInfo = buildClientInfoFromHomeAccountId(ccsCred.credential);
|
|
3902
|
-
headers[
|
|
3883
|
+
headers[HeaderNames.CCS_HEADER] = `Oid:${clientInfo.uid}@${clientInfo.utid}`;
|
|
3903
3884
|
}
|
|
3904
3885
|
catch (e) {
|
|
3905
3886
|
this.logger.verbose("Could not parse home account ID for CCS Header: " +
|
|
3906
3887
|
e);
|
|
3907
3888
|
}
|
|
3908
3889
|
break;
|
|
3909
|
-
case
|
|
3910
|
-
headers[
|
|
3890
|
+
case CcsCredentialType.UPN:
|
|
3891
|
+
headers[HeaderNames.CCS_HEADER] = `UPN: ${ccsCred.credential}`;
|
|
3911
3892
|
break;
|
|
3912
3893
|
}
|
|
3913
3894
|
}
|
|
@@ -4009,13 +3990,13 @@ class CredentialEntity {
|
|
|
4009
3990
|
*/
|
|
4010
3991
|
generateType() {
|
|
4011
3992
|
switch (this.credentialType) {
|
|
4012
|
-
case
|
|
4013
|
-
return
|
|
4014
|
-
case
|
|
4015
|
-
case
|
|
4016
|
-
return
|
|
4017
|
-
case
|
|
4018
|
-
return
|
|
3993
|
+
case CredentialType.ID_TOKEN:
|
|
3994
|
+
return CacheType.ID_TOKEN;
|
|
3995
|
+
case CredentialType.ACCESS_TOKEN:
|
|
3996
|
+
case CredentialType.ACCESS_TOKEN_WITH_AUTH_SCHEME:
|
|
3997
|
+
return CacheType.ACCESS_TOKEN;
|
|
3998
|
+
case CredentialType.REFRESH_TOKEN:
|
|
3999
|
+
return CacheType.REFRESH_TOKEN;
|
|
4019
4000
|
default: {
|
|
4020
4001
|
throw ClientAuthError.createUnexpectedCredentialTypeError();
|
|
4021
4002
|
}
|
|
@@ -4052,7 +4033,7 @@ class CredentialEntity {
|
|
|
4052
4033
|
* @param familyId
|
|
4053
4034
|
*/
|
|
4054
4035
|
static generateCredentialIdForCacheKey(credentialType, clientId, realm, familyId) {
|
|
4055
|
-
const clientOrFamilyId = credentialType ===
|
|
4036
|
+
const clientOrFamilyId = credentialType === CredentialType.REFRESH_TOKEN
|
|
4056
4037
|
? familyId || clientId
|
|
4057
4038
|
: clientId;
|
|
4058
4039
|
const credentialId = [
|
|
@@ -4084,7 +4065,7 @@ class CredentialEntity {
|
|
|
4084
4065
|
*/
|
|
4085
4066
|
return tokenType &&
|
|
4086
4067
|
tokenType.toLowerCase() !==
|
|
4087
|
-
|
|
4068
|
+
AuthenticationScheme.BEARER.toLowerCase()
|
|
4088
4069
|
? tokenType.toLowerCase()
|
|
4089
4070
|
: Constants.EMPTY_STRING;
|
|
4090
4071
|
}
|
|
@@ -4121,7 +4102,7 @@ class IdTokenEntity extends CredentialEntity {
|
|
|
4121
4102
|
*/
|
|
4122
4103
|
static createIdTokenEntity(homeAccountId, environment, idToken, clientId, tenantId) {
|
|
4123
4104
|
const idTokenEntity = new IdTokenEntity();
|
|
4124
|
-
idTokenEntity.credentialType =
|
|
4105
|
+
idTokenEntity.credentialType = CredentialType.ID_TOKEN;
|
|
4125
4106
|
idTokenEntity.homeAccountId = homeAccountId;
|
|
4126
4107
|
idTokenEntity.environment = environment;
|
|
4127
4108
|
idTokenEntity.clientId = clientId;
|
|
@@ -4143,7 +4124,7 @@ class IdTokenEntity extends CredentialEntity {
|
|
|
4143
4124
|
entity.hasOwnProperty("realm") &&
|
|
4144
4125
|
entity.hasOwnProperty("clientId") &&
|
|
4145
4126
|
entity.hasOwnProperty("secret") &&
|
|
4146
|
-
entity["credentialType"] ===
|
|
4127
|
+
entity["credentialType"] === CredentialType.ID_TOKEN);
|
|
4147
4128
|
}
|
|
4148
4129
|
}
|
|
4149
4130
|
|
|
@@ -4236,7 +4217,7 @@ class AccessTokenEntity extends CredentialEntity {
|
|
|
4236
4217
|
static createAccessTokenEntity(homeAccountId, environment, accessToken, clientId, tenantId, scopes, expiresOn, extExpiresOn, cryptoUtils, refreshOn, tokenType, userAssertionHash, keyId, requestedClaims, requestedClaimsHash) {
|
|
4237
4218
|
const atEntity = new AccessTokenEntity();
|
|
4238
4219
|
atEntity.homeAccountId = homeAccountId;
|
|
4239
|
-
atEntity.credentialType =
|
|
4220
|
+
atEntity.credentialType = CredentialType.ACCESS_TOKEN;
|
|
4240
4221
|
atEntity.secret = accessToken;
|
|
4241
4222
|
const currentTime = TimeUtils.nowSeconds();
|
|
4242
4223
|
atEntity.cachedAt = currentTime.toString();
|
|
@@ -4255,7 +4236,7 @@ class AccessTokenEntity extends CredentialEntity {
|
|
|
4255
4236
|
atEntity.target = scopes;
|
|
4256
4237
|
atEntity.userAssertionHash = userAssertionHash;
|
|
4257
4238
|
atEntity.tokenType = StringUtils.isEmpty(tokenType)
|
|
4258
|
-
?
|
|
4239
|
+
? AuthenticationScheme.BEARER
|
|
4259
4240
|
: tokenType;
|
|
4260
4241
|
if (requestedClaims) {
|
|
4261
4242
|
atEntity.requestedClaims = requestedClaims;
|
|
@@ -4266,11 +4247,11 @@ class AccessTokenEntity extends CredentialEntity {
|
|
|
4266
4247
|
* Cast to lower to handle "bearer" from ADFS
|
|
4267
4248
|
*/
|
|
4268
4249
|
if (atEntity.tokenType?.toLowerCase() !==
|
|
4269
|
-
|
|
4250
|
+
AuthenticationScheme.BEARER.toLowerCase()) {
|
|
4270
4251
|
atEntity.credentialType =
|
|
4271
|
-
|
|
4252
|
+
CredentialType.ACCESS_TOKEN_WITH_AUTH_SCHEME;
|
|
4272
4253
|
switch (atEntity.tokenType) {
|
|
4273
|
-
case
|
|
4254
|
+
case AuthenticationScheme.POP:
|
|
4274
4255
|
// Make sure keyId is present and add it to credential
|
|
4275
4256
|
const tokenClaims = AuthToken.extractTokenClaims(accessToken, cryptoUtils);
|
|
4276
4257
|
if (!tokenClaims?.cnf?.kid) {
|
|
@@ -4278,7 +4259,7 @@ class AccessTokenEntity extends CredentialEntity {
|
|
|
4278
4259
|
}
|
|
4279
4260
|
atEntity.keyId = tokenClaims.cnf.kid;
|
|
4280
4261
|
break;
|
|
4281
|
-
case
|
|
4262
|
+
case AuthenticationScheme.SSH:
|
|
4282
4263
|
atEntity.keyId = keyId;
|
|
4283
4264
|
}
|
|
4284
4265
|
}
|
|
@@ -4299,9 +4280,9 @@ class AccessTokenEntity extends CredentialEntity {
|
|
|
4299
4280
|
entity.hasOwnProperty("clientId") &&
|
|
4300
4281
|
entity.hasOwnProperty("secret") &&
|
|
4301
4282
|
entity.hasOwnProperty("target") &&
|
|
4302
|
-
(entity["credentialType"] ===
|
|
4283
|
+
(entity["credentialType"] === CredentialType.ACCESS_TOKEN ||
|
|
4303
4284
|
entity["credentialType"] ===
|
|
4304
|
-
|
|
4285
|
+
CredentialType.ACCESS_TOKEN_WITH_AUTH_SCHEME));
|
|
4305
4286
|
}
|
|
4306
4287
|
}
|
|
4307
4288
|
|
|
@@ -4339,7 +4320,7 @@ class RefreshTokenEntity extends CredentialEntity {
|
|
|
4339
4320
|
static createRefreshTokenEntity(homeAccountId, environment, refreshToken, clientId, familyId, userAssertionHash) {
|
|
4340
4321
|
const rtEntity = new RefreshTokenEntity();
|
|
4341
4322
|
rtEntity.clientId = clientId;
|
|
4342
|
-
rtEntity.credentialType =
|
|
4323
|
+
rtEntity.credentialType = CredentialType.REFRESH_TOKEN;
|
|
4343
4324
|
rtEntity.environment = environment;
|
|
4344
4325
|
rtEntity.homeAccountId = homeAccountId;
|
|
4345
4326
|
rtEntity.secret = refreshToken;
|
|
@@ -4361,7 +4342,7 @@ class RefreshTokenEntity extends CredentialEntity {
|
|
|
4361
4342
|
entity.hasOwnProperty("credentialType") &&
|
|
4362
4343
|
entity.hasOwnProperty("clientId") &&
|
|
4363
4344
|
entity.hasOwnProperty("secret") &&
|
|
4364
|
-
entity["credentialType"] ===
|
|
4345
|
+
entity["credentialType"] === CredentialType.REFRESH_TOKEN);
|
|
4365
4346
|
}
|
|
4366
4347
|
}
|
|
4367
4348
|
|
|
@@ -4623,8 +4604,8 @@ class UrlString {
|
|
|
4623
4604
|
const pathArray = urlObject.PathSegments;
|
|
4624
4605
|
if (tenantId &&
|
|
4625
4606
|
pathArray.length !== 0 &&
|
|
4626
|
-
(pathArray[0] ===
|
|
4627
|
-
pathArray[0] ===
|
|
4607
|
+
(pathArray[0] === AADAuthorityConstants.COMMON ||
|
|
4608
|
+
pathArray[0] === AADAuthorityConstants.ORGANIZATIONS)) {
|
|
4628
4609
|
pathArray[0] = tenantId;
|
|
4629
4610
|
}
|
|
4630
4611
|
return UrlString.constructAuthorityUriFromObject(urlObject);
|
|
@@ -4783,212 +4764,210 @@ class UrlString {
|
|
|
4783
4764
|
* @export
|
|
4784
4765
|
* @enum {number}
|
|
4785
4766
|
*/
|
|
4786
|
-
|
|
4787
|
-
(function (PerformanceEvents) {
|
|
4767
|
+
const PerformanceEvents = {
|
|
4788
4768
|
/**
|
|
4789
4769
|
* acquireTokenByCode API (msal-browser and msal-node).
|
|
4790
4770
|
* Used to acquire tokens by trading an authorization code against the token endpoint.
|
|
4791
4771
|
*/
|
|
4792
|
-
|
|
4772
|
+
AcquireTokenByCode: "acquireTokenByCode",
|
|
4793
4773
|
/**
|
|
4794
4774
|
* acquireTokenByRefreshToken API (msal-browser and msal-node).
|
|
4795
4775
|
* Used to renew an access token using a refresh token against the token endpoint.
|
|
4796
4776
|
*/
|
|
4797
|
-
|
|
4777
|
+
AcquireTokenByRefreshToken: "acquireTokenByRefreshToken",
|
|
4798
4778
|
/**
|
|
4799
4779
|
* acquireTokenSilent API (msal-browser and msal-node).
|
|
4800
4780
|
* Used to silently acquire a new access token (from the cache or the network).
|
|
4801
4781
|
*/
|
|
4802
|
-
|
|
4782
|
+
AcquireTokenSilent: "acquireTokenSilent",
|
|
4803
4783
|
/**
|
|
4804
4784
|
* acquireTokenSilentAsync (msal-browser).
|
|
4805
4785
|
* Internal API for acquireTokenSilent.
|
|
4806
4786
|
*/
|
|
4807
|
-
|
|
4787
|
+
AcquireTokenSilentAsync: "acquireTokenSilentAsync",
|
|
4808
4788
|
/**
|
|
4809
4789
|
* acquireTokenPopup (msal-browser).
|
|
4810
4790
|
* Used to acquire a new access token interactively through pop ups
|
|
4811
4791
|
*/
|
|
4812
|
-
|
|
4792
|
+
AcquireTokenPopup: "acquireTokenPopup",
|
|
4813
4793
|
/**
|
|
4814
4794
|
* getPublicKeyThumbprint API in CryptoOpts class (msal-browser).
|
|
4815
4795
|
* Used to generate a public/private keypair and generate a public key thumbprint for pop requests.
|
|
4816
4796
|
*/
|
|
4817
|
-
|
|
4797
|
+
CryptoOptsGetPublicKeyThumbprint: "cryptoOptsGetPublicKeyThumbprint",
|
|
4818
4798
|
/**
|
|
4819
4799
|
* signJwt API in CryptoOpts class (msal-browser).
|
|
4820
4800
|
* Used to signed a pop token.
|
|
4821
4801
|
*/
|
|
4822
|
-
|
|
4802
|
+
CryptoOptsSignJwt: "cryptoOptsSignJwt",
|
|
4823
4803
|
/**
|
|
4824
4804
|
* acquireToken API in the SilentCacheClient class (msal-browser).
|
|
4825
4805
|
* Used to read access tokens from the cache.
|
|
4826
4806
|
*/
|
|
4827
|
-
|
|
4807
|
+
SilentCacheClientAcquireToken: "silentCacheClientAcquireToken",
|
|
4828
4808
|
/**
|
|
4829
4809
|
* acquireToken API in the SilentIframeClient class (msal-browser).
|
|
4830
4810
|
* Used to acquire a new set of tokens from the authorize endpoint in a hidden iframe.
|
|
4831
4811
|
*/
|
|
4832
|
-
|
|
4812
|
+
SilentIframeClientAcquireToken: "silentIframeClientAcquireToken",
|
|
4833
4813
|
/**
|
|
4834
4814
|
* acquireToken API in SilentRereshClient (msal-browser).
|
|
4835
4815
|
* Used to acquire a new set of tokens from the token endpoint using a refresh token.
|
|
4836
4816
|
*/
|
|
4837
|
-
|
|
4817
|
+
SilentRefreshClientAcquireToken: "silentRefreshClientAcquireToken",
|
|
4838
4818
|
/**
|
|
4839
4819
|
* ssoSilent API (msal-browser).
|
|
4840
4820
|
* Used to silently acquire an authorization code and set of tokens using a hidden iframe.
|
|
4841
4821
|
*/
|
|
4842
|
-
|
|
4822
|
+
SsoSilent: "ssoSilent",
|
|
4843
4823
|
/**
|
|
4844
4824
|
* getDiscoveredAuthority API in StandardInteractionClient class (msal-browser).
|
|
4845
4825
|
* Used to load authority metadata for a request.
|
|
4846
4826
|
*/
|
|
4847
|
-
|
|
4827
|
+
StandardInteractionClientGetDiscoveredAuthority: "standardInteractionClientGetDiscoveredAuthority",
|
|
4848
4828
|
/**
|
|
4849
4829
|
* acquireToken APIs in msal-browser.
|
|
4850
4830
|
* Used to make an /authorize endpoint call with native brokering enabled.
|
|
4851
4831
|
*/
|
|
4852
|
-
|
|
4832
|
+
FetchAccountIdWithNativeBroker: "fetchAccountIdWithNativeBroker",
|
|
4853
4833
|
/**
|
|
4854
4834
|
* acquireToken API in NativeInteractionClient class (msal-browser).
|
|
4855
4835
|
* Used to acquire a token from Native component when native brokering is enabled.
|
|
4856
4836
|
*/
|
|
4857
|
-
|
|
4837
|
+
NativeInteractionClientAcquireToken: "nativeInteractionClientAcquireToken",
|
|
4858
4838
|
/**
|
|
4859
4839
|
* Time spent creating default headers for requests to token endpoint
|
|
4860
4840
|
*/
|
|
4861
|
-
|
|
4841
|
+
BaseClientCreateTokenRequestHeaders: "baseClientCreateTokenRequestHeaders",
|
|
4862
4842
|
/**
|
|
4863
4843
|
* Used to measure the time taken for completing embedded-broker handshake (PW-Broker).
|
|
4864
4844
|
*/
|
|
4865
|
-
|
|
4845
|
+
BrokerHandhshake: "brokerHandshake",
|
|
4866
4846
|
/**
|
|
4867
4847
|
* acquireTokenByRefreshToken API in BrokerClientApplication (PW-Broker) .
|
|
4868
4848
|
*/
|
|
4869
|
-
|
|
4849
|
+
AcquireTokenByRefreshTokenInBroker: "acquireTokenByRefreshTokenInBroker",
|
|
4870
4850
|
/**
|
|
4871
4851
|
* Time taken for token acquisition by broker
|
|
4872
4852
|
*/
|
|
4873
|
-
|
|
4853
|
+
AcquireTokenByBroker: "acquireTokenByBroker",
|
|
4874
4854
|
/**
|
|
4875
4855
|
* Time spent on the network for refresh token acquisition
|
|
4876
4856
|
*/
|
|
4877
|
-
|
|
4857
|
+
RefreshTokenClientExecuteTokenRequest: "refreshTokenClientExecuteTokenRequest",
|
|
4878
4858
|
/**
|
|
4879
4859
|
* Time taken for acquiring refresh token , records RT size
|
|
4880
4860
|
*/
|
|
4881
|
-
|
|
4861
|
+
RefreshTokenClientAcquireToken: "refreshTokenClientAcquireToken",
|
|
4882
4862
|
/**
|
|
4883
4863
|
* Time taken for acquiring cached refresh token
|
|
4884
4864
|
*/
|
|
4885
|
-
|
|
4865
|
+
RefreshTokenClientAcquireTokenWithCachedRefreshToken: "refreshTokenClientAcquireTokenWithCachedRefreshToken",
|
|
4886
4866
|
/**
|
|
4887
4867
|
* acquireTokenByRefreshToken API in RefreshTokenClient (msal-common).
|
|
4888
4868
|
*/
|
|
4889
|
-
|
|
4869
|
+
RefreshTokenClientAcquireTokenByRefreshToken: "refreshTokenClientAcquireTokenByRefreshToken",
|
|
4890
4870
|
/**
|
|
4891
4871
|
* Helper function to create token request body in RefreshTokenClient (msal-common).
|
|
4892
4872
|
*/
|
|
4893
|
-
|
|
4873
|
+
RefreshTokenClientCreateTokenRequestBody: "refreshTokenClientCreateTokenRequestBody",
|
|
4894
4874
|
/**
|
|
4895
4875
|
* acquireTokenFromCache (msal-browser).
|
|
4896
4876
|
* Internal API for acquiring token from cache
|
|
4897
4877
|
*/
|
|
4898
|
-
|
|
4878
|
+
AcquireTokenFromCache: "acquireTokenFromCache",
|
|
4899
4879
|
/**
|
|
4900
4880
|
* acquireTokenBySilentIframe (msal-browser).
|
|
4901
4881
|
* Internal API for acquiring token by silent Iframe
|
|
4902
4882
|
*/
|
|
4903
|
-
|
|
4883
|
+
AcquireTokenBySilentIframe: "acquireTokenBySilentIframe",
|
|
4904
4884
|
/**
|
|
4905
4885
|
* Internal API for initializing base request in BaseInteractionClient (msal-browser)
|
|
4906
4886
|
*/
|
|
4907
|
-
|
|
4887
|
+
InitializeBaseRequest: "initializeBaseRequest",
|
|
4908
4888
|
/**
|
|
4909
4889
|
* Internal API for initializing silent request in SilentCacheClient (msal-browser)
|
|
4910
4890
|
*/
|
|
4911
|
-
|
|
4912
|
-
|
|
4891
|
+
InitializeSilentRequest: "initializeSilentRequest",
|
|
4892
|
+
InitializeClientApplication: "initializeClientApplication",
|
|
4913
4893
|
/**
|
|
4914
4894
|
* Helper function in SilentIframeClient class (msal-browser).
|
|
4915
4895
|
*/
|
|
4916
|
-
|
|
4896
|
+
SilentIframeClientTokenHelper: "silentIframeClientTokenHelper",
|
|
4917
4897
|
/**
|
|
4918
4898
|
* SilentHandler
|
|
4919
4899
|
*/
|
|
4920
|
-
|
|
4921
|
-
|
|
4922
|
-
|
|
4900
|
+
SilentHandlerInitiateAuthRequest: "silentHandlerInitiateAuthRequest",
|
|
4901
|
+
SilentHandlerMonitorIframeForHash: "silentHandlerMonitorIframeForHash",
|
|
4902
|
+
SilentHandlerLoadFrame: "silentHandlerLoadFrame",
|
|
4923
4903
|
/**
|
|
4924
4904
|
* Helper functions in StandardInteractionClient class (msal-browser)
|
|
4925
4905
|
*/
|
|
4926
|
-
|
|
4927
|
-
|
|
4928
|
-
|
|
4929
|
-
|
|
4906
|
+
StandardInteractionClientCreateAuthCodeClient: "standardInteractionClientCreateAuthCodeClient",
|
|
4907
|
+
StandardInteractionClientGetClientConfiguration: "standardInteractionClientGetClientConfiguration",
|
|
4908
|
+
StandardInteractionClientInitializeAuthorizationRequest: "standardInteractionClientInitializeAuthorizationRequest",
|
|
4909
|
+
StandardInteractionClientInitializeAuthorizationCodeRequest: "standardInteractionClientInitializeAuthorizationCodeRequest",
|
|
4930
4910
|
/**
|
|
4931
4911
|
* getAuthCodeUrl API (msal-browser and msal-node).
|
|
4932
4912
|
*/
|
|
4933
|
-
|
|
4913
|
+
GetAuthCodeUrl: "getAuthCodeUrl",
|
|
4934
4914
|
/**
|
|
4935
4915
|
* Functions from InteractionHandler (msal-browser)
|
|
4936
4916
|
*/
|
|
4937
|
-
|
|
4938
|
-
|
|
4939
|
-
|
|
4917
|
+
HandleCodeResponseFromServer: "handleCodeResponseFromServer",
|
|
4918
|
+
HandleCodeResponseFromHash: "handleCodeResponseFromHash",
|
|
4919
|
+
UpdateTokenEndpointAuthority: "updateTokenEndpointAuthority",
|
|
4940
4920
|
/**
|
|
4941
4921
|
* APIs in Authorization Code Client (msal-common)
|
|
4942
4922
|
*/
|
|
4943
|
-
|
|
4944
|
-
|
|
4945
|
-
|
|
4946
|
-
|
|
4923
|
+
AuthClientAcquireToken: "authClientAcquireToken",
|
|
4924
|
+
AuthClientExecuteTokenRequest: "authClientExecuteTokenRequest",
|
|
4925
|
+
AuthClientCreateTokenRequestBody: "authClientCreateTokenRequestBody",
|
|
4926
|
+
AuthClientCreateQueryString: "authClientCreateQueryString",
|
|
4947
4927
|
/**
|
|
4948
4928
|
* Generate functions in PopTokenGenerator (msal-common)
|
|
4949
4929
|
*/
|
|
4950
|
-
|
|
4951
|
-
|
|
4930
|
+
PopTokenGenerateCnf: "popTokenGenerateCnf",
|
|
4931
|
+
PopTokenGenerateKid: "popTokenGenerateKid",
|
|
4952
4932
|
/**
|
|
4953
4933
|
* handleServerTokenResponse API in ResponseHandler (msal-common)
|
|
4954
4934
|
*/
|
|
4955
|
-
|
|
4935
|
+
HandleServerTokenResponse: "handleServerTokenResponse",
|
|
4956
4936
|
/**
|
|
4957
4937
|
* Authority functions
|
|
4958
4938
|
*/
|
|
4959
|
-
|
|
4960
|
-
|
|
4961
|
-
|
|
4962
|
-
|
|
4963
|
-
|
|
4964
|
-
|
|
4965
|
-
|
|
4939
|
+
AuthorityFactoryCreateDiscoveredInstance: "authorityFactoryCreateDiscoveredInstance",
|
|
4940
|
+
AuthorityResolveEndpointsAsync: "authorityResolveEndpointsAsync",
|
|
4941
|
+
AuthorityGetCloudDiscoveryMetadataFromNetwork: "authorityGetCloudDiscoveryMetadataFromNetwork",
|
|
4942
|
+
AuthorityUpdateCloudDiscoveryMetadata: "authorityUpdateCloudDiscoveryMetadata",
|
|
4943
|
+
AuthorityGetEndpointMetadataFromNetwork: "authorityGetEndpointMetadataFromNetwork",
|
|
4944
|
+
AuthorityUpdateEndpointMetadata: "authorityUpdateEndpointMetadata",
|
|
4945
|
+
AuthorityUpdateMetadataWithRegionalInformation: "authorityUpdateMetadataWithRegionalInformation",
|
|
4966
4946
|
/**
|
|
4967
4947
|
* Region Discovery functions
|
|
4968
4948
|
*/
|
|
4969
|
-
|
|
4970
|
-
|
|
4971
|
-
|
|
4972
|
-
|
|
4973
|
-
|
|
4974
|
-
|
|
4975
|
-
|
|
4976
|
-
|
|
4977
|
-
|
|
4978
|
-
|
|
4979
|
-
}
|
|
4949
|
+
RegionDiscoveryDetectRegion: "regionDiscoveryDetectRegion",
|
|
4950
|
+
RegionDiscoveryGetRegionFromIMDS: "regionDiscoveryGetRegionFromIMDS",
|
|
4951
|
+
RegionDiscoveryGetCurrentVersion: "regionDiscoveryGetCurrentVersion",
|
|
4952
|
+
AcquireTokenByCodeAsync: "acquireTokenByCodeAsync",
|
|
4953
|
+
GetEndpointMetadataFromNetwork: "getEndpointMetadataFromNetwork",
|
|
4954
|
+
GetCloudDiscoveryMetadataFromNetworkMeasurement: "getCloudDiscoveryMetadataFromNetworkMeasurement",
|
|
4955
|
+
HandleRedirectPromiseMeasurement: "handleRedirectPromiseMeasurement",
|
|
4956
|
+
UpdateCloudDiscoveryMetadataMeasurement: "updateCloudDiscoveryMetadataMeasurement",
|
|
4957
|
+
UsernamePasswordClientAcquireToken: "usernamePasswordClientAcquireToken",
|
|
4958
|
+
NativeMessageHandlerHandshake: "nativeMessageHandlerHandshake",
|
|
4959
|
+
};
|
|
4980
4960
|
/**
|
|
4981
4961
|
* State of the performance event.
|
|
4982
4962
|
*
|
|
4983
4963
|
* @export
|
|
4984
4964
|
* @enum {number}
|
|
4985
4965
|
*/
|
|
4986
|
-
|
|
4987
|
-
|
|
4988
|
-
|
|
4989
|
-
|
|
4990
|
-
|
|
4991
|
-
})(exports.PerformanceEventStatus || (exports.PerformanceEventStatus = {}));
|
|
4966
|
+
const PerformanceEventStatus = {
|
|
4967
|
+
NotStarted: 0,
|
|
4968
|
+
InProgress: 1,
|
|
4969
|
+
Completed: 2,
|
|
4970
|
+
};
|
|
4992
4971
|
const IntFields = new Set([
|
|
4993
4972
|
"accessTokenSize",
|
|
4994
4973
|
"durationMs",
|
|
@@ -5005,11 +4984,10 @@ const IntFields = new Set([
|
|
|
5005
4984
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
5006
4985
|
* Licensed under the MIT License.
|
|
5007
4986
|
*/
|
|
5008
|
-
|
|
5009
|
-
|
|
5010
|
-
|
|
5011
|
-
|
|
5012
|
-
})(KeyLocation || (KeyLocation = {}));
|
|
4987
|
+
const KeyLocation = {
|
|
4988
|
+
SW: "sw",
|
|
4989
|
+
UHW: "uhw",
|
|
4990
|
+
};
|
|
5013
4991
|
class PopTokenGenerator {
|
|
5014
4992
|
constructor(cryptoUtils, performanceClient) {
|
|
5015
4993
|
this.cryptoUtils = cryptoUtils;
|
|
@@ -5022,8 +5000,8 @@ class PopTokenGenerator {
|
|
|
5022
5000
|
* @returns
|
|
5023
5001
|
*/
|
|
5024
5002
|
async generateCnf(request) {
|
|
5025
|
-
this.performanceClient?.addQueueMeasurement(
|
|
5026
|
-
this.performanceClient?.setPreQueueTime(
|
|
5003
|
+
this.performanceClient?.addQueueMeasurement(PerformanceEvents.PopTokenGenerateCnf, request.correlationId);
|
|
5004
|
+
this.performanceClient?.setPreQueueTime(PerformanceEvents.PopTokenGenerateKid, request.correlationId);
|
|
5027
5005
|
const reqCnf = await this.generateKid(request);
|
|
5028
5006
|
const reqCnfString = this.cryptoUtils.base64Encode(JSON.stringify(reqCnf));
|
|
5029
5007
|
return {
|
|
@@ -5038,7 +5016,7 @@ class PopTokenGenerator {
|
|
|
5038
5016
|
* @returns
|
|
5039
5017
|
*/
|
|
5040
5018
|
async generateKid(request) {
|
|
5041
|
-
this.performanceClient?.addQueueMeasurement(
|
|
5019
|
+
this.performanceClient?.addQueueMeasurement(PerformanceEvents.PopTokenGenerateKid, request.correlationId);
|
|
5042
5020
|
const kidThumbprint = await this.cryptoUtils.getPublicKeyThumbprint(request);
|
|
5043
5021
|
return {
|
|
5044
5022
|
kid: kidThumbprint,
|
|
@@ -5246,7 +5224,7 @@ class ResponseHandler {
|
|
|
5246
5224
|
* @param authority
|
|
5247
5225
|
*/
|
|
5248
5226
|
async handleServerTokenResponse(serverTokenResponse, authority, reqTimestamp, request, authCodePayload, userAssertionHash, handlingRefreshTokenResponse, forceCacheRefreshTokenResponse, serverRequestId) {
|
|
5249
|
-
this.performanceClient?.addQueueMeasurement(
|
|
5227
|
+
this.performanceClient?.addQueueMeasurement(PerformanceEvents.HandleServerTokenResponse, serverTokenResponse.correlation_id);
|
|
5250
5228
|
// create an idToken object (not entity)
|
|
5251
5229
|
let idTokenObj;
|
|
5252
5230
|
if (serverTokenResponse.id_token) {
|
|
@@ -5389,7 +5367,7 @@ class ResponseHandler {
|
|
|
5389
5367
|
? authCodePayload.msgraph_host
|
|
5390
5368
|
: Constants.EMPTY_STRING;
|
|
5391
5369
|
// ADFS does not require client_info in the response
|
|
5392
|
-
if (authorityType ===
|
|
5370
|
+
if (authorityType === AuthorityType.Adfs) {
|
|
5393
5371
|
this.logger.verbose("Authority type is ADFS, creating ADFS account");
|
|
5394
5372
|
return AccountEntity.createGenericAccount(this.homeAccountIdentifier, idToken, authority, cloudGraphHostName, msGraphhost);
|
|
5395
5373
|
}
|
|
@@ -5419,7 +5397,7 @@ class ResponseHandler {
|
|
|
5419
5397
|
let extExpiresOn;
|
|
5420
5398
|
let familyId = Constants.EMPTY_STRING;
|
|
5421
5399
|
if (cacheRecord.accessToken) {
|
|
5422
|
-
if (cacheRecord.accessToken.tokenType ===
|
|
5400
|
+
if (cacheRecord.accessToken.tokenType === AuthenticationScheme.POP) {
|
|
5423
5401
|
const popTokenGenerator = new PopTokenGenerator(cryptoObj);
|
|
5424
5402
|
const { secret, keyId } = cacheRecord.accessToken;
|
|
5425
5403
|
if (!keyId) {
|
|
@@ -5503,8 +5481,8 @@ class AuthorizationCodeClient extends BaseClient {
|
|
|
5503
5481
|
* @param request
|
|
5504
5482
|
*/
|
|
5505
5483
|
async getAuthCodeUrl(request) {
|
|
5506
|
-
this.performanceClient?.addQueueMeasurement(
|
|
5507
|
-
this.performanceClient?.setPreQueueTime(
|
|
5484
|
+
this.performanceClient?.addQueueMeasurement(PerformanceEvents.GetAuthCodeUrl, request.correlationId);
|
|
5485
|
+
this.performanceClient?.setPreQueueTime(PerformanceEvents.AuthClientCreateQueryString, request.correlationId);
|
|
5508
5486
|
const queryString = await this.createAuthCodeUrlQueryString(request);
|
|
5509
5487
|
return UrlString.appendQueryString(this.authority.authorizationEndpoint, queryString);
|
|
5510
5488
|
}
|
|
@@ -5517,17 +5495,17 @@ class AuthorizationCodeClient extends BaseClient {
|
|
|
5517
5495
|
if (!request || !request.code) {
|
|
5518
5496
|
throw ClientAuthError.createTokenRequestCannotBeMadeError();
|
|
5519
5497
|
}
|
|
5520
|
-
this.performanceClient?.addQueueMeasurement(
|
|
5498
|
+
this.performanceClient?.addQueueMeasurement(PerformanceEvents.AuthClientAcquireToken, request.correlationId);
|
|
5521
5499
|
const atsMeasurement = this.performanceClient?.startMeasurement(
|
|
5522
5500
|
// @ts-ignore
|
|
5523
5501
|
"AuthCodeClientAcquireToken", request.correlationId);
|
|
5524
5502
|
this.logger.info("in acquireToken call in auth-code client");
|
|
5525
5503
|
const reqTimestamp = TimeUtils.nowSeconds();
|
|
5526
|
-
this.performanceClient?.setPreQueueTime(
|
|
5504
|
+
this.performanceClient?.setPreQueueTime(PerformanceEvents.AuthClientExecuteTokenRequest, request.correlationId);
|
|
5527
5505
|
const response = await this.executeTokenRequest(this.authority, request);
|
|
5528
5506
|
// Retrieve requestId from response headers
|
|
5529
|
-
const requestId = response.headers?.[
|
|
5530
|
-
const httpVerAuthority = response.headers?.[
|
|
5507
|
+
const requestId = response.headers?.[HeaderNames.X_MS_REQUEST_ID];
|
|
5508
|
+
const httpVerAuthority = response.headers?.[HeaderNames.X_MS_HTTP_VERSION];
|
|
5531
5509
|
if (httpVerAuthority) {
|
|
5532
5510
|
atsMeasurement?.addStaticFields({
|
|
5533
5511
|
httpVerAuthority,
|
|
@@ -5536,7 +5514,7 @@ class AuthorizationCodeClient extends BaseClient {
|
|
|
5536
5514
|
const responseHandler = new ResponseHandler(this.config.authOptions.clientId, this.cacheManager, this.cryptoUtils, this.logger, this.config.serializableCache, this.config.persistencePlugin, this.performanceClient);
|
|
5537
5515
|
// Validate response. This function throws a server error if an error is returned by the server.
|
|
5538
5516
|
responseHandler.validateTokenResponse(response.body);
|
|
5539
|
-
this.performanceClient?.setPreQueueTime(
|
|
5517
|
+
this.performanceClient?.setPreQueueTime(PerformanceEvents.HandleServerTokenResponse, request.correlationId);
|
|
5540
5518
|
return responseHandler
|
|
5541
5519
|
.handleServerTokenResponse(response.body, this.authority, reqTimestamp, request, authCodePayload, undefined, undefined, undefined, requestId)
|
|
5542
5520
|
.then((result) => {
|
|
@@ -5599,8 +5577,8 @@ class AuthorizationCodeClient extends BaseClient {
|
|
|
5599
5577
|
* @param request
|
|
5600
5578
|
*/
|
|
5601
5579
|
async executeTokenRequest(authority, request) {
|
|
5602
|
-
this.performanceClient?.addQueueMeasurement(
|
|
5603
|
-
this.performanceClient?.setPreQueueTime(
|
|
5580
|
+
this.performanceClient?.addQueueMeasurement(PerformanceEvents.AuthClientExecuteTokenRequest, request.correlationId);
|
|
5581
|
+
this.performanceClient?.setPreQueueTime(PerformanceEvents.AuthClientCreateTokenRequestBody, request.correlationId);
|
|
5604
5582
|
const queryParametersString = this.createTokenQueryParameters(request);
|
|
5605
5583
|
const endpoint = UrlString.appendQueryString(authority.tokenEndpoint, queryParametersString);
|
|
5606
5584
|
const requestBody = await this.createTokenRequestBody(request);
|
|
@@ -5610,7 +5588,7 @@ class AuthorizationCodeClient extends BaseClient {
|
|
|
5610
5588
|
const clientInfo = buildClientInfo(request.clientInfo, this.cryptoUtils);
|
|
5611
5589
|
ccsCredential = {
|
|
5612
5590
|
credential: `${clientInfo.uid}${Separators.CLIENT_INFO_SEPARATOR}${clientInfo.utid}`,
|
|
5613
|
-
type:
|
|
5591
|
+
type: CcsCredentialType.HOME_ACCOUNT_ID,
|
|
5614
5592
|
};
|
|
5615
5593
|
}
|
|
5616
5594
|
catch (e) {
|
|
@@ -5636,7 +5614,7 @@ class AuthorizationCodeClient extends BaseClient {
|
|
|
5636
5614
|
* @param request
|
|
5637
5615
|
*/
|
|
5638
5616
|
async createTokenRequestBody(request) {
|
|
5639
|
-
this.performanceClient?.addQueueMeasurement(
|
|
5617
|
+
this.performanceClient?.addQueueMeasurement(PerformanceEvents.AuthClientCreateTokenRequestBody, request.correlationId);
|
|
5640
5618
|
const parameterBuilder = new RequestParameterBuilder();
|
|
5641
5619
|
parameterBuilder.addClientId(this.config.authOptions.clientId);
|
|
5642
5620
|
/*
|
|
@@ -5674,16 +5652,16 @@ class AuthorizationCodeClient extends BaseClient {
|
|
|
5674
5652
|
parameterBuilder.addClientAssertion(clientAssertion.assertion);
|
|
5675
5653
|
parameterBuilder.addClientAssertionType(clientAssertion.assertionType);
|
|
5676
5654
|
}
|
|
5677
|
-
parameterBuilder.addGrantType(
|
|
5655
|
+
parameterBuilder.addGrantType(GrantType.AUTHORIZATION_CODE_GRANT);
|
|
5678
5656
|
parameterBuilder.addClientInfo();
|
|
5679
|
-
if (request.authenticationScheme ===
|
|
5657
|
+
if (request.authenticationScheme === AuthenticationScheme.POP) {
|
|
5680
5658
|
const popTokenGenerator = new PopTokenGenerator(this.cryptoUtils, this.performanceClient);
|
|
5681
|
-
this.performanceClient?.setPreQueueTime(
|
|
5659
|
+
this.performanceClient?.setPreQueueTime(PerformanceEvents.PopTokenGenerateCnf, request.correlationId);
|
|
5682
5660
|
const reqCnfData = await popTokenGenerator.generateCnf(request);
|
|
5683
5661
|
// SPA PoP requires full Base64Url encoded req_cnf string (unhashed)
|
|
5684
5662
|
parameterBuilder.addPopToken(reqCnfData.reqCnfString);
|
|
5685
5663
|
}
|
|
5686
|
-
else if (request.authenticationScheme ===
|
|
5664
|
+
else if (request.authenticationScheme === AuthenticationScheme.SSH) {
|
|
5687
5665
|
if (request.sshJwk) {
|
|
5688
5666
|
parameterBuilder.addSshJwk(request.sshJwk);
|
|
5689
5667
|
}
|
|
@@ -5705,7 +5683,7 @@ class AuthorizationCodeClient extends BaseClient {
|
|
|
5705
5683
|
const clientInfo = buildClientInfo(request.clientInfo, this.cryptoUtils);
|
|
5706
5684
|
ccsCred = {
|
|
5707
5685
|
credential: `${clientInfo.uid}${Separators.CLIENT_INFO_SEPARATOR}${clientInfo.utid}`,
|
|
5708
|
-
type:
|
|
5686
|
+
type: CcsCredentialType.HOME_ACCOUNT_ID,
|
|
5709
5687
|
};
|
|
5710
5688
|
}
|
|
5711
5689
|
catch (e) {
|
|
@@ -5718,7 +5696,7 @@ class AuthorizationCodeClient extends BaseClient {
|
|
|
5718
5696
|
// Adds these as parameters in the request instead of headers to prevent CORS preflight request
|
|
5719
5697
|
if (this.config.systemOptions.preventCorsPreflight && ccsCred) {
|
|
5720
5698
|
switch (ccsCred.type) {
|
|
5721
|
-
case
|
|
5699
|
+
case CcsCredentialType.HOME_ACCOUNT_ID:
|
|
5722
5700
|
try {
|
|
5723
5701
|
const clientInfo = buildClientInfoFromHomeAccountId(ccsCred.credential);
|
|
5724
5702
|
parameterBuilder.addCcsOid(clientInfo);
|
|
@@ -5728,7 +5706,7 @@ class AuthorizationCodeClient extends BaseClient {
|
|
|
5728
5706
|
e);
|
|
5729
5707
|
}
|
|
5730
5708
|
break;
|
|
5731
|
-
case
|
|
5709
|
+
case CcsCredentialType.UPN:
|
|
5732
5710
|
parameterBuilder.addCcsUpn(ccsCred.credential);
|
|
5733
5711
|
break;
|
|
5734
5712
|
}
|
|
@@ -5739,9 +5717,9 @@ class AuthorizationCodeClient extends BaseClient {
|
|
|
5739
5717
|
// Add hybrid spa parameters if not already provided
|
|
5740
5718
|
if (request.enableSpaAuthorizationCode &&
|
|
5741
5719
|
(!request.tokenBodyParameters ||
|
|
5742
|
-
!request.tokenBodyParameters[
|
|
5720
|
+
!request.tokenBodyParameters[AADServerParamKeys.RETURN_SPA_CODE])) {
|
|
5743
5721
|
parameterBuilder.addExtraQueryParameters({
|
|
5744
|
-
[
|
|
5722
|
+
[AADServerParamKeys.RETURN_SPA_CODE]: "1",
|
|
5745
5723
|
});
|
|
5746
5724
|
}
|
|
5747
5725
|
return parameterBuilder.createQueryString();
|
|
@@ -5751,7 +5729,7 @@ class AuthorizationCodeClient extends BaseClient {
|
|
|
5751
5729
|
* @param request
|
|
5752
5730
|
*/
|
|
5753
5731
|
async createAuthCodeUrlQueryString(request) {
|
|
5754
|
-
this.performanceClient?.addQueueMeasurement(
|
|
5732
|
+
this.performanceClient?.addQueueMeasurement(PerformanceEvents.AuthClientCreateQueryString, request.correlationId);
|
|
5755
5733
|
const parameterBuilder = new RequestParameterBuilder();
|
|
5756
5734
|
parameterBuilder.addClientId(this.config.authOptions.clientId);
|
|
5757
5735
|
const requestScopes = [
|
|
@@ -5866,7 +5844,7 @@ class AuthorizationCodeClient extends BaseClient {
|
|
|
5866
5844
|
// signal ests that this is a WAM call
|
|
5867
5845
|
parameterBuilder.addNativeBroker();
|
|
5868
5846
|
// pass the req_cnf for POP
|
|
5869
|
-
if (request.authenticationScheme ===
|
|
5847
|
+
if (request.authenticationScheme === AuthenticationScheme.POP) {
|
|
5870
5848
|
const popTokenGenerator = new PopTokenGenerator(this.cryptoUtils);
|
|
5871
5849
|
// to reduce the URL length, it is recommended to send the hash of the req_cnf instead of the whole string
|
|
5872
5850
|
const reqCnfData = await popTokenGenerator.generateCnf(request);
|
|
@@ -5925,13 +5903,13 @@ class RefreshTokenClient extends BaseClient {
|
|
|
5925
5903
|
super(configuration, performanceClient);
|
|
5926
5904
|
}
|
|
5927
5905
|
async acquireToken(request) {
|
|
5928
|
-
this.performanceClient?.addQueueMeasurement(
|
|
5929
|
-
const atsMeasurement = this.performanceClient?.startMeasurement(
|
|
5906
|
+
this.performanceClient?.addQueueMeasurement(PerformanceEvents.RefreshTokenClientAcquireToken, request.correlationId);
|
|
5907
|
+
const atsMeasurement = this.performanceClient?.startMeasurement(PerformanceEvents.RefreshTokenClientAcquireToken, request.correlationId);
|
|
5930
5908
|
this.logger.verbose("RefreshTokenClientAcquireToken called", request.correlationId);
|
|
5931
5909
|
const reqTimestamp = TimeUtils.nowSeconds();
|
|
5932
|
-
this.performanceClient?.setPreQueueTime(
|
|
5910
|
+
this.performanceClient?.setPreQueueTime(PerformanceEvents.RefreshTokenClientExecuteTokenRequest, request.correlationId);
|
|
5933
5911
|
const response = await this.executeTokenRequest(request, this.authority);
|
|
5934
|
-
const httpVerToken = response.headers?.[
|
|
5912
|
+
const httpVerToken = response.headers?.[HeaderNames.X_MS_HTTP_VERSION];
|
|
5935
5913
|
atsMeasurement?.addStaticFields({
|
|
5936
5914
|
refreshTokenSize: response.body.refresh_token?.length || 0,
|
|
5937
5915
|
});
|
|
@@ -5941,10 +5919,10 @@ class RefreshTokenClient extends BaseClient {
|
|
|
5941
5919
|
});
|
|
5942
5920
|
}
|
|
5943
5921
|
// Retrieve requestId from response headers
|
|
5944
|
-
const requestId = response.headers?.[
|
|
5922
|
+
const requestId = response.headers?.[HeaderNames.X_MS_REQUEST_ID];
|
|
5945
5923
|
const responseHandler = new ResponseHandler(this.config.authOptions.clientId, this.cacheManager, this.cryptoUtils, this.logger, this.config.serializableCache, this.config.persistencePlugin);
|
|
5946
5924
|
responseHandler.validateTokenResponse(response.body);
|
|
5947
|
-
this.performanceClient?.setPreQueueTime(
|
|
5925
|
+
this.performanceClient?.setPreQueueTime(PerformanceEvents.HandleServerTokenResponse, request.correlationId);
|
|
5948
5926
|
return responseHandler
|
|
5949
5927
|
.handleServerTokenResponse(response.body, this.authority, reqTimestamp, request, undefined, undefined, true, request.forceCache, requestId)
|
|
5950
5928
|
.then((result) => {
|
|
@@ -5972,7 +5950,7 @@ class RefreshTokenClient extends BaseClient {
|
|
|
5972
5950
|
if (!request) {
|
|
5973
5951
|
throw ClientConfigurationError.createEmptyTokenRequestError();
|
|
5974
5952
|
}
|
|
5975
|
-
this.performanceClient?.addQueueMeasurement(
|
|
5953
|
+
this.performanceClient?.addQueueMeasurement(PerformanceEvents.RefreshTokenClientAcquireTokenByRefreshToken, request.correlationId);
|
|
5976
5954
|
// We currently do not support silent flow for account === null use cases; This will be revisited for confidential flow usecases
|
|
5977
5955
|
if (!request.account) {
|
|
5978
5956
|
throw ClientAuthError.createNoAccountInSilentRequestError();
|
|
@@ -5982,7 +5960,7 @@ class RefreshTokenClient extends BaseClient {
|
|
|
5982
5960
|
// if the app is part of the family, retrive a Family refresh token if present and make a refreshTokenRequest
|
|
5983
5961
|
if (isFOCI) {
|
|
5984
5962
|
try {
|
|
5985
|
-
this.performanceClient?.setPreQueueTime(
|
|
5963
|
+
this.performanceClient?.setPreQueueTime(PerformanceEvents.RefreshTokenClientAcquireTokenWithCachedRefreshToken, request.correlationId);
|
|
5986
5964
|
return this.acquireTokenWithCachedRefreshToken(request, true);
|
|
5987
5965
|
}
|
|
5988
5966
|
catch (e) {
|
|
@@ -5995,7 +5973,7 @@ class RefreshTokenClient extends BaseClient {
|
|
|
5995
5973
|
e.subError === Errors.CLIENT_MISMATCH_ERROR;
|
|
5996
5974
|
// if family Refresh Token (FRT) cache acquisition fails or if client_mismatch error is seen with FRT, reattempt with application Refresh Token (ART)
|
|
5997
5975
|
if (noFamilyRTInCache || clientMismatchErrorWithFamilyRT) {
|
|
5998
|
-
this.performanceClient?.setPreQueueTime(
|
|
5976
|
+
this.performanceClient?.setPreQueueTime(PerformanceEvents.RefreshTokenClientAcquireTokenWithCachedRefreshToken, request.correlationId);
|
|
5999
5977
|
return this.acquireTokenWithCachedRefreshToken(request, false);
|
|
6000
5978
|
// throw in all other cases
|
|
6001
5979
|
}
|
|
@@ -6005,7 +5983,7 @@ class RefreshTokenClient extends BaseClient {
|
|
|
6005
5983
|
}
|
|
6006
5984
|
}
|
|
6007
5985
|
// fall back to application refresh token acquisition
|
|
6008
|
-
this.performanceClient?.setPreQueueTime(
|
|
5986
|
+
this.performanceClient?.setPreQueueTime(PerformanceEvents.RefreshTokenClientAcquireTokenWithCachedRefreshToken, request.correlationId);
|
|
6009
5987
|
return this.acquireTokenWithCachedRefreshToken(request, false);
|
|
6010
5988
|
}
|
|
6011
5989
|
/**
|
|
@@ -6013,9 +5991,9 @@ class RefreshTokenClient extends BaseClient {
|
|
|
6013
5991
|
* @param request
|
|
6014
5992
|
*/
|
|
6015
5993
|
async acquireTokenWithCachedRefreshToken(request, foci) {
|
|
6016
|
-
this.performanceClient?.addQueueMeasurement(
|
|
5994
|
+
this.performanceClient?.addQueueMeasurement(PerformanceEvents.RefreshTokenClientAcquireTokenWithCachedRefreshToken, request.correlationId);
|
|
6017
5995
|
// fetches family RT or application RT based on FOCI value
|
|
6018
|
-
const atsMeasurement = this.performanceClient?.startMeasurement(
|
|
5996
|
+
const atsMeasurement = this.performanceClient?.startMeasurement(PerformanceEvents.RefreshTokenClientAcquireTokenWithCachedRefreshToken, request.correlationId);
|
|
6019
5997
|
this.logger.verbose("RefreshTokenClientAcquireTokenWithCachedRefreshToken called", request.correlationId);
|
|
6020
5998
|
const refreshToken = this.cacheManager.getRefreshToken(request.account, foci);
|
|
6021
5999
|
if (!refreshToken) {
|
|
@@ -6029,13 +6007,13 @@ class RefreshTokenClient extends BaseClient {
|
|
|
6029
6007
|
const refreshTokenRequest = {
|
|
6030
6008
|
...request,
|
|
6031
6009
|
refreshToken: refreshToken.secret,
|
|
6032
|
-
authenticationScheme: request.authenticationScheme ||
|
|
6010
|
+
authenticationScheme: request.authenticationScheme || AuthenticationScheme.BEARER,
|
|
6033
6011
|
ccsCredential: {
|
|
6034
6012
|
credential: request.account.homeAccountId,
|
|
6035
|
-
type:
|
|
6013
|
+
type: CcsCredentialType.HOME_ACCOUNT_ID,
|
|
6036
6014
|
},
|
|
6037
6015
|
};
|
|
6038
|
-
this.performanceClient?.setPreQueueTime(
|
|
6016
|
+
this.performanceClient?.setPreQueueTime(PerformanceEvents.RefreshTokenClientAcquireToken, request.correlationId);
|
|
6039
6017
|
return this.acquireToken(refreshTokenRequest);
|
|
6040
6018
|
}
|
|
6041
6019
|
/**
|
|
@@ -6044,9 +6022,9 @@ class RefreshTokenClient extends BaseClient {
|
|
|
6044
6022
|
* @param authority
|
|
6045
6023
|
*/
|
|
6046
6024
|
async executeTokenRequest(request, authority) {
|
|
6047
|
-
this.performanceClient?.addQueueMeasurement(
|
|
6048
|
-
const acquireTokenMeasurement = this.performanceClient?.startMeasurement(
|
|
6049
|
-
this.performanceClient?.setPreQueueTime(
|
|
6025
|
+
this.performanceClient?.addQueueMeasurement(PerformanceEvents.RefreshTokenClientExecuteTokenRequest, request.correlationId);
|
|
6026
|
+
const acquireTokenMeasurement = this.performanceClient?.startMeasurement(PerformanceEvents.RefreshTokenClientExecuteTokenRequest, request.correlationId);
|
|
6027
|
+
this.performanceClient?.setPreQueueTime(PerformanceEvents.RefreshTokenClientCreateTokenRequestBody, request.correlationId);
|
|
6050
6028
|
const queryParametersString = this.createTokenQueryParameters(request);
|
|
6051
6029
|
const endpoint = UrlString.appendQueryString(authority.tokenEndpoint, queryParametersString);
|
|
6052
6030
|
const requestBody = await this.createTokenRequestBody(request);
|
|
@@ -6081,13 +6059,13 @@ class RefreshTokenClient extends BaseClient {
|
|
|
6081
6059
|
* @param request
|
|
6082
6060
|
*/
|
|
6083
6061
|
async createTokenRequestBody(request) {
|
|
6084
|
-
this.performanceClient?.addQueueMeasurement(
|
|
6062
|
+
this.performanceClient?.addQueueMeasurement(PerformanceEvents.RefreshTokenClientCreateTokenRequestBody, request.correlationId);
|
|
6085
6063
|
const correlationId = request.correlationId;
|
|
6086
|
-
const acquireTokenMeasurement = this.performanceClient?.startMeasurement(
|
|
6064
|
+
const acquireTokenMeasurement = this.performanceClient?.startMeasurement(PerformanceEvents.BaseClientCreateTokenRequestHeaders, correlationId);
|
|
6087
6065
|
const parameterBuilder = new RequestParameterBuilder();
|
|
6088
6066
|
parameterBuilder.addClientId(this.config.authOptions.clientId);
|
|
6089
6067
|
parameterBuilder.addScopes(request.scopes);
|
|
6090
|
-
parameterBuilder.addGrantType(
|
|
6068
|
+
parameterBuilder.addGrantType(GrantType.REFRESH_TOKEN_GRANT);
|
|
6091
6069
|
parameterBuilder.addClientInfo();
|
|
6092
6070
|
parameterBuilder.addLibraryInfo(this.config.libraryInfo);
|
|
6093
6071
|
parameterBuilder.addApplicationTelemetry(this.config.telemetry.application);
|
|
@@ -6105,14 +6083,14 @@ class RefreshTokenClient extends BaseClient {
|
|
|
6105
6083
|
parameterBuilder.addClientAssertion(clientAssertion.assertion);
|
|
6106
6084
|
parameterBuilder.addClientAssertionType(clientAssertion.assertionType);
|
|
6107
6085
|
}
|
|
6108
|
-
if (request.authenticationScheme ===
|
|
6086
|
+
if (request.authenticationScheme === AuthenticationScheme.POP) {
|
|
6109
6087
|
const popTokenGenerator = new PopTokenGenerator(this.cryptoUtils, this.performanceClient);
|
|
6110
|
-
this.performanceClient?.setPreQueueTime(
|
|
6088
|
+
this.performanceClient?.setPreQueueTime(PerformanceEvents.PopTokenGenerateCnf, request.correlationId);
|
|
6111
6089
|
const reqCnfData = await popTokenGenerator.generateCnf(request);
|
|
6112
6090
|
// SPA PoP requires full Base64Url encoded req_cnf string (unhashed)
|
|
6113
6091
|
parameterBuilder.addPopToken(reqCnfData.reqCnfString);
|
|
6114
6092
|
}
|
|
6115
|
-
else if (request.authenticationScheme ===
|
|
6093
|
+
else if (request.authenticationScheme === AuthenticationScheme.SSH) {
|
|
6116
6094
|
if (request.sshJwk) {
|
|
6117
6095
|
parameterBuilder.addSshJwk(request.sshJwk);
|
|
6118
6096
|
}
|
|
@@ -6131,7 +6109,7 @@ class RefreshTokenClient extends BaseClient {
|
|
|
6131
6109
|
if (this.config.systemOptions.preventCorsPreflight &&
|
|
6132
6110
|
request.ccsCredential) {
|
|
6133
6111
|
switch (request.ccsCredential.type) {
|
|
6134
|
-
case
|
|
6112
|
+
case CcsCredentialType.HOME_ACCOUNT_ID:
|
|
6135
6113
|
try {
|
|
6136
6114
|
const clientInfo = buildClientInfoFromHomeAccountId(request.ccsCredential.credential);
|
|
6137
6115
|
parameterBuilder.addCcsOid(clientInfo);
|
|
@@ -6141,7 +6119,7 @@ class RefreshTokenClient extends BaseClient {
|
|
|
6141
6119
|
e);
|
|
6142
6120
|
}
|
|
6143
6121
|
break;
|
|
6144
|
-
case
|
|
6122
|
+
case CcsCredentialType.UPN:
|
|
6145
6123
|
parameterBuilder.addCcsUpn(request.ccsCredential.credential);
|
|
6146
6124
|
break;
|
|
6147
6125
|
}
|
|
@@ -6192,10 +6170,16 @@ class SilentFlowClient extends BaseClient {
|
|
|
6192
6170
|
}
|
|
6193
6171
|
if (request.forceRefresh) {
|
|
6194
6172
|
// Must refresh due to present force_refresh flag.
|
|
6195
|
-
this.serverTelemetryManager?.setCacheOutcome(
|
|
6173
|
+
this.serverTelemetryManager?.setCacheOutcome(CacheOutcome.FORCE_REFRESH);
|
|
6196
6174
|
this.logger.info("SilentFlowClient:acquireCachedToken - Skipping cache because forceRefresh is true.");
|
|
6197
6175
|
throw ClientAuthError.createRefreshRequiredError();
|
|
6198
6176
|
}
|
|
6177
|
+
else if (!this.config.cacheOptions.claimsBasedCachingEnabled &&
|
|
6178
|
+
!StringUtils.isEmptyObj(request.claims)) {
|
|
6179
|
+
// Must refresh due to request parameters.
|
|
6180
|
+
this.logger.info("SilentFlowClient:acquireCachedToken - Skipping cache because claims-based caching is disabled and claims were requested.");
|
|
6181
|
+
throw ClientAuthError.createRefreshRequiredError();
|
|
6182
|
+
}
|
|
6199
6183
|
// We currently do not support silent flow for account === null use cases; This will be revisited for confidential flow usecases
|
|
6200
6184
|
if (!request.account) {
|
|
6201
6185
|
throw ClientAuthError.createNoAccountInSilentRequestError();
|
|
@@ -6204,21 +6188,21 @@ class SilentFlowClient extends BaseClient {
|
|
|
6204
6188
|
const cacheRecord = this.cacheManager.readCacheRecord(request.account, request, environment);
|
|
6205
6189
|
if (!cacheRecord.accessToken) {
|
|
6206
6190
|
// Must refresh due to non-existent access_token.
|
|
6207
|
-
this.serverTelemetryManager?.setCacheOutcome(
|
|
6191
|
+
this.serverTelemetryManager?.setCacheOutcome(CacheOutcome.NO_CACHED_ACCESS_TOKEN);
|
|
6208
6192
|
this.logger.info("SilentFlowClient:acquireCachedToken - No access token found in cache for the given properties.");
|
|
6209
6193
|
throw ClientAuthError.createRefreshRequiredError();
|
|
6210
6194
|
}
|
|
6211
6195
|
else if (TimeUtils.wasClockTurnedBack(cacheRecord.accessToken.cachedAt) ||
|
|
6212
6196
|
TimeUtils.isTokenExpired(cacheRecord.accessToken.expiresOn, this.config.systemOptions.tokenRenewalOffsetSeconds)) {
|
|
6213
6197
|
// Must refresh due to expired access_token.
|
|
6214
|
-
this.serverTelemetryManager?.setCacheOutcome(
|
|
6198
|
+
this.serverTelemetryManager?.setCacheOutcome(CacheOutcome.CACHED_ACCESS_TOKEN_EXPIRED);
|
|
6215
6199
|
this.logger.info(`SilentFlowClient:acquireCachedToken - Cached access token is expired or will expire within ${this.config.systemOptions.tokenRenewalOffsetSeconds} seconds.`);
|
|
6216
6200
|
throw ClientAuthError.createRefreshRequiredError();
|
|
6217
6201
|
}
|
|
6218
6202
|
else if (cacheRecord.accessToken.refreshOn &&
|
|
6219
6203
|
TimeUtils.isTokenExpired(cacheRecord.accessToken.refreshOn, 0)) {
|
|
6220
6204
|
// Must refresh due to the refresh_in value.
|
|
6221
|
-
this.serverTelemetryManager?.setCacheOutcome(
|
|
6205
|
+
this.serverTelemetryManager?.setCacheOutcome(CacheOutcome.REFRESH_CACHED_ACCESS_TOKEN);
|
|
6222
6206
|
this.logger.info("SilentFlowClient:acquireCachedToken - Cached access token's refreshOn property has been exceeded'.");
|
|
6223
6207
|
throw ClientAuthError.createRefreshRequiredError();
|
|
6224
6208
|
}
|
|
@@ -7143,11 +7127,10 @@ const InstanceDiscoveryMetadata = rawMetdataJSON.instanceDiscoveryMetadata;
|
|
|
7143
7127
|
/**
|
|
7144
7128
|
* Protocol modes supported by MSAL.
|
|
7145
7129
|
*/
|
|
7146
|
-
|
|
7147
|
-
|
|
7148
|
-
|
|
7149
|
-
|
|
7150
|
-
})(exports.ProtocolMode || (exports.ProtocolMode = {}));
|
|
7130
|
+
const ProtocolMode = {
|
|
7131
|
+
AAD: "AAD",
|
|
7132
|
+
OIDC: "OIDC",
|
|
7133
|
+
};
|
|
7151
7134
|
|
|
7152
7135
|
/*
|
|
7153
7136
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -7261,14 +7244,14 @@ class RegionDiscovery {
|
|
|
7261
7244
|
* @returns Promise<string | null>
|
|
7262
7245
|
*/
|
|
7263
7246
|
async detectRegion(environmentRegion, regionDiscoveryMetadata) {
|
|
7264
|
-
this.performanceClient?.addQueueMeasurement(
|
|
7247
|
+
this.performanceClient?.addQueueMeasurement(PerformanceEvents.RegionDiscoveryDetectRegion, this.correlationId);
|
|
7265
7248
|
// Initialize auto detected region with the region from the envrionment
|
|
7266
7249
|
let autodetectedRegionName = environmentRegion;
|
|
7267
7250
|
// Check if a region was detected from the environment, if not, attempt to get the region from IMDS
|
|
7268
7251
|
if (!autodetectedRegionName) {
|
|
7269
7252
|
const options = RegionDiscovery.IMDS_OPTIONS;
|
|
7270
7253
|
try {
|
|
7271
|
-
this.performanceClient?.setPreQueueTime(
|
|
7254
|
+
this.performanceClient?.setPreQueueTime(PerformanceEvents.RegionDiscoveryGetRegionFromIMDS, this.correlationId);
|
|
7272
7255
|
const localIMDSVersionResponse = await this.getRegionFromIMDS(Constants.IMDS_VERSION, options);
|
|
7273
7256
|
if (localIMDSVersionResponse.status ===
|
|
7274
7257
|
ResponseCodes.httpSuccess) {
|
|
@@ -7279,14 +7262,14 @@ class RegionDiscovery {
|
|
|
7279
7262
|
// If the response using the local IMDS version failed, try to fetch the current version of IMDS and retry.
|
|
7280
7263
|
if (localIMDSVersionResponse.status ===
|
|
7281
7264
|
ResponseCodes.httpBadRequest) {
|
|
7282
|
-
this.performanceClient?.setPreQueueTime(
|
|
7265
|
+
this.performanceClient?.setPreQueueTime(PerformanceEvents.RegionDiscoveryGetCurrentVersion, this.correlationId);
|
|
7283
7266
|
const currentIMDSVersion = await this.getCurrentVersion(options);
|
|
7284
7267
|
if (!currentIMDSVersion) {
|
|
7285
7268
|
regionDiscoveryMetadata.region_source =
|
|
7286
7269
|
RegionDiscoverySources.FAILED_AUTO_DETECTION;
|
|
7287
7270
|
return null;
|
|
7288
7271
|
}
|
|
7289
|
-
this.performanceClient?.setPreQueueTime(
|
|
7272
|
+
this.performanceClient?.setPreQueueTime(PerformanceEvents.RegionDiscoveryGetRegionFromIMDS, this.correlationId);
|
|
7290
7273
|
const currentIMDSVersionResponse = await this.getRegionFromIMDS(currentIMDSVersion, options);
|
|
7291
7274
|
if (currentIMDSVersionResponse.status ===
|
|
7292
7275
|
ResponseCodes.httpSuccess) {
|
|
@@ -7321,7 +7304,7 @@ class RegionDiscovery {
|
|
|
7321
7304
|
* @returns Promise<NetworkResponse<string>>
|
|
7322
7305
|
*/
|
|
7323
7306
|
async getRegionFromIMDS(version, options) {
|
|
7324
|
-
this.performanceClient?.addQueueMeasurement(
|
|
7307
|
+
this.performanceClient?.addQueueMeasurement(PerformanceEvents.RegionDiscoveryGetRegionFromIMDS, this.correlationId);
|
|
7325
7308
|
return this.networkInterface.sendGetRequestAsync(`${Constants.IMDS_ENDPOINT}?api-version=${version}&format=text`, options, Constants.IMDS_TIMEOUT);
|
|
7326
7309
|
}
|
|
7327
7310
|
/**
|
|
@@ -7330,7 +7313,7 @@ class RegionDiscovery {
|
|
|
7330
7313
|
* @returns Promise<string | null>
|
|
7331
7314
|
*/
|
|
7332
7315
|
async getCurrentVersion(options) {
|
|
7333
|
-
this.performanceClient?.addQueueMeasurement(
|
|
7316
|
+
this.performanceClient?.addQueueMeasurement(PerformanceEvents.RegionDiscoveryGetCurrentVersion, this.correlationId);
|
|
7334
7317
|
try {
|
|
7335
7318
|
const response = await this.networkInterface.sendGetRequestAsync(`${Constants.IMDS_ENDPOINT}?format=json`, options);
|
|
7336
7319
|
// When IMDS endpoint is called without the api version query param, bad request response comes back with latest version.
|
|
@@ -7387,18 +7370,18 @@ class Authority {
|
|
|
7387
7370
|
getAuthorityType(authorityUri) {
|
|
7388
7371
|
// CIAM auth url pattern is being standardized as: <tenant>.ciamlogin.com
|
|
7389
7372
|
if (authorityUri.HostNameAndPort.endsWith(Constants.CIAM_AUTH_URL)) {
|
|
7390
|
-
return
|
|
7373
|
+
return AuthorityType.Ciam;
|
|
7391
7374
|
}
|
|
7392
7375
|
const pathSegments = authorityUri.PathSegments;
|
|
7393
7376
|
if (pathSegments.length) {
|
|
7394
7377
|
switch (pathSegments[0].toLowerCase()) {
|
|
7395
7378
|
case Constants.ADFS:
|
|
7396
|
-
return
|
|
7379
|
+
return AuthorityType.Adfs;
|
|
7397
7380
|
case Constants.DSTS:
|
|
7398
|
-
return
|
|
7381
|
+
return AuthorityType.Dsts;
|
|
7399
7382
|
}
|
|
7400
7383
|
}
|
|
7401
|
-
return
|
|
7384
|
+
return AuthorityType.Default;
|
|
7402
7385
|
}
|
|
7403
7386
|
// See above for AuthorityType
|
|
7404
7387
|
get authorityType() {
|
|
@@ -7527,8 +7510,8 @@ class Authority {
|
|
|
7527
7510
|
canReplaceTenant(authorityUri) {
|
|
7528
7511
|
return authorityUri.PathSegments.length === 1
|
|
7529
7512
|
&& !Authority.reservedTenantDomains.has(authorityUri.PathSegments[0])
|
|
7530
|
-
&& this.getAuthorityType(authorityUri) ===
|
|
7531
|
-
&& this.protocolMode ===
|
|
7513
|
+
&& this.getAuthorityType(authorityUri) === AuthorityType.Default
|
|
7514
|
+
&& this.protocolMode === ProtocolMode.AAD;
|
|
7532
7515
|
}
|
|
7533
7516
|
/**
|
|
7534
7517
|
* Replaces tenant in url path with current tenant. Defaults to common.
|
|
@@ -7571,8 +7554,8 @@ class Authority {
|
|
|
7571
7554
|
* The default open id configuration endpoint for any canonical authority.
|
|
7572
7555
|
*/
|
|
7573
7556
|
get defaultOpenIdConfigurationEndpoint() {
|
|
7574
|
-
if (this.authorityType ===
|
|
7575
|
-
this.protocolMode ===
|
|
7557
|
+
if (this.authorityType === AuthorityType.Adfs ||
|
|
7558
|
+
this.protocolMode === ProtocolMode.OIDC) {
|
|
7576
7559
|
return `${this.canonicalAuthority}.well-known/openid-configuration`;
|
|
7577
7560
|
}
|
|
7578
7561
|
return `${this.canonicalAuthority}v2.0/.well-known/openid-configuration`;
|
|
@@ -7588,16 +7571,16 @@ class Authority {
|
|
|
7588
7571
|
* and the /authorize, /token and logout endpoints.
|
|
7589
7572
|
*/
|
|
7590
7573
|
async resolveEndpointsAsync() {
|
|
7591
|
-
this.performanceClient?.addQueueMeasurement(
|
|
7574
|
+
this.performanceClient?.addQueueMeasurement(PerformanceEvents.AuthorityResolveEndpointsAsync, this.correlationId);
|
|
7592
7575
|
let metadataEntity = this.cacheManager.getAuthorityMetadataByAlias(this.hostnameAndPort);
|
|
7593
7576
|
if (!metadataEntity) {
|
|
7594
7577
|
metadataEntity = new AuthorityMetadataEntity();
|
|
7595
7578
|
metadataEntity.updateCanonicalAuthority(this.canonicalAuthority);
|
|
7596
7579
|
}
|
|
7597
|
-
this.performanceClient?.setPreQueueTime(
|
|
7580
|
+
this.performanceClient?.setPreQueueTime(PerformanceEvents.AuthorityUpdateCloudDiscoveryMetadata, this.correlationId);
|
|
7598
7581
|
const cloudDiscoverySource = await this.updateCloudDiscoveryMetadata(metadataEntity);
|
|
7599
7582
|
this.canonicalAuthority = this.canonicalAuthority.replace(this.hostnameAndPort, metadataEntity.preferred_network);
|
|
7600
|
-
this.performanceClient?.setPreQueueTime(
|
|
7583
|
+
this.performanceClient?.setPreQueueTime(PerformanceEvents.AuthorityUpdateEndpointMetadata, this.correlationId);
|
|
7601
7584
|
const endpointSource = await this.updateEndpointMetadata(metadataEntity);
|
|
7602
7585
|
if (cloudDiscoverySource !== AuthorityMetadataSource.CACHE &&
|
|
7603
7586
|
endpointSource !== AuthorityMetadataSource.CACHE) {
|
|
@@ -7614,7 +7597,7 @@ class Authority {
|
|
|
7614
7597
|
* @param metadataEntity
|
|
7615
7598
|
*/
|
|
7616
7599
|
async updateEndpointMetadata(metadataEntity) {
|
|
7617
|
-
this.performanceClient?.addQueueMeasurement(
|
|
7600
|
+
this.performanceClient?.addQueueMeasurement(PerformanceEvents.AuthorityUpdateEndpointMetadata, this.correlationId);
|
|
7618
7601
|
let metadata = this.getEndpointMetadataFromConfig();
|
|
7619
7602
|
if (metadata) {
|
|
7620
7603
|
metadataEntity.updateEndpointMetadata(metadata, false);
|
|
@@ -7626,12 +7609,12 @@ class Authority {
|
|
|
7626
7609
|
// No need to update
|
|
7627
7610
|
return AuthorityMetadataSource.CACHE;
|
|
7628
7611
|
}
|
|
7629
|
-
this.performanceClient?.setPreQueueTime(
|
|
7612
|
+
this.performanceClient?.setPreQueueTime(PerformanceEvents.AuthorityGetEndpointMetadataFromNetwork, this.correlationId);
|
|
7630
7613
|
metadata = await this.getEndpointMetadataFromNetwork();
|
|
7631
7614
|
if (metadata) {
|
|
7632
7615
|
// If the user prefers to use an azure region replace the global endpoints with regional information.
|
|
7633
7616
|
if (this.authorityOptions.azureRegionConfiguration?.azureRegion) {
|
|
7634
|
-
this.performanceClient?.setPreQueueTime(
|
|
7617
|
+
this.performanceClient?.setPreQueueTime(PerformanceEvents.AuthorityUpdateMetadataWithRegionalInformation, this.correlationId);
|
|
7635
7618
|
metadata = await this.updateMetadataWithRegionalInformation(metadata);
|
|
7636
7619
|
}
|
|
7637
7620
|
metadataEntity.updateEndpointMetadata(metadata, true);
|
|
@@ -7642,7 +7625,7 @@ class Authority {
|
|
|
7642
7625
|
!this.authorityOptions.skipAuthorityMetadataCache) {
|
|
7643
7626
|
// If the user prefers to use an azure region replace the global endpoints with regional information.
|
|
7644
7627
|
if (this.authorityOptions.azureRegionConfiguration?.azureRegion) {
|
|
7645
|
-
this.performanceClient?.setPreQueueTime(
|
|
7628
|
+
this.performanceClient?.setPreQueueTime(PerformanceEvents.AuthorityUpdateMetadataWithRegionalInformation, this.correlationId);
|
|
7646
7629
|
harcodedMetadata =
|
|
7647
7630
|
await this.updateMetadataWithRegionalInformation(harcodedMetadata);
|
|
7648
7631
|
}
|
|
@@ -7685,8 +7668,8 @@ class Authority {
|
|
|
7685
7668
|
* @param hasHardcodedMetadata boolean
|
|
7686
7669
|
*/
|
|
7687
7670
|
async getEndpointMetadataFromNetwork() {
|
|
7688
|
-
this.performanceClient?.addQueueMeasurement(
|
|
7689
|
-
const perfEvent = this.performanceClient?.startMeasurement(
|
|
7671
|
+
this.performanceClient?.addQueueMeasurement(PerformanceEvents.AuthorityGetEndpointMetadataFromNetwork, this.correlationId);
|
|
7672
|
+
const perfEvent = this.performanceClient?.startMeasurement(PerformanceEvents.AuthorityGetEndpointMetadataFromNetwork, this.correlationId);
|
|
7690
7673
|
const options = {};
|
|
7691
7674
|
/*
|
|
7692
7675
|
* TODO: Add a timeout if the authority exists in our library's
|
|
@@ -7724,37 +7707,25 @@ class Authority {
|
|
|
7724
7707
|
}
|
|
7725
7708
|
/**
|
|
7726
7709
|
* Update the retrieved metadata with regional information.
|
|
7710
|
+
* User selected Azure region will be used if configured.
|
|
7727
7711
|
*/
|
|
7728
7712
|
async updateMetadataWithRegionalInformation(metadata) {
|
|
7729
|
-
this.performanceClient?.addQueueMeasurement(
|
|
7730
|
-
this.
|
|
7731
|
-
|
|
7732
|
-
|
|
7733
|
-
|
|
7734
|
-
|
|
7735
|
-
|
|
7736
|
-
if (this.authorityOptions.azureRegionConfiguration?.azureRegion ===
|
|
7737
|
-
Constants.AZURE_REGION_AUTO_DISCOVER_FLAG) {
|
|
7738
|
-
this.regionDiscoveryMetadata.region_outcome = autodetectedRegionName
|
|
7739
|
-
? RegionDiscoveryOutcomes.AUTO_DETECTION_REQUESTED_SUCCESSFUL
|
|
7740
|
-
: RegionDiscoveryOutcomes.AUTO_DETECTION_REQUESTED_FAILED;
|
|
7741
|
-
}
|
|
7742
|
-
else {
|
|
7743
|
-
if (autodetectedRegionName) {
|
|
7744
|
-
this.regionDiscoveryMetadata.region_outcome =
|
|
7745
|
-
this.authorityOptions.azureRegionConfiguration
|
|
7746
|
-
?.azureRegion === autodetectedRegionName
|
|
7747
|
-
? RegionDiscoveryOutcomes.CONFIGURED_MATCHES_DETECTED
|
|
7748
|
-
: RegionDiscoveryOutcomes.CONFIGURED_NOT_DETECTED;
|
|
7713
|
+
this.performanceClient?.addQueueMeasurement(PerformanceEvents.AuthorityUpdateMetadataWithRegionalInformation, this.correlationId);
|
|
7714
|
+
const userConfiguredAzureRegion = this.authorityOptions.azureRegionConfiguration?.azureRegion;
|
|
7715
|
+
if (userConfiguredAzureRegion) {
|
|
7716
|
+
if (userConfiguredAzureRegion !== Constants.AZURE_REGION_AUTO_DISCOVER_FLAG) {
|
|
7717
|
+
this.regionDiscoveryMetadata.region_outcome = RegionDiscoveryOutcomes.CONFIGURED_NO_AUTO_DETECTION;
|
|
7718
|
+
this.regionDiscoveryMetadata.region_used = userConfiguredAzureRegion;
|
|
7719
|
+
return Authority.replaceWithRegionalInformation(metadata, userConfiguredAzureRegion);
|
|
7749
7720
|
}
|
|
7750
|
-
|
|
7751
|
-
|
|
7752
|
-
|
|
7721
|
+
this.performanceClient?.setPreQueueTime(PerformanceEvents.RegionDiscoveryDetectRegion, this.correlationId);
|
|
7722
|
+
const autodetectedRegionName = await this.regionDiscovery.detectRegion(this.authorityOptions.azureRegionConfiguration?.environmentRegion, this.regionDiscoveryMetadata);
|
|
7723
|
+
if (autodetectedRegionName) {
|
|
7724
|
+
this.regionDiscoveryMetadata.region_outcome = RegionDiscoveryOutcomes.AUTO_DETECTION_REQUESTED_SUCCESSFUL;
|
|
7725
|
+
this.regionDiscoveryMetadata.region_used = autodetectedRegionName;
|
|
7726
|
+
return Authority.replaceWithRegionalInformation(metadata, autodetectedRegionName);
|
|
7753
7727
|
}
|
|
7754
|
-
|
|
7755
|
-
if (azureRegion) {
|
|
7756
|
-
this.regionDiscoveryMetadata.region_used = azureRegion;
|
|
7757
|
-
return Authority.replaceWithRegionalInformation(metadata, azureRegion);
|
|
7728
|
+
this.regionDiscoveryMetadata.region_outcome = RegionDiscoveryOutcomes.AUTO_DETECTION_REQUESTED_FAILED;
|
|
7758
7729
|
}
|
|
7759
7730
|
return metadata;
|
|
7760
7731
|
}
|
|
@@ -7765,7 +7736,7 @@ class Authority {
|
|
|
7765
7736
|
* @returns AuthorityMetadataSource
|
|
7766
7737
|
*/
|
|
7767
7738
|
async updateCloudDiscoveryMetadata(metadataEntity) {
|
|
7768
|
-
this.performanceClient?.addQueueMeasurement(
|
|
7739
|
+
this.performanceClient?.addQueueMeasurement(PerformanceEvents.AuthorityUpdateCloudDiscoveryMetadata, this.correlationId);
|
|
7769
7740
|
this.logger.verbose("Attempting to get cloud discovery metadata in the config");
|
|
7770
7741
|
this.logger.verbosePii(`Known Authorities: ${this.authorityOptions.knownAuthorities ||
|
|
7771
7742
|
Constants.NOT_APPLICABLE}`);
|
|
@@ -7792,7 +7763,7 @@ class Authority {
|
|
|
7792
7763
|
this.logger.verbose("The metadata entity is expired.");
|
|
7793
7764
|
}
|
|
7794
7765
|
this.logger.verbose("Did not find cloud discovery metadata in the cache... Attempting to get cloud discovery metadata from the network.");
|
|
7795
|
-
this.performanceClient?.setPreQueueTime(
|
|
7766
|
+
this.performanceClient?.setPreQueueTime(PerformanceEvents.AuthorityGetCloudDiscoveryMetadataFromNetwork, this.correlationId);
|
|
7796
7767
|
metadata = await this.getCloudDiscoveryMetadataFromNetwork();
|
|
7797
7768
|
if (metadata) {
|
|
7798
7769
|
this.logger.verbose("cloud discovery metadata was successfully returned from getCloudDiscoveryMetadataFromNetwork()");
|
|
@@ -7815,7 +7786,7 @@ class Authority {
|
|
|
7815
7786
|
*/
|
|
7816
7787
|
getCloudDiscoveryMetadataFromConfig() {
|
|
7817
7788
|
// CIAM does not support cloud discovery metadata
|
|
7818
|
-
if (this.authorityType ===
|
|
7789
|
+
if (this.authorityType === AuthorityType.Ciam) {
|
|
7819
7790
|
this.logger.verbose("CIAM authorities do not support cloud discovery metadata, generate the aliases from authority host.");
|
|
7820
7791
|
return Authority.createCloudDiscoveryMetadataFromHost(this.hostnameAndPort);
|
|
7821
7792
|
}
|
|
@@ -7853,7 +7824,7 @@ class Authority {
|
|
|
7853
7824
|
* @param hasHardcodedMetadata boolean
|
|
7854
7825
|
*/
|
|
7855
7826
|
async getCloudDiscoveryMetadataFromNetwork() {
|
|
7856
|
-
this.performanceClient?.addQueueMeasurement(
|
|
7827
|
+
this.performanceClient?.addQueueMeasurement(PerformanceEvents.AuthorityGetCloudDiscoveryMetadataFromNetwork, this.correlationId);
|
|
7857
7828
|
const instanceDiscoveryEndpoint = `${Constants.AAD_INSTANCE_DISCOVERY_ENDPT}${this.canonicalAuthority}oauth2/v2.0/authorize`;
|
|
7858
7829
|
const options = {};
|
|
7859
7830
|
/*
|
|
@@ -7936,7 +7907,7 @@ class Authority {
|
|
|
7936
7907
|
static generateAuthority(authorityString, azureCloudOptions) {
|
|
7937
7908
|
let authorityAzureCloudInstance;
|
|
7938
7909
|
if (azureCloudOptions &&
|
|
7939
|
-
azureCloudOptions.azureCloudInstance !==
|
|
7910
|
+
azureCloudOptions.azureCloudInstance !== AzureCloudInstance.None) {
|
|
7940
7911
|
const tenant = azureCloudOptions.tenant
|
|
7941
7912
|
? azureCloudOptions.tenant
|
|
7942
7913
|
: Constants.DEFAULT_COMMON_TENANT;
|
|
@@ -8065,9 +8036,9 @@ class Authority {
|
|
|
8065
8036
|
Authority.reservedTenantDomains = (new Set([
|
|
8066
8037
|
"{tenant}",
|
|
8067
8038
|
"{tenantid}",
|
|
8068
|
-
|
|
8069
|
-
|
|
8070
|
-
|
|
8039
|
+
AADAuthorityConstants.COMMON,
|
|
8040
|
+
AADAuthorityConstants.CONSUMERS,
|
|
8041
|
+
AADAuthorityConstants.ORGANIZATIONS
|
|
8071
8042
|
]));
|
|
8072
8043
|
|
|
8073
8044
|
/*
|
|
@@ -8086,12 +8057,12 @@ class AuthorityFactory {
|
|
|
8086
8057
|
* @param protocolMode
|
|
8087
8058
|
*/
|
|
8088
8059
|
static async createDiscoveredInstance(authorityUri, networkClient, cacheManager, authorityOptions, logger, performanceClient, correlationId) {
|
|
8089
|
-
performanceClient?.addQueueMeasurement(
|
|
8060
|
+
performanceClient?.addQueueMeasurement(PerformanceEvents.AuthorityFactoryCreateDiscoveredInstance, correlationId);
|
|
8090
8061
|
const authorityUriFinal = Authority.transformCIAMAuthority(authorityUri);
|
|
8091
8062
|
// Initialize authority and perform discovery endpoint check.
|
|
8092
8063
|
const acquireTokenAuthority = AuthorityFactory.createInstance(authorityUriFinal, networkClient, cacheManager, authorityOptions, logger, performanceClient, correlationId);
|
|
8093
8064
|
try {
|
|
8094
|
-
performanceClient?.setPreQueueTime(
|
|
8065
|
+
performanceClient?.setPreQueueTime(PerformanceEvents.AuthorityResolveEndpointsAsync, correlationId);
|
|
8095
8066
|
await acquireTokenAuthority.resolveEndpointsAsync();
|
|
8096
8067
|
return acquireTokenAuthority;
|
|
8097
8068
|
}
|
|
@@ -8280,22 +8251,22 @@ class AuthenticationHeaderParser {
|
|
|
8280
8251
|
*/
|
|
8281
8252
|
getShrNonce() {
|
|
8282
8253
|
// Attempt to parse nonce from Authentiacation-Info
|
|
8283
|
-
const authenticationInfo = this.headers[
|
|
8254
|
+
const authenticationInfo = this.headers[HeaderNames.AuthenticationInfo];
|
|
8284
8255
|
if (authenticationInfo) {
|
|
8285
8256
|
const authenticationInfoChallenges = this.parseChallenges(authenticationInfo);
|
|
8286
8257
|
if (authenticationInfoChallenges.nextnonce) {
|
|
8287
8258
|
return authenticationInfoChallenges.nextnonce;
|
|
8288
8259
|
}
|
|
8289
|
-
throw ClientConfigurationError.createInvalidAuthenticationHeaderError(
|
|
8260
|
+
throw ClientConfigurationError.createInvalidAuthenticationHeaderError(HeaderNames.AuthenticationInfo, "nextnonce challenge is missing.");
|
|
8290
8261
|
}
|
|
8291
8262
|
// Attempt to parse nonce from WWW-Authenticate
|
|
8292
|
-
const wwwAuthenticate = this.headers[
|
|
8263
|
+
const wwwAuthenticate = this.headers[HeaderNames.WWWAuthenticate];
|
|
8293
8264
|
if (wwwAuthenticate) {
|
|
8294
8265
|
const wwwAuthenticateChallenges = this.parseChallenges(wwwAuthenticate);
|
|
8295
8266
|
if (wwwAuthenticateChallenges.nonce) {
|
|
8296
8267
|
return wwwAuthenticateChallenges.nonce;
|
|
8297
8268
|
}
|
|
8298
|
-
throw ClientConfigurationError.createInvalidAuthenticationHeaderError(
|
|
8269
|
+
throw ClientConfigurationError.createInvalidAuthenticationHeaderError(HeaderNames.WWWAuthenticate, "nonce challenge is missing.");
|
|
8299
8270
|
}
|
|
8300
8271
|
// If neither header is present, throw missing headers error
|
|
8301
8272
|
throw ClientConfigurationError.createMissingNonceAuthenticationHeadersError();
|
|
@@ -8324,7 +8295,7 @@ class AuthenticationHeaderParser {
|
|
|
8324
8295
|
*/
|
|
8325
8296
|
class ServerTelemetryManager {
|
|
8326
8297
|
constructor(telemetryRequest, cacheManager) {
|
|
8327
|
-
this.cacheOutcome =
|
|
8298
|
+
this.cacheOutcome = CacheOutcome.NO_CACHE_HIT;
|
|
8328
8299
|
this.cacheManager = cacheManager;
|
|
8329
8300
|
this.apiId = telemetryRequest.apiId;
|
|
8330
8301
|
this.correlationId = telemetryRequest.correlationId;
|
|
@@ -8665,7 +8636,7 @@ class PerformanceClient {
|
|
|
8665
8636
|
performanceMeasurement.startMeasurement();
|
|
8666
8637
|
const inProgressEvent = {
|
|
8667
8638
|
eventId: this.generateId(),
|
|
8668
|
-
status:
|
|
8639
|
+
status: PerformanceEventStatus.InProgress,
|
|
8669
8640
|
authority: this.authority,
|
|
8670
8641
|
libraryName: this.libraryName,
|
|
8671
8642
|
libraryVersion: this.libraryVersion,
|
|
@@ -8757,7 +8728,7 @@ class PerformanceClient {
|
|
|
8757
8728
|
queuedTimeMs: queueInfo.totalQueueTime,
|
|
8758
8729
|
queuedCount: queueInfo.totalQueueCount,
|
|
8759
8730
|
queuedManuallyCompletedCount: queueInfo.manuallyCompletedCount,
|
|
8760
|
-
status:
|
|
8731
|
+
status: PerformanceEventStatus.Completed,
|
|
8761
8732
|
incompleteSubsCount,
|
|
8762
8733
|
};
|
|
8763
8734
|
this.truncateIntegralFields(finalEvent, this.getIntFields());
|
|
@@ -8927,13 +8898,9 @@ class PerformanceClient {
|
|
|
8927
8898
|
* Licensed under the MIT License.
|
|
8928
8899
|
*/
|
|
8929
8900
|
class StubPerformanceMeasurement {
|
|
8930
|
-
|
|
8931
|
-
|
|
8932
|
-
|
|
8933
|
-
endMeasurement() { }
|
|
8934
|
-
flushMeasurement() {
|
|
8935
|
-
return null;
|
|
8936
|
-
}
|
|
8901
|
+
startMeasurement() { return; }
|
|
8902
|
+
endMeasurement() { return; }
|
|
8903
|
+
flushMeasurement() { return null; }
|
|
8937
8904
|
}
|
|
8938
8905
|
class StubPerformanceClient extends PerformanceClient {
|
|
8939
8906
|
generateId() {
|
|
@@ -8942,23 +8909,15 @@ class StubPerformanceClient extends PerformanceClient {
|
|
|
8942
8909
|
startPerformanceMeasurement() {
|
|
8943
8910
|
return new StubPerformanceMeasurement();
|
|
8944
8911
|
}
|
|
8945
|
-
|
|
8946
|
-
calculateQueuedTime(preQueueTime, currentTime) {
|
|
8912
|
+
calculateQueuedTime() {
|
|
8947
8913
|
return 0;
|
|
8948
8914
|
}
|
|
8949
|
-
addQueueMeasurement(
|
|
8950
|
-
|
|
8951
|
-
queueTime // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
8952
|
-
) {
|
|
8953
|
-
return;
|
|
8954
|
-
}
|
|
8955
|
-
setPreQueueTime(eventName, // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
8956
|
-
correlationId // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
8957
|
-
) {
|
|
8958
|
-
return;
|
|
8959
|
-
}
|
|
8915
|
+
addQueueMeasurement() { return; }
|
|
8916
|
+
setPreQueueTime() { return; }
|
|
8960
8917
|
}
|
|
8961
8918
|
|
|
8919
|
+
exports.AADAuthorityConstants = AADAuthorityConstants;
|
|
8920
|
+
exports.AADServerParamKeys = AADServerParamKeys;
|
|
8962
8921
|
exports.AccessTokenEntity = AccessTokenEntity;
|
|
8963
8922
|
exports.AccountEntity = AccountEntity;
|
|
8964
8923
|
exports.AppMetadataEntity = AppMetadataEntity;
|
|
@@ -8966,13 +8925,21 @@ exports.AuthError = AuthError;
|
|
|
8966
8925
|
exports.AuthErrorMessage = AuthErrorMessage;
|
|
8967
8926
|
exports.AuthToken = AuthToken;
|
|
8968
8927
|
exports.AuthenticationHeaderParser = AuthenticationHeaderParser;
|
|
8928
|
+
exports.AuthenticationScheme = AuthenticationScheme;
|
|
8969
8929
|
exports.Authority = Authority;
|
|
8970
8930
|
exports.AuthorityFactory = AuthorityFactory;
|
|
8971
8931
|
exports.AuthorityMetadataEntity = AuthorityMetadataEntity;
|
|
8932
|
+
exports.AuthorityType = AuthorityType;
|
|
8972
8933
|
exports.AuthorizationCodeClient = AuthorizationCodeClient;
|
|
8934
|
+
exports.AzureCloudInstance = AzureCloudInstance;
|
|
8973
8935
|
exports.BaseClient = BaseClient;
|
|
8936
|
+
exports.CacheAccountType = CacheAccountType;
|
|
8974
8937
|
exports.CacheManager = CacheManager;
|
|
8938
|
+
exports.CacheOutcome = CacheOutcome;
|
|
8975
8939
|
exports.CacheRecord = CacheRecord;
|
|
8940
|
+
exports.CacheType = CacheType;
|
|
8941
|
+
exports.CcsCredentialType = CcsCredentialType;
|
|
8942
|
+
exports.ClaimsRequestKeys = ClaimsRequestKeys;
|
|
8976
8943
|
exports.ClientAuthError = ClientAuthError;
|
|
8977
8944
|
exports.ClientAuthErrorMessage = ClientAuthErrorMessage;
|
|
8978
8945
|
exports.ClientConfigurationError = ClientConfigurationError;
|
|
@@ -8980,10 +8947,13 @@ exports.ClientConfigurationErrorMessage = ClientConfigurationErrorMessage;
|
|
|
8980
8947
|
exports.CodeChallengeMethodValues = CodeChallengeMethodValues;
|
|
8981
8948
|
exports.Constants = Constants;
|
|
8982
8949
|
exports.CredentialEntity = CredentialEntity;
|
|
8950
|
+
exports.CredentialType = CredentialType;
|
|
8983
8951
|
exports.DEFAULT_CRYPTO_IMPLEMENTATION = DEFAULT_CRYPTO_IMPLEMENTATION;
|
|
8984
8952
|
exports.DEFAULT_SYSTEM_OPTIONS = DEFAULT_SYSTEM_OPTIONS;
|
|
8985
8953
|
exports.DefaultStorageClass = DefaultStorageClass;
|
|
8986
8954
|
exports.Errors = Errors;
|
|
8955
|
+
exports.GrantType = GrantType;
|
|
8956
|
+
exports.HeaderNames = HeaderNames;
|
|
8987
8957
|
exports.IdToken = AuthToken;
|
|
8988
8958
|
exports.IdTokenEntity = IdTokenEntity;
|
|
8989
8959
|
exports.IntFields = IntFields;
|
|
@@ -8994,14 +8964,21 @@ exports.Logger = Logger;
|
|
|
8994
8964
|
exports.NetworkManager = NetworkManager;
|
|
8995
8965
|
exports.OIDC_DEFAULT_SCOPES = OIDC_DEFAULT_SCOPES;
|
|
8996
8966
|
exports.ONE_DAY_IN_MS = ONE_DAY_IN_MS;
|
|
8967
|
+
exports.PasswordGrantConstants = PasswordGrantConstants;
|
|
8997
8968
|
exports.PerformanceClient = PerformanceClient;
|
|
8969
|
+
exports.PerformanceEventStatus = PerformanceEventStatus;
|
|
8970
|
+
exports.PerformanceEvents = PerformanceEvents;
|
|
8971
|
+
exports.PersistentCacheKeys = PersistentCacheKeys;
|
|
8998
8972
|
exports.PopTokenGenerator = PopTokenGenerator;
|
|
8999
8973
|
exports.PromptValue = PromptValue;
|
|
8974
|
+
exports.ProtocolMode = ProtocolMode;
|
|
9000
8975
|
exports.ProtocolUtils = ProtocolUtils;
|
|
9001
8976
|
exports.RefreshTokenClient = RefreshTokenClient;
|
|
9002
8977
|
exports.RefreshTokenEntity = RefreshTokenEntity;
|
|
9003
8978
|
exports.RequestParameterBuilder = RequestParameterBuilder;
|
|
9004
8979
|
exports.ResponseHandler = ResponseHandler;
|
|
8980
|
+
exports.ResponseMode = ResponseMode;
|
|
8981
|
+
exports.SSOTypes = SSOTypes;
|
|
9005
8982
|
exports.ScopeSet = ScopeSet;
|
|
9006
8983
|
exports.ServerError = ServerError;
|
|
9007
8984
|
exports.ServerTelemetryEntity = ServerTelemetryEntity;
|