@ultimat3/storage 31.41.0 → 31.42.1
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/CLAUDE.md +1 -1
- package/package.json +2 -2
- package/src/driver-s3-client.ts +17 -1
package/CLAUDE.md
CHANGED
|
@@ -177,7 +177,7 @@ Gotchas:
|
|
|
177
177
|
- **`VARIANT_FORMATS` is this package's format vocabulary, and `IMAGE_FORMATS` is core's.** †
|
|
178
178
|
- `transformImage()` encodes at exactly `fitDimensions()`'s size, `format` explicit — anything else
|
|
179
179
|
is a layout shift. †
|
|
180
|
-
- Bun's S3 flag is `virtualHostedStyle`; our `forcePathStyle` is its inverse.
|
|
180
|
+
- Bun's S3 flag is `virtualHostedStyle`; our `forcePathStyle` is its inverse, and in virtual-hosted mode Bun takes the endpoint AS the bucket's host, so `clientTarget` puts the bucket in it (`bucketHost`) — the host `s3ObjectUrl` signs for.
|
|
181
181
|
- **No `region` signs for `auto`** (R2's; AWS refuses it) — `regionMismatch()` makes it `X_CONFIG_INVALID` naming `S3_REGION`. Full rule: `docs/history/storage.md`.
|
|
182
182
|
- The signature check runs BEFORE the expiry check. Do not reorder.
|
|
183
183
|
- `timingSafeEqual` is `@ultimat3/core`'s (`signed-url.ts` imports it) — the same
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ultimat3/storage",
|
|
3
|
-
"version": "31.
|
|
3
|
+
"version": "31.42.1",
|
|
4
4
|
"description": "Named disks over Bun.file and Bun.s3: safe keys, signed URLs, sniffed uploads",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ultimate",
|
|
@@ -43,6 +43,6 @@
|
|
|
43
43
|
"test": "bun test"
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"@ultimat3/core": "31.
|
|
46
|
+
"@ultimat3/core": "31.42.1"
|
|
47
47
|
}
|
|
48
48
|
}
|
package/src/driver-s3-client.ts
CHANGED
|
@@ -53,6 +53,18 @@ interface S3ClientConstructor {
|
|
|
53
53
|
new (options: Record<string, unknown>): S3ClientLike;
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
+
/**
|
|
57
|
+
* Bun's virtual-hosted mode takes the endpoint AS the bucket's host, so the bucket goes into it
|
|
58
|
+
* here — the host `s3ObjectUrl` signs for. The bare account endpoint sent every request to the
|
|
59
|
+
* account root (on R2: an opaque `S3Error` for a read, `ListBuckets` for a list). An endpoint
|
|
60
|
+
* that already names the bucket is kept.
|
|
61
|
+
*/
|
|
62
|
+
function bucketHost(endpoint: string, bucket: string): string {
|
|
63
|
+
const base = new URL(endpoint);
|
|
64
|
+
if (base.host.startsWith(`${bucket}.`)) return endpoint;
|
|
65
|
+
return `${base.protocol}//${bucket}.${base.host}`;
|
|
66
|
+
}
|
|
67
|
+
|
|
56
68
|
/**
|
|
57
69
|
* Everything but the key pair `Bun.S3Client` is built with — the SAME `resolveS3Target` the signed
|
|
58
70
|
* path reads, handed over explicitly so Bun never consults a second table.
|
|
@@ -61,10 +73,14 @@ export function clientTarget(options: S3DriverOptions): Record<string, unknown>
|
|
|
61
73
|
const target = resolveS3Target(options);
|
|
62
74
|
// Bun's flag is the inverse: path style means "not virtual hosted".
|
|
63
75
|
const pathStyle = options.forcePathStyle;
|
|
76
|
+
const endpoint =
|
|
77
|
+
target.endpoint === undefined || pathStyle !== false
|
|
78
|
+
? target.endpoint
|
|
79
|
+
: bucketHost(target.endpoint, options.bucket);
|
|
64
80
|
return {
|
|
65
81
|
bucket: options.bucket,
|
|
66
82
|
...(target.region === undefined ? {} : { region: target.region }),
|
|
67
|
-
...(
|
|
83
|
+
...(endpoint === undefined ? {} : { endpoint }),
|
|
68
84
|
...(pathStyle === undefined ? {} : { virtualHostedStyle: !pathStyle }),
|
|
69
85
|
...(target.sessionToken === undefined ? {} : { sessionToken: target.sessionToken }),
|
|
70
86
|
};
|