@powerhousedao/switchboard 6.2.3-dev.8 → 6.2.3-dev.80

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 (272) hide show
  1. package/.tsbuild/test/attachments/byte-grants.test.d.ts +2 -0
  2. package/.tsbuild/test/attachments/byte-grants.test.d.ts.map +1 -0
  3. package/.tsbuild/test/attachments/byte-routes-read-gate.integration.test.d.ts +2 -0
  4. package/.tsbuild/test/attachments/byte-routes-read-gate.integration.test.d.ts.map +1 -0
  5. package/.tsbuild/test/attachments/reserve-metadata-parity.test.d.ts +2 -0
  6. package/.tsbuild/test/attachments/reserve-metadata-parity.test.d.ts.map +1 -0
  7. package/.tsbuild/test/attachments/url-signer.test.d.ts +2 -0
  8. package/.tsbuild/test/attachments/url-signer.test.d.ts.map +1 -0
  9. package/.tsbuild/test/boot-auth-config.test.d.ts +2 -0
  10. package/.tsbuild/test/boot-auth-config.test.d.ts.map +1 -0
  11. package/.tsbuild/test/boot-create-signature-policy.test.d.ts +2 -0
  12. package/.tsbuild/test/boot-create-signature-policy.test.d.ts.map +1 -0
  13. package/.tsbuild/test/boot-env-isolation.test.d.ts +2 -0
  14. package/.tsbuild/test/boot-env-isolation.test.d.ts.map +1 -0
  15. package/.tsbuild/test/boot-helpers.d.ts +5 -0
  16. package/.tsbuild/test/boot-helpers.d.ts.map +1 -0
  17. package/.tsbuild/test/boot-inspection-enabled.test.d.ts +2 -0
  18. package/.tsbuild/test/boot-inspection-enabled.test.d.ts.map +1 -0
  19. package/.tsbuild/test/boot-mcp-auth.test.d.ts +2 -0
  20. package/.tsbuild/test/boot-mcp-auth.test.d.ts.map +1 -0
  21. package/.tsbuild/test/boot-mcp-enabled.test.d.ts +2 -0
  22. package/.tsbuild/test/boot-mcp-enabled.test.d.ts.map +1 -0
  23. package/.tsbuild/test/boot-port-zero.test.d.ts +2 -0
  24. package/.tsbuild/test/boot-port-zero.test.d.ts.map +1 -0
  25. package/.tsbuild/test/boot-preconditions.test.d.ts +2 -0
  26. package/.tsbuild/test/boot-preconditions.test.d.ts.map +1 -0
  27. package/.tsbuild/test/boot-privacy.test.d.ts +2 -0
  28. package/.tsbuild/test/boot-privacy.test.d.ts.map +1 -0
  29. package/.tsbuild/test/boot-unsupported-stored-documents.test.d.ts +2 -0
  30. package/.tsbuild/test/boot-unsupported-stored-documents.test.d.ts.map +1 -0
  31. package/.tsbuild/test/boot-without-renown.test.d.ts +2 -0
  32. package/.tsbuild/test/boot-without-renown.test.d.ts.map +1 -0
  33. package/.tsbuild/test/boot-without-require-signatures.test.d.ts +2 -0
  34. package/.tsbuild/test/boot-without-require-signatures.test.d.ts.map +1 -0
  35. package/.tsbuild/test/boot-worker-trust-policy.test.d.ts +2 -0
  36. package/.tsbuild/test/boot-worker-trust-policy.test.d.ts.map +1 -0
  37. package/.tsbuild/test/boot-workflow-singleton-conflict.test.d.ts +2 -0
  38. package/.tsbuild/test/boot-workflow-singleton-conflict.test.d.ts.map +1 -0
  39. package/.tsbuild/test/boot-workflow-singleton-retry.test.d.ts +2 -0
  40. package/.tsbuild/test/boot-workflow-singleton-retry.test.d.ts.map +1 -0
  41. package/.tsbuild/test/builder-defaults.test.d.ts +2 -0
  42. package/.tsbuild/test/builder-defaults.test.d.ts.map +1 -0
  43. package/.tsbuild/test/config-from-env.test.d.ts +2 -0
  44. package/.tsbuild/test/config-from-env.test.d.ts.map +1 -0
  45. package/.tsbuild/test/config-merge.test.d.ts +2 -0
  46. package/.tsbuild/test/config-merge.test.d.ts.map +1 -0
  47. package/.tsbuild/test/config-schema.test.d.ts +2 -0
  48. package/.tsbuild/test/config-schema.test.d.ts.map +1 -0
  49. package/.tsbuild/test/create-signature-policy.test.d.ts +2 -0
  50. package/.tsbuild/test/create-signature-policy.test.d.ts.map +1 -0
  51. package/.tsbuild/test/default-drive-protocol-versions.test.d.ts +2 -0
  52. package/.tsbuild/test/default-drive-protocol-versions.test.d.ts.map +1 -0
  53. package/.tsbuild/test/default-drive-slug.test.d.ts +2 -0
  54. package/.tsbuild/test/default-drive-slug.test.d.ts.map +1 -0
  55. package/.tsbuild/test/durable-node-fs-pg16.test.d.ts +2 -0
  56. package/.tsbuild/test/durable-node-fs-pg16.test.d.ts.map +1 -0
  57. package/.tsbuild/test/fatal-shutdown.test.d.ts +2 -0
  58. package/.tsbuild/test/fatal-shutdown.test.d.ts.map +1 -0
  59. package/.tsbuild/test/inspection-throttle.test.d.ts +2 -0
  60. package/.tsbuild/test/inspection-throttle.test.d.ts.map +1 -0
  61. package/.tsbuild/test/observability-signals.test.d.ts +2 -0
  62. package/.tsbuild/test/observability-signals.test.d.ts.map +1 -0
  63. package/.tsbuild/test/permissions-backfill.test.d.ts +2 -0
  64. package/.tsbuild/test/permissions-backfill.test.d.ts.map +1 -0
  65. package/.tsbuild/test/pglite-preflight.test.d.ts +2 -0
  66. package/.tsbuild/test/pglite-preflight.test.d.ts.map +1 -0
  67. package/.tsbuild/test/pglite-storage-dirs.test.d.ts +2 -0
  68. package/.tsbuild/test/pglite-storage-dirs.test.d.ts.map +1 -0
  69. package/.tsbuild/test/pglite-store.test.d.ts +2 -0
  70. package/.tsbuild/test/pglite-store.test.d.ts.map +1 -0
  71. package/.tsbuild/test/plugin-config-schemas.test.d.ts +2 -0
  72. package/.tsbuild/test/plugin-config-schemas.test.d.ts.map +1 -0
  73. package/.tsbuild/test/plugin-presence.test.d.ts +2 -0
  74. package/.tsbuild/test/plugin-presence.test.d.ts.map +1 -0
  75. package/.tsbuild/test/port-probe.test.d.ts +2 -0
  76. package/.tsbuild/test/port-probe.test.d.ts.map +1 -0
  77. package/.tsbuild/test/renown-storage-path.test.d.ts +2 -0
  78. package/.tsbuild/test/renown-storage-path.test.d.ts.map +1 -0
  79. package/.tsbuild/test/renown-trust-policy.test.d.ts +2 -0
  80. package/.tsbuild/test/renown-trust-policy.test.d.ts.map +1 -0
  81. package/.tsbuild/test/served-schemas.test.d.ts +2 -0
  82. package/.tsbuild/test/served-schemas.test.d.ts.map +1 -0
  83. package/.tsbuild/test/shutdown.test.d.ts +2 -0
  84. package/.tsbuild/test/shutdown.test.d.ts.map +1 -0
  85. package/.tsbuild/test/snapshot-writer.d.ts +18 -0
  86. package/.tsbuild/test/snapshot-writer.d.ts.map +1 -0
  87. package/.tsbuild/test/store-lock.test.d.ts +2 -0
  88. package/.tsbuild/test/store-lock.test.d.ts.map +1 -0
  89. package/.tsbuild/test/two-switchboards.test.d.ts +2 -0
  90. package/.tsbuild/test/two-switchboards.test.d.ts.map +1 -0
  91. package/.tsbuild/test/unsupported-stored-documents.test.d.ts +2 -0
  92. package/.tsbuild/test/unsupported-stored-documents.test.d.ts.map +1 -0
  93. package/.tsbuild/test/workflow/harness.d.ts +56 -0
  94. package/.tsbuild/test/workflow/harness.d.ts.map +1 -0
  95. package/.tsbuild/test/workflow/oauth.test.d.ts +2 -0
  96. package/.tsbuild/test/workflow/oauth.test.d.ts.map +1 -0
  97. package/.tsbuild/test/workflow/resolvers.test.d.ts +2 -0
  98. package/.tsbuild/test/workflow/resolvers.test.d.ts.map +1 -0
  99. package/.tsbuild/test/workflow/runtime-host.test.d.ts +2 -0
  100. package/.tsbuild/test/workflow/runtime-host.test.d.ts.map +1 -0
  101. package/.tsbuild/test/workflow/webhook-dedupe.test.d.ts +2 -0
  102. package/.tsbuild/test/workflow/webhook-dedupe.test.d.ts.map +1 -0
  103. package/.tsbuild/test/workflow/webhook-signed.test.d.ts +2 -0
  104. package/.tsbuild/test/workflow/webhook-signed.test.d.ts.map +1 -0
  105. package/.tsbuild/test/workflow/webhook-trigger-test.test.d.ts +2 -0
  106. package/.tsbuild/test/workflow/webhook-trigger-test.test.d.ts.map +1 -0
  107. package/.tsbuild/test/workflow/webhook-unsigned.test.d.ts +2 -0
  108. package/.tsbuild/test/workflow/webhook-unsigned.test.d.ts.map +1 -0
  109. package/.tsbuild/test/workflow-reactor-access.test.d.ts +2 -0
  110. package/.tsbuild/test/workflow-reactor-access.test.d.ts.map +1 -0
  111. package/.tsbuild/test/workflow-reactor-enforcement.test.d.ts +2 -0
  112. package/.tsbuild/test/workflow-reactor-enforcement.test.d.ts.map +1 -0
  113. package/.tsbuild/test/workflow-read-gate.test.d.ts +2 -0
  114. package/.tsbuild/test/workflow-read-gate.test.d.ts.map +1 -0
  115. package/.tsbuild/test/workflow-runtime.test.d.ts +2 -0
  116. package/.tsbuild/test/workflow-runtime.test.d.ts.map +1 -0
  117. package/.tsbuild/test/workflows-plugin-config.test.d.ts +2 -0
  118. package/.tsbuild/test/workflows-plugin-config.test.d.ts.map +1 -0
  119. package/.tsbuild/tsconfig.tsbuildinfo +1 -1
  120. package/.tsbuild/tsdown.config.d.ts.map +1 -1
  121. package/.tsbuild/vitest.config.d.ts.map +1 -1
  122. package/Auth.md +144 -2
  123. package/CHANGELOG.md +1057 -0
  124. package/README.md +55 -14
  125. package/dist/boot.d.mts +46 -0
  126. package/dist/boot.d.mts.map +1 -0
  127. package/dist/boot.mjs +67 -0
  128. package/dist/boot.mjs.map +1 -0
  129. package/dist/config/from-env.d.mts +15 -0
  130. package/dist/config/from-env.d.mts.map +1 -0
  131. package/dist/config/from-env.mjs +4 -0
  132. package/dist/config/schema.d.mts +3 -0
  133. package/dist/config/schema.mjs +4 -0
  134. package/dist/from-env-BO0n9R02.mjs +401 -0
  135. package/dist/from-env-BO0n9R02.mjs.map +1 -0
  136. package/dist/index.d.mts +2 -1
  137. package/dist/index.mjs +76 -79
  138. package/dist/index.mjs.map +1 -1
  139. package/dist/install-packages.d.mts +2 -1
  140. package/dist/install-packages.mjs +2 -2
  141. package/dist/install-packages.mjs.map +1 -1
  142. package/dist/mcp-SsBK14Jm.mjs +32 -0
  143. package/dist/mcp-SsBK14Jm.mjs.map +1 -0
  144. package/dist/migrate.d.mts +2 -1
  145. package/dist/migrate.mjs +7 -5
  146. package/dist/migrate.mjs.map +1 -1
  147. package/dist/plugin-host-C1sYEm8g.d.mts +46 -0
  148. package/dist/plugin-host-C1sYEm8g.d.mts.map +1 -0
  149. package/dist/plugins/attachments.d.mts +33 -0
  150. package/dist/plugins/attachments.d.mts.map +1 -0
  151. package/dist/plugins/attachments.mjs +4 -0
  152. package/dist/plugins/mcp.d.mts +31 -0
  153. package/dist/plugins/mcp.d.mts.map +1 -0
  154. package/dist/plugins/mcp.mjs +4 -0
  155. package/dist/plugins/privacy.d.mts +22 -0
  156. package/dist/plugins/privacy.d.mts.map +1 -0
  157. package/dist/plugins/privacy.mjs +4 -0
  158. package/dist/plugins/workflows.d.mts +79 -0
  159. package/dist/plugins/workflows.d.mts.map +1 -0
  160. package/dist/plugins/workflows.mjs +4 -0
  161. package/dist/postgres-url-DTDhBjXX.mjs +11 -0
  162. package/dist/postgres-url-DTDhBjXX.mjs.map +1 -0
  163. package/dist/privacy-BO8Q25xI.mjs +44 -0
  164. package/dist/privacy-BO8Q25xI.mjs.map +1 -0
  165. package/dist/privacy-DxIJGH4P.mjs +91 -0
  166. package/dist/privacy-DxIJGH4P.mjs.map +1 -0
  167. package/dist/renown-layers-COZsrGQT.mjs +40 -0
  168. package/dist/renown-layers-COZsrGQT.mjs.map +1 -0
  169. package/dist/schema-0g_QdOWn.mjs +267 -0
  170. package/dist/schema-0g_QdOWn.mjs.map +1 -0
  171. package/dist/schema-ivUWPQOn.d.mts +202 -0
  172. package/dist/schema-ivUWPQOn.d.mts.map +1 -0
  173. package/dist/server-eNNf230W.mjs +2518 -0
  174. package/dist/server-eNNf230W.mjs.map +1 -0
  175. package/dist/server.d.mts +270 -48
  176. package/dist/server.d.mts.map +1 -1
  177. package/dist/server.mjs +5 -5
  178. package/dist/utils-BbV_nodR.mjs +119 -0
  179. package/dist/utils-BbV_nodR.mjs.map +1 -0
  180. package/dist/utils.d.mts +12 -5
  181. package/dist/utils.d.mts.map +1 -1
  182. package/dist/utils.mjs +4 -3
  183. package/dist/worker-pool-BWHBLBJd.mjs +304 -0
  184. package/dist/worker-pool-BWHBLBJd.mjs.map +1 -0
  185. package/dist/workflow-runtime-7GaJ13c9.d.mts +30 -0
  186. package/dist/workflow-runtime-7GaJ13c9.d.mts.map +1 -0
  187. package/dist/workflows-5Chwj98o.mjs +1440 -0
  188. package/dist/workflows-5Chwj98o.mjs.map +1 -0
  189. package/package.json +68 -23
  190. package/scripts/install-packages.sh +0 -0
  191. package/test/attachment-reference-read-model.test.ts +28 -20
  192. package/test/attachments/auth.test.ts +85 -0
  193. package/test/attachments/byte-grants.test.ts +290 -0
  194. package/test/attachments/byte-routes-read-gate.integration.test.ts +314 -0
  195. package/test/attachments/download-target.test.ts +211 -32
  196. package/test/attachments/index.test.ts +47 -4
  197. package/test/attachments/reserve-metadata-parity.test.ts +96 -0
  198. package/test/attachments/routes-integration.test.ts +60 -4
  199. package/test/attachments/routes.test.ts +297 -35
  200. package/test/attachments/service-config.test.ts +41 -19
  201. package/test/attachments/url-signer.test.ts +105 -0
  202. package/test/boot-auth-config.test.ts +109 -0
  203. package/test/boot-create-signature-policy.test.ts +110 -0
  204. package/test/boot-env-isolation.test.ts +26 -0
  205. package/test/boot-helpers.ts +19 -0
  206. package/test/boot-inspection-enabled.test.ts +140 -0
  207. package/test/boot-mcp-auth.test.ts +449 -0
  208. package/test/boot-mcp-enabled.test.ts +119 -0
  209. package/test/boot-port-zero.test.ts +101 -0
  210. package/test/boot-preconditions.test.ts +200 -0
  211. package/test/boot-privacy.test.ts +232 -0
  212. package/test/boot-unsupported-stored-documents.test.ts +214 -0
  213. package/test/boot-without-renown.test.ts +83 -0
  214. package/test/boot-without-require-signatures.test.ts +76 -0
  215. package/test/boot-worker-trust-policy.test.ts +91 -0
  216. package/test/boot-workflow-singleton-conflict.test.ts +109 -0
  217. package/test/boot-workflow-singleton-retry.test.ts +122 -0
  218. package/test/builder-defaults.test.ts +80 -0
  219. package/test/config-from-env.test.ts +758 -0
  220. package/test/config-merge.test.ts +215 -0
  221. package/test/config-schema.test.ts +128 -0
  222. package/test/create-signature-policy.test.ts +69 -0
  223. package/test/default-drive-protocol-versions.test.ts +78 -0
  224. package/test/default-drive-slug.test.ts +97 -0
  225. package/test/durable-node-fs-pg16.test.ts +80 -0
  226. package/test/fatal-shutdown.test.ts +165 -0
  227. package/test/goldens/packages.graphql +797 -0
  228. package/test/goldens/privacy.graphql +853 -0
  229. package/test/goldens/reactor-drive-nodes.graphql +827 -0
  230. package/test/goldens/resolvers.json +321 -0
  231. package/test/goldens/supergraph.graphql +5636 -0
  232. package/test/goldens/workflow-runtime.graphql +1403 -0
  233. package/test/inspection-throttle.test.ts +23 -0
  234. package/test/observability-signals.test.ts +131 -0
  235. package/test/permissions-backfill.test.ts +486 -0
  236. package/test/pglite-dialect.test.ts +237 -2
  237. package/test/pglite-preflight.test.ts +313 -0
  238. package/test/pglite-storage-dirs.test.ts +113 -0
  239. package/test/pglite-store.test.ts +264 -0
  240. package/test/pglite-version.test.ts +9 -1
  241. package/test/plugin-config-schemas.test.ts +83 -0
  242. package/test/plugin-presence.test.ts +262 -0
  243. package/test/port-probe.test.ts +45 -0
  244. package/test/renown-storage-path.test.ts +40 -0
  245. package/test/renown-trust-policy.test.ts +313 -0
  246. package/test/served-schemas.test.ts +134 -0
  247. package/test/shutdown.test.ts +278 -0
  248. package/test/snapshot-writer.ts +94 -0
  249. package/test/store-lock.test.ts +65 -0
  250. package/test/two-switchboards.test.ts +146 -0
  251. package/test/unsupported-stored-documents.test.ts +72 -0
  252. package/test/worker-pool.test.ts +27 -1
  253. package/test/workflow/harness.ts +289 -0
  254. package/test/workflow/oauth.test.ts +214 -0
  255. package/test/workflow/resolvers.test.ts +357 -0
  256. package/test/workflow/runtime-host.test.ts +20 -0
  257. package/test/workflow/webhook-dedupe.test.ts +295 -0
  258. package/test/workflow/webhook-signed.test.ts +509 -0
  259. package/test/workflow/webhook-trigger-test.test.ts +82 -0
  260. package/test/workflow/webhook-unsigned.test.ts +345 -0
  261. package/test/workflow-reactor-access.test.ts +384 -0
  262. package/test/workflow-reactor-enforcement.test.ts +808 -0
  263. package/test/workflow-read-gate.test.ts +213 -0
  264. package/test/workflow-runtime.test.ts +1135 -0
  265. package/test/workflows-plugin-config.test.ts +77 -0
  266. package/tsconfig.json +11 -2
  267. package/tsdown.config.ts +12 -1
  268. package/vitest.config.ts +65 -0
  269. package/dist/server-CiKkVE6g.mjs +0 -1555
  270. package/dist/server-CiKkVE6g.mjs.map +0 -1
  271. package/dist/utils-Baw7rThP.mjs +0 -80
  272. package/dist/utils-Baw7rThP.mjs.map +0 -1
@@ -8,16 +8,39 @@ import type {
8
8
  AttachmentAccessResult,
9
9
  IAttachmentAccessService,
10
10
  } from "@powerhousedao/reactor-api";
11
+ import type { ILogger } from "document-model";
11
12
  import type { IncomingMessage, ServerResponse } from "node:http";
12
13
  import { describe, expect, it, vi } from "vitest";
13
14
  import type { AttachmentActorContext } from "../../src/attachments/auth.js";
14
15
  import { registerAttachmentRoutes } from "../../src/attachments/index.js";
15
- import { makeDownloadTargetHandler } from "../../src/attachments/routes.js";
16
+ import {
17
+ downloadTargetTtlCapSeconds,
18
+ makeDownloadTargetHandler,
19
+ } from "../../src/attachments/routes.js";
20
+ import { AttachmentUrlSigner } from "../../src/attachments/url-signer.js";
21
+ import { switchboardConfigFromEnv } from "../../src/config/from-env.js";
22
+
23
+ const silentLogger = {
24
+ verbose: () => {},
25
+ debug: () => {},
26
+ info: () => {},
27
+ warn: () => {},
28
+ error: () => {},
29
+ child: () => silentLogger,
30
+ } as unknown as ILogger;
16
31
 
17
32
  const HASH = "a".repeat(64) as AttachmentHash;
18
33
  const REF = `attachment://v1:${HASH}`;
19
34
  const DOC_ID = "doc-1";
20
35
  const EXPIRES = "2026-07-23T00:00:00.000Z";
36
+ const NOW_MS = Date.parse("2026-07-22T00:00:00.000Z");
37
+ const SIGNER = new AttachmentUrlSigner("s".repeat(32), () => NOW_MS);
38
+
39
+ function signedUrlParts(body: string) {
40
+ const target = JSON.parse(body) as { url: string; expiresAtUtc: string };
41
+ const url = new URL(target.url);
42
+ return { target, url, params: url.searchParams };
43
+ }
21
44
 
22
45
  const ACTOR: AttachmentActorContext = {
23
46
  user: {
@@ -82,7 +105,13 @@ function makeAccess(result: AttachmentAccessResult): {
82
105
  spy: ReturnType<typeof vi.fn>;
83
106
  } {
84
107
  const spy = vi.fn().mockResolvedValue(result);
85
- return { access: { canReadAttachment: spy }, spy };
108
+ return {
109
+ access: {
110
+ canReadAttachment: spy,
111
+ admitCaller: () => Promise.resolve({ kind: "admitted" }),
112
+ },
113
+ spy,
114
+ };
86
115
  }
87
116
 
88
117
  function makeAttachments(opts: {
@@ -106,27 +135,118 @@ const ALLOWED: AttachmentAccessResult = {
106
135
  };
107
136
 
108
137
  describe("makeDownloadTargetHandler", () => {
109
- it("returns a switchboard target for filesystem with no-store", async () => {
138
+ it("returns a signed switchboard target for filesystem with no-store", async () => {
110
139
  const { access, spy } = makeAccess(ALLOWED);
111
140
  const attachments = makeAttachments({});
112
- const handler = makeDownloadTargetHandler(attachments, access);
141
+ const handler = makeDownloadTargetHandler(attachments, access, SIGNER);
113
142
  const res = makeRes();
114
143
 
115
144
  await handler(makeReq({}), res, undefined, ACTOR);
116
145
 
117
146
  expect(res.statusCode).toBe(200);
118
147
  expect(res._headers["cache-control"]).toBe("no-store");
119
- expect(JSON.parse(res._body)).toEqual({
148
+ const { target, url, params } = signedUrlParts(res._body);
149
+ expect(target).toMatchObject({
120
150
  kind: "switchboard",
121
151
  method: "GET",
122
- url: `http://sb.example.com/attachments/${HASH}`,
123
152
  headers: {},
153
+ expiresAtUtc: new Date(NOW_MS + 300_000).toISOString(),
124
154
  });
155
+ expect(`${url.origin}${url.pathname}`).toBe(
156
+ `http://sb.example.com/attachments/${HASH}`,
157
+ );
158
+ expect(params.get("documentId")).toBe(DOC_ID);
159
+ expect(
160
+ SIGNER.verify(
161
+ HASH,
162
+ DOC_ID,
163
+ params.get("expires")!,
164
+ params.get("signature")!,
165
+ ),
166
+ ).toBe(true);
125
167
  expect(spy).toHaveBeenCalledWith({
126
168
  documentId: DOC_ID,
127
169
  attachmentRef: REF,
128
170
  userAddress: "0xverified",
171
+ appKey: "did:key:zAppTest",
172
+ });
173
+ });
174
+
175
+ it("signs for the requested expiresIn, clamped to the download-target ceiling", async () => {
176
+ const { access } = makeAccess(ALLOWED);
177
+ const handler = makeDownloadTargetHandler(
178
+ makeAttachments({}),
179
+ access,
180
+ SIGNER,
181
+ );
182
+
183
+ for (const [requested, granted] of [
184
+ [60, 60],
185
+ [3600, 300],
186
+ [99999999, 300],
187
+ ]) {
188
+ const res = makeRes();
189
+ await handler(
190
+ makeReq({
191
+ url: `/attachments/${HASH}/download-target?documentId=${DOC_ID}&expiresIn=${requested}`,
192
+ }),
193
+ res,
194
+ undefined,
195
+ ACTOR,
196
+ );
197
+ expect(signedUrlParts(res._body).target.expiresAtUtc).toBe(
198
+ new Date(NOW_MS + granted * 1000).toISOString(),
199
+ );
200
+ }
201
+ });
202
+
203
+ it("signs the canonical document id the access decision resolved", async () => {
204
+ const { access } = makeAccess({ ...ALLOWED, documentId: "canon" as never });
205
+ const handler = makeDownloadTargetHandler(
206
+ makeAttachments({}),
207
+ access,
208
+ SIGNER,
209
+ );
210
+ const res = makeRes();
211
+
212
+ await handler(makeReq({}), res, undefined, ACTOR);
213
+
214
+ expect(signedUrlParts(res._body).params.get("documentId")).toBe("canon");
215
+ });
216
+
217
+ it("fails closed with 503 on filesystem when no signer is configured", async () => {
218
+ const { access } = makeAccess(ALLOWED);
219
+ const handler = makeDownloadTargetHandler(
220
+ makeAttachments({}),
221
+ access,
222
+ null,
223
+ );
224
+ const res = makeRes();
225
+
226
+ await handler(makeReq({}), res, undefined, ACTOR);
227
+
228
+ expect(res.statusCode).toBe(503);
229
+ expect(res._body).not.toContain("/attachments/");
230
+ });
231
+
232
+ it("needs no signer for S3 presigned targets", async () => {
233
+ const { access } = makeAccess(ALLOWED);
234
+ const prepareDownloadTarget = vi.fn().mockResolvedValue({
235
+ kind: "presigned-get",
236
+ method: "GET",
237
+ url: "https://bucket.example.com/attachments/aa?sig=1",
238
+ headers: {},
239
+ expiresAtUtc: EXPIRES,
240
+ });
241
+ const attachments = makeAttachments({
242
+ backend: { kind: "s3", prepareDownloadTarget } as never,
129
243
  });
244
+ const handler = makeDownloadTargetHandler(attachments, access, null);
245
+ const res = makeRes();
246
+
247
+ await handler(makeReq({}), res, undefined, ACTOR);
248
+
249
+ expect(res.statusCode).toBe(200);
130
250
  });
131
251
 
132
252
  it("returns the backend presigned-get target in S3 mode", async () => {
@@ -141,14 +261,14 @@ describe("makeDownloadTargetHandler", () => {
141
261
  const attachments = makeAttachments({
142
262
  backend: { kind: "s3", prepareDownloadTarget } as never,
143
263
  });
144
- const handler = makeDownloadTargetHandler(attachments, access);
264
+ const handler = makeDownloadTargetHandler(attachments, access, SIGNER);
145
265
  const res = makeRes();
146
266
 
147
267
  await handler(makeReq({}), res, undefined, ACTOR);
148
268
 
149
269
  expect(res.statusCode).toBe(200);
150
270
  expect(JSON.parse(res._body)).toMatchObject({ kind: "presigned-get" });
151
- expect(prepareDownloadTarget).toHaveBeenCalledWith(HASH, undefined);
271
+ expect(prepareDownloadTarget).toHaveBeenCalledWith(HASH, 300);
152
272
  });
153
273
 
154
274
  it("passes a requested expiresIn through to the backend presigner", async () => {
@@ -163,12 +283,12 @@ describe("makeDownloadTargetHandler", () => {
163
283
  const attachments = makeAttachments({
164
284
  backend: { kind: "s3", prepareDownloadTarget } as never,
165
285
  });
166
- const handler = makeDownloadTargetHandler(attachments, access);
286
+ const handler = makeDownloadTargetHandler(attachments, access, SIGNER);
167
287
  const res = makeRes();
168
288
 
169
289
  await handler(
170
290
  makeReq({
171
- url: `/attachments/${HASH}/download-target?documentId=${DOC_ID}&expiresIn=3600`,
291
+ url: `/attachments/${HASH}/download-target?documentId=${DOC_ID}&expiresIn=60`,
172
292
  }),
173
293
  res,
174
294
  undefined,
@@ -176,10 +296,10 @@ describe("makeDownloadTargetHandler", () => {
176
296
  );
177
297
 
178
298
  expect(res.statusCode).toBe(200);
179
- expect(prepareDownloadTarget).toHaveBeenCalledWith(HASH, 3600);
299
+ expect(prepareDownloadTarget).toHaveBeenCalledWith(HASH, 60);
180
300
  });
181
301
 
182
- it("clamps expiresIn to the 7-day presigning ceiling", async () => {
302
+ it("clamps a requested expiresIn to the ceiling", async () => {
183
303
  const { access } = makeAccess(ALLOWED);
184
304
  const prepareDownloadTarget = vi.fn().mockResolvedValue({
185
305
  kind: "presigned-get",
@@ -191,7 +311,7 @@ describe("makeDownloadTargetHandler", () => {
191
311
  const attachments = makeAttachments({
192
312
  backend: { kind: "s3", prepareDownloadTarget } as never,
193
313
  });
194
- const handler = makeDownloadTargetHandler(attachments, access);
314
+ const handler = makeDownloadTargetHandler(attachments, access, SIGNER);
195
315
  const res = makeRes();
196
316
 
197
317
  await handler(
@@ -203,10 +323,10 @@ describe("makeDownloadTargetHandler", () => {
203
323
  ACTOR,
204
324
  );
205
325
 
206
- expect(prepareDownloadTarget).toHaveBeenCalledWith(HASH, 604800);
326
+ expect(prepareDownloadTarget).toHaveBeenCalledWith(HASH, 300);
207
327
  });
208
328
 
209
- it("omits the TTL override when expiresIn is absent", async () => {
329
+ it("applies the ceiling when expiresIn is absent, rather than the backend default", async () => {
210
330
  const { access } = makeAccess(ALLOWED);
211
331
  const prepareDownloadTarget = vi.fn().mockResolvedValue({
212
332
  kind: "presigned-get",
@@ -218,11 +338,69 @@ describe("makeDownloadTargetHandler", () => {
218
338
  const attachments = makeAttachments({
219
339
  backend: { kind: "s3", prepareDownloadTarget } as never,
220
340
  });
221
- const handler = makeDownloadTargetHandler(attachments, access);
341
+ const handler = makeDownloadTargetHandler(attachments, access, SIGNER);
222
342
 
223
343
  await handler(makeReq({}), makeRes(), undefined, ACTOR);
224
344
 
225
- expect(prepareDownloadTarget).toHaveBeenCalledWith(HASH, undefined);
345
+ expect(prepareDownloadTarget).toHaveBeenCalledWith(HASH, 300);
346
+ });
347
+
348
+ describe("ATTACHMENT_DOWNLOAD_TARGET_MAX_TTL_SECONDS, mapped at the edge", () => {
349
+ async function ttlFor(configured: string | undefined, query = "") {
350
+ const config = switchboardConfigFromEnv(
351
+ { ATTACHMENT_DOWNLOAD_TARGET_MAX_TTL_SECONDS: configured },
352
+ { logger: silentLogger },
353
+ );
354
+ const { access } = makeAccess(ALLOWED);
355
+ const prepareDownloadTarget = vi.fn().mockResolvedValue({
356
+ kind: "presigned-get",
357
+ method: "GET",
358
+ url: "https://bucket.example.com/attachments/aa?sig=1",
359
+ headers: {},
360
+ expiresAtUtc: EXPIRES,
361
+ });
362
+ const attachments = makeAttachments({
363
+ backend: { kind: "s3", prepareDownloadTarget } as never,
364
+ });
365
+ const handler = makeDownloadTargetHandler(
366
+ attachments,
367
+ access,
368
+ SIGNER,
369
+ downloadTargetTtlCapSeconds(
370
+ config.attachments?.downloadTargetMaxTtlSeconds,
371
+ ),
372
+ );
373
+ await handler(
374
+ makeReq({
375
+ url: `/attachments/${HASH}/download-target?documentId=${DOC_ID}${query}`,
376
+ }),
377
+ makeRes(),
378
+ undefined,
379
+ ACTOR,
380
+ );
381
+ return (prepareDownloadTarget.mock.calls[0] as unknown[])[1];
382
+ }
383
+
384
+ it("raises the ceiling when a deployment configures one", async () => {
385
+ await expect(ttlFor("1800")).resolves.toBe(1800);
386
+ });
387
+
388
+ it("never lets a configured ceiling exceed the signing maximum", async () => {
389
+ await expect(ttlFor("99999999")).resolves.toBe(604800);
390
+ });
391
+
392
+ it.each(["not-a-number", "0", "-5", "12.5"])(
393
+ "falls back to the default, not the maximum, on %s",
394
+ async (configured) => {
395
+ // A typo must narrow nothing and widen nothing: falling back to the
396
+ // signing ceiling would turn a misconfiguration into a week-long URL.
397
+ await expect(ttlFor(configured)).resolves.toBe(300);
398
+ },
399
+ );
400
+
401
+ it("still clamps a caller's request to the configured ceiling", async () => {
402
+ await expect(ttlFor("1800", "&expiresIn=99999")).resolves.toBe(1800);
403
+ });
226
404
  });
227
405
 
228
406
  it.each([
@@ -234,7 +412,7 @@ describe("makeDownloadTargetHandler", () => {
234
412
  ])("rejects a %s expiresIn with 400 before authorization", async (_, qs) => {
235
413
  const { access, spy } = makeAccess(ALLOWED);
236
414
  const attachments = makeAttachments({});
237
- const handler = makeDownloadTargetHandler(attachments, access);
415
+ const handler = makeDownloadTargetHandler(attachments, access, SIGNER);
238
416
  const res = makeRes();
239
417
 
240
418
  await handler(
@@ -253,7 +431,7 @@ describe("makeDownloadTargetHandler", () => {
253
431
  it("normalizes an uppercase path hash before authorization and lookup", async () => {
254
432
  const { access, spy } = makeAccess(ALLOWED);
255
433
  const attachments = makeAttachments({});
256
- const handler = makeDownloadTargetHandler(attachments, access);
434
+ const handler = makeDownloadTargetHandler(attachments, access, SIGNER);
257
435
  const res = makeRes();
258
436
 
259
437
  await handler(makeReq({ hash: HASH.toUpperCase() }), res, undefined, ACTOR);
@@ -268,7 +446,7 @@ describe("makeDownloadTargetHandler", () => {
268
446
  it("rejects an invalid hash before any access or storage call", async () => {
269
447
  const { access, spy } = makeAccess(ALLOWED);
270
448
  const attachments = makeAttachments({});
271
- const handler = makeDownloadTargetHandler(attachments, access);
449
+ const handler = makeDownloadTargetHandler(attachments, access, SIGNER);
272
450
  const res = makeRes();
273
451
 
274
452
  await handler(makeReq({ hash: "nothex" }), res, undefined, ACTOR);
@@ -292,7 +470,7 @@ describe("makeDownloadTargetHandler", () => {
292
470
  ])("rejects a %s documentId before authorization", async (_, url) => {
293
471
  const { access, spy } = makeAccess(ALLOWED);
294
472
  const attachments = makeAttachments({});
295
- const handler = makeDownloadTargetHandler(attachments, access);
473
+ const handler = makeDownloadTargetHandler(attachments, access, SIGNER);
296
474
  const res = makeRes();
297
475
 
298
476
  await handler(makeReq({ url }), res, undefined, ACTOR);
@@ -307,7 +485,7 @@ describe("makeDownloadTargetHandler", () => {
307
485
  const attachments = makeAttachments({
308
486
  backend: { kind: "s3", prepareDownloadTarget } as never,
309
487
  });
310
- const handler = makeDownloadTargetHandler(attachments, access);
488
+ const handler = makeDownloadTargetHandler(attachments, access, SIGNER);
311
489
  const res = makeRes();
312
490
 
313
491
  await handler(makeReq({}), res, undefined, ACTOR);
@@ -321,7 +499,7 @@ describe("makeDownloadTargetHandler", () => {
321
499
  it("maps projection-unavailable to a generic non-cacheable 503 before storage", async () => {
322
500
  const { access } = makeAccess({ kind: "projection-unavailable" });
323
501
  const attachments = makeAttachments({});
324
- const handler = makeDownloadTargetHandler(attachments, access);
502
+ const handler = makeDownloadTargetHandler(attachments, access, SIGNER);
325
503
  const res = makeRes();
326
504
 
327
505
  await handler(makeReq({}), res, undefined, ACTOR);
@@ -337,7 +515,7 @@ describe("makeDownloadTargetHandler", () => {
337
515
  const { AttachmentNotFound } =
338
516
  await import("@powerhousedao/reactor-attachments");
339
517
  attachments.statSpy.mockRejectedValue(new AttachmentNotFound(HASH));
340
- const handler = makeDownloadTargetHandler(attachments, access);
518
+ const handler = makeDownloadTargetHandler(attachments, access, SIGNER);
341
519
  const res = makeRes();
342
520
 
343
521
  await handler(makeReq({}), res, undefined, ACTOR);
@@ -351,7 +529,7 @@ describe("makeDownloadTargetHandler", () => {
351
529
  const attachments = makeAttachments({
352
530
  stat: () => Promise.resolve({ ...AVAILABLE_HEADER, status: "pending" }),
353
531
  });
354
- const handler = makeDownloadTargetHandler(attachments, access);
532
+ const handler = makeDownloadTargetHandler(attachments, access, SIGNER);
355
533
  const res = makeRes();
356
534
 
357
535
  await handler(makeReq({}), res, undefined, ACTOR);
@@ -371,7 +549,7 @@ describe("makeDownloadTargetHandler", () => {
371
549
  const attachments = makeAttachments({
372
550
  backend: { kind: "s3", prepareDownloadTarget } as never,
373
551
  });
374
- const handler = makeDownloadTargetHandler(attachments, access);
552
+ const handler = makeDownloadTargetHandler(attachments, access, SIGNER);
375
553
  const res = makeRes();
376
554
 
377
555
  await handler(makeReq({}), res, undefined, ACTOR);
@@ -384,7 +562,7 @@ describe("makeDownloadTargetHandler", () => {
384
562
  it("passes an anonymous actor as an undefined address (OPEN mode)", async () => {
385
563
  const { access, spy } = makeAccess(ALLOWED);
386
564
  const attachments = makeAttachments({});
387
- const handler = makeDownloadTargetHandler(attachments, access);
565
+ const handler = makeDownloadTargetHandler(attachments, access, SIGNER);
388
566
  const res = makeRes();
389
567
 
390
568
  await handler(makeReq({}), res, undefined, {
@@ -400,7 +578,7 @@ describe("makeDownloadTargetHandler", () => {
400
578
  it("honours x-forwarded proto/host when building the switchboard target", async () => {
401
579
  const { access } = makeAccess(ALLOWED);
402
580
  const attachments = makeAttachments({});
403
- const handler = makeDownloadTargetHandler(attachments, access);
581
+ const handler = makeDownloadTargetHandler(attachments, access, SIGNER);
404
582
  const res = makeRes();
405
583
 
406
584
  await handler(
@@ -415,9 +593,10 @@ describe("makeDownloadTargetHandler", () => {
415
593
  ACTOR,
416
594
  );
417
595
 
418
- expect(JSON.parse(res._body)).toMatchObject({
419
- url: `https://public.example.com/attachments/${HASH}`,
420
- });
596
+ const { url } = signedUrlParts(res._body);
597
+ expect(`${url.origin}${url.pathname}`).toBe(
598
+ `https://public.example.com/attachments/${HASH}`,
599
+ );
421
600
  });
422
601
  });
423
602
 
@@ -435,7 +614,7 @@ describe("registerAttachmentRoutes inventory", () => {
435
614
  attachmentAccess: { canReadAttachment: vi.fn() },
436
615
  } as unknown as API;
437
616
 
438
- registerAttachmentRoutes(api);
617
+ registerAttachmentRoutes(api, { urlSigner: null });
439
618
 
440
619
  expect(captured).toEqual([
441
620
  { method: "POST", path: "/attachments/reservations" },
@@ -11,10 +11,19 @@ type Captured = {
11
11
  res: ServerResponse,
12
12
  body?: unknown,
13
13
  ) => void | Promise<void>;
14
+ options?: unknown;
14
15
  };
15
16
 
16
- function makeFakeApi(authService: AuthService | undefined): {
17
- api: Pick<API, "httpAdapter" | "authService">;
17
+ type FakeApi = Pick<
18
+ API,
19
+ "httpAdapter" | "authService" | "requireAuthenticatedCaller"
20
+ >;
21
+
22
+ function makeFakeApi(
23
+ authService: AuthService | undefined,
24
+ requireAuthenticatedCaller = false,
25
+ ): {
26
+ api: FakeApi;
18
27
  captured: Captured[];
19
28
  } {
20
29
  const captured: Captured[] = [];
@@ -24,12 +33,14 @@ function makeFakeApi(authService: AuthService | undefined): {
24
33
  method: string,
25
34
  path: string,
26
35
  handler: Captured["handler"],
36
+ options?: unknown,
27
37
  ) => {
28
- captured.push({ method, path, handler });
38
+ captured.push({ method, path, handler, options });
29
39
  },
30
40
  },
31
41
  authService,
32
- } as unknown as Pick<API, "httpAdapter" | "authService">;
42
+ requireAuthenticatedCaller,
43
+ } as unknown as FakeApi;
33
44
  return { api, captured };
34
45
  }
35
46
 
@@ -138,6 +149,28 @@ describe("mountAuthenticatedNodeRoute", () => {
138
149
  });
139
150
  });
140
151
 
152
+ it("carries the deployment's authenticated-caller floor onto the route, over allowAnonymous", async () => {
153
+ // auth_enabled false is the shape a deployment running the document
154
+ // policies has: the boundary policy is OPEN, and this floor is what keeps
155
+ // an anonymous caller off the attachment routes.
156
+ const verifyBearer = vi.fn(() =>
157
+ Promise.resolve({ user: undefined, admins: [], auth_enabled: false }),
158
+ );
159
+ const authService = { verifyBearer } as unknown as AuthService;
160
+ const { api, captured } = makeFakeApi(authService, true);
161
+ const inner = vi.fn();
162
+
163
+ mountAuthenticatedNodeRoute(api, "GET", "/x", inner, {
164
+ allowAnonymous: true,
165
+ });
166
+
167
+ const res = makeRes();
168
+ await captured[0].handler(makeReq(), res);
169
+
170
+ expect(res.statusCode).toBe(401);
171
+ expect(inner).not.toHaveBeenCalled();
172
+ });
173
+
141
174
  it("mounts a wrapper that forwards the anonymous actor when authService is undefined", async () => {
142
175
  const { api, captured } = makeFakeApi(undefined);
143
176
  const inner = vi.fn();
@@ -155,4 +188,14 @@ describe("mountAuthenticatedNodeRoute", () => {
155
188
  authEnabled: false,
156
189
  });
157
190
  });
191
+
192
+ it("forwards rawBody to the adapter and keeps it out of the auth options", () => {
193
+ const { api, captured } = makeFakeApi(undefined);
194
+
195
+ mountAuthenticatedNodeRoute(api, "PUT", "/x", vi.fn(), { rawBody: true });
196
+ mountAuthenticatedNodeRoute(api, "GET", "/y", vi.fn());
197
+
198
+ expect(captured[0].options).toEqual({ rawBody: true });
199
+ expect(captured[1].options).toEqual({ rawBody: false });
200
+ });
158
201
  });
@@ -0,0 +1,96 @@
1
+ import {
2
+ InvalidAttachmentMetadata,
3
+ validateReserveMetadata,
4
+ type ReserveMetadata,
5
+ } from "@powerhousedao/reactor-attachments";
6
+ import { describe, expect, it } from "vitest";
7
+ import { parseReserveOptions } from "../../src/attachments/routes.js";
8
+
9
+ type Case = [name: string, meta: Record<string, unknown>];
10
+
11
+ const base = { mimeType: "text/plain", fileName: "note.txt" };
12
+
13
+ // The download route's setHeader throws on each of these.
14
+ const headerBreaking: Case[] = [
15
+ ["CRLF before a parameter", { ...base, mimeType: "text/plain\r\n;a=b" }],
16
+ ["LF after a ;", { ...base, mimeType: "text/plain;\na=b" }],
17
+ ["a control char quoted", { ...base, mimeType: 'text/plain; a="\x01"' }],
18
+ ["a DEL quoted", { ...base, mimeType: 'text/plain; a="\x7f"' }],
19
+ ["a char above 0xFF quoted", { ...base, mimeType: 'text/plain;a="\u0100"' }],
20
+ ];
21
+
22
+ const cases: Case[] = [
23
+ ["plain metadata", base],
24
+ ["an extension", { ...base, extension: "txt" }],
25
+ ["a null extension", { ...base, extension: null }],
26
+ ["a parameter", { ...base, mimeType: "text/plain; charset=utf-8" }],
27
+ ["a quoted parameter", { ...base, mimeType: 'text/plain; a="b c"' }],
28
+ ["a unicode file name", { ...base, fileName: "résumé.pdf" }],
29
+ ["a 255-char mimeType", { ...base, mimeType: `a/${"b".repeat(253)}` }],
30
+ ["a 256-char mimeType", { ...base, mimeType: `a/${"b".repeat(254)}` }],
31
+ ["a 255-char fileName", { ...base, fileName: "f".repeat(255) }],
32
+ ["a 256-char fileName", { ...base, fileName: "f".repeat(256) }],
33
+ ["an empty mimeType", { ...base, mimeType: "" }],
34
+ ["an empty fileName", { ...base, fileName: "" }],
35
+ ["an empty extension", { ...base, extension: "" }],
36
+ ["a mimeType with no slash", { ...base, mimeType: "text" }],
37
+ ["a mimeType with no subtype", { ...base, mimeType: "text/" }],
38
+ ["a mimeType with no type", { ...base, mimeType: "/plain" }],
39
+ ["a mimeType with two slashes", { ...base, mimeType: "text/plain/x" }],
40
+ ["a mimeType with a space", { ...base, mimeType: "text plain" }],
41
+ ["a mimeType with a dangling ;", { ...base, mimeType: "text/plain;" }],
42
+ ["a non-string mimeType", { ...base, mimeType: 5 }],
43
+ ["a trailing CRLF in mimeType", { ...base, mimeType: "text/plain\r\n" }],
44
+ [
45
+ "an injected header in mimeType",
46
+ { ...base, mimeType: "text/plain\nX-Injected: 1" },
47
+ ],
48
+ ["a NUL in mimeType", { ...base, mimeType: "text/pl\x00ain" }],
49
+ ...headerBreaking,
50
+ ["a NUL in fileName", { ...base, fileName: "a\x00b" }],
51
+ ["a LF in fileName", { ...base, fileName: "a\nb" }],
52
+ ["a CR in fileName", { ...base, fileName: "a\rb" }],
53
+ ["a tab in fileName", { ...base, fileName: "a\tb" }],
54
+ ["a DEL in fileName", { ...base, fileName: "a\x7fb" }],
55
+ ["a non-string fileName", { ...base, fileName: null }],
56
+ ["a slash in extension", { ...base, extension: "a/b" }],
57
+ ["a backslash in extension", { ...base, extension: "a\\b" }],
58
+ ["a bare slash extension", { ...base, extension: "/" }],
59
+ ["a non-string extension", { ...base, extension: 5 }],
60
+ ];
61
+
62
+ function routeAccepts(meta: Record<string, unknown>): boolean {
63
+ return parseReserveOptions(meta) !== null;
64
+ }
65
+
66
+ function validatorAccepts(meta: Record<string, unknown>): boolean {
67
+ try {
68
+ validateReserveMetadata(meta as ReserveMetadata);
69
+ return true;
70
+ } catch (err) {
71
+ if (err instanceof InvalidAttachmentMetadata) return false;
72
+ throw err;
73
+ }
74
+ }
75
+
76
+ describe("reserve metadata parity between the route and validateReserveMetadata", () => {
77
+ it("covers both accepted and rejected metadata", () => {
78
+ const verdicts = cases.map(([, meta]) => routeAccepts(meta));
79
+ expect(verdicts).toContain(true);
80
+ expect(verdicts).toContain(false);
81
+ });
82
+
83
+ it.each(cases)("agrees on %s", (_name, meta) => {
84
+ expect(validatorAccepts(meta)).toBe(routeAccepts(meta));
85
+ });
86
+ });
87
+
88
+ describe("header-breaking mimeType values", () => {
89
+ it.each(headerBreaking)("the route rejects %s", (_name, meta) => {
90
+ expect(routeAccepts(meta)).toBe(false);
91
+ });
92
+
93
+ it.each(headerBreaking)("the validator rejects %s", (_name, meta) => {
94
+ expect(validatorAccepts(meta)).toBe(false);
95
+ });
96
+ });