npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

onfido

v4.3.0

Published

Client library for the Onfido API.

Downloads

1,236

Readme

onfido

Onfido - JavaScript client for onfido The Onfido API is used to submit check requests.

This package is automatically generated by the OpenAPI Generator project:

  • API version: 2.0.0
  • Package version: 4.3.0
  • Build package: org.openapitools.codegen.languages.JavascriptClientCodegen

Installation

For Node.js

Install via npm:

npm install onfido

Alternatively, if you're using Yarn:

yarn add onfido

Frontend JavaScript: warning

You must not use this project in your application's frontend because it uses API tokens. Instead, you can use the Onfido Web SDK for frontend JavaScript.

If you use this project in your frontend, malicious users could discover the tokens in your source code. You should only use this project in your backend code.

You can read more about API token security in the Onfido API reference documentation.

Getting Started

Please follow the installation instruction and execute the following JS code:

const Onfido = require('onfido');

const defaultClient = Onfido.ApiClient.instance;

// Configure API key authorization: Token
const token_auth = defaultClient.authentications['Token'];
token_auth.apiKey = 'token=' + 'YOUR API KEY';
token_auth.apiKeyPrefix = 'Token';

// Limit the at-rest region, if needed (optional, see https://documentation.onfido.com/#regions)
// defaultClient.basePath = Onfido.ApiClient.getBasePathFromSettings(1, {region: 'us'});

const api = new Onfido.DefaultApi();

// Setting applicant details
const applicant = new Onfido.Applicant();
applicant.first_name = 'John';
applicant.last_name = 'Smith';
applicant.dob = new Date('1980-01-22');
applicant.country = 'GBR';

// You can also use getters and setters for properties using camelCase:
// applicant.setFirstName('John');
// applicant.setLastName('Smith');

const address = new Onfido.Address();
address.building_number = '100';
address.street = 'Main Street';
address.town = 'London';
address.postcode = 'SW4 6EH';
address.country = 'GBR';

applicant.addresses = [address];

// Setting check details
const check = new Onfido.Check();
check.type = 'express';
const report = new Onfido.Report();
report.name = 'identity';
check.reports = [report];

// Using promises
api.createApplicant(applicant).then(applicantData => {
  const applicantId = applicantData.id;
  return api.createCheck(applicantId, check);
}).then(checkData => {
  console.log(checkData);
}).catch(error => {
  console.error(error.response.body);
});

// Using async/await
(async () => {
  try {
    const applicantData = await api.createApplicant(applicant);
    const applicantId = applicantData.id;
    const checkData = await api.createCheck(applicantId, check);
    console.log(checkData);
  } catch(error) {
    console.error(error.response.body);
  }
})();

Uploading and Downloading

For uploading files, the file argument should be a Readable Stream. For example, for uploading a document:

const documentImage = fs.createReadStream('document.png');
api.uploadDocument(applicantId, 'passport', documentImage);

There is currently an issue with OpenAPI Generator, the tool used to generate this library, that prevents downloading files from working in Node. As a workaround, you can use the API endpoints for downloading files directly. See the API documentation for more info:

  • Documents: https://documentation.onfido.com/#download-document
  • Live Photos: https://documentation.onfido.com/#download-live-video

Documentation for API Endpoints

All URIs are relative to https://api.onfido.com/v2

Class | Method | HTTP request | Description ------------ | ------------- | ------------- | ------------- Onfido.DefaultApi | cancelReport | POST /checks/{check_id}/reports/{report_id}/cancel | This endpoint is for cancelling individual paused reports. Onfido.DefaultApi | createApplicant | POST /applicants | Create Applicant Onfido.DefaultApi | createCheck | POST /applicants/{applicant_id}/checks | Create a check Onfido.DefaultApi | createWebhook | POST /webhooks | Create a webhook Onfido.DefaultApi | deleteWebhook | DELETE /webhooks/{webhook_id} | Delete a webhook Onfido.DefaultApi | destroyApplicant | DELETE /applicants/{applicant_id} | Delete Applicant Onfido.DefaultApi | downloadDocument | GET /applicants/{applicant_id}/documents/{document_id}/download | Download a documents raw data Onfido.DefaultApi | downloadLivePhoto | GET /live_photos/{live_photo_id}/download | Download live photo Onfido.DefaultApi | downloadLiveVideo | GET /live_videos/{live_video_id}/download | Download live video Onfido.DefaultApi | editWebhook | PUT /webhooks/{webhook_id} | Edit a webhook Onfido.DefaultApi | findAddresses | GET /addresses/pick | Search for addresses by postcode Onfido.DefaultApi | findApplicant | GET /applicants/{applicant_id} | Retrieve Applicant Onfido.DefaultApi | findCheck | GET /applicants/{applicant_id}/checks/{check_id} | Retrieve a Check Onfido.DefaultApi | findDocument | GET /applicants/{applicant_id}/documents/{document_id} | A single document can be retrieved by calling this endpoint with the document’s unique identifier. Onfido.DefaultApi | findLivePhoto | GET /live_photos/{live_photo_id} | Retrieve live photo Onfido.DefaultApi | findLiveVideo | GET /live_videos/{live_video_id} | Retrieve live video Onfido.DefaultApi | findReport | GET /checks/{check_id}/reports/{report_id} | A single report can be retrieved using this endpoint with the corresponding unique identifier. Onfido.DefaultApi | findReportTypeGroup | GET /report_type_groups/{report_type_group_id} | Retrieve single report type group object Onfido.DefaultApi | findWebhook | GET /webhooks/{webhook_id} | Retrieve a Webhook Onfido.DefaultApi | generateSdkToken | POST /sdk_token | Generate a SDK token Onfido.DefaultApi | listApplicants | GET /applicants | List Applicants Onfido.DefaultApi | listChecks | GET /applicants/{applicant_id}/checks | Retrieve Checks Onfido.DefaultApi | listDocuments | GET /applicants/{applicant_id}/documents | List documents Onfido.DefaultApi | listLivePhotos | GET /live_photos | List live photos Onfido.DefaultApi | listLiveVideos | GET /live_videos | List live videos Onfido.DefaultApi | listReportTypeGroups | GET /report_type_groups | Retrieve all report type groups Onfido.DefaultApi | listReports | GET /checks/{check_id}/reports | All the reports belonging to a particular check can be listed from this endpoint. Onfido.DefaultApi | listWebhooks | GET /webhooks | List webhooks Onfido.DefaultApi | restoreApplicant | POST /applicants/{applicant_id}/restore | Restore Applicant Onfido.DefaultApi | resumeCheck | POST /checks/{check_id}/resume | Resume a Check Onfido.DefaultApi | resumeReport | POST /checks/{check_id}/reports/{report_id}/resume | This endpoint is for resuming individual paused reports. Onfido.DefaultApi | updateApplicant | PUT /applicants/{applicant_id} | Update Applicant Onfido.DefaultApi | uploadDocument | POST /applicants/{applicant_id}/documents | Upload a document Onfido.DefaultApi | uploadLivePhoto | POST /live_photos | Upload live photo

Documentation for Models

Documentation for Authorization

Token

  • Type: API key
  • API key parameter name: Authorization
  • Location: HTTP header