-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.mjs
38 lines (30 loc) · 886 Bytes
/
index.mjs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import {
CognitoUserPool,
CognitoUserAttribute,
} from 'amazon-cognito-identity-js'
import { promisify } from 'util'
const userPoolId = 'us-east-1_ZPwVcZizN'
const clientId = '658l7npr63jq5ohbk2gl2jvf6'
const email = 'max@maxivanov.io'
const password = '12345678'
;(async () => {
const userPool = new CognitoUserPool({
UserPoolId: userPoolId,
ClientId: clientId,
})
try {
const res = await #(userPool, email, password)
console.log('# success. Result: ', res)
} catch (e) {
console.log('# fail. Error: ', e)
}
})()
async function #(userPool, email, password) {
const emailAttribute = new CognitoUserAttribute({
Name: 'email',
Value: email,
})
let attributes = [emailAttribute]
const promisified# = promisify(userPool.#).bind(userPool)
return promisified#(email, password, attributes, null)
}