alphavalid-sdk 0.0.5 → 0.0.8
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 +73 -0
- package/dist/alphavalid.es.js +18017 -9
- package/dist/alphavalid.umd.js +3804 -1
- package/dist/core/camera.d.ts +8 -0
- package/dist/core/camera.d.ts.map +1 -0
- package/dist/core/feedback.d.ts +7 -0
- package/dist/core/feedback.d.ts.map +1 -0
- package/dist/index.d.ts +13 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/types/sdk.d.ts +33 -0
- package/dist/types/sdk.d.ts.map +1 -0
- package/dist/ui/overlay.d.ts +16 -0
- package/dist/ui/overlay.d.ts.map +1 -0
- package/dist/utils/dom.d.ts +3 -0
- package/dist/utils/dom.d.ts.map +1 -0
- package/dist/vision/faceDetector.d.ts +7 -0
- package/dist/vision/faceDetector.d.ts.map +1 -0
- package/models/README.md +8 -0
- package/models/tiny_face_detector_model-shard1 +0 -0
- package/models/tiny_face_detector_model-weights_manifest.json +1 -0
- package/package.json +15 -2
- package/.gitattributes +0 -2
- package/src/index.ts +0 -29
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export interface CameraHandle {
|
|
2
|
+
video: HTMLVideoElement;
|
|
3
|
+
stream: MediaStream;
|
|
4
|
+
stop: () => void;
|
|
5
|
+
}
|
|
6
|
+
export declare function startUserCamera(container: HTMLElement): Promise<CameraHandle>;
|
|
7
|
+
export declare function captureVideoFrameToJpegBlob(video: HTMLVideoElement, quality?: number): Promise<Blob>;
|
|
8
|
+
//# sourceMappingURL=camera.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"camera.d.ts","sourceRoot":"","sources":["../../src/core/camera.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,gBAAgB,CAAC;IACxB,MAAM,EAAE,WAAW,CAAC;IACpB,IAAI,EAAE,MAAM,IAAI,CAAC;CAClB;AAED,wBAAsB,eAAe,CAAC,SAAS,EAAE,WAAW,GAAG,OAAO,CAAC,YAAY,CAAC,CA0CnF;AAED,wBAAsB,2BAA2B,CAAC,KAAK,EAAE,gBAAgB,EAAE,OAAO,SAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAkBvG"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { AlphaValidFeedbackMessage, FaceDetectionStatus } from '../types/sdk';
|
|
2
|
+
export interface FeedbackResult {
|
|
3
|
+
message: AlphaValidFeedbackMessage;
|
|
4
|
+
valid: boolean;
|
|
5
|
+
}
|
|
6
|
+
export declare function computeFeedback(status: FaceDetectionStatus): FeedbackResult;
|
|
7
|
+
//# sourceMappingURL=feedback.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"feedback.d.ts","sourceRoot":"","sources":["../../src/core/feedback.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,yBAAyB,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAEnF,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,yBAAyB,CAAC;IACnC,KAAK,EAAE,OAAO,CAAC;CAChB;AAED,wBAAgB,eAAe,CAAC,MAAM,EAAE,mBAAmB,GAAG,cAAc,CA6B3E"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,17 @@
|
|
|
1
|
+
import type { AlphaValidStartOptions } from './types/sdk';
|
|
1
2
|
export declare class AlphaValid {
|
|
2
|
-
private
|
|
3
|
-
|
|
3
|
+
private _camera;
|
|
4
|
+
private _overlay;
|
|
5
|
+
private _container;
|
|
6
|
+
private _faceDetector;
|
|
7
|
+
private _loopTimer;
|
|
8
|
+
private _lastStatusValid;
|
|
9
|
+
private _options;
|
|
10
|
+
start(options: AlphaValidStartOptions): Promise<void>;
|
|
11
|
+
/** Stop camera + overlay + detection loop */
|
|
12
|
+
stop(): Promise<void>;
|
|
4
13
|
capture(): Promise<Blob>;
|
|
14
|
+
private startDetectionLoop;
|
|
5
15
|
}
|
|
16
|
+
export type { AlphaValidStartOptions } from './types/sdk';
|
|
6
17
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,qBAAa,UAAU;IACrB,OAAO,CAAC,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAO1D,qBAAa,UAAU;IACrB,OAAO,CAAC,OAAO,CAA6B;IAC5C,OAAO,CAAC,QAAQ,CAA8B;IAC9C,OAAO,CAAC,UAAU,CAA4B;IAC9C,OAAO,CAAC,aAAa,CAAsC;IAC3D,OAAO,CAAC,UAAU,CAAuB;IACzC,OAAO,CAAC,gBAAgB,CAAS;IACjC,OAAO,CAAC,QAAQ,CAAuC;IAEjD,KAAK,CAAC,OAAO,EAAE,sBAAsB;IAwC3C,6CAA6C;IACvC,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAsBrB,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAW9B,OAAO,CAAC,kBAAkB;CA2B3B;AAED,YAAY,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export type AlphaValidFeedbackMessage = 'Inicializando câmera...' | 'Centralize seu rosto' | 'Aproxime o rosto' | 'Afaste o rosto' | 'Ajuste a iluminação' | 'Apenas 1 rosto por vez' | 'Rosto detectado' | 'Pronto para capturar';
|
|
2
|
+
export interface AlphaValidStartOptions {
|
|
3
|
+
container: HTMLElement;
|
|
4
|
+
/** Called when the camera stream is attached and video can play. */
|
|
5
|
+
onReady?: () => void;
|
|
6
|
+
/** Called frequently as face detection runs, to guide the user. */
|
|
7
|
+
onFeedback?: (message: AlphaValidFeedbackMessage) => void;
|
|
8
|
+
/** Called on errors (permission denied, no camera, etc). */
|
|
9
|
+
onError?: (error: unknown) => void;
|
|
10
|
+
/** Optional: enable/disable overlay guide (default true). */
|
|
11
|
+
overlay?: boolean;
|
|
12
|
+
/** Optional: circle size ratio (0-1). Default 0.72 of the smallest side. */
|
|
13
|
+
guideCircleRatio?: number;
|
|
14
|
+
/** How often to run face detection (ms). Default 200. */
|
|
15
|
+
detectionIntervalMs?: number;
|
|
16
|
+
/**
|
|
17
|
+
* Base URL where face-api.js models are served from.
|
|
18
|
+
* Option A (recommended): copy this package's /models into your app public assets,
|
|
19
|
+
* e.g. '/assets/alphavalid-models'.
|
|
20
|
+
*/
|
|
21
|
+
modelsPath?: string;
|
|
22
|
+
}
|
|
23
|
+
export interface FaceDetectionStatus {
|
|
24
|
+
faces: number;
|
|
25
|
+
/** Face box normalized [0..1] relative to video square viewport. */
|
|
26
|
+
box?: {
|
|
27
|
+
x: number;
|
|
28
|
+
y: number;
|
|
29
|
+
width: number;
|
|
30
|
+
height: number;
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=sdk.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sdk.d.ts","sourceRoot":"","sources":["../../src/types/sdk.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,yBAAyB,GACjC,yBAAyB,GACzB,sBAAsB,GACtB,kBAAkB,GAClB,gBAAgB,GAChB,qBAAqB,GACrB,wBAAwB,GACxB,iBAAiB,GACjB,sBAAsB,CAAC;AAE3B,MAAM,WAAW,sBAAsB;IACrC,SAAS,EAAE,WAAW,CAAC;IAEvB,oEAAoE;IACpE,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IAErB,mEAAmE;IACnE,UAAU,CAAC,EAAE,CAAC,OAAO,EAAE,yBAAyB,KAAK,IAAI,CAAC;IAE1D,4DAA4D;IAC5D,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;IAEnC,6DAA6D;IAC7D,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB,4EAA4E;IAC5E,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAE1B,yDAAyD;IACzD,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAE7B;;;;OAIG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,mBAAmB;IAClC,KAAK,EAAE,MAAM,CAAC;IACd,oEAAoE;IACpE,GAAG,CAAC,EAAE;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;CAC/D"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export interface OverlayHandle {
|
|
2
|
+
canvas: HTMLCanvasElement;
|
|
3
|
+
dispose: () => void;
|
|
4
|
+
render: (status: {
|
|
5
|
+
message?: string;
|
|
6
|
+
box?: {
|
|
7
|
+
x: number;
|
|
8
|
+
y: number;
|
|
9
|
+
width: number;
|
|
10
|
+
height: number;
|
|
11
|
+
};
|
|
12
|
+
valid?: boolean;
|
|
13
|
+
}) => void;
|
|
14
|
+
}
|
|
15
|
+
export declare function createOverlay(container: HTMLElement, guideCircleRatio?: number): OverlayHandle;
|
|
16
|
+
//# sourceMappingURL=overlay.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"overlay.d.ts","sourceRoot":"","sources":["../../src/ui/overlay.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,iBAAiB,CAAC;IAC1B,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,MAAM,EAAE,CAAC,MAAM,EAAE;QACf,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,GAAG,CAAC,EAAE;YAAE,CAAC,EAAE,MAAM,CAAC;YAAC,CAAC,EAAE,MAAM,CAAC;YAAC,KAAK,EAAE,MAAM,CAAC;YAAC,MAAM,EAAE,MAAM,CAAA;SAAE,CAAC;QAC9D,KAAK,CAAC,EAAE,OAAO,CAAC;KACjB,KAAK,IAAI,CAAC;CACZ;AAED,wBAAgB,aAAa,CAAC,SAAS,EAAE,WAAW,EAAE,gBAAgB,SAAO,GAAG,aAAa,CAkF5F"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dom.d.ts","sourceRoot":"","sources":["../../src/utils/dom.ts"],"names":[],"mappings":"AAAA,wBAAgB,iBAAiB,CAAC,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,EAAE,IAAI,WAAW,CAItF;AAED,wBAAgB,cAAc,CAAC,EAAE,EAAE,WAAW,GAAG,IAAI,GAAG,SAAS,GAAG,IAAI,CAOvE"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { FaceDetectionStatus } from '../types/sdk';
|
|
2
|
+
export interface FaceDetector {
|
|
3
|
+
load: (modelsPath: string) => Promise<void>;
|
|
4
|
+
detect: (video: HTMLVideoElement) => Promise<FaceDetectionStatus>;
|
|
5
|
+
}
|
|
6
|
+
export declare function createFaceDetector(): FaceDetector;
|
|
7
|
+
//# sourceMappingURL=faceDetector.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"faceDetector.d.ts","sourceRoot":"","sources":["../../src/vision/faceDetector.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAExD,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5C,MAAM,EAAE,CAAC,KAAK,EAAE,gBAAgB,KAAK,OAAO,CAAC,mBAAmB,CAAC,CAAC;CACnE;AAED,wBAAgB,kBAAkB,IAAI,YAAY,CAwCjD"}
|
package/models/README.md
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
Place face-api.js model files here (TinyFaceDetector) to be shipped with the npm package.
|
|
2
|
+
|
|
3
|
+
Expected files:
|
|
4
|
+
- tiny_face_detector_model-weights_manifest.json
|
|
5
|
+
- tiny_face_detector_model-shard1
|
|
6
|
+
- tiny_face_detector_model-shard2 (if present)
|
|
7
|
+
|
|
8
|
+
These files will be included in the npm tarball and can be copied by consumer apps into their public assets directory.
|
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
[{"weights":[{"name":"conv0/filters","shape":[3,3,3,16],"dtype":"float32","quantization":{"dtype":"uint8","scale":0.009007044399485869,"min":-1.2069439495311063}},{"name":"conv0/bias","shape":[16],"dtype":"float32","quantization":{"dtype":"uint8","scale":0.005263455241334205,"min":-0.9211046672334858}},{"name":"conv1/depthwise_filter","shape":[3,3,16,1],"dtype":"float32","quantization":{"dtype":"uint8","scale":0.004001977630690033,"min":-0.5042491814669441}},{"name":"conv1/pointwise_filter","shape":[1,1,16,32],"dtype":"float32","quantization":{"dtype":"uint8","scale":0.013836609615999109,"min":-1.411334180831909}},{"name":"conv1/bias","shape":[32],"dtype":"float32","quantization":{"dtype":"uint8","scale":0.0015159862590771096,"min":-0.30926119685173037}},{"name":"conv2/depthwise_filter","shape":[3,3,32,1],"dtype":"float32","quantization":{"dtype":"uint8","scale":0.002666276225856706,"min":-0.317286870876948}},{"name":"conv2/pointwise_filter","shape":[1,1,32,64],"dtype":"float32","quantization":{"dtype":"uint8","scale":0.015265831292844286,"min":-1.6792414422128714}},{"name":"conv2/bias","shape":[64],"dtype":"float32","quantization":{"dtype":"uint8","scale":0.0020280554598453,"min":-0.37113414915168985}},{"name":"conv3/depthwise_filter","shape":[3,3,64,1],"dtype":"float32","quantization":{"dtype":"uint8","scale":0.006100742489683862,"min":-0.8907084034938438}},{"name":"conv3/pointwise_filter","shape":[1,1,64,128],"dtype":"float32","quantization":{"dtype":"uint8","scale":0.016276211832083907,"min":-2.0508026908425725}},{"name":"conv3/bias","shape":[128],"dtype":"float32","quantization":{"dtype":"uint8","scale":0.003394414279975143,"min":-0.7637432129944072}},{"name":"conv4/depthwise_filter","shape":[3,3,128,1],"dtype":"float32","quantization":{"dtype":"uint8","scale":0.006716050119961009,"min":-0.8059260143953211}},{"name":"conv4/pointwise_filter","shape":[1,1,128,256],"dtype":"float32","quantization":{"dtype":"uint8","scale":0.021875603993733724,"min":-2.8875797271728514}},{"name":"conv4/bias","shape":[256],"dtype":"float32","quantization":{"dtype":"uint8","scale":0.0041141652009066415,"min":-0.8187188749804216}},{"name":"conv5/depthwise_filter","shape":[3,3,256,1],"dtype":"float32","quantization":{"dtype":"uint8","scale":0.008423839597141042,"min":-0.9013508368940915}},{"name":"conv5/pointwise_filter","shape":[1,1,256,512],"dtype":"float32","quantization":{"dtype":"uint8","scale":0.030007277283014035,"min":-3.8709387695088107}},{"name":"conv5/bias","shape":[512],"dtype":"float32","quantization":{"dtype":"uint8","scale":0.008402082966823203,"min":-1.4871686851277068}},{"name":"conv8/filters","shape":[1,1,512,25],"dtype":"float32","quantization":{"dtype":"uint8","scale":0.028336129469030042,"min":-4.675461362389957}},{"name":"conv8/bias","shape":[25],"dtype":"float32","quantization":{"dtype":"uint8","scale":0.002268134028303857,"min":-0.41053225912299807}}],"paths":["tiny_face_detector_model-shard1"]}]
|
package/package.json
CHANGED
|
@@ -1,14 +1,27 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "alphavalid-sdk",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.8",
|
|
4
4
|
"description": "SDK de validação facial e liveness",
|
|
5
5
|
"main": "dist/alphavalid.umd.js",
|
|
6
6
|
"module": "dist/alphavalid.es.js",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
8
|
+
"files": [
|
|
9
|
+
"dist",
|
|
10
|
+
"models",
|
|
11
|
+
"README.md",
|
|
12
|
+
"package.json",
|
|
13
|
+
"vite.config.ts",
|
|
14
|
+
"tsconfig.json"
|
|
15
|
+
],
|
|
8
16
|
"scripts": {
|
|
9
17
|
"build": "npx vite build",
|
|
10
18
|
"types": "tsc -p tsconfig.json",
|
|
11
|
-
"build:all": "rm -rf dist && npm run build && npm run types"
|
|
19
|
+
"build:all": "rm -rf dist && npm run build && npm run types",
|
|
20
|
+
"test:local": "vite preview",
|
|
21
|
+
"copy-models": "node ./scripts/copy-models.cjs"
|
|
22
|
+
},
|
|
23
|
+
"dependencies": {
|
|
24
|
+
"face-api.js": "^0.22.2"
|
|
12
25
|
},
|
|
13
26
|
"devDependencies": {
|
|
14
27
|
"@types/node": "^25.5.0",
|
package/.gitattributes
DELETED
package/src/index.ts
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
export class AlphaValid {
|
|
2
|
-
private video!: HTMLVideoElement;
|
|
3
|
-
|
|
4
|
-
async start(options: any) {
|
|
5
|
-
const stream = await navigator.mediaDevices.getUserMedia({
|
|
6
|
-
video: { facingMode: "user" }
|
|
7
|
-
});
|
|
8
|
-
|
|
9
|
-
this.video = document.createElement("video");
|
|
10
|
-
this.video.srcObject = stream;
|
|
11
|
-
this.video.autoplay = true;
|
|
12
|
-
this.video.playsInline = true;
|
|
13
|
-
|
|
14
|
-
options.container.appendChild(this.video);
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
async capture(): Promise<Blob> {
|
|
18
|
-
const canvas = document.createElement("canvas");
|
|
19
|
-
canvas.width = this.video.videoWidth;
|
|
20
|
-
canvas.height = this.video.videoHeight;
|
|
21
|
-
|
|
22
|
-
const ctx = canvas.getContext("2d");
|
|
23
|
-
ctx?.drawImage(this.video, 0, 0);
|
|
24
|
-
|
|
25
|
-
return new Promise((resolve) => {
|
|
26
|
-
canvas.toBlob((blob) => resolve(blob!), "image/jpeg");
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
}
|