Skip to content

Commit

Permalink
chore(credential-providers): unavailable browser credential providers…
Browse files Browse the repository at this point in the history
… throw at runtime
  • Loading branch information
kuhe committed Mar 1, 2024
1 parent 3a82d4c commit 8b7ac60
Showing 1 changed file with 42 additions and 1 deletion.
43 changes: 42 additions & 1 deletion packages/credential-providers/src/index.browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,47 @@ export * from "./fromCognitoIdentity";
export * from "./fromCognitoIdentityPool";
export { fromHttp } from "@aws-sdk/credential-provider-http";
export type { FromHttpOptions, HttpProviderCredentials } from "@aws-sdk/credential-provider-http";
export * from "./fromEnv";
export * from "./fromTemporaryCredentials";
export * from "./fromWebToken";

export const fromContainerMetadata = async () => {
notAvailable("fromContainerMetadata");
};

export const fromEnv = async () => {
notAvailable("fromEnv");
};

export const fromIni = async () => {
notAvailable("fromIni");
};

export const fromInstanceMetadata = async () => {
notAvailable("fromInstanceMetadata");
};

export const fromNodeProviderChain = async () => {
notAvailable("fromNodeProviderChain");
};

export const fromProcess = async () => {
notAvailable("fromProcess");
};

export const fromSSO = async () => {
notAvailable("fromSSO");
};

export const fromTokenFile = async () => {
notAvailable("fromTokenFile");
};

/**
* @internal
*/
const notAvailable = (name: string): never => {
throw new Error(
`${name} is not available in the browser mode or similar environment.
See https://www.npmjs.com/package/@aws-sdk/credential-providers for usage.`
);
};

0 comments on commit 8b7ac60

Please sign in to comment.