vouched-nodejs
Getting Started
Required libraries
vouched-nodejs
relies on libvps and python for compressing images before transport.
Installation instructions for libvips found at https://github.com/lovell/sharp-libvips.
Installation
If you use npm, simply do:
npm install vouched-nodejs
.
Otherwise, you can grab the code from [GitHub].
Quick start
Here's a very simple server using Vouched for Node.js for authentication
Create the Vouched client
const Client = require('vouched-nodejs').default;
const client = Client(secret_app_key);
Arguments
Parameter | Type | Required | Description |
---|
key | String | * | Secret Application Key |
Returns
Parameter | Type | Required | Description |
---|
key | String | * | Secret Application Key |
Errors
InvalidRequestError
Update client key
const secretClientKey = '<SECRET>'
const data = client.updateSecretClientKey(secretClientKey);
Arguments
Parameter | Type | Required | Description |
---|
secretClientKey | String | * | The secret key to be included in the header X-Api-Key of the webhook call. |
Returns
Parameter | Type | Required | Description |
---|
secretClientKey | String | * | The updated secretClientKey |
Errors
AuthenticationError
ConnectionError
InvalidRequestError
UnknownSystemError
Submit a verification job
const utils = require('vouched-nodejs').utils;
const userPhotoBase64 = await utils.imageToBase64(
'./tests/data/selfie.png'
);
const idPhotoBase64 = await utils.imageToBase64(
'./tests/data/id.jpg'
);
const job = await client.submit({
userPhoto:userPhotoBase64,
idPhoto:idPhotoBase64,
type:'id-verification',
firstName:'Janice',
properties:[
{name:'internal_id',value:'iid'},
{name:'internal_username',value:'bob'}
],
dob:'06/22/1990',
lastName:'Way'
})
Arguments
type | String | * | Type of AI job ("id-verification")} |
---|
callbackURL | String | | Upon the jobs completion, Vouched will POST the job results to the webhook. If the callbackURL is not given, Vouch will process the job in realtime. |
properties | Object | | Arbitrary properties to add to the job, i.e. application ids. Described below. |
parameters | Object | * | Object for id-verification. Described below. |
properties
- arbitrary properties to add to the job, i.e. application ids
type | String | * | Type of AI job ("id-verification")} |
---|
name | String | | Name of the property |
value | String | | Value of the property |
parameters
- object for id-verification.
type | String | * | Type of AI job ("id-verification") |
---|
userPhoto | String | Buffer | | The users id comparison photo. Supported types include image/png, image/jpeg |
idPhoto | String | Buffer | * | The users official identification photo. Supported types include image/png, image/jpeg |
idPhotoBack | String | Buffer | * | The users official back of the identification photo. Supported types include image/png, image/jpeg. |
firstName | String | * | The users first name. |
lastName | String | * | The users last name. |
dob | String | * | Date in the format MM/DD/YYYY. |
Returns
Parameter | Type | Required | Description |
---|
job | Job | * | The newly created job. |
Errors
AuthenticationError
ConnectionError
InvalidRequestError
UnknownSystemError
Remove a job
const job = await client.remove({ id: 'ofm1k9xF' })
Arguments
Parameter | Type | Required | Description |
---|
id | String | * | ID of the job to remove. |
Returns
Parameter | Type | Required | Description |
---|
job | Job | * | The newly created job. |
Errors
AuthenticationError
ConnectionError
InvalidRequestError
UnknownSystemError
Provide results on jobs
params := map[string]interface{}{
"page": 1,
"sortBy": "date",
"sortOrder": "desc",
"from": "1990-12-24T04:44:00+00:00",
"to": "2020-12-24T04:44:00+00:00",
"type": "id-verification",
"token": "SESSION_TOKEN",
"status": "active",
"withPhotos": false,
"pageSize": 2,
}
if resp, err := c.Jobs(params); err != nil {
fmt.Printf("Error: %+v
", err)
} else {
fmt.Printf("Jobs: %+v
", resp)
}
const jobs = client.jobs({
page:1,
pageSize:2,
type:'id-verification',
status:'active',
token:<TOKEN_FROM_WEB_CLIENT>,
sortBy:'date',
sortOrder:'desc',
withPhotos:true,
fromDate:'2017-01-24T04:44:00+00:00',
toDate:'2020-12-24T04:44:00+00:00'
})
Arguments
Parameter | Type | Required | Description |
---|
id | String | * | ID of the job to remove. |
type | String | | Type of job ("id-verification"). |
ids | ID | | Filter by a list of job IDs. |
page | String | | Paginate list by page where the page starts at 1, defaults to 1. |
pageSize | String | | The number of items for a page, max 1000, defaults to 100. |
sortBy | String | | Sort the list from ("date", "status"). |
sortOrder | String | | Order the sort from ("asc", "desc"). |
status | String | | Filter by status from ("active","completed") |
to | String | | Filter by submitted to ISO8601 date. |
from | String | | Filter by submitted from ISO8601 date. |
withPhotos | Boolean | | Defaults to False. The returned job will contain detailed information idPhoto, idPhotoBack, and userPhoto. |
Returns
Parameter | Type | Required | Description |
---|
jobs | Job | * | The removed job. |
totalPages | Int | * | Total number of pages of jobs. |
pageSize | Int | * | The requested page size. |
page | Int | * | The requested page. |
total | Int | * | Total number of filtered jobs. |
Errors
AuthenticationError
ConnectionError
InvalidRequestError
UnknownSystemError
Types
Errors
Parameter | Type | Required | Description |
---|
type | String | * | |
message | String | * | Type of job ("id-verification"). |
suggestion | ID | | A suggestion for matching name, John Smith, Jon Smith. |
errors | Error | InvalidRequestError contains a sub list of errors |
type
InvalidRequestError
- The request is invalid.
FaceMatchError
- Face match felled below the threshold
NameMatchError
- Name match felled below the threshold
BirthDateMatchError
- Birth date match felled below the threshold
InvalidIdPhotoError
- The ID is invalid
InvalidUserPhotoError
- The user photo (selfie) is invalid
UNAUTHENTICATED
/AuthenticationError
- The request could not be authenticated
ConnectionError
- A connection error occurred while communicating to the Vouched service
InvalidIdBackPhotoError
- The back of the ID is invalid
UnknownSystemError
- A unknown system error occurred
InvalidIdError
- The ID is invalid
Job
Parameter | Type | Required | Description |
---|
id | ID | * | Job ID |
status | String | * | Job status from ("active","completed") |
submitted | String | | ISO8601 date |
request | Object | | Object for 'id-verification'. |
result | Object | | Object of 'id-verification'. |
errors | Error | | List of errors for unsuccessful completed jobs. |
request
Parameter | Type | Required | Description |
---|
type | String | * | Job type |
callbackURL | String | | POST enabled webhook |
parameters | JobParameters | * | Object for 'id-verification' |
result
Parameter | Type | Required | Description |
---|
success | Boolean | * | Did the id verification completed successfully? |
type | String | | The id type |
callbackURL | String | | POST enabled webhook |
state | String | | The issuing state of the id if applicable |
country | String | | The issuing country of the id |
id | String | | The verified id number of the id |
expireDate | String | | The verified expired date in the format MM/DD/YYYY |
birthDate | String | | The verified date in the format MM/DD/YYYY |
firstName | String | | The user's verified first name. |
lastName | String | | The user's verified last name |
confidences | Confidences | | Confidence scores |
Confidences
Parameter | Type | Required | Description |
---|
id | Float | * | Confidence score for an id photo, 0-1.0 |
backId | Float | * | Confidence score for the back of the id photo, 0-1.0 |
selfie | Float | * | Confidence score for a selfie photo, 0-1.0 |
idMatch | Float | * | Confidence score for matching data on the id, 0-1.0 |
faceMatch | Float | * | Confidence score for matching faces, 0-1.0 |
JobParameters
Parameter | Type | Required | Description |
---|
idPhoto | String | * | The user's official identification photo in base64. |
userPhoto | String | | The user's id comparison photo in base64. |
twicPhoto | String | | The user's id twic id photo in base64. |
carInsurancePhoto | String | | The user's id car insurance photo in base64. |
dotPhoto | String | * | The user's id dot letter photo in base64. |
idPhotoBack | String | | The user's official back of the identification photo in base64. |
dob | String | | Date in the format MM/DD/YYYY. |
firstName | String | | The user's first name. |
lastName | String | | The user's last name. |
Testing
Run the tests:
yarn test
Run a specific test file:
yarn test -- 'utils.test'
Run a specific test scenario:
yarn test -- 'utils.test' --t 'toImage - success'
yarn test -- 'client.test' --t 'submit - success'