@neofaceid/web-sdk 1.9.0 → 1.10.0

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.
@@ -219,9 +219,9 @@ function requireReactJsxRuntime_development() {
219
219
  case REACT_LAZY_TYPE: {
220
220
  var lazyComponent = type;
221
221
  var payload = lazyComponent._payload;
222
- var init = lazyComponent._init;
222
+ var init2 = lazyComponent._init;
223
223
  try {
224
- return getComponentNameFromType(init(payload));
224
+ return getComponentNameFromType(init2(payload));
225
225
  } catch (x) {
226
226
  return null;
227
227
  }
@@ -469,9 +469,9 @@ function requireReactJsxRuntime_development() {
469
469
  case REACT_LAZY_TYPE: {
470
470
  var lazyComponent = type;
471
471
  var payload = lazyComponent._payload;
472
- var init = lazyComponent._init;
472
+ var init2 = lazyComponent._init;
473
473
  try {
474
- return describeUnknownElementTypeFrameInDEV(init(payload), source, ownerFn);
474
+ return describeUnknownElementTypeFrameInDEV(init2(payload), source, ownerFn);
475
475
  } catch (x) {
476
476
  }
477
477
  }
@@ -1134,11 +1134,65 @@ class NeoFaceError extends Error {
1134
1134
  this.type = type;
1135
1135
  }
1136
1136
  }
1137
- const __vite_import_meta_env__$1 = {};
1138
- const API_BASE_URL = __vite_import_meta_env__$1 == null ? void 0 : __vite_import_meta_env__$1.VITE_API_BASE_URL;
1139
- if (!API_BASE_URL) {
1140
- console.error("[NeoFaceID SDK] VITE_API_BASE_URL não está configurado. Configure no arquivo .env");
1137
+ const __vite_import_meta_env__ = {};
1138
+ const ENVIRONMENT_URLS = {
1139
+ development: "http://localhost:8000",
1140
+ sandbox: "https://sandbox-core.neofaceid.com",
1141
+ production: "https://core.neofaceid.com.br"
1142
+ };
1143
+ let globalConfig = {
1144
+ baseUrl: ENVIRONMENT_URLS.sandbox,
1145
+ // Default para sandbox
1146
+ applicationToken: null,
1147
+ environment: "sandbox",
1148
+ initialized: false
1149
+ };
1150
+ function init(options = {}) {
1151
+ const { environment, baseUrl, applicationToken } = options;
1152
+ if (baseUrl) {
1153
+ globalConfig.baseUrl = baseUrl;
1154
+ globalConfig.environment = "custom";
1155
+ } else if (environment) {
1156
+ if (!ENVIRONMENT_URLS[environment]) {
1157
+ console.warn(`[NeoFaceID SDK] Ambiente '${environment}' não reconhecido. Usando 'sandbox'.`);
1158
+ globalConfig.baseUrl = ENVIRONMENT_URLS.sandbox;
1159
+ globalConfig.environment = "sandbox";
1160
+ } else {
1161
+ globalConfig.baseUrl = ENVIRONMENT_URLS[environment];
1162
+ globalConfig.environment = environment;
1163
+ }
1164
+ } else {
1165
+ const envUrl = typeof import.meta !== "undefined" && (__vite_import_meta_env__ == null ? void 0 : __vite_import_meta_env__.VITE_API_BASE_URL);
1166
+ if (envUrl) {
1167
+ globalConfig.baseUrl = envUrl;
1168
+ globalConfig.environment = "custom";
1169
+ }
1170
+ }
1171
+ if (applicationToken) {
1172
+ globalConfig.applicationToken = applicationToken;
1173
+ }
1174
+ globalConfig.initialized = true;
1175
+ console.log(`[NeoFaceID SDK] Inicializado - Ambiente: ${globalConfig.environment}, URL: ${globalConfig.baseUrl}`);
1176
+ }
1177
+ function getBaseUrl() {
1178
+ if (!globalConfig.initialized) {
1179
+ console.warn("[NeoFaceID SDK] SDK não foi inicializado. Usando configuração padrão (sandbox).");
1180
+ }
1181
+ return globalConfig.baseUrl;
1182
+ }
1183
+ function getApplicationToken() {
1184
+ return globalConfig.applicationToken;
1185
+ }
1186
+ function getEnvironment() {
1187
+ return globalConfig.environment;
1188
+ }
1189
+ function isInitialized() {
1190
+ return globalConfig.initialized;
1191
+ }
1192
+ function getConfig() {
1193
+ return { ...globalConfig };
1141
1194
  }
1195
+ const getApiBaseUrl = () => getBaseUrl();
1142
1196
  const REQUEST_TIMEOUT = 1e4;
1143
1197
  const ensureSecureContext = () => {
1144
1198
  const isLocalhost = window.location.hostname === "localhost" || window.location.hostname === "127.0.0.1" || window.location.hostname === "";
@@ -1228,7 +1282,7 @@ const validateToken = async (applicationToken) => {
1228
1282
  ensureSecureContext();
1229
1283
  const controller = createTimeoutController();
1230
1284
  try {
1231
- const response = await fetch(`${API_BASE_URL}/api/v1/auth/application/validate_token/`, {
1285
+ const response = await fetch(`${getApiBaseUrl()}/api/v1/auth/application/validate_token/`, {
1232
1286
  method: "POST",
1233
1287
  headers: {
1234
1288
  "Content-Type": "application/json",
@@ -1253,7 +1307,7 @@ const getOnboardingDetails = async (applicationToken, onboardingToken) => {
1253
1307
  const controller = createTimeoutController();
1254
1308
  try {
1255
1309
  const response = await fetch(
1256
- `${API_BASE_URL}/api/v1/onboardings/${encodeURIComponent(onboardingToken)}/`,
1310
+ `${getApiBaseUrl()}/api/v1/onboardings/${encodeURIComponent(onboardingToken)}/`,
1257
1311
  {
1258
1312
  method: "GET",
1259
1313
  headers: {
@@ -1291,7 +1345,7 @@ const validateOnboardingToken = async (applicationToken, onboardingToken) => {
1291
1345
  const controller = createTimeoutController();
1292
1346
  try {
1293
1347
  const response = await fetch(
1294
- `${API_BASE_URL}/api/v1/onboardings/${encodeURIComponent(onboardingToken)}/`,
1348
+ `${getApiBaseUrl()}/api/v1/onboardings/${encodeURIComponent(onboardingToken)}/`,
1295
1349
  {
1296
1350
  method: "GET",
1297
1351
  headers: {
@@ -1334,7 +1388,7 @@ const completeOnboarding = async (applicationToken, onboardingToken, faceImage,
1334
1388
  formData.append("face_image", compressedFace, "face.jpg");
1335
1389
  formData.append("document_image", compressedDocument, "document.jpg");
1336
1390
  const response = await fetch(
1337
- `${API_BASE_URL}/api/v1/onboardings/${encodeURIComponent(onboardingToken)}/complete`,
1391
+ `${getApiBaseUrl()}/api/v1/onboardings/${encodeURIComponent(onboardingToken)}/complete`,
1338
1392
  {
1339
1393
  method: "POST",
1340
1394
  headers: {
@@ -1411,7 +1465,7 @@ const completeOnboardingWithData = async (applicationToken, onboardingToken, per
1411
1465
  formData.append("email", personData.email);
1412
1466
  }
1413
1467
  const response = await fetch(
1414
- `${API_BASE_URL}/api/v1/onboardings/${encodeURIComponent(onboardingToken)}/complete`,
1468
+ `${getApiBaseUrl()}/api/v1/onboardings/${encodeURIComponent(onboardingToken)}/complete`,
1415
1469
  {
1416
1470
  method: "POST",
1417
1471
  headers: {
@@ -1465,7 +1519,7 @@ const recognize = async (image, applicationToken) => {
1465
1519
  try {
1466
1520
  const formData = new FormData();
1467
1521
  formData.append("face_frames", compressedImage);
1468
- const response = await fetch(`${API_BASE_URL}/api/v1/external/recognition/face/`, {
1522
+ const response = await fetch(`${getApiBaseUrl()}/api/v1/external/recognition/face/`, {
1469
1523
  method: "POST",
1470
1524
  headers: {
1471
1525
  "X-App-Token": applicationToken
@@ -1510,7 +1564,7 @@ const loginWithBiometric$1 = async (image, applicationToken) => {
1510
1564
  const base64Image = btoa(
1511
1565
  new Uint8Array(arrayBuffer).reduce((data2, byte) => data2 + String.fromCharCode(byte), "")
1512
1566
  );
1513
- const response = await fetch(`${API_BASE_URL}/api/v1/login/donor/face/`, {
1567
+ const response = await fetch(`${getApiBaseUrl()}/api/v1/login/donor/face/`, {
1514
1568
  method: "POST",
1515
1569
  headers: {
1516
1570
  "Content-Type": "application/json",
@@ -1572,7 +1626,7 @@ const recognizeBiometric = async (image, applicationToken, livenessCheck = true,
1572
1626
  formData.append("face_frames", compressedImage);
1573
1627
  formData.append("liveness_check", livenessCheck.toString());
1574
1628
  formData.append("confidence_threshold", confidenceThreshold.toString());
1575
- const response = await fetch(`${API_BASE_URL}/api/v1/external/recognition/biometric/`, {
1629
+ const response = await fetch(`${getApiBaseUrl()}/api/v1/external/recognition/biometric/`, {
1576
1630
  method: "POST",
1577
1631
  headers: {
1578
1632
  "X-App-Token": applicationToken
@@ -1611,7 +1665,7 @@ const simpleIdentification = async (documentType, documentNumber, applicationTok
1611
1665
  ensureSecureContext();
1612
1666
  const controller = createTimeoutController();
1613
1667
  try {
1614
- const response = await fetch(`${API_BASE_URL}/api/v1/external/recognition/simple/`, {
1668
+ const response = await fetch(`${getApiBaseUrl()}/api/v1/external/recognition/simple/`, {
1615
1669
  method: "POST",
1616
1670
  headers: {
1617
1671
  "Content-Type": "application/json",
@@ -1677,7 +1731,7 @@ const recognizeByPurpose = async (image, applicationToken, purpose, confidenceTh
1677
1731
  if (signature) {
1678
1732
  requestBody.signature = signature;
1679
1733
  }
1680
- const response = await fetch(`${API_BASE_URL}/api/v1/external/recognition/purpose/`, {
1734
+ const response = await fetch(`${getApiBaseUrl()}/api/v1/external/recognition/purpose/`, {
1681
1735
  method: "POST",
1682
1736
  headers: {
1683
1737
  "Content-Type": "application/json",
@@ -1758,7 +1812,7 @@ const registerPersonWithoutFace = async (personData, applicationToken, options)
1758
1812
  type: (options == null ? void 0 : options.documentType) || "RG"
1759
1813
  }];
1760
1814
  }
1761
- const response = await fetch(`${API_BASE_URL}/api/v1/signup/donor/`, {
1815
+ const response = await fetch(`${getApiBaseUrl()}/api/v1/signup/donor/`, {
1762
1816
  method: "POST",
1763
1817
  headers: {
1764
1818
  "Content-Type": "application/json",
@@ -1852,7 +1906,7 @@ const registerPersonWithBiometric = async (personData, facePhotos, applicationTo
1852
1906
  type: (options == null ? void 0 : options.documentType) || "RG"
1853
1907
  }];
1854
1908
  }
1855
- const response = await fetch(`${API_BASE_URL}/api/v1/signup/donor/`, {
1909
+ const response = await fetch(`${getApiBaseUrl()}/api/v1/signup/donor/`, {
1856
1910
  method: "POST",
1857
1911
  headers: {
1858
1912
  "Content-Type": "application/json",
@@ -1938,7 +1992,7 @@ const loginWithEmail = async (email, password, applicationToken) => {
1938
1992
  ensureSecureContext();
1939
1993
  const controller = createTimeoutController();
1940
1994
  try {
1941
- const response = await fetch(`${API_BASE_URL}/api/v1/auth/login/`, {
1995
+ const response = await fetch(`${getApiBaseUrl()}/api/v1/auth/login/`, {
1942
1996
  method: "POST",
1943
1997
  headers: {
1944
1998
  "Content-Type": "application/json",
@@ -1995,7 +2049,7 @@ const identifyPerson = async (image, applicationToken) => {
1995
2049
  reader.readAsDataURL(compressedImage);
1996
2050
  });
1997
2051
  try {
1998
- const response = await fetch(`${API_BASE_URL}/api/v1/external/recognition/face/`, {
2052
+ const response = await fetch(`${getApiBaseUrl()}/api/v1/external/recognition/face/`, {
1999
2053
  method: "POST",
2000
2054
  headers: {
2001
2055
  "Content-Type": "application/json",
@@ -2072,7 +2126,7 @@ const registerBiometric = async (personId, faceImage, applicationToken) => {
2072
2126
  reader.readAsDataURL(compressedImage);
2073
2127
  });
2074
2128
  try {
2075
- const response = await fetch(`${API_BASE_URL}/api/v1/identity-data/`, {
2129
+ const response = await fetch(`${getApiBaseUrl()}/api/v1/identity-data/`, {
2076
2130
  method: "POST",
2077
2131
  headers: {
2078
2132
  "Content-Type": "application/json",
@@ -2132,7 +2186,7 @@ const registerApplication = async (jwtToken, consumerId, applicationData) => {
2132
2186
  ensureSecureContext();
2133
2187
  const controller = createTimeoutController();
2134
2188
  try {
2135
- const response = await fetch(`${API_BASE_URL}/api/v1/applications/`, {
2189
+ const response = await fetch(`${getApiBaseUrl()}/api/v1/applications/`, {
2136
2190
  method: "POST",
2137
2191
  headers: {
2138
2192
  "Content-Type": "application/json",
@@ -2287,7 +2341,7 @@ const pollTaskStatus = async (taskId, applicationToken, options = {}) => {
2287
2341
  while (attempts < maxAttempts) {
2288
2342
  attempts++;
2289
2343
  try {
2290
- const response = await fetch(`${API_BASE_URL}/api/v1/tasks/status/?task_id=${taskId}`, {
2344
+ const response = await fetch(`${getApiBaseUrl()}/api/v1/tasks/status/?task_id=${taskId}`, {
2291
2345
  method: "GET",
2292
2346
  headers: {
2293
2347
  Accept: "application/json",
@@ -2331,7 +2385,7 @@ const startProofOfLife = async (videoBase64, applicationToken) => {
2331
2385
  ensureSecureContext();
2332
2386
  const controller = createTimeoutController();
2333
2387
  try {
2334
- const response = await fetch(`${API_BASE_URL}/api/v1/auth/recognition/face/external/`, {
2388
+ const response = await fetch(`${getApiBaseUrl()}/api/v1/auth/recognition/face/external/`, {
2335
2389
  method: "POST",
2336
2390
  headers: {
2337
2391
  "Content-Type": "application/json",
@@ -5714,8 +5768,8 @@ const biometricDetection = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.
5714
5768
  initializeBiometricDetection,
5715
5769
  isAdvancedDetectionAvailable
5716
5770
  }, Symbol.toStringTag, { value: "Module" }));
5717
- const VERSION = "1.9.0";
5718
- const RELEASE_DATE = "2026-01-20";
5771
+ const VERSION = "1.10.0";
5772
+ const RELEASE_DATE = "2026-01-21";
5719
5773
  class OnboardingCaptureModal {
5720
5774
  constructor(options) {
5721
5775
  __publicField(this, "overlay", null);
@@ -5933,7 +5987,6 @@ const startOnboarding = async (options) => {
5933
5987
  onError(new NeoFaceError(message, ErrorType.UNKNOWN));
5934
5988
  }
5935
5989
  };
5936
- const __vite_import_meta_env__ = {};
5937
5990
  class NeoFaceID {
5938
5991
  /**
5939
5992
  * Creates a new NeoFaceID instance
@@ -5946,15 +5999,9 @@ class NeoFaceID {
5946
5999
  __publicField(this, "signature");
5947
6000
  __publicField(this, "sessionData");
5948
6001
  this.appToken = config.appToken;
5949
- this.baseUrl = config.baseUrl || (__vite_import_meta_env__ == null ? void 0 : __vite_import_meta_env__.VITE_API_BASE_URL);
6002
+ this.baseUrl = config.baseUrl || getBaseUrl();
5950
6003
  this.signature = config.signature;
5951
6004
  this.sessionData = config.sessionData;
5952
- if (!this.baseUrl) {
5953
- throw new NeoFaceError(
5954
- "baseUrl não configurado. Passe via config ou configure VITE_API_BASE_URL no .env",
5955
- ErrorType.VALIDATION_ERROR
5956
- );
5957
- }
5958
6005
  if (this.signature && !this.validateSignatureFormat(this.signature)) {
5959
6006
  throw new NeoFaceError(
5960
6007
  "Invalid signature format. Expected HMAC-SHA256 hex string (minimum 64 characters)",
@@ -7445,6 +7492,7 @@ export {
7445
7492
  BiometricRegistrationModal,
7446
7493
  BiometricStatusOverlay,
7447
7494
  DocumentCaptureModal,
7495
+ ENVIRONMENT_URLS,
7448
7496
  EmailPasswordModal,
7449
7497
  ErrorType,
7450
7498
  FaceCaptureModal,
@@ -7459,9 +7507,15 @@ export {
7459
7507
  completeOnboarding,
7460
7508
  completeOnboardingWithData,
7461
7509
  detectBiometricType,
7510
+ getApplicationToken,
7511
+ getBaseUrl,
7512
+ getConfig,
7513
+ getEnvironment,
7462
7514
  identifyPerson,
7515
+ init,
7463
7516
  initializeBiometricDetection,
7464
7517
  isAdvancedDetectionAvailable,
7518
+ isInitialized,
7465
7519
  loginWithBiometric$1 as loginWithBiometric,
7466
7520
  loginWithEmail,
7467
7521
  preloadFaceDetectionModels,