@bevel-software/platform-core-backend 0.23.0 → 0.24.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 (227) hide show
  1. package/dist/core/create-core-server.d.ts.map +1 -1
  2. package/dist/core/create-core-server.js +17 -3
  3. package/dist/core/create-core-server.js.map +1 -1
  4. package/dist/core/create-core-services.d.ts +3 -0
  5. package/dist/core/create-core-services.d.ts.map +1 -1
  6. package/dist/core/create-core-services.js +25 -1
  7. package/dist/core/create-core-services.js.map +1 -1
  8. package/dist/core/lifecycle.d.ts +12 -0
  9. package/dist/core/lifecycle.d.ts.map +1 -1
  10. package/dist/core/lifecycle.js +10 -0
  11. package/dist/core/lifecycle.js.map +1 -1
  12. package/dist/core-config.d.ts +16 -0
  13. package/dist/core-config.d.ts.map +1 -1
  14. package/dist/core-config.js +17 -0
  15. package/dist/core-config.js.map +1 -1
  16. package/dist/index.d.ts +3 -2
  17. package/dist/index.d.ts.map +1 -1
  18. package/dist/index.js +10 -2
  19. package/dist/index.js.map +1 -1
  20. package/dist/modules/access/access.routes.d.ts.map +1 -1
  21. package/dist/modules/access/access.routes.js +4 -1
  22. package/dist/modules/access/access.routes.js.map +1 -1
  23. package/dist/modules/access/directory-sync-bot.d.ts.map +1 -1
  24. package/dist/modules/access/directory-sync-bot.js +7 -3
  25. package/dist/modules/access/directory-sync-bot.js.map +1 -1
  26. package/dist/modules/agent-instructions/agent-instructions.routes.d.ts +8 -1
  27. package/dist/modules/agent-instructions/agent-instructions.routes.d.ts.map +1 -1
  28. package/dist/modules/agent-instructions/agent-instructions.routes.js +8 -2
  29. package/dist/modules/agent-instructions/agent-instructions.routes.js.map +1 -1
  30. package/dist/modules/agent-instructions/compose.d.ts +38 -6
  31. package/dist/modules/agent-instructions/compose.d.ts.map +1 -1
  32. package/dist/modules/agent-instructions/compose.js +39 -6
  33. package/dist/modules/agent-instructions/compose.js.map +1 -1
  34. package/dist/modules/agent-instructions/index.d.ts +2 -1
  35. package/dist/modules/agent-instructions/index.d.ts.map +1 -1
  36. package/dist/modules/agent-instructions/index.js +2 -1
  37. package/dist/modules/agent-instructions/index.js.map +1 -1
  38. package/dist/modules/agent-instructions/shared-file-rules.d.ts +115 -0
  39. package/dist/modules/agent-instructions/shared-file-rules.d.ts.map +1 -0
  40. package/dist/modules/agent-instructions/shared-file-rules.js +272 -0
  41. package/dist/modules/agent-instructions/shared-file-rules.js.map +1 -0
  42. package/dist/modules/audit/agent-audit.service.d.ts.map +1 -1
  43. package/dist/modules/audit/agent-audit.service.js +4 -2
  44. package/dist/modules/audit/agent-audit.service.js.map +1 -1
  45. package/dist/modules/auth/account-erasure.service.d.ts.map +1 -1
  46. package/dist/modules/auth/account-erasure.service.js +57 -16
  47. package/dist/modules/auth/account-erasure.service.js.map +1 -1
  48. package/dist/modules/auth/auth.service.d.ts.map +1 -1
  49. package/dist/modules/auth/auth.service.js +25 -15
  50. package/dist/modules/auth/auth.service.js.map +1 -1
  51. package/dist/modules/code-mode/code-mode.tool.d.ts +20 -2
  52. package/dist/modules/code-mode/code-mode.tool.d.ts.map +1 -1
  53. package/dist/modules/code-mode/code-mode.tool.js +66 -35
  54. package/dist/modules/code-mode/code-mode.tool.js.map +1 -1
  55. package/dist/modules/database/connection.d.ts +16 -0
  56. package/dist/modules/database/connection.d.ts.map +1 -1
  57. package/dist/modules/database/connection.js +117 -0
  58. package/dist/modules/database/connection.js.map +1 -1
  59. package/dist/modules/database/core-schema.d.ts +296 -96
  60. package/dist/modules/database/core-schema.d.ts.map +1 -1
  61. package/dist/modules/database/core-schema.js +81 -31
  62. package/dist/modules/database/core-schema.js.map +1 -1
  63. package/dist/modules/database/migrate.d.ts +8 -0
  64. package/dist/modules/database/migrate.d.ts.map +1 -1
  65. package/dist/modules/database/migrate.js +271 -1
  66. package/dist/modules/database/migrate.js.map +1 -1
  67. package/dist/modules/mcp/mcp.service.d.ts +8 -0
  68. package/dist/modules/mcp/mcp.service.d.ts.map +1 -1
  69. package/dist/modules/mcp/mcp.service.js +38 -8
  70. package/dist/modules/mcp/mcp.service.js.map +1 -1
  71. package/dist/modules/plugins/join-request-records.store.d.ts.map +1 -1
  72. package/dist/modules/plugins/join-request-records.store.js +7 -4
  73. package/dist/modules/plugins/join-request-records.store.js.map +1 -1
  74. package/dist/modules/tool-auth/external-api-key.service.d.ts.map +1 -1
  75. package/dist/modules/tool-auth/external-api-key.service.js +8 -2
  76. package/dist/modules/tool-auth/external-api-key.service.js.map +1 -1
  77. package/dist/modules/tool-manuals/tool-manuals.tools.d.ts.map +1 -1
  78. package/dist/modules/tool-manuals/tool-manuals.tools.js +42 -31
  79. package/dist/modules/tool-manuals/tool-manuals.tools.js.map +1 -1
  80. package/dist/modules/tool-registry/description-length.d.ts +80 -0
  81. package/dist/modules/tool-registry/description-length.d.ts.map +1 -0
  82. package/dist/modules/tool-registry/description-length.js +108 -0
  83. package/dist/modules/tool-registry/description-length.js.map +1 -0
  84. package/dist/modules/workflow/git/git.service.d.ts +25 -0
  85. package/dist/modules/workflow/git/git.service.d.ts.map +1 -1
  86. package/dist/modules/workflow/git/git.service.js +40 -1
  87. package/dist/modules/workflow/git/git.service.js.map +1 -1
  88. package/dist/modules/workflow/pending-commits.service.d.ts.map +1 -1
  89. package/dist/modules/workflow/pending-commits.service.js +5 -1
  90. package/dist/modules/workflow/pending-commits.service.js.map +1 -1
  91. package/dist/modules/workflow/recovery-bot.d.ts.map +1 -1
  92. package/dist/modules/workflow/recovery-bot.js +7 -3
  93. package/dist/modules/workflow/recovery-bot.js.map +1 -1
  94. package/dist/modules/workflow/review-workflow/review-workflow.service.d.ts.map +1 -1
  95. package/dist/modules/workflow/review-workflow/review-workflow.service.js +12 -3
  96. package/dist/modules/workflow/review-workflow/review-workflow.service.js.map +1 -1
  97. package/dist/modules/workflow/workflow.service.d.ts.map +1 -1
  98. package/dist/modules/workflow/workflow.service.js +4 -1
  99. package/dist/modules/workflow/workflow.service.js.map +1 -1
  100. package/dist/modules/workspace/agent-upload.routes.d.ts +77 -0
  101. package/dist/modules/workspace/agent-upload.routes.d.ts.map +1 -0
  102. package/dist/modules/workspace/agent-upload.routes.js +210 -0
  103. package/dist/modules/workspace/agent-upload.routes.js.map +1 -0
  104. package/dist/modules/workspace/agent-upload.store.d.ts +284 -0
  105. package/dist/modules/workspace/agent-upload.store.d.ts.map +1 -0
  106. package/dist/modules/workspace/agent-upload.store.js +553 -0
  107. package/dist/modules/workspace/agent-upload.store.js.map +1 -0
  108. package/dist/modules/workspace/startup/steps/seed-tree.d.ts.map +1 -1
  109. package/dist/modules/workspace/startup/steps/seed-tree.js +3 -3
  110. package/dist/modules/workspace/startup/steps/seed-tree.js.map +1 -1
  111. package/dist/modules/workspace/startup/steps/template-source.d.ts +40 -0
  112. package/dist/modules/workspace/startup/steps/template-source.d.ts.map +1 -1
  113. package/dist/modules/workspace/startup/steps/template-source.js +46 -4
  114. package/dist/modules/workspace/startup/steps/template-source.js.map +1 -1
  115. package/dist/modules/workspace/upload-limits.d.ts +13 -0
  116. package/dist/modules/workspace/upload-limits.d.ts.map +1 -0
  117. package/dist/modules/workspace/upload-limits.js +13 -0
  118. package/dist/modules/workspace/upload-limits.js.map +1 -0
  119. package/dist/modules/workspace/workspace.routes.d.ts.map +1 -1
  120. package/dist/modules/workspace/workspace.routes.js +1 -1
  121. package/dist/modules/workspace/workspace.routes.js.map +1 -1
  122. package/dist/modules/workspace/workspace.service.d.ts +13 -0
  123. package/dist/modules/workspace/workspace.service.d.ts.map +1 -1
  124. package/dist/modules/workspace/workspace.service.js +61 -33
  125. package/dist/modules/workspace/workspace.service.js.map +1 -1
  126. package/dist/modules/workspace/workspace.tools.d.ts +11 -9
  127. package/dist/modules/workspace/workspace.tools.d.ts.map +1 -1
  128. package/dist/modules/workspace/workspace.tools.js +512 -113
  129. package/dist/modules/workspace/workspace.tools.js.map +1 -1
  130. package/dist/modules/workspace/write-denial.d.ts +0 -6
  131. package/dist/modules/workspace/write-denial.d.ts.map +1 -1
  132. package/dist/modules/workspace/write-denial.js +0 -6
  133. package/dist/modules/workspace/write-denial.js.map +1 -1
  134. package/dist/modules/workspace/zip-entry-rules.d.ts +114 -0
  135. package/dist/modules/workspace/zip-entry-rules.d.ts.map +1 -0
  136. package/dist/modules/workspace/zip-entry-rules.js +154 -0
  137. package/dist/modules/workspace/zip-entry-rules.js.map +1 -0
  138. package/dist/shared/column-crypto.d.ts +194 -0
  139. package/dist/shared/column-crypto.d.ts.map +1 -0
  140. package/dist/shared/column-crypto.js +144 -0
  141. package/dist/shared/column-crypto.js.map +1 -0
  142. package/dist/shared/token-crypto.d.ts.map +1 -1
  143. package/dist/shared/token-crypto.js +25 -1
  144. package/dist/shared/token-crypto.js.map +1 -1
  145. package/dist/tenancy/static-tenant-source.d.ts.map +1 -1
  146. package/dist/tenancy/static-tenant-source.js +1 -0
  147. package/dist/tenancy/static-tenant-source.js.map +1 -1
  148. package/dist/tenancy/tenant-secrets.d.ts +5 -1
  149. package/dist/tenancy/tenant-secrets.d.ts.map +1 -1
  150. package/dist/tenancy/tenant-secrets.js +4 -0
  151. package/dist/tenancy/tenant-secrets.js.map +1 -1
  152. package/kb-template/AGENTS.md +2 -0
  153. package/migrations/0016_pii_encryption.sql +20 -0
  154. package/migrations/meta/0016_snapshot.json +2327 -0
  155. package/migrations/meta/_journal.json +7 -0
  156. package/package.json +3 -3
  157. package/src/core/__tests__/lifecycle.test.ts +71 -4
  158. package/src/core/create-core-server.ts +21 -3
  159. package/src/core/create-core-services.ts +27 -1
  160. package/src/core/lifecycle.ts +19 -0
  161. package/src/core-config.ts +18 -0
  162. package/src/index.ts +18 -0
  163. package/src/modules/access/__tests__/users-db-double.ts +21 -12
  164. package/src/modules/access/access.routes.ts +4 -1
  165. package/src/modules/access/directory-sync-bot.ts +7 -3
  166. package/src/modules/agent-instructions/__tests__/agent-instructions.route.test.ts +8 -4
  167. package/src/modules/agent-instructions/__tests__/compose.test.ts +19 -10
  168. package/src/modules/agent-instructions/__tests__/shared-file-rules.test.ts +238 -0
  169. package/src/modules/agent-instructions/agent-instructions.routes.ts +12 -2
  170. package/src/modules/agent-instructions/compose.ts +50 -7
  171. package/src/modules/agent-instructions/index.ts +12 -0
  172. package/src/modules/agent-instructions/shared-file-rules.ts +314 -0
  173. package/src/modules/audit/agent-audit.service.ts +4 -2
  174. package/src/modules/auth/__tests__/account-deactivation.test.ts +2 -1
  175. package/src/modules/auth/__tests__/account-erasure.approval-gate.test.ts +6 -2
  176. package/src/modules/auth/__tests__/account.routes.test.ts +6 -3
  177. package/src/modules/auth/__tests__/auth.service.test.ts +3 -1
  178. package/src/modules/auth/account-erasure.service.ts +69 -18
  179. package/src/modules/auth/auth.service.ts +33 -23
  180. package/src/modules/code-mode/__tests__/chain-runtime.e2e.test.ts +335 -0
  181. package/src/modules/code-mode/__tests__/code-mode.tool.test.ts +46 -2
  182. package/src/modules/code-mode/code-mode.tool.ts +80 -34
  183. package/src/modules/database/__tests__/connection.test.ts +12 -0
  184. package/src/modules/database/__tests__/pii-backfill.pg.test.ts +561 -0
  185. package/src/modules/database/connection.ts +117 -0
  186. package/src/modules/database/core-schema.ts +81 -31
  187. package/src/modules/database/migrate.ts +353 -1
  188. package/src/modules/mcp/__tests__/mcp.e2e.test.ts +4 -3
  189. package/src/modules/mcp/__tests__/mcp.service.test.ts +47 -7
  190. package/src/modules/mcp/mcp.service.ts +46 -7
  191. package/src/modules/plugins/join-request-records.store.ts +7 -4
  192. package/src/modules/tool-auth/external-api-key.service.ts +8 -2
  193. package/src/modules/tool-manuals/tool-manuals.tools.ts +44 -31
  194. package/src/modules/tool-registry/__tests__/tool-description-length.test.ts +378 -0
  195. package/src/modules/tool-registry/description-length.ts +111 -0
  196. package/src/modules/workflow/git/__tests__/git.service.prFetchFailure.test.ts +170 -0
  197. package/src/modules/workflow/git/git.service.ts +47 -1
  198. package/src/modules/workflow/pending-commits.service.ts +5 -1
  199. package/src/modules/workflow/recovery-bot.ts +7 -3
  200. package/src/modules/workflow/review-workflow/__tests__/carry-approvals-forward.test.ts +4 -0
  201. package/src/modules/workflow/review-workflow/__tests__/erase-approver.test.ts +25 -3
  202. package/src/modules/workflow/review-workflow/review-workflow.service.ts +12 -3
  203. package/src/modules/workflow/workflow.service.ts +4 -1
  204. package/src/modules/workspace/__tests__/agent-uploads.test.ts +1604 -0
  205. package/src/modules/workspace/__tests__/escape-sequences.routes.test.ts +24 -14
  206. package/src/modules/workspace/__tests__/workspace.service.any-workspace-credentials.test.ts +156 -0
  207. package/src/modules/workspace/__tests__/workspace.service.replaced-repository.test.ts +77 -1
  208. package/src/modules/workspace/__tests__/workspace.service.test.ts +57 -0
  209. package/src/modules/workspace/__tests__/workspace.tools.agents-file.test.ts +39 -36
  210. package/src/modules/workspace/__tests__/workspace.tools.test.ts +84 -45
  211. package/src/modules/workspace/agent-upload.routes.ts +214 -0
  212. package/src/modules/workspace/agent-upload.store.ts +668 -0
  213. package/src/modules/workspace/startup/steps/__tests__/steps.test.ts +9 -9
  214. package/src/modules/workspace/startup/steps/seed-tree.ts +3 -6
  215. package/src/modules/workspace/startup/steps/template-source.ts +53 -5
  216. package/src/modules/workspace/upload-limits.ts +12 -0
  217. package/src/modules/workspace/workspace.routes.ts +1 -2
  218. package/src/modules/workspace/workspace.service.ts +63 -37
  219. package/src/modules/workspace/workspace.tools.ts +588 -127
  220. package/src/modules/workspace/write-denial.ts +0 -8
  221. package/src/modules/workspace/zip-entry-rules.ts +173 -0
  222. package/src/shared/__tests__/column-crypto.test.ts +217 -0
  223. package/src/shared/column-crypto.ts +218 -0
  224. package/src/shared/token-crypto.ts +28 -1
  225. package/src/tenancy/__tests__/static-tenant-source.test.ts +4 -0
  226. package/src/tenancy/static-tenant-source.ts +1 -0
  227. package/src/tenancy/tenant-secrets.ts +5 -1
@@ -0,0 +1,154 @@
1
+ import { inflateRawSync } from 'node:zlib';
2
+ import { validateFilename } from '@bevel-software/platform-shared';
3
+ import { GitInternalsError } from '../../shared/domain-errors.js';
4
+ import { hasGitInternalsSegment } from '../../shared/git-internals.js';
5
+ /**
6
+ * What an archive's entry NAMES are allowed to be, as one set of rules two
7
+ * surfaces ask: `unzip` (a .zip already in the workspace) and
8
+ * `apply_file_upload` (a .zip the agent sent to the upload route). Both land
9
+ * bytes an agent never typed at paths the archive chose, so both have to judge
10
+ * the same names the same way — and they did not, for as long as the rules
11
+ * lived inside `WorkspaceService.unzipFile` as three inline blocks.
12
+ *
13
+ * NAMES, and how an entry's BYTES are read ({@link readZipEntry}) — the two
14
+ * things decidable from the archive alone. Whether a target sits behind a
15
+ * symbolic link already on disk, whether the caller may write there, and what
16
+ * is already at the path are facts about a workspace, so each surface asks
17
+ * those where its own writes land.
18
+ */
19
+ /**
20
+ * The entries an archive from macOS carries that nobody asked for: the
21
+ * resource-fork sidecar tree and the Finder's own index. SILENTLY dropped
22
+ * rather than reported — they are not the caller's content and a list of
23
+ * refusals about them says nothing.
24
+ */
25
+ export function isZipNoiseEntry(rawName) {
26
+ return (rawName.startsWith('__MACOSX/') ||
27
+ rawName === '__MACOSX' ||
28
+ rawName.endsWith('/.DS_Store') ||
29
+ rawName === '.DS_Store' ||
30
+ /(^|\/)\._/.test(rawName));
31
+ }
32
+ /**
33
+ * An entry's name with separators in the one spelling the rules read. A zip
34
+ * written on Windows may use `\`, which every check below (and every path
35
+ * built from the result) would otherwise read as part of a single segment.
36
+ */
37
+ export function zipEntryName(entryName) {
38
+ return entryName.replace(/\\/g, '/');
39
+ }
40
+ /** The path segments `rawName` names, with a trailing slash and empty parts dropped. */
41
+ export function zipEntrySegments(rawName) {
42
+ return rawName
43
+ .replace(/\/+$/, '')
44
+ .split('/')
45
+ .filter((s) => s.length > 0);
46
+ }
47
+ /**
48
+ * Why `rawName` may not be landed at all — the reason a caller reports beside
49
+ * the entry — or null when the name is one a workspace path can be built from.
50
+ *
51
+ * Three rules, in the order that makes each refusal say the most useful thing:
52
+ * a path that climbs out or is anchored at the root is invalid whatever its
53
+ * segments are; the git folder is refused in every spelling, because an
54
+ * archive must not be a way to write what git reads as its own metadata; and
55
+ * then each segment has to be a name a filesystem on any of the three
56
+ * operating systems keeps intact (`validateFilename`).
57
+ */
58
+ export function zipEntryNameRefusal(rawName) {
59
+ if (!rawName || rawName.startsWith('/') || /(^|\/)\.\.($|\/)/.test(rawName))
60
+ return 'Invalid path';
61
+ if (hasGitInternalsSegment(rawName))
62
+ return new GitInternalsError().message;
63
+ for (const segment of zipEntrySegments(rawName)) {
64
+ const reason = validateFilename(segment);
65
+ if (reason)
66
+ return reason;
67
+ }
68
+ return null;
69
+ }
70
+ /**
71
+ * Whether a zip entry is a symbolic LINK rather than a file or a folder.
72
+ *
73
+ * A zip stores a link as an ordinary member whose bytes are the link's target
74
+ * text and whose unix mode (the high half of the external attributes) carries
75
+ * `S_IFLNK`. A reader that ignores the mode writes the target text out as a
76
+ * regular file — content nobody sent, under a name that was meant to point
77
+ * somewhere. `apply_file_upload` refuses such an entry outright; the entry is
78
+ * not a file, so there are no bytes of the caller's to land.
79
+ */
80
+ export function isSymlinkZipEntry(entry) {
81
+ const attr = entry.header?.attr ?? entry.attr ?? 0;
82
+ if (!Number.isFinite(attr) || attr <= 0)
83
+ return false;
84
+ // The external attributes' high 16 bits are the unix mode when the archive
85
+ // was written on a unix host; `S_IFMT & mode === S_IFLNK` is the link bit.
86
+ return ((attr >>> 16) & 0o170000) === 0o120000;
87
+ }
88
+ /** A zip's compression method for DEFLATE, the only one that can expand. */
89
+ const ZIP_METHOD_DEFLATED = 8;
90
+ /**
91
+ * Read one entry's bytes, inflating NO MORE than `budget` of them.
92
+ *
93
+ * The one read both surfaces use, because the bound is the whole point and it
94
+ * has a hole when each surface writes it itself. An entry's header DECLARES its
95
+ * uncompressed size, and the reader caps the inflation at that — but only when
96
+ * the size it declares is above zero. An entry that declares zero is inflated
97
+ * with no cap at all, so "check the declared size against the budget, then
98
+ * read" passes a 20 KB archive that expands to 20 MB, and a 50 MB one that
99
+ * expands to tens of gigabytes in a single call, before any check on the bytes
100
+ * that arrived has run. A thousandfold is what deflate does to a run of one
101
+ * byte; the header saying "empty" was the only thing standing in front of it.
102
+ *
103
+ * So the declared size is never the only bound:
104
+ *
105
+ * - an entry declaring more than `budget` is refused unread;
106
+ * - a DEFLATED entry declaring ZERO with a stream of its own is inflated here,
107
+ * capped at a single byte. An empty file compressed with deflate is exactly
108
+ * this shape (a two-byte stream that inflates to nothing) and is read as the
109
+ * empty file it is; anything that inflates to a byte or more contradicts its
110
+ * own header and is refused;
111
+ * - every other entry is read by the archive reader, which caps the inflation
112
+ * at the declared size this function has just held against the budget, and
113
+ * the bytes that arrive are measured again.
114
+ *
115
+ * A read that throws — a failed checksum, a stream longer than it declared, an
116
+ * unknown method — is that entry's refusal, not the whole archive's: one bad
117
+ * member must not cost the caller the others.
118
+ */
119
+ export function readZipEntry(entry, budget) {
120
+ const { size: declared, compressedSize, method } = entry.header;
121
+ if (declared > budget)
122
+ return { ok: false, reason: 'too_large' };
123
+ if (declared === 0 && method === ZIP_METHOD_DEFLATED && compressedSize > 0) {
124
+ let inflated;
125
+ try {
126
+ inflated = inflateRawSync(entry.getCompressedData(), { maxOutputLength: 1 });
127
+ }
128
+ catch (err) {
129
+ // Past the one-byte cap, or not a deflate stream at all: either way it
130
+ // is not the empty file its header says it is.
131
+ return { ok: false, reason: 'unreadable', detail: declaresEmptyButIsNot(err) };
132
+ }
133
+ if (inflated.byteLength > 0)
134
+ return { ok: false, reason: 'unreadable', detail: declaresEmptyButIsNot() };
135
+ return { ok: true, data: inflated };
136
+ }
137
+ let data;
138
+ try {
139
+ data = entry.getData();
140
+ }
141
+ catch (err) {
142
+ return { ok: false, reason: 'unreadable', detail: err instanceof Error ? err.message : String(err) };
143
+ }
144
+ if (data.byteLength > budget)
145
+ return { ok: false, reason: 'too_large' };
146
+ return { ok: true, data };
147
+ }
148
+ function declaresEmptyButIsNot(err) {
149
+ const outputLimit = err?.code === 'ERR_BUFFER_TOO_LARGE';
150
+ return err === undefined || outputLimit
151
+ ? 'its header declares an empty file, but it holds content'
152
+ : `its header declares an empty file, and its content could not be read (${err instanceof Error ? err.message : String(err)})`;
153
+ }
154
+ //# sourceMappingURL=zip-entry-rules.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"zip-entry-rules.js","sourceRoot":"","sources":["../../../src/modules/workspace/zip-entry-rules.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACnE,OAAO,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAClE,OAAO,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AAEvE;;;;;;;;;;;;;GAaG;AAEH;;;;;GAKG;AACH,MAAM,UAAU,eAAe,CAAC,OAAe;IAC7C,OAAO,CACL,OAAO,CAAC,UAAU,CAAC,WAAW,CAAC;QAC/B,OAAO,KAAK,UAAU;QACtB,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAC;QAC9B,OAAO,KAAK,WAAW;QACvB,WAAW,CAAC,IAAI,CAAC,OAAO,CAAC,CAC1B,CAAC;AACJ,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,YAAY,CAAC,SAAiB;IAC5C,OAAO,SAAS,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;AACvC,CAAC;AAED,wFAAwF;AACxF,MAAM,UAAU,gBAAgB,CAAC,OAAe;IAC9C,OAAO,OAAO;SACX,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC;SACnB,KAAK,CAAC,GAAG,CAAC;SACV,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;AACjC,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,UAAU,mBAAmB,CAAC,OAAe;IACjD,IAAI,CAAC,OAAO,IAAI,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,kBAAkB,CA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AC,yEAAyE,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC;AACnI,CAAC"}
@@ -0,0 +1,194 @@
1
+ /**
2
+ * Application-layer encryption for PII columns. Personal data (emails, names,
3
+ * change-request text) is AES-256-GCM ciphertext in Postgres, so a leaked
4
+ * dump, an injected query, or a compromised DB credential yields no personal
5
+ * data — the key lives only in the app's environment. Disk-level encryption
6
+ * still carries the blanket at-rest claim (git refs, WAL, logs); this layer is
7
+ * the DB-specific control on top.
8
+ *
9
+ * THE KEY BELONGS TO THE DATABASE HANDLE, not to the process. A process that
10
+ * serves several knowledge bases holds one handle per tenant, each built with
11
+ * that tenant's own `SECRETS_ENC_KEY` (`createDb(url, { piiKey })`), so a
12
+ * tenant's rows are sealed under the same key as its stored credentials and
13
+ * its dump opens, whole, with that one key.
14
+ *
15
+ * A drizzle column type is a module-level object and is told nothing about
16
+ * the handle a statement runs on, so it cannot hold a key. It only MARKS a
17
+ * value ({@link SealOnWrite}, {@link IndexOnWrite}); the handle's own
18
+ * connection replaces the mark with ciphertext or a blind index on the way
19
+ * in, and opens every sealed value on the way out (see `connection.ts`). A
20
+ * mark that reaches a connection with no key refuses to be written.
21
+ *
22
+ * Both keys are HKDF-derived from the handle's key with distinct info
23
+ * strings, so PII ciphertext and blind indexes are domain-separated from the
24
+ * secrets-vault key without asking operators to provision a second variable.
25
+ */
26
+ /** What a database handle seals, opens and indexes personal data with. */
27
+ export interface PiiKeys {
28
+ /**
29
+ * Encrypt a value for storage (fresh random IV — NOT equality-comparable).
30
+ *
31
+ * The empty string is stored as itself: it carries no personal data, GCM of
32
+ * an empty plaintext would produce an empty ciphertext segment the blob
33
+ * parser cannot represent, and columns with a DB-level `DEFAULT ''` then
34
+ * hold exactly the same representation as an app-written empty value.
35
+ */
36
+ seal(plain: string): string;
37
+ /**
38
+ * Open a stored value, and SAY whether it opened: a value that is not a
39
+ * blob is its own plaintext; a blob this key does not open is `ok: false`.
40
+ * For the callers that must tell "the key does not open this" from a value
41
+ * — the shape of what {@link read} returns proves nothing, since a
42
+ * plaintext may itself be shaped like a blob.
43
+ */
44
+ open(value: string): {
45
+ ok: true;
46
+ plain: string;
47
+ } | {
48
+ ok: false;
49
+ };
50
+ /**
51
+ * The lenient read every query result goes through: a blob this key does
52
+ * not open is handed back as it is, as is anything that is not a blob —
53
+ * rows written before the encryption release stay readable until the
54
+ * backfill at start rewrites them.
55
+ */
56
+ read(value: string): string;
57
+ /**
58
+ * Blind index for equality on an encrypted column: HMAC-SHA256 of the
59
+ * trimmed, lower-cased value, hex-encoded. Deterministic, so a `*_bidx`
60
+ * column can carry the unique constraints and lookups that randomized
61
+ * ciphertext cannot. Reveals only equality, never content.
62
+ */
63
+ index(value: string): string;
64
+ }
65
+ /** Derive the personal-data keys from a deployment's (or a tenant's) `SECRETS_ENC_KEY`. */
66
+ export declare function derivePiiKeys(secretsEncKey: string): PiiKeys;
67
+ /**
68
+ * Every PII ciphertext starts with this marker. An explicit prefix — rather
69
+ * than recognising ciphertext by its `iv:tag:ct` shape — means legacy
70
+ * plaintext can never be mistaken for ciphertext (and silently skipped by the
71
+ * backfill), and lets the backfill find unsealed rows with a plain SQL
72
+ * predicate instead of scanning every row in the app. Bump the version
73
+ * segment if the format ever changes.
74
+ */
75
+ export declare const PII_CIPHERTEXT_PREFIX = "pii:v1:";
76
+ /**
77
+ * The shape of a PII ciphertext blob, as ONE pattern both Postgres and this
78
+ * process read: the version prefix followed by base64 segments of the exact
79
+ * widths GCM produces (12-byte IV → 16 chars, 16-byte tag → 22 chars + `==`).
80
+ * Lets the backfill find unsealed rows with a `!~` predicate instead of
81
+ * scanning every row in the app.
82
+ *
83
+ * {@link isEncryptedBlob} is built FROM it rather than written beside it. The
84
+ * two used to be separate spellings of one idea, and they disagreed: the
85
+ * JavaScript one decoded each part and so took an unpadded tag for a 16-byte
86
+ * one, which this pattern does not. A value the two disagreed about was
87
+ * selected by the backfill's SQL as unsealed and then skipped by its
88
+ * JavaScript as sealed, on every start, and stayed in clear for good. The
89
+ * pattern uses nothing POSIX and JavaScript read differently.
90
+ */
91
+ export declare const PII_SEALED_SHAPE_SQL_REGEX = "^pii:v1:[A-Za-z0-9+/]{16}:[A-Za-z0-9+/]{22}==:[A-Za-z0-9+/]+={0,2}$";
92
+ /**
93
+ * Whether `value` has the shape of a PII ciphertext blob — exactly the values
94
+ * {@link PII_SEALED_SHAPE_SQL_REGEX} matches in the database, no more and no
95
+ * fewer. Shape only: whether the configured key OPENS it is `PiiKeys.open`'s
96
+ * answer, and a plaintext somebody typed in this shape passes here.
97
+ */
98
+ export declare function isEncryptedBlob(value: string): boolean;
99
+ /**
100
+ * A value on its way to the database that the handle's connection still has
101
+ * to turn into what is stored. It is never a storable value itself: `pg`
102
+ * asks an object how to serialise itself through `toPostgres`, and this one
103
+ * refuses, so a statement that reaches a connection which did not replace it
104
+ * — a pool built without `createDb`, or a handle built without a key — fails
105
+ * instead of writing the plaintext.
106
+ */
107
+ export declare abstract class PiiParam {
108
+ readonly plain: string;
109
+ constructor(plain: string);
110
+ /** What the handle's keys make of it. */
111
+ abstract stored(keys: PiiKeys): string;
112
+ toPostgres(): never;
113
+ }
114
+ /** Plaintext of an {@link encryptedText} column: stored as ciphertext. */
115
+ export declare class SealOnWrite extends PiiParam {
116
+ stored(keys: PiiKeys): string;
117
+ }
118
+ /** The address a {@link blindIndexText} column is written or compared with: stored as its blind index. */
119
+ export declare class IndexOnWrite extends PiiParam {
120
+ stored(keys: PiiKeys): string;
121
+ }
122
+ /**
123
+ * Drizzle column type for encrypted PII text: services read and write
124
+ * plaintext, the database only ever sees ciphertext. NEVER use an
125
+ * `encryptedText` column in a WHERE clause or conflict target — the fresh IV
126
+ * per write means `eq(column, plaintext)` silently matches nothing. Equality
127
+ * goes through the column's `*_bidx` companion ({@link blindIndexText}).
128
+ */
129
+ export declare const encryptedText: {
130
+ (): import("drizzle-orm/pg-core").PgCustomColumnBuilder<{
131
+ name: "";
132
+ dataType: "custom";
133
+ columnType: "PgCustomColumn";
134
+ data: string;
135
+ driverParam: string;
136
+ enumValues: undefined;
137
+ }>;
138
+ <TConfig extends Record<string, any>>(fieldConfig?: TConfig | undefined): import("drizzle-orm/pg-core").PgCustomColumnBuilder<{
139
+ name: "";
140
+ dataType: "custom";
141
+ columnType: "PgCustomColumn";
142
+ data: string;
143
+ driverParam: string;
144
+ enumValues: undefined;
145
+ }>;
146
+ <TName extends string>(dbName: TName, fieldConfig?: unknown): import("drizzle-orm/pg-core").PgCustomColumnBuilder<{
147
+ name: TName;
148
+ dataType: "custom";
149
+ columnType: "PgCustomColumn";
150
+ data: string;
151
+ driverParam: string;
152
+ enumValues: undefined;
153
+ }>;
154
+ };
155
+ /**
156
+ * Drizzle column type for the blind index beside an encrypted column. WRITE
157
+ * AND COMPARE IT WITH THE VALUE ITSELF — `emailBidx: email`,
158
+ * `eq(users.emailBidx, email)`, `inArray(users.emailBidx, emails)` — and the
159
+ * handle's connection stores or binds its index. Reading the column gives the
160
+ * stored index, which is good for nothing but SQL: writing it back would
161
+ * index the index, so that is refused. A row copied from another carries the
162
+ * value its index was made from, not the index.
163
+ *
164
+ * Only through drizzle's operators, which bind through the column: a value
165
+ * interpolated into a raw `sql` template is compared as it is and matches
166
+ * nothing.
167
+ */
168
+ export declare const blindIndexText: {
169
+ (): import("drizzle-orm/pg-core").PgCustomColumnBuilder<{
170
+ name: "";
171
+ dataType: "custom";
172
+ columnType: "PgCustomColumn";
173
+ data: string;
174
+ driverParam: string;
175
+ enumValues: undefined;
176
+ }>;
177
+ <TConfig extends Record<string, any>>(fieldConfig?: TConfig | undefined): import("drizzle-orm/pg-core").PgCustomColumnBuilder<{
178
+ name: "";
179
+ dataType: "custom";
180
+ columnType: "PgCustomColumn";
181
+ data: string;
182
+ driverParam: string;
183
+ enumValues: undefined;
184
+ }>;
185
+ <TName extends string>(dbName: TName, fieldConfig?: unknown): import("drizzle-orm/pg-core").PgCustomColumnBuilder<{
186
+ name: TName;
187
+ dataType: "custom";
188
+ columnType: "PgCustomColumn";
189
+ data: string;
190
+ driverParam: string;
191
+ enumValues: undefined;
192
+ }>;
193
+ };
194
+ //# sourceMappingURL=column-crypto.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"column-crypto.d.ts","sourceRoot":"","sources":["../../src/shared/column-crypto.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,0EAA0E;AAC1E,MAAM,WAAW,OAAO;IACtB;;;;;;;OAOG;IACH,IAAI,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC;IAC5B;;;;;;OAMG;IACH,IAAI,CAAC,KAAK,EAAE,MAAM,GAAG;QAAE,EAAE,EAAE,IAAI,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,GAAG;QAAE,EAAE,EAAE,KAAK,CAAA;KAAE,CAAC;IACjE;;;;;OAKG;IACH,IAAI,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC;IAC5B;;;;;OAKG;IACH,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC;CAC9B;AAED,2FAA2F;AAC3F,wBAAgB,aAAa,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAsB5D;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,qBAAqB,YAAY,CAAC;AAE/C;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,0BAA0B,wEAAyF,CAAC;AAIjI;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAEtD;AAED;;;;;;;GAOG;AACH,8BAAsB,QAAQ;IAChB,QAAQ,CAAC,KAAK,EAAE,MAAM;gBAAb,KAAK,EAAE,MAAM;IAElC,yCAAyC;IACzC,QAAQ,CAAC,MAAM,CAAC,IAAI,EAAE,OAAO,GAAG,MAAM;IAEtC,UAAU,IAAI,KAAK;CAMpB;AAED,0EAA0E;AAC1E,qBAAa,WAAY,SAAQ,QAAQ;IACvC,MAAM,CAAC,IAAI,EAAE,OAAO,GAAG,MAAM;CAG9B;AAED,0GAA0G;AAC1G,qBAAa,YAAa,SAAQ,QAAQ;IACxC,MAAM,CAAC,IAAI,EAAE,OAAO,GAAG,MAAM;CAG9B;AAED;;;;;;GAMG;AACH,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;CAaxB,CAAC;AAIH;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;CAezB,CAAC"}
@@ -0,0 +1,144 @@
1
+ import { createHmac, hkdfSync } from 'node:crypto';
2
+ import { customType } from 'drizzle-orm/pg-core';
3
+ import { TokenCrypto, assertKeyDecodesTo32Bytes } from './token-crypto.js';
4
+ /** Derive the personal-data keys from a deployment's (or a tenant's) `SECRETS_ENC_KEY`. */
5
+ export function derivePiiKeys(secretsEncKey) {
6
+ const ikm = assertKeyDecodesTo32Bytes(secretsEncKey, 'SECRETS_ENC_KEY');
7
+ const columnKey = Buffer.from(hkdfSync('sha256', ikm, Buffer.alloc(0), 'bevel-pii-column-v1', 32));
8
+ const bidxKey = Buffer.from(hkdfSync('sha256', ikm, Buffer.alloc(0), 'bevel-pii-bidx-v1', 32));
9
+ const crypto = new TokenCrypto(columnKey.toString('base64'));
10
+ const open = (value) => {
11
+ if (!isEncryptedBlob(value))
12
+ return { ok: true, plain: value };
13
+ try {
14
+ return { ok: true, plain: crypto.decrypt(value.slice(PII_CIPHERTEXT_PREFIX.length)) };
15
+ }
16
+ catch {
17
+ return { ok: false };
18
+ }
19
+ };
20
+ return {
21
+ seal: (plain) => (plain === '' ? '' : PII_CIPHERTEXT_PREFIX + crypto.encrypt(plain)),
22
+ open,
23
+ read: (value) => {
24
+ const opened = open(value);
25
+ return opened.ok ? opened.plain : value;
26
+ },
27
+ index: (value) => createHmac('sha256', bidxKey).update(value.trim().toLowerCase()).digest('hex'),
28
+ };
29
+ }
30
+ /**
31
+ * Every PII ciphertext starts with this marker. An explicit prefix — rather
32
+ * than recognising ciphertext by its `iv:tag:ct` shape — means legacy
33
+ * plaintext can never be mistaken for ciphertext (and silently skipped by the
34
+ * backfill), and lets the backfill find unsealed rows with a plain SQL
35
+ * predicate instead of scanning every row in the app. Bump the version
36
+ * segment if the format ever changes.
37
+ */
38
+ export const PII_CIPHERTEXT_PREFIX = 'pii:v1:';
39
+ /**
40
+ * The shape of a PII ciphertext blob, as ONE pattern both Postgres and this
41
+ * process read: the version prefix followed by base64 segments of the exact
42
+ * widths GCM produces (12-byte IV → 16 chars, 16-byte tag → 22 chars + `==`).
43
+ * Lets the backfill find unsealed rows with a `!~` predicate instead of
44
+ * scanning every row in the app.
45
+ *
46
+ * {@link isEncryptedBlob} is built FROM it rather than written beside it. The
47
+ * two used to be separate spellings of one idea, and they disagreed: the
48
+ * JavaScript one decoded each part and so took an unpadded tag for a 16-byte
49
+ * one, which this pattern does not. A value the two disagreed about was
50
+ * selected by the backfill's SQL as unsealed and then skipped by its
51
+ * JavaScript as sealed, on every start, and stayed in clear for good. The
52
+ * pattern uses nothing POSIX and JavaScript read differently.
53
+ */
54
+ export const PII_SEALED_SHAPE_SQL_REGEX = `^${PII_CIPHERTEXT_PREFIX}[A-Za-z0-9+/]{16}:[A-Za-z0-9+/]{22}==:[A-Za-z0-9+/]+={0,2}$`;
55
+ const PII_SEALED_SHAPE = new RegExp(PII_SEALED_SHAPE_SQL_REGEX);
56
+ /**
57
+ * Whether `value` has the shape of a PII ciphertext blob — exactly the values
58
+ * {@link PII_SEALED_SHAPE_SQL_REGEX} matches in the database, no more and no
59
+ * fewer. Shape only: whether the configured key OPENS it is `PiiKeys.open`'s
60
+ * answer, and a plaintext somebody typed in this shape passes here.
61
+ */
62
+ export function isEncryptedBlob(value) {
63
+ return PII_SEALED_SHAPE.test(value);
64
+ }
65
+ /**
66
+ * A value on its way to the database that the handle's connection still has
67
+ * to turn into what is stored. It is never a storable value itself: `pg`
68
+ * asks an object how to serialise itself through `toPostgres`, and this one
69
+ * refuses, so a statement that reaches a connection which did not replace it
70
+ * — a pool built without `createDb`, or a handle built without a key — fails
71
+ * instead of writing the plaintext.
72
+ */
73
+ export class PiiParam {
74
+ plain;
75
+ constructor(plain) {
76
+ this.plain = plain;
77
+ }
78
+ toPostgres() {
79
+ throw new Error('A personal-data value reached a database connection that holds no key for it. ' +
80
+ 'Build the handle with createDb/getDb and its piiKey (createCoreServices does).');
81
+ }
82
+ }
83
+ /** Plaintext of an {@link encryptedText} column: stored as ciphertext. */
84
+ export class SealOnWrite extends PiiParam {
85
+ stored(keys) {
86
+ return keys.seal(this.plain);
87
+ }
88
+ }
89
+ /** The address a {@link blindIndexText} column is written or compared with: stored as its blind index. */
90
+ export class IndexOnWrite extends PiiParam {
91
+ stored(keys) {
92
+ return keys.index(this.plain);
93
+ }
94
+ }
95
+ /**
96
+ * Drizzle column type for encrypted PII text: services read and write
97
+ * plaintext, the database only ever sees ciphertext. NEVER use an
98
+ * `encryptedText` column in a WHERE clause or conflict target — the fresh IV
99
+ * per write means `eq(column, plaintext)` silently matches nothing. Equality
100
+ * goes through the column's `*_bidx` companion ({@link blindIndexText}).
101
+ */
102
+ export const encryptedText = customType({
103
+ dataType() {
104
+ return 'text';
105
+ },
106
+ toDriver(value) {
107
+ // The mark, typed as the text it becomes on the handle's connection.
108
+ return (value === '' ? '' : new SealOnWrite(value));
109
+ },
110
+ fromDriver(value) {
111
+ // Already opened: the handle's connection opens every sealed value of a
112
+ // result before drizzle maps it.
113
+ return value;
114
+ },
115
+ });
116
+ const STORED_INDEX = /^[0-9a-f]{64}$/;
117
+ /**
118
+ * Drizzle column type for the blind index beside an encrypted column. WRITE
119
+ * AND COMPARE IT WITH THE VALUE ITSELF — `emailBidx: email`,
120
+ * `eq(users.emailBidx, email)`, `inArray(users.emailBidx, emails)` — and the
121
+ * handle's connection stores or binds its index. Reading the column gives the
122
+ * stored index, which is good for nothing but SQL: writing it back would
123
+ * index the index, so that is refused. A row copied from another carries the
124
+ * value its index was made from, not the index.
125
+ *
126
+ * Only through drizzle's operators, which bind through the column: a value
127
+ * interpolated into a raw `sql` template is compared as it is and matches
128
+ * nothing.
129
+ */
130
+ export const blindIndexText = customType({
131
+ dataType() {
132
+ return 'text';
133
+ },
134
+ toDriver(value) {
135
+ if (STORED_INDEX.test(value)) {
136
+ throw new Error('A blind-index column was written with a stored index. Write it with the value the index is of (the address).');
137
+ }
138
+ return new IndexOnWrite(value);
139
+ },
140
+ fromDriver(value) {
141
+ return value;
142
+ },
143
+ });
144
+ //# sourceMappingURL=column-crypto.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"column-crypto.js","sourceRoot":"","sources":["../../src/shared/column-crypto.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,WAAW,EAAE,yBAAyB,EAAE,MAAM,mBAAmB,CAAC;AA+D3E,2FAA2F;AAC3F,MAAM,UAAU,aAAa,CAAC,aAAqB;IACjD,MAAM,GAAG,GAAG,yBAAyB,CAAC,aAAa,EAAE,iBAAiB,CAAC,CAAC;IACxE,MAAM,SAAS,GAAG,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,QAAQ,EAAE,GAAG,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,qBAAqB,EAAE,EAAE,CAAC,CAAC,CAAC;IACnG,MAAM,OAAO,GAAG,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,QAAQ,EAAE,GAAG,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,mBAAmB,EAAE,EAAE,CAAC,CAAC,CAAC;IAC/F,MAAM,MAAM,GAAG,IAAI,WAAW,CAAC,SAAS,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC;IAC7D,MA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AQ,CAAC,KAAa;QACpB,IAAI,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;YAC7B,MAAM,IAAI,KAAK,CACb,8GAA8G,CAC/G,CAAC;QACJ,CAAC;QACD,OAAO,IAAI,YAAY,CAAC,KAAK,CAAsB,CAAC;IACtD,CAAC;IACD,UAAU,CAAC,KAAa;QACtB,OAAO,KAAK,CAAC;IACf,CAAC;CACF,CAAC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"token-crypto.d.ts","sourceRoot":"","sources":["../../src/shared/token-crypto.ts"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AACH,qBAAa,WAAW;IACtB,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAS;IAE7B;;;;;;;OAOG;gBACS,MAAM,EAAE,MAAM,EAAE,UAAU,SAAoB;IAI1D,OAAO,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM;IAQlC,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM;CAa9B;AASD;;;;;;GAMG;AACH,wBAAgB,yBAAyB,CAAC,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,CASpF"}
1
+ {"version":3,"file":"token-crypto.d.ts","sourceRoot":"","sources":["../../src/shared/token-crypto.ts"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AACH,qBAAa,WAAW;IACtB,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAS;IAE7B;;;;;;;OAOG;gBACS,MAAM,EAAE,MAAM,EAAE,UAAU,SAAoB;IAI1D,OAAO,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM;IAQlC,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM;CAa9B;AASD;;;;;;GAMG;AACH,wBAAgB,yBAAyB,CAAC,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,CA4BpF"}
@@ -56,11 +56,35 @@ function decodeKey(raw) {
56
56
  * is then safe, because a bad key never gets that far.
57
57
  */
58
58
  export function assertKeyDecodesTo32Bytes(rawKey, envVarName) {
59
- const key = decodeKey(rawKey);
59
+ // Whitespace around it is the environment's, not the key's.
60
+ const written = rawKey.trim();
61
+ const key = decodeKey(written);
60
62
  if (key.length !== 32) {
61
63
  throw new Error(`${envVarName} must decode to 32 bytes (got ${key.length}). ` +
62
64
  'Generate one with: `node -e "console.log(require(\'crypto\').randomBytes(32).toString(\'base64\'))"`.');
63
65
  }
66
+ // WHAT IS WRITTEN MUST BE A SPELLING OF WHAT IT DECODES TO. Node's decoder is
67
+ // forgiving in ways a key must not be: it skips a character it does not know,
68
+ // it stops at padding wherever padding stands, and it ignores bits a final
69
+ // character should not carry. Each of those turns a mistyped key into 32
70
+ // bytes — a DIFFERENT key, sealing data that the value an operator wrote
71
+ // down will never open. Asking which characters and which padding are
72
+ // acceptable is a list that is always one case short, so the question is put
73
+ // the other way round: encode the bytes again, and accept the value only
74
+ // when it is one of the ways those bytes are written.
75
+ if (!spellingsOf(key).includes(/^[0-9a-fA-F]{64}$/.test(written) ? written.toLowerCase() : written)) {
76
+ throw new Error(`${envVarName} is not a clean hex or base64 spelling of a 32-byte key: it holds a character, a padding ` +
77
+ 'or trailing bits the encoding does not have, which the decoder skipped. The key in use so far is what ' +
78
+ 'it decoded to; print that key spelled properly with ' +
79
+ `\`node -e "console.log(Buffer.from(process.env.${envVarName}, 'base64').toString('base64'))"\` and set that.`);
80
+ }
64
81
  return key;
65
82
  }
83
+ /** Every way 32 bytes are written as a key: hex, and base64 in either alphabet, padded or not. */
84
+ function spellingsOf(key) {
85
+ const standard = key.toString('base64');
86
+ const urlSafe = key.toString('base64url');
87
+ const padding = standard.slice(standard.replace(/=+$/, '').length);
88
+ return [key.toString('hex'), standard, standard.replace(/=+$/, ''), urlSafe, urlSafe + padding];
89
+ }
66
90
  //# sourceMappingURL=token-crypto.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"token-crypto.js","sourceRoot":"","sources":["../../src/shared/token-crypto.ts"],"names":[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A2BjF"}
@@ -103,6 +103,7 @@ export function tenantConfigFrom(record, settings) {
103
103
  workspacesRoot: path.resolve(settings.workspacesRoot, slug),
104
104
  backupsRoot: besideWorkspaces('backups'),
105
105
  spillRoot: besideWorkspaces('tool-chain-spills'),
106
+ agentUploadsRoot: besideWorkspaces('agent-uploads'),
106
107
  docExtractCacheRoot: besideWorkspaces('doc-extract-cache'),
107
108
  jwtSecret: secrets.jwtSecret,
108
109
  secretsEncKey: secrets.secretsEncKey,
@@ -1 +1 @@
1
- {"version":3,"file":"static-tenant-source.js","sourceRoot":"","sources":["../../src/tenancy/static-tenant-source.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAClC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,kBAAkB,EAAqB,MAAM,mBAAmB,CAAC;AAC1E,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AACxF,OAAO,EAAE,sBAAsB,EAAE,MAAM,4CAA4C,CAAC;AACpF,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAA4C,MAAM,6BAA6B,CAAC;AA+DxH,MAAM,aAAa,GAAG,4BAA4B,CAAC;AACnD,MAAM,gBAAgB,GAAG,mBAAmB,CAAC;AAE7C;;;;;GAKG;AACH,MAAM,UAAU,gBAAgB,CAAC,MAAoB,EAAE,QAA4B;IACjF,MAAM,IAAI,GAAG,gBAAgB,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAC3C,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,MAAM,CAAC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