@qntx/wallet 0.0.0-stage → 0.2.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-APACHE +201 -0
- package/LICENSE-MIT +21 -0
- package/README.md +73 -2
- package/dist/host.d.mts +54 -0
- package/dist/host.mjs +291 -0
- package/dist/host.mjs.map +1 -0
- package/dist/index-BJfyIwOZ.d.mts +286 -0
- package/dist/index.d.mts +2 -0
- package/dist/index.mjs +2 -0
- package/dist/nostr.d.mts +47 -0
- package/dist/nostr.mjs +174 -0
- package/dist/nostr.mjs.map +1 -0
- package/dist/protocol-D9_0sY_Y.mjs +466 -0
- package/dist/protocol-D9_0sY_Y.mjs.map +1 -0
- package/dist/protocol.d.mts +3 -0
- package/dist/protocol.mjs +2 -0
- package/dist/secret-B-P3QOym.mjs +375 -0
- package/dist/secret-B-P3QOym.mjs.map +1 -0
- package/dist/types-CEy7At1l.d.mts +168 -0
- package/dist/types.d.mts +2 -0
- package/dist/types.mjs +16 -0
- package/dist/types.mjs.map +1 -0
- package/package.json +97 -4
|
@@ -0,0 +1,466 @@
|
|
|
1
|
+
//#region src/protocol/validate.ts
|
|
2
|
+
var ValidationError = class extends Error {
|
|
3
|
+
name = "ValidationError";
|
|
4
|
+
};
|
|
5
|
+
function fail() {
|
|
6
|
+
throw new ValidationError();
|
|
7
|
+
}
|
|
8
|
+
function literal(expected) {
|
|
9
|
+
return (value) => {
|
|
10
|
+
if (value !== expected) fail();
|
|
11
|
+
return expected;
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
const nullValue = literal(null);
|
|
15
|
+
const bool = (value) => {
|
|
16
|
+
if (typeof value !== "boolean") fail();
|
|
17
|
+
return value;
|
|
18
|
+
};
|
|
19
|
+
function int(min, max) {
|
|
20
|
+
return (value) => {
|
|
21
|
+
if (typeof value !== "number" || !Number.isSafeInteger(value) || value < min || value > max) fail();
|
|
22
|
+
return value;
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
function str(max, pattern) {
|
|
26
|
+
return (value) => {
|
|
27
|
+
if (typeof value !== "string" || value.length > max || pattern !== void 0 && !pattern.test(value)) fail();
|
|
28
|
+
return value;
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
function bytes(min, max) {
|
|
32
|
+
const high = max ?? min;
|
|
33
|
+
return (value) => {
|
|
34
|
+
if (!(value instanceof Uint8Array) || value.length < min || value.length > high) fail();
|
|
35
|
+
return value;
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
function arr(item, max, min = 0) {
|
|
39
|
+
return (value) => {
|
|
40
|
+
if (!Array.isArray(value) || value.length < min || value.length > max) fail();
|
|
41
|
+
const out = [];
|
|
42
|
+
for (const element of value) out.push(item(element));
|
|
43
|
+
return out;
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
var Opt = class {
|
|
47
|
+
validator;
|
|
48
|
+
constructor(validator) {
|
|
49
|
+
this.validator = validator;
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
function opt(validator) {
|
|
53
|
+
return new Opt(validator);
|
|
54
|
+
}
|
|
55
|
+
/** Exact key set: required keys present, optional keys allowed, nothing else. */
|
|
56
|
+
function obj(shape) {
|
|
57
|
+
const keys = Object.keys(shape);
|
|
58
|
+
return (value) => {
|
|
59
|
+
if (typeof value !== "object" || value === null || Array.isArray(value) || value instanceof Uint8Array) fail();
|
|
60
|
+
const record = value;
|
|
61
|
+
for (const key of Object.keys(record)) if (!(key in shape)) fail();
|
|
62
|
+
const out = {};
|
|
63
|
+
for (const key of keys) {
|
|
64
|
+
const field = shape[key];
|
|
65
|
+
if (field === void 0) fail();
|
|
66
|
+
const raw = record[key];
|
|
67
|
+
if (field instanceof Opt) {
|
|
68
|
+
if (raw !== void 0) out[key] = field.validator(raw);
|
|
69
|
+
} else {
|
|
70
|
+
if (!(key in record)) fail();
|
|
71
|
+
out[key] = field(raw);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
return out;
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
/** Tries each branch in order; the first match wins. */
|
|
78
|
+
function union(...branches) {
|
|
79
|
+
return (value) => {
|
|
80
|
+
for (const branch of branches) try {
|
|
81
|
+
return branch(value);
|
|
82
|
+
} catch (error) {
|
|
83
|
+
if (!(error instanceof ValidationError)) throw error;
|
|
84
|
+
}
|
|
85
|
+
return fail();
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
/** Validates a value and returns it, or undefined on a shape mismatch. */
|
|
89
|
+
function validate(validator, value) {
|
|
90
|
+
try {
|
|
91
|
+
return validator(value);
|
|
92
|
+
} catch (error) {
|
|
93
|
+
if (error instanceof ValidationError) return;
|
|
94
|
+
throw error;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
//#endregion
|
|
98
|
+
//#region src/protocol/core.ts
|
|
99
|
+
const MAX_TEXT = 262144;
|
|
100
|
+
const MAX_TAGS = 1024;
|
|
101
|
+
const MAX_TAG_ITEM = 4096;
|
|
102
|
+
const MAX_SNAPSHOT_ITEMS = 4096;
|
|
103
|
+
const sessionId = str(32, /^[0-9a-f]{32}$/);
|
|
104
|
+
const draftId = str(32, /^[0-9a-f]{32}$/);
|
|
105
|
+
const walletId = str(16, /^[0-9a-f]{16}$/);
|
|
106
|
+
const publicKey = str(64, /^[0-9a-f]{64}$/);
|
|
107
|
+
const credentialId = str(1364, /^[A-Za-z0-9_-]+$/);
|
|
108
|
+
const safeTime = int(0, Number.MAX_SAFE_INTEGER);
|
|
109
|
+
const groupIndex = int(0, 2147483647);
|
|
110
|
+
const factor = union(obj({
|
|
111
|
+
kind: literal("password"),
|
|
112
|
+
password: bytes(1, 1024)
|
|
113
|
+
}), obj({
|
|
114
|
+
kind: literal("passkey"),
|
|
115
|
+
credentialId: bytes(1, 1023),
|
|
116
|
+
prf: bytes(32)
|
|
117
|
+
}));
|
|
118
|
+
const factorInfo = union(obj({ kind: literal("hardware") }), obj({
|
|
119
|
+
kind: literal("passkey"),
|
|
120
|
+
id: sessionId,
|
|
121
|
+
credentialId,
|
|
122
|
+
createdAt: safeTime
|
|
123
|
+
}), obj({
|
|
124
|
+
kind: literal("password"),
|
|
125
|
+
id: sessionId,
|
|
126
|
+
createdAt: safeTime
|
|
127
|
+
}));
|
|
128
|
+
const walletInfo = obj({
|
|
129
|
+
walletId,
|
|
130
|
+
origin: union(literal("passkey"), literal("mnemonic")),
|
|
131
|
+
words: union(literal(12), literal(15), literal(18), literal(21), literal(24)),
|
|
132
|
+
backedUp: bool,
|
|
133
|
+
createdAt: safeTime
|
|
134
|
+
});
|
|
135
|
+
const walletErrorCode = union(literal("locked"), literal("cancelled"), literal("factor-unavailable"), literal("factor-invalidated"), literal("wrong-password"), literal("rate-limited"), literal("invalid-input"), literal("not-found"), literal("already-exists"), literal("integrity"), literal("crashed"));
|
|
136
|
+
const createdResult = obj({
|
|
137
|
+
wallet: walletInfo,
|
|
138
|
+
session: sessionId
|
|
139
|
+
});
|
|
140
|
+
const CORE_METHODS = {
|
|
141
|
+
"vault.unlock": {
|
|
142
|
+
session: false,
|
|
143
|
+
params: obj({ factor }),
|
|
144
|
+
result: obj({ session: sessionId })
|
|
145
|
+
},
|
|
146
|
+
"vault.lock": {
|
|
147
|
+
session: false,
|
|
148
|
+
params: nullValue,
|
|
149
|
+
result: nullValue
|
|
150
|
+
},
|
|
151
|
+
"vault.reset": {
|
|
152
|
+
session: false,
|
|
153
|
+
params: nullValue,
|
|
154
|
+
result: nullValue
|
|
155
|
+
},
|
|
156
|
+
"vault.addFactor": {
|
|
157
|
+
session: true,
|
|
158
|
+
params: obj({
|
|
159
|
+
verify: factor,
|
|
160
|
+
factor
|
|
161
|
+
}),
|
|
162
|
+
result: factorInfo
|
|
163
|
+
},
|
|
164
|
+
"vault.removeFactor": {
|
|
165
|
+
session: true,
|
|
166
|
+
params: obj({
|
|
167
|
+
verify: factor,
|
|
168
|
+
id: sessionId
|
|
169
|
+
}),
|
|
170
|
+
result: nullValue
|
|
171
|
+
},
|
|
172
|
+
"wallet.createWithPasskey": {
|
|
173
|
+
session: false,
|
|
174
|
+
params: obj({
|
|
175
|
+
credentialId: bytes(1, 1023),
|
|
176
|
+
prfWallet: bytes(32),
|
|
177
|
+
factor: opt(factor)
|
|
178
|
+
}),
|
|
179
|
+
result: createdResult
|
|
180
|
+
},
|
|
181
|
+
"wallet.restoreWithPasskey": {
|
|
182
|
+
session: false,
|
|
183
|
+
params: obj({
|
|
184
|
+
credentialId: bytes(1, 1023),
|
|
185
|
+
prfWallet: bytes(32),
|
|
186
|
+
factor: opt(factor)
|
|
187
|
+
}),
|
|
188
|
+
result: createdResult
|
|
189
|
+
},
|
|
190
|
+
"wallet.createMnemonic": {
|
|
191
|
+
session: false,
|
|
192
|
+
params: obj({
|
|
193
|
+
words: union(literal(12), literal(24)),
|
|
194
|
+
factor: opt(factor)
|
|
195
|
+
}),
|
|
196
|
+
result: obj({
|
|
197
|
+
draft: draftId,
|
|
198
|
+
words: bytes(16, 1024),
|
|
199
|
+
quiz: arr(int(0, 23), 3, 3)
|
|
200
|
+
})
|
|
201
|
+
},
|
|
202
|
+
"wallet.confirmMnemonic": {
|
|
203
|
+
session: false,
|
|
204
|
+
params: obj({
|
|
205
|
+
draft: draftId,
|
|
206
|
+
answers: arr(bytes(1, 64), 3, 3)
|
|
207
|
+
}),
|
|
208
|
+
result: createdResult
|
|
209
|
+
},
|
|
210
|
+
"wallet.discardMnemonic": {
|
|
211
|
+
session: false,
|
|
212
|
+
params: obj({ draft: draftId }),
|
|
213
|
+
result: nullValue
|
|
214
|
+
},
|
|
215
|
+
"wallet.importMnemonic": {
|
|
216
|
+
session: false,
|
|
217
|
+
params: obj({
|
|
218
|
+
mnemonic: bytes(1, 1024),
|
|
219
|
+
factor: opt(factor)
|
|
220
|
+
}),
|
|
221
|
+
result: createdResult
|
|
222
|
+
},
|
|
223
|
+
"wallet.exportMnemonic": {
|
|
224
|
+
session: true,
|
|
225
|
+
params: obj({
|
|
226
|
+
verify: factor,
|
|
227
|
+
walletId
|
|
228
|
+
}),
|
|
229
|
+
result: bytes(16, 1024)
|
|
230
|
+
},
|
|
231
|
+
"wallet.delete": {
|
|
232
|
+
session: true,
|
|
233
|
+
params: obj({
|
|
234
|
+
verify: factor,
|
|
235
|
+
walletId
|
|
236
|
+
}),
|
|
237
|
+
result: nullValue
|
|
238
|
+
},
|
|
239
|
+
"dataKeys.get": {
|
|
240
|
+
session: true,
|
|
241
|
+
params: obj({ purpose: str(32, /^[a-z0-9-]{1,32}$/) }),
|
|
242
|
+
result: bytes(32)
|
|
243
|
+
}
|
|
244
|
+
};
|
|
245
|
+
//#endregion
|
|
246
|
+
//#region src/protocol/nostr.ts
|
|
247
|
+
const hex128 = str(128, /^[0-9a-f]{128}$/);
|
|
248
|
+
const nostrKeyInfo = obj({
|
|
249
|
+
ref: union(obj({
|
|
250
|
+
kind: literal("derived"),
|
|
251
|
+
walletId,
|
|
252
|
+
groupIndex
|
|
253
|
+
}), obj({
|
|
254
|
+
kind: literal("standalone"),
|
|
255
|
+
id: publicKey
|
|
256
|
+
}), obj({
|
|
257
|
+
kind: literal("nip46-client"),
|
|
258
|
+
id: publicKey
|
|
259
|
+
})),
|
|
260
|
+
publicKey,
|
|
261
|
+
origin: union(literal("derived"), literal("nsec"), literal("ncryptsec"), literal("generated"), literal("nip46-client")),
|
|
262
|
+
createdAt: safeTime
|
|
263
|
+
});
|
|
264
|
+
/** The nostr section of the status payload, composed by protocol/index.ts. */
|
|
265
|
+
const nostrStatus = obj({ keys: arr(nostrKeyInfo, MAX_SNAPSHOT_ITEMS) });
|
|
266
|
+
const keyResult = obj({
|
|
267
|
+
key: nostrKeyInfo,
|
|
268
|
+
session: sessionId
|
|
269
|
+
});
|
|
270
|
+
const derivedNostrKey = obj({
|
|
271
|
+
groupIndex,
|
|
272
|
+
publicKey
|
|
273
|
+
});
|
|
274
|
+
const tags = arr(arr(str(MAX_TAG_ITEM), 64), MAX_TAGS);
|
|
275
|
+
const signEventInput = obj({
|
|
276
|
+
kind: int(0, 65535),
|
|
277
|
+
created_at: safeTime,
|
|
278
|
+
tags,
|
|
279
|
+
content: str(MAX_TEXT),
|
|
280
|
+
pubkey: opt(publicKey)
|
|
281
|
+
});
|
|
282
|
+
const signedEvent = obj({
|
|
283
|
+
id: publicKey,
|
|
284
|
+
pubkey: publicKey,
|
|
285
|
+
sig: hex128,
|
|
286
|
+
kind: int(0, 65535),
|
|
287
|
+
created_at: safeTime,
|
|
288
|
+
tags,
|
|
289
|
+
content: str(MAX_TEXT)
|
|
290
|
+
});
|
|
291
|
+
const rumor = obj({
|
|
292
|
+
id: publicKey,
|
|
293
|
+
pubkey: publicKey,
|
|
294
|
+
kind: int(0, 65535),
|
|
295
|
+
created_at: safeTime,
|
|
296
|
+
tags,
|
|
297
|
+
content: str(MAX_TEXT)
|
|
298
|
+
});
|
|
299
|
+
const nostrImportInput = union(obj({
|
|
300
|
+
kind: literal("nsec"),
|
|
301
|
+
nsec: bytes(1, 256)
|
|
302
|
+
}), obj({
|
|
303
|
+
kind: literal("ncryptsec"),
|
|
304
|
+
ncryptsec: str(512, /^ncryptsec1/),
|
|
305
|
+
password: bytes(1, 1024)
|
|
306
|
+
}));
|
|
307
|
+
const nostrExportFormat = union(obj({ kind: literal("nsec") }), obj({
|
|
308
|
+
kind: literal("ncryptsec"),
|
|
309
|
+
password: bytes(1, 1024)
|
|
310
|
+
}));
|
|
311
|
+
const textParams = obj({
|
|
312
|
+
publicKey,
|
|
313
|
+
peer: publicKey,
|
|
314
|
+
text: str(MAX_TEXT)
|
|
315
|
+
});
|
|
316
|
+
const textResult = str(MAX_TEXT * 4);
|
|
317
|
+
const NOSTR_METHODS = {
|
|
318
|
+
"nostr.discover": {
|
|
319
|
+
session: true,
|
|
320
|
+
params: obj({
|
|
321
|
+
walletId,
|
|
322
|
+
from: groupIndex,
|
|
323
|
+
count: int(1, 20)
|
|
324
|
+
}),
|
|
325
|
+
result: obj({ keys: arr(derivedNostrKey, 20) })
|
|
326
|
+
},
|
|
327
|
+
"nostr.deriveKey": {
|
|
328
|
+
session: true,
|
|
329
|
+
params: obj({
|
|
330
|
+
walletId,
|
|
331
|
+
groupIndex
|
|
332
|
+
}),
|
|
333
|
+
result: nostrKeyInfo
|
|
334
|
+
},
|
|
335
|
+
"nostr.importKey": {
|
|
336
|
+
session: false,
|
|
337
|
+
params: obj({
|
|
338
|
+
input: nostrImportInput,
|
|
339
|
+
factor: opt(factor)
|
|
340
|
+
}),
|
|
341
|
+
result: keyResult
|
|
342
|
+
},
|
|
343
|
+
"nostr.generateKey": {
|
|
344
|
+
session: false,
|
|
345
|
+
params: obj({ factor: opt(factor) }),
|
|
346
|
+
result: keyResult
|
|
347
|
+
},
|
|
348
|
+
"nostr.createNip46ClientKey": {
|
|
349
|
+
session: true,
|
|
350
|
+
params: nullValue,
|
|
351
|
+
result: nostrKeyInfo
|
|
352
|
+
},
|
|
353
|
+
"nostr.removeKey": {
|
|
354
|
+
session: true,
|
|
355
|
+
params: obj({
|
|
356
|
+
publicKey,
|
|
357
|
+
verify: opt(factor)
|
|
358
|
+
}),
|
|
359
|
+
result: nullValue
|
|
360
|
+
},
|
|
361
|
+
"nostr.exportKey": {
|
|
362
|
+
session: true,
|
|
363
|
+
params: obj({
|
|
364
|
+
verify: factor,
|
|
365
|
+
publicKey,
|
|
366
|
+
format: nostrExportFormat
|
|
367
|
+
}),
|
|
368
|
+
result: bytes(16, 4096)
|
|
369
|
+
},
|
|
370
|
+
"nostr.signEvent": {
|
|
371
|
+
session: true,
|
|
372
|
+
params: obj({
|
|
373
|
+
publicKey,
|
|
374
|
+
event: signEventInput
|
|
375
|
+
}),
|
|
376
|
+
result: signedEvent
|
|
377
|
+
},
|
|
378
|
+
"nostr.nip04Encrypt": {
|
|
379
|
+
session: true,
|
|
380
|
+
params: textParams,
|
|
381
|
+
result: textResult
|
|
382
|
+
},
|
|
383
|
+
"nostr.nip04Decrypt": {
|
|
384
|
+
session: true,
|
|
385
|
+
params: textParams,
|
|
386
|
+
result: textResult
|
|
387
|
+
},
|
|
388
|
+
"nostr.nip44Encrypt": {
|
|
389
|
+
session: true,
|
|
390
|
+
params: textParams,
|
|
391
|
+
result: textResult
|
|
392
|
+
},
|
|
393
|
+
"nostr.nip44Decrypt": {
|
|
394
|
+
session: true,
|
|
395
|
+
params: textParams,
|
|
396
|
+
result: textResult
|
|
397
|
+
},
|
|
398
|
+
"nostr.unwrapGiftWraps": {
|
|
399
|
+
session: true,
|
|
400
|
+
params: obj({
|
|
401
|
+
publicKey,
|
|
402
|
+
events: arr(signedEvent, 256)
|
|
403
|
+
}),
|
|
404
|
+
result: obj({ results: arr(union(obj({ ok: rumor }), obj({ err: walletErrorCode })), 256) })
|
|
405
|
+
}
|
|
406
|
+
};
|
|
407
|
+
//#endregion
|
|
408
|
+
//#region src/protocol/index.ts
|
|
409
|
+
const PROTOCOL_VERSION = 1;
|
|
410
|
+
/**
|
|
411
|
+
* Responses to requests whose `id` cannot be parsed (malformed envelope) carry id 0. Main-side
|
|
412
|
+
* request ids start at 1, so a `0` is never a real pending request.
|
|
413
|
+
*/
|
|
414
|
+
const UNATTRIBUTED_ID = 0;
|
|
415
|
+
/** Deep check that a structured-cloned value is a strict ProtocolValue (no cycles detected). */
|
|
416
|
+
function isProtocolValue(value) {
|
|
417
|
+
switch (typeof value) {
|
|
418
|
+
case "boolean":
|
|
419
|
+
case "string": return true;
|
|
420
|
+
case "number": return Number.isSafeInteger(value);
|
|
421
|
+
case "object": break;
|
|
422
|
+
default: return false;
|
|
423
|
+
}
|
|
424
|
+
if (value === null || value instanceof Uint8Array) return true;
|
|
425
|
+
if (Array.isArray(value)) return value.every(isProtocolValue);
|
|
426
|
+
if (Object.getPrototypeOf(value) !== Object.prototype) return false;
|
|
427
|
+
return Object.values(value).every(isProtocolValue);
|
|
428
|
+
}
|
|
429
|
+
/** The status payload: core sections plus one object section per protocol module. */
|
|
430
|
+
const statusPayload = obj({
|
|
431
|
+
protocol: literal(1),
|
|
432
|
+
vault: union(literal("uninitialized"), literal("locked"), literal("unlocked"), literal("corrupted")),
|
|
433
|
+
factors: arr(factorInfo, MAX_SNAPSHOT_ITEMS),
|
|
434
|
+
wallets: arr(walletInfo, MAX_SNAPSHOT_ITEMS),
|
|
435
|
+
nostr: nostrStatus
|
|
436
|
+
});
|
|
437
|
+
const METHODS = {
|
|
438
|
+
status: {
|
|
439
|
+
session: false,
|
|
440
|
+
params: nullValue,
|
|
441
|
+
result: statusPayload
|
|
442
|
+
},
|
|
443
|
+
...CORE_METHODS,
|
|
444
|
+
...NOSTR_METHODS
|
|
445
|
+
};
|
|
446
|
+
const lockReason = union(literal("cold-start"), literal("user"), literal("idle"), literal("background"), literal("expired"), literal("crashed"));
|
|
447
|
+
const errorPayload = obj({
|
|
448
|
+
code: walletErrorCode,
|
|
449
|
+
retryAt: opt(safeTime)
|
|
450
|
+
});
|
|
451
|
+
/** Host-side validators: `kernelEvent` covers the two push messages. */
|
|
452
|
+
const kernelEvent = union(obj({
|
|
453
|
+
v: literal(1),
|
|
454
|
+
event: literal("status"),
|
|
455
|
+
status: statusPayload
|
|
456
|
+
}), obj({
|
|
457
|
+
v: literal(1),
|
|
458
|
+
event: literal("locked"),
|
|
459
|
+
reason: lockReason
|
|
460
|
+
}));
|
|
461
|
+
/** Validates the `err` payload of a response; `ok` is checked against `METHODS[m].result`. */
|
|
462
|
+
const responseError = errorPayload;
|
|
463
|
+
//#endregion
|
|
464
|
+
export { opt as _, kernelEvent as a, validate as b, CORE_METHODS as c, bool as d, bytes as f, obj as g, nullValue as h, isProtocolValue as i, ValidationError as l, literal as m, PROTOCOL_VERSION as n, responseError as o, int as p, UNATTRIBUTED_ID as r, NOSTR_METHODS as s, METHODS as t, arr as u, str as v, union as y };
|
|
465
|
+
|
|
466
|
+
//# sourceMappingURL=protocol-D9_0sY_Y.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"protocol-D9_0sY_Y.mjs","names":[],"sources":["../src/protocol/validate.ts","../src/protocol/core.ts","../src/protocol/nostr.ts","../src/protocol/index.ts"],"sourcesContent":["/**\n * Strict validator combinators for the secret-area protocol. Both sides share them: the kernel\n * validates every request, the host validates every response. Anything that does not match is a\n * `ValidationError` — never a partially-accepted value.\n */\nimport type { NullValue } from \"./index.ts\";\n\nexport class ValidationError extends Error {\n override name = \"ValidationError\";\n}\n\nexport type Validator<T> = (value: unknown) => T;\n\nfunction fail(): never {\n throw new ValidationError();\n}\n\nexport function literal<T extends NullValue | boolean | number | string>(\n expected: T,\n): Validator<T> {\n return (value) => {\n if (value !== expected) {\n fail();\n }\n return expected;\n };\n}\n\nexport const nullValue: Validator<NullValue> = literal(null);\nexport const bool: Validator<boolean> = (value) => {\n if (typeof value !== \"boolean\") {\n fail();\n }\n return value;\n};\n\nexport function int(min: number, max: number): Validator<number> {\n return (value) => {\n if (typeof value !== \"number\" || !Number.isSafeInteger(value) || value < min || value > max) {\n fail();\n }\n return value;\n };\n}\n\nexport function str(max: number, pattern?: RegExp): Validator<string> {\n return (value) => {\n if (\n typeof value !== \"string\" ||\n value.length > max ||\n (pattern !== undefined && !pattern.test(value))\n ) {\n fail();\n }\n return value;\n };\n}\n\nexport function bytes(min: number, max?: number): Validator<Uint8Array> {\n const high = max ?? min;\n return (value) => {\n if (!(value instanceof Uint8Array) || value.length < min || value.length > high) {\n fail();\n }\n return value;\n };\n}\n\nexport function arr<T>(item: Validator<T>, max: number, min = 0): Validator<ReadonlyArray<T>> {\n return (value) => {\n if (!Array.isArray(value) || value.length < min || value.length > max) {\n fail();\n }\n const out: T[] = [];\n for (const element of value) {\n out.push(item(element));\n }\n return out;\n };\n}\n\nclass Opt<T> {\n readonly validator: Validator<T>;\n\n constructor(validator: Validator<T>) {\n this.validator = validator;\n }\n}\n\nexport function opt<T>(validator: Validator<T>): Opt<T> {\n return new Opt(validator);\n}\n\ntype Field = Validator<unknown> | Opt<unknown>;\ntype Shape = Record<string, Field>;\n\ntype RequiredKeys<S extends Shape> = {\n readonly [K in keyof S as S[K] extends Opt<unknown> ? never : K]: S[K] extends Validator<infer T>\n ? T\n : never;\n};\ntype OptionalKeys<S extends Shape> = {\n readonly [K in keyof S as S[K] extends Opt<unknown> ? K : never]?: S[K] extends Opt<infer T>\n ? T\n : never;\n};\ntype ShapeResult<S extends Shape> = RequiredKeys<S> & OptionalKeys<S>;\n\n/** Exact key set: required keys present, optional keys allowed, nothing else. */\nexport function obj<S extends Shape>(shape: S): Validator<ShapeResult<S>> {\n const keys = Object.keys(shape);\n return (value) => {\n if (\n typeof value !== \"object\" ||\n value === null ||\n Array.isArray(value) ||\n value instanceof Uint8Array\n ) {\n fail();\n }\n // oxlint-disable-next-line typescript/no-unsafe-type-assertion -- narrowed to a plain object above\n const record = value as Record<string, unknown>;\n for (const key of Object.keys(record)) {\n if (!(key in shape)) {\n fail();\n }\n }\n const out: Record<string, unknown> = {};\n for (const key of keys) {\n const field = shape[key];\n if (field === undefined) {\n fail();\n }\n const raw = record[key];\n if (field instanceof Opt) {\n if (raw !== undefined) {\n out[key] = field.validator(raw);\n }\n } else {\n if (!(key in record)) {\n fail();\n }\n out[key] = field(raw);\n }\n }\n // oxlint-disable-next-line typescript/no-unsafe-type-assertion -- the shape guarantees the keys\n return out as ShapeResult<S>;\n };\n}\n\n/** Tries each branch in order; the first match wins. */\nexport function union<Vs extends ReadonlyArray<Validator<unknown>>>(\n ...branches: Vs\n): Validator<ReturnType<Vs[number]>> {\n return (value) => {\n for (const branch of branches) {\n try {\n // oxlint-disable-next-line typescript/no-unsafe-type-assertion -- ReturnType of the branch union\n return branch(value) as ReturnType<Vs[number]>;\n } catch (error) {\n if (!(error instanceof ValidationError)) {\n throw error;\n }\n }\n }\n return fail();\n };\n}\n\n/** Validates a value and returns it, or undefined on a shape mismatch. */\nexport function validate<T>(validator: Validator<T>, value: unknown): T | undefined {\n try {\n return validator(value);\n } catch (error) {\n if (error instanceof ValidationError) {\n return undefined;\n }\n throw error;\n }\n}\n","/**\n * The core method table: vault, wallet and data-key commands — nothing protocol-specific. \"Create\n * or import\" commands (createWithPasskey/restoreWithPasskey/createMnemonic/importMnemonic) are\n * `session: false` here because the rule is dynamic: with an uninitialized vault they carry\n * `factor` and establish the vault in one commit; with an established vault `factor` must be absent\n * and a valid session is required.\n *\n * The shared wire validators (factor, wallet info, ids) live here too so the nostr module's table\n * can reuse them — `protocol/nostr.ts` imports only from this file.\n */\nimport type { FactorInfo, WalletErrorCode, WalletInfo } from \"../types.ts\";\nimport type { NullValue } from \"./index.ts\";\nimport type { Validator } from \"./validate.ts\";\nimport { arr, bool, bytes, int, literal, nullValue, obj, opt, str, union } from \"./validate.ts\";\n\nexport type MethodSpec<P, R> = {\n readonly session: boolean;\n readonly params: Validator<P>;\n readonly result: Validator<R>;\n};\n\n// Size caps (UTF-16 units for strings, bytes for Uint8Array). A whole message is capped at 1 MiB\n// by the host; these bound individual fields.\nexport const MAX_TEXT = 262_144;\nexport const MAX_TAGS = 1024;\nexport const MAX_TAG_ITEMS = 64;\nexport const MAX_TAG_ITEM = 4096;\nexport const MAX_BATCH = 256;\nexport const MAX_SNAPSHOT_ITEMS = 4096;\n\nexport const sessionId: Validator<string> = str(32, /^[0-9a-f]{32}$/);\nexport const draftId: Validator<string> = str(32, /^[0-9a-f]{32}$/);\nexport const walletId: Validator<string> = str(16, /^[0-9a-f]{16}$/);\nexport const publicKey: Validator<string> = str(64, /^[0-9a-f]{64}$/);\nexport const credentialId: Validator<string> = str(1364, /^[A-Za-z0-9_-]+$/);\nexport const safeTime: Validator<number> = int(0, Number.MAX_SAFE_INTEGER);\nexport const groupIndex: Validator<number> = int(0, 0x7fffffff);\n\nexport type Factor =\n | { readonly kind: \"password\"; readonly password: Uint8Array }\n | { readonly kind: \"passkey\"; readonly credentialId: Uint8Array; readonly prf: Uint8Array };\n\nexport const factor: Validator<Factor> = union(\n obj({ kind: literal(\"password\"), password: bytes(1, 1024) }),\n obj({ kind: literal(\"passkey\"), credentialId: bytes(1, 1023), prf: bytes(32) }),\n);\n\nexport const factorInfo: Validator<FactorInfo> = union(\n obj({ kind: literal(\"hardware\") }),\n obj({\n kind: literal(\"passkey\"),\n id: sessionId,\n credentialId,\n createdAt: safeTime,\n }),\n obj({ kind: literal(\"password\"), id: sessionId, createdAt: safeTime }),\n);\n\nexport const walletInfo: Validator<WalletInfo> = obj({\n walletId,\n origin: union(literal(\"passkey\"), literal(\"mnemonic\")),\n words: union(literal(12), literal(15), literal(18), literal(21), literal(24)),\n backedUp: bool,\n createdAt: safeTime,\n});\n\nexport const walletErrorCode: Validator<WalletErrorCode> = union(\n literal(\"locked\"),\n literal(\"cancelled\"),\n literal(\"factor-unavailable\"),\n literal(\"factor-invalidated\"),\n literal(\"wrong-password\"),\n literal(\"rate-limited\"),\n literal(\"invalid-input\"),\n literal(\"not-found\"),\n literal(\"already-exists\"),\n literal(\"integrity\"),\n literal(\"crashed\"),\n);\n\n/**\n * The result of every \"create or import\" wallet command: the new wallet's public info plus the\n * session it opened. Creating a wallet derives no protocol keys — modules add keys separately.\n */\nexport type CreatedResult = {\n readonly wallet: WalletInfo;\n readonly session: string;\n};\n\nconst createdResult: Validator<CreatedResult> = obj({ wallet: walletInfo, session: sessionId });\n\n// `status` itself is a core method, but its result validator composes every module's status\n// section — it is wired in protocol/index.ts, not here.\nexport const CORE_METHODS: {\n readonly \"vault.unlock\": MethodSpec<{ readonly factor: Factor }, { readonly session: string }>;\n readonly \"vault.lock\": MethodSpec<NullValue, NullValue>;\n readonly \"vault.reset\": MethodSpec<NullValue, NullValue>;\n readonly \"vault.addFactor\": MethodSpec<\n { readonly verify: Factor; readonly factor: Factor },\n FactorInfo\n >;\n readonly \"vault.removeFactor\": MethodSpec<\n { readonly verify: Factor; readonly id: string },\n NullValue\n >;\n readonly \"wallet.createWithPasskey\": MethodSpec<\n {\n readonly credentialId: Uint8Array;\n readonly prfWallet: Uint8Array;\n readonly factor?: Factor;\n },\n CreatedResult\n >;\n readonly \"wallet.restoreWithPasskey\": MethodSpec<\n {\n readonly credentialId: Uint8Array;\n readonly prfWallet: Uint8Array;\n readonly factor?: Factor;\n },\n CreatedResult\n >;\n readonly \"wallet.createMnemonic\": MethodSpec<\n { readonly words: 12 | 24; readonly factor?: Factor },\n { readonly draft: string; readonly words: Uint8Array; readonly quiz: ReadonlyArray<number> }\n >;\n readonly \"wallet.confirmMnemonic\": MethodSpec<\n { readonly draft: string; readonly answers: ReadonlyArray<Uint8Array> },\n CreatedResult\n >;\n readonly \"wallet.discardMnemonic\": MethodSpec<{ readonly draft: string }, NullValue>;\n readonly \"wallet.importMnemonic\": MethodSpec<\n { readonly mnemonic: Uint8Array; readonly factor?: Factor },\n CreatedResult\n >;\n readonly \"wallet.exportMnemonic\": MethodSpec<\n { readonly verify: Factor; readonly walletId: string },\n Uint8Array\n >;\n readonly \"wallet.delete\": MethodSpec<\n { readonly verify: Factor; readonly walletId: string },\n NullValue\n >;\n readonly \"dataKeys.get\": MethodSpec<{ readonly purpose: string }, Uint8Array>;\n} = {\n \"vault.unlock\": {\n session: false,\n params: obj({ factor }),\n result: obj({ session: sessionId }),\n },\n \"vault.lock\": { session: false, params: nullValue, result: nullValue },\n \"vault.reset\": { session: false, params: nullValue, result: nullValue },\n \"vault.addFactor\": {\n session: true,\n params: obj({ verify: factor, factor }),\n result: factorInfo,\n },\n \"vault.removeFactor\": {\n session: true,\n params: obj({ verify: factor, id: sessionId }),\n result: nullValue,\n },\n \"wallet.createWithPasskey\": {\n session: false,\n params: obj({ credentialId: bytes(1, 1023), prfWallet: bytes(32), factor: opt(factor) }),\n result: createdResult,\n },\n \"wallet.restoreWithPasskey\": {\n session: false,\n params: obj({ credentialId: bytes(1, 1023), prfWallet: bytes(32), factor: opt(factor) }),\n result: createdResult,\n },\n \"wallet.createMnemonic\": {\n session: false,\n params: obj({ words: union(literal(12), literal(24)), factor: opt(factor) }),\n result: obj({\n draft: draftId,\n words: bytes(16, 1024),\n quiz: arr(int(0, 23), 3, 3),\n }),\n },\n \"wallet.confirmMnemonic\": {\n session: false,\n params: obj({ draft: draftId, answers: arr(bytes(1, 64), 3, 3) }),\n result: createdResult,\n },\n \"wallet.discardMnemonic\": {\n session: false,\n params: obj({ draft: draftId }),\n result: nullValue,\n },\n \"wallet.importMnemonic\": {\n session: false,\n params: obj({ mnemonic: bytes(1, 1024), factor: opt(factor) }),\n result: createdResult,\n },\n \"wallet.exportMnemonic\": {\n session: true,\n params: obj({ verify: factor, walletId }),\n result: bytes(16, 1024),\n },\n \"wallet.delete\": {\n session: true,\n params: obj({ verify: factor, walletId }),\n result: nullValue,\n },\n \"dataKeys.get\": {\n session: true,\n params: obj({ purpose: str(32, /^[a-z0-9-]{1,32}$/) }),\n result: bytes(32),\n },\n};\n","/**\n * The nostr module's method table and wire validators. The protocol stays free of @qntx/nostr\n * imports — even types — so the event shapes it validates are declared here structurally; a\n * type-level test in packages/wallet/tests pins them assignable to and from @qntx/nostr's\n * Event/UnsignedEvent/Rumor.\n */\nimport type { DerivedNostrKey, NostrKeyInfo, WalletErrorCode } from \"../types.ts\";\nimport {\n factor,\n groupIndex,\n MAX_BATCH,\n MAX_SNAPSHOT_ITEMS,\n MAX_TAG_ITEM,\n MAX_TAG_ITEMS,\n MAX_TAGS,\n MAX_TEXT,\n publicKey,\n safeTime,\n sessionId,\n walletErrorCode,\n walletId,\n} from \"./core.ts\";\nimport type { Factor } from \"./core.ts\";\nimport type { MethodSpec, NullValue } from \"./index.ts\";\nimport type { Validator } from \"./validate.ts\";\nimport { arr, bytes, int, literal, nullValue, obj, opt, str, union } from \"./validate.ts\";\n\n/**\n * The unsigned event input the kernel signs. `pubkey` is optional: callers may omit it and the\n * kernel fills the signing key's own. Structurally compatible with @qntx/nostr's UnsignedEvent.\n */\nexport type UnsignedEventInput = {\n readonly kind: number;\n readonly created_at: number;\n readonly tags: ReadonlyArray<ReadonlyArray<string>>;\n readonly content: string;\n readonly pubkey?: string;\n};\n\n/** The signed event the kernel returns — the Nostr event minus `id`-less forms. */\nexport type SignedEvent = {\n readonly id: string;\n readonly pubkey: string;\n readonly sig: string;\n readonly kind: number;\n readonly created_at: number;\n readonly tags: ReadonlyArray<ReadonlyArray<string>>;\n readonly content: string;\n};\n\n/** A NIP-59 rumor: an unsigned event carrying a computed `id` but no `sig`. */\nexport type Rumor = {\n readonly id: string;\n readonly pubkey: string;\n readonly kind: number;\n readonly created_at: number;\n readonly tags: ReadonlyArray<ReadonlyArray<string>>;\n readonly content: string;\n};\n\nexport type NostrImportInput =\n | { readonly kind: \"nsec\"; readonly nsec: Uint8Array }\n | { readonly kind: \"ncryptsec\"; readonly ncryptsec: string; readonly password: Uint8Array };\n\nexport type NostrExportFormat =\n | { readonly kind: \"nsec\" }\n | { readonly kind: \"ncryptsec\"; readonly password: Uint8Array };\n\n/** One \"import/generate a key\" result: the key's public info plus the session it may have opened. */\nexport type KeyResult = { readonly key: NostrKeyInfo; readonly session: string };\n\nexport type UnwrapResult = { readonly ok: Rumor } | { readonly err: WalletErrorCode };\n\nconst hex128: Validator<string> = str(128, /^[0-9a-f]{128}$/);\n\nconst nostrKeyRef = union(\n obj({ kind: literal(\"derived\"), walletId, groupIndex }),\n obj({ kind: literal(\"standalone\"), id: publicKey }),\n obj({ kind: literal(\"nip46-client\"), id: publicKey }),\n);\n\nexport const nostrKeyInfo: Validator<NostrKeyInfo> = obj({\n ref: nostrKeyRef,\n publicKey,\n origin: union(\n literal(\"derived\"),\n literal(\"nsec\"),\n literal(\"ncryptsec\"),\n literal(\"generated\"),\n literal(\"nip46-client\"),\n ),\n createdAt: safeTime,\n});\n\n/** The nostr section of the status payload, composed by protocol/index.ts. */\nexport const nostrStatus: Validator<{ readonly keys: ReadonlyArray<NostrKeyInfo> }> = obj({\n keys: arr(nostrKeyInfo, MAX_SNAPSHOT_ITEMS),\n});\n\nconst keyResult: Validator<KeyResult> = obj({ key: nostrKeyInfo, session: sessionId });\n\nconst derivedNostrKey: Validator<DerivedNostrKey> = obj({ groupIndex, publicKey });\n\nconst tags: Validator<ReadonlyArray<ReadonlyArray<string>>> = arr(\n arr(str(MAX_TAG_ITEM), MAX_TAG_ITEMS),\n MAX_TAGS,\n);\n\nconst signEventInput: Validator<UnsignedEventInput> = obj({\n kind: int(0, 65535),\n created_at: safeTime,\n tags,\n content: str(MAX_TEXT),\n pubkey: opt(publicKey),\n});\n\nconst signedEvent: Validator<SignedEvent> = obj({\n id: publicKey,\n pubkey: publicKey,\n sig: hex128,\n kind: int(0, 65535),\n created_at: safeTime,\n tags,\n content: str(MAX_TEXT),\n});\n\nconst rumor: Validator<Rumor> = obj({\n id: publicKey,\n pubkey: publicKey,\n kind: int(0, 65535),\n created_at: safeTime,\n tags,\n content: str(MAX_TEXT),\n});\n\nconst nostrImportInput: Validator<NostrImportInput> = union(\n obj({ kind: literal(\"nsec\"), nsec: bytes(1, 256) }),\n obj({ kind: literal(\"ncryptsec\"), ncryptsec: str(512, /^ncryptsec1/), password: bytes(1, 1024) }),\n);\n\nconst nostrExportFormat: Validator<NostrExportFormat> = union(\n obj({ kind: literal(\"nsec\") }),\n obj({ kind: literal(\"ncryptsec\"), password: bytes(1, 1024) }),\n);\n\nconst textParams = obj({ publicKey, peer: publicKey, text: str(MAX_TEXT) });\nconst textResult = str(MAX_TEXT * 4);\n\nexport const NOSTR_METHODS: {\n readonly \"nostr.discover\": MethodSpec<\n { readonly walletId: string; readonly from: number; readonly count: number },\n { readonly keys: ReadonlyArray<DerivedNostrKey> }\n >;\n readonly \"nostr.deriveKey\": MethodSpec<\n { readonly walletId: string; readonly groupIndex: number },\n NostrKeyInfo\n >;\n readonly \"nostr.importKey\": MethodSpec<\n { readonly input: NostrImportInput; readonly factor?: Factor },\n KeyResult\n >;\n readonly \"nostr.generateKey\": MethodSpec<{ readonly factor?: Factor }, KeyResult>;\n readonly \"nostr.createNip46ClientKey\": MethodSpec<NullValue, NostrKeyInfo>;\n readonly \"nostr.removeKey\": MethodSpec<\n { readonly publicKey: string; readonly verify?: Factor },\n NullValue\n >;\n readonly \"nostr.exportKey\": MethodSpec<\n { readonly verify: Factor; readonly publicKey: string; readonly format: NostrExportFormat },\n Uint8Array\n >;\n readonly \"nostr.signEvent\": MethodSpec<\n { readonly publicKey: string; readonly event: UnsignedEventInput },\n SignedEvent\n >;\n readonly \"nostr.nip04Encrypt\": MethodSpec<\n { readonly publicKey: string; readonly peer: string; readonly text: string },\n string\n >;\n readonly \"nostr.nip04Decrypt\": MethodSpec<\n { readonly publicKey: string; readonly peer: string; readonly text: string },\n string\n >;\n readonly \"nostr.nip44Encrypt\": MethodSpec<\n { readonly publicKey: string; readonly peer: string; readonly text: string },\n string\n >;\n readonly \"nostr.nip44Decrypt\": MethodSpec<\n { readonly publicKey: string; readonly peer: string; readonly text: string },\n string\n >;\n readonly \"nostr.unwrapGiftWraps\": MethodSpec<\n { readonly publicKey: string; readonly events: ReadonlyArray<SignedEvent> },\n { readonly results: ReadonlyArray<UnwrapResult> }\n >;\n} = {\n \"nostr.discover\": {\n session: true,\n params: obj({ walletId, from: groupIndex, count: int(1, 20) }),\n result: obj({ keys: arr(derivedNostrKey, 20) }),\n },\n \"nostr.deriveKey\": {\n session: true,\n params: obj({ walletId, groupIndex }),\n result: nostrKeyInfo,\n },\n \"nostr.importKey\": {\n session: false,\n params: obj({ input: nostrImportInput, factor: opt(factor) }),\n result: keyResult,\n },\n \"nostr.generateKey\": {\n session: false,\n params: obj({ factor: opt(factor) }),\n result: keyResult,\n },\n \"nostr.createNip46ClientKey\": { session: true, params: nullValue, result: nostrKeyInfo },\n \"nostr.removeKey\": {\n session: true,\n params: obj({ publicKey, verify: opt(factor) }),\n result: nullValue,\n },\n \"nostr.exportKey\": {\n session: true,\n params: obj({ verify: factor, publicKey, format: nostrExportFormat }),\n result: bytes(16, 4096),\n },\n \"nostr.signEvent\": {\n session: true,\n params: obj({ publicKey, event: signEventInput }),\n result: signedEvent,\n },\n \"nostr.nip04Encrypt\": { session: true, params: textParams, result: textResult },\n \"nostr.nip04Decrypt\": { session: true, params: textParams, result: textResult },\n \"nostr.nip44Encrypt\": { session: true, params: textParams, result: textResult },\n \"nostr.nip44Decrypt\": { session: true, params: textParams, result: textResult },\n \"nostr.unwrapGiftWraps\": {\n session: true,\n params: obj({ publicKey, events: arr(signedEvent, MAX_BATCH) }),\n result: obj({\n results: arr(union(obj({ ok: rumor }), obj({ err: walletErrorCode })), MAX_BATCH),\n }),\n },\n};\n","/**\n * Secret-area wire protocol (design/impl/wallet-e0.mdx \"协议与传输\"). Shared by the kernel and the main\n * runtime: the kernel validates every request, the host validates every response. Web/Node carry\n * ProtocolValue via structured clone; the RN host encodes the same values as CBOR.\n *\n * This file is the method-table composition point: `METHODS` spreads the core table\n * (protocol/core.ts) and the nostr module's table (protocol/nostr.ts), and the status result\n * validator composes the core sections with each module's status section.\n */\nimport type { LockReason, StatusPayload, WalletErrorCode } from \"../types.ts\";\n// oxlint-disable-next-line unicorn/prefer-export-from -- the tables are composed locally AND re-exported\nimport {\n CORE_METHODS,\n factorInfo,\n MAX_SNAPSHOT_ITEMS,\n safeTime,\n walletErrorCode,\n walletInfo,\n} from \"./core.ts\";\nimport type { MethodSpec } from \"./core.ts\";\n// oxlint-disable-next-line unicorn/prefer-export-from -- the table is composed locally AND re-exported\nimport { NOSTR_METHODS, nostrStatus } from \"./nostr.ts\";\nimport { arr, literal, nullValue, obj, opt, union } from \"./validate.ts\";\nimport type { Validator } from \"./validate.ts\";\n\nexport type { WalletErrorCode } from \"../types.ts\";\n\nexport const PROTOCOL_VERSION = 1;\n\n/**\n * Responses to requests whose `id` cannot be parsed (malformed envelope) carry id 0. Main-side\n * request ids start at 1, so a `0` is never a real pending request.\n */\nexport const UNATTRIBUTED_ID = 0;\n\n// oxlint-disable-next-line typescript/no-restricted-types -- JSON null is a protocol value\nexport type NullValue = null;\n\nexport type ProtocolValue =\n | NullValue\n | boolean\n | number // safe integer\n | string\n | Uint8Array\n | ReadonlyArray<ProtocolValue>\n | { readonly [key: string]: ProtocolValue };\n\nexport type Request = {\n readonly v: 1;\n readonly id: number;\n readonly method: string;\n readonly session?: string;\n readonly params: ProtocolValue;\n};\n\nexport type ErrorPayload = {\n readonly code: WalletErrorCode;\n readonly retryAt?: number; // only for \"rate-limited\"\n};\n\nexport type Response =\n | { readonly v: 1; readonly id: number; readonly ok: ProtocolValue }\n | { readonly v: 1; readonly id: number; readonly err: ErrorPayload };\n\nexport type KernelEvent =\n | { readonly v: 1; readonly event: \"status\"; readonly status: StatusPayload }\n | { readonly v: 1; readonly event: \"locked\"; readonly reason: LockReason };\n\n/** Deep check that a structured-cloned value is a strict ProtocolValue (no cycles detected). */\nexport function isProtocolValue(value: unknown): value is ProtocolValue {\n switch (typeof value) {\n case \"boolean\":\n case \"string\":\n return true;\n case \"number\":\n return Number.isSafeInteger(value);\n case \"object\":\n break;\n default:\n return false;\n }\n if (value === null || value instanceof Uint8Array) {\n return true;\n }\n if (Array.isArray(value)) {\n return value.every(isProtocolValue);\n }\n if (Object.getPrototypeOf(value) !== Object.prototype) {\n return false;\n }\n return Object.values(value).every(isProtocolValue);\n}\n\n/** The status payload: core sections plus one object section per protocol module. */\nconst statusPayload: Validator<StatusPayload> = obj({\n protocol: literal(1),\n vault: union(\n literal(\"uninitialized\"),\n literal(\"locked\"),\n literal(\"unlocked\"),\n literal(\"corrupted\"),\n ),\n factors: arr(factorInfo, MAX_SNAPSHOT_ITEMS),\n wallets: arr(walletInfo, MAX_SNAPSHOT_ITEMS),\n nostr: nostrStatus,\n});\n\n// The explicit annotation is the composition contract: a key missing from either table fails\n// declaration emit, and a duplicated key fails assignability (the spread's type for that key\n// cannot satisfy the intersection).\nexport const METHODS: {\n readonly status: MethodSpec<NullValue, StatusPayload>;\n} & typeof CORE_METHODS &\n typeof NOSTR_METHODS = {\n status: {\n session: false,\n params: nullValue,\n result: statusPayload,\n },\n ...CORE_METHODS,\n ...NOSTR_METHODS,\n};\n\n// A method name must live in exactly one table: an overlap violates the never constraint.\ntype AssertNever<T extends never> = T;\nexport type MethodTablesDisjoint = AssertNever<\n keyof typeof CORE_METHODS & keyof typeof NOSTR_METHODS\n>;\n\nexport type MethodName = keyof typeof METHODS;\nexport type ParamsOf<M extends MethodName> = ReturnType<(typeof METHODS)[M][\"params\"]>;\nexport type ResultOf<M extends MethodName> = ReturnType<(typeof METHODS)[M][\"result\"]>;\n\nconst lockReason: Validator<LockReason> = union(\n literal(\"cold-start\"),\n literal(\"user\"),\n literal(\"idle\"),\n literal(\"background\"),\n literal(\"expired\"),\n literal(\"crashed\"),\n);\n\nconst errorPayload = obj({ code: walletErrorCode, retryAt: opt(safeTime) });\n\n/** Host-side validators: `kernelEvent` covers the two push messages. */\nexport const kernelEvent: Validator<KernelEvent> = union(\n obj({ v: literal(1), event: literal(\"status\"), status: statusPayload }),\n obj({ v: literal(1), event: literal(\"locked\"), reason: lockReason }),\n);\n\n/** Validates the `err` payload of a response; `ok` is checked against `METHODS[m].result`. */\nexport const responseError: Validator<{ code: WalletErrorCode; retryAt?: number | undefined }> =\n errorPayload;\n\nexport { CORE_METHODS, NOSTR_METHODS };\nexport type { MethodSpec } from \"./core.ts\";\nexport type { CreatedResult, Factor } from \"./core.ts\";\nexport type {\n KeyResult,\n NostrExportFormat,\n NostrImportInput,\n Rumor,\n SignedEvent,\n UnsignedEventInput,\n UnwrapResult,\n} from \"./nostr.ts\";\nexport {\n ValidationError,\n arr,\n bool,\n bytes,\n int,\n literal,\n nullValue,\n obj,\n opt,\n str,\n union,\n validate,\n type Validator,\n} from \"./validate.ts\";\n"],"mappings":";AAOA,IAAa,kBAAb,cAAqC,MAAM;CACzC,OAAgB;AAClB;AAIA,SAAS,OAAc;CACrB,MAAM,IAAI,gBAAgB;AAC5B;AAEA,SAAgB,QACd,UACc;CACd,QAAQ,UAAU;EAChB,IAAI,UAAU,UACZ,KAAK;EAEP,OAAO;CACT;AACF;AAEA,MAAa,YAAkC,QAAQ,IAAI;AAC3D,MAAa,QAA4B,UAAU;CACjD,IAAI,OAAO,UAAU,WACnB,KAAK;CAEP,OAAO;AAC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C,QAAQ,YAAY,GACpB,QAAQ,MAAM,GACd,QAAQ,MAAM,GACd,QAAQ,YAAY,GACpB,QAAQ,SAAS,GACjB,QAAQ,SAAS,CACnB;AAEA,MAAM,eAAe,IAAI;CAAE,MAAM;CAAiB,SAAS,IAAI,QAAQ;AAAE,CAAC;;AAG1E,MAAa,cAAsC,MACjD,IAAI;CAAE,GAAG,QAAQ,CAAC;CAAG,OAAO,QAAQ,QAAQ;CAAG,QAAQ;AAAc,CAAC,GACtE,IAAI;CAAE,GAAG,QAAQ,CAAC;CAAG,OAAO,QAAQ,QAAQ;CAAG,QAAQ;AAAW,CAAC,CACrE;;AAGA,MAAa,gBACX"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { _ as WalletErrorCode } from "./types-CEy7At1l.mjs";
|
|
2
|
+
import { A as Validator, B as union, C as UnsignedEventInput, D as Factor, E as CreatedResult, F as literal, I as nullValue, L as obj, M as bool, N as bytes, O as MethodSpec, P as int, R as opt, S as SignedEvent, T as CORE_METHODS, V as validate, _ as KeyResult, a as MethodTablesDisjoint, b as NostrImportInput, c as ParamsOf, d as Response, f as ResultOf, g as responseError, h as kernelEvent, i as MethodName, j as arr, k as ValidationError, l as ProtocolValue, m as isProtocolValue, n as KernelEvent, o as NullValue, p as UNATTRIBUTED_ID, r as METHODS, s as PROTOCOL_VERSION, t as ErrorPayload, u as Request, v as NOSTR_METHODS, w as UnwrapResult, x as Rumor, y as NostrExportFormat, z as str } from "./index-BJfyIwOZ.mjs";
|
|
3
|
+
export { CORE_METHODS, type CreatedResult, ErrorPayload, type Factor, KernelEvent, type KeyResult, METHODS, MethodName, type MethodSpec, MethodTablesDisjoint, NOSTR_METHODS, type NostrExportFormat, type NostrImportInput, NullValue, PROTOCOL_VERSION, ParamsOf, ProtocolValue, Request, Response, ResultOf, type Rumor, type SignedEvent, UNATTRIBUTED_ID, type UnsignedEventInput, type UnwrapResult, ValidationError, type Validator, type WalletErrorCode, arr, bool, bytes, int, isProtocolValue, kernelEvent, literal, nullValue, obj, opt, responseError, str, union, validate };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { _ as opt, a as kernelEvent, b as validate, c as CORE_METHODS, d as bool, f as bytes, g as obj, h as nullValue, i as isProtocolValue, l as ValidationError, m as literal, n as PROTOCOL_VERSION, o as responseError, p as int, r as UNATTRIBUTED_ID, s as NOSTR_METHODS, t as METHODS, u as arr, v as str, y as union } from "./protocol-D9_0sY_Y.mjs";
|
|
2
|
+
export { CORE_METHODS, METHODS, NOSTR_METHODS, PROTOCOL_VERSION, UNATTRIBUTED_ID, ValidationError, arr, bool, bytes, int, isProtocolValue, kernelEvent, literal, nullValue, obj, opt, responseError, str, union, validate };
|