@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.
@@ -212,7 +212,13 @@ var DEFAULT_MAX_DELAY_MS = 5e3;
212
212
  function sleep(ms) {
213
213
  return new Promise((resolve) => setTimeout(resolve, ms));
214
214
  }
215
- async function withRetry(fn, opts) {
215
+ function isRetryableFor(method, err) {
216
+ if (err instanceof MedialaneApiError && err.status === 429) return true;
217
+ const isRead = method === "GET" || method === "HEAD";
218
+ if (!isRead) return false;
219
+ return err instanceof MedialaneApiError && err.status >= 500 || err instanceof TypeError;
220
+ }
221
+ async function withRetry(fn, opts, method = "GET") {
216
222
  const maxAttempts = opts?.maxAttempts ?? DEFAULT_MAX_ATTEMPTS;
217
223
  const baseDelayMs = opts?.baseDelayMs ?? DEFAULT_BASE_DELAY_MS;
218
224
  const maxDelayMs = opts?.maxDelayMs ?? DEFAULT_MAX_DELAY_MS;
@@ -222,11 +228,7 @@ async function withRetry(fn, opts) {
222
228
  return await fn();
223
229
  } catch (err) {
224
230
  lastError = err;
225
- if (err instanceof MedialaneApiError && err.status < 500 && err.status !== 429) {
226
- throw err;
227
- }
228
- const isRetryable = err instanceof MedialaneApiError && (err.status >= 500 || err.status === 429) || err instanceof TypeError;
229
- if (!isRetryable || attempt === maxAttempts - 1) {
231
+ if (!isRetryableFor(method, err) || attempt === maxAttempts - 1) {
230
232
  throw err;
231
233
  }
232
234
  const retryAfterMs = err instanceof MedialaneApiError ? err.retryAfterMs : void 0;
@@ -307,7 +309,7 @@ var ApiClient = class {
307
309
  );
308
310
  }
309
311
  return response;
310
- }, this.retryOptions);
312
+ }, this.retryOptions, (init?.method ?? "GET").toUpperCase());
311
313
  if (allowed(res.status)) return null;
312
314
  return res.json();
313
315
  }
@@ -375,19 +377,6 @@ var ApiClient = class {
375
377
  `/v1/tokens/${contract}/${tokenId}/history?page=${page}&limit=${limit}`
376
378
  );
377
379
  }
378
- getCollections(page = 1, limit = 20, isKnown, sort, service, chain, standard) {
379
- const params = new URLSearchParams({ page: String(page), limit: String(limit) });
380
- if (isKnown !== void 0) params.set("isKnown", String(isKnown));
381
- if (sort) params.set("sort", sort);
382
- if (service) params.set("service", service);
383
- if (chain) params.set("chain", chain);
384
- if (standard) params.set("standard", standard);
385
- return this.get(`/v1/collections?${params}`);
386
- }
387
- getCollectionsByOwner(owner, page = 1, limit = 50) {
388
- const params = new URLSearchParams({ owner: this.addr(owner), page: String(page), limit: String(limit) });
389
- return this.get(`/v1/collections?${params}`);
390
- }
391
380
  getCollection(contract) {
392
381
  return this.get(`/v1/collections/${this.addr(contract)}`);
393
382
  }
@@ -756,10 +745,8 @@ var ApiClient = class {
756
745
  });
757
746
  }
758
747
  async checkEmail(email) {
759
- const body = await this.get(
760
- `/v1/auth/email/exists?email=${encodeURIComponent(email)}`
761
- );
762
- return { exists: body.exists, walletWaiting: body.walletWaiting === true };
748
+ const body = await this.get(`/v1/auth/email/exists?email=${encodeURIComponent(email)}`);
749
+ return { exists: body.exists };
763
750
  }
764
751
  async requestEmailCode(email) {
765
752
  await this.post("/v1/auth/email/request-code", { email });
@@ -768,15 +755,19 @@ var ApiClient = class {
768
755
  await this.post("/v1/auth/email/register-account", { email });
769
756
  }
770
757
  async verifyEmailCode(email, code) {
771
- const body = await this.post("/v1/auth/email/verify-code", { email, code });
772
- return { waitingWallets: body.waitingWallets ?? [] };
758
+ await this.post("/v1/auth/email/verify-code", { email, code });
773
759
  }
774
- claimWallet(params) {
775
- return this.post("/v1/users/me/claim-wallet", params);
760
+ /**
761
+ * Makes the passkey the only owner of the session account's wallet. `signature` is the passkey's owner-alive
762
+ * proof for the wallet. Answers 409 when the wallet is already set up.
763
+ */
764
+ setupWalletKey(params) {
765
+ return this.post("/v1/users/me/wallet/key", params);
776
766
  }
767
+ /** The session account's wallet, and whether its passkey still has to be set up (`setupWalletKey`). */
777
768
  async getSessionWallet() {
778
769
  const body = await this.post("/v1/users/me/wallet", {});
779
- return body.walletAddress ?? null;
770
+ return body.walletAddress ? { walletAddress: body.walletAddress, needsKeySetup: body.needsKeySetup === true } : null;
780
771
  }
781
772
  getMyWallet(siwsToken) {
782
773
  return this.request(
@@ -859,9 +850,6 @@ var ApiClient = class {
859
850
  headers: { "Authorization": `Bearer ${siwsToken}` }
860
851
  });
861
852
  }
862
- getPopCollections(opts = {}) {
863
- return this.getCollections(opts.page ?? 1, opts.limit ?? 20, void 0, opts.sort, "pop-protocol");
864
- }
865
853
  async getPopEligibility(collection, wallet) {
866
854
  const res = await this.get(
867
855
  `/v1/pop/eligibility/${this.addr(collection)}/${this.addr(wallet)}`
@@ -911,9 +899,6 @@ var ApiClient = class {
911
899
  headers: this.bearer(siwsToken)
912
900
  });
913
901
  }
914
- getDropCollections(opts = {}) {
915
- return this.getCollections(opts.page ?? 1, opts.limit ?? 20, void 0, opts.sort, "drop-collection");
916
- }
917
902
  async getDropMintStatus(collection, wallet) {
918
903
  const res = await this.get(
919
904
  `/v1/drop/mint-status/${this.addr(collection)}/${this.addr(wallet)}`
@@ -940,6 +925,10 @@ var ApiClient = class {
940
925
  const res = await this.get(`/v1/tickets/${this.addr(contract)}/count`);
941
926
  return res.data.count;
942
927
  }
928
+ async getClubMembershipCount(contract) {
929
+ const res = await this.get(`/v1/club/${this.addr(contract)}/count`);
930
+ return res.data.count;
931
+ }
943
932
  async getClubMembership(contract, tokenId) {
944
933
  const res = await this.get(`/v1/club/${this.addr(contract)}/${tokenId}`);
945
934
  return res.data;
@@ -1023,6 +1012,7 @@ var ApiClient = class {
1023
1012
  if (query.sort) params.set("sort", query.sort);
1024
1013
  if (query.isFeatured !== void 0) params.set("isFeatured", String(query.isFeatured));
1025
1014
  if (query.hideEmpty !== void 0) params.set("hideEmpty", String(query.hideEmpty));
1015
+ if (query.standard) params.set("standard", query.standard);
1026
1016
  if (query.chain) params.set("chain", query.chain);
1027
1017
  const qs = params.toString();
1028
1018
  return this.get(`/v1/collections${qs ? `?${qs}` : ""}`);