@chipi-stack/backend 11.4.0 → 11.6.0

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/index.d.mts CHANGED
@@ -1,4 +1,5 @@
1
- import { ChipiSDKConfig, ExecuteTransactionParams, TransferParams, ApproveParams, StakeVesuUsdcParams, WithdrawVesuUsdcParams, CallAnyContractParams, CreateWalletParams, CreateWalletResponse, RecordSendTransactionParams, Transaction, GetWalletParams, WalletData, GetTokenBalanceParams, GetTokenBalanceResponse } from '@chipi-stack/types';
1
+ import * as _chipi_stack_types from '@chipi-stack/types';
2
+ import { ChipiSDKConfig, ExecuteTransactionParams, TransferParams, ApproveParams, StakeVesuUsdcParams, WithdrawVesuUsdcParams, CallAnyContractParams, CreateWalletParams, CreateWalletResponse, RecordSendTransactionParams, Transaction, GetWalletParams, GetTokenBalanceParams, GetTokenBalanceResponse, ChipiServerSDKConfig, ChipiBrowserSDKConfig } from '@chipi-stack/types';
2
3
  export * from '@chipi-stack/types';
3
4
  import { ChipiWallets } from './wallets.mjs';
4
5
  import { ChipiTransactions } from './transactions.mjs';
@@ -11,65 +12,148 @@ export { C as ChipiClient } from './client-D4ZnPqgQ.mjs';
11
12
  declare class ChipiSDK {
12
13
  private client;
13
14
  private nodeUrl;
15
+ private apiSecretKey?;
14
16
  readonly wallets: ChipiWallets;
15
17
  readonly transactions: ChipiTransactions;
16
18
  readonly skus: ChipiSkus;
17
19
  constructor(config: ChipiSDKConfig);
20
+ /**
21
+ * Resolve bearer token - uses provided token or falls back to apiSecretKey
22
+ */
23
+ private resolveBearerToken;
18
24
  /**
19
25
  * Execute a gasless transaction
20
26
  */
21
- executeTransaction(params: Omit<ExecuteTransactionParams, "apiPublicKey" | "backendUrl">): Promise<string>;
27
+ executeTransaction({ params, bearerToken, }: {
28
+ params: ExecuteTransactionParams;
29
+ bearerToken?: string;
30
+ }): Promise<string>;
22
31
  /**
23
32
  * Transfer tokens
24
33
  */
25
34
  transfer({ params, bearerToken, }: {
26
35
  params: TransferParams;
27
- bearerToken: string;
36
+ bearerToken?: string;
28
37
  }): Promise<string>;
29
38
  /**
30
39
  * Approve token spending
31
40
  */
32
41
  approve({ params, bearerToken, }: {
33
42
  params: ApproveParams;
34
- bearerToken: string;
43
+ bearerToken?: string;
35
44
  }): Promise<string>;
36
45
  /**
37
46
  * Stake USDC in Vesu protocol
38
47
  */
39
48
  stakeVesuUsdc({ params, bearerToken, }: {
40
49
  params: StakeVesuUsdcParams;
41
- bearerToken: string;
50
+ bearerToken?: string;
42
51
  }): Promise<string>;
43
52
  /**
44
53
  * Withdraw USDC from Vesu protocol
45
54
  */
46
55
  withdrawVesuUsdc({ params, bearerToken, }: {
47
56
  params: WithdrawVesuUsdcParams;
48
- bearerToken: string;
57
+ bearerToken?: string;
49
58
  }): Promise<string>;
50
59
  /**
51
60
  * Call any contract method
52
61
  */
53
62
  callAnyContract({ params, bearerToken, }: {
54
63
  params: CallAnyContractParams;
55
- bearerToken: string;
64
+ bearerToken?: string;
56
65
  }): Promise<string>;
57
66
  /**
58
67
  * Create a new wallet
59
68
  */
60
69
  createWallet({ params, bearerToken, }: {
61
70
  params: CreateWalletParams;
62
- bearerToken: string;
71
+ bearerToken?: string;
63
72
  }): Promise<CreateWalletResponse>;
64
73
  recordSendTransaction({ params, bearerToken, }: {
65
74
  params: RecordSendTransactionParams;
66
- bearerToken: string;
75
+ bearerToken?: string;
67
76
  }): Promise<Transaction>;
68
- getWallet(params: GetWalletParams, bearerToken: string): Promise<WalletData>;
69
- getTokenBalance(params: GetTokenBalanceParams, bearerToken: string): Promise<GetTokenBalanceResponse>;
77
+ getWallet(params: GetWalletParams, bearerToken?: string): Promise<(_chipi_stack_types.GetWalletResponse & {
78
+ normalizedPublicKey: string;
79
+ }) | null>;
80
+ getTokenBalance(params: GetTokenBalanceParams, bearerToken?: string): Promise<GetTokenBalanceResponse>;
81
+ }
82
+
83
+ /**
84
+ * Server-side Chipi SDK with built-in API Secret Key authentication
85
+ *
86
+ * This class is designed for server-side environments where you can safely store
87
+ * the API Secret Key. All methods automatically use the secret key for authentication,
88
+ * so you don't need to pass a bearer token with each call.
89
+ *
90
+ * The apiSecretKey is stored internally and used automatically for all authenticated requests.
91
+ * All methods from ChipiSDK are inherited and work without requiring a bearerToken parameter.
92
+ *
93
+ * @example
94
+ * ```typescript
95
+ * const chipiServer = new ChipiServerSDK({
96
+ * apiPublicKey: "pk_...",
97
+ * apiSecretKey: "sk_...",
98
+ * environment: "production"
99
+ * });
100
+ *
101
+ * // No bearer token needed - automatically uses apiSecretKey!
102
+ * const wallet = await chipiServer.createWallet({
103
+ * params: {
104
+ * encryptKey: "user-encryption-key",
105
+ * externalUserId: "user-123"
106
+ * }
107
+ * });
108
+ *
109
+ * const userWallet = await chipiServer.getWallet({ externalUserId: "user-123" });
110
+ * const txHash = await chipiServer.transfer({ params: { ... } });
111
+ * ```
112
+ */
113
+ declare class ChipiServerSDK extends ChipiSDK {
114
+ constructor(config: ChipiServerSDKConfig);
115
+ }
116
+
117
+ /**
118
+ * Browser-side Chipi SDK for client-side applications
119
+ *
120
+ * This class is designed for browser environments (Vue, Svelte, Angular, vanilla JS, etc.)
121
+ * where you need to pass a bearer token (JWT) with each authenticated request.
122
+ *
123
+ * All methods require a bearerToken parameter since browser environments should not
124
+ * store API Secret Keys.
125
+ *
126
+ * ⚠️ SECURITY WARNING: DO NOT use your API Secret Key in browser environments!
127
+ * The secret key should only be used server-side with ChipiServerSDK.
128
+ *
129
+ * @example
130
+ * ```typescript
131
+ * const chipiBrowser = new ChipiBrowserSDK({
132
+ * apiPublicKey: "pk_...",
133
+ * environment: "production"
134
+ * });
135
+ *
136
+ * // Get user's JWT token from your auth system
137
+ * const userToken = await getUserJWT();
138
+ *
139
+ * // Pass bearer token with each call
140
+ * const wallet = await chipiBrowser.createWallet({
141
+ * params: {
142
+ * encryptKey: "user-encryption-key",
143
+ * externalUserId: "user-123"
144
+ * },
145
+ * bearerToken: userToken
146
+ * });
147
+ *
148
+ * const userWallet = await chipiBrowser.getWallet({ externalUserId: "user-123" }, userToken);
149
+ * const txHash = await chipiBrowser.transfer({ params: {...}, bearerToken: userToken });
150
+ * ```
151
+ */
152
+ declare class ChipiBrowserSDK extends ChipiSDK {
153
+ constructor(config: ChipiBrowserSDKConfig);
70
154
  }
71
155
 
72
156
  declare const encryptPrivateKey: (privateKey: string, password: string) => string;
73
157
  declare const decryptPrivateKey: (encryptedPrivateKey: string, password: string) => string;
74
158
 
75
- export { ChipiSDK, ChipiSkus, ChipiTransactions, ChipiWallets, decryptPrivateKey, encryptPrivateKey };
159
+ export { ChipiBrowserSDK, ChipiSDK, ChipiServerSDK, ChipiSkus, ChipiTransactions, ChipiWallets, decryptPrivateKey, encryptPrivateKey };
package/dist/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
- import { ChipiSDKConfig, ExecuteTransactionParams, TransferParams, ApproveParams, StakeVesuUsdcParams, WithdrawVesuUsdcParams, CallAnyContractParams, CreateWalletParams, CreateWalletResponse, RecordSendTransactionParams, Transaction, GetWalletParams, WalletData, GetTokenBalanceParams, GetTokenBalanceResponse } from '@chipi-stack/types';
1
+ import * as _chipi_stack_types from '@chipi-stack/types';
2
+ import { ChipiSDKConfig, ExecuteTransactionParams, TransferParams, ApproveParams, StakeVesuUsdcParams, WithdrawVesuUsdcParams, CallAnyContractParams, CreateWalletParams, CreateWalletResponse, RecordSendTransactionParams, Transaction, GetWalletParams, GetTokenBalanceParams, GetTokenBalanceResponse, ChipiServerSDKConfig, ChipiBrowserSDKConfig } from '@chipi-stack/types';
2
3
  export * from '@chipi-stack/types';
3
4
  import { ChipiWallets } from './wallets.js';
4
5
  import { ChipiTransactions } from './transactions.js';
@@ -11,65 +12,148 @@ export { C as ChipiClient } from './client-D4ZnPqgQ.js';
11
12
  declare class ChipiSDK {
12
13
  private client;
13
14
  private nodeUrl;
15
+ private apiSecretKey?;
14
16
  readonly wallets: ChipiWallets;
15
17
  readonly transactions: ChipiTransactions;
16
18
  readonly skus: ChipiSkus;
17
19
  constructor(config: ChipiSDKConfig);
20
+ /**
21
+ * Resolve bearer token - uses provided token or falls back to apiSecretKey
22
+ */
23
+ private resolveBearerToken;
18
24
  /**
19
25
  * Execute a gasless transaction
20
26
  */
21
- executeTransaction(params: Omit<ExecuteTransactionParams, "apiPublicKey" | "backendUrl">): Promise<string>;
27
+ executeTransaction({ params, bearerToken, }: {
28
+ params: ExecuteTransactionParams;
29
+ bearerToken?: string;
30
+ }): Promise<string>;
22
31
  /**
23
32
  * Transfer tokens
24
33
  */
25
34
  transfer({ params, bearerToken, }: {
26
35
  params: TransferParams;
27
- bearerToken: string;
36
+ bearerToken?: string;
28
37
  }): Promise<string>;
29
38
  /**
30
39
  * Approve token spending
31
40
  */
32
41
  approve({ params, bearerToken, }: {
33
42
  params: ApproveParams;
34
- bearerToken: string;
43
+ bearerToken?: string;
35
44
  }): Promise<string>;
36
45
  /**
37
46
  * Stake USDC in Vesu protocol
38
47
  */
39
48
  stakeVesuUsdc({ params, bearerToken, }: {
40
49
  params: StakeVesuUsdcParams;
41
- bearerToken: string;
50
+ bearerToken?: string;
42
51
  }): Promise<string>;
43
52
  /**
44
53
  * Withdraw USDC from Vesu protocol
45
54
  */
46
55
  withdrawVesuUsdc({ params, bearerToken, }: {
47
56
  params: WithdrawVesuUsdcParams;
48
- bearerToken: string;
57
+ bearerToken?: string;
49
58
  }): Promise<string>;
50
59
  /**
51
60
  * Call any contract method
52
61
  */
53
62
  callAnyContract({ params, bearerToken, }: {
54
63
  params: CallAnyContractParams;
55
- bearerToken: string;
64
+ bearerToken?: string;
56
65
  }): Promise<string>;
57
66
  /**
58
67
  * Create a new wallet
59
68
  */
60
69
  createWallet({ params, bearerToken, }: {
61
70
  params: CreateWalletParams;
62
- bearerToken: string;
71
+ bearerToken?: string;
63
72
  }): Promise<CreateWalletResponse>;
64
73
  recordSendTransaction({ params, bearerToken, }: {
65
74
  params: RecordSendTransactionParams;
66
- bearerToken: string;
75
+ bearerToken?: string;
67
76
  }): Promise<Transaction>;
68
- getWallet(params: GetWalletParams, bearerToken: string): Promise<WalletData>;
69
- getTokenBalance(params: GetTokenBalanceParams, bearerToken: string): Promise<GetTokenBalanceResponse>;
77
+ getWallet(params: GetWalletParams, bearerToken?: string): Promise<(_chipi_stack_types.GetWalletResponse & {
78
+ normalizedPublicKey: string;
79
+ }) | null>;
80
+ getTokenBalance(params: GetTokenBalanceParams, bearerToken?: string): Promise<GetTokenBalanceResponse>;
81
+ }
82
+
83
+ /**
84
+ * Server-side Chipi SDK with built-in API Secret Key authentication
85
+ *
86
+ * This class is designed for server-side environments where you can safely store
87
+ * the API Secret Key. All methods automatically use the secret key for authentication,
88
+ * so you don't need to pass a bearer token with each call.
89
+ *
90
+ * The apiSecretKey is stored internally and used automatically for all authenticated requests.
91
+ * All methods from ChipiSDK are inherited and work without requiring a bearerToken parameter.
92
+ *
93
+ * @example
94
+ * ```typescript
95
+ * const chipiServer = new ChipiServerSDK({
96
+ * apiPublicKey: "pk_...",
97
+ * apiSecretKey: "sk_...",
98
+ * environment: "production"
99
+ * });
100
+ *
101
+ * // No bearer token needed - automatically uses apiSecretKey!
102
+ * const wallet = await chipiServer.createWallet({
103
+ * params: {
104
+ * encryptKey: "user-encryption-key",
105
+ * externalUserId: "user-123"
106
+ * }
107
+ * });
108
+ *
109
+ * const userWallet = await chipiServer.getWallet({ externalUserId: "user-123" });
110
+ * const txHash = await chipiServer.transfer({ params: { ... } });
111
+ * ```
112
+ */
113
+ declare class ChipiServerSDK extends ChipiSDK {
114
+ constructor(config: ChipiServerSDKConfig);
115
+ }
116
+
117
+ /**
118
+ * Browser-side Chipi SDK for client-side applications
119
+ *
120
+ * This class is designed for browser environments (Vue, Svelte, Angular, vanilla JS, etc.)
121
+ * where you need to pass a bearer token (JWT) with each authenticated request.
122
+ *
123
+ * All methods require a bearerToken parameter since browser environments should not
124
+ * store API Secret Keys.
125
+ *
126
+ * ⚠️ SECURITY WARNING: DO NOT use your API Secret Key in browser environments!
127
+ * The secret key should only be used server-side with ChipiServerSDK.
128
+ *
129
+ * @example
130
+ * ```typescript
131
+ * const chipiBrowser = new ChipiBrowserSDK({
132
+ * apiPublicKey: "pk_...",
133
+ * environment: "production"
134
+ * });
135
+ *
136
+ * // Get user's JWT token from your auth system
137
+ * const userToken = await getUserJWT();
138
+ *
139
+ * // Pass bearer token with each call
140
+ * const wallet = await chipiBrowser.createWallet({
141
+ * params: {
142
+ * encryptKey: "user-encryption-key",
143
+ * externalUserId: "user-123"
144
+ * },
145
+ * bearerToken: userToken
146
+ * });
147
+ *
148
+ * const userWallet = await chipiBrowser.getWallet({ externalUserId: "user-123" }, userToken);
149
+ * const txHash = await chipiBrowser.transfer({ params: {...}, bearerToken: userToken });
150
+ * ```
151
+ */
152
+ declare class ChipiBrowserSDK extends ChipiSDK {
153
+ constructor(config: ChipiBrowserSDKConfig);
70
154
  }
71
155
 
72
156
  declare const encryptPrivateKey: (privateKey: string, password: string) => string;
73
157
  declare const decryptPrivateKey: (encryptedPrivateKey: string, password: string) => string;
74
158
 
75
- export { ChipiSDK, ChipiSkus, ChipiTransactions, ChipiWallets, decryptPrivateKey, encryptPrivateKey };
159
+ export { ChipiBrowserSDK, ChipiSDK, ChipiServerSDK, ChipiSkus, ChipiTransactions, ChipiWallets, decryptPrivateKey, encryptPrivateKey };
package/dist/index.js CHANGED
@@ -279,6 +279,9 @@ var ChipiWallets = class {
279
279
  });
280
280
  return getWalletResponse;
281
281
  } catch (err) {
282
+ if (err instanceof shared.ChipiApiError && err.status === 404) {
283
+ return null;
284
+ }
282
285
  throw new Error(`getWallet error: ${String(err)}`);
283
286
  }
284
287
  }
@@ -294,9 +297,14 @@ var ChipiWallets = class {
294
297
  return getBalanceResponse;
295
298
  }
296
299
  };
297
- var executePaymasterTransaction = async (params) => {
300
+ var executePaymasterTransaction = async ({
301
+ params,
302
+ bearerToken,
303
+ apiPublicKey,
304
+ backendUrl
305
+ }) => {
298
306
  try {
299
- const { encryptKey, wallet, calls, apiPublicKey, bearerToken, backendUrl } = params;
307
+ const { encryptKey, wallet, calls } = params;
300
308
  const privateKeyDecrypted = decryptPrivateKey(
301
309
  wallet.encryptedPrivateKey,
302
310
  encryptKey
@@ -377,9 +385,13 @@ var ChipiTransactions = class {
377
385
  /**
378
386
  * Execute a gasless transaction using paymaster
379
387
  */
380
- async executeTransaction(params) {
388
+ async executeTransaction({
389
+ params,
390
+ bearerToken
391
+ }) {
381
392
  return executePaymasterTransaction({
382
- ...params,
393
+ params,
394
+ bearerToken,
383
395
  backendUrl: this.client.baseUrl,
384
396
  apiPublicKey: this.client.getApiPublicKey()
385
397
  });
@@ -404,16 +416,18 @@ var ChipiTransactions = class {
404
416
  }
405
417
  const formattedAmount = shared.formatAmount(amount, decimals);
406
418
  return this.executeTransaction({
407
- encryptKey,
408
- wallet,
409
- bearerToken,
410
- calls: [
411
- {
412
- contractAddress,
413
- entrypoint: "transfer",
414
- calldata: [recipient, formattedAmount, "0x0"]
415
- }
416
- ]
419
+ params: {
420
+ encryptKey,
421
+ wallet,
422
+ calls: [
423
+ {
424
+ contractAddress,
425
+ entrypoint: "transfer",
426
+ calldata: [recipient, formattedAmount, "0x0"]
427
+ }
428
+ ]
429
+ },
430
+ bearerToken
417
431
  });
418
432
  }
419
433
  /**
@@ -422,27 +436,36 @@ var ChipiTransactions = class {
422
436
  async approve(params) {
423
437
  const formattedAmount = shared.formatAmount(params.amount, params.decimals);
424
438
  return this.executeTransaction({
425
- encryptKey: params.encryptKey,
426
- wallet: params.wallet,
427
- bearerToken: params.bearerToken,
428
- calls: [
429
- {
430
- contractAddress: params.contractAddress,
431
- entrypoint: "approve",
432
- calldata: [params.spender, formattedAmount, "0x0"]
433
- }
434
- ]
439
+ params: {
440
+ encryptKey: params.encryptKey,
441
+ wallet: params.wallet,
442
+ calls: [
443
+ {
444
+ contractAddress: params.contractAddress,
445
+ entrypoint: "approve",
446
+ calldata: [params.spender, formattedAmount, "0x0"]
447
+ }
448
+ ]
449
+ },
450
+ bearerToken: params.bearerToken
435
451
  });
436
452
  }
437
453
  /**
438
454
  * Call any contract method
439
455
  */
440
- async callAnyContract(params) {
456
+ // {
457
+ // encryptKey: string;
458
+ // wallet: any;
459
+ // calls: any[];
460
+ // bearerToken: string;
461
+ // }
462
+ async callAnyContract({
463
+ params,
464
+ bearerToken
465
+ }) {
441
466
  return this.executeTransaction({
442
- encryptKey: params.encryptKey,
443
- wallet: params.wallet,
444
- bearerToken: params.bearerToken,
445
- calls: params.calls
467
+ params,
468
+ bearerToken
446
469
  });
447
470
  }
448
471
  /**
@@ -473,6 +496,7 @@ var ChipiSDK = class {
473
496
  constructor(config) {
474
497
  this.client = new ChipiClient(config);
475
498
  this.nodeUrl = config.nodeUrl || shared.STARKNET_NETWORKS.MAINNET;
499
+ this.apiSecretKey = config.apiSecretKey;
476
500
  this.wallets = new ChipiWallets(this.client);
477
501
  this.transactions = new ChipiTransactions(this.client);
478
502
  this.skus = new ChipiSkus(this.client);
@@ -485,11 +509,29 @@ var ChipiSDK = class {
485
509
  this.createWallet = this.createWallet.bind(this);
486
510
  this.recordSendTransaction = this.recordSendTransaction.bind(this);
487
511
  }
512
+ /**
513
+ * Resolve bearer token - uses provided token or falls back to apiSecretKey
514
+ */
515
+ resolveBearerToken(bearerToken) {
516
+ const token = bearerToken ?? this.apiSecretKey;
517
+ if (!token) {
518
+ throw new Error(
519
+ "Authentication required: either pass a bearerToken or configure the SDK with an apiSecretKey"
520
+ );
521
+ }
522
+ return token;
523
+ }
488
524
  /**
489
525
  * Execute a gasless transaction
490
526
  */
491
- async executeTransaction(params) {
492
- return this.transactions.executeTransaction(params);
527
+ async executeTransaction({
528
+ params,
529
+ bearerToken
530
+ }) {
531
+ return this.transactions.executeTransaction({
532
+ params,
533
+ bearerToken: this.resolveBearerToken(bearerToken)
534
+ });
493
535
  }
494
536
  /**
495
537
  * Transfer tokens
@@ -500,7 +542,7 @@ var ChipiSDK = class {
500
542
  }) {
501
543
  return this.transactions.transfer({
502
544
  params,
503
- bearerToken
545
+ bearerToken: this.resolveBearerToken(bearerToken)
504
546
  });
505
547
  }
506
548
  /**
@@ -512,16 +554,18 @@ var ChipiSDK = class {
512
554
  }) {
513
555
  const { encryptKey, wallet, contractAddress, spender, amount, decimals } = params;
514
556
  return this.executeTransaction({
515
- encryptKey,
516
- wallet,
517
- bearerToken,
518
- calls: [
519
- {
520
- contractAddress,
521
- entrypoint: "approve",
522
- calldata: [spender, shared.formatAmount(amount, decimals), "0x0"]
523
- }
524
- ]
557
+ params: {
558
+ encryptKey,
559
+ wallet,
560
+ calls: [
561
+ {
562
+ contractAddress,
563
+ entrypoint: "approve",
564
+ calldata: [spender, shared.formatAmount(amount, decimals), "0x0"]
565
+ }
566
+ ]
567
+ },
568
+ bearerToken: this.resolveBearerToken(bearerToken)
525
569
  });
526
570
  }
527
571
  /**
@@ -534,25 +578,27 @@ var ChipiSDK = class {
534
578
  const { encryptKey, wallet, amount, receiverWallet } = params;
535
579
  const formattedAmount = shared.formatAmount(amount, 6);
536
580
  return this.executeTransaction({
537
- encryptKey,
538
- wallet,
539
- bearerToken,
540
- calls: [
541
- {
542
- contractAddress: shared.CONTRACT_ADDRESSES.USDC_MAINNET,
543
- entrypoint: "approve",
544
- calldata: [
545
- shared.CONTRACT_ADDRESSES.VESU_USDC_MAINNET,
546
- formattedAmount,
547
- "0x0"
548
- ]
549
- },
550
- {
551
- contractAddress: shared.CONTRACT_ADDRESSES.VESU_USDC_MAINNET,
552
- entrypoint: "deposit",
553
- calldata: [formattedAmount, "0x0", receiverWallet]
554
- }
555
- ]
581
+ params: {
582
+ encryptKey,
583
+ wallet,
584
+ calls: [
585
+ {
586
+ contractAddress: shared.CONTRACT_ADDRESSES.USDC_MAINNET,
587
+ entrypoint: "approve",
588
+ calldata: [
589
+ shared.CONTRACT_ADDRESSES.VESU_USDC_MAINNET,
590
+ formattedAmount,
591
+ "0x0"
592
+ ]
593
+ },
594
+ {
595
+ contractAddress: shared.CONTRACT_ADDRESSES.VESU_USDC_MAINNET,
596
+ entrypoint: "deposit",
597
+ calldata: [formattedAmount, "0x0", receiverWallet]
598
+ }
599
+ ]
600
+ },
601
+ bearerToken: this.resolveBearerToken(bearerToken)
556
602
  });
557
603
  }
558
604
  /**
@@ -565,16 +611,18 @@ var ChipiSDK = class {
565
611
  const { encryptKey, wallet, amount, recipient } = params;
566
612
  const formattedAmount = shared.formatAmount(amount, 6);
567
613
  return this.executeTransaction({
568
- encryptKey,
569
- wallet,
570
- bearerToken,
571
- calls: [
572
- {
573
- contractAddress: shared.CONTRACT_ADDRESSES.VESU_USDC_MAINNET,
574
- entrypoint: "withdraw",
575
- calldata: [formattedAmount, recipient, "0x0"]
576
- }
577
- ]
614
+ params: {
615
+ encryptKey,
616
+ wallet,
617
+ calls: [
618
+ {
619
+ contractAddress: shared.CONTRACT_ADDRESSES.VESU_USDC_MAINNET,
620
+ entrypoint: "withdraw",
621
+ calldata: [formattedAmount, recipient, "0x0"]
622
+ }
623
+ ]
624
+ },
625
+ bearerToken: this.resolveBearerToken(bearerToken)
578
626
  });
579
627
  }
580
628
  /**
@@ -586,10 +634,12 @@ var ChipiSDK = class {
586
634
  }) {
587
635
  const { encryptKey, wallet, calls } = params;
588
636
  return this.executeTransaction({
589
- encryptKey,
590
- wallet,
591
- bearerToken,
592
- calls
637
+ params: {
638
+ encryptKey,
639
+ wallet,
640
+ calls
641
+ },
642
+ bearerToken: this.resolveBearerToken(bearerToken)
593
643
  });
594
644
  }
595
645
  /**
@@ -601,7 +651,7 @@ var ChipiSDK = class {
601
651
  }) {
602
652
  return this.wallets.createWallet({
603
653
  ...params,
604
- bearerToken
654
+ bearerToken: this.resolveBearerToken(bearerToken)
605
655
  });
606
656
  }
607
657
  async recordSendTransaction({
@@ -610,22 +660,47 @@ var ChipiSDK = class {
610
660
  }) {
611
661
  return this.transactions.recordSendTransaction({
612
662
  params,
613
- bearerToken
663
+ bearerToken: this.resolveBearerToken(bearerToken)
614
664
  });
615
665
  }
616
666
  async getWallet(params, bearerToken) {
617
- return this.wallets.getWallet(params, bearerToken);
667
+ return this.wallets.getWallet(params, this.resolveBearerToken(bearerToken));
618
668
  }
619
669
  async getTokenBalance(params, bearerToken) {
620
670
  return this.wallets.getTokenBalance({
621
671
  params,
622
- bearerToken
672
+ bearerToken: this.resolveBearerToken(bearerToken)
623
673
  });
624
674
  }
625
675
  };
626
676
 
677
+ // src/chipi-server-sdk.ts
678
+ var ChipiServerSDK = class extends ChipiSDK {
679
+ constructor(config) {
680
+ if (!config.apiSecretKey) {
681
+ throw new Error(
682
+ "apiSecretKey is required for ChipiServerSDK. Use ChipiBrowserSDK for client-side applications."
683
+ );
684
+ }
685
+ super(config);
686
+ }
687
+ // All methods are inherited from ChipiSDK
688
+ // The apiSecretKey from config is automatically used via resolveBearerToken()
689
+ };
690
+
691
+ // src/chipi-browser-sdk.ts
692
+ var ChipiBrowserSDK = class extends ChipiSDK {
693
+ constructor(config) {
694
+ super(config);
695
+ }
696
+ // All methods are inherited from ChipiSDK
697
+ // bearerToken parameter is required for each authenticated request
698
+ };
699
+
700
+ exports.ChipiBrowserSDK = ChipiBrowserSDK;
627
701
  exports.ChipiClient = ChipiClient;
628
702
  exports.ChipiSDK = ChipiSDK;
703
+ exports.ChipiServerSDK = ChipiServerSDK;
629
704
  exports.ChipiSkus = ChipiSkus;
630
705
  exports.ChipiTransactions = ChipiTransactions;
631
706
  exports.ChipiWallets = ChipiWallets;