fedipod-server 0.11.0 → 0.13.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 +22 -6
- package/dist/claims.d.ts +8 -0
- package/dist/claims.js +10 -0
- package/dist/handler.d.ts +13 -0
- package/dist/handler.js +56 -11
- package/dist/handler.jsonld +8 -0
- package/dist/store-pod.js +18 -4
- package/lib/{c2s.mjs → client/c2s.mjs} +10 -3
- package/lib/{localapi.mjs → client/localapi.mjs} +2 -2
- package/lib/client/masto/accounts.mjs +264 -0
- package/lib/client/masto/body.mjs +69 -0
- package/lib/client/masto/index.mjs +183 -0
- package/lib/client/masto/instance.mjs +104 -0
- package/lib/client/masto/media.mjs +133 -0
- package/lib/client/masto/oauth.mjs +599 -0
- package/lib/client/masto/render.mjs +459 -0
- package/lib/client/masto/statuses.mjs +331 -0
- package/lib/client/masto/timelines.mjs +316 -0
- package/lib/{streaming.mjs → client/streaming.mjs} +1 -1
- package/lib/{acctfeed.mjs → connections/acctfeed.mjs} +1 -1
- package/lib/{atproto.mjs → connections/atproto.mjs} +15 -16
- package/lib/{bskygroup.mjs → connections/bskygroup.mjs} +1 -1
- package/lib/{fediacct.mjs → connections/fediacct.mjs} +31 -35
- package/lib/{import.mjs → connections/import.mjs} +1 -1
- package/lib/{tagfeed.mjs → connections/tagfeed.mjs} +3 -3
- package/lib/connections/vault.mjs +114 -0
- package/lib/core/as2.mjs +170 -0
- package/lib/core/contexts/activitystreams.json +379 -0
- package/lib/core/contexts/did-v1.json +57 -0
- package/lib/core/contexts/fep-5711.json +36 -0
- package/lib/core/contexts/gotosocial.json +86 -0
- package/lib/core/contexts/identity-v1.json +152 -0
- package/lib/core/contexts/index.mjs +45 -0
- package/lib/core/contexts/join-lemmy.json +33 -0
- package/lib/core/contexts/joinmastodon.json +28 -0
- package/lib/core/contexts/map.json +16 -0
- package/lib/core/contexts/miscellany.json +19 -0
- package/lib/core/contexts/schemaorg.json +8845 -0
- package/lib/core/contexts/security-data-integrity-v1.json +78 -0
- package/lib/core/contexts/security-data-integrity-v2.json +81 -0
- package/lib/core/contexts/security-multikey-v1.json +35 -0
- package/lib/core/contexts/security-v1.json +74 -0
- package/lib/core/contexts/webfinger.json +10 -0
- package/lib/{deliver.mjs → core/deliver.mjs} +2 -2
- package/lib/core/graphview.mjs +269 -0
- package/lib/core/intake/activities.mjs +437 -0
- package/lib/core/intake/activity.mjs +240 -0
- package/lib/core/intake/channel.mjs +144 -0
- package/lib/core/intake/group.mjs +222 -0
- package/lib/core/intake/index.mjs +629 -0
- package/lib/core/intake/notes.mjs +288 -0
- package/lib/core/intake/verify.mjs +142 -0
- package/lib/{keys.mjs → core/keys.mjs} +1 -1
- package/lib/core/publisher/collections.mjs +229 -0
- package/lib/core/publisher/index.mjs +421 -0
- package/lib/core/publisher/notes.mjs +188 -0
- package/lib/core/publisher/questions.mjs +233 -0
- package/lib/core/publisher/restore.mjs +199 -0
- package/lib/core/shapes/activitystreams.ttl +129 -0
- package/lib/core/shapes/index.mjs +107 -0
- package/lib/core/shapes/shapes-text.mjs +13 -0
- package/lib/{social.mjs → core/social.mjs} +2 -2
- package/lib/{store.mjs → core/store.mjs} +4 -0
- package/lib/{wire.mjs → core/wire.mjs} +2 -2
- package/lib/device/admin/index.mjs +13 -0
- package/lib/device/admin/origins.mjs +35 -0
- package/lib/device/admin/routes/connections.mjs +144 -0
- package/lib/device/admin/routes/gateway.mjs +199 -0
- package/lib/device/admin/routes/lifecycle.mjs +191 -0
- package/lib/device/admin/routes/owner.mjs +322 -0
- package/lib/device/admin/routes/setup.mjs +393 -0
- package/lib/device/admin/routes/social.mjs +188 -0
- package/lib/device/admin/server.mjs +95 -0
- package/lib/device/admin/static.mjs +244 -0
- package/lib/device/admin/surface.mjs +274 -0
- package/lib/device/cli/commands/account.mjs +586 -0
- package/lib/device/cli/commands/run.mjs +278 -0
- package/lib/device/cli/commands/service.mjs +221 -0
- package/lib/device/cli/commands/setup.mjs +410 -0
- package/lib/device/cli/commands/state.mjs +559 -0
- package/lib/device/cli/context.mjs +288 -0
- package/lib/{migrate.mjs → device/migrate.mjs} +1 -1
- package/lib/{remote.mjs → device/remote.mjs} +3 -3
- package/lib/{setup.mjs → device/setup.mjs} +3 -3
- package/lib/{update.mjs → device/update.mjs} +1 -1
- package/lib/{directory.mjs → gateway/directory.mjs} +1 -1
- package/lib/{front-core.mjs → gateway/front-core.mjs} +3 -3
- package/lib/{gateway-core.mjs → gateway/gateway-core.mjs} +1 -1
- package/lib/{httpsig.mjs → gateway/httpsig.mjs} +1 -1
- package/lib/server/embed.mjs +405 -0
- package/lib/{links.mjs → shared/links.mjs} +1 -1
- package/lib/{ua.mjs → shared/ua.mjs} +1 -1
- package/package.json +1 -1
- package/run-agent.mjs +33 -25
- package/web/admin/actors.js +145 -0
- package/web/admin/common.js +23 -0
- package/web/admin/connections.js +112 -0
- package/web/admin/gateway.js +111 -0
- package/web/admin/group.js +258 -0
- package/web/admin/index.html +7 -1
- package/web/admin/record.js +378 -0
- package/web/admin/setup/index.html +1 -0
- package/web/admin/setup/setup.js +2 -13
- package/web/admin/upkeep.js +170 -0
- package/web/app/README.md +6 -6
- package/web/app/admin-facade.mjs +3 -3
- package/web/app/agent.mjs +14 -16
- package/web/app/atproto-browser.mjs +1 -1
- package/web/app/boot.mjs +2 -3
- package/web/app/deliver-relay.mjs +1 -1
- package/web/app/dist/boot.js +22 -3
- package/web/app/dist/boot.js.map +2 -2
- package/web/app/dist/sw.js +21913 -5446
- package/web/app/dist/sw.js.map +4 -4
- package/web/app/fediacct-browser.mjs +1 -1
- package/web/app/keys-browser.mjs +27 -4
- package/web/app/shims/shapes-text.mjs +8 -0
- package/web/app/signup.mjs +2 -3
- package/web/app/site/admin/actors.js +145 -0
- package/web/app/site/admin/common.js +23 -0
- package/web/app/site/admin/connections.js +112 -0
- package/web/app/site/admin/gateway.js +111 -0
- package/web/app/site/admin/group.js +258 -0
- package/web/app/site/admin/index.html +7 -1
- package/web/app/site/admin/record.js +378 -0
- package/web/app/site/admin/setup/index.html +1 -0
- package/web/app/site/admin/setup/setup.js +2 -13
- package/web/app/site/admin/upkeep.js +170 -0
- package/web/app/site/boot.js +22 -3
- package/web/app/site/sw.js +21913 -5446
- package/web/app/sw-src.mjs +17 -2
- package/lib/admin.mjs +0 -1913
- package/lib/embed.mjs +0 -220
- package/lib/intake.mjs +0 -1981
- package/lib/mastoapi.mjs +0 -2284
- package/lib/publisher.mjs +0 -1192
- package/web/admin/admin.js +0 -1181
- package/web/app/site/admin/admin.js +0 -1181
- /package/lib/{oidc-auth.mjs → client/oidc-auth.mjs} +0 -0
- /package/lib/{webpush.mjs → client/webpush.mjs} +0 -0
- /package/lib/{bskyfeed.mjs → connections/bskyfeed.mjs} +0 -0
- /package/lib/{lease.mjs → core/lease.mjs} +0 -0
- /package/lib/{polls.mjs → core/polls.mjs} +0 -0
- /package/lib/{proof.mjs → core/proof.mjs} +0 -0
- /package/lib/{storage.mjs → core/storage.mjs} +0 -0
- /package/lib/{account.mjs → device/account.mjs} +0 -0
- /package/lib/{certs.mjs → device/certs.mjs} +0 -0
- /package/lib/{export-collections.mjs → device/export-collections.mjs} +0 -0
- /package/lib/{home.mjs → device/home.mjs} +0 -0
- /package/lib/{ports.mjs → device/ports.mjs} +0 -0
- /package/lib/{guard.mjs → shared/guard.mjs} +0 -0
- /package/lib/{safefetch.mjs → shared/safefetch.mjs} +0 -0
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
// short-lived OAuth "pending" state stay in IndexedDB (per browser), and the
|
|
15
15
|
// pending state is persisted so a connection survives the worker being
|
|
16
16
|
// idle-killed between the redirect out and the code coming back.
|
|
17
|
-
import { FediAccounts } from '../../lib/fediacct.mjs';
|
|
17
|
+
import { FediAccounts } from '../../lib/connections/fediacct.mjs';
|
|
18
18
|
import { kvAll, kvPut, kvDel } from './idb-kv.mjs';
|
|
19
19
|
|
|
20
20
|
const POD_DOC = 'fediaccts.json'; // { id: record } for pod-stored connections
|
package/web/app/keys-browser.mjs
CHANGED
|
@@ -4,6 +4,11 @@
|
|
|
4
4
|
// this returns the same, RSA only. FEP-8b32 Ed25519 proofs are optional — the
|
|
5
5
|
// deliverer treats a null edPrivate as "no proof", and an unproved activity
|
|
6
6
|
// still federates — so the browser MVP omits them.
|
|
7
|
+
//
|
|
8
|
+
// The private key is imported NON-extractable, and the copy this browser keeps
|
|
9
|
+
// in IndexedDB is that CryptoKey, not the PEM: it can sign and cannot be read
|
|
10
|
+
// out, so a script that reaches this origin's storage gets nothing it can carry
|
|
11
|
+
// away. The PEM record exists only in memory, between unwrap and import.
|
|
7
12
|
import { kvGet, kvPut } from './idb-kv.mjs';
|
|
8
13
|
import * as podState from '../../lib/pod/state.mjs';
|
|
9
14
|
import { isKeyEnvelope, KeyPasswordNeeded } from './keystore.mjs';
|
|
@@ -13,10 +18,26 @@ const pemToDer = (pem) => Uint8Array.from(
|
|
|
13
18
|
|
|
14
19
|
export async function importSigningKey(keysRecord) {
|
|
15
20
|
const rsaPrivate = await crypto.subtle.importKey('pkcs8', pemToDer(keysRecord.rsa.privatePem),
|
|
16
|
-
{ name: 'RSASSA-PKCS1-v1_5', hash: 'SHA-256' },
|
|
21
|
+
{ name: 'RSASSA-PKCS1-v1_5', hash: 'SHA-256' }, false, ['sign']);
|
|
17
22
|
return { rsaPrivate, rsaPublicPem: keysRecord.rsa.publicPem, edPrivate: null, edPublicMultibase: null };
|
|
18
23
|
}
|
|
19
24
|
|
|
25
|
+
/** What the cache holds: the non-extractable key and the public half. */
|
|
26
|
+
const fromCache = (c) => ({ rsaPrivate: c.rsaPrivate, rsaPublicPem: c.rsaPublicPem, edPrivate: null, edPublicMultibase: null });
|
|
27
|
+
const isOpenedKey = (c) => c?.rsaPrivate?.type === 'private' && typeof c.rsaPublicPem === 'string';
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Keep this browser's opened copy: import the record and store the CryptoKey.
|
|
31
|
+
* Best effort on the store — a browser that refuses IndexedDB (private mode)
|
|
32
|
+
* asks for the password on the way back in. Returns the imported keys.
|
|
33
|
+
*/
|
|
34
|
+
export async function cacheOpenedKeys(actorUrl, keysRecord) {
|
|
35
|
+
const keys = await importSigningKey(keysRecord);
|
|
36
|
+
await kvPut(keyCacheKey(actorUrl), { rsaPrivate: keys.rsaPrivate, rsaPublicPem: keys.rsaPublicPem })
|
|
37
|
+
.catch(() => {});
|
|
38
|
+
return keys;
|
|
39
|
+
}
|
|
40
|
+
|
|
20
41
|
// Where this browser keeps its own opened copy of the signing key. The pod's
|
|
21
42
|
// copy is wrapped under the account password; this one is not, because it never
|
|
22
43
|
// leaves the origin — the same protection the OIDC session in the next IDB row
|
|
@@ -34,13 +55,15 @@ export const keyCacheKey = (actorUrl) => `signing-keys:${actorUrl}`;
|
|
|
34
55
|
// needs the password and so has to go back to the page.
|
|
35
56
|
export async function loadKeysFromPod(remote, urls) {
|
|
36
57
|
const cached = await kvGet(keyCacheKey(urls.actor)).catch(() => null);
|
|
37
|
-
if (cached
|
|
58
|
+
if (isOpenedKey(cached)) return fromCache(cached);
|
|
59
|
+
// A copy stored as PEM by an earlier build: import it and store the key form
|
|
60
|
+
// in its place, so the PEM is gone from storage after one boot.
|
|
61
|
+
if (cached?.rsa?.privatePem) return cacheOpenedKeys(urls.actor, cached);
|
|
38
62
|
|
|
39
63
|
const doc = await podState.readWrappedKeys(remote, urls);
|
|
40
64
|
if (isKeyEnvelope(doc)) throw new KeyPasswordNeeded();
|
|
41
65
|
if (!doc || !doc.rsa) throw new Error('no signing key on the pod — sign up did not finish');
|
|
42
66
|
// A pre-wrapping install. Cache it so the next boot is one read, and leave
|
|
43
67
|
// the pod's copy alone: re-wrapping it would need the password we do not have.
|
|
44
|
-
|
|
45
|
-
return importSigningKey(doc);
|
|
68
|
+
return cacheOpenedKeys(urls.actor, doc);
|
|
46
69
|
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
// shapes-text.mjs — the shapes document in the browser agent.
|
|
2
|
+
//
|
|
3
|
+
// Same activitystreams.ttl the Node agent reads; esbuild's text loader turns
|
|
4
|
+
// it into a string at build time, so there is no filesystem here and no second
|
|
5
|
+
// copy of the shapes.
|
|
6
|
+
import ttl from '../../../lib/core/shapes/activitystreams.ttl';
|
|
7
|
+
|
|
8
|
+
export const SHAPES_TTL = ttl;
|
package/web/app/signup.mjs
CHANGED
|
@@ -14,8 +14,7 @@ import { createAccountWithPod, mintCredential, makeDpopSession, revokeCredential
|
|
|
14
14
|
import { generateKeys, wrapKeys } from './keystore.mjs';
|
|
15
15
|
import { BrowserRemotePod } from './pod-remote.mjs';
|
|
16
16
|
import * as podState from '../../lib/pod/state.mjs';
|
|
17
|
-
import {
|
|
18
|
-
import { keyCacheKey } from './keys-browser.mjs';
|
|
17
|
+
import { cacheOpenedKeys } from './keys-browser.mjs';
|
|
19
18
|
|
|
20
19
|
// The container everything the agent publishes hangs under. New pods made here
|
|
21
20
|
// use `fedipod/`; the agent's own default stays `activitypods-js/` for installs
|
|
@@ -167,7 +166,7 @@ export async function signUp(answers, { onStep = () => {}, frontOrigin = null }
|
|
|
167
166
|
// This browser's own opened copy, so the boot after the login redirect
|
|
168
167
|
// needs no password. Best effort: a browser that refuses IndexedDB (private
|
|
169
168
|
// mode) simply asks for the password on the way back in.
|
|
170
|
-
await
|
|
169
|
+
await cacheOpenedKeys(actorUrl, keys);
|
|
171
170
|
prog.keys = keys; prog.keysStored = true;
|
|
172
171
|
keysStep.ok();
|
|
173
172
|
} else {
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
// actors.js — the other actors on this machine: the picker, going to one,
|
|
2
|
+
// starting a stopped one, and the form for a new one.
|
|
3
|
+
|
|
4
|
+
// Somewhere to go, and nothing else. A stopped actor is left out — the link
|
|
5
|
+
// would land on nothing. The one you are on keeps its place in the row but
|
|
6
|
+
// offers only `app`, because its admin page is the page you are reading.
|
|
7
|
+
|
|
8
|
+
let actors = [];
|
|
9
|
+
|
|
10
|
+
async function renderOthers() {
|
|
11
|
+
const { json } = await api('/profiles');
|
|
12
|
+
actors = json?.identities || [];
|
|
13
|
+
const sel = $('actor-pick');
|
|
14
|
+
sel.textContent = '';
|
|
15
|
+
// The fediverse address, which is what the actor IS to everyone else, and the
|
|
16
|
+
// only form that stays distinct: two identities can share a local handle, but
|
|
17
|
+
// never a handle AND a pod. A stopped one has no address to report — nothing
|
|
18
|
+
// answered — so it falls back to the name it is filed under.
|
|
19
|
+
const label = (r) => (r.address || r.handle || r.name)
|
|
20
|
+
+ (r.mode && r.mode !== 'active' ? ` (${r.mode})` : '') + (r.mode ? '' : ' (stopped)');
|
|
21
|
+
const seen = {};
|
|
22
|
+
for (const r of actors) seen[label(r)] = (seen[label(r)] || 0) + 1;
|
|
23
|
+
|
|
24
|
+
for (const [i, r] of actors.entries()) {
|
|
25
|
+
const o = document.createElement('option');
|
|
26
|
+
o.value = String(i);
|
|
27
|
+
o.selected = !!r.current; // it opens showing where you already are
|
|
28
|
+
o.textContent = label(r) + (seen[label(r)] > 1 && r.port ? ` :${r.port}` : '');
|
|
29
|
+
sel.appendChild(o);
|
|
30
|
+
}
|
|
31
|
+
// The way to a NEW actor rides the same dropdown as the existing ones.
|
|
32
|
+
const add = document.createElement('option');
|
|
33
|
+
add.value = '__add';
|
|
34
|
+
add.textContent = '+ add a new account…';
|
|
35
|
+
sel.appendChild(add);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// Going to an actor commits a navigation and, for a stopped one, a POST that
|
|
39
|
+
// boots its pod — so it must run once per choice. Pressing Enter on the select
|
|
40
|
+
// fires BOTH a keydown (handled below) and a native `change`, so without a
|
|
41
|
+
// guard a keyboard commit would start the actor twice.
|
|
42
|
+
let goingToActor = false;
|
|
43
|
+
const goToActor = async () => {
|
|
44
|
+
if (goingToActor) return;
|
|
45
|
+
if ($('actor-pick').value === '__add') { renderOthers(); openNewActor(); return; }
|
|
46
|
+
const r = actors[Number($('actor-pick').value)];
|
|
47
|
+
if (!r || r.current) return;
|
|
48
|
+
goingToActor = true;
|
|
49
|
+
try {
|
|
50
|
+
if (r.mode) { location.href = r.admin; return; }
|
|
51
|
+
$('actor-pick').disabled = true;
|
|
52
|
+
say(`starting ${r.name}`);
|
|
53
|
+
const started = await write('/start-actor', { name: r.name }, `${r.name} is up`);
|
|
54
|
+
$('actor-pick').disabled = false;
|
|
55
|
+
if (started?.url) location.href = `${started.url}admin/`;
|
|
56
|
+
else renderOthers(); // put the picker back on the current actor
|
|
57
|
+
} finally {
|
|
58
|
+
goingToActor = false;
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
// Choosing one goes to its record, as it always has.
|
|
62
|
+
//
|
|
63
|
+
// Arrowing is the one case that must not: on a closed select every Arrow
|
|
64
|
+
// keypress fires `change`, so a keyboard user browsing the list would be
|
|
65
|
+
// carried off to the first actor they passed — and for a stopped one that
|
|
66
|
+
// boots its pod. An arrow key arms a flag and the change it causes is ignored;
|
|
67
|
+
// Enter commits. A mouse never sets the flag, so clicking behaves as before.
|
|
68
|
+
let arrowing = false;
|
|
69
|
+
$('actor-pick').addEventListener('keydown', (ev) => {
|
|
70
|
+
if (['ArrowUp', 'ArrowDown', 'Home', 'End', 'PageUp', 'PageDown'].includes(ev.key)) arrowing = true;
|
|
71
|
+
if (ev.key === 'Enter') { arrowing = false; goToActor(); }
|
|
72
|
+
});
|
|
73
|
+
$('actor-pick').addEventListener('pointerdown', () => { arrowing = false; });
|
|
74
|
+
$('actor-pick').addEventListener('change', () => {
|
|
75
|
+
if (!arrowing) goToActor();
|
|
76
|
+
arrowing = false;
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
// Setting up a new actor asks for exactly what this page cannot already tell
|
|
80
|
+
// it: the pod and the account behind it, and its permanent name. Display name,
|
|
81
|
+
// bio and pictures are the client's job now — Phanpy's profile editor writes
|
|
82
|
+
// them through /api/v1/accounts/update_credentials. Where the private data goes
|
|
83
|
+
// is not a question either: it lands beside the credential, and `state --to`
|
|
84
|
+
// moves it afterwards.
|
|
85
|
+
|
|
86
|
+
const picked = (name) => document.querySelector(`input[name=${name}]:checked`)?.value;
|
|
87
|
+
|
|
88
|
+
function newActorRows() {
|
|
89
|
+
const mode = picked('newMode');
|
|
90
|
+
$('new-row-podname').hidden = mode !== 'new';
|
|
91
|
+
$('new-row-pod').hidden = mode !== 'existing';
|
|
92
|
+
}
|
|
93
|
+
for (const el of document.querySelectorAll('input[name=newMode]')) {
|
|
94
|
+
el.addEventListener('change', newActorRows);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
// While the form is up the page IS the new actor's setup — so the record of
|
|
98
|
+
// the actor you came from goes away, list included. Which panes were showing
|
|
99
|
+
// is remembered rather than recomputed: whether Group and Inbox belong is a
|
|
100
|
+
// decision render() already made.
|
|
101
|
+
const RECORD_PANES = ['pane-identity', 'pane-group', 'pane-inbox', 'rail'];
|
|
102
|
+
let putBack = [];
|
|
103
|
+
|
|
104
|
+
function showNewActor(on) {
|
|
105
|
+
if (on) closePanels(); // nothing of the old actor left open behind it
|
|
106
|
+
document.body.classList.toggle('adding', on); // see body.adding in the CSS
|
|
107
|
+
$('new-actor-form').hidden = !on;
|
|
108
|
+
if (on) {
|
|
109
|
+
putBack = RECORD_PANES.filter(id => !$(id).hidden);
|
|
110
|
+
for (const id of putBack) $(id).hidden = true;
|
|
111
|
+
} else {
|
|
112
|
+
for (const id of putBack) $(id).hidden = false;
|
|
113
|
+
putBack = [];
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
// `add a new account` is the last item of the Local Actors dropdown; choosing
|
|
118
|
+
// it opens the form in place. Arriving with ?new does the same.
|
|
119
|
+
function openNewActor() {
|
|
120
|
+
showNewActor(true);
|
|
121
|
+
newActorRows();
|
|
122
|
+
$('new-handle').focus();
|
|
123
|
+
}
|
|
124
|
+
$('new-actor-cancel').addEventListener('click', () => { showNewActor(false); say('nothing changed'); });
|
|
125
|
+
|
|
126
|
+
$('new-actor-form').addEventListener('submit', async (ev) => {
|
|
127
|
+
ev.preventDefault();
|
|
128
|
+
const handle = $('new-handle').value.trim();
|
|
129
|
+
const answers = {
|
|
130
|
+
handle,
|
|
131
|
+
kind: picked('newKind'),
|
|
132
|
+
mode: picked('newMode'),
|
|
133
|
+
issuer: $('new-issuer').value.trim(),
|
|
134
|
+
email: $('new-email').value.trim(),
|
|
135
|
+
password: $('new-password').value,
|
|
136
|
+
};
|
|
137
|
+
if (answers.mode === 'new') answers.podName = $('new-podname').value.trim() || handle;
|
|
138
|
+
else answers.pod = $('new-pod').value.trim();
|
|
139
|
+
$('new-actor-go').disabled = true;
|
|
140
|
+
say(`setting up ${handle || 'the new actor'} — this takes a while`);
|
|
141
|
+
const r = await write('/new-actor', answers, `setting up ${handle}`);
|
|
142
|
+
$('new-actor-go').disabled = false;
|
|
143
|
+
if (r?.url) location.href = r.url; // its own page, where the progress is
|
|
144
|
+
});
|
|
145
|
+
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
// common.js — what every admin page starts from: the element lookup, the
|
|
2
|
+
// door the page is served behind, and the two ways it talks to the agent.
|
|
3
|
+
// Loaded first by the record page and by the setup page.
|
|
4
|
+
|
|
5
|
+
const $ = (id) => document.getElementById(id);
|
|
6
|
+
// The door this page is served behind: nothing when the agent runs on this
|
|
7
|
+
// machine, `/app` when the identity is hosted by its own pod server. Read from
|
|
8
|
+
// the page's own address, so one build serves both.
|
|
9
|
+
const BASE = location.pathname.replace(/\/admin\/.*$/u, '');
|
|
10
|
+
// Every call carries `x-fedipod-page`. On the Node agent it is ignored — the
|
|
11
|
+
// Origin check there already refuses a page on somebody else's site. In the
|
|
12
|
+
// browser build the agent IS this origin's service worker, which cannot see
|
|
13
|
+
// Sec-Fetch-* and answers these routes with no password, so this header is the
|
|
14
|
+
// whole door: a cross-site form cannot set one, and a cross-origin fetch that
|
|
15
|
+
// sets one is stopped at a preflight the worker never grants. See sw-src.mjs.
|
|
16
|
+
const PAGE_HEADER = { 'x-fedipod-page': '1' };
|
|
17
|
+
const api = async (path, init) => {
|
|
18
|
+
const res = await fetch(BASE + path, { ...init, headers: { ...(init?.headers || {}), ...PAGE_HEADER } });
|
|
19
|
+
return { status: res.status, json: await res.json().catch(() => null) };
|
|
20
|
+
};
|
|
21
|
+
const postJson = (path, body) => api(path, {
|
|
22
|
+
method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify(body || {}),
|
|
23
|
+
});
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
// connections.js — the accounts held elsewhere: the rail, the connect forms
|
|
2
|
+
// for Bluesky and for a fediverse account, and the migration aliases.
|
|
3
|
+
|
|
4
|
+
// The connect form lives in the floating window, like every other form here.
|
|
5
|
+
// The inbound transfer panel: the aliases live here now, not in the facts.
|
|
6
|
+
$('do-transfer-in').addEventListener('click', () => {
|
|
7
|
+
solWindow.show('transfer-in-form', 'Transfer an account here');
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
// The rail: one click hides the actions; on a phone it starts hidden.
|
|
11
|
+
function setRail(closed) {
|
|
12
|
+
$('rail').classList.toggle('closed', closed);
|
|
13
|
+
const t = $('rail-toggle');
|
|
14
|
+
t.setAttribute('aria-expanded', String(!closed));
|
|
15
|
+
t.querySelector('.rail-arrow').textContent = closed ? '»' : '«';
|
|
16
|
+
t.title = closed ? ' Show the action panel' : ' Hide the action panel';
|
|
17
|
+
}
|
|
18
|
+
$('rail-toggle').addEventListener('click', () => setRail(!$('rail').classList.contains('closed')));
|
|
19
|
+
if (matchMedia('(max-width: 47rem)').matches) setRail(true);
|
|
20
|
+
|
|
21
|
+
// One way in for both networks, because from the record they are the same
|
|
22
|
+
// thing: an account elsewhere whose timeline joins the one you read here.
|
|
23
|
+
$('ident-open').addEventListener('click', () => {
|
|
24
|
+
closePanels();
|
|
25
|
+
solWindow.show('ident-form', 'Connect an identity');
|
|
26
|
+
});
|
|
27
|
+
$('ident-pick-fedi').addEventListener('click', () => {
|
|
28
|
+
solWindow.show('fediacct-form', 'Connect a Fediverse account');
|
|
29
|
+
});
|
|
30
|
+
$('ident-pick-bsky').addEventListener('click', () => {
|
|
31
|
+
solWindow.show('bsky-form', 'Connect a Bluesky account');
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
let bskyBusy = false;
|
|
35
|
+
$('bsky-form').addEventListener('submit', async (ev) => {
|
|
36
|
+
ev.preventDefault();
|
|
37
|
+
if (bskyBusy) return;
|
|
38
|
+
bskyBusy = true;
|
|
39
|
+
try {
|
|
40
|
+
const r = await write('/atproto/connect', {
|
|
41
|
+
service: $('bsky-service').value.trim(),
|
|
42
|
+
identifier: $('bsky-identifier').value.trim(),
|
|
43
|
+
appPassword: $('bsky-password').value,
|
|
44
|
+
}, 'bluesky account connected');
|
|
45
|
+
if (r) {
|
|
46
|
+
$('bsky-password').value = '';
|
|
47
|
+
closePanels();
|
|
48
|
+
await load();
|
|
49
|
+
}
|
|
50
|
+
} finally { bskyBusy = false; }
|
|
51
|
+
});
|
|
52
|
+
// The sign-in happens at the other server, so this hands the browser over
|
|
53
|
+
// rather than taking a password. What comes back lands on /fediacct/callback,
|
|
54
|
+
// which this machine answers and nowhere else does.
|
|
55
|
+
let fediBusy = false;
|
|
56
|
+
$('fediacct-form').addEventListener('submit', async (ev) => {
|
|
57
|
+
ev.preventDefault();
|
|
58
|
+
if (fediBusy) return;
|
|
59
|
+
fediBusy = true;
|
|
60
|
+
try {
|
|
61
|
+
const r = await write('/fediacct/connect', { host: $('fediacct-host').value.trim() }, '');
|
|
62
|
+
if (r?.authorize) location.href = r.authorize;
|
|
63
|
+
} finally { fediBusy = false; }
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
// Disconnecting Bluesky, pausing its feed and choosing its storage all live in
|
|
67
|
+
// the account's Options menu now (see optionsMenu). Connecting is still here.
|
|
68
|
+
// Adding resolves the old account on the agent side, so what lands in
|
|
69
|
+
// alsoKnownAs is its canonical id, not the string typed here.
|
|
70
|
+
// The accounts elsewhere this one may receive a Move from — the chips in the
|
|
71
|
+
// Transfer-an-account-here panel. Each entry is removable, behind a second
|
|
72
|
+
// click: servers still retrying a Move check the list, so removal is not a
|
|
73
|
+
// tidy-up.
|
|
74
|
+
function renderAliases() {
|
|
75
|
+
const box = $('alias-chips');
|
|
76
|
+
box.textContent = '';
|
|
77
|
+
for (const alias of config.aliases || []) {
|
|
78
|
+
let armed = false;
|
|
79
|
+
const rm = document.createElement('button');
|
|
80
|
+
rm.type = 'button';
|
|
81
|
+
rm.className = 'inline danger';
|
|
82
|
+
rm.textContent = '✕';
|
|
83
|
+
rm.title = ' Remove this alias';
|
|
84
|
+
rm.addEventListener('click', async () => {
|
|
85
|
+
if (!armed) {
|
|
86
|
+
armed = true;
|
|
87
|
+
rm.textContent = 'confirm ✕';
|
|
88
|
+
rm.title = ' Servers still retrying the Move check this alias — click again to remove it anyway';
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
const r = await write('/alias', { remove: alias, confirm: true }, 'alias removed and the actor republished');
|
|
92
|
+
if (r) { config.aliases = r.aliases; render(); }
|
|
93
|
+
});
|
|
94
|
+
const chip = document.createElement('span');
|
|
95
|
+
chip.append(alias, ' ', rm);
|
|
96
|
+
box.append(chip, ' ');
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
let aliasBusy = false;
|
|
101
|
+
$('alias-add').addEventListener('click', async () => {
|
|
102
|
+
if (aliasBusy) return;
|
|
103
|
+
const v = $('alias-input').value.trim();
|
|
104
|
+
if (!v) { say('enter the old account first — @you@old.server', 'err'); return; }
|
|
105
|
+
aliasBusy = true;
|
|
106
|
+
try {
|
|
107
|
+
const r = await write('/alias', { add: v }, 'alias added and the actor republished');
|
|
108
|
+
if (r) { $('alias-input').value = ''; config.aliases = r.aliases; render(); }
|
|
109
|
+
} finally { aliasBusy = false; }
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
// gateway.js — the gateway row and its attach and detach forms, the inbox
|
|
2
|
+
// prune actions, and the load that starts the page.
|
|
3
|
+
|
|
4
|
+
const GATEWAY_CTL = $('gateway-ctl'); // held: it rides into a generated row
|
|
5
|
+
const GATEWAY_WORD = $('gateway-word');
|
|
6
|
+
const GW_OPEN_ATTACH = $('gateway-open-attach');
|
|
7
|
+
const GW_OPEN_DETACH = $('gateway-open-detach');
|
|
8
|
+
let gwState = null;
|
|
9
|
+
async function refreshGateway() {
|
|
10
|
+
const { status, json: g } = await api('/gateway');
|
|
11
|
+
if (status !== 200 || !g) return;
|
|
12
|
+
gwState = g;
|
|
13
|
+
GATEWAY_CTL.hidden = false;
|
|
14
|
+
if (g.configured) {
|
|
15
|
+
let host = g.url;
|
|
16
|
+
try { host = new URL(g.url).host; } catch { /* show it as-is */ }
|
|
17
|
+
const frontName = g.frontActor?.match(/\/u\/([^/]+)\/ap\/actor\/?$/)?.[1];
|
|
18
|
+
GATEWAY_WORD.textContent = frontName ? `${host} — publishing as @${frontName}@${host}` : host;
|
|
19
|
+
GW_OPEN_ATTACH.hidden = true;
|
|
20
|
+
GW_OPEN_DETACH.hidden = false;
|
|
21
|
+
} else {
|
|
22
|
+
GATEWAY_WORD.textContent = '';
|
|
23
|
+
GW_OPEN_ATTACH.hidden = false;
|
|
24
|
+
GW_OPEN_DETACH.hidden = true;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
const gwShape = () => document.querySelector('input[name=gwShape]:checked')?.value || 'pod';
|
|
28
|
+
function gwPreviews() {
|
|
29
|
+
$('gw-pod-preview').textContent = config?.address || `@${config?.handle || 'you'}@your.pod`;
|
|
30
|
+
try { $('gw-front-host').textContent = new URL($('gw-front').value.trim()).host; }
|
|
31
|
+
catch { /* not a URL yet — the placeholder host stands */ }
|
|
32
|
+
}
|
|
33
|
+
function gwShapeChanged() { gwPreviews(); gwCheck(); }
|
|
34
|
+
for (const r of document.querySelectorAll('input[name=gwShape]')) r.addEventListener('change', gwShapeChanged);
|
|
35
|
+
// Typing in the blank IS choosing that shape.
|
|
36
|
+
$('gw-name').addEventListener('focus', () => {
|
|
37
|
+
const r = document.querySelector('input[name=gwShape][value=front]');
|
|
38
|
+
if (!r.checked) { r.checked = true; gwShapeChanged(); }
|
|
39
|
+
});
|
|
40
|
+
GW_OPEN_ATTACH.addEventListener('click', () => {
|
|
41
|
+
gwShapeChanged();
|
|
42
|
+
solWindow.show('gateway-attach-form', 'Attach to a gateway');
|
|
43
|
+
});
|
|
44
|
+
GW_OPEN_DETACH.addEventListener('click', () => {
|
|
45
|
+
$('gw-detach-fronted').hidden = !gwState?.frontActor;
|
|
46
|
+
$('gw-detach-plain').hidden = !!gwState?.frontActor;
|
|
47
|
+
solWindow.show('gateway-detach-form', 'Detach from gateway');
|
|
48
|
+
});
|
|
49
|
+
// Live availability, asked through the agent (the front answers it without CORS).
|
|
50
|
+
let gwTimer = null;
|
|
51
|
+
function gwCheck() {
|
|
52
|
+
clearTimeout(gwTimer);
|
|
53
|
+
const front = $('gw-front').value.trim().replace(/\/+$/, '');
|
|
54
|
+
const name = $('gw-name').value.trim().toLowerCase();
|
|
55
|
+
$('gw-name-msg').textContent = ''; $('gw-name-msg').className = 'hint';
|
|
56
|
+
if (gwShape() !== 'front' || !front || !name) return;
|
|
57
|
+
gwTimer = setTimeout(async () => {
|
|
58
|
+
const { status, json } = await postJson('/gateway', { action: 'check', front, handle: name });
|
|
59
|
+
if (status !== 200 || !json) return;
|
|
60
|
+
$('gw-name-msg').textContent = json.available
|
|
61
|
+
? `${name} is free at ${front.replace(/^https?:\/\//, '')}`
|
|
62
|
+
: (json.reason || 'that name is taken');
|
|
63
|
+
$('gw-name-msg').className = json.available ? 'hint' : 'warn';
|
|
64
|
+
}, 300);
|
|
65
|
+
}
|
|
66
|
+
$('gw-front').addEventListener('input', () => { gwPreviews(); gwCheck(); });
|
|
67
|
+
$('gw-name').addEventListener('input', () => { gwPreviews(); gwCheck(); });
|
|
68
|
+
$('gw-attach').addEventListener('click', async () => {
|
|
69
|
+
const front = $('gw-front').value.trim().replace(/\/+$/, '');
|
|
70
|
+
const fronted = gwShape() === 'front';
|
|
71
|
+
const name = $('gw-name').value.trim().toLowerCase();
|
|
72
|
+
if (fronted && !name) { say('give the handle you want at the gateway', 'err'); return; }
|
|
73
|
+
$('gw-attach').disabled = true;
|
|
74
|
+
// Pod-based sends no name: the door's label is the agent's business, not
|
|
75
|
+
// the user's, and the agent picks a free variant by itself.
|
|
76
|
+
const r = await write('/gateway',
|
|
77
|
+
{ action: 'attach', front, ...(fronted ? { handle: name, fronted: true } : {}) },
|
|
78
|
+
fronted ? 'attached — the agent is restarting to publish under the gateway handle; reload in a moment'
|
|
79
|
+
: 'attached — your mail now arrives through the gateway, filtered');
|
|
80
|
+
$('gw-attach').disabled = false;
|
|
81
|
+
if (r) { closePanels(); refreshGateway(); }
|
|
82
|
+
});
|
|
83
|
+
$('gw-detach').addEventListener('click', async () => {
|
|
84
|
+
const fronted = !!gwState?.frontActor;
|
|
85
|
+
const r = await write('/gateway', { action: 'forget' },
|
|
86
|
+
fronted ? 'detached — the agent is restarting under your pod\'s own name; reload in a moment'
|
|
87
|
+
: 'detached — the actor was republished advertising your pod\'s own inbox');
|
|
88
|
+
if (r) { closePanels(); refreshGateway(); }
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
$('inbox-keep').addEventListener('click', () => {
|
|
92
|
+
dismissed = true;
|
|
93
|
+
$('pane-inbox').hidden = true;
|
|
94
|
+
say('leaving it to the agent — it drains oldest first');
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
$('inbox-prune').addEventListener('click', async () => {
|
|
98
|
+
const days = Number($('inbox-before').value);
|
|
99
|
+
const before = new Date(Date.now() - days * 86400_000).toISOString();
|
|
100
|
+
$('inbox-prune').disabled = true;
|
|
101
|
+
say(`discarding content older than ${days} days — this takes a while`);
|
|
102
|
+
const r = await write('/inbox/prune', { before }, 'done');
|
|
103
|
+
$('inbox-prune').disabled = false;
|
|
104
|
+
if (r) {
|
|
105
|
+
say(`applied ${r.applied} follow/unfollow/delete, discarded ${r.dropped + r.discarded} posts`
|
|
106
|
+
+ (r.failed ? `, ${r.failed} failed` : ''));
|
|
107
|
+
renderInbox();
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
load();
|