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/index.d.ts CHANGED
@@ -113,6 +113,10 @@ declare class KycApiService {
113
113
  * Get session status
114
114
  */
115
115
  getSessionStatus(): Promise<SessionStatusResponse>;
116
+ /**
117
+ * Get session result (kyc result)
118
+ */
119
+ getResult(): Promise<any>;
116
120
  /**
117
121
  * Upload face scan image
118
122
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "astra-sdk-web",
3
- "version": "1.1.16",
3
+ "version": "1.1.18",
4
4
  "description": "Official Astra SDK for JavaScript/TypeScript",
5
5
  "type": "module",
6
6
  "main": "./dist/astra-sdk.cjs.js",
package/src/index.css CHANGED
@@ -9,6 +9,12 @@
9
9
  scrollbar-color: #474747 transparent;
10
10
  }
11
11
 
12
+
13
+
14
+
15
+
16
+
17
+
12
18
  .custom__scrollbar::-webkit-scrollbar {
13
19
  width: 6px;
14
20
  }
@@ -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, onNavigate, mobileBaseUrl = 'https://kyc-sdk-stage.astraprotocol.com', sessionId, apiBaseUrl, serverKey }: QRCodePageProps = {}) {
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 handleRefresh = () => {
59
- window.location.reload();
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={handleRefresh}
149
+ onClick={handleCheckResult}
128
150
  >
129
- I've completed on mobile - Refresh
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
  */