@hexar/biometric-identity-sdk-react-native 1.0.0
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 +68 -0
- package/dist/components/BiometricIdentityFlow.d.ts +17 -0
- package/dist/components/BiometricIdentityFlow.d.ts.map +1 -0
- package/dist/components/BiometricIdentityFlow.js +366 -0
- package/dist/components/CameraCapture.d.ts +15 -0
- package/dist/components/CameraCapture.d.ts.map +1 -0
- package/dist/components/CameraCapture.js +238 -0
- package/dist/components/ErrorScreen.d.ts +15 -0
- package/dist/components/ErrorScreen.d.ts.map +1 -0
- package/dist/components/ErrorScreen.js +142 -0
- package/dist/components/InstructionsScreen.d.ts +14 -0
- package/dist/components/InstructionsScreen.d.ts.map +1 -0
- package/dist/components/InstructionsScreen.js +181 -0
- package/dist/components/ResultScreen.d.ts +15 -0
- package/dist/components/ResultScreen.d.ts.map +1 -0
- package/dist/components/ResultScreen.js +182 -0
- package/dist/components/ValidationProgress.d.ts +14 -0
- package/dist/components/ValidationProgress.d.ts.map +1 -0
- package/dist/components/ValidationProgress.js +143 -0
- package/dist/components/VideoRecorder.d.ts +43 -0
- package/dist/components/VideoRecorder.d.ts.map +1 -0
- package/dist/components/VideoRecorder.js +631 -0
- package/dist/hooks/useBiometricSDK.d.ts +25 -0
- package/dist/hooks/useBiometricSDK.d.ts.map +1 -0
- package/dist/hooks/useBiometricSDK.js +173 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +47 -0
- package/package.json +27 -0
- package/src/components/BiometricIdentityFlow.tsx +557 -0
- package/src/components/CameraCapture.tsx +262 -0
- package/src/components/ErrorScreen.tsx +201 -0
- package/src/components/InstructionsScreen.tsx +269 -0
- package/src/components/ResultScreen.tsx +301 -0
- package/src/components/ValidationProgress.tsx +223 -0
- package/src/components/VideoRecorder.tsx +794 -0
- package/src/hooks/useBiometricSDK.ts +230 -0
- package/src/index.ts +24 -0
- package/tsconfig.json +20 -0
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useBiometricSDK = void 0;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
const biometric_identity_sdk_core_1 = require("@hexar/biometric-identity-sdk-core");
|
|
6
|
+
const useBiometricSDK = () => {
|
|
7
|
+
const [sdk] = (0, react_1.useState)(() => biometric_identity_sdk_core_1.BiometricIdentitySDK.createSession());
|
|
8
|
+
const [state, setState] = (0, react_1.useState)(sdk.getState());
|
|
9
|
+
const [isInitialized, setIsInitialized] = (0, react_1.useState)(false);
|
|
10
|
+
const [challenges, setChallenges] = (0, react_1.useState)([]);
|
|
11
|
+
const isMounted = (0, react_1.useRef)(true);
|
|
12
|
+
(0, react_1.useEffect)(() => {
|
|
13
|
+
isMounted.current = true;
|
|
14
|
+
const init = async () => {
|
|
15
|
+
try {
|
|
16
|
+
await sdk.initialize();
|
|
17
|
+
if (isMounted.current) {
|
|
18
|
+
setIsInitialized(true);
|
|
19
|
+
setState(sdk.getState());
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
catch (error) {
|
|
23
|
+
console.error('SDK initialization failed:', error);
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
init();
|
|
27
|
+
return () => {
|
|
28
|
+
isMounted.current = false;
|
|
29
|
+
sdk.dispose();
|
|
30
|
+
};
|
|
31
|
+
}, [sdk]);
|
|
32
|
+
// Poll state updates while loading
|
|
33
|
+
(0, react_1.useEffect)(() => {
|
|
34
|
+
if (!state.isLoading)
|
|
35
|
+
return;
|
|
36
|
+
const interval = setInterval(() => {
|
|
37
|
+
if (isMounted.current) {
|
|
38
|
+
setState(sdk.getState());
|
|
39
|
+
}
|
|
40
|
+
}, 100);
|
|
41
|
+
return () => clearInterval(interval);
|
|
42
|
+
}, [sdk, state.isLoading]);
|
|
43
|
+
/**
|
|
44
|
+
* Fetch liveness challenges from backend
|
|
45
|
+
*/
|
|
46
|
+
const fetchChallenges = (0, react_1.useCallback)(async (type = 'active') => {
|
|
47
|
+
try {
|
|
48
|
+
const response = await sdk.generateLivenessChallenge(type);
|
|
49
|
+
if (response && response.challenges) {
|
|
50
|
+
const challengeActions = response.challenges.map(c => ({
|
|
51
|
+
action: c.action,
|
|
52
|
+
instruction: c.instruction,
|
|
53
|
+
duration_ms: c.duration_ms,
|
|
54
|
+
order: c.order,
|
|
55
|
+
}));
|
|
56
|
+
setChallenges(challengeActions);
|
|
57
|
+
return challengeActions;
|
|
58
|
+
}
|
|
59
|
+
// Return default challenges if backend not available
|
|
60
|
+
const defaultChallenges = sdk.getDefaultChallenges().map(c => ({
|
|
61
|
+
action: c.action,
|
|
62
|
+
instruction: c.instruction,
|
|
63
|
+
duration_ms: c.duration_ms,
|
|
64
|
+
order: c.order,
|
|
65
|
+
}));
|
|
66
|
+
setChallenges(defaultChallenges);
|
|
67
|
+
return defaultChallenges;
|
|
68
|
+
}
|
|
69
|
+
catch (error) {
|
|
70
|
+
console.error('Failed to fetch challenges:', error);
|
|
71
|
+
const defaultChallenges = sdk.getDefaultChallenges().map(c => ({
|
|
72
|
+
action: c.action,
|
|
73
|
+
instruction: c.instruction,
|
|
74
|
+
duration_ms: c.duration_ms,
|
|
75
|
+
order: c.order,
|
|
76
|
+
}));
|
|
77
|
+
setChallenges(defaultChallenges);
|
|
78
|
+
return defaultChallenges;
|
|
79
|
+
}
|
|
80
|
+
}, [sdk]);
|
|
81
|
+
/**
|
|
82
|
+
* Upload front ID image
|
|
83
|
+
*/
|
|
84
|
+
const uploadFrontID = (0, react_1.useCallback)(async (imageData) => {
|
|
85
|
+
await sdk.uploadFrontID(imageData);
|
|
86
|
+
if (isMounted.current) {
|
|
87
|
+
setState(sdk.getState());
|
|
88
|
+
}
|
|
89
|
+
}, [sdk]);
|
|
90
|
+
/**
|
|
91
|
+
* Upload back ID image
|
|
92
|
+
*/
|
|
93
|
+
const uploadBackID = (0, react_1.useCallback)(async (imageData) => {
|
|
94
|
+
await sdk.uploadBackID(imageData);
|
|
95
|
+
if (isMounted.current) {
|
|
96
|
+
setState(sdk.getState());
|
|
97
|
+
}
|
|
98
|
+
}, [sdk]);
|
|
99
|
+
/**
|
|
100
|
+
* Store video recording result
|
|
101
|
+
*/
|
|
102
|
+
const storeVideoRecording = (0, react_1.useCallback)(async (videoData) => {
|
|
103
|
+
// Add session ID if using backend
|
|
104
|
+
const sessionId = sdk.getSessionId();
|
|
105
|
+
if (sessionId) {
|
|
106
|
+
videoData.sessionId = sessionId;
|
|
107
|
+
}
|
|
108
|
+
await sdk.storeVideoRecording(videoData);
|
|
109
|
+
if (isMounted.current) {
|
|
110
|
+
setState(sdk.getState());
|
|
111
|
+
}
|
|
112
|
+
}, [sdk]);
|
|
113
|
+
/**
|
|
114
|
+
* Legacy: Record video (for backwards compatibility)
|
|
115
|
+
*/
|
|
116
|
+
const recordVideo = (0, react_1.useCallback)(async (videoData) => {
|
|
117
|
+
if (videoData) {
|
|
118
|
+
await storeVideoRecording(videoData);
|
|
119
|
+
}
|
|
120
|
+
else {
|
|
121
|
+
// Mock video result for backwards compatibility
|
|
122
|
+
const mockVideoResult = {
|
|
123
|
+
frames: Array.from({ length: 80 }, (_, i) => `frame_${i}_base64`),
|
|
124
|
+
duration: 8000,
|
|
125
|
+
instructionsFollowed: true,
|
|
126
|
+
qualityScore: 85,
|
|
127
|
+
challengesCompleted: challenges.map(c => c.action),
|
|
128
|
+
sessionId: sdk.getSessionId() || undefined,
|
|
129
|
+
};
|
|
130
|
+
await sdk.storeVideoRecording(mockVideoResult);
|
|
131
|
+
}
|
|
132
|
+
if (isMounted.current) {
|
|
133
|
+
setState(sdk.getState());
|
|
134
|
+
}
|
|
135
|
+
}, [sdk, storeVideoRecording, challenges]);
|
|
136
|
+
/**
|
|
137
|
+
* Validate identity with all collected data
|
|
138
|
+
*/
|
|
139
|
+
const validateIdentity = (0, react_1.useCallback)(async () => {
|
|
140
|
+
const result = await sdk.validateIdentity();
|
|
141
|
+
if (isMounted.current) {
|
|
142
|
+
setState(sdk.getState());
|
|
143
|
+
}
|
|
144
|
+
return result;
|
|
145
|
+
}, [sdk]);
|
|
146
|
+
/**
|
|
147
|
+
* Reset SDK state
|
|
148
|
+
*/
|
|
149
|
+
const reset = (0, react_1.useCallback)(() => {
|
|
150
|
+
sdk.reset();
|
|
151
|
+
setChallenges([]);
|
|
152
|
+
if (isMounted.current) {
|
|
153
|
+
setState(sdk.getState());
|
|
154
|
+
}
|
|
155
|
+
}, [sdk]);
|
|
156
|
+
return {
|
|
157
|
+
sdk,
|
|
158
|
+
state,
|
|
159
|
+
isInitialized,
|
|
160
|
+
isUsingBackend: sdk.isUsingBackend(),
|
|
161
|
+
sessionId: sdk.getSessionId(),
|
|
162
|
+
challenges,
|
|
163
|
+
uploadFrontID,
|
|
164
|
+
uploadBackID,
|
|
165
|
+
storeVideoRecording,
|
|
166
|
+
fetchChallenges,
|
|
167
|
+
validateIdentity,
|
|
168
|
+
reset,
|
|
169
|
+
recordVideo,
|
|
170
|
+
};
|
|
171
|
+
};
|
|
172
|
+
exports.useBiometricSDK = useBiometricSDK;
|
|
173
|
+
exports.default = exports.useBiometricSDK;
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* React Native Biometric Identity SDK
|
|
3
|
+
* Main entry point
|
|
4
|
+
*/
|
|
5
|
+
export { BiometricIdentityFlow } from './components/BiometricIdentityFlow';
|
|
6
|
+
export { default } from './components/BiometricIdentityFlow';
|
|
7
|
+
export { CameraCapture } from './components/CameraCapture';
|
|
8
|
+
export { VideoRecorder } from './components/VideoRecorder';
|
|
9
|
+
export { ValidationProgress } from './components/ValidationProgress';
|
|
10
|
+
export { ResultScreen } from './components/ResultScreen';
|
|
11
|
+
export { ErrorScreen } from './components/ErrorScreen';
|
|
12
|
+
export { InstructionsScreen } from './components/InstructionsScreen';
|
|
13
|
+
export { useBiometricSDK } from './hooks/useBiometricSDK';
|
|
14
|
+
export * from '@hexar/biometric-identity-sdk-core';
|
|
15
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,qBAAqB,EAAE,MAAM,oCAAoC,CAAC;AAC3E,OAAO,EAAE,OAAO,EAAE,MAAM,oCAAoC,CAAC;AAG7D,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AACrE,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AAGrE,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAG1D,cAAc,oCAAoC,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* React Native Biometric Identity SDK
|
|
4
|
+
* Main entry point
|
|
5
|
+
*/
|
|
6
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
7
|
+
if (k2 === undefined) k2 = k;
|
|
8
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
9
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
10
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
11
|
+
}
|
|
12
|
+
Object.defineProperty(o, k2, desc);
|
|
13
|
+
}) : (function(o, m, k, k2) {
|
|
14
|
+
if (k2 === undefined) k2 = k;
|
|
15
|
+
o[k2] = m[k];
|
|
16
|
+
}));
|
|
17
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
18
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
19
|
+
};
|
|
20
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
21
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
22
|
+
};
|
|
23
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24
|
+
exports.useBiometricSDK = exports.InstructionsScreen = exports.ErrorScreen = exports.ResultScreen = exports.ValidationProgress = exports.VideoRecorder = exports.CameraCapture = exports.default = exports.BiometricIdentityFlow = void 0;
|
|
25
|
+
// Main component
|
|
26
|
+
var BiometricIdentityFlow_1 = require("./components/BiometricIdentityFlow");
|
|
27
|
+
Object.defineProperty(exports, "BiometricIdentityFlow", { enumerable: true, get: function () { return BiometricIdentityFlow_1.BiometricIdentityFlow; } });
|
|
28
|
+
var BiometricIdentityFlow_2 = require("./components/BiometricIdentityFlow");
|
|
29
|
+
Object.defineProperty(exports, "default", { enumerable: true, get: function () { return __importDefault(BiometricIdentityFlow_2).default; } });
|
|
30
|
+
// Individual components (for custom implementations)
|
|
31
|
+
var CameraCapture_1 = require("./components/CameraCapture");
|
|
32
|
+
Object.defineProperty(exports, "CameraCapture", { enumerable: true, get: function () { return CameraCapture_1.CameraCapture; } });
|
|
33
|
+
var VideoRecorder_1 = require("./components/VideoRecorder");
|
|
34
|
+
Object.defineProperty(exports, "VideoRecorder", { enumerable: true, get: function () { return VideoRecorder_1.VideoRecorder; } });
|
|
35
|
+
var ValidationProgress_1 = require("./components/ValidationProgress");
|
|
36
|
+
Object.defineProperty(exports, "ValidationProgress", { enumerable: true, get: function () { return ValidationProgress_1.ValidationProgress; } });
|
|
37
|
+
var ResultScreen_1 = require("./components/ResultScreen");
|
|
38
|
+
Object.defineProperty(exports, "ResultScreen", { enumerable: true, get: function () { return ResultScreen_1.ResultScreen; } });
|
|
39
|
+
var ErrorScreen_1 = require("./components/ErrorScreen");
|
|
40
|
+
Object.defineProperty(exports, "ErrorScreen", { enumerable: true, get: function () { return ErrorScreen_1.ErrorScreen; } });
|
|
41
|
+
var InstructionsScreen_1 = require("./components/InstructionsScreen");
|
|
42
|
+
Object.defineProperty(exports, "InstructionsScreen", { enumerable: true, get: function () { return InstructionsScreen_1.InstructionsScreen; } });
|
|
43
|
+
// Hooks
|
|
44
|
+
var useBiometricSDK_1 = require("./hooks/useBiometricSDK");
|
|
45
|
+
Object.defineProperty(exports, "useBiometricSDK", { enumerable: true, get: function () { return useBiometricSDK_1.useBiometricSDK; } });
|
|
46
|
+
// Re-export core types
|
|
47
|
+
__exportStar(require("@hexar/biometric-identity-sdk-core"), exports);
|
package/package.json
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@hexar/biometric-identity-sdk-react-native",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "React Native wrapper for Biometric Identity SDK",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"private": false,
|
|
8
|
+
"scripts": {
|
|
9
|
+
"build": "tsc",
|
|
10
|
+
"dev": "tsc --watch",
|
|
11
|
+
"clean": "rm -rf dist"
|
|
12
|
+
},
|
|
13
|
+
"peerDependencies": {
|
|
14
|
+
"react": ">=18.0.0",
|
|
15
|
+
"react-native": ">=0.70.0",
|
|
16
|
+
"react-native-permissions": "^4.0.0",
|
|
17
|
+
"react-native-vision-camera": "^4.0.0"
|
|
18
|
+
},
|
|
19
|
+
"dependencies": {
|
|
20
|
+
"@hexar/biometric-identity-sdk-core": "file:../core"
|
|
21
|
+
},
|
|
22
|
+
"devDependencies": {
|
|
23
|
+
"@types/react": "^19.0.0",
|
|
24
|
+
"@types/react-native": "^0.73.0",
|
|
25
|
+
"typescript": "^5.3.3"
|
|
26
|
+
}
|
|
27
|
+
}
|