@wtfalch/email 0.13.1 → 0.15.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 +390 -12
- package/dist/imip/compose.d.ts +5 -0
- package/dist/imip/compose.js +84 -0
- package/dist/imip/index.d.ts +15 -0
- package/dist/imip/index.js +14 -0
- package/dist/imip/lookup.d.ts +21 -0
- package/dist/imip/lookup.js +26 -0
- package/dist/imip/parse.d.ts +11 -0
- package/dist/imip/parse.js +116 -0
- package/dist/imip/types.d.ts +57 -0
- package/dist/imip/types.js +9 -0
- package/dist/mailbox/client.d.ts +28 -1
- package/dist/mailbox/client.js +51 -0
- package/dist/mailbox/fake/mailbox.js +567 -7
- package/dist/mailbox/index.d.ts +16 -8
- package/dist/mailbox/index.js +8 -4
- package/dist/mailbox/mail.css +13 -0
- package/dist/mailbox/mailboxes.d.ts +95 -1
- package/dist/mailbox/mailboxes.js +243 -1
- package/dist/mailbox/mutate.d.ts +21 -0
- package/dist/mailbox/mutate.js +71 -0
- package/dist/mailbox/quoted.d.ts +94 -0
- package/dist/mailbox/quoted.js +158 -0
- package/dist/mailbox/react/Composer.js +13 -1
- package/dist/mailbox/react/Mail.js +273 -33
- package/dist/mailbox/react/ThreadView.d.ts +13 -1
- package/dist/mailbox/react/ThreadView.js +5 -4
- package/dist/mailbox/react/index.d.ts +3 -1
- package/dist/mailbox/react/index.js +2 -1
- package/dist/mailbox/react/quotedHtml.d.ts +105 -0
- package/dist/mailbox/react/quotedHtml.js +163 -0
- package/dist/mailbox/sieve.d.ts +76 -0
- package/dist/mailbox/sieve.js +241 -0
- package/dist/mailbox/snooze.d.ts +48 -0
- package/dist/mailbox/snooze.js +176 -0
- package/dist/mailbox/submit.d.ts +56 -2
- package/dist/mailbox/submit.js +145 -11
- package/dist/mailbox/threads.js +2 -0
- package/dist/mailbox/types.d.ts +60 -0
- package/dist/mailbox/vacation.d.ts +32 -0
- package/dist/mailbox/vacation.js +79 -0
- package/dist/postmaster/apply.d.ts +154 -1
- package/dist/postmaster/apply.js +336 -1
- package/dist/postmaster/audit.d.ts +22 -1
- package/dist/postmaster/audit.js +7 -0
- package/dist/postmaster/client.d.ts +49 -0
- package/dist/postmaster/client.js +43 -0
- package/dist/postmaster/index.d.ts +6 -3
- package/dist/postmaster/index.js +5 -2
- package/dist/postmaster/mail-copy.d.ts +169 -0
- package/dist/postmaster/mail-copy.js +259 -0
- package/dist/postmaster/objects.js +11 -0
- package/dist/postmaster/org-mail.d.ts +117 -0
- package/dist/postmaster/org-mail.js +206 -0
- package/dist/postmaster/overview.d.ts +4 -0
- package/dist/postmaster/queue.d.ts +111 -0
- package/dist/postmaster/queue.js +64 -0
- package/dist/postmaster/writes.d.ts +59 -0
- package/dist/postmaster/writes.js +106 -0
- package/package.json +8 -3
|
@@ -94,6 +94,31 @@ export function withoutAppPassword(account, credentialId) {
|
|
|
94
94
|
}
|
|
95
95
|
return indexed(existing.filter((c) => c !== target));
|
|
96
96
|
}
|
|
97
|
+
/**
|
|
98
|
+
* The `credentials` list to send so that one API key stops working and
|
|
99
|
+
* every other credential survives.
|
|
100
|
+
*
|
|
101
|
+
* The mirror image of `withoutAppPassword`'s type guard: an entry whose
|
|
102
|
+
* type is not `ApiKey` is not this action's to touch. `Password` is the
|
|
103
|
+
* account's own password; `AppPassword` is a person's, revoked by
|
|
104
|
+
* `withoutAppPassword`. This function's business is exactly the type that
|
|
105
|
+
* one refuses to touch.
|
|
106
|
+
*
|
|
107
|
+
* Surviving entries keep their masked secrets, which the server reads as
|
|
108
|
+
* "leave this one alone" — the behaviour `withPassword` documents and
|
|
109
|
+
* relies on.
|
|
110
|
+
*/
|
|
111
|
+
export function withoutApiKey(account, credentialId) {
|
|
112
|
+
const existing = entriesOf(account.credentials);
|
|
113
|
+
const target = existing.find((c) => c.credentialId === credentialId);
|
|
114
|
+
if (!target) {
|
|
115
|
+
throw new MailWriteRefused('that credential is not on this mailbox any more');
|
|
116
|
+
}
|
|
117
|
+
if (target['@type'] !== 'ApiKey') {
|
|
118
|
+
throw new MailWriteRefused(`that credential is a ${target['@type']}, not an API key; only API keys are revoked here`);
|
|
119
|
+
}
|
|
120
|
+
return indexed(existing.filter((c) => c !== target));
|
|
121
|
+
}
|
|
97
122
|
/**
|
|
98
123
|
* The `Account` to create for a person, mirroring what
|
|
99
124
|
* `scripts/mail-sync.mts` sends, minus the password.
|
|
@@ -129,3 +154,84 @@ export function newAccount(input) {
|
|
|
129
154
|
memberGroupIds: {},
|
|
130
155
|
};
|
|
131
156
|
}
|
|
157
|
+
/**
|
|
158
|
+
* A shared mailbox: `hr@`, `support@`, an address a team reads together
|
|
159
|
+
* rather than a person's own.
|
|
160
|
+
*
|
|
161
|
+
* On the server this is an account like any other — the same object, the
|
|
162
|
+
* same delivery, the same aliases — whose `@type` is `Group` instead of
|
|
163
|
+
* `User`. What makes it shared is on the *people*: an account naming this
|
|
164
|
+
* group in `memberGroupIds` reaches it with their own credential, as a
|
|
165
|
+
* second account in the same JMAP session. So a group is created empty here
|
|
166
|
+
* and filled by `addToGroup`.
|
|
167
|
+
*
|
|
168
|
+
* It takes no password and no `external` flag, unlike `newAccount`: nobody
|
|
169
|
+
* ever signs in as a shared mailbox, so there is no first secret to show
|
|
170
|
+
* once, and the question a personal mailbox has to ask — does this domain
|
|
171
|
+
* keep its own passwords — does not arise.
|
|
172
|
+
*/
|
|
173
|
+
export function newGroup(input) {
|
|
174
|
+
const local = input.local.trim().toLowerCase();
|
|
175
|
+
if (!local)
|
|
176
|
+
throw new MailWriteRefused('a shared mailbox needs a name');
|
|
177
|
+
if (local.includes('@')) {
|
|
178
|
+
throw new MailWriteRefused(`"${input.local}" looks like a whole address; a mailbox is named by its local part`);
|
|
179
|
+
}
|
|
180
|
+
return {
|
|
181
|
+
'@type': 'Group',
|
|
182
|
+
name: local,
|
|
183
|
+
domainId: input.domainId,
|
|
184
|
+
description: input.description ?? null,
|
|
185
|
+
roles: { '@type': 'Default' },
|
|
186
|
+
permissions: { '@type': 'Inherit' },
|
|
187
|
+
quotas: {},
|
|
188
|
+
aliases: {},
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* The `memberGroupIds` to send so that this account also reads `groupId`.
|
|
193
|
+
*
|
|
194
|
+
* **A membership map is a set, not a list.** The server sends and takes
|
|
195
|
+
* `{"<id>": true}`, and an entry whose value is not `true` is dropped on the
|
|
196
|
+
* way in, so what is sent is the whole surviving set — the same replace-the-
|
|
197
|
+
* lot rule as `aliases`, and the same reason these functions are worth
|
|
198
|
+
* testing.
|
|
199
|
+
*
|
|
200
|
+
* A duplicate is refused rather than sent, because sending it would report
|
|
201
|
+
* that somebody was added when the set was already exactly this.
|
|
202
|
+
*/
|
|
203
|
+
export function withMembership(account, groupId) {
|
|
204
|
+
const wanted = groupId.trim();
|
|
205
|
+
if (!wanted)
|
|
206
|
+
throw new MailWriteRefused('a membership needs a shared mailbox to name');
|
|
207
|
+
const existing = membershipIds(account);
|
|
208
|
+
if (existing.includes(wanted)) {
|
|
209
|
+
throw new MailWriteRefused('this person already reads that shared mailbox');
|
|
210
|
+
}
|
|
211
|
+
return asSet([...existing, wanted]);
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* The `memberGroupIds` to send so that this account no longer reads
|
|
215
|
+
* `groupId`. Refuses when the membership is absent, so a stale page cannot
|
|
216
|
+
* send the set back unchanged and report that it took access away.
|
|
217
|
+
*/
|
|
218
|
+
export function withoutMembership(account, groupId) {
|
|
219
|
+
const wanted = groupId.trim();
|
|
220
|
+
const existing = membershipIds(account);
|
|
221
|
+
const kept = existing.filter((id) => id !== wanted);
|
|
222
|
+
if (kept.length === existing.length) {
|
|
223
|
+
throw new MailWriteRefused('this person does not read that shared mailbox');
|
|
224
|
+
}
|
|
225
|
+
return asSet(kept);
|
|
226
|
+
}
|
|
227
|
+
/** The group ids on an account, in the order the server sent them. Only
|
|
228
|
+
* entries the server marked `true` count: it drops the others on read, so a
|
|
229
|
+
* write that kept them would add back what somebody just removed. */
|
|
230
|
+
export function membershipIds(account) {
|
|
231
|
+
return Object.entries(account.memberGroupIds ?? {})
|
|
232
|
+
.filter(([, on]) => on === true)
|
|
233
|
+
.map(([id]) => id);
|
|
234
|
+
}
|
|
235
|
+
function asSet(ids) {
|
|
236
|
+
return Object.fromEntries(ids.map((id) => [id, true]));
|
|
237
|
+
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wtfalch/email",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "The wtfalch estate: reading a mailbox over JMAP,
|
|
3
|
+
"version": "0.15.0",
|
|
4
|
+
"description": "The wtfalch estate: reading a mailbox over JMAP, administering the Stalwart server it lives on, and iTIP scheduling over iMIP. Three entries with no code in common.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"repository": {
|
|
@@ -22,6 +22,10 @@
|
|
|
22
22
|
"default": "./dist/mailbox/fake/index.js"
|
|
23
23
|
},
|
|
24
24
|
"./mailbox/mail.css": "./dist/mailbox/mail.css",
|
|
25
|
+
"./imip": {
|
|
26
|
+
"types": "./dist/imip/index.d.ts",
|
|
27
|
+
"default": "./dist/imip/index.js"
|
|
28
|
+
},
|
|
25
29
|
"./postmaster": {
|
|
26
30
|
"browser": "./dist/postmaster/browser-refusal.js",
|
|
27
31
|
"types": "./dist/postmaster/index.d.ts",
|
|
@@ -75,8 +79,9 @@
|
|
|
75
79
|
"engines": {
|
|
76
80
|
"node": ">=22.0.0"
|
|
77
81
|
},
|
|
78
|
-
"keywords": ["jmap", "email", "mail", "stalwart", "rfc8621"],
|
|
82
|
+
"keywords": ["jmap", "email", "mail", "stalwart", "rfc8621", "itip", "imip", "icalendar"],
|
|
79
83
|
"dependencies": {
|
|
84
|
+
"ical.js": "2.2.1",
|
|
80
85
|
"jmap-jam": "^0.13.6"
|
|
81
86
|
}
|
|
82
87
|
}
|