@jupitermetalabs/face-zk-sdk 0.3.4 → 0.3.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.
- package/README.md +46 -1
- package/assets/face-guidance/pose-guidance.js.txt +4 -2
- package/assets/liveness/liveness.js.txt +3 -0
- package/dist/FaceZkSdk.d.ts +69 -0
- package/dist/FaceZkSdk.js +136 -0
- package/dist/assets/face-guidance/pose-guidance.js.txt +4 -2
- package/dist/assets/liveness/liveness.js.txt +3 -0
- package/dist/assets/onnx/ort-min.d.ts +1 -0
- package/dist/assets/onnx/ort-min.js +11 -0
- package/dist/config/defaults.d.ts +51 -0
- package/dist/config/defaults.js +61 -0
- package/dist/config/types.d.ts +169 -0
- package/dist/config/types.js +17 -0
- package/dist/core/enrollment-core.d.ts +70 -0
- package/dist/core/enrollment-core.js +206 -0
- package/dist/core/idGenerator.d.ts +11 -0
- package/dist/core/idGenerator.js +32 -0
- package/dist/core/matching.d.ts +69 -0
- package/dist/core/matching.js +101 -0
- package/dist/core/types.d.ts +379 -0
- package/dist/core/types.js +37 -0
- package/dist/core/verification-core.d.ts +120 -0
- package/dist/core/verification-core.js +442 -0
- package/dist/core/zk-core.d.ts +69 -0
- package/dist/core/zk-core.js +244 -0
- package/dist/index.d.ts +29 -0
- package/dist/index.js +51 -0
- package/dist/react-native/adapters/faceEmbeddingProvider.d.ts +38 -0
- package/dist/react-native/adapters/faceEmbeddingProvider.js +45 -0
- package/dist/react-native/adapters/imageDataProvider.d.ts +53 -0
- package/dist/react-native/adapters/imageDataProvider.js +134 -0
- package/dist/react-native/adapters/livenessProvider.d.ts +133 -0
- package/dist/react-native/adapters/livenessProvider.js +150 -0
- package/dist/react-native/adapters/zkProofEngine-webview.d.ts +73 -0
- package/dist/react-native/adapters/zkProofEngine-webview.js +135 -0
- package/dist/react-native/bundledRuntimeAssets.d.ts +39 -0
- package/dist/react-native/bundledRuntimeAssets.js +44 -0
- package/dist/react-native/components/FacePoseGuidanceWebView.d.ts +30 -0
- package/dist/react-native/components/FacePoseGuidanceWebView.js +530 -0
- package/dist/react-native/components/LivenessWebView.d.ts +39 -0
- package/dist/react-native/components/LivenessWebView.js +386 -0
- package/dist/react-native/components/OnnxRuntimeWebView.d.ts +58 -0
- package/dist/react-native/components/OnnxRuntimeWebView.js +518 -0
- package/dist/react-native/components/ZkProofWebView.d.ts +59 -0
- package/dist/react-native/components/ZkProofWebView.js +297 -0
- package/dist/react-native/dependencies.d.ts +144 -0
- package/dist/react-native/dependencies.js +130 -0
- package/dist/react-native/hooks/useOnnxLoader.d.ts +37 -0
- package/dist/react-native/hooks/useOnnxLoader.js +74 -0
- package/dist/react-native/hooks/useWasmLoader.d.ts +30 -0
- package/dist/react-native/hooks/useWasmLoader.js +158 -0
- package/dist/react-native/index.d.ts +61 -0
- package/dist/react-native/index.js +144 -0
- package/dist/react-native/services/FaceRecognition.d.ts +92 -0
- package/dist/react-native/services/FaceRecognition.js +674 -0
- package/dist/react-native/ui/FaceZkVerificationFlow.d.ts +97 -0
- package/dist/react-native/ui/FaceZkVerificationFlow.js +477 -0
- package/dist/react-native/ui/ReferenceEnrollmentFlow.d.ts +72 -0
- package/dist/react-native/ui/ReferenceEnrollmentFlow.js +369 -0
- package/dist/react-native/utils/faceAlignment.d.ts +37 -0
- package/dist/react-native/utils/faceAlignment.js +186 -0
- package/dist/react-native/utils/modelInitialisationChecks.d.ts +36 -0
- package/dist/react-native/utils/modelInitialisationChecks.js +128 -0
- package/dist/react-native/utils/resolveModelUri.d.ts +55 -0
- package/dist/react-native/utils/resolveModelUri.js +211 -0
- package/dist/react-native/utils/resolveRuntimeAsset.d.ts +25 -0
- package/dist/react-native/utils/resolveRuntimeAsset.js +94 -0
- package/dist/react-native/utils/resolveUiConfig.d.ts +41 -0
- package/dist/react-native/utils/resolveUiConfig.js +81 -0
- package/dist/storage/defaultStorageAdapter.d.ts +44 -0
- package/dist/storage/defaultStorageAdapter.js +344 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/face-zk.config.example.js +10 -3
- package/package.json +2 -2
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright 2026 JupiterMeta Labs
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.generateZkProofOnly = generateZkProofOnly;
|
|
19
|
+
exports.generateAndPersistZkProof = generateAndPersistZkProof;
|
|
20
|
+
/**
|
|
21
|
+
* Generate a zero-knowledge proof from embeddings without running the full verification pipeline.
|
|
22
|
+
*
|
|
23
|
+
* This function focuses strictly on the cryptographic generation mechanism using the provided ZK engine.
|
|
24
|
+
* It is designed for advanced integrations where the caller computes embeddings manually or handles their own camera lifecycles.
|
|
25
|
+
*
|
|
26
|
+
* **ZK Context:** Plonky3 WASM circuits enforce that the Euclidean distance between `referenceEmbedding` and `liveEmbedding` does not exceed the globally compiled threshold. If it does, proof generation fails cryptographically, returning a structured `ZK_ERROR`.
|
|
27
|
+
*
|
|
28
|
+
* @param {FloatVector} referenceEmbedding - Trusted reference face embedding.
|
|
29
|
+
* @param {FloatVector} liveEmbedding - Face embedding derived from the current live capture.
|
|
30
|
+
* @param {FaceZkRuntimeConfig} sdkConfig - Global SDK configuration requiring `zk.enabled = true` and an injected `zk.engine`.
|
|
31
|
+
* @param {ZkProofOptions} options - Options containing optional `nonce`. If missing, cryptographically secure nonce is auto-generated.
|
|
32
|
+
* @returns {Promise<ZkProofSummary>} Cryptographic proof, inputs, and the verified hash.
|
|
33
|
+
* @throws {SdkError} Throws `ZK_ERROR` if the embeddings do not meet the circuit threshold, if vectors mismatch, or if ZK is not enabled.
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* try {
|
|
37
|
+
* const summary = await generateZkProofOnly(refEmbed, liveEmbed, config, {});
|
|
38
|
+
* console.log(`Proof generated. Hash: ${summary.hash}`);
|
|
39
|
+
* } catch (error) {
|
|
40
|
+
* console.error("Proof failed (threshold not met):", error);
|
|
41
|
+
* }
|
|
42
|
+
*/
|
|
43
|
+
async function generateZkProofOnly(referenceEmbedding, liveEmbedding, sdkConfig, options) {
|
|
44
|
+
const { nonce } = options;
|
|
45
|
+
// Validate ZK is enabled
|
|
46
|
+
if (!sdkConfig.zk?.enabled) {
|
|
47
|
+
const error = {
|
|
48
|
+
code: "ZK_ERROR",
|
|
49
|
+
message: "ZK proof generation requested but ZK is not enabled in config",
|
|
50
|
+
details: { stage: "zk_validation" },
|
|
51
|
+
};
|
|
52
|
+
sdkConfig.onLog?.({
|
|
53
|
+
level: "error",
|
|
54
|
+
message: error.message,
|
|
55
|
+
context: error,
|
|
56
|
+
});
|
|
57
|
+
throw error;
|
|
58
|
+
}
|
|
59
|
+
// Validate embeddings
|
|
60
|
+
if (!referenceEmbedding || referenceEmbedding.length === 0) {
|
|
61
|
+
const error = {
|
|
62
|
+
code: "ZK_ERROR",
|
|
63
|
+
message: "Invalid reference embedding (empty or undefined)",
|
|
64
|
+
details: { stage: "zk_validation" },
|
|
65
|
+
};
|
|
66
|
+
sdkConfig.onLog?.({
|
|
67
|
+
level: "error",
|
|
68
|
+
message: error.message,
|
|
69
|
+
context: error,
|
|
70
|
+
});
|
|
71
|
+
throw error;
|
|
72
|
+
}
|
|
73
|
+
if (!liveEmbedding || liveEmbedding.length === 0) {
|
|
74
|
+
const error = {
|
|
75
|
+
code: "ZK_ERROR",
|
|
76
|
+
message: "Invalid live embedding (empty or undefined)",
|
|
77
|
+
details: { stage: "zk_validation" },
|
|
78
|
+
};
|
|
79
|
+
sdkConfig.onLog?.({
|
|
80
|
+
level: "error",
|
|
81
|
+
message: error.message,
|
|
82
|
+
context: error,
|
|
83
|
+
});
|
|
84
|
+
throw error;
|
|
85
|
+
}
|
|
86
|
+
if (referenceEmbedding.length !== liveEmbedding.length) {
|
|
87
|
+
const error = {
|
|
88
|
+
code: "ZK_ERROR",
|
|
89
|
+
message: `Embedding dimension mismatch: reference=${referenceEmbedding.length}, live=${liveEmbedding.length}`,
|
|
90
|
+
details: {
|
|
91
|
+
stage: "zk_validation",
|
|
92
|
+
referenceDim: referenceEmbedding.length,
|
|
93
|
+
liveDim: liveEmbedding.length,
|
|
94
|
+
},
|
|
95
|
+
};
|
|
96
|
+
sdkConfig.onLog?.({
|
|
97
|
+
level: "error",
|
|
98
|
+
message: error.message,
|
|
99
|
+
context: error,
|
|
100
|
+
});
|
|
101
|
+
throw error;
|
|
102
|
+
}
|
|
103
|
+
sdkConfig.onLog?.({
|
|
104
|
+
level: "info",
|
|
105
|
+
message: "Starting ZK proof generation",
|
|
106
|
+
context: {
|
|
107
|
+
embeddingDim: referenceEmbedding.length,
|
|
108
|
+
nonce,
|
|
109
|
+
},
|
|
110
|
+
});
|
|
111
|
+
try {
|
|
112
|
+
const startTime = Date.now();
|
|
113
|
+
// Step 1: Generate nonce if not provided (cryptographically secure)
|
|
114
|
+
const actualNonce = nonce ?? Math.floor(Math.random() * 0xFFFFFFFF);
|
|
115
|
+
sdkConfig.onLog?.({
|
|
116
|
+
level: "debug",
|
|
117
|
+
message: "Generating ZK proof via engine",
|
|
118
|
+
context: { nonce: actualNonce },
|
|
119
|
+
});
|
|
120
|
+
// Step 2: Generate proof
|
|
121
|
+
const { proof, publicInputs } = await sdkConfig.zk.engine.generateProof(referenceEmbedding, liveEmbedding, actualNonce);
|
|
122
|
+
const proofGenDuration = Date.now() - startTime;
|
|
123
|
+
sdkConfig.onLog?.({
|
|
124
|
+
level: "debug",
|
|
125
|
+
message: "Proof generated, now verifying",
|
|
126
|
+
context: {
|
|
127
|
+
proofSize: proof.length,
|
|
128
|
+
publicInputsCount: publicInputs.length,
|
|
129
|
+
durationMs: proofGenDuration,
|
|
130
|
+
},
|
|
131
|
+
});
|
|
132
|
+
// Step 3: Verify proof
|
|
133
|
+
const verifyStartTime = Date.now();
|
|
134
|
+
const verified = await sdkConfig.zk.engine.verifyProof(proof, publicInputs);
|
|
135
|
+
const verifyDuration = Date.now() - verifyStartTime;
|
|
136
|
+
sdkConfig.onLog?.({
|
|
137
|
+
level: "debug",
|
|
138
|
+
message: "Proof verification complete",
|
|
139
|
+
context: { verified, durationMs: verifyDuration },
|
|
140
|
+
});
|
|
141
|
+
// Step 4: Compute hash
|
|
142
|
+
const hashStartTime = Date.now();
|
|
143
|
+
const hash = await sdkConfig.zk.engine.getProofHash(proof);
|
|
144
|
+
const hashDuration = Date.now() - hashStartTime;
|
|
145
|
+
sdkConfig.onLog?.({
|
|
146
|
+
level: "debug",
|
|
147
|
+
message: "Proof hash computed",
|
|
148
|
+
context: { hash, durationMs: hashDuration },
|
|
149
|
+
});
|
|
150
|
+
// Step 5: Build summary
|
|
151
|
+
const summary = {
|
|
152
|
+
proof,
|
|
153
|
+
publicInputs,
|
|
154
|
+
hash,
|
|
155
|
+
verified,
|
|
156
|
+
timestamp: Date.now(),
|
|
157
|
+
sizeBytes: new TextEncoder().encode(proof).length,
|
|
158
|
+
};
|
|
159
|
+
const totalDuration = Date.now() - startTime;
|
|
160
|
+
sdkConfig.onLog?.({
|
|
161
|
+
level: "info",
|
|
162
|
+
message: "ZK proof generation complete",
|
|
163
|
+
context: {
|
|
164
|
+
verified,
|
|
165
|
+
hash,
|
|
166
|
+
sizeBytes: summary.sizeBytes,
|
|
167
|
+
totalDurationMs: totalDuration,
|
|
168
|
+
breakdown: {
|
|
169
|
+
generation: proofGenDuration,
|
|
170
|
+
verification: verifyDuration,
|
|
171
|
+
hashing: hashDuration,
|
|
172
|
+
},
|
|
173
|
+
},
|
|
174
|
+
});
|
|
175
|
+
return summary;
|
|
176
|
+
}
|
|
177
|
+
catch (error) {
|
|
178
|
+
const zkError = {
|
|
179
|
+
code: "ZK_ERROR",
|
|
180
|
+
message: error instanceof Error
|
|
181
|
+
? error.message
|
|
182
|
+
: "ZK proof generation failed with unknown error",
|
|
183
|
+
details: {
|
|
184
|
+
stage: "zk_generation",
|
|
185
|
+
originalError: String(error),
|
|
186
|
+
embeddingDim: referenceEmbedding.length,
|
|
187
|
+
},
|
|
188
|
+
};
|
|
189
|
+
sdkConfig.onLog?.({
|
|
190
|
+
level: "error",
|
|
191
|
+
message: "ZK proof generation failed",
|
|
192
|
+
context: zkError,
|
|
193
|
+
});
|
|
194
|
+
throw zkError;
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* Helper function to generate a ZK proof and persist it securely using the active `StorageAdapter`.
|
|
199
|
+
*
|
|
200
|
+
* **Crypto Context:** The proof is persisted only if local verification against the generated public inputs passes. Unverified proofs will not be persisted to prevent storage poisoning.
|
|
201
|
+
*
|
|
202
|
+
* @param {string} referenceId - The opaque ID linking this proof to the enrolled reference.
|
|
203
|
+
* @param {FloatVector} referenceEmbedding - Trusted reference face embedding.
|
|
204
|
+
* @param {FloatVector} liveEmbedding - Live face embedding.
|
|
205
|
+
* @param {FaceZkRuntimeConfig} sdkConfig - SDK configuration including the configured `storage` adapter.
|
|
206
|
+
* @param {ZkProofOptions} options - Options containing optional `nonce`.
|
|
207
|
+
* @returns {Promise<{ summary: ZkProofSummary; proofId?: string }>} The generated ZK summary, and the storage handle if successfully persisted.
|
|
208
|
+
*
|
|
209
|
+
* @example
|
|
210
|
+
* const { summary, proofId } = await generateAndPersistZkProof(
|
|
211
|
+
* 'user-1234', refEmbed, liveEmbed, config, {}
|
|
212
|
+
* );
|
|
213
|
+
* console.log(`Proof stored under handle: ${proofId}`);
|
|
214
|
+
*/
|
|
215
|
+
async function generateAndPersistZkProof(referenceId, referenceEmbedding, liveEmbedding, sdkConfig, options) {
|
|
216
|
+
// Generate proof
|
|
217
|
+
const summary = await generateZkProofOnly(referenceEmbedding, liveEmbedding, sdkConfig, options);
|
|
218
|
+
// Persist if storage adapter is available
|
|
219
|
+
let proofId;
|
|
220
|
+
if (sdkConfig.storage?.saveProof && summary.verified) {
|
|
221
|
+
sdkConfig.onLog?.({
|
|
222
|
+
level: "debug",
|
|
223
|
+
message: "Persisting ZK proof",
|
|
224
|
+
context: { referenceId, hash: summary.hash },
|
|
225
|
+
});
|
|
226
|
+
proofId = await sdkConfig.storage.saveProof({
|
|
227
|
+
referenceId,
|
|
228
|
+
zkProof: summary,
|
|
229
|
+
});
|
|
230
|
+
sdkConfig.onLog?.({
|
|
231
|
+
level: "info",
|
|
232
|
+
message: "ZK proof persisted",
|
|
233
|
+
context: { referenceId, proofId, hash: summary.hash },
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
else if (sdkConfig.storage?.saveProof && !summary.verified) {
|
|
237
|
+
sdkConfig.onLog?.({
|
|
238
|
+
level: "warn",
|
|
239
|
+
message: "Skipping persistence of unverified ZK proof",
|
|
240
|
+
context: { referenceId, verified: summary.verified },
|
|
241
|
+
});
|
|
242
|
+
}
|
|
243
|
+
return { summary, proofId };
|
|
244
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2026 JupiterMeta Labs
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*
|
|
16
|
+
* Face+ZK SDK – Core Exports
|
|
17
|
+
*
|
|
18
|
+
* Main entry point for the Face+ZK SDK core functionality.
|
|
19
|
+
* This provides headless (non-UI) APIs for face verification and ZK proofs.
|
|
20
|
+
*
|
|
21
|
+
* For React Native UI components, import from '@jupitermetalabs/face-zk-sdk/react-native'
|
|
22
|
+
*/
|
|
23
|
+
export { FaceZkSdk } from "./FaceZkSdk";
|
|
24
|
+
export type { FaceZkConfig, FaceZkModelsConfig, FaceZkFeaturesConfig, FaceZkSetupConfig, ModelSource, } from "./config/types";
|
|
25
|
+
export type { FloatVector, Pose, LivenessCheckId, ReferenceId, ReferenceTemplate, ReferenceTemplateInput, LiveImageInfo, LiveCaptureResult, LivenessCheckResult, LivenessResult, FaceMatchResult, ZkProofSummary, SdkErrorCode, SdkError, VerificationOutcome, LivenessConfig, ZkProofEngine, ZkConfig, StorageAdapter, ReferenceStorageRecord, ProofStorageRecord, SdkLogger, FaceZkRuntimeConfig, VerificationOptions, EnrollmentOptions, ZkProofOptions, VerificationStage, UiConfig, FaceZkTheme, FaceZkStrings, } from "./core/types";
|
|
26
|
+
export { l2SquaredDistance, l2SquaredToPercentage, computeFaceMatchResult, } from "./core/matching";
|
|
27
|
+
export { createReferenceFromImage, type FaceEmbeddingProvider, } from "./core/enrollment-core";
|
|
28
|
+
export { verifyOnly, verifyWithProof, type VerifyCallOptions, type LivenessProvider, } from "./core/verification-core";
|
|
29
|
+
export { generateZkProofOnly, generateAndPersistZkProof, } from "./core/zk-core";
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright 2026 JupiterMeta Labs
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*
|
|
17
|
+
* Face+ZK SDK – Core Exports
|
|
18
|
+
*
|
|
19
|
+
* Main entry point for the Face+ZK SDK core functionality.
|
|
20
|
+
* This provides headless (non-UI) APIs for face verification and ZK proofs.
|
|
21
|
+
*
|
|
22
|
+
* For React Native UI components, import from '@jupitermetalabs/face-zk-sdk/react-native'
|
|
23
|
+
*/
|
|
24
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
+
exports.generateAndPersistZkProof = exports.generateZkProofOnly = exports.verifyWithProof = exports.verifyOnly = exports.createReferenceFromImage = exports.computeFaceMatchResult = exports.l2SquaredToPercentage = exports.l2SquaredDistance = exports.FaceZkSdk = void 0;
|
|
26
|
+
// ============================================================================
|
|
27
|
+
// SDK Initialization
|
|
28
|
+
// ============================================================================
|
|
29
|
+
var FaceZkSdk_1 = require("./FaceZkSdk");
|
|
30
|
+
Object.defineProperty(exports, "FaceZkSdk", { enumerable: true, get: function () { return FaceZkSdk_1.FaceZkSdk; } });
|
|
31
|
+
// ============================================================================
|
|
32
|
+
// Matching Functions
|
|
33
|
+
// ============================================================================
|
|
34
|
+
var matching_1 = require("./core/matching");
|
|
35
|
+
Object.defineProperty(exports, "l2SquaredDistance", { enumerable: true, get: function () { return matching_1.l2SquaredDistance; } });
|
|
36
|
+
Object.defineProperty(exports, "l2SquaredToPercentage", { enumerable: true, get: function () { return matching_1.l2SquaredToPercentage; } });
|
|
37
|
+
Object.defineProperty(exports, "computeFaceMatchResult", { enumerable: true, get: function () { return matching_1.computeFaceMatchResult; } });
|
|
38
|
+
// ============================================================================
|
|
39
|
+
// Core Entrypoints
|
|
40
|
+
// ============================================================================
|
|
41
|
+
// Enrollment
|
|
42
|
+
var enrollment_core_1 = require("./core/enrollment-core");
|
|
43
|
+
Object.defineProperty(exports, "createReferenceFromImage", { enumerable: true, get: function () { return enrollment_core_1.createReferenceFromImage; } });
|
|
44
|
+
// Verification
|
|
45
|
+
var verification_core_1 = require("./core/verification-core");
|
|
46
|
+
Object.defineProperty(exports, "verifyOnly", { enumerable: true, get: function () { return verification_core_1.verifyOnly; } });
|
|
47
|
+
Object.defineProperty(exports, "verifyWithProof", { enumerable: true, get: function () { return verification_core_1.verifyWithProof; } });
|
|
48
|
+
// ZK Proofs
|
|
49
|
+
var zk_core_1 = require("./core/zk-core");
|
|
50
|
+
Object.defineProperty(exports, "generateZkProofOnly", { enumerable: true, get: function () { return zk_core_1.generateZkProofOnly; } });
|
|
51
|
+
Object.defineProperty(exports, "generateAndPersistZkProof", { enumerable: true, get: function () { return zk_core_1.generateAndPersistZkProof; } });
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2026 JupiterMeta Labs
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
/**
|
|
17
|
+
* Face Embedding Provider Adapter for React Native
|
|
18
|
+
*
|
|
19
|
+
* Wraps the existing faceRecognitionService to implement the FaceEmbeddingProvider interface.
|
|
20
|
+
* This adapter bridges the SDK core logic to the platform-specific implementation.
|
|
21
|
+
*/
|
|
22
|
+
import type { FaceEmbeddingProvider } from "../../core/enrollment-core";
|
|
23
|
+
/**
|
|
24
|
+
* Create a face embedding provider that wraps faceRecognitionService.
|
|
25
|
+
*
|
|
26
|
+
* This adapter:
|
|
27
|
+
* - Implements the FaceEmbeddingProvider interface
|
|
28
|
+
* - Delegates to faceRecognitionService.processImageForEmbedding()
|
|
29
|
+
* - Guarantees embedding + pose are returned on success
|
|
30
|
+
*
|
|
31
|
+
* @returns FaceEmbeddingProvider implementation
|
|
32
|
+
*/
|
|
33
|
+
export declare function createFaceEmbeddingProvider(): FaceEmbeddingProvider;
|
|
34
|
+
/**
|
|
35
|
+
* Singleton instance for convenience.
|
|
36
|
+
* Use this if you don't need custom configuration.
|
|
37
|
+
*/
|
|
38
|
+
export declare const defaultFaceEmbeddingProvider: FaceEmbeddingProvider;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright 2026 JupiterMeta Labs
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.defaultFaceEmbeddingProvider = void 0;
|
|
19
|
+
exports.createFaceEmbeddingProvider = createFaceEmbeddingProvider;
|
|
20
|
+
const FaceRecognition_1 = require("../services/FaceRecognition");
|
|
21
|
+
/**
|
|
22
|
+
* Create a face embedding provider that wraps faceRecognitionService.
|
|
23
|
+
*
|
|
24
|
+
* This adapter:
|
|
25
|
+
* - Implements the FaceEmbeddingProvider interface
|
|
26
|
+
* - Delegates to faceRecognitionService.processImageForEmbedding()
|
|
27
|
+
* - Guarantees embedding + pose are returned on success
|
|
28
|
+
*
|
|
29
|
+
* @returns FaceEmbeddingProvider implementation
|
|
30
|
+
*/
|
|
31
|
+
function createFaceEmbeddingProvider() {
|
|
32
|
+
return {
|
|
33
|
+
async processImageForEmbedding(imageUri) {
|
|
34
|
+
// Delegate to existing service
|
|
35
|
+
const result = await FaceRecognition_1.faceRecognitionService.processImageForEmbedding(imageUri);
|
|
36
|
+
// Return result as-is (it already matches the expected format)
|
|
37
|
+
return result;
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Singleton instance for convenience.
|
|
43
|
+
* Use this if you don't need custom configuration.
|
|
44
|
+
*/
|
|
45
|
+
exports.defaultFaceEmbeddingProvider = createFaceEmbeddingProvider();
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2026 JupiterMeta Labs
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
/**
|
|
17
|
+
* Image Data Provider Adapter for React Native
|
|
18
|
+
*
|
|
19
|
+
* Provides platform-specific image data reading capabilities (base64, file size).
|
|
20
|
+
* This keeps the SDK core framework-agnostic while providing necessary functionality.
|
|
21
|
+
*/
|
|
22
|
+
import type { ImageDataProvider } from "../../core/verification-core";
|
|
23
|
+
/**
|
|
24
|
+
* Create an image data provider using Expo FileSystem.
|
|
25
|
+
*
|
|
26
|
+
* This adapter implements base64 reading and file size retrieval
|
|
27
|
+
* for React Native / Expo environments.
|
|
28
|
+
*
|
|
29
|
+
* @returns ImageDataProvider implementation for React Native
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* ```typescript
|
|
33
|
+
* import { createDefaultImageDataProvider } from './sdk/react-native/adapters/imageDataProvider';
|
|
34
|
+
*
|
|
35
|
+
* const imageDataProvider = createDefaultImageDataProvider();
|
|
36
|
+
*
|
|
37
|
+
* // Use in verification
|
|
38
|
+
* const outcome = await verifyOnly(
|
|
39
|
+
* reference,
|
|
40
|
+
* liveImageUri,
|
|
41
|
+
* sdkConfig,
|
|
42
|
+
* embeddingProvider,
|
|
43
|
+
* livenessProvider,
|
|
44
|
+
* imageDataProvider, // <-- enables base64/sizeKb
|
|
45
|
+
* { includeImageData: { base64: true, sizeKb: true } },
|
|
46
|
+
* );
|
|
47
|
+
* ```
|
|
48
|
+
*/
|
|
49
|
+
export declare function createDefaultImageDataProvider(): ImageDataProvider;
|
|
50
|
+
/**
|
|
51
|
+
* Default singleton instance for convenience.
|
|
52
|
+
*/
|
|
53
|
+
export declare const defaultImageDataProvider: ImageDataProvider;
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright 2026 JupiterMeta Labs
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
18
|
+
if (k2 === undefined) k2 = k;
|
|
19
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
20
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
21
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
22
|
+
}
|
|
23
|
+
Object.defineProperty(o, k2, desc);
|
|
24
|
+
}) : (function(o, m, k, k2) {
|
|
25
|
+
if (k2 === undefined) k2 = k;
|
|
26
|
+
o[k2] = m[k];
|
|
27
|
+
}));
|
|
28
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
29
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
30
|
+
}) : function(o, v) {
|
|
31
|
+
o["default"] = v;
|
|
32
|
+
});
|
|
33
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
34
|
+
var ownKeys = function(o) {
|
|
35
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
36
|
+
var ar = [];
|
|
37
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
38
|
+
return ar;
|
|
39
|
+
};
|
|
40
|
+
return ownKeys(o);
|
|
41
|
+
};
|
|
42
|
+
return function (mod) {
|
|
43
|
+
if (mod && mod.__esModule) return mod;
|
|
44
|
+
var result = {};
|
|
45
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
46
|
+
__setModuleDefault(result, mod);
|
|
47
|
+
return result;
|
|
48
|
+
};
|
|
49
|
+
})();
|
|
50
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
51
|
+
exports.defaultImageDataProvider = void 0;
|
|
52
|
+
exports.createDefaultImageDataProvider = createDefaultImageDataProvider;
|
|
53
|
+
const FileSystem = __importStar(require("expo-file-system/legacy"));
|
|
54
|
+
/**
|
|
55
|
+
* Create an image data provider using Expo FileSystem.
|
|
56
|
+
*
|
|
57
|
+
* This adapter implements base64 reading and file size retrieval
|
|
58
|
+
* for React Native / Expo environments.
|
|
59
|
+
*
|
|
60
|
+
* @returns ImageDataProvider implementation for React Native
|
|
61
|
+
*
|
|
62
|
+
* @example
|
|
63
|
+
* ```typescript
|
|
64
|
+
* import { createDefaultImageDataProvider } from './sdk/react-native/adapters/imageDataProvider';
|
|
65
|
+
*
|
|
66
|
+
* const imageDataProvider = createDefaultImageDataProvider();
|
|
67
|
+
*
|
|
68
|
+
* // Use in verification
|
|
69
|
+
* const outcome = await verifyOnly(
|
|
70
|
+
* reference,
|
|
71
|
+
* liveImageUri,
|
|
72
|
+
* sdkConfig,
|
|
73
|
+
* embeddingProvider,
|
|
74
|
+
* livenessProvider,
|
|
75
|
+
* imageDataProvider, // <-- enables base64/sizeKb
|
|
76
|
+
* { includeImageData: { base64: true, sizeKb: true } },
|
|
77
|
+
* );
|
|
78
|
+
* ```
|
|
79
|
+
*/
|
|
80
|
+
function createDefaultImageDataProvider() {
|
|
81
|
+
return {
|
|
82
|
+
async readAsBase64(imageUri) {
|
|
83
|
+
try {
|
|
84
|
+
const base64 = await FileSystem.readAsStringAsync(imageUri, {
|
|
85
|
+
encoding: FileSystem.EncodingType.Base64,
|
|
86
|
+
});
|
|
87
|
+
return base64;
|
|
88
|
+
}
|
|
89
|
+
catch (error) {
|
|
90
|
+
throw new Error(`Failed to read image as base64: ${error instanceof Error ? error.message : String(error)}`);
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
async getFileSizeBytes(imageUri) {
|
|
94
|
+
try {
|
|
95
|
+
const fileInfo = await FileSystem.getInfoAsync(imageUri);
|
|
96
|
+
if (!fileInfo.exists) {
|
|
97
|
+
throw new Error(`File does not exist: ${imageUri}`);
|
|
98
|
+
}
|
|
99
|
+
// getInfoAsync returns { exists, uri, size?, ... }
|
|
100
|
+
if ("size" in fileInfo && typeof fileInfo.size === "number") {
|
|
101
|
+
return fileInfo.size;
|
|
102
|
+
}
|
|
103
|
+
throw new Error(`File size not available for: ${imageUri}`);
|
|
104
|
+
}
|
|
105
|
+
catch (error) {
|
|
106
|
+
throw new Error(`Failed to get file size: ${error instanceof Error ? error.message : String(error)}`);
|
|
107
|
+
}
|
|
108
|
+
},
|
|
109
|
+
async analyzeQuality(imageUri) {
|
|
110
|
+
// Quality is estimated from file size — a practical proxy for face image
|
|
111
|
+
// fidelity without requiring additional image-processing dependencies.
|
|
112
|
+
// Thresholds are calibrated for compressed JPEG face captures:
|
|
113
|
+
// < 5 KB → heavily compressed / thumbnail → score near 0
|
|
114
|
+
// ≥ 200 KB → high-detail capture → score near 1
|
|
115
|
+
const MIN_BYTES = 5_000;
|
|
116
|
+
const MAX_BYTES = 200_000;
|
|
117
|
+
try {
|
|
118
|
+
const fileInfo = await FileSystem.getInfoAsync(imageUri);
|
|
119
|
+
if (!fileInfo.exists || !("size" in fileInfo) || typeof fileInfo.size !== "number") {
|
|
120
|
+
return 0;
|
|
121
|
+
}
|
|
122
|
+
const clamped = Math.max(MIN_BYTES, Math.min(MAX_BYTES, fileInfo.size));
|
|
123
|
+
return Math.round(((clamped - MIN_BYTES) / (MAX_BYTES - MIN_BYTES)) * 100) / 100;
|
|
124
|
+
}
|
|
125
|
+
catch {
|
|
126
|
+
return 0;
|
|
127
|
+
}
|
|
128
|
+
},
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Default singleton instance for convenience.
|
|
133
|
+
*/
|
|
134
|
+
exports.defaultImageDataProvider = createDefaultImageDataProvider();
|