Skip to content

Commit bf45750

Browse files
Move EXTRA_IDENTITIES from public config to secret for privacy
Relocate EXTRA_IDENTITIES from wrangler.jsonc vars to .dev.vars/.env secrets so email addresses stay out of the public repo. Update setup.mjs to read from env, add to SECRET_KEYS list, document in .dev.vars.example and README, mark optional in types.ts.
1 parent cc6826e commit bf45750

5 files changed

Lines changed: 23 additions & 10 deletions

File tree

‎.dev.vars.example‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,9 @@ UI_PASSWORD=change-me-strong-password
77

88
# HMAC key for signing session cookies (required; any long random string)
99
SESSION_SECRET=change-me-long-random-string
10+
11+
# Extra send/receive identities beyond PRIMARY_ADDRESS (optional).
12+
# Kept as a secret so your addresses stay out of this public repo.
13+
# Format: semicolon-separated "address=Display Name" pairs (name optional).
14+
# Each address gets an Email Routing rule -> the worker via scripts/setup.mjs.
15+
# EXTRA_IDENTITIES=alias@yourdomain.com=Alias Name;alias2@yourdomain.com

‎README.md‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,18 @@ Everything lives in **`wrangler.jsonc`** — worker, assets, D1, `send_email`, c
6262
| Var | Default | Meaning |
6363
| ------------------------- | --------------------- | ---------------------------------------- |
6464
| `MAIL_DOMAIN` | `devartslab.com` | Your domain |
65-
| `PRIMARY_ADDRESS` | `amir@devartslab.com` | Send/receive identity |
65+
| `PRIMARY_ADDRESS` | `amir@devartslab.com` | Primary send/receive identity |
6666
| `DISPLAY_NAME` | `Amir \| DevArts Lab` | From-name on outgoing mail |
6767
| `AUTO_ACCEPT_INVITES` | `"false"` | Auto-accept incoming invites |
6868
| `INVITE_REMINDER_MINUTES` | `"30"` | Reminder email before events (`0` = off) |
6969
| `SESSION_TTL_HOURS` | `"168"` | UI session length |
7070

71+
| Secret | Meaning |
72+
| ------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
73+
| `UI_PASSWORD` | Web UI login password |
74+
| `SESSION_SECRET` | HMAC key for session cookies |
75+
| `EXTRA_IDENTITIES` | Extra send/receive addresses: `alias@domain=Name;alias2@domain` — kept secret so your addresses stay out of this repo. Each gets a routing rule via `npm run setup`. |
76+
7177
Secrets live in `.dev.vars` locally / `wrangler secret` in prod — never committed.
7278

7379
## 📁 Layout

‎scripts/setup.mjs‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,12 @@ const PRIMARY = vars.PRIMARY_ADDRESS;
7272
const DOMAIN = vars.MAIL_DOMAIN;
7373

7474
// All addresses routed to the worker: primary + EXTRA_IDENTITIES
75-
// ("addr=Display Name;addr2=Name2").
75+
// ("addr=Display Name;addr2=Name2"). EXTRA_IDENTITIES is a secret —
76+
// comes from env / .dev.vars, never from the committed config.
77+
const EXTRA_IDENTITIES = env("EXTRA_IDENTITIES") || "";
7678
const ADDRESSES = [
7779
PRIMARY,
78-
...(vars.EXTRA_IDENTITIES || "")
79-
.split(";")
80+
...EXTRA_IDENTITIES.split(";")
8081
.map((p) => p.split("=")[0].trim().toLowerCase())
8182
.filter(Boolean),
8283
].filter((a, i, arr) => a && arr.indexOf(a) === i);
@@ -146,7 +147,7 @@ console.log("-> applying migrations (remote)");
146147
run(`npx wrangler d1 migrations apply ${D1_NAME} --remote`);
147148

148149
// --- 3. secrets ----------------------------------------------------------------
149-
const SECRET_KEYS = ["UI_PASSWORD", "SESSION_SECRET"];
150+
const SECRET_KEYS = ["UI_PASSWORD", "SESSION_SECRET", "EXTRA_IDENTITIES"];
150151
for (const key of SECRET_KEYS) {
151152
const val = env(key);
152153
if (!val) {

‎src/types.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ export interface Env {
77
MAIL_DOMAIN: string;
88
PRIMARY_ADDRESS: string;
99
DISPLAY_NAME: string;
10-
/** Extra send/receive identities: "addr=Display Name;addr2=Name2" */
11-
EXTRA_IDENTITIES: string;
10+
/** Extra send/receive identities (secret): "addr=Display Name;addr2=Name2" */
11+
EXTRA_IDENTITIES?: string;
1212
CALENDAR_NAME: string;
1313
CALENDAR_TZ: string;
1414
AUTO_ACCEPT_INVITES: string;

‎wrangler.jsonc‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@
4141
"MAIL_DOMAIN": "devartslab.com",
4242
"PRIMARY_ADDRESS": "amir@devartslab.com",
4343
"DISPLAY_NAME": "Amir | DevArts Lab",
44-
// Additional send/receive identities: "addr=Display Name;addr2=Name2"
45-
// (each gets an Email Routing rule -> this worker via scripts/setup.mjs)
46-
"EXTRA_IDENTITIES": "pypi@devartslab.com=PyPI | DevArts Lab",
44+
// NOTE: EXTRA_IDENTITIES is a SECRET, not a var — don't publish your
45+
// addresses in this repo. Set in .dev.vars / `wrangler secret put`:
46+
// EXTRA_IDENTITIES="alias@domain=Display Name;alias2@domain=Name2"
4747
"CALENDAR_NAME": "DevArts Lab",
4848
"CALENDAR_TZ": "America/Los_Angeles",
4949

0 commit comments

Comments
 (0)