@neofaceid/web-sdk 1.40.0 → 1.40.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
@@ -345,6 +345,11 @@ export declare const checkUserExistence: (params: {
345
345
  cpf?: string;
346
346
  }) => Promise<UserExistenceResult>;
347
347
 
348
+ /**
349
+ * Limpa o histórico de consentimentos no localStorage.
350
+ */
351
+ export declare function clearConsentTrail(): void;
352
+
348
353
  /**
349
354
  * Conclui o processo de onboarding enviando imagens de face e documento
350
355
  * @param applicationToken Token da aplicação (header `X-App-Token`)
@@ -448,6 +453,14 @@ export declare interface ConsentModalProps {
448
453
  onDecline: () => void;
449
454
  }
450
455
 
456
+ export declare interface ConsentRecord {
457
+ hash: string;
458
+ timestamp: string;
459
+ purpose: string;
460
+ legalBasis: string;
461
+ sdkVersion: string;
462
+ }
463
+
451
464
  /**
452
465
  * Compatibilidade com callers antigos que passavam `{ purpose, legalBasis }`.
453
466
  * Deprecated — remover quando US14.4 unificar tokens.
@@ -692,6 +705,12 @@ export declare function getConfig(): Readonly<SDKConfig>;
692
705
  /** Retorna os dados de consentimento configurados (ou os defaults conservadores). */
693
706
  export declare function getConsent(): Consent;
694
707
 
708
+ /**
709
+ * Retorna o histórico (trail) de consentimentos gravados no localStorage.
710
+ * Falha silenciosamente retornando array vazio caso o localStorage esteja inacessível.
711
+ */
712
+ export declare function getConsentTrail(): ConsentRecord[];
713
+
695
714
  /**
696
715
  * Retorna o ambiente atual configurado.
697
716
  */
@@ -1238,6 +1257,17 @@ export declare const recognizeByPurpose: (image: Blob, applicationToken: string,
1238
1257
  sessionId?: string;
1239
1258
  }>;
1240
1259
 
1260
+ /**
1261
+ * Grava um novo aceite de consentimento no localStorage do titular.
1262
+ * Zero PII: grava apenas hash (SHA-256 de userAgent+purpose+timestamp), timestamp, finalidade, base legal e versão do SDK.
1263
+ * Mantém até no máximo 100 registros (FIFO).
1264
+ * Falha silenciosamente em caso de erro no localStorage (ex: Safari modo privado ou QuotaExceededError).
1265
+ */
1266
+ export declare function recordConsent(customConsent?: Partial<{
1267
+ purpose: string;
1268
+ legalBasis: string;
1269
+ }>): Promise<ConsentRecord | null>;
1270
+
1241
1271
  /**
1242
1272
  * NEO-101: Register biometric data for an existing person
1243
1273
  *
@@ -1709,7 +1739,7 @@ export declare const validateToken: (applicationToken: string) => Promise<boolea
1709
1739
  * MINOR: Incrementado quando adicionamos funcionalidades mantendo compatibilidade
1710
1740
  * PATCH: Incrementado quando corrigimos bugs mantendo compatibilidade
1711
1741
  */
1712
- export declare const VERSION = "1.40.0";
1742
+ export declare const VERSION = "1.40.1";
1713
1743
 
1714
1744
  /**
1715
1745
  * Executa `fn(sessionId)`. Se o servidor devolver 410 (sessão consumida/expirada),
@@ -8736,6 +8736,74 @@ function BiometricRegistrationModal({
8736
8736
  /* @__PURE__ */ jsx("canvas", { ref: canvasRef })
8737
8737
  ] });
8738
8738
  }
8739
+ const VERSION = "1.40.1";
8740
+ const RELEASE_DATE = "2026-09-09";
8741
+ const CONSENT_TRAIL_STORAGE_KEY = "neoface_consent_trail_v1";
8742
+ const CONSENT_TRAIL_MAX_LIMIT = 100;
8743
+ async function hashString(inputStr) {
8744
+ try {
8745
+ if (typeof crypto !== "undefined" && crypto.subtle && typeof crypto.subtle.digest === "function") {
8746
+ const encoder = new TextEncoder();
8747
+ const buffer = await crypto.subtle.digest("SHA-256", encoder.encode(inputStr));
8748
+ return Array.from(new Uint8Array(buffer)).map((b) => b.toString(16).padStart(2, "0")).join("");
8749
+ }
8750
+ } catch {
8751
+ }
8752
+ return "sha256-unavailable";
8753
+ }
8754
+ function getConsentTrail() {
8755
+ try {
8756
+ if (typeof window === "undefined" || !window.localStorage) {
8757
+ return [];
8758
+ }
8759
+ const rawData = window.localStorage.getItem(CONSENT_TRAIL_STORAGE_KEY);
8760
+ if (!rawData) {
8761
+ return [];
8762
+ }
8763
+ const parsed = JSON.parse(rawData);
8764
+ if (Array.isArray(parsed)) {
8765
+ return parsed;
8766
+ }
8767
+ return [];
8768
+ } catch {
8769
+ return [];
8770
+ }
8771
+ }
8772
+ function clearConsentTrail() {
8773
+ try {
8774
+ if (typeof window !== "undefined" && window.localStorage) {
8775
+ window.localStorage.removeItem(CONSENT_TRAIL_STORAGE_KEY);
8776
+ }
8777
+ } catch {
8778
+ }
8779
+ }
8780
+ async function recordConsent(customConsent) {
8781
+ try {
8782
+ const configConsent = getConsent();
8783
+ const purpose = (customConsent == null ? void 0 : customConsent.purpose) ?? configConsent.purpose ?? "authentication";
8784
+ const legalBasis = (customConsent == null ? void 0 : customConsent.legalBasis) ?? configConsent.legalBasis ?? "fraud_prevention";
8785
+ const timestamp = (/* @__PURE__ */ new Date()).toISOString();
8786
+ const userAgent = typeof navigator !== "undefined" ? navigator.userAgent : "";
8787
+ const sdkVersion = VERSION;
8788
+ const hash = await hashString(`${userAgent}${purpose}${timestamp}`);
8789
+ const record = {
8790
+ hash,
8791
+ timestamp,
8792
+ purpose,
8793
+ legalBasis,
8794
+ sdkVersion
8795
+ };
8796
+ const currentTrail = getConsentTrail();
8797
+ currentTrail.push(record);
8798
+ const updatedTrail = currentTrail.slice(-CONSENT_TRAIL_MAX_LIMIT);
8799
+ if (typeof window !== "undefined" && window.localStorage) {
8800
+ window.localStorage.setItem(CONSENT_TRAIL_STORAGE_KEY, JSON.stringify(updatedTrail));
8801
+ }
8802
+ return record;
8803
+ } catch {
8804
+ return null;
8805
+ }
8806
+ }
8739
8807
  const DEFAULT_PRIVACY_URL = "https://neofaceid.com/privacidade";
8740
8808
  const DEFAULT_RETENTION_DAYS = 90;
8741
8809
  const COPY = {
@@ -9027,7 +9095,11 @@ function ConsentModalComponent({
9027
9095
  {
9028
9096
  type: "button",
9029
9097
  className: "neofaceid-consent-button neofaceid-consent-button-primary",
9030
- onClick: onAccept,
9098
+ onClick: () => {
9099
+ recordConsent().catch(() => {
9100
+ });
9101
+ onAccept();
9102
+ },
9031
9103
  children: copy.primary
9032
9104
  }
9033
9105
  ),
@@ -11271,8 +11343,6 @@ const biometricDetection = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.
11271
11343
  initializeBiometricDetection,
11272
11344
  isAdvancedDetectionAvailable
11273
11345
  }, Symbol.toStringTag, { value: "Module" }));
11274
- const VERSION = "1.40.0";
11275
- const RELEASE_DATE = "2026-09-09";
11276
11346
  let cachedSession = null;
11277
11347
  function getCachedCaptureSession() {
11278
11348
  return cachedSession;
@@ -14387,6 +14457,7 @@ export {
14387
14457
  authorize,
14388
14458
  authorizeOperation,
14389
14459
  checkUserExistence,
14460
+ clearConsentTrail,
14390
14461
  completeOnboarding,
14391
14462
  completeOnboardingWithData,
14392
14463
  confirmPasswordReset,
@@ -14398,6 +14469,7 @@ export {
14398
14469
  getCachedCaptureSession,
14399
14470
  getConfig,
14400
14471
  getConsent,
14472
+ getConsentTrail,
14401
14473
  getEnvironment,
14402
14474
  getLocale,
14403
14475
  getRadius,
@@ -14416,6 +14488,7 @@ export {
14416
14488
  recognize,
14417
14489
  recognizeBiometric,
14418
14490
  recognizeByPurpose,
14491
+ recordConsent,
14419
14492
  registerBiometric,
14420
14493
  registerPersonWithBiometric,
14421
14494
  registerPersonWithoutFace,