@pithy-sh/storage 0.1.1 → 0.1.3

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 (86) hide show
  1. package/dist/capability.d.ts +43 -0
  2. package/dist/capability.d.ts.map +1 -0
  3. package/dist/capability.js +74 -0
  4. package/dist/config/config.d.ts +25 -0
  5. package/dist/config/config.d.ts.map +1 -0
  6. package/dist/config/config.js +47 -0
  7. package/dist/data/share.d.ts +25 -0
  8. package/dist/data/share.d.ts.map +1 -0
  9. package/dist/data/share.js +26 -0
  10. package/dist/data/storageObject.d.ts +53 -0
  11. package/dist/data/storageObject.d.ts.map +1 -0
  12. package/dist/data/storageObject.js +42 -0
  13. package/dist/data/tables.d.ts +21 -0
  14. package/dist/data/tables.d.ts.map +1 -0
  15. package/dist/data/tables.js +24 -0
  16. package/dist/error/errors.d.ts +58 -0
  17. package/dist/error/errors.d.ts.map +1 -0
  18. package/dist/error/errors.js +87 -0
  19. package/dist/http/guard.d.ts +18 -0
  20. package/dist/http/guard.d.ts.map +1 -0
  21. package/dist/http/guard.js +27 -0
  22. package/dist/http/handlers.d.ts +230 -0
  23. package/dist/http/handlers.d.ts.map +1 -0
  24. package/dist/http/handlers.js +505 -0
  25. package/dist/http/routes.d.ts +68 -0
  26. package/dist/http/routes.d.ts.map +1 -0
  27. package/dist/http/routes.js +133 -0
  28. package/dist/http/schemas.d.ts +72 -0
  29. package/dist/http/schemas.d.ts.map +1 -0
  30. package/dist/http/schemas.js +91 -0
  31. package/dist/http/serve.d.ts +119 -0
  32. package/dist/http/serve.d.ts.map +1 -0
  33. package/dist/http/serve.js +207 -0
  34. package/dist/index.d.ts +21 -0
  35. package/dist/index.d.ts.map +1 -0
  36. package/dist/index.js +12 -0
  37. package/dist/migrations/0001_objects.d.ts +22 -0
  38. package/dist/migrations/0001_objects.d.ts.map +1 -0
  39. package/dist/migrations/0001_objects.js +39 -0
  40. package/dist/object/cloudflare.d.ts +21 -0
  41. package/dist/object/cloudflare.d.ts.map +1 -0
  42. package/dist/object/cloudflare.js +46 -0
  43. package/dist/object/key.d.ts +27 -0
  44. package/dist/object/key.d.ts.map +1 -0
  45. package/dist/object/key.js +35 -0
  46. package/dist/object/multipart.d.ts +76 -0
  47. package/dist/object/multipart.d.ts.map +1 -0
  48. package/dist/object/multipart.js +129 -0
  49. package/dist/object/store.d.ts +201 -0
  50. package/dist/object/store.d.ts.map +1 -0
  51. package/dist/object/store.js +176 -0
  52. package/dist/provision/provisionStorage.d.ts +137 -0
  53. package/dist/provision/provisionStorage.d.ts.map +1 -0
  54. package/dist/provision/provisionStorage.js +110 -0
  55. package/dist/provision/resolveStorageConfig.d.ts +43 -0
  56. package/dist/provision/resolveStorageConfig.d.ts.map +1 -0
  57. package/dist/provision/resolveStorageConfig.js +31 -0
  58. package/dist/quota/quota.d.ts +125 -0
  59. package/dist/quota/quota.d.ts.map +1 -0
  60. package/dist/quota/quota.js +100 -0
  61. package/dist/secret/registry.d.ts +70 -0
  62. package/dist/secret/registry.d.ts.map +1 -0
  63. package/dist/secret/registry.js +82 -0
  64. package/dist/seeds/example.d.ts +3 -0
  65. package/dist/seeds/example.d.ts.map +1 -0
  66. package/dist/seeds/example.js +109 -0
  67. package/dist/test-utils/liveStorage.d.ts +50 -0
  68. package/dist/test-utils/liveStorage.d.ts.map +1 -0
  69. package/dist/test-utils/liveStorage.js +196 -0
  70. package/dist/version.generated.d.ts +5 -0
  71. package/dist/version.generated.d.ts.map +1 -0
  72. package/dist/version.generated.js +7 -0
  73. package/dist/workflows/retryPolicy.d.ts +37 -0
  74. package/dist/workflows/retryPolicy.d.ts.map +1 -0
  75. package/dist/workflows/retryPolicy.js +41 -0
  76. package/dist/workflows/specs.d.ts +55 -0
  77. package/dist/workflows/specs.d.ts.map +1 -0
  78. package/dist/workflows/specs.js +58 -0
  79. package/dist/workflows/sweep.d.ts +82 -0
  80. package/dist/workflows/sweep.d.ts.map +1 -0
  81. package/dist/workflows/sweep.js +143 -0
  82. package/dist/workflows/worker.d.ts +49 -0
  83. package/dist/workflows/worker.d.ts.map +1 -0
  84. package/dist/workflows/worker.js +50 -0
  85. package/package.json +22 -11
  86. package/src/version.generated.ts +1 -1
@@ -0,0 +1,133 @@
1
+ import { storageDatabase } from "../data/tables.js";
2
+ import { STORAGE_R2_SECRET } from "../secret/registry.js";
3
+ import { objectStore } from "../object/store.js";
4
+ import { requireAuth } from "./guard.js";
5
+ import { abortUpload, completeUpload, copyObject, createShare, deleteObject, initUpload, listObjects, listUploadParts, presignObject, readableObject, resolveShare, revokeShare, updateObject } from "./handlers.js";
6
+ import { CompleteUploadInput, CopyObjectInput, CreateShareInput, CreateUploadInput, ListObjectsQuery, ObjectIdParam, ObjectReadQuery, ShareTokenParam, UpdateObjectInput } from "./schemas.js";
7
+ import { parseConditions, parseRangeHeader, rangeNotSatisfiable, serveMetadata, serveObject, toObjectRange } from "./serve.js";
8
+ import { InternalError } from "@pithy-sh/core/src/error/pithyError";
9
+ import { zValidator } from "@hono/zod-validator";
10
+ import { validationHook } from "@pithy-sh/core/src/http/validation";
11
+ //#region src/http/routes.ts
12
+ /**
13
+ * Read one binding, or fail with a message naming the binding and how to add it. A `?.` here would
14
+ * turn a missing binding into a `TypeError` at the first query, attributed to nothing.
15
+ */
16
+ function requireBinding(env, name, kind) {
17
+ const value = env[name];
18
+ if (!value) throw new InternalError({
19
+ message: "Storage is not configured.",
20
+ action: `Bind ${kind} named ${name} in wrangler.jsonc, then redeploy.`,
21
+ detail: `@pithy-sh/storage requires the ${name} binding; none was present on env.`
22
+ });
23
+ return value;
24
+ }
25
+ /** Build the default per-request dependency resolver from the resolved config. */
26
+ function defaultResolveDeps(config) {
27
+ return async (c) => {
28
+ const env = c.env;
29
+ const bucket = requireBinding(env, "STORAGE_BUCKET", "an R2 bucket");
30
+ const d1 = requireBinding(env, "DB", "a D1 database");
31
+ return {
32
+ db: storageDatabase(d1),
33
+ store: objectStore({
34
+ bucket,
35
+ env,
36
+ secretName: STORAGE_R2_SECRET
37
+ }),
38
+ config,
39
+ ownerId: c.var.auth?.userId ?? null,
40
+ newId: () => crypto.randomUUID(),
41
+ newToken: () => shareToken(),
42
+ now: () => /* @__PURE__ */ new Date()
43
+ };
44
+ };
45
+ }
46
+ /** A 256-bit share token, base64url-encoded and unpadded so it is safe in a path segment. */
47
+ function shareToken() {
48
+ const bytes = crypto.getRandomValues(/* @__PURE__ */ new Uint8Array(32));
49
+ const binary = String.fromCharCode(...bytes);
50
+ return btoa(binary).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
51
+ }
52
+ /** Register the storage sub-router. Returned as the capability's `routes` hook. */
53
+ function registerStorageRoutes(options) {
54
+ const base = options.basePath ?? "/storage";
55
+ const share = options.sharePath ?? "/s";
56
+ const resolve = options.resolveDeps ?? defaultResolveDeps(options.config);
57
+ /** Stream one object, honoring `Range` and `If-None-Match`. Shared by the id route and the share route. */
58
+ const stream = async (c, deps, object, download) => {
59
+ const requested = parseRangeHeader(c.req.header("range"), object.size);
60
+ if (requested.kind === "unsatisfiable") return rangeNotSatisfiable(object.size ?? 0);
61
+ const result = await deps.store.get(object.key, {
62
+ range: toObjectRange(requested),
63
+ onlyIf: parseConditions(c.req.header("if-none-match"))
64
+ });
65
+ if (!result) return c.notFound();
66
+ return serveObject({
67
+ metadata: result.metadata,
68
+ body: result.body,
69
+ range: result.range,
70
+ path: object.path,
71
+ visibility: object.visibility,
72
+ download
73
+ });
74
+ };
75
+ return (app) => {
76
+ app.post(base, requireAuth(), zValidator("json", CreateUploadInput, validationHook), async (c) => {
77
+ return c.json(await initUpload(await resolve(c), c.req.valid("json")), 201);
78
+ });
79
+ app.get(base, requireAuth(), zValidator("query", ListObjectsQuery, validationHook), async (c) => {
80
+ return c.json(await listObjects(await resolve(c), c.req.valid("query")));
81
+ });
82
+ app.delete(`${base}/shares/:token`, requireAuth(), zValidator("param", ShareTokenParam, validationHook), async (c) => {
83
+ return c.json(await revokeShare(await resolve(c), c.req.valid("param").token));
84
+ });
85
+ app.post(`${base}/:id/complete`, requireAuth(), zValidator("param", ObjectIdParam, validationHook), zValidator("json", CompleteUploadInput, validationHook), async (c) => {
86
+ return c.json(await completeUpload(await resolve(c), c.req.valid("param").id, c.req.valid("json")));
87
+ });
88
+ app.post(`${base}/:id/abort`, requireAuth(), zValidator("param", ObjectIdParam, validationHook), async (c) => {
89
+ return c.json(await abortUpload(await resolve(c), c.req.valid("param").id));
90
+ });
91
+ app.get(`${base}/:id/parts`, requireAuth(), zValidator("param", ObjectIdParam, validationHook), async (c) => {
92
+ return c.json(await listUploadParts(await resolve(c), c.req.valid("param").id));
93
+ });
94
+ app.post(`${base}/:id/copy`, requireAuth(), zValidator("param", ObjectIdParam, validationHook), zValidator("json", CopyObjectInput, validationHook), async (c) => {
95
+ return c.json(await copyObject(await resolve(c), c.req.valid("param").id, c.req.valid("json")), 201);
96
+ });
97
+ app.post(`${base}/:id/shares`, requireAuth(), zValidator("param", ObjectIdParam, validationHook), zValidator("json", CreateShareInput, validationHook), async (c) => {
98
+ return c.json(await createShare(await resolve(c), c.req.valid("param").id, c.req.valid("json")), 201);
99
+ });
100
+ app.get(`${base}/:id/url`, requireAuth(), zValidator("param", ObjectIdParam, validationHook), async (c) => {
101
+ return c.json(await presignObject(await resolve(c), c.req.valid("param").id));
102
+ });
103
+ app.get(`${base}/:id`, zValidator("param", ObjectIdParam, validationHook), zValidator("query", ObjectReadQuery, validationHook), async (c) => {
104
+ const deps = await resolve(c);
105
+ const object = await readableObject(deps, c.req.valid("param").id);
106
+ return stream(c, deps, object, c.req.valid("query").download === "1");
107
+ });
108
+ app.on("HEAD", `${base}/:id`, requireAuth(), zValidator("param", ObjectIdParam, validationHook), async (c) => {
109
+ const deps = await resolve(c);
110
+ const object = await readableObject(deps, c.req.valid("param").id);
111
+ const metadata = await deps.store.head(object.key);
112
+ if (!metadata) return c.notFound();
113
+ return serveMetadata({
114
+ metadata,
115
+ path: object.path,
116
+ visibility: object.visibility
117
+ });
118
+ });
119
+ app.patch(`${base}/:id`, requireAuth(), zValidator("param", ObjectIdParam, validationHook), zValidator("json", UpdateObjectInput, validationHook), async (c) => {
120
+ return c.json(await updateObject(await resolve(c), c.req.valid("param").id, c.req.valid("json")));
121
+ });
122
+ app.delete(`${base}/:id`, requireAuth(), zValidator("param", ObjectIdParam, validationHook), async (c) => {
123
+ return c.json(await deleteObject(await resolve(c), c.req.valid("param").id));
124
+ });
125
+ app.get(`${share}/:token`, zValidator("param", ShareTokenParam, validationHook), zValidator("query", ObjectReadQuery, validationHook), async (c) => {
126
+ const deps = await resolve(c);
127
+ const object = await resolveShare(deps, c.req.valid("param").token);
128
+ return stream(c, deps, object, c.req.valid("query").download === "1");
129
+ });
130
+ };
131
+ }
132
+ //#endregion
133
+ export { registerStorageRoutes };
@@ -0,0 +1,72 @@
1
+ import { z } from "zod";
2
+ /**
3
+ * The `:id` path parameter every single-object route carries. Deliberately a bounded generic string
4
+ * and **not** `z.uuid()`: ids are minted with `crypto.randomUUID()`, but this is a shape check, not a
5
+ * lookup. A well-formed id nobody owns must still reach the handler and answer `storage/not_found`
6
+ * (404) — the answer that keeps the route from being an enumeration oracle. A UUID check would turn
7
+ * that into a 400 and hand back a shape the caller could probe against.
8
+ */
9
+ export declare const ObjectIdParam: z.ZodObject<{
10
+ id: z.ZodString;
11
+ }, z.core.$strip>;
12
+ export type ObjectIdParam = z.output<typeof ObjectIdParam>;
13
+ /**
14
+ * The `:token` path parameter the two share routes carry. Bounded only — a minted token is 43
15
+ * base64url characters, but the bound exists to stop an unbounded string reaching the shares table,
16
+ * not to pre-empt the lookup. An unknown-but-well-formed token still answers `storage/not_found`.
17
+ */
18
+ export declare const ShareTokenParam: z.ZodObject<{
19
+ token: z.ZodString;
20
+ }, z.core.$strip>;
21
+ export type ShareTokenParam = z.output<typeof ShareTokenParam>;
22
+ /**
23
+ * The query string an object read accepts. Only `?download=1` means anything; every other value is
24
+ * simply not a download, which is what the bare string comparison said before and still says. Typed
25
+ * as a bounded string rather than `z.literal("1")` because `?download=0` is a request that works
26
+ * today, and a literal would answer it with a 400.
27
+ */
28
+ export declare const ObjectReadQuery: z.ZodObject<{
29
+ download: z.ZodOptional<z.ZodString>;
30
+ }, z.core.$strip>;
31
+ export type ObjectReadQuery = z.output<typeof ObjectReadQuery>;
32
+ export declare const CreateUploadInput: z.ZodObject<{
33
+ path: z.ZodString;
34
+ contentType: z.ZodString;
35
+ size: z.ZodNumber;
36
+ visibility: z.ZodOptional<z.ZodEnum<{
37
+ private: "private";
38
+ public: "public";
39
+ }>>;
40
+ }, z.core.$strip>;
41
+ export type CreateUploadInput = z.output<typeof CreateUploadInput>;
42
+ export declare const CompleteUploadInput: z.ZodObject<{
43
+ parts: z.ZodDefault<z.ZodArray<z.ZodObject<{
44
+ partNumber: z.ZodNumber;
45
+ etag: z.ZodString;
46
+ }, z.core.$strip>>>;
47
+ checksum: z.ZodOptional<z.ZodString>;
48
+ }, z.core.$strip>;
49
+ export type CompleteUploadInput = z.output<typeof CompleteUploadInput>;
50
+ export declare const UpdateObjectInput: z.ZodObject<{
51
+ path: z.ZodOptional<z.ZodString>;
52
+ visibility: z.ZodOptional<z.ZodEnum<{
53
+ private: "private";
54
+ public: "public";
55
+ }>>;
56
+ }, z.core.$strip>;
57
+ export type UpdateObjectInput = z.output<typeof UpdateObjectInput>;
58
+ export declare const CopyObjectInput: z.ZodObject<{
59
+ path: z.ZodString;
60
+ }, z.core.$strip>;
61
+ export type CopyObjectInput = z.output<typeof CopyObjectInput>;
62
+ export declare const CreateShareInput: z.ZodObject<{
63
+ expiresInSeconds: z.ZodOptional<z.ZodNumber>;
64
+ }, z.core.$strip>;
65
+ export type CreateShareInput = z.output<typeof CreateShareInput>;
66
+ export declare const ListObjectsQuery: z.ZodObject<{
67
+ prefix: z.ZodOptional<z.ZodString>;
68
+ cursor: z.ZodOptional<z.ZodString>;
69
+ limit: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
70
+ }, z.core.$strip>;
71
+ export type ListObjectsQuery = z.output<typeof ListObjectsQuery>;
72
+ //# sourceMappingURL=schemas.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../src/http/schemas.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAkDxB;;;;;;GAMG;AACH,eAAO,MAAM,aAAa;;iBAQsC,CAAC;AACjE,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,aAAa,CAAC,CAAC;AAE3D;;;;GAIG;AACH,eAAO,MAAM,eAAe;;iBAQiC,CAAC;AAC9D,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,eAAe,CAAC,CAAC;AAE/D;;;;;GAKG;AACH,eAAO,MAAM,eAAe;;iBAQiE,CAAC;AAC9F,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,eAAe,CAAC,CAAC;AAE/D,eAAO,MAAM,iBAAiB;;;;;;;;iBAqBuE,CAAC;AACtG,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAEnE,eAAO,MAAM,mBAAmB;;;;;;iBAgBqE,CAAC;AACtG,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAEvE,eAAO,MAAM,iBAAiB;;;;;;iBAmB1B,CAAC;AACL,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAEnE,eAAO,MAAM,eAAe;;iBAE8D,CAAC;AAC3F,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,eAAe,CAAC,CAAC;AAK/D,eAAO,MAAM,gBAAgB;;iBAYwC,CAAC;AACtE,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAEjE,eAAO,MAAM,gBAAgB;;;;iBAoBgC,CAAC;AAC9D,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,gBAAgB,CAAC,CAAC"}
@@ -0,0 +1,91 @@
1
+ import { StorageVisibility } from "../data/storageObject.js";
2
+ import { ReportedPart } from "../object/multipart.js";
3
+ import { MAX_OBJECT_KEY_BYTES } from "../object/key.js";
4
+ import { z } from "zod";
5
+ //#region src/http/schemas.ts
6
+ /**
7
+ * The request schemas for the storage routes. Every path parameter, query string and body is parsed
8
+ * here before a handler sees it (CLAUDE.md §Zod: validate at every boundary), declared on the route
9
+ * line with `zValidator(target, Schema, validationHook)` — so reading `routes.ts` tells you what a
10
+ * route accepts without opening a handler. A failure maps to `validation/invalid_input` through
11
+ * `fromZodError`.
12
+ *
13
+ * Two shapes deserve a note.
14
+ *
15
+ * **`path` is bounded and control-character-free, but otherwise unconstrained.** It is the adopter's
16
+ * logical name and never becomes an R2 key, so `../` is not a traversal — it is just an odd file
17
+ * name. What it *is* is a value that gets stored, listed, and eventually rendered somewhere, so a NUL
18
+ * or a newline in it is rejected: those break log lines, headers, and `Content-Disposition` rather
19
+ * than escaping a prefix. The length bound matches R2's key limit even though the path is not a key,
20
+ * because an unbounded text column is an easy way to fill someone's database.
21
+ *
22
+ * **`size` is required on upload-init.** A presigned PUT signs `Content-Length`, so the client must
23
+ * commit to a byte count before a URL can be minted at all. It is also what the `pending` row
24
+ * reserves against the owner's quota — a null size would reserve nothing and make the quota a
25
+ * suggestion under concurrency (see `quota/quota.ts`).
26
+ */
27
+ /**
28
+ * Whether a path is free of C0 control characters and DEL. Written as a scan rather than a regex
29
+ * because a regex spelling this needs literal control-character escapes, which Biome rejects — and
30
+ * the rule it rejects them under is a good one.
31
+ */
32
+ function isPrintablePath(value) {
33
+ for (let index = 0; index < value.length; index += 1) {
34
+ const code = value.charCodeAt(index);
35
+ if (code < 32 || code === 127) return false;
36
+ }
37
+ return true;
38
+ }
39
+ /** The logical path field, shared by upload-init, rename, and copy so the three cannot drift apart. */
40
+ const logicalPath = z.string().min(1).max(MAX_OBJECT_KEY_BYTES).refine(isPrintablePath, { error: "A path may not contain control characters." }).describe("The file's logical name, e.g. `invoices/2026/q3.pdf`. Stored, indexed, and listable by prefix; never part of the R2 key, so slashes are naming, not directories.");
41
+ /**
42
+ * The `:id` path parameter every single-object route carries. Deliberately a bounded generic string
43
+ * and **not** `z.uuid()`: ids are minted with `crypto.randomUUID()`, but this is a shape check, not a
44
+ * lookup. A well-formed id nobody owns must still reach the handler and answer `storage/not_found`
45
+ * (404) — the answer that keeps the route from being an enumeration oracle. A UUID check would turn
46
+ * that into a 400 and hand back a shape the caller could probe against.
47
+ */
48
+ const ObjectIdParam = z.object({ id: z.string().min(1).max(128).describe("The object id from the path. Bounded so an unbounded string never reaches the database.") }).describe("The path parameter identifying one stored object.");
49
+ /**
50
+ * The `:token` path parameter the two share routes carry. Bounded only — a minted token is 43
51
+ * base64url characters, but the bound exists to stop an unbounded string reaching the shares table,
52
+ * not to pre-empt the lookup. An unknown-but-well-formed token still answers `storage/not_found`.
53
+ */
54
+ const ShareTokenParam = z.object({ token: z.string().min(1).max(128).describe("The share token from the path — the credential itself, checked against the shares table.") }).describe("The path parameter identifying one share link.");
55
+ /**
56
+ * The query string an object read accepts. Only `?download=1` means anything; every other value is
57
+ * simply not a download, which is what the bare string comparison said before and still says. Typed
58
+ * as a bounded string rather than `z.literal("1")` because `?download=0` is a request that works
59
+ * today, and a literal would answer it with a 400.
60
+ */
61
+ const ObjectReadQuery = z.object({ download: z.string().max(16).optional().describe("`1` serves the bytes as an attachment. Anything else, or omitted, serves them inline.") }).describe("Query parameters for reading an object's bytes, by id or through a share link.");
62
+ const CreateUploadInput = z.object({
63
+ path: logicalPath,
64
+ contentType: z.string().min(1).max(255).describe("The file's MIME type, as you intend it. A declaration, not a constraint: a presigned PUT cannot sign a content type, so completion replaces this with the type R2 actually stored."),
65
+ size: z.number().int().nonnegative().describe("The exact byte count. Required: the presigned PUT signs Content-Length, and the pending row reserves these bytes against the owner's quota the moment it is written."),
66
+ visibility: StorageVisibility.optional().describe("Who may read the file once stored. Omitted takes the configured default, which is private.")
67
+ }).describe("A request to start an upload — what the file is called, what it is, and how big it is.");
68
+ const CompleteUploadInput = z.object({
69
+ parts: z.array(ReportedPart).default([]).describe("Every part's number and the ETag R2 answered its PUT with. Empty for a single-PUT upload, which has no parts to assemble."),
70
+ checksum: z.string().regex(/^[0-9a-f]{64}$/).optional().describe("Lowercase hex SHA-256 the client computed over the bytes it sent. Recorded, not verified server-side.")
71
+ }).describe("A request to finalize an upload — the parts to assemble, and optionally what was sent.");
72
+ const UpdateObjectInput = z.object({
73
+ path: logicalPath.optional(),
74
+ visibility: StorageVisibility.optional().describe("Change who may read the file. Takes effect on the next request.")
75
+ }).describe("A rename, a visibility change, or both. At least one field must be present.").check((ctx) => {
76
+ if (ctx.value.path === void 0 && ctx.value.visibility === void 0) ctx.issues.push({
77
+ code: "custom",
78
+ input: ctx.value,
79
+ path: [],
80
+ message: "Send a path, a visibility, or both — an empty patch changes nothing."
81
+ });
82
+ });
83
+ const CopyObjectInput = z.object({ path: logicalPath }).describe("A server-side copy — the new file's logical path. The bytes never leave R2.");
84
+ const CreateShareInput = z.object({ expiresInSeconds: z.number().int().positive().max(31536e3).optional().describe("How long the link works, in seconds. Omitted never expires — revocation is then the only way to end it, which is a deliberate choice rather than a default.") }).describe("A request to mint a revocable share link for one file.");
85
+ const ListObjectsQuery = z.object({
86
+ prefix: z.string().max(MAX_OBJECT_KEY_BYTES).optional().describe("Only files whose logical path starts with this. Omitted lists everything you own."),
87
+ cursor: z.string().min(1).optional().describe("The `cursor` a previous page returned. Opaque — pass it back unchanged to advance."),
88
+ limit: z.coerce.number().int().min(1).max(100).optional().describe("Files per page. Defaults to 50, capped at 100 so one request cannot scan an entire owner's files.")
89
+ }).describe("Query parameters for the owner's file listing.");
90
+ //#endregion
91
+ export { CompleteUploadInput, CopyObjectInput, CreateShareInput, CreateUploadInput, ListObjectsQuery, ObjectIdParam, ObjectReadQuery, ShareTokenParam, UpdateObjectInput };
@@ -0,0 +1,119 @@
1
+ import type { ReadableStream } from "@cloudflare/workers-types";
2
+ import type { ObjectConditions, ObjectMetadata, ObjectRange } from "../object/store";
3
+ /**
4
+ * Turning an object read into an HTTP response — the one part of storage where bytes *do* pass
5
+ * through the Worker, and the reason they do.
6
+ *
7
+ * Uploads never proxy through the Worker: the client PUTs straight to a presigned URL, so a 40 GiB
8
+ * file costs the Worker one request and not one byte of transfer (that request presigns 640 part URLs
9
+ * at the default part size — the saving is the bytes, not the signatures). Downloads are the opposite
10
+ * trade, on purpose. A presigned GET
11
+ * cannot be authorized per request (the signature is the authorization, and it is bearer-equivalent
12
+ * once it leaves), cannot be revoked, and cannot carry a `Content-Disposition` the server chose. The
13
+ * moment a file has an owner, a visibility, or a share that can be withdrawn, the read has to be a
14
+ * request the Worker answers. `GET /storage/:id/url` is the escape hatch for callers who would rather
15
+ * have the throughput than the control — it is offered, not the default.
16
+ *
17
+ * Given that, this module owns the parts of HTTP that make a byte-serving route correct rather than
18
+ * merely working: `Range` (206), `If-None-Match` (304), `ETag`, `Content-Length`, `Content-Range`,
19
+ * `Content-Disposition`, and a `Cache-Control` that follows the object's visibility.
20
+ *
21
+ * **Every byte served here is untrusted, and it is served from the adopter's own origin.** That is the
22
+ * threat this module exists to contain. An authenticated user uploads the bytes *and* declares the type;
23
+ * the adopter chooses the mount point, so the response shares an origin with every other Pithy route and
24
+ * with the adopter's own app. There is no separate sandbox domain to fall back on, and we cannot invent
25
+ * one on their behalf. So the server decides how the bytes present, not the uploader:
26
+ *
27
+ * - `X-Content-Type-Options: nosniff` and `Content-Security-Policy: default-src 'none'; sandbox` on
28
+ * **every** object response — the id route, `HEAD`, and the share route all build headers here.
29
+ * - An **active type is neutralised**: `text/html`, any `+xml` (which is where `image/svg+xml` lives),
30
+ * and script types are served as `application/octet-stream` with `Content-Disposition: attachment`,
31
+ * whatever was stored and whatever `?download=` said. SVG is the one that makes `attachment`
32
+ * non-negotiable rather than belt-and-braces: it is *meant* to render inline, and a CSP on this
33
+ * response does not travel with it when another origin loads it as an `<img>`.
34
+ * - **`Content-Disposition` is derived, never replayed.** A stored disposition is a string the uploader
35
+ * chose, and honoring it would let them pin `inline` on the very content the rule above forces down.
36
+ *
37
+ * The cost is that this route will not host an adopter's own HTML or JavaScript assets. That is the
38
+ * right trade: it is a store for user files, and Workers Assets or a bucket on its own domain is where
39
+ * first-party markup belongs.
40
+ *
41
+ * **Ranges are resolved against the row's recorded size, not against R2's echo.** A `stored` row
42
+ * knows the object's byte count — it was confirmed against R2 at completion — so `bytes=-500` can be
43
+ * turned into an explicit offset and length before R2 is touched. That makes `Content-Range` exact,
44
+ * makes an unsatisfiable range a 416 that costs no read at all, and removes any dependence on which
45
+ * of R2's four range shapes comes back. A row with no recorded size simply serves the whole object;
46
+ * a wrong `Content-Range` is worse than no range support.
47
+ */
48
+ /** How a `Range` header resolved against a known object size. */
49
+ export type RangeRequest =
50
+ /** No usable range — serve the whole object, 200. */
51
+ {
52
+ kind: "none";
53
+ }
54
+ /** A single satisfiable byte range — serve 206. */
55
+ | {
56
+ kind: "bytes";
57
+ offset: number;
58
+ length: number;
59
+ }
60
+ /** A syntactically valid range that starts past the end — 416. */
61
+ | {
62
+ kind: "unsatisfiable";
63
+ };
64
+ /**
65
+ * Resolve a `Range` header against the object's recorded size.
66
+ *
67
+ * Multi-range requests (`bytes=0-9,20-29`) are answered with the **whole object**, which RFC 9110
68
+ * explicitly permits: a server may ignore a range it does not wish to satisfy. Building a
69
+ * `multipart/byteranges` body would mean buffering and re-framing every part in the Worker, which is
70
+ * the exact cost this design is trying not to pay, for a feature essentially nothing asks for.
71
+ */
72
+ export declare function parseRangeHeader(header: string | null | undefined, size: number | null): RangeRequest;
73
+ /** The store-level range for a resolved request, or `undefined` for a whole-object read. */
74
+ export declare function toObjectRange(request: RangeRequest): ObjectRange | undefined;
75
+ /**
76
+ * The conditional-read preconditions a request's headers imply. Only `If-None-Match` is honored: it
77
+ * is the one that saves a transfer, and the one every cache and browser actually sends. `If-Match`
78
+ * guards writes, which this route does not perform.
79
+ */
80
+ export declare function parseConditions(ifNoneMatch: string | null | undefined): ObjectConditions | undefined;
81
+ /** What a serve path knows beyond the object's own metadata. */
82
+ export interface ServeOptions {
83
+ /** The object's metadata, as `head` or `get` reported it. */
84
+ metadata: ObjectMetadata;
85
+ /** The logical path — its last segment becomes the download filename. */
86
+ path: string;
87
+ /** Whether anyone may read the object, which decides whether a shared cache may hold it. */
88
+ visibility: "private" | "public";
89
+ /** Serve as a download (`attachment`) rather than inline. */
90
+ download?: boolean;
91
+ }
92
+ /** A response body plus the range it covers. */
93
+ export interface ServeBody {
94
+ /** The bytes. `null` means a precondition failed — the 304 signal. */
95
+ body: ReadableStream | null;
96
+ /** The range served, or `null` for the whole object. */
97
+ range: {
98
+ offset: number;
99
+ length: number;
100
+ } | null;
101
+ }
102
+ /**
103
+ * Build the response for an object read: 304 when a precondition failed, 206 when a range was served,
104
+ * 200 otherwise.
105
+ *
106
+ * `Content-Length` is the *served* byte count, so a ranged response reports the range's length while
107
+ * `Content-Range` reports the whole object's size. Getting that pair backwards is the classic way a
108
+ * range implementation appears to work until a client tries to resume.
109
+ */
110
+ export declare function serveObject(options: ServeOptions & ServeBody): Response;
111
+ /**
112
+ * The `HEAD` response: exactly the headers a `GET` would carry, with no body. Same builder as the
113
+ * 200 path, so the two cannot describe the same object differently — which is the only thing that
114
+ * makes a `HEAD` worth issuing.
115
+ */
116
+ export declare function serveMetadata(options: ServeOptions): Response;
117
+ /** The 416 response. `Content-Range: bytes * /size` tells the client what range would have been valid. */
118
+ export declare function rangeNotSatisfiable(size: number): Response;
119
+ //# sourceMappingURL=serve.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"serve.d.ts","sourceRoot":"","sources":["../../src/http/serve.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAChE,OAAO,KAAK,EAAE,gBAAgB,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAErF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AAEH,iEAAiE;AACjE,MAAM,MAAM,YAAY;AACtB,qDAAqD;AACnD;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE;AAClB,mDAAmD;GACjD;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE;AACnD,kEAAkE;GAChE;IAAE,IAAI,EAAE,eAAe,CAAA;CAAE,CAAC;AAK9B;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,YAAY,CAwBrG;AAED,4FAA4F;AAC5F,wBAAgB,aAAa,CAAC,OAAO,EAAE,YAAY,GAAG,WAAW,GAAG,SAAS,CAE5E;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,gBAAgB,GAAG,SAAS,CAQpG;AAQD,gEAAgE;AAChE,MAAM,WAAW,YAAY;IAC3B,6DAA6D;IAC7D,QAAQ,EAAE,cAAc,CAAC;IACzB,yEAAyE;IACzE,IAAI,EAAE,MAAM,CAAC;IACb,4FAA4F;IAC5F,UAAU,EAAE,SAAS,GAAG,QAAQ,CAAC;IACjC,6DAA6D;IAC7D,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,gDAAgD;AAChD,MAAM,WAAW,SAAS;IACxB,sEAAsE;IACtE,IAAI,EAAE,cAAc,GAAG,IAAI,CAAC;IAC5B,wDAAwD;IACxD,KAAK,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC;CAClD;AAmGD;;;;;;;GAOG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE,YAAY,GAAG,SAAS,GAAG,QAAQ,CAsBvE;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,YAAY,GAAG,QAAQ,CAI7D;AAED,0GAA0G;AAC1G,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,QAAQ,CAE1D"}
@@ -0,0 +1,207 @@
1
+ //#region src/http/serve.ts
2
+ /** `bytes=<first>-<last>` / `bytes=<first>-` / `bytes=-<suffix>`, with optional whitespace. */
3
+ const RANGE_PATTERN = /^bytes=(\d*)-(\d*)$/;
4
+ /**
5
+ * Resolve a `Range` header against the object's recorded size.
6
+ *
7
+ * Multi-range requests (`bytes=0-9,20-29`) are answered with the **whole object**, which RFC 9110
8
+ * explicitly permits: a server may ignore a range it does not wish to satisfy. Building a
9
+ * `multipart/byteranges` body would mean buffering and re-framing every part in the Worker, which is
10
+ * the exact cost this design is trying not to pay, for a feature essentially nothing asks for.
11
+ */
12
+ function parseRangeHeader(header, size) {
13
+ if (!header || size === null) return { kind: "none" };
14
+ const match = RANGE_PATTERN.exec(header.trim());
15
+ if (!match) return { kind: "none" };
16
+ const [, rawFirst, rawLast] = match;
17
+ if (rawFirst === "") {
18
+ const suffix = Number(rawLast);
19
+ if (rawLast === "" || !Number.isFinite(suffix) || suffix <= 0) return { kind: "none" };
20
+ if (size === 0) return { kind: "unsatisfiable" };
21
+ const length = Math.min(suffix, size);
22
+ return {
23
+ kind: "bytes",
24
+ offset: size - length,
25
+ length
26
+ };
27
+ }
28
+ const offset = Number(rawFirst);
29
+ if (!Number.isFinite(offset)) return { kind: "none" };
30
+ if (offset >= size) return { kind: "unsatisfiable" };
31
+ const last = rawLast === "" ? size - 1 : Math.min(Number(rawLast), size - 1);
32
+ if (!Number.isFinite(last) || last < offset) return { kind: "none" };
33
+ return {
34
+ kind: "bytes",
35
+ offset,
36
+ length: last - offset + 1
37
+ };
38
+ }
39
+ /** The store-level range for a resolved request, or `undefined` for a whole-object read. */
40
+ function toObjectRange(request) {
41
+ return request.kind === "bytes" ? {
42
+ offset: request.offset,
43
+ length: request.length
44
+ } : void 0;
45
+ }
46
+ /**
47
+ * The conditional-read preconditions a request's headers imply. Only `If-None-Match` is honored: it
48
+ * is the one that saves a transfer, and the one every cache and browser actually sends. `If-Match`
49
+ * guards writes, which this route does not perform.
50
+ */
51
+ function parseConditions(ifNoneMatch) {
52
+ if (!ifNoneMatch) return void 0;
53
+ const value = ifNoneMatch.trim();
54
+ if (value === "*") return void 0;
55
+ const etag = unquoteEtag(value.split(",")[0]?.trim() ?? "");
56
+ return etag ? { etagDoesNotMatch: etag } : void 0;
57
+ }
58
+ /** Strip a weak-validator prefix and the surrounding quotes — R2 stores and compares the bare tag. */
59
+ function unquoteEtag(value) {
60
+ return (value.startsWith("W/") ? value.slice(2) : value).replace(/^"|"$/g, "");
61
+ }
62
+ /**
63
+ * Cache lifetimes. A private object is revalidated every time — its authorization can change between
64
+ * two requests, and a cached copy would outlive a visibility change or a revoked share. A public
65
+ * object is immutable in practice (a new upload gets a new id and a new key), so it is cacheable for
66
+ * an hour by shared caches.
67
+ */
68
+ const PRIVATE_CACHE_CONTROL = "private, no-cache, must-revalidate";
69
+ const PUBLIC_CACHE_CONTROL = "public, max-age=3600";
70
+ /** What an object is served as when its stored type is not one a browser may be trusted with. */
71
+ const NEUTRAL_CONTENT_TYPE = "application/octet-stream";
72
+ /**
73
+ * The policy every object response carries. `default-src 'none'` means a document made out of these
74
+ * bytes can load nothing and reach nothing; `sandbox` (with no allow-list) drops it into an opaque
75
+ * origin, so even if a browser were talked into rendering it, it is not the adopter's origin any more.
76
+ */
77
+ const OBJECT_CSP = "default-src 'none'; sandbox";
78
+ /**
79
+ * Types a browser will execute, or render as a document that can execute. Served neutralised.
80
+ *
81
+ * The `+xml` suffix rule is what carries `image/svg+xml`, `application/xhtml+xml` and every structured
82
+ * XML type an adopter has not thought of; the set holds the ones with no suffix to key on. Script types
83
+ * are here because `nosniff` protects a *document* from being re-typed, not a correctly-typed script
84
+ * from being pulled in by a `<script src>` on some other page.
85
+ */
86
+ const ACTIVE_CONTENT_TYPES = /* @__PURE__ */ new Set([
87
+ "text/html",
88
+ "text/xml",
89
+ "text/xsl",
90
+ "text/javascript",
91
+ "text/ecmascript",
92
+ "application/xml",
93
+ "application/javascript",
94
+ "application/x-javascript",
95
+ "application/ecmascript"
96
+ ]);
97
+ /** The bare type/subtype, lowercased — `Text/HTML; charset=utf-8` is `text/html` for this decision. */
98
+ function contentTypeEssence(value) {
99
+ return (value.split(";")[0] ?? "").trim().toLowerCase();
100
+ }
101
+ /** Whether a stored type is one the server refuses to serve as itself. */
102
+ function isActiveContentType(value) {
103
+ const essence = contentTypeEssence(value);
104
+ return ACTIVE_CONTENT_TYPES.has(essence) || essence.endsWith("+xml");
105
+ }
106
+ /** The type to send, and whether that decision also forces a download. */
107
+ function resolveContentType(metadata) {
108
+ const stored = metadata.contentType;
109
+ if (!stored) return {
110
+ contentType: NEUTRAL_CONTENT_TYPE,
111
+ forceAttachment: false
112
+ };
113
+ if (isActiveContentType(stored)) return {
114
+ contentType: NEUTRAL_CONTENT_TYPE,
115
+ forceAttachment: true
116
+ };
117
+ return {
118
+ contentType: stored,
119
+ forceAttachment: false
120
+ };
121
+ }
122
+ /** The headers every object response carries, regardless of status. */
123
+ function baseHeaders(options) {
124
+ const { contentType, forceAttachment } = resolveContentType(options.metadata);
125
+ const headers = new Headers();
126
+ headers.set("Content-Type", contentType);
127
+ headers.set("X-Content-Type-Options", "nosniff");
128
+ headers.set("Content-Security-Policy", OBJECT_CSP);
129
+ headers.set("ETag", `"${options.metadata.etag}"`);
130
+ headers.set("Cache-Control", options.visibility === "public" ? PUBLIC_CACHE_CONTROL : PRIVATE_CACHE_CONTROL);
131
+ headers.set("Accept-Ranges", "bytes");
132
+ headers.set("Content-Disposition", contentDisposition(options, forceAttachment));
133
+ return headers;
134
+ }
135
+ /**
136
+ * The `Content-Disposition` value, always built from the logical path's last segment. The stored
137
+ * disposition is deliberately ignored: the uploader wrote it, so honoring it would hand them back the
138
+ * `inline` this module just took away — and it would replay an unsanitised string into a response
139
+ * header. The server decides how its own origin presents bytes.
140
+ *
141
+ * Both forms of the filename are emitted — a quote-stripped ASCII `filename` for old clients and an
142
+ * RFC 5987 `filename*` for everything since — because a UTF-8 name in the bare parameter is what
143
+ * makes a browser save `q3.pdf` as `q3.pdf.txt` or worse. Quotes and backslashes are dropped rather
144
+ * than escaped: a filename is not worth a header-injection surface.
145
+ */
146
+ function contentDisposition(options, forceAttachment) {
147
+ const type = forceAttachment || options.download ? "attachment" : "inline";
148
+ const segments = options.path.split("/");
149
+ const raw = segments[segments.length - 1] ?? "download";
150
+ const ascii = raw.replace(/[^\x20-\x7e]/g, "_").replace(/["\\]/g, "");
151
+ return `${type}; filename="${ascii.length > 0 ? ascii : "download"}"; filename*=UTF-8''${encodeURIComponent(raw)}`;
152
+ }
153
+ /**
154
+ * Build the response for an object read: 304 when a precondition failed, 206 when a range was served,
155
+ * 200 otherwise.
156
+ *
157
+ * `Content-Length` is the *served* byte count, so a ranged response reports the range's length while
158
+ * `Content-Range` reports the whole object's size. Getting that pair backwards is the classic way a
159
+ * range implementation appears to work until a client tries to resume.
160
+ */
161
+ function serveObject(options) {
162
+ const headers = baseHeaders(options);
163
+ if (options.body === null) {
164
+ headers.delete("Content-Type");
165
+ headers.delete("Content-Disposition");
166
+ return new Response(null, {
167
+ status: 304,
168
+ headers
169
+ });
170
+ }
171
+ if (options.range) {
172
+ const { offset, length } = options.range;
173
+ headers.set("Content-Length", String(length));
174
+ headers.set("Content-Range", `bytes ${offset}-${offset + length - 1}/${options.metadata.size}`);
175
+ return new Response(options.body, {
176
+ status: 206,
177
+ headers
178
+ });
179
+ }
180
+ headers.set("Content-Length", String(options.metadata.size));
181
+ return new Response(options.body, {
182
+ status: 200,
183
+ headers
184
+ });
185
+ }
186
+ /**
187
+ * The `HEAD` response: exactly the headers a `GET` would carry, with no body. Same builder as the
188
+ * 200 path, so the two cannot describe the same object differently — which is the only thing that
189
+ * makes a `HEAD` worth issuing.
190
+ */
191
+ function serveMetadata(options) {
192
+ const headers = baseHeaders(options);
193
+ headers.set("Content-Length", String(options.metadata.size));
194
+ return new Response(null, {
195
+ status: 200,
196
+ headers
197
+ });
198
+ }
199
+ /** The 416 response. `Content-Range: bytes * /size` tells the client what range would have been valid. */
200
+ function rangeNotSatisfiable(size) {
201
+ return new Response(null, {
202
+ status: 416,
203
+ headers: { "Content-Range": `bytes */${size}` }
204
+ });
205
+ }
206
+ //#endregion
207
+ export { parseConditions, parseRangeHeader, rangeNotSatisfiable, serveMetadata, serveObject, toObjectRange };
@@ -0,0 +1,21 @@
1
+ /**
2
+ * The package entrypoint — the surface `pithy add storage` wires into `pithy.config.ts`.
3
+ *
4
+ * Deliberately narrow: the capability factory and its config, the {@link ObjectStore} seam another
5
+ * capability holds to move bytes (`@pithy-sh/media` is the first), the registry factory that makes a
6
+ * second bucket's credentials resolvable, and the table schemas an adopter reads rows against. Every
7
+ * other module is imported by deep path (`@pithy-sh/storage/src/...`); this is the documented
8
+ * contract, not a barrel over the package.
9
+ */
10
+ export { isStorageCapability, STORAGE_MIGRATION_ORDER, type StorageCapability, type StorageOptions, storage, } from "./capability";
11
+ export { maxObjectBytes, StorageConfig, type StorageConfigInput, StorageQuota } from "./config/config";
12
+ export { StorageShare } from "./data/share";
13
+ export { StorageObject, StorageObjectStatus, StorageVisibility } from "./data/storageObject";
14
+ export { STORAGE_OBJECTS_TABLE, STORAGE_SHARES_TABLE, type StorageDatabase, storageDatabase } from "./data/tables";
15
+ export { deriveObjectKey, isDerivedObjectKey, OBJECT_KEY_PREFIX } from "./object/key";
16
+ export { collectParts, MultipartPlan, needsMultipart, PartPlan, planMultipart, ReportedPart } from "./object/multipart";
17
+ export { ObjectListing, ObjectMetadata, type ObjectStore, type ObjectStoreOptions, objectStore, type PresignedObjects, } from "./object/store";
18
+ export { R2StorageCredentials, r2CredentialsRegistry, STORAGE_R2_SECRET, storageSecretsRegistry, } from "./secret/registry";
19
+ export { STORAGE_CAPABILITY, StorageSweepParams, storageWorkflows } from "./workflows/specs";
20
+ export { type SweepDeps, type SweepResult, sweepStorage } from "./workflows/sweep";
21
+ //# sourceMappingURL=index.d.ts.map