@neofaceid/web-sdk 1.15.0 → 1.15.2
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.
|
@@ -1652,110 +1652,6 @@ const loginWithBiometric = async (image, applicationToken) => {
|
|
|
1652
1652
|
throw new NeoFaceError("Unknown error occurred", ErrorType.NETWORK_ERROR);
|
|
1653
1653
|
}
|
|
1654
1654
|
};
|
|
1655
|
-
const loginWithBiometricSSE = async (image, applicationToken) => {
|
|
1656
|
-
var _a;
|
|
1657
|
-
ensureSecureContext();
|
|
1658
|
-
const compressedImage = await compressImage(image);
|
|
1659
|
-
const arrayBuffer = await compressedImage.arrayBuffer();
|
|
1660
|
-
const base64Image = btoa(
|
|
1661
|
-
new Uint8Array(arrayBuffer).reduce((data, byte) => data + String.fromCharCode(byte), "")
|
|
1662
|
-
);
|
|
1663
|
-
const controller = createTimeoutController();
|
|
1664
|
-
let response;
|
|
1665
|
-
try {
|
|
1666
|
-
response = await fetch(`${getApiBaseUrl()}/api/v1/auth/recognition/face/external/`, {
|
|
1667
|
-
method: "POST",
|
|
1668
|
-
headers: {
|
|
1669
|
-
"Content-Type": "application/json",
|
|
1670
|
-
"X-App-Token": applicationToken
|
|
1671
|
-
},
|
|
1672
|
-
body: JSON.stringify({ image: base64Image, purpose: "LOGIN" }),
|
|
1673
|
-
signal: controller.signal
|
|
1674
|
-
});
|
|
1675
|
-
} catch (error) {
|
|
1676
|
-
if (error instanceof Error) {
|
|
1677
|
-
if (error.name === "AbortError") {
|
|
1678
|
-
throw new NeoFaceError("Request timed out", ErrorType.NETWORK);
|
|
1679
|
-
}
|
|
1680
|
-
if (error instanceof NeoFaceError) throw error;
|
|
1681
|
-
throw new NeoFaceError(error.message, ErrorType.NETWORK);
|
|
1682
|
-
}
|
|
1683
|
-
throw new NeoFaceError("Unknown error occurred", ErrorType.NETWORK_ERROR);
|
|
1684
|
-
}
|
|
1685
|
-
if (!response.ok) {
|
|
1686
|
-
if (response.status === 401 || response.status === 403) {
|
|
1687
|
-
throw new NeoFaceError("Invalid application token", ErrorType.INVALID_TOKEN);
|
|
1688
|
-
}
|
|
1689
|
-
throw new NeoFaceError(`API Error ${response.status}`, ErrorType.API_ERROR);
|
|
1690
|
-
}
|
|
1691
|
-
const initData = await response.json();
|
|
1692
|
-
if (!initData.success || !((_a = initData.data) == null ? void 0 : _a.task_id)) {
|
|
1693
|
-
throw new NeoFaceError(initData.message || "Failed to start login", ErrorType.LOGIN_FAILED);
|
|
1694
|
-
}
|
|
1695
|
-
const taskId = initData.data.task_id;
|
|
1696
|
-
return new Promise((resolve, reject) => {
|
|
1697
|
-
const sseUrl = `${getApiBaseUrl()}/api/v1/auth/recognition/face/external/login/events/${taskId}/`;
|
|
1698
|
-
const eventSource = new EventSource(sseUrl);
|
|
1699
|
-
const timeoutId = setTimeout(() => {
|
|
1700
|
-
eventSource.close();
|
|
1701
|
-
reject(new NeoFaceError("Login timeout", ErrorType.NETWORK));
|
|
1702
|
-
}, 31e4);
|
|
1703
|
-
const cleanup = () => {
|
|
1704
|
-
clearTimeout(timeoutId);
|
|
1705
|
-
eventSource.close();
|
|
1706
|
-
};
|
|
1707
|
-
eventSource.addEventListener("success", (event) => {
|
|
1708
|
-
var _a2, _b, _c, _d, _e, _f;
|
|
1709
|
-
cleanup();
|
|
1710
|
-
try {
|
|
1711
|
-
const data = JSON.parse(event.data);
|
|
1712
|
-
resolve({
|
|
1713
|
-
success: true,
|
|
1714
|
-
accessToken: data.token || data.access_token || "",
|
|
1715
|
-
alias: ((_a2 = data.user) == null ? void 0 : _a2.alias) || data.alias || "",
|
|
1716
|
-
user: {
|
|
1717
|
-
id: ((_b = data.user) == null ? void 0 : _b.id) || "",
|
|
1718
|
-
email: ((_c = data.user) == null ? void 0 : _c.email) || "",
|
|
1719
|
-
role: ((_d = data.user) == null ? void 0 : _d.role) || "",
|
|
1720
|
-
validated: ((_e = data.user) == null ? void 0 : _e.validated) ?? false,
|
|
1721
|
-
active: ((_f = data.user) == null ? void 0 : _f.active) ?? false
|
|
1722
|
-
},
|
|
1723
|
-
person: data.person ? { name: data.person.name || "", birth_date: data.person.birth_date || "" } : void 0,
|
|
1724
|
-
confidence_score: data.confidence_score,
|
|
1725
|
-
recognition_id: data.recognition_id ?? data.history_id
|
|
1726
|
-
});
|
|
1727
|
-
} catch {
|
|
1728
|
-
reject(new NeoFaceError("Erro ao processar resposta de login", ErrorType.API_ERROR));
|
|
1729
|
-
}
|
|
1730
|
-
});
|
|
1731
|
-
eventSource.addEventListener("failed", (event) => {
|
|
1732
|
-
cleanup();
|
|
1733
|
-
try {
|
|
1734
|
-
const data = JSON.parse(event.data);
|
|
1735
|
-
reject(new NeoFaceError(data.message || "Login failed", ErrorType.LOGIN_FAILED));
|
|
1736
|
-
} catch {
|
|
1737
|
-
reject(new NeoFaceError("Login failed", ErrorType.LOGIN_FAILED));
|
|
1738
|
-
}
|
|
1739
|
-
});
|
|
1740
|
-
eventSource.addEventListener("error", (event) => {
|
|
1741
|
-
cleanup();
|
|
1742
|
-
try {
|
|
1743
|
-
const data = JSON.parse(event.data || "{}");
|
|
1744
|
-
reject(new NeoFaceError(data.message || "Processing error", ErrorType.API_ERROR));
|
|
1745
|
-
} catch {
|
|
1746
|
-
reject(new NeoFaceError("Processing error", ErrorType.API_ERROR));
|
|
1747
|
-
}
|
|
1748
|
-
});
|
|
1749
|
-
eventSource.addEventListener("timeout", () => {
|
|
1750
|
-
cleanup();
|
|
1751
|
-
reject(new NeoFaceError("Login timeout", ErrorType.NETWORK));
|
|
1752
|
-
});
|
|
1753
|
-
eventSource.onerror = () => {
|
|
1754
|
-
cleanup();
|
|
1755
|
-
reject(new NeoFaceError("SSE connection error", ErrorType.NETWORK));
|
|
1756
|
-
};
|
|
1757
|
-
});
|
|
1758
|
-
};
|
|
1759
1655
|
const recognizeBiometric = async (image, applicationToken, livenessCheck = true, confidenceThreshold = 0.8) => {
|
|
1760
1656
|
ensureSecureContext();
|
|
1761
1657
|
const controller = createTimeoutController();
|
|
@@ -5832,7 +5728,7 @@ async function attemptLogin(applicationToken, overlay, fastMode = false, isRetry
|
|
|
5832
5728
|
);
|
|
5833
5729
|
});
|
|
5834
5730
|
overlay.updateStatus("verifying");
|
|
5835
|
-
const result = await
|
|
5731
|
+
const result = await loginWithBiometric(imageBlob, applicationToken);
|
|
5836
5732
|
if (!result.success) {
|
|
5837
5733
|
throw new NeoFaceError("Login falhou", ErrorType.LOGIN_FAILED);
|
|
5838
5734
|
}
|
|
@@ -5930,11 +5826,6 @@ const biometricLoginFlow = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.
|
|
|
5930
5826
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
5931
5827
|
async function startFaceLogin(options) {
|
|
5932
5828
|
try {
|
|
5933
|
-
const isValidToken = await validateToken(options.applicationToken);
|
|
5934
|
-
if (!isValidToken) {
|
|
5935
|
-
options.onError(new NeoFaceError("Token de aplicação inválido", ErrorType.INVALID_TOKEN));
|
|
5936
|
-
return;
|
|
5937
|
-
}
|
|
5938
5829
|
await executeBiometricLoginFlow({
|
|
5939
5830
|
applicationToken: options.applicationToken,
|
|
5940
5831
|
onSuccess: options.onSuccess,
|
|
@@ -5963,11 +5854,6 @@ async function startFaceLogin(options) {
|
|
|
5963
5854
|
}
|
|
5964
5855
|
async function startHandLogin(options) {
|
|
5965
5856
|
try {
|
|
5966
|
-
const isValidToken = await validateToken(options.applicationToken);
|
|
5967
|
-
if (!isValidToken) {
|
|
5968
|
-
options.onError(new NeoFaceError("Token de aplicação inválido", ErrorType.INVALID_TOKEN));
|
|
5969
|
-
return;
|
|
5970
|
-
}
|
|
5971
5857
|
const captureOptions = {
|
|
5972
5858
|
mode: "hand",
|
|
5973
5859
|
onSuccess: async (imageData, _detectedType) => {
|
|
@@ -5998,11 +5884,6 @@ async function startHandLogin(options) {
|
|
|
5998
5884
|
}
|
|
5999
5885
|
async function startAutoLogin(options) {
|
|
6000
5886
|
try {
|
|
6001
|
-
const isValidToken = await validateToken(options.applicationToken);
|
|
6002
|
-
if (!isValidToken) {
|
|
6003
|
-
options.onError(new NeoFaceError("Token de aplicação inválido", ErrorType.INVALID_TOKEN));
|
|
6004
|
-
return;
|
|
6005
|
-
}
|
|
6006
5887
|
const captureOptions = {
|
|
6007
5888
|
mode: "auto",
|
|
6008
5889
|
onSuccess: async (imageData, _detectedType) => {
|
|
@@ -6255,7 +6136,7 @@ const biometricDetection = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.
|
|
|
6255
6136
|
initializeBiometricDetection,
|
|
6256
6137
|
isAdvancedDetectionAvailable
|
|
6257
6138
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
6258
|
-
const VERSION = "1.15.
|
|
6139
|
+
const VERSION = "1.15.2";
|
|
6259
6140
|
const RELEASE_DATE = "2026-03-04";
|
|
6260
6141
|
class OnboardingCaptureModal {
|
|
6261
6142
|
constructor(options) {
|