New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@onfido/api

Package Overview
Dependencies
Maintainers
1
Versions
43
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@onfido/api - npm Package Compare versions

Comparing version 1.1.0 to 1.2.0

9

dist/formatting.d.ts

@@ -0,7 +1,16 @@

/// <reference types="node" />
import FormData from "form-data";
import { Readable } from "stream";
export declare type SimpleObject = {
[key: string]: unknown;
};
declare type ContentsAndOptions = {
contents: Readable;
filepath: string;
contentType?: string;
};
export declare type FileLike = Readable | ContentsAndOptions;
export declare const convertObjectToSnakeCase: (requestBody: unknown) => unknown;
export declare const convertObjectToCamelCase: (responseBody: SimpleObject) => SimpleObject;
export declare const toFormData: (object: SimpleObject) => FormData;
export {};

1

dist/index.d.ts

@@ -5,2 +5,3 @@ export { Onfido, OnfidoOptions, Region } from "./Onfido";

export { OnfidoApiError } from "./errors/OnfidoApiError";
export { FileLike } from "./formatting";
export { WebhookEvent, WebhookEventVerifier } from "./WebhookEventVerifier";

@@ -7,0 +8,0 @@ export { Applicant, ApplicantRequest } from "./resources/Applicants";

@@ -36,2 +36,29 @@ import axios from 'axios';

/*! *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */
function __rest(s, e) {
var t = {};
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
t[p] = s[p];
if (s != null && typeof Object.getOwnPropertySymbols === "function")
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
t[p[i]] = s[p[i]];
}
return t;
}
const snakeCase = (s) => s.replace(/[A-Z]/g, char => `_${char.toLowerCase()}`);

@@ -61,3 +88,7 @@ const camelCase = (s) => s.replace(/_[a-z]/g, underscoreChar => underscoreChar[1].toUpperCase());

return Object.entries(object).reduce((formData, [key, value]) => {
if (value !== undefined && value !== null) {
if (value instanceof Object && "contents" in value) {
const _a = value, { contents } = _a, options = __rest(_a, ["contents"]);
formData.append(snakeCase(key), contents, options);
}
else if (value !== undefined && value !== null) {
formData.append(snakeCase(key), value);

@@ -363,6 +394,8 @@ }

Region["US"] = "US";
Region["CA"] = "CA";
})(Region || (Region = {}));
const apiUrls = {
[Region.EU]: "https://api.onfido.com/v3/",
[Region.US]: "https://api.us.onfido.com/v3/"
[Region.US]: "https://api.us.onfido.com/v3/",
[Region.CA]: "https://api.ca.onfido.com/v3/"
};

@@ -369,0 +402,0 @@ class Onfido {

@@ -42,2 +42,29 @@ 'use strict';

/*! *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */
function __rest(s, e) {
var t = {};
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
t[p] = s[p];
if (s != null && typeof Object.getOwnPropertySymbols === "function")
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
t[p[i]] = s[p[i]];
}
return t;
}
const snakeCase = (s) => s.replace(/[A-Z]/g, char => `_${char.toLowerCase()}`);

@@ -67,3 +94,7 @@ const camelCase = (s) => s.replace(/_[a-z]/g, underscoreChar => underscoreChar[1].toUpperCase());

return Object.entries(object).reduce((formData, [key, value]) => {
if (value !== undefined && value !== null) {
if (value instanceof Object && "contents" in value) {
const _a = value, { contents } = _a, options = __rest(_a, ["contents"]);
formData.append(snakeCase(key), contents, options);
}
else if (value !== undefined && value !== null) {
formData.append(snakeCase(key), value);

@@ -368,6 +399,8 @@ }

Region["US"] = "US";
Region["CA"] = "CA";
})(exports.Region || (exports.Region = {}));
const apiUrls = {
[exports.Region.EU]: "https://api.onfido.com/v3/",
[exports.Region.US]: "https://api.us.onfido.com/v3/"
[exports.Region.US]: "https://api.us.onfido.com/v3/",
[exports.Region.CA]: "https://api.ca.onfido.com/v3/"
};

@@ -374,0 +407,0 @@ class Onfido {

3

dist/Onfido.d.ts

@@ -13,3 +13,4 @@ import { AxiosInstance } from "axios";

EU = "EU",
US = "US"
US = "US",
CA = "CA"
}

@@ -16,0 +17,0 @@ export declare type OnfidoOptions = {

@@ -6,2 +6,3 @@ import { AxiosInstance } from "axios";

reportNames: string[];
documentIds?: string[] | null;
applicantProvidesData?: boolean;

@@ -8,0 +9,0 @@ asynchronous?: boolean;

@@ -1,4 +0,3 @@

/// <reference types="node" />
import { AxiosInstance } from "axios";
import { ReadStream } from "fs";
import { FileLike } from "../formatting";
import { OnfidoDownload } from "../OnfidoDownload";

@@ -8,3 +7,3 @@ import { Resource } from "../Resource";

applicantId?: string | null;
file: ReadStream;
file: FileLike;
type: string;

@@ -11,0 +10,0 @@ side?: string | null;

@@ -1,4 +0,3 @@

/// <reference types="node" />
import { AxiosInstance } from "axios";
import { ReadStream } from "fs";
import { FileLike } from "../formatting";
import { OnfidoDownload } from "../OnfidoDownload";

@@ -8,3 +7,3 @@ import { Resource } from "../Resource";

applicantId: string;
file: ReadStream;
file: FileLike;
advancedValidation?: boolean;

@@ -11,0 +10,0 @@ };

{
"name": "@onfido/api",
"version": "1.1.0",
"version": "1.2.0",
"description": "Node.js library for the Onfido API",

@@ -5,0 +5,0 @@ "keywords": [

@@ -23,3 +23,3 @@ # Onfido Node.js Library

## Getting Started
## Getting started

@@ -43,3 +43,3 @@ Require the package:

apiToken: process.env.ONFIDO_API_TOKEN
// Defaults to EU region (api.onfido.com)
// Defaults to Region.EU (api.onfido.com), supports Region.US and Region.CA
// region: Region.US

@@ -156,4 +156,30 @@ });

## More Documentation
## File upload
For some common types of streams, like instances of `fs.ReadStream`, you can provide the stream directly in the `file` property:
```js
onfido.document.upload({
applicantId: "<APPLICANT_ID>",
file: fs.createReadStream("path/to/passport.png"),
type: "passport"
});
```
Alternatively, you may need to provide some extra information:
```js
onfido.livePhoto.upload({
applicantId: "<APPLICANT_ID>",
file: {
contents: stream,
filepath: "path/to/photo.png",
contentType: "image/png"
},
type: "passport"
});
```
## More documentation
More documentation and code examples can be found at <https://documentation.onfido.com>

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc