Options
All
  • Public
  • Public/Protected
  • All
Menu

Class AuthClass

Provide authentication steps

Hierarchy

  • AuthClass

Index

Constructors

constructor

Properties

data

data: any

Methods

changePassword

  • changePassword(user: CognitoUser, oldPassword: string, newPassword: string): Promise<"SUCCESS">
  • Change a password for an authenticated user

    Parameters

    • user: CognitoUser

      The CognitoUser object

    • oldPassword: string

      the current password

    • newPassword: string

      the requested new password

    Returns Promise<"SUCCESS">

    • A promise resolves if success

completeNewPassword

  • completeNewPassword(user: CognitoUser, password: string, requiredAttributes: any): Promise<CognitoUser>
  • Parameters

    • user: CognitoUser
    • password: string
    • requiredAttributes: any

    Returns Promise<CognitoUser>

configure

  • configure(config: any): any

confirmSignIn

  • confirmSignIn(user: CognitoUser, code: string, mfaType?: "SMS_MFA" | "SOFTWARE_TOKEN_MFA" | null): Promise<CognitoUser>
  • Send MFA code to confirm sign in

    Parameters

    • user: CognitoUser

      The CognitoUser object

    • code: string

      The confirmation code

    • Optional mfaType: "SMS_MFA" | "SOFTWARE_TOKEN_MFA" | null

    Returns Promise<CognitoUser>

confirmSignUp

  • Send the verfication code to confirm sign up

    Parameters

    • username: string

      The username to be confirmed

    • code: string

      The verification code

    • Optional options: ConfirmSignUpOptions

      other options for confirm signup

    Returns Promise<any>

    • A promise resolves callback data if success

currentAuthenticatedUser

  • currentAuthenticatedUser(): Promise<CognitoUser | any>
  • Get current authenticated user

    Returns Promise<CognitoUser | any>

    • A promise resolves to curret authenticated CognitoUser if success

currentCredentials

currentSession

  • currentSession(): Promise<CognitoUserSession>
  • Get current user's session

    Returns Promise<CognitoUserSession>

    • A promise resolves to session object if success

currentUserCredentials

currentUserInfo

  • currentUserInfo(): Promise<any>
  • Get user information

    async

    Returns Promise<any>

    • current User's information

currentUserPoolUser

  • currentUserPoolUser(): Promise<CognitoUser>
  • Get current authenticated user

    Returns Promise<CognitoUser>

    • A promise resolves to curret authenticated CognitoUser if success

disableSMS

  • disableSMS(user: CognitoUser): Promise<string>
  • diable SMS

    deprecated

    Parameters

    • user: CognitoUser

      the current user

    Returns Promise<string>

    • A promise resolves is success

enableSMS

  • enableSMS(user: CognitoUser): Promise<string>
  • enable SMS

    deprecated

    Parameters

    • user: CognitoUser

      the current user

    Returns Promise<string>

    • A promise resolves is success

essentialCredentials

federatedSignIn

  • For federated login

    Parameters

    • provider: "google" | "facebook" | "amazon" | "developer"

      federation login provider

    • response: FederatedResponse

      response should have the access token the identity id (optional) and the expiration time (the universal time)

    • user: FederatedUser

      user info

    Returns Promise<ICredentials>

forgotPassword

  • forgotPassword(username: string): Promise<any>
  • Initiate a forgot password request

    Parameters

    • username: string

      the username to change password

    Returns Promise<any>

    • A promise resolves if success

forgotPasswordSubmit

  • forgotPasswordSubmit(username: string, code: string, password: string): Promise<void>
  • Confirm a new password using a confirmation Code

    Parameters

    • username: string

      The username

    • code: string

      The confirmation code

    • password: string

      The new password

    Returns Promise<void>

    • A promise that resolves if success

getMFAOptions

  • getMFAOptions(user: CognitoUser): Promise<MFAOption[]>
  • get user current preferred mfa option this method doesn't work with totp, we need to deprecate it.

    deprecated

    Parameters

    • user: CognitoUser

      the current user

    Returns Promise<MFAOption[]>

    • A promise resolves the current preferred mfa option if success

getModuleName

  • getModuleName(): string

getPreferredMFA

  • getPreferredMFA(user: any): Promise<string>
  • get preferred mfa method

    Parameters

    • user: any

      the current cognito user

    Returns Promise<string>

resendSignUp

  • resendSignUp(username: string): Promise<string>
  • Resend the verification code

    Parameters

    • username: string

      The username to be confirmed

    Returns Promise<string>

    • A promise resolves data if success

sendCustomChallengeAnswer

  • sendCustomChallengeAnswer(user: CognitoUser, challengeResponses: string): Promise<CognitoUser>
  • Send the answer to a custom challenge

    Parameters

    • user: CognitoUser

      The CognitoUser object

    • challengeResponses: string

      The confirmation code

    Returns Promise<CognitoUser>

setPreferredMFA

  • setPreferredMFA(user: CognitoUser, mfaMethod: "TOTP" | "SMS" | "NOMFA"): Promise<string>
  • set preferred MFA method

    Parameters

    • user: CognitoUser

      the current Cognito user

    • mfaMethod: "TOTP" | "SMS" | "NOMFA"

      preferred mfa method

    Returns Promise<string>

    • A promise resolve if success

setupTOTP

  • setupTOTP(user: CognitoUser): Promise<string>
  • Setup TOTP

    Parameters

    • user: CognitoUser

      the current user

    Returns Promise<string>

    • A promise resolves with the secret code if success

signIn

  • signIn(username: string, password?: string): Promise<CognitoUser>
  • Sign in

    Parameters

    • username: string

      The username to be signed in

    • Optional password: string

      The password of the username

    Returns Promise<CognitoUser>

    • A promise resolves the CognitoUser

signOut

signUp

  • signUp(params: string | SignUpParams, ...restOfAttrs: string[]): Promise<ISignUpResult>
  • Sign up with username, password and other attrbutes like phone, email

    Parameters

    • params: string | SignUpParams

      The user attirbutes used for signin

    • Rest ...restOfAttrs: string[]

      for the backward compatability

    Returns Promise<ISignUpResult>

    • A promise resolves callback data if success

updateUserAttributes

  • updateUserAttributes(user: CognitoUser, attributes: object): Promise<string>
  • Update an authenticated users' attributes

    Parameters

    • user: CognitoUser
    • attributes: object

    Returns Promise<string>

userAttributes

  • userAttributes(user: CognitoUser): Promise<CognitoUserAttribute[]>
  • Return user attributes

    Parameters

    • user: CognitoUser

      The CognitoUser object

    Returns Promise<CognitoUserAttribute[]>

    • A promise resolves to user attributes if success

userSession

  • userSession(user: any): Promise<CognitoUserSession>
  • Get the corresponding user session

    Parameters

    • user: any

      The CognitoUser object

    Returns Promise<CognitoUserSession>

    • A promise resolves to the session

verifiedContact

  • verifiedContact(user: CognitoUser): Promise<object>

verifyCurrentUserAttribute

  • verifyCurrentUserAttribute(attr: string): Promise<void>

verifyCurrentUserAttributeSubmit

  • verifyCurrentUserAttributeSubmit(attr: string, code: string): Promise<string>
  • Confirm current user's attribute using a confirmation code

    Parameters

    • attr: string

      The attribute to be verified

    • code: string

      The confirmation code

    Returns Promise<string>

    • A promise resolves to callback data if success

verifyTotpToken

  • verifyTotpToken(user: CognitoUser, challengeAnswer: string): Promise<CognitoUserSession>
  • verify TOTP setup

    Parameters

    • user: CognitoUser

      the current user

    • challengeAnswer: string

      challenge answer

    Returns Promise<CognitoUserSession>

    • A promise resolves is success

verifyUserAttribute

  • verifyUserAttribute(user: CognitoUser, attr: string): Promise<void>
  • Initiate an attribute confirmation request

    Parameters

    • user: CognitoUser

      The CognitoUser

    • attr: string

      The attributes to be verified

    Returns Promise<void>

    • A promise resolves to callback data if success

verifyUserAttributeSubmit

  • verifyUserAttributeSubmit(user: CognitoUser, attr: string, code: string): Promise<string>
  • Confirm an attribute using a confirmation code

    Parameters

    • user: CognitoUser

      The CognitoUser

    • attr: string

      The attribute to be verified

    • code: string

      The confirmation code

    Returns Promise<string>

    • A promise resolves to callback data if success