@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.
Files changed (54) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +115 -132
  3. package/dist/api.d.ts +11690 -0
  4. package/dist/api.js +5113 -0
  5. package/dist/base.d.ts +66 -0
  6. package/dist/base.js +65 -0
  7. package/dist/common.d.ts +66 -0
  8. package/dist/common.js +201 -0
  9. package/dist/configuration.d.ts +93 -0
  10. package/dist/configuration.js +53 -0
  11. package/dist/esm/api.d.ts +11690 -0
  12. package/dist/esm/api.js +5106 -0
  13. package/dist/esm/base.d.ts +66 -0
  14. package/dist/esm/base.js +60 -0
  15. package/dist/esm/common.d.ts +66 -0
  16. package/dist/esm/common.js +189 -0
  17. package/dist/esm/configuration.d.ts +93 -0
  18. package/dist/esm/configuration.js +49 -0
  19. package/dist/esm/index.d.ts +14 -0
  20. package/dist/esm/index.js +16 -0
  21. package/dist/esm/webhook-event-verifier.d.ts +9 -0
  22. package/dist/esm/webhook-event-verifier.js +31 -0
  23. package/dist/index.d.ts +14 -19
  24. package/dist/index.js +31 -553
  25. package/dist/webhook-event-verifier.d.ts +9 -0
  26. package/dist/webhook-event-verifier.js +36 -0
  27. package/package.json +30 -31
  28. package/CHANGELOG.md +0 -121
  29. package/dist/Onfido.d.ts +0 -40
  30. package/dist/OnfidoDownload.d.ts +0 -9
  31. package/dist/Resource.d.ts +0 -22
  32. package/dist/WebhookEventVerifier.d.ts +0 -17
  33. package/dist/errors/OnfidoApiError.d.ts +0 -10
  34. package/dist/errors/OnfidoError.d.ts +0 -3
  35. package/dist/formatting.d.ts +0 -16
  36. package/dist/index.es.js +0 -544
  37. package/dist/index.es.js.map +0 -1
  38. package/dist/index.js.map +0 -1
  39. package/dist/resources/Addresses.d.ts +0 -27
  40. package/dist/resources/Applicants.d.ts +0 -44
  41. package/dist/resources/Autofill.d.ts +0 -37
  42. package/dist/resources/Checks.d.ts +0 -42
  43. package/dist/resources/ConsentsRequest.d.ts +0 -4
  44. package/dist/resources/Documents.d.ts +0 -34
  45. package/dist/resources/IdNumbers.d.ts +0 -10
  46. package/dist/resources/LivePhotos.d.ts +0 -25
  47. package/dist/resources/LiveVideos.d.ts +0 -19
  48. package/dist/resources/Location.d.ts +0 -8
  49. package/dist/resources/MotionCaptures.d.ts +0 -19
  50. package/dist/resources/Reports.d.ts +0 -24
  51. package/dist/resources/SdkTokens.d.ts +0 -12
  52. package/dist/resources/Webhooks.d.ts +0 -26
  53. package/dist/resources/WorkflowRuns.d.ts +0 -48
  54. package/dist/types/formData.d.ts +0 -27
package/dist/base.d.ts ADDED
@@ -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/base.js ADDED
@@ -0,0 +1,65 @@
1
+ "use strict";
2
+ /* tslint:disable */
3
+ /* eslint-disable */
4
+ /**
5
+ * Onfido API v3.6
6
+ * The Onfido API (v3.6)
7
+ *
8
+ * The version of the OpenAPI document: v3.6
9
+ *
10
+ *
11
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
12
+ * https://openapi-generator.tech
13
+ * Do not edit the class manually.
14
+ */
15
+ Object.defineProperty(exports, "__esModule", { value: true });
16
+ exports.operationServerMap = exports.RequiredError = exports.BaseAPI = exports.COLLECTION_FORMATS = exports.BASE_PATH = void 0;
17
+ const axios_1 = require("axios");
18
+ exports.BASE_PATH = "https://api.eu.onfido.com/v3.6".replace(/\/+$/, "");
19
+ /**
20
+ *
21
+ * @export
22
+ */
23
+ exports.COLLECTION_FORMATS = {
24
+ csv: ",",
25
+ ssv: " ",
26
+ tsv: "\t",
27
+ pipes: "|",
28
+ };
29
+ /**
30
+ *
31
+ * @export
32
+ * @class BaseAPI
33
+ */
34
+ class BaseAPI {
35
+ constructor(configuration, basePath = exports.BASE_PATH, axios = axios_1.default) {
36
+ var _a;
37
+ this.basePath = basePath;
38
+ this.axios = axios;
39
+ if (configuration) {
40
+ this.configuration = configuration;
41
+ this.basePath = (_a = configuration.basePath) !== null && _a !== void 0 ? _a : basePath;
42
+ }
43
+ }
44
+ }
45
+ exports.BaseAPI = BaseAPI;
46
+ ;
47
+ /**
48
+ *
49
+ * @export
50
+ * @class RequiredError
51
+ * @extends {Error}
52
+ */
53
+ class RequiredError extends Error {
54
+ constructor(field, msg) {
55
+ super(msg);
56
+ this.field = field;
57
+ this.name = "RequiredError";
58
+ }
59
+ }
60
+ exports.RequiredError = RequiredError;
61
+ /**
62
+ *
63
+ * @export
64
+ */
65
+ exports.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>;
package/dist/common.js ADDED
@@ -0,0 +1,201 @@
1
+ "use strict";
2
+ /* tslint:disable */
3
+ /* eslint-disable */
4
+ /**
5
+ * Onfido API v3.6
6
+ * The Onfido API (v3.6)
7
+ *
8
+ * The version of the OpenAPI document: v3.6
9
+ *
10
+ *
11
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
12
+ * https://openapi-generator.tech
13
+ * Do not edit the class manually.
14
+ */
15
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
16
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
17
+ return new (P || (P = Promise))(function (resolve, reject) {
18
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
19
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
20
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
21
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
22
+ });
23
+ };
24
+ Object.defineProperty(exports, "__esModule", { value: true });
25
+ exports.createRequestFunction = exports.toPathString = exports.serializeDataIfNeeded = exports.setSearchParams = exports.setOAuthToObject = exports.setBearerAuthToObject = exports.setBasicAuthToObject = exports.setApiKeyToObject = exports.assertParamExists = exports.DUMMY_BASE_URL = void 0;
26
+ const base_1 = require("./base");
27
+ const url_1 = require("url");
28
+ /**
29
+ *
30
+ * @export
31
+ */
32
+ exports.DUMMY_BASE_URL = 'https://example.com';
33
+ /**
34
+ *
35
+ * @throws {RequiredError}
36
+ * @export
37
+ */
38
+ const assertParamExists = function (functionName, paramName, paramValue) {
39
+ if (paramValue === null || paramValue === undefined) {
40
+ throw new base_1.RequiredError(paramName, `Required parameter ${paramName} was null or undefined when calling ${functionName}.`);
41
+ }
42
+ };
43
+ exports.assertParamExists = assertParamExists;
44
+ /**
45
+ *
46
+ * @export
47
+ */
48
+ const setApiKeyToObject = function (object, keyParamName, configuration) {
49
+ return __awaiter(this, void 0, void 0, function* () {
50
+ if (configuration && configuration.apiKey) {
51
+ const localVarApiKeyValue = typeof configuration.apiKey === 'function'
52
+ ? yield configuration.apiKey(keyParamName)
53
+ : yield configuration.apiKey;
54
+ object[keyParamName] = localVarApiKeyValue;
55
+ }
56
+ });
57
+ };
58
+ exports.setApiKeyToObject = setApiKeyToObject;
59
+ /**
60
+ *
61
+ * @export
62
+ */
63
+ const setBasicAuthToObject = function (object, configuration) {
64
+ if (configuration && (configuration.username || configuration.password)) {
65
+ object["auth"] = { username: configuration.username, password: configuration.password };
66
+ }
67
+ };
68
+ exports.setBasicAuthToObject = setBasicAuthToObject;
69
+ /**
70
+ *
71
+ * @export
72
+ */
73
+ const setBearerAuthToObject = function (object, configuration) {
74
+ return __awaiter(this, void 0, void 0, function* () {
75
+ if (configuration && configuration.accessToken) {
76
+ const accessToken = typeof configuration.accessToken === 'function'
77
+ ? yield configuration.accessToken()
78
+ : yield configuration.accessToken;
79
+ object["Authorization"] = "Bearer " + accessToken;
80
+ }
81
+ });
82
+ };
83
+ exports.setBearerAuthToObject = setBearerAuthToObject;
84
+ /**
85
+ *
86
+ * @export
87
+ */
88
+ const setOAuthToObject = function (object, name, scopes, configuration) {
89
+ return __awaiter(this, void 0, void 0, function* () {
90
+ if (configuration && configuration.accessToken) {
91
+ const localVarAccessTokenValue = typeof configuration.accessToken === 'function'
92
+ ? yield configuration.accessToken(name, scopes)
93
+ : yield configuration.accessToken;
94
+ object["Authorization"] = "Bearer " + localVarAccessTokenValue;
95
+ }
96
+ });
97
+ };
98
+ exports.setOAuthToObject = setOAuthToObject;
99
+ function setFlattenedQueryParams(urlSearchParams, parameter, key = "") {
100
+ if (parameter == null)
101
+ return;
102
+ if (typeof parameter === "object") {
103
+ if (Array.isArray(parameter)) {
104
+ parameter.forEach(item => setFlattenedQueryParams(urlSearchParams, item, key));
105
+ }
106
+ else {
107
+ Object.keys(parameter).forEach(currentKey => setFlattenedQueryParams(urlSearchParams, parameter[currentKey], `${key}${key !== '' ? '.' : ''}${currentKey}`));
108
+ }
109
+ }
110
+ else {
111
+ if (urlSearchParams.has(key)) {
112
+ urlSearchParams.append(key, parameter);
113
+ }
114
+ else {
115
+ urlSearchParams.set(key, parameter);
116
+ }
117
+ }
118
+ }
119
+ /**
120
+ *
121
+ * @export
122
+ */
123
+ const setSearchParams = function (url, ...objects) {
124
+ const searchParams = new url_1.URLSearchParams(url.search);
125
+ setFlattenedQueryParams(searchParams, objects);
126
+ url.search = searchParams.toString();
127
+ };
128
+ exports.setSearchParams = setSearchParams;
129
+ /**
130
+ *
131
+ * @export
132
+ */
133
+ const serializeDataIfNeeded = function (value, requestOptions, configuration) {
134
+ const nonString = typeof value !== 'string';
135
+ const needsSerialization = nonString && configuration && configuration.isJsonMime
136
+ ? configuration.isJsonMime(requestOptions.headers['Content-Type'])
137
+ : nonString;
138
+ return needsSerialization
139
+ ? JSON.stringify(value !== undefined ? convertMapsAndSetsToPlain(value) : {})
140
+ : (value || "");
141
+ };
142
+ exports.serializeDataIfNeeded = serializeDataIfNeeded;
143
+ function convertMapsAndSetsToPlain(value) {
144
+ if (typeof Set === "undefined")
145
+ return value;
146
+ if (typeof Map === "undefined")
147
+ return value;
148
+ if (typeof value !== "object" || !value) {
149
+ return value;
150
+ }
151
+ if (value instanceof Set) {
152
+ return Array.from(value).map(item => convertMapsAndSetsToPlain(item));
153
+ }
154
+ if (value instanceof Map) {
155
+ const entries = [];
156
+ value.forEach((value, key) => {
157
+ entries.push([key, convertMapsAndSetsToPlain(value)]);
158
+ });
159
+ return objectFromEntries(entries);
160
+ }
161
+ if (Array.isArray(value)) {
162
+ return value.map(it => convertMapsAndSetsToPlain(it));
163
+ }
164
+ return objectFromEntries(objectEntries(value)
165
+ .map(([k, v]) => [k, convertMapsAndSetsToPlain(v)]));
166
+ }
167
+ /**
168
+ * Ponyfill for Object.entries
169
+ */
170
+ function objectEntries(object) {
171
+ return Object.keys(object).map(key => [key, object[key]]);
172
+ }
173
+ /**
174
+ * Ponyfill for Object.fromEntries
175
+ */
176
+ function objectFromEntries(entries) {
177
+ return [...entries].reduce((object, [key, val]) => {
178
+ object[key] = val;
179
+ return object;
180
+ }, {});
181
+ }
182
+ /**
183
+ *
184
+ * @export
185
+ */
186
+ const toPathString = function (url) {
187
+ return url.pathname + url.search + url.hash;
188
+ };
189
+ exports.toPathString = toPathString;
190
+ /**
191
+ *
192
+ * @export
193
+ */
194
+ const createRequestFunction = function (axiosArgs, globalAxios, BASE_PATH, configuration) {
195
+ return (axios = globalAxios, basePath = BASE_PATH) => {
196
+ var _a;
197
+ 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 });
198
+ return axios.request(axiosRequestArgs);
199
+ };
200
+ };
201
+ exports.createRequestFunction = createRequestFunction;
@@ -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,53 @@
1
+ "use strict";
2
+ /* tslint:disable */
3
+ /* eslint-disable */
4
+ /**
5
+ * Onfido API v3.6
6
+ * The Onfido API (v3.6)
7
+ *
8
+ * The version of the OpenAPI document: v3.6
9
+ *
10
+ *
11
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
12
+ * https://openapi-generator.tech
13
+ * Do not edit the class manually.
14
+ */
15
+ Object.defineProperty(exports, "__esModule", { value: true });
16
+ exports.Configuration = exports.Region = void 0;
17
+ const base_1 = require("./base");
18
+ var Region;
19
+ (function (Region) {
20
+ Region[Region["EU"] = 0] = "EU";
21
+ Region[Region["US"] = 1] = "US";
22
+ Region[Region["CA"] = 2] = "CA";
23
+ })(Region = exports.Region || (exports.Region = {}));
24
+ class Configuration {
25
+ constructor(param = {}) {
26
+ var _a;
27
+ if (!param.apiToken) {
28
+ throw new Error("No apiToken provided");
29
+ }
30
+ if (param.region && !Object.values(Region).includes(param.region)) {
31
+ throw new Error(`Unknown or missing region '${param.region}'`);
32
+ }
33
+ this.apiKey = 'Token token=' + param.apiToken;
34
+ this.basePath = param.basePath || base_1.BASE_PATH.replace('.eu.', `.${Region[param.region || Region.EU].toLowerCase()}.`);
35
+ 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' }) });
36
+ this.formDataCtor = param.formDataCtor || require('form-data'); // Injiect form data constructor (if needed)
37
+ }
38
+ /**
39
+ * Check if the given MIME is a JSON MIME.
40
+ * JSON MIME examples:
41
+ * application/json
42
+ * application/json; charset=UTF8
43
+ * APPLICATION/JSON
44
+ * application/vnd.company+json
45
+ * @param mime - MIME (Multipurpose Internet Mail Extensions)
46
+ * @return True if the given MIME is JSON, false otherwise.
47
+ */
48
+ isJsonMime(mime) {
49
+ const jsonMime = new RegExp('^(application\/json|[^;/ \t]+\/[^;/ \t]+[+]json)[ \t]*(;.*)?$', 'i');
50
+ return mime !== null && (jsonMime.test(mime) || mime.toLowerCase() === 'application/json-patch+json');
51
+ }
52
+ }
53
+ exports.Configuration = Configuration;