@azure/identity 4.7.1-alpha.20250219.1 → 4.7.1-alpha.20250220.3
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +3 -1
- package/dist/browser/credentials/interactiveBrowserCredential-browser.d.mts.map +1 -1
- package/dist/browser/credentials/interactiveBrowserCredential-browser.mjs.map +1 -1
- package/dist/browser/credentials/interactiveBrowserCredential.d.ts +1 -1
- package/dist/browser/credentials/interactiveBrowserCredential.js +5 -5
- package/dist/browser/credentials/usernamePasswordCredential-browser.d.mts.map +1 -1
- package/dist/browser/credentials/usernamePasswordCredential-browser.mjs.map +1 -1
- package/dist/browser/credentials/usernamePasswordCredential.d.ts +2 -0
- package/dist/browser/credentials/usernamePasswordCredential.js +2 -0
- package/dist/browser/msal/browserFlows/msalBrowserCommon.d.ts +10 -97
- package/dist/browser/msal/browserFlows/msalBrowserCommon.d.ts.map +1 -1
- package/dist/browser/msal/browserFlows/msalBrowserCommon.js +235 -60
- package/dist/browser/msal/browserFlows/msalBrowserCommon.js.map +1 -1
- package/dist/browser/msal/browserFlows/msalBrowserOptions.d.ts +87 -0
- package/dist/browser/msal/browserFlows/msalBrowserOptions.d.ts.map +1 -0
- package/dist/{esm/msal/browserFlows/flows.js → browser/msal/browserFlows/msalBrowserOptions.js} +1 -1
- package/dist/browser/msal/browserFlows/msalBrowserOptions.js.map +1 -0
- package/dist/commonjs/credentials/usernamePasswordCredential.d.ts +2 -0
- package/dist/commonjs/credentials/usernamePasswordCredential.d.ts.map +1 -1
- package/dist/commonjs/credentials/usernamePasswordCredential.js +2 -0
- package/dist/commonjs/credentials/usernamePasswordCredential.js.map +1 -1
- package/dist/commonjs/msal/browserFlows/msalBrowserCommon.d.ts +10 -97
- package/dist/commonjs/msal/browserFlows/msalBrowserCommon.d.ts.map +1 -1
- package/dist/commonjs/msal/browserFlows/msalBrowserCommon.js +237 -63
- package/dist/commonjs/msal/browserFlows/msalBrowserCommon.js.map +1 -1
- package/dist/commonjs/msal/browserFlows/msalBrowserOptions.d.ts +87 -0
- package/dist/commonjs/msal/browserFlows/msalBrowserOptions.d.ts.map +1 -0
- package/dist/commonjs/msal/browserFlows/{flows.js → msalBrowserOptions.js} +1 -1
- package/dist/commonjs/msal/browserFlows/msalBrowserOptions.js.map +1 -0
- package/dist/esm/credentials/usernamePasswordCredential.d.ts +2 -0
- package/dist/esm/credentials/usernamePasswordCredential.d.ts.map +1 -1
- package/dist/esm/credentials/usernamePasswordCredential.js +2 -0
- package/dist/esm/credentials/usernamePasswordCredential.js.map +1 -1
- package/dist/esm/msal/browserFlows/msalBrowserCommon.d.ts +10 -97
- package/dist/esm/msal/browserFlows/msalBrowserCommon.d.ts.map +1 -1
- package/dist/esm/msal/browserFlows/msalBrowserCommon.js +235 -60
- package/dist/esm/msal/browserFlows/msalBrowserCommon.js.map +1 -1
- package/dist/esm/msal/browserFlows/msalBrowserOptions.d.ts +87 -0
- package/dist/esm/msal/browserFlows/msalBrowserOptions.d.ts.map +1 -0
- package/dist/{browser/msal/browserFlows/flows.js → esm/msal/browserFlows/msalBrowserOptions.js} +1 -1
- package/dist/esm/msal/browserFlows/msalBrowserOptions.js.map +1 -0
- package/package.json +2 -2
- package/dist/browser/msal/browserFlows/flows.d.ts +0 -42
- package/dist/browser/msal/browserFlows/flows.d.ts.map +0 -1
- package/dist/browser/msal/browserFlows/flows.js.map +0 -1
- package/dist/browser/msal/browserFlows/msalAuthCode.d.ts +0 -48
- package/dist/browser/msal/browserFlows/msalAuthCode.d.ts.map +0 -1
- package/dist/browser/msal/browserFlows/msalAuthCode.js +0 -203
- package/dist/browser/msal/browserFlows/msalAuthCode.js.map +0 -1
- package/dist/commonjs/msal/browserFlows/flows.d.ts +0 -42
- package/dist/commonjs/msal/browserFlows/flows.d.ts.map +0 -1
- package/dist/commonjs/msal/browserFlows/flows.js.map +0 -1
- package/dist/commonjs/msal/browserFlows/msalAuthCode.d.ts +0 -48
- package/dist/commonjs/msal/browserFlows/msalAuthCode.d.ts.map +0 -1
- package/dist/commonjs/msal/browserFlows/msalAuthCode.js +0 -208
- package/dist/commonjs/msal/browserFlows/msalAuthCode.js.map +0 -1
- package/dist/esm/msal/browserFlows/flows.d.ts +0 -42
- package/dist/esm/msal/browserFlows/flows.d.ts.map +0 -1
- package/dist/esm/msal/browserFlows/flows.js.map +0 -1
- package/dist/esm/msal/browserFlows/msalAuthCode.d.ts +0 -48
- package/dist/esm/msal/browserFlows/msalAuthCode.d.ts.map +0 -1
- package/dist/esm/msal/browserFlows/msalAuthCode.js +0 -203
- package/dist/esm/msal/browserFlows/msalAuthCode.js.map +0 -1
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"msalBrowserOptions.d.ts","sourceRoot":"","sources":["../../../../src/msal/browserFlows/msalBrowserOptions.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AACxD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,0DAA0D,CAAC;AAClG,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAClE,OAAO,KAAK,EAAE,iCAAiC,EAAE,MAAM,wDAAwD,CAAC;AAChH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAE9D;;;GAGG;AACH,MAAM,WAAW,sBAAsB;IACrC,MAAM,EAAE,gBAAgB,CAAC;IAEzB;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB;;;;OAIG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IAEvB;;;;;;;;;OASG;IACH,oBAAoB,CAAC,EAAE,oBAAoB,CAAC;IAE5C;;;OAGG;IACH,8BAA8B,CAAC,EAAE,OAAO,CAAC;IAEzC;;;;;;OAMG;IACH,wBAAwB,CAAC,EAAE,OAAO,CAAC;IAEnC;;OAEG;IACH,sBAAsB,EAAE,iCAAiC,CAAC;IAE1D;;;;OAIG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB;;;;;OAKG;IACH,UAAU,EAAE,iBAAiB,CAAC;IAE9B;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB;;OAEG;IACH,cAAc,CAAC,EAAE,gBAAgB,GAAG;QAClC;;WAEG;QACH,8BAA8B,CAAC,EAAE,OAAO,CAAC;QACzC;;WAEG;QACH,0BAA0B,CAAC,EAAE,OAAO,CAAC;KACtC,CAAC;CACH"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"msalBrowserOptions.js","sourceRoot":"","sources":["../../../../src/msal/browserFlows/msalBrowserOptions.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { AuthenticationRecord } from \"../types.js\";\nimport type { BrowserLoginStyle } from \"../../credentials/interactiveBrowserCredentialOptions.js\";\nimport type { LogPolicyOptions } from \"@azure/core-rest-pipeline\";\nimport type { MultiTenantTokenCredentialOptions } from \"../../credentials/multiTenantTokenCredentialOptions.js\";\nimport type { CredentialLogger } from \"../../util/logging.js\";\n\n/**\n * Options for the MSAL browser flows.\n * @internal\n */\nexport interface MsalBrowserFlowOptions {\n logger: CredentialLogger;\n\n /**\n * The Client ID of the Microsoft Entra application that users will sign into.\n * This parameter is required on the browser.\n */\n clientId?: string;\n\n /**\n * The Microsoft Entra tenant (directory) ID.\n */\n tenantId?: string;\n\n /**\n * The authority host to use for authentication requests.\n * Possible values are available through {@link AzureAuthorityHosts}.\n * The default is \"https://login.microsoftonline.com\".\n */\n authorityHost?: string;\n\n /**\n * Result of a previous authentication that can be used to retrieve the cached credentials of each individual account.\n * This is necessary to provide in case the application wants to work with more than one account per\n * Client ID and Tenant ID pair.\n *\n * This record can be retrieved by calling to the credential's `authenticate()` method, as follows:\n *\n * const authenticationRecord = await credential.authenticate();\n *\n */\n authenticationRecord?: AuthenticationRecord;\n\n /**\n * Makes getToken throw if a manual authentication is necessary.\n * Developers will need to call to `authenticate()` to control when to manually authenticate.\n */\n disableAutomaticAuthentication?: boolean;\n\n /**\n * The field determines whether instance discovery is performed when attempting to authenticate.\n * Setting this to `true` will completely disable both instance discovery and authority validation.\n * As a result, it's crucial to ensure that the configured authority host is valid and trustworthy.\n * This functionality is intended for use in scenarios where the metadata endpoint cannot be reached, such as in private clouds or Azure Stack.\n * The process of instance discovery entails retrieving authority metadata from https://login.microsoft.com/ to validate the authority.\n */\n disableInstanceDiscovery?: boolean;\n\n /**\n * Options for multi-tenant applications which allows for additionally allowed tenants.\n */\n tokenCredentialOptions: MultiTenantTokenCredentialOptions;\n\n /**\n * Gets the redirect URI of the application. This should be same as the value\n * in the application registration portal. Defaults to `window.location.href`.\n * This field is no longer required for Node.js.\n */\n redirectUri?: string;\n\n /**\n * Specifies whether a redirect or a popup window should be used to\n * initiate the user authentication flow. Possible values are \"redirect\"\n * or \"popup\" (default) for browser and \"popup\" (default) for node.\n *\n */\n loginStyle: BrowserLoginStyle;\n\n /**\n * loginHint allows a user name to be pre-selected for interactive logins.\n * Setting this option skips the account selection prompt and immediately attempts to login with the specified account.\n */\n loginHint?: string;\n\n /**\n * Allows users to configure settings for logging policy options, allow logging account information and personally identifiable information for customer support.\n */\n loggingOptions?: LogPolicyOptions & {\n /**\n * Allows logging account information once the authentication flow succeeds.\n */\n allowLoggingAccountIdentifiers?: boolean;\n /**\n * Allows logging personally identifiable information for customer support.\n */\n enableUnsafeSupportLogging?: boolean;\n };\n}\n"]}
|
@@ -22,6 +22,8 @@ export declare class UsernamePasswordCredential implements TokenCredential {
|
|
22
22
|
* @param username - The user account's e-mail address (user name).
|
23
23
|
* @param password - The user account's account password
|
24
24
|
* @param options - Options for configuring the client which makes the authentication request.
|
25
|
+
*
|
26
|
+
* @deprecated UsernamePasswordCredential is deprecated. Use a more secure credential. See https://aka.ms/azsdk/identity/mfa for details.
|
25
27
|
*/
|
26
28
|
constructor(tenantId: string, clientId: string, username: string, password: string, options?: UsernamePasswordCredentialOptions);
|
27
29
|
/**
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"usernamePasswordCredential.d.ts","sourceRoot":"","sources":["../../../src/credentials/usernamePasswordCredential.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAStF,OAAO,KAAK,EAAE,iCAAiC,EAAE,MAAM,wCAAwC,CAAC;AAOhG;;;;;GAKG;AACH,qBAAa,0BAA2B,YAAW,eAAe;IAChE,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,4BAA4B,CAAW;IAC/C,OAAO,CAAC,UAAU,CAAa;IAC/B,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,QAAQ,CAAS;IAEzB
|
1
|
+
{"version":3,"file":"usernamePasswordCredential.d.ts","sourceRoot":"","sources":["../../../src/credentials/usernamePasswordCredential.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAStF,OAAO,KAAK,EAAE,iCAAiC,EAAE,MAAM,wCAAwC,CAAC;AAOhG;;;;;GAKG;AACH,qBAAa,0BAA2B,YAAW,eAAe;IAChE,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,4BAA4B,CAAW;IAC/C,OAAO,CAAC,UAAU,CAAa;IAC/B,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,QAAQ,CAAS;IAEzB;;;;;;;;;;;;OAYG;gBAED,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM,EAChB,OAAO,GAAE,iCAAsC;IAwCjD;;;;;;;;;;;OAWG;IACG,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,EAAE,OAAO,GAAE,eAAoB,GAAG,OAAO,CAAC,WAAW,CAAC;CAsB/F"}
|
@@ -24,6 +24,8 @@ export class UsernamePasswordCredential {
|
|
24
24
|
* @param username - The user account's e-mail address (user name).
|
25
25
|
* @param password - The user account's account password
|
26
26
|
* @param options - Options for configuring the client which makes the authentication request.
|
27
|
+
*
|
28
|
+
* @deprecated UsernamePasswordCredential is deprecated. Use a more secure credential. See https://aka.ms/azsdk/identity/mfa for details.
|
27
29
|
*/
|
28
30
|
constructor(tenantId, clientId, username, password, options = {}) {
|
29
31
|
if (!tenantId) {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"usernamePasswordCredential.js","sourceRoot":"","sources":["../../../src/credentials/usernamePasswordCredential.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAIlC,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACnE,OAAO,EACL,yBAAyB,EACzB,mCAAmC,GACpC,MAAM,0BAA0B,CAAC;AAElC,OAAO,EAAE,0BAA0B,EAAE,MAAM,cAAc,CAAC;AAE1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAEnD,MAAM,MAAM,GAAG,gBAAgB,CAAC,4BAA4B,CAAC,CAAC;AAE9D;;;;;GAKG;AACH,MAAM,OAAO,0BAA0B;IAOrC
|
1
|
+
{"version":3,"file":"usernamePasswordCredential.js","sourceRoot":"","sources":["../../../src/credentials/usernamePasswordCredential.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAIlC,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACnE,OAAO,EACL,yBAAyB,EACzB,mCAAmC,GACpC,MAAM,0BAA0B,CAAC;AAElC,OAAO,EAAE,0BAA0B,EAAE,MAAM,cAAc,CAAC;AAE1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAEnD,MAAM,MAAM,GAAG,gBAAgB,CAAC,4BAA4B,CAAC,CAAC;AAE9D;;;;;GAKG;AACH,MAAM,OAAO,0BAA0B;IAOrC;;;;;;;;;;;;OAYG;IACH,YACE,QAAgB,EAChB,QAAgB,EAChB,QAAgB,EAChB,QAAgB,EAChB,UAA6C,EAAE;QAE/C,IAAI,CAAC,QAAQ,EAAE,CAAC;YACd,MAAM,IAAI,0BAA0B,CAClC,gKAAgK,CACjK,CAAC;QACJ,CAAC;QAED,IAAI,CAAC,QAAQ,EAAE,CAAC;YACd,MAAM,IAAI,0BAA0B,CAClC,gKAAgK,CACjK,CAAC;QACJ,CAAC;QAED,IAAI,CAAC,QAAQ,EAAE,CAAC;YACd,MAAM,IAAI,0BAA0B,CAClC,gKAAgK,CACjK,CAAC;QACJ,CAAC;QAED,IAAI,CAAC,QAAQ,EAAE,CAAC;YACd,MAAM,IAAI,0BAA0B,CAClC,gKAAgK,CACjK,CAAC;QACJ,CAAC;QAED,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,4BAA4B,GAAG,mCAAmC,CACrE,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,0BAA0B,CACpC,CAAC;QAEF,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QAEzB,IAAI,CAAC,UAAU,GAAG,gBAAgB,CAAC,QAAQ,EAAE,IAAI,CAAC,QAAQ,kCACrD,OAAO,KACV,sBAAsB,EAAE,OAAO,aAAP,OAAO,cAAP,OAAO,GAAI,EAAE,IACrC,CAAC;IACL,CAAC;IAED;;;;;;;;;;;OAWG;IACH,KAAK,CAAC,QAAQ,CAAC,MAAyB,EAAE,UAA2B,EAAE;QACrE,OAAO,aAAa,CAAC,QAAQ,CAC3B,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,WAAW,EACnC,OAAO,EACP,KAAK,EAAE,UAAU,EAAE,EAAE;YACnB,UAAU,CAAC,QAAQ,GAAG,yBAAyB,CAC7C,IAAI,CAAC,QAAQ,EACb,UAAU,EACV,IAAI,CAAC,4BAA4B,EACjC,MAAM,CACP,CAAC;YAEF,MAAM,WAAW,GAAG,YAAY,CAAC,MAAM,CAAC,CAAC;YACzC,OAAO,IAAI,CAAC,UAAU,CAAC,0BAA0B,CAC/C,WAAW,EACX,IAAI,CAAC,QAAQ,EACb,IAAI,CAAC,QAAQ,EACb,UAAU,CACX,CAAC;QACJ,CAAC,CACF,CAAC;IACJ,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { AccessToken, GetTokenOptions, TokenCredential } from \"@azure/core-auth\";\nimport type { MsalClient } from \"../msal/nodeFlows/msalClient.js\";\nimport { createMsalClient } from \"../msal/nodeFlows/msalClient.js\";\nimport {\n processMultiTenantRequest,\n resolveAdditionallyAllowedTenantIds,\n} from \"../util/tenantIdUtils.js\";\n\nimport { CredentialUnavailableError } from \"../errors.js\";\nimport type { UsernamePasswordCredentialOptions } from \"./usernamePasswordCredentialOptions.js\";\nimport { credentialLogger } from \"../util/logging.js\";\nimport { ensureScopes } from \"../util/scopeUtils.js\";\nimport { tracingClient } from \"../util/tracing.js\";\n\nconst logger = credentialLogger(\"UsernamePasswordCredential\");\n\n/**\n * Enables authentication to Microsoft Entra ID with a user's\n * username and password. This credential requires a high degree of\n * trust so you should only use it when other, more secure credential\n * types can't be used.\n */\nexport class UsernamePasswordCredential implements TokenCredential {\n private tenantId: string;\n private additionallyAllowedTenantIds: string[];\n private msalClient: MsalClient;\n private username: string;\n private password: string;\n\n /**\n * Creates an instance of the UsernamePasswordCredential with the details\n * needed to authenticate against Microsoft Entra ID with a username\n * and password.\n *\n * @param tenantId - The Microsoft Entra tenant (directory).\n * @param clientId - The client (application) ID of an App Registration in the tenant.\n * @param username - The user account's e-mail address (user name).\n * @param password - The user account's account password\n * @param options - Options for configuring the client which makes the authentication request.\n *\n * @deprecated UsernamePasswordCredential is deprecated. Use a more secure credential. See https://aka.ms/azsdk/identity/mfa for details.\n */\n constructor(\n tenantId: string,\n clientId: string,\n username: string,\n password: string,\n options: UsernamePasswordCredentialOptions = {},\n ) {\n if (!tenantId) {\n throw new CredentialUnavailableError(\n \"UsernamePasswordCredential: tenantId is a required parameter. To troubleshoot, visit https://aka.ms/azsdk/js/identity/usernamepasswordcredential/troubleshoot.\",\n );\n }\n\n if (!clientId) {\n throw new CredentialUnavailableError(\n \"UsernamePasswordCredential: clientId is a required parameter. To troubleshoot, visit https://aka.ms/azsdk/js/identity/usernamepasswordcredential/troubleshoot.\",\n );\n }\n\n if (!username) {\n throw new CredentialUnavailableError(\n \"UsernamePasswordCredential: username is a required parameter. To troubleshoot, visit https://aka.ms/azsdk/js/identity/usernamepasswordcredential/troubleshoot.\",\n );\n }\n\n if (!password) {\n throw new CredentialUnavailableError(\n \"UsernamePasswordCredential: password is a required parameter. To troubleshoot, visit https://aka.ms/azsdk/js/identity/usernamepasswordcredential/troubleshoot.\",\n );\n }\n\n this.tenantId = tenantId;\n this.additionallyAllowedTenantIds = resolveAdditionallyAllowedTenantIds(\n options?.additionallyAllowedTenants,\n );\n\n this.username = username;\n this.password = password;\n\n this.msalClient = createMsalClient(clientId, this.tenantId, {\n ...options,\n tokenCredentialOptions: options ?? {},\n });\n }\n\n /**\n * Authenticates with Microsoft Entra ID and returns an access token if successful.\n * If authentication fails, a {@link CredentialUnavailableError} will be thrown with the details of the failure.\n *\n * If the user provided the option `disableAutomaticAuthentication`,\n * once the token can't be retrieved silently,\n * this method won't attempt to request user interaction to retrieve the token.\n *\n * @param scopes - The list of scopes for which the token will have access.\n * @param options - The options used to configure any requests this\n * TokenCredential implementation might make.\n */\n async getToken(scopes: string | string[], options: GetTokenOptions = {}): Promise<AccessToken> {\n return tracingClient.withSpan(\n `${this.constructor.name}.getToken`,\n options,\n async (newOptions) => {\n newOptions.tenantId = processMultiTenantRequest(\n this.tenantId,\n newOptions,\n this.additionallyAllowedTenantIds,\n logger,\n );\n\n const arrayScopes = ensureScopes(scopes);\n return this.msalClient.getTokenByUsernamePassword(\n arrayScopes,\n this.username,\n this.password,\n newOptions,\n );\n },\n );\n }\n}\n"]}
|
@@ -1,106 +1,19 @@
|
|
1
|
-
import type
|
2
|
-
import type { AccessToken
|
3
|
-
import type { AuthenticationRecord
|
4
|
-
import type { CredentialLogger } from "../../util/logging.js";
|
5
|
-
import type { MsalFlow, MsalFlowOptions } from "./flows.js";
|
6
|
-
import type { BrowserLoginStyle } from "../../credentials/interactiveBrowserCredentialOptions.js";
|
1
|
+
import type { MsalBrowserFlowOptions } from "./msalBrowserOptions.js";
|
2
|
+
import type { AccessToken } from "@azure/core-auth";
|
3
|
+
import type { AuthenticationRecord } from "../types.js";
|
7
4
|
import type { CredentialFlowGetTokenOptions } from "../credentials.js";
|
8
|
-
import type { LogPolicyOptions } from "@azure/core-rest-pipeline";
|
9
|
-
import type { MultiTenantTokenCredentialOptions } from "../../credentials/multiTenantTokenCredentialOptions.js";
|
10
5
|
/**
|
11
|
-
*
|
12
|
-
* Some properties might not be used by some flow types.
|
13
|
-
*/
|
14
|
-
export interface MsalBrowserFlowOptions extends MsalFlowOptions {
|
15
|
-
tokenCredentialOptions: MultiTenantTokenCredentialOptions;
|
16
|
-
redirectUri?: string;
|
17
|
-
loginStyle: BrowserLoginStyle;
|
18
|
-
loginHint?: string;
|
19
|
-
/**
|
20
|
-
* Allows users to configure settings for logging policy options, allow logging account information and personally identifiable information for customer support.
|
21
|
-
*/
|
22
|
-
loggingOptions?: LogPolicyOptions & {
|
23
|
-
/**
|
24
|
-
* Allows logging account information once the authentication flow succeeds.
|
25
|
-
*/
|
26
|
-
allowLoggingAccountIdentifiers?: boolean;
|
27
|
-
/**
|
28
|
-
* Allows logging personally identifiable information for customer support.
|
29
|
-
*/
|
30
|
-
enableUnsafeSupportLogging?: boolean;
|
31
|
-
};
|
32
|
-
}
|
33
|
-
/**
|
34
|
-
* The common methods we use to work with the MSAL browser flows.
|
6
|
+
* Methods that are used by InteractiveBrowserCredential
|
35
7
|
* @internal
|
36
8
|
*/
|
37
|
-
export interface
|
38
|
-
|
39
|
-
|
9
|
+
export interface MsalBrowserClient {
|
10
|
+
getActiveAccount(): Promise<AuthenticationRecord | undefined>;
|
11
|
+
getToken(scopes: string[], options: CredentialFlowGetTokenOptions): Promise<AccessToken>;
|
40
12
|
}
|
41
13
|
/**
|
42
|
-
*
|
14
|
+
* Uses MSAL Browser 2.X for browser authentication,
|
15
|
+
* which uses the [Auth Code Flow](https://learn.microsoft.com/en-us/azure/active-directory/develop/v2-oauth2-auth-code-flow).
|
43
16
|
* @internal
|
44
17
|
*/
|
45
|
-
export declare function
|
46
|
-
/**
|
47
|
-
* MSAL partial base client for the browsers.
|
48
|
-
*
|
49
|
-
* It completes the input configuration with some default values.
|
50
|
-
* It also provides with utility protected methods that can be used from any of the clients,
|
51
|
-
* which includes handlers for successful responses and errors.
|
52
|
-
*
|
53
|
-
* @internal
|
54
|
-
*/
|
55
|
-
export declare abstract class MsalBrowser implements MsalBrowserFlow {
|
56
|
-
protected loginStyle: BrowserLoginStyle;
|
57
|
-
protected clientId: string;
|
58
|
-
protected tenantId: string;
|
59
|
-
protected additionallyAllowedTenantIds: string[];
|
60
|
-
protected authorityHost?: string;
|
61
|
-
protected account: AuthenticationRecord | undefined;
|
62
|
-
protected msalConfig: msalBrowser.Configuration;
|
63
|
-
protected disableAutomaticAuthentication?: boolean;
|
64
|
-
protected app?: msalBrowser.IPublicClientApplication;
|
65
|
-
protected logger: CredentialLogger;
|
66
|
-
constructor(options: MsalBrowserFlowOptions);
|
67
|
-
/**
|
68
|
-
* In the browsers we don't need to init()
|
69
|
-
*/
|
70
|
-
init(): Promise<void>;
|
71
|
-
/**
|
72
|
-
* Attempts to handle a redirection request the least amount of times possible.
|
73
|
-
*/
|
74
|
-
abstract handleRedirect(): Promise<AuthenticationRecord | undefined>;
|
75
|
-
/**
|
76
|
-
* Clears MSAL's cache.
|
77
|
-
*/
|
78
|
-
logout(): Promise<void>;
|
79
|
-
/**
|
80
|
-
* Uses MSAL to retrieve the active account.
|
81
|
-
*/
|
82
|
-
abstract getActiveAccount(): Promise<AuthenticationRecord | undefined>;
|
83
|
-
/**
|
84
|
-
* Uses MSAL to trigger a redirect or a popup login.
|
85
|
-
*/
|
86
|
-
abstract login(scopes?: string | string[]): Promise<AuthenticationRecord | undefined>;
|
87
|
-
/**
|
88
|
-
* Attempts to retrieve a token from cache.
|
89
|
-
*/
|
90
|
-
abstract getTokenSilent(scopes: string[]): Promise<AccessToken>;
|
91
|
-
/**
|
92
|
-
* Attempts to retrieve the token in the browser.
|
93
|
-
*/
|
94
|
-
protected abstract doGetToken(scopes: string[]): Promise<AccessToken>;
|
95
|
-
/**
|
96
|
-
* Attempts to retrieve an authenticated token from MSAL.
|
97
|
-
*/
|
98
|
-
getToken(scopes: string[], options?: CredentialFlowGetTokenOptions): Promise<AccessToken>;
|
99
|
-
/**
|
100
|
-
* Handles the MSAL authentication result.
|
101
|
-
* If the result has an account, we update the local account reference.
|
102
|
-
* If the token received is invalid, an error will be thrown depending on what's missing.
|
103
|
-
*/
|
104
|
-
protected handleResult(scopes: string | string[], result?: MsalResult, getTokenOptions?: GetTokenOptions): AccessToken;
|
105
|
-
}
|
18
|
+
export declare function createMsalBrowserClient(options: MsalBrowserFlowOptions): MsalBrowserClient;
|
106
19
|
//# sourceMappingURL=msalBrowserCommon.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"msalBrowserCommon.d.ts","sourceRoot":"","sources":["../../../../src/msal/browserFlows/msalBrowserCommon.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"msalBrowserCommon.d.ts","sourceRoot":"","sources":["../../../../src/msal/browserFlows/msalBrowserCommon.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AAYtE,OAAO,KAAK,EAAE,WAAW,EAAmB,MAAM,kBAAkB,CAAC;AACrE,OAAO,KAAK,EAAE,oBAAoB,EAAc,MAAM,aAAa,CAAC;AAEpE,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,mBAAmB,CAAC;AA2CvE;;;GAGG;AACH,MAAM,WAAW,iBAAiB;IAChC,gBAAgB,IAAI,OAAO,CAAC,oBAAoB,GAAG,SAAS,CAAC,CAAC;IAC9D,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,6BAA6B,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC;CAC1F;AAKD;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,sBAAsB,GAAG,iBAAiB,CA+R1F"}
|
@@ -1,15 +1,18 @@
|
|
1
1
|
// Copyright (c) Microsoft Corporation.
|
2
2
|
// Licensed under the MIT License.
|
3
|
+
import * as msalBrowser from "@azure/msal-browser";
|
4
|
+
import { defaultLoggerCallback, ensureValidMsalToken, getAuthority, getKnownAuthorities, getMSALLogLevel, handleMsalError, msalToPublic, publicToMsal, } from "../utils.js";
|
3
5
|
import { AuthenticationRequiredError, CredentialUnavailableError } from "../../errors.js";
|
6
|
+
import { getLogLevel } from "@azure/logger";
|
4
7
|
import { formatSuccess } from "../../util/logging.js";
|
5
|
-
import { ensureValidMsalToken, getAuthority, getKnownAuthorities, msalToPublic } from "../utils.js";
|
6
8
|
import { processMultiTenantRequest, resolveAdditionallyAllowedTenantIds, resolveTenantId, } from "../../util/tenantIdUtils.js";
|
7
9
|
import { DefaultTenantId } from "../../constants.js";
|
8
10
|
/**
|
9
11
|
* Generates a MSAL configuration that generally works for browsers
|
10
12
|
* @internal
|
11
13
|
*/
|
12
|
-
|
14
|
+
function generateMsalBrowserConfiguration(options) {
|
15
|
+
var _a;
|
13
16
|
const tenantId = options.tenantId || DefaultTenantId;
|
14
17
|
const authority = getAuthority(tenantId, options.authorityHost);
|
15
18
|
return {
|
@@ -22,89 +25,124 @@ export function defaultBrowserMsalConfig(options) {
|
|
22
25
|
// we can try to use the current page we're in as a default value.
|
23
26
|
redirectUri: options.redirectUri || self.location.origin,
|
24
27
|
},
|
28
|
+
cache: {
|
29
|
+
cacheLocation: "sessionStorage",
|
30
|
+
storeAuthStateInCookie: true, // Set to true to improve the experience on IE11 and Edge.
|
31
|
+
},
|
32
|
+
system: {
|
33
|
+
loggerOptions: {
|
34
|
+
loggerCallback: defaultLoggerCallback(options.logger, "Browser"),
|
35
|
+
logLevel: getMSALLogLevel(getLogLevel()),
|
36
|
+
piiLoggingEnabled: (_a = options.loggingOptions) === null || _a === void 0 ? void 0 : _a.enableUnsafeSupportLogging,
|
37
|
+
},
|
38
|
+
},
|
25
39
|
};
|
26
40
|
}
|
41
|
+
// We keep a copy of the redirect hash.
|
42
|
+
const redirectHash = self.location.hash;
|
27
43
|
/**
|
28
|
-
* MSAL
|
29
|
-
*
|
30
|
-
* It completes the input configuration with some default values.
|
31
|
-
* It also provides with utility protected methods that can be used from any of the clients,
|
32
|
-
* which includes handlers for successful responses and errors.
|
33
|
-
*
|
44
|
+
* Uses MSAL Browser 2.X for browser authentication,
|
45
|
+
* which uses the [Auth Code Flow](https://learn.microsoft.com/en-us/azure/active-directory/develop/v2-oauth2-auth-code-flow).
|
34
46
|
* @internal
|
35
47
|
*/
|
36
|
-
export
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
if (!options.clientId) {
|
42
|
-
throw new CredentialUnavailableError("A client ID is required in browsers");
|
43
|
-
}
|
44
|
-
this.clientId = options.clientId;
|
45
|
-
this.additionallyAllowedTenantIds = resolveAdditionallyAllowedTenantIds((_a = options === null || options === void 0 ? void 0 : options.tokenCredentialOptions) === null || _a === void 0 ? void 0 : _a.additionallyAllowedTenants);
|
46
|
-
this.tenantId = resolveTenantId(this.logger, options.tenantId, options.clientId);
|
47
|
-
this.authorityHost = options.authorityHost;
|
48
|
-
this.msalConfig = defaultBrowserMsalConfig(options);
|
49
|
-
this.disableAutomaticAuthentication = options.disableAutomaticAuthentication;
|
50
|
-
if (options.authenticationRecord) {
|
51
|
-
this.account = Object.assign(Object.assign({}, options.authenticationRecord), { tenantId: this.tenantId });
|
52
|
-
}
|
48
|
+
export function createMsalBrowserClient(options) {
|
49
|
+
var _a;
|
50
|
+
const loginStyle = options.loginStyle;
|
51
|
+
if (!options.clientId) {
|
52
|
+
throw new CredentialUnavailableError("A client ID is required in browsers");
|
53
53
|
}
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
54
|
+
const clientId = options.clientId;
|
55
|
+
const logger = options.logger;
|
56
|
+
const tenantId = resolveTenantId(logger, options.tenantId, options.clientId);
|
57
|
+
const additionallyAllowedTenantIds = resolveAdditionallyAllowedTenantIds((_a = options === null || options === void 0 ? void 0 : options.tokenCredentialOptions) === null || _a === void 0 ? void 0 : _a.additionallyAllowedTenants);
|
58
|
+
const authorityHost = options.authorityHost;
|
59
|
+
const msalConfig = generateMsalBrowserConfiguration(options);
|
60
|
+
const disableAutomaticAuthentication = options.disableAutomaticAuthentication;
|
61
|
+
const loginHint = options.loginHint;
|
62
|
+
let account;
|
63
|
+
if (options.authenticationRecord) {
|
64
|
+
account = Object.assign(Object.assign({}, options.authenticationRecord), { tenantId });
|
59
65
|
}
|
66
|
+
// This variable should only be used through calling `getApp` function
|
67
|
+
let app;
|
60
68
|
/**
|
61
|
-
*
|
69
|
+
* Return the MSAL account if not set yet
|
70
|
+
* @returns MSAL application
|
62
71
|
*/
|
63
|
-
async
|
64
|
-
|
65
|
-
|
72
|
+
async function getApp() {
|
73
|
+
if (!app) {
|
74
|
+
// Prepare the MSAL application
|
75
|
+
app = await msalBrowser.PublicClientApplication.createPublicClientApplication(msalConfig);
|
76
|
+
// setting the account right after the app is created.
|
77
|
+
if (account) {
|
78
|
+
app.setActiveAccount(publicToMsal(account));
|
79
|
+
}
|
80
|
+
}
|
81
|
+
return app;
|
66
82
|
}
|
67
83
|
/**
|
68
|
-
*
|
84
|
+
* Loads the account based on the result of the authentication.
|
85
|
+
* If no result was received, tries to load the account from the cache.
|
86
|
+
* @param result - Result object received from MSAL.
|
69
87
|
*/
|
70
|
-
async
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
await this.handleRedirect();
|
78
|
-
if (!(await this.getActiveAccount()) && !this.disableAutomaticAuthentication) {
|
79
|
-
await this.login(scopes);
|
80
|
-
}
|
81
|
-
return this.getTokenSilent(scopes).catch((err) => {
|
82
|
-
if (err.name !== "AuthenticationRequiredError") {
|
83
|
-
throw err;
|
88
|
+
async function handleBrowserResult(result) {
|
89
|
+
try {
|
90
|
+
const msalApp = await getApp();
|
91
|
+
if (result && result.account) {
|
92
|
+
logger.info(`MSAL Browser V2 authentication successful.`);
|
93
|
+
msalApp.setActiveAccount(result.account);
|
94
|
+
return msalToPublic(clientId, result.account);
|
84
95
|
}
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
96
|
+
// If by this point we happen to have an active account, we should stop trying to parse this.
|
97
|
+
const activeAccount = msalApp.getActiveAccount();
|
98
|
+
if (activeAccount) {
|
99
|
+
return msalToPublic(clientId, activeAccount);
|
100
|
+
}
|
101
|
+
// If we don't have an active account, we try to activate it from all the already loaded accounts.
|
102
|
+
const allAccounts = app.getAllAccounts();
|
103
|
+
if (allAccounts.length > 1) {
|
104
|
+
// If there's more than one account in memory, we force the user to authenticate again.
|
105
|
+
// At this point we can't identify which account should this credential work with,
|
106
|
+
// since at this point the user won't have provided enough information.
|
107
|
+
// We log a message in case that helps.
|
108
|
+
logger.info(`More than one account was found authenticated for this Client ID and Tenant ID.
|
109
|
+
However, no "authenticationRecord" has been provided for this credential,
|
110
|
+
therefore we're unable to pick between these accounts.
|
111
|
+
A new login attempt will be requested, to ensure the correct account is picked.
|
112
|
+
To work with multiple accounts for the same Client ID and Tenant ID, please provide an "authenticationRecord" when initializing "InteractiveBrowserCredential".`);
|
113
|
+
// To safely trigger a new login, we're also ensuring the local cache is cleared up for this MSAL object.
|
114
|
+
// However, we want to avoid kicking the user out of their authentication on the Azure side.
|
115
|
+
// We do this by calling to logout while specifying a `onRedirectNavigate` that returns false.
|
116
|
+
await msalApp.logout({
|
117
|
+
onRedirectNavigate: () => false,
|
90
118
|
});
|
119
|
+
return;
|
91
120
|
}
|
92
|
-
this
|
93
|
-
|
94
|
-
|
121
|
+
// If there's only one account for this MSAL object, we can safely activate it.
|
122
|
+
if (allAccounts.length === 1) {
|
123
|
+
const msalAccount = allAccounts[0];
|
124
|
+
msalApp.setActiveAccount(msalAccount);
|
125
|
+
return msalToPublic(clientId, msalAccount);
|
126
|
+
}
|
127
|
+
logger.info(`No accounts were found through MSAL.`);
|
128
|
+
}
|
129
|
+
catch (e) {
|
130
|
+
logger.info(`Failed to acquire token through MSAL. ${e.message}`);
|
131
|
+
}
|
132
|
+
return;
|
95
133
|
}
|
96
134
|
/**
|
97
135
|
* Handles the MSAL authentication result.
|
98
136
|
* If the result has an account, we update the local account reference.
|
99
137
|
* If the token received is invalid, an error will be thrown depending on what's missing.
|
100
138
|
*/
|
101
|
-
handleResult(scopes, result, getTokenOptions) {
|
139
|
+
function handleResult(scopes, result, getTokenOptions) {
|
102
140
|
var _a;
|
103
141
|
if (result === null || result === void 0 ? void 0 : result.account) {
|
104
|
-
|
142
|
+
account = msalToPublic(clientId, result.account);
|
105
143
|
}
|
106
144
|
ensureValidMsalToken(scopes, result, getTokenOptions);
|
107
|
-
|
145
|
+
logger.getToken.info(formatSuccess(scopes));
|
108
146
|
return {
|
109
147
|
token: result.accessToken,
|
110
148
|
expiresOnTimestamp: result.expiresOn.getTime(),
|
@@ -112,5 +150,142 @@ export class MsalBrowser {
|
|
112
150
|
tokenType: "Bearer",
|
113
151
|
};
|
114
152
|
}
|
153
|
+
/**
|
154
|
+
* Uses MSAL to handle the redirect.
|
155
|
+
*/
|
156
|
+
async function handleRedirect() {
|
157
|
+
const msalApp = await getApp();
|
158
|
+
return handleBrowserResult((await msalApp.handleRedirectPromise(redirectHash)) || undefined);
|
159
|
+
}
|
160
|
+
/**
|
161
|
+
* Uses MSAL to retrieve the active account.
|
162
|
+
*/
|
163
|
+
async function getActiveAccount() {
|
164
|
+
const msalApp = await getApp();
|
165
|
+
const activeAccount = msalApp.getActiveAccount();
|
166
|
+
if (!activeAccount) {
|
167
|
+
return;
|
168
|
+
}
|
169
|
+
return msalToPublic(clientId, activeAccount);
|
170
|
+
}
|
171
|
+
/**
|
172
|
+
* Uses MSAL to trigger a redirect or a popup login.
|
173
|
+
*/
|
174
|
+
async function login(scopes = []) {
|
175
|
+
const arrayScopes = Array.isArray(scopes) ? scopes : [scopes];
|
176
|
+
const loginRequest = {
|
177
|
+
scopes: arrayScopes,
|
178
|
+
loginHint: loginHint,
|
179
|
+
};
|
180
|
+
const msalApp = await getApp();
|
181
|
+
switch (loginStyle) {
|
182
|
+
case "redirect": {
|
183
|
+
await app.loginRedirect(loginRequest);
|
184
|
+
return;
|
185
|
+
}
|
186
|
+
case "popup":
|
187
|
+
return handleBrowserResult(await msalApp.loginPopup(loginRequest));
|
188
|
+
}
|
189
|
+
}
|
190
|
+
/**
|
191
|
+
* Tries to retrieve the token silently using MSAL.
|
192
|
+
*/
|
193
|
+
async function getTokenSilent(scopes, getTokenOptions) {
|
194
|
+
const activeAccount = await getActiveAccount();
|
195
|
+
if (!activeAccount) {
|
196
|
+
throw new AuthenticationRequiredError({
|
197
|
+
scopes,
|
198
|
+
getTokenOptions,
|
199
|
+
message: "Silent authentication failed. We couldn't retrieve an active account from the cache.",
|
200
|
+
});
|
201
|
+
}
|
202
|
+
const parameters = {
|
203
|
+
authority: (getTokenOptions === null || getTokenOptions === void 0 ? void 0 : getTokenOptions.authority) || msalConfig.auth.authority,
|
204
|
+
correlationId: getTokenOptions === null || getTokenOptions === void 0 ? void 0 : getTokenOptions.correlationId,
|
205
|
+
claims: getTokenOptions === null || getTokenOptions === void 0 ? void 0 : getTokenOptions.claims,
|
206
|
+
account: publicToMsal(activeAccount),
|
207
|
+
forceRefresh: false,
|
208
|
+
scopes,
|
209
|
+
};
|
210
|
+
try {
|
211
|
+
logger.info("Attempting to acquire token silently");
|
212
|
+
const msalApp = await getApp();
|
213
|
+
const response = await msalApp.acquireTokenSilent(parameters);
|
214
|
+
return handleResult(scopes, response);
|
215
|
+
}
|
216
|
+
catch (err) {
|
217
|
+
throw handleMsalError(scopes, err, options);
|
218
|
+
}
|
219
|
+
}
|
220
|
+
/**
|
221
|
+
* Attempts to retrieve the token in the browser through interactive methods.
|
222
|
+
*/
|
223
|
+
async function getTokenInteractive(scopes, getTokenOptions) {
|
224
|
+
const activeAccount = await getActiveAccount();
|
225
|
+
if (!activeAccount) {
|
226
|
+
throw new AuthenticationRequiredError({
|
227
|
+
scopes,
|
228
|
+
getTokenOptions,
|
229
|
+
message: "Silent authentication failed. We couldn't retrieve an active account from the cache.",
|
230
|
+
});
|
231
|
+
}
|
232
|
+
const parameters = {
|
233
|
+
authority: (getTokenOptions === null || getTokenOptions === void 0 ? void 0 : getTokenOptions.authority) || msalConfig.auth.authority,
|
234
|
+
correlationId: getTokenOptions === null || getTokenOptions === void 0 ? void 0 : getTokenOptions.correlationId,
|
235
|
+
claims: getTokenOptions === null || getTokenOptions === void 0 ? void 0 : getTokenOptions.claims,
|
236
|
+
account: publicToMsal(activeAccount),
|
237
|
+
loginHint: loginHint,
|
238
|
+
scopes,
|
239
|
+
};
|
240
|
+
const msalApp = await getApp();
|
241
|
+
switch (loginStyle) {
|
242
|
+
case "redirect":
|
243
|
+
// This will go out of the page.
|
244
|
+
// Once the InteractiveBrowserCredential is initialized again,
|
245
|
+
// we'll load the MSAL account in the constructor.
|
246
|
+
await msalApp.acquireTokenRedirect(parameters);
|
247
|
+
return { token: "", expiresOnTimestamp: 0, tokenType: "Bearer" };
|
248
|
+
case "popup":
|
249
|
+
return handleResult(scopes, await app.acquireTokenPopup(parameters));
|
250
|
+
}
|
251
|
+
}
|
252
|
+
/**
|
253
|
+
* Attempts to get token through the silent flow.
|
254
|
+
* If failed, get token through interactive method with `doGetToken` method.
|
255
|
+
*/
|
256
|
+
async function getToken(scopes, getTokenOptions = {}) {
|
257
|
+
const getTokenTenantId = processMultiTenantRequest(tenantId, getTokenOptions, additionallyAllowedTenantIds) ||
|
258
|
+
tenantId;
|
259
|
+
if (!getTokenOptions.authority) {
|
260
|
+
getTokenOptions.authority = getAuthority(getTokenTenantId, authorityHost);
|
261
|
+
}
|
262
|
+
// We ensure that redirection is handled at this point.
|
263
|
+
await handleRedirect();
|
264
|
+
if (!(await getActiveAccount()) && !disableAutomaticAuthentication) {
|
265
|
+
await login(scopes);
|
266
|
+
}
|
267
|
+
// Attempts to get the token silently; else, falls back to interactive method.
|
268
|
+
try {
|
269
|
+
return await getTokenSilent(scopes, getTokenOptions);
|
270
|
+
}
|
271
|
+
catch (err) {
|
272
|
+
if (err.name !== "AuthenticationRequiredError") {
|
273
|
+
throw err;
|
274
|
+
}
|
275
|
+
if (getTokenOptions === null || getTokenOptions === void 0 ? void 0 : getTokenOptions.disableAutomaticAuthentication) {
|
276
|
+
throw new AuthenticationRequiredError({
|
277
|
+
scopes,
|
278
|
+
getTokenOptions,
|
279
|
+
message: "Automatic authentication has been disabled. You may call the authenticate() method.",
|
280
|
+
});
|
281
|
+
}
|
282
|
+
logger.info(`Silent authentication failed, falling back to interactive method ${loginStyle}`);
|
283
|
+
return getTokenInteractive(scopes, getTokenOptions);
|
284
|
+
}
|
285
|
+
}
|
286
|
+
return {
|
287
|
+
getActiveAccount,
|
288
|
+
getToken,
|
289
|
+
};
|
115
290
|
}
|
116
291
|
//# sourceMappingURL=msalBrowserCommon.js.map
|