@azure/msal-node 1.6.0 → 1.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cache/NodeStorage.d.ts.map +1 -1
- package/dist/cache/serializer/Deserializer.d.ts.map +1 -1
- package/dist/cache/serializer/Serializer.d.ts.map +1 -1
- package/dist/cache/serializer/SerializerTypes.d.ts +2 -0
- package/dist/cache/serializer/SerializerTypes.d.ts.map +1 -1
- package/dist/client/ClientApplication.d.ts +7 -3
- package/dist/client/ClientApplication.d.ts.map +1 -1
- package/dist/client/IConfidentialClientApplication.d.ts +2 -0
- package/dist/client/IConfidentialClientApplication.d.ts.map +1 -1
- package/dist/client/IPublicClientApplication.d.ts +2 -0
- package/dist/client/IPublicClientApplication.d.ts.map +1 -1
- package/dist/crypto/CryptoProvider.d.ts +2 -1
- package/dist/crypto/CryptoProvider.d.ts.map +1 -1
- package/dist/crypto/HashUtils.d.ts +9 -0
- package/dist/crypto/HashUtils.d.ts.map +1 -0
- package/dist/crypto/PkceGenerator.d.ts +2 -5
- package/dist/crypto/PkceGenerator.d.ts.map +1 -1
- package/dist/msal-node.cjs.development.js +60 -29
- package/dist/msal-node.cjs.development.js.map +1 -1
- package/dist/msal-node.cjs.production.min.js +1 -1
- package/dist/msal-node.cjs.production.min.js.map +1 -1
- package/dist/msal-node.esm.js +60 -29
- package/dist/msal-node.esm.js.map +1 -1
- package/dist/packageMetadata.d.ts +1 -1
- package/package.json +1 -1
- package/CHANGELOG.json +0 -1027
- package/CHANGELOG.md +0 -333
package/dist/msal-node.esm.js
CHANGED
|
@@ -323,6 +323,21 @@ class EncodingUtils {
|
|
|
323
323
|
|
|
324
324
|
}
|
|
325
325
|
|
|
326
|
+
/*
|
|
327
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
328
|
+
* Licensed under the MIT License.
|
|
329
|
+
*/
|
|
330
|
+
class HashUtils {
|
|
331
|
+
/**
|
|
332
|
+
* generate 'SHA256' hash
|
|
333
|
+
* @param buffer
|
|
334
|
+
*/
|
|
335
|
+
sha256(buffer) {
|
|
336
|
+
return crypto.createHash(Hash.SHA256).update(buffer).digest();
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
}
|
|
340
|
+
|
|
326
341
|
/*
|
|
327
342
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
328
343
|
* Licensed under the MIT License.
|
|
@@ -332,10 +347,15 @@ class EncodingUtils {
|
|
|
332
347
|
*/
|
|
333
348
|
|
|
334
349
|
class PkceGenerator {
|
|
350
|
+
constructor() {
|
|
351
|
+
this.hashUtils = new HashUtils();
|
|
352
|
+
}
|
|
335
353
|
/**
|
|
336
354
|
* generates the codeVerfier and the challenge from the codeVerfier
|
|
337
355
|
* reference: https://tools.ietf.org/html/rfc7636#section-4.1 and https://tools.ietf.org/html/rfc7636#section-4.2
|
|
338
356
|
*/
|
|
357
|
+
|
|
358
|
+
|
|
339
359
|
async generatePkceCodes() {
|
|
340
360
|
const verifier = this.generateCodeVerifier();
|
|
341
361
|
const challenge = this.generateCodeChallengeFromVerifier(verifier);
|
|
@@ -378,16 +398,7 @@ class PkceGenerator {
|
|
|
378
398
|
|
|
379
399
|
|
|
380
400
|
generateCodeChallengeFromVerifier(codeVerifier) {
|
|
381
|
-
return EncodingUtils.base64EncodeUrl(this.sha256(codeVerifier).toString("base64"), "base64");
|
|
382
|
-
}
|
|
383
|
-
/**
|
|
384
|
-
* generate 'SHA256' hash
|
|
385
|
-
* @param buffer
|
|
386
|
-
*/
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
sha256(buffer) {
|
|
390
|
-
return crypto.createHash(Hash.SHA256).update(buffer).digest();
|
|
401
|
+
return EncodingUtils.base64EncodeUrl(this.hashUtils.sha256(codeVerifier).toString("base64"), "base64");
|
|
391
402
|
}
|
|
392
403
|
|
|
393
404
|
}
|
|
@@ -406,6 +417,7 @@ class CryptoProvider {
|
|
|
406
417
|
constructor() {
|
|
407
418
|
// Browser crypto needs to be validated first before any other classes can be set.
|
|
408
419
|
this.pkceGenerator = new PkceGenerator();
|
|
420
|
+
this.hashUtils = new HashUtils();
|
|
409
421
|
}
|
|
410
422
|
/**
|
|
411
423
|
* Creates a new random GUID - used to populate state and nonce.
|
|
@@ -480,8 +492,8 @@ class CryptoProvider {
|
|
|
480
492
|
*/
|
|
481
493
|
|
|
482
494
|
|
|
483
|
-
hashString() {
|
|
484
|
-
|
|
495
|
+
async hashString(plainText) {
|
|
496
|
+
return EncodingUtils.base64EncodeUrl(this.hashUtils.sha256(plainText).toString("base64"), "base64");
|
|
485
497
|
}
|
|
486
498
|
|
|
487
499
|
}
|
|
@@ -588,7 +600,9 @@ class Deserializer {
|
|
|
588
600
|
extendedExpiresOn: serializedAT.extended_expires_on,
|
|
589
601
|
refreshOn: serializedAT.refresh_on,
|
|
590
602
|
keyId: serializedAT.key_id,
|
|
591
|
-
tokenType: serializedAT.token_type
|
|
603
|
+
tokenType: serializedAT.token_type,
|
|
604
|
+
requestedClaims: serializedAT.requestedClaims,
|
|
605
|
+
requestedClaimsHash: serializedAT.requestedClaimsHash
|
|
592
606
|
};
|
|
593
607
|
const accessToken = new AccessTokenEntity();
|
|
594
608
|
CacheManager.toObject(accessToken, mappedAT);
|
|
@@ -752,7 +766,9 @@ class Serializer {
|
|
|
752
766
|
extended_expires_on: atEntity.extendedExpiresOn,
|
|
753
767
|
refresh_on: atEntity.refreshOn,
|
|
754
768
|
key_id: atEntity.keyId,
|
|
755
|
-
token_type: atEntity.tokenType
|
|
769
|
+
token_type: atEntity.tokenType,
|
|
770
|
+
requestedClaims: atEntity.requestedClaims,
|
|
771
|
+
requestedClaimsHash: atEntity.requestedClaimsHash
|
|
756
772
|
};
|
|
757
773
|
});
|
|
758
774
|
return accessTokens;
|
|
@@ -891,12 +907,14 @@ class NodeStorage extends CacheManager {
|
|
|
891
907
|
inMemoryCacheToCache(inMemoryCache) {
|
|
892
908
|
// convert in memory cache to a flat Key-Value map
|
|
893
909
|
let cache = this.getCache();
|
|
894
|
-
cache = { ...
|
|
910
|
+
cache = { ...cache,
|
|
911
|
+
...inMemoryCache.accounts,
|
|
895
912
|
...inMemoryCache.idTokens,
|
|
896
913
|
...inMemoryCache.accessTokens,
|
|
897
914
|
...inMemoryCache.refreshTokens,
|
|
898
915
|
...inMemoryCache.appMetadata
|
|
899
|
-
};
|
|
916
|
+
}; // convert in memory cache to a flat Key-Value map
|
|
917
|
+
|
|
900
918
|
return cache;
|
|
901
919
|
}
|
|
902
920
|
/**
|
|
@@ -1568,7 +1586,7 @@ class TokenCache {
|
|
|
1568
1586
|
|
|
1569
1587
|
/* eslint-disable header/header */
|
|
1570
1588
|
const name = "@azure/msal-node";
|
|
1571
|
-
const version = "1.
|
|
1589
|
+
const version = "1.7.0";
|
|
1572
1590
|
|
|
1573
1591
|
/*
|
|
1574
1592
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -1604,7 +1622,7 @@ class ClientApplication {
|
|
|
1604
1622
|
async getAuthCodeUrl(request) {
|
|
1605
1623
|
this.logger.info("getAuthCodeUrl called", request.correlationId);
|
|
1606
1624
|
const validRequest = { ...request,
|
|
1607
|
-
...this.initializeBaseRequest(request),
|
|
1625
|
+
...(await this.initializeBaseRequest(request)),
|
|
1608
1626
|
responseMode: request.responseMode || ResponseMode.QUERY,
|
|
1609
1627
|
authenticationScheme: AuthenticationScheme.BEARER
|
|
1610
1628
|
};
|
|
@@ -1623,10 +1641,10 @@ class ClientApplication {
|
|
|
1623
1641
|
*/
|
|
1624
1642
|
|
|
1625
1643
|
|
|
1626
|
-
async acquireTokenByCode(request) {
|
|
1644
|
+
async acquireTokenByCode(request, authCodePayLoad) {
|
|
1627
1645
|
this.logger.info("acquireTokenByCode called", request.correlationId);
|
|
1628
1646
|
const validRequest = { ...request,
|
|
1629
|
-
...this.initializeBaseRequest(request),
|
|
1647
|
+
...(await this.initializeBaseRequest(request)),
|
|
1630
1648
|
authenticationScheme: AuthenticationScheme.BEARER
|
|
1631
1649
|
};
|
|
1632
1650
|
const serverTelemetryManager = this.initializeServerTelemetryManager(ApiId.acquireTokenByCode, validRequest.correlationId);
|
|
@@ -1635,7 +1653,7 @@ class ClientApplication {
|
|
|
1635
1653
|
const authClientConfig = await this.buildOauthClientConfiguration(validRequest.authority, validRequest.correlationId, serverTelemetryManager, undefined, request.azureCloudOptions);
|
|
1636
1654
|
const authorizationCodeClient = new AuthorizationCodeClient(authClientConfig);
|
|
1637
1655
|
this.logger.verbose("Auth code client created", validRequest.correlationId);
|
|
1638
|
-
return authorizationCodeClient.acquireToken(validRequest);
|
|
1656
|
+
return authorizationCodeClient.acquireToken(validRequest, authCodePayLoad);
|
|
1639
1657
|
} catch (e) {
|
|
1640
1658
|
if (e instanceof AuthError) {
|
|
1641
1659
|
e.setCorrelationId(validRequest.correlationId);
|
|
@@ -1657,7 +1675,7 @@ class ClientApplication {
|
|
|
1657
1675
|
async acquireTokenByRefreshToken(request) {
|
|
1658
1676
|
this.logger.info("acquireTokenByRefreshToken called", request.correlationId);
|
|
1659
1677
|
const validRequest = { ...request,
|
|
1660
|
-
...this.initializeBaseRequest(request),
|
|
1678
|
+
...(await this.initializeBaseRequest(request)),
|
|
1661
1679
|
authenticationScheme: AuthenticationScheme.BEARER
|
|
1662
1680
|
};
|
|
1663
1681
|
const serverTelemetryManager = this.initializeServerTelemetryManager(ApiId.acquireTokenByRefreshToken, validRequest.correlationId);
|
|
@@ -1688,7 +1706,7 @@ class ClientApplication {
|
|
|
1688
1706
|
|
|
1689
1707
|
async acquireTokenSilent(request) {
|
|
1690
1708
|
const validRequest = { ...request,
|
|
1691
|
-
...this.initializeBaseRequest(request),
|
|
1709
|
+
...(await this.initializeBaseRequest(request)),
|
|
1692
1710
|
forceRefresh: request.forceRefresh || false
|
|
1693
1711
|
};
|
|
1694
1712
|
const serverTelemetryManager = this.initializeServerTelemetryManager(ApiId.acquireTokenSilent, validRequest.correlationId, validRequest.forceRefresh);
|
|
@@ -1722,7 +1740,7 @@ class ClientApplication {
|
|
|
1722
1740
|
async acquireTokenByUsernamePassword(request) {
|
|
1723
1741
|
this.logger.info("acquireTokenByUsernamePassword called", request.correlationId);
|
|
1724
1742
|
const validRequest = { ...request,
|
|
1725
|
-
...this.initializeBaseRequest(request)
|
|
1743
|
+
...(await this.initializeBaseRequest(request))
|
|
1726
1744
|
};
|
|
1727
1745
|
const serverTelemetryManager = this.initializeServerTelemetryManager(ApiId.acquireTokenByUsernamePassword, validRequest.correlationId);
|
|
1728
1746
|
|
|
@@ -1827,14 +1845,19 @@ class ClientApplication {
|
|
|
1827
1845
|
*/
|
|
1828
1846
|
|
|
1829
1847
|
|
|
1830
|
-
initializeBaseRequest(authRequest) {
|
|
1848
|
+
async initializeBaseRequest(authRequest) {
|
|
1831
1849
|
this.logger.verbose("initializeRequestScopes called", authRequest.correlationId); // Default authenticationScheme to Bearer, log that POP isn't supported yet
|
|
1832
1850
|
|
|
1833
1851
|
if (authRequest.authenticationScheme && authRequest.authenticationScheme === AuthenticationScheme.POP) {
|
|
1834
1852
|
this.logger.verbose("Authentication Scheme 'pop' is not supported yet, setting Authentication Scheme to 'Bearer' for request", authRequest.correlationId);
|
|
1835
1853
|
}
|
|
1836
1854
|
|
|
1837
|
-
authRequest.authenticationScheme = AuthenticationScheme.BEARER;
|
|
1855
|
+
authRequest.authenticationScheme = AuthenticationScheme.BEARER; // Set requested claims hash if claims were requested
|
|
1856
|
+
|
|
1857
|
+
if (authRequest.claims && !StringUtils.isEmpty(authRequest.claims)) {
|
|
1858
|
+
authRequest.requestedClaimsHash = await this.cryptoProvider.hashString(authRequest.claims);
|
|
1859
|
+
}
|
|
1860
|
+
|
|
1838
1861
|
return { ...authRequest,
|
|
1839
1862
|
scopes: [...(authRequest && authRequest.scopes || []), ...OIDC_DEFAULT_SCOPES],
|
|
1840
1863
|
correlationId: authRequest && authRequest.correlationId || this.cryptoProvider.createNewGuid(),
|
|
@@ -1878,6 +1901,14 @@ class ClientApplication {
|
|
|
1878
1901
|
};
|
|
1879
1902
|
return await AuthorityFactory.createDiscoveredInstance(authorityUrl, this.config.system.networkClient, this.storage, authorityOptions);
|
|
1880
1903
|
}
|
|
1904
|
+
/**
|
|
1905
|
+
* Clear the cache
|
|
1906
|
+
*/
|
|
1907
|
+
|
|
1908
|
+
|
|
1909
|
+
clearCache() {
|
|
1910
|
+
this.storage.clear();
|
|
1911
|
+
}
|
|
1881
1912
|
|
|
1882
1913
|
}
|
|
1883
1914
|
|
|
@@ -1925,7 +1956,7 @@ class PublicClientApplication extends ClientApplication {
|
|
|
1925
1956
|
|
|
1926
1957
|
async acquireTokenByDeviceCode(request) {
|
|
1927
1958
|
this.logger.info("acquireTokenByDeviceCode called", request.correlationId);
|
|
1928
|
-
const validRequest = Object.assign(request, this.initializeBaseRequest(request));
|
|
1959
|
+
const validRequest = Object.assign(request, await this.initializeBaseRequest(request));
|
|
1929
1960
|
const serverTelemetryManager = this.initializeServerTelemetryManager(ApiId.acquireTokenByDeviceCode, validRequest.correlationId);
|
|
1930
1961
|
|
|
1931
1962
|
try {
|
|
@@ -2124,7 +2155,7 @@ class ConfidentialClientApplication extends ClientApplication {
|
|
|
2124
2155
|
async acquireTokenByClientCredential(request) {
|
|
2125
2156
|
this.logger.info("acquireTokenByClientCredential called", request.correlationId);
|
|
2126
2157
|
const validRequest = { ...request,
|
|
2127
|
-
...this.initializeBaseRequest(request)
|
|
2158
|
+
...(await this.initializeBaseRequest(request))
|
|
2128
2159
|
};
|
|
2129
2160
|
const azureRegionConfiguration = {
|
|
2130
2161
|
azureRegion: validRequest.azureRegion,
|
|
@@ -2162,7 +2193,7 @@ class ConfidentialClientApplication extends ClientApplication {
|
|
|
2162
2193
|
async acquireTokenOnBehalfOf(request) {
|
|
2163
2194
|
this.logger.info("acquireTokenOnBehalfOf called", request.correlationId);
|
|
2164
2195
|
const validRequest = { ...request,
|
|
2165
|
-
...this.initializeBaseRequest(request)
|
|
2196
|
+
...(await this.initializeBaseRequest(request))
|
|
2166
2197
|
};
|
|
2167
2198
|
|
|
2168
2199
|
try {
|