@ot06/aws-cognito
v0.0.5
Published
AWS Cognito SDK
Downloads
2
Keywords
Readme
AWS Cognito SDK (v1.0.x)
Installation
This package requires Node Version v14.18.2+
Installing the package:
npm i @ot06/aws-cognito
Environment Variables to Set
COGNITO_REGION (Optional; Default: ap-south-1) AWS Region of the Cognito Instance is to be used
COGNITO_ENABLED (Default: false) Flag to enable Cognito Persistent Client
COGNITO_USER_POOL_ID Default 'UserPoolId' to be used
COGNITO_APP_CLIENT_ID Default 'ClientId' to be used
COGNITO_APP_CLIENT_SECRET Default 'ClientSecret' to be used
COGNITO_API_VERSION (Optional; Default: 2016-04-18) API Version of AWS Cognito APIs being used
Schema Options
- type (string) - Defines the Datatype of the property -- string -- number -- boolean -- array -- object
- isCustom (boolean) - Denotes that the property is a Custom Attribute
Example User Schema
const UserSchema = {
Username: { type: 'string' },
name: { type: 'string' },
email: { type: 'string' },
role: { type: 'string', isCustom: true },
userId: { type: 'number', isCustom: true },
isActive: { type: 'boolean', isCustom: true },
tags: { type: 'array', isCustom: true },
acl: { type: 'object', isCustom: true }
}
How to Use
import CognitoSdk from '@ot06/aws-cognito'
const cognitoSdk = new CognitoSdk(UserSchema)
SDK Methods
- adminCreateUser
- adminDeleteUser
- adminDisableUser
- adminEnableUser
- adminGetUser
- adminUpdateUserAttributes
- adminResetUserPassword
- adminSetUserPassword
- adminInitiateAuth
- customAdminLoginUser
- customAdminRefreshUserToken
- customValidateToken
- changePassword
- forgotPassword
- getUser
- listUsers
- revokeToken
NOTE: -- Usage of these methods is similar to the commands from the package @aws-sdk/client-cognito-identity-provider. Internally, the same is being used. Setting the right environment variables will eliminate their mandatory passing to these methods.
--The only change in the Input data structures are the 'Attributes' and 'UserAttributes' properties. You need to pass values as User objects structures as defined by 'UserSchema'
License
MIT
Free Software, Hell Yeah!