@neofaceid/web-sdk 1.2.0 → 1.3.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.
|
@@ -1705,6 +1705,75 @@ const loginWithEmail = async (email, password, applicationToken) => {
|
|
|
1705
1705
|
throw new NeoFaceError("Unknown error occurred", ErrorType.NETWORK_ERROR);
|
|
1706
1706
|
}
|
|
1707
1707
|
};
|
|
1708
|
+
const identifyPerson = async (image, applicationToken) => {
|
|
1709
|
+
var _a, _b;
|
|
1710
|
+
ensureSecureContext();
|
|
1711
|
+
const controller = createTimeoutController();
|
|
1712
|
+
const compressedImage = await compressImage(image);
|
|
1713
|
+
const base64Image = await new Promise((resolve, reject) => {
|
|
1714
|
+
const reader = new FileReader();
|
|
1715
|
+
reader.onload = () => {
|
|
1716
|
+
const result = reader.result;
|
|
1717
|
+
resolve(result.split(",")[1]);
|
|
1718
|
+
};
|
|
1719
|
+
reader.onerror = reject;
|
|
1720
|
+
reader.readAsDataURL(compressedImage);
|
|
1721
|
+
});
|
|
1722
|
+
try {
|
|
1723
|
+
const response = await fetch(`${API_BASE_URL}/api/v1/external/recognition/face/`, {
|
|
1724
|
+
method: "POST",
|
|
1725
|
+
headers: {
|
|
1726
|
+
"Content-Type": "application/json",
|
|
1727
|
+
"X-App-Token": applicationToken
|
|
1728
|
+
},
|
|
1729
|
+
body: JSON.stringify({
|
|
1730
|
+
image: base64Image,
|
|
1731
|
+
purpose: "SIMPLE_IDENTIFICATION_F"
|
|
1732
|
+
}),
|
|
1733
|
+
signal: controller.signal
|
|
1734
|
+
});
|
|
1735
|
+
if (!response.ok) {
|
|
1736
|
+
if (response.status === 401 || response.status === 403) {
|
|
1737
|
+
throw new NeoFaceError("Invalid or expired application token", ErrorType.INVALID_TOKEN);
|
|
1738
|
+
}
|
|
1739
|
+
throw new NeoFaceError(`Server returned status ${response.status}`, ErrorType.NETWORK);
|
|
1740
|
+
}
|
|
1741
|
+
const data = await response.json();
|
|
1742
|
+
if (!data.success) {
|
|
1743
|
+
throw new NeoFaceError(data.message || "Person identification failed", ErrorType.RECOGNITION_FAILED);
|
|
1744
|
+
}
|
|
1745
|
+
const personName = ((_a = data.person) == null ? void 0 : _a.name) || "";
|
|
1746
|
+
const birthDateStr = (_b = data.person) == null ? void 0 : _b.birth_date;
|
|
1747
|
+
if (!personName) {
|
|
1748
|
+
throw new NeoFaceError("Person name not found in response", ErrorType.PERSON_NOT_FOUND);
|
|
1749
|
+
}
|
|
1750
|
+
if (!birthDateStr) {
|
|
1751
|
+
throw new NeoFaceError("Birth date not found in response", ErrorType.PERSON_NOT_FOUND);
|
|
1752
|
+
}
|
|
1753
|
+
const birthDate = new Date(birthDateStr);
|
|
1754
|
+
const today = /* @__PURE__ */ new Date();
|
|
1755
|
+
let age = today.getFullYear() - birthDate.getFullYear();
|
|
1756
|
+
const monthDiff = today.getMonth() - birthDate.getMonth();
|
|
1757
|
+
if (monthDiff < 0 || monthDiff === 0 && today.getDate() < birthDate.getDate()) {
|
|
1758
|
+
age--;
|
|
1759
|
+
}
|
|
1760
|
+
return {
|
|
1761
|
+
name: personName,
|
|
1762
|
+
age
|
|
1763
|
+
};
|
|
1764
|
+
} catch (error) {
|
|
1765
|
+
if (error instanceof Error) {
|
|
1766
|
+
if (error.name === "AbortError") {
|
|
1767
|
+
throw new NeoFaceError("Request timed out", ErrorType.NETWORK);
|
|
1768
|
+
}
|
|
1769
|
+
if (error instanceof NeoFaceError) {
|
|
1770
|
+
throw error;
|
|
1771
|
+
}
|
|
1772
|
+
throw new NeoFaceError(error.message, ErrorType.NETWORK);
|
|
1773
|
+
}
|
|
1774
|
+
throw new NeoFaceError("Unknown error occurred", ErrorType.NETWORK_ERROR);
|
|
1775
|
+
}
|
|
1776
|
+
};
|
|
1708
1777
|
const modalReducer$1 = (state, action) => {
|
|
1709
1778
|
switch (action.type) {
|
|
1710
1779
|
case "PERMISSION_GRANTED":
|
|
@@ -4040,8 +4109,8 @@ const biometricDetection = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.
|
|
|
4040
4109
|
initializeBiometricDetection,
|
|
4041
4110
|
isAdvancedDetectionAvailable
|
|
4042
4111
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
4043
|
-
const VERSION = "1.
|
|
4044
|
-
const RELEASE_DATE = "2025-11-
|
|
4112
|
+
const VERSION = "1.3.0";
|
|
4113
|
+
const RELEASE_DATE = "2025-11-17";
|
|
4045
4114
|
class OnboardingCaptureModal {
|
|
4046
4115
|
constructor(options) {
|
|
4047
4116
|
__publicField(this, "overlay", null);
|
|
@@ -4337,6 +4406,7 @@ export {
|
|
|
4337
4406
|
biometricLogin,
|
|
4338
4407
|
biometricLoginWithFallback,
|
|
4339
4408
|
detectBiometricType,
|
|
4409
|
+
identifyPerson,
|
|
4340
4410
|
initializeBiometricDetection,
|
|
4341
4411
|
isAdvancedDetectionAvailable,
|
|
4342
4412
|
loginWithBiometric,
|