@chipi-stack/backend 11.5.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,5 +1,5 @@
1
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 } 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';
3
3
  export * from '@chipi-stack/types';
4
4
  import { ChipiWallets } from './wallets.mjs';
5
5
  import { ChipiTransactions } from './transactions.mjs';
@@ -12,67 +12,148 @@ export { C as ChipiClient } from './client-D4ZnPqgQ.mjs';
12
12
  declare class ChipiSDK {
13
13
  private client;
14
14
  private nodeUrl;
15
+ private apiSecretKey?;
15
16
  readonly wallets: ChipiWallets;
16
17
  readonly transactions: ChipiTransactions;
17
18
  readonly skus: ChipiSkus;
18
19
  constructor(config: ChipiSDKConfig);
20
+ /**
21
+ * Resolve bearer token - uses provided token or falls back to apiSecretKey
22
+ */
23
+ private resolveBearerToken;
19
24
  /**
20
25
  * Execute a gasless transaction
21
26
  */
22
- executeTransaction(params: Omit<ExecuteTransactionParams, "apiPublicKey" | "backendUrl">): Promise<string>;
27
+ executeTransaction({ params, bearerToken, }: {
28
+ params: ExecuteTransactionParams;
29
+ bearerToken?: string;
30
+ }): Promise<string>;
23
31
  /**
24
32
  * Transfer tokens
25
33
  */
26
34
  transfer({ params, bearerToken, }: {
27
35
  params: TransferParams;
28
- bearerToken: string;
36
+ bearerToken?: string;
29
37
  }): Promise<string>;
30
38
  /**
31
39
  * Approve token spending
32
40
  */
33
41
  approve({ params, bearerToken, }: {
34
42
  params: ApproveParams;
35
- bearerToken: string;
43
+ bearerToken?: string;
36
44
  }): Promise<string>;
37
45
  /**
38
46
  * Stake USDC in Vesu protocol
39
47
  */
40
48
  stakeVesuUsdc({ params, bearerToken, }: {
41
49
  params: StakeVesuUsdcParams;
42
- bearerToken: string;
50
+ bearerToken?: string;
43
51
  }): Promise<string>;
44
52
  /**
45
53
  * Withdraw USDC from Vesu protocol
46
54
  */
47
55
  withdrawVesuUsdc({ params, bearerToken, }: {
48
56
  params: WithdrawVesuUsdcParams;
49
- bearerToken: string;
57
+ bearerToken?: string;
50
58
  }): Promise<string>;
51
59
  /**
52
60
  * Call any contract method
53
61
  */
54
62
  callAnyContract({ params, bearerToken, }: {
55
63
  params: CallAnyContractParams;
56
- bearerToken: string;
64
+ bearerToken?: string;
57
65
  }): Promise<string>;
58
66
  /**
59
67
  * Create a new wallet
60
68
  */
61
69
  createWallet({ params, bearerToken, }: {
62
70
  params: CreateWalletParams;
63
- bearerToken: string;
71
+ bearerToken?: string;
64
72
  }): Promise<CreateWalletResponse>;
65
73
  recordSendTransaction({ params, bearerToken, }: {
66
74
  params: RecordSendTransactionParams;
67
- bearerToken: string;
75
+ bearerToken?: string;
68
76
  }): Promise<Transaction>;
69
- getWallet(params: GetWalletParams, bearerToken: string): Promise<(_chipi_stack_types.GetWalletResponse & {
77
+ getWallet(params: GetWalletParams, bearerToken?: string): Promise<(_chipi_stack_types.GetWalletResponse & {
70
78
  normalizedPublicKey: string;
71
79
  }) | null>;
72
- getTokenBalance(params: GetTokenBalanceParams, bearerToken: string): Promise<GetTokenBalanceResponse>;
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);
73
154
  }
74
155
 
75
156
  declare const encryptPrivateKey: (privateKey: string, password: string) => string;
76
157
  declare const decryptPrivateKey: (encryptedPrivateKey: string, password: string) => string;
77
158
 
78
- export { ChipiSDK, ChipiSkus, ChipiTransactions, ChipiWallets, decryptPrivateKey, encryptPrivateKey };
159
+ export { ChipiBrowserSDK, ChipiSDK, ChipiServerSDK, ChipiSkus, ChipiTransactions, ChipiWallets, decryptPrivateKey, encryptPrivateKey };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
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 } 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';
3
3
  export * from '@chipi-stack/types';
4
4
  import { ChipiWallets } from './wallets.js';
5
5
  import { ChipiTransactions } from './transactions.js';
@@ -12,67 +12,148 @@ export { C as ChipiClient } from './client-D4ZnPqgQ.js';
12
12
  declare class ChipiSDK {
13
13
  private client;
14
14
  private nodeUrl;
15
+ private apiSecretKey?;
15
16
  readonly wallets: ChipiWallets;
16
17
  readonly transactions: ChipiTransactions;
17
18
  readonly skus: ChipiSkus;
18
19
  constructor(config: ChipiSDKConfig);
20
+ /**
21
+ * Resolve bearer token - uses provided token or falls back to apiSecretKey
22
+ */
23
+ private resolveBearerToken;
19
24
  /**
20
25
  * Execute a gasless transaction
21
26
  */
22
- executeTransaction(params: Omit<ExecuteTransactionParams, "apiPublicKey" | "backendUrl">): Promise<string>;
27
+ executeTransaction({ params, bearerToken, }: {
28
+ params: ExecuteTransactionParams;
29
+ bearerToken?: string;
30
+ }): Promise<string>;
23
31
  /**
24
32
  * Transfer tokens
25
33
  */
26
34
  transfer({ params, bearerToken, }: {
27
35
  params: TransferParams;
28
- bearerToken: string;
36
+ bearerToken?: string;
29
37
  }): Promise<string>;
30
38
  /**
31
39
  * Approve token spending
32
40
  */
33
41
  approve({ params, bearerToken, }: {
34
42
  params: ApproveParams;
35
- bearerToken: string;
43
+ bearerToken?: string;
36
44
  }): Promise<string>;
37
45
  /**
38
46
  * Stake USDC in Vesu protocol
39
47
  */
40
48
  stakeVesuUsdc({ params, bearerToken, }: {
41
49
  params: StakeVesuUsdcParams;
42
- bearerToken: string;
50
+ bearerToken?: string;
43
51
  }): Promise<string>;
44
52
  /**
45
53
  * Withdraw USDC from Vesu protocol
46
54
  */
47
55
  withdrawVesuUsdc({ params, bearerToken, }: {
48
56
  params: WithdrawVesuUsdcParams;
49
- bearerToken: string;
57
+ bearerToken?: string;
50
58
  }): Promise<string>;
51
59
  /**
52
60
  * Call any contract method
53
61
  */
54
62
  callAnyContract({ params, bearerToken, }: {
55
63
  params: CallAnyContractParams;
56
- bearerToken: string;
64
+ bearerToken?: string;
57
65
  }): Promise<string>;
58
66
  /**
59
67
  * Create a new wallet
60
68
  */
61
69
  createWallet({ params, bearerToken, }: {
62
70
  params: CreateWalletParams;
63
- bearerToken: string;
71
+ bearerToken?: string;
64
72
  }): Promise<CreateWalletResponse>;
65
73
  recordSendTransaction({ params, bearerToken, }: {
66
74
  params: RecordSendTransactionParams;
67
- bearerToken: string;
75
+ bearerToken?: string;
68
76
  }): Promise<Transaction>;
69
- getWallet(params: GetWalletParams, bearerToken: string): Promise<(_chipi_stack_types.GetWalletResponse & {
77
+ getWallet(params: GetWalletParams, bearerToken?: string): Promise<(_chipi_stack_types.GetWalletResponse & {
70
78
  normalizedPublicKey: string;
71
79
  }) | null>;
72
- getTokenBalance(params: GetTokenBalanceParams, bearerToken: string): Promise<GetTokenBalanceResponse>;
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);
73
154
  }
74
155
 
75
156
  declare const encryptPrivateKey: (privateKey: string, password: string) => string;
76
157
  declare const decryptPrivateKey: (encryptedPrivateKey: string, password: string) => string;
77
158
 
78
- export { ChipiSDK, ChipiSkus, ChipiTransactions, ChipiWallets, decryptPrivateKey, encryptPrivateKey };
159
+ export { ChipiBrowserSDK, ChipiSDK, ChipiServerSDK, ChipiSkus, ChipiTransactions, ChipiWallets, decryptPrivateKey, encryptPrivateKey };
package/dist/index.js CHANGED
@@ -297,9 +297,14 @@ var ChipiWallets = class {
297
297
  return getBalanceResponse;
298
298
  }
299
299
  };
300
- var executePaymasterTransaction = async (params) => {
300
+ var executePaymasterTransaction = async ({
301
+ params,
302
+ bearerToken,
303
+ apiPublicKey,
304
+ backendUrl
305
+ }) => {
301
306
  try {
302
- const { encryptKey, wallet, calls, apiPublicKey, bearerToken, backendUrl } = params;
307
+ const { encryptKey, wallet, calls } = params;
303
308
  const privateKeyDecrypted = decryptPrivateKey(
304
309
  wallet.encryptedPrivateKey,
305
310
  encryptKey
@@ -380,9 +385,13 @@ var ChipiTransactions = class {
380
385
  /**
381
386
  * Execute a gasless transaction using paymaster
382
387
  */
383
- async executeTransaction(params) {
388
+ async executeTransaction({
389
+ params,
390
+ bearerToken
391
+ }) {
384
392
  return executePaymasterTransaction({
385
- ...params,
393
+ params,
394
+ bearerToken,
386
395
  backendUrl: this.client.baseUrl,
387
396
  apiPublicKey: this.client.getApiPublicKey()
388
397
  });
@@ -407,16 +416,18 @@ var ChipiTransactions = class {
407
416
  }
408
417
  const formattedAmount = shared.formatAmount(amount, decimals);
409
418
  return this.executeTransaction({
410
- encryptKey,
411
- wallet,
412
- bearerToken,
413
- calls: [
414
- {
415
- contractAddress,
416
- entrypoint: "transfer",
417
- calldata: [recipient, formattedAmount, "0x0"]
418
- }
419
- ]
419
+ params: {
420
+ encryptKey,
421
+ wallet,
422
+ calls: [
423
+ {
424
+ contractAddress,
425
+ entrypoint: "transfer",
426
+ calldata: [recipient, formattedAmount, "0x0"]
427
+ }
428
+ ]
429
+ },
430
+ bearerToken
420
431
  });
421
432
  }
422
433
  /**
@@ -425,27 +436,36 @@ var ChipiTransactions = class {
425
436
  async approve(params) {
426
437
  const formattedAmount = shared.formatAmount(params.amount, params.decimals);
427
438
  return this.executeTransaction({
428
- encryptKey: params.encryptKey,
429
- wallet: params.wallet,
430
- bearerToken: params.bearerToken,
431
- calls: [
432
- {
433
- contractAddress: params.contractAddress,
434
- entrypoint: "approve",
435
- calldata: [params.spender, formattedAmount, "0x0"]
436
- }
437
- ]
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
438
451
  });
439
452
  }
440
453
  /**
441
454
  * Call any contract method
442
455
  */
443
- 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
+ }) {
444
466
  return this.executeTransaction({
445
- encryptKey: params.encryptKey,
446
- wallet: params.wallet,
447
- bearerToken: params.bearerToken,
448
- calls: params.calls
467
+ params,
468
+ bearerToken
449
469
  });
450
470
  }
451
471
  /**
@@ -476,6 +496,7 @@ var ChipiSDK = class {
476
496
  constructor(config) {
477
497
  this.client = new ChipiClient(config);
478
498
  this.nodeUrl = config.nodeUrl || shared.STARKNET_NETWORKS.MAINNET;
499
+ this.apiSecretKey = config.apiSecretKey;
479
500
  this.wallets = new ChipiWallets(this.client);
480
501
  this.transactions = new ChipiTransactions(this.client);
481
502
  this.skus = new ChipiSkus(this.client);
@@ -488,11 +509,29 @@ var ChipiSDK = class {
488
509
  this.createWallet = this.createWallet.bind(this);
489
510
  this.recordSendTransaction = this.recordSendTransaction.bind(this);
490
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
+ }
491
524
  /**
492
525
  * Execute a gasless transaction
493
526
  */
494
- async executeTransaction(params) {
495
- 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
+ });
496
535
  }
497
536
  /**
498
537
  * Transfer tokens
@@ -503,7 +542,7 @@ var ChipiSDK = class {
503
542
  }) {
504
543
  return this.transactions.transfer({
505
544
  params,
506
- bearerToken
545
+ bearerToken: this.resolveBearerToken(bearerToken)
507
546
  });
508
547
  }
509
548
  /**
@@ -515,16 +554,18 @@ var ChipiSDK = class {
515
554
  }) {
516
555
  const { encryptKey, wallet, contractAddress, spender, amount, decimals } = params;
517
556
  return this.executeTransaction({
518
- encryptKey,
519
- wallet,
520
- bearerToken,
521
- calls: [
522
- {
523
- contractAddress,
524
- entrypoint: "approve",
525
- calldata: [spender, shared.formatAmount(amount, decimals), "0x0"]
526
- }
527
- ]
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)
528
569
  });
529
570
  }
530
571
  /**
@@ -537,25 +578,27 @@ var ChipiSDK = class {
537
578
  const { encryptKey, wallet, amount, receiverWallet } = params;
538
579
  const formattedAmount = shared.formatAmount(amount, 6);
539
580
  return this.executeTransaction({
540
- encryptKey,
541
- wallet,
542
- bearerToken,
543
- calls: [
544
- {
545
- contractAddress: shared.CONTRACT_ADDRESSES.USDC_MAINNET,
546
- entrypoint: "approve",
547
- calldata: [
548
- shared.CONTRACT_ADDRESSES.VESU_USDC_MAINNET,
549
- formattedAmount,
550
- "0x0"
551
- ]
552
- },
553
- {
554
- contractAddress: shared.CONTRACT_ADDRESSES.VESU_USDC_MAINNET,
555
- entrypoint: "deposit",
556
- calldata: [formattedAmount, "0x0", receiverWallet]
557
- }
558
- ]
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)
559
602
  });
560
603
  }
561
604
  /**
@@ -568,16 +611,18 @@ var ChipiSDK = class {
568
611
  const { encryptKey, wallet, amount, recipient } = params;
569
612
  const formattedAmount = shared.formatAmount(amount, 6);
570
613
  return this.executeTransaction({
571
- encryptKey,
572
- wallet,
573
- bearerToken,
574
- calls: [
575
- {
576
- contractAddress: shared.CONTRACT_ADDRESSES.VESU_USDC_MAINNET,
577
- entrypoint: "withdraw",
578
- calldata: [formattedAmount, recipient, "0x0"]
579
- }
580
- ]
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)
581
626
  });
582
627
  }
583
628
  /**
@@ -589,10 +634,12 @@ var ChipiSDK = class {
589
634
  }) {
590
635
  const { encryptKey, wallet, calls } = params;
591
636
  return this.executeTransaction({
592
- encryptKey,
593
- wallet,
594
- bearerToken,
595
- calls
637
+ params: {
638
+ encryptKey,
639
+ wallet,
640
+ calls
641
+ },
642
+ bearerToken: this.resolveBearerToken(bearerToken)
596
643
  });
597
644
  }
598
645
  /**
@@ -604,7 +651,7 @@ var ChipiSDK = class {
604
651
  }) {
605
652
  return this.wallets.createWallet({
606
653
  ...params,
607
- bearerToken
654
+ bearerToken: this.resolveBearerToken(bearerToken)
608
655
  });
609
656
  }
610
657
  async recordSendTransaction({
@@ -613,22 +660,47 @@ var ChipiSDK = class {
613
660
  }) {
614
661
  return this.transactions.recordSendTransaction({
615
662
  params,
616
- bearerToken
663
+ bearerToken: this.resolveBearerToken(bearerToken)
617
664
  });
618
665
  }
619
666
  async getWallet(params, bearerToken) {
620
- return this.wallets.getWallet(params, bearerToken);
667
+ return this.wallets.getWallet(params, this.resolveBearerToken(bearerToken));
621
668
  }
622
669
  async getTokenBalance(params, bearerToken) {
623
670
  return this.wallets.getTokenBalance({
624
671
  params,
625
- bearerToken
672
+ bearerToken: this.resolveBearerToken(bearerToken)
626
673
  });
627
674
  }
628
675
  };
629
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;
630
701
  exports.ChipiClient = ChipiClient;
631
702
  exports.ChipiSDK = ChipiSDK;
703
+ exports.ChipiServerSDK = ChipiServerSDK;
632
704
  exports.ChipiSkus = ChipiSkus;
633
705
  exports.ChipiTransactions = ChipiTransactions;
634
706
  exports.ChipiWallets = ChipiWallets;