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