alphavalid-sdk 0.0.9 → 0.0.11

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 CHANGED
@@ -16,6 +16,9 @@ npm i alphavalid-sdk
16
16
 
17
17
  O `face-api.js` carrega os pesos do modelo via HTTP. Este pacote leva os arquivos em `models/`, e você deve copiá-los para os assets do seu app.
18
18
 
19
+ > Nota (Ionic/Angular + Vite dev-server): o shard do TinyFaceDetector é distribuído com extensão `.bin`
20
+ > para evitar erros de `vite:import-analysis` em alguns pipelines.
21
+
19
22
  ### Ionic/Angular (recomendado) — cópia automática no `postinstall`
20
23
 
21
24
  No `package.json` do **APP consumidor**, adicione:
@@ -51,8 +54,8 @@ const sdk = new AlphaValid();
51
54
 
52
55
  await sdk.start({
53
56
  container: document.getElementById('cameraContainer')!,
54
- // default: '/assets/alphavalid-models'
55
- // modelsPath: '/assets/alphavalid-models',
57
+ // Angular/Ionic assets:
58
+ modelsPath: '/assets/alphavalid-models',
56
59
  onReady: () => console.log('ready'),
57
60
  onFeedback: (msg) => console.log('feedback:', msg),
58
61
  onError: (err) => console.error('error:', err)
@@ -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"}
@@ -0,0 +1,17 @@
1
+ import type { AlphaValidStartOptions } from './types/sdk';
2
+ export declare class AlphaValid {
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>;
13
+ capture(): Promise<Blob>;
14
+ private startDetectionLoop;
15
+ }
16
+ export type { AlphaValidStartOptions } from './types/sdk';
17
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
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,35 @@
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
+ * Recommended (Vite/Ionic): copy this package's `/models` into your app `public/alphavalid-models`
19
+ * so they are served at `/alphavalid-models`.
20
+ *
21
+ * Example: modelsPath: '/alphavalid-models'
22
+ */
23
+ modelsPath?: string;
24
+ }
25
+ export interface FaceDetectionStatus {
26
+ faces: number;
27
+ /** Face box normalized [0..1] relative to video square viewport. */
28
+ box?: {
29
+ x: number;
30
+ y: number;
31
+ width: number;
32
+ height: number;
33
+ };
34
+ }
35
+ //# 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;;;;;;OAMG;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,3 @@
1
+ export declare function ensureHTMLElement(el: unknown, name: string): asserts el is HTMLElement;
2
+ export declare function cleanupElement(el: HTMLElement | null | undefined): void;
3
+ //# sourceMappingURL=dom.d.ts.map
@@ -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"}
@@ -1 +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"]}]
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.bin"]}]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "alphavalid-sdk",
3
- "version": "0.0.9",
3
+ "version": "0.0.11",
4
4
  "description": "SDK de validação facial e liveness",
5
5
  "main": "dist/alphavalid.umd.js",
6
6
  "module": "dist/alphavalid.es.js",
@@ -14,7 +14,7 @@
14
14
  "tsconfig.json"
15
15
  ],
16
16
  "scripts": {
17
- "build": "npx vite build",
17
+ "build": "npx vite build && npm run types",
18
18
  "types": "tsc -p tsconfig.json",
19
19
  "build:all": "rm -rf dist && npm run build && npm run types",
20
20
  "test:local": "vite preview",