clavarium 0.2.230-next.1 → 0.2.232-next.1
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/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
- package/server/accounts.mjs +2 -1
- package/server/api.mjs +9 -0
- package/server/mailbox.mjs +9 -0
- package/web/app.js +60 -8
- package/web/index.html +7 -8
- package/web/style.css +7 -0
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "clavarium",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.232-next.1",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "clavarium",
|
|
9
|
-
"version": "0.2.
|
|
9
|
+
"version": "0.2.232-next.1",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@xterm/addon-fit": "^0.11.0",
|
package/package.json
CHANGED
package/server/accounts.mjs
CHANGED
|
@@ -130,7 +130,8 @@ export class Accounts {
|
|
|
130
130
|
const specs = [];
|
|
131
131
|
for (const k of wanted) {
|
|
132
132
|
const config = { user: address };
|
|
133
|
-
|
|
133
|
+
/* Its sending server too, unless none is given: then it reads, moves and flags, and refuses to send (02-11). */
|
|
134
|
+
if (k === 'mail') { const i = hostPort(imap, 'mail (IMAP)', 993); Object.assign(config, { host: i.host, port: i.port }); if (String(smtp ?? '').trim()) { const o = hostPort(smtp, 'sending (SMTP)', 587); Object.assign(config, { smtpHost: o.host, smtpPort: o.port }); } }
|
|
134
135
|
if (k === 'calendar') config.caldav = davUrl(caldav, 'calendar (CalDAV)');
|
|
135
136
|
if (k === 'contacts') config.carddav = davUrl(carddav, 'contacts (CardDAV)');
|
|
136
137
|
specs.push({ id: targetId(k, 'classic', address), title: `${KIND[k].title} — ${address}`, kind: KIND[k].kind, connector: KIND[k].connector, config, secrets: { password: name } });
|
package/server/api.mjs
CHANGED
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
* POST /api/conversations/<name>/health/seen what it says now no longer calls its owner (Needs you)
|
|
15
15
|
* POST /api/conversations/<name>/exit-report why its tool ended: { now (read in its machine, if it runs), last (kept at its end) }
|
|
16
16
|
* POST /api/conversations/<name>/archive
|
|
17
|
+
* POST /api/mailboxes/<name>/live {smtp, email?}: that mailbox connected live too (send, move...), its password reused
|
|
17
18
|
* POST /api/conversations/<name>/erase {confirm: <its name>}: deleted for good -- its machine and its work files
|
|
18
19
|
* POST /api/conversations/<name>/rebuild {reset?, confirm?}: built again; reset (confirm: its name) for a working one too
|
|
19
20
|
* POST /api/conversations/<name>/ask-first {on}: its tool asks before acting (true), or acts without asking in its machine (false, the default), from its next start
|
|
@@ -453,6 +454,14 @@ export async function handleApi(request, response, conversations, headers, resou
|
|
|
453
454
|
if (pathname === '/api/accounts/connect' && accounts) { const made = await accounts.connect(body); return send(201, made), true; }
|
|
454
455
|
if (pathname === '/api/accounts/lookup' && accounts) return send(200, await accounts.lookup(body)), true;
|
|
455
456
|
if (pathname === '/api/accounts/classic' && accounts) { const made = await accounts.classic(body); return send(201, made), true; }
|
|
457
|
+
/* A mailbox of Assets, connected live too (send, move...): its address and password reused, server side. */
|
|
458
|
+
const live = /^\/api\/mailboxes\/([a-z0-9-]{1,32})\/live$/.exec(pathname);
|
|
459
|
+
if (live && accounts && mailboxes) {
|
|
460
|
+
const c = mailboxes.credentials(live[1]);
|
|
461
|
+
const user = String(body?.email ?? c.user).trim();
|
|
462
|
+
const made = await accounts.classic({ user, password: c.password, imap: `${c.host}:${c.port}`, smtp: String(body?.smtp ?? ''), kinds: ['mail'] });
|
|
463
|
+
return send(201, made), true;
|
|
464
|
+
}
|
|
456
465
|
if (pathname === '/api/accounts/verify' && accounts) { const r = await accounts.verify(body); return send(200, r), true; }
|
|
457
466
|
/* Assets > Access: the owner sets a conversation's level and rules on a
|
|
458
467
|
target, decides a call that waited, or removes a target. Each is an op the
|
package/server/mailbox.mjs
CHANGED
|
@@ -134,6 +134,15 @@ export class Mailboxes {
|
|
|
134
134
|
return this.#store.all().map((m) => ({ name: m.name, host: m.host, port: m.port ?? 993, user: m.user, provider: m.provider ?? null, messages: m.messages ?? 0, syncedAt: m.syncedAt ?? null, failure: m.failure ?? null }));
|
|
135
135
|
}
|
|
136
136
|
|
|
137
|
+
/* What a live link needs to be made from it (02-11: a mailbox of Assets given the same actions as a
|
|
138
|
+
connected account): server side only, never to the page. A classic one only (a password). */
|
|
139
|
+
credentials(name) {
|
|
140
|
+
const m = this.#store.get(name);
|
|
141
|
+
if (!m) throw new Refusal(404, 'No such mailbox.');
|
|
142
|
+
if (m.provider) throw new Refusal(400, 'This mailbox signs in with Google or Microsoft: connect that account in Access instead.');
|
|
143
|
+
return { host: m.host, port: m.port ?? 993, user: m.user, password: this.#vault.open(m.sealed) };
|
|
144
|
+
}
|
|
145
|
+
|
|
137
146
|
/* Adds a mailbox after proving it can be read, as a folder of that name. */
|
|
138
147
|
async add(body) {
|
|
139
148
|
const name = String(body?.name ?? '');
|
package/web/app.js
CHANGED
|
@@ -4646,6 +4646,35 @@
|
|
|
4646
4646
|
const r = chosen.resource;
|
|
4647
4647
|
/* State, in a line. */
|
|
4648
4648
|
if (chosen.kind === 'mailbox' && !chosen.target) detail.append(el('p', chosen.box?.failure ? 'error' : 'hint', boxSub(chosen.box)));
|
|
4649
|
+
/* ACTIONS TOO (02-11): a mailbox copied as files is read only; the same mailbox, connected live, can
|
|
4650
|
+
send, reply, move, flag -- within the rights given. Made here with its address and password (they
|
|
4651
|
+
stay on the server); only its sending server is asked, found from the address when known. */
|
|
4652
|
+
if (chosen.kind === 'mailbox' && !chosen.target && chosen.box && !chosen.box.provider) {
|
|
4653
|
+
const live = el('div', 'as-live');
|
|
4654
|
+
const go = el('button', '', 'Also allow actions (send, move…)'); go.type = 'button';
|
|
4655
|
+
live.append(el('p', 'hint', 'Read only here. Connected live too, an agent can send, reply, move or flag its mail, each within the rights you give.'), go);
|
|
4656
|
+
go.addEventListener('click', async () => {
|
|
4657
|
+
go.hidden = true;
|
|
4658
|
+
const box = chosen.box; const emailLike = String(box.user ?? '').includes('@');
|
|
4659
|
+
const email = el('input'); email.type = 'email'; email.value = emailLike ? box.user : ''; email.placeholder = 'its email address'; email.setAttribute('aria-label', 'Email address');
|
|
4660
|
+
const smtp = el('input'); smtp.placeholder = 'smtp.example.com'; smtp.spellcheck = false; smtp.setAttribute('aria-label', 'Sending server (SMTP)');
|
|
4661
|
+
const make = el('button', 'primary', 'Connect'); make.type = 'button';
|
|
4662
|
+
const said = el('p', 'error'); said.hidden = true;
|
|
4663
|
+
const form = el('div', 'as-live-form');
|
|
4664
|
+
form.append(el('label', '', 'Email address'), email, el('label', '', 'Sending server (SMTP)'), smtp, make, said);
|
|
4665
|
+
live.append(form);
|
|
4666
|
+
const guess = async () => { try { const found = await post(`${API}/accounts/lookup`, { user: email.value.trim() }); if (found?.smtp && !smtp.value.trim()) smtp.value = found.smtp; } catch { /* typed by hand */ } if (!smtp.value.trim() && box.host) smtp.value = String(box.host).replace(/^imap\./, 'smtp.'); };
|
|
4667
|
+
if (email.value) void guess();
|
|
4668
|
+
email.addEventListener('change', () => void guess());
|
|
4669
|
+
make.addEventListener('click', async () => {
|
|
4670
|
+
make.disabled = true; make.textContent = 'Trying it…'; said.hidden = true;
|
|
4671
|
+
try { await post(`${API}/mailboxes/${encodeURIComponent(box.name)}/live`, { email: email.value.trim(), smtp: smtp.value.trim() }); void paintAssets(); }
|
|
4672
|
+
catch (error) { said.textContent = error.message; said.hidden = false; make.disabled = false; make.textContent = 'Connect'; }
|
|
4673
|
+
});
|
|
4674
|
+
focusField(smtp.value ? make : smtp);
|
|
4675
|
+
});
|
|
4676
|
+
detail.append(live);
|
|
4677
|
+
}
|
|
4649
4678
|
/* A live link: what it is, and that it is associated with the same account's others. */
|
|
4650
4679
|
if (chosen.target) {
|
|
4651
4680
|
const t = chosen.target;
|
|
@@ -7001,25 +7030,48 @@
|
|
|
7001
7030
|
catch (error) { $('assets-error').textContent = error.message; $('assets-error').hidden = false; }
|
|
7002
7031
|
});
|
|
7003
7032
|
|
|
7033
|
+
/* NEW MAILBOX (02-11): an IMAP mailbox is connected LIVE by default, as a Microsoft or Google one -- the
|
|
7034
|
+
same levels, through Tether -- with its sending server (SMTP) too, unless "No sending". The former
|
|
7035
|
+
read-only copy as files stays, ticked on purpose. */
|
|
7036
|
+
let mailboxLooked = '';
|
|
7037
|
+
$('mailbox-user').addEventListener('change', async () => {
|
|
7038
|
+
const user = $('mailbox-user').value.trim();
|
|
7039
|
+
if (!user.includes('@') || user === mailboxLooked) return;
|
|
7040
|
+
mailboxLooked = user;
|
|
7041
|
+
try {
|
|
7042
|
+
const found = await post(`${API}/accounts/lookup`, { user });
|
|
7043
|
+
if (found?.imap && !$('mailbox-host').value.trim()) { const [h, p] = String(found.imap).split(':'); $('mailbox-host').value = h; if (p) $('mailbox-port').value = p; }
|
|
7044
|
+
if (found?.smtp && !$('mailbox-smtp').value.trim()) $('mailbox-smtp').value = found.smtp;
|
|
7045
|
+
} catch { /* typed by hand */ }
|
|
7046
|
+
});
|
|
7004
7047
|
$('mailbox-new').addEventListener('submit', async (event) => {
|
|
7005
7048
|
event.preventDefault();
|
|
7006
7049
|
$('mailbox-error').hidden = true;
|
|
7007
7050
|
const button = $('mailbox-new').querySelector('button[type=submit]');
|
|
7008
|
-
button.disabled = true; button.textContent = '
|
|
7051
|
+
button.disabled = true; button.textContent = 'Trying it...';
|
|
7052
|
+
const host = $('mailbox-host').value.trim(); const port = $('mailbox-port').value.trim();
|
|
7009
7053
|
try {
|
|
7010
|
-
await post(`${API}/
|
|
7011
|
-
assetOpen = `
|
|
7054
|
+
const made = await post(`${API}/accounts/classic`, { user: $('mailbox-user').value.trim(), password: $('mailbox-password').value, imap: port ? `${host}:${port}` : host, smtp: $('mailbox-smtp').value.trim(), kinds: ['mail'] });
|
|
7055
|
+
if (made?.targets?.[0]?.id) assetOpen = `connexion:${made.targets[0].id}`;
|
|
7056
|
+
assetsAdding = ''; $('mailbox-new').reset(); mailboxLooked = '';
|
|
7012
7057
|
} catch (error) { $('mailbox-error').textContent = error.message; $('mailbox-error').hidden = false; }
|
|
7013
|
-
button.disabled = false; button.textContent = '
|
|
7058
|
+
button.disabled = false; button.textContent = 'Connect';
|
|
7014
7059
|
await paintAssets();
|
|
7015
7060
|
});
|
|
7016
|
-
/* New mailbox
|
|
7017
|
-
|
|
7018
|
-
straight to adding one. */
|
|
7061
|
+
/* New mailbox: IMAP and SMTP, connected live (02-11). Gmail and Microsoft sign in instead (token kept on
|
|
7062
|
+
the server): "Sign in with them" jumps to that form. */
|
|
7019
7063
|
const MAILBOX_PROVIDER = { google: 'Google', microsoft: 'Microsoft', classic: 'your host' };
|
|
7020
7064
|
/* Which kinds each provider can be connected for (from the server). */
|
|
7021
7065
|
let accountSupported = { google: ['mail', 'calendar', 'contacts'], microsoft: ['mail'], classic: ['mail', 'calendar', 'contacts'] };
|
|
7022
|
-
|
|
7066
|
+
/* From New mailbox: the account form, on the host's kind ("Other") with what was typed here, unless it is Gmail or Microsoft. */
|
|
7067
|
+
$('mailbox-to-connexion').addEventListener('click', async () => {
|
|
7068
|
+
const user = $('mailbox-user').value.trim(); const host = $('mailbox-host').value.trim();
|
|
7069
|
+
assetsAdding = 'connexion'; await paintAssets();
|
|
7070
|
+
const big = /@(gmail|googlemail|outlook|hotmail|live)\./i.test(user) ? (/gmail|googlemail/i.test(user) ? 'google' : 'microsoft') : null;
|
|
7071
|
+
setConnexionProvider(big ?? 'google');
|
|
7072
|
+
if (user.includes('@')) { $('connexion-email').value = user; $('connexion-email').dispatchEvent(new Event('change')); }
|
|
7073
|
+
if (host && !big && !$('connexion-imap').value.trim()) $('connexion-imap').value = host;
|
|
7074
|
+
});
|
|
7023
7075
|
/* CONNECT AN ACCOUNT (Connexions): a live link through Tether. The person signs
|
|
7024
7076
|
in in their own browser; the token is kept on the server, never in a machine.
|
|
7025
7077
|
Both cover mail+calendar+contacts in one go, each landing on the same
|
package/web/index.html
CHANGED
|
@@ -541,18 +541,17 @@
|
|
|
541
541
|
<p id="git-keys-empty" class="hint">No key yet: "New key" in Add a repository makes one.</p>
|
|
542
542
|
</div>
|
|
543
543
|
<div id="mailbox-box" class="as-form" data-kind="mailbox"><h3>New mailbox</h3>
|
|
544
|
-
<div class="hint">
|
|
545
|
-
<
|
|
546
|
-
|
|
547
|
-
<
|
|
548
|
-
<input id="mailbox-name" maxlength="32" pattern="[a-z]([a-z0-9-]{0,30}[a-z0-9])?" placeholder="inbox" spellcheck="false" autocapitalize="off" required>
|
|
544
|
+
<div class="hint">Its IMAP and SMTP settings, like any mail app. What a conversation may do with it is chosen when you give it to one. Gmail or Microsoft? <button type="button" id="mailbox-to-connexion" class="as-link">Sign in with them</button></div>
|
|
545
|
+
<form id="mailbox-new" autocomplete="off" data-provider="imap" data-how="live">
|
|
546
|
+
<label for="mailbox-user">Email address</label>
|
|
547
|
+
<input id="mailbox-user" inputmode="email" spellcheck="false" autocapitalize="off" autocomplete="off" placeholder="you@example.com">
|
|
549
548
|
<label for="mailbox-host">Mail server (IMAP, TLS)</label>
|
|
550
549
|
<div class="row"><input id="mailbox-host" placeholder="imap.example.com" spellcheck="false" autocapitalize="off"><input id="mailbox-port" inputmode="numeric" placeholder="993" aria-label="Port" size="5"></div>
|
|
551
|
-
<label for="mailbox-
|
|
552
|
-
<input id="mailbox-
|
|
550
|
+
<label for="mailbox-smtp" class="mailbox-live">Sending server (SMTP)</label>
|
|
551
|
+
<input id="mailbox-smtp" class="mailbox-live" placeholder="smtp.example.com — empty: no sending" spellcheck="false" autocapitalize="off">
|
|
553
552
|
<label for="mailbox-password">Password</label>
|
|
554
553
|
<div class="row"><input id="mailbox-password" type="password" autocomplete="new-password">
|
|
555
|
-
<button type="submit" class="primary">
|
|
554
|
+
<button type="submit" class="primary">Connect</button></div>
|
|
556
555
|
<p id="mailbox-error" class="error" role="alert" hidden></p>
|
|
557
556
|
</form>
|
|
558
557
|
</div>
|
package/web/style.css
CHANGED
|
@@ -2103,3 +2103,10 @@ body.as-dragging #assets-rows .as-row { touch-action: none; }
|
|
|
2103
2103
|
.sure { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 8px; }
|
|
2104
2104
|
.sure label { flex: 1 1 100%; color: var(--ink2); }
|
|
2105
2105
|
.sure input { flex: 1 1 12em; min-width: 0; }
|
|
2106
|
+
|
|
2107
|
+
/* A mailbox of Assets, given actions too: its small form. */
|
|
2108
|
+
.as-live { display: flex; flex-direction: column; gap: 8px; margin: 8px 0 12px; }
|
|
2109
|
+
.as-live > button { align-self: flex-start; }
|
|
2110
|
+
.as-live-form { display: grid; grid-template-columns: minmax(0, 1fr); gap: 6px; max-width: 28rem; }
|
|
2111
|
+
.as-live-form > button { justify-self: start; margin-top: 4px; }
|
|
2112
|
+
|