@azure/msal-common 14.3.0 → 14.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/account/AuthToken.mjs +1 -1
- package/dist/account/CcsCredential.mjs +1 -1
- package/dist/account/ClientInfo.mjs +1 -1
- package/dist/authority/Authority.d.ts.map +1 -1
- package/dist/authority/Authority.mjs +2 -3
- package/dist/authority/Authority.mjs.map +1 -1
- package/dist/authority/AuthorityFactory.mjs +1 -1
- package/dist/authority/AuthorityMetadata.mjs +1 -1
- package/dist/authority/AuthorityOptions.mjs +1 -1
- package/dist/authority/AuthorityType.mjs +1 -1
- package/dist/authority/CloudInstanceDiscoveryErrorResponse.mjs +1 -1
- package/dist/authority/CloudInstanceDiscoveryResponse.mjs +1 -1
- package/dist/authority/OpenIdConfigResponse.mjs +1 -1
- package/dist/authority/ProtocolMode.mjs +1 -1
- package/dist/authority/RegionDiscovery.mjs +1 -1
- package/dist/cache/CacheManager.d.ts +24 -19
- package/dist/cache/CacheManager.d.ts.map +1 -1
- package/dist/cache/CacheManager.mjs +36 -23
- package/dist/cache/CacheManager.mjs.map +1 -1
- package/dist/cache/entities/AccountEntity.mjs +1 -1
- package/dist/cache/entities/AppMetadataEntity.mjs +1 -1
- package/dist/cache/entities/AuthorityMetadataEntity.mjs +1 -1
- package/dist/cache/entities/CacheRecord.mjs +1 -1
- package/dist/cache/entities/ServerTelemetryEntity.d.ts +2 -9
- package/dist/cache/entities/ServerTelemetryEntity.d.ts.map +1 -1
- package/dist/cache/entities/ThrottlingEntity.mjs +1 -1
- package/dist/cache/persistence/TokenCacheContext.mjs +1 -1
- package/dist/cache/utils/CacheHelpers.d.ts +6 -0
- package/dist/cache/utils/CacheHelpers.d.ts.map +1 -1
- package/dist/cache/utils/CacheHelpers.mjs +19 -3
- package/dist/cache/utils/CacheHelpers.mjs.map +1 -1
- package/dist/client/AuthorizationCodeClient.d.ts +2 -1
- package/dist/client/AuthorizationCodeClient.d.ts.map +1 -1
- package/dist/client/AuthorizationCodeClient.mjs +3 -9
- package/dist/client/AuthorizationCodeClient.mjs.map +1 -1
- package/dist/client/BaseClient.mjs +1 -1
- package/dist/client/RefreshTokenClient.d.ts.map +1 -1
- package/dist/client/RefreshTokenClient.mjs +2 -2
- package/dist/client/RefreshTokenClient.mjs.map +1 -1
- package/dist/client/SilentFlowClient.d.ts.map +1 -1
- package/dist/client/SilentFlowClient.mjs +5 -3
- package/dist/client/SilentFlowClient.mjs.map +1 -1
- package/dist/config/ClientConfiguration.mjs +1 -1
- package/dist/crypto/ICrypto.d.ts +3 -3
- package/dist/crypto/ICrypto.d.ts.map +1 -1
- package/dist/crypto/ICrypto.mjs +1 -1
- package/dist/crypto/ICrypto.mjs.map +1 -1
- package/dist/crypto/JoseHeader.d.ts +3 -3
- package/dist/crypto/JoseHeader.d.ts.map +1 -1
- package/dist/crypto/JoseHeader.mjs +3 -3
- package/dist/crypto/JoseHeader.mjs.map +1 -1
- package/dist/crypto/PopTokenGenerator.d.ts.map +1 -1
- package/dist/crypto/PopTokenGenerator.mjs +3 -3
- package/dist/crypto/PopTokenGenerator.mjs.map +1 -1
- package/dist/crypto/SignedHttpRequest.d.ts +4 -0
- package/dist/crypto/SignedHttpRequest.d.ts.map +1 -1
- package/dist/error/AuthError.mjs +1 -1
- package/dist/error/AuthErrorCodes.mjs +1 -1
- package/dist/error/ClientAuthError.mjs +1 -1
- package/dist/error/ClientAuthErrorCodes.mjs +1 -1
- package/dist/error/ClientConfigurationError.mjs +1 -1
- package/dist/error/ClientConfigurationErrorCodes.mjs +1 -1
- package/dist/error/InteractionRequiredAuthError.mjs +1 -1
- package/dist/error/InteractionRequiredAuthErrorCodes.mjs +1 -1
- package/dist/error/JoseHeaderError.mjs +1 -1
- package/dist/error/JoseHeaderErrorCodes.mjs +1 -1
- package/dist/error/ServerError.mjs +1 -1
- package/dist/index.cjs +139 -201
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.mjs +4 -3
- package/dist/index.mjs.map +1 -1
- package/dist/logger/Logger.mjs +1 -1
- package/dist/network/INetworkModule.mjs +1 -1
- package/dist/network/NetworkManager.mjs +1 -1
- package/dist/network/RequestThumbprint.d.ts +2 -0
- package/dist/network/RequestThumbprint.d.ts.map +1 -1
- package/dist/network/ThrottlingUtils.mjs +1 -1
- package/dist/packageMetadata.d.ts +1 -1
- package/dist/packageMetadata.mjs +2 -2
- package/dist/request/AuthenticationHeaderParser.mjs +1 -1
- package/dist/request/BaseAuthRequest.d.ts +3 -0
- package/dist/request/BaseAuthRequest.d.ts.map +1 -1
- package/dist/request/RequestParameterBuilder.mjs +1 -1
- package/dist/request/RequestValidator.mjs +1 -1
- package/dist/request/ScopeSet.mjs +1 -1
- package/dist/response/ResponseHandler.mjs +1 -1
- package/dist/telemetry/performance/PerformanceClient.mjs +1 -1
- package/dist/telemetry/performance/PerformanceEvent.d.ts +8 -1
- package/dist/telemetry/performance/PerformanceEvent.d.ts.map +1 -1
- package/dist/telemetry/performance/PerformanceEvent.mjs +6 -2
- package/dist/telemetry/performance/PerformanceEvent.mjs.map +1 -1
- package/dist/telemetry/performance/StubPerformanceClient.mjs +1 -1
- package/dist/telemetry/server/ServerTelemetryManager.d.ts.map +1 -1
- package/dist/telemetry/server/ServerTelemetryManager.mjs +11 -8
- package/dist/telemetry/server/ServerTelemetryManager.mjs.map +1 -1
- package/dist/url/UrlString.d.ts +2 -37
- package/dist/url/UrlString.d.ts.map +1 -1
- package/dist/url/UrlString.mjs +7 -126
- package/dist/url/UrlString.mjs.map +1 -1
- package/dist/utils/Constants.d.ts +2 -3
- package/dist/utils/Constants.d.ts.map +1 -1
- package/dist/utils/Constants.mjs +3 -4
- package/dist/utils/Constants.mjs.map +1 -1
- package/dist/utils/FunctionWrappers.mjs +1 -1
- package/dist/utils/ProtocolUtils.mjs +1 -1
- package/dist/utils/StringUtils.mjs +1 -1
- package/dist/utils/TimeUtils.mjs +1 -1
- package/dist/utils/UrlUtils.d.ts +11 -0
- package/dist/utils/UrlUtils.d.ts.map +1 -0
- package/dist/utils/UrlUtils.mjs +52 -0
- package/dist/utils/UrlUtils.mjs.map +1 -0
- package/package.json +1 -1
- package/src/authority/Authority.ts +2 -3
- package/src/cache/CacheManager.ts +63 -22
- package/src/cache/entities/ServerTelemetryEntity.ts +2 -30
- package/src/cache/utils/CacheHelpers.ts +21 -0
- package/src/client/AuthorizationCodeClient.ts +3 -13
- package/src/client/RefreshTokenClient.ts +7 -1
- package/src/client/SilentFlowClient.ts +8 -4
- package/src/crypto/ICrypto.ts +7 -2
- package/src/crypto/JoseHeader.ts +4 -4
- package/src/crypto/PopTokenGenerator.ts +2 -0
- package/src/crypto/SignedHttpRequest.ts +6 -0
- package/src/index.ts +3 -1
- package/src/network/RequestThumbprint.ts +2 -0
- package/src/packageMetadata.ts +1 -1
- package/src/request/BaseAuthRequest.ts +3 -0
- package/src/telemetry/performance/PerformanceEvent.ts +12 -1
- package/src/telemetry/server/ServerTelemetryManager.ts +12 -6
- package/src/url/UrlString.ts +6 -153
- package/src/utils/Constants.ts +3 -3
- package/src/utils/UrlUtils.ts +60 -0
- package/dist/cache/entities/ServerTelemetryEntity.mjs +0 -34
- package/dist/cache/entities/ServerTelemetryEntity.mjs.map +0 -1
|
@@ -46,6 +46,7 @@ import { StoreInCache } from "../request/StoreInCache";
|
|
|
46
46
|
import { getAliasesFromStaticSources } from "../authority/AuthorityMetadata";
|
|
47
47
|
import { StaticAuthorityOptions } from "../authority/AuthorityOptions";
|
|
48
48
|
import { TokenClaims } from "../account/TokenClaims";
|
|
49
|
+
import { IPerformanceClient } from "../telemetry/performance/IPerformanceClient";
|
|
49
50
|
|
|
50
51
|
/**
|
|
51
52
|
* Interface class which implement cache storage functions used by MSAL to perform validity checks, and store tokens.
|
|
@@ -876,29 +877,40 @@ export abstract class CacheManager implements ICacheManager {
|
|
|
876
877
|
|
|
877
878
|
/**
|
|
878
879
|
* Retrieve the cached credentials into a cacherecord
|
|
879
|
-
* @param account
|
|
880
|
-
* @param
|
|
881
|
-
* @param
|
|
882
|
-
* @param
|
|
883
|
-
* @param
|
|
880
|
+
* @param account {AccountInfo}
|
|
881
|
+
* @param request {BaseAuthRequest}
|
|
882
|
+
* @param environment {string}
|
|
883
|
+
* @param performanceClient {?IPerformanceClient}
|
|
884
|
+
* @param correlationId {?string}
|
|
884
885
|
*/
|
|
885
886
|
readCacheRecord(
|
|
886
887
|
account: AccountInfo,
|
|
887
888
|
request: BaseAuthRequest,
|
|
888
|
-
environment: string
|
|
889
|
+
environment: string,
|
|
890
|
+
performanceClient?: IPerformanceClient,
|
|
891
|
+
correlationId?: string
|
|
889
892
|
): CacheRecord {
|
|
890
893
|
const tokenKeys = this.getTokenKeys();
|
|
891
894
|
const cachedAccount = this.readAccountFromCache(account);
|
|
892
|
-
const cachedIdToken = this.getIdToken(
|
|
895
|
+
const cachedIdToken = this.getIdToken(
|
|
896
|
+
account,
|
|
897
|
+
tokenKeys,
|
|
898
|
+
performanceClient,
|
|
899
|
+
correlationId
|
|
900
|
+
);
|
|
893
901
|
const cachedAccessToken = this.getAccessToken(
|
|
894
902
|
account,
|
|
895
903
|
request,
|
|
896
|
-
tokenKeys
|
|
904
|
+
tokenKeys,
|
|
905
|
+
performanceClient,
|
|
906
|
+
correlationId
|
|
897
907
|
);
|
|
898
908
|
const cachedRefreshToken = this.getRefreshToken(
|
|
899
909
|
account,
|
|
900
910
|
false,
|
|
901
|
-
tokenKeys
|
|
911
|
+
tokenKeys,
|
|
912
|
+
performanceClient,
|
|
913
|
+
correlationId
|
|
902
914
|
);
|
|
903
915
|
const cachedAppMetadata = this.readAppMetadataFromCache(environment);
|
|
904
916
|
|
|
@@ -930,13 +942,16 @@ export abstract class CacheManager implements ICacheManager {
|
|
|
930
942
|
|
|
931
943
|
/**
|
|
932
944
|
* Retrieve IdTokenEntity from cache
|
|
933
|
-
* @param
|
|
934
|
-
* @param
|
|
935
|
-
* @param
|
|
945
|
+
* @param account {AccountInfo}
|
|
946
|
+
* @param tokenKeys {?TokenKeys}
|
|
947
|
+
* @param performanceClient {?IPerformanceClient}
|
|
948
|
+
* @param correlationId {?string}
|
|
936
949
|
*/
|
|
937
950
|
getIdToken(
|
|
938
951
|
account: AccountInfo,
|
|
939
|
-
tokenKeys?: TokenKeys
|
|
952
|
+
tokenKeys?: TokenKeys,
|
|
953
|
+
performanceClient?: IPerformanceClient,
|
|
954
|
+
correlationId?: string
|
|
940
955
|
): IdTokenEntity | null {
|
|
941
956
|
this.commonLogger.trace("CacheManager - getIdToken called");
|
|
942
957
|
const idTokenFilter: CredentialFilter = {
|
|
@@ -963,6 +978,12 @@ export abstract class CacheManager implements ICacheManager {
|
|
|
963
978
|
idTokens.forEach((idToken) => {
|
|
964
979
|
this.removeIdToken(generateCredentialKey(idToken));
|
|
965
980
|
});
|
|
981
|
+
if (performanceClient && correlationId) {
|
|
982
|
+
performanceClient.addFields(
|
|
983
|
+
{ multiMatchedID: idTokens.length },
|
|
984
|
+
correlationId
|
|
985
|
+
);
|
|
986
|
+
}
|
|
966
987
|
return null;
|
|
967
988
|
}
|
|
968
989
|
|
|
@@ -1047,15 +1068,18 @@ export abstract class CacheManager implements ICacheManager {
|
|
|
1047
1068
|
|
|
1048
1069
|
/**
|
|
1049
1070
|
* Retrieve AccessTokenEntity from cache
|
|
1050
|
-
* @param
|
|
1051
|
-
* @param
|
|
1052
|
-
* @param
|
|
1053
|
-
* @param
|
|
1071
|
+
* @param account {AccountInfo}
|
|
1072
|
+
* @param request {BaseAuthRequest}
|
|
1073
|
+
* @param tokenKeys {?TokenKeys}
|
|
1074
|
+
* @param performanceClient {?IPerformanceClient}
|
|
1075
|
+
* @param correlationId {?string}
|
|
1054
1076
|
*/
|
|
1055
1077
|
getAccessToken(
|
|
1056
1078
|
account: AccountInfo,
|
|
1057
1079
|
request: BaseAuthRequest,
|
|
1058
|
-
tokenKeys?: TokenKeys
|
|
1080
|
+
tokenKeys?: TokenKeys,
|
|
1081
|
+
performanceClient?: IPerformanceClient,
|
|
1082
|
+
correlationId?: string
|
|
1059
1083
|
): AccessTokenEntity | null {
|
|
1060
1084
|
this.commonLogger.trace("CacheManager - getAccessToken called");
|
|
1061
1085
|
const scopes = ScopeSet.createSearchScopes(request.scopes);
|
|
@@ -1119,6 +1143,12 @@ export abstract class CacheManager implements ICacheManager {
|
|
|
1119
1143
|
accessTokens.forEach((accessToken) => {
|
|
1120
1144
|
void this.removeAccessToken(generateCredentialKey(accessToken));
|
|
1121
1145
|
});
|
|
1146
|
+
if (performanceClient && correlationId) {
|
|
1147
|
+
performanceClient.addFields(
|
|
1148
|
+
{ multiMatchedAT: accessTokens.length },
|
|
1149
|
+
correlationId
|
|
1150
|
+
);
|
|
1151
|
+
}
|
|
1122
1152
|
return null;
|
|
1123
1153
|
}
|
|
1124
1154
|
|
|
@@ -1216,14 +1246,18 @@ export abstract class CacheManager implements ICacheManager {
|
|
|
1216
1246
|
|
|
1217
1247
|
/**
|
|
1218
1248
|
* Helper to retrieve the appropriate refresh token from cache
|
|
1219
|
-
* @param
|
|
1220
|
-
* @param
|
|
1221
|
-
* @param
|
|
1249
|
+
* @param account {AccountInfo}
|
|
1250
|
+
* @param familyRT {boolean}
|
|
1251
|
+
* @param tokenKeys {?TokenKeys}
|
|
1252
|
+
* @param performanceClient {?IPerformanceClient}
|
|
1253
|
+
* @param correlationId {?string}
|
|
1222
1254
|
*/
|
|
1223
1255
|
getRefreshToken(
|
|
1224
1256
|
account: AccountInfo,
|
|
1225
1257
|
familyRT: boolean,
|
|
1226
|
-
tokenKeys?: TokenKeys
|
|
1258
|
+
tokenKeys?: TokenKeys,
|
|
1259
|
+
performanceClient?: IPerformanceClient,
|
|
1260
|
+
correlationId?: string
|
|
1227
1261
|
): RefreshTokenEntity | null {
|
|
1228
1262
|
this.commonLogger.trace("CacheManager - getRefreshToken called");
|
|
1229
1263
|
const id = familyRT ? THE_FAMILY_ID : undefined;
|
|
@@ -1266,6 +1300,13 @@ export abstract class CacheManager implements ICacheManager {
|
|
|
1266
1300
|
}
|
|
1267
1301
|
// address the else case after remove functions address environment aliases
|
|
1268
1302
|
|
|
1303
|
+
if (numRefreshTokens > 1 && performanceClient && correlationId) {
|
|
1304
|
+
performanceClient.addFields(
|
|
1305
|
+
{ multiMatchedRT: numRefreshTokens },
|
|
1306
|
+
correlationId
|
|
1307
|
+
);
|
|
1308
|
+
}
|
|
1309
|
+
|
|
1269
1310
|
this.commonLogger.info(
|
|
1270
1311
|
"CacheManager:getRefreshToken - returning refresh token"
|
|
1271
1312
|
);
|
|
@@ -3,36 +3,8 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
export class ServerTelemetryEntity {
|
|
6
|
+
export type ServerTelemetryEntity = {
|
|
9
7
|
failedRequests: Array<string | number>;
|
|
10
8
|
errors: string[];
|
|
11
9
|
cacheHits: number;
|
|
12
|
-
|
|
13
|
-
constructor() {
|
|
14
|
-
this.failedRequests = [];
|
|
15
|
-
this.errors = [];
|
|
16
|
-
this.cacheHits = 0;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* validates if a given cache entry is "Telemetry", parses <key,value>
|
|
21
|
-
* @param key
|
|
22
|
-
* @param entity
|
|
23
|
-
*/
|
|
24
|
-
static isServerTelemetryEntity(key: string, entity?: object): boolean {
|
|
25
|
-
const validateKey: boolean =
|
|
26
|
-
key.indexOf(SERVER_TELEM_CONSTANTS.CACHE_KEY) === 0;
|
|
27
|
-
let validateEntity: boolean = true;
|
|
28
|
-
|
|
29
|
-
if (entity) {
|
|
30
|
-
validateEntity =
|
|
31
|
-
entity.hasOwnProperty("failedRequests") &&
|
|
32
|
-
entity.hasOwnProperty("errors") &&
|
|
33
|
-
entity.hasOwnProperty("cacheHits");
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
return validateKey && validateEntity;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
10
|
+
};
|
|
@@ -12,6 +12,7 @@ import {
|
|
|
12
12
|
import {
|
|
13
13
|
AuthenticationScheme,
|
|
14
14
|
CredentialType,
|
|
15
|
+
SERVER_TELEM_CONSTANTS,
|
|
15
16
|
Separators,
|
|
16
17
|
} from "../../utils/Constants";
|
|
17
18
|
import { TimeUtils } from "../../utils/TimeUtils";
|
|
@@ -304,3 +305,23 @@ function generateScheme(credentialEntity: CredentialEntity): string {
|
|
|
304
305
|
? credentialEntity.tokenType.toLowerCase()
|
|
305
306
|
: "";
|
|
306
307
|
}
|
|
308
|
+
|
|
309
|
+
/**
|
|
310
|
+
* validates if a given cache entry is "Telemetry", parses <key,value>
|
|
311
|
+
* @param key
|
|
312
|
+
* @param entity
|
|
313
|
+
*/
|
|
314
|
+
export function isServerTelemetryEntity(key: string, entity?: object): boolean {
|
|
315
|
+
const validateKey: boolean =
|
|
316
|
+
key.indexOf(SERVER_TELEM_CONSTANTS.CACHE_KEY) === 0;
|
|
317
|
+
let validateEntity: boolean = true;
|
|
318
|
+
|
|
319
|
+
if (entity) {
|
|
320
|
+
validateEntity =
|
|
321
|
+
entity.hasOwnProperty("failedRequests") &&
|
|
322
|
+
entity.hasOwnProperty("errors") &&
|
|
323
|
+
entity.hasOwnProperty("cacheHits");
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
return validateKey && validateEntity;
|
|
327
|
+
}
|
|
@@ -171,7 +171,7 @@ export class AuthorizationCodeClient extends BaseClient {
|
|
|
171
171
|
* @param hashFragment
|
|
172
172
|
*/
|
|
173
173
|
handleFragmentResponse(
|
|
174
|
-
|
|
174
|
+
serverParams: ServerAuthorizationCodeResponse,
|
|
175
175
|
cachedState: string
|
|
176
176
|
): AuthorizationCodePayload {
|
|
177
177
|
// Handle responses.
|
|
@@ -184,13 +184,6 @@ export class AuthorizationCodeClient extends BaseClient {
|
|
|
184
184
|
null
|
|
185
185
|
);
|
|
186
186
|
|
|
187
|
-
const serverParams: ServerAuthorizationCodeResponse =
|
|
188
|
-
UrlString.getDeserializedCodeResponse(
|
|
189
|
-
this.config.authOptions.authority.options.OIDCOptions
|
|
190
|
-
?.serverResponseType,
|
|
191
|
-
hashFragment
|
|
192
|
-
);
|
|
193
|
-
|
|
194
187
|
// Get code response
|
|
195
188
|
responseHandler.validateServerAuthorizationCodeResponse(
|
|
196
189
|
serverParams,
|
|
@@ -203,11 +196,8 @@ export class AuthorizationCodeClient extends BaseClient {
|
|
|
203
196
|
ClientAuthErrorCodes.authorizationCodeMissingFromServerResponse
|
|
204
197
|
);
|
|
205
198
|
}
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
// Code param is optional in ServerAuthorizationCodeResponse but required in AuthorizationCodePaylod
|
|
209
|
-
code: serverParams.code,
|
|
210
|
-
};
|
|
199
|
+
|
|
200
|
+
return serverParams as AuthorizationCodePayload;
|
|
211
201
|
}
|
|
212
202
|
|
|
213
203
|
/**
|
|
@@ -202,7 +202,13 @@ export class RefreshTokenClient extends BaseClient {
|
|
|
202
202
|
this.logger,
|
|
203
203
|
this.performanceClient,
|
|
204
204
|
request.correlationId
|
|
205
|
-
)(
|
|
205
|
+
)(
|
|
206
|
+
request.account,
|
|
207
|
+
foci,
|
|
208
|
+
undefined,
|
|
209
|
+
this.performanceClient,
|
|
210
|
+
request.correlationId
|
|
211
|
+
);
|
|
206
212
|
|
|
207
213
|
if (!refreshToken) {
|
|
208
214
|
throw createInteractionRequiredAuthError(
|
|
@@ -124,7 +124,9 @@ export class SilentFlowClient extends BaseClient {
|
|
|
124
124
|
const cacheRecord = this.cacheManager.readCacheRecord(
|
|
125
125
|
request.account,
|
|
126
126
|
request,
|
|
127
|
-
environment
|
|
127
|
+
environment,
|
|
128
|
+
this.performanceClient,
|
|
129
|
+
request.correlationId
|
|
128
130
|
);
|
|
129
131
|
|
|
130
132
|
if (!cacheRecord.accessToken) {
|
|
@@ -190,9 +192,11 @@ export class SilentFlowClient extends BaseClient {
|
|
|
190
192
|
},
|
|
191
193
|
correlationId
|
|
192
194
|
);
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
195
|
+
if (cacheOutcome !== CacheOutcome.NOT_APPLICABLE) {
|
|
196
|
+
this.logger.info(
|
|
197
|
+
`Token refresh is required due to cache outcome: ${cacheOutcome}`
|
|
198
|
+
);
|
|
199
|
+
}
|
|
196
200
|
}
|
|
197
201
|
|
|
198
202
|
/**
|
package/src/crypto/ICrypto.ts
CHANGED
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
createClientAuthError,
|
|
9
9
|
} from "../error/ClientAuthError";
|
|
10
10
|
import { BaseAuthRequest } from "../request/BaseAuthRequest";
|
|
11
|
-
import { SignedHttpRequest } from "./SignedHttpRequest";
|
|
11
|
+
import { ShrOptions, SignedHttpRequest } from "./SignedHttpRequest";
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* The PkceCodes type describes the structure
|
|
@@ -22,7 +22,11 @@ export type PkceCodes = {
|
|
|
22
22
|
|
|
23
23
|
export type SignedHttpRequestParameters = Pick<
|
|
24
24
|
BaseAuthRequest,
|
|
25
|
-
|
|
25
|
+
| "resourceRequestMethod"
|
|
26
|
+
| "resourceRequestUri"
|
|
27
|
+
| "shrClaims"
|
|
28
|
+
| "shrNonce"
|
|
29
|
+
| "shrOptions"
|
|
26
30
|
> & {
|
|
27
31
|
correlationId?: string;
|
|
28
32
|
};
|
|
@@ -68,6 +72,7 @@ export interface ICrypto {
|
|
|
68
72
|
signJwt(
|
|
69
73
|
payload: SignedHttpRequest,
|
|
70
74
|
kid: string,
|
|
75
|
+
shrOptions?: ShrOptions,
|
|
71
76
|
correlationId?: string
|
|
72
77
|
): Promise<string>;
|
|
73
78
|
/**
|
package/src/crypto/JoseHeader.ts
CHANGED
|
@@ -7,17 +7,17 @@ import {
|
|
|
7
7
|
JoseHeaderErrorCodes,
|
|
8
8
|
createJoseHeaderError,
|
|
9
9
|
} from "../error/JoseHeaderError";
|
|
10
|
-
import {
|
|
10
|
+
import { JsonWebTokenTypes } from "../utils/Constants";
|
|
11
11
|
|
|
12
12
|
export type JoseHeaderOptions = {
|
|
13
|
-
typ?:
|
|
13
|
+
typ?: JsonWebTokenTypes;
|
|
14
14
|
alg?: string;
|
|
15
15
|
kid?: string;
|
|
16
16
|
};
|
|
17
17
|
|
|
18
18
|
/** @internal */
|
|
19
19
|
export class JoseHeader {
|
|
20
|
-
public typ?:
|
|
20
|
+
public typ?: JsonWebTokenTypes;
|
|
21
21
|
public alg?: string;
|
|
22
22
|
public kid?: string;
|
|
23
23
|
|
|
@@ -48,7 +48,7 @@ export class JoseHeader {
|
|
|
48
48
|
|
|
49
49
|
const shrHeader = new JoseHeader({
|
|
50
50
|
// Access Token PoP headers must have type pop, but the type header can be overriden for special cases
|
|
51
|
-
typ: shrHeaderOptions.typ ||
|
|
51
|
+
typ: shrHeaderOptions.typ || JsonWebTokenTypes.Pop,
|
|
52
52
|
kid: shrHeaderOptions.kid,
|
|
53
53
|
alg: shrHeaderOptions.alg,
|
|
54
54
|
});
|
|
@@ -133,6 +133,7 @@ export class PopTokenGenerator {
|
|
|
133
133
|
resourceRequestUri,
|
|
134
134
|
shrClaims,
|
|
135
135
|
shrNonce,
|
|
136
|
+
shrOptions,
|
|
136
137
|
} = request;
|
|
137
138
|
|
|
138
139
|
const resourceUrlString = resourceRequestUri
|
|
@@ -154,6 +155,7 @@ export class PopTokenGenerator {
|
|
|
154
155
|
...claims,
|
|
155
156
|
},
|
|
156
157
|
keyId,
|
|
158
|
+
shrOptions,
|
|
157
159
|
request.correlationId
|
|
158
160
|
);
|
|
159
161
|
}
|
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
+
import { JoseHeaderOptions } from "./JoseHeader";
|
|
7
|
+
|
|
6
8
|
export type SignedHttpRequest = {
|
|
7
9
|
at?: string;
|
|
8
10
|
cnf?: object;
|
|
@@ -14,3 +16,7 @@ export type SignedHttpRequest = {
|
|
|
14
16
|
nonce?: string;
|
|
15
17
|
client_claims?: string;
|
|
16
18
|
};
|
|
19
|
+
|
|
20
|
+
export type ShrOptions = {
|
|
21
|
+
header: JoseHeaderOptions;
|
|
22
|
+
};
|
package/src/index.ts
CHANGED
|
@@ -105,7 +105,7 @@ export {
|
|
|
105
105
|
DEFAULT_CRYPTO_IMPLEMENTATION,
|
|
106
106
|
SignedHttpRequestParameters,
|
|
107
107
|
} from "./crypto/ICrypto";
|
|
108
|
-
export { SignedHttpRequest } from "./crypto/SignedHttpRequest";
|
|
108
|
+
export { SignedHttpRequest, ShrOptions } from "./crypto/SignedHttpRequest";
|
|
109
109
|
export { IGuidGenerator } from "./crypto/IGuidGenerator";
|
|
110
110
|
export { JoseHeader } from "./crypto/JoseHeader";
|
|
111
111
|
// Request
|
|
@@ -193,6 +193,7 @@ export {
|
|
|
193
193
|
GrantType,
|
|
194
194
|
AADAuthorityConstants,
|
|
195
195
|
HttpStatus,
|
|
196
|
+
JsonWebTokenTypes,
|
|
196
197
|
} from "./utils/Constants";
|
|
197
198
|
export { StringUtils } from "./utils/StringUtils";
|
|
198
199
|
export { StringDict } from "./utils/MsalTypes";
|
|
@@ -202,6 +203,7 @@ export {
|
|
|
202
203
|
LibraryStateObject,
|
|
203
204
|
} from "./utils/ProtocolUtils";
|
|
204
205
|
export { TimeUtils } from "./utils/TimeUtils";
|
|
206
|
+
export * as UrlUtils from "./utils/UrlUtils";
|
|
205
207
|
export * from "./utils/FunctionWrappers";
|
|
206
208
|
// Server Telemetry
|
|
207
209
|
export { ServerTelemetryManager } from "./telemetry/server/ServerTelemetryManager";
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
+
import { ShrOptions } from "../crypto/SignedHttpRequest";
|
|
6
7
|
import { AuthenticationScheme } from "../utils/Constants";
|
|
7
8
|
|
|
8
9
|
/**
|
|
@@ -19,4 +20,5 @@ export type RequestThumbprint = {
|
|
|
19
20
|
resourceRequestUri?: string;
|
|
20
21
|
shrClaims?: string;
|
|
21
22
|
sshKid?: string;
|
|
23
|
+
shrOptions?: ShrOptions;
|
|
22
24
|
};
|
package/src/packageMetadata.ts
CHANGED
|
@@ -7,6 +7,7 @@ import { AuthenticationScheme } from "../utils/Constants";
|
|
|
7
7
|
import { AzureCloudOptions } from "../config/ClientConfiguration";
|
|
8
8
|
import { StringDict } from "../utils/MsalTypes";
|
|
9
9
|
import { StoreInCache } from "./StoreInCache";
|
|
10
|
+
import { ShrOptions } from "../crypto/SignedHttpRequest";
|
|
10
11
|
|
|
11
12
|
/**
|
|
12
13
|
* BaseAuthRequest
|
|
@@ -17,6 +18,7 @@ import { StoreInCache } from "./StoreInCache";
|
|
|
17
18
|
* - claims - A stringified claims request which will be added to all /authorize and /token calls
|
|
18
19
|
* - shrClaims - A stringified claims object which will be added to a Signed HTTP Request
|
|
19
20
|
* - shrNonce - A server-generated timestamp that has been encrypted and base64URL encoded, which will be added to a Signed HTTP Request.
|
|
21
|
+
* - shrOptions - An object containing options for the Signed HTTP Request
|
|
20
22
|
* - resourceRequestMethod - HTTP Request type used to request data from the resource (i.e. "GET", "POST", etc.). Used for proof-of-possession flows.
|
|
21
23
|
* - resourceRequestUri - URI that token will be used for. Used for proof-of-possession flows.
|
|
22
24
|
* - sshJwk - A stringified JSON Web Key representing a public key that can be signed by an SSH certificate.
|
|
@@ -34,6 +36,7 @@ export type BaseAuthRequest = {
|
|
|
34
36
|
claims?: string;
|
|
35
37
|
shrClaims?: string;
|
|
36
38
|
shrNonce?: string;
|
|
39
|
+
shrOptions?: ShrOptions;
|
|
37
40
|
resourceRequestMethod?: string;
|
|
38
41
|
resourceRequestUri?: string;
|
|
39
42
|
sshJwk?: string;
|
|
@@ -208,7 +208,7 @@ export const PerformanceEvents = {
|
|
|
208
208
|
* Functions from InteractionHandler (msal-browser)
|
|
209
209
|
*/
|
|
210
210
|
HandleCodeResponseFromServer: "handleCodeResponseFromServer",
|
|
211
|
-
|
|
211
|
+
HandleCodeResponse: "handleCodeResponse",
|
|
212
212
|
UpdateTokenEndpointAuthority: "updateTokenEndpointAuthority",
|
|
213
213
|
|
|
214
214
|
/**
|
|
@@ -229,6 +229,7 @@ export const PerformanceEvents = {
|
|
|
229
229
|
* handleServerTokenResponse API in ResponseHandler (msal-common)
|
|
230
230
|
*/
|
|
231
231
|
HandleServerTokenResponse: "handleServerTokenResponse",
|
|
232
|
+
DeserializeResponse: "deserializeResponse",
|
|
232
233
|
|
|
233
234
|
/**
|
|
234
235
|
* Authority functions
|
|
@@ -558,6 +559,13 @@ export type PerformanceEvent = {
|
|
|
558
559
|
* Nested App Auth Fields
|
|
559
560
|
*/
|
|
560
561
|
nestedAppAuthRequest?: boolean;
|
|
562
|
+
|
|
563
|
+
/**
|
|
564
|
+
* Multiple matched access/id/refresh tokens in the cache
|
|
565
|
+
*/
|
|
566
|
+
multiMatchedAT?: number;
|
|
567
|
+
multiMatchedID?: number;
|
|
568
|
+
multiMatchedRT?: number;
|
|
561
569
|
};
|
|
562
570
|
|
|
563
571
|
export const IntFields: ReadonlySet<string> = new Set([
|
|
@@ -570,4 +578,7 @@ export const IntFields: ReadonlySet<string> = new Set([
|
|
|
570
578
|
"queuedTimeMs",
|
|
571
579
|
"startTimeMs",
|
|
572
580
|
"status",
|
|
581
|
+
"multiMatchedAT",
|
|
582
|
+
"multiMatchedID",
|
|
583
|
+
"multiMatchedRT",
|
|
573
584
|
]);
|
|
@@ -160,7 +160,11 @@ export class ServerTelemetryManager {
|
|
|
160
160
|
* Get the server telemetry entity from cache or initialize a new one
|
|
161
161
|
*/
|
|
162
162
|
getLastRequests(): ServerTelemetryEntity {
|
|
163
|
-
const initialValue: ServerTelemetryEntity =
|
|
163
|
+
const initialValue: ServerTelemetryEntity = {
|
|
164
|
+
failedRequests: [],
|
|
165
|
+
errors: [],
|
|
166
|
+
cacheHits: 0,
|
|
167
|
+
};
|
|
164
168
|
const lastRequests = this.cacheManager.getServerTelemetry(
|
|
165
169
|
this.telemetryCacheKey
|
|
166
170
|
) as ServerTelemetryEntity;
|
|
@@ -181,11 +185,13 @@ export class ServerTelemetryManager {
|
|
|
181
185
|
this.cacheManager.removeItem(this.telemetryCacheKey);
|
|
182
186
|
} else {
|
|
183
187
|
// Partial data was flushed to server, construct a new telemetry cache item with errors that were not flushed
|
|
184
|
-
const serverTelemEntity =
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
lastRequests.errors.slice(numErrorsFlushed)
|
|
188
|
+
const serverTelemEntity: ServerTelemetryEntity = {
|
|
189
|
+
failedRequests: lastRequests.failedRequests.slice(
|
|
190
|
+
numErrorsFlushed * 2
|
|
191
|
+
), // failedRequests contains 2 items for each error
|
|
192
|
+
errors: lastRequests.errors.slice(numErrorsFlushed),
|
|
193
|
+
cacheHits: 0,
|
|
194
|
+
};
|
|
189
195
|
|
|
190
196
|
this.cacheManager.setServerTelemetry(
|
|
191
197
|
this.telemetryCacheKey,
|