@x12i/email-service 0.0.0-stage → 0.1.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.
- package/README.md +70 -2
- package/dist/address.d.ts +8 -0
- package/dist/address.js +21 -0
- package/dist/address.js.map +1 -0
- package/dist/api.d.ts +11 -0
- package/dist/api.js +66 -0
- package/dist/api.js.map +1 -0
- package/dist/bytes.d.ts +1 -0
- package/dist/bytes.js +22 -0
- package/dist/bytes.js.map +1 -0
- package/dist/config.d.ts +20 -0
- package/dist/config.js +59 -0
- package/dist/config.js.map +1 -0
- package/dist/domains.d.ts +14 -0
- package/dist/domains.js +95 -0
- package/dist/domains.js.map +1 -0
- package/dist/inbox-client.d.ts +15 -0
- package/dist/inbox-client.js +67 -0
- package/dist/inbox-client.js.map +1 -0
- package/dist/index.d.ts +99 -0
- package/dist/index.js +97 -0
- package/dist/index.js.map +1 -0
- package/dist/ports.d.ts +96 -0
- package/dist/ports.js +2 -0
- package/dist/ports.js.map +1 -0
- package/dist/relay.d.ts +9 -0
- package/dist/relay.js +9 -0
- package/dist/relay.js.map +1 -0
- package/dist/routing.d.ts +49 -0
- package/dist/routing.js +201 -0
- package/dist/routing.js.map +1 -0
- package/dist/send.d.ts +8 -0
- package/dist/send.js +151 -0
- package/dist/send.js.map +1 -0
- package/dist/worker.d.ts +28 -0
- package/dist/worker.js +44 -0
- package/dist/worker.js.map +1 -0
- package/package.json +27 -4
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import type { CloudflareConfig } from "./config.js";
|
|
2
|
+
import type { ProviderEvidence } from "./ports.js";
|
|
3
|
+
export { readCloudflareConfig, type CloudflareConfig } from "./config.js";
|
|
4
|
+
export { cloudflareApi } from "./api.js";
|
|
5
|
+
export { UnsupportedCloudflareOperation } from "./routing.js";
|
|
6
|
+
export { domainName, MAX_MESSAGE_BYTES, smtpAddress } from "./address.js";
|
|
7
|
+
export { createInboxRelayClient, type RelayDelivery } from "./inbox-client.js";
|
|
8
|
+
export type { DnsRecord, DomainVerification, MailClass, ObservedRule, ProviderEvidence, ProviderSendRequest, ProviderSendResult, RoutingStep, RuleAction, StepResult, } from "./ports.js";
|
|
9
|
+
export declare function createCloudflareProvider(cfg: CloudflareConfig, options?: {
|
|
10
|
+
fetch?: typeof fetch;
|
|
11
|
+
recordEvidence?: (events: ProviderEvidence[]) => Promise<void>;
|
|
12
|
+
}): {
|
|
13
|
+
id: string;
|
|
14
|
+
routing: {
|
|
15
|
+
checkConnection(input: {
|
|
16
|
+
secretRef: string;
|
|
17
|
+
providerAccountId: string;
|
|
18
|
+
}): Promise<{
|
|
19
|
+
ok: boolean;
|
|
20
|
+
scopes: string[];
|
|
21
|
+
zones: {
|
|
22
|
+
zoneId: string;
|
|
23
|
+
name: string;
|
|
24
|
+
}[];
|
|
25
|
+
}>;
|
|
26
|
+
observe(input: {
|
|
27
|
+
secretRef: string;
|
|
28
|
+
zoneId: string;
|
|
29
|
+
domain: string;
|
|
30
|
+
}): Promise<{
|
|
31
|
+
rules: import("./ports.js").ObservedRule[];
|
|
32
|
+
mx: string[];
|
|
33
|
+
ownership: "verified" | "unverified";
|
|
34
|
+
routingEnabled: boolean;
|
|
35
|
+
}>;
|
|
36
|
+
applyStep(input: {
|
|
37
|
+
secretRef: string;
|
|
38
|
+
zoneId: string;
|
|
39
|
+
domain: string;
|
|
40
|
+
} & {
|
|
41
|
+
step: import("./ports.js").RoutingStep;
|
|
42
|
+
}): Promise<import("./ports.js").StepResult>;
|
|
43
|
+
createDestination(input: {
|
|
44
|
+
secretRef: string;
|
|
45
|
+
address: string;
|
|
46
|
+
}): Promise<{
|
|
47
|
+
providerRef: string;
|
|
48
|
+
}>;
|
|
49
|
+
destinationStatus(input: {
|
|
50
|
+
secretRef: string;
|
|
51
|
+
providerRef: string;
|
|
52
|
+
}): Promise<"pending" | "verified" | "failed">;
|
|
53
|
+
removeDestination(_input: {
|
|
54
|
+
secretRef: string;
|
|
55
|
+
providerRef: string;
|
|
56
|
+
}): Promise<void>;
|
|
57
|
+
};
|
|
58
|
+
preflight: () => Promise<{
|
|
59
|
+
sending: {
|
|
60
|
+
domain: string;
|
|
61
|
+
state: "verified" | "pending" | "failed";
|
|
62
|
+
tokenActive: boolean;
|
|
63
|
+
requiredRecords: number;
|
|
64
|
+
matchingRecords: number;
|
|
65
|
+
} | null;
|
|
66
|
+
routing: {
|
|
67
|
+
domain: string;
|
|
68
|
+
state: string;
|
|
69
|
+
mx: string[];
|
|
70
|
+
incumbentMx: string[];
|
|
71
|
+
managedRules: number;
|
|
72
|
+
foreignRules: number;
|
|
73
|
+
} | null;
|
|
74
|
+
zone: string;
|
|
75
|
+
zoneVerified: boolean;
|
|
76
|
+
}>;
|
|
77
|
+
capabilities: () => {
|
|
78
|
+
id: string;
|
|
79
|
+
transactional: boolean;
|
|
80
|
+
marketing: boolean;
|
|
81
|
+
maxMessageBytes: number;
|
|
82
|
+
maxRecipients: number;
|
|
83
|
+
supportsIdempotency: boolean;
|
|
84
|
+
supportsStatusLookup: boolean;
|
|
85
|
+
classes: never[] | readonly ["system", "notification", "transactional", "conversational"];
|
|
86
|
+
};
|
|
87
|
+
send: (req: import("./ports.js").ProviderSendRequest) => Promise<import("./ports.js").ProviderSendResult>;
|
|
88
|
+
status(_input: {
|
|
89
|
+
correlationId: string;
|
|
90
|
+
secretRef: string | null;
|
|
91
|
+
}): Promise<{
|
|
92
|
+
found: boolean;
|
|
93
|
+
providerRef?: string;
|
|
94
|
+
}>;
|
|
95
|
+
verifySenderDomain(input: {
|
|
96
|
+
domain: string;
|
|
97
|
+
secretRef: string | null;
|
|
98
|
+
}): Promise<import("./ports.js").DomainVerification>;
|
|
99
|
+
};
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { cloudflareApi } from "./api.js";
|
|
2
|
+
import { domainsApi, incumbentMx, routingMxReady } from "./domains.js";
|
|
3
|
+
import { routingPort, UnsupportedCloudflareOperation } from "./routing.js";
|
|
4
|
+
import { classes, MAX_RECIPIENTS, outbound } from "./send.js";
|
|
5
|
+
export { readCloudflareConfig } from "./config.js";
|
|
6
|
+
export { cloudflareApi } from "./api.js";
|
|
7
|
+
export { UnsupportedCloudflareOperation } from "./routing.js";
|
|
8
|
+
export { domainName, MAX_MESSAGE_BYTES, smtpAddress } from "./address.js";
|
|
9
|
+
export { createInboxRelayClient } from "./inbox-client.js";
|
|
10
|
+
export function createCloudflareProvider(cfg, options = {}) {
|
|
11
|
+
const request = options.fetch ?? fetch;
|
|
12
|
+
const control = cloudflareApi(cfg.controlToken, request);
|
|
13
|
+
const sending = cfg.sending ? cloudflareApi(cfg.sending.token, request, 20_000) : null;
|
|
14
|
+
const domains = domainsApi(cfg, control);
|
|
15
|
+
const routing = routingPort(cfg, control, domains);
|
|
16
|
+
const id = "cloudflare";
|
|
17
|
+
async function sendTokenActive() {
|
|
18
|
+
if (!sending)
|
|
19
|
+
return false;
|
|
20
|
+
const accountPath = `/accounts/${cfg.accountId}/tokens/verify`;
|
|
21
|
+
for (const path of [accountPath, "/user/tokens/verify"]) {
|
|
22
|
+
try {
|
|
23
|
+
const token = await sending.result(path);
|
|
24
|
+
return token?.status === "active";
|
|
25
|
+
}
|
|
26
|
+
catch { /* Account and user tokens have different verification endpoints. */ }
|
|
27
|
+
}
|
|
28
|
+
return false;
|
|
29
|
+
}
|
|
30
|
+
async function preflight() {
|
|
31
|
+
const zoneVerified = await domains.hasZone();
|
|
32
|
+
const base = { zone: cfg.zone, zoneVerified };
|
|
33
|
+
if (!zoneVerified)
|
|
34
|
+
return { ...base, sending: null, routing: null };
|
|
35
|
+
const [senderResult, receiverResult, tokenResult] = await Promise.allSettled([
|
|
36
|
+
cfg.sending ? senderReadiness(cfg.sending.domain) : null,
|
|
37
|
+
cfg.routing ? routing.observe({ secretRef: cfg.secretRef, zoneId: cfg.zoneId, domain: cfg.routing.domain }) : null,
|
|
38
|
+
cfg.sending ? sendTokenActive() : false,
|
|
39
|
+
]);
|
|
40
|
+
const sender = senderResult.status === "fulfilled" ? senderResult.value : null;
|
|
41
|
+
const receiver = receiverResult.status === "fulfilled" ? receiverResult.value : null;
|
|
42
|
+
const tokenActive = tokenResult.status === "fulfilled" && tokenResult.value;
|
|
43
|
+
const routeEnabled = receiver?.routingEnabled === true;
|
|
44
|
+
return {
|
|
45
|
+
...base,
|
|
46
|
+
sending: cfg.sending ? {
|
|
47
|
+
domain: cfg.sending.domain, state: tokenActive ? sender?.state ?? "failed" : "failed", tokenActive,
|
|
48
|
+
requiredRecords: sender?.required.length ?? 0, matchingRecords: sender?.observed.length ?? 0,
|
|
49
|
+
} : null,
|
|
50
|
+
routing: cfg.routing ? {
|
|
51
|
+
domain: cfg.routing.domain,
|
|
52
|
+
state: !receiver || receiver.ownership !== "verified" ? "failed" : routeEnabled && routingMxReady(receiver.mx) ? "verified" : "pending",
|
|
53
|
+
mx: receiver?.mx ?? [], incumbentMx: incumbentMx(receiver?.mx ?? []),
|
|
54
|
+
managedRules: receiver?.rules.filter((r) => r.managed).length ?? 0,
|
|
55
|
+
foreignRules: receiver?.rules.filter((r) => !r.managed).length ?? 0,
|
|
56
|
+
} : null,
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
async function senderReadiness(domain) {
|
|
60
|
+
const result = await domains.verifySenderDomain(domain);
|
|
61
|
+
if (result.state === "verified" && cfg.sending?.mode === "verified-destinations" &&
|
|
62
|
+
!(await domains.verifiedDestinations()).size)
|
|
63
|
+
return { ...result, state: "pending" };
|
|
64
|
+
return result;
|
|
65
|
+
}
|
|
66
|
+
return {
|
|
67
|
+
id,
|
|
68
|
+
routing,
|
|
69
|
+
preflight,
|
|
70
|
+
capabilities: () => ({
|
|
71
|
+
id, transactional: !!cfg.sending, marketing: false, maxMessageBytes: cfg.maxMessageBytes, maxRecipients: MAX_RECIPIENTS,
|
|
72
|
+
supportsIdempotency: false, supportsStatusLookup: false, classes: cfg.sending ? classes : [],
|
|
73
|
+
}),
|
|
74
|
+
send: outbound(cfg, sending, options.recordEvidence, async (recipients) => {
|
|
75
|
+
if (!cfg.sending || (await domains.verifySenderDomain(cfg.sending.domain)).state !== "verified") {
|
|
76
|
+
return "CF_SENDER_NOT_VERIFIED";
|
|
77
|
+
}
|
|
78
|
+
if (cfg.sending.mode === "verified-destinations") {
|
|
79
|
+
const verified = await domains.verifiedDestinations();
|
|
80
|
+
if (recipients.some((address) => !verified.has(address.toLowerCase())))
|
|
81
|
+
return "CF_RECIPIENT_NOT_VERIFIED";
|
|
82
|
+
}
|
|
83
|
+
return null;
|
|
84
|
+
}),
|
|
85
|
+
// The suite's legacy resend path calls status() even when lookup is not
|
|
86
|
+
// supported. Returning found:false would authorize a duplicate send.
|
|
87
|
+
async status(_input) {
|
|
88
|
+
throw new UnsupportedCloudflareOperation("Cloudflare cannot prove that the previous send was not accepted.");
|
|
89
|
+
},
|
|
90
|
+
async verifySenderDomain(input) {
|
|
91
|
+
if (input.secretRef !== cfg.secretRef)
|
|
92
|
+
return { state: "failed", required: [], observed: [] };
|
|
93
|
+
return senderReadiness(input.domain);
|
|
94
|
+
},
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAEvE,OAAO,EAAE,WAAW,EAAE,8BAA8B,EAAE,MAAM,cAAc,CAAC;AAC3E,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAE9D,OAAO,EAAE,oBAAoB,EAAyB,MAAM,aAAa,CAAC;AAC1E,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,8B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F,wEAAwE;QACxE,qEAAqE;QACrE,KAAK,CAAC,MAAM,CAAC,MAA2D;YACtE,MAAM,IAAI,8BAA8B,CAAC,kEAAkE,CAAC,CAAC;QAC/G,CAAC;QACD,KAAK,CAAC,kBAAkB,CAAC,KAAmD;YAC1E,IAAI,KAAK,CAAC,SAAS,KAAK,GAAG,CAAC,SAAS;gBAAE,OAAO,EAAE,KAAK,EAAE,QAAiB,EAAE,QAAQ,EAAE,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC;YACvG,OAAO,eAAe,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;QACvC,CAAC;KACF,CAAC;AACJ,CAAC"}
|
package/dist/ports.d.ts
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
export type MailClass = "system" | "notification" | "transactional" | "conversational" | "marketing";
|
|
2
|
+
export interface ProviderSendRequest {
|
|
3
|
+
correlationId: string;
|
|
4
|
+
idempotencyKey: string;
|
|
5
|
+
secretRef: string | null;
|
|
6
|
+
class: MailClass;
|
|
7
|
+
from: string;
|
|
8
|
+
fromName: string;
|
|
9
|
+
replyTo: string | null;
|
|
10
|
+
to: string[];
|
|
11
|
+
cc: string[];
|
|
12
|
+
bcc: string[];
|
|
13
|
+
subject: string;
|
|
14
|
+
text: string;
|
|
15
|
+
html: string | null;
|
|
16
|
+
headers: Record<string, string>;
|
|
17
|
+
attachments: Array<{
|
|
18
|
+
name: string;
|
|
19
|
+
mime: string;
|
|
20
|
+
bytes: Uint8Array;
|
|
21
|
+
}>;
|
|
22
|
+
calendar?: {
|
|
23
|
+
method: "REQUEST" | "REPLY" | "CANCEL" | "PUBLISH";
|
|
24
|
+
content: Uint8Array;
|
|
25
|
+
};
|
|
26
|
+
recipientRefs: Record<string, string>;
|
|
27
|
+
recipientNames?: Record<string, string>;
|
|
28
|
+
}
|
|
29
|
+
export type ProviderSendResult = {
|
|
30
|
+
outcome: "accepted";
|
|
31
|
+
providerRef: string;
|
|
32
|
+
evidence?: ProviderEvidence[];
|
|
33
|
+
} | {
|
|
34
|
+
outcome: "rejected";
|
|
35
|
+
permanent: boolean;
|
|
36
|
+
code: string;
|
|
37
|
+
retryAfterSeconds?: number;
|
|
38
|
+
} | {
|
|
39
|
+
outcome: "unknown";
|
|
40
|
+
reason?: string;
|
|
41
|
+
};
|
|
42
|
+
export interface ProviderEvidence {
|
|
43
|
+
eventId: string;
|
|
44
|
+
correlationId: string;
|
|
45
|
+
type: "delivered" | "bounced" | "rejected";
|
|
46
|
+
at: string;
|
|
47
|
+
bounceType?: "hard";
|
|
48
|
+
}
|
|
49
|
+
export interface DnsRecord {
|
|
50
|
+
type: "TXT" | "CNAME" | "MX";
|
|
51
|
+
name: string;
|
|
52
|
+
value: string;
|
|
53
|
+
purpose: "spf" | "dkim" | "dmarc" | "return-path" | "ownership" | "mx";
|
|
54
|
+
}
|
|
55
|
+
export interface DomainVerification {
|
|
56
|
+
state: "pending" | "verified" | "failed";
|
|
57
|
+
required: DnsRecord[];
|
|
58
|
+
observed: DnsRecord[];
|
|
59
|
+
}
|
|
60
|
+
export type RuleAction = {
|
|
61
|
+
type: "mailbox" | "app";
|
|
62
|
+
mailboxId: string;
|
|
63
|
+
} | {
|
|
64
|
+
type: "forward";
|
|
65
|
+
destinationId: string;
|
|
66
|
+
} | {
|
|
67
|
+
type: "drop";
|
|
68
|
+
};
|
|
69
|
+
export interface ObservedRule {
|
|
70
|
+
providerRef: string;
|
|
71
|
+
match: "exact" | "catchall";
|
|
72
|
+
address: string | null;
|
|
73
|
+
action: RuleAction;
|
|
74
|
+
enabled: boolean;
|
|
75
|
+
managed: boolean;
|
|
76
|
+
}
|
|
77
|
+
export interface RoutingStep {
|
|
78
|
+
id: string;
|
|
79
|
+
kind: "create_rule" | "update_rule" | "delete_rule" | "set_mx" | "enable_routing";
|
|
80
|
+
match?: "exact" | "catchall";
|
|
81
|
+
address?: string | null;
|
|
82
|
+
action?: RuleAction;
|
|
83
|
+
forwardTarget?: string;
|
|
84
|
+
enabled?: boolean;
|
|
85
|
+
providerRef?: string;
|
|
86
|
+
mx?: string[];
|
|
87
|
+
}
|
|
88
|
+
export type StepResult = {
|
|
89
|
+
result: "done";
|
|
90
|
+
providerRef?: string;
|
|
91
|
+
} | {
|
|
92
|
+
result: "ambiguous";
|
|
93
|
+
} | {
|
|
94
|
+
result: "failed";
|
|
95
|
+
error: string;
|
|
96
|
+
};
|
package/dist/ports.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ports.js","sourceRoot":"","sources":["../src/ports.ts"],"names":[],"mappings":""}
|
package/dist/relay.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare const RELAY_PATH = "/v1/deliveries";
|
|
2
|
+
export declare const RELAY_TOKEN_PATTERN: RegExp;
|
|
3
|
+
export declare const DELIVERY_ID_PATTERN: RegExp;
|
|
4
|
+
export declare const MAX_RELAY_PAGE_SIZE = 50;
|
|
5
|
+
export interface RelayPage {
|
|
6
|
+
ids: string[];
|
|
7
|
+
cursor?: string;
|
|
8
|
+
}
|
|
9
|
+
export declare function relayCursor(value: string): number | null;
|
package/dist/relay.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export const RELAY_PATH = "/v1/deliveries";
|
|
2
|
+
export const RELAY_TOKEN_PATTERN = /^[A-Za-z0-9_-]{43}$/;
|
|
3
|
+
export const DELIVERY_ID_PATTERN = /^cf_[a-f0-9]{64}$/;
|
|
4
|
+
export const MAX_RELAY_PAGE_SIZE = 50;
|
|
5
|
+
export function relayCursor(value) {
|
|
6
|
+
const sequence = Number(value);
|
|
7
|
+
return /^[1-9][0-9]*$/.test(value) && Number.isSafeInteger(sequence) ? sequence : null;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=relay.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"relay.js","sourceRoot":"","sources":["../src/relay.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,UAAU,GAAG,gBAAgB,CAAC;AAC3C,MAAM,CAAC,MAAM,mBAAmB,GAAG,qBAAqB,CAAC;AACzD,MAAM,CAAC,MAAM,mBAAmB,GAAG,mBAAmB,CAAC;AACvD,MAAM,CAAC,MAAM,mBAAmB,GAAG,EAAE,CAAC;AAOtC,MAAM,UAAU,WAAW,CAAC,KAAa;IACvC,MAAM,QAAQ,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;IAC/B,OAAO,eAAe,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,MAAM,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC;AACzF,CAAC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { type CloudflareApi } from "./api.js";
|
|
2
|
+
import { type CloudflareConfig } from "./config.js";
|
|
3
|
+
import { type DomainsApi } from "./domains.js";
|
|
4
|
+
import type { ObservedRule, RoutingStep, StepResult } from "./ports.js";
|
|
5
|
+
type Scope = {
|
|
6
|
+
secretRef: string;
|
|
7
|
+
zoneId: string;
|
|
8
|
+
domain: string;
|
|
9
|
+
};
|
|
10
|
+
export declare class UnsupportedCloudflareOperation extends Error {
|
|
11
|
+
constructor(message: string);
|
|
12
|
+
}
|
|
13
|
+
export declare function routingPort(cfg: CloudflareConfig, api: CloudflareApi, domains: DomainsApi): {
|
|
14
|
+
checkConnection(input: {
|
|
15
|
+
secretRef: string;
|
|
16
|
+
providerAccountId: string;
|
|
17
|
+
}): Promise<{
|
|
18
|
+
ok: boolean;
|
|
19
|
+
scopes: string[];
|
|
20
|
+
zones: {
|
|
21
|
+
zoneId: string;
|
|
22
|
+
name: string;
|
|
23
|
+
}[];
|
|
24
|
+
}>;
|
|
25
|
+
observe(input: Scope): Promise<{
|
|
26
|
+
rules: ObservedRule[];
|
|
27
|
+
mx: string[];
|
|
28
|
+
ownership: "verified" | "unverified";
|
|
29
|
+
routingEnabled: boolean;
|
|
30
|
+
}>;
|
|
31
|
+
applyStep(input: Scope & {
|
|
32
|
+
step: RoutingStep;
|
|
33
|
+
}): Promise<StepResult>;
|
|
34
|
+
createDestination(input: {
|
|
35
|
+
secretRef: string;
|
|
36
|
+
address: string;
|
|
37
|
+
}): Promise<{
|
|
38
|
+
providerRef: string;
|
|
39
|
+
}>;
|
|
40
|
+
destinationStatus(input: {
|
|
41
|
+
secretRef: string;
|
|
42
|
+
providerRef: string;
|
|
43
|
+
}): Promise<"pending" | "verified" | "failed">;
|
|
44
|
+
removeDestination(_input: {
|
|
45
|
+
secretRef: string;
|
|
46
|
+
providerRef: string;
|
|
47
|
+
}): Promise<void>;
|
|
48
|
+
};
|
|
49
|
+
export {};
|
package/dist/routing.js
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import { smtpAddress } from "./address.js";
|
|
3
|
+
import { CloudflareError } from "./api.js";
|
|
4
|
+
import { cfId } from "./config.js";
|
|
5
|
+
import { routingMxReady } from "./domains.js";
|
|
6
|
+
const failed = (error) => ({ result: "failed", error });
|
|
7
|
+
const safeMailboxId = /^[A-Za-z0-9_-]{1,128}$/;
|
|
8
|
+
const addressTag = (address) => createHash("sha256").update(address).digest("hex").slice(0, 24);
|
|
9
|
+
export class UnsupportedCloudflareOperation extends Error {
|
|
10
|
+
constructor(message) {
|
|
11
|
+
super(message);
|
|
12
|
+
this.name = "UnsupportedCloudflareOperation";
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
export function routingPort(cfg, api, domains) {
|
|
16
|
+
const rulesPath = `/zones/${cfg.zoneId}/email/routing/rules`;
|
|
17
|
+
const destinationsPath = `/accounts/${cfg.accountId}/email/routing/addresses`;
|
|
18
|
+
const catchAllPath = `${rulesPath}/catch_all`;
|
|
19
|
+
// Existing installations used this tag before namespaces became configurable.
|
|
20
|
+
const prefix = `${cfg.routing?.ruleNamespace ?? "email-service"}/${cfg.routing?.worker ?? ""}/`;
|
|
21
|
+
const inScope = (s) => s.secretRef === cfg.secretRef && s.zoneId === cfg.zoneId && s.domain === cfg.routing?.domain;
|
|
22
|
+
function fromCloudflare(row, address) {
|
|
23
|
+
const match = address === null ? "catchall" : "exact";
|
|
24
|
+
const providerRef = row.id ?? row.tag ?? (match === "catchall" ? "catch_all" : "");
|
|
25
|
+
if (!cfId(providerRef) && providerRef !== "catch_all")
|
|
26
|
+
throw new CloudflareError(200);
|
|
27
|
+
if (typeof row.enabled !== "boolean")
|
|
28
|
+
throw new CloudflareError(200);
|
|
29
|
+
const action = row.actions?.length === 1 ? row.actions[0] : undefined;
|
|
30
|
+
const name = row.name ?? "";
|
|
31
|
+
const mark = name.startsWith(prefix) && row.source !== "wrangler" ? name.slice(prefix.length) : "";
|
|
32
|
+
const [kind, mailboxId, extra] = mark.split("/");
|
|
33
|
+
const forward = action?.type === "forward" && action.value?.length === 1 ? smtpAddress(action.value[0])?.address.toLowerCase() : undefined;
|
|
34
|
+
const mapped = mark === "drop" && action?.type === "drop" ? { type: "drop" }
|
|
35
|
+
: kind === "forward" && mailboxId && safeMailboxId.test(mailboxId) && forward && mark === `forward/${mailboxId}/${addressTag(forward)}`
|
|
36
|
+
? { type: "forward", destinationId: mailboxId }
|
|
37
|
+
: (kind === "mailbox" || kind === "app") && mailboxId && safeMailboxId.test(mailboxId) && extra === undefined &&
|
|
38
|
+
action?.type === "worker" && action.value?.length === 1 && action.value[0] === cfg.routing?.worker
|
|
39
|
+
? { type: kind, mailboxId } : null;
|
|
40
|
+
const external = action?.type === "forward" ? { type: "forward", destinationId: "external" }
|
|
41
|
+
: action?.type === "worker" ? { type: "app", mailboxId: "external" } : { type: "drop" };
|
|
42
|
+
const defaultCatchAll = match === "catchall" && !row.enabled && action?.type === "drop" &&
|
|
43
|
+
(!name || /^catch[ -]?all$/i.test(name)) && row.source !== "wrangler";
|
|
44
|
+
return { defaultCatchAll, rule: { providerRef, match, address, action: mapped ?? external, enabled: row.enabled, managed: mapped !== null } };
|
|
45
|
+
}
|
|
46
|
+
async function readRules(domain) {
|
|
47
|
+
const exactRows = await api.list(rulesPath);
|
|
48
|
+
const out = [];
|
|
49
|
+
for (const row of exactRows) {
|
|
50
|
+
if (row.matchers?.length === 1 && row.matchers[0]?.type === "all")
|
|
51
|
+
continue; // read via the singleton endpoint
|
|
52
|
+
const matcher = row.matchers?.length === 1 ? row.matchers[0] : undefined;
|
|
53
|
+
const address = matcher?.type === "literal" && matcher.field === "to" && typeof matcher.value === "string"
|
|
54
|
+
? smtpAddress(matcher.value) : null;
|
|
55
|
+
if (!address)
|
|
56
|
+
throw new CloudflareError(200); // do not write against an incomplete rules snapshot
|
|
57
|
+
if (address.domain === domain)
|
|
58
|
+
out.push(fromCloudflare(row, address.address.toLowerCase()));
|
|
59
|
+
}
|
|
60
|
+
if (domain === cfg.zone)
|
|
61
|
+
out.push(fromCloudflare(await api.result(catchAllPath), null));
|
|
62
|
+
return out;
|
|
63
|
+
}
|
|
64
|
+
async function isEnabled() {
|
|
65
|
+
try {
|
|
66
|
+
return await domains.routingEnabled();
|
|
67
|
+
}
|
|
68
|
+
catch (error) {
|
|
69
|
+
if (error instanceof CloudflareError && error.status === 404)
|
|
70
|
+
return false;
|
|
71
|
+
throw error;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
return {
|
|
75
|
+
async checkConnection(input) {
|
|
76
|
+
let ok = false;
|
|
77
|
+
if (input.secretRef === cfg.secretRef && input.providerAccountId === cfg.accountId) {
|
|
78
|
+
try {
|
|
79
|
+
ok = await domains.hasZone();
|
|
80
|
+
}
|
|
81
|
+
catch { /* report degraded */ }
|
|
82
|
+
}
|
|
83
|
+
return { ok, scopes: ok ? ["zone:read"] : [], zones: ok ? [{ zoneId: cfg.zoneId, name: cfg.zone }] : [] };
|
|
84
|
+
},
|
|
85
|
+
async observe(input) {
|
|
86
|
+
if (!inScope(input) || !await domains.hasZone())
|
|
87
|
+
return { rules: [], mx: [], ownership: "unverified", routingEnabled: false };
|
|
88
|
+
const [mx, enabled] = await Promise.all([domains.readMx(input.domain), isEnabled()]);
|
|
89
|
+
const rules = enabled ? (await readRules(input.domain)).filter((r) => !r.defaultCatchAll).map((r) => r.rule) : [];
|
|
90
|
+
return { rules, mx, ownership: "verified", routingEnabled: enabled };
|
|
91
|
+
},
|
|
92
|
+
async applyStep(input) {
|
|
93
|
+
const { step, domain } = input;
|
|
94
|
+
if (!inScope(input))
|
|
95
|
+
return failed("CF_ROUTING_SCOPE_MISMATCH");
|
|
96
|
+
if (step.kind === "set_mx")
|
|
97
|
+
return failed("CF_MX_CHANGE_REQUIRES_OPERATOR");
|
|
98
|
+
let attempted = false;
|
|
99
|
+
try {
|
|
100
|
+
if (!await domains.hasZone())
|
|
101
|
+
return failed("CF_ZONE_UNVERIFIED");
|
|
102
|
+
const [mx, enabled] = await Promise.all([domains.readMx(domain), isEnabled()]);
|
|
103
|
+
if (!enabled || !routingMxReady(mx))
|
|
104
|
+
return failed("CF_ROUTING_NOT_READY");
|
|
105
|
+
if (step.kind === "enable_routing")
|
|
106
|
+
return { result: "done" };
|
|
107
|
+
const rules = await readRules(domain);
|
|
108
|
+
const target = rules.find(({ rule }) => rule.providerRef === step.providerRef);
|
|
109
|
+
if (step.kind === "delete_rule") {
|
|
110
|
+
if (!target)
|
|
111
|
+
return { result: "done" };
|
|
112
|
+
if (!target.rule.managed)
|
|
113
|
+
return failed("CF_FOREIGN_RULE");
|
|
114
|
+
attempted = true;
|
|
115
|
+
if (target.rule.match === "catchall") {
|
|
116
|
+
await api.result(catchAllPath, "PUT", {
|
|
117
|
+
name: "Catch-all", enabled: false, matchers: [{ type: "all" }], actions: [{ type: "drop" }],
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
else {
|
|
121
|
+
await api.result(`${rulesPath}/${target.rule.providerRef}`, "DELETE");
|
|
122
|
+
}
|
|
123
|
+
return { result: "done" };
|
|
124
|
+
}
|
|
125
|
+
if (!step.match || !step.action || typeof step.enabled !== "boolean")
|
|
126
|
+
return failed("CF_RULE_INVALID");
|
|
127
|
+
const catchAll = step.match === "catchall";
|
|
128
|
+
const address = catchAll ? null : smtpAddress(step.address ?? "")?.address.toLowerCase();
|
|
129
|
+
if (catchAll ? domain !== cfg.zone : !address || address.length > 90 || smtpAddress(address)?.domain !== domain) {
|
|
130
|
+
return failed("CF_RULE_MATCH_UNSUPPORTED");
|
|
131
|
+
}
|
|
132
|
+
const prior = rules.filter(({ rule }) => rule.address === address);
|
|
133
|
+
const forward = step.action.type === "forward" ? smtpAddress(step.forwardTarget ?? "")?.address.toLowerCase() : undefined;
|
|
134
|
+
if (step.action.type === "forward" && (!forward || catchAll || forward === address || !(await domains.verifiedDestinations()).has(forward))) {
|
|
135
|
+
return failed("CF_FORWARD_TARGET_UNVERIFIED");
|
|
136
|
+
}
|
|
137
|
+
const writeName = step.action.type === "drop" ? "drop"
|
|
138
|
+
: step.action.type === "forward" ? safeMailboxId.test(step.action.destinationId) && forward ? `forward/${step.action.destinationId}/${addressTag(forward)}` : null
|
|
139
|
+
: safeMailboxId.test(step.action.mailboxId) ? `${step.action.type}/${step.action.mailboxId}` : null;
|
|
140
|
+
if (!writeName)
|
|
141
|
+
return failed("CF_RULE_INVALID");
|
|
142
|
+
const create = step.kind === "create_rule";
|
|
143
|
+
if (create) {
|
|
144
|
+
if (prior.some((r) => !r.defaultCatchAll))
|
|
145
|
+
return failed("CF_RULE_CONFLICT");
|
|
146
|
+
}
|
|
147
|
+
else if (!target?.rule.managed || target.rule.address !== address || prior.length !== 1) {
|
|
148
|
+
return failed("CF_RULE_DRIFTED");
|
|
149
|
+
}
|
|
150
|
+
const body = {
|
|
151
|
+
name: `${prefix}${writeName}`,
|
|
152
|
+
matchers: catchAll ? [{ type: "all" }] : [{ type: "literal", field: "to", value: address }],
|
|
153
|
+
actions: step.action.type === "drop" ? [{ type: "drop" }] : forward ? [{ type: "forward", value: [forward] }] : [{ type: "worker", value: [cfg.routing.worker] }],
|
|
154
|
+
enabled: step.enabled,
|
|
155
|
+
};
|
|
156
|
+
attempted = true;
|
|
157
|
+
const row = await api.result(catchAll ? catchAllPath : create ? rulesPath : `${rulesPath}/${target.rule.providerRef}`, catchAll || !create ? "PUT" : "POST", body);
|
|
158
|
+
const id = row?.id ?? row?.tag ?? (catchAll ? "catch_all" : undefined);
|
|
159
|
+
return cfId(id) || id === "catch_all" ? { result: "done", providerRef: id } : { result: "ambiguous" };
|
|
160
|
+
}
|
|
161
|
+
catch (error) {
|
|
162
|
+
if (!attempted)
|
|
163
|
+
return failed("CF_ROUTE_PREFLIGHT_FAILED");
|
|
164
|
+
if (error instanceof CloudflareError && error.explicitFailure && [400, 401, 403, 404, 409, 422, 429].includes(error.status)) {
|
|
165
|
+
return failed(`CF_ROUTE_${error.status}`);
|
|
166
|
+
}
|
|
167
|
+
return { result: "ambiguous" };
|
|
168
|
+
}
|
|
169
|
+
},
|
|
170
|
+
async createDestination(input) {
|
|
171
|
+
const email = smtpAddress(input.address)?.address.toLowerCase();
|
|
172
|
+
if (input.secretRef !== cfg.secretRef || !email || email.length > 90 || !await domains.hasZone()) {
|
|
173
|
+
throw new UnsupportedCloudflareOperation("Verify the Cloudflare connection and enter a valid destination of up to 90 characters.");
|
|
174
|
+
}
|
|
175
|
+
try {
|
|
176
|
+
const existing = (await api.list(destinationsPath)).find((row) => row.email?.toLowerCase() === email);
|
|
177
|
+
const row = existing ?? await api.result(destinationsPath, "POST", { email });
|
|
178
|
+
const providerRef = row.id ?? row.tag;
|
|
179
|
+
if (!cfId(providerRef) || row.email?.toLowerCase() !== email)
|
|
180
|
+
throw new CloudflareError(200);
|
|
181
|
+
return { providerRef };
|
|
182
|
+
}
|
|
183
|
+
catch (error) {
|
|
184
|
+
if (error instanceof CloudflareError && (error.status === 401 || error.status === 403)) {
|
|
185
|
+
throw new UnsupportedCloudflareOperation("Add the destination in Cloudflare Email Routing or grant Email Routing Addresses Write to the control token, then try again.");
|
|
186
|
+
}
|
|
187
|
+
throw error;
|
|
188
|
+
}
|
|
189
|
+
},
|
|
190
|
+
async destinationStatus(input) {
|
|
191
|
+
if (input.secretRef !== cfg.secretRef || !cfId(input.providerRef) || !await domains.hasZone())
|
|
192
|
+
return "failed";
|
|
193
|
+
const row = (await api.list(destinationsPath)).find((item) => (item.id ?? item.tag) === input.providerRef);
|
|
194
|
+
return row ? typeof row.verified === "string" && Number.isFinite(Date.parse(row.verified)) ? "verified" : "pending" : "failed";
|
|
195
|
+
},
|
|
196
|
+
async removeDestination(_input) {
|
|
197
|
+
// Verification belongs to the Cloudflare account and may be in use by other zones or sending.
|
|
198
|
+
},
|
|
199
|
+
};
|
|
200
|
+
}
|
|
201
|
+
//# sourceMappingURL=routing.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"routing.js","sourceRoot":"","sources":["../src/routing.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,eAAe,EAAsB,MAAM,UAAU,CAAC;AAC/D,OAAO,EAAE,IAAI,EAAyB,MAAM,aAAa,CAAC;AAC1D,OAAO,EAAE,cAAc,EAAmB,MAAM,cAAc,CAAC;AAe/D,MAAM,MAAM,GAAG,CAAC,KAAa,EAAc,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC,CAAC;AAC5E,MAAM,aAAa,GAAG,wBAAwB,CAAC;AAC/C,MAAM,UAAU,GAAG,CAAC,OAAe,EAAE,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;AAExG,MAAM,OAAO,8BAA+B,SAAQ,KAAK;IACvD,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,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,GAAG,CAAC,SAAS,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,IAAI,CAAC,MAAM,OAAO,CAAC,OAAO,EAAE;gBAAE,OAAO,QAAQ,CAAC;YAC/G,MAAM,GAAG,GAAG,CAAC,MAAM,GAAG,CAAC,IAAI,CAAgB,gBAAgB,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,EAAE,IAAI,IAAI,CAAC,GAAG,CAAC,KAAK,KAAK,CAAC,WAAW,CAAC,CAAC;YAC1H,OAAO,GAAG,CAAC,CAAC,CAAC,OAAO,GAAG,CAAC,QAAQ,KAAK,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,QAAQ,CAAC;QACjI,CAAC;QACD,KAAK,CAAC,iBAAiB,CAAC,MAAkD;YACxE,8FAA8F;QAChG,CAAC;KACF,CAAC;AACJ,CAAC"}
|
package/dist/send.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type CloudflareApi } from "./api.js";
|
|
2
|
+
import type { CloudflareConfig } from "./config.js";
|
|
3
|
+
import type { ProviderEvidence, ProviderSendRequest, ProviderSendResult } from "./ports.js";
|
|
4
|
+
export declare const classes: readonly ["system", "notification", "transactional", "conversational"];
|
|
5
|
+
export declare const MAX_RECIPIENTS = 50;
|
|
6
|
+
type RecordEvidence = (events: ProviderEvidence[]) => Promise<void>;
|
|
7
|
+
export declare function outbound(cfg: CloudflareConfig, api: CloudflareApi | null, recordEvidence: RecordEvidence | undefined, checkSend: (recipients: string[]) => Promise<string | null>): (req: ProviderSendRequest) => Promise<ProviderSendResult>;
|
|
8
|
+
export {};
|