@velixbiometrics/sdk-core 0.1.0 → 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.
Files changed (2) hide show
  1. package/README.md +162 -0
  2. package/package.json +1 -1
package/README.md ADDED
@@ -0,0 +1,162 @@
1
+ # @velixbiometrics/sdk-core — TypeScript/JavaScript SDK ![version](https://img.shields.io/badge/version-0.1.0--alpha.1-orange)
2
+
3
+ > ⚠️ **Alpha / pre-release**, mas já publicado e confirmado funcionando de ponta a ponta contra a API real de staging (onboarding, LGPD, me, events). **npm:** https://www.npmjs.com/package/@velixbiometrics/sdk-core
4
+
5
+ Official TypeScript/JavaScript SDK for the VELIX Biometrics platform — facial access control B2B SaaS.
6
+
7
+ ## Requirements
8
+
9
+ - Node.js 20+
10
+ - TypeScript 5+ (strict mode)
11
+
12
+ ## Installation
13
+
14
+ ```bash
15
+ npm install @velixbiometrics/sdk-core
16
+ # or
17
+ yarn add @velixbiometrics/sdk-core
18
+ ```
19
+
20
+ ## Quick Start
21
+
22
+ ```typescript
23
+ import { VelixClient, CheckinModule } from '@velixbiometrics/sdk-core'
24
+
25
+ const client = new VelixClient({
26
+ apiUrl: process.env.VELIX_API_URL!,
27
+ apiKey: process.env.VELIX_API_KEY!,
28
+ environment: 'sandbox',
29
+ })
30
+
31
+ const result = await new CheckinModule(client).identify({ imageBase64: frameBase64 })
32
+ console.log(result.matched) // true | false
33
+ ```
34
+
35
+ ## Environment Variables
36
+
37
+ | Variable | Required | Description |
38
+ |----------|----------|-------------|
39
+ | `VELIX_API_URL` | Yes | API base URL (`https://api.velixbiometrics.com`) |
40
+ | `VELIX_API_KEY` | Yes | Tenant API key (`vx_live_...` or `vx_sandbox_...`) |
41
+ | `VELIX_TIMEOUT` | No | Request timeout in ms (default: `30000`) |
42
+
43
+ ## Modules
44
+
45
+ | Module | Methods | Endpoint |
46
+ |--------|---------|----------|
47
+ | `OnboardingModule` | `enroll()` | `POST /v1/api/onboarding` |
48
+ | `CheckinModule` | `identify()` | `POST /v1/api/checkin/identify` |
49
+ | `LgpdModule` | `requestDeletion()` | `POST /v1/api/deletion-request` |
50
+ | `MeModule` | `get()` | `GET /v1/api/me/:personId` |
51
+ | `EventsModule` | `createGuest()`, `getGuest()` | `POST`/`GET /v1/api/events/:id/guests` |
52
+ | `TimeModule` | `punch()`, `getEspelho()` | não implementado — ver nota abaixo |
53
+
54
+ ## Checkin Module
55
+
56
+ ```typescript
57
+ import { CheckinModule } from '@velixbiometrics/sdk-core'
58
+ const checkin = new CheckinModule(client)
59
+
60
+ // Facial identification (base64 JPEG frame)
61
+ const result = await checkin.identify({ imageBase64: frameBase64 })
62
+ // { matched: true, personId: 'uuid', qualityScore: 0.91, message: '...' }
63
+
64
+ // With liveness challenge (token from GET /v1/public/checkin/{tenantSlug}/liveness/challenge)
65
+ const result2 = await checkin.identify({
66
+ imageBase64: frameBase64,
67
+ liveness: { token: challengeToken, samples: [{ action: 'center', imageBase64: frameBase64 }] },
68
+ })
69
+ ```
70
+
71
+ ## Onboarding Module
72
+
73
+ ```typescript
74
+ import { OnboardingModule } from '@velixbiometrics/sdk-core'
75
+ const onboarding = new OnboardingModule(client)
76
+
77
+ const result = await onboarding.enroll({
78
+ name: 'João Silva',
79
+ email: 'joao@company.com',
80
+ documentType: 'CPF',
81
+ document: '12345678900',
82
+ frames: [frame1, frame2, frame3],
83
+ })
84
+ // { personId: 'uuid', identityId: 'uuid', enrolled: true, framesProcessed: 3, ... }
85
+ ```
86
+
87
+ ## Me Module
88
+
89
+ ```typescript
90
+ import { MeModule } from '@velixbiometrics/sdk-core'
91
+ const me = new MeModule(client)
92
+
93
+ const person = await me.get('person-uuid')
94
+ ```
95
+
96
+ ## LGPD Module
97
+
98
+ ```typescript
99
+ import { LgpdModule } from '@velixbiometrics/sdk-core'
100
+ const lgpd = new LgpdModule(client)
101
+
102
+ const { protocolNumber } = await lgpd.requestDeletion({ personId: 'uuid' })
103
+ ```
104
+
105
+ ## Events Module (Velix Events — convidados)
106
+
107
+ ```typescript
108
+ import { EventsModule } from '@velixbiometrics/sdk-core'
109
+ const events = new EventsModule(client)
110
+
111
+ const guest = await events.createGuest('event-uuid', {
112
+ name: 'João Silva',
113
+ email: 'joao@company.com',
114
+ cpf: '12345678900',
115
+ })
116
+ const fetched = await events.getGuest('event-uuid', guest.id)
117
+ ```
118
+
119
+ ## Time Module
120
+
121
+ `api-velix-time` ainda não tem proxy público via `api-velix-identity-core` (gap de servidor, task #593). `TimeModule.punch()` e `TimeModule.getEspelho()` existem apenas para deixar isso explícito — **sempre lançam `VelixError`**, nunca simulam sucesso ou retornam dados falsos.
122
+
123
+ ## Error Handling
124
+
125
+ ```typescript
126
+ import { VelixError, VelixApiError, VelixNetworkError } from '@velixbiometrics/sdk-core'
127
+
128
+ try {
129
+ const result = await checkin.identify({ imageBase64: frame })
130
+ } catch (err) {
131
+ if (err instanceof VelixApiError) console.error(`HTTP ${err.status}: ${err.message}`)
132
+ if (err instanceof VelixNetworkError) console.error('Network error:', err.cause)
133
+ if (err instanceof VelixError) console.error(err.message)
134
+ }
135
+ ```
136
+
137
+ ## Running Tests
138
+
139
+ ```bash
140
+ npm test # all tests
141
+ npm test -- --coverage # with coverage
142
+ npm test -- --watch # watch mode
143
+ ```
144
+
145
+ Tests use axios mocks — no running service required.
146
+
147
+ ## Local Development
148
+
149
+ ```bash
150
+ npm install
151
+ npm run build # compile to dist/
152
+ npm run lint # eslint
153
+
154
+ # Link locally in another project
155
+ npm link
156
+ # In the consumer project:
157
+ npm link @velixbiometrics/sdk-core
158
+ ```
159
+
160
+ ## Get an API Key
161
+
162
+ Access the dashboard at **velixbiometrics.com** → Settings → API Keys → New Key.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@velixbiometrics/sdk-core",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Official TypeScript/JavaScript SDK for VELIX Biometrics — facial access control platform",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",