@simprints/simface-sdk 0.5.1 → 0.7.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/README.md CHANGED
@@ -8,7 +8,7 @@ This repository is the public frontend SDK and demo repo for SimFace. For fronte
8
8
 
9
9
  The backend API, infrastructure, and TensorFlow Lite runtime live in the separate private backend repository.
10
10
 
11
- In standard browsers, the SDK uses an in-page camera flow powered by `getUserMedia()`. In WhatsApp, it falls back to the native capture handoff because that path is more reliable in the in-app browser.
11
+ The capture flow is planned explicitly as: auto camera -> manual camera -> media picker. Hosts can keep the default popup experience or opt into embedded capture with the same fallback policy.
12
12
 
13
13
  ## Quick Start
14
14
 
@@ -90,12 +90,41 @@ npm run dev
90
90
 
91
91
  The demo runs at `http://localhost:4173` and consumes the built SDK artifact from `dist/`.
92
92
 
93
+ ## Capture strategy
94
+
95
+ The top-level SDK helpers accept an optional third `captureOptions` argument so the host can choose popup vs embedded capture and tune the fallback chain:
96
+
97
+ ```javascript
98
+ import { enroll } from '@simprints/simface-sdk';
99
+
100
+ const result = await enroll(config, 'unique-user-id', {
101
+ presentation: 'embedded',
102
+ container: '#capture-slot',
103
+ capturePreference: 'auto-preferred',
104
+ allowMediaPickerFallback: true,
105
+ label: 'Capture a face for enrollment',
106
+ confirmLabel: 'Confirm enrollment capture',
107
+ });
108
+ ```
109
+
110
+ Supported capture planning options:
111
+
112
+ - `presentation: 'popup' | 'embedded'`
113
+ - `capturePreference: 'auto-preferred' | 'manual-only'`
114
+ - `allowMediaPickerFallback: boolean`
115
+ - `container: HTMLElement | string` (required for top-level embedded capture)
116
+ - `label` / `confirmLabel`
117
+
93
118
  ## Web Component
94
119
 
95
120
  For more control over the UI, use the `<simface-capture>` Web Component directly:
96
121
 
97
122
  ```html
98
- <simface-capture label="Take a selfie for verification"></simface-capture>
123
+ <simface-capture
124
+ embedded
125
+ capture-preference="auto-preferred"
126
+ label="Take a selfie for verification"
127
+ ></simface-capture>
99
128
 
100
129
  <script type="module">
101
130
  import '@simprints/simface-sdk';
@@ -129,6 +158,10 @@ For more control over the UI, use the `<simface-capture>` Web Component directly
129
158
  | Attribute | Type | Default | Description |
130
159
  |-----------|------|---------|-------------|
131
160
  | `label` | String | `"Take a selfie"` | Instructional text shown on the capture button |
161
+ | `embedded` | Boolean | `false` | Runs the component inline instead of delegating to the popup capture service |
162
+ | `confirm-label` | String | `"Use this capture"` | Confirm button label used in preview state |
163
+ | `capture-preference` | `"auto-preferred" \| "manual-only"` | `"auto-preferred"` | Whether auto capture should be preferred or disabled |
164
+ | `allow-media-picker-fallback` | Boolean | `true` | Whether the component may fall back to the media picker if camera capture is unavailable |
132
165
 
133
166
  ### Events
134
167
 
@@ -140,7 +173,7 @@ For more control over the UI, use the `<simface-capture>` Web Component directly
140
173
 
141
174
  ## API Reference
142
175
 
143
- ### `enroll(config, clientId): Promise<EnrollResult>`
176
+ ### `enroll(config, clientId, captureOptions?): Promise<EnrollResult>`
144
177
 
145
178
  Opens the camera, captures a face image with quality validation, and enrolls the user.
146
179
 
@@ -150,6 +183,7 @@ Parameters:
150
183
  |-----------|------|-------------|
151
184
  | `config` | `SimFaceConfig` | SDK configuration (`apiUrl`, `projectId`, `apiKey`) |
152
185
  | `clientId` | `string` | Unique identifier for the user |
186
+ | `captureOptions` | `SimFaceCaptureOptions` | Optional capture presentation/fallback overrides |
153
187
 
154
188
  Returns `EnrollResult`:
155
189
  ```typescript
@@ -161,7 +195,7 @@ Returns `EnrollResult`:
161
195
  }
162
196
  ```
163
197
 
164
- ### `verify(config, clientId): Promise<VerifyResult>`
198
+ ### `verify(config, clientId, captureOptions?): Promise<VerifyResult>`
165
199
 
166
200
  Opens the camera, captures a face image, and verifies against the enrolled face.
167
201
 
@@ -171,6 +205,7 @@ Parameters:
171
205
  |-----------|------|-------------|
172
206
  | `config` | `SimFaceConfig` | SDK configuration (`apiUrl`, `projectId`, `apiKey`) |
173
207
  | `clientId` | `string` | Unique identifier for the user |
208
+ | `captureOptions` | `SimFaceCaptureOptions` | Optional capture presentation/fallback overrides |
174
209
 
175
210
  Returns `VerifyResult`:
176
211
  ```typescript
@@ -193,6 +228,19 @@ Returns `VerifyResult`:
193
228
  }
194
229
  ```
195
230
 
231
+ ### `SimFaceCaptureOptions`
232
+
233
+ ```typescript
234
+ {
235
+ presentation?: 'popup' | 'embedded';
236
+ capturePreference?: 'auto-preferred' | 'manual-only';
237
+ allowMediaPickerFallback?: boolean;
238
+ container?: HTMLElement | string;
239
+ label?: string;
240
+ confirmLabel?: string;
241
+ }
242
+ ```
243
+
196
244
  ## Backend API Endpoints
197
245
 
198
246
  For clients integrating directly with the REST API:
@@ -1,4 +1,5 @@
1
1
  import { LitElement } from 'lit';
2
+ import type { CapturePreference } from '../types/index.js';
2
3
  /**
3
4
  * <simface-capture> — Web Component for capturing and quality-checking face images.
4
5
  *
@@ -12,6 +13,8 @@ export declare class SimFaceCapture extends LitElement {
12
13
  embedded: boolean;
13
14
  active: boolean;
14
15
  confirmLabel: string;
16
+ capturePreference: CapturePreference;
17
+ allowMediaPickerFallback: boolean;
15
18
  private captureState;
16
19
  private errorMessage;
17
20
  private feedbackMessage;
@@ -19,16 +22,13 @@ export declare class SimFaceCapture extends LitElement {
19
22
  private previewUrl;
20
23
  private countdownProgress;
21
24
  private qualityResult;
25
+ private canTakePhoto;
22
26
  private embeddedVideoElement?;
23
27
  private stream;
24
- private animationFrameId;
25
- private analysisInFlight;
26
- private lastAnalysisTimestamp;
28
+ private sessionController;
29
+ private currentCaptureStep;
27
30
  private capturedBlob;
28
- private countdownStartedAt;
29
- private bestCaptureBlob;
30
- private bestCaptureScore;
31
- private bestQualityResult;
31
+ private pendingActiveSync;
32
32
  static styles: import("lit").CSSResult;
33
33
  disconnectedCallback(): void;
34
34
  updated(changedProperties: Map<string, unknown>): void;
@@ -39,30 +39,26 @@ export declare class SimFaceCapture extends LitElement {
39
39
  private handlePopupCapture;
40
40
  private handlePopupRetake;
41
41
  private handlePopupCancel;
42
- private startEmbeddedCapture;
43
- private scheduleEmbeddedAnalysis;
44
- private captureEmbeddedFrame;
45
- private considerBestFrame;
46
- private finishCountdownCapture;
47
- private assessCapturedBlob;
42
+ private beginEmbeddedCapture;
43
+ private startEmbeddedMediaPicker;
44
+ private applySessionState;
45
+ private showPickedPreview;
48
46
  private handleEmbeddedManualCapture;
49
47
  private handleEmbeddedRetake;
50
48
  private handleEmbeddedConfirm;
51
49
  private handleEmbeddedCancel;
52
50
  private handleEmbeddedError;
51
+ private endEmbeddedCapture;
53
52
  private stopEmbeddedSession;
54
53
  private resetEmbeddedState;
55
54
  private resetPopupState;
55
+ private setPreviewBlob;
56
+ private clearPreviewUrl;
56
57
  private dispatchCaptured;
57
58
  private dispatchCancelled;
58
59
  private dispatchError;
59
60
  private feedbackClass;
60
- private waitForVideoReady;
61
- private captureVideoFrame;
62
- private resumeEmbeddedVideo;
63
- private resetCountdown;
64
- private countdownMessage;
65
- private bestCaptureMessage;
61
+ private assessPickedBlob;
66
62
  }
67
63
  declare global {
68
64
  interface HTMLElementTagNameMap {