@dxos/echo-pipeline 0.6.5 → 0.6.6-main.e1a6e1f
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/browser/{chunk-2MII6KJX.mjs → chunk-LNIQX6PQ.mjs} +2132 -2119
- package/dist/lib/browser/chunk-LNIQX6PQ.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +1 -1
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/testing/index.mjs +1 -1
- package/dist/lib/node/{chunk-6MWU4MHX.cjs → chunk-LTR534RP.cjs} +2125 -2112
- package/dist/lib/node/chunk-LTR534RP.cjs.map +7 -0
- package/dist/lib/node/index.cjs +35 -35
- package/dist/lib/node/index.cjs.map +1 -1
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/testing/index.cjs +11 -11
- package/dist/types/src/automerge/echo-network-adapter.d.ts.map +1 -1
- package/dist/types/src/automerge/echo-replicator.d.ts +5 -1
- package/dist/types/src/automerge/echo-replicator.d.ts.map +1 -1
- package/dist/types/src/automerge/network-protocol.d.ts +3 -28
- package/dist/types/src/automerge/network-protocol.d.ts.map +1 -1
- package/dist/types/src/space/space-manager.d.ts +3 -1
- package/dist/types/src/space/space-manager.d.ts.map +1 -1
- package/dist/types/src/space/space-protocol.d.ts +10 -3
- package/dist/types/src/space/space-protocol.d.ts.map +1 -1
- package/dist/types/src/space/space.d.ts.map +1 -1
- package/package.json +33 -33
- package/src/automerge/echo-network-adapter.ts +5 -0
- package/src/automerge/echo-replicator.ts +5 -1
- package/src/automerge/network-protocol.ts +8 -34
- package/src/space/space-manager.ts +15 -2
- package/src/space/space-protocol.ts +42 -5
- package/src/space/space.ts +4 -4
- package/dist/lib/browser/chunk-2MII6KJX.mjs.map +0 -7
- package/dist/lib/node/chunk-6MWU4MHX.cjs.map +0 -7
|
@@ -7,6 +7,7 @@ import type { FeedMessage } from '@dxos/protocols/proto/dxos/echo/feed';
|
|
|
7
7
|
import { type MuxerStats, Teleport } from '@dxos/teleport';
|
|
8
8
|
import { type BlobStore, BlobSync } from '@dxos/teleport-extension-object-sync';
|
|
9
9
|
import { ReplicatorExtension } from '@dxos/teleport-extension-replicator';
|
|
10
|
+
import { CallbackCollection, type AsyncCallback } from '@dxos/util';
|
|
10
11
|
import { type AuthProvider, type AuthVerifier } from './auth';
|
|
11
12
|
export declare const MOCK_AUTH_PROVIDER: AuthProvider;
|
|
12
13
|
export declare const MOCK_AUTH_VERIFIER: AuthVerifier;
|
|
@@ -20,12 +21,14 @@ export type SpaceProtocolOptions = {
|
|
|
20
21
|
swarmIdentity: SwarmIdentity;
|
|
21
22
|
networkManager: SwarmNetworkManager;
|
|
22
23
|
blobStore: BlobStore;
|
|
24
|
+
onFeed?: (feed: FeedWrapper<FeedMessage>) => Promise<void>;
|
|
23
25
|
/**
|
|
24
26
|
* Called when new session is authenticated.
|
|
25
27
|
* Additional extensions can be added here.
|
|
26
28
|
*/
|
|
27
29
|
onSessionAuth?: (session: Teleport) => void;
|
|
28
30
|
onAuthFailure?: (session: Teleport) => void;
|
|
31
|
+
disableP2pReplication?: boolean;
|
|
29
32
|
};
|
|
30
33
|
/**
|
|
31
34
|
* Manages Teleport protocol stream creation and joining swarms with replication and presence extensions.
|
|
@@ -36,17 +39,19 @@ export declare class SpaceProtocol {
|
|
|
36
39
|
private readonly _onSessionAuth?;
|
|
37
40
|
private readonly _onAuthFailure?;
|
|
38
41
|
readonly blobSync: BlobSync;
|
|
42
|
+
private readonly _disableP2pReplication;
|
|
39
43
|
private readonly _topic;
|
|
40
44
|
private readonly _spaceKey;
|
|
41
45
|
private readonly _feeds;
|
|
42
46
|
private readonly _sessions;
|
|
43
47
|
private readonly _topology;
|
|
44
48
|
private _connection?;
|
|
49
|
+
readonly feedAdded: CallbackCollection<AsyncCallback<FeedWrapper<FeedMessage>>>;
|
|
45
50
|
get sessions(): ReadonlyMap<PublicKey, SpaceProtocolSession>;
|
|
46
51
|
get feeds(): ReadonlySet<FeedWrapper<FeedMessage>>;
|
|
47
52
|
private get _ownPeerKey();
|
|
48
|
-
constructor({ topic, swarmIdentity, networkManager, onSessionAuth, onAuthFailure, blobStore }: SpaceProtocolOptions);
|
|
49
|
-
addFeed(feed: FeedWrapper<FeedMessage>): void
|
|
53
|
+
constructor({ topic, swarmIdentity, networkManager, onSessionAuth, onAuthFailure, blobStore, disableP2pReplication, }: SpaceProtocolOptions);
|
|
54
|
+
addFeed(feed: FeedWrapper<FeedMessage>): Promise<void>;
|
|
50
55
|
start(): Promise<void>;
|
|
51
56
|
updateTopology(): void;
|
|
52
57
|
stop(): Promise<void>;
|
|
@@ -62,6 +67,7 @@ export type SpaceProtocolSessionParams = {
|
|
|
62
67
|
*/
|
|
63
68
|
onSessionAuth?: (session: Teleport) => void;
|
|
64
69
|
onAuthFailure?: (session: Teleport) => void;
|
|
70
|
+
disableP2pReplication?: boolean;
|
|
65
71
|
};
|
|
66
72
|
export declare enum AuthStatus {
|
|
67
73
|
INITIAL = "INITIAL",
|
|
@@ -73,6 +79,7 @@ export declare enum AuthStatus {
|
|
|
73
79
|
*/
|
|
74
80
|
export declare class SpaceProtocolSession implements WireProtocol {
|
|
75
81
|
private readonly _wireParams;
|
|
82
|
+
private readonly _disableP2pReplication;
|
|
76
83
|
private readonly _onSessionAuth?;
|
|
77
84
|
private readonly _onAuthFailure?;
|
|
78
85
|
private readonly _swarmIdentity;
|
|
@@ -82,7 +89,7 @@ export declare class SpaceProtocolSession implements WireProtocol {
|
|
|
82
89
|
private _authStatus;
|
|
83
90
|
get authStatus(): AuthStatus;
|
|
84
91
|
get stats(): Event<MuxerStats>;
|
|
85
|
-
constructor({ wireParams, swarmIdentity, onSessionAuth, onAuthFailure, blobSync }: SpaceProtocolSessionParams);
|
|
92
|
+
constructor({ wireParams, swarmIdentity, onSessionAuth, onAuthFailure, blobSync, disableP2pReplication, }: SpaceProtocolSessionParams);
|
|
86
93
|
get stream(): import("stream").Duplex;
|
|
87
94
|
open(sessionId?: PublicKey): Promise<void>;
|
|
88
95
|
close(): Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"space-protocol.d.ts","sourceRoot":"","sources":["../../../../src/space/space-protocol.ts"],"names":[],"mappings":";AAIA,OAAO,EAAE,KAAK,KAAK,EAAE,MAAM,aAAa,CAAC;AAEzC,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAEvC,OAAO,EAEL,KAAK,mBAAmB,EAExB,KAAK,YAAY,EACjB,KAAK,kBAAkB,EAExB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sCAAsC,CAAC;AACxE,OAAO,EAAE,KAAK,UAAU,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC3D,OAAO,EAAE,KAAK,SAAS,EAAE,QAAQ,EAAE,MAAM,sCAAsC,CAAC;AAChF,OAAO,EAAE,mBAAmB,EAAE,MAAM,qCAAqC,CAAC;
|
|
1
|
+
{"version":3,"file":"space-protocol.d.ts","sourceRoot":"","sources":["../../../../src/space/space-protocol.ts"],"names":[],"mappings":";AAIA,OAAO,EAAE,KAAK,KAAK,EAAE,MAAM,aAAa,CAAC;AAEzC,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAEvC,OAAO,EAEL,KAAK,mBAAmB,EAExB,KAAK,YAAY,EACjB,KAAK,kBAAkB,EAExB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sCAAsC,CAAC;AACxE,OAAO,EAAE,KAAK,UAAU,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC3D,OAAO,EAAE,KAAK,SAAS,EAAE,QAAQ,EAAE,MAAM,sCAAsC,CAAC;AAChF,OAAO,EAAE,m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AC,CAA8B;IAC9D,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAC,CAA8B;IAC9D,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAgB;IAC/C,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAW;IAErC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAW;IAGrC,SAAgB,UAAU,sBAA0D;IAEpF,OAAO,CAAC,WAAW,CAAsB;IAEzC,IACI,UAAU,eAEb;IAED,IAAI,KAAK,IAAI,KAAK,CAAC,UAAU,CAAC,CAE7B;gBAGW,EACV,UAAU,EACV,aAAa,EACb,aAAa,EACb,aAAa,EACb,QAAQ,EACR,qBAAqB,GACtB,EAAE,0BAA0B;IAY7B,IAAI,MAAM,4BAET;IAEK,IAAI,CAAC,SAAS,CAAC,EAAE,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC;IA0B1C,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAKtB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAG7B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"space.d.ts","sourceRoot":"","sources":["../../../../src/space/space.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,
|
|
1
|
+
{"version":3,"file":"space.d.ts","sourceRoot":"","sources":["../../../../src/space/space.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,EAA+C,MAAM,aAAa,CAAC;AACjF,OAAO,EAAE,KAAK,OAAO,EAAkB,QAAQ,EAAE,MAAM,eAAe,CAAC;AACvE,OAAO,EAAE,KAAK,4BAA4B,EAAE,KAAK,QAAQ,EAAE,KAAK,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAEtG,OAAO,EAAE,KAAK,WAAW,EAAE,KAAK,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAEtE,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAEhD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sCAAsC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
6
|
"bugs": "https://github.com/dxos/dxos/issues",
|
|
@@ -41,38 +41,38 @@
|
|
|
41
41
|
"crc-32": "^1.2.2",
|
|
42
42
|
"level": "^8.0.1",
|
|
43
43
|
"level-transcoder": "^1.0.1",
|
|
44
|
-
"@dxos/context": "0.6.
|
|
45
|
-
"@dxos/
|
|
46
|
-
"@dxos/
|
|
47
|
-
"@dxos/
|
|
48
|
-
"@dxos/
|
|
49
|
-
"@dxos/
|
|
50
|
-
"@dxos/echo-protocol": "0.6.
|
|
51
|
-
"@dxos/
|
|
52
|
-
"@dxos/
|
|
53
|
-
"@dxos/
|
|
54
|
-
"@dxos/
|
|
55
|
-
"@dxos/
|
|
56
|
-
"@dxos/
|
|
57
|
-
"@dxos/keyring": "0.6.
|
|
58
|
-
"@dxos/kv-store": "0.6.
|
|
59
|
-
"@dxos/
|
|
60
|
-
"@dxos/
|
|
61
|
-
"@dxos/
|
|
62
|
-
"@dxos/
|
|
63
|
-
"@dxos/
|
|
64
|
-
"@dxos/
|
|
65
|
-
"@dxos/
|
|
66
|
-
"@dxos/
|
|
67
|
-
"@dxos/
|
|
68
|
-
"@dxos/teleport-extension-
|
|
69
|
-
"@dxos/teleport-extension-
|
|
70
|
-
"@dxos/
|
|
71
|
-
"@dxos/teleport-extension-replicator": "0.6.
|
|
72
|
-
"@dxos/
|
|
73
|
-
"@dxos/tracing": "0.6.
|
|
74
|
-
"@dxos/util": "0.6.
|
|
75
|
-
"@dxos/
|
|
44
|
+
"@dxos/context": "0.6.6-main.e1a6e1f",
|
|
45
|
+
"@dxos/async": "0.6.6-main.e1a6e1f",
|
|
46
|
+
"@dxos/codec-protobuf": "0.6.6-main.e1a6e1f",
|
|
47
|
+
"@dxos/credentials": "0.6.6-main.e1a6e1f",
|
|
48
|
+
"@dxos/crypto": "0.6.6-main.e1a6e1f",
|
|
49
|
+
"@dxos/debug": "0.6.6-main.e1a6e1f",
|
|
50
|
+
"@dxos/echo-protocol": "0.6.6-main.e1a6e1f",
|
|
51
|
+
"@dxos/echo-schema": "0.6.6-main.e1a6e1f",
|
|
52
|
+
"@dxos/feed-store": "0.6.6-main.e1a6e1f",
|
|
53
|
+
"@dxos/indexing": "0.6.6-main.e1a6e1f",
|
|
54
|
+
"@dxos/hypercore": "0.6.6-main.e1a6e1f",
|
|
55
|
+
"@dxos/invariant": "0.6.6-main.e1a6e1f",
|
|
56
|
+
"@dxos/keys": "0.6.6-main.e1a6e1f",
|
|
57
|
+
"@dxos/keyring": "0.6.6-main.e1a6e1f",
|
|
58
|
+
"@dxos/kv-store": "0.6.6-main.e1a6e1f",
|
|
59
|
+
"@dxos/network-manager": "0.6.6-main.e1a6e1f",
|
|
60
|
+
"@dxos/messaging": "0.6.6-main.e1a6e1f",
|
|
61
|
+
"@dxos/automerge": "0.6.6-main.e1a6e1f",
|
|
62
|
+
"@dxos/node-std": "0.6.6-main.e1a6e1f",
|
|
63
|
+
"@dxos/protocols": "0.6.6-main.e1a6e1f",
|
|
64
|
+
"@dxos/teleport": "0.6.6-main.e1a6e1f",
|
|
65
|
+
"@dxos/random-access-storage": "0.6.6-main.e1a6e1f",
|
|
66
|
+
"@dxos/rpc": "0.6.6-main.e1a6e1f",
|
|
67
|
+
"@dxos/teleport-extension-automerge-replicator": "0.6.6-main.e1a6e1f",
|
|
68
|
+
"@dxos/teleport-extension-gossip": "0.6.6-main.e1a6e1f",
|
|
69
|
+
"@dxos/teleport-extension-object-sync": "0.6.6-main.e1a6e1f",
|
|
70
|
+
"@dxos/timeframe": "0.6.6-main.e1a6e1f",
|
|
71
|
+
"@dxos/teleport-extension-replicator": "0.6.6-main.e1a6e1f",
|
|
72
|
+
"@dxos/typings": "0.6.6-main.e1a6e1f",
|
|
73
|
+
"@dxos/tracing": "0.6.6-main.e1a6e1f",
|
|
74
|
+
"@dxos/util": "0.6.6-main.e1a6e1f",
|
|
75
|
+
"@dxos/log": "0.6.6-main.e1a6e1f"
|
|
76
76
|
},
|
|
77
77
|
"devDependencies": {
|
|
78
78
|
"fast-check": "^3.19.0",
|
|
@@ -22,6 +22,7 @@ import {
|
|
|
22
22
|
type CollectionQueryMessage,
|
|
23
23
|
type CollectionStateMessage,
|
|
24
24
|
} from './network-protocol';
|
|
25
|
+
import { createIdFromSpaceKey } from '../space';
|
|
25
26
|
|
|
26
27
|
export interface NetworkDataMonitor {
|
|
27
28
|
recordPeerConnected(peerId: string): void;
|
|
@@ -112,6 +113,10 @@ export class EchoNetworkAdapter extends NetworkAdapter {
|
|
|
112
113
|
onConnectionClosed: this._onConnectionClosed.bind(this),
|
|
113
114
|
onConnectionAuthScopeChanged: this._onConnectionAuthScopeChanged.bind(this),
|
|
114
115
|
getContainingSpaceForDocument: this._params.getContainingSpaceForDocument,
|
|
116
|
+
getContainingSpaceIdForDocument: async (documentId) => {
|
|
117
|
+
const key = await this._params.getContainingSpaceForDocument(documentId);
|
|
118
|
+
return key ? createIdFromSpaceKey(key) : null;
|
|
119
|
+
},
|
|
115
120
|
});
|
|
116
121
|
}
|
|
117
122
|
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
import { type Message } from '@dxos/automerge/automerge-repo';
|
|
6
|
-
import { type PublicKey } from '@dxos/keys';
|
|
6
|
+
import { type PublicKey, type SpaceId } from '@dxos/keys';
|
|
7
7
|
|
|
8
8
|
export interface EchoReplicator {
|
|
9
9
|
/**
|
|
@@ -23,7 +23,11 @@ export interface EchoReplicatorContext {
|
|
|
23
23
|
*/
|
|
24
24
|
get peerId(): string;
|
|
25
25
|
|
|
26
|
+
/**
|
|
27
|
+
* @deprecated Use `getContainingSpaceIdForDocument`.
|
|
28
|
+
*/
|
|
26
29
|
getContainingSpaceForDocument(documentId: string): Promise<PublicKey | null>;
|
|
30
|
+
getContainingSpaceIdForDocument(documentId: string): Promise<SpaceId | null>;
|
|
27
31
|
|
|
28
32
|
onConnectionOpen(connection: ReplicatorConnection): void;
|
|
29
33
|
onConnectionClosed(connection: ReplicatorConnection): void;
|
|
@@ -2,44 +2,18 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import type { Message
|
|
5
|
+
import type { Message } from '@dxos/automerge/automerge-repo';
|
|
6
|
+
import {
|
|
7
|
+
type CollectionQueryMessage,
|
|
8
|
+
type CollectionStateMessage,
|
|
9
|
+
MESSAGE_TYPE_COLLECTION_QUERY,
|
|
10
|
+
MESSAGE_TYPE_COLLECTION_STATE,
|
|
11
|
+
} from '@dxos/protocols';
|
|
6
12
|
|
|
7
|
-
export
|
|
8
|
-
|
|
9
|
-
export type CollectionQueryMessage = {
|
|
10
|
-
type: typeof MESSAGE_TYPE_COLLECTION_QUERY;
|
|
11
|
-
senderId: PeerId;
|
|
12
|
-
targetId: PeerId;
|
|
13
|
-
collectionId: string;
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Identifier of the current state.
|
|
17
|
-
* Remote peer will skip sending the state if it has the same tag.
|
|
18
|
-
*/
|
|
19
|
-
stateTag?: string;
|
|
20
|
-
};
|
|
13
|
+
export { type CollectionStateMessage, type CollectionQueryMessage };
|
|
21
14
|
|
|
22
15
|
export const isCollectionQueryMessage = (message: Message): message is CollectionQueryMessage =>
|
|
23
16
|
message.type === MESSAGE_TYPE_COLLECTION_QUERY;
|
|
24
17
|
|
|
25
|
-
export const MESSAGE_TYPE_COLLECTION_STATE = 'collection-state';
|
|
26
|
-
|
|
27
|
-
export type CollectionStateMessage = {
|
|
28
|
-
type: typeof MESSAGE_TYPE_COLLECTION_STATE;
|
|
29
|
-
senderId: PeerId;
|
|
30
|
-
targetId: PeerId;
|
|
31
|
-
collectionId: string;
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* State representation is implementation-defined.
|
|
35
|
-
*/
|
|
36
|
-
state?: unknown;
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* Identifier of the current state.
|
|
40
|
-
*/
|
|
41
|
-
stateTag?: string;
|
|
42
|
-
};
|
|
43
|
-
|
|
44
18
|
export const isCollectionStateMessage = (message: Message): message is CollectionStateMessage =>
|
|
45
19
|
message.type === MESSAGE_TYPE_COLLECTION_STATE;
|
|
@@ -34,6 +34,8 @@ export type SpaceManagerParams = {
|
|
|
34
34
|
snapshotStore: SnapshotStore;
|
|
35
35
|
|
|
36
36
|
blobStore: BlobStore;
|
|
37
|
+
|
|
38
|
+
disableP2pReplication?: boolean;
|
|
37
39
|
};
|
|
38
40
|
|
|
39
41
|
export type ConstructSpaceParams = {
|
|
@@ -68,14 +70,23 @@ export class SpaceManager {
|
|
|
68
70
|
private readonly _snapshotStore: SnapshotStore;
|
|
69
71
|
private readonly _blobStore: BlobStore;
|
|
70
72
|
private readonly _instanceId = PublicKey.random().toHex();
|
|
71
|
-
|
|
72
|
-
|
|
73
|
+
private readonly _disableP2pReplication: boolean;
|
|
74
|
+
|
|
75
|
+
constructor({
|
|
76
|
+
feedStore,
|
|
77
|
+
networkManager,
|
|
78
|
+
metadataStore,
|
|
79
|
+
snapshotStore,
|
|
80
|
+
blobStore,
|
|
81
|
+
disableP2pReplication,
|
|
82
|
+
}: SpaceManagerParams) {
|
|
73
83
|
// TODO(burdon): Assert.
|
|
74
84
|
this._feedStore = feedStore;
|
|
75
85
|
this._networkManager = networkManager;
|
|
76
86
|
this._metadataStore = metadataStore;
|
|
77
87
|
this._snapshotStore = snapshotStore;
|
|
78
88
|
this._blobStore = blobStore;
|
|
89
|
+
this._disableP2pReplication = disableP2pReplication ?? false;
|
|
79
90
|
}
|
|
80
91
|
|
|
81
92
|
// TODO(burdon): Remove.
|
|
@@ -115,6 +126,7 @@ export class SpaceManager {
|
|
|
115
126
|
onSessionAuth: onAuthorizedConnection,
|
|
116
127
|
onAuthFailure,
|
|
117
128
|
blobStore: this._blobStore,
|
|
129
|
+
disableP2pReplication: this._disableP2pReplication,
|
|
118
130
|
});
|
|
119
131
|
const snapshotManager = new SnapshotManager(this._snapshotStore, this._blobStore, protocol.blobSync);
|
|
120
132
|
|
|
@@ -157,6 +169,7 @@ export class SpaceManager {
|
|
|
157
169
|
},
|
|
158
170
|
onAuthFailure: (session: Teleport) => session.close(),
|
|
159
171
|
blobStore: this._blobStore,
|
|
172
|
+
disableP2pReplication: this._disableP2pReplication,
|
|
160
173
|
});
|
|
161
174
|
|
|
162
175
|
try {
|
|
@@ -20,7 +20,7 @@ import { type MuxerStats, Teleport } from '@dxos/teleport';
|
|
|
20
20
|
import { type BlobStore, BlobSync } from '@dxos/teleport-extension-object-sync';
|
|
21
21
|
import { ReplicatorExtension } from '@dxos/teleport-extension-replicator';
|
|
22
22
|
import { trace } from '@dxos/tracing';
|
|
23
|
-
import { ComplexMap } from '@dxos/util';
|
|
23
|
+
import { CallbackCollection, ComplexMap, type AsyncCallback } from '@dxos/util';
|
|
24
24
|
|
|
25
25
|
import { AuthExtension, type AuthProvider, type AuthVerifier } from './auth';
|
|
26
26
|
|
|
@@ -41,12 +41,16 @@ export type SpaceProtocolOptions = {
|
|
|
41
41
|
|
|
42
42
|
blobStore: BlobStore;
|
|
43
43
|
|
|
44
|
+
onFeed?: (feed: FeedWrapper<FeedMessage>) => Promise<void>;
|
|
45
|
+
|
|
44
46
|
/**
|
|
45
47
|
* Called when new session is authenticated.
|
|
46
48
|
* Additional extensions can be added here.
|
|
47
49
|
*/
|
|
48
50
|
onSessionAuth?: (session: Teleport) => void;
|
|
49
51
|
onAuthFailure?: (session: Teleport) => void;
|
|
52
|
+
|
|
53
|
+
disableP2pReplication?: boolean;
|
|
50
54
|
};
|
|
51
55
|
|
|
52
56
|
/**
|
|
@@ -61,6 +65,8 @@ export class SpaceProtocol {
|
|
|
61
65
|
|
|
62
66
|
public readonly blobSync: BlobSync;
|
|
63
67
|
|
|
68
|
+
private readonly _disableP2pReplication: boolean;
|
|
69
|
+
|
|
64
70
|
@logInfo
|
|
65
71
|
@trace.info()
|
|
66
72
|
private readonly _topic: Promise<PublicKey>;
|
|
@@ -79,6 +85,8 @@ export class SpaceProtocol {
|
|
|
79
85
|
|
|
80
86
|
private _connection?: SwarmConnection;
|
|
81
87
|
|
|
88
|
+
public readonly feedAdded = new CallbackCollection<AsyncCallback<FeedWrapper<FeedMessage>>>();
|
|
89
|
+
|
|
82
90
|
get sessions(): ReadonlyMap<PublicKey, SpaceProtocolSession> {
|
|
83
91
|
return this._sessions;
|
|
84
92
|
}
|
|
@@ -92,7 +100,15 @@ export class SpaceProtocol {
|
|
|
92
100
|
return this._swarmIdentity.peerKey;
|
|
93
101
|
}
|
|
94
102
|
|
|
95
|
-
constructor({
|
|
103
|
+
constructor({
|
|
104
|
+
topic,
|
|
105
|
+
swarmIdentity,
|
|
106
|
+
networkManager,
|
|
107
|
+
onSessionAuth,
|
|
108
|
+
onAuthFailure,
|
|
109
|
+
blobStore,
|
|
110
|
+
disableP2pReplication,
|
|
111
|
+
}: SpaceProtocolOptions) {
|
|
96
112
|
this._spaceKey = topic;
|
|
97
113
|
this._networkManager = networkManager;
|
|
98
114
|
this._swarmIdentity = swarmIdentity;
|
|
@@ -102,16 +118,20 @@ export class SpaceProtocol {
|
|
|
102
118
|
|
|
103
119
|
// TODO(burdon): Async race condition? Move to start?
|
|
104
120
|
this._topic = subtleCrypto.digest('SHA-256', topic.asBuffer()).then(discoveryKey).then(PublicKey.from);
|
|
121
|
+
|
|
122
|
+
this._disableP2pReplication = disableP2pReplication ?? false;
|
|
105
123
|
}
|
|
106
124
|
|
|
107
125
|
// TODO(burdon): Create abstraction for Space (e.g., add keys and have provider).
|
|
108
|
-
addFeed(feed: FeedWrapper<FeedMessage>) {
|
|
126
|
+
async addFeed(feed: FeedWrapper<FeedMessage>) {
|
|
109
127
|
log('addFeed', { key: feed.key });
|
|
110
128
|
|
|
111
129
|
this._feeds.add(feed);
|
|
112
130
|
for (const session of this._sessions.values()) {
|
|
113
131
|
session.replicator.addFeed(feed);
|
|
114
132
|
}
|
|
133
|
+
|
|
134
|
+
await this.feedAdded.callSerial(feed);
|
|
115
135
|
}
|
|
116
136
|
|
|
117
137
|
// TODO(burdon): Rename open? Common open/close interfaces for all services?
|
|
@@ -160,6 +180,7 @@ export class SpaceProtocol {
|
|
|
160
180
|
onSessionAuth: this._onSessionAuth,
|
|
161
181
|
onAuthFailure: this._onAuthFailure,
|
|
162
182
|
blobSync: this.blobSync,
|
|
183
|
+
disableP2pReplication: this._disableP2pReplication,
|
|
163
184
|
});
|
|
164
185
|
this._sessions.set(wireParams.remotePeerId, session);
|
|
165
186
|
|
|
@@ -185,6 +206,8 @@ export type SpaceProtocolSessionParams = {
|
|
|
185
206
|
onSessionAuth?: (session: Teleport) => void;
|
|
186
207
|
|
|
187
208
|
onAuthFailure?: (session: Teleport) => void;
|
|
209
|
+
|
|
210
|
+
disableP2pReplication?: boolean;
|
|
188
211
|
};
|
|
189
212
|
|
|
190
213
|
export enum AuthStatus {
|
|
@@ -201,6 +224,8 @@ export class SpaceProtocolSession implements WireProtocol {
|
|
|
201
224
|
@logInfo
|
|
202
225
|
private readonly _wireParams: WireProtocolParams;
|
|
203
226
|
|
|
227
|
+
private readonly _disableP2pReplication: boolean;
|
|
228
|
+
|
|
204
229
|
private readonly _onSessionAuth?: (session: Teleport) => void;
|
|
205
230
|
private readonly _onAuthFailure?: (session: Teleport) => void;
|
|
206
231
|
private readonly _swarmIdentity: SwarmIdentity;
|
|
@@ -223,7 +248,14 @@ export class SpaceProtocolSession implements WireProtocol {
|
|
|
223
248
|
}
|
|
224
249
|
|
|
225
250
|
// TODO(dmaretskyi): Allow to pass in extra extensions.
|
|
226
|
-
constructor({
|
|
251
|
+
constructor({
|
|
252
|
+
wireParams,
|
|
253
|
+
swarmIdentity,
|
|
254
|
+
onSessionAuth,
|
|
255
|
+
onAuthFailure,
|
|
256
|
+
blobSync,
|
|
257
|
+
disableP2pReplication,
|
|
258
|
+
}: SpaceProtocolSessionParams) {
|
|
227
259
|
this._wireParams = wireParams;
|
|
228
260
|
this._swarmIdentity = swarmIdentity;
|
|
229
261
|
this._onSessionAuth = onSessionAuth;
|
|
@@ -231,6 +263,8 @@ export class SpaceProtocolSession implements WireProtocol {
|
|
|
231
263
|
this._blobSync = blobSync;
|
|
232
264
|
|
|
233
265
|
this._teleport = new Teleport(wireParams);
|
|
266
|
+
|
|
267
|
+
this._disableP2pReplication = disableP2pReplication ?? false;
|
|
234
268
|
}
|
|
235
269
|
|
|
236
270
|
get stream() {
|
|
@@ -256,7 +290,10 @@ export class SpaceProtocolSession implements WireProtocol {
|
|
|
256
290
|
},
|
|
257
291
|
}),
|
|
258
292
|
);
|
|
259
|
-
|
|
293
|
+
|
|
294
|
+
if (!this._disableP2pReplication) {
|
|
295
|
+
this._teleport.addExtension('dxos.mesh.teleport.replicator', this.replicator);
|
|
296
|
+
}
|
|
260
297
|
this._teleport.addExtension('dxos.mesh.teleport.blobsync', this._blobSync.createExtension());
|
|
261
298
|
}
|
|
262
299
|
|
package/src/space/space.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// Copyright 2022 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { Event, synchronized, trackLeaks } from '@dxos/async';
|
|
5
|
+
import { Event, scheduleMicroTask, synchronized, trackLeaks } from '@dxos/async';
|
|
6
6
|
import { type Context, LifecycleState, Resource } from '@dxos/context';
|
|
7
7
|
import { type DelegateInvitationCredential, type FeedInfo, type MemberInfo } from '@dxos/credentials';
|
|
8
8
|
import { subtleCrypto } from '@dxos/crypto';
|
|
@@ -93,8 +93,8 @@ export class Space extends Resource {
|
|
|
93
93
|
const sparse = info.assertion.designation === AdmittedFeed.Designation.DATA;
|
|
94
94
|
|
|
95
95
|
if (!info.key.equals(params.genesisFeed.key)) {
|
|
96
|
-
|
|
97
|
-
this.protocol.addFeed(await params.feedProvider(info.key, { sparse }));
|
|
96
|
+
scheduleMicroTask(this._ctx, async () => {
|
|
97
|
+
await this.protocol.addFeed(await params.feedProvider(info.key, { sparse }));
|
|
98
98
|
});
|
|
99
99
|
}
|
|
100
100
|
});
|
|
@@ -119,7 +119,6 @@ export class Space extends Resource {
|
|
|
119
119
|
|
|
120
120
|
// Start replicating the genesis feed.
|
|
121
121
|
this.protocol = params.protocol;
|
|
122
|
-
this.protocol.addFeed(params.genesisFeed);
|
|
123
122
|
}
|
|
124
123
|
|
|
125
124
|
@logInfo
|
|
@@ -192,6 +191,7 @@ export class Space extends Resource {
|
|
|
192
191
|
// Order is important.
|
|
193
192
|
await this._controlPipeline.start();
|
|
194
193
|
await this.protocol.start();
|
|
194
|
+
await this.protocol.addFeed(await this._feedProvider(this._genesisFeedKey));
|
|
195
195
|
|
|
196
196
|
log('opened');
|
|
197
197
|
}
|