UNPKG

n8n-nodes-deepidv

Version:

n8n community node to integrate with the DeepIDV identity verification API

183 lines 7.57 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Deepidv = void 0; const n8n_workflow_1 = require("n8n-workflow"); class Deepidv { constructor() { this.description = { displayName: 'DeepIDV', name: 'deepidv', icon: 'file:deepidv.svg', group: ['transform'], version: 1, subtitle: '={{$parameter["operation"]}}', description: 'DeepIDV session management operations', defaults: { name: 'DeepIDV' }, inputs: ['main'], outputs: ['main'], credentials: [{ name: 'deepIDVApi', required: true }], properties: [ // 1) Operation selector { displayName: 'Operation', name: 'operation', type: 'options', noDataExpression: true, options: [ { name: 'Invite Session', value: 'sessionInvite' }, { name: 'List Sessions', value: 'listSessions' }, ], default: 'sessionInvite', }, // 2) Organization ID { displayName: 'Organization ID', name: 'organizationId', type: 'string', default: '', required: true, }, // ─── Invite Session parameters ─────────────────────────────────────────── { displayName: 'First Name', name: 'firstName', type: 'string', default: '', required: true, displayOptions: { show: { operation: ['sessionInvite'] } }, }, { displayName: 'Last Name', name: 'lastName', type: 'string', default: '', required: true, displayOptions: { show: { operation: ['sessionInvite'] } }, }, { displayName: 'Email', name: 'email', type: 'string', default: '', placeholder: 'name@email.com', required: true, displayOptions: { show: { operation: ['sessionInvite'] } }, }, { displayName: 'Phone', name: 'phone', type: 'string', default: '', required: true, displayOptions: { show: { operation: ['sessionInvite'] } }, }, { displayName: 'Sender User ID', name: 'senderUserId', type: 'string', default: '', required: true, displayOptions: { show: { operation: ['sessionInvite'] } }, }, { displayName: 'Send Invite?', name: 'sendInvite', type: 'boolean', default: true, displayOptions: { show: { operation: ['sessionInvite'] } }, }, // ─── List Sessions parameters ──────────────────────────────────────────── { displayName: 'Limit', name: 'limit', type: 'number', default: 50, typeOptions: { minValue: 1 }, displayOptions: { show: { operation: ['listSessions'] } }, description: 'Max number of results to return', }, { displayName: 'Offset', name: 'offset', type: 'number', default: 0, displayOptions: { show: { operation: ['listSessions'] } }, description: 'Number of sessions to skip', }, ], }; } async execute() { const items = this.getInputData(); const returnData = []; const creds = (await this.getCredentials('deepIDVApi')); if (!creds.apiKey) { throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'No API key set for DeepIDV'); } for (let i = 0; i < items.length; i++) { const operation = this.getNodeParameter('operation', i); const orgId = this.getNodeParameter('organizationId', i); let responseData; // 1) Session Invite if (operation === 'sessionInvite') { const firstName = this.getNodeParameter('firstName', i); const lastName = this.getNodeParameter('lastName', i); const email = this.getNodeParameter('email', i); const phone = this.getNodeParameter('phone', i); const senderUserId = this.getNodeParameter('senderUserId', i); const sendInvite = this.getNodeParameter('sendInvite', i); responseData = await this.helpers.request({ method: 'POST', uri: 'https://henzev2hp9.execute-api.us-east-1.amazonaws.com/dev/v1/verification/sessionInvite', headers: { 'x-api-key': creds.apiKey, 'Content-Type': 'application/json', }, body: { organizationId: orgId, firstName, lastName, email, phone, senderUserId, sendInvite, }, json: true, }); // 2) List Sessions } else if (operation === 'listSessions') { const limit = this.getNodeParameter('limit', i); const offset = this.getNodeParameter('offset', i); responseData = await this.helpers.request({ method: 'GET', uri: 'https://henzev2hp9.execute-api.us-east-1.amazonaws.com/dev/v1/verification/session/list', headers: { 'x-api-key': creds.apiKey, }, qs: { organizationId: orgId, limit, offset, }, json: true, }); } else { throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Operation "${operation}" not supported`); } // Push result(s) if (Array.isArray(responseData)) { for (const record of responseData) { returnData.push({ json: record }); } } else { returnData.push({ json: responseData }); } } return this.prepareOutputData(returnData); } } exports.Deepidv = Deepidv; //# sourceMappingURL=Deepidv.node.js.map