astra-sdk-web 1.1.17 → 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.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.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/pages/QRCodePage.tsx +27 -5
- package/src/services/kycApiService.ts +34 -0
package/dist/astra-sdk.d.cts
CHANGED
package/dist/astra-sdk.es.js
CHANGED
|
@@ -262,6 +262,36 @@ var KycApiService = class {
|
|
|
262
262
|
throw new Error(`Status fetch failed: ${message}`);
|
|
263
263
|
}
|
|
264
264
|
}
|
|
265
|
+
/**
|
|
266
|
+
* Get session result (kyc result)
|
|
267
|
+
*/
|
|
268
|
+
async getResult() {
|
|
269
|
+
const deviceType = this.config.deviceType || this.detectDeviceType();
|
|
270
|
+
try {
|
|
271
|
+
const response = await fetch(
|
|
272
|
+
`${this.config.apiBaseUrl}/api/v2/dashboard/merchant/onsite/session/${this.config.sessionId}/result`,
|
|
273
|
+
{
|
|
274
|
+
method: "GET",
|
|
275
|
+
headers: {
|
|
276
|
+
"x-server-key": this.config.serverKey,
|
|
277
|
+
"device-type": deviceType,
|
|
278
|
+
"Content-Type": "application/json"
|
|
279
|
+
},
|
|
280
|
+
credentials: "include"
|
|
281
|
+
}
|
|
282
|
+
);
|
|
283
|
+
if (!response.ok) {
|
|
284
|
+
const errorData = await response.json().catch(() => ({}));
|
|
285
|
+
const message = errorData?.message || `Result fetch failed with status ${response.status}`;
|
|
286
|
+
throw new Error(message);
|
|
287
|
+
}
|
|
288
|
+
const data = await response.json();
|
|
289
|
+
return data;
|
|
290
|
+
} catch (error) {
|
|
291
|
+
const message = error?.message || "Result fetch failed";
|
|
292
|
+
throw new Error(`Result fetch failed: ${message}`);
|
|
293
|
+
}
|
|
294
|
+
}
|
|
265
295
|
/**
|
|
266
296
|
* Upload face scan image
|
|
267
297
|
*/
|
|
@@ -1902,7 +1932,7 @@ function MobileRoute({ onClose, onNavigate } = {}) {
|
|
|
1902
1932
|
] }) });
|
|
1903
1933
|
}
|
|
1904
1934
|
var MobileRoute_default = MobileRoute;
|
|
1905
|
-
function QRCodePage({ onClose,
|
|
1935
|
+
function QRCodePage({ onClose, mobileBaseUrl = "https://kyc-sdk-stage.astraprotocol.com", sessionId, apiBaseUrl, serverKey } = {}) {
|
|
1906
1936
|
const [qrUrl, setQrUrl] = useState("");
|
|
1907
1937
|
const [copied, setCopied] = useState(false);
|
|
1908
1938
|
useEffect(() => {
|
|
@@ -1937,8 +1967,25 @@ function QRCodePage({ onClose, onNavigate, mobileBaseUrl = "https://kyc-sdk-stag
|
|
|
1937
1967
|
onClose();
|
|
1938
1968
|
}
|
|
1939
1969
|
};
|
|
1940
|
-
const
|
|
1941
|
-
|
|
1970
|
+
const handleCheckResult = async () => {
|
|
1971
|
+
if (!apiBaseUrl || !sessionId || !serverKey) {
|
|
1972
|
+
alert("Missing configuration to check KYC result.");
|
|
1973
|
+
return;
|
|
1974
|
+
}
|
|
1975
|
+
try {
|
|
1976
|
+
const svc = new KycApiService({ apiBaseUrl, sessionId, serverKey });
|
|
1977
|
+
const payload = await svc.getResult();
|
|
1978
|
+
const first = Array.isArray(payload?.data) && payload.data.length > 0 ? payload.data[0] : null;
|
|
1979
|
+
if (first && first.kyc_status === "success" && first.redirectUrl) {
|
|
1980
|
+
window.location.href = first.redirectUrl;
|
|
1981
|
+
return;
|
|
1982
|
+
}
|
|
1983
|
+
alert("Please complete your KYC first.");
|
|
1984
|
+
} catch (error) {
|
|
1985
|
+
const msg = error?.message || "Result fetch failed";
|
|
1986
|
+
console.error("getResult:error", msg);
|
|
1987
|
+
alert(`Result fetch failed: ${msg}`);
|
|
1988
|
+
}
|
|
1942
1989
|
};
|
|
1943
1990
|
return /* @__PURE__ */ 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: [
|
|
1944
1991
|
/* @__PURE__ */ jsx("div", { className: "absolute inset-0 opacity-10", style: {
|
|
@@ -1995,8 +2042,8 @@ function QRCodePage({ onClose, onNavigate, mobileBaseUrl = "https://kyc-sdk-stag
|
|
|
1995
2042
|
"button",
|
|
1996
2043
|
{
|
|
1997
2044
|
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",
|
|
1998
|
-
onClick:
|
|
1999
|
-
children: "I've completed on mobile -
|
|
2045
|
+
onClick: handleCheckResult,
|
|
2046
|
+
children: "I've completed on mobile - Move to next step"
|
|
2000
2047
|
}
|
|
2001
2048
|
)
|
|
2002
2049
|
] })
|