0.0.30 • Published 2 days ago
@jill64/cognito-passwordless v0.0.30
Installation
npm i cognito-passwordless
Usage
Frontend
import { CognitoPasswordless } from 'cognito-passwordless';
const client = new CognitoPasswordlessClient(
// AWS Credential
{
accessKeyId: string
secretAccessKey: string
region: string
},
// Cognito Credential
{
clientId: string
clientSecret: string
userPoolId: string
},
// Cookies Handler
{
set: (
name: string,
value: string,
options?: CookieSerializeOptions
) => void
delete: (name: string, options?: CookieSerializeOptions) => void
get: (name: string) => string | undefined
})
// Authenticate
const userInfo = await client.auth()
// Signup
const email = 'email@example.com'
const session = await client.signup(email)
await login({
session,
email,
code: 'OTP-CODE'
})
// Login
const email = 'email@example.com'
const session = await client.sendEmail(email)
await login({
session,
email,
code: 'OTP-CODE'
})
// Logout
await client.logout()
Backend
Please deploy these Lambda functions properly.
import { CognitoPasswordlessServer } from 'cognito-passwordless';
const server = new CognitoPasswordlessServer(
region: string,
// Verify Mail
{
source: string
subject: string
body: (code: string) => string
}
)
// Define Challenge Lambda Function
export const handle = server.defineChallenge
// Create Challenge Lambda Function
export const handle = server.createChallenge
// Verify Challenge Lambda Function
export const handle = server.verifyChallenge
0.0.30
2 days ago
0.0.28
3 days ago
0.0.29
2 days ago
0.0.26
4 days ago
0.0.27
4 days ago
0.0.25
8 days ago
0.0.24
9 days ago
0.0.23
9 days ago
0.0.22
16 days ago
0.0.21
18 days ago
0.0.20
23 days ago
0.0.19
23 days ago
0.0.15
25 days ago
0.0.16
25 days ago
0.0.17
25 days ago
0.0.18
24 days ago
0.0.14
27 days ago
0.0.13
28 days ago
0.0.12
29 days ago
0.0.11
30 days ago
0.0.10
1 month ago
0.0.9
1 month ago
0.0.8
1 month ago
0.0.7
1 month ago
0.0.6
1 month ago
0.0.5
1 month ago
0.0.4
1 month ago
0.0.3
1 month ago