Skip to content

Commit

Permalink
Fix browser bundle issue
Browse files Browse the repository at this point in the history
PR Azure#7994 introduced a build break to rollup by referencing `process`
inside `DefaultAzureCredential`.

This fix adds a browser version of `DefaultAzureCredential` without the reference
to `process`.
  • Loading branch information
xirzec committed Mar 27, 2020
1 parent 2bb0575 commit a102c04
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
1 change: 1 addition & 0 deletions sdk/identity/identity/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"./dist-esm/src/credentials/managedIdentityCredential.js": "./dist-esm/src/credentials/managedIdentityCredential.browser.js",
"./dist-esm/src/credentials/clientCertificateCredential.js": "./dist-esm/src/credentials/clientCertificateCredential.browser.js",
"./dist-esm/src/credentials/deviceCodeCredential.js": "./dist-esm/src/credentials/deviceCodeCredential.browser.js",
"./dist-esm/src/credentials/defaultAzureCredential.js": "./dist-esm/src/credentials/defaultAzureCredential.browser.js",
"./dist-esm/src/credentials/authorizationCodeCredential.js": "./dist-esm/src/credentials/authorizationCodeCredential.browser.js",
"./dist-esm/src/credentials/interactiveBrowserCredential.js": "./dist-esm/src/credentials/interactiveBrowserCredential.browser.js",
"./dist-esm/src/credentials/vscodeCredential.js": "./dist-esm/src/credentials/vscodeCredential.browser.js"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

import { TokenCredentialOptions } from "../client/identityClient";
import { ChainedTokenCredential } from "./chainedTokenCredential";
import { EnvironmentCredential } from "./environmentCredential";
import { ManagedIdentityCredential } from "./managedIdentityCredential";
import { AzureCliCredential } from "./azureCliCredential";
import { VSCodeCredential } from "./vscodeCredential";

/**
* Provides a default {@link ChainedTokenCredential} configuration for
* applications that will be deployed to Azure. The following credential
* types will be tried, in order:
*
* - {@link EnvironmentCredential}
* - {@link ManagedIdentityCredential}
*
* Consult the documentation of these credential types for more information
* on how they attempt authentication.
*/
export class DefaultAzureCredential extends ChainedTokenCredential {
/**
* Creates an instance of the DefaultAzureCredential class.
*
* @param options Options for configuring the client which makes the authentication request.
*/
constructor(tokenCredentialOptions?: TokenCredentialOptions) {
let credentials = [];
credentials.push(new EnvironmentCredential(tokenCredentialOptions));
credentials.push(new ManagedIdentityCredential(tokenCredentialOptions));
credentials.push(new AzureCliCredential());
credentials.push(new VSCodeCredential(tokenCredentialOptions));

super(...credentials);
}
}

0 comments on commit a102c04

Please sign in to comment.