@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
package/dist/codes.d.ts
ADDED
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
import { type CirclePolicy } from "@peer2peer/core/v3";
|
|
2
|
+
import type { App, Delivery } from "./app.js";
|
|
3
|
+
import { type EventFrom, type NewEvent } from "./inbound.js";
|
|
4
|
+
import type { CodeRecord } from "./state.js";
|
|
5
|
+
export declare const CODE_LABEL_MAX = 64;
|
|
6
|
+
/** `K7QM…`: how a code is named once it is no longer secret. */
|
|
7
|
+
export declare const codeHint: (code: string) => string;
|
|
8
|
+
export interface InviteCodeResult {
|
|
9
|
+
/** `<relay host>/K7QM-3XPD-9TWA-HF2N-6RJC`: what the other person types after `p2p join`. */
|
|
10
|
+
code: string;
|
|
11
|
+
/** A line to paste into a message. */
|
|
12
|
+
line: string;
|
|
13
|
+
relay: string;
|
|
14
|
+
label: string | null;
|
|
15
|
+
to: {
|
|
16
|
+
userId: string;
|
|
17
|
+
address: string;
|
|
18
|
+
} | null;
|
|
19
|
+
/** The first circle (what clients before multi-circle codes join). */
|
|
20
|
+
circle: {
|
|
21
|
+
cid: string;
|
|
22
|
+
name: string;
|
|
23
|
+
} | null;
|
|
24
|
+
/** Every circle the code joins, the first one first. */
|
|
25
|
+
circles: {
|
|
26
|
+
cid: string;
|
|
27
|
+
name: string;
|
|
28
|
+
members: number;
|
|
29
|
+
}[];
|
|
30
|
+
/** The same code as a web link: `https://ix-infra.com/p2p/invite#<code>`. */
|
|
31
|
+
web: string;
|
|
32
|
+
/** Unix seconds. */
|
|
33
|
+
expiresAt: number;
|
|
34
|
+
/** Always 1: a code is single-use. */
|
|
35
|
+
uses: 1;
|
|
36
|
+
/** The relay lookup id: a hash of the code, not secret. The inviter's `p2p.joined` event carries the same `lid`. */
|
|
37
|
+
lid: string;
|
|
38
|
+
/**
|
|
39
|
+
* A message to paste into Slack, Signal, …, for someone who may not have Peer2Peer yet: the web link,
|
|
40
|
+
* how to install the Claude Code plugin, the join command (with --allow-private-relay and a note when
|
|
41
|
+
* the code's relay is on a private network), and where the Codex instructions are.
|
|
42
|
+
*/
|
|
43
|
+
message: string;
|
|
44
|
+
/** The code's relay is on a private network (Tailscale, a LAN): joining it takes --allow-private-relay. */
|
|
45
|
+
privateRelay: boolean;
|
|
46
|
+
}
|
|
47
|
+
/** The Claude Code plugin's install steps, as the invite message gives them. */
|
|
48
|
+
export declare const PLUGIN_INSTALL: string[];
|
|
49
|
+
export declare const CODEX_INSTALL_URL = "https://github.com/ix-infrastructure/Peer2Peer/blob/main/packages/codex-bridge/README.md#install";
|
|
50
|
+
/** POSIX single quotes: `'` closes, an escaped quote, and opens again, so nothing can break out. */
|
|
51
|
+
export declare function shellQuote(s: string): string;
|
|
52
|
+
/** The `p2p join` line for a code's web link (quoted for the shell), with --allow-private-relay when it needs it. */
|
|
53
|
+
export declare function joinCommandFor(web: string, privateRelay: boolean): string;
|
|
54
|
+
/** The message `p2p invite` prints to send: self-contained for someone who has never installed Peer2Peer. */
|
|
55
|
+
export declare function inviteMessage(web: string, privateRelay: boolean): string;
|
|
56
|
+
/**
|
|
57
|
+
* Is this relay on a private network as this machine sees it (its host a private address, or a name
|
|
58
|
+
* resolving to one, as a Tailscale MagicDNS name does)? Bounded; unknown counts as not.
|
|
59
|
+
*/
|
|
60
|
+
export declare function relayLooksPrivate(relay: string): Promise<boolean>;
|
|
61
|
+
export declare function inviteCode(app: App, opts: {
|
|
62
|
+
label?: string;
|
|
63
|
+
circles?: string[];
|
|
64
|
+
noCircle?: boolean;
|
|
65
|
+
to?: string;
|
|
66
|
+
ttlDays?: number;
|
|
67
|
+
relay?: string;
|
|
68
|
+
}): Promise<InviteCodeResult>;
|
|
69
|
+
/** Merges code records from another of our devices: a later status wins. */
|
|
70
|
+
export declare function importCodes(app: App, recs: unknown[]): Promise<void>;
|
|
71
|
+
export declare function codeByInv(app: App, inv: string): Promise<CodeRecord | undefined>;
|
|
72
|
+
/** Runs after the accept of one of our codes' invites was recorded: the redeemer is added to each circle, the user is told. */
|
|
73
|
+
export declare function onCodeRedeemed(app: App, env: string, at: number, from: EventFrom, rec: CodeRecord, who: string): Promise<NewEvent[]>;
|
|
74
|
+
export interface JoinCircleOutcome {
|
|
75
|
+
cid: string;
|
|
76
|
+
name: string;
|
|
77
|
+
/**
|
|
78
|
+
* joined; pending: the inviter hasn't added us yet (finished by a later command); needs-approval: no
|
|
79
|
+
* second member confirmed it (`p2p held approve <held>`); held: not joined from the code (unverified,
|
|
80
|
+
* open, not run by the inviter, or not what was previewed): its circle invite, when it comes, is
|
|
81
|
+
* approved on its own (`reason` says why).
|
|
82
|
+
*/
|
|
83
|
+
status: "joined" | "already" | "pending" | "needs-approval" | "held";
|
|
84
|
+
default: boolean;
|
|
85
|
+
held?: string;
|
|
86
|
+
reason?: string;
|
|
87
|
+
}
|
|
88
|
+
/** A circle as a code's preview shows it. */
|
|
89
|
+
export interface PreviewCircle {
|
|
90
|
+
cid: string;
|
|
91
|
+
name: string;
|
|
92
|
+
members: number;
|
|
93
|
+
policy: CirclePolicy;
|
|
94
|
+
owner: string;
|
|
95
|
+
ownerAddress: string;
|
|
96
|
+
/** Signed by the owner it names (verifyCircleVersionAlone, or the first circle's chain). */
|
|
97
|
+
verified: boolean;
|
|
98
|
+
/** Joined on the yes: verified, not open, and the inviter is its owner or an admin. Else `note` says why not. */
|
|
99
|
+
auto: boolean;
|
|
100
|
+
note?: "unverified" | "open" | "not-admin";
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* What a code offers, shown before anything is accepted. Each circle is as its version in the code
|
|
104
|
+
* says, checked for the owner's signature (`verified`); only `auto` circles are joined on the yes, and
|
|
105
|
+
* each again only once its real chain arrives and matches (see completeCodeJoin).
|
|
106
|
+
*/
|
|
107
|
+
export interface CodePreview {
|
|
108
|
+
from: {
|
|
109
|
+
userId: string;
|
|
110
|
+
address: string;
|
|
111
|
+
fingerprint: string;
|
|
112
|
+
};
|
|
113
|
+
/** Set when the code was made for one person (it is this user, or nothing is accepted). */
|
|
114
|
+
to: string | null;
|
|
115
|
+
toAddress?: string;
|
|
116
|
+
circles: PreviewCircle[];
|
|
117
|
+
/** When the invite inside expires (unix seconds). */
|
|
118
|
+
expiresAt: number;
|
|
119
|
+
}
|
|
120
|
+
export interface JoinCodeResult {
|
|
121
|
+
from: {
|
|
122
|
+
userId: string;
|
|
123
|
+
address: string;
|
|
124
|
+
fingerprint: string;
|
|
125
|
+
};
|
|
126
|
+
friend: {
|
|
127
|
+
userId: string;
|
|
128
|
+
address: string;
|
|
129
|
+
};
|
|
130
|
+
delivered: Delivery | null;
|
|
131
|
+
/** The first circle's outcome (what clients before multi-circle codes report). */
|
|
132
|
+
circle: JoinCircleOutcome | null;
|
|
133
|
+
/** Every circle the code joins, the first one first. */
|
|
134
|
+
circles: JoinCircleOutcome[];
|
|
135
|
+
/** The default circle after the join (set to the code's circle when there was none). */
|
|
136
|
+
defaultCircle: string | null;
|
|
137
|
+
created: {
|
|
138
|
+
userId: string;
|
|
139
|
+
address: string;
|
|
140
|
+
relays: string[];
|
|
141
|
+
} | null;
|
|
142
|
+
/** Set when the identity this join created has only the code's relay (that host): show it to the user. */
|
|
143
|
+
relayWarning?: string;
|
|
144
|
+
}
|
|
145
|
+
export interface JoinCodeOpts {
|
|
146
|
+
waitSec?: number;
|
|
147
|
+
/** Scripts: consent to the join, and join a circle even when no second member confirmed it (§3.3). */
|
|
148
|
+
yes?: boolean;
|
|
149
|
+
/** The person already saw the preview and said yes (the Claude mod's Join button): no second question. */
|
|
150
|
+
consent?: boolean;
|
|
151
|
+
/** Only open the code and say what it offers: nothing is accepted, no identity is created. */
|
|
152
|
+
previewOnly?: boolean;
|
|
153
|
+
name?: string;
|
|
154
|
+
confirm?: (q: string) => Promise<boolean>;
|
|
155
|
+
/** Accept a code whose relay is a loopback, link-local or private host (a team relay on your own network). */
|
|
156
|
+
allowPrivateRelay?: boolean;
|
|
157
|
+
/** Creates an identity when there is none (identity.init); passed in to keep the module graph acyclic. */
|
|
158
|
+
create?: (app: App, opts: {
|
|
159
|
+
name?: string;
|
|
160
|
+
relays: string[];
|
|
161
|
+
}) => Promise<{
|
|
162
|
+
userId: string;
|
|
163
|
+
address: string;
|
|
164
|
+
relays: string[];
|
|
165
|
+
}>;
|
|
166
|
+
}
|
|
167
|
+
/** What a code offers, in words: who made it and every circle with its member count. */
|
|
168
|
+
export declare function previewText(p: CodePreview): string;
|
|
169
|
+
export declare function joinCode(app: App, input: string, opts?: JoinCodeOpts): Promise<JoinCodeResult>;
|
|
170
|
+
/** A code as messages show it: rebuilt from its parsed parts, never the raw input (which may be anything pasted). */
|
|
171
|
+
export declare function shownCode(input: string): string;
|
|
172
|
+
/** joinCode with `previewOnly`: what the code offers (thrown so nothing after the preview can run). */
|
|
173
|
+
export declare class CodePreviewReady extends Error {
|
|
174
|
+
readonly preview: CodePreview;
|
|
175
|
+
constructor(preview: CodePreview);
|
|
176
|
+
}
|
|
177
|
+
/** `p2p join --preview`: opens the code (kept here, used up on the relay) and says what it offers; accepts nothing. */
|
|
178
|
+
export declare function previewCode(app: App, input: string, opts?: {
|
|
179
|
+
allowPrivateRelay?: boolean;
|
|
180
|
+
}): Promise<CodePreview>;
|
|
181
|
+
/**
|
|
182
|
+
* After a drain (App.afterDrain): finishes code joins whose circle has
|
|
183
|
+
* arrived since `p2p join` returned. Joins that need the user's say stay
|
|
184
|
+
* held (`p2p held approve`).
|
|
185
|
+
*/
|
|
186
|
+
export declare function finishCodeJoins(app: App): Promise<NewEvent[]>;
|
|
187
|
+
export interface CodeRow {
|
|
188
|
+
code: string;
|
|
189
|
+
label: string | null;
|
|
190
|
+
to: {
|
|
191
|
+
userId: string;
|
|
192
|
+
address: string;
|
|
193
|
+
} | null;
|
|
194
|
+
circle: {
|
|
195
|
+
cid: string;
|
|
196
|
+
name: string;
|
|
197
|
+
} | null;
|
|
198
|
+
/** Every circle the code joins (multi-circle codes), the first one first. */
|
|
199
|
+
circles: {
|
|
200
|
+
cid: string;
|
|
201
|
+
name: string;
|
|
202
|
+
}[];
|
|
203
|
+
createdAt: number;
|
|
204
|
+
exp: number;
|
|
205
|
+
/** open: waiting on the relay; taken: fetched, nobody joined (yet); redeemed; expired; revoked. */
|
|
206
|
+
/** evicted: the relay dropped it to make room (full store); make a new code. */
|
|
207
|
+
status: "open" | "taken" | "evicted" | "redeemed" | "expired" | "revoked";
|
|
208
|
+
redeemedBy?: {
|
|
209
|
+
userId: string;
|
|
210
|
+
address: string;
|
|
211
|
+
};
|
|
212
|
+
redeemedAt?: number;
|
|
213
|
+
}
|
|
214
|
+
export declare function listCodes(app: App): Promise<CodeRow[]>;
|
|
215
|
+
export declare function revokeCode(app: App, input: string): Promise<{
|
|
216
|
+
code: string;
|
|
217
|
+
revoked: boolean;
|
|
218
|
+
wasOpen: boolean;
|
|
219
|
+
redeemedBy: string | null;
|
|
220
|
+
}>;
|
|
221
|
+
export interface RemoveResult {
|
|
222
|
+
removed: string;
|
|
223
|
+
address: string;
|
|
224
|
+
unfriended: boolean;
|
|
225
|
+
circles: {
|
|
226
|
+
cid: string;
|
|
227
|
+
result: "removed" | "proposed" | "not-member" | "not-allowed";
|
|
228
|
+
}[];
|
|
229
|
+
}
|
|
230
|
+
/** Undoes a code redemption: unfriends `who` and takes them out of the circles our codes added them to. */
|
|
231
|
+
export declare function removeUser(app: App, who: string): Promise<RemoveResult>;
|