Skip to main content

snippets_js

Integration

New integration from credential
const awsCognitoClient = yepcode.integration.awsCognito("credential-slug");
New integration from plain authentication data
const { CognitoIdentityProviderClient } = require("@aws-sdk/client-cognito-identity-provider");

const awsCognitoClient = new CognitoIdentityProviderClient({
credentials: {
accessKeyId: "accessKeyId",
secretAccessKey: "secretAccessKey",
},
});

Create Identify Provider

Create identify provider
const { CreateIdentityProviderCommand } = require('@aws-sdk/client-cognito-identity-provider)
const input = {
UserPoolId: userPoolId,
ProviderName: providerName,
ProviderType: providerType,
ProviderDetails: {
keys: providerDetails,
}
};
const command = new CreateIdentityProviderCommand(input);
const response = await awsCognitoClient.send(command);

Create User Pool

Create user pool
const { CreateUserPoolCommand } = require("@aws-sdk/client-cognito-identity-provider");

const input = {
PoolName: poolName
LambdaConfig: {
CustomSMSSender: {
LambdaVersion: lambdaVersion,
LambdaArn: lambdaArn,
},
CustomEmailSender: {
LambdaVersion: lambdaVersion,
LambdaArn: lambdaArn,
},
},
SmsConfiguration: {
SnsCallerArn: snsCallerArn,
},
UsernameConfiguration: {
CaseSensitive: caseSensitive,
},
AccountRecoverySetting: {
RecoveryMechanisms: [
{
Priority: Number(recoveryMechanismsPriority),
Name: recoveryMechanismsName,
},
],
}
};
const command = new CreateUserPoolCommand(input);
const response = await awsCognitoClient.send(command);

List Identity Providers

List identify providers
const { ListIdentityProvidersCommand } = require("@aws-sdk/client-cognito-identity-provider");
const input = {
UserPoolId: userPoolId
};
const command = new ListIdentityProvidersCommand(input);
const response = await awsCognitoClient.send(command);
for(const provider of response.Providers) {
console.log(provider)
}