astra-sdk-web 1.1.11 → 1.1.13
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/README.md +179 -179
- package/dist/astra-sdk.cjs.js +3 -3
- package/dist/astra-sdk.cjs.js.map +1 -1
- package/dist/astra-sdk.css +42 -0
- package/dist/astra-sdk.css.map +1 -1
- package/dist/astra-sdk.es.js +3 -3
- package/dist/astra-sdk.es.js.map +1 -1
- package/dist/components.cjs.js +3 -3
- package/dist/components.cjs.js.map +1 -1
- package/dist/components.css +42 -0
- package/dist/components.css.map +1 -1
- package/dist/components.es.js +3 -3
- package/dist/components.es.js.map +1 -1
- package/package.json +74 -74
- package/src/App.tsx +17 -17
- package/src/components/MobileKycPage.tsx +1122 -0
- package/src/components/kycModal.tsx +551 -0
- package/src/index.css +22 -18
- package/src/main.tsx +10 -10
- package/src/pages/DocumentUploadModal.tsx +2 -3
- package/src/pages/QRCodePage.tsx +1 -1
- package/dist/.htaccess +0 -9
package/README.md
CHANGED
|
@@ -1,179 +1,179 @@
|
|
|
1
|
-
# Astra SDK
|
|
2
|
-
|
|
3
|
-
Official Astra SDK for JavaScript/TypeScript
|
|
4
|
-
|
|
5
|
-
## Installation
|
|
6
|
-
|
|
7
|
-
```bash
|
|
8
|
-
npm install astra-sdk
|
|
9
|
-
# or
|
|
10
|
-
yarn add astra-sdk
|
|
11
|
-
# or
|
|
12
|
-
pnpm add astra-sdk
|
|
13
|
-
```
|
|
14
|
-
|
|
15
|
-
## Usage
|
|
16
|
-
|
|
17
|
-
### Basic Setup
|
|
18
|
-
|
|
19
|
-
```typescript
|
|
20
|
-
import { AstraSDK } from 'astra-sdk';
|
|
21
|
-
|
|
22
|
-
const sdk = new AstraSDK({
|
|
23
|
-
apiKey: 'your-api-key-here',
|
|
24
|
-
baseURL: 'https://api.astra.com', // optional
|
|
25
|
-
timeout: 30000, // optional, default: 30000
|
|
26
|
-
retries: 3, // optional, default: 3
|
|
27
|
-
retryDelay: 1000, // optional, default: 1000
|
|
28
|
-
});
|
|
29
|
-
```
|
|
30
|
-
|
|
31
|
-
### Making Requests
|
|
32
|
-
|
|
33
|
-
```typescript
|
|
34
|
-
// GET request
|
|
35
|
-
const response = await sdk.get('/users');
|
|
36
|
-
console.log(response.data);
|
|
37
|
-
|
|
38
|
-
// POST request
|
|
39
|
-
const newUser = await sdk.post('/users', {
|
|
40
|
-
name: 'John Doe',
|
|
41
|
-
email: 'john@example.com',
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
// PUT request
|
|
45
|
-
const updated = await sdk.put('/users/123', {
|
|
46
|
-
name: 'Jane Doe',
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
// PATCH request
|
|
50
|
-
const patched = await sdk.patch('/users/123', {
|
|
51
|
-
email: 'jane@example.com',
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
// DELETE request
|
|
55
|
-
await sdk.delete('/users/123');
|
|
56
|
-
|
|
57
|
-
// Custom request
|
|
58
|
-
const custom = await sdk.request('/custom-endpoint', {
|
|
59
|
-
method: 'POST',
|
|
60
|
-
headers: {
|
|
61
|
-
'Custom-Header': 'value',
|
|
62
|
-
},
|
|
63
|
-
body: { data: 'value' },
|
|
64
|
-
params: { query: 'param' },
|
|
65
|
-
});
|
|
66
|
-
```
|
|
67
|
-
|
|
68
|
-
### Error Handling
|
|
69
|
-
|
|
70
|
-
```typescript
|
|
71
|
-
import { AstraSDK, AstraSDKError } from 'astra-sdk';
|
|
72
|
-
|
|
73
|
-
try {
|
|
74
|
-
const response = await sdk.get('/users');
|
|
75
|
-
} catch (error) {
|
|
76
|
-
if (error instanceof AstraSDKError) {
|
|
77
|
-
console.error('SDK Error:', error.message);
|
|
78
|
-
console.error('Status:', error.status);
|
|
79
|
-
console.error('Code:', error.code);
|
|
80
|
-
console.error('Details:', error.details);
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
```
|
|
84
|
-
|
|
85
|
-
### Advanced Usage
|
|
86
|
-
|
|
87
|
-
```typescript
|
|
88
|
-
// Access the underlying API client
|
|
89
|
-
const client = sdk.getClient();
|
|
90
|
-
|
|
91
|
-
// Update configuration
|
|
92
|
-
sdk.updateConfig({
|
|
93
|
-
timeout: 60000,
|
|
94
|
-
headers: {
|
|
95
|
-
'X-Custom-Header': 'value',
|
|
96
|
-
},
|
|
97
|
-
});
|
|
98
|
-
```
|
|
99
|
-
|
|
100
|
-
## API Reference
|
|
101
|
-
|
|
102
|
-
### AstraSDK
|
|
103
|
-
|
|
104
|
-
Main SDK class for interacting with the Astra API.
|
|
105
|
-
|
|
106
|
-
#### Constructor
|
|
107
|
-
|
|
108
|
-
```typescript
|
|
109
|
-
new AstraSDK(config: AstraSDKConfig)
|
|
110
|
-
```
|
|
111
|
-
|
|
112
|
-
#### Methods
|
|
113
|
-
|
|
114
|
-
- `get<T>(endpoint: string, options?: RequestOptions): Promise<ApiResponse<T>>`
|
|
115
|
-
- `post<T>(endpoint: string, body?: unknown, options?: RequestOptions): Promise<ApiResponse<T>>`
|
|
116
|
-
- `put<T>(endpoint: string, body?: unknown, options?: RequestOptions): Promise<ApiResponse<T>>`
|
|
117
|
-
- `patch<T>(endpoint: string, body?: unknown, options?: RequestOptions): Promise<ApiResponse<T>>`
|
|
118
|
-
- `delete<T>(endpoint: string, options?: RequestOptions): Promise<ApiResponse<T>>`
|
|
119
|
-
- `request<T>(endpoint: string, options?: RequestOptions): Promise<ApiResponse<T>>`
|
|
120
|
-
- `updateConfig(config: Partial<AstraSDKConfig>): void`
|
|
121
|
-
- `getClient(): ApiClient`
|
|
122
|
-
|
|
123
|
-
## Types
|
|
124
|
-
|
|
125
|
-
### AstraSDKConfig
|
|
126
|
-
|
|
127
|
-
```typescript
|
|
128
|
-
interface AstraSDKConfig {
|
|
129
|
-
apiKey: string;
|
|
130
|
-
baseURL?: string;
|
|
131
|
-
timeout?: number;
|
|
132
|
-
headers?: Record<string, string>;
|
|
133
|
-
retries?: number;
|
|
134
|
-
retryDelay?: number;
|
|
135
|
-
}
|
|
136
|
-
```
|
|
137
|
-
|
|
138
|
-
### ApiResponse
|
|
139
|
-
|
|
140
|
-
```typescript
|
|
141
|
-
interface ApiResponse<T> {
|
|
142
|
-
data: T;
|
|
143
|
-
status: number;
|
|
144
|
-
statusText: string;
|
|
145
|
-
headers: Record<string, string>;
|
|
146
|
-
}
|
|
147
|
-
```
|
|
148
|
-
|
|
149
|
-
### RequestOptions
|
|
150
|
-
|
|
151
|
-
```typescript
|
|
152
|
-
interface RequestOptions {
|
|
153
|
-
method?: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH';
|
|
154
|
-
headers?: Record<string, string>;
|
|
155
|
-
body?: unknown;
|
|
156
|
-
params?: Record<string, string | number | boolean>;
|
|
157
|
-
timeout?: number;
|
|
158
|
-
}
|
|
159
|
-
```
|
|
160
|
-
|
|
161
|
-
## Development
|
|
162
|
-
|
|
163
|
-
```bash
|
|
164
|
-
# Install dependencies
|
|
165
|
-
npm install
|
|
166
|
-
|
|
167
|
-
# Build the SDK
|
|
168
|
-
npm run build
|
|
169
|
-
|
|
170
|
-
# Run type checking
|
|
171
|
-
npm run type-check
|
|
172
|
-
|
|
173
|
-
# Lint
|
|
174
|
-
npm run lint
|
|
175
|
-
```
|
|
176
|
-
|
|
177
|
-
## License
|
|
178
|
-
|
|
179
|
-
MIT
|
|
1
|
+
# Astra SDK
|
|
2
|
+
|
|
3
|
+
Official Astra SDK for JavaScript/TypeScript
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install astra-sdk
|
|
9
|
+
# or
|
|
10
|
+
yarn add astra-sdk
|
|
11
|
+
# or
|
|
12
|
+
pnpm add astra-sdk
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Usage
|
|
16
|
+
|
|
17
|
+
### Basic Setup
|
|
18
|
+
|
|
19
|
+
```typescript
|
|
20
|
+
import { AstraSDK } from 'astra-sdk';
|
|
21
|
+
|
|
22
|
+
const sdk = new AstraSDK({
|
|
23
|
+
apiKey: 'your-api-key-here',
|
|
24
|
+
baseURL: 'https://api.astra.com', // optional
|
|
25
|
+
timeout: 30000, // optional, default: 30000
|
|
26
|
+
retries: 3, // optional, default: 3
|
|
27
|
+
retryDelay: 1000, // optional, default: 1000
|
|
28
|
+
});
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
### Making Requests
|
|
32
|
+
|
|
33
|
+
```typescript
|
|
34
|
+
// GET request
|
|
35
|
+
const response = await sdk.get('/users');
|
|
36
|
+
console.log(response.data);
|
|
37
|
+
|
|
38
|
+
// POST request
|
|
39
|
+
const newUser = await sdk.post('/users', {
|
|
40
|
+
name: 'John Doe',
|
|
41
|
+
email: 'john@example.com',
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
// PUT request
|
|
45
|
+
const updated = await sdk.put('/users/123', {
|
|
46
|
+
name: 'Jane Doe',
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
// PATCH request
|
|
50
|
+
const patched = await sdk.patch('/users/123', {
|
|
51
|
+
email: 'jane@example.com',
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
// DELETE request
|
|
55
|
+
await sdk.delete('/users/123');
|
|
56
|
+
|
|
57
|
+
// Custom request
|
|
58
|
+
const custom = await sdk.request('/custom-endpoint', {
|
|
59
|
+
method: 'POST',
|
|
60
|
+
headers: {
|
|
61
|
+
'Custom-Header': 'value',
|
|
62
|
+
},
|
|
63
|
+
body: { data: 'value' },
|
|
64
|
+
params: { query: 'param' },
|
|
65
|
+
});
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
### Error Handling
|
|
69
|
+
|
|
70
|
+
```typescript
|
|
71
|
+
import { AstraSDK, AstraSDKError } from 'astra-sdk';
|
|
72
|
+
|
|
73
|
+
try {
|
|
74
|
+
const response = await sdk.get('/users');
|
|
75
|
+
} catch (error) {
|
|
76
|
+
if (error instanceof AstraSDKError) {
|
|
77
|
+
console.error('SDK Error:', error.message);
|
|
78
|
+
console.error('Status:', error.status);
|
|
79
|
+
console.error('Code:', error.code);
|
|
80
|
+
console.error('Details:', error.details);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
### Advanced Usage
|
|
86
|
+
|
|
87
|
+
```typescript
|
|
88
|
+
// Access the underlying API client
|
|
89
|
+
const client = sdk.getClient();
|
|
90
|
+
|
|
91
|
+
// Update configuration
|
|
92
|
+
sdk.updateConfig({
|
|
93
|
+
timeout: 60000,
|
|
94
|
+
headers: {
|
|
95
|
+
'X-Custom-Header': 'value',
|
|
96
|
+
},
|
|
97
|
+
});
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
## API Reference
|
|
101
|
+
|
|
102
|
+
### AstraSDK
|
|
103
|
+
|
|
104
|
+
Main SDK class for interacting with the Astra API.
|
|
105
|
+
|
|
106
|
+
#### Constructor
|
|
107
|
+
|
|
108
|
+
```typescript
|
|
109
|
+
new AstraSDK(config: AstraSDKConfig)
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
#### Methods
|
|
113
|
+
|
|
114
|
+
- `get<T>(endpoint: string, options?: RequestOptions): Promise<ApiResponse<T>>`
|
|
115
|
+
- `post<T>(endpoint: string, body?: unknown, options?: RequestOptions): Promise<ApiResponse<T>>`
|
|
116
|
+
- `put<T>(endpoint: string, body?: unknown, options?: RequestOptions): Promise<ApiResponse<T>>`
|
|
117
|
+
- `patch<T>(endpoint: string, body?: unknown, options?: RequestOptions): Promise<ApiResponse<T>>`
|
|
118
|
+
- `delete<T>(endpoint: string, options?: RequestOptions): Promise<ApiResponse<T>>`
|
|
119
|
+
- `request<T>(endpoint: string, options?: RequestOptions): Promise<ApiResponse<T>>`
|
|
120
|
+
- `updateConfig(config: Partial<AstraSDKConfig>): void`
|
|
121
|
+
- `getClient(): ApiClient`
|
|
122
|
+
|
|
123
|
+
## Types
|
|
124
|
+
|
|
125
|
+
### AstraSDKConfig
|
|
126
|
+
|
|
127
|
+
```typescript
|
|
128
|
+
interface AstraSDKConfig {
|
|
129
|
+
apiKey: string;
|
|
130
|
+
baseURL?: string;
|
|
131
|
+
timeout?: number;
|
|
132
|
+
headers?: Record<string, string>;
|
|
133
|
+
retries?: number;
|
|
134
|
+
retryDelay?: number;
|
|
135
|
+
}
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
### ApiResponse
|
|
139
|
+
|
|
140
|
+
```typescript
|
|
141
|
+
interface ApiResponse<T> {
|
|
142
|
+
data: T;
|
|
143
|
+
status: number;
|
|
144
|
+
statusText: string;
|
|
145
|
+
headers: Record<string, string>;
|
|
146
|
+
}
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
### RequestOptions
|
|
150
|
+
|
|
151
|
+
```typescript
|
|
152
|
+
interface RequestOptions {
|
|
153
|
+
method?: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH';
|
|
154
|
+
headers?: Record<string, string>;
|
|
155
|
+
body?: unknown;
|
|
156
|
+
params?: Record<string, string | number | boolean>;
|
|
157
|
+
timeout?: number;
|
|
158
|
+
}
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
## Development
|
|
162
|
+
|
|
163
|
+
```bash
|
|
164
|
+
# Install dependencies
|
|
165
|
+
npm install
|
|
166
|
+
|
|
167
|
+
# Build the SDK
|
|
168
|
+
npm run build
|
|
169
|
+
|
|
170
|
+
# Run type checking
|
|
171
|
+
npm run type-check
|
|
172
|
+
|
|
173
|
+
# Lint
|
|
174
|
+
npm run lint
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
## License
|
|
178
|
+
|
|
179
|
+
MIT
|
package/dist/astra-sdk.cjs.js
CHANGED
|
@@ -670,8 +670,8 @@ function DocumentUploadModal({ onComplete }) {
|
|
|
670
670
|
await apiService.uploadDocument(blob, docType);
|
|
671
671
|
try {
|
|
672
672
|
const statusResponse = await apiService.getSessionStatus();
|
|
673
|
-
const { completed_steps,
|
|
674
|
-
if (
|
|
673
|
+
const { completed_steps, next_step } = statusResponse.data;
|
|
674
|
+
if (next_step === "completed" || completed_steps.includes(COMPLETED_STEPS.COMPLETED)) {
|
|
675
675
|
setKycCompleted(true);
|
|
676
676
|
}
|
|
677
677
|
} catch (error) {
|
|
@@ -1910,7 +1910,7 @@ function MobileRoute({ onClose, onNavigate } = {}) {
|
|
|
1910
1910
|
] }) });
|
|
1911
1911
|
}
|
|
1912
1912
|
var MobileRoute_default = MobileRoute;
|
|
1913
|
-
function QRCodePage({ onClose, onNavigate, mobileBaseUrl = "https://
|
|
1913
|
+
function QRCodePage({ onClose, onNavigate, mobileBaseUrl = "https://kyc-sdk.astraprotocol.com", sessionId, apiBaseUrl, serverKey } = {}) {
|
|
1914
1914
|
const [qrUrl, setQrUrl] = React.useState("");
|
|
1915
1915
|
const [copied, setCopied] = React.useState(false);
|
|
1916
1916
|
React.useEffect(() => {
|