@powercred/liveness-web 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.
@@ -0,0 +1,138 @@
1
+ /** Public types of @powercred/liveness-web. */
2
+ export type ChallengeType = 'turn_head' | 'nod' | 'smile' | 'blink' | 'open_mouth';
3
+ export type Direction = 'left' | 'right' | 'up' | 'down' | null;
4
+ export interface IssuedChallenge {
5
+ order: number;
6
+ type: ChallengeType;
7
+ direction: Direction;
8
+ timeout_ms: number;
9
+ }
10
+ export interface FlashSegment {
11
+ color: string;
12
+ duration_ms: number;
13
+ }
14
+ /**
15
+ * What your backend receives from `POST /id/liveness/sessions` and hands to the SDK.
16
+ * The SDK never needs an API key: the token authorizes uploads for this session only.
17
+ */
18
+ export interface LivenessSession {
19
+ liveness_session_id: string;
20
+ token: string;
21
+ expires_at: string;
22
+ mode: 'active' | 'passive';
23
+ client_checks?: 'device' | 'none';
24
+ challenges: IssuedChallenge[];
25
+ flash: {
26
+ enabled: boolean;
27
+ segments: FlashSegment[];
28
+ max_hz?: number;
29
+ };
30
+ limits: {
31
+ max_video_seconds: number;
32
+ max_video_bytes: number;
33
+ max_stills: number;
34
+ max_still_bytes: number;
35
+ max_attempts: number;
36
+ accepted_video_types?: string[];
37
+ };
38
+ /** Path of the upload endpoint, relative to `baseUrl`. */
39
+ upload_url: string;
40
+ }
41
+ export interface LivenessConfig {
42
+ /** Base URL of the PowerCred API, e.g. "https://<api-host>/kyc". */
43
+ baseUrl: string;
44
+ /** The session your backend created, or a function that fetches it from your backend. */
45
+ session?: LivenessSession;
46
+ sessionProvider?: () => Promise<LivenessSession>;
47
+ /**
48
+ * true (default): start() resolves with the server's verdict.
49
+ * false: start() resolves as soon as the recording is done ("submitted"); the server verdict
50
+ * arrives through onServerResult while the page stays open, and your backend can read it.
51
+ */
52
+ waitForServer?: boolean;
53
+ /** Set false to skip the colour flash even when the session asks for it. */
54
+ flash?: boolean;
55
+ /**
56
+ * The folder holding the SDK's face-tracking files (the package's dist/assets). Default: the
57
+ * assets/ folder next to the SDK script. Set it when a bundler moves the SDK away from that folder.
58
+ */
59
+ assetsUrl?: string;
60
+ /** Seconds per challenge when the device does not check moves itself (default 3.5). */
61
+ timedWindowSeconds?: number;
62
+ /** Attempts the device may restart on its own before giving up (default 2). */
63
+ maxLocalRetries?: number;
64
+ /** Show the built-in result screen (default true). */
65
+ showResult?: boolean;
66
+ strings?: Partial<import('./ui/strings').Strings>;
67
+ theme?: {
68
+ primaryColor?: string;
69
+ fontFamily?: string;
70
+ };
71
+ onEvent?: (event: LivenessEvent) => void;
72
+ onServerResult?: (result: ServerOutcome) => void;
73
+ }
74
+ export type DeviceMode = 'device' | 'none';
75
+ export interface DeviceOutcome {
76
+ mode: DeviceMode;
77
+ fallbackReason: string | null;
78
+ /** Challenges the device saw completed, in order (empty in "none" mode). */
79
+ passedChallenges: ChallengeType[];
80
+ }
81
+ export interface ServerOutcome {
82
+ liveness_session_id: string;
83
+ attempt: number;
84
+ status: 'passed' | 'failed' | 'inconclusive';
85
+ retry_allowed: boolean;
86
+ server_result: {
87
+ passed: boolean;
88
+ score: number;
89
+ reasons: string[];
90
+ checks: Record<string, unknown>;
91
+ processing_ms?: number;
92
+ };
93
+ }
94
+ export type LivenessStatus = 'passed' | 'failed' | 'inconclusive' | 'submitted' | 'cancelled' | 'error';
95
+ export interface LivenessResult {
96
+ status: LivenessStatus;
97
+ livenessSessionId: string | null;
98
+ attempt?: number;
99
+ device: DeviceOutcome | null;
100
+ server?: ServerOutcome;
101
+ retryAllowed?: boolean;
102
+ /** A front-facing photo from the check (eyes open), for your own face-match calls. */
103
+ selfie?: Blob;
104
+ /** Machine-readable reason for failed / error / cancelled. */
105
+ reason?: string;
106
+ }
107
+ export type LivenessEvent = {
108
+ type: 'camera_ready';
109
+ } | {
110
+ type: 'mode';
111
+ mode: DeviceMode;
112
+ fallbackReason: string | null;
113
+ } | {
114
+ type: 'recording_started';
115
+ } | {
116
+ type: 'challenge_started';
117
+ challenge: IssuedChallenge;
118
+ } | {
119
+ type: 'challenge_passed';
120
+ challenge: IssuedChallenge;
121
+ } | {
122
+ type: 'attempt_aborted';
123
+ reason: string;
124
+ } | {
125
+ type: 'flash_started';
126
+ } | {
127
+ type: 'flash_ended';
128
+ } | {
129
+ type: 'uploading';
130
+ bytes: number;
131
+ } | {
132
+ type: 'server_result';
133
+ result: ServerOutcome;
134
+ } | {
135
+ type: 'error';
136
+ code: string;
137
+ message: string;
138
+ };
@@ -0,0 +1,42 @@
1
+ /** Every user-visible text. Override any of them with `config.strings`. */
2
+ export interface Strings {
3
+ gettingReady: string;
4
+ center: string;
5
+ moveCloser: string;
6
+ moveBack: string;
7
+ lookStraight: string;
8
+ noFace: string;
9
+ multipleFaces: string;
10
+ turnLeft: string;
11
+ turnRight: string;
12
+ lookUp: string;
13
+ lookDown: string;
14
+ smile: string;
15
+ blink: string;
16
+ openMouth: string;
17
+ holdStill: string;
18
+ great: string;
19
+ wrongDirection: string;
20
+ faceLost: string;
21
+ interrupted: string;
22
+ timeUp: string;
23
+ tooSlow: string;
24
+ flashIntro: string;
25
+ checking: string;
26
+ passedTitle: string;
27
+ passedDetail: string;
28
+ submittedTitle: string;
29
+ failedTitle: string;
30
+ failedDetail: string;
31
+ noAttemptsDetail: string;
32
+ tryAgain: string;
33
+ cameraDenied: string;
34
+ cameraUnavailable: string;
35
+ unsupportedBrowser: string;
36
+ insecureContext: string;
37
+ network: string;
38
+ sessionExpired: string;
39
+ serviceUnavailable: string;
40
+ genericError: string;
41
+ }
42
+ export declare const EN: Strings;
package/package.json CHANGED
@@ -1,6 +1,18 @@
1
1
  {
2
2
  "name": "@powercred/liveness-web",
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": "PowerCred Liveness for the web: guided liveness challenges, recorded and verified by the PowerCred backend.",
5
+ "type": "module",
6
+ "module": "./dist/liveness.js",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/liveness.js"
12
+ }
13
+ },
14
+ "files": [
15
+ "dist",
16
+ "THIRD_PARTY_NOTICES.txt"
17
+ ]
18
+ }