@drfed/drfed 0.0.0-stage → 0.1.0-dev.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 (165) hide show
  1. package/LICENSE +661 -0
  2. package/README.md +1198 -2
  3. package/bin/drfed-account.mjs +20 -0
  4. package/bin/drfed-migrate.mjs +20 -0
  5. package/bin/drfed-server.mjs +20 -0
  6. package/bin/drfed-web.mjs +20 -0
  7. package/completions/bash/drfed-account +219 -0
  8. package/completions/bash/drfed-migrate +219 -0
  9. package/completions/bash/drfed-server +219 -0
  10. package/completions/bash/drfed-web +219 -0
  11. package/completions/fish/drfed-account.fish +264 -0
  12. package/completions/fish/drfed-migrate.fish +264 -0
  13. package/completions/fish/drfed-server.fish +264 -0
  14. package/completions/fish/drfed-web.fish +264 -0
  15. package/completions/nu/drfed-account.nu +293 -0
  16. package/completions/nu/drfed-migrate.nu +293 -0
  17. package/completions/nu/drfed-server.nu +293 -0
  18. package/completions/nu/drfed-web.nu +293 -0
  19. package/completions/pwsh/drfed-account.ps1 +183 -0
  20. package/completions/pwsh/drfed-migrate.ps1 +183 -0
  21. package/completions/pwsh/drfed-server.ps1 +183 -0
  22. package/completions/pwsh/drfed-web.ps1 +183 -0
  23. package/completions/zsh/_drfed-account +145 -0
  24. package/completions/zsh/_drfed-migrate +145 -0
  25. package/completions/zsh/_drfed-server +145 -0
  26. package/completions/zsh/_drfed-web +145 -0
  27. package/dist/api-mail-parser.d.mts +106 -0
  28. package/dist/api-mail-parser.d.mts.map +1 -0
  29. package/dist/api-mail-parser.mjs +145 -0
  30. package/dist/api-mail-parser.mjs.map +1 -0
  31. package/dist/api-mail-settings-BcGaqQ9f.d.mts +142 -0
  32. package/dist/api-mail-settings-BcGaqQ9f.d.mts.map +1 -0
  33. package/dist/api-mail-settings.d.mts +2 -0
  34. package/dist/api-mail-settings.mjs +272 -0
  35. package/dist/api-mail-settings.mjs.map +1 -0
  36. package/dist/bounded-mail-runtime.d.mts +9 -0
  37. package/dist/bounded-mail-runtime.d.mts.map +1 -0
  38. package/dist/bounded-mail-runtime.mjs +66 -0
  39. package/dist/bounded-mail-runtime.mjs.map +1 -0
  40. package/dist/commands/account-create.d.mts +37 -0
  41. package/dist/commands/account-create.d.mts.map +1 -0
  42. package/dist/commands/account-create.mjs +87 -0
  43. package/dist/commands/account-create.mjs.map +1 -0
  44. package/dist/commands/account-program.d.mts +223 -0
  45. package/dist/commands/account-program.d.mts.map +1 -0
  46. package/dist/commands/account-program.mjs +116 -0
  47. package/dist/commands/account-program.mjs.map +1 -0
  48. package/dist/commands/account.d.mts +6 -0
  49. package/dist/commands/account.d.mts.map +1 -0
  50. package/dist/commands/account.mjs +91 -0
  51. package/dist/commands/account.mjs.map +1 -0
  52. package/dist/commands/migrate-program.d.mts +219 -0
  53. package/dist/commands/migrate-program.d.mts.map +1 -0
  54. package/dist/commands/migrate-program.mjs +116 -0
  55. package/dist/commands/migrate-program.mjs.map +1 -0
  56. package/dist/commands/migrate.d.mts +6 -0
  57. package/dist/commands/migrate.d.mts.map +1 -0
  58. package/dist/commands/migrate.mjs +85 -0
  59. package/dist/commands/migrate.mjs.map +1 -0
  60. package/dist/commands/web-program.d.mts +213 -0
  61. package/dist/commands/web-program.d.mts.map +1 -0
  62. package/dist/commands/web-program.mjs +112 -0
  63. package/dist/commands/web-program.mjs.map +1 -0
  64. package/dist/commands/web.d.mts +6 -0
  65. package/dist/commands/web.d.mts.map +1 -0
  66. package/dist/commands/web.mjs +184 -0
  67. package/dist/commands/web.mjs.map +1 -0
  68. package/dist/configuration-DVVF7xNv.d.mts +432 -0
  69. package/dist/configuration-DVVF7xNv.d.mts.map +1 -0
  70. package/dist/configuration.d.mts +2 -0
  71. package/dist/configuration.mjs +469 -0
  72. package/dist/configuration.mjs.map +1 -0
  73. package/dist/data-path.d.mts +9 -0
  74. package/dist/data-path.d.mts.map +1 -0
  75. package/dist/data-path.mjs +21 -0
  76. package/dist/data-path.mjs.map +1 -0
  77. package/dist/database-runtime.d.mts +26 -0
  78. package/dist/database-runtime.d.mts.map +1 -0
  79. package/dist/database-runtime.mjs +92 -0
  80. package/dist/database-runtime.mjs.map +1 -0
  81. package/dist/database-settings.d.mts +36 -0
  82. package/dist/database-settings.d.mts.map +1 -0
  83. package/dist/database-settings.mjs +67 -0
  84. package/dist/database-settings.mjs.map +1 -0
  85. package/dist/diagnostics.d.mts +29 -0
  86. package/dist/diagnostics.d.mts.map +1 -0
  87. package/dist/diagnostics.mjs +61 -0
  88. package/dist/diagnostics.mjs.map +1 -0
  89. package/dist/index.d.mts +5 -0
  90. package/dist/index.d.mts.map +1 -0
  91. package/dist/index.mjs +344 -0
  92. package/dist/index.mjs.map +1 -0
  93. package/dist/jmap-parser.d.mts +35 -0
  94. package/dist/jmap-parser.d.mts.map +1 -0
  95. package/dist/jmap-parser.mjs +42 -0
  96. package/dist/jmap-parser.mjs.map +1 -0
  97. package/dist/jmap-runtime.d.mts +10 -0
  98. package/dist/jmap-runtime.d.mts.map +1 -0
  99. package/dist/jmap-runtime.mjs +17 -0
  100. package/dist/jmap-runtime.mjs.map +1 -0
  101. package/dist/jmap-settings-BXNAF1ep.d.mts +41 -0
  102. package/dist/jmap-settings-BXNAF1ep.d.mts.map +1 -0
  103. package/dist/jmap-settings.d.mts +2 -0
  104. package/dist/jmap-settings.mjs +104 -0
  105. package/dist/jmap-settings.mjs.map +1 -0
  106. package/dist/logging.d.mts +33 -0
  107. package/dist/logging.d.mts.map +1 -0
  108. package/dist/logging.mjs +56 -0
  109. package/dist/logging.mjs.map +1 -0
  110. package/dist/mail-parser-DyI4wuQp.d.mts +246 -0
  111. package/dist/mail-parser-DyI4wuQp.d.mts.map +1 -0
  112. package/dist/mail-parser.d.mts +2 -0
  113. package/dist/mail-parser.mjs +100 -0
  114. package/dist/mail-parser.mjs.map +1 -0
  115. package/dist/mail-runtime-YROIQ8up.mjs +314 -0
  116. package/dist/mail-runtime-YROIQ8up.mjs.map +1 -0
  117. package/dist/mail-runtime.d.mts +68 -0
  118. package/dist/mail-runtime.d.mts.map +1 -0
  119. package/dist/mail-runtime.mjs +2 -0
  120. package/dist/mail-settings-BD1TQ0rt.mjs +427 -0
  121. package/dist/mail-settings-BD1TQ0rt.mjs.map +1 -0
  122. package/dist/mail-settings-DjWMAUaE.d.mts +80 -0
  123. package/dist/mail-settings-DjWMAUaE.d.mts.map +1 -0
  124. package/dist/mail-settings.d.mts +2 -0
  125. package/dist/mail-settings.mjs +2 -0
  126. package/dist/operations.d.mts +32 -0
  127. package/dist/operations.d.mts.map +1 -0
  128. package/dist/operations.mjs +55 -0
  129. package/dist/operations.mjs.map +1 -0
  130. package/dist/package-7FOUqcPO.mjs +6 -0
  131. package/dist/package-7FOUqcPO.mjs.map +1 -0
  132. package/dist/parser-DGIQTgS7.mjs +178 -0
  133. package/dist/parser-DGIQTgS7.mjs.map +1 -0
  134. package/dist/parser-TANGHRjL.d.mts +305 -0
  135. package/dist/parser-TANGHRjL.d.mts.map +1 -0
  136. package/dist/postgres-settings.d.mts +20 -0
  137. package/dist/postgres-settings.d.mts.map +1 -0
  138. package/dist/postgres-settings.mjs +60 -0
  139. package/dist/postgres-settings.mjs.map +1 -0
  140. package/dist/query-logger.d.mts +9 -0
  141. package/dist/query-logger.d.mts.map +1 -0
  142. package/dist/query-logger.mjs +17 -0
  143. package/dist/query-logger.mjs.map +1 -0
  144. package/dist/resources.d.mts +20 -0
  145. package/dist/resources.d.mts.map +1 -0
  146. package/dist/resources.mjs +34 -0
  147. package/dist/resources.mjs.map +1 -0
  148. package/dist/secret-source-BeZx72Ue.d.mts +21 -0
  149. package/dist/secret-source-BeZx72Ue.d.mts.map +1 -0
  150. package/dist/secret-source.d.mts +2 -0
  151. package/dist/secret-source.mjs +58 -0
  152. package/dist/secret-source.mjs.map +1 -0
  153. package/dist/serving.d.mts +82 -0
  154. package/dist/serving.d.mts.map +1 -0
  155. package/dist/serving.mjs +138 -0
  156. package/dist/serving.mjs.map +1 -0
  157. package/dist/smtp-settings.d.mts +11 -0
  158. package/dist/smtp-settings.d.mts.map +1 -0
  159. package/dist/smtp-settings.mjs +38 -0
  160. package/dist/smtp-settings.mjs.map +1 -0
  161. package/dist/valueparser.d.mts +46 -0
  162. package/dist/valueparser.d.mts.map +1 -0
  163. package/dist/valueparser.mjs +121 -0
  164. package/dist/valueparser.mjs.map +1 -0
  165. package/package.json +275 -3
package/README.md CHANGED
@@ -1,3 +1,1199 @@
1
- # Temporary Holding Version
1
+ @drfed/drfed
2
+ ============
2
3
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
4
+ The main application package for [DrFed], a web-based platform for developing
5
+ and debugging ActivityPub apps. It wires together the database layer,
6
+ ActivityPub federation, GraphQL server, and HTTP server, and exposes the
7
+ `drfed-server`, `drfed-web`, `drfed-migrate`, and `drfed-account` commands.
8
+
9
+ [DrFed]: https://drfed.org/
10
+
11
+
12
+ Usage
13
+ -----
14
+
15
+ ~~~~ sh
16
+ drfed-server --root-origin https://drfed.example.com \
17
+ --data-path .pgdata
18
+ drfed-server --root-origin https://drfed.example.com \
19
+ --database-url postgres://user@localhost/drfed
20
+ ~~~~
21
+
22
+ The server listens on `localhost:8888` by default. Pass `--listen HOST:PORT`
23
+ to override. Automatic database migrations run on startup unless `--no-migrate`
24
+ is given. The frontend and exact `/graphql` endpoint share this listener. Open
25
+ the configured root origin for the frontend, or set `--public-origin` to a
26
+ different control authority. Instance and deeper subdomains cannot be selected
27
+ as its authority. Other control authorities still serve `/graphql`, but web
28
+ requests on them receive 421.
29
+
30
+ CLI parsing validates settings before opening database or mail resources.
31
+ `--help`, `--version`, and `--generate-graphql-schema` can run without starting
32
+ the server; invalid options also exit before creating those resources.
33
+
34
+
35
+ Standalone web frontend
36
+ -----------------------
37
+
38
+ Use `--no-web` for a backend that serves `/graphql` and federation; other
39
+ control paths return 404. Supply the frontend login origin explicitly.
40
+ `drfed-web` runs the installed frontend against that backend:
41
+
42
+ ~~~~ sh
43
+ drfed-server --no-web --root-origin https://drfed.example.com \
44
+ --login-origin https://drfed.example.com --listen localhost:8888
45
+ drfed-web --backend-url http://localhost:8888 \
46
+ --public-origin https://drfed.example.com --listen localhost:3000
47
+ ~~~~
48
+
49
+ Add the public frontend origin to the backend's `--login-origin` allowlist.
50
+ The command consumes the shared TOML file's `web` and `telemetry` sections,
51
+ without opening database or mail resources. Its listen setting is
52
+ `web.listen`/`DRFED_WEB_LISTEN`, independent of
53
+ `server.listen`/`DRFED_LISTEN`. See [the web package's README](../web/README.md)
54
+ for the complete runtime and request policy.
55
+
56
+
57
+ Root origin
58
+ -----------
59
+
60
+ A root origin is required through `--root-origin`, `DRFED_ROOT_ORIGIN`, or
61
+ `server.root_origin` in the selected TOML file. Everything else follows from
62
+ it. Each instance is served from its own subdomain of that origin, so with
63
+ `https://drfed.example.com` the instance `foo-bar` lives at
64
+ `https://foo-bar.drfed.example.com`. A non-default port belongs in the value
65
+ and is carried into every instance, which is what makes a development
66
+ deployment work:
67
+
68
+ ~~~~ sh
69
+ drfed-server --root-origin http://drfed.localhost:8888 \
70
+ --data-path .pgdata
71
+ ~~~~
72
+
73
+ Requests are routed by the authority they arrive on:
74
+
75
+ | Authority | Serves |
76
+ | ------------------------------------- | ------------------------------------- |
77
+ | `<slug>.<root domain>` | ActivityPub only; GraphQL answers 404 |
78
+ | the public web authority | Frontend and exact `/graphql` |
79
+ | other control authorities | Exact `/graphql`; web paths are 421 |
80
+ | anything deeper under the root domain | 421 Misdirected Request |
81
+ | an unusable `Host` header | 400 Bad Request |
82
+
83
+ The authority has to match in full, port included. A request for
84
+ `foo.drfed.example.com:8888` against a root origin of
85
+ `https://drfed.example.com` does not name an instance and is served the control
86
+ surface, not a 404, so do not read the table above as isolating GraphQL by host
87
+ name alone. Ports 80 and 443 both count as no port at all, since which of them
88
+ is the default depends on a scheme that is deliberately not compared.
89
+
90
+ The first-release reverse proxy contract preserves the original `Host` header.
91
+ Set the root origin's external scheme for federation and the public web
92
+ origin's external scheme for the frontend. The server restores those schemes
93
+ before handing requests to Fedify or SolidStart; it ignores forwarded headers.
94
+ `X-Forwarded-Host` cannot select an instance or frontend. Proxies that replace
95
+ `Host` are unsupported. A trailing-dot Host may be refused by srvx before the
96
+ DrFed router runs.
97
+
98
+ Deploying this way needs a wildcard DNS record for `*.<root domain>` and, over
99
+ HTTPS, a wildcard TLS certificate to match.
100
+
101
+ Changing the root origin after instances exist does not move them. Their host
102
+ names are already part of the actor URIs the rest of the fediverse has stored,
103
+ so the server only warns at startup about instances it can no longer reach.
104
+
105
+
106
+ Login origins
107
+ -------------
108
+
109
+ `--login-origin` specifies an HTTP or HTTPS origin allowed in email login
110
+ links. Combined mode defaults to the public web origin. An explicit list
111
+ replaces this default and must include that origin. With `--no-web`, at least
112
+ one origin must be explicit. Repeat the option to allow multiple origins:
113
+
114
+ ~~~~ sh
115
+ drfed-server --root-origin https://drfed.example.com --data-path .pgdata \
116
+ --login-origin https://drfed.example.com \
117
+ --login-origin http://localhost:3000
118
+ ~~~~
119
+
120
+ For repository development, create the environment file loaded by
121
+ `mise run dev`:
122
+
123
+ ~~~~ sh
124
+ cp packages/drfed/.env.example packages/drfed/.env
125
+ ~~~~
126
+
127
+ `mise run dev` reads `DRFED_LOGIN_ORIGINS` as a JSON string array and passes
128
+ each value as a `--login-origin` option. If unset, it defaults to
129
+ `["http://localhost:3000"]`. The installed CLI reads the same variable.
130
+ Convert older comma-separated development values to JSON arrays.
131
+
132
+ That file also carries `DRFED_ROOT_ORIGIN`, which `mise run dev` passes as
133
+ `--root-origin`. It defaults to `http://drfed.localhost:8888`; every subdomain
134
+ of `localhost` resolves to the loopback address without any DNS or */etc/hosts*
135
+ setup, which is what makes per-instance subdomains usable locally.
136
+
137
+
138
+ Options
139
+ -------
140
+
141
+ | Option | Short | Description |
142
+ | --------------------------------- | ----- | ------------------------------------------------------------------------------------------------------------------------- |
143
+ | `--web` / `--no-web` | | Enable or disable the frontend (default: enabled) |
144
+ | `--public-origin ORIGIN` | | Frontend origin (default: root origin; unused with `--no-web`) |
145
+ | `--print-config` | | Print effective settings and sources with secrets redacted; exit |
146
+ | `--config FILE` | | Explicit TOML configuration file |
147
+ | `--migrate` | | Enable automatic migrations |
148
+ | `--mail-transport KIND` | | Select `logtape`, `smtp`, `jmap`, `lettermint`, `maileroo`, `mailtrap`, `mailgun`, `plunk`, `resend`, `sendgrid` or `ses` |
149
+ | `--root-origin ORIGIN` | `-r` | Origin instances are subdomains of (required) |
150
+ | `--login-origin ORIGIN` | | Origin allowed in login links (required with `--no-web`; repeatable) |
151
+ | `--listen HOST:PORT` | `-l` | Address to listen on (default: `localhost:8888`) |
152
+ | `--pglite-data-path PATH` | `-d` | Directory for PGlite storage (alias: `--data-path`) |
153
+ | `--postgres-url URL` | `-D` | PostgreSQL connection URL (alias: `--database-url`) |
154
+ | `--no-migrate` | `-M` | Skip automatic migrations |
155
+ | `--email-from ADDRESS` | `-f` | Sender of login mail (default: `noreply@` at the root origin's host) |
156
+ | `--smtp-url URL` | `-s` | SMTP server to deliver mail through |
157
+ | `--mail-log-content` | | Include subject/body and login codes in log-only output |
158
+ | `--no-mail-log-content` | | Exclude mail subject/body (default) |
159
+ | `--smtp-host VALUE` | | SMTP server hostname |
160
+ | `--smtp-port VALUE` | | SMTP server port |
161
+ | `--smtp-tls VALUE` | | SMTP TLS mode: direct, starttls-required or opportunistic |
162
+ | `--smtp-user VALUE` | | SMTP authentication username |
163
+ | `--smtp-password VALUE` | | SMTP authentication password |
164
+ | `--smtp-password-file VALUE` | | File containing the SMTP password |
165
+ | `--smtp-auth-method VALUE` | | SMTP authentication method |
166
+ | `--smtp-access-token VALUE` | | Static SMTP OAuth access token |
167
+ | `--smtp-access-token-file VALUE` | | File containing the SMTP OAuth access token |
168
+ | `--smtp-connection-timeout VALUE` | | SMTP connection timeout in milliseconds |
169
+ | `--smtp-socket-timeout VALUE` | | SMTP socket timeout in milliseconds |
170
+ | `--smtp-pool-size VALUE` | | Maximum owned SMTP connections |
171
+ | `--smtp-local-name VALUE` | | Local name for SMTP EHLO |
172
+ | `--smtp-ca-file VALUE` | | File containing additional SMTP certificate authorities |
173
+ | `--smtp-cert-file VALUE` | | File containing the SMTP client certificate |
174
+ | `--smtp-key-file VALUE` | | File containing the SMTP client private key |
175
+ | `--help` | | Show help |
176
+ | `--version` | | Show version |
177
+
178
+ `--pglite-data-path` and `--postgres-url` conflict at the winning input source.
179
+ Provide the path or URL for the selected database through CLI, environment or
180
+ TOML; the source selection rules are described below.
181
+
182
+ Without a mail delivery transport, DrFed logs mail lifecycle events and warns
183
+ that delivery is disabled. Subject and body are excluded by default. For local
184
+ login links, explicitly pass `--mail-log-content`; `mise run dev` does this for
185
+ the development server.
186
+
187
+
188
+ Building completion scripts
189
+ ---------------------------
190
+
191
+ `mise run build` generates completion scripts for all four commands and the
192
+ five Optique shells. To regenerate them explicitly, run
193
+ `mise run generate:completion` from the repository root.
194
+
195
+ The published package includes these files under *completions/*:
196
+
197
+ - *bash/drfed-COMMAND*
198
+ - *zsh/\_drfed-COMMAND*
199
+ - *fish/drfed-COMMAND.fish*
200
+ - *pwsh/drfed-COMMAND.ps1*
201
+ - *nu/drfed-COMMAND.nu*
202
+
203
+ Replace `COMMAND` with `server`, `web`, `migrate`, or `account`. The files are
204
+ generated from the built command runners; installation does not run the
205
+ generator or require development dependencies.
206
+
207
+
208
+ Completion installation
209
+ -----------------------
210
+
211
+ npm installation does not activate shell completion automatically. Packed
212
+ local and custom global installations keep the scripts inside the package;
213
+ fresh shells do not discover them through npm's bin links. A version-manager
214
+ prefix is also not necessarily a shell completion search path.
215
+
216
+ | Shell | Loading requirement |
217
+ | ---------- | ------------------------------------------------------------------- |
218
+ | Bash | Source the script, or use an initialized bash-completion framework. |
219
+ | zsh | Initialize `compinit` and source the script. |
220
+ | fish | Source the script, or put it in `fish_complete_path`. |
221
+ | PowerShell | Dot-source the script in the session or a profile. |
222
+ | Nushell | Source the script in the session or *config.nu*. |
223
+
224
+ The [bash-completion lookup conventions] allow prefix-based discovery with
225
+ recent versions of that framework. zsh uses [`fpath`], and fish uses
226
+ [`fish_complete_path`]; neither necessarily searches an npm prefix. PowerShell
227
+ [profiles] and Nushell [custom completions] require explicit loading.
228
+
229
+ DrFed does not install shared completion links or use lifecycle hooks for
230
+ setup. npm has [no uninstall lifecycle hook] to reliably remove shared
231
+ registrations, and installation scripts can be disabled. Shell setup stays
232
+ under the operator's control, including when several DrFed installations
233
+ coexist. Select the intended binary through `PATH`; regenerate your copied
234
+ scripts after upgrades and remove your copies and startup references when
235
+ you no longer use them.
236
+
237
+ To probe packed installations and explicit loading in all five shells, run
238
+ `mise run test:completion-installation`. This selects fish 4.9.3 and PowerShell
239
+ 7.6.6 through mise, in addition to Bash, zsh and the pinned Nushell. Probes
240
+ use temporary shell configuration directories and do not edit startup files.
241
+ On macOS, actual zsh Tab requests were exercised for all four commands, and
242
+ all four Nushell scripts were sourced together before checking each command's
243
+ suggestions. The bash-completion framework, live version-manager prefixes,
244
+ Linux and Windows installation behavior have not yet been tested.
245
+
246
+ [bash-completion lookup conventions]: https://github.com/scop/bash-completion#faq
247
+ [`fpath`]: https://zsh.sourceforge.io/Doc/Release/Completion-System.html#Initialization
248
+ [`fish_complete_path`]: https://fishshell.com/docs/current/completions.html#where-to-put-completions
249
+ [profiles]: https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_profiles
250
+ [custom completions]: https://www.nushell.sh/book/custom_completions.html
251
+ [no uninstall lifecycle hook]: https://docs.npmjs.com/cli/v11/using-npm/scripts#a-note-on-a-lack-of-npm-uninstall-scripts
252
+
253
+
254
+ Manual loading
255
+ --------------
256
+
257
+ Register all four commands. For a local installation, first put the project's
258
+ *node\_modules/.bin/* on the current shell's `PATH`, so callbacks can find the
259
+ same binaries that generated the scripts. For example, in Bash or zsh:
260
+
261
+ ~~~~ sh
262
+ export PATH="$PWD/node_modules/.bin:$PATH"
263
+ ~~~~
264
+
265
+ In fish use `set -gx PATH "$PWD/node_modules/.bin" $PATH`. In PowerShell use
266
+ `$env:PATH = "$(Join-Path $PWD 'node_modules/.bin')$([IO.Path]::PathSeparator)$env:PATH"`.
267
+ In Nushell use
268
+ `$env.PATH = ($env.PATH | prepend ($env.PWD | path join node_modules .bin))`.
269
+ On Windows the local executable shims are
270
+ *node\_modules/.bin/drfed-COMMAND.cmd*; for example,
271
+ `& .\node_modules\.bin\drfed-server.cmd completion pwsh` generates the
272
+ PowerShell script. Local npm installation does not add these binaries to your
273
+ general `PATH`.
274
+
275
+ Generate files in a directory you control. The following commands replace
276
+ files with the same names, so choose a fresh directory for initial setup.
277
+
278
+ ### Bash
279
+
280
+ ~~~~ bash
281
+ for command in drfed-server drfed-web drfed-migrate drfed-account; do
282
+ "$command" completion bash > "$command-completion.bash"
283
+ source "./$command-completion.bash"
284
+ done
285
+ ~~~~
286
+
287
+ For persistent loading, move the files to a stable user-owned directory and
288
+ add four `source` statements with their absolute paths to your interactive
289
+ Bash startup file. This route does not require bash-completion.
290
+
291
+ ### zsh
292
+
293
+ ~~~~ zsh
294
+ autoload -Uz compinit
295
+ compinit
296
+ for command in drfed-server drfed-web drfed-migrate drfed-account; do
297
+ "$command" completion zsh > "$command-completion.zsh"
298
+ source "./$command-completion.zsh"
299
+ done
300
+ ~~~~
301
+
302
+ For persistent loading, source all four files from a stable directory in
303
+ *.zshrc*, after your existing `compinit` initialization.
304
+
305
+ ### fish
306
+
307
+ ~~~~ fish
308
+ for command in drfed-server drfed-web drfed-migrate drfed-account
309
+ $command completion fish > "$command-completion.fish"
310
+ source "./$command-completion.fish"
311
+ end
312
+ ~~~~
313
+
314
+ For persistent discovery, generate files named *drfed-server.fish*,
315
+ *drfed-web.fish*, *drfed-migrate.fish* and *drfed-account.fish* in your chosen
316
+ fish user completion directory, usually *~/.config/fish/completions/*.
317
+
318
+ ### PowerShell
319
+
320
+ ~~~~ powershell
321
+ foreach ($command in 'drfed-server', 'drfed-web', 'drfed-migrate', 'drfed-account') {
322
+ & $command completion pwsh | Set-Content -Encoding utf8 "$command-completion.ps1"
323
+ . "./$command-completion.ps1"
324
+ }
325
+ ~~~~
326
+
327
+ For persistent loading, dot-source all four files by absolute path in the
328
+ current user's PowerShell profile, whose path is shown by `$PROFILE`.
329
+ PowerShell profile loading applies on Windows too; UNIX completion
330
+ directories do not configure it.
331
+
332
+ ### Nushell
333
+
334
+ First generate the scripts:
335
+
336
+ ~~~~ nu
337
+ for command in [drfed-server drfed-web drfed-migrate drfed-account] {
338
+ ^$command completion nu | save --force $"($command)-completion.nu"
339
+ }
340
+ ~~~~
341
+
342
+ Then load them as separate commands, after the files exist:
343
+
344
+ ~~~~ nu
345
+ source ./drfed-server-completion.nu
346
+ source ./drfed-web-completion.nu
347
+ source ./drfed-migrate-completion.nu
348
+ source ./drfed-account-completion.nu
349
+ ~~~~
350
+
351
+ For persistent loading, add these four `source` statements with absolute
352
+ paths to the configuration file shown by `$nu.config-path`. The scripts
353
+ chain their external completers so all four commands remain registered.
354
+ Nushell 0.114.1 emits a deprecation warning for Optique 1.3.0's generated
355
+ `str downcase` calls; the calls still work in that version.
356
+
357
+
358
+ Testing npm installation
359
+ ------------------------
360
+
361
+ From the repository root, run `mise run test:packaging` to build and pack the
362
+ five packages, then install their tarballs with npm in temporary local
363
+ and global prefixes outside the checkout. The check uses a separate npm cache
364
+ and empty npm configuration files, omits development dependencies, and disables
365
+ installation scripts. It needs network access to the public npm registry for
366
+ external dependencies.
367
+
368
+ The check verifies packed entry points, migrations and all 20 completion
369
+ scripts. It exercises script generation and runtime suggestions for all five
370
+ shell protocols through the installed binaries, including account subcommands
371
+ and mail choices. It also checks npm's bin links and help for all four
372
+ commands, standalone migration and account creation, a
373
+ database-backed GraphQL request after initial migration, and a restart with
374
+ `--no-migrate` using the same PGlite directory. It removes
375
+ the temporary installations and databases after stopping their servers.
376
+
377
+ All five tarballs are supplied to each install together so unpublished
378
+ workspace versions can be tested. The check covers combined and standalone
379
+ frontend SSR, assets, login confirmation and session cookies. It does not cover
380
+ installing only the facade from the registry or upgrading an older release.
381
+ It does not publish anything to npm.
382
+
383
+
384
+ Resource ownership
385
+ ------------------
386
+
387
+ Server startup registers each resource as it is acquired. Startup failures and
388
+ shutdown stop new work, drain active requests, GraphQL resolvers and the task
389
+ worker, then close
390
+ owned resources in reverse order. Cleanup continues if one resource fails;
391
+ startup errors retain their original cause. SIGTERM allows ten seconds for
392
+ shutdown and force-closes stalled HTTP connections after five seconds.
393
+
394
+ The `@drfed/drfed/resources` and `@drfed/drfed/operations` subpaths export
395
+ `ResourceOwner` and `OperationRegistry` for code that manages its own runtime.
396
+ Register borrowed resources with `owned: false`; the owner leaves them open.
397
+ Operations receive a shared abort signal and remain tracked until their
398
+ promises settle. HTTP response streams in the CLI remain drained by srvx.
399
+
400
+ The CLI also tracks GraphQL context loading and field/type resolvers separately
401
+ from the HTTP handler. [Yoga execution cancellation] stops further execution
402
+ when a client disconnects, but a resolver already waiting on a database or mail
403
+ operation can still be running. Its resources remain open until it settles.
404
+
405
+ Use `run()` to admit new work and `track()` only for continuations of requests
406
+ already accepted. Stop admitting requests and stop background producers before
407
+ calling `drain()`. Draining also waits for continuations registered during
408
+ shutdown, so an accepted GraphQL response can finish during the grace period.
409
+
410
+ [Yoga execution cancellation]: https://the-guild.dev/graphql/yoga-server/docs/features/execution-cancellation
411
+
412
+
413
+ Shared configuration bindings
414
+ -----------------------------
415
+
416
+ `@drfed/drfed/configuration` supplies the common setting registry, strict TOML
417
+ structure, and isolated [Optique environment] and [configuration] contexts.
418
+ Bindings preserve `CLI > DRFED_* > TOML > default`, including `false` and
419
+ empty arrays. Array sources replace each other. Each result carries its source
420
+ and, for TOML values, the absolute configuration file path; provenance maps
421
+ contain no setting values.
422
+
423
+ Commands must check required values after resolution. An absent optional
424
+ setting has a default-sourced result whose `value` is `undefined`; wrapping
425
+ a binding in `optional()` can hide invalid environment values and should be
426
+ avoided. Bind only the settings a command consumes: the entire TOML file is
427
+ checked for unknown keys and wrong types, while unused environment values
428
+ remain unread. `configurationPath()` resolves CLI and environment paths
429
+ against the supplied working directory and TOML paths against the file's
430
+ directory. The loader reads only an explicitly selected file and fails if
431
+ that file is missing. It neither searches for configuration nor loads *.env*.
432
+
433
+ The server CLI uses these bindings. Set `DRFED_CONFIG` or pass `--config`
434
+ to select one TOML file; explicit CLI settings take priority over environment
435
+ variables and that file. Help and version requests do not read operational
436
+ configuration. Schema output does not read the TOML file.
437
+
438
+ ~~~~ toml
439
+ [server]
440
+ root_origin = "https://drfed.example.com"
441
+ listen = "localhost:8888"
442
+ login_origins = ["https://drfed.example.com"]
443
+
444
+ [database]
445
+ data_path = "data"
446
+ migrate = true
447
+
448
+ [mail]
449
+ transport = "logtape"
450
+
451
+ [telemetry]
452
+ log_level = "info"
453
+ ~~~~
454
+
455
+ ~~~~ sh
456
+ drfed-server --config /etc/drfed/drfed.toml
457
+ DRFED_CONFIG=/etc/drfed/drfed.toml drfed-server --no-migrate
458
+ DRFED_LOGIN_ORIGINS='["https://frontend.example.com"]' \
459
+ drfed-server --config /etc/drfed/drfed.toml
460
+ ~~~~
461
+
462
+ The example stores PGlite data at */etc/drfed/data*, relative to the file.
463
+ Environment and CLI paths are relative to the command's working directory.
464
+ When no database selector is given, PGlite uses a persistent OS data directory:
465
+ *~/Library/Application Support/DrFed/data* on macOS,
466
+ *$XDG\_DATA\_HOME/drfed/data* (or *~/.local/share/drfed/data*) on Linux, and
467
+ *%LOCALAPPDATA%/DrFed/data* (or *%USERPROFILE%/AppData/Local/DrFed/data*) on
468
+ Windows. Relative OS environment paths are ignored. Override the location
469
+ with `--data-path`; selecting PostgreSQL still requires its URL.
470
+
471
+ | Setting | Environment variable | TOML |
472
+ | --------------------------------------------------------- | ------------------------------- | --------------------------------- |
473
+ | Root origin | `DRFED_ROOT_ORIGIN` | `server.root_origin` |
474
+ | Listen address | `DRFED_LISTEN` | `server.listen` |
475
+ | Login origin array | `DRFED_LOGIN_ORIGINS` | `server.login_origins` |
476
+ | PGlite path | `DRFED_DATA_PATH` | `database.data_path` |
477
+ | PostgreSQL URL | `DRFED_POSTGRES_URL` | `database.url` |
478
+ | Migration lock wait | `DRFED_MIGRATION_LOCK_TIMEOUT` | `database.lock_timeout_ms` |
479
+ | Automatic migrations | `DRFED_MIGRATE` | `database.migrate` |
480
+ | Mail sender | `DRFED_EMAIL_FROM` | `mail.from` |
481
+ | Mail transport | `DRFED_MAIL_TRANSPORT` | `mail.transport` |
482
+ | SMTP URL | `DRFED_SMTP_URL` | `mail.smtp.url` |
483
+ | Mail content logging | `DRFED_MAIL_LOG_CONTENT` | `mail.log_content` |
484
+ | SMTP server hostname | `DRFED_SMTP_HOST` | `mail.smtp.host` |
485
+ | SMTP server port | `DRFED_SMTP_PORT` | `mail.smtp.port` |
486
+ | SMTP TLS mode: direct, starttls-required or opportunistic | `DRFED_SMTP_TLS` | `mail.smtp.tls` |
487
+ | SMTP authentication username | `DRFED_SMTP_USER` | `mail.smtp.user` |
488
+ | SMTP authentication password | `DRFED_SMTP_PASSWORD` | `mail.smtp.password` |
489
+ | File containing the SMTP password | `DRFED_SMTP_PASSWORD_FILE` | `mail.smtp.password_file` |
490
+ | SMTP authentication method | `DRFED_SMTP_AUTH_METHOD` | `mail.smtp.auth_method` |
491
+ | Static SMTP OAuth access token | `DRFED_SMTP_ACCESS_TOKEN` | `mail.smtp.access_token` |
492
+ | File containing the SMTP OAuth access token | `DRFED_SMTP_ACCESS_TOKEN_FILE` | `mail.smtp.access_token_file` |
493
+ | SMTP connection timeout in milliseconds | `DRFED_SMTP_CONNECTION_TIMEOUT` | `mail.smtp.connection_timeout_ms` |
494
+ | SMTP socket timeout in milliseconds | `DRFED_SMTP_SOCKET_TIMEOUT` | `mail.smtp.socket_timeout_ms` |
495
+ | Maximum owned SMTP connections | `DRFED_SMTP_POOL_SIZE` | `mail.smtp.pool_size` |
496
+ | Local name for SMTP EHLO | `DRFED_SMTP_LOCAL_NAME` | `mail.smtp.local_name` |
497
+ | File containing additional SMTP certificate authorities | `DRFED_SMTP_CA_FILE` | `mail.smtp.ca_file` |
498
+ | File containing the SMTP client certificate | `DRFED_SMTP_CERT_FILE` | `mail.smtp.cert_file` |
499
+ | File containing the SMTP client private key | `DRFED_SMTP_KEY_FILE` | `mail.smtp.key_file` |
500
+ | Log level | `DRFED_LOG_LEVEL` | `telemetry.log_level` |
501
+ | Log formatter | `DRFED_LOG_FORMAT` | `telemetry.log_format` |
502
+ | Log output | `DRFED_LOG_OUTPUT` | `telemetry.log_output` |
503
+
504
+ A PGlite path and PostgreSQL URL are mutually exclusive at the highest
505
+ configuration source. A CLI PostgreSQL URL replaces a TOML PGlite path, and a
506
+ CLI PGlite path replaces a TOML PostgreSQL URL. With neither selector, DrFed
507
+ uses PGlite in the OS data location. Foreign lower-source fields are removed
508
+ before domain validation. The inferred kind and source appear as
509
+ `database.driver` in `--print-config`; it is not a configuration input.
510
+
511
+ The mail transport follows the same precedence: an SMTP URL or `--smtp-host`
512
+ selects `smtp`, and a higher-source `--mail-transport logtape` disables
513
+ configured SMTP settings. SMTP URLs accept `smtp://` (port 587 by default) and
514
+ `smtps://` (implicit TLS, port 465 by default). URL credentials are
515
+ percent-decoded. A URL and separate host/port/TLS or credentials at the same
516
+ source cannot specify the same component twice. Higher-source fields replace
517
+ individual lower URL components; for example, a CLI password file replaces the
518
+ TOML URL password while keeping its host and port.
519
+
520
+ With separate SMTP fields, TLS defaults to `starttls-required`. `direct` uses
521
+ implicit TLS, and `opportunistic` upgrades only when supported. Authenticated
522
+ `smtp://` URLs require STARTTLS even when it is not advertised; explicitly
523
+ choosing opportunistic TLS with authentication is rejected. Certificates are
524
+ verified and TLS 1.2 or newer is required. Connection and socket timeouts
525
+ default to 30 seconds, with at most five owned SMTP connections.
526
+
527
+ Password authentication supports `plain` and `login`. Static OAuth
528
+ access tokens support `xoauth2` and `oauthbearer`; dynamic token callbacks are
529
+ library APIs rather than CLI settings. For password authentication, usernames
530
+ and passwords must currently be printable ASCII because Upyo 0.6.0 does not
531
+ encode Unicode password credentials as UTF-8. Non-root URL paths, query
532
+ parameters and fragments are rejected before runtime resources are created.
533
+
534
+ ~~~~ toml
535
+ [mail]
536
+ transport = "smtp"
537
+ from = "noreply@drfed.example"
538
+
539
+ [mail.smtp]
540
+ host = "smtp.example"
541
+ port = 587
542
+ tls = "starttls-required"
543
+ user = "operator"
544
+ password_file = "secrets/smtp-password"
545
+ connection_timeout_ms = 30000
546
+ socket_timeout_ms = 30000
547
+ pool_size = 5
548
+ ~~~~
549
+
550
+ Literal credentials and credential files are variants of one setting: a higher
551
+ source wins, while both at the same source are an error. Only files named by
552
+ the effective configuration are read, after configuration diagnostics and
553
+ before database preparation. Relative TOML paths use the configuration
554
+ directory; CLI/env paths use the working directory. Files must be regular UTF-8
555
+ files of at most 64 KiB; projected secret symlinks are supported. Exactly one
556
+ final LF or CRLF is removed, preserving spaces and any additional newline. File
557
+ paths and contents do not appear in credential read errors or `--print-config`
558
+ output.
559
+
560
+ `ca_file` adds certificate authorities to Node's default roots. For mutual TLS,
561
+ configure both `cert_file` and `key_file`; the files contain PEM certificates
562
+ and an unencrypted PEM private key. Certificate verification cannot be disabled.
563
+ See the [Upyo SMTP documentation] for the underlying transport.
564
+
565
+ `--migrate` and `--no-migrate` explicitly override the selected migration
566
+ policy.
567
+
568
+ `@drfed/drfed/database-settings` exposes `resolveDatabaseSettings()` for the
569
+ same database selection contract, returning plain runtime settings and
570
+ source-only metadata for ignored fields.
571
+
572
+ [Optique environment]: https://optique.dev/integrations/env.md
573
+ [configuration]: https://optique.dev/integrations/config.md
574
+ [Upyo SMTP documentation]: https://upyo.org/transports/smtp
575
+
576
+
577
+ JMAP mail
578
+ ---------
579
+
580
+ Use [Upyo JMAP] with bearer authentication or basic authentication. A session
581
+ URL selects JMAP at that source; an explicit `--mail-transport jmap` also
582
+ selects it. Conflicting transport selectors at the same source are rejected.
583
+ Higher sources can switch transports without reading the previous transport's
584
+ credential files.
585
+
586
+ ~~~~ toml
587
+ [mail]
588
+ transport = "jmap"
589
+
590
+ [mail.jmap]
591
+ session_url = "https://mail.example.com/.well-known/jmap"
592
+ bearer_token_file = "/run/secrets/jmap-token"
593
+ ~~~~
594
+
595
+ Set `user` and `password_file` instead of `bearer_token_file` for basic
596
+ authentication. Basic credentials must be printable ASCII because the pinned
597
+ Upyo SDK does not encode non-ASCII credentials as UTF-8. The username cannot
598
+ contain a colon. Literal and file credentials use the same source precedence
599
+ and file rules as [SMTP](#shared-configuration-bindings); bearer and basic
600
+ credentials at the same source are rejected. Secret values and paths are
601
+ redacted from `--print-config`.
602
+
603
+ | CLI option | Environment variable | TOML field |
604
+ | -------------------------- | ------------------------------ | -------------------------------- |
605
+ | `--jmap-session-url` | `DRFED_JMAP_SESSION_URL` | `mail.jmap.session_url` |
606
+ | `--jmap-bearer-token` | `DRFED_JMAP_BEARER_TOKEN` | `mail.jmap.bearer_token` |
607
+ | `--jmap-bearer-token-file` | `DRFED_JMAP_BEARER_TOKEN_FILE` | `mail.jmap.bearer_token_file` |
608
+ | `--jmap-user` | `DRFED_JMAP_USER` | `mail.jmap.user` |
609
+ | `--jmap-password` | `DRFED_JMAP_PASSWORD` | `mail.jmap.password` |
610
+ | `--jmap-password-file` | `DRFED_JMAP_PASSWORD_FILE` | `mail.jmap.password_file` |
611
+ | `--jmap-account-id` | `DRFED_JMAP_ACCOUNT_ID` | `mail.jmap.account_id` |
612
+ | `--jmap-identity-id` | `DRFED_JMAP_IDENTITY_ID` | `mail.jmap.identity_id` |
613
+ | `--jmap-base-url` | `DRFED_JMAP_BASE_URL` | `mail.jmap.base_url` |
614
+ | `--jmap-timeout` | `DRFED_JMAP_TIMEOUT` | `mail.jmap.timeout_ms` |
615
+ | `--jmap-session-cache-ttl` | `DRFED_JMAP_SESSION_CACHE_TTL` | `mail.jmap.session_cache_ttl_ms` |
616
+
617
+ Session and base URLs require HTTPS, except HTTP on `localhost`, `127.0.0.1`,
618
+ or `[::1]` for local testing. URL credentials and fragments are rejected.
619
+ `base_url` is an origin used to rewrite endpoints discovered from the session,
620
+ useful when the mail server advertises internal host names. Without
621
+ `account_id` and `identity_id`, Upyo discovers a mail account and selects the
622
+ identity matching the sender address.
623
+
624
+ Duration options and their environment variables take milliseconds, matching
625
+ the TOML fields.
626
+
627
+ The whole delivery timeout defaults to 30 seconds, and session cache lifetime
628
+ to five minutes. Automatic JMAP retries are disabled because the pinned SDK
629
+ can replay a mail submission after an uncertain response. These settings apply
630
+ only when JMAP is selected. Cancelling a request aborts the in-flight JMAP
631
+ call. Delivery failures return the same opaque login response and produce the
632
+ same mail outcome log entries as SMTP.
633
+
634
+ [Upyo JMAP]: https://upyo.org/transports/jmap
635
+
636
+
637
+ Lettermint mail
638
+ ---------------
639
+
640
+ Set `transport = "lettermint"` under `[mail]` and supply a sending API token:
641
+
642
+ ~~~~ toml
643
+ [mail]
644
+ transport = "lettermint"
645
+
646
+ [mail.lettermint]
647
+ api_token_file = "/run/secrets/lettermint-token"
648
+ route = "transactional"
649
+ ~~~~
650
+
651
+ The optional `route` selects a route configured in Lettermint; omit it to leave
652
+ route selection to the service. Delivery uses [Upyo Lettermint].
653
+
654
+ You can use the common API credential options instead of the Lettermint-specific
655
+ ones. For example, `--mail-api-key-file /run/secrets/lettermint-token` overrides
656
+ a Lettermint token from a lower-priority source. Of the four credential settings
657
+ (common or Lettermint, literal or file), only the highest-priority source is
658
+ used. Supplying more than one at that source is rejected. See the [shared
659
+ configuration](#shared-configuration-bindings) for the source order and secret
660
+ file rules. Only the selected file is read. Values and paths are redacted from
661
+ `--print-config`.
662
+
663
+ | CLI option | Environment variable | TOML field |
664
+ | ----------------------------- | --------------------------------- | -------------------------------- |
665
+ | `--mail-api-key` | `DRFED_MAIL_API_KEY` | `mail.api_key` |
666
+ | `--mail-api-key-file` | `DRFED_MAIL_API_KEY_FILE` | `mail.api_key_file` |
667
+ | `--lettermint-api-token` | `DRFED_LETTERMINT_API_TOKEN` | `mail.lettermint.api_token` |
668
+ | `--lettermint-api-token-file` | `DRFED_LETTERMINT_API_TOKEN_FILE` | `mail.lettermint.api_token_file` |
669
+ | `--lettermint-base-url` | `DRFED_LETTERMINT_BASE_URL` | `mail.lettermint.base_url` |
670
+ | `--lettermint-route` | `DRFED_LETTERMINT_ROUTE` | `mail.lettermint.route` |
671
+ | `--lettermint-timeout` | `DRFED_LETTERMINT_TIMEOUT` | `mail.lettermint.timeout_ms` |
672
+ | `--lettermint-retries` | `DRFED_LETTERMINT_RETRIES` | `mail.lettermint.retries` |
673
+
674
+ The base URL defaults to `https://api.lettermint.co` and must be a bare origin:
675
+ HTTPS, or HTTP on loopback for local testing, with no credentials, path, query,
676
+ or fragment. All timeout forms take milliseconds. The whole delivery timeout
677
+ defaults to 30,000 milliseconds, including response bodies and retry delays.
678
+ When that deadline expires, DrFed reports a delivery failure and does not
679
+ automatically resend.
680
+
681
+ After the first attempt, up to three retries are made by default, with a
682
+ maximum of ten. Upyo generates one idempotency key per delivery and reuses it
683
+ across retries. A permanently rejected request is not retried. Cancelling a
684
+ delivery or shutting the transport down aborts in-flight requests.
685
+
686
+ [Upyo Lettermint]: https://upyo.org/transports/lettermint
687
+
688
+
689
+ Configuration diagnostics
690
+ -------------------------
691
+
692
+ `drfed-server --config drfed.toml --print-config` prints JSON containing the
693
+ selected settings and their sources without opening the database, mail
694
+ transport or log file. PostgreSQL and SMTP URLs are printed as `<redacted>`.
695
+ Database and mail selectors report the source that selected the effective kind;
696
+ ignored database fields and the unused web area are listed separately.
697
+ Invalid active settings still fail rather than falling back to another source.
698
+
699
+ Help, version and GraphQL schema output ignore operational environment values
700
+ and do not read the TOML file. Schema generation still accepts the historical
701
+ logging options, but ignores them and does not create a log file.
702
+
703
+
704
+ Database startup and updates
705
+ ----------------------------
706
+
707
+ The server verifies bundled migration hashes and the database history before
708
+ starting workers or accepting HTTP requests. Automatic migration applies only
709
+ an exact known prefix, upgrades supported legacy metadata and requires ready
710
+ history afterward. Modified, diverged, newer or unsupported histories fail
711
+ without applying migration SQL. Restore or reconcile these histories after
712
+ reviewing your backup; changing hashes to silence the check is unsafe.
713
+
714
+ `--no-migrate` inspects history without applying SQL or upgrading metadata. It
715
+ starts only when history is exactly ready; fresh, pending and legacy databases
716
+ must first be prepared with automatic migration enabled. Opening a fresh
717
+ PGlite directory still initializes PGlite's own database files and catalog.
718
+
719
+ A persistent PGlite directory is exclusively owned for the lifetime of the
720
+ server. A second process fails immediately, including through a symlink alias.
721
+ The stable *.drfed.lock* file remains after shutdown and must not be deleted
722
+ to work around an ownership error. Process exit releases the native lock.
723
+
724
+ PostgreSQL migration uses a separate session, verifies history under its
725
+ advisory lock and closes that session before creating the runtime connection
726
+ pool. `--migration-lock-timeout 30000` sets the connection and lock acquisition
727
+ limit in milliseconds, through the same CLI/environment/TOML precedence. It
728
+ does not time out SQL already applying under the lock.
729
+ The timeout ranges from 1 to 2,147,483,647; the default is 30,000. It does not
730
+ change PGlite's immediate ownership conflict behavior.
731
+
732
+ PostgreSQL URLs must name one TCP host, a user and a database. Supported query
733
+ parameters are `sslmode`, `search_path` and `application_name`; duplicate or
734
+ unsupported parameters are rejected before connecting. The default TLS mode
735
+ is `disable`, intended for local connections or a separately secured network.
736
+ Use `sslmode=verify-full` for remote connections: both migration and runtime
737
+ connections verify the certificate chain and host name using Node.js's trust
738
+ store. Set Node.js's `NODE_EXTRA_CA_CERTS` before starting DrFed when a private
739
+ CA is required; see [Node.js's CA configuration]. Modes that allow plaintext
740
+ fallback or disable certificate verification, direct TLS negotiation and
741
+ multi-host URLs are not supported.
742
+
743
+ Both connections use the same `search_path` (default `public`) and
744
+ `application_name` (default `drfed`). The migration session passes `search_path`
745
+ through escaped PostgreSQL startup options, preserving quoted identifiers.
746
+
747
+ [Node.js's CA configuration]: https://nodejs.org/api/cli.html#node_extra_ca_certsfile
748
+
749
+
750
+ Database preparation command
751
+ ----------------------------
752
+
753
+ Use `drfed-migrate` to prepare a database without starting the server, mail,
754
+ federation workers or web frontend. It uses the same `--config` TOML file,
755
+ `DRFED_CONFIG`, database options and environment variables as `drfed-server`;
756
+ server origins and mail settings are unnecessary for this command.
757
+
758
+ ~~~~ sh
759
+ drfed-migrate --config /etc/drfed/drfed.toml --check
760
+ drfed-migrate --config /etc/drfed/drfed.toml
761
+ drfed-server --config /etc/drfed/drfed.toml --no-migrate
762
+ ~~~~
763
+
764
+ The default invocation explicitly applies migrations even when the shared file
765
+ sets `database.migrate = false` or `DRFED_MIGRATE` disables server migration.
766
+ `--no-migrate` is a server option; use `--check` for database inspection.
767
+
768
+ `--check` inspects migration history without applying DrFed SQL or upgrading
769
+ legacy metadata. It exits 0 only when the database is ready, and exits 1 when
770
+ preparation is needed, history is incompatible or inspection fails. Both modes
771
+ print JSON with `status`, `format`, `applied` and `pending` on stdout;
772
+ operational errors go to stderr. `--print-config` prints redacted effective
773
+ settings and provenance without opening the database.
774
+
775
+ PGlite uses the same default persistent directory and native ownership lock as
776
+ the server. Stop a PGlite server before running either migration mode.
777
+ Inspecting a fresh directory creates PGlite's own database files and system
778
+ catalog, although it creates no DrFed tables or migration history. PostgreSQL
779
+ `--check` uses the current command's read privileges and needs no schema-change
780
+ grants.
781
+
782
+ Before updating, back up the database and stop running DrFed processes. Install
783
+ the new package, run `drfed-migrate` and verify `drfed-migrate --check`, then
784
+ start the server. Automatic migration at server startup is also available. Use
785
+ `--no-migrate` for later starts that should only inspect already prepared
786
+ history. Keep your backup until you have verified the update.
787
+
788
+
789
+ Initial account creation
790
+ ------------------------
791
+
792
+ Create a local account before signing in; installed deployments do not need the
793
+ development seed. Use the same shared configuration or database options:
794
+
795
+ ~~~~ sh
796
+ drfed-account create --config /etc/drfed/drfed.toml \
797
+ --email operator@example.com --name Operator
798
+ ~~~~
799
+
800
+ The command prepares a fresh database by default. `database.migrate = false`,
801
+ `DRFED_MIGRATE=false` or `--no-migrate` requires ready history instead; use
802
+ `--migrate` to override a lower-source disabled setting. PGlite ownership is
803
+ shared with the server, so stop a PGlite server before account creation.
804
+
805
+ Account creation grants no administrator privileges and creates no login
806
+ session. Repeat creation for the same normalized email to obtain the existing
807
+ account; its name and privileges are preserved. Email domain normalization
808
+ matches login. Display names are trimmed and accept 1 to 100 Unicode characters.
809
+ Invalid input is rejected before opening the database.
810
+
811
+ The command prints JSON with `status` (`created` or `exists`) and the stored
812
+ account identity. Both outcomes exit 0; configuration, preparation, ownership,
813
+ write and cleanup failures exit 1. Interruption also exits 1 after draining
814
+ admitted work; an in-flight write may complete, and retrying preserves an
815
+ account that was already created. `--print-config` shows redacted database
816
+ settings without acquiring resources. Server/mail settings are unused.
817
+
818
+
819
+ Maileroo mail
820
+ -------------
821
+
822
+ Set the mail transport to `maileroo` and provide a sending key for a verified
823
+ Maileroo domain. Use the common `--mail-api-key`/`--mail-api-key-file` options
824
+ or the Maileroo-specific options below. CLI values take precedence over
825
+ environment variables, then TOML. At the highest source level that provides
826
+ a key, exactly one of `--mail-api-key`, `--mail-api-key-file`,
827
+ `--maileroo-api-key`, or `--maileroo-api-key-file` may be present. Lower sources
828
+ are ignored before validation or file access.
829
+
830
+ | CLI option | Environment variable | TOML setting |
831
+ | ------------------------- | ----------------------------- | ---------------------------- |
832
+ | `--maileroo-api-key` | `DRFED_MAILEROO_API_KEY` | `mail.maileroo.api_key` |
833
+ | `--maileroo-api-key-file` | `DRFED_MAILEROO_API_KEY_FILE` | `mail.maileroo.api_key_file` |
834
+ | `--maileroo-base-url` | `DRFED_MAILEROO_BASE_URL` | `mail.maileroo.base_url` |
835
+ | `--maileroo-timeout` | `DRFED_MAILEROO_TIMEOUT` | `mail.maileroo.timeout_ms` |
836
+
837
+ ~~~~ toml
838
+ [mail]
839
+ transport = "maileroo"
840
+
841
+ [mail.maileroo]
842
+ api_key_file = "/run/secrets/maileroo"
843
+ ~~~~
844
+
845
+ The default API URL is `https://smtp.maileroo.com/api/v2`. An override replaces
846
+ this URL; Upyo appends `/emails` after removing trailing slashes. It must use
847
+ HTTPS or local loopback HTTP, without credentials, a query or a fragment.
848
+ The timeout covers the whole delivery, including the response body. Values
849
+ use milliseconds in all three sources and default to 30,000.
850
+ Timeouts must be positive and at most 2,147,483,647 milliseconds.
851
+
852
+ DrFed disables retries in Upyo's Maileroo transport. Maileroo's reference ID
853
+ is a tracking identifier;
854
+ it does not establish that resending an uncertain submission is safe. If the
855
+ response is lost or a request times out, DrFed cannot tell whether Maileroo
856
+ accepted the message. Login produces the same response as other mail failures,
857
+ and DrFed does not automatically resend the message. See the
858
+ [Upyo Maileroo documentation] and [Maileroo reference ID documentation].
859
+
860
+ [Upyo Maileroo documentation]: https://upyo.org/transports/maileroo
861
+ [Maileroo reference ID documentation]: https://maileroo.com/docs/smtp-relay/advanced-message-options
862
+
863
+
864
+ Mailtrap mail
865
+ -------------
866
+
867
+ Set `mail.transport = "mailtrap"` to use [Upyo Mailtrap]. Provide a sending
868
+ API token through the shared API key or key file options, or through the
869
+ Mailtrap-specific token or token file options. CLI values take precedence over
870
+ environment variables, which take precedence over TOML. At the highest source
871
+ level that supplies a credential, exactly one representation may be present.
872
+ Credential files from lower sources or other providers are not opened.
873
+
874
+ ~~~~ toml
875
+ [mail]
876
+ transport = "mailtrap"
877
+
878
+ [mail.mailtrap]
879
+ api_token_file = "/run/secrets/mailtrap"
880
+ sandbox = true
881
+ inbox_id = "12345"
882
+ ~~~~
883
+
884
+ Sandbox mode captures messages in a test inbox rather than delivering them
885
+ to recipients. It requires a positive decimal inbox ID no greater than
886
+ 9,007,199,254,740,991. Production delivery is the default; an inbox ID alone
887
+ does not enable sandbox mode. Use `--mailtrap-sandbox` to enable it or
888
+ `--no-mailtrap-sandbox` to disable it when a lower source enabled it.
889
+
890
+ | CLI option | Environment variable | TOML setting |
891
+ | ---------------------------------------------- | --------------------------------- | -------------------------------- |
892
+ | `--mailtrap-api-token` | `DRFED_MAILTRAP_API_TOKEN` | `mail.mailtrap.api_token` |
893
+ | `--mailtrap-api-token-file` | `DRFED_MAILTRAP_API_TOKEN_FILE` | `mail.mailtrap.api_token_file` |
894
+ | `--mailtrap-sandbox` / `--no-mailtrap-sandbox` | `DRFED_MAILTRAP_SANDBOX` | `mail.mailtrap.sandbox` |
895
+ | `--mailtrap-inbox-id` | `DRFED_MAILTRAP_INBOX_ID` | `mail.mailtrap.inbox_id` |
896
+ | `--mailtrap-send-base-url` | `DRFED_MAILTRAP_SEND_BASE_URL` | `mail.mailtrap.send_base_url` |
897
+ | `--mailtrap-sandbox-base-url` | `DRFED_MAILTRAP_SANDBOX_BASE_URL` | `mail.mailtrap.sandbox_base_url` |
898
+ | `--mailtrap-timeout` | `DRFED_MAILTRAP_TIMEOUT` | `mail.mailtrap.timeout_ms` |
899
+
900
+ The production API defaults to `https://send.api.mailtrap.io`; the sandbox
901
+ API defaults to `https://sandbox.api.mailtrap.io`. Only the selected mode's
902
+ endpoint is validated and used. Overrides must use HTTPS or HTTP to a loopback
903
+ address and must not contain credentials, a query or a fragment. Upyo appends
904
+ `/api/send` for production or `/api/send/{inbox_id}` for the sandbox.
905
+ Certificate verification remains enabled.
906
+
907
+ The timeout covers the whole delivery, including reading the response body,
908
+ and defaults to 30,000 milliseconds. All input sources use milliseconds; values
909
+ must be positive and at most 2,147,483,647. DrFed disables Upyo's Mailtrap
910
+ retries because an uncertain API response can leave acceptance unknown, making
911
+ automatic resubmission risk duplicate mail. Cancellation and shutdown abort
912
+ active sends and wait for them to settle.
913
+
914
+ [Upyo Mailtrap]: https://upyo.org/transports/mailtrap
915
+
916
+
917
+ Mailgun mail
918
+ ------------
919
+
920
+ Set the mail transport to `mailgun` and provide a verified sending domain and
921
+ API key. Use the shared `--mail-api-key`/`--mail-api-key-file` options
922
+ or the Mailgun-specific options below. CLI values take precedence over
923
+ environment variables, which take precedence over TOML. At the highest source
924
+ level that supplies a credential, set exactly one of these four key or key-file
925
+ options. Credential files from lower-priority sources or other providers are
926
+ not opened.
927
+
928
+ ~~~~ toml
929
+ [mail]
930
+ transport = "mailgun"
931
+ from = "noreply@mg.example.com"
932
+
933
+ [mail.mailgun]
934
+ api_key_file = "/run/secrets/mailgun"
935
+ domain = "mg.example.com"
936
+ region = "eu"
937
+ ~~~~
938
+
939
+ | CLI option | Environment variable | TOML setting |
940
+ | ------------------------ | ---------------------------- | --------------------------- |
941
+ | `--mailgun-api-key` | `DRFED_MAILGUN_API_KEY` | `mail.mailgun.api_key` |
942
+ | `--mailgun-api-key-file` | `DRFED_MAILGUN_API_KEY_FILE` | `mail.mailgun.api_key_file` |
943
+ | `--mailgun-domain` | `DRFED_MAILGUN_DOMAIN` | `mail.mailgun.domain` |
944
+ | `--mailgun-region` | `DRFED_MAILGUN_REGION` | `mail.mailgun.region` |
945
+ | `--mailgun-base-url` | `DRFED_MAILGUN_BASE_URL` | `mail.mailgun.base_url` |
946
+ | `--mailgun-timeout` | `DRFED_MAILGUN_TIMEOUT` | `mail.mailgun.timeout_ms` |
947
+
948
+ The domain, including an internationalized domain name, is normalized to
949
+ lowercase ASCII. It must be a DNS name without credentials, a port or a URL
950
+ path. The default `us` region uses `https://api.mailgun.net/v3`; `eu` uses
951
+ `https://api.eu.mailgun.net/v3`. A base URL override replaces that endpoint.
952
+ Overrides require HTTPS or local loopback HTTP, without credentials, a query or
953
+ a fragment. Upyo, DrFed's mail library, appends `/{domain}/messages` and sends
954
+ multipart form data.
955
+
956
+ DrFed disables per-message click and open tracking so login links go directly
957
+ to DrFed. These settings override the domain's tracking defaults. DrFed
958
+ disables Upyo's automatic retries. A submission that times out may already have
959
+ been accepted, so retrying it could send the message twice. The timeout covers
960
+ the whole delivery, including reading the response body, and defaults to 30,000
961
+ milliseconds. CLI options, environment variables and TOML all use milliseconds;
962
+ values must be positive and at most 2,147,483,647. Certificate verification
963
+ remains enabled.
964
+
965
+ See [Upyo Mailgun],
966
+ [Mailgun sending options]
967
+ and [click tracking].
968
+
969
+ [Upyo Mailgun]: https://upyo.org/transports/mailgun
970
+ [Mailgun sending options]: https://documentation.mailgun.com/docs/mailgun/api-reference/send/mailgun/messages
971
+ [click tracking]: https://documentation.mailgun.com/docs/mailgun/user-manual/tracking-messages/tracking-clicks
972
+
973
+
974
+ Plunk mail
975
+ ----------
976
+
977
+ Set the mail transport to `plunk` and provide a sending API key through the
978
+ shared `--mail-api-key`/`--mail-api-key-file` options or the Plunk-specific
979
+ options below. CLI values take precedence over environment variables, which
980
+ take precedence over TOML. In the highest-precedence source that supplies a
981
+ credential, set exactly one of the key or key-file options. Credential files
982
+ from lower sources or other providers are not opened.
983
+
984
+ ~~~~ toml
985
+ [mail]
986
+ transport = "plunk"
987
+
988
+ [mail.plunk]
989
+ api_key_file = "/run/secrets/plunk"
990
+ base_url = "https://mail.example.com/api"
991
+ ~~~~
992
+
993
+ | CLI option | Environment variable | TOML setting |
994
+ | ---------------------- | -------------------------- | ------------------------- |
995
+ | `--plunk-api-key` | `DRFED_PLUNK_API_KEY` | `mail.plunk.api_key` |
996
+ | `--plunk-api-key-file` | `DRFED_PLUNK_API_KEY_FILE` | `mail.plunk.api_key_file` |
997
+ | `--plunk-base-url` | `DRFED_PLUNK_BASE_URL` | `mail.plunk.base_url` |
998
+ | `--plunk-timeout` | `DRFED_PLUNK_TIMEOUT` | `mail.plunk.timeout_ms` |
999
+
1000
+ The base URL defaults to the hosted API at `https://next-api.useplunk.com`. For
1001
+ a self-hosted server, override the base URL, including its API path if needed.
1002
+ Upyo appends `/v1/send`, so the example above sends to
1003
+ `https://mail.example.com/api/v1/send`. Overrides must use HTTPS, or HTTP only
1004
+ for a loopback address, and must not contain credentials, a query or a
1005
+ fragment. Certificate verification remains enabled.
1006
+
1007
+ DrFed disables Upyo's Plunk retries because an uncertain API response leaves
1008
+ acceptance unknown, and automatic resubmission could send duplicate mail. The
1009
+ timeout covers the whole delivery, including reading the response body, and
1010
+ defaults to 30,000 milliseconds. CLI options, environment variables and TOML
1011
+ all use milliseconds; values must be positive and at most 2,147,483,647.
1012
+ Cancellation and shutdown abort active sends and wait for them to settle.
1013
+
1014
+ See [Upyo Plunk] for transport details, including self-hosted servers.
1015
+
1016
+ [Upyo Plunk]: https://upyo.org/transports/plunk
1017
+
1018
+
1019
+ Resend mail
1020
+ -----------
1021
+
1022
+ Set the mail transport to `resend` and provide a sending API key through the
1023
+ shared `--mail-api-key`/`--mail-api-key-file` options or the Resend-specific
1024
+ options below. CLI values take precedence over environment variables, which
1025
+ take precedence over TOML. In the highest-precedence source that supplies a
1026
+ credential, set exactly one key or key-file option. Credential files from
1027
+ lower sources or other providers are not opened.
1028
+
1029
+ ~~~~ toml
1030
+ [mail]
1031
+ transport = "resend"
1032
+
1033
+ [mail.resend]
1034
+ api_key_file = "/run/secrets/resend"
1035
+ retries = 1
1036
+ ~~~~
1037
+
1038
+ | CLI option | Environment variable | TOML setting |
1039
+ | ----------------------- | --------------------------- | -------------------------- |
1040
+ | `--resend-api-key` | `DRFED_RESEND_API_KEY` | `mail.resend.api_key` |
1041
+ | `--resend-api-key-file` | `DRFED_RESEND_API_KEY_FILE` | `mail.resend.api_key_file` |
1042
+ | `--resend-base-url` | `DRFED_RESEND_BASE_URL` | `mail.resend.base_url` |
1043
+ | `--resend-timeout` | `DRFED_RESEND_TIMEOUT` | `mail.resend.timeout_ms` |
1044
+ | `--resend-retries` | `DRFED_RESEND_RETRIES` | `mail.resend.retries` |
1045
+
1046
+ The base URL defaults to `https://api.resend.com`. Upyo, the mail library DrFed
1047
+ uses, appends `/emails`. Overrides must use HTTPS. HTTP is accepted only for
1048
+ loopback addresses. Overrides must not contain credentials, a query or a
1049
+ fragment. Certificate verification remains enabled.
1050
+
1051
+ DrFed generates one idempotency key per delivery and sends it with every
1052
+ attempt. Resend uses this key to deduplicate submissions for 24 hours, allowing
1053
+ bounded retries after an uncertain response. DrFed uses Upyo's Retry wrapper,
1054
+ with cancellable delays, rather than the Resend SDK's internal retry loop.
1055
+ Retries default to three additional attempts and may be set from zero through
1056
+ ten. Only failures marked retryable are tried again. Each login email is its
1057
+ own delivery and receives its own key.
1058
+
1059
+ The timeout covers the whole delivery, including retry delays and reading the
1060
+ response body, and defaults to 30,000 milliseconds. CLI options, environment
1061
+ variables and TOML all use milliseconds; values must be positive and at most
1062
+ 2,147,483,647. Cancellation and shutdown abort active sends and wait for them
1063
+ to settle.
1064
+
1065
+ See [Upyo Resend] and [Resend idempotency keys].
1066
+
1067
+ [Upyo Resend]: https://upyo.org/transports/resend
1068
+ [Resend idempotency keys]: https://resend.com/docs/dashboard/emails/idempotency-keys
1069
+
1070
+
1071
+ SendGrid mail
1072
+ -------------
1073
+
1074
+ Set the mail transport to `sendgrid` and provide a sending API key through the
1075
+ shared `--mail-api-key`/`--mail-api-key-file` options or the SendGrid-specific
1076
+ options below. CLI values take precedence over environment variables, which
1077
+ take precedence over TOML. Credentials come from the highest-precedence source
1078
+ that supplies any of the four shared or SendGrid-specific key or key-file
1079
+ settings. That source must set exactly one; conflicting representations cause a
1080
+ startup error. Credential files from lower-precedence sources or other
1081
+ providers are not opened.
1082
+
1083
+ ~~~~ toml
1084
+ [mail]
1085
+ transport = "sendgrid"
1086
+
1087
+ [mail.sendgrid]
1088
+ api_key_file = "/run/secrets/sendgrid"
1089
+ ~~~~
1090
+
1091
+ | CLI option | Environment variable | TOML setting |
1092
+ | ------------------------- | ----------------------------- | ---------------------------- |
1093
+ | `--sendgrid-api-key` | `DRFED_SENDGRID_API_KEY` | `mail.sendgrid.api_key` |
1094
+ | `--sendgrid-api-key-file` | `DRFED_SENDGRID_API_KEY_FILE` | `mail.sendgrid.api_key_file` |
1095
+ | `--sendgrid-base-url` | `DRFED_SENDGRID_BASE_URL` | `mail.sendgrid.base_url` |
1096
+ | `--sendgrid-timeout` | `DRFED_SENDGRID_TIMEOUT` | `mail.sendgrid.timeout_ms` |
1097
+
1098
+ The base URL defaults to `https://api.sendgrid.com/v3`. Upyo, the mail library
1099
+ DrFed uses, appends `/mail/send` to the base URL. Overrides must use HTTPS,
1100
+ except that HTTP is accepted for loopback addresses. Overrides must not contain
1101
+ credentials, a query or a fragment. Certificate verification remains enabled.
1102
+
1103
+ DrFed disables Upyo's automatic SendGrid retries because when a response is
1104
+ lost or ambiguous, DrFed cannot tell whether SendGrid accepted the message, and
1105
+ a retry could send duplicate mail. Click, open, subscription and Google
1106
+ Analytics tracking are disabled in each message's tracking settings so login
1107
+ links go directly to DrFed.
1108
+
1109
+ The timeout covers the whole delivery, including reading the
1110
+ response body, and defaults to 30,000 milliseconds. CLI options, environment
1111
+ variables and TOML all use milliseconds; values must be positive and at most
1112
+ 2,147,483,647. Cancellation and shutdown abort active sends and wait for them
1113
+ to settle.
1114
+
1115
+ See [Upyo SendGrid] and [SendGrid sending options].
1116
+
1117
+ [Upyo SendGrid]: https://upyo.org/transports/sendgrid
1118
+ [SendGrid sending options]: https://www.twilio.com/docs/sendgrid/api-reference/mail-send/mail-send
1119
+
1120
+
1121
+ Amazon SES mail
1122
+ ---------------
1123
+
1124
+ Set the mail transport to `ses` and provide an AWS access key ID and secret
1125
+ access key. DrFed uses Upyo's SES API transport; these are AWS credentials,
1126
+ not SMTP credentials. Use the SES-specific settings below. The shared
1127
+ `--mail-api-key` settings belong to the other API providers and are ignored
1128
+ for SES. CLI values take precedence over environment variables, which take
1129
+ precedence over TOML. At the highest source level that supplies a credential,
1130
+ set its literal or file setting, not both. Credential files from lower sources
1131
+ or other providers are not opened.
1132
+
1133
+ ~~~~ toml
1134
+ [mail]
1135
+ transport = "ses"
1136
+
1137
+ [mail.ses]
1138
+ auth = "session"
1139
+ access_key_id_file = "/run/secrets/aws-access-key-id"
1140
+ secret_access_key_file = "/run/secrets/aws-secret-access-key"
1141
+ session_token_file = "/run/secrets/aws-session-token"
1142
+ region = "eu-west-1"
1143
+ ~~~~
1144
+
1145
+ | CLI option | Environment variable | TOML setting |
1146
+ | ------------------------------ | ---------------------------------- | --------------------------------- |
1147
+ | `--ses-auth` | `DRFED_SES_AUTH` | `mail.ses.auth` |
1148
+ | `--ses-access-key-id` | `DRFED_SES_ACCESS_KEY_ID` | `mail.ses.access_key_id` |
1149
+ | `--ses-access-key-id-file` | `DRFED_SES_ACCESS_KEY_ID_FILE` | `mail.ses.access_key_id_file` |
1150
+ | `--ses-secret-access-key` | `DRFED_SES_SECRET_ACCESS_KEY` | `mail.ses.secret_access_key` |
1151
+ | `--ses-secret-access-key-file` | `DRFED_SES_SECRET_ACCESS_KEY_FILE` | `mail.ses.secret_access_key_file` |
1152
+ | `--ses-session-token` | `DRFED_SES_SESSION_TOKEN` | `mail.ses.session_token` |
1153
+ | `--ses-session-token-file` | `DRFED_SES_SESSION_TOKEN_FILE` | `mail.ses.session_token_file` |
1154
+ | `--ses-region` | `DRFED_SES_REGION` | `mail.ses.region` |
1155
+ | `--ses-timeout` | `DRFED_SES_TIMEOUT` | `mail.ses.timeout_ms` |
1156
+
1157
+ Authentication defaults to `credentials`. A session token at a higher source
1158
+ level selects `session`; an explicit authentication setting at the same or a
1159
+ higher level wins. Session mode requires a token. Explicit `credentials` mode
1160
+ leaves unused token files unopened. Access key IDs must contain ASCII letters
1161
+ and digits; secret keys and session tokens must be nonempty printable ASCII
1162
+ without whitespace. Selected files are read once at startup, with the final
1163
+ LF or CRLF removed.
1164
+
1165
+ Upyo does not obtain IAM roles or refresh credentials. Obtain temporary
1166
+ credentials outside DrFed and restart with fresh settings when they change.
1167
+ DrFed reads the `DRFED_SES_*` variables above, not the AWS SDK's profile or
1168
+ credential-provider chain.
1169
+
1170
+ The region defaults to `us-east-1`. Upyo constructs the HTTPS endpoint
1171
+ `https://email.{region}.amazonaws.com/v2/email/outbound-emails` and signs
1172
+ requests with AWS SigV4. Regions must use an ASCII AWS region name. China,
1173
+ isolated and sovereign partitions that need another endpoint suffix are
1174
+ unsupported by this SDK. There is no custom endpoint option. Certificate
1175
+ verification remains enabled.
1176
+
1177
+ DrFed disables Upyo's SES retries because a lost response may leave message
1178
+ acceptance unknown, and an automatic retry could send duplicate mail. The
1179
+ timeout covers the whole delivery, including reading the response body, and
1180
+ defaults to 30,000 milliseconds. CLI options, environment variables and TOML
1181
+ all use milliseconds; values must be positive and at most 2,147,483,647.
1182
+ Cancellation and shutdown abort active sends and wait for them to settle.
1183
+
1184
+ See [Upyo SES] and [AWS SES endpoints].
1185
+
1186
+ [Upyo SES]: https://upyo.org/transports/ses
1187
+ [AWS SES endpoints]: https://docs.aws.amazon.com/general/latest/gr/ses.html
1188
+
1189
+
1190
+ Standalone backend security
1191
+ ---------------------------
1192
+
1193
+ `drfed-web` requires HTTPS for non-loopback backends because requests carry
1194
+ session tokens. HTTP is allowed for `localhost`, its subdomains, IPv4
1195
+ loopback addresses and `::1`. For a trusted internal network, explicitly use
1196
+ `--allow-insecure-backend`, `DRFED_ALLOW_INSECURE_BACKEND=true`, or
1197
+ `web.allow_insecure_backend = true` in TOML. This permits unencrypted session
1198
+ tokens and logs a warning at startup. `--no-allow-insecure-backend` overrides
1199
+ permission from the environment or configuration file.