@hexar/biometric-identity-sdk-react-native 1.1.5 → 1.1.7
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ProfilePictureCapture.d.ts","sourceRoot":"","sources":["../../src/components/ProfilePictureCapture.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmD,MAAM,OAAO,CAAC;AASxE,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAmC,cAAc,EAAsB,MAAM,oCAAoC,CAAC;AAGzJ,MAAM,WAAW,8BAA8B;IAC7C,OAAO,EAAE,OAAO,CAAC;IACjB,cAAc,EAAE,MAAM,CAAC;IACvB,aAAa,EAAE,MAAM,CAAC;IACtB,YAAY,EAAE,OAAO,CAAC;IACtB,QAAQ,EAAE,MAAM,EAAE,CAAC;CACpB;AAED,MAAM,WAAW,0BAA0B;IACzC,UAAU,EAAE,CAAC,MAAM,EAAE,8BAA8B,KAAK,IAAI,CAAC;IAC7D,OAAO,EAAE,CAAC,KAAK,EAAE,cAAc,KAAK,IAAI,CAAC;IACzC,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;IACtB,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB,QAAQ,CAAC,EAAE,iBAAiB,CAAC;CAC9B;AAED,eAAO,MAAM,qBAAqB,EAAE,KAAK,CAAC,EAAE,CAAC,0BAA0B,
|
|
1
|
+
{"version":3,"file":"ProfilePictureCapture.d.ts","sourceRoot":"","sources":["../../src/components/ProfilePictureCapture.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmD,MAAM,OAAO,CAAC;AASxE,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAmC,cAAc,EAAsB,MAAM,oCAAoC,CAAC;AAGzJ,MAAM,WAAW,8BAA8B;IAC7C,OAAO,EAAE,OAAO,CAAC;IACjB,cAAc,EAAE,MAAM,CAAC;IACvB,aAAa,EAAE,MAAM,CAAC;IACtB,YAAY,EAAE,OAAO,CAAC;IACtB,QAAQ,EAAE,MAAM,EAAE,CAAC;CACpB;AAED,MAAM,WAAW,0BAA0B;IACzC,UAAU,EAAE,CAAC,MAAM,EAAE,8BAA8B,KAAK,IAAI,CAAC;IAC7D,OAAO,EAAE,CAAC,KAAK,EAAE,cAAc,KAAK,IAAI,CAAC;IACzC,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;IACtB,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB,QAAQ,CAAC,EAAE,iBAAiB,CAAC;CAC9B;AAED,eAAO,MAAM,qBAAqB,EAAE,KAAK,CAAC,EAAE,CAAC,0BAA0B,CAmNtE,CAAC;AAuBF,eAAe,qBAAqB,CAAC"}
|
|
@@ -40,14 +40,33 @@ const VideoRecorder_1 = require("./VideoRecorder");
|
|
|
40
40
|
const biometric_identity_sdk_core_1 = require("@hexar/biometric-identity-sdk-core");
|
|
41
41
|
const useBiometricSDK_1 = require("../hooks/useBiometricSDK");
|
|
42
42
|
const ProfilePictureCapture = ({ onComplete, onError, onCancel, theme, language, }) => {
|
|
43
|
-
const { sdk, isInitialized, isUsingBackend, sessionId, } = (0, useBiometricSDK_1.useBiometricSDK)();
|
|
43
|
+
const { sdk, isInitialized, isUsingBackend, sessionId, fetchChallenges, } = (0, useBiometricSDK_1.useBiometricSDK)();
|
|
44
44
|
const [isValidating, setIsValidating] = (0, react_1.useState)(false);
|
|
45
|
-
const [
|
|
45
|
+
const [currentChallenges, setCurrentChallenges] = (0, react_1.useState)([]);
|
|
46
|
+
const [isLoadingChallenges, setIsLoadingChallenges] = (0, react_1.useState)(false);
|
|
46
47
|
(0, react_1.useEffect)(() => {
|
|
47
48
|
if (language) {
|
|
48
49
|
(0, biometric_identity_sdk_core_1.setLanguage)(language);
|
|
49
50
|
}
|
|
50
51
|
}, [language]);
|
|
52
|
+
// Fetch challenges when component mounts and SDK is ready
|
|
53
|
+
(0, react_1.useEffect)(() => {
|
|
54
|
+
if (isInitialized && isUsingBackend) {
|
|
55
|
+
const loadChallenges = async () => {
|
|
56
|
+
setIsLoadingChallenges(true);
|
|
57
|
+
try {
|
|
58
|
+
const challenges = await fetchChallenges('active');
|
|
59
|
+
setCurrentChallenges(challenges);
|
|
60
|
+
}
|
|
61
|
+
catch (error) {
|
|
62
|
+
biometric_identity_sdk_core_1.logger.warn('Failed to fetch challenges, VideoRecorder will use defaults');
|
|
63
|
+
setCurrentChallenges([]);
|
|
64
|
+
}
|
|
65
|
+
setIsLoadingChallenges(false);
|
|
66
|
+
};
|
|
67
|
+
loadChallenges();
|
|
68
|
+
}
|
|
69
|
+
}, [isInitialized, isUsingBackend, fetchChallenges]);
|
|
51
70
|
const strings = (0, biometric_identity_sdk_core_1.getStrings)();
|
|
52
71
|
const validateWithBackend = (0, react_1.useCallback)(async (videoResult) => {
|
|
53
72
|
try {
|
|
@@ -120,12 +139,16 @@ const ProfilePictureCapture = ({ onComplete, onError, onCancel, theme, language,
|
|
|
120
139
|
}, [isInitialized, isUsingBackend, sdk]);
|
|
121
140
|
const handleVideoComplete = (0, react_1.useCallback)(async (videoResult) => {
|
|
122
141
|
setIsValidating(true);
|
|
123
|
-
setValidationError(null);
|
|
124
142
|
try {
|
|
125
143
|
const result = await validateWithBackend(videoResult);
|
|
126
144
|
if (!result.isValid) {
|
|
127
|
-
setValidationError(strings.errors.livenessCheckFailed || 'Liveness check failed');
|
|
128
145
|
setIsValidating(false);
|
|
146
|
+
const livenessError = {
|
|
147
|
+
name: 'BiometricError',
|
|
148
|
+
message: strings.errors.livenessCheckFailed || 'Liveness check failed. Please try again.',
|
|
149
|
+
code: biometric_identity_sdk_core_1.BiometricErrorCode.LIVENESS_CHECK_FAILED,
|
|
150
|
+
};
|
|
151
|
+
onError(livenessError);
|
|
129
152
|
return;
|
|
130
153
|
}
|
|
131
154
|
setIsValidating(false);
|
|
@@ -171,13 +194,11 @@ const ProfilePictureCapture = ({ onComplete, onError, onCancel, theme, language,
|
|
|
171
194
|
react_1.default.createElement(react_native_1.Text, { style: [styles.loadingText, { color: theme?.textColor || '#1e1b4b' }] }, strings.liveness.processing || strings.validation.checkingLiveness || 'Processing...'),
|
|
172
195
|
react_1.default.createElement(react_native_1.Text, { style: [styles.loadingSubtext, { color: theme?.secondaryTextColor || '#64748b' }] }, strings.validation.almostDone || strings.common.loading || 'This may take a few seconds'))));
|
|
173
196
|
}
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
}
|
|
180
|
-
return (react_1.default.createElement(VideoRecorder_1.VideoRecorder, { theme: theme, language: language, duration: 8000, smartMode: true, sessionId: sdk.getSessionId() || undefined, onComplete: handleVideoComplete, onCancel: handleVideoCancel }));
|
|
197
|
+
return (react_1.default.createElement(VideoRecorder_1.VideoRecorder, { theme: theme, language: language, duration: 8000, smartMode: true, challenges: currentChallenges, sessionId: sdk.getSessionId() || undefined, onComplete: handleVideoComplete, onCancel: handleVideoCancel, onFetchChallenges: async () => {
|
|
198
|
+
const challenges = await fetchChallenges('active');
|
|
199
|
+
setCurrentChallenges(challenges);
|
|
200
|
+
return challenges;
|
|
201
|
+
} }));
|
|
181
202
|
};
|
|
182
203
|
exports.ProfilePictureCapture = ProfilePictureCapture;
|
|
183
204
|
const styles = react_native_1.StyleSheet.create({
|
|
@@ -199,21 +220,5 @@ const styles = react_native_1.StyleSheet.create({
|
|
|
199
220
|
fontSize: 14,
|
|
200
221
|
marginTop: 8,
|
|
201
222
|
},
|
|
202
|
-
errorContainer: {
|
|
203
|
-
flex: 1,
|
|
204
|
-
justifyContent: 'center',
|
|
205
|
-
alignItems: 'center',
|
|
206
|
-
padding: 24,
|
|
207
|
-
},
|
|
208
|
-
errorTitle: {
|
|
209
|
-
fontSize: 20,
|
|
210
|
-
fontWeight: '600',
|
|
211
|
-
marginBottom: 12,
|
|
212
|
-
},
|
|
213
|
-
errorText: {
|
|
214
|
-
fontSize: 16,
|
|
215
|
-
textAlign: 'center',
|
|
216
|
-
lineHeight: 24,
|
|
217
|
-
},
|
|
218
223
|
});
|
|
219
224
|
exports.default = exports.ProfilePictureCapture;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hexar/biometric-identity-sdk-react-native",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.7",
|
|
4
4
|
"description": "React Native wrapper for Biometric Identity SDK",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"clean": "rm -rf dist"
|
|
12
12
|
},
|
|
13
13
|
"peerDependencies": {
|
|
14
|
-
"@hexar/biometric-identity-sdk-core": ">=1.
|
|
14
|
+
"@hexar/biometric-identity-sdk-core": ">=1.1.2",
|
|
15
15
|
"react": ">=18.0.0",
|
|
16
16
|
"react-native": ">=0.70.0",
|
|
17
17
|
"react-native-permissions": ">=4.0.0",
|
|
@@ -38,10 +38,12 @@ export const ProfilePictureCapture: React.FC<ProfilePictureCaptureProps> = ({
|
|
|
38
38
|
isInitialized,
|
|
39
39
|
isUsingBackend,
|
|
40
40
|
sessionId,
|
|
41
|
+
fetchChallenges,
|
|
41
42
|
} = useBiometricSDK();
|
|
42
43
|
|
|
43
44
|
const [isValidating, setIsValidating] = useState(false);
|
|
44
|
-
const [
|
|
45
|
+
const [currentChallenges, setCurrentChallenges] = useState<any[]>([]);
|
|
46
|
+
const [isLoadingChallenges, setIsLoadingChallenges] = useState(false);
|
|
45
47
|
|
|
46
48
|
useEffect(() => {
|
|
47
49
|
if (language) {
|
|
@@ -49,6 +51,24 @@ export const ProfilePictureCapture: React.FC<ProfilePictureCaptureProps> = ({
|
|
|
49
51
|
}
|
|
50
52
|
}, [language]);
|
|
51
53
|
|
|
54
|
+
// Fetch challenges when component mounts and SDK is ready
|
|
55
|
+
useEffect(() => {
|
|
56
|
+
if (isInitialized && isUsingBackend) {
|
|
57
|
+
const loadChallenges = async () => {
|
|
58
|
+
setIsLoadingChallenges(true);
|
|
59
|
+
try {
|
|
60
|
+
const challenges = await fetchChallenges('active');
|
|
61
|
+
setCurrentChallenges(challenges);
|
|
62
|
+
} catch (error) {
|
|
63
|
+
logger.warn('Failed to fetch challenges, VideoRecorder will use defaults');
|
|
64
|
+
setCurrentChallenges([]);
|
|
65
|
+
}
|
|
66
|
+
setIsLoadingChallenges(false);
|
|
67
|
+
};
|
|
68
|
+
loadChallenges();
|
|
69
|
+
}
|
|
70
|
+
}, [isInitialized, isUsingBackend, fetchChallenges]);
|
|
71
|
+
|
|
52
72
|
const strings = getStrings();
|
|
53
73
|
|
|
54
74
|
const validateWithBackend = useCallback(async (videoResult: VideoRecordingResult): Promise<ProfilePictureValidationResult> => {
|
|
@@ -130,14 +150,18 @@ export const ProfilePictureCapture: React.FC<ProfilePictureCaptureProps> = ({
|
|
|
130
150
|
|
|
131
151
|
const handleVideoComplete = useCallback(async (videoResult: VideoRecordingResult) => {
|
|
132
152
|
setIsValidating(true);
|
|
133
|
-
setValidationError(null);
|
|
134
153
|
|
|
135
154
|
try {
|
|
136
155
|
const result = await validateWithBackend(videoResult);
|
|
137
156
|
|
|
138
157
|
if (!result.isValid) {
|
|
139
|
-
setValidationError(strings.errors.livenessCheckFailed || 'Liveness check failed');
|
|
140
158
|
setIsValidating(false);
|
|
159
|
+
const livenessError: BiometricError = {
|
|
160
|
+
name: 'BiometricError',
|
|
161
|
+
message: strings.errors.livenessCheckFailed || 'Liveness check failed. Please try again.',
|
|
162
|
+
code: BiometricErrorCode.LIVENESS_CHECK_FAILED,
|
|
163
|
+
} as BiometricError;
|
|
164
|
+
onError(livenessError);
|
|
141
165
|
return;
|
|
142
166
|
}
|
|
143
167
|
|
|
@@ -196,30 +220,21 @@ export const ProfilePictureCapture: React.FC<ProfilePictureCaptureProps> = ({
|
|
|
196
220
|
);
|
|
197
221
|
}
|
|
198
222
|
|
|
199
|
-
if (validationError) {
|
|
200
|
-
return (
|
|
201
|
-
<SafeAreaView style={[styles.container, { backgroundColor: theme?.backgroundColor || '#FFFFFF' }]}>
|
|
202
|
-
<View style={styles.errorContainer}>
|
|
203
|
-
<Text style={[styles.errorTitle, { color: theme?.errorColor || '#EF4444' }]}>
|
|
204
|
-
{strings.errors.unknownError || strings.validation.title || 'Error'}
|
|
205
|
-
</Text>
|
|
206
|
-
<Text style={[styles.errorText, { color: theme?.textColor || '#1e1b4b' }]}>
|
|
207
|
-
{validationError}
|
|
208
|
-
</Text>
|
|
209
|
-
</View>
|
|
210
|
-
</SafeAreaView>
|
|
211
|
-
);
|
|
212
|
-
}
|
|
213
|
-
|
|
214
223
|
return (
|
|
215
224
|
<VideoRecorder
|
|
216
225
|
theme={theme}
|
|
217
226
|
language={language}
|
|
218
227
|
duration={8000}
|
|
219
228
|
smartMode={true}
|
|
229
|
+
challenges={currentChallenges}
|
|
220
230
|
sessionId={sdk.getSessionId() || undefined}
|
|
221
231
|
onComplete={handleVideoComplete}
|
|
222
232
|
onCancel={handleVideoCancel}
|
|
233
|
+
onFetchChallenges={async () => {
|
|
234
|
+
const challenges = await fetchChallenges('active');
|
|
235
|
+
setCurrentChallenges(challenges);
|
|
236
|
+
return challenges;
|
|
237
|
+
}}
|
|
223
238
|
/>
|
|
224
239
|
);
|
|
225
240
|
};
|
|
@@ -243,22 +258,6 @@ const styles = StyleSheet.create({
|
|
|
243
258
|
fontSize: 14,
|
|
244
259
|
marginTop: 8,
|
|
245
260
|
},
|
|
246
|
-
errorContainer: {
|
|
247
|
-
flex: 1,
|
|
248
|
-
justifyContent: 'center',
|
|
249
|
-
alignItems: 'center',
|
|
250
|
-
padding: 24,
|
|
251
|
-
},
|
|
252
|
-
errorTitle: {
|
|
253
|
-
fontSize: 20,
|
|
254
|
-
fontWeight: '600',
|
|
255
|
-
marginBottom: 12,
|
|
256
|
-
},
|
|
257
|
-
errorText: {
|
|
258
|
-
fontSize: 16,
|
|
259
|
-
textAlign: 'center',
|
|
260
|
-
lineHeight: 24,
|
|
261
|
-
},
|
|
262
261
|
});
|
|
263
262
|
|
|
264
263
|
export default ProfilePictureCapture;
|