@neofaceid/web-sdk 1.44.0 → 2.0.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/dist/index.d.ts CHANGED
@@ -191,80 +191,6 @@ export declare interface AwaitPushApprovalOptions {
191
191
  onFallback?: () => void;
192
192
  }
193
193
 
194
- export declare class BiometricCaptureModal {
195
- private modal;
196
- private video;
197
- private canvas;
198
- private stream;
199
- private options;
200
- private countdownInterval;
201
- private isCapturing;
202
- private flashController;
203
- constructor(options: BiometricCaptureOptions);
204
- /**
205
- * Abre o modal de captura biométrica
206
- */
207
- open(): Promise<void>;
208
- /**
209
- * Fecha o modal e limpa recursos
210
- */
211
- close(): void;
212
- /**
213
- * Cria a estrutura HTML do modal
214
- */
215
- private createModal;
216
- /**
217
- * Inicializa a câmera
218
- */
219
- private initializeCamera;
220
- /**
221
- * NEO-413 · US14.6 (item 18) — a contagem "3, 2, 1" foi removida.
222
- * Agora habilita direto o botão "Capturar" assim que a câmera fica pronta.
223
- * Vivacidade fica com o desafio `runLivenessChallenge` (NEO-408), servidor decide.
224
- */
225
- private enableCaptureButton;
226
- /**
227
- * Captura a imagem da câmera
228
- */
229
- private captureImage;
230
- /**
231
- * Detecta o tipo biométrico na imagem (face ou mão)
232
- */
233
- private detectBiometricType;
234
- /**
235
- * Adiciona event listeners aos elementos do modal
236
- */
237
- private addEventListeners;
238
- /**
239
- * Limpa recursos (câmera, intervalos, etc.)
240
- */
241
- private cleanup;
242
- /**
243
- * Retorna o título padrão baseado no modo
244
- */
245
- private getDefaultTitle;
246
- /**
247
- * Retorna o subtítulo padrão baseado no modo
248
- */
249
- private getDefaultSubtitle;
250
- /**
251
- * Adiciona estilos CSS ao modal
252
- */
253
- private addStyles;
254
- }
255
-
256
- declare interface BiometricCaptureOptions {
257
- mode: 'face' | 'hand' | 'auto';
258
- onSuccess: (imageData: string, detectedType: 'face' | 'hand') => void;
259
- onError: (error: NeoFaceError) => void;
260
- onCancel?: () => void;
261
- countdown?: number;
262
- title?: string;
263
- subtitle?: string;
264
- /** NEO-425 · US14.11.a — screen flash assistivo em ambiente escuro. Default true. */
265
- autoLighting?: boolean;
266
- }
267
-
268
194
  export declare interface BiometricLoginOptions {
269
195
  applicationToken: string;
270
196
  /**
@@ -425,10 +351,21 @@ export declare interface CameraOvalGuideProps {
425
351
  }
426
352
 
427
353
  /**
428
- * Options for capturing face frames
354
+ * Captura quadros do rosto sem abrir modal.
355
+ *
356
+ * Substitui `new NeoFaceID(...).captureFaceFrames(options)`, removido na 2.0.0.
357
+ * Não precisava da instância — só a mantinha por estar pendurado na classe.
429
358
  */
359
+ export declare function captureFaceFrames(options: CaptureFaceFramesOptions): Promise<Blob[]>;
360
+
361
+ /** Opções de {@link captureFaceFrames}. */
430
362
  export declare interface CaptureFaceFramesOptions {
363
+ /** Quantos quadros capturar, de 1 a 10. */
431
364
  numFrames: number;
365
+ /**
366
+ * Espaça as capturas em 300 ms. Uma foto estática produz quadros idênticos;
367
+ * um rosto presente, não.
368
+ */
432
369
  livenessCheck: boolean;
433
370
  }
434
371
 
@@ -628,23 +565,6 @@ export declare function consumeSseStream<T>(options: ConsumeSseOptions<T>): Prom
628
565
  */
629
566
  export declare const DEFAULT_CONSENT_INFO: ConsentInfo;
630
567
 
631
- /**
632
- * Detecta automaticamente o tipo biométrico na imagem
633
- * @param imageData Dados da imagem em base64
634
- * @returns Resultado da detecção com tipo e confiança
635
- */
636
- export declare function detectBiometricType(imageData: string): Promise<DetectionResult>;
637
-
638
- /**
639
- * Módulo de detecção automática de tipo biométrico
640
- * Utiliza face-api.js para detectar se a imagem contém face ou mão
641
- */
642
- export declare interface DetectionResult {
643
- type: 'face' | 'hand' | 'unknown';
644
- confidence: number;
645
- details?: any;
646
- }
647
-
648
568
  /** Desfecho da inscrição de aparelho. */
649
569
  export declare type DeviceEnrollmentOutcome = {
650
570
  status: 'enrolled';
@@ -1006,18 +926,6 @@ export declare const identifyPersonAsync: (image: Blob, applicationToken: string
1006
926
  */
1007
927
  export declare function init(options?: SDKInitOptions): void;
1008
928
 
1009
- /**
1010
- * Inicializa o sistema de detecção biométrica
1011
- * Carrega bibliotecas e modelos necessários
1012
- */
1013
- export declare function initializeBiometricDetection(): Promise<void>;
1014
-
1015
- /**
1016
- * Verifica se o sistema de detecção está disponível
1017
- * @returns true se a detecção avançada está disponível
1018
- */
1019
- export declare function isAdvancedDetectionAvailable(): boolean;
1020
-
1021
929
  /**
1022
930
  * Verifica se o SDK foi inicializado.
1023
931
  */
@@ -1045,30 +953,6 @@ export declare interface LivenessChallengeResult {
1045
953
  raw: unknown;
1046
954
  }
1047
955
 
1048
- /**
1049
- * Options for login recognition
1050
- */
1051
- export declare interface LoginRecognitionOptions {
1052
- biometricData: Blob | Blob[];
1053
- typeOfIdentification: 'FACE' | 'HAND';
1054
- purpose: 'LOGIN' | 'PROOF_OF_LIFE' | 'AUTHORIZATION' | 'SIMPLE_IDENTIFICATION' | 'SIMPLIFIED_REGISTRATION';
1055
- confidenceThreshold?: number;
1056
- }
1057
-
1058
- /**
1059
- * Result of login recognition
1060
- */
1061
- export declare interface LoginRecognitionResult {
1062
- success: boolean;
1063
- personName: string;
1064
- email: string;
1065
- cpf: string;
1066
- signature?: string;
1067
- sessionId?: string;
1068
- confidenceScore?: number;
1069
- accessToken?: string;
1070
- }
1071
-
1072
956
  /**
1073
957
  * Performs biometric login using face recognition
1074
958
  * @param image The image blob to process
@@ -1107,194 +991,6 @@ export declare class NeoFaceError extends Error {
1107
991
  getFriendlyMessage(): string;
1108
992
  }
1109
993
 
1110
- /**
1111
- * NeoFaceID SDK class for biometric authentication
1112
- *
1113
- * This class provides a high-level API for biometric recognition,
1114
- * supporting both internal use (without signature) and external integrations
1115
- * (with signature and session data for systems like OpsPay).
1116
- *
1117
- * @example
1118
- * ```typescript
1119
- * // For external integrations (with signature)
1120
- * const sdk = new NeoFaceID({
1121
- * appToken: 'your-application-token',
1122
- * baseUrl: 'https://core.neofaceid.com',
1123
- * signature: signatureFromBackend,
1124
- * sessionData: {
1125
- * email: 'user@example.com',
1126
- * cpf: '12345678901',
1127
- * sessionId: 'session-uuid-123'
1128
- * }
1129
- * });
1130
- *
1131
- * // For internal use (without signature)
1132
- * const sdk = new NeoFaceID({
1133
- * appToken: 'your-application-token'
1134
- * });
1135
- * ```
1136
- */
1137
- export declare class NeoFaceID {
1138
- private appToken;
1139
- private signature?;
1140
- private sessionData?;
1141
- /**
1142
- * Creates a new NeoFaceID instance
1143
- * @param config Configuration object
1144
- * @throws NeoFaceError if signature format is invalid
1145
- */
1146
- constructor(config: NeoFaceIDConfig);
1147
- /**
1148
- * Validates the format of a signature
1149
- * HMAC-SHA256 produces a 64-character hexadecimal string
1150
- * @param signature The signature to validate
1151
- * @returns true if valid, false otherwise
1152
- */
1153
- private validateSignatureFormat;
1154
- /**
1155
- * Captures multiple face frames for biometric recognition
1156
- * @param options Capture options
1157
- * @returns Promise that resolves to an array of image blobs
1158
- * @throws NeoFaceError if capture fails
1159
- */
1160
- captureFaceFrames(options: CaptureFaceFramesOptions): Promise<Blob[]>;
1161
- /**
1162
- * Performs login recognition using biometric data
1163
- *
1164
- * This method is designed for external integrations that require
1165
- * signature validation and session management.
1166
- *
1167
- * @param options Recognition options
1168
- * @returns Promise that resolves to recognition result
1169
- * @throws NeoFaceError if recognition fails
1170
- *
1171
- * @example
1172
- * ```typescript
1173
- * const result = await sdk.loginRecognition({
1174
- * biometricData: await sdk.captureFaceFrames({
1175
- * numFrames: 5,
1176
- * livenessCheck: true
1177
- * }),
1178
- * typeOfIdentification: 'FACE',
1179
- * purpose: 'LOGIN',
1180
- * confidenceThreshold: 0.8
1181
- * });
1182
- *
1183
- * // Result includes signature and sessionId for callback validation
1184
- * console.log(result.signature, result.sessionId);
1185
- * ```
1186
- */
1187
- loginRecognition(options: LoginRecognitionOptions): Promise<LoginRecognitionResult>;
1188
- /**
1189
- * Register a new application for a consumer
1190
- *
1191
- * This method allows authenticated users to register new applications
1192
- * that will receive their own app_token for API access.
1193
- *
1194
- * @param jwtToken JWT authentication token from logged user
1195
- * @param consumerId Consumer ID (UUID) who will own the application
1196
- * @param applicationData Application registration data
1197
- * @returns Promise with registration result including app_token
1198
- * @throws NeoFaceError if registration fails
1199
- *
1200
- * @example
1201
- * ```typescript
1202
- * const sdk = new NeoFaceID({
1203
- * appToken: 'your-application-token'
1204
- * });
1205
- *
1206
- * const result = await sdk.registerApplication(
1207
- * userJwtToken,
1208
- * consumerUuid,
1209
- * {
1210
- * applicationName: 'My New App',
1211
- * domain: 'example.com',
1212
- * acceptOnlyEmailWithSameDomain: true
1213
- * }
1214
- * );
1215
- *
1216
- * // Use the generated app_token for the new application
1217
- * console.log('New App Token:', result.application.app_token);
1218
- * ```
1219
- */
1220
- registerApplication(jwtToken: string, consumerId: string, applicationData: ApplicationRegistrationData): Promise<ApplicationRegistrationResult>;
1221
- /**
1222
- * Performs Proof of Life verification
1223
- *
1224
- * This method records a video from the camera, sends it to the backend
1225
- * for liveness detection and face recognition, and returns the result
1226
- * with personal data filtered by purpose.
1227
- *
1228
- * The process is asynchronous:
1229
- * 1. Records video from the camera (default 3 seconds)
1230
- * 2. Converts video to base64 and sends to backend
1231
- * 3. Backend processes liveness detection and face recognition
1232
- * 4. Polls for task completion
1233
- * 5. Returns personal data of the identified person
1234
- *
1235
- * @param options Configuration options for the proof of life process
1236
- * @returns Promise that resolves to ProofOfLifeResult
1237
- * @throws NeoFaceError if verification fails
1238
- *
1239
- * @example
1240
- * ```typescript
1241
- * const sdk = new NeoFaceID({
1242
- * appToken: 'your-application-token'
1243
- * });
1244
- *
1245
- * const result = await sdk.proofOfLife({
1246
- * videoDurationMs: 3000, // 3 seconds
1247
- * onRecordingProgress: (progress) => {
1248
- * console.log(`Recording: ${progress}%`);
1249
- * },
1250
- * onTaskStatusChange: (status, progress) => {
1251
- * console.log(`Status: ${status}, Progress: ${progress}%`);
1252
- * }
1253
- * });
1254
- *
1255
- * if (result.success && result.isLive) {
1256
- * console.log('Person verified:', result.personalData);
1257
- * console.log('Liveness score:', result.livenessScore);
1258
- * console.log('Face recognition score:', result.faceRecognitionScore);
1259
- * }
1260
- * ```
1261
- */
1262
- /**
1263
- * Registers document images for an already-registered donor person.
1264
- *
1265
- * Opens the document capture UI (front + optional back), then submits
1266
- * the images to the backend for extraction via DocExt.
1267
- * The backend processes this asynchronously — use the returned `taskId`
1268
- * to poll status if needed.
1269
- *
1270
- * @param personId UUID of the donor's person record
1271
- * @param jwtToken JWT Bearer token of the authenticated donor
1272
- * @param options Optional capture configuration
1273
- * @returns Promise with task_id and processing status
1274
- * @throws NeoFaceError if capture is cancelled, validation fails, or API call fails
1275
- *
1276
- * @example
1277
- * ```typescript
1278
- * const sdk = new NeoFaceID({ appToken: 'your-token' });
1279
- *
1280
- * const result = await sdk.registerDocumentByImage(personId, userJwtToken);
1281
- * console.log('Task ID:', result.taskId); // poll for completion
1282
- * ```
1283
- */
1284
- registerDocumentByImage(personId: string, jwtToken: string, options?: RegisterDocumentByImageOptions): Promise<RegisterDocumentResult>;
1285
- proofOfLife(options?: ProofOfLifeOptions): Promise<ProofOfLifeResult>;
1286
- }
1287
-
1288
- /**
1289
- * Configuration for NeoFaceID SDK initialization
1290
- */
1291
- export declare interface NeoFaceIDConfig {
1292
- appToken: string;
1293
- baseUrl?: string;
1294
- signature?: string;
1295
- sessionData?: SessionData;
1296
- }
1297
-
1298
994
  declare interface OnboardingLinkDetails {
1299
995
  id: string;
1300
996
  token: string;
@@ -1365,18 +1061,42 @@ export declare interface PersonalDataItem {
1365
1061
  export declare function preloadFaceDetectionModels(): Promise<void>;
1366
1062
 
1367
1063
  /**
1368
- * Options for Proof of Life verification
1064
+ * Prova de vida: grava um vídeo curto da câmera, envia ao core e aguarda o
1065
+ * resultado da detecção de vivacidade e do reconhecimento.
1066
+ *
1067
+ * Substitui `new NeoFaceID({ appToken }).proofOfLife(options)`, removido na
1068
+ * 2.0.0. A migração é direta:
1069
+ *
1070
+ * ```ts
1071
+ * // antes
1072
+ * const sdk = new NeoFaceID({ appToken: TOKEN });
1073
+ * const r = await sdk.proofOfLife({ videoDurationMs: 3000 });
1074
+ *
1075
+ * // depois
1076
+ * const r = await proofOfLife({ applicationToken: TOKEN, videoDurationMs: 3000 });
1077
+ * ```
1078
+ *
1079
+ * `success: false` com `isLive: false` é desfecho, não exceção — a pessoa pode
1080
+ * simplesmente não ter passado na prova. Exceção fica para falha de câmera,
1081
+ * rede ou credencial.
1369
1082
  */
1083
+ export declare function proofOfLife(options?: ProofOfLifeOptions): Promise<ProofOfLifeResult>;
1084
+
1085
+ /** Opções de {@link proofOfLife}. */
1370
1086
  export declare interface ProofOfLifeOptions {
1371
- /** Duration of video recording in milliseconds (default: 3000) */
1087
+ /**
1088
+ * Token da aplicação. Se omitido, usa o informado em `init({ applicationToken })`.
1089
+ */
1090
+ applicationToken?: string;
1091
+ /** Duração da gravação, em milissegundos. Default 3000. */
1372
1092
  videoDurationMs?: number;
1373
- /** Maximum polling attempts for task status (default: 60) */
1093
+ /** Máximo de consultas ao status da task. Default 60. */
1374
1094
  maxPollingAttempts?: number;
1375
- /** Interval between polling attempts in ms (default: 1000) */
1095
+ /** Intervalo entre consultas, em milissegundos. Default 1000. */
1376
1096
  pollingIntervalMs?: number;
1377
- /** Callback for recording progress (0-100) */
1097
+ /** Progresso da gravação, de 0 a 100. */
1378
1098
  onRecordingProgress?: (progress: number) => void;
1379
- /** Callback for task status changes */
1099
+ /** Mudança de estado da task no core. */
1380
1100
  onTaskStatusChange?: (status: string, progress?: number) => void;
1381
1101
  }
1382
1102
 
@@ -1531,6 +1251,30 @@ export declare interface RefreshedSession {
1531
1251
  */
1532
1252
  export declare const refreshSession: (refreshToken: string, applicationToken: string) => Promise<RefreshedSession>;
1533
1253
 
1254
+ /**
1255
+ * Register a new application for a consumer
1256
+ * @param jwtToken JWT authentication token from logged user
1257
+ * @param consumerId Consumer ID (UUID) who will own the application
1258
+ * @param applicationData Application registration data
1259
+ * @returns Promise with registration result
1260
+ * @throws NeoFaceError if registration fails
1261
+ *
1262
+ * @example
1263
+ * ```typescript
1264
+ * const result = await registerApplication(
1265
+ * 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...',
1266
+ * 'consumer-uuid-123',
1267
+ * {
1268
+ * applicationName: 'My App',
1269
+ * domain: 'example.com',
1270
+ * acceptOnlyEmailWithSameDomain: true
1271
+ * }
1272
+ * );
1273
+ * console.log('App Token:', result.application.app_token);
1274
+ * ```
1275
+ */
1276
+ export declare const registerApplication: (jwtToken: string, consumerId: string, applicationData: ApplicationRegistrationData) => Promise<ApplicationRegistrationResult>;
1277
+
1534
1278
  /**
1535
1279
  * NEO-101: Register biometric data for an existing person
1536
1280
  *
@@ -1554,12 +1298,24 @@ export declare const registerBiometric: (personId: string, faceImage: Blob, appl
1554
1298
  }>;
1555
1299
 
1556
1300
  /**
1557
- * Options for registering a document by image capture
1301
+ * Abre a captura de documento (frente e, opcionalmente, verso) e envia as
1302
+ * imagens ao core para extração.
1303
+ *
1304
+ * Substitui `new NeoFaceID(...).registerDocumentByImage(...)`, removido na
1305
+ * 2.0.0. Difere de `startDocumentCapture()`, que só captura: esta função
1306
+ * também submete ao core. O processamento é assíncrono — use o `taskId`
1307
+ * devolvido para acompanhar.
1308
+ *
1309
+ * @param personId UUID da pessoa (doador já cadastrado).
1310
+ * @param jwtToken Bearer do doador autenticado.
1558
1311
  */
1312
+ export declare function registerDocumentByImage(personId: string, jwtToken: string, options?: RegisterDocumentByImageOptions): Promise<RegisterDocumentResult>;
1313
+
1314
+ /** Opções de {@link registerDocumentByImage}. */
1559
1315
  export declare interface RegisterDocumentByImageOptions {
1560
- /** Pre-select document type, skipping the selection screen */
1316
+ /** Pré-seleciona o tipo de documento, pulando a tela de escolha. */
1561
1317
  preSelectedDocument?: 'RG' | 'CNH' | 'CPF';
1562
- /** Use back camera for capture (default: true) */
1318
+ /** Usa a câmera traseira. Default `true`. */
1563
1319
  useBackCamera?: boolean;
1564
1320
  }
1565
1321
 
@@ -1635,7 +1391,7 @@ export declare const registerPersonWithoutFace: (personData: {
1635
1391
  /**
1636
1392
  * Data de lançamento da versão atual
1637
1393
  */
1638
- export declare const RELEASE_DATE = "2026-09-16";
1394
+ export declare const RELEASE_DATE = "2026-09-20";
1639
1395
 
1640
1396
  declare interface RequestChallengeWithSessionParams {
1641
1397
  applicationToken: string;
@@ -2108,7 +1864,7 @@ export declare const validateToken: (applicationToken: string) => Promise<boolea
2108
1864
  * MINOR: Incrementado quando adicionamos funcionalidades mantendo compatibilidade
2109
1865
  * PATCH: Incrementado quando corrigimos bugs mantendo compatibilidade
2110
1866
  */
2111
- export declare const VERSION = "1.44.0";
1867
+ export declare const VERSION = "2.0.1";
2112
1868
 
2113
1869
  /**
2114
1870
  * Executa `fn(sessionId)`. Se o servidor devolver 410 (sessão consumida/expirada),