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.
@@ -4869,6 +4869,21 @@ 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
+ // `Promise.resolve`, not `instanceof Promise`: a promise from another
4879
+ // realm (an iframe) fails that check, and its rejection would go unhandled.
4880
+ Promise.resolve(notify())["catch"](function (e) {
4881
+ return warn$1(name + " rejected", e);
4882
+ });
4883
+ } catch (e) {
4884
+ warn$1(name + " threw", e);
4885
+ }
4886
+ }
4872
4887
  /**
4873
4888
  * How long an async `sessionId` resolver may take. It typically mints the
4874
4889
  * session through the host's own backend (an OAuth token, then
@@ -4891,6 +4906,10 @@ function resolveSessionIdWithTimeout(resolve) {
4891
4906
  return clearTimeout(timer);
4892
4907
  });
4893
4908
  }
4909
+ /**
4910
+ * Creates a client. Its type is `Required<IdmissionClient>`: unlike a
4911
+ * hand-written `IdmissionClient`, it always has `post()` and `handoff()`.
4912
+ */
4894
4913
  function createIdmissionClient(config) {
4895
4914
  var _config$fetch, _config$now;
4896
4915
  // `let`: when config.sessionId is an async resolver, the session URN (and
@@ -4941,7 +4960,10 @@ function createIdmissionClient(config) {
4941
4960
  var livenessToken;
4942
4961
  function timedFetch(_x, _x2) {
4943
4962
  return _timedFetch.apply(this, arguments);
4944
- }
4963
+ } // The attestation nonce THIS client's session was validated with. The
4964
+ // holders are module-level, so another client validating later replaces
4965
+ // them; comparing against this, not against whatever the holder says at
4966
+ // submit time, is what keeps that client's nonce off this client's request.
4945
4967
  function _timedFetch() {
4946
4968
  _timedFetch = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2(url, init) {
4947
4969
  var controller, timer;
@@ -4977,10 +4999,35 @@ function createIdmissionClient(config) {
4977
4999
  }));
4978
5000
  return _timedFetch.apply(this, arguments);
4979
5001
  }
4980
- function performUpload(blob, metadata) {
4981
- return uploadDocument(blob, metadata, {
4982
- documentServiceUrl: urls.documentServiceUrl,
5002
+ var validatedSessionNonce = null;
5003
+ function currentRoute() {
5004
+ return {
4983
5005
  sessionId: store.getState().session.sessionId,
5006
+ submissionUrl: urls.submissionUrl,
5007
+ documentServiceUrl: urls.documentServiceUrl,
5008
+ sessionNonce: validatedSessionNonce
5009
+ };
5010
+ }
5011
+ // The attestation holders are module-level and follow the newest
5012
+ // ValidateSession, from any client. If they no longer hold this operation's
5013
+ // session nonce, the nonce and OS token belong to someone else: omit the
5014
+ // envelope (throwing here is
5015
+ // attachMetadataToRequest's fail-open path, which reports
5016
+ // `attestationAttached: false`) rather than attach a stranger's.
5017
+ function routeBoundCollectors(route) {
5018
+ return {
5019
+ collectAttestation: function collectAttestation(web, versions) {
5020
+ if (getLastSessionNonce() !== route.sessionNonce) {
5021
+ throw new Error('session changed during submission; attestation omitted');
5022
+ }
5023
+ return collectClientAttestation(web, versions);
5024
+ }
5025
+ };
5026
+ }
5027
+ function performUpload(blob, metadata, route) {
5028
+ return uploadDocument(blob, metadata, {
5029
+ documentServiceUrl: route.documentServiceUrl,
5030
+ sessionId: route.sessionId,
4984
5031
  Upload: config.tusUpload,
4985
5032
  delay: config.delay,
4986
5033
  calculateMd5: config.calculateMd5,
@@ -5032,7 +5079,7 @@ function createIdmissionClient(config) {
5032
5079
  }
5033
5080
  function _runSessionValidation() {
5034
5081
  _runSessionValidation = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee3(epoch) {
5035
- var authUrl, adoptSessionUrls, resolvedSessionId, err, valid, finalState, _err, _t, _t2;
5082
+ var authUrl, adoptSessionUrls, resolvedSessionId, err, responseNonce, valid, finalState, _err, _t, _t2;
5036
5083
  return _regeneratorRuntime.wrap(function (_context3) {
5037
5084
  while (1) switch (_context3.prev = _context3.next) {
5038
5085
  case 0:
@@ -5127,14 +5174,22 @@ function createIdmissionClient(config) {
5127
5174
  payload: 'RUNNING'
5128
5175
  });
5129
5176
  _context3.prev = 8;
5177
+ // The nonce THIS response carried, taken as it is ingested: reading
5178
+ // the shared holder after the await could pick up another client's.
5179
+ responseNonce = null;
5130
5180
  _context3.next = 9;
5131
5181
  return validateSession(authUrl, resolvedSessionId, {
5132
5182
  fetch: config.fetch,
5133
- delay: config.delay
5183
+ delay: config.delay,
5184
+ ingestNonce: function ingestNonce(nonce) {
5185
+ responseNonce = typeof nonce === 'string' && nonce ? nonce : null;
5186
+ ingestSessionAttestation(nonce);
5187
+ }
5134
5188
  });
5135
5189
  case 9:
5136
5190
  valid = _context3.sent;
5137
5191
  finalState = valid ? 'PASSED' : 'FAILED';
5192
+ if (epoch === sessionRunEpoch) validatedSessionNonce = responseNonce;
5138
5193
  dispatchSessionIfCurrent(epoch, {
5139
5194
  type: 'setCheckState',
5140
5195
  payload: finalState
@@ -5204,23 +5259,28 @@ function createIdmissionClient(config) {
5204
5259
  }));
5205
5260
  return _retrySession.apply(this, arguments);
5206
5261
  }
5207
- function submit(_x6, _x7) {
5208
- return _submit.apply(this, arguments);
5262
+ function runPipeline(_x6, _x7, _x8) {
5263
+ return _runPipeline.apply(this, arguments);
5209
5264
  }
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;
5265
+ function _runPipeline() {
5266
+ _runPipeline = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee7(artifacts, options, kind) {
5267
+ var _artifacts$meta$liven, _artifacts$meta, _options$onBeforeSubm;
5268
+ 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
5269
  return _regeneratorRuntime.wrap(function (_context7) {
5215
5270
  while (1) switch (_context7.prev = _context7.next) {
5216
5271
  case 0:
5217
- if (!(options.action === SubmissionAction.NONE && !config.onSubmit)) {
5272
+ handsOff = kind === 'handoff' || kind === 'submit' && config.onSubmit !== undefined; // sdk2 short-circuits action NONE to a synthetic success before any
5273
+ // network activity (SubmissionProvider.tsx:1203-1225). This client does
5274
+ // not fabricate that response, but it keeps the "NONE does no network
5275
+ // work" guarantee by rejecting here, before any upload — unless the
5276
+ // request is being handed off, which is the one thing NONE can do.
5277
+ if (!(options.action === SubmissionAction.NONE && !handsOff)) {
5218
5278
  _context7.next = 1;
5219
5279
  break;
5220
5280
  }
5221
5281
  throw new SubmissionError({
5222
5282
  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"
5283
+ statusMessage: "action 'NONE' has no endpoint to post to; use handoff() to build the request without posting it"
5224
5284
  });
5225
5285
  case 1:
5226
5286
  if (!(store.getState().session.sessionCheckState !== 'PASSED')) {
@@ -5229,6 +5289,11 @@ function createIdmissionClient(config) {
5229
5289
  }
5230
5290
  throw new AuthenticationError(401, 'session not validated');
5231
5291
  case 2:
5292
+ route = currentRoute(); // Claimed, not read: an overlapping operation must not reuse it, and a
5293
+ // `checkLiveness()` that lands mid-operation keeps its own token for the
5294
+ // next one (SubmissionProvider.tsx:1350 cleared it after the submit).
5295
+ claimedLivenessToken = (_artifacts$meta$liven = (_artifacts$meta = artifacts.meta) == null ? void 0 : _artifacts$meta.livenessToken) != null ? _artifacts$meta$liven : livenessToken;
5296
+ livenessToken = undefined;
5232
5297
  store.setState({
5233
5298
  submissionStatus: SubmissionStatus.SUBMITTING,
5234
5299
  submissionError: undefined
@@ -5245,7 +5310,7 @@ function createIdmissionClient(config) {
5245
5310
  _context7.next = 5;
5246
5311
  return buildSubmissionPayload(_extends({}, artifacts, {
5247
5312
  meta: _extends({}, artifacts.meta, {
5248
- livenessToken: (_artifacts$meta$liven = (_artifacts$meta = artifacts.meta) == null ? void 0 : _artifacts$meta.livenessToken) != null ? _artifacts$meta$liven : livenessToken
5313
+ livenessToken: claimedLivenessToken
5249
5314
  })
5250
5315
  }), _extends({}, options, {
5251
5316
  onBeforeSubmit: beforeSubmit ? function (request) {
@@ -5261,7 +5326,7 @@ function createIdmissionClient(config) {
5261
5326
  // withJobTaskMetadata (see its own comment above): only present
5262
5327
  // when options.jobID/taskID are present.
5263
5328
  uploadDocument: documentServiceEnabled ? (/*#__PURE__*/function () {
5264
- var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee6(blob, metadata) {
5329
+ var _ref3 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee6(blob, metadata) {
5265
5330
  var result, _t3;
5266
5331
  return _regeneratorRuntime.wrap(function (_context6) {
5267
5332
  while (1) switch (_context6.prev = _context6.next) {
@@ -5278,7 +5343,7 @@ function createIdmissionClient(config) {
5278
5343
  });
5279
5344
  _context6.prev = 1;
5280
5345
  _context6.next = 2;
5281
- return performUpload(blob, withJobTaskMetadata(metadata, options.jobID, options.taskID));
5346
+ return performUpload(blob, withJobTaskMetadata(metadata, options.jobID, options.taskID), route);
5282
5347
  case 2:
5283
5348
  result = _context6.sent;
5284
5349
  progress.observe({
@@ -5308,12 +5373,13 @@ function createIdmissionClient(config) {
5308
5373
  }
5309
5374
  }, _callee6, null, [[1, 3, 4, 5]]);
5310
5375
  }));
5311
- return function (_x10, _x11) {
5312
- return _ref2.apply(this, arguments);
5376
+ return function (_x13, _x14) {
5377
+ return _ref3.apply(this, arguments);
5313
5378
  };
5314
5379
  }()) : undefined,
5315
5380
  now: config.now,
5316
- sdkVersions: config.sdkVersions
5381
+ sdkVersions: config.sdkVersions,
5382
+ collectors: routeBoundCollectors(route)
5317
5383
  });
5318
5384
  case 5:
5319
5385
  payloadResult = _context7.sent;
@@ -5327,40 +5393,41 @@ function createIdmissionClient(config) {
5327
5393
  case 7:
5328
5394
  payloadBuildEnd = payloadResult.uploadTimings.payloadBuildEnd;
5329
5395
  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.
5396
+ request = payloadResult.request; // Stashed before the hand-off returns, so hand-off callers get the
5397
+ // request alongside the timings the `finally` records.
5334
5398
  store.setState({
5335
5399
  attestationAttached: payloadResult.attestationAttached,
5336
5400
  lastSubmissionRequest: request
5337
5401
  });
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) {
5402
+ if (!handsOff) {
5351
5403
  _context7.next = 8;
5352
5404
  break;
5353
5405
  }
5406
+ // sdk2 short-circuits at the equivalent point
5407
+ // (SubmissionProvider.tsx:1374-1377), so everything above runs and
5408
+ // nothing below does.
5409
+ //
5410
+ // The status goes to SUBMITTED, where sdk2 leaves it at READY. That is
5411
+ // a deliberate divergence in INTERNAL state to preserve the VISIBLE
5412
+ // behaviour: sdk2's wizard renders an empty fragment for READY via its
5413
+ // switch `default`, whereas this codebase renders the submitting
5414
+ // screen for READY — so inheriting READY would park the user on a
5415
+ // spinner forever. SUBMITTED with no response falls through every
5416
+ // terminal branch to `return null`, which is sdk2's empty fragment.
5354
5417
  store.setState({
5355
5418
  submissionStatus: SubmissionStatus.SUBMITTED
5356
5419
  });
5357
- config.onSubmit(request);
5420
+ if (kind === 'submit') config.onSubmit == null || config.onSubmit(request);
5358
5421
  progress.observe({
5359
5422
  kind: 'flow-completed'
5360
5423
  });
5361
- return _context7.abrupt("return", null);
5424
+ built = {
5425
+ request: request,
5426
+ response: null
5427
+ };
5428
+ _context7.next = 23;
5429
+ break;
5362
5430
  case 8:
5363
- sessionId = store.getState().session.sessionId;
5364
5431
  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
5432
  progress.observe({
5366
5433
  kind: 'phase',
@@ -5375,9 +5442,9 @@ function createIdmissionClient(config) {
5375
5442
  _context7.prev = 9;
5376
5443
  _context7.prev = 10;
5377
5444
  _context7.next = 11;
5378
- return timedFetch(urls.submissionUrl + endpoint, {
5445
+ return timedFetch(route.submissionUrl + endpoint, {
5379
5446
  method: 'POST',
5380
- headers: apiHeaders(sessionId, options.sendBase64DocumentsInSwaggerProxy),
5447
+ headers: apiHeaders(route.sessionId, options.sendBase64DocumentsInSwaggerProxy),
5381
5448
  body: JSON.stringify(request)
5382
5449
  });
5383
5450
  case 11:
@@ -5467,10 +5534,21 @@ function createIdmissionClient(config) {
5467
5534
  progress.observe({
5468
5535
  kind: 'flow-completed'
5469
5536
  });
5470
- config.onResponseReceived == null || config.onResponseReceived(submissionResponse, request);
5471
- return _context7.abrupt("return", submissionResponse);
5537
+ // Legacy `submit()` keeps a throwing `onResponseReceived` inside the
5538
+ // failure path, as it always has; `post()` notifies after the outcome
5539
+ // is settled (below).
5540
+ if (kind === 'submit') {
5541
+ config.onResponseReceived == null || config.onResponseReceived(submissionResponse, request);
5542
+ }
5543
+ built = {
5544
+ request: request,
5545
+ response: submissionResponse
5546
+ };
5472
5547
  case 23:
5473
- _context7.prev = 23;
5548
+ _context7.next = 25;
5549
+ break;
5550
+ case 24:
5551
+ _context7.prev = 24;
5474
5552
  _t0 = _context7["catch"](3);
5475
5553
  if (failedAt === undefined) failedAt = 'submission';
5476
5554
  err = _t0;
@@ -5482,72 +5560,116 @@ function createIdmissionClient(config) {
5482
5560
  // UNLIKE sdk2 (`if (throwErrorsOnFailure) throw err`) there is no
5483
5561
  // catch-swallow path: rejection always propagates.
5484
5562
  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;
5563
+ case 25:
5564
+ _context7.prev = 25;
5490
5565
  endedAt = nowImpl();
5566
+ timings = buildSubmissionTimings({
5567
+ startedAt: startedAt,
5568
+ endedAt: endedAt,
5569
+ payloadBuildStart: payloadBuildStart,
5570
+ payloadBuildEnd: payloadBuildEnd,
5571
+ uploads: uploadMeasurements,
5572
+ apiCallStart: apiCallStart,
5573
+ apiCallEnd: apiCallEnd,
5574
+ responseParseStart: responseParseStart,
5575
+ responseParseEnd: responseParseEnd,
5576
+ failedAt: failedAt
5577
+ });
5491
5578
  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
- })
5579
+ lastSubmissionTimings: timings
5504
5580
  });
5505
- return _context7.finish(24);
5506
- case 25:
5581
+ return _context7.finish(25);
5582
+ case 26:
5583
+ if (kind === 'post' && built.response) {
5584
+ _built = built, _response = _built.response, _request = _built.request;
5585
+ notifySafely$1('onResponseReceived', function () {
5586
+ return config.onResponseReceived == null ? void 0 : config.onResponseReceived(_response, _request);
5587
+ });
5588
+ }
5589
+ return _context7.abrupt("return", _extends({}, built, {
5590
+ timings: timings
5591
+ }));
5592
+ case 27:
5507
5593
  case "end":
5508
5594
  return _context7.stop();
5509
5595
  }
5510
- }, _callee7, null, [[3, 23, 24, 25], [4, 6], [9, 20], [10, 12]]);
5596
+ }, _callee7, null, [[3, 24, 25, 26], [4, 6], [9, 20], [10, 12]]);
5597
+ }));
5598
+ return _runPipeline.apply(this, arguments);
5599
+ }
5600
+ function submit(artifacts, options) {
5601
+ return runPipeline(artifacts, options, 'submit').then(function (_ref2) {
5602
+ var response = _ref2.response;
5603
+ return response;
5604
+ });
5605
+ }
5606
+ function post(artifacts, options) {
5607
+ return runPipeline(artifacts, options, 'post');
5608
+ }
5609
+ function handoff(_x9, _x0) {
5610
+ return _handoff.apply(this, arguments);
5611
+ }
5612
+ function _handoff() {
5613
+ _handoff = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee8(artifacts, options) {
5614
+ var _yield$runPipeline, request, timings;
5615
+ return _regeneratorRuntime.wrap(function (_context8) {
5616
+ while (1) switch (_context8.prev = _context8.next) {
5617
+ case 0:
5618
+ _context8.next = 1;
5619
+ return runPipeline(artifacts, options, 'handoff');
5620
+ case 1:
5621
+ _yield$runPipeline = _context8.sent;
5622
+ request = _yield$runPipeline.request;
5623
+ timings = _yield$runPipeline.timings;
5624
+ return _context8.abrupt("return", {
5625
+ request: request,
5626
+ timings: timings
5627
+ });
5628
+ case 2:
5629
+ case "end":
5630
+ return _context8.stop();
5631
+ }
5632
+ }, _callee8);
5511
5633
  }));
5512
- return _submit.apply(this, arguments);
5634
+ return _handoff.apply(this, arguments);
5513
5635
  }
5514
- function checkLiveness(_x8, _x9) {
5636
+ function checkLiveness(_x1, _x10) {
5515
5637
  return _checkLiveness.apply(this, arguments);
5516
5638
  }
5517
5639
  function _checkLiveness() {
5518
- _checkLiveness = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee8(imageDataUrl, options) {
5640
+ _checkLiveness = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee9(imageDataUrl, options) {
5519
5641
  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) {
5642
+ return _regeneratorRuntime.wrap(function (_context9) {
5643
+ while (1) switch (_context9.prev = _context9.next) {
5522
5644
  case 0:
5523
5645
  if (options === void 0) {
5524
5646
  options = {};
5525
5647
  }
5526
- _context8.prev = 1;
5648
+ _context9.prev = 1;
5527
5649
  selfie = imageDataUrl;
5528
5650
  if (!(options.useDocumentServiceForLivenessChecks && documentServiceEnabled)) {
5529
- _context8.next = 6;
5651
+ _context9.next = 6;
5530
5652
  break;
5531
5653
  }
5532
5654
  if (!selfie.startsWith('data:')) {
5533
5655
  selfie = "data:image/jpeg;base64," + selfie;
5534
5656
  }
5535
- _context8.prev = 2;
5536
- _context8.next = 3;
5657
+ _context9.prev = 2;
5658
+ _context9.next = 3;
5537
5659
  return performUpload(dataUrlToBlob(selfie), withJobTaskMetadata({
5538
5660
  filename: 'liveness',
5539
5661
  filetype: 'image/jpeg'
5540
- }, options.jobID, options.taskID));
5662
+ }, options.jobID, options.taskID), currentRoute());
5541
5663
  case 3:
5542
- selfie = _context8.sent;
5543
- _context8.next = 5;
5664
+ selfie = _context9.sent;
5665
+ _context9.next = 5;
5544
5666
  break;
5545
5667
  case 4:
5546
- _context8.prev = 4;
5547
- _t1 = _context8["catch"](2);
5668
+ _context9.prev = 4;
5669
+ _t1 = _context9["catch"](2);
5548
5670
  throw new NetworkError(_t1 instanceof Error ? _t1.message : String(_t1));
5549
5671
  case 5:
5550
- _context8.next = 7;
5672
+ _context9.next = 7;
5551
5673
  break;
5552
5674
  case 6:
5553
5675
  selfie = dataUrlToBase64Sync$1(selfie);
@@ -5615,19 +5737,19 @@ function createIdmissionClient(config) {
5615
5737
  attestationAttached: attestationAttached
5616
5738
  });
5617
5739
  if (!config.onBeforeLivenessCheck) {
5618
- _context8.next = 9;
5740
+ _context9.next = 9;
5619
5741
  break;
5620
5742
  }
5621
- _context8.next = 8;
5743
+ _context9.next = 8;
5622
5744
  return config.onBeforeLivenessCheck(request);
5623
5745
  case 8:
5624
- result = _context8.sent;
5746
+ result = _context9.sent;
5625
5747
  if (result) request = result;
5626
5748
  case 9:
5627
5749
  endpoint = liveCheckEndpoint(!!options.idCardForFaceMatch);
5628
5750
  sessionId = store.getState().session.sessionId;
5629
- _context8.prev = 10;
5630
- _context8.next = 11;
5751
+ _context9.prev = 10;
5752
+ _context9.next = 11;
5631
5753
  return timedFetch(urls.submissionUrl + endpoint, {
5632
5754
  method: 'POST',
5633
5755
  // SubmissionProvider.tsx:1447 — sourced from the same
@@ -5638,36 +5760,36 @@ function createIdmissionClient(config) {
5638
5760
  body: JSON.stringify(request)
5639
5761
  });
5640
5762
  case 11:
5641
- response = _context8.sent;
5642
- _context8.next = 13;
5763
+ response = _context9.sent;
5764
+ _context9.next = 13;
5643
5765
  break;
5644
5766
  case 12:
5645
- _context8.prev = 12;
5646
- _t10 = _context8["catch"](10);
5767
+ _context9.prev = 12;
5768
+ _t10 = _context9["catch"](10);
5647
5769
  throw new NetworkError(_t10 instanceof Error ? _t10.message : String(_t10));
5648
5770
  case 13:
5649
5771
  if (response.ok) {
5650
- _context8.next = 18;
5772
+ _context9.next = 18;
5651
5773
  break;
5652
5774
  }
5653
5775
  if (!(response.status === 401 || response.status === 403)) {
5654
- _context8.next = 15;
5776
+ _context9.next = 15;
5655
5777
  break;
5656
5778
  }
5657
5779
  _t11 = AuthenticationError;
5658
5780
  _t12 = response.status;
5659
- _context8.next = 14;
5781
+ _context9.next = 14;
5660
5782
  return response.text();
5661
5783
  case 14:
5662
- _t13 = _context8.sent;
5784
+ _t13 = _context9.sent;
5663
5785
  throw new _t11(_t12, _t13);
5664
5786
  case 15:
5665
- _context8.next = 16;
5787
+ _context9.next = 16;
5666
5788
  return response.text();
5667
5789
  case 16:
5668
- statusMessage = _context8.sent;
5790
+ statusMessage = _context9.sent;
5669
5791
  if (!(!statusMessage || statusMessage === 'Load failed')) {
5670
- _context8.next = 17;
5792
+ _context9.next = 17;
5671
5793
  break;
5672
5794
  }
5673
5795
  throw new NetworkError(statusMessage);
@@ -5677,12 +5799,12 @@ function createIdmissionClient(config) {
5677
5799
  statusMessage: statusMessage
5678
5800
  });
5679
5801
  case 18:
5680
- _context8.next = 19;
5802
+ _context9.next = 19;
5681
5803
  return response.json();
5682
5804
  case 19:
5683
- livenessResponse = _context8.sent;
5805
+ livenessResponse = _context9.sent;
5684
5806
  if (!(livenessResponse.status.statusCode !== '000')) {
5685
- _context8.next = 20;
5807
+ _context9.next = 20;
5686
5808
  break;
5687
5809
  }
5688
5810
  throw new SubmissionError(livenessResponse.status);
@@ -5695,7 +5817,7 @@ function createIdmissionClient(config) {
5695
5817
  // unconditional here — a deliberate scope narrowing, not a silent drop.
5696
5818
  livenessToken = (_livenessResponse$res = livenessResponse.resultData) == null ? void 0 : _livenessResponse$res.livenessToken;
5697
5819
  if (!(options.softFail && !isLiveFaceConfirmed((_livenessResponse$res2 = livenessResponse.resultData) == null ? void 0 : _livenessResponse$res2.verificationResult))) {
5698
- _context8.next = 21;
5820
+ _context9.next = 21;
5699
5821
  break;
5700
5822
  }
5701
5823
  // Current sdk2 (SubmissionProvider.tsx checkLiveness): softFail also
@@ -5704,21 +5826,21 @@ function createIdmissionClient(config) {
5704
5826
  // non-live capture) and hand back a typed failure that still carries
5705
5827
  // the response so callers can read the detection flags.
5706
5828
  livenessToken = undefined;
5707
- return _context8.abrupt("return", {
5829
+ return _context9.abrupt("return", {
5708
5830
  ok: false,
5709
5831
  error: new Error("Liveness not confirmed: " + ((_livenessResponse$res3 = (_livenessResponse$res4 = livenessResponse.resultData) == null ? void 0 : _livenessResponse$res4.verificationResult) != null ? _livenessResponse$res3 : 'no verificationResult')),
5710
5832
  response: livenessResponse
5711
5833
  });
5712
5834
  case 21:
5713
- return _context8.abrupt("return", {
5835
+ return _context9.abrupt("return", {
5714
5836
  ok: true,
5715
5837
  response: livenessResponse
5716
5838
  });
5717
5839
  case 22:
5718
- _context8.prev = 22;
5719
- _t14 = _context8["catch"](1);
5840
+ _context9.prev = 22;
5841
+ _t14 = _context9["catch"](1);
5720
5842
  if (!options.softFail) {
5721
- _context8.next = 23;
5843
+ _context9.next = 23;
5722
5844
  break;
5723
5845
  }
5724
5846
  // Caller is treating this as a best-effort check. Don't surface the
@@ -5726,7 +5848,7 @@ function createIdmissionClient(config) {
5726
5848
  // typed failure result instead of sdk2's silent `undefined` (deliberate
5727
5849
  // divergence #3).
5728
5850
  livenessToken = undefined;
5729
- return _context8.abrupt("return", {
5851
+ return _context9.abrupt("return", {
5730
5852
  ok: false,
5731
5853
  error: _t14
5732
5854
  });
@@ -5740,32 +5862,32 @@ function createIdmissionClient(config) {
5740
5862
  throw err;
5741
5863
  case 24:
5742
5864
  case "end":
5743
- return _context8.stop();
5865
+ return _context9.stop();
5744
5866
  }
5745
- }, _callee8, null, [[1, 22], [2, 4], [10, 12]]);
5867
+ }, _callee9, null, [[1, 22], [2, 4], [10, 12]]);
5746
5868
  }));
5747
5869
  return _checkLiveness.apply(this, arguments);
5748
5870
  }
5749
- function clientUploadDocument(_x0, _x1) {
5871
+ function clientUploadDocument(_x11, _x12) {
5750
5872
  return _clientUploadDocument.apply(this, arguments);
5751
5873
  }
5752
5874
  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) {
5875
+ _clientUploadDocument = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee0(blob, metadata) {
5876
+ return _regeneratorRuntime.wrap(function (_context0) {
5877
+ while (1) switch (_context0.prev = _context0.next) {
5756
5878
  case 0:
5757
5879
  if (documentServiceEnabled) {
5758
- _context9.next = 1;
5880
+ _context0.next = 1;
5759
5881
  break;
5760
5882
  }
5761
5883
  throw new Error('document upload is disabled: no documentServiceUrl configured');
5762
5884
  case 1:
5763
- return _context9.abrupt("return", performUpload(blob, metadata != null ? metadata : {}));
5885
+ return _context0.abrupt("return", performUpload(blob, metadata != null ? metadata : {}, currentRoute()));
5764
5886
  case 2:
5765
5887
  case "end":
5766
- return _context9.stop();
5888
+ return _context0.stop();
5767
5889
  }
5768
- }, _callee9);
5890
+ }, _callee0);
5769
5891
  }));
5770
5892
  return _clientUploadDocument.apply(this, arguments);
5771
5893
  }
@@ -5781,6 +5903,8 @@ function createIdmissionClient(config) {
5781
5903
  validateSession: validateSessionMethod,
5782
5904
  retrySession: retrySession,
5783
5905
  submit: submit,
5906
+ post: post,
5907
+ handoff: handoff,
5784
5908
  checkLiveness: checkLiveness,
5785
5909
  uploadDocument: clientUploadDocument
5786
5910
  };
@@ -38405,7 +38529,9 @@ function SubmissionProvider(_ref) {
38405
38529
  onComplete = _ref.onComplete,
38406
38530
  onApproved = _ref.onApproved,
38407
38531
  onDenied = _ref.onDenied,
38408
- onRequestFailure = _ref.onRequestFailure;
38532
+ onSubmissionFailure = _ref.onSubmissionFailure,
38533
+ onRequestFailure = _ref.onRequestFailure,
38534
+ mode = _ref.mode;
38409
38535
  var progress = useCaptureObserver();
38410
38536
  var clientState = shim.useSyncExternalStore(client.subscribe, client.getState, client.getState);
38411
38537
  var _useAuthState = useAuthState(),
@@ -38418,10 +38544,22 @@ function SubmissionProvider(_ref) {
38418
38544
  _useState4 = _slicedToArray(_useState3, 2),
38419
38545
  localError = _useState4[0],
38420
38546
  setLocalError = _useState4[1];
38421
- var _useState5 = React.useState(false),
38547
+ var _useState5 = React.useState(IDLE_ATTEMPT),
38422
38548
  _useState6 = _slicedToArray(_useState5, 2),
38423
- resubmitting = _useState6[0],
38424
- setResubmitting = _useState6[1];
38549
+ attempt = _useState6[0],
38550
+ setAttempt = _useState6[1];
38551
+ // Which path the latest submission took. State is read from that path even
38552
+ // if `mode` changes while it is in flight; before any submission, `mode`
38553
+ // decides.
38554
+ var _useState7 = React.useState(null),
38555
+ _useState8 = _slicedToArray(_useState7, 2),
38556
+ startedExplicit = _useState8[0],
38557
+ setStartedExplicit = _useState8[1];
38558
+ var reportFailure = onSubmissionFailure != null ? onSubmissionFailure : onRequestFailure;
38559
+ var _useState9 = React.useState(false),
38560
+ _useState0 = _slicedToArray(_useState9, 2),
38561
+ resubmitting = _useState0[0],
38562
+ setResubmitting = _useState0[1];
38425
38563
  var lastArtifactsRef = React.useRef(null);
38426
38564
  var submitInFlightRef = React.useRef(null);
38427
38565
  var resubmitInFlightRef = React.useRef(null);
@@ -38439,6 +38577,71 @@ function SubmissionProvider(_ref) {
38439
38577
  }) : incoming;
38440
38578
  // Store the merged artifacts so a resubmit carries location too.
38441
38579
  lastArtifactsRef.current = artifacts;
38580
+ setStartedExplicit(mode !== undefined);
38581
+ if (mode !== undefined) {
38582
+ // Registered before anything customer-supplied runs, so a throw from
38583
+ // a notification can never leave the flow without a status.
38584
+ setAttempt(_extends({}, IDLE_ATTEMPT, {
38585
+ status: SubmissionStatus.SUBMITTING
38586
+ }));
38587
+ var _unbindProgress = bindSubmissionObserver(artifacts, progress);
38588
+ // The client call waits one microtask so the in-flight promise is
38589
+ // registered first: an `onSubmissionStarted` that calls `submit()`
38590
+ // gets this attempt back instead of starting a second one.
38591
+ var _promise = Promise.resolve().then(function () {
38592
+ return runAttempt(client, mode, artifacts, _extends({}, options, {
38593
+ action: action
38594
+ }));
38595
+ }).then(function (outcome) {
38596
+ setAttempt(_extends({}, outcome, {
38597
+ status: SubmissionStatus.SUBMITTED,
38598
+ error: null
38599
+ }));
38600
+ var response = outcome.response,
38601
+ request = outcome.request;
38602
+ if (response === null) {
38603
+ // Terminal once called; the handler is never awaited.
38604
+ if (typeof mode === 'object') {
38605
+ notifySafely('submitMode.handoff', function () {
38606
+ return mode.handoff(request);
38607
+ });
38608
+ }
38609
+ return null;
38610
+ }
38611
+ notifySafely('onComplete', function () {
38612
+ return onComplete == null ? void 0 : onComplete(response);
38613
+ });
38614
+ if (isApprovedResponse(action, response)) {
38615
+ notifySafely('onApproved', function () {
38616
+ return onApproved == null ? void 0 : onApproved(response);
38617
+ });
38618
+ } else {
38619
+ notifySafely('onDenied', function () {
38620
+ return onDenied == null ? void 0 : onDenied(response);
38621
+ });
38622
+ }
38623
+ return response;
38624
+ }, function (cause) {
38625
+ var error = cause instanceof Error ? cause : new Error(String(cause));
38626
+ setAttempt(_extends({}, IDLE_ATTEMPT, {
38627
+ status: SubmissionStatus.FAILED,
38628
+ error: error
38629
+ }));
38630
+ notifySafely('onSubmissionFailure', function () {
38631
+ return reportFailure == null ? void 0 : reportFailure(error);
38632
+ });
38633
+ throw error;
38634
+ })["finally"](function () {
38635
+ _unbindProgress();
38636
+ submitInFlightRef.current = null;
38637
+ setResubmitting(false);
38638
+ });
38639
+ submitInFlightRef.current = _promise;
38640
+ notifySafely('onSubmissionStarted', function () {
38641
+ return onSubmissionStarted == null ? void 0 : onSubmissionStarted(artifacts);
38642
+ });
38643
+ return _promise;
38644
+ }
38442
38645
  setSubmissionResponse(null);
38443
38646
  setLocalError(null);
38444
38647
  onSubmissionStarted == null || onSubmissionStarted(artifacts);
@@ -38459,7 +38662,7 @@ function SubmissionProvider(_ref) {
38459
38662
  })["catch"](function (cause) {
38460
38663
  var error = cause instanceof Error ? cause : new Error(String(cause));
38461
38664
  setLocalError(error);
38462
- onRequestFailure == null || onRequestFailure(error);
38665
+ reportFailure == null || reportFailure(error);
38463
38666
  throw error;
38464
38667
  })["finally"](function () {
38465
38668
  unbindProgress();
@@ -38468,7 +38671,7 @@ function SubmissionProvider(_ref) {
38468
38671
  });
38469
38672
  submitInFlightRef.current = promise;
38470
38673
  return promise;
38471
- }, [action, client, geolocation, onApproved, onComplete, onDenied, onRequestFailure, onSubmissionStarted, options, progress]);
38674
+ }, [action, client, geolocation, onApproved, onComplete, onDenied, reportFailure, onSubmissionStarted, options, progress, mode]);
38472
38675
  var resubmit = React.useMemo(function () {
38473
38676
  if (!authState.session.canRefreshSession) return null;
38474
38677
  return function () {
@@ -38513,22 +38716,120 @@ function SubmissionProvider(_ref) {
38513
38716
  }, [authState.session.canRefreshSession, client, submit]);
38514
38717
  var value = React.useMemo(function () {
38515
38718
  var _ref3, _clientState$lastSubm, _clientState$lastSubm2;
38719
+ if (startedExplicit != null ? startedExplicit : mode !== undefined) {
38720
+ return {
38721
+ action: action,
38722
+ submit: submit,
38723
+ submissionStatus: resubmitting ? SubmissionStatus.SUBMITTING : attempt.status,
38724
+ submissionResponse: attempt.response,
38725
+ submissionError: attempt.error,
38726
+ lastSubmissionTimings: attempt.timings,
38727
+ lastSubmissionRequest: attempt.request,
38728
+ resubmit: resubmit
38729
+ };
38730
+ }
38516
38731
  return {
38517
38732
  action: action,
38518
38733
  submit: submit,
38519
- submissionStatus: resubmitting ? SubmissionStatus.SUBMITTING : clientState.submissionStatus,
38734
+ // A rejection before the client records anything (an unsupported
38735
+ // action, an unvalidated session) leaves the client at READY, which the
38736
+ // wizard renders as its submitting screen; the local error is the
38737
+ // failure it would otherwise never show.
38738
+ submissionStatus: resubmitting ? SubmissionStatus.SUBMITTING : localError && clientState.submissionStatus === SubmissionStatus.READY ? SubmissionStatus.FAILED : clientState.submissionStatus,
38520
38739
  submissionResponse: submissionResponse,
38521
38740
  submissionError: (_ref3 = localError != null ? localError : clientState.submissionError) != null ? _ref3 : null,
38522
38741
  lastSubmissionTimings: (_clientState$lastSubm = clientState.lastSubmissionTimings) != null ? _clientState$lastSubm : null,
38523
38742
  lastSubmissionRequest: (_clientState$lastSubm2 = clientState.lastSubmissionRequest) != null ? _clientState$lastSubm2 : null,
38524
38743
  resubmit: resubmit
38525
38744
  };
38526
- }, [action, clientState.lastSubmissionRequest, clientState.lastSubmissionTimings, clientState.submissionError, clientState.submissionStatus, localError, resubmit, resubmitting, submissionResponse, submit]);
38745
+ }, [action, attempt, clientState.lastSubmissionRequest, clientState.lastSubmissionTimings, clientState.submissionError, clientState.submissionStatus, localError, mode, resubmit, resubmitting, startedExplicit, submissionResponse, submit]);
38527
38746
  return jsxRuntime.jsx(SubmissionContext.Provider, {
38528
38747
  value: value,
38529
38748
  children: children
38530
38749
  });
38531
38750
  }
38751
+ var IDLE_ATTEMPT = {
38752
+ status: SubmissionStatus.READY,
38753
+ response: null,
38754
+ request: null,
38755
+ timings: null,
38756
+ error: null
38757
+ };
38758
+ /**
38759
+ * One explicit-mode attempt through the client's `post()` or `handoff()`.
38760
+ * Never falls back to `submit()`: that would let the deprecated
38761
+ * `config.onSubmit` decide what an explicit mode already decided.
38762
+ */
38763
+ function runAttempt(_x, _x2, _x3, _x4) {
38764
+ return _runAttempt.apply(this, arguments);
38765
+ }
38766
+ function _runAttempt() {
38767
+ _runAttempt = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2(client, mode, artifacts, options) {
38768
+ var _yield$client$handoff, request, timings;
38769
+ return _regeneratorRuntime.wrap(function (_context2) {
38770
+ while (1) switch (_context2.prev = _context2.next) {
38771
+ case 0:
38772
+ if (!(mode === 'capture')) {
38773
+ _context2.next = 1;
38774
+ break;
38775
+ }
38776
+ throw new Error("submitMode 'capture' does not submit; the flow reports onCaptured instead");
38777
+ case 1:
38778
+ if (!(mode === 'post')) {
38779
+ _context2.next = 3;
38780
+ break;
38781
+ }
38782
+ if (client.post) {
38783
+ _context2.next = 2;
38784
+ break;
38785
+ }
38786
+ throw missingMethod('post', "submitMode 'post'");
38787
+ case 2:
38788
+ return _context2.abrupt("return", client.post(artifacts, options));
38789
+ case 3:
38790
+ if (client.handoff) {
38791
+ _context2.next = 4;
38792
+ break;
38793
+ }
38794
+ throw missingMethod('handoff', 'submitMode { handoff }');
38795
+ case 4:
38796
+ _context2.next = 5;
38797
+ return client.handoff(artifacts, options);
38798
+ case 5:
38799
+ _yield$client$handoff = _context2.sent;
38800
+ request = _yield$client$handoff.request;
38801
+ timings = _yield$client$handoff.timings;
38802
+ return _context2.abrupt("return", {
38803
+ request: request,
38804
+ timings: timings,
38805
+ response: null
38806
+ });
38807
+ case 6:
38808
+ case "end":
38809
+ return _context2.stop();
38810
+ }
38811
+ }, _callee2);
38812
+ }));
38813
+ return _runAttempt.apply(this, arguments);
38814
+ }
38815
+ function missingMethod(method, needs) {
38816
+ return new Error(needs + " needs client." + method + "(), which this client does not have. " + 'Create the client with createIdmissionClient or useIdmissionClient.');
38817
+ }
38818
+ /**
38819
+ * Runs a customer callback whose failure must not change an outcome that is
38820
+ * already settled: a throw or a rejected promise is logged, never rethrown.
38821
+ */
38822
+ function notifySafely(name, notify) {
38823
+ try {
38824
+ // `Promise.resolve`, not `instanceof Promise`: a promise from another
38825
+ // realm (an iframe) fails that check, and its rejection would go unhandled.
38826
+ Promise.resolve(notify())["catch"](function (e) {
38827
+ return warn(name + " rejected", e);
38828
+ });
38829
+ } catch (e) {
38830
+ warn(name + " threw", e);
38831
+ }
38832
+ }
38532
38833
  function useSubmission() {
38533
38834
  var context = React.useContext(SubmissionContext);
38534
38835
  if (!context) {
@@ -40393,11 +40694,12 @@ function RemoteDiagnosticsMount(_ref) {
40393
40694
  }
40394
40695
 
40395
40696
  var _templateObject$1, _templateObject2$1, _templateObject3, _templateObject4;
40396
- var _excluded$9 = ["client", "action", "submission", "theme", "className", "geolocationEnabled", "geolocationRequired", "captureProgress", "remoteDiagnostics", "loadingSpinner", "showEnrollmentId", "lang", "children"];
40697
+ var _excluded$9 = ["client", "action", "submission", "submitMode", "theme", "className", "geolocationEnabled", "geolocationRequired", "captureProgress", "remoteDiagnostics", "loadingSpinner", "showEnrollmentId", "lang", "children"];
40397
40698
  function FlowChassis(_ref) {
40398
40699
  var client = _ref.client,
40399
40700
  action = _ref.action,
40400
40701
  submission = _ref.submission,
40702
+ submitMode = _ref.submitMode,
40401
40703
  _ref$theme = _ref.theme,
40402
40704
  theme = _ref$theme === void 0 ? 'default' : _ref$theme,
40403
40705
  className = _ref.className,
@@ -40430,6 +40732,7 @@ function FlowChassis(_ref) {
40430
40732
  client: client,
40431
40733
  action: action,
40432
40734
  options: submission,
40735
+ mode: submitMode,
40433
40736
  geolocation: geolocation.position
40434
40737
  }, callbacks, {
40435
40738
  children: jsxRuntime.jsx(FlowPage, {
@@ -40750,7 +41053,7 @@ function withVirtualCameras(camera, allowVirtualCameras) {
40750
41053
  return base;
40751
41054
  }
40752
41055
 
40753
- 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"];
41056
+ 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"];
40754
41057
  var EMPTY_ID_CAPTURE$3 = {};
40755
41058
  var EMPTY_SIGNATURE_CAPTURE$5 = {};
40756
41059
  var EMPTY_ID_VIEW$3 = {};
@@ -40767,8 +41070,8 @@ function IdValidationFlow(_ref) {
40767
41070
  submission = _ref$submission === void 0 ? EMPTY_SUBMISSION$6 : _ref$submission,
40768
41071
  _ref$initialArtifacts = _ref.initialArtifacts,
40769
41072
  initialArtifacts = _ref$initialArtifacts === void 0 ? EMPTY_ARTIFACTS$9 : _ref$initialArtifacts,
40770
- _ref$captureOnly = _ref.captureOnly,
40771
- captureOnly = _ref$captureOnly === void 0 ? false : _ref$captureOnly,
41073
+ submitMode = _ref.submitMode,
41074
+ captureOnly = _ref.captureOnly,
40772
41075
  signatureController = _ref.signatureController,
40773
41076
  _ref$signatureCapture = _ref.signatureCapture,
40774
41077
  signatureCapture = _ref$signatureCapture === void 0 ? EMPTY_SIGNATURE_CAPTURE$5 : _ref$signatureCapture,
@@ -40927,10 +41230,12 @@ function IdValidationFlow(_ref) {
40927
41230
  successIssuerCaptionText: 'confirmed'
40928
41231
  }
40929
41232
  });
41233
+ var mode = submitMode != null ? submitMode : captureOnly ? 'capture' : undefined;
40930
41234
  return jsxRuntime.jsxs(FlowChassis, _extends({
40931
41235
  client: client,
40932
41236
  action: SubmissionAction.VALIDATE,
40933
41237
  submission: submission,
41238
+ submitMode: mode,
40934
41239
  theme: theme,
40935
41240
  className: className,
40936
41241
  lang: lang
@@ -40938,7 +41243,7 @@ function IdValidationFlow(_ref) {
40938
41243
  children: [jsxRuntime.jsx(CompositeWizard, _extends({}, ringScreens, {
40939
41244
  steps: steps,
40940
41245
  initialArtifacts: initialArtifacts,
40941
- captureOnly: captureOnly,
41246
+ captureOnly: mode === 'capture',
40942
41247
  showResultScreen: showResultScreen != null ? showResultScreen : showSuccessScreen,
40943
41248
  showDiagnostics: showDiagnostics,
40944
41249
  onArtifactsCollected: onCaptured,
@@ -41398,6 +41703,10 @@ function SignatureKYCFlow(_ref) {
41398
41703
  captureProgress = _ref.captureProgress,
41399
41704
  remoteDiagnostics = _ref.remoteDiagnostics,
41400
41705
  loadingSpinner = _ref.loadingSpinner,
41706
+ _ref$submitMode = _ref.submitMode,
41707
+ submitMode = _ref$submitMode === void 0 ? 'capture' : _ref$submitMode,
41708
+ onSubmissionStarted = _ref.onSubmissionStarted,
41709
+ onSubmissionFailure = _ref.onSubmissionFailure,
41401
41710
  onCaptured = _ref.onCaptured,
41402
41711
  onCaptureError = _ref.onCaptureError;
41403
41712
  // Flow-wide settings reach each step unless its own bag sets them.
@@ -41593,13 +41902,21 @@ function SignatureKYCFlow(_ref) {
41593
41902
  resolvedSelfieController.actions.retry();
41594
41903
  setStage('face-liveness');
41595
41904
  }, [resolvedSelfieController]);
41905
+ // Lives here, above the chassis's session gate: a session error unmounts
41906
+ // and remounts `SignatureHandoff`, and must not start the hand-off again.
41907
+ var handoffStartedRef = React.useRef(false);
41908
+ var claimHandoffStart = React.useCallback(function () {
41909
+ if (handoffStartedRef.current) return false;
41910
+ handoffStartedRef.current = true;
41911
+ return true;
41912
+ }, []);
41596
41913
  var handleSignatureCompleted = React.useCallback(function (artifacts) {
41597
41914
  if (completedRef.current) return;
41598
41915
  completedRef.current = true;
41599
41916
  artifactsRef.current = mergeSubmissionArtifacts(artifactsRef.current, artifacts);
41600
41917
  setStage('complete');
41601
- onCaptured == null || onCaptured(artifactsRef.current);
41602
- }, [onCaptured]);
41918
+ if (submitMode === 'capture') onCaptured == null || onCaptured(artifactsRef.current);
41919
+ }, [onCaptured, submitMode]);
41603
41920
  var handleLivenessFailureExit = React.useCallback(function () {
41604
41921
  onExitAfterLivenessFailure == null || onExitAfterLivenessFailure();
41605
41922
  if (allowSignatureAfterLivenessCheckFailure) handleLivenessDone();
@@ -41608,6 +41925,9 @@ function SignatureKYCFlow(_ref) {
41608
41925
  client: client,
41609
41926
  action: SubmissionAction.NONE,
41610
41927
  submission: submission,
41928
+ submitMode: submitMode,
41929
+ onSubmissionStarted: onSubmissionStarted,
41930
+ onSubmissionFailure: onSubmissionFailure,
41611
41931
  theme: theme,
41612
41932
  className: className,
41613
41933
  lang: lang,
@@ -41617,8 +41937,11 @@ function SignatureKYCFlow(_ref) {
41617
41937
  remoteDiagnostics: remoteDiagnostics,
41618
41938
  loadingSpinner: loadingSpinner,
41619
41939
  children: [jsxRuntime.jsx(CaptureProgressCompletion, {
41620
- completed: stage === 'complete'
41621
- }), stage !== 'complete' ? jsxRuntime.jsxs(HandoffRoot, {
41940
+ completed: stage === 'complete' && submitMode === 'capture'
41941
+ }), stage === 'complete' && submitMode !== 'capture' ? jsxRuntime.jsx(SignatureHandoff, {
41942
+ artifacts: artifactsRef.current,
41943
+ claimStart: claimHandoffStart
41944
+ }) : null, stage !== 'complete' ? jsxRuntime.jsxs(HandoffRoot, {
41622
41945
  children: [jsxRuntime.jsx(SignatureCaptureView, _extends({}, signatureView, {
41623
41946
  skipSuccessScreen: impliedSkipSuccessScreen(signatureView.skipSuccessScreen, isRingIntroActive(faceView)),
41624
41947
  controller: resolvedSignatureController,
@@ -41668,6 +41991,43 @@ function SignatureKYCFlow(_ref) {
41668
41991
  }) : null]
41669
41992
  });
41670
41993
  }
41994
+ /**
41995
+ * Hands the finished capture off once the session has passed: a finishing
41996
+ * screen while the request is built, a retry screen if that fails, and
41997
+ * nothing once it has been handed off.
41998
+ */
41999
+ function SignatureHandoff(_ref3) {
42000
+ var artifacts = _ref3.artifacts,
42001
+ claimStart = _ref3.claimStart;
42002
+ var _useSubmission = useSubmission(),
42003
+ action = _useSubmission.action,
42004
+ submit = _useSubmission.submit,
42005
+ submissionStatus = _useSubmission.submissionStatus,
42006
+ submissionError = _useSubmission.submissionError;
42007
+ var sessionReady = useSessionReady();
42008
+ // The provider reports a failure itself; these catches only keep the
42009
+ // rejection from going unhandled.
42010
+ React.useEffect(function () {
42011
+ if (!sessionReady || !claimStart()) return;
42012
+ submit(artifacts)["catch"](function () {});
42013
+ }, [artifacts, claimStart, sessionReady, submit]);
42014
+ if (submissionStatus === SubmissionStatus.SUBMITTED) return null;
42015
+ if (submissionStatus === SubmissionStatus.FAILED) {
42016
+ return jsxRuntime.jsx(SubmissionErrorOverlay, {
42017
+ error: submissionError,
42018
+ onRetry: function onRetry() {
42019
+ submit(artifacts)["catch"](function () {});
42020
+ }
42021
+ });
42022
+ }
42023
+ var text = submissionStatusText(action, artifacts);
42024
+ return jsxRuntime.jsx(OrbStatusScreen, {
42025
+ state: "working",
42026
+ text: text,
42027
+ accessibleLabel: text,
42028
+ loadingStage: "submission"
42029
+ });
42030
+ }
41671
42031
  /**
41672
42032
  * Black, so iOS Safari's bars read as letterboxing around the camera feed
41673
42033
  * rather than as one more colour a theme has to choose.
@@ -41685,10 +42045,10 @@ var CAMERA_EDGE_COLOR = '#000';
41685
42045
  * no flat strip can sit on its bottom edge unseen: that one is drawn invisibly,
41686
42046
  * as on ID capture's overlay. Opaque, it covered the bottom 12px of the bar.
41687
42047
  */
41688
- function FlowEdgeTint(_ref3) {
42048
+ function FlowEdgeTint(_ref4) {
41689
42049
  var _theme$selfieCapture$, _theme$selfieCapture, _theme$background;
41690
- var surface = _ref3.surface,
41691
- modelsReady = _ref3.modelsReady;
42050
+ var surface = _ref4.surface,
42051
+ modelsReady = _ref4.modelsReady;
41692
42052
  var theme = styledComponents.useTheme();
41693
42053
  if (theme.isFullscreen === false || surface === null) return null;
41694
42054
  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');
@@ -41698,9 +42058,9 @@ function FlowEdgeTint(_ref3) {
41698
42058
  hiddenBottomColor: surface === 'overlay' ? selfieLoadingOverlayBottomEdgeColor(theme, modelsReady) : undefined
41699
42059
  });
41700
42060
  }
41701
- function SelfieTrackerAttachment(_ref4) {
41702
- var controller = _ref4.controller,
41703
- video = _ref4.video;
42061
+ function SelfieTrackerAttachment(_ref5) {
42062
+ var controller = _ref5.controller,
42063
+ video = _ref5.video;
41704
42064
  React.useEffect(function () {
41705
42065
  if (!video) return;
41706
42066
  void controller.attach(video)["catch"](function () {
@@ -41718,7 +42078,7 @@ var FaceStage = styledComponents.styled.div(_templateObject2 || (_templateObject
41718
42078
  return props.$visible ? 'block' : 'none';
41719
42079
  });
41720
42080
 
41721
- 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"],
42081
+ 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"],
41722
42082
  _excluded2$2 = ["checkLivenessOptions"];
41723
42083
  var EMPTY_ID_CAPTURE$1 = {};
41724
42084
  var EMPTY_FACE_CAPTURE$2 = {};
@@ -41751,8 +42111,8 @@ function VideoIdValidationFlow(_ref) {
41751
42111
  submission = _ref$submission === void 0 ? EMPTY_SUBMISSION$2 : _ref$submission,
41752
42112
  _ref$initialArtifacts = _ref.initialArtifacts,
41753
42113
  initialArtifacts = _ref$initialArtifacts === void 0 ? EMPTY_ARTIFACTS$5 : _ref$initialArtifacts,
41754
- _ref$captureOnly = _ref.captureOnly,
41755
- captureOnly = _ref$captureOnly === void 0 ? false : _ref$captureOnly,
42114
+ submitMode = _ref.submitMode,
42115
+ captureOnly = _ref.captureOnly,
41756
42116
  signatureController = _ref.signatureController,
41757
42117
  _ref$signatureCapture = _ref.signatureCapture,
41758
42118
  signatureCapture = _ref$signatureCapture === void 0 ? EMPTY_SIGNATURE_CAPTURE$2 : _ref$signatureCapture,
@@ -41970,10 +42330,12 @@ function VideoIdValidationFlow(_ref) {
41970
42330
  successIssuerCaptionText: 'confirmed'
41971
42331
  }
41972
42332
  });
42333
+ var mode = submitMode != null ? submitMode : captureOnly ? 'capture' : undefined;
41973
42334
  return jsxRuntime.jsxs(FlowChassis, _extends({
41974
42335
  client: client,
41975
42336
  action: action,
41976
42337
  submission: submission,
42338
+ submitMode: mode,
41977
42339
  theme: theme,
41978
42340
  className: className,
41979
42341
  lang: lang
@@ -41981,7 +42343,7 @@ function VideoIdValidationFlow(_ref) {
41981
42343
  children: [jsxRuntime.jsx(CompositeWizard, _extends({}, ringScreens, {
41982
42344
  steps: steps,
41983
42345
  initialArtifacts: initialArtifacts,
41984
- captureOnly: captureOnly,
42346
+ captureOnly: mode === 'capture',
41985
42347
  showResultScreen: showResultScreen != null ? showResultScreen : showSuccessScreen,
41986
42348
  showDiagnostics: showDiagnostics,
41987
42349
  onArtifactsCollected: onCaptured,
@@ -46192,7 +46554,9 @@ function CustomerMatchFlow(_ref) {
46192
46554
  onComplete = _ref.onComplete,
46193
46555
  onCustomerMatched = _ref.onCustomerMatched,
46194
46556
  onCustomerNotMatched = _ref.onCustomerNotMatched,
46557
+ onSubmissionFailure = _ref.onSubmissionFailure,
46195
46558
  onRequestFailure = _ref.onRequestFailure,
46559
+ submitMode = _ref.submitMode,
46196
46560
  onCaptureGuidanceTimeout = _ref.onCaptureGuidanceTimeout,
46197
46561
  onExitCapture = _ref.onExitCapture,
46198
46562
  onExitAfterFailure = _ref.onExitAfterFailure;
@@ -46279,15 +46643,19 @@ function CustomerMatchFlow(_ref) {
46279
46643
  setOutcome('notMatched');
46280
46644
  onCustomerNotMatched == null || onCustomerNotMatched(response);
46281
46645
  }, [onCustomerNotMatched]);
46646
+ var reportFailure = onSubmissionFailure != null ? onSubmissionFailure : onRequestFailure;
46282
46647
  var handleLivenessCheckFailed = React.useCallback(function (error) {
46283
46648
  setOutcome('failed');
46284
- onRequestFailure == null || onRequestFailure(error);
46285
- }, [onRequestFailure]);
46649
+ reportFailure == null || reportFailure(error);
46650
+ }, [reportFailure]);
46286
46651
  var handleRequestError = React.useCallback(function (error) {
46287
46652
  errorRef.current = error;
46288
46653
  setOutcome('error');
46289
- onRequestFailure == null || onRequestFailure(error);
46290
- }, [onRequestFailure]);
46654
+ reportFailure == null || reportFailure(error);
46655
+ }, [reportFailure]);
46656
+ var handleHandedOff = React.useCallback(function () {
46657
+ return setOutcome('handedOff');
46658
+ }, []);
46291
46659
  var handleCaptureGuidanceTimeout = React.useCallback(function () {
46292
46660
  setOutcome('failed');
46293
46661
  onCaptureGuidanceTimeout == null || onCaptureGuidanceTimeout();
@@ -46328,6 +46696,7 @@ function CustomerMatchFlow(_ref) {
46328
46696
  client: client,
46329
46697
  action: action,
46330
46698
  submission: submission,
46699
+ submitMode: submitMode,
46331
46700
  theme: theme,
46332
46701
  className: className,
46333
46702
  lang: lang,
@@ -46352,6 +46721,7 @@ function CustomerMatchFlow(_ref) {
46352
46721
  onNotMatched: handleNotMatched,
46353
46722
  onLivenessCheckFailed: handleLivenessCheckFailed,
46354
46723
  onRequestError: handleRequestError,
46724
+ onSubmissionIntercepted: handleHandedOff,
46355
46725
  onCaptureGuidanceTimeout: handleCaptureGuidanceTimeout,
46356
46726
  onExitCapture: onExitCapture,
46357
46727
  finishingScreen: {
@@ -46487,6 +46857,84 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
46487
46857
  return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
46488
46858
  };
46489
46859
 
46860
+ function createIdAndFaceValidationJourneyEvent(event, now) {
46861
+ if (now === void 0) {
46862
+ now = function now() {
46863
+ return new Date();
46864
+ };
46865
+ }
46866
+ return _assign(_assign({}, event), {
46867
+ version: 1,
46868
+ flow: 'id-and-face-validation',
46869
+ timestamp: now().toISOString()
46870
+ });
46871
+ }
46872
+ /**
46873
+ * websdk-ui `CompositeWizardStep.id` -> journey stage.
46874
+ *
46875
+ * Four of the five stage names ARE step ids already; only the additional-
46876
+ * documents step differs, because sdk2's stage vocabulary says
46877
+ * `additional-document-capture` (singular "document") while websdk-ui's step
46878
+ * is `additional-documents`. Unknown ids return undefined so a step this
46879
+ * vocabulary has no name for is silently skipped rather than emitted with a
46880
+ * bogus stage — the same shape as sdk2's partial lookup record.
46881
+ */
46882
+ function journeyStageForStepId(stepId) {
46883
+ switch (stepId) {
46884
+ case 'id-capture':
46885
+ case 'face-liveness':
46886
+ case 'signature-capture':
46887
+ case 'video-signature-capture':
46888
+ return stepId;
46889
+ case 'additional-documents':
46890
+ return 'additional-document-capture';
46891
+ default:
46892
+ return undefined;
46893
+ }
46894
+ }
46895
+ /**
46896
+ * The document types sdk2 reports as `document.captured`. sdk2 filters the
46897
+ * wizard's `onDocumentStored` through this set (`primaryIdDocumentTypes`) so
46898
+ * that a document type outside the journey vocabulary cannot widen the event.
46899
+ * Kept as a predicate rather than a Set: the ES5 UMD bundle target makes
46900
+ * `for..of` over a Set a downlevel hazard, and a switch needs no iteration.
46901
+ */
46902
+ function isJourneyDocumentType(documentType) {
46903
+ return documentType === 'idCardFront' || documentType === 'idCardBack' || documentType === 'passport' || documentType === 'singlePage';
46904
+ }
46905
+ /**
46906
+ * The lazy `flow.started` rule, lifted out of sdk2's `emitJourneyEvent`
46907
+ * closure (IdAndFaceValidation.tsx:521-537) so it can be tested without a
46908
+ * React tree.
46909
+ *
46910
+ * sdk2 does NOT simply emit `flow.started` from a mount effect: it emits it
46911
+ * before the FIRST event of any kind, whatever that event is, and then
46912
+ * suppresses the explicit mount emit. The mount effect and the lazy guard
46913
+ * together mean `flow.started` is always the first event a customer sees,
46914
+ * even if some other event races the effect. That ordering guarantee is the
46915
+ * contract, not the effect.
46916
+ */
46917
+ function createJourneyEmitter(callback, now) {
46918
+ var flowStartedEmitted = false;
46919
+ return function emit(event) {
46920
+ if (!callback) return;
46921
+ if (!flowStartedEmitted) {
46922
+ flowStartedEmitted = true;
46923
+ emitWith(callback, {
46924
+ name: 'flow.started'
46925
+ }, now);
46926
+ }
46927
+ if (event.name !== 'flow.started') emitWith(callback, event, now);
46928
+ };
46929
+ }
46930
+ function emitWith(callback, event, now) {
46931
+ try {
46932
+ callback(createIdAndFaceValidationJourneyEvent(event, now));
46933
+ } catch (error) {
46934
+ warn$1('[IdAndFaceValidation] onJourneyEvent callback failed', error);
46935
+ }
46936
+ }
46937
+
46490
46938
  /**
46491
46939
  * sdk2 exports this as a mutable `string[]`
46492
46940
  * (contexts/AuthStateContext.tsx:25), not a readonly tuple — copied rather
@@ -46659,12 +47107,9 @@ function mapClientConfig(props) {
46659
47107
  documentServiceUrl: (_b = props.documentServiceUrl) !== null && _b !== void 0 ? _b : apiBase ? apiBase + '/files/' : override === null || override === void 0 ? void 0 : override.documentServiceUrl,
46660
47108
  onBeforeSubmit: props.onBeforeSubmit,
46661
47109
  onBeforeLivenessCheck: props.onBeforeLivenessCheck,
46662
- // Straight through to the client, which is where sdk2 put it too
46663
- // (SubmissionProvider.submit). That is what makes the SUPPRESSION uniform:
46664
- // every flow — including the two match flows, which own their own stage
46665
- // machine — submits through this one client, so none of them can post
46666
- // behind an integrator who supplied `onSubmit`.
46667
- onSubmit: props.onSubmit,
47110
+ // 2.x's `onSubmit` is not a client option here: each flow maps it to its
47111
+ // own `submitMode: { handoff }` (see ./props.ts), which follows the prop
47112
+ // live where a client option would be fixed at mount.
46668
47113
  onBeforeDocumentUpload: props.onBeforeDocumentUpload,
46669
47114
  onDocumentUploadProgress: props.onDocumentUploadProgress,
46670
47115
  onDocumentUploaded: props.onDocumentUploaded,
@@ -47674,84 +48119,6 @@ function mapFaceCapture(props, prefixed) {
47674
48119
  };
47675
48120
  }
47676
48121
 
47677
- function createIdAndFaceValidationJourneyEvent(event, now) {
47678
- if (now === void 0) {
47679
- now = function now() {
47680
- return new Date();
47681
- };
47682
- }
47683
- return _assign(_assign({}, event), {
47684
- version: 1,
47685
- flow: 'id-and-face-validation',
47686
- timestamp: now().toISOString()
47687
- });
47688
- }
47689
- /**
47690
- * websdk-ui `CompositeWizardStep.id` -> journey stage.
47691
- *
47692
- * Four of the five stage names ARE step ids already; only the additional-
47693
- * documents step differs, because sdk2's stage vocabulary says
47694
- * `additional-document-capture` (singular "document") while websdk-ui's step
47695
- * is `additional-documents`. Unknown ids return undefined so a step this
47696
- * vocabulary has no name for is silently skipped rather than emitted with a
47697
- * bogus stage — the same shape as sdk2's partial lookup record.
47698
- */
47699
- function journeyStageForStepId(stepId) {
47700
- switch (stepId) {
47701
- case 'id-capture':
47702
- case 'face-liveness':
47703
- case 'signature-capture':
47704
- case 'video-signature-capture':
47705
- return stepId;
47706
- case 'additional-documents':
47707
- return 'additional-document-capture';
47708
- default:
47709
- return undefined;
47710
- }
47711
- }
47712
- /**
47713
- * The document types sdk2 reports as `document.captured`. sdk2 filters the
47714
- * wizard's `onDocumentStored` through this set (`primaryIdDocumentTypes`) so
47715
- * that a document type outside the journey vocabulary cannot widen the event.
47716
- * Kept as a predicate rather than a Set: the ES5 UMD bundle target makes
47717
- * `for..of` over a Set a downlevel hazard, and a switch needs no iteration.
47718
- */
47719
- function isJourneyDocumentType(documentType) {
47720
- return documentType === 'idCardFront' || documentType === 'idCardBack' || documentType === 'passport' || documentType === 'singlePage';
47721
- }
47722
- /**
47723
- * The lazy `flow.started` rule, lifted out of sdk2's `emitJourneyEvent`
47724
- * closure (IdAndFaceValidation.tsx:521-537) so it can be tested without a
47725
- * React tree.
47726
- *
47727
- * sdk2 does NOT simply emit `flow.started` from a mount effect: it emits it
47728
- * before the FIRST event of any kind, whatever that event is, and then
47729
- * suppresses the explicit mount emit. The mount effect and the lazy guard
47730
- * together mean `flow.started` is always the first event a customer sees,
47731
- * even if some other event races the effect. That ordering guarantee is the
47732
- * contract, not the effect.
47733
- */
47734
- function createJourneyEmitter(callback, now) {
47735
- var flowStartedEmitted = false;
47736
- return function emit(event) {
47737
- if (!callback) return;
47738
- if (!flowStartedEmitted) {
47739
- flowStartedEmitted = true;
47740
- emitWith(callback, {
47741
- name: 'flow.started'
47742
- }, now);
47743
- }
47744
- if (event.name !== 'flow.started') emitWith(callback, event, now);
47745
- };
47746
- }
47747
- function emitWith(callback, event, now) {
47748
- try {
47749
- callback(createIdAndFaceValidationJourneyEvent(event, now));
47750
- } catch (error) {
47751
- warn$1('[IdAndFaceValidation] onJourneyEvent callback failed', error);
47752
- }
47753
- }
47754
-
47755
48122
  /**
47756
48123
  * Recursively drops keys whose value is exactly `undefined`.
47757
48124
  *
@@ -47934,6 +48301,16 @@ function mapThemeWithColors(theme, colors) {
47934
48301
  return mergeThemes(mapped, overrides);
47935
48302
  }
47936
48303
 
48304
+ /**
48305
+ * 2.x's `onSubmit` as the flow's hand-off. sdk2 read it on every submission,
48306
+ * so this maps on every render: adding or removing it takes effect from the
48307
+ * next submission. Without it the flow posts.
48308
+ */
48309
+ function mapHandoff(onSubmit) {
48310
+ return onSubmit ? {
48311
+ handoff: onSubmit
48312
+ } : undefined;
48313
+ }
47937
48314
  var EMPTY_CONTEXT = {};
47938
48315
  /** Adapts a 3.0 `(response)` callback back to 2.x's `(response, request)`. */
47939
48316
  function withSubmissionRequest(callback, ctx) {
@@ -48025,13 +48402,13 @@ function mapAdditionalDocumentVerbiage(verbiage) {
48025
48402
  }
48026
48403
  // --- 1. IdValidation ------------------------------------------------------
48027
48404
  function mapIdValidationProps(props, ctx) {
48028
- var _a;
48405
+ var _a, _b;
48029
48406
  if (ctx === void 0) {
48030
48407
  ctx = EMPTY_CONTEXT;
48031
48408
  }
48032
- var _b = mapIdCapture(props),
48033
- capture = _b.capture,
48034
- view = _b.view;
48409
+ var _c = mapIdCapture(props),
48410
+ capture = _c.capture,
48411
+ view = _c.view;
48035
48412
  return compact({
48036
48413
  capture: capture,
48037
48414
  view: view,
@@ -48057,9 +48434,8 @@ function mapIdValidationProps(props, ctx) {
48057
48434
  // `onSubmit` WINS over capture-only, matching sdk2's ordering: its
48058
48435
  // `submit()` checks `onSubmit` before the `action === NONE` branch
48059
48436
  // (SubmissionProvider.tsx:1374 vs :1237), so a capture-only flow still
48060
- // owes the callback its built request. Letting the flow run its normal
48061
- // submit path is what builds that request; the client suppresses the POST.
48062
- captureOnly: props.onSubmit ? undefined : props.captureOnly,
48437
+ // owes the callback its built request.
48438
+ submitMode: (_b = mapHandoff(props.onSubmit)) !== null && _b !== void 0 ? _b : props.captureOnly ? 'capture' : undefined,
48063
48439
  captureAdditionalDocuments: props.captureAdditionalDocuments,
48064
48440
  geolocationEnabled: props.geolocationEnabled,
48065
48441
  geolocationRequired: props.geolocationRequired,
@@ -48080,13 +48456,10 @@ function mapIdValidationProps(props, ctx) {
48080
48456
  // would be a NEW restriction, not parity.
48081
48457
  showResultScreen: props.debugMode,
48082
48458
  showDiagnostics: props.debugMode,
48083
- // `onSubmit` is NOT mapped to a flow prop: it goes to the client config
48084
- // (see mapClientConfig), which is the layer sdk2 put it at and the only
48085
- // one that can suppress the POST for every flow at once.
48086
48459
  onComplete: withSubmissionRequest(props.onComplete, ctx),
48087
48460
  onApproved: withSubmissionRequest(props.onApproved, ctx),
48088
48461
  onDenied: withSubmissionRequest(props.onDenied, ctx),
48089
- onRequestFailure: props.onRequestFailure
48462
+ onSubmissionFailure: props.onRequestFailure
48090
48463
  });
48091
48464
  }
48092
48465
  // --- 2. FaceValidation ----------------------------------------------------
@@ -48278,7 +48651,8 @@ function mapIdAndFaceValidationProps(props, ctx) {
48278
48651
  onComplete: withSubmissionRequest(props.onComplete, ctx),
48279
48652
  onApproved: withSubmissionRequest(props.onApproved, ctx),
48280
48653
  onDenied: withSubmissionRequest(props.onDenied, ctx),
48281
- onRequestFailure: props.onRequestFailure,
48654
+ submitMode: mapHandoff(props.onSubmit),
48655
+ onSubmissionFailure: props.onRequestFailure,
48282
48656
  onCaptureError: props.onRequestFailure
48283
48657
  });
48284
48658
  }
@@ -48433,10 +48807,11 @@ function mapSignatureKYCProps(props, ctx) {
48433
48807
  captureProgress: props.captureProgress,
48434
48808
  remoteDiagnostics: props.remoteDiagnostics,
48435
48809
  loadingSpinner: props.loadingSpinner,
48436
- // `onCaptured` is supplied by the COMPONENT, not here: this flow never
48437
- // enters `client.submit()` on its own, so the façade makes that call from
48438
- // `onCaptured` to produce the same built request 2.x hands over. See
48439
- // components/flows.tsx.
48810
+ // 2.x builds this flow's request and hands it to `onSubmit`
48811
+ // (SubmissionProvider.tsx:1374, ahead of its NONE branch). Unset, the
48812
+ // flow captures and posts nothing, as 2.x's NONE did. A failed hand-off
48813
+ // is not reported to `onRequestFailure`, which 2.x never did either.
48814
+ submitMode: mapHandoff(props.onSubmit),
48440
48815
  onCaptureError: props.onRequestFailure
48441
48816
  });
48442
48817
  }
@@ -48462,7 +48837,7 @@ function nestedLayer(nested, map) {
48462
48837
  return map(nested);
48463
48838
  }
48464
48839
  function mapVideoIdValidationProps(props, ctx) {
48465
- var _a, _b, _c;
48840
+ var _a, _b, _c, _d;
48466
48841
  if (ctx === void 0) {
48467
48842
  ctx = EMPTY_CONTEXT;
48468
48843
  }
@@ -48555,7 +48930,11 @@ function mapVideoIdValidationProps(props, ctx) {
48555
48930
  showResultScreen: props.debugMode,
48556
48931
  showDiagnostics: props.debugMode,
48557
48932
  onComplete: withSubmissionRequest(props.onComplete, ctx),
48558
- onRequestFailure: props.onRequestFailure,
48933
+ // No ID captured and none supplied resolves the action to NONE, which
48934
+ // has nothing to post. 2.x answered with a synthetic success and no
48935
+ // request; capture mode is that without the fabricated response.
48936
+ submitMode: (_d = mapHandoff(props.onSubmit)) !== null && _d !== void 0 ? _d : props.skipIdCapture && !props.idCardForFaceMatch ? 'capture' : undefined,
48937
+ onSubmissionFailure: props.onRequestFailure,
48559
48938
  onCaptureError: props.onRequestFailure
48560
48939
  });
48561
48940
  }
@@ -48720,7 +49099,8 @@ function mapCustomerMatchProps(props, ctx) {
48720
49099
  onComplete: withSubmissionRequest(props.onComplete, ctx),
48721
49100
  onCustomerMatched: withSubmissionRequest(props.onCustomerMatched, ctx),
48722
49101
  onCustomerNotMatched: withSubmissionRequest(props.onCustomerNotMatched, ctx),
48723
- onRequestFailure: props.onRequestFailure,
49102
+ submitMode: mapHandoff(props.onSubmit),
49103
+ onSubmissionFailure: props.onRequestFailure,
48724
49104
  onExitCapture: props.onExitCapture,
48725
49105
  onExitAfterFailure: props.onExitAfterFailure
48726
49106
  });
@@ -48789,7 +49169,8 @@ function mapCustomerBiometricsEnrollmentProps(props, ctx) {
48789
49169
  // sdk2's enrollment twin of `onApproved`.
48790
49170
  onApproved: withSubmissionRequest(props.onEnrolled, ctx),
48791
49171
  onDenied: withSubmissionRequest(props.onDenied, ctx),
48792
- onRequestFailure: props.onRequestFailure,
49172
+ submitMode: mapHandoff(props.onSubmit),
49173
+ onSubmissionFailure: props.onRequestFailure,
48793
49174
  onCaptureError: props.onRequestFailure
48794
49175
  });
48795
49176
  }
@@ -48881,12 +49262,13 @@ function mapCustomerIdAndBiometricsEnrollmentProps(props, ctx) {
48881
49262
  onComplete: withSubmissionRequest(props.onComplete, ctx),
48882
49263
  onApproved: withSubmissionRequest(props.onEnrolled, ctx),
48883
49264
  onDenied: withSubmissionRequest(props.onDenied, ctx),
48884
- onRequestFailure: props.onRequestFailure,
49265
+ submitMode: mapHandoff(props.onSubmit),
49266
+ onSubmissionFailure: props.onRequestFailure,
48885
49267
  onCaptureError: props.onRequestFailure
48886
49268
  });
48887
49269
  }
48888
49270
 
48889
- var webSdkVersion = '2.6.3-changeset-release-develop-124a427';
49271
+ var webSdkVersion = '2.6.3-changeset-release-develop-776f131';
48890
49272
 
48891
49273
  // GENERATED by scripts/styleBagTypes.mjs from
48892
49274
  // src/__fixtures__/sdk2StyleBags.json and the mapper sweep — do not
@@ -50943,23 +51325,17 @@ var STYLE_WITH_ASSETS = {
50943
51325
  var SUBMIT_CALLBACKS = {
50944
51326
  onBeforeSubmit: MAPPED,
50945
51327
  /**
50946
- * Mapped to the CLIENT's `onSubmit`, not to a flow prop — the layer sdk2 put
50947
- * it at (SubmissionProvider.submit). The client builds the request, hands it
50948
- * over, and does NOT post, so `onComplete`/`onApproved`/`onDenied` never
50949
- * fire, exactly as 2.x documents. Every flow submits through that one
50950
- * client, including the two match flows with their own stage machine, so the
50951
- * suppression is uniform.
51328
+ * Mapped to the flow's `submitMode: { handoff }`. The flow builds the
51329
+ * request, hands it over, and does NOT post, so `onComplete`/`onApproved`/
51330
+ * `onDenied` never fire, exactly as 2.x documents. Mapped on every render,
51331
+ * so adding or removing it takes effect from the next submission, as sdk2's
51332
+ * ref-held `onSubmit` did.
50952
51333
  *
50953
51334
  * What the flow SHOWS afterwards is a 3.0 call rather than a 2.x
50954
51335
  * reproduction: every family now ends quietly, because the integrator owns
50955
51336
  * the outcome once they have the request. 2.x's match flows showed a failure
50956
51337
  * screen there, but only because their `submit()` could not distinguish an
50957
51338
  * intercepted submission from a broken one.
50958
- *
50959
- * `SignatureKYC` reaches the same place by a different route: its 3.0
50960
- * counterpart never enters `client.submit()`, so the façade component makes
50961
- * that call itself from `onCaptured`. `action: NONE` is accepted there
50962
- * precisely because `onSubmit` is bound.
50963
51339
  */
50964
51340
  onSubmit: MAPPED,
50965
51341
  onComplete: MAPPED,
@@ -51057,7 +51433,7 @@ var SignatureKYC$1 = _assign(_assign(_assign(_assign(_assign(_assign(_assign(_as
51057
51433
  // `SubmissionAction.NONE` and wires `onComplete` to the provider's
51058
51434
  // `onResponseReceived` (SignatureKYC.tsx:434,449), which never fires because
51059
51435
  // nothing is ever posted. `onSubmit` is the real completion seam and IS
51060
- // mapped, to the flow's `onCaptured`.
51436
+ // mapped, to the flow's `submitMode: { handoff }`.
51061
51437
  onComplete: NOOP,
51062
51438
  onSubmit: MAPPED,
51063
51439
  onRequestFailure: MAPPED,
@@ -51548,10 +51924,6 @@ function useCompatClient(props) {
51548
51924
  _lastLivenessRequest.current = request;
51549
51925
  return propsRef.current.onBeforeLivenessCheck ? propsRef.current.onBeforeLivenessCheck(request) : Promise.resolve(request);
51550
51926
  },
51551
- onSubmit: propsRef.current.onSubmit ? function (request) {
51552
- var _a, _b;
51553
- return (_b = (_a = propsRef.current).onSubmit) === null || _b === void 0 ? void 0 : _b.call(_a, request);
51554
- } : undefined,
51555
51927
  onResponseReceived: function onResponseReceived(_response, request) {
51556
51928
  _lastSubmissionRequest.current = request;
51557
51929
  },
@@ -51722,34 +52094,12 @@ var SignatureKYC = function SignatureKYC(props) {
51722
52094
  client = _a.client,
51723
52095
  ctx = _a.ctx;
51724
52096
  useDroppedPropReport('SignatureKYC', props);
51725
- // The one flow whose 3.0 counterpart never enters `client.submit()`: it runs
51726
- // its own stage machine and reports completion through `onCaptured` instead.
51727
- // 2.x DOES submit here — its CompositeWizard calls `submit()`, which hands
51728
- // the built request to `onSubmit` before reaching the capture-only branch —
51729
- // so the façade makes that call itself to produce the same request. The
51730
- // client suppresses the POST, and `action: NONE` is accepted precisely
51731
- // because `onSubmit` is bound.
51732
- //
51733
- // Only when bound: without `onSubmit` the client rejects NONE by design, and
51734
- // this flow has nothing to submit anyway.
51735
- var onSubmit = props.onSubmit;
51736
- var submission = mapSubmission(props);
51737
- var handOff = onSubmit ? function (artifacts) {
51738
- void client.submit(artifacts, _assign(_assign({}, submission), {
51739
- action: SubmissionAction.NONE
51740
- }))["catch"](function () {
51741
- // The failure already reached `onRequestFailure` through the
51742
- // client's own hook, which is where 2.x reported it too.
51743
- });
51744
- } : undefined;
51745
52097
  // No `children`: SignatureKYCFlow omits it from its props (it runs its own
51746
52098
  // stage machine rather than CompositeWizard), so passing it would not
51747
52099
  // compile — and 2.x rendered it nowhere either.
51748
52100
  return /*#__PURE__*/React__default.default.createElement(SignatureKYCFlow, _assign({
51749
52101
  client: client
51750
- }, mapSignatureKYCProps(props, ctx), {
51751
- onCaptured: handOff
51752
- }));
52102
+ }, mapSignatureKYCProps(props, ctx)));
51753
52103
  };
51754
52104
  /**
51755
52105
  * Render a fullscreen capture component that performs ID and face validation,