@medialane/sdk 0.103.0 → 0.104.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.cjs CHANGED
@@ -1280,8 +1280,23 @@ var PUBLIC_RPC_FALLBACKS = [
1280
1280
  "https://rpc.starknet.lava.build"
1281
1281
  ];
1282
1282
  var TRANSIENT_BODY_RE = /"code"\s*:\s*-32001|"code"\s*:\s*-32603|unable to complete|rate.?limit|too many|throttl|exceed.*quota|temporarily unavailable|service unavailable|overload|gateway.*time|upstream.*time|backend.*error/i;
1283
+ var POLICY_REFUSAL_CODES = [-32003, -32005, -32600];
1284
+ function isPolicyRefusal(input) {
1285
+ let body = input.body;
1286
+ if (typeof body === "string") {
1287
+ try {
1288
+ body = JSON.parse(body);
1289
+ } catch {
1290
+ return false;
1291
+ }
1292
+ }
1293
+ const err = body?.error;
1294
+ const code = err && typeof err === "object" ? err.code : void 0;
1295
+ return typeof code === "number" && POLICY_REFUSAL_CODES.includes(code);
1296
+ }
1283
1297
  function isTransientRpcError(input) {
1284
1298
  const { status, body } = input;
1299
+ if (isPolicyRefusal({ body })) return false;
1285
1300
  if (typeof status === "number" && (status === 429 || status >= 500)) return true;
1286
1301
  if (body == null) return false;
1287
1302
  if (typeof body === "object") {
@@ -1327,6 +1342,16 @@ function createFailoverFetch(urls, options = {}) {
1327
1342
  };
1328
1343
  return failover;
1329
1344
  }
1345
+ var PAID_UPSTREAM_MARKERS = [
1346
+ "rpc.starknet.lava.build",
1347
+ "g.alchemy.com",
1348
+ "ALCHEMY_RPC_URL",
1349
+ "STARKNET_RPC_URL",
1350
+ "AVNU_PAYMASTER_API_KEY",
1351
+ "@avnu/avnu-sdk",
1352
+ "api.pinata.cloud",
1353
+ "PINATA_JWT"
1354
+ ];
1330
1355
 
1331
1356
  // src/server/rate-limit.ts
1332
1357
  function createRateLimiter(windowMs, max) {
@@ -1640,6 +1665,8 @@ exports.MAX_IMAGE_REDIRECTS = MAX_IMAGE_REDIRECTS;
1640
1665
  exports.MAX_IPFS_GATEWAY_RESPONSE_BYTES = MAX_IPFS_GATEWAY_RESPONSE_BYTES;
1641
1666
  exports.MedialaneApiError = MedialaneApiError;
1642
1667
  exports.OPEN_LICENSES = OPEN_LICENSES;
1668
+ exports.PAID_UPSTREAM_MARKERS = PAID_UPSTREAM_MARKERS;
1669
+ exports.POLICY_REFUSAL_CODES = POLICY_REFUSAL_CODES;
1643
1670
  exports.PUBLIC_RPC_FALLBACKS = PUBLIC_RPC_FALLBACKS;
1644
1671
  exports.RESERVED_TRAITS = RESERVED_TRAITS;
1645
1672
  exports.STARKNET_COLLECTION_1155_CLASS_HASH = STARKNET_COLLECTION_1155_CLASS_HASH;
@@ -1700,6 +1727,7 @@ exports.getStarknetCoordinates = getStarknetCoordinates;
1700
1727
  exports.getTokenByAddress = getTokenByAddress;
1701
1728
  exports.getTokenBySymbol = getTokenBySymbol;
1702
1729
  exports.hasCapability = hasCapability;
1730
+ exports.isPolicyRefusal = isPolicyRefusal;
1703
1731
  exports.isPrivateHost = isPrivateHost;
1704
1732
  exports.isSameOrigin = isSameOrigin;
1705
1733
  exports.isServiceId = isServiceId;