@koraidv/react 1.7.9 → 1.7.11

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.d.mts CHANGED
@@ -67,7 +67,7 @@ interface UseKoraIDVReturn {
67
67
  /**
68
68
  * Start a new verification
69
69
  */
70
- startVerification: (externalId: string, tier?: string) => Promise<void>;
70
+ startVerification: (externalId: string, tier?: string, expectedFirstName?: string, expectedLastName?: string) => Promise<void>;
71
71
  /**
72
72
  * Resume an existing verification
73
73
  */
@@ -142,6 +142,21 @@ interface VerificationFlowProps {
142
142
  externalId: string;
143
143
  tier?: 'basic' | 'standard' | 'enhanced';
144
144
  documentTypes?: DocumentType[];
145
+ /**
146
+ * Optional name-match inputs. When set, the backend compares the
147
+ * OCR'd names on the document against these values and surfaces a
148
+ * real `scores.nameMatch` percentage on the verification result —
149
+ * the ResultScreen's "Name Match" row shows real PASS/FAIL instead
150
+ * of the always-0% / always-FAIL it shows when these aren't passed.
151
+ *
152
+ * Wire from your user record at mount time, e.g.
153
+ * `<VerificationFlow expectedFirstName={user.firstName} ... />`
154
+ *
155
+ * Mirrors iOS's
156
+ * `KoraIDV.startVerification(expectedFirstName:expectedLastName:)`.
157
+ */
158
+ expectedFirstName?: string;
159
+ expectedLastName?: string;
145
160
  onComplete?: (verification: Verification) => void;
146
161
  onError?: (error: KoraError) => void;
147
162
  onCancel?: () => void;
@@ -151,7 +166,7 @@ interface VerificationFlowProps {
151
166
  /**
152
167
  * Complete verification flow component
153
168
  */
154
- declare function VerificationFlow({ externalId, tier, documentTypes, onComplete, onError, onCancel, className, style, }: VerificationFlowProps): react_jsx_runtime.JSX.Element;
169
+ declare function VerificationFlow({ externalId, tier, documentTypes, expectedFirstName, expectedLastName, onComplete, onError, onCancel, className, style, }: VerificationFlowProps): react_jsx_runtime.JSX.Element;
155
170
 
156
171
  interface ConsentScreenProps {
157
172
  onAccept: () => void;
package/dist/index.d.ts CHANGED
@@ -67,7 +67,7 @@ interface UseKoraIDVReturn {
67
67
  /**
68
68
  * Start a new verification
69
69
  */
70
- startVerification: (externalId: string, tier?: string) => Promise<void>;
70
+ startVerification: (externalId: string, tier?: string, expectedFirstName?: string, expectedLastName?: string) => Promise<void>;
71
71
  /**
72
72
  * Resume an existing verification
73
73
  */
@@ -142,6 +142,21 @@ interface VerificationFlowProps {
142
142
  externalId: string;
143
143
  tier?: 'basic' | 'standard' | 'enhanced';
144
144
  documentTypes?: DocumentType[];
145
+ /**
146
+ * Optional name-match inputs. When set, the backend compares the
147
+ * OCR'd names on the document against these values and surfaces a
148
+ * real `scores.nameMatch` percentage on the verification result —
149
+ * the ResultScreen's "Name Match" row shows real PASS/FAIL instead
150
+ * of the always-0% / always-FAIL it shows when these aren't passed.
151
+ *
152
+ * Wire from your user record at mount time, e.g.
153
+ * `<VerificationFlow expectedFirstName={user.firstName} ... />`
154
+ *
155
+ * Mirrors iOS's
156
+ * `KoraIDV.startVerification(expectedFirstName:expectedLastName:)`.
157
+ */
158
+ expectedFirstName?: string;
159
+ expectedLastName?: string;
145
160
  onComplete?: (verification: Verification) => void;
146
161
  onError?: (error: KoraError) => void;
147
162
  onCancel?: () => void;
@@ -151,7 +166,7 @@ interface VerificationFlowProps {
151
166
  /**
152
167
  * Complete verification flow component
153
168
  */
154
- declare function VerificationFlow({ externalId, tier, documentTypes, onComplete, onError, onCancel, className, style, }: VerificationFlowProps): react_jsx_runtime.JSX.Element;
169
+ declare function VerificationFlow({ externalId, tier, documentTypes, expectedFirstName, expectedLastName, onComplete, onError, onCancel, className, style, }: VerificationFlowProps): react_jsx_runtime.JSX.Element;
155
170
 
156
171
  interface ConsentScreenProps {
157
172
  onAccept: () => void;
package/dist/index.js CHANGED
@@ -101,11 +101,16 @@ function useKoraIDV() {
101
101
  const [selectedDocumentType, setSelectedDocumentType] = (0, import_react2.useState)(null);
102
102
  const [documentFrontCaptured, setDocumentFrontCaptured] = (0, import_react2.useState)(false);
103
103
  const startVerification = (0, import_react2.useCallback)(
104
- async (externalId, tier = "standard") => {
104
+ async (externalId, tier = "standard", expectedFirstName, expectedLastName) => {
105
105
  setState((prev) => ({ ...prev, isLoading: true, error: null }));
106
106
  try {
107
107
  await sdk.startVerification(
108
- { externalId, tier },
108
+ {
109
+ externalId,
110
+ tier,
111
+ expectedFirstName,
112
+ expectedLastName
113
+ },
109
114
  {
110
115
  onStepChange: (step) => {
111
116
  setState((prev) => ({ ...prev, step }));
@@ -1509,13 +1514,18 @@ function ProcessingScreen({ steps }) {
1509
1514
  ] });
1510
1515
  }
1511
1516
  function computeScoreBreakdown(verification) {
1512
- const liveness = verification.livenessVerification?.livenessScore ?? 0;
1513
- const livenessPercent = Math.round(liveness * 100);
1514
- const docQuality = verification.documentVerification?.authenticityScore ?? 0;
1515
- const docPercent = Math.round(docQuality * 100);
1516
- const nameMatch = verification.documentVerification?.firstName && verification.documentVerification?.lastName ? 100 : 0;
1517
- const selfieMatch = verification.faceVerification?.matchScore ?? 0;
1518
- const selfiePercent = Math.round(selfieMatch * 100);
1517
+ const livenessPercent = Math.round(
1518
+ verification.scores?.liveness ?? verification.livenessVerification?.livenessScore ?? 0
1519
+ );
1520
+ const docPercent = Math.round(
1521
+ verification.scores?.documentAuth ?? (verification.documentVerification?.authenticityScore ?? 0) * 100
1522
+ );
1523
+ const nameMatch = Math.round(
1524
+ verification.scores?.nameMatch ?? (verification.documentVerification?.firstName && verification.documentVerification?.lastName ? 100 : 0)
1525
+ );
1526
+ const selfiePercent = Math.round(
1527
+ verification.scores?.faceMatch ?? verification.faceVerification?.matchScore ?? 0
1528
+ );
1519
1529
  function getStatus(score) {
1520
1530
  if (score >= 75) return "pass";
1521
1531
  if (score >= 50) return "borderline";
@@ -2663,7 +2673,9 @@ function ResultScreen({ verification, onDone, onRetry, resultPageMode, simplifie
2663
2673
  }
2664
2674
  }
2665
2675
  function SuccessResult({ verification, onDone }) {
2666
- const score = verification.riskScore ?? 84;
2676
+ const score = Math.round(
2677
+ verification.scores?.overall ?? 100 - (verification.riskScore ?? 16)
2678
+ );
2667
2679
  const metrics = computeScoreBreakdown(verification);
2668
2680
  return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { style: styles.resultContainer, children: [
2669
2681
  /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { style: styles.resultContent, children: [
@@ -2704,7 +2716,9 @@ function SuccessResult({ verification, onDone }) {
2704
2716
  ] });
2705
2717
  }
2706
2718
  function RejectedResult({ verification, onRetry }) {
2707
- const score = verification.riskScore ?? 42;
2719
+ const score = Math.round(
2720
+ verification.scores?.overall ?? 100 - (verification.riskScore ?? 58)
2721
+ );
2708
2722
  const metrics = computeScoreBreakdown(verification);
2709
2723
  return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { style: styles.resultContainer, children: [
2710
2724
  /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { style: styles.resultContent, children: [
@@ -2795,7 +2809,9 @@ function ExpiredResult({ verification, onRetry }) {
2795
2809
  ] });
2796
2810
  }
2797
2811
  function ManualReviewResult({ verification, onDone }) {
2798
- const score = verification.riskScore ?? 68;
2812
+ const score = Math.round(
2813
+ verification.scores?.overall ?? 100 - (verification.riskScore ?? 32)
2814
+ );
2799
2815
  const metrics = computeScoreBreakdown(verification);
2800
2816
  return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { style: styles.resultContainer, children: [
2801
2817
  /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { style: styles.resultContent, children: [
@@ -3031,6 +3047,8 @@ function VerificationFlow({
3031
3047
  externalId,
3032
3048
  tier = "standard",
3033
3049
  documentTypes,
3050
+ expectedFirstName,
3051
+ expectedLastName,
3034
3052
  onComplete,
3035
3053
  onError,
3036
3054
  onCancel,
@@ -3063,8 +3081,8 @@ function VerificationFlow({
3063
3081
  }
3064
3082
  }, [state.step]);
3065
3083
  (0, import_react10.useEffect)(() => {
3066
- startVerification(externalId, tier);
3067
- }, [externalId, tier, startVerification]);
3084
+ startVerification(externalId, tier, expectedFirstName, expectedLastName);
3085
+ }, [externalId, tier, expectedFirstName, expectedLastName, startVerification]);
3068
3086
  (0, import_react10.useEffect)(() => {
3069
3087
  if (state.error && onError) {
3070
3088
  onError(state.error);
package/dist/index.mjs CHANGED
@@ -52,11 +52,16 @@ function useKoraIDV() {
52
52
  const [selectedDocumentType, setSelectedDocumentType] = useState(null);
53
53
  const [documentFrontCaptured, setDocumentFrontCaptured] = useState(false);
54
54
  const startVerification = useCallback(
55
- async (externalId, tier = "standard") => {
55
+ async (externalId, tier = "standard", expectedFirstName, expectedLastName) => {
56
56
  setState((prev) => ({ ...prev, isLoading: true, error: null }));
57
57
  try {
58
58
  await sdk.startVerification(
59
- { externalId, tier },
59
+ {
60
+ externalId,
61
+ tier,
62
+ expectedFirstName,
63
+ expectedLastName
64
+ },
60
65
  {
61
66
  onStepChange: (step) => {
62
67
  setState((prev) => ({ ...prev, step }));
@@ -1460,13 +1465,18 @@ function ProcessingScreen({ steps }) {
1460
1465
  ] });
1461
1466
  }
1462
1467
  function computeScoreBreakdown(verification) {
1463
- const liveness = verification.livenessVerification?.livenessScore ?? 0;
1464
- const livenessPercent = Math.round(liveness * 100);
1465
- const docQuality = verification.documentVerification?.authenticityScore ?? 0;
1466
- const docPercent = Math.round(docQuality * 100);
1467
- const nameMatch = verification.documentVerification?.firstName && verification.documentVerification?.lastName ? 100 : 0;
1468
- const selfieMatch = verification.faceVerification?.matchScore ?? 0;
1469
- const selfiePercent = Math.round(selfieMatch * 100);
1468
+ const livenessPercent = Math.round(
1469
+ verification.scores?.liveness ?? verification.livenessVerification?.livenessScore ?? 0
1470
+ );
1471
+ const docPercent = Math.round(
1472
+ verification.scores?.documentAuth ?? (verification.documentVerification?.authenticityScore ?? 0) * 100
1473
+ );
1474
+ const nameMatch = Math.round(
1475
+ verification.scores?.nameMatch ?? (verification.documentVerification?.firstName && verification.documentVerification?.lastName ? 100 : 0)
1476
+ );
1477
+ const selfiePercent = Math.round(
1478
+ verification.scores?.faceMatch ?? verification.faceVerification?.matchScore ?? 0
1479
+ );
1470
1480
  function getStatus(score) {
1471
1481
  if (score >= 75) return "pass";
1472
1482
  if (score >= 50) return "borderline";
@@ -2614,7 +2624,9 @@ function ResultScreen({ verification, onDone, onRetry, resultPageMode, simplifie
2614
2624
  }
2615
2625
  }
2616
2626
  function SuccessResult({ verification, onDone }) {
2617
- const score = verification.riskScore ?? 84;
2627
+ const score = Math.round(
2628
+ verification.scores?.overall ?? 100 - (verification.riskScore ?? 16)
2629
+ );
2618
2630
  const metrics = computeScoreBreakdown(verification);
2619
2631
  return /* @__PURE__ */ jsxs9("div", { style: styles.resultContainer, children: [
2620
2632
  /* @__PURE__ */ jsxs9("div", { style: styles.resultContent, children: [
@@ -2655,7 +2667,9 @@ function SuccessResult({ verification, onDone }) {
2655
2667
  ] });
2656
2668
  }
2657
2669
  function RejectedResult({ verification, onRetry }) {
2658
- const score = verification.riskScore ?? 42;
2670
+ const score = Math.round(
2671
+ verification.scores?.overall ?? 100 - (verification.riskScore ?? 58)
2672
+ );
2659
2673
  const metrics = computeScoreBreakdown(verification);
2660
2674
  return /* @__PURE__ */ jsxs9("div", { style: styles.resultContainer, children: [
2661
2675
  /* @__PURE__ */ jsxs9("div", { style: styles.resultContent, children: [
@@ -2746,7 +2760,9 @@ function ExpiredResult({ verification, onRetry }) {
2746
2760
  ] });
2747
2761
  }
2748
2762
  function ManualReviewResult({ verification, onDone }) {
2749
- const score = verification.riskScore ?? 68;
2763
+ const score = Math.round(
2764
+ verification.scores?.overall ?? 100 - (verification.riskScore ?? 32)
2765
+ );
2750
2766
  const metrics = computeScoreBreakdown(verification);
2751
2767
  return /* @__PURE__ */ jsxs9("div", { style: styles.resultContainer, children: [
2752
2768
  /* @__PURE__ */ jsxs9("div", { style: styles.resultContent, children: [
@@ -2982,6 +2998,8 @@ function VerificationFlow({
2982
2998
  externalId,
2983
2999
  tier = "standard",
2984
3000
  documentTypes,
3001
+ expectedFirstName,
3002
+ expectedLastName,
2985
3003
  onComplete,
2986
3004
  onError,
2987
3005
  onCancel,
@@ -3014,8 +3032,8 @@ function VerificationFlow({
3014
3032
  }
3015
3033
  }, [state.step]);
3016
3034
  useEffect8(() => {
3017
- startVerification(externalId, tier);
3018
- }, [externalId, tier, startVerification]);
3035
+ startVerification(externalId, tier, expectedFirstName, expectedLastName);
3036
+ }, [externalId, tier, expectedFirstName, expectedLastName, startVerification]);
3019
3037
  useEffect8(() => {
3020
3038
  if (state.error && onError) {
3021
3039
  onError(state.error);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@koraidv/react",
3
- "version": "1.7.9",
3
+ "version": "1.7.11",
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.7.9"
24
+ "@koraidv/core": "^1.7.11"
25
25
  },
26
26
  "devDependencies": {
27
27
  "@types/react": "^18.2.0",