astra-sdk-web 1.1.16 → 1.1.18
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/astra-sdk.cjs.js +52 -5
- package/dist/astra-sdk.cjs.js.map +1 -1
- package/dist/astra-sdk.css.map +1 -1
- package/dist/astra-sdk.d.cts +4 -0
- package/dist/astra-sdk.es.js +52 -5
- package/dist/astra-sdk.es.js.map +1 -1
- package/dist/components.cjs.js +52 -5
- package/dist/components.cjs.js.map +1 -1
- package/dist/components.css.map +1 -1
- package/dist/components.es.js +52 -5
- package/dist/components.es.js.map +1 -1
- package/dist/index.d.ts +4 -0
- package/package.json +1 -1
- package/src/index.css +6 -0
- package/src/pages/QRCodePage.tsx +27 -5
- package/src/services/kycApiService.ts +34 -0
package/dist/components.cjs.js
CHANGED
|
@@ -65,6 +65,36 @@ var KycApiService = class {
|
|
|
65
65
|
throw new Error(`Status fetch failed: ${message}`);
|
|
66
66
|
}
|
|
67
67
|
}
|
|
68
|
+
/**
|
|
69
|
+
* Get session result (kyc result)
|
|
70
|
+
*/
|
|
71
|
+
async getResult() {
|
|
72
|
+
const deviceType = this.config.deviceType || this.detectDeviceType();
|
|
73
|
+
try {
|
|
74
|
+
const response = await fetch(
|
|
75
|
+
`${this.config.apiBaseUrl}/api/v2/dashboard/merchant/onsite/session/${this.config.sessionId}/result`,
|
|
76
|
+
{
|
|
77
|
+
method: "GET",
|
|
78
|
+
headers: {
|
|
79
|
+
"x-server-key": this.config.serverKey,
|
|
80
|
+
"device-type": deviceType,
|
|
81
|
+
"Content-Type": "application/json"
|
|
82
|
+
},
|
|
83
|
+
credentials: "include"
|
|
84
|
+
}
|
|
85
|
+
);
|
|
86
|
+
if (!response.ok) {
|
|
87
|
+
const errorData = await response.json().catch(() => ({}));
|
|
88
|
+
const message = errorData?.message || `Result fetch failed with status ${response.status}`;
|
|
89
|
+
throw new Error(message);
|
|
90
|
+
}
|
|
91
|
+
const data = await response.json();
|
|
92
|
+
return data;
|
|
93
|
+
} catch (error) {
|
|
94
|
+
const message = error?.message || "Result fetch failed";
|
|
95
|
+
throw new Error(`Result fetch failed: ${message}`);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
68
98
|
/**
|
|
69
99
|
* Upload face scan image
|
|
70
100
|
*/
|
|
@@ -1705,7 +1735,7 @@ function MobileRoute({ onClose, onNavigate } = {}) {
|
|
|
1705
1735
|
] }) });
|
|
1706
1736
|
}
|
|
1707
1737
|
var MobileRoute_default = MobileRoute;
|
|
1708
|
-
function QRCodePage({ onClose,
|
|
1738
|
+
function QRCodePage({ onClose, mobileBaseUrl = "https://kyc-sdk-stage.astraprotocol.com", sessionId, apiBaseUrl, serverKey } = {}) {
|
|
1709
1739
|
const [qrUrl, setQrUrl] = React.useState("");
|
|
1710
1740
|
const [copied, setCopied] = React.useState(false);
|
|
1711
1741
|
React.useEffect(() => {
|
|
@@ -1740,8 +1770,25 @@ function QRCodePage({ onClose, onNavigate, mobileBaseUrl = "https://kyc-sdk-stag
|
|
|
1740
1770
|
onClose();
|
|
1741
1771
|
}
|
|
1742
1772
|
};
|
|
1743
|
-
const
|
|
1744
|
-
|
|
1773
|
+
const handleCheckResult = async () => {
|
|
1774
|
+
if (!apiBaseUrl || !sessionId || !serverKey) {
|
|
1775
|
+
alert("Missing configuration to check KYC result.");
|
|
1776
|
+
return;
|
|
1777
|
+
}
|
|
1778
|
+
try {
|
|
1779
|
+
const svc = new KycApiService({ apiBaseUrl, sessionId, serverKey });
|
|
1780
|
+
const payload = await svc.getResult();
|
|
1781
|
+
const first = Array.isArray(payload?.data) && payload.data.length > 0 ? payload.data[0] : null;
|
|
1782
|
+
if (first && first.kyc_status === "success" && first.redirectUrl) {
|
|
1783
|
+
window.location.href = first.redirectUrl;
|
|
1784
|
+
return;
|
|
1785
|
+
}
|
|
1786
|
+
alert("Please complete your KYC first.");
|
|
1787
|
+
} catch (error) {
|
|
1788
|
+
const msg = error?.message || "Result fetch failed";
|
|
1789
|
+
console.error("getResult:error", msg);
|
|
1790
|
+
alert(`Result fetch failed: ${msg}`);
|
|
1791
|
+
}
|
|
1745
1792
|
};
|
|
1746
1793
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "fixed inset-0 flex items-center justify-center bg-gradient-to-br from-gray-900 via-gray-800 to-black p-4 sm:p-6 md:p-8 z-[1000]", children: [
|
|
1747
1794
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "absolute inset-0 opacity-10", style: {
|
|
@@ -1798,8 +1845,8 @@ function QRCodePage({ onClose, onNavigate, mobileBaseUrl = "https://kyc-sdk-stag
|
|
|
1798
1845
|
"button",
|
|
1799
1846
|
{
|
|
1800
1847
|
className: "w-full py-3 sm:py-4 px-6 bg-gradient-to-r from-[#FF842D] to-[#FF2D55] border-none rounded-lg text-white text-sm sm:text-base font-semibold cursor-pointer transition-all hover:-translate-y-0.5 hover:shadow-[0_4px_12px_rgba(255,107,53,0.4)] active:translate-y-0",
|
|
1801
|
-
onClick:
|
|
1802
|
-
children: "I've completed on mobile -
|
|
1848
|
+
onClick: handleCheckResult,
|
|
1849
|
+
children: "I've completed on mobile - Move to next step"
|
|
1803
1850
|
}
|
|
1804
1851
|
)
|
|
1805
1852
|
] })
|