idea-aws
    Preparing search index...

    Class Cognito

    A wrapper for AWS Cognito.

    IDEA's user pools sign in by email: the methods find a local account by its email, which Cognito accepts in place of its own username (a UUID, equal to the sub). A local account linked to an external provider (SAML, OIDC) stays local, found by its email. A federated account, born from a sign-in through a provider with no account linked, has the email the provider sent, if any, but isn't found by it: it answers only to <provider>_<id> (federatedUsername). The methods that take every name Cognito knows an account by (the email of a local one, its sub, the federatedUsername of a federated one) call it username.

    Index
    client: CognitoIdentityProviderClient
    • Add a user (by email) to a group in the user pool.

      Parameters

      • email: string
      • group: string
      • userPoolId: string

      Returns Promise<void>

    • Complete the flow of a password forgot.

      Parameters

      • email: string
      • newPassword: string
      • confirmationCode: string
      • userPoolClientId: string

      Returns Promise<void>

    • Confirm and conclude a registration, usign a confirmation code.

      Parameters

      • email: string
      • confirmationCode: string
      • userPoolClientId: string

      Returns Promise<void>

    • Create a new group in the user pool.

      Parameters

      • groupName: string
      • userPoolId: string

      Returns Promise<void>

    • Create a new user (by its email) in the pool specified.

      Parameters

      • cognitoUserOrEmail: string | CognitoUser
      • userPoolId: string
      • options: CreateUserOptions = {}

      Returns Promise<string>

      userId of the new user

    • Delete a group from the user pool.

      Parameters

      • groupName: string
      • userPoolId: string

      Returns Promise<void>

    • Delete an account: a local one by its email or its sub, a federated one by its federatedUsername.

      Parameters

      • username: string
      • userPoolId: string

      Returns Promise<void>

    • Disable an account: a local one by its email or its sub, a federated one by its federatedUsername.

      Parameters

      • username: string
      • userPoolId: string

      Returns Promise<void>

    • Enable an account: a local one by its email or its sub, a federated one by its federatedUsername.

      Parameters

      • username: string
      • userPoolId: string

      Returns Promise<void>

    • Send to a user the instructions to change the password.

      Parameters

      • email: string
      • userPoolClientId: string

      Returns Promise<CodeDeliveryDetailsType>

    • Get the attributes of the user, from the authorizer claims.

      Parameters

      • claims: Record<string, any>

        authorizer claims

      Returns CognitoUserGeneric

      user's data

      use idea-toolbox's CognitoUser instead

    • The local account that signs in with an email, with its attributes. A federated account with the same email isn't found: listUsersByEmail lists it.

      Parameters

      • email: string
      • userPoolId: string

      Returns Promise<CognitoUserGeneric>

    • Get the list of groups of a user by its email address.

      Parameters

      • email: string
      • userPoolId: string

      Returns Promise<string[]>

    • Sign out an account from all devices: a local one by its email or its sub, a federated one by its federatedUsername.

      Parameters

      • username: string
      • userPoolId: string

      Returns Promise<void>

    • Link the local account that signs in with an email to a person's identity in an external provider of the pool: their sign-ins through the provider then sign in that account. Whoever presents that identity gets the account: link only on a provider, and on an attribute, that the person can't set by themselves. A federated account that holds the identity already must be deleted first.

      Parameters

      Returns Promise<void>

    • List all the users of the pool.

      Parameters

      • userPoolId: string
      • options: { pagination?: string; users: CognitoUser[] } = ...

      Returns Promise<CognitoUser[]>

    • Every account with an email: the local one that signs in with it, and the federated ones whose provider sent it. The listing is eventually consistent: an account just created may be missing, one just deleted still listed; getUserByEmail tells for sure whether the local one exists.

      Parameters

      • email: string
      • userPoolId: string

      Returns Promise<CognitoUserGeneric[]>

    • List the users part of a group in the user pool.

      Parameters

      • group: string
      • userPoolId: string
      • options: { pagination?: string; users: CognitoUser[] } = ...

      Returns Promise<CognitoUser[]>

    • List all the users of the pool, including the information about the groups they're in. Note: it's slower than the alternative listUsers: use it only when needed.

      Parameters

      • cognitoUserPoolId: string

      Returns Promise<CognitoUser[]>

    • List all the users of the pool with what Cognito knows of their accounts, besides their attributes: the status (e.g. FORCE_CHANGE_PASSWORD until the first sign-in), whether they're disabled, when they were created and last changed. listUsers gives idea-toolbox's CognitoUser, which keeps none of these.

      Parameters

      • userPoolId: string

      Returns Promise<CognitoUserGeneric[]>

    • Given a username and a refresh token (and pool data), refresh the session and return the new tokens.

      Parameters

      • email: string
      • refreshToken: string
      • userPoolId: string
      • userPoolClientId: string

      Returns Promise<AuthenticationResultType>

    • Remove a user (by email) from a group in the user pool.

      Parameters

      • email: string
      • group: string
      • userPoolId: string

      Returns Promise<void>

    • Set a new password for a specific user identified by its email (admin-only). If not specified, the password is generated randomly, and the user must change it at the first login.

      Parameters

      • email: string
      • userPoolId: string
      • options: { password?: string; permanent?: boolean } = {}

      Returns Promise<void>

    • Change the region in which to find the user pool. Default: the runner's (e.g. Lambda function) region.

      Parameters

      • region: string

      Returns void

    • Sign in a user of a specific pool through username and password.

      Parameters

      • email: string
      • password: string
      • userPoolId: string
      • userPoolClientId: string

      Returns Promise<AuthenticationResultType>

    • Change the email of an account, marked as verified: a local one by its email or its sub, a federated one by its federatedUsername. With globalSignOut, the account is signed out of every device too.

      Parameters

      • username: string
      • newEmail: string
      • userPoolId: string
      • globalSignOut: boolean = false

      Returns Promise<void>

    • Change the password to sign in for a user.

      Parameters

      • email: string
      • oldPassword: string
      • newPassword: string
      • userPoolId: string
      • userPoolClientId: string

      Returns Promise<void>

    • Update a (Cognito)User's attributes, excluding the attributes that require specific methods.

      Parameters

      • user: CognitoUser
      • userPoolId: string

      Returns Promise<void>

    • Mark as verified (or not, with unverify) the email of the local account that signs in with it.

      Parameters

      • email: string
      • userPoolId: string
      • unverify: boolean = false

      Returns Promise<void>