@repa/mail 0.1.0-alpha.20 → 0.1.0-alpha.22
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 +75 -3
- package/dist/browser-denied.d.ts +1 -1
- package/dist/{chunk-CXNVFCRT.js → chunk-C27HOMPC.js} +183 -28
- package/dist/contracts.d.ts +434 -6
- package/dist/contracts.js +1 -1
- package/dist/{errors-B_W1C1Hu.d.ts → errors-VxeL4C8r.d.ts} +1 -1
- package/dist/index.d.ts +107 -109
- package/dist/index.js +7 -2
- package/dist/{operations-14iYfteB.d.ts → operations-g1slmaT3.d.ts} +626 -7
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,21 +1,24 @@
|
|
|
1
|
-
import { H as HeadlessInput, S as Submission, D as DraftAction, a as DraftInput, b as DraftResult,
|
|
2
|
-
export {
|
|
3
|
-
import { E as
|
|
4
|
-
export { j as EmailAttachment, m as EmailDomainSendScope, l as EmailDomainSender, h as EmailError, i as EmailErrorCode, q as EmailEvent, p as EmailEventType, k as EmailExactSender, o as EmailFeedbackType, n as EmailSubmissionState } from './errors-
|
|
1
|
+
import { H as HeadlessInput, N as NewTextMessage, M as Message, S as Submission, D as DraftAction, a as DraftInput, b as DraftResult, c as MailTransport } from './operations-g1slmaT3.js';
|
|
2
|
+
export { d as HeadlessResult, k as MailboxRules, s as NewTextConfidence, p as NewTextInfo, r as NewTextOutcome, q as NewTextRemoved, t as NewTextSignatureReason, u as ReadContent, R as Rule, e as RuleActions, f as RuleCondition, g as RuleForward, h as RuleItem, i as RuleItemInput, j as RuleVacation, l as RulesChecked, m as RulesNotice, n as RulesProblem, o as RulesSaved } from './operations-g1slmaT3.js';
|
|
3
|
+
import { E as EmailRequestOptions, a as EmailClientOptions, b as EmailSender, c as EmailMessage, d as EmailSendOptions, e as EmailSubmission, f as EmailEventPage, g as EmailWebhookEvent } from './errors-VxeL4C8r.js';
|
|
4
|
+
export { j as EmailAttachment, m as EmailDomainSendScope, l as EmailDomainSender, h as EmailError, i as EmailErrorCode, q as EmailEvent, p as EmailEventType, k as EmailExactSender, o as EmailFeedbackType, n as EmailSubmissionState } from './errors-VxeL4C8r.js';
|
|
5
5
|
import 'zod';
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
7
|
+
type HeadlessCaller = <T>(path: string, decode: (value: unknown) => T, options: EmailRequestOptions, body: {
|
|
8
|
+
body: string;
|
|
9
|
+
key?: string;
|
|
10
|
+
}, operationId?: string, lookupKey?: string, maximum?: number) => Promise<T>;
|
|
11
|
+
/** `content: 'new'` returns what the sender wrote without the quoted chain, with `newText` saying what was
|
|
12
|
+
* removed (EMAIL-D240); without it (or `'full'`) the whole message. */
|
|
13
|
+
type ReadMessage = {
|
|
14
|
+
(input: HeadlessInput<'read'> & {
|
|
15
|
+
content: 'new';
|
|
16
|
+
}, options?: EmailRequestOptions): Promise<NewTextMessage>;
|
|
17
|
+
(input: HeadlessInput<'read'> & {
|
|
18
|
+
content?: 'full';
|
|
19
|
+
}, options?: EmailRequestOptions): Promise<Message>;
|
|
20
|
+
};
|
|
21
|
+
declare function headlessMethods(call: HeadlessCaller): {
|
|
19
22
|
listMailboxes: (input: HeadlessInput<"mailboxes">, options?: EmailRequestOptions) => Promise<{
|
|
20
23
|
mailboxes: {
|
|
21
24
|
id: string;
|
|
@@ -57,40 +60,7 @@ declare function createEmailClient(options: EmailClientOptions): Readonly<{
|
|
|
57
60
|
hasMore: boolean;
|
|
58
61
|
count: number;
|
|
59
62
|
}>;
|
|
60
|
-
readMessage:
|
|
61
|
-
entry: {
|
|
62
|
-
uid: number;
|
|
63
|
-
id: string;
|
|
64
|
-
flags: number;
|
|
65
|
-
date: string;
|
|
66
|
-
octets: number;
|
|
67
|
-
preview: string;
|
|
68
|
-
hasAttachment: boolean;
|
|
69
|
-
subject: string;
|
|
70
|
-
from: string;
|
|
71
|
-
to: string;
|
|
72
|
-
};
|
|
73
|
-
headers: {
|
|
74
|
-
subject: string;
|
|
75
|
-
from: string;
|
|
76
|
-
to: string;
|
|
77
|
-
cc: string;
|
|
78
|
-
replyTo: string;
|
|
79
|
-
messageId: string;
|
|
80
|
-
unsubscribe?: string | undefined;
|
|
81
|
-
};
|
|
82
|
-
text: string;
|
|
83
|
-
html: string;
|
|
84
|
-
attachments: {
|
|
85
|
-
part: string;
|
|
86
|
-
name: string;
|
|
87
|
-
type: string;
|
|
88
|
-
octets: number;
|
|
89
|
-
contentId?: string | undefined;
|
|
90
|
-
}[];
|
|
91
|
-
warnings: ("incomplete_scan" | "hosted_domain_unaligned" | "link_text_mismatch" | "lookalike_brand" | "lookalike_tenant" | "homograph_domain" | "credential_form" | "dangerous_attachment" | "encrypted_archive")[];
|
|
92
|
-
incomplete: boolean;
|
|
93
|
-
}>;
|
|
63
|
+
readMessage: ReadMessage;
|
|
94
64
|
listConversations: (input: HeadlessInput<"conversations">, options?: EmailRequestOptions) => Promise<{
|
|
95
65
|
conversations: {
|
|
96
66
|
id: string;
|
|
@@ -145,6 +115,33 @@ declare function createEmailClient(options: EmailClientOptions): Readonly<{
|
|
|
145
115
|
quoted: boolean;
|
|
146
116
|
signature: string;
|
|
147
117
|
truncated: boolean;
|
|
118
|
+
newText: {
|
|
119
|
+
outcome: "cut" | "whole" | "unreadable";
|
|
120
|
+
confidence: "proven" | "structural" | "none";
|
|
121
|
+
reason: string;
|
|
122
|
+
extractorVersion: number;
|
|
123
|
+
fullTextBytes: number;
|
|
124
|
+
signatureReason: "" | "rfc3676_delimiter" | "html_signature" | "sender_learned";
|
|
125
|
+
removed: {
|
|
126
|
+
kind: "quote" | "forward_header" | "signature";
|
|
127
|
+
messageId: string | null;
|
|
128
|
+
headerId: string | null;
|
|
129
|
+
bytes: number;
|
|
130
|
+
}[];
|
|
131
|
+
} | {
|
|
132
|
+
outcome: "";
|
|
133
|
+
confidence: "";
|
|
134
|
+
reason: "";
|
|
135
|
+
extractorVersion: 0;
|
|
136
|
+
fullTextBytes: 0;
|
|
137
|
+
signatureReason: "";
|
|
138
|
+
removed: {
|
|
139
|
+
kind: "quote" | "forward_header" | "signature";
|
|
140
|
+
messageId: string | null;
|
|
141
|
+
headerId: string | null;
|
|
142
|
+
bytes: number;
|
|
143
|
+
}[];
|
|
144
|
+
};
|
|
148
145
|
};
|
|
149
146
|
hasHTML: boolean;
|
|
150
147
|
attachments: {
|
|
@@ -196,6 +193,8 @@ declare function createEmailClient(options: EmailClientOptions): Readonly<{
|
|
|
196
193
|
warningPercent: 0 | 80 | 95;
|
|
197
194
|
workspaceWarningPercent: 0 | 80 | 95;
|
|
198
195
|
}>;
|
|
196
|
+
/** Mailbox rules need the "Read and organize" level or higher. Writes are compare-and-swap on
|
|
197
|
+
* `expectedRevision` (0: no rules yet) and send no Idempotency-Key; a refusal resolves `{status: 'rejected'}`. */
|
|
199
198
|
getRules: (input: HeadlessInput<"rulesGet">, options?: EmailRequestOptions) => Promise<{
|
|
200
199
|
accountId: string;
|
|
201
200
|
kind: "personal" | "shared";
|
|
@@ -467,25 +466,23 @@ declare function createEmailClient(options: EmailClientOptions): Readonly<{
|
|
|
467
466
|
state: "queued";
|
|
468
467
|
}>;
|
|
469
468
|
draft: <K extends DraftAction>(action: K, input: DraftInput<K>, options?: EmailRequestOptions) => Promise<DraftResult<K>>;
|
|
470
|
-
}
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
* secret from trusted endpoint configuration, never from request parameters. */
|
|
475
|
-
declare function verifyEmailWebhook(input: {
|
|
476
|
-
readonly body: Uint8Array;
|
|
477
|
-
readonly headers: Headers | Readonly<Record<string, string>>;
|
|
478
|
-
readonly endpointId: string;
|
|
479
|
-
readonly secrets: Readonly<Record<number, string>>;
|
|
480
|
-
readonly now?: Date;
|
|
481
|
-
readonly toleranceSeconds?: number;
|
|
482
|
-
}): EmailWebhookEvent;
|
|
469
|
+
};
|
|
470
|
+
/** Install only on the host backend. Bind the client subject to the host's
|
|
471
|
+
* authenticated session and enforce that user's mailbox policy before calls. */
|
|
472
|
+
declare function createMailTransport(client: ReturnType<typeof headlessMethods>): MailTransport;
|
|
483
473
|
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
474
|
+
declare const REPA_EMAIL_API_BASE_URL = "https://api.repa.run";
|
|
475
|
+
/** No automatic retries: after any uncertain result, look up the original key
|
|
476
|
+
* or replay the same frozen request. Never allocate a replacement identity. */
|
|
477
|
+
declare function createEmailClient(options: EmailClientOptions): Readonly<{
|
|
478
|
+
listSenders: (request?: EmailRequestOptions) => Promise<readonly EmailSender[]>;
|
|
479
|
+
send: (message: EmailMessage, request: EmailSendOptions) => Promise<EmailSubmission>;
|
|
480
|
+
getSubmission: (operationId: string, request?: EmailRequestOptions) => Promise<EmailSubmission>;
|
|
481
|
+
findSubmissionByKey: (idempotencyKey: string, request?: EmailRequestOptions) => Promise<EmailSubmission>;
|
|
482
|
+
listEvents: (page?: {
|
|
483
|
+
after?: number;
|
|
484
|
+
limit?: number;
|
|
485
|
+
}, request?: EmailRequestOptions) => Promise<EmailEventPage>;
|
|
489
486
|
listMailboxes: (input: HeadlessInput<"mailboxes">, options?: EmailRequestOptions) => Promise<{
|
|
490
487
|
mailboxes: {
|
|
491
488
|
id: string;
|
|
@@ -527,40 +524,7 @@ declare function headlessMethods(call: HeadlessCaller): {
|
|
|
527
524
|
hasMore: boolean;
|
|
528
525
|
count: number;
|
|
529
526
|
}>;
|
|
530
|
-
readMessage:
|
|
531
|
-
entry: {
|
|
532
|
-
uid: number;
|
|
533
|
-
id: string;
|
|
534
|
-
flags: number;
|
|
535
|
-
date: string;
|
|
536
|
-
octets: number;
|
|
537
|
-
preview: string;
|
|
538
|
-
hasAttachment: boolean;
|
|
539
|
-
subject: string;
|
|
540
|
-
from: string;
|
|
541
|
-
to: string;
|
|
542
|
-
};
|
|
543
|
-
headers: {
|
|
544
|
-
subject: string;
|
|
545
|
-
from: string;
|
|
546
|
-
to: string;
|
|
547
|
-
cc: string;
|
|
548
|
-
replyTo: string;
|
|
549
|
-
messageId: string;
|
|
550
|
-
unsubscribe?: string | undefined;
|
|
551
|
-
};
|
|
552
|
-
text: string;
|
|
553
|
-
html: string;
|
|
554
|
-
attachments: {
|
|
555
|
-
part: string;
|
|
556
|
-
name: string;
|
|
557
|
-
type: string;
|
|
558
|
-
octets: number;
|
|
559
|
-
contentId?: string | undefined;
|
|
560
|
-
}[];
|
|
561
|
-
warnings: ("incomplete_scan" | "hosted_domain_unaligned" | "link_text_mismatch" | "lookalike_brand" | "lookalike_tenant" | "homograph_domain" | "credential_form" | "dangerous_attachment" | "encrypted_archive")[];
|
|
562
|
-
incomplete: boolean;
|
|
563
|
-
}>;
|
|
527
|
+
readMessage: ReadMessage;
|
|
564
528
|
listConversations: (input: HeadlessInput<"conversations">, options?: EmailRequestOptions) => Promise<{
|
|
565
529
|
conversations: {
|
|
566
530
|
id: string;
|
|
@@ -615,6 +579,33 @@ declare function headlessMethods(call: HeadlessCaller): {
|
|
|
615
579
|
quoted: boolean;
|
|
616
580
|
signature: string;
|
|
617
581
|
truncated: boolean;
|
|
582
|
+
newText: {
|
|
583
|
+
outcome: "cut" | "whole" | "unreadable";
|
|
584
|
+
confidence: "proven" | "structural" | "none";
|
|
585
|
+
reason: string;
|
|
586
|
+
extractorVersion: number;
|
|
587
|
+
fullTextBytes: number;
|
|
588
|
+
signatureReason: "" | "rfc3676_delimiter" | "html_signature" | "sender_learned";
|
|
589
|
+
removed: {
|
|
590
|
+
kind: "quote" | "forward_header" | "signature";
|
|
591
|
+
messageId: string | null;
|
|
592
|
+
headerId: string | null;
|
|
593
|
+
bytes: number;
|
|
594
|
+
}[];
|
|
595
|
+
} | {
|
|
596
|
+
outcome: "";
|
|
597
|
+
confidence: "";
|
|
598
|
+
reason: "";
|
|
599
|
+
extractorVersion: 0;
|
|
600
|
+
fullTextBytes: 0;
|
|
601
|
+
signatureReason: "";
|
|
602
|
+
removed: {
|
|
603
|
+
kind: "quote" | "forward_header" | "signature";
|
|
604
|
+
messageId: string | null;
|
|
605
|
+
headerId: string | null;
|
|
606
|
+
bytes: number;
|
|
607
|
+
}[];
|
|
608
|
+
};
|
|
618
609
|
};
|
|
619
610
|
hasHTML: boolean;
|
|
620
611
|
attachments: {
|
|
@@ -666,8 +657,6 @@ declare function headlessMethods(call: HeadlessCaller): {
|
|
|
666
657
|
warningPercent: 0 | 80 | 95;
|
|
667
658
|
workspaceWarningPercent: 0 | 80 | 95;
|
|
668
659
|
}>;
|
|
669
|
-
/** Mailbox rules need the "Read and organize" level or higher. Writes are compare-and-swap on
|
|
670
|
-
* `expectedRevision` (0: no rules yet) and send no Idempotency-Key; a refusal resolves `{status: 'rejected'}`. */
|
|
671
660
|
getRules: (input: HeadlessInput<"rulesGet">, options?: EmailRequestOptions) => Promise<{
|
|
672
661
|
accountId: string;
|
|
673
662
|
kind: "personal" | "shared";
|
|
@@ -939,9 +928,18 @@ declare function headlessMethods(call: HeadlessCaller): {
|
|
|
939
928
|
state: "queued";
|
|
940
929
|
}>;
|
|
941
930
|
draft: <K extends DraftAction>(action: K, input: DraftInput<K>, options?: EmailRequestOptions) => Promise<DraftResult<K>>;
|
|
942
|
-
}
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
931
|
+
}>;
|
|
932
|
+
type EmailClient = ReturnType<typeof createEmailClient>;
|
|
933
|
+
|
|
934
|
+
/** Verify the exact received bytes before JSON parsing. Resolve the versioned
|
|
935
|
+
* secret from trusted endpoint configuration, never from request parameters. */
|
|
936
|
+
declare function verifyEmailWebhook(input: {
|
|
937
|
+
readonly body: Uint8Array;
|
|
938
|
+
readonly headers: Headers | Readonly<Record<string, string>>;
|
|
939
|
+
readonly endpointId: string;
|
|
940
|
+
readonly secrets: Readonly<Record<number, string>>;
|
|
941
|
+
readonly now?: Date;
|
|
942
|
+
readonly toleranceSeconds?: number;
|
|
943
|
+
}): EmailWebhookEvent;
|
|
946
944
|
|
|
947
|
-
export { DraftAction, DraftInput, DraftResult, type EmailClient, EmailClientOptions, EmailEventPage, EmailMessage, EmailRequestOptions, EmailSendOptions, EmailSender, EmailSubmission, EmailWebhookEvent, HeadlessInput, MailTransport, REPA_EMAIL_API_BASE_URL, createEmailClient, createMailTransport, verifyEmailWebhook };
|
|
945
|
+
export { DraftAction, DraftInput, DraftResult, type EmailClient, EmailClientOptions, EmailEventPage, EmailMessage, EmailRequestOptions, EmailSendOptions, EmailSender, EmailSubmission, EmailWebhookEvent, HeadlessInput, MailTransport, Message, NewTextMessage, REPA_EMAIL_API_BASE_URL, type ReadMessage, createEmailClient, createMailTransport, verifyEmailWebhook };
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { MAXIMUM_SEND_BODY_BYTES, MAXIMUM_SEND_BYTES, headlessOperations } from './chunk-
|
|
1
|
+
import { MAXIMUM_SEND_BODY_BYTES, MAXIMUM_SEND_BYTES, headlessOperations } from './chunk-C27HOMPC.js';
|
|
2
2
|
import { EmailError, publicErrorCodes } from './chunk-XW4CRZRY.js';
|
|
3
3
|
export { EmailError } from './chunk-XW4CRZRY.js';
|
|
4
4
|
import { createHmac, timingSafeEqual } from 'crypto';
|
|
@@ -18,12 +18,17 @@ function headlessMethods(call) {
|
|
|
18
18
|
return result.data;
|
|
19
19
|
}, options, { body, ...key ? { key } : {} }, void 0, void 0, operation.responseBytes);
|
|
20
20
|
}
|
|
21
|
+
const readMessage = (async (input, options) => {
|
|
22
|
+
const message = await invoke("read", input, options);
|
|
23
|
+
if ("newText" in message !== (input.content === "new")) throw new EmailError("PROTOCOL");
|
|
24
|
+
return message;
|
|
25
|
+
});
|
|
21
26
|
const draftNames = { schedule: "draftSchedule", unschedule: "draftUnschedule", list: "draftList", get: "draftGet", save: "draftSave", discard: "draftDiscard", prepare: "draftPrepare", send: "draftSend" };
|
|
22
27
|
return {
|
|
23
28
|
listMailboxes: (input, options) => invoke("mailboxes", input, options),
|
|
24
29
|
openMailbox: (accountId, options) => invoke("open", { accountId }, options),
|
|
25
30
|
listMessages: (input, options) => invoke("list", input, options),
|
|
26
|
-
readMessage
|
|
31
|
+
readMessage,
|
|
27
32
|
listConversations: (input, options) => invoke("conversations", input, options),
|
|
28
33
|
readConversation: (input, options) => invoke("conversation", input, options),
|
|
29
34
|
downloadMessage: (input, options) => invoke("download", input, options),
|