@medialane/sdk 0.137.0 → 0.139.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/README.md CHANGED
@@ -280,11 +280,12 @@ token.balances?.forEach((b: ApiTokenBalance) => {
280
280
 
281
281
  ```typescript
282
282
  // All collections: newest first by default
283
- const collections = await client.api.getCollections();
283
+ const collections = await client.api.listCollections();
284
284
 
285
- // With sort and pagination
286
- const byVolume = await client.api.getCollections(1, 20, undefined, "volume");
287
- const verified = await client.api.getCollections(1, 18, true, "recent");
285
+ // Filter, sort and paginate in one query
286
+ const byVolume = await client.api.listCollections({ page: 1, limit: 20, sort: "volume" });
287
+ const featured = await client.api.listCollections({ limit: 18, isFeatured: true, sort: "recent" });
288
+ const myDrops = await client.api.listCollections({ owner: "0x...", service: "drop-collection" });
288
289
 
289
290
  // Sort options: "recent" | "supply" | "floor" | "volume" | "name"
290
291
  const collection = await client.api.getCollection(contract);
@@ -967,15 +967,8 @@ interface ApiAdminCollectionClaim extends ApiCollectionClaim {
967
967
  updatedAt: string;
968
968
  }
969
969
  interface ApiBusinessProvisioning {
970
- id: string;
971
- accountId: string;
972
970
  chain: string;
973
971
  walletAddress: string;
974
- recipientScheme: string;
975
- recipientValue: string;
976
- interimOwnerPubkey: string | null;
977
- newOwnerPubkey: string | null;
978
- status: "DEPLOYED" | "REUSED" | "TRANSFERRED";
979
972
  }
980
973
  interface ApiWalletActivity {
981
974
  id: string;
@@ -1238,6 +1231,7 @@ interface ApiCollectionsListQuery {
1238
1231
  sort?: CollectionSort;
1239
1232
  isFeatured?: boolean;
1240
1233
  hideEmpty?: boolean;
1234
+ standard?: string;
1241
1235
  chain?: ChainFilter;
1242
1236
  }
1243
1237
  interface ApiPricingRule {
@@ -1296,8 +1290,6 @@ declare class ApiClient {
1296
1290
  getToken(contract: string, tokenId: string, wait?: boolean): Promise<ApiResponse<ApiToken>>;
1297
1291
  getTokensByOwner(address: string, page?: number, limit?: number): Promise<ApiResponse<ApiToken[]>>;
1298
1292
  getTokenHistory(contract: string, tokenId: string, page?: number, limit?: number): Promise<ApiResponse<ApiActivity[]>>;
1299
- getCollections(page?: number, limit?: number, isKnown?: boolean, sort?: CollectionSort, service?: string, chain?: ChainFilter, standard?: string): Promise<ApiResponse<ApiCollection[]>>;
1300
- getCollectionsByOwner(owner: string, page?: number, limit?: number): Promise<ApiResponse<ApiCollection[]>>;
1301
1293
  getCollection(contract: string): Promise<ApiResponse<ApiCollection>>;
1302
1294
  getCollectionTokens(contract: string, page?: number, limit?: number, sort?: CollectionTokensSort): Promise<ApiResponse<ApiToken[]>>;
1303
1295
  getActivities(query?: ApiActivitiesQuery): Promise<ApiResponse<ApiActivity[]>>;
@@ -1404,7 +1396,7 @@ declare class ApiClient {
1404
1396
  }>;
1405
1397
  registerBusinessProvisioning(params: {
1406
1398
  chain?: "STARKNET";
1407
- recipientScheme: string;
1399
+ recipientScheme: "email";
1408
1400
  recipientValue: string;
1409
1401
  }): Promise<ApiResponse<ApiBusinessProvisioning> & {
1410
1402
  reusedExistingWallet?: boolean;
@@ -1456,24 +1448,26 @@ declare class ApiClient {
1456
1448
  }): Promise<ApiUserWallet>;
1457
1449
  checkEmail(email: string): Promise<{
1458
1450
  exists: boolean;
1459
- walletWaiting: boolean;
1460
1451
  }>;
1461
1452
  requestEmailCode(email: string): Promise<void>;
1462
1453
  registerEmailAccount(email: string): Promise<void>;
1463
- verifyEmailCode(email: string, code: string): Promise<{
1464
- waitingWallets: string[];
1465
- }>;
1466
- claimWallet(params: {
1454
+ verifyEmailCode(email: string, code: string): Promise<void>;
1455
+ /**
1456
+ * Makes the passkey the only owner of the session account's wallet. `signature` is the passkey's owner-alive
1457
+ * proof for the wallet. Answers 409 when the wallet is already set up.
1458
+ */
1459
+ setupWalletKey(params: {
1467
1460
  newOwnerPubkey: string;
1468
- proofs: {
1469
- walletAddress: string;
1470
- signature: string[];
1471
- expiration: number;
1472
- }[];
1461
+ signature: string[];
1462
+ expiration: number;
1473
1463
  }): Promise<{
1474
- claimed: string[];
1464
+ walletAddress: string;
1475
1465
  }>;
1476
- getSessionWallet(): Promise<string | null>;
1466
+ /** The session account's wallet, and whether its passkey still has to be set up (`setupWalletKey`). */
1467
+ getSessionWallet(): Promise<{
1468
+ walletAddress: string;
1469
+ needsKeySetup: boolean;
1470
+ } | null>;
1477
1471
  getMyWallet(siwsToken: string): Promise<ApiUserWallet | null>;
1478
1472
  changeMyEmail(email: string, siwsToken: string): Promise<{
1479
1473
  email: string;
@@ -1491,11 +1485,6 @@ declare class ApiClient {
1491
1485
  confirmRemixOffer(id: string, params: ConfirmRemixOfferParams, siwsToken: string): Promise<ApiResponse<ApiRemixOffer>>;
1492
1486
  rejectRemixOffer(id: string, siwsToken: string): Promise<ApiResponse<ApiRemixOffer>>;
1493
1487
  extendRemixOffer(id: string, days: number, siwsToken: string): Promise<ApiResponse<ApiRemixOffer>>;
1494
- getPopCollections(opts?: {
1495
- page?: number;
1496
- limit?: number;
1497
- sort?: CollectionSort;
1498
- }): Promise<ApiResponse<ApiCollection[]>>;
1499
1488
  getPopEligibility(collection: string, wallet: string): Promise<PopClaimStatus>;
1500
1489
  getPopEligibilityBatch(collection: string, wallets: string[]): Promise<PopBatchEligibilityItem[]>;
1501
1490
  getCoins(opts?: ApiCoinsQuery): Promise<ApiResponse<ApiCoin[]>>;
@@ -1509,16 +1498,12 @@ declare class ApiClient {
1509
1498
  image?: string | null;
1510
1499
  description?: string | null;
1511
1500
  }, siwsToken: string): Promise<ApiResponse<ApiCoin>>;
1512
- getDropCollections(opts?: {
1513
- page?: number;
1514
- limit?: number;
1515
- sort?: CollectionSort;
1516
- }): Promise<ApiResponse<ApiCollection[]>>;
1517
1501
  getDropMintStatus(collection: string, wallet: string): Promise<DropMintStatus>;
1518
1502
  getDropInfo(contract: string): Promise<ApiDropInfo | null>;
1519
1503
  getDropState(contract: string): Promise<ApiDropState>;
1520
1504
  getTicket(contract: string, tokenId: string): Promise<ApiTierOnchain>;
1521
1505
  getTicketCount(contract: string): Promise<number>;
1506
+ getClubMembershipCount(contract: string): Promise<number>;
1522
1507
  getClubMembership(contract: string, tokenId: string): Promise<ApiTierOnchain>;
1523
1508
  isClubMember(contract: string, tokenId: string, wallet: string): Promise<boolean>;
1524
1509
  getIpNftTokenData(contract: string, tokenId: string): Promise<ApiIpNftTokenData | null>;
@@ -967,15 +967,8 @@ interface ApiAdminCollectionClaim extends ApiCollectionClaim {
967
967
  updatedAt: string;
968
968
  }
969
969
  interface ApiBusinessProvisioning {
970
- id: string;
971
- accountId: string;
972
970
  chain: string;
973
971
  walletAddress: string;
974
- recipientScheme: string;
975
- recipientValue: string;
976
- interimOwnerPubkey: string | null;
977
- newOwnerPubkey: string | null;
978
- status: "DEPLOYED" | "REUSED" | "TRANSFERRED";
979
972
  }
980
973
  interface ApiWalletActivity {
981
974
  id: string;
@@ -1238,6 +1231,7 @@ interface ApiCollectionsListQuery {
1238
1231
  sort?: CollectionSort;
1239
1232
  isFeatured?: boolean;
1240
1233
  hideEmpty?: boolean;
1234
+ standard?: string;
1241
1235
  chain?: ChainFilter;
1242
1236
  }
1243
1237
  interface ApiPricingRule {
@@ -1296,8 +1290,6 @@ declare class ApiClient {
1296
1290
  getToken(contract: string, tokenId: string, wait?: boolean): Promise<ApiResponse<ApiToken>>;
1297
1291
  getTokensByOwner(address: string, page?: number, limit?: number): Promise<ApiResponse<ApiToken[]>>;
1298
1292
  getTokenHistory(contract: string, tokenId: string, page?: number, limit?: number): Promise<ApiResponse<ApiActivity[]>>;
1299
- getCollections(page?: number, limit?: number, isKnown?: boolean, sort?: CollectionSort, service?: string, chain?: ChainFilter, standard?: string): Promise<ApiResponse<ApiCollection[]>>;
1300
- getCollectionsByOwner(owner: string, page?: number, limit?: number): Promise<ApiResponse<ApiCollection[]>>;
1301
1293
  getCollection(contract: string): Promise<ApiResponse<ApiCollection>>;
1302
1294
  getCollectionTokens(contract: string, page?: number, limit?: number, sort?: CollectionTokensSort): Promise<ApiResponse<ApiToken[]>>;
1303
1295
  getActivities(query?: ApiActivitiesQuery): Promise<ApiResponse<ApiActivity[]>>;
@@ -1404,7 +1396,7 @@ declare class ApiClient {
1404
1396
  }>;
1405
1397
  registerBusinessProvisioning(params: {
1406
1398
  chain?: "STARKNET";
1407
- recipientScheme: string;
1399
+ recipientScheme: "email";
1408
1400
  recipientValue: string;
1409
1401
  }): Promise<ApiResponse<ApiBusinessProvisioning> & {
1410
1402
  reusedExistingWallet?: boolean;
@@ -1456,24 +1448,26 @@ declare class ApiClient {
1456
1448
  }): Promise<ApiUserWallet>;
1457
1449
  checkEmail(email: string): Promise<{
1458
1450
  exists: boolean;
1459
- walletWaiting: boolean;
1460
1451
  }>;
1461
1452
  requestEmailCode(email: string): Promise<void>;
1462
1453
  registerEmailAccount(email: string): Promise<void>;
1463
- verifyEmailCode(email: string, code: string): Promise<{
1464
- waitingWallets: string[];
1465
- }>;
1466
- claimWallet(params: {
1454
+ verifyEmailCode(email: string, code: string): Promise<void>;
1455
+ /**
1456
+ * Makes the passkey the only owner of the session account's wallet. `signature` is the passkey's owner-alive
1457
+ * proof for the wallet. Answers 409 when the wallet is already set up.
1458
+ */
1459
+ setupWalletKey(params: {
1467
1460
  newOwnerPubkey: string;
1468
- proofs: {
1469
- walletAddress: string;
1470
- signature: string[];
1471
- expiration: number;
1472
- }[];
1461
+ signature: string[];
1462
+ expiration: number;
1473
1463
  }): Promise<{
1474
- claimed: string[];
1464
+ walletAddress: string;
1475
1465
  }>;
1476
- getSessionWallet(): Promise<string | null>;
1466
+ /** The session account's wallet, and whether its passkey still has to be set up (`setupWalletKey`). */
1467
+ getSessionWallet(): Promise<{
1468
+ walletAddress: string;
1469
+ needsKeySetup: boolean;
1470
+ } | null>;
1477
1471
  getMyWallet(siwsToken: string): Promise<ApiUserWallet | null>;
1478
1472
  changeMyEmail(email: string, siwsToken: string): Promise<{
1479
1473
  email: string;
@@ -1491,11 +1485,6 @@ declare class ApiClient {
1491
1485
  confirmRemixOffer(id: string, params: ConfirmRemixOfferParams, siwsToken: string): Promise<ApiResponse<ApiRemixOffer>>;
1492
1486
  rejectRemixOffer(id: string, siwsToken: string): Promise<ApiResponse<ApiRemixOffer>>;
1493
1487
  extendRemixOffer(id: string, days: number, siwsToken: string): Promise<ApiResponse<ApiRemixOffer>>;
1494
- getPopCollections(opts?: {
1495
- page?: number;
1496
- limit?: number;
1497
- sort?: CollectionSort;
1498
- }): Promise<ApiResponse<ApiCollection[]>>;
1499
1488
  getPopEligibility(collection: string, wallet: string): Promise<PopClaimStatus>;
1500
1489
  getPopEligibilityBatch(collection: string, wallets: string[]): Promise<PopBatchEligibilityItem[]>;
1501
1490
  getCoins(opts?: ApiCoinsQuery): Promise<ApiResponse<ApiCoin[]>>;
@@ -1509,16 +1498,12 @@ declare class ApiClient {
1509
1498
  image?: string | null;
1510
1499
  description?: string | null;
1511
1500
  }, siwsToken: string): Promise<ApiResponse<ApiCoin>>;
1512
- getDropCollections(opts?: {
1513
- page?: number;
1514
- limit?: number;
1515
- sort?: CollectionSort;
1516
- }): Promise<ApiResponse<ApiCollection[]>>;
1517
1501
  getDropMintStatus(collection: string, wallet: string): Promise<DropMintStatus>;
1518
1502
  getDropInfo(contract: string): Promise<ApiDropInfo | null>;
1519
1503
  getDropState(contract: string): Promise<ApiDropState>;
1520
1504
  getTicket(contract: string, tokenId: string): Promise<ApiTierOnchain>;
1521
1505
  getTicketCount(contract: string): Promise<number>;
1506
+ getClubMembershipCount(contract: string): Promise<number>;
1522
1507
  getClubMembership(contract: string, tokenId: string): Promise<ApiTierOnchain>;
1523
1508
  isClubMember(contract: string, tokenId: string, wallet: string): Promise<boolean>;
1524
1509
  getIpNftTokenData(contract: string, tokenId: string): Promise<ApiIpNftTokenData | null>;
package/dist/index.cjs CHANGED
@@ -239,7 +239,13 @@ var DEFAULT_MAX_DELAY_MS = 5e3;
239
239
  function sleep(ms) {
240
240
  return new Promise((resolve) => setTimeout(resolve, ms));
241
241
  }
242
- async function withRetry(fn, opts) {
242
+ function isRetryableFor(method, err) {
243
+ if (err instanceof MedialaneApiError && err.status === 429) return true;
244
+ const isRead = method === "GET" || method === "HEAD";
245
+ if (!isRead) return false;
246
+ return err instanceof MedialaneApiError && err.status >= 500 || err instanceof TypeError;
247
+ }
248
+ async function withRetry(fn, opts, method = "GET") {
243
249
  const maxAttempts = opts?.maxAttempts ?? DEFAULT_MAX_ATTEMPTS;
244
250
  const baseDelayMs = opts?.baseDelayMs ?? DEFAULT_BASE_DELAY_MS;
245
251
  const maxDelayMs = opts?.maxDelayMs ?? DEFAULT_MAX_DELAY_MS;
@@ -249,11 +255,7 @@ async function withRetry(fn, opts) {
249
255
  return await fn();
250
256
  } catch (err) {
251
257
  lastError = err;
252
- if (err instanceof MedialaneApiError && err.status < 500 && err.status !== 429) {
253
- throw err;
254
- }
255
- const isRetryable = err instanceof MedialaneApiError && (err.status >= 500 || err.status === 429) || err instanceof TypeError;
256
- if (!isRetryable || attempt === maxAttempts - 1) {
258
+ if (!isRetryableFor(method, err) || attempt === maxAttempts - 1) {
257
259
  throw err;
258
260
  }
259
261
  const retryAfterMs = err instanceof MedialaneApiError ? err.retryAfterMs : void 0;
@@ -334,7 +336,7 @@ var ApiClient = class {
334
336
  );
335
337
  }
336
338
  return response;
337
- }, this.retryOptions);
339
+ }, this.retryOptions, (init?.method ?? "GET").toUpperCase());
338
340
  if (allowed(res.status)) return null;
339
341
  return res.json();
340
342
  }
@@ -402,19 +404,6 @@ var ApiClient = class {
402
404
  `/v1/tokens/${contract}/${tokenId}/history?page=${page}&limit=${limit}`
403
405
  );
404
406
  }
405
- getCollections(page = 1, limit = 20, isKnown, sort, service, chain, standard) {
406
- const params = new URLSearchParams({ page: String(page), limit: String(limit) });
407
- if (isKnown !== void 0) params.set("isKnown", String(isKnown));
408
- if (sort) params.set("sort", sort);
409
- if (service) params.set("service", service);
410
- if (chain) params.set("chain", chain);
411
- if (standard) params.set("standard", standard);
412
- return this.get(`/v1/collections?${params}`);
413
- }
414
- getCollectionsByOwner(owner, page = 1, limit = 50) {
415
- const params = new URLSearchParams({ owner: this.addr(owner), page: String(page), limit: String(limit) });
416
- return this.get(`/v1/collections?${params}`);
417
- }
418
407
  getCollection(contract) {
419
408
  return this.get(`/v1/collections/${this.addr(contract)}`);
420
409
  }
@@ -783,10 +772,8 @@ var ApiClient = class {
783
772
  });
784
773
  }
785
774
  async checkEmail(email) {
786
- const body = await this.get(
787
- `/v1/auth/email/exists?email=${encodeURIComponent(email)}`
788
- );
789
- return { exists: body.exists, walletWaiting: body.walletWaiting === true };
775
+ const body = await this.get(`/v1/auth/email/exists?email=${encodeURIComponent(email)}`);
776
+ return { exists: body.exists };
790
777
  }
791
778
  async requestEmailCode(email) {
792
779
  await this.post("/v1/auth/email/request-code", { email });
@@ -795,15 +782,19 @@ var ApiClient = class {
795
782
  await this.post("/v1/auth/email/register-account", { email });
796
783
  }
797
784
  async verifyEmailCode(email, code) {
798
- const body = await this.post("/v1/auth/email/verify-code", { email, code });
799
- return { waitingWallets: body.waitingWallets ?? [] };
785
+ await this.post("/v1/auth/email/verify-code", { email, code });
800
786
  }
801
- claimWallet(params) {
802
- return this.post("/v1/users/me/claim-wallet", params);
787
+ /**
788
+ * Makes the passkey the only owner of the session account's wallet. `signature` is the passkey's owner-alive
789
+ * proof for the wallet. Answers 409 when the wallet is already set up.
790
+ */
791
+ setupWalletKey(params) {
792
+ return this.post("/v1/users/me/wallet/key", params);
803
793
  }
794
+ /** The session account's wallet, and whether its passkey still has to be set up (`setupWalletKey`). */
804
795
  async getSessionWallet() {
805
796
  const body = await this.post("/v1/users/me/wallet", {});
806
- return body.walletAddress ?? null;
797
+ return body.walletAddress ? { walletAddress: body.walletAddress, needsKeySetup: body.needsKeySetup === true } : null;
807
798
  }
808
799
  getMyWallet(siwsToken) {
809
800
  return this.request(
@@ -886,9 +877,6 @@ var ApiClient = class {
886
877
  headers: { "Authorization": `Bearer ${siwsToken}` }
887
878
  });
888
879
  }
889
- getPopCollections(opts = {}) {
890
- return this.getCollections(opts.page ?? 1, opts.limit ?? 20, void 0, opts.sort, "pop-protocol");
891
- }
892
880
  async getPopEligibility(collection, wallet) {
893
881
  const res = await this.get(
894
882
  `/v1/pop/eligibility/${this.addr(collection)}/${this.addr(wallet)}`
@@ -938,9 +926,6 @@ var ApiClient = class {
938
926
  headers: this.bearer(siwsToken)
939
927
  });
940
928
  }
941
- getDropCollections(opts = {}) {
942
- return this.getCollections(opts.page ?? 1, opts.limit ?? 20, void 0, opts.sort, "drop-collection");
943
- }
944
929
  async getDropMintStatus(collection, wallet) {
945
930
  const res = await this.get(
946
931
  `/v1/drop/mint-status/${this.addr(collection)}/${this.addr(wallet)}`
@@ -967,6 +952,10 @@ var ApiClient = class {
967
952
  const res = await this.get(`/v1/tickets/${this.addr(contract)}/count`);
968
953
  return res.data.count;
969
954
  }
955
+ async getClubMembershipCount(contract) {
956
+ const res = await this.get(`/v1/club/${this.addr(contract)}/count`);
957
+ return res.data.count;
958
+ }
970
959
  async getClubMembership(contract, tokenId) {
971
960
  const res = await this.get(`/v1/club/${this.addr(contract)}/${tokenId}`);
972
961
  return res.data;
@@ -1050,6 +1039,7 @@ var ApiClient = class {
1050
1039
  if (query.sort) params.set("sort", query.sort);
1051
1040
  if (query.isFeatured !== void 0) params.set("isFeatured", String(query.isFeatured));
1052
1041
  if (query.hideEmpty !== void 0) params.set("hideEmpty", String(query.hideEmpty));
1042
+ if (query.standard) params.set("standard", query.standard);
1053
1043
  if (query.chain) params.set("chain", query.chain);
1054
1044
  const qs = params.toString();
1055
1045
  return this.get(`/v1/collections${qs ? `?${qs}` : ""}`);