@ultimat3/storage 31.23.0 → 31.25.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/CLAUDE.md CHANGED
@@ -44,7 +44,7 @@ A rule marked `†` has its full text in [`docs/history/storage-rules.md`](../..
44
44
  | `multipart.ts` / `driver-s3-multipart*.ts` / `driver-s3-put-stream.ts` | part arithmetic + `MultipartCapability`; the six signed calls + s3's capability; the pump |
45
45
  | `grant-multipart.ts` / `upload-client-multipart.ts` / `accept-part.ts` / `multipart-staged.ts` | uploads in parts: server calls, browser, local part PUT, local/memory sessions |
46
46
  | `expire.ts` | `expireObjects`, `abortStaleUploads`, `objectPurgeTarget` |
47
- | `driver-local-stream.ts` / `driver-s3-sse.ts` / `errors-stream.ts` | the staged local stream; the s3 SSE refusal; the stream codes |
47
+ | `driver-local-stream.ts` / `driver-s3-sse.ts` / `errors-stream.ts` | the staged local stream; `serverSideEncryption` as s3's signed-PUT headers; the stream codes |
48
48
  | `driver-s3-settle.ts` | a lost Complete/PUT answer, settled by a stat (size + S3's etag of the bytes sent: MD5, or MD5-of-part-MD5s `-N`), then for multipart by an abort (204 = was open, nothing stored; 404 = completed, stat again). Neither settles: `X_STORAGE_WRITE_OUTCOME_UNKNOWN`, never `X_STORAGE_PUT_FAILED`. Plain `put()` settles the same way (`settleLostPut`); `isAnswered` (coded, or Bun's `S3Error`) is what counts as the provider answering |
49
49
  | `range.ts` | `get(key, { range })`: screen + `servedRange` (`errors-range.ts`); s3's one-GET read is `driver-s3-range.ts` |
50
50
  | `driver-local.ts` | dev default over `Bun.file`, `.meta/` sidecars; listing is `driver-local-list.ts` (`Bun.Glob`, cursor, `listFailed`), removal `driver-local-remove.ts` (a refused unlink vs one already gone) |
@@ -121,7 +121,7 @@ Gotchas:
121
121
  `X_STORAGE_LIST_FAILED`, whose `fix` the DRIVER supplies.
122
122
  - **`head()` and `list()` NEVER read an object's bytes** — an unknowable etag is `''`, as on s3.
123
123
  `get()` hashes bytes it holds; `copy()` passes `hash: true`, so no sidecar records `etag: ''`.
124
- - **s3 `put()` with `metadata`/`cacheControl`/`retention`/`legalHold` is ONE signed PUT** (core's
124
+ - **s3 `put()` with `metadata`/`cacheControl`/`serverSideEncryption`/`retention`/`legalHold` is ONE signed PUT** (core's
125
125
  `signAwsRequest`; Bun's `write` takes no header); a plain `put()` stays on Bun. Reads stay Bun's
126
126
  HEAD, so s3 `get()` reports neither field — pinned in `driver-parity.test.ts`.
127
127
  - **Object Lock: local/memory REFUSE delete/overwrite/copy-onto** (`X_STORAGE_OBJECT_LOCKED`);
@@ -142,7 +142,11 @@ Gotchas:
142
142
  `NotFound`/`ENOENT` or a 404), local on `ENOENT`; else `X_STORAGE_DELETE_FAILED`, fix per driver.
143
143
  - **`toBytes` takes a `ByteLimit`, and there is no unbounded variant**; one default,
144
144
  `DEFAULT_MAX_UPLOAD_BYTES` (`upload.ts`). †
145
- - **`serverSideEncryption` is declared and refused by BOTH drivers.** Full rule: `docs/history/storage.md`.
145
+ - **`serverSideEncryption` is SENT by s3 and refused by local/memory** (`As of 2026-11`): s3 puts it on
146
+ the signed PUT or a `putStream`'s multipart Create (`x-amz-server-side-encryption`, `-aws-kms-key-id`;
147
+ `sseHeaders`), local and memory
148
+ refuse it as `X_INVARIANT` (`refuseUnsupportedPut` in `driver-local-write.ts`) — plain bytes are
149
+ not encrypted at rest. No driver raises `X_NOT_IMPLEMENTED`; it stays borrowed (public type).
146
150
  - **The `uploadScanner` port is the ONE scan path** (`As of 31.0.0`; the `quarantine: true` segment
147
151
  and `releaseQuarantine` are retired). An out-of-band decision — a review, an async vendor scan —
148
152
  is the verdict `hold`, keyed by `(ScanInput.pendingKey, ScanInput.revision)` — the etag, or the bytes' sha256 (31.3; `pendingKey` alone cleared a rewrite): `X_STORAGE_QUARANTINED` (409), upload
package/README.md CHANGED
@@ -219,9 +219,10 @@ past the end is `X_STORAGE_RANGE_UNSATISFIABLE`. `stream(key, { etag })` and
219
219
  `streamRange(key, range, { etag })` serve that revision only — another is `X_STORAGE_OBJECT_CHANGED`
220
220
  (409): s3 sends `If-Match`, local checks the etag at the call and again at the first read, memory compares. `/_storage`
221
221
  pins every read to the etag its headers came from. `putStream` takes `contentType`, `cacheControl`,
222
- `metadata` and a REQUIRED `maxBytes` (`PutStreamOptions`). Past it the source is cancelled, nothing
223
- is stored and the key stays as it was (`X_STORAGE_TOO_LARGE`). `checksum`, `retention`, `legalHold`
224
- and `serverSideEncryption` need the bytes up front: the type omits them and an untyped caller gets
222
+ `metadata`, `serverSideEncryption` (s3 sends it on the PUT or the multipart Create; local and memory
223
+ refuse it, `X_INVARIANT`) and a REQUIRED `maxBytes` (`PutStreamOptions`). Past it the source is cancelled, nothing
224
+ is stored and the key stays as it was (`X_STORAGE_TOO_LARGE`). `checksum`, `retention` and `legalHold`
225
+ need the bytes up front: the type omits them and an untyped caller gets
225
226
  `X_INVARIANT`. On s3 a body under one part is one signed PUT and past it a signed multipart upload,
226
227
  8 MiB parts (doubled every 1,000 parts, so 10,000 reach past S3's 5 TiB; never derived from
227
228
  `maxBytes`), up to `STREAM_PART_BUFFERS` (4) parts held at once — in flight plus the one filling,
@@ -289,13 +290,16 @@ lock — on S3 it is per version and set by the request. The local refusal is in
289
290
 
290
291
  ## Server-side encryption, storage classes, lifecycle
291
292
 
292
- `PutOptions.serverSideEncryption` exists so the gap is visible **at the type level**, and every
293
- shipped driver refuses it (`X_NOT_IMPLEMENTED`) with the out-of-band command in the `fix`.
294
- `Bun.S3Client` exposes `acl`, `storageClass` and `type` and nothing for
295
- `x-amz-server-side-encryption*`; a local disk writes plain files. A typed refusal an engineer
296
- meets at the call site beats a silent absence discovered during a security review.
293
+ `PutOptions.serverSideEncryption` is per-object encryption, honoured where the disk can honour it:
297
294
 
298
- Encryption at rest is therefore a **bucket default**, and so are bucket lifecycle rules, storage
295
+ | Disk | `put(key, body, { serverSideEncryption })` |
296
+ |---|---|
297
+ | `s3Driver` | **sent**, on one signed PUT (`Bun.S3Client` has no field for it): `x-amz-server-side-encryption: AES256` or `aws:kms`, plus `x-amz-server-side-encryption-aws-kms-key-id` when `kmsKeyId` is given (absent: the bucket's default key). An unknown algorithm, a `kmsKeyId` with `AES256`, or a key id that cannot travel as a header is `X_INVARIANT` before a byte moves |
298
+ | `localDriver`, `memoryStorageDriver` | **refused**, `X_INVARIANT` (the put-option refusal `assertPutOptions` makes): plain bytes on disk or in a `Map` are not encrypted at rest, and recording the request would answer a security review with a field the disk never honoured |
299
+
300
+ `putStream` takes it the same way: s3 sends it on the one signed PUT or the multipart Create,
301
+ local and memory refuse it. A **bucket default** is still the rule for
302
+ everything written without the option — and so are bucket lifecycle rules, storage
299
303
  classes and cross-region replication: all four are bucket-side configuration and belong to
300
304
  terraform, not to the framework (axiom 7 — zero platform primitives). Ultimate half-building any of
301
305
  them would be a second place to look for the same setting.
@@ -596,7 +600,6 @@ name is not found.
596
600
  | `X_STORAGE_READ_FAILED` | the disk REFUSED a `get`/`stat`/`exists`/`stream` or the read half of a `copy` — a denied `s3:GetObject`, a throttle, an unreadable file. An **absent** object is still `X_STORAGE_NOT_FOUND`, including one deleted between the existence check and the read |
597
601
  | `X_STORAGE_RANGE_UNSATISFIABLE` | `get(key, { range })` whose first byte is at or past the object's size — the 416 |
598
602
  | `X_STORAGE_KEY_CONFLICT` | local and memory disks (never s3): the key's path is another key's directory, or the reverse (`a` and `a/b`) |
599
- | `X_NOT_IMPLEMENTED` | `serverSideEncryption` on any driver |
600
603
  | `X_ENV_MISSING` | core's: S3 credential env vars, or a `localDriver` built outside development where neither `signingSecret` nor `STORAGE_SIGNING_SECRET` holds a secret other than the published `DEV_SIGNING_SECRET` |
601
604
  | `X_IMAGE_UNSUPPORTED` | core's: an `avif` encode, a source no built-in decoder reads, or a `variantKey` format no variant can carry |
602
605
  | `X_IMAGE_DECODE_FAILED` | core's: truncated or corrupt image bytes |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ultimat3/storage",
3
- "version": "31.23.0",
3
+ "version": "31.25.0",
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.23.0"
46
+ "@ultimat3/core": "31.25.0"
47
47
  }
48
48
  }
@@ -5,25 +5,25 @@
5
5
  // why: Bun has no `rename` and no `mkdir` — `Bun.write` creates parents and replaces in place,
6
6
  // which is exactly the non-atomic write this file exists to stop. Delete both the day Bun ships them.
7
7
  import { mkdir, rename } from 'node:fs/promises';
8
- import { NotImplementedError, renderFixShellArg, stringField } from '@ultimat3/core';
8
+ import { assert, renderFixShellArg, stringField } from '@ultimat3/core';
9
9
  import type { PutOptions } from './driver';
10
10
  import type { Sidecar } from './driver-local-sidecar';
11
11
  import { isStorageError, keyConflict, putFailed } from './errors';
12
12
  import { META_DIR } from './path';
13
13
 
14
14
  /**
15
- * A POSIX file is not encrypted at rest by this driver, and recording the request in the sidecar
16
- * would answer a security review with a field the disk never honoured. Refused on the DEV disk
17
- * too, and deliberately: a `put()` that succeeds locally and throws in production is a gap an app
18
- * meets on the worst day, and both drivers refusing is one rule instead of two.
15
+ * A file under one root (or a byte array in a Map) is not encrypted at rest by the disk, and
16
+ * recording the request would answer a security review with a field the disk never honoured — so
17
+ * the option is refused as every other put option a disk cannot take is (`assertPutOptions`,
18
+ * `X_INVARIANT`), on the local AND the memory disk. The s3 disk sends it
19
+ * (`x-amz-server-side-encryption`, `driver-s3-sse.ts`).
19
20
  */
20
- export function refuseUnsupportedPut(putOptions?: PutOptions): void {
21
- if (putOptions?.serverSideEncryption === undefined) return;
22
- throw new NotImplementedError({
23
- cause:
24
- 'server-side encryption on the local driver (it writes plain files under one root) is not implemented by this driver — drop serverSideEncryption from put() and encrypt the disk itself: an s3Driver over a bucket with a default KMS rule, or a LUKS/FileVault volume under root',
25
- fix: 'put(key, body)',
26
- });
21
+ export function refuseUnsupportedPut(driver: string, putOptions?: PutOptions): void {
22
+ assert(
23
+ putOptions?.serverSideEncryption === undefined,
24
+ `put() on the ${driver} disk was given serverSideEncryption, and this disk stores plain bytes — it cannot encrypt one object at rest`,
25
+ `put(key, body) without serverSideEncryption on the ${driver} disk — or put to an s3Driver({ bucket }) disk, which sends it as x-amz-server-side-encryption; encrypt the volume itself (LUKS/FileVault) for a local root`,
26
+ );
27
27
  }
28
28
 
29
29
  /** Inside `.meta/`, so the listing's one filter already keeps a staged file out of the keys. */
@@ -210,7 +210,7 @@ export function localDriver(options: LocalDriverOptions): StorageDriver {
210
210
 
211
211
  async put(key: string, body: StorageBody, putOptions?: PutOptions): Promise<StorageObject> {
212
212
  const safe = safeKey(key);
213
- refuseUnsupportedPut(putOptions);
213
+ refuseUnsupportedPut(DRIVER_NAME, putOptions);
214
214
  assertPutOptions(DRIVER_NAME, putOptions);
215
215
  assertObjectLockOptions(DRIVER_NAME, putOptions, clock);
216
216
  const bytes = await toBytes(body, {
@@ -255,6 +255,7 @@ export function localDriver(options: LocalDriverOptions): StorageDriver {
255
255
  ): Promise<StorageObject> {
256
256
  const safe = safeKey(key);
257
257
  const maxBytes = assertPutStream(DRIVER_NAME, body, streamOptions);
258
+ refuseUnsupportedPut(DRIVER_NAME, streamOptions);
258
259
  const input = { root, key: safe, disk: registered, body, maxBytes, clock };
259
260
  return putLocalStream(input, streamOptions, (then) =>
260
261
  oneAtATime(safe, async () => {
@@ -10,7 +10,6 @@ import {
10
10
  type Clock,
11
11
  finiteCount,
12
12
  isUltimateError,
13
- NotImplementedError,
14
13
  type Page,
15
14
  pageOf,
16
15
  systemClock,
@@ -37,6 +36,7 @@ import {
37
36
  toBytes,
38
37
  } from './driver';
39
38
  import type { LocalDriverOptions } from './driver-local';
39
+ import { refuseUnsupportedPut } from './driver-local-write';
40
40
  import { keyInTheWay } from './driver-memory-conflict';
41
41
  import { memoryPartStore } from './driver-memory-multipart';
42
42
  import { checksumMismatch, getTooLarge, keyConflict, objectNotFound, putFailed } from './errors';
@@ -204,15 +204,9 @@ export function memoryStorageDriver(options: MemoryStorageDriverOptions = {}): M
204
204
 
205
205
  async put(key: string, body: StorageBody, putOptions?: PutOptions): Promise<StorageObject> {
206
206
  const safe = assertSafeKey(key);
207
- // The same refusal both shipped disks make: a `put()` that succeeds in a test and throws in
208
- // production is a gap an app meets on the worst day.
209
- if (putOptions?.serverSideEncryption !== undefined) {
210
- throw new NotImplementedError({
211
- cause:
212
- 'server-side encryption on the memory driver (it holds bytes in a Map) is not implemented by this driver — drop serverSideEncryption from put() and encrypt the disk itself: an s3Driver over a bucket with a default KMS rule',
213
- fix: 'put(key, body)',
214
- });
215
- }
207
+ // The local disk's refusal: neither stores encrypted bytes, and the memory disk stands in
208
+ // for the local one in tests.
209
+ refuseUnsupportedPut(DRIVER_NAME, putOptions);
216
210
  assertPutOptions(DRIVER_NAME, putOptions);
217
211
  assertObjectLockOptions(DRIVER_NAME, putOptions, clock);
218
212
  const bytes = await toBytes(body, {
@@ -236,6 +230,7 @@ export function memoryStorageDriver(options: MemoryStorageDriverOptions = {}): M
236
230
  ): Promise<StorageObject> {
237
231
  const safe = assertSafeKey(key);
238
232
  const maxBytes = assertPutStream(DRIVER_NAME, body, streamOptions);
233
+ refuseUnsupportedPut(DRIVER_NAME, streamOptions);
239
234
  refuseOverwrite(safe, 'overwrite');
240
235
  const chunks: Uint8Array[] = [];
241
236
  const limit = streamLimit(DRIVER_NAME, safe, maxBytes);
@@ -1,11 +1,12 @@
1
1
  // Single responsibility: the two s3 calls `Bun.S3Client` cannot make — a PUT carrying user
2
- // metadata, `Cache-Control` and Object Lock headers, and the `?retention` / `?legal-hold` reads
2
+ // metadata, `Cache-Control`, server-side encryption and Object Lock headers, and the `?retention` / `?legal-hold` reads
3
3
  // behind `retentionOf` — over the signed wire in `driver-s3-signed.ts`, answered in this package's
4
4
  // vocabulary. A plain `put()` never comes here: it stays on the Bun client.
5
5
 
6
6
  import { assert, describeValue } from '@ultimat3/core';
7
7
  import { DEFAULT_CONTENT_TYPE, HEADER_VALUE, type PutOptions } from './driver';
8
8
  import { type S3Refusal, type S3WireOptions, sendSigned, xmlField } from './driver-s3-signed';
9
+ import { sseHeaders } from './driver-s3-sse';
9
10
  import { isRetentionMode, type ObjectLock } from './object-lock';
10
11
 
11
12
  /** RFC 9110 `token` — the only bytes an `x-amz-meta-<name>` header name may carry. */
@@ -16,6 +17,7 @@ export function needsSignedPut(options: PutOptions | undefined): boolean {
16
17
  return (
17
18
  options?.metadata !== undefined ||
18
19
  options?.cacheControl !== undefined ||
20
+ options?.serverSideEncryption !== undefined ||
19
21
  options?.retention !== undefined ||
20
22
  options?.legalHold !== undefined
21
23
  );
@@ -35,6 +37,7 @@ export function putHeaders(bytes: Uint8Array, options: PutOptions): Record<strin
35
37
  export function objectHeaders(options: PutOptions): Record<string, string> {
36
38
  const headers: Record<string, string> = {
37
39
  'content-type': options.contentType ?? DEFAULT_CONTENT_TYPE,
40
+ ...sseHeaders(options),
38
41
  };
39
42
  if (options.cacheControl !== undefined) {
40
43
  assert(
@@ -1,29 +1,40 @@
1
- // Single responsibility: the one `put()` option the s3 disk cannot honour, refused by name with the
2
- // bucket-wide command that does the job instead.
1
+ // Single responsibility: per-object server-side encryption on the s3 disk — `serverSideEncryption`
2
+ // as the `x-amz-server-side-encryption*` headers of the signed PUT, screened before a byte moves.
3
+ // `Bun.S3Client` has no field for it, so an SSE put always rides the signed wire.
3
4
 
4
- import { NotImplementedError, renderFixLiteral, renderFixShellArg } from '@ultimat3/core';
5
- import type { PutOptions } from './driver';
5
+ import { assert, describeValue } from '@ultimat3/core';
6
+ import { HEADER_VALUE, type PutOptions } from './driver';
7
+
8
+ const ALGORITHMS: readonly string[] = ['AES256', 'aws:kms'];
6
9
 
7
10
  /**
8
- * Everything `put()` may be handed that this driver cannot honour, refused before a byte moves.
9
- * A typed refusal at the call site is the whole point: `serverSideEncryption` exists on
10
- * `PutOptions` so that "this disk cannot prove per-object encryption" is something an engineer
11
- * meets while writing the call, not while answering a security review.
11
+ * The headers `serverSideEncryption` becomes; none without it. What the provider would answer with
12
+ * a 400 — an algorithm it does not know, a key id beside `AES256`, a key id that cannot travel as a
13
+ * header — is refused here instead, so a refused write is never mistaken for a lost one.
12
14
  */
13
- export function refuseUnsupportedPut(bucket: string, putOptions?: PutOptions): void {
14
- const sse = putOptions?.serverSideEncryption;
15
- if (sse === undefined) return;
16
- // The key id is the caller's own option, spliced into single-quoted JSON: `renderFixLiteral`
17
- // escapes the `"` and `\` JSON needs, and a `'` — the one byte live inside single quotes — makes
18
- // it the placeholder rather than ending the argument (plan 101 row S12).
19
- const keyId = sse.kmsKeyId?.includes("'") === false ? sse.kmsKeyId : undefined;
20
- const bucketArg = renderFixShellArg(bucket, "'<bucket>'");
21
- throw new NotImplementedError({
22
- cause:
23
- 'per-object server-side encryption on the s3 driver (Bun.S3Client exposes acl, storageClass and type, and nothing for x-amz-server-side-encryption) is not implemented by this driver — set it bucket-wide with the command in fix, then drop serverSideEncryption from put()',
24
- fix:
25
- sse.algorithm === 'aws:kms'
26
- ? `aws s3api put-bucket-encryption --bucket ${bucketArg} --server-side-encryption-configuration '{"Rules":[{"ApplyServerSideEncryptionByDefault":{"SSEAlgorithm":"aws:kms","KMSMasterKeyID":${renderFixLiteral(keyId, '"<key-arn>"')}},"BucketKeyEnabled":true}]}'`
27
- : `aws s3api put-bucket-encryption --bucket ${bucketArg} --server-side-encryption-configuration '{"Rules":[{"ApplyServerSideEncryptionByDefault":{"SSEAlgorithm":"AES256"},"BucketKeyEnabled":true}]}'`,
28
- });
15
+ export function sseHeaders(options: PutOptions): Record<string, string> {
16
+ const sse = options.serverSideEncryption;
17
+ if (sse === undefined) return {};
18
+ const algorithm: unknown = sse.algorithm;
19
+ assert(
20
+ typeof algorithm === 'string' && ALGORITHMS.includes(algorithm),
21
+ `put() on the s3 disk was given a serverSideEncryption algorithm the provider does not take (${describeValue(algorithm)})`,
22
+ "put(key, body, { serverSideEncryption: { algorithm: 'AES256' } }) — or algorithm: 'aws:kms'",
23
+ );
24
+ const keyId: unknown = sse.kmsKeyId;
25
+ if (keyId === undefined) return { 'x-amz-server-side-encryption': algorithm };
26
+ assert(
27
+ algorithm === 'aws:kms',
28
+ 'put() on the s3 disk was given serverSideEncryption.kmsKeyId with AES256, which takes no key',
29
+ "put(key, body, { serverSideEncryption: { algorithm: 'aws:kms', kmsKeyId } }) — or drop kmsKeyId for AES256",
30
+ );
31
+ assert(
32
+ typeof keyId === 'string' && keyId !== '' && HEADER_VALUE.test(keyId),
33
+ `put() on the s3 disk was given a serverSideEncryption.kmsKeyId that cannot travel as a header (${describeValue(keyId)})`,
34
+ "put(key, body, { serverSideEncryption: { algorithm: 'aws:kms', kmsKeyId: 'arn:aws:kms:<region>:<account>:key/<id>' } }) — or omit kmsKeyId for the bucket's default key",
35
+ );
36
+ return {
37
+ 'x-amz-server-side-encryption': algorithm,
38
+ 'x-amz-server-side-encryption-aws-kms-key-id': keyId,
39
+ };
29
40
  }
package/src/driver-s3.ts CHANGED
@@ -42,7 +42,6 @@ import { readS3Range } from './driver-s3-range';
42
42
  import { regionMismatch } from './driver-s3-region';
43
43
  import { settleLostPut } from './driver-s3-settle';
44
44
  import type { S3FetchLike, S3Refusal } from './driver-s3-signed';
45
- import { refuseUnsupportedPut } from './driver-s3-sse';
46
45
  import { streamS3Pinned } from './driver-s3-stream';
47
46
  import {
48
47
  checksumMismatch,
@@ -221,7 +220,6 @@ export function s3Driver(options: S3DriverOptions): StorageDriver {
221
220
 
222
221
  async put(key: string, body: StorageBody, putOptions?: PutOptions): Promise<StorageObject> {
223
222
  const safe = assertSafeKey(key);
224
- refuseUnsupportedPut(options.bucket, putOptions);
225
223
  assertPutOptions(DRIVER_NAME, putOptions);
226
224
  assertObjectLockOptions(DRIVER_NAME, putOptions, clock);
227
225
  // Buffered on purpose: size and checksum must be known before the object exists — so this
package/src/driver.ts CHANGED
@@ -45,12 +45,9 @@ export interface StorageObject extends StorageListEntry {
45
45
  }
46
46
 
47
47
  /**
48
- * Encryption at rest, per object. Declared so the gap is visible at the type level: an engineer
49
- * asked "can you prove which key encrypted this object?" must meet the answer at the call site,
50
- * not by reading the driver. NO driver honours it yet — `Bun.S3Client` exposes `acl`,
51
- * `storageClass` and `type` and nothing for `x-amz-server-side-encryption*`, and a POSIX file is
52
- * not encrypted at all — so both drivers refuse a `put()` carrying one (`X_NOT_IMPLEMENTED`) with
53
- * the out-of-band bucket-default command in the `fix`. A typed refusal beats a silent absence.
48
+ * Encryption at rest, per object. The s3 disk SENDS it, as `x-amz-server-side-encryption*` on the
49
+ * signed PUT (`driver-s3-sse.ts`); the local and memory disks store plain bytes and REFUSE it
50
+ * (`X_INVARIANT`, `refuseUnsupportedPut`) rather than record a claim the disk never honoured.
54
51
  */
55
52
  export interface ServerSideEncryption {
56
53
  readonly algorithm: 'AES256' | 'aws:kms';
@@ -69,7 +66,7 @@ export interface PutOptions extends ObjectLockOptions {
69
66
  readonly metadata?: Readonly<Record<string, string>> | undefined;
70
67
  /** base64 SHA-256 of the body. Supplied means verified: a mismatch is a rejected write. */
71
68
  readonly checksum?: string | undefined;
72
- /** Refused by every shipped driver — see `ServerSideEncryption`. */
69
+ /** Sent by s3, refused by local and memory — see `ServerSideEncryption`. */
73
70
  readonly serverSideEncryption?: ServerSideEncryption | undefined;
74
71
  }
75
72
 
package/src/errors.ts CHANGED
@@ -45,8 +45,10 @@ export const STORAGE_OWNED_ERROR_CODES = [
45
45
  ] as const;
46
46
 
47
47
  /**
48
- * `X_NOT_IMPLEMENTED` is `@ultimat3/core`'s. The drivers throw core's own `NotImplementedError`
49
- * and this package keeps no title for it — one code, one owner, one title, or the two copies drift apart in silence.
48
+ * `X_NOT_IMPLEMENTED` is `@ultimat3/core`'s, and this package keeps no title for it — one code, one
49
+ * owner, one title, or the two copies drift apart in silence. No shipped driver raises it any more
50
+ * (`serverSideEncryption` is sent by s3 and refused as `X_INVARIANT` by local/memory, 2026-11); it
51
+ * stays in the list because `StorageErrorCode` is public, and narrowing it is a break.
50
52
  * `X_IMAGE_UNSUPPORTED` / `X_IMAGE_DECODE_FAILED` are core's too and surface unwrapped (`image.ts`).
51
53
  * `X_ENV_MISSING` is core's for the same reason: an unset `STORAGE_SIGNING_SECRET` outside
52
54
  * development is a missing environment variable, not a storage concept needing its own code.
package/src/put-stream.ts CHANGED
@@ -3,7 +3,7 @@
3
3
 
4
4
  import { assert, describeValue, finiteCount } from '@ultimat3/core';
5
5
  import type { PumpLimit } from './byte-pump';
6
- import { assertPutOptions } from './driver';
6
+ import { assertPutOptions, type ServerSideEncryption } from './driver';
7
7
  import { streamTooLarge } from './errors-stream';
8
8
 
9
9
  export interface PutStreamOptions {
@@ -16,10 +16,15 @@ export interface PutStreamOptions {
16
16
  readonly contentType?: string | undefined;
17
17
  readonly cacheControl?: string | undefined;
18
18
  readonly metadata?: Readonly<Record<string, string>> | undefined;
19
+ /**
20
+ * Sent by s3 — on the one signed PUT or the multipart Create, both before a byte is stored;
21
+ * refused by local and memory, which store plain bytes (`X_INVARIANT`).
22
+ */
23
+ readonly serverSideEncryption?: ServerSideEncryption | undefined;
19
24
  }
20
25
 
21
26
  /** `put()` options that need the bytes before the object exists. The type omits them too. */
22
- const NEEDS_THE_BYTES = ['checksum', 'retention', 'legalHold', 'serverSideEncryption'] as const;
27
+ const NEEDS_THE_BYTES = ['checksum', 'retention', 'legalHold'] as const;
23
28
 
24
29
  /** Everything judged before a chunk is read. Answers the screened `maxBytes`. */
25
30
  export function assertPutStream(