idmission-web-sdk 2.6.3-t3code-shared-flow-settings-07ab804 → 2.6.3-t3code-callback-homes-submit-handoff-9690b2d

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.
@@ -4869,6 +4869,22 @@ function withJobTaskMetadata(metadata, jobID, taskID) {
4869
4869
  if (taskID) merged.taskid = taskID;
4870
4870
  return merged;
4871
4871
  }
4872
+ /**
4873
+ * Runs a customer callback whose failure must not change an outcome that is
4874
+ * already settled: a throw or a rejected promise is logged, never rethrown.
4875
+ */
4876
+ function notifySafely$1(name, notify) {
4877
+ try {
4878
+ var result = notify();
4879
+ if (result instanceof Promise) {
4880
+ result["catch"](function (e) {
4881
+ return warn$1(name + " rejected", e);
4882
+ });
4883
+ }
4884
+ } catch (e) {
4885
+ warn$1(name + " threw", e);
4886
+ }
4887
+ }
4872
4888
  /**
4873
4889
  * How long an async `sessionId` resolver may take. It typically mints the
4874
4890
  * session through the host's own backend (an OAuth token, then
@@ -4891,6 +4907,10 @@ function resolveSessionIdWithTimeout(resolve) {
4891
4907
  return clearTimeout(timer);
4892
4908
  });
4893
4909
  }
4910
+ /**
4911
+ * Creates a client. Its type is `Required<IdmissionClient>`: unlike a
4912
+ * hand-written `IdmissionClient`, it always has `post()` and `handoff()`.
4913
+ */
4894
4914
  function createIdmissionClient(config) {
4895
4915
  var _config$fetch, _config$now;
4896
4916
  // `let`: when config.sessionId is an async resolver, the session URN (and
@@ -4977,10 +4997,33 @@ function createIdmissionClient(config) {
4977
4997
  }));
4978
4998
  return _timedFetch.apply(this, arguments);
4979
4999
  }
4980
- function performUpload(blob, metadata) {
4981
- return uploadDocument(blob, metadata, {
4982
- documentServiceUrl: urls.documentServiceUrl,
5000
+ function currentRoute() {
5001
+ return {
4983
5002
  sessionId: store.getState().session.sessionId,
5003
+ submissionUrl: urls.submissionUrl,
5004
+ documentServiceUrl: urls.documentServiceUrl,
5005
+ sessionNonce: getLastSessionNonce()
5006
+ };
5007
+ }
5008
+ // The attestation holders are module-level and follow the newest
5009
+ // ValidateSession. If that is no longer this operation's session, its nonce
5010
+ // and OS token belong to someone else: omit the envelope (throwing here is
5011
+ // attachMetadataToRequest's fail-open path, which reports
5012
+ // `attestationAttached: false`) rather than attach a stranger's.
5013
+ function routeBoundCollectors(route) {
5014
+ return {
5015
+ collectAttestation: function collectAttestation(web, versions) {
5016
+ if (getLastSessionNonce() !== route.sessionNonce) {
5017
+ throw new Error('session changed during submission; attestation omitted');
5018
+ }
5019
+ return collectClientAttestation(web, versions);
5020
+ }
5021
+ };
5022
+ }
5023
+ function performUpload(blob, metadata, route) {
5024
+ return uploadDocument(blob, metadata, {
5025
+ documentServiceUrl: route.documentServiceUrl,
5026
+ sessionId: route.sessionId,
4984
5027
  Upload: config.tusUpload,
4985
5028
  delay: config.delay,
4986
5029
  calculateMd5: config.calculateMd5,
@@ -5204,23 +5247,28 @@ function createIdmissionClient(config) {
5204
5247
  }));
5205
5248
  return _retrySession.apply(this, arguments);
5206
5249
  }
5207
- function submit(_x6, _x7) {
5208
- return _submit.apply(this, arguments);
5250
+ function runPipeline(_x6, _x7, _x8) {
5251
+ return _runPipeline.apply(this, arguments);
5209
5252
  }
5210
- function _submit() {
5211
- _submit = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee7(artifacts, options) {
5212
- var _options$onBeforeSubm;
5213
- 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;
5253
+ function _runPipeline() {
5254
+ _runPipeline = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee7(artifacts, options, kind) {
5255
+ var _artifacts$meta$liven, _artifacts$meta, _options$onBeforeSubm;
5256
+ 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;
5214
5257
  return _regeneratorRuntime.wrap(function (_context7) {
5215
5258
  while (1) switch (_context7.prev = _context7.next) {
5216
5259
  case 0:
5217
- if (!(options.action === SubmissionAction.NONE && !config.onSubmit)) {
5260
+ handsOff = kind === 'handoff' || kind === 'submit' && config.onSubmit !== undefined; // sdk2 short-circuits action NONE to a synthetic success before any
5261
+ // network activity (SubmissionProvider.tsx:1203-1225). This client does
5262
+ // not fabricate that response, but it keeps the "NONE does no network
5263
+ // work" guarantee by rejecting here, before any upload — unless the
5264
+ // request is being handed off, which is the one thing NONE can do.
5265
+ if (!(options.action === SubmissionAction.NONE && !handsOff)) {
5218
5266
  _context7.next = 1;
5219
5267
  break;
5220
5268
  }
5221
5269
  throw new SubmissionError({
5222
5270
  statusCode: 'UNSUPPORTED_ACTION',
5223
- statusMessage: "submit() rejects action: 'NONE' -- capture-only, no-network submission is the controller layer's responsibility (plan 3), not this client's"
5271
+ statusMessage: "action 'NONE' has no endpoint to post to; use handoff() to build the request without posting it"
5224
5272
  });
5225
5273
  case 1:
5226
5274
  if (!(store.getState().session.sessionCheckState !== 'PASSED')) {
@@ -5229,6 +5277,11 @@ function createIdmissionClient(config) {
5229
5277
  }
5230
5278
  throw new AuthenticationError(401, 'session not validated');
5231
5279
  case 2:
5280
+ route = currentRoute(); // Claimed, not read: an overlapping operation must not reuse it, and a
5281
+ // `checkLiveness()` that lands mid-operation keeps its own token for the
5282
+ // next one (SubmissionProvider.tsx:1350 cleared it after the submit).
5283
+ claimedLivenessToken = (_artifacts$meta$liven = (_artifacts$meta = artifacts.meta) == null ? void 0 : _artifacts$meta.livenessToken) != null ? _artifacts$meta$liven : livenessToken;
5284
+ livenessToken = undefined;
5232
5285
  store.setState({
5233
5286
  submissionStatus: SubmissionStatus.SUBMITTING,
5234
5287
  submissionError: undefined
@@ -5245,7 +5298,7 @@ function createIdmissionClient(config) {
5245
5298
  _context7.next = 5;
5246
5299
  return buildSubmissionPayload(_extends({}, artifacts, {
5247
5300
  meta: _extends({}, artifacts.meta, {
5248
- livenessToken: (_artifacts$meta$liven = (_artifacts$meta = artifacts.meta) == null ? void 0 : _artifacts$meta.livenessToken) != null ? _artifacts$meta$liven : livenessToken
5301
+ livenessToken: claimedLivenessToken
5249
5302
  })
5250
5303
  }), _extends({}, options, {
5251
5304
  onBeforeSubmit: beforeSubmit ? function (request) {
@@ -5261,7 +5314,7 @@ function createIdmissionClient(config) {
5261
5314
  // withJobTaskMetadata (see its own comment above): only present
5262
5315
  // when options.jobID/taskID are present.
5263
5316
  uploadDocument: documentServiceEnabled ? (/*#__PURE__*/function () {
5264
- var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee6(blob, metadata) {
5317
+ var _ref3 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee6(blob, metadata) {
5265
5318
  var result, _t3;
5266
5319
  return _regeneratorRuntime.wrap(function (_context6) {
5267
5320
  while (1) switch (_context6.prev = _context6.next) {
@@ -5278,7 +5331,7 @@ function createIdmissionClient(config) {
5278
5331
  });
5279
5332
  _context6.prev = 1;
5280
5333
  _context6.next = 2;
5281
- return performUpload(blob, withJobTaskMetadata(metadata, options.jobID, options.taskID));
5334
+ return performUpload(blob, withJobTaskMetadata(metadata, options.jobID, options.taskID), route);
5282
5335
  case 2:
5283
5336
  result = _context6.sent;
5284
5337
  progress.observe({
@@ -5308,12 +5361,13 @@ function createIdmissionClient(config) {
5308
5361
  }
5309
5362
  }, _callee6, null, [[1, 3, 4, 5]]);
5310
5363
  }));
5311
- return function (_x10, _x11) {
5312
- return _ref2.apply(this, arguments);
5364
+ return function (_x13, _x14) {
5365
+ return _ref3.apply(this, arguments);
5313
5366
  };
5314
5367
  }()) : undefined,
5315
5368
  now: config.now,
5316
- sdkVersions: config.sdkVersions
5369
+ sdkVersions: config.sdkVersions,
5370
+ collectors: routeBoundCollectors(route)
5317
5371
  });
5318
5372
  case 5:
5319
5373
  payloadResult = _context7.sent;
@@ -5327,40 +5381,41 @@ function createIdmissionClient(config) {
5327
5381
  case 7:
5328
5382
  payloadBuildEnd = payloadResult.uploadTimings.payloadBuildEnd;
5329
5383
  uploadMeasurements = payloadResult.uploadTimings.uploads;
5330
- request = payloadResult.request; // Stashed HERE rather than next to `lastSubmissionTimings` in the
5331
- // `finally`, because the hand-off below returns early: parking it in
5332
- // the same setState as the timings would leave `onSubmit` customers
5333
- // with a timings block and no request to go with it.
5384
+ request = payloadResult.request; // Stashed before the hand-off returns, so hand-off callers get the
5385
+ // request alongside the timings the `finally` records.
5334
5386
  store.setState({
5335
5387
  attestationAttached: payloadResult.attestationAttached,
5336
5388
  lastSubmissionRequest: request
5337
5389
  });
5338
- // THE HAND-OFF. sdk2 short-circuits at the equivalent point
5339
- // (SubmissionProvider.tsx:1374-1377, `return onSubmit.current(request)`
5340
- // before `defaultOnSubmit`), so everything above this line runs and
5341
- // nothing below it does.
5342
- //
5343
- // The status goes to SUBMITTED, where sdk2 leaves it at READY. That is a
5344
- // deliberate divergence in INTERNAL state to preserve the VISIBLE
5345
- // behaviour: sdk2's wizard renders an empty fragment for READY via its
5346
- // switch `default`, whereas this codebase renders the submitting screen
5347
- // for READY — so inheriting READY would park the user on a spinner
5348
- // forever. SUBMITTED with no response falls through every terminal
5349
- // branch to `return null`, which is sdk2's empty fragment.
5350
- if (!config.onSubmit) {
5390
+ if (!handsOff) {
5351
5391
  _context7.next = 8;
5352
5392
  break;
5353
5393
  }
5394
+ // sdk2 short-circuits at the equivalent point
5395
+ // (SubmissionProvider.tsx:1374-1377), so everything above runs and
5396
+ // nothing below does.
5397
+ //
5398
+ // The status goes to SUBMITTED, where sdk2 leaves it at READY. That is
5399
+ // a deliberate divergence in INTERNAL state to preserve the VISIBLE
5400
+ // behaviour: sdk2's wizard renders an empty fragment for READY via its
5401
+ // switch `default`, whereas this codebase renders the submitting
5402
+ // screen for READY — so inheriting READY would park the user on a
5403
+ // spinner forever. SUBMITTED with no response falls through every
5404
+ // terminal branch to `return null`, which is sdk2's empty fragment.
5354
5405
  store.setState({
5355
5406
  submissionStatus: SubmissionStatus.SUBMITTED
5356
5407
  });
5357
- config.onSubmit(request);
5408
+ if (kind === 'submit') config.onSubmit == null || config.onSubmit(request);
5358
5409
  progress.observe({
5359
5410
  kind: 'flow-completed'
5360
5411
  });
5361
- return _context7.abrupt("return", null);
5412
+ built = {
5413
+ request: request,
5414
+ response: null
5415
+ };
5416
+ _context7.next = 23;
5417
+ break;
5362
5418
  case 8:
5363
- sessionId = store.getState().session.sessionId;
5364
5419
  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));
5365
5420
  progress.observe({
5366
5421
  kind: 'phase',
@@ -5375,9 +5430,9 @@ function createIdmissionClient(config) {
5375
5430
  _context7.prev = 9;
5376
5431
  _context7.prev = 10;
5377
5432
  _context7.next = 11;
5378
- return timedFetch(urls.submissionUrl + endpoint, {
5433
+ return timedFetch(route.submissionUrl + endpoint, {
5379
5434
  method: 'POST',
5380
- headers: apiHeaders(sessionId, options.sendBase64DocumentsInSwaggerProxy),
5435
+ headers: apiHeaders(route.sessionId, options.sendBase64DocumentsInSwaggerProxy),
5381
5436
  body: JSON.stringify(request)
5382
5437
  });
5383
5438
  case 11:
@@ -5467,10 +5522,21 @@ function createIdmissionClient(config) {
5467
5522
  progress.observe({
5468
5523
  kind: 'flow-completed'
5469
5524
  });
5470
- config.onResponseReceived == null || config.onResponseReceived(submissionResponse, request);
5471
- return _context7.abrupt("return", submissionResponse);
5525
+ // Legacy `submit()` keeps a throwing `onResponseReceived` inside the
5526
+ // failure path, as it always has; `post()` notifies after the outcome
5527
+ // is settled (below).
5528
+ if (kind === 'submit') {
5529
+ config.onResponseReceived == null || config.onResponseReceived(submissionResponse, request);
5530
+ }
5531
+ built = {
5532
+ request: request,
5533
+ response: submissionResponse
5534
+ };
5472
5535
  case 23:
5473
- _context7.prev = 23;
5536
+ _context7.next = 25;
5537
+ break;
5538
+ case 24:
5539
+ _context7.prev = 24;
5474
5540
  _t0 = _context7["catch"](3);
5475
5541
  if (failedAt === undefined) failedAt = 'submission';
5476
5542
  err = _t0;
@@ -5482,72 +5548,116 @@ function createIdmissionClient(config) {
5482
5548
  // UNLIKE sdk2 (`if (throwErrorsOnFailure) throw err`) there is no
5483
5549
  // catch-swallow path: rejection always propagates.
5484
5550
  throw err;
5485
- case 24:
5486
- _context7.prev = 24;
5487
- // Liveness tokens are single-use: clear after each submit so a stale
5488
- // token isn't reapplied on a retry (SubmissionProvider.tsx:1350).
5489
- livenessToken = undefined;
5551
+ case 25:
5552
+ _context7.prev = 25;
5490
5553
  endedAt = nowImpl();
5554
+ timings = buildSubmissionTimings({
5555
+ startedAt: startedAt,
5556
+ endedAt: endedAt,
5557
+ payloadBuildStart: payloadBuildStart,
5558
+ payloadBuildEnd: payloadBuildEnd,
5559
+ uploads: uploadMeasurements,
5560
+ apiCallStart: apiCallStart,
5561
+ apiCallEnd: apiCallEnd,
5562
+ responseParseStart: responseParseStart,
5563
+ responseParseEnd: responseParseEnd,
5564
+ failedAt: failedAt
5565
+ });
5491
5566
  store.setState({
5492
- lastSubmissionTimings: buildSubmissionTimings({
5493
- startedAt: startedAt,
5494
- endedAt: endedAt,
5495
- payloadBuildStart: payloadBuildStart,
5496
- payloadBuildEnd: payloadBuildEnd,
5497
- uploads: uploadMeasurements,
5498
- apiCallStart: apiCallStart,
5499
- apiCallEnd: apiCallEnd,
5500
- responseParseStart: responseParseStart,
5501
- responseParseEnd: responseParseEnd,
5502
- failedAt: failedAt
5503
- })
5567
+ lastSubmissionTimings: timings
5504
5568
  });
5505
- return _context7.finish(24);
5506
- case 25:
5569
+ return _context7.finish(25);
5570
+ case 26:
5571
+ if (kind === 'post' && built.response) {
5572
+ _built = built, _response = _built.response, _request = _built.request;
5573
+ notifySafely$1('onResponseReceived', function () {
5574
+ return config.onResponseReceived == null ? void 0 : config.onResponseReceived(_response, _request);
5575
+ });
5576
+ }
5577
+ return _context7.abrupt("return", _extends({}, built, {
5578
+ timings: timings
5579
+ }));
5580
+ case 27:
5507
5581
  case "end":
5508
5582
  return _context7.stop();
5509
5583
  }
5510
- }, _callee7, null, [[3, 23, 24, 25], [4, 6], [9, 20], [10, 12]]);
5584
+ }, _callee7, null, [[3, 24, 25, 26], [4, 6], [9, 20], [10, 12]]);
5585
+ }));
5586
+ return _runPipeline.apply(this, arguments);
5587
+ }
5588
+ function submit(artifacts, options) {
5589
+ return runPipeline(artifacts, options, 'submit').then(function (_ref2) {
5590
+ var response = _ref2.response;
5591
+ return response;
5592
+ });
5593
+ }
5594
+ function post(artifacts, options) {
5595
+ return runPipeline(artifacts, options, 'post');
5596
+ }
5597
+ function handoff(_x9, _x0) {
5598
+ return _handoff.apply(this, arguments);
5599
+ }
5600
+ function _handoff() {
5601
+ _handoff = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee8(artifacts, options) {
5602
+ var _yield$runPipeline, request, timings;
5603
+ return _regeneratorRuntime.wrap(function (_context8) {
5604
+ while (1) switch (_context8.prev = _context8.next) {
5605
+ case 0:
5606
+ _context8.next = 1;
5607
+ return runPipeline(artifacts, options, 'handoff');
5608
+ case 1:
5609
+ _yield$runPipeline = _context8.sent;
5610
+ request = _yield$runPipeline.request;
5611
+ timings = _yield$runPipeline.timings;
5612
+ return _context8.abrupt("return", {
5613
+ request: request,
5614
+ timings: timings
5615
+ });
5616
+ case 2:
5617
+ case "end":
5618
+ return _context8.stop();
5619
+ }
5620
+ }, _callee8);
5511
5621
  }));
5512
- return _submit.apply(this, arguments);
5622
+ return _handoff.apply(this, arguments);
5513
5623
  }
5514
- function checkLiveness(_x8, _x9) {
5624
+ function checkLiveness(_x1, _x10) {
5515
5625
  return _checkLiveness.apply(this, arguments);
5516
5626
  }
5517
5627
  function _checkLiveness() {
5518
- _checkLiveness = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee8(imageDataUrl, options) {
5628
+ _checkLiveness = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee9(imageDataUrl, options) {
5519
5629
  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;
5520
- return _regeneratorRuntime.wrap(function (_context8) {
5521
- while (1) switch (_context8.prev = _context8.next) {
5630
+ return _regeneratorRuntime.wrap(function (_context9) {
5631
+ while (1) switch (_context9.prev = _context9.next) {
5522
5632
  case 0:
5523
5633
  if (options === void 0) {
5524
5634
  options = {};
5525
5635
  }
5526
- _context8.prev = 1;
5636
+ _context9.prev = 1;
5527
5637
  selfie = imageDataUrl;
5528
5638
  if (!(options.useDocumentServiceForLivenessChecks && documentServiceEnabled)) {
5529
- _context8.next = 6;
5639
+ _context9.next = 6;
5530
5640
  break;
5531
5641
  }
5532
5642
  if (!selfie.startsWith('data:')) {
5533
5643
  selfie = "data:image/jpeg;base64," + selfie;
5534
5644
  }
5535
- _context8.prev = 2;
5536
- _context8.next = 3;
5645
+ _context9.prev = 2;
5646
+ _context9.next = 3;
5537
5647
  return performUpload(dataUrlToBlob(selfie), withJobTaskMetadata({
5538
5648
  filename: 'liveness',
5539
5649
  filetype: 'image/jpeg'
5540
- }, options.jobID, options.taskID));
5650
+ }, options.jobID, options.taskID), currentRoute());
5541
5651
  case 3:
5542
- selfie = _context8.sent;
5543
- _context8.next = 5;
5652
+ selfie = _context9.sent;
5653
+ _context9.next = 5;
5544
5654
  break;
5545
5655
  case 4:
5546
- _context8.prev = 4;
5547
- _t1 = _context8["catch"](2);
5656
+ _context9.prev = 4;
5657
+ _t1 = _context9["catch"](2);
5548
5658
  throw new NetworkError(_t1 instanceof Error ? _t1.message : String(_t1));
5549
5659
  case 5:
5550
- _context8.next = 7;
5660
+ _context9.next = 7;
5551
5661
  break;
5552
5662
  case 6:
5553
5663
  selfie = dataUrlToBase64Sync$1(selfie);
@@ -5615,19 +5725,19 @@ function createIdmissionClient(config) {
5615
5725
  attestationAttached: attestationAttached
5616
5726
  });
5617
5727
  if (!config.onBeforeLivenessCheck) {
5618
- _context8.next = 9;
5728
+ _context9.next = 9;
5619
5729
  break;
5620
5730
  }
5621
- _context8.next = 8;
5731
+ _context9.next = 8;
5622
5732
  return config.onBeforeLivenessCheck(request);
5623
5733
  case 8:
5624
- result = _context8.sent;
5734
+ result = _context9.sent;
5625
5735
  if (result) request = result;
5626
5736
  case 9:
5627
5737
  endpoint = liveCheckEndpoint(!!options.idCardForFaceMatch);
5628
5738
  sessionId = store.getState().session.sessionId;
5629
- _context8.prev = 10;
5630
- _context8.next = 11;
5739
+ _context9.prev = 10;
5740
+ _context9.next = 11;
5631
5741
  return timedFetch(urls.submissionUrl + endpoint, {
5632
5742
  method: 'POST',
5633
5743
  // SubmissionProvider.tsx:1447 — sourced from the same
@@ -5638,36 +5748,36 @@ function createIdmissionClient(config) {
5638
5748
  body: JSON.stringify(request)
5639
5749
  });
5640
5750
  case 11:
5641
- response = _context8.sent;
5642
- _context8.next = 13;
5751
+ response = _context9.sent;
5752
+ _context9.next = 13;
5643
5753
  break;
5644
5754
  case 12:
5645
- _context8.prev = 12;
5646
- _t10 = _context8["catch"](10);
5755
+ _context9.prev = 12;
5756
+ _t10 = _context9["catch"](10);
5647
5757
  throw new NetworkError(_t10 instanceof Error ? _t10.message : String(_t10));
5648
5758
  case 13:
5649
5759
  if (response.ok) {
5650
- _context8.next = 18;
5760
+ _context9.next = 18;
5651
5761
  break;
5652
5762
  }
5653
5763
  if (!(response.status === 401 || response.status === 403)) {
5654
- _context8.next = 15;
5764
+ _context9.next = 15;
5655
5765
  break;
5656
5766
  }
5657
5767
  _t11 = AuthenticationError;
5658
5768
  _t12 = response.status;
5659
- _context8.next = 14;
5769
+ _context9.next = 14;
5660
5770
  return response.text();
5661
5771
  case 14:
5662
- _t13 = _context8.sent;
5772
+ _t13 = _context9.sent;
5663
5773
  throw new _t11(_t12, _t13);
5664
5774
  case 15:
5665
- _context8.next = 16;
5775
+ _context9.next = 16;
5666
5776
  return response.text();
5667
5777
  case 16:
5668
- statusMessage = _context8.sent;
5778
+ statusMessage = _context9.sent;
5669
5779
  if (!(!statusMessage || statusMessage === 'Load failed')) {
5670
- _context8.next = 17;
5780
+ _context9.next = 17;
5671
5781
  break;
5672
5782
  }
5673
5783
  throw new NetworkError(statusMessage);
@@ -5677,12 +5787,12 @@ function createIdmissionClient(config) {
5677
5787
  statusMessage: statusMessage
5678
5788
  });
5679
5789
  case 18:
5680
- _context8.next = 19;
5790
+ _context9.next = 19;
5681
5791
  return response.json();
5682
5792
  case 19:
5683
- livenessResponse = _context8.sent;
5793
+ livenessResponse = _context9.sent;
5684
5794
  if (!(livenessResponse.status.statusCode !== '000')) {
5685
- _context8.next = 20;
5795
+ _context9.next = 20;
5686
5796
  break;
5687
5797
  }
5688
5798
  throw new SubmissionError(livenessResponse.status);
@@ -5695,7 +5805,7 @@ function createIdmissionClient(config) {
5695
5805
  // unconditional here — a deliberate scope narrowing, not a silent drop.
5696
5806
  livenessToken = (_livenessResponse$res = livenessResponse.resultData) == null ? void 0 : _livenessResponse$res.livenessToken;
5697
5807
  if (!(options.softFail && !isLiveFaceConfirmed((_livenessResponse$res2 = livenessResponse.resultData) == null ? void 0 : _livenessResponse$res2.verificationResult))) {
5698
- _context8.next = 21;
5808
+ _context9.next = 21;
5699
5809
  break;
5700
5810
  }
5701
5811
  // Current sdk2 (SubmissionProvider.tsx checkLiveness): softFail also
@@ -5704,21 +5814,21 @@ function createIdmissionClient(config) {
5704
5814
  // non-live capture) and hand back a typed failure that still carries
5705
5815
  // the response so callers can read the detection flags.
5706
5816
  livenessToken = undefined;
5707
- return _context8.abrupt("return", {
5817
+ return _context9.abrupt("return", {
5708
5818
  ok: false,
5709
5819
  error: new Error("Liveness not confirmed: " + ((_livenessResponse$res3 = (_livenessResponse$res4 = livenessResponse.resultData) == null ? void 0 : _livenessResponse$res4.verificationResult) != null ? _livenessResponse$res3 : 'no verificationResult')),
5710
5820
  response: livenessResponse
5711
5821
  });
5712
5822
  case 21:
5713
- return _context8.abrupt("return", {
5823
+ return _context9.abrupt("return", {
5714
5824
  ok: true,
5715
5825
  response: livenessResponse
5716
5826
  });
5717
5827
  case 22:
5718
- _context8.prev = 22;
5719
- _t14 = _context8["catch"](1);
5828
+ _context9.prev = 22;
5829
+ _t14 = _context9["catch"](1);
5720
5830
  if (!options.softFail) {
5721
- _context8.next = 23;
5831
+ _context9.next = 23;
5722
5832
  break;
5723
5833
  }
5724
5834
  // Caller is treating this as a best-effort check. Don't surface the
@@ -5726,7 +5836,7 @@ function createIdmissionClient(config) {
5726
5836
  // typed failure result instead of sdk2's silent `undefined` (deliberate
5727
5837
  // divergence #3).
5728
5838
  livenessToken = undefined;
5729
- return _context8.abrupt("return", {
5839
+ return _context9.abrupt("return", {
5730
5840
  ok: false,
5731
5841
  error: _t14
5732
5842
  });
@@ -5740,32 +5850,32 @@ function createIdmissionClient(config) {
5740
5850
  throw err;
5741
5851
  case 24:
5742
5852
  case "end":
5743
- return _context8.stop();
5853
+ return _context9.stop();
5744
5854
  }
5745
- }, _callee8, null, [[1, 22], [2, 4], [10, 12]]);
5855
+ }, _callee9, null, [[1, 22], [2, 4], [10, 12]]);
5746
5856
  }));
5747
5857
  return _checkLiveness.apply(this, arguments);
5748
5858
  }
5749
- function clientUploadDocument(_x0, _x1) {
5859
+ function clientUploadDocument(_x11, _x12) {
5750
5860
  return _clientUploadDocument.apply(this, arguments);
5751
5861
  }
5752
5862
  function _clientUploadDocument() {
5753
- _clientUploadDocument = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee9(blob, metadata) {
5754
- return _regeneratorRuntime.wrap(function (_context9) {
5755
- while (1) switch (_context9.prev = _context9.next) {
5863
+ _clientUploadDocument = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee0(blob, metadata) {
5864
+ return _regeneratorRuntime.wrap(function (_context0) {
5865
+ while (1) switch (_context0.prev = _context0.next) {
5756
5866
  case 0:
5757
5867
  if (documentServiceEnabled) {
5758
- _context9.next = 1;
5868
+ _context0.next = 1;
5759
5869
  break;
5760
5870
  }
5761
5871
  throw new Error('document upload is disabled: no documentServiceUrl configured');
5762
5872
  case 1:
5763
- return _context9.abrupt("return", performUpload(blob, metadata != null ? metadata : {}));
5873
+ return _context0.abrupt("return", performUpload(blob, metadata != null ? metadata : {}, currentRoute()));
5764
5874
  case 2:
5765
5875
  case "end":
5766
- return _context9.stop();
5876
+ return _context0.stop();
5767
5877
  }
5768
- }, _callee9);
5878
+ }, _callee0);
5769
5879
  }));
5770
5880
  return _clientUploadDocument.apply(this, arguments);
5771
5881
  }
@@ -5781,6 +5891,8 @@ function createIdmissionClient(config) {
5781
5891
  validateSession: validateSessionMethod,
5782
5892
  retrySession: retrySession,
5783
5893
  submit: submit,
5894
+ post: post,
5895
+ handoff: handoff,
5784
5896
  checkLiveness: checkLiveness,
5785
5897
  uploadDocument: clientUploadDocument
5786
5898
  };
@@ -7573,12 +7685,17 @@ var SdkLanguageContext = /*#__PURE__*/React.createContext(undefined);
7573
7685
  * Binds one rendered SDK tree to its requested language. A fixed translator
7574
7686
  * avoids waiting for a post-render changeLanguage() effect and keeps SSR and
7575
7687
  * concurrently mounted SDK views independent of the shared detector instance.
7688
+ *
7689
+ * An unset `lang` keeps whatever scope encloses it (or none), so a caller can
7690
+ * render the provider unconditionally: toggling `lang` between unset and set
7691
+ * then never changes the element tree, and never remounts the subtree.
7576
7692
  */
7577
7693
  function SdkLanguageProvider(_ref) {
7578
7694
  var children = _ref.children,
7579
7695
  lang = _ref.lang;
7696
+ var inherited = React.useContext(SdkLanguageContext);
7580
7697
  return /*#__PURE__*/React.createElement(SdkLanguageContext.Provider, {
7581
- value: lang === 'auto' ? detectedLanguage : lang
7698
+ value: lang === undefined ? inherited : lang === 'auto' ? detectedLanguage : lang
7582
7699
  }, children);
7583
7700
  }
7584
7701
  /**
@@ -38400,7 +38517,9 @@ function SubmissionProvider(_ref) {
38400
38517
  onComplete = _ref.onComplete,
38401
38518
  onApproved = _ref.onApproved,
38402
38519
  onDenied = _ref.onDenied,
38403
- onRequestFailure = _ref.onRequestFailure;
38520
+ onSubmissionFailure = _ref.onSubmissionFailure,
38521
+ onRequestFailure = _ref.onRequestFailure,
38522
+ mode = _ref.mode;
38404
38523
  var progress = useCaptureObserver();
38405
38524
  var clientState = shim.useSyncExternalStore(client.subscribe, client.getState, client.getState);
38406
38525
  var _useAuthState = useAuthState(),
@@ -38413,10 +38532,15 @@ function SubmissionProvider(_ref) {
38413
38532
  _useState4 = _slicedToArray(_useState3, 2),
38414
38533
  localError = _useState4[0],
38415
38534
  setLocalError = _useState4[1];
38416
- var _useState5 = React.useState(false),
38535
+ var _useState5 = React.useState(IDLE_ATTEMPT),
38417
38536
  _useState6 = _slicedToArray(_useState5, 2),
38418
- resubmitting = _useState6[0],
38419
- setResubmitting = _useState6[1];
38537
+ attempt = _useState6[0],
38538
+ setAttempt = _useState6[1];
38539
+ var reportFailure = onSubmissionFailure != null ? onSubmissionFailure : onRequestFailure;
38540
+ var _useState7 = React.useState(false),
38541
+ _useState8 = _slicedToArray(_useState7, 2),
38542
+ resubmitting = _useState8[0],
38543
+ setResubmitting = _useState8[1];
38420
38544
  var lastArtifactsRef = React.useRef(null);
38421
38545
  var submitInFlightRef = React.useRef(null);
38422
38546
  var resubmitInFlightRef = React.useRef(null);
@@ -38434,6 +38558,65 @@ function SubmissionProvider(_ref) {
38434
38558
  }) : incoming;
38435
38559
  // Store the merged artifacts so a resubmit carries location too.
38436
38560
  lastArtifactsRef.current = artifacts;
38561
+ if (mode !== undefined) {
38562
+ // Registered before anything customer-supplied runs, so a throw from
38563
+ // a notification can never leave the flow without a status.
38564
+ setAttempt(_extends({}, IDLE_ATTEMPT, {
38565
+ status: SubmissionStatus.SUBMITTING
38566
+ }));
38567
+ notifySafely('onSubmissionStarted', function () {
38568
+ return onSubmissionStarted == null ? void 0 : onSubmissionStarted(artifacts);
38569
+ });
38570
+ var _unbindProgress = bindSubmissionObserver(artifacts, progress);
38571
+ var _promise = runAttempt(client, mode, artifacts, _extends({}, options, {
38572
+ action: action
38573
+ })).then(function (outcome) {
38574
+ setAttempt(_extends({}, outcome, {
38575
+ status: SubmissionStatus.SUBMITTED,
38576
+ error: null
38577
+ }));
38578
+ var response = outcome.response,
38579
+ request = outcome.request;
38580
+ if (response === null) {
38581
+ // Terminal once called; the handler is never awaited.
38582
+ if (typeof mode === 'object') {
38583
+ notifySafely('submitMode.handoff', function () {
38584
+ return mode.handoff(request);
38585
+ });
38586
+ }
38587
+ return null;
38588
+ }
38589
+ notifySafely('onComplete', function () {
38590
+ return onComplete == null ? void 0 : onComplete(response);
38591
+ });
38592
+ if (isApprovedResponse(action, response)) {
38593
+ notifySafely('onApproved', function () {
38594
+ return onApproved == null ? void 0 : onApproved(response);
38595
+ });
38596
+ } else {
38597
+ notifySafely('onDenied', function () {
38598
+ return onDenied == null ? void 0 : onDenied(response);
38599
+ });
38600
+ }
38601
+ return response;
38602
+ }, function (cause) {
38603
+ var error = cause instanceof Error ? cause : new Error(String(cause));
38604
+ setAttempt(_extends({}, IDLE_ATTEMPT, {
38605
+ status: SubmissionStatus.FAILED,
38606
+ error: error
38607
+ }));
38608
+ notifySafely('onSubmissionFailure', function () {
38609
+ return reportFailure == null ? void 0 : reportFailure(error);
38610
+ });
38611
+ throw error;
38612
+ })["finally"](function () {
38613
+ _unbindProgress();
38614
+ submitInFlightRef.current = null;
38615
+ setResubmitting(false);
38616
+ });
38617
+ submitInFlightRef.current = _promise;
38618
+ return _promise;
38619
+ }
38437
38620
  setSubmissionResponse(null);
38438
38621
  setLocalError(null);
38439
38622
  onSubmissionStarted == null || onSubmissionStarted(artifacts);
@@ -38454,7 +38637,7 @@ function SubmissionProvider(_ref) {
38454
38637
  })["catch"](function (cause) {
38455
38638
  var error = cause instanceof Error ? cause : new Error(String(cause));
38456
38639
  setLocalError(error);
38457
- onRequestFailure == null || onRequestFailure(error);
38640
+ reportFailure == null || reportFailure(error);
38458
38641
  throw error;
38459
38642
  })["finally"](function () {
38460
38643
  unbindProgress();
@@ -38463,7 +38646,7 @@ function SubmissionProvider(_ref) {
38463
38646
  });
38464
38647
  submitInFlightRef.current = promise;
38465
38648
  return promise;
38466
- }, [action, client, geolocation, onApproved, onComplete, onDenied, onRequestFailure, onSubmissionStarted, options, progress]);
38649
+ }, [action, client, geolocation, onApproved, onComplete, onDenied, reportFailure, onSubmissionStarted, options, progress, mode]);
38467
38650
  var resubmit = React.useMemo(function () {
38468
38651
  if (!authState.session.canRefreshSession) return null;
38469
38652
  return function () {
@@ -38508,22 +38691,121 @@ function SubmissionProvider(_ref) {
38508
38691
  }, [authState.session.canRefreshSession, client, submit]);
38509
38692
  var value = React.useMemo(function () {
38510
38693
  var _ref3, _clientState$lastSubm, _clientState$lastSubm2;
38694
+ if (mode !== undefined) {
38695
+ return {
38696
+ action: action,
38697
+ submit: submit,
38698
+ submissionStatus: resubmitting ? SubmissionStatus.SUBMITTING : attempt.status,
38699
+ submissionResponse: attempt.response,
38700
+ submissionError: attempt.error,
38701
+ lastSubmissionTimings: attempt.timings,
38702
+ lastSubmissionRequest: attempt.request,
38703
+ resubmit: resubmit
38704
+ };
38705
+ }
38511
38706
  return {
38512
38707
  action: action,
38513
38708
  submit: submit,
38514
- submissionStatus: resubmitting ? SubmissionStatus.SUBMITTING : clientState.submissionStatus,
38709
+ // A rejection before the client records anything (an unsupported
38710
+ // action, an unvalidated session) leaves the client at READY, which the
38711
+ // wizard renders as its submitting screen; the local error is the
38712
+ // failure it would otherwise never show.
38713
+ submissionStatus: resubmitting ? SubmissionStatus.SUBMITTING : localError && clientState.submissionStatus === SubmissionStatus.READY ? SubmissionStatus.FAILED : clientState.submissionStatus,
38515
38714
  submissionResponse: submissionResponse,
38516
38715
  submissionError: (_ref3 = localError != null ? localError : clientState.submissionError) != null ? _ref3 : null,
38517
38716
  lastSubmissionTimings: (_clientState$lastSubm = clientState.lastSubmissionTimings) != null ? _clientState$lastSubm : null,
38518
38717
  lastSubmissionRequest: (_clientState$lastSubm2 = clientState.lastSubmissionRequest) != null ? _clientState$lastSubm2 : null,
38519
38718
  resubmit: resubmit
38520
38719
  };
38521
- }, [action, clientState.lastSubmissionRequest, clientState.lastSubmissionTimings, clientState.submissionError, clientState.submissionStatus, localError, resubmit, resubmitting, submissionResponse, submit]);
38720
+ }, [action, attempt, clientState.lastSubmissionRequest, clientState.lastSubmissionTimings, clientState.submissionError, clientState.submissionStatus, localError, mode, resubmit, resubmitting, submissionResponse, submit]);
38522
38721
  return jsxRuntime.jsx(SubmissionContext.Provider, {
38523
38722
  value: value,
38524
38723
  children: children
38525
38724
  });
38526
38725
  }
38726
+ var IDLE_ATTEMPT = {
38727
+ status: SubmissionStatus.READY,
38728
+ response: null,
38729
+ request: null,
38730
+ timings: null,
38731
+ error: null
38732
+ };
38733
+ /**
38734
+ * One explicit-mode attempt through the client's `post()` or `handoff()`.
38735
+ * Never falls back to `submit()`: that would let the deprecated
38736
+ * `config.onSubmit` decide what an explicit mode already decided.
38737
+ */
38738
+ function runAttempt(_x, _x2, _x3, _x4) {
38739
+ return _runAttempt.apply(this, arguments);
38740
+ }
38741
+ function _runAttempt() {
38742
+ _runAttempt = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2(client, mode, artifacts, options) {
38743
+ var _yield$client$handoff, request, timings;
38744
+ return _regeneratorRuntime.wrap(function (_context2) {
38745
+ while (1) switch (_context2.prev = _context2.next) {
38746
+ case 0:
38747
+ if (!(mode === 'capture')) {
38748
+ _context2.next = 1;
38749
+ break;
38750
+ }
38751
+ throw new Error("submitMode 'capture' does not submit; the flow reports onCaptured instead");
38752
+ case 1:
38753
+ if (!(mode === 'post')) {
38754
+ _context2.next = 3;
38755
+ break;
38756
+ }
38757
+ if (client.post) {
38758
+ _context2.next = 2;
38759
+ break;
38760
+ }
38761
+ throw missingMethod('post', "submitMode 'post'");
38762
+ case 2:
38763
+ return _context2.abrupt("return", client.post(artifacts, options));
38764
+ case 3:
38765
+ if (client.handoff) {
38766
+ _context2.next = 4;
38767
+ break;
38768
+ }
38769
+ throw missingMethod('handoff', 'submitMode { handoff }');
38770
+ case 4:
38771
+ _context2.next = 5;
38772
+ return client.handoff(artifacts, options);
38773
+ case 5:
38774
+ _yield$client$handoff = _context2.sent;
38775
+ request = _yield$client$handoff.request;
38776
+ timings = _yield$client$handoff.timings;
38777
+ return _context2.abrupt("return", {
38778
+ request: request,
38779
+ timings: timings,
38780
+ response: null
38781
+ });
38782
+ case 6:
38783
+ case "end":
38784
+ return _context2.stop();
38785
+ }
38786
+ }, _callee2);
38787
+ }));
38788
+ return _runAttempt.apply(this, arguments);
38789
+ }
38790
+ function missingMethod(method, needs) {
38791
+ return new Error(needs + " needs client." + method + "(), which this client does not have. " + 'Create the client with createIdmissionClient or useIdmissionClient.');
38792
+ }
38793
+ /**
38794
+ * Runs a customer callback whose failure must not change an outcome that is
38795
+ * already settled: a throw or a rejected promise is logged, never rethrown.
38796
+ */
38797
+ function notifySafely(name, notify) {
38798
+ try {
38799
+ var result = notify();
38800
+ if (result instanceof Promise) {
38801
+ result["catch"](function (e) {
38802
+ return warn(name + " rejected", e);
38803
+ });
38804
+ }
38805
+ } catch (e) {
38806
+ warn(name + " threw", e);
38807
+ }
38808
+ }
38527
38809
  function useSubmission() {
38528
38810
  var context = React.useContext(SubmissionContext);
38529
38811
  if (!context) {
@@ -40388,11 +40670,12 @@ function RemoteDiagnosticsMount(_ref) {
40388
40670
  }
40389
40671
 
40390
40672
  var _templateObject$1, _templateObject2$1, _templateObject3, _templateObject4;
40391
- var _excluded$9 = ["client", "action", "submission", "theme", "className", "geolocationEnabled", "geolocationRequired", "captureProgress", "remoteDiagnostics", "loadingSpinner", "showEnrollmentId", "lang", "children"];
40673
+ var _excluded$9 = ["client", "action", "submission", "submitMode", "theme", "className", "geolocationEnabled", "geolocationRequired", "captureProgress", "remoteDiagnostics", "loadingSpinner", "showEnrollmentId", "lang", "children"];
40392
40674
  function FlowChassis(_ref) {
40393
40675
  var client = _ref.client,
40394
40676
  action = _ref.action,
40395
40677
  submission = _ref.submission,
40678
+ submitMode = _ref.submitMode,
40396
40679
  _ref$theme = _ref.theme,
40397
40680
  theme = _ref$theme === void 0 ? 'default' : _ref$theme,
40398
40681
  className = _ref.className,
@@ -40415,7 +40698,7 @@ function FlowChassis(_ref) {
40415
40698
  client: client,
40416
40699
  children: [jsxRuntime.jsx(RemoteDiagnosticsMount, {
40417
40700
  remoteDiagnostics: remoteDiagnostics
40418
- }), jsxRuntime.jsx(FlowLanguage, {
40701
+ }), jsxRuntime.jsx(SdkLanguageProvider, {
40419
40702
  lang: lang,
40420
40703
  children: jsxRuntime.jsx(ThemeProvider, {
40421
40704
  theme: theme,
@@ -40425,6 +40708,7 @@ function FlowChassis(_ref) {
40425
40708
  client: client,
40426
40709
  action: action,
40427
40710
  options: submission,
40711
+ mode: submitMode,
40428
40712
  geolocation: geolocation.position
40429
40713
  }, callbacks, {
40430
40714
  children: jsxRuntime.jsx(FlowPage, {
@@ -40443,17 +40727,8 @@ function FlowChassis(_ref) {
40443
40727
  })
40444
40728
  });
40445
40729
  }
40446
- /** Scopes the flow's own screens to `lang`; a no-op when the flow sets none. */
40447
- function FlowLanguage(_ref2) {
40448
- var lang = _ref2.lang,
40449
- children = _ref2.children;
40450
- return lang === undefined ? children : jsxRuntime.jsx(SdkLanguageProvider, {
40451
- lang: lang,
40452
- children: children
40453
- });
40454
- }
40455
- function AuthGate(_ref3) {
40456
- var children = _ref3.children;
40730
+ function AuthGate(_ref2) {
40731
+ var children = _ref2.children;
40457
40732
  var _useAuthState = useAuthState(),
40458
40733
  state = _useAuthState.state,
40459
40734
  retry = _useAuthState.retry;
@@ -40504,10 +40779,10 @@ function AuthGate(_ref3) {
40504
40779
  * enrollment-ID banner sits outside that body, so stages and their in-body
40505
40780
  * overlays lay out below it instead of over it.
40506
40781
  */
40507
- function FlowPage(_ref4) {
40508
- var className = _ref4.className,
40509
- enrollmentId = _ref4.enrollmentId,
40510
- children = _ref4.children;
40782
+ function FlowPage(_ref3) {
40783
+ var className = _ref3.className,
40784
+ enrollmentId = _ref3.enrollmentId,
40785
+ children = _ref3.children;
40511
40786
  var _useTheme = styledComponents.useTheme(),
40512
40787
  Header = _useTheme.header,
40513
40788
  Footer = _useTheme.footer;
@@ -40617,8 +40892,8 @@ function impliedSkipSuccessScreen(explicit, introActive) {
40617
40892
  */
40618
40893
  function inheritFlowSettings(step, flow) {
40619
40894
  var inherited = {};
40620
- for (var _i = 0, _Object$keys = Object.keys(flow); _i < _Object$keys.length; _i++) {
40621
- var key = _Object$keys[_i];
40895
+ for (var key in flow) {
40896
+ if (!Object.prototype.hasOwnProperty.call(flow, key)) continue;
40622
40897
  if ((step == null ? void 0 : step[key]) === undefined && flow[key] !== undefined) {
40623
40898
  inherited[key] = flow[key];
40624
40899
  }
@@ -40754,7 +41029,7 @@ function withVirtualCameras(camera, allowVirtualCameras) {
40754
41029
  return base;
40755
41030
  }
40756
41031
 
40757
- 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"];
41032
+ 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"];
40758
41033
  var EMPTY_ID_CAPTURE$3 = {};
40759
41034
  var EMPTY_SIGNATURE_CAPTURE$5 = {};
40760
41035
  var EMPTY_ID_VIEW$3 = {};
@@ -40771,8 +41046,8 @@ function IdValidationFlow(_ref) {
40771
41046
  submission = _ref$submission === void 0 ? EMPTY_SUBMISSION$6 : _ref$submission,
40772
41047
  _ref$initialArtifacts = _ref.initialArtifacts,
40773
41048
  initialArtifacts = _ref$initialArtifacts === void 0 ? EMPTY_ARTIFACTS$9 : _ref$initialArtifacts,
40774
- _ref$captureOnly = _ref.captureOnly,
40775
- captureOnly = _ref$captureOnly === void 0 ? false : _ref$captureOnly,
41049
+ submitMode = _ref.submitMode,
41050
+ captureOnly = _ref.captureOnly,
40776
41051
  signatureController = _ref.signatureController,
40777
41052
  _ref$signatureCapture = _ref.signatureCapture,
40778
41053
  signatureCapture = _ref$signatureCapture === void 0 ? EMPTY_SIGNATURE_CAPTURE$5 : _ref$signatureCapture,
@@ -40931,10 +41206,12 @@ function IdValidationFlow(_ref) {
40931
41206
  successIssuerCaptionText: 'confirmed'
40932
41207
  }
40933
41208
  });
41209
+ var mode = submitMode != null ? submitMode : captureOnly ? 'capture' : undefined;
40934
41210
  return jsxRuntime.jsxs(FlowChassis, _extends({
40935
41211
  client: client,
40936
41212
  action: SubmissionAction.VALIDATE,
40937
41213
  submission: submission,
41214
+ submitMode: mode,
40938
41215
  theme: theme,
40939
41216
  className: className,
40940
41217
  lang: lang
@@ -40942,7 +41219,7 @@ function IdValidationFlow(_ref) {
40942
41219
  children: [jsxRuntime.jsx(CompositeWizard, _extends({}, ringScreens, {
40943
41220
  steps: steps,
40944
41221
  initialArtifacts: initialArtifacts,
40945
- captureOnly: captureOnly,
41222
+ captureOnly: mode === 'capture',
40946
41223
  showResultScreen: showResultScreen != null ? showResultScreen : showSuccessScreen,
40947
41224
  showDiagnostics: showDiagnostics,
40948
41225
  onArtifactsCollected: onCaptured,
@@ -41402,6 +41679,10 @@ function SignatureKYCFlow(_ref) {
41402
41679
  captureProgress = _ref.captureProgress,
41403
41680
  remoteDiagnostics = _ref.remoteDiagnostics,
41404
41681
  loadingSpinner = _ref.loadingSpinner,
41682
+ _ref$submitMode = _ref.submitMode,
41683
+ submitMode = _ref$submitMode === void 0 ? 'capture' : _ref$submitMode,
41684
+ onSubmissionStarted = _ref.onSubmissionStarted,
41685
+ onSubmissionFailure = _ref.onSubmissionFailure,
41405
41686
  onCaptured = _ref.onCaptured,
41406
41687
  onCaptureError = _ref.onCaptureError;
41407
41688
  // Flow-wide settings reach each step unless its own bag sets them.
@@ -41602,8 +41883,8 @@ function SignatureKYCFlow(_ref) {
41602
41883
  completedRef.current = true;
41603
41884
  artifactsRef.current = mergeSubmissionArtifacts(artifactsRef.current, artifacts);
41604
41885
  setStage('complete');
41605
- onCaptured == null || onCaptured(artifactsRef.current);
41606
- }, [onCaptured]);
41886
+ if (submitMode === 'capture') onCaptured == null || onCaptured(artifactsRef.current);
41887
+ }, [onCaptured, submitMode]);
41607
41888
  var handleLivenessFailureExit = React.useCallback(function () {
41608
41889
  onExitAfterLivenessFailure == null || onExitAfterLivenessFailure();
41609
41890
  if (allowSignatureAfterLivenessCheckFailure) handleLivenessDone();
@@ -41612,6 +41893,9 @@ function SignatureKYCFlow(_ref) {
41612
41893
  client: client,
41613
41894
  action: SubmissionAction.NONE,
41614
41895
  submission: submission,
41896
+ submitMode: submitMode,
41897
+ onSubmissionStarted: onSubmissionStarted,
41898
+ onSubmissionFailure: onSubmissionFailure,
41615
41899
  theme: theme,
41616
41900
  className: className,
41617
41901
  lang: lang,
@@ -41621,8 +41905,10 @@ function SignatureKYCFlow(_ref) {
41621
41905
  remoteDiagnostics: remoteDiagnostics,
41622
41906
  loadingSpinner: loadingSpinner,
41623
41907
  children: [jsxRuntime.jsx(CaptureProgressCompletion, {
41624
- completed: stage === 'complete'
41625
- }), stage !== 'complete' ? jsxRuntime.jsxs(HandoffRoot, {
41908
+ completed: stage === 'complete' && submitMode === 'capture'
41909
+ }), stage === 'complete' && submitMode !== 'capture' ? jsxRuntime.jsx(SignatureHandoff, {
41910
+ artifacts: artifactsRef.current
41911
+ }) : null, stage !== 'complete' ? jsxRuntime.jsxs(HandoffRoot, {
41626
41912
  children: [jsxRuntime.jsx(SignatureCaptureView, _extends({}, signatureView, {
41627
41913
  skipSuccessScreen: impliedSkipSuccessScreen(signatureView.skipSuccessScreen, isRingIntroActive(faceView)),
41628
41914
  controller: resolvedSignatureController,
@@ -41672,6 +41958,44 @@ function SignatureKYCFlow(_ref) {
41672
41958
  }) : null]
41673
41959
  });
41674
41960
  }
41961
+ /**
41962
+ * Hands the finished capture off once the session has passed: a finishing
41963
+ * screen while the request is built, a retry screen if that fails, and
41964
+ * nothing once it has been handed off.
41965
+ */
41966
+ function SignatureHandoff(_ref3) {
41967
+ var artifacts = _ref3.artifacts;
41968
+ var _useSubmission = useSubmission(),
41969
+ action = _useSubmission.action,
41970
+ submit = _useSubmission.submit,
41971
+ submissionStatus = _useSubmission.submissionStatus,
41972
+ submissionError = _useSubmission.submissionError;
41973
+ var sessionReady = useSessionReady();
41974
+ var startedRef = React.useRef(false);
41975
+ // The provider reports a failure itself; these catches only keep the
41976
+ // rejection from going unhandled.
41977
+ React.useEffect(function () {
41978
+ if (!sessionReady || startedRef.current) return;
41979
+ startedRef.current = true;
41980
+ submit(artifacts)["catch"](function () {});
41981
+ }, [artifacts, sessionReady, submit]);
41982
+ if (submissionStatus === SubmissionStatus.SUBMITTED) return null;
41983
+ if (submissionStatus === SubmissionStatus.FAILED) {
41984
+ return jsxRuntime.jsx(SubmissionErrorOverlay, {
41985
+ error: submissionError,
41986
+ onRetry: function onRetry() {
41987
+ submit(artifacts)["catch"](function () {});
41988
+ }
41989
+ });
41990
+ }
41991
+ var text = submissionStatusText(action, artifacts);
41992
+ return jsxRuntime.jsx(OrbStatusScreen, {
41993
+ state: "working",
41994
+ text: text,
41995
+ accessibleLabel: text,
41996
+ loadingStage: "submission"
41997
+ });
41998
+ }
41675
41999
  /**
41676
42000
  * Black, so iOS Safari's bars read as letterboxing around the camera feed
41677
42001
  * rather than as one more colour a theme has to choose.
@@ -41689,10 +42013,10 @@ var CAMERA_EDGE_COLOR = '#000';
41689
42013
  * no flat strip can sit on its bottom edge unseen: that one is drawn invisibly,
41690
42014
  * as on ID capture's overlay. Opaque, it covered the bottom 12px of the bar.
41691
42015
  */
41692
- function FlowEdgeTint(_ref3) {
42016
+ function FlowEdgeTint(_ref4) {
41693
42017
  var _theme$selfieCapture$, _theme$selfieCapture, _theme$background;
41694
- var surface = _ref3.surface,
41695
- modelsReady = _ref3.modelsReady;
42018
+ var surface = _ref4.surface,
42019
+ modelsReady = _ref4.modelsReady;
41696
42020
  var theme = styledComponents.useTheme();
41697
42021
  if (theme.isFullscreen === false || surface === null) return null;
41698
42022
  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');
@@ -41702,9 +42026,9 @@ function FlowEdgeTint(_ref3) {
41702
42026
  hiddenBottomColor: surface === 'overlay' ? selfieLoadingOverlayBottomEdgeColor(theme, modelsReady) : undefined
41703
42027
  });
41704
42028
  }
41705
- function SelfieTrackerAttachment(_ref4) {
41706
- var controller = _ref4.controller,
41707
- video = _ref4.video;
42029
+ function SelfieTrackerAttachment(_ref5) {
42030
+ var controller = _ref5.controller,
42031
+ video = _ref5.video;
41708
42032
  React.useEffect(function () {
41709
42033
  if (!video) return;
41710
42034
  void controller.attach(video)["catch"](function () {
@@ -41722,7 +42046,7 @@ var FaceStage = styledComponents.styled.div(_templateObject2 || (_templateObject
41722
42046
  return props.$visible ? 'block' : 'none';
41723
42047
  });
41724
42048
 
41725
- 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"],
42049
+ 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"],
41726
42050
  _excluded2$2 = ["checkLivenessOptions"];
41727
42051
  var EMPTY_ID_CAPTURE$1 = {};
41728
42052
  var EMPTY_FACE_CAPTURE$2 = {};
@@ -41755,8 +42079,8 @@ function VideoIdValidationFlow(_ref) {
41755
42079
  submission = _ref$submission === void 0 ? EMPTY_SUBMISSION$2 : _ref$submission,
41756
42080
  _ref$initialArtifacts = _ref.initialArtifacts,
41757
42081
  initialArtifacts = _ref$initialArtifacts === void 0 ? EMPTY_ARTIFACTS$5 : _ref$initialArtifacts,
41758
- _ref$captureOnly = _ref.captureOnly,
41759
- captureOnly = _ref$captureOnly === void 0 ? false : _ref$captureOnly,
42082
+ submitMode = _ref.submitMode,
42083
+ captureOnly = _ref.captureOnly,
41760
42084
  signatureController = _ref.signatureController,
41761
42085
  _ref$signatureCapture = _ref.signatureCapture,
41762
42086
  signatureCapture = _ref$signatureCapture === void 0 ? EMPTY_SIGNATURE_CAPTURE$2 : _ref$signatureCapture,
@@ -41974,10 +42298,12 @@ function VideoIdValidationFlow(_ref) {
41974
42298
  successIssuerCaptionText: 'confirmed'
41975
42299
  }
41976
42300
  });
42301
+ var mode = submitMode != null ? submitMode : captureOnly ? 'capture' : undefined;
41977
42302
  return jsxRuntime.jsxs(FlowChassis, _extends({
41978
42303
  client: client,
41979
42304
  action: action,
41980
42305
  submission: submission,
42306
+ submitMode: mode,
41981
42307
  theme: theme,
41982
42308
  className: className,
41983
42309
  lang: lang
@@ -41985,7 +42311,7 @@ function VideoIdValidationFlow(_ref) {
41985
42311
  children: [jsxRuntime.jsx(CompositeWizard, _extends({}, ringScreens, {
41986
42312
  steps: steps,
41987
42313
  initialArtifacts: initialArtifacts,
41988
- captureOnly: captureOnly,
42314
+ captureOnly: mode === 'capture',
41989
42315
  showResultScreen: showResultScreen != null ? showResultScreen : showSuccessScreen,
41990
42316
  showDiagnostics: showDiagnostics,
41991
42317
  onArtifactsCollected: onCaptured,
@@ -46196,7 +46522,9 @@ function CustomerMatchFlow(_ref) {
46196
46522
  onComplete = _ref.onComplete,
46197
46523
  onCustomerMatched = _ref.onCustomerMatched,
46198
46524
  onCustomerNotMatched = _ref.onCustomerNotMatched,
46525
+ onSubmissionFailure = _ref.onSubmissionFailure,
46199
46526
  onRequestFailure = _ref.onRequestFailure,
46527
+ submitMode = _ref.submitMode,
46200
46528
  onCaptureGuidanceTimeout = _ref.onCaptureGuidanceTimeout,
46201
46529
  onExitCapture = _ref.onExitCapture,
46202
46530
  onExitAfterFailure = _ref.onExitAfterFailure;
@@ -46283,15 +46611,19 @@ function CustomerMatchFlow(_ref) {
46283
46611
  setOutcome('notMatched');
46284
46612
  onCustomerNotMatched == null || onCustomerNotMatched(response);
46285
46613
  }, [onCustomerNotMatched]);
46614
+ var reportFailure = onSubmissionFailure != null ? onSubmissionFailure : onRequestFailure;
46286
46615
  var handleLivenessCheckFailed = React.useCallback(function (error) {
46287
46616
  setOutcome('failed');
46288
- onRequestFailure == null || onRequestFailure(error);
46289
- }, [onRequestFailure]);
46617
+ reportFailure == null || reportFailure(error);
46618
+ }, [reportFailure]);
46290
46619
  var handleRequestError = React.useCallback(function (error) {
46291
46620
  errorRef.current = error;
46292
46621
  setOutcome('error');
46293
- onRequestFailure == null || onRequestFailure(error);
46294
- }, [onRequestFailure]);
46622
+ reportFailure == null || reportFailure(error);
46623
+ }, [reportFailure]);
46624
+ var handleHandedOff = React.useCallback(function () {
46625
+ return setOutcome('handedOff');
46626
+ }, []);
46295
46627
  var handleCaptureGuidanceTimeout = React.useCallback(function () {
46296
46628
  setOutcome('failed');
46297
46629
  onCaptureGuidanceTimeout == null || onCaptureGuidanceTimeout();
@@ -46332,6 +46664,7 @@ function CustomerMatchFlow(_ref) {
46332
46664
  client: client,
46333
46665
  action: action,
46334
46666
  submission: submission,
46667
+ submitMode: submitMode,
46335
46668
  theme: theme,
46336
46669
  className: className,
46337
46670
  lang: lang,
@@ -46356,6 +46689,7 @@ function CustomerMatchFlow(_ref) {
46356
46689
  onNotMatched: handleNotMatched,
46357
46690
  onLivenessCheckFailed: handleLivenessCheckFailed,
46358
46691
  onRequestError: handleRequestError,
46692
+ onSubmissionIntercepted: handleHandedOff,
46359
46693
  onCaptureGuidanceTimeout: handleCaptureGuidanceTimeout,
46360
46694
  onExitCapture: onExitCapture,
46361
46695
  finishingScreen: {
@@ -46491,6 +46825,84 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
46491
46825
  return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
46492
46826
  };
46493
46827
 
46828
+ function createIdAndFaceValidationJourneyEvent(event, now) {
46829
+ if (now === void 0) {
46830
+ now = function now() {
46831
+ return new Date();
46832
+ };
46833
+ }
46834
+ return _assign(_assign({}, event), {
46835
+ version: 1,
46836
+ flow: 'id-and-face-validation',
46837
+ timestamp: now().toISOString()
46838
+ });
46839
+ }
46840
+ /**
46841
+ * websdk-ui `CompositeWizardStep.id` -> journey stage.
46842
+ *
46843
+ * Four of the five stage names ARE step ids already; only the additional-
46844
+ * documents step differs, because sdk2's stage vocabulary says
46845
+ * `additional-document-capture` (singular "document") while websdk-ui's step
46846
+ * is `additional-documents`. Unknown ids return undefined so a step this
46847
+ * vocabulary has no name for is silently skipped rather than emitted with a
46848
+ * bogus stage — the same shape as sdk2's partial lookup record.
46849
+ */
46850
+ function journeyStageForStepId(stepId) {
46851
+ switch (stepId) {
46852
+ case 'id-capture':
46853
+ case 'face-liveness':
46854
+ case 'signature-capture':
46855
+ case 'video-signature-capture':
46856
+ return stepId;
46857
+ case 'additional-documents':
46858
+ return 'additional-document-capture';
46859
+ default:
46860
+ return undefined;
46861
+ }
46862
+ }
46863
+ /**
46864
+ * The document types sdk2 reports as `document.captured`. sdk2 filters the
46865
+ * wizard's `onDocumentStored` through this set (`primaryIdDocumentTypes`) so
46866
+ * that a document type outside the journey vocabulary cannot widen the event.
46867
+ * Kept as a predicate rather than a Set: the ES5 UMD bundle target makes
46868
+ * `for..of` over a Set a downlevel hazard, and a switch needs no iteration.
46869
+ */
46870
+ function isJourneyDocumentType(documentType) {
46871
+ return documentType === 'idCardFront' || documentType === 'idCardBack' || documentType === 'passport' || documentType === 'singlePage';
46872
+ }
46873
+ /**
46874
+ * The lazy `flow.started` rule, lifted out of sdk2's `emitJourneyEvent`
46875
+ * closure (IdAndFaceValidation.tsx:521-537) so it can be tested without a
46876
+ * React tree.
46877
+ *
46878
+ * sdk2 does NOT simply emit `flow.started` from a mount effect: it emits it
46879
+ * before the FIRST event of any kind, whatever that event is, and then
46880
+ * suppresses the explicit mount emit. The mount effect and the lazy guard
46881
+ * together mean `flow.started` is always the first event a customer sees,
46882
+ * even if some other event races the effect. That ordering guarantee is the
46883
+ * contract, not the effect.
46884
+ */
46885
+ function createJourneyEmitter(callback, now) {
46886
+ var flowStartedEmitted = false;
46887
+ return function emit(event) {
46888
+ if (!callback) return;
46889
+ if (!flowStartedEmitted) {
46890
+ flowStartedEmitted = true;
46891
+ emitWith(callback, {
46892
+ name: 'flow.started'
46893
+ }, now);
46894
+ }
46895
+ if (event.name !== 'flow.started') emitWith(callback, event, now);
46896
+ };
46897
+ }
46898
+ function emitWith(callback, event, now) {
46899
+ try {
46900
+ callback(createIdAndFaceValidationJourneyEvent(event, now));
46901
+ } catch (error) {
46902
+ warn$1('[IdAndFaceValidation] onJourneyEvent callback failed', error);
46903
+ }
46904
+ }
46905
+
46494
46906
  /**
46495
46907
  * sdk2 exports this as a mutable `string[]`
46496
46908
  * (contexts/AuthStateContext.tsx:25), not a readonly tuple — copied rather
@@ -46663,12 +47075,9 @@ function mapClientConfig(props) {
46663
47075
  documentServiceUrl: (_b = props.documentServiceUrl) !== null && _b !== void 0 ? _b : apiBase ? apiBase + '/files/' : override === null || override === void 0 ? void 0 : override.documentServiceUrl,
46664
47076
  onBeforeSubmit: props.onBeforeSubmit,
46665
47077
  onBeforeLivenessCheck: props.onBeforeLivenessCheck,
46666
- // Straight through to the client, which is where sdk2 put it too
46667
- // (SubmissionProvider.submit). That is what makes the SUPPRESSION uniform:
46668
- // every flow — including the two match flows, which own their own stage
46669
- // machine — submits through this one client, so none of them can post
46670
- // behind an integrator who supplied `onSubmit`.
46671
- onSubmit: props.onSubmit,
47078
+ // 2.x's `onSubmit` is not a client option here: each flow maps it to its
47079
+ // own `submitMode: { handoff }` (see ./props.ts), which follows the prop
47080
+ // live where a client option would be fixed at mount.
46672
47081
  onBeforeDocumentUpload: props.onBeforeDocumentUpload,
46673
47082
  onDocumentUploadProgress: props.onDocumentUploadProgress,
46674
47083
  onDocumentUploaded: props.onDocumentUploaded,
@@ -47678,84 +48087,6 @@ function mapFaceCapture(props, prefixed) {
47678
48087
  };
47679
48088
  }
47680
48089
 
47681
- function createIdAndFaceValidationJourneyEvent(event, now) {
47682
- if (now === void 0) {
47683
- now = function now() {
47684
- return new Date();
47685
- };
47686
- }
47687
- return _assign(_assign({}, event), {
47688
- version: 1,
47689
- flow: 'id-and-face-validation',
47690
- timestamp: now().toISOString()
47691
- });
47692
- }
47693
- /**
47694
- * websdk-ui `CompositeWizardStep.id` -> journey stage.
47695
- *
47696
- * Four of the five stage names ARE step ids already; only the additional-
47697
- * documents step differs, because sdk2's stage vocabulary says
47698
- * `additional-document-capture` (singular "document") while websdk-ui's step
47699
- * is `additional-documents`. Unknown ids return undefined so a step this
47700
- * vocabulary has no name for is silently skipped rather than emitted with a
47701
- * bogus stage — the same shape as sdk2's partial lookup record.
47702
- */
47703
- function journeyStageForStepId(stepId) {
47704
- switch (stepId) {
47705
- case 'id-capture':
47706
- case 'face-liveness':
47707
- case 'signature-capture':
47708
- case 'video-signature-capture':
47709
- return stepId;
47710
- case 'additional-documents':
47711
- return 'additional-document-capture';
47712
- default:
47713
- return undefined;
47714
- }
47715
- }
47716
- /**
47717
- * The document types sdk2 reports as `document.captured`. sdk2 filters the
47718
- * wizard's `onDocumentStored` through this set (`primaryIdDocumentTypes`) so
47719
- * that a document type outside the journey vocabulary cannot widen the event.
47720
- * Kept as a predicate rather than a Set: the ES5 UMD bundle target makes
47721
- * `for..of` over a Set a downlevel hazard, and a switch needs no iteration.
47722
- */
47723
- function isJourneyDocumentType(documentType) {
47724
- return documentType === 'idCardFront' || documentType === 'idCardBack' || documentType === 'passport' || documentType === 'singlePage';
47725
- }
47726
- /**
47727
- * The lazy `flow.started` rule, lifted out of sdk2's `emitJourneyEvent`
47728
- * closure (IdAndFaceValidation.tsx:521-537) so it can be tested without a
47729
- * React tree.
47730
- *
47731
- * sdk2 does NOT simply emit `flow.started` from a mount effect: it emits it
47732
- * before the FIRST event of any kind, whatever that event is, and then
47733
- * suppresses the explicit mount emit. The mount effect and the lazy guard
47734
- * together mean `flow.started` is always the first event a customer sees,
47735
- * even if some other event races the effect. That ordering guarantee is the
47736
- * contract, not the effect.
47737
- */
47738
- function createJourneyEmitter(callback, now) {
47739
- var flowStartedEmitted = false;
47740
- return function emit(event) {
47741
- if (!callback) return;
47742
- if (!flowStartedEmitted) {
47743
- flowStartedEmitted = true;
47744
- emitWith(callback, {
47745
- name: 'flow.started'
47746
- }, now);
47747
- }
47748
- if (event.name !== 'flow.started') emitWith(callback, event, now);
47749
- };
47750
- }
47751
- function emitWith(callback, event, now) {
47752
- try {
47753
- callback(createIdAndFaceValidationJourneyEvent(event, now));
47754
- } catch (error) {
47755
- warn$1('[IdAndFaceValidation] onJourneyEvent callback failed', error);
47756
- }
47757
- }
47758
-
47759
48090
  /**
47760
48091
  * Recursively drops keys whose value is exactly `undefined`.
47761
48092
  *
@@ -47938,6 +48269,16 @@ function mapThemeWithColors(theme, colors) {
47938
48269
  return mergeThemes(mapped, overrides);
47939
48270
  }
47940
48271
 
48272
+ /**
48273
+ * 2.x's `onSubmit` as the flow's hand-off. sdk2 read it on every submission,
48274
+ * so this maps on every render: adding or removing it takes effect from the
48275
+ * next submission. Without it the flow posts.
48276
+ */
48277
+ function mapHandoff(onSubmit) {
48278
+ return onSubmit ? {
48279
+ handoff: onSubmit
48280
+ } : undefined;
48281
+ }
47941
48282
  var EMPTY_CONTEXT = {};
47942
48283
  /** Adapts a 3.0 `(response)` callback back to 2.x's `(response, request)`. */
47943
48284
  function withSubmissionRequest(callback, ctx) {
@@ -48029,13 +48370,13 @@ function mapAdditionalDocumentVerbiage(verbiage) {
48029
48370
  }
48030
48371
  // --- 1. IdValidation ------------------------------------------------------
48031
48372
  function mapIdValidationProps(props, ctx) {
48032
- var _a;
48373
+ var _a, _b;
48033
48374
  if (ctx === void 0) {
48034
48375
  ctx = EMPTY_CONTEXT;
48035
48376
  }
48036
- var _b = mapIdCapture(props),
48037
- capture = _b.capture,
48038
- view = _b.view;
48377
+ var _c = mapIdCapture(props),
48378
+ capture = _c.capture,
48379
+ view = _c.view;
48039
48380
  return compact({
48040
48381
  capture: capture,
48041
48382
  view: view,
@@ -48061,9 +48402,8 @@ function mapIdValidationProps(props, ctx) {
48061
48402
  // `onSubmit` WINS over capture-only, matching sdk2's ordering: its
48062
48403
  // `submit()` checks `onSubmit` before the `action === NONE` branch
48063
48404
  // (SubmissionProvider.tsx:1374 vs :1237), so a capture-only flow still
48064
- // owes the callback its built request. Letting the flow run its normal
48065
- // submit path is what builds that request; the client suppresses the POST.
48066
- captureOnly: props.onSubmit ? undefined : props.captureOnly,
48405
+ // owes the callback its built request.
48406
+ submitMode: (_b = mapHandoff(props.onSubmit)) !== null && _b !== void 0 ? _b : props.captureOnly ? 'capture' : undefined,
48067
48407
  captureAdditionalDocuments: props.captureAdditionalDocuments,
48068
48408
  geolocationEnabled: props.geolocationEnabled,
48069
48409
  geolocationRequired: props.geolocationRequired,
@@ -48084,13 +48424,10 @@ function mapIdValidationProps(props, ctx) {
48084
48424
  // would be a NEW restriction, not parity.
48085
48425
  showResultScreen: props.debugMode,
48086
48426
  showDiagnostics: props.debugMode,
48087
- // `onSubmit` is NOT mapped to a flow prop: it goes to the client config
48088
- // (see mapClientConfig), which is the layer sdk2 put it at and the only
48089
- // one that can suppress the POST for every flow at once.
48090
48427
  onComplete: withSubmissionRequest(props.onComplete, ctx),
48091
48428
  onApproved: withSubmissionRequest(props.onApproved, ctx),
48092
48429
  onDenied: withSubmissionRequest(props.onDenied, ctx),
48093
- onRequestFailure: props.onRequestFailure
48430
+ onSubmissionFailure: props.onRequestFailure
48094
48431
  });
48095
48432
  }
48096
48433
  // --- 2. FaceValidation ----------------------------------------------------
@@ -48282,7 +48619,8 @@ function mapIdAndFaceValidationProps(props, ctx) {
48282
48619
  onComplete: withSubmissionRequest(props.onComplete, ctx),
48283
48620
  onApproved: withSubmissionRequest(props.onApproved, ctx),
48284
48621
  onDenied: withSubmissionRequest(props.onDenied, ctx),
48285
- onRequestFailure: props.onRequestFailure,
48622
+ submitMode: mapHandoff(props.onSubmit),
48623
+ onSubmissionFailure: props.onRequestFailure,
48286
48624
  onCaptureError: props.onRequestFailure
48287
48625
  });
48288
48626
  }
@@ -48437,10 +48775,11 @@ function mapSignatureKYCProps(props, ctx) {
48437
48775
  captureProgress: props.captureProgress,
48438
48776
  remoteDiagnostics: props.remoteDiagnostics,
48439
48777
  loadingSpinner: props.loadingSpinner,
48440
- // `onCaptured` is supplied by the COMPONENT, not here: this flow never
48441
- // enters `client.submit()` on its own, so the façade makes that call from
48442
- // `onCaptured` to produce the same built request 2.x hands over. See
48443
- // components/flows.tsx.
48778
+ // 2.x builds this flow's request and hands it to `onSubmit`
48779
+ // (SubmissionProvider.tsx:1374, ahead of its NONE branch). Unset, the
48780
+ // flow captures and posts nothing, as 2.x's NONE did. A failed hand-off
48781
+ // is not reported to `onRequestFailure`, which 2.x never did either.
48782
+ submitMode: mapHandoff(props.onSubmit),
48444
48783
  onCaptureError: props.onRequestFailure
48445
48784
  });
48446
48785
  }
@@ -48466,7 +48805,7 @@ function nestedLayer(nested, map) {
48466
48805
  return map(nested);
48467
48806
  }
48468
48807
  function mapVideoIdValidationProps(props, ctx) {
48469
- var _a, _b, _c;
48808
+ var _a, _b, _c, _d;
48470
48809
  if (ctx === void 0) {
48471
48810
  ctx = EMPTY_CONTEXT;
48472
48811
  }
@@ -48559,7 +48898,11 @@ function mapVideoIdValidationProps(props, ctx) {
48559
48898
  showResultScreen: props.debugMode,
48560
48899
  showDiagnostics: props.debugMode,
48561
48900
  onComplete: withSubmissionRequest(props.onComplete, ctx),
48562
- onRequestFailure: props.onRequestFailure,
48901
+ // No ID captured and none supplied resolves the action to NONE, which
48902
+ // has nothing to post. 2.x answered with a synthetic success and no
48903
+ // request; capture mode is that without the fabricated response.
48904
+ submitMode: (_d = mapHandoff(props.onSubmit)) !== null && _d !== void 0 ? _d : props.skipIdCapture && !props.idCardForFaceMatch ? 'capture' : undefined,
48905
+ onSubmissionFailure: props.onRequestFailure,
48563
48906
  onCaptureError: props.onRequestFailure
48564
48907
  });
48565
48908
  }
@@ -48724,7 +49067,8 @@ function mapCustomerMatchProps(props, ctx) {
48724
49067
  onComplete: withSubmissionRequest(props.onComplete, ctx),
48725
49068
  onCustomerMatched: withSubmissionRequest(props.onCustomerMatched, ctx),
48726
49069
  onCustomerNotMatched: withSubmissionRequest(props.onCustomerNotMatched, ctx),
48727
- onRequestFailure: props.onRequestFailure,
49070
+ submitMode: mapHandoff(props.onSubmit),
49071
+ onSubmissionFailure: props.onRequestFailure,
48728
49072
  onExitCapture: props.onExitCapture,
48729
49073
  onExitAfterFailure: props.onExitAfterFailure
48730
49074
  });
@@ -48793,7 +49137,8 @@ function mapCustomerBiometricsEnrollmentProps(props, ctx) {
48793
49137
  // sdk2's enrollment twin of `onApproved`.
48794
49138
  onApproved: withSubmissionRequest(props.onEnrolled, ctx),
48795
49139
  onDenied: withSubmissionRequest(props.onDenied, ctx),
48796
- onRequestFailure: props.onRequestFailure,
49140
+ submitMode: mapHandoff(props.onSubmit),
49141
+ onSubmissionFailure: props.onRequestFailure,
48797
49142
  onCaptureError: props.onRequestFailure
48798
49143
  });
48799
49144
  }
@@ -48885,12 +49230,13 @@ function mapCustomerIdAndBiometricsEnrollmentProps(props, ctx) {
48885
49230
  onComplete: withSubmissionRequest(props.onComplete, ctx),
48886
49231
  onApproved: withSubmissionRequest(props.onEnrolled, ctx),
48887
49232
  onDenied: withSubmissionRequest(props.onDenied, ctx),
48888
- onRequestFailure: props.onRequestFailure,
49233
+ submitMode: mapHandoff(props.onSubmit),
49234
+ onSubmissionFailure: props.onRequestFailure,
48889
49235
  onCaptureError: props.onRequestFailure
48890
49236
  });
48891
49237
  }
48892
49238
 
48893
- var webSdkVersion = '2.6.3-t3code-shared-flow-settings-07ab804';
49239
+ var webSdkVersion = '2.6.3-t3code-callback-homes-submit-handoff-9690b2d';
48894
49240
 
48895
49241
  // GENERATED by scripts/styleBagTypes.mjs from
48896
49242
  // src/__fixtures__/sdk2StyleBags.json and the mapper sweep — do not
@@ -50947,23 +51293,17 @@ var STYLE_WITH_ASSETS = {
50947
51293
  var SUBMIT_CALLBACKS = {
50948
51294
  onBeforeSubmit: MAPPED,
50949
51295
  /**
50950
- * Mapped to the CLIENT's `onSubmit`, not to a flow prop — the layer sdk2 put
50951
- * it at (SubmissionProvider.submit). The client builds the request, hands it
50952
- * over, and does NOT post, so `onComplete`/`onApproved`/`onDenied` never
50953
- * fire, exactly as 2.x documents. Every flow submits through that one
50954
- * client, including the two match flows with their own stage machine, so the
50955
- * suppression is uniform.
51296
+ * Mapped to the flow's `submitMode: { handoff }`. The flow builds the
51297
+ * request, hands it over, and does NOT post, so `onComplete`/`onApproved`/
51298
+ * `onDenied` never fire, exactly as 2.x documents. Mapped on every render,
51299
+ * so adding or removing it takes effect from the next submission, as sdk2's
51300
+ * ref-held `onSubmit` did.
50956
51301
  *
50957
51302
  * What the flow SHOWS afterwards is a 3.0 call rather than a 2.x
50958
51303
  * reproduction: every family now ends quietly, because the integrator owns
50959
51304
  * the outcome once they have the request. 2.x's match flows showed a failure
50960
51305
  * screen there, but only because their `submit()` could not distinguish an
50961
51306
  * intercepted submission from a broken one.
50962
- *
50963
- * `SignatureKYC` reaches the same place by a different route: its 3.0
50964
- * counterpart never enters `client.submit()`, so the façade component makes
50965
- * that call itself from `onCaptured`. `action: NONE` is accepted there
50966
- * precisely because `onSubmit` is bound.
50967
51307
  */
50968
51308
  onSubmit: MAPPED,
50969
51309
  onComplete: MAPPED,
@@ -51061,7 +51401,7 @@ var SignatureKYC$1 = _assign(_assign(_assign(_assign(_assign(_assign(_assign(_as
51061
51401
  // `SubmissionAction.NONE` and wires `onComplete` to the provider's
51062
51402
  // `onResponseReceived` (SignatureKYC.tsx:434,449), which never fires because
51063
51403
  // nothing is ever posted. `onSubmit` is the real completion seam and IS
51064
- // mapped, to the flow's `onCaptured`.
51404
+ // mapped, to the flow's `submitMode: { handoff }`.
51065
51405
  onComplete: NOOP,
51066
51406
  onSubmit: MAPPED,
51067
51407
  onRequestFailure: MAPPED,
@@ -51552,10 +51892,6 @@ function useCompatClient(props) {
51552
51892
  _lastLivenessRequest.current = request;
51553
51893
  return propsRef.current.onBeforeLivenessCheck ? propsRef.current.onBeforeLivenessCheck(request) : Promise.resolve(request);
51554
51894
  },
51555
- onSubmit: propsRef.current.onSubmit ? function (request) {
51556
- var _a, _b;
51557
- return (_b = (_a = propsRef.current).onSubmit) === null || _b === void 0 ? void 0 : _b.call(_a, request);
51558
- } : undefined,
51559
51895
  onResponseReceived: function onResponseReceived(_response, request) {
51560
51896
  _lastSubmissionRequest.current = request;
51561
51897
  },
@@ -51726,34 +52062,12 @@ var SignatureKYC = function SignatureKYC(props) {
51726
52062
  client = _a.client,
51727
52063
  ctx = _a.ctx;
51728
52064
  useDroppedPropReport('SignatureKYC', props);
51729
- // The one flow whose 3.0 counterpart never enters `client.submit()`: it runs
51730
- // its own stage machine and reports completion through `onCaptured` instead.
51731
- // 2.x DOES submit here — its CompositeWizard calls `submit()`, which hands
51732
- // the built request to `onSubmit` before reaching the capture-only branch —
51733
- // so the façade makes that call itself to produce the same request. The
51734
- // client suppresses the POST, and `action: NONE` is accepted precisely
51735
- // because `onSubmit` is bound.
51736
- //
51737
- // Only when bound: without `onSubmit` the client rejects NONE by design, and
51738
- // this flow has nothing to submit anyway.
51739
- var onSubmit = props.onSubmit;
51740
- var submission = mapSubmission(props);
51741
- var handOff = onSubmit ? function (artifacts) {
51742
- void client.submit(artifacts, _assign(_assign({}, submission), {
51743
- action: SubmissionAction.NONE
51744
- }))["catch"](function () {
51745
- // The failure already reached `onRequestFailure` through the
51746
- // client's own hook, which is where 2.x reported it too.
51747
- });
51748
- } : undefined;
51749
52065
  // No `children`: SignatureKYCFlow omits it from its props (it runs its own
51750
52066
  // stage machine rather than CompositeWizard), so passing it would not
51751
52067
  // compile — and 2.x rendered it nowhere either.
51752
52068
  return /*#__PURE__*/React__default.default.createElement(SignatureKYCFlow, _assign({
51753
52069
  client: client
51754
- }, mapSignatureKYCProps(props, ctx), {
51755
- onCaptured: handOff
51756
- }));
52070
+ }, mapSignatureKYCProps(props, ctx)));
51757
52071
  };
51758
52072
  /**
51759
52073
  * Render a fullscreen capture component that performs ID and face validation,