@chipi-stack/backend 13.1.0 → 13.3.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 { GetUserParams, User, WalletData, CreateUserParams, CreateSessionKeyParams, SessionKeyData, AddSessionKeyParams, RevokeSessionKeyParams, GetSessionDataParams, SessionDataResponse, ExecuteWithSessionParams, Currency, ChipiSDKConfig, ExecuteTransactionParams, TransferParams, ApproveParams, StakeVesuUsdcParams, WithdrawVesuUsdcParams, CallAnyContractParams, CreateWalletParams, CreateWalletResponse, RecordSendTransactionParams, Transaction, GetTransactionListQuery, PaginatedResponse, GetWalletParams, GetTokenBalanceParams, GetTokenBalanceResponse, CreateSkuPurchaseParams, GetSkuListQuery, Sku, ChipiServerSDKConfig, ChipiBrowserSDKConfig } from '@chipi-stack/types';
2
+ import { CreateSessionKeyParams, SessionKeyData, AddSessionKeyParams, RevokeSessionKeyParams, GetSessionDataParams, SessionDataResponse, ExecuteWithSessionParams, Currency, ChipiSDKConfig, ExecuteTransactionParams, TransferParams, ApproveParams, CallAnyContractParams, CreateWalletParams, CreateWalletResponse, RecordSendTransactionParams, Transaction, GetTransactionListQuery, PaginatedResponse, GetWalletParams, GetTokenBalanceParams, GetTokenBalanceResponse, CreateSkuPurchaseParams, GetSkuListQuery, Sku, 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';
@@ -7,30 +7,6 @@ import { ChipiSkuPurchases } from './skuPurchases.mjs';
7
7
  import { ChipiSkus } from './skus.mjs';
8
8
  import { C as ChipiClient } from './client-43S3tkH3.mjs';
9
9
 
10
- /**
11
- * User management
12
- */
13
- declare class Users {
14
- private client;
15
- constructor(client: ChipiClient);
16
- /**
17
- * Get a single SKU by ID
18
- * @param bearerToken - Authentication token for API calls
19
- * @param id - SKU ID
20
- * @returns Promise<Sku> - Single SKU
21
- */
22
- getUser(params: GetUserParams, bearerToken: string): Promise<User & {
23
- chipiWallets?: WalletData[];
24
- }>;
25
- /**
26
- * Create a new user
27
- * @param bearerToken - Authentication token for API calls
28
- * @param params - CreateUserParams
29
- * @returns Promise<User> - Single User
30
- */
31
- createUser(params: CreateUserParams, bearerToken: string): Promise<User>;
32
- }
33
-
34
10
  /**
35
11
  * Session key management for CHIPI wallets (SNIP-9 compatible).
36
12
  *
@@ -209,7 +185,6 @@ declare class ChipiSDK {
209
185
  readonly transactions: ChipiTransactions;
210
186
  readonly skuPurchases: ChipiSkuPurchases;
211
187
  readonly skus: ChipiSkus;
212
- readonly users: Users;
213
188
  readonly sessions: ChipiSessions;
214
189
  readonly exchanges: ChipiExchanges;
215
190
  constructor(config: ChipiSDKConfig);
@@ -276,20 +251,6 @@ declare class ChipiSDK {
276
251
  params: ApproveParams;
277
252
  bearerToken?: string;
278
253
  }): Promise<string>;
279
- /**
280
- * Stake USDC in Vesu protocol
281
- */
282
- stakeVesuUsdc({ params, bearerToken, }: {
283
- params: StakeVesuUsdcParams;
284
- bearerToken?: string;
285
- }): Promise<string>;
286
- /**
287
- * Withdraw USDC from Vesu protocol
288
- */
289
- withdrawVesuUsdc({ params, bearerToken, }: {
290
- params: WithdrawVesuUsdcParams;
291
- bearerToken?: string;
292
- }): Promise<string>;
293
254
  /**
294
255
  * Call any contract method
295
256
  */
@@ -324,8 +285,6 @@ declare class ChipiSDK {
324
285
  getSkuPurchase(id: string, bearerToken?: string): Promise<Transaction>;
325
286
  getSkuList(params: GetSkuListQuery, bearerToken?: string): Promise<PaginatedResponse<Sku>>;
326
287
  getSku(id: string, bearerToken?: string): Promise<Sku>;
327
- getUser(params: GetUserParams, bearerToken?: string): Promise<User>;
328
- createUser(params: CreateUserParams, bearerToken?: string): Promise<User>;
329
288
  getUsdAmount(currencyAmount: number, currency: Currency, bearerToken?: string): Promise<number>;
330
289
  }
331
290
 
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as _chipi_stack_types from '@chipi-stack/types';
2
- import { GetUserParams, User, WalletData, CreateUserParams, CreateSessionKeyParams, SessionKeyData, AddSessionKeyParams, RevokeSessionKeyParams, GetSessionDataParams, SessionDataResponse, ExecuteWithSessionParams, Currency, ChipiSDKConfig, ExecuteTransactionParams, TransferParams, ApproveParams, StakeVesuUsdcParams, WithdrawVesuUsdcParams, CallAnyContractParams, CreateWalletParams, CreateWalletResponse, RecordSendTransactionParams, Transaction, GetTransactionListQuery, PaginatedResponse, GetWalletParams, GetTokenBalanceParams, GetTokenBalanceResponse, CreateSkuPurchaseParams, GetSkuListQuery, Sku, ChipiServerSDKConfig, ChipiBrowserSDKConfig } from '@chipi-stack/types';
2
+ import { CreateSessionKeyParams, SessionKeyData, AddSessionKeyParams, RevokeSessionKeyParams, GetSessionDataParams, SessionDataResponse, ExecuteWithSessionParams, Currency, ChipiSDKConfig, ExecuteTransactionParams, TransferParams, ApproveParams, CallAnyContractParams, CreateWalletParams, CreateWalletResponse, RecordSendTransactionParams, Transaction, GetTransactionListQuery, PaginatedResponse, GetWalletParams, GetTokenBalanceParams, GetTokenBalanceResponse, CreateSkuPurchaseParams, GetSkuListQuery, Sku, 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';
@@ -7,30 +7,6 @@ import { ChipiSkuPurchases } from './skuPurchases.js';
7
7
  import { ChipiSkus } from './skus.js';
8
8
  import { C as ChipiClient } from './client-43S3tkH3.js';
9
9
 
10
- /**
11
- * User management
12
- */
13
- declare class Users {
14
- private client;
15
- constructor(client: ChipiClient);
16
- /**
17
- * Get a single SKU by ID
18
- * @param bearerToken - Authentication token for API calls
19
- * @param id - SKU ID
20
- * @returns Promise<Sku> - Single SKU
21
- */
22
- getUser(params: GetUserParams, bearerToken: string): Promise<User & {
23
- chipiWallets?: WalletData[];
24
- }>;
25
- /**
26
- * Create a new user
27
- * @param bearerToken - Authentication token for API calls
28
- * @param params - CreateUserParams
29
- * @returns Promise<User> - Single User
30
- */
31
- createUser(params: CreateUserParams, bearerToken: string): Promise<User>;
32
- }
33
-
34
10
  /**
35
11
  * Session key management for CHIPI wallets (SNIP-9 compatible).
36
12
  *
@@ -209,7 +185,6 @@ declare class ChipiSDK {
209
185
  readonly transactions: ChipiTransactions;
210
186
  readonly skuPurchases: ChipiSkuPurchases;
211
187
  readonly skus: ChipiSkus;
212
- readonly users: Users;
213
188
  readonly sessions: ChipiSessions;
214
189
  readonly exchanges: ChipiExchanges;
215
190
  constructor(config: ChipiSDKConfig);
@@ -276,20 +251,6 @@ declare class ChipiSDK {
276
251
  params: ApproveParams;
277
252
  bearerToken?: string;
278
253
  }): Promise<string>;
279
- /**
280
- * Stake USDC in Vesu protocol
281
- */
282
- stakeVesuUsdc({ params, bearerToken, }: {
283
- params: StakeVesuUsdcParams;
284
- bearerToken?: string;
285
- }): Promise<string>;
286
- /**
287
- * Withdraw USDC from Vesu protocol
288
- */
289
- withdrawVesuUsdc({ params, bearerToken, }: {
290
- params: WithdrawVesuUsdcParams;
291
- bearerToken?: string;
292
- }): Promise<string>;
293
254
  /**
294
255
  * Call any contract method
295
256
  */
@@ -324,8 +285,6 @@ declare class ChipiSDK {
324
285
  getSkuPurchase(id: string, bearerToken?: string): Promise<Transaction>;
325
286
  getSkuList(params: GetSkuListQuery, bearerToken?: string): Promise<PaginatedResponse<Sku>>;
326
287
  getSku(id: string, bearerToken?: string): Promise<Sku>;
327
- getUser(params: GetUserParams, bearerToken?: string): Promise<User>;
328
- createUser(params: CreateUserParams, bearerToken?: string): Promise<User>;
329
288
  getUsdAmount(currencyAmount: number, currency: Currency, bearerToken?: string): Promise<number>;
330
289
  }
331
290
 
package/dist/index.js CHANGED
@@ -378,7 +378,7 @@ var executePaymasterTransaction = async ({
378
378
  wallet.publicKey,
379
379
  privateKeyDecrypted
380
380
  );
381
- const { typedData: typedData2, walletType } = await client.post({
381
+ const prepareResponse = await client.post({
382
382
  endpoint: "/transactions/prepare-typed-data",
383
383
  bearerToken,
384
384
  body: {
@@ -387,6 +387,30 @@ var executePaymasterTransaction = async ({
387
387
  accountClassHash
388
388
  }
389
389
  });
390
+ if (!prepareResponse || typeof prepareResponse !== "object") {
391
+ throw new Error(
392
+ "Invalid response from /transactions/prepare-typed-data: response is not an object"
393
+ );
394
+ }
395
+ let typedData2;
396
+ let walletType;
397
+ if ("typedData" in prepareResponse) {
398
+ const resp = prepareResponse;
399
+ typedData2 = resp.typedData;
400
+ walletType = resp.walletType;
401
+ } else if (prepareResponse && "types" in prepareResponse && "message" in prepareResponse) {
402
+ typedData2 = prepareResponse;
403
+ } else {
404
+ const apiMessage = prepareResponse && typeof prepareResponse.message === "string" ? prepareResponse.message : void 0;
405
+ throw new Error(
406
+ apiMessage ?? "Invalid response from /transactions/prepare-typed-data: typedData is missing. This may occur for older STARKNET wallets that don't support paymaster transactions. Please ensure the wallet is a CHIPI wallet type."
407
+ );
408
+ }
409
+ if (!typedData2 || typeof typedData2 !== "object" || !("message" in typedData2)) {
410
+ throw new Error(
411
+ "Invalid typedData received from backend: missing 'message' field. This may occur for older STARKNET wallets that don't support paymaster transactions."
412
+ );
413
+ }
390
414
  const userSignature = await account.signMessage(typedData2);
391
415
  const result = await client.post({
392
416
  endpoint: "/transactions/execute-sponsored-transaction",
@@ -816,43 +840,6 @@ var ChipiSkus = class {
816
840
  });
817
841
  }
818
842
  };
819
- var Users = class {
820
- constructor(client) {
821
- this.client = client;
822
- }
823
- /**
824
- * Get a single SKU by ID
825
- * @param bearerToken - Authentication token for API calls
826
- * @param id - SKU ID
827
- * @returns Promise<Sku> - Single SKU
828
- */
829
- async getUser(params, bearerToken) {
830
- const { phone, ...rest } = params;
831
- const queryParams = {
832
- ...rest,
833
- phoneCountryCode: phone?.phoneCountryCode?.toString() || void 0,
834
- phoneNumber: phone?.phoneNumber?.toString() || void 0
835
- };
836
- return this.client.get({
837
- endpoint: `${shared.API_ENDPOINTS.USERS}`,
838
- params: queryParams,
839
- bearerToken
840
- });
841
- }
842
- /**
843
- * Create a new user
844
- * @param bearerToken - Authentication token for API calls
845
- * @param params - CreateUserParams
846
- * @returns Promise<User> - Single User
847
- */
848
- async createUser(params, bearerToken) {
849
- return this.client.post({
850
- endpoint: `${shared.API_ENDPOINTS.USERS}`,
851
- bearerToken,
852
- body: params
853
- });
854
- }
855
- };
856
843
  var ChipiSessions = class {
857
844
  constructor(client) {
858
845
  this.client = client;
@@ -1240,15 +1227,12 @@ var ChipiSDK = class {
1240
1227
  this.transactions = new ChipiTransactions(this.client);
1241
1228
  this.skuPurchases = new ChipiSkuPurchases(this.client);
1242
1229
  this.skus = new ChipiSkus(this.client);
1243
- this.users = new Users(this.client);
1244
1230
  this.sessions = new ChipiSessions(this.client);
1245
1231
  this.exchanges = new ChipiExchanges(this.client);
1246
1232
  this.executeTransaction = this.executeTransaction.bind(this);
1247
1233
  this.executeTransactionWithSession = this.executeTransactionWithSession.bind(this);
1248
1234
  this.transfer = this.transfer.bind(this);
1249
1235
  this.approve = this.approve.bind(this);
1250
- this.stakeVesuUsdc = this.stakeVesuUsdc.bind(this);
1251
- this.withdrawVesuUsdc = this.withdrawVesuUsdc.bind(this);
1252
1236
  this.callAnyContract = this.callAnyContract.bind(this);
1253
1237
  this.createWallet = this.createWallet.bind(this);
1254
1238
  this.recordSendTransaction = this.recordSendTransaction.bind(this);
@@ -1357,63 +1341,6 @@ var ChipiSDK = class {
1357
1341
  bearerToken: this.resolveBearerToken(bearerToken)
1358
1342
  });
1359
1343
  }
1360
- /**
1361
- * Stake USDC in Vesu protocol
1362
- */
1363
- async stakeVesuUsdc({
1364
- params,
1365
- bearerToken
1366
- }) {
1367
- const { encryptKey, wallet, amount, receiverWallet } = params;
1368
- const formattedAmount = shared.formatAmount(amount, 6);
1369
- return this.executeTransaction({
1370
- params: {
1371
- encryptKey,
1372
- wallet,
1373
- calls: [
1374
- {
1375
- contractAddress: shared.CONTRACT_ADDRESSES.USDC_MAINNET,
1376
- entrypoint: "approve",
1377
- calldata: [
1378
- shared.CONTRACT_ADDRESSES.VESU_USDC_MAINNET,
1379
- formattedAmount,
1380
- "0x0"
1381
- ]
1382
- },
1383
- {
1384
- contractAddress: shared.CONTRACT_ADDRESSES.VESU_USDC_MAINNET,
1385
- entrypoint: "deposit",
1386
- calldata: [formattedAmount, "0x0", receiverWallet]
1387
- }
1388
- ]
1389
- },
1390
- bearerToken: this.resolveBearerToken(bearerToken)
1391
- });
1392
- }
1393
- /**
1394
- * Withdraw USDC from Vesu protocol
1395
- */
1396
- async withdrawVesuUsdc({
1397
- params,
1398
- bearerToken
1399
- }) {
1400
- const { encryptKey, wallet, amount, recipient } = params;
1401
- const formattedAmount = shared.formatAmount(amount, 6);
1402
- return this.executeTransaction({
1403
- params: {
1404
- encryptKey,
1405
- wallet,
1406
- calls: [
1407
- {
1408
- contractAddress: shared.CONTRACT_ADDRESSES.VESU_USDC_MAINNET,
1409
- entrypoint: "withdraw",
1410
- calldata: [formattedAmount, recipient, "0x0"]
1411
- }
1412
- ]
1413
- },
1414
- bearerToken: this.resolveBearerToken(bearerToken)
1415
- });
1416
- }
1417
1344
  /**
1418
1345
  * Call any contract method
1419
1346
  */
@@ -1495,13 +1422,6 @@ var ChipiSDK = class {
1495
1422
  async getSku(id, bearerToken) {
1496
1423
  return this.skus.getSku(id, this.resolveBearerToken(bearerToken));
1497
1424
  }
1498
- // USERS
1499
- async getUser(params, bearerToken) {
1500
- return this.users.getUser(params, this.resolveBearerToken(bearerToken));
1501
- }
1502
- async createUser(params, bearerToken) {
1503
- return this.users.createUser(params, this.resolveBearerToken(bearerToken));
1504
- }
1505
1425
  async getUsdAmount(currencyAmount, currency, bearerToken) {
1506
1426
  return this.exchanges.getUsdAmount(
1507
1427
  currencyAmount,