Skip to content

Commit

Permalink
fix(credential-provider-cognito-identity): return identityId as part …
Browse files Browse the repository at this point in the history
…of cognitoIdentityPool (#1635)

* fix: propogate identityId from cognito identity

* fix: update test
  • Loading branch information
alexforsyth authored Oct 28, 2020
1 parent e72d03b commit de75f7e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ describe("fromCognitoIdentity", () => {
customRoleArn: "myArn",
})()
).toEqual({
identityId: identityId,
accessKeyId: "foo",
secretAccessKey: "bar",
sessionToken: "baz",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,21 @@ 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.
*
* Results from this function call are not cached internally.
*/
export function fromCognitoIdentity(parameters: FromCognitoIdentityParameters): CredentialProvider {
return async (): Promise<Credentials> => {
return async (): Promise<CognitoIdentityCredentials> => {
const {
Credentials: {
AccessKeyId = throwOnMissingAccessKeyId(),
Expand All @@ -29,6 +36,7 @@ export function fromCognitoIdentity(parameters: FromCognitoIdentityParameters):
);

return {
identityId: parameters.identityId,
accessKeyId: AccessKeyId,
secretAccessKey: SecretKey,
sessionToken: SessionToken,
Expand Down

0 comments on commit de75f7e

Please sign in to comment.