solana-age-verify-sdk 2.0.0-beta.2

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.
Files changed (47) hide show
  1. package/README.md +185 -0
  2. package/dist/adapters/blazeface.d.ts +15 -0
  3. package/dist/adapters/blazeface.js +258 -0
  4. package/dist/adapters/mediapipe.d.ts +7 -0
  5. package/dist/adapters/mediapipe.js +55 -0
  6. package/dist/adapters/onnx.d.ts +10 -0
  7. package/dist/adapters/onnx.js +171 -0
  8. package/dist/camera.d.ts +15 -0
  9. package/dist/camera.js +76 -0
  10. package/dist/embedding/descriptor.d.ts +22 -0
  11. package/dist/embedding/descriptor.js +134 -0
  12. package/dist/hashing/facehash.d.ts +3 -0
  13. package/dist/hashing/facehash.js +27 -0
  14. package/dist/hashing/webcrypto.d.ts +1 -0
  15. package/dist/hashing/webcrypto.js +1 -0
  16. package/dist/index.d.ts +6 -0
  17. package/dist/index.js +7 -0
  18. package/dist/liveness/challenges.d.ts +3 -0
  19. package/dist/liveness/challenges.js +34 -0
  20. package/dist/liveness/scorer.d.ts +1 -0
  21. package/dist/liveness/scorer.js +3 -0
  22. package/dist/liveness/texture.d.ts +72 -0
  23. package/dist/liveness/texture.js +266 -0
  24. package/dist/types.d.ts +86 -0
  25. package/dist/types.js +9 -0
  26. package/dist/verify.d.ts +4 -0
  27. package/dist/verify.js +892 -0
  28. package/dist/worker/frame.d.ts +5 -0
  29. package/dist/worker/frame.js +1 -0
  30. package/dist/worker/infer.d.ts +4 -0
  31. package/dist/worker/infer.js +22 -0
  32. package/dist/worker/worker.d.ts +0 -0
  33. package/dist/worker/worker.js +61 -0
  34. package/package.json +46 -0
  35. package/public/models/age_gender.onnx +1446 -0
  36. package/public/models/age_gender_model-weights_manifest.json +62 -0
  37. package/public/models/age_gender_model.shard1 +1447 -0
  38. package/public/models/face_landmark_68_model-weights_manifest.json +60 -0
  39. package/public/models/face_landmark_68_model.shard1 +1447 -0
  40. package/public/models/face_recognition_model-weights_manifest.json +128 -0
  41. package/public/models/face_recognition_model.shard1 +1447 -0
  42. package/public/models/face_recognition_model.shard2 +1447 -0
  43. package/public/models/ort-wasm-simd-threaded.asyncify.wasm +0 -0
  44. package/public/models/ort-wasm-simd-threaded.jsep.wasm +0 -0
  45. package/public/models/ort-wasm-simd-threaded.wasm +0 -0
  46. package/public/models/tiny_face_detector_model-weights_manifest.json +30 -0
  47. package/public/models/tiny_face_detector_model.shard1 +1447 -0
@@ -0,0 +1,5 @@
1
+ export interface Frame {
2
+ data: Uint8Array;
3
+ width: number;
4
+ height: number;
5
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,4 @@
1
+ import { Frame } from './frame';
2
+ import { DetectionResult } from '../types';
3
+ export declare function loadModels(basePath?: string): Promise<void>;
4
+ export declare function infer(frame: Frame): Promise<DetectionResult>;
@@ -0,0 +1,22 @@
1
+ import { BlazeFaceAdapter } from '../adapters/blazeface';
2
+ const adapter = new BlazeFaceAdapter();
3
+ let isLoaded = false;
4
+ export async function loadModels(basePath) {
5
+ if (!isLoaded) {
6
+ await adapter.load(basePath);
7
+ isLoaded = true;
8
+ }
9
+ }
10
+ export async function infer(frame) {
11
+ if (!isLoaded) {
12
+ await adapter.load();
13
+ isLoaded = true;
14
+ }
15
+ // Convert Frame (Uint8ClampedArray) to ImageData compatible structure if needed
16
+ // TFJS generic backend usually takes HTML element or Tensor.
17
+ // In worker, we probably use OffscreenCanvas or explicit tensor creation.
18
+ // For this mock/scaffold, we just pass it as is or cast.
19
+ // We mock the ImageData since we are in a worker environment (no DOM ImageData global usually, unless polyfilled)
20
+ const imageData = new ImageData(frame.data, frame.width, frame.height);
21
+ return await adapter.detect(imageData);
22
+ }
File without changes
@@ -0,0 +1,61 @@
1
+ "use strict";
2
+ // Web Worker for Age Verification Inference
3
+ // Using MediaPipe for robust in-worker inference
4
+ console.log("Worker: Initializing...");
5
+ // Polyfill ImageData if missing (crucial for TFJS in helper canvas ops)
6
+ if (typeof ImageData === 'undefined') {
7
+ // @ts-ignore
8
+ self.ImageData = class {
9
+ constructor(data, width, height) {
10
+ Object.defineProperty(this, "data", {
11
+ enumerable: true,
12
+ configurable: true,
13
+ writable: true,
14
+ value: data
15
+ });
16
+ Object.defineProperty(this, "width", {
17
+ enumerable: true,
18
+ configurable: true,
19
+ writable: true,
20
+ value: width
21
+ });
22
+ Object.defineProperty(this, "height", {
23
+ enumerable: true,
24
+ configurable: true,
25
+ writable: true,
26
+ value: height
27
+ });
28
+ }
29
+ };
30
+ }
31
+ self.onmessage = async (e) => {
32
+ const { type, payload } = e.data;
33
+ try {
34
+ // Dynamic import to defer initialization
35
+ const { infer, loadModels } = await import('./infer');
36
+ if (type === 'LOAD_MODELS') {
37
+ try {
38
+ await loadModels(payload?.basePath);
39
+ self.postMessage({ type: 'LOADED' });
40
+ }
41
+ catch (err) {
42
+ console.error("Worker: Model Load Failed:", err);
43
+ self.postMessage({ type: 'ERROR', error: err.message });
44
+ }
45
+ }
46
+ else if (type === 'PROCESS_FRAME') {
47
+ try {
48
+ const result = await infer(payload);
49
+ self.postMessage({ type: 'RESULT', payload: result });
50
+ }
51
+ catch (err) {
52
+ console.error("Worker: Inference Failed:", err);
53
+ self.postMessage({ type: 'ERROR', error: err.message });
54
+ }
55
+ }
56
+ }
57
+ catch (err) {
58
+ console.error("Worker: Logic Import Failed:", err);
59
+ self.postMessage({ type: 'ERROR', error: `Worker init failed: ${err.message}` });
60
+ }
61
+ };
package/package.json ADDED
@@ -0,0 +1,46 @@
1
+ {
2
+ "name": "solana-age-verify-sdk",
3
+ "version": "2.0.0-beta.2",
4
+ "type": "module",
5
+ "description": "Solana Age Verify is a premium, client-side SDK for privacy-preserving age verification and liveness detection. It generates a deterministic Face Hash linked to a wallet without storing facial data.",
6
+ "license": "MIT",
7
+ "main": "dist/index.js",
8
+ "types": "dist/index.d.ts",
9
+ "files": [
10
+ "dist",
11
+ "public"
12
+ ],
13
+ "homepage": "https://talkchain.live",
14
+ "keywords": [
15
+ "solana",
16
+ "age-verification",
17
+ "id-verification",
18
+ "biometrics",
19
+ "liveness-detection",
20
+ "kyc",
21
+ "web3",
22
+ "privacy",
23
+ "facehash",
24
+ "onnx"
25
+ ],
26
+ "exports": {
27
+ ".": "./dist/index.js",
28
+ "./worker": "./dist/worker/worker.js"
29
+ },
30
+ "scripts": {
31
+ "build": "tsc",
32
+ "test": "echo \"Error: no test specified\" && exit 0",
33
+ "lint": "eslint src"
34
+ },
35
+ "dependencies": {
36
+ "@mediapipe/tasks-vision": "0.10.22-rc.20250304",
37
+ "@solana/web3.js": "^1.98.4",
38
+ "@tensorflow-models/face-detection": "^1.0.3",
39
+ "@tensorflow/tfjs": "^4.0.0",
40
+ "@tensorflow/tfjs-backend-wasm": "^4.22.0",
41
+ "@tensorflow/tfjs-backend-webgl": "^4.22.0",
42
+ "@tensorflow/tfjs-converter": "^4.22.0",
43
+ "@tensorflow/tfjs-core": "^4.22.0",
44
+ "onnxruntime-web": "^1.23.2"
45
+ }
46
+ }