UNPKG

@onfido/api

Version:

Node.js library for the Onfido API

54 lines (53 loc) 2.2 kB
"use strict"; /* 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. */ Object.defineProperty(exports, "__esModule", { value: true }); exports.Configuration = exports.Region = void 0; const base_1 = require("./base"); var Region; (function (Region) { Region[Region["EU"] = 0] = "EU"; Region[Region["US"] = 1] = "US"; Region[Region["CA"] = 2] = "CA"; })(Region = exports.Region || (exports.Region = {})); 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_1.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'); } } exports.Configuration = Configuration;