@dxos/client-services 0.1.30-next.a4f4fa5 → 0.1.30
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-ZIQUYEJS.mjs → chunk-DFO3FW2W.mjs} +53 -20
- package/dist/lib/browser/{chunk-ZIQUYEJS.mjs.map → chunk-DFO3FW2W.mjs.map} +3 -3
- package/dist/lib/browser/index.mjs +1 -1
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/packlets/testing/index.mjs +64 -6
- package/dist/lib/browser/packlets/testing/index.mjs.map +3 -3
- package/dist/lib/node/index.cjs +52 -19
- package/dist/lib/node/index.cjs.map +3 -3
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/packlets/testing/index.cjs +114 -22
- package/dist/lib/node/packlets/testing/index.cjs.map +3 -3
- package/dist/types/src/packlets/spaces/data-space-manager.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/data-space.d.ts +8 -1
- package/dist/types/src/packlets/spaces/data-space.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/notarization-plugin.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/spaces-service.d.ts +4 -1
- package/dist/types/src/packlets/spaces/spaces-service.d.ts.map +1 -1
- package/dist/types/src/packlets/testing/test-builder.d.ts +2 -0
- package/dist/types/src/packlets/testing/test-builder.d.ts.map +1 -1
- package/dist/types/src/packlets/tests/text.test.d.ts +2 -0
- package/dist/types/src/packlets/tests/text.test.d.ts.map +1 -0
- package/package.json +31 -30
- package/src/packlets/spaces/data-space-manager.test.ts +60 -0
- package/src/packlets/spaces/data-space-manager.ts +11 -7
- package/src/packlets/spaces/data-space.ts +13 -1
- package/src/packlets/spaces/notarization-plugin.ts +9 -2
- package/src/packlets/spaces/spaces-service.ts +25 -0
- package/src/packlets/testing/test-builder.ts +45 -5
- package/src/packlets/tests/spaces-invitations.test.ts +46 -6
- package/src/packlets/tests/spaces.test.ts +70 -2
- package/src/packlets/tests/text.test.ts +206 -0
|
@@ -2095,7 +2095,7 @@ import { getCredentialAssertion as getCredentialAssertion2 } from "@dxos/credent
|
|
|
2095
2095
|
import { spaceGenesis, SnapshotManager } from "@dxos/echo-pipeline";
|
|
2096
2096
|
import { PublicKey as PublicKey7 } from "@dxos/keys";
|
|
2097
2097
|
import { log as log8 } from "@dxos/log";
|
|
2098
|
-
import { Presence } from "@dxos/teleport-extension-
|
|
2098
|
+
import { Gossip, Presence } from "@dxos/teleport-extension-gossip";
|
|
2099
2099
|
import { ComplexMap as ComplexMap3, deferFunction as deferFunction2 } from "@dxos/util";
|
|
2100
2100
|
|
|
2101
2101
|
// packages/sdk/client-services/src/packlets/spaces/data-space.ts
|
|
@@ -2109,7 +2109,7 @@ import { ComplexSet as ComplexSet2 } from "@dxos/util";
|
|
|
2109
2109
|
|
|
2110
2110
|
// packages/sdk/client-services/src/packlets/spaces/notarization-plugin.ts
|
|
2111
2111
|
import assert9 from "@dxos/node-std/assert";
|
|
2112
|
-
import { DeferredTask, Event as Event4, scheduleTask as scheduleTask3, TimeoutError, Trigger as Trigger4 } from "@dxos/async";
|
|
2112
|
+
import { DeferredTask, Event as Event4, scheduleTask as scheduleTask3, sleep as sleep3, TimeoutError, Trigger as Trigger4 } from "@dxos/async";
|
|
2113
2113
|
import { Context as Context5 } from "@dxos/context";
|
|
2114
2114
|
import { PublicKey as PublicKey5 } from "@dxos/keys";
|
|
2115
2115
|
import { log as log7 } from "@dxos/log";
|
|
@@ -2117,6 +2117,7 @@ import { schema as schema4 } from "@dxos/protocols";
|
|
|
2117
2117
|
import { RpcExtension as RpcExtension3 } from "@dxos/teleport";
|
|
2118
2118
|
import { ComplexMap as ComplexMap2, ComplexSet, entry } from "@dxos/util";
|
|
2119
2119
|
var RETRY_TIMEOUT = 1e3;
|
|
2120
|
+
var SUCCESS_DELAY = 1e3;
|
|
2120
2121
|
var NOTARIZE_TIMEOUT = 1e4;
|
|
2121
2122
|
var NotarizationPlugin = class {
|
|
2122
2123
|
constructor() {
|
|
@@ -2139,7 +2140,7 @@ var NotarizationPlugin = class {
|
|
|
2139
2140
|
credentials
|
|
2140
2141
|
}, {
|
|
2141
2142
|
file: "notarization-plugin.ts",
|
|
2142
|
-
line:
|
|
2143
|
+
line: 50,
|
|
2143
2144
|
scope: this,
|
|
2144
2145
|
callSite: (f, a) => f(...a)
|
|
2145
2146
|
});
|
|
@@ -2151,7 +2152,7 @@ var NotarizationPlugin = class {
|
|
|
2151
2152
|
err
|
|
2152
2153
|
}, {
|
|
2153
2154
|
file: "notarization-plugin.ts",
|
|
2154
|
-
line:
|
|
2155
|
+
line: 59,
|
|
2155
2156
|
scope: this,
|
|
2156
2157
|
callSite: (f, a) => f(...a)
|
|
2157
2158
|
});
|
|
@@ -2162,7 +2163,7 @@ var NotarizationPlugin = class {
|
|
|
2162
2163
|
scheduleTask3(ctx, () => {
|
|
2163
2164
|
log7.warn("Notarization timeout", {}, {
|
|
2164
2165
|
file: "notarization-plugin.ts",
|
|
2165
|
-
line:
|
|
2166
|
+
line: 67,
|
|
2166
2167
|
scope: this,
|
|
2167
2168
|
callSite: (f, a) => f(...a)
|
|
2168
2169
|
});
|
|
@@ -2176,7 +2177,7 @@ var NotarizationPlugin = class {
|
|
|
2176
2177
|
if (this._extensions.size === 0) {
|
|
2177
2178
|
log7.warn("No peers to notarize with", {}, {
|
|
2178
2179
|
file: "notarization-plugin.ts",
|
|
2179
|
-
line:
|
|
2180
|
+
line: 82,
|
|
2180
2181
|
scope: this,
|
|
2181
2182
|
callSite: (f, a) => f(...a)
|
|
2182
2183
|
});
|
|
@@ -2190,7 +2191,7 @@ var NotarizationPlugin = class {
|
|
|
2190
2191
|
retryIn: RETRY_TIMEOUT
|
|
2191
2192
|
}, {
|
|
2192
2193
|
file: "notarization-plugin.ts",
|
|
2193
|
-
line:
|
|
2194
|
+
line: 89,
|
|
2194
2195
|
scope: this,
|
|
2195
2196
|
callSite: (f, a) => f(...a)
|
|
2196
2197
|
});
|
|
@@ -2204,7 +2205,7 @@ var NotarizationPlugin = class {
|
|
|
2204
2205
|
credentialId: credentials.map((credential) => credential.id)
|
|
2205
2206
|
}, {
|
|
2206
2207
|
file: "notarization-plugin.ts",
|
|
2207
|
-
line:
|
|
2208
|
+
line: 96,
|
|
2208
2209
|
scope: this,
|
|
2209
2210
|
callSite: (f, a) => f(...a)
|
|
2210
2211
|
});
|
|
@@ -2213,14 +2214,15 @@ var NotarizationPlugin = class {
|
|
|
2213
2214
|
});
|
|
2214
2215
|
log7("success", {}, {
|
|
2215
2216
|
file: "notarization-plugin.ts",
|
|
2216
|
-
line:
|
|
2217
|
+
line: 100,
|
|
2217
2218
|
scope: this,
|
|
2218
2219
|
callSite: (f, a) => f(...a)
|
|
2219
2220
|
});
|
|
2221
|
+
await sleep3(SUCCESS_DELAY);
|
|
2220
2222
|
} catch (err) {
|
|
2221
2223
|
log7.warn("error notarizing (recoverable)", err, {
|
|
2222
2224
|
file: "notarization-plugin.ts",
|
|
2223
|
-
line:
|
|
2225
|
+
line: 103,
|
|
2224
2226
|
scope: this,
|
|
2225
2227
|
callSite: (f, a) => f(...a)
|
|
2226
2228
|
});
|
|
@@ -2236,7 +2238,7 @@ var NotarizationPlugin = class {
|
|
|
2236
2238
|
]);
|
|
2237
2239
|
log7("done", {}, {
|
|
2238
2240
|
file: "notarization-plugin.ts",
|
|
2239
|
-
line:
|
|
2241
|
+
line: 114,
|
|
2240
2242
|
scope: this,
|
|
2241
2243
|
callSite: (f, a) => f(...a)
|
|
2242
2244
|
});
|
|
@@ -2289,7 +2291,7 @@ var NotarizationPlugin = class {
|
|
|
2289
2291
|
peer: extension.localPeerId
|
|
2290
2292
|
}, {
|
|
2291
2293
|
file: "notarization-plugin.ts",
|
|
2292
|
-
line:
|
|
2294
|
+
line: 163,
|
|
2293
2295
|
scope: this,
|
|
2294
2296
|
callSite: (f, a) => f(...a)
|
|
2295
2297
|
});
|
|
@@ -2301,7 +2303,7 @@ var NotarizationPlugin = class {
|
|
|
2301
2303
|
peer: extension.localPeerId
|
|
2302
2304
|
}, {
|
|
2303
2305
|
file: "notarization-plugin.ts",
|
|
2304
|
-
line:
|
|
2306
|
+
line: 168,
|
|
2305
2307
|
scope: this,
|
|
2306
2308
|
callSite: (f, a) => f(...a)
|
|
2307
2309
|
});
|
|
@@ -2360,6 +2362,7 @@ var DataSpace = class DataSpace2 {
|
|
|
2360
2362
|
constructor(params) {
|
|
2361
2363
|
this._ctx = new Context6();
|
|
2362
2364
|
this._inner = params.inner;
|
|
2365
|
+
this._gossip = params.gossip;
|
|
2363
2366
|
this._presence = params.presence;
|
|
2364
2367
|
this._keyring = params.keyring;
|
|
2365
2368
|
this._feedStore = params.feedStore;
|
|
@@ -2416,6 +2419,12 @@ var DataSpace = class DataSpace2 {
|
|
|
2416
2419
|
await this.notarizationPlugin.close();
|
|
2417
2420
|
await this._presence.destroy();
|
|
2418
2421
|
}
|
|
2422
|
+
async postMessage(channel, message) {
|
|
2423
|
+
return this._gossip.postMessage(channel, message);
|
|
2424
|
+
}
|
|
2425
|
+
listen(channel, callback) {
|
|
2426
|
+
return this._gossip.listen(channel, callback);
|
|
2427
|
+
}
|
|
2419
2428
|
async initializeDataPipeline() {
|
|
2420
2429
|
await this._inner.controlPipeline.state.waitUntilReachedTargetTimeframe({
|
|
2421
2430
|
timeout: CONTROL_PIPELINE_READY_TIMEFRAME
|
|
@@ -2596,11 +2605,14 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2596
2605
|
return space;
|
|
2597
2606
|
}
|
|
2598
2607
|
async _constructSpace(metadata) {
|
|
2608
|
+
const gossip = new Gossip({
|
|
2609
|
+
localPeerId: this._signingContext.deviceKey
|
|
2610
|
+
});
|
|
2599
2611
|
const presence = new Presence({
|
|
2600
|
-
|
|
2601
|
-
|
|
2602
|
-
|
|
2603
|
-
|
|
2612
|
+
announceInterval: 500,
|
|
2613
|
+
offlineTimeout: 5e3,
|
|
2614
|
+
identityKey: this._signingContext.identityKey,
|
|
2615
|
+
gossip
|
|
2604
2616
|
});
|
|
2605
2617
|
const snapshotManager = new SnapshotManager(this._snapshotStore);
|
|
2606
2618
|
const controlFeed = metadata.controlFeedKey && await this._feedStore.openFeed(metadata.controlFeedKey, {
|
|
@@ -2617,7 +2629,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2617
2629
|
credentialAuthenticator: deferFunction2(() => dataSpace.authVerifier.verifier)
|
|
2618
2630
|
},
|
|
2619
2631
|
onNetworkConnection: (session) => {
|
|
2620
|
-
session.addExtension("dxos.mesh.teleport.
|
|
2632
|
+
session.addExtension("dxos.mesh.teleport.gossip", gossip.createExtension({
|
|
2621
2633
|
remotePeerId: session.remotePeerId
|
|
2622
2634
|
}));
|
|
2623
2635
|
session.addExtension("dxos.mesh.teleport.objectsync", snapshotManager.objectSync.createExtension());
|
|
@@ -2631,6 +2643,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2631
2643
|
modelFactory: this._modelFactory,
|
|
2632
2644
|
metadataStore: this._metadataStore,
|
|
2633
2645
|
snapshotManager,
|
|
2646
|
+
gossip,
|
|
2634
2647
|
presence,
|
|
2635
2648
|
memberKey: this._signingContext.identityKey,
|
|
2636
2649
|
keyring: this._keyring,
|
|
@@ -2694,7 +2707,7 @@ var SpacesServiceImpl = class {
|
|
|
2694
2707
|
spaces
|
|
2695
2708
|
}, {
|
|
2696
2709
|
file: "spaces-service.ts",
|
|
2697
|
-
line:
|
|
2710
|
+
line: 62,
|
|
2698
2711
|
scope: this,
|
|
2699
2712
|
callSite: (f, a) => f(...a)
|
|
2700
2713
|
});
|
|
@@ -2732,6 +2745,25 @@ var SpacesServiceImpl = class {
|
|
|
2732
2745
|
}
|
|
2733
2746
|
});
|
|
2734
2747
|
}
|
|
2748
|
+
async postMessage({ spaceKey, channel, message }) {
|
|
2749
|
+
var _a;
|
|
2750
|
+
const dataSpaceManager = await this._getDataSpaceManager();
|
|
2751
|
+
const space = (_a = dataSpaceManager.spaces.get(spaceKey)) != null ? _a : raise(new SpaceNotFoundError(spaceKey));
|
|
2752
|
+
await space.postMessage(getChannelId(channel), message);
|
|
2753
|
+
}
|
|
2754
|
+
subscribeMessages({ spaceKey, channel }) {
|
|
2755
|
+
return new Stream10(({ ctx, next }) => {
|
|
2756
|
+
scheduleTask4(ctx, async () => {
|
|
2757
|
+
var _a;
|
|
2758
|
+
const dataSpaceManager = await this._getDataSpaceManager();
|
|
2759
|
+
const space = (_a = dataSpaceManager.spaces.get(spaceKey)) != null ? _a : raise(new SpaceNotFoundError(spaceKey));
|
|
2760
|
+
const handle = space.listen(getChannelId(channel), (message) => {
|
|
2761
|
+
next(message);
|
|
2762
|
+
});
|
|
2763
|
+
ctx.onDispose(() => handle.unsubscribe());
|
|
2764
|
+
});
|
|
2765
|
+
});
|
|
2766
|
+
}
|
|
2735
2767
|
queryCredentials({ spaceKey }) {
|
|
2736
2768
|
return new Stream10(({ ctx, next }) => {
|
|
2737
2769
|
var _a;
|
|
@@ -2775,6 +2807,7 @@ var SpacesServiceImpl = class {
|
|
|
2775
2807
|
};
|
|
2776
2808
|
}
|
|
2777
2809
|
};
|
|
2810
|
+
var getChannelId = (channel) => `user-channel/${channel}`;
|
|
2778
2811
|
|
|
2779
2812
|
// packages/sdk/client-services/src/packlets/system/system-service.ts
|
|
2780
2813
|
import { Stream as Stream11 } from "@dxos/codec-protobuf";
|
|
@@ -3865,4 +3898,4 @@ export {
|
|
|
3865
3898
|
LocalClientServices,
|
|
3866
3899
|
fromHost
|
|
3867
3900
|
};
|
|
3868
|
-
//# sourceMappingURL=chunk-
|
|
3901
|
+
//# sourceMappingURL=chunk-DFO3FW2W.mjs.map
|