astra-sdk-web 1.1.23 → 1.1.24

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "astra-sdk-web",
3
- "version": "1.1.23",
3
+ "version": "1.1.24",
4
4
  "description": "Official Astra SDK for JavaScript/TypeScript",
5
5
  "type": "module",
6
6
  "main": "./dist/astra-sdk.cjs.js",
@@ -66,6 +66,7 @@
66
66
  "@mediapipe/face_mesh": "^0.4.1633559619",
67
67
  "qrcode.react": "^4.2.0",
68
68
  "react-router-dom": "^7.11.0"
69
+ ,"react-toastify": "^9.2.1"
69
70
  },
70
71
  "peerDependencies": {
71
72
  "react": "^18.0.0 || ^19.0.0",
@@ -1,6 +1,10 @@
1
1
  import { useState, useEffect } from 'react';
2
2
  import { QRCodeSVG } from 'qrcode.react';
3
3
  import { KycApiService } from '../services/kycApiService';
4
+ // @ts-ignore - optional dependency, may not be installed in some consumers
5
+ import { toast, ToastContainer } from 'react-toastify';
6
+ // @ts-ignore - import styles only when package is present
7
+ import 'react-toastify/dist/ReactToastify.css';
4
8
  import '../index.css';
5
9
 
6
10
  interface QRCodePageProps {
@@ -58,7 +62,7 @@ function QRCodePage({ onClose, mobileBaseUrl = 'https://kyc-sdk-stage.astraproto
58
62
 
59
63
  const handleCheckResult = async () => {
60
64
  if (!apiBaseUrl || !sessionId || !serverKey) {
61
- alert('Missing configuration to check KYC result.');
65
+ toast.error('Missing configuration to check KYC result.');
62
66
  return;
63
67
  }
64
68
 
@@ -66,23 +70,32 @@ function QRCodePage({ onClose, mobileBaseUrl = 'https://kyc-sdk-stage.astraproto
66
70
  const svc = new KycApiService({ apiBaseUrl, sessionId, serverKey });
67
71
  const payload = await svc.getResult();
68
72
 
69
- const first = Array.isArray(payload?.data) && payload.data.length > 0 ? payload.data[0] : null;
70
-
71
- if (first && first.kyc_status === 'verified' && first.redirect_url) {
72
- window.location.href = first.redirect_url;
73
- return;
73
+ // support both array and object shapes
74
+ const first = Array.isArray(payload?.data)
75
+ ? payload.data.length > 0
76
+ ? payload.data[0]
77
+ : null
78
+ : payload?.data || null;
79
+
80
+ if (first && (first.kyc_status === 'verified' || first.kyc_status === 'success')) {
81
+ const redirect = first.redirect_url || first.redirectUrl || null;
82
+ if (redirect) {
83
+ window.location.href = redirect;
84
+ return;
85
+ }
74
86
  }
75
87
 
76
- alert('Please complete your KYC first.');
88
+ toast.warn('Please complete your KYC first.');
77
89
  } catch (error: any) {
78
90
  const msg = error?.message || 'Result fetch failed';
79
91
  console.error('getResult:error', msg);
80
- alert(`Result fetch failed: ${msg}`);
92
+ toast.error(`Result fetch failed: ${msg}`);
81
93
  }
82
94
  };
83
95
 
84
96
  return (
85
97
  <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]">
98
+ <ToastContainer position="top-right" />
86
99
  {/* Background pattern overlay */}
87
100
  <div className="absolute inset-0 opacity-10" style={{
88
101
  backgroundImage: `radial-gradient(circle at 2px 2px, rgba(255,255,255,0.15) 1px, transparent 0)`,
@@ -0,0 +1,3 @@
1
+ declare module 'react-toastify';
2
+
3
+