2.0.0 • Published 3 years ago

@orcden/od-storage v2.0.0

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

OD-Storage

Storage Library

ODS3Storage is a simple library that will manage your storage through amazon S3

Installation

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

Usage - ODCognitoAuth

import '@orcden/od-storage';
let storage = new ODS3Storage( this._getCognitoConfigs(), this._getS3Configs() );

_getCognitoConfigs() {
    return {
        // REQUIRED - Amazon Cognito Region
        region: 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,                        
        // REQUIRED only for Federated Authentication - Amazon Cognito Identity Pool ID
        identityPoolId: process.env.APP_COGNITO_IDENTITY_POOL_ID
    }
}

_getS3Configs() {
    return {
        //REQUIRED -  Amazon S3 bucket name
        bucket: '', 
        //OPTIONAL -  Amazon service region
        region: 'XX-XXXX-X'
    }
}

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
tryCompleteNewPasswordemail, newPassword, 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
2.0.0

3 years ago

1.0.0

3 years ago

0.0.2

3 years ago

0.0.1

3 years ago