@neofaceid/web-sdk 1.24.1 → 1.25.4
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/index.d.ts +1365 -0
- package/dist/neoface-id-sdk.es.js +392 -113
- package/dist/neoface-id-sdk.umd.js +1 -1
- package/package.json +23 -3
- package/dist/logo-horizontal-branco-no-background.png +0 -0
- package/dist/logo-horizontal-preto-no-background.png +0 -0
- package/dist/logo-horizontal-preto.png +0 -0
- package/dist/logo-icone-no-background.png +0 -0
- package/dist/logo-icone.png +0 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,1365 @@
|
|
|
1
|
+
import { JSX as JSX_2 } from 'react/jsx-runtime';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Application registration data
|
|
6
|
+
*/
|
|
7
|
+
export declare interface ApplicationRegistrationData {
|
|
8
|
+
applicationName: string;
|
|
9
|
+
domain: string;
|
|
10
|
+
acceptOnlyEmailWithSameDomain: boolean;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Application registration result
|
|
15
|
+
*/
|
|
16
|
+
export declare interface ApplicationRegistrationResult {
|
|
17
|
+
success: boolean;
|
|
18
|
+
application: {
|
|
19
|
+
id: string;
|
|
20
|
+
application_name: string;
|
|
21
|
+
domain: string;
|
|
22
|
+
accept_only_email_with_same_domain: boolean;
|
|
23
|
+
app_token: string;
|
|
24
|
+
is_active: boolean;
|
|
25
|
+
created_at: string;
|
|
26
|
+
};
|
|
27
|
+
message: string;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export declare interface AuthorizationOptions {
|
|
31
|
+
onProgress?: (step: number, totalSteps: number, instruction: string) => void;
|
|
32
|
+
onPhotoTaken?: (photoNumber: number, blob: Blob) => void;
|
|
33
|
+
captureDelay?: number;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export declare interface AuthorizationResult {
|
|
37
|
+
success: boolean;
|
|
38
|
+
authorizationHash?: string;
|
|
39
|
+
name?: string;
|
|
40
|
+
birthDate?: string;
|
|
41
|
+
cpf?: string;
|
|
42
|
+
confidenceScore?: number;
|
|
43
|
+
message?: string;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* NEO-108: Authorization operation with multi-photo capture and gesture detection
|
|
48
|
+
*
|
|
49
|
+
* This function captures 4 sequential photos for authorization:
|
|
50
|
+
* - Photo 1: Front face
|
|
51
|
+
* - Photo 2: Left profile
|
|
52
|
+
* - Photo 3: Right profile
|
|
53
|
+
* - Photo 4: Thumbs up gesture with front face
|
|
54
|
+
*
|
|
55
|
+
* @param applicationToken The application token for authentication
|
|
56
|
+
* @param cpf The CPF of the person to authorize
|
|
57
|
+
* @param options Optional configuration for progress callbacks and delays
|
|
58
|
+
* @returns Promise with authorization result
|
|
59
|
+
* @throws NeoFaceError if capture or recognition fails
|
|
60
|
+
*/
|
|
61
|
+
export declare const authorizeOperation: (applicationToken: string, cpf: string, options?: AuthorizationOptions) => Promise<AuthorizationResult>;
|
|
62
|
+
|
|
63
|
+
export declare class BiometricCaptureModal {
|
|
64
|
+
private modal;
|
|
65
|
+
private video;
|
|
66
|
+
private canvas;
|
|
67
|
+
private stream;
|
|
68
|
+
private options;
|
|
69
|
+
private countdownInterval;
|
|
70
|
+
private isCapturing;
|
|
71
|
+
constructor(options: BiometricCaptureOptions);
|
|
72
|
+
/**
|
|
73
|
+
* Abre o modal de captura biométrica
|
|
74
|
+
*/
|
|
75
|
+
open(): Promise<void>;
|
|
76
|
+
/**
|
|
77
|
+
* Fecha o modal e limpa recursos
|
|
78
|
+
*/
|
|
79
|
+
close(): void;
|
|
80
|
+
/**
|
|
81
|
+
* Cria a estrutura HTML do modal
|
|
82
|
+
*/
|
|
83
|
+
private createModal;
|
|
84
|
+
/**
|
|
85
|
+
* Inicializa a câmera
|
|
86
|
+
*/
|
|
87
|
+
private initializeCamera;
|
|
88
|
+
/**
|
|
89
|
+
* Inicia a contagem regressiva
|
|
90
|
+
*/
|
|
91
|
+
private startCountdown;
|
|
92
|
+
/**
|
|
93
|
+
* Captura a imagem da câmera
|
|
94
|
+
*/
|
|
95
|
+
private captureImage;
|
|
96
|
+
/**
|
|
97
|
+
* Detecta o tipo biométrico na imagem (face ou mão)
|
|
98
|
+
*/
|
|
99
|
+
private detectBiometricType;
|
|
100
|
+
/**
|
|
101
|
+
* Adiciona event listeners aos elementos do modal
|
|
102
|
+
*/
|
|
103
|
+
private addEventListeners;
|
|
104
|
+
/**
|
|
105
|
+
* Limpa recursos (câmera, intervalos, etc.)
|
|
106
|
+
*/
|
|
107
|
+
private cleanup;
|
|
108
|
+
/**
|
|
109
|
+
* Retorna o título padrão baseado no modo
|
|
110
|
+
*/
|
|
111
|
+
private getDefaultTitle;
|
|
112
|
+
/**
|
|
113
|
+
* Retorna o subtítulo padrão baseado no modo
|
|
114
|
+
*/
|
|
115
|
+
private getDefaultSubtitle;
|
|
116
|
+
/**
|
|
117
|
+
* Adiciona estilos CSS ao modal
|
|
118
|
+
*/
|
|
119
|
+
private addStyles;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
declare interface BiometricCaptureOptions {
|
|
123
|
+
mode: 'face' | 'hand' | 'auto';
|
|
124
|
+
onSuccess: (imageData: string, detectedType: 'face' | 'hand') => void;
|
|
125
|
+
onError: (error: NeoFaceError) => void;
|
|
126
|
+
onCancel?: () => void;
|
|
127
|
+
countdown?: number;
|
|
128
|
+
title?: string;
|
|
129
|
+
subtitle?: string;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Função de conveniência para login biométrico simples
|
|
134
|
+
* @param applicationToken Token da aplicação
|
|
135
|
+
* @param mode Modo de captura ('face', 'hand' ou 'auto')
|
|
136
|
+
* @returns Promise que resolve com o resultado do login
|
|
137
|
+
*/
|
|
138
|
+
export declare function biometricLogin(applicationToken: string, mode?: 'face' | 'hand' | 'auto'): Promise<BiometricLoginResult>;
|
|
139
|
+
|
|
140
|
+
export declare interface BiometricLoginOptions {
|
|
141
|
+
applicationToken: string;
|
|
142
|
+
onSuccess: (result: BiometricLoginResult) => void;
|
|
143
|
+
onError: (error: NeoFaceError) => void;
|
|
144
|
+
onCancel?: () => void;
|
|
145
|
+
onFallbackRequest?: () => void;
|
|
146
|
+
countdown?: number;
|
|
147
|
+
title?: string;
|
|
148
|
+
subtitle?: string;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
export declare type BiometricLoginResult = z.infer<typeof BiometricLoginResultSchema>;
|
|
152
|
+
|
|
153
|
+
declare const BiometricLoginResultSchema: z.ZodObject<{
|
|
154
|
+
success: z.ZodBoolean;
|
|
155
|
+
accessToken: z.ZodOptional<z.ZodString>;
|
|
156
|
+
alias: z.ZodOptional<z.ZodString>;
|
|
157
|
+
user: z.ZodOptional<z.ZodObject<{
|
|
158
|
+
id: z.ZodString;
|
|
159
|
+
email: z.ZodString;
|
|
160
|
+
role: z.ZodString;
|
|
161
|
+
validated: z.ZodBoolean;
|
|
162
|
+
active: z.ZodBoolean;
|
|
163
|
+
}, z.core.$strip>>;
|
|
164
|
+
person: z.ZodOptional<z.ZodObject<{
|
|
165
|
+
id: z.ZodString;
|
|
166
|
+
name: z.ZodString;
|
|
167
|
+
birth_date: z.ZodString;
|
|
168
|
+
}, z.core.$strip>>;
|
|
169
|
+
confidence_score: z.ZodOptional<z.ZodNumber>;
|
|
170
|
+
recognition_id: z.ZodOptional<z.ZodString>;
|
|
171
|
+
task_id: z.ZodOptional<z.ZodString>;
|
|
172
|
+
status: z.ZodOptional<z.ZodString>;
|
|
173
|
+
message: z.ZodOptional<z.ZodString>;
|
|
174
|
+
}, z.core.$strip>;
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* Inicia o processo de login biométrico com fallback para email e senha se não houver match (assumindo purpose LOGIN).
|
|
178
|
+
* @param applicationToken Token da aplicação
|
|
179
|
+
* @param mode Modo de captura ('face', 'hand' ou 'auto')
|
|
180
|
+
* @returns Promise que resolve com o resultado do login
|
|
181
|
+
*/
|
|
182
|
+
export declare function biometricLoginWithFallback(applicationToken: string, mode?: 'face' | 'hand' | 'auto'): Promise<BiometricLoginResult>;
|
|
183
|
+
|
|
184
|
+
declare interface BiometricRegistrationCallbacks {
|
|
185
|
+
onSuccess(result: BiometricRegistrationResult): void;
|
|
186
|
+
onError(code: string, message: string): void;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
export declare function BiometricRegistrationModal({ personData, applicationToken, onClose, onSuccess, onPhotosCaptured, onError, }: BiometricRegistrationModalProps): JSX_2.Element;
|
|
190
|
+
|
|
191
|
+
declare interface BiometricRegistrationModalProps {
|
|
192
|
+
personData?: {
|
|
193
|
+
name: string;
|
|
194
|
+
birth_date: string;
|
|
195
|
+
cpf: string;
|
|
196
|
+
email: string;
|
|
197
|
+
password: string;
|
|
198
|
+
};
|
|
199
|
+
applicationToken?: string;
|
|
200
|
+
onClose: () => void;
|
|
201
|
+
onSuccess?: (result: BiometricRegistrationResult_2) => void;
|
|
202
|
+
onPhotosCaptured?: (photos: Blob[]) => void;
|
|
203
|
+
onError: (error: string) => void;
|
|
204
|
+
useRealApi?: boolean;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
declare interface BiometricRegistrationResult {
|
|
208
|
+
success: boolean;
|
|
209
|
+
message: string;
|
|
210
|
+
person_id?: string;
|
|
211
|
+
user_id?: string;
|
|
212
|
+
person_validated?: boolean;
|
|
213
|
+
face_processing?: any;
|
|
214
|
+
onboarding_link?: string;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
declare interface BiometricRegistrationResult_2 {
|
|
218
|
+
success: boolean;
|
|
219
|
+
message: string;
|
|
220
|
+
person_id?: string;
|
|
221
|
+
user_id?: string;
|
|
222
|
+
person_validated?: boolean;
|
|
223
|
+
face_processing?: any;
|
|
224
|
+
onboarding_link?: string;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
/**
|
|
228
|
+
* Overlay minimalista estilo FaceID para login biométrico
|
|
229
|
+
* Implementação vanilla JS (sem React) para evitar conflitos de versão
|
|
230
|
+
*/
|
|
231
|
+
export declare class BiometricStatusOverlay {
|
|
232
|
+
private container;
|
|
233
|
+
private currentStatus;
|
|
234
|
+
private getStyles;
|
|
235
|
+
private getStatusText;
|
|
236
|
+
private renderContent;
|
|
237
|
+
show(status?: OverlayStatus): void;
|
|
238
|
+
updateStatus(status: OverlayStatus): void;
|
|
239
|
+
close(): void;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
declare interface Callbacks {
|
|
243
|
+
onSuccess(user: {
|
|
244
|
+
name: string;
|
|
245
|
+
email: string;
|
|
246
|
+
documentId: string;
|
|
247
|
+
}): void;
|
|
248
|
+
onError(code: string, message: string): void;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
/**
|
|
252
|
+
* Options for capturing face frames
|
|
253
|
+
*/
|
|
254
|
+
export declare interface CaptureFaceFramesOptions {
|
|
255
|
+
numFrames: number;
|
|
256
|
+
livenessCheck: boolean;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
/**
|
|
260
|
+
* Check if a user exists by email or CPF
|
|
261
|
+
* @param params Object with email or cpf to check (only one at a time)
|
|
262
|
+
* @returns Promise with existence status
|
|
263
|
+
* @throws NeoFaceError if verification fails
|
|
264
|
+
*
|
|
265
|
+
* @example
|
|
266
|
+
* ```typescript
|
|
267
|
+
* const result = await checkUserExistence({ email: 'user@example.com' });
|
|
268
|
+
* if (result.data.exists) {
|
|
269
|
+
* console.log('User already exists');
|
|
270
|
+
* }
|
|
271
|
+
* ```
|
|
272
|
+
*/
|
|
273
|
+
export declare const checkUserExistence: (params: {
|
|
274
|
+
email?: string;
|
|
275
|
+
cpf?: string;
|
|
276
|
+
}) => Promise<UserExistenceResult>;
|
|
277
|
+
|
|
278
|
+
/**
|
|
279
|
+
* Conclui o processo de onboarding enviando imagens de face e documento
|
|
280
|
+
* @param applicationToken Token da aplicação (header `X-App-Token`)
|
|
281
|
+
* @param onboardingToken Token do link de onboarding
|
|
282
|
+
* @param faceImage Blob da imagem de rosto
|
|
283
|
+
* @param documentImage Blob da imagem do documento
|
|
284
|
+
* @returns Resposta da conclusão do onboarding
|
|
285
|
+
* @throws NeoFaceError em caso de falha de rede ou validação
|
|
286
|
+
*/
|
|
287
|
+
export declare const completeOnboarding: (applicationToken: string, onboardingToken: string, faceImage: Blob, documentImage: Blob) => Promise<{
|
|
288
|
+
success: boolean;
|
|
289
|
+
message: string;
|
|
290
|
+
person_id?: string;
|
|
291
|
+
identity_data_id?: string;
|
|
292
|
+
confidence_score?: number;
|
|
293
|
+
processing_time?: number;
|
|
294
|
+
}>;
|
|
295
|
+
|
|
296
|
+
/**
|
|
297
|
+
* Conclui o processo de onboarding com dados completos da pessoa
|
|
298
|
+
*
|
|
299
|
+
* RECEBE:
|
|
300
|
+
* - Nome, DataDeNascimento, CPF, CNPJ, Email
|
|
301
|
+
* - Imagens da Pessoa (array de Blobs)
|
|
302
|
+
* - Imagem do documento
|
|
303
|
+
*
|
|
304
|
+
* AÇÃO (backend):
|
|
305
|
+
* - Se não é cadastrado no NeoFaceId, cadastra-o
|
|
306
|
+
* - Escaneia o documento e confere com os dados passados
|
|
307
|
+
* - Confere se a imagem/vídeo passa nos critérios de prova de vida
|
|
308
|
+
*
|
|
309
|
+
* @param applicationToken Token da aplicação (header `X-App-Token`)
|
|
310
|
+
* @param onboardingToken Token do link de onboarding
|
|
311
|
+
* @param personData Dados da pessoa (Nome, DataDeNascimento, CPF, CNPJ, Email)
|
|
312
|
+
* @param personImages Array de imagens/vídeos da pessoa para prova de vida (mínimo 1)
|
|
313
|
+
* @param documentImage Blob da imagem do documento
|
|
314
|
+
* @returns Resposta da conclusão do onboarding
|
|
315
|
+
* @throws NeoFaceError em caso de falha de rede ou validação
|
|
316
|
+
*/
|
|
317
|
+
export declare const completeOnboardingWithData: (applicationToken: string, onboardingToken: string, personData: OnboardingPersonData, personImages: Blob[], documentImage: Blob) => Promise<{
|
|
318
|
+
success: boolean;
|
|
319
|
+
message: string;
|
|
320
|
+
person_id?: string;
|
|
321
|
+
identity_data_id?: string;
|
|
322
|
+
confidence_score?: number;
|
|
323
|
+
processing_time?: number;
|
|
324
|
+
liveness_passed?: boolean;
|
|
325
|
+
document_verified?: boolean;
|
|
326
|
+
person_created?: boolean;
|
|
327
|
+
}>;
|
|
328
|
+
|
|
329
|
+
/**
|
|
330
|
+
* Confirm password reset using token
|
|
331
|
+
* @param token Reset token received via email
|
|
332
|
+
* @param new_password New password
|
|
333
|
+
*/
|
|
334
|
+
export declare function confirmPasswordReset(token: string, new_password: string): Promise<{
|
|
335
|
+
message: string;
|
|
336
|
+
}>;
|
|
337
|
+
|
|
338
|
+
export declare interface ConsentInfo {
|
|
339
|
+
purpose: string;
|
|
340
|
+
legalBasis: string;
|
|
341
|
+
privacyPolicyUrl: string;
|
|
342
|
+
retentionDays: number;
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
/**
|
|
346
|
+
* Gerencia o ciclo de vida (montagem/desmontagem) do modal de consentimento.
|
|
347
|
+
*/
|
|
348
|
+
export declare class ConsentModal {
|
|
349
|
+
private container;
|
|
350
|
+
private root;
|
|
351
|
+
show(props: ConsentModalProps): void;
|
|
352
|
+
close(): void;
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
/**
|
|
356
|
+
* Props do modal de consentimento LGPD exibido antes de qualquer captura de câmera.
|
|
357
|
+
*/
|
|
358
|
+
export declare interface ConsentModalProps {
|
|
359
|
+
purpose: string;
|
|
360
|
+
legalBasis: string;
|
|
361
|
+
privacyPolicyUrl: string;
|
|
362
|
+
retentionDays: number;
|
|
363
|
+
onAccept: () => void;
|
|
364
|
+
onDecline: () => void;
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
/**
|
|
368
|
+
* Defaults conservadores usados enquanto `SDKInitOptions` não expõe `consent` (US7.2).
|
|
369
|
+
* Quando essa opção existir, este helper passa a ler `getConfig().consent`.
|
|
370
|
+
*/
|
|
371
|
+
export declare const DEFAULT_CONSENT_INFO: ConsentInfo;
|
|
372
|
+
|
|
373
|
+
/**
|
|
374
|
+
* Detecta automaticamente o tipo biométrico na imagem
|
|
375
|
+
* @param imageData Dados da imagem em base64
|
|
376
|
+
* @returns Resultado da detecção com tipo e confiança
|
|
377
|
+
*/
|
|
378
|
+
export declare function detectBiometricType(imageData: string): Promise<DetectionResult>;
|
|
379
|
+
|
|
380
|
+
/**
|
|
381
|
+
* Módulo de detecção automática de tipo biométrico
|
|
382
|
+
* Utiliza face-api.js para detectar se a imagem contém face ou mão
|
|
383
|
+
*/
|
|
384
|
+
export declare interface DetectionResult {
|
|
385
|
+
type: 'face' | 'hand' | 'unknown';
|
|
386
|
+
confidence: number;
|
|
387
|
+
details?: any;
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
export declare class DocumentCaptureModal {
|
|
391
|
+
private overlay;
|
|
392
|
+
private video;
|
|
393
|
+
private canvas;
|
|
394
|
+
private stream;
|
|
395
|
+
private resolvePromise;
|
|
396
|
+
private options;
|
|
397
|
+
private selectedDocument;
|
|
398
|
+
private currentStep;
|
|
399
|
+
private frontBlob;
|
|
400
|
+
private backBlob;
|
|
401
|
+
constructor(options?: DocumentCaptureOptions);
|
|
402
|
+
open(): Promise<DocumentCaptureResult>;
|
|
403
|
+
private render;
|
|
404
|
+
private createOverlay;
|
|
405
|
+
private renderSelectStep;
|
|
406
|
+
private renderCaptureStep;
|
|
407
|
+
private renderPreviewStep;
|
|
408
|
+
private renderBranding;
|
|
409
|
+
private bindSelectEvents;
|
|
410
|
+
private bindCaptureEvents;
|
|
411
|
+
private handleFileUpload;
|
|
412
|
+
private compressUploadedImage;
|
|
413
|
+
private bindPreviewEvents;
|
|
414
|
+
private bindCloseEvent;
|
|
415
|
+
private startCamera;
|
|
416
|
+
private stopCamera;
|
|
417
|
+
private handleCapture;
|
|
418
|
+
private handleBack;
|
|
419
|
+
private handleRetake;
|
|
420
|
+
private handleConfirm;
|
|
421
|
+
private handleCancel;
|
|
422
|
+
private close;
|
|
423
|
+
private getStyles;
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
export declare interface DocumentCaptureOptions {
|
|
427
|
+
title?: string;
|
|
428
|
+
subtitle?: string;
|
|
429
|
+
useBackCamera?: boolean;
|
|
430
|
+
onCancel?: () => void;
|
|
431
|
+
preSelectedDocument?: DocumentType_2;
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
export declare interface DocumentCaptureResult {
|
|
435
|
+
success: boolean;
|
|
436
|
+
documentType?: DocumentType_2;
|
|
437
|
+
frontImage: Blob | null;
|
|
438
|
+
backImage: Blob | null;
|
|
439
|
+
error?: string;
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
/**
|
|
443
|
+
* Modal de captura de documento para validação de identidade
|
|
444
|
+
* Suporta RG, CNH e CPF com etapas de frente e verso quando aplicável
|
|
445
|
+
*/
|
|
446
|
+
declare type DocumentType_2 = 'RG' | 'CNH' | 'CPF';
|
|
447
|
+
export { DocumentType_2 as DocumentType }
|
|
448
|
+
|
|
449
|
+
/**
|
|
450
|
+
* Modal para entrada de email e senha como fallback para login.
|
|
451
|
+
*/
|
|
452
|
+
export declare class EmailPasswordModal {
|
|
453
|
+
private options;
|
|
454
|
+
private modalElement;
|
|
455
|
+
constructor(options: EmailPasswordOptions);
|
|
456
|
+
/**
|
|
457
|
+
* Abre o modal de login com email e senha.
|
|
458
|
+
*/
|
|
459
|
+
open(): Promise<void>;
|
|
460
|
+
/**
|
|
461
|
+
* Fecha o modal.
|
|
462
|
+
*/
|
|
463
|
+
close(): void;
|
|
464
|
+
private createModal;
|
|
465
|
+
private addStyles;
|
|
466
|
+
private handleSubmit;
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
export declare interface EmailPasswordOptions {
|
|
470
|
+
applicationToken: string;
|
|
471
|
+
onSuccess: (result: BiometricLoginResult) => void;
|
|
472
|
+
onError: (error: NeoFaceError) => void;
|
|
473
|
+
onCancel?: () => void;
|
|
474
|
+
title?: string;
|
|
475
|
+
subtitle?: string;
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
/**
|
|
479
|
+
* SDK Global Configuration
|
|
480
|
+
*
|
|
481
|
+
* Este módulo gerencia a configuração global do SDK, permitindo
|
|
482
|
+
* inicialização com detecção automática de ambiente ou override manual.
|
|
483
|
+
*/
|
|
484
|
+
export declare type Environment = 'development' | 'sandbox' | 'production';
|
|
485
|
+
|
|
486
|
+
/**
|
|
487
|
+
* Mapeamento de ambientes para URLs base da API
|
|
488
|
+
*/
|
|
489
|
+
export declare const ENVIRONMENT_URLS: Record<Environment, string>;
|
|
490
|
+
|
|
491
|
+
/**
|
|
492
|
+
* Tipos padronizados de erro do SDK NeoFace ID.
|
|
493
|
+
* Utilize estes tipos para categorizar e tratar erros de forma consistente.
|
|
494
|
+
*/
|
|
495
|
+
export declare enum ErrorType {
|
|
496
|
+
NETWORK = "NetworkError",
|
|
497
|
+
NETWORK_ERROR = "NetworkError",
|
|
498
|
+
INVALID_TOKEN = "InvalidTokenError",
|
|
499
|
+
RECOGNITION_FAILED = "RecognitionFailedError",
|
|
500
|
+
LOGIN_FAILED = "LoginFailedError",
|
|
501
|
+
VALIDATION_ERROR = "ValidationError",
|
|
502
|
+
API_ERROR = "ApiError",
|
|
503
|
+
PERSON_NOT_FOUND = "PersonNotFoundError",
|
|
504
|
+
INITIALIZATION_ERROR = "InitializationError",
|
|
505
|
+
CAMERA_ERROR = "CameraError",
|
|
506
|
+
NO_CAMERA = "NoCameraError",
|
|
507
|
+
CAPTURE_ERROR = "CaptureError",
|
|
508
|
+
NOT_FOUND = "NotFoundError",
|
|
509
|
+
UNKNOWN = "UnknownError",
|
|
510
|
+
CONSENT_DENIED = "ConsentDeniedError"
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
export declare function FaceCaptureModal({ accessToken, onClose, onSuccess }: FaceCaptureModalProps): JSX_2.Element;
|
|
514
|
+
|
|
515
|
+
declare interface FaceCaptureModalProps {
|
|
516
|
+
accessToken: string;
|
|
517
|
+
onClose: () => void;
|
|
518
|
+
onSuccess: (result: RecognitionResult) => void;
|
|
519
|
+
}
|
|
520
|
+
|
|
521
|
+
/**
|
|
522
|
+
* Classe para gerenciar o prompt de fallback
|
|
523
|
+
*/
|
|
524
|
+
export declare class FallbackPrompt {
|
|
525
|
+
private container;
|
|
526
|
+
private root;
|
|
527
|
+
/**
|
|
528
|
+
* Exibe o prompt de fallback
|
|
529
|
+
*/
|
|
530
|
+
show(error: NeoFaceError | undefined, onRetry: () => void, onCredentials: () => void, onCancel?: () => void, applicationToken?: string): void;
|
|
531
|
+
/**
|
|
532
|
+
* Fecha o prompt
|
|
533
|
+
*/
|
|
534
|
+
close(): void;
|
|
535
|
+
/**
|
|
536
|
+
* Renderiza o componente
|
|
537
|
+
*/
|
|
538
|
+
private render;
|
|
539
|
+
}
|
|
540
|
+
|
|
541
|
+
/**
|
|
542
|
+
* Modal de recuperação de senha — self-contained, sem dependência de rotas externas.
|
|
543
|
+
* Segue o mesmo padrão visual do EmailPasswordModal (vanilla JS, overlay dark).
|
|
544
|
+
*/
|
|
545
|
+
export declare class ForgotPasswordModal {
|
|
546
|
+
private applicationToken;
|
|
547
|
+
private modalElement;
|
|
548
|
+
constructor(applicationToken: string);
|
|
549
|
+
open(): void;
|
|
550
|
+
close(): void;
|
|
551
|
+
private renderEmailForm;
|
|
552
|
+
private renderSuccess;
|
|
553
|
+
private handleSubmit;
|
|
554
|
+
private addStyles;
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
/**
|
|
558
|
+
* Retorna o token de aplicação configurado, se houver.
|
|
559
|
+
*/
|
|
560
|
+
export declare function getApplicationToken(): string | null;
|
|
561
|
+
|
|
562
|
+
/**
|
|
563
|
+
* Retorna a URL base configurada para a API.
|
|
564
|
+
* Se o SDK não foi inicializado, retorna o fallback para sandbox.
|
|
565
|
+
*/
|
|
566
|
+
export declare function getBaseUrl(): string;
|
|
567
|
+
|
|
568
|
+
/**
|
|
569
|
+
* Retorna toda a configuração atual (para debug).
|
|
570
|
+
*/
|
|
571
|
+
export declare function getConfig(): Readonly<SDKConfig>;
|
|
572
|
+
|
|
573
|
+
/**
|
|
574
|
+
* Retorna o ambiente atual configurado.
|
|
575
|
+
*/
|
|
576
|
+
export declare function getEnvironment(): Environment | 'custom';
|
|
577
|
+
|
|
578
|
+
/**
|
|
579
|
+
* Identifies a person from an image and returns name and age
|
|
580
|
+
* @param image The image blob to process
|
|
581
|
+
* @param applicationToken The application token for authentication
|
|
582
|
+
* @returns Promise with person name and age
|
|
583
|
+
* @throws NeoFaceError if request fails
|
|
584
|
+
* @throws NeoFaceError if identification fails
|
|
585
|
+
*/
|
|
586
|
+
export declare const identifyPerson: (image: Blob, applicationToken: string) => Promise<{
|
|
587
|
+
success: boolean;
|
|
588
|
+
taskId?: string;
|
|
589
|
+
status?: string;
|
|
590
|
+
person?: {
|
|
591
|
+
name: string;
|
|
592
|
+
birth_date: string;
|
|
593
|
+
};
|
|
594
|
+
message?: string;
|
|
595
|
+
}>;
|
|
596
|
+
|
|
597
|
+
/**
|
|
598
|
+
* High-level helper that identifies a person and waits for the result (polling)
|
|
599
|
+
* @param image The image blob to process
|
|
600
|
+
* @param applicationToken The application token
|
|
601
|
+
* @param options Polling options (maxRetries, interval)
|
|
602
|
+
*/
|
|
603
|
+
export declare const identifyPersonAsync: (image: Blob, applicationToken: string, options?: {
|
|
604
|
+
maxRetries?: number;
|
|
605
|
+
interval?: number;
|
|
606
|
+
}) => Promise<{
|
|
607
|
+
personFound: boolean;
|
|
608
|
+
person?: {
|
|
609
|
+
name: string;
|
|
610
|
+
birth_date: string;
|
|
611
|
+
};
|
|
612
|
+
}>;
|
|
613
|
+
|
|
614
|
+
/**
|
|
615
|
+
* Inicializa o SDK com as configurações fornecidas.
|
|
616
|
+
* Deve ser chamado uma vez no início da aplicação, antes de usar qualquer função do SDK.
|
|
617
|
+
*
|
|
618
|
+
* @example
|
|
619
|
+
* ```typescript
|
|
620
|
+
* import { init } from '@neofaceid/web-sdk';
|
|
621
|
+
*
|
|
622
|
+
* // Usando ambiente predefinido
|
|
623
|
+
* init({ environment: 'production' });
|
|
624
|
+
*
|
|
625
|
+
* // Usando URL customizada
|
|
626
|
+
* init({ baseUrl: 'https://my-custom-api.com' });
|
|
627
|
+
*
|
|
628
|
+
* // Com token de aplicação
|
|
629
|
+
* init({
|
|
630
|
+
* environment: 'sandbox',
|
|
631
|
+
* applicationToken: 'your-app-token'
|
|
632
|
+
* });
|
|
633
|
+
* ```
|
|
634
|
+
*
|
|
635
|
+
* @param options Opções de inicialização
|
|
636
|
+
*/
|
|
637
|
+
export declare function init(options?: SDKInitOptions): void;
|
|
638
|
+
|
|
639
|
+
/**
|
|
640
|
+
* Inicializa o sistema de detecção biométrica
|
|
641
|
+
* Carrega bibliotecas e modelos necessários
|
|
642
|
+
*/
|
|
643
|
+
export declare function initializeBiometricDetection(): Promise<void>;
|
|
644
|
+
|
|
645
|
+
/**
|
|
646
|
+
* Verifica se o sistema de detecção está disponível
|
|
647
|
+
* @returns true se a detecção avançada está disponível
|
|
648
|
+
*/
|
|
649
|
+
export declare function isAdvancedDetectionAvailable(): boolean;
|
|
650
|
+
|
|
651
|
+
/**
|
|
652
|
+
* Verifica se o SDK foi inicializado.
|
|
653
|
+
*/
|
|
654
|
+
export declare function isInitialized(): boolean;
|
|
655
|
+
|
|
656
|
+
/**
|
|
657
|
+
* Options for login recognition
|
|
658
|
+
*/
|
|
659
|
+
export declare interface LoginRecognitionOptions {
|
|
660
|
+
biometricData: Blob | Blob[];
|
|
661
|
+
typeOfIdentification: 'FACE' | 'HAND';
|
|
662
|
+
purpose: 'LOGIN' | 'PROOF_OF_LIFE' | 'AUTHORIZATION' | 'SIMPLE_IDENTIFICATION' | 'SIMPLIFIED_REGISTRATION';
|
|
663
|
+
confidenceThreshold?: number;
|
|
664
|
+
}
|
|
665
|
+
|
|
666
|
+
/**
|
|
667
|
+
* Result of login recognition
|
|
668
|
+
*/
|
|
669
|
+
export declare interface LoginRecognitionResult {
|
|
670
|
+
success: boolean;
|
|
671
|
+
personName: string;
|
|
672
|
+
email: string;
|
|
673
|
+
cpf: string;
|
|
674
|
+
signature?: string;
|
|
675
|
+
sessionId?: string;
|
|
676
|
+
confidenceScore?: number;
|
|
677
|
+
accessToken?: string;
|
|
678
|
+
}
|
|
679
|
+
|
|
680
|
+
/**
|
|
681
|
+
* Performs biometric login using face recognition
|
|
682
|
+
* @param image The image blob to process
|
|
683
|
+
* @param applicationToken The application token for authentication
|
|
684
|
+
* @returns Promise with login result
|
|
685
|
+
* @throws NeoFaceError if request fails
|
|
686
|
+
*/
|
|
687
|
+
export declare const loginWithBiometric: (image: Blob, applicationToken: string) => Promise<BiometricLoginResult>;
|
|
688
|
+
|
|
689
|
+
/**
|
|
690
|
+
* Performs login using email and password
|
|
691
|
+
* @param email User's email
|
|
692
|
+
* @param password User's password
|
|
693
|
+
* @param applicationToken The application token for authentication
|
|
694
|
+
/**
|
|
695
|
+
* @returns Promise with login result
|
|
696
|
+
* @throws NeoFaceError if request fails
|
|
697
|
+
*/
|
|
698
|
+
export declare const loginWithEmail: (email: string, password: string, applicationToken: string) => Promise<BiometricLoginResult>;
|
|
699
|
+
|
|
700
|
+
/**
|
|
701
|
+
* Erro customizado do SDK que carrega um tipo semântico.
|
|
702
|
+
* Permite aos consumidores diferenciar falhas por categoria com `error.type`.
|
|
703
|
+
*/
|
|
704
|
+
export declare class NeoFaceError extends Error {
|
|
705
|
+
type: ErrorType;
|
|
706
|
+
/**
|
|
707
|
+
* Constrói um erro do SDK com mensagem e tipo categórico.
|
|
708
|
+
* @param message Mensagem descritiva do erro (pode ser técnica)
|
|
709
|
+
* @param type Tipo categórico do erro
|
|
710
|
+
*/
|
|
711
|
+
constructor(message: string, type: ErrorType);
|
|
712
|
+
/**
|
|
713
|
+
* Retorna uma mensagem amigável para o usuário final, ocultando termos técnicos.
|
|
714
|
+
*/
|
|
715
|
+
getFriendlyMessage(): string;
|
|
716
|
+
}
|
|
717
|
+
|
|
718
|
+
/**
|
|
719
|
+
* NeoFaceID SDK class for biometric authentication
|
|
720
|
+
*
|
|
721
|
+
* This class provides a high-level API for biometric recognition,
|
|
722
|
+
* supporting both internal use (without signature) and external integrations
|
|
723
|
+
* (with signature and session data for systems like OpsPay).
|
|
724
|
+
*
|
|
725
|
+
* @example
|
|
726
|
+
* ```typescript
|
|
727
|
+
* // For external integrations (with signature)
|
|
728
|
+
* const sdk = new NeoFaceID({
|
|
729
|
+
* appToken: 'your-application-token',
|
|
730
|
+
* baseUrl: 'https://core.neofaceid.com',
|
|
731
|
+
* signature: signatureFromBackend,
|
|
732
|
+
* sessionData: {
|
|
733
|
+
* email: 'user@example.com',
|
|
734
|
+
* cpf: '12345678901',
|
|
735
|
+
* sessionId: 'session-uuid-123'
|
|
736
|
+
* }
|
|
737
|
+
* });
|
|
738
|
+
*
|
|
739
|
+
* // For internal use (without signature)
|
|
740
|
+
* const sdk = new NeoFaceID({
|
|
741
|
+
* appToken: 'your-application-token'
|
|
742
|
+
* });
|
|
743
|
+
* ```
|
|
744
|
+
*/
|
|
745
|
+
export declare class NeoFaceID {
|
|
746
|
+
private appToken;
|
|
747
|
+
private signature?;
|
|
748
|
+
private sessionData?;
|
|
749
|
+
/**
|
|
750
|
+
* Creates a new NeoFaceID instance
|
|
751
|
+
* @param config Configuration object
|
|
752
|
+
* @throws NeoFaceError if signature format is invalid
|
|
753
|
+
*/
|
|
754
|
+
constructor(config: NeoFaceIDConfig);
|
|
755
|
+
/**
|
|
756
|
+
* Validates the format of a signature
|
|
757
|
+
* HMAC-SHA256 produces a 64-character hexadecimal string
|
|
758
|
+
* @param signature The signature to validate
|
|
759
|
+
* @returns true if valid, false otherwise
|
|
760
|
+
*/
|
|
761
|
+
private validateSignatureFormat;
|
|
762
|
+
/**
|
|
763
|
+
* Captures multiple face frames for biometric recognition
|
|
764
|
+
* @param options Capture options
|
|
765
|
+
* @returns Promise that resolves to an array of image blobs
|
|
766
|
+
* @throws NeoFaceError if capture fails
|
|
767
|
+
*/
|
|
768
|
+
captureFaceFrames(options: CaptureFaceFramesOptions): Promise<Blob[]>;
|
|
769
|
+
/**
|
|
770
|
+
* Performs login recognition using biometric data
|
|
771
|
+
*
|
|
772
|
+
* This method is designed for external integrations that require
|
|
773
|
+
* signature validation and session management.
|
|
774
|
+
*
|
|
775
|
+
* @param options Recognition options
|
|
776
|
+
* @returns Promise that resolves to recognition result
|
|
777
|
+
* @throws NeoFaceError if recognition fails
|
|
778
|
+
*
|
|
779
|
+
* @example
|
|
780
|
+
* ```typescript
|
|
781
|
+
* const result = await sdk.loginRecognition({
|
|
782
|
+
* biometricData: await sdk.captureFaceFrames({
|
|
783
|
+
* numFrames: 5,
|
|
784
|
+
* livenessCheck: true
|
|
785
|
+
* }),
|
|
786
|
+
* typeOfIdentification: 'FACE',
|
|
787
|
+
* purpose: 'LOGIN',
|
|
788
|
+
* confidenceThreshold: 0.8
|
|
789
|
+
* });
|
|
790
|
+
*
|
|
791
|
+
* // Result includes signature and sessionId for callback validation
|
|
792
|
+
* console.log(result.signature, result.sessionId);
|
|
793
|
+
* ```
|
|
794
|
+
*/
|
|
795
|
+
loginRecognition(options: LoginRecognitionOptions): Promise<LoginRecognitionResult>;
|
|
796
|
+
/**
|
|
797
|
+
* Register a new application for a consumer
|
|
798
|
+
*
|
|
799
|
+
* This method allows authenticated users to register new applications
|
|
800
|
+
* that will receive their own app_token for API access.
|
|
801
|
+
*
|
|
802
|
+
* @param jwtToken JWT authentication token from logged user
|
|
803
|
+
* @param consumerId Consumer ID (UUID) who will own the application
|
|
804
|
+
* @param applicationData Application registration data
|
|
805
|
+
* @returns Promise with registration result including app_token
|
|
806
|
+
* @throws NeoFaceError if registration fails
|
|
807
|
+
*
|
|
808
|
+
* @example
|
|
809
|
+
* ```typescript
|
|
810
|
+
* const sdk = new NeoFaceID({
|
|
811
|
+
* appToken: 'your-application-token'
|
|
812
|
+
* });
|
|
813
|
+
*
|
|
814
|
+
* const result = await sdk.registerApplication(
|
|
815
|
+
* userJwtToken,
|
|
816
|
+
* consumerUuid,
|
|
817
|
+
* {
|
|
818
|
+
* applicationName: 'My New App',
|
|
819
|
+
* domain: 'example.com',
|
|
820
|
+
* acceptOnlyEmailWithSameDomain: true
|
|
821
|
+
* }
|
|
822
|
+
* );
|
|
823
|
+
*
|
|
824
|
+
* // Use the generated app_token for the new application
|
|
825
|
+
* console.log('New App Token:', result.application.app_token);
|
|
826
|
+
* ```
|
|
827
|
+
*/
|
|
828
|
+
registerApplication(jwtToken: string, consumerId: string, applicationData: ApplicationRegistrationData): Promise<ApplicationRegistrationResult>;
|
|
829
|
+
/**
|
|
830
|
+
* Performs Proof of Life verification
|
|
831
|
+
*
|
|
832
|
+
* This method records a video from the camera, sends it to the backend
|
|
833
|
+
* for liveness detection and face recognition, and returns the result
|
|
834
|
+
* with personal data filtered by purpose.
|
|
835
|
+
*
|
|
836
|
+
* The process is asynchronous:
|
|
837
|
+
* 1. Records video from the camera (default 3 seconds)
|
|
838
|
+
* 2. Converts video to base64 and sends to backend
|
|
839
|
+
* 3. Backend processes liveness detection and face recognition
|
|
840
|
+
* 4. Polls for task completion
|
|
841
|
+
* 5. Returns personal data of the identified person
|
|
842
|
+
*
|
|
843
|
+
* @param options Configuration options for the proof of life process
|
|
844
|
+
* @returns Promise that resolves to ProofOfLifeResult
|
|
845
|
+
* @throws NeoFaceError if verification fails
|
|
846
|
+
*
|
|
847
|
+
* @example
|
|
848
|
+
* ```typescript
|
|
849
|
+
* const sdk = new NeoFaceID({
|
|
850
|
+
* appToken: 'your-application-token'
|
|
851
|
+
* });
|
|
852
|
+
*
|
|
853
|
+
* const result = await sdk.proofOfLife({
|
|
854
|
+
* videoDurationMs: 3000, // 3 seconds
|
|
855
|
+
* onRecordingProgress: (progress) => {
|
|
856
|
+
* console.log(`Recording: ${progress}%`);
|
|
857
|
+
* },
|
|
858
|
+
* onTaskStatusChange: (status, progress) => {
|
|
859
|
+
* console.log(`Status: ${status}, Progress: ${progress}%`);
|
|
860
|
+
* }
|
|
861
|
+
* });
|
|
862
|
+
*
|
|
863
|
+
* if (result.success && result.isLive) {
|
|
864
|
+
* console.log('Person verified:', result.personalData);
|
|
865
|
+
* console.log('Liveness score:', result.livenessScore);
|
|
866
|
+
* console.log('Face recognition score:', result.faceRecognitionScore);
|
|
867
|
+
* }
|
|
868
|
+
* ```
|
|
869
|
+
*/
|
|
870
|
+
/**
|
|
871
|
+
* Registers document images for an already-registered donor person.
|
|
872
|
+
*
|
|
873
|
+
* Opens the document capture UI (front + optional back), then submits
|
|
874
|
+
* the images to the backend for extraction via DocExt.
|
|
875
|
+
* The backend processes this asynchronously — use the returned `taskId`
|
|
876
|
+
* to poll status if needed.
|
|
877
|
+
*
|
|
878
|
+
* @param personId UUID of the donor's person record
|
|
879
|
+
* @param jwtToken JWT Bearer token of the authenticated donor
|
|
880
|
+
* @param options Optional capture configuration
|
|
881
|
+
* @returns Promise with task_id and processing status
|
|
882
|
+
* @throws NeoFaceError if capture is cancelled, validation fails, or API call fails
|
|
883
|
+
*
|
|
884
|
+
* @example
|
|
885
|
+
* ```typescript
|
|
886
|
+
* const sdk = new NeoFaceID({ appToken: 'your-token' });
|
|
887
|
+
*
|
|
888
|
+
* const result = await sdk.registerDocumentByImage(personId, userJwtToken);
|
|
889
|
+
* console.log('Task ID:', result.taskId); // poll for completion
|
|
890
|
+
* ```
|
|
891
|
+
*/
|
|
892
|
+
registerDocumentByImage(personId: string, jwtToken: string, options?: RegisterDocumentByImageOptions): Promise<RegisterDocumentResult>;
|
|
893
|
+
proofOfLife(options?: ProofOfLifeOptions): Promise<ProofOfLifeResult>;
|
|
894
|
+
}
|
|
895
|
+
|
|
896
|
+
/**
|
|
897
|
+
* Configuration for NeoFaceID SDK initialization
|
|
898
|
+
*/
|
|
899
|
+
export declare interface NeoFaceIDConfig {
|
|
900
|
+
appToken: string;
|
|
901
|
+
baseUrl?: string;
|
|
902
|
+
signature?: string;
|
|
903
|
+
sessionData?: SessionData;
|
|
904
|
+
}
|
|
905
|
+
|
|
906
|
+
declare interface OnboardingLinkDetails {
|
|
907
|
+
id: string;
|
|
908
|
+
token: string;
|
|
909
|
+
event: string;
|
|
910
|
+
custom_flow_id?: string | null;
|
|
911
|
+
expire: boolean;
|
|
912
|
+
expires_at?: string | null;
|
|
913
|
+
notification: boolean;
|
|
914
|
+
callback_url?: string | null;
|
|
915
|
+
callback_email?: string | null;
|
|
916
|
+
person_name: string;
|
|
917
|
+
person_birth_date: string;
|
|
918
|
+
person_cpf: string;
|
|
919
|
+
person_email: string;
|
|
920
|
+
person_phone?: string | null;
|
|
921
|
+
status: string;
|
|
922
|
+
created_at: string;
|
|
923
|
+
updated_at: string;
|
|
924
|
+
completed_at?: string | null;
|
|
925
|
+
is_valid: boolean;
|
|
926
|
+
is_expired: boolean;
|
|
927
|
+
onboarding_url: string;
|
|
928
|
+
consumer_name?: string;
|
|
929
|
+
}
|
|
930
|
+
|
|
931
|
+
/**
|
|
932
|
+
* Interface para dados da pessoa no onboarding
|
|
933
|
+
*/
|
|
934
|
+
export declare interface OnboardingPersonData {
|
|
935
|
+
name?: string;
|
|
936
|
+
birth_date?: string;
|
|
937
|
+
cpf?: string;
|
|
938
|
+
cnpj?: string;
|
|
939
|
+
email?: string;
|
|
940
|
+
}
|
|
941
|
+
|
|
942
|
+
export declare type OverlayStatus = 'preparing' | 'detecting' | 'waiting-for-face' | 'capturing' | 'verifying' | 'success' | 'error';
|
|
943
|
+
|
|
944
|
+
/**
|
|
945
|
+
* Personal data item returned by PROOF_OF_LIFE
|
|
946
|
+
*/
|
|
947
|
+
export declare interface PersonalDataItem {
|
|
948
|
+
type: string;
|
|
949
|
+
english_label?: string;
|
|
950
|
+
value: string;
|
|
951
|
+
masked: boolean;
|
|
952
|
+
validated: boolean;
|
|
953
|
+
is_principal_identification?: boolean;
|
|
954
|
+
data_classification?: string;
|
|
955
|
+
}
|
|
956
|
+
|
|
957
|
+
/**
|
|
958
|
+
* Pré-carrega modelos do face-api.js (chame no início da aplicação)
|
|
959
|
+
*/
|
|
960
|
+
export declare function preloadFaceDetectionModels(): Promise<void>;
|
|
961
|
+
|
|
962
|
+
/**
|
|
963
|
+
* Options for Proof of Life verification
|
|
964
|
+
*/
|
|
965
|
+
export declare interface ProofOfLifeOptions {
|
|
966
|
+
/** Duration of video recording in milliseconds (default: 3000) */
|
|
967
|
+
videoDurationMs?: number;
|
|
968
|
+
/** Maximum polling attempts for task status (default: 60) */
|
|
969
|
+
maxPollingAttempts?: number;
|
|
970
|
+
/** Interval between polling attempts in ms (default: 1000) */
|
|
971
|
+
pollingIntervalMs?: number;
|
|
972
|
+
/** Callback for recording progress (0-100) */
|
|
973
|
+
onRecordingProgress?: (progress: number) => void;
|
|
974
|
+
/** Callback for task status changes */
|
|
975
|
+
onTaskStatusChange?: (status: string, progress?: number) => void;
|
|
976
|
+
}
|
|
977
|
+
|
|
978
|
+
/**
|
|
979
|
+
* Result of PROOF_OF_LIFE operation
|
|
980
|
+
*/
|
|
981
|
+
export declare interface ProofOfLifeResult {
|
|
982
|
+
success: boolean;
|
|
983
|
+
isLive: boolean;
|
|
984
|
+
livenessScore: number;
|
|
985
|
+
faceRecognitionScore: number;
|
|
986
|
+
combinedConfidence: number;
|
|
987
|
+
personId?: string;
|
|
988
|
+
personalData: PersonalDataItem[];
|
|
989
|
+
processingTime: number;
|
|
990
|
+
historyId: string;
|
|
991
|
+
taskId: string;
|
|
992
|
+
message?: string;
|
|
993
|
+
error?: string;
|
|
994
|
+
}
|
|
995
|
+
|
|
996
|
+
declare interface RecognitionResult {
|
|
997
|
+
success: boolean;
|
|
998
|
+
data: {
|
|
999
|
+
faceId: string;
|
|
1000
|
+
confidence: number;
|
|
1001
|
+
};
|
|
1002
|
+
}
|
|
1003
|
+
|
|
1004
|
+
/**
|
|
1005
|
+
* Recognizes a face from an image and returns user data
|
|
1006
|
+
* @param image The image blob to process
|
|
1007
|
+
* @param applicationToken The application token for authentication
|
|
1008
|
+
* @returns Promise with access token and user payload
|
|
1009
|
+
* @throws NeoFaceError if request fails
|
|
1010
|
+
* @throws NeoFaceError if recognition fails
|
|
1011
|
+
*/
|
|
1012
|
+
export declare const recognize: (image: Blob, applicationToken: string) => Promise<{
|
|
1013
|
+
accessToken: string;
|
|
1014
|
+
payload: {
|
|
1015
|
+
name: string;
|
|
1016
|
+
email: string;
|
|
1017
|
+
documentId: string;
|
|
1018
|
+
};
|
|
1019
|
+
}>;
|
|
1020
|
+
|
|
1021
|
+
/**
|
|
1022
|
+
* Performs biometric recognition with liveness check
|
|
1023
|
+
*
|
|
1024
|
+
* Note: person_id is NOT returned for security reasons.
|
|
1025
|
+
* Use recognizeByPurpose for external integrations that require signature validation.
|
|
1026
|
+
*
|
|
1027
|
+
* @param image The image blob to process
|
|
1028
|
+
* @param applicationToken The application token for authentication
|
|
1029
|
+
* @param livenessCheck Whether to perform liveness check (default: true)
|
|
1030
|
+
* @param confidenceThreshold Confidence threshold for recognition (default: 0.8)
|
|
1031
|
+
* @returns Promise with recognition result
|
|
1032
|
+
* @throws NeoFaceError if request fails
|
|
1033
|
+
*/
|
|
1034
|
+
export declare const recognizeBiometric: (image: Blob, applicationToken: string, livenessCheck?: boolean, confidenceThreshold?: number) => Promise<{
|
|
1035
|
+
success: boolean;
|
|
1036
|
+
confidenceScore?: number;
|
|
1037
|
+
accessToken?: string;
|
|
1038
|
+
payload?: {
|
|
1039
|
+
name: string;
|
|
1040
|
+
email: string;
|
|
1041
|
+
documentId: string;
|
|
1042
|
+
};
|
|
1043
|
+
}>;
|
|
1044
|
+
|
|
1045
|
+
/**
|
|
1046
|
+
* Performs purpose-specific recognition
|
|
1047
|
+
* @param image The image blob to process
|
|
1048
|
+
* @param applicationToken The application token for authentication
|
|
1049
|
+
* @param purpose Purpose of recognition ('LOGIN', 'PROOF_OF_LIFE', 'AUTHORIZATION', etc.)
|
|
1050
|
+
* @param confidenceThreshold Confidence threshold for recognition (default: 0.8)
|
|
1051
|
+
* @param signature Optional signature for external integrations (HMAC-SHA256 hex string)
|
|
1052
|
+
* @param sessionData Optional session data for external integrations (email, cpf, sessionId)
|
|
1053
|
+
* @returns Promise with recognition result
|
|
1054
|
+
* @throws NeoFaceError if request fails
|
|
1055
|
+
*/
|
|
1056
|
+
export declare const recognizeByPurpose: (image: Blob, applicationToken: string, purpose: "LOGIN" | "PROOF_OF_LIFE" | "AUTHORIZATION" | "SIMPLE_IDENTIFICATION" | "SIMPLIFIED_REGISTRATION", confidenceThreshold?: number, signature?: string, sessionData?: SessionData) => Promise<{
|
|
1057
|
+
success: boolean;
|
|
1058
|
+
personName?: string;
|
|
1059
|
+
email?: string;
|
|
1060
|
+
cpf?: string;
|
|
1061
|
+
confidenceScore?: number;
|
|
1062
|
+
accessToken?: string;
|
|
1063
|
+
payload?: any;
|
|
1064
|
+
signature?: string;
|
|
1065
|
+
sessionId?: string;
|
|
1066
|
+
}>;
|
|
1067
|
+
|
|
1068
|
+
/**
|
|
1069
|
+
* NEO-101: Register biometric data for an existing person
|
|
1070
|
+
*
|
|
1071
|
+
* This method registers facial biometric data for a person already in the system.
|
|
1072
|
+
* It validates the image and sends it to the backend.
|
|
1073
|
+
*
|
|
1074
|
+
* @param personId The ID of the person to register biometric data for
|
|
1075
|
+
* @param faceImage The face image blob to register
|
|
1076
|
+
* @param applicationToken The application token for authentication
|
|
1077
|
+
* @returns Promise with registration result
|
|
1078
|
+
* @throws NeoFaceError if request fails
|
|
1079
|
+
* @throws NeoFaceError if validation fails
|
|
1080
|
+
*/
|
|
1081
|
+
export declare const registerBiometric: (personId: string, faceImage: Blob, applicationToken: string) => Promise<{
|
|
1082
|
+
success: boolean;
|
|
1083
|
+
message: string;
|
|
1084
|
+
identity_data_id?: string;
|
|
1085
|
+
type_of_identification?: string;
|
|
1086
|
+
have_biometric_data?: boolean;
|
|
1087
|
+
created_at?: string;
|
|
1088
|
+
}>;
|
|
1089
|
+
|
|
1090
|
+
/**
|
|
1091
|
+
* Options for registering a document by image capture
|
|
1092
|
+
*/
|
|
1093
|
+
export declare interface RegisterDocumentByImageOptions {
|
|
1094
|
+
/** Pre-select document type, skipping the selection screen */
|
|
1095
|
+
preSelectedDocument?: 'RG' | 'CNH' | 'CPF';
|
|
1096
|
+
/** Use back camera for capture (default: true) */
|
|
1097
|
+
useBackCamera?: boolean;
|
|
1098
|
+
}
|
|
1099
|
+
|
|
1100
|
+
/**
|
|
1101
|
+
* Result of a document registration request
|
|
1102
|
+
*/
|
|
1103
|
+
export declare interface RegisterDocumentResult {
|
|
1104
|
+
success: boolean;
|
|
1105
|
+
taskId: string;
|
|
1106
|
+
status: string;
|
|
1107
|
+
message: string;
|
|
1108
|
+
}
|
|
1109
|
+
|
|
1110
|
+
/**
|
|
1111
|
+
* Register a person with face biometric data and liveness detection
|
|
1112
|
+
* @param personData Person registration data
|
|
1113
|
+
* @param facePhotos Array of face photos for biometric registration (up to 5 photos)
|
|
1114
|
+
* @param applicationToken The application token for authentication
|
|
1115
|
+
* @param options Optional document images
|
|
1116
|
+
* @returns Promise with registration result
|
|
1117
|
+
*/
|
|
1118
|
+
export declare const registerPersonWithBiometric: (personData: {
|
|
1119
|
+
name: string;
|
|
1120
|
+
birth_date: string;
|
|
1121
|
+
cpf: string;
|
|
1122
|
+
email: string;
|
|
1123
|
+
password: string;
|
|
1124
|
+
is_pep?: boolean;
|
|
1125
|
+
}, facePhotos: Blob[], applicationToken: string, options?: {
|
|
1126
|
+
documentFront?: Blob;
|
|
1127
|
+
documentBack?: Blob;
|
|
1128
|
+
documentType?: string;
|
|
1129
|
+
}) => Promise<{
|
|
1130
|
+
success: boolean;
|
|
1131
|
+
message: string;
|
|
1132
|
+
person_id?: string;
|
|
1133
|
+
user_id?: string;
|
|
1134
|
+
person_validated?: boolean;
|
|
1135
|
+
face_processing?: any;
|
|
1136
|
+
onboarding_link?: string;
|
|
1137
|
+
task_id?: string;
|
|
1138
|
+
status?: string;
|
|
1139
|
+
}>;
|
|
1140
|
+
|
|
1141
|
+
/**
|
|
1142
|
+
* Register a person without face biometric data
|
|
1143
|
+
* @param personData Person registration data
|
|
1144
|
+
* @param applicationToken The application token for authentication
|
|
1145
|
+
* @param options Optional document images
|
|
1146
|
+
* @returns Promise with registration result
|
|
1147
|
+
*/
|
|
1148
|
+
export declare const registerPersonWithoutFace: (personData: {
|
|
1149
|
+
name: string;
|
|
1150
|
+
birth_date: string;
|
|
1151
|
+
cpf: string;
|
|
1152
|
+
email: string;
|
|
1153
|
+
password: string;
|
|
1154
|
+
is_pep?: boolean;
|
|
1155
|
+
}, applicationToken: string, options?: {
|
|
1156
|
+
documentFront?: Blob;
|
|
1157
|
+
documentBack?: Blob;
|
|
1158
|
+
documentType?: string;
|
|
1159
|
+
}) => Promise<{
|
|
1160
|
+
success: boolean;
|
|
1161
|
+
message: string;
|
|
1162
|
+
person_id?: string;
|
|
1163
|
+
user_id?: string;
|
|
1164
|
+
person_validated?: boolean;
|
|
1165
|
+
onboarding_link?: string;
|
|
1166
|
+
data?: any;
|
|
1167
|
+
}>;
|
|
1168
|
+
|
|
1169
|
+
/**
|
|
1170
|
+
* Data de lançamento da versão atual
|
|
1171
|
+
*/
|
|
1172
|
+
export declare const RELEASE_DATE = "2026-08-29";
|
|
1173
|
+
|
|
1174
|
+
/**
|
|
1175
|
+
* Exibe o modal de consentimento e resolve `true` se o titular aceitou,
|
|
1176
|
+
* `false` se recusou. Deve ser chamado antes de qualquer `getUserMedia()`.
|
|
1177
|
+
*/
|
|
1178
|
+
export declare function requestConsent(info?: Partial<ConsentInfo>): Promise<boolean>;
|
|
1179
|
+
|
|
1180
|
+
/**
|
|
1181
|
+
* Request a password reset for a user account
|
|
1182
|
+
* @param email User email address
|
|
1183
|
+
* @param applicationToken Application token
|
|
1184
|
+
*/
|
|
1185
|
+
export declare function requestPasswordReset(email: string, applicationToken: string): Promise<{
|
|
1186
|
+
message: string;
|
|
1187
|
+
}>;
|
|
1188
|
+
|
|
1189
|
+
/**
|
|
1190
|
+
* Configuração interna do SDK
|
|
1191
|
+
*/
|
|
1192
|
+
declare interface SDKConfig {
|
|
1193
|
+
baseUrl: string;
|
|
1194
|
+
applicationToken: string | null;
|
|
1195
|
+
environment: Environment | 'custom';
|
|
1196
|
+
initialized: boolean;
|
|
1197
|
+
}
|
|
1198
|
+
|
|
1199
|
+
/**
|
|
1200
|
+
* Opções de inicialização do SDK
|
|
1201
|
+
*/
|
|
1202
|
+
export declare interface SDKInitOptions {
|
|
1203
|
+
/**
|
|
1204
|
+
* Ambiente da aplicação. Se fornecido, a URL base será determinada automaticamente.
|
|
1205
|
+
* Pode ser 'development', 'sandbox' ou 'production'.
|
|
1206
|
+
*/
|
|
1207
|
+
environment?: Environment;
|
|
1208
|
+
/**
|
|
1209
|
+
* URL base da API. Se fornecido, tem precedência sobre 'environment'.
|
|
1210
|
+
* Útil para ambientes customizados ou testes.
|
|
1211
|
+
*/
|
|
1212
|
+
baseUrl?: string;
|
|
1213
|
+
/**
|
|
1214
|
+
* Token de aplicação para autenticação com a API.
|
|
1215
|
+
* Obtido através do painel administrativo do NeoFaceID.
|
|
1216
|
+
*/
|
|
1217
|
+
applicationToken?: string;
|
|
1218
|
+
}
|
|
1219
|
+
|
|
1220
|
+
/**
|
|
1221
|
+
* Session data interface for external integrations
|
|
1222
|
+
*/
|
|
1223
|
+
export declare interface SessionData {
|
|
1224
|
+
email: string;
|
|
1225
|
+
cpf: string;
|
|
1226
|
+
sessionId: string;
|
|
1227
|
+
}
|
|
1228
|
+
|
|
1229
|
+
/**
|
|
1230
|
+
* Performs simple identification using document data
|
|
1231
|
+
* @param documentType Type of document (e.g., 'CPF')
|
|
1232
|
+
* @param documentNumber Document number
|
|
1233
|
+
* @param applicationToken The application token for authentication
|
|
1234
|
+
* @param purpose Purpose of identification (default: 'LOGIN')
|
|
1235
|
+
* @returns Promise with identification result
|
|
1236
|
+
* @throws NeoFaceError if request fails
|
|
1237
|
+
*/
|
|
1238
|
+
export declare const simpleIdentification: (documentType: string, documentNumber: string, applicationToken: string, purpose?: string) => Promise<{
|
|
1239
|
+
success: boolean;
|
|
1240
|
+
personId?: string;
|
|
1241
|
+
accessToken?: string;
|
|
1242
|
+
payload?: {
|
|
1243
|
+
name: string;
|
|
1244
|
+
email: string;
|
|
1245
|
+
documentId: string;
|
|
1246
|
+
};
|
|
1247
|
+
}>;
|
|
1248
|
+
|
|
1249
|
+
export declare function start(applicationToken: string, callbacks: Callbacks): void;
|
|
1250
|
+
|
|
1251
|
+
/**
|
|
1252
|
+
* Inicia o processo de login com detecção automática do tipo biométrico
|
|
1253
|
+
* @param options Opções de configuração para o login automático
|
|
1254
|
+
*/
|
|
1255
|
+
export declare function startAutoLogin(options: BiometricLoginOptions): Promise<void>;
|
|
1256
|
+
|
|
1257
|
+
/**
|
|
1258
|
+
* Start biometric registration process with liveness detection
|
|
1259
|
+
* @param personData Person registration data (name, cpf, birth_date, email, password)
|
|
1260
|
+
* @param applicationToken Application token for authentication
|
|
1261
|
+
* @param callbacks Success and error callbacks
|
|
1262
|
+
*/
|
|
1263
|
+
export declare function startBiometricRegistration(personData: {
|
|
1264
|
+
name: string;
|
|
1265
|
+
birth_date: string;
|
|
1266
|
+
cpf: string;
|
|
1267
|
+
email: string;
|
|
1268
|
+
password: string;
|
|
1269
|
+
}, applicationToken: string, callbacks: BiometricRegistrationCallbacks, options?: {
|
|
1270
|
+
useRealApi?: boolean;
|
|
1271
|
+
}): void;
|
|
1272
|
+
|
|
1273
|
+
/**
|
|
1274
|
+
* Função auxiliar para iniciar a captura de documento
|
|
1275
|
+
*/
|
|
1276
|
+
export declare const startDocumentCapture: (options?: DocumentCaptureOptions) => Promise<DocumentCaptureResult>;
|
|
1277
|
+
|
|
1278
|
+
/**
|
|
1279
|
+
* Inicia o processo de login usando reconhecimento facial
|
|
1280
|
+
* Usa overlay minimalista estilo FaceID (não mostra câmera)
|
|
1281
|
+
* @param options Opções de configuração para o login facial
|
|
1282
|
+
*/
|
|
1283
|
+
export declare function startFaceLogin(options: BiometricLoginOptions): Promise<void>;
|
|
1284
|
+
|
|
1285
|
+
/**
|
|
1286
|
+
* Inicia o processo de login usando reconhecimento de mão
|
|
1287
|
+
* @param options Opções de configuração para o login por mão
|
|
1288
|
+
*/
|
|
1289
|
+
export declare function startHandLogin(options: BiometricLoginOptions): Promise<void>;
|
|
1290
|
+
|
|
1291
|
+
/**
|
|
1292
|
+
* Start liveness capture process only (no registration)
|
|
1293
|
+
* @param applicationToken Application token for authentication
|
|
1294
|
+
* @param callbacks Success and error callbacks
|
|
1295
|
+
*/
|
|
1296
|
+
export declare function startLivenessCapture(applicationToken: string, callbacks: {
|
|
1297
|
+
onSuccess(photos: Blob[]): void;
|
|
1298
|
+
onError(code: string, message: string): void;
|
|
1299
|
+
onCancel?(): void;
|
|
1300
|
+
}): void;
|
|
1301
|
+
|
|
1302
|
+
/**
|
|
1303
|
+
* Inicia o fluxo de onboarding: valida token, captura face e documento, conclui no backend.
|
|
1304
|
+
* Este método orquestra o processo completo e expõe callbacks de sucesso/erro.
|
|
1305
|
+
*/
|
|
1306
|
+
export declare const startOnboarding: (options: StartOnboardingOptions) => Promise<void>;
|
|
1307
|
+
|
|
1308
|
+
export declare interface StartOnboardingOptions {
|
|
1309
|
+
applicationToken: string;
|
|
1310
|
+
onboardingToken: string;
|
|
1311
|
+
countdown?: number;
|
|
1312
|
+
title?: string;
|
|
1313
|
+
subtitle?: string;
|
|
1314
|
+
onSuccess: (result: {
|
|
1315
|
+
success: boolean;
|
|
1316
|
+
message: string;
|
|
1317
|
+
person_id?: string;
|
|
1318
|
+
identity_data_id?: string;
|
|
1319
|
+
confidence_score?: number;
|
|
1320
|
+
processing_time?: number;
|
|
1321
|
+
details: OnboardingLinkDetails;
|
|
1322
|
+
}) => void;
|
|
1323
|
+
onError: (error: NeoFaceError) => void;
|
|
1324
|
+
onCancel?: () => void;
|
|
1325
|
+
}
|
|
1326
|
+
|
|
1327
|
+
/**
|
|
1328
|
+
* Result of user existence check
|
|
1329
|
+
*/
|
|
1330
|
+
declare interface UserExistenceResult {
|
|
1331
|
+
success: boolean;
|
|
1332
|
+
message: string;
|
|
1333
|
+
data: {
|
|
1334
|
+
exists: boolean;
|
|
1335
|
+
};
|
|
1336
|
+
}
|
|
1337
|
+
|
|
1338
|
+
/**
|
|
1339
|
+
* Valida se um token de onboarding é válido
|
|
1340
|
+
* @param applicationToken Token da aplicação (header `X-App-Token`)
|
|
1341
|
+
* @param onboardingToken Token do link de onboarding a ser validado
|
|
1342
|
+
* @returns Promise que resolve para true se o token é válido, false caso contrário
|
|
1343
|
+
* @throws NeoFaceError em caso de falha de rede ou autorização
|
|
1344
|
+
*/
|
|
1345
|
+
export declare const validateOnboardingToken: (applicationToken: string, onboardingToken: string) => Promise<boolean>;
|
|
1346
|
+
|
|
1347
|
+
/**
|
|
1348
|
+
* Validates an application token
|
|
1349
|
+
* @param applicationToken The application token to validate
|
|
1350
|
+
* @returns Promise that resolves to true if token is valid, false otherwise
|
|
1351
|
+
* @throws NeoFaceError if request fails
|
|
1352
|
+
*/
|
|
1353
|
+
export declare const validateToken: (applicationToken: string) => Promise<boolean>;
|
|
1354
|
+
|
|
1355
|
+
/**
|
|
1356
|
+
* Versão atual do SDK NeoFace ID Web
|
|
1357
|
+
* Formato: MAJOR.MINOR.PATCH
|
|
1358
|
+
*
|
|
1359
|
+
* MAJOR: Incrementado quando há mudanças incompatíveis com versões anteriores
|
|
1360
|
+
* MINOR: Incrementado quando adicionamos funcionalidades mantendo compatibilidade
|
|
1361
|
+
* PATCH: Incrementado quando corrigimos bugs mantendo compatibilidade
|
|
1362
|
+
*/
|
|
1363
|
+
export declare const VERSION = "1.25.4";
|
|
1364
|
+
|
|
1365
|
+
export { }
|