argus-face-sdk 0.0.0-stage → 0.1.1

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/dist/files.js ADDED
@@ -0,0 +1,78 @@
1
+ import { ArgusValidationError } from "./errors.js";
2
+ export const IMAGE_MAX_BYTES = 12 * 1024 * 1024; // every image endpoint
3
+ export const FACE_CLIP_MAX_BYTES = 24 * 1024 * 1024; // /v1/face/verify clip (server default)
4
+ export const ID_CLIP_MAX_BYTES = 30 * 1024 * 1024; // /v1/screen/id recording
5
+ export const ID_CAPTURE_MAX_CHARS = 64 * 1024; // /v1/screen/id `capture` JSON
6
+ const IMAGE_TYPES = ["image/jpeg", "image/png", "image/webp", "image/gif"];
7
+ const CLIP_TYPES = ["video/webm", "video/mp4"];
8
+ /** The media type from the first bytes. The server reads the type from the bytes too, so this is what it will see. */
9
+ export function sniff(b) {
10
+ const at = (i, ...v) => v.every((x, k) => b[i + k] === x);
11
+ if (b.length >= 3 && at(0, 0xff, 0xd8, 0xff))
12
+ return "image/jpeg";
13
+ if (b.length >= 8 && at(0, 0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a))
14
+ return "image/png";
15
+ if (b.length >= 12 && at(0, 0x52, 0x49, 0x46, 0x46) && at(8, 0x57, 0x45, 0x42, 0x50))
16
+ return "image/webp";
17
+ if (b.length >= 6 && at(0, 0x47, 0x49, 0x46, 0x38))
18
+ return "image/gif";
19
+ if (b.length >= 4 && at(0, 0x1a, 0x45, 0xdf, 0xa3))
20
+ return "video/webm";
21
+ if (b.length >= 12 && at(4, 0x66, 0x74, 0x79, 0x70)) { // ISO BMFF: 'ftyp' + brand
22
+ const brand = String.fromCharCode(b[8], b[9], b[10], b[11]);
23
+ if (/^(heic|heix|hevc|heim|heis|mif1|msf1)$/.test(brand))
24
+ return "image/heic";
25
+ if (brand === "avif" || brand === "avis")
26
+ return "image/avif";
27
+ if (brand === "qt ")
28
+ return "video/quicktime";
29
+ return "video/mp4";
30
+ }
31
+ if (b.length >= 5 && at(0, 0x25, 0x50, 0x44, 0x46, 0x2d))
32
+ return "application/pdf";
33
+ return null;
34
+ }
35
+ async function bytesOf(input) {
36
+ let data;
37
+ let filename;
38
+ if (input && typeof input === "object" && "data" in input && !(input instanceof Blob) && !ArrayBuffer.isView(input)) {
39
+ data = input.data;
40
+ filename = input.filename;
41
+ }
42
+ else {
43
+ data = input;
44
+ }
45
+ if (typeof Blob !== "undefined" && data instanceof Blob) {
46
+ const name = data.name;
47
+ return { bytes: new Uint8Array(await data.arrayBuffer()), filename: filename ?? (typeof name === "string" ? name : undefined) };
48
+ }
49
+ if (data instanceof ArrayBuffer)
50
+ return { bytes: new Uint8Array(data), filename };
51
+ if (ArrayBuffer.isView(data))
52
+ return { bytes: new Uint8Array(data.buffer, data.byteOffset, data.byteLength), filename };
53
+ throw new ArgusValidationError({ status: 0, detail: "expected a Blob, ArrayBuffer, Uint8Array/Buffer or {data}" });
54
+ }
55
+ const EXT = {
56
+ "image/jpeg": "jpg", "image/png": "png", "image/webp": "webp", "image/gif": "gif", "video/webm": "webm", "video/mp4": "mp4",
57
+ };
58
+ /**
59
+ * Read an input, check its type from its bytes and its size, and return a Blob typed with that type. Refused here
60
+ * (status 0, nothing sent, nothing charged): empty files, files over the limit, and types the endpoint can't read.
61
+ */
62
+ export async function prepare(input, field, kind, maxBytes) {
63
+ const { bytes, filename } = await bytesOf(input);
64
+ if (!bytes.length)
65
+ throw new ArgusValidationError({ status: 0, detail: `${field} is empty` });
66
+ if (bytes.length > maxBytes) {
67
+ throw new ArgusValidationError({ status: 0, detail: `${field} is too large (max ${Math.round(maxBytes / 1048576)} MB)` });
68
+ }
69
+ const type = sniff(bytes);
70
+ const allowed = kind === "image" ? IMAGE_TYPES : CLIP_TYPES;
71
+ if (!type || !allowed.includes(type)) {
72
+ const want = kind === "image" ? "a JPEG, PNG, WebP or GIF image" : "a WebM or MP4 recording";
73
+ throw new ArgusValidationError({ status: 0, detail: `${field} must be ${want}${type ? ` (got ${type})` : ""}` });
74
+ }
75
+ const copy = new Uint8Array(bytes.byteLength); // a standalone copy: Blob parts must not alias a shared buffer
76
+ copy.set(bytes);
77
+ return { blob: new Blob([copy], { type }), filename: filename || `${field}.${EXT[type]}`, type, size: bytes.length };
78
+ }
@@ -0,0 +1,9 @@
1
+ export { ArgusFace, DEFAULT_BASE_URL } from "./client.js";
2
+ export type { ArgusFaceOptions, CallCost, IdentityResult, IdLiveCapture, LivenessCapture, ScreenIdInput, VerifyFaceInput, VerifyIdentityInput, } from "./client.js";
3
+ export { explainResult } from "./explain.js";
4
+ export type { Explanation, Signal, SignalEffect } from "./explain.js";
5
+ export { ArgusAllowanceError, ArgusAuthError, ArgusConflictError, ArgusError, ArgusNetworkError, ArgusNotFoundError, ArgusPermissionError, ArgusRateLimitError, ArgusUnavailableError, ArgusUpstreamError, ArgusValidationError, } from "./errors.js";
6
+ export type { RateLimitReason } from "./errors.js";
7
+ export { sniff, IMAGE_MAX_BYTES, FACE_CLIP_MAX_BYTES, ID_CLIP_MAX_BYTES } from "./files.js";
8
+ export type { FileInput } from "./files.js";
9
+ export * from "./types.js";
package/dist/index.js ADDED
@@ -0,0 +1,5 @@
1
+ export { ArgusFace, DEFAULT_BASE_URL } from "./client.js";
2
+ export { explainResult } from "./explain.js";
3
+ export { ArgusAllowanceError, ArgusAuthError, ArgusConflictError, ArgusError, ArgusNetworkError, ArgusNotFoundError, ArgusPermissionError, ArgusRateLimitError, ArgusUnavailableError, ArgusUpstreamError, ArgusValidationError, } from "./errors.js";
4
+ export { sniff, IMAGE_MAX_BYTES, FACE_CLIP_MAX_BYTES, ID_CLIP_MAX_BYTES } from "./files.js";
5
+ export * from "./types.js";
@@ -0,0 +1,268 @@
1
+ /**
2
+ * Response types, written from the server code (poc/app/main.py, face_*.py, doc_liveness.py) on 2026-11-29.
3
+ * Every check object can carry more keys than listed; they are typed as open records so new server fields don't break
4
+ * callers. Strings the server may extend are typed `X | (string & {})`: known values autocomplete, unknown ones pass.
5
+ */
6
+ type Open<T> = T & {
7
+ [key: string]: unknown;
8
+ };
9
+ type Known<T extends string> = T | (string & {});
10
+ /** How a check is used by the server. `gate` counts towards the status; `shadow` is reported only; `off` didn't run. */
11
+ export type CheckMode = Known<"gate" | "shadow" | "off">;
12
+ export type FaceStatus = Known<"verified" | "review" | "failed">;
13
+ export type MatchAssessment = Known<"match" | "likely_match" | "inconclusive" | "likely_mismatch" | "mismatch">;
14
+ /** Face Match Analyst (AI). `similarity` is the model's own estimate, not a calibrated score. */
15
+ export type FaceMatch = Open<{
16
+ assessment: MatchAssessment;
17
+ similarity?: number;
18
+ confidence?: number;
19
+ consistent_features?: string[];
20
+ discrepancies?: string[];
21
+ quality_issues?: string[];
22
+ faces_detected?: {
23
+ id?: boolean;
24
+ selfie?: boolean;
25
+ };
26
+ notes?: string | null;
27
+ }>;
28
+ /** Presentation-Attack Analyst (AI): a lean, never a guarantee. */
29
+ export type FaceIntegrity = Open<{
30
+ verdict?: Known<"authentic" | "review" | "suspect">;
31
+ /** The sandbox fixture sends `assessment` ("genuine" / "spoof") instead of `verdict`. */
32
+ assessment?: string;
33
+ confidence?: number;
34
+ live_capture_signals?: string[];
35
+ attack_signals?: string[];
36
+ attack_types_considered?: string[];
37
+ quality_issues?: string[];
38
+ apparent_age?: {
39
+ estimate: number;
40
+ low: number;
41
+ high: number;
42
+ } | null;
43
+ notes?: string | null;
44
+ }>;
45
+ /** The open-source engine: SFace matcher (`match`) and Silent-Face/MiniFASNet anti-spoof (`pad`). Null when not installed. */
46
+ export type FaceEngine = Open<{
47
+ match?: Open<{
48
+ decision?: Known<"match" | "inconclusive" | "no_match" | "no_face" | "error">;
49
+ score?: number;
50
+ threshold?: number;
51
+ }>;
52
+ pad?: Open<{
53
+ decision?: Known<"live" | "uncertain" | "spoof" | "no_face" | "error">;
54
+ live_score?: number;
55
+ spoof_score?: number;
56
+ }>;
57
+ version?: string;
58
+ }>;
59
+ export type PulseCheck = Open<{
60
+ mode: CheckMode;
61
+ decision: Known<"pulse" | "weak" | "none" | "insufficient">;
62
+ hr_bpm?: number;
63
+ snr_db?: number;
64
+ notes?: string;
65
+ }>;
66
+ export type FlashCheck = Open<{
67
+ mode: CheckMode;
68
+ decision: Known<"matched" | "not_matched" | "weak" | "invalid" | "insufficient" | "skipped">;
69
+ score?: number;
70
+ p_value?: number;
71
+ notes?: string;
72
+ }>;
73
+ export type DeviceCheck = Open<{
74
+ mode: CheckMode;
75
+ decision: Known<"clean" | "suspicious" | "injected" | "automated" | "unavailable">;
76
+ signals: Array<Open<{
77
+ severity: Known<"low" | "medium" | "high">;
78
+ detail: string;
79
+ }>>;
80
+ }>;
81
+ export type FaceLiveness = Open<{
82
+ clip_document_id: string | null;
83
+ challenge: Record<string, unknown>;
84
+ /** Reported by the browser's on-device check. Evidence, not proof: a capable attacker controls the browser. */
85
+ challenge_passed: boolean;
86
+ on_device: boolean;
87
+ consent: boolean;
88
+ expires_at: string | null;
89
+ encrypted: boolean;
90
+ size_bytes: number;
91
+ pulse: PulseCheck | null;
92
+ flash: FlashCheck | null;
93
+ device: DeviceCheck | null;
94
+ note?: string;
95
+ }>;
96
+ export type DocumentCheckIssue = Open<{
97
+ level: Known<"fail" | "warn" | "info">;
98
+ detail: string;
99
+ code?: string;
100
+ }>;
101
+ /** doc_check on the reference image: genuine / review / suspect, or none (not a document). `suspect` fails the check. */
102
+ export type DocumentCheck = Open<{
103
+ decision: Known<"genuine" | "review" | "suspect" | "none" | "unavailable">;
104
+ document_type?: string;
105
+ issuing_country?: string;
106
+ issues?: DocumentCheckIssue[];
107
+ }>;
108
+ /** doc_liveness on a live ID capture: the signed movement challenge, device report, screen replay, photo-vs-clip. */
109
+ export type DocumentLiveness = Open<{
110
+ mode?: CheckMode;
111
+ decision: Known<"live" | "review" | "insufficient" | "unavailable">;
112
+ /** e.g. "live_phone" (rear camera on a phone, challenge matched), "live_webcam", "unproven". */
113
+ assurance?: string;
114
+ reasons?: string[];
115
+ /** Whether the stills show the card filmed in the clip. */
116
+ photos?: Open<{
117
+ decision: Known<"matched" | "mismatch" | "inconclusive">;
118
+ notes?: string;
119
+ }> | null;
120
+ }>;
121
+ /** Identity-fraud checks (face_fraud.py). The same-face (1:N) search and IP/device links run for API keys only. */
122
+ export type FraudChecks = Open<{
123
+ mode: CheckMode;
124
+ reasons?: string[];
125
+ age?: Open<{
126
+ decision: Known<"consistent" | "mismatch" | "unknown">;
127
+ notes?: string;
128
+ }>;
129
+ repeat_face?: Open<{
130
+ decision: Known<"new" | "returning" | "seen_before" | "other_identity" | "unavailable" | "not_run">;
131
+ matches?: Array<Record<string, unknown>>;
132
+ notes?: string;
133
+ }>;
134
+ linkage?: Open<{
135
+ decision: Known<"clear" | "linked" | "unavailable" | "not_run">;
136
+ signals?: Array<Record<string, unknown>>;
137
+ }>;
138
+ recent_issue?: Record<string, unknown>;
139
+ }>;
140
+ /** The `result` of POST /v1/face/verify. */
141
+ export type FaceVerifyResult = Open<{
142
+ status: FaceStatus;
143
+ verified: boolean;
144
+ reasons: string[];
145
+ match: FaceMatch | null;
146
+ integrity: FaceIntegrity | null;
147
+ engine: FaceEngine | null;
148
+ liveness: FaceLiveness | null;
149
+ document: DocumentCheck | null;
150
+ document_live: DocumentLiveness | null;
151
+ fraud?: FraudChecks | null;
152
+ reference_document_id: string | null;
153
+ selfie_document_id: string | null;
154
+ checked_at: string;
155
+ checked_by?: string;
156
+ advisory: string;
157
+ sandbox?: boolean;
158
+ /** Set by the SDK when the server returned a stored result for a repeated Idempotency-Key (nothing was charged). */
159
+ replayed?: true;
160
+ }>;
161
+ /** POST /v1/face/flash. Hand it to the browser; it is valid for about 2 minutes, once, for the key that asked. */
162
+ export type FlashChallenge = {
163
+ token: string;
164
+ slot_ms: number;
165
+ expires_in: number;
166
+ sequence: Array<{
167
+ name: string;
168
+ rgb: [number, number, number];
169
+ }>;
170
+ };
171
+ /** POST /v1/screen/id/capture/start. Valid for 600 s, once, for the key that asked. */
172
+ export type IdCaptureChallenge = {
173
+ token: string;
174
+ expires_in: number;
175
+ steps: Array<{
176
+ code: string;
177
+ text: string;
178
+ }>;
179
+ };
180
+ export type IdDocumentBlock = Open<{
181
+ source: Known<"camera" | "upload">;
182
+ liveness: DocumentLiveness | null;
183
+ checks: {
184
+ front?: DocumentCheck;
185
+ back?: DocumentCheck;
186
+ };
187
+ assurance: string;
188
+ }>;
189
+ export type ParsedId = Open<{
190
+ screening_query: {
191
+ name: string | null;
192
+ dob?: string | null;
193
+ country?: string | null;
194
+ aliases?: string[] | null;
195
+ };
196
+ document: IdDocumentBlock;
197
+ back_document_id?: string;
198
+ }>;
199
+ export type ScreeningMatch = Open<{
200
+ name?: string;
201
+ match_score?: number;
202
+ match_band?: string;
203
+ dataset_type?: string;
204
+ pep_classification?: string;
205
+ /** Per-match photo path, only for partner keys allowed /v1/photo/. */
206
+ photo?: string | null;
207
+ }>;
208
+ export type Screening = Open<{
209
+ result_band?: string;
210
+ matches?: ScreeningMatch[];
211
+ }>;
212
+ /** POST /v1/screen/id. `screening` is null when no name could be read (see `warning`). */
213
+ export type IdScreenResult = Open<{
214
+ parsed: ParsedId;
215
+ screening: Screening | null;
216
+ document_id: string;
217
+ warning?: string;
218
+ }>;
219
+ /** POST /v1/screen/id/{doc_id}/face: AI match + integrity + engine, with no overall status. */
220
+ export type IdFaceCheck = Open<{
221
+ face_check: Open<{
222
+ match: FaceMatch | null;
223
+ integrity: FaceIntegrity | null;
224
+ engine: FaceEngine | null;
225
+ selfie_document_id: string | null;
226
+ checked_at: string;
227
+ checked_by?: string;
228
+ advisory: string;
229
+ }>;
230
+ document_id: string;
231
+ }>;
232
+ /** GET /v1/face/config. */
233
+ export type FaceConfig = Open<{
234
+ liveness: boolean;
235
+ max_seconds: number;
236
+ retain_hours: number;
237
+ challenges: string[];
238
+ engine: Record<string, unknown>;
239
+ pulse: {
240
+ available: boolean;
241
+ mode: CheckMode;
242
+ };
243
+ flash: {
244
+ available: boolean;
245
+ mode: CheckMode;
246
+ slots: number;
247
+ slot_ms: number;
248
+ };
249
+ device: {
250
+ mode: CheckMode;
251
+ };
252
+ limits: {
253
+ image_megapixels: number;
254
+ };
255
+ encryption: {
256
+ clips: string;
257
+ };
258
+ }>;
259
+ /** GET /v1/founder/usage (founder keys only). */
260
+ export type FounderUsage = Open<{
261
+ org: string;
262
+ sandbox: boolean;
263
+ monthly_units: number;
264
+ units_used: number;
265
+ by_kind: Array<Record<string, unknown>>;
266
+ period: string;
267
+ }>;
268
+ export {};
package/dist/types.js ADDED
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Response types, written from the server code (poc/app/main.py, face_*.py, doc_liveness.py) on 2026-11-29.
3
+ * Every check object can carry more keys than listed; they are typed as open records so new server fields don't break
4
+ * callers. Strings the server may extend are typed `X | (string & {})`: known values autocomplete, unknown ones pass.
5
+ */
6
+ export {};
package/package.json CHANGED
@@ -1,6 +1,51 @@
1
1
  {
2
2
  "name": "argus-face-sdk",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.1",
4
+ "description": "Client SDK for the Argus face verification API: face match, ID document plus selfie, live capture.",
5
+ "homepage": "https://argus.unbackoffice.com/developer",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/sect0rial/argus-face-sdk.git"
9
+ },
10
+ "bugs": "https://github.com/sect0rial/argus-face-sdk/issues",
11
+ "author": "Daertho <1@daertho.com> (https://daertho.com)",
12
+ "license": "MIT",
13
+ "keywords": [
14
+ "argus",
15
+ "face-verification",
16
+ "kyc",
17
+ "liveness",
18
+ "identity",
19
+ "sdk"
20
+ ],
21
+ "type": "module",
22
+ "main": "./dist/index.js",
23
+ "types": "./dist/index.d.ts",
24
+ "exports": {
25
+ ".": {
26
+ "types": "./dist/index.d.ts",
27
+ "default": "./dist/index.js"
28
+ },
29
+ "./browser": {
30
+ "types": "./dist/browser.d.ts",
31
+ "default": "./dist/browser.js"
32
+ }
33
+ },
34
+ "files": [
35
+ "dist",
36
+ "README.md",
37
+ "LICENSE"
38
+ ],
39
+ "engines": {
40
+ "node": ">=18"
41
+ },
42
+ "sideEffects": false,
43
+ "scripts": {
44
+ "build": "tsc -p tsconfig.json",
45
+ "test": "npm run build && node --test test/*.test.mjs",
46
+ "prepublishOnly": "npm test"
47
+ },
48
+ "devDependencies": {
49
+ "typescript": "5.9.3"
50
+ }
51
+ }