@neofaceid/web-sdk 1.34.1 → 1.35.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
@@ -1634,7 +1634,7 @@ export declare const validateToken: (applicationToken: string) => Promise<boolea
1634
1634
  * MINOR: Incrementado quando adicionamos funcionalidades mantendo compatibilidade
1635
1635
  * PATCH: Incrementado quando corrigimos bugs mantendo compatibilidade
1636
1636
  */
1637
- export declare const VERSION = "1.34.1";
1637
+ export declare const VERSION = "1.35.1";
1638
1638
 
1639
1639
  /**
1640
1640
  * Executa `fn(sessionId)`. Se o servidor devolver 410 (sessão consumida/expirada),
@@ -4473,7 +4473,7 @@ const CSS_VAR = {
4473
4473
  radius: "--nfid-radius"
4474
4474
  };
4475
4475
  const INJECTED_STYLE_ID = "neofaceid-focus-frame-tokens";
4476
- function injectThemeStyles$1(options = {}) {
4476
+ function injectThemeStyles(options = {}) {
4477
4477
  const resolved = resolveTheme(options);
4478
4478
  if (typeof document === "undefined") return resolved;
4479
4479
  const css = buildRootCss(resolved);
@@ -4521,7 +4521,7 @@ function buildRootCss(theme) {
4521
4521
  }
4522
4522
  }`;
4523
4523
  }
4524
- function injectScopedStyles$1(id, css) {
4524
+ function injectScopedStyles(id, css) {
4525
4525
  if (typeof document === "undefined") return;
4526
4526
  const existing = document.getElementById(id);
4527
4527
  if (existing) {
@@ -4612,7 +4612,7 @@ function init(options = {}) {
4612
4612
  theme: globalConfig.theme
4613
4613
  });
4614
4614
  globalConfig.resolvedTheme = resolved;
4615
- injectThemeStyles$1({
4615
+ injectThemeStyles({
4616
4616
  accent: globalConfig.accent ?? void 0,
4617
4617
  radius: globalConfig.radius,
4618
4618
  theme: globalConfig.theme
@@ -6410,7 +6410,7 @@ function FaceCaptureModal({
6410
6410
  detectFaces();
6411
6411
  };
6412
6412
  useEffect(() => {
6413
- injectThemeStyles$1();
6413
+ injectThemeStyles();
6414
6414
  }, []);
6415
6415
  useEffect(() => {
6416
6416
  const loadModels = async () => {
@@ -6564,7 +6564,7 @@ class ForgotPasswordModal {
6564
6564
  }
6565
6565
  open() {
6566
6566
  if (this.modalElement) return;
6567
- injectThemeStyles$1();
6567
+ injectThemeStyles();
6568
6568
  this.addStyles();
6569
6569
  this.modalElement = document.createElement("div");
6570
6570
  this.modalElement.className = "neofaceid-root neoface-forgot-modal";
@@ -6686,7 +6686,7 @@ class ForgotPasswordModal {
6686
6686
  addStyles() {
6687
6687
  const styleId = "neoface-forgot-password-modal-styles";
6688
6688
  if (document.getElementById(styleId)) return;
6689
- injectScopedStyles$1(styleId, `
6689
+ injectScopedStyles(styleId, `
6690
6690
  .neoface-forgot-modal {
6691
6691
  position: fixed;
6692
6692
  top: 0;
@@ -7005,7 +7005,7 @@ function BiometricRegistrationModal({
7005
7005
  );
7006
7006
  const [cameraReady, setCameraReady] = useState(false);
7007
7007
  useEffect(() => {
7008
- injectThemeStyles$1();
7008
+ injectThemeStyles();
7009
7009
  }, []);
7010
7010
  useEffect(() => {
7011
7011
  if (state.status === "liveness") {
@@ -8712,7 +8712,7 @@ class ConsentModal {
8712
8712
  }
8713
8713
  show(props) {
8714
8714
  if (this.container) return;
8715
- injectThemeStyles$1();
8715
+ injectThemeStyles();
8716
8716
  this.container = document.createElement("div");
8717
8717
  this.container.id = "neofaceid-consent-modal-container";
8718
8718
  document.body.appendChild(this.container);
@@ -8846,7 +8846,7 @@ class BiometricCaptureModal {
8846
8846
  </div>
8847
8847
  </div>
8848
8848
  `;
8849
- injectThemeStyles$1();
8849
+ injectThemeStyles();
8850
8850
  this.addStyles();
8851
8851
  this.addEventListeners();
8852
8852
  document.body.appendChild(this.modal);
@@ -9025,7 +9025,7 @@ class BiometricCaptureModal {
9025
9025
  if (existingStyles) {
9026
9026
  existingStyles.remove();
9027
9027
  }
9028
- injectScopedStyles$1(styleId, `
9028
+ injectScopedStyles(styleId, `
9029
9029
  .neofaceid-biometric-modal {
9030
9030
  position: fixed;
9031
9031
  top: 0;
@@ -9717,7 +9717,7 @@ class FallbackPrompt {
9717
9717
  if (this.container) {
9718
9718
  return;
9719
9719
  }
9720
- injectThemeStyles$1();
9720
+ injectThemeStyles();
9721
9721
  this.container = document.createElement("div");
9722
9722
  this.container.id = "neofaceid-fallback-prompt";
9723
9723
  document.body.appendChild(this.container);
@@ -9791,7 +9791,7 @@ class EmailPasswordModal {
9791
9791
  }
9792
9792
  }
9793
9793
  createModal() {
9794
- injectThemeStyles$1();
9794
+ injectThemeStyles();
9795
9795
  this.addStyles();
9796
9796
  this.modalElement = document.createElement("div");
9797
9797
  this.modalElement.className = "neofaceid-root neoface-email-password-modal";
@@ -9830,7 +9830,7 @@ class EmailPasswordModal {
9830
9830
  if (existingStyles) {
9831
9831
  return;
9832
9832
  }
9833
- injectScopedStyles$1(styleId, `
9833
+ injectScopedStyles(styleId, `
9834
9834
  .neoface-email-password-modal {
9835
9835
  position: fixed;
9836
9836
  top: 0;
@@ -10866,7 +10866,7 @@ const biometricDetection = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.
10866
10866
  initializeBiometricDetection,
10867
10867
  isAdvancedDetectionAvailable
10868
10868
  }, Symbol.toStringTag, { value: "Module" }));
10869
- const VERSION = "1.34.1";
10869
+ const VERSION = "1.35.1";
10870
10870
  const RELEASE_DATE = "2026-09-02";
10871
10871
  let cachedSession = null;
10872
10872
  function getCachedCaptureSession() {
@@ -10894,7 +10894,9 @@ async function openCaptureSession({
10894
10894
  "Content-Type": "application/json",
10895
10895
  "X-App-Token": applicationToken
10896
10896
  },
10897
- body: JSON.stringify({ purpose })
10897
+ // NEO-424 · backend real aceita apenas valores em UPPERCASE
10898
+ // (`AUTHORIZATION`, `LOGIN`, `ONBOARDING`, …). API pública mantém lowercase.
10899
+ body: JSON.stringify({ purpose: String(purpose).toUpperCase() })
10898
10900
  });
10899
10901
  } catch (err) {
10900
10902
  const message = err instanceof Error ? err.message : "Erro de rede";
@@ -10912,16 +10914,20 @@ async function openCaptureSession({
10912
10914
  const raw = await response.json().catch(() => null);
10913
10915
  const payload = (raw == null ? void 0 : raw.data) ?? raw;
10914
10916
  const sessionId = payload == null ? void 0 : payload.session_id;
10915
- const expiresAt = payload == null ? void 0 : payload.expires_at;
10916
- if (!sessionId || !expiresAt) {
10917
+ if (!sessionId) {
10917
10918
  throw new NeoFaceError(
10918
- "Resposta inválida ao abrir sessão de captura (campos ausentes)",
10919
+ "Resposta inválida ao abrir sessão de captura (session_id ausente)",
10919
10920
  ErrorType.API_ERROR
10920
10921
  );
10921
10922
  }
10923
+ const expiresAt = typeof (payload == null ? void 0 : payload.expires_at) === "string" && payload.expires_at.length > 0 ? payload.expires_at : deriveExpiresAt(payload == null ? void 0 : payload.expires_in);
10922
10924
  cachedSession = { session_id: sessionId, expires_at: expiresAt };
10923
10925
  return cachedSession;
10924
10926
  }
10927
+ function deriveExpiresAt(expiresIn) {
10928
+ const seconds = typeof expiresIn === "number" && Number.isFinite(expiresIn) ? expiresIn : 0;
10929
+ return new Date(Date.now() + seconds * 1e3).toISOString();
10930
+ }
10925
10931
  async function withCaptureSession(params, fn) {
10926
10932
  const session = cachedSession ?? await openCaptureSession(params);
10927
10933
  try {
@@ -11839,7 +11845,7 @@ function Sheet({
11839
11845
  style
11840
11846
  }) {
11841
11847
  useEffect(() => {
11842
- injectThemeStyles$1();
11848
+ injectThemeStyles();
11843
11849
  }, []);
11844
11850
  if (!open) return null;
11845
11851
  const handleOverlay = () => {
@@ -12331,8 +12337,8 @@ const CSS = `
12331
12337
  `;
12332
12338
  function useStateStyles() {
12333
12339
  useEffect(() => {
12334
- injectThemeStyles$1();
12335
- injectScopedStyles$1(STYLE_ID$1, CSS);
12340
+ injectThemeStyles();
12341
+ injectScopedStyles(STYLE_ID$1, CSS);
12336
12342
  }, []);
12337
12343
  }
12338
12344
  function AuthorizeSuccess({ appName, onContinue }) {
@@ -12717,8 +12723,8 @@ function AuthorizeModalComponent({
12717
12723
  const headerAppName = appName ?? getAppName() ?? "sua aplicação";
12718
12724
  const headerAmount = typeof amount === "number" && Number.isFinite(amount) ? formatCurrency(amount, locale) : null;
12719
12725
  useEffect(() => {
12720
- injectThemeStyles$1();
12721
- injectScopedStyles$1(
12726
+ injectThemeStyles();
12727
+ injectScopedStyles(
12722
12728
  STYLE_ID,
12723
12729
  `
12724
12730
  .neofaceid-root .nfid-authorize-header { display: flex; flex-direction: column; gap: 4px; margin-bottom: 16px; }
@@ -13052,8 +13058,8 @@ class DocumentCaptureModal {
13052
13058
  <div class="neoface-doc-content"></div>
13053
13059
  </div>
13054
13060
  `;
13055
- injectThemeStyles$1();
13056
- injectScopedStyles$1("neoface-doc-styles-v2", this.getStyles());
13061
+ injectThemeStyles();
13062
+ injectScopedStyles("neoface-doc-styles-v2", this.getStyles());
13057
13063
  overlay.classList.add("neofaceid-root");
13058
13064
  document.body.appendChild(overlay);
13059
13065
  this.overlay = overlay;