@azure/identity 4.4.0 → 4.5.0-alpha.20240813.2

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 (70) hide show
  1. package/README.md +22 -1
  2. package/dist/index.js +441 -812
  3. package/dist/index.js.map +1 -1
  4. package/dist-esm/src/client/identityClient.js +8 -2
  5. package/dist-esm/src/client/identityClient.js.map +1 -1
  6. package/dist-esm/src/constants.js +1 -1
  7. package/dist-esm/src/constants.js.map +1 -1
  8. package/dist-esm/src/credentials/azurePipelinesCredential.js +50 -26
  9. package/dist-esm/src/credentials/azurePipelinesCredential.js.map +1 -1
  10. package/dist-esm/src/credentials/azurePowerShellCredential.js +63 -19
  11. package/dist-esm/src/credentials/azurePowerShellCredential.js.map +1 -1
  12. package/dist-esm/src/credentials/clientAssertionCredential.js +9 -2
  13. package/dist-esm/src/credentials/clientAssertionCredential.js.map +1 -1
  14. package/dist-esm/src/credentials/clientCertificateCredential.js +35 -27
  15. package/dist-esm/src/credentials/clientCertificateCredential.js.map +1 -1
  16. package/dist-esm/src/credentials/clientSecretCredential.js +9 -2
  17. package/dist-esm/src/credentials/clientSecretCredential.js.map +1 -1
  18. package/dist-esm/src/credentials/deviceCodeCredential.js +1 -1
  19. package/dist-esm/src/credentials/deviceCodeCredential.js.map +1 -1
  20. package/dist-esm/src/credentials/deviceCodeCredentialOptions.js.map +1 -1
  21. package/dist-esm/src/credentials/environmentCredential.js +11 -1
  22. package/dist-esm/src/credentials/environmentCredential.js.map +1 -1
  23. package/dist-esm/src/credentials/interactiveBrowserCredential.browser.js.map +1 -1
  24. package/dist-esm/src/credentials/interactiveBrowserCredential.js +1 -1
  25. package/dist-esm/src/credentials/interactiveBrowserCredential.js.map +1 -1
  26. package/dist-esm/src/credentials/interactiveBrowserCredentialOptions.js.map +1 -1
  27. package/dist-esm/src/credentials/managedIdentityCredential/imdsRetryPolicy.js +37 -0
  28. package/dist-esm/src/credentials/managedIdentityCredential/imdsRetryPolicy.js.map +1 -0
  29. package/dist-esm/src/credentials/managedIdentityCredential/index.js +6 -2
  30. package/dist-esm/src/credentials/managedIdentityCredential/index.js.map +1 -1
  31. package/dist-esm/src/credentials/managedIdentityCredential/legacyMsiProvider.js +1 -1
  32. package/dist-esm/src/credentials/managedIdentityCredential/legacyMsiProvider.js.map +1 -1
  33. package/dist-esm/src/credentials/managedIdentityCredential/msalMsiProvider.js +195 -0
  34. package/dist-esm/src/credentials/managedIdentityCredential/msalMsiProvider.js.map +1 -0
  35. package/dist-esm/src/credentials/managedIdentityCredential/tokenExchangeMsi.js +19 -22
  36. package/dist-esm/src/credentials/managedIdentityCredential/tokenExchangeMsi.js.map +1 -1
  37. package/dist-esm/src/credentials/onBehalfOfCredential.js +16 -9
  38. package/dist-esm/src/credentials/onBehalfOfCredential.js.map +1 -1
  39. package/dist-esm/src/credentials/usernamePasswordCredential.js +13 -3
  40. package/dist-esm/src/credentials/usernamePasswordCredential.js.map +1 -1
  41. package/dist-esm/src/credentials/workloadIdentityCredential.js +16 -6
  42. package/dist-esm/src/credentials/workloadIdentityCredential.js.map +1 -1
  43. package/dist-esm/src/errors.js +12 -7
  44. package/dist-esm/src/errors.js.map +1 -1
  45. package/dist-esm/src/msal/browserFlows/flows.js.map +1 -0
  46. package/dist-esm/src/msal/browserFlows/msalBrowserCommon.js.map +1 -1
  47. package/dist-esm/src/msal/nodeFlows/msalClient.js +8 -1
  48. package/dist-esm/src/msal/nodeFlows/msalClient.js.map +1 -1
  49. package/package.json +4 -4
  50. package/types/identity.d.ts +26 -8
  51. package/dist-esm/src/msal/flows.js.map +0 -1
  52. package/dist-esm/src/msal/nodeFlows/msalAuthorizationCode.js +0 -47
  53. package/dist-esm/src/msal/nodeFlows/msalAuthorizationCode.js.map +0 -1
  54. package/dist-esm/src/msal/nodeFlows/msalClientAssertion.js +0 -42
  55. package/dist-esm/src/msal/nodeFlows/msalClientAssertion.js.map +0 -1
  56. package/dist-esm/src/msal/nodeFlows/msalClientCertificate.js +0 -112
  57. package/dist-esm/src/msal/nodeFlows/msalClientCertificate.js.map +0 -1
  58. package/dist-esm/src/msal/nodeFlows/msalClientSecret.js +0 -33
  59. package/dist-esm/src/msal/nodeFlows/msalClientSecret.js.map +0 -1
  60. package/dist-esm/src/msal/nodeFlows/msalDeviceCode.js +0 -35
  61. package/dist-esm/src/msal/nodeFlows/msalDeviceCode.js.map +0 -1
  62. package/dist-esm/src/msal/nodeFlows/msalNodeCommon.js +0 -323
  63. package/dist-esm/src/msal/nodeFlows/msalNodeCommon.js.map +0 -1
  64. package/dist-esm/src/msal/nodeFlows/msalOnBehalfOf.js +0 -58
  65. package/dist-esm/src/msal/nodeFlows/msalOnBehalfOf.js.map +0 -1
  66. package/dist-esm/src/msal/nodeFlows/msalOpenBrowser.js +0 -113
  67. package/dist-esm/src/msal/nodeFlows/msalOpenBrowser.js.map +0 -1
  68. package/dist-esm/src/msal/nodeFlows/msalUsernamePassword.js +0 -33
  69. package/dist-esm/src/msal/nodeFlows/msalUsernamePassword.js.map +0 -1
  70. /package/dist-esm/src/msal/{flows.js → browserFlows/flows.js} +0 -0
@@ -40,7 +40,9 @@ export declare class AuthenticationError extends Error {
40
40
  * The error response details.
41
41
  */
42
42
  readonly errorResponse: ErrorResponse;
43
- constructor(statusCode: number, errorBody: object | string | undefined | null);
43
+ constructor(statusCode: number, errorBody: object | string | undefined | null, options?: {
44
+ cause?: unknown;
45
+ });
44
46
  }
45
47
 
46
48
  /**
@@ -109,6 +111,10 @@ export declare interface AuthenticationRequiredErrorOptions {
109
111
  * The message of the error.
110
112
  */
111
113
  message?: string;
114
+ /**
115
+ * The underlying cause, if any, that caused the authentication to fail.
116
+ */
117
+ cause?: unknown;
112
118
  }
113
119
 
114
120
  /**
@@ -651,7 +657,6 @@ export declare class ClientCertificateCredential implements TokenCredential {
651
657
  */
652
658
  getToken(scopes: string | string[], options?: GetTokenOptions): Promise<AccessToken>;
653
659
  private buildClientCertificate;
654
- private parseCertificate;
655
660
  }
656
661
 
657
662
  /**
@@ -782,7 +787,9 @@ export declare interface CredentialPersistenceOptions {
782
787
  * an error that should halt the chain, it's caught and the chain continues
783
788
  */
784
789
  export declare class CredentialUnavailableError extends Error {
785
- constructor(message?: string);
790
+ constructor(message?: string, options?: {
791
+ cause?: unknown;
792
+ });
786
793
  }
787
794
 
788
795
  /**
@@ -978,7 +985,7 @@ export declare class DeviceCodeCredential implements TokenCredential {
978
985
  * Authenticates with Microsoft Entra ID and returns an access token if successful.
979
986
  * If authentication fails, a {@link CredentialUnavailableError} will be thrown with the details of the failure.
980
987
  *
981
- * If the token can't be retrieved silently, this method will require user interaction to retrieve the token.
988
+ * If the token can't be retrieved silently, this method will always generate a challenge for the user.
982
989
  *
983
990
  * @param scopes - The list of scopes for which the token will have access.
984
991
  * @param options - The options used to configure any requests this
@@ -996,7 +1003,11 @@ export declare interface DeviceCodeCredentialOptions extends InteractiveCredenti
996
1003
  */
997
1004
  tenantId?: string;
998
1005
  /**
999
- * The client (application) ID of an App Registration in the tenant.
1006
+ * Client ID of the Microsoft Entra application that users will sign into.
1007
+ * It is recommended that developers register their applications and assign appropriate roles.
1008
+ * For more information, visit https://aka.ms/identity/AppRegistrationAndRoleAssignment.
1009
+ * If not specified, users will authenticate to an Azure development application,
1010
+ * which is not recommended for production scenarios.
1000
1011
  */
1001
1012
  clientId?: string;
1002
1013
  /**
@@ -1056,6 +1067,7 @@ export declare class EnvironmentCredential implements TokenCredential {
1056
1067
  * - `AZURE_CLIENT_SECRET`: A client secret that was generated for the App Registration.
1057
1068
  * - `AZURE_CLIENT_CERTIFICATE_PATH`: The path to a PEM certificate to use during the authentication, instead of the client secret.
1058
1069
  * - `AZURE_CLIENT_CERTIFICATE_PASSWORD`: (optional) password for the certificate file.
1070
+ * - `AZURE_CLIENT_SEND_CERTIFICATE_CHAIN`: (optional) indicates that the certificate chain should be set in x5c header to support subject name / issuer based authentication.
1059
1071
  *
1060
1072
  * Alternatively, users can provide environment variables for username and password authentication:
1061
1073
  * - `AZURE_USERNAME`: Username to authenticate with.
@@ -1210,7 +1222,7 @@ export declare class InteractiveBrowserCredential implements TokenCredential {
1210
1222
  * Authenticates with Microsoft Entra ID and returns an access token if successful.
1211
1223
  * If authentication fails, a {@link CredentialUnavailableError} will be thrown with the details of the failure.
1212
1224
  *
1213
- * If the token can't be retrieved silently, this method will require user interaction to retrieve the token.
1225
+ * If the token can't be retrieved silently, this method will always generate a challenge for the user.
1214
1226
  *
1215
1227
  * On Node.js, this credential has [Proof Key for Code Exchange (PKCE)](https://datatracker.ietf.org/doc/html/rfc7636) enabled by default.
1216
1228
  * PKCE is a security feature that mitigates authentication code interception attacks.
@@ -1237,8 +1249,10 @@ export declare interface InteractiveBrowserCredentialInBrowserOptions extends In
1237
1249
  */
1238
1250
  tenantId?: string;
1239
1251
  /**
1240
- * The client (application) ID of an App Registration in the tenant.
1252
+ * The Client ID of the Microsoft Entra application that users will sign into.
1241
1253
  * This parameter is required on the browser.
1254
+ * Developers need to register their applications and assign appropriate roles.
1255
+ * For more information, visit https://aka.ms/identity/AppRegistrationAndRoleAssignment.
1242
1256
  */
1243
1257
  clientId: string;
1244
1258
  /**
@@ -1270,7 +1284,11 @@ export declare interface InteractiveBrowserCredentialNodeOptions extends Interac
1270
1284
  */
1271
1285
  tenantId?: string;
1272
1286
  /**
1273
- * The client (application) ID of an App Registration in the tenant.
1287
+ * The Client ID of the Microsoft Entra application that users will sign into.
1288
+ * It is recommended that developers register their applications and assign appropriate roles.
1289
+ * For more information, visit https://aka.ms/identity/AppRegistrationAndRoleAssignment.
1290
+ * If not specified, users will authenticate to an Azure development application,
1291
+ * which is not recommended for production scenarios.
1274
1292
  */
1275
1293
  clientId?: string;
1276
1294
  /**
@@ -1 +0,0 @@
1
- {"version":3,"file":"flows.js","sourceRoot":"","sources":["../../../src/msal/flows.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { AccessToken } from \"@azure/core-auth\";\nimport { AuthenticationRecord } from \"./types\";\nimport { CredentialFlowGetTokenOptions } from \"./credentials\";\nimport { CredentialLogger } from \"../util/logging\";\n\n/**\n * Union of the constructor parameters that all MSAL flow types take.\n * @internal\n */\nexport interface MsalFlowOptions {\n logger: CredentialLogger;\n clientId?: string;\n tenantId?: string;\n authorityHost?: string;\n authenticationRecord?: AuthenticationRecord;\n disableAutomaticAuthentication?: boolean;\n disableInstanceDiscovery?: boolean;\n getAssertion?: () => Promise<string>;\n enableMsaPassthrough?: boolean;\n}\n\n/**\n * The common methods we use to work with the MSAL flows.\n * @internal\n */\nexport interface MsalFlow {\n /**\n * Allows for any setup before any request is processed.\n */\n init(options?: CredentialFlowGetTokenOptions): Promise<void>;\n /**\n * Tries to load the active account, either from memory or from MSAL.\n */\n getActiveAccount(): Promise<AuthenticationRecord | undefined>;\n /**\n * Tries to retrieve the token silently using MSAL.\n */\n getTokenSilent(scopes?: string[], options?: CredentialFlowGetTokenOptions): Promise<AccessToken>;\n /**\n * Calls to the implementation's doGetToken method.\n */\n getToken(scopes?: string[], options?: CredentialFlowGetTokenOptions): Promise<AccessToken>;\n}\n"]}
@@ -1,47 +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
- /**
7
- * 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`
8
- * to trigger the authentication flow, and then respond based on the values obtained from the redirect callback
9
- * @internal
10
- */
11
- export class MsalAuthorizationCode extends MsalNode {
12
- constructor(options) {
13
- super(options);
14
- this.logger = credentialLogger("Node.js MSAL Authorization Code");
15
- this.redirectUri = options.redirectUri;
16
- this.authorizationCode = options.authorizationCode;
17
- if (options.clientSecret) {
18
- this.msalConfig.auth.clientSecret = options.clientSecret;
19
- }
20
- }
21
- async getAuthCodeUrl(options) {
22
- await this.init();
23
- return this.getApp("confidentialFirst", options.enableCae).getAuthCodeUrl({
24
- scopes: options.scopes,
25
- redirectUri: options.redirectUri,
26
- });
27
- }
28
- async doGetToken(scopes, options) {
29
- try {
30
- const result = await this.getApp("confidentialFirst", options === null || options === void 0 ? void 0 : options.enableCae).acquireTokenByCode({
31
- scopes,
32
- redirectUri: this.redirectUri,
33
- code: this.authorizationCode,
34
- correlationId: options === null || options === void 0 ? void 0 : options.correlationId,
35
- authority: options === null || options === void 0 ? void 0 : options.authority,
36
- claims: options === null || options === void 0 ? void 0 : options.claims,
37
- });
38
- // The Client Credential flow does not return an account,
39
- // so each time getToken gets called, we will have to acquire a new token through the service.
40
- return this.handleResult(scopes, result || undefined);
41
- }
42
- catch (err) {
43
- throw handleMsalError(scopes, err, options);
44
- }
45
- }
46
- }
47
- //# sourceMappingURL=msalAuthorizationCode.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"msalAuthorizationCode.js","sourceRoot":"","sources":["../../../../src/msal/nodeFlows/msalAuthorizationCode.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,QAAQ,EAAmB,MAAM,kBAAkB,CAAC;AAI7D,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAY3C;;;;GAIG;AACH,MAAM,OAAO,qBAAsB,SAAQ,QAAQ;IAIjD,YAAY,OAAqC;QAC/C,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,MAAM,GAAG,gBAAgB,CAAC,iCAAiC,CAAC,CAAC;QAClE,IAAI,CAAC,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC;QACvC,IAAI,CAAC,iBAAiB,GAAG,OAAO,CAAC,iBAAiB,CAAC;QACnD,IAAI,OAAO,CAAC,YAAY,EAAE,CAAC;YACzB,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,YAAY,GAAG,OAAO,CAAC,YAAY,CAAC;QAC3D,CAAC;IACH,CAAC;IAED,KAAK,CAAC,cAAc,CAAC,OAIpB;QACC,MAAM,IAAI,CAAC,IAAI,EAAE,CAAC;QAClB,OAAO,IAAI,CAAC,MAAM,CAAC,mBAAmB,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC,cAAc,CAAC;YACxE,MAAM,EAAE,OAAO,CAAC,MAAM;YACtB,WAAW,EAAE,OAAO,CAAC,WAAW;SACjC,CAAC,CAAC;IACL,CAAC;IAES,KAAK,CAAC,UAAU,CACxB,MAAgB,EAChB,OAAuC;QAEvC,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,mBAAmB,EAAE,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,SAAS,CAAC,CAAC,kBAAkB,CAAC;gBAC3F,MAAM;gBACN,WAAW,EAAE,IAAI,CAAC,WAAW;gBAC7B,IAAI,EAAE,IAAI,CAAC,iBAAiB;gBAC5B,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,CAAC;YACH,yDAAyD;YACzD,8FAA8F;YAC9F,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 { credentialLogger } from \"../../util/logging\";\nimport { handleMsalError } from \"../utils\";\n\n/**\n * Options that can be passed to configure MSAL to handle authentication through opening a browser window.\n * @internal\n */\nexport interface MsalAuthorizationCodeOptions extends MsalNodeOptions {\n redirectUri: string;\n authorizationCode: string;\n clientSecret?: string;\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 MsalAuthorizationCode extends MsalNode {\n private redirectUri: string;\n private authorizationCode: string;\n\n constructor(options: MsalAuthorizationCodeOptions) {\n super(options);\n this.logger = credentialLogger(\"Node.js MSAL Authorization Code\");\n this.redirectUri = options.redirectUri;\n this.authorizationCode = options.authorizationCode;\n if (options.clientSecret) {\n this.msalConfig.auth.clientSecret = options.clientSecret;\n }\n }\n\n async getAuthCodeUrl(options: {\n scopes: string[];\n redirectUri: string;\n enableCae?: boolean;\n }): Promise<string> {\n await this.init();\n return this.getApp(\"confidentialFirst\", options.enableCae).getAuthCodeUrl({\n scopes: options.scopes,\n redirectUri: options.redirectUri,\n });\n }\n\n protected async doGetToken(\n scopes: string[],\n options?: CredentialFlowGetTokenOptions,\n ): Promise<AccessToken> {\n try {\n const result = await this.getApp(\"confidentialFirst\", options?.enableCae).acquireTokenByCode({\n scopes,\n redirectUri: this.redirectUri,\n code: this.authorizationCode,\n correlationId: options?.correlationId,\n authority: options?.authority,\n claims: options?.claims,\n });\n // The Client Credential flow does not return an account,\n // so each time getToken gets called, we will have to acquire a new token through the service.\n return this.handleResult(scopes, result || undefined);\n } catch (err: any) {\n throw handleMsalError(scopes, err, options);\n }\n }\n}\n"]}
@@ -1,42 +0,0 @@
1
- // Copyright (c) Microsoft Corporation.
2
- // Licensed under the MIT license.
3
- import { MsalNode } from "./msalNodeCommon";
4
- import { handleMsalError } from "../utils";
5
- import { isError } from "@azure/core-util";
6
- /**
7
- * MSAL client assertion client. Calls to MSAL's confidential application's `acquireTokenByClientCredential` during `doGetToken`.
8
- * @internal
9
- */
10
- export class MsalClientAssertion extends MsalNode {
11
- constructor(options) {
12
- super(options);
13
- this.requiresConfidential = true;
14
- this.getAssertion = options.getAssertion;
15
- }
16
- async doGetToken(scopes, options = {}) {
17
- try {
18
- const result = await this.getApp("confidential", options.enableCae).acquireTokenByClientCredential({
19
- scopes,
20
- correlationId: options.correlationId,
21
- azureRegion: this.azureRegion,
22
- authority: options.authority,
23
- claims: options.claims,
24
- clientAssertion: this.getAssertion,
25
- });
26
- // The Client Credential flow does not return an account,
27
- // so each time getToken gets called, we will have to acquire a new token through the service.
28
- return this.handleResult(scopes, result || undefined);
29
- }
30
- catch (err) {
31
- let err2 = err;
32
- if (err === null || err === undefined) {
33
- err2 = new Error(JSON.stringify(err));
34
- }
35
- else {
36
- err2 = isError(err) ? err : new Error(String(err));
37
- }
38
- throw handleMsalError(scopes, err2, options);
39
- }
40
- }
41
- }
42
- //# sourceMappingURL=msalClientAssertion.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"msalClientAssertion.js","sourceRoot":"","sources":["../../../../src/msal/nodeFlows/msalClientAssertion.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,QAAQ,EAAmB,MAAM,kBAAkB,CAAC;AAI7D,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAC3C,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAa3C;;;GAGG;AACH,MAAM,OAAO,mBAAoB,SAAQ,QAAQ;IAE/C,YAAY,OAAmC;QAC7C,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,oBAAoB,GAAG,IAAI,CAAC;QACjC,IAAI,CAAC,YAAY,GAAG,OAAO,CAAC,YAAY,CAAC;IAC3C,CAAC;IAES,KAAK,CAAC,UAAU,CACxB,MAAgB,EAChB,UAAyC,EAAE;QAE3C,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,MAAM,CAC9B,cAAc,EACd,OAAO,CAAC,SAAS,CAClB,CAAC,8BAA8B,CAAC;gBAC/B,MAAM;gBACN,aAAa,EAAE,OAAO,CAAC,aAAa;gBACpC,WAAW,EAAE,IAAI,CAAC,WAAW;gBAC7B,SAAS,EAAE,OAAO,CAAC,SAAS;gBAC5B,MAAM,EAAE,OAAO,CAAC,MAAM;gBACtB,eAAe,EAAE,IAAI,CAAC,YAAY;aACnC,CAAC,CAAC;YACH,yDAAyD;YACzD,8FAA8F;YAC9F,OAAO,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE,MAAM,IAAI,SAAS,CAAC,CAAC;QACxD,CAAC;QAAC,OAAO,GAAY,EAAE,CAAC;YACtB,IAAI,IAAI,GAAG,GAAG,CAAC;YACf,IAAI,GAAG,KAAK,IAAI,IAAI,GAAG,KAAK,SAAS,EAAE,CAAC;gBACtC,IAAI,GAAG,IAAI,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC;YACxC,CAAC;iBAAM,CAAC;gBACN,IAAI,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;YACrD,CAAC;YACD,MAAM,eAAe,CAAC,MAAM,EAAE,IAAa,EAAE,OAAO,CAAC,CAAC;QACxD,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 { handleMsalError } from \"../utils\";\nimport { isError } from \"@azure/core-util\";\n\n/**\n * Options that can be passed to configure MSAL to handle client assertions.\n * @internal\n */\nexport interface MsalClientAssertionOptions extends MsalNodeOptions {\n /**\n * A function that retrieves the assertion for the credential to use.\n */\n getAssertion: () => Promise<string>;\n}\n\n/**\n * MSAL client assertion client. Calls to MSAL's confidential application's `acquireTokenByClientCredential` during `doGetToken`.\n * @internal\n */\nexport class MsalClientAssertion extends MsalNode {\n getAssertion: () => Promise<string>;\n constructor(options: MsalClientAssertionOptions) {\n super(options);\n this.requiresConfidential = true;\n this.getAssertion = options.getAssertion;\n }\n\n protected async doGetToken(\n scopes: string[],\n options: CredentialFlowGetTokenOptions = {},\n ): Promise<AccessToken> {\n try {\n const result = await this.getApp(\n \"confidential\",\n options.enableCae,\n ).acquireTokenByClientCredential({\n scopes,\n correlationId: options.correlationId,\n azureRegion: this.azureRegion,\n authority: options.authority,\n claims: options.claims,\n clientAssertion: this.getAssertion,\n });\n // The Client Credential flow does not return an account,\n // so each time getToken gets called, we will have to acquire a new token through the service.\n return this.handleResult(scopes, result || undefined);\n } catch (err: unknown) {\n let err2 = err;\n if (err === null || err === undefined) {\n err2 = new Error(JSON.stringify(err));\n } else {\n err2 = isError(err) ? err : new Error(String(err));\n }\n throw handleMsalError(scopes, err2 as Error, options);\n }\n }\n}\n"]}
@@ -1,112 +0,0 @@
1
- // Copyright (c) Microsoft Corporation.
2
- // Licensed under the MIT license.
3
- import { MsalNode } from "./msalNodeCommon";
4
- import { createHash, createPrivateKey } from "crypto";
5
- import { formatError } from "../../util/logging";
6
- import { handleMsalError } from "../utils";
7
- import { promisify } from "util";
8
- import { readFile } from "fs";
9
- const readFileAsync = promisify(readFile);
10
- /**
11
- * Tries to asynchronously load a certificate from the given path.
12
- *
13
- * @param configuration - Either the PEM value or the path to the certificate.
14
- * @param sendCertificateChain - Option to include x5c header for SubjectName and Issuer name authorization.
15
- * @returns - The certificate parts, or `undefined` if the certificate could not be loaded.
16
- * @internal
17
- */
18
- export async function parseCertificate(configuration, sendCertificateChain) {
19
- const certificateParts = {};
20
- const certificate = configuration
21
- .certificate;
22
- const certificatePath = configuration
23
- .certificatePath;
24
- certificateParts.certificateContents =
25
- certificate || (await readFileAsync(certificatePath, "utf8"));
26
- if (sendCertificateChain) {
27
- certificateParts.x5c = certificateParts.certificateContents;
28
- }
29
- const certificatePattern = /(-+BEGIN CERTIFICATE-+)(\n\r?|\r\n?)([A-Za-z0-9+/\n\r]+=*)(\n\r?|\r\n?)(-+END CERTIFICATE-+)/g;
30
- const publicKeys = [];
31
- // Match all possible certificates, in the order they are in the file. These will form the chain that is used for x5c
32
- let match;
33
- do {
34
- match = certificatePattern.exec(certificateParts.certificateContents);
35
- if (match) {
36
- publicKeys.push(match[3]);
37
- }
38
- } while (match);
39
- if (publicKeys.length === 0) {
40
- throw new Error("The file at the specified path does not contain a PEM-encoded certificate.");
41
- }
42
- certificateParts.thumbprint = createHash("sha1")
43
- .update(Buffer.from(publicKeys[0], "base64"))
44
- .digest("hex")
45
- .toUpperCase();
46
- return certificateParts;
47
- }
48
- /**
49
- * MSAL client certificate client. Calls to MSAL's confidential application's `acquireTokenByClientCredential` during `doGetToken`.
50
- * @internal
51
- */
52
- export class MsalClientCertificate extends MsalNode {
53
- constructor(options) {
54
- super(options);
55
- this.requiresConfidential = true;
56
- this.configuration = options.configuration;
57
- this.sendCertificateChain = options.sendCertificateChain;
58
- }
59
- // Changing the MSAL configuration asynchronously
60
- async init(options) {
61
- try {
62
- const parts = await parseCertificate(this.configuration, this.sendCertificateChain);
63
- let privateKey;
64
- if (this.configuration.certificatePassword !== undefined) {
65
- const privateKeyObject = createPrivateKey({
66
- key: parts.certificateContents,
67
- passphrase: this.configuration.certificatePassword,
68
- format: "pem",
69
- });
70
- privateKey = privateKeyObject
71
- .export({
72
- format: "pem",
73
- type: "pkcs8",
74
- })
75
- .toString();
76
- }
77
- else {
78
- privateKey = parts.certificateContents;
79
- }
80
- this.msalConfig.auth.clientCertificate = {
81
- thumbprint: parts.thumbprint,
82
- privateKey: privateKey,
83
- x5c: parts.x5c,
84
- };
85
- }
86
- catch (error) {
87
- this.logger.info(formatError("", error));
88
- throw error;
89
- }
90
- return super.init(options);
91
- }
92
- async doGetToken(scopes, options = {}) {
93
- try {
94
- const clientCredReq = {
95
- scopes,
96
- correlationId: options.correlationId,
97
- azureRegion: this.azureRegion,
98
- authority: options.authority,
99
- claims: options.claims,
100
- };
101
- const result = await this.getApp("confidential", options.enableCae).acquireTokenByClientCredential(clientCredReq);
102
- // Even though we're providing the same default in memory persistence cache that we use for DeviceCodeCredential,
103
- // The Client Credential flow does not return the account information from the authentication service,
104
- // so each time getToken gets called, we will have to acquire a new token through the service.
105
- return this.handleResult(scopes, result || undefined);
106
- }
107
- catch (err) {
108
- throw handleMsalError(scopes, err, options);
109
- }
110
- }
111
- }
112
- //# sourceMappingURL=msalClientCertificate.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"msalClientCertificate.js","sourceRoot":"","sources":["../../../../src/msal/nodeFlows/msalClientCertificate.ts"],"names":[],"mappings":"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","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport {\n ClientCertificateCredentialPEMConfiguration,\n ClientCertificatePEMCertificate,\n ClientCertificatePEMCertificatePath,\n} from \"../../credentials/clientCertificateCredential\";\nimport { MsalNode, MsalNodeOptions } from \"./msalNodeCommon\";\nimport { createHash, createPrivateKey } from \"crypto\";\n\nimport { AccessToken } from \"@azure/core-auth\";\nimport { ClientCredentialRequest } from \"@azure/msal-node\";\nimport { CredentialFlowGetTokenOptions } from \"../credentials\";\nimport { formatError } from \"../../util/logging\";\nimport { handleMsalError } from \"../utils\";\nimport { promisify } from \"util\";\nimport { readFile } from \"fs\";\n\nconst readFileAsync = promisify(readFile);\n\n/**\n * Options that can be passed to configure MSAL to handle client certificates.\n * @internal\n */\nexport interface MsalClientCertificateOptions extends MsalNodeOptions {\n /**\n * Location of the PEM certificate.\n */\n configuration: ClientCertificateCredentialPEMConfiguration;\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\n/**\n * Parts of a certificate, as understood by MSAL.\n * @internal\n */\ninterface CertificateParts {\n /**\n * Hex encoded X.509 SHA-1 thumbprint of the certificate\n */\n thumbprint: string;\n /**\n * The PEM encoded private key (string should contain -----BEGIN PRIVATE KEY----- ... -----END PRIVATE KEY-----\n */\n certificateContents: string;\n /**\n * x5c header.\n */\n x5c: string;\n}\n\n/**\n * Tries to asynchronously load a certificate from the given path.\n *\n * @param configuration - Either the PEM value or the path to the certificate.\n * @param sendCertificateChain - Option to include x5c header for SubjectName and Issuer name authorization.\n * @returns - The certificate parts, or `undefined` if the certificate could not be loaded.\n * @internal\n */\nexport async function parseCertificate(\n configuration: ClientCertificateCredentialPEMConfiguration,\n sendCertificateChain?: boolean,\n): Promise<CertificateParts> {\n const certificateParts: Partial<CertificateParts> = {};\n\n const certificate: string | undefined = (configuration as ClientCertificatePEMCertificate)\n .certificate;\n const certificatePath: string | undefined = (configuration as ClientCertificatePEMCertificatePath)\n .certificatePath;\n certificateParts.certificateContents =\n certificate || (await readFileAsync(certificatePath!, \"utf8\"));\n if (sendCertificateChain) {\n certificateParts.x5c = certificateParts.certificateContents;\n }\n\n const certificatePattern =\n /(-+BEGIN CERTIFICATE-+)(\\n\\r?|\\r\\n?)([A-Za-z0-9+/\\n\\r]+=*)(\\n\\r?|\\r\\n?)(-+END CERTIFICATE-+)/g;\n const publicKeys: string[] = [];\n\n // Match all possible certificates, in the order they are in the file. These will form the chain that is used for x5c\n let match;\n do {\n match = certificatePattern.exec(certificateParts.certificateContents);\n if (match) {\n publicKeys.push(match[3]);\n }\n } while (match);\n\n if (publicKeys.length === 0) {\n throw new Error(\"The file at the specified path does not contain a PEM-encoded certificate.\");\n }\n\n certificateParts.thumbprint = createHash(\"sha1\")\n .update(Buffer.from(publicKeys[0], \"base64\"))\n .digest(\"hex\")\n .toUpperCase();\n\n return certificateParts as CertificateParts;\n}\n\n/**\n * MSAL client certificate client. Calls to MSAL's confidential application's `acquireTokenByClientCredential` during `doGetToken`.\n * @internal\n */\nexport class MsalClientCertificate extends MsalNode {\n private configuration: ClientCertificateCredentialPEMConfiguration;\n private sendCertificateChain?: boolean;\n\n constructor(options: MsalClientCertificateOptions) {\n super(options);\n this.requiresConfidential = true;\n this.configuration = options.configuration;\n this.sendCertificateChain = options.sendCertificateChain;\n }\n\n // Changing the MSAL configuration asynchronously\n async init(options?: CredentialFlowGetTokenOptions): Promise<void> {\n try {\n const parts = await parseCertificate(this.configuration, this.sendCertificateChain);\n\n let privateKey: string | undefined;\n if (this.configuration.certificatePassword !== undefined) {\n const privateKeyObject = createPrivateKey({\n key: parts.certificateContents,\n passphrase: this.configuration.certificatePassword,\n format: \"pem\",\n });\n\n privateKey = privateKeyObject\n .export({\n format: \"pem\",\n type: \"pkcs8\",\n })\n .toString();\n } else {\n privateKey = parts.certificateContents;\n }\n\n this.msalConfig.auth.clientCertificate = {\n thumbprint: parts.thumbprint,\n privateKey: privateKey,\n x5c: parts.x5c,\n };\n } catch (error: any) {\n this.logger.info(formatError(\"\", error));\n throw error;\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 clientCredReq: ClientCredentialRequest = {\n scopes,\n correlationId: options.correlationId,\n azureRegion: this.azureRegion,\n authority: options.authority,\n claims: options.claims,\n };\n const result = await this.getApp(\n \"confidential\",\n options.enableCae,\n ).acquireTokenByClientCredential(clientCredReq);\n // Even though we're providing the same default in memory persistence cache that we use for DeviceCodeCredential,\n // The Client Credential flow does not return the account information from the authentication service,\n // so each time getToken gets called, we will have to acquire a new token through the service.\n return this.handleResult(scopes, result || undefined);\n } catch (err: any) {\n throw handleMsalError(scopes, err, options);\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 client secret client. Calls to MSAL's confidential application's `acquireTokenByClientCredential` during `doGetToken`.
7
- * @internal
8
- */
9
- export class MsalClientSecret extends MsalNode {
10
- constructor(options) {
11
- super(options);
12
- this.requiresConfidential = true;
13
- this.msalConfig.auth.clientSecret = options.clientSecret;
14
- }
15
- async doGetToken(scopes, options = {}) {
16
- try {
17
- const result = await this.getApp("confidential", options.enableCae).acquireTokenByClientCredential({
18
- scopes,
19
- correlationId: options.correlationId,
20
- azureRegion: this.azureRegion,
21
- authority: options.authority,
22
- claims: options.claims,
23
- });
24
- // The Client Credential flow does not return an account,
25
- // so each time getToken gets called, we will have to acquire a new token through the service.
26
- return this.handleResult(scopes, result || undefined);
27
- }
28
- catch (err) {
29
- throw handleMsalError(scopes, err, options);
30
- }
31
- }
32
- }
33
- //# sourceMappingURL=msalClientSecret.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"msalClientSecret.js","sourceRoot":"","sources":["../../../../src/msal/nodeFlows/msalClientSecret.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,QAAQ,EAAmB,MAAM,kBAAkB,CAAC;AAI7D,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAa3C;;;GAGG;AACH,MAAM,OAAO,gBAAiB,SAAQ,QAAQ;IAC5C,YAAY,OAAgC;QAC1C,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,oBAAoB,GAAG,IAAI,CAAC;QACjC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,YAAY,GAAG,OAAO,CAAC,YAAY,CAAC;IAC3D,CAAC;IAES,KAAK,CAAC,UAAU,CACxB,MAAgB,EAChB,UAAyC,EAAE;QAE3C,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,MAAM,CAC9B,cAAc,EACd,OAAO,CAAC,SAAS,CAClB,CAAC,8BAA8B,CAAC;gBAC/B,MAAM;gBACN,aAAa,EAAE,OAAO,CAAC,aAAa;gBACpC,WAAW,EAAE,IAAI,CAAC,WAAW;gBAC7B,SAAS,EAAE,OAAO,CAAC,SAAS;gBAC5B,MAAM,EAAE,OAAO,CAAC,MAAM;aACvB,CAAC,CAAC;YACH,yDAAyD;YACzD,8FAA8F;YAC9F,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 { handleMsalError } from \"../utils\";\n\n/**\n * Options that can be passed to configure MSAL to handle client secrets.\n * @internal\n */\nexport interface MsalClientSecretOptions extends MsalNodeOptions {\n /**\n * A client secret that was generated for the App Registration.\n */\n clientSecret: string;\n}\n\n/**\n * MSAL client secret client. Calls to MSAL's confidential application's `acquireTokenByClientCredential` during `doGetToken`.\n * @internal\n */\nexport class MsalClientSecret extends MsalNode {\n constructor(options: MsalClientSecretOptions) {\n super(options);\n this.requiresConfidential = true;\n this.msalConfig.auth.clientSecret = options.clientSecret;\n }\n\n protected async doGetToken(\n scopes: string[],\n options: CredentialFlowGetTokenOptions = {},\n ): Promise<AccessToken> {\n try {\n const result = await this.getApp(\n \"confidential\",\n options.enableCae,\n ).acquireTokenByClientCredential({\n scopes,\n correlationId: options.correlationId,\n azureRegion: this.azureRegion,\n authority: options.authority,\n claims: options.claims,\n });\n // The Client Credential flow does not return an account,\n // so each time getToken gets called, we will have to acquire a new token through the service.\n return this.handleResult(scopes, result || undefined);\n } catch (err: any) {\n throw handleMsalError(scopes, err, options);\n }\n }\n}\n"]}
@@ -1,35 +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 device code client. Calls to the MSAL's public application's `acquireTokenByDeviceCode` during `doGetToken`.
7
- * @internal
8
- */
9
- export class MsalDeviceCode extends MsalNode {
10
- constructor(options) {
11
- super(options);
12
- this.userPromptCallback = options.userPromptCallback;
13
- }
14
- async doGetToken(scopes, options) {
15
- try {
16
- const requestOptions = {
17
- deviceCodeCallback: this.userPromptCallback,
18
- scopes,
19
- cancel: false,
20
- correlationId: options === null || options === void 0 ? void 0 : options.correlationId,
21
- authority: options === null || options === void 0 ? void 0 : options.authority,
22
- claims: options === null || options === void 0 ? void 0 : options.claims,
23
- };
24
- const promise = this.getApp("public", options === null || options === void 0 ? void 0 : options.enableCae).acquireTokenByDeviceCode(requestOptions);
25
- const deviceResponse = await this.withCancellation(promise, options === null || options === void 0 ? void 0 : options.abortSignal, () => {
26
- requestOptions.cancel = true;
27
- });
28
- return this.handleResult(scopes, deviceResponse || undefined);
29
- }
30
- catch (error) {
31
- throw handleMsalError(scopes, error, options);
32
- }
33
- }
34
- }
35
- //# sourceMappingURL=msalDeviceCode.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"msalDeviceCode.js","sourceRoot":"","sources":["../../../../src/msal/nodeFlows/msalDeviceCode.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAIlC,OAAO,EAAE,QAAQ,EAAmB,MAAM,kBAAkB,CAAC;AAK7D,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAU3C;;;GAGG;AACH,MAAM,OAAO,cAAe,SAAQ,QAAQ;IAG1C,YAAY,OAA8B;QACxC,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,kBAAkB,GAAG,OAAO,CAAC,kBAAkB,CAAC;IACvD,CAAC;IAES,KAAK,CAAC,UAAU,CACxB,MAAgB,EAChB,OAAuC;QAEvC,IAAI,CAAC;YACH,MAAM,cAAc,GAA+B;gBACjD,kBAAkB,EAAE,IAAI,CAAC,kBAAkB;gBAC3C,MAAM;gBACN,MAAM,EAAE,KAAK;gBACb,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,OAAO,GAAG,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,SAAS,CAAC,CAAC,wBAAwB,CAChF,cAAc,CACf,CAAC;YACF,MAAM,cAAc,GAAG,MAAM,IAAI,CAAC,gBAAgB,CAAC,OAAO,EAAE,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,WAAW,EAAE,GAAG,EAAE;gBACrF,cAAc,CAAC,MAAM,GAAG,IAAI,CAAC;YAC/B,CAAC,CAAC,CAAC;YACH,OAAO,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE,cAAc,IAAI,SAAS,CAAC,CAAC;QAChE,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 { DeviceCodePromptCallback } from \"../../credentials/deviceCodeCredentialOptions\";\nimport { handleMsalError } from \"../utils\";\n\n/**\n * Options that can be passed to configure MSAL to handle authentication through device codes.\n * @internal\n */\nexport interface MsalDeviceCodeOptions extends MsalNodeOptions {\n userPromptCallback: DeviceCodePromptCallback;\n}\n\n/**\n * MSAL device code client. Calls to the MSAL's public application's `acquireTokenByDeviceCode` during `doGetToken`.\n * @internal\n */\nexport class MsalDeviceCode extends MsalNode {\n private userPromptCallback: DeviceCodePromptCallback;\n\n constructor(options: MsalDeviceCodeOptions) {\n super(options);\n this.userPromptCallback = options.userPromptCallback;\n }\n\n protected async doGetToken(\n scopes: string[],\n options?: CredentialFlowGetTokenOptions,\n ): Promise<AccessToken> {\n try {\n const requestOptions: msalNode.DeviceCodeRequest = {\n deviceCodeCallback: this.userPromptCallback,\n scopes,\n cancel: false,\n correlationId: options?.correlationId,\n authority: options?.authority,\n claims: options?.claims,\n };\n const promise = this.getApp(\"public\", options?.enableCae).acquireTokenByDeviceCode(\n requestOptions,\n );\n const deviceResponse = await this.withCancellation(promise, options?.abortSignal, () => {\n requestOptions.cancel = true;\n });\n return this.handleResult(scopes, deviceResponse || undefined);\n } catch (error: any) {\n throw handleMsalError(scopes, error, options);\n }\n }\n}\n"]}