@medialane/sdk 0.89.0 → 0.91.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 +65 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +14 -3
- package/dist/index.d.ts +14 -3
- package/dist/index.js +61 -1
- package/dist/index.js.map +1 -1
- package/dist/{services-vwXIiRBm.d.cts → services-D3M9dJZg.d.cts} +7 -2
- package/dist/{services-CELm1bdL.d.ts → services-DTkc0lLx.d.ts} +7 -2
- package/dist/starknet/index.d.cts +1 -1
- package/dist/starknet/index.d.ts +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1381,6 +1381,66 @@ function createRpcProxyHandler(config) {
|
|
|
1381
1381
|
return createBackendProxyHandler({ ...config, path: "/v1/rpc" });
|
|
1382
1382
|
}
|
|
1383
1383
|
|
|
1384
|
+
// src/server/ssrf-guard.ts
|
|
1385
|
+
var ALLOWED_IMAGE_CONTENT_TYPES = /* @__PURE__ */ new Set([
|
|
1386
|
+
"image/jpeg",
|
|
1387
|
+
"image/jpg",
|
|
1388
|
+
"image/png",
|
|
1389
|
+
"image/gif",
|
|
1390
|
+
"image/webp",
|
|
1391
|
+
"image/svg+xml",
|
|
1392
|
+
"image/avif",
|
|
1393
|
+
"image/bmp",
|
|
1394
|
+
"image/tiff"
|
|
1395
|
+
]);
|
|
1396
|
+
var MAX_IMAGE_REDIRECTS = 5;
|
|
1397
|
+
var MAX_IMAGE_PROXY_BYTES = 15 * 1024 * 1024;
|
|
1398
|
+
function isPrivateHost(hostname) {
|
|
1399
|
+
const h = hostname.toLowerCase().replace(/^\[|\]$/g, "");
|
|
1400
|
+
if (h === "localhost" || h === "127.0.0.1" || h === "0.0.0.0") return true;
|
|
1401
|
+
if (/^\d+$/.test(h)) {
|
|
1402
|
+
const n = parseInt(h, 10);
|
|
1403
|
+
if (n === 2130706433 || n === 0 || n >= 2886729728 && n <= 2887778303 || n >= 3232235520 && n <= 3232301055 || n >= 167772160 && n <= 184549375 || n >= 2851995648 && n <= 2852061183) return true;
|
|
1404
|
+
}
|
|
1405
|
+
if (/^0x[0-9a-f]+$/i.test(h)) {
|
|
1406
|
+
const n = parseInt(h, 16);
|
|
1407
|
+
if (n === 2130706433 || n === 0 || n >= 2886729728 && n <= 2887778303 || n >= 3232235520 && n <= 3232301055 || n >= 167772160 && n <= 184549375 || n >= 2851995648 && n <= 2852061183) return true;
|
|
1408
|
+
}
|
|
1409
|
+
if (/^0\d+\.\d+\.\d+\.\d+$/.test(h)) return true;
|
|
1410
|
+
if (h === "::1" || /^0*:0*:0*:0*:0*:0*:0*:0*1$/.test(h)) return true;
|
|
1411
|
+
const v4mapped = h.match(/^::ffff:(\d+\.\d+\.\d+\.\d+)$/i);
|
|
1412
|
+
if (v4mapped) return isPrivateHost(v4mapped[1]);
|
|
1413
|
+
if (/^10\./.test(h)) return true;
|
|
1414
|
+
if (/^172\.(1[6-9]|2\d|3[01])\./.test(h)) return true;
|
|
1415
|
+
if (/^192\.168\./.test(h)) return true;
|
|
1416
|
+
if (/^169\.254\./.test(h)) return true;
|
|
1417
|
+
if (/^100\.(6[4-9]|[7-9]\d|1[01]\d|12[0-7])\./.test(h)) return true;
|
|
1418
|
+
if (/^fe80:/i.test(h)) return true;
|
|
1419
|
+
if (/^f[cd][0-9a-f]{2}:/i.test(h)) return true;
|
|
1420
|
+
if (h.endsWith(".local")) return true;
|
|
1421
|
+
if (h === "metadata.google.internal") return true;
|
|
1422
|
+
if (h === "metadata.azure.internal") return true;
|
|
1423
|
+
return false;
|
|
1424
|
+
}
|
|
1425
|
+
function validateUrl(raw) {
|
|
1426
|
+
let parsed;
|
|
1427
|
+
try {
|
|
1428
|
+
parsed = new URL(raw);
|
|
1429
|
+
} catch {
|
|
1430
|
+
return { error: "Invalid url", status: 400 };
|
|
1431
|
+
}
|
|
1432
|
+
if (parsed.protocol !== "https:") {
|
|
1433
|
+
return { error: "Only https URLs allowed", status: 400 };
|
|
1434
|
+
}
|
|
1435
|
+
if (parsed.username || parsed.password) {
|
|
1436
|
+
return { error: "URL credentials not allowed", status: 400 };
|
|
1437
|
+
}
|
|
1438
|
+
if (isPrivateHost(parsed.hostname)) {
|
|
1439
|
+
return { error: "URL not allowed", status: 400 };
|
|
1440
|
+
}
|
|
1441
|
+
return { url: parsed };
|
|
1442
|
+
}
|
|
1443
|
+
|
|
1384
1444
|
// src/server/backend-metadata.ts
|
|
1385
1445
|
function endpoint(config, path) {
|
|
1386
1446
|
return `${config.backendUrl.replace(/\/$/, "")}/v1/metadata/${path}`;
|
|
@@ -1523,12 +1583,15 @@ function resolveSafeImageContentType(contentType) {
|
|
|
1523
1583
|
}
|
|
1524
1584
|
var MAX_IPFS_GATEWAY_RESPONSE_BYTES = 25 * 1024 * 1024;
|
|
1525
1585
|
|
|
1586
|
+
exports.ALLOWED_IMAGE_CONTENT_TYPES = ALLOWED_IMAGE_CONTENT_TYPES;
|
|
1526
1587
|
exports.ApiClient = ApiClient;
|
|
1527
1588
|
exports.CHAINS = CHAINS;
|
|
1528
1589
|
exports.DEFAULT_CHAIN = DEFAULT_CHAIN;
|
|
1529
1590
|
exports.DEFAULT_CURRENCY = DEFAULT_CURRENCY;
|
|
1530
1591
|
exports.FeeConfigSchema = FeeConfigSchema;
|
|
1531
1592
|
exports.IPFS_SAFE_CONTENT_TYPE_PREFIXES = IPFS_SAFE_CONTENT_TYPE_PREFIXES;
|
|
1593
|
+
exports.MAX_IMAGE_PROXY_BYTES = MAX_IMAGE_PROXY_BYTES;
|
|
1594
|
+
exports.MAX_IMAGE_REDIRECTS = MAX_IMAGE_REDIRECTS;
|
|
1532
1595
|
exports.MAX_IPFS_GATEWAY_RESPONSE_BYTES = MAX_IPFS_GATEWAY_RESPONSE_BYTES;
|
|
1533
1596
|
exports.MedialaneApiError = MedialaneApiError;
|
|
1534
1597
|
exports.OPEN_LICENSES = OPEN_LICENSES;
|
|
@@ -1589,6 +1652,7 @@ exports.getStarknetCoordinates = getStarknetCoordinates;
|
|
|
1589
1652
|
exports.getTokenByAddress = getTokenByAddress;
|
|
1590
1653
|
exports.getTokenBySymbol = getTokenBySymbol;
|
|
1591
1654
|
exports.hasCapability = hasCapability;
|
|
1655
|
+
exports.isPrivateHost = isPrivateHost;
|
|
1592
1656
|
exports.isSameOrigin = isSameOrigin;
|
|
1593
1657
|
exports.isServiceId = isServiceId;
|
|
1594
1658
|
exports.isTransientRpcError = isTransientRpcError;
|
|
@@ -1609,5 +1673,6 @@ exports.u256ToBigInt = u256ToBigInt;
|
|
|
1609
1673
|
exports.uploadDirectoryToBackend = uploadDirectoryToBackend;
|
|
1610
1674
|
exports.uploadFileToBackend = uploadFileToBackend;
|
|
1611
1675
|
exports.uploadJsonToBackend = uploadJsonToBackend;
|
|
1676
|
+
exports.validateUrl = validateUrl;
|
|
1612
1677
|
//# sourceMappingURL=index.cjs.map
|
|
1613
1678
|
//# sourceMappingURL=index.cjs.map
|