@onfido/api
Version:
Node.js library for the Onfido API
50 lines (49 loc) • 2.02 kB
JavaScript
/* tslint:disable */
/* eslint-disable */
/**
* Onfido API v3.6
* The Onfido API (v3.6)
*
* The version of the OpenAPI document: v3.6
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
import { BASE_PATH } from "./base";
export var Region;
(function (Region) {
Region[Region["EU"] = 0] = "EU";
Region[Region["US"] = 1] = "US";
Region[Region["CA"] = 2] = "CA";
})(Region || (Region = {}));
export class Configuration {
constructor(param = {}) {
var _a;
if (!param.apiToken) {
throw new Error("No apiToken provided");
}
if (param.region && !Object.values(Region).includes(param.region)) {
throw new Error(`Unknown or missing region '${param.region}'`);
}
this.apiKey = 'Token token=' + param.apiToken;
this.basePath = param.basePath || BASE_PATH.replace('.eu.', `.${Region[param.region || Region.EU].toLowerCase()}.`);
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/5.4.0" }) });
this.formDataCtor = param.formDataCtor || require('form-data'); // Injiect form data constructor (if needed)
}
/**
* Check if the given MIME is a JSON MIME.
* JSON MIME examples:
* application/json
* application/json; charset=UTF8
* APPLICATION/JSON
* application/vnd.company+json
* @param mime - MIME (Multipurpose Internet Mail Extensions)
* @return True if the given MIME is JSON, false otherwise.
*/
isJsonMime(mime) {
const jsonMime = new RegExp('^(application\/json|[^;/ \t]+\/[^;/ \t]+[+]json)[ \t]*(;.*)?$', 'i');
return mime !== null && (jsonMime.test(mime) || mime.toLowerCase() === 'application/json-patch+json');
}
}