From 90d71223bc57dab03851898e4287480cb3263c5d Mon Sep 17 00:00:00 2001 From: George Fu Date: Fri, 13 Dec 2024 19:47:16 +0000 Subject: [PATCH] feat(credential-providers): rename types --- .../src/fromCognitoIdentity.ts | 4 ++-- packages/credential-provider-ini/src/fromIni.ts | 4 ++-- .../src/fromWebToken.ts | 4 ++-- .../src/createCredentialChain.spec.ts | 4 ++-- .../src/createCredentialChain.ts | 10 +++++----- packages/credential-providers/src/fromIni.ts | 4 ++-- .../middleware-signing/src/awsAuthConfiguration.ts | 8 ++++---- packages/token-providers/src/fromSso.ts | 4 ++-- .../types/src/identity/AwsCredentialIdentity.ts | 14 ++++++++------ 9 files changed, 29 insertions(+), 27 deletions(-) diff --git a/packages/credential-provider-cognito-identity/src/fromCognitoIdentity.ts b/packages/credential-provider-cognito-identity/src/fromCognitoIdentity.ts index db5e1b745ad4..13b75764b7d9 100644 --- a/packages/credential-provider-cognito-identity/src/fromCognitoIdentity.ts +++ b/packages/credential-provider-cognito-identity/src/fromCognitoIdentity.ts @@ -1,4 +1,4 @@ -import type { AwsIdentityProperties, CredentialProviderOptions, RegionalIdentityProvider } from "@aws-sdk/types"; +import type { AwsIdentityProperties, CredentialProviderOptions, RuntimeConfigIdentityProvider } from "@aws-sdk/types"; import { CredentialsProviderError } from "@smithy/property-provider"; import type { AwsCredentialIdentity, Logger } from "@smithy/types"; @@ -18,7 +18,7 @@ export interface CognitoIdentityCredentials extends AwsCredentialIdentity { /** * @internal */ -export type CognitoIdentityCredentialProvider = RegionalIdentityProvider; +export type CognitoIdentityCredentialProvider = RuntimeConfigIdentityProvider; /** * @internal diff --git a/packages/credential-provider-ini/src/fromIni.ts b/packages/credential-provider-ini/src/fromIni.ts index 9f6de87c5f85..d505746de1b6 100644 --- a/packages/credential-provider-ini/src/fromIni.ts +++ b/packages/credential-provider-ini/src/fromIni.ts @@ -1,6 +1,6 @@ import type { AssumeRoleWithWebIdentityParams } from "@aws-sdk/credential-provider-web-identity"; import type { CredentialProviderOptions } from "@aws-sdk/types"; -import type { RegionalAwsCredentialIdentityProvider } from "@aws-sdk/types"; +import type { RuntimeConfigAwsCredentialIdentityProvider } from "@aws-sdk/types"; import { getProfileName, parseKnownFiles, SourceProfileInit } from "@smithy/shared-ini-file-loader"; import type { AwsCredentialIdentity, Pluggable } from "@smithy/types"; @@ -56,7 +56,7 @@ export interface FromIniInit extends SourceProfileInit, CredentialProviderOption * role assumption and multi-factor authentication. */ export const fromIni = - (_init: FromIniInit = {}): RegionalAwsCredentialIdentityProvider => + (_init: FromIniInit = {}): RuntimeConfigAwsCredentialIdentityProvider => async ({ callerClientConfig } = {}) => { const init: FromIniInit = { ..._init, diff --git a/packages/credential-provider-web-identity/src/fromWebToken.ts b/packages/credential-provider-web-identity/src/fromWebToken.ts index d2edd9ca6cc1..41489ce7467c 100644 --- a/packages/credential-provider-web-identity/src/fromWebToken.ts +++ b/packages/credential-provider-web-identity/src/fromWebToken.ts @@ -1,7 +1,7 @@ import type { AwsIdentityProperties, CredentialProviderOptions, - RegionalAwsCredentialIdentityProvider, + RuntimeConfigAwsCredentialIdentityProvider, } from "@aws-sdk/types"; import type { AwsCredentialIdentity, Pluggable } from "@smithy/types"; @@ -155,7 +155,7 @@ export interface FromWebTokenInit * @internal */ export const fromWebToken = - (init: FromWebTokenInit): RegionalAwsCredentialIdentityProvider => + (init: FromWebTokenInit): RuntimeConfigAwsCredentialIdentityProvider => async (awsIdentityProperties?: AwsIdentityProperties) => { init.logger?.debug("@aws-sdk/credential-provider-web-identity - fromWebToken"); const { roleArn, roleSessionName, webIdentityToken, providerId, policyArns, policy, durationSeconds } = init; diff --git a/packages/credential-providers/src/createCredentialChain.spec.ts b/packages/credential-providers/src/createCredentialChain.spec.ts index 0cbee3d05553..e188c2e8d896 100644 --- a/packages/credential-providers/src/createCredentialChain.spec.ts +++ b/packages/credential-providers/src/createCredentialChain.spec.ts @@ -1,4 +1,4 @@ -import { RegionalAwsCredentialIdentityProvider } from "@aws-sdk/types"; +import { RuntimeConfigAwsCredentialIdentityProvider } from "@aws-sdk/types"; import { ProviderError } from "@smithy/property-provider"; import { AwsCredentialIdentity, AwsCredentialIdentityProvider } from "@smithy/types"; import { describe, expect, test as it } from "vitest"; @@ -82,7 +82,7 @@ describe(createCredentialChain.name, () => { }); it("is compatible with contextual-region-aware credential providers", async () => { - const provider: RegionalAwsCredentialIdentityProvider = async ({ callerClientConfig } = {}) => { + const provider: RuntimeConfigAwsCredentialIdentityProvider = async ({ callerClientConfig } = {}) => { return { accessKeyId: "", secretAccessKey: "", diff --git a/packages/credential-providers/src/createCredentialChain.ts b/packages/credential-providers/src/createCredentialChain.ts index 0c536436f1a8..6bc80f26cde5 100644 --- a/packages/credential-providers/src/createCredentialChain.ts +++ b/packages/credential-providers/src/createCredentialChain.ts @@ -1,7 +1,7 @@ import type { AwsIdentityProperties, - RegionalAwsCredentialIdentityProvider, - RegionalIdentityProvider, + RuntimeConfigAwsCredentialIdentityProvider, + RuntimeConfigIdentityProvider, } from "@aws-sdk/types"; import { ProviderError } from "@smithy/property-provider"; import type { AwsCredentialIdentityProvider } from "@smithy/types"; @@ -57,8 +57,8 @@ type Mutable = { * providers in sequence until one succeeds or all fail. */ export const createCredentialChain = ( - ...credentialProviders: RegionalAwsCredentialIdentityProvider[] -): RegionalAwsCredentialIdentityProvider & CustomCredentialChainOptions => { + ...credentialProviders: RuntimeConfigAwsCredentialIdentityProvider[] +): RuntimeConfigAwsCredentialIdentityProvider & CustomCredentialChainOptions => { let expireAfter = -1; const baseFunction = async (awsIdentityProperties?: AwsIdentityProperties) => { const credentials = await propertyProviderChain(...credentialProviders)(awsIdentityProperties); @@ -85,7 +85,7 @@ export const createCredentialChain = ( * @internal */ export const propertyProviderChain = - (...providers: Array>): RegionalIdentityProvider => + (...providers: Array>): RuntimeConfigIdentityProvider => async (awsIdentityProperties?: AwsIdentityProperties) => { if (providers.length === 0) { throw new ProviderError("No providers in chain"); diff --git a/packages/credential-providers/src/fromIni.ts b/packages/credential-providers/src/fromIni.ts index 6cc35a8c03ee..40b64511178c 100644 --- a/packages/credential-providers/src/fromIni.ts +++ b/packages/credential-providers/src/fromIni.ts @@ -1,5 +1,5 @@ import { fromIni as _fromIni, FromIniInit } from "@aws-sdk/credential-provider-ini"; -import type { RegionalAwsCredentialIdentityProvider } from "@aws-sdk/types"; +import type { RuntimeConfigAwsCredentialIdentityProvider } from "@aws-sdk/types"; /** * Creates a credential provider function that reads from a shared credentials file at `~/.aws/credentials` and a @@ -40,7 +40,7 @@ import type { RegionalAwsCredentialIdentityProvider } from "@aws-sdk/types"; * }); * ``` */ -export const fromIni = (init: FromIniInit = {}): RegionalAwsCredentialIdentityProvider => +export const fromIni = (init: FromIniInit = {}): RuntimeConfigAwsCredentialIdentityProvider => _fromIni({ ...init, }); diff --git a/packages/middleware-signing/src/awsAuthConfiguration.ts b/packages/middleware-signing/src/awsAuthConfiguration.ts index 12313d69b0b5..539f317441ee 100644 --- a/packages/middleware-signing/src/awsAuthConfiguration.ts +++ b/packages/middleware-signing/src/awsAuthConfiguration.ts @@ -1,4 +1,4 @@ -import type { AwsCredentialIdentityProvider, RegionalAwsCredentialIdentityProvider } from "@aws-sdk/types"; +import type { AwsCredentialIdentityProvider, RuntimeConfigAwsCredentialIdentityProvider } from "@aws-sdk/types"; import { memoize } from "@smithy/property-provider"; import { SignatureV4, SignatureV4CryptoInit, SignatureV4Init } from "@smithy/signature-v4"; import { @@ -293,7 +293,7 @@ export const resolveSigV4AuthConfig = ( * @deprecated only used in legacy auth. */ const normalizeCredentialProvider = ( - credentials: AwsCredentialIdentity | Provider | RegionalAwsCredentialIdentityProvider + credentials: AwsCredentialIdentity | Provider | RuntimeConfigAwsCredentialIdentityProvider ): MemoizedProvider => { if (typeof credentials === "function") { return memoize( @@ -315,7 +315,7 @@ const normalizeCredentialProvider = ( * a binding to the config itself. */ const createConfigBoundCredentialProvider = (input: { - credentials?: AwsCredentialIdentity | AwsCredentialIdentityProvider | RegionalAwsCredentialIdentityProvider; + credentials?: AwsCredentialIdentity | AwsCredentialIdentityProvider | RuntimeConfigAwsCredentialIdentityProvider; credentialDefaultProvider: PreviouslyResolved["credentialDefaultProvider"]; region: PreviouslyResolved["region"]; }): AwsCredentialIdentityProvider => { @@ -327,7 +327,7 @@ const createConfigBoundCredentialProvider = (input: { }) ); const normalizedCreds = async () => - (normalizedCredentialsProvider as RegionalAwsCredentialIdentityProvider)({ + (normalizedCredentialsProvider as RuntimeConfigAwsCredentialIdentityProvider)({ callerClientConfig: { region: normalizeProvider(input.region), }, diff --git a/packages/token-providers/src/fromSso.ts b/packages/token-providers/src/fromSso.ts index 0f973dd8787c..0266209a3b6c 100644 --- a/packages/token-providers/src/fromSso.ts +++ b/packages/token-providers/src/fromSso.ts @@ -1,7 +1,7 @@ import { AwsIdentityProperties, CredentialProviderOptions, - RegionalIdentityProvider, + RuntimeConfigIdentityProvider, TokenIdentity, } from "@aws-sdk/types"; import { TokenProviderError } from "@smithy/property-provider"; @@ -36,7 +36,7 @@ export interface FromSsoInit extends SourceProfileInit, CredentialProviderOption * Creates a token provider that will read from SSO token cache or ssoOidc.createToken() call. */ export const fromSso = - (_init: FromSsoInit = {}): RegionalIdentityProvider => + (_init: FromSsoInit = {}): RuntimeConfigIdentityProvider => async (awsIdentityProperties?: AwsIdentityProperties) => { const init: FromSsoInit = { ..._init, diff --git a/packages/types/src/identity/AwsCredentialIdentity.ts b/packages/types/src/identity/AwsCredentialIdentity.ts index 0af1dcfb22d2..ad1091af88ac 100644 --- a/packages/types/src/identity/AwsCredentialIdentity.ts +++ b/packages/types/src/identity/AwsCredentialIdentity.ts @@ -17,23 +17,25 @@ export interface AwsIdentityProperties { * @public * * Variation of {@link IdentityProvider} which accepts a contextual - * client configuration that includes an AWS region. + * client configuration that includes an AWS region and potentially other + * configurable fields. * - * Used to link a credential provider to a client region if it is being called + * Used to link a credential provider to a client if it is being called * in the context of a client. */ -export type RegionalIdentityProvider = (awsIdentityProperties?: AwsIdentityProperties) => Promise; +export type RuntimeConfigIdentityProvider = (awsIdentityProperties?: AwsIdentityProperties) => Promise; /** * @public * * Variation of {@link AwsCredentialIdentityProvider} which accepts a contextual - * client configuration that includes an AWS region. + * client configuration that includes an AWS region and potentially other + * configurable fields. * - * Used to link a credential provider to a client region if it is being called + * Used to link a credential provider to a client if it is being called * in the context of a client. */ -export type RegionalAwsCredentialIdentityProvider = RegionalIdentityProvider; +export type RuntimeConfigAwsCredentialIdentityProvider = RuntimeConfigIdentityProvider; /** * @public