@pithy-sh/storage 0.3.0 → 0.5.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.
Files changed (84) hide show
  1. package/dist/capability.d.ts +12 -3
  2. package/dist/capability.d.ts.map +1 -1
  3. package/dist/capability.js +35 -9
  4. package/dist/config/config.d.ts +20 -4
  5. package/dist/config/config.d.ts.map +1 -1
  6. package/dist/config/config.js +23 -6
  7. package/dist/data/storageObject.d.ts +12 -0
  8. package/dist/data/storageObject.d.ts.map +1 -1
  9. package/dist/data/storageObject.js +13 -2
  10. package/dist/data/tables.js +1 -1
  11. package/dist/error/errors.d.ts +4 -3
  12. package/dist/error/errors.d.ts.map +1 -1
  13. package/dist/error/errors.js +2 -2
  14. package/dist/http/handlers.d.ts +45 -14
  15. package/dist/http/handlers.d.ts.map +1 -1
  16. package/dist/http/handlers.js +169 -66
  17. package/dist/http/responses.d.ts +6 -0
  18. package/dist/http/responses.d.ts.map +1 -1
  19. package/dist/http/responses.js +2 -1
  20. package/dist/http/routes.d.ts +13 -2
  21. package/dist/http/routes.d.ts.map +1 -1
  22. package/dist/http/routes.js +37 -9
  23. package/dist/http/schemas.d.ts +6 -0
  24. package/dist/http/schemas.d.ts.map +1 -1
  25. package/dist/http/schemas.js +6 -5
  26. package/dist/http/scopes.d.ts +25 -0
  27. package/dist/http/scopes.d.ts.map +1 -0
  28. package/dist/http/scopes.js +32 -0
  29. package/dist/http/serve.d.ts +5 -2
  30. package/dist/http/serve.d.ts.map +1 -1
  31. package/dist/index.d.ts +2 -0
  32. package/dist/index.d.ts.map +1 -1
  33. package/dist/index.js +5 -3
  34. package/dist/migrations/0002_ownership.d.ts +5 -0
  35. package/dist/migrations/0002_ownership.d.ts.map +1 -0
  36. package/dist/migrations/0002_ownership.js +114 -0
  37. package/dist/object/cloudflare.d.ts +2 -1
  38. package/dist/object/cloudflare.d.ts.map +1 -1
  39. package/dist/object/cloudflare.js +2 -2
  40. package/dist/provision/provisionStorage.d.ts +14 -2
  41. package/dist/provision/provisionStorage.d.ts.map +1 -1
  42. package/dist/provision/provisionStorage.js +19 -4
  43. package/dist/provision/resolveStorageConfig.js +1 -1
  44. package/dist/quota/ceiling.d.ts +36 -0
  45. package/dist/quota/ceiling.d.ts.map +1 -0
  46. package/dist/quota/ceiling.js +31 -0
  47. package/dist/quota/quota.d.ts +24 -7
  48. package/dist/quota/quota.d.ts.map +1 -1
  49. package/dist/quota/quota.js +40 -12
  50. package/dist/secret/bundleToken.d.ts +24 -0
  51. package/dist/secret/bundleToken.d.ts.map +1 -0
  52. package/dist/secret/bundleToken.js +74 -0
  53. package/dist/secret/registry.d.ts +5 -1
  54. package/dist/secret/registry.d.ts.map +1 -1
  55. package/dist/secret/registry.js +7 -3
  56. package/dist/seeds/example.d.ts.map +1 -1
  57. package/dist/seeds/example.js +3 -0
  58. package/dist/test-utils/liveStorage.d.ts.map +1 -1
  59. package/dist/test-utils/liveStorage.js +5 -2
  60. package/dist/version.generated.d.ts +1 -1
  61. package/dist/version.generated.js +1 -1
  62. package/package.json +5 -5
  63. package/pithy.manifest.json +20 -10
  64. package/src/capability.ts +52 -8
  65. package/src/config/config.ts +24 -6
  66. package/src/data/storageObject.ts +22 -6
  67. package/src/error/errors.ts +6 -5
  68. package/src/http/handlers.ts +212 -79
  69. package/src/http/responses.ts +13 -1
  70. package/src/http/routes.ts +64 -10
  71. package/src/http/schemas.ts +10 -4
  72. package/src/http/scopes.ts +39 -0
  73. package/src/http/serve.ts +5 -2
  74. package/src/index.ts +2 -0
  75. package/src/migrations/0002_ownership.ts +176 -0
  76. package/src/object/cloudflare.ts +2 -2
  77. package/src/provision/provisionStorage.ts +22 -3
  78. package/src/quota/ceiling.ts +44 -0
  79. package/src/quota/quota.ts +63 -20
  80. package/src/secret/bundleToken.ts +81 -0
  81. package/src/secret/registry.ts +6 -8
  82. package/src/seeds/example.ts +3 -0
  83. package/src/test-utils/liveStorage.ts +3 -6
  84. package/src/version.generated.ts +1 -1
@@ -1,5 +1,6 @@
1
1
  // SPDX-FileCopyrightText: 2026 Pithy
2
2
  // SPDX-License-Identifier: MIT
3
+ import type { PermissionHook } from "@pithy-sh/core/src/access/access";
3
4
  import { type Capability } from "@pithy-sh/core/src/capability/capability";
4
5
  import type { DatabaseSpecMap } from "@pithy-sh/core/src/data/databases";
5
6
  import type { KvNamespaceSpecMap } from "@pithy-sh/core/src/kv/namespaces";
@@ -13,6 +14,12 @@ export declare const STORAGE_MIGRATION_ORDER = 800;
13
14
  export type StorageOptions = StorageConfigInput & {
14
15
  /** Mount the object routes somewhere other than `/storage`. */
15
16
  basePath?: string;
17
+ /**
18
+ * Asked on every read and write of a stored file: `allow`, `deny`, or `default` for the rules. Sharing a
19
+ * file with one person is an allow; a legal hold is a deny. No hook is the rules, unchanged. Share
20
+ * links are unchanged by it, and usage rollups keep their non-disclosure rule whatever it answers.
21
+ */
22
+ permission?: PermissionHook;
16
23
  /** Mount share fetches somewhere other than `/s`. Short by default — the whole URL gets pasted around. */
17
24
  sharePath?: string;
18
25
  };
@@ -36,9 +43,11 @@ export interface StorageCapability extends Capability<DatabaseSpecMap, KvNamespa
36
43
  *
37
44
  * `dependsOn: ["secrets"]` is real: the R2 credential bundle is read through the aggregated registry
38
45
  * at startup, so a project composing storage without `@pithy-sh/secrets` must fail at assembly, not at
39
- * the first presign. Auth is *not* listed — it is a seam. Ownership scoping reads `c.var.auth.userId`,
40
- * so without `@pithy-sh/auth` every owner-scoped route denies rather than opens, which is the right
41
- * failure and needs no dependency edge. It belongs in the manifest's `optionalCapabilities`.
46
+ * the first presign. Auth is *not* listed — it is a seam. Ownership reads `c.var.auth.userId`, so without
47
+ * `@pithy-sh/auth` every write denies rather than opens, which is the right failure and needs no
48
+ * dependency edge. Tenancy is a seam too: the organization a file belongs to comes from core's
49
+ * acting-organization resolver, so `@pithy-sh/organization` is optional, never imported, and declared on
50
+ * `powers` only through `storage:manage`. Both belong in the manifest's `optionalCapabilities`.
42
51
  */
43
52
  export declare function storage(options?: StorageOptions): StorageCapability;
44
53
  export declare function isStorageCapability(capability: Capability): capability is StorageCapability;
@@ -1 +1 @@
1
- {"version":3,"file":"capability.d.ts","sourceRoot":"","sources":["../src/capability.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,UAAU,EAAoB,MAAM,0CAA0C,CAAC;AAC7F,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAC;AACzE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAC;AAG3E,OAAO,EAAE,aAAa,EAAE,KAAK,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAOzE,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAErD;;;GAGG;AACH,eAAO,MAAM,uBAAuB,MAAM,CAAC;AAE3C,MAAM,MAAM,cAAc,GAAG,kBAAkB,GAAG;IAChD,+DAA+D;IAC/D,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,0GAA0G;IAC1G,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF;;;;GAIG;AACH,MAAM,WAAW,iBACf,SAAQ,UAAU,CAAC,eAAe,EAAE,kBAAkB,EAAE,SAAS,EAAE,OAAO,gBAAgB,CAAC;IAC3F,mCAAmC;IACnC,aAAa,EAAE,aAAa,CAAC;CAC9B;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,OAAO,CAAC,OAAO,GAAE,cAAmB,GAAG,iBAAiB,CA6CvE;AAED,wBAAgB,mBAAmB,CAAC,UAAU,EAAE,UAAU,GAAG,UAAU,IAAI,iBAAiB,CAE3F"}
1
+ {"version":3,"file":"capability.d.ts","sourceRoot":"","sources":["../src/capability.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kCAAkC,CAAC;AAGvE,OAAO,EAAE,KAAK,UAAU,EAAoB,MAAM,0CAA0C,CAAC;AAE7F,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAC;AACzE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAC;AAG3E,OAAO,EAA+B,aAAa,EAAE,KAAK,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAWtG,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAErD;;;GAGG;AACH,eAAO,MAAM,uBAAuB,MAAM,CAAC;AAE3C,MAAM,MAAM,cAAc,GAAG,kBAAkB,GAAG;IAChD,+DAA+D;IAC/D,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;;OAIG;IACH,UAAU,CAAC,EAAE,cAAc,CAAC;IAC5B,0GAA0G;IAC1G,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF;;;;GAIG;AACH,MAAM,WAAW,iBACf,SAAQ,UAAU,CAAC,eAAe,EAAE,kBAAkB,EAAE,SAAS,EAAE,OAAO,gBAAgB,CAAC;IAC3F,mCAAmC;IACnC,aAAa,EAAE,aAAa,CAAC;CAC9B;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,OAAO,CAAC,OAAO,GAAE,cAAmB,GAAG,iBAAiB,CA0EvE;AAED,wBAAgB,mBAAmB,CAAC,UAAU,EAAE,UAAU,GAAG,UAAU,IAAI,iBAAiB,CAE3F"}
@@ -1,14 +1,20 @@
1
1
  // SPDX-FileCopyrightText: 2026 Pithy
2
2
  // SPDX-License-Identifier: MIT
3
- import { StorageConfig } from "./config/config.js";
3
+ import { StorageConfig, refuseRenamedStorageOptions } from "./config/config.js";
4
4
  import { storageTables } from "./data/tables.js";
5
- import { STORAGE_BUCKET_BINDING, storageSecretsRegistry } from "./secret/registry.js";
5
+ import { STORAGE_MANAGE_POWER } from "./http/handlers.js";
6
+ import { STORAGE_BUCKET_BINDING, STORAGE_R2_SECRET, storageSecretsRegistry } from "./secret/registry.js";
7
+ import { storageAdminRoutes } from "./http/scopes.js";
6
8
  import { registerStorageRoutes } from "./http/routes.js";
7
9
  import { storage_0001_objects } from "./migrations/0001_objects.js";
10
+ import { storage_0002_ownership } from "./migrations/0002_ownership.js";
11
+ import { bundleTokenCheck } from "./secret/bundleToken.js";
8
12
  import { storageExampleSeed } from "./seeds/example.js";
9
13
  import { PACKAGE_NAME, PACKAGE_VERSION } from "./version.generated.js";
10
14
  import { storageWorkflows } from "./workflows/specs.js";
15
+ import { recordsOutsidePolicy } from "@pithy-sh/core/src/access/policyCheck";
11
16
  import { defineCapability } from "@pithy-sh/core/src/capability/capability";
17
+ import { allSettings } from "@pithy-sh/core/src/capability/settings";
12
18
  import { workflowBindings } from "@pithy-sh/core/src/workflow/bindings";
13
19
  //#region src/capability.ts
14
20
  /**
@@ -27,14 +33,21 @@ const STORAGE_MIGRATION_ORDER = 800;
27
33
  *
28
34
  * `dependsOn: ["secrets"]` is real: the R2 credential bundle is read through the aggregated registry
29
35
  * at startup, so a project composing storage without `@pithy-sh/secrets` must fail at assembly, not at
30
- * the first presign. Auth is *not* listed — it is a seam. Ownership scoping reads `c.var.auth.userId`,
31
- * so without `@pithy-sh/auth` every owner-scoped route denies rather than opens, which is the right
32
- * failure and needs no dependency edge. It belongs in the manifest's `optionalCapabilities`.
36
+ * the first presign. Auth is *not* listed — it is a seam. Ownership reads `c.var.auth.userId`, so without
37
+ * `@pithy-sh/auth` every write denies rather than opens, which is the right failure and needs no
38
+ * dependency edge. Tenancy is a seam too: the organization a file belongs to comes from core's
39
+ * acting-organization resolver, so `@pithy-sh/organization` is optional, never imported, and declared on
40
+ * `powers` only through `storage:manage`. Both belong in the manifest's `optionalCapabilities`.
33
41
  */
34
42
  function storage(options = {}) {
35
- const { basePath, sharePath, ...configInput } = options;
43
+ const { basePath, sharePath, permission, ...configInput } = options;
44
+ refuseRenamedStorageOptions(configInput);
36
45
  const resolved = StorageConfig.parse(configInput);
37
- const migrations = { "0001_objects": storage_0001_objects };
46
+ const mountPath = basePath ?? "/storage";
47
+ const migrations = {
48
+ "0001_objects": storage_0001_objects,
49
+ "0002_ownership": storage_0002_ownership
50
+ };
38
51
  const requiredBindings = [
39
52
  {
40
53
  type: "d1",
@@ -55,16 +68,29 @@ function storage(options = {}) {
55
68
  workflows: storageWorkflows,
56
69
  requiredBindings,
57
70
  config: StorageConfig,
71
+ powers: [STORAGE_MANAGE_POWER],
58
72
  databases: { app: {
59
73
  binding: "DB",
60
74
  tables: storageTables(),
61
75
  migrationOrder: 800,
62
76
  migrations
63
77
  } },
78
+ adminRoutes: storageAdminRoutes(mountPath),
79
+ settings: allSettings(recordsOutsidePolicy({
80
+ capability: "storage",
81
+ noun: "file",
82
+ table: "pithy_storage_objects",
83
+ policy: resolved.visibility,
84
+ remedy: `Move each with PATCH ${mountPath}/:id`
85
+ }), bundleTokenCheck({
86
+ secret: STORAGE_R2_SECRET,
87
+ provision: "storage provision"
88
+ })),
64
89
  routes: registerStorageRoutes({
65
90
  config: resolved,
66
- basePath,
67
- sharePath
91
+ basePath: mountPath,
92
+ sharePath,
93
+ ...permission ? { permission } : {}
68
94
  }),
69
95
  seeds: [storageExampleSeed]
70
96
  });
@@ -11,10 +11,18 @@ export declare const StorageConfig: z.ZodObject<{
11
11
  }, z.core.$strip>>;
12
12
  multipartThresholdBytes: z.ZodDefault<z.ZodNumber>;
13
13
  partSizeBytes: z.ZodDefault<z.ZodNumber>;
14
- defaultVisibility: z.ZodDefault<z.ZodEnum<{
15
- private: "private";
16
- public: "public";
17
- }>>;
14
+ visibility: z.ZodPrefault<z.ZodObject<{
15
+ default: z.ZodDefault<z.ZodEnum<{
16
+ organization: "organization";
17
+ private: "private";
18
+ public: "public";
19
+ }>>;
20
+ allowed: z.ZodDefault<z.ZodArray<z.ZodEnum<{
21
+ organization: "organization";
22
+ private: "private";
23
+ public: "public";
24
+ }>>>;
25
+ }, z.core.$strip>>;
18
26
  pendingTtlSeconds: z.ZodDefault<z.ZodNumber>;
19
27
  }, z.core.$strip>;
20
28
  export type StorageConfig = z.output<typeof StorageConfig>;
@@ -24,4 +32,12 @@ export type StorageConfigInput = z.input<typeof StorageConfig>;
24
32
  * docs can state a real number rather than a rule of thumb.
25
33
  */
26
34
  export declare function maxObjectBytes(config: StorageConfig): number;
35
+ /**
36
+ * Refuse a config that still names an option a release renamed, naming the new one.
37
+ *
38
+ * `defaultVisibility` became `visibility.default`, beside `visibility.allowed`. Zod would strip the old key
39
+ * and parse the rest, so a project upgrading without the edit would quietly get the default it may have
40
+ * meant to change — refused here instead, before the config is parsed.
41
+ */
42
+ export declare function refuseRenamedStorageOptions(input: Record<string, unknown>): void;
27
43
  //# sourceMappingURL=config.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/config/config.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AA+BxB,eAAO,MAAM,YAAY;;iBAYyF,CAAC;AACnH,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,YAAY,CAAC,CAAC;AAEzD,eAAO,MAAM,aAAa;;;;;;;;;;;iBA6CtB,CAAC;AACL,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,aAAa,CAAC,CAAC;AAC3D,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,aAAa,CAAC,CAAC;AAE/D;;;GAGG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,aAAa,GAAG,MAAM,CAE5D"}
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/config/config.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AA+BxB,eAAO,MAAM,YAAY;;iBAYyF,CAAC;AACnH,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,YAAY,CAAC,CAAC;AAEzD,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;iBA6CtB,CAAC;AACL,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,aAAa,CAAC,CAAC;AAC3D,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,aAAa,CAAC,CAAC;AAE/D;;;GAGG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,aAAa,GAAG,MAAM,CAE5D;AAED;;;;;;GAMG;AACH,wBAAgB,2BAA2B,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAOhF"}
@@ -1,7 +1,8 @@
1
1
  // SPDX-FileCopyrightText: 2026 Pithy
2
2
  // SPDX-License-Identifier: MIT
3
- import { StorageVisibility } from "../data/storageObject.js";
4
3
  import { DEFAULT_MULTIPART_THRESHOLD_BYTES, DEFAULT_PART_SIZE_BYTES, MAX_PART_SIZE_BYTES, MAX_UPLOAD_PARTS, MIN_PART_SIZE_BYTES } from "../object/multipart.js";
4
+ import { VisibilityPolicy } from "@pithy-sh/core/src/access/visibility";
5
+ import { ValidationError } from "@pithy-sh/core/src/error/pithyError";
5
6
  import { z } from "zod";
6
7
  //#region src/config/config.ts
7
8
  /**
@@ -18,8 +19,9 @@ import { z } from "zod";
18
19
  * fixes the practical object ceiling: 10,000 × 64 MiB ≈ 625 GiB. Raise `partSizeBytes` to raise the
19
20
  * ceiling (R2's own object cap is 4.995 TiB); the cost is that every retry re-sends a larger part.
20
21
  *
21
- * **Default visibility is private.** The safe default is the one where forgetting to set a field
22
- * cannot leak a file.
22
+ * **Default visibility is private, and the project decides which levels exist.** The safe default is the
23
+ * one where forgetting to set a field cannot leak a file, and `visibility.allowed` — all three levels
24
+ * unless narrowed — is how a project promises that a file can never be published at all.
23
25
  */
24
26
  /** The largest single-part upload R2 accepts — 5 GiB, less 5 MiB. Above it, multipart is not optional. */
25
27
  const MAX_SINGLE_PART_BYTES = 5363466240;
@@ -28,9 +30,9 @@ const StorageConfig = z.object({
28
30
  quota: StorageQuota.prefault({}).describe("Per-owner byte limits. Unlimited unless configured."),
29
31
  multipartThresholdBytes: z.number().int().min(MIN_PART_SIZE_BYTES).max(MAX_SINGLE_PART_BYTES).default(DEFAULT_MULTIPART_THRESHOLD_BYTES).describe("Uploads larger than this go multipart; smaller ones get one presigned PUT. It cannot exceed R2's ~5 GiB single-part cap, because above that multipart is the only way to store the bytes at all."),
30
32
  partSizeBytes: z.number().int().min(MIN_PART_SIZE_BYTES).max(MAX_PART_SIZE_BYTES).default(DEFAULT_PART_SIZE_BYTES).describe("Bytes per multipart part, for every part but the last. R2 allows at most 10,000 parts, so this fixes the largest object you can store: 64 MiB gives ~625 GiB. The floor is S3's 5 MiB rule for non-final parts."),
31
- defaultVisibility: StorageVisibility.default("private").describe("Visibility for an upload that does not name one. Private, so a forgotten field can never publish a file."),
33
+ visibility: VisibilityPolicy.prefault({}).describe("Which visibility levels a file may carry, and the one an upload gets when it names none. Private by default; every level allowed unless narrowed."),
32
34
  pendingTtlSeconds: z.number().int().positive().default(86400).describe("How long a `pending` row holds its quota reservation before the orphan sweep reclaims it. Long enough for a slow multipart upload to finish; short enough that an abandoned one does not hold a quota forever.")
33
- }).describe("Configuration for the storage capability — quotas, multipart sizing, and default visibility.").check((ctx) => {
35
+ }).describe("Configuration for the storage capability — quotas, multipart sizing, and the visibility policy.").check((ctx) => {
34
36
  if (ctx.value.multipartThresholdBytes < ctx.value.partSizeBytes) ctx.issues.push({
35
37
  code: "custom",
36
38
  input: ctx.value,
@@ -45,5 +47,20 @@ const StorageConfig = z.object({
45
47
  function maxObjectBytes(config) {
46
48
  return config.partSizeBytes * MAX_UPLOAD_PARTS;
47
49
  }
50
+ /**
51
+ * Refuse a config that still names an option a release renamed, naming the new one.
52
+ *
53
+ * `defaultVisibility` became `visibility.default`, beside `visibility.allowed`. Zod would strip the old key
54
+ * and parse the rest, so a project upgrading without the edit would quietly get the default it may have
55
+ * meant to change — refused here instead, before the config is parsed.
56
+ */
57
+ function refuseRenamedStorageOptions(input) {
58
+ if (!("defaultVisibility" in input)) return;
59
+ throw new ValidationError({
60
+ message: "`defaultVisibility` was renamed `visibility.default`.",
61
+ action: `Replace \`defaultVisibility: ${JSON.stringify(input.defaultVisibility)}\` with \`visibility: { default: ${JSON.stringify(input.defaultVisibility)} }\` in storage({ … }) in this Worker's pithy.config.ts.`,
62
+ detail: "storage({ defaultVisibility }) names an option this release renamed"
63
+ });
64
+ }
48
65
  //#endregion
49
- export { StorageConfig, StorageQuota, maxObjectBytes };
66
+ export { StorageConfig, StorageQuota, maxObjectBytes, refuseRenamedStorageOptions };
@@ -17,8 +17,18 @@ import { z } from "zod";
17
17
  * `size` is declared by the client at init and *confirmed* against R2 at completion. It is nullable
18
18
  * because a caller may not know it up front; a null size reserves no quota, which is why the handler
19
19
  * requires it whenever a quota is configured.
20
+ *
21
+ * **Whose it is.** `ownerId` is the authenticated user and `organizationId` the organization they were
22
+ * acting for when the file was written — the same two columns, in the same terms, as a media record, so
23
+ * one name answers *what is this account holding* across both. The organization is the fact at the time
24
+ * of the write, never a join through current membership.
25
+ */
26
+ /**
27
+ * Who may read an object without a share link — core's three levels, the same ones media uses. Visibility
28
+ * is authorization, not a bucket setting: the bucket itself stays private.
20
29
  */
21
30
  export declare const StorageVisibility: z.ZodEnum<{
31
+ organization: "organization";
22
32
  private: "private";
23
33
  public: "public";
24
34
  }>;
@@ -34,9 +44,11 @@ export declare const StorageObject: z.ZodObject<{
34
44
  key: z.ZodString;
35
45
  path: z.ZodString;
36
46
  ownerId: z.ZodNullable<z.ZodString>;
47
+ organizationId: z.ZodNullable<z.ZodString>;
37
48
  contentType: z.ZodString;
38
49
  size: z.ZodNullable<z.ZodNumber>;
39
50
  visibility: z.ZodEnum<{
51
+ organization: "organization";
40
52
  private: "private";
41
53
  public: "public";
42
54
  }>;
@@ -1 +1 @@
1
- {"version":3,"file":"storageObject.d.ts","sourceRoot":"","sources":["../../src/data/storageObject.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,CAAC,EAAE,MAAM,KA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  // SPDX-License-Identifier: MIT
3
+ import { RecordVisibility } from "@pithy-sh/core/src/access/visibility";
3
4
  import { z } from "zod";
4
5
  import { SQLiteDate } from "@pithy-sh/core/src/data/codecs";
5
6
  //#region src/data/storageObject.ts
@@ -19,8 +20,17 @@ import { SQLiteDate } from "@pithy-sh/core/src/data/codecs";
19
20
  * `size` is declared by the client at init and *confirmed* against R2 at completion. It is nullable
20
21
  * because a caller may not know it up front; a null size reserves no quota, which is why the handler
21
22
  * requires it whenever a quota is configured.
23
+ *
24
+ * **Whose it is.** `ownerId` is the authenticated user and `organizationId` the organization they were
25
+ * acting for when the file was written — the same two columns, in the same terms, as a media record, so
26
+ * one name answers *what is this account holding* across both. The organization is the fact at the time
27
+ * of the write, never a join through current membership.
28
+ */
29
+ /**
30
+ * Who may read an object without a share link — core's three levels, the same ones media uses. Visibility
31
+ * is authorization, not a bucket setting: the bucket itself stays private.
22
32
  */
23
- const StorageVisibility = z.enum(["private", "public"]).describe("Who may read an object without a share link: `private` is the owner alone, `public` is anyone with the id. Visibility is authorization, not a bucket setting — the bucket itself stays private.");
33
+ const StorageVisibility = RecordVisibility.describe("Who may read an object without a share link: `private` is its owner, acting for its organization; `organization` is any member acting for it; `public` is anyone with the id. Visibility is authorization, not a bucket setting — the bucket itself stays private.");
24
34
  const StorageObjectStatus = z.enum([
25
35
  "pending",
26
36
  "stored",
@@ -31,9 +41,10 @@ const StorageObject = z.object({
31
41
  key: z.string().min(1).describe("The opaque R2 object key, server-derived (`obj/<uuid>`). Unique, and never sent to a client."),
32
42
  path: z.string().min(1).describe("The adopter's logical path (`invoices/2026/q3.pdf`). Indexed and listable; never part of the key."),
33
43
  ownerId: z.string().nullable().describe("The authenticated user who owns the file, from AuthContext. Null for system-owned objects."),
44
+ organizationId: z.string().nullable().describe("The organization the owner was acting for when the file was written, from the acting-organization seam. Null when none was in force, and for system-owned objects."),
34
45
  contentType: z.string().min(1).describe("The MIME type. Declared at init and overwritten at completion with what R2 stored — a presigned PUT cannot sign a content type, so only the completed row is authoritative. An active type is still neutralised on serve."),
35
46
  size: z.number().int().nonnegative().nullable().describe("Byte count. Declared at init so the pending row reserves quota; confirmed against R2 at completion."),
36
- visibility: StorageVisibility.describe("Whether anyone with the id may read this object, or only its owner."),
47
+ visibility: StorageVisibility.describe("Who may read this object: its owner, its organization's members, or anyone with the id."),
37
48
  checksum: z.string().nullable().describe("Lowercase hex SHA-256 of the bytes, when one is known. Null until a completion supplies it."),
38
49
  status: StorageObjectStatus.describe("The upload's lifecycle state."),
39
50
  uploadId: z.string().nullable().describe("The multipart upload id while one is in flight. Null for a single-PUT upload and after completion."),
@@ -1,7 +1,7 @@
1
1
  // SPDX-FileCopyrightText: 2026 Pithy
2
2
  // SPDX-License-Identifier: MIT
3
- import { StorageObject } from "./storageObject.js";
4
3
  import { StorageShare } from "./share.js";
4
+ import { StorageObject } from "./storageObject.js";
5
5
  import { createDatabase } from "@pithy-sh/core/src/data/db";
6
6
  //#region src/data/tables.ts
7
7
  /** The objects table. `CamelCasePlugin` snake-cases it to `pithy_storage_objects`. */
@@ -2,6 +2,7 @@
2
2
  // SPDX-License-Identifier: MIT
3
3
  import { PithyError } from "@pithy-sh/core/src/error/pithyError";
4
4
  import type { MessageParams } from "@pithy-sh/core/src/i18n/catalog";
5
+ import type { UnmarkedString } from "@pithy-sh/core/src/privacy/types";
5
6
  /**
6
7
  * `@pithy-sh/storage` throw sugar. The `storage/*` codes live in core's closed `KitErrorPayload` union
7
8
  * (CLAUDE.md §Errors); these subclasses are the package-local vehicles that set one of those members.
@@ -12,9 +13,9 @@ import type { MessageParams } from "@pithy-sh/core/src/i18n/catalog";
12
13
  * counts are exactly the kind of internal shape a client should never be handed.
13
14
  */
14
15
  interface StorageErrorArgs {
15
- message?: string;
16
- action?: string;
17
- detail?: string;
16
+ message?: UnmarkedString;
17
+ action?: UnmarkedString;
18
+ detail?: UnmarkedString;
18
19
  /**
19
20
  * Values a translating client interpolates into its own wording for this code. Client-facing, so —
20
21
  * unlike `action` and `detail` — these cross the boundary with `message`.
@@ -1 +1 @@
1
- {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/error/errors.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAE,MAAM,qCAAqC,CAAC;AACjE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAErE;;;;;;;;GAQG;AAEH,UAAU,gBAAgB;IACxB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;OAGG;IACH,MAAM,CAAC,EAAE,aAAa,CAAC;CACxB;AAED,qBAAa,oBAAqB,SAAQ,UAAU;IAClD,YAAY,IAAI,GAAE,gBAAqB,EAAE,OAAO,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,OAAO,CAAA;KAAE,EAYrE;CACF;AAED,qBAAa,qBAAsB,SAAQ,UAAU;IACnD,YAAY,IAAI,GAAE,gBAAqB,EAAE,OAAO,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,OAAO,CAAA;KAAE,EAYrE;CACF;AAED,qBAAa,yBAA0B,SAAQ,UAAU;IACvD,YAAY,IAAI,GAAE,gBAAqB,EAAE,OAAO,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,OAAO,CAAA;KAAE,EAYrE;CACF;AAED,qBAAa,4BAA6B,SAAQ,UAAU;IAC1D,YAAY,IAAI,GAAE,gBAAqB,EAAE,OAAO,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,OAAO,CAAA;KAAE,EAYrE;CACF;AAED,qBAAa,2BAA4B,SAAQ,UAAU;IACzD,YAAY,IAAI,GAAE,gBAAqB,EAAE,OAAO,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,OAAO,CAAA;KAAE,EAcrE;CACF;AAED,qBAAa,wBAAyB,SAAQ,UAAU;IACtD,YAAY,IAAI,GAAE,gBAAqB,EAAE,OAAO,CAA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,qBAAa,2BAA4B,SAAQ,UAAU;IACzD,YAAY,IAAI,GAAE,gBAAqB,EAAE,OAAO,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,OAAO,CAAA;KAAE,EAcrE;CACF;AAED,qBAAa,wBAAyB,SAAQ,UAAU;IACtD,YAAY,IAAI,GAAE,gBAAqB,EAAE,OAAO,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,OAAO,CAAA;KAAE,EAYrE;CACF;AAED,qBAAa,wBAAyB,SAAQ,UAAU;IACtD,YAAY,IAAI,GAAE,gBAAqB,EAAE,OAAO,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,OAAO,CAAA;KAAE,EAYrE;CACF"}
@@ -19,8 +19,8 @@ var StorageForbiddenError = class extends PithyError {
19
19
  super({
20
20
  code: "storage/forbidden",
21
21
  status: 403,
22
- message: args.message ?? "That file is not yours.",
23
- action: args.action ?? "Sign in as the owner, or ask them for a share link.",
22
+ message: args.message ?? "You can see that file, but it is not yours to change.",
23
+ action: args.action ?? "Sign in as the owner, or ask a role holding storage:manage in its organization.",
24
24
  detail: args.detail,
25
25
  params: args.params
26
26
  }, options);
@@ -1,10 +1,12 @@
1
1
  // SPDX-FileCopyrightText: 2026 Pithy
2
2
  // SPDX-License-Identifier: MIT
3
+ import { type AccessCaller, type PermissionHook } from "@pithy-sh/core/src/access/access";
3
4
  import type { StorageConfig } from "../config/config";
4
5
  import { StorageObject } from "../data/storageObject";
5
6
  import { type StorageDatabase } from "../data/tables";
6
7
  import type { ObjectStore } from "../object/store";
7
8
  import type { UploadedPart } from "../object/uploadedPart";
9
+ import type { StorageCeiling } from "../quota/ceiling";
8
10
  import type { CompleteUploadInput, CopyObjectInput, CreateShareInput, CreateUploadInput, ListObjectsQuery, UpdateObjectInput } from "./schemas";
9
11
  /**
10
12
  * The storage request handlers — pure functions over injected dependencies, so every branch is tested
@@ -22,36 +24,60 @@ import type { CompleteUploadInput, CopyObjectInput, CreateShareInput, CreateUplo
22
24
  * addresses, so a key in a response body is a capability leak waiting for the first adopter who logs
23
25
  * their API responses.
24
26
  *
25
- * **A file you cannot see reads as missing.** `assertOwner` answers `storage/not_found` for a private
26
- * object owned by someone else and `storage/forbidden` only when the object is already public —
27
- * because a 403 on a private object confirms it exists, which is exactly the oracle an enumeration
28
- * attack wants. Public objects have nothing left to hide, so there the honest answer is the useful one.
27
+ * **Whose a file is, and who may reach it.** Every file is written with its owner, the organization in
28
+ * force, and a visibility — `private`, `organization` or `public` — from the project's policy. Every route
29
+ * asks core's access rules, and the adopter's permission hook if they supplied one, before it acts:
30
+ * reading is the visibility's, and changing a file — completing, aborting, copying, renaming,
31
+ * re-scoping, sharing, deleting — is its owner's, acting for its organization, or a role holding
32
+ * `storage:manage` there.
33
+ *
34
+ * **A file you cannot see reads as missing.** A caller who may not read a file gets `storage/not_found`,
35
+ * and `storage/forbidden` only when they may read it but not change it — because a 403 on a file they
36
+ * cannot see confirms it exists, which is exactly the oracle an enumeration attack wants. A file they
37
+ * can already read has nothing left to hide, so there the honest answer is the useful one.
29
38
  */
39
+ /** The power a role holds to edit, delete and re-scope any file in its own organization. */
40
+ export declare const STORAGE_MANAGE_POWER = "storage:manage";
30
41
  /** Everything a handler needs, all injectable. */
31
42
  export interface HandlerDeps {
32
43
  /** The storage database. */
33
44
  db: StorageDatabase;
34
45
  /** The object plane — presigning, the multipart lifecycle, and binding-backed reads. */
35
46
  store: ObjectStore;
36
- /** The resolved storage config: quota, multipart sizing, default visibility. */
47
+ /** The resolved storage config: quota, multipart sizing, the visibility policy. */
37
48
  config: StorageConfig;
38
- /** The authenticated caller from the core `AuthContext` seam, or null for an unauthenticated read. */
39
- ownerId: string | null;
49
+ /** Who is asking: the signed-in user from `AuthContext`, if any, and the organization they act for. */
50
+ caller: AccessCaller;
51
+ /** The adopter's permission hook, if they supplied one. */
52
+ permission?: PermissionHook;
53
+ /** The Worker env, handed to the permission hook. */
54
+ env: Record<string, unknown>;
40
55
  /** Mints an object id. */
41
56
  newId: () => string;
42
57
  /** Mints a share token. */
43
58
  newToken: () => string;
44
59
  /** The current time. */
45
60
  now: () => Date;
61
+ /**
62
+ * The byte ceiling for this request's writes, and whose bytes it covers.
63
+ *
64
+ * Absent means the configured `quota.bytesPerOwner`, per owner, which is what a project composing no
65
+ * entitlement provider has always had. The default resolver fills it from the `storageBytes` meter when the
66
+ * provider enforces one, so a plan's quota — or a subject's pinned one, or `unrestricted` — becomes the
67
+ * ceiling, summed across the organization when the plan is an organization's, and an advisory meter leaves
68
+ * the configured number in force.
69
+ */
70
+ quotaLimit?: () => Promise<StorageCeiling>;
46
71
  }
47
72
  /** The client-facing shape of a stored file. Deliberately without `key` and `uploadId`. */
48
73
  export interface StorageObjectView {
49
74
  id: string;
50
75
  path: string;
51
76
  ownerId: string | null;
77
+ organizationId: string | null;
52
78
  contentType: string;
53
79
  size: number | null;
54
- visibility: "private" | "public";
80
+ visibility: StorageObject["visibility"];
55
81
  checksum: string | null;
56
82
  status: "pending" | "stored" | "failed";
57
83
  createdAt: Date;
@@ -161,14 +187,16 @@ export interface UploadPartsResult {
161
187
  */
162
188
  export declare function listUploadParts(deps: HandlerDeps, id: string): Promise<UploadPartsResult>;
163
189
  /**
164
- * One page of the caller's files, ordered by logical path. Scoped to the authenticated owner: there
165
- * is no way to list another owner's files, and no parameter that could be made to.
190
+ * One page of the files the caller may see, ordered by logical path: their own, their organization's,
191
+ * and — only when `includePublic=true` — every public file. The rules run in SQL, so there is no
192
+ * parameter that lists anyone else's private files; the hook is asked about each row on the page and may
193
+ * remove one, so a page can come back short while its cursor still says there is more.
166
194
  */
167
195
  export declare function listObjects(deps: HandlerDeps, query: ListObjectsQuery): Promise<{
168
196
  objects: StorageObjectView[];
169
197
  cursor?: string;
170
198
  }>;
171
- /** Load an object for reading, enforcing public-or-owner and that its bytes exist. */
199
+ /** Load an object for reading, enforcing who may read it and that its bytes exist. */
172
200
  export declare function readableObject(deps: HandlerDeps, id: string): Promise<StorageObject>;
173
201
  /** How long a direct-download URL stays valid. Short: it is bearer-equivalent and cannot be revoked. */
174
202
  export declare const PRESIGNED_URL_TTL_SECONDS = 300;
@@ -183,16 +211,19 @@ export declare function presignObject(deps: HandlerDeps, id: string): Promise<{
183
211
  url: string;
184
212
  expiresInSeconds: number;
185
213
  }>;
186
- /** Rename a file, change who may read it, or both. The key never moves — only the row changes. */
214
+ /**
215
+ * Rename a file, change who may read it, or both. The key never moves — only the row changes. A level the
216
+ * policy does not allow is refused, and `organization` on a file written with no organization is too.
217
+ */
187
218
  export declare function updateObject(deps: HandlerDeps, id: string, input: UpdateObjectInput): Promise<StorageObjectView>;
188
219
  /**
189
220
  * Copy a file server-side. The bytes are copied by R2 and never enter the Worker; the copy is a new
190
221
  * object with its own id, its own key, and its own share links — it is not an alias.
191
222
  *
192
- * Owner-scoped, like every other mutating route: you may copy your own files. Copying a *public* file
223
+ * A change, like every other mutating route: you may copy a file you may change. Copying a *public* file
193
224
  * you do not own is a plausible feature and deliberately not this one — it would let any reader
194
225
  * duplicate bytes into their own quota on the owner's storage bill, which is a decision an adopter
195
- * should make explicitly rather than inherit.
226
+ * should make explicitly rather than inherit. The copy is the caller's, in the organization they act for.
196
227
  */
197
228
  export declare function copyObject(deps: HandlerDeps, id: string, input: CopyObjectInput): Promise<StorageObjectView>;
198
229
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"handlers.d.ts","sourceRoot":"","sources":["../../src/http/handlers.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEtD,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAA+C,KAAK,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAUnG,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAE3D,OAAO,KAAK,EACV,mBAAmB,EACnB,eAAe,EACf,gBAAgB,EACh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