@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.
@@ -1,5 +1,5 @@
1
1
  import React, { ReactNode } from 'react';
2
- import { U as User, T as Transaction, P as Payee, D as Diviswap, d as Address, e as CreateAddressRequest, g as ChainName, l as WalletTrackingConfig, W as WalletConnection, k as EthereumWallet, i as WalletTracker } from '../wallet-Ca1U51kT.mjs';
2
+ import { U as User, T as Transaction, P as Payee, D as Diviswap, d as Address, e as CreateAddressRequest, g as ChainName, l as WalletTrackingConfig, W as WalletConnection, k as EthereumWallet, i as WalletTracker } from '../wallet-yDJlJqCw.mjs';
3
3
 
4
4
  interface DiviswapContextValue {
5
5
  user: User | null;
@@ -1,5 +1,5 @@
1
1
  import React, { ReactNode } from 'react';
2
- import { U as User, T as Transaction, P as Payee, D as Diviswap, d as Address, e as CreateAddressRequest, g as ChainName, l as WalletTrackingConfig, W as WalletConnection, k as EthereumWallet, i as WalletTracker } from '../wallet-Ca1U51kT.js';
2
+ import { U as User, T as Transaction, P as Payee, D as Diviswap, d as Address, e as CreateAddressRequest, g as ChainName, l as WalletTrackingConfig, W as WalletConnection, k as EthereumWallet, i as WalletTracker } from '../wallet-yDJlJqCw.js';
3
3
 
4
4
  interface DiviswapContextValue {
5
5
  user: User | null;
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Core type definitions for Diviswap SDK
3
3
  */
4
- type Environment = 'production' | 'sandbox' | 'development';
4
+ type Environment = 'production' | 'sandbox';
5
5
  type AuthMode = 'user' | 'partner';
6
6
  interface BaseDiviswapConfig {
7
7
  /** Environment to use (defaults to 'production') */
@@ -124,16 +124,10 @@ interface Payee {
124
124
  }
125
125
  interface CreatePayeeRequest {
126
126
  nickname: string;
127
- accountNumber?: string;
128
- routingNumber?: string;
129
- accountType: 'checking' | 'savings' | 'debit_card';
127
+ accountNumber: string;
128
+ routingNumber: string;
129
+ accountType: 'checking' | 'savings';
130
130
  setAsDefault?: boolean;
131
- debitCard?: {
132
- number: string;
133
- expirationMonth: string;
134
- expirationYear: string;
135
- cvv: string;
136
- };
137
131
  }
138
132
  interface Transaction {
139
133
  id: string;
@@ -505,12 +499,19 @@ interface VerifyPayeeRequest {
505
499
  declare class PayeesModule {
506
500
  private client;
507
501
  constructor(client: UnifiedApiClient);
502
+ /**
503
+ * Validate ABA routing number checksum
504
+ */
505
+ private validateRoutingNumber;
506
+ /**
507
+ * Validate account number format
508
+ */
509
+ private validateAccountNumber;
508
510
  /**
509
511
  * Create a new payee (bank account)
510
512
  *
511
513
  * @example
512
514
  * ```typescript
513
- * // Bank account
514
515
  * const bankAccount = await diviswap.payees.create({
515
516
  * nickname: 'My Checking',
516
517
  * accountNumber: '123456789',
@@ -518,19 +519,6 @@ declare class PayeesModule {
518
519
  * accountType: 'checking',
519
520
  * setAsDefault: true
520
521
  * });
521
- *
522
- * // Debit card
523
- * const debitCard = await diviswap.payees.create({
524
- * nickname: 'My Debit Card',
525
- * accountType: 'debit_card',
526
- * debitCard: {
527
- * number: '4111111111111111',
528
- * expirationMonth: '12',
529
- * expirationYear: '2025',
530
- * cvv: '123'
531
- * },
532
- * setAsDefault: false
533
- * });
534
522
  * ```
535
523
  */
536
524
  create(data: CreatePayeeRequest): Promise<Payee>;
@@ -630,7 +618,7 @@ interface FeeEstimate {
630
618
  declare class TransactionsModule {
631
619
  private client;
632
620
  private depositAddresses;
633
- constructor(client: UnifiedApiClient, environment?: 'production' | 'sandbox' | 'development');
621
+ constructor(client: UnifiedApiClient, environment?: 'production' | 'sandbox');
634
622
  /**
635
623
  * Map chain name to chain ID
636
624
  * @private
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Core type definitions for Diviswap SDK
3
3
  */
4
- type Environment = 'production' | 'sandbox' | 'development';
4
+ type Environment = 'production' | 'sandbox';
5
5
  type AuthMode = 'user' | 'partner';
6
6
  interface BaseDiviswapConfig {
7
7
  /** Environment to use (defaults to 'production') */
@@ -124,16 +124,10 @@ interface Payee {
124
124
  }
125
125
  interface CreatePayeeRequest {
126
126
  nickname: string;
127
- accountNumber?: string;
128
- routingNumber?: string;
129
- accountType: 'checking' | 'savings' | 'debit_card';
127
+ accountNumber: string;
128
+ routingNumber: string;
129
+ accountType: 'checking' | 'savings';
130
130
  setAsDefault?: boolean;
131
- debitCard?: {
132
- number: string;
133
- expirationMonth: string;
134
- expirationYear: string;
135
- cvv: string;
136
- };
137
131
  }
138
132
  interface Transaction {
139
133
  id: string;
@@ -505,12 +499,19 @@ interface VerifyPayeeRequest {
505
499
  declare class PayeesModule {
506
500
  private client;
507
501
  constructor(client: UnifiedApiClient);
502
+ /**
503
+ * Validate ABA routing number checksum
504
+ */
505
+ private validateRoutingNumber;
506
+ /**
507
+ * Validate account number format
508
+ */
509
+ private validateAccountNumber;
508
510
  /**
509
511
  * Create a new payee (bank account)
510
512
  *
511
513
  * @example
512
514
  * ```typescript
513
- * // Bank account
514
515
  * const bankAccount = await diviswap.payees.create({
515
516
  * nickname: 'My Checking',
516
517
  * accountNumber: '123456789',
@@ -518,19 +519,6 @@ declare class PayeesModule {
518
519
  * accountType: 'checking',
519
520
  * setAsDefault: true
520
521
  * });
521
- *
522
- * // Debit card
523
- * const debitCard = await diviswap.payees.create({
524
- * nickname: 'My Debit Card',
525
- * accountType: 'debit_card',
526
- * debitCard: {
527
- * number: '4111111111111111',
528
- * expirationMonth: '12',
529
- * expirationYear: '2025',
530
- * cvv: '123'
531
- * },
532
- * setAsDefault: false
533
- * });
534
522
  * ```
535
523
  */
536
524
  create(data: CreatePayeeRequest): Promise<Payee>;
@@ -630,7 +618,7 @@ interface FeeEstimate {
630
618
  declare class TransactionsModule {
631
619
  private client;
632
620
  private depositAddresses;
633
- constructor(client: UnifiedApiClient, environment?: 'production' | 'sandbox' | 'development');
621
+ constructor(client: UnifiedApiClient, environment?: 'production' | 'sandbox');
634
622
  /**
635
623
  * Map chain name to chain ID
636
624
  * @private
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@diviswap/sdk",
3
- "version": "1.8.1",
3
+ "version": "1.9.1",
4
4
  "description": "Official Diviswap SDK - Crypto rails made simple",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -133,58 +133,14 @@ const postHandlers: Record<string, ActionHandler> = {
133
133
  // Set customer context before API calls
134
134
  setCustomerContext(diviswap, params);
135
135
 
136
-
137
- // Check if the SDK is sending structured debit card data
138
- if (params.debitCard) {
139
- // New SDK structure - debitCard object is already properly formatted
140
- const debitCardPayload = {
141
- nickname: params.nickname,
142
- accountType: 'debit_card' as const,
143
- debitCard: params.debitCard,
144
- setAsDefault: params.setAsDefault || false
145
- };
146
-
147
- const payee = await diviswap.payees.create(debitCardPayload);
148
- return NextResponse.json(payee);
149
- }
150
- // Handle legacy flat structure for debit cards
151
- else if (params.accountType === 'debit_card' || params.payeeType === 'debit') {
152
- // Parse expiry date if needed
153
- let expirationMonth = params.expirationMonth;
154
- let expirationYear = params.expirationYear;
155
-
156
- // If expiry is in MM/YY format in routingNumber field
157
- if (params.routingNumber && params.routingNumber.includes('/')) {
158
- const expiryParts = params.routingNumber.split('/');
159
- expirationMonth = expiryParts[0];
160
- expirationYear = expiryParts[1] ? `20${expiryParts[1]}` : '2025';
161
- }
162
-
163
- const debitCardPayload = {
164
- nickname: params.nickname,
165
- accountType: 'debit_card' as const,
166
- debitCard: {
167
- number: params.accountNumber?.replace(/\s+/g, '') || '', // Remove spaces
168
- expirationMonth: expirationMonth || '12',
169
- expirationYear: expirationYear || '2025',
170
- cvv: params.cvv || '123'
171
- },
172
- setAsDefault: params.setAsDefault || false
173
- };
174
-
175
- const payee = await diviswap.payees.create(debitCardPayload);
176
- return NextResponse.json(payee);
177
- } else {
178
- // Bank account structure
179
- const payee = await diviswap.payees.create({
180
- nickname: params.nickname,
181
- accountNumber: params.accountNumber,
182
- routingNumber: params.routingNumber,
183
- accountType: params.accountType || 'checking',
184
- setAsDefault: params.setAsDefault || false
185
- });
186
- return NextResponse.json(payee);
187
- }
136
+ const payee = await diviswap.payees.create({
137
+ nickname: params.nickname,
138
+ accountNumber: params.accountNumber,
139
+ routingNumber: params.routingNumber,
140
+ accountType: params.accountType || 'checking',
141
+ setAsDefault: params.setAsDefault || false
142
+ });
143
+ return NextResponse.json(payee);
188
144
  },
189
145
 
190
146
  {{#if (includes features "fees")}}
@@ -49,7 +49,7 @@ export interface TransactionFees {
49
49
 
50
50
  export interface PaymentMethod {
51
51
  id: string;
52
- type: 'bank_account' | 'debit_card' | 'credit_card' | 'wire_transfer';
52
+ type: 'bank_account' | 'wire_transfer';
53
53
  last4?: string;
54
54
  bankName?: string;
55
55
  isDefault?: boolean;