@cero-base/core 2.5.0 → 2.7.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/package.json +1 -1
- package/src/database/dispatch.js +159 -30
- package/src/database/encryption.js +9 -8
- package/src/database/index.js +53 -17
- package/src/database/rotation.js +13 -11
- package/src/identity/index.js +131 -56
- package/src/lib/schema.js +15 -7
- package/src/lib/spec/index.js +15 -12
- package/src/lib/spec/schema.json +10 -10
- package/src/lib/utils.js +5 -4
- package/src/network/index.js +4 -11
- package/src/pairing/index.js +18 -10
- package/src/push/index.js +4 -3
- package/types/database/encryption.d.ts +8 -6
- package/types/database/index.d.ts +22 -5
- package/types/database/rotation.d.ts +2 -2
- package/types/identity/index.d.ts +101 -41
- package/types/lib/schema.d.ts +15 -4
- package/types/lib/spec/index.d.ts +4 -4
- package/types/network/index.d.ts +1 -7
- package/types/pairing/index.d.ts +13 -2
- package/types/push/index.d.ts +3 -2
|
@@ -15,25 +15,27 @@ export declare function blobEpochKey(entropy: Uint8Array): Uint8Array;
|
|
|
15
15
|
*/
|
|
16
16
|
export declare function loadEpochs(keyring: Keyring, local: import('hypercore')): Promise<void>;
|
|
17
17
|
/**
|
|
18
|
-
*
|
|
19
|
-
*
|
|
18
|
+
* A rotation announcement's envelope list — one box per device row, sealed to its device key and
|
|
19
|
+
* addressed by its writer id.
|
|
20
20
|
*
|
|
21
|
-
* @param {Array<{ id: string }>}
|
|
21
|
+
* @param {Array<{ id: string, key: Uint8Array }>} devices
|
|
22
22
|
* @param {Uint8Array} secret
|
|
23
23
|
* @returns {Array<{ id: string, box: Uint8Array }>}
|
|
24
24
|
*/
|
|
25
|
-
export declare function seal(
|
|
25
|
+
export declare function seal(devices: Array<{
|
|
26
26
|
id: string;
|
|
27
|
+
key: Uint8Array;
|
|
27
28
|
}>, secret: Uint8Array): Array<{
|
|
28
29
|
id: string;
|
|
29
30
|
box: Uint8Array;
|
|
30
31
|
}>;
|
|
31
32
|
/**
|
|
32
|
-
* @param {import('../identity/index.js').Identity} identity
|
|
33
|
+
* @param {import('../identity/index.js').Identity} identity Whose device key opens the box.
|
|
34
|
+
* @param {string} id This device's writer id in the database.
|
|
33
35
|
* @param {Uint8Array} wrapped
|
|
34
36
|
* @returns {Generator<Uint8Array, void, unknown>}
|
|
35
37
|
*/
|
|
36
|
-
export declare function opened(identity: import('../identity/index.js').Identity, wrapped: Uint8Array): Generator<Uint8Array, void, unknown>;
|
|
38
|
+
export declare function opened(identity: import('../identity/index.js').Identity, id: string, wrapped: Uint8Array): Generator<Uint8Array, void, unknown>;
|
|
37
39
|
/** @type {import('compact-encoding').Encoder<Array<{ id: string, box: Uint8Array }>>} */
|
|
38
40
|
export declare const wraps: import('compact-encoding').Encoder<Array<{
|
|
39
41
|
id: string;
|
|
@@ -61,7 +61,7 @@ export type DatabaseOpts = {
|
|
|
61
61
|
*/
|
|
62
62
|
pinned?: boolean;
|
|
63
63
|
/**
|
|
64
|
-
* Push a notification through the mirrors after
|
|
64
|
+
* Push a notification through the mirrors after a local write to a ref whose meta declares `push`, naming the ref, so members learn of it while their app is dead.
|
|
65
65
|
*/
|
|
66
66
|
push?: boolean;
|
|
67
67
|
/**
|
|
@@ -131,6 +131,10 @@ export type HookContext = {
|
|
|
131
131
|
* The writer's role, null likewise.
|
|
132
132
|
*/
|
|
133
133
|
role: string | null;
|
|
134
|
+
/**
|
|
135
|
+
* On removing a member or changing her rank: whether the writer's rank alone allows it. A rule answers `'grant'` to allow what rank refuses, `false` to refuse.
|
|
136
|
+
*/
|
|
137
|
+
ranked?: boolean;
|
|
134
138
|
get: (ref: string | {
|
|
135
139
|
name: string;
|
|
136
140
|
}, query?: string | Record<string, unknown>) => Promise<{
|
|
@@ -158,7 +162,7 @@ export type HookFn = (ctx: HookContext) => unknown;
|
|
|
158
162
|
* @property {Array<{ epoch: number, entropy: Uint8Array }> | null} [epochs] Rotation epochs to prime the keyring with (delivered at join).
|
|
159
163
|
* @property {Uint8Array | null} [key] Existing autobee key to reopen.
|
|
160
164
|
* @property {boolean} [pinned] Always search and announce, outside the network's presence budget. The root.
|
|
161
|
-
* @property {boolean} [push] Push a notification through the mirrors after
|
|
165
|
+
* @property {boolean} [push] Push a notification through the mirrors after a local write to a ref whose meta declares `push`, naming the ref, so members learn of it while their app is dead.
|
|
162
166
|
* @property {import('../identity/index.js').KeyPair} [keyPair] This device's writer keypair; a fresh random one by default. Never the identity's, never the database key.
|
|
163
167
|
* @property {(err: Error) => void} [onerror] Called when a node is skipped or refused, or the bee errors.
|
|
164
168
|
*
|
|
@@ -179,6 +183,7 @@ export type HookFn = (ctx: HookContext) => unknown;
|
|
|
179
183
|
* @property {string | null} id The row id for a `del`.
|
|
180
184
|
* @property {string | null} memberId The writer's member id, null for a core no member owns yet (a join, a claim, genesis).
|
|
181
185
|
* @property {string | null} role The writer's role, null likewise.
|
|
186
|
+
* @property {boolean} [ranked] On removing a member or changing her rank: whether the writer's rank alone allows it. A rule answers `'grant'` to allow what rank refuses, `false` to refuse.
|
|
182
187
|
* @property {(ref: string | { name: string }, query?: string | Record<string, unknown>) => Promise<{ data: unknown }>} get
|
|
183
188
|
* @property {(ref: string | { name: string }, row: Record<string, unknown>) => Promise<void>} put
|
|
184
189
|
* @property {(ref: string | { name: string }, row: Record<string, unknown>) => Promise<void>} set
|
|
@@ -237,6 +242,8 @@ export declare class Database extends ReadyResource {
|
|
|
237
242
|
key: Uint8Array<ArrayBufferLike>;
|
|
238
243
|
pinned: boolean;
|
|
239
244
|
push: boolean;
|
|
245
|
+
/** @private */
|
|
246
|
+
_pushes;
|
|
240
247
|
keyPair: import("../index.js").KeyPair;
|
|
241
248
|
/** @private */
|
|
242
249
|
_onerror;
|
|
@@ -259,6 +266,8 @@ export declare class Database extends ReadyResource {
|
|
|
259
266
|
/** @private */
|
|
260
267
|
_pushed;
|
|
261
268
|
/** @private */
|
|
269
|
+
_pushRef;
|
|
270
|
+
/** @private */
|
|
262
271
|
_onResume;
|
|
263
272
|
/** @private */
|
|
264
273
|
_txChain;
|
|
@@ -391,6 +400,8 @@ export declare class Database extends ReadyResource {
|
|
|
391
400
|
/** @private */
|
|
392
401
|
private _push;
|
|
393
402
|
/** @private */
|
|
403
|
+
private _ref;
|
|
404
|
+
/** @private */
|
|
394
405
|
private _send;
|
|
395
406
|
/**
|
|
396
407
|
* Read a row. With no `query`: list all (collection) or fetch the one
|
|
@@ -457,12 +468,18 @@ export declare class Database extends ReadyResource {
|
|
|
457
468
|
timeout?: number;
|
|
458
469
|
}): Promise<void>;
|
|
459
470
|
/**
|
|
460
|
-
*
|
|
471
|
+
* Learn epochs handed over after the open, as a root carries them for a handle. One is kept
|
|
472
|
+
* once its announcement applied here and the secret meets the commitment it carries: hand them
|
|
473
|
+
* over again when an announcement applies.
|
|
461
474
|
*
|
|
462
|
-
* @param {Uint8Array}
|
|
475
|
+
* @param {Array<{ epoch: number, stamp: number, entropy: Uint8Array }>} epochs
|
|
463
476
|
* @returns {Promise<void>}
|
|
464
477
|
*/
|
|
465
|
-
|
|
478
|
+
learn(epochs: Array<{
|
|
479
|
+
epoch: number;
|
|
480
|
+
stamp: number;
|
|
481
|
+
entropy: Uint8Array;
|
|
482
|
+
}>): Promise<void>;
|
|
466
483
|
/**
|
|
467
484
|
* Remove a peer's writer key from the indexer set.
|
|
468
485
|
*
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Epoch key rotation for a database: mint a secret, seal it to every
|
|
2
|
+
* Epoch key rotation for a database: mint a secret, seal it to every device, announce it
|
|
3
3
|
* through the log, and on every peer learn the secrets addressed to it.
|
|
4
4
|
*/
|
|
5
5
|
export declare class Rotation {
|
|
@@ -48,7 +48,7 @@ export declare class Rotation {
|
|
|
48
48
|
/** @private */
|
|
49
49
|
private _rotate;
|
|
50
50
|
/** @private */
|
|
51
|
-
private
|
|
51
|
+
private _devices;
|
|
52
52
|
/** @private */
|
|
53
53
|
private _announce;
|
|
54
54
|
/** @private */
|
|
@@ -4,17 +4,47 @@ export type KeyPair = {
|
|
|
4
4
|
id: string;
|
|
5
5
|
};
|
|
6
6
|
export type IdentityFields = {
|
|
7
|
+
/**
|
|
8
|
+
* The identity's public key.
|
|
9
|
+
*/
|
|
7
10
|
publicKey: Uint8Array;
|
|
8
|
-
|
|
11
|
+
/**
|
|
12
|
+
* Its root encryption key, derived from the seed.
|
|
13
|
+
*/
|
|
9
14
|
encryptionKey: Uint8Array;
|
|
10
|
-
|
|
15
|
+
/**
|
|
16
|
+
* This device's signing keypair.
|
|
17
|
+
*/
|
|
18
|
+
device: KeyPair;
|
|
19
|
+
/**
|
|
20
|
+
* The device's chain of attestations back to the identity.
|
|
21
|
+
*/
|
|
22
|
+
proof: Uint8Array;
|
|
23
|
+
/**
|
|
24
|
+
* The phrase's entropy: on the device that created or recovered the identity, never on a linked one.
|
|
25
|
+
*/
|
|
26
|
+
seed?: Uint8Array | null;
|
|
27
|
+
};
|
|
28
|
+
export type Verified = {
|
|
29
|
+
identity: Uint8Array;
|
|
30
|
+
device: Uint8Array;
|
|
11
31
|
};
|
|
12
32
|
/**
|
|
13
33
|
* @typedef {{ publicKey: Uint8Array, secretKey: Uint8Array, id: string }} KeyPair
|
|
14
|
-
*
|
|
34
|
+
*
|
|
35
|
+
* @typedef {object} IdentityFields
|
|
36
|
+
* @property {Uint8Array} publicKey The identity's public key.
|
|
37
|
+
* @property {Uint8Array} encryptionKey Its root encryption key, derived from the seed.
|
|
38
|
+
* @property {KeyPair} device This device's signing keypair.
|
|
39
|
+
* @property {Uint8Array} proof The device's chain of attestations back to the identity.
|
|
40
|
+
* @property {Uint8Array | null} [seed] The phrase's entropy: on the device that created or recovered the identity, never on a linked one.
|
|
41
|
+
*
|
|
42
|
+
* @typedef {{ identity: Uint8Array, device: Uint8Array }} Verified
|
|
15
43
|
*/
|
|
16
44
|
/**
|
|
17
|
-
*
|
|
45
|
+
* A user identity, as one of its devices holds it. The identity's secret key signs exactly one
|
|
46
|
+
* thing, a device's first proof, and is never kept: everything else is signed by the device key
|
|
47
|
+
* and carries the proof, so a stolen device leaks only itself.
|
|
18
48
|
*/
|
|
19
49
|
export declare class Identity {
|
|
20
50
|
/**
|
|
@@ -25,8 +55,6 @@ export declare class Identity {
|
|
|
25
55
|
id: string;
|
|
26
56
|
/** @type {Uint8Array} */
|
|
27
57
|
publicKey: Uint8Array;
|
|
28
|
-
/** @type {Uint8Array} */
|
|
29
|
-
secretKey: Uint8Array;
|
|
30
58
|
/**
|
|
31
59
|
* Symmetric key for encrypting per-identity payloads.
|
|
32
60
|
*
|
|
@@ -39,17 +67,17 @@ export declare class Identity {
|
|
|
39
67
|
* @type {Uint8Array}
|
|
40
68
|
*/
|
|
41
69
|
topic: Uint8Array;
|
|
70
|
+
/** @type {KeyPair} */
|
|
71
|
+
device: KeyPair;
|
|
72
|
+
/** @type {Uint8Array} */
|
|
73
|
+
proof: Uint8Array;
|
|
74
|
+
/** @type {Uint8Array | null} */
|
|
75
|
+
seed: Uint8Array | null;
|
|
76
|
+
/** @param {IdentityFields} fields */
|
|
77
|
+
constructor({ publicKey, encryptionKey, device, proof, seed }: IdentityFields);
|
|
42
78
|
/**
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
* @type {Uint8Array}
|
|
46
|
-
*/
|
|
47
|
-
seed: Uint8Array;
|
|
48
|
-
/** @param {IdentityFields} keys */
|
|
49
|
-
constructor(keys: IdentityFields);
|
|
50
|
-
/**
|
|
51
|
-
* Redacted — secretKey/encryptionKey/seed must never reach JSON.stringify
|
|
52
|
-
* or a structured logger.
|
|
79
|
+
* Redacted — the device secret, encryptionKey and seed must never reach JSON.stringify or a
|
|
80
|
+
* structured logger.
|
|
53
81
|
*
|
|
54
82
|
* @returns {{ id: string }}
|
|
55
83
|
*/
|
|
@@ -57,23 +85,36 @@ export declare class Identity {
|
|
|
57
85
|
id: string;
|
|
58
86
|
};
|
|
59
87
|
/**
|
|
60
|
-
*
|
|
88
|
+
* A proof over `data`: this device's signature, under its chain to the identity.
|
|
61
89
|
*
|
|
62
|
-
* @param {Uint8Array}
|
|
90
|
+
* @param {Uint8Array} data
|
|
63
91
|
* @returns {Uint8Array}
|
|
64
92
|
*/
|
|
65
|
-
sign(
|
|
93
|
+
sign(data: Uint8Array): Uint8Array;
|
|
66
94
|
/**
|
|
67
|
-
*
|
|
95
|
+
* A proof for a new device: this device attests it, one link further down the chain.
|
|
68
96
|
*
|
|
69
|
-
* @param {Uint8Array}
|
|
70
|
-
* @
|
|
71
|
-
* @returns {boolean}
|
|
97
|
+
* @param {Uint8Array} publicKey
|
|
98
|
+
* @returns {Uint8Array}
|
|
72
99
|
*/
|
|
73
|
-
|
|
100
|
+
link(publicKey: Uint8Array): Uint8Array;
|
|
74
101
|
/**
|
|
75
|
-
*
|
|
76
|
-
*
|
|
102
|
+
* A device with no identity yet: it signs as itself, its own key standing for the identity,
|
|
103
|
+
* until one attests it.
|
|
104
|
+
*
|
|
105
|
+
* @param {KeyPair} [device] A fresh keypair by default.
|
|
106
|
+
* @returns {Promise<Identity>}
|
|
107
|
+
*/
|
|
108
|
+
static bare(device?: KeyPair): Promise<Identity>;
|
|
109
|
+
/**
|
|
110
|
+
* The keys a proof chains through: the identity, then each device down to the signer.
|
|
111
|
+
*
|
|
112
|
+
* @param {Uint8Array} proof
|
|
113
|
+
* @returns {Uint8Array[]} Empty when it is not a proof.
|
|
114
|
+
*/
|
|
115
|
+
static chain(proof: Uint8Array): Uint8Array[];
|
|
116
|
+
/**
|
|
117
|
+
* Open a sealed box addressed to this device.
|
|
77
118
|
*
|
|
78
119
|
* @param {Uint8Array} sealed
|
|
79
120
|
* @returns {Uint8Array | null}
|
|
@@ -86,15 +127,44 @@ export declare class Identity {
|
|
|
86
127
|
*/
|
|
87
128
|
toPhrase(): string;
|
|
88
129
|
/**
|
|
89
|
-
* An identity from its seed, 16 or 32 bytes; a fresh one without.
|
|
130
|
+
* An identity from its seed, 16 or 32 bytes; a fresh one without. The identity key attests
|
|
131
|
+
* `device` and is dropped.
|
|
90
132
|
*
|
|
91
|
-
* @param {{ seed?: Uint8Array | null, words?: 12 | 24 }} [opts] `words` sizes a fresh
|
|
133
|
+
* @param {{ seed?: Uint8Array | null, words?: 12 | 24, device?: KeyPair }} [opts] `words` sizes a fresh seed; `device` is a fresh keypair by default.
|
|
92
134
|
* @returns {Promise<Identity>}
|
|
93
135
|
*/
|
|
94
|
-
static create({ seed, words }?: {
|
|
136
|
+
static create({ seed, words, device }?: {
|
|
95
137
|
seed?: Uint8Array | null;
|
|
96
138
|
words?: 12 | 24;
|
|
139
|
+
device?: KeyPair;
|
|
97
140
|
}): Promise<Identity>;
|
|
141
|
+
/**
|
|
142
|
+
* The identity keypair a seed writes, for what only the identity itself may sign: the pointer
|
|
143
|
+
* core it is created with. Nothing else ever takes it.
|
|
144
|
+
*
|
|
145
|
+
* @param {Uint8Array} seed
|
|
146
|
+
* @returns {Promise<{ publicKey: Uint8Array, secretKey: Uint8Array }>}
|
|
147
|
+
*/
|
|
148
|
+
static keyPair(seed: Uint8Array): Promise<{
|
|
149
|
+
publicKey: Uint8Array;
|
|
150
|
+
secretKey: Uint8Array;
|
|
151
|
+
}>;
|
|
152
|
+
/**
|
|
153
|
+
* The identity as a stored or linked device holds it. The proof must chain `device` to it.
|
|
154
|
+
*
|
|
155
|
+
* @param {IdentityFields} fields
|
|
156
|
+
* @returns {Identity}
|
|
157
|
+
*/
|
|
158
|
+
static from({ publicKey, encryptionKey, device, proof, seed }: IdentityFields): Identity;
|
|
159
|
+
/**
|
|
160
|
+
* Who signed `data`: the identity a proof chains to and the device that signed, or null.
|
|
161
|
+
*
|
|
162
|
+
* @param {Uint8Array} proof
|
|
163
|
+
* @param {Uint8Array | null} [data] What the proof signs; null verifies the chain alone.
|
|
164
|
+
* @param {Uint8Array | null} [publicKey] The identity expected, any when omitted.
|
|
165
|
+
* @returns {Verified | null}
|
|
166
|
+
*/
|
|
167
|
+
static verify(proof: Uint8Array, data?: Uint8Array | null, publicKey?: Uint8Array | null): Verified | null;
|
|
98
168
|
/**
|
|
99
169
|
* The seed a BIP-39 phrase writes out.
|
|
100
170
|
*
|
|
@@ -110,17 +180,7 @@ export declare class Identity {
|
|
|
110
180
|
*/
|
|
111
181
|
static toPhrase(seed: Uint8Array): string;
|
|
112
182
|
/**
|
|
113
|
-
*
|
|
114
|
-
*
|
|
115
|
-
* @param {Uint8Array} publicKey
|
|
116
|
-
* @param {Uint8Array} message
|
|
117
|
-
* @param {Uint8Array} signature
|
|
118
|
-
* @returns {boolean}
|
|
119
|
-
*/
|
|
120
|
-
static verify(publicKey: Uint8Array, message: Uint8Array, signature: Uint8Array): boolean;
|
|
121
|
-
/**
|
|
122
|
-
* Seal a message to an identity's Ed25519 public key (sealed box over the curve25519
|
|
123
|
-
* conversion).
|
|
183
|
+
* Seal a message to a device's Ed25519 public key (sealed box over the curve25519 conversion).
|
|
124
184
|
*
|
|
125
185
|
* @param {Uint8Array} publicKey
|
|
126
186
|
* @param {Uint8Array} message
|
|
@@ -128,7 +188,7 @@ export declare class Identity {
|
|
|
128
188
|
*/
|
|
129
189
|
static seal(publicKey: Uint8Array, message: Uint8Array): Uint8Array;
|
|
130
190
|
/**
|
|
131
|
-
* Generate a fresh Ed25519 keypair (for devices, blind invites
|
|
191
|
+
* Generate a fresh Ed25519 keypair (for devices, writers, blind invites).
|
|
132
192
|
*
|
|
133
193
|
* @returns {KeyPair}
|
|
134
194
|
*/
|
package/types/lib/schema.d.ts
CHANGED
|
@@ -5,6 +5,9 @@ export type Prim = {
|
|
|
5
5
|
export type TypeDef = {
|
|
6
6
|
kind: 'single' | 'collection' | 'action';
|
|
7
7
|
fields: Record<string, Prim>;
|
|
8
|
+
indexes?: Record<string, string[]>;
|
|
9
|
+
own?: boolean;
|
|
10
|
+
push?: boolean;
|
|
8
11
|
};
|
|
9
12
|
export type SchemaDefs = {
|
|
10
13
|
[name: string]: TypeDef | Record<string, TypeDef>;
|
|
@@ -39,28 +42,36 @@ export declare const t: {
|
|
|
39
42
|
* Single-row table (one record, set/get by name).
|
|
40
43
|
*
|
|
41
44
|
* @param {Record<string, Prim>} fields
|
|
45
|
+
* @param {{ push?: boolean }} [opts] `push`: a write pushes a notification, see collection.
|
|
42
46
|
* @returns {TypeDef}
|
|
43
47
|
*/
|
|
44
|
-
single(fields: Record<string, Prim
|
|
48
|
+
single(fields: Record<string, Prim>, opts?: {
|
|
49
|
+
push?: boolean;
|
|
50
|
+
}): TypeDef;
|
|
45
51
|
/**
|
|
46
52
|
* Multi-row table keyed by `id`. `own` restricts a row to the member who wrote it — anyone
|
|
47
|
-
* may add rows, but only the author changes or deletes theirs.
|
|
53
|
+
* may add rows, but only the author changes or deletes theirs. `push` makes a write to it push
|
|
54
|
+
* a notification to the other members' devices; what it says is the app's push worklet's.
|
|
48
55
|
*
|
|
49
56
|
* @param {Record<string, Prim>} fields
|
|
50
|
-
* @param {{ indexes?: Record<string, string[]>, own?: boolean }} [opts]
|
|
57
|
+
* @param {{ indexes?: Record<string, string[]>, own?: boolean, push?: boolean }} [opts]
|
|
51
58
|
* @returns {TypeDef}
|
|
52
59
|
*/
|
|
53
60
|
collection(fields: Record<string, Prim>, opts?: {
|
|
54
61
|
indexes?: Record<string, string[]>;
|
|
55
62
|
own?: boolean;
|
|
63
|
+
push?: boolean;
|
|
56
64
|
}): TypeDef;
|
|
57
65
|
/**
|
|
58
66
|
* RPC-style mutation that doesn't persist a row.
|
|
59
67
|
*
|
|
60
68
|
* @param {Record<string, Prim>} fields
|
|
69
|
+
* @param {{ push?: boolean }} [opts] `push`: a call pushes a notification, see collection.
|
|
61
70
|
* @returns {TypeDef}
|
|
62
71
|
*/
|
|
63
|
-
action(fields: Record<string, Prim
|
|
72
|
+
action(fields: Record<string, Prim>, opts?: {
|
|
73
|
+
push?: boolean;
|
|
74
|
+
}): TypeDef;
|
|
64
75
|
/**
|
|
65
76
|
* Add fields to a builtin type (members, devices, …). Merged into the
|
|
66
77
|
* builtin's base fields at build time; redeclaring a base field throws.
|
|
@@ -16,9 +16,8 @@ declare function getEncoding(name: any): {
|
|
|
16
16
|
decode(state: any): {
|
|
17
17
|
invite: any;
|
|
18
18
|
reply: any;
|
|
19
|
-
proof: any;
|
|
20
|
-
identity: any;
|
|
21
19
|
signature: any;
|
|
20
|
+
proof: any;
|
|
22
21
|
ts: any;
|
|
23
22
|
};
|
|
24
23
|
} | {
|
|
@@ -38,6 +37,7 @@ declare function getEncoding(name: any): {
|
|
|
38
37
|
key: any;
|
|
39
38
|
encryptionKey: any;
|
|
40
39
|
epochs: any;
|
|
40
|
+
proof: any;
|
|
41
41
|
};
|
|
42
42
|
} | {
|
|
43
43
|
preencode(state: any, m: any): void;
|
|
@@ -80,9 +80,8 @@ declare function getStruct(name: any, v?: number): {
|
|
|
80
80
|
} | {
|
|
81
81
|
invite: any;
|
|
82
82
|
reply: any;
|
|
83
|
-
proof: any;
|
|
84
|
-
identity: any;
|
|
85
83
|
signature: any;
|
|
84
|
+
proof: any;
|
|
86
85
|
ts: any;
|
|
87
86
|
} | {
|
|
88
87
|
epoch: any;
|
|
@@ -94,6 +93,7 @@ declare function getStruct(name: any, v?: number): {
|
|
|
94
93
|
key: any;
|
|
95
94
|
encryptionKey: any;
|
|
96
95
|
epochs: any;
|
|
96
|
+
proof: any;
|
|
97
97
|
} | {
|
|
98
98
|
data: any;
|
|
99
99
|
} | {
|
package/types/network/index.d.ts
CHANGED
|
@@ -4,10 +4,6 @@ import { Presence } from './presence.js';
|
|
|
4
4
|
/** @type {(topic: Uint8Array, channel: string | null) => Uint8Array} */
|
|
5
5
|
export declare function channelTopic(topic: Uint8Array<ArrayBufferLike>, channel: string): Uint8Array<ArrayBufferLike>;
|
|
6
6
|
export type NetworkOpts = {
|
|
7
|
-
/**
|
|
8
|
-
* Long-lived keypair used as the swarm identity.
|
|
9
|
-
*/
|
|
10
|
-
identity?: import('../identity/index.js').Identity;
|
|
11
7
|
/**
|
|
12
8
|
* Custom DHT bootstrap nodes.
|
|
13
9
|
*/
|
|
@@ -54,7 +50,6 @@ export type NetworkOpts = {
|
|
|
54
50
|
};
|
|
55
51
|
/**
|
|
56
52
|
* @typedef {object} NetworkOpts
|
|
57
|
-
* @property {import('../identity/index.js').Identity} [identity] Long-lived keypair used as the swarm identity.
|
|
58
53
|
* @property {Array<{ host: string, port: number }>} [bootstrap] Custom DHT bootstrap nodes.
|
|
59
54
|
* @property {(remotePublicKey: Uint8Array, payload: unknown) => boolean} [firewall] Incoming-connection filter.
|
|
60
55
|
* @property {Uint8Array[]} [relayThrough] Relay public keys to tunnel through.
|
|
@@ -70,7 +65,6 @@ export type NetworkOpts = {
|
|
|
70
65
|
* replicates the store.
|
|
71
66
|
*/
|
|
72
67
|
export declare class Network extends ReadyResource {
|
|
73
|
-
identity: import("../index.js").Identity;
|
|
74
68
|
bootstrap: {
|
|
75
69
|
host: string;
|
|
76
70
|
port: number;
|
|
@@ -101,7 +95,7 @@ export declare class Network extends ReadyResource {
|
|
|
101
95
|
/** @private */
|
|
102
96
|
_onerror;
|
|
103
97
|
/** @param {NetworkOpts} opts */
|
|
104
|
-
constructor({
|
|
98
|
+
constructor({ bootstrap, firewall, relayThrough, backoffs, channel, store, mirrors, presence, onerror }?: NetworkOpts);
|
|
105
99
|
/** @returns {import('hyperswarm') | null} The underlying hyperswarm, or null before ready / after close. */
|
|
106
100
|
get swarm(): import('hyperswarm') | null;
|
|
107
101
|
/** @returns {Map<string, object>} Known peers keyed by public-key string. */
|
package/types/pairing/index.d.ts
CHANGED
|
@@ -42,6 +42,10 @@ export type AcceptOpts = {
|
|
|
42
42
|
* Role granted: the invite's by default, at most the invite's.
|
|
43
43
|
*/
|
|
44
44
|
role?: string;
|
|
45
|
+
/**
|
|
46
|
+
* The joiner's chain to your identity, from `identity.link`: it joins as a device of yours, not as a member.
|
|
47
|
+
*/
|
|
48
|
+
proof?: Uint8Array | null;
|
|
45
49
|
};
|
|
46
50
|
export type JoinOpts = {
|
|
47
51
|
/**
|
|
@@ -89,6 +93,10 @@ export type JoinResult = {
|
|
|
89
93
|
* The writer the join admitted: open the database with it.
|
|
90
94
|
*/
|
|
91
95
|
writer: KeyPair;
|
|
96
|
+
/**
|
|
97
|
+
* A device's chain to the identity it was linked under, null for a member.
|
|
98
|
+
*/
|
|
99
|
+
proof: Uint8Array | null;
|
|
92
100
|
};
|
|
93
101
|
/**
|
|
94
102
|
* @typedef {{ publicKey: Uint8Array, secretKey: Uint8Array }} KeyPair
|
|
@@ -106,6 +114,7 @@ export type JoinResult = {
|
|
|
106
114
|
*
|
|
107
115
|
* @typedef {object} AcceptOpts
|
|
108
116
|
* @property {string} [role] Role granted: the invite's by default, at most the invite's.
|
|
117
|
+
* @property {Uint8Array | null} [proof] The joiner's chain to your identity, from `identity.link`: it joins as a device of yours, not as a member.
|
|
109
118
|
*
|
|
110
119
|
* @typedef {object} JoinOpts
|
|
111
120
|
* @property {import('../identity/index.js').Identity} identity Who joins: the member they become, and who signs the join.
|
|
@@ -120,6 +129,7 @@ export type JoinResult = {
|
|
|
120
129
|
* @property {Uint8Array | null} encryptionKey
|
|
121
130
|
* @property {Array<{ epoch: number, stamp: number, entropy: Uint8Array }>} epochs
|
|
122
131
|
* @property {KeyPair} writer The writer the join admitted: open the database with it.
|
|
132
|
+
* @property {Uint8Array | null} proof A device's chain to the identity it was linked under, null for a member.
|
|
123
133
|
*/
|
|
124
134
|
/**
|
|
125
135
|
* Invites into a database. An invite is a record in the database; a joiner writes one signed
|
|
@@ -172,7 +182,7 @@ export declare class Pairing extends ReadyResource {
|
|
|
172
182
|
* @param {AcceptOpts} [opts]
|
|
173
183
|
* @returns {Promise<void>}
|
|
174
184
|
*/
|
|
175
|
-
accept(id: string, { role }?: AcceptOpts): Promise<void>;
|
|
185
|
+
accept(id: string, { role, proof }?: AcceptOpts): Promise<void>;
|
|
176
186
|
/**
|
|
177
187
|
* Refuse a join waiting on a `confirm` invite, by its id in `requests`, with an optional reason.
|
|
178
188
|
*
|
|
@@ -212,7 +222,8 @@ export declare class Pairing extends ReadyResource {
|
|
|
212
222
|
}
|
|
213
223
|
/**
|
|
214
224
|
* A join's payload: sealed to the database's address, so only its members read who joins; proven
|
|
215
|
-
* by the invite over the writer; signed by the joiner's
|
|
225
|
+
* by the invite over the writer; signed by the joiner's device, under its chain to the identity,
|
|
226
|
+
* for this writer and reply address.
|
|
216
227
|
*
|
|
217
228
|
* @param {Invite} invite
|
|
218
229
|
* @param {import('../identity/index.js').Identity} identity
|
package/types/push/index.d.ts
CHANGED
|
@@ -5,10 +5,11 @@ export type Handle = {
|
|
|
5
5
|
export type Hit = Handle & {
|
|
6
6
|
length: number;
|
|
7
7
|
newer: boolean;
|
|
8
|
+
ref: string | null;
|
|
8
9
|
};
|
|
9
10
|
/**
|
|
10
11
|
* @typedef {{ id: string, key: Uint8Array }} Handle A handle this device holds: its id and its database key.
|
|
11
|
-
* @typedef {Handle & { length: number, newer: boolean }} Hit The handle a push is about, the length it proves,
|
|
12
|
+
* @typedef {Handle & { length: number, newer: boolean, ref: string | null }} Hit The handle a push is about, the length it proves, whether this device is behind it, and the ref the write was on.
|
|
12
13
|
*/
|
|
13
14
|
/**
|
|
14
15
|
* Verify a push payload against this device's storage: the one the gateway sent, decoded from the
|
|
@@ -19,4 +20,4 @@ export type Hit = Handle & {
|
|
|
19
20
|
* @param {Handle[]} handles
|
|
20
21
|
* @returns {Promise<Hit | null>}
|
|
21
22
|
*/
|
|
22
|
-
export declare function
|
|
23
|
+
export declare function verify(storage: import('hypercore-storage'), payload: Uint8Array, handles: Handle[]): Promise<Hit | null>;
|