Class Cognito

A wrapper for AWS Cognito.

Constructors

Properties

client: CognitoIdentityProviderClient

Methods

  • 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 a user by its email (username), in the pool specified.

    Parameters

    • email: 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

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

    Parameters

    • email: string
    • userPoolId: string

    Returns Promise<string[]>

  • Sign out the user from all devices.

    Parameters

    • email: string
    • userPoolId: string

    Returns Promise<void>

  • List all the users of the pool.

    Parameters

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

    Returns Promise<CognitoUser[]>

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

    Parameters

    • group: string
    • userPoolId: string
    • options: {
          pagination?: string;
          users: CognitoUser[];
      } = ...
      • Optionalpagination?: 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[]>

  • 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>

  • Resend the password to a user who never logged in.

    Parameters

    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;
      } = {}
      • Optionalpassword?: string
      • Optionalpermanent?: 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 address (== username) associated to a user.

    Parameters

    • email: string
    • newEmail: string
    • userPoolId: string

    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>