@diviswap/sdk 1.7.12 → 1.7.14

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.
Files changed (45) hide show
  1. package/dist/cli/index.js +8 -2
  2. package/dist/cli/templates/nextjs-app/actions.ts.hbs +32 -32
  3. package/dist/cli/templates/nextjs-app/api-hooks.ts.hbs +10 -10
  4. package/dist/cli/templates/nextjs-app/api-route.ts.hbs +67 -67
  5. package/dist/cli/templates/nextjs-app/auth-context.tsx.hbs +1 -1
  6. package/dist/cli/templates/nextjs-app/client.ts.hbs +10 -10
  7. package/dist/cli/templates/nextjs-app/dashboard-hooks.ts.hbs +7 -7
  8. package/dist/cli/templates/nextjs-app/example-page.tsx.hbs +9 -9
  9. package/dist/cli/templates/nextjs-app/hooks.ts.hbs +7 -7
  10. package/dist/cli/templates/nextjs-app/kyc-hooks.ts.hbs +3 -3
  11. package/dist/cli/templates/nextjs-app/kyc-wizard.css.hbs +16 -16
  12. package/dist/cli/templates/nextjs-app/kyc-wizard.tsx.hbs +25 -25
  13. package/dist/cli/templates/nextjs-app/layout-wrapper.tsx.hbs +4 -4
  14. package/dist/cli/templates/nextjs-app/layout.tsx.hbs +4 -4
  15. package/dist/cli/templates/nextjs-app/middleware.ts.hbs +15 -15
  16. package/dist/cli/templates/nextjs-app/provider-wrapper.tsx.hbs +4 -4
  17. package/dist/cli/templates/nextjs-app/provider.tsx.hbs +21 -21
  18. package/dist/cli/templates/nextjs-app/setup-provider.tsx.hbs +4 -4
  19. package/dist/cli/templates/react/api-client-wrapper.ts.hbs +14 -14
  20. package/dist/cli/templates/react/example.tsx.hbs +6 -6
  21. package/dist/cli/templates/react/tanstack-hooks.ts.hbs +14 -14
  22. package/dist/cli/templates/webhooks/nextjs.hbs +3 -3
  23. package/package.json +2 -1
  24. package/src/cli/templates/index.ts +13 -2
  25. package/src/cli/templates/nextjs-app/actions.ts.hbs +32 -32
  26. package/src/cli/templates/nextjs-app/api-hooks.ts.hbs +10 -10
  27. package/src/cli/templates/nextjs-app/api-route.ts.hbs +67 -67
  28. package/src/cli/templates/nextjs-app/auth-context.tsx.hbs +1 -1
  29. package/src/cli/templates/nextjs-app/client.ts.hbs +10 -10
  30. package/src/cli/templates/nextjs-app/dashboard-hooks.ts.hbs +7 -7
  31. package/src/cli/templates/nextjs-app/example-page.tsx.hbs +9 -9
  32. package/src/cli/templates/nextjs-app/hooks.ts.hbs +7 -7
  33. package/src/cli/templates/nextjs-app/kyc-hooks.ts.hbs +3 -3
  34. package/src/cli/templates/nextjs-app/kyc-wizard.css.hbs +16 -16
  35. package/src/cli/templates/nextjs-app/kyc-wizard.tsx.hbs +25 -25
  36. package/src/cli/templates/nextjs-app/layout-wrapper.tsx.hbs +4 -4
  37. package/src/cli/templates/nextjs-app/layout.tsx.hbs +4 -4
  38. package/src/cli/templates/nextjs-app/middleware.ts.hbs +15 -15
  39. package/src/cli/templates/nextjs-app/provider-wrapper.tsx.hbs +4 -4
  40. package/src/cli/templates/nextjs-app/provider.tsx.hbs +21 -21
  41. package/src/cli/templates/nextjs-app/setup-provider.tsx.hbs +4 -4
  42. package/src/cli/templates/react/api-client-wrapper.ts.hbs +14 -14
  43. package/src/cli/templates/react/example.tsx.hbs +6 -6
  44. package/src/cli/templates/react/tanstack-hooks.ts.hbs +14 -14
  45. package/src/cli/templates/webhooks/nextjs.hbs +3 -3
package/dist/cli/index.js CHANGED
@@ -148,7 +148,13 @@ function getTemplate(templateName, data) {
148
148
  possiblePaths.forEach((p) => console.error(` - ${p}`));
149
149
  templateSource = getInlineTemplateSource(templateName);
150
150
  }
151
- template = Handlebars__default.default.compile(templateSource);
151
+ const PLACEHOLDER = "__TEMPLATE_LITERAL_START__";
152
+ templateSource = templateSource.replace(/\$\{/g, PLACEHOLDER);
153
+ const compiledTemplate = Handlebars__default.default.compile(templateSource);
154
+ template = (data2) => {
155
+ const result = compiledTemplate(data2);
156
+ return result.replace(new RegExp(PLACEHOLDER, "g"), "${");
157
+ };
152
158
  templateCache.set(templateName, template);
153
159
  }
154
160
  return template(data);
@@ -1931,7 +1937,7 @@ async function uninstall(options = {}) {
1931
1937
  }
1932
1938
 
1933
1939
  // package.json
1934
- var version = "1.7.12";
1940
+ var version = "1.7.14";
1935
1941
 
1936
1942
  // src/cli/index.ts
1937
1943
  var program = new commander.Command();
@@ -1,16 +1,16 @@
1
1
  'use server';
2
2
 
3
- import { Diviswap } from '@diviswap/sdk';
4
- import type { Transaction, Payee } from '@diviswap/sdk';
3
+ import { LiberEx } from '@99darwin/liberex-sdk';
4
+ import type { Transaction, Payee } from '@99darwin/liberex-sdk';
5
5
  import { revalidatePath } from 'next/cache';
6
6
  import { cookies } from 'next/headers';
7
7
 
8
- // Initialize Diviswap SDK
9
- function getDiviswap() {
10
- return Diviswap.init({
11
- apiKey: process.env.DIVISWAP_API_KEY!,
12
- clientId: process.env.DIVISWAP_CLIENT_ID!,
13
- environment: (process.env.NEXT_PUBLIC_DIVISWAP_ENV as 'production' | 'sandbox') || 'production',
8
+ // Initialize LiberEx SDK
9
+ function getLiberEx() {
10
+ return LiberEx.init({
11
+ apiKey: process.env.LIBEREX_API_KEY!,
12
+ clientId: process.env.LIBEREX_CLIENT_ID!,
13
+ environment: (process.env.NEXT_PUBLIC_LIBEREX_ENV as 'production' | 'sandbox') || 'production',
14
14
  debug: true // Enable debug logging
15
15
  });
16
16
  }
@@ -18,7 +18,7 @@ function getDiviswap() {
18
18
  // Helper to get session token from cookies
19
19
  async function getSessionToken() {
20
20
  const cookieStore = await cookies();
21
- const session = cookieStore.get('diviswap_session');
21
+ const session = cookieStore.get('liberex_session');
22
22
  return session?.value;
23
23
  }
24
24
 
@@ -39,7 +39,7 @@ export async function createTransactionAction(data: {
39
39
  return { success: false, error: 'Not authenticated' };
40
40
  }
41
41
 
42
- const diviswap = getDiviswap();
42
+ const liberex = getLiberEx();
43
43
 
44
44
  // Use the appropriate method based on transaction type
45
45
  let transaction;
@@ -47,7 +47,7 @@ export async function createTransactionAction(data: {
47
47
  // Note: Onramp is not yet available in v1 API
48
48
  return { success: false, error: 'Onramp transactions are not yet available' };
49
49
  } else {
50
- transaction = await diviswap.transactions.offramp({
50
+ transaction = await liberex.transactions.offramp({
51
51
  amount: data.amount,
52
52
  currency: data.currency || 'USD',
53
53
  payeeId: data.payeeId!,
@@ -56,7 +56,7 @@ export async function createTransactionAction(data: {
56
56
  });
57
57
  }
58
58
 
59
- revalidatePath('/diviswap');
59
+ revalidatePath('/liberex');
60
60
  return { success: true, transaction };
61
61
  } catch (error) {
62
62
  return {
@@ -78,8 +78,8 @@ export async function getTransactionsAction(filters?: {
78
78
  return { success: false, error: 'Not authenticated' };
79
79
  }
80
80
 
81
- const diviswap = getDiviswap();
82
- const transactions = await diviswap.transactions.list(filters);
81
+ const liberex = getLiberEx();
82
+ const transactions = await liberex.transactions.list(filters);
83
83
 
84
84
  return { success: true, transactions };
85
85
  } catch (error) {
@@ -98,8 +98,8 @@ export async function getPayeesAction() {
98
98
  return { success: false, error: 'Not authenticated' };
99
99
  }
100
100
 
101
- const diviswap = getDiviswap();
102
- const payees = await diviswap.payees.list();
101
+ const liberex = getLiberEx();
102
+ const payees = await liberex.payees.list();
103
103
 
104
104
  return { success: true, payees };
105
105
  } catch (error) {
@@ -122,8 +122,8 @@ export async function createPayeeAction(data: {
122
122
  return { success: false, error: 'Not authenticated' };
123
123
  }
124
124
 
125
- const diviswap = getDiviswap();
126
- const payee = await diviswap.payees.create({
125
+ const liberex = getLiberEx();
126
+ const payee = await liberex.payees.create({
127
127
  nickname: data.nickname,
128
128
  accountNumber: data.accountNumber,
129
129
  routingNumber: data.routingNumber,
@@ -131,7 +131,7 @@ export async function createPayeeAction(data: {
131
131
  setAsDefault: false
132
132
  });
133
133
 
134
- revalidatePath('/diviswap');
134
+ revalidatePath('/liberex');
135
135
  return { success: true, payee };
136
136
  } catch (error) {
137
137
  return {
@@ -148,10 +148,10 @@ export async function deletePayeeAction(payeeId: string) {
148
148
  return { success: false, error: 'Not authenticated' };
149
149
  }
150
150
 
151
- const diviswap = getDiviswap();
152
- await diviswap.payees.delete(payeeId);
151
+ const liberex = getLiberEx();
152
+ await liberex.payees.delete(payeeId);
153
153
 
154
- revalidatePath('/diviswap');
154
+ revalidatePath('/liberex');
155
155
  return { success: true };
156
156
  } catch (error) {
157
157
  return {
@@ -169,8 +169,8 @@ export async function calculateFeesAction(data: {
169
169
  currency?: string;
170
170
  }) {
171
171
  try {
172
- const diviswap = getDiviswap();
173
- const fees = await diviswap.fees.calculateFees({
172
+ const liberex = getLiberEx();
173
+ const fees = await liberex.fees.calculateFees({
174
174
  amount: data.amount,
175
175
  userId: undefined // Optional: for per-user fees
176
176
  });
@@ -191,8 +191,8 @@ export async function getIntegratorFeesAction() {
191
191
  return { success: false, error: 'Not authenticated' };
192
192
  }
193
193
 
194
- const diviswap = getDiviswap();
195
- const fees = await diviswap.fees.getFees();
194
+ const liberex = getLiberEx();
195
+ const fees = await liberex.fees.getFees();
196
196
 
197
197
  return { success: true, fees };
198
198
  } catch (error) {
@@ -213,10 +213,10 @@ export async function updateIntegratorFeeAction(data: {
213
213
  return { success: false, error: 'Not authenticated' };
214
214
  }
215
215
 
216
- const diviswap = getDiviswap();
217
- const fee = await diviswap.fees.setFee(data);
216
+ const liberex = getLiberEx();
217
+ const fee = await liberex.fees.setFee(data);
218
218
 
219
- revalidatePath('/diviswap');
219
+ revalidatePath('/liberex');
220
220
  return { success: true, fee };
221
221
  } catch (error) {
222
222
  return {
@@ -235,8 +235,8 @@ export async function getCurrentUserAction() {
235
235
  return { success: false, user: null };
236
236
  }
237
237
 
238
- const diviswap = getDiviswap();
239
- const user = await diviswap.auth.getProfile();
238
+ const liberex = getLiberEx();
239
+ const user = await liberex.auth.getProfile();
240
240
 
241
241
  return { success: true, user };
242
242
  } catch (error) {
@@ -247,7 +247,7 @@ export async function getCurrentUserAction() {
247
247
  // Utility action for checking API status
248
248
  export async function checkApiStatusAction() {
249
249
  try {
250
- const diviswap = getDiviswap();
250
+ const liberex = getLiberEx();
251
251
  // Note: Health check endpoint not available in SDK
252
252
  return { success: true, status: 'OK' };
253
253
  } catch (error) {
@@ -34,7 +34,7 @@ export function useAuth() {
34
34
 
35
35
  const setCustomer = useCallback(async (customerId: string, customerEmail: string) => {
36
36
  try {
37
- const response = await fetch('/api/diviswap', {
37
+ const response = await fetch('/api/liberex', {
38
38
  method: 'POST',
39
39
  headers: { 'Content-Type': 'application/json' },
40
40
  body: JSON.stringify({
@@ -56,7 +56,7 @@ export function useAuth() {
56
56
 
57
57
  const clearCustomer = useCallback(async () => {
58
58
  try {
59
- await fetch('/api/diviswap', {
59
+ await fetch('/api/liberex', {
60
60
  method: 'POST',
61
61
  headers: { 'Content-Type': 'application/json' },
62
62
  body: JSON.stringify({ action: 'clearCustomer' })
@@ -106,7 +106,7 @@ export function useTransactions() {
106
106
  ...filters
107
107
  });
108
108
 
109
- const response = await fetch(`/api/diviswap?\${queryParams}`);
109
+ const response = await fetch(`/api/liberex?${queryParams}`);
110
110
  if (!response.ok) throw new Error('Failed to fetch transactions');
111
111
 
112
112
  const data = await response.json();
@@ -129,7 +129,7 @@ export function useTransactions() {
129
129
  setError(null);
130
130
 
131
131
  try {
132
- const response = await fetch('/api/diviswap', {
132
+ const response = await fetch('/api/liberex', {
133
133
  method: 'POST',
134
134
  headers: { 'Content-Type': 'application/json' },
135
135
  body: JSON.stringify({
@@ -180,7 +180,7 @@ export function usePayees() {
180
180
  setError(null);
181
181
 
182
182
  try {
183
- const response = await fetch(`/api/diviswap?resource=payees&customerId=\${customerId}&customerEmail=\${customerEmail}`);
183
+ const response = await fetch(`/api/liberex?resource=payees&customerId=${customerId}&customerEmail=${customerEmail}`);
184
184
  if (!response.ok) throw new Error('Failed to fetch payees');
185
185
 
186
186
  const data = await response.json();
@@ -203,7 +203,7 @@ export function usePayees() {
203
203
  setError(null);
204
204
 
205
205
  try {
206
- const response = await fetch('/api/diviswap', {
206
+ const response = await fetch('/api/liberex', {
207
207
  method: 'POST',
208
208
  headers: { 'Content-Type': 'application/json' },
209
209
  body: JSON.stringify({
@@ -237,7 +237,7 @@ export function usePayees() {
237
237
  setError(null);
238
238
 
239
239
  try {
240
- const response = await fetch(`/api/diviswap?resource=payee&id=\${id}&customerId=\${customerId}&customerEmail=\${customerEmail}`, {
240
+ const response = await fetch(`/api/liberex?resource=payee&id=${id}&customerId=${customerId}&customerEmail=${customerEmail}`, {
241
241
  method: 'DELETE'
242
242
  });
243
243
 
@@ -286,7 +286,7 @@ export function useKYC() {
286
286
  setError(null);
287
287
 
288
288
  try {
289
- const response = await fetch(`/api/diviswap?resource=kycStatus&customerId=\${customerId}&customerEmail=\${customerEmail}`);
289
+ const response = await fetch(`/api/liberex?resource=kycStatus&customerId=${customerId}&customerEmail=${customerEmail}`);
290
290
  if (!response.ok) throw new Error('Failed to fetch KYC status');
291
291
 
292
292
  const data = await response.json();
@@ -309,7 +309,7 @@ export function useKYC() {
309
309
  setError(null);
310
310
 
311
311
  try {
312
- const response = await fetch('/api/diviswap', {
312
+ const response = await fetch('/api/liberex', {
313
313
  method: 'POST',
314
314
  headers: { 'Content-Type': 'application/json' },
315
315
  body: JSON.stringify({
@@ -372,7 +372,7 @@ export function useFeeCalculator() {
372
372
  setError(null);
373
373
 
374
374
  try {
375
- const response = await fetch('/api/diviswap', {
375
+ const response = await fetch('/api/liberex', {
376
376
  method: 'POST',
377
377
  headers: { 'Content-Type': 'application/json' },
378
378
  body: JSON.stringify({
@@ -1,24 +1,24 @@
1
1
  import { NextRequest, NextResponse } from 'next/server';
2
- import { Diviswap } from '@diviswap/sdk';
2
+ import { LiberEx } from '@99darwin/liberex-sdk';
3
3
  import { cookies } from 'next/headers';
4
- import type { Diviswap as DiviswapType } from '@diviswap/sdk';
4
+ import type { LiberEx as LiberExType } from '@99darwin/liberex-sdk';
5
5
 
6
- // Initialize Diviswap SDK with partner authentication
7
- function getDiviswap() {
6
+ // Initialize LiberEx SDK with partner authentication
7
+ function getLiberEx() {
8
8
  const config = {
9
9
  mode: 'partner' as const,
10
- keyId: process.env.DIVISWAP_PARTNER_KEY_ID!,
11
- secretKey: process.env.DIVISWAP_PARTNER_SECRET_KEY!,
10
+ keyId: process.env.LIBEREX_PARTNER_KEY_ID!,
11
+ secretKey: process.env.LIBEREX_PARTNER_SECRET_KEY!,
12
12
  authMethod: 'hmac' as const,
13
- environment: (process.env.NEXT_PUBLIC_DIVISWAP_ENV as 'production' | 'sandbox') || 'sandbox'
13
+ environment: (process.env.NEXT_PUBLIC_LIBEREX_ENV as 'production' | 'sandbox') || 'sandbox'
14
14
  };
15
15
 
16
- return Diviswap.init(config);
16
+ return LiberEx.init(config);
17
17
  }
18
18
 
19
19
  // Helper function to handle errors
20
20
  function handleError(error: unknown) {
21
- console.error('Diviswap API error:', error);
21
+ console.error('LiberEx API error:', error);
22
22
 
23
23
  if (error instanceof Error) {
24
24
  return NextResponse.json(
@@ -35,7 +35,7 @@ function handleError(error: unknown) {
35
35
 
36
36
  // Type definitions for handlers
37
37
  type HandlerContext = {
38
- diviswap: DiviswapType;
38
+ liberex: LiberExType;
39
39
  cookieStore: Awaited<ReturnType<typeof cookies>>;
40
40
  };
41
41
 
@@ -43,7 +43,7 @@ type ActionHandler = (params: any, context: HandlerContext) => Promise<NextRespo
43
43
  type ResourceHandler = (searchParams: URLSearchParams, context: HandlerContext) => Promise<NextResponse>;
44
44
 
45
45
  // Helper function to set customer context from request
46
- function setCustomerContext(diviswap: DiviswapType, params: any) {
46
+ function setCustomerContext(liberex: LiberExType, params: any) {
47
47
  // In partner authentication, you need to identify your user from your session/auth
48
48
  // For this example, we'll expect customerId and customerEmail in the request
49
49
  // In production, you'd get this from your own authentication system
@@ -51,14 +51,14 @@ function setCustomerContext(diviswap: DiviswapType, params: any) {
51
51
  const customerId = params.customerId || 'demo-customer-123';
52
52
  const customerEmail = params.customerEmail || 'demo@yourapp.com';
53
53
 
54
- diviswap.setCustomer(customerId, customerEmail);
54
+ liberex.setCustomer(customerId, customerEmail);
55
55
  }
56
56
 
57
57
  // POST action handlers
58
58
  const postHandlers: Record<string, ActionHandler> = {
59
- setCustomer: async (params, { diviswap }) => {
59
+ setCustomer: async (params, { liberex }) => {
60
60
  try {
61
- diviswap.setCustomer(params.customerId, params.customerEmail);
61
+ liberex.setCustomer(params.customerId, params.customerEmail);
62
62
  return NextResponse.json({
63
63
  success: true,
64
64
  customerId: params.customerId,
@@ -70,9 +70,9 @@ const postHandlers: Record<string, ActionHandler> = {
70
70
  }
71
71
  },
72
72
 
73
- clearCustomer: async (_, { diviswap }) => {
73
+ clearCustomer: async (_, { liberex }) => {
74
74
  try {
75
- diviswap.clearCustomer();
75
+ liberex.clearCustomer();
76
76
  return NextResponse.json({ success: true });
77
77
  } catch (error: any) {
78
78
  console.error('Clear customer error:', error);
@@ -80,9 +80,9 @@ const postHandlers: Record<string, ActionHandler> = {
80
80
  }
81
81
  },
82
82
 
83
- createTransaction: async (params, { diviswap }) => {
83
+ createTransaction: async (params, { liberex }) => {
84
84
  // Set customer context before API calls
85
- setCustomerContext(diviswap, params);
85
+ setCustomerContext(liberex, params);
86
86
 
87
87
  // Use the appropriate method based on transaction type
88
88
  let transaction;
@@ -121,17 +121,17 @@ const postHandlers: Record<string, ActionHandler> = {
121
121
  // Use environment-appropriate method
122
122
  // Production: uses regular offramp (creates completed transaction)
123
123
  // Sandbox/Development: uses offrampTest (creates pending transaction)
124
- const isProduction = process.env.NEXT_PUBLIC_DIVISWAP_ENV === 'production';
124
+ const isProduction = process.env.NEXT_PUBLIC_LIBEREX_ENV === 'production';
125
125
  transaction = isProduction
126
- ? await diviswap.transactions.offramp(sdkParams)
127
- : await diviswap.transactions.offrampTest(sdkParams);
126
+ ? await liberex.transactions.offramp(sdkParams)
127
+ : await liberex.transactions.offrampTest(sdkParams);
128
128
  }
129
129
  return NextResponse.json(transaction);
130
130
  },
131
131
 
132
- createPayee: async (params, { diviswap }) => {
132
+ createPayee: async (params, { liberex }) => {
133
133
  // Set customer context before API calls
134
- setCustomerContext(diviswap, params);
134
+ setCustomerContext(liberex, params);
135
135
 
136
136
 
137
137
  // Check if the SDK is sending structured debit card data
@@ -144,7 +144,7 @@ const postHandlers: Record<string, ActionHandler> = {
144
144
  setAsDefault: params.setAsDefault || false
145
145
  };
146
146
 
147
- const payee = await diviswap.payees.create(debitCardPayload);
147
+ const payee = await liberex.payees.create(debitCardPayload);
148
148
  return NextResponse.json(payee);
149
149
  }
150
150
  // Handle legacy flat structure for debit cards
@@ -157,7 +157,7 @@ const postHandlers: Record<string, ActionHandler> = {
157
157
  if (params.routingNumber && params.routingNumber.includes('/')) {
158
158
  const expiryParts = params.routingNumber.split('/');
159
159
  expirationMonth = expiryParts[0];
160
- expirationYear = expiryParts[1] ? `20\${expiryParts[1]}` : '2025';
160
+ expirationYear = expiryParts[1] ? `20${expiryParts[1]}` : '2025';
161
161
  }
162
162
 
163
163
  const debitCardPayload = {
@@ -172,11 +172,11 @@ const postHandlers: Record<string, ActionHandler> = {
172
172
  setAsDefault: params.setAsDefault || false
173
173
  };
174
174
 
175
- const payee = await diviswap.payees.create(debitCardPayload);
175
+ const payee = await liberex.payees.create(debitCardPayload);
176
176
  return NextResponse.json(payee);
177
177
  } else {
178
178
  // Bank account structure
179
- const payee = await diviswap.payees.create({
179
+ const payee = await liberex.payees.create({
180
180
  nickname: params.nickname,
181
181
  accountNumber: params.accountNumber,
182
182
  routingNumber: params.routingNumber,
@@ -188,23 +188,23 @@ const postHandlers: Record<string, ActionHandler> = {
188
188
  },
189
189
 
190
190
  {{#if (includes features "fees")}}
191
- calculateFees: async (params, { diviswap }) => {
192
- const fees = await diviswap.fees.calculateFees({
191
+ calculateFees: async (params, { liberex }) => {
192
+ const fees = await liberex.fees.calculateFees({
193
193
  amount: params.amount,
194
194
  userId: undefined
195
195
  });
196
196
  return NextResponse.json(fees);
197
197
  },
198
198
 
199
- getIntegratorFees: async (_, { diviswap }) => {
200
- const fees = await diviswap.fees.getFees();
199
+ getIntegratorFees: async (_, { liberex }) => {
200
+ const fees = await liberex.fees.getFees();
201
201
  return NextResponse.json(fees);
202
202
  },
203
203
  {{/if}}
204
204
 
205
- submitKYC: async (params, { diviswap }) => {
205
+ submitKYC: async (params, { liberex }) => {
206
206
  // Set customer context before KYC submission
207
- setCustomerContext(diviswap, params);
207
+ setCustomerContext(liberex, params);
208
208
 
209
209
  try {
210
210
 
@@ -230,7 +230,7 @@ const postHandlers: Record<string, ActionHandler> = {
230
230
  }
231
231
 
232
232
  // Clean up the payload - remove undefined/null values and empty strings for optional fields
233
- const street = address.addressLine1 + (address.addressLine2 && address.addressLine2.trim() ? ` \${address.addressLine2.trim()}` : '');
233
+ const street = address.addressLine1 + (address.addressLine2 && address.addressLine2.trim() ? ` ${address.addressLine2.trim()}` : '');
234
234
 
235
235
  const kycPayload = {
236
236
  firstName: personalInfo.firstName,
@@ -248,7 +248,7 @@ const postHandlers: Record<string, ActionHandler> = {
248
248
  };
249
249
 
250
250
 
251
- const result = await diviswap.kyc.submitPersonalInfo(kycPayload);
251
+ const result = await liberex.kyc.submitPersonalInfo(kycPayload);
252
252
 
253
253
  return NextResponse.json(result);
254
254
  } catch (error: any) {
@@ -260,12 +260,12 @@ const postHandlers: Record<string, ActionHandler> = {
260
260
  }
261
261
  },
262
262
 
263
- createAddress: async (params, { diviswap }) => {
263
+ createAddress: async (params, { liberex }) => {
264
264
  // Set customer context before API call
265
- setCustomerContext(diviswap, params);
265
+ setCustomerContext(liberex, params);
266
266
 
267
267
  try {
268
- const address = await diviswap.addresses.create({
268
+ const address = await liberex.addresses.create({
269
269
  chain_id: params.chain_id,
270
270
  address: params.address,
271
271
  is_default: params.is_default
@@ -278,12 +278,12 @@ const postHandlers: Record<string, ActionHandler> = {
278
278
  }
279
279
  },
280
280
 
281
- setDefaultAddress: async (params, { diviswap }) => {
281
+ setDefaultAddress: async (params, { liberex }) => {
282
282
  // Set customer context before API call
283
- setCustomerContext(diviswap, params);
283
+ setCustomerContext(liberex, params);
284
284
 
285
285
  try {
286
- await diviswap.addresses.setDefault({
286
+ await liberex.addresses.setDefault({
287
287
  chain_id: params.chain_id,
288
288
  address: params.address
289
289
  });
@@ -295,12 +295,12 @@ const postHandlers: Record<string, ActionHandler> = {
295
295
  }
296
296
  },
297
297
 
298
- deleteAddress: async (params, { diviswap }) => {
298
+ deleteAddress: async (params, { liberex }) => {
299
299
  // Set customer context before API call
300
- setCustomerContext(diviswap, params);
300
+ setCustomerContext(liberex, params);
301
301
 
302
302
  try {
303
- await diviswap.addresses.delete({
303
+ await liberex.addresses.delete({
304
304
  chain_id: params.chain_id,
305
305
  address: params.address
306
306
  });
@@ -330,8 +330,8 @@ export async function POST(request: NextRequest) {
330
330
  );
331
331
  }
332
332
 
333
- const diviswap = getDiviswap();
334
- return await handler(params, { diviswap, cookieStore });
333
+ const liberex = getLiberEx();
334
+ return await handler(params, { liberex, cookieStore });
335
335
  } catch (error) {
336
336
  return handleError(error);
337
337
  }
@@ -339,12 +339,12 @@ export async function POST(request: NextRequest) {
339
339
 
340
340
  // GET resource handlers
341
341
  const getHandlers: Record<string, ResourceHandler> = {
342
- customerStatus: async (searchParams, { diviswap }) => {
342
+ customerStatus: async (searchParams, { liberex }) => {
343
343
  const customerId = searchParams.get('customerId') || 'demo-customer-123';
344
344
  const customerEmail = searchParams.get('customerEmail') || 'demo@yourapp.com';
345
345
 
346
346
  // Set customer context
347
- diviswap.setCustomer(customerId, customerEmail);
347
+ liberex.setCustomer(customerId, customerEmail);
348
348
 
349
349
  return NextResponse.json({
350
350
  customerId,
@@ -354,30 +354,30 @@ const getHandlers: Record<string, ResourceHandler> = {
354
354
  });
355
355
  },
356
356
 
357
- payees: async (searchParams, { diviswap }) => {
357
+ payees: async (searchParams, { liberex }) => {
358
358
  const customerId = searchParams.get('customerId') || 'demo-customer-123';
359
359
  const customerEmail = searchParams.get('customerEmail') || 'demo@yourapp.com';
360
360
 
361
361
  // Set customer context before API call
362
- diviswap.setCustomer(customerId, customerEmail);
362
+ liberex.setCustomer(customerId, customerEmail);
363
363
 
364
- const payees = await diviswap.payees.list();
364
+ const payees = await liberex.payees.list();
365
365
  return NextResponse.json(payees);
366
366
  },
367
367
 
368
- transactions: async (searchParams, { diviswap }) => {
368
+ transactions: async (searchParams, { liberex }) => {
369
369
  const customerId = searchParams.get('customerId') || 'demo-customer-123';
370
370
  const customerEmail = searchParams.get('customerEmail') || 'demo@yourapp.com';
371
371
 
372
372
  // Set customer context before API call
373
- diviswap.setCustomer(customerId, customerEmail);
373
+ liberex.setCustomer(customerId, customerEmail);
374
374
 
375
375
  const limit = searchParams.get('limit');
376
376
  const offset = searchParams.get('offset');
377
377
  const status = searchParams.get('status');
378
378
  const type = searchParams.get('type');
379
379
 
380
- const transactions = await diviswap.transactions.list({
380
+ const transactions = await liberex.transactions.list({
381
381
  limit: limit ? Number(limit) : 10,
382
382
  offset: offset ? Number(offset) : 0,
383
383
  status: status as 'pending' | 'processing' | 'completed' | 'failed' | undefined,
@@ -387,16 +387,16 @@ const getHandlers: Record<string, ResourceHandler> = {
387
387
  return NextResponse.json(transactions);
388
388
  },
389
389
 
390
- kycStatus: async (searchParams, { diviswap }) => {
390
+ kycStatus: async (searchParams, { liberex }) => {
391
391
  const customerId = searchParams.get('customerId') || 'demo-customer-123';
392
392
  const customerEmail = searchParams.get('customerEmail') || 'demo@yourapp.com';
393
393
 
394
394
  // Set customer context before API call
395
- diviswap.setCustomer(customerId, customerEmail);
395
+ liberex.setCustomer(customerId, customerEmail);
396
396
 
397
397
  try {
398
398
 
399
- const status = await diviswap.kyc.getComplianceStatus();
399
+ const status = await liberex.kyc.getComplianceStatus();
400
400
  return NextResponse.json(status);
401
401
  } catch (error: any) {
402
402
  console.error('Failed to get KYC status:', error);
@@ -412,17 +412,17 @@ const getHandlers: Record<string, ResourceHandler> = {
412
412
  }
413
413
  },
414
414
 
415
- addresses: async (searchParams, { diviswap }) => {
415
+ addresses: async (searchParams, { liberex }) => {
416
416
  const customerId = searchParams.get('customerId') || 'demo-customer-123';
417
417
  const customerEmail = searchParams.get('customerEmail') || 'demo@yourapp.com';
418
418
 
419
419
  // Set customer context before API call
420
- diviswap.setCustomer(customerId, customerEmail);
420
+ liberex.setCustomer(customerId, customerEmail);
421
421
 
422
422
  const chain_id = searchParams.get('chain_id');
423
423
  const is_default = searchParams.get('is_default');
424
424
 
425
- const addresses = await diviswap.addresses.list({
425
+ const addresses = await liberex.addresses.list({
426
426
  ...(chain_id && { chain_id: Number(chain_id) }),
427
427
  ...(is_default !== null && { is_default: is_default === 'true' })
428
428
  });
@@ -447,8 +447,8 @@ export async function GET(request: NextRequest) {
447
447
  );
448
448
  }
449
449
 
450
- const diviswap = getDiviswap();
451
- return await handler(searchParams, { diviswap, cookieStore });
450
+ const liberex = getLiberEx();
451
+ return await handler(searchParams, { liberex, cookieStore });
452
452
  } catch (error) {
453
453
  return handleError(error);
454
454
  }
@@ -457,7 +457,7 @@ export async function GET(request: NextRequest) {
457
457
  {{#if (includes features "webhooks")}}
458
458
  // DELETE resource handlers
459
459
  const deleteHandlers: Record<string, ResourceHandler> = {
460
- payee: async (searchParams, { diviswap }) => {
460
+ payee: async (searchParams, { liberex }) => {
461
461
  const customerId = searchParams.get('customerId') || 'demo-customer-123';
462
462
  const customerEmail = searchParams.get('customerEmail') || 'demo@yourapp.com';
463
463
  const id = searchParams.get('id');
@@ -470,9 +470,9 @@ const deleteHandlers: Record<string, ResourceHandler> = {
470
470
  }
471
471
 
472
472
  // Set customer context before API call
473
- diviswap.setCustomer(customerId, customerEmail);
473
+ liberex.setCustomer(customerId, customerEmail);
474
474
 
475
- await diviswap.payees.delete(id);
475
+ await liberex.payees.delete(id);
476
476
  return NextResponse.json({ success: true });
477
477
  },
478
478
  };
@@ -493,8 +493,8 @@ export async function DELETE(request: NextRequest) {
493
493
  );
494
494
  }
495
495
 
496
- const diviswap = getDiviswap();
497
- return await handler(searchParams, { diviswap, cookieStore });
496
+ const liberex = getLiberEx();
497
+ return await handler(searchParams, { liberex, cookieStore });
498
498
  } catch (error) {
499
499
  return handleError(error);
500
500
  }
@@ -26,7 +26,7 @@ interface {{prefix}}AuthProviderProps {
26
26
  clearCustomer: () => Promise<void>;
27
27
  }
28
28
 
29
- // This provider receives props instead of using useDiviswap directly
29
+ // This provider receives props instead of using useLiberEx directly
30
30
  // to avoid circular dependencies
31
31
  export function {{prefix}}AuthProvider({
32
32
  children,