4.1.2 • Published 3 years ago

@orcden/od-authentication v4.1.2

Weekly downloads
123
License
MIT
Repository
bitbucket
Last release
3 years ago

OD-Authentication

Authentication Library

ODCognitoAuth is a simple library that will manage your connection to AWS Cognito Servers

Installation

  • Install with npm
npm i @orcden/od-authentication

Usage - ODCognitoAuth

import '@orcden/od-authentication';
let auth = new ODCognitoAuth( this._getCognitoConfigs() );

_getCognitoConfigs() {
    return {
        // REQUIRED - Amazon Cognito Region
        region: process.env.APP_COGNITO_REGION,
        // OPTIONAL - Amazon Cognito Federated Identity Pool Region 
        // Required only if it's different from Amazon Cognito Region
        identityPoolRegion: process.env.APP_COGNITO_REGION,
        // OPTIONAL - Amazon Cognito User Pool ID
        userPoolId: process.env.APP_COGNITO_USER_POOL_ID ,
        // OPTIONAL - Amazon Cognito Web Client ID (26-char alphanumeric string)
        userPoolWebClientId: process.env.APP_COGNITO_USER_POOL_WEB_CLIENT_ID,                        
        // OPTIONAL - Manually set the authentication flow type. Default is 'USER_SRP_AUTH'
        authenticationFlowType: process.env.APP_COGNITO_AUTHENTICATION_FLOW_TYPE,
        // OPTIONAL - Hosted UI configuration
        oauth: {
            domain: null,
            scope: [],
            redirectSignIn: null,
            redirectSignOut: null,
            responseType: 'code' // or 'token', note that REFRESH token will only be generated when the responseType is code
        },
        // REQUIRED only for Federated Authentication - Amazon Cognito Identity Pool ID
        identityPoolId: process.env.APP_COGNITO_IDENTITY_POOL_ID
    }
}

Functions

NameParametersDescription
tryGetCurrentAuthenticatedUsercallbackTrys to authenticates a user from session data and performs a callback with the info. Callback parameters: loggedIn, userDetails, error
trySignInusername, password, callbackTrys to manually authenticate with the given parameters and performs a callback with the info. Callback parameters: userDetails, challenge, error
tryGetCurrenSessionDatacallbackGets a user from session data and performs a callback with the info. Needs to be authenticated first. Callback parameters: userDetails, error
trySignUpusername, email, password, callbackTrys to sign a user up with the given parameters and performs a callback with the info. Callback parameters: userDetails, error
tryCompleteNewPasswordnewPassword, callbackTrys to complete a new password challenge with the given parameters and performs a callback with the info. Callback parameters: userDetails, error
tryResendConfirmationCodeusername, callbackTrys to resend a confirmation code to a specific user and performs a callback with the info. Callback parameters: error
trySignOutcallbackTrys to sign out the current authenticated user and performs a callback with the info. Callback parameters: error
tryChangePasswordoldPassword, newPassword, callbackTrys to change the password of the current authernticated user and performs a callback with the info. Callback parameters: passwordChangeData, error
tryVerifyEmailSendCodecallbackTrys to send a code to the current authernticated user and performs a callback with the info. Callback parameters: error
tryUpdateEmailSendCodeemail, callbackTrys to update the email of and send a code to the current authernticated user and performs a callback with the info. Callback parameters: error
tryVerifyEmailSubmitcode, callbackTrys to verify the email update code of current authernticated user and performs a callback with the info. Callback parameters: error
tryforgotPasswordSendCodeusername, callbackTrys to reset the password of and send a code to a specific user and performs a callback with the info. Callback parameters: error
tryforgotPasswordSubmitusername, code, newPassword, callbackTrys to verify the email update code of a specific user to update their password and performs a callback with the info. Callback parameters: passwordChangeData, error

Development

Run linter

npm run lint

Fix linter errors

npm run fix

Run tests

npm run test

Build for production

npm run build
4.1.0

3 years ago

4.1.2

3 years ago

4.1.1

3 years ago

4.0.1

3 years ago

4.0.0

3 years ago

3.4.2

3 years ago

3.3.1

3 years ago

3.3.0

3 years ago

3.2.0

3 years ago

3.1.0

3 years ago

3.0.0

3 years ago

2.0.0

3 years ago

1.1.9

3 years ago

1.1.7

3 years ago

1.1.6

3 years ago

1.1.5

3 years ago

1.1.4

3 years ago

1.1.3

3 years ago

1.1.2

3 years ago

1.1.12

3 years ago

1.1.11

3 years ago

1.1.10

3 years ago

1.1.16

3 years ago

1.1.15

3 years ago

1.1.14

3 years ago

1.1.19

3 years ago

1.1.17

3 years ago

1.1.20

3 years ago

1.1.1

3 years ago

1.1.0

3 years ago

1.0.3

3 years ago

1.0.1

3 years ago

1.0.0

4 years ago

0.0.6

4 years ago

0.0.5

4 years ago

0.0.4

4 years ago

0.0.3

4 years ago

0.0.2

4 years ago

0.0.1

4 years ago