UNPKG

@chevre/domain

Version:

Chevre Domain Library for Node.js

57 lines (48 loc) 1.58 kB
import { CognitoIdentityProvider } from '@aws-sdk/client-cognito-identity-provider'; import { fromEnv } from '@aws-sdk/credential-providers'; // tslint:disable:no-console no-magic-numbers import { chevre } from '../../../../lib/index'; async function main() { const awsCredentials = fromEnv(); const personRepo = await chevre.repository.Person.createInstance({ userPoolId: <string>process.env.COGNITO_USER_POOL_ID, cognitoIdentityServiceProvider: new CognitoIdentityProvider({ apiVersion: 'latest', region: 'ap-northeast-1', credentials: awsCredentials }) }); const username = 'xxx'; let profile = await personRepo.getUserAttributes({ username: username }); console.log('profile:', profile); await personRepo.updateProfile({ username: username, profile: { familyName: 'テスト', givenName: profile.givenName, telephone: profile.telephone, email: profile.email, additionalProperty: [ // { // name: 'email_verified', // value: 'true' // }, // { // name: 'custom:postalCode', // value: '999-9999' // } ] } }); profile = await personRepo.getUserAttributes({ username: username }); console.log('profile:', profile); } main() .then(() => { console.log('success!'); }) .catch(console.error);