2024-11-17 08:14:42 -08:00
|
|
|
import type { INodeType, INodeTypeDescription } from 'n8n-workflow';
|
|
|
|
import { NodeConnectionType } from 'n8n-workflow';
|
|
|
|
|
2024-11-26 04:20:53 -08:00
|
|
|
import {
|
|
|
|
userOperations,
|
|
|
|
userFields,
|
|
|
|
userPoolOperations,
|
|
|
|
userPoolFields,
|
|
|
|
groupOperations,
|
|
|
|
groupFields,
|
|
|
|
} from './descriptions';
|
2024-11-26 08:42:22 -08:00
|
|
|
import {
|
|
|
|
presendStringifyBody,
|
|
|
|
searchUserPools,
|
|
|
|
searchGroups,
|
|
|
|
searchUsers,
|
|
|
|
} from './GenericFunctions';
|
2024-11-17 08:14:42 -08:00
|
|
|
|
|
|
|
export class AwsCognito implements INodeType {
|
|
|
|
description: INodeTypeDescription = {
|
|
|
|
displayName: 'AWS Cognito',
|
|
|
|
name: 'awsCognito',
|
|
|
|
icon: 'file:cognito.svg',
|
|
|
|
group: ['output'],
|
|
|
|
version: 1,
|
|
|
|
subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}',
|
|
|
|
description: 'Interacts with Amazon Cognito',
|
|
|
|
defaults: { name: 'AWS Cognito' },
|
|
|
|
inputs: [NodeConnectionType.Main],
|
|
|
|
outputs: [NodeConnectionType.Main],
|
|
|
|
hints: [
|
2024-12-09 06:16:01 -08:00
|
|
|
{
|
|
|
|
message: 'Please select a parameter in the options to update the user',
|
|
|
|
displayCondition:
|
|
|
|
'={{$parameter["resource"] === "user" && $parameter["operation"] === "update" && Object.keys($parameter["additionalOptions"]).length === 0}}',
|
|
|
|
whenToDisplay: 'always',
|
|
|
|
location: 'outputPane',
|
|
|
|
type: 'warning',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
message: 'Please select a parameter in the options to update the group',
|
|
|
|
displayCondition:
|
|
|
|
'={{$parameter["resource"] === "group" && $parameter["operation"] === "update" && Object.keys($parameter["options"]).length === 0}}',
|
|
|
|
whenToDisplay: 'always',
|
|
|
|
location: 'outputPane',
|
|
|
|
type: 'warning',
|
|
|
|
},
|
2024-11-17 08:14:42 -08:00
|
|
|
],
|
|
|
|
credentials: [
|
|
|
|
{
|
|
|
|
name: 'aws',
|
|
|
|
required: true,
|
|
|
|
},
|
|
|
|
],
|
|
|
|
requestDefaults: {
|
|
|
|
baseURL: '=https://cognito-idp.{{$credentials.region}}.amazonaws.com',
|
|
|
|
url: '',
|
|
|
|
json: true,
|
|
|
|
headers: {
|
|
|
|
'Content-Type': 'application/x-amz-json-1.1',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
properties: [
|
|
|
|
{
|
|
|
|
displayName: 'Resource',
|
|
|
|
name: 'resource',
|
|
|
|
type: 'options',
|
|
|
|
noDataExpression: true,
|
|
|
|
default: 'user',
|
|
|
|
routing: {
|
|
|
|
send: {
|
|
|
|
preSend: [presendStringifyBody],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
options: [
|
|
|
|
{
|
|
|
|
name: 'User',
|
|
|
|
value: 'user',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'User Pool',
|
|
|
|
value: 'userPool',
|
|
|
|
},
|
2024-11-26 04:20:53 -08:00
|
|
|
{
|
|
|
|
name: 'Group',
|
|
|
|
value: 'group',
|
|
|
|
},
|
2024-11-17 08:14:42 -08:00
|
|
|
],
|
|
|
|
},
|
|
|
|
...userPoolOperations,
|
|
|
|
...userPoolFields,
|
|
|
|
...userOperations,
|
|
|
|
...userFields,
|
2024-11-26 04:20:53 -08:00
|
|
|
...groupOperations,
|
|
|
|
...groupFields,
|
2024-11-17 08:14:42 -08:00
|
|
|
],
|
|
|
|
};
|
|
|
|
|
|
|
|
methods = {
|
|
|
|
listSearch: {
|
|
|
|
searchUserPools,
|
2024-11-26 06:47:14 -08:00
|
|
|
searchGroups,
|
2024-11-26 08:42:22 -08:00
|
|
|
searchUsers,
|
2024-11-17 08:14:42 -08:00
|
|
|
},
|
|
|
|
};
|
|
|
|
}
|