@azure/msal-node 1.3.1 → 1.5.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.
Files changed (35) hide show
  1. package/CHANGELOG.json +126 -0
  2. package/{changelog.md → CHANGELOG.md} +304 -267
  3. package/LICENSE +21 -21
  4. package/README.md +183 -182
  5. package/dist/cache/NodeStorage.d.ts +5 -1
  6. package/dist/cache/NodeStorage.d.ts.map +1 -1
  7. package/dist/crypto/CryptoProvider.d.ts +4 -0
  8. package/dist/crypto/CryptoProvider.d.ts.map +1 -1
  9. package/dist/index.d.ts +2 -1
  10. package/dist/index.d.ts.map +1 -1
  11. package/dist/msal-node.cjs.development.js +53 -5
  12. package/dist/msal-node.cjs.development.js.map +1 -1
  13. package/dist/msal-node.cjs.production.min.js +1 -1
  14. package/dist/msal-node.cjs.production.min.js.map +1 -1
  15. package/dist/msal-node.esm.js +48 -7
  16. package/dist/msal-node.esm.js.map +1 -1
  17. package/dist/network/HttpClient.d.ts.map +1 -1
  18. package/dist/packageMetadata.d.ts +1 -1
  19. package/dist/request/AuthorizationCodeRequest.d.ts +1 -1
  20. package/dist/request/AuthorizationCodeRequest.d.ts.map +1 -1
  21. package/dist/request/AuthorizationUrlRequest.d.ts +1 -1
  22. package/dist/request/AuthorizationUrlRequest.d.ts.map +1 -1
  23. package/dist/request/ClientCredentialRequest.d.ts +1 -1
  24. package/dist/request/ClientCredentialRequest.d.ts.map +1 -1
  25. package/dist/request/DeviceCodeRequest.d.ts +1 -1
  26. package/dist/request/DeviceCodeRequest.d.ts.map +1 -1
  27. package/dist/request/OnBehalfOfRequest.d.ts +1 -1
  28. package/dist/request/OnBehalfOfRequest.d.ts.map +1 -1
  29. package/dist/request/RefreshTokenRequest.d.ts +1 -1
  30. package/dist/request/RefreshTokenRequest.d.ts.map +1 -1
  31. package/dist/request/SilentFlowRequest.d.ts +1 -1
  32. package/dist/request/SilentFlowRequest.d.ts.map +1 -1
  33. package/dist/request/UsernamePasswordRequest.d.ts +1 -1
  34. package/dist/request/UsernamePasswordRequest.d.ts.map +1 -1
  35. package/package.json +12 -6
@@ -1,5 +1,5 @@
1
1
  import { Constants as Constants$1, ProtocolMode, LogLevel, StringUtils, AccountEntity, CacheManager, IdTokenEntity, AccessTokenEntity, RefreshTokenEntity, AppMetadataEntity, ServerTelemetryEntity, AuthorityMetadataEntity, ThrottlingEntity, TokenCacheContext, Logger, ResponseMode, AuthenticationScheme, AuthorizationCodeClient, AuthError, RefreshTokenClient, SilentFlowClient, UsernamePasswordClient, OIDC_DEFAULT_SCOPES, ServerTelemetryManager, AuthorityFactory, DeviceCodeClient, ClientAuthError, TimeUtils, ClientCredentialClient, OnBehalfOfClient } from '@azure/msal-common';
2
- export { AuthError, AuthErrorMessage, ClientAuthError, ClientAuthErrorMessage, ClientConfigurationError, ClientConfigurationErrorMessage, InteractionRequiredAuthError, LogLevel, Logger, PromptValue, ProtocolMode, ResponseMode, ServerError, TokenCacheContext } from '@azure/msal-common';
2
+ export { AuthError, AuthErrorMessage, ClientAuthError, ClientAuthErrorMessage, ClientConfigurationError, ClientConfigurationErrorMessage, InteractionRequiredAuthError, InteractionRequiredAuthErrorMessage, LogLevel, Logger, PromptValue, ProtocolMode, ResponseMode, ServerError, TokenCacheContext } from '@azure/msal-common';
3
3
  import axios from 'axios';
4
4
  import { v4 } from 'uuid';
5
5
  import crypto from 'crypto';
@@ -106,7 +106,11 @@ class HttpClient {
106
106
  const request = {
107
107
  method: HttpMethod.GET,
108
108
  url: url,
109
+
110
+ /* istanbul ignore next */
109
111
  headers: options && options.headers,
112
+
113
+ /* istanbul ignore next */
110
114
  validateStatus: () => true
111
115
  };
112
116
  const response = await axios(request);
@@ -127,9 +131,15 @@ class HttpClient {
127
131
  const request = {
128
132
  method: HttpMethod.POST,
129
133
  url: url,
134
+
135
+ /* istanbul ignore next */
130
136
  data: options && options.body || "",
131
137
  timeout: cancellationToken,
138
+
139
+ /* istanbul ignore next */
132
140
  headers: options && options.headers,
141
+
142
+ /* istanbul ignore next */
133
143
  validateStatus: () => true
134
144
  };
135
145
  const response = await axios(request);
@@ -445,6 +455,14 @@ class CryptoProvider {
445
455
  signJwt() {
446
456
  throw new Error("Method not implemented.");
447
457
  }
458
+ /**
459
+ * Returns the SHA-256 hash of an input string
460
+ */
461
+
462
+
463
+ hashString() {
464
+ throw new Error("Method not implemented.");
465
+ }
448
466
 
449
467
  }
450
468
 
@@ -1222,6 +1240,29 @@ class NodeStorage extends CacheManager {
1222
1240
  static generateJsonCache(inMemoryCache) {
1223
1241
  return Serializer.serializeAllCache(inMemoryCache);
1224
1242
  }
1243
+ /**
1244
+ * Updates a credential's cache key if the current cache key is outdated
1245
+ */
1246
+
1247
+
1248
+ updateCredentialCacheKey(currentCacheKey, credential) {
1249
+ const updatedCacheKey = credential.generateCredentialKey();
1250
+
1251
+ if (currentCacheKey !== updatedCacheKey) {
1252
+ const cacheItem = this.getItem(currentCacheKey);
1253
+
1254
+ if (cacheItem) {
1255
+ this.removeItem(currentCacheKey);
1256
+ this.setItem(updatedCacheKey, cacheItem);
1257
+ this.logger.verbose(`Updated an outdated ${credential.credentialType} cache key`);
1258
+ return updatedCacheKey;
1259
+ } else {
1260
+ this.logger.error(`Attempted to update an outdated ${credential.credentialType} cache key but no item matching the outdated key was found in storage`);
1261
+ }
1262
+ }
1263
+
1264
+ return currentCacheKey;
1265
+ }
1225
1266
 
1226
1267
  }
1227
1268
 
@@ -1507,7 +1548,7 @@ class TokenCache {
1507
1548
 
1508
1549
  /* eslint-disable header/header */
1509
1550
  const name = "@azure/msal-node";
1510
- const version = "1.3.1";
1551
+ const version = "1.5.0";
1511
1552
 
1512
1553
  /*
1513
1554
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1955,13 +1996,13 @@ class ClientAssertion {
1955
1996
  const issuedAt = TimeUtils.nowSeconds();
1956
1997
  this.expirationTime = issuedAt + 600;
1957
1998
  const header = {
1958
- [JwtConstants.ALGORITHM]: JwtConstants.RSA_256,
1959
- [JwtConstants.X5T]: EncodingUtils.base64EncodeUrl(this.thumbprint, "hex")
1999
+ alg: JwtConstants.RSA_256,
2000
+ x5t: EncodingUtils.base64EncodeUrl(this.thumbprint, "hex")
1960
2001
  };
1961
2002
 
1962
2003
  if (this.publicCertificate) {
1963
2004
  Object.assign(header, {
1964
- [JwtConstants.X5C]: this.publicCertificate
2005
+ x5c: this.publicCertificate
1965
2006
  });
1966
2007
  }
1967
2008
 
@@ -1974,7 +2015,7 @@ class ClientAssertion {
1974
2015
  [JwtConstants.JWT_ID]: cryptoProvider.createNewGuid()
1975
2016
  };
1976
2017
  this.jwt = sign(payload, this.privateKey, {
1977
- header: header
2018
+ header
1978
2019
  });
1979
2020
  return this.jwt;
1980
2021
  }
@@ -2145,5 +2186,5 @@ class ConfidentialClientApplication extends ClientApplication {
2145
2186
 
2146
2187
  }
2147
2188
 
2148
- export { ClientApplication, ClientAssertion, ConfidentialClientApplication, CryptoProvider, NodeStorage, PublicClientApplication, TokenCache, buildAppConfiguration };
2189
+ export { ClientApplication, ClientAssertion, ConfidentialClientApplication, CryptoProvider, NodeStorage, PublicClientApplication, TokenCache, buildAppConfiguration, version };
2149
2190
  //# sourceMappingURL=msal-node.esm.js.map