@sanctum-key/react-native-sdk 1.0.53 → 1.0.56
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/README.md +7 -2
- package/android/build/.transforms/3db9b15041d4285a820fc84462995ea1/results.bin +1 -0
- package/android/build/.transforms/3db9b15041d4285a820fc84462995ea1/transformed/classes/classes_dex/classes.dex +0 -0
- package/android/build/intermediates/compile_library_classes_jar/debug/bundleLibCompileToJarDebug/classes.jar +0 -0
- package/android/build/intermediates/runtime_library_classes_jar/debug/bundleLibRuntimeToJarDebug/classes.jar +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/inputs/source-to-output.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/inputs/source-to-output.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-attributes.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-attributes.tab.keystream +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-attributes.tab.keystream.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-attributes.tab.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-attributes.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-attributes.tab_i +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab.keystream +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab.keystream.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab_i +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab.keystream +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab.keystream.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab_i +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab.keystream +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab.keystream.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab_i +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/source-to-classes.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/source-to-classes.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/subtypes.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/subtypes.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/supertypes.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/supertypes.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/counters.tab +1 -1
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/file-to-id.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/file-to-id.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab.keystream +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab.keystream.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab_i +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab.keystream +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab.keystream.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab_i +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/last-build.bin +0 -0
- package/android/build/kotlin/compileDebugKotlin/classpath-snapshot/shrunk-classpath-snapshot.bin +0 -0
- package/android/build/kotlin/compileDebugKotlin/local-state/build-history.bin +0 -0
- package/android/build/tmp/compileDebugJavaWithJavac/previous-compilation-data.bin +0 -0
- package/android/build/tmp/kotlin-classes/debug/kyc/sanctumkey/com/SanctumKeySdkModule$BarcodeRegion.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/kyc/sanctumkey/com/SanctumKeySdkModule$Companion.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/kyc/sanctumkey/com/{SanctumKeySdkModule$definition$1$5$1.class → SanctumKeySdkModule$definition$1$6$1.class} +0 -0
- package/android/build/tmp/kotlin-classes/debug/kyc/sanctumkey/com/{SanctumKeySdkModule$definition$1$5$2.class → SanctumKeySdkModule$definition$1$6$2.class} +0 -0
- package/android/build/tmp/kotlin-classes/debug/kyc/sanctumkey/com/{SanctumKeySdkModule$definition$lambda$5$$inlined$AsyncFunction$1.class → SanctumKeySdkModule$definition$lambda$16$$inlined$AsyncFunction$1.class} +0 -0
- package/android/build/tmp/kotlin-classes/debug/kyc/sanctumkey/com/{SanctumKeySdkModule$definition$lambda$5$$inlined$AsyncFunction$5.class → SanctumKeySdkModule$definition$lambda$16$$inlined$AsyncFunction$2.class} +0 -0
- package/android/build/tmp/kotlin-classes/debug/kyc/sanctumkey/com/{SanctumKeySdkModule$definition$lambda$5$$inlined$AsyncFunction$3.class → SanctumKeySdkModule$definition$lambda$16$$inlined$AsyncFunction$3.class} +0 -0
- package/android/build/tmp/kotlin-classes/debug/kyc/sanctumkey/com/{SanctumKeySdkModule$definition$lambda$5$$inlined$AsyncFunction$4.class → SanctumKeySdkModule$definition$lambda$16$$inlined$AsyncFunction$4.class} +0 -0
- package/android/build/tmp/kotlin-classes/debug/kyc/sanctumkey/com/{SanctumKeySdkModule$definition$lambda$5$$inlined$AsyncFunction$2.class → SanctumKeySdkModule$definition$lambda$16$$inlined$AsyncFunction$5.class} +0 -0
- package/android/build/tmp/kotlin-classes/debug/kyc/sanctumkey/com/{SanctumKeySdkModule$definition$lambda$5$$inlined$AsyncFunction$6.class → SanctumKeySdkModule$definition$lambda$16$$inlined$AsyncFunction$6.class} +0 -0
- package/android/build/tmp/kotlin-classes/debug/kyc/sanctumkey/com/{SanctumKeySdkModule$definition$lambda$5$$inlined$AsyncFunctionWithPromise$1.class → SanctumKeySdkModule$definition$lambda$16$$inlined$AsyncFunctionWithPromise$1.class} +0 -0
- package/android/build/tmp/kotlin-classes/debug/kyc/sanctumkey/com/{SanctumKeySdkModule$definition$lambda$5$$inlined$AsyncFunctionWithPromise$3.class → SanctumKeySdkModule$definition$lambda$16$$inlined$AsyncFunctionWithPromise$2.class} +0 -0
- package/android/build/tmp/kotlin-classes/debug/kyc/sanctumkey/com/SanctumKeySdkModule$definition$lambda$16$$inlined$AsyncFunctionWithPromise$3.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/kyc/sanctumkey/com/SanctumKeySdkModule$definition$lambda$16$$inlined$AsyncFunctionWithPromise$4.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/kyc/sanctumkey/com/{SanctumKeySdkModule$definition$lambda$5$$inlined$AsyncFunctionWithPromise$2.class → SanctumKeySdkModule$definition$lambda$16$$inlined$AsyncFunctionWithPromise$5.class} +0 -0
- package/android/build/tmp/kotlin-classes/debug/kyc/sanctumkey/com/SanctumKeySdkModule$definition$lambda$16$$inlined$AsyncFunctionWithPromise$6.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/kyc/sanctumkey/com/{SanctumKeySdkModule$definition$lambda$5$$inlined$AsyncFunctionWithPromise$4.class → SanctumKeySdkModule$definition$lambda$16$$inlined$AsyncFunctionWithPromise$7.class} +0 -0
- package/android/build/tmp/kotlin-classes/debug/kyc/sanctumkey/com/{SanctumKeySdkModule$definition$lambda$5$$inlined$View$1.class → SanctumKeySdkModule$definition$lambda$16$$inlined$View$1.class} +0 -0
- package/android/build/tmp/kotlin-classes/debug/kyc/sanctumkey/com/{SanctumKeySdkModule$definition$lambda$5$lambda$4$$inlined$Prop$1.class → SanctumKeySdkModule$definition$lambda$16$lambda$15$$inlined$Prop$1.class} +0 -0
- package/android/build/tmp/kotlin-classes/debug/kyc/sanctumkey/com/{SanctumKeySdkModule$definition$lambda$5$lambda$4$$inlined$Prop$2.class → SanctumKeySdkModule$definition$lambda$16$lambda$15$$inlined$Prop$2.class} +0 -0
- package/android/build/tmp/kotlin-classes/debug/kyc/sanctumkey/com/SanctumKeySdkModule.class +0 -0
- package/android/build.gradle +7 -0
- package/android/src/main/java/kyc/sanctumkey/com/SanctumKeySdkModule.kt +428 -1
- package/build/package.json +3 -1
- package/build/src/SanctumKeySdkModule.d.ts +1 -0
- package/build/src/SanctumKeySdkModule.d.ts.map +1 -1
- package/build/src/SanctumKeySdkModule.js.map +1 -1
- package/build/src/components/EnhancedCameraView.d.ts.map +1 -1
- package/build/src/components/EnhancedCameraView.js +50 -41
- package/build/src/components/EnhancedCameraView.js.map +1 -1
- package/build/src/components/EnhancedCameraView.web.d.ts +2 -0
- package/build/src/components/EnhancedCameraView.web.d.ts.map +1 -1
- package/build/src/components/EnhancedCameraView.web.js +11 -6
- package/build/src/components/EnhancedCameraView.web.js.map +1 -1
- package/build/src/components/KYCElements/IDCardCapture.d.ts.map +1 -1
- package/build/src/components/KYCElements/IDCardCapture.js +499 -78
- package/build/src/components/KYCElements/IDCardCapture.js.map +1 -1
- package/build/src/components/TemplateKYCExample.d.ts.map +1 -1
- package/build/src/components/TemplateKYCExample.js +3 -9
- package/build/src/components/TemplateKYCExample.js.map +1 -1
- package/build/src/components/TemplateKYCFlowRefactored.d.ts.map +1 -1
- package/build/src/components/TemplateKYCFlowRefactored.js +0 -2
- package/build/src/components/TemplateKYCFlowRefactored.js.map +1 -1
- package/build/src/components/WebBarcodeScanner.d.ts +2 -0
- package/build/src/components/WebBarcodeScanner.d.ts.map +1 -1
- package/build/src/components/WebBarcodeScanner.js +99 -85
- package/build/src/components/WebBarcodeScanner.js.map +1 -1
- package/build/src/modules/api/KYCService.d.ts +1 -0
- package/build/src/modules/api/KYCService.d.ts.map +1 -1
- package/build/src/modules/api/KYCService.js +1 -1
- package/build/src/modules/api/KYCService.js.map +1 -1
- package/build/src/modules/api/types.d.ts +1 -0
- package/build/src/modules/api/types.d.ts.map +1 -1
- package/build/src/modules/api/types.js.map +1 -1
- package/build/src/web/WebKYCEntry.d.ts.map +1 -1
- package/build/src/web/WebKYCEntry.js +50 -32
- package/build/src/web/WebKYCEntry.js.map +1 -1
- package/package.json +3 -1
- package/plugin/build/withVisionCamera.d.ts +1 -0
- package/plugin/build/withVisionCamera.js +13 -1
- package/plugin/src/withVisionCamera.js +18 -2
- package/plugin/src/withVisionCamera.ts +19 -2
- package/src/SanctumKeySdkModule.ts +1 -0
- package/src/components/EnhancedCameraView.tsx +52 -41
- package/src/components/EnhancedCameraView.web.tsx +15 -5
- package/src/components/KYCElements/IDCardCapture.tsx +552 -75
- package/src/components/TemplateKYCExample.tsx +6 -14
- package/src/components/TemplateKYCFlowRefactored.tsx +0 -2
- package/src/components/WebBarcodeScanner.tsx +147 -198
- package/src/modules/api/KYCService.ts +3 -3
- package/src/modules/api/types.ts +1 -0
- package/src/web/WebKYCEntry.tsx +89 -50
package/src/web/WebKYCEntry.tsx
CHANGED
|
@@ -5,6 +5,7 @@ import { TemplateKYCExample } from '../components/TemplateKYCExample';
|
|
|
5
5
|
import { isCallbackUrlAllowed } from '../config/allowedDomains';
|
|
6
6
|
import KYCConfig from '../config/KYCConfig';
|
|
7
7
|
import { BackendEnvironment } from '../types/env.types';
|
|
8
|
+
import CryptoJS from 'crypto-js'; // 🚨 IMPORT ADDED
|
|
8
9
|
|
|
9
10
|
interface WebKYCEntryProps {
|
|
10
11
|
onComplete?: (data: any) => void;
|
|
@@ -31,8 +32,7 @@ interface URLParams {
|
|
|
31
32
|
country?: string;
|
|
32
33
|
document_type?: string;
|
|
33
34
|
region?: string;
|
|
34
|
-
|
|
35
|
-
session_id?: string;
|
|
35
|
+
session_id?: string;
|
|
36
36
|
resume?: boolean;
|
|
37
37
|
}
|
|
38
38
|
|
|
@@ -42,8 +42,21 @@ interface VerificationSteps {
|
|
|
42
42
|
liveness_checked?: boolean;
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
-
|
|
45
|
+
// 🚨 MODIFIED: Accepts the webhook secret to generate the signature
|
|
46
|
+
const postWebhook = async (url: string, payload: unknown, secret?: string, timeoutMs: number = 5000) => {
|
|
46
47
|
const body = JSON.stringify(payload);
|
|
48
|
+
|
|
49
|
+
const headers: Record<string, string> = {
|
|
50
|
+
'Content-Type': 'application/json',
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
// 🚨 Generate HMAC SHA-256 Signature if secret is provided
|
|
54
|
+
if (secret) {
|
|
55
|
+
const signature = CryptoJS.HmacSHA256(body, secret).toString(CryptoJS.enc.Hex);
|
|
56
|
+
headers['x-sanctumkey-signature'] = signature;
|
|
57
|
+
console.log("🔒 Generated Webhook Signature:", signature);
|
|
58
|
+
}
|
|
59
|
+
|
|
47
60
|
const postWithTimeout = async (init: RequestInit) => {
|
|
48
61
|
const controller = new AbortController();
|
|
49
62
|
const timeoutId = setTimeout(() => controller.abort(), timeoutMs);
|
|
@@ -56,17 +69,23 @@ const postWebhook = async (url: string, payload: unknown, timeoutMs: number = 50
|
|
|
56
69
|
|
|
57
70
|
if (typeof window !== 'undefined') {
|
|
58
71
|
try {
|
|
59
|
-
const response = await postWithTimeout({ headers
|
|
72
|
+
const response = await postWithTimeout({ headers, body, keepalive: true });
|
|
60
73
|
if (!response.ok) throw new Error(`Webhook failed with status ${response.status}`);
|
|
61
74
|
return;
|
|
62
75
|
} catch (error) {
|
|
63
76
|
if (error instanceof Error && error.name === 'AbortError') throw error;
|
|
64
|
-
|
|
77
|
+
// Fallback for CORS issues, though signature headers might be stripped in 'no-cors' mode
|
|
78
|
+
await postWithTimeout({
|
|
79
|
+
mode: 'no-cors',
|
|
80
|
+
headers: { 'Content-Type': 'text/plain;charset=UTF-8' },
|
|
81
|
+
body,
|
|
82
|
+
keepalive: true
|
|
83
|
+
});
|
|
65
84
|
return;
|
|
66
85
|
}
|
|
67
86
|
}
|
|
68
87
|
|
|
69
|
-
const response = await postWithTimeout({ headers
|
|
88
|
+
const response = await postWithTimeout({ headers, body });
|
|
70
89
|
if (!response.ok) throw new Error(`Webhook failed with status ${response.status}`);
|
|
71
90
|
};
|
|
72
91
|
|
|
@@ -79,21 +98,19 @@ export function WebKYCEntry({ onComplete, onError, onCancel, onSessionSave }: We
|
|
|
79
98
|
|
|
80
99
|
const parseUrlParams = useCallback((): URLParams => {
|
|
81
100
|
if (typeof window === 'undefined') return {};
|
|
82
|
-
|
|
83
101
|
const rawUrl = window.location.href;
|
|
84
102
|
console.log("Raw URL intercepted:", rawUrl);
|
|
85
103
|
|
|
86
104
|
const paramsString = rawUrl.replace(/^[^?#]*[?#]/, '').replace(/[?#]/g, '&');
|
|
87
|
-
|
|
88
105
|
const urlParams = new URLSearchParams(paramsString);
|
|
89
|
-
|
|
90
106
|
const getParam = (key: string) => urlParams.get(key) || undefined;
|
|
91
|
-
|
|
107
|
+
|
|
92
108
|
const envParam = getParam('env');
|
|
93
109
|
const validEnv = envParam === 'SANDBOX' || envParam === 'PRODUCTION' ? envParam : 'PRODUCTION';
|
|
110
|
+
|
|
94
111
|
const serverEnvParam = getParam('server_env');
|
|
95
112
|
const validServerEnv: BackendEnvironment = serverEnvParam === 'TEST' || serverEnvParam === 'PRODUCTION' ? (serverEnvParam as BackendEnvironment) : 'PRODUCTION';
|
|
96
|
-
|
|
113
|
+
|
|
97
114
|
return {
|
|
98
115
|
token: getParam('token'),
|
|
99
116
|
return_url: getParam('return_url'),
|
|
@@ -102,7 +119,7 @@ export function WebKYCEntry({ onComplete, onError, onCancel, onSessionSave }: We
|
|
|
102
119
|
reference_id: getParam('reference_id'),
|
|
103
120
|
lang: getParam('lang') || 'en',
|
|
104
121
|
theme: getParam('theme') || 'light',
|
|
105
|
-
kyc_id: getParam('kyc_id') || getParam('session_id'),
|
|
122
|
+
kyc_id: getParam('kyc_id') || getParam('session_id'),
|
|
106
123
|
secret: getParam('secret'),
|
|
107
124
|
env: validEnv,
|
|
108
125
|
template_id: getParam('template_id'),
|
|
@@ -116,9 +133,19 @@ export function WebKYCEntry({ onComplete, onError, onCancel, onSessionSave }: We
|
|
|
116
133
|
};
|
|
117
134
|
}, []);
|
|
118
135
|
|
|
119
|
-
const redirectToReturnUrl = useCallback(async (params: {
|
|
136
|
+
const redirectToReturnUrl = useCallback(async (params: {
|
|
137
|
+
status: 'completed' | 'cancelled' | 'error';
|
|
138
|
+
kyc_id?: string;
|
|
139
|
+
message?: string;
|
|
140
|
+
processing_state?: 'analyzing' | 'completed' | 'pending';
|
|
141
|
+
verification_steps?: VerificationSteps;
|
|
142
|
+
}) => {
|
|
120
143
|
const { return_url } = urlParams;
|
|
121
|
-
if (!return_url) {
|
|
144
|
+
if (!return_url) {
|
|
145
|
+
console.warn('No return_url provided');
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
|
|
122
149
|
try {
|
|
123
150
|
const validation = isCallbackUrlAllowed(return_url);
|
|
124
151
|
if (!validation.allowed) {
|
|
@@ -126,9 +153,17 @@ export function WebKYCEntry({ onComplete, onError, onCancel, onSessionSave }: We
|
|
|
126
153
|
setError(`Security Error: ${validation.reason}`);
|
|
127
154
|
return;
|
|
128
155
|
}
|
|
156
|
+
|
|
129
157
|
if (window.parent !== window) {
|
|
130
158
|
const targetOrigin = new URL(return_url).origin;
|
|
131
|
-
window.parent.postMessage({
|
|
159
|
+
window.parent.postMessage({
|
|
160
|
+
type: 'kyc_result',
|
|
161
|
+
status: params.status,
|
|
162
|
+
kyc_id: params.kyc_id,
|
|
163
|
+
message: params.message,
|
|
164
|
+
processing_state: params.processing_state,
|
|
165
|
+
verification_steps: params.verification_steps
|
|
166
|
+
}, targetOrigin);
|
|
132
167
|
} else {
|
|
133
168
|
window.location.href = return_url;
|
|
134
169
|
}
|
|
@@ -144,29 +179,18 @@ export function WebKYCEntry({ onComplete, onError, onCancel, onSessionSave }: We
|
|
|
144
179
|
|
|
145
180
|
if (urlParams.push_url) {
|
|
146
181
|
try {
|
|
147
|
-
// 1. Locate the actual backend payload from the Context state
|
|
148
182
|
const backendResult = data?.verification?.result || data?.result?.result || data?.result || data;
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
const finalSessionId =
|
|
152
|
-
data?.session?.session_id ||
|
|
153
|
-
backendResult?.session_id ||
|
|
154
|
-
backendResult?.data?.session_id ||
|
|
155
|
-
urlParams.kyc_id ||
|
|
156
|
-
'unknown';
|
|
157
|
-
|
|
158
|
-
// 3. Extract the core data payload
|
|
183
|
+
const finalSessionId = data?.session?.session_id || backendResult?.session_id || backendResult?.data?.session_id || urlParams.kyc_id || 'unknown';
|
|
184
|
+
|
|
159
185
|
let parsedKycData: any = {};
|
|
160
186
|
if (backendResult?.data) {
|
|
161
187
|
try {
|
|
162
|
-
parsedKycData = typeof backendResult.data === 'string'
|
|
163
|
-
? JSON.parse(backendResult.data)
|
|
164
|
-
: backendResult.data;
|
|
188
|
+
parsedKycData = typeof backendResult.data === 'string' ? JSON.parse(backendResult.data) : backendResult.data;
|
|
165
189
|
} catch (e) {
|
|
166
190
|
console.warn("Could not parse backendResult.data JSON");
|
|
167
191
|
}
|
|
168
192
|
}
|
|
169
|
-
|
|
193
|
+
|
|
170
194
|
if (parsedKycData && typeof parsedKycData === 'object' && parsedKycData[finalSessionId]) {
|
|
171
195
|
const nested = parsedKycData[finalSessionId];
|
|
172
196
|
if (nested?.data) {
|
|
@@ -188,32 +212,24 @@ export function WebKYCEntry({ onComplete, onError, onCancel, onSessionSave }: We
|
|
|
188
212
|
const hasValidData = parsedKycData && Object.keys(parsedKycData).length > 0;
|
|
189
213
|
|
|
190
214
|
if (!hasValidSessionId || !hasValidData) {
|
|
191
|
-
console.log("Webhook Blocked: Payload contains no data or session_id is unknown."
|
|
215
|
+
console.log("Webhook Blocked: Payload contains no data or session_id is unknown.");
|
|
192
216
|
} else {
|
|
193
|
-
|
|
194
|
-
await postWebhook(urlParams.push_url, verificationState, 5000);
|
|
217
|
+
// 🚨 MODIFIED: Passing urlParams.secret
|
|
218
|
+
await postWebhook(urlParams.push_url, verificationState, urlParams.secret, 5000);
|
|
195
219
|
}
|
|
196
|
-
|
|
197
220
|
} catch (err) {
|
|
198
221
|
console.warn('Failed to construct or push data to webhook URL:', err);
|
|
199
222
|
}
|
|
200
223
|
}
|
|
201
224
|
|
|
202
225
|
setIsAnalyzing(false);
|
|
203
|
-
|
|
204
|
-
// Always redirect the user back to your main app/website, regardless of webhook success/block
|
|
205
226
|
redirectToReturnUrl({
|
|
206
227
|
status: data?.verification?.status === 'failed' ? 'error' : 'completed',
|
|
207
228
|
kyc_id: data?.session?.session_id || urlParams.kyc_id,
|
|
208
229
|
message: 'KYC process concluded',
|
|
209
230
|
processing_state: isStillProcessing ? 'analyzing' : 'completed',
|
|
210
|
-
verification_steps: {
|
|
211
|
-
document_analyzed: true,
|
|
212
|
-
selfie_analyzed: true,
|
|
213
|
-
liveness_checked: true
|
|
214
|
-
},
|
|
231
|
+
verification_steps: { document_analyzed: true, selfie_analyzed: true, liveness_checked: true },
|
|
215
232
|
});
|
|
216
|
-
|
|
217
233
|
onComplete?.(data);
|
|
218
234
|
}, [redirectToReturnUrl, urlParams, onComplete]);
|
|
219
235
|
|
|
@@ -228,21 +244,38 @@ export function WebKYCEntry({ onComplete, onError, onCancel, onSessionSave }: We
|
|
|
228
244
|
setIsAnalyzing(false);
|
|
229
245
|
if (urlParams.push_url) {
|
|
230
246
|
try {
|
|
231
|
-
|
|
232
|
-
|
|
247
|
+
// 🚨 MODIFIED: Passing urlParams.secret
|
|
248
|
+
await postWebhook(
|
|
249
|
+
urlParams.push_url,
|
|
250
|
+
{ status: 'cancelled', result: null, reference_id: urlParams.reference_id },
|
|
251
|
+
urlParams.secret,
|
|
252
|
+
5000
|
|
253
|
+
);
|
|
254
|
+
} catch (err) {
|
|
255
|
+
console.warn('Failed to push data to webhook URL:', err);
|
|
256
|
+
}
|
|
233
257
|
}
|
|
258
|
+
|
|
234
259
|
redirectToReturnUrl({ status: 'cancelled', kyc_id: urlParams.kyc_id, message: 'KYC process was cancelled', processing_state: 'pending' });
|
|
235
260
|
onCancel?.();
|
|
236
|
-
}, [redirectToReturnUrl, urlParams.kyc_id, urlParams.push_url, urlParams.reference_id, onCancel]);
|
|
261
|
+
}, [redirectToReturnUrl, urlParams.kyc_id, urlParams.push_url, urlParams.reference_id, urlParams.secret, onCancel]);
|
|
237
262
|
|
|
238
263
|
const handleSessionSave = useCallback(async (sessionId: string) => {
|
|
239
264
|
if (urlParams.save_session_url) {
|
|
240
265
|
try {
|
|
241
|
-
|
|
242
|
-
|
|
266
|
+
// 🚨 MODIFIED: Passing urlParams.secret
|
|
267
|
+
await postWebhook(
|
|
268
|
+
urlParams.save_session_url,
|
|
269
|
+
{ status: 'session_created', reference_id: urlParams.reference_id, result: { session_id: sessionId, kyc_id: sessionId } },
|
|
270
|
+
urlParams.secret,
|
|
271
|
+
5000
|
|
272
|
+
);
|
|
273
|
+
} catch (err) {
|
|
274
|
+
console.warn('Failed to push session data:', err);
|
|
275
|
+
}
|
|
243
276
|
}
|
|
244
277
|
onSessionSave?.(sessionId);
|
|
245
|
-
}, [urlParams.save_session_url, urlParams.reference_id, onSessionSave]);
|
|
278
|
+
}, [urlParams.save_session_url, urlParams.reference_id, urlParams.secret, onSessionSave]);
|
|
246
279
|
|
|
247
280
|
useEffect(() => {
|
|
248
281
|
try {
|
|
@@ -272,7 +305,9 @@ export function WebKYCEntry({ onComplete, onError, onCancel, onSessionSave }: We
|
|
|
272
305
|
</View>
|
|
273
306
|
</View>
|
|
274
307
|
)}
|
|
308
|
+
{/* Overlay UI unchanged */}
|
|
275
309
|
<TemplateKYCExample
|
|
310
|
+
// ...Props unchanged...
|
|
276
311
|
onComplete={handleComplete}
|
|
277
312
|
onCancel={handleCancel}
|
|
278
313
|
onError={handleError}
|
|
@@ -281,14 +316,18 @@ export function WebKYCEntry({ onComplete, onError, onCancel, onSessionSave }: We
|
|
|
281
316
|
templateId={urlParams.template_id}
|
|
282
317
|
env={urlParams.env || 'PRODUCTION'}
|
|
283
318
|
serverEnv={urlParams.server_env}
|
|
284
|
-
existingSessionId={urlParams.kyc_id}
|
|
319
|
+
existingSessionId={urlParams.kyc_id}
|
|
285
320
|
initialComponentIndex={(() => {
|
|
286
321
|
const raw = urlParams.component_index ?? urlParams.step;
|
|
287
322
|
if (raw == null || raw === '') return undefined;
|
|
288
323
|
const index = parseInt(raw, 10);
|
|
289
324
|
return Number.isNaN(index) ? undefined : index;
|
|
290
325
|
})()}
|
|
291
|
-
initialCountryResume={urlParams.country && urlParams.document_type ? {
|
|
326
|
+
initialCountryResume={urlParams.country && urlParams.document_type ? {
|
|
327
|
+
code: urlParams.country,
|
|
328
|
+
documentType: urlParams.document_type,
|
|
329
|
+
region: urlParams.region || undefined
|
|
330
|
+
} : undefined}
|
|
292
331
|
referenceId={urlParams.reference_id}
|
|
293
332
|
onSessionSave={handleSessionSave}
|
|
294
333
|
/>
|