@diviswap/sdk 1.8.1 → 1.9.1
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 +7 -3
- package/dist/cli/templates/nextjs-app/api-route.ts.hbs +8 -52
- package/dist/cli/templates/nextjs-app/types.ts.hbs +1 -1
- package/dist/index.d.mts +3 -4
- package/dist/index.d.ts +3 -4
- package/dist/index.js +42 -68
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +43 -68
- package/dist/index.mjs.map +1 -1
- package/dist/react/index.d.mts +1 -1
- package/dist/react/index.d.ts +1 -1
- package/dist/{wallet-Ca1U51kT.d.mts → wallet-yDJlJqCw.d.mts} +13 -25
- package/dist/{wallet-Ca1U51kT.d.ts → wallet-yDJlJqCw.d.ts} +13 -25
- package/package.json +1 -1
- package/src/cli/templates/nextjs-app/api-route.ts.hbs +8 -52
- package/src/cli/templates/nextjs-app/types.ts.hbs +1 -1
package/dist/index.mjs
CHANGED
|
@@ -246,12 +246,28 @@ var PayeesModule = class {
|
|
|
246
246
|
constructor(client) {
|
|
247
247
|
this.client = client;
|
|
248
248
|
}
|
|
249
|
+
/**
|
|
250
|
+
* Validate ABA routing number checksum
|
|
251
|
+
*/
|
|
252
|
+
validateRoutingNumber(routing) {
|
|
253
|
+
if (routing.length !== 9 || !/^\d{9}$/.test(routing)) {
|
|
254
|
+
return false;
|
|
255
|
+
}
|
|
256
|
+
const d = routing.split("").map(Number);
|
|
257
|
+
const checksum = 3 * (d[0] + d[3] + d[6]) + 7 * (d[1] + d[4] + d[7]) + 1 * (d[2] + d[5] + d[8]);
|
|
258
|
+
return checksum % 10 === 0;
|
|
259
|
+
}
|
|
260
|
+
/**
|
|
261
|
+
* Validate account number format
|
|
262
|
+
*/
|
|
263
|
+
validateAccountNumber(account) {
|
|
264
|
+
return /^\d{4,17}$/.test(account);
|
|
265
|
+
}
|
|
249
266
|
/**
|
|
250
267
|
* Create a new payee (bank account)
|
|
251
268
|
*
|
|
252
269
|
* @example
|
|
253
270
|
* ```typescript
|
|
254
|
-
* // Bank account
|
|
255
271
|
* const bankAccount = await diviswap.payees.create({
|
|
256
272
|
* nickname: 'My Checking',
|
|
257
273
|
* accountNumber: '123456789',
|
|
@@ -259,54 +275,32 @@ var PayeesModule = class {
|
|
|
259
275
|
* accountType: 'checking',
|
|
260
276
|
* setAsDefault: true
|
|
261
277
|
* });
|
|
262
|
-
*
|
|
263
|
-
* // Debit card
|
|
264
|
-
* const debitCard = await diviswap.payees.create({
|
|
265
|
-
* nickname: 'My Debit Card',
|
|
266
|
-
* accountType: 'debit_card',
|
|
267
|
-
* debitCard: {
|
|
268
|
-
* number: '4111111111111111',
|
|
269
|
-
* expirationMonth: '12',
|
|
270
|
-
* expirationYear: '2025',
|
|
271
|
-
* cvv: '123'
|
|
272
|
-
* },
|
|
273
|
-
* setAsDefault: false
|
|
274
|
-
* });
|
|
275
278
|
* ```
|
|
276
279
|
*/
|
|
277
280
|
async create(data) {
|
|
278
281
|
try {
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
debit_card: {
|
|
289
|
-
number: data.debitCard.number,
|
|
290
|
-
expiration_month: data.debitCard.expirationMonth,
|
|
291
|
-
expiration_year: data.debitCard.expirationYear,
|
|
292
|
-
cvv: data.debitCard.cvv
|
|
293
|
-
},
|
|
294
|
-
set_as_default: data.setAsDefault || false
|
|
295
|
-
});
|
|
296
|
-
} else {
|
|
297
|
-
if (!data.accountNumber || !data.routingNumber) {
|
|
298
|
-
throw new Error(
|
|
299
|
-
"Account number and routing number are required for bank accounts"
|
|
300
|
-
);
|
|
301
|
-
}
|
|
302
|
-
response = await this.client.post("/api/v1/payees", {
|
|
303
|
-
name: data.nickname,
|
|
304
|
-
account_number: data.accountNumber,
|
|
305
|
-
routing_number: data.routingNumber,
|
|
306
|
-
type: (data.accountType || "checking").toUpperCase(),
|
|
307
|
-
set_as_default: data.setAsDefault || false
|
|
308
|
-
});
|
|
282
|
+
if (!data.accountNumber || !data.routingNumber) {
|
|
283
|
+
throw new Error(
|
|
284
|
+
"Account number and routing number are required for bank accounts"
|
|
285
|
+
);
|
|
286
|
+
}
|
|
287
|
+
if (!this.validateRoutingNumber(data.routingNumber)) {
|
|
288
|
+
throw new Error(
|
|
289
|
+
"Invalid routing number. Please provide a valid 9-digit ABA routing number."
|
|
290
|
+
);
|
|
309
291
|
}
|
|
292
|
+
if (!this.validateAccountNumber(data.accountNumber)) {
|
|
293
|
+
throw new Error(
|
|
294
|
+
"Invalid account number. Must be 4-17 digits with no letters or special characters."
|
|
295
|
+
);
|
|
296
|
+
}
|
|
297
|
+
const response = await this.client.post("/api/v1/payees", {
|
|
298
|
+
name: data.nickname,
|
|
299
|
+
account_number: data.accountNumber,
|
|
300
|
+
routing_number: data.routingNumber,
|
|
301
|
+
type: (data.accountType || "checking").toUpperCase(),
|
|
302
|
+
set_as_default: data.setAsDefault || false
|
|
303
|
+
});
|
|
310
304
|
return this.transformPayee(response);
|
|
311
305
|
} catch (error) {
|
|
312
306
|
throw new Error(`Failed to create payee: ${error.message}`);
|
|
@@ -465,21 +459,12 @@ var SANDBOX_DEPOSIT_ADDRESSES = {
|
|
|
465
459
|
polygon: "0xa3da8ffC1D131F917f9D0Ac078D82914e75d9651",
|
|
466
460
|
solana: "EokHeEoZpGtBNeuJKRPvtxzXqaXz6bM5zsVB5TVPtNee"
|
|
467
461
|
};
|
|
468
|
-
var DEVELOPMENT_DEPOSIT_ADDRESSES = {
|
|
469
|
-
ethereum: "0xa3da8ffC1D131F917f9D0Ac078D82914e75d9651",
|
|
470
|
-
// Same unified address
|
|
471
|
-
base: "0xa3da8ffC1D131F917f9D0Ac078D82914e75d9651",
|
|
472
|
-
polygon: "0xa3da8ffC1D131F917f9D0Ac078D82914e75d9651",
|
|
473
|
-
solana: "EokHeEoZpGtBNeuJKRPvtxzXqaXz6bM5zsVB5TVPtNee"
|
|
474
|
-
};
|
|
475
462
|
function getDepositAddresses(environment) {
|
|
476
463
|
switch (environment) {
|
|
477
464
|
case "production":
|
|
478
465
|
return PRODUCTION_DEPOSIT_ADDRESSES;
|
|
479
466
|
case "sandbox":
|
|
480
467
|
return SANDBOX_DEPOSIT_ADDRESSES;
|
|
481
|
-
case "development":
|
|
482
|
-
return DEVELOPMENT_DEPOSIT_ADDRESSES;
|
|
483
468
|
default:
|
|
484
469
|
return SANDBOX_DEPOSIT_ADDRESSES;
|
|
485
470
|
}
|
|
@@ -1829,16 +1814,8 @@ var UnifiedApiClient = class _UnifiedApiClient {
|
|
|
1829
1814
|
);
|
|
1830
1815
|
}
|
|
1831
1816
|
}
|
|
1832
|
-
static getDefaultApiUrl(
|
|
1833
|
-
|
|
1834
|
-
case "production":
|
|
1835
|
-
case "sandbox":
|
|
1836
|
-
return "https://api.diviswap.com";
|
|
1837
|
-
case "development":
|
|
1838
|
-
return "https://dev-api.diviswap.com";
|
|
1839
|
-
default:
|
|
1840
|
-
return "https://api.diviswap.com";
|
|
1841
|
-
}
|
|
1817
|
+
static getDefaultApiUrl(_environment) {
|
|
1818
|
+
return "https://api.diviswap.com";
|
|
1842
1819
|
}
|
|
1843
1820
|
/**
|
|
1844
1821
|
* Update customer context for partner auth
|
|
@@ -2220,11 +2197,9 @@ var _Diviswap = class _Diviswap {
|
|
|
2220
2197
|
);
|
|
2221
2198
|
}
|
|
2222
2199
|
}
|
|
2223
|
-
if (config.environment && !["production", "sandbox"
|
|
2224
|
-
config.environment
|
|
2225
|
-
)) {
|
|
2200
|
+
if (config.environment && !["production", "sandbox"].includes(config.environment)) {
|
|
2226
2201
|
throw new ConfigurationError(
|
|
2227
|
-
"Invalid environment. Must be one of: production, sandbox
|
|
2202
|
+
"Invalid environment. Must be one of: production, sandbox"
|
|
2228
2203
|
);
|
|
2229
2204
|
}
|
|
2230
2205
|
}
|
|
@@ -2453,6 +2428,6 @@ function extractTransactionHash(result) {
|
|
|
2453
2428
|
return result;
|
|
2454
2429
|
}
|
|
2455
2430
|
|
|
2456
|
-
export { AuthenticationError, CHAIN_IDS, CHAIN_ID_TO_NAME, CHAIN_NAME_TO_ID, ConfigurationError,
|
|
2431
|
+
export { AuthenticationError, CHAIN_IDS, CHAIN_ID_TO_NAME, CHAIN_NAME_TO_ID, ConfigurationError, Diviswap, DiviswapError, Diviswap as LiberEx, LiberExError, NetworkError, PRODUCTION_DEPOSIT_ADDRESSES, SANDBOX_DEPOSIT_ADDRESSES, STABLECOIN_ADDRESSES, ValidationError, WalletTracker, connectWallet, extractTransactionHash, getDepositAddresses, setupWalletTracking, trackCurrentWallet };
|
|
2457
2432
|
//# sourceMappingURL=index.mjs.map
|
|
2458
2433
|
//# sourceMappingURL=index.mjs.map
|