@hexar/biometric-identity-sdk-react-native 1.1.2 → 1.1.4
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,CAoMtE,CAAC;AAuCF,eAAe,qBAAqB,CAAC"}
|
|
@@ -40,7 +40,7 @@ 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, } = (0, useBiometricSDK_1.useBiometricSDK)();
|
|
43
|
+
const { sdk, isInitialized, isUsingBackend, sessionId, } = (0, useBiometricSDK_1.useBiometricSDK)();
|
|
44
44
|
const [isValidating, setIsValidating] = (0, react_1.useState)(false);
|
|
45
45
|
const [validationError, setValidationError] = (0, react_1.useState)(null);
|
|
46
46
|
(0, react_1.useEffect)(() => {
|
|
@@ -59,9 +59,20 @@ const ProfilePictureCapture = ({ onComplete, onError, onCancel, theme, language,
|
|
|
59
59
|
biometric_identity_sdk_core_1.logger.error('Backend not available - SDK not configured with backend');
|
|
60
60
|
throw new Error('NETWORK_ERROR');
|
|
61
61
|
}
|
|
62
|
-
|
|
62
|
+
let sessionId = videoResult.sessionId || sdk.getSessionId();
|
|
63
63
|
if (!sessionId) {
|
|
64
|
-
biometric_identity_sdk_core_1.logger.
|
|
64
|
+
biometric_identity_sdk_core_1.logger.info('No session ID available, generating challenge to create one');
|
|
65
|
+
try {
|
|
66
|
+
const challengeResponse = await sdk.generateLivenessChallenge('active');
|
|
67
|
+
sessionId = challengeResponse.session_id;
|
|
68
|
+
biometric_identity_sdk_core_1.logger.info('Session ID generated', { sessionId });
|
|
69
|
+
}
|
|
70
|
+
catch (challengeError) {
|
|
71
|
+
biometric_identity_sdk_core_1.logger.error('Failed to generate challenge for session ID', challengeError);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
if (!sessionId) {
|
|
75
|
+
biometric_identity_sdk_core_1.logger.error('Session ID not available after attempting to generate');
|
|
65
76
|
throw new Error('VALIDATION_ERROR');
|
|
66
77
|
}
|
|
67
78
|
biometric_identity_sdk_core_1.logger.info('Validating profile picture with backend', {
|
|
@@ -69,9 +80,15 @@ const ProfilePictureCapture = ({ onComplete, onError, onCancel, theme, language,
|
|
|
69
80
|
framesCount: videoResult.frames.length,
|
|
70
81
|
duration: videoResult.duration,
|
|
71
82
|
isUsingBackend,
|
|
83
|
+
hasVideoFrames: !!videoResult.frames,
|
|
84
|
+
videoFramesType: typeof videoResult.frames,
|
|
85
|
+
firstFrameLength: videoResult.frames?.[0]?.length || 0,
|
|
72
86
|
});
|
|
87
|
+
if (!videoResult.frames || videoResult.frames.length === 0) {
|
|
88
|
+
throw new Error('No video frames available for validation');
|
|
89
|
+
}
|
|
73
90
|
const result = await sdk.validateProfilePicture({
|
|
74
|
-
sessionId,
|
|
91
|
+
sessionId: sessionId,
|
|
75
92
|
videoFrames: videoResult.frames,
|
|
76
93
|
videoDurationMs: videoResult.duration,
|
|
77
94
|
challengesCompleted: videoResult.challengesCompleted || [],
|
|
@@ -90,7 +107,14 @@ const ProfilePictureCapture = ({ onComplete, onError, onCancel, theme, language,
|
|
|
90
107
|
};
|
|
91
108
|
}
|
|
92
109
|
catch (error) {
|
|
93
|
-
biometric_identity_sdk_core_1.logger.error('Profile picture validation error',
|
|
110
|
+
biometric_identity_sdk_core_1.logger.error('Profile picture validation error', {
|
|
111
|
+
error,
|
|
112
|
+
errorMessage: error?.message,
|
|
113
|
+
errorName: error?.name,
|
|
114
|
+
errorCode: error?.code,
|
|
115
|
+
errorStack: error?.stack,
|
|
116
|
+
errorString: String(error),
|
|
117
|
+
});
|
|
94
118
|
throw error;
|
|
95
119
|
}
|
|
96
120
|
}, [isInitialized, isUsingBackend, sdk]);
|
|
@@ -153,7 +177,7 @@ const ProfilePictureCapture = ({ onComplete, onError, onCancel, theme, language,
|
|
|
153
177
|
react_1.default.createElement(react_native_1.Text, { style: [styles.errorTitle, { color: theme?.errorColor || '#EF4444' }] }, strings.errors.unknownError || strings.validation.title || 'Error'),
|
|
154
178
|
react_1.default.createElement(react_native_1.Text, { style: [styles.errorText, { color: theme?.textColor || '#1e1b4b' }] }, validationError))));
|
|
155
179
|
}
|
|
156
|
-
return (react_1.default.createElement(VideoRecorder_1.VideoRecorder, { theme: theme, language: language, duration: 8000, smartMode: true, onComplete: handleVideoComplete, onCancel: handleVideoCancel }));
|
|
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 }));
|
|
157
181
|
};
|
|
158
182
|
exports.ProfilePictureCapture = ProfilePictureCapture;
|
|
159
183
|
const styles = react_native_1.StyleSheet.create({
|
package/package.json
CHANGED
|
@@ -37,6 +37,7 @@ export const ProfilePictureCapture: React.FC<ProfilePictureCaptureProps> = ({
|
|
|
37
37
|
sdk,
|
|
38
38
|
isInitialized,
|
|
39
39
|
isUsingBackend,
|
|
40
|
+
sessionId,
|
|
40
41
|
} = useBiometricSDK();
|
|
41
42
|
|
|
42
43
|
const [isValidating, setIsValidating] = useState(false);
|
|
@@ -62,9 +63,21 @@ export const ProfilePictureCapture: React.FC<ProfilePictureCaptureProps> = ({
|
|
|
62
63
|
throw new Error('NETWORK_ERROR');
|
|
63
64
|
}
|
|
64
65
|
|
|
65
|
-
|
|
66
|
+
let sessionId = videoResult.sessionId || sdk.getSessionId();
|
|
67
|
+
|
|
68
|
+
if (!sessionId) {
|
|
69
|
+
logger.info('No session ID available, generating challenge to create one');
|
|
70
|
+
try {
|
|
71
|
+
const challengeResponse = await sdk.generateLivenessChallenge('active');
|
|
72
|
+
sessionId = challengeResponse.session_id;
|
|
73
|
+
logger.info('Session ID generated', { sessionId });
|
|
74
|
+
} catch (challengeError) {
|
|
75
|
+
logger.error('Failed to generate challenge for session ID', challengeError);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
66
79
|
if (!sessionId) {
|
|
67
|
-
logger.error('Session ID not available');
|
|
80
|
+
logger.error('Session ID not available after attempting to generate');
|
|
68
81
|
throw new Error('VALIDATION_ERROR');
|
|
69
82
|
}
|
|
70
83
|
|
|
@@ -73,10 +86,17 @@ export const ProfilePictureCapture: React.FC<ProfilePictureCaptureProps> = ({
|
|
|
73
86
|
framesCount: videoResult.frames.length,
|
|
74
87
|
duration: videoResult.duration,
|
|
75
88
|
isUsingBackend,
|
|
89
|
+
hasVideoFrames: !!videoResult.frames,
|
|
90
|
+
videoFramesType: typeof videoResult.frames,
|
|
91
|
+
firstFrameLength: videoResult.frames?.[0]?.length || 0,
|
|
76
92
|
});
|
|
77
93
|
|
|
94
|
+
if (!videoResult.frames || videoResult.frames.length === 0) {
|
|
95
|
+
throw new Error('No video frames available for validation');
|
|
96
|
+
}
|
|
97
|
+
|
|
78
98
|
const result = await (sdk as any).validateProfilePicture({
|
|
79
|
-
sessionId
|
|
99
|
+
sessionId: sessionId!,
|
|
80
100
|
videoFrames: videoResult.frames,
|
|
81
101
|
videoDurationMs: videoResult.duration,
|
|
82
102
|
challengesCompleted: videoResult.challengesCompleted || [],
|
|
@@ -96,7 +116,14 @@ export const ProfilePictureCapture: React.FC<ProfilePictureCaptureProps> = ({
|
|
|
96
116
|
warnings: result.warnings || [],
|
|
97
117
|
};
|
|
98
118
|
} catch (error: any) {
|
|
99
|
-
logger.error('Profile picture validation error',
|
|
119
|
+
logger.error('Profile picture validation error', {
|
|
120
|
+
error,
|
|
121
|
+
errorMessage: error?.message,
|
|
122
|
+
errorName: error?.name,
|
|
123
|
+
errorCode: error?.code,
|
|
124
|
+
errorStack: error?.stack,
|
|
125
|
+
errorString: String(error),
|
|
126
|
+
});
|
|
100
127
|
throw error;
|
|
101
128
|
}
|
|
102
129
|
}, [isInitialized, isUsingBackend, sdk]);
|
|
@@ -190,6 +217,7 @@ export const ProfilePictureCapture: React.FC<ProfilePictureCaptureProps> = ({
|
|
|
190
217
|
language={language}
|
|
191
218
|
duration={8000}
|
|
192
219
|
smartMode={true}
|
|
220
|
+
sessionId={sdk.getSessionId() || undefined}
|
|
193
221
|
onComplete={handleVideoComplete}
|
|
194
222
|
onCancel={handleVideoCancel}
|
|
195
223
|
/>
|