@weaveprotocol/core 0.1.2 → 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/README.md +244 -39
- package/dist/identity/contact-key.d.ts +42 -0
- package/dist/identity/contact-key.d.ts.map +1 -0
- package/dist/identity/contact-key.js +133 -0
- package/dist/identity/contact-key.js.map +1 -0
- package/dist/index.d.ts +16 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -5
- package/dist/index.js.map +1 -1
- package/dist/network/mesh.d.ts +6 -0
- package/dist/network/mesh.d.ts.map +1 -1
- package/dist/network/mesh.js +11 -1
- package/dist/network/mesh.js.map +1 -1
- package/dist/network/multi-signaling.d.ts +12 -2
- package/dist/network/multi-signaling.d.ts.map +1 -1
- package/dist/network/multi-signaling.js +86 -14
- package/dist/network/multi-signaling.js.map +1 -1
- package/dist/network/peer-auth.d.ts +50 -16
- package/dist/network/peer-auth.d.ts.map +1 -1
- package/dist/network/peer-auth.js +52 -15
- package/dist/network/peer-auth.js.map +1 -1
- package/dist/node/carrier.d.ts +87 -0
- package/dist/node/carrier.d.ts.map +1 -1
- package/dist/node/carrier.js +180 -59
- package/dist/node/carrier.js.map +1 -1
- package/dist/node/copy.d.ts.map +1 -1
- package/dist/node/copy.js +6 -3
- package/dist/node/copy.js.map +1 -1
- package/dist/node/host.d.ts +117 -0
- package/dist/node/host.d.ts.map +1 -0
- package/dist/node/host.js +192 -0
- package/dist/node/host.js.map +1 -0
- package/dist/node/index.d.ts +6 -2
- package/dist/node/index.d.ts.map +1 -1
- package/dist/node/index.js +1 -0
- package/dist/node/index.js.map +1 -1
- package/dist/node/node.d.ts.map +1 -1
- package/dist/node/node.js +640 -25
- package/dist/node/node.js.map +1 -1
- package/dist/node/space-runtime.d.ts +42 -25
- package/dist/node/space-runtime.d.ts.map +1 -1
- package/dist/node/space-runtime.js +734 -35
- package/dist/node/space-runtime.js.map +1 -1
- package/dist/node/types.d.ts +269 -3
- package/dist/node/types.d.ts.map +1 -1
- package/dist/privacy/space-encryption.d.ts +16 -0
- package/dist/privacy/space-encryption.d.ts.map +1 -1
- package/dist/privacy/space-encryption.js +40 -0
- package/dist/privacy/space-encryption.js.map +1 -1
- package/dist/query/engine.js +1 -1
- package/dist/query/engine.js.map +1 -1
- package/dist/query/types.d.ts +7 -0
- package/dist/query/types.d.ts.map +1 -1
- package/dist/query/types.js.map +1 -1
- package/dist/react/use-query.d.ts +1 -1
- package/dist/react/use-query.d.ts.map +1 -1
- package/dist/records/topics.d.ts +21 -0
- package/dist/records/topics.d.ts.map +1 -0
- package/dist/records/topics.js +86 -0
- package/dist/records/topics.js.map +1 -0
- package/dist/schema/collection-def.d.ts +7 -0
- package/dist/schema/collection-def.d.ts.map +1 -1
- package/dist/schema/collection-def.js +4 -0
- package/dist/schema/collection-def.js.map +1 -1
- package/dist/schema/expression.d.ts +2 -0
- package/dist/schema/expression.d.ts.map +1 -1
- package/dist/schema/expression.js +1 -0
- package/dist/schema/expression.js.map +1 -1
- package/dist/schemas/contacts.d.ts +77 -0
- package/dist/schemas/contacts.d.ts.map +1 -0
- package/dist/schemas/contacts.js +35 -0
- package/dist/schemas/contacts.js.map +1 -0
- package/dist/schemas/index.d.ts +2 -0
- package/dist/schemas/index.d.ts.map +1 -1
- package/dist/schemas/index.js +1 -0
- package/dist/schemas/index.js.map +1 -1
- package/dist/session/auth.d.ts.map +1 -1
- package/dist/session/auth.js +14 -3
- package/dist/session/auth.js.map +1 -1
- package/dist/session/connect.d.ts +25 -1
- package/dist/session/connect.d.ts.map +1 -1
- package/dist/session/connect.js +9 -2
- package/dist/session/connect.js.map +1 -1
- package/dist/session/hosting.d.ts +155 -0
- package/dist/session/hosting.d.ts.map +1 -0
- package/dist/session/hosting.js +160 -0
- package/dist/session/hosting.js.map +1 -0
- package/dist/space/account-registry.d.ts +6 -0
- package/dist/space/account-registry.d.ts.map +1 -1
- package/dist/space/account-registry.js +16 -4
- package/dist/space/account-registry.js.map +1 -1
- package/dist/space/notify.d.ts +88 -0
- package/dist/space/notify.d.ts.map +1 -0
- package/dist/space/notify.js +127 -0
- package/dist/space/notify.js.map +1 -0
- package/dist/space/pass.d.ts +6 -0
- package/dist/space/pass.d.ts.map +1 -1
- package/dist/space/pass.js +5 -2
- package/dist/space/pass.js.map +1 -1
- package/dist/space/roles.d.ts +71 -0
- package/dist/space/roles.d.ts.map +1 -1
- package/dist/space/roles.js +114 -0
- package/dist/space/roles.js.map +1 -1
- package/dist/space/space-access.d.ts +24 -0
- package/dist/space/space-access.d.ts.map +1 -1
- package/dist/space/space-access.js +24 -0
- package/dist/space/space-access.js.map +1 -1
- package/dist/space/space-manager.d.ts +35 -1
- package/dist/space/space-manager.d.ts.map +1 -1
- package/dist/space/space-manager.js +72 -25
- package/dist/space/space-manager.js.map +1 -1
- package/dist/storage/blob/memory.d.ts +9 -0
- package/dist/storage/blob/memory.d.ts.map +1 -0
- package/dist/storage/blob/memory.js +20 -0
- package/dist/storage/blob/memory.js.map +1 -0
- package/dist/storage/blob/s3.d.ts +16 -0
- package/dist/storage/blob/s3.d.ts.map +1 -0
- package/dist/storage/blob/s3.js +86 -0
- package/dist/storage/blob/s3.js.map +1 -0
- package/dist/storage/blob-store.d.ts +26 -0
- package/dist/storage/blob-store.d.ts.map +1 -0
- package/dist/storage/blob-store.js +2 -0
- package/dist/storage/blob-store.js.map +1 -0
- package/dist/storage/encrypted-adapter.d.ts +3 -3
- package/dist/storage/encrypted-adapter.js +3 -3
- package/dist/storage/folder-adapter.d.ts +8 -8
- package/dist/storage/folder-adapter.d.ts.map +1 -1
- package/dist/storage/folder-adapter.js +7 -7
- package/dist/storage/folder-reconcile.d.ts +12 -14
- package/dist/storage/folder-reconcile.d.ts.map +1 -1
- package/dist/storage/folder-reconcile.js +20 -14
- package/dist/storage/folder-reconcile.js.map +1 -1
- package/dist/storage/index.d.ts +0 -1
- package/dist/storage/index.d.ts.map +1 -1
- package/dist/storage/index.js +0 -1
- package/dist/storage/index.js.map +1 -1
- package/dist/storage/indexeddb-adapter.d.ts.map +1 -1
- package/dist/storage/indexeddb-adapter.js +8 -9
- package/dist/storage/indexeddb-adapter.js.map +1 -1
- package/dist/storage/mirror.d.ts +68 -0
- package/dist/storage/mirror.d.ts.map +1 -0
- package/dist/storage/mirror.js +174 -0
- package/dist/storage/mirror.js.map +1 -0
- package/dist/storage/segment.d.ts +20 -0
- package/dist/storage/segment.d.ts.map +1 -0
- package/dist/storage/segment.js +27 -0
- package/dist/storage/segment.js.map +1 -0
- package/dist/storage/storage-provider.d.ts +36 -40
- package/dist/storage/storage-provider.d.ts.map +1 -1
- package/dist/storage/storage-provider.js +208 -117
- package/dist/storage/storage-provider.js.map +1 -1
- package/dist/sync/index.d.ts +1 -1
- package/dist/sync/index.d.ts.map +1 -1
- package/dist/sync/index.js +1 -1
- package/dist/sync/index.js.map +1 -1
- package/dist/sync/negentropy.d.ts +68 -0
- package/dist/sync/negentropy.d.ts.map +1 -0
- package/dist/sync/negentropy.js +379 -0
- package/dist/sync/negentropy.js.map +1 -0
- package/dist/sync/sync-engine.d.ts +45 -13
- package/dist/sync/sync-engine.d.ts.map +1 -1
- package/dist/sync/sync-engine.js +290 -207
- package/dist/sync/sync-engine.js.map +1 -1
- package/dist/sync/sync-messages.d.ts +42 -32
- package/dist/sync/sync-messages.d.ts.map +1 -1
- package/dist/sync/sync-messages.js +1 -1
- package/dist/sync/sync-messages.js.map +1 -1
- package/dist/types.d.ts +9 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/utils/hash.d.ts +9 -0
- package/dist/utils/hash.d.ts.map +1 -1
- package/dist/utils/hash.js +33 -0
- package/dist/utils/hash.js.map +1 -1
- package/package.json +3 -2
- package/dist/storage/mst.d.ts +0 -121
- package/dist/storage/mst.d.ts.map +0 -1
- package/dist/storage/mst.js +0 -402
- package/dist/storage/mst.js.map +0 -1
- package/dist/sync/anti-entropy.d.ts +0 -49
- package/dist/sync/anti-entropy.d.ts.map +0 -1
- package/dist/sync/anti-entropy.js +0 -62
- package/dist/sync/anti-entropy.js.map +0 -1
|
@@ -24,6 +24,16 @@
|
|
|
24
24
|
* it, and a host that cannot read the space checks readers exactly as a
|
|
25
25
|
* member's own node does.
|
|
26
26
|
*
|
|
27
|
+
* **A private space's key changes** when someone is removed (`sys.key`), and
|
|
28
|
+
* with it the read key. A reader proves the one the space names now. One
|
|
29
|
+
* that was offline when it changed still holds only an older one: it proves
|
|
30
|
+
* that, and sends its note — the delegation from its account — sealed with
|
|
31
|
+
* the older space key, so only those who could read the space then can open
|
|
32
|
+
* it. A peer holding that key opens the note and lets it in if its account is
|
|
33
|
+
* still a member. Someone removed holds the older key too, but is no member.
|
|
34
|
+
* A peer without any key of the space's (a host) takes the current read key
|
|
35
|
+
* only.
|
|
36
|
+
*
|
|
27
37
|
* The node signs with **its own key**, the one its DID names. That proves the
|
|
28
38
|
* welcome comes from the node that sent the challenge; which node to trust is
|
|
29
39
|
* the client's choice of URL. Naming the node in the client's signature keeps
|
|
@@ -34,7 +44,39 @@ import type { CryptoProvider } from '../types.js';
|
|
|
34
44
|
export interface HelloProof {
|
|
35
45
|
readonly sig: string;
|
|
36
46
|
readonly read?: string;
|
|
47
|
+
/** The read key that signed `read`, when it is not the one the space names now */
|
|
48
|
+
readonly readKey?: string;
|
|
49
|
+
/** Its note, sealed with the space key behind `readKey` — for a reader that may be behind */
|
|
50
|
+
readonly member?: string;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Who may read a private space, as one side of a connection knows it — asked
|
|
54
|
+
* at every handshake, since the space's key can change while it is open.
|
|
55
|
+
*/
|
|
56
|
+
export interface ReadAccess {
|
|
57
|
+
/** The read key this side proves with, or null when it holds none */
|
|
58
|
+
key(): Promise<{
|
|
59
|
+
readonly did: string;
|
|
60
|
+
readonly privateKey: CryptoKey;
|
|
61
|
+
} | null>;
|
|
62
|
+
/** The read key every reader must prove, as the space names it now */
|
|
63
|
+
current(): string;
|
|
64
|
+
/**
|
|
65
|
+
* This side's note, sealed with the space key behind the read key it
|
|
66
|
+
* proves with — sent along when that may not be the current one.
|
|
67
|
+
*/
|
|
68
|
+
membership?(): Promise<string | null>;
|
|
69
|
+
/** Whether a peer proving an older read key, with this sealed note, is still a member */
|
|
70
|
+
admits?(peerDid: string, readKey: string, membership: unknown): Promise<boolean>;
|
|
37
71
|
}
|
|
72
|
+
/** What a caller may pass for a space's read access: the full thing, or a fixed key pair and the public half it must match */
|
|
73
|
+
export type ReadAccessInput = ReadAccess | {
|
|
74
|
+
readonly key: {
|
|
75
|
+
readonly privateKey: CryptoKey;
|
|
76
|
+
readonly did?: string;
|
|
77
|
+
} | null;
|
|
78
|
+
readonly publicDid: string;
|
|
79
|
+
};
|
|
38
80
|
/** The connecting side: proves who it is and that it may read, and checks the node's welcome. */
|
|
39
81
|
export interface ClientAuth {
|
|
40
82
|
hello(clientDid: string, nodeDid: string, nodeNonce: string): Promise<HelloProof>;
|
|
@@ -51,30 +93,27 @@ export declare function peerNonce(): string;
|
|
|
51
93
|
* The client side.
|
|
52
94
|
* @param spaceId The space — bound into every signature, so a proof for one space is useless in another
|
|
53
95
|
* @param session This side's DID and the key it names
|
|
54
|
-
* @param
|
|
96
|
+
* @param read In a private space, how this side proves it may read — or just the read key (`deriveReadKey`); null in a public one
|
|
55
97
|
*/
|
|
56
98
|
export declare function createClientAuth(spaceId: string, session: {
|
|
57
99
|
readonly did: string;
|
|
58
100
|
readonly key: CryptoKey;
|
|
59
|
-
},
|
|
101
|
+
}, read: ReadAccess | {
|
|
60
102
|
readonly privateKey: CryptoKey;
|
|
61
103
|
} | null, provider: CryptoProvider): ClientAuth;
|
|
62
104
|
/**
|
|
63
|
-
* The node side.
|
|
64
|
-
* @param
|
|
105
|
+
* The node side. Needs no secret of the space's.
|
|
106
|
+
* @param read In a private space, who may read it — or just its public read key; null in a public one
|
|
65
107
|
* @param nodeKey The private key of the DID the node introduces itself as
|
|
66
108
|
*/
|
|
67
|
-
export declare function createServerAuth(spaceId: string,
|
|
109
|
+
export declare function createServerAuth(spaceId: string, read: ReadAccess | string | null, nodeKey: CryptoKey, provider: CryptoProvider): ServerAuth;
|
|
68
110
|
/** The fingerprints of one connection's two ends, as this side sees them */
|
|
69
111
|
export interface ChannelBinding {
|
|
70
112
|
readonly local: string;
|
|
71
113
|
readonly remote: string;
|
|
72
114
|
}
|
|
73
|
-
/** What one side sends to prove itself */
|
|
74
|
-
export
|
|
75
|
-
readonly sig: string;
|
|
76
|
-
readonly read?: string;
|
|
77
|
-
}
|
|
115
|
+
/** What one side sends to prove itself — as a client's hello */
|
|
116
|
+
export type MeshProof = HelloProof;
|
|
78
117
|
/** Proving who you are to a peer — and, in a private space, that you may read it. */
|
|
79
118
|
export interface MeshAuth {
|
|
80
119
|
prove(peerDid: string, peerNonce: string, binding: ChannelBinding | null): Promise<MeshProof>;
|
|
@@ -89,10 +128,5 @@ export interface MeshAuth {
|
|
|
89
128
|
export declare function createMeshAuth(spaceId: string, session: {
|
|
90
129
|
readonly did: string;
|
|
91
130
|
readonly key: CryptoKey;
|
|
92
|
-
}, read:
|
|
93
|
-
readonly key: {
|
|
94
|
-
readonly privateKey: CryptoKey;
|
|
95
|
-
} | null;
|
|
96
|
-
readonly publicDid: string;
|
|
97
|
-
} | null, provider: CryptoProvider): MeshAuth;
|
|
131
|
+
}, read: ReadAccessInput | null, provider: CryptoProvider): MeshAuth;
|
|
98
132
|
//# sourceMappingURL=peer-auth.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"peer-auth.d.ts","sourceRoot":"","sources":["../../src/network/peer-auth.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"peer-auth.d.ts","sourceRoot":"","sources":["../../src/network/peer-auth.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AACH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AA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CAAC;IAC9F,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,cAAc,GAAG,IAAI,EAAE,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CAC5G;AAKD;;;;;GAKG;AACH,wBAAgB,cAAc,CAC5B,OAAO,EAAE,MAAM,EACf,OAAO,EAAE;IAAE,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,GAAG,EAAE,SAAS,CAAA;CAAE,EAC1D,IAAI,EAAE,eAAe,GAAG,IAAI,EAC5B,QAAQ,EAAE,cAAc,GACvB,QAAQ,CAoBV"}
|
|
@@ -1,5 +1,34 @@
|
|
|
1
1
|
import { base64UrlDecode, base64UrlEncode, utf8Encode } from '../utils/encoding.js';
|
|
2
2
|
import { didToPublicKey } from '../identity/did.js';
|
|
3
|
+
function readAccessOf(read) {
|
|
4
|
+
if (!read)
|
|
5
|
+
return null;
|
|
6
|
+
if ('current' in read)
|
|
7
|
+
return read;
|
|
8
|
+
const { key, publicDid } = read;
|
|
9
|
+
return { key: async () => (key ? { did: key.did ?? publicDid, privateKey: key.privateKey } : null), current: () => publicDid };
|
|
10
|
+
}
|
|
11
|
+
/** Signs `label` as a reader: with the read key, saying which one when it is not the current one, and the sealed note then */
|
|
12
|
+
async function proveRead(access, label, provider) {
|
|
13
|
+
const key = await access.key();
|
|
14
|
+
if (!key)
|
|
15
|
+
return null;
|
|
16
|
+
const read = base64UrlEncode(await provider.sign(key.privateKey, label));
|
|
17
|
+
if (key.did === access.current())
|
|
18
|
+
return { read };
|
|
19
|
+
const member = (await access.membership?.()) ?? null;
|
|
20
|
+
return { read, readKey: key.did, ...(member ? { member } : {}) };
|
|
21
|
+
}
|
|
22
|
+
/** Whether a proof shows a reader: the current read key, or an older one with a note from someone still a member */
|
|
23
|
+
async function checkRead(access, peerDid, label, proof, provider) {
|
|
24
|
+
const current = access.current();
|
|
25
|
+
const claimed = typeof proof.readKey === 'string' ? proof.readKey : current;
|
|
26
|
+
if (!claimed.startsWith('did:key:') || !(await verifyBy(provider, claimed, proof.read, label)))
|
|
27
|
+
return false;
|
|
28
|
+
if (claimed === current)
|
|
29
|
+
return true;
|
|
30
|
+
return access.admits ? access.admits(peerDid, claimed, proof.member) : false;
|
|
31
|
+
}
|
|
3
32
|
/** A fresh random nonce, as a string. */
|
|
4
33
|
export function peerNonce() {
|
|
5
34
|
return base64UrlEncode(globalThis.crypto.getRandomValues(new Uint8Array(16)));
|
|
@@ -21,14 +50,19 @@ async function verifyBy(provider, did, sig, data) {
|
|
|
21
50
|
* The client side.
|
|
22
51
|
* @param spaceId The space — bound into every signature, so a proof for one space is useless in another
|
|
23
52
|
* @param session This side's DID and the key it names
|
|
24
|
-
* @param
|
|
53
|
+
* @param read In a private space, how this side proves it may read — or just the read key (`deriveReadKey`); null in a public one
|
|
25
54
|
*/
|
|
26
|
-
export function createClientAuth(spaceId, session,
|
|
55
|
+
export function createClientAuth(spaceId, session, read, provider) {
|
|
56
|
+
// A bare key pair proves itself as whatever the node names now.
|
|
57
|
+
const access = !read ? null : 'current' in read ? read : { key: async () => ({ did: '', privateKey: read.privateKey }), current: () => '' };
|
|
27
58
|
return Object.freeze({
|
|
28
59
|
async hello(clientDid, nodeDid, nodeNonce) {
|
|
29
60
|
const label = helloLabel(spaceId, clientDid, nodeDid, nodeNonce);
|
|
30
61
|
const sig = base64UrlEncode(await provider.sign(session.key, label));
|
|
31
|
-
|
|
62
|
+
if (!access)
|
|
63
|
+
return { sig };
|
|
64
|
+
const proof = await proveRead(access, label, provider);
|
|
65
|
+
return proof ? { sig, ...proof } : { sig };
|
|
32
66
|
},
|
|
33
67
|
checkWelcome(nodeDid, clientNonce, sig) {
|
|
34
68
|
return verifyBy(provider, nodeDid, sig, welcomeLabel(spaceId, nodeDid, clientNonce));
|
|
@@ -36,18 +70,19 @@ export function createClientAuth(spaceId, session, readKey, provider) {
|
|
|
36
70
|
});
|
|
37
71
|
}
|
|
38
72
|
/**
|
|
39
|
-
* The node side.
|
|
40
|
-
* @param
|
|
73
|
+
* The node side. Needs no secret of the space's.
|
|
74
|
+
* @param read In a private space, who may read it — or just its public read key; null in a public one
|
|
41
75
|
* @param nodeKey The private key of the DID the node introduces itself as
|
|
42
76
|
*/
|
|
43
|
-
export function createServerAuth(spaceId,
|
|
77
|
+
export function createServerAuth(spaceId, read, nodeKey, provider) {
|
|
78
|
+
const access = read === null ? null : typeof read === 'string' ? { key: async () => null, current: () => read } : read;
|
|
44
79
|
return Object.freeze({
|
|
45
80
|
async checkHello(clientDid, nodeDid, nodeNonce, proof) {
|
|
46
|
-
const
|
|
81
|
+
const given = (proof ?? {});
|
|
47
82
|
const label = helloLabel(spaceId, clientDid, nodeDid, nodeNonce);
|
|
48
|
-
if (!clientDid.startsWith('did:key:') || !(await verifyBy(provider, clientDid, sig, label)))
|
|
83
|
+
if (!clientDid.startsWith('did:key:') || !(await verifyBy(provider, clientDid, given.sig, label)))
|
|
49
84
|
return false;
|
|
50
|
-
return
|
|
85
|
+
return access ? checkRead(access, clientDid, label, given, provider) : true;
|
|
51
86
|
},
|
|
52
87
|
async welcome(nodeDid, clientNonce) {
|
|
53
88
|
return base64UrlEncode(await provider.sign(nodeKey, welcomeLabel(spaceId, nodeDid, clientNonce)));
|
|
@@ -62,24 +97,26 @@ const meshLabel = (spaceId, prover, verifier, nonce, proverCert, verifierCert) =
|
|
|
62
97
|
* @param read In a private space: the read key to prove with, and the public half the space names to check others against
|
|
63
98
|
*/
|
|
64
99
|
export function createMeshAuth(spaceId, session, read, provider) {
|
|
100
|
+
const access = readAccessOf(read);
|
|
65
101
|
return Object.freeze({
|
|
66
102
|
async prove(peerDid, peerNonce, binding) {
|
|
67
103
|
const label = meshLabel(spaceId, session.did, peerDid, peerNonce, binding?.local ?? '', binding?.remote ?? '');
|
|
68
104
|
const sig = base64UrlEncode(await provider.sign(session.key, label));
|
|
69
|
-
if (!
|
|
105
|
+
if (!access)
|
|
70
106
|
return { sig };
|
|
107
|
+
const proof = await proveRead(access, label, provider);
|
|
71
108
|
// A node without the space's key cannot prove it may read — and should not be served.
|
|
72
|
-
if (!
|
|
109
|
+
if (!proof)
|
|
73
110
|
throw new Error('This node cannot read the space, so it cannot join its peers');
|
|
74
|
-
return { sig,
|
|
111
|
+
return { sig, ...proof };
|
|
75
112
|
},
|
|
76
113
|
async check(peerDid, ourNonce, binding, proof) {
|
|
77
|
-
const
|
|
114
|
+
const given = (proof ?? {});
|
|
78
115
|
// What they signed, seen from this end: their certificate is our remote one.
|
|
79
116
|
const label = meshLabel(spaceId, peerDid, session.did, ourNonce, binding?.remote ?? '', binding?.local ?? '');
|
|
80
|
-
if (!peerDid.startsWith('did:key:') || !(await verifyBy(provider, peerDid, sig, label)))
|
|
117
|
+
if (!peerDid.startsWith('did:key:') || !(await verifyBy(provider, peerDid, given.sig, label)))
|
|
81
118
|
return false;
|
|
82
|
-
return
|
|
119
|
+
return access ? checkRead(access, peerDid, label, given, provider) : true;
|
|
83
120
|
},
|
|
84
121
|
});
|
|
85
122
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"peer-auth.js","sourceRoot":"","sources":["../../src/network/peer-auth.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"peer-auth.js","sourceRoot":"","sources":["../../src/network/peer-auth.ts"],"names":[],"mappings":"AA0CA,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AACpF,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAmCpD,SAAS,YAAY,CAAC,IAA4B;IAChD,IAAI,CAAC,IAAI;QAAE,OAAO,IAAI,CAAC;IACvB,IAAI,SAAS,IAAI,IAAI;QAAE,OAAO,IAAI,CAAC;IACnC,MAAM,EAAE,GAAG,EAAE,SAAS,EAAE,GAAG,IAAI,CAAC;IAChC,OAAO,EAAE,GAAG,EAAE,KAAK,IAAI,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,EAAE,OAAO,CAAC,GAAG,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,IAAI,EAAE,EAAE,OAAO,EAAE,KAAK,IAAI,EAAE,CAAC,CAAC;YAC9G,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,MAAM,QAAQ,CAAC,QAAQ,EAAE,OAAO,EAAE,KAAK,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;gBAAE,OAAO,KAAK,CAAC;YAC5G,OAAO,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;QAC5E,CAAC;KACF,CAAC,CAAC;AACL,CAAC"}
|
package/dist/node/carrier.d.ts
CHANGED
|
@@ -22,7 +22,12 @@
|
|
|
22
22
|
* registry are never opened.
|
|
23
23
|
*/
|
|
24
24
|
import type { CryptoProvider } from '../types.js';
|
|
25
|
+
import { type SpaceRecord } from '../space/space-manager.js';
|
|
26
|
+
import { type CarriedSubscription } from '../space/notify.js';
|
|
27
|
+
import { type LocalHub } from '../network/local-transport.js';
|
|
28
|
+
import { type SpaceRuntime } from './space-runtime.js';
|
|
25
29
|
import type { StoreFactory } from './stores.js';
|
|
30
|
+
import type { BlobStore } from '../storage/blob-store.js';
|
|
26
31
|
import type { ConnectionState, NodeNetworkConfig } from './types.js';
|
|
27
32
|
export interface CarrierConfig {
|
|
28
33
|
/** Its own key — who it is to peers. Never the account's. */
|
|
@@ -63,7 +68,34 @@ export type CarrierEvent =
|
|
|
63
68
|
/** The account stopped using this carrier: forget everything */
|
|
64
69
|
| {
|
|
65
70
|
readonly type: 'closed';
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* A record arrived that one of the account's subscriptions asks about. Only
|
|
74
|
+
* what the carrier can see: which subscription, which space, which record.
|
|
75
|
+
*/
|
|
76
|
+
| {
|
|
77
|
+
readonly type: 'notify';
|
|
78
|
+
readonly subscription: CarriedSubscriptionView;
|
|
79
|
+
readonly space: {
|
|
80
|
+
readonly id: string;
|
|
81
|
+
readonly name: string;
|
|
82
|
+
};
|
|
83
|
+
readonly record: {
|
|
84
|
+
readonly key: string;
|
|
85
|
+
readonly collection: string;
|
|
86
|
+
readonly createdAt: string;
|
|
87
|
+
};
|
|
66
88
|
};
|
|
89
|
+
/** A subscription as the carrier holds it: the person's label, what it looks at, where a click goes */
|
|
90
|
+
export interface CarriedSubscriptionView {
|
|
91
|
+
readonly id: string;
|
|
92
|
+
readonly label: string;
|
|
93
|
+
readonly collection: string;
|
|
94
|
+
/** The spaces it looks at, by name; empty for every space */
|
|
95
|
+
readonly spaces: ReadonlyArray<string>;
|
|
96
|
+
readonly open?: string;
|
|
97
|
+
readonly paused: boolean;
|
|
98
|
+
}
|
|
67
99
|
export interface CarrierNode {
|
|
68
100
|
readonly did: string;
|
|
69
101
|
/** The carry space's id */
|
|
@@ -74,12 +106,67 @@ export interface CarrierNode {
|
|
|
74
106
|
* data path in it. Null stops writing there; the carrier's own copy goes on.
|
|
75
107
|
*/
|
|
76
108
|
usePod(stores: StoreFactory | null): Promise<void>;
|
|
109
|
+
/** The account's subscriptions, as this carrier holds them */
|
|
110
|
+
subscriptions(): Promise<ReadonlyArray<CarriedSubscriptionView>>;
|
|
77
111
|
subscribe(listener: (event: CarrierEvent) => void): () => void;
|
|
78
112
|
close(): Promise<void>;
|
|
79
113
|
}
|
|
114
|
+
interface Carried {
|
|
115
|
+
readonly record: SpaceRecord;
|
|
116
|
+
readonly hub: LocalHub;
|
|
117
|
+
readonly runtime: SpaceRuntime;
|
|
118
|
+
pod: Promise<SpaceRuntime> | null;
|
|
119
|
+
}
|
|
120
|
+
/** An account's carry space, as a carrying node holds it */
|
|
121
|
+
interface Carry {
|
|
122
|
+
readonly account: string;
|
|
123
|
+
/** The spaces its passes named last time they were read */
|
|
124
|
+
wants: ReadonlySet<string>;
|
|
125
|
+
/** Its subscriptions, by key, as last read */
|
|
126
|
+
subscriptions: ReadonlyMap<string, CarriedSubscription>;
|
|
127
|
+
}
|
|
128
|
+
export interface CarryCoreConfig {
|
|
129
|
+
readonly key: CryptoKeyPair;
|
|
130
|
+
readonly stores: StoreFactory;
|
|
131
|
+
readonly network?: NodeNetworkConfig;
|
|
132
|
+
readonly provider?: CryptoProvider;
|
|
133
|
+
readonly watchIntervalMs?: number;
|
|
134
|
+
readonly emit: (event: CarrierEvent) => void;
|
|
135
|
+
/** An account wrote `carry:closed` into its carry space: it stopped using this node */
|
|
136
|
+
readonly onClosed: (carrySpace: string) => void;
|
|
137
|
+
/** A file store every carried space is also kept in — a host's bucket */
|
|
138
|
+
readonly mirror?: BlobStore;
|
|
139
|
+
/** A space nobody asks for any more was let go — not one opened again after a key change */
|
|
140
|
+
readonly onRelease?: (spaceId: string) => Promise<void>;
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* What a carrier and a host share: carry spaces — one per account it carries
|
|
144
|
+
* for — and every space their passes name, each held once however many
|
|
145
|
+
* accounts ask for it.
|
|
146
|
+
*/
|
|
147
|
+
export declare function createCarryCore(config: CarryCoreConfig): Promise<{
|
|
148
|
+
did: string;
|
|
149
|
+
podDid: string;
|
|
150
|
+
carried: ReadonlyMap<string, Carried>;
|
|
151
|
+
carries: ReadonlyMap<string, Carry>;
|
|
152
|
+
/**
|
|
153
|
+
* Starts carrying for an account: joins its carry space and every space
|
|
154
|
+
* its passes name.
|
|
155
|
+
* @returns The carry space's id
|
|
156
|
+
* @throws When the invite is not a readable invite to a private space
|
|
157
|
+
*/
|
|
158
|
+
addCarry(account: string, invite: string): Promise<string>;
|
|
159
|
+
/** Stops carrying for an account: its carry space, and every space nobody else still asks for */
|
|
160
|
+
removeCarry(carrySpace: string): Promise<void>;
|
|
161
|
+
setPod(stores: StoreFactory | null): Promise<void>;
|
|
162
|
+
subscriptions(): Promise<ReadonlyArray<CarriedSubscriptionView>>;
|
|
163
|
+
spaces(): Promise<ReadonlyArray<CarriedSpace>>;
|
|
164
|
+
close(): Promise<void>;
|
|
165
|
+
}>;
|
|
80
166
|
/**
|
|
81
167
|
* Starts a carrier.
|
|
82
168
|
* @throws When the carry invite is not a readable invite to a private space
|
|
83
169
|
*/
|
|
84
170
|
export declare function createCarrierNode(config: CarrierConfig): Promise<CarrierNode>;
|
|
171
|
+
export {};
|
|
85
172
|
//# sourceMappingURL=carrier.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"carrier.d.ts","sourceRoot":"","sources":["../../src/node/carrier.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"carrier.d.ts","sourceRoot":"","sources":["../../src/node/carrier.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAKlD,OAAO,EAAwC,KAAK,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAEnG,OAAO,EAA6D,KAAK,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAEzH,OAAO,EAAkB,KAAK,QAAQ,EAAE,MAAM,+BAA+B,CAAC;AAC9E,OAAO,EAA6B,KAAK,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,KAAK,EAAE,eAAe,EAAa,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAEhF,MAAM,WAAW,aAAa;IAC5B,6DAA6D;IAC7D,QAAQ,CAAC,GAAG,EAAE,aAAa,CAAC;IAC5B,sEAAsE;IACtE,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,8CAA8C;IAC9C,QAAQ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