@sanctum-key/react-native-sdk 1.0.51 → 1.0.53
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/android/build/intermediates/compiled_local_resources/debug/compileDebugLibraryResources/out/xml_file_paths.xml.flat +0 -0
- package/android/build/intermediates/incremental/debug/packageDebugResources/compile-file-map.properties +2 -2
- package/android/build/intermediates/incremental/debug/packageDebugResources/merger.xml +1 -1
- package/android/build/intermediates/incremental/mergeDebugJniLibFolders/merger.xml +1 -1
- package/android/build/intermediates/incremental/mergeDebugShaders/merger.xml +1 -1
- package/android/build/intermediates/incremental/packageDebugAssets/merger.xml +1 -1
- package/android/build/intermediates/manifest_merge_blame_file/debug/processDebugManifest/manifest-merger-blame-debug-report.txt +41 -41
- package/android/build/kotlin/compileDebugKotlin/cacheable/last-build.bin +0 -0
- package/android/build/kotlin/compileDebugKotlin/local-state/build-history.bin +0 -0
- package/android/build/outputs/logs/manifest-merger-debug-report.txt +52 -52
- package/build/package.json +1 -1
- package/build/src/components/KYCElements/IDCardCapture.d.ts.map +1 -1
- package/build/src/components/KYCElements/IDCardCapture.js +73 -66
- package/build/src/components/KYCElements/IDCardCapture.js.map +1 -1
- package/build/src/components/TemplateKYCExample.d.ts +2 -1
- package/build/src/components/TemplateKYCExample.d.ts.map +1 -1
- package/build/src/components/TemplateKYCExample.js +20 -18
- package/build/src/components/TemplateKYCExample.js.map +1 -1
- package/build/src/components/TemplateKYCFlowRefactored.d.ts +1 -0
- package/build/src/components/TemplateKYCFlowRefactored.d.ts.map +1 -1
- package/build/src/components/TemplateKYCFlowRefactored.js +20 -20
- package/build/src/components/TemplateKYCFlowRefactored.js.map +1 -1
- package/build/src/config/KYCConfig.d.ts.map +1 -1
- package/build/src/config/KYCConfig.js +4 -2
- package/build/src/config/KYCConfig.js.map +1 -1
- package/build/src/hooks/useTemplateKYCFlow.d.ts +1 -0
- package/build/src/hooks/useTemplateKYCFlow.d.ts.map +1 -1
- package/build/src/hooks/useTemplateKYCFlow.js.map +1 -1
- package/build/src/hooks/useTemplateLoader.d.ts.map +1 -1
- package/build/src/hooks/useTemplateLoader.js +0 -2
- package/build/src/hooks/useTemplateLoader.js.map +1 -1
- package/build/src/modules/api/CardAuthentification.d.ts +0 -23
- package/build/src/modules/api/CardAuthentification.d.ts.map +1 -1
- package/build/src/modules/api/CardAuthentification.js +46 -83
- package/build/src/modules/api/CardAuthentification.js.map +1 -1
- package/build/src/modules/api/KYCService.d.ts.map +1 -1
- package/build/src/modules/api/KYCService.js +96 -38
- package/build/src/modules/api/KYCService.js.map +1 -1
- package/build/src/modules/api/SelfieVerification.d.ts.map +1 -1
- package/build/src/modules/api/SelfieVerification.js +12 -19
- package/build/src/modules/api/SelfieVerification.js.map +1 -1
- package/build/src/modules/api/TemplateService.d.ts.map +1 -1
- package/build/src/modules/api/TemplateService.js +2 -1
- package/build/src/modules/api/TemplateService.js.map +1 -1
- package/build/src/modules/api/types.d.ts +34 -27
- package/build/src/modules/api/types.d.ts.map +1 -1
- package/build/src/modules/api/types.js.map +1 -1
- package/package.json +1 -1
- package/src/components/KYCElements/IDCardCapture.tsx +192 -191
- package/src/components/TemplateKYCExample.tsx +29 -20
- package/src/components/TemplateKYCFlowRefactored.tsx +33 -31
- package/src/config/KYCConfig.ts +7 -5
- package/src/hooks/useTemplateKYCFlow.tsx +1 -0
- package/src/hooks/useTemplateLoader.ts +0 -2
- package/src/modules/api/CardAuthentification.ts +409 -445
- package/src/modules/api/KYCService.ts +599 -449
- package/src/modules/api/SelfieVerification.ts +22 -29
- package/src/modules/api/TemplateService.ts +3 -2
- package/src/modules/api/types.ts +36 -29
|
@@ -48,6 +48,7 @@ export interface TemplateKYCExampleProps {
|
|
|
48
48
|
onError: (error: string) => void;
|
|
49
49
|
language: string;
|
|
50
50
|
API_KEY?: string;
|
|
51
|
+
TEST_API_KEY?: string;
|
|
51
52
|
templateId?: string;
|
|
52
53
|
template?: KYCTemplate;
|
|
53
54
|
env?: KycEnvironment;
|
|
@@ -66,6 +67,7 @@ export function TemplateKYCExample({
|
|
|
66
67
|
onError,
|
|
67
68
|
language,
|
|
68
69
|
API_KEY,
|
|
70
|
+
TEST_API_KEY,
|
|
69
71
|
templateId,
|
|
70
72
|
template,
|
|
71
73
|
env = 'PRODUCTION',
|
|
@@ -84,45 +86,51 @@ export function TemplateKYCExample({
|
|
|
84
86
|
let finalPayload: any = data; // Fallback to raw data if mapping fails
|
|
85
87
|
|
|
86
88
|
if ((data.status === 'success' || data.status === 'in_progress') && data.result) {
|
|
87
|
-
// 1. Extract the dynamic root key (e.g., 'national_id', 'passport')
|
|
88
|
-
const docKey = Object.keys(data.result)[0];
|
|
89
89
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
90
|
+
// 1. Grab the backend data directly from the result (no docKey needed)
|
|
91
|
+
const backendData = data.result.data;
|
|
92
|
+
|
|
93
|
+
if (backendData) {
|
|
94
|
+
const personalInfo = backendData.user_data?.personal_information || {};
|
|
95
|
+
|
|
94
96
|
// Ensure we capture the session ID from whichever prop was provided
|
|
95
|
-
const activeSessionId = kyc_session_id || existingSessionId || "";
|
|
97
|
+
const activeSessionId = kyc_session_id || existingSessionId || backendData.session_id || "";
|
|
96
98
|
|
|
97
|
-
// 2. Strict mapping to your expected format
|
|
99
|
+
// 2. Strict mapping to your expected format with improved fallbacks
|
|
98
100
|
finalPayload = {
|
|
99
101
|
data: {
|
|
100
|
-
verification_id: backendData
|
|
101
|
-
verification_status: backendData
|
|
102
|
+
verification_id: backendData.verification_id,
|
|
103
|
+
verification_status: backendData.verification_status,
|
|
102
104
|
session_id: activeSessionId,
|
|
103
105
|
user_data: {
|
|
104
106
|
personal_information: {
|
|
105
|
-
|
|
107
|
+
// Safely fallback to given_name and surname if first/last are empty strings
|
|
108
|
+
first_name: personalInfo.first_name || personalInfo.given_name || undefined,
|
|
109
|
+
last_name: personalInfo.last_name || personalInfo.surname || undefined,
|
|
106
110
|
given_name: personalInfo.given_name || undefined,
|
|
107
|
-
|
|
108
|
-
|
|
111
|
+
surname: personalInfo.surname || undefined,
|
|
112
|
+
|
|
109
113
|
address: personalInfo.address || undefined,
|
|
110
114
|
city: personalInfo.city || undefined,
|
|
111
115
|
postal_code: personalInfo.postal_code || undefined,
|
|
112
116
|
expiry_date: personalInfo.expiry_date || undefined,
|
|
113
117
|
issue_date: personalInfo.issue_date || undefined,
|
|
114
|
-
|
|
115
|
-
birth_date
|
|
118
|
+
|
|
119
|
+
// Fallback to birth_date if date_of_birth is missing
|
|
120
|
+
date_of_birth: personalInfo.date_of_birth || personalInfo.birth_date || undefined,
|
|
121
|
+
birth_date: personalInfo.birth_date || undefined,
|
|
122
|
+
|
|
116
123
|
country: personalInfo.country || undefined,
|
|
117
|
-
document_number:
|
|
118
|
-
nationality:
|
|
124
|
+
document_number: personalInfo.document_number || undefined,
|
|
125
|
+
nationality: personalInfo.nationality || undefined,
|
|
126
|
+
sex: personalInfo.sex || undefined,
|
|
119
127
|
}
|
|
120
128
|
}
|
|
121
129
|
}
|
|
122
130
|
};
|
|
123
131
|
|
|
124
132
|
sdkLogger.info("Wrapper formatted completion payload successfully", {
|
|
125
|
-
|
|
133
|
+
data: finalPayload
|
|
126
134
|
});
|
|
127
135
|
}
|
|
128
136
|
} else {
|
|
@@ -130,7 +138,7 @@ export function TemplateKYCExample({
|
|
|
130
138
|
}
|
|
131
139
|
|
|
132
140
|
onComplete(finalPayload as any);
|
|
133
|
-
|
|
141
|
+
};
|
|
134
142
|
|
|
135
143
|
const handleCancel = () => {
|
|
136
144
|
console.log('KYC Template flow cancelled');
|
|
@@ -138,7 +146,7 @@ export function TemplateKYCExample({
|
|
|
138
146
|
};
|
|
139
147
|
|
|
140
148
|
const handleError = (error: string) => {
|
|
141
|
-
|
|
149
|
+
sdkLogger.error('KYC Template error:', error);
|
|
142
150
|
onError(error);
|
|
143
151
|
};
|
|
144
152
|
|
|
@@ -155,6 +163,7 @@ export function TemplateKYCExample({
|
|
|
155
163
|
onCancel={handleCancel}
|
|
156
164
|
language={language}
|
|
157
165
|
API_KEY={API_KEY}
|
|
166
|
+
TEST_API_KEY={TEST_API_KEY}
|
|
158
167
|
env={env}
|
|
159
168
|
serverEnv={serverEnv}
|
|
160
169
|
existingSessionId={existingSessionId}
|
|
@@ -4,7 +4,6 @@ import { KYCTemplate, VerificationState } from '../types/KYC.types';
|
|
|
4
4
|
import { TemplateKYCFlowProvider, useTemplateKYCFlowContext } from '../hooks/useTemplateKYCFlow';
|
|
5
5
|
import { useI18n } from '../hooks/useI18n';
|
|
6
6
|
import { showAlert } from '../utils/platformAlert';
|
|
7
|
-
|
|
8
7
|
import { IDCardCapture } from './KYCElements/IDCardCapture';
|
|
9
8
|
import { SelfieCaptureTemplate } from './KYCElements/SelfieCaptureTemplate';
|
|
10
9
|
import { FileUploadTemplate } from './KYCElements/FileUploadTemplate';
|
|
@@ -21,18 +20,19 @@ import { PersonalInformationTemplate } from './KYCElements/PersonalInformationTe
|
|
|
21
20
|
import { AdditionalDocumentsTemplate } from './KYCElements/AdditionalDocumentsTemplate';
|
|
22
21
|
import { KycEnvironment, BackendEnvironment } from '../types/env.types';
|
|
23
22
|
import KYCConfig from '../config/KYCConfig';
|
|
24
|
-
import { sdkLogger } from '../utils/logger';
|
|
23
|
+
import { logger, sdkLogger } from '../utils/logger';
|
|
25
24
|
|
|
26
25
|
interface TemplateKYCFlowProps {
|
|
27
|
-
template?: KYCTemplate;
|
|
28
|
-
templateId?: string;
|
|
26
|
+
template?: KYCTemplate;
|
|
27
|
+
templateId?: string;
|
|
29
28
|
onComplete?: (data: VerificationState) => void;
|
|
30
29
|
onError?: (error: string) => void;
|
|
31
30
|
language?: string;
|
|
32
31
|
onCancel?: () => void;
|
|
33
|
-
API_KEY?: string;
|
|
34
|
-
|
|
35
|
-
|
|
32
|
+
API_KEY?: string;
|
|
33
|
+
TEST_API_KEY?: string;
|
|
34
|
+
env?: KycEnvironment;
|
|
35
|
+
serverEnv?: BackendEnvironment;
|
|
36
36
|
existingSessionId?: string;
|
|
37
37
|
initialComponentIndex?: number;
|
|
38
38
|
initialCountryResume?: { code: string; documentType: string; region?: string };
|
|
@@ -49,6 +49,7 @@ export const TemplateKYCFlow: React.FC<TemplateKYCFlowProps> = ({
|
|
|
49
49
|
language = 'fr',
|
|
50
50
|
onCancel,
|
|
51
51
|
API_KEY,
|
|
52
|
+
TEST_API_KEY,
|
|
52
53
|
env = 'PRODUCTION',
|
|
53
54
|
serverEnv,
|
|
54
55
|
existingSessionId,
|
|
@@ -61,12 +62,14 @@ export const TemplateKYCFlow: React.FC<TemplateKYCFlowProps> = ({
|
|
|
61
62
|
const { t } = useI18n();
|
|
62
63
|
const { template: loadedTemplate, isLoading, error, loadTemplate } = useTemplateLoader();
|
|
63
64
|
|
|
65
|
+
// 🚨 1. Determine the active API key based on the environment
|
|
66
|
+
const activeApiKey = env === 'PRODUCTION' ? API_KEY : (TEST_API_KEY || API_KEY);
|
|
67
|
+
|
|
64
68
|
useEffect(() => {
|
|
65
|
-
if (
|
|
66
|
-
if (sdkLogger.setApiKey) sdkLogger.setApiKey(
|
|
69
|
+
if (activeApiKey) {
|
|
70
|
+
if (sdkLogger.setApiKey) sdkLogger.setApiKey(activeApiKey);
|
|
67
71
|
}
|
|
68
|
-
|
|
69
|
-
}, [env, serverEnv, existingSessionId, API_KEY]);
|
|
72
|
+
}, [env, serverEnv, existingSessionId, activeApiKey]);
|
|
70
73
|
|
|
71
74
|
useEffect(() => {
|
|
72
75
|
if (serverEnv !== undefined) {
|
|
@@ -77,19 +80,20 @@ export const TemplateKYCFlow: React.FC<TemplateKYCFlowProps> = ({
|
|
|
77
80
|
useEffect(() => {
|
|
78
81
|
if (!providedTemplate && !templateId) {
|
|
79
82
|
const errorMsg = 'Either template or templateId must be provided';
|
|
80
|
-
|
|
83
|
+
logger.error("Template Loading Failed: Missing Props", { errorMsg });
|
|
81
84
|
onError?.(errorMsg);
|
|
82
85
|
return;
|
|
83
86
|
}
|
|
84
87
|
|
|
85
|
-
if (templateId && !
|
|
86
|
-
|
|
88
|
+
if (templateId && !activeApiKey) {
|
|
89
|
+
logger.log(`Fetching template ${templateId} via token authentication`);
|
|
87
90
|
loadTemplate(templateId);
|
|
88
|
-
} else if (templateId &&
|
|
89
|
-
|
|
90
|
-
|
|
91
|
+
} else if (templateId && activeApiKey) {
|
|
92
|
+
logger.log(`Fetching template ${templateId} via API Key`);
|
|
93
|
+
// 🚨 2. Use the resolved active key here
|
|
94
|
+
loadTemplate(templateId, activeApiKey);
|
|
91
95
|
}
|
|
92
|
-
}, [templateId,
|
|
96
|
+
}, [templateId, activeApiKey, providedTemplate, loadTemplate, onError]);
|
|
93
97
|
|
|
94
98
|
useEffect(() => {
|
|
95
99
|
if (error) {
|
|
@@ -103,8 +107,8 @@ export const TemplateKYCFlow: React.FC<TemplateKYCFlowProps> = ({
|
|
|
103
107
|
t('kyc.cancelConfirmation.title'),
|
|
104
108
|
t('kyc.cancelConfirmation.message'),
|
|
105
109
|
[
|
|
106
|
-
{
|
|
107
|
-
text: t('kyc.cancelConfirmation.cancelButton'),
|
|
110
|
+
{
|
|
111
|
+
text: t('kyc.cancelConfirmation.cancelButton'),
|
|
108
112
|
style: 'cancel',
|
|
109
113
|
},
|
|
110
114
|
{
|
|
@@ -121,11 +125,7 @@ export const TemplateKYCFlow: React.FC<TemplateKYCFlowProps> = ({
|
|
|
121
125
|
|
|
122
126
|
const template = providedTemplate || loadedTemplate;
|
|
123
127
|
|
|
124
|
-
|
|
125
|
-
if (template) {
|
|
126
|
-
sdkLogger.info("Template loaded successfully", { componentCount: template.components.length });
|
|
127
|
-
}
|
|
128
|
-
}, [template]);
|
|
128
|
+
|
|
129
129
|
|
|
130
130
|
if (templateId && isLoading && !template) {
|
|
131
131
|
return (
|
|
@@ -140,11 +140,11 @@ export const TemplateKYCFlow: React.FC<TemplateKYCFlowProps> = ({
|
|
|
140
140
|
return (
|
|
141
141
|
<View style={styles.errorContainer}>
|
|
142
142
|
<Text style={styles.errorText}>{error}</Text>
|
|
143
|
-
<TouchableOpacity
|
|
144
|
-
style={styles.retryButton}
|
|
143
|
+
<TouchableOpacity
|
|
144
|
+
style={styles.retryButton}
|
|
145
145
|
onPress={() => {
|
|
146
146
|
sdkLogger.info("User retrying template fetch");
|
|
147
|
-
loadTemplate(templateId,
|
|
147
|
+
loadTemplate(templateId, activeApiKey);
|
|
148
148
|
}}
|
|
149
149
|
>
|
|
150
150
|
<Text style={styles.retryButtonText}>{t('common.retry') || 'Retry'}</Text>
|
|
@@ -163,23 +163,26 @@ export const TemplateKYCFlow: React.FC<TemplateKYCFlowProps> = ({
|
|
|
163
163
|
);
|
|
164
164
|
}
|
|
165
165
|
|
|
166
|
-
|
|
167
166
|
return (
|
|
168
167
|
<TemplateKYCFlowProvider
|
|
169
168
|
template={template}
|
|
170
169
|
onComplete={(data) => {
|
|
171
170
|
sdkLogger.info("KYC Flow Completed", { referenceId: data?.result?.referenceId });
|
|
172
171
|
sdkLogger.flush();
|
|
172
|
+
logger.log('this is the data going to the TG side',data)
|
|
173
|
+
console.log('this is the data going to the TG side',data)
|
|
173
174
|
if (onComplete) onComplete(data);
|
|
174
175
|
}}
|
|
175
176
|
onError={(err) => {
|
|
176
177
|
sdkLogger.error("KYC Flow Error", { error: err });
|
|
177
178
|
sdkLogger.flush();
|
|
179
|
+
logger.log('Error', err)
|
|
178
180
|
if (onError) onError(err);
|
|
179
181
|
}}
|
|
180
182
|
onCancel={OnCancel}
|
|
181
183
|
initialLanguage={language}
|
|
182
|
-
apiKey={
|
|
184
|
+
apiKey={activeApiKey}
|
|
185
|
+
testApiKey={TEST_API_KEY}
|
|
183
186
|
env={env}
|
|
184
187
|
existingSessionId={existingSessionId}
|
|
185
188
|
initialComponentIndex={initialComponentIndex}
|
|
@@ -197,7 +200,6 @@ const TemplateKYCFlowContent: React.FC<{ onCancel?: () => void }> = ({ onCancel
|
|
|
197
200
|
const { state, actions, currentComponent, progress } = useTemplateKYCFlowContext();
|
|
198
201
|
const { t } = useI18n();
|
|
199
202
|
|
|
200
|
-
console.log(`sessionnnn id: ${state.session.session_id}`)
|
|
201
203
|
|
|
202
204
|
useEffect(() => {
|
|
203
205
|
if (state.session?.session_id) {
|
package/src/config/KYCConfig.ts
CHANGED
|
@@ -4,10 +4,11 @@ class KYCConfig {
|
|
|
4
4
|
private static instance: KYCConfig;
|
|
5
5
|
private backendEnvironment: BackendEnvironment = 'PRODUCTION';
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
// 🚨 Use a string record to safely handle 'TEST' or 'SANDBOX' aliases
|
|
8
|
+
private backendUrls: Record<string, string> = {
|
|
8
9
|
PRODUCTION: 'https://service.sanctumkey.com/api/v1',
|
|
9
|
-
|
|
10
|
-
|
|
10
|
+
TEST: 'https://api.sanctumkey.com/api/v1',
|
|
11
|
+
SANDBOX: 'https://kyc-backend.transfergratis.net/api/v1',
|
|
11
12
|
};
|
|
12
13
|
|
|
13
14
|
private constructor() { }
|
|
@@ -24,7 +25,8 @@ class KYCConfig {
|
|
|
24
25
|
}
|
|
25
26
|
|
|
26
27
|
public getBackendUrl(): string {
|
|
27
|
-
|
|
28
|
+
// Fallback to PRODUCTION if an invalid env string is somehow passed
|
|
29
|
+
return this.backendUrls[this.backendEnvironment] || this.backendUrls['PRODUCTION'];
|
|
28
30
|
}
|
|
29
31
|
|
|
30
32
|
public getBackendEnvironment(): BackendEnvironment {
|
|
@@ -32,4 +34,4 @@ class KYCConfig {
|
|
|
32
34
|
}
|
|
33
35
|
}
|
|
34
36
|
|
|
35
|
-
export default KYCConfig.getInstance();
|
|
37
|
+
export default KYCConfig.getInstance();
|
|
@@ -33,6 +33,7 @@ interface TemplateKYCFlowProviderProps {
|
|
|
33
33
|
onCancel?: () => void;
|
|
34
34
|
initialLanguage?: string;
|
|
35
35
|
apiKey?: string;
|
|
36
|
+
testApiKey?: string;
|
|
36
37
|
env?: KycEnvironment;
|
|
37
38
|
existingSessionId?: string;
|
|
38
39
|
/** Index in template.components where to resume (0-based). Simple to store in template table. */
|
|
@@ -61,10 +61,8 @@ export function useTemplateLoader(): UseTemplateLoaderReturn {
|
|
|
61
61
|
|
|
62
62
|
// Set the template
|
|
63
63
|
setTemplate(transformedTemplate);
|
|
64
|
-
logger.log(`Template loaded successfully: ${templateId}`);
|
|
65
64
|
} catch (err: any) {
|
|
66
65
|
const errorMessage = err.message || 'Failed to load template';
|
|
67
|
-
logger.error(`Error loading template ${templateId}:`, errorMessage);
|
|
68
66
|
setError(errorMessage);
|
|
69
67
|
setTemplate(null);
|
|
70
68
|
} finally {
|