@azure/identity 4.5.0-beta.1 → 4.5.0-beta.3
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +67 -50
- package/dist/index.js +355 -170
- package/dist/index.js.map +1 -1
- package/dist-esm/src/client/identityClient.js +4 -4
- package/dist-esm/src/client/identityClient.js.map +1 -1
- package/dist-esm/src/constants.js +2 -2
- package/dist-esm/src/constants.js.map +1 -1
- package/dist-esm/src/credentials/authorityValidationOptions.js +1 -1
- package/dist-esm/src/credentials/authorityValidationOptions.js.map +1 -1
- package/dist-esm/src/credentials/authorizationCodeCredential.browser.js +1 -1
- package/dist-esm/src/credentials/authorizationCodeCredential.browser.js.map +1 -1
- package/dist-esm/src/credentials/authorizationCodeCredential.js +1 -1
- package/dist-esm/src/credentials/authorizationCodeCredential.js.map +1 -1
- package/dist-esm/src/credentials/authorizationCodeCredentialOptions.js +1 -1
- package/dist-esm/src/credentials/authorizationCodeCredentialOptions.js.map +1 -1
- package/dist-esm/src/credentials/azureApplicationCredential.browser.js +1 -1
- package/dist-esm/src/credentials/azureApplicationCredential.browser.js.map +1 -1
- package/dist-esm/src/credentials/azureApplicationCredential.js +1 -1
- package/dist-esm/src/credentials/azureApplicationCredential.js.map +1 -1
- package/dist-esm/src/credentials/azureApplicationCredentialOptions.js +1 -1
- package/dist-esm/src/credentials/azureApplicationCredentialOptions.js.map +1 -1
- package/dist-esm/src/credentials/azureCliCredential.browser.js +1 -1
- package/dist-esm/src/credentials/azureCliCredential.browser.js.map +1 -1
- package/dist-esm/src/credentials/azureCliCredential.js +1 -1
- package/dist-esm/src/credentials/azureCliCredential.js.map +1 -1
- package/dist-esm/src/credentials/azureCliCredentialOptions.js +1 -1
- package/dist-esm/src/credentials/azureCliCredentialOptions.js.map +1 -1
- package/dist-esm/src/credentials/azureDeveloperCliCredential.browser.js +1 -1
- package/dist-esm/src/credentials/azureDeveloperCliCredential.browser.js.map +1 -1
- package/dist-esm/src/credentials/azureDeveloperCliCredential.js +1 -1
- package/dist-esm/src/credentials/azureDeveloperCliCredential.js.map +1 -1
- package/dist-esm/src/credentials/azureDeveloperCliCredentialOptions.js +1 -1
- package/dist-esm/src/credentials/azureDeveloperCliCredentialOptions.js.map +1 -1
- package/dist-esm/src/credentials/azurePipelinesCredential.browser.js +1 -1
- package/dist-esm/src/credentials/azurePipelinesCredential.browser.js.map +1 -1
- package/dist-esm/src/credentials/azurePipelinesCredential.js +51 -27
- package/dist-esm/src/credentials/azurePipelinesCredential.js.map +1 -1
- package/dist-esm/src/credentials/azurePipelinesCredentialOptions.js +1 -1
- package/dist-esm/src/credentials/azurePipelinesCredentialOptions.js.map +1 -1
- package/dist-esm/src/credentials/azurePowerShellCredential.browser.js +1 -1
- package/dist-esm/src/credentials/azurePowerShellCredential.browser.js.map +1 -1
- package/dist-esm/src/credentials/azurePowerShellCredential.js +64 -20
- package/dist-esm/src/credentials/azurePowerShellCredential.js.map +1 -1
- package/dist-esm/src/credentials/azurePowerShellCredentialOptions.js +1 -1
- package/dist-esm/src/credentials/azurePowerShellCredentialOptions.js.map +1 -1
- package/dist-esm/src/credentials/brokerAuthOptions.js.map +1 -1
- package/dist-esm/src/credentials/browserCustomizationOptions.js +1 -1
- package/dist-esm/src/credentials/browserCustomizationOptions.js.map +1 -1
- package/dist-esm/src/credentials/chainedTokenCredential.js +1 -1
- package/dist-esm/src/credentials/chainedTokenCredential.js.map +1 -1
- package/dist-esm/src/credentials/clientAssertionCredential.browser.js +1 -1
- package/dist-esm/src/credentials/clientAssertionCredential.browser.js.map +1 -1
- package/dist-esm/src/credentials/clientAssertionCredential.js +10 -3
- package/dist-esm/src/credentials/clientAssertionCredential.js.map +1 -1
- package/dist-esm/src/credentials/clientAssertionCredentialOptions.js +1 -1
- package/dist-esm/src/credentials/clientAssertionCredentialOptions.js.map +1 -1
- package/dist-esm/src/credentials/clientCertificateCredential.browser.js +1 -1
- package/dist-esm/src/credentials/clientCertificateCredential.browser.js.map +1 -1
- package/dist-esm/src/credentials/clientCertificateCredential.js +36 -28
- package/dist-esm/src/credentials/clientCertificateCredential.js.map +1 -1
- package/dist-esm/src/credentials/clientCertificateCredentialOptions.js +1 -1
- package/dist-esm/src/credentials/clientCertificateCredentialOptions.js.map +1 -1
- package/dist-esm/src/credentials/clientSecretCredential.browser.js +1 -1
- package/dist-esm/src/credentials/clientSecretCredential.browser.js.map +1 -1
- package/dist-esm/src/credentials/clientSecretCredential.js +10 -3
- package/dist-esm/src/credentials/clientSecretCredential.js.map +1 -1
- package/dist-esm/src/credentials/clientSecretCredentialOptions.js +1 -1
- package/dist-esm/src/credentials/clientSecretCredentialOptions.js.map +1 -1
- package/dist-esm/src/credentials/credentialPersistenceOptions.js +1 -1
- package/dist-esm/src/credentials/credentialPersistenceOptions.js.map +1 -1
- package/dist-esm/src/credentials/defaultAzureCredential.browser.js +1 -1
- package/dist-esm/src/credentials/defaultAzureCredential.browser.js.map +1 -1
- package/dist-esm/src/credentials/defaultAzureCredential.js +1 -1
- package/dist-esm/src/credentials/defaultAzureCredential.js.map +1 -1
- package/dist-esm/src/credentials/defaultAzureCredentialOptions.js +1 -1
- package/dist-esm/src/credentials/defaultAzureCredentialOptions.js.map +1 -1
- package/dist-esm/src/credentials/deviceCodeCredential.browser.js +1 -1
- package/dist-esm/src/credentials/deviceCodeCredential.browser.js.map +1 -1
- package/dist-esm/src/credentials/deviceCodeCredential.js +2 -2
- package/dist-esm/src/credentials/deviceCodeCredential.js.map +1 -1
- package/dist-esm/src/credentials/deviceCodeCredentialOptions.js +1 -1
- package/dist-esm/src/credentials/deviceCodeCredentialOptions.js.map +1 -1
- package/dist-esm/src/credentials/environmentCredential.browser.js +1 -1
- package/dist-esm/src/credentials/environmentCredential.browser.js.map +1 -1
- package/dist-esm/src/credentials/environmentCredential.js +12 -2
- package/dist-esm/src/credentials/environmentCredential.js.map +1 -1
- package/dist-esm/src/credentials/environmentCredentialOptions.js +1 -1
- package/dist-esm/src/credentials/environmentCredentialOptions.js.map +1 -1
- package/dist-esm/src/credentials/interactiveBrowserCredential.browser.js +1 -1
- package/dist-esm/src/credentials/interactiveBrowserCredential.browser.js.map +1 -1
- package/dist-esm/src/credentials/interactiveBrowserCredential.js +2 -2
- package/dist-esm/src/credentials/interactiveBrowserCredential.js.map +1 -1
- package/dist-esm/src/credentials/interactiveBrowserCredentialOptions.js +1 -1
- package/dist-esm/src/credentials/interactiveBrowserCredentialOptions.js.map +1 -1
- package/dist-esm/src/credentials/interactiveCredentialOptions.js +1 -1
- package/dist-esm/src/credentials/interactiveCredentialOptions.js.map +1 -1
- package/dist-esm/src/credentials/managedIdentityCredential/appServiceMsi2017.js +1 -1
- package/dist-esm/src/credentials/managedIdentityCredential/appServiceMsi2017.js.map +1 -1
- package/dist-esm/src/credentials/managedIdentityCredential/appServiceMsi2019.js +1 -1
- package/dist-esm/src/credentials/managedIdentityCredential/appServiceMsi2019.js.map +1 -1
- package/dist-esm/src/credentials/managedIdentityCredential/arcMsi.js +1 -1
- package/dist-esm/src/credentials/managedIdentityCredential/arcMsi.js.map +1 -1
- package/dist-esm/src/credentials/managedIdentityCredential/cloudShellMsi.js +1 -1
- package/dist-esm/src/credentials/managedIdentityCredential/cloudShellMsi.js.map +1 -1
- package/dist-esm/src/credentials/managedIdentityCredential/constants.js +1 -1
- package/dist-esm/src/credentials/managedIdentityCredential/constants.js.map +1 -1
- package/dist-esm/src/credentials/managedIdentityCredential/fabricMsi.js +1 -1
- package/dist-esm/src/credentials/managedIdentityCredential/fabricMsi.js.map +1 -1
- package/dist-esm/src/credentials/managedIdentityCredential/imdsMsi.js +1 -1
- package/dist-esm/src/credentials/managedIdentityCredential/imdsMsi.js.map +1 -1
- package/dist-esm/src/credentials/managedIdentityCredential/imdsRetryPolicy.js +6 -10
- package/dist-esm/src/credentials/managedIdentityCredential/imdsRetryPolicy.js.map +1 -1
- package/dist-esm/src/credentials/managedIdentityCredential/index.browser.js +1 -1
- package/dist-esm/src/credentials/managedIdentityCredential/index.browser.js.map +1 -1
- package/dist-esm/src/credentials/managedIdentityCredential/index.js +1 -1
- package/dist-esm/src/credentials/managedIdentityCredential/index.js.map +1 -1
- package/dist-esm/src/credentials/managedIdentityCredential/legacyMsiProvider.js +7 -1
- package/dist-esm/src/credentials/managedIdentityCredential/legacyMsiProvider.js.map +1 -1
- package/dist-esm/src/credentials/managedIdentityCredential/models.js +1 -1
- package/dist-esm/src/credentials/managedIdentityCredential/models.js.map +1 -1
- package/dist-esm/src/credentials/managedIdentityCredential/msalMsiProvider.js +25 -8
- package/dist-esm/src/credentials/managedIdentityCredential/msalMsiProvider.js.map +1 -1
- package/dist-esm/src/credentials/managedIdentityCredential/tokenExchangeMsi.js +1 -1
- package/dist-esm/src/credentials/managedIdentityCredential/tokenExchangeMsi.js.map +1 -1
- package/dist-esm/src/credentials/managedIdentityCredential/utils.js +26 -1
- package/dist-esm/src/credentials/managedIdentityCredential/utils.js.map +1 -1
- package/dist-esm/src/credentials/multiTenantTokenCredentialOptions.js +1 -1
- package/dist-esm/src/credentials/multiTenantTokenCredentialOptions.js.map +1 -1
- package/dist-esm/src/credentials/onBehalfOfCredential.browser.js +1 -1
- package/dist-esm/src/credentials/onBehalfOfCredential.browser.js.map +1 -1
- package/dist-esm/src/credentials/onBehalfOfCredential.js +17 -10
- package/dist-esm/src/credentials/onBehalfOfCredential.js.map +1 -1
- package/dist-esm/src/credentials/onBehalfOfCredentialOptions.js +1 -1
- package/dist-esm/src/credentials/onBehalfOfCredentialOptions.js.map +1 -1
- package/dist-esm/src/credentials/usernamePasswordCredential.browser.js +1 -1
- package/dist-esm/src/credentials/usernamePasswordCredential.browser.js.map +1 -1
- package/dist-esm/src/credentials/usernamePasswordCredential.js +14 -4
- package/dist-esm/src/credentials/usernamePasswordCredential.js.map +1 -1
- package/dist-esm/src/credentials/usernamePasswordCredentialOptions.js +1 -1
- package/dist-esm/src/credentials/usernamePasswordCredentialOptions.js.map +1 -1
- package/dist-esm/src/credentials/visualStudioCodeCredential.browser.js +1 -1
- package/dist-esm/src/credentials/visualStudioCodeCredential.browser.js.map +1 -1
- package/dist-esm/src/credentials/visualStudioCodeCredential.js +1 -1
- package/dist-esm/src/credentials/visualStudioCodeCredential.js.map +1 -1
- package/dist-esm/src/credentials/visualStudioCodeCredentialOptions.js +1 -1
- package/dist-esm/src/credentials/visualStudioCodeCredentialOptions.js.map +1 -1
- package/dist-esm/src/credentials/visualStudioCodeCredentialPlugin.js +1 -1
- package/dist-esm/src/credentials/visualStudioCodeCredentialPlugin.js.map +1 -1
- package/dist-esm/src/credentials/workloadIdentityCredential.browser.js +1 -1
- package/dist-esm/src/credentials/workloadIdentityCredential.browser.js.map +1 -1
- package/dist-esm/src/credentials/workloadIdentityCredential.js +17 -7
- package/dist-esm/src/credentials/workloadIdentityCredential.js.map +1 -1
- package/dist-esm/src/credentials/workloadIdentityCredentialOptions.js +1 -1
- package/dist-esm/src/credentials/workloadIdentityCredentialOptions.js.map +1 -1
- package/dist-esm/src/errors.js +13 -9
- package/dist-esm/src/errors.js.map +1 -1
- package/dist-esm/src/index.js +1 -1
- package/dist-esm/src/index.js.map +1 -1
- package/dist-esm/src/msal/browserFlows/flows.js +4 -0
- package/dist-esm/src/msal/browserFlows/flows.js.map +1 -0
- package/dist-esm/src/msal/browserFlows/msalAuthCode.js +1 -1
- package/dist-esm/src/msal/browserFlows/msalAuthCode.js.map +1 -1
- package/dist-esm/src/msal/browserFlows/msalBrowserCommon.js +3 -1
- package/dist-esm/src/msal/browserFlows/msalBrowserCommon.js.map +1 -1
- package/dist-esm/src/msal/credentials.js +1 -1
- package/dist-esm/src/msal/credentials.js.map +1 -1
- package/dist-esm/src/msal/msal.browser.js +1 -1
- package/dist-esm/src/msal/msal.browser.js.map +1 -1
- package/dist-esm/src/msal/msal.js +1 -1
- package/dist-esm/src/msal/msal.js.map +1 -1
- package/dist-esm/src/msal/nodeFlows/brokerOptions.js.map +1 -1
- package/dist-esm/src/msal/nodeFlows/msalClient.js +25 -9
- package/dist-esm/src/msal/nodeFlows/msalClient.js.map +1 -1
- package/dist-esm/src/msal/nodeFlows/msalPlugins.js +1 -1
- package/dist-esm/src/msal/nodeFlows/msalPlugins.js.map +1 -1
- package/dist-esm/src/msal/nodeFlows/tokenCachePersistenceOptions.js +1 -1
- package/dist-esm/src/msal/nodeFlows/tokenCachePersistenceOptions.js.map +1 -1
- package/dist-esm/src/msal/types.js +1 -1
- package/dist-esm/src/msal/types.js.map +1 -1
- package/dist-esm/src/msal/utils.js +15 -2
- package/dist-esm/src/msal/utils.js.map +1 -1
- package/dist-esm/src/plugins/consumer.browser.js +1 -1
- package/dist-esm/src/plugins/consumer.browser.js.map +1 -1
- package/dist-esm/src/plugins/consumer.js +1 -1
- package/dist-esm/src/plugins/consumer.js.map +1 -1
- package/dist-esm/src/plugins/provider.js +1 -1
- package/dist-esm/src/plugins/provider.js.map +1 -1
- package/dist-esm/src/regionalAuthority.js +1 -1
- package/dist-esm/src/regionalAuthority.js.map +1 -1
- package/dist-esm/src/tokenCredentialOptions.js +1 -1
- package/dist-esm/src/tokenCredentialOptions.js.map +1 -1
- package/dist-esm/src/tokenProvider.js +1 -1
- package/dist-esm/src/tokenProvider.js.map +1 -1
- package/dist-esm/src/util/authHostEnv.browser.js +1 -1
- package/dist-esm/src/util/authHostEnv.browser.js.map +1 -1
- package/dist-esm/src/util/identityTokenEndpoint.js +1 -1
- package/dist-esm/src/util/identityTokenEndpoint.js.map +1 -1
- package/dist-esm/src/util/logging.js +1 -1
- package/dist-esm/src/util/logging.js.map +1 -1
- package/dist-esm/src/util/processMultiTenantRequest.browser.js +1 -1
- package/dist-esm/src/util/processMultiTenantRequest.browser.js.map +1 -1
- package/dist-esm/src/util/processMultiTenantRequest.js +1 -1
- package/dist-esm/src/util/processMultiTenantRequest.js.map +1 -1
- package/dist-esm/src/util/processUtils.js +1 -1
- package/dist-esm/src/util/processUtils.js.map +1 -1
- package/dist-esm/src/util/scopeUtils.js +1 -1
- package/dist-esm/src/util/scopeUtils.js.map +1 -1
- package/dist-esm/src/util/tenantIdUtils.js +1 -1
- package/dist-esm/src/util/tenantIdUtils.js.map +1 -1
- package/dist-esm/src/util/tracing.js +1 -1
- package/dist-esm/src/util/tracing.js.map +1 -1
- package/package.json +9 -9
- package/types/identity.d.ts +47 -11
- package/dist-esm/src/msal/flows.js +0 -4
- package/dist-esm/src/msal/flows.js.map +0 -1
- package/dist-esm/src/msal/nodeFlows/msalAuthorizationCode.js +0 -47
- package/dist-esm/src/msal/nodeFlows/msalAuthorizationCode.js.map +0 -1
- package/dist-esm/src/msal/nodeFlows/msalClientAssertion.js +0 -42
- package/dist-esm/src/msal/nodeFlows/msalClientAssertion.js.map +0 -1
- package/dist-esm/src/msal/nodeFlows/msalClientCertificate.js +0 -112
- package/dist-esm/src/msal/nodeFlows/msalClientCertificate.js.map +0 -1
- package/dist-esm/src/msal/nodeFlows/msalClientSecret.js +0 -33
- package/dist-esm/src/msal/nodeFlows/msalClientSecret.js.map +0 -1
- package/dist-esm/src/msal/nodeFlows/msalDeviceCode.js +0 -35
- package/dist-esm/src/msal/nodeFlows/msalDeviceCode.js.map +0 -1
- package/dist-esm/src/msal/nodeFlows/msalNodeCommon.js +0 -323
- package/dist-esm/src/msal/nodeFlows/msalNodeCommon.js.map +0 -1
- package/dist-esm/src/msal/nodeFlows/msalOnBehalfOf.js +0 -58
- package/dist-esm/src/msal/nodeFlows/msalOnBehalfOf.js.map +0 -1
- package/dist-esm/src/msal/nodeFlows/msalOpenBrowser.js +0 -113
- package/dist-esm/src/msal/nodeFlows/msalOpenBrowser.js.map +0 -1
- package/dist-esm/src/msal/nodeFlows/msalUsernamePassword.js +0 -33
- package/dist-esm/src/msal/nodeFlows/msalUsernamePassword.js.map +0 -1
@@ -1,58 +0,0 @@
|
|
1
|
-
// Copyright (c) Microsoft Corporation.
|
2
|
-
// Licensed under the MIT license.
|
3
|
-
import { MsalNode } from "./msalNodeCommon";
|
4
|
-
import { formatError } from "../../util/logging";
|
5
|
-
import { handleMsalError } from "../utils";
|
6
|
-
import { parseCertificate } from "./msalClientCertificate";
|
7
|
-
/**
|
8
|
-
* MSAL on behalf of flow. Calls to MSAL's confidential application's `acquireTokenOnBehalfOf` during `doGetToken`.
|
9
|
-
* @internal
|
10
|
-
*/
|
11
|
-
export class MsalOnBehalfOf extends MsalNode {
|
12
|
-
constructor(options) {
|
13
|
-
super(options);
|
14
|
-
this.logger.info("Initialized MSAL's On-Behalf-Of flow");
|
15
|
-
this.requiresConfidential = true;
|
16
|
-
this.userAssertionToken = options.userAssertionToken;
|
17
|
-
this.certificatePath = options.certificatePath;
|
18
|
-
this.sendCertificateChain = options.sendCertificateChain;
|
19
|
-
this.clientSecret = options.clientSecret;
|
20
|
-
}
|
21
|
-
// Changing the MSAL configuration asynchronously
|
22
|
-
async init(options) {
|
23
|
-
if (this.certificatePath) {
|
24
|
-
try {
|
25
|
-
const parts = await parseCertificate({ certificatePath: this.certificatePath }, this.sendCertificateChain);
|
26
|
-
this.msalConfig.auth.clientCertificate = {
|
27
|
-
thumbprint: parts.thumbprint,
|
28
|
-
privateKey: parts.certificateContents,
|
29
|
-
x5c: parts.x5c,
|
30
|
-
};
|
31
|
-
}
|
32
|
-
catch (error) {
|
33
|
-
this.logger.info(formatError("", error));
|
34
|
-
throw error;
|
35
|
-
}
|
36
|
-
}
|
37
|
-
else {
|
38
|
-
this.msalConfig.auth.clientSecret = this.clientSecret;
|
39
|
-
}
|
40
|
-
return super.init(options);
|
41
|
-
}
|
42
|
-
async doGetToken(scopes, options = {}) {
|
43
|
-
try {
|
44
|
-
const result = await this.getApp("confidential", options.enableCae).acquireTokenOnBehalfOf({
|
45
|
-
scopes,
|
46
|
-
correlationId: options.correlationId,
|
47
|
-
authority: options.authority,
|
48
|
-
claims: options.claims,
|
49
|
-
oboAssertion: this.userAssertionToken,
|
50
|
-
});
|
51
|
-
return this.handleResult(scopes, result || undefined);
|
52
|
-
}
|
53
|
-
catch (err) {
|
54
|
-
throw handleMsalError(scopes, err, options);
|
55
|
-
}
|
56
|
-
}
|
57
|
-
}
|
58
|
-
//#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EAAE,KAAK,CAAC,GAAG;iBACf,CAAC;YACJ,CAAC;YAAC,OAAO,KAAU,EAAE,CAAC;gBACpB,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE,EAAE,KAAK,CAAC,CAAC,CAAC;gBACzC,MAAM,KAAK,CAAC;YACd,CAAC;QACH,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,YAAY,CAAC;QACxD,CAAC;QACD,OAAO,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAC7B,CAAC;IAES,KAAK,CAAC,UAAU,CACxB,MAAgB,EAChB,UAAyC,EAAE;QAE3C,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,cAAc,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC,sBAAsB,CAAC;gBACzF,MAAM;gBACN,aAAa,EAAE,OAAO,CAAC,aAAa;gBACpC,SAAS,EAAE,OAAO,CAAC,SAAS;gBAC5B,MAAM,EAAE,OAAO,CAAC,MAAM;gBACtB,YAAY,EAAE,IAAI,CAAC,kBAAkB;aACtC,CAAC,CAAC;YACH,OAAO,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE,MAAM,IAAI,SAAS,CAAC,CAAC;QACxD,CAAC;QAAC,OAAO,GAAQ,EAAE,CAAC;YAClB,MAAM,eAAe,CAAC,MAAM,EAAE,GAAG,EAAE,OAAO,CAAC,CAAC;QAC9C,CAAC;IACH,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { MsalNode, MsalNodeOptions } from \"./msalNodeCommon\";\n\nimport { AccessToken } from \"@azure/core-auth\";\nimport { CredentialFlowGetTokenOptions } from \"../credentials\";\nimport { formatError } from \"../../util/logging\";\nimport { handleMsalError } from \"../utils\";\nimport { parseCertificate } from \"./msalClientCertificate\";\n\n/**\n * Options that can be passed to configure MSAL to handle On-Behalf-Of authentication requests.\n * @internal\n */\nexport interface MsalOnBehalfOfOptions extends MsalNodeOptions {\n /**\n * A client secret that was generated for the App Registration.\n */\n clientSecret?: string;\n /**\n * Location of the PEM certificate.\n */\n certificatePath?: string;\n /**\n * A function that retrieves the client assertion for the credential to use\n */\n getAssertion?: () => Promise<string>;\n /**\n * Option to include x5c header for SubjectName and Issuer name authorization.\n * Set this option to send base64 encoded public certificate in the client assertion header as an x5c claim\n */\n sendCertificateChain?: boolean;\n /**\n * The user assertion for the On-Behalf-Of flow.\n */\n userAssertionToken: string;\n}\n\n/**\n * MSAL on behalf of flow. Calls to MSAL's confidential application's `acquireTokenOnBehalfOf` during `doGetToken`.\n * @internal\n */\nexport class MsalOnBehalfOf extends MsalNode {\n private userAssertionToken: string;\n private certificatePath?: string;\n private sendCertificateChain?: boolean;\n private clientSecret?: string;\n\n constructor(options: MsalOnBehalfOfOptions) {\n super(options);\n this.logger.info(\"Initialized MSAL's On-Behalf-Of flow\");\n this.requiresConfidential = true;\n this.userAssertionToken = options.userAssertionToken;\n this.certificatePath = options.certificatePath;\n this.sendCertificateChain = options.sendCertificateChain;\n this.clientSecret = options.clientSecret;\n }\n\n // Changing the MSAL configuration asynchronously\n async init(options?: CredentialFlowGetTokenOptions): Promise<void> {\n if (this.certificatePath) {\n try {\n const parts = await parseCertificate(\n { certificatePath: this.certificatePath },\n this.sendCertificateChain,\n );\n this.msalConfig.auth.clientCertificate = {\n thumbprint: parts.thumbprint,\n privateKey: parts.certificateContents,\n x5c: parts.x5c,\n };\n } catch (error: any) {\n this.logger.info(formatError(\"\", error));\n throw error;\n }\n } else {\n this.msalConfig.auth.clientSecret = this.clientSecret;\n }\n return super.init(options);\n }\n\n protected async doGetToken(\n scopes: string[],\n options: CredentialFlowGetTokenOptions = {},\n ): Promise<AccessToken> {\n try {\n const result = await this.getApp(\"confidential\", options.enableCae).acquireTokenOnBehalfOf({\n scopes,\n correlationId: options.correlationId,\n authority: options.authority,\n claims: options.claims,\n oboAssertion: this.userAssertionToken,\n });\n return this.handleResult(scopes, result || undefined);\n } catch (err: any) {\n throw handleMsalError(scopes, err, options);\n }\n }\n}\n"]}
|
@@ -1,113 +0,0 @@
|
|
1
|
-
// Copyright (c) Microsoft Corporation.
|
2
|
-
// Licensed under the MIT license.
|
3
|
-
import { MsalNode } from "./msalNodeCommon";
|
4
|
-
import { credentialLogger } from "../../util/logging";
|
5
|
-
import { handleMsalError } from "../utils";
|
6
|
-
import { hasNativeBroker } from "./msalPlugins";
|
7
|
-
import open from "open";
|
8
|
-
/**
|
9
|
-
* A call to open(), but mockable
|
10
|
-
* @internal
|
11
|
-
*/
|
12
|
-
export const interactiveBrowserMockable = {
|
13
|
-
open,
|
14
|
-
};
|
15
|
-
/**
|
16
|
-
* This MSAL client sets up a web server to listen for redirect callbacks, then calls to the MSAL's public application's `acquireTokenByDeviceCode` during `doGetToken`
|
17
|
-
* to trigger the authentication flow, and then respond based on the values obtained from the redirect callback
|
18
|
-
* @internal
|
19
|
-
*/
|
20
|
-
export class MsalOpenBrowser extends MsalNode {
|
21
|
-
constructor(options) {
|
22
|
-
var _a, _b, _c, _d;
|
23
|
-
super(options);
|
24
|
-
this.loginHint = options.loginHint;
|
25
|
-
this.errorTemplate = (_a = options.browserCustomizationOptions) === null || _a === void 0 ? void 0 : _a.errorMessage;
|
26
|
-
this.successTemplate = (_b = options.browserCustomizationOptions) === null || _b === void 0 ? void 0 : _b.successMessage;
|
27
|
-
this.logger = credentialLogger("Node.js MSAL Open Browser");
|
28
|
-
this.useDefaultBrokerAccount =
|
29
|
-
((_c = options.brokerOptions) === null || _c === void 0 ? void 0 : _c.enabled) && ((_d = options.brokerOptions) === null || _d === void 0 ? void 0 : _d.useDefaultBrokerAccount);
|
30
|
-
}
|
31
|
-
async doGetToken(scopes, options = {}) {
|
32
|
-
try {
|
33
|
-
const interactiveRequest = {
|
34
|
-
openBrowser: async (url) => {
|
35
|
-
await interactiveBrowserMockable.open(url, { wait: true, newInstance: true });
|
36
|
-
},
|
37
|
-
scopes,
|
38
|
-
authority: options === null || options === void 0 ? void 0 : options.authority,
|
39
|
-
claims: options === null || options === void 0 ? void 0 : options.claims,
|
40
|
-
correlationId: options === null || options === void 0 ? void 0 : options.correlationId,
|
41
|
-
loginHint: this.loginHint,
|
42
|
-
errorTemplate: this.errorTemplate,
|
43
|
-
successTemplate: this.successTemplate,
|
44
|
-
};
|
45
|
-
if (hasNativeBroker() && this.enableBroker) {
|
46
|
-
return this.doGetBrokeredToken(scopes, interactiveRequest, {
|
47
|
-
enableCae: options.enableCae,
|
48
|
-
useDefaultBrokerAccount: this.useDefaultBrokerAccount,
|
49
|
-
});
|
50
|
-
}
|
51
|
-
// If the broker is not enabled, we will fall back to interactive authentication
|
52
|
-
if (hasNativeBroker() && !this.enableBroker) {
|
53
|
-
this.logger.verbose("Authentication will resume normally without the broker, since it's not enabled");
|
54
|
-
}
|
55
|
-
const result = await this.getApp("public", options === null || options === void 0 ? void 0 : options.enableCae).acquireTokenInteractive(interactiveRequest);
|
56
|
-
return this.handleResult(scopes, result || undefined);
|
57
|
-
}
|
58
|
-
catch (err) {
|
59
|
-
throw handleMsalError(scopes, err, options);
|
60
|
-
}
|
61
|
-
}
|
62
|
-
/**
|
63
|
-
* A helper function that supports brokered authentication through the MSAL's public application.
|
64
|
-
*
|
65
|
-
* When options.useDefaultBrokerAccount is true, the method will attempt to authenticate using the default broker account.
|
66
|
-
* If the default broker account is not available, the method will fall back to interactive authentication.
|
67
|
-
*/
|
68
|
-
async doGetBrokeredToken(scopes, interactiveRequest, options) {
|
69
|
-
var _a;
|
70
|
-
this.logger.verbose("Authentication will resume through the broker");
|
71
|
-
if (this.parentWindowHandle) {
|
72
|
-
interactiveRequest.windowHandle = Buffer.from(this.parentWindowHandle);
|
73
|
-
}
|
74
|
-
else {
|
75
|
-
// error should have been thrown from within the constructor of InteractiveBrowserCredential
|
76
|
-
this.logger.warning("Parent window handle is not specified for the broker. This may cause unexpected behavior. Please provide the parentWindowHandle.");
|
77
|
-
}
|
78
|
-
if (this.enableMsaPassthrough) {
|
79
|
-
((_a = interactiveRequest.tokenQueryParameters) !== null && _a !== void 0 ? _a : (interactiveRequest.tokenQueryParameters = {}))["msal_request_type"] =
|
80
|
-
"consumer_passthrough";
|
81
|
-
}
|
82
|
-
if (options.useDefaultBrokerAccount) {
|
83
|
-
interactiveRequest.prompt = "none";
|
84
|
-
this.logger.verbose("Attempting broker authentication using the default broker account");
|
85
|
-
}
|
86
|
-
else {
|
87
|
-
interactiveRequest.prompt = undefined;
|
88
|
-
this.logger.verbose("Attempting broker authentication without the default broker account");
|
89
|
-
}
|
90
|
-
try {
|
91
|
-
const result = await this.getApp("public", options === null || options === void 0 ? void 0 : options.enableCae).acquireTokenInteractive(interactiveRequest);
|
92
|
-
if (result.fromNativeBroker) {
|
93
|
-
this.logger.verbose(`This result is returned from native broker`);
|
94
|
-
}
|
95
|
-
return this.handleResult(scopes, result || undefined);
|
96
|
-
}
|
97
|
-
catch (e) {
|
98
|
-
this.logger.verbose(`Failed to authenticate through the broker: ${e.message}`);
|
99
|
-
// If we tried to use the default broker account and failed, fall back to interactive authentication
|
100
|
-
if (options.useDefaultBrokerAccount) {
|
101
|
-
return this.doGetBrokeredToken(scopes, interactiveRequest, {
|
102
|
-
enableCae: options.enableCae,
|
103
|
-
useDefaultBrokerAccount: false,
|
104
|
-
});
|
105
|
-
}
|
106
|
-
else {
|
107
|
-
// If we're not using the default broker account, throw the error
|
108
|
-
throw handleMsalError(scopes, e);
|
109
|
-
}
|
110
|
-
}
|
111
|
-
}
|
112
|
-
}
|
113
|
-
//# sourceMappingURL=msalOpenBrowser.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"msalOpenBrowser.js","sourceRoot":"","sources":["../../../../src/msal/nodeFlows/msalOpenBrowser.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAIlC,OAAO,EAAE,QAAQ,EAAmB,MAAM,kBAAkB,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SAAS;oBAC5B,uBAAuB,EAAE,KAAK;iBAC/B,CAAC,CAAC;YACL,CAAC;iBAAM,CAAC;gBACN,iEAAiE;gBACjE,MAAM,eAAe,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;YACnC,CAAC;QACH,CAAC;IACH,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport * as msalNode from \"@azure/msal-node\";\n\nimport { MsalNode, MsalNodeOptions } from \"./msalNodeCommon\";\n\nimport { AccessToken } from \"@azure/core-auth\";\nimport { CredentialFlowGetTokenOptions } from \"../credentials\";\nimport { credentialLogger } from \"../../util/logging\";\nimport { handleMsalError } from \"../utils\";\nimport { hasNativeBroker } from \"./msalPlugins\";\nimport open from \"open\";\n\n/**\n * Options that can be passed to configure MSAL to handle authentication through opening a browser window.\n * @internal\n */\nexport interface MsalOpenBrowserOptions extends MsalNodeOptions {\n redirectUri?: string;\n loginHint?: string;\n browserCustomizationOptions?: {\n errorMessage?: string;\n successMessage?: string;\n };\n}\n\n/**\n * A call to open(), but mockable\n * @internal\n */\nexport const interactiveBrowserMockable = {\n open,\n};\n\n/**\n * This MSAL client sets up a web server to listen for redirect callbacks, then calls to the MSAL's public application's `acquireTokenByDeviceCode` during `doGetToken`\n * to trigger the authentication flow, and then respond based on the values obtained from the redirect callback\n * @internal\n */\nexport class MsalOpenBrowser extends MsalNode {\n private loginHint?: string;\n private errorTemplate?: string;\n private successTemplate?: string;\n private useDefaultBrokerAccount?: boolean;\n\n constructor(options: MsalOpenBrowserOptions) {\n super(options);\n this.loginHint = options.loginHint;\n this.errorTemplate = options.browserCustomizationOptions?.errorMessage;\n this.successTemplate = options.browserCustomizationOptions?.successMessage;\n this.logger = credentialLogger(\"Node.js MSAL Open Browser\");\n this.useDefaultBrokerAccount =\n options.brokerOptions?.enabled && options.brokerOptions?.useDefaultBrokerAccount;\n }\n\n protected async doGetToken(\n scopes: string[],\n options: CredentialFlowGetTokenOptions = {},\n ): Promise<AccessToken> {\n try {\n const interactiveRequest: msalNode.InteractiveRequest = {\n openBrowser: async (url) => {\n await interactiveBrowserMockable.open(url, { wait: true, newInstance: true });\n },\n scopes,\n authority: options?.authority,\n claims: options?.claims,\n correlationId: options?.correlationId,\n loginHint: this.loginHint,\n errorTemplate: this.errorTemplate,\n successTemplate: this.successTemplate,\n };\n\n if (hasNativeBroker() && this.enableBroker) {\n return this.doGetBrokeredToken(scopes, interactiveRequest, {\n enableCae: options.enableCae,\n useDefaultBrokerAccount: this.useDefaultBrokerAccount,\n });\n }\n\n // If the broker is not enabled, we will fall back to interactive authentication\n\n if (hasNativeBroker() && !this.enableBroker) {\n this.logger.verbose(\n \"Authentication will resume normally without the broker, since it's not enabled\",\n );\n }\n\n const result = await this.getApp(\"public\", options?.enableCae).acquireTokenInteractive(\n interactiveRequest,\n );\n return this.handleResult(scopes, result || undefined);\n } catch (err: any) {\n throw handleMsalError(scopes, err, options);\n }\n }\n\n /**\n * A helper function that supports brokered authentication through the MSAL's public application.\n *\n * When options.useDefaultBrokerAccount is true, the method will attempt to authenticate using the default broker account.\n * If the default broker account is not available, the method will fall back to interactive authentication.\n */\n private async doGetBrokeredToken(\n scopes: string[],\n interactiveRequest: msalNode.InteractiveRequest,\n options: {\n enableCae?: boolean;\n useDefaultBrokerAccount?: boolean;\n },\n ): Promise<AccessToken> {\n this.logger.verbose(\"Authentication will resume through the broker\");\n if (this.parentWindowHandle) {\n interactiveRequest.windowHandle = Buffer.from(this.parentWindowHandle);\n } else {\n // error should have been thrown from within the constructor of InteractiveBrowserCredential\n this.logger.warning(\n \"Parent window handle is not specified for the broker. This may cause unexpected behavior. Please provide the parentWindowHandle.\",\n );\n }\n\n if (this.enableMsaPassthrough) {\n (interactiveRequest.tokenQueryParameters ??= {})[\"msal_request_type\"] =\n \"consumer_passthrough\";\n }\n\n if (options.useDefaultBrokerAccount) {\n interactiveRequest.prompt = \"none\";\n this.logger.verbose(\"Attempting broker authentication using the default broker account\");\n } else {\n interactiveRequest.prompt = undefined;\n this.logger.verbose(\"Attempting broker authentication without the default broker account\");\n }\n\n try {\n const result = await this.getApp(\"public\", options?.enableCae).acquireTokenInteractive(\n interactiveRequest,\n );\n if (result.fromNativeBroker) {\n this.logger.verbose(`This result is returned from native broker`);\n }\n return this.handleResult(scopes, result || undefined);\n } catch (e: any) {\n this.logger.verbose(`Failed to authenticate through the broker: ${e.message}`);\n // If we tried to use the default broker account and failed, fall back to interactive authentication\n if (options.useDefaultBrokerAccount) {\n return this.doGetBrokeredToken(scopes, interactiveRequest, {\n enableCae: options.enableCae,\n useDefaultBrokerAccount: false,\n });\n } else {\n // If we're not using the default broker account, throw the error\n throw handleMsalError(scopes, e);\n }\n }\n }\n}\n"]}
|
@@ -1,33 +0,0 @@
|
|
1
|
-
// Copyright (c) Microsoft Corporation.
|
2
|
-
// Licensed under the MIT license.
|
3
|
-
import { MsalNode } from "./msalNodeCommon";
|
4
|
-
import { handleMsalError } from "../utils";
|
5
|
-
/**
|
6
|
-
* MSAL username and password client. Calls to the MSAL's public application's `acquireTokenByUsernamePassword` during `doGetToken`.
|
7
|
-
* @internal
|
8
|
-
*/
|
9
|
-
export class MsalUsernamePassword extends MsalNode {
|
10
|
-
constructor(options) {
|
11
|
-
super(options);
|
12
|
-
this.username = options.username;
|
13
|
-
this.password = options.password;
|
14
|
-
}
|
15
|
-
async doGetToken(scopes, options) {
|
16
|
-
try {
|
17
|
-
const requestOptions = {
|
18
|
-
scopes,
|
19
|
-
username: this.username,
|
20
|
-
password: this.password,
|
21
|
-
correlationId: options === null || options === void 0 ? void 0 : options.correlationId,
|
22
|
-
authority: options === null || options === void 0 ? void 0 : options.authority,
|
23
|
-
claims: options === null || options === void 0 ? void 0 : options.claims,
|
24
|
-
};
|
25
|
-
const result = await this.getApp("public", options === null || options === void 0 ? void 0 : options.enableCae).acquireTokenByUsernamePassword(requestOptions);
|
26
|
-
return this.handleResult(scopes, result || undefined);
|
27
|
-
}
|
28
|
-
catch (error) {
|
29
|
-
throw handleMsalError(scopes, error, options);
|
30
|
-
}
|
31
|
-
}
|
32
|
-
}
|
33
|
-
//# sourceMappingURL=msalUsernamePassword.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"msalUsernamePassword.js","sourceRoot":"","sources":["../../../../src/msal/nodeFlows/msalUsernamePassword.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAIlC,OAAO,EAAE,QAAQ,EAAmB,MAAM,kBAAkB,CAAC;AAI7D,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAW3C;;;GAGG;AACH,MAAM,OAAO,oBAAqB,SAAQ,QAAQ;IAIhD,YAAY,OAAoC;QAC9C,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC;QACjC,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC;IACnC,CAAC;IAES,KAAK,CAAC,UAAU,CACxB,MAAgB,EAChB,OAAuC;QAEvC,IAAI,CAAC;YACH,MAAM,cAAc,GAAqC;gBACvD,MAAM;gBACN,QAAQ,EAAE,IAAI,CAAC,QAAQ;gBACvB,QAAQ,EAAE,IAAI,CAAC,QAAQ;gBACvB,aAAa,EAAE,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,aAAa;gBACrC,SAAS,EAAE,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,SAAS;gBAC7B,MAAM,EAAE,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,MAAM;aACxB,CAAC;YACF,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,SAAS,CAAC,CAAC,8BAA8B,CAC3F,cAAc,CACf,CAAC;YACF,OAAO,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE,MAAM,IAAI,SAAS,CAAC,CAAC;QACxD,CAAC;QAAC,OAAO,KAAU,EAAE,CAAC;YACpB,MAAM,eAAe,CAAC,MAAM,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;QAChD,CAAC;IACH,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport * as msalNode from \"@azure/msal-node\";\n\nimport { MsalNode, MsalNodeOptions } from \"./msalNodeCommon\";\n\nimport { AccessToken } from \"@azure/core-auth\";\nimport { CredentialFlowGetTokenOptions } from \"../credentials\";\nimport { handleMsalError } from \"../utils\";\n\n/**\n * Options that can be passed to configure MSAL to handle authentication through username and password.\n * @internal\n */\nexport interface MsalUsernamePasswordOptions extends MsalNodeOptions {\n username: string;\n password: string;\n}\n\n/**\n * MSAL username and password client. Calls to the MSAL's public application's `acquireTokenByUsernamePassword` during `doGetToken`.\n * @internal\n */\nexport class MsalUsernamePassword extends MsalNode {\n private username: string;\n private password: string;\n\n constructor(options: MsalUsernamePasswordOptions) {\n super(options);\n this.username = options.username;\n this.password = options.password;\n }\n\n protected async doGetToken(\n scopes: string[],\n options?: CredentialFlowGetTokenOptions,\n ): Promise<AccessToken> {\n try {\n const requestOptions: msalNode.UsernamePasswordRequest = {\n scopes,\n username: this.username,\n password: this.password,\n correlationId: options?.correlationId,\n authority: options?.authority,\n claims: options?.claims,\n };\n const result = await this.getApp(\"public\", options?.enableCae).acquireTokenByUsernamePassword(\n requestOptions,\n );\n return this.handleResult(scopes, result || undefined);\n } catch (error: any) {\n throw handleMsalError(scopes, error, options);\n }\n }\n}\n"]}
|