@onfido/api 3.0.0 → 3.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -127,48 +127,9 @@ export const serializeDataIfNeeded = function (value, requestOptions, configurat
127
127
  ? configuration.isJsonMime(requestOptions.headers['Content-Type'])
128
128
  : nonString;
129
129
  return needsSerialization
130
- ? JSON.stringify(value !== undefined ? convertMapsAndSetsToPlain(value) : {})
130
+ ? JSON.stringify(value !== undefined ? value : {})
131
131
  : (value || "");
132
132
  };
133
- function convertMapsAndSetsToPlain(value) {
134
- if (typeof Set === "undefined")
135
- return value;
136
- if (typeof Map === "undefined")
137
- return value;
138
- if (typeof value !== "object" || !value) {
139
- return value;
140
- }
141
- if (value instanceof Set) {
142
- return Array.from(value).map(item => convertMapsAndSetsToPlain(item));
143
- }
144
- if (value instanceof Map) {
145
- const entries = [];
146
- value.forEach((value, key) => {
147
- entries.push([key, convertMapsAndSetsToPlain(value)]);
148
- });
149
- return objectFromEntries(entries);
150
- }
151
- if (Array.isArray(value)) {
152
- return value.map(it => convertMapsAndSetsToPlain(it));
153
- }
154
- return objectFromEntries(objectEntries(value)
155
- .map(([k, v]) => [k, convertMapsAndSetsToPlain(v)]));
156
- }
157
- /**
158
- * Ponyfill for Object.entries
159
- */
160
- function objectEntries(object) {
161
- return Object.keys(object).map(key => [key, object[key]]);
162
- }
163
- /**
164
- * Ponyfill for Object.fromEntries
165
- */
166
- function objectFromEntries(entries) {
167
- return [...entries].reduce((object, [key, val]) => {
168
- object[key] = val;
169
- return object;
170
- }, {});
171
- }
172
133
  /**
173
134
  *
174
135
  * @export
@@ -29,7 +29,7 @@ export class Configuration {
29
29
  }
30
30
  this.apiKey = 'Token token=' + param.apiToken;
31
31
  this.basePath = param.basePath || BASE_PATH.replace('.eu.', `.${Region[param.region || Region.EU].toLowerCase()}.`);
32
- this.baseOptions = Object.assign(Object.assign({ timeout: 30000 }, param.baseOptions), { headers: Object.assign(Object.assign({}, (_a = param.baseOptions) === null || _a === void 0 ? void 0 : _a.headers), { 'User-Agent': 'onfido-node/3.0.0' }) });
32
+ this.baseOptions = Object.assign(Object.assign({ timeout: 30000 }, param.baseOptions), { headers: Object.assign(Object.assign({}, (_a = param.baseOptions) === null || _a === void 0 ? void 0 : _a.headers), { 'User-Agent': 'onfido-node/3.1.0' }) });
33
33
  this.formDataCtor = param.formDataCtor || require('form-data'); // Injiect form data constructor (if needed)
34
34
  }
35
35
  /**
@@ -0,0 +1,10 @@
1
+ /// <reference types="node" />
2
+ /// <reference types="node" />
3
+ import { PathLike } from "fs";
4
+ export declare class FileTransfer {
5
+ readonly buffer: Buffer;
6
+ readonly filename: String;
7
+ constructor(buffer: String, filename: String);
8
+ constructor(buffer: Buffer, filename: String);
9
+ constructor(inputFile: PathLike);
10
+ }
@@ -0,0 +1,13 @@
1
+ import { readFileSync } from "fs";
2
+ export class FileTransfer {
3
+ constructor(data, filename) {
4
+ if (filename == null) {
5
+ this.buffer = readFileSync(data);
6
+ this.filename = data.toString();
7
+ }
8
+ else {
9
+ this.buffer = data;
10
+ this.filename = filename;
11
+ }
12
+ }
13
+ }
@@ -12,3 +12,4 @@
12
12
  export * from "./api";
13
13
  export * from "./configuration";
14
14
  export * from "./webhook-event-verifier";
15
+ export * from "./file-transfer";
package/dist/esm/index.js CHANGED
@@ -14,3 +14,4 @@
14
14
  export * from "./api";
15
15
  export * from "./configuration";
16
16
  export * from "./webhook-event-verifier";
17
+ export * from "./file-transfer";
@@ -0,0 +1,10 @@
1
+ /// <reference types="node" />
2
+ /// <reference types="node" />
3
+ import { PathLike } from "fs";
4
+ export declare class FileTransfer {
5
+ readonly buffer: Buffer;
6
+ readonly filename: String;
7
+ constructor(buffer: String, filename: String);
8
+ constructor(buffer: Buffer, filename: String);
9
+ constructor(inputFile: PathLike);
10
+ }
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FileTransfer = void 0;
4
+ const fs_1 = require("fs");
5
+ class FileTransfer {
6
+ constructor(data, filename) {
7
+ if (filename == null) {
8
+ this.buffer = (0, fs_1.readFileSync)(data);
9
+ this.filename = data.toString();
10
+ }
11
+ else {
12
+ this.buffer = data;
13
+ this.filename = filename;
14
+ }
15
+ }
16
+ }
17
+ exports.FileTransfer = FileTransfer;
package/dist/index.d.ts CHANGED
@@ -12,3 +12,4 @@
12
12
  export * from "./api";
13
13
  export * from "./configuration";
14
14
  export * from "./webhook-event-verifier";
15
+ export * from "./file-transfer";
package/dist/index.js CHANGED
@@ -30,3 +30,4 @@ Object.defineProperty(exports, "__esModule", { value: true });
30
30
  __exportStar(require("./api"), exports);
31
31
  __exportStar(require("./configuration"), exports);
32
32
  __exportStar(require("./webhook-event-verifier"), exports);
33
+ __exportStar(require("./file-transfer"), exports);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onfido/api",
3
- "version": "3.0.0",
3
+ "version": "3.1.0",
4
4
  "description": "Node.js library for the Onfido API",
5
5
  "author": "OpenAPI-Generator Contributors",
6
6
  "repository": {
@@ -54,8 +54,8 @@
54
54
  "prettier": "^1.18.2",
55
55
  "ts-jest": "^26.4.4",
56
56
  "dotenv": "^16.4.5",
57
- "@types/node": "^12.11.5",
58
- "typescript": "^4.0"
57
+ "@types/node": "12.11.5 - 12.20.42",
58
+ "typescript": "^4.0 || ^5.0"
59
59
  },
60
60
  "publishConfig": {
61
61
  "access": "public"