@azure/msal-node 2.1.0 → 2.2.0-alpha.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 (134) hide show
  1. package/dist/cache/ITokenCache.d.ts +15 -15
  2. package/dist/cache/NodeStorage.cjs +401 -401
  3. package/dist/cache/NodeStorage.d.ts +182 -182
  4. package/dist/cache/NodeStorage.mjs +401 -401
  5. package/dist/cache/TokenCache.cjs +265 -265
  6. package/dist/cache/TokenCache.d.ts +90 -90
  7. package/dist/cache/TokenCache.mjs +265 -265
  8. package/dist/cache/distributed/DistributedCachePlugin.cjs +26 -26
  9. package/dist/cache/distributed/DistributedCachePlugin.d.ts +10 -10
  10. package/dist/cache/distributed/DistributedCachePlugin.mjs +26 -26
  11. package/dist/cache/distributed/ICacheClient.d.ts +17 -17
  12. package/dist/cache/distributed/IPartitionManager.d.ts +28 -28
  13. package/dist/cache/serializer/Deserializer.cjs +173 -173
  14. package/dist/cache/serializer/Deserializer.d.ts +42 -42
  15. package/dist/cache/serializer/Deserializer.mjs +173 -173
  16. package/dist/cache/serializer/Serializer.cjs +134 -134
  17. package/dist/cache/serializer/Serializer.d.ts +39 -39
  18. package/dist/cache/serializer/Serializer.mjs +134 -134
  19. package/dist/cache/serializer/SerializerTypes.d.ts +101 -101
  20. package/dist/client/ClientApplication.cjs +333 -333
  21. package/dist/client/ClientApplication.cjs.map +1 -1
  22. package/dist/client/ClientApplication.d.ts +142 -142
  23. package/dist/client/ClientApplication.d.ts.map +1 -1
  24. package/dist/client/ClientApplication.mjs +334 -334
  25. package/dist/client/ClientApplication.mjs.map +1 -1
  26. package/dist/client/ClientAssertion.cjs +116 -116
  27. package/dist/client/ClientAssertion.cjs.map +1 -1
  28. package/dist/client/ClientAssertion.d.ts +46 -46
  29. package/dist/client/ClientAssertion.d.ts.map +1 -1
  30. package/dist/client/ClientAssertion.mjs +117 -117
  31. package/dist/client/ClientAssertion.mjs.map +1 -1
  32. package/dist/client/ClientCredentialClient.cjs +189 -190
  33. package/dist/client/ClientCredentialClient.cjs.map +1 -1
  34. package/dist/client/ClientCredentialClient.d.ts +33 -34
  35. package/dist/client/ClientCredentialClient.d.ts.map +1 -1
  36. package/dist/client/ClientCredentialClient.mjs +190 -191
  37. package/dist/client/ClientCredentialClient.mjs.map +1 -1
  38. package/dist/client/ConfidentialClientApplication.cjs +163 -163
  39. package/dist/client/ConfidentialClientApplication.cjs.map +1 -1
  40. package/dist/client/ConfidentialClientApplication.d.ts +58 -58
  41. package/dist/client/ConfidentialClientApplication.d.ts.map +1 -1
  42. package/dist/client/ConfidentialClientApplication.mjs +164 -164
  43. package/dist/client/ConfidentialClientApplication.mjs.map +1 -1
  44. package/dist/client/DeviceCodeClient.cjs +207 -207
  45. package/dist/client/DeviceCodeClient.cjs.map +1 -1
  46. package/dist/client/DeviceCodeClient.d.ts +53 -53
  47. package/dist/client/DeviceCodeClient.d.ts.map +1 -1
  48. package/dist/client/DeviceCodeClient.mjs +208 -208
  49. package/dist/client/DeviceCodeClient.mjs.map +1 -1
  50. package/dist/client/IConfidentialClientApplication.d.ts +39 -39
  51. package/dist/client/IPublicClientApplication.d.ts +42 -42
  52. package/dist/client/OnBehalfOfClient.cjs +202 -202
  53. package/dist/client/OnBehalfOfClient.cjs.map +1 -1
  54. package/dist/client/OnBehalfOfClient.d.ts +47 -47
  55. package/dist/client/OnBehalfOfClient.d.ts.map +1 -1
  56. package/dist/client/OnBehalfOfClient.mjs +203 -203
  57. package/dist/client/OnBehalfOfClient.mjs.map +1 -1
  58. package/dist/client/PublicClientApplication.cjs +229 -182
  59. package/dist/client/PublicClientApplication.cjs.map +1 -1
  60. package/dist/client/PublicClientApplication.d.ts +71 -65
  61. package/dist/client/PublicClientApplication.d.ts.map +1 -1
  62. package/dist/client/PublicClientApplication.mjs +231 -184
  63. package/dist/client/PublicClientApplication.mjs.map +1 -1
  64. package/dist/client/UsernamePasswordClient.cjs +95 -95
  65. package/dist/client/UsernamePasswordClient.d.ts +25 -25
  66. package/dist/client/UsernamePasswordClient.mjs +95 -95
  67. package/dist/config/Configuration.cjs +72 -72
  68. package/dist/config/Configuration.d.ts +107 -107
  69. package/dist/config/Configuration.mjs +72 -72
  70. package/dist/crypto/CryptoProvider.cjs +75 -75
  71. package/dist/crypto/CryptoProvider.d.ts +52 -52
  72. package/dist/crypto/CryptoProvider.mjs +75 -75
  73. package/dist/crypto/GuidGenerator.cjs +22 -22
  74. package/dist/crypto/GuidGenerator.d.ts +14 -14
  75. package/dist/crypto/GuidGenerator.mjs +22 -22
  76. package/dist/crypto/HashUtils.cjs +13 -13
  77. package/dist/crypto/HashUtils.d.ts +8 -8
  78. package/dist/crypto/HashUtils.mjs +13 -13
  79. package/dist/crypto/PkceGenerator.cjs +49 -49
  80. package/dist/crypto/PkceGenerator.d.ts +22 -22
  81. package/dist/crypto/PkceGenerator.mjs +49 -49
  82. package/dist/error/NodeAuthError.cjs +85 -85
  83. package/dist/error/NodeAuthError.d.ts +65 -65
  84. package/dist/error/NodeAuthError.mjs +85 -85
  85. package/dist/index.cjs +17 -1
  86. package/dist/index.cjs.map +1 -1
  87. package/dist/index.d.ts +42 -42
  88. package/dist/index.d.ts.map +1 -1
  89. package/dist/index.mjs +2 -2
  90. package/dist/internals.cjs +8 -8
  91. package/dist/internals.d.ts +6 -6
  92. package/dist/internals.mjs +8 -8
  93. package/dist/network/HttpClient.cjs +276 -276
  94. package/dist/network/HttpClient.d.ts +25 -25
  95. package/dist/network/HttpClient.mjs +276 -276
  96. package/dist/network/ILoopbackClient.d.ts +10 -10
  97. package/dist/network/LoopbackClient.cjs +75 -84
  98. package/dist/network/LoopbackClient.cjs.map +1 -1
  99. package/dist/network/LoopbackClient.d.ts +21 -21
  100. package/dist/network/LoopbackClient.d.ts.map +1 -1
  101. package/dist/network/LoopbackClient.mjs +76 -85
  102. package/dist/network/LoopbackClient.mjs.map +1 -1
  103. package/dist/packageMetadata.cjs +3 -3
  104. package/dist/packageMetadata.d.ts +2 -2
  105. package/dist/packageMetadata.mjs +3 -3
  106. package/dist/request/AuthorizationCodeRequest.d.ts +21 -21
  107. package/dist/request/AuthorizationUrlRequest.d.ts +33 -33
  108. package/dist/request/ClientCredentialRequest.d.ts +14 -14
  109. package/dist/request/DeviceCodeRequest.d.ts +15 -15
  110. package/dist/request/InteractiveRequest.d.ts +22 -22
  111. package/dist/request/OnBehalfOfRequest.d.ts +14 -14
  112. package/dist/request/RefreshTokenRequest.d.ts +17 -17
  113. package/dist/request/SignOutRequest.d.ts +5 -5
  114. package/dist/request/SilentFlowRequest.d.ts +16 -16
  115. package/dist/request/UsernamePasswordRequest.d.ts +19 -19
  116. package/dist/utils/Constants.cjs +80 -80
  117. package/dist/utils/Constants.d.ts +86 -86
  118. package/dist/utils/Constants.mjs +80 -80
  119. package/dist/utils/EncodingUtils.cjs +44 -44
  120. package/dist/utils/EncodingUtils.d.ts +26 -26
  121. package/dist/utils/EncodingUtils.mjs +44 -44
  122. package/dist/utils/NetworkUtils.cjs +38 -38
  123. package/dist/utils/NetworkUtils.d.ts +5 -5
  124. package/dist/utils/NetworkUtils.mjs +38 -38
  125. package/package.json +2 -2
  126. package/src/client/ClientApplication.ts +3 -2
  127. package/src/client/ClientAssertion.ts +7 -2
  128. package/src/client/ClientCredentialClient.ts +32 -34
  129. package/src/client/ConfidentialClientApplication.ts +11 -4
  130. package/src/client/DeviceCodeClient.ts +16 -7
  131. package/src/client/OnBehalfOfClient.ts +11 -4
  132. package/src/client/PublicClientApplication.ts +69 -13
  133. package/src/index.ts +4 -0
  134. package/src/network/LoopbackClient.ts +17 -33
@@ -1 +1 @@
1
- {"version":3,"file":"ClientApplication.mjs","sources":["../../src/client/ClientApplication.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;;;;;;;;AAKA;AA6BA;AAKA;AACA;;AAgBG;AACH;AACI;AACO,uBAAwB,CAAA;AAE/B;;AAEG;AACH,IAAA,WAAU,CAAA,aAAS,EAAA;AACnB,QAAA,IAAA,CAA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,YAAA,CAAA,aAAA,EAAA,YAAA,CAAA,YAAA,CAAA,CAAA;AACH,QAAA,IAAA;AAeA,YAAA,MAAA,sBAAA,GAAA,MAAA,IAAA,CAAA,6BAAA,CAAA,YAAA,CAAA,SAAA,EAAA,YAAA,CAAA,aAAA,EAAA,sBAAA,EAAA,SAAA,EAAA,OAAA,CAAA,iBAAA,CAAA,CAAA;;;;AAIG,SAAA;eAC0B,CAAA,EAAA;AAiC7B,YAAA,IAAA,CAAA,YAAA,SAAA,EAAA;;AAEG,aAAA;AACH,YAAA,sBAAkB,CAAA,kBAAA,CAAA,CAAA,CAAA,CAAA;AAGrB,YAAA,MAAA,CAAA,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -1,4 +1,4 @@
1
- /*! @azure/msal-node v2.1.0 2023-09-05 */
1
+ /*! @azure/msal-node v2.2.0-alpha.0 2023-09-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.ClientAuthError.createInvalidAssertionError();
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 +1 @@
1
- {"version":3,"file":"ClientAssertion.cjs","sources":["../../src/client/ClientAssertion.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;;;;;AAOA;AAIA;;;;;;;AAWW,sBAAkB;AAEzB;;;AAGG;AACW,IAAA,OAAA,aAAa,CAAC,SAAS,EAAE;AAMvC,QAAA,MAAA,eAAA,GAAA,IAAA,eAAA,EAAA,CAAA;;;;;AAKG;AACW;AAed;;;;;AAKG,QAAA,eAAA,CAAA,UAAA,GAAA,UAAA,CAAA;AACI,QAAA,eACH,CAAA,UAAgB,GAAA,UAChB,CAAA;AA4BJ,QAAA,IAAA,iBAAA,EAAA;;AAEG,gBAAA,IAAA,CAAA,gBAAA,CAAA,iBAAA,CAAA,CAAA;AACH,SAAA;AAkCA,QAAA,OAAA,eAAA,CAAA;;AAEG;AACH;AAIA;;;AAGG;WACW,cAAgB,EAAA,mBAAoB,EAAA;AAoBrD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"ClientAssertion.cjs","sources":["../../src/client/ClientAssertion.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;;;;;AAYA;AAIA;;;;;;;AAWW,sBAAkB;AAEzB;;;AAGG;AACW,IAAA,OAAA,aAAa,CAAC,SAAS,EAAE;AAMvC,QAAA,MAAA,eAAA,GAAA,IAAA,eAAA,EAAA,CAAA;;;;;AAKG;AACW;AAed;;;;;AAKG,QAAA,eAAA,CAAA,UAAA,GAAA,UAAA,CAAA;AACI,QAAA,eACH,CAAA,UAAgB,GAAA,UAChB,CAAA;AA4BJ,QAAA,IAAA,iBAAA,EAAA;;AAEG,gBAAA,IAAA,CAAA,gBAAA,CAAA,iBAAA,CAAA,CAAA;AACH,SAAA;AAkCA,QAAA,OAAA,eAAA,CAAA;;AAEG;AACH;AAIA;;;AAGG;WACW,cAAgB,EAAA,mBAAoB,EAAA;AAoBrD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -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 +1 @@
1
- {"version":3,"file":"ClientAssertion.d.ts","sourceRoot":"","sources":["../../src/client/ClientAssertion.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAI7D;;;GAGG;AACH,qBAAa,eAAe;IACxB,OAAO,CAAC,GAAG,CAAS;IACpB,OAAO,CAAC,UAAU,CAAS;IAC3B,OAAO,CAAC,UAAU,CAAS;IAC3B,OAAO,CAAC,cAAc,CAAS;IAC/B,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,WAAW,CAAS;IAC5B,OAAO,CAAC,iBAAiB,CAAgB;IAEzC;;;OAGG;WACW,aAAa,CAAC,SAAS,EAAE,MAAM,GAAG,eAAe;IAM/D;;;;;OAKG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C;CAoB3E"}
@@ -1,125 +1,125 @@
1
- /*! @azure/msal-node v2.1.0 2023-09-05 */
1
+ /*! @azure/msal-node v2.2.0-alpha.0 2023-09-20 */
2
2
  'use strict';
3
3
  import jwt from 'jsonwebtoken';
4
- import { ClientAuthError, TimeUtils, Constants } from '@azure/msal-common';
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 ClientAuthError.createInvalidAssertionError();
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 };
@@ -1 +1 @@
1
- {"version":3,"file":"ClientAssertion.mjs","sources":["../../src/client/ClientAssertion.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;;;AAOA;AAIA;;;;;;;AAWW,sBAAkB;AAEzB;;;AAGG;AACW,IAAA,OAAA,aAAa,CAAC,SAAS,EAAE;AAMvC,QAAA,MAAA,eAAA,GAAA,IAAA,eAAA,EAAA,CAAA;;;;;AAKG;AACW;AAed;;;;;AAKG,QAAA,eAAA,CAAA,UAAA,GAAA,UAAA,CAAA;AACI,QAAA,eACH,CAAA,UAAgB,GAAA,UAChB,CAAA;AA4BJ,QAAA,IAAA,iBAAA,EAAA;;AAEG,gBAAA,IAAA,CAAA,gBAAA,CAAA,iBAAA,CAAA,CAAA;AACH,SAAA;AAkCA,QAAA,OAAA,eAAA,CAAA;;AAEG;AACH;AAIA;;;AAGG;WACW,cAAgB,EAAA,mBAAoB,EAAA;AAoBrD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"ClientAssertion.mjs","sources":["../../src/client/ClientAssertion.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;;;AAYA;AAIA;;;;;;;AAWW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