2.0.0 • Published 3 years ago
@orcden/od-storage v2.0.0
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
Name | Parameters | Description |
---|---|---|
tryGetCurrentAuthenticatedUser | callback | Trys to authenticates a user from session data and performs a callback with the info. Callback parameters: loggedIn, userDetails, error |
trySignIn | username, password, callback | Trys to manually authenticate with the given parameters and performs a callback with the info. Callback parameters: userDetails, challenge, error |
tryGetCurrenSessionData | callback | Gets a user from session data and performs a callback with the info. Needs to be authenticated first. Callback parameters: userDetails, error |
trySignUp | username, email, password, callback | Trys to sign a user up with the given parameters and performs a callback with the info. Callback parameters: userDetails, error |
tryCompleteNewPassword | email, newPassword, callback | Trys to complete a new password challenge with the given parameters and performs a callback with the info. Callback parameters: userDetails, error |
tryResendConfirmationCode | username, callback | Trys to resend a confirmation code to a specific user and performs a callback with the info. Callback parameters: error |
trySignOut | callback | Trys to sign out the current authenticated user and performs a callback with the info. Callback parameters: error |
tryChangePassword | oldPassword, newPassword, callback | Trys to change the password of the current authernticated user and performs a callback with the info. Callback parameters: passwordChangeData, error |
tryVerifyEmailSendCode | callback | Trys to send a code to the current authernticated user and performs a callback with the info. Callback parameters: error |
tryUpdateEmailSendCode | email, callback | Trys to update the email of and send a code to the current authernticated user and performs a callback with the info. Callback parameters: error |
tryVerifyEmailSubmit | code, callback | Trys to verify the email update code of current authernticated user and performs a callback with the info. Callback parameters: error |
tryforgotPasswordSendCode | username, callback | Trys to reset the password of and send a code to a specific user and performs a callback with the info. Callback parameters: error |
tryforgotPasswordSubmit | username, code, newPassword, callback | Trys 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