@pithy-sh/email 0.3.4 → 0.3.5
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.
- package/dist/crypto/signingKey.d.ts +6 -0
- package/dist/crypto/signingKey.d.ts.map +1 -1
- package/dist/crypto/signingKey.js +8 -1
- package/dist/provision/resolveEmailConfig.d.ts.map +1 -1
- package/dist/provision/resolveEmailConfig.js +2 -2
- package/dist/provision/settingsCheck.js +2 -2
- package/dist/version.generated.d.ts +1 -1
- package/dist/version.generated.js +1 -1
- package/dist/workflows/hostEnv.d.ts +2 -2
- package/dist/workflows/hostEnv.js +3 -3
- package/dist/workflows/worker.d.ts +2 -2
- package/dist/workflows/worker.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/crypto/signingKey.ts +8 -0
- package/src/provision/resolveEmailConfig.ts +3 -2
- package/src/provision/settingsCheck.ts +2 -2
- package/src/version.generated.ts +1 -1
- package/src/workflows/hostEnv.ts +4 -4
- package/src/workflows/worker.ts +2 -2
- package/src/workflows/wrangler.jsonc +1 -1
|
@@ -8,6 +8,12 @@ import type { VersionedSecret } from "@pithy-sh/secrets/src/secretsStore";
|
|
|
8
8
|
* whichever registry names it, so email never needs the project-wide registry to sign or verify a link.
|
|
9
9
|
*/
|
|
10
10
|
export declare const EMAIL_LINK_SIGNING_KEY = "email-link-signing-key";
|
|
11
|
+
/**
|
|
12
|
+
* The binding a Worker reads the link-signing key through: `EMAIL_LINK_SIGNING_KEY` (#603). Derived, never
|
|
13
|
+
* spelled — the stanza `pithy secrets provision` writes and the reader in `@pithy-sh/secrets` both call
|
|
14
|
+
* `secretBindingName`, and so does this.
|
|
15
|
+
*/
|
|
16
|
+
export declare const EMAIL_LINK_SIGNING_KEY_BINDING: "EMAIL_LINK_SIGNING_KEY";
|
|
11
17
|
/** The minimal registry email uses to resolve its signing key. Rotatable so old links verify after rotation. */
|
|
12
18
|
export declare const emailSigningRegistry: {
|
|
13
19
|
readonly "email-link-signing-key": {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signingKey.d.ts","sourceRoot":"","sources":["../../src/crypto/signingKey.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"signingKey.d.ts","sourceRoot":"","sources":["../../src/crypto/signingKey.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAC;AAE1E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAC;AAG1E;;;;GAIG;AACH,eAAO,MAAM,sBAAsB,2BAA2B,CAAC;AAE/D;;;;GAIG;AACH,eAAO,MAAM,8BAA8B,0BAA4C,CAAC;AAExF,gHAAgH;AAChH,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;CA+B/B,CAAC;AAEH;;;;GAIG;AACH,wBAAsB,kBAAkB,CACtC,GAAG,EAAE,eAAe,GACnB,OAAO,CAAC,eAAe,CAAC,CAAC,OAAO,oBAAoB,CAAC,CAAC,OAAO,sBAAsB,CAAC,CAAC,CAAC,CAGxF"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// SPDX-FileCopyrightText: 2026 Pithy
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
|
+
import { secretBindingName } from "@pithy-sh/secrets/src/env/bindingName";
|
|
3
4
|
import { defineSecretRegistry } from "@pithy-sh/secrets/src/registry";
|
|
4
5
|
import { sharedSecretsStore } from "@pithy-sh/secrets/src/sharedSecretsStore";
|
|
5
6
|
//#region src/crypto/signingKey.ts
|
|
@@ -9,6 +10,12 @@ import { sharedSecretsStore } from "@pithy-sh/secrets/src/sharedSecretsStore";
|
|
|
9
10
|
* whichever registry names it, so email never needs the project-wide registry to sign or verify a link.
|
|
10
11
|
*/
|
|
11
12
|
const EMAIL_LINK_SIGNING_KEY = "email-link-signing-key";
|
|
13
|
+
/**
|
|
14
|
+
* The binding a Worker reads the link-signing key through: `EMAIL_LINK_SIGNING_KEY` (#603). Derived, never
|
|
15
|
+
* spelled — the stanza `pithy secrets provision` writes and the reader in `@pithy-sh/secrets` both call
|
|
16
|
+
* `secretBindingName`, and so does this.
|
|
17
|
+
*/
|
|
18
|
+
const EMAIL_LINK_SIGNING_KEY_BINDING = secretBindingName(EMAIL_LINK_SIGNING_KEY);
|
|
12
19
|
/** The minimal registry email uses to resolve its signing key. Rotatable so old links verify after rotation. */
|
|
13
20
|
const emailSigningRegistry = defineSecretRegistry({ [EMAIL_LINK_SIGNING_KEY]: {
|
|
14
21
|
backend: "cf-secrets-store",
|
|
@@ -35,4 +42,4 @@ async function resolveSigningKeys(env) {
|
|
|
35
42
|
return (await sharedSecretsStore(env, emailSigningRegistry)).getVersions(EMAIL_LINK_SIGNING_KEY);
|
|
36
43
|
}
|
|
37
44
|
//#endregion
|
|
38
|
-
export { EMAIL_LINK_SIGNING_KEY, emailSigningRegistry, resolveSigningKeys };
|
|
45
|
+
export { EMAIL_LINK_SIGNING_KEY, EMAIL_LINK_SIGNING_KEY_BINDING, emailSigningRegistry, resolveSigningKeys };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolveEmailConfig.d.ts","sourceRoot":"","sources":["../../src/provision/resolveEmailConfig.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AAEtE,OAAO,KAAK,EACV,aAAa,EACb,uBAAuB,EACvB,oBAAoB,EACpB,mBAAmB,EACnB,oBAAoB,EACrB,MAAM,kCAAkC,CAAC;AAG1C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AAEzE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AAGtE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAErD,OAAO,EAAE,KAAK,eAAe,EAAuB,MAAM,eAAe,CAAC;AAG1E;;;;;;GAMG;AACH,MAAM,WAAW,2BAA4B,SAAQ,oBAA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QAAQ,EAAE,cAAc,GAAG,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAiB9F;AAED,4FAA4F;AAC5F,MAAM,WAAW,iBAAiB;IAChC;;;;;OAKG;IACH,OAAO,EAAE,MAAM,CAAC;IAChB;;;;OAIG;IACH,GAAG,EAAE,kBAAkB,GAAG,KAAK,CAAC;IAChC,yEAAyE;IACzE,aAAa,EAAE,MAAM,CAAC;IACtB,sEAAsE;IACtE,qBAAqB,EAAE,MAAM,CAAC;IAC9B,+GAA+G;IAC/G,iBAAiB,EAAE,MAAM,CAAC;IAC1B,+FAA+F;IAC/F,OAAO,EAAE,MAAM,CAAC;IAChB,mGAAmG;IACnG,OAAO,EAAE,MAAM,CAAC;IAChB,iFAAiF;IACjF,KAAK,EAAE,UAAU,CAAC;IAClB;;;;;;;OAOG;IACH,QAAQ,CAAC,EAAE,cAAc,CAAC;IAC1B;;;OAGG;IACH,WAAW,CAAC,EAAE,eAAe,CAAC;CAK/B;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,kBAAkB,CAChC,QAAQ,EAAE,2BAA2B,EACrC,MAAM,EAAE,iBAAiB,GACxB,2BAA2B,CAuC7B"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// SPDX-FileCopyrightText: 2026 Pithy
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
|
-
import { EMAIL_LINK_SIGNING_KEY, emailSigningRegistry } from "../crypto/signingKey.js";
|
|
3
|
+
import { EMAIL_LINK_SIGNING_KEY, EMAIL_LINK_SIGNING_KEY_BINDING, emailSigningRegistry } from "../crypto/signingKey.js";
|
|
4
4
|
import { emailCatalogVarName } from "../templates/messages.js";
|
|
5
5
|
import { emailRemoteBindings } from "./devDelivery.js";
|
|
6
6
|
import { EMAIL_CAPABILITY, suppressionDatabaseName } from "./provisionEmail.js";
|
|
@@ -111,7 +111,7 @@ function resolveEmailConfig(template, params) {
|
|
|
111
111
|
databaseNames: { EMAIL_SUPPRESSIONS: suppressionDatabaseName(project) },
|
|
112
112
|
secretsStoreId: storeId,
|
|
113
113
|
masterKeySecretName: masterKeySecretName(project, env),
|
|
114
|
-
secretNames: { [
|
|
114
|
+
secretNames: { [EMAIL_LINK_SIGNING_KEY_BINDING]: environmentScope(project, env).secretEntry(EMAIL_LINK_SIGNING_KEY, emailSigningRegistry[EMAIL_LINK_SIGNING_KEY].scope) },
|
|
115
115
|
vars: {
|
|
116
116
|
EMAIL_THEME: JSON.stringify(theme),
|
|
117
117
|
BASE_URL: baseUrl,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// SPDX-FileCopyrightText: 2026 Pithy
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
|
-
import { EMAIL_LINK_SIGNING_KEY, emailSigningRegistry } from "../crypto/signingKey.js";
|
|
3
|
+
import { EMAIL_LINK_SIGNING_KEY, EMAIL_LINK_SIGNING_KEY_BINDING, emailSigningRegistry } from "../crypto/signingKey.js";
|
|
4
4
|
import { emailHostEnv } from "../workflows/hostEnv.js";
|
|
5
5
|
import { suppressionDatabaseName } from "./provisionEmail.js";
|
|
6
6
|
import { hostEnvFindings } from "@pithy-sh/core/src/capability/settings";
|
|
@@ -23,7 +23,7 @@ function stubBindings() {
|
|
|
23
23
|
EMAIL_SUPPRESSIONS: d1,
|
|
24
24
|
SECRETS: d1,
|
|
25
25
|
SECRETS_ENCRYPTION_KEYS: "checked elsewhere",
|
|
26
|
-
[
|
|
26
|
+
[EMAIL_LINK_SIGNING_KEY_BINDING]: "checked elsewhere",
|
|
27
27
|
EMAIL: { send: () => void 0 },
|
|
28
28
|
EMAIL_SENDER: {
|
|
29
29
|
create: () => void 0,
|
|
@@ -3,5 +3,5 @@
|
|
|
3
3
|
/** This package's npm name — the join key against a release feed. */
|
|
4
4
|
export declare const PACKAGE_NAME = "@pithy-sh/email";
|
|
5
5
|
/** This package's version, stamped from its own package.json at generation time. */
|
|
6
|
-
export declare const PACKAGE_VERSION = "0.3.
|
|
6
|
+
export declare const PACKAGE_VERSION = "0.3.5";
|
|
7
7
|
//# sourceMappingURL=version.generated.d.ts.map
|
|
@@ -4,6 +4,6 @@
|
|
|
4
4
|
/** This package's npm name — the join key against a release feed. */
|
|
5
5
|
const PACKAGE_NAME = "@pithy-sh/email";
|
|
6
6
|
/** This package's version, stamped from its own package.json at generation time. */
|
|
7
|
-
const PACKAGE_VERSION = "0.3.
|
|
7
|
+
const PACKAGE_VERSION = "0.3.5";
|
|
8
8
|
//#endregion
|
|
9
9
|
export { PACKAGE_NAME, PACKAGE_VERSION };
|
|
@@ -11,7 +11,7 @@ export declare const EmailHostEnv: z.ZodObject<{
|
|
|
11
11
|
EMAIL_SUPPRESSIONS: z.ZodType<D1Database, unknown, z.core.$ZodTypeInternals<D1Database, unknown>>;
|
|
12
12
|
SECRETS: z.ZodType<D1Database, unknown, z.core.$ZodTypeInternals<D1Database, unknown>>;
|
|
13
13
|
SECRETS_ENCRYPTION_KEYS: z.ZodUnion<readonly [z.ZodString, z.ZodType<SecretBinding, unknown, z.core.$ZodTypeInternals<SecretBinding, unknown>>]>;
|
|
14
|
-
|
|
14
|
+
EMAIL_LINK_SIGNING_KEY: z.ZodUnion<readonly [z.ZodString, z.ZodType<SecretBinding, unknown, z.core.$ZodTypeInternals<SecretBinding, unknown>>]>;
|
|
15
15
|
EMAIL: z.ZodType<EmailSender, unknown, z.core.$ZodTypeInternals<EmailSender, unknown>>;
|
|
16
16
|
EMAIL_SENDER: z.ZodCustom<EmailSenderBinding, EmailSenderBinding>;
|
|
17
17
|
EMAIL_SCHEDULER: z.ZodType<{
|
|
@@ -81,7 +81,7 @@ export declare const emailHostEnv: import("@pithy-sh/core/src/workflow/hostEnv")
|
|
|
81
81
|
EMAIL_SUPPRESSIONS: z.ZodType<D1Database, unknown, z.core.$ZodTypeInternals<D1Database, unknown>>;
|
|
82
82
|
SECRETS: z.ZodType<D1Database, unknown, z.core.$ZodTypeInternals<D1Database, unknown>>;
|
|
83
83
|
SECRETS_ENCRYPTION_KEYS: z.ZodUnion<readonly [z.ZodString, z.ZodType<SecretBinding, unknown, z.core.$ZodTypeInternals<SecretBinding, unknown>>]>;
|
|
84
|
-
|
|
84
|
+
EMAIL_LINK_SIGNING_KEY: z.ZodUnion<readonly [z.ZodString, z.ZodType<SecretBinding, unknown, z.core.$ZodTypeInternals<SecretBinding, unknown>>]>;
|
|
85
85
|
EMAIL: z.ZodType<EmailSender, unknown, z.core.$ZodTypeInternals<EmailSender, unknown>>;
|
|
86
86
|
EMAIL_SENDER: z.ZodCustom<EmailSenderBinding, EmailSenderBinding>;
|
|
87
87
|
EMAIL_SCHEDULER: z.ZodType<{
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// SPDX-FileCopyrightText: 2026 Pithy
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
|
-
import { EMAIL_LINK_SIGNING_KEY } from "../crypto/signingKey.js";
|
|
3
|
+
import { EMAIL_LINK_SIGNING_KEY, EMAIL_LINK_SIGNING_KEY_BINDING } from "../crypto/signingKey.js";
|
|
4
4
|
import { EmailTheme, defaultTheme } from "../templates/theme.js";
|
|
5
5
|
import { z } from "zod";
|
|
6
6
|
import { defineHostEnv } from "@pithy-sh/core/src/workflow/hostEnv";
|
|
@@ -89,7 +89,7 @@ const EmailHostEnv = z.object({
|
|
|
89
89
|
EMAIL_SUPPRESSIONS: d1Binding("The shared suppression database every environment of this project binds").describe("The durable suppression D1 database — one per project, bound identically in every environment, so an unsubscribe or a hard bounce applies everywhere the project sends from. Named `<project>-global-email-suppressions`."),
|
|
90
90
|
SECRETS: d1Binding("The per-environment secrets database").describe("The per-environment secrets D1 database, bound on every prebuilt host that reads through `@pithy-sh/secrets`. The link-signing key is not in it: that is a Secrets Store entry, below (#596)."),
|
|
91
91
|
SECRETS_ENCRYPTION_KEYS: z.union([z.string().min(1), callable("get", "The master key binding")]).describe("The master key that decrypts the secrets database — a Cloudflare Secrets Store binding in a deployed environment, and the same name as a plain string in `.dev.vars` locally. The one secret read outside the `secretsStore` accessor, because it is what makes the accessor work."),
|
|
92
|
-
[
|
|
92
|
+
[EMAIL_LINK_SIGNING_KEY_BINDING]: z.union([z.string().min(1), callable("get", "The link-signing key binding")]).describe("The key every tracking and unsubscribe link is signed with — a Cloudflare Secrets Store entry for this environment, bound as `EMAIL_LINK_SIGNING_KEY`, and the same entry the app Worker verifies those links against. Locally it is the same name in `.dev.vars`. Without it no link can be signed, and a marketing send cannot render."),
|
|
93
93
|
EMAIL: callable("send", "The Cloudflare Email Service send binding").describe("The Cloudflare Email Service `send_email` binding — the only thing in the kit that puts a message on the wire. `wrangler dev` simulates it locally; `remote: true` (the default under `pithy dev`) sends for real from the developer's machine."),
|
|
94
94
|
EMAIL_SENDER: z.custom((value) => isCallable(value, "create") && isCallable(value, "get"), { error: "The send Workflow binding — it must both start an instance and answer about one." }).describe("This host's own send Workflow, same-script. Two calls, and both matter: `create` starts a batch, and `get` is how the scheduler asks whether the instance a stranded row names is still alive before re-driving it."),
|
|
95
95
|
EMAIL_SCHEDULER: callable("create", "The scheduler Workflow binding").describe("This host's own scheduler Workflow, same-script. Fired by the every-minute cron; it finds due jobs and fans them out into send batches."),
|
|
@@ -138,7 +138,7 @@ const emailHostEnv = defineHostEnv({
|
|
|
138
138
|
name: "SECRETS_ENCRYPTION_KEYS",
|
|
139
139
|
command: SECRETS_PROVISION
|
|
140
140
|
},
|
|
141
|
-
[
|
|
141
|
+
[EMAIL_LINK_SIGNING_KEY_BINDING]: {
|
|
142
142
|
kind: "secret",
|
|
143
143
|
name: EMAIL_LINK_SIGNING_KEY,
|
|
144
144
|
command: SECRETS_PROVISION
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import { WorkflowEntrypoint, type WorkflowEvent, type WorkflowStep } from "cloudflare:workers";
|
|
4
4
|
import type { D1Database, ExecutionContext } from "@cloudflare/workers-types";
|
|
5
5
|
import type { SecretBinding, SecretsStoreEnv } from "@pithy-sh/secrets/src/env/bindings";
|
|
6
|
-
import {
|
|
6
|
+
import { EMAIL_LINK_SIGNING_KEY_BINDING } from "../crypto/signingKey";
|
|
7
7
|
import type { SendWorkflowBinding } from "../send/enqueue";
|
|
8
8
|
import type { EmailSender } from "../send/sender";
|
|
9
9
|
import type { SendWorkflowInstances } from "./instances";
|
|
@@ -41,7 +41,7 @@ export interface EmailWorkerEnv extends SecretsStoreEnv {
|
|
|
41
41
|
/** The app database the per-environment jobs/events tables live in. */
|
|
42
42
|
DB: D1Database;
|
|
43
43
|
/** The link-signing key: this environment's Secrets Store entry, or its `.dev.vars` string locally (#596). */
|
|
44
|
-
[
|
|
44
|
+
[EMAIL_LINK_SIGNING_KEY_BINDING]: SecretBinding | string;
|
|
45
45
|
/** The shared, durable suppression database. */
|
|
46
46
|
EMAIL_SUPPRESSIONS: D1Database;
|
|
47
47
|
/** The Cloudflare Email Service send binding. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"worker.d.ts","sourceRoot":"","sources":["../../src/workflows/worker.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,kBAAkB,EAAE,KAAK,aAAa,EAAE,KAAK,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAE/F,OAAO,KAAK,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAG9E,OAAO,KAAK,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAC;AAEzF,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"worker.d.ts","sourceRoot":"","sources":["../../src/workflows/worker.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,kBAAkB,EAAE,KAAK,aAAa,EAAE,KAAK,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAE/F,OAAO,KAAK,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAG9E,OAAO,KAAK,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAC;AAEzF,OAAO,EAAE,8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;IAAE,MAAM,EAAE,MAAM,EAAE,CAAA;CAAE,CAAC;IAI9E,GAAG,CAAC,KAAK,EAAE,aAAa,CAAC;QAAE,MAAM,EAAE,MAAM,EAAE,CAAA;KAAE,CAAC,EAAE,IAAI,EAAE,YAAY,GAAG,OAAO,CAAC,eAAe,CAAC,CAM3G;CACF;AAED,0FAA0F;AAC1F,qBAAa,sBAAuB,SAAQ,kBAAkB,CAAC,cAAc,EAAE,OAAO,CAAC;IACtE,GAAG,CAAC,MAAM,EAAE,aAAa,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAIpF;CACF;;IAGC;;;;;;;;;;;;;;;;;;;;;OAqBG;IACG,SAAS,cAAc,OAAO,OAAO,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;IAOzE;;;;;;;;OAQG;IACG,KAAK,UAAU,OAAO,OAAO,cAAc,OAAO,gBAAgB,GAAG,OAAO,CAAC,QAAQ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pithy-sh/email",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.5",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
},
|
|
44
44
|
"peerDependencies": {
|
|
45
45
|
"@pithy-sh/core": "^0.7.0",
|
|
46
|
-
"@pithy-sh/secrets": "^0.2.
|
|
46
|
+
"@pithy-sh/secrets": "^0.2.5",
|
|
47
47
|
"hono": "^4.13.2",
|
|
48
48
|
"kysely": "^0.29.0",
|
|
49
49
|
"zod": "^4.4.0"
|
package/src/crypto/signingKey.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// SPDX-FileCopyrightText: 2026 Pithy
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
|
|
4
|
+
import { secretBindingName } from "@pithy-sh/secrets/src/env/bindingName";
|
|
4
5
|
import type { SecretsStoreEnv } from "@pithy-sh/secrets/src/env/bindings";
|
|
5
6
|
import { defineSecretRegistry } from "@pithy-sh/secrets/src/registry";
|
|
6
7
|
import type { VersionedSecret } from "@pithy-sh/secrets/src/secretsStore";
|
|
@@ -13,6 +14,13 @@ import { sharedSecretsStore } from "@pithy-sh/secrets/src/sharedSecretsStore";
|
|
|
13
14
|
*/
|
|
14
15
|
export const EMAIL_LINK_SIGNING_KEY = "email-link-signing-key";
|
|
15
16
|
|
|
17
|
+
/**
|
|
18
|
+
* The binding a Worker reads the link-signing key through: `EMAIL_LINK_SIGNING_KEY` (#603). Derived, never
|
|
19
|
+
* spelled — the stanza `pithy secrets provision` writes and the reader in `@pithy-sh/secrets` both call
|
|
20
|
+
* `secretBindingName`, and so does this.
|
|
21
|
+
*/
|
|
22
|
+
export const EMAIL_LINK_SIGNING_KEY_BINDING = secretBindingName(EMAIL_LINK_SIGNING_KEY);
|
|
23
|
+
|
|
16
24
|
/** The minimal registry email uses to resolve its signing key. Rotatable so old links verify after rotation. */
|
|
17
25
|
export const emailSigningRegistry = defineSecretRegistry({
|
|
18
26
|
[EMAIL_LINK_SIGNING_KEY]: {
|
|
@@ -16,7 +16,7 @@ import { workflowKey } from "@pithy-sh/core/src/workflow/naming";
|
|
|
16
16
|
import type { WorkflowRegistry } from "@pithy-sh/core/src/workflow/spec";
|
|
17
17
|
import { masterKeySecretName } from "@pithy-sh/secrets/src/provision/provisionSecrets";
|
|
18
18
|
import type { ManagedEnvironment } from "@pithy-sh/secrets/src/scope";
|
|
19
|
-
import { EMAIL_LINK_SIGNING_KEY, emailSigningRegistry } from "../crypto/signingKey";
|
|
19
|
+
import { EMAIL_LINK_SIGNING_KEY, EMAIL_LINK_SIGNING_KEY_BINDING, emailSigningRegistry } from "../crypto/signingKey";
|
|
20
20
|
import { emailCatalogVarName } from "../templates/messages";
|
|
21
21
|
import type { EmailTheme } from "../templates/theme";
|
|
22
22
|
import { EmailScheduleParams, EmailSendParams } from "../workflows/params";
|
|
@@ -213,8 +213,9 @@ export function resolveEmailConfig(
|
|
|
213
213
|
// The link-signing key, at the entry `pithy secrets provision` created and bound the app Worker to —
|
|
214
214
|
// composed by the same `environmentScope(...).secretEntry` call, from the declaration's own scope, so
|
|
215
215
|
// the Worker that signs a link and the Worker that verifies it cannot be handed two different keys.
|
|
216
|
+
// Keyed by the binding the template declares; the entry keeps the registry key's name (#603).
|
|
216
217
|
secretNames: {
|
|
217
|
-
[
|
|
218
|
+
[EMAIL_LINK_SIGNING_KEY_BINDING]: environmentScope(project, env).secretEntry(
|
|
218
219
|
EMAIL_LINK_SIGNING_KEY,
|
|
219
220
|
emailSigningRegistry[EMAIL_LINK_SIGNING_KEY].scope as SecretNameScope,
|
|
220
221
|
),
|
|
@@ -12,7 +12,7 @@ import { hostEnvFindings } from "@pithy-sh/core/src/capability/settings";
|
|
|
12
12
|
import { LOCAL_ORIGIN } from "@pithy-sh/core/src/naming/domains";
|
|
13
13
|
import { environmentScope, type SecretNameScope } from "@pithy-sh/core/src/naming/provisionScope";
|
|
14
14
|
import { checkHostEnv } from "@pithy-sh/core/src/workflow/hostEnv";
|
|
15
|
-
import { EMAIL_LINK_SIGNING_KEY, emailSigningRegistry } from "../crypto/signingKey";
|
|
15
|
+
import { EMAIL_LINK_SIGNING_KEY, EMAIL_LINK_SIGNING_KEY_BINDING, emailSigningRegistry } from "../crypto/signingKey";
|
|
16
16
|
import type { EmailTheme } from "../templates/theme";
|
|
17
17
|
import { emailHostEnv } from "../workflows/hostEnv";
|
|
18
18
|
import { suppressionDatabaseName } from "./provisionEmail";
|
|
@@ -69,7 +69,7 @@ function stubBindings(): Record<string, unknown> {
|
|
|
69
69
|
EMAIL_SUPPRESSIONS: d1,
|
|
70
70
|
SECRETS: d1,
|
|
71
71
|
SECRETS_ENCRYPTION_KEYS: "checked elsewhere",
|
|
72
|
-
[
|
|
72
|
+
[EMAIL_LINK_SIGNING_KEY_BINDING]: "checked elsewhere",
|
|
73
73
|
EMAIL: { send: () => undefined },
|
|
74
74
|
EMAIL_SENDER: { create: () => undefined, get: () => undefined },
|
|
75
75
|
EMAIL_SCHEDULER: { create: () => undefined },
|
package/src/version.generated.ts
CHANGED
package/src/workflows/hostEnv.ts
CHANGED
|
@@ -5,7 +5,7 @@ import type { D1Database } from "@cloudflare/workers-types";
|
|
|
5
5
|
import { defineHostEnv, type HostEnvProvider } from "@pithy-sh/core/src/workflow/hostEnv";
|
|
6
6
|
import type { SecretBinding } from "@pithy-sh/secrets/src/env/bindings";
|
|
7
7
|
import { z } from "zod";
|
|
8
|
-
import { EMAIL_LINK_SIGNING_KEY } from "../crypto/signingKey";
|
|
8
|
+
import { EMAIL_LINK_SIGNING_KEY, EMAIL_LINK_SIGNING_KEY_BINDING } from "../crypto/signingKey";
|
|
9
9
|
import type { EmailSender } from "../send/sender";
|
|
10
10
|
import { defaultTheme, EmailTheme } from "../templates/theme";
|
|
11
11
|
import type { SendWorkflowInstances } from "./instances";
|
|
@@ -105,10 +105,10 @@ export const EmailHostEnv = z
|
|
|
105
105
|
.describe(
|
|
106
106
|
"The master key that decrypts the secrets database — a Cloudflare Secrets Store binding in a deployed environment, and the same name as a plain string in `.dev.vars` locally. The one secret read outside the `secretsStore` accessor, because it is what makes the accessor work.",
|
|
107
107
|
),
|
|
108
|
-
[
|
|
108
|
+
[EMAIL_LINK_SIGNING_KEY_BINDING]: z
|
|
109
109
|
.union([z.string().min(1), callable<SecretBinding>("get", "The link-signing key binding")])
|
|
110
110
|
.describe(
|
|
111
|
-
"The key every tracking and unsubscribe link is signed with — a Cloudflare Secrets Store entry for this environment, bound
|
|
111
|
+
"The key every tracking and unsubscribe link is signed with — a Cloudflare Secrets Store entry for this environment, bound as `EMAIL_LINK_SIGNING_KEY`, and the same entry the app Worker verifies those links against. Locally it is the same name in `.dev.vars`. Without it no link can be signed, and a marketing send cannot render.",
|
|
112
112
|
),
|
|
113
113
|
EMAIL: callable<EmailSender>("send", "The Cloudflare Email Service send binding").describe(
|
|
114
114
|
"The Cloudflare Email Service `send_email` binding — the only thing in the kit that puts a message on the wire. `wrangler dev` simulates it locally; `remote: true` (the default under `pithy dev`) sends for real from the developer's machine.",
|
|
@@ -212,7 +212,7 @@ export const emailHostEnv = defineHostEnv({
|
|
|
212
212
|
name: "SECRETS_ENCRYPTION_KEYS",
|
|
213
213
|
command: SECRETS_PROVISION,
|
|
214
214
|
},
|
|
215
|
-
[
|
|
215
|
+
[EMAIL_LINK_SIGNING_KEY_BINDING]: {
|
|
216
216
|
kind: "secret",
|
|
217
217
|
name: EMAIL_LINK_SIGNING_KEY,
|
|
218
218
|
command: SECRETS_PROVISION,
|
package/src/workflows/worker.ts
CHANGED
|
@@ -8,7 +8,7 @@ import { classifiedSteps } from "@pithy-sh/core/src/workflow/faults";
|
|
|
8
8
|
import { requireHostEnv } from "@pithy-sh/core/src/workflow/hostEnv";
|
|
9
9
|
import type { SecretBinding, SecretsStoreEnv } from "@pithy-sh/secrets/src/env/bindings";
|
|
10
10
|
import { configureSharedSecrets } from "@pithy-sh/secrets/src/sharedSecretsStore";
|
|
11
|
-
import {
|
|
11
|
+
import { EMAIL_LINK_SIGNING_KEY_BINDING, emailSigningRegistry, resolveSigningKeys } from "../crypto/signingKey";
|
|
12
12
|
import { emailDatabase, emailSuppressionDatabase } from "../data/tables";
|
|
13
13
|
import { mintBatchId } from "../send/batchIdentity";
|
|
14
14
|
import type { SendWorkflowBinding } from "../send/enqueue";
|
|
@@ -56,7 +56,7 @@ export interface EmailWorkerEnv extends SecretsStoreEnv {
|
|
|
56
56
|
/** The app database the per-environment jobs/events tables live in. */
|
|
57
57
|
DB: D1Database;
|
|
58
58
|
/** The link-signing key: this environment's Secrets Store entry, or its `.dev.vars` string locally (#596). */
|
|
59
|
-
[
|
|
59
|
+
[EMAIL_LINK_SIGNING_KEY_BINDING]: SecretBinding | string;
|
|
60
60
|
/** The shared, durable suppression database. */
|
|
61
61
|
EMAIL_SUPPRESSIONS: D1Database;
|
|
62
62
|
/** The Cloudflare Email Service send binding. */
|