@azure/msal-node 2.0.0-alpha.1 → 2.0.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -21
- package/README.md +182 -182
- package/dist/cache/ITokenCache.d.ts +15 -15
- package/dist/cache/NodeStorage.d.ts +182 -182
- package/dist/cache/NodeStorage.esm.js +401 -401
- package/dist/cache/NodeStorage.js +401 -401
- package/dist/cache/TokenCache.d.ts +90 -90
- package/dist/cache/TokenCache.esm.js +269 -269
- package/dist/cache/TokenCache.js +269 -269
- package/dist/cache/distributed/DistributedCachePlugin.d.ts +10 -10
- package/dist/cache/distributed/DistributedCachePlugin.esm.js +26 -26
- package/dist/cache/distributed/DistributedCachePlugin.js +26 -26
- package/dist/cache/distributed/ICacheClient.d.ts +17 -17
- package/dist/cache/distributed/IPartitionManager.d.ts +28 -28
- package/dist/cache/serializer/Deserializer.d.ts +42 -42
- package/dist/cache/serializer/Deserializer.esm.js +175 -175
- package/dist/cache/serializer/Deserializer.js +175 -175
- package/dist/cache/serializer/Serializer.d.ts +39 -39
- package/dist/cache/serializer/Serializer.esm.js +134 -134
- package/dist/cache/serializer/Serializer.js +134 -134
- package/dist/cache/serializer/SerializerTypes.d.ts +101 -101
- package/dist/client/ClientApplication.d.ts +142 -142
- package/dist/client/ClientApplication.esm.js +327 -327
- package/dist/client/ClientApplication.js +327 -327
- package/dist/client/ClientAssertion.d.ts +46 -46
- package/dist/client/ClientAssertion.esm.js +116 -116
- package/dist/client/ClientAssertion.js +116 -116
- package/dist/client/ClientCredentialClient.d.ts +33 -33
- package/dist/client/ClientCredentialClient.esm.js +157 -157
- package/dist/client/ClientCredentialClient.js +157 -157
- package/dist/client/ConfidentialClientApplication.d.ts +58 -58
- package/dist/client/ConfidentialClientApplication.esm.js +163 -163
- package/dist/client/ConfidentialClientApplication.js +163 -163
- package/dist/client/DeviceCodeClient.d.ts +53 -53
- package/dist/client/DeviceCodeClient.esm.js +207 -207
- package/dist/client/DeviceCodeClient.js +207 -207
- package/dist/client/IConfidentialClientApplication.d.ts +39 -39
- package/dist/client/IPublicClientApplication.d.ts +42 -42
- package/dist/client/OnBehalfOfClient.d.ts +47 -47
- package/dist/client/OnBehalfOfClient.esm.js +204 -204
- package/dist/client/OnBehalfOfClient.js +204 -204
- package/dist/client/PublicClientApplication.d.ts +65 -65
- package/dist/client/PublicClientApplication.esm.js +175 -175
- package/dist/client/PublicClientApplication.js +175 -175
- package/dist/client/UsernamePasswordClient.d.ts +25 -25
- package/dist/client/UsernamePasswordClient.esm.js +102 -102
- package/dist/client/UsernamePasswordClient.js +102 -102
- package/dist/config/Configuration.d.ts +105 -105
- package/dist/config/Configuration.esm.js +70 -70
- package/dist/config/Configuration.js +70 -70
- package/dist/crypto/CryptoProvider.d.ts +52 -52
- package/dist/crypto/CryptoProvider.esm.js +75 -75
- package/dist/crypto/CryptoProvider.js +75 -75
- package/dist/crypto/GuidGenerator.d.ts +14 -14
- package/dist/crypto/GuidGenerator.esm.js +22 -22
- package/dist/crypto/GuidGenerator.js +22 -22
- package/dist/crypto/HashUtils.d.ts +8 -8
- package/dist/crypto/HashUtils.esm.js +13 -13
- package/dist/crypto/HashUtils.js +13 -13
- package/dist/crypto/PkceGenerator.d.ts +22 -22
- package/dist/crypto/PkceGenerator.esm.js +49 -49
- package/dist/crypto/PkceGenerator.js +49 -49
- package/dist/error/NodeAuthError.d.ts +65 -65
- package/dist/error/NodeAuthError.esm.js +85 -85
- package/dist/error/NodeAuthError.js +85 -85
- package/dist/index.d.ts +41 -41
- package/dist/index.esm.js +1 -1
- package/dist/index.js +1 -1
- package/dist/internals.d.ts +6 -6
- package/dist/internals.esm.js +4 -4
- package/dist/internals.js +4 -4
- package/dist/network/HttpClient.d.ts +25 -25
- package/dist/network/HttpClient.esm.js +276 -276
- package/dist/network/HttpClient.js +276 -276
- package/dist/network/ILoopbackClient.d.ts +10 -10
- package/dist/network/LoopbackClient.d.ts +21 -21
- package/dist/network/LoopbackClient.esm.js +84 -84
- package/dist/network/LoopbackClient.js +84 -84
- package/dist/packageMetadata.d.ts +2 -2
- package/dist/packageMetadata.d.ts.map +1 -1
- package/dist/packageMetadata.esm.js +4 -4
- package/dist/packageMetadata.js +4 -4
- package/dist/request/AuthorizationCodeRequest.d.ts +21 -21
- package/dist/request/AuthorizationUrlRequest.d.ts +33 -33
- package/dist/request/ClientCredentialRequest.d.ts +14 -15
- package/dist/request/ClientCredentialRequest.d.ts.map +1 -1
- package/dist/request/DeviceCodeRequest.d.ts +15 -15
- package/dist/request/InteractiveRequest.d.ts +22 -22
- package/dist/request/OnBehalfOfRequest.d.ts +14 -14
- package/dist/request/RefreshTokenRequest.d.ts +17 -17
- package/dist/request/SignOutRequest.d.ts +5 -5
- package/dist/request/SilentFlowRequest.d.ts +16 -16
- package/dist/request/UsernamePasswordRequest.d.ts +19 -19
- package/dist/utils/Constants.d.ts +96 -92
- package/dist/utils/Constants.d.ts.map +1 -1
- package/dist/utils/Constants.esm.js +89 -93
- package/dist/utils/Constants.esm.js.map +1 -1
- package/dist/utils/Constants.js +93 -93
- package/dist/utils/Constants.js.map +1 -1
- package/dist/utils/EncodingUtils.d.ts +26 -26
- package/dist/utils/EncodingUtils.esm.js +44 -44
- package/dist/utils/EncodingUtils.js +44 -44
- package/dist/utils/NetworkUtils.d.ts +5 -5
- package/dist/utils/NetworkUtils.esm.js +38 -38
- package/dist/utils/NetworkUtils.js +38 -38
- package/package.json +77 -73
- package/dist/msal-node.cjs.development.js +0 -2705
- package/dist/msal-node.cjs.development.js.map +0 -1
- package/dist/msal-node.cjs.production.min.js +0 -2
- package/dist/msal-node.cjs.production.min.js.map +0 -1
- package/dist/msal-node.esm.js +0 -2594
- package/dist/msal-node.esm.js.map +0 -1
|
@@ -1,110 +1,110 @@
|
|
|
1
|
-
/*! @azure/msal-node v2.0.0-
|
|
1
|
+
/*! @azure/msal-node v2.0.0-beta.0 2023-06-19 */
|
|
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
|
-
const atsMeasurement = this.performanceClient?.startMeasurement(
|
|
26
|
-
// @ts-ignore
|
|
27
|
-
"UsernamePasswordClientAcquireToken", request.correlationId);
|
|
28
|
-
this.logger.info("in acquireToken call in username-password client");
|
|
29
|
-
const reqTimestamp = msalCommon.TimeUtils.nowSeconds();
|
|
30
|
-
const response = await this.executeTokenRequest(this.authority, request);
|
|
31
|
-
const httpVerToken = response.headers?.[msalCommon.HeaderNames.X_MS_HTTP_VERSION];
|
|
32
|
-
atsMeasurement?.addStaticFields({
|
|
33
|
-
httpVerToken,
|
|
34
|
-
});
|
|
35
|
-
const responseHandler = new msalCommon.ResponseHandler(this.config.authOptions.clientId, this.cacheManager, this.cryptoUtils, this.logger, this.config.serializableCache, this.config.persistencePlugin);
|
|
36
|
-
// Validate response. This function throws a server error if an error is returned by the server.
|
|
37
|
-
responseHandler.validateTokenResponse(response.body);
|
|
38
|
-
const tokenResponse = responseHandler.handleServerTokenResponse(response.body, this.authority, reqTimestamp, request);
|
|
39
|
-
return tokenResponse;
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
* Executes POST request to token endpoint
|
|
43
|
-
* @param authority
|
|
44
|
-
* @param request
|
|
45
|
-
*/
|
|
46
|
-
async executeTokenRequest(authority, request) {
|
|
47
|
-
const queryParametersString = this.createTokenQueryParameters(request);
|
|
48
|
-
const endpoint = msalCommon.UrlString.appendQueryString(authority.tokenEndpoint, queryParametersString);
|
|
49
|
-
const requestBody = this.createTokenRequestBody(request);
|
|
50
|
-
const headers = this.createTokenRequestHeaders({
|
|
51
|
-
credential: request.username,
|
|
52
|
-
type: msalCommon.CcsCredentialType.UPN,
|
|
53
|
-
});
|
|
54
|
-
const thumbprint = {
|
|
55
|
-
clientId: this.config.authOptions.clientId,
|
|
56
|
-
authority: authority.canonicalAuthority,
|
|
57
|
-
scopes: request.scopes,
|
|
58
|
-
claims: request.claims,
|
|
59
|
-
authenticationScheme: request.authenticationScheme,
|
|
60
|
-
resourceRequestMethod: request.resourceRequestMethod,
|
|
61
|
-
resourceRequestUri: request.resourceRequestUri,
|
|
62
|
-
shrClaims: request.shrClaims,
|
|
63
|
-
sshKid: request.sshKid,
|
|
64
|
-
};
|
|
65
|
-
return this.executePostToTokenEndpoint(endpoint, requestBody, headers, thumbprint);
|
|
66
|
-
}
|
|
67
|
-
/**
|
|
68
|
-
* Generates a map for all the params to be sent to the service
|
|
69
|
-
* @param request
|
|
70
|
-
*/
|
|
71
|
-
createTokenRequestBody(request) {
|
|
72
|
-
const parameterBuilder = new msalCommon.RequestParameterBuilder();
|
|
73
|
-
parameterBuilder.addClientId(this.config.authOptions.clientId);
|
|
74
|
-
parameterBuilder.addUsername(request.username);
|
|
75
|
-
parameterBuilder.addPassword(request.password);
|
|
76
|
-
parameterBuilder.addScopes(request.scopes);
|
|
77
|
-
parameterBuilder.addResponseTypeForTokenAndIdToken();
|
|
78
|
-
parameterBuilder.addGrantType(msalCommon.GrantType.RESOURCE_OWNER_PASSWORD_GRANT);
|
|
79
|
-
parameterBuilder.addClientInfo();
|
|
80
|
-
parameterBuilder.addLibraryInfo(this.config.libraryInfo);
|
|
81
|
-
parameterBuilder.addApplicationTelemetry(this.config.telemetry.application);
|
|
82
|
-
parameterBuilder.addThrottling();
|
|
83
|
-
if (this.serverTelemetryManager) {
|
|
84
|
-
parameterBuilder.addServerTelemetry(this.serverTelemetryManager);
|
|
85
|
-
}
|
|
86
|
-
const correlationId = request.correlationId ||
|
|
87
|
-
this.config.cryptoInterface.createNewGuid();
|
|
88
|
-
parameterBuilder.addCorrelationId(correlationId);
|
|
89
|
-
if (this.config.clientCredentials.clientSecret) {
|
|
90
|
-
parameterBuilder.addClientSecret(this.config.clientCredentials.clientSecret);
|
|
91
|
-
}
|
|
92
|
-
if (this.config.clientCredentials.clientAssertion) {
|
|
93
|
-
const clientAssertion = this.config.clientCredentials.clientAssertion;
|
|
94
|
-
parameterBuilder.addClientAssertion(clientAssertion.assertion);
|
|
95
|
-
parameterBuilder.addClientAssertionType(clientAssertion.assertionType);
|
|
96
|
-
}
|
|
97
|
-
if (!msalCommon.StringUtils.isEmptyObj(request.claims) ||
|
|
98
|
-
(this.config.authOptions.clientCapabilities &&
|
|
99
|
-
this.config.authOptions.clientCapabilities.length > 0)) {
|
|
100
|
-
parameterBuilder.addClaims(request.claims, this.config.authOptions.clientCapabilities);
|
|
101
|
-
}
|
|
102
|
-
if (this.config.systemOptions.preventCorsPreflight &&
|
|
103
|
-
request.username) {
|
|
104
|
-
parameterBuilder.addCcsUpn(request.username);
|
|
105
|
-
}
|
|
106
|
-
return parameterBuilder.createQueryString();
|
|
107
|
-
}
|
|
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
|
+
const atsMeasurement = this.performanceClient?.startMeasurement(
|
|
26
|
+
// @ts-ignore
|
|
27
|
+
"UsernamePasswordClientAcquireToken", request.correlationId);
|
|
28
|
+
this.logger.info("in acquireToken call in username-password client");
|
|
29
|
+
const reqTimestamp = msalCommon.TimeUtils.nowSeconds();
|
|
30
|
+
const response = await this.executeTokenRequest(this.authority, request);
|
|
31
|
+
const httpVerToken = response.headers?.[msalCommon.HeaderNames.X_MS_HTTP_VERSION];
|
|
32
|
+
atsMeasurement?.addStaticFields({
|
|
33
|
+
httpVerToken,
|
|
34
|
+
});
|
|
35
|
+
const responseHandler = new msalCommon.ResponseHandler(this.config.authOptions.clientId, this.cacheManager, this.cryptoUtils, this.logger, this.config.serializableCache, this.config.persistencePlugin);
|
|
36
|
+
// Validate response. This function throws a server error if an error is returned by the server.
|
|
37
|
+
responseHandler.validateTokenResponse(response.body);
|
|
38
|
+
const tokenResponse = responseHandler.handleServerTokenResponse(response.body, this.authority, reqTimestamp, request);
|
|
39
|
+
return tokenResponse;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Executes POST request to token endpoint
|
|
43
|
+
* @param authority
|
|
44
|
+
* @param request
|
|
45
|
+
*/
|
|
46
|
+
async executeTokenRequest(authority, request) {
|
|
47
|
+
const queryParametersString = this.createTokenQueryParameters(request);
|
|
48
|
+
const endpoint = msalCommon.UrlString.appendQueryString(authority.tokenEndpoint, queryParametersString);
|
|
49
|
+
const requestBody = this.createTokenRequestBody(request);
|
|
50
|
+
const headers = this.createTokenRequestHeaders({
|
|
51
|
+
credential: request.username,
|
|
52
|
+
type: msalCommon.CcsCredentialType.UPN,
|
|
53
|
+
});
|
|
54
|
+
const thumbprint = {
|
|
55
|
+
clientId: this.config.authOptions.clientId,
|
|
56
|
+
authority: authority.canonicalAuthority,
|
|
57
|
+
scopes: request.scopes,
|
|
58
|
+
claims: request.claims,
|
|
59
|
+
authenticationScheme: request.authenticationScheme,
|
|
60
|
+
resourceRequestMethod: request.resourceRequestMethod,
|
|
61
|
+
resourceRequestUri: request.resourceRequestUri,
|
|
62
|
+
shrClaims: request.shrClaims,
|
|
63
|
+
sshKid: request.sshKid,
|
|
64
|
+
};
|
|
65
|
+
return this.executePostToTokenEndpoint(endpoint, requestBody, headers, thumbprint);
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Generates a map for all the params to be sent to the service
|
|
69
|
+
* @param request
|
|
70
|
+
*/
|
|
71
|
+
createTokenRequestBody(request) {
|
|
72
|
+
const parameterBuilder = new msalCommon.RequestParameterBuilder();
|
|
73
|
+
parameterBuilder.addClientId(this.config.authOptions.clientId);
|
|
74
|
+
parameterBuilder.addUsername(request.username);
|
|
75
|
+
parameterBuilder.addPassword(request.password);
|
|
76
|
+
parameterBuilder.addScopes(request.scopes);
|
|
77
|
+
parameterBuilder.addResponseTypeForTokenAndIdToken();
|
|
78
|
+
parameterBuilder.addGrantType(msalCommon.GrantType.RESOURCE_OWNER_PASSWORD_GRANT);
|
|
79
|
+
parameterBuilder.addClientInfo();
|
|
80
|
+
parameterBuilder.addLibraryInfo(this.config.libraryInfo);
|
|
81
|
+
parameterBuilder.addApplicationTelemetry(this.config.telemetry.application);
|
|
82
|
+
parameterBuilder.addThrottling();
|
|
83
|
+
if (this.serverTelemetryManager) {
|
|
84
|
+
parameterBuilder.addServerTelemetry(this.serverTelemetryManager);
|
|
85
|
+
}
|
|
86
|
+
const correlationId = request.correlationId ||
|
|
87
|
+
this.config.cryptoInterface.createNewGuid();
|
|
88
|
+
parameterBuilder.addCorrelationId(correlationId);
|
|
89
|
+
if (this.config.clientCredentials.clientSecret) {
|
|
90
|
+
parameterBuilder.addClientSecret(this.config.clientCredentials.clientSecret);
|
|
91
|
+
}
|
|
92
|
+
if (this.config.clientCredentials.clientAssertion) {
|
|
93
|
+
const clientAssertion = this.config.clientCredentials.clientAssertion;
|
|
94
|
+
parameterBuilder.addClientAssertion(clientAssertion.assertion);
|
|
95
|
+
parameterBuilder.addClientAssertionType(clientAssertion.assertionType);
|
|
96
|
+
}
|
|
97
|
+
if (!msalCommon.StringUtils.isEmptyObj(request.claims) ||
|
|
98
|
+
(this.config.authOptions.clientCapabilities &&
|
|
99
|
+
this.config.authOptions.clientCapabilities.length > 0)) {
|
|
100
|
+
parameterBuilder.addClaims(request.claims, this.config.authOptions.clientCapabilities);
|
|
101
|
+
}
|
|
102
|
+
if (this.config.systemOptions.preventCorsPreflight &&
|
|
103
|
+
request.username) {
|
|
104
|
+
parameterBuilder.addCcsUpn(request.username);
|
|
105
|
+
}
|
|
106
|
+
return parameterBuilder.createQueryString();
|
|
107
|
+
}
|
|
108
108
|
}
|
|
109
109
|
|
|
110
110
|
exports.UsernamePasswordClient = UsernamePasswordClient;
|
|
@@ -1,106 +1,106 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
/// <reference types="node" />
|
|
3
|
-
import { LoggerOptions, INetworkModule, ProtocolMode, ICachePlugin, AzureCloudOptions, ApplicationTelemetry, INativeBrokerPlugin } from "@azure/msal-common";
|
|
4
|
-
import { AgentOptions as httpAgentOptions } from "http";
|
|
5
|
-
import { AgentOptions as httpsAgentOptions } from "https";
|
|
6
|
-
/**
|
|
7
|
-
* - clientId - Client id of the application.
|
|
8
|
-
* - authority - Url of the authority. If no value is set, defaults to https://login.microsoftonline.com/common.
|
|
9
|
-
* - knownAuthorities - Needed for Azure B2C and ADFS. All authorities that will be used in the client application. Only the host of the authority should be passed in.
|
|
10
|
-
* - clientSecret - Secret string that the application uses when requesting a token. Only used in confidential client applications. Can be created in the Azure app registration portal.
|
|
11
|
-
* - clientAssertion - Assertion string that the application uses when requesting a token. Only used in confidential client applications. Assertion should be of type urn:ietf:params:oauth:client-assertion-type:jwt-bearer.
|
|
12
|
-
* - clientCertificate - Certificate that the application uses when requesting a token. Only used in confidential client applications. Requires hex encoded X.509 SHA-1 thumbprint of the certificiate, and the PEM encoded private key (string should contain -----BEGIN PRIVATE KEY----- ... -----END PRIVATE KEY----- )
|
|
13
|
-
* - protocolMode - Enum that represents the protocol that msal follows. Used for configuring proper endpoints.
|
|
14
|
-
* - skipAuthorityMetadataCache - A flag to choose whether to use or not use the local metadata cache during authority initialization. Defaults to false.
|
|
15
|
-
* @public
|
|
16
|
-
*/
|
|
17
|
-
export type NodeAuthOptions = {
|
|
18
|
-
clientId: string;
|
|
19
|
-
authority?: string;
|
|
20
|
-
clientSecret?: string;
|
|
21
|
-
clientAssertion?: string;
|
|
22
|
-
clientCertificate?: {
|
|
23
|
-
thumbprint: string;
|
|
24
|
-
privateKey: string;
|
|
25
|
-
x5c?: string;
|
|
26
|
-
};
|
|
27
|
-
knownAuthorities?: Array<string>;
|
|
28
|
-
cloudDiscoveryMetadata?: string;
|
|
29
|
-
authorityMetadata?: string;
|
|
30
|
-
clientCapabilities?: Array<string>;
|
|
31
|
-
protocolMode?: ProtocolMode;
|
|
32
|
-
azureCloudOptions?: AzureCloudOptions;
|
|
33
|
-
skipAuthorityMetadataCache?: boolean;
|
|
34
|
-
};
|
|
35
|
-
/**
|
|
36
|
-
* Use this to configure the below cache configuration options:
|
|
37
|
-
*
|
|
38
|
-
* - cachePlugin - Plugin for reading and writing token cache to disk.
|
|
39
|
-
* @public
|
|
40
|
-
*/
|
|
41
|
-
export type CacheOptions = {
|
|
42
|
-
cachePlugin?: ICachePlugin;
|
|
43
|
-
};
|
|
44
|
-
/**
|
|
45
|
-
* Use this to configure the below broker options:
|
|
46
|
-
* - nativeBrokerPlugin - Native broker implementation (should be imported from msal-node-extensions)
|
|
47
|
-
*
|
|
48
|
-
* Note: These options are only available for PublicClientApplications using the Authorization Code Flow
|
|
49
|
-
* @public
|
|
50
|
-
*/
|
|
51
|
-
export type BrokerOptions = {
|
|
52
|
-
nativeBrokerPlugin?: INativeBrokerPlugin;
|
|
53
|
-
};
|
|
54
|
-
/**
|
|
55
|
-
* Type for configuring logger and http client options
|
|
56
|
-
*
|
|
57
|
-
* - logger - Used to initialize the Logger object; TODO: Expand on logger details or link to the documentation on logger
|
|
58
|
-
* - networkClient - Http client used for all http get and post calls. Defaults to using MSAL's default http client.
|
|
59
|
-
* @public
|
|
60
|
-
*/
|
|
61
|
-
export type NodeSystemOptions = {
|
|
62
|
-
loggerOptions?: LoggerOptions;
|
|
63
|
-
networkClient?: INetworkModule;
|
|
64
|
-
proxyUrl?: string;
|
|
65
|
-
customAgentOptions?: httpAgentOptions | httpsAgentOptions;
|
|
66
|
-
};
|
|
67
|
-
export type NodeTelemetryOptions = {
|
|
68
|
-
application?: ApplicationTelemetry;
|
|
69
|
-
};
|
|
70
|
-
/**
|
|
71
|
-
* Use the configuration object to configure MSAL and initialize the client application object
|
|
72
|
-
*
|
|
73
|
-
* - auth: this is where you configure auth elements like clientID, authority used for authenticating against the Microsoft Identity Platform
|
|
74
|
-
* - broker: this is where you configure broker options
|
|
75
|
-
* - cache: this is where you configure cache location
|
|
76
|
-
* - system: this is where you can configure the network client, logger
|
|
77
|
-
* - telemetry: this is where you can configure telemetry options
|
|
78
|
-
* @public
|
|
79
|
-
*/
|
|
80
|
-
export type Configuration = {
|
|
81
|
-
auth: NodeAuthOptions;
|
|
82
|
-
broker?: BrokerOptions;
|
|
83
|
-
cache?: CacheOptions;
|
|
84
|
-
system?: NodeSystemOptions;
|
|
85
|
-
telemetry?: NodeTelemetryOptions;
|
|
86
|
-
};
|
|
87
|
-
export type NodeConfiguration = {
|
|
88
|
-
auth: Required<NodeAuthOptions>;
|
|
89
|
-
broker: BrokerOptions;
|
|
90
|
-
cache: CacheOptions;
|
|
91
|
-
system: Required<NodeSystemOptions>;
|
|
92
|
-
telemetry: Required<NodeTelemetryOptions>;
|
|
93
|
-
};
|
|
94
|
-
/**
|
|
95
|
-
* Sets the default options when not explicitly configured from app developer
|
|
96
|
-
*
|
|
97
|
-
* @param auth - Authentication options
|
|
98
|
-
* @param cache - Cache options
|
|
99
|
-
* @param system - System options
|
|
100
|
-
* @param telemetry - Telemetry options
|
|
101
|
-
*
|
|
102
|
-
* @returns Configuration
|
|
103
|
-
* @public
|
|
104
|
-
*/
|
|
105
|
-
export declare function buildAppConfiguration({ auth, broker, cache, system, telemetry, }: Configuration): NodeConfiguration;
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
/// <reference types="node" />
|
|
3
|
+
import { LoggerOptions, INetworkModule, ProtocolMode, ICachePlugin, AzureCloudOptions, ApplicationTelemetry, INativeBrokerPlugin } from "@azure/msal-common";
|
|
4
|
+
import { AgentOptions as httpAgentOptions } from "http";
|
|
5
|
+
import { AgentOptions as httpsAgentOptions } from "https";
|
|
6
|
+
/**
|
|
7
|
+
* - clientId - Client id of the application.
|
|
8
|
+
* - authority - Url of the authority. If no value is set, defaults to https://login.microsoftonline.com/common.
|
|
9
|
+
* - knownAuthorities - Needed for Azure B2C and ADFS. All authorities that will be used in the client application. Only the host of the authority should be passed in.
|
|
10
|
+
* - clientSecret - Secret string that the application uses when requesting a token. Only used in confidential client applications. Can be created in the Azure app registration portal.
|
|
11
|
+
* - clientAssertion - Assertion string that the application uses when requesting a token. Only used in confidential client applications. Assertion should be of type urn:ietf:params:oauth:client-assertion-type:jwt-bearer.
|
|
12
|
+
* - clientCertificate - Certificate that the application uses when requesting a token. Only used in confidential client applications. Requires hex encoded X.509 SHA-1 thumbprint of the certificiate, and the PEM encoded private key (string should contain -----BEGIN PRIVATE KEY----- ... -----END PRIVATE KEY----- )
|
|
13
|
+
* - protocolMode - Enum that represents the protocol that msal follows. Used for configuring proper endpoints.
|
|
14
|
+
* - skipAuthorityMetadataCache - A flag to choose whether to use or not use the local metadata cache during authority initialization. Defaults to false.
|
|
15
|
+
* @public
|
|
16
|
+
*/
|
|
17
|
+
export type NodeAuthOptions = {
|
|
18
|
+
clientId: string;
|
|
19
|
+
authority?: string;
|
|
20
|
+
clientSecret?: string;
|
|
21
|
+
clientAssertion?: string;
|
|
22
|
+
clientCertificate?: {
|
|
23
|
+
thumbprint: string;
|
|
24
|
+
privateKey: string;
|
|
25
|
+
x5c?: string;
|
|
26
|
+
};
|
|
27
|
+
knownAuthorities?: Array<string>;
|
|
28
|
+
cloudDiscoveryMetadata?: string;
|
|
29
|
+
authorityMetadata?: string;
|
|
30
|
+
clientCapabilities?: Array<string>;
|
|
31
|
+
protocolMode?: ProtocolMode;
|
|
32
|
+
azureCloudOptions?: AzureCloudOptions;
|
|
33
|
+
skipAuthorityMetadataCache?: boolean;
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* Use this to configure the below cache configuration options:
|
|
37
|
+
*
|
|
38
|
+
* - cachePlugin - Plugin for reading and writing token cache to disk.
|
|
39
|
+
* @public
|
|
40
|
+
*/
|
|
41
|
+
export type CacheOptions = {
|
|
42
|
+
cachePlugin?: ICachePlugin;
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* Use this to configure the below broker options:
|
|
46
|
+
* - nativeBrokerPlugin - Native broker implementation (should be imported from msal-node-extensions)
|
|
47
|
+
*
|
|
48
|
+
* Note: These options are only available for PublicClientApplications using the Authorization Code Flow
|
|
49
|
+
* @public
|
|
50
|
+
*/
|
|
51
|
+
export type BrokerOptions = {
|
|
52
|
+
nativeBrokerPlugin?: INativeBrokerPlugin;
|
|
53
|
+
};
|
|
54
|
+
/**
|
|
55
|
+
* Type for configuring logger and http client options
|
|
56
|
+
*
|
|
57
|
+
* - logger - Used to initialize the Logger object; TODO: Expand on logger details or link to the documentation on logger
|
|
58
|
+
* - networkClient - Http client used for all http get and post calls. Defaults to using MSAL's default http client.
|
|
59
|
+
* @public
|
|
60
|
+
*/
|
|
61
|
+
export type NodeSystemOptions = {
|
|
62
|
+
loggerOptions?: LoggerOptions;
|
|
63
|
+
networkClient?: INetworkModule;
|
|
64
|
+
proxyUrl?: string;
|
|
65
|
+
customAgentOptions?: httpAgentOptions | httpsAgentOptions;
|
|
66
|
+
};
|
|
67
|
+
export type NodeTelemetryOptions = {
|
|
68
|
+
application?: ApplicationTelemetry;
|
|
69
|
+
};
|
|
70
|
+
/**
|
|
71
|
+
* Use the configuration object to configure MSAL and initialize the client application object
|
|
72
|
+
*
|
|
73
|
+
* - auth: this is where you configure auth elements like clientID, authority used for authenticating against the Microsoft Identity Platform
|
|
74
|
+
* - broker: this is where you configure broker options
|
|
75
|
+
* - cache: this is where you configure cache location
|
|
76
|
+
* - system: this is where you can configure the network client, logger
|
|
77
|
+
* - telemetry: this is where you can configure telemetry options
|
|
78
|
+
* @public
|
|
79
|
+
*/
|
|
80
|
+
export type Configuration = {
|
|
81
|
+
auth: NodeAuthOptions;
|
|
82
|
+
broker?: BrokerOptions;
|
|
83
|
+
cache?: CacheOptions;
|
|
84
|
+
system?: NodeSystemOptions;
|
|
85
|
+
telemetry?: NodeTelemetryOptions;
|
|
86
|
+
};
|
|
87
|
+
export type NodeConfiguration = {
|
|
88
|
+
auth: Required<NodeAuthOptions>;
|
|
89
|
+
broker: BrokerOptions;
|
|
90
|
+
cache: CacheOptions;
|
|
91
|
+
system: Required<NodeSystemOptions>;
|
|
92
|
+
telemetry: Required<NodeTelemetryOptions>;
|
|
93
|
+
};
|
|
94
|
+
/**
|
|
95
|
+
* Sets the default options when not explicitly configured from app developer
|
|
96
|
+
*
|
|
97
|
+
* @param auth - Authentication options
|
|
98
|
+
* @param cache - Cache options
|
|
99
|
+
* @param system - System options
|
|
100
|
+
* @param telemetry - Telemetry options
|
|
101
|
+
*
|
|
102
|
+
* @returns Configuration
|
|
103
|
+
* @public
|
|
104
|
+
*/
|
|
105
|
+
export declare function buildAppConfiguration({ auth, broker, cache, system, telemetry, }: Configuration): NodeConfiguration;
|
|
106
106
|
//# sourceMappingURL=Configuration.d.ts.map
|
|
@@ -1,77 +1,77 @@
|
|
|
1
|
-
/*! @azure/msal-node v2.0.0-
|
|
1
|
+
/*! @azure/msal-node v2.0.0-beta.0 2023-06-19 */
|
|
2
2
|
'use strict';
|
|
3
3
|
import { Constants, ProtocolMode, AzureCloudInstance, LogLevel } from '@azure/msal-common';
|
|
4
4
|
import { HttpClient } from '../network/HttpClient.esm.js';
|
|
5
5
|
|
|
6
|
-
/*
|
|
7
|
-
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
8
|
-
* Licensed under the MIT License.
|
|
9
|
-
*/
|
|
10
|
-
const DEFAULT_AUTH_OPTIONS = {
|
|
11
|
-
clientId: Constants.EMPTY_STRING,
|
|
12
|
-
authority: Constants.DEFAULT_AUTHORITY,
|
|
13
|
-
clientSecret: Constants.EMPTY_STRING,
|
|
14
|
-
clientAssertion: Constants.EMPTY_STRING,
|
|
15
|
-
clientCertificate: {
|
|
16
|
-
thumbprint: Constants.EMPTY_STRING,
|
|
17
|
-
privateKey: Constants.EMPTY_STRING,
|
|
18
|
-
x5c: Constants.EMPTY_STRING,
|
|
19
|
-
},
|
|
20
|
-
knownAuthorities: [],
|
|
21
|
-
cloudDiscoveryMetadata: Constants.EMPTY_STRING,
|
|
22
|
-
authorityMetadata: Constants.EMPTY_STRING,
|
|
23
|
-
clientCapabilities: [],
|
|
24
|
-
protocolMode: ProtocolMode.AAD,
|
|
25
|
-
azureCloudOptions: {
|
|
26
|
-
azureCloudInstance: AzureCloudInstance.None,
|
|
27
|
-
tenant: Constants.EMPTY_STRING,
|
|
28
|
-
},
|
|
29
|
-
skipAuthorityMetadataCache: false,
|
|
30
|
-
};
|
|
31
|
-
const DEFAULT_CACHE_OPTIONS = {};
|
|
32
|
-
const DEFAULT_LOGGER_OPTIONS = {
|
|
33
|
-
loggerCallback: () => {
|
|
34
|
-
// allow users to not set logger call back
|
|
35
|
-
},
|
|
36
|
-
piiLoggingEnabled: false,
|
|
37
|
-
logLevel: LogLevel.Info,
|
|
38
|
-
};
|
|
39
|
-
const DEFAULT_SYSTEM_OPTIONS = {
|
|
40
|
-
loggerOptions: DEFAULT_LOGGER_OPTIONS,
|
|
41
|
-
networkClient: new HttpClient(),
|
|
42
|
-
proxyUrl: Constants.EMPTY_STRING,
|
|
43
|
-
customAgentOptions: {},
|
|
44
|
-
};
|
|
45
|
-
const DEFAULT_TELEMETRY_OPTIONS = {
|
|
46
|
-
application: {
|
|
47
|
-
appName: Constants.EMPTY_STRING,
|
|
48
|
-
appVersion: Constants.EMPTY_STRING,
|
|
49
|
-
},
|
|
50
|
-
};
|
|
51
|
-
/**
|
|
52
|
-
* Sets the default options when not explicitly configured from app developer
|
|
53
|
-
*
|
|
54
|
-
* @param auth - Authentication options
|
|
55
|
-
* @param cache - Cache options
|
|
56
|
-
* @param system - System options
|
|
57
|
-
* @param telemetry - Telemetry options
|
|
58
|
-
*
|
|
59
|
-
* @returns Configuration
|
|
60
|
-
* @public
|
|
61
|
-
*/
|
|
62
|
-
function buildAppConfiguration({ auth, broker, cache, system, telemetry, }) {
|
|
63
|
-
const systemOptions = {
|
|
64
|
-
...DEFAULT_SYSTEM_OPTIONS,
|
|
65
|
-
networkClient: new HttpClient(system?.proxyUrl, system?.customAgentOptions),
|
|
66
|
-
loggerOptions: system?.loggerOptions || DEFAULT_LOGGER_OPTIONS,
|
|
67
|
-
};
|
|
68
|
-
return {
|
|
69
|
-
auth: { ...DEFAULT_AUTH_OPTIONS, ...auth },
|
|
70
|
-
broker: { ...broker },
|
|
71
|
-
cache: { ...DEFAULT_CACHE_OPTIONS, ...cache },
|
|
72
|
-
system: { ...systemOptions, ...system },
|
|
73
|
-
telemetry: { ...DEFAULT_TELEMETRY_OPTIONS, ...telemetry },
|
|
74
|
-
};
|
|
6
|
+
/*
|
|
7
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
8
|
+
* Licensed under the MIT License.
|
|
9
|
+
*/
|
|
10
|
+
const DEFAULT_AUTH_OPTIONS = {
|
|
11
|
+
clientId: Constants.EMPTY_STRING,
|
|
12
|
+
authority: Constants.DEFAULT_AUTHORITY,
|
|
13
|
+
clientSecret: Constants.EMPTY_STRING,
|
|
14
|
+
clientAssertion: Constants.EMPTY_STRING,
|
|
15
|
+
clientCertificate: {
|
|
16
|
+
thumbprint: Constants.EMPTY_STRING,
|
|
17
|
+
privateKey: Constants.EMPTY_STRING,
|
|
18
|
+
x5c: Constants.EMPTY_STRING,
|
|
19
|
+
},
|
|
20
|
+
knownAuthorities: [],
|
|
21
|
+
cloudDiscoveryMetadata: Constants.EMPTY_STRING,
|
|
22
|
+
authorityMetadata: Constants.EMPTY_STRING,
|
|
23
|
+
clientCapabilities: [],
|
|
24
|
+
protocolMode: ProtocolMode.AAD,
|
|
25
|
+
azureCloudOptions: {
|
|
26
|
+
azureCloudInstance: AzureCloudInstance.None,
|
|
27
|
+
tenant: Constants.EMPTY_STRING,
|
|
28
|
+
},
|
|
29
|
+
skipAuthorityMetadataCache: false,
|
|
30
|
+
};
|
|
31
|
+
const DEFAULT_CACHE_OPTIONS = {};
|
|
32
|
+
const DEFAULT_LOGGER_OPTIONS = {
|
|
33
|
+
loggerCallback: () => {
|
|
34
|
+
// allow users to not set logger call back
|
|
35
|
+
},
|
|
36
|
+
piiLoggingEnabled: false,
|
|
37
|
+
logLevel: LogLevel.Info,
|
|
38
|
+
};
|
|
39
|
+
const DEFAULT_SYSTEM_OPTIONS = {
|
|
40
|
+
loggerOptions: DEFAULT_LOGGER_OPTIONS,
|
|
41
|
+
networkClient: new HttpClient(),
|
|
42
|
+
proxyUrl: Constants.EMPTY_STRING,
|
|
43
|
+
customAgentOptions: {},
|
|
44
|
+
};
|
|
45
|
+
const DEFAULT_TELEMETRY_OPTIONS = {
|
|
46
|
+
application: {
|
|
47
|
+
appName: Constants.EMPTY_STRING,
|
|
48
|
+
appVersion: Constants.EMPTY_STRING,
|
|
49
|
+
},
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
52
|
+
* Sets the default options when not explicitly configured from app developer
|
|
53
|
+
*
|
|
54
|
+
* @param auth - Authentication options
|
|
55
|
+
* @param cache - Cache options
|
|
56
|
+
* @param system - System options
|
|
57
|
+
* @param telemetry - Telemetry options
|
|
58
|
+
*
|
|
59
|
+
* @returns Configuration
|
|
60
|
+
* @public
|
|
61
|
+
*/
|
|
62
|
+
function buildAppConfiguration({ auth, broker, cache, system, telemetry, }) {
|
|
63
|
+
const systemOptions = {
|
|
64
|
+
...DEFAULT_SYSTEM_OPTIONS,
|
|
65
|
+
networkClient: new HttpClient(system?.proxyUrl, system?.customAgentOptions),
|
|
66
|
+
loggerOptions: system?.loggerOptions || DEFAULT_LOGGER_OPTIONS,
|
|
67
|
+
};
|
|
68
|
+
return {
|
|
69
|
+
auth: { ...DEFAULT_AUTH_OPTIONS, ...auth },
|
|
70
|
+
broker: { ...broker },
|
|
71
|
+
cache: { ...DEFAULT_CACHE_OPTIONS, ...cache },
|
|
72
|
+
system: { ...systemOptions, ...system },
|
|
73
|
+
telemetry: { ...DEFAULT_TELEMETRY_OPTIONS, ...telemetry },
|
|
74
|
+
};
|
|
75
75
|
}
|
|
76
76
|
|
|
77
77
|
export { buildAppConfiguration };
|