@peer2peer/cli 0.0.0-stage → 0.1.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/LICENSE +201 -0
- package/README.md +366 -2
- package/dist/ancestry.d.ts +13 -0
- package/dist/ancestry.js +71 -0
- package/dist/app.d.ts +363 -0
- package/dist/app.js +1177 -0
- package/dist/bin.d.ts +2 -0
- package/dist/bin.js +56 -0
- package/dist/circle-ops.d.ts +402 -0
- package/dist/circle-ops.js +1725 -0
- package/dist/cli.d.ts +611 -0
- package/dist/cli.js +1650 -0
- package/dist/codes.d.ts +231 -0
- package/dist/codes.js +998 -0
- package/dist/config.d.ts +112 -0
- package/dist/config.js +243 -0
- package/dist/doctor.d.ts +99 -0
- package/dist/doctor.js +817 -0
- package/dist/errors.d.ts +8 -0
- package/dist/errors.js +29 -0
- package/dist/ext-host.d.ts +32 -0
- package/dist/ext-host.js +259 -0
- package/dist/extensions.d.ts +386 -0
- package/dist/extensions.js +395 -0
- package/dist/features.d.ts +91 -0
- package/dist/features.js +164 -0
- package/dist/format.d.ts +57 -0
- package/dist/format.js +248 -0
- package/dist/identity.d.ts +236 -0
- package/dist/identity.js +751 -0
- package/dist/inbound.d.ts +32 -0
- package/dist/inbound.js +258 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +14 -0
- package/dist/join-answers.d.ts +49 -0
- package/dist/join-answers.js +149 -0
- package/dist/outbox.d.ts +109 -0
- package/dist/outbox.js +337 -0
- package/dist/pretty.d.ts +100 -0
- package/dist/pretty.js +256 -0
- package/dist/procstart.d.ts +1 -0
- package/dist/procstart.js +66 -0
- package/dist/progress.d.ts +30 -0
- package/dist/progress.js +78 -0
- package/dist/projects.d.ts +240 -0
- package/dist/projects.js +699 -0
- package/dist/prompt/picker.d.ts +64 -0
- package/dist/prompt/picker.js +152 -0
- package/dist/prompt/tty.d.ts +29 -0
- package/dist/prompt/tty.js +122 -0
- package/dist/readonly.d.ts +20 -0
- package/dist/readonly.js +50 -0
- package/dist/receipts.d.ts +99 -0
- package/dist/receipts.js +180 -0
- package/dist/relay-client.d.ts +277 -0
- package/dist/relay-client.js +873 -0
- package/dist/relay-info.d.ts +24 -0
- package/dist/relay-info.js +53 -0
- package/dist/rotation.d.ts +402 -0
- package/dist/rotation.js +2054 -0
- package/dist/running.d.ts +5 -0
- package/dist/running.js +74 -0
- package/dist/sessions.d.ts +340 -0
- package/dist/sessions.js +1152 -0
- package/dist/shortcode.d.ts +149 -0
- package/dist/shortcode.js +465 -0
- package/dist/social.d.ts +139 -0
- package/dist/social.js +485 -0
- package/dist/state.d.ts +483 -0
- package/dist/state.js +217 -0
- package/dist/stdin.d.ts +17 -0
- package/dist/stdin.js +46 -0
- package/dist/sync.d.ts +77 -0
- package/dist/sync.js +375 -0
- package/dist/transient.d.ts +1 -0
- package/dist/transient.js +28 -0
- package/dist/trust.d.ts +37 -0
- package/dist/trust.js +134 -0
- package/dist/tty-confirm.d.ts +2 -0
- package/dist/tty-confirm.js +53 -0
- package/dist/tui/command.d.ts +20 -0
- package/dist/tui/command.js +70 -0
- package/dist/tui/frame.d.ts +43 -0
- package/dist/tui/frame.js +111 -0
- package/dist/tui/model.d.ts +215 -0
- package/dist/tui/model.js +255 -0
- package/dist/tui/sanitize.d.ts +13 -0
- package/dist/tui/sanitize.js +151 -0
- package/dist/tui/terminal.d.ts +88 -0
- package/dist/tui/terminal.js +354 -0
- package/dist/tui/tui.d.ts +71 -0
- package/dist/tui/tui.js +571 -0
- package/dist/tui/view.d.ts +4 -0
- package/dist/tui/view.js +356 -0
- package/dist/unknown-kinds.d.ts +12 -0
- package/dist/unknown-kinds.js +66 -0
- package/dist/version.d.ts +1 -0
- package/dist/version.js +5 -0
- package/dist/want-pow.d.ts +12 -0
- package/dist/want-pow.js +46 -0
- package/dist/watch.d.ts +35 -0
- package/dist/watch.js +325 -0
- package/dist/xstate.d.ts +125 -0
- package/dist/xstate.js +422 -0
- package/package.json +60 -4
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { App } from "./app.js";
|
|
2
|
+
export interface RelayInfoRec {
|
|
3
|
+
/** When it was fetched (ms). */
|
|
4
|
+
at: number;
|
|
5
|
+
/** Whether the relay answered with its info. */
|
|
6
|
+
ok: boolean;
|
|
7
|
+
/** Its protocol minor (0: a relay from before features were listed). */
|
|
8
|
+
minor: number;
|
|
9
|
+
features: string[];
|
|
10
|
+
frames: string[];
|
|
11
|
+
software?: string;
|
|
12
|
+
}
|
|
13
|
+
export declare const RELAY_INFO_TTL_MS: number;
|
|
14
|
+
export declare const RELAY_INFO_RETRY_MS: number;
|
|
15
|
+
/** The frames every v3 relay answers (protocol 3.0). */
|
|
16
|
+
export declare const BASELINE_RELAY_FRAMES: readonly string[];
|
|
17
|
+
/** A relay that stores identity documents and caps with fields it doesn't know (the crit rule). */
|
|
18
|
+
export declare const RELAY_FEATURE_LENIENT_IDENTITY = "identity.lenient";
|
|
19
|
+
/** A relay's info, from the cache or fetched; never throws (an unreachable relay is the baseline). */
|
|
20
|
+
export declare function relayInfo(app: App, relay: string, opts?: {
|
|
21
|
+
refresh?: boolean;
|
|
22
|
+
}): Promise<RelayInfoRec>;
|
|
23
|
+
/** Whether every one of `relays` lists `feature` (no relay: no). */
|
|
24
|
+
export declare function relaysSupport(app: App, relays: readonly string[], feature: string): Promise<boolean>;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
// Copyright 2026 Ix Infrastructure Inc.
|
|
2
|
+
//
|
|
3
|
+
// What a relay supports, from its /.well-known/p2p-relay.json (docs/compatibility.md): the frames
|
|
4
|
+
// it answers, its protocol minor and its features. A relay from before this listed none: it is
|
|
5
|
+
// taken to support the baseline (everything up to protocol 3.0), and nothing newer is asked of it.
|
|
6
|
+
// An older client never asks, and works with a newer relay as before.
|
|
7
|
+
//
|
|
8
|
+
// - Cached in state (`relayInfo`) for RELAY_INFO_TTL_MS; a relay that didn't answer is asked again
|
|
9
|
+
// after RELAY_INFO_RETRY_MS (and counts as baseline meanwhile).
|
|
10
|
+
// - Features this client checks: `identity.lenient` (the relay stores identity documents and caps
|
|
11
|
+
// that carry fields it doesn't know, under the crit rule), before it publishes an identity
|
|
12
|
+
// document with device info (`dinfo`). Unknown features are kept and shown, never relied on.
|
|
13
|
+
import { canonicalRelayUrl } from "@peer2peer/core/v3";
|
|
14
|
+
import { fetchRelayInfo } from "./relay-client.js";
|
|
15
|
+
export const RELAY_INFO_TTL_MS = 24 * 3600 * 1000;
|
|
16
|
+
export const RELAY_INFO_RETRY_MS = 3600 * 1000;
|
|
17
|
+
const RELAY_INFO_TIMEOUT_MS = 5000;
|
|
18
|
+
/** The frames every v3 relay answers (protocol 3.0). */
|
|
19
|
+
export const BASELINE_RELAY_FRAMES = ["auth", "send", "ack", "revoke", "identity", "link-put", "link-get", "link-open"];
|
|
20
|
+
/** A relay that stores identity documents and caps with fields it doesn't know (the crit rule). */
|
|
21
|
+
export const RELAY_FEATURE_LENIENT_IDENTITY = "identity.lenient";
|
|
22
|
+
const strs = (v, max) => Array.isArray(v) ? v.filter((x) => typeof x === "string" && /^[a-z][a-z0-9._-]{0,47}$/.test(x)).slice(0, max) : [];
|
|
23
|
+
/** A relay's info, from the cache or fetched; never throws (an unreachable relay is the baseline). */
|
|
24
|
+
export async function relayInfo(app, relay, opts = {}) {
|
|
25
|
+
const url = canonicalRelayUrl(relay);
|
|
26
|
+
const now = Date.now();
|
|
27
|
+
const held = ((await app.state.get("relayInfo")) ?? {})[url];
|
|
28
|
+
if (held && !opts.refresh && now - held.at < (held.ok ? RELAY_INFO_TTL_MS : RELAY_INFO_RETRY_MS))
|
|
29
|
+
return held;
|
|
30
|
+
let rec;
|
|
31
|
+
try {
|
|
32
|
+
const j = await fetchRelayInfo(app.transport(url), RELAY_INFO_TIMEOUT_MS, app.progress);
|
|
33
|
+
const minor = typeof j?.protocolMinor === "number" && Number.isSafeInteger(j.protocolMinor) && j.protocolMinor >= 0 ? j.protocolMinor : 0;
|
|
34
|
+
const sw = j?.software?.version;
|
|
35
|
+
rec = j
|
|
36
|
+
? { at: now, ok: true, minor, features: strs(j.features, 64), frames: strs(j.frames, 64), ...(typeof sw === "string" ? { software: sw.slice(0, 40) } : {}) }
|
|
37
|
+
: { at: now, ok: false, minor: 0, features: [], frames: [] };
|
|
38
|
+
}
|
|
39
|
+
catch {
|
|
40
|
+
rec = { at: now, ok: false, minor: 0, features: [], frames: [] };
|
|
41
|
+
}
|
|
42
|
+
await app.state.update("relayInfo", (cur = {}) => ({ next: { ...cur, [url]: rec }, result: undefined }));
|
|
43
|
+
return rec;
|
|
44
|
+
}
|
|
45
|
+
/** Whether every one of `relays` lists `feature` (no relay: no). */
|
|
46
|
+
export async function relaysSupport(app, relays, feature) {
|
|
47
|
+
if (relays.length === 0)
|
|
48
|
+
return false;
|
|
49
|
+
for (const r of relays)
|
|
50
|
+
if (!(await relayInfo(app, r)).features.includes(feature))
|
|
51
|
+
return false;
|
|
52
|
+
return true;
|
|
53
|
+
}
|
|
@@ -0,0 +1,402 @@
|
|
|
1
|
+
import { type RotationStatement, type VerifiedRotation } from "@peer2peer/core/v3";
|
|
2
|
+
import { App } from "./app.js";
|
|
3
|
+
import type { HeldItem } from "./state.js";
|
|
4
|
+
import { type EventFrom, type NewEvent } from "./inbound.js";
|
|
5
|
+
export type RotationStep = "created" | "published" | "devices" | "social" | "final" | "done";
|
|
6
|
+
export interface RotationDeviceRec {
|
|
7
|
+
label: string;
|
|
8
|
+
keyholder: boolean;
|
|
9
|
+
status: "pending" | "followed" | "offline" | "excluded" | "aborted";
|
|
10
|
+
/** The device's did under the new identity, once it followed. */
|
|
11
|
+
newDid?: string;
|
|
12
|
+
/** Why the plan drops it unless the user keeps it explicitly (pre-release re-review N2, L1). */
|
|
13
|
+
why?: string;
|
|
14
|
+
/** False when its label comes only from versions this device didn't publish (untrusted). */
|
|
15
|
+
labelTrusted?: boolean;
|
|
16
|
+
}
|
|
17
|
+
export interface RotationCircleRec {
|
|
18
|
+
name: string;
|
|
19
|
+
role: "owner" | "member";
|
|
20
|
+
status: "pending" | "done" | "failed" | "skipped";
|
|
21
|
+
reason?: string;
|
|
22
|
+
}
|
|
23
|
+
export interface RotationState {
|
|
24
|
+
v: 1;
|
|
25
|
+
from: string;
|
|
26
|
+
to: string;
|
|
27
|
+
statement: RotationStatement;
|
|
28
|
+
startedAt: number;
|
|
29
|
+
step: RotationStep;
|
|
30
|
+
/** The user accepted the plan (step `created` only waits for this). */
|
|
31
|
+
accepted?: boolean;
|
|
32
|
+
/** Contesting a rotation this device didn't publish (§2.8: a conflict, so neither applies). */
|
|
33
|
+
contest?: boolean;
|
|
34
|
+
keepKeyholders: boolean;
|
|
35
|
+
devices: Record<string, RotationDeviceRec>;
|
|
36
|
+
/** Excluded devices revoked on the old identity before any link code went out. */
|
|
37
|
+
revoked?: string[];
|
|
38
|
+
plan: {
|
|
39
|
+
friends: number;
|
|
40
|
+
owned: number;
|
|
41
|
+
memberOf: number;
|
|
42
|
+
};
|
|
43
|
+
/** The rotating device (its own signatures count as trusted). */
|
|
44
|
+
selfDid?: string;
|
|
45
|
+
/**
|
|
46
|
+
* pre-release re-review M1: per friend, the device that signed our side of each
|
|
47
|
+
* stored friendship (not ended by an unfriend), and whether it verifies now.
|
|
48
|
+
*/
|
|
49
|
+
friendSigners?: Record<string, {
|
|
50
|
+
did: string;
|
|
51
|
+
live: boolean;
|
|
52
|
+
}[]>;
|
|
53
|
+
/** Friends the plan leaves out by default that the user chose to invite anyway (`--invite`). */
|
|
54
|
+
inviteOptIn?: string[];
|
|
55
|
+
friends: Record<string, "pending" | "sent" | "failed">;
|
|
56
|
+
/** When `--resend` sent invites (ms), for the relays' per-sender contact limit. */
|
|
57
|
+
resendAt?: number[];
|
|
58
|
+
circles: Record<string, RotationCircleRec>;
|
|
59
|
+
proofs?: {
|
|
60
|
+
kind: string;
|
|
61
|
+
claim: string;
|
|
62
|
+
publish: string;
|
|
63
|
+
}[];
|
|
64
|
+
finalVer?: number;
|
|
65
|
+
/** False when a contest's final version couldn't reach any relay (they already refuse the old devices). */
|
|
66
|
+
finalPublished?: boolean;
|
|
67
|
+
backupFile?: string;
|
|
68
|
+
/** Where the old home went, once this home is the new identity's. */
|
|
69
|
+
archive?: string;
|
|
70
|
+
}
|
|
71
|
+
export declare function readRotationState(home: string): Promise<RotationState | undefined>;
|
|
72
|
+
/**
|
|
73
|
+
* Makes `src` (a home holding the new identity) this home's identity, after
|
|
74
|
+
* the old identity's work here has stopped (moveHomes).
|
|
75
|
+
*/
|
|
76
|
+
export declare function adoptHome(app: App, src: string, tag: string): Promise<string>;
|
|
77
|
+
/**
|
|
78
|
+
* §2.8, compromise: a rotation of this user's identity that this device
|
|
79
|
+
* didn't publish (judged by its publish log) is raised loudly, once per
|
|
80
|
+
* statement: a stderr line, a `p2p.alert` watch event (the mod shows it on
|
|
81
|
+
* its status line). A key holder is told to contest it.
|
|
82
|
+
*/
|
|
83
|
+
export declare function raiseRotationAlert(app: App, r: VerifiedRotation, by?: string): Promise<boolean>;
|
|
84
|
+
/** Alerts for every rotation on our own held tips this device didn't publish (no network). */
|
|
85
|
+
export declare function alertForeignRotations(app: App): Promise<void>;
|
|
86
|
+
export interface RotateOptions {
|
|
87
|
+
resume?: boolean;
|
|
88
|
+
/** Devices that must NOT follow (a lost or stolen one that is still listed): revoked first. */
|
|
89
|
+
exclude?: string[];
|
|
90
|
+
/** Devices the plan dropped by default (added by a version this device didn't publish, or not seen lately) to keep anyway. */
|
|
91
|
+
keep?: string[];
|
|
92
|
+
/** Friends the plan leaves out by default (see RotationPlan.friendsOptIn) to invite anyway. */
|
|
93
|
+
invite?: string[];
|
|
94
|
+
/** Followers that held the old identity key also hold the new one (default: they follow as ordinary devices). */
|
|
95
|
+
keepKeyholders?: boolean;
|
|
96
|
+
/** How long to wait for the other devices to follow (seconds; default the link code's 10 minutes). */
|
|
97
|
+
waitSec?: number;
|
|
98
|
+
/** Asks the user to accept the plan (it names the new fingerprint); `yes` accepts without asking. */
|
|
99
|
+
confirm?: (plan: RotationPlan) => Promise<boolean>;
|
|
100
|
+
yes?: boolean;
|
|
101
|
+
/** Write the new identity's backup phrase to this 0600 file (never overwritten). */
|
|
102
|
+
backupFile?: string;
|
|
103
|
+
/** The same, at `<home>/backup-phrase-<new fingerprint>.txt`. */
|
|
104
|
+
backupFileDefault?: boolean;
|
|
105
|
+
/** A key holder contests a rotation it didn't publish: a competing one, so neither applies. */
|
|
106
|
+
contest?: boolean;
|
|
107
|
+
/** Tests: stop after this step, as an interruption would. */
|
|
108
|
+
stopAfter?: RotationStep;
|
|
109
|
+
}
|
|
110
|
+
export interface RotationPlan {
|
|
111
|
+
from: string;
|
|
112
|
+
address: string;
|
|
113
|
+
/** The new identity this would move to (made, not yet published). */
|
|
114
|
+
to: string;
|
|
115
|
+
newFingerprint: string;
|
|
116
|
+
follow: {
|
|
117
|
+
did: string;
|
|
118
|
+
label: string;
|
|
119
|
+
keyholder: boolean;
|
|
120
|
+
labelTrusted: boolean;
|
|
121
|
+
}[];
|
|
122
|
+
/** `why`: dropped by default (keep it with `--keep <did>`); without it, the user dropped it. */
|
|
123
|
+
excluded: {
|
|
124
|
+
did: string;
|
|
125
|
+
label: string;
|
|
126
|
+
keyholder: boolean;
|
|
127
|
+
labelTrusted: boolean;
|
|
128
|
+
why?: string;
|
|
129
|
+
}[];
|
|
130
|
+
/** The friends that get the new identity's invite (exactly the ones `friendsOptIn` doesn't leave out). */
|
|
131
|
+
friends: number;
|
|
132
|
+
/**
|
|
133
|
+
* pre-release re-review M1: friendships this device can't vouch for (our side was
|
|
134
|
+
* signed by a device the plan drops or no longer lists, or, rotating
|
|
135
|
+
* normally, the friendship doesn't verify now). Not invited unless the
|
|
136
|
+
* user opts in (`--invite <user>`); `invited` says it did.
|
|
137
|
+
*/
|
|
138
|
+
friendsOptIn: {
|
|
139
|
+
userId: string;
|
|
140
|
+
address?: string;
|
|
141
|
+
why: string;
|
|
142
|
+
invited: boolean;
|
|
143
|
+
}[];
|
|
144
|
+
owned: number;
|
|
145
|
+
memberOf: number;
|
|
146
|
+
contest: boolean;
|
|
147
|
+
backup?: {
|
|
148
|
+
file: string;
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
export interface RotateResult {
|
|
152
|
+
from: string;
|
|
153
|
+
to: string;
|
|
154
|
+
address: string;
|
|
155
|
+
fingerprint: string;
|
|
156
|
+
did: string;
|
|
157
|
+
step: RotationStep;
|
|
158
|
+
contest?: boolean;
|
|
159
|
+
devices: {
|
|
160
|
+
followed: {
|
|
161
|
+
did: string;
|
|
162
|
+
newDid: string;
|
|
163
|
+
label: string;
|
|
164
|
+
}[];
|
|
165
|
+
offline: {
|
|
166
|
+
did: string;
|
|
167
|
+
label: string;
|
|
168
|
+
}[];
|
|
169
|
+
excluded: {
|
|
170
|
+
did: string;
|
|
171
|
+
label: string;
|
|
172
|
+
}[];
|
|
173
|
+
};
|
|
174
|
+
friends: {
|
|
175
|
+
invited: number;
|
|
176
|
+
failed: string[];
|
|
177
|
+
};
|
|
178
|
+
circles: {
|
|
179
|
+
cid: string;
|
|
180
|
+
name: string;
|
|
181
|
+
role: string;
|
|
182
|
+
status: string;
|
|
183
|
+
reason?: string;
|
|
184
|
+
}[];
|
|
185
|
+
proofs: {
|
|
186
|
+
kind: string;
|
|
187
|
+
claim: string;
|
|
188
|
+
publish: string;
|
|
189
|
+
}[];
|
|
190
|
+
finalVer?: number;
|
|
191
|
+
finalPublished?: boolean;
|
|
192
|
+
backup?: {
|
|
193
|
+
file: string;
|
|
194
|
+
};
|
|
195
|
+
archive?: string;
|
|
196
|
+
warnings: string[];
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* pre-release re-review M1: whether `peer` gets the new identity's invite. Only a
|
|
200
|
+
* friendship whose our-side signature comes from this device or a device
|
|
201
|
+
* that stays in the plan counts (a thief's device can plant friendships with
|
|
202
|
+
* accomplices); rotating normally it must also verify now, while a contest
|
|
203
|
+
* also takes stored ones the other rotation left unverifiable. Anything else
|
|
204
|
+
* is shown in the plan, invited only when the user opts in.
|
|
205
|
+
*/
|
|
206
|
+
export declare function friendVerdict(st: RotationState, peer: string): {
|
|
207
|
+
invite: boolean;
|
|
208
|
+
why?: string;
|
|
209
|
+
};
|
|
210
|
+
/**
|
|
211
|
+
* `p2p identity rotate --plan`: makes the new identity key (published only
|
|
212
|
+
* once the plan is accepted) and shows what would happen: the new
|
|
213
|
+
* fingerprint, the devices that would follow, and what moves.
|
|
214
|
+
*/
|
|
215
|
+
export declare function rotatePlan(app: App, opts?: RotateOptions): Promise<RotationPlan>;
|
|
216
|
+
/** `p2p identity rotate --cancel`: drops a rotation whose plan wasn't accepted (nothing was published). */
|
|
217
|
+
export declare function rotateCancel(app: App): Promise<{
|
|
218
|
+
cancelled: boolean;
|
|
219
|
+
to?: string;
|
|
220
|
+
}>;
|
|
221
|
+
export declare function rotate(app: App, opts?: RotateOptions): Promise<RotateResult>;
|
|
222
|
+
/** A device counts as seen lately when it sent this device something, or got a certificate, in the last 30 days. */
|
|
223
|
+
export declare const DEVICE_SEEN_WINDOW_SEC: number;
|
|
224
|
+
/**
|
|
225
|
+
* pre-release re-review L1: during a rotation window (a rotation under way on this
|
|
226
|
+
* device, our identity carrying a rotation, or one this device alerted
|
|
227
|
+
* about), why a friendship synced from another of our devices whose our-side
|
|
228
|
+
* signer is `did` isn't taken: that device is one the rotation drops, or one
|
|
229
|
+
* deviceTrust can't vouch for. Undefined (take it) outside a window, and for
|
|
230
|
+
* this device's own signature.
|
|
231
|
+
*/
|
|
232
|
+
export declare function untrustedImportSigner(app: App, did: string): Promise<string | undefined>;
|
|
233
|
+
/** The most invites `--resend` sends in a rolling hour: under the relays' per-sender contact limit. */
|
|
234
|
+
export declare const RESEND_PER_HOUR = 50;
|
|
235
|
+
/**
|
|
236
|
+
* `p2p identity rotate --resend` (after the rotation is done): re-sends the
|
|
237
|
+
* new identity's invite to the friends no invite reached, throttled under
|
|
238
|
+
* the relays' per-sender limit on contacts (at most RESEND_PER_HOUR, or 80%
|
|
239
|
+
* of what a relay advertises, in a rolling hour).
|
|
240
|
+
*/
|
|
241
|
+
export declare function rotateResend(app: App): Promise<{
|
|
242
|
+
sent: number;
|
|
243
|
+
failed: string[];
|
|
244
|
+
remaining: number;
|
|
245
|
+
throttled: boolean;
|
|
246
|
+
}>;
|
|
247
|
+
/** The verified rotations known for `old`: recorded ones and those its held document's tips carry. */
|
|
248
|
+
export declare function rotationsFor(app: App, old: string): Promise<VerifiedRotation[]>;
|
|
249
|
+
/**
|
|
250
|
+
* §2.8: more than one rotation from the same old id is a conflict
|
|
251
|
+
* (rotationConflicts). Once the user settled one (`p2p identity dispute`),
|
|
252
|
+
* the identities they rejected no longer count; a rotation to anyone new
|
|
253
|
+
* conflicts again.
|
|
254
|
+
*/
|
|
255
|
+
export declare function rotationConflict(app: App, r: VerifiedRotation): Promise<string[] | undefined>;
|
|
256
|
+
/** A `rotationApprovals` sync from another of our devices: recorded here, and a conflict already known disputes now. */
|
|
257
|
+
export declare function importRotationApprovals(app: App, list: unknown): Promise<void>;
|
|
258
|
+
/** A `rotationDispute` sync from another of our devices: the same identities suspended, the same dispute held. */
|
|
259
|
+
/**
|
|
260
|
+
* A `rotationDispute` sync from another of our devices (pre-release third review
|
|
261
|
+
* M-A): never acted on as claimed. Its statements are verified here (each is
|
|
262
|
+
* signed by the old and the new identity key) and the old identity's
|
|
263
|
+
* document refreshed; only a conflict this device then verifies itself
|
|
264
|
+
* counts, and only the identities in that verified conflict that the
|
|
265
|
+
* sending device suspended are suspended here too (on a key holder, also
|
|
266
|
+
* out of the circles it owns). A claim this device can't verify is a quiet
|
|
267
|
+
* note: nothing is blocked, held or published.
|
|
268
|
+
*/
|
|
269
|
+
export declare function importRotationDispute(app: App, body: unknown): Promise<void>;
|
|
270
|
+
/**
|
|
271
|
+
* `p2p identity dispute <id> --keep <userId> | --neither`: the user's
|
|
272
|
+
* decision after checking out of band. The rejected identities' friendships
|
|
273
|
+
* end locally, they leave the circles this owner swapped them into, and they
|
|
274
|
+
* stay suspended; the kept one is restored (back into the circles it was
|
|
275
|
+
* taken out of, or, when it was never carried over, its held rotation is
|
|
276
|
+
* applied now) and later rotations to the rejected ones no longer count as a
|
|
277
|
+
* conflict.
|
|
278
|
+
*
|
|
279
|
+
* pre-release re-review M2/M3: only on a key holder. The settlement changes circles
|
|
280
|
+
* this user owns (which only the identity key signs) and goes to every
|
|
281
|
+
* other device of the user, which take it from a key holder only; anywhere
|
|
282
|
+
* else it is refused, loudly, with nothing changed.
|
|
283
|
+
*/
|
|
284
|
+
export declare function resolveDispute(app: App, id: string, choice: {
|
|
285
|
+
keep?: string;
|
|
286
|
+
neither?: boolean;
|
|
287
|
+
}): Promise<Record<string, unknown>>;
|
|
288
|
+
/** A `rotationResolved` sync: taken only from one of our current key holders (they alone settle, see resolveDispute). */
|
|
289
|
+
export declare function importRotationResolved(app: App, body: unknown, fromDid?: string): Promise<void>;
|
|
290
|
+
/** Whether the old identity's own held document (its final version) carries exactly this statement. */
|
|
291
|
+
export declare function publishedByOld(app: App, r: VerifiedRotation): Promise<boolean>;
|
|
292
|
+
/** Records a rotation and flags the held items it now conflicts with. */
|
|
293
|
+
export declare function noteRotation(app: App, r: VerifiedRotation): Promise<boolean>;
|
|
294
|
+
/** A friend's or co-member's document now carries a rotation (the 10-minute refresh, no push). */
|
|
295
|
+
export declare function noteDocRotations(app: App, userId: string): Promise<void>;
|
|
296
|
+
/**
|
|
297
|
+
* A friend's new identity sent its invite with the statement (`contact`
|
|
298
|
+
* {rotation, invite}): held as "<friend> moved to a new key" (§2.8: carry a
|
|
299
|
+
* friendship over only after asking). From someone who was never a friend
|
|
300
|
+
* of the old identity, it is an ordinary invite.
|
|
301
|
+
*/
|
|
302
|
+
export declare function onRotationContact(app: App, env: string, at: number, from: EventFrom, rotation: VerifiedRotation, invite: {
|
|
303
|
+
jws: string;
|
|
304
|
+
exp: number;
|
|
305
|
+
iss: string;
|
|
306
|
+
}): Promise<NewEvent[]>;
|
|
307
|
+
/**
|
|
308
|
+
* Approving a held "moved to a new key": both halves verified again, the old
|
|
309
|
+
* identity's document refreshed, refused on any conflict and refused unless
|
|
310
|
+
* the old identity's own final version carries this same statement (pre-release review H2: a statement it never published can't split it from its
|
|
311
|
+
* friends); then the normal accept flow with the new identity, and the old
|
|
312
|
+
* friendship ends locally. A petname carries over.
|
|
313
|
+
*/
|
|
314
|
+
export declare function approveRotation(app: App, item: HeldItem, opts?: {
|
|
315
|
+
force?: boolean;
|
|
316
|
+
}): Promise<Record<string, unknown>>;
|
|
317
|
+
export interface RotationJoinOutcome {
|
|
318
|
+
events: NewEvent[];
|
|
319
|
+
/** Circles whose statements from the new identity (and the old one's leave) were handled here (ownerDuties skips them). */
|
|
320
|
+
handled: Set<string>;
|
|
321
|
+
/** The old identity, when a rotation was handled. */
|
|
322
|
+
old?: string;
|
|
323
|
+
}
|
|
324
|
+
/** Whether this owner holds changes to `cid` for approval (`p2p circle hold`). */
|
|
325
|
+
export declare function circleHeld(app: App, cid: string): Promise<boolean>;
|
|
326
|
+
/**
|
|
327
|
+
* A `circle` bundle carrying `rotation` with the new identity's join. For a
|
|
328
|
+
* circle this device owns (key holder): the old identity swapped for the new
|
|
329
|
+
* as a member in one version only when rotationJoinVerdict allows it; an
|
|
330
|
+
* admin's rights are held for the owner's approval; anything else is held as
|
|
331
|
+
* `rotation-join` (re-checked when the old identity's final version shows up).
|
|
332
|
+
*/
|
|
333
|
+
export declare function onRotationJoin(app: App, env: string, at: number, from: EventFrom, statement: RotationStatement, sender: string, joins: readonly {
|
|
334
|
+
iss: string;
|
|
335
|
+
cid: string;
|
|
336
|
+
op: string;
|
|
337
|
+
jws: string;
|
|
338
|
+
}[]): Promise<RotationJoinOutcome>;
|
|
339
|
+
/**
|
|
340
|
+
* Held `rotation-join`s waiting for the old identity's final version: applied
|
|
341
|
+
* once it carries the statement (and nothing else stops them). Run after a
|
|
342
|
+
* drain and on watch's 10-minute refresh.
|
|
343
|
+
*/
|
|
344
|
+
export declare function retryRotationJoins(app: App): Promise<NewEvent[]>;
|
|
345
|
+
/**
|
|
346
|
+
* Owner: approves a held `rotation-join` (refused on a conflict, or before
|
|
347
|
+
* the old identity's final version carries the statement): swaps old for
|
|
348
|
+
* new, or adds the new identity, and, since the owner approves it here,
|
|
349
|
+
* carries an admin's rights over (`admin` items do only that).
|
|
350
|
+
*/
|
|
351
|
+
export declare function approveRotationJoin(app: App, item: HeldItem, opts?: {
|
|
352
|
+
force?: boolean;
|
|
353
|
+
}): Promise<Record<string, unknown>>;
|
|
354
|
+
/**
|
|
355
|
+
* A `sync` from our own (old) identity with `{rotation: {statement, link,
|
|
356
|
+
* keyholder?}}` (pre-release review H2): never followed by itself. On an ordinary
|
|
357
|
+
* device it is held (with the new fingerprint and the sending device) for
|
|
358
|
+
* the user to follow, or not; a key-holding device never follows, it alerts
|
|
359
|
+
* and offers to contest. Only a sync from a current key holder counts, with
|
|
360
|
+
* a statement from our own identity.
|
|
361
|
+
*/
|
|
362
|
+
export declare function noteOwnRotation(app: App, body: unknown, fromDid?: string): Promise<void>;
|
|
363
|
+
/**
|
|
364
|
+
* `p2p identity follow <id>` (or approving the held item): the user's own
|
|
365
|
+
* decision to move this device with its identity. Links to the new identity
|
|
366
|
+
* with the code the key holder sent, then makes this home the new identity's
|
|
367
|
+
* (the old one archived). A key-holding device never follows. If the key
|
|
368
|
+
* holder isn't answering any more, re-link by hand (`link join --rotated`).
|
|
369
|
+
*/
|
|
370
|
+
export declare function followHeld(app: App, idOrItem: string | HeldItem): Promise<{
|
|
371
|
+
userId: string;
|
|
372
|
+
address: string;
|
|
373
|
+
did: string;
|
|
374
|
+
from: string;
|
|
375
|
+
keyholder: boolean;
|
|
376
|
+
}>;
|
|
377
|
+
/**
|
|
378
|
+
* L4: a follow that linked to the new identity but died before (or while)
|
|
379
|
+
* this home was swapped finishes on the next run: `rotation/follow` then
|
|
380
|
+
* holds the new identity and a `linked.json` marker. Pure file work, run
|
|
381
|
+
* before the home's identity is loaded. Returns true when it finished one.
|
|
382
|
+
*/
|
|
383
|
+
export declare function recoverInterruptedFollow(home: string): Promise<boolean>;
|
|
384
|
+
/**
|
|
385
|
+
* `p2p link join <code> --rotated`: a device whose identity was rotated
|
|
386
|
+
* without it re-links by hand. Allowed only when this home's identity
|
|
387
|
+
* carries a rotation (its final version, or a rotation our key holder
|
|
388
|
+
* sent), and only into an identity a rotation names.
|
|
389
|
+
*/
|
|
390
|
+
export declare function relinkRotated(app: App, code: string, opts?: {
|
|
391
|
+
label?: string;
|
|
392
|
+
}): Promise<{
|
|
393
|
+
compareCode: string;
|
|
394
|
+
did: string;
|
|
395
|
+
wait: () => Promise<{
|
|
396
|
+
from: string;
|
|
397
|
+
userId: string;
|
|
398
|
+
address: string;
|
|
399
|
+
did: string;
|
|
400
|
+
keyholder: boolean;
|
|
401
|
+
}>;
|
|
402
|
+
}>;
|