ftown 0.19.53 → 0.19.55
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/dist/bridge-auth.d.ts +3 -0
- package/dist/bridge-auth.js.map +1 -1
- package/dist/command-rpc.js +21 -12
- package/dist/command-rpc.js.map +1 -1
- package/dist/index.js +124 -7
- package/dist/index.js.map +1 -1
- package/dist/pairing-client.d.ts +24 -12
- package/dist/pairing-client.js +383 -13
- package/dist/pairing-client.js.map +1 -1
- package/dist/security/account-crypto.d.ts +33 -0
- package/dist/security/account-crypto.js +649 -0
- package/dist/security/account-crypto.js.map +1 -0
- package/dist/security/account-protocol.d.ts +228 -0
- package/dist/security/account-protocol.js +2 -0
- package/dist/security/account-protocol.js.map +1 -0
- package/dist/security/bridge/account-client.d.ts +7 -0
- package/dist/security/bridge/account-client.js +87 -0
- package/dist/security/bridge/account-client.js.map +1 -0
- package/dist/security/bridge/account-state.d.ts +471 -0
- package/dist/security/bridge/account-state.js +78 -0
- package/dist/security/bridge/account-state.js.map +1 -0
- package/dist/security/bridge/execute.js +2 -1
- package/dist/security/bridge/execute.js.map +1 -1
- package/dist/security/bridge/identity.d.ts +436 -0
- package/dist/security/bridge/identity.js +27 -5
- package/dist/security/bridge/identity.js.map +1 -1
- package/dist/security/bridge/pending-approval.d.ts +21 -0
- package/dist/security/bridge/pending-approval.js +79 -0
- package/dist/security/bridge/pending-approval.js.map +1 -0
- package/dist/security/bridge/pending-enrollment.d.ts +33 -0
- package/dist/security/bridge/pending-enrollment.js +177 -0
- package/dist/security/bridge/pending-enrollment.js.map +1 -0
- package/dist/security/bridge/permissions.js +2 -2
- package/dist/security/bridge/permissions.js.map +1 -1
- package/dist/security/bridge/policy.d.ts +20 -0
- package/dist/security/bridge/policy.js +159 -7
- package/dist/security/bridge/policy.js.map +1 -1
- package/dist/security/bridge/security.d.ts +11 -0
- package/dist/security/bridge/security.js +93 -3
- package/dist/security/bridge/security.js.map +1 -1
- package/dist/security/bridge/snapshot.d.ts +1 -1
- package/dist/security/bridge/snapshot.js.map +1 -1
- package/dist/security/pending-approval-crypto.d.ts +29 -0
- package/dist/security/pending-approval-crypto.js +716 -0
- package/dist/security/pending-approval-crypto.js.map +1 -0
- package/dist/security/pending-approval-protocol.d.ts +329 -0
- package/dist/security/pending-approval-protocol.js +2 -0
- package/dist/security/pending-approval-protocol.js.map +1 -0
- package/dist/security/protocol.d.ts +12 -1
- package/dist/security-cli.js +15 -0
- package/dist/security-cli.js.map +1 -1
- package/dist/types.d.ts +1 -1
- package/package.json +2 -2
|
@@ -1,5 +1,441 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
1
2
|
import type { EndpointIdentity, EndpointKind } from '../protocol.js';
|
|
3
|
+
import type { VerifiedAccountTrust } from '../account-protocol.js';
|
|
4
|
+
export declare const identityRecordSchema: z.ZodObject<{
|
|
5
|
+
version: z.ZodLiteral<1>;
|
|
6
|
+
endpoint: z.ZodEffects<z.ZodObject<{
|
|
7
|
+
version: z.ZodLiteral<1>;
|
|
8
|
+
id: z.ZodString;
|
|
9
|
+
ownerId: z.ZodString;
|
|
10
|
+
kind: z.ZodEnum<["bridge", "browser", "mcp", "local-cli"]>;
|
|
11
|
+
publicKey: z.ZodString;
|
|
12
|
+
}, "strict", z.ZodTypeAny, {
|
|
13
|
+
id: string;
|
|
14
|
+
version: 1;
|
|
15
|
+
ownerId: string;
|
|
16
|
+
kind: "bridge" | "browser" | "mcp" | "local-cli";
|
|
17
|
+
publicKey: string;
|
|
18
|
+
}, {
|
|
19
|
+
id: string;
|
|
20
|
+
version: 1;
|
|
21
|
+
ownerId: string;
|
|
22
|
+
kind: "bridge" | "browser" | "mcp" | "local-cli";
|
|
23
|
+
publicKey: string;
|
|
24
|
+
}>, {
|
|
25
|
+
id: string;
|
|
26
|
+
version: 1;
|
|
27
|
+
ownerId: string;
|
|
28
|
+
kind: "bridge" | "browser" | "mcp" | "local-cli";
|
|
29
|
+
publicKey: string;
|
|
30
|
+
}, {
|
|
31
|
+
id: string;
|
|
32
|
+
version: 1;
|
|
33
|
+
ownerId: string;
|
|
34
|
+
kind: "bridge" | "browser" | "mcp" | "local-cli";
|
|
35
|
+
publicKey: string;
|
|
36
|
+
}>;
|
|
37
|
+
privateKey: z.ZodObject<{
|
|
38
|
+
kty: z.ZodLiteral<"EC">;
|
|
39
|
+
crv: z.ZodLiteral<"P-256">;
|
|
40
|
+
x: z.ZodString;
|
|
41
|
+
y: z.ZodString;
|
|
42
|
+
d: z.ZodString;
|
|
43
|
+
key_ops: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
44
|
+
ext: z.ZodOptional<z.ZodBoolean>;
|
|
45
|
+
}, "strict", z.ZodTypeAny, {
|
|
46
|
+
kty: "EC";
|
|
47
|
+
crv: "P-256";
|
|
48
|
+
x: string;
|
|
49
|
+
y: string;
|
|
50
|
+
d: string;
|
|
51
|
+
key_ops?: string[] | undefined;
|
|
52
|
+
ext?: boolean | undefined;
|
|
53
|
+
}, {
|
|
54
|
+
kty: "EC";
|
|
55
|
+
crv: "P-256";
|
|
56
|
+
x: string;
|
|
57
|
+
y: string;
|
|
58
|
+
d: string;
|
|
59
|
+
key_ops?: string[] | undefined;
|
|
60
|
+
ext?: boolean | undefined;
|
|
61
|
+
}>;
|
|
62
|
+
accountBootstrap: z.ZodOptional<z.ZodObject<{
|
|
63
|
+
history: z.ZodType<import("../account-protocol.js").AccountHistory, z.ZodTypeDef, import("../account-protocol.js").AccountHistory>;
|
|
64
|
+
checkpoint: z.ZodObject<{
|
|
65
|
+
version: z.ZodLiteral<1>;
|
|
66
|
+
ownerId: z.ZodString;
|
|
67
|
+
rootId: z.ZodString;
|
|
68
|
+
head: z.ZodString;
|
|
69
|
+
revision: z.ZodNumber;
|
|
70
|
+
devices: z.ZodArray<z.ZodObject<{
|
|
71
|
+
endpoint: z.ZodEffects<z.ZodObject<{
|
|
72
|
+
version: z.ZodLiteral<1>;
|
|
73
|
+
id: z.ZodString;
|
|
74
|
+
ownerId: z.ZodString;
|
|
75
|
+
kind: z.ZodEnum<["bridge", "browser", "mcp", "local-cli"]>;
|
|
76
|
+
publicKey: z.ZodString;
|
|
77
|
+
}, "strict", z.ZodTypeAny, {
|
|
78
|
+
id: string;
|
|
79
|
+
version: 1;
|
|
80
|
+
ownerId: string;
|
|
81
|
+
kind: "bridge" | "browser" | "mcp" | "local-cli";
|
|
82
|
+
publicKey: string;
|
|
83
|
+
}, {
|
|
84
|
+
id: string;
|
|
85
|
+
version: 1;
|
|
86
|
+
ownerId: string;
|
|
87
|
+
kind: "bridge" | "browser" | "mcp" | "local-cli";
|
|
88
|
+
publicKey: string;
|
|
89
|
+
}>, {
|
|
90
|
+
id: string;
|
|
91
|
+
version: 1;
|
|
92
|
+
ownerId: string;
|
|
93
|
+
kind: "bridge" | "browser" | "mcp" | "local-cli";
|
|
94
|
+
publicKey: string;
|
|
95
|
+
}, {
|
|
96
|
+
id: string;
|
|
97
|
+
version: 1;
|
|
98
|
+
ownerId: string;
|
|
99
|
+
kind: "bridge" | "browser" | "mcp" | "local-cli";
|
|
100
|
+
publicKey: string;
|
|
101
|
+
}>;
|
|
102
|
+
signingPublicKey: z.ZodString;
|
|
103
|
+
label: z.ZodString;
|
|
104
|
+
approvedAt: z.ZodString;
|
|
105
|
+
}, "strict", z.ZodTypeAny, {
|
|
106
|
+
endpoint: {
|
|
107
|
+
id: string;
|
|
108
|
+
version: 1;
|
|
109
|
+
ownerId: string;
|
|
110
|
+
kind: "bridge" | "browser" | "mcp" | "local-cli";
|
|
111
|
+
publicKey: string;
|
|
112
|
+
};
|
|
113
|
+
label: string;
|
|
114
|
+
approvedAt: string;
|
|
115
|
+
signingPublicKey: string;
|
|
116
|
+
}, {
|
|
117
|
+
endpoint: {
|
|
118
|
+
id: string;
|
|
119
|
+
version: 1;
|
|
120
|
+
ownerId: string;
|
|
121
|
+
kind: "bridge" | "browser" | "mcp" | "local-cli";
|
|
122
|
+
publicKey: string;
|
|
123
|
+
};
|
|
124
|
+
label: string;
|
|
125
|
+
approvedAt: string;
|
|
126
|
+
signingPublicKey: string;
|
|
127
|
+
}>, "many">;
|
|
128
|
+
bridges: z.ZodArray<z.ZodObject<{
|
|
129
|
+
bridgeId: z.ZodString;
|
|
130
|
+
endpoint: z.ZodEffects<z.ZodObject<{
|
|
131
|
+
version: z.ZodLiteral<1>;
|
|
132
|
+
id: z.ZodString;
|
|
133
|
+
ownerId: z.ZodString;
|
|
134
|
+
kind: z.ZodEnum<["bridge", "browser", "mcp", "local-cli"]>;
|
|
135
|
+
publicKey: z.ZodString;
|
|
136
|
+
}, "strict", z.ZodTypeAny, {
|
|
137
|
+
id: string;
|
|
138
|
+
version: 1;
|
|
139
|
+
ownerId: string;
|
|
140
|
+
kind: "bridge" | "browser" | "mcp" | "local-cli";
|
|
141
|
+
publicKey: string;
|
|
142
|
+
}, {
|
|
143
|
+
id: string;
|
|
144
|
+
version: 1;
|
|
145
|
+
ownerId: string;
|
|
146
|
+
kind: "bridge" | "browser" | "mcp" | "local-cli";
|
|
147
|
+
publicKey: string;
|
|
148
|
+
}>, {
|
|
149
|
+
id: string;
|
|
150
|
+
version: 1;
|
|
151
|
+
ownerId: string;
|
|
152
|
+
kind: "bridge" | "browser" | "mcp" | "local-cli";
|
|
153
|
+
publicKey: string;
|
|
154
|
+
}, {
|
|
155
|
+
id: string;
|
|
156
|
+
version: 1;
|
|
157
|
+
ownerId: string;
|
|
158
|
+
kind: "bridge" | "browser" | "mcp" | "local-cli";
|
|
159
|
+
publicKey: string;
|
|
160
|
+
}>;
|
|
161
|
+
label: z.ZodString;
|
|
162
|
+
approvedAt: z.ZodString;
|
|
163
|
+
}, "strict", z.ZodTypeAny, {
|
|
164
|
+
bridgeId: string;
|
|
165
|
+
endpoint: {
|
|
166
|
+
id: string;
|
|
167
|
+
version: 1;
|
|
168
|
+
ownerId: string;
|
|
169
|
+
kind: "bridge" | "browser" | "mcp" | "local-cli";
|
|
170
|
+
publicKey: string;
|
|
171
|
+
};
|
|
172
|
+
label: string;
|
|
173
|
+
approvedAt: string;
|
|
174
|
+
}, {
|
|
175
|
+
bridgeId: string;
|
|
176
|
+
endpoint: {
|
|
177
|
+
id: string;
|
|
178
|
+
version: 1;
|
|
179
|
+
ownerId: string;
|
|
180
|
+
kind: "bridge" | "browser" | "mcp" | "local-cli";
|
|
181
|
+
publicKey: string;
|
|
182
|
+
};
|
|
183
|
+
label: string;
|
|
184
|
+
approvedAt: string;
|
|
185
|
+
}>, "many">;
|
|
186
|
+
revokedDeviceIds: z.ZodArray<z.ZodString, "many">;
|
|
187
|
+
revokedBridgeIds: z.ZodArray<z.ZodString, "many">;
|
|
188
|
+
}, "strict", z.ZodTypeAny, {
|
|
189
|
+
version: 1;
|
|
190
|
+
ownerId: string;
|
|
191
|
+
rootId: string;
|
|
192
|
+
revision: number;
|
|
193
|
+
head: string;
|
|
194
|
+
devices: {
|
|
195
|
+
endpoint: {
|
|
196
|
+
id: string;
|
|
197
|
+
version: 1;
|
|
198
|
+
ownerId: string;
|
|
199
|
+
kind: "bridge" | "browser" | "mcp" | "local-cli";
|
|
200
|
+
publicKey: string;
|
|
201
|
+
};
|
|
202
|
+
label: string;
|
|
203
|
+
approvedAt: string;
|
|
204
|
+
signingPublicKey: string;
|
|
205
|
+
}[];
|
|
206
|
+
bridges: {
|
|
207
|
+
bridgeId: string;
|
|
208
|
+
endpoint: {
|
|
209
|
+
id: string;
|
|
210
|
+
version: 1;
|
|
211
|
+
ownerId: string;
|
|
212
|
+
kind: "bridge" | "browser" | "mcp" | "local-cli";
|
|
213
|
+
publicKey: string;
|
|
214
|
+
};
|
|
215
|
+
label: string;
|
|
216
|
+
approvedAt: string;
|
|
217
|
+
}[];
|
|
218
|
+
revokedDeviceIds: string[];
|
|
219
|
+
revokedBridgeIds: string[];
|
|
220
|
+
}, {
|
|
221
|
+
version: 1;
|
|
222
|
+
ownerId: string;
|
|
223
|
+
rootId: string;
|
|
224
|
+
revision: number;
|
|
225
|
+
head: string;
|
|
226
|
+
devices: {
|
|
227
|
+
endpoint: {
|
|
228
|
+
id: string;
|
|
229
|
+
version: 1;
|
|
230
|
+
ownerId: string;
|
|
231
|
+
kind: "bridge" | "browser" | "mcp" | "local-cli";
|
|
232
|
+
publicKey: string;
|
|
233
|
+
};
|
|
234
|
+
label: string;
|
|
235
|
+
approvedAt: string;
|
|
236
|
+
signingPublicKey: string;
|
|
237
|
+
}[];
|
|
238
|
+
bridges: {
|
|
239
|
+
bridgeId: string;
|
|
240
|
+
endpoint: {
|
|
241
|
+
id: string;
|
|
242
|
+
version: 1;
|
|
243
|
+
ownerId: string;
|
|
244
|
+
kind: "bridge" | "browser" | "mcp" | "local-cli";
|
|
245
|
+
publicKey: string;
|
|
246
|
+
};
|
|
247
|
+
label: string;
|
|
248
|
+
approvedAt: string;
|
|
249
|
+
}[];
|
|
250
|
+
revokedDeviceIds: string[];
|
|
251
|
+
revokedBridgeIds: string[];
|
|
252
|
+
}>;
|
|
253
|
+
}, "strict", z.ZodTypeAny, {
|
|
254
|
+
history: import("../account-protocol.js").AccountHistory;
|
|
255
|
+
checkpoint: {
|
|
256
|
+
version: 1;
|
|
257
|
+
ownerId: string;
|
|
258
|
+
rootId: string;
|
|
259
|
+
revision: number;
|
|
260
|
+
head: string;
|
|
261
|
+
devices: {
|
|
262
|
+
endpoint: {
|
|
263
|
+
id: string;
|
|
264
|
+
version: 1;
|
|
265
|
+
ownerId: string;
|
|
266
|
+
kind: "bridge" | "browser" | "mcp" | "local-cli";
|
|
267
|
+
publicKey: string;
|
|
268
|
+
};
|
|
269
|
+
label: string;
|
|
270
|
+
approvedAt: string;
|
|
271
|
+
signingPublicKey: string;
|
|
272
|
+
}[];
|
|
273
|
+
bridges: {
|
|
274
|
+
bridgeId: string;
|
|
275
|
+
endpoint: {
|
|
276
|
+
id: string;
|
|
277
|
+
version: 1;
|
|
278
|
+
ownerId: string;
|
|
279
|
+
kind: "bridge" | "browser" | "mcp" | "local-cli";
|
|
280
|
+
publicKey: string;
|
|
281
|
+
};
|
|
282
|
+
label: string;
|
|
283
|
+
approvedAt: string;
|
|
284
|
+
}[];
|
|
285
|
+
revokedDeviceIds: string[];
|
|
286
|
+
revokedBridgeIds: string[];
|
|
287
|
+
};
|
|
288
|
+
}, {
|
|
289
|
+
history: import("../account-protocol.js").AccountHistory;
|
|
290
|
+
checkpoint: {
|
|
291
|
+
version: 1;
|
|
292
|
+
ownerId: string;
|
|
293
|
+
rootId: string;
|
|
294
|
+
revision: number;
|
|
295
|
+
head: string;
|
|
296
|
+
devices: {
|
|
297
|
+
endpoint: {
|
|
298
|
+
id: string;
|
|
299
|
+
version: 1;
|
|
300
|
+
ownerId: string;
|
|
301
|
+
kind: "bridge" | "browser" | "mcp" | "local-cli";
|
|
302
|
+
publicKey: string;
|
|
303
|
+
};
|
|
304
|
+
label: string;
|
|
305
|
+
approvedAt: string;
|
|
306
|
+
signingPublicKey: string;
|
|
307
|
+
}[];
|
|
308
|
+
bridges: {
|
|
309
|
+
bridgeId: string;
|
|
310
|
+
endpoint: {
|
|
311
|
+
id: string;
|
|
312
|
+
version: 1;
|
|
313
|
+
ownerId: string;
|
|
314
|
+
kind: "bridge" | "browser" | "mcp" | "local-cli";
|
|
315
|
+
publicKey: string;
|
|
316
|
+
};
|
|
317
|
+
label: string;
|
|
318
|
+
approvedAt: string;
|
|
319
|
+
}[];
|
|
320
|
+
revokedDeviceIds: string[];
|
|
321
|
+
revokedBridgeIds: string[];
|
|
322
|
+
};
|
|
323
|
+
}>>;
|
|
324
|
+
}, "strict", z.ZodTypeAny, {
|
|
325
|
+
version: 1;
|
|
326
|
+
endpoint: {
|
|
327
|
+
id: string;
|
|
328
|
+
version: 1;
|
|
329
|
+
ownerId: string;
|
|
330
|
+
kind: "bridge" | "browser" | "mcp" | "local-cli";
|
|
331
|
+
publicKey: string;
|
|
332
|
+
};
|
|
333
|
+
privateKey: {
|
|
334
|
+
kty: "EC";
|
|
335
|
+
crv: "P-256";
|
|
336
|
+
x: string;
|
|
337
|
+
y: string;
|
|
338
|
+
d: string;
|
|
339
|
+
key_ops?: string[] | undefined;
|
|
340
|
+
ext?: boolean | undefined;
|
|
341
|
+
};
|
|
342
|
+
accountBootstrap?: {
|
|
343
|
+
history: import("../account-protocol.js").AccountHistory;
|
|
344
|
+
checkpoint: {
|
|
345
|
+
version: 1;
|
|
346
|
+
ownerId: string;
|
|
347
|
+
rootId: string;
|
|
348
|
+
revision: number;
|
|
349
|
+
head: string;
|
|
350
|
+
devices: {
|
|
351
|
+
endpoint: {
|
|
352
|
+
id: string;
|
|
353
|
+
version: 1;
|
|
354
|
+
ownerId: string;
|
|
355
|
+
kind: "bridge" | "browser" | "mcp" | "local-cli";
|
|
356
|
+
publicKey: string;
|
|
357
|
+
};
|
|
358
|
+
label: string;
|
|
359
|
+
approvedAt: string;
|
|
360
|
+
signingPublicKey: string;
|
|
361
|
+
}[];
|
|
362
|
+
bridges: {
|
|
363
|
+
bridgeId: string;
|
|
364
|
+
endpoint: {
|
|
365
|
+
id: string;
|
|
366
|
+
version: 1;
|
|
367
|
+
ownerId: string;
|
|
368
|
+
kind: "bridge" | "browser" | "mcp" | "local-cli";
|
|
369
|
+
publicKey: string;
|
|
370
|
+
};
|
|
371
|
+
label: string;
|
|
372
|
+
approvedAt: string;
|
|
373
|
+
}[];
|
|
374
|
+
revokedDeviceIds: string[];
|
|
375
|
+
revokedBridgeIds: string[];
|
|
376
|
+
};
|
|
377
|
+
} | undefined;
|
|
378
|
+
}, {
|
|
379
|
+
version: 1;
|
|
380
|
+
endpoint: {
|
|
381
|
+
id: string;
|
|
382
|
+
version: 1;
|
|
383
|
+
ownerId: string;
|
|
384
|
+
kind: "bridge" | "browser" | "mcp" | "local-cli";
|
|
385
|
+
publicKey: string;
|
|
386
|
+
};
|
|
387
|
+
privateKey: {
|
|
388
|
+
kty: "EC";
|
|
389
|
+
crv: "P-256";
|
|
390
|
+
x: string;
|
|
391
|
+
y: string;
|
|
392
|
+
d: string;
|
|
393
|
+
key_ops?: string[] | undefined;
|
|
394
|
+
ext?: boolean | undefined;
|
|
395
|
+
};
|
|
396
|
+
accountBootstrap?: {
|
|
397
|
+
history: import("../account-protocol.js").AccountHistory;
|
|
398
|
+
checkpoint: {
|
|
399
|
+
version: 1;
|
|
400
|
+
ownerId: string;
|
|
401
|
+
rootId: string;
|
|
402
|
+
revision: number;
|
|
403
|
+
head: string;
|
|
404
|
+
devices: {
|
|
405
|
+
endpoint: {
|
|
406
|
+
id: string;
|
|
407
|
+
version: 1;
|
|
408
|
+
ownerId: string;
|
|
409
|
+
kind: "bridge" | "browser" | "mcp" | "local-cli";
|
|
410
|
+
publicKey: string;
|
|
411
|
+
};
|
|
412
|
+
label: string;
|
|
413
|
+
approvedAt: string;
|
|
414
|
+
signingPublicKey: string;
|
|
415
|
+
}[];
|
|
416
|
+
bridges: {
|
|
417
|
+
bridgeId: string;
|
|
418
|
+
endpoint: {
|
|
419
|
+
id: string;
|
|
420
|
+
version: 1;
|
|
421
|
+
ownerId: string;
|
|
422
|
+
kind: "bridge" | "browser" | "mcp" | "local-cli";
|
|
423
|
+
publicKey: string;
|
|
424
|
+
};
|
|
425
|
+
label: string;
|
|
426
|
+
approvedAt: string;
|
|
427
|
+
}[];
|
|
428
|
+
revokedDeviceIds: string[];
|
|
429
|
+
revokedBridgeIds: string[];
|
|
430
|
+
};
|
|
431
|
+
} | undefined;
|
|
432
|
+
}>;
|
|
2
433
|
/** OS-local persisted keys; corruption/wrong owner never silently generates a replacement identity. */
|
|
3
434
|
export declare function loadOrCreateIdentity(dataDir: string, ownerId: string, kind: 'bridge' | 'local-cli'): Promise<EndpointIdentity>;
|
|
4
435
|
export declare function isLocalIdentityKind(kind: EndpointKind): kind is 'bridge' | 'local-cli';
|
|
5
436
|
export declare function loadLocalIdentity(dataDir: string, ownerId: string): Promise<EndpointIdentity>;
|
|
437
|
+
/** Absence alone permits virgin onboarding; corruption must never generate a new key/root. */
|
|
438
|
+
export declare function readBoundBridgeIdentity(dataDir: string): Promise<{
|
|
439
|
+
identity: EndpointIdentity;
|
|
440
|
+
bootstrap?: VerifiedAccountTrust;
|
|
441
|
+
} | null>;
|
|
@@ -5,16 +5,17 @@ import { generateEndpoint, importEndpoint } from '../crypto.js';
|
|
|
5
5
|
import { endpointSchema } from './metadata.js';
|
|
6
6
|
import { AtomicSnapshot } from './snapshot.js';
|
|
7
7
|
import { BridgeSecurityError } from './errors.js';
|
|
8
|
-
|
|
8
|
+
import { verifiedAccountSchema } from './account-state.js';
|
|
9
|
+
export const identityRecordSchema = z.object({ version: z.literal(1), endpoint: endpointSchema, privateKey: z.object({
|
|
9
10
|
kty: z.literal('EC'), crv: z.literal('P-256'), x: z.string(), y: z.string(), d: z.string(),
|
|
10
11
|
key_ops: z.array(z.string()).optional(), ext: z.boolean().optional(),
|
|
11
|
-
}).strict() }).strict();
|
|
12
|
+
}).strict(), accountBootstrap: verifiedAccountSchema.optional() }).strict();
|
|
12
13
|
/** OS-local persisted keys; corruption/wrong owner never silently generates a replacement identity. */
|
|
13
14
|
export async function loadOrCreateIdentity(dataDir, ownerId, kind) {
|
|
14
15
|
const generated = await generateEndpoint(ownerId, kind, true);
|
|
15
16
|
const jwk = await crypto.subtle.exportKey('jwk', generated.keyPair.privateKey);
|
|
16
|
-
const initial =
|
|
17
|
-
const store = new AtomicSnapshot(join(dataDir, 'security', `${kind}-identity.json`),
|
|
17
|
+
const initial = identityRecordSchema.parse({ version: 1, endpoint: generated.endpoint, privateKey: jwk });
|
|
18
|
+
const store = new AtomicSnapshot(join(dataDir, 'security', `${kind}-identity.json`), identityRecordSchema, () => initial);
|
|
18
19
|
const saved = await store.transact(state => {
|
|
19
20
|
if (state.endpoint.ownerId !== ownerId || state.endpoint.kind !== kind)
|
|
20
21
|
throw new BridgeSecurityError('wrong_context');
|
|
@@ -30,7 +31,7 @@ export async function loadOrCreateIdentity(dataDir, ownerId, kind) {
|
|
|
30
31
|
export function isLocalIdentityKind(kind) { return kind === 'bridge' || kind === 'local-cli'; }
|
|
31
32
|
export async function loadLocalIdentity(dataDir, ownerId) {
|
|
32
33
|
try {
|
|
33
|
-
const saved =
|
|
34
|
+
const saved = identityRecordSchema.parse(JSON.parse(await readFile(join(dataDir, 'security', 'local-cli-identity.json'), 'utf8')));
|
|
34
35
|
if (saved.endpoint.ownerId !== ownerId || saved.endpoint.kind !== 'local-cli')
|
|
35
36
|
throw new Error('Wrong local key');
|
|
36
37
|
return await importEndpoint(saved.endpoint, saved.privateKey, false);
|
|
@@ -39,4 +40,25 @@ export async function loadLocalIdentity(dataDir, ownerId) {
|
|
|
39
40
|
throw new BridgeSecurityError('key_unavailable');
|
|
40
41
|
}
|
|
41
42
|
}
|
|
43
|
+
/** Absence alone permits virgin onboarding; corruption must never generate a new key/root. */
|
|
44
|
+
export async function readBoundBridgeIdentity(dataDir) {
|
|
45
|
+
let raw;
|
|
46
|
+
try {
|
|
47
|
+
raw = await readFile(join(dataDir, 'security', 'bridge-identity.json'), 'utf8');
|
|
48
|
+
}
|
|
49
|
+
catch (error) {
|
|
50
|
+
if (error.code === 'ENOENT')
|
|
51
|
+
return null;
|
|
52
|
+
throw new BridgeSecurityError('key_unavailable');
|
|
53
|
+
}
|
|
54
|
+
try {
|
|
55
|
+
const record = identityRecordSchema.parse(JSON.parse(raw));
|
|
56
|
+
if (record.endpoint.kind !== 'bridge')
|
|
57
|
+
throw new BridgeSecurityError('wrong_context');
|
|
58
|
+
return { identity: await importEndpoint(record.endpoint, record.privateKey, false), bootstrap: record.accountBootstrap };
|
|
59
|
+
}
|
|
60
|
+
catch {
|
|
61
|
+
throw new BridgeSecurityError('key_unavailable');
|
|
62
|
+
}
|
|
63
|
+
}
|
|
42
64
|
//# sourceMappingURL=identity.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"identity.js","sourceRoot":"","sources":["../../../src/security/bridge/identity.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,E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CAAC,iBAAiB,CAAC,CAAC;IACnD,CAAC;IACD,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,oBAAoB,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC;QAC3D,IAAI,MAAM,CAAC,QAAQ,CAAC,IAAI,KAAK,QAAQ;YAAE,MAAM,IAAI,mBAAmB,CAAC,eAAe,CAAC,CAAC;QACtF,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC,MAAM,CAAC,QAAQ,EAAE,MAAM,CAAC,UAAU,EAAE,KAAK,CAAC,EAAE,SAAS,EAAE,MAAM,CAAC,gBAAgB,EAAE,CAAC;IAC3H,CAAC;IAAC,MAAM,CAAC;QAAC,MAAM,IAAI,mBAAmB,CAAC,iBAAiB,CAAC,CAAC;IAAC,CAAC;AAC/D,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { PendingBridgeDecision, PendingBridgeStatus } from '../pending-approval-protocol.js';
|
|
2
|
+
/** The bridge is the only writer. CLI reads never modify this snapshot. */
|
|
3
|
+
export declare function writePendingBridgeStatus(dataDir: string, status: PendingBridgeStatus): Promise<void>;
|
|
4
|
+
export declare function readPendingBridgeStatus(dataDir: string): Promise<PendingBridgeStatus>;
|
|
5
|
+
/** Called only by explicit OS-local CLI action, never by server status. */
|
|
6
|
+
export declare function submitPendingBridgeDecision(dataDir: string, decision: 'confirm' | 'reject', comparisonCode?: string, now?: number): Promise<void>;
|
|
7
|
+
export declare function matchesPendingBridgeDecision(status: PendingBridgeStatus, decision: PendingBridgeDecision, now?: number): boolean;
|
|
8
|
+
/** Reads a separate CLI-owned message file; never edits or deletes it. */
|
|
9
|
+
export declare function waitForPendingBridgeDecision(dataDir: string, status: PendingBridgeStatus, signal: AbortSignal): Promise<PendingBridgeDecision>;
|
|
10
|
+
export type BridgePairingMode = {
|
|
11
|
+
method: 'pending-v1';
|
|
12
|
+
accountHint: string;
|
|
13
|
+
} | {
|
|
14
|
+
method: 'bootstrap';
|
|
15
|
+
};
|
|
16
|
+
export declare function selectBridgePairingMode(options: {
|
|
17
|
+
account?: string;
|
|
18
|
+
bootstrap?: boolean;
|
|
19
|
+
interactive: boolean;
|
|
20
|
+
previousPending?: boolean;
|
|
21
|
+
}, prompt: () => Promise<string>): Promise<BridgePairingMode>;
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { join } from 'node:path';
|
|
2
|
+
import { setTimeout as delay } from 'node:timers/promises';
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
import { normalizePendingAccountHint } from '../pending-approval-crypto.js';
|
|
5
|
+
import { AtomicSnapshot } from './snapshot.js';
|
|
6
|
+
import { BridgeSecurityError } from './errors.js';
|
|
7
|
+
const hash = z.string().regex(/^[A-Za-z0-9_-]{43}$/);
|
|
8
|
+
const code = z.string().regex(/^[A-F0-9]{4}-[A-F0-9]{4}-[A-F0-9]{4}$/);
|
|
9
|
+
const common = { version: z.literal(1), requestId: hash, processNonce: hash, expiresAt: z.string().datetime() };
|
|
10
|
+
const statusSchema = z.union([
|
|
11
|
+
z.object({ ...common, phase: z.literal('waiting'), offerHash: hash.nullable(), comparisonCode: z.null() }).strict(),
|
|
12
|
+
z.object({ ...common, phase: z.enum(['comparing', 'confirming']), offerHash: hash, comparisonCode: code }).strict(),
|
|
13
|
+
z.object({ ...common, phase: z.enum(['approved', 'rejected', 'cancelled', 'expired', 'conflict']), offerHash: hash.nullable(), comparisonCode: z.null() }).strict(),
|
|
14
|
+
]);
|
|
15
|
+
const decisionSchema = z.union([
|
|
16
|
+
z.object({ ...common, decision: z.literal('confirm'), offerHash: hash, comparisonCode: code }).strict(),
|
|
17
|
+
z.object({ ...common, decision: z.literal('reject'), offerHash: hash.nullable() }).strict(),
|
|
18
|
+
]);
|
|
19
|
+
const terminal = (state) => ['approved', 'rejected', 'cancelled', 'expired', 'conflict'].includes(state.phase);
|
|
20
|
+
/** The bridge is the only writer. CLI reads never modify this snapshot. */
|
|
21
|
+
export async function writePendingBridgeStatus(dataDir, status) {
|
|
22
|
+
const store = new AtomicSnapshot(join(dataDir, 'security', 'pending-approval-status.json'), z.object({ status: statusSchema }).strict(), () => ({ status }));
|
|
23
|
+
await store.transact(state => { state.status = status; });
|
|
24
|
+
}
|
|
25
|
+
export async function readPendingBridgeStatus(dataDir) {
|
|
26
|
+
const store = new AtomicSnapshot(join(dataDir, 'security', 'pending-approval-status.json'), z.object({ status: statusSchema }).strict().nullable(), () => null);
|
|
27
|
+
const saved = await store.read(state => state?.status ?? null);
|
|
28
|
+
if (!saved)
|
|
29
|
+
throw new BridgeSecurityError('account_approval_required');
|
|
30
|
+
return saved;
|
|
31
|
+
}
|
|
32
|
+
/** Called only by explicit OS-local CLI action, never by server status. */
|
|
33
|
+
export async function submitPendingBridgeDecision(dataDir, decision, comparisonCode, now = Date.now()) {
|
|
34
|
+
const status = await readPendingBridgeStatus(dataDir);
|
|
35
|
+
if (terminal(status) || Date.parse(status.expiresAt) <= now)
|
|
36
|
+
throw new BridgeSecurityError('account_enrollment_expired');
|
|
37
|
+
const base = { version: 1, requestId: status.requestId, processNonce: status.processNonce, expiresAt: status.expiresAt };
|
|
38
|
+
let value;
|
|
39
|
+
if (decision === 'confirm') {
|
|
40
|
+
if (status.phase !== 'comparing' || comparisonCode !== status.comparisonCode)
|
|
41
|
+
throw new BridgeSecurityError('account_enrollment_invalid');
|
|
42
|
+
value = { ...base, decision, offerHash: status.offerHash, comparisonCode };
|
|
43
|
+
}
|
|
44
|
+
else
|
|
45
|
+
value = { ...base, decision, offerHash: status.offerHash };
|
|
46
|
+
const store = new AtomicSnapshot(join(dataDir, 'security', 'pending-approval-confirmation.json'), z.object({ decision: decisionSchema }).strict(), () => ({ decision: value }));
|
|
47
|
+
await store.transact(state => { state.decision = value; });
|
|
48
|
+
}
|
|
49
|
+
export function matchesPendingBridgeDecision(status, decision, now = Date.now()) {
|
|
50
|
+
return !terminal(status) && Date.parse(status.expiresAt) > now && decision.requestId === status.requestId
|
|
51
|
+
&& decision.processNonce === status.processNonce && decision.offerHash === status.offerHash && decision.expiresAt === status.expiresAt
|
|
52
|
+
&& (decision.decision === 'reject' || (status.phase === 'comparing' && decision.comparisonCode === status.comparisonCode));
|
|
53
|
+
}
|
|
54
|
+
/** Reads a separate CLI-owned message file; never edits or deletes it. */
|
|
55
|
+
export async function waitForPendingBridgeDecision(dataDir, status, signal) {
|
|
56
|
+
const store = new AtomicSnapshot(join(dataDir, 'security', 'pending-approval-confirmation.json'), z.object({ decision: decisionSchema }).strict().nullable(), () => null);
|
|
57
|
+
for (;;) {
|
|
58
|
+
signal.throwIfAborted();
|
|
59
|
+
if (Date.parse(status.expiresAt) <= Date.now())
|
|
60
|
+
throw new BridgeSecurityError('account_enrollment_expired');
|
|
61
|
+
const decision = await store.read(state => state?.decision ?? null);
|
|
62
|
+
if (decision && matchesPendingBridgeDecision(status, decision))
|
|
63
|
+
return decision;
|
|
64
|
+
await delay(100, undefined, { signal });
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
export async function selectBridgePairingMode(options, prompt) {
|
|
68
|
+
if (options.account !== undefined && options.bootstrap)
|
|
69
|
+
throw new Error('--account and --bootstrap cannot be combined');
|
|
70
|
+
if (options.account !== undefined)
|
|
71
|
+
return { method: 'pending-v1', accountHint: normalizePendingAccountHint(options.account) };
|
|
72
|
+
if (options.previousPending && !options.bootstrap && !options.interactive)
|
|
73
|
+
throw new Error('Previous inbox approval was interrupted. Restart with --account <email>, or select --bootstrap explicitly.');
|
|
74
|
+
if (options.bootstrap || !options.interactive)
|
|
75
|
+
return { method: 'bootstrap' };
|
|
76
|
+
const entered = await prompt();
|
|
77
|
+
return entered.trim() === '' ? { method: 'bootstrap' } : { method: 'pending-v1', accountHint: normalizePendingAccountHint(entered) };
|
|
78
|
+
}
|
|
79
|
+
//# sourceMappingURL=pending-approval.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pending-approval.js","sourceRoot":"","sources":["../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AC9H,IAAI,OAAO,CAAC,eAAe,IAAI,CAAC,OAAO,CAAC,SAAS,IAAI,CAAC,OAAO,CAAC,WAAW;QAAE,MAAM,IAAI,KAAK,CAAC,4GAA4G,CAAC,CAAC;IACzM,IAAI,OAAO,CAAC,SAAS,IAAI,CAAC,OAAO,CAAC,WAAW;QAAE,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,CAAC;IAC9E,MAAM,OAAO,GAAG,MAAM,MAAM,EAAE,CAAC;IAC/B,OAAO,OAAO,CAAC,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,WAAW,EAAE,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,YAAY,EAAE,WAAW,EAAE,2BAA2B,CAAC,OAAO,CAAC,EAAE,CAAC;AACvI,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { AccountEnrollmentLink, VerifiedAccountTrust } from '../account-protocol.js';
|
|
2
|
+
import type { AccountEnrollmentRequest } from '../account-protocol.js';
|
|
3
|
+
import type { PendingHello, PendingOffer } from '../pending-approval-protocol.js';
|
|
4
|
+
import type { EndpointIdentity } from '../protocol.js';
|
|
5
|
+
export interface PendingBridgeEnrollment {
|
|
6
|
+
identity: EndpointIdentity;
|
|
7
|
+
link: AccountEnrollmentLink;
|
|
8
|
+
}
|
|
9
|
+
export declare function previousPendingBridgeAttempt(dataDir: string): Promise<{
|
|
10
|
+
requestId: string;
|
|
11
|
+
candidateToken: string;
|
|
12
|
+
} | null>;
|
|
13
|
+
export declare function prepareBridgeEnrollment(dataDir: string, bridgeId: string, label: string, now?: number, fresh?: boolean): Promise<PendingBridgeEnrollment>;
|
|
14
|
+
export interface PendingAutomaticEnrollment {
|
|
15
|
+
identity: EndpointIdentity;
|
|
16
|
+
request: Extract<AccountEnrollmentRequest, {
|
|
17
|
+
kind: 'bridge';
|
|
18
|
+
}>;
|
|
19
|
+
candidateToken: string;
|
|
20
|
+
previous: {
|
|
21
|
+
requestId: string;
|
|
22
|
+
candidateToken: string;
|
|
23
|
+
} | null;
|
|
24
|
+
pinOffer(offer: PendingOffer): Promise<void>;
|
|
25
|
+
pinHello(hello: PendingHello): Promise<void>;
|
|
26
|
+
}
|
|
27
|
+
/** One fresh process attempt, retaining the long-term point even after cancellation/restart. */
|
|
28
|
+
export declare function preparePendingBridgeEnrollment(dataDir: string, bridgeId: string, label: string, now?: number): Promise<PendingAutomaticEnrollment>;
|
|
29
|
+
/** URL is constructed from operator configuration, never a service-provided redirect. */
|
|
30
|
+
export declare function savePairingVerificationUrl(dataDir: string, apiUrl: string, userCode: string): Promise<string>;
|
|
31
|
+
export declare function pendingPairingLink(dataDir: string, now?: number): Promise<string>;
|
|
32
|
+
/** Save the normalized SAME private/public key and trusted bootstrap in one durable identity record. */
|
|
33
|
+
export declare function bindPendingBridgeIdentity(dataDir: string, trust: VerifiedAccountTrust): Promise<EndpointIdentity>;
|