@medialane/sdk 0.85.11 → 0.85.13
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 +32 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +6 -3
- package/dist/index.d.ts +6 -3
- package/dist/index.js +31 -5
- package/dist/index.js.map +1 -1
- package/dist/{services-B_7IX3dM.d.ts → services-BMVi2U8T.d.ts} +1 -1
- package/dist/{services-BN4c7iT1.d.cts → services-yppVbYf6.d.cts} +1 -1
- package/dist/starknet/index.cjs +3 -2
- package/dist/starknet/index.cjs.map +1 -1
- package/dist/starknet/index.d.cts +1 -1
- package/dist/starknet/index.d.ts +1 -1
- package/dist/starknet/index.js +3 -2
- package/dist/starknet/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -495,8 +495,9 @@ var ApiClient = class {
|
|
|
495
495
|
if (query.limit !== void 0) params.set("limit", String(query.limit));
|
|
496
496
|
return this.get(`/v1/orders/counter-offers?${params}`);
|
|
497
497
|
}
|
|
498
|
-
getMetadataSignedUrl() {
|
|
499
|
-
|
|
498
|
+
getMetadataSignedUrl(kind) {
|
|
499
|
+
const params = kind ? `?kind=${kind}` : "";
|
|
500
|
+
return this.get(`/v1/metadata/signed-url${params}`);
|
|
500
501
|
}
|
|
501
502
|
uploadMetadata(metadata) {
|
|
502
503
|
return this.post("/v1/metadata/upload", metadata);
|
|
@@ -1281,6 +1282,32 @@ function createFailoverFetch(urls, options = {}) {
|
|
|
1281
1282
|
return failover;
|
|
1282
1283
|
}
|
|
1283
1284
|
|
|
1285
|
+
// src/server/rate-limit.ts
|
|
1286
|
+
function createRateLimiter(windowMs, max) {
|
|
1287
|
+
const counts = /* @__PURE__ */ new Map();
|
|
1288
|
+
let nextSweepAt = Date.now() + windowMs;
|
|
1289
|
+
return function checkRateLimit(key) {
|
|
1290
|
+
const now = Date.now();
|
|
1291
|
+
if (now >= nextSweepAt) {
|
|
1292
|
+
for (const [k, entry2] of counts) {
|
|
1293
|
+
if (now >= entry2.resetAt) counts.delete(k);
|
|
1294
|
+
}
|
|
1295
|
+
nextSweepAt = now + windowMs;
|
|
1296
|
+
}
|
|
1297
|
+
const entry = counts.get(key);
|
|
1298
|
+
if (!entry || now >= entry.resetAt) {
|
|
1299
|
+
counts.set(key, { count: 1, resetAt: now + windowMs });
|
|
1300
|
+
return true;
|
|
1301
|
+
}
|
|
1302
|
+
if (entry.count >= max) return false;
|
|
1303
|
+
entry.count += 1;
|
|
1304
|
+
return true;
|
|
1305
|
+
};
|
|
1306
|
+
}
|
|
1307
|
+
function requestIp(req) {
|
|
1308
|
+
return req.headers.get("x-forwarded-for")?.split(",")[0].trim() ?? "unknown";
|
|
1309
|
+
}
|
|
1310
|
+
|
|
1284
1311
|
// src/server/rpc-proxy.ts
|
|
1285
1312
|
var DEFAULT_STARKNET_RPC_METHODS = [
|
|
1286
1313
|
"starknet_call",
|
|
@@ -1359,8 +1386,7 @@ function createRpcProxyHandler(config) {
|
|
|
1359
1386
|
if (!isSameOrigin(req)) {
|
|
1360
1387
|
return rpcError(-32600, "Cross-origin requests are not allowed", 403);
|
|
1361
1388
|
}
|
|
1362
|
-
|
|
1363
|
-
if (!config.checkRateLimit(ip)) {
|
|
1389
|
+
if (!config.checkRateLimit(requestIp(req))) {
|
|
1364
1390
|
return rpcError(-32005, "Too many requests", 429);
|
|
1365
1391
|
}
|
|
1366
1392
|
let body;
|
|
@@ -1558,6 +1584,7 @@ exports.chainSlug = chainSlug;
|
|
|
1558
1584
|
exports.coinHref = coinHref;
|
|
1559
1585
|
exports.collectionHref = collectionHref;
|
|
1560
1586
|
exports.createFailoverFetch = createFailoverFetch;
|
|
1587
|
+
exports.createRateLimiter = createRateLimiter;
|
|
1561
1588
|
exports.createRpcProxyHandler = createRpcProxyHandler;
|
|
1562
1589
|
exports.encodeU256 = encodeU256;
|
|
1563
1590
|
exports.formatAmount = formatAmount;
|
|
@@ -1576,6 +1603,7 @@ exports.listServices = listServices;
|
|
|
1576
1603
|
exports.normalizeAddress = normalizeAddress;
|
|
1577
1604
|
exports.normalizeHash = normalizeHash;
|
|
1578
1605
|
exports.parseAmount = parseAmount;
|
|
1606
|
+
exports.requestIp = requestIp;
|
|
1579
1607
|
exports.resolveConfig = resolveConfig;
|
|
1580
1608
|
exports.resolveFeeConfig = resolveFeeConfig;
|
|
1581
1609
|
exports.resolveSafeImageContentType = resolveSafeImageContentType;
|