@medialane/sdk 0.152.0 → 0.153.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.
@@ -92,6 +92,7 @@ var MedialaneConfigSchema = zod.z.object({
92
92
  rpcUrl: zod.z.string().url().optional(),
93
93
  backendUrl: zod.z.string().url().optional(),
94
94
  apiKey: zod.z.string().optional(),
95
+ appSource: zod.z.string().regex(/^[A-Z][A-Z0-9_]*$/).optional(),
95
96
  marketplace721Contract: zod.z.string().optional(),
96
97
  marketplaceContract: zod.z.string().optional(),
97
98
  marketplace1155Contract: zod.z.string().optional(),
@@ -116,6 +117,7 @@ function resolveConfig(raw) {
116
117
  rpcUrl: parsed.rpcUrl ?? coords.rpcUrl,
117
118
  backendUrl: parsed.backendUrl,
118
119
  apiKey: parsed.apiKey,
120
+ appSource: parsed.appSource,
119
121
  marketplace721Contract,
120
122
  marketplaceContract: marketplace721Contract,
121
123
  marketplace1155Contract: parsed.marketplace1155Contract ?? sn.marketplace1155,
@@ -266,10 +268,13 @@ function parseRetryAfter(value) {
266
268
  return void 0;
267
269
  }
268
270
  var ApiClient = class {
269
- constructor(baseUrl, apiKey, retryOptions, chain = "STARKNET") {
271
+ constructor(baseUrl, apiKey, retryOptions, chain = "STARKNET", appSource) {
270
272
  this.baseUrl = baseUrl;
271
273
  this.chain = chain;
272
- this.baseHeaders = apiKey ? { "x-api-key": apiKey } : {};
274
+ this.baseHeaders = {
275
+ ...apiKey ? { "x-api-key": apiKey } : {},
276
+ ...appSource ? { "x-app-source": appSource } : {}
277
+ };
273
278
  this.retryOptions = retryOptions;
274
279
  }
275
280
  addr(a) {
@@ -11111,7 +11116,7 @@ var MedialaneClient = class {
11111
11116
  }
11112
11117
  });
11113
11118
  } else {
11114
- this.api = new ApiClient(this.config.backendUrl, this.config.apiKey, this.config.retryOptions, this.config.chain);
11119
+ this.api = new ApiClient(this.config.backendUrl, this.config.apiKey, this.config.retryOptions, this.config.chain, this.config.appSource);
11115
11120
  }
11116
11121
  }
11117
11122
  get chain() {
@@ -11803,9 +11808,13 @@ async function requestSiwsToken({
11803
11808
  appSource
11804
11809
  }) {
11805
11810
  const base = backendUrl.replace(/\/$/, "");
11811
+ const headers = {
11812
+ "Content-Type": "application/json",
11813
+ ...appSource ? { "x-app-source": appSource } : {}
11814
+ };
11806
11815
  const nonceRes = await fetch(`${base}/v1/auth/siws/nonce`, {
11807
11816
  method: "POST",
11808
- headers: { "Content-Type": "application/json" },
11817
+ headers,
11809
11818
  body: JSON.stringify({ walletAddress })
11810
11819
  });
11811
11820
  if (!nonceRes.ok) {
@@ -11815,7 +11824,7 @@ async function requestSiwsToken({
11815
11824
  const signature = normalizeSiwsSignature(await signer.signMessage(typedData));
11816
11825
  const verifyRes = await fetch(`${base}/v1/auth/siws/verify`, {
11817
11826
  method: "POST",
11818
- headers: { "Content-Type": "application/json" },
11827
+ headers,
11819
11828
  body: JSON.stringify({ walletAddress, nonce, signature, ...appSource ? { appSource } : {} })
11820
11829
  });
11821
11830
  if (!verifyRes.ok) {