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.
package/dist/sdk2.esm.js CHANGED
@@ -4858,6 +4858,21 @@ function withJobTaskMetadata(metadata, jobID, taskID) {
4858
4858
  if (taskID) merged.taskid = taskID;
4859
4859
  return merged;
4860
4860
  }
4861
+ /**
4862
+ * Runs a customer callback whose failure must not change an outcome that is
4863
+ * already settled: a throw or a rejected promise is logged, never rethrown.
4864
+ */
4865
+ function notifySafely$1(name, notify) {
4866
+ try {
4867
+ // `Promise.resolve`, not `instanceof Promise`: a promise from another
4868
+ // realm (an iframe) fails that check, and its rejection would go unhandled.
4869
+ Promise.resolve(notify())["catch"](function (e) {
4870
+ return warn$1(name + " rejected", e);
4871
+ });
4872
+ } catch (e) {
4873
+ warn$1(name + " threw", e);
4874
+ }
4875
+ }
4861
4876
  /**
4862
4877
  * How long an async `sessionId` resolver may take. It typically mints the
4863
4878
  * session through the host's own backend (an OAuth token, then
@@ -4880,6 +4895,10 @@ function resolveSessionIdWithTimeout(resolve) {
4880
4895
  return clearTimeout(timer);
4881
4896
  });
4882
4897
  }
4898
+ /**
4899
+ * Creates a client. Its type is `Required<IdmissionClient>`: unlike a
4900
+ * hand-written `IdmissionClient`, it always has `post()` and `handoff()`.
4901
+ */
4883
4902
  function createIdmissionClient(config) {
4884
4903
  var _config$fetch, _config$now;
4885
4904
  // `let`: when config.sessionId is an async resolver, the session URN (and
@@ -4930,7 +4949,10 @@ function createIdmissionClient(config) {
4930
4949
  var livenessToken;
4931
4950
  function timedFetch(_x, _x2) {
4932
4951
  return _timedFetch.apply(this, arguments);
4933
- }
4952
+ } // The attestation nonce THIS client's session was validated with. The
4953
+ // holders are module-level, so another client validating later replaces
4954
+ // them; comparing against this, not against whatever the holder says at
4955
+ // submit time, is what keeps that client's nonce off this client's request.
4934
4956
  function _timedFetch() {
4935
4957
  _timedFetch = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2(url, init) {
4936
4958
  var controller, timer;
@@ -4966,10 +4988,35 @@ function createIdmissionClient(config) {
4966
4988
  }));
4967
4989
  return _timedFetch.apply(this, arguments);
4968
4990
  }
4969
- function performUpload(blob, metadata) {
4970
- return uploadDocument(blob, metadata, {
4971
- documentServiceUrl: urls.documentServiceUrl,
4991
+ var validatedSessionNonce = null;
4992
+ function currentRoute() {
4993
+ return {
4972
4994
  sessionId: store.getState().session.sessionId,
4995
+ submissionUrl: urls.submissionUrl,
4996
+ documentServiceUrl: urls.documentServiceUrl,
4997
+ sessionNonce: validatedSessionNonce
4998
+ };
4999
+ }
5000
+ // The attestation holders are module-level and follow the newest
5001
+ // ValidateSession, from any client. If they no longer hold this operation's
5002
+ // session nonce, the nonce and OS token belong to someone else: omit the
5003
+ // envelope (throwing here is
5004
+ // attachMetadataToRequest's fail-open path, which reports
5005
+ // `attestationAttached: false`) rather than attach a stranger's.
5006
+ function routeBoundCollectors(route) {
5007
+ return {
5008
+ collectAttestation: function collectAttestation(web, versions) {
5009
+ if (getLastSessionNonce() !== route.sessionNonce) {
5010
+ throw new Error('session changed during submission; attestation omitted');
5011
+ }
5012
+ return collectClientAttestation(web, versions);
5013
+ }
5014
+ };
5015
+ }
5016
+ function performUpload(blob, metadata, route) {
5017
+ return uploadDocument(blob, metadata, {
5018
+ documentServiceUrl: route.documentServiceUrl,
5019
+ sessionId: route.sessionId,
4973
5020
  Upload: config.tusUpload,
4974
5021
  delay: config.delay,
4975
5022
  calculateMd5: config.calculateMd5,
@@ -5021,7 +5068,7 @@ function createIdmissionClient(config) {
5021
5068
  }
5022
5069
  function _runSessionValidation() {
5023
5070
  _runSessionValidation = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee3(epoch) {
5024
- var authUrl, adoptSessionUrls, resolvedSessionId, err, valid, finalState, _err, _t, _t2;
5071
+ var authUrl, adoptSessionUrls, resolvedSessionId, err, responseNonce, valid, finalState, _err, _t, _t2;
5025
5072
  return _regeneratorRuntime.wrap(function (_context3) {
5026
5073
  while (1) switch (_context3.prev = _context3.next) {
5027
5074
  case 0:
@@ -5116,14 +5163,22 @@ function createIdmissionClient(config) {
5116
5163
  payload: 'RUNNING'
5117
5164
  });
5118
5165
  _context3.prev = 8;
5166
+ // The nonce THIS response carried, taken as it is ingested: reading
5167
+ // the shared holder after the await could pick up another client's.
5168
+ responseNonce = null;
5119
5169
  _context3.next = 9;
5120
5170
  return validateSession(authUrl, resolvedSessionId, {
5121
5171
  fetch: config.fetch,
5122
- delay: config.delay
5172
+ delay: config.delay,
5173
+ ingestNonce: function ingestNonce(nonce) {
5174
+ responseNonce = typeof nonce === 'string' && nonce ? nonce : null;
5175
+ ingestSessionAttestation(nonce);
5176
+ }
5123
5177
  });
5124
5178
  case 9:
5125
5179
  valid = _context3.sent;
5126
5180
  finalState = valid ? 'PASSED' : 'FAILED';
5181
+ if (epoch === sessionRunEpoch) validatedSessionNonce = responseNonce;
5127
5182
  dispatchSessionIfCurrent(epoch, {
5128
5183
  type: 'setCheckState',
5129
5184
  payload: finalState
@@ -5193,23 +5248,28 @@ function createIdmissionClient(config) {
5193
5248
  }));
5194
5249
  return _retrySession.apply(this, arguments);
5195
5250
  }
5196
- function submit(_x6, _x7) {
5197
- return _submit.apply(this, arguments);
5251
+ function runPipeline(_x6, _x7, _x8) {
5252
+ return _runPipeline.apply(this, arguments);
5198
5253
  }
5199
- function _submit() {
5200
- _submit = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee7(artifacts, options) {
5201
- var _options$onBeforeSubm;
5202
- 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;
5254
+ function _runPipeline() {
5255
+ _runPipeline = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee7(artifacts, options, kind) {
5256
+ var _artifacts$meta$liven, _artifacts$meta, _options$onBeforeSubm;
5257
+ 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;
5203
5258
  return _regeneratorRuntime.wrap(function (_context7) {
5204
5259
  while (1) switch (_context7.prev = _context7.next) {
5205
5260
  case 0:
5206
- if (!(options.action === SubmissionAction.NONE && !config.onSubmit)) {
5261
+ handsOff = kind === 'handoff' || kind === 'submit' && config.onSubmit !== undefined; // sdk2 short-circuits action NONE to a synthetic success before any
5262
+ // network activity (SubmissionProvider.tsx:1203-1225). This client does
5263
+ // not fabricate that response, but it keeps the "NONE does no network
5264
+ // work" guarantee by rejecting here, before any upload — unless the
5265
+ // request is being handed off, which is the one thing NONE can do.
5266
+ if (!(options.action === SubmissionAction.NONE && !handsOff)) {
5207
5267
  _context7.next = 1;
5208
5268
  break;
5209
5269
  }
5210
5270
  throw new SubmissionError({
5211
5271
  statusCode: 'UNSUPPORTED_ACTION',
5212
- statusMessage: "submit() rejects action: 'NONE' -- capture-only, no-network submission is the controller layer's responsibility (plan 3), not this client's"
5272
+ statusMessage: "action 'NONE' has no endpoint to post to; use handoff() to build the request without posting it"
5213
5273
  });
5214
5274
  case 1:
5215
5275
  if (!(store.getState().session.sessionCheckState !== 'PASSED')) {
@@ -5218,6 +5278,11 @@ function createIdmissionClient(config) {
5218
5278
  }
5219
5279
  throw new AuthenticationError(401, 'session not validated');
5220
5280
  case 2:
5281
+ route = currentRoute(); // Claimed, not read: an overlapping operation must not reuse it, and a
5282
+ // `checkLiveness()` that lands mid-operation keeps its own token for the
5283
+ // next one (SubmissionProvider.tsx:1350 cleared it after the submit).
5284
+ claimedLivenessToken = (_artifacts$meta$liven = (_artifacts$meta = artifacts.meta) == null ? void 0 : _artifacts$meta.livenessToken) != null ? _artifacts$meta$liven : livenessToken;
5285
+ livenessToken = undefined;
5221
5286
  store.setState({
5222
5287
  submissionStatus: SubmissionStatus.SUBMITTING,
5223
5288
  submissionError: undefined
@@ -5234,7 +5299,7 @@ function createIdmissionClient(config) {
5234
5299
  _context7.next = 5;
5235
5300
  return buildSubmissionPayload(_extends({}, artifacts, {
5236
5301
  meta: _extends({}, artifacts.meta, {
5237
- livenessToken: (_artifacts$meta$liven = (_artifacts$meta = artifacts.meta) == null ? void 0 : _artifacts$meta.livenessToken) != null ? _artifacts$meta$liven : livenessToken
5302
+ livenessToken: claimedLivenessToken
5238
5303
  })
5239
5304
  }), _extends({}, options, {
5240
5305
  onBeforeSubmit: beforeSubmit ? function (request) {
@@ -5250,7 +5315,7 @@ function createIdmissionClient(config) {
5250
5315
  // withJobTaskMetadata (see its own comment above): only present
5251
5316
  // when options.jobID/taskID are present.
5252
5317
  uploadDocument: documentServiceEnabled ? (/*#__PURE__*/function () {
5253
- var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee6(blob, metadata) {
5318
+ var _ref3 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee6(blob, metadata) {
5254
5319
  var result, _t3;
5255
5320
  return _regeneratorRuntime.wrap(function (_context6) {
5256
5321
  while (1) switch (_context6.prev = _context6.next) {
@@ -5267,7 +5332,7 @@ function createIdmissionClient(config) {
5267
5332
  });
5268
5333
  _context6.prev = 1;
5269
5334
  _context6.next = 2;
5270
- return performUpload(blob, withJobTaskMetadata(metadata, options.jobID, options.taskID));
5335
+ return performUpload(blob, withJobTaskMetadata(metadata, options.jobID, options.taskID), route);
5271
5336
  case 2:
5272
5337
  result = _context6.sent;
5273
5338
  progress.observe({
@@ -5297,12 +5362,13 @@ function createIdmissionClient(config) {
5297
5362
  }
5298
5363
  }, _callee6, null, [[1, 3, 4, 5]]);
5299
5364
  }));
5300
- return function (_x10, _x11) {
5301
- return _ref2.apply(this, arguments);
5365
+ return function (_x13, _x14) {
5366
+ return _ref3.apply(this, arguments);
5302
5367
  };
5303
5368
  }()) : undefined,
5304
5369
  now: config.now,
5305
- sdkVersions: config.sdkVersions
5370
+ sdkVersions: config.sdkVersions,
5371
+ collectors: routeBoundCollectors(route)
5306
5372
  });
5307
5373
  case 5:
5308
5374
  payloadResult = _context7.sent;
@@ -5316,40 +5382,41 @@ function createIdmissionClient(config) {
5316
5382
  case 7:
5317
5383
  payloadBuildEnd = payloadResult.uploadTimings.payloadBuildEnd;
5318
5384
  uploadMeasurements = payloadResult.uploadTimings.uploads;
5319
- request = payloadResult.request; // Stashed HERE rather than next to `lastSubmissionTimings` in the
5320
- // `finally`, because the hand-off below returns early: parking it in
5321
- // the same setState as the timings would leave `onSubmit` customers
5322
- // with a timings block and no request to go with it.
5385
+ request = payloadResult.request; // Stashed before the hand-off returns, so hand-off callers get the
5386
+ // request alongside the timings the `finally` records.
5323
5387
  store.setState({
5324
5388
  attestationAttached: payloadResult.attestationAttached,
5325
5389
  lastSubmissionRequest: request
5326
5390
  });
5327
- // THE HAND-OFF. sdk2 short-circuits at the equivalent point
5328
- // (SubmissionProvider.tsx:1374-1377, `return onSubmit.current(request)`
5329
- // before `defaultOnSubmit`), so everything above this line runs and
5330
- // nothing below it does.
5331
- //
5332
- // The status goes to SUBMITTED, where sdk2 leaves it at READY. That is a
5333
- // deliberate divergence in INTERNAL state to preserve the VISIBLE
5334
- // behaviour: sdk2's wizard renders an empty fragment for READY via its
5335
- // switch `default`, whereas this codebase renders the submitting screen
5336
- // for READY — so inheriting READY would park the user on a spinner
5337
- // forever. SUBMITTED with no response falls through every terminal
5338
- // branch to `return null`, which is sdk2's empty fragment.
5339
- if (!config.onSubmit) {
5391
+ if (!handsOff) {
5340
5392
  _context7.next = 8;
5341
5393
  break;
5342
5394
  }
5395
+ // sdk2 short-circuits at the equivalent point
5396
+ // (SubmissionProvider.tsx:1374-1377), so everything above runs and
5397
+ // nothing below does.
5398
+ //
5399
+ // The status goes to SUBMITTED, where sdk2 leaves it at READY. That is
5400
+ // a deliberate divergence in INTERNAL state to preserve the VISIBLE
5401
+ // behaviour: sdk2's wizard renders an empty fragment for READY via its
5402
+ // switch `default`, whereas this codebase renders the submitting
5403
+ // screen for READY — so inheriting READY would park the user on a
5404
+ // spinner forever. SUBMITTED with no response falls through every
5405
+ // terminal branch to `return null`, which is sdk2's empty fragment.
5343
5406
  store.setState({
5344
5407
  submissionStatus: SubmissionStatus.SUBMITTED
5345
5408
  });
5346
- config.onSubmit(request);
5409
+ if (kind === 'submit') config.onSubmit == null || config.onSubmit(request);
5347
5410
  progress.observe({
5348
5411
  kind: 'flow-completed'
5349
5412
  });
5350
- return _context7.abrupt("return", null);
5413
+ built = {
5414
+ request: request,
5415
+ response: null
5416
+ };
5417
+ _context7.next = 23;
5418
+ break;
5351
5419
  case 8:
5352
- sessionId = store.getState().session.sessionId;
5353
5420
  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));
5354
5421
  progress.observe({
5355
5422
  kind: 'phase',
@@ -5364,9 +5431,9 @@ function createIdmissionClient(config) {
5364
5431
  _context7.prev = 9;
5365
5432
  _context7.prev = 10;
5366
5433
  _context7.next = 11;
5367
- return timedFetch(urls.submissionUrl + endpoint, {
5434
+ return timedFetch(route.submissionUrl + endpoint, {
5368
5435
  method: 'POST',
5369
- headers: apiHeaders(sessionId, options.sendBase64DocumentsInSwaggerProxy),
5436
+ headers: apiHeaders(route.sessionId, options.sendBase64DocumentsInSwaggerProxy),
5370
5437
  body: JSON.stringify(request)
5371
5438
  });
5372
5439
  case 11:
@@ -5456,10 +5523,21 @@ function createIdmissionClient(config) {
5456
5523
  progress.observe({
5457
5524
  kind: 'flow-completed'
5458
5525
  });
5459
- config.onResponseReceived == null || config.onResponseReceived(submissionResponse, request);
5460
- return _context7.abrupt("return", submissionResponse);
5526
+ // Legacy `submit()` keeps a throwing `onResponseReceived` inside the
5527
+ // failure path, as it always has; `post()` notifies after the outcome
5528
+ // is settled (below).
5529
+ if (kind === 'submit') {
5530
+ config.onResponseReceived == null || config.onResponseReceived(submissionResponse, request);
5531
+ }
5532
+ built = {
5533
+ request: request,
5534
+ response: submissionResponse
5535
+ };
5461
5536
  case 23:
5462
- _context7.prev = 23;
5537
+ _context7.next = 25;
5538
+ break;
5539
+ case 24:
5540
+ _context7.prev = 24;
5463
5541
  _t0 = _context7["catch"](3);
5464
5542
  if (failedAt === undefined) failedAt = 'submission';
5465
5543
  err = _t0;
@@ -5471,72 +5549,116 @@ function createIdmissionClient(config) {
5471
5549
  // UNLIKE sdk2 (`if (throwErrorsOnFailure) throw err`) there is no
5472
5550
  // catch-swallow path: rejection always propagates.
5473
5551
  throw err;
5474
- case 24:
5475
- _context7.prev = 24;
5476
- // Liveness tokens are single-use: clear after each submit so a stale
5477
- // token isn't reapplied on a retry (SubmissionProvider.tsx:1350).
5478
- livenessToken = undefined;
5552
+ case 25:
5553
+ _context7.prev = 25;
5479
5554
  endedAt = nowImpl();
5555
+ timings = buildSubmissionTimings({
5556
+ startedAt: startedAt,
5557
+ endedAt: endedAt,
5558
+ payloadBuildStart: payloadBuildStart,
5559
+ payloadBuildEnd: payloadBuildEnd,
5560
+ uploads: uploadMeasurements,
5561
+ apiCallStart: apiCallStart,
5562
+ apiCallEnd: apiCallEnd,
5563
+ responseParseStart: responseParseStart,
5564
+ responseParseEnd: responseParseEnd,
5565
+ failedAt: failedAt
5566
+ });
5480
5567
  store.setState({
5481
- lastSubmissionTimings: buildSubmissionTimings({
5482
- startedAt: startedAt,
5483
- endedAt: endedAt,
5484
- payloadBuildStart: payloadBuildStart,
5485
- payloadBuildEnd: payloadBuildEnd,
5486
- uploads: uploadMeasurements,
5487
- apiCallStart: apiCallStart,
5488
- apiCallEnd: apiCallEnd,
5489
- responseParseStart: responseParseStart,
5490
- responseParseEnd: responseParseEnd,
5491
- failedAt: failedAt
5492
- })
5568
+ lastSubmissionTimings: timings
5493
5569
  });
5494
- return _context7.finish(24);
5495
- case 25:
5570
+ return _context7.finish(25);
5571
+ case 26:
5572
+ if (kind === 'post' && built.response) {
5573
+ _built = built, _response = _built.response, _request = _built.request;
5574
+ notifySafely$1('onResponseReceived', function () {
5575
+ return config.onResponseReceived == null ? void 0 : config.onResponseReceived(_response, _request);
5576
+ });
5577
+ }
5578
+ return _context7.abrupt("return", _extends({}, built, {
5579
+ timings: timings
5580
+ }));
5581
+ case 27:
5496
5582
  case "end":
5497
5583
  return _context7.stop();
5498
5584
  }
5499
- }, _callee7, null, [[3, 23, 24, 25], [4, 6], [9, 20], [10, 12]]);
5585
+ }, _callee7, null, [[3, 24, 25, 26], [4, 6], [9, 20], [10, 12]]);
5586
+ }));
5587
+ return _runPipeline.apply(this, arguments);
5588
+ }
5589
+ function submit(artifacts, options) {
5590
+ return runPipeline(artifacts, options, 'submit').then(function (_ref2) {
5591
+ var response = _ref2.response;
5592
+ return response;
5593
+ });
5594
+ }
5595
+ function post(artifacts, options) {
5596
+ return runPipeline(artifacts, options, 'post');
5597
+ }
5598
+ function handoff(_x9, _x0) {
5599
+ return _handoff.apply(this, arguments);
5600
+ }
5601
+ function _handoff() {
5602
+ _handoff = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee8(artifacts, options) {
5603
+ var _yield$runPipeline, request, timings;
5604
+ return _regeneratorRuntime.wrap(function (_context8) {
5605
+ while (1) switch (_context8.prev = _context8.next) {
5606
+ case 0:
5607
+ _context8.next = 1;
5608
+ return runPipeline(artifacts, options, 'handoff');
5609
+ case 1:
5610
+ _yield$runPipeline = _context8.sent;
5611
+ request = _yield$runPipeline.request;
5612
+ timings = _yield$runPipeline.timings;
5613
+ return _context8.abrupt("return", {
5614
+ request: request,
5615
+ timings: timings
5616
+ });
5617
+ case 2:
5618
+ case "end":
5619
+ return _context8.stop();
5620
+ }
5621
+ }, _callee8);
5500
5622
  }));
5501
- return _submit.apply(this, arguments);
5623
+ return _handoff.apply(this, arguments);
5502
5624
  }
5503
- function checkLiveness(_x8, _x9) {
5625
+ function checkLiveness(_x1, _x10) {
5504
5626
  return _checkLiveness.apply(this, arguments);
5505
5627
  }
5506
5628
  function _checkLiveness() {
5507
- _checkLiveness = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee8(imageDataUrl, options) {
5629
+ _checkLiveness = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee9(imageDataUrl, options) {
5508
5630
  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;
5509
- return _regeneratorRuntime.wrap(function (_context8) {
5510
- while (1) switch (_context8.prev = _context8.next) {
5631
+ return _regeneratorRuntime.wrap(function (_context9) {
5632
+ while (1) switch (_context9.prev = _context9.next) {
5511
5633
  case 0:
5512
5634
  if (options === void 0) {
5513
5635
  options = {};
5514
5636
  }
5515
- _context8.prev = 1;
5637
+ _context9.prev = 1;
5516
5638
  selfie = imageDataUrl;
5517
5639
  if (!(options.useDocumentServiceForLivenessChecks && documentServiceEnabled)) {
5518
- _context8.next = 6;
5640
+ _context9.next = 6;
5519
5641
  break;
5520
5642
  }
5521
5643
  if (!selfie.startsWith('data:')) {
5522
5644
  selfie = "data:image/jpeg;base64," + selfie;
5523
5645
  }
5524
- _context8.prev = 2;
5525
- _context8.next = 3;
5646
+ _context9.prev = 2;
5647
+ _context9.next = 3;
5526
5648
  return performUpload(dataUrlToBlob(selfie), withJobTaskMetadata({
5527
5649
  filename: 'liveness',
5528
5650
  filetype: 'image/jpeg'
5529
- }, options.jobID, options.taskID));
5651
+ }, options.jobID, options.taskID), currentRoute());
5530
5652
  case 3:
5531
- selfie = _context8.sent;
5532
- _context8.next = 5;
5653
+ selfie = _context9.sent;
5654
+ _context9.next = 5;
5533
5655
  break;
5534
5656
  case 4:
5535
- _context8.prev = 4;
5536
- _t1 = _context8["catch"](2);
5657
+ _context9.prev = 4;
5658
+ _t1 = _context9["catch"](2);
5537
5659
  throw new NetworkError(_t1 instanceof Error ? _t1.message : String(_t1));
5538
5660
  case 5:
5539
- _context8.next = 7;
5661
+ _context9.next = 7;
5540
5662
  break;
5541
5663
  case 6:
5542
5664
  selfie = dataUrlToBase64Sync$1(selfie);
@@ -5604,19 +5726,19 @@ function createIdmissionClient(config) {
5604
5726
  attestationAttached: attestationAttached
5605
5727
  });
5606
5728
  if (!config.onBeforeLivenessCheck) {
5607
- _context8.next = 9;
5729
+ _context9.next = 9;
5608
5730
  break;
5609
5731
  }
5610
- _context8.next = 8;
5732
+ _context9.next = 8;
5611
5733
  return config.onBeforeLivenessCheck(request);
5612
5734
  case 8:
5613
- result = _context8.sent;
5735
+ result = _context9.sent;
5614
5736
  if (result) request = result;
5615
5737
  case 9:
5616
5738
  endpoint = liveCheckEndpoint(!!options.idCardForFaceMatch);
5617
5739
  sessionId = store.getState().session.sessionId;
5618
- _context8.prev = 10;
5619
- _context8.next = 11;
5740
+ _context9.prev = 10;
5741
+ _context9.next = 11;
5620
5742
  return timedFetch(urls.submissionUrl + endpoint, {
5621
5743
  method: 'POST',
5622
5744
  // SubmissionProvider.tsx:1447 — sourced from the same
@@ -5627,36 +5749,36 @@ function createIdmissionClient(config) {
5627
5749
  body: JSON.stringify(request)
5628
5750
  });
5629
5751
  case 11:
5630
- response = _context8.sent;
5631
- _context8.next = 13;
5752
+ response = _context9.sent;
5753
+ _context9.next = 13;
5632
5754
  break;
5633
5755
  case 12:
5634
- _context8.prev = 12;
5635
- _t10 = _context8["catch"](10);
5756
+ _context9.prev = 12;
5757
+ _t10 = _context9["catch"](10);
5636
5758
  throw new NetworkError(_t10 instanceof Error ? _t10.message : String(_t10));
5637
5759
  case 13:
5638
5760
  if (response.ok) {
5639
- _context8.next = 18;
5761
+ _context9.next = 18;
5640
5762
  break;
5641
5763
  }
5642
5764
  if (!(response.status === 401 || response.status === 403)) {
5643
- _context8.next = 15;
5765
+ _context9.next = 15;
5644
5766
  break;
5645
5767
  }
5646
5768
  _t11 = AuthenticationError;
5647
5769
  _t12 = response.status;
5648
- _context8.next = 14;
5770
+ _context9.next = 14;
5649
5771
  return response.text();
5650
5772
  case 14:
5651
- _t13 = _context8.sent;
5773
+ _t13 = _context9.sent;
5652
5774
  throw new _t11(_t12, _t13);
5653
5775
  case 15:
5654
- _context8.next = 16;
5776
+ _context9.next = 16;
5655
5777
  return response.text();
5656
5778
  case 16:
5657
- statusMessage = _context8.sent;
5779
+ statusMessage = _context9.sent;
5658
5780
  if (!(!statusMessage || statusMessage === 'Load failed')) {
5659
- _context8.next = 17;
5781
+ _context9.next = 17;
5660
5782
  break;
5661
5783
  }
5662
5784
  throw new NetworkError(statusMessage);
@@ -5666,12 +5788,12 @@ function createIdmissionClient(config) {
5666
5788
  statusMessage: statusMessage
5667
5789
  });
5668
5790
  case 18:
5669
- _context8.next = 19;
5791
+ _context9.next = 19;
5670
5792
  return response.json();
5671
5793
  case 19:
5672
- livenessResponse = _context8.sent;
5794
+ livenessResponse = _context9.sent;
5673
5795
  if (!(livenessResponse.status.statusCode !== '000')) {
5674
- _context8.next = 20;
5796
+ _context9.next = 20;
5675
5797
  break;
5676
5798
  }
5677
5799
  throw new SubmissionError(livenessResponse.status);
@@ -5684,7 +5806,7 @@ function createIdmissionClient(config) {
5684
5806
  // unconditional here — a deliberate scope narrowing, not a silent drop.
5685
5807
  livenessToken = (_livenessResponse$res = livenessResponse.resultData) == null ? void 0 : _livenessResponse$res.livenessToken;
5686
5808
  if (!(options.softFail && !isLiveFaceConfirmed((_livenessResponse$res2 = livenessResponse.resultData) == null ? void 0 : _livenessResponse$res2.verificationResult))) {
5687
- _context8.next = 21;
5809
+ _context9.next = 21;
5688
5810
  break;
5689
5811
  }
5690
5812
  // Current sdk2 (SubmissionProvider.tsx checkLiveness): softFail also
@@ -5693,21 +5815,21 @@ function createIdmissionClient(config) {
5693
5815
  // non-live capture) and hand back a typed failure that still carries
5694
5816
  // the response so callers can read the detection flags.
5695
5817
  livenessToken = undefined;
5696
- return _context8.abrupt("return", {
5818
+ return _context9.abrupt("return", {
5697
5819
  ok: false,
5698
5820
  error: new Error("Liveness not confirmed: " + ((_livenessResponse$res3 = (_livenessResponse$res4 = livenessResponse.resultData) == null ? void 0 : _livenessResponse$res4.verificationResult) != null ? _livenessResponse$res3 : 'no verificationResult')),
5699
5821
  response: livenessResponse
5700
5822
  });
5701
5823
  case 21:
5702
- return _context8.abrupt("return", {
5824
+ return _context9.abrupt("return", {
5703
5825
  ok: true,
5704
5826
  response: livenessResponse
5705
5827
  });
5706
5828
  case 22:
5707
- _context8.prev = 22;
5708
- _t14 = _context8["catch"](1);
5829
+ _context9.prev = 22;
5830
+ _t14 = _context9["catch"](1);
5709
5831
  if (!options.softFail) {
5710
- _context8.next = 23;
5832
+ _context9.next = 23;
5711
5833
  break;
5712
5834
  }
5713
5835
  // Caller is treating this as a best-effort check. Don't surface the
@@ -5715,7 +5837,7 @@ function createIdmissionClient(config) {
5715
5837
  // typed failure result instead of sdk2's silent `undefined` (deliberate
5716
5838
  // divergence #3).
5717
5839
  livenessToken = undefined;
5718
- return _context8.abrupt("return", {
5840
+ return _context9.abrupt("return", {
5719
5841
  ok: false,
5720
5842
  error: _t14
5721
5843
  });
@@ -5729,32 +5851,32 @@ function createIdmissionClient(config) {
5729
5851
  throw err;
5730
5852
  case 24:
5731
5853
  case "end":
5732
- return _context8.stop();
5854
+ return _context9.stop();
5733
5855
  }
5734
- }, _callee8, null, [[1, 22], [2, 4], [10, 12]]);
5856
+ }, _callee9, null, [[1, 22], [2, 4], [10, 12]]);
5735
5857
  }));
5736
5858
  return _checkLiveness.apply(this, arguments);
5737
5859
  }
5738
- function clientUploadDocument(_x0, _x1) {
5860
+ function clientUploadDocument(_x11, _x12) {
5739
5861
  return _clientUploadDocument.apply(this, arguments);
5740
5862
  }
5741
5863
  function _clientUploadDocument() {
5742
- _clientUploadDocument = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee9(blob, metadata) {
5743
- return _regeneratorRuntime.wrap(function (_context9) {
5744
- while (1) switch (_context9.prev = _context9.next) {
5864
+ _clientUploadDocument = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee0(blob, metadata) {
5865
+ return _regeneratorRuntime.wrap(function (_context0) {
5866
+ while (1) switch (_context0.prev = _context0.next) {
5745
5867
  case 0:
5746
5868
  if (documentServiceEnabled) {
5747
- _context9.next = 1;
5869
+ _context0.next = 1;
5748
5870
  break;
5749
5871
  }
5750
5872
  throw new Error('document upload is disabled: no documentServiceUrl configured');
5751
5873
  case 1:
5752
- return _context9.abrupt("return", performUpload(blob, metadata != null ? metadata : {}));
5874
+ return _context0.abrupt("return", performUpload(blob, metadata != null ? metadata : {}, currentRoute()));
5753
5875
  case 2:
5754
5876
  case "end":
5755
- return _context9.stop();
5877
+ return _context0.stop();
5756
5878
  }
5757
- }, _callee9);
5879
+ }, _callee0);
5758
5880
  }));
5759
5881
  return _clientUploadDocument.apply(this, arguments);
5760
5882
  }
@@ -5770,6 +5892,8 @@ function createIdmissionClient(config) {
5770
5892
  validateSession: validateSessionMethod,
5771
5893
  retrySession: retrySession,
5772
5894
  submit: submit,
5895
+ post: post,
5896
+ handoff: handoff,
5773
5897
  checkLiveness: checkLiveness,
5774
5898
  uploadDocument: clientUploadDocument
5775
5899
  };
@@ -38394,7 +38518,9 @@ function SubmissionProvider(_ref) {
38394
38518
  onComplete = _ref.onComplete,
38395
38519
  onApproved = _ref.onApproved,
38396
38520
  onDenied = _ref.onDenied,
38397
- onRequestFailure = _ref.onRequestFailure;
38521
+ onSubmissionFailure = _ref.onSubmissionFailure,
38522
+ onRequestFailure = _ref.onRequestFailure,
38523
+ mode = _ref.mode;
38398
38524
  var progress = useCaptureObserver();
38399
38525
  var clientState = useSyncExternalStore(client.subscribe, client.getState, client.getState);
38400
38526
  var _useAuthState = useAuthState(),
@@ -38407,10 +38533,22 @@ function SubmissionProvider(_ref) {
38407
38533
  _useState4 = _slicedToArray(_useState3, 2),
38408
38534
  localError = _useState4[0],
38409
38535
  setLocalError = _useState4[1];
38410
- var _useState5 = useState(false),
38536
+ var _useState5 = useState(IDLE_ATTEMPT),
38411
38537
  _useState6 = _slicedToArray(_useState5, 2),
38412
- resubmitting = _useState6[0],
38413
- setResubmitting = _useState6[1];
38538
+ attempt = _useState6[0],
38539
+ setAttempt = _useState6[1];
38540
+ // Which path the latest submission took. State is read from that path even
38541
+ // if `mode` changes while it is in flight; before any submission, `mode`
38542
+ // decides.
38543
+ var _useState7 = useState(null),
38544
+ _useState8 = _slicedToArray(_useState7, 2),
38545
+ startedExplicit = _useState8[0],
38546
+ setStartedExplicit = _useState8[1];
38547
+ var reportFailure = onSubmissionFailure != null ? onSubmissionFailure : onRequestFailure;
38548
+ var _useState9 = useState(false),
38549
+ _useState0 = _slicedToArray(_useState9, 2),
38550
+ resubmitting = _useState0[0],
38551
+ setResubmitting = _useState0[1];
38414
38552
  var lastArtifactsRef = useRef(null);
38415
38553
  var submitInFlightRef = useRef(null);
38416
38554
  var resubmitInFlightRef = useRef(null);
@@ -38428,6 +38566,71 @@ function SubmissionProvider(_ref) {
38428
38566
  }) : incoming;
38429
38567
  // Store the merged artifacts so a resubmit carries location too.
38430
38568
  lastArtifactsRef.current = artifacts;
38569
+ setStartedExplicit(mode !== undefined);
38570
+ if (mode !== undefined) {
38571
+ // Registered before anything customer-supplied runs, so a throw from
38572
+ // a notification can never leave the flow without a status.
38573
+ setAttempt(_extends({}, IDLE_ATTEMPT, {
38574
+ status: SubmissionStatus.SUBMITTING
38575
+ }));
38576
+ var _unbindProgress = bindSubmissionObserver(artifacts, progress);
38577
+ // The client call waits one microtask so the in-flight promise is
38578
+ // registered first: an `onSubmissionStarted` that calls `submit()`
38579
+ // gets this attempt back instead of starting a second one.
38580
+ var _promise = Promise.resolve().then(function () {
38581
+ return runAttempt(client, mode, artifacts, _extends({}, options, {
38582
+ action: action
38583
+ }));
38584
+ }).then(function (outcome) {
38585
+ setAttempt(_extends({}, outcome, {
38586
+ status: SubmissionStatus.SUBMITTED,
38587
+ error: null
38588
+ }));
38589
+ var response = outcome.response,
38590
+ request = outcome.request;
38591
+ if (response === null) {
38592
+ // Terminal once called; the handler is never awaited.
38593
+ if (typeof mode === 'object') {
38594
+ notifySafely('submitMode.handoff', function () {
38595
+ return mode.handoff(request);
38596
+ });
38597
+ }
38598
+ return null;
38599
+ }
38600
+ notifySafely('onComplete', function () {
38601
+ return onComplete == null ? void 0 : onComplete(response);
38602
+ });
38603
+ if (isApprovedResponse(action, response)) {
38604
+ notifySafely('onApproved', function () {
38605
+ return onApproved == null ? void 0 : onApproved(response);
38606
+ });
38607
+ } else {
38608
+ notifySafely('onDenied', function () {
38609
+ return onDenied == null ? void 0 : onDenied(response);
38610
+ });
38611
+ }
38612
+ return response;
38613
+ }, function (cause) {
38614
+ var error = cause instanceof Error ? cause : new Error(String(cause));
38615
+ setAttempt(_extends({}, IDLE_ATTEMPT, {
38616
+ status: SubmissionStatus.FAILED,
38617
+ error: error
38618
+ }));
38619
+ notifySafely('onSubmissionFailure', function () {
38620
+ return reportFailure == null ? void 0 : reportFailure(error);
38621
+ });
38622
+ throw error;
38623
+ })["finally"](function () {
38624
+ _unbindProgress();
38625
+ submitInFlightRef.current = null;
38626
+ setResubmitting(false);
38627
+ });
38628
+ submitInFlightRef.current = _promise;
38629
+ notifySafely('onSubmissionStarted', function () {
38630
+ return onSubmissionStarted == null ? void 0 : onSubmissionStarted(artifacts);
38631
+ });
38632
+ return _promise;
38633
+ }
38431
38634
  setSubmissionResponse(null);
38432
38635
  setLocalError(null);
38433
38636
  onSubmissionStarted == null || onSubmissionStarted(artifacts);
@@ -38448,7 +38651,7 @@ function SubmissionProvider(_ref) {
38448
38651
  })["catch"](function (cause) {
38449
38652
  var error = cause instanceof Error ? cause : new Error(String(cause));
38450
38653
  setLocalError(error);
38451
- onRequestFailure == null || onRequestFailure(error);
38654
+ reportFailure == null || reportFailure(error);
38452
38655
  throw error;
38453
38656
  })["finally"](function () {
38454
38657
  unbindProgress();
@@ -38457,7 +38660,7 @@ function SubmissionProvider(_ref) {
38457
38660
  });
38458
38661
  submitInFlightRef.current = promise;
38459
38662
  return promise;
38460
- }, [action, client, geolocation, onApproved, onComplete, onDenied, onRequestFailure, onSubmissionStarted, options, progress]);
38663
+ }, [action, client, geolocation, onApproved, onComplete, onDenied, reportFailure, onSubmissionStarted, options, progress, mode]);
38461
38664
  var resubmit = useMemo(function () {
38462
38665
  if (!authState.session.canRefreshSession) return null;
38463
38666
  return function () {
@@ -38502,22 +38705,120 @@ function SubmissionProvider(_ref) {
38502
38705
  }, [authState.session.canRefreshSession, client, submit]);
38503
38706
  var value = useMemo(function () {
38504
38707
  var _ref3, _clientState$lastSubm, _clientState$lastSubm2;
38708
+ if (startedExplicit != null ? startedExplicit : mode !== undefined) {
38709
+ return {
38710
+ action: action,
38711
+ submit: submit,
38712
+ submissionStatus: resubmitting ? SubmissionStatus.SUBMITTING : attempt.status,
38713
+ submissionResponse: attempt.response,
38714
+ submissionError: attempt.error,
38715
+ lastSubmissionTimings: attempt.timings,
38716
+ lastSubmissionRequest: attempt.request,
38717
+ resubmit: resubmit
38718
+ };
38719
+ }
38505
38720
  return {
38506
38721
  action: action,
38507
38722
  submit: submit,
38508
- submissionStatus: resubmitting ? SubmissionStatus.SUBMITTING : clientState.submissionStatus,
38723
+ // A rejection before the client records anything (an unsupported
38724
+ // action, an unvalidated session) leaves the client at READY, which the
38725
+ // wizard renders as its submitting screen; the local error is the
38726
+ // failure it would otherwise never show.
38727
+ submissionStatus: resubmitting ? SubmissionStatus.SUBMITTING : localError && clientState.submissionStatus === SubmissionStatus.READY ? SubmissionStatus.FAILED : clientState.submissionStatus,
38509
38728
  submissionResponse: submissionResponse,
38510
38729
  submissionError: (_ref3 = localError != null ? localError : clientState.submissionError) != null ? _ref3 : null,
38511
38730
  lastSubmissionTimings: (_clientState$lastSubm = clientState.lastSubmissionTimings) != null ? _clientState$lastSubm : null,
38512
38731
  lastSubmissionRequest: (_clientState$lastSubm2 = clientState.lastSubmissionRequest) != null ? _clientState$lastSubm2 : null,
38513
38732
  resubmit: resubmit
38514
38733
  };
38515
- }, [action, clientState.lastSubmissionRequest, clientState.lastSubmissionTimings, clientState.submissionError, clientState.submissionStatus, localError, resubmit, resubmitting, submissionResponse, submit]);
38734
+ }, [action, attempt, clientState.lastSubmissionRequest, clientState.lastSubmissionTimings, clientState.submissionError, clientState.submissionStatus, localError, mode, resubmit, resubmitting, startedExplicit, submissionResponse, submit]);
38516
38735
  return jsx(SubmissionContext.Provider, {
38517
38736
  value: value,
38518
38737
  children: children
38519
38738
  });
38520
38739
  }
38740
+ var IDLE_ATTEMPT = {
38741
+ status: SubmissionStatus.READY,
38742
+ response: null,
38743
+ request: null,
38744
+ timings: null,
38745
+ error: null
38746
+ };
38747
+ /**
38748
+ * One explicit-mode attempt through the client's `post()` or `handoff()`.
38749
+ * Never falls back to `submit()`: that would let the deprecated
38750
+ * `config.onSubmit` decide what an explicit mode already decided.
38751
+ */
38752
+ function runAttempt(_x, _x2, _x3, _x4) {
38753
+ return _runAttempt.apply(this, arguments);
38754
+ }
38755
+ function _runAttempt() {
38756
+ _runAttempt = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2(client, mode, artifacts, options) {
38757
+ var _yield$client$handoff, request, timings;
38758
+ return _regeneratorRuntime.wrap(function (_context2) {
38759
+ while (1) switch (_context2.prev = _context2.next) {
38760
+ case 0:
38761
+ if (!(mode === 'capture')) {
38762
+ _context2.next = 1;
38763
+ break;
38764
+ }
38765
+ throw new Error("submitMode 'capture' does not submit; the flow reports onCaptured instead");
38766
+ case 1:
38767
+ if (!(mode === 'post')) {
38768
+ _context2.next = 3;
38769
+ break;
38770
+ }
38771
+ if (client.post) {
38772
+ _context2.next = 2;
38773
+ break;
38774
+ }
38775
+ throw missingMethod('post', "submitMode 'post'");
38776
+ case 2:
38777
+ return _context2.abrupt("return", client.post(artifacts, options));
38778
+ case 3:
38779
+ if (client.handoff) {
38780
+ _context2.next = 4;
38781
+ break;
38782
+ }
38783
+ throw missingMethod('handoff', 'submitMode { handoff }');
38784
+ case 4:
38785
+ _context2.next = 5;
38786
+ return client.handoff(artifacts, options);
38787
+ case 5:
38788
+ _yield$client$handoff = _context2.sent;
38789
+ request = _yield$client$handoff.request;
38790
+ timings = _yield$client$handoff.timings;
38791
+ return _context2.abrupt("return", {
38792
+ request: request,
38793
+ timings: timings,
38794
+ response: null
38795
+ });
38796
+ case 6:
38797
+ case "end":
38798
+ return _context2.stop();
38799
+ }
38800
+ }, _callee2);
38801
+ }));
38802
+ return _runAttempt.apply(this, arguments);
38803
+ }
38804
+ function missingMethod(method, needs) {
38805
+ return new Error(needs + " needs client." + method + "(), which this client does not have. " + 'Create the client with createIdmissionClient or useIdmissionClient.');
38806
+ }
38807
+ /**
38808
+ * Runs a customer callback whose failure must not change an outcome that is
38809
+ * already settled: a throw or a rejected promise is logged, never rethrown.
38810
+ */
38811
+ function notifySafely(name, notify) {
38812
+ try {
38813
+ // `Promise.resolve`, not `instanceof Promise`: a promise from another
38814
+ // realm (an iframe) fails that check, and its rejection would go unhandled.
38815
+ Promise.resolve(notify())["catch"](function (e) {
38816
+ return warn(name + " rejected", e);
38817
+ });
38818
+ } catch (e) {
38819
+ warn(name + " threw", e);
38820
+ }
38821
+ }
38521
38822
  function useSubmission() {
38522
38823
  var context = useContext(SubmissionContext);
38523
38824
  if (!context) {
@@ -40382,11 +40683,12 @@ function RemoteDiagnosticsMount(_ref) {
40382
40683
  }
40383
40684
 
40384
40685
  var _templateObject$1, _templateObject2$1, _templateObject3, _templateObject4;
40385
- var _excluded$9 = ["client", "action", "submission", "theme", "className", "geolocationEnabled", "geolocationRequired", "captureProgress", "remoteDiagnostics", "loadingSpinner", "showEnrollmentId", "lang", "children"];
40686
+ var _excluded$9 = ["client", "action", "submission", "submitMode", "theme", "className", "geolocationEnabled", "geolocationRequired", "captureProgress", "remoteDiagnostics", "loadingSpinner", "showEnrollmentId", "lang", "children"];
40386
40687
  function FlowChassis(_ref) {
40387
40688
  var client = _ref.client,
40388
40689
  action = _ref.action,
40389
40690
  submission = _ref.submission,
40691
+ submitMode = _ref.submitMode,
40390
40692
  _ref$theme = _ref.theme,
40391
40693
  theme = _ref$theme === void 0 ? 'default' : _ref$theme,
40392
40694
  className = _ref.className,
@@ -40419,6 +40721,7 @@ function FlowChassis(_ref) {
40419
40721
  client: client,
40420
40722
  action: action,
40421
40723
  options: submission,
40724
+ mode: submitMode,
40422
40725
  geolocation: geolocation.position
40423
40726
  }, callbacks, {
40424
40727
  children: jsx(FlowPage, {
@@ -40739,7 +41042,7 @@ function withVirtualCameras(camera, allowVirtualCameras) {
40739
41042
  return base;
40740
41043
  }
40741
41044
 
40742
- 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"];
41045
+ 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"];
40743
41046
  var EMPTY_ID_CAPTURE$3 = {};
40744
41047
  var EMPTY_SIGNATURE_CAPTURE$5 = {};
40745
41048
  var EMPTY_ID_VIEW$3 = {};
@@ -40756,8 +41059,8 @@ function IdValidationFlow(_ref) {
40756
41059
  submission = _ref$submission === void 0 ? EMPTY_SUBMISSION$6 : _ref$submission,
40757
41060
  _ref$initialArtifacts = _ref.initialArtifacts,
40758
41061
  initialArtifacts = _ref$initialArtifacts === void 0 ? EMPTY_ARTIFACTS$9 : _ref$initialArtifacts,
40759
- _ref$captureOnly = _ref.captureOnly,
40760
- captureOnly = _ref$captureOnly === void 0 ? false : _ref$captureOnly,
41062
+ submitMode = _ref.submitMode,
41063
+ captureOnly = _ref.captureOnly,
40761
41064
  signatureController = _ref.signatureController,
40762
41065
  _ref$signatureCapture = _ref.signatureCapture,
40763
41066
  signatureCapture = _ref$signatureCapture === void 0 ? EMPTY_SIGNATURE_CAPTURE$5 : _ref$signatureCapture,
@@ -40916,10 +41219,12 @@ function IdValidationFlow(_ref) {
40916
41219
  successIssuerCaptionText: 'confirmed'
40917
41220
  }
40918
41221
  });
41222
+ var mode = submitMode != null ? submitMode : captureOnly ? 'capture' : undefined;
40919
41223
  return jsxs(FlowChassis, _extends({
40920
41224
  client: client,
40921
41225
  action: SubmissionAction.VALIDATE,
40922
41226
  submission: submission,
41227
+ submitMode: mode,
40923
41228
  theme: theme,
40924
41229
  className: className,
40925
41230
  lang: lang
@@ -40927,7 +41232,7 @@ function IdValidationFlow(_ref) {
40927
41232
  children: [jsx(CompositeWizard, _extends({}, ringScreens, {
40928
41233
  steps: steps,
40929
41234
  initialArtifacts: initialArtifacts,
40930
- captureOnly: captureOnly,
41235
+ captureOnly: mode === 'capture',
40931
41236
  showResultScreen: showResultScreen != null ? showResultScreen : showSuccessScreen,
40932
41237
  showDiagnostics: showDiagnostics,
40933
41238
  onArtifactsCollected: onCaptured,
@@ -41387,6 +41692,10 @@ function SignatureKYCFlow(_ref) {
41387
41692
  captureProgress = _ref.captureProgress,
41388
41693
  remoteDiagnostics = _ref.remoteDiagnostics,
41389
41694
  loadingSpinner = _ref.loadingSpinner,
41695
+ _ref$submitMode = _ref.submitMode,
41696
+ submitMode = _ref$submitMode === void 0 ? 'capture' : _ref$submitMode,
41697
+ onSubmissionStarted = _ref.onSubmissionStarted,
41698
+ onSubmissionFailure = _ref.onSubmissionFailure,
41390
41699
  onCaptured = _ref.onCaptured,
41391
41700
  onCaptureError = _ref.onCaptureError;
41392
41701
  // Flow-wide settings reach each step unless its own bag sets them.
@@ -41582,13 +41891,21 @@ function SignatureKYCFlow(_ref) {
41582
41891
  resolvedSelfieController.actions.retry();
41583
41892
  setStage('face-liveness');
41584
41893
  }, [resolvedSelfieController]);
41894
+ // Lives here, above the chassis's session gate: a session error unmounts
41895
+ // and remounts `SignatureHandoff`, and must not start the hand-off again.
41896
+ var handoffStartedRef = useRef(false);
41897
+ var claimHandoffStart = useCallback(function () {
41898
+ if (handoffStartedRef.current) return false;
41899
+ handoffStartedRef.current = true;
41900
+ return true;
41901
+ }, []);
41585
41902
  var handleSignatureCompleted = useCallback(function (artifacts) {
41586
41903
  if (completedRef.current) return;
41587
41904
  completedRef.current = true;
41588
41905
  artifactsRef.current = mergeSubmissionArtifacts(artifactsRef.current, artifacts);
41589
41906
  setStage('complete');
41590
- onCaptured == null || onCaptured(artifactsRef.current);
41591
- }, [onCaptured]);
41907
+ if (submitMode === 'capture') onCaptured == null || onCaptured(artifactsRef.current);
41908
+ }, [onCaptured, submitMode]);
41592
41909
  var handleLivenessFailureExit = useCallback(function () {
41593
41910
  onExitAfterLivenessFailure == null || onExitAfterLivenessFailure();
41594
41911
  if (allowSignatureAfterLivenessCheckFailure) handleLivenessDone();
@@ -41597,6 +41914,9 @@ function SignatureKYCFlow(_ref) {
41597
41914
  client: client,
41598
41915
  action: SubmissionAction.NONE,
41599
41916
  submission: submission,
41917
+ submitMode: submitMode,
41918
+ onSubmissionStarted: onSubmissionStarted,
41919
+ onSubmissionFailure: onSubmissionFailure,
41600
41920
  theme: theme,
41601
41921
  className: className,
41602
41922
  lang: lang,
@@ -41606,8 +41926,11 @@ function SignatureKYCFlow(_ref) {
41606
41926
  remoteDiagnostics: remoteDiagnostics,
41607
41927
  loadingSpinner: loadingSpinner,
41608
41928
  children: [jsx(CaptureProgressCompletion, {
41609
- completed: stage === 'complete'
41610
- }), stage !== 'complete' ? jsxs(HandoffRoot, {
41929
+ completed: stage === 'complete' && submitMode === 'capture'
41930
+ }), stage === 'complete' && submitMode !== 'capture' ? jsx(SignatureHandoff, {
41931
+ artifacts: artifactsRef.current,
41932
+ claimStart: claimHandoffStart
41933
+ }) : null, stage !== 'complete' ? jsxs(HandoffRoot, {
41611
41934
  children: [jsx(SignatureCaptureView, _extends({}, signatureView, {
41612
41935
  skipSuccessScreen: impliedSkipSuccessScreen(signatureView.skipSuccessScreen, isRingIntroActive(faceView)),
41613
41936
  controller: resolvedSignatureController,
@@ -41657,6 +41980,43 @@ function SignatureKYCFlow(_ref) {
41657
41980
  }) : null]
41658
41981
  });
41659
41982
  }
41983
+ /**
41984
+ * Hands the finished capture off once the session has passed: a finishing
41985
+ * screen while the request is built, a retry screen if that fails, and
41986
+ * nothing once it has been handed off.
41987
+ */
41988
+ function SignatureHandoff(_ref3) {
41989
+ var artifacts = _ref3.artifacts,
41990
+ claimStart = _ref3.claimStart;
41991
+ var _useSubmission = useSubmission(),
41992
+ action = _useSubmission.action,
41993
+ submit = _useSubmission.submit,
41994
+ submissionStatus = _useSubmission.submissionStatus,
41995
+ submissionError = _useSubmission.submissionError;
41996
+ var sessionReady = useSessionReady();
41997
+ // The provider reports a failure itself; these catches only keep the
41998
+ // rejection from going unhandled.
41999
+ useEffect(function () {
42000
+ if (!sessionReady || !claimStart()) return;
42001
+ submit(artifacts)["catch"](function () {});
42002
+ }, [artifacts, claimStart, sessionReady, submit]);
42003
+ if (submissionStatus === SubmissionStatus.SUBMITTED) return null;
42004
+ if (submissionStatus === SubmissionStatus.FAILED) {
42005
+ return jsx(SubmissionErrorOverlay, {
42006
+ error: submissionError,
42007
+ onRetry: function onRetry() {
42008
+ submit(artifacts)["catch"](function () {});
42009
+ }
42010
+ });
42011
+ }
42012
+ var text = submissionStatusText(action, artifacts);
42013
+ return jsx(OrbStatusScreen, {
42014
+ state: "working",
42015
+ text: text,
42016
+ accessibleLabel: text,
42017
+ loadingStage: "submission"
42018
+ });
42019
+ }
41660
42020
  /**
41661
42021
  * Black, so iOS Safari's bars read as letterboxing around the camera feed
41662
42022
  * rather than as one more colour a theme has to choose.
@@ -41674,10 +42034,10 @@ var CAMERA_EDGE_COLOR = '#000';
41674
42034
  * no flat strip can sit on its bottom edge unseen: that one is drawn invisibly,
41675
42035
  * as on ID capture's overlay. Opaque, it covered the bottom 12px of the bar.
41676
42036
  */
41677
- function FlowEdgeTint(_ref3) {
42037
+ function FlowEdgeTint(_ref4) {
41678
42038
  var _theme$selfieCapture$, _theme$selfieCapture, _theme$background;
41679
- var surface = _ref3.surface,
41680
- modelsReady = _ref3.modelsReady;
42039
+ var surface = _ref4.surface,
42040
+ modelsReady = _ref4.modelsReady;
41681
42041
  var theme = useTheme();
41682
42042
  if (theme.isFullscreen === false || surface === null) return null;
41683
42043
  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');
@@ -41687,9 +42047,9 @@ function FlowEdgeTint(_ref3) {
41687
42047
  hiddenBottomColor: surface === 'overlay' ? selfieLoadingOverlayBottomEdgeColor(theme, modelsReady) : undefined
41688
42048
  });
41689
42049
  }
41690
- function SelfieTrackerAttachment(_ref4) {
41691
- var controller = _ref4.controller,
41692
- video = _ref4.video;
42050
+ function SelfieTrackerAttachment(_ref5) {
42051
+ var controller = _ref5.controller,
42052
+ video = _ref5.video;
41693
42053
  useEffect(function () {
41694
42054
  if (!video) return;
41695
42055
  void controller.attach(video)["catch"](function () {
@@ -41707,7 +42067,7 @@ var FaceStage = styled.div(_templateObject2 || (_templateObject2 = _taggedTempla
41707
42067
  return props.$visible ? 'block' : 'none';
41708
42068
  });
41709
42069
 
41710
- 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"],
42070
+ 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"],
41711
42071
  _excluded2$2 = ["checkLivenessOptions"];
41712
42072
  var EMPTY_ID_CAPTURE$1 = {};
41713
42073
  var EMPTY_FACE_CAPTURE$2 = {};
@@ -41740,8 +42100,8 @@ function VideoIdValidationFlow(_ref) {
41740
42100
  submission = _ref$submission === void 0 ? EMPTY_SUBMISSION$2 : _ref$submission,
41741
42101
  _ref$initialArtifacts = _ref.initialArtifacts,
41742
42102
  initialArtifacts = _ref$initialArtifacts === void 0 ? EMPTY_ARTIFACTS$5 : _ref$initialArtifacts,
41743
- _ref$captureOnly = _ref.captureOnly,
41744
- captureOnly = _ref$captureOnly === void 0 ? false : _ref$captureOnly,
42103
+ submitMode = _ref.submitMode,
42104
+ captureOnly = _ref.captureOnly,
41745
42105
  signatureController = _ref.signatureController,
41746
42106
  _ref$signatureCapture = _ref.signatureCapture,
41747
42107
  signatureCapture = _ref$signatureCapture === void 0 ? EMPTY_SIGNATURE_CAPTURE$2 : _ref$signatureCapture,
@@ -41959,10 +42319,12 @@ function VideoIdValidationFlow(_ref) {
41959
42319
  successIssuerCaptionText: 'confirmed'
41960
42320
  }
41961
42321
  });
42322
+ var mode = submitMode != null ? submitMode : captureOnly ? 'capture' : undefined;
41962
42323
  return jsxs(FlowChassis, _extends({
41963
42324
  client: client,
41964
42325
  action: action,
41965
42326
  submission: submission,
42327
+ submitMode: mode,
41966
42328
  theme: theme,
41967
42329
  className: className,
41968
42330
  lang: lang
@@ -41970,7 +42332,7 @@ function VideoIdValidationFlow(_ref) {
41970
42332
  children: [jsx(CompositeWizard, _extends({}, ringScreens, {
41971
42333
  steps: steps,
41972
42334
  initialArtifacts: initialArtifacts,
41973
- captureOnly: captureOnly,
42335
+ captureOnly: mode === 'capture',
41974
42336
  showResultScreen: showResultScreen != null ? showResultScreen : showSuccessScreen,
41975
42337
  showDiagnostics: showDiagnostics,
41976
42338
  onArtifactsCollected: onCaptured,
@@ -46181,7 +46543,9 @@ function CustomerMatchFlow(_ref) {
46181
46543
  onComplete = _ref.onComplete,
46182
46544
  onCustomerMatched = _ref.onCustomerMatched,
46183
46545
  onCustomerNotMatched = _ref.onCustomerNotMatched,
46546
+ onSubmissionFailure = _ref.onSubmissionFailure,
46184
46547
  onRequestFailure = _ref.onRequestFailure,
46548
+ submitMode = _ref.submitMode,
46185
46549
  onCaptureGuidanceTimeout = _ref.onCaptureGuidanceTimeout,
46186
46550
  onExitCapture = _ref.onExitCapture,
46187
46551
  onExitAfterFailure = _ref.onExitAfterFailure;
@@ -46268,15 +46632,19 @@ function CustomerMatchFlow(_ref) {
46268
46632
  setOutcome('notMatched');
46269
46633
  onCustomerNotMatched == null || onCustomerNotMatched(response);
46270
46634
  }, [onCustomerNotMatched]);
46635
+ var reportFailure = onSubmissionFailure != null ? onSubmissionFailure : onRequestFailure;
46271
46636
  var handleLivenessCheckFailed = useCallback(function (error) {
46272
46637
  setOutcome('failed');
46273
- onRequestFailure == null || onRequestFailure(error);
46274
- }, [onRequestFailure]);
46638
+ reportFailure == null || reportFailure(error);
46639
+ }, [reportFailure]);
46275
46640
  var handleRequestError = useCallback(function (error) {
46276
46641
  errorRef.current = error;
46277
46642
  setOutcome('error');
46278
- onRequestFailure == null || onRequestFailure(error);
46279
- }, [onRequestFailure]);
46643
+ reportFailure == null || reportFailure(error);
46644
+ }, [reportFailure]);
46645
+ var handleHandedOff = useCallback(function () {
46646
+ return setOutcome('handedOff');
46647
+ }, []);
46280
46648
  var handleCaptureGuidanceTimeout = useCallback(function () {
46281
46649
  setOutcome('failed');
46282
46650
  onCaptureGuidanceTimeout == null || onCaptureGuidanceTimeout();
@@ -46317,6 +46685,7 @@ function CustomerMatchFlow(_ref) {
46317
46685
  client: client,
46318
46686
  action: action,
46319
46687
  submission: submission,
46688
+ submitMode: submitMode,
46320
46689
  theme: theme,
46321
46690
  className: className,
46322
46691
  lang: lang,
@@ -46341,6 +46710,7 @@ function CustomerMatchFlow(_ref) {
46341
46710
  onNotMatched: handleNotMatched,
46342
46711
  onLivenessCheckFailed: handleLivenessCheckFailed,
46343
46712
  onRequestError: handleRequestError,
46713
+ onSubmissionIntercepted: handleHandedOff,
46344
46714
  onCaptureGuidanceTimeout: handleCaptureGuidanceTimeout,
46345
46715
  onExitCapture: onExitCapture,
46346
46716
  finishingScreen: {
@@ -46476,6 +46846,84 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
46476
46846
  return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
46477
46847
  };
46478
46848
 
46849
+ function createIdAndFaceValidationJourneyEvent(event, now) {
46850
+ if (now === void 0) {
46851
+ now = function now() {
46852
+ return new Date();
46853
+ };
46854
+ }
46855
+ return _assign(_assign({}, event), {
46856
+ version: 1,
46857
+ flow: 'id-and-face-validation',
46858
+ timestamp: now().toISOString()
46859
+ });
46860
+ }
46861
+ /**
46862
+ * websdk-ui `CompositeWizardStep.id` -> journey stage.
46863
+ *
46864
+ * Four of the five stage names ARE step ids already; only the additional-
46865
+ * documents step differs, because sdk2's stage vocabulary says
46866
+ * `additional-document-capture` (singular "document") while websdk-ui's step
46867
+ * is `additional-documents`. Unknown ids return undefined so a step this
46868
+ * vocabulary has no name for is silently skipped rather than emitted with a
46869
+ * bogus stage — the same shape as sdk2's partial lookup record.
46870
+ */
46871
+ function journeyStageForStepId(stepId) {
46872
+ switch (stepId) {
46873
+ case 'id-capture':
46874
+ case 'face-liveness':
46875
+ case 'signature-capture':
46876
+ case 'video-signature-capture':
46877
+ return stepId;
46878
+ case 'additional-documents':
46879
+ return 'additional-document-capture';
46880
+ default:
46881
+ return undefined;
46882
+ }
46883
+ }
46884
+ /**
46885
+ * The document types sdk2 reports as `document.captured`. sdk2 filters the
46886
+ * wizard's `onDocumentStored` through this set (`primaryIdDocumentTypes`) so
46887
+ * that a document type outside the journey vocabulary cannot widen the event.
46888
+ * Kept as a predicate rather than a Set: the ES5 UMD bundle target makes
46889
+ * `for..of` over a Set a downlevel hazard, and a switch needs no iteration.
46890
+ */
46891
+ function isJourneyDocumentType(documentType) {
46892
+ return documentType === 'idCardFront' || documentType === 'idCardBack' || documentType === 'passport' || documentType === 'singlePage';
46893
+ }
46894
+ /**
46895
+ * The lazy `flow.started` rule, lifted out of sdk2's `emitJourneyEvent`
46896
+ * closure (IdAndFaceValidation.tsx:521-537) so it can be tested without a
46897
+ * React tree.
46898
+ *
46899
+ * sdk2 does NOT simply emit `flow.started` from a mount effect: it emits it
46900
+ * before the FIRST event of any kind, whatever that event is, and then
46901
+ * suppresses the explicit mount emit. The mount effect and the lazy guard
46902
+ * together mean `flow.started` is always the first event a customer sees,
46903
+ * even if some other event races the effect. That ordering guarantee is the
46904
+ * contract, not the effect.
46905
+ */
46906
+ function createJourneyEmitter(callback, now) {
46907
+ var flowStartedEmitted = false;
46908
+ return function emit(event) {
46909
+ if (!callback) return;
46910
+ if (!flowStartedEmitted) {
46911
+ flowStartedEmitted = true;
46912
+ emitWith(callback, {
46913
+ name: 'flow.started'
46914
+ }, now);
46915
+ }
46916
+ if (event.name !== 'flow.started') emitWith(callback, event, now);
46917
+ };
46918
+ }
46919
+ function emitWith(callback, event, now) {
46920
+ try {
46921
+ callback(createIdAndFaceValidationJourneyEvent(event, now));
46922
+ } catch (error) {
46923
+ warn$1('[IdAndFaceValidation] onJourneyEvent callback failed', error);
46924
+ }
46925
+ }
46926
+
46479
46927
  /**
46480
46928
  * sdk2 exports this as a mutable `string[]`
46481
46929
  * (contexts/AuthStateContext.tsx:25), not a readonly tuple — copied rather
@@ -46648,12 +47096,9 @@ function mapClientConfig(props) {
46648
47096
  documentServiceUrl: (_b = props.documentServiceUrl) !== null && _b !== void 0 ? _b : apiBase ? apiBase + '/files/' : override === null || override === void 0 ? void 0 : override.documentServiceUrl,
46649
47097
  onBeforeSubmit: props.onBeforeSubmit,
46650
47098
  onBeforeLivenessCheck: props.onBeforeLivenessCheck,
46651
- // Straight through to the client, which is where sdk2 put it too
46652
- // (SubmissionProvider.submit). That is what makes the SUPPRESSION uniform:
46653
- // every flow — including the two match flows, which own their own stage
46654
- // machine — submits through this one client, so none of them can post
46655
- // behind an integrator who supplied `onSubmit`.
46656
- onSubmit: props.onSubmit,
47099
+ // 2.x's `onSubmit` is not a client option here: each flow maps it to its
47100
+ // own `submitMode: { handoff }` (see ./props.ts), which follows the prop
47101
+ // live where a client option would be fixed at mount.
46657
47102
  onBeforeDocumentUpload: props.onBeforeDocumentUpload,
46658
47103
  onDocumentUploadProgress: props.onDocumentUploadProgress,
46659
47104
  onDocumentUploaded: props.onDocumentUploaded,
@@ -47663,84 +48108,6 @@ function mapFaceCapture(props, prefixed) {
47663
48108
  };
47664
48109
  }
47665
48110
 
47666
- function createIdAndFaceValidationJourneyEvent(event, now) {
47667
- if (now === void 0) {
47668
- now = function now() {
47669
- return new Date();
47670
- };
47671
- }
47672
- return _assign(_assign({}, event), {
47673
- version: 1,
47674
- flow: 'id-and-face-validation',
47675
- timestamp: now().toISOString()
47676
- });
47677
- }
47678
- /**
47679
- * websdk-ui `CompositeWizardStep.id` -> journey stage.
47680
- *
47681
- * Four of the five stage names ARE step ids already; only the additional-
47682
- * documents step differs, because sdk2's stage vocabulary says
47683
- * `additional-document-capture` (singular "document") while websdk-ui's step
47684
- * is `additional-documents`. Unknown ids return undefined so a step this
47685
- * vocabulary has no name for is silently skipped rather than emitted with a
47686
- * bogus stage — the same shape as sdk2's partial lookup record.
47687
- */
47688
- function journeyStageForStepId(stepId) {
47689
- switch (stepId) {
47690
- case 'id-capture':
47691
- case 'face-liveness':
47692
- case 'signature-capture':
47693
- case 'video-signature-capture':
47694
- return stepId;
47695
- case 'additional-documents':
47696
- return 'additional-document-capture';
47697
- default:
47698
- return undefined;
47699
- }
47700
- }
47701
- /**
47702
- * The document types sdk2 reports as `document.captured`. sdk2 filters the
47703
- * wizard's `onDocumentStored` through this set (`primaryIdDocumentTypes`) so
47704
- * that a document type outside the journey vocabulary cannot widen the event.
47705
- * Kept as a predicate rather than a Set: the ES5 UMD bundle target makes
47706
- * `for..of` over a Set a downlevel hazard, and a switch needs no iteration.
47707
- */
47708
- function isJourneyDocumentType(documentType) {
47709
- return documentType === 'idCardFront' || documentType === 'idCardBack' || documentType === 'passport' || documentType === 'singlePage';
47710
- }
47711
- /**
47712
- * The lazy `flow.started` rule, lifted out of sdk2's `emitJourneyEvent`
47713
- * closure (IdAndFaceValidation.tsx:521-537) so it can be tested without a
47714
- * React tree.
47715
- *
47716
- * sdk2 does NOT simply emit `flow.started` from a mount effect: it emits it
47717
- * before the FIRST event of any kind, whatever that event is, and then
47718
- * suppresses the explicit mount emit. The mount effect and the lazy guard
47719
- * together mean `flow.started` is always the first event a customer sees,
47720
- * even if some other event races the effect. That ordering guarantee is the
47721
- * contract, not the effect.
47722
- */
47723
- function createJourneyEmitter(callback, now) {
47724
- var flowStartedEmitted = false;
47725
- return function emit(event) {
47726
- if (!callback) return;
47727
- if (!flowStartedEmitted) {
47728
- flowStartedEmitted = true;
47729
- emitWith(callback, {
47730
- name: 'flow.started'
47731
- }, now);
47732
- }
47733
- if (event.name !== 'flow.started') emitWith(callback, event, now);
47734
- };
47735
- }
47736
- function emitWith(callback, event, now) {
47737
- try {
47738
- callback(createIdAndFaceValidationJourneyEvent(event, now));
47739
- } catch (error) {
47740
- warn$1('[IdAndFaceValidation] onJourneyEvent callback failed', error);
47741
- }
47742
- }
47743
-
47744
48111
  /**
47745
48112
  * Recursively drops keys whose value is exactly `undefined`.
47746
48113
  *
@@ -47923,6 +48290,16 @@ function mapThemeWithColors(theme, colors) {
47923
48290
  return mergeThemes(mapped, overrides);
47924
48291
  }
47925
48292
 
48293
+ /**
48294
+ * 2.x's `onSubmit` as the flow's hand-off. sdk2 read it on every submission,
48295
+ * so this maps on every render: adding or removing it takes effect from the
48296
+ * next submission. Without it the flow posts.
48297
+ */
48298
+ function mapHandoff(onSubmit) {
48299
+ return onSubmit ? {
48300
+ handoff: onSubmit
48301
+ } : undefined;
48302
+ }
47926
48303
  var EMPTY_CONTEXT = {};
47927
48304
  /** Adapts a 3.0 `(response)` callback back to 2.x's `(response, request)`. */
47928
48305
  function withSubmissionRequest(callback, ctx) {
@@ -48014,13 +48391,13 @@ function mapAdditionalDocumentVerbiage(verbiage) {
48014
48391
  }
48015
48392
  // --- 1. IdValidation ------------------------------------------------------
48016
48393
  function mapIdValidationProps(props, ctx) {
48017
- var _a;
48394
+ var _a, _b;
48018
48395
  if (ctx === void 0) {
48019
48396
  ctx = EMPTY_CONTEXT;
48020
48397
  }
48021
- var _b = mapIdCapture(props),
48022
- capture = _b.capture,
48023
- view = _b.view;
48398
+ var _c = mapIdCapture(props),
48399
+ capture = _c.capture,
48400
+ view = _c.view;
48024
48401
  return compact({
48025
48402
  capture: capture,
48026
48403
  view: view,
@@ -48046,9 +48423,8 @@ function mapIdValidationProps(props, ctx) {
48046
48423
  // `onSubmit` WINS over capture-only, matching sdk2's ordering: its
48047
48424
  // `submit()` checks `onSubmit` before the `action === NONE` branch
48048
48425
  // (SubmissionProvider.tsx:1374 vs :1237), so a capture-only flow still
48049
- // owes the callback its built request. Letting the flow run its normal
48050
- // submit path is what builds that request; the client suppresses the POST.
48051
- captureOnly: props.onSubmit ? undefined : props.captureOnly,
48426
+ // owes the callback its built request.
48427
+ submitMode: (_b = mapHandoff(props.onSubmit)) !== null && _b !== void 0 ? _b : props.captureOnly ? 'capture' : undefined,
48052
48428
  captureAdditionalDocuments: props.captureAdditionalDocuments,
48053
48429
  geolocationEnabled: props.geolocationEnabled,
48054
48430
  geolocationRequired: props.geolocationRequired,
@@ -48069,13 +48445,10 @@ function mapIdValidationProps(props, ctx) {
48069
48445
  // would be a NEW restriction, not parity.
48070
48446
  showResultScreen: props.debugMode,
48071
48447
  showDiagnostics: props.debugMode,
48072
- // `onSubmit` is NOT mapped to a flow prop: it goes to the client config
48073
- // (see mapClientConfig), which is the layer sdk2 put it at and the only
48074
- // one that can suppress the POST for every flow at once.
48075
48448
  onComplete: withSubmissionRequest(props.onComplete, ctx),
48076
48449
  onApproved: withSubmissionRequest(props.onApproved, ctx),
48077
48450
  onDenied: withSubmissionRequest(props.onDenied, ctx),
48078
- onRequestFailure: props.onRequestFailure
48451
+ onSubmissionFailure: props.onRequestFailure
48079
48452
  });
48080
48453
  }
48081
48454
  // --- 2. FaceValidation ----------------------------------------------------
@@ -48267,7 +48640,8 @@ function mapIdAndFaceValidationProps(props, ctx) {
48267
48640
  onComplete: withSubmissionRequest(props.onComplete, ctx),
48268
48641
  onApproved: withSubmissionRequest(props.onApproved, ctx),
48269
48642
  onDenied: withSubmissionRequest(props.onDenied, ctx),
48270
- onRequestFailure: props.onRequestFailure,
48643
+ submitMode: mapHandoff(props.onSubmit),
48644
+ onSubmissionFailure: props.onRequestFailure,
48271
48645
  onCaptureError: props.onRequestFailure
48272
48646
  });
48273
48647
  }
@@ -48422,10 +48796,11 @@ function mapSignatureKYCProps(props, ctx) {
48422
48796
  captureProgress: props.captureProgress,
48423
48797
  remoteDiagnostics: props.remoteDiagnostics,
48424
48798
  loadingSpinner: props.loadingSpinner,
48425
- // `onCaptured` is supplied by the COMPONENT, not here: this flow never
48426
- // enters `client.submit()` on its own, so the façade makes that call from
48427
- // `onCaptured` to produce the same built request 2.x hands over. See
48428
- // components/flows.tsx.
48799
+ // 2.x builds this flow's request and hands it to `onSubmit`
48800
+ // (SubmissionProvider.tsx:1374, ahead of its NONE branch). Unset, the
48801
+ // flow captures and posts nothing, as 2.x's NONE did. A failed hand-off
48802
+ // is not reported to `onRequestFailure`, which 2.x never did either.
48803
+ submitMode: mapHandoff(props.onSubmit),
48429
48804
  onCaptureError: props.onRequestFailure
48430
48805
  });
48431
48806
  }
@@ -48451,7 +48826,7 @@ function nestedLayer(nested, map) {
48451
48826
  return map(nested);
48452
48827
  }
48453
48828
  function mapVideoIdValidationProps(props, ctx) {
48454
- var _a, _b, _c;
48829
+ var _a, _b, _c, _d;
48455
48830
  if (ctx === void 0) {
48456
48831
  ctx = EMPTY_CONTEXT;
48457
48832
  }
@@ -48544,7 +48919,11 @@ function mapVideoIdValidationProps(props, ctx) {
48544
48919
  showResultScreen: props.debugMode,
48545
48920
  showDiagnostics: props.debugMode,
48546
48921
  onComplete: withSubmissionRequest(props.onComplete, ctx),
48547
- onRequestFailure: props.onRequestFailure,
48922
+ // No ID captured and none supplied resolves the action to NONE, which
48923
+ // has nothing to post. 2.x answered with a synthetic success and no
48924
+ // request; capture mode is that without the fabricated response.
48925
+ submitMode: (_d = mapHandoff(props.onSubmit)) !== null && _d !== void 0 ? _d : props.skipIdCapture && !props.idCardForFaceMatch ? 'capture' : undefined,
48926
+ onSubmissionFailure: props.onRequestFailure,
48548
48927
  onCaptureError: props.onRequestFailure
48549
48928
  });
48550
48929
  }
@@ -48709,7 +49088,8 @@ function mapCustomerMatchProps(props, ctx) {
48709
49088
  onComplete: withSubmissionRequest(props.onComplete, ctx),
48710
49089
  onCustomerMatched: withSubmissionRequest(props.onCustomerMatched, ctx),
48711
49090
  onCustomerNotMatched: withSubmissionRequest(props.onCustomerNotMatched, ctx),
48712
- onRequestFailure: props.onRequestFailure,
49091
+ submitMode: mapHandoff(props.onSubmit),
49092
+ onSubmissionFailure: props.onRequestFailure,
48713
49093
  onExitCapture: props.onExitCapture,
48714
49094
  onExitAfterFailure: props.onExitAfterFailure
48715
49095
  });
@@ -48778,7 +49158,8 @@ function mapCustomerBiometricsEnrollmentProps(props, ctx) {
48778
49158
  // sdk2's enrollment twin of `onApproved`.
48779
49159
  onApproved: withSubmissionRequest(props.onEnrolled, ctx),
48780
49160
  onDenied: withSubmissionRequest(props.onDenied, ctx),
48781
- onRequestFailure: props.onRequestFailure,
49161
+ submitMode: mapHandoff(props.onSubmit),
49162
+ onSubmissionFailure: props.onRequestFailure,
48782
49163
  onCaptureError: props.onRequestFailure
48783
49164
  });
48784
49165
  }
@@ -48870,12 +49251,13 @@ function mapCustomerIdAndBiometricsEnrollmentProps(props, ctx) {
48870
49251
  onComplete: withSubmissionRequest(props.onComplete, ctx),
48871
49252
  onApproved: withSubmissionRequest(props.onEnrolled, ctx),
48872
49253
  onDenied: withSubmissionRequest(props.onDenied, ctx),
48873
- onRequestFailure: props.onRequestFailure,
49254
+ submitMode: mapHandoff(props.onSubmit),
49255
+ onSubmissionFailure: props.onRequestFailure,
48874
49256
  onCaptureError: props.onRequestFailure
48875
49257
  });
48876
49258
  }
48877
49259
 
48878
- var webSdkVersion = '2.6.3-changeset-release-develop-124a427';
49260
+ var webSdkVersion = '2.6.3-changeset-release-develop-776f131';
48879
49261
 
48880
49262
  // GENERATED by scripts/styleBagTypes.mjs from
48881
49263
  // src/__fixtures__/sdk2StyleBags.json and the mapper sweep — do not
@@ -50932,23 +51314,17 @@ var STYLE_WITH_ASSETS = {
50932
51314
  var SUBMIT_CALLBACKS = {
50933
51315
  onBeforeSubmit: MAPPED,
50934
51316
  /**
50935
- * Mapped to the CLIENT's `onSubmit`, not to a flow prop — the layer sdk2 put
50936
- * it at (SubmissionProvider.submit). The client builds the request, hands it
50937
- * over, and does NOT post, so `onComplete`/`onApproved`/`onDenied` never
50938
- * fire, exactly as 2.x documents. Every flow submits through that one
50939
- * client, including the two match flows with their own stage machine, so the
50940
- * suppression is uniform.
51317
+ * Mapped to the flow's `submitMode: { handoff }`. The flow builds the
51318
+ * request, hands it over, and does NOT post, so `onComplete`/`onApproved`/
51319
+ * `onDenied` never fire, exactly as 2.x documents. Mapped on every render,
51320
+ * so adding or removing it takes effect from the next submission, as sdk2's
51321
+ * ref-held `onSubmit` did.
50941
51322
  *
50942
51323
  * What the flow SHOWS afterwards is a 3.0 call rather than a 2.x
50943
51324
  * reproduction: every family now ends quietly, because the integrator owns
50944
51325
  * the outcome once they have the request. 2.x's match flows showed a failure
50945
51326
  * screen there, but only because their `submit()` could not distinguish an
50946
51327
  * intercepted submission from a broken one.
50947
- *
50948
- * `SignatureKYC` reaches the same place by a different route: its 3.0
50949
- * counterpart never enters `client.submit()`, so the façade component makes
50950
- * that call itself from `onCaptured`. `action: NONE` is accepted there
50951
- * precisely because `onSubmit` is bound.
50952
51328
  */
50953
51329
  onSubmit: MAPPED,
50954
51330
  onComplete: MAPPED,
@@ -51046,7 +51422,7 @@ var SignatureKYC$1 = _assign(_assign(_assign(_assign(_assign(_assign(_assign(_as
51046
51422
  // `SubmissionAction.NONE` and wires `onComplete` to the provider's
51047
51423
  // `onResponseReceived` (SignatureKYC.tsx:434,449), which never fires because
51048
51424
  // nothing is ever posted. `onSubmit` is the real completion seam and IS
51049
- // mapped, to the flow's `onCaptured`.
51425
+ // mapped, to the flow's `submitMode: { handoff }`.
51050
51426
  onComplete: NOOP,
51051
51427
  onSubmit: MAPPED,
51052
51428
  onRequestFailure: MAPPED,
@@ -51537,10 +51913,6 @@ function useCompatClient(props) {
51537
51913
  _lastLivenessRequest.current = request;
51538
51914
  return propsRef.current.onBeforeLivenessCheck ? propsRef.current.onBeforeLivenessCheck(request) : Promise.resolve(request);
51539
51915
  },
51540
- onSubmit: propsRef.current.onSubmit ? function (request) {
51541
- var _a, _b;
51542
- return (_b = (_a = propsRef.current).onSubmit) === null || _b === void 0 ? void 0 : _b.call(_a, request);
51543
- } : undefined,
51544
51916
  onResponseReceived: function onResponseReceived(_response, request) {
51545
51917
  _lastSubmissionRequest.current = request;
51546
51918
  },
@@ -51711,34 +52083,12 @@ var SignatureKYC = function SignatureKYC(props) {
51711
52083
  client = _a.client,
51712
52084
  ctx = _a.ctx;
51713
52085
  useDroppedPropReport('SignatureKYC', props);
51714
- // The one flow whose 3.0 counterpart never enters `client.submit()`: it runs
51715
- // its own stage machine and reports completion through `onCaptured` instead.
51716
- // 2.x DOES submit here — its CompositeWizard calls `submit()`, which hands
51717
- // the built request to `onSubmit` before reaching the capture-only branch —
51718
- // so the façade makes that call itself to produce the same request. The
51719
- // client suppresses the POST, and `action: NONE` is accepted precisely
51720
- // because `onSubmit` is bound.
51721
- //
51722
- // Only when bound: without `onSubmit` the client rejects NONE by design, and
51723
- // this flow has nothing to submit anyway.
51724
- var onSubmit = props.onSubmit;
51725
- var submission = mapSubmission(props);
51726
- var handOff = onSubmit ? function (artifacts) {
51727
- void client.submit(artifacts, _assign(_assign({}, submission), {
51728
- action: SubmissionAction.NONE
51729
- }))["catch"](function () {
51730
- // The failure already reached `onRequestFailure` through the
51731
- // client's own hook, which is where 2.x reported it too.
51732
- });
51733
- } : undefined;
51734
52086
  // No `children`: SignatureKYCFlow omits it from its props (it runs its own
51735
52087
  // stage machine rather than CompositeWizard), so passing it would not
51736
52088
  // compile — and 2.x rendered it nowhere either.
51737
52089
  return /*#__PURE__*/React.createElement(SignatureKYCFlow, _assign({
51738
52090
  client: client
51739
- }, mapSignatureKYCProps(props, ctx), {
51740
- onCaptured: handOff
51741
- }));
52091
+ }, mapSignatureKYCProps(props, ctx)));
51742
52092
  };
51743
52093
  /**
51744
52094
  * Render a fullscreen capture component that performs ID and face validation,