0.0.1-beta.10 • Published 4 years ago

vouched-nodejs v0.0.1-beta.10

Weekly downloads
-
License
Apache-2.0
Repository
-
Last release
4 years ago

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

ParameterTypeRequiredDescription
keyString*Secret Application Key

Returns

ParameterTypeRequiredDescription
keyString*Secret Application Key

Errors

InvalidRequestError

Update client key

const secretClientKey = '<SECRET>'
const data = client.updateSecretClientKey(secretClientKey);

Arguments

ParameterTypeRequiredDescription
secretClientKeyString*The secret key to be included in the header X-Api-Key of the webhook call.

Returns

ParameterTypeRequiredDescription
secretClientKeyString*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

typeString*Type of AI job ("id-verification")}
callbackURLStringUpon 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.
propertiesObjectArbitrary properties to add to the job, i.e. application ids. Described below.
parametersObject*Object for id-verification. Described below.

properties - arbitrary properties to add to the job, i.e. application ids

typeString*Type of AI job ("id-verification")}
nameStringName of the property
valueStringValue of the property

parameters - object for id-verification.

typeString*Type of AI job ("id-verification")
userPhotoStringBufferThe users id comparison photo. Supported types include image/png, image/jpeg
idPhotoStringBuffer*The users official identification photo. Supported types include image/png, image/jpeg
idPhotoBackStringBuffer*The users official back of the identification photo. Supported types include image/png, image/jpeg.
firstNameString*The users first name.
lastNameString*The users last name.
dobString*Date in the format MM/DD/YYYY.

Returns

ParameterTypeRequiredDescription
jobJob*The newly created job.

Errors

AuthenticationError ConnectionError InvalidRequestError UnknownSystemError

Remove a job

const job = await client.remove({ id: 'ofm1k9xF' })

Arguments

ParameterTypeRequiredDescription
idString*ID of the job to remove.

Returns

ParameterTypeRequiredDescription
jobJob*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

ParameterTypeRequiredDescription
idString*ID of the job to remove.
typeStringType of job ("id-verification").
idsIDFilter by a list of job IDs.
pageStringPaginate list by page where the page starts at 1, defaults to 1.
pageSizeStringThe number of items for a page, max 1000, defaults to 100.
sortByStringSort the list from ("date", "status").
sortOrderStringOrder the sort from ("asc", "desc").
statusStringFilter by status from ("active","completed")
toStringFilter by submitted to ISO8601 date.
fromStringFilter by submitted from ISO8601 date.
withPhotosBooleanDefaults to False. The returned job will contain detailed information idPhoto, idPhotoBack, and userPhoto.

Returns

ParameterTypeRequiredDescription
jobsJob*The removed job.
totalPagesInt*Total number of pages of jobs.
pageSizeInt*The requested page size.
pageInt*The requested page.
totalInt*Total number of filtered jobs.

Errors

AuthenticationError ConnectionError InvalidRequestError UnknownSystemError

Types

Errors

ParameterTypeRequiredDescription
typeString*
messageString*Type of job ("id-verification").
suggestionIDA suggestion for matching name, John Smith, Jon Smith.
errorsErrorInvalidRequestError 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

ParameterTypeRequiredDescription
idID*Job ID
statusString*Job status from ("active","completed")
submittedStringISO8601 date
requestObjectObject for 'id-verification'.
resultObjectObject of 'id-verification'.
errorsErrorList of errors for unsuccessful completed jobs.

request

ParameterTypeRequiredDescription
typeString*Job type
callbackURLStringPOST enabled webhook
parametersJobParameters*Object for 'id-verification'

result

ParameterTypeRequiredDescription
successBoolean*Did the id verification completed successfully?
typeStringThe id type
callbackURLStringPOST enabled webhook
stateStringThe issuing state of the id if applicable
countryStringThe issuing country of the id
idStringThe verified id number of the id
expireDateStringThe verified expired date in the format MM/DD/YYYY
birthDateStringThe verified date in the format MM/DD/YYYY
firstNameStringThe user's verified first name.
lastNameStringThe user's verified last name
confidencesConfidencesConfidence scores

Confidences

ParameterTypeRequiredDescription
idFloat*Confidence score for an id photo, 0-1.0
backIdFloat*Confidence score for the back of the id photo, 0-1.0
selfieFloat*Confidence score for a selfie photo, 0-1.0
idMatchFloat*Confidence score for matching data on the id, 0-1.0
faceMatchFloat*Confidence score for matching faces, 0-1.0

JobParameters

ParameterTypeRequiredDescription
idPhotoString*The user's official identification photo in base64.
userPhotoStringThe user's id comparison photo in base64.
twicPhotoStringThe user's id twic id photo in base64.
carInsurancePhotoStringThe user's id car insurance photo in base64.
dotPhotoString*The user's id dot letter photo in base64.
idPhotoBackStringThe user's official back of the identification photo in base64.
dobStringDate in the format MM/DD/YYYY.
firstNameStringThe user's first name.
lastNameStringThe 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'