@azure/msal-node 2.2.0-alpha.0 → 2.3.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 (114) hide show
  1. package/dist/cache/ITokenCache.d.ts +15 -15
  2. package/dist/cache/NodeStorage.cjs +401 -401
  3. package/dist/cache/NodeStorage.cjs.map +1 -1
  4. package/dist/cache/NodeStorage.d.ts +182 -182
  5. package/dist/cache/NodeStorage.d.ts.map +1 -1
  6. package/dist/cache/NodeStorage.mjs +401 -401
  7. package/dist/cache/NodeStorage.mjs.map +1 -1
  8. package/dist/cache/TokenCache.cjs +265 -265
  9. package/dist/cache/TokenCache.d.ts +90 -90
  10. package/dist/cache/TokenCache.mjs +265 -265
  11. package/dist/cache/distributed/DistributedCachePlugin.cjs +26 -26
  12. package/dist/cache/distributed/DistributedCachePlugin.d.ts +10 -10
  13. package/dist/cache/distributed/DistributedCachePlugin.mjs +26 -26
  14. package/dist/cache/distributed/ICacheClient.d.ts +17 -17
  15. package/dist/cache/distributed/IPartitionManager.d.ts +28 -28
  16. package/dist/cache/serializer/Deserializer.cjs +173 -173
  17. package/dist/cache/serializer/Deserializer.d.ts +42 -42
  18. package/dist/cache/serializer/Deserializer.mjs +173 -173
  19. package/dist/cache/serializer/Serializer.cjs +134 -134
  20. package/dist/cache/serializer/Serializer.d.ts +39 -39
  21. package/dist/cache/serializer/Serializer.mjs +134 -134
  22. package/dist/cache/serializer/SerializerTypes.d.ts +101 -101
  23. package/dist/client/ClientApplication.cjs +333 -333
  24. package/dist/client/ClientApplication.cjs.map +1 -1
  25. package/dist/client/ClientApplication.d.ts +142 -142
  26. package/dist/client/ClientApplication.d.ts.map +1 -1
  27. package/dist/client/ClientApplication.mjs +334 -334
  28. package/dist/client/ClientApplication.mjs.map +1 -1
  29. package/dist/client/ClientAssertion.cjs +116 -116
  30. package/dist/client/ClientAssertion.d.ts +46 -46
  31. package/dist/client/ClientAssertion.mjs +116 -116
  32. package/dist/client/ClientCredentialClient.cjs +189 -189
  33. package/dist/client/ClientCredentialClient.d.ts +33 -33
  34. package/dist/client/ClientCredentialClient.mjs +189 -189
  35. package/dist/client/ConfidentialClientApplication.cjs +163 -163
  36. package/dist/client/ConfidentialClientApplication.d.ts +58 -58
  37. package/dist/client/ConfidentialClientApplication.mjs +163 -163
  38. package/dist/client/DeviceCodeClient.cjs +207 -207
  39. package/dist/client/DeviceCodeClient.d.ts +53 -53
  40. package/dist/client/DeviceCodeClient.mjs +207 -207
  41. package/dist/client/IConfidentialClientApplication.d.ts +39 -39
  42. package/dist/client/IPublicClientApplication.d.ts +42 -42
  43. package/dist/client/OnBehalfOfClient.cjs +202 -202
  44. package/dist/client/OnBehalfOfClient.d.ts +47 -47
  45. package/dist/client/OnBehalfOfClient.mjs +202 -202
  46. package/dist/client/PublicClientApplication.cjs +229 -229
  47. package/dist/client/PublicClientApplication.d.ts +71 -71
  48. package/dist/client/PublicClientApplication.mjs +229 -229
  49. package/dist/client/UsernamePasswordClient.cjs +95 -95
  50. package/dist/client/UsernamePasswordClient.d.ts +25 -25
  51. package/dist/client/UsernamePasswordClient.mjs +95 -95
  52. package/dist/config/Configuration.cjs +72 -72
  53. package/dist/config/Configuration.d.ts +107 -107
  54. package/dist/config/Configuration.mjs +72 -72
  55. package/dist/crypto/CryptoProvider.cjs +75 -75
  56. package/dist/crypto/CryptoProvider.d.ts +52 -52
  57. package/dist/crypto/CryptoProvider.mjs +75 -75
  58. package/dist/crypto/GuidGenerator.cjs +22 -22
  59. package/dist/crypto/GuidGenerator.d.ts +14 -14
  60. package/dist/crypto/GuidGenerator.mjs +22 -22
  61. package/dist/crypto/HashUtils.cjs +13 -13
  62. package/dist/crypto/HashUtils.d.ts +8 -8
  63. package/dist/crypto/HashUtils.mjs +13 -13
  64. package/dist/crypto/PkceGenerator.cjs +49 -49
  65. package/dist/crypto/PkceGenerator.d.ts +22 -22
  66. package/dist/crypto/PkceGenerator.mjs +49 -49
  67. package/dist/error/NodeAuthError.cjs +85 -85
  68. package/dist/error/NodeAuthError.d.ts +65 -65
  69. package/dist/error/NodeAuthError.mjs +85 -85
  70. package/dist/index.cjs +1 -1
  71. package/dist/index.d.ts +42 -42
  72. package/dist/index.d.ts.map +1 -1
  73. package/dist/index.mjs +1 -1
  74. package/dist/internals.cjs +8 -8
  75. package/dist/internals.d.ts +6 -6
  76. package/dist/internals.mjs +8 -8
  77. package/dist/network/HttpClient.cjs +276 -276
  78. package/dist/network/HttpClient.d.ts +25 -25
  79. package/dist/network/HttpClient.mjs +276 -276
  80. package/dist/network/ILoopbackClient.d.ts +10 -10
  81. package/dist/network/LoopbackClient.cjs +76 -75
  82. package/dist/network/LoopbackClient.cjs.map +1 -1
  83. package/dist/network/LoopbackClient.d.ts +21 -21
  84. package/dist/network/LoopbackClient.d.ts.map +1 -1
  85. package/dist/network/LoopbackClient.mjs +76 -75
  86. package/dist/network/LoopbackClient.mjs.map +1 -1
  87. package/dist/packageMetadata.cjs +4 -4
  88. package/dist/packageMetadata.d.ts +2 -2
  89. package/dist/packageMetadata.mjs +4 -4
  90. package/dist/request/AuthorizationCodeRequest.d.ts +21 -21
  91. package/dist/request/AuthorizationUrlRequest.d.ts +33 -33
  92. package/dist/request/ClientCredentialRequest.d.ts +14 -14
  93. package/dist/request/DeviceCodeRequest.d.ts +15 -15
  94. package/dist/request/InteractiveRequest.d.ts +22 -22
  95. package/dist/request/OnBehalfOfRequest.d.ts +14 -14
  96. package/dist/request/RefreshTokenRequest.d.ts +17 -17
  97. package/dist/request/SignOutRequest.d.ts +5 -5
  98. package/dist/request/SilentFlowRequest.d.ts +16 -16
  99. package/dist/request/UsernamePasswordRequest.d.ts +19 -19
  100. package/dist/utils/Constants.cjs +80 -80
  101. package/dist/utils/Constants.d.ts +86 -86
  102. package/dist/utils/Constants.mjs +80 -80
  103. package/dist/utils/EncodingUtils.cjs +44 -44
  104. package/dist/utils/EncodingUtils.d.ts +26 -26
  105. package/dist/utils/EncodingUtils.mjs +44 -44
  106. package/dist/utils/NetworkUtils.cjs +38 -38
  107. package/dist/utils/NetworkUtils.d.ts +5 -5
  108. package/dist/utils/NetworkUtils.mjs +38 -38
  109. package/package.json +2 -2
  110. package/src/cache/NodeStorage.ts +8 -2
  111. package/src/client/ClientApplication.ts +3 -1
  112. package/src/index.ts +1 -0
  113. package/src/network/LoopbackClient.ts +1 -0
  114. package/src/packageMetadata.ts +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"ClientApplication.mjs","sources":["../../src/client/ClientApplication.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;;;;;;;;AAKA;AA8BA;AAKA;AACA;;AAgBG;AACH;AACI;AACO,uBAAwB,CAAA;AAE/B;;AAEG;AACH,IAAA,WAAU,CAAA,aAAS,EAAA;AACnB,QAAA,IAAA,CAAA,MAAA,GAAA,qBAAA,CAAA,aAAA,CAAA,CAAA;;AAEG,QAAA,IAAA,CAAA,MAAA,GAAA,IAAA,MAAA,CAAA,IAAA,CAAA,MAAA,CAAA,MAAA,CAAA,aAAA,EAAA,IAAA,EAAA,OAAA,CAAA,CAAA;AACH,QAAA,IAAA,CAAS,OAAO,GAAE,IAAA,WAAO,CAAA,IAAA,CAAA,MAAA,EAAA,IAAA,CAAA,MAAA,CAAA,IAAA,CAAA,QAAA,EAAA,IAAA,CAAA,cAAA,CAAA,CAAA;AACzB,QAAA,IAAA,CAAA,UAAA,GAAA,IAAA,UAAA,CAAA,IAAA,CAAA,OAAA,EAAA,IAAA,CAAA,MAAA,EAAA,IAAA,CAAA,MAAA,CAAA,KAAA,CAAA,WAAA,CAAA,CAAA;;AAEG;AACH;AACA;;AAEG;AACH;AACA;;AAEG;AACH,IAAA,MAAA,cAAU,CAAA,OAAc,EAAM;AAE9B,QAAA,IAAA,CAAA,MAAA,CAAA,IAAA,CAAA,uBAAA,EAAA,OAAA,CAAA,aAAA,CAAA,CAAA;;AAEG,YAAA,GAAA,OAAA;YACM,IAAA,MAAA,IAAa,CAAa,qBAAe,CAAA,OAA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4 @@
1
- /*! @azure/msal-node v2.2.0-alpha.0 2023-09-20 */
1
+ /*! @azure/msal-node v2.3.0 2023-10-20 */
2
2
  'use strict';
3
3
  'use strict';
4
4
 
@@ -7,121 +7,121 @@ var msalCommon = require('@azure/msal-common');
7
7
  var EncodingUtils = require('../utils/EncodingUtils.cjs');
8
8
  var Constants = require('../utils/Constants.cjs');
9
9
 
10
- /*
11
- * Copyright (c) Microsoft Corporation. All rights reserved.
12
- * Licensed under the MIT License.
13
- */
14
- /**
15
- * Client assertion of type jwt-bearer used in confidential client flows
16
- * @public
17
- */
18
- class ClientAssertion {
19
- /**
20
- * Initialize the ClientAssertion class from the clientAssertion passed by the user
21
- * @param assertion - refer https://tools.ietf.org/html/rfc7521
22
- */
23
- static fromAssertion(assertion) {
24
- const clientAssertion = new ClientAssertion();
25
- clientAssertion.jwt = assertion;
26
- return clientAssertion;
27
- }
28
- /**
29
- * Initialize the ClientAssertion class from the certificate passed by the user
30
- * @param thumbprint - identifier of a certificate
31
- * @param privateKey - secret key
32
- * @param publicCertificate - electronic document provided to prove the ownership of the public key
33
- */
34
- static fromCertificate(thumbprint, privateKey, publicCertificate) {
35
- const clientAssertion = new ClientAssertion();
36
- clientAssertion.privateKey = privateKey;
37
- clientAssertion.thumbprint = thumbprint;
38
- if (publicCertificate) {
39
- clientAssertion.publicCertificate =
40
- this.parseCertificate(publicCertificate);
41
- }
42
- return clientAssertion;
43
- }
44
- /**
45
- * Update JWT for certificate based clientAssertion, if passed by the user, uses it as is
46
- * @param cryptoProvider - library's crypto helper
47
- * @param issuer - iss claim
48
- * @param jwtAudience - aud claim
49
- */
50
- getJwt(cryptoProvider, issuer, jwtAudience) {
51
- // if assertion was created from certificate, check if jwt is expired and create new one.
52
- if (this.privateKey && this.thumbprint) {
53
- if (this.jwt &&
54
- !this.isExpired() &&
55
- issuer === this.issuer &&
56
- jwtAudience === this.jwtAudience) {
57
- return this.jwt;
58
- }
59
- return this.createJwt(cryptoProvider, issuer, jwtAudience);
60
- }
61
- /*
62
- * if assertion was created by caller, then we just append it. It is up to the caller to
63
- * ensure that it contains necessary claims and that it is not expired.
64
- */
65
- if (this.jwt) {
66
- return this.jwt;
67
- }
68
- throw msalCommon.createClientAuthError(msalCommon.ClientAuthErrorCodes.invalidAssertion);
69
- }
70
- /**
71
- * JWT format and required claims specified: https://tools.ietf.org/html/rfc7523#section-3
72
- */
73
- createJwt(cryptoProvider, issuer, jwtAudience) {
74
- this.issuer = issuer;
75
- this.jwtAudience = jwtAudience;
76
- const issuedAt = msalCommon.TimeUtils.nowSeconds();
77
- this.expirationTime = issuedAt + 600;
78
- const header = {
79
- alg: Constants.JwtConstants.RSA_256,
80
- x5t: EncodingUtils.EncodingUtils.base64EncodeUrl(this.thumbprint, "hex"),
81
- };
82
- if (this.publicCertificate) {
83
- Object.assign(header, {
84
- x5c: this.publicCertificate,
85
- });
86
- }
87
- const payload = {
88
- [Constants.JwtConstants.AUDIENCE]: this.jwtAudience,
89
- [Constants.JwtConstants.EXPIRATION_TIME]: this.expirationTime,
90
- [Constants.JwtConstants.ISSUER]: this.issuer,
91
- [Constants.JwtConstants.SUBJECT]: this.issuer,
92
- [Constants.JwtConstants.NOT_BEFORE]: issuedAt,
93
- [Constants.JwtConstants.JWT_ID]: cryptoProvider.createNewGuid(),
94
- };
95
- this.jwt = jwt.sign(payload, this.privateKey, { header });
96
- return this.jwt;
97
- }
98
- /**
99
- * Utility API to check expiration
100
- */
101
- isExpired() {
102
- return this.expirationTime < msalCommon.TimeUtils.nowSeconds();
103
- }
104
- /**
105
- * Extracts the raw certs from a given certificate string and returns them in an array.
106
- * @param publicCertificate - electronic document provided to prove the ownership of the public key
107
- */
108
- static parseCertificate(publicCertificate) {
109
- /**
110
- * This is regex to identify the certs in a given certificate string.
111
- * We want to look for the contents between the BEGIN and END certificate strings, without the associated newlines.
112
- * The information in parens "(.+?)" is the capture group to represent the cert we want isolated.
113
- * "." means any string character, "+" means match 1 or more times, and "?" means the shortest match.
114
- * The "g" at the end of the regex means search the string globally, and the "s" enables the "." to match newlines.
115
- */
116
- const regexToFindCerts = /-----BEGIN CERTIFICATE-----\r*\n(.+?)\r*\n-----END CERTIFICATE-----/gs;
117
- const certs = [];
118
- let matches;
119
- while ((matches = regexToFindCerts.exec(publicCertificate)) !== null) {
120
- // matches[1] represents the first parens capture group in the regex.
121
- certs.push(matches[1].replace(/\r*\n/g, msalCommon.Constants.EMPTY_STRING));
122
- }
123
- return certs;
124
- }
10
+ /*
11
+ * Copyright (c) Microsoft Corporation. All rights reserved.
12
+ * Licensed under the MIT License.
13
+ */
14
+ /**
15
+ * Client assertion of type jwt-bearer used in confidential client flows
16
+ * @public
17
+ */
18
+ class ClientAssertion {
19
+ /**
20
+ * Initialize the ClientAssertion class from the clientAssertion passed by the user
21
+ * @param assertion - refer https://tools.ietf.org/html/rfc7521
22
+ */
23
+ static fromAssertion(assertion) {
24
+ const clientAssertion = new ClientAssertion();
25
+ clientAssertion.jwt = assertion;
26
+ return clientAssertion;
27
+ }
28
+ /**
29
+ * Initialize the ClientAssertion class from the certificate passed by the user
30
+ * @param thumbprint - identifier of a certificate
31
+ * @param privateKey - secret key
32
+ * @param publicCertificate - electronic document provided to prove the ownership of the public key
33
+ */
34
+ static fromCertificate(thumbprint, privateKey, publicCertificate) {
35
+ const clientAssertion = new ClientAssertion();
36
+ clientAssertion.privateKey = privateKey;
37
+ clientAssertion.thumbprint = thumbprint;
38
+ if (publicCertificate) {
39
+ clientAssertion.publicCertificate =
40
+ this.parseCertificate(publicCertificate);
41
+ }
42
+ return clientAssertion;
43
+ }
44
+ /**
45
+ * Update JWT for certificate based clientAssertion, if passed by the user, uses it as is
46
+ * @param cryptoProvider - library's crypto helper
47
+ * @param issuer - iss claim
48
+ * @param jwtAudience - aud claim
49
+ */
50
+ getJwt(cryptoProvider, issuer, jwtAudience) {
51
+ // if assertion was created from certificate, check if jwt is expired and create new one.
52
+ if (this.privateKey && this.thumbprint) {
53
+ if (this.jwt &&
54
+ !this.isExpired() &&
55
+ issuer === this.issuer &&
56
+ jwtAudience === this.jwtAudience) {
57
+ return this.jwt;
58
+ }
59
+ return this.createJwt(cryptoProvider, issuer, jwtAudience);
60
+ }
61
+ /*
62
+ * if assertion was created by caller, then we just append it. It is up to the caller to
63
+ * ensure that it contains necessary claims and that it is not expired.
64
+ */
65
+ if (this.jwt) {
66
+ return this.jwt;
67
+ }
68
+ throw msalCommon.createClientAuthError(msalCommon.ClientAuthErrorCodes.invalidAssertion);
69
+ }
70
+ /**
71
+ * JWT format and required claims specified: https://tools.ietf.org/html/rfc7523#section-3
72
+ */
73
+ createJwt(cryptoProvider, issuer, jwtAudience) {
74
+ this.issuer = issuer;
75
+ this.jwtAudience = jwtAudience;
76
+ const issuedAt = msalCommon.TimeUtils.nowSeconds();
77
+ this.expirationTime = issuedAt + 600;
78
+ const header = {
79
+ alg: Constants.JwtConstants.RSA_256,
80
+ x5t: EncodingUtils.EncodingUtils.base64EncodeUrl(this.thumbprint, "hex"),
81
+ };
82
+ if (this.publicCertificate) {
83
+ Object.assign(header, {
84
+ x5c: this.publicCertificate,
85
+ });
86
+ }
87
+ const payload = {
88
+ [Constants.JwtConstants.AUDIENCE]: this.jwtAudience,
89
+ [Constants.JwtConstants.EXPIRATION_TIME]: this.expirationTime,
90
+ [Constants.JwtConstants.ISSUER]: this.issuer,
91
+ [Constants.JwtConstants.SUBJECT]: this.issuer,
92
+ [Constants.JwtConstants.NOT_BEFORE]: issuedAt,
93
+ [Constants.JwtConstants.JWT_ID]: cryptoProvider.createNewGuid(),
94
+ };
95
+ this.jwt = jwt.sign(payload, this.privateKey, { header });
96
+ return this.jwt;
97
+ }
98
+ /**
99
+ * Utility API to check expiration
100
+ */
101
+ isExpired() {
102
+ return this.expirationTime < msalCommon.TimeUtils.nowSeconds();
103
+ }
104
+ /**
105
+ * Extracts the raw certs from a given certificate string and returns them in an array.
106
+ * @param publicCertificate - electronic document provided to prove the ownership of the public key
107
+ */
108
+ static parseCertificate(publicCertificate) {
109
+ /**
110
+ * This is regex to identify the certs in a given certificate string.
111
+ * We want to look for the contents between the BEGIN and END certificate strings, without the associated newlines.
112
+ * The information in parens "(.+?)" is the capture group to represent the cert we want isolated.
113
+ * "." means any string character, "+" means match 1 or more times, and "?" means the shortest match.
114
+ * The "g" at the end of the regex means search the string globally, and the "s" enables the "." to match newlines.
115
+ */
116
+ const regexToFindCerts = /-----BEGIN CERTIFICATE-----\r*\n(.+?)\r*\n-----END CERTIFICATE-----/gs;
117
+ const certs = [];
118
+ let matches;
119
+ while ((matches = regexToFindCerts.exec(publicCertificate)) !== null) {
120
+ // matches[1] represents the first parens capture group in the regex.
121
+ certs.push(matches[1].replace(/\r*\n/g, msalCommon.Constants.EMPTY_STRING));
122
+ }
123
+ return certs;
124
+ }
125
125
  }
126
126
 
127
127
  exports.ClientAssertion = ClientAssertion;
@@ -1,47 +1,47 @@
1
- import { CryptoProvider } from "../crypto/CryptoProvider.js";
2
- /**
3
- * Client assertion of type jwt-bearer used in confidential client flows
4
- * @public
5
- */
6
- export declare class ClientAssertion {
7
- private jwt;
8
- private privateKey;
9
- private thumbprint;
10
- private expirationTime;
11
- private issuer;
12
- private jwtAudience;
13
- private publicCertificate;
14
- /**
15
- * Initialize the ClientAssertion class from the clientAssertion passed by the user
16
- * @param assertion - refer https://tools.ietf.org/html/rfc7521
17
- */
18
- static fromAssertion(assertion: string): ClientAssertion;
19
- /**
20
- * Initialize the ClientAssertion class from the certificate passed by the user
21
- * @param thumbprint - identifier of a certificate
22
- * @param privateKey - secret key
23
- * @param publicCertificate - electronic document provided to prove the ownership of the public key
24
- */
25
- static fromCertificate(thumbprint: string, privateKey: string, publicCertificate?: string): ClientAssertion;
26
- /**
27
- * Update JWT for certificate based clientAssertion, if passed by the user, uses it as is
28
- * @param cryptoProvider - library's crypto helper
29
- * @param issuer - iss claim
30
- * @param jwtAudience - aud claim
31
- */
32
- getJwt(cryptoProvider: CryptoProvider, issuer: string, jwtAudience: string): string;
33
- /**
34
- * JWT format and required claims specified: https://tools.ietf.org/html/rfc7523#section-3
35
- */
36
- private createJwt;
37
- /**
38
- * Utility API to check expiration
39
- */
40
- private isExpired;
41
- /**
42
- * Extracts the raw certs from a given certificate string and returns them in an array.
43
- * @param publicCertificate - electronic document provided to prove the ownership of the public key
44
- */
45
- static parseCertificate(publicCertificate: string): Array<string>;
46
- }
1
+ import { CryptoProvider } from "../crypto/CryptoProvider.js";
2
+ /**
3
+ * Client assertion of type jwt-bearer used in confidential client flows
4
+ * @public
5
+ */
6
+ export declare class ClientAssertion {
7
+ private jwt;
8
+ private privateKey;
9
+ private thumbprint;
10
+ private expirationTime;
11
+ private issuer;
12
+ private jwtAudience;
13
+ private publicCertificate;
14
+ /**
15
+ * Initialize the ClientAssertion class from the clientAssertion passed by the user
16
+ * @param assertion - refer https://tools.ietf.org/html/rfc7521
17
+ */
18
+ static fromAssertion(assertion: string): ClientAssertion;
19
+ /**
20
+ * Initialize the ClientAssertion class from the certificate passed by the user
21
+ * @param thumbprint - identifier of a certificate
22
+ * @param privateKey - secret key
23
+ * @param publicCertificate - electronic document provided to prove the ownership of the public key
24
+ */
25
+ static fromCertificate(thumbprint: string, privateKey: string, publicCertificate?: string): ClientAssertion;
26
+ /**
27
+ * Update JWT for certificate based clientAssertion, if passed by the user, uses it as is
28
+ * @param cryptoProvider - library's crypto helper
29
+ * @param issuer - iss claim
30
+ * @param jwtAudience - aud claim
31
+ */
32
+ getJwt(cryptoProvider: CryptoProvider, issuer: string, jwtAudience: string): string;
33
+ /**
34
+ * JWT format and required claims specified: https://tools.ietf.org/html/rfc7523#section-3
35
+ */
36
+ private createJwt;
37
+ /**
38
+ * Utility API to check expiration
39
+ */
40
+ private isExpired;
41
+ /**
42
+ * Extracts the raw certs from a given certificate string and returns them in an array.
43
+ * @param publicCertificate - electronic document provided to prove the ownership of the public key
44
+ */
45
+ static parseCertificate(publicCertificate: string): Array<string>;
46
+ }
47
47
  //# sourceMappingURL=ClientAssertion.d.ts.map
@@ -1,125 +1,125 @@
1
- /*! @azure/msal-node v2.2.0-alpha.0 2023-09-20 */
1
+ /*! @azure/msal-node v2.3.0 2023-10-20 */
2
2
  'use strict';
3
3
  import jwt from 'jsonwebtoken';
4
4
  import { createClientAuthError, ClientAuthErrorCodes, TimeUtils, Constants } from '@azure/msal-common';
5
5
  import { EncodingUtils } from '../utils/EncodingUtils.mjs';
6
6
  import { JwtConstants } from '../utils/Constants.mjs';
7
7
 
8
- /*
9
- * Copyright (c) Microsoft Corporation. All rights reserved.
10
- * Licensed under the MIT License.
11
- */
12
- /**
13
- * Client assertion of type jwt-bearer used in confidential client flows
14
- * @public
15
- */
16
- class ClientAssertion {
17
- /**
18
- * Initialize the ClientAssertion class from the clientAssertion passed by the user
19
- * @param assertion - refer https://tools.ietf.org/html/rfc7521
20
- */
21
- static fromAssertion(assertion) {
22
- const clientAssertion = new ClientAssertion();
23
- clientAssertion.jwt = assertion;
24
- return clientAssertion;
25
- }
26
- /**
27
- * Initialize the ClientAssertion class from the certificate passed by the user
28
- * @param thumbprint - identifier of a certificate
29
- * @param privateKey - secret key
30
- * @param publicCertificate - electronic document provided to prove the ownership of the public key
31
- */
32
- static fromCertificate(thumbprint, privateKey, publicCertificate) {
33
- const clientAssertion = new ClientAssertion();
34
- clientAssertion.privateKey = privateKey;
35
- clientAssertion.thumbprint = thumbprint;
36
- if (publicCertificate) {
37
- clientAssertion.publicCertificate =
38
- this.parseCertificate(publicCertificate);
39
- }
40
- return clientAssertion;
41
- }
42
- /**
43
- * Update JWT for certificate based clientAssertion, if passed by the user, uses it as is
44
- * @param cryptoProvider - library's crypto helper
45
- * @param issuer - iss claim
46
- * @param jwtAudience - aud claim
47
- */
48
- getJwt(cryptoProvider, issuer, jwtAudience) {
49
- // if assertion was created from certificate, check if jwt is expired and create new one.
50
- if (this.privateKey && this.thumbprint) {
51
- if (this.jwt &&
52
- !this.isExpired() &&
53
- issuer === this.issuer &&
54
- jwtAudience === this.jwtAudience) {
55
- return this.jwt;
56
- }
57
- return this.createJwt(cryptoProvider, issuer, jwtAudience);
58
- }
59
- /*
60
- * if assertion was created by caller, then we just append it. It is up to the caller to
61
- * ensure that it contains necessary claims and that it is not expired.
62
- */
63
- if (this.jwt) {
64
- return this.jwt;
65
- }
66
- throw createClientAuthError(ClientAuthErrorCodes.invalidAssertion);
67
- }
68
- /**
69
- * JWT format and required claims specified: https://tools.ietf.org/html/rfc7523#section-3
70
- */
71
- createJwt(cryptoProvider, issuer, jwtAudience) {
72
- this.issuer = issuer;
73
- this.jwtAudience = jwtAudience;
74
- const issuedAt = TimeUtils.nowSeconds();
75
- this.expirationTime = issuedAt + 600;
76
- const header = {
77
- alg: JwtConstants.RSA_256,
78
- x5t: EncodingUtils.base64EncodeUrl(this.thumbprint, "hex"),
79
- };
80
- if (this.publicCertificate) {
81
- Object.assign(header, {
82
- x5c: this.publicCertificate,
83
- });
84
- }
85
- const payload = {
86
- [JwtConstants.AUDIENCE]: this.jwtAudience,
87
- [JwtConstants.EXPIRATION_TIME]: this.expirationTime,
88
- [JwtConstants.ISSUER]: this.issuer,
89
- [JwtConstants.SUBJECT]: this.issuer,
90
- [JwtConstants.NOT_BEFORE]: issuedAt,
91
- [JwtConstants.JWT_ID]: cryptoProvider.createNewGuid(),
92
- };
93
- this.jwt = jwt.sign(payload, this.privateKey, { header });
94
- return this.jwt;
95
- }
96
- /**
97
- * Utility API to check expiration
98
- */
99
- isExpired() {
100
- return this.expirationTime < TimeUtils.nowSeconds();
101
- }
102
- /**
103
- * Extracts the raw certs from a given certificate string and returns them in an array.
104
- * @param publicCertificate - electronic document provided to prove the ownership of the public key
105
- */
106
- static parseCertificate(publicCertificate) {
107
- /**
108
- * This is regex to identify the certs in a given certificate string.
109
- * We want to look for the contents between the BEGIN and END certificate strings, without the associated newlines.
110
- * The information in parens "(.+?)" is the capture group to represent the cert we want isolated.
111
- * "." means any string character, "+" means match 1 or more times, and "?" means the shortest match.
112
- * The "g" at the end of the regex means search the string globally, and the "s" enables the "." to match newlines.
113
- */
114
- const regexToFindCerts = /-----BEGIN CERTIFICATE-----\r*\n(.+?)\r*\n-----END CERTIFICATE-----/gs;
115
- const certs = [];
116
- let matches;
117
- while ((matches = regexToFindCerts.exec(publicCertificate)) !== null) {
118
- // matches[1] represents the first parens capture group in the regex.
119
- certs.push(matches[1].replace(/\r*\n/g, Constants.EMPTY_STRING));
120
- }
121
- return certs;
122
- }
8
+ /*
9
+ * Copyright (c) Microsoft Corporation. All rights reserved.
10
+ * Licensed under the MIT License.
11
+ */
12
+ /**
13
+ * Client assertion of type jwt-bearer used in confidential client flows
14
+ * @public
15
+ */
16
+ class ClientAssertion {
17
+ /**
18
+ * Initialize the ClientAssertion class from the clientAssertion passed by the user
19
+ * @param assertion - refer https://tools.ietf.org/html/rfc7521
20
+ */
21
+ static fromAssertion(assertion) {
22
+ const clientAssertion = new ClientAssertion();
23
+ clientAssertion.jwt = assertion;
24
+ return clientAssertion;
25
+ }
26
+ /**
27
+ * Initialize the ClientAssertion class from the certificate passed by the user
28
+ * @param thumbprint - identifier of a certificate
29
+ * @param privateKey - secret key
30
+ * @param publicCertificate - electronic document provided to prove the ownership of the public key
31
+ */
32
+ static fromCertificate(thumbprint, privateKey, publicCertificate) {
33
+ const clientAssertion = new ClientAssertion();
34
+ clientAssertion.privateKey = privateKey;
35
+ clientAssertion.thumbprint = thumbprint;
36
+ if (publicCertificate) {
37
+ clientAssertion.publicCertificate =
38
+ this.parseCertificate(publicCertificate);
39
+ }
40
+ return clientAssertion;
41
+ }
42
+ /**
43
+ * Update JWT for certificate based clientAssertion, if passed by the user, uses it as is
44
+ * @param cryptoProvider - library's crypto helper
45
+ * @param issuer - iss claim
46
+ * @param jwtAudience - aud claim
47
+ */
48
+ getJwt(cryptoProvider, issuer, jwtAudience) {
49
+ // if assertion was created from certificate, check if jwt is expired and create new one.
50
+ if (this.privateKey && this.thumbprint) {
51
+ if (this.jwt &&
52
+ !this.isExpired() &&
53
+ issuer === this.issuer &&
54
+ jwtAudience === this.jwtAudience) {
55
+ return this.jwt;
56
+ }
57
+ return this.createJwt(cryptoProvider, issuer, jwtAudience);
58
+ }
59
+ /*
60
+ * if assertion was created by caller, then we just append it. It is up to the caller to
61
+ * ensure that it contains necessary claims and that it is not expired.
62
+ */
63
+ if (this.jwt) {
64
+ return this.jwt;
65
+ }
66
+ throw createClientAuthError(ClientAuthErrorCodes.invalidAssertion);
67
+ }
68
+ /**
69
+ * JWT format and required claims specified: https://tools.ietf.org/html/rfc7523#section-3
70
+ */
71
+ createJwt(cryptoProvider, issuer, jwtAudience) {
72
+ this.issuer = issuer;
73
+ this.jwtAudience = jwtAudience;
74
+ const issuedAt = TimeUtils.nowSeconds();
75
+ this.expirationTime = issuedAt + 600;
76
+ const header = {
77
+ alg: JwtConstants.RSA_256,
78
+ x5t: EncodingUtils.base64EncodeUrl(this.thumbprint, "hex"),
79
+ };
80
+ if (this.publicCertificate) {
81
+ Object.assign(header, {
82
+ x5c: this.publicCertificate,
83
+ });
84
+ }
85
+ const payload = {
86
+ [JwtConstants.AUDIENCE]: this.jwtAudience,
87
+ [JwtConstants.EXPIRATION_TIME]: this.expirationTime,
88
+ [JwtConstants.ISSUER]: this.issuer,
89
+ [JwtConstants.SUBJECT]: this.issuer,
90
+ [JwtConstants.NOT_BEFORE]: issuedAt,
91
+ [JwtConstants.JWT_ID]: cryptoProvider.createNewGuid(),
92
+ };
93
+ this.jwt = jwt.sign(payload, this.privateKey, { header });
94
+ return this.jwt;
95
+ }
96
+ /**
97
+ * Utility API to check expiration
98
+ */
99
+ isExpired() {
100
+ return this.expirationTime < TimeUtils.nowSeconds();
101
+ }
102
+ /**
103
+ * Extracts the raw certs from a given certificate string and returns them in an array.
104
+ * @param publicCertificate - electronic document provided to prove the ownership of the public key
105
+ */
106
+ static parseCertificate(publicCertificate) {
107
+ /**
108
+ * This is regex to identify the certs in a given certificate string.
109
+ * We want to look for the contents between the BEGIN and END certificate strings, without the associated newlines.
110
+ * The information in parens "(.+?)" is the capture group to represent the cert we want isolated.
111
+ * "." means any string character, "+" means match 1 or more times, and "?" means the shortest match.
112
+ * The "g" at the end of the regex means search the string globally, and the "s" enables the "." to match newlines.
113
+ */
114
+ const regexToFindCerts = /-----BEGIN CERTIFICATE-----\r*\n(.+?)\r*\n-----END CERTIFICATE-----/gs;
115
+ const certs = [];
116
+ let matches;
117
+ while ((matches = regexToFindCerts.exec(publicCertificate)) !== null) {
118
+ // matches[1] represents the first parens capture group in the regex.
119
+ certs.push(matches[1].replace(/\r*\n/g, Constants.EMPTY_STRING));
120
+ }
121
+ return certs;
122
+ }
123
123
  }
124
124
 
125
125
  export { ClientAssertion };