@ccmsg/cli 0.9.1 → 0.11.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/package.json +1 -1
- package/src/auth/admin.ts +32 -6
- package/src/cli.ts +377 -57
- package/src/daemon/control.ts +61 -9
- package/src/daemon/registry.ts +398 -70
- package/src/daemon/supervise.ts +27 -3
- package/src/instance/ccmsg-config.d.ts +112 -0
- package/src/instance/config.ts +513 -131
- package/src/instance/identity.ts +11 -2
- package/src/instance/instance.ts +71 -26
- package/src/instance/paths.ts +37 -6
- package/src/mesh/index.ts +0 -1
- package/src/mesh/mesh.ts +47 -62
- package/src/mesh/wire.ts +1 -29
- package/src/mesh/probe.ts +0 -105
package/package.json
CHANGED
package/src/auth/admin.ts
CHANGED
|
@@ -22,23 +22,49 @@ export type AdminRequest =
|
|
|
22
22
|
readonly sub?: Subject;
|
|
23
23
|
}
|
|
24
24
|
| { readonly admin: "passkey_list"; readonly request_id: string }
|
|
25
|
-
| { readonly admin: "passkey_remove"; readonly request_id: string; readonly sub: Subject }
|
|
25
|
+
| { readonly admin: "passkey_remove"; readonly request_id: string; readonly sub: Subject }
|
|
26
|
+
/** Stop being a peer of this endpoint, now rather than at the next start.
|
|
27
|
+
*
|
|
28
|
+
* Here with the passkey requests because it is the same kind of thing: what
|
|
29
|
+
* this host is prepared to talk to, said from the machine it runs on, on the
|
|
30
|
+
* socket where reaching the address is the permission. `ccmsg mesh remove`
|
|
31
|
+
* has already taken it off the list; this is the running instance being told
|
|
32
|
+
* so, because a revocation that waited for a restart would leave the link it
|
|
33
|
+
* revoked standing. */
|
|
34
|
+
| { readonly admin: "mesh_forget"; readonly request_id: string; readonly endpoint: Endpoint };
|
|
35
|
+
|
|
36
|
+
const ADMIN_NAMES = ["passkey_add", "passkey_list", "passkey_remove", "mesh_forget"];
|
|
26
37
|
|
|
27
38
|
/** Whether a frame is one of these, without deciding anything about it. */
|
|
28
39
|
export function adminRequestOf(frame: unknown): AdminRequest | undefined {
|
|
29
40
|
if (typeof frame !== "object" || frame === null) return undefined;
|
|
30
41
|
const fields = frame as Record<string, unknown>;
|
|
31
|
-
|
|
32
|
-
if (name !== "passkey_add" && name !== "passkey_list" && name !== "passkey_remove") {
|
|
33
|
-
return undefined;
|
|
34
|
-
}
|
|
42
|
+
if (!ADMIN_NAMES.includes(fields["admin"] as string)) return undefined;
|
|
35
43
|
return typeof fields["request_id"] === "string" ? (frame as AdminRequest) : undefined;
|
|
36
44
|
}
|
|
37
45
|
|
|
46
|
+
/** What an administrative request is asked of: the passkeys, and the mesh on an
|
|
47
|
+
* instance that has one. */
|
|
48
|
+
export interface Administered {
|
|
49
|
+
readonly auth: Auth;
|
|
50
|
+
readonly mesh?: { forget(peer: Endpoint): boolean };
|
|
51
|
+
}
|
|
52
|
+
|
|
38
53
|
/** Run one administrative request. */
|
|
39
|
-
export function handleAdmin(
|
|
54
|
+
export function handleAdmin(at: Administered, request: AdminRequest): DispatchResult {
|
|
55
|
+
const auth = at.auth;
|
|
40
56
|
try {
|
|
41
57
|
switch (request.admin) {
|
|
58
|
+
case "mesh_forget": {
|
|
59
|
+
const mesh = at.mesh;
|
|
60
|
+
if (mesh === undefined) {
|
|
61
|
+
return reply(request.request_id, { endpoint: request.endpoint, dropped: false });
|
|
62
|
+
}
|
|
63
|
+
return reply(request.request_id, {
|
|
64
|
+
endpoint: request.endpoint,
|
|
65
|
+
dropped: mesh.forget(request.endpoint),
|
|
66
|
+
});
|
|
67
|
+
}
|
|
42
68
|
case "passkey_add":
|
|
43
69
|
return reply(
|
|
44
70
|
request.request_id,
|