@nextlyhq/storage-vercel-blob 0.0.2-alpha.69 → 0.0.2-alpha.70

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
@@ -657,53 +657,7 @@ function ipv4ToInt(ip) {
657
657
  }
658
658
  return acc >>> 0;
659
659
  }
660
- // ../nextly/dist/storage/read-errors.mjs
661
- /**
662
- * The one way the storage layer says a read exceeded the caller's cap.
663
- *
664
- * `StorageReadOptions.maxBytes` is part of the adapter contract, so what happens
665
- * when it is exceeded belongs to the contract too. Without this each backend
666
- * refuses in its own vocabulary — the URL-addressed ones through a fetch error
667
- * carrying a `reason`, S3 through whatever its own code threw — and a caller
668
- * wanting to tell "too large" from "could not read" has to know which adapter it
669
- * is talking to. That is the thing an adapter contract exists to stop.
670
- *
671
- * Distinct from a generic internal failure because callers ACT on the
672
- * difference. The email attachment path answers an over-cap read with
673
- * `ATTACHMENT_SIZE_EXCEEDED`, which tells an author to attach something smaller;
674
- * a storage failure tells them nothing they can act on. Collapsing the two turns
675
- * a fixable refusal into an opaque error, which is the same conflation this
676
- * contract already draws between a missing key and an unreachable store.
677
- *
678
- * @module storage/read-errors
679
- */
680
- /**
681
- * A read refused because the object is larger than the caller allowed.
682
- *
683
- * Carries the numbers rather than only a message, so a caller can say what the
684
- * limit was without parsing prose — and so the message itself stays free of the
685
- * key, which should not travel to whoever asked for the file.
686
- */
687
- var StorageReadTooLargeError = class extends NextlyError {
688
- path;
689
- maxBytes;
690
- size;
691
- constructor(path, maxBytes, size) {
692
- super({
693
- code: "STORAGE_READ_TOO_LARGE",
694
- publicMessage: "The stored file is larger than the limit for this read.",
695
- logContext: {
696
- path,
697
- maxBytes,
698
- ...size === void 0 ? {} : { size }
699
- }
700
- });
701
- this.path = path;
702
- this.maxBytes = maxBytes;
703
- this.size = size;
704
- }
705
- };
706
- // ../nextly/dist/fetch-stored-bytes-CJ9Uv8it.mjs
660
+ // ../nextly/dist/validate-external-url-uHUKFZGh.mjs
707
661
  const IPV4_RE = /^(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)$/;
708
662
  /**
709
663
  * IPv4 CIDR ranges that must NEVER be the destination of an outbound
@@ -1145,6 +1099,53 @@ function isPublicIpv6(addr, allowLoopback) {
1145
1099
  if (firstHextet.startsWith("ff")) return false;
1146
1100
  return true;
1147
1101
  }
1102
+ // ../nextly/dist/storage/read-errors.mjs
1103
+ /**
1104
+ * The one way the storage layer says a read exceeded the caller's cap.
1105
+ *
1106
+ * `StorageReadOptions.maxBytes` is part of the adapter contract, so what happens
1107
+ * when it is exceeded belongs to the contract too. Without this each backend
1108
+ * refuses in its own vocabulary — the URL-addressed ones through a fetch error
1109
+ * carrying a `reason`, S3 through whatever its own code threw — and a caller
1110
+ * wanting to tell "too large" from "could not read" has to know which adapter it
1111
+ * is talking to. That is the thing an adapter contract exists to stop.
1112
+ *
1113
+ * Distinct from a generic internal failure because callers ACT on the
1114
+ * difference. The email attachment path answers an over-cap read with
1115
+ * `ATTACHMENT_SIZE_EXCEEDED`, which tells an author to attach something smaller;
1116
+ * a storage failure tells them nothing they can act on. Collapsing the two turns
1117
+ * a fixable refusal into an opaque error, which is the same conflation this
1118
+ * contract already draws between a missing key and an unreachable store.
1119
+ *
1120
+ * @module storage/read-errors
1121
+ */
1122
+ /**
1123
+ * A read refused because the object is larger than the caller allowed.
1124
+ *
1125
+ * Carries the numbers rather than only a message, so a caller can say what the
1126
+ * limit was without parsing prose — and so the message itself stays free of the
1127
+ * key, which should not travel to whoever asked for the file.
1128
+ */
1129
+ var StorageReadTooLargeError = class extends NextlyError {
1130
+ path;
1131
+ maxBytes;
1132
+ size;
1133
+ constructor(path, maxBytes, size) {
1134
+ super({
1135
+ code: "STORAGE_READ_TOO_LARGE",
1136
+ publicMessage: "The stored file is larger than the limit for this read.",
1137
+ logContext: {
1138
+ path,
1139
+ maxBytes,
1140
+ ...size === void 0 ? {} : { size }
1141
+ }
1142
+ });
1143
+ this.path = path;
1144
+ this.maxBytes = maxBytes;
1145
+ this.size = size;
1146
+ }
1147
+ };
1148
+ // ../nextly/dist/storage/fetch-stored-bytes.mjs
1148
1149
  /**
1149
1150
  * Reading bytes back from a storage service that only exposes them over HTTP.
1150
1151
  *
@@ -1240,6 +1241,10 @@ function classifyFetchFailure(error) {
1240
1241
  const successful = error.status !== void 0 && error.status >= 200 && error.status < 300;
1241
1242
  return error.reason === "response-too-large" && successful ? "oversized" : "unknown";
1242
1243
  }
1244
+ /** The deadline a stored read runs under when the caller names none. */
1245
+ const DEFAULT_READ_TIMEOUT_MS = DEFAULT_TIMEOUT_MS;
1246
+ /** The byte cap a stored read runs under when the caller names none. */
1247
+ const DEFAULT_READ_MAX_BYTES = DEFAULT_MAX_RESPONSE_BYTES;
1243
1248
  /**
1244
1249
  * The bounds a read actually runs under, defaults filled in.
1245
1250
  *
@@ -1255,8 +1260,8 @@ function classifyFetchFailure(error) {
1255
1260
  */
1256
1261
  function resolveReadBounds(options) {
1257
1262
  return {
1258
- maxBytes: options?.maxBytes ?? 10485760,
1259
- timeoutMs: options?.timeoutMs ?? 3e4
1263
+ maxBytes: options?.maxBytes ?? DEFAULT_READ_MAX_BYTES,
1264
+ timeoutMs: options?.timeoutMs ?? DEFAULT_READ_TIMEOUT_MS
1260
1265
  };
1261
1266
  }
1262
1267
  // src/adapter.ts
@@ -1431,7 +1436,7 @@ var VercelBlobStorageAdapter = class {
1431
1436
  * @returns The blob's bytes, or `null` when it does not exist
1432
1437
  */
1433
1438
  async read(filePath, options) {
1434
- const deadline = AbortSignal.timeout(options?.timeoutMs ?? 3e4);
1439
+ const deadline = AbortSignal.timeout(options?.timeoutMs ?? DEFAULT_READ_TIMEOUT_MS);
1435
1440
  let target;
1436
1441
  try {
1437
1442
  const meta = await (0, _vercel_blob.head)(filePath, {