Skip to content

Commit dc39552

Browse files
committed
[Components] veriff #17455
Actions - Create Verification Decision - Find A Decision
1 parent 4a4c5a2 commit dc39552

File tree

6 files changed

+327
-7
lines changed

6 files changed

+327
-7
lines changed
Lines changed: 161 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,161 @@
1+
import constants from "../../common/constants.mjs";
2+
import { parseObject } from "../../common/utils.mjs";
3+
import app from "../../veriff.app.mjs";
4+
5+
export default {
6+
key: "veriff-create-verification",
7+
name: "Create Verification Session",
8+
description: "Creates a new verification session [See the documentation](https://devdocs.veriff.com/apidocs/v1sessions)",
9+
version: "0.0.1",
10+
type: "action",
11+
props: {
12+
app,
13+
callback: {
14+
type: "string",
15+
label: "Callback URL",
16+
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.",
17+
optional: true,
18+
},
19+
firstName: {
20+
type: "string",
21+
label: "First Name",
22+
description: "Person's first name",
23+
optional: true,
24+
},
25+
lastName: {
26+
type: "string",
27+
label: "Last Name",
28+
description: "Person's last name",
29+
optional: true,
30+
},
31+
idNumber: {
32+
type: "string",
33+
label: "ID Number",
34+
description: "Person's national identification number",
35+
optional: true,
36+
},
37+
phoneNumber: {
38+
type: "string",
39+
label: "Phone Number",
40+
description: "Person's phone number",
41+
optional: true,
42+
},
43+
gender: {
44+
type: "string",
45+
label: "Gender",
46+
description: "Person's gender",
47+
options: constants.GENDER_OPTIONS,
48+
optional: true,
49+
},
50+
dateOfBirth: {
51+
type: "string",
52+
label: "Date of Birth",
53+
description: "Person's date of birth (YYYY-MM-DD)",
54+
optional: true,
55+
},
56+
email: {
57+
type: "string",
58+
label: "Email",
59+
description: "Person's email address",
60+
optional: true,
61+
},
62+
maritalStatus: {
63+
type: "string",
64+
label: "Marital Status",
65+
description: "Person's marital status",
66+
options: constants.MARITAL_STATUS_OPTIONS,
67+
optional: true,
68+
},
69+
isDeceased: {
70+
type: "boolean",
71+
label: "Is Deceased",
72+
description: "Person's deceased status",
73+
optional: true,
74+
},
75+
number: {
76+
type: "string",
77+
label: "Document Number",
78+
description: "Document number, [a-zA-Z0-9] characters only",
79+
optional: true,
80+
},
81+
country: {
82+
type: "string",
83+
label: "Country",
84+
description: "Document issuing country (ISO 3166-1 alpha-2)",
85+
optional: true,
86+
},
87+
type: {
88+
type: "string",
89+
label: "Document Type",
90+
description: "Type of document to verify",
91+
options: constants.DOCUMENT_TYPE_OPTIONS,
92+
optional: true,
93+
},
94+
firstIssue: {
95+
type: "string",
96+
label: "First Issue",
97+
description: "Date of first issue of the document (YYYY-MM-DD)",
98+
optional: true,
99+
},
100+
fullAddress: {
101+
type: "string",
102+
label: "Address",
103+
description: "Full address (mandatory only for UK DIATF M1B profile flow)",
104+
optional: true,
105+
},
106+
vendorData: {
107+
type: "string",
108+
label: "Vendor Data",
109+
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",
110+
optional: true,
111+
},
112+
endUserId: {
113+
type: "string",
114+
label: "End User ID",
115+
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",
116+
optional: true,
117+
},
118+
consents: {
119+
type: "string[]",
120+
label: "Consents",
121+
description: "Array of objects listing the type of consent given. Optional, should be only included for features that require consent",
122+
optional: true,
123+
},
124+
},
125+
async run({ $ }) {
126+
const response = await this.app.createVerificationSession({
127+
$,
128+
data: {
129+
verification: {
130+
callback: this.callback,
131+
person: {
132+
firstName: this.firstName,
133+
lastName: this.lastName,
134+
idNumber: this.idNumber,
135+
phoneNumber: this.phoneNumber,
136+
gender: this.gender,
137+
dateOfBirth: this.dateOfBirth,
138+
email: this.email,
139+
maritalStatus: this.maritalStatus,
140+
isDeceased: this.isDeceased,
141+
},
142+
document: {
143+
number: this.number,
144+
country: this.country,
145+
type: this.type,
146+
firstIssue: this.firstIssue,
147+
},
148+
address: {
149+
fullAddress: this.fullAddress,
150+
},
151+
vendorData: this.vendorData,
152+
endUserId: this.endUserId,
153+
consents: parseObject(this.consents),
154+
},
155+
},
156+
});
157+
158+
$.export("$summary", `Created verification session ${response.verification.id}`);
159+
return response;
160+
},
161+
};
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import crypto from "crypto";
2+
import app from "../../veriff.app.mjs";
3+
4+
export default {
5+
key: "veriff-find-a-decision",
6+
name: "Find A Decision",
7+
description: "Finds decision by session ID. [See the documentation](https://devdocs.veriff.com/apidocs/v1sessionsiddecision-1)",
8+
version: "0.0.1",
9+
type: "action",
10+
props: {
11+
app,
12+
sessionId: {
13+
type: "string",
14+
label: "Session ID",
15+
description: "The session ID to find the decision for",
16+
},
17+
},
18+
async run({ $ }) {
19+
const hmacSignature = crypto
20+
.createHmac("sha256", this.app.$auth.secret_key)
21+
.update(this.sessionId)
22+
.digest("hex");
23+
24+
const response = await this.app.getSessionDecision({
25+
$,
26+
sessionId: this.sessionId,
27+
headers: {
28+
"x-hmac-signature": hmacSignature,
29+
},
30+
});
31+
32+
$.export("$summary", `Found decision for session ${this.sessionId}`);
33+
return response;
34+
},
35+
};
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
export default {
2+
BASE_URL: "https://api.veriff.me/v1",
3+
WEBHOOK_EVENTS: {
4+
SESSION_COMPLETED: "session.completed",
5+
SESSION_APPROVED: "session.approved",
6+
SESSION_DECLINED: "session.declined",
7+
SESSION_RESUBMITTED: "session.resubmitted",
8+
},
9+
VERIFICATION_STATUS: {
10+
APPROVED: "approved",
11+
DECLINED: "declined",
12+
RESUBMITTED: "resubmitted",
13+
PENDING: "pending",
14+
},
15+
GENDER_OPTIONS: [
16+
{
17+
label: "Male",
18+
value: "M",
19+
},
20+
{
21+
label: "Female",
22+
value: "F",
23+
},
24+
],
25+
MARITAL_STATUS_OPTIONS: [
26+
{
27+
label: "Single",
28+
value: "single",
29+
},
30+
{
31+
label: "Married",
32+
value: "married",
33+
},
34+
{
35+
label: "Divorced",
36+
value: "divorced",
37+
},
38+
{
39+
label: "Widowed",
40+
value: "widowed",
41+
},
42+
],
43+
DOCUMENT_TYPE_OPTIONS: [
44+
{
45+
label: "Id Card",
46+
value: "ID_CARD",
47+
},
48+
{
49+
label: "Passport",
50+
value: "PASSPORT",
51+
},
52+
{
53+
label: "Driver's License",
54+
value: "DRIVERS_LICENSE",
55+
},
56+
{
57+
label: "Residence Permit",
58+
value: "RESIDENCE_PERMIT",
59+
},
60+
],
61+
ID_CARD_TYPE_OPTIONS: [
62+
"CE",
63+
"TI",
64+
],
65+
};
66+

components/veriff/common/utils.mjs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
export const parseObject = (obj) => {
2+
if (!obj) return undefined;
3+
4+
if (Array.isArray(obj)) {
5+
return obj.map((item) => {
6+
if (typeof item === "string") {
7+
try {
8+
return JSON.parse(item);
9+
} catch (e) {
10+
return item;
11+
}
12+
}
13+
return item;
14+
});
15+
}
16+
if (typeof obj === "string") {
17+
try {
18+
return JSON.parse(obj);
19+
} catch (e) {
20+
return obj;
21+
}
22+
}
23+
return obj;
24+
};

components/veriff/package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/veriff",
3-
"version": "0.0.1",
3+
"version": "0.1.0",
44
"description": "Pipedream Veriff Components",
55
"main": "veriff.app.mjs",
66
"keywords": [
@@ -11,5 +11,8 @@
1111
"author": "Pipedream <[email protected]> (https://pipedream.com/)",
1212
"publishConfig": {
1313
"access": "public"
14+
},
15+
"dependencies": {
16+
"@pipedream/platform": "^3.1.0"
1417
}
15-
}
18+
}

components/veriff/veriff.app.mjs

Lines changed: 36 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,42 @@
1+
import { axios } from "@pipedream/platform";
2+
13
export default {
24
type: "app",
35
app: "veriff",
4-
propDefinitions: {},
56
methods: {
6-
// this.$auth contains connected account data
7-
authKeys() {
8-
console.log(Object.keys(this.$auth));
7+
_baseUrl() {
8+
return `${this.$auth.api_url}/v1`;
9+
},
10+
_headers(headers = {}) {
11+
return {
12+
"content-type": "application/json",
13+
"x-auth-client": `${this.$auth.api_key}`,
14+
...headers,
15+
};
16+
},
17+
_makeRequest({
18+
$ = this, path, headers, ...opts
19+
}) {
20+
return axios($, {
21+
url: this._baseUrl() + path,
22+
headers: this._headers(headers),
23+
...opts,
24+
});
25+
},
26+
createVerificationSession(opts = {}) {
27+
return this._makeRequest({
28+
method: "POST",
29+
path: "/sessions",
30+
...opts,
31+
});
32+
},
33+
getSessionDecision({
34+
sessionId, ...opts
35+
}) {
36+
return this._makeRequest({
37+
path: `/sessions/${sessionId}/decision`,
38+
...opts,
39+
});
940
},
1041
},
11-
};
42+
};

0 commit comments

Comments
 (0)