@simprints/simface-sdk 0.14.1 → 0.16.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/LICENSE +21 -0
- package/README.md +11 -0
- package/dist/services/api-client.js +15 -6
- package/dist/services/api-client.js.map +1 -1
- package/dist/simface-sdk.js +911 -908
- package/dist/simface-sdk.umd.cjs +18 -18
- package/dist/types/index.d.ts +1 -1
- package/package.json +22 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Simprints
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -6,6 +6,8 @@ Works in: all modern browsers, WhatsApp in-app browser, and mobile WebViews.
|
|
|
6
6
|
|
|
7
7
|
This repository is the public frontend SDK and demo repo for SimFace. For frontend architecture and contributor setup, see [docs/architecture.md](docs/architecture.md) and [docs/development.md](docs/development.md).
|
|
8
8
|
|
|
9
|
+
For repository policies and contribution guidance, see [SECURITY.md](SECURITY.md), [CONTRIBUTING.md](CONTRIBUTING.md), and [LICENSE](LICENSE).
|
|
10
|
+
|
|
9
11
|
The backend API, infrastructure, and TensorFlow Lite runtime live in the separate private backend repository.
|
|
10
12
|
|
|
11
13
|
The capture flow is planned explicitly as: auto camera -> manual camera -> media picker. The primary API supports two UI modes:
|
|
@@ -56,6 +58,13 @@ const config = {
|
|
|
56
58
|
};
|
|
57
59
|
```
|
|
58
60
|
|
|
61
|
+
### Security considerations
|
|
62
|
+
|
|
63
|
+
- Treat `apiKey` as a browser-visible credential. Do not hardcode long-lived secrets into shipped frontend bundles.
|
|
64
|
+
- Prefer issuing short-lived credentials or session-bound tokens from your own backend for each capture session.
|
|
65
|
+
- Keep `apiUrl` on HTTPS in production and make sure the backend only accepts trusted origins and authorized project IDs.
|
|
66
|
+
- The local demo does **not** persist project IDs or API keys to `localStorage`; it only remembers the API URL, presentation mode, and client ID between reloads.
|
|
67
|
+
|
|
59
68
|
### 3. Enroll a User
|
|
60
69
|
|
|
61
70
|
```javascript
|
|
@@ -378,3 +387,5 @@ npm run dev
|
|
|
378
387
|
```
|
|
379
388
|
|
|
380
389
|
The demo runs at `http://localhost:4173` and consumes the built SDK artifact from `dist/`. To enable HTTPS (required for camera access from other devices on the local network), set `DEMO_USE_HTTPS=true` before starting the demo.
|
|
390
|
+
|
|
391
|
+
The published demo starts with the hosted demo backend URL by default so GitHub Pages users can try the flow immediately. Override the API URL if you want to point it at a local or alternate backend.
|
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
async function getAPIErrorMessage(response, fallback) {
|
|
2
|
+
try {
|
|
3
|
+
const err = await response.json();
|
|
4
|
+
if (typeof err.error === 'string' && err.error.trim()) {
|
|
5
|
+
return err.error.trim();
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
catch {
|
|
9
|
+
// Ignore malformed or empty error payloads and fall back to a stable message.
|
|
10
|
+
}
|
|
11
|
+
return `${fallback} (HTTP ${response.status})`;
|
|
12
|
+
}
|
|
1
13
|
export class SimFaceAPIClient {
|
|
2
14
|
constructor(config) {
|
|
3
15
|
this.apiUrl = config.apiUrl.replace(/\/$/, '');
|
|
@@ -14,8 +26,7 @@ export class SimFaceAPIClient {
|
|
|
14
26
|
}),
|
|
15
27
|
});
|
|
16
28
|
if (!response.ok) {
|
|
17
|
-
|
|
18
|
-
throw new Error(err.error || 'API key validation failed');
|
|
29
|
+
throw new Error(await getAPIErrorMessage(response, 'API key validation failed'));
|
|
19
30
|
}
|
|
20
31
|
return response.json();
|
|
21
32
|
}
|
|
@@ -33,8 +44,7 @@ export class SimFaceAPIClient {
|
|
|
33
44
|
return { success: false, clientId, alreadyEnrolled: true, message: 'User already enrolled' };
|
|
34
45
|
}
|
|
35
46
|
if (!response.ok) {
|
|
36
|
-
|
|
37
|
-
throw new Error(err.error || 'Enrollment failed');
|
|
47
|
+
throw new Error(await getAPIErrorMessage(response, 'Enrollment failed'));
|
|
38
48
|
}
|
|
39
49
|
return response.json();
|
|
40
50
|
}
|
|
@@ -52,8 +62,7 @@ export class SimFaceAPIClient {
|
|
|
52
62
|
return { match: false, score: 0, threshold: 0, notEnrolled: true, message: 'User not enrolled' };
|
|
53
63
|
}
|
|
54
64
|
if (!response.ok) {
|
|
55
|
-
|
|
56
|
-
throw new Error(err.error || 'Verification failed');
|
|
65
|
+
throw new Error(await getAPIErrorMessage(response, 'Verification failed'));
|
|
57
66
|
}
|
|
58
67
|
return response.json();
|
|
59
68
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api-client.js","sourceRoot":"","sources":["../../src/services/api-client.ts"],"names":[],"mappings":"AAEA,MAAM,OAAO,gBAAgB;IA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