@onfido/api 2.9.0 → 3.0.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 +115 -132
- package/dist/api.d.ts +11690 -0
- package/dist/api.js +5113 -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 +201 -0
- package/dist/configuration.d.ts +93 -0
- package/dist/configuration.js +53 -0
- package/dist/esm/api.d.ts +11690 -0
- package/dist/esm/api.js +5106 -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 +189 -0
- package/dist/esm/configuration.d.ts +93 -0
- package/dist/esm/configuration.js +49 -0
- package/dist/esm/index.d.ts +14 -0
- package/dist/esm/index.js +16 -0
- package/dist/esm/webhook-event-verifier.d.ts +9 -0
- package/dist/esm/webhook-event-verifier.js +31 -0
- package/dist/index.d.ts +14 -19
- package/dist/index.js +31 -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
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Onfido API v3.6
|
|
3
|
+
* The Onfido API (v3.6)
|
|
4
|
+
*
|
|
5
|
+
* The version of the OpenAPI document: v3.6
|
|
6
|
+
*
|
|
7
|
+
*
|
|
8
|
+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
|
9
|
+
* https://openapi-generator.tech
|
|
10
|
+
* Do not edit the class manually.
|
|
11
|
+
*/
|
|
12
|
+
import type { Configuration } from './configuration';
|
|
13
|
+
import type { AxiosInstance, RawAxiosRequestConfig } from 'axios';
|
|
14
|
+
export declare const BASE_PATH: string;
|
|
15
|
+
/**
|
|
16
|
+
*
|
|
17
|
+
* @export
|
|
18
|
+
*/
|
|
19
|
+
export declare const COLLECTION_FORMATS: {
|
|
20
|
+
csv: string;
|
|
21
|
+
ssv: string;
|
|
22
|
+
tsv: string;
|
|
23
|
+
pipes: string;
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
*
|
|
27
|
+
* @export
|
|
28
|
+
* @interface RequestArgs
|
|
29
|
+
*/
|
|
30
|
+
export interface RequestArgs {
|
|
31
|
+
url: string;
|
|
32
|
+
options: RawAxiosRequestConfig;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
*
|
|
36
|
+
* @export
|
|
37
|
+
* @class BaseAPI
|
|
38
|
+
*/
|
|
39
|
+
export declare class BaseAPI {
|
|
40
|
+
protected basePath: string;
|
|
41
|
+
protected axios: AxiosInstance;
|
|
42
|
+
protected configuration: Configuration | undefined;
|
|
43
|
+
constructor(configuration?: Configuration, basePath?: string, axios?: AxiosInstance);
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
*
|
|
47
|
+
* @export
|
|
48
|
+
* @class RequiredError
|
|
49
|
+
* @extends {Error}
|
|
50
|
+
*/
|
|
51
|
+
export declare class RequiredError extends Error {
|
|
52
|
+
field: string;
|
|
53
|
+
constructor(field: string, msg?: string);
|
|
54
|
+
}
|
|
55
|
+
interface ServerMap {
|
|
56
|
+
[key: string]: {
|
|
57
|
+
url: string;
|
|
58
|
+
description: string;
|
|
59
|
+
}[];
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
*
|
|
63
|
+
* @export
|
|
64
|
+
*/
|
|
65
|
+
export declare const operationServerMap: ServerMap;
|
|
66
|
+
export {};
|
package/dist/esm/base.js
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
/**
|
|
4
|
+
* Onfido API v3.6
|
|
5
|
+
* The Onfido API (v3.6)
|
|
6
|
+
*
|
|
7
|
+
* The version of the OpenAPI document: v3.6
|
|
8
|
+
*
|
|
9
|
+
*
|
|
10
|
+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
|
11
|
+
* https://openapi-generator.tech
|
|
12
|
+
* Do not edit the class manually.
|
|
13
|
+
*/
|
|
14
|
+
import globalAxios from 'axios';
|
|
15
|
+
export const BASE_PATH = "https://api.eu.onfido.com/v3.6".replace(/\/+$/, "");
|
|
16
|
+
/**
|
|
17
|
+
*
|
|
18
|
+
* @export
|
|
19
|
+
*/
|
|
20
|
+
export const COLLECTION_FORMATS = {
|
|
21
|
+
csv: ",",
|
|
22
|
+
ssv: " ",
|
|
23
|
+
tsv: "\t",
|
|
24
|
+
pipes: "|",
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
*
|
|
28
|
+
* @export
|
|
29
|
+
* @class BaseAPI
|
|
30
|
+
*/
|
|
31
|
+
export class BaseAPI {
|
|
32
|
+
constructor(configuration, basePath = BASE_PATH, axios = globalAxios) {
|
|
33
|
+
var _a;
|
|
34
|
+
this.basePath = basePath;
|
|
35
|
+
this.axios = axios;
|
|
36
|
+
if (configuration) {
|
|
37
|
+
this.configuration = configuration;
|
|
38
|
+
this.basePath = (_a = configuration.basePath) !== null && _a !== void 0 ? _a : basePath;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
;
|
|
43
|
+
/**
|
|
44
|
+
*
|
|
45
|
+
* @export
|
|
46
|
+
* @class RequiredError
|
|
47
|
+
* @extends {Error}
|
|
48
|
+
*/
|
|
49
|
+
export class RequiredError extends Error {
|
|
50
|
+
constructor(field, msg) {
|
|
51
|
+
super(msg);
|
|
52
|
+
this.field = field;
|
|
53
|
+
this.name = "RequiredError";
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
*
|
|
58
|
+
* @export
|
|
59
|
+
*/
|
|
60
|
+
export const operationServerMap = {};
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Onfido API v3.6
|
|
3
|
+
* The Onfido API (v3.6)
|
|
4
|
+
*
|
|
5
|
+
* The version of the OpenAPI document: v3.6
|
|
6
|
+
*
|
|
7
|
+
*
|
|
8
|
+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
|
9
|
+
* https://openapi-generator.tech
|
|
10
|
+
* Do not edit the class manually.
|
|
11
|
+
*/
|
|
12
|
+
import type { Configuration } from "./configuration";
|
|
13
|
+
import type { RequestArgs } from "./base";
|
|
14
|
+
import type { AxiosInstance, AxiosResponse } from 'axios';
|
|
15
|
+
import { URL } from 'url';
|
|
16
|
+
/**
|
|
17
|
+
*
|
|
18
|
+
* @export
|
|
19
|
+
*/
|
|
20
|
+
export declare const DUMMY_BASE_URL = "https://example.com";
|
|
21
|
+
/**
|
|
22
|
+
*
|
|
23
|
+
* @throws {RequiredError}
|
|
24
|
+
* @export
|
|
25
|
+
*/
|
|
26
|
+
export declare const assertParamExists: (functionName: string, paramName: string, paramValue: unknown) => void;
|
|
27
|
+
/**
|
|
28
|
+
*
|
|
29
|
+
* @export
|
|
30
|
+
*/
|
|
31
|
+
export declare const setApiKeyToObject: (object: any, keyParamName: string, configuration?: Configuration) => Promise<void>;
|
|
32
|
+
/**
|
|
33
|
+
*
|
|
34
|
+
* @export
|
|
35
|
+
*/
|
|
36
|
+
export declare const setBasicAuthToObject: (object: any, configuration?: Configuration) => void;
|
|
37
|
+
/**
|
|
38
|
+
*
|
|
39
|
+
* @export
|
|
40
|
+
*/
|
|
41
|
+
export declare const setBearerAuthToObject: (object: any, configuration?: Configuration) => Promise<void>;
|
|
42
|
+
/**
|
|
43
|
+
*
|
|
44
|
+
* @export
|
|
45
|
+
*/
|
|
46
|
+
export declare const setOAuthToObject: (object: any, name: string, scopes: string[], configuration?: Configuration) => Promise<void>;
|
|
47
|
+
/**
|
|
48
|
+
*
|
|
49
|
+
* @export
|
|
50
|
+
*/
|
|
51
|
+
export declare const setSearchParams: (url: URL, ...objects: any[]) => void;
|
|
52
|
+
/**
|
|
53
|
+
*
|
|
54
|
+
* @export
|
|
55
|
+
*/
|
|
56
|
+
export declare const serializeDataIfNeeded: (value: any, requestOptions: any, configuration?: Configuration) => any;
|
|
57
|
+
/**
|
|
58
|
+
*
|
|
59
|
+
* @export
|
|
60
|
+
*/
|
|
61
|
+
export declare const toPathString: (url: URL) => string;
|
|
62
|
+
/**
|
|
63
|
+
*
|
|
64
|
+
* @export
|
|
65
|
+
*/
|
|
66
|
+
export declare const createRequestFunction: (axiosArgs: RequestArgs, globalAxios: AxiosInstance, BASE_PATH: string, configuration?: Configuration) => <T = unknown, R = AxiosResponse<T, any>>(axios?: AxiosInstance, basePath?: string) => Promise<R>;
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
/**
|
|
4
|
+
* Onfido API v3.6
|
|
5
|
+
* The Onfido API (v3.6)
|
|
6
|
+
*
|
|
7
|
+
* The version of the OpenAPI document: v3.6
|
|
8
|
+
*
|
|
9
|
+
*
|
|
10
|
+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
|
11
|
+
* https://openapi-generator.tech
|
|
12
|
+
* Do not edit the class manually.
|
|
13
|
+
*/
|
|
14
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
15
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
16
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
17
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
18
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
19
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
20
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
import { RequiredError } from "./base";
|
|
24
|
+
import { URLSearchParams } from 'url';
|
|
25
|
+
/**
|
|
26
|
+
*
|
|
27
|
+
* @export
|
|
28
|
+
*/
|
|
29
|
+
export const DUMMY_BASE_URL = 'https://example.com';
|
|
30
|
+
/**
|
|
31
|
+
*
|
|
32
|
+
* @throws {RequiredError}
|
|
33
|
+
* @export
|
|
34
|
+
*/
|
|
35
|
+
export const assertParamExists = function (functionName, paramName, paramValue) {
|
|
36
|
+
if (paramValue === null || paramValue === undefined) {
|
|
37
|
+
throw new RequiredError(paramName, `Required parameter ${paramName} was null or undefined when calling ${functionName}.`);
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
*
|
|
42
|
+
* @export
|
|
43
|
+
*/
|
|
44
|
+
export const setApiKeyToObject = function (object, keyParamName, configuration) {
|
|
45
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
46
|
+
if (configuration && configuration.apiKey) {
|
|
47
|
+
const localVarApiKeyValue = typeof configuration.apiKey === 'function'
|
|
48
|
+
? yield configuration.apiKey(keyParamName)
|
|
49
|
+
: yield configuration.apiKey;
|
|
50
|
+
object[keyParamName] = localVarApiKeyValue;
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
};
|
|
54
|
+
/**
|
|
55
|
+
*
|
|
56
|
+
* @export
|
|
57
|
+
*/
|
|
58
|
+
export const setBasicAuthToObject = function (object, configuration) {
|
|
59
|
+
if (configuration && (configuration.username || configuration.password)) {
|
|
60
|
+
object["auth"] = { username: configuration.username, password: configuration.password };
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
/**
|
|
64
|
+
*
|
|
65
|
+
* @export
|
|
66
|
+
*/
|
|
67
|
+
export const setBearerAuthToObject = function (object, configuration) {
|
|
68
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
69
|
+
if (configuration && configuration.accessToken) {
|
|
70
|
+
const accessToken = typeof configuration.accessToken === 'function'
|
|
71
|
+
? yield configuration.accessToken()
|
|
72
|
+
: yield configuration.accessToken;
|
|
73
|
+
object["Authorization"] = "Bearer " + accessToken;
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
};
|
|
77
|
+
/**
|
|
78
|
+
*
|
|
79
|
+
* @export
|
|
80
|
+
*/
|
|
81
|
+
export const setOAuthToObject = function (object, name, scopes, configuration) {
|
|
82
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
83
|
+
if (configuration && configuration.accessToken) {
|
|
84
|
+
const localVarAccessTokenValue = typeof configuration.accessToken === 'function'
|
|
85
|
+
? yield configuration.accessToken(name, scopes)
|
|
86
|
+
: yield configuration.accessToken;
|
|
87
|
+
object["Authorization"] = "Bearer " + localVarAccessTokenValue;
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
};
|
|
91
|
+
function setFlattenedQueryParams(urlSearchParams, parameter, key = "") {
|
|
92
|
+
if (parameter == null)
|
|
93
|
+
return;
|
|
94
|
+
if (typeof parameter === "object") {
|
|
95
|
+
if (Array.isArray(parameter)) {
|
|
96
|
+
parameter.forEach(item => setFlattenedQueryParams(urlSearchParams, item, key));
|
|
97
|
+
}
|
|
98
|
+
else {
|
|
99
|
+
Object.keys(parameter).forEach(currentKey => setFlattenedQueryParams(urlSearchParams, parameter[currentKey], `${key}${key !== '' ? '.' : ''}${currentKey}`));
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
else {
|
|
103
|
+
if (urlSearchParams.has(key)) {
|
|
104
|
+
urlSearchParams.append(key, parameter);
|
|
105
|
+
}
|
|
106
|
+
else {
|
|
107
|
+
urlSearchParams.set(key, parameter);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
*
|
|
113
|
+
* @export
|
|
114
|
+
*/
|
|
115
|
+
export const setSearchParams = function (url, ...objects) {
|
|
116
|
+
const searchParams = new URLSearchParams(url.search);
|
|
117
|
+
setFlattenedQueryParams(searchParams, objects);
|
|
118
|
+
url.search = searchParams.toString();
|
|
119
|
+
};
|
|
120
|
+
/**
|
|
121
|
+
*
|
|
122
|
+
* @export
|
|
123
|
+
*/
|
|
124
|
+
export const serializeDataIfNeeded = function (value, requestOptions, configuration) {
|
|
125
|
+
const nonString = typeof value !== 'string';
|
|
126
|
+
const needsSerialization = nonString && configuration && configuration.isJsonMime
|
|
127
|
+
? configuration.isJsonMime(requestOptions.headers['Content-Type'])
|
|
128
|
+
: nonString;
|
|
129
|
+
return needsSerialization
|
|
130
|
+
? JSON.stringify(value !== undefined ? convertMapsAndSetsToPlain(value) : {})
|
|
131
|
+
: (value || "");
|
|
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
|
+
/**
|
|
173
|
+
*
|
|
174
|
+
* @export
|
|
175
|
+
*/
|
|
176
|
+
export const toPathString = function (url) {
|
|
177
|
+
return url.pathname + url.search + url.hash;
|
|
178
|
+
};
|
|
179
|
+
/**
|
|
180
|
+
*
|
|
181
|
+
* @export
|
|
182
|
+
*/
|
|
183
|
+
export const createRequestFunction = function (axiosArgs, globalAxios, BASE_PATH, configuration) {
|
|
184
|
+
return (axios = globalAxios, basePath = BASE_PATH) => {
|
|
185
|
+
var _a;
|
|
186
|
+
const axiosRequestArgs = Object.assign(Object.assign({}, axiosArgs.options), { url: (axios.defaults.baseURL ? '' : (_a = configuration === null || configuration === void 0 ? void 0 : configuration.basePath) !== null && _a !== void 0 ? _a : basePath) + axiosArgs.url });
|
|
187
|
+
return axios.request(axiosRequestArgs);
|
|
188
|
+
};
|
|
189
|
+
};
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Onfido API v3.6
|
|
3
|
+
* The Onfido API (v3.6)
|
|
4
|
+
*
|
|
5
|
+
* The version of the OpenAPI document: v3.6
|
|
6
|
+
*
|
|
7
|
+
*
|
|
8
|
+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
|
9
|
+
* https://openapi-generator.tech
|
|
10
|
+
* Do not edit the class manually.
|
|
11
|
+
*/
|
|
12
|
+
export declare enum Region {
|
|
13
|
+
EU = 0,
|
|
14
|
+
US = 1,
|
|
15
|
+
CA = 2
|
|
16
|
+
}
|
|
17
|
+
export interface ConfigurationParameters {
|
|
18
|
+
apiToken?: string;
|
|
19
|
+
region?: Region;
|
|
20
|
+
basePath?: string;
|
|
21
|
+
baseOptions?: any;
|
|
22
|
+
formDataCtor?: new () => any;
|
|
23
|
+
}
|
|
24
|
+
export declare class Configuration {
|
|
25
|
+
/**
|
|
26
|
+
* parameter for apiKey security
|
|
27
|
+
* @param name security name
|
|
28
|
+
* @memberof Configuration
|
|
29
|
+
*/
|
|
30
|
+
apiKey?: string | Promise<string> | ((name: string) => string) | ((name: string) => Promise<string>);
|
|
31
|
+
/**
|
|
32
|
+
* parameter for basic security
|
|
33
|
+
*
|
|
34
|
+
* @type {string}
|
|
35
|
+
* @memberof Configuration
|
|
36
|
+
*/
|
|
37
|
+
username?: string;
|
|
38
|
+
/**
|
|
39
|
+
* parameter for basic security
|
|
40
|
+
*
|
|
41
|
+
* @type {string}
|
|
42
|
+
* @memberof Configuration
|
|
43
|
+
*/
|
|
44
|
+
password?: string;
|
|
45
|
+
/**
|
|
46
|
+
* parameter for oauth2 security
|
|
47
|
+
* @param name security name
|
|
48
|
+
* @param scopes oauth2 scope
|
|
49
|
+
* @memberof Configuration
|
|
50
|
+
*/
|
|
51
|
+
accessToken?: string | Promise<string> | ((name?: string, scopes?: string[]) => string) | ((name?: string, scopes?: string[]) => Promise<string>);
|
|
52
|
+
/**
|
|
53
|
+
* override base path
|
|
54
|
+
*
|
|
55
|
+
* @type {string}
|
|
56
|
+
* @memberof Configuration
|
|
57
|
+
*/
|
|
58
|
+
basePath?: string;
|
|
59
|
+
/**
|
|
60
|
+
* override server index
|
|
61
|
+
*
|
|
62
|
+
* @type {number}
|
|
63
|
+
* @memberof Configuration
|
|
64
|
+
*/
|
|
65
|
+
serverIndex?: number;
|
|
66
|
+
/**
|
|
67
|
+
* base options for axios calls
|
|
68
|
+
*
|
|
69
|
+
* @type {any}
|
|
70
|
+
* @memberof Configuration
|
|
71
|
+
*/
|
|
72
|
+
baseOptions?: any;
|
|
73
|
+
/**
|
|
74
|
+
* The FormData constructor that will be used to create multipart form data
|
|
75
|
+
* requests. You can inject this here so that execution environments that
|
|
76
|
+
* do not support the FormData class can still run the generated client.
|
|
77
|
+
*
|
|
78
|
+
* @type {new () => FormData}
|
|
79
|
+
*/
|
|
80
|
+
formDataCtor?: new () => any;
|
|
81
|
+
constructor(param?: ConfigurationParameters);
|
|
82
|
+
/**
|
|
83
|
+
* Check if the given MIME is a JSON MIME.
|
|
84
|
+
* JSON MIME examples:
|
|
85
|
+
* application/json
|
|
86
|
+
* application/json; charset=UTF8
|
|
87
|
+
* APPLICATION/JSON
|
|
88
|
+
* application/vnd.company+json
|
|
89
|
+
* @param mime - MIME (Multipurpose Internet Mail Extensions)
|
|
90
|
+
* @return True if the given MIME is JSON, false otherwise.
|
|
91
|
+
*/
|
|
92
|
+
isJsonMime(mime: string): boolean;
|
|
93
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
/**
|
|
4
|
+
* Onfido API v3.6
|
|
5
|
+
* The Onfido API (v3.6)
|
|
6
|
+
*
|
|
7
|
+
* The version of the OpenAPI document: v3.6
|
|
8
|
+
*
|
|
9
|
+
*
|
|
10
|
+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
|
11
|
+
* https://openapi-generator.tech
|
|
12
|
+
* Do not edit the class manually.
|
|
13
|
+
*/
|
|
14
|
+
import { BASE_PATH } from "./base";
|
|
15
|
+
export var Region;
|
|
16
|
+
(function (Region) {
|
|
17
|
+
Region[Region["EU"] = 0] = "EU";
|
|
18
|
+
Region[Region["US"] = 1] = "US";
|
|
19
|
+
Region[Region["CA"] = 2] = "CA";
|
|
20
|
+
})(Region || (Region = {}));
|
|
21
|
+
export class Configuration {
|
|
22
|
+
constructor(param = {}) {
|
|
23
|
+
var _a;
|
|
24
|
+
if (!param.apiToken) {
|
|
25
|
+
throw new Error("No apiToken provided");
|
|
26
|
+
}
|
|
27
|
+
if (param.region && !Object.values(Region).includes(param.region)) {
|
|
28
|
+
throw new Error(`Unknown or missing region '${param.region}'`);
|
|
29
|
+
}
|
|
30
|
+
this.apiKey = 'Token token=' + param.apiToken;
|
|
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' }) });
|
|
33
|
+
this.formDataCtor = param.formDataCtor || require('form-data'); // Injiect form data constructor (if needed)
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Check if the given MIME is a JSON MIME.
|
|
37
|
+
* JSON MIME examples:
|
|
38
|
+
* application/json
|
|
39
|
+
* application/json; charset=UTF8
|
|
40
|
+
* APPLICATION/JSON
|
|
41
|
+
* application/vnd.company+json
|
|
42
|
+
* @param mime - MIME (Multipurpose Internet Mail Extensions)
|
|
43
|
+
* @return True if the given MIME is JSON, false otherwise.
|
|
44
|
+
*/
|
|
45
|
+
isJsonMime(mime) {
|
|
46
|
+
const jsonMime = new RegExp('^(application\/json|[^;/ \t]+\/[^;/ \t]+[+]json)[ \t]*(;.*)?$', 'i');
|
|
47
|
+
return mime !== null && (jsonMime.test(mime) || mime.toLowerCase() === 'application/json-patch+json');
|
|
48
|
+
}
|
|
49
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Onfido API v3.6
|
|
3
|
+
* The Onfido API (v3.6)
|
|
4
|
+
*
|
|
5
|
+
* The version of the OpenAPI document: v3.6
|
|
6
|
+
*
|
|
7
|
+
*
|
|
8
|
+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
|
9
|
+
* https://openapi-generator.tech
|
|
10
|
+
* Do not edit the class manually.
|
|
11
|
+
*/
|
|
12
|
+
export * from "./api";
|
|
13
|
+
export * from "./configuration";
|
|
14
|
+
export * from "./webhook-event-verifier";
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
/**
|
|
4
|
+
* Onfido API v3.6
|
|
5
|
+
* The Onfido API (v3.6)
|
|
6
|
+
*
|
|
7
|
+
* The version of the OpenAPI document: v3.6
|
|
8
|
+
*
|
|
9
|
+
*
|
|
10
|
+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
|
11
|
+
* https://openapi-generator.tech
|
|
12
|
+
* Do not edit the class manually.
|
|
13
|
+
*/
|
|
14
|
+
export * from "./api";
|
|
15
|
+
export * from "./configuration";
|
|
16
|
+
export * from "./webhook-event-verifier";
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { WebhookEvent } from "./api";
|
|
3
|
+
export declare class OnfidoInvalidSignatureError extends Error {
|
|
4
|
+
}
|
|
5
|
+
export declare class WebhookEventVerifier {
|
|
6
|
+
private readonly webhookToken;
|
|
7
|
+
constructor(webhookToken: string);
|
|
8
|
+
readPayload(rawEventBody: string | Buffer, hexSignature: string): WebhookEvent;
|
|
9
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
// Require crypto instead of importing, because Node can be built without crypto support.
|
|
2
|
+
let crypto;
|
|
3
|
+
try {
|
|
4
|
+
// tslint:disable-next-line: no-var-requires
|
|
5
|
+
crypto = require("crypto");
|
|
6
|
+
}
|
|
7
|
+
catch (_a) {
|
|
8
|
+
// We throw an error when verifying webhooks instead.
|
|
9
|
+
}
|
|
10
|
+
export class OnfidoInvalidSignatureError extends Error {
|
|
11
|
+
}
|
|
12
|
+
export class WebhookEventVerifier {
|
|
13
|
+
constructor(webhookToken) {
|
|
14
|
+
this.webhookToken = webhookToken;
|
|
15
|
+
}
|
|
16
|
+
readPayload(rawEventBody, hexSignature) {
|
|
17
|
+
if (!crypto) {
|
|
18
|
+
throw new Error("Verifying webhook events requires crypto support");
|
|
19
|
+
}
|
|
20
|
+
const givenSignature = Buffer.from(hexSignature, "hex");
|
|
21
|
+
// Compute the the actual HMAC signature from the raw request body.
|
|
22
|
+
const hmac = crypto.createHmac("sha256", this.webhookToken);
|
|
23
|
+
hmac.update(rawEventBody);
|
|
24
|
+
const eventSignature = hmac.digest();
|
|
25
|
+
// Use timingSafeEqual to prevent against timing attacks.
|
|
26
|
+
if (!crypto.timingSafeEqual(givenSignature, eventSignature)) {
|
|
27
|
+
throw new OnfidoInvalidSignatureError("Invalid signature for webhook event");
|
|
28
|
+
}
|
|
29
|
+
return JSON.parse(rawEventBody.toString());
|
|
30
|
+
}
|
|
31
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,19 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
export
|
|
13
|
-
export
|
|
14
|
-
export
|
|
15
|
-
export { Report } from "./resources/Reports";
|
|
16
|
-
export { Webhook, WebhookRequest } from "./resources/Webhooks";
|
|
17
|
-
export { SdkTokenRequest } from "./resources/SdkTokens";
|
|
18
|
-
export { Autofill, ExtractionResult } from "./resources/Autofill";
|
|
19
|
-
export { WorkflowRun, WorkflowRunRequest } from "./resources/WorkflowRuns";
|
|
1
|
+
/**
|
|
2
|
+
* Onfido API v3.6
|
|
3
|
+
* The Onfido API (v3.6)
|
|
4
|
+
*
|
|
5
|
+
* The version of the OpenAPI document: v3.6
|
|
6
|
+
*
|
|
7
|
+
*
|
|
8
|
+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
|
9
|
+
* https://openapi-generator.tech
|
|
10
|
+
* Do not edit the class manually.
|
|
11
|
+
*/
|
|
12
|
+
export * from "./api";
|
|
13
|
+
export * from "./configuration";
|
|
14
|
+
export * from "./webhook-event-verifier";
|