diff --git a/packages/credential-provider-cognito-identity/src/fromCognitoIdentity.spec.ts b/packages/credential-provider-cognito-identity/src/fromCognitoIdentity.spec.ts index 8c4414b06a366..19f17a6d23f45 100644 --- a/packages/credential-provider-cognito-identity/src/fromCognitoIdentity.spec.ts +++ b/packages/credential-provider-cognito-identity/src/fromCognitoIdentity.spec.ts @@ -29,6 +29,7 @@ describe("fromCognitoIdentity", () => { customRoleArn: "myArn", })() ).toEqual({ + identityId: identityId, accessKeyId: "foo", secretAccessKey: "bar", sessionToken: "baz", diff --git a/packages/credential-provider-cognito-identity/src/fromCognitoIdentity.ts b/packages/credential-provider-cognito-identity/src/fromCognitoIdentity.ts index 4d7caea1f3d18..ae2d6df1338de 100644 --- a/packages/credential-provider-cognito-identity/src/fromCognitoIdentity.ts +++ b/packages/credential-provider-cognito-identity/src/fromCognitoIdentity.ts @@ -5,6 +5,13 @@ import { CredentialProvider, Credentials } from "@aws-sdk/types"; import { CognitoProviderParameters } from "./CognitoProviderParameters"; import { resolveLogins } from "./resolveLogins"; +export interface CognitoIdentityCredentials extends Credentials { + /** + * The Cognito ID returned by the last call to AWS.CognitoIdentity.getOpenIdToken(). + */ + identityId: string; +} + /** * Retrieves temporary AWS credentials using Amazon Cognito's * `GetCredentialsForIdentity` operation. @@ -12,7 +19,7 @@ import { resolveLogins } from "./resolveLogins"; * Results from this function call are not cached internally. */ export function fromCognitoIdentity(parameters: FromCognitoIdentityParameters): CredentialProvider { - return async (): Promise => { + return async (): Promise => { const { Credentials: { AccessKeyId = throwOnMissingAccessKeyId(), @@ -29,6 +36,7 @@ export function fromCognitoIdentity(parameters: FromCognitoIdentityParameters): ); return { + identityId: parameters.identityId, accessKeyId: AccessKeyId, secretAccessKey: SecretKey, sessionToken: SessionToken,