From dc39552eccee69a4c9709471b4e12bcff8282241 Mon Sep 17 00:00:00 2001 From: Luan Cazarine Date: Tue, 8 Jul 2025 18:02:02 -0300 Subject: [PATCH 1/2] [Components] veriff #17455 Actions - Create Verification Decision - Find A Decision --- .../create-verification.mjs | 161 ++++++++++++++++++ .../find-a-decision/find-a-decision.mjs | 35 ++++ components/veriff/common/constants.mjs | 66 +++++++ components/veriff/common/utils.mjs | 24 +++ components/veriff/package.json | 7 +- components/veriff/veriff.app.mjs | 41 ++++- 6 files changed, 327 insertions(+), 7 deletions(-) create mode 100644 components/veriff/actions/create-verification/create-verification.mjs create mode 100644 components/veriff/actions/find-a-decision/find-a-decision.mjs create mode 100644 components/veriff/common/constants.mjs create mode 100644 components/veriff/common/utils.mjs diff --git a/components/veriff/actions/create-verification/create-verification.mjs b/components/veriff/actions/create-verification/create-verification.mjs new file mode 100644 index 0000000000000..b937589e9b94a --- /dev/null +++ b/components/veriff/actions/create-verification/create-verification.mjs @@ -0,0 +1,161 @@ +import constants from "../../common/constants.mjs"; +import { parseObject } from "../../common/utils.mjs"; +import app from "../../veriff.app.mjs"; + +export default { + key: "veriff-create-verification", + name: "Create Verification Session", + description: "Creates a new verification session [See the documentation](https://devdocs.veriff.com/apidocs/v1sessions)", + version: "0.0.1", + type: "action", + props: { + app, + callback: { + type: "string", + label: "Callback URL", + description: "The callback URL to where the end-user is redirected after the verification session is completed. Default is visible in the Veriff Customer Portal > Settings. Changing the value in this request body will overwrite the default callback URL, but it will not change the callback URL that is visible in the Customer Portal.", + optional: true, + }, + firstName: { + type: "string", + label: "First Name", + description: "Person's first name", + optional: true, + }, + lastName: { + type: "string", + label: "Last Name", + description: "Person's last name", + optional: true, + }, + idNumber: { + type: "string", + label: "ID Number", + description: "Person's national identification number", + optional: true, + }, + phoneNumber: { + type: "string", + label: "Phone Number", + description: "Person's phone number", + optional: true, + }, + gender: { + type: "string", + label: "Gender", + description: "Person's gender", + options: constants.GENDER_OPTIONS, + optional: true, + }, + dateOfBirth: { + type: "string", + label: "Date of Birth", + description: "Person's date of birth (YYYY-MM-DD)", + optional: true, + }, + email: { + type: "string", + label: "Email", + description: "Person's email address", + optional: true, + }, + maritalStatus: { + type: "string", + label: "Marital Status", + description: "Person's marital status", + options: constants.MARITAL_STATUS_OPTIONS, + optional: true, + }, + isDeceased: { + type: "boolean", + label: "Is Deceased", + description: "Person's deceased status", + optional: true, + }, + number: { + type: "string", + label: "Document Number", + description: "Document number, [a-zA-Z0-9] characters only", + optional: true, + }, + country: { + type: "string", + label: "Country", + description: "Document issuing country (ISO 3166-1 alpha-2)", + optional: true, + }, + type: { + type: "string", + label: "Document Type", + description: "Type of document to verify", + options: constants.DOCUMENT_TYPE_OPTIONS, + optional: true, + }, + firstIssue: { + type: "string", + label: "First Issue", + description: "Date of first issue of the document (YYYY-MM-DD)", + optional: true, + }, + fullAddress: { + type: "string", + label: "Address", + description: "Full address (mandatory only for UK DIATF M1B profile flow)", + optional: true, + }, + vendorData: { + type: "string", + label: "Vendor Data", + description: "The unique identifier that you created for your end-user. It can be max 1,000 characters long and contain only non-semantic data that can not be resolved or used outside your systems or environments. Veriff returns it unmodified in webhooks and API response payloads, or as null if not provided", + optional: true, + }, + endUserId: { + type: "string", + label: "End User ID", + description: "The `UUID` that you created for your end-user, that can not be resolved or used outside your systems or environments. Veriff returns it unmodified in webhooks and API response payloads, or as `null` if not provided", + optional: true, + }, + consents: { + type: "string[]", + label: "Consents", + description: "Array of objects listing the type of consent given. Optional, should be only included for features that require consent", + optional: true, + }, + }, + async run({ $ }) { + const response = await this.app.createVerificationSession({ + $, + data: { + verification: { + callback: this.callback, + person: { + firstName: this.firstName, + lastName: this.lastName, + idNumber: this.idNumber, + phoneNumber: this.phoneNumber, + gender: this.gender, + dateOfBirth: this.dateOfBirth, + email: this.email, + maritalStatus: this.maritalStatus, + isDeceased: this.isDeceased, + }, + document: { + number: this.number, + country: this.country, + type: this.type, + firstIssue: this.firstIssue, + }, + address: { + fullAddress: this.fullAddress, + }, + vendorData: this.vendorData, + endUserId: this.endUserId, + consents: parseObject(this.consents), + }, + }, + }); + + $.export("$summary", `Created verification session ${response.verification.id}`); + return response; + }, +}; diff --git a/components/veriff/actions/find-a-decision/find-a-decision.mjs b/components/veriff/actions/find-a-decision/find-a-decision.mjs new file mode 100644 index 0000000000000..c8442eb3da810 --- /dev/null +++ b/components/veriff/actions/find-a-decision/find-a-decision.mjs @@ -0,0 +1,35 @@ +import crypto from "crypto"; +import app from "../../veriff.app.mjs"; + +export default { + key: "veriff-find-a-decision", + name: "Find A Decision", + description: "Finds decision by session ID. [See the documentation](https://devdocs.veriff.com/apidocs/v1sessionsiddecision-1)", + version: "0.0.1", + type: "action", + props: { + app, + sessionId: { + type: "string", + label: "Session ID", + description: "The session ID to find the decision for", + }, + }, + async run({ $ }) { + const hmacSignature = crypto + .createHmac("sha256", this.app.$auth.secret_key) + .update(this.sessionId) + .digest("hex"); + + const response = await this.app.getSessionDecision({ + $, + sessionId: this.sessionId, + headers: { + "x-hmac-signature": hmacSignature, + }, + }); + + $.export("$summary", `Found decision for session ${this.sessionId}`); + return response; + }, +}; diff --git a/components/veriff/common/constants.mjs b/components/veriff/common/constants.mjs new file mode 100644 index 0000000000000..b10e6c13c6b8e --- /dev/null +++ b/components/veriff/common/constants.mjs @@ -0,0 +1,66 @@ +export default { + BASE_URL: "https://api.veriff.me/v1", + WEBHOOK_EVENTS: { + SESSION_COMPLETED: "session.completed", + SESSION_APPROVED: "session.approved", + SESSION_DECLINED: "session.declined", + SESSION_RESUBMITTED: "session.resubmitted", + }, + VERIFICATION_STATUS: { + APPROVED: "approved", + DECLINED: "declined", + RESUBMITTED: "resubmitted", + PENDING: "pending", + }, + GENDER_OPTIONS: [ + { + label: "Male", + value: "M", + }, + { + label: "Female", + value: "F", + }, + ], + MARITAL_STATUS_OPTIONS: [ + { + label: "Single", + value: "single", + }, + { + label: "Married", + value: "married", + }, + { + label: "Divorced", + value: "divorced", + }, + { + label: "Widowed", + value: "widowed", + }, + ], + DOCUMENT_TYPE_OPTIONS: [ + { + label: "Id Card", + value: "ID_CARD", + }, + { + label: "Passport", + value: "PASSPORT", + }, + { + label: "Driver's License", + value: "DRIVERS_LICENSE", + }, + { + label: "Residence Permit", + value: "RESIDENCE_PERMIT", + }, + ], + ID_CARD_TYPE_OPTIONS: [ + "CE", + "TI", + ], +}; + diff --git a/components/veriff/common/utils.mjs b/components/veriff/common/utils.mjs new file mode 100644 index 0000000000000..dcc9cc61f6f41 --- /dev/null +++ b/components/veriff/common/utils.mjs @@ -0,0 +1,24 @@ +export const parseObject = (obj) => { + if (!obj) return undefined; + + if (Array.isArray(obj)) { + return obj.map((item) => { + if (typeof item === "string") { + try { + return JSON.parse(item); + } catch (e) { + return item; + } + } + return item; + }); + } + if (typeof obj === "string") { + try { + return JSON.parse(obj); + } catch (e) { + return obj; + } + } + return obj; +}; diff --git a/components/veriff/package.json b/components/veriff/package.json index 3a441c4db8931..1b4614834ff0e 100644 --- a/components/veriff/package.json +++ b/components/veriff/package.json @@ -1,6 +1,6 @@ { "name": "@pipedream/veriff", - "version": "0.0.1", + "version": "0.1.0", "description": "Pipedream Veriff Components", "main": "veriff.app.mjs", "keywords": [ @@ -11,5 +11,8 @@ "author": "Pipedream (https://pipedream.com/)", "publishConfig": { "access": "public" + }, + "dependencies": { + "@pipedream/platform": "^3.1.0" } -} \ No newline at end of file +} diff --git a/components/veriff/veriff.app.mjs b/components/veriff/veriff.app.mjs index d58ed792edb9b..ea20f3cfe12e3 100644 --- a/components/veriff/veriff.app.mjs +++ b/components/veriff/veriff.app.mjs @@ -1,11 +1,42 @@ +import { axios } from "@pipedream/platform"; + export default { type: "app", app: "veriff", - propDefinitions: {}, methods: { - // this.$auth contains connected account data - authKeys() { - console.log(Object.keys(this.$auth)); + _baseUrl() { + return `${this.$auth.api_url}/v1`; + }, + _headers(headers = {}) { + return { + "content-type": "application/json", + "x-auth-client": `${this.$auth.api_key}`, + ...headers, + }; + }, + _makeRequest({ + $ = this, path, headers, ...opts + }) { + return axios($, { + url: this._baseUrl() + path, + headers: this._headers(headers), + ...opts, + }); + }, + createVerificationSession(opts = {}) { + return this._makeRequest({ + method: "POST", + path: "/sessions", + ...opts, + }); + }, + getSessionDecision({ + sessionId, ...opts + }) { + return this._makeRequest({ + path: `/sessions/${sessionId}/decision`, + ...opts, + }); }, }, -}; \ No newline at end of file +}; From 8f35a7d29b7200f1812b638043ea44a2cc158f4f Mon Sep 17 00:00:00 2001 From: Luan Cazarine Date: Tue, 8 Jul 2025 18:06:40 -0300 Subject: [PATCH 2/2] pnpm update --- pnpm-lock.yaml | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index c7b875fc01cbc..610b8c12b345a 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -242,8 +242,7 @@ importers: specifier: ^3.0.0 version: 3.0.3 - components/accuweather: - specifiers: {} + components/accuweather: {} components/acelle_mail: {} @@ -714,8 +713,7 @@ importers: components/alphamoon: {} - components/alt_text_generator_ai: - specifiers: {} + components/alt_text_generator_ai: {} components/alteryx_analytics_cloud: {} @@ -14475,7 +14473,11 @@ importers: specifier: 3.2.2 version: 3.2.2 - components/veriff: {} + components/veriff: + dependencies: + '@pipedream/platform': + specifier: ^3.1.0 + version: 3.1.0 components/verifiedemail: {} @@ -15838,14 +15840,6 @@ importers: specifier: ^6.0.0 version: 6.2.0 - modelcontextprotocol/node_modules2/@modelcontextprotocol/sdk/dist/cjs: {} - - modelcontextprotocol/node_modules2/@modelcontextprotocol/sdk/dist/esm: {} - - modelcontextprotocol/node_modules2/zod-to-json-schema/dist/cjs: {} - - modelcontextprotocol/node_modules2/zod-to-json-schema/dist/esm: {} - packages/ai: dependencies: '@pipedream/sdk':