@diviswap/sdk 1.7.22 → 1.7.25

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 CHANGED
@@ -1937,7 +1937,7 @@ async function uninstall(options = {}) {
1937
1937
  }
1938
1938
 
1939
1939
  // package.json
1940
- var version = "1.7.22";
1940
+ var version = "1.7.25";
1941
1941
 
1942
1942
  // src/cli/index.ts
1943
1943
  var program = new commander.Command();
@@ -5,12 +5,15 @@ import type { Transaction, Payee } from '@diviswap/sdk';
5
5
  import { revalidatePath } from 'next/cache';
6
6
 
7
7
  // Initialize Diviswap SDK in Partner mode
8
- function getDiviswap(customerId?: string) {
8
+ // customerId: unique identifier for the customer in YOUR system (required for user-specific operations)
9
+ // customerEmail: optional, only needed if you want Diviswap to send email notifications
10
+ function getDiviswap(customerId?: string, customerEmail?: string) {
9
11
  return Diviswap.init({
10
12
  keyId: process.env.DIVISWAP_PARTNER_KEY_ID!,
11
13
  secretKey: process.env.DIVISWAP_PARTNER_SECRET_KEY!,
12
14
  environment: (process.env.NEXT_PUBLIC_DIVISWAP_ENV as 'production' | 'sandbox') || 'sandbox',
13
- customerId, // Associate operations with this customer
15
+ customerId, // Your unique identifier for this customer (e.g., email, UUID, username)
16
+ customerEmail, // Optional: for email notifications
14
17
  debug: process.env.NODE_ENV === 'development'
15
18
  });
16
19
  }
@@ -26,9 +29,12 @@ export async function createTransactionAction(data: {
26
29
  fromAddress?: string;
27
30
  chain?: string;
28
31
  txHash?: string; // Required for offramp - transaction hash from blockchain
32
+ // Customer identification for partner auth
33
+ customerId?: string; // Required: unique identifier in your system
34
+ customerEmail?: string; // Optional: for email notifications
29
35
  }) {
30
36
  try {
31
- const diviswap = getDiviswap();
37
+ const diviswap = getDiviswap(data.customerId, data.customerEmail);
32
38
 
33
39
  // Use the appropriate method based on transaction type
34
40
  let transaction;
@@ -61,14 +67,18 @@ export async function createTransactionAction(data: {
61
67
  }
62
68
  }
63
69
 
64
- export async function getTransactionsAction(filters?: {
65
- limit?: number;
66
- offset?: number;
67
- status?: 'pending' | 'processing' | 'completed' | 'failed';
68
- type?: 'onramp' | 'offramp';
69
- }) {
70
+ export async function getTransactionsAction(
71
+ customerId?: string,
72
+ customerEmail?: string,
73
+ filters?: {
74
+ limit?: number;
75
+ offset?: number;
76
+ status?: 'pending' | 'processing' | 'completed' | 'failed';
77
+ type?: 'onramp' | 'offramp';
78
+ }
79
+ ) {
70
80
  try {
71
- const diviswap = getDiviswap();
81
+ const diviswap = getDiviswap(customerId, customerEmail);
72
82
  const transactions = await diviswap.transactions.list(filters);
73
83
 
74
84
  return { success: true, transactions };
@@ -81,9 +91,9 @@ export async function getTransactionsAction(filters?: {
81
91
  }
82
92
 
83
93
  // Payee Server Actions
84
- export async function getPayeesAction() {
94
+ export async function getPayeesAction(customerId?: string, customerEmail?: string) {
85
95
  try {
86
- const diviswap = getDiviswap();
96
+ const diviswap = getDiviswap(customerId, customerEmail);
87
97
  const payees = await diviswap.payees.list();
88
98
 
89
99
  return { success: true, payees };
@@ -100,9 +110,11 @@ export async function createPayeeAction(data: {
100
110
  accountNumber: string;
101
111
  routingNumber: string;
102
112
  accountType: 'checking' | 'savings';
113
+ customerId?: string; // Required: unique identifier in your system
114
+ customerEmail?: string; // Optional: for email notifications
103
115
  }) {
104
116
  try {
105
- const diviswap = getDiviswap();
117
+ const diviswap = getDiviswap(data.customerId, data.customerEmail);
106
118
  const payee = await diviswap.payees.create({
107
119
  nickname: data.nickname,
108
120
  accountNumber: data.accountNumber,
@@ -121,9 +133,9 @@ export async function createPayeeAction(data: {
121
133
  }
122
134
  }
123
135
 
124
- export async function deletePayeeAction(payeeId: string) {
136
+ export async function deletePayeeAction(payeeId: string, customerId?: string, customerEmail?: string) {
125
137
  try {
126
- const diviswap = getDiviswap();
138
+ const diviswap = getDiviswap(customerId, customerEmail);
127
139
  await diviswap.payees.delete(payeeId);
128
140
 
129
141
  revalidatePath('/diviswap');
@@ -164,9 +176,9 @@ export async function getDepositAddressesAction() {
164
176
  }
165
177
 
166
178
  // Fee Calculation Actions
167
- export async function calculateFeesAction(amount: number) {
179
+ export async function calculateFeesAction(amount: number, customerId?: string, customerEmail?: string) {
168
180
  try {
169
- const diviswap = getDiviswap();
181
+ const diviswap = getDiviswap(customerId, customerEmail);
170
182
  const fees = await diviswap.fees.calculateFees({ amount });
171
183
  return { success: true, fees };
172
184
  } catch (error) {
@@ -179,6 +191,7 @@ export async function calculateFeesAction(amount: number) {
179
191
 
180
192
  export async function getIntegratorFeesAction() {
181
193
  try {
194
+ // Integrator fees are partner-wide, no customer context needed
182
195
  const diviswap = getDiviswap();
183
196
  const fees = await diviswap.fees.getFees();
184
197
 
@@ -196,6 +209,7 @@ export async function updateIntegratorFeeAction(data: {
196
209
  userId?: number;
197
210
  }) {
198
211
  try {
212
+ // Integrator fee updates are partner-wide, no customer context needed
199
213
  const diviswap = getDiviswap();
200
214
  const fee = await diviswap.fees.setFee(data);
201
215
 
@@ -210,9 +224,9 @@ export async function updateIntegratorFeeAction(data: {
210
224
  }
211
225
 
212
226
  // Authentication Server Actions (for server components that need auth status)
213
- export async function getCurrentUserAction() {
227
+ export async function getCurrentUserAction(customerId?: string, customerEmail?: string) {
214
228
  try {
215
- const diviswap = getDiviswap();
229
+ const diviswap = getDiviswap(customerId, customerEmail);
216
230
  const user = await diviswap.auth.getProfile();
217
231
 
218
232
  return { success: true, user };
@@ -140,12 +140,13 @@ export function DiviswapKYC({
140
140
  };
141
141
 
142
142
  // Call your KYC submission API
143
+ // Use submitKYC (not registerCustomer) since shadow user is already created by partner HMAC auth
143
144
  const response = await fetch('/api/diviswap', {
144
145
  method: 'POST',
145
146
  headers: { 'Content-Type': 'application/json' },
146
- body: JSON.stringify({
147
- action: 'registerCustomer',
148
- ...kycData
147
+ body: JSON.stringify({
148
+ action: 'submitKYC',
149
+ ...kycData
149
150
  }),
150
151
  });
151
152
 
package/dist/index.js CHANGED
@@ -1841,6 +1841,9 @@ var UnifiedApiClient = class _UnifiedApiClient {
1841
1841
  try {
1842
1842
  const controller = new AbortController();
1843
1843
  const timeoutId = setTimeout(() => controller.abort(), this.config.timeout);
1844
+ if (this.config.debug) {
1845
+ console.log(`[Diviswap SDK] ${method} ${url}`);
1846
+ }
1844
1847
  const response = await fetch(url, {
1845
1848
  method,
1846
1849
  headers: requestHeaders,
@@ -1855,6 +1858,9 @@ var UnifiedApiClient = class _UnifiedApiClient {
1855
1858
  } catch {
1856
1859
  responseData = responseText;
1857
1860
  }
1861
+ if (this.config.debug) {
1862
+ console.log(`[Diviswap SDK] Response ${response.status}: ${responseText.substring(0, 500)}`);
1863
+ }
1858
1864
  if (!response.ok) {
1859
1865
  await this.handleErrorResponse(response, responseData);
1860
1866
  }