idmission-web-sdk 2.2.56 → 2.2.57

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.
@@ -211,7 +211,7 @@
211
211
  return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
212
212
  };
213
213
 
214
- var webSdkVersion = '2.2.56';
214
+ var webSdkVersion = '2.2.57';
215
215
 
216
216
  function getPlatform() {
217
217
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
@@ -2277,7 +2277,7 @@
2277
2277
  var uploadDocument = React.useCallback(function (src, metadata) {
2278
2278
  return new Promise(function (resolve, reject) {
2279
2279
  return __awaiter(void 0, void 0, void 0, function () {
2280
- var blob, _a, upload, _b, _c;
2280
+ var blob, _a, documentId, upload, _b, _c;
2281
2281
  var _d, _e;
2282
2282
  var _f;
2283
2283
  return __generator(this, function (_g) {
@@ -2315,9 +2315,22 @@
2315
2315
  percentage: (bytesUploaded / bytesTotal * 100).toFixed(2) + '%',
2316
2316
  metadata: metadata
2317
2317
  });
2318
+ }, _d.onAfterResponse = function (_req, res) {
2319
+ var contentType = res.getHeader('Content-Type');
2320
+ if (!(contentType === null || contentType === void 0 ? void 0 : contentType.startsWith('application/json'))) return;
2321
+ var body = res.getBody();
2322
+ if (!body) return;
2323
+ try {
2324
+ var parsedId = JSON.parse(body).id;
2325
+ if (parsedId.startsWith('urn:documentsv1:')) {
2326
+ documentId = parsedId;
2327
+ }
2328
+ } catch (e) {
2329
+ warn('Failed to parse documents service response body', e);
2330
+ }
2318
2331
  }, _d.onSuccess = function () {
2319
2332
  var _a, _b;
2320
- var documentId = 'urn:documentsv1:' + ((_a = upload.url.split('/files/').pop()) === null || _a === void 0 ? void 0 : _a.split('+').shift());
2333
+ documentId || (documentId = "urn:documentsv1:".concat((_a = upload.url.split('/files/').pop()) === null || _a === void 0 ? void 0 : _a.split('+').shift()));
2321
2334
  (_b = onDocumentUploaded.current) === null || _b === void 0 ? void 0 : _b.call(onDocumentUploaded, documentId, metadata);
2322
2335
  resolve(documentId);
2323
2336
  }, _d.onError = function (error) {