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/index.d.ts
CHANGED
package/package.json
CHANGED
package/src/index.css
CHANGED
package/src/pages/QRCodePage.tsx
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { useState, useEffect } from 'react';
|
|
2
2
|
import { QRCodeSVG } from 'qrcode.react';
|
|
3
|
+
import { KycApiService } from '../services/kycApiService';
|
|
3
4
|
import '../index.css';
|
|
4
5
|
|
|
5
6
|
interface QRCodePageProps {
|
|
@@ -11,7 +12,7 @@ interface QRCodePageProps {
|
|
|
11
12
|
serverKey?: string;
|
|
12
13
|
}
|
|
13
14
|
|
|
14
|
-
function QRCodePage({ onClose,
|
|
15
|
+
function QRCodePage({ onClose, mobileBaseUrl = 'https://kyc-sdk-stage.astraprotocol.com', sessionId, apiBaseUrl, serverKey }: QRCodePageProps = {}) {
|
|
15
16
|
const [qrUrl, setQrUrl] = useState<string>('');
|
|
16
17
|
const [copied, setCopied] = useState<boolean>(false);
|
|
17
18
|
|
|
@@ -55,8 +56,29 @@ function QRCodePage({ onClose, onNavigate, mobileBaseUrl = 'https://kyc-sdk-stag
|
|
|
55
56
|
}
|
|
56
57
|
};
|
|
57
58
|
|
|
58
|
-
const
|
|
59
|
-
|
|
59
|
+
const handleCheckResult = async () => {
|
|
60
|
+
if (!apiBaseUrl || !sessionId || !serverKey) {
|
|
61
|
+
alert('Missing configuration to check KYC result.');
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
try {
|
|
66
|
+
const svc = new KycApiService({ apiBaseUrl, sessionId, serverKey });
|
|
67
|
+
const payload = await svc.getResult();
|
|
68
|
+
|
|
69
|
+
const first = Array.isArray(payload?.data) && payload.data.length > 0 ? payload.data[0] : null;
|
|
70
|
+
|
|
71
|
+
if (first && first.kyc_status === 'success' && first.redirectUrl) {
|
|
72
|
+
window.location.href = first.redirectUrl;
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
alert('Please complete your KYC first.');
|
|
77
|
+
} catch (error: any) {
|
|
78
|
+
const msg = error?.message || 'Result fetch failed';
|
|
79
|
+
console.error('getResult:error', msg);
|
|
80
|
+
alert(`Result fetch failed: ${msg}`);
|
|
81
|
+
}
|
|
60
82
|
};
|
|
61
83
|
|
|
62
84
|
return (
|
|
@@ -124,9 +146,9 @@ function QRCodePage({ onClose, onNavigate, mobileBaseUrl = 'https://kyc-sdk-stag
|
|
|
124
146
|
|
|
125
147
|
<button
|
|
126
148
|
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"
|
|
127
|
-
onClick={
|
|
149
|
+
onClick={handleCheckResult}
|
|
128
150
|
>
|
|
129
|
-
I've completed on mobile -
|
|
151
|
+
I've completed on mobile - Move to next step
|
|
130
152
|
</button>
|
|
131
153
|
</div>
|
|
132
154
|
</div>
|
|
@@ -92,6 +92,40 @@ export class KycApiService {
|
|
|
92
92
|
}
|
|
93
93
|
}
|
|
94
94
|
|
|
95
|
+
/**
|
|
96
|
+
* Get session result (kyc result)
|
|
97
|
+
*/
|
|
98
|
+
async getResult(): Promise<any> {
|
|
99
|
+
const deviceType = this.config.deviceType || this.detectDeviceType();
|
|
100
|
+
|
|
101
|
+
try {
|
|
102
|
+
const response = await fetch(
|
|
103
|
+
`${this.config.apiBaseUrl}/api/v2/dashboard/merchant/onsite/session/${this.config.sessionId}/result`,
|
|
104
|
+
{
|
|
105
|
+
method: 'GET',
|
|
106
|
+
headers: {
|
|
107
|
+
'x-server-key': this.config.serverKey,
|
|
108
|
+
'device-type': deviceType,
|
|
109
|
+
'Content-Type': 'application/json',
|
|
110
|
+
},
|
|
111
|
+
credentials: 'include',
|
|
112
|
+
}
|
|
113
|
+
);
|
|
114
|
+
|
|
115
|
+
if (!response.ok) {
|
|
116
|
+
const errorData = await response.json().catch(() => ({}));
|
|
117
|
+
const message = errorData?.message || `Result fetch failed with status ${response.status}`;
|
|
118
|
+
throw new Error(message);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
const data = await response.json();
|
|
122
|
+
return data;
|
|
123
|
+
} catch (error: any) {
|
|
124
|
+
const message = error?.message || 'Result fetch failed';
|
|
125
|
+
throw new Error(`Result fetch failed: ${message}`);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
95
129
|
/**
|
|
96
130
|
* Upload face scan image
|
|
97
131
|
*/
|