@azure/msal-common 6.3.0-beta.0 → 7.0.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/LICENSE +21 -21
- package/README.md +62 -62
- package/dist/_virtual/_tslib.js +1 -1
- package/dist/account/AuthToken.js +1 -1
- package/dist/account/AuthToken.js.map +1 -1
- package/dist/account/CcsCredential.js +1 -1
- package/dist/account/CcsCredential.js.map +1 -1
- package/dist/account/ClientCredentials.d.ts +15 -0
- package/dist/account/ClientCredentials.d.ts.map +1 -0
- package/dist/account/ClientInfo.js +1 -1
- package/dist/account/ClientInfo.js.map +1 -1
- package/dist/account/TokenClaims.d.ts +1 -1
- package/dist/account/TokenClaims.d.ts.map +1 -1
- package/dist/authority/Authority.js +1 -1
- package/dist/authority/Authority.js.map +1 -1
- package/dist/authority/AuthorityFactory.js +1 -1
- package/dist/authority/AuthorityFactory.js.map +1 -1
- package/dist/authority/AuthorityOptions.js +1 -1
- package/dist/authority/AuthorityOptions.js.map +1 -1
- package/dist/authority/AuthorityType.js +1 -1
- package/dist/authority/AuthorityType.js.map +1 -1
- package/dist/authority/CloudInstanceDiscoveryResponse.js +1 -1
- package/dist/authority/CloudInstanceDiscoveryResponse.js.map +1 -1
- package/dist/authority/OpenIdConfigResponse.js +1 -1
- package/dist/authority/OpenIdConfigResponse.js.map +1 -1
- package/dist/authority/ProtocolMode.js +1 -1
- package/dist/authority/ProtocolMode.js.map +1 -1
- package/dist/authority/RegionDiscovery.js +1 -1
- package/dist/authority/RegionDiscovery.js.map +1 -1
- package/dist/cache/CacheManager.d.ts +2 -2
- package/dist/cache/CacheManager.d.ts.map +1 -1
- package/dist/cache/CacheManager.js +9 -9
- package/dist/cache/CacheManager.js.map +1 -1
- package/dist/cache/entities/AccessTokenEntity.d.ts +1 -1
- package/dist/cache/entities/AccessTokenEntity.d.ts.map +1 -1
- package/dist/cache/entities/AccessTokenEntity.js +3 -3
- package/dist/cache/entities/AccessTokenEntity.js.map +1 -1
- package/dist/cache/entities/AccountEntity.d.ts +2 -4
- package/dist/cache/entities/AccountEntity.d.ts.map +1 -1
- package/dist/cache/entities/AccountEntity.js +3 -6
- package/dist/cache/entities/AccountEntity.js.map +1 -1
- package/dist/cache/entities/AppMetadataEntity.js +1 -1
- package/dist/cache/entities/AppMetadataEntity.js.map +1 -1
- package/dist/cache/entities/AuthorityMetadataEntity.js +1 -1
- package/dist/cache/entities/AuthorityMetadataEntity.js.map +1 -1
- package/dist/cache/entities/CacheRecord.js +1 -1
- package/dist/cache/entities/CacheRecord.js.map +1 -1
- package/dist/cache/entities/CredentialEntity.d.ts +2 -2
- package/dist/cache/entities/CredentialEntity.d.ts.map +1 -1
- package/dist/cache/entities/CredentialEntity.js +2 -2
- package/dist/cache/entities/CredentialEntity.js.map +1 -1
- package/dist/cache/entities/IdTokenEntity.d.ts +1 -1
- package/dist/cache/entities/IdTokenEntity.d.ts.map +1 -1
- package/dist/cache/entities/IdTokenEntity.js +2 -3
- package/dist/cache/entities/IdTokenEntity.js.map +1 -1
- package/dist/cache/entities/RefreshTokenEntity.d.ts +1 -1
- package/dist/cache/entities/RefreshTokenEntity.d.ts.map +1 -1
- package/dist/cache/entities/RefreshTokenEntity.js +3 -3
- package/dist/cache/entities/RefreshTokenEntity.js.map +1 -1
- package/dist/cache/entities/ServerTelemetryEntity.js +1 -1
- package/dist/cache/entities/ServerTelemetryEntity.js.map +1 -1
- package/dist/cache/entities/ThrottlingEntity.js +1 -1
- package/dist/cache/entities/ThrottlingEntity.js.map +1 -1
- package/dist/cache/persistence/TokenCacheContext.js +1 -1
- package/dist/cache/persistence/TokenCacheContext.js.map +1 -1
- package/dist/cache/utils/CacheTypes.d.ts +1 -1
- package/dist/cache/utils/CacheTypes.d.ts.map +1 -1
- package/dist/client/AuthorizationCodeClient.d.ts.map +1 -1
- package/dist/client/AuthorizationCodeClient.js +12 -14
- package/dist/client/AuthorizationCodeClient.js.map +1 -1
- package/dist/client/BaseClient.js +1 -1
- package/dist/client/BaseClient.js.map +1 -1
- package/dist/client/ClientCredentialClient.d.ts.map +1 -1
- package/dist/client/ClientCredentialClient.js +4 -3
- package/dist/client/ClientCredentialClient.js.map +1 -1
- package/dist/client/DeviceCodeClient.js +1 -1
- package/dist/client/DeviceCodeClient.js.map +1 -1
- package/dist/client/OnBehalfOfClient.d.ts +12 -9
- package/dist/client/OnBehalfOfClient.d.ts.map +1 -1
- package/dist/client/OnBehalfOfClient.js +87 -59
- package/dist/client/OnBehalfOfClient.js.map +1 -1
- package/dist/client/RefreshTokenClient.d.ts.map +1 -1
- package/dist/client/RefreshTokenClient.js +5 -4
- package/dist/client/RefreshTokenClient.js.map +1 -1
- package/dist/client/SilentFlowClient.js +1 -1
- package/dist/client/SilentFlowClient.js.map +1 -1
- package/dist/client/UsernamePasswordClient.js +1 -1
- package/dist/client/UsernamePasswordClient.js.map +1 -1
- package/dist/config/ClientConfiguration.d.ts +1 -10
- package/dist/config/ClientConfiguration.d.ts.map +1 -1
- package/dist/config/ClientConfiguration.js +1 -1
- package/dist/config/ClientConfiguration.js.map +1 -1
- package/dist/crypto/ICrypto.js +1 -1
- package/dist/crypto/ICrypto.js.map +1 -1
- package/dist/crypto/JoseHeader.d.ts +22 -0
- package/dist/crypto/JoseHeader.d.ts.map +1 -0
- package/dist/crypto/JoseHeader.js +45 -0
- package/dist/crypto/JoseHeader.js.map +1 -0
- package/dist/crypto/PopTokenGenerator.d.ts +9 -9
- package/dist/crypto/PopTokenGenerator.d.ts.map +1 -1
- package/dist/crypto/PopTokenGenerator.js +19 -31
- package/dist/crypto/PopTokenGenerator.js.map +1 -1
- package/dist/error/AuthError.js +1 -1
- package/dist/error/AuthError.js.map +1 -1
- package/dist/error/ClientAuthError.d.ts +8 -0
- package/dist/error/ClientAuthError.d.ts.map +1 -1
- package/dist/error/ClientAuthError.js +11 -1
- package/dist/error/ClientAuthError.js.map +1 -1
- package/dist/error/ClientConfigurationError.js +1 -1
- package/dist/error/ClientConfigurationError.js.map +1 -1
- package/dist/error/InteractionRequiredAuthError.js +1 -1
- package/dist/error/InteractionRequiredAuthError.js.map +1 -1
- package/dist/error/JoseHeaderError.d.ts +29 -0
- package/dist/error/JoseHeaderError.d.ts.map +1 -0
- package/dist/error/JoseHeaderError.js +50 -0
- package/dist/error/JoseHeaderError.js.map +1 -0
- package/dist/error/ServerError.js +1 -1
- package/dist/error/ServerError.js.map +1 -1
- package/dist/index.cjs.js +267 -148
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/logger/Logger.js +1 -1
- package/dist/logger/Logger.js.map +1 -1
- package/dist/network/INetworkModule.js +1 -1
- package/dist/network/INetworkModule.js.map +1 -1
- package/dist/network/NetworkManager.js +1 -1
- package/dist/network/NetworkManager.js.map +1 -1
- package/dist/network/ThrottlingUtils.js +1 -1
- package/dist/network/ThrottlingUtils.js.map +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/packageMetadata.js.map +1 -1
- package/dist/request/AuthenticationHeaderParser.js +1 -1
- package/dist/request/AuthenticationHeaderParser.js.map +1 -1
- package/dist/request/BaseAuthRequest.d.ts +2 -2
- package/dist/request/CommonClientCredentialRequest.d.ts +2 -0
- package/dist/request/CommonClientCredentialRequest.d.ts.map +1 -1
- package/dist/request/RequestParameterBuilder.d.ts.map +1 -1
- package/dist/request/RequestParameterBuilder.js +9 -5
- package/dist/request/RequestParameterBuilder.js.map +1 -1
- package/dist/request/RequestValidator.js +1 -1
- package/dist/request/RequestValidator.js.map +1 -1
- package/dist/request/ScopeSet.js +1 -1
- package/dist/request/ScopeSet.js.map +1 -1
- package/dist/response/ResponseHandler.d.ts +1 -1
- package/dist/response/ResponseHandler.d.ts.map +1 -1
- package/dist/response/ResponseHandler.js +23 -19
- package/dist/response/ResponseHandler.js.map +1 -1
- package/dist/telemetry/performance/PerformanceClient.js +1 -1
- package/dist/telemetry/performance/PerformanceClient.js.map +1 -1
- package/dist/telemetry/performance/PerformanceEvent.d.ts +12 -0
- package/dist/telemetry/performance/PerformanceEvent.d.ts.map +1 -1
- package/dist/telemetry/performance/PerformanceEvent.js +1 -1
- package/dist/telemetry/performance/PerformanceEvent.js.map +1 -1
- package/dist/telemetry/performance/StubPerformanceClient.js +1 -1
- package/dist/telemetry/performance/StubPerformanceClient.js.map +1 -1
- package/dist/telemetry/server/ServerTelemetryManager.js +1 -1
- package/dist/telemetry/server/ServerTelemetryManager.js.map +1 -1
- package/dist/url/UrlString.js +1 -1
- package/dist/url/UrlString.js.map +1 -1
- package/dist/utils/Constants.d.ts +4 -0
- package/dist/utils/Constants.d.ts.map +1 -1
- package/dist/utils/Constants.js +8 -3
- package/dist/utils/Constants.js.map +1 -1
- package/dist/utils/ProtocolUtils.js +1 -1
- package/dist/utils/ProtocolUtils.js.map +1 -1
- package/dist/utils/StringUtils.js +1 -1
- package/dist/utils/StringUtils.js.map +1 -1
- package/dist/utils/TimeUtils.js +1 -1
- package/dist/utils/TimeUtils.js.map +1 -1
- package/package.json +74 -74
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
/*! @azure/msal-common
|
|
1
|
+
/*! @azure/msal-common v7.0.0 2022-06-13 */
|
|
2
2
|
'use strict';
|
|
3
3
|
import { __extends, __awaiter, __generator } from '../_virtual/_tslib.js';
|
|
4
4
|
import { BaseClient } from './BaseClient.js';
|
|
5
5
|
import { RequestParameterBuilder } from '../request/RequestParameterBuilder.js';
|
|
6
6
|
import { ScopeSet } from '../request/ScopeSet.js';
|
|
7
|
-
import { CredentialType, GrantType, AADServerParamKeys, CacheOutcome, Constants } from '../utils/Constants.js';
|
|
7
|
+
import { AuthenticationScheme, CredentialType, GrantType, AADServerParamKeys, CacheOutcome, Constants } from '../utils/Constants.js';
|
|
8
8
|
import { ResponseHandler } from '../response/ResponseHandler.js';
|
|
9
9
|
import { TimeUtils } from '../utils/TimeUtils.js';
|
|
10
10
|
import { AuthToken } from '../account/AuthToken.js';
|
|
@@ -28,44 +28,64 @@ var OnBehalfOfClient = /** @class */ (function (_super) {
|
|
|
28
28
|
*/
|
|
29
29
|
OnBehalfOfClient.prototype.acquireToken = function (request) {
|
|
30
30
|
return __awaiter(this, void 0, void 0, function () {
|
|
31
|
-
var
|
|
32
|
-
return __generator(this, function (
|
|
33
|
-
switch (
|
|
31
|
+
var _a;
|
|
32
|
+
return __generator(this, function (_b) {
|
|
33
|
+
switch (_b.label) {
|
|
34
34
|
case 0:
|
|
35
35
|
this.scopeSet = new ScopeSet(request.scopes || []);
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
case
|
|
36
|
+
// generate the user_assertion_hash for OBOAssertion
|
|
37
|
+
_a = this;
|
|
38
|
+
return [4 /*yield*/, this.cryptoUtils.hashString(request.oboAssertion)];
|
|
39
|
+
case 1:
|
|
40
|
+
// generate the user_assertion_hash for OBOAssertion
|
|
41
|
+
_a.userAssertionHash = _b.sent();
|
|
42
|
+
if (!request.skipCache) return [3 /*break*/, 3];
|
|
43
|
+
return [4 /*yield*/, this.executeTokenRequest(request, this.authority, this.userAssertionHash)];
|
|
44
|
+
case 2: return [2 /*return*/, _b.sent()];
|
|
40
45
|
case 3:
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
case
|
|
45
|
-
|
|
46
|
+
_b.trys.push([3, 5, , 7]);
|
|
47
|
+
return [4 /*yield*/, this.getCachedAuthenticationResult(request)];
|
|
48
|
+
case 4: return [2 /*return*/, _b.sent()];
|
|
49
|
+
case 5:
|
|
50
|
+
_b.sent();
|
|
51
|
+
return [4 /*yield*/, this.executeTokenRequest(request, this.authority, this.userAssertionHash)];
|
|
52
|
+
case 6:
|
|
53
|
+
// Any failure falls back to interactive request, once we implement distributed cache, we plan to handle `createRefreshRequiredError` to refresh using the RT
|
|
54
|
+
return [2 /*return*/, _b.sent()];
|
|
55
|
+
case 7: return [2 /*return*/];
|
|
46
56
|
}
|
|
47
57
|
});
|
|
48
58
|
});
|
|
49
59
|
};
|
|
50
60
|
/**
|
|
51
61
|
* look up cache for tokens
|
|
62
|
+
* Find idtoken in the cache
|
|
63
|
+
* Find accessToken based on user assertion and account info in the cache
|
|
64
|
+
* Please note we are not yet supported OBO tokens refreshed with long lived RT. User will have to send a new assertion if the current access token expires
|
|
65
|
+
* This is to prevent security issues when the assertion changes over time, however, longlived RT helps retaining the session
|
|
52
66
|
* @param request
|
|
53
67
|
*/
|
|
54
68
|
OnBehalfOfClient.prototype.getCachedAuthenticationResult = function (request) {
|
|
55
|
-
var _a;
|
|
69
|
+
var _a, _b;
|
|
56
70
|
return __awaiter(this, void 0, void 0, function () {
|
|
57
71
|
var cachedAccessToken, cachedIdToken, idTokenObject, cachedAccount, localAccountId, accountInfo;
|
|
58
|
-
return __generator(this, function (
|
|
59
|
-
switch (
|
|
72
|
+
return __generator(this, function (_c) {
|
|
73
|
+
switch (_c.label) {
|
|
60
74
|
case 0:
|
|
61
|
-
cachedAccessToken = this.
|
|
62
|
-
if (!cachedAccessToken
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
75
|
+
cachedAccessToken = this.readAccessTokenFromCacheForOBO(this.config.authOptions.clientId, request);
|
|
76
|
+
if (!cachedAccessToken) {
|
|
77
|
+
// Must refresh due to non-existent access_token.
|
|
78
|
+
(_a = this.serverTelemetryManager) === null || _a === void 0 ? void 0 : _a.setCacheOutcome(CacheOutcome.NO_CACHED_ACCESS_TOKEN);
|
|
79
|
+
this.logger.info("SilentFlowClient:acquireCachedToken - No access token found in cache for the given properties.");
|
|
80
|
+
throw ClientAuthError.createRefreshRequiredError();
|
|
81
|
+
}
|
|
82
|
+
else if (TimeUtils.isTokenExpired(cachedAccessToken.expiresOn, this.config.systemOptions.tokenRenewalOffsetSeconds)) {
|
|
83
|
+
// Access token expired, will need to renewed
|
|
84
|
+
(_b = this.serverTelemetryManager) === null || _b === void 0 ? void 0 : _b.setCacheOutcome(CacheOutcome.CACHED_ACCESS_TOKEN_EXPIRED);
|
|
85
|
+
this.logger.info("OnbehalfofFlow:getCachedAuthenticationResult - Cached access token is expired or will expire within " + this.config.systemOptions.tokenRenewalOffsetSeconds + " seconds.");
|
|
86
|
+
throw ClientAuthError.createRefreshRequiredError();
|
|
67
87
|
}
|
|
68
|
-
cachedIdToken = this.
|
|
88
|
+
cachedIdToken = this.readIdTokenFromCacheForOBO(request, cachedAccessToken.homeAccountId);
|
|
69
89
|
cachedAccount = null;
|
|
70
90
|
if (cachedIdToken) {
|
|
71
91
|
idTokenObject = new AuthToken(cachedIdToken.secret, this.config.cryptoInterface);
|
|
@@ -77,7 +97,11 @@ var OnBehalfOfClient = /** @class */ (function (_super) {
|
|
|
77
97
|
username: Constants.EMPTY_STRING,
|
|
78
98
|
localAccountId: localAccountId || Constants.EMPTY_STRING
|
|
79
99
|
};
|
|
80
|
-
cachedAccount = this.readAccountFromCache(accountInfo);
|
|
100
|
+
cachedAccount = this.cacheManager.readAccountFromCache(accountInfo);
|
|
101
|
+
}
|
|
102
|
+
// increment telemetry cache hit counter
|
|
103
|
+
if (this.config.serverTelemetryManager) {
|
|
104
|
+
this.config.serverTelemetryManager.incrementCacheHits();
|
|
81
105
|
}
|
|
82
106
|
return [4 /*yield*/, ResponseHandler.generateAuthenticationResult(this.cryptoUtils, this.authority, {
|
|
83
107
|
account: cachedAccount,
|
|
@@ -86,45 +110,23 @@ var OnBehalfOfClient = /** @class */ (function (_super) {
|
|
|
86
110
|
refreshToken: null,
|
|
87
111
|
appMetadata: null
|
|
88
112
|
}, true, request, idTokenObject)];
|
|
89
|
-
case 1: return [2 /*return*/,
|
|
113
|
+
case 1: return [2 /*return*/, _c.sent()];
|
|
90
114
|
}
|
|
91
115
|
});
|
|
92
116
|
});
|
|
93
117
|
};
|
|
94
118
|
/**
|
|
95
|
-
* read
|
|
96
|
-
*
|
|
97
|
-
*/
|
|
98
|
-
OnBehalfOfClient.prototype.readAccessTokenFromCache = function () {
|
|
99
|
-
var accessTokenFilter = {
|
|
100
|
-
environment: this.authority.canonicalAuthorityUrlComponents.HostNameAndPort,
|
|
101
|
-
credentialType: CredentialType.ACCESS_TOKEN,
|
|
102
|
-
clientId: this.config.authOptions.clientId,
|
|
103
|
-
realm: this.authority.tenant,
|
|
104
|
-
target: this.scopeSet.printScopesLowerCase(),
|
|
105
|
-
};
|
|
106
|
-
var credentialCache = this.cacheManager.getCredentialsFilteredBy(accessTokenFilter);
|
|
107
|
-
var accessTokens = Object.keys(credentialCache.accessTokens).map(function (key) { return credentialCache.accessTokens[key]; });
|
|
108
|
-
var numAccessTokens = accessTokens.length;
|
|
109
|
-
if (numAccessTokens < 1) {
|
|
110
|
-
return null;
|
|
111
|
-
}
|
|
112
|
-
else if (numAccessTokens > 1) {
|
|
113
|
-
throw ClientAuthError.createMultipleMatchingTokensInCacheError();
|
|
114
|
-
}
|
|
115
|
-
return accessTokens[0];
|
|
116
|
-
};
|
|
117
|
-
/**
|
|
118
|
-
* read idtoken from cache TODO: CacheManager API should be used here instead
|
|
119
|
+
* read idtoken from cache, this is a specific implementation for OBO as the requirements differ from a generic lookup in the cacheManager
|
|
120
|
+
* Certain use cases of OBO flow do not expect an idToken in the cache/or from the service
|
|
119
121
|
* @param request
|
|
120
122
|
*/
|
|
121
|
-
OnBehalfOfClient.prototype.
|
|
123
|
+
OnBehalfOfClient.prototype.readIdTokenFromCacheForOBO = function (request, atHomeAccountId) {
|
|
122
124
|
var idTokenFilter = {
|
|
125
|
+
homeAccountId: atHomeAccountId,
|
|
123
126
|
environment: this.authority.canonicalAuthorityUrlComponents.HostNameAndPort,
|
|
124
127
|
credentialType: CredentialType.ID_TOKEN,
|
|
125
128
|
clientId: this.config.authOptions.clientId,
|
|
126
|
-
realm: this.authority.tenant
|
|
127
|
-
oboAssertion: request.oboAssertion
|
|
129
|
+
realm: this.authority.tenant
|
|
128
130
|
};
|
|
129
131
|
var credentialCache = this.cacheManager.getCredentialsFilteredBy(idTokenFilter);
|
|
130
132
|
var idTokens = Object.keys(credentialCache.idTokens).map(function (key) { return credentialCache.idTokens[key]; });
|
|
@@ -135,18 +137,44 @@ var OnBehalfOfClient = /** @class */ (function (_super) {
|
|
|
135
137
|
return idTokens[0];
|
|
136
138
|
};
|
|
137
139
|
/**
|
|
138
|
-
*
|
|
139
|
-
* @param
|
|
140
|
+
* Fetches the cached access token based on incoming assertion
|
|
141
|
+
* @param clientId
|
|
142
|
+
* @param request
|
|
143
|
+
* @param userAssertionHash
|
|
140
144
|
*/
|
|
141
|
-
OnBehalfOfClient.prototype.
|
|
142
|
-
|
|
145
|
+
OnBehalfOfClient.prototype.readAccessTokenFromCacheForOBO = function (clientId, request) {
|
|
146
|
+
var authScheme = request.authenticationScheme || AuthenticationScheme.BEARER;
|
|
147
|
+
/*
|
|
148
|
+
* Distinguish between Bearer and PoP/SSH token cache types
|
|
149
|
+
* Cast to lowercase to handle "bearer" from ADFS
|
|
150
|
+
*/
|
|
151
|
+
var credentialType = (authScheme && authScheme.toLowerCase() !== AuthenticationScheme.BEARER.toLowerCase()) ? CredentialType.ACCESS_TOKEN_WITH_AUTH_SCHEME : CredentialType.ACCESS_TOKEN;
|
|
152
|
+
var accessTokenFilter = {
|
|
153
|
+
credentialType: credentialType,
|
|
154
|
+
clientId: clientId,
|
|
155
|
+
target: this.scopeSet.printScopesLowerCase(),
|
|
156
|
+
tokenType: authScheme,
|
|
157
|
+
keyId: request.sshKid,
|
|
158
|
+
requestedClaimsHash: request.requestedClaimsHash,
|
|
159
|
+
userAssertionHash: this.userAssertionHash
|
|
160
|
+
};
|
|
161
|
+
var credentialCache = this.cacheManager.getCredentialsFilteredBy(accessTokenFilter);
|
|
162
|
+
var accessTokens = Object.keys(credentialCache.accessTokens).map(function (key) { return credentialCache.accessTokens[key]; });
|
|
163
|
+
var numAccessTokens = accessTokens.length;
|
|
164
|
+
if (numAccessTokens < 1) {
|
|
165
|
+
return null;
|
|
166
|
+
}
|
|
167
|
+
else if (numAccessTokens > 1) {
|
|
168
|
+
throw ClientAuthError.createMultipleMatchingTokensInCacheError();
|
|
169
|
+
}
|
|
170
|
+
return accessTokens[0];
|
|
143
171
|
};
|
|
144
172
|
/**
|
|
145
173
|
* Make a network call to the server requesting credentials
|
|
146
174
|
* @param request
|
|
147
175
|
* @param authority
|
|
148
176
|
*/
|
|
149
|
-
OnBehalfOfClient.prototype.executeTokenRequest = function (request, authority) {
|
|
177
|
+
OnBehalfOfClient.prototype.executeTokenRequest = function (request, authority, userAssertionHash) {
|
|
150
178
|
return __awaiter(this, void 0, void 0, function () {
|
|
151
179
|
var requestBody, headers, thumbprint, reqTimestamp, response, responseHandler, tokenResponse;
|
|
152
180
|
return __generator(this, function (_a) {
|
|
@@ -171,7 +199,7 @@ var OnBehalfOfClient = /** @class */ (function (_super) {
|
|
|
171
199
|
response = _a.sent();
|
|
172
200
|
responseHandler = new ResponseHandler(this.config.authOptions.clientId, this.cacheManager, this.cryptoUtils, this.logger, this.config.serializableCache, this.config.persistencePlugin);
|
|
173
201
|
responseHandler.validateTokenResponse(response.body);
|
|
174
|
-
return [4 /*yield*/, responseHandler.handleServerTokenResponse(response.body, this.authority, reqTimestamp, request)];
|
|
202
|
+
return [4 /*yield*/, responseHandler.handleServerTokenResponse(response.body, this.authority, reqTimestamp, request, undefined, userAssertionHash)];
|
|
175
203
|
case 2:
|
|
176
204
|
tokenResponse = _a.sent();
|
|
177
205
|
return [2 /*return*/, tokenResponse];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OnBehalfOfClient.js","sources":["../../src/client/OnBehalfOfClient.ts"],"sourcesContent":["/*\r\n * Copyright (c) Microsoft Corporation. All rights reserved.\r\n * Licensed under the MIT License.\r\n */\r\n\r\nimport { ClientConfiguration } from \"../config/ClientConfiguration\";\r\nimport { BaseClient } from \"./BaseClient\";\r\nimport { Authority } from \"../authority/Authority\";\r\nimport { RequestParameterBuilder } from \"../request/RequestParameterBuilder\";\r\nimport { ScopeSet } from \"../request/ScopeSet\";\r\nimport { GrantType, AADServerParamKeys , CredentialType, Constants, CacheOutcome } from \"../utils/Constants\";\r\nimport { ResponseHandler } from \"../response/ResponseHandler\";\r\nimport { AuthenticationResult } from \"../response/AuthenticationResult\";\r\nimport { CommonOnBehalfOfRequest } from \"../request/CommonOnBehalfOfRequest\";\r\nimport { TimeUtils } from \"../utils/TimeUtils\";\r\nimport { CredentialFilter, CredentialCache } from \"../cache/utils/CacheTypes\";\r\nimport { AccessTokenEntity } from \"../cache/entities/AccessTokenEntity\";\r\nimport { IdTokenEntity } from \"../cache/entities/IdTokenEntity\";\r\nimport { AccountEntity } from \"../cache/entities/AccountEntity\";\r\nimport { AuthToken } from \"../account/AuthToken\";\r\nimport { ClientAuthError } from \"../error/ClientAuthError\";\r\nimport { RequestThumbprint } from \"../network/RequestThumbprint\";\r\nimport { AccountInfo } from \"../account/AccountInfo\";\r\n\r\n/**\r\n * On-Behalf-Of client\r\n */\r\nexport class OnBehalfOfClient extends BaseClient {\r\n\r\n private scopeSet: ScopeSet;\r\n\r\n constructor(configuration: ClientConfiguration) {\r\n super(configuration);\r\n }\r\n\r\n /**\r\n * Public API to acquire tokens with on behalf of flow\r\n * @param request\r\n */\r\n public async acquireToken(request: CommonOnBehalfOfRequest): Promise<AuthenticationResult | null> {\r\n this.scopeSet = new ScopeSet(request.scopes || []);\r\n\r\n if (request.skipCache) {\r\n return await this.executeTokenRequest(request, this.authority);\r\n }\r\n\r\n const cachedAuthenticationResult = await this.getCachedAuthenticationResult(request);\r\n if (cachedAuthenticationResult) {\r\n return cachedAuthenticationResult;\r\n } else {\r\n return await this.executeTokenRequest(request, this.authority);\r\n }\r\n }\r\n\r\n /**\r\n * look up cache for tokens\r\n * @param request\r\n */\r\n private async getCachedAuthenticationResult(request: CommonOnBehalfOfRequest): Promise<AuthenticationResult | null> {\r\n const cachedAccessToken = this.readAccessTokenFromCache();\r\n if (!cachedAccessToken ||\r\n TimeUtils.isTokenExpired(cachedAccessToken.expiresOn, this.config.systemOptions.tokenRenewalOffsetSeconds)) {\r\n\r\n // Update the server telemetry outcome\r\n this.serverTelemetryManager?.setCacheOutcome(!cachedAccessToken ? CacheOutcome.CACHED_ACCESS_TOKEN_EXPIRED : CacheOutcome.NO_CACHED_ACCESS_TOKEN);\r\n\r\n return null;\r\n }\r\n\r\n const cachedIdToken = this.readIdTokenFromCache(request);\r\n let idTokenObject: AuthToken | undefined;\r\n let cachedAccount: AccountEntity | null = null;\r\n if (cachedIdToken) {\r\n idTokenObject = new AuthToken(cachedIdToken.secret, this.config.cryptoInterface);\r\n const localAccountId = idTokenObject.claims.oid ? idTokenObject.claims.oid : idTokenObject.claims.sub;\r\n const accountInfo: AccountInfo = {\r\n homeAccountId: cachedIdToken.homeAccountId,\r\n environment: cachedIdToken.environment,\r\n tenantId: cachedIdToken.realm,\r\n username: Constants.EMPTY_STRING,\r\n localAccountId: localAccountId || Constants.EMPTY_STRING\r\n };\r\n\r\n cachedAccount = this.readAccountFromCache(accountInfo);\r\n }\r\n\r\n return await ResponseHandler.generateAuthenticationResult(\r\n this.cryptoUtils,\r\n this.authority,\r\n {\r\n account: cachedAccount,\r\n accessToken: cachedAccessToken,\r\n idToken: cachedIdToken,\r\n refreshToken: null,\r\n appMetadata: null\r\n },\r\n true,\r\n request,\r\n idTokenObject);\r\n }\r\n\r\n /**\r\n * read access token from cache TODO: CacheManager API should be used here\r\n * @param request\r\n */\r\n private readAccessTokenFromCache(): AccessTokenEntity | null {\r\n const accessTokenFilter: CredentialFilter = {\r\n environment: this.authority.canonicalAuthorityUrlComponents.HostNameAndPort,\r\n credentialType: CredentialType.ACCESS_TOKEN,\r\n clientId: this.config.authOptions.clientId,\r\n realm: this.authority.tenant,\r\n target: this.scopeSet.printScopesLowerCase(),\r\n };\r\n\r\n const credentialCache: CredentialCache = this.cacheManager.getCredentialsFilteredBy(accessTokenFilter);\r\n const accessTokens = Object.keys(credentialCache.accessTokens).map(key => credentialCache.accessTokens[key]);\r\n\r\n const numAccessTokens = accessTokens.length;\r\n if (numAccessTokens < 1) {\r\n return null;\r\n } else if (numAccessTokens > 1) {\r\n throw ClientAuthError.createMultipleMatchingTokensInCacheError();\r\n }\r\n return accessTokens[0] as AccessTokenEntity;\r\n }\r\n\r\n /**\r\n * read idtoken from cache TODO: CacheManager API should be used here instead\r\n * @param request\r\n */\r\n private readIdTokenFromCache(request: CommonOnBehalfOfRequest): IdTokenEntity | null {\r\n const idTokenFilter: CredentialFilter = {\r\n environment: this.authority.canonicalAuthorityUrlComponents.HostNameAndPort,\r\n credentialType: CredentialType.ID_TOKEN,\r\n clientId: this.config.authOptions.clientId,\r\n realm: this.authority.tenant,\r\n oboAssertion: request.oboAssertion\r\n };\r\n\r\n const credentialCache: CredentialCache = this.cacheManager.getCredentialsFilteredBy(idTokenFilter);\r\n const idTokens = Object.keys(credentialCache.idTokens).map(key => credentialCache.idTokens[key]);\r\n // When acquiring a token on behalf of an application, there might not be an id token in the cache\r\n if (idTokens.length < 1) {\r\n return null;\r\n }\r\n return idTokens[0] as IdTokenEntity;\r\n }\r\n\r\n /**\r\n * read account from cache, TODO: CacheManager API should be used here instead\r\n * @param account\r\n */\r\n private readAccountFromCache(account: AccountInfo): AccountEntity | null {\r\n return this.cacheManager.readAccountFromCache(account);\r\n }\r\n\r\n /**\r\n * Make a network call to the server requesting credentials\r\n * @param request\r\n * @param authority\r\n */\r\n private async executeTokenRequest(request: CommonOnBehalfOfRequest, authority: Authority)\r\n : Promise<AuthenticationResult | null> {\r\n\r\n const requestBody = this.createTokenRequestBody(request);\r\n const headers: Record<string, string> = this.createTokenRequestHeaders();\r\n const thumbprint: RequestThumbprint = {\r\n clientId: this.config.authOptions.clientId,\r\n authority: request.authority,\r\n scopes: request.scopes,\r\n claims: request.claims,\r\n authenticationScheme: request.authenticationScheme,\r\n resourceRequestMethod: request.resourceRequestMethod,\r\n resourceRequestUri: request.resourceRequestUri,\r\n shrClaims: request.shrClaims,\r\n sshKid: request.sshKid\r\n };\r\n\r\n const reqTimestamp = TimeUtils.nowSeconds();\r\n const response = await this.executePostToTokenEndpoint(authority.tokenEndpoint, requestBody, headers, thumbprint);\r\n\r\n const responseHandler = new ResponseHandler(\r\n this.config.authOptions.clientId,\r\n this.cacheManager,\r\n this.cryptoUtils,\r\n this.logger,\r\n this.config.serializableCache,\r\n this.config.persistencePlugin\r\n );\r\n\r\n responseHandler.validateTokenResponse(response.body);\r\n const tokenResponse = await responseHandler.handleServerTokenResponse(\r\n response.body,\r\n this.authority,\r\n reqTimestamp,\r\n request\r\n );\r\n\r\n return tokenResponse;\r\n }\r\n\r\n /**\r\n * generate a server request in accepable format\r\n * @param request\r\n */\r\n private createTokenRequestBody(request: CommonOnBehalfOfRequest): string {\r\n const parameterBuilder = new RequestParameterBuilder();\r\n\r\n parameterBuilder.addClientId(this.config.authOptions.clientId);\r\n\r\n parameterBuilder.addScopes(request.scopes);\r\n\r\n parameterBuilder.addGrantType(GrantType.JWT_BEARER);\r\n\r\n parameterBuilder.addClientInfo();\r\n\r\n parameterBuilder.addLibraryInfo(this.config.libraryInfo);\r\n parameterBuilder.addApplicationTelemetry(this.config.telemetry.application);\r\n parameterBuilder.addThrottling();\r\n \r\n if (this.serverTelemetryManager) {\r\n parameterBuilder.addServerTelemetry(this.serverTelemetryManager);\r\n }\r\n\r\n const correlationId = request.correlationId || this.config.cryptoInterface.createNewGuid();\r\n parameterBuilder.addCorrelationId(correlationId);\r\n\r\n parameterBuilder.addRequestTokenUse(AADServerParamKeys.ON_BEHALF_OF);\r\n\r\n parameterBuilder.addOboAssertion(request.oboAssertion);\r\n\r\n if (this.config.clientCredentials.clientSecret) {\r\n parameterBuilder.addClientSecret(this.config.clientCredentials.clientSecret);\r\n }\r\n\r\n if (this.config.clientCredentials.clientAssertion) {\r\n const clientAssertion = this.config.clientCredentials.clientAssertion;\r\n parameterBuilder.addClientAssertion(clientAssertion.assertion);\r\n parameterBuilder.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AC,iBAAiB,CAAC,YAAY,CAAC,CAAC;SAChF;QAED,IAAI,IAAI,CAAC,MAAM,CAAC,iBAAiB,CAAC,eAAe,EAAE;YAC/C,IAAM,eAAe,GAAG,IAAI,CAAC,MAAM,CAAC,iBAAiB,CAAC,eAAe,CAAC;YACtE,gBAAgB,CAAC,kBAAkB,CAAC,eAAe,CAAC,SAAS,CAAC,CAAC;YAC/D,gBAAgB,CAAC,sBAAsB,CAAC,eAAe,CAAC,aAAa,CAAC,CAAC;SAC1E;QAED,OAAO,gBAAgB,CAAC,iBAAiB,EAAE,CAAC;KAC/C;IACL,uBAAC;AAAD,CAxNA,CAAsC,UAAU;;;;"}
|
|
1
|
+
{"version":3,"file":"OnBehalfOfClient.js","sources":["../../src/client/OnBehalfOfClient.ts"],"sourcesContent":["/*\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ClientConfiguration } from \"../config/ClientConfiguration\";\nimport { BaseClient } from \"./BaseClient\";\nimport { Authority } from \"../authority/Authority\";\nimport { RequestParameterBuilder } from \"../request/RequestParameterBuilder\";\nimport { ScopeSet } from \"../request/ScopeSet\";\nimport { GrantType, AADServerParamKeys , CredentialType, Constants, CacheOutcome, AuthenticationScheme } from \"../utils/Constants\";\nimport { ResponseHandler } from \"../response/ResponseHandler\";\nimport { AuthenticationResult } from \"../response/AuthenticationResult\";\nimport { CommonOnBehalfOfRequest } from \"../request/CommonOnBehalfOfRequest\";\nimport { TimeUtils } from \"../utils/TimeUtils\";\nimport { CredentialFilter, CredentialCache } from \"../cache/utils/CacheTypes\";\nimport { AccessTokenEntity } from \"../cache/entities/AccessTokenEntity\";\nimport { IdTokenEntity } from \"../cache/entities/IdTokenEntity\";\nimport { AccountEntity } from \"../cache/entities/AccountEntity\";\nimport { AuthToken } from \"../account/AuthToken\";\nimport { ClientAuthError } from \"../error/ClientAuthError\";\nimport { RequestThumbprint } from \"../network/RequestThumbprint\";\nimport { AccountInfo } from \"../account/AccountInfo\";\n\n/**\n * On-Behalf-Of client\n */\nexport class OnBehalfOfClient extends BaseClient {\n\n private scopeSet: ScopeSet;\n private userAssertionHash: string;\n\n constructor(configuration: ClientConfiguration) {\n super(configuration);\n }\n\n /**\n * Public API to acquire tokens with on behalf of flow\n * @param request\n */\n public async acquireToken(request: CommonOnBehalfOfRequest): Promise<AuthenticationResult | null> {\n this.scopeSet = new ScopeSet(request.scopes || []);\n\n // generate the user_assertion_hash for OBOAssertion\n this.userAssertionHash = await this.cryptoUtils.hashString(request.oboAssertion);\n\n if (request.skipCache) {\n return await this.executeTokenRequest(request, this.authority, this.userAssertionHash);\n }\n\n try {\n return await this.getCachedAuthenticationResult(request);\n } catch (e) {\n // Any failure falls back to interactive request, once we implement distributed cache, we plan to handle `createRefreshRequiredError` to refresh using the RT\n return await this.executeTokenRequest(request, this.authority, this.userAssertionHash);\n }\n }\n\n /**\n * look up cache for tokens\n * Find idtoken in the cache\n * Find accessToken based on user assertion and account info in the cache\n * Please note we are not yet supported OBO tokens refreshed with long lived RT. User will have to send a new assertion if the current access token expires\n * This is to prevent security issues when the assertion changes over time, however, longlived RT helps retaining the session\n * @param request\n */\n private async getCachedAuthenticationResult(request: CommonOnBehalfOfRequest): Promise<AuthenticationResult | null> {\n\n // look in the cache for the access_token which matches the incoming_assertion\n const cachedAccessToken = this.readAccessTokenFromCacheForOBO(this.config.authOptions.clientId, request);\n if (!cachedAccessToken) {\n // Must refresh due to non-existent access_token.\n this.serverTelemetryManager?.setCacheOutcome(CacheOutcome.NO_CACHED_ACCESS_TOKEN);\n this.logger.info(\"SilentFlowClient:acquireCachedToken - No access token found in cache for the given properties.\");\n throw ClientAuthError.createRefreshRequiredError();\n } else if (TimeUtils.isTokenExpired(cachedAccessToken.expiresOn, this.config.systemOptions.tokenRenewalOffsetSeconds)) {\n // Access token expired, will need to renewed\n this.serverTelemetryManager?.setCacheOutcome(CacheOutcome.CACHED_ACCESS_TOKEN_EXPIRED);\n this.logger.info(`OnbehalfofFlow:getCachedAuthenticationResult - Cached access token is expired or will expire within ${this.config.systemOptions.tokenRenewalOffsetSeconds} seconds.`);\n throw ClientAuthError.createRefreshRequiredError();\n }\n\n // fetch the idToken from cache\n const cachedIdToken = this.readIdTokenFromCacheForOBO(request, cachedAccessToken.homeAccountId);\n let idTokenObject: AuthToken | undefined;\n let cachedAccount: AccountEntity | null = null;\n if (cachedIdToken) {\n idTokenObject = new AuthToken(cachedIdToken.secret, this.config.cryptoInterface);\n const localAccountId = idTokenObject.claims.oid ? idTokenObject.claims.oid : idTokenObject.claims.sub;\n const accountInfo: AccountInfo = {\n homeAccountId: cachedIdToken.homeAccountId,\n environment: cachedIdToken.environment,\n tenantId: cachedIdToken.realm,\n username: Constants.EMPTY_STRING,\n localAccountId: localAccountId || Constants.EMPTY_STRING\n };\n\n cachedAccount = this.cacheManager.readAccountFromCache(accountInfo);\n }\n\n // increment telemetry cache hit counter\n if (this.config.serverTelemetryManager) {\n this.config.serverTelemetryManager.incrementCacheHits();\n }\n\n return await ResponseHandler.generateAuthenticationResult(\n this.cryptoUtils,\n this.authority,\n {\n account: cachedAccount,\n accessToken: cachedAccessToken,\n idToken: cachedIdToken,\n refreshToken: null,\n appMetadata: null\n },\n true,\n request,\n idTokenObject);\n }\n\n /**\n * read idtoken from cache, this is a specific implementation for OBO as the requirements differ from a generic lookup in the cacheManager\n * Certain use cases of OBO flow do not expect an idToken in the cache/or from the service\n * @param request\n */\n private readIdTokenFromCacheForOBO(request: CommonOnBehalfOfRequest, atHomeAccountId: string): IdTokenEntity | null {\n\n const idTokenFilter: CredentialFilter = {\n homeAccountId: atHomeAccountId,\n environment: this.authority.canonicalAuthorityUrlComponents.HostNameAndPort,\n credentialType: CredentialType.ID_TOKEN,\n clientId: this.config.authOptions.clientId,\n realm: this.authority.tenant\n };\n\n const credentialCache: CredentialCache = this.cacheManager.getCredentialsFilteredBy(idTokenFilter);\n const idTokens = Object.keys(credentialCache.idTokens).map(key => credentialCache.idTokens[key]);\n // When acquiring a token on behalf of an application, there might not be an id token in the cache\n if (idTokens.length < 1) {\n return null;\n }\n return idTokens[0] as IdTokenEntity;\n }\n\n /**\n * Fetches the cached access token based on incoming assertion\n * @param clientId\n * @param request\n * @param userAssertionHash\n */\n private readAccessTokenFromCacheForOBO(clientId: string, request: CommonOnBehalfOfRequest) {\n const authScheme = request.authenticationScheme || AuthenticationScheme.BEARER;\n /*\n * Distinguish between Bearer and PoP/SSH token cache types\n * Cast to lowercase to handle \"bearer\" from ADFS\n */\n const credentialType = (authScheme && authScheme.toLowerCase() !== AuthenticationScheme.BEARER.toLowerCase()) ? CredentialType.ACCESS_TOKEN_WITH_AUTH_SCHEME : CredentialType.ACCESS_TOKEN;\n\n const accessTokenFilter: CredentialFilter = {\n credentialType: credentialType,\n clientId,\n target: this.scopeSet.printScopesLowerCase(),\n tokenType: authScheme,\n keyId: request.sshKid,\n requestedClaimsHash: request.requestedClaimsHash,\n userAssertionHash: this.userAssertionHash\n };\n\n const credentialCache: CredentialCache = this.cacheManager.getCredentialsFilteredBy(accessTokenFilter);\n\n const accessTokens = Object.keys(credentialCache.accessTokens).map((key) => credentialCache.accessTokens[key]);\n\n const numAccessTokens = accessTokens.length;\n if (numAccessTokens < 1) {\n return null;\n } else if (numAccessTokens > 1) {\n throw ClientAuthError.createMultipleMatchingTokensInCacheError();\n }\n\n return accessTokens[0] as AccessTokenEntity;\n }\n\n /**\n * Make a network call to the server requesting credentials\n * @param request\n * @param authority\n */\n private async executeTokenRequest(request: CommonOnBehalfOfRequest, authority: Authority, userAssertionHash: string)\n : Promise<AuthenticationResult | null> {\n\n const requestBody = this.createTokenRequestBody(request);\n const headers: Record<string, string> = this.createTokenRequestHeaders();\n const thumbprint: RequestThumbprint = {\n clientId: this.config.authOptions.clientId,\n authority: request.authority,\n scopes: request.scopes,\n claims: request.claims,\n authenticationScheme: request.authenticationScheme,\n resourceRequestMethod: request.resourceRequestMethod,\n resourceRequestUri: request.resourceRequestUri,\n shrClaims: request.shrClaims,\n sshKid: request.sshKid\n };\n\n const reqTimestamp = TimeUtils.nowSeconds();\n const response = await this.executePostToTokenEndpoint(authority.tokenEndpoint, requestBody, headers, thumbprint);\n\n const responseHandler = new ResponseHandler(\n this.config.authOptions.clientId,\n this.cacheManager,\n this.cryptoUtils,\n this.logger,\n this.config.serializableCache,\n this.config.persistencePlugin\n );\n\n responseHandler.validateTokenResponse(response.body);\n const tokenResponse = await responseHandler.handleServerTokenResponse(\n response.body,\n this.authority,\n reqTimestamp,\n request,\n undefined,\n userAssertionHash\n );\n\n return tokenResponse;\n }\n\n /**\n * generate a server request in accepable format\n * @param request\n */\n private createTokenRequestBody(request: CommonOnBehalfOfRequest): string {\n const parameterBuilder = new RequestParameterBuilder();\n\n parameterBuilder.addClientId(this.config.authOptions.clientId);\n\n parameterBuilder.addScopes(request.scopes);\n\n parameterBuilder.addGrantType(GrantType.JWT_BEARER);\n\n parameterBuilder.addClientInfo();\n\n parameterBuilder.addLibraryInfo(this.config.libraryInfo);\n parameterBuilder.addApplicationTelemetry(this.config.telemetry.application);\n parameterBuilder.addThrottling();\n\n if (this.serverTelemetryManager) {\n parameterBuilder.addServerTelemetry(this.serverTelemetryManager);\n }\n\n const correlationId = request.correlationId || this.config.cryptoInterface.createNewGuid();\n parameterBuilder.addCorrelationId(correlationId);\n\n parameterBuilder.addRequestTokenUse(AADServerParamKeys.ON_BEHALF_OF);\n\n parameterBuilder.addOboAssertion(request.oboAssertion);\n\n if (this.config.clientCredentials.clientSecret) {\n parameterBuilder.addClientSecret(this.config.clientCredentials.clientSecret);\n }\n\n if (this.config.clientCredentials.clientAssertion) {\n const clientAssertion = this.config.clientCredentials.clientAssertion;\n parameterBuilder.addClientAssertion(clientAssertion.assertion);\n parameterBuilder.addClientAssertionType(clientAssertion.assertionType);\n }\n\n return parameterBuilder.createQueryString();\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;;AAAA;;;;AAwBA;;;;IAGsC,oCAAU;IAK5C,0BAAY,aAAkC;eAC1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xG;;;OAGG;YACW,kCAAkC;IAsBhD;;;;OAIG;YACW,mBAAmB;IAsBjC;;;OAGG;IACH,OAAO,CAAC,0BAA0B;IAUlC;;;OAGG;YACW,sBAAsB;CAqEvC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @azure/msal-common
|
|
1
|
+
/*! @azure/msal-common v7.0.0 2022-06-13 */
|
|
2
2
|
'use strict';
|
|
3
3
|
import { __extends, __awaiter, __generator, __assign } from '../_virtual/_tslib.js';
|
|
4
4
|
import { BaseClient } from './BaseClient.js';
|
|
@@ -155,7 +155,7 @@ var RefreshTokenClient = /** @class */ (function (_super) {
|
|
|
155
155
|
*/
|
|
156
156
|
RefreshTokenClient.prototype.createTokenRequestBody = function (request) {
|
|
157
157
|
return __awaiter(this, void 0, void 0, function () {
|
|
158
|
-
var parameterBuilder, correlationId, clientAssertion, popTokenGenerator,
|
|
158
|
+
var parameterBuilder, correlationId, clientAssertion, popTokenGenerator, reqCnfData, clientInfo;
|
|
159
159
|
return __generator(this, function (_a) {
|
|
160
160
|
switch (_a.label) {
|
|
161
161
|
case 0:
|
|
@@ -185,8 +185,9 @@ var RefreshTokenClient = /** @class */ (function (_super) {
|
|
|
185
185
|
popTokenGenerator = new PopTokenGenerator(this.cryptoUtils);
|
|
186
186
|
return [4 /*yield*/, popTokenGenerator.generateCnf(request)];
|
|
187
187
|
case 1:
|
|
188
|
-
|
|
189
|
-
|
|
188
|
+
reqCnfData = _a.sent();
|
|
189
|
+
// SPA PoP requires full Base64Url encoded req_cnf string (unhashed)
|
|
190
|
+
parameterBuilder.addPopToken(reqCnfData.reqCnfString);
|
|
190
191
|
return [3 /*break*/, 3];
|
|
191
192
|
case 2:
|
|
192
193
|
if (request.authenticationScheme === AuthenticationScheme.SSH) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RefreshTokenClient.js","sources":["../../src/client/RefreshTokenClient.ts"],"sourcesContent":["/*\r\n * Copyright (c) Microsoft Corporation. All rights reserved.\r\n * Licensed under the MIT License.\r\n */\r\n\r\nimport { ClientConfiguration } from \"../config/ClientConfiguration\";\r\nimport { BaseClient } from \"./BaseClient\";\r\nimport { CommonRefreshTokenRequest } from \"../request/CommonRefreshTokenRequest\";\r\nimport { Authority } from \"../authority/Authority\";\r\nimport { ServerAuthorizationTokenResponse } from \"../response/ServerAuthorizationTokenResponse\";\r\nimport { RequestParameterBuilder } from \"../request/RequestParameterBuilder\";\r\nimport { GrantType, AuthenticationScheme, Errors } from \"../utils/Constants\";\r\nimport { ResponseHandler } from \"../response/ResponseHandler\";\r\nimport { AuthenticationResult } from \"../response/AuthenticationResult\";\r\nimport { PopTokenGenerator } from \"../crypto/PopTokenGenerator\";\r\nimport { StringUtils } from \"../utils/StringUtils\";\r\nimport { RequestThumbprint } from \"../network/RequestThumbprint\";\r\nimport { NetworkResponse } from \"../network/NetworkManager\";\r\nimport { CommonSilentFlowRequest } from \"../request/CommonSilentFlowRequest\";\r\nimport { ClientConfigurationError } from \"../error/ClientConfigurationError\";\r\nimport { ClientAuthError } from \"../error/ClientAuthError\";\r\nimport { ServerError } from \"../error/ServerError\";\r\nimport { TimeUtils } from \"../utils/TimeUtils\";\r\nimport { UrlString } from \"../url/UrlString\";\r\nimport { CcsCredentialType } from \"../account/CcsCredential\";\r\nimport { buildClientInfoFromHomeAccountId } from \"../account/ClientInfo\";\r\nimport { InteractionRequiredAuthError, InteractionRequiredAuthErrorMessage } from \"../error/InteractionRequiredAuthError\";\r\n\r\n/**\r\n * OAuth2.0 refresh token client\r\n */\r\nexport class RefreshTokenClient extends BaseClient {\r\n\r\n constructor(configuration: ClientConfiguration) {\r\n super(configuration);\r\n }\r\n\r\n public async acquireToken(request: CommonRefreshTokenRequest): Promise<AuthenticationResult>{\r\n const reqTimestamp = TimeUtils.nowSeconds();\r\n const response = await this.executeTokenRequest(request, this.authority);\r\n\r\n const responseHandler = new ResponseHandler(\r\n this.config.authOptions.clientId,\r\n this.cacheManager,\r\n this.cryptoUtils,\r\n this.logger,\r\n this.config.serializableCache,\r\n this.config.persistencePlugin\r\n );\r\n\r\n responseHandler.validateTokenResponse(response.body);\r\n return responseHandler.handleServerTokenResponse(\r\n response.body,\r\n this.authority,\r\n reqTimestamp,\r\n request,\r\n undefined,\r\n undefined,\r\n true\r\n );\r\n }\r\n\r\n /**\r\n * Gets cached refresh token and attaches to request, then calls acquireToken API\r\n * @param request\r\n */\r\n public async acquireTokenByRefreshToken(request: CommonSilentFlowRequest): Promise<AuthenticationResult> {\r\n // Cannot renew token if no request object is given.\r\n if (!request) {\r\n throw ClientConfigurationError.createEmptyTokenRequestError();\r\n }\r\n\r\n // We currently do not support silent flow for account === null use cases; This will be revisited for confidential flow usecases\r\n if (!request.account) {\r\n throw ClientAuthError.createNoAccountInSilentRequestError();\r\n }\r\n\r\n // try checking if FOCI is enabled for the given application\r\n const isFOCI = this.cacheManager.isAppMetadataFOCI(request.account.environment, this.config.authOptions.clientId);\r\n\r\n // if the app is part of the family, retrive a Family refresh token if present and make a refreshTokenRequest\r\n if (isFOCI) {\r\n try {\r\n return this.acquireTokenWithCachedRefreshToken(request, true);\r\n } catch (e) {\r\n const noFamilyRTInCache = e instanceof InteractionRequiredAuthError && e.errorCode === InteractionRequiredAuthErrorMessage.noTokensFoundError.code;\r\n const clientMismatchErrorWithFamilyRT = e instanceof ServerError && e.errorCode === Errors.INVALID_GRANT_ERROR && e.subError === Errors.CLIENT_MISMATCH_ERROR;\r\n\r\n // if family Refresh Token (FRT) cache acquisition fails or if client_mismatch error is seen with FRT, reattempt with application Refresh Token (ART)\r\n if (noFamilyRTInCache || clientMismatchErrorWithFamilyRT) {\r\n return this.acquireTokenWithCachedRefreshToken(request, false);\r\n // throw in all other cases\r\n } else {\r\n throw e;\r\n }\r\n }\r\n }\r\n\r\n // fall back to application refresh token acquisition\r\n return this.acquireTokenWithCachedRefreshToken(request, false);\r\n }\r\n\r\n /**\r\n * makes a network call to acquire tokens by exchanging RefreshToken available in userCache; throws if refresh token is not cached\r\n * @param request\r\n */\r\n private async acquireTokenWithCachedRefreshToken(request: CommonSilentFlowRequest, foci: boolean) {\r\n // fetches family RT or application RT based on FOCI value\r\n const refreshToken = this.cacheManager.readRefreshTokenFromCache(this.config.authOptions.clientId, request.account, foci);\r\n\r\n // no refresh Token\r\n if (!refreshToken) {\r\n throw InteractionRequiredAuthError.createNoTokensFoundError();\r\n }\r\n\r\n const refreshTokenRequest: CommonRefreshTokenRequest = {\r\n ...request,\r\n refreshToken: refreshToken.secret,\r\n authenticationScheme: request.authenticationScheme || AuthenticationScheme.BEARER,\r\n ccsCredential: {\r\n credential: request.account.homeAccountId,\r\n type: CcsCredentialType.HOME_ACCOUNT_ID\r\n }\r\n };\r\n\r\n return this.acquireToken(refreshTokenRequest);\r\n }\r\n\r\n /**\r\n * Constructs the network message and makes a NW call to the underlying secure token service\r\n * @param request\r\n * @param authority\r\n */\r\n private async executeTokenRequest(request: CommonRefreshTokenRequest, authority: Authority)\r\n : Promise<NetworkResponse<ServerAuthorizationTokenResponse>> {\r\n\r\n const requestBody = await this.createTokenRequestBody(request);\r\n const queryParameters = this.createTokenQueryParameters(request);\r\n const headers: Record<string, string> = this.createTokenRequestHeaders(request.ccsCredential);\r\n const thumbprint: RequestThumbprint = {\r\n clientId: this.config.authOptions.clientId,\r\n authority: authority.canonicalAuthority,\r\n scopes: request.scopes,\r\n claims: request.claims,\r\n authenticationScheme: request.authenticationScheme,\r\n resourceRequestMethod: request.resourceRequestMethod,\r\n resourceRequestUri: request.resourceRequestUri,\r\n shrClaims: request.shrClaims,\r\n sshKid: request.sshKid\r\n };\r\n\r\n const endpoint = UrlString.appendQueryString(authority.tokenEndpoint, queryParameters);\r\n return this.executePostToTokenEndpoint(endpoint, requestBody, headers, thumbprint);\r\n }\r\n\r\n /**\r\n * Creates query string for the /token request\r\n * @param request \r\n */\r\n private createTokenQueryParameters(request: CommonRefreshTokenRequest): string {\r\n const parameterBuilder = new RequestParameterBuilder();\r\n\r\n if (request.tokenQueryParameters) {\r\n parameterBuilder.addExtraQueryParameters(request.tokenQueryParameters);\r\n }\r\n\r\n return parameterBuilder.createQueryString();\r\n }\r\n\r\n /**\r\n * Helper function to create the token request body\r\n * @param request\r\n */\r\n private async createTokenRequestBody(request: CommonRefreshTokenRequest): Promise<string> {\r\n const parameterBuilder = new RequestParameterBuilder();\r\n\r\n parameterBuilder.addClientId(this.config.authOptions.clientId);\r\n\r\n parameterBuilder.addScopes(request.scopes);\r\n\r\n parameterBuilder.addGrantType(GrantType.REFRESH_TOKEN_GRANT);\r\n\r\n parameterBuilder.addClientInfo();\r\n\r\n parameterBuilder.addLibraryInfo(this.config.libraryInfo);\r\n parameterBuilder.addApplicationTelemetry(this.config.telemetry.application);\r\n parameterBuilder.addThrottling();\r\n \r\n if (this.serverTelemetryManager) {\r\n parameterBuilder.addServerTelemetry(this.serverTelemetryManager);\r\n }\r\n\r\n const correlationId = request.correlationId || this.config.cryptoInterface.createNewGuid();\r\n parameterBuilder.addCorrelationId(correlationId);\r\n\r\n parameterBuilder.addRefreshToken(request.refreshToken);\r\n\r\n if (this.config.clientCredentials.clientSecret) {\r\n parameterBuilder.addClientSecret(this.config.clientCredentials.clientSecret);\r\n }\r\n\r\n if (this.config.clientCredentials.clientAssertion) {\r\n const clientAssertion = this.config.clientCredentials.clientAssertion;\r\n parameterBuilder.addClientAssertion(clientAssertion.assertion);\r\n parameterBuilder.addClientAssertionType(clientAssertion.assertionType);\r\n }\r\n\r\n if (request.authenticationScheme === AuthenticationScheme.POP) {\r\n const popTokenGenerator = new PopTokenGenerator(this.cryptoUtils);\r\n const cnfString = await popTokenGenerator.generateCnf(request);\r\n parameterBuilder.addPopToken(cnfString);\r\n } else if (request.authenticationScheme === AuthenticationScheme.SSH) {\r\n if(request.sshJwk) {\r\n parameterBuilder.addSshJwk(request.sshJwk);\r\n } else {\r\n throw ClientConfigurationError.createMissingSshJwkError();\r\n }\r\n }\r\n\r\n if (!StringUtils.isEmptyObj(request.claims) || this.config.authOptions.clientCapabilities && this.config.authOptions.clientCapabilities.length > 0) {\r\n parameterBuilder.addClaims(request.claims, this.config.authOptions.clientCapabilities);\r\n }\r\n\r\n if (this.config.systemOptions.preventCorsPreflight && request.ccsCredential) {\r\n switch (request.ccsCredential.type) {\r\n case CcsCredentialType.HOME_ACCOUNT_ID:\r\n try {\r\n const clientInfo = buildClientInfoFromHomeAccountId(request.ccsCredential.credential);\r\n parameterBuilder.addCcsOid(clientInfo);\r\n } catch (e) {\r\n this.logger.verbose(\"Could not parse home account ID for CCS Header: \" + e);\r\n }\r\n break;\r\n case CcsCredentialType.UPN:\r\n parameterBuilder.addCcsUpn(request.ccsCredential.credential);\r\n break;\r\n }\r\n }\r\n\r\n return parameterBuilder.createQueryString();\r\n }\r\n}\r\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA;;;;AA4BA;;;;IAGwC,sCAAU;IAE9C,4BAAY,aAAkC;eAC1C,kBAAM,aAAa,CAAC;KACvB;IAEY,yCAAY,GAAzB,UAA0B,OAAkC;;;;;;wBAClD,YAAY,GAAG,SAAS,CAAC,UAAU,EAAE,CAAC;wBAC3B,qBAAM,IAAI,CAAC,mBAAmB,CAAC,OAAO,EAAE,IAAI,CAAC,SAAS,CAAC,EAAA;;wBAAlE,QAAQ,GAAG,SAAuD;wBAElE,eAAe,GAAG,IAAI,eAAe,CACvC,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,QAAQ,EAChC,IAAI,CAAC,YAAY,EACjB,IAAI,CAAC,WAAW,EAChB,IAAI,CAAC,MAAM,EACX,IAAI,CAAC,MAAM,CAAC,iBAAiB,EAC7B,IAAI,CAAC,MAAM,CAAC,iBAAiB,CAChC,CAAC;wBAEF,eAAe,CAAC,qBAAqB,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;wBACrD,sBAAO,eAAe,CAAC,yBAAyB,CAC5C,QAAQ,CAAC,IAAI,EACb,IAAI,CAAC,SAAS,EACd,YAAY,EACZ,OAAO,EACP,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GAAG,CAAC,EAAE;4BAChJ,gBAAgB,CAAC,SAAS,CAAC,OAAO,CAAC,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,kBAAkB,CAAC,CAAC;yBAC1F;wBAED,IAAI,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,oBAAoB,IAAI,OAAO,CAAC,aAAa,EAAE;4BACzE,QAAQ,OAAO,CAAC,aAAa,CAAC,IAAI;gCAC9B,KAAK,iBAAiB,CAAC,eAAe;oCAClC,IAAI;wCACM,UAAU,GAAG,gCAAgC,CAAC,OAAO,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC;wCACtF,gBAAgB,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC;qCAC1C;oCAAC,OAAO,CAAC,EAAE;wCACR,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,kDAAkD,GAAG,CAAC,CAAC,CAAC;qCAC/E;oCACD,MAAM;gCACV,KAAK,iBAAiB,CAAC,GAAG;oCACtB,gBAAgB,CAAC,SAAS,CAAC,OAAO,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC;oCAC7D,MAAM;6BACb;yBACJ;wBAED,sBAAO,gBAAgB,CAAC,iBAAiB,EAAE,EAAC;;;;KAC/C;IACL,yBAAC;AAAD,CAlNA,CAAwC,UAAU;;;;"}
|
|
1
|
+
{"version":3,"file":"RefreshTokenClient.js","sources":["../../src/client/RefreshTokenClient.ts"],"sourcesContent":["/*\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ClientConfiguration } from \"../config/ClientConfiguration\";\nimport { BaseClient } from \"./BaseClient\";\nimport { CommonRefreshTokenRequest } from \"../request/CommonRefreshTokenRequest\";\nimport { Authority } from \"../authority/Authority\";\nimport { ServerAuthorizationTokenResponse } from \"../response/ServerAuthorizationTokenResponse\";\nimport { RequestParameterBuilder } from \"../request/RequestParameterBuilder\";\nimport { GrantType, AuthenticationScheme, Errors } from \"../utils/Constants\";\nimport { ResponseHandler } from \"../response/ResponseHandler\";\nimport { AuthenticationResult } from \"../response/AuthenticationResult\";\nimport { PopTokenGenerator } from \"../crypto/PopTokenGenerator\";\nimport { StringUtils } from \"../utils/StringUtils\";\nimport { RequestThumbprint } from \"../network/RequestThumbprint\";\nimport { NetworkResponse } from \"../network/NetworkManager\";\nimport { CommonSilentFlowRequest } from \"../request/CommonSilentFlowRequest\";\nimport { ClientConfigurationError } from \"../error/ClientConfigurationError\";\nimport { ClientAuthError } from \"../error/ClientAuthError\";\nimport { ServerError } from \"../error/ServerError\";\nimport { TimeUtils } from \"../utils/TimeUtils\";\nimport { UrlString } from \"../url/UrlString\";\nimport { CcsCredentialType } from \"../account/CcsCredential\";\nimport { buildClientInfoFromHomeAccountId } from \"../account/ClientInfo\";\nimport { InteractionRequiredAuthError, InteractionRequiredAuthErrorMessage } from \"../error/InteractionRequiredAuthError\";\n\n/**\n * OAuth2.0 refresh token client\n */\nexport class RefreshTokenClient extends BaseClient {\n\n constructor(configuration: ClientConfiguration) {\n super(configuration);\n }\n\n public async acquireToken(request: CommonRefreshTokenRequest): Promise<AuthenticationResult>{\n const reqTimestamp = TimeUtils.nowSeconds();\n const response = await this.executeTokenRequest(request, this.authority);\n\n const responseHandler = new ResponseHandler(\n this.config.authOptions.clientId,\n this.cacheManager,\n this.cryptoUtils,\n this.logger,\n this.config.serializableCache,\n this.config.persistencePlugin\n );\n\n responseHandler.validateTokenResponse(response.body);\n return responseHandler.handleServerTokenResponse(\n response.body,\n this.authority,\n reqTimestamp,\n request,\n undefined,\n undefined,\n true\n );\n }\n\n /**\n * Gets cached refresh token and attaches to request, then calls acquireToken API\n * @param request\n */\n public async acquireTokenByRefreshToken(request: CommonSilentFlowRequest): Promise<AuthenticationResult> {\n // Cannot renew token if no request object is given.\n if (!request) {\n throw ClientConfigurationError.createEmptyTokenRequestError();\n }\n\n // We currently do not support silent flow for account === null use cases; This will be revisited for confidential flow usecases\n if (!request.account) {\n throw ClientAuthError.createNoAccountInSilentRequestError();\n }\n\n // try checking if FOCI is enabled for the given application\n const isFOCI = this.cacheManager.isAppMetadataFOCI(request.account.environment, this.config.authOptions.clientId);\n\n // if the app is part of the family, retrive a Family refresh token if present and make a refreshTokenRequest\n if (isFOCI) {\n try {\n return this.acquireTokenWithCachedRefreshToken(request, true);\n } catch (e) {\n const noFamilyRTInCache = e instanceof InteractionRequiredAuthError && e.errorCode === InteractionRequiredAuthErrorMessage.noTokensFoundError.code;\n const clientMismatchErrorWithFamilyRT = e instanceof ServerError && e.errorCode === Errors.INVALID_GRANT_ERROR && e.subError === Errors.CLIENT_MISMATCH_ERROR;\n\n // if family Refresh Token (FRT) cache acquisition fails or if client_mismatch error is seen with FRT, reattempt with application Refresh Token (ART)\n if (noFamilyRTInCache || clientMismatchErrorWithFamilyRT) {\n return this.acquireTokenWithCachedRefreshToken(request, false);\n // throw in all other cases\n } else {\n throw e;\n }\n }\n }\n\n // fall back to application refresh token acquisition\n return this.acquireTokenWithCachedRefreshToken(request, false);\n }\n\n /**\n * makes a network call to acquire tokens by exchanging RefreshToken available in userCache; throws if refresh token is not cached\n * @param request\n */\n private async acquireTokenWithCachedRefreshToken(request: CommonSilentFlowRequest, foci: boolean) {\n // fetches family RT or application RT based on FOCI value\n const refreshToken = this.cacheManager.readRefreshTokenFromCache(this.config.authOptions.clientId, request.account, foci);\n\n // no refresh Token\n if (!refreshToken) {\n throw InteractionRequiredAuthError.createNoTokensFoundError();\n }\n\n const refreshTokenRequest: CommonRefreshTokenRequest = {\n ...request,\n refreshToken: refreshToken.secret,\n authenticationScheme: request.authenticationScheme || AuthenticationScheme.BEARER,\n ccsCredential: {\n credential: request.account.homeAccountId,\n type: CcsCredentialType.HOME_ACCOUNT_ID\n }\n };\n\n return this.acquireToken(refreshTokenRequest);\n }\n\n /**\n * Constructs the network message and makes a NW call to the underlying secure token service\n * @param request\n * @param authority\n */\n private async executeTokenRequest(request: CommonRefreshTokenRequest, authority: Authority)\n : Promise<NetworkResponse<ServerAuthorizationTokenResponse>> {\n\n const requestBody = await this.createTokenRequestBody(request);\n const queryParameters = this.createTokenQueryParameters(request);\n const headers: Record<string, string> = this.createTokenRequestHeaders(request.ccsCredential);\n const thumbprint: RequestThumbprint = {\n clientId: this.config.authOptions.clientId,\n authority: authority.canonicalAuthority,\n scopes: request.scopes,\n claims: request.claims,\n authenticationScheme: request.authenticationScheme,\n resourceRequestMethod: request.resourceRequestMethod,\n resourceRequestUri: request.resourceRequestUri,\n shrClaims: request.shrClaims,\n sshKid: request.sshKid\n };\n\n const endpoint = UrlString.appendQueryString(authority.tokenEndpoint, queryParameters);\n return this.executePostToTokenEndpoint(endpoint, requestBody, headers, thumbprint);\n }\n\n /**\n * Creates query string for the /token request\n * @param request\n */\n private createTokenQueryParameters(request: CommonRefreshTokenRequest): string {\n const parameterBuilder = new RequestParameterBuilder();\n\n if (request.tokenQueryParameters) {\n parameterBuilder.addExtraQueryParameters(request.tokenQueryParameters);\n }\n\n return parameterBuilder.createQueryString();\n }\n\n /**\n * Helper function to create the token request body\n * @param request\n */\n private async createTokenRequestBody(request: CommonRefreshTokenRequest): Promise<string> {\n const parameterBuilder = new RequestParameterBuilder();\n\n parameterBuilder.addClientId(this.config.authOptions.clientId);\n\n parameterBuilder.addScopes(request.scopes);\n\n parameterBuilder.addGrantType(GrantType.REFRESH_TOKEN_GRANT);\n\n parameterBuilder.addClientInfo();\n\n parameterBuilder.addLibraryInfo(this.config.libraryInfo);\n parameterBuilder.addApplicationTelemetry(this.config.telemetry.application);\n parameterBuilder.addThrottling();\n\n if (this.serverTelemetryManager) {\n parameterBuilder.addServerTelemetry(this.serverTelemetryManager);\n }\n\n const correlationId = request.correlationId || this.config.cryptoInterface.createNewGuid();\n parameterBuilder.addCorrelationId(correlationId);\n\n parameterBuilder.addRefreshToken(request.refreshToken);\n\n if (this.config.clientCredentials.clientSecret) {\n parameterBuilder.addClientSecret(this.config.clientCredentials.clientSecret);\n }\n\n if (this.config.clientCredentials.clientAssertion) {\n const clientAssertion = this.config.clientCredentials.clientAssertion;\n parameterBuilder.addClientAssertion(clientAssertion.assertion);\n parameterBuilder.addClientAssertionType(clientAssertion.assertionType);\n }\n\n if (request.authenticationScheme === AuthenticationScheme.POP) {\n const popTokenGenerator = new PopTokenGenerator(this.cryptoUtils);\n const reqCnfData = await popTokenGenerator.generateCnf(request);\n // SPA PoP requires full Base64Url encoded req_cnf string (unhashed)\n parameterBuilder.addPopToken(reqCnfData.reqCnfString);\n } else if (request.authenticationScheme === AuthenticationScheme.SSH) {\n if(request.sshJwk) {\n parameterBuilder.addSshJwk(request.sshJwk);\n } else {\n throw ClientConfigurationError.createMissingSshJwkError();\n }\n }\n\n if (!StringUtils.isEmptyObj(request.claims) || this.config.authOptions.clientCapabilities && this.config.authOptions.clientCapabilities.length > 0) {\n parameterBuilder.addClaims(request.claims, this.config.authOptions.clientCapabilities);\n }\n\n if (this.config.systemOptions.preventCorsPreflight && request.ccsCredential) {\n switch (request.ccsCredential.type) {\n case CcsCredentialType.HOME_ACCOUNT_ID:\n try {\n const clientInfo = buildClientInfoFromHomeAccountId(request.ccsCredential.credential);\n parameterBuilder.addCcsOid(clientInfo);\n } catch (e) {\n this.logger.verbose(\"Could not parse home account ID for CCS Header: \" + e);\n }\n break;\n case CcsCredentialType.UPN:\n parameterBuilder.addCcsUpn(request.ccsCredential.credential);\n break;\n }\n }\n\n return parameterBuilder.createQueryString();\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA;;;;AA4BA;;;;IAGwC,sCAAU;IAE9C,4BAAY,aAAkC;eAC1C,kBAAM,aAAa,CAAC;KACvB;IAEY,yCAAY,GAAzB,UAA0B,OAAkC;;;;;;wBAClD,YAAY,GAAG,SAAS,CAAC,UAAU,EAAE,CAAC;wBAC3B,qBAAM,IAAI,CAAC,mBAAmB,CAAC,OAAO,EAAE,IAAI,CAAC,SAAS,CAAC,EAAA;;wBAAlE,QAAQ,GAAG,SAAuD;wBAElE,eAAe,GAAG,IAAI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@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SilentFlowClient.js","sources":["../../src/client/SilentFlowClient.ts"],"sourcesContent":["/*\
|
|
1
|
+
{"version":3,"file":"SilentFlowClient.js","sources":["../../src/client/SilentFlowClient.ts"],"sourcesContent":["/*\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { BaseClient } from \"./BaseClient\";\nimport { ClientConfiguration } from \"../config/ClientConfiguration\";\nimport { CommonSilentFlowRequest } from \"../request/CommonSilentFlowRequest\";\nimport { AuthenticationResult } from \"../response/AuthenticationResult\";\nimport { AuthToken } from \"../account/AuthToken\";\nimport { TimeUtils } from \"../utils/TimeUtils\";\nimport { RefreshTokenClient } from \"./RefreshTokenClient\";\nimport { ClientAuthError, ClientAuthErrorMessage } from \"../error/ClientAuthError\";\nimport { ClientConfigurationError } from \"../error/ClientConfigurationError\";\nimport { ResponseHandler } from \"../response/ResponseHandler\";\nimport { CacheRecord } from \"../cache/entities/CacheRecord\";\nimport { CacheOutcome } from \"../utils/Constants\";\n\nexport class SilentFlowClient extends BaseClient {\n\n constructor(configuration: ClientConfiguration) {\n super(configuration);\n }\n\n /**\n * Retrieves a token from cache if it is still valid, or uses the cached refresh token to renew\n * the given token and returns the renewed token\n * @param request\n */\n async acquireToken(request: CommonSilentFlowRequest): Promise<AuthenticationResult> {\n try {\n return await this.acquireCachedToken(request);\n } catch (e) {\n if (e instanceof ClientAuthError && e.errorCode === ClientAuthErrorMessage.tokenRefreshRequired.code) {\n const refreshTokenClient = new RefreshTokenClient(this.config);\n return refreshTokenClient.acquireTokenByRefreshToken(request);\n } else {\n throw e;\n }\n }\n }\n\n /**\n * Retrieves token from cache or throws an error if it must be refreshed.\n * @param request\n */\n async acquireCachedToken(request: CommonSilentFlowRequest): Promise<AuthenticationResult> {\n // Cannot renew token if no request object is given.\n if (!request) {\n throw ClientConfigurationError.createEmptyTokenRequestError();\n }\n\n if (request.forceRefresh) {\n // Must refresh due to present force_refresh flag.\n this.serverTelemetryManager?.setCacheOutcome(CacheOutcome.FORCE_REFRESH);\n this.logger.info(\"SilentFlowClient:acquireCachedToken - Skipping cache because forceRefresh is true.\");\n throw ClientAuthError.createRefreshRequiredError();\n }\n\n // We currently do not support silent flow for account === null use cases; This will be revisited for confidential flow usecases\n if (!request.account) {\n throw ClientAuthError.createNoAccountInSilentRequestError();\n }\n\n const environment = request.authority || this.authority.getPreferredCache();\n\n const cacheRecord = this.cacheManager.readCacheRecord(request.account, this.config.authOptions.clientId, request, environment);\n \n if (!cacheRecord.accessToken) {\n // Must refresh due to non-existent access_token.\n this.serverTelemetryManager?.setCacheOutcome(CacheOutcome.NO_CACHED_ACCESS_TOKEN);\n this.logger.info(\"SilentFlowClient:acquireCachedToken - No access token found in cache for the given properties.\");\n throw ClientAuthError.createRefreshRequiredError();\n } else if (\n TimeUtils.wasClockTurnedBack(cacheRecord.accessToken.cachedAt) ||\n TimeUtils.isTokenExpired(cacheRecord.accessToken.expiresOn, this.config.systemOptions.tokenRenewalOffsetSeconds)\n ) {\n // Must refresh due to expired access_token.\n this.serverTelemetryManager?.setCacheOutcome(CacheOutcome.CACHED_ACCESS_TOKEN_EXPIRED);\n this.logger.info(`SilentFlowClient:acquireCachedToken - Cached access token is expired or will expire within ${this.config.systemOptions.tokenRenewalOffsetSeconds} seconds.`);\n throw ClientAuthError.createRefreshRequiredError();\n } else if (cacheRecord.accessToken.refreshOn && TimeUtils.isTokenExpired(cacheRecord.accessToken.refreshOn, 0)) {\n // Must refresh due to the refresh_in value.\n this.serverTelemetryManager?.setCacheOutcome(CacheOutcome.REFRESH_CACHED_ACCESS_TOKEN);\n this.logger.info(\"SilentFlowClient:acquireCachedToken - Cached access token's refreshOn property has been exceeded'.\");\n throw ClientAuthError.createRefreshRequiredError();\n }\n\n if (this.config.serverTelemetryManager) {\n this.config.serverTelemetryManager.incrementCacheHits();\n }\n\n return await this.generateResultFromCacheRecord(cacheRecord, request);\n }\n\n /**\n * Helper function to build response object from the CacheRecord\n * @param cacheRecord\n */\n private async generateResultFromCacheRecord(cacheRecord: CacheRecord, request: CommonSilentFlowRequest): Promise<AuthenticationResult> {\n let idTokenObj: AuthToken | undefined;\n if (cacheRecord.idToken) {\n idTokenObj = new AuthToken(cacheRecord.idToken.secret, this.config.cryptoInterface);\n }\n return await ResponseHandler.generateAuthenticationResult(\n this.cryptoUtils,\n this.authority,\n cacheRecord,\n true,\n request,\n idTokenObj\n );\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;;AAAA;;;;;IAkBsC,oCAAU;IAE5C,0BAAY,aAAkC;eAC1C,kBAAM,aAAa,CAAC;KACvB;;;;;;IAOK,uCAAY,GAAlB,UAAmB,OAAgC;;;;;;;wBAEpC,qBAAM,IAAI,CAAC,kBAAkB,CAAC,OAAO,CAAC,EAAA;4BAA7C,sBAAO,SAAsC,EAAC;;;wBAE9C,IAAI,GAAC,YAAY,eAAe,IAAI,GAAC,CAAC,SAAS,KAAK,sBAAsB,CAAC,oBAAoB,CAAC,IAAI,EAAE;4BAC5F,kBAAkB,GAAG,IAAI,kBAAkB,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;4BAC/D,sBAAO,kBAAkB,CAAC,0BAA0B,CAAC,OAAO,CAAC,EAAC;yBACjE;6BAAM;4BACH,MAAM,GAAC,CAAC;yBACX;;;;;KAER;;;;;IAMK,6CAAkB,GAAxB,UAAyB,OAAgC;;;;;;;;wBAErD,IAAI,CAAC,OAAO,EAAE;4BACV,MAAM,wBAAwB,CAAC,4BAA4B,EAAE,CAAC;yBACjE;wBAED,IAAI,OAAO,CAAC,YAAY,EAAE;;4BAEtB,MAAA,IAAI,CAAC,sBAAsB,0CAAE,eAAe,CAAC,YAAY,CAAC,aAAa,EAAE;4BACzE,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,oFAAoF,CAAC,CAAC;4BACvG,MAAM,eAAe,CAAC,0BAA0B,EAAE,CAAC;yBACtD;;wBAGD,IAAI,CAAC,OAAO,C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I,CAAC,MAAM,CAAC,IAAI,CAAC,oGAAoG,CAAC,CAAC;4BACvH,MAAM,eAAe,CAAC,0BAA0B,EAAE,CAAC;yBACtD;wBAED,IAAI,IAAI,CAAC,MAAM,CAAC,sBAAsB,EAAE;4BACpC,IAAI,CAAC,MAAM,CAAC,sBAAsB,CAAC,kBAAkB,EAAE,CAAC;yBAC3D;wBAEM,qBAAM,IAAI,CAAC,6BAA6B,CAAC,WAAW,EAAE,OAAO,CAAC,EAAA;4BAArE,sBAAO,SAA8D,EAAC;;;;KACzE;;;;;IAMa,wDAA6B,GAA3C,UAA4C,WAAwB,EAAE,OAAgC;;;;;;wBAElG,IAAI,WAAW,CAAC,OAAO,EAAE;4BACrB,UAAU,GAAG,IAAI,SAAS,CAAC,WAAW,CAAC,OAAO,CAAC,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,eAAe,CAAC,CAAC;yBACvF;wBACM,qBAAM,eAAe,CAAC,4BAA4B,CACrD,IAAI,CAAC,WAAW,EAChB,IAAI,CAAC,SAAS,EACd,WAAW,EACX,IAAI,EACJ,OAAO,EACP,UAAU,CACb,EAAA;4BAPD,sBAAO,SAON,EAAC;;;;KACL;IACL,uBAAC;AAAD,CA/FA,CAAsC,UAAU;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UsernamePasswordClient.js","sources":["../../src/client/UsernamePasswordClient.ts"],"sourcesContent":["/*\
|
|
1
|
+
{"version":3,"file":"UsernamePasswordClient.js","sources":["../../src/client/UsernamePasswordClient.ts"],"sourcesContent":["/*\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { BaseClient } from \"./BaseClient\";\nimport { ClientConfiguration } from \"../config/ClientConfiguration\";\nimport { CommonUsernamePasswordRequest } from \"../request/CommonUsernamePasswordRequest\";\nimport { AuthenticationResult } from \"../response/AuthenticationResult\";\nimport { ResponseHandler } from \"../response/ResponseHandler\";\nimport { Authority } from \"../authority/Authority\";\nimport { NetworkResponse } from \"../network/NetworkManager\";\nimport { ServerAuthorizationTokenResponse } from \"../response/ServerAuthorizationTokenResponse\";\nimport { RequestParameterBuilder } from \"../request/RequestParameterBuilder\";\nimport { GrantType } from \"../utils/Constants\";\nimport { StringUtils } from \"../utils/StringUtils\";\nimport { RequestThumbprint } from \"../network/RequestThumbprint\";\nimport { TimeUtils } from \"../utils/TimeUtils\";\nimport { CcsCredentialType } from \"../account/CcsCredential\";\n\n/**\n * Oauth2.0 Password grant client\n * Note: We are only supporting public clients for password grant and for purely testing purposes\n */\nexport class UsernamePasswordClient extends BaseClient {\n\n constructor(configuration: ClientConfiguration) {\n super(configuration);\n }\n\n /**\n * API to acquire a token by passing the username and password to the service in exchage of credentials\n * password_grant\n * @param request\n */\n async acquireToken(request: CommonUsernamePasswordRequest): Promise<AuthenticationResult | null> {\n this.logger.info(\"in acquireToken call\");\n\n const reqTimestamp = TimeUtils.nowSeconds();\n const response = await this.executeTokenRequest(this.authority, request);\n\n const responseHandler = new ResponseHandler(\n this.config.authOptions.clientId,\n this.cacheManager,\n this.cryptoUtils,\n this.logger,\n this.config.serializableCache,\n this.config.persistencePlugin\n );\n\n // Validate response. This function throws a server error if an error is returned by the server.\n responseHandler.validateTokenResponse(response.body);\n const tokenResponse = responseHandler.handleServerTokenResponse(response.body, this.authority, reqTimestamp, request);\n\n return tokenResponse;\n }\n\n /**\n * Executes POST request to token endpoint\n * @param authority\n * @param request\n */\n private async executeTokenRequest(authority: Authority, request: CommonUsernamePasswordRequest): Promise<NetworkResponse<ServerAuthorizationTokenResponse>> {\n const thumbprint: RequestThumbprint = {\n clientId: this.config.authOptions.clientId,\n authority: authority.canonicalAuthority,\n scopes: request.scopes,\n claims: request.claims,\n authenticationScheme: request.authenticationScheme,\n resourceRequestMethod: request.resourceRequestMethod,\n resourceRequestUri: request.resourceRequestUri,\n shrClaims: request.shrClaims,\n sshKid: request.sshKid\n };\n const requestBody = this.createTokenRequestBody(request);\n const headers: Record<string, string> = this.createTokenRequestHeaders({\n credential: request.username,\n type: CcsCredentialType.UPN\n });\n\n return this.executePostToTokenEndpoint(authority.tokenEndpoint, requestBody, headers, thumbprint);\n }\n\n /**\n * Generates a map for all the params to be sent to the service\n * @param request\n */\n private createTokenRequestBody(request: CommonUsernamePasswordRequest): string {\n const parameterBuilder = new RequestParameterBuilder();\n\n parameterBuilder.addClientId(this.config.authOptions.clientId);\n parameterBuilder.addUsername(request.username);\n parameterBuilder.addPassword(request.password);\n\n parameterBuilder.addScopes(request.scopes);\n\n parameterBuilder.addResponseTypeForTokenAndIdToken();\n\n parameterBuilder.addGrantType(GrantType.RESOURCE_OWNER_PASSWORD_GRANT);\n parameterBuilder.addClientInfo();\n\n parameterBuilder.addLibraryInfo(this.config.libraryInfo);\n parameterBuilder.addApplicationTelemetry(this.config.telemetry.application);\n parameterBuilder.addThrottling();\n\n if (this.serverTelemetryManager) {\n parameterBuilder.addServerTelemetry(this.serverTelemetryManager);\n }\n\n const correlationId = request.correlationId || this.config.cryptoInterface.createNewGuid();\n parameterBuilder.addCorrelationId(correlationId);\n\n if (this.config.clientCredentials.clientSecret) {\n parameterBuilder.addClientSecret(this.config.clientCredentials.clientSecret);\n }\n\n if (this.config.clientCredentials.clientAssertion) {\n const clientAssertion = this.config.clientCredentials.clientAssertion;\n parameterBuilder.addClientAssertion(clientAssertion.assertion);\n parameterBuilder.addClientAssertionType(clientAssertion.assertionType);\n }\n\n if (!StringUtils.isEmptyObj(request.claims) || this.config.authOptions.clientCapabilities && this.config.authOptions.clientCapabilities.length > 0) {\n parameterBuilder.addClaims(request.claims, this.config.authOptions.clientCapabilities);\n }\n\n if (this.config.systemOptions.preventCorsPreflight && request.username) {\n parameterBuilder.addCcsUpn(request.username);\n }\n\n return parameterBuilder.createQueryString();\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;AAAA;;;;AAoBA;;;;;IAI4C,0CAAU;IAElD,gCAAY,aAAkC;eAC1C,kBAAM,aAAa,CAAC;KACvB;;;;;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C,aAAa,EAAE,CAAC;QAC3F,gBAAgB,CAAC,gBAAgB,CAAC,aAAa,CAAC,CAAC;QAEjD,IAAI,IAAI,CAAC,MAAM,CAAC,iBAAiB,CAAC,YAAY,EAAE;YAC5C,gBAAgB,CAAC,eAAe,CAAC,IAAI,CAAC,MAAM,CAAC,iBAAiB,CAAC,YAAY,CAAC,CAAC;SAChF;QAED,IAAI,IAAI,CAAC,MAAM,CAAC,iBAAiB,CAAC,eAAe,EAAE;YAC/C,IAAM,eAAe,GAAG,IAAI,CAAC,MAAM,CAAC,iBAAiB,CAAC,eAAe,CAAC;YACtE,gBAAgB,CAAC,kBAAkB,CAAC,eAAe,CAAC,SAAS,CAAC,CAAC;YAC/D,gBAAgB,CAAC,sBAAsB,CAAC,eAAe,CAAC,aAAa,CAAC,CAAC;SAC1E;QAED,IAAI,CAAC,WAAW,CAAC,UAAU,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,kBAAkB,IAAI,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,kBAAkB,CAAC,MAAM,GAAG,CAAC,EAAE;YAChJ,gBAAgB,CAAC,SAAS,CAAC,OAAO,CAAC,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,kBAAkB,CAAC,CAAC;SAC1F;QAED,IAAI,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,oBAAoB,IAAI,OAAO,CAAC,QAAQ,EAAE;YACpE,gBAAgB,CAAC,SAAS,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;SAChD;QAED,OAAO,gBAAgB,CAAC,iBAAiB,EAAE,CAAC;KAC/C;IACL,6BAAC;AAAD,CA5GA,CAA4C,UAAU;;;;"}
|
|
@@ -7,6 +7,7 @@ import { CacheManager } from "../cache/CacheManager";
|
|
|
7
7
|
import { ServerTelemetryManager } from "../telemetry/server/ServerTelemetryManager";
|
|
8
8
|
import { ICachePlugin } from "../cache/interface/ICachePlugin";
|
|
9
9
|
import { ISerializableTokenCache } from "../cache/interface/ISerializableTokenCache";
|
|
10
|
+
import { ClientCredentials } from "../account/ClientCredentials";
|
|
10
11
|
/**
|
|
11
12
|
* Use the configuration object to configure MSAL Modules and initialize the base interfaces for MSAL.
|
|
12
13
|
*
|
|
@@ -98,16 +99,6 @@ export declare type LibraryInfo = {
|
|
|
98
99
|
cpu: string;
|
|
99
100
|
os: string;
|
|
100
101
|
};
|
|
101
|
-
/**
|
|
102
|
-
* Credentials for confidential clients
|
|
103
|
-
*/
|
|
104
|
-
export declare type ClientCredentials = {
|
|
105
|
-
clientSecret?: string;
|
|
106
|
-
clientAssertion?: {
|
|
107
|
-
assertion: string;
|
|
108
|
-
assertionType: string;
|
|
109
|
-
};
|
|
110
|
-
};
|
|
111
102
|
/**
|
|
112
103
|
* AzureCloudInstance specific options
|
|
113
104
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ClientConfiguration.d.ts","sourceRoot":"","sources":["../../src/config/ClientConfiguration.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,EAAiC,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAE3E,OAAO,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAG7D,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACnD,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AACnE,OAAO,EAAE,YAAY,EAAuB,MAAM,uBAAuB,CAAC;AAC1E,OAAO,EAAE,sBAAsB,EAAE,MAAM,4CAA4C,CAAC;AACpF,OAAO,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAC/D,OAAO,EAAE,uBAAuB,EAAE,MAAM,4CAA4C,CAAC;
|
|
1
|
+
{"version":3,"file":"ClientConfiguration.d.ts","sourceRoot":"","sources":["../../src/config/ClientConfiguration.ts"],"names":[],"mappings":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