@azure/msal-node 2.2.0-alpha.0 → 2.2.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 (106) 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.d.ts +142 -142
  22. package/dist/client/ClientApplication.mjs +333 -333
  23. package/dist/client/ClientAssertion.cjs +116 -116
  24. package/dist/client/ClientAssertion.d.ts +46 -46
  25. package/dist/client/ClientAssertion.mjs +116 -116
  26. package/dist/client/ClientCredentialClient.cjs +189 -189
  27. package/dist/client/ClientCredentialClient.d.ts +33 -33
  28. package/dist/client/ClientCredentialClient.mjs +189 -189
  29. package/dist/client/ConfidentialClientApplication.cjs +163 -163
  30. package/dist/client/ConfidentialClientApplication.d.ts +58 -58
  31. package/dist/client/ConfidentialClientApplication.mjs +163 -163
  32. package/dist/client/DeviceCodeClient.cjs +207 -207
  33. package/dist/client/DeviceCodeClient.d.ts +53 -53
  34. package/dist/client/DeviceCodeClient.mjs +207 -207
  35. package/dist/client/IConfidentialClientApplication.d.ts +39 -39
  36. package/dist/client/IPublicClientApplication.d.ts +42 -42
  37. package/dist/client/OnBehalfOfClient.cjs +202 -202
  38. package/dist/client/OnBehalfOfClient.d.ts +47 -47
  39. package/dist/client/OnBehalfOfClient.mjs +202 -202
  40. package/dist/client/PublicClientApplication.cjs +229 -229
  41. package/dist/client/PublicClientApplication.d.ts +71 -71
  42. package/dist/client/PublicClientApplication.mjs +229 -229
  43. package/dist/client/UsernamePasswordClient.cjs +95 -95
  44. package/dist/client/UsernamePasswordClient.d.ts +25 -25
  45. package/dist/client/UsernamePasswordClient.mjs +95 -95
  46. package/dist/config/Configuration.cjs +72 -72
  47. package/dist/config/Configuration.d.ts +107 -107
  48. package/dist/config/Configuration.mjs +72 -72
  49. package/dist/crypto/CryptoProvider.cjs +75 -75
  50. package/dist/crypto/CryptoProvider.d.ts +52 -52
  51. package/dist/crypto/CryptoProvider.mjs +75 -75
  52. package/dist/crypto/GuidGenerator.cjs +22 -22
  53. package/dist/crypto/GuidGenerator.d.ts +14 -14
  54. package/dist/crypto/GuidGenerator.mjs +22 -22
  55. package/dist/crypto/HashUtils.cjs +13 -13
  56. package/dist/crypto/HashUtils.d.ts +8 -8
  57. package/dist/crypto/HashUtils.mjs +13 -13
  58. package/dist/crypto/PkceGenerator.cjs +49 -49
  59. package/dist/crypto/PkceGenerator.d.ts +22 -22
  60. package/dist/crypto/PkceGenerator.mjs +49 -49
  61. package/dist/error/NodeAuthError.cjs +85 -85
  62. package/dist/error/NodeAuthError.d.ts +65 -65
  63. package/dist/error/NodeAuthError.mjs +85 -85
  64. package/dist/index.cjs +1 -1
  65. package/dist/index.d.ts +42 -42
  66. package/dist/index.d.ts.map +1 -1
  67. package/dist/index.mjs +1 -1
  68. package/dist/internals.cjs +8 -8
  69. package/dist/internals.d.ts +6 -6
  70. package/dist/internals.mjs +8 -8
  71. package/dist/network/HttpClient.cjs +276 -276
  72. package/dist/network/HttpClient.d.ts +25 -25
  73. package/dist/network/HttpClient.mjs +276 -276
  74. package/dist/network/ILoopbackClient.d.ts +10 -10
  75. package/dist/network/LoopbackClient.cjs +76 -75
  76. package/dist/network/LoopbackClient.cjs.map +1 -1
  77. package/dist/network/LoopbackClient.d.ts +21 -21
  78. package/dist/network/LoopbackClient.d.ts.map +1 -1
  79. package/dist/network/LoopbackClient.mjs +76 -75
  80. package/dist/network/LoopbackClient.mjs.map +1 -1
  81. package/dist/packageMetadata.cjs +4 -4
  82. package/dist/packageMetadata.d.ts +2 -2
  83. package/dist/packageMetadata.mjs +4 -4
  84. package/dist/request/AuthorizationCodeRequest.d.ts +21 -21
  85. package/dist/request/AuthorizationUrlRequest.d.ts +33 -33
  86. package/dist/request/ClientCredentialRequest.d.ts +14 -14
  87. package/dist/request/DeviceCodeRequest.d.ts +15 -15
  88. package/dist/request/InteractiveRequest.d.ts +22 -22
  89. package/dist/request/OnBehalfOfRequest.d.ts +14 -14
  90. package/dist/request/RefreshTokenRequest.d.ts +17 -17
  91. package/dist/request/SignOutRequest.d.ts +5 -5
  92. package/dist/request/SilentFlowRequest.d.ts +16 -16
  93. package/dist/request/UsernamePasswordRequest.d.ts +19 -19
  94. package/dist/utils/Constants.cjs +80 -80
  95. package/dist/utils/Constants.d.ts +86 -86
  96. package/dist/utils/Constants.mjs +80 -80
  97. package/dist/utils/EncodingUtils.cjs +44 -44
  98. package/dist/utils/EncodingUtils.d.ts +26 -26
  99. package/dist/utils/EncodingUtils.mjs +44 -44
  100. package/dist/utils/NetworkUtils.cjs +38 -38
  101. package/dist/utils/NetworkUtils.d.ts +5 -5
  102. package/dist/utils/NetworkUtils.mjs +38 -38
  103. package/package.json +2 -2
  104. package/src/index.ts +1 -0
  105. package/src/network/LoopbackClient.ts +1 -0
  106. package/src/packageMetadata.ts +1 -1
@@ -1,103 +1,103 @@
1
- /*! @azure/msal-node v2.2.0-alpha.0 2023-09-20 */
1
+ /*! @azure/msal-node v2.2.0 2023-10-05 */
2
2
  'use strict';
3
3
  'use strict';
4
4
 
5
5
  var msalCommon = require('@azure/msal-common');
6
6
 
7
- /*
8
- * Copyright (c) Microsoft Corporation. All rights reserved.
9
- * Licensed under the MIT License.
10
- */
11
- /**
12
- * Oauth2.0 Password grant client
13
- * Note: We are only supporting public clients for password grant and for purely testing purposes
14
- */
15
- class UsernamePasswordClient extends msalCommon.BaseClient {
16
- constructor(configuration) {
17
- super(configuration);
18
- }
19
- /**
20
- * API to acquire a token by passing the username and password to the service in exchage of credentials
21
- * password_grant
22
- * @param request
23
- */
24
- async acquireToken(request) {
25
- this.logger.info("in acquireToken call in username-password client");
26
- const reqTimestamp = msalCommon.TimeUtils.nowSeconds();
27
- const response = await this.executeTokenRequest(this.authority, request);
28
- const responseHandler = new msalCommon.ResponseHandler(this.config.authOptions.clientId, this.cacheManager, this.cryptoUtils, this.logger, this.config.serializableCache, this.config.persistencePlugin);
29
- // Validate response. This function throws a server error if an error is returned by the server.
30
- responseHandler.validateTokenResponse(response.body);
31
- const tokenResponse = responseHandler.handleServerTokenResponse(response.body, this.authority, reqTimestamp, request);
32
- return tokenResponse;
33
- }
34
- /**
35
- * Executes POST request to token endpoint
36
- * @param authority
37
- * @param request
38
- */
39
- async executeTokenRequest(authority, request) {
40
- const queryParametersString = this.createTokenQueryParameters(request);
41
- const endpoint = msalCommon.UrlString.appendQueryString(authority.tokenEndpoint, queryParametersString);
42
- const requestBody = this.createTokenRequestBody(request);
43
- const headers = this.createTokenRequestHeaders({
44
- credential: request.username,
45
- type: msalCommon.CcsCredentialType.UPN,
46
- });
47
- const thumbprint = {
48
- clientId: this.config.authOptions.clientId,
49
- authority: authority.canonicalAuthority,
50
- scopes: request.scopes,
51
- claims: request.claims,
52
- authenticationScheme: request.authenticationScheme,
53
- resourceRequestMethod: request.resourceRequestMethod,
54
- resourceRequestUri: request.resourceRequestUri,
55
- shrClaims: request.shrClaims,
56
- sshKid: request.sshKid,
57
- };
58
- return this.executePostToTokenEndpoint(endpoint, requestBody, headers, thumbprint, request.correlationId);
59
- }
60
- /**
61
- * Generates a map for all the params to be sent to the service
62
- * @param request
63
- */
64
- createTokenRequestBody(request) {
65
- const parameterBuilder = new msalCommon.RequestParameterBuilder();
66
- parameterBuilder.addClientId(this.config.authOptions.clientId);
67
- parameterBuilder.addUsername(request.username);
68
- parameterBuilder.addPassword(request.password);
69
- parameterBuilder.addScopes(request.scopes);
70
- parameterBuilder.addResponseTypeForTokenAndIdToken();
71
- parameterBuilder.addGrantType(msalCommon.GrantType.RESOURCE_OWNER_PASSWORD_GRANT);
72
- parameterBuilder.addClientInfo();
73
- parameterBuilder.addLibraryInfo(this.config.libraryInfo);
74
- parameterBuilder.addApplicationTelemetry(this.config.telemetry.application);
75
- parameterBuilder.addThrottling();
76
- if (this.serverTelemetryManager) {
77
- parameterBuilder.addServerTelemetry(this.serverTelemetryManager);
78
- }
79
- const correlationId = request.correlationId ||
80
- this.config.cryptoInterface.createNewGuid();
81
- parameterBuilder.addCorrelationId(correlationId);
82
- if (this.config.clientCredentials.clientSecret) {
83
- parameterBuilder.addClientSecret(this.config.clientCredentials.clientSecret);
84
- }
85
- if (this.config.clientCredentials.clientAssertion) {
86
- const clientAssertion = this.config.clientCredentials.clientAssertion;
87
- parameterBuilder.addClientAssertion(clientAssertion.assertion);
88
- parameterBuilder.addClientAssertionType(clientAssertion.assertionType);
89
- }
90
- if (!msalCommon.StringUtils.isEmptyObj(request.claims) ||
91
- (this.config.authOptions.clientCapabilities &&
92
- this.config.authOptions.clientCapabilities.length > 0)) {
93
- parameterBuilder.addClaims(request.claims, this.config.authOptions.clientCapabilities);
94
- }
95
- if (this.config.systemOptions.preventCorsPreflight &&
96
- request.username) {
97
- parameterBuilder.addCcsUpn(request.username);
98
- }
99
- return parameterBuilder.createQueryString();
100
- }
7
+ /*
8
+ * Copyright (c) Microsoft Corporation. All rights reserved.
9
+ * Licensed under the MIT License.
10
+ */
11
+ /**
12
+ * Oauth2.0 Password grant client
13
+ * Note: We are only supporting public clients for password grant and for purely testing purposes
14
+ */
15
+ class UsernamePasswordClient extends msalCommon.BaseClient {
16
+ constructor(configuration) {
17
+ super(configuration);
18
+ }
19
+ /**
20
+ * API to acquire a token by passing the username and password to the service in exchage of credentials
21
+ * password_grant
22
+ * @param request
23
+ */
24
+ async acquireToken(request) {
25
+ this.logger.info("in acquireToken call in username-password client");
26
+ const reqTimestamp = msalCommon.TimeUtils.nowSeconds();
27
+ const response = await this.executeTokenRequest(this.authority, request);
28
+ const responseHandler = new msalCommon.ResponseHandler(this.config.authOptions.clientId, this.cacheManager, this.cryptoUtils, this.logger, this.config.serializableCache, this.config.persistencePlugin);
29
+ // Validate response. This function throws a server error if an error is returned by the server.
30
+ responseHandler.validateTokenResponse(response.body);
31
+ const tokenResponse = responseHandler.handleServerTokenResponse(response.body, this.authority, reqTimestamp, request);
32
+ return tokenResponse;
33
+ }
34
+ /**
35
+ * Executes POST request to token endpoint
36
+ * @param authority
37
+ * @param request
38
+ */
39
+ async executeTokenRequest(authority, request) {
40
+ const queryParametersString = this.createTokenQueryParameters(request);
41
+ const endpoint = msalCommon.UrlString.appendQueryString(authority.tokenEndpoint, queryParametersString);
42
+ const requestBody = this.createTokenRequestBody(request);
43
+ const headers = this.createTokenRequestHeaders({
44
+ credential: request.username,
45
+ type: msalCommon.CcsCredentialType.UPN,
46
+ });
47
+ const thumbprint = {
48
+ clientId: this.config.authOptions.clientId,
49
+ authority: authority.canonicalAuthority,
50
+ scopes: request.scopes,
51
+ claims: request.claims,
52
+ authenticationScheme: request.authenticationScheme,
53
+ resourceRequestMethod: request.resourceRequestMethod,
54
+ resourceRequestUri: request.resourceRequestUri,
55
+ shrClaims: request.shrClaims,
56
+ sshKid: request.sshKid,
57
+ };
58
+ return this.executePostToTokenEndpoint(endpoint, requestBody, headers, thumbprint, request.correlationId);
59
+ }
60
+ /**
61
+ * Generates a map for all the params to be sent to the service
62
+ * @param request
63
+ */
64
+ createTokenRequestBody(request) {
65
+ const parameterBuilder = new msalCommon.RequestParameterBuilder();
66
+ parameterBuilder.addClientId(this.config.authOptions.clientId);
67
+ parameterBuilder.addUsername(request.username);
68
+ parameterBuilder.addPassword(request.password);
69
+ parameterBuilder.addScopes(request.scopes);
70
+ parameterBuilder.addResponseTypeForTokenAndIdToken();
71
+ parameterBuilder.addGrantType(msalCommon.GrantType.RESOURCE_OWNER_PASSWORD_GRANT);
72
+ parameterBuilder.addClientInfo();
73
+ parameterBuilder.addLibraryInfo(this.config.libraryInfo);
74
+ parameterBuilder.addApplicationTelemetry(this.config.telemetry.application);
75
+ parameterBuilder.addThrottling();
76
+ if (this.serverTelemetryManager) {
77
+ parameterBuilder.addServerTelemetry(this.serverTelemetryManager);
78
+ }
79
+ const correlationId = request.correlationId ||
80
+ this.config.cryptoInterface.createNewGuid();
81
+ parameterBuilder.addCorrelationId(correlationId);
82
+ if (this.config.clientCredentials.clientSecret) {
83
+ parameterBuilder.addClientSecret(this.config.clientCredentials.clientSecret);
84
+ }
85
+ if (this.config.clientCredentials.clientAssertion) {
86
+ const clientAssertion = this.config.clientCredentials.clientAssertion;
87
+ parameterBuilder.addClientAssertion(clientAssertion.assertion);
88
+ parameterBuilder.addClientAssertionType(clientAssertion.assertionType);
89
+ }
90
+ if (!msalCommon.StringUtils.isEmptyObj(request.claims) ||
91
+ (this.config.authOptions.clientCapabilities &&
92
+ this.config.authOptions.clientCapabilities.length > 0)) {
93
+ parameterBuilder.addClaims(request.claims, this.config.authOptions.clientCapabilities);
94
+ }
95
+ if (this.config.systemOptions.preventCorsPreflight &&
96
+ request.username) {
97
+ parameterBuilder.addCcsUpn(request.username);
98
+ }
99
+ return parameterBuilder.createQueryString();
100
+ }
101
101
  }
102
102
 
103
103
  exports.UsernamePasswordClient = UsernamePasswordClient;
@@ -1,26 +1,26 @@
1
- import { AuthenticationResult, BaseClient, ClientConfiguration, CommonUsernamePasswordRequest } from "@azure/msal-common";
2
- /**
3
- * Oauth2.0 Password grant client
4
- * Note: We are only supporting public clients for password grant and for purely testing purposes
5
- */
6
- export declare class UsernamePasswordClient extends BaseClient {
7
- constructor(configuration: ClientConfiguration);
8
- /**
9
- * API to acquire a token by passing the username and password to the service in exchage of credentials
10
- * password_grant
11
- * @param request
12
- */
13
- acquireToken(request: CommonUsernamePasswordRequest): Promise<AuthenticationResult | null>;
14
- /**
15
- * Executes POST request to token endpoint
16
- * @param authority
17
- * @param request
18
- */
19
- private executeTokenRequest;
20
- /**
21
- * Generates a map for all the params to be sent to the service
22
- * @param request
23
- */
24
- private createTokenRequestBody;
25
- }
1
+ import { AuthenticationResult, BaseClient, ClientConfiguration, CommonUsernamePasswordRequest } from "@azure/msal-common";
2
+ /**
3
+ * Oauth2.0 Password grant client
4
+ * Note: We are only supporting public clients for password grant and for purely testing purposes
5
+ */
6
+ export declare class UsernamePasswordClient extends BaseClient {
7
+ constructor(configuration: ClientConfiguration);
8
+ /**
9
+ * API to acquire a token by passing the username and password to the service in exchage of credentials
10
+ * password_grant
11
+ * @param request
12
+ */
13
+ acquireToken(request: CommonUsernamePasswordRequest): Promise<AuthenticationResult | null>;
14
+ /**
15
+ * Executes POST request to token endpoint
16
+ * @param authority
17
+ * @param request
18
+ */
19
+ private executeTokenRequest;
20
+ /**
21
+ * Generates a map for all the params to be sent to the service
22
+ * @param request
23
+ */
24
+ private createTokenRequestBody;
25
+ }
26
26
  //# sourceMappingURL=UsernamePasswordClient.d.ts.map
@@ -1,101 +1,101 @@
1
- /*! @azure/msal-node v2.2.0-alpha.0 2023-09-20 */
1
+ /*! @azure/msal-node v2.2.0 2023-10-05 */
2
2
  'use strict';
3
3
  import { BaseClient, TimeUtils, ResponseHandler, UrlString, CcsCredentialType, RequestParameterBuilder, GrantType, StringUtils } from '@azure/msal-common';
4
4
 
5
- /*
6
- * Copyright (c) Microsoft Corporation. All rights reserved.
7
- * Licensed under the MIT License.
8
- */
9
- /**
10
- * Oauth2.0 Password grant client
11
- * Note: We are only supporting public clients for password grant and for purely testing purposes
12
- */
13
- class UsernamePasswordClient extends BaseClient {
14
- constructor(configuration) {
15
- super(configuration);
16
- }
17
- /**
18
- * API to acquire a token by passing the username and password to the service in exchage of credentials
19
- * password_grant
20
- * @param request
21
- */
22
- async acquireToken(request) {
23
- this.logger.info("in acquireToken call in username-password client");
24
- const reqTimestamp = TimeUtils.nowSeconds();
25
- const response = await this.executeTokenRequest(this.authority, request);
26
- const responseHandler = new ResponseHandler(this.config.authOptions.clientId, this.cacheManager, this.cryptoUtils, this.logger, this.config.serializableCache, this.config.persistencePlugin);
27
- // Validate response. This function throws a server error if an error is returned by the server.
28
- responseHandler.validateTokenResponse(response.body);
29
- const tokenResponse = responseHandler.handleServerTokenResponse(response.body, this.authority, reqTimestamp, request);
30
- return tokenResponse;
31
- }
32
- /**
33
- * Executes POST request to token endpoint
34
- * @param authority
35
- * @param request
36
- */
37
- async executeTokenRequest(authority, request) {
38
- const queryParametersString = this.createTokenQueryParameters(request);
39
- const endpoint = UrlString.appendQueryString(authority.tokenEndpoint, queryParametersString);
40
- const requestBody = this.createTokenRequestBody(request);
41
- const headers = this.createTokenRequestHeaders({
42
- credential: request.username,
43
- type: CcsCredentialType.UPN,
44
- });
45
- const thumbprint = {
46
- clientId: this.config.authOptions.clientId,
47
- authority: authority.canonicalAuthority,
48
- scopes: request.scopes,
49
- claims: request.claims,
50
- authenticationScheme: request.authenticationScheme,
51
- resourceRequestMethod: request.resourceRequestMethod,
52
- resourceRequestUri: request.resourceRequestUri,
53
- shrClaims: request.shrClaims,
54
- sshKid: request.sshKid,
55
- };
56
- return this.executePostToTokenEndpoint(endpoint, requestBody, headers, thumbprint, request.correlationId);
57
- }
58
- /**
59
- * Generates a map for all the params to be sent to the service
60
- * @param request
61
- */
62
- createTokenRequestBody(request) {
63
- const parameterBuilder = new RequestParameterBuilder();
64
- parameterBuilder.addClientId(this.config.authOptions.clientId);
65
- parameterBuilder.addUsername(request.username);
66
- parameterBuilder.addPassword(request.password);
67
- parameterBuilder.addScopes(request.scopes);
68
- parameterBuilder.addResponseTypeForTokenAndIdToken();
69
- parameterBuilder.addGrantType(GrantType.RESOURCE_OWNER_PASSWORD_GRANT);
70
- parameterBuilder.addClientInfo();
71
- parameterBuilder.addLibraryInfo(this.config.libraryInfo);
72
- parameterBuilder.addApplicationTelemetry(this.config.telemetry.application);
73
- parameterBuilder.addThrottling();
74
- if (this.serverTelemetryManager) {
75
- parameterBuilder.addServerTelemetry(this.serverTelemetryManager);
76
- }
77
- const correlationId = request.correlationId ||
78
- this.config.cryptoInterface.createNewGuid();
79
- parameterBuilder.addCorrelationId(correlationId);
80
- if (this.config.clientCredentials.clientSecret) {
81
- parameterBuilder.addClientSecret(this.config.clientCredentials.clientSecret);
82
- }
83
- if (this.config.clientCredentials.clientAssertion) {
84
- const clientAssertion = this.config.clientCredentials.clientAssertion;
85
- parameterBuilder.addClientAssertion(clientAssertion.assertion);
86
- parameterBuilder.addClientAssertionType(clientAssertion.assertionType);
87
- }
88
- if (!StringUtils.isEmptyObj(request.claims) ||
89
- (this.config.authOptions.clientCapabilities &&
90
- this.config.authOptions.clientCapabilities.length > 0)) {
91
- parameterBuilder.addClaims(request.claims, this.config.authOptions.clientCapabilities);
92
- }
93
- if (this.config.systemOptions.preventCorsPreflight &&
94
- request.username) {
95
- parameterBuilder.addCcsUpn(request.username);
96
- }
97
- return parameterBuilder.createQueryString();
98
- }
5
+ /*
6
+ * Copyright (c) Microsoft Corporation. All rights reserved.
7
+ * Licensed under the MIT License.
8
+ */
9
+ /**
10
+ * Oauth2.0 Password grant client
11
+ * Note: We are only supporting public clients for password grant and for purely testing purposes
12
+ */
13
+ class UsernamePasswordClient extends BaseClient {
14
+ constructor(configuration) {
15
+ super(configuration);
16
+ }
17
+ /**
18
+ * API to acquire a token by passing the username and password to the service in exchage of credentials
19
+ * password_grant
20
+ * @param request
21
+ */
22
+ async acquireToken(request) {
23
+ this.logger.info("in acquireToken call in username-password client");
24
+ const reqTimestamp = TimeUtils.nowSeconds();
25
+ const response = await this.executeTokenRequest(this.authority, request);
26
+ const responseHandler = new ResponseHandler(this.config.authOptions.clientId, this.cacheManager, this.cryptoUtils, this.logger, this.config.serializableCache, this.config.persistencePlugin);
27
+ // Validate response. This function throws a server error if an error is returned by the server.
28
+ responseHandler.validateTokenResponse(response.body);
29
+ const tokenResponse = responseHandler.handleServerTokenResponse(response.body, this.authority, reqTimestamp, request);
30
+ return tokenResponse;
31
+ }
32
+ /**
33
+ * Executes POST request to token endpoint
34
+ * @param authority
35
+ * @param request
36
+ */
37
+ async executeTokenRequest(authority, request) {
38
+ const queryParametersString = this.createTokenQueryParameters(request);
39
+ const endpoint = UrlString.appendQueryString(authority.tokenEndpoint, queryParametersString);
40
+ const requestBody = this.createTokenRequestBody(request);
41
+ const headers = this.createTokenRequestHeaders({
42
+ credential: request.username,
43
+ type: CcsCredentialType.UPN,
44
+ });
45
+ const thumbprint = {
46
+ clientId: this.config.authOptions.clientId,
47
+ authority: authority.canonicalAuthority,
48
+ scopes: request.scopes,
49
+ claims: request.claims,
50
+ authenticationScheme: request.authenticationScheme,
51
+ resourceRequestMethod: request.resourceRequestMethod,
52
+ resourceRequestUri: request.resourceRequestUri,
53
+ shrClaims: request.shrClaims,
54
+ sshKid: request.sshKid,
55
+ };
56
+ return this.executePostToTokenEndpoint(endpoint, requestBody, headers, thumbprint, request.correlationId);
57
+ }
58
+ /**
59
+ * Generates a map for all the params to be sent to the service
60
+ * @param request
61
+ */
62
+ createTokenRequestBody(request) {
63
+ const parameterBuilder = new RequestParameterBuilder();
64
+ parameterBuilder.addClientId(this.config.authOptions.clientId);
65
+ parameterBuilder.addUsername(request.username);
66
+ parameterBuilder.addPassword(request.password);
67
+ parameterBuilder.addScopes(request.scopes);
68
+ parameterBuilder.addResponseTypeForTokenAndIdToken();
69
+ parameterBuilder.addGrantType(GrantType.RESOURCE_OWNER_PASSWORD_GRANT);
70
+ parameterBuilder.addClientInfo();
71
+ parameterBuilder.addLibraryInfo(this.config.libraryInfo);
72
+ parameterBuilder.addApplicationTelemetry(this.config.telemetry.application);
73
+ parameterBuilder.addThrottling();
74
+ if (this.serverTelemetryManager) {
75
+ parameterBuilder.addServerTelemetry(this.serverTelemetryManager);
76
+ }
77
+ const correlationId = request.correlationId ||
78
+ this.config.cryptoInterface.createNewGuid();
79
+ parameterBuilder.addCorrelationId(correlationId);
80
+ if (this.config.clientCredentials.clientSecret) {
81
+ parameterBuilder.addClientSecret(this.config.clientCredentials.clientSecret);
82
+ }
83
+ if (this.config.clientCredentials.clientAssertion) {
84
+ const clientAssertion = this.config.clientCredentials.clientAssertion;
85
+ parameterBuilder.addClientAssertion(clientAssertion.assertion);
86
+ parameterBuilder.addClientAssertionType(clientAssertion.assertionType);
87
+ }
88
+ if (!StringUtils.isEmptyObj(request.claims) ||
89
+ (this.config.authOptions.clientCapabilities &&
90
+ this.config.authOptions.clientCapabilities.length > 0)) {
91
+ parameterBuilder.addClaims(request.claims, this.config.authOptions.clientCapabilities);
92
+ }
93
+ if (this.config.systemOptions.preventCorsPreflight &&
94
+ request.username) {
95
+ parameterBuilder.addCcsUpn(request.username);
96
+ }
97
+ return parameterBuilder.createQueryString();
98
+ }
99
99
  }
100
100
 
101
101
  export { UsernamePasswordClient };
@@ -1,81 +1,81 @@
1
- /*! @azure/msal-node v2.2.0-alpha.0 2023-09-20 */
1
+ /*! @azure/msal-node v2.2.0 2023-10-05 */
2
2
  'use strict';
3
3
  'use strict';
4
4
 
5
5
  var msalCommon = require('@azure/msal-common');
6
6
  var HttpClient = require('../network/HttpClient.cjs');
7
7
 
8
- /*
9
- * Copyright (c) Microsoft Corporation. All rights reserved.
10
- * Licensed under the MIT License.
11
- */
12
- const DEFAULT_AUTH_OPTIONS = {
13
- clientId: msalCommon.Constants.EMPTY_STRING,
14
- authority: msalCommon.Constants.DEFAULT_AUTHORITY,
15
- clientSecret: msalCommon.Constants.EMPTY_STRING,
16
- clientAssertion: msalCommon.Constants.EMPTY_STRING,
17
- clientCertificate: {
18
- thumbprint: msalCommon.Constants.EMPTY_STRING,
19
- privateKey: msalCommon.Constants.EMPTY_STRING,
20
- x5c: msalCommon.Constants.EMPTY_STRING,
21
- },
22
- knownAuthorities: [],
23
- cloudDiscoveryMetadata: msalCommon.Constants.EMPTY_STRING,
24
- authorityMetadata: msalCommon.Constants.EMPTY_STRING,
25
- clientCapabilities: [],
26
- protocolMode: msalCommon.ProtocolMode.AAD,
27
- azureCloudOptions: {
28
- azureCloudInstance: msalCommon.AzureCloudInstance.None,
29
- tenant: msalCommon.Constants.EMPTY_STRING,
30
- },
31
- skipAuthorityMetadataCache: false,
32
- };
33
- const DEFAULT_CACHE_OPTIONS = {
34
- claimsBasedCachingEnabled: false,
35
- };
36
- const DEFAULT_LOGGER_OPTIONS = {
37
- loggerCallback: () => {
38
- // allow users to not set logger call back
39
- },
40
- piiLoggingEnabled: false,
41
- logLevel: msalCommon.LogLevel.Info,
42
- };
43
- const DEFAULT_SYSTEM_OPTIONS = {
44
- loggerOptions: DEFAULT_LOGGER_OPTIONS,
45
- networkClient: new HttpClient.HttpClient(),
46
- proxyUrl: msalCommon.Constants.EMPTY_STRING,
47
- customAgentOptions: {},
48
- };
49
- const DEFAULT_TELEMETRY_OPTIONS = {
50
- application: {
51
- appName: msalCommon.Constants.EMPTY_STRING,
52
- appVersion: msalCommon.Constants.EMPTY_STRING,
53
- },
54
- };
55
- /**
56
- * Sets the default options when not explicitly configured from app developer
57
- *
58
- * @param auth - Authentication options
59
- * @param cache - Cache options
60
- * @param system - System options
61
- * @param telemetry - Telemetry options
62
- *
63
- * @returns Configuration
64
- * @internal
65
- */
66
- function buildAppConfiguration({ auth, broker, cache, system, telemetry, }) {
67
- const systemOptions = {
68
- ...DEFAULT_SYSTEM_OPTIONS,
69
- networkClient: new HttpClient.HttpClient(system?.proxyUrl, system?.customAgentOptions),
70
- loggerOptions: system?.loggerOptions || DEFAULT_LOGGER_OPTIONS,
71
- };
72
- return {
73
- auth: { ...DEFAULT_AUTH_OPTIONS, ...auth },
74
- broker: { ...broker },
75
- cache: { ...DEFAULT_CACHE_OPTIONS, ...cache },
76
- system: { ...systemOptions, ...system },
77
- telemetry: { ...DEFAULT_TELEMETRY_OPTIONS, ...telemetry },
78
- };
8
+ /*
9
+ * Copyright (c) Microsoft Corporation. All rights reserved.
10
+ * Licensed under the MIT License.
11
+ */
12
+ const DEFAULT_AUTH_OPTIONS = {
13
+ clientId: msalCommon.Constants.EMPTY_STRING,
14
+ authority: msalCommon.Constants.DEFAULT_AUTHORITY,
15
+ clientSecret: msalCommon.Constants.EMPTY_STRING,
16
+ clientAssertion: msalCommon.Constants.EMPTY_STRING,
17
+ clientCertificate: {
18
+ thumbprint: msalCommon.Constants.EMPTY_STRING,
19
+ privateKey: msalCommon.Constants.EMPTY_STRING,
20
+ x5c: msalCommon.Constants.EMPTY_STRING,
21
+ },
22
+ knownAuthorities: [],
23
+ cloudDiscoveryMetadata: msalCommon.Constants.EMPTY_STRING,
24
+ authorityMetadata: msalCommon.Constants.EMPTY_STRING,
25
+ clientCapabilities: [],
26
+ protocolMode: msalCommon.ProtocolMode.AAD,
27
+ azureCloudOptions: {
28
+ azureCloudInstance: msalCommon.AzureCloudInstance.None,
29
+ tenant: msalCommon.Constants.EMPTY_STRING,
30
+ },
31
+ skipAuthorityMetadataCache: false,
32
+ };
33
+ const DEFAULT_CACHE_OPTIONS = {
34
+ claimsBasedCachingEnabled: false,
35
+ };
36
+ const DEFAULT_LOGGER_OPTIONS = {
37
+ loggerCallback: () => {
38
+ // allow users to not set logger call back
39
+ },
40
+ piiLoggingEnabled: false,
41
+ logLevel: msalCommon.LogLevel.Info,
42
+ };
43
+ const DEFAULT_SYSTEM_OPTIONS = {
44
+ loggerOptions: DEFAULT_LOGGER_OPTIONS,
45
+ networkClient: new HttpClient.HttpClient(),
46
+ proxyUrl: msalCommon.Constants.EMPTY_STRING,
47
+ customAgentOptions: {},
48
+ };
49
+ const DEFAULT_TELEMETRY_OPTIONS = {
50
+ application: {
51
+ appName: msalCommon.Constants.EMPTY_STRING,
52
+ appVersion: msalCommon.Constants.EMPTY_STRING,
53
+ },
54
+ };
55
+ /**
56
+ * Sets the default options when not explicitly configured from app developer
57
+ *
58
+ * @param auth - Authentication options
59
+ * @param cache - Cache options
60
+ * @param system - System options
61
+ * @param telemetry - Telemetry options
62
+ *
63
+ * @returns Configuration
64
+ * @internal
65
+ */
66
+ function buildAppConfiguration({ auth, broker, cache, system, telemetry, }) {
67
+ const systemOptions = {
68
+ ...DEFAULT_SYSTEM_OPTIONS,
69
+ networkClient: new HttpClient.HttpClient(system?.proxyUrl, system?.customAgentOptions),
70
+ loggerOptions: system?.loggerOptions || DEFAULT_LOGGER_OPTIONS,
71
+ };
72
+ return {
73
+ auth: { ...DEFAULT_AUTH_OPTIONS, ...auth },
74
+ broker: { ...broker },
75
+ cache: { ...DEFAULT_CACHE_OPTIONS, ...cache },
76
+ system: { ...systemOptions, ...system },
77
+ telemetry: { ...DEFAULT_TELEMETRY_OPTIONS, ...telemetry },
78
+ };
79
79
  }
80
80
 
81
81
  exports.buildAppConfiguration = buildAppConfiguration;