@onfido/api 3.0.0 → 3.2.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/dist/common.js CHANGED
@@ -136,49 +136,10 @@ const serializeDataIfNeeded = function (value, requestOptions, configuration) {
136
136
  ? configuration.isJsonMime(requestOptions.headers['Content-Type'])
137
137
  : nonString;
138
138
  return needsSerialization
139
- ? JSON.stringify(value !== undefined ? convertMapsAndSetsToPlain(value) : {})
139
+ ? JSON.stringify(value !== undefined ? value : {})
140
140
  : (value || "");
141
141
  };
142
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
143
  /**
183
144
  *
184
145
  * @export
@@ -32,7 +32,7 @@ class Configuration {
32
32
  }
33
33
  this.apiKey = 'Token token=' + param.apiToken;
34
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' }) });
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.2.0' }) });
36
36
  this.formDataCtor = param.formDataCtor || require('form-data'); // Injiect form data constructor (if needed)
37
37
  }
38
38
  /**