Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(credential-provider-cognito-identity): return identityId as part of cognitoIdentityPool #1635

Merged
merged 2 commits into from
Oct 28, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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