@medialane/sdk 0.85.8 → 0.85.10

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
@@ -1335,11 +1335,39 @@ function buildAssetMetadata(input) {
1335
1335
  };
1336
1336
  }
1337
1337
 
1338
+ // src/utils/ipfs-gateway.ts
1339
+ var CID_PATH_PATTERN = /^(Qm[1-9A-HJ-NP-Za-km-z]{44,}|b[a-z2-7]{58,})(\/[\w.\-/]*)?$/;
1340
+ function isValidIpfsCidPath(cidPath) {
1341
+ if (!CID_PATH_PATTERN.test(cidPath)) return false;
1342
+ if (cidPath.split("/").includes("..")) return false;
1343
+ return true;
1344
+ }
1345
+ var IPFS_SAFE_CONTENT_TYPE_PREFIXES = [
1346
+ "image/jpeg",
1347
+ "image/png",
1348
+ "image/gif",
1349
+ "image/webp",
1350
+ "image/avif",
1351
+ "image/svg+xml",
1352
+ "video/",
1353
+ "audio/",
1354
+ "model/",
1355
+ "font/",
1356
+ "application/json",
1357
+ "application/octet-stream"
1358
+ ];
1359
+ function resolveSafeImageContentType(contentType) {
1360
+ return IPFS_SAFE_CONTENT_TYPE_PREFIXES.some((p) => contentType.startsWith(p)) ? contentType : "application/octet-stream";
1361
+ }
1362
+ var MAX_IPFS_GATEWAY_RESPONSE_BYTES = 25 * 1024 * 1024;
1363
+
1338
1364
  exports.ApiClient = ApiClient;
1339
1365
  exports.CHAINS = CHAINS;
1340
1366
  exports.DEFAULT_CHAIN = DEFAULT_CHAIN;
1341
1367
  exports.DEFAULT_CURRENCY = DEFAULT_CURRENCY;
1342
1368
  exports.FeeConfigSchema = FeeConfigSchema;
1369
+ exports.IPFS_SAFE_CONTENT_TYPE_PREFIXES = IPFS_SAFE_CONTENT_TYPE_PREFIXES;
1370
+ exports.MAX_IPFS_GATEWAY_RESPONSE_BYTES = MAX_IPFS_GATEWAY_RESPONSE_BYTES;
1343
1371
  exports.MedialaneApiError = MedialaneApiError;
1344
1372
  exports.OPEN_LICENSES = OPEN_LICENSES;
1345
1373
  exports.PUBLIC_RPC_FALLBACKS = PUBLIC_RPC_FALLBACKS;
@@ -1396,12 +1424,14 @@ exports.getTokenBySymbol = getTokenBySymbol;
1396
1424
  exports.hasCapability = hasCapability;
1397
1425
  exports.isServiceId = isServiceId;
1398
1426
  exports.isTransientRpcError = isTransientRpcError;
1427
+ exports.isValidIpfsCidPath = isValidIpfsCidPath;
1399
1428
  exports.listServices = listServices;
1400
1429
  exports.normalizeAddress = normalizeAddress;
1401
1430
  exports.normalizeHash = normalizeHash;
1402
1431
  exports.parseAmount = parseAmount;
1403
1432
  exports.resolveConfig = resolveConfig;
1404
1433
  exports.resolveFeeConfig = resolveFeeConfig;
1434
+ exports.resolveSafeImageContentType = resolveSafeImageContentType;
1405
1435
  exports.shortenAddress = shortenAddress;
1406
1436
  exports.stringifyBigInts = stringifyBigInts;
1407
1437
  exports.u256ToBigInt = u256ToBigInt;