@onfido/api 2.9.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.
- package/LICENSE +1 -1
- package/README.md +138 -132
- package/dist/api.d.ts +12036 -0
- package/dist/api.js +5284 -0
- package/dist/base.d.ts +66 -0
- package/dist/base.js +65 -0
- package/dist/common.d.ts +66 -0
- package/dist/common.js +162 -0
- package/dist/configuration.d.ts +93 -0
- package/dist/configuration.js +53 -0
- package/dist/esm/api.d.ts +12036 -0
- package/dist/esm/api.js +5277 -0
- package/dist/esm/base.d.ts +66 -0
- package/dist/esm/base.js +60 -0
- package/dist/esm/common.d.ts +66 -0
- package/dist/esm/common.js +150 -0
- package/dist/esm/configuration.d.ts +93 -0
- package/dist/esm/configuration.js +49 -0
- package/dist/esm/file-transfer.d.ts +10 -0
- package/dist/esm/file-transfer.js +13 -0
- package/dist/esm/index.d.ts +15 -0
- package/dist/esm/index.js +17 -0
- package/dist/esm/webhook-event-verifier.d.ts +9 -0
- package/dist/esm/webhook-event-verifier.js +31 -0
- package/dist/file-transfer.d.ts +10 -0
- package/dist/file-transfer.js +17 -0
- package/dist/index.d.ts +15 -19
- package/dist/index.js +32 -553
- package/dist/webhook-event-verifier.d.ts +9 -0
- package/dist/webhook-event-verifier.js +36 -0
- package/package.json +30 -31
- package/CHANGELOG.md +0 -121
- package/dist/Onfido.d.ts +0 -40
- package/dist/OnfidoDownload.d.ts +0 -9
- package/dist/Resource.d.ts +0 -22
- package/dist/WebhookEventVerifier.d.ts +0 -17
- package/dist/errors/OnfidoApiError.d.ts +0 -10
- package/dist/errors/OnfidoError.d.ts +0 -3
- package/dist/formatting.d.ts +0 -16
- package/dist/index.es.js +0 -544
- package/dist/index.es.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/resources/Addresses.d.ts +0 -27
- package/dist/resources/Applicants.d.ts +0 -44
- package/dist/resources/Autofill.d.ts +0 -37
- package/dist/resources/Checks.d.ts +0 -42
- package/dist/resources/ConsentsRequest.d.ts +0 -4
- package/dist/resources/Documents.d.ts +0 -34
- package/dist/resources/IdNumbers.d.ts +0 -10
- package/dist/resources/LivePhotos.d.ts +0 -25
- package/dist/resources/LiveVideos.d.ts +0 -19
- package/dist/resources/Location.d.ts +0 -8
- package/dist/resources/MotionCaptures.d.ts +0 -19
- package/dist/resources/Reports.d.ts +0 -24
- package/dist/resources/SdkTokens.d.ts +0 -12
- package/dist/resources/Webhooks.d.ts +0 -26
- package/dist/resources/WorkflowRuns.d.ts +0 -48
- package/dist/types/formData.d.ts +0 -27
package/dist/index.es.js
DELETED
|
@@ -1,544 +0,0 @@
|
|
|
1
|
-
import axios from 'axios';
|
|
2
|
-
import { PassThrough, Readable } from 'stream';
|
|
3
|
-
|
|
4
|
-
var version = "2.9.0";
|
|
5
|
-
|
|
6
|
-
class OnfidoError extends Error {
|
|
7
|
-
constructor(message) {
|
|
8
|
-
super(message);
|
|
9
|
-
this.name = "OnfidoError";
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
class OnfidoApiError extends OnfidoError {
|
|
14
|
-
constructor(message, responseBody, statusCode, type, fields) {
|
|
15
|
-
super(message);
|
|
16
|
-
this.name = "OnfidoApiError";
|
|
17
|
-
this.responseBody = responseBody;
|
|
18
|
-
this.statusCode = statusCode;
|
|
19
|
-
this.type = type;
|
|
20
|
-
this.fields = fields;
|
|
21
|
-
}
|
|
22
|
-
static fromResponse(responseBody, statusCode) {
|
|
23
|
-
const innerErrorData = responseBody instanceof Object ? responseBody.error : {};
|
|
24
|
-
const innerError = innerErrorData instanceof Object ? innerErrorData : {};
|
|
25
|
-
const type = `${innerError.type || "unknown"}`;
|
|
26
|
-
const message = `${innerError.message || responseBody}`;
|
|
27
|
-
const fields = innerError.fields;
|
|
28
|
-
const fullMessage = `${message} (status code ${statusCode})` +
|
|
29
|
-
(fields ? ` | ${JSON.stringify(fields)}` : "");
|
|
30
|
-
return new OnfidoApiError(fullMessage, responseBody, statusCode, type, fields);
|
|
31
|
-
}
|
|
32
|
-
isClientError() {
|
|
33
|
-
return this.statusCode < 500;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
/*! *****************************************************************************
|
|
38
|
-
Copyright (c) Microsoft Corporation. All rights reserved.
|
|
39
|
-
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
|
40
|
-
this file except in compliance with the License. You may obtain a copy of the
|
|
41
|
-
License at http://www.apache.org/licenses/LICENSE-2.0
|
|
42
|
-
|
|
43
|
-
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
44
|
-
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
|
|
45
|
-
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
|
|
46
|
-
MERCHANTABLITY OR NON-INFRINGEMENT.
|
|
47
|
-
|
|
48
|
-
See the Apache Version 2.0 License for specific language governing permissions
|
|
49
|
-
and limitations under the License.
|
|
50
|
-
***************************************************************************** */
|
|
51
|
-
|
|
52
|
-
function __rest(s, e) {
|
|
53
|
-
var t = {};
|
|
54
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
55
|
-
t[p] = s[p];
|
|
56
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
57
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
58
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
59
|
-
t[p[i]] = s[p[i]];
|
|
60
|
-
}
|
|
61
|
-
return t;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
// Using require because "form-data" exports this object as a default export which breaks integration when esModuleInterop: false
|
|
65
|
-
// tslint:disable-next-line: no-var-requires
|
|
66
|
-
const FormData = require("form-data");
|
|
67
|
-
const snakeCase = (camelCaseString) => camelCaseString.replace(/[A-Z]/g, char => `_${char.toLowerCase()}`);
|
|
68
|
-
const formatValue = (value) => {
|
|
69
|
-
if (typeof value === 'boolean') {
|
|
70
|
-
return String(value);
|
|
71
|
-
}
|
|
72
|
-
else {
|
|
73
|
-
return value;
|
|
74
|
-
}
|
|
75
|
-
};
|
|
76
|
-
const camelCase = (snakeCaseString) => snakeCaseString
|
|
77
|
-
.replace(/_[0-9]/g, underscoreDigit => underscoreDigit[1])
|
|
78
|
-
.replace(/_[a-z]/g, underscoreChar => underscoreChar[1].toUpperCase());
|
|
79
|
-
const deepMapObjectKeys = (value, f) => {
|
|
80
|
-
if (!(value instanceof Object)) {
|
|
81
|
-
return value;
|
|
82
|
-
}
|
|
83
|
-
else if (Array.isArray(value)) {
|
|
84
|
-
return value.map(item => deepMapObjectKeys(item, f));
|
|
85
|
-
}
|
|
86
|
-
else {
|
|
87
|
-
return Object.keys(value).reduce((acc, key) => {
|
|
88
|
-
acc[f(key)] = deepMapObjectKeys(value[key], f);
|
|
89
|
-
return acc;
|
|
90
|
-
}, {});
|
|
91
|
-
}
|
|
92
|
-
};
|
|
93
|
-
const convertObjectToSnakeCase = (requestBody) => {
|
|
94
|
-
// Converting to JSON and back first handles things like dates, circular references etc.
|
|
95
|
-
requestBody = JSON.parse(JSON.stringify(requestBody));
|
|
96
|
-
return deepMapObjectKeys(requestBody, snakeCase);
|
|
97
|
-
};
|
|
98
|
-
const convertObjectToCamelCase = (responseBody) => deepMapObjectKeys(responseBody, camelCase);
|
|
99
|
-
const toFormData = (object) => {
|
|
100
|
-
return Object.entries(object).reduce((formData, [key, value]) => {
|
|
101
|
-
if (value instanceof Object && "contents" in value) {
|
|
102
|
-
const _a = value, { contents } = _a, options = __rest(_a, ["contents"]);
|
|
103
|
-
formData.append(snakeCase(key), contents, options);
|
|
104
|
-
}
|
|
105
|
-
else if (value !== undefined && value !== null) {
|
|
106
|
-
if (value instanceof Object) {
|
|
107
|
-
for (const [elementKey, elementValue] of Object.entries(value)) {
|
|
108
|
-
formData.append(snakeCase(key + "[" + elementKey + "]"), elementValue);
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
else {
|
|
112
|
-
formData.append(snakeCase(key), formatValue(value));
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
return formData;
|
|
116
|
-
}, new FormData());
|
|
117
|
-
};
|
|
118
|
-
|
|
119
|
-
class OnfidoDownload {
|
|
120
|
-
constructor(incomingMessage) {
|
|
121
|
-
this.incomingMessage = incomingMessage;
|
|
122
|
-
}
|
|
123
|
-
asStream() {
|
|
124
|
-
// Use a PassThrough stream so the IncomingMessage isn't exposed.
|
|
125
|
-
const passThroughStream = new PassThrough();
|
|
126
|
-
this.incomingMessage.pipe(passThroughStream);
|
|
127
|
-
return passThroughStream;
|
|
128
|
-
}
|
|
129
|
-
get contentType() {
|
|
130
|
-
return this.incomingMessage.headers["content-type"];
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
var Method;
|
|
135
|
-
(function (Method) {
|
|
136
|
-
Method["GET"] = "get";
|
|
137
|
-
Method["POST"] = "post";
|
|
138
|
-
Method["PUT"] = "put";
|
|
139
|
-
Method["DELETE"] = "delete";
|
|
140
|
-
})(Method || (Method = {}));
|
|
141
|
-
const isJson = (response) => (response.headers["content-type"] || "").includes("application/json");
|
|
142
|
-
const readFullStream = (stream) => new Promise((resolve) => {
|
|
143
|
-
let all = "";
|
|
144
|
-
stream.on("data", data => (all += data));
|
|
145
|
-
stream.on("error", () => resolve("An error occurred reading the response"));
|
|
146
|
-
stream.on("end", () => {
|
|
147
|
-
// Try to parse as JSON, but fall back to just returning the raw text.
|
|
148
|
-
try {
|
|
149
|
-
resolve(JSON.parse(all));
|
|
150
|
-
}
|
|
151
|
-
catch (_a) {
|
|
152
|
-
resolve(all);
|
|
153
|
-
}
|
|
154
|
-
});
|
|
155
|
-
});
|
|
156
|
-
const convertAxiosErrorToOnfidoError = async (error) => {
|
|
157
|
-
if (!error.response) {
|
|
158
|
-
return new OnfidoError(error.message || "An unknown error occurred making the request");
|
|
159
|
-
}
|
|
160
|
-
// Received a 4XX or 5XX response.
|
|
161
|
-
const response = error.response;
|
|
162
|
-
const data = response.data;
|
|
163
|
-
// If we were downloading a file, we will have a stream instead of a string.
|
|
164
|
-
const body = data instanceof Readable ? await readFullStream(data) : data;
|
|
165
|
-
return OnfidoApiError.fromResponse(body, response.status);
|
|
166
|
-
};
|
|
167
|
-
const handleResponse = async (request) => {
|
|
168
|
-
try {
|
|
169
|
-
const response = await request;
|
|
170
|
-
const data = response.data;
|
|
171
|
-
return isJson(response) ? convertObjectToCamelCase(data) : data;
|
|
172
|
-
}
|
|
173
|
-
catch (error) {
|
|
174
|
-
throw await convertAxiosErrorToOnfidoError(error);
|
|
175
|
-
}
|
|
176
|
-
};
|
|
177
|
-
class Resource {
|
|
178
|
-
constructor(name, axiosInstance) {
|
|
179
|
-
this.name = name;
|
|
180
|
-
this.axiosInstance = axiosInstance;
|
|
181
|
-
}
|
|
182
|
-
async request({ method, path = "", body, query }) {
|
|
183
|
-
const url = path === null ? `${this.name}` : `${this.name}/${path}`;
|
|
184
|
-
const request = this.axiosInstance({
|
|
185
|
-
method,
|
|
186
|
-
url: url,
|
|
187
|
-
data: body && convertObjectToSnakeCase(body),
|
|
188
|
-
params: query && convertObjectToSnakeCase(query)
|
|
189
|
-
});
|
|
190
|
-
return handleResponse(request);
|
|
191
|
-
}
|
|
192
|
-
async upload(body) {
|
|
193
|
-
const formData = toFormData(body);
|
|
194
|
-
const request = this.axiosInstance({
|
|
195
|
-
method: Method.POST,
|
|
196
|
-
url: `${this.name}/`,
|
|
197
|
-
data: formData,
|
|
198
|
-
headers: formData.getHeaders()
|
|
199
|
-
});
|
|
200
|
-
return handleResponse(request);
|
|
201
|
-
}
|
|
202
|
-
async download(path) {
|
|
203
|
-
const request = this.axiosInstance({
|
|
204
|
-
method: Method.GET,
|
|
205
|
-
url: `${this.name}/${path}`,
|
|
206
|
-
responseType: "stream",
|
|
207
|
-
// Accept a response with any content type (e.g. image/png, application/pdf, video/mp4)
|
|
208
|
-
headers: { Accept: "*/*" }
|
|
209
|
-
});
|
|
210
|
-
const stream = await handleResponse(request);
|
|
211
|
-
return new OnfidoDownload(stream);
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
class Addresses extends Resource {
|
|
216
|
-
constructor(axiosInstance) {
|
|
217
|
-
super("addresses", axiosInstance);
|
|
218
|
-
}
|
|
219
|
-
async pick(postcode) {
|
|
220
|
-
const { addresses } = await this.request({
|
|
221
|
-
method: Method.GET,
|
|
222
|
-
path: "pick",
|
|
223
|
-
query: { postcode }
|
|
224
|
-
});
|
|
225
|
-
return addresses;
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
class Applicants extends Resource {
|
|
230
|
-
constructor(axiosInstance) {
|
|
231
|
-
super("applicants", axiosInstance);
|
|
232
|
-
}
|
|
233
|
-
async create(applicantRequest) {
|
|
234
|
-
return this.request({ method: Method.POST, body: applicantRequest });
|
|
235
|
-
}
|
|
236
|
-
async find(id) {
|
|
237
|
-
return this.request({ method: Method.GET, path: id });
|
|
238
|
-
}
|
|
239
|
-
async update(id, applicantRequest) {
|
|
240
|
-
return this.request({
|
|
241
|
-
method: Method.PUT,
|
|
242
|
-
path: id,
|
|
243
|
-
body: applicantRequest
|
|
244
|
-
});
|
|
245
|
-
}
|
|
246
|
-
async delete(id) {
|
|
247
|
-
await this.request({ method: Method.DELETE, path: id });
|
|
248
|
-
}
|
|
249
|
-
async restore(id) {
|
|
250
|
-
await this.request({ method: Method.POST, path: `${id}/restore` });
|
|
251
|
-
}
|
|
252
|
-
async list({ page, perPage, includeDeleted } = {}) {
|
|
253
|
-
const { applicants } = await this.request({
|
|
254
|
-
method: Method.GET,
|
|
255
|
-
query: { page, perPage, includeDeleted }
|
|
256
|
-
});
|
|
257
|
-
return applicants;
|
|
258
|
-
}
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
class Autofill extends Resource {
|
|
262
|
-
constructor(axiosInstance) {
|
|
263
|
-
super("extractions", axiosInstance);
|
|
264
|
-
}
|
|
265
|
-
async perform(documentId) {
|
|
266
|
-
return this.request({
|
|
267
|
-
method: Method.POST,
|
|
268
|
-
body: { documentId }
|
|
269
|
-
});
|
|
270
|
-
}
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
class Checks extends Resource {
|
|
274
|
-
constructor(axiosInstance) {
|
|
275
|
-
super("checks", axiosInstance);
|
|
276
|
-
}
|
|
277
|
-
async create(checkRequest) {
|
|
278
|
-
return this.request({ method: Method.POST, body: checkRequest });
|
|
279
|
-
}
|
|
280
|
-
async find(id) {
|
|
281
|
-
return this.request({ method: Method.GET, path: id });
|
|
282
|
-
}
|
|
283
|
-
async list(applicantId) {
|
|
284
|
-
const { checks } = await this.request({
|
|
285
|
-
method: Method.GET,
|
|
286
|
-
query: { applicantId }
|
|
287
|
-
});
|
|
288
|
-
return checks;
|
|
289
|
-
}
|
|
290
|
-
async resume(id) {
|
|
291
|
-
await this.request({ method: Method.POST, path: `${id}/resume` });
|
|
292
|
-
}
|
|
293
|
-
async download(id) {
|
|
294
|
-
return super.download(`${id}/download`);
|
|
295
|
-
}
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
class Documents extends Resource {
|
|
299
|
-
constructor(axiosInstance) {
|
|
300
|
-
super("documents", axiosInstance);
|
|
301
|
-
}
|
|
302
|
-
async upload(documentRequest) {
|
|
303
|
-
return super.upload(documentRequest);
|
|
304
|
-
}
|
|
305
|
-
async download(id) {
|
|
306
|
-
return super.download(`${id}/download`);
|
|
307
|
-
}
|
|
308
|
-
async find(id) {
|
|
309
|
-
return this.request({ method: Method.GET, path: id });
|
|
310
|
-
}
|
|
311
|
-
async list(applicantId) {
|
|
312
|
-
const { documents } = await this.request({
|
|
313
|
-
method: Method.GET,
|
|
314
|
-
query: { applicantId }
|
|
315
|
-
});
|
|
316
|
-
return documents;
|
|
317
|
-
}
|
|
318
|
-
}
|
|
319
|
-
|
|
320
|
-
class LivePhotos extends Resource {
|
|
321
|
-
constructor(axiosInstance) {
|
|
322
|
-
super("live_photos", axiosInstance);
|
|
323
|
-
}
|
|
324
|
-
async upload(livePhotoRequest) {
|
|
325
|
-
return super.upload(livePhotoRequest);
|
|
326
|
-
}
|
|
327
|
-
async download(id) {
|
|
328
|
-
return super.download(`${id}/download`);
|
|
329
|
-
}
|
|
330
|
-
async find(id) {
|
|
331
|
-
return this.request({ method: Method.GET, path: id });
|
|
332
|
-
}
|
|
333
|
-
async list(applicantId) {
|
|
334
|
-
const { livePhotos } = await this.request({
|
|
335
|
-
method: Method.GET,
|
|
336
|
-
query: { applicantId }
|
|
337
|
-
});
|
|
338
|
-
return livePhotos;
|
|
339
|
-
}
|
|
340
|
-
}
|
|
341
|
-
|
|
342
|
-
class LiveVideos extends Resource {
|
|
343
|
-
constructor(axiosInstance) {
|
|
344
|
-
super("live_videos", axiosInstance);
|
|
345
|
-
}
|
|
346
|
-
async download(id) {
|
|
347
|
-
return super.download(`${id}/download`);
|
|
348
|
-
}
|
|
349
|
-
async frame(id) {
|
|
350
|
-
return super.download(`${id}/frame`);
|
|
351
|
-
}
|
|
352
|
-
async find(id) {
|
|
353
|
-
return this.request({ method: Method.GET, path: id });
|
|
354
|
-
}
|
|
355
|
-
async list(applicantId) {
|
|
356
|
-
const { liveVideos } = await this.request({
|
|
357
|
-
method: Method.GET,
|
|
358
|
-
query: { applicantId }
|
|
359
|
-
});
|
|
360
|
-
return liveVideos;
|
|
361
|
-
}
|
|
362
|
-
}
|
|
363
|
-
|
|
364
|
-
class MotionCaptures extends Resource {
|
|
365
|
-
constructor(axiosInstance) {
|
|
366
|
-
super("motion_captures", axiosInstance);
|
|
367
|
-
}
|
|
368
|
-
async download(id) {
|
|
369
|
-
return super.download(`${id}/download`);
|
|
370
|
-
}
|
|
371
|
-
async frame(id) {
|
|
372
|
-
return super.download(`${id}/frame`);
|
|
373
|
-
}
|
|
374
|
-
async find(id) {
|
|
375
|
-
return this.request({ method: Method.GET, path: id });
|
|
376
|
-
}
|
|
377
|
-
async list(applicantId) {
|
|
378
|
-
const { motionCaptures } = await this.request({
|
|
379
|
-
method: Method.GET,
|
|
380
|
-
query: { applicantId }
|
|
381
|
-
});
|
|
382
|
-
return motionCaptures;
|
|
383
|
-
}
|
|
384
|
-
}
|
|
385
|
-
|
|
386
|
-
class Reports extends Resource {
|
|
387
|
-
constructor(axiosInstance) {
|
|
388
|
-
super("reports", axiosInstance);
|
|
389
|
-
}
|
|
390
|
-
async find(id) {
|
|
391
|
-
return this.request({ method: Method.GET, path: id });
|
|
392
|
-
}
|
|
393
|
-
async list(checkId) {
|
|
394
|
-
const { reports } = await this.request({
|
|
395
|
-
method: Method.GET,
|
|
396
|
-
query: { checkId }
|
|
397
|
-
});
|
|
398
|
-
return reports;
|
|
399
|
-
}
|
|
400
|
-
async resume(id) {
|
|
401
|
-
await this.request({ method: Method.POST, path: `${id}/resume` });
|
|
402
|
-
}
|
|
403
|
-
async cancel(id) {
|
|
404
|
-
await this.request({ method: Method.POST, path: `${id}/cancel` });
|
|
405
|
-
}
|
|
406
|
-
}
|
|
407
|
-
|
|
408
|
-
class SdkTokens extends Resource {
|
|
409
|
-
constructor(axiosInstance) {
|
|
410
|
-
super("sdk_token", axiosInstance);
|
|
411
|
-
}
|
|
412
|
-
async generate(sdkTokenRequest) {
|
|
413
|
-
const { token } = await this.request({
|
|
414
|
-
method: Method.POST,
|
|
415
|
-
body: sdkTokenRequest
|
|
416
|
-
});
|
|
417
|
-
return token;
|
|
418
|
-
}
|
|
419
|
-
}
|
|
420
|
-
|
|
421
|
-
class Webhooks extends Resource {
|
|
422
|
-
constructor(axiosInstance) {
|
|
423
|
-
super("webhooks", axiosInstance);
|
|
424
|
-
}
|
|
425
|
-
async create(webhookRequest) {
|
|
426
|
-
return this.request({ method: Method.POST, body: webhookRequest });
|
|
427
|
-
}
|
|
428
|
-
async find(id) {
|
|
429
|
-
return this.request({ method: Method.GET, path: id });
|
|
430
|
-
}
|
|
431
|
-
async update(id, webhookRequest) {
|
|
432
|
-
return this.request({
|
|
433
|
-
method: Method.PUT,
|
|
434
|
-
path: id,
|
|
435
|
-
body: webhookRequest
|
|
436
|
-
});
|
|
437
|
-
}
|
|
438
|
-
async delete(id) {
|
|
439
|
-
await this.request({ method: Method.DELETE, path: id });
|
|
440
|
-
}
|
|
441
|
-
async list() {
|
|
442
|
-
const { webhooks } = await this.request({ method: Method.GET });
|
|
443
|
-
return webhooks;
|
|
444
|
-
}
|
|
445
|
-
}
|
|
446
|
-
|
|
447
|
-
class WorkflowRuns extends Resource {
|
|
448
|
-
constructor(axiosInstance) {
|
|
449
|
-
super("workflow_runs", axiosInstance);
|
|
450
|
-
}
|
|
451
|
-
async create(workflowRunRequest) {
|
|
452
|
-
return this.request({ method: Method.POST, body: workflowRunRequest });
|
|
453
|
-
}
|
|
454
|
-
async find(id) {
|
|
455
|
-
return this.request({ method: Method.GET, path: id });
|
|
456
|
-
}
|
|
457
|
-
async list(queryParams) {
|
|
458
|
-
const workflowRuns = await this.request({
|
|
459
|
-
method: Method.GET,
|
|
460
|
-
query: queryParams
|
|
461
|
-
});
|
|
462
|
-
return workflowRuns;
|
|
463
|
-
}
|
|
464
|
-
async evidence(id) {
|
|
465
|
-
return super.download(`${id}/signed_evidence_file`);
|
|
466
|
-
}
|
|
467
|
-
}
|
|
468
|
-
|
|
469
|
-
var Region;
|
|
470
|
-
(function (Region) {
|
|
471
|
-
Region["EU"] = "EU";
|
|
472
|
-
Region["US"] = "US";
|
|
473
|
-
Region["CA"] = "CA";
|
|
474
|
-
})(Region || (Region = {}));
|
|
475
|
-
class Onfido {
|
|
476
|
-
constructor({ apiToken, region, timeout = 30000, unknownApiUrl }) {
|
|
477
|
-
if (!apiToken) {
|
|
478
|
-
throw new Error("No apiToken provided");
|
|
479
|
-
}
|
|
480
|
-
if (!region || !Object.values(Region).includes(region)) {
|
|
481
|
-
throw new Error(`Unknown or missing region '${region}'. ` +
|
|
482
|
-
"We previously defaulted to region 'EU', so if you previously didn’t " +
|
|
483
|
-
"set a region or used api.onfido.com, please set your region to 'EU'");
|
|
484
|
-
}
|
|
485
|
-
const regionUrl = `https://api.${region.toLowerCase()}.onfido.com/v3.6/`;
|
|
486
|
-
this.axiosInstance = axios.create({
|
|
487
|
-
baseURL: unknownApiUrl || regionUrl,
|
|
488
|
-
headers: {
|
|
489
|
-
Authorization: `Token token=${apiToken}`,
|
|
490
|
-
Accept: "application/json",
|
|
491
|
-
"User-Agent": `onfido-node/${version}`
|
|
492
|
-
},
|
|
493
|
-
timeout
|
|
494
|
-
});
|
|
495
|
-
// Core resources
|
|
496
|
-
this.applicant = new Applicants(this.axiosInstance);
|
|
497
|
-
this.document = new Documents(this.axiosInstance);
|
|
498
|
-
this.livePhoto = new LivePhotos(this.axiosInstance);
|
|
499
|
-
this.liveVideo = new LiveVideos(this.axiosInstance);
|
|
500
|
-
this.motionCapture = new MotionCaptures(this.axiosInstance);
|
|
501
|
-
this.check = new Checks(this.axiosInstance);
|
|
502
|
-
this.report = new Reports(this.axiosInstance);
|
|
503
|
-
this.workflowRun = new WorkflowRuns(this.axiosInstance);
|
|
504
|
-
// Other endpoints
|
|
505
|
-
this.address = new Addresses(this.axiosInstance);
|
|
506
|
-
this.webhook = new Webhooks(this.axiosInstance);
|
|
507
|
-
this.sdkToken = new SdkTokens(this.axiosInstance);
|
|
508
|
-
this.autofill = new Autofill(this.axiosInstance);
|
|
509
|
-
}
|
|
510
|
-
}
|
|
511
|
-
|
|
512
|
-
// Require crypto instead of importing, because Node can be built without crypto support.
|
|
513
|
-
let crypto;
|
|
514
|
-
try {
|
|
515
|
-
// tslint:disable-next-line: no-var-requires
|
|
516
|
-
crypto = require("crypto");
|
|
517
|
-
}
|
|
518
|
-
catch (_a) {
|
|
519
|
-
// We throw an error when verifying webhooks instead.
|
|
520
|
-
}
|
|
521
|
-
class WebhookEventVerifier {
|
|
522
|
-
constructor(webhookToken) {
|
|
523
|
-
this.webhookToken = webhookToken;
|
|
524
|
-
}
|
|
525
|
-
readPayload(rawEventBody, hexSignature) {
|
|
526
|
-
if (!crypto) {
|
|
527
|
-
throw new Error("Verifying webhook events requires crypto support");
|
|
528
|
-
}
|
|
529
|
-
const givenSignature = Buffer.from(hexSignature, "hex");
|
|
530
|
-
// Compute the the actual HMAC signature from the raw request body.
|
|
531
|
-
const hmac = crypto.createHmac("sha256", this.webhookToken);
|
|
532
|
-
hmac.update(rawEventBody);
|
|
533
|
-
const eventSignature = hmac.digest();
|
|
534
|
-
// Use timingSafeEqual to prevent against timing attacks.
|
|
535
|
-
if (!crypto.timingSafeEqual(givenSignature, eventSignature)) {
|
|
536
|
-
throw new OnfidoError("Invalid signature for webhook event");
|
|
537
|
-
}
|
|
538
|
-
const { payload } = JSON.parse(rawEventBody.toString());
|
|
539
|
-
return convertObjectToCamelCase(payload);
|
|
540
|
-
}
|
|
541
|
-
}
|
|
542
|
-
|
|
543
|
-
export { Autofill, Onfido, OnfidoApiError, OnfidoDownload, OnfidoError, Region, WebhookEventVerifier };
|
|
544
|
-
//# sourceMappingURL=index.es.js.map
|
package/dist/index.es.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.es.js","sources":["../src/errors/OnfidoError.ts","../src/errors/OnfidoApiError.ts","../src/formatting.ts","../src/OnfidoDownload.ts","../src/Resource.ts","../src/resources/Addresses.ts","../src/resources/Applicants.ts","../src/resources/Autofill.ts","../src/resources/Checks.ts","../src/resources/Documents.ts","../src/resources/LivePhotos.ts","../src/resources/LiveVideos.ts","../src/resources/MotionCaptures.ts","../src/resources/Reports.ts","../src/resources/SdkTokens.ts","../src/resources/Webhooks.ts","../src/resources/WorkflowRuns.ts","../src/Onfido.ts","../src/WebhookEventVerifier.ts"],"sourcesContent":["export class OnfidoError extends Error {\n constructor(message?: string) {\n super(message);\n this.name = \"OnfidoError\";\n }\n}\n","import { OnfidoError } from \"./OnfidoError\";\n\nexport class OnfidoApiError extends OnfidoError {\n public readonly responseBody: unknown;\n public readonly statusCode: number;\n public readonly type: string;\n public readonly fields: unknown;\n\n private constructor(\n message: string,\n responseBody: unknown,\n statusCode: number,\n type: string,\n fields: unknown\n ) {\n super(message);\n this.name = \"OnfidoApiError\";\n\n this.responseBody = responseBody;\n this.statusCode = statusCode;\n this.type = type;\n this.fields = fields;\n }\n\n public static fromResponse(\n responseBody: unknown,\n statusCode: number\n ): OnfidoApiError {\n const innerErrorData: unknown =\n responseBody instanceof Object ? (responseBody as any).error : {};\n\n const innerError: {\n type?: unknown;\n message?: unknown;\n fields?: unknown;\n } = innerErrorData instanceof Object ? innerErrorData : {};\n\n const type = `${innerError.type || \"unknown\"}`;\n const message = `${innerError.message || responseBody}`;\n const fields = innerError.fields;\n\n const fullMessage =\n `${message} (status code ${statusCode})` +\n (fields ? ` | ${JSON.stringify(fields)}` : \"\");\n\n return new OnfidoApiError(\n fullMessage,\n responseBody,\n statusCode,\n type,\n fields\n );\n }\n\n public isClientError(): boolean {\n return this.statusCode < 500;\n }\n}\n","import { Readable } from \"stream\";\nimport { IFormData } from \"./types/formData\";\n\n// Using require because \"form-data\" exports this object as a default export which breaks integration when esModuleInterop: false\n// tslint:disable-next-line: no-var-requires\nconst FormData = require(\"form-data\");\n\nexport type SimpleObject = { [key: string]: unknown };\n\ntype ContentsAndOptions = {\n contents: Readable;\n filepath: string;\n contentType?: string;\n};\n\nexport type FileLike = Readable | ContentsAndOptions;\n\nconst snakeCase = (camelCaseString: string): string =>\n camelCaseString.replace(/[A-Z]/g, char => `_${char.toLowerCase()}`);\n\nconst formatValue = (value: any): string => {\n if (typeof value === 'boolean') {\n return String(value);\n } else {\n return value;\n }\n};\n\nconst camelCase = (snakeCaseString: string): string =>\n snakeCaseString\n .replace(/_[0-9]/g, underscoreDigit => underscoreDigit[1])\n .replace(/_[a-z]/g, underscoreChar => underscoreChar[1].toUpperCase());\n\nconst deepMapObjectKeys = (value: unknown, f: (key: string) => string): any => {\n if (!(value instanceof Object)) {\n return value;\n } else if (Array.isArray(value)) {\n return value.map(item => deepMapObjectKeys(item, f));\n } else {\n return Object.keys(value).reduce<SimpleObject>((acc, key) => {\n acc[f(key)] = deepMapObjectKeys((value as SimpleObject)[key], f);\n return acc;\n }, {});\n }\n};\n\nexport const convertObjectToSnakeCase = (requestBody: unknown): unknown => {\n // Converting to JSON and back first handles things like dates, circular references etc.\n requestBody = JSON.parse(JSON.stringify(requestBody));\n\n return deepMapObjectKeys(requestBody, snakeCase);\n};\n\nexport const convertObjectToCamelCase = (\n responseBody: SimpleObject\n): SimpleObject => deepMapObjectKeys(responseBody, camelCase);\n\nexport const toFormData = (object: SimpleObject): IFormData => {\n return Object.entries(object).reduce((formData, [key, value]) => {\n if (value instanceof Object && \"contents\" in value) {\n const { contents, ...options } = value as ContentsAndOptions;\n formData.append(snakeCase(key), contents, options);\n } else if (value !== undefined && value !== null) {\n if (value instanceof Object) {\n for (const [elementKey, elementValue] of Object.entries(value)) {\n formData.append(snakeCase(key + \"[\" + elementKey + \"]\"), elementValue);\n }\n } else {\n formData.append(snakeCase(key), formatValue(value));\n }\n }\n return formData;\n }, new FormData());\n};\n","import { IncomingMessage } from \"http\";\nimport { PassThrough, Readable } from \"stream\";\n\nexport class OnfidoDownload {\n private readonly incomingMessage: IncomingMessage;\n\n constructor(incomingMessage: IncomingMessage) {\n this.incomingMessage = incomingMessage;\n }\n\n public asStream(): Readable {\n // Use a PassThrough stream so the IncomingMessage isn't exposed.\n const passThroughStream = new PassThrough();\n this.incomingMessage.pipe(passThroughStream);\n return passThroughStream;\n }\n\n public get contentType(): string {\n return this.incomingMessage.headers[\"content-type\"]!;\n }\n}\n","import { AxiosInstance, AxiosPromise, AxiosResponse } from \"axios\";\nimport { IncomingMessage } from \"http\";\nimport { Readable } from \"stream\";\nimport { OnfidoApiError } from \"./errors/OnfidoApiError\";\nimport { OnfidoError } from \"./errors/OnfidoError\";\nimport {\n convertObjectToCamelCase,\n convertObjectToSnakeCase,\n SimpleObject,\n toFormData\n} from \"./formatting\";\nimport { OnfidoDownload } from \"./OnfidoDownload\";\n\nexport enum Method {\n GET = \"get\",\n POST = \"post\",\n PUT = \"put\",\n DELETE = \"delete\"\n}\n\nconst isJson = (response: AxiosResponse<unknown>): boolean =>\n (response.headers[\"content-type\"] || \"\").includes(\"application/json\");\n\nconst readFullStream = (stream: Readable): Promise<unknown> =>\n new Promise((resolve): void => {\n let all = \"\";\n\n stream.on(\"data\", data => (all += data));\n stream.on(\"error\", () => resolve(\"An error occurred reading the response\"));\n stream.on(\"end\", () => {\n // Try to parse as JSON, but fall back to just returning the raw text.\n try {\n resolve(JSON.parse(all));\n } catch {\n resolve(all);\n }\n });\n });\n\nconst convertAxiosErrorToOnfidoError = async (\n error: any\n): Promise<OnfidoError> => {\n if (!error.response) {\n return new OnfidoError(\n error.message || \"An unknown error occurred making the request\"\n );\n }\n\n // Received a 4XX or 5XX response.\n const response: AxiosResponse = error.response;\n const data = response.data;\n\n // If we were downloading a file, we will have a stream instead of a string.\n const body = data instanceof Readable ? await readFullStream(data) : data;\n\n return OnfidoApiError.fromResponse(body, response.status);\n};\n\nconst handleResponse = async (request: AxiosPromise<any>): Promise<any> => {\n try {\n const response = await request;\n const data = response.data;\n return isJson(response) ? convertObjectToCamelCase(data) : data;\n } catch (error) {\n throw await convertAxiosErrorToOnfidoError(error);\n }\n};\n\nexport class Resource<T extends SimpleObject> {\n private readonly name: string;\n private readonly axiosInstance: AxiosInstance;\n\n protected constructor(name: string, axiosInstance: AxiosInstance) {\n this.name = name;\n this.axiosInstance = axiosInstance;\n }\n\n protected async request({\n method,\n path = \"\",\n body,\n query\n }: {\n method: Method;\n path?: string;\n body?: T;\n query?: SimpleObject;\n }): Promise<any> {\n const url = path === null ? `${this.name}` : `${this.name}/${path}`;\n const request = this.axiosInstance({\n method,\n url: url,\n data: body && convertObjectToSnakeCase(body),\n params: query && convertObjectToSnakeCase(query)\n });\n\n return handleResponse(request);\n }\n\n protected async upload(body: T): Promise<any> {\n const formData = toFormData(body);\n\n const request = this.axiosInstance({\n method: Method.POST,\n url: `${this.name}/`,\n data: formData,\n headers: formData.getHeaders()\n });\n\n return handleResponse(request);\n }\n\n protected async download(path: string): Promise<OnfidoDownload> {\n const request = this.axiosInstance({\n method: Method.GET,\n url: `${this.name}/${path}`,\n responseType: \"stream\",\n // Accept a response with any content type (e.g. image/png, application/pdf, video/mp4)\n headers: { Accept: \"*/*\" }\n });\n\n const stream: IncomingMessage = await handleResponse(request);\n return new OnfidoDownload(stream);\n }\n}\n","import { AxiosInstance } from \"axios\";\nimport { Method, Resource } from \"../Resource\";\n\ntype AddressOptional = {\n flatNumber: string | null;\n buildingNumber: string | null;\n buildingName: string | null;\n street: string | null;\n subStreet: string | null;\n town: string | null;\n state: string | null;\n line1: string | null;\n line2: string | null;\n line3: string | null;\n};\n\nexport type AddressRequest = {\n postcode: string;\n country: string;\n} & Partial<AddressOptional>;\n\nexport type Address = {\n postcode: string;\n country: string;\n} & Partial<AddressOptional>;\n\nexport class Addresses extends Resource<never> {\n constructor(axiosInstance: AxiosInstance) {\n super(\"addresses\", axiosInstance);\n }\n\n public async pick(postcode: string): Promise<Address[]> {\n const { addresses } = await this.request({\n method: Method.GET,\n path: \"pick\",\n query: { postcode }\n });\n\n return addresses;\n }\n}\n","import { AxiosInstance } from \"axios\";\nimport { Method, Resource } from \"../Resource\";\nimport { Address, AddressRequest } from \"./Addresses\";\nimport { IdNumber, IdNumberRequest } from \"./IdNumbers\";\nimport { Location, LocationRequest } from \"./Location\";\nimport { ConsentsRequest } from \"./ConsentsRequest\";\n\n// firstName and lastName are also optional, to allow updating.\nexport type ApplicantRequest = {\n firstName?: string | null;\n lastName?: string | null;\n email?: string | null;\n dob?: string | null;\n address?: AddressRequest | null;\n idNumbers?: IdNumberRequest[] | null;\n phoneNumber?: string | null;\n location?: LocationRequest | null;\n consents?: ConsentsRequest[] | null;\n};\n\nexport type Applicant = {\n id: string;\n createdAt: string;\n deleteAt: string | null;\n href: string;\n firstName: string;\n lastName: string;\n email: string | null;\n dob: string | null;\n address: Address | null;\n idNumbers: IdNumber[] | null;\n phoneNumber: string | null;\n location: Location | null;\n};\n\nexport class Applicants extends Resource<ApplicantRequest> {\n constructor(axiosInstance: AxiosInstance) {\n super(\"applicants\", axiosInstance);\n }\n\n public async create(applicantRequest: ApplicantRequest): Promise<Applicant> {\n return this.request({ method: Method.POST, body: applicantRequest });\n }\n\n public async find(id: string): Promise<Applicant> {\n return this.request({ method: Method.GET, path: id });\n }\n\n public async update(\n id: string,\n applicantRequest: ApplicantRequest\n ): Promise<Applicant> {\n return this.request({\n method: Method.PUT,\n path: id,\n body: applicantRequest\n });\n }\n\n public async delete(id: string): Promise<void> {\n await this.request({ method: Method.DELETE, path: id });\n }\n\n public async restore(id: string): Promise<void> {\n await this.request({ method: Method.POST, path: `${id}/restore` });\n }\n\n public async list({\n page,\n perPage,\n includeDeleted\n }: {\n page?: number;\n perPage?: number;\n includeDeleted?: boolean;\n } = {}): Promise<Applicant[]> {\n const { applicants } = await this.request({\n method: Method.GET,\n query: { page, perPage, includeDeleted }\n });\n\n return applicants;\n }\n}\n","import { AxiosInstance } from \"axios\";\nimport { Method, Resource } from \"../Resource\";\n\nexport type ExtractionResult = {\n documentId: string;\n documentClassification: {\n issuingCountry: string;\n documentType: string;\n issuingState?: string;\n };\n extractedData: {\n documentNumber?: string;\n firstName?: string;\n lastName?: string;\n middleName?: string;\n fullName?: string;\n gender?: string;\n dateOfBirth?: string;\n dateOfExpiry?: string;\n nationality?: string;\n mrzLine1?: string;\n mrzLine2?: string;\n mrzLine3?: string;\n addressLine1?: string;\n addressLine2?: string;\n addressLine3?: string;\n addressLine4?: string;\n addressLine5?: string;\n };\n};\n\ntype AutofillResource = {\n documentId: string;\n};\n\nexport class Autofill extends Resource<AutofillResource> {\n constructor(axiosInstance: AxiosInstance) {\n super(\"extractions\", axiosInstance);\n }\n\n public async perform(documentId: string): Promise<ExtractionResult> {\n return this.request({\n method: Method.POST,\n body: { documentId }\n });\n }\n}\n","import { AxiosInstance } from \"axios\";\nimport { OnfidoDownload } from \"../OnfidoDownload\";\nimport { Method, Resource } from \"../Resource\";\n\nexport type CheckRequest = {\n applicantId: string;\n reportNames: string[];\n documentIds?: string[] | null;\n applicantProvidesData?: boolean;\n asynchronous?: boolean;\n tags?: string[] | null;\n suppressFormEmails?: boolean;\n redirectUri?: string | null;\n privacyNoticesReadConsentGiven?: boolean;\n webhookIds?: string[] | null;\n subResult?: string;\n consider?: string[];\n};\n\nexport type Check = {\n id: string;\n reportIds: string[];\n createdAt: string;\n href: string;\n applicantId: string;\n applicantProvidesData: boolean;\n sandbox: boolean;\n status: string;\n tags: string[];\n result: string | null;\n formUri: string | null;\n redirectUri: string | null;\n resultsUri: string;\n privacyNoticesReadConsentGiven: boolean;\n webhookIds: string[] | null;\n};\n\nexport class Checks extends Resource<CheckRequest> {\n constructor(axiosInstance: AxiosInstance) {\n super(\"checks\", axiosInstance);\n }\n\n public async create(checkRequest: CheckRequest): Promise<Check> {\n return this.request({ method: Method.POST, body: checkRequest });\n }\n\n public async find(id: string): Promise<Check> {\n return this.request({ method: Method.GET, path: id });\n }\n\n public async list(applicantId: string): Promise<Check[]> {\n const { checks } = await this.request({\n method: Method.GET,\n query: { applicantId }\n });\n\n return checks;\n }\n\n public async resume(id: string): Promise<void> {\n await this.request({ method: Method.POST, path: `${id}/resume` });\n }\n\n public async download(id: string): Promise<OnfidoDownload> {\n return super.download(`${id}/download`);\n }\n}\n","import { AxiosInstance } from \"axios\";\nimport { FileLike } from \"../formatting\";\nimport { OnfidoDownload } from \"../OnfidoDownload\";\nimport { Method, Resource } from \"../Resource\";\nimport { LocationRequest } from \"./Location\";\n\nexport type DocumentRequest = {\n applicantId?: string | null;\n file: FileLike;\n type: string;\n side?: string | null;\n issuingCountry?: string | null;\n validateImageQuality?: boolean | null | string;\n location?: LocationRequest | null;\n};\n\nexport type Document = {\n id: string;\n applicantId: string | null;\n createdAt: string;\n href: string;\n downloadHref: string;\n fileName: string;\n fileType: string;\n fileSize: number;\n type: string;\n side: string | null;\n issuingCountry: string | null;\n};\n\nexport class Documents extends Resource<DocumentRequest> {\n constructor(axiosInstance: AxiosInstance) {\n super(\"documents\", axiosInstance);\n }\n\n public async upload(documentRequest: DocumentRequest): Promise<Document> {\n return super.upload(documentRequest);\n }\n\n public async download(id: string): Promise<OnfidoDownload> {\n return super.download(`${id}/download`);\n }\n\n public async find(id: string): Promise<Document> {\n return this.request({ method: Method.GET, path: id });\n }\n\n public async list(applicantId: string): Promise<Document[]> {\n const { documents } = await this.request({\n method: Method.GET,\n query: { applicantId }\n });\n\n return documents;\n }\n}\n","import { AxiosInstance } from \"axios\";\nimport { FileLike } from \"../formatting\";\nimport { OnfidoDownload } from \"../OnfidoDownload\";\nimport { Method, Resource } from \"../Resource\";\n\nexport type LivePhotoRequest = {\n applicantId: string;\n file: FileLike;\n advancedValidation?: string;\n};\n\nexport type LivePhoto = {\n id: string;\n createdAt: string;\n href: string;\n downloadHref: string;\n fileName: string;\n fileType: string;\n fileSize: number;\n};\n\nexport class LivePhotos extends Resource<LivePhotoRequest> {\n constructor(axiosInstance: AxiosInstance) {\n super(\"live_photos\", axiosInstance);\n }\n\n public async upload(livePhotoRequest: LivePhotoRequest): Promise<LivePhoto> {\n return super.upload(livePhotoRequest);\n }\n\n public async download(id: string): Promise<OnfidoDownload> {\n return super.download(`${id}/download`);\n }\n\n public async find(id: string): Promise<LivePhoto> {\n return this.request({ method: Method.GET, path: id });\n }\n\n public async list(applicantId: string): Promise<LivePhoto[]> {\n const { livePhotos } = await this.request({\n method: Method.GET,\n query: { applicantId }\n });\n\n return livePhotos;\n }\n}\n","import { AxiosInstance } from \"axios\";\nimport { OnfidoDownload } from \"../OnfidoDownload\";\nimport { Method, Resource } from \"../Resource\";\n\nexport type LiveVideo = {\n id: string;\n createdAt: string;\n href: string;\n downloadHref: string;\n fileName: string;\n fileType: string;\n fileSize: number;\n};\n\nexport class LiveVideos extends Resource<never> {\n constructor(axiosInstance: AxiosInstance) {\n super(\"live_videos\", axiosInstance);\n }\n\n public async download(id: string): Promise<OnfidoDownload> {\n return super.download(`${id}/download`);\n }\n\n public async frame(id: string): Promise<OnfidoDownload> {\n return super.download(`${id}/frame`);\n }\n\n public async find(id: string): Promise<LiveVideo> {\n return this.request({ method: Method.GET, path: id });\n }\n\n public async list(applicantId: string): Promise<LiveVideo[]> {\n const { liveVideos } = await this.request({\n method: Method.GET,\n query: { applicantId }\n });\n\n return liveVideos;\n }\n}\n","import { AxiosInstance } from \"axios\";\nimport { OnfidoDownload } from \"../OnfidoDownload\";\nimport { Method, Resource } from \"../Resource\";\n\nexport type MotionCapture = {\n id: string;\n createdAt: string;\n href: string;\n downloadHref: string;\n fileName: string;\n fileType: string;\n fileSize: number;\n};\n\nexport class MotionCaptures extends Resource<never> {\n constructor(axiosInstance: AxiosInstance) {\n super(\"motion_captures\", axiosInstance);\n }\n\n public async download(id: string): Promise<OnfidoDownload> {\n return super.download(`${id}/download`);\n }\n\n public async frame(id: string): Promise<OnfidoDownload> {\n return super.download(`${id}/frame`);\n }\n\n public async find(id: string): Promise<MotionCapture> {\n return this.request({ method: Method.GET, path: id });\n }\n\n public async list(applicantId: string): Promise<MotionCapture[]> {\n const { motionCaptures } = await this.request({\n method: Method.GET,\n query: { applicantId }\n });\n\n return motionCaptures;\n }\n}\n","import { AxiosInstance } from \"axios\";\nimport { Method, Resource } from \"../Resource\";\n\nexport type Report = {\n id: string;\n createdAt: string;\n name: string;\n href: string;\n status: string;\n result: string | null;\n subResult: string | null;\n properties: object | null;\n breakdown: object | null;\n documents: Array<{ id: string }>;\n checkId: string;\n};\n\nexport class Reports extends Resource<never> {\n constructor(axiosInstance: AxiosInstance) {\n super(\"reports\", axiosInstance);\n }\n\n public async find(id: string): Promise<Report> {\n return this.request({ method: Method.GET, path: id });\n }\n\n public async list(checkId: string): Promise<Report[]> {\n const { reports } = await this.request({\n method: Method.GET,\n query: { checkId }\n });\n\n return reports;\n }\n\n public async resume(id: string): Promise<void> {\n await this.request({ method: Method.POST, path: `${id}/resume` });\n }\n\n public async cancel(id: string): Promise<void> {\n await this.request({ method: Method.POST, path: `${id}/cancel` });\n }\n}\n","import { AxiosInstance } from \"axios\";\nimport { Method, Resource } from \"../Resource\";\n\nexport type SdkTokenRequest = {\n applicantId: string;\n applicationId?: string | null;\n referrer?: string | null;\n crossDeviceUrl?: string | null;\n};\n\nexport class SdkTokens extends Resource<SdkTokenRequest> {\n constructor(axiosInstance: AxiosInstance) {\n super(\"sdk_token\", axiosInstance);\n }\n\n public async generate(sdkTokenRequest: SdkTokenRequest): Promise<string> {\n const { token } = await this.request({\n method: Method.POST,\n body: sdkTokenRequest\n });\n\n return token;\n }\n}\n","import { AxiosInstance } from \"axios\";\nimport { Method, Resource } from \"../Resource\";\n\n// url is also optional to allow updating.\nexport type WebhookRequest = {\n url?: string | null;\n enabled?: boolean;\n environments?: string[];\n events?: string[] | null;\n};\n\nexport type Webhook = {\n id: string;\n url: string;\n enabled: boolean;\n events: string[];\n token: string;\n href: string;\n environments: string[];\n payloadVersion: number;\n};\n\nexport class Webhooks extends Resource<WebhookRequest> {\n constructor(axiosInstance: AxiosInstance) {\n super(\"webhooks\", axiosInstance);\n }\n\n public async create(webhookRequest: WebhookRequest): Promise<Webhook> {\n return this.request({ method: Method.POST, body: webhookRequest });\n }\n\n public async find(id: string): Promise<Webhook> {\n return this.request({ method: Method.GET, path: id });\n }\n\n public async update(\n id: string,\n webhookRequest: WebhookRequest\n ): Promise<Webhook> {\n return this.request({\n method: Method.PUT,\n path: id,\n body: webhookRequest\n });\n }\n\n public async delete(id: string): Promise<void> {\n await this.request({ method: Method.DELETE, path: id });\n }\n\n public async list(): Promise<Webhook[]> {\n const { webhooks } = await this.request({ method: Method.GET });\n\n return webhooks;\n }\n}\n","import { AxiosInstance } from \"axios\";\nimport { OnfidoDownload } from \"../OnfidoDownload\";\nimport { Method, Resource } from \"../Resource\";\n\nexport type WorkflowRunRequest = {\n applicantId: string;\n workflowId: string;\n customData?: any;\n};\n\ntype WorkflowRunError = {\n type: string;\n message: string;\n}\n\ntype WorkflowRunLink = {\n url: string;\n completed_redirect_url: string;\n expired_redirect_url: string;\n expires_at: string;\n language: string;\n}\n\nexport type WorkflowRun = {\n id: string;\n applicantId: string;\n workflowId: string;\n workflowVersionId: number;\n dashboardUrl: string;\n status: string;\n output: any;\n reasons: string[] | null;\n error: WorkflowRunError | null;\n link: WorkflowRunLink | null;\n createdAt: string;\n updatedAt: string;\n tags: string[] | null;\n};\n\nexport type WorkflowRunListRequest = {\n page?: number;\n status?: string;\n created_at_gt?: string;\n created_at_lt?: string;\n}\n\nexport class WorkflowRuns extends Resource<WorkflowRunRequest> {\n constructor(axiosInstance: AxiosInstance) {\n super(\"workflow_runs\", axiosInstance);\n }\n\n public async create(workflowRunRequest: WorkflowRunRequest): Promise<WorkflowRun> {\n return this.request({ method: Method.POST, body: workflowRunRequest });\n }\n\n public async find(id: string): Promise<WorkflowRun> {\n return this.request({ method: Method.GET, path: id });\n }\n\n public async list(queryParams?: WorkflowRunListRequest): Promise<WorkflowRun[]> {\n const workflowRuns = await this.request({\n method: Method.GET,\n query: queryParams\n });\n\n return workflowRuns;\n }\n\n public async evidence(id: string): Promise<OnfidoDownload> {\n return super.download(`${id}/signed_evidence_file`);\n }\n}\n","import axios, { AxiosInstance } from \"axios\";\nimport { version } from \"../package.json\";\nimport { Addresses } from \"./resources/Addresses\";\nimport { Applicants } from \"./resources/Applicants\";\nimport { Autofill } from \"./resources/Autofill\";\nimport { Checks } from \"./resources/Checks\";\nimport { Documents } from \"./resources/Documents\";\nimport { LivePhotos } from \"./resources/LivePhotos\";\nimport { LiveVideos } from \"./resources/LiveVideos\";\nimport { MotionCaptures } from \"./resources/MotionCaptures\";\nimport { Reports } from \"./resources/Reports\";\nimport { SdkTokens } from \"./resources/SdkTokens\";\nimport { Webhooks } from \"./resources/Webhooks\";\nimport { WorkflowRuns } from \"./resources/WorkflowRuns\";\n\nexport enum Region {\n EU = \"EU\",\n US = \"US\",\n CA = \"CA\"\n}\n\nexport type OnfidoOptions = {\n apiToken: string;\n region: Region;\n timeout?: number;\n unknownApiUrl?: string;\n};\n\nexport class Onfido {\n public readonly axiosInstance: AxiosInstance;\n // Core resources\n public readonly applicant: Applicants;\n public readonly document: Documents;\n public readonly livePhoto: LivePhotos;\n public readonly liveVideo: LiveVideos;\n public readonly motionCapture: MotionCaptures;\n public readonly check: Checks;\n public readonly report: Reports;\n public readonly workflowRun: WorkflowRuns;\n // Other endpoints\n public readonly address: Addresses;\n public readonly webhook: Webhooks;\n public readonly sdkToken: SdkTokens;\n public readonly autofill: Autofill;\n\n constructor({\n apiToken,\n region,\n timeout = 30_000,\n unknownApiUrl\n }: OnfidoOptions) {\n if (!apiToken) {\n throw new Error(\"No apiToken provided\");\n }\n if (!region || !Object.values(Region).includes(region)) {\n throw new Error(\n `Unknown or missing region '${region}'. ` +\n \"We previously defaulted to region 'EU', so if you previously didn’t \" +\n \"set a region or used api.onfido.com, please set your region to 'EU'\"\n );\n }\n\n const regionUrl = `https://api.${region.toLowerCase()}.onfido.com/v3.6/`;\n\n this.axiosInstance = axios.create({\n baseURL: unknownApiUrl || regionUrl,\n headers: {\n Authorization: `Token token=${apiToken}`,\n Accept: \"application/json\",\n \"User-Agent\": `onfido-node/${version}`\n },\n timeout\n });\n\n // Core resources\n this.applicant = new Applicants(this.axiosInstance);\n this.document = new Documents(this.axiosInstance);\n this.livePhoto = new LivePhotos(this.axiosInstance);\n this.liveVideo = new LiveVideos(this.axiosInstance);\n this.motionCapture = new MotionCaptures(this.axiosInstance);\n this.check = new Checks(this.axiosInstance);\n this.report = new Reports(this.axiosInstance);\n this.workflowRun = new WorkflowRuns(this.axiosInstance);\n // Other endpoints\n this.address = new Addresses(this.axiosInstance);\n this.webhook = new Webhooks(this.axiosInstance);\n this.sdkToken = new SdkTokens(this.axiosInstance);\n this.autofill = new Autofill(this.axiosInstance);\n }\n}\n","import { OnfidoError } from \"./errors/OnfidoError\";\nimport { convertObjectToCamelCase } from \"./formatting\";\n\n// Require crypto instead of importing, because Node can be built without crypto support.\nlet crypto: typeof import(\"crypto\") | undefined;\ntry {\n // tslint:disable-next-line: no-var-requires\n crypto = require(\"crypto\");\n} catch {\n // We throw an error when verifying webhooks instead.\n}\n\nexport type WebhookEvent = {\n resourceType: string;\n action: string;\n object: {\n id: string;\n status: string;\n href: string;\n completedAtIso8601: string;\n };\n resource?: object;\n};\n\nexport class WebhookEventVerifier {\n private readonly webhookToken: string;\n\n constructor(webhookToken: string) {\n this.webhookToken = webhookToken;\n }\n\n public readPayload(\n rawEventBody: string | Buffer,\n hexSignature: string\n ): WebhookEvent {\n if (!crypto) {\n throw new Error(\"Verifying webhook events requires crypto support\");\n }\n\n const givenSignature = Buffer.from(hexSignature, \"hex\");\n\n // Compute the the actual HMAC signature from the raw request body.\n const hmac = crypto.createHmac(\"sha256\", this.webhookToken);\n hmac.update(rawEventBody);\n const eventSignature = hmac.digest();\n\n // Use timingSafeEqual to prevent against timing attacks.\n if (!crypto.timingSafeEqual(givenSignature, eventSignature)) {\n throw new OnfidoError(\"Invalid signature for webhook event\");\n }\n\n const { payload } = JSON.parse(rawEventBody.toString());\n return convertObjectToCamelCase(payload) as WebhookEvent;\n }\n}\n"],"names":[],"mappings":";;;;;MAAa,WAAY,SAAQ,KAAK;IACpC,YAAY,OAAgB;QAC1B,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,aAAa,CAAC;KAC3B;CACF;;MCHY,cAAe,SAAQ,WAAW;IAM7C,YACE,OAAe,EACf,YAAqB,EACrB,UAAkB,EAClB,IAAY,EACZ,MAAe;QAEf,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,gBAAgB,CAAC;QAE7B,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;QACjC,IA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