@koraidv/react 1.8.1 → 1.8.2

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/index.js CHANGED
@@ -101,8 +101,10 @@ function useKoraIDV() {
101
101
  });
102
102
  const [selectedDocumentType, setSelectedDocumentType] = (0, import_react2.useState)(null);
103
103
  const [documentFrontCaptured, setDocumentFrontCaptured] = (0, import_react2.useState)(false);
104
+ const lastStartArgsRef = (0, import_react2.useRef)(null);
104
105
  const startVerification = (0, import_react2.useCallback)(
105
106
  async (externalId, tier = "standard", expectedFirstName, expectedLastName) => {
107
+ lastStartArgsRef.current = { externalId, tier, expectedFirstName, expectedLastName };
106
108
  setState((prev) => ({ ...prev, isLoading: true, error: null }));
107
109
  try {
108
110
  await sdk.startVerification(
@@ -363,14 +365,28 @@ function useKoraIDV() {
363
365
  error: null,
364
366
  lastChallengeError: null
365
367
  });
368
+ setSelectedDocumentType(null);
369
+ setDocumentFrontCaptured(false);
366
370
  }, [sdk]);
367
371
  const retry = (0, import_react2.useCallback)(() => {
368
- setState((prev) => ({
369
- ...prev,
372
+ const args = lastStartArgsRef.current;
373
+ sdk.reset();
374
+ setState({
375
+ step: "consent",
376
+ verification: null,
377
+ livenessSession: null,
378
+ currentChallenge: null,
379
+ completedChallenges: 0,
380
+ isLoading: false,
370
381
  error: null,
371
- isLoading: false
372
- }));
373
- }, []);
382
+ lastChallengeError: null
383
+ });
384
+ setSelectedDocumentType(null);
385
+ setDocumentFrontCaptured(false);
386
+ if (args) {
387
+ startVerification(args.externalId, args.tier, args.expectedFirstName, args.expectedLastName);
388
+ }
389
+ }, [sdk, startVerification]);
374
390
  return {
375
391
  state,
376
392
  startVerification,
@@ -3658,7 +3674,12 @@ function VerificationFlow({
3658
3674
  {
3659
3675
  verification: state.verification,
3660
3676
  onDone: () => onComplete?.(state.verification),
3661
- onRetry: retry
3677
+ onRetry: () => {
3678
+ setFlowStep("consent");
3679
+ setSelectedCountry(null);
3680
+ setShowFlipInstruction(true);
3681
+ retry();
3682
+ }
3662
3683
  }
3663
3684
  )
3664
3685
  ] });
package/dist/index.mjs CHANGED
@@ -52,8 +52,10 @@ function useKoraIDV() {
52
52
  });
53
53
  const [selectedDocumentType, setSelectedDocumentType] = useState(null);
54
54
  const [documentFrontCaptured, setDocumentFrontCaptured] = useState(false);
55
+ const lastStartArgsRef = useRef(null);
55
56
  const startVerification = useCallback(
56
57
  async (externalId, tier = "standard", expectedFirstName, expectedLastName) => {
58
+ lastStartArgsRef.current = { externalId, tier, expectedFirstName, expectedLastName };
57
59
  setState((prev) => ({ ...prev, isLoading: true, error: null }));
58
60
  try {
59
61
  await sdk.startVerification(
@@ -314,14 +316,28 @@ function useKoraIDV() {
314
316
  error: null,
315
317
  lastChallengeError: null
316
318
  });
319
+ setSelectedDocumentType(null);
320
+ setDocumentFrontCaptured(false);
317
321
  }, [sdk]);
318
322
  const retry = useCallback(() => {
319
- setState((prev) => ({
320
- ...prev,
323
+ const args = lastStartArgsRef.current;
324
+ sdk.reset();
325
+ setState({
326
+ step: "consent",
327
+ verification: null,
328
+ livenessSession: null,
329
+ currentChallenge: null,
330
+ completedChallenges: 0,
331
+ isLoading: false,
321
332
  error: null,
322
- isLoading: false
323
- }));
324
- }, []);
333
+ lastChallengeError: null
334
+ });
335
+ setSelectedDocumentType(null);
336
+ setDocumentFrontCaptured(false);
337
+ if (args) {
338
+ startVerification(args.externalId, args.tier, args.expectedFirstName, args.expectedLastName);
339
+ }
340
+ }, [sdk, startVerification]);
325
341
  return {
326
342
  state,
327
343
  startVerification,
@@ -3609,7 +3625,12 @@ function VerificationFlow({
3609
3625
  {
3610
3626
  verification: state.verification,
3611
3627
  onDone: () => onComplete?.(state.verification),
3612
- onRetry: retry
3628
+ onRetry: () => {
3629
+ setFlowStep("consent");
3630
+ setSelectedCountry(null);
3631
+ setShowFlipInstruction(true);
3632
+ retry();
3633
+ }
3613
3634
  }
3614
3635
  )
3615
3636
  ] });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@koraidv/react",
3
- "version": "1.8.1",
3
+ "version": "1.8.2",
4
4
  "description": "Kora IDV React Components for Identity Verification",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -21,7 +21,7 @@
21
21
  "test": "vitest run"
22
22
  },
23
23
  "dependencies": {
24
- "@koraidv/core": "^1.8.1"
24
+ "@koraidv/core": "^1.8.2"
25
25
  },
26
26
  "devDependencies": {
27
27
  "@types/react": "^18.2.0",