Skip to content

17455 components veriff #17536

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
161 changes: 161 additions & 0 deletions components/veriff/actions/create-verification/create-verification.mjs
Original file line number Diff line number Diff line change
@@ -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,
},
Comment on lines +50 to +55
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Add input validation for date format.

The date of birth field expects "YYYY-MM-DD" format but lacks validation to ensure users provide the correct format.

Consider adding validation to ensure the date format is correct:

 dateOfBirth: {
   type: "string",
   label: "Date of Birth",
   description: "Person's date of birth (YYYY-MM-DD)",
+  pattern: "^\\d{4}-\\d{2}-\\d{2}$",
   optional: true,
 },
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
dateOfBirth: {
type: "string",
label: "Date of Birth",
description: "Person's date of birth (YYYY-MM-DD)",
optional: true,
},
dateOfBirth: {
type: "string",
label: "Date of Birth",
description: "Person's date of birth (YYYY-MM-DD)",
pattern: "^\\d{4}-\\d{2}-\\d{2}$",
optional: true,
},
🤖 Prompt for AI Agents
In components/veriff/actions/create-verification/create-verification.mjs around
lines 50 to 55, the dateOfBirth field lacks validation to ensure the input
matches the expected "YYYY-MM-DD" format. Add a validation function or regex
pattern to check the date string format and reject or flag inputs that do not
conform to this pattern, ensuring only correctly formatted dates are accepted.

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,
},
Comment on lines +75 to +80
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Add input validation for document number format.

The document number field specifies "[a-zA-Z0-9] characters only" but lacks validation to enforce this constraint.

Consider adding validation to ensure the document number format is correct:

 number: {
   type: "string",
   label: "Document Number",
   description: "Document number, [a-zA-Z0-9] characters only",
+  pattern: "^[a-zA-Z0-9]+$",
   optional: true,
 },
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
number: {
type: "string",
label: "Document Number",
description: "Document number, [a-zA-Z0-9] characters only",
optional: true,
},
number: {
type: "string",
label: "Document Number",
description: "Document number, [a-zA-Z0-9] characters only",
pattern: "^[a-zA-Z0-9]+$",
optional: true,
},
🤖 Prompt for AI Agents
In components/veriff/actions/create-verification/create-verification.mjs around
lines 75 to 80, the document number field lacks validation to enforce the
allowed character set [a-zA-Z0-9]. Add a validation function or regex pattern to
check that the input contains only alphanumeric characters and integrate this
validation into the field definition to reject invalid inputs.

country: {
type: "string",
label: "Country",
description: "Document issuing country (ISO 3166-1 alpha-2)",
optional: true,
},
Comment on lines +81 to +86
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Add input validation for country code format.

The country field expects "ISO 3166-1 alpha-2" format but lacks validation to ensure users provide valid country codes.

Consider adding validation to ensure the country code format is correct:

 country: {
   type: "string",
   label: "Country",
   description: "Document issuing country (ISO 3166-1 alpha-2)",
+  pattern: "^[A-Z]{2}$",
   optional: true,
 },
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
country: {
type: "string",
label: "Country",
description: "Document issuing country (ISO 3166-1 alpha-2)",
optional: true,
},
country: {
type: "string",
label: "Country",
description: "Document issuing country (ISO 3166-1 alpha-2)",
pattern: "^[A-Z]{2}$",
optional: true,
},
🤖 Prompt for AI Agents
In components/veriff/actions/create-verification/create-verification.mjs around
lines 81 to 86, the country field lacks validation to ensure the input matches
the ISO 3166-1 alpha-2 format. Add a validation function or regex pattern to
check that the country code is exactly two uppercase letters, and integrate this
validation into the field definition to reject invalid inputs.

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,
},
Comment on lines +94 to +99
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Add input validation for first issue date format.

The first issue field expects "YYYY-MM-DD" format but lacks validation to ensure users provide the correct format.

Consider adding validation to ensure the date format is correct:

 firstIssue: {
   type: "string",
   label: "First Issue",
   description: "Date of first issue of the document (YYYY-MM-DD)",
+  pattern: "^\\d{4}-\\d{2}-\\d{2}$",
   optional: true,
 },
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
firstIssue: {
type: "string",
label: "First Issue",
description: "Date of first issue of the document (YYYY-MM-DD)",
optional: true,
},
firstIssue: {
type: "string",
label: "First Issue",
description: "Date of first issue of the document (YYYY-MM-DD)",
pattern: "^\\d{4}-\\d{2}-\\d{2}$",
optional: true,
},
🤖 Prompt for AI Agents
In components/veriff/actions/create-verification/create-verification.mjs around
lines 94 to 99, the firstIssue field lacks validation to ensure the date is in
"YYYY-MM-DD" format. Add a validation function or regex pattern to check the
input matches this date format and integrate it into the field definition to
prevent invalid date entries.

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,
},
Comment on lines +118 to +123
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Clarify the consents data type and structure.

The consents field is defined as string[] but is processed with parseObject() on line 153, which suggests it might be a JSON string rather than an array.

Consider clarifying the data type and providing an example:

 consents: {
-  type: "string[]",
+  type: "string",
   label: "Consents",
-  description: "Array of objects listing the type of consent given. Optional, should be only included for features that require consent",
+  description: "JSON string representing an array of objects listing the type of consent given. Example: `[{\"type\": \"data_processing\", \"given\": true}]`. Optional, should be only included for features that require consent",
   optional: true,
 },
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
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,
},
consents: {
type: "string",
label: "Consents",
description: "JSON string representing an array of objects listing the type of consent given. Example: `[{\"type\": \"data_processing\", \"given\": true}]`. Optional, should be only included for features that require consent",
optional: true,
},
🤖 Prompt for AI Agents
In components/veriff/actions/create-verification/create-verification.mjs around
lines 118 to 123, the consents field is declared as a string array but is parsed
as an object later, indicating a mismatch. Update the consents field type to
"string" to reflect it being a JSON string, and clarify in the description that
it should be a JSON string representing an array of consent objects. Optionally,
add an example of the expected JSON string format to improve clarity.

},
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;
},
};
35 changes: 35 additions & 0 deletions components/veriff/actions/find-a-decision/find-a-decision.mjs
Original file line number Diff line number Diff line change
@@ -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;
},
};
66 changes: 66 additions & 0 deletions components/veriff/common/constants.mjs
Original file line number Diff line number Diff line change
@@ -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",
],
Comment on lines +61 to +64
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Verification agent

🧩 Analysis chain

Verify the completeness of ID card type options.

The ID_CARD_TYPE_OPTIONS only contains two values ("CE" and "TI"). Please verify this is complete according to the Veriff API documentation, as it seems quite limited compared to the other option arrays.


🌐 Web query:

What are the supported ID card types for the Veriff identity verification API?

💡 Result:

Veriff's identity verification API supports a wide range of government-issued identity documents from over 230 countries and territories. This includes more than 12,000 document specimens, such as passports, national ID cards, driver's licenses, and residence permits. (veriff.com)

The API is designed to automatically recognize and process various document types, including those in Latin-based, Cyrillic, Japanese, and Arabic scripts. This extensive support ensures that Veriff can verify identities globally, accommodating diverse document formats and languages. (veriff.com)

For a comprehensive list of supported document types and to ensure compatibility with specific ID cards, you can refer to Veriff's official documentation or contact their support team for detailed information.

Citations:


Ensure ID_CARD_TYPE_OPTIONS covers all supported Veriff document types

The array at components/veriff/common/constants.mjs (lines 61–64) currently only includes "CE" and "TI", but Veriff’s API recognizes a broad set of ID documents (passports, national ID cards, driver’s licenses, residence permits, etc.). Please update this constant to reflect all relevant ID card types your integration needs (or consider fetching the list dynamically from Veriff’s docs/API).

• File: components/veriff/common/constants.mjs
Lines: 61–64

ID_CARD_TYPE_OPTIONS: [
  // replace these two placeholders…
  "CE",
  "TI",
  // …with the full set of required ID document codes
],
🤖 Prompt for AI Agents
In components/veriff/common/constants.mjs at lines 61 to 64, the
ID_CARD_TYPE_OPTIONS array currently only includes "CE" and "TI", which is
incomplete. Update this array to include all supported Veriff document types
required by your integration, such as passports, national ID cards, driver’s
licenses, residence permits, etc. Alternatively, implement logic to fetch this
list dynamically from Veriff’s API or documentation to ensure it stays current.

};

24 changes: 24 additions & 0 deletions components/veriff/common/utils.mjs
Original file line number Diff line number Diff line change
@@ -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;
};
7 changes: 5 additions & 2 deletions components/veriff/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pipedream/veriff",
"version": "0.0.1",
"version": "0.1.0",
"description": "Pipedream Veriff Components",
"main": "veriff.app.mjs",
"keywords": [
Expand All @@ -11,5 +11,8 @@
"author": "Pipedream <[email protected]> (https://pipedream.com/)",
"publishConfig": {
"access": "public"
},
"dependencies": {
"@pipedream/platform": "^3.1.0"
}
}
}
41 changes: 36 additions & 5 deletions components/veriff/veriff.app.mjs
Original file line number Diff line number Diff line change
@@ -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,
});
},
},
};
};
Loading
Loading