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/astra-sdk.cjs.js
CHANGED
|
@@ -270,6 +270,36 @@ var KycApiService = class {
|
|
|
270
270
|
throw new Error(`Status fetch failed: ${message}`);
|
|
271
271
|
}
|
|
272
272
|
}
|
|
273
|
+
/**
|
|
274
|
+
* Get session result (kyc result)
|
|
275
|
+
*/
|
|
276
|
+
async getResult() {
|
|
277
|
+
const deviceType = this.config.deviceType || this.detectDeviceType();
|
|
278
|
+
try {
|
|
279
|
+
const response = await fetch(
|
|
280
|
+
`${this.config.apiBaseUrl}/api/v2/dashboard/merchant/onsite/session/${this.config.sessionId}/result`,
|
|
281
|
+
{
|
|
282
|
+
method: "GET",
|
|
283
|
+
headers: {
|
|
284
|
+
"x-server-key": this.config.serverKey,
|
|
285
|
+
"device-type": deviceType,
|
|
286
|
+
"Content-Type": "application/json"
|
|
287
|
+
},
|
|
288
|
+
credentials: "include"
|
|
289
|
+
}
|
|
290
|
+
);
|
|
291
|
+
if (!response.ok) {
|
|
292
|
+
const errorData = await response.json().catch(() => ({}));
|
|
293
|
+
const message = errorData?.message || `Result fetch failed with status ${response.status}`;
|
|
294
|
+
throw new Error(message);
|
|
295
|
+
}
|
|
296
|
+
const data = await response.json();
|
|
297
|
+
return data;
|
|
298
|
+
} catch (error) {
|
|
299
|
+
const message = error?.message || "Result fetch failed";
|
|
300
|
+
throw new Error(`Result fetch failed: ${message}`);
|
|
301
|
+
}
|
|
302
|
+
}
|
|
273
303
|
/**
|
|
274
304
|
* Upload face scan image
|
|
275
305
|
*/
|
|
@@ -1910,7 +1940,7 @@ function MobileRoute({ onClose, onNavigate } = {}) {
|
|
|
1910
1940
|
] }) });
|
|
1911
1941
|
}
|
|
1912
1942
|
var MobileRoute_default = MobileRoute;
|
|
1913
|
-
function QRCodePage({ onClose,
|
|
1943
|
+
function QRCodePage({ onClose, mobileBaseUrl = "https://kyc-sdk-stage.astraprotocol.com", sessionId, apiBaseUrl, serverKey } = {}) {
|
|
1914
1944
|
const [qrUrl, setQrUrl] = React.useState("");
|
|
1915
1945
|
const [copied, setCopied] = React.useState(false);
|
|
1916
1946
|
React.useEffect(() => {
|
|
@@ -1945,8 +1975,25 @@ function QRCodePage({ onClose, onNavigate, mobileBaseUrl = "https://kyc-sdk-stag
|
|
|
1945
1975
|
onClose();
|
|
1946
1976
|
}
|
|
1947
1977
|
};
|
|
1948
|
-
const
|
|
1949
|
-
|
|
1978
|
+
const handleCheckResult = async () => {
|
|
1979
|
+
if (!apiBaseUrl || !sessionId || !serverKey) {
|
|
1980
|
+
alert("Missing configuration to check KYC result.");
|
|
1981
|
+
return;
|
|
1982
|
+
}
|
|
1983
|
+
try {
|
|
1984
|
+
const svc = new KycApiService({ apiBaseUrl, sessionId, serverKey });
|
|
1985
|
+
const payload = await svc.getResult();
|
|
1986
|
+
const first = Array.isArray(payload?.data) && payload.data.length > 0 ? payload.data[0] : null;
|
|
1987
|
+
if (first && first.kyc_status === "success" && first.redirectUrl) {
|
|
1988
|
+
window.location.href = first.redirectUrl;
|
|
1989
|
+
return;
|
|
1990
|
+
}
|
|
1991
|
+
alert("Please complete your KYC first.");
|
|
1992
|
+
} catch (error) {
|
|
1993
|
+
const msg = error?.message || "Result fetch failed";
|
|
1994
|
+
console.error("getResult:error", msg);
|
|
1995
|
+
alert(`Result fetch failed: ${msg}`);
|
|
1996
|
+
}
|
|
1950
1997
|
};
|
|
1951
1998
|
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: [
|
|
1952
1999
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "absolute inset-0 opacity-10", style: {
|
|
@@ -2003,8 +2050,8 @@ function QRCodePage({ onClose, onNavigate, mobileBaseUrl = "https://kyc-sdk-stag
|
|
|
2003
2050
|
"button",
|
|
2004
2051
|
{
|
|
2005
2052
|
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",
|
|
2006
|
-
onClick:
|
|
2007
|
-
children: "I've completed on mobile -
|
|
2053
|
+
onClick: handleCheckResult,
|
|
2054
|
+
children: "I've completed on mobile - Move to next step"
|
|
2008
2055
|
}
|
|
2009
2056
|
)
|
|
2010
2057
|
] })
|