@diviswap/sdk 1.7.12 → 1.7.15
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/cli/index.js +8 -2
- package/dist/cli/templates/nextjs-app/actions.ts.hbs +31 -31
- package/dist/cli/templates/nextjs-app/api-hooks.ts.hbs +10 -10
- package/dist/cli/templates/nextjs-app/api-route.ts.hbs +67 -67
- package/dist/cli/templates/nextjs-app/auth-context.tsx.hbs +1 -1
- package/dist/cli/templates/nextjs-app/client.ts.hbs +10 -10
- package/dist/cli/templates/nextjs-app/dashboard-hooks.ts.hbs +7 -7
- package/dist/cli/templates/nextjs-app/example-page.tsx.hbs +9 -9
- package/dist/cli/templates/nextjs-app/hooks.ts.hbs +7 -7
- package/dist/cli/templates/nextjs-app/kyc-hooks.ts.hbs +3 -3
- package/dist/cli/templates/nextjs-app/kyc-wizard.css.hbs +16 -16
- package/dist/cli/templates/nextjs-app/kyc-wizard.tsx.hbs +25 -25
- package/dist/cli/templates/nextjs-app/layout-wrapper.tsx.hbs +4 -4
- package/dist/cli/templates/nextjs-app/layout.tsx.hbs +4 -4
- package/dist/cli/templates/nextjs-app/middleware.ts.hbs +15 -15
- package/dist/cli/templates/nextjs-app/provider-wrapper.tsx.hbs +4 -4
- package/dist/cli/templates/nextjs-app/provider.tsx.hbs +21 -21
- package/dist/cli/templates/nextjs-app/setup-provider.tsx.hbs +4 -4
- package/dist/cli/templates/react/api-client-wrapper.ts.hbs +14 -14
- package/dist/cli/templates/react/example.tsx.hbs +6 -6
- package/dist/cli/templates/react/tanstack-hooks.ts.hbs +14 -14
- package/dist/cli/templates/webhooks/nextjs.hbs +3 -3
- package/package.json +2 -1
- package/src/cli/templates/index.ts +13 -2
- package/src/cli/templates/nextjs-app/actions.ts.hbs +31 -31
- package/src/cli/templates/nextjs-app/api-hooks.ts.hbs +10 -10
- package/src/cli/templates/nextjs-app/api-route.ts.hbs +67 -67
- package/src/cli/templates/nextjs-app/auth-context.tsx.hbs +1 -1
- package/src/cli/templates/nextjs-app/client.ts.hbs +10 -10
- package/src/cli/templates/nextjs-app/dashboard-hooks.ts.hbs +7 -7
- package/src/cli/templates/nextjs-app/example-page.tsx.hbs +9 -9
- package/src/cli/templates/nextjs-app/hooks.ts.hbs +7 -7
- package/src/cli/templates/nextjs-app/kyc-hooks.ts.hbs +3 -3
- package/src/cli/templates/nextjs-app/kyc-wizard.css.hbs +16 -16
- package/src/cli/templates/nextjs-app/kyc-wizard.tsx.hbs +25 -25
- package/src/cli/templates/nextjs-app/layout-wrapper.tsx.hbs +4 -4
- package/src/cli/templates/nextjs-app/layout.tsx.hbs +4 -4
- package/src/cli/templates/nextjs-app/middleware.ts.hbs +15 -15
- package/src/cli/templates/nextjs-app/provider-wrapper.tsx.hbs +4 -4
- package/src/cli/templates/nextjs-app/provider.tsx.hbs +21 -21
- package/src/cli/templates/nextjs-app/setup-provider.tsx.hbs +4 -4
- package/src/cli/templates/react/api-client-wrapper.ts.hbs +14 -14
- package/src/cli/templates/react/example.tsx.hbs +6 -6
- package/src/cli/templates/react/tanstack-hooks.ts.hbs +14 -14
- package/src/cli/templates/webhooks/nextjs.hbs +3 -3
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
// This file is auto-generated by
|
|
2
|
-
// It provides a client for communicating with the
|
|
1
|
+
// This file is auto-generated by LiberEx SDK CLI
|
|
2
|
+
// It provides a client for communicating with the LiberEx API routes
|
|
3
3
|
|
|
4
|
-
export class
|
|
5
|
-
constructor(private baseUrl: string = '/api/
|
|
4
|
+
export class LiberExClient {
|
|
5
|
+
constructor(private baseUrl: string = '/api/liberex') {}
|
|
6
6
|
|
|
7
7
|
private async request<T = any>(
|
|
8
8
|
endpoint: string,
|
|
9
9
|
options: RequestInit = {}
|
|
10
10
|
): Promise<T> {
|
|
11
|
-
const response = await fetch(
|
|
11
|
+
const response = await fetch(this.baseUrl + endpoint, {
|
|
12
12
|
...options,
|
|
13
13
|
headers: {
|
|
14
14
|
'Content-Type': 'application/json',
|
|
@@ -41,7 +41,7 @@ export class DiviswapClient {
|
|
|
41
41
|
|
|
42
42
|
async getCustomerStatus(customerId: string, customerEmail: string) {
|
|
43
43
|
try {
|
|
44
|
-
return await this.request(`?resource=customerStatus&customerId
|
|
44
|
+
return await this.request(`?resource=customerStatus&customerId=${encodeURIComponent(customerId)}&customerEmail=${encodeURIComponent(customerEmail)}`);
|
|
45
45
|
} catch {
|
|
46
46
|
return null;
|
|
47
47
|
}
|
|
@@ -72,16 +72,16 @@ export class DiviswapClient {
|
|
|
72
72
|
...(params.type && { type: params.type }),
|
|
73
73
|
}),
|
|
74
74
|
});
|
|
75
|
-
return this.request(
|
|
75
|
+
return this.request(`?${searchParams}`);
|
|
76
76
|
}
|
|
77
77
|
|
|
78
78
|
async getTransaction(id: string) {
|
|
79
|
-
return this.request(`?resource=transaction&id
|
|
79
|
+
return this.request(`?resource=transaction&id=${id}`);
|
|
80
80
|
}
|
|
81
81
|
|
|
82
82
|
// Payee methods
|
|
83
83
|
async getPayees(customerId: string, customerEmail: string) {
|
|
84
|
-
return this.request(`?resource=payees&customerId
|
|
84
|
+
return this.request(`?resource=payees&customerId=${encodeURIComponent(customerId)}&customerEmail=${encodeURIComponent(customerEmail)}`);
|
|
85
85
|
}
|
|
86
86
|
|
|
87
87
|
async createPayee(data: any) {
|
|
@@ -92,7 +92,7 @@ export class DiviswapClient {
|
|
|
92
92
|
}
|
|
93
93
|
|
|
94
94
|
async deletePayee(id: string, customerId: string, customerEmail: string) {
|
|
95
|
-
return this.request(`?resource=payee&id
|
|
95
|
+
return this.request(`?resource=payee&id=${id}&customerId=${encodeURIComponent(customerId)}&customerEmail=${encodeURIComponent(customerEmail)}`, {
|
|
96
96
|
method: 'DELETE',
|
|
97
97
|
});
|
|
98
98
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
3
|
import { useEffect, useState } from 'react';
|
|
4
|
-
import { use{{prefix}}Auth } from '~/context/
|
|
4
|
+
import { use{{prefix}}Auth } from '~/context/liberex-auth-context';
|
|
5
5
|
|
|
6
6
|
export function use{{prefix}}Dashboard() {
|
|
7
7
|
const { customerId, customerEmail, isAuthenticated } = use{{prefix}}Auth();
|
|
@@ -15,14 +15,14 @@ export function use{{prefix}}Dashboard() {
|
|
|
15
15
|
customerEmail,
|
|
16
16
|
...params
|
|
17
17
|
});
|
|
18
|
-
const response = await fetch(`/api/
|
|
18
|
+
const response = await fetch(`/api/liberex?${queryParams}`);
|
|
19
19
|
if (!response.ok) throw new Error('Failed to fetch transactions');
|
|
20
20
|
return response.json();
|
|
21
21
|
};
|
|
22
22
|
|
|
23
23
|
const getPayees = async () => {
|
|
24
24
|
if (!isAuthenticated || !customerId) return [];
|
|
25
|
-
const response = await fetch(`/api/
|
|
25
|
+
const response = await fetch(`/api/liberex?resource=payees&customerId=${customerId}&customerEmail=${customerEmail}`);
|
|
26
26
|
if (!response.ok) throw new Error('Failed to fetch payees');
|
|
27
27
|
return response.json();
|
|
28
28
|
};
|
|
@@ -36,14 +36,14 @@ export function use{{prefix}}Dashboard() {
|
|
|
36
36
|
...(params?.chain_id && { chain_id: params.chain_id.toString() }),
|
|
37
37
|
...(params?.is_default !== undefined && { is_default: params.is_default.toString() })
|
|
38
38
|
});
|
|
39
|
-
const response = await fetch(`/api/
|
|
39
|
+
const response = await fetch(`/api/liberex?${queryParams}`);
|
|
40
40
|
if (!response.ok) throw new Error('Failed to fetch addresses');
|
|
41
41
|
return response.json();
|
|
42
42
|
};
|
|
43
43
|
|
|
44
44
|
const createAddress = async (data: { chain_id: number; address: string; is_default?: boolean }) => {
|
|
45
45
|
if (!isAuthenticated || !customerId) throw new Error('Not authenticated');
|
|
46
|
-
const response = await fetch('/api/
|
|
46
|
+
const response = await fetch('/api/liberex', {
|
|
47
47
|
method: 'POST',
|
|
48
48
|
headers: { 'Content-Type': 'application/json' },
|
|
49
49
|
body: JSON.stringify({
|
|
@@ -59,7 +59,7 @@ export function use{{prefix}}Dashboard() {
|
|
|
59
59
|
|
|
60
60
|
const setDefaultAddress = async (data: { chain_id: number; address: string }) => {
|
|
61
61
|
if (!isAuthenticated || !customerId) throw new Error('Not authenticated');
|
|
62
|
-
const response = await fetch('/api/
|
|
62
|
+
const response = await fetch('/api/liberex', {
|
|
63
63
|
method: 'POST',
|
|
64
64
|
headers: { 'Content-Type': 'application/json' },
|
|
65
65
|
body: JSON.stringify({
|
|
@@ -75,7 +75,7 @@ export function use{{prefix}}Dashboard() {
|
|
|
75
75
|
|
|
76
76
|
const deleteAddress = async (data: { chain_id: number; address: string }) => {
|
|
77
77
|
if (!isAuthenticated || !customerId) throw new Error('Not authenticated');
|
|
78
|
-
const response = await fetch('/api/
|
|
78
|
+
const response = await fetch('/api/liberex', {
|
|
79
79
|
method: 'POST',
|
|
80
80
|
headers: { 'Content-Type': 'application/json' },
|
|
81
81
|
body: JSON.stringify({
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
3
|
import { useState } from 'react';
|
|
4
|
-
import { LiberexKYC, LiberexKYCModal } from '@/components/
|
|
5
|
-
import '@/components/
|
|
4
|
+
import { LiberexKYC, LiberexKYCModal } from '@/components/liberex-kyc-wizard';
|
|
5
|
+
import '@/components/liberex-kyc-wizard.css';
|
|
6
6
|
|
|
7
|
-
export default function
|
|
7
|
+
export default function LiberExDemo() {
|
|
8
8
|
// Demo state
|
|
9
9
|
const [currentDemo, setCurrentDemo] = useState<'kyc-inline' | 'kyc-modal' | 'features'>('kyc-inline');
|
|
10
10
|
const [showKYCModal, setShowKYCModal] = useState(false);
|
|
@@ -20,7 +20,7 @@ export default function DiviswapDemo() {
|
|
|
20
20
|
};
|
|
21
21
|
|
|
22
22
|
const handleKYCError = (error: Error) => {
|
|
23
|
-
alert(`KYC Error:
|
|
23
|
+
alert(`KYC Error: ${error.message}`);
|
|
24
24
|
};
|
|
25
25
|
|
|
26
26
|
return (
|
|
@@ -29,7 +29,7 @@ export default function DiviswapDemo() {
|
|
|
29
29
|
<div className="bg-white shadow">
|
|
30
30
|
<div className="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
|
|
31
31
|
<div className="flex justify-between items-center py-6">
|
|
32
|
-
<h1 className="text-2xl font-bold text-gray-900">
|
|
32
|
+
<h1 className="text-2xl font-bold text-gray-900">LiberEx KYC Wizard Demo</h1>
|
|
33
33
|
<div className="text-sm text-gray-600">
|
|
34
34
|
Ready-to-use KYC component
|
|
35
35
|
</div>
|
|
@@ -60,7 +60,7 @@ export default function DiviswapDemo() {
|
|
|
60
60
|
<div className="flex space-x-1 mb-8">
|
|
61
61
|
<button
|
|
62
62
|
onClick={() => setCurrentDemo('kyc-inline')}
|
|
63
|
-
className={`flex-1 py-3 px-6 text-sm font-medium rounded-lg transition-colors
|
|
63
|
+
className={`flex-1 py-3 px-6 text-sm font-medium rounded-lg transition-colors ${
|
|
64
64
|
currentDemo === 'kyc-inline'
|
|
65
65
|
? 'bg-indigo-100 text-indigo-700 border-2 border-indigo-200'
|
|
66
66
|
: 'text-gray-500 hover:text-gray-700 border-2 border-transparent'
|
|
@@ -70,7 +70,7 @@ export default function DiviswapDemo() {
|
|
|
70
70
|
</button>
|
|
71
71
|
<button
|
|
72
72
|
onClick={() => setCurrentDemo('kyc-modal')}
|
|
73
|
-
className={`flex-1 py-3 px-6 text-sm font-medium rounded-lg transition-colors
|
|
73
|
+
className={`flex-1 py-3 px-6 text-sm font-medium rounded-lg transition-colors ${
|
|
74
74
|
currentDemo === 'kyc-modal'
|
|
75
75
|
? 'bg-indigo-100 text-indigo-700 border-2 border-indigo-200'
|
|
76
76
|
: 'text-gray-500 hover:text-gray-700 border-2 border-transparent'
|
|
@@ -80,7 +80,7 @@ export default function DiviswapDemo() {
|
|
|
80
80
|
</button>
|
|
81
81
|
<button
|
|
82
82
|
onClick={() => setCurrentDemo('features')}
|
|
83
|
-
className={`flex-1 py-3 px-6 text-sm font-medium rounded-lg transition-colors
|
|
83
|
+
className={`flex-1 py-3 px-6 text-sm font-medium rounded-lg transition-colors ${
|
|
84
84
|
currentDemo === 'features'
|
|
85
85
|
? 'bg-indigo-100 text-indigo-700 border-2 border-indigo-200'
|
|
86
86
|
: 'text-gray-500 hover:text-gray-700 border-2 border-transparent'
|
|
@@ -132,7 +132,7 @@ export default function DiviswapDemo() {
|
|
|
132
132
|
<h3 className="text-lg font-medium text-gray-900 mb-4">Integration Code</h3>
|
|
133
133
|
<div className="bg-gray-50 rounded-md p-4 text-left">
|
|
134
134
|
<pre className="text-sm text-gray-800 overflow-x-auto">
|
|
135
|
-
{`import { LiberexKYCModal } from '@/components/
|
|
135
|
+
{`import { LiberexKYCModal } from '@/components/liberex-kyc-wizard';
|
|
136
136
|
|
|
137
137
|
function MyComponent() {
|
|
138
138
|
const [showKYC, setShowKYC] = useState(false);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useState, useEffect, useCallback } from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { useLiberEx } from '{{providerImportPath}}';
|
|
3
3
|
import type { Transaction, Payee, TransactionStatus } from '{{typesImportPath}}';
|
|
4
4
|
|
|
5
5
|
// IMPORTANT: These hooks use direct SDK calls which may not work properly
|
|
@@ -7,11 +7,11 @@ import type { Transaction, Payee, TransactionStatus } from '{{typesImportPath}}'
|
|
|
7
7
|
// pattern demonstrated in api-hooks.ts instead.
|
|
8
8
|
|
|
9
9
|
// Re-export the main hook
|
|
10
|
-
export {
|
|
10
|
+
export { useLiberEx };
|
|
11
11
|
|
|
12
12
|
// Convenience hook for authentication
|
|
13
13
|
export function useAuth() {
|
|
14
|
-
const { user, login, logout, register, loading, error } =
|
|
14
|
+
const { user, login, logout, register, loading, error } = useLiberEx();
|
|
15
15
|
|
|
16
16
|
return {
|
|
17
17
|
user,
|
|
@@ -27,7 +27,7 @@ export function useAuth() {
|
|
|
27
27
|
|
|
28
28
|
// Hook for managing transactions
|
|
29
29
|
export function useTransactions() {
|
|
30
|
-
const { createTransaction, getTransactions, error } =
|
|
30
|
+
const { createTransaction, getTransactions, error } = useLiberEx();
|
|
31
31
|
const [transactions, setTransactions] = useState<Transaction[]>([]);
|
|
32
32
|
const [loading, setLoading] = useState(false);
|
|
33
33
|
|
|
@@ -76,7 +76,7 @@ export function useTransactions() {
|
|
|
76
76
|
|
|
77
77
|
// Hook for managing payees
|
|
78
78
|
export function usePayees() {
|
|
79
|
-
const { getPayees, createPayee, deletePayee, error } =
|
|
79
|
+
const { getPayees, createPayee, deletePayee, error } = useLiberEx();
|
|
80
80
|
const [payees, setPayees] = useState<Payee[]>([]);
|
|
81
81
|
const [loading, setLoading] = useState(false);
|
|
82
82
|
|
|
@@ -141,7 +141,7 @@ export function usePayees() {
|
|
|
141
141
|
{{#if (includes features "fees")}}
|
|
142
142
|
// Hook for fee calculations
|
|
143
143
|
export function useFeeCalculator() {
|
|
144
|
-
const { calculateFees } =
|
|
144
|
+
const { calculateFees } = useLiberEx();
|
|
145
145
|
const [fees, setFees] = useState<any>(null);
|
|
146
146
|
const [loading, setLoading] = useState(false);
|
|
147
147
|
const [error, setError] = useState<Error | null>(null);
|
|
@@ -184,7 +184,7 @@ export function useFeeCalculator() {
|
|
|
184
184
|
{{#if (includes features "realtime")}}
|
|
185
185
|
// Hook for real-time transaction updates
|
|
186
186
|
export function useTransactionUpdates(transactionId?: string) {
|
|
187
|
-
const { socket, subscribeToTransaction, unsubscribeFromTransaction } =
|
|
187
|
+
const { socket, subscribeToTransaction, unsubscribeFromTransaction } = useLiberEx();
|
|
188
188
|
const [updates, setUpdates] = useState<any[]>([]);
|
|
189
189
|
const [latestStatus, setLatestStatus] = useState<TransactionStatus | null>(null);
|
|
190
190
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
3
|
import { useState } from 'react';
|
|
4
|
-
import { use{{prefix}}Auth } from '~/context/
|
|
4
|
+
import { use{{prefix}}Auth } from '~/context/liberex-auth-context';
|
|
5
5
|
|
|
6
6
|
interface KYCFormData {
|
|
7
7
|
firstName: string;
|
|
@@ -29,7 +29,7 @@ export function use{{prefix}}KYC() {
|
|
|
29
29
|
|
|
30
30
|
try {
|
|
31
31
|
// Format date of birth
|
|
32
|
-
const dateOfBirth =
|
|
32
|
+
const dateOfBirth = formData.dobYear + '-' + formData.dobMonth.padStart(2, '0') + '-' + formData.dobDay.padStart(2, '0');
|
|
33
33
|
|
|
34
34
|
// Prepare KYC data
|
|
35
35
|
const kycData = {
|
|
@@ -53,7 +53,7 @@ export function use{{prefix}}KYC() {
|
|
|
53
53
|
};
|
|
54
54
|
|
|
55
55
|
// Call API to submit KYC
|
|
56
|
-
const response = await fetch('/api/
|
|
56
|
+
const response = await fetch('/api/liberex', {
|
|
57
57
|
method: 'POST',
|
|
58
58
|
headers: { 'Content-Type': 'application/json' },
|
|
59
59
|
body: JSON.stringify({
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
/*
|
|
2
|
-
.
|
|
1
|
+
/* LiberEx KYC Wizard Styles */
|
|
2
|
+
.liberex-kyc-container {
|
|
3
3
|
max-width: 600px;
|
|
4
4
|
margin: 0 auto;
|
|
5
5
|
padding: 2rem;
|
|
@@ -288,7 +288,7 @@
|
|
|
288
288
|
}
|
|
289
289
|
|
|
290
290
|
/* Modal */
|
|
291
|
-
.
|
|
291
|
+
.liberex-kyc-modal-overlay {
|
|
292
292
|
position: fixed;
|
|
293
293
|
top: 0;
|
|
294
294
|
left: 0;
|
|
@@ -302,7 +302,7 @@
|
|
|
302
302
|
padding: 1rem;
|
|
303
303
|
}
|
|
304
304
|
|
|
305
|
-
.
|
|
305
|
+
.liberex-kyc-modal {
|
|
306
306
|
background-color: white;
|
|
307
307
|
border-radius: 12px;
|
|
308
308
|
max-width: 600px;
|
|
@@ -311,54 +311,54 @@
|
|
|
311
311
|
overflow-y: auto;
|
|
312
312
|
}
|
|
313
313
|
|
|
314
|
-
.
|
|
314
|
+
.liberex-kyc-modal .liberex-kyc-container {
|
|
315
315
|
border: none;
|
|
316
316
|
box-shadow: none;
|
|
317
317
|
margin: 0;
|
|
318
318
|
}
|
|
319
319
|
|
|
320
320
|
/* Dark Theme */
|
|
321
|
-
.
|
|
321
|
+
.liberex-kyc-container[data-theme="dark"] {
|
|
322
322
|
background-color: #1f2937;
|
|
323
323
|
color: #f9fafb;
|
|
324
324
|
border-color: #374151;
|
|
325
325
|
}
|
|
326
326
|
|
|
327
|
-
.
|
|
328
|
-
.
|
|
327
|
+
.liberex-kyc-container[data-theme="dark"] .form-field input,
|
|
328
|
+
.liberex-kyc-container[data-theme="dark"] .form-field select {
|
|
329
329
|
background-color: #374151;
|
|
330
330
|
border-color: #4b5563;
|
|
331
331
|
color: #f9fafb;
|
|
332
332
|
}
|
|
333
333
|
|
|
334
|
-
.
|
|
335
|
-
.
|
|
334
|
+
.liberex-kyc-container[data-theme="dark"] .form-field input:focus,
|
|
335
|
+
.liberex-kyc-container[data-theme="dark"] .form-field select:focus {
|
|
336
336
|
border-color: #6366f1;
|
|
337
337
|
}
|
|
338
338
|
|
|
339
|
-
.
|
|
339
|
+
.liberex-kyc-container[data-theme="dark"] .review-section {
|
|
340
340
|
background-color: #374151;
|
|
341
341
|
border-color: #4b5563;
|
|
342
342
|
}
|
|
343
343
|
|
|
344
|
-
.
|
|
344
|
+
.liberex-kyc-container[data-theme="dark"] .btn-secondary {
|
|
345
345
|
border-color: #4b5563;
|
|
346
346
|
color: #d1d5db;
|
|
347
347
|
}
|
|
348
348
|
|
|
349
|
-
.
|
|
349
|
+
.liberex-kyc-container[data-theme="dark"] .btn-secondary:hover {
|
|
350
350
|
background-color: #374151;
|
|
351
351
|
border-color: #6b7280;
|
|
352
352
|
}
|
|
353
353
|
|
|
354
|
-
.
|
|
354
|
+
.liberex-kyc-container[data-theme="dark"] .info-box {
|
|
355
355
|
background-color: #064e3b;
|
|
356
356
|
border-color: #047857;
|
|
357
357
|
}
|
|
358
358
|
|
|
359
359
|
/* Responsive Design */
|
|
360
360
|
@media (max-width: 640px) {
|
|
361
|
-
.
|
|
361
|
+
.liberex-kyc-container {
|
|
362
362
|
padding: 1rem;
|
|
363
363
|
margin: 1rem;
|
|
364
364
|
}
|
|
@@ -417,7 +417,7 @@
|
|
|
417
417
|
|
|
418
418
|
/* High Contrast Mode */
|
|
419
419
|
@media (prefers-contrast: high) {
|
|
420
|
-
.
|
|
420
|
+
.liberex-kyc-container {
|
|
421
421
|
border-width: 2px;
|
|
422
422
|
}
|
|
423
423
|
|
|
@@ -82,7 +82,7 @@ export function LiberexKYC({
|
|
|
82
82
|
setIsSubmitting(true);
|
|
83
83
|
try {
|
|
84
84
|
// Format date of birth
|
|
85
|
-
const dateOfBirth =
|
|
85
|
+
const dateOfBirth = formData.dobYear + '-' + formData.dobMonth.padStart(2, '0') + '-' + formData.dobDay.padStart(2, '0');
|
|
86
86
|
|
|
87
87
|
// Prepare KYC data
|
|
88
88
|
const kycData = {
|
|
@@ -106,7 +106,7 @@ export function LiberexKYC({
|
|
|
106
106
|
};
|
|
107
107
|
|
|
108
108
|
// Call your KYC submission API
|
|
109
|
-
const response = await fetch('/api/
|
|
109
|
+
const response = await fetch('/api/liberex', {
|
|
110
110
|
method: 'POST',
|
|
111
111
|
headers: { 'Content-Type': 'application/json' },
|
|
112
112
|
body: JSON.stringify({
|
|
@@ -155,32 +155,32 @@ export function LiberexKYC({
|
|
|
155
155
|
};
|
|
156
156
|
|
|
157
157
|
const updateFormData = (updates: Partial<KycFormData>) => {
|
|
158
|
-
setFormData(prev => ({ ...prev, ...updates }));
|
|
158
|
+
setFormData(prev => (\{{ ...prev, ...updates \}}));
|
|
159
159
|
};
|
|
160
160
|
|
|
161
|
-
const containerStyle = {
|
|
161
|
+
const containerStyle = \{{
|
|
162
162
|
backgroundColor: themeConfig.backgroundColor,
|
|
163
163
|
color: themeConfig.textColor,
|
|
164
164
|
borderRadius: themeConfig.borderRadius
|
|
165
|
-
};
|
|
165
|
+
\}};
|
|
166
166
|
|
|
167
|
-
const primaryButtonStyle = {
|
|
167
|
+
const primaryButtonStyle = \{{
|
|
168
168
|
backgroundColor: themeConfig.primaryColor,
|
|
169
169
|
borderRadius: themeConfig.borderRadius
|
|
170
|
-
};
|
|
170
|
+
\}};
|
|
171
171
|
|
|
172
172
|
return (
|
|
173
|
-
<div className={`
|
|
173
|
+
<div className={`liberex-kyc-container ${className}`} style={containerStyle}>
|
|
174
174
|
{/* Progress Bar */}
|
|
175
175
|
{currentStep !== 'intro' && currentStep !== 'success' && (
|
|
176
176
|
<div className="progress-container">
|
|
177
177
|
<div className="progress-bar">
|
|
178
|
-
<div
|
|
179
|
-
className="progress-fill"
|
|
180
|
-
style
|
|
181
|
-
width:
|
|
182
|
-
backgroundColor: themeConfig.primaryColor
|
|
183
|
-
}}
|
|
178
|
+
<div
|
|
179
|
+
className="progress-fill"
|
|
180
|
+
style=\{{
|
|
181
|
+
width: progressPercentage + '%',
|
|
182
|
+
backgroundColor: themeConfig.primaryColor
|
|
183
|
+
\}}
|
|
184
184
|
/>
|
|
185
185
|
</div>
|
|
186
186
|
<div className="progress-text">
|
|
@@ -253,7 +253,7 @@ function IntroStep({ onNext, onClose, theme }: any) {
|
|
|
253
253
|
return (
|
|
254
254
|
<div className="kyc-step intro-step">
|
|
255
255
|
<div className="step-header">
|
|
256
|
-
<CheckCircle className="step-icon" style
|
|
256
|
+
<CheckCircle className="step-icon" style=\{{ color: theme.primaryColor \}} />
|
|
257
257
|
<h2>Identity Verification</h2>
|
|
258
258
|
<p>We need to verify your identity to comply with financial regulations. This process takes about 3 minutes.</p>
|
|
259
259
|
</div>
|
|
@@ -286,7 +286,7 @@ function IntroStep({ onNext, onClose, theme }: any) {
|
|
|
286
286
|
<button
|
|
287
287
|
onClick={onNext}
|
|
288
288
|
className="btn-primary"
|
|
289
|
-
style
|
|
289
|
+
style=\{{ backgroundColor: theme.primaryColor \}}
|
|
290
290
|
>
|
|
291
291
|
Start Verification
|
|
292
292
|
<ArrowRight className="btn-icon" />
|
|
@@ -402,7 +402,7 @@ function PersonalInfoStep({ formData, updateFormData, onNext, onPrev, theme }: a
|
|
|
402
402
|
onClick={onNext}
|
|
403
403
|
disabled={!isValid}
|
|
404
404
|
className="btn-primary"
|
|
405
|
-
style
|
|
405
|
+
style=\{{ backgroundColor: theme.primaryColor \}}
|
|
406
406
|
>
|
|
407
407
|
Continue
|
|
408
408
|
<ArrowRight className="btn-icon" />
|
|
@@ -465,7 +465,7 @@ function IdentificationStep({ formData, updateFormData, onNext, onPrev, theme }:
|
|
|
465
465
|
onClick={onNext}
|
|
466
466
|
disabled={!isValid}
|
|
467
467
|
className="btn-primary"
|
|
468
|
-
style
|
|
468
|
+
style=\{{ backgroundColor: theme.primaryColor \}}
|
|
469
469
|
>
|
|
470
470
|
Continue
|
|
471
471
|
<ArrowRight className="btn-icon" />
|
|
@@ -567,7 +567,7 @@ function AddressStep({ formData, updateFormData, onNext, onPrev, theme }: any) {
|
|
|
567
567
|
onClick={onNext}
|
|
568
568
|
disabled={!isValid}
|
|
569
569
|
className="btn-primary"
|
|
570
|
-
style
|
|
570
|
+
style=\{{ backgroundColor: theme.primaryColor \}}
|
|
571
571
|
>
|
|
572
572
|
Continue
|
|
573
573
|
<ArrowRight className="btn-icon" />
|
|
@@ -620,7 +620,7 @@ function ReviewStep({ formData, onSubmit, onPrev, isSubmitting, theme }: any) {
|
|
|
620
620
|
<span>Address:</span>
|
|
621
621
|
<span>
|
|
622
622
|
{formData.addressLine1}
|
|
623
|
-
{formData.addressLine2 && `,
|
|
623
|
+
{formData.addressLine2 && `, ${formData.addressLine2}`}
|
|
624
624
|
</span>
|
|
625
625
|
</div>
|
|
626
626
|
<div className="review-item">
|
|
@@ -643,7 +643,7 @@ function ReviewStep({ formData, onSubmit, onPrev, isSubmitting, theme }: any) {
|
|
|
643
643
|
onClick={onSubmit}
|
|
644
644
|
disabled={isSubmitting}
|
|
645
645
|
className="btn-primary"
|
|
646
|
-
style
|
|
646
|
+
style=\{{ backgroundColor: theme.primaryColor \}}
|
|
647
647
|
>
|
|
648
648
|
{isSubmitting ? (
|
|
649
649
|
<>
|
|
@@ -666,7 +666,7 @@ function SuccessStep({ onClose, theme }: any) {
|
|
|
666
666
|
return (
|
|
667
667
|
<div className="kyc-step success-step">
|
|
668
668
|
<div className="step-header">
|
|
669
|
-
<CheckCircle className="step-icon success-icon" style
|
|
669
|
+
<CheckCircle className="step-icon success-icon" style=\{{ color: theme.primaryColor \}} />
|
|
670
670
|
<h2>Verification Submitted!</h2>
|
|
671
671
|
<p>Your identity verification has been submitted successfully. We'll review your information and notify you of the results.</p>
|
|
672
672
|
</div>
|
|
@@ -687,7 +687,7 @@ function SuccessStep({ onClose, theme }: any) {
|
|
|
687
687
|
<button
|
|
688
688
|
onClick={onClose}
|
|
689
689
|
className="btn-primary"
|
|
690
|
-
style
|
|
690
|
+
style=\{{ backgroundColor: theme.primaryColor \}}
|
|
691
691
|
>
|
|
692
692
|
Continue
|
|
693
693
|
</button>
|
|
@@ -702,8 +702,8 @@ export function LiberexKYCModal({ isOpen, onClose, ...props }: LiberexKYCProps &
|
|
|
702
702
|
if (!isOpen) return null;
|
|
703
703
|
|
|
704
704
|
return (
|
|
705
|
-
<div className="
|
|
706
|
-
<div className="
|
|
705
|
+
<div className="liberex-kyc-modal-overlay">
|
|
706
|
+
<div className="liberex-kyc-modal">
|
|
707
707
|
<LiberexKYC {...props} onClose={onClose} />
|
|
708
708
|
</div>
|
|
709
709
|
</div>
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { LiberExProvider } from '@diviswap/sdk/react';
|
|
2
2
|
|
|
3
|
-
export default function
|
|
3
|
+
export default function LiberExLayout({
|
|
4
4
|
children,
|
|
5
5
|
}: {
|
|
6
6
|
children: React.ReactNode;
|
|
7
7
|
}) {
|
|
8
8
|
return (
|
|
9
|
-
<
|
|
9
|
+
<LiberExProvider>
|
|
10
10
|
{children}
|
|
11
|
-
</
|
|
11
|
+
</LiberExProvider>
|
|
12
12
|
);
|
|
13
13
|
}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { LiberExProvider } from './lbx-provider';
|
|
2
2
|
|
|
3
|
-
export default function
|
|
3
|
+
export default function LiberExLayout({
|
|
4
4
|
children,
|
|
5
5
|
}: {
|
|
6
6
|
children: React.ReactNode;
|
|
7
7
|
}) {
|
|
8
8
|
return (
|
|
9
|
-
<
|
|
9
|
+
<LiberExProvider>
|
|
10
10
|
{children}
|
|
11
|
-
</
|
|
11
|
+
</LiberExProvider>
|
|
12
12
|
);
|
|
13
13
|
}
|
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
import { NextRequest, NextResponse } from 'next/server';
|
|
2
2
|
|
|
3
|
-
// This middleware adds
|
|
3
|
+
// This middleware adds LiberEx session information to requests
|
|
4
4
|
// Note: In middleware, we use request.cookies (not the async cookies() from next/headers)
|
|
5
|
-
export function
|
|
6
|
-
// Check for
|
|
7
|
-
const
|
|
5
|
+
export function liberexMiddleware(request: NextRequest) {
|
|
6
|
+
// Check for LiberEx session cookie
|
|
7
|
+
const liberexSession = request.cookies.get('liberex_session');
|
|
8
8
|
|
|
9
|
-
if (!
|
|
9
|
+
if (!liberexSession) {
|
|
10
10
|
// No session, proceed without authentication
|
|
11
11
|
return NextResponse.next();
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
// Add session to headers for API routes
|
|
15
15
|
const requestHeaders = new Headers(request.headers);
|
|
16
|
-
requestHeaders.set('x-
|
|
16
|
+
requestHeaders.set('x-liberex-session', liberexSession.value);
|
|
17
17
|
|
|
18
18
|
// You can also add other headers or perform additional checks here
|
|
19
|
-
requestHeaders.set('x-
|
|
19
|
+
requestHeaders.set('x-liberex-client-version', '1.0.0');
|
|
20
20
|
|
|
21
21
|
return NextResponse.next({
|
|
22
22
|
request: {
|
|
@@ -26,24 +26,24 @@ export function diviswapMiddleware(request: NextRequest) {
|
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
// Optional: Add route protection
|
|
29
|
-
export function
|
|
30
|
-
const
|
|
29
|
+
export function protectLiberExRoutes(request: NextRequest) {
|
|
30
|
+
const liberexSession = request.cookies.get('liberex_session');
|
|
31
31
|
|
|
32
32
|
// List of protected routes
|
|
33
33
|
const protectedRoutes = [
|
|
34
|
-
'/
|
|
35
|
-
'/
|
|
36
|
-
'/
|
|
34
|
+
'/liberex/dashboard',
|
|
35
|
+
'/liberex/transactions',
|
|
36
|
+
'/liberex/settings'
|
|
37
37
|
];
|
|
38
38
|
|
|
39
39
|
const isProtectedRoute = protectedRoutes.some(route =>
|
|
40
40
|
request.nextUrl.pathname.startsWith(route)
|
|
41
41
|
);
|
|
42
42
|
|
|
43
|
-
if (isProtectedRoute && !
|
|
43
|
+
if (isProtectedRoute && !liberexSession) {
|
|
44
44
|
// Redirect to login page
|
|
45
|
-
return NextResponse.redirect(new URL('/
|
|
45
|
+
return NextResponse.redirect(new URL('/liberex', request.url));
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
-
return
|
|
48
|
+
return liberexMiddleware(request);
|
|
49
49
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { LiberExProvider } from '@diviswap/sdk/react';
|
|
4
4
|
|
|
5
|
-
// Wrapper to ensure client-side rendering for
|
|
6
|
-
export function
|
|
7
|
-
return <
|
|
5
|
+
// Wrapper to ensure client-side rendering for LiberEx components
|
|
6
|
+
export function LiberExClientProvider({ children }: { children: React.ReactNode }) {
|
|
7
|
+
return <LiberExProvider>{children}</LiberExProvider>;
|
|
8
8
|
}
|