idmission-web-sdk 2.6.3-changeset-release-develop-124a427 → 2.6.3-changeset-release-develop-776f131

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.
@@ -5559,6 +5559,21 @@
5559
5559
  if (taskID) merged.taskid = taskID;
5560
5560
  return merged;
5561
5561
  }
5562
+ /**
5563
+ * Runs a customer callback whose failure must not change an outcome that is
5564
+ * already settled: a throw or a rejected promise is logged, never rethrown.
5565
+ */
5566
+ function notifySafely$1(name, notify) {
5567
+ try {
5568
+ // `Promise.resolve`, not `instanceof Promise`: a promise from another
5569
+ // realm (an iframe) fails that check, and its rejection would go unhandled.
5570
+ Promise.resolve(notify())["catch"](function (e) {
5571
+ return warn$2(name + " rejected", e);
5572
+ });
5573
+ } catch (e) {
5574
+ warn$2(name + " threw", e);
5575
+ }
5576
+ }
5562
5577
  /**
5563
5578
  * How long an async `sessionId` resolver may take. It typically mints the
5564
5579
  * session through the host's own backend (an OAuth token, then
@@ -5581,6 +5596,10 @@
5581
5596
  return clearTimeout(timer);
5582
5597
  });
5583
5598
  }
5599
+ /**
5600
+ * Creates a client. Its type is `Required<IdmissionClient>`: unlike a
5601
+ * hand-written `IdmissionClient`, it always has `post()` and `handoff()`.
5602
+ */
5584
5603
  function createIdmissionClient(config) {
5585
5604
  var _config$fetch, _config$now;
5586
5605
  // `let`: when config.sessionId is an async resolver, the session URN (and
@@ -5631,7 +5650,10 @@
5631
5650
  var livenessToken;
5632
5651
  function timedFetch(_x, _x2) {
5633
5652
  return _timedFetch.apply(this, arguments);
5634
- }
5653
+ } // The attestation nonce THIS client's session was validated with. The
5654
+ // holders are module-level, so another client validating later replaces
5655
+ // them; comparing against this, not against whatever the holder says at
5656
+ // submit time, is what keeps that client's nonce off this client's request.
5635
5657
  function _timedFetch() {
5636
5658
  _timedFetch = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2(url, init) {
5637
5659
  var controller, timer;
@@ -5667,10 +5689,35 @@
5667
5689
  }));
5668
5690
  return _timedFetch.apply(this, arguments);
5669
5691
  }
5670
- function performUpload(blob, metadata) {
5671
- return uploadDocument(blob, metadata, {
5672
- documentServiceUrl: urls.documentServiceUrl,
5692
+ var validatedSessionNonce = null;
5693
+ function currentRoute() {
5694
+ return {
5673
5695
  sessionId: store.getState().session.sessionId,
5696
+ submissionUrl: urls.submissionUrl,
5697
+ documentServiceUrl: urls.documentServiceUrl,
5698
+ sessionNonce: validatedSessionNonce
5699
+ };
5700
+ }
5701
+ // The attestation holders are module-level and follow the newest
5702
+ // ValidateSession, from any client. If they no longer hold this operation's
5703
+ // session nonce, the nonce and OS token belong to someone else: omit the
5704
+ // envelope (throwing here is
5705
+ // attachMetadataToRequest's fail-open path, which reports
5706
+ // `attestationAttached: false`) rather than attach a stranger's.
5707
+ function routeBoundCollectors(route) {
5708
+ return {
5709
+ collectAttestation: function collectAttestation(web, versions) {
5710
+ if (getLastSessionNonce() !== route.sessionNonce) {
5711
+ throw new Error('session changed during submission; attestation omitted');
5712
+ }
5713
+ return collectClientAttestation(web, versions);
5714
+ }
5715
+ };
5716
+ }
5717
+ function performUpload(blob, metadata, route) {
5718
+ return uploadDocument(blob, metadata, {
5719
+ documentServiceUrl: route.documentServiceUrl,
5720
+ sessionId: route.sessionId,
5674
5721
  Upload: config.tusUpload,
5675
5722
  delay: config.delay,
5676
5723
  calculateMd5: config.calculateMd5,
@@ -5722,7 +5769,7 @@
5722
5769
  }
5723
5770
  function _runSessionValidation() {
5724
5771
  _runSessionValidation = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee3(epoch) {
5725
- var authUrl, adoptSessionUrls, resolvedSessionId, err, valid, finalState, _err, _t, _t2;
5772
+ var authUrl, adoptSessionUrls, resolvedSessionId, err, responseNonce, valid, finalState, _err, _t, _t2;
5726
5773
  return _regeneratorRuntime.wrap(function (_context3) {
5727
5774
  while (1) switch (_context3.prev = _context3.next) {
5728
5775
  case 0:
@@ -5817,14 +5864,22 @@
5817
5864
  payload: 'RUNNING'
5818
5865
  });
5819
5866
  _context3.prev = 8;
5867
+ // The nonce THIS response carried, taken as it is ingested: reading
5868
+ // the shared holder after the await could pick up another client's.
5869
+ responseNonce = null;
5820
5870
  _context3.next = 9;
5821
5871
  return validateSession(authUrl, resolvedSessionId, {
5822
5872
  fetch: config.fetch,
5823
- delay: config.delay
5873
+ delay: config.delay,
5874
+ ingestNonce: function ingestNonce(nonce) {
5875
+ responseNonce = typeof nonce === 'string' && nonce ? nonce : null;
5876
+ ingestSessionAttestation(nonce);
5877
+ }
5824
5878
  });
5825
5879
  case 9:
5826
5880
  valid = _context3.sent;
5827
5881
  finalState = valid ? 'PASSED' : 'FAILED';
5882
+ if (epoch === sessionRunEpoch) validatedSessionNonce = responseNonce;
5828
5883
  dispatchSessionIfCurrent(epoch, {
5829
5884
  type: 'setCheckState',
5830
5885
  payload: finalState
@@ -5894,23 +5949,28 @@
5894
5949
  }));
5895
5950
  return _retrySession.apply(this, arguments);
5896
5951
  }
5897
- function submit(_x6, _x7) {
5898
- return _submit.apply(this, arguments);
5952
+ function runPipeline(_x6, _x7, _x8) {
5953
+ return _runPipeline.apply(this, arguments);
5899
5954
  }
5900
- function _submit() {
5901
- _submit = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee7(artifacts, options) {
5902
- var _options$onBeforeSubm;
5903
- var progress, uploadsInFlight, beforeSubmit, startedAt, payloadBuildStart, payloadBuildEnd, uploadMeasurements, apiCallStart, apiCallEnd, responseParseStart, responseParseEnd, failedAt, _artifacts$id, _artifacts$id2, _artifacts$id3, _artifacts$face, payloadResult, _artifacts$meta$liven, _artifacts$meta, request, sessionId, endpoint, submissionResponse, response, _response$statusText, statusMessage, err, endedAt, _t4, _t5, _t6, _t7, _t8, _t9, _t0;
5955
+ function _runPipeline() {
5956
+ _runPipeline = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee7(artifacts, options, kind) {
5957
+ var _artifacts$meta$liven, _artifacts$meta, _options$onBeforeSubm;
5958
+ var handsOff, route, claimedLivenessToken, progress, uploadsInFlight, beforeSubmit, startedAt, payloadBuildStart, payloadBuildEnd, uploadMeasurements, apiCallStart, apiCallEnd, responseParseStart, responseParseEnd, failedAt, built, timings, payloadResult, request, _artifacts$id, _artifacts$id2, _artifacts$id3, _artifacts$face, endpoint, submissionResponse, response, _response$statusText, statusMessage, err, endedAt, _built, _response, _request, _t4, _t5, _t6, _t7, _t8, _t9, _t0;
5904
5959
  return _regeneratorRuntime.wrap(function (_context7) {
5905
5960
  while (1) switch (_context7.prev = _context7.next) {
5906
5961
  case 0:
5907
- if (!(options.action === SubmissionAction.NONE && !config.onSubmit)) {
5962
+ handsOff = kind === 'handoff' || kind === 'submit' && config.onSubmit !== undefined; // sdk2 short-circuits action NONE to a synthetic success before any
5963
+ // network activity (SubmissionProvider.tsx:1203-1225). This client does
5964
+ // not fabricate that response, but it keeps the "NONE does no network
5965
+ // work" guarantee by rejecting here, before any upload — unless the
5966
+ // request is being handed off, which is the one thing NONE can do.
5967
+ if (!(options.action === SubmissionAction.NONE && !handsOff)) {
5908
5968
  _context7.next = 1;
5909
5969
  break;
5910
5970
  }
5911
5971
  throw new SubmissionError({
5912
5972
  statusCode: 'UNSUPPORTED_ACTION',
5913
- statusMessage: "submit() rejects action: 'NONE' -- capture-only, no-network submission is the controller layer's responsibility (plan 3), not this client's"
5973
+ statusMessage: "action 'NONE' has no endpoint to post to; use handoff() to build the request without posting it"
5914
5974
  });
5915
5975
  case 1:
5916
5976
  if (!(store.getState().session.sessionCheckState !== 'PASSED')) {
@@ -5919,6 +5979,11 @@
5919
5979
  }
5920
5980
  throw new AuthenticationError(401, 'session not validated');
5921
5981
  case 2:
5982
+ route = currentRoute(); // Claimed, not read: an overlapping operation must not reuse it, and a
5983
+ // `checkLiveness()` that lands mid-operation keeps its own token for the
5984
+ // next one (SubmissionProvider.tsx:1350 cleared it after the submit).
5985
+ claimedLivenessToken = (_artifacts$meta$liven = (_artifacts$meta = artifacts.meta) == null ? void 0 : _artifacts$meta.livenessToken) != null ? _artifacts$meta$liven : livenessToken;
5986
+ livenessToken = undefined;
5922
5987
  store.setState({
5923
5988
  submissionStatus: SubmissionStatus.SUBMITTING,
5924
5989
  submissionError: undefined
@@ -5935,7 +6000,7 @@
5935
6000
  _context7.next = 5;
5936
6001
  return buildSubmissionPayload(_extends$1({}, artifacts, {
5937
6002
  meta: _extends$1({}, artifacts.meta, {
5938
- livenessToken: (_artifacts$meta$liven = (_artifacts$meta = artifacts.meta) == null ? void 0 : _artifacts$meta.livenessToken) != null ? _artifacts$meta$liven : livenessToken
6003
+ livenessToken: claimedLivenessToken
5939
6004
  })
5940
6005
  }), _extends$1({}, options, {
5941
6006
  onBeforeSubmit: beforeSubmit ? function (request) {
@@ -5951,7 +6016,7 @@
5951
6016
  // withJobTaskMetadata (see its own comment above): only present
5952
6017
  // when options.jobID/taskID are present.
5953
6018
  uploadDocument: documentServiceEnabled ? (/*#__PURE__*/function () {
5954
- var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee6(blob, metadata) {
6019
+ var _ref3 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee6(blob, metadata) {
5955
6020
  var result, _t3;
5956
6021
  return _regeneratorRuntime.wrap(function (_context6) {
5957
6022
  while (1) switch (_context6.prev = _context6.next) {
@@ -5968,7 +6033,7 @@
5968
6033
  });
5969
6034
  _context6.prev = 1;
5970
6035
  _context6.next = 2;
5971
- return performUpload(blob, withJobTaskMetadata(metadata, options.jobID, options.taskID));
6036
+ return performUpload(blob, withJobTaskMetadata(metadata, options.jobID, options.taskID), route);
5972
6037
  case 2:
5973
6038
  result = _context6.sent;
5974
6039
  progress.observe({
@@ -5998,12 +6063,13 @@
5998
6063
  }
5999
6064
  }, _callee6, null, [[1, 3, 4, 5]]);
6000
6065
  }));
6001
- return function (_x10, _x11) {
6002
- return _ref2.apply(this, arguments);
6066
+ return function (_x13, _x14) {
6067
+ return _ref3.apply(this, arguments);
6003
6068
  };
6004
6069
  }()) : undefined,
6005
6070
  now: config.now,
6006
- sdkVersions: config.sdkVersions
6071
+ sdkVersions: config.sdkVersions,
6072
+ collectors: routeBoundCollectors(route)
6007
6073
  });
6008
6074
  case 5:
6009
6075
  payloadResult = _context7.sent;
@@ -6017,40 +6083,41 @@
6017
6083
  case 7:
6018
6084
  payloadBuildEnd = payloadResult.uploadTimings.payloadBuildEnd;
6019
6085
  uploadMeasurements = payloadResult.uploadTimings.uploads;
6020
- request = payloadResult.request; // Stashed HERE rather than next to `lastSubmissionTimings` in the
6021
- // `finally`, because the hand-off below returns early: parking it in
6022
- // the same setState as the timings would leave `onSubmit` customers
6023
- // with a timings block and no request to go with it.
6086
+ request = payloadResult.request; // Stashed before the hand-off returns, so hand-off callers get the
6087
+ // request alongside the timings the `finally` records.
6024
6088
  store.setState({
6025
6089
  attestationAttached: payloadResult.attestationAttached,
6026
6090
  lastSubmissionRequest: request
6027
6091
  });
6028
- // THE HAND-OFF. sdk2 short-circuits at the equivalent point
6029
- // (SubmissionProvider.tsx:1374-1377, `return onSubmit.current(request)`
6030
- // before `defaultOnSubmit`), so everything above this line runs and
6031
- // nothing below it does.
6032
- //
6033
- // The status goes to SUBMITTED, where sdk2 leaves it at READY. That is a
6034
- // deliberate divergence in INTERNAL state to preserve the VISIBLE
6035
- // behaviour: sdk2's wizard renders an empty fragment for READY via its
6036
- // switch `default`, whereas this codebase renders the submitting screen
6037
- // for READY — so inheriting READY would park the user on a spinner
6038
- // forever. SUBMITTED with no response falls through every terminal
6039
- // branch to `return null`, which is sdk2's empty fragment.
6040
- if (!config.onSubmit) {
6092
+ if (!handsOff) {
6041
6093
  _context7.next = 8;
6042
6094
  break;
6043
6095
  }
6096
+ // sdk2 short-circuits at the equivalent point
6097
+ // (SubmissionProvider.tsx:1374-1377), so everything above runs and
6098
+ // nothing below does.
6099
+ //
6100
+ // The status goes to SUBMITTED, where sdk2 leaves it at READY. That is
6101
+ // a deliberate divergence in INTERNAL state to preserve the VISIBLE
6102
+ // behaviour: sdk2's wizard renders an empty fragment for READY via its
6103
+ // switch `default`, whereas this codebase renders the submitting
6104
+ // screen for READY — so inheriting READY would park the user on a
6105
+ // spinner forever. SUBMITTED with no response falls through every
6106
+ // terminal branch to `return null`, which is sdk2's empty fragment.
6044
6107
  store.setState({
6045
6108
  submissionStatus: SubmissionStatus.SUBMITTED
6046
6109
  });
6047
- config.onSubmit(request);
6110
+ if (kind === 'submit') config.onSubmit == null || config.onSubmit(request);
6048
6111
  progress.observe({
6049
6112
  kind: 'flow-completed'
6050
6113
  });
6051
- return _context7.abrupt("return", null);
6114
+ built = {
6115
+ request: request,
6116
+ response: null
6117
+ };
6118
+ _context7.next = 23;
6119
+ break;
6052
6120
  case 8:
6053
- sessionId = store.getState().session.sessionId;
6054
6121
  endpoint = determineSubmissionEndpoint(options.action, !!((_artifacts$id = artifacts.id) != null && _artifacts$id.frontImage || (_artifacts$id2 = artifacts.id) != null && _artifacts$id2.backImage || (_artifacts$id3 = artifacts.id) != null && _artifacts$id3.passportImage), !!((_artifacts$face = artifacts.face) != null && _artifacts$face.selfieImage));
6055
6122
  progress.observe({
6056
6123
  kind: 'phase',
@@ -6065,9 +6132,9 @@
6065
6132
  _context7.prev = 9;
6066
6133
  _context7.prev = 10;
6067
6134
  _context7.next = 11;
6068
- return timedFetch(urls.submissionUrl + endpoint, {
6135
+ return timedFetch(route.submissionUrl + endpoint, {
6069
6136
  method: 'POST',
6070
- headers: apiHeaders(sessionId, options.sendBase64DocumentsInSwaggerProxy),
6137
+ headers: apiHeaders(route.sessionId, options.sendBase64DocumentsInSwaggerProxy),
6071
6138
  body: JSON.stringify(request)
6072
6139
  });
6073
6140
  case 11:
@@ -6157,10 +6224,21 @@
6157
6224
  progress.observe({
6158
6225
  kind: 'flow-completed'
6159
6226
  });
6160
- config.onResponseReceived == null || config.onResponseReceived(submissionResponse, request);
6161
- return _context7.abrupt("return", submissionResponse);
6227
+ // Legacy `submit()` keeps a throwing `onResponseReceived` inside the
6228
+ // failure path, as it always has; `post()` notifies after the outcome
6229
+ // is settled (below).
6230
+ if (kind === 'submit') {
6231
+ config.onResponseReceived == null || config.onResponseReceived(submissionResponse, request);
6232
+ }
6233
+ built = {
6234
+ request: request,
6235
+ response: submissionResponse
6236
+ };
6162
6237
  case 23:
6163
- _context7.prev = 23;
6238
+ _context7.next = 25;
6239
+ break;
6240
+ case 24:
6241
+ _context7.prev = 24;
6164
6242
  _t0 = _context7["catch"](3);
6165
6243
  if (failedAt === undefined) failedAt = 'submission';
6166
6244
  err = _t0;
@@ -6172,72 +6250,116 @@
6172
6250
  // UNLIKE sdk2 (`if (throwErrorsOnFailure) throw err`) there is no
6173
6251
  // catch-swallow path: rejection always propagates.
6174
6252
  throw err;
6175
- case 24:
6176
- _context7.prev = 24;
6177
- // Liveness tokens are single-use: clear after each submit so a stale
6178
- // token isn't reapplied on a retry (SubmissionProvider.tsx:1350).
6179
- livenessToken = undefined;
6253
+ case 25:
6254
+ _context7.prev = 25;
6180
6255
  endedAt = nowImpl();
6256
+ timings = buildSubmissionTimings({
6257
+ startedAt: startedAt,
6258
+ endedAt: endedAt,
6259
+ payloadBuildStart: payloadBuildStart,
6260
+ payloadBuildEnd: payloadBuildEnd,
6261
+ uploads: uploadMeasurements,
6262
+ apiCallStart: apiCallStart,
6263
+ apiCallEnd: apiCallEnd,
6264
+ responseParseStart: responseParseStart,
6265
+ responseParseEnd: responseParseEnd,
6266
+ failedAt: failedAt
6267
+ });
6181
6268
  store.setState({
6182
- lastSubmissionTimings: buildSubmissionTimings({
6183
- startedAt: startedAt,
6184
- endedAt: endedAt,
6185
- payloadBuildStart: payloadBuildStart,
6186
- payloadBuildEnd: payloadBuildEnd,
6187
- uploads: uploadMeasurements,
6188
- apiCallStart: apiCallStart,
6189
- apiCallEnd: apiCallEnd,
6190
- responseParseStart: responseParseStart,
6191
- responseParseEnd: responseParseEnd,
6192
- failedAt: failedAt
6193
- })
6269
+ lastSubmissionTimings: timings
6194
6270
  });
6195
- return _context7.finish(24);
6196
- case 25:
6271
+ return _context7.finish(25);
6272
+ case 26:
6273
+ if (kind === 'post' && built.response) {
6274
+ _built = built, _response = _built.response, _request = _built.request;
6275
+ notifySafely$1('onResponseReceived', function () {
6276
+ return config.onResponseReceived == null ? void 0 : config.onResponseReceived(_response, _request);
6277
+ });
6278
+ }
6279
+ return _context7.abrupt("return", _extends$1({}, built, {
6280
+ timings: timings
6281
+ }));
6282
+ case 27:
6197
6283
  case "end":
6198
6284
  return _context7.stop();
6199
6285
  }
6200
- }, _callee7, null, [[3, 23, 24, 25], [4, 6], [9, 20], [10, 12]]);
6286
+ }, _callee7, null, [[3, 24, 25, 26], [4, 6], [9, 20], [10, 12]]);
6287
+ }));
6288
+ return _runPipeline.apply(this, arguments);
6289
+ }
6290
+ function submit(artifacts, options) {
6291
+ return runPipeline(artifacts, options, 'submit').then(function (_ref2) {
6292
+ var response = _ref2.response;
6293
+ return response;
6294
+ });
6295
+ }
6296
+ function post(artifacts, options) {
6297
+ return runPipeline(artifacts, options, 'post');
6298
+ }
6299
+ function handoff(_x9, _x0) {
6300
+ return _handoff.apply(this, arguments);
6301
+ }
6302
+ function _handoff() {
6303
+ _handoff = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee8(artifacts, options) {
6304
+ var _yield$runPipeline, request, timings;
6305
+ return _regeneratorRuntime.wrap(function (_context8) {
6306
+ while (1) switch (_context8.prev = _context8.next) {
6307
+ case 0:
6308
+ _context8.next = 1;
6309
+ return runPipeline(artifacts, options, 'handoff');
6310
+ case 1:
6311
+ _yield$runPipeline = _context8.sent;
6312
+ request = _yield$runPipeline.request;
6313
+ timings = _yield$runPipeline.timings;
6314
+ return _context8.abrupt("return", {
6315
+ request: request,
6316
+ timings: timings
6317
+ });
6318
+ case 2:
6319
+ case "end":
6320
+ return _context8.stop();
6321
+ }
6322
+ }, _callee8);
6201
6323
  }));
6202
- return _submit.apply(this, arguments);
6324
+ return _handoff.apply(this, arguments);
6203
6325
  }
6204
- function checkLiveness(_x8, _x9) {
6326
+ function checkLiveness(_x1, _x10) {
6205
6327
  return _checkLiveness.apply(this, arguments);
6206
6328
  }
6207
6329
  function _checkLiveness() {
6208
- _checkLiveness = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee8(imageDataUrl, options) {
6330
+ _checkLiveness = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee9(imageDataUrl, options) {
6209
6331
  var _options$metadata$sel, _options$metadata, _options$metadata$idF, _options$metadata2, _options$metadata$idB, _options$metadata3, _options$metadata$bar, _options$metadata4, _options$metadata5, _options$metadata$geo, _options$metadata6, _livenessResponse$res, _livenessResponse$res2, selfie, request, _attachMetadataToRequ, attestationAttached, result, endpoint, sessionId, response, statusMessage, livenessResponse, _livenessResponse$res3, _livenessResponse$res4, err, _t1, _t10, _t11, _t12, _t13, _t14;
6210
- return _regeneratorRuntime.wrap(function (_context8) {
6211
- while (1) switch (_context8.prev = _context8.next) {
6332
+ return _regeneratorRuntime.wrap(function (_context9) {
6333
+ while (1) switch (_context9.prev = _context9.next) {
6212
6334
  case 0:
6213
6335
  if (options === void 0) {
6214
6336
  options = {};
6215
6337
  }
6216
- _context8.prev = 1;
6338
+ _context9.prev = 1;
6217
6339
  selfie = imageDataUrl;
6218
6340
  if (!(options.useDocumentServiceForLivenessChecks && documentServiceEnabled)) {
6219
- _context8.next = 6;
6341
+ _context9.next = 6;
6220
6342
  break;
6221
6343
  }
6222
6344
  if (!selfie.startsWith('data:')) {
6223
6345
  selfie = "data:image/jpeg;base64," + selfie;
6224
6346
  }
6225
- _context8.prev = 2;
6226
- _context8.next = 3;
6347
+ _context9.prev = 2;
6348
+ _context9.next = 3;
6227
6349
  return performUpload(dataUrlToBlob(selfie), withJobTaskMetadata({
6228
6350
  filename: 'liveness',
6229
6351
  filetype: 'image/jpeg'
6230
- }, options.jobID, options.taskID));
6352
+ }, options.jobID, options.taskID), currentRoute());
6231
6353
  case 3:
6232
- selfie = _context8.sent;
6233
- _context8.next = 5;
6354
+ selfie = _context9.sent;
6355
+ _context9.next = 5;
6234
6356
  break;
6235
6357
  case 4:
6236
- _context8.prev = 4;
6237
- _t1 = _context8["catch"](2);
6358
+ _context9.prev = 4;
6359
+ _t1 = _context9["catch"](2);
6238
6360
  throw new NetworkError(_t1 instanceof Error ? _t1.message : String(_t1));
6239
6361
  case 5:
6240
- _context8.next = 7;
6362
+ _context9.next = 7;
6241
6363
  break;
6242
6364
  case 6:
6243
6365
  selfie = dataUrlToBase64Sync$1(selfie);
@@ -6305,19 +6427,19 @@
6305
6427
  attestationAttached: attestationAttached
6306
6428
  });
6307
6429
  if (!config.onBeforeLivenessCheck) {
6308
- _context8.next = 9;
6430
+ _context9.next = 9;
6309
6431
  break;
6310
6432
  }
6311
- _context8.next = 8;
6433
+ _context9.next = 8;
6312
6434
  return config.onBeforeLivenessCheck(request);
6313
6435
  case 8:
6314
- result = _context8.sent;
6436
+ result = _context9.sent;
6315
6437
  if (result) request = result;
6316
6438
  case 9:
6317
6439
  endpoint = liveCheckEndpoint(!!options.idCardForFaceMatch);
6318
6440
  sessionId = store.getState().session.sessionId;
6319
- _context8.prev = 10;
6320
- _context8.next = 11;
6441
+ _context9.prev = 10;
6442
+ _context9.next = 11;
6321
6443
  return timedFetch(urls.submissionUrl + endpoint, {
6322
6444
  method: 'POST',
6323
6445
  // SubmissionProvider.tsx:1447 — sourced from the same
@@ -6328,36 +6450,36 @@
6328
6450
  body: JSON.stringify(request)
6329
6451
  });
6330
6452
  case 11:
6331
- response = _context8.sent;
6332
- _context8.next = 13;
6453
+ response = _context9.sent;
6454
+ _context9.next = 13;
6333
6455
  break;
6334
6456
  case 12:
6335
- _context8.prev = 12;
6336
- _t10 = _context8["catch"](10);
6457
+ _context9.prev = 12;
6458
+ _t10 = _context9["catch"](10);
6337
6459
  throw new NetworkError(_t10 instanceof Error ? _t10.message : String(_t10));
6338
6460
  case 13:
6339
6461
  if (response.ok) {
6340
- _context8.next = 18;
6462
+ _context9.next = 18;
6341
6463
  break;
6342
6464
  }
6343
6465
  if (!(response.status === 401 || response.status === 403)) {
6344
- _context8.next = 15;
6466
+ _context9.next = 15;
6345
6467
  break;
6346
6468
  }
6347
6469
  _t11 = AuthenticationError;
6348
6470
  _t12 = response.status;
6349
- _context8.next = 14;
6471
+ _context9.next = 14;
6350
6472
  return response.text();
6351
6473
  case 14:
6352
- _t13 = _context8.sent;
6474
+ _t13 = _context9.sent;
6353
6475
  throw new _t11(_t12, _t13);
6354
6476
  case 15:
6355
- _context8.next = 16;
6477
+ _context9.next = 16;
6356
6478
  return response.text();
6357
6479
  case 16:
6358
- statusMessage = _context8.sent;
6480
+ statusMessage = _context9.sent;
6359
6481
  if (!(!statusMessage || statusMessage === 'Load failed')) {
6360
- _context8.next = 17;
6482
+ _context9.next = 17;
6361
6483
  break;
6362
6484
  }
6363
6485
  throw new NetworkError(statusMessage);
@@ -6367,12 +6489,12 @@
6367
6489
  statusMessage: statusMessage
6368
6490
  });
6369
6491
  case 18:
6370
- _context8.next = 19;
6492
+ _context9.next = 19;
6371
6493
  return response.json();
6372
6494
  case 19:
6373
- livenessResponse = _context8.sent;
6495
+ livenessResponse = _context9.sent;
6374
6496
  if (!(livenessResponse.status.statusCode !== '000')) {
6375
- _context8.next = 20;
6497
+ _context9.next = 20;
6376
6498
  break;
6377
6499
  }
6378
6500
  throw new SubmissionError(livenessResponse.status);
@@ -6385,7 +6507,7 @@
6385
6507
  // unconditional here — a deliberate scope narrowing, not a silent drop.
6386
6508
  livenessToken = (_livenessResponse$res = livenessResponse.resultData) == null ? void 0 : _livenessResponse$res.livenessToken;
6387
6509
  if (!(options.softFail && !isLiveFaceConfirmed((_livenessResponse$res2 = livenessResponse.resultData) == null ? void 0 : _livenessResponse$res2.verificationResult))) {
6388
- _context8.next = 21;
6510
+ _context9.next = 21;
6389
6511
  break;
6390
6512
  }
6391
6513
  // Current sdk2 (SubmissionProvider.tsx checkLiveness): softFail also
@@ -6394,21 +6516,21 @@
6394
6516
  // non-live capture) and hand back a typed failure that still carries
6395
6517
  // the response so callers can read the detection flags.
6396
6518
  livenessToken = undefined;
6397
- return _context8.abrupt("return", {
6519
+ return _context9.abrupt("return", {
6398
6520
  ok: false,
6399
6521
  error: new Error("Liveness not confirmed: " + ((_livenessResponse$res3 = (_livenessResponse$res4 = livenessResponse.resultData) == null ? void 0 : _livenessResponse$res4.verificationResult) != null ? _livenessResponse$res3 : 'no verificationResult')),
6400
6522
  response: livenessResponse
6401
6523
  });
6402
6524
  case 21:
6403
- return _context8.abrupt("return", {
6525
+ return _context9.abrupt("return", {
6404
6526
  ok: true,
6405
6527
  response: livenessResponse
6406
6528
  });
6407
6529
  case 22:
6408
- _context8.prev = 22;
6409
- _t14 = _context8["catch"](1);
6530
+ _context9.prev = 22;
6531
+ _t14 = _context9["catch"](1);
6410
6532
  if (!options.softFail) {
6411
- _context8.next = 23;
6533
+ _context9.next = 23;
6412
6534
  break;
6413
6535
  }
6414
6536
  // Caller is treating this as a best-effort check. Don't surface the
@@ -6416,7 +6538,7 @@
6416
6538
  // typed failure result instead of sdk2's silent `undefined` (deliberate
6417
6539
  // divergence #3).
6418
6540
  livenessToken = undefined;
6419
- return _context8.abrupt("return", {
6541
+ return _context9.abrupt("return", {
6420
6542
  ok: false,
6421
6543
  error: _t14
6422
6544
  });
@@ -6430,32 +6552,32 @@
6430
6552
  throw err;
6431
6553
  case 24:
6432
6554
  case "end":
6433
- return _context8.stop();
6555
+ return _context9.stop();
6434
6556
  }
6435
- }, _callee8, null, [[1, 22], [2, 4], [10, 12]]);
6557
+ }, _callee9, null, [[1, 22], [2, 4], [10, 12]]);
6436
6558
  }));
6437
6559
  return _checkLiveness.apply(this, arguments);
6438
6560
  }
6439
- function clientUploadDocument(_x0, _x1) {
6561
+ function clientUploadDocument(_x11, _x12) {
6440
6562
  return _clientUploadDocument.apply(this, arguments);
6441
6563
  }
6442
6564
  function _clientUploadDocument() {
6443
- _clientUploadDocument = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee9(blob, metadata) {
6444
- return _regeneratorRuntime.wrap(function (_context9) {
6445
- while (1) switch (_context9.prev = _context9.next) {
6565
+ _clientUploadDocument = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee0(blob, metadata) {
6566
+ return _regeneratorRuntime.wrap(function (_context0) {
6567
+ while (1) switch (_context0.prev = _context0.next) {
6446
6568
  case 0:
6447
6569
  if (documentServiceEnabled) {
6448
- _context9.next = 1;
6570
+ _context0.next = 1;
6449
6571
  break;
6450
6572
  }
6451
6573
  throw new Error('document upload is disabled: no documentServiceUrl configured');
6452
6574
  case 1:
6453
- return _context9.abrupt("return", performUpload(blob, metadata != null ? metadata : {}));
6575
+ return _context0.abrupt("return", performUpload(blob, metadata != null ? metadata : {}, currentRoute()));
6454
6576
  case 2:
6455
6577
  case "end":
6456
- return _context9.stop();
6578
+ return _context0.stop();
6457
6579
  }
6458
- }, _callee9);
6580
+ }, _callee0);
6459
6581
  }));
6460
6582
  return _clientUploadDocument.apply(this, arguments);
6461
6583
  }
@@ -6471,6 +6593,8 @@
6471
6593
  validateSession: validateSessionMethod,
6472
6594
  retrySession: retrySession,
6473
6595
  submit: submit,
6596
+ post: post,
6597
+ handoff: handoff,
6474
6598
  checkLiveness: checkLiveness,
6475
6599
  uploadDocument: clientUploadDocument
6476
6600
  };
@@ -43973,7 +44097,9 @@
43973
44097
  onComplete = _ref.onComplete,
43974
44098
  onApproved = _ref.onApproved,
43975
44099
  onDenied = _ref.onDenied,
43976
- onRequestFailure = _ref.onRequestFailure;
44100
+ onSubmissionFailure = _ref.onSubmissionFailure,
44101
+ onRequestFailure = _ref.onRequestFailure,
44102
+ mode = _ref.mode;
43977
44103
  var progress = useCaptureObserver();
43978
44104
  var clientState = shimExports.useSyncExternalStore(client.subscribe, client.getState, client.getState);
43979
44105
  var _useAuthState = useAuthState(),
@@ -43986,10 +44112,22 @@
43986
44112
  _useState4 = _slicedToArray$1(_useState3, 2),
43987
44113
  localError = _useState4[0],
43988
44114
  setLocalError = _useState4[1];
43989
- var _useState5 = React.useState(false),
44115
+ var _useState5 = React.useState(IDLE_ATTEMPT),
43990
44116
  _useState6 = _slicedToArray$1(_useState5, 2),
43991
- resubmitting = _useState6[0],
43992
- setResubmitting = _useState6[1];
44117
+ attempt = _useState6[0],
44118
+ setAttempt = _useState6[1];
44119
+ // Which path the latest submission took. State is read from that path even
44120
+ // if `mode` changes while it is in flight; before any submission, `mode`
44121
+ // decides.
44122
+ var _useState7 = React.useState(null),
44123
+ _useState8 = _slicedToArray$1(_useState7, 2),
44124
+ startedExplicit = _useState8[0],
44125
+ setStartedExplicit = _useState8[1];
44126
+ var reportFailure = onSubmissionFailure != null ? onSubmissionFailure : onRequestFailure;
44127
+ var _useState9 = React.useState(false),
44128
+ _useState0 = _slicedToArray$1(_useState9, 2),
44129
+ resubmitting = _useState0[0],
44130
+ setResubmitting = _useState0[1];
43993
44131
  var lastArtifactsRef = React.useRef(null);
43994
44132
  var submitInFlightRef = React.useRef(null);
43995
44133
  var resubmitInFlightRef = React.useRef(null);
@@ -44007,6 +44145,71 @@
44007
44145
  }) : incoming;
44008
44146
  // Store the merged artifacts so a resubmit carries location too.
44009
44147
  lastArtifactsRef.current = artifacts;
44148
+ setStartedExplicit(mode !== undefined);
44149
+ if (mode !== undefined) {
44150
+ // Registered before anything customer-supplied runs, so a throw from
44151
+ // a notification can never leave the flow without a status.
44152
+ setAttempt(_extends$1({}, IDLE_ATTEMPT, {
44153
+ status: SubmissionStatus.SUBMITTING
44154
+ }));
44155
+ var _unbindProgress = bindSubmissionObserver(artifacts, progress);
44156
+ // The client call waits one microtask so the in-flight promise is
44157
+ // registered first: an `onSubmissionStarted` that calls `submit()`
44158
+ // gets this attempt back instead of starting a second one.
44159
+ var _promise = Promise.resolve().then(function () {
44160
+ return runAttempt(client, mode, artifacts, _extends$1({}, options, {
44161
+ action: action
44162
+ }));
44163
+ }).then(function (outcome) {
44164
+ setAttempt(_extends$1({}, outcome, {
44165
+ status: SubmissionStatus.SUBMITTED,
44166
+ error: null
44167
+ }));
44168
+ var response = outcome.response,
44169
+ request = outcome.request;
44170
+ if (response === null) {
44171
+ // Terminal once called; the handler is never awaited.
44172
+ if (typeof mode === 'object') {
44173
+ notifySafely('submitMode.handoff', function () {
44174
+ return mode.handoff(request);
44175
+ });
44176
+ }
44177
+ return null;
44178
+ }
44179
+ notifySafely('onComplete', function () {
44180
+ return onComplete == null ? void 0 : onComplete(response);
44181
+ });
44182
+ if (isApprovedResponse(action, response)) {
44183
+ notifySafely('onApproved', function () {
44184
+ return onApproved == null ? void 0 : onApproved(response);
44185
+ });
44186
+ } else {
44187
+ notifySafely('onDenied', function () {
44188
+ return onDenied == null ? void 0 : onDenied(response);
44189
+ });
44190
+ }
44191
+ return response;
44192
+ }, function (cause) {
44193
+ var error = cause instanceof Error ? cause : new Error(String(cause));
44194
+ setAttempt(_extends$1({}, IDLE_ATTEMPT, {
44195
+ status: SubmissionStatus.FAILED,
44196
+ error: error
44197
+ }));
44198
+ notifySafely('onSubmissionFailure', function () {
44199
+ return reportFailure == null ? void 0 : reportFailure(error);
44200
+ });
44201
+ throw error;
44202
+ })["finally"](function () {
44203
+ _unbindProgress();
44204
+ submitInFlightRef.current = null;
44205
+ setResubmitting(false);
44206
+ });
44207
+ submitInFlightRef.current = _promise;
44208
+ notifySafely('onSubmissionStarted', function () {
44209
+ return onSubmissionStarted == null ? void 0 : onSubmissionStarted(artifacts);
44210
+ });
44211
+ return _promise;
44212
+ }
44010
44213
  setSubmissionResponse(null);
44011
44214
  setLocalError(null);
44012
44215
  onSubmissionStarted == null || onSubmissionStarted(artifacts);
@@ -44027,7 +44230,7 @@
44027
44230
  })["catch"](function (cause) {
44028
44231
  var error = cause instanceof Error ? cause : new Error(String(cause));
44029
44232
  setLocalError(error);
44030
- onRequestFailure == null || onRequestFailure(error);
44233
+ reportFailure == null || reportFailure(error);
44031
44234
  throw error;
44032
44235
  })["finally"](function () {
44033
44236
  unbindProgress();
@@ -44036,7 +44239,7 @@
44036
44239
  });
44037
44240
  submitInFlightRef.current = promise;
44038
44241
  return promise;
44039
- }, [action, client, geolocation, onApproved, onComplete, onDenied, onRequestFailure, onSubmissionStarted, options, progress]);
44242
+ }, [action, client, geolocation, onApproved, onComplete, onDenied, reportFailure, onSubmissionStarted, options, progress, mode]);
44040
44243
  var resubmit = React.useMemo(function () {
44041
44244
  if (!authState.session.canRefreshSession) return null;
44042
44245
  return function () {
@@ -44081,22 +44284,120 @@
44081
44284
  }, [authState.session.canRefreshSession, client, submit]);
44082
44285
  var value = React.useMemo(function () {
44083
44286
  var _ref3, _clientState$lastSubm, _clientState$lastSubm2;
44287
+ if (startedExplicit != null ? startedExplicit : mode !== undefined) {
44288
+ return {
44289
+ action: action,
44290
+ submit: submit,
44291
+ submissionStatus: resubmitting ? SubmissionStatus.SUBMITTING : attempt.status,
44292
+ submissionResponse: attempt.response,
44293
+ submissionError: attempt.error,
44294
+ lastSubmissionTimings: attempt.timings,
44295
+ lastSubmissionRequest: attempt.request,
44296
+ resubmit: resubmit
44297
+ };
44298
+ }
44084
44299
  return {
44085
44300
  action: action,
44086
44301
  submit: submit,
44087
- submissionStatus: resubmitting ? SubmissionStatus.SUBMITTING : clientState.submissionStatus,
44302
+ // A rejection before the client records anything (an unsupported
44303
+ // action, an unvalidated session) leaves the client at READY, which the
44304
+ // wizard renders as its submitting screen; the local error is the
44305
+ // failure it would otherwise never show.
44306
+ submissionStatus: resubmitting ? SubmissionStatus.SUBMITTING : localError && clientState.submissionStatus === SubmissionStatus.READY ? SubmissionStatus.FAILED : clientState.submissionStatus,
44088
44307
  submissionResponse: submissionResponse,
44089
44308
  submissionError: (_ref3 = localError != null ? localError : clientState.submissionError) != null ? _ref3 : null,
44090
44309
  lastSubmissionTimings: (_clientState$lastSubm = clientState.lastSubmissionTimings) != null ? _clientState$lastSubm : null,
44091
44310
  lastSubmissionRequest: (_clientState$lastSubm2 = clientState.lastSubmissionRequest) != null ? _clientState$lastSubm2 : null,
44092
44311
  resubmit: resubmit
44093
44312
  };
44094
- }, [action, clientState.lastSubmissionRequest, clientState.lastSubmissionTimings, clientState.submissionError, clientState.submissionStatus, localError, resubmit, resubmitting, submissionResponse, submit]);
44313
+ }, [action, attempt, clientState.lastSubmissionRequest, clientState.lastSubmissionTimings, clientState.submissionError, clientState.submissionStatus, localError, mode, resubmit, resubmitting, startedExplicit, submissionResponse, submit]);
44095
44314
  return jsx(SubmissionContext.Provider, {
44096
44315
  value: value,
44097
44316
  children: children
44098
44317
  });
44099
44318
  }
44319
+ var IDLE_ATTEMPT = {
44320
+ status: SubmissionStatus.READY,
44321
+ response: null,
44322
+ request: null,
44323
+ timings: null,
44324
+ error: null
44325
+ };
44326
+ /**
44327
+ * One explicit-mode attempt through the client's `post()` or `handoff()`.
44328
+ * Never falls back to `submit()`: that would let the deprecated
44329
+ * `config.onSubmit` decide what an explicit mode already decided.
44330
+ */
44331
+ function runAttempt(_x, _x2, _x3, _x4) {
44332
+ return _runAttempt.apply(this, arguments);
44333
+ }
44334
+ function _runAttempt() {
44335
+ _runAttempt = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2(client, mode, artifacts, options) {
44336
+ var _yield$client$handoff, request, timings;
44337
+ return _regeneratorRuntime.wrap(function (_context2) {
44338
+ while (1) switch (_context2.prev = _context2.next) {
44339
+ case 0:
44340
+ if (!(mode === 'capture')) {
44341
+ _context2.next = 1;
44342
+ break;
44343
+ }
44344
+ throw new Error("submitMode 'capture' does not submit; the flow reports onCaptured instead");
44345
+ case 1:
44346
+ if (!(mode === 'post')) {
44347
+ _context2.next = 3;
44348
+ break;
44349
+ }
44350
+ if (client.post) {
44351
+ _context2.next = 2;
44352
+ break;
44353
+ }
44354
+ throw missingMethod('post', "submitMode 'post'");
44355
+ case 2:
44356
+ return _context2.abrupt("return", client.post(artifacts, options));
44357
+ case 3:
44358
+ if (client.handoff) {
44359
+ _context2.next = 4;
44360
+ break;
44361
+ }
44362
+ throw missingMethod('handoff', 'submitMode { handoff }');
44363
+ case 4:
44364
+ _context2.next = 5;
44365
+ return client.handoff(artifacts, options);
44366
+ case 5:
44367
+ _yield$client$handoff = _context2.sent;
44368
+ request = _yield$client$handoff.request;
44369
+ timings = _yield$client$handoff.timings;
44370
+ return _context2.abrupt("return", {
44371
+ request: request,
44372
+ timings: timings,
44373
+ response: null
44374
+ });
44375
+ case 6:
44376
+ case "end":
44377
+ return _context2.stop();
44378
+ }
44379
+ }, _callee2);
44380
+ }));
44381
+ return _runAttempt.apply(this, arguments);
44382
+ }
44383
+ function missingMethod(method, needs) {
44384
+ return new Error(needs + " needs client." + method + "(), which this client does not have. " + 'Create the client with createIdmissionClient or useIdmissionClient.');
44385
+ }
44386
+ /**
44387
+ * Runs a customer callback whose failure must not change an outcome that is
44388
+ * already settled: a throw or a rejected promise is logged, never rethrown.
44389
+ */
44390
+ function notifySafely(name, notify) {
44391
+ try {
44392
+ // `Promise.resolve`, not `instanceof Promise`: a promise from another
44393
+ // realm (an iframe) fails that check, and its rejection would go unhandled.
44394
+ Promise.resolve(notify())["catch"](function (e) {
44395
+ return warn$1(name + " rejected", e);
44396
+ });
44397
+ } catch (e) {
44398
+ warn$1(name + " threw", e);
44399
+ }
44400
+ }
44100
44401
  function useSubmission() {
44101
44402
  var context = React.useContext(SubmissionContext);
44102
44403
  if (!context) {
@@ -46802,11 +47103,12 @@
46802
47103
  }
46803
47104
 
46804
47105
  var _templateObject$2, _templateObject2$2, _templateObject3$1, _templateObject4$1;
46805
- var _excluded$9 = ["client", "action", "submission", "theme", "className", "geolocationEnabled", "geolocationRequired", "captureProgress", "remoteDiagnostics", "loadingSpinner", "showEnrollmentId", "lang", "children"];
47106
+ var _excluded$9 = ["client", "action", "submission", "submitMode", "theme", "className", "geolocationEnabled", "geolocationRequired", "captureProgress", "remoteDiagnostics", "loadingSpinner", "showEnrollmentId", "lang", "children"];
46806
47107
  function FlowChassis(_ref) {
46807
47108
  var client = _ref.client,
46808
47109
  action = _ref.action,
46809
47110
  submission = _ref.submission,
47111
+ submitMode = _ref.submitMode,
46810
47112
  _ref$theme = _ref.theme,
46811
47113
  theme = _ref$theme === void 0 ? 'default' : _ref$theme,
46812
47114
  className = _ref.className,
@@ -46839,6 +47141,7 @@
46839
47141
  client: client,
46840
47142
  action: action,
46841
47143
  options: submission,
47144
+ mode: submitMode,
46842
47145
  geolocation: geolocation.position
46843
47146
  }, callbacks, {
46844
47147
  children: jsx(FlowPage, {
@@ -47159,7 +47462,7 @@
47159
47462
  return base;
47160
47463
  }
47161
47464
 
47162
- var _excluded$8 = ["client", "controller", "capture", "view", "submission", "initialArtifacts", "captureOnly", "signatureController", "signatureCapture", "signatureView", "captureSignature", "captureSignatureVideo", "allowVirtualCameras", "theme", "className", "lang", "debugMode", "skipSuccessScreen", "showResultScreen", "showSuccessScreen", "showDiagnostics", "captureAdditionalDocuments", "additionalDocumentClassNames", "additionalDocumentVerbiage", "ringScreenClassNames", "ringScreenVerbiage", "onCaptured", "onSubmitted", "children"];
47465
+ var _excluded$8 = ["client", "controller", "capture", "view", "submission", "initialArtifacts", "submitMode", "captureOnly", "signatureController", "signatureCapture", "signatureView", "captureSignature", "captureSignatureVideo", "allowVirtualCameras", "theme", "className", "lang", "debugMode", "skipSuccessScreen", "showResultScreen", "showSuccessScreen", "showDiagnostics", "captureAdditionalDocuments", "additionalDocumentClassNames", "additionalDocumentVerbiage", "ringScreenClassNames", "ringScreenVerbiage", "onCaptured", "onSubmitted", "children"];
47163
47466
  var EMPTY_ID_CAPTURE$3 = {};
47164
47467
  var EMPTY_SIGNATURE_CAPTURE$5 = {};
47165
47468
  var EMPTY_ID_VIEW$3 = {};
@@ -47176,8 +47479,8 @@
47176
47479
  submission = _ref$submission === void 0 ? EMPTY_SUBMISSION$6 : _ref$submission,
47177
47480
  _ref$initialArtifacts = _ref.initialArtifacts,
47178
47481
  initialArtifacts = _ref$initialArtifacts === void 0 ? EMPTY_ARTIFACTS$9 : _ref$initialArtifacts,
47179
- _ref$captureOnly = _ref.captureOnly,
47180
- captureOnly = _ref$captureOnly === void 0 ? false : _ref$captureOnly,
47482
+ submitMode = _ref.submitMode,
47483
+ captureOnly = _ref.captureOnly,
47181
47484
  signatureController = _ref.signatureController,
47182
47485
  _ref$signatureCapture = _ref.signatureCapture,
47183
47486
  signatureCapture = _ref$signatureCapture === void 0 ? EMPTY_SIGNATURE_CAPTURE$5 : _ref$signatureCapture,
@@ -47336,10 +47639,12 @@
47336
47639
  successIssuerCaptionText: 'confirmed'
47337
47640
  }
47338
47641
  });
47642
+ var mode = submitMode != null ? submitMode : captureOnly ? 'capture' : undefined;
47339
47643
  return jsxs(FlowChassis, _extends$1({
47340
47644
  client: client,
47341
47645
  action: SubmissionAction.VALIDATE,
47342
47646
  submission: submission,
47647
+ submitMode: mode,
47343
47648
  theme: theme,
47344
47649
  className: className,
47345
47650
  lang: lang
@@ -47347,7 +47652,7 @@
47347
47652
  children: [jsx(CompositeWizard, _extends$1({}, ringScreens, {
47348
47653
  steps: steps,
47349
47654
  initialArtifacts: initialArtifacts,
47350
- captureOnly: captureOnly,
47655
+ captureOnly: mode === 'capture',
47351
47656
  showResultScreen: showResultScreen != null ? showResultScreen : showSuccessScreen,
47352
47657
  showDiagnostics: showDiagnostics,
47353
47658
  onArtifactsCollected: onCaptured,
@@ -47807,6 +48112,10 @@
47807
48112
  captureProgress = _ref.captureProgress,
47808
48113
  remoteDiagnostics = _ref.remoteDiagnostics,
47809
48114
  loadingSpinner = _ref.loadingSpinner,
48115
+ _ref$submitMode = _ref.submitMode,
48116
+ submitMode = _ref$submitMode === void 0 ? 'capture' : _ref$submitMode,
48117
+ onSubmissionStarted = _ref.onSubmissionStarted,
48118
+ onSubmissionFailure = _ref.onSubmissionFailure,
47810
48119
  onCaptured = _ref.onCaptured,
47811
48120
  onCaptureError = _ref.onCaptureError;
47812
48121
  // Flow-wide settings reach each step unless its own bag sets them.
@@ -48002,13 +48311,21 @@
48002
48311
  resolvedSelfieController.actions.retry();
48003
48312
  setStage('face-liveness');
48004
48313
  }, [resolvedSelfieController]);
48314
+ // Lives here, above the chassis's session gate: a session error unmounts
48315
+ // and remounts `SignatureHandoff`, and must not start the hand-off again.
48316
+ var handoffStartedRef = React.useRef(false);
48317
+ var claimHandoffStart = React.useCallback(function () {
48318
+ if (handoffStartedRef.current) return false;
48319
+ handoffStartedRef.current = true;
48320
+ return true;
48321
+ }, []);
48005
48322
  var handleSignatureCompleted = React.useCallback(function (artifacts) {
48006
48323
  if (completedRef.current) return;
48007
48324
  completedRef.current = true;
48008
48325
  artifactsRef.current = mergeSubmissionArtifacts(artifactsRef.current, artifacts);
48009
48326
  setStage('complete');
48010
- onCaptured == null || onCaptured(artifactsRef.current);
48011
- }, [onCaptured]);
48327
+ if (submitMode === 'capture') onCaptured == null || onCaptured(artifactsRef.current);
48328
+ }, [onCaptured, submitMode]);
48012
48329
  var handleLivenessFailureExit = React.useCallback(function () {
48013
48330
  onExitAfterLivenessFailure == null || onExitAfterLivenessFailure();
48014
48331
  if (allowSignatureAfterLivenessCheckFailure) handleLivenessDone();
@@ -48017,6 +48334,9 @@
48017
48334
  client: client,
48018
48335
  action: SubmissionAction.NONE,
48019
48336
  submission: submission,
48337
+ submitMode: submitMode,
48338
+ onSubmissionStarted: onSubmissionStarted,
48339
+ onSubmissionFailure: onSubmissionFailure,
48020
48340
  theme: theme,
48021
48341
  className: className,
48022
48342
  lang: lang,
@@ -48026,8 +48346,11 @@
48026
48346
  remoteDiagnostics: remoteDiagnostics,
48027
48347
  loadingSpinner: loadingSpinner,
48028
48348
  children: [jsx(CaptureProgressCompletion, {
48029
- completed: stage === 'complete'
48030
- }), stage !== 'complete' ? jsxs(HandoffRoot, {
48349
+ completed: stage === 'complete' && submitMode === 'capture'
48350
+ }), stage === 'complete' && submitMode !== 'capture' ? jsx(SignatureHandoff, {
48351
+ artifacts: artifactsRef.current,
48352
+ claimStart: claimHandoffStart
48353
+ }) : null, stage !== 'complete' ? jsxs(HandoffRoot, {
48031
48354
  children: [jsx(SignatureCaptureView, _extends$1({}, signatureView, {
48032
48355
  skipSuccessScreen: impliedSkipSuccessScreen(signatureView.skipSuccessScreen, isRingIntroActive(faceView)),
48033
48356
  controller: resolvedSignatureController,
@@ -48077,6 +48400,43 @@
48077
48400
  }) : null]
48078
48401
  });
48079
48402
  }
48403
+ /**
48404
+ * Hands the finished capture off once the session has passed: a finishing
48405
+ * screen while the request is built, a retry screen if that fails, and
48406
+ * nothing once it has been handed off.
48407
+ */
48408
+ function SignatureHandoff(_ref3) {
48409
+ var artifacts = _ref3.artifacts,
48410
+ claimStart = _ref3.claimStart;
48411
+ var _useSubmission = useSubmission(),
48412
+ action = _useSubmission.action,
48413
+ submit = _useSubmission.submit,
48414
+ submissionStatus = _useSubmission.submissionStatus,
48415
+ submissionError = _useSubmission.submissionError;
48416
+ var sessionReady = useSessionReady();
48417
+ // The provider reports a failure itself; these catches only keep the
48418
+ // rejection from going unhandled.
48419
+ React.useEffect(function () {
48420
+ if (!sessionReady || !claimStart()) return;
48421
+ submit(artifacts)["catch"](function () {});
48422
+ }, [artifacts, claimStart, sessionReady, submit]);
48423
+ if (submissionStatus === SubmissionStatus.SUBMITTED) return null;
48424
+ if (submissionStatus === SubmissionStatus.FAILED) {
48425
+ return jsx(SubmissionErrorOverlay, {
48426
+ error: submissionError,
48427
+ onRetry: function onRetry() {
48428
+ submit(artifacts)["catch"](function () {});
48429
+ }
48430
+ });
48431
+ }
48432
+ var text = submissionStatusText(action, artifacts);
48433
+ return jsx(OrbStatusScreen, {
48434
+ state: "working",
48435
+ text: text,
48436
+ accessibleLabel: text,
48437
+ loadingStage: "submission"
48438
+ });
48439
+ }
48080
48440
  /**
48081
48441
  * Black, so iOS Safari's bars read as letterboxing around the camera feed
48082
48442
  * rather than as one more colour a theme has to choose.
@@ -48094,10 +48454,10 @@
48094
48454
  * no flat strip can sit on its bottom edge unseen: that one is drawn invisibly,
48095
48455
  * as on ID capture's overlay. Opaque, it covered the bottom 12px of the bar.
48096
48456
  */
48097
- function FlowEdgeTint(_ref3) {
48457
+ function FlowEdgeTint(_ref4) {
48098
48458
  var _theme$selfieCapture$, _theme$selfieCapture, _theme$background;
48099
- var surface = _ref3.surface,
48100
- modelsReady = _ref3.modelsReady;
48459
+ var surface = _ref4.surface,
48460
+ modelsReady = _ref4.modelsReady;
48101
48461
  var theme = useTheme();
48102
48462
  if (theme.isFullscreen === false || surface === null) return null;
48103
48463
  var color = opaqueColor(surface === 'camera' ? CAMERA_EDGE_COLOR : surface === 'overlay' ? (_theme$selfieCapture$ = (_theme$selfieCapture = theme.selfieCapture) == null || (_theme$selfieCapture = _theme$selfieCapture.loadingOverlay) == null ? void 0 : _theme$selfieCapture.backgroundColor) != null ? _theme$selfieCapture$ : SELFIE_LOADING_OVERLAY_BACKGROUND_DEFAULT : (_theme$background = theme.background) != null ? _theme$background : '#fff');
@@ -48107,9 +48467,9 @@
48107
48467
  hiddenBottomColor: surface === 'overlay' ? selfieLoadingOverlayBottomEdgeColor(theme, modelsReady) : undefined
48108
48468
  });
48109
48469
  }
48110
- function SelfieTrackerAttachment(_ref4) {
48111
- var controller = _ref4.controller,
48112
- video = _ref4.video;
48470
+ function SelfieTrackerAttachment(_ref5) {
48471
+ var controller = _ref5.controller,
48472
+ video = _ref5.video;
48113
48473
  React.useEffect(function () {
48114
48474
  if (!video) return;
48115
48475
  void controller.attach(video)["catch"](function () {
@@ -48127,7 +48487,7 @@
48127
48487
  return props.$visible ? 'block' : 'none';
48128
48488
  });
48129
48489
 
48130
- var _excluded$4 = ["client", "idController", "selfieController", "controller", "idCapture", "faceCapture", "capture", "idView", "faceView", "view", "submission", "initialArtifacts", "captureOnly", "signatureController", "signatureCapture", "signatureView", "captureSignature", "captureSignatureVideo", "allowVirtualCameras", "skipIdCapture", "matchOnly", "readTextPrompt", "onMicrophoneAccessDenied", "theme", "className", "lang", "debugMode", "skipSuccessScreen", "showResultScreen", "showSuccessScreen", "showDiagnostics", "captureAdditionalDocuments", "additionalDocumentClassNames", "additionalDocumentVerbiage", "ringScreenClassNames", "ringScreenVerbiage", "onCaptured", "onSubmitted", "onCaptureError", "children"],
48490
+ var _excluded$4 = ["client", "idController", "selfieController", "controller", "idCapture", "faceCapture", "capture", "idView", "faceView", "view", "submission", "initialArtifacts", "submitMode", "captureOnly", "signatureController", "signatureCapture", "signatureView", "captureSignature", "captureSignatureVideo", "allowVirtualCameras", "skipIdCapture", "matchOnly", "readTextPrompt", "onMicrophoneAccessDenied", "theme", "className", "lang", "debugMode", "skipSuccessScreen", "showResultScreen", "showSuccessScreen", "showDiagnostics", "captureAdditionalDocuments", "additionalDocumentClassNames", "additionalDocumentVerbiage", "ringScreenClassNames", "ringScreenVerbiage", "onCaptured", "onSubmitted", "onCaptureError", "children"],
48131
48491
  _excluded2$2 = ["checkLivenessOptions"];
48132
48492
  var EMPTY_ID_CAPTURE$1 = {};
48133
48493
  var EMPTY_FACE_CAPTURE$2 = {};
@@ -48160,8 +48520,8 @@
48160
48520
  submission = _ref$submission === void 0 ? EMPTY_SUBMISSION$2 : _ref$submission,
48161
48521
  _ref$initialArtifacts = _ref.initialArtifacts,
48162
48522
  initialArtifacts = _ref$initialArtifacts === void 0 ? EMPTY_ARTIFACTS$5 : _ref$initialArtifacts,
48163
- _ref$captureOnly = _ref.captureOnly,
48164
- captureOnly = _ref$captureOnly === void 0 ? false : _ref$captureOnly,
48523
+ submitMode = _ref.submitMode,
48524
+ captureOnly = _ref.captureOnly,
48165
48525
  signatureController = _ref.signatureController,
48166
48526
  _ref$signatureCapture = _ref.signatureCapture,
48167
48527
  signatureCapture = _ref$signatureCapture === void 0 ? EMPTY_SIGNATURE_CAPTURE$2 : _ref$signatureCapture,
@@ -48379,10 +48739,12 @@
48379
48739
  successIssuerCaptionText: 'confirmed'
48380
48740
  }
48381
48741
  });
48742
+ var mode = submitMode != null ? submitMode : captureOnly ? 'capture' : undefined;
48382
48743
  return jsxs(FlowChassis, _extends$1({
48383
48744
  client: client,
48384
48745
  action: action,
48385
48746
  submission: submission,
48747
+ submitMode: mode,
48386
48748
  theme: theme,
48387
48749
  className: className,
48388
48750
  lang: lang
@@ -48390,7 +48752,7 @@
48390
48752
  children: [jsx(CompositeWizard, _extends$1({}, ringScreens, {
48391
48753
  steps: steps,
48392
48754
  initialArtifacts: initialArtifacts,
48393
- captureOnly: captureOnly,
48755
+ captureOnly: mode === 'capture',
48394
48756
  showResultScreen: showResultScreen != null ? showResultScreen : showSuccessScreen,
48395
48757
  showDiagnostics: showDiagnostics,
48396
48758
  onArtifactsCollected: onCaptured,
@@ -52601,7 +52963,9 @@
52601
52963
  onComplete = _ref.onComplete,
52602
52964
  onCustomerMatched = _ref.onCustomerMatched,
52603
52965
  onCustomerNotMatched = _ref.onCustomerNotMatched,
52966
+ onSubmissionFailure = _ref.onSubmissionFailure,
52604
52967
  onRequestFailure = _ref.onRequestFailure,
52968
+ submitMode = _ref.submitMode,
52605
52969
  onCaptureGuidanceTimeout = _ref.onCaptureGuidanceTimeout,
52606
52970
  onExitCapture = _ref.onExitCapture,
52607
52971
  onExitAfterFailure = _ref.onExitAfterFailure;
@@ -52688,15 +53052,19 @@
52688
53052
  setOutcome('notMatched');
52689
53053
  onCustomerNotMatched == null || onCustomerNotMatched(response);
52690
53054
  }, [onCustomerNotMatched]);
53055
+ var reportFailure = onSubmissionFailure != null ? onSubmissionFailure : onRequestFailure;
52691
53056
  var handleLivenessCheckFailed = React.useCallback(function (error) {
52692
53057
  setOutcome('failed');
52693
- onRequestFailure == null || onRequestFailure(error);
52694
- }, [onRequestFailure]);
53058
+ reportFailure == null || reportFailure(error);
53059
+ }, [reportFailure]);
52695
53060
  var handleRequestError = React.useCallback(function (error) {
52696
53061
  errorRef.current = error;
52697
53062
  setOutcome('error');
52698
- onRequestFailure == null || onRequestFailure(error);
52699
- }, [onRequestFailure]);
53063
+ reportFailure == null || reportFailure(error);
53064
+ }, [reportFailure]);
53065
+ var handleHandedOff = React.useCallback(function () {
53066
+ return setOutcome('handedOff');
53067
+ }, []);
52700
53068
  var handleCaptureGuidanceTimeout = React.useCallback(function () {
52701
53069
  setOutcome('failed');
52702
53070
  onCaptureGuidanceTimeout == null || onCaptureGuidanceTimeout();
@@ -52737,6 +53105,7 @@
52737
53105
  client: client,
52738
53106
  action: action,
52739
53107
  submission: submission,
53108
+ submitMode: submitMode,
52740
53109
  theme: theme,
52741
53110
  className: className,
52742
53111
  lang: lang,
@@ -52761,6 +53130,7 @@
52761
53130
  onNotMatched: handleNotMatched,
52762
53131
  onLivenessCheckFailed: handleLivenessCheckFailed,
52763
53132
  onRequestError: handleRequestError,
53133
+ onSubmissionIntercepted: handleHandedOff,
52764
53134
  onCaptureGuidanceTimeout: handleCaptureGuidanceTimeout,
52765
53135
  onExitCapture: onExitCapture,
52766
53136
  finishingScreen: {
@@ -52896,6 +53266,84 @@
52896
53266
  return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
52897
53267
  };
52898
53268
 
53269
+ function createIdAndFaceValidationJourneyEvent(event, now) {
53270
+ if (now === void 0) {
53271
+ now = function now() {
53272
+ return new Date();
53273
+ };
53274
+ }
53275
+ return _assign(_assign({}, event), {
53276
+ version: 1,
53277
+ flow: 'id-and-face-validation',
53278
+ timestamp: now().toISOString()
53279
+ });
53280
+ }
53281
+ /**
53282
+ * websdk-ui `CompositeWizardStep.id` -> journey stage.
53283
+ *
53284
+ * Four of the five stage names ARE step ids already; only the additional-
53285
+ * documents step differs, because sdk2's stage vocabulary says
53286
+ * `additional-document-capture` (singular "document") while websdk-ui's step
53287
+ * is `additional-documents`. Unknown ids return undefined so a step this
53288
+ * vocabulary has no name for is silently skipped rather than emitted with a
53289
+ * bogus stage — the same shape as sdk2's partial lookup record.
53290
+ */
53291
+ function journeyStageForStepId(stepId) {
53292
+ switch (stepId) {
53293
+ case 'id-capture':
53294
+ case 'face-liveness':
53295
+ case 'signature-capture':
53296
+ case 'video-signature-capture':
53297
+ return stepId;
53298
+ case 'additional-documents':
53299
+ return 'additional-document-capture';
53300
+ default:
53301
+ return undefined;
53302
+ }
53303
+ }
53304
+ /**
53305
+ * The document types sdk2 reports as `document.captured`. sdk2 filters the
53306
+ * wizard's `onDocumentStored` through this set (`primaryIdDocumentTypes`) so
53307
+ * that a document type outside the journey vocabulary cannot widen the event.
53308
+ * Kept as a predicate rather than a Set: the ES5 UMD bundle target makes
53309
+ * `for..of` over a Set a downlevel hazard, and a switch needs no iteration.
53310
+ */
53311
+ function isJourneyDocumentType(documentType) {
53312
+ return documentType === 'idCardFront' || documentType === 'idCardBack' || documentType === 'passport' || documentType === 'singlePage';
53313
+ }
53314
+ /**
53315
+ * The lazy `flow.started` rule, lifted out of sdk2's `emitJourneyEvent`
53316
+ * closure (IdAndFaceValidation.tsx:521-537) so it can be tested without a
53317
+ * React tree.
53318
+ *
53319
+ * sdk2 does NOT simply emit `flow.started` from a mount effect: it emits it
53320
+ * before the FIRST event of any kind, whatever that event is, and then
53321
+ * suppresses the explicit mount emit. The mount effect and the lazy guard
53322
+ * together mean `flow.started` is always the first event a customer sees,
53323
+ * even if some other event races the effect. That ordering guarantee is the
53324
+ * contract, not the effect.
53325
+ */
53326
+ function createJourneyEmitter(callback, now) {
53327
+ var flowStartedEmitted = false;
53328
+ return function emit(event) {
53329
+ if (!callback) return;
53330
+ if (!flowStartedEmitted) {
53331
+ flowStartedEmitted = true;
53332
+ emitWith(callback, {
53333
+ name: 'flow.started'
53334
+ }, now);
53335
+ }
53336
+ if (event.name !== 'flow.started') emitWith(callback, event, now);
53337
+ };
53338
+ }
53339
+ function emitWith(callback, event, now) {
53340
+ try {
53341
+ callback(createIdAndFaceValidationJourneyEvent(event, now));
53342
+ } catch (error) {
53343
+ warn$2('[IdAndFaceValidation] onJourneyEvent callback failed', error);
53344
+ }
53345
+ }
53346
+
52899
53347
  /**
52900
53348
  * sdk2 exports this as a mutable `string[]`
52901
53349
  * (contexts/AuthStateContext.tsx:25), not a readonly tuple — copied rather
@@ -53068,12 +53516,9 @@
53068
53516
  documentServiceUrl: (_b = props.documentServiceUrl) !== null && _b !== void 0 ? _b : apiBase ? apiBase + '/files/' : override === null || override === void 0 ? void 0 : override.documentServiceUrl,
53069
53517
  onBeforeSubmit: props.onBeforeSubmit,
53070
53518
  onBeforeLivenessCheck: props.onBeforeLivenessCheck,
53071
- // Straight through to the client, which is where sdk2 put it too
53072
- // (SubmissionProvider.submit). That is what makes the SUPPRESSION uniform:
53073
- // every flow — including the two match flows, which own their own stage
53074
- // machine — submits through this one client, so none of them can post
53075
- // behind an integrator who supplied `onSubmit`.
53076
- onSubmit: props.onSubmit,
53519
+ // 2.x's `onSubmit` is not a client option here: each flow maps it to its
53520
+ // own `submitMode: { handoff }` (see ./props.ts), which follows the prop
53521
+ // live where a client option would be fixed at mount.
53077
53522
  onBeforeDocumentUpload: props.onBeforeDocumentUpload,
53078
53523
  onDocumentUploadProgress: props.onDocumentUploadProgress,
53079
53524
  onDocumentUploaded: props.onDocumentUploaded,
@@ -54083,84 +54528,6 @@
54083
54528
  };
54084
54529
  }
54085
54530
 
54086
- function createIdAndFaceValidationJourneyEvent(event, now) {
54087
- if (now === void 0) {
54088
- now = function now() {
54089
- return new Date();
54090
- };
54091
- }
54092
- return _assign(_assign({}, event), {
54093
- version: 1,
54094
- flow: 'id-and-face-validation',
54095
- timestamp: now().toISOString()
54096
- });
54097
- }
54098
- /**
54099
- * websdk-ui `CompositeWizardStep.id` -> journey stage.
54100
- *
54101
- * Four of the five stage names ARE step ids already; only the additional-
54102
- * documents step differs, because sdk2's stage vocabulary says
54103
- * `additional-document-capture` (singular "document") while websdk-ui's step
54104
- * is `additional-documents`. Unknown ids return undefined so a step this
54105
- * vocabulary has no name for is silently skipped rather than emitted with a
54106
- * bogus stage — the same shape as sdk2's partial lookup record.
54107
- */
54108
- function journeyStageForStepId(stepId) {
54109
- switch (stepId) {
54110
- case 'id-capture':
54111
- case 'face-liveness':
54112
- case 'signature-capture':
54113
- case 'video-signature-capture':
54114
- return stepId;
54115
- case 'additional-documents':
54116
- return 'additional-document-capture';
54117
- default:
54118
- return undefined;
54119
- }
54120
- }
54121
- /**
54122
- * The document types sdk2 reports as `document.captured`. sdk2 filters the
54123
- * wizard's `onDocumentStored` through this set (`primaryIdDocumentTypes`) so
54124
- * that a document type outside the journey vocabulary cannot widen the event.
54125
- * Kept as a predicate rather than a Set: the ES5 UMD bundle target makes
54126
- * `for..of` over a Set a downlevel hazard, and a switch needs no iteration.
54127
- */
54128
- function isJourneyDocumentType(documentType) {
54129
- return documentType === 'idCardFront' || documentType === 'idCardBack' || documentType === 'passport' || documentType === 'singlePage';
54130
- }
54131
- /**
54132
- * The lazy `flow.started` rule, lifted out of sdk2's `emitJourneyEvent`
54133
- * closure (IdAndFaceValidation.tsx:521-537) so it can be tested without a
54134
- * React tree.
54135
- *
54136
- * sdk2 does NOT simply emit `flow.started` from a mount effect: it emits it
54137
- * before the FIRST event of any kind, whatever that event is, and then
54138
- * suppresses the explicit mount emit. The mount effect and the lazy guard
54139
- * together mean `flow.started` is always the first event a customer sees,
54140
- * even if some other event races the effect. That ordering guarantee is the
54141
- * contract, not the effect.
54142
- */
54143
- function createJourneyEmitter(callback, now) {
54144
- var flowStartedEmitted = false;
54145
- return function emit(event) {
54146
- if (!callback) return;
54147
- if (!flowStartedEmitted) {
54148
- flowStartedEmitted = true;
54149
- emitWith(callback, {
54150
- name: 'flow.started'
54151
- }, now);
54152
- }
54153
- if (event.name !== 'flow.started') emitWith(callback, event, now);
54154
- };
54155
- }
54156
- function emitWith(callback, event, now) {
54157
- try {
54158
- callback(createIdAndFaceValidationJourneyEvent(event, now));
54159
- } catch (error) {
54160
- warn$2('[IdAndFaceValidation] onJourneyEvent callback failed', error);
54161
- }
54162
- }
54163
-
54164
54531
  /**
54165
54532
  * Recursively drops keys whose value is exactly `undefined`.
54166
54533
  *
@@ -54343,6 +54710,16 @@
54343
54710
  return mergeThemes(mapped, overrides);
54344
54711
  }
54345
54712
 
54713
+ /**
54714
+ * 2.x's `onSubmit` as the flow's hand-off. sdk2 read it on every submission,
54715
+ * so this maps on every render: adding or removing it takes effect from the
54716
+ * next submission. Without it the flow posts.
54717
+ */
54718
+ function mapHandoff(onSubmit) {
54719
+ return onSubmit ? {
54720
+ handoff: onSubmit
54721
+ } : undefined;
54722
+ }
54346
54723
  var EMPTY_CONTEXT = {};
54347
54724
  /** Adapts a 3.0 `(response)` callback back to 2.x's `(response, request)`. */
54348
54725
  function withSubmissionRequest(callback, ctx) {
@@ -54434,13 +54811,13 @@
54434
54811
  }
54435
54812
  // --- 1. IdValidation ------------------------------------------------------
54436
54813
  function mapIdValidationProps(props, ctx) {
54437
- var _a;
54814
+ var _a, _b;
54438
54815
  if (ctx === void 0) {
54439
54816
  ctx = EMPTY_CONTEXT;
54440
54817
  }
54441
- var _b = mapIdCapture(props),
54442
- capture = _b.capture,
54443
- view = _b.view;
54818
+ var _c = mapIdCapture(props),
54819
+ capture = _c.capture,
54820
+ view = _c.view;
54444
54821
  return compact({
54445
54822
  capture: capture,
54446
54823
  view: view,
@@ -54466,9 +54843,8 @@
54466
54843
  // `onSubmit` WINS over capture-only, matching sdk2's ordering: its
54467
54844
  // `submit()` checks `onSubmit` before the `action === NONE` branch
54468
54845
  // (SubmissionProvider.tsx:1374 vs :1237), so a capture-only flow still
54469
- // owes the callback its built request. Letting the flow run its normal
54470
- // submit path is what builds that request; the client suppresses the POST.
54471
- captureOnly: props.onSubmit ? undefined : props.captureOnly,
54846
+ // owes the callback its built request.
54847
+ submitMode: (_b = mapHandoff(props.onSubmit)) !== null && _b !== void 0 ? _b : props.captureOnly ? 'capture' : undefined,
54472
54848
  captureAdditionalDocuments: props.captureAdditionalDocuments,
54473
54849
  geolocationEnabled: props.geolocationEnabled,
54474
54850
  geolocationRequired: props.geolocationRequired,
@@ -54489,13 +54865,10 @@
54489
54865
  // would be a NEW restriction, not parity.
54490
54866
  showResultScreen: props.debugMode,
54491
54867
  showDiagnostics: props.debugMode,
54492
- // `onSubmit` is NOT mapped to a flow prop: it goes to the client config
54493
- // (see mapClientConfig), which is the layer sdk2 put it at and the only
54494
- // one that can suppress the POST for every flow at once.
54495
54868
  onComplete: withSubmissionRequest(props.onComplete, ctx),
54496
54869
  onApproved: withSubmissionRequest(props.onApproved, ctx),
54497
54870
  onDenied: withSubmissionRequest(props.onDenied, ctx),
54498
- onRequestFailure: props.onRequestFailure
54871
+ onSubmissionFailure: props.onRequestFailure
54499
54872
  });
54500
54873
  }
54501
54874
  // --- 2. FaceValidation ----------------------------------------------------
@@ -54687,7 +55060,8 @@
54687
55060
  onComplete: withSubmissionRequest(props.onComplete, ctx),
54688
55061
  onApproved: withSubmissionRequest(props.onApproved, ctx),
54689
55062
  onDenied: withSubmissionRequest(props.onDenied, ctx),
54690
- onRequestFailure: props.onRequestFailure,
55063
+ submitMode: mapHandoff(props.onSubmit),
55064
+ onSubmissionFailure: props.onRequestFailure,
54691
55065
  onCaptureError: props.onRequestFailure
54692
55066
  });
54693
55067
  }
@@ -54842,10 +55216,11 @@
54842
55216
  captureProgress: props.captureProgress,
54843
55217
  remoteDiagnostics: props.remoteDiagnostics,
54844
55218
  loadingSpinner: props.loadingSpinner,
54845
- // `onCaptured` is supplied by the COMPONENT, not here: this flow never
54846
- // enters `client.submit()` on its own, so the façade makes that call from
54847
- // `onCaptured` to produce the same built request 2.x hands over. See
54848
- // components/flows.tsx.
55219
+ // 2.x builds this flow's request and hands it to `onSubmit`
55220
+ // (SubmissionProvider.tsx:1374, ahead of its NONE branch). Unset, the
55221
+ // flow captures and posts nothing, as 2.x's NONE did. A failed hand-off
55222
+ // is not reported to `onRequestFailure`, which 2.x never did either.
55223
+ submitMode: mapHandoff(props.onSubmit),
54849
55224
  onCaptureError: props.onRequestFailure
54850
55225
  });
54851
55226
  }
@@ -54871,7 +55246,7 @@
54871
55246
  return map(nested);
54872
55247
  }
54873
55248
  function mapVideoIdValidationProps(props, ctx) {
54874
- var _a, _b, _c;
55249
+ var _a, _b, _c, _d;
54875
55250
  if (ctx === void 0) {
54876
55251
  ctx = EMPTY_CONTEXT;
54877
55252
  }
@@ -54964,7 +55339,11 @@
54964
55339
  showResultScreen: props.debugMode,
54965
55340
  showDiagnostics: props.debugMode,
54966
55341
  onComplete: withSubmissionRequest(props.onComplete, ctx),
54967
- onRequestFailure: props.onRequestFailure,
55342
+ // No ID captured and none supplied resolves the action to NONE, which
55343
+ // has nothing to post. 2.x answered with a synthetic success and no
55344
+ // request; capture mode is that without the fabricated response.
55345
+ submitMode: (_d = mapHandoff(props.onSubmit)) !== null && _d !== void 0 ? _d : props.skipIdCapture && !props.idCardForFaceMatch ? 'capture' : undefined,
55346
+ onSubmissionFailure: props.onRequestFailure,
54968
55347
  onCaptureError: props.onRequestFailure
54969
55348
  });
54970
55349
  }
@@ -55129,7 +55508,8 @@
55129
55508
  onComplete: withSubmissionRequest(props.onComplete, ctx),
55130
55509
  onCustomerMatched: withSubmissionRequest(props.onCustomerMatched, ctx),
55131
55510
  onCustomerNotMatched: withSubmissionRequest(props.onCustomerNotMatched, ctx),
55132
- onRequestFailure: props.onRequestFailure,
55511
+ submitMode: mapHandoff(props.onSubmit),
55512
+ onSubmissionFailure: props.onRequestFailure,
55133
55513
  onExitCapture: props.onExitCapture,
55134
55514
  onExitAfterFailure: props.onExitAfterFailure
55135
55515
  });
@@ -55198,7 +55578,8 @@
55198
55578
  // sdk2's enrollment twin of `onApproved`.
55199
55579
  onApproved: withSubmissionRequest(props.onEnrolled, ctx),
55200
55580
  onDenied: withSubmissionRequest(props.onDenied, ctx),
55201
- onRequestFailure: props.onRequestFailure,
55581
+ submitMode: mapHandoff(props.onSubmit),
55582
+ onSubmissionFailure: props.onRequestFailure,
55202
55583
  onCaptureError: props.onRequestFailure
55203
55584
  });
55204
55585
  }
@@ -55290,12 +55671,13 @@
55290
55671
  onComplete: withSubmissionRequest(props.onComplete, ctx),
55291
55672
  onApproved: withSubmissionRequest(props.onEnrolled, ctx),
55292
55673
  onDenied: withSubmissionRequest(props.onDenied, ctx),
55293
- onRequestFailure: props.onRequestFailure,
55674
+ submitMode: mapHandoff(props.onSubmit),
55675
+ onSubmissionFailure: props.onRequestFailure,
55294
55676
  onCaptureError: props.onRequestFailure
55295
55677
  });
55296
55678
  }
55297
55679
 
55298
- var webSdkVersion = '2.6.3-changeset-release-develop-124a427';
55680
+ var webSdkVersion = '2.6.3-changeset-release-develop-776f131';
55299
55681
 
55300
55682
  // GENERATED by scripts/styleBagTypes.mjs from
55301
55683
  // src/__fixtures__/sdk2StyleBags.json and the mapper sweep — do not
@@ -57352,23 +57734,17 @@
57352
57734
  var SUBMIT_CALLBACKS = {
57353
57735
  onBeforeSubmit: MAPPED,
57354
57736
  /**
57355
- * Mapped to the CLIENT's `onSubmit`, not to a flow prop — the layer sdk2 put
57356
- * it at (SubmissionProvider.submit). The client builds the request, hands it
57357
- * over, and does NOT post, so `onComplete`/`onApproved`/`onDenied` never
57358
- * fire, exactly as 2.x documents. Every flow submits through that one
57359
- * client, including the two match flows with their own stage machine, so the
57360
- * suppression is uniform.
57737
+ * Mapped to the flow's `submitMode: { handoff }`. The flow builds the
57738
+ * request, hands it over, and does NOT post, so `onComplete`/`onApproved`/
57739
+ * `onDenied` never fire, exactly as 2.x documents. Mapped on every render,
57740
+ * so adding or removing it takes effect from the next submission, as sdk2's
57741
+ * ref-held `onSubmit` did.
57361
57742
  *
57362
57743
  * What the flow SHOWS afterwards is a 3.0 call rather than a 2.x
57363
57744
  * reproduction: every family now ends quietly, because the integrator owns
57364
57745
  * the outcome once they have the request. 2.x's match flows showed a failure
57365
57746
  * screen there, but only because their `submit()` could not distinguish an
57366
57747
  * intercepted submission from a broken one.
57367
- *
57368
- * `SignatureKYC` reaches the same place by a different route: its 3.0
57369
- * counterpart never enters `client.submit()`, so the façade component makes
57370
- * that call itself from `onCaptured`. `action: NONE` is accepted there
57371
- * precisely because `onSubmit` is bound.
57372
57748
  */
57373
57749
  onSubmit: MAPPED,
57374
57750
  onComplete: MAPPED,
@@ -57466,7 +57842,7 @@
57466
57842
  // `SubmissionAction.NONE` and wires `onComplete` to the provider's
57467
57843
  // `onResponseReceived` (SignatureKYC.tsx:434,449), which never fires because
57468
57844
  // nothing is ever posted. `onSubmit` is the real completion seam and IS
57469
- // mapped, to the flow's `onCaptured`.
57845
+ // mapped, to the flow's `submitMode: { handoff }`.
57470
57846
  onComplete: NOOP,
57471
57847
  onSubmit: MAPPED,
57472
57848
  onRequestFailure: MAPPED,
@@ -57957,10 +58333,6 @@
57957
58333
  _lastLivenessRequest.current = request;
57958
58334
  return propsRef.current.onBeforeLivenessCheck ? propsRef.current.onBeforeLivenessCheck(request) : Promise.resolve(request);
57959
58335
  },
57960
- onSubmit: propsRef.current.onSubmit ? function (request) {
57961
- var _a, _b;
57962
- return (_b = (_a = propsRef.current).onSubmit) === null || _b === void 0 ? void 0 : _b.call(_a, request);
57963
- } : undefined,
57964
58336
  onResponseReceived: function onResponseReceived(_response, request) {
57965
58337
  _lastSubmissionRequest.current = request;
57966
58338
  },
@@ -58131,34 +58503,12 @@
58131
58503
  client = _a.client,
58132
58504
  ctx = _a.ctx;
58133
58505
  useDroppedPropReport('SignatureKYC', props);
58134
- // The one flow whose 3.0 counterpart never enters `client.submit()`: it runs
58135
- // its own stage machine and reports completion through `onCaptured` instead.
58136
- // 2.x DOES submit here — its CompositeWizard calls `submit()`, which hands
58137
- // the built request to `onSubmit` before reaching the capture-only branch —
58138
- // so the façade makes that call itself to produce the same request. The
58139
- // client suppresses the POST, and `action: NONE` is accepted precisely
58140
- // because `onSubmit` is bound.
58141
- //
58142
- // Only when bound: without `onSubmit` the client rejects NONE by design, and
58143
- // this flow has nothing to submit anyway.
58144
- var onSubmit = props.onSubmit;
58145
- var submission = mapSubmission(props);
58146
- var handOff = onSubmit ? function (artifacts) {
58147
- void client.submit(artifacts, _assign(_assign({}, submission), {
58148
- action: SubmissionAction.NONE
58149
- }))["catch"](function () {
58150
- // The failure already reached `onRequestFailure` through the
58151
- // client's own hook, which is where 2.x reported it too.
58152
- });
58153
- } : undefined;
58154
58506
  // No `children`: SignatureKYCFlow omits it from its props (it runs its own
58155
58507
  // stage machine rather than CompositeWizard), so passing it would not
58156
58508
  // compile — and 2.x rendered it nowhere either.
58157
58509
  return /*#__PURE__*/React.createElement(SignatureKYCFlow, _assign({
58158
58510
  client: client
58159
- }, mapSignatureKYCProps(props, ctx), {
58160
- onCaptured: handOff
58161
- }));
58511
+ }, mapSignatureKYCProps(props, ctx)));
58162
58512
  };
58163
58513
  /**
58164
58514
  * Render a fullscreen capture component that performs ID and face validation,