@peer2peer/cli 0.0.0-stage → 0.1.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.
Files changed (111) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +370 -2
  3. package/dist/ancestry.d.ts +13 -0
  4. package/dist/ancestry.js +71 -0
  5. package/dist/app.d.ts +368 -0
  6. package/dist/app.js +1181 -0
  7. package/dist/bin.d.ts +2 -0
  8. package/dist/bin.js +56 -0
  9. package/dist/circle-ops.d.ts +402 -0
  10. package/dist/circle-ops.js +1725 -0
  11. package/dist/cli.d.ts +660 -0
  12. package/dist/cli.js +1787 -0
  13. package/dist/codes.d.ts +231 -0
  14. package/dist/codes.js +998 -0
  15. package/dist/config.d.ts +159 -0
  16. package/dist/config.js +294 -0
  17. package/dist/doctor.d.ts +113 -0
  18. package/dist/doctor.js +930 -0
  19. package/dist/errors.d.ts +8 -0
  20. package/dist/errors.js +29 -0
  21. package/dist/ext-host.d.ts +38 -0
  22. package/dist/ext-host.js +293 -0
  23. package/dist/extensions.d.ts +487 -0
  24. package/dist/extensions.js +406 -0
  25. package/dist/features.d.ts +91 -0
  26. package/dist/features.js +164 -0
  27. package/dist/format.d.ts +57 -0
  28. package/dist/format.js +248 -0
  29. package/dist/graph-memory.d.ts +107 -0
  30. package/dist/graph-memory.js +393 -0
  31. package/dist/history.d.ts +155 -0
  32. package/dist/history.js +697 -0
  33. package/dist/identity.d.ts +239 -0
  34. package/dist/identity.js +759 -0
  35. package/dist/inbound.d.ts +32 -0
  36. package/dist/inbound.js +261 -0
  37. package/dist/index.d.ts +8 -0
  38. package/dist/index.js +14 -0
  39. package/dist/ix-local.d.ts +76 -0
  40. package/dist/ix-local.js +203 -0
  41. package/dist/join-answers.d.ts +49 -0
  42. package/dist/join-answers.js +149 -0
  43. package/dist/outbox.d.ts +109 -0
  44. package/dist/outbox.js +337 -0
  45. package/dist/pretty.d.ts +100 -0
  46. package/dist/pretty.js +256 -0
  47. package/dist/procstart.d.ts +1 -0
  48. package/dist/procstart.js +66 -0
  49. package/dist/progress.d.ts +30 -0
  50. package/dist/progress.js +78 -0
  51. package/dist/projects.d.ts +491 -0
  52. package/dist/projects.js +1383 -0
  53. package/dist/prompt/picker.d.ts +64 -0
  54. package/dist/prompt/picker.js +152 -0
  55. package/dist/prompt/tty.d.ts +29 -0
  56. package/dist/prompt/tty.js +122 -0
  57. package/dist/readonly.d.ts +20 -0
  58. package/dist/readonly.js +50 -0
  59. package/dist/receipts.d.ts +99 -0
  60. package/dist/receipts.js +182 -0
  61. package/dist/relay-client.d.ts +277 -0
  62. package/dist/relay-client.js +873 -0
  63. package/dist/relay-info.d.ts +24 -0
  64. package/dist/relay-info.js +53 -0
  65. package/dist/rotation.d.ts +402 -0
  66. package/dist/rotation.js +2054 -0
  67. package/dist/running.d.ts +5 -0
  68. package/dist/running.js +74 -0
  69. package/dist/sessions.d.ts +355 -0
  70. package/dist/sessions.js +1247 -0
  71. package/dist/shortcode.d.ts +149 -0
  72. package/dist/shortcode.js +465 -0
  73. package/dist/social.d.ts +139 -0
  74. package/dist/social.js +485 -0
  75. package/dist/state.d.ts +509 -0
  76. package/dist/state.js +220 -0
  77. package/dist/stdin.d.ts +17 -0
  78. package/dist/stdin.js +46 -0
  79. package/dist/sync.d.ts +77 -0
  80. package/dist/sync.js +375 -0
  81. package/dist/transient.d.ts +1 -0
  82. package/dist/transient.js +28 -0
  83. package/dist/trust.d.ts +37 -0
  84. package/dist/trust.js +134 -0
  85. package/dist/tty-confirm.d.ts +2 -0
  86. package/dist/tty-confirm.js +53 -0
  87. package/dist/tui/command.d.ts +20 -0
  88. package/dist/tui/command.js +70 -0
  89. package/dist/tui/frame.d.ts +43 -0
  90. package/dist/tui/frame.js +111 -0
  91. package/dist/tui/model.d.ts +221 -0
  92. package/dist/tui/model.js +259 -0
  93. package/dist/tui/sanitize.d.ts +13 -0
  94. package/dist/tui/sanitize.js +151 -0
  95. package/dist/tui/terminal.d.ts +88 -0
  96. package/dist/tui/terminal.js +354 -0
  97. package/dist/tui/tui.d.ts +78 -0
  98. package/dist/tui/tui.js +612 -0
  99. package/dist/tui/view.d.ts +4 -0
  100. package/dist/tui/view.js +358 -0
  101. package/dist/unknown-kinds.d.ts +12 -0
  102. package/dist/unknown-kinds.js +66 -0
  103. package/dist/version.d.ts +1 -0
  104. package/dist/version.js +5 -0
  105. package/dist/want-pow.d.ts +12 -0
  106. package/dist/want-pow.js +46 -0
  107. package/dist/watch.d.ts +35 -0
  108. package/dist/watch.js +331 -0
  109. package/dist/xstate.d.ts +125 -0
  110. package/dist/xstate.js +422 -0
  111. package/package.json +60 -4
@@ -0,0 +1,239 @@
1
+ import { type DisplayProfile, type ProofFetchers } from "@peer2peer/core/v3";
2
+ import { type App } from "./app.js";
3
+ import { type SetupIx } from "./ix-local.js";
4
+ export interface InitResult {
5
+ userId: string;
6
+ address: string;
7
+ fingerprint: string;
8
+ did: string;
9
+ relays: string[];
10
+ published: string[];
11
+ failed: {
12
+ relay: string;
13
+ code: string;
14
+ }[];
15
+ }
16
+ export declare function init(app: App, opts: {
17
+ name?: string;
18
+ relays?: string[];
19
+ }): Promise<InitResult>;
20
+ export interface SetupResult {
21
+ userId: string;
22
+ address: string;
23
+ fingerprint: string;
24
+ did: string;
25
+ relays: string[];
26
+ /** False when this home already held an identity (nothing was changed). */
27
+ created: boolean;
28
+ published?: string[];
29
+ failed?: {
30
+ relay: string;
31
+ code: string;
32
+ }[];
33
+ /** Present only when the phrase was saved (`file`) or printing was asked for (`phrase`). */
34
+ backup?: {
35
+ file?: string;
36
+ phrase?: string;
37
+ };
38
+ /** Ix on by default (ix-local.ts setupIx): found, enabled, and what to do when it isn't. */
39
+ ix?: SetupIx;
40
+ }
41
+ export declare const BACKUP_FILE_NAME = "backup-phrase.txt";
42
+ export declare function setup(app: App, opts: {
43
+ name?: string;
44
+ relays?: string[];
45
+ backup?: "file" | "print" | "none";
46
+ backupFile?: string;
47
+ }): Promise<SetupResult>;
48
+ export declare function relaysList(app: App): Promise<{
49
+ relays: string[];
50
+ }>;
51
+ export interface RelaysChange {
52
+ relays: string[];
53
+ ver: number;
54
+ published: string[];
55
+ failed: {
56
+ relay: string;
57
+ code: string;
58
+ }[];
59
+ /** Friends sent a fresh friend cap naming the new relay list. */
60
+ capsReissued: number;
61
+ /** Circles whose join statement was re-signed with a co-member cap on the new relays. */
62
+ rejoined: string[];
63
+ /** relays remove: old caps revoked at the removed relay (best effort). */
64
+ revokedAtRemoved?: number;
65
+ }
66
+ /**
67
+ * review L5: caps name the relays they admit at. After the relay list changes,
68
+ * friends get a fresh friend cap on the new list and our circle joins are
69
+ * re-signed with a fresh co-member cap, so nobody is left holding caps only
70
+ * for relays we dropped. Old caps aren't revoked: a friend who hasn't picked
71
+ * up the new one still reaches the relays both name.
72
+ */
73
+ export declare function reissueForRelays(app: App): Promise<{
74
+ capsReissued: number;
75
+ rejoined: string[];
76
+ }>;
77
+ /** Adds a relay to your identity document (the next version, published to old and new relays). */
78
+ export declare function relaysAdd(app: App, url: string): Promise<RelaysChange>;
79
+ /** Removes a relay (at least one must stay). The removed relay gets the new version too, so it stops admitting removed state. */
80
+ export declare function relaysRemove(app: App, url: string): Promise<RelaysChange>;
81
+ export interface DeviceRow {
82
+ did: string;
83
+ label: string;
84
+ keyholder: boolean;
85
+ thisDevice: boolean;
86
+ certExp?: number;
87
+ }
88
+ export interface WhoamiResult {
89
+ userId: string;
90
+ name: string;
91
+ address: string;
92
+ fingerprint: string;
93
+ did: string;
94
+ keyholder: boolean;
95
+ devices: DeviceRow[];
96
+ relays: string[];
97
+ doc: {
98
+ ver: number;
99
+ exp: number;
100
+ freshness: string;
101
+ daysPastExp: number;
102
+ forked: boolean;
103
+ historyGap: boolean;
104
+ };
105
+ profile: DisplayProfile;
106
+ proofs: number;
107
+ defaultCircle?: string;
108
+ warnings: string[];
109
+ }
110
+ export declare function devices(app: App): Promise<DeviceRow[]>;
111
+ export declare function whoami(app: App): Promise<WhoamiResult>;
112
+ /**
113
+ * Revokes a device (§2.5): the next document version without it. Caps that
114
+ * device signed stop working at relays (§5.3 L1), so they are revoked and
115
+ * re-issued from this device, and membership statements it signed are
116
+ * re-signed (§3.3 N4).
117
+ */
118
+ export declare function revokeDevice(app: App, did: string): Promise<{
119
+ revoked: string;
120
+ ver: number;
121
+ capsReissued: number;
122
+ rejoined: string[];
123
+ warnings: string[];
124
+ }>;
125
+ export interface LinkStart {
126
+ code: string;
127
+ relay: string;
128
+ expiresAt: number;
129
+ /** Waits for the new device's request, asks `confirm`, then certifies it. */
130
+ wait(confirm: (req: {
131
+ label: string;
132
+ compareCode: string;
133
+ did: string;
134
+ }) => Promise<boolean>): Promise<{
135
+ did: string;
136
+ label: string;
137
+ keyholder: boolean;
138
+ ver: number;
139
+ }>;
140
+ cancel(): void;
141
+ }
142
+ export declare function linkStart(app: App, opts?: {
143
+ keyholder?: boolean;
144
+ relay?: string;
145
+ }): Promise<LinkStart>;
146
+ export interface LinkJoin {
147
+ compareCode: string;
148
+ did: string;
149
+ wait(): Promise<{
150
+ userId: string;
151
+ address: string;
152
+ did: string;
153
+ keyholder: boolean;
154
+ }>;
155
+ }
156
+ export declare function linkJoin(app: App, code: string, opts?: {
157
+ label?: string;
158
+ maxWaitMs?: number;
159
+ }): Promise<LinkJoin>;
160
+ export declare function backupShow(app: App): Promise<{
161
+ phrase: string;
162
+ words: number;
163
+ }>;
164
+ /**
165
+ * Restores the identity key on a fresh home: a new key-holding device and
166
+ * the next document version, which by default lists only this device (§2.7:
167
+ * normally revoking devices that were lost). Friendships and circles are not
168
+ * in the phrase: friends' certificates of the old devices stop verifying.
169
+ *
170
+ * review M4: "the relays hold no document" and "the relays couldn't be read"
171
+ * are different. Starting a new chain at version 1 needs `newChain`, and
172
+ * only when at least one relay answered and none holds a document.
173
+ */
174
+ export declare function backupRestore(app: App, phrase: string, opts: {
175
+ relays?: string[];
176
+ name?: string;
177
+ keepDevices?: boolean;
178
+ newChain?: boolean;
179
+ }): Promise<RestoreResult>;
180
+ export interface RestoreResult {
181
+ userId: string;
182
+ address: string;
183
+ did: string;
184
+ ver: number;
185
+ revoked: string[];
186
+ warnings: string[];
187
+ merged: number;
188
+ /** Relays that didn't accept the restored document (R3-M2). */
189
+ failed: {
190
+ relay: string;
191
+ code: string;
192
+ }[];
193
+ }
194
+ /** review H2/L5: revoking a key holder doesn't take the identity key back. */
195
+ export declare function lostKeyholderWarning(n: number): string;
196
+ /** An avatar value: an https URL or data: URI as given, or an image file made into a data: URI (≤ 4 KiB). */
197
+ export declare function avatarValue(input: string, read?: (p: string) => Promise<Uint8Array>): Promise<string>;
198
+ export declare function profileSet(app: App, opts: {
199
+ bio?: string;
200
+ avatar?: string;
201
+ links?: string[];
202
+ clear?: boolean;
203
+ }): Promise<{
204
+ profile: DisplayProfile;
205
+ ver: number;
206
+ }>;
207
+ export declare function profileShow(app: App, who?: string): Promise<{
208
+ userId: string;
209
+ address: string;
210
+ profile: DisplayProfile;
211
+ }>;
212
+ export interface ProofAddResult {
213
+ kind: "github" | "dns";
214
+ claim: string;
215
+ loc?: string;
216
+ proof?: string;
217
+ ver?: number;
218
+ /** What the user must publish at the counterpart. */
219
+ publish: string;
220
+ pending?: boolean;
221
+ }
222
+ export declare function proofAdd(app: App, kind: string, claimRaw: string, opts: {
223
+ gist?: string;
224
+ }): Promise<ProofAddResult>;
225
+ /** Fetchers for the built-in kinds: the GitHub gist API and DNS TXT. */
226
+ export declare function defaultProofFetchers(): ProofFetchers;
227
+ export interface ProofCheck {
228
+ kind: string;
229
+ claim: string;
230
+ loc: string;
231
+ verified: boolean;
232
+ display?: string;
233
+ error?: string;
234
+ }
235
+ export declare function proofVerify(app: App, who: string, fetchers?: ProofFetchers): Promise<{
236
+ userId: string;
237
+ address: string;
238
+ proofs: ProofCheck[];
239
+ }>;