@dxos/client-services 0.1.23 → 0.1.24
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-R2FEBB66.mjs +3865 -0
- package/dist/lib/browser/chunk-R2FEBB66.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +56 -3066
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/packlets/testing/index.mjs +198 -0
- package/dist/lib/browser/packlets/testing/index.mjs.map +7 -0
- package/dist/lib/node/index.cjs +1401 -645
- package/dist/lib/node/index.cjs.map +4 -4
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/packlets/testing/index.cjs +3688 -0
- package/dist/lib/node/packlets/testing/index.cjs.map +7 -0
- package/dist/types/src/packlets/deprecated/profile.d.ts +3 -1
- package/dist/types/src/packlets/deprecated/profile.d.ts.map +1 -1
- package/dist/types/src/packlets/deprecated/space.d.ts.map +1 -1
- package/dist/types/src/packlets/deprecated/system.d.ts +15 -9
- package/dist/types/src/packlets/deprecated/system.d.ts.map +1 -1
- package/dist/types/src/packlets/devtools/devtools.d.ts +2 -2
- package/dist/types/src/packlets/devtools/devtools.d.ts.map +1 -1
- package/dist/types/src/packlets/devtools/feeds.d.ts.map +1 -1
- package/dist/types/src/packlets/devtools/network.d.ts +3 -3
- package/dist/types/src/packlets/devtools/network.d.ts.map +1 -1
- package/dist/types/src/packlets/devtools/spaces.d.ts.map +1 -1
- package/dist/types/src/packlets/identity/authenticator.d.ts +1 -1
- package/dist/types/src/packlets/identity/authenticator.d.ts.map +1 -1
- package/dist/types/src/packlets/identity/identity-manager.d.ts +7 -1
- package/dist/types/src/packlets/identity/identity-manager.d.ts.map +1 -1
- package/dist/types/src/packlets/identity/identity.d.ts +1 -0
- package/dist/types/src/packlets/identity/identity.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/halo-invitations-handler.d.ts +11 -3
- package/dist/types/src/packlets/invitations/halo-invitations-handler.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/invitations.d.ts +1 -1
- package/dist/types/src/packlets/invitations/invitations.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/space-invitations-handler.d.ts.map +1 -1
- package/dist/types/src/packlets/services/service-context.d.ts +2 -0
- package/dist/types/src/packlets/services/service-context.d.ts.map +1 -1
- package/dist/types/src/packlets/services/service-context.test.d.ts +2 -0
- package/dist/types/src/packlets/services/service-context.test.d.ts.map +1 -0
- package/dist/types/src/packlets/services/service-definitions.d.ts +1 -1
- package/dist/types/src/packlets/services/service-definitions.d.ts.map +1 -1
- package/dist/types/src/packlets/services/service-host.d.ts +9 -6
- package/dist/types/src/packlets/services/service-host.d.ts.map +1 -1
- package/dist/types/src/packlets/services/service-registry.d.ts +4 -3
- package/dist/types/src/packlets/services/service-registry.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/data-space-manager.d.ts +9 -2
- package/dist/types/src/packlets/spaces/data-space-manager.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/data-space.d.ts +18 -4
- package/dist/types/src/packlets/spaces/data-space.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/notarization-plugin.d.ts +50 -0
- package/dist/types/src/packlets/spaces/notarization-plugin.d.ts.map +1 -0
- package/dist/types/src/packlets/spaces/notarization-plugin.test.d.ts +2 -0
- package/dist/types/src/packlets/spaces/notarization-plugin.test.d.ts.map +1 -0
- package/dist/types/src/packlets/spaces/spaces-service.d.ts +2 -1
- package/dist/types/src/packlets/spaces/spaces-service.d.ts.map +1 -1
- package/dist/types/src/packlets/testing/credential-utils.d.ts +8 -0
- package/dist/types/src/packlets/testing/credential-utils.d.ts.map +1 -0
- package/dist/types/src/packlets/testing/index.d.ts +2 -0
- package/dist/types/src/packlets/testing/index.d.ts.map +1 -1
- package/dist/types/src/packlets/testing/invitation-utils.d.ts +3 -0
- package/dist/types/src/packlets/testing/invitation-utils.d.ts.map +1 -0
- package/dist/types/src/packlets/testing/test-builder.d.ts +2 -2
- package/dist/types/src/packlets/testing/test-builder.d.ts.map +1 -1
- package/dist/types/src/packlets/vault/iframe-host-runtime.d.ts +28 -0
- package/dist/types/src/packlets/vault/iframe-host-runtime.d.ts.map +1 -0
- package/dist/types/src/packlets/vault/{iframe-runtime.d.ts → iframe-proxy-runtime.d.ts} +4 -4
- package/dist/types/src/packlets/vault/iframe-proxy-runtime.d.ts.map +1 -0
- package/dist/types/src/packlets/vault/index.d.ts +4 -1
- package/dist/types/src/packlets/vault/index.d.ts.map +1 -1
- package/dist/types/src/packlets/vault/vault-resource-lock.d.ts +19 -0
- package/dist/types/src/packlets/vault/vault-resource-lock.d.ts.map +1 -0
- package/dist/types/src/packlets/vault/worker-runtime.d.ts.map +1 -1
- package/dist/types/src/packlets/vault/worker-session.d.ts +4 -4
- package/dist/types/src/packlets/vault/worker-session.d.ts.map +1 -1
- package/package.json +29 -29
- package/src/packlets/deprecated/profile.ts +20 -2
- package/src/packlets/deprecated/space.ts +41 -37
- package/src/packlets/deprecated/system.ts +26 -13
- package/src/packlets/devtools/devtools.ts +4 -4
- package/src/packlets/devtools/feeds.ts +11 -6
- package/src/packlets/devtools/network.ts +20 -9
- package/src/packlets/devtools/spaces.ts +7 -6
- package/src/packlets/identity/authenticator.ts +11 -6
- package/src/packlets/identity/identity-manager.test.ts +24 -15
- package/src/packlets/identity/identity-manager.ts +22 -8
- package/src/packlets/identity/identity.test.ts +21 -22
- package/src/packlets/identity/identity.ts +10 -5
- package/src/packlets/invitations/halo-invitations-handler.test.ts +4 -45
- package/src/packlets/invitations/halo-invitations-handler.ts +33 -17
- package/src/packlets/invitations/invitations.ts +2 -1
- package/src/packlets/invitations/space-invitations-handler.test.ts +43 -26
- package/src/packlets/invitations/space-invitations-handler.ts +8 -11
- package/src/packlets/services/service-context.test.ts +56 -0
- package/src/packlets/services/service-context.ts +60 -4
- package/src/packlets/services/service-definitions.ts +1 -1
- package/src/packlets/services/service-host.test.ts +74 -5
- package/src/packlets/services/service-host.ts +85 -23
- package/src/packlets/services/service-registry.test.ts +2 -1
- package/src/packlets/services/service-registry.ts +5 -1
- package/src/packlets/spaces/data-space-manager.test.ts +71 -14
- package/src/packlets/spaces/data-space-manager.ts +49 -8
- package/src/packlets/spaces/data-space.ts +113 -14
- package/src/packlets/spaces/notarization-plugin.test.ts +81 -0
- package/src/packlets/spaces/notarization-plugin.ts +211 -0
- package/src/packlets/spaces/spaces-service.ts +9 -1
- package/src/packlets/testing/credential-utils.ts +28 -0
- package/src/packlets/testing/index.ts +2 -0
- package/src/packlets/testing/invitation-utils.ts +44 -0
- package/src/packlets/testing/test-builder.ts +14 -18
- package/src/packlets/vault/iframe-host-runtime.ts +112 -0
- package/src/packlets/vault/{iframe-runtime.ts → iframe-proxy-runtime.ts} +3 -3
- package/src/packlets/vault/index.ts +4 -1
- package/src/packlets/vault/vault-resource-lock.ts +76 -0
- package/src/packlets/vault/worker-runtime.ts +13 -3
- package/src/packlets/vault/worker-session.ts +17 -17
- package/dist/types/src/packlets/vault/iframe-runtime.d.ts.map +0 -1
package/dist/lib/node/index.cjs
CHANGED
|
@@ -42,7 +42,8 @@ __export(src_exports, {
|
|
|
42
42
|
HaloInvitationsHandler: () => HaloInvitationsHandler,
|
|
43
43
|
HaloInvitationsProxy: () => HaloInvitationsProxy,
|
|
44
44
|
HaloInvitationsServiceImpl: () => HaloInvitationsServiceImpl,
|
|
45
|
-
|
|
45
|
+
IFrameHostRuntime: () => IFrameHostRuntime,
|
|
46
|
+
IFrameProxyRuntime: () => IFrameProxyRuntime,
|
|
46
47
|
INVITATION_TIMEOUT: () => INVITATION_TIMEOUT,
|
|
47
48
|
Identity: () => Identity,
|
|
48
49
|
IdentityManager: () => IdentityManager,
|
|
@@ -59,6 +60,7 @@ __export(src_exports, {
|
|
|
59
60
|
SystemServiceImpl: () => SystemServiceImpl,
|
|
60
61
|
TracingServiceImpl: () => TracingServiceImpl,
|
|
61
62
|
TrustedKeySetAuthVerifier: () => TrustedKeySetAuthVerifier,
|
|
63
|
+
VaultResourceLock: () => VaultResourceLock,
|
|
62
64
|
WorkerRuntime: () => WorkerRuntime,
|
|
63
65
|
WorkerSession: () => WorkerSession,
|
|
64
66
|
clientServiceBundle: () => clientServiceBundle,
|
|
@@ -66,20 +68,21 @@ __export(src_exports, {
|
|
|
66
68
|
createDefaultModelFactory: () => createDefaultModelFactory,
|
|
67
69
|
createStorageObjects: () => createStorageObjects,
|
|
68
70
|
getNetworkPeers: () => getNetworkPeers,
|
|
71
|
+
iframeServiceBundle: () => iframeServiceBundle,
|
|
69
72
|
subscribeToFeedBlocks: () => subscribeToFeedBlocks,
|
|
70
73
|
subscribeToFeeds: () => subscribeToFeeds,
|
|
71
74
|
subscribeToNetworkStatus: () => subscribeToNetworkStatus,
|
|
72
75
|
subscribeToNetworkTopics: () => subscribeToNetworkTopics,
|
|
73
|
-
|
|
76
|
+
subscribeToSignal: () => subscribeToSignal,
|
|
74
77
|
subscribeToSpaces: () => subscribeToSpaces,
|
|
75
78
|
subscribeToSwarmInfo: () => subscribeToSwarmInfo,
|
|
79
|
+
workerServiceBundle: () => workerServiceBundle,
|
|
76
80
|
wrapObservable: () => wrapObservable
|
|
77
81
|
});
|
|
78
82
|
module.exports = __toCommonJS(src_exports);
|
|
79
83
|
|
|
80
84
|
// packages/sdk/client-services/src/packlets/deprecated/space.ts
|
|
81
85
|
var import_node_assert = __toESM(require("node:assert"));
|
|
82
|
-
var import_async = require("@dxos/async");
|
|
83
86
|
var import_codec_protobuf = require("@dxos/codec-protobuf");
|
|
84
87
|
var import_debug = require("@dxos/debug");
|
|
85
88
|
var import_log = require("@dxos/log");
|
|
@@ -103,10 +106,9 @@ var SpaceServiceImpl = class {
|
|
|
103
106
|
});
|
|
104
107
|
}
|
|
105
108
|
subscribeSpaces() {
|
|
106
|
-
return new import_codec_protobuf.Stream(({ next }) => {
|
|
107
|
-
const subscriptions = new import_async.EventSubscriptions();
|
|
109
|
+
return new import_codec_protobuf.Stream(({ next, ctx }) => {
|
|
108
110
|
const onUpdate = () => {
|
|
109
|
-
const spaces = Array.from(this.serviceContext.dataSpaceManager.spaces.values()).map((space) => ({
|
|
111
|
+
const spaces = Array.from(this.serviceContext.dataSpaceManager.spaces.values()).filter((space) => this.serviceContext.dataServiceSubscriptions.getDataService(space.key)).map((space) => ({
|
|
110
112
|
publicKey: space.key,
|
|
111
113
|
isOpen: true,
|
|
112
114
|
isActive: true,
|
|
@@ -126,7 +128,7 @@ var SpaceServiceImpl = class {
|
|
|
126
128
|
spaces
|
|
127
129
|
}, {
|
|
128
130
|
file: "space.ts",
|
|
129
|
-
line:
|
|
131
|
+
line: 119,
|
|
130
132
|
scope: this,
|
|
131
133
|
callSite: (f, a) => f(...a)
|
|
132
134
|
});
|
|
@@ -141,26 +143,31 @@ var SpaceServiceImpl = class {
|
|
|
141
143
|
});
|
|
142
144
|
}
|
|
143
145
|
await this.serviceContext.initialized.wait();
|
|
144
|
-
|
|
145
|
-
this.serviceContext.dataSpaceManager.spaces.
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
146
|
+
const subscribeSpaces = () => {
|
|
147
|
+
for (const space of this.serviceContext.dataSpaceManager.spaces.values()) {
|
|
148
|
+
if (!this.serviceContext.dataServiceSubscriptions.getDataService(space.key)) {
|
|
149
|
+
continue;
|
|
150
|
+
}
|
|
151
|
+
space.stateUpdate.on(ctx, onUpdate);
|
|
152
|
+
space.presence.updated.on(ctx, onUpdate);
|
|
153
|
+
}
|
|
154
|
+
};
|
|
155
|
+
this.serviceContext.dataSpaceManager.updated.on(ctx, () => {
|
|
156
|
+
subscribeSpaces();
|
|
149
157
|
onUpdate();
|
|
150
|
-
}));
|
|
151
|
-
this.serviceContext.dataSpaceManager.spaces.forEach((space) => {
|
|
152
|
-
subscriptions.add(space.stateUpdate.on(onUpdate));
|
|
153
|
-
subscriptions.add(space.presence.updated.on(onUpdate));
|
|
154
158
|
});
|
|
159
|
+
subscribeSpaces();
|
|
155
160
|
onUpdate();
|
|
156
161
|
});
|
|
157
|
-
return () => subscriptions.clear();
|
|
158
162
|
});
|
|
159
163
|
}
|
|
160
164
|
async getSpaceDetails(request) {
|
|
161
165
|
return (0, import_debug.todo)();
|
|
162
166
|
}
|
|
163
167
|
async createSpace() {
|
|
168
|
+
if (!this.serviceContext.identityManager.identity) {
|
|
169
|
+
throw new Error("This device has no HALO identity available. See https://docs.dxos.org/guide/halo");
|
|
170
|
+
}
|
|
164
171
|
await this.serviceContext.initialized.wait();
|
|
165
172
|
const space = await this.serviceContext.dataSpaceManager.createSpace();
|
|
166
173
|
return {
|
|
@@ -193,7 +200,9 @@ var SpaceServiceImpl = class {
|
|
|
193
200
|
};
|
|
194
201
|
|
|
195
202
|
// packages/sdk/client-services/src/packlets/deprecated/profile.ts
|
|
203
|
+
var import_node_assert2 = __toESM(require("node:assert"));
|
|
196
204
|
var import_codec_protobuf2 = require("@dxos/codec-protobuf");
|
|
205
|
+
var import_credentials = require("@dxos/credentials");
|
|
197
206
|
var import_debug2 = require("@dxos/debug");
|
|
198
207
|
var ProfileServiceImpl = class {
|
|
199
208
|
constructor(context) {
|
|
@@ -208,7 +217,8 @@ var ProfileServiceImpl = class {
|
|
|
208
217
|
profile: this.context.identityManager.identity ? {
|
|
209
218
|
identityKey: this.context.identityManager.identity.identityKey,
|
|
210
219
|
deviceKey: this.context.identityManager.identity.deviceKey,
|
|
211
|
-
displayName: (_a = this.context.identityManager.identity.profileDocument) == null ? void 0 : _a.displayName
|
|
220
|
+
displayName: (_a = this.context.identityManager.identity.profileDocument) == null ? void 0 : _a.displayName,
|
|
221
|
+
haloSpace: this.context.identityManager.identity.space.key
|
|
212
222
|
} : void 0
|
|
213
223
|
});
|
|
214
224
|
};
|
|
@@ -224,7 +234,8 @@ var ProfileServiceImpl = class {
|
|
|
224
234
|
return {
|
|
225
235
|
identityKey: this.context.identityManager.identity.identityKey,
|
|
226
236
|
deviceKey: this.context.identityManager.identity.deviceKey,
|
|
227
|
-
displayName: (_a = this.context.identityManager.identity.profileDocument) == null ? void 0 : _a.displayName
|
|
237
|
+
displayName: (_a = this.context.identityManager.identity.profileDocument) == null ? void 0 : _a.displayName,
|
|
238
|
+
haloSpace: this.context.identityManager.identity.space.key
|
|
228
239
|
};
|
|
229
240
|
}
|
|
230
241
|
async recoverProfile(request) {
|
|
@@ -233,28 +244,38 @@ var ProfileServiceImpl = class {
|
|
|
233
244
|
throw new Error("Recovery SeedPhrase not provided.");
|
|
234
245
|
}
|
|
235
246
|
}
|
|
247
|
+
async signPresentation({ presentation, nonce }) {
|
|
248
|
+
(0, import_node_assert2.default)(this.context.identityManager.identity, "Identity not initialized.");
|
|
249
|
+
return await (0, import_credentials.signPresentation)({
|
|
250
|
+
presentation,
|
|
251
|
+
signer: this.context.keyring,
|
|
252
|
+
signerKey: this.context.identityManager.identity.deviceKey,
|
|
253
|
+
chain: this.context.identityManager.identity.deviceCredentialChain,
|
|
254
|
+
nonce
|
|
255
|
+
});
|
|
256
|
+
}
|
|
236
257
|
};
|
|
237
258
|
|
|
238
259
|
// packages/sdk/client-services/src/packlets/deprecated/system.ts
|
|
239
260
|
var SystemServiceImpl = class {
|
|
240
|
-
constructor(
|
|
241
|
-
this._config =
|
|
242
|
-
this.
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
async initSession() {
|
|
261
|
+
constructor({ config, onInit, onStatus, onReset }) {
|
|
262
|
+
this._config = config;
|
|
263
|
+
this._onInit = onInit;
|
|
264
|
+
this._onStatus = onStatus;
|
|
265
|
+
this._onReset = onReset;
|
|
246
266
|
}
|
|
247
|
-
async getConfig(
|
|
267
|
+
async getConfig() {
|
|
248
268
|
return this._config.values;
|
|
249
269
|
}
|
|
250
270
|
// TODO(burdon): Connect to iframe RPC heartbeat for network status?
|
|
251
|
-
async getStatus(
|
|
252
|
-
return
|
|
253
|
-
|
|
254
|
-
|
|
271
|
+
async getStatus() {
|
|
272
|
+
return this._onStatus();
|
|
273
|
+
}
|
|
274
|
+
async initSession() {
|
|
275
|
+
await this._onInit();
|
|
255
276
|
}
|
|
256
|
-
async reset(
|
|
257
|
-
await this.
|
|
277
|
+
async reset() {
|
|
278
|
+
await this._onReset();
|
|
258
279
|
}
|
|
259
280
|
};
|
|
260
281
|
|
|
@@ -272,79 +293,83 @@ var TracingServiceImpl = class {
|
|
|
272
293
|
};
|
|
273
294
|
|
|
274
295
|
// packages/sdk/client-services/src/packlets/devtools/devtools.ts
|
|
275
|
-
var
|
|
296
|
+
var import_async2 = require("@dxos/async");
|
|
276
297
|
var import_codec_protobuf7 = require("@dxos/codec-protobuf");
|
|
277
298
|
|
|
278
299
|
// packages/sdk/client-services/src/packlets/devtools/feeds.ts
|
|
279
|
-
var
|
|
300
|
+
var import_async = require("@dxos/async");
|
|
280
301
|
var import_codec_protobuf3 = require("@dxos/codec-protobuf");
|
|
281
302
|
var import_feed_store = require("@dxos/feed-store");
|
|
282
303
|
var import_keys = require("@dxos/keys");
|
|
283
304
|
var import_util2 = require("@dxos/util");
|
|
284
|
-
var subscribeToFeeds = ({ feedStore }, { feedKeys }) =>
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
}
|
|
288
|
-
const feedMap = new import_util2.ComplexMap(import_keys.PublicKey.hash);
|
|
289
|
-
const subscriptions = new import_async2.EventSubscriptions();
|
|
290
|
-
const update = () => {
|
|
291
|
-
const feeds = feedStore.feeds;
|
|
292
|
-
feeds.filter((feed) => !(feedKeys == null ? void 0 : feedKeys.length) || feedKeys.some((feedKey) => feedKey.equals(feed.key))).forEach((feed) => {
|
|
293
|
-
if (!feedMap.has(feed.key)) {
|
|
294
|
-
feedMap.set(feed.key, feed);
|
|
295
|
-
feed.on("close", update);
|
|
296
|
-
subscriptions.add(feed.off("close", update));
|
|
297
|
-
}
|
|
298
|
-
});
|
|
299
|
-
next({
|
|
300
|
-
feeds: Array.from(feedMap.values()).map((feed) => ({
|
|
301
|
-
feedKey: feed.key,
|
|
302
|
-
length: feed.properties.length
|
|
303
|
-
}))
|
|
304
|
-
});
|
|
305
|
-
};
|
|
306
|
-
subscriptions.add(feedStore.feedOpened.on(update));
|
|
307
|
-
update();
|
|
308
|
-
return () => {
|
|
309
|
-
subscriptions.clear();
|
|
310
|
-
};
|
|
311
|
-
});
|
|
312
|
-
var subscribeToFeedBlocks = ({ feedStore }, { feedKey, maxBlocks = 10 }) => new import_codec_protobuf3.Stream(({ next }) => {
|
|
313
|
-
if (!feedKey) {
|
|
314
|
-
return;
|
|
315
|
-
}
|
|
316
|
-
const subscriptions = new import_async2.EventSubscriptions();
|
|
317
|
-
const timeout = setTimeout(async () => {
|
|
318
|
-
const feed = feedStore.getFeed(feedKey);
|
|
319
|
-
if (!feed) {
|
|
305
|
+
var subscribeToFeeds = ({ feedStore }, { feedKeys }) => {
|
|
306
|
+
return new import_codec_protobuf3.Stream(({ next }) => {
|
|
307
|
+
if ((feedKeys == null ? void 0 : feedKeys.length) === 0) {
|
|
320
308
|
return;
|
|
321
309
|
}
|
|
322
|
-
const
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
const
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
310
|
+
const subscriptions = new import_async.EventSubscriptions();
|
|
311
|
+
const feedMap = new import_util2.ComplexMap(import_keys.PublicKey.hash);
|
|
312
|
+
const update = () => {
|
|
313
|
+
const { feeds } = feedStore;
|
|
314
|
+
feeds.filter((feed) => !(feedKeys == null ? void 0 : feedKeys.length) || feedKeys.some((feedKey) => feedKey.equals(feed.key))).forEach((feed) => {
|
|
315
|
+
if (!feedMap.has(feed.key)) {
|
|
316
|
+
feedMap.set(feed.key, feed);
|
|
317
|
+
feed.on("close", update);
|
|
318
|
+
subscriptions.add(feed.off("close", update));
|
|
330
319
|
}
|
|
331
|
-
}
|
|
320
|
+
});
|
|
332
321
|
next({
|
|
333
|
-
|
|
322
|
+
feeds: Array.from(feedMap.values()).map((feed) => ({
|
|
323
|
+
feedKey: feed.key,
|
|
324
|
+
length: feed.properties.length
|
|
325
|
+
}))
|
|
334
326
|
});
|
|
335
|
-
await iterator.close();
|
|
336
327
|
};
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
328
|
+
subscriptions.add(feedStore.feedOpened.on(update));
|
|
329
|
+
update();
|
|
330
|
+
return () => {
|
|
331
|
+
subscriptions.clear();
|
|
332
|
+
};
|
|
342
333
|
});
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
334
|
+
};
|
|
335
|
+
var subscribeToFeedBlocks = ({ feedStore }, { feedKey, maxBlocks = 10 }) => {
|
|
336
|
+
return new import_codec_protobuf3.Stream(({ next }) => {
|
|
337
|
+
if (!feedKey) {
|
|
338
|
+
return;
|
|
339
|
+
}
|
|
340
|
+
const subscriptions = new import_async.EventSubscriptions();
|
|
341
|
+
const timeout = setTimeout(async () => {
|
|
342
|
+
const feed = feedStore.getFeed(feedKey);
|
|
343
|
+
if (!feed) {
|
|
344
|
+
return;
|
|
345
|
+
}
|
|
346
|
+
const update = async () => {
|
|
347
|
+
const iterator = new import_feed_store.FeedIterator(feed);
|
|
348
|
+
await iterator.open();
|
|
349
|
+
const blocks = [];
|
|
350
|
+
for await (const block of iterator) {
|
|
351
|
+
blocks.push(block);
|
|
352
|
+
if (blocks.length >= feed.properties.length) {
|
|
353
|
+
break;
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
next({
|
|
357
|
+
blocks: blocks.slice(-maxBlocks)
|
|
358
|
+
});
|
|
359
|
+
await iterator.close();
|
|
360
|
+
};
|
|
361
|
+
feed.on("append", update);
|
|
362
|
+
subscriptions.add(() => feed.off("append", update));
|
|
363
|
+
feed.on("truncate", update);
|
|
364
|
+
subscriptions.add(() => feed.off("truncate", update));
|
|
365
|
+
await update();
|
|
366
|
+
});
|
|
367
|
+
return () => {
|
|
368
|
+
subscriptions.clear();
|
|
369
|
+
clearTimeout(timeout);
|
|
370
|
+
};
|
|
371
|
+
});
|
|
372
|
+
};
|
|
348
373
|
|
|
349
374
|
// packages/sdk/client-services/src/packlets/devtools/keys.ts
|
|
350
375
|
var import_codec_protobuf4 = require("@dxos/codec-protobuf");
|
|
@@ -361,6 +386,7 @@ var subscribeToKeyringKeys = ({ keyring }) => new import_codec_protobuf4.Stream(
|
|
|
361
386
|
|
|
362
387
|
// packages/sdk/client-services/src/packlets/devtools/network.ts
|
|
363
388
|
var import_codec_protobuf5 = require("@dxos/codec-protobuf");
|
|
389
|
+
var import_context = require("@dxos/context");
|
|
364
390
|
var import_keys2 = require("@dxos/keys");
|
|
365
391
|
var subscribeToNetworkStatus = ({ networkManager }) => new import_codec_protobuf5.Stream(({ next, close }) => {
|
|
366
392
|
const update = () => {
|
|
@@ -376,17 +402,27 @@ var subscribeToNetworkStatus = ({ networkManager }) => new import_codec_protobuf
|
|
|
376
402
|
networkManager.signalManager.statusChanged.on(update);
|
|
377
403
|
update();
|
|
378
404
|
});
|
|
379
|
-
var
|
|
380
|
-
|
|
381
|
-
|
|
405
|
+
var subscribeToSignal = ({ networkManager }) => new import_codec_protobuf5.Stream(({ next }) => {
|
|
406
|
+
const ctx = new import_context.Context();
|
|
407
|
+
networkManager.signalManager.onMessage.on(ctx, (message) => {
|
|
408
|
+
next({
|
|
409
|
+
message: {
|
|
410
|
+
author: message.author.asUint8Array(),
|
|
411
|
+
recipient: message.recipient.asUint8Array(),
|
|
412
|
+
payload: message.payload
|
|
413
|
+
},
|
|
414
|
+
receivedAt: new Date()
|
|
415
|
+
});
|
|
382
416
|
});
|
|
383
|
-
|
|
384
|
-
networkManager.signalManager.commandTrace.on((msg) => {
|
|
385
|
-
trace.push(msg);
|
|
417
|
+
networkManager.signalManager.swarmEvent.on(ctx, (swarmEvent) => {
|
|
386
418
|
next({
|
|
387
|
-
|
|
419
|
+
swarmEvent: swarmEvent.swarmEvent,
|
|
420
|
+
receivedAt: new Date()
|
|
388
421
|
});
|
|
389
422
|
});
|
|
423
|
+
return () => {
|
|
424
|
+
return ctx.dispose();
|
|
425
|
+
};
|
|
390
426
|
});
|
|
391
427
|
var subscribeToNetworkTopics = ({ networkManager }) => new import_codec_protobuf5.Stream(({ next, close }) => {
|
|
392
428
|
const update = () => {
|
|
@@ -438,42 +474,44 @@ var getNetworkPeers = ({ networkManager }, request) => {
|
|
|
438
474
|
|
|
439
475
|
// packages/sdk/client-services/src/packlets/devtools/spaces.ts
|
|
440
476
|
var import_codec_protobuf6 = require("@dxos/codec-protobuf");
|
|
441
|
-
var subscribeToSpaces = (context, { spaceKeys = [] }) =>
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
const
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
477
|
+
var subscribeToSpaces = (context, { spaceKeys = [] }) => {
|
|
478
|
+
return new import_codec_protobuf6.Stream(({ next }) => {
|
|
479
|
+
let unsubscribe;
|
|
480
|
+
const update = async () => {
|
|
481
|
+
const spaces = [
|
|
482
|
+
...context.spaceManager.spaces.values()
|
|
483
|
+
];
|
|
484
|
+
const filteredSpaces = spaces.filter((space) => !(spaceKeys == null ? void 0 : spaceKeys.length) || spaceKeys.some((spaceKey) => spaceKey.equals(space.key)));
|
|
485
|
+
next({
|
|
486
|
+
spaces: filteredSpaces.map((space) => {
|
|
487
|
+
const spaceMetadata = context.metadataStore.spaces.find((spaceMetadata2) => spaceMetadata2.key.equals(space.key));
|
|
488
|
+
return {
|
|
489
|
+
key: space.key,
|
|
490
|
+
isOpen: space.isOpen,
|
|
491
|
+
timeframe: spaceMetadata == null ? void 0 : spaceMetadata.dataTimeframe,
|
|
492
|
+
genesisFeed: space.genesisFeedKey,
|
|
493
|
+
controlFeed: space.controlFeedKey,
|
|
494
|
+
dataFeed: space.dataFeedKey
|
|
495
|
+
};
|
|
496
|
+
})
|
|
497
|
+
});
|
|
498
|
+
};
|
|
499
|
+
const timeout = setTimeout(async () => {
|
|
500
|
+
await context.initialized.wait();
|
|
501
|
+
unsubscribe = context.dataSpaceManager.updated.on(() => update());
|
|
502
|
+
await update();
|
|
503
|
+
});
|
|
504
|
+
return () => {
|
|
505
|
+
unsubscribe == null ? void 0 : unsubscribe();
|
|
506
|
+
clearTimeout(timeout);
|
|
507
|
+
};
|
|
466
508
|
});
|
|
467
|
-
|
|
468
|
-
unsubscribe == null ? void 0 : unsubscribe();
|
|
469
|
-
clearTimeout(timeout);
|
|
470
|
-
};
|
|
471
|
-
});
|
|
509
|
+
};
|
|
472
510
|
|
|
473
511
|
// packages/sdk/client-services/src/packlets/devtools/devtools.ts
|
|
474
512
|
var DevtoolsHostEvents = class {
|
|
475
513
|
constructor() {
|
|
476
|
-
this.ready = new
|
|
514
|
+
this.ready = new import_async2.Event();
|
|
477
515
|
}
|
|
478
516
|
};
|
|
479
517
|
var DevtoolsServiceImpl = class {
|
|
@@ -545,8 +583,8 @@ var DevtoolsServiceImpl = class {
|
|
|
545
583
|
networkManager: this.params.context.networkManager
|
|
546
584
|
});
|
|
547
585
|
}
|
|
548
|
-
|
|
549
|
-
return
|
|
586
|
+
subscribeToSignal() {
|
|
587
|
+
return subscribeToSignal({
|
|
550
588
|
networkManager: this.params.context.networkManager
|
|
551
589
|
});
|
|
552
590
|
}
|
|
@@ -558,9 +596,9 @@ var DevtoolsServiceImpl = class {
|
|
|
558
596
|
};
|
|
559
597
|
|
|
560
598
|
// packages/sdk/client-services/src/packlets/identity/authenticator.ts
|
|
561
|
-
var
|
|
562
|
-
var
|
|
563
|
-
var
|
|
599
|
+
var import_async3 = require("@dxos/async");
|
|
600
|
+
var import_context2 = require("@dxos/context");
|
|
601
|
+
var import_credentials2 = require("@dxos/credentials");
|
|
564
602
|
var import_log2 = require("@dxos/log");
|
|
565
603
|
var import_protocols = require("@dxos/protocols");
|
|
566
604
|
var createAuthProvider = (signer) => async (nonce) => {
|
|
@@ -574,17 +612,14 @@ var createAuthProvider = (signer) => async (nonce) => {
|
|
|
574
612
|
return import_protocols.schema.getCodecForType("dxos.halo.credentials.Credential").encode(credential);
|
|
575
613
|
};
|
|
576
614
|
var TrustedKeySetAuthVerifier = class {
|
|
615
|
+
// prettier-ignore
|
|
577
616
|
constructor(_params) {
|
|
578
617
|
this._params = _params;
|
|
579
|
-
this._ctx = new
|
|
618
|
+
this._ctx = new import_context2.Context();
|
|
580
619
|
}
|
|
581
620
|
async close() {
|
|
582
621
|
await this._ctx.dispose();
|
|
583
622
|
}
|
|
584
|
-
_isTrustedKey(deviceKey) {
|
|
585
|
-
const deviceSet = this._params.trustedKeysProvider();
|
|
586
|
-
return deviceSet.has(deviceKey);
|
|
587
|
-
}
|
|
588
623
|
get verifier() {
|
|
589
624
|
return async (nonce, auth) => {
|
|
590
625
|
const credential = import_protocols.schema.getCodecForType("dxos.halo.credentials.Credential").decode(auth);
|
|
@@ -592,17 +627,17 @@ var TrustedKeySetAuthVerifier = class {
|
|
|
592
627
|
credential
|
|
593
628
|
}, {
|
|
594
629
|
file: "authenticator.ts",
|
|
595
|
-
line:
|
|
630
|
+
line: 57,
|
|
596
631
|
scope: this,
|
|
597
632
|
callSite: (f, a) => f(...a)
|
|
598
633
|
});
|
|
599
|
-
const result = await (0,
|
|
634
|
+
const result = await (0, import_credentials2.verifyCredential)(credential);
|
|
600
635
|
if (result.kind === "fail") {
|
|
601
636
|
(0, import_log2.log)("Invalid credential", {
|
|
602
637
|
result
|
|
603
638
|
}, {
|
|
604
639
|
file: "authenticator.ts",
|
|
605
|
-
line:
|
|
640
|
+
line: 61,
|
|
606
641
|
scope: this,
|
|
607
642
|
callSite: (f, a) => f(...a)
|
|
608
643
|
});
|
|
@@ -614,7 +649,7 @@ var TrustedKeySetAuthVerifier = class {
|
|
|
614
649
|
credential
|
|
615
650
|
}, {
|
|
616
651
|
file: "authenticator.ts",
|
|
617
|
-
line:
|
|
652
|
+
line: 66,
|
|
618
653
|
scope: this,
|
|
619
654
|
callSite: (f, a) => f(...a)
|
|
620
655
|
});
|
|
@@ -625,13 +660,13 @@ var TrustedKeySetAuthVerifier = class {
|
|
|
625
660
|
key: credential.issuer
|
|
626
661
|
}, {
|
|
627
662
|
file: "authenticator.ts",
|
|
628
|
-
line:
|
|
663
|
+
line: 71,
|
|
629
664
|
scope: this,
|
|
630
665
|
callSite: (f, a) => f(...a)
|
|
631
666
|
});
|
|
632
667
|
return true;
|
|
633
668
|
}
|
|
634
|
-
const trigger = new
|
|
669
|
+
const trigger = new import_async3.Trigger();
|
|
635
670
|
this._ctx.onDispose(() => {
|
|
636
671
|
trigger.wake(false);
|
|
637
672
|
});
|
|
@@ -641,7 +676,7 @@ var TrustedKeySetAuthVerifier = class {
|
|
|
641
676
|
key: credential.issuer
|
|
642
677
|
}, {
|
|
643
678
|
file: "authenticator.ts",
|
|
644
|
-
line:
|
|
679
|
+
line: 82,
|
|
645
680
|
scope: this,
|
|
646
681
|
callSite: (f, a) => f(...a)
|
|
647
682
|
});
|
|
@@ -651,7 +686,7 @@ var TrustedKeySetAuthVerifier = class {
|
|
|
651
686
|
key: credential.issuer
|
|
652
687
|
}, {
|
|
653
688
|
file: "authenticator.ts",
|
|
654
|
-
line:
|
|
689
|
+
line: 85,
|
|
655
690
|
scope: this,
|
|
656
691
|
callSite: (f, a) => f(...a)
|
|
657
692
|
});
|
|
@@ -668,29 +703,34 @@ var TrustedKeySetAuthVerifier = class {
|
|
|
668
703
|
}
|
|
669
704
|
};
|
|
670
705
|
}
|
|
706
|
+
_isTrustedKey(deviceKey) {
|
|
707
|
+
const deviceSet = this._params.trustedKeysProvider();
|
|
708
|
+
return deviceSet.has(deviceKey);
|
|
709
|
+
}
|
|
671
710
|
};
|
|
672
711
|
|
|
673
712
|
// packages/sdk/client-services/src/packlets/identity/identity.ts
|
|
674
|
-
var
|
|
675
|
-
var
|
|
676
|
-
var
|
|
713
|
+
var import_node_assert3 = __toESM(require("node:assert"));
|
|
714
|
+
var import_async4 = require("@dxos/async");
|
|
715
|
+
var import_credentials3 = require("@dxos/credentials");
|
|
716
|
+
var import_debug3 = require("@dxos/debug");
|
|
677
717
|
var import_feed_store2 = require("@dxos/feed-store");
|
|
678
718
|
var import_log3 = require("@dxos/log");
|
|
679
|
-
var
|
|
719
|
+
var import_credentials4 = require("@dxos/protocols/proto/dxos/halo/credentials");
|
|
680
720
|
var AUTH_TIMEOUT = 3e4;
|
|
681
721
|
var Identity = class {
|
|
682
722
|
constructor({ space, signer, identityKey, deviceKey }) {
|
|
683
|
-
this.stateUpdate = new
|
|
723
|
+
this.stateUpdate = new import_async4.Event();
|
|
684
724
|
this.space = space;
|
|
685
725
|
this._signer = signer;
|
|
686
726
|
this.identityKey = identityKey;
|
|
687
727
|
this.deviceKey = deviceKey;
|
|
688
|
-
this._deviceStateMachine = this.space.spaceState.registerProcessor(new
|
|
728
|
+
this._deviceStateMachine = this.space.spaceState.registerProcessor(new import_credentials3.DeviceStateMachine({
|
|
689
729
|
identityKey: this.identityKey,
|
|
690
730
|
deviceKey: this.deviceKey,
|
|
691
731
|
onUpdate: () => this.stateUpdate.emit()
|
|
692
732
|
}));
|
|
693
|
-
this._profileStateMachine = this.space.spaceState.registerProcessor(new
|
|
733
|
+
this._profileStateMachine = this.space.spaceState.registerProcessor(new import_credentials3.ProfileStateMachine({
|
|
694
734
|
identityKey: this.identityKey,
|
|
695
735
|
onUpdate: () => this.stateUpdate.emit()
|
|
696
736
|
}));
|
|
@@ -717,6 +757,9 @@ var Identity = class {
|
|
|
717
757
|
}
|
|
718
758
|
async ready() {
|
|
719
759
|
await this._deviceStateMachine.processor.deviceChainReady.wait();
|
|
760
|
+
await this.controlPipeline.state.waitUntilReachedTargetTimeframe({
|
|
761
|
+
timeout: 3e3
|
|
762
|
+
});
|
|
720
763
|
}
|
|
721
764
|
get profileDocument() {
|
|
722
765
|
return this._profileStateMachine.processor.profile;
|
|
@@ -733,11 +776,15 @@ var Identity = class {
|
|
|
733
776
|
get haloGenesisFeedKey() {
|
|
734
777
|
return this.space.genesisFeedKey;
|
|
735
778
|
}
|
|
779
|
+
get deviceCredentialChain() {
|
|
780
|
+
return this._deviceStateMachine.processor.deviceCredentialChain;
|
|
781
|
+
}
|
|
736
782
|
getAdmissionCredentials() {
|
|
783
|
+
var _a, _b;
|
|
737
784
|
return {
|
|
738
785
|
deviceKey: this.deviceKey,
|
|
739
|
-
controlFeedKey: this.space.controlFeedKey,
|
|
740
|
-
dataFeedKey: this.space.dataFeedKey
|
|
786
|
+
controlFeedKey: (_a = this.space.controlFeedKey) != null ? _a : (0, import_debug3.failUndefined)(),
|
|
787
|
+
dataFeedKey: (_b = this.space.dataFeedKey) != null ? _b : (0, import_debug3.failUndefined)()
|
|
741
788
|
};
|
|
742
789
|
}
|
|
743
790
|
/**
|
|
@@ -745,14 +792,14 @@ var Identity = class {
|
|
|
745
792
|
* Requires identity to be ready.
|
|
746
793
|
*/
|
|
747
794
|
getIdentityCredentialSigner() {
|
|
748
|
-
(0,
|
|
749
|
-
return (0,
|
|
795
|
+
(0, import_node_assert3.default)(this._deviceStateMachine.processor.deviceCredentialChain, "Device credential chain is not ready.");
|
|
796
|
+
return (0, import_credentials3.createCredentialSignerWithChain)(this._signer, this._deviceStateMachine.processor.deviceCredentialChain, this.deviceKey);
|
|
750
797
|
}
|
|
751
798
|
/**
|
|
752
799
|
* Issues credentials as device.
|
|
753
800
|
*/
|
|
754
801
|
getDeviceCredentialSigner() {
|
|
755
|
-
return (0,
|
|
802
|
+
return (0, import_credentials3.createCredentialSignerWithKey)(this._signer, this.deviceKey);
|
|
756
803
|
}
|
|
757
804
|
async admitDevice({ deviceKey, controlFeedKey, dataFeedKey }) {
|
|
758
805
|
(0, import_log3.log)("Admitting device:", {
|
|
@@ -763,7 +810,7 @@ var Identity = class {
|
|
|
763
810
|
dataFeedKey
|
|
764
811
|
}, {
|
|
765
812
|
file: "identity.ts",
|
|
766
|
-
line:
|
|
813
|
+
line: 160,
|
|
767
814
|
scope: this,
|
|
768
815
|
callSite: (f, a) => f(...a)
|
|
769
816
|
});
|
|
@@ -784,7 +831,7 @@ var Identity = class {
|
|
|
784
831
|
spaceKey: this.haloSpaceKey,
|
|
785
832
|
deviceKey,
|
|
786
833
|
identityKey: this.identityKey,
|
|
787
|
-
designation:
|
|
834
|
+
designation: import_credentials4.AdmittedFeed.Designation.CONTROL
|
|
788
835
|
}
|
|
789
836
|
}),
|
|
790
837
|
await signer.createCredential({
|
|
@@ -794,31 +841,33 @@ var Identity = class {
|
|
|
794
841
|
spaceKey: this.haloSpaceKey,
|
|
795
842
|
deviceKey,
|
|
796
843
|
identityKey: this.identityKey,
|
|
797
|
-
designation:
|
|
844
|
+
designation: import_credentials4.AdmittedFeed.Designation.DATA
|
|
798
845
|
}
|
|
799
846
|
})
|
|
800
847
|
].map((credential) => ({
|
|
801
|
-
|
|
802
|
-
|
|
848
|
+
credential: {
|
|
849
|
+
credential
|
|
850
|
+
}
|
|
803
851
|
})));
|
|
804
852
|
}
|
|
805
853
|
};
|
|
806
854
|
|
|
807
855
|
// packages/sdk/client-services/src/packlets/identity/identity-manager.ts
|
|
808
|
-
var
|
|
809
|
-
var
|
|
810
|
-
var
|
|
856
|
+
var import_node_assert4 = __toESM(require("node:assert"));
|
|
857
|
+
var import_async5 = require("@dxos/async");
|
|
858
|
+
var import_credentials5 = require("@dxos/credentials");
|
|
811
859
|
var import_log4 = require("@dxos/log");
|
|
812
|
-
var
|
|
860
|
+
var import_credentials6 = require("@dxos/protocols/proto/dxos/halo/credentials");
|
|
813
861
|
var import_util3 = require("@dxos/util");
|
|
814
862
|
var IdentityManager = class {
|
|
815
863
|
// TODO(burdon): IdentityManagerParams.
|
|
816
864
|
// TODO(dmaretskyi): Perhaps this should take/generate the peerKey outside of an initialized identity.
|
|
817
|
-
constructor(_metadataStore, _keyring, _spaceManager) {
|
|
865
|
+
constructor(_metadataStore, _keyring, _feedStore, _spaceManager) {
|
|
818
866
|
this._metadataStore = _metadataStore;
|
|
819
867
|
this._keyring = _keyring;
|
|
868
|
+
this._feedStore = _feedStore;
|
|
820
869
|
this._spaceManager = _spaceManager;
|
|
821
|
-
this.stateUpdate = new
|
|
870
|
+
this.stateUpdate = new import_async5.Event();
|
|
822
871
|
}
|
|
823
872
|
get identity() {
|
|
824
873
|
return this._identity;
|
|
@@ -830,7 +879,7 @@ var IdentityManager = class {
|
|
|
830
879
|
identityRecord
|
|
831
880
|
}, {
|
|
832
881
|
file: "identity-manager.ts",
|
|
833
|
-
line:
|
|
882
|
+
line: 63,
|
|
834
883
|
scope: this,
|
|
835
884
|
callSite: (f, a) => f(...a)
|
|
836
885
|
});
|
|
@@ -846,10 +895,10 @@ var IdentityManager = class {
|
|
|
846
895
|
await ((_a = this._identity) == null ? void 0 : _a.close());
|
|
847
896
|
}
|
|
848
897
|
async createIdentity({ displayName } = {}) {
|
|
849
|
-
(0,
|
|
898
|
+
(0, import_node_assert4.default)(!this._identity, "Identity already exists.");
|
|
850
899
|
(0, import_log4.log)("creating identity...", {}, {
|
|
851
900
|
file: "identity-manager.ts",
|
|
852
|
-
line:
|
|
901
|
+
line: 78,
|
|
853
902
|
scope: this,
|
|
854
903
|
callSite: (f, a) => f(...a)
|
|
855
904
|
});
|
|
@@ -867,12 +916,12 @@ var IdentityManager = class {
|
|
|
867
916
|
const identity = await this._constructIdentity(identityRecord);
|
|
868
917
|
await identity.open();
|
|
869
918
|
{
|
|
870
|
-
const generator = new
|
|
919
|
+
const generator = new import_credentials5.CredentialGenerator(this._keyring, identityRecord.identityKey, identityRecord.deviceKey);
|
|
871
920
|
const credentials = [
|
|
872
921
|
// Space genesis.
|
|
873
922
|
...await generator.createSpaceGenesis(identityRecord.haloSpace.spaceKey, identityRecord.haloSpace.genesisFeedKey),
|
|
874
923
|
// Feed admission.
|
|
875
|
-
await generator.createFeedAdmission(identityRecord.haloSpace.spaceKey, identityRecord.haloSpace.writeDataFeedKey,
|
|
924
|
+
await generator.createFeedAdmission(identityRecord.haloSpace.spaceKey, identityRecord.haloSpace.writeDataFeedKey, import_credentials6.AdmittedFeed.Designation.DATA)
|
|
876
925
|
];
|
|
877
926
|
if (displayName) {
|
|
878
927
|
credentials.push(await generator.createProfileCredential({
|
|
@@ -882,8 +931,9 @@ var IdentityManager = class {
|
|
|
882
931
|
credentials.push(await generator.createDeviceAuthorization(identityRecord.deviceKey));
|
|
883
932
|
for (const credential of credentials) {
|
|
884
933
|
await identity.controlPipeline.writer.write({
|
|
885
|
-
|
|
886
|
-
|
|
934
|
+
credential: {
|
|
935
|
+
credential
|
|
936
|
+
}
|
|
887
937
|
});
|
|
888
938
|
}
|
|
889
939
|
}
|
|
@@ -896,7 +946,7 @@ var IdentityManager = class {
|
|
|
896
946
|
deviceKey: identity.deviceKey
|
|
897
947
|
}, {
|
|
898
948
|
file: "identity-manager.ts",
|
|
899
|
-
line:
|
|
949
|
+
line: 136,
|
|
900
950
|
scope: this,
|
|
901
951
|
callSite: (f, a) => f(...a)
|
|
902
952
|
});
|
|
@@ -910,47 +960,65 @@ var IdentityManager = class {
|
|
|
910
960
|
params
|
|
911
961
|
}, {
|
|
912
962
|
file: "identity-manager.ts",
|
|
913
|
-
line:
|
|
963
|
+
line: 144,
|
|
914
964
|
scope: this,
|
|
915
965
|
callSite: (f, a) => f(...a)
|
|
916
966
|
});
|
|
917
|
-
(0,
|
|
967
|
+
(0, import_node_assert4.default)(!this._identity, "Identity already exists.");
|
|
918
968
|
const identityRecord = {
|
|
919
969
|
identityKey: params.identityKey,
|
|
920
|
-
deviceKey:
|
|
970
|
+
deviceKey: params.deviceKey,
|
|
921
971
|
haloSpace: {
|
|
922
972
|
spaceKey: params.haloSpaceKey,
|
|
923
973
|
genesisFeedKey: params.haloGenesisFeedKey,
|
|
924
|
-
writeControlFeedKey:
|
|
925
|
-
writeDataFeedKey:
|
|
974
|
+
writeControlFeedKey: params.controlFeedKey,
|
|
975
|
+
writeDataFeedKey: params.dataFeedKey
|
|
926
976
|
}
|
|
927
977
|
};
|
|
928
978
|
const identity = await this._constructIdentity(identityRecord);
|
|
929
979
|
await identity.open();
|
|
930
980
|
this._identity = identity;
|
|
931
981
|
await this._metadataStore.setIdentityRecord(identityRecord);
|
|
982
|
+
await this._identity.ready();
|
|
932
983
|
this.stateUpdate.emit();
|
|
984
|
+
(0, import_log4.log)("accepted identity", {
|
|
985
|
+
identityKey: identity.identityKey,
|
|
986
|
+
deviceKey: identity.deviceKey
|
|
987
|
+
}, {
|
|
988
|
+
file: "identity-manager.ts",
|
|
989
|
+
line: 164,
|
|
990
|
+
scope: this,
|
|
991
|
+
callSite: (f, a) => f(...a)
|
|
992
|
+
});
|
|
933
993
|
return identity;
|
|
934
994
|
}
|
|
935
995
|
async _constructIdentity(identityRecord) {
|
|
936
|
-
(0,
|
|
996
|
+
(0, import_node_assert4.default)(!this._identity);
|
|
937
997
|
(0, import_log4.log)("constructing identity", {
|
|
938
998
|
identityRecord
|
|
939
999
|
}, {
|
|
940
1000
|
file: "identity-manager.ts",
|
|
941
|
-
line:
|
|
1001
|
+
line: 170,
|
|
942
1002
|
scope: this,
|
|
943
1003
|
callSite: (f, a) => f(...a)
|
|
944
1004
|
});
|
|
1005
|
+
const controlFeed = await this._feedStore.openFeed(identityRecord.haloSpace.writeControlFeedKey, {
|
|
1006
|
+
writable: true
|
|
1007
|
+
});
|
|
1008
|
+
const dataFeed = await this._feedStore.openFeed(identityRecord.haloSpace.writeDataFeedKey, {
|
|
1009
|
+
writable: true
|
|
1010
|
+
});
|
|
945
1011
|
const space = await this._constructSpace({
|
|
946
1012
|
spaceRecord: identityRecord.haloSpace,
|
|
947
1013
|
swarmIdentity: {
|
|
948
1014
|
peerKey: identityRecord.deviceKey,
|
|
949
|
-
credentialProvider: createAuthProvider((0,
|
|
1015
|
+
credentialProvider: createAuthProvider((0, import_credentials5.createCredentialSignerWithKey)(this._keyring, identityRecord.deviceKey)),
|
|
950
1016
|
credentialAuthenticator: (0, import_util3.deferFunction)(() => identity.authVerifier.verifier)
|
|
951
1017
|
},
|
|
952
1018
|
identityKey: identityRecord.identityKey
|
|
953
1019
|
});
|
|
1020
|
+
space.setControlFeed(controlFeed);
|
|
1021
|
+
space.setDataFeed(dataFeed);
|
|
954
1022
|
const identity = new Identity({
|
|
955
1023
|
space,
|
|
956
1024
|
signer: this._keyring,
|
|
@@ -961,7 +1029,7 @@ var IdentityManager = class {
|
|
|
961
1029
|
identityKey: identityRecord.identityKey
|
|
962
1030
|
}, {
|
|
963
1031
|
file: "identity-manager.ts",
|
|
964
|
-
line:
|
|
1032
|
+
line: 196,
|
|
965
1033
|
scope: this,
|
|
966
1034
|
callSite: (f, a) => f(...a)
|
|
967
1035
|
});
|
|
@@ -971,9 +1039,7 @@ var IdentityManager = class {
|
|
|
971
1039
|
return this._spaceManager.constructSpace({
|
|
972
1040
|
metadata: {
|
|
973
1041
|
key: spaceRecord.spaceKey,
|
|
974
|
-
genesisFeedKey: spaceRecord.genesisFeedKey
|
|
975
|
-
controlFeedKey: spaceRecord.writeControlFeedKey,
|
|
976
|
-
dataFeedKey: spaceRecord.writeDataFeedKey
|
|
1042
|
+
genesisFeedKey: spaceRecord.genesisFeedKey
|
|
977
1043
|
},
|
|
978
1044
|
swarmIdentity,
|
|
979
1045
|
onNetworkConnection: () => {
|
|
@@ -997,11 +1063,10 @@ var InvitationEncoder = class {
|
|
|
997
1063
|
};
|
|
998
1064
|
|
|
999
1065
|
// packages/sdk/client-services/src/packlets/invitations/halo-invitations-handler.ts
|
|
1000
|
-
var
|
|
1001
|
-
var
|
|
1002
|
-
var
|
|
1003
|
-
var
|
|
1004
|
-
var import_debug3 = require("@dxos/debug");
|
|
1066
|
+
var import_node_assert6 = __toESM(require("node:assert"));
|
|
1067
|
+
var import_async7 = require("@dxos/async");
|
|
1068
|
+
var import_context3 = require("@dxos/context");
|
|
1069
|
+
var import_credentials7 = require("@dxos/credentials");
|
|
1005
1070
|
var import_keys4 = require("@dxos/keys");
|
|
1006
1071
|
var import_log5 = require("@dxos/log");
|
|
1007
1072
|
var import_network_manager = require("@dxos/network-manager");
|
|
@@ -1011,13 +1076,13 @@ var import_invitations = require("@dxos/protocols/proto/dxos/halo/invitations");
|
|
|
1011
1076
|
var import_teleport = require("@dxos/teleport");
|
|
1012
1077
|
|
|
1013
1078
|
// packages/sdk/client-services/src/packlets/invitations/invitations.ts
|
|
1014
|
-
var
|
|
1015
|
-
var
|
|
1079
|
+
var import_node_assert5 = __toESM(require("node:assert"));
|
|
1080
|
+
var import_async6 = require("@dxos/async");
|
|
1016
1081
|
var import_services = require("@dxos/protocols/proto/dxos/client/services");
|
|
1017
1082
|
var AUTHENTICATION_CODE_LENGTH = 6;
|
|
1018
1083
|
var INVITATION_TIMEOUT = 3 * 6e4;
|
|
1019
|
-
var ON_CLOSE_DELAY =
|
|
1020
|
-
var InvitationObservableProvider = class extends
|
|
1084
|
+
var ON_CLOSE_DELAY = 1e3;
|
|
1085
|
+
var InvitationObservableProvider = class extends import_async6.CancellableObservableProvider {
|
|
1021
1086
|
get invitation() {
|
|
1022
1087
|
return this._invitation;
|
|
1023
1088
|
}
|
|
@@ -1039,7 +1104,7 @@ var wrapObservable = async (observable) => {
|
|
|
1039
1104
|
return new Promise((resolve, reject) => {
|
|
1040
1105
|
const unsubscribe = observable.subscribe({
|
|
1041
1106
|
onSuccess: (invitation) => {
|
|
1042
|
-
(0,
|
|
1107
|
+
(0, import_node_assert5.default)(invitation.state === import_services.Invitation.State.SUCCESS);
|
|
1043
1108
|
unsubscribe();
|
|
1044
1109
|
resolve(invitation);
|
|
1045
1110
|
},
|
|
@@ -1062,25 +1127,24 @@ var AbstractInvitationsHandler = class {
|
|
|
1062
1127
|
// packages/sdk/client-services/src/packlets/invitations/halo-invitations-handler.ts
|
|
1063
1128
|
var HaloInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
1064
1129
|
// prettier-ignore
|
|
1065
|
-
constructor(
|
|
1066
|
-
super(networkManager);
|
|
1067
|
-
this.
|
|
1130
|
+
constructor(_params) {
|
|
1131
|
+
super(_params.networkManager);
|
|
1132
|
+
this._params = _params;
|
|
1068
1133
|
}
|
|
1069
1134
|
/**
|
|
1070
1135
|
* Creates an invitation and listens for a join request from the invited (guest) peer.
|
|
1071
1136
|
*/
|
|
1072
1137
|
createInvitation(context, options) {
|
|
1073
|
-
var _a;
|
|
1074
1138
|
const { type, timeout = INVITATION_TIMEOUT, swarmKey } = options != null ? options : {};
|
|
1075
|
-
(0,
|
|
1076
|
-
const identity =
|
|
1139
|
+
(0, import_node_assert6.default)(type !== import_services2.Invitation.Type.OFFLINE);
|
|
1140
|
+
const identity = this._params.getIdentity();
|
|
1077
1141
|
const invitation = {
|
|
1078
1142
|
type,
|
|
1079
1143
|
invitationId: import_keys4.PublicKey.random().toHex(),
|
|
1080
1144
|
swarmKey: swarmKey != null ? swarmKey : import_keys4.PublicKey.random(),
|
|
1081
|
-
authenticationCode: (0,
|
|
1145
|
+
authenticationCode: (0, import_credentials7.generatePasscode)(AUTHENTICATION_CODE_LENGTH)
|
|
1082
1146
|
};
|
|
1083
|
-
const ctx = new
|
|
1147
|
+
const ctx = new import_context3.Context({
|
|
1084
1148
|
onError: (err) => {
|
|
1085
1149
|
void ctx.dispose();
|
|
1086
1150
|
observable.callback.onError(err);
|
|
@@ -1090,111 +1154,108 @@ var HaloInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
1090
1154
|
await ctx.dispose();
|
|
1091
1155
|
});
|
|
1092
1156
|
let authenticationCode;
|
|
1093
|
-
const complete = new
|
|
1094
|
-
const createExtension = () => {
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1157
|
+
const complete = new import_async7.Trigger();
|
|
1158
|
+
const createExtension = () => new HostHaloInvitationExtension({
|
|
1159
|
+
requestAdmission: async () => {
|
|
1160
|
+
var _a, _b;
|
|
1161
|
+
(0, import_log5.log)("responding with admission offer", {
|
|
1162
|
+
host: identity.deviceKey
|
|
1163
|
+
}, {
|
|
1164
|
+
file: "halo-invitations-handler.ts",
|
|
1165
|
+
line: 91,
|
|
1166
|
+
scope: this,
|
|
1167
|
+
callSite: (f, a) => f(...a)
|
|
1168
|
+
});
|
|
1169
|
+
(_b = (_a = observable.callback).onAuthenticating) == null ? void 0 : _b.call(_a, invitation);
|
|
1170
|
+
return {
|
|
1171
|
+
identityKey: identity.identityKey,
|
|
1172
|
+
haloSpaceKey: identity.haloSpaceKey,
|
|
1173
|
+
genesisFeedKey: identity.haloGenesisFeedKey
|
|
1174
|
+
};
|
|
1175
|
+
},
|
|
1176
|
+
authenticate: async ({ authenticationCode: code }) => {
|
|
1177
|
+
(0, import_log5.log)("received authentication request", {
|
|
1178
|
+
authenticationCode: code
|
|
1179
|
+
}, {
|
|
1180
|
+
file: "halo-invitations-handler.ts",
|
|
1181
|
+
line: 105,
|
|
1182
|
+
scope: this,
|
|
1183
|
+
callSite: (f, a) => f(...a)
|
|
1184
|
+
});
|
|
1185
|
+
authenticationCode = code;
|
|
1186
|
+
return {
|
|
1187
|
+
status: import_invitations.AuthenticationResponse.Status.OK
|
|
1188
|
+
};
|
|
1189
|
+
},
|
|
1190
|
+
// TODO(burdon): Not used: controlFeedKey, dataFeedKey.
|
|
1191
|
+
presentAdmissionCredentials: async (credentials) => {
|
|
1192
|
+
try {
|
|
1193
|
+
if (invitation.type !== import_services2.Invitation.Type.INTERACTIVE_TESTING) {
|
|
1194
|
+
if (invitation.authenticationCode === void 0 || invitation.authenticationCode !== authenticationCode) {
|
|
1195
|
+
throw new Error(`invalid authentication code: ${authenticationCode}`);
|
|
1196
|
+
}
|
|
1197
|
+
}
|
|
1198
|
+
(0, import_log5.log)("writing guest credentials", {
|
|
1199
|
+
host: identity.deviceKey,
|
|
1200
|
+
guest: credentials.deviceKey
|
|
1116
1201
|
}, {
|
|
1117
1202
|
file: "halo-invitations-handler.ts",
|
|
1118
|
-
line:
|
|
1203
|
+
line: 120,
|
|
1119
1204
|
scope: this,
|
|
1120
1205
|
callSite: (f, a) => f(...a)
|
|
1121
1206
|
});
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1207
|
+
await identity.admitDevice(credentials);
|
|
1208
|
+
complete.wake(credentials.deviceKey);
|
|
1209
|
+
} catch (err) {
|
|
1210
|
+
observable.callback.onError(err);
|
|
1211
|
+
throw err;
|
|
1212
|
+
}
|
|
1213
|
+
},
|
|
1214
|
+
onOpen: () => {
|
|
1215
|
+
(0, import_async7.scheduleTask)(ctx, async () => {
|
|
1216
|
+
var _a, _b;
|
|
1129
1217
|
try {
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1218
|
+
(0, import_log5.log)("connected", {
|
|
1219
|
+
host: identity.deviceKey
|
|
1220
|
+
}, {
|
|
1221
|
+
file: "halo-invitations-handler.ts",
|
|
1222
|
+
line: 136,
|
|
1223
|
+
scope: this,
|
|
1224
|
+
callSite: (f, a) => f(...a)
|
|
1225
|
+
});
|
|
1226
|
+
(_b = (_a = observable.callback).onConnected) == null ? void 0 : _b.call(_a, invitation);
|
|
1227
|
+
const deviceKey = await complete.wait({
|
|
1228
|
+
timeout
|
|
1229
|
+
});
|
|
1230
|
+
(0, import_log5.log)("admitted guest", {
|
|
1136
1231
|
host: identity.deviceKey,
|
|
1137
|
-
guest:
|
|
1232
|
+
guest: deviceKey
|
|
1138
1233
|
}, {
|
|
1139
1234
|
file: "halo-invitations-handler.ts",
|
|
1140
|
-
line:
|
|
1235
|
+
line: 139,
|
|
1141
1236
|
scope: this,
|
|
1142
1237
|
callSite: (f, a) => f(...a)
|
|
1143
1238
|
});
|
|
1144
|
-
|
|
1145
|
-
complete.wake(credentials.deviceKey);
|
|
1239
|
+
observable.callback.onSuccess(invitation);
|
|
1146
1240
|
} catch (err) {
|
|
1147
|
-
observable.
|
|
1148
|
-
|
|
1149
|
-
}
|
|
1150
|
-
},
|
|
1151
|
-
onOpen: () => {
|
|
1152
|
-
(0, import_async8.scheduleTask)(ctx, async () => {
|
|
1153
|
-
var _a2, _b;
|
|
1154
|
-
try {
|
|
1155
|
-
(0, import_log5.log)("connected", {
|
|
1156
|
-
host: identity.deviceKey
|
|
1157
|
-
}, {
|
|
1158
|
-
file: "halo-invitations-handler.ts",
|
|
1159
|
-
line: 129,
|
|
1160
|
-
scope: this,
|
|
1161
|
-
callSite: (f, a) => f(...a)
|
|
1162
|
-
});
|
|
1163
|
-
(_b = (_a2 = observable.callback).onConnected) == null ? void 0 : _b.call(_a2, invitation);
|
|
1164
|
-
const deviceKey = await complete.wait({
|
|
1165
|
-
timeout
|
|
1166
|
-
});
|
|
1167
|
-
(0, import_log5.log)("admitted guest", {
|
|
1168
|
-
host: identity.deviceKey,
|
|
1169
|
-
guest: deviceKey
|
|
1170
|
-
}, {
|
|
1241
|
+
if (!observable.cancelled) {
|
|
1242
|
+
import_log5.log.error("failed", err, {
|
|
1171
1243
|
file: "halo-invitations-handler.ts",
|
|
1172
|
-
line:
|
|
1244
|
+
line: 143,
|
|
1173
1245
|
scope: this,
|
|
1174
1246
|
callSite: (f, a) => f(...a)
|
|
1175
1247
|
});
|
|
1176
|
-
observable.callback.
|
|
1177
|
-
} catch (err) {
|
|
1178
|
-
if (!observable.cancelled) {
|
|
1179
|
-
import_log5.log.error("failed", err, {
|
|
1180
|
-
file: "halo-invitations-handler.ts",
|
|
1181
|
-
line: 136,
|
|
1182
|
-
scope: this,
|
|
1183
|
-
callSite: (f, a) => f(...a)
|
|
1184
|
-
});
|
|
1185
|
-
observable.callback.onError(err);
|
|
1186
|
-
}
|
|
1187
|
-
} finally {
|
|
1188
|
-
await (0, import_async8.sleep)(ON_CLOSE_DELAY);
|
|
1189
|
-
await ctx.dispose();
|
|
1248
|
+
observable.callback.onError(err);
|
|
1190
1249
|
}
|
|
1191
|
-
}
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1250
|
+
} finally {
|
|
1251
|
+
await (0, import_async7.sleep)(ON_CLOSE_DELAY);
|
|
1252
|
+
await ctx.dispose();
|
|
1253
|
+
}
|
|
1254
|
+
});
|
|
1255
|
+
}
|
|
1256
|
+
});
|
|
1257
|
+
(0, import_async7.scheduleTask)(ctx, async () => {
|
|
1258
|
+
var _a, _b;
|
|
1198
1259
|
const topic = invitation.swarmKey;
|
|
1199
1260
|
const swarmConnection = await this._networkManager.joinSwarm({
|
|
1200
1261
|
topic,
|
|
@@ -1205,7 +1266,7 @@ var HaloInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
1205
1266
|
topology: new import_network_manager.StarTopology(topic)
|
|
1206
1267
|
});
|
|
1207
1268
|
ctx.onDispose(() => swarmConnection.close());
|
|
1208
|
-
(_b = (
|
|
1269
|
+
(_b = (_a = observable.callback).onConnecting) == null ? void 0 : _b.call(_a, invitation);
|
|
1209
1270
|
});
|
|
1210
1271
|
return observable;
|
|
1211
1272
|
}
|
|
@@ -1216,13 +1277,13 @@ var HaloInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
1216
1277
|
*/
|
|
1217
1278
|
acceptInvitation(invitation, options) {
|
|
1218
1279
|
const { timeout = INVITATION_TIMEOUT } = options != null ? options : {};
|
|
1219
|
-
const ctx = new
|
|
1280
|
+
const ctx = new import_context3.Context({
|
|
1220
1281
|
onError: (err) => {
|
|
1221
1282
|
void ctx.dispose();
|
|
1222
1283
|
observable.callback.onError(err);
|
|
1223
1284
|
}
|
|
1224
1285
|
});
|
|
1225
|
-
const authenticated = new
|
|
1286
|
+
const authenticated = new import_async7.Trigger();
|
|
1226
1287
|
const observable = new AuthenticatingInvitationProvider({
|
|
1227
1288
|
onCancel: async () => {
|
|
1228
1289
|
await ctx.dispose();
|
|
@@ -1233,11 +1294,11 @@ var HaloInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
1233
1294
|
}
|
|
1234
1295
|
});
|
|
1235
1296
|
let connectionCount = 0;
|
|
1236
|
-
const complete = new
|
|
1297
|
+
const complete = new import_async7.Trigger();
|
|
1237
1298
|
const createExtension = () => {
|
|
1238
1299
|
const extension = new GuestHaloInvitationExtension({
|
|
1239
1300
|
onOpen: () => {
|
|
1240
|
-
(0,
|
|
1301
|
+
(0, import_async7.scheduleTask)(ctx, async () => {
|
|
1241
1302
|
var _a, _b, _c, _d;
|
|
1242
1303
|
try {
|
|
1243
1304
|
if (++connectionCount > 1) {
|
|
@@ -1245,14 +1306,14 @@ var HaloInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
1245
1306
|
}
|
|
1246
1307
|
(0, import_log5.log)("connected", {}, {
|
|
1247
1308
|
file: "halo-invitations-handler.ts",
|
|
1248
|
-
line:
|
|
1309
|
+
line: 214,
|
|
1249
1310
|
scope: this,
|
|
1250
1311
|
callSite: (f, a) => f(...a)
|
|
1251
1312
|
});
|
|
1252
1313
|
(_b = (_a = observable.callback).onConnected) == null ? void 0 : _b.call(_a, invitation);
|
|
1253
1314
|
(0, import_log5.log)("sending admission request", {}, {
|
|
1254
1315
|
file: "halo-invitations-handler.ts",
|
|
1255
|
-
line:
|
|
1316
|
+
line: 218,
|
|
1256
1317
|
scope: this,
|
|
1257
1318
|
callSite: (f, a) => f(...a)
|
|
1258
1319
|
});
|
|
@@ -1260,7 +1321,7 @@ var HaloInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
1260
1321
|
if (invitation.type === void 0 || invitation.type === import_services2.Invitation.Type.INTERACTIVE) {
|
|
1261
1322
|
(0, import_log5.log)("guest waiting for authentication code...", {}, {
|
|
1262
1323
|
file: "halo-invitations-handler.ts",
|
|
1263
|
-
line:
|
|
1324
|
+
line: 225,
|
|
1264
1325
|
scope: this,
|
|
1265
1326
|
callSite: (f, a) => f(...a)
|
|
1266
1327
|
});
|
|
@@ -1270,7 +1331,7 @@ var HaloInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
1270
1331
|
});
|
|
1271
1332
|
(0, import_log5.log)("sending authentication request", {}, {
|
|
1272
1333
|
file: "halo-invitations-handler.ts",
|
|
1273
|
-
line:
|
|
1334
|
+
line: 228,
|
|
1274
1335
|
scope: this,
|
|
1275
1336
|
callSite: (f, a) => f(...a)
|
|
1276
1337
|
});
|
|
@@ -1278,36 +1339,48 @@ var HaloInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
1278
1339
|
authenticationCode
|
|
1279
1340
|
});
|
|
1280
1341
|
}
|
|
1281
|
-
const
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
haloGenesisFeedKey: genesisFeedKey
|
|
1285
|
-
});
|
|
1342
|
+
const deviceKey = await this._params.keyring.createKey();
|
|
1343
|
+
const controlFeedKey = await this._params.keyring.createKey();
|
|
1344
|
+
const dataFeedKey = await this._params.keyring.createKey();
|
|
1286
1345
|
(0, import_log5.log)("presenting admission credentials", {
|
|
1287
|
-
|
|
1288
|
-
|
|
1346
|
+
identityKey,
|
|
1347
|
+
deviceKey,
|
|
1348
|
+
controlFeedKey,
|
|
1349
|
+
dataFeedKey
|
|
1289
1350
|
}, {
|
|
1290
1351
|
file: "halo-invitations-handler.ts",
|
|
1291
|
-
line:
|
|
1352
|
+
line: 237,
|
|
1292
1353
|
scope: this,
|
|
1293
1354
|
callSite: (f, a) => f(...a)
|
|
1294
1355
|
});
|
|
1295
|
-
await extension.rpc.HaloHostService.presentAdmissionCredentials(
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
}
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1356
|
+
await extension.rpc.HaloHostService.presentAdmissionCredentials({
|
|
1357
|
+
deviceKey,
|
|
1358
|
+
controlFeedKey,
|
|
1359
|
+
dataFeedKey
|
|
1360
|
+
});
|
|
1361
|
+
const identity = await this._params.acceptIdentity({
|
|
1362
|
+
identityKey,
|
|
1363
|
+
deviceKey,
|
|
1364
|
+
haloSpaceKey,
|
|
1365
|
+
haloGenesisFeedKey: genesisFeedKey,
|
|
1366
|
+
controlFeedKey,
|
|
1367
|
+
dataFeedKey
|
|
1368
|
+
});
|
|
1369
|
+
(0, import_log5.log)("admitted by host", {
|
|
1370
|
+
guest: identity.deviceKey,
|
|
1371
|
+
identityKey
|
|
1372
|
+
}, {
|
|
1373
|
+
file: "halo-invitations-handler.ts",
|
|
1374
|
+
line: 256,
|
|
1375
|
+
scope: this,
|
|
1376
|
+
callSite: (f, a) => f(...a)
|
|
1304
1377
|
});
|
|
1305
1378
|
complete.wake(identityKey);
|
|
1306
1379
|
} catch (err) {
|
|
1307
1380
|
if (!observable.cancelled) {
|
|
1308
1381
|
import_log5.log.warn("auth failed", err, {
|
|
1309
1382
|
file: "halo-invitations-handler.ts",
|
|
1310
|
-
line:
|
|
1383
|
+
line: 260,
|
|
1311
1384
|
scope: this,
|
|
1312
1385
|
callSite: (f, a) => f(...a)
|
|
1313
1386
|
});
|
|
@@ -1321,9 +1394,9 @@ var HaloInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
1321
1394
|
});
|
|
1322
1395
|
return extension;
|
|
1323
1396
|
};
|
|
1324
|
-
(0,
|
|
1397
|
+
(0, import_async7.scheduleTask)(ctx, async () => {
|
|
1325
1398
|
var _a, _b;
|
|
1326
|
-
(0,
|
|
1399
|
+
(0, import_node_assert6.default)(invitation.swarmKey);
|
|
1327
1400
|
const topic = invitation.swarmKey;
|
|
1328
1401
|
const swarmConnection = await this._networkManager.joinSwarm({
|
|
1329
1402
|
topic,
|
|
@@ -1393,8 +1466,8 @@ var GuestHaloInvitationExtension = class extends import_teleport.RpcExtension {
|
|
|
1393
1466
|
};
|
|
1394
1467
|
|
|
1395
1468
|
// packages/sdk/client-services/src/packlets/invitations/invitations-proxy.ts
|
|
1396
|
-
var
|
|
1397
|
-
var
|
|
1469
|
+
var import_node_assert7 = __toESM(require("node:assert"));
|
|
1470
|
+
var import_async8 = require("@dxos/async");
|
|
1398
1471
|
var import_log6 = require("@dxos/log");
|
|
1399
1472
|
var import_services3 = require("@dxos/protocols/proto/dxos/client/services");
|
|
1400
1473
|
var AbstractInvitationsProxy = class {
|
|
@@ -1421,7 +1494,7 @@ var AbstractInvitationsProxy = class {
|
|
|
1421
1494
|
observable.setInvitation(invitation2);
|
|
1422
1495
|
switch (invitation2.state) {
|
|
1423
1496
|
case import_services3.Invitation.State.CONNECTING: {
|
|
1424
|
-
(0,
|
|
1497
|
+
(0, import_node_assert7.default)(invitation2.invitationId);
|
|
1425
1498
|
invitationId = invitation2.invitationId;
|
|
1426
1499
|
(_b = (_a = observable.callback).onConnecting) == null ? void 0 : _b.call(_a, invitation2);
|
|
1427
1500
|
break;
|
|
@@ -1453,18 +1526,18 @@ var AbstractInvitationsProxy = class {
|
|
|
1453
1526
|
}
|
|
1454
1527
|
}, (err) => {
|
|
1455
1528
|
if (err) {
|
|
1456
|
-
(0,
|
|
1529
|
+
(0, import_async8.observableError)(observable, err);
|
|
1457
1530
|
}
|
|
1458
1531
|
});
|
|
1459
1532
|
return observable;
|
|
1460
1533
|
}
|
|
1461
1534
|
acceptInvitation(invitation, options) {
|
|
1462
|
-
(0,
|
|
1535
|
+
(0, import_node_assert7.default)(invitation && invitation.swarmKey);
|
|
1463
1536
|
const observable = new AuthenticatingInvitationProvider({
|
|
1464
1537
|
onCancel: async () => {
|
|
1465
1538
|
var _a;
|
|
1466
1539
|
const invitationId = (_a = observable.invitation) == null ? void 0 : _a.invitationId;
|
|
1467
|
-
(0,
|
|
1540
|
+
(0, import_node_assert7.default)(invitationId);
|
|
1468
1541
|
await this._invitationsService.cancelInvitation({
|
|
1469
1542
|
invitationId
|
|
1470
1543
|
});
|
|
@@ -1472,7 +1545,7 @@ var AbstractInvitationsProxy = class {
|
|
|
1472
1545
|
onAuthenticate: async (authenticationCode) => {
|
|
1473
1546
|
var _a;
|
|
1474
1547
|
const invitationId = (_a = observable.invitation) == null ? void 0 : _a.invitationId;
|
|
1475
|
-
(0,
|
|
1548
|
+
(0, import_node_assert7.default)(invitationId);
|
|
1476
1549
|
await this._invitationsService.authenticate({
|
|
1477
1550
|
invitationId,
|
|
1478
1551
|
authenticationCode
|
|
@@ -1485,7 +1558,7 @@ var AbstractInvitationsProxy = class {
|
|
|
1485
1558
|
});
|
|
1486
1559
|
stream.subscribe((invitation2) => {
|
|
1487
1560
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
1488
|
-
(0,
|
|
1561
|
+
(0, import_node_assert7.default)(invitation2.invitationId);
|
|
1489
1562
|
observable.setInvitation(invitation2);
|
|
1490
1563
|
switch (invitation2.state) {
|
|
1491
1564
|
case import_services3.Invitation.State.CONNECTING: {
|
|
@@ -1519,7 +1592,7 @@ var AbstractInvitationsProxy = class {
|
|
|
1519
1592
|
}
|
|
1520
1593
|
}, (err) => {
|
|
1521
1594
|
if (err) {
|
|
1522
|
-
(0,
|
|
1595
|
+
(0, import_async8.observableError)(observable, err);
|
|
1523
1596
|
}
|
|
1524
1597
|
});
|
|
1525
1598
|
return observable;
|
|
@@ -1534,7 +1607,7 @@ var HaloInvitationsProxy = class extends AbstractInvitationsProxy {
|
|
|
1534
1607
|
};
|
|
1535
1608
|
|
|
1536
1609
|
// packages/sdk/client-services/src/packlets/invitations/invitations-service.ts
|
|
1537
|
-
var
|
|
1610
|
+
var import_node_assert8 = __toESM(require("node:assert"));
|
|
1538
1611
|
var import_codec_protobuf8 = require("@dxos/codec-protobuf");
|
|
1539
1612
|
var import_log7 = require("@dxos/log");
|
|
1540
1613
|
var import_services4 = require("@dxos/protocols/proto/dxos/client/services");
|
|
@@ -1571,30 +1644,30 @@ var AbstractInvitationsService = class {
|
|
|
1571
1644
|
});
|
|
1572
1645
|
observable.subscribe({
|
|
1573
1646
|
onConnecting: (invitation2) => {
|
|
1574
|
-
(0,
|
|
1647
|
+
(0, import_node_assert8.default)(invitation2.invitationId);
|
|
1575
1648
|
invitationId = invitation2.invitationId;
|
|
1576
1649
|
this._createInvitations.set(invitation2.invitationId, observable);
|
|
1577
1650
|
invitation2.state = import_services4.Invitation.State.CONNECTING;
|
|
1578
1651
|
next(invitation2);
|
|
1579
1652
|
},
|
|
1580
1653
|
onConnected: (invitation2) => {
|
|
1581
|
-
(0,
|
|
1654
|
+
(0, import_node_assert8.default)(invitation2.invitationId);
|
|
1582
1655
|
invitation2.state = import_services4.Invitation.State.CONNECTED;
|
|
1583
1656
|
next(invitation2);
|
|
1584
1657
|
},
|
|
1585
1658
|
onAuthenticating: (invitation2) => {
|
|
1586
|
-
(0,
|
|
1659
|
+
(0, import_node_assert8.default)(invitation2.invitationId);
|
|
1587
1660
|
invitation2.state = import_services4.Invitation.State.AUTHENTICATING;
|
|
1588
1661
|
next(invitation2);
|
|
1589
1662
|
},
|
|
1590
1663
|
onSuccess: (invitation2) => {
|
|
1591
|
-
(0,
|
|
1664
|
+
(0, import_node_assert8.default)(invitation2.invitationId);
|
|
1592
1665
|
invitation2.state = import_services4.Invitation.State.SUCCESS;
|
|
1593
1666
|
next(invitation2);
|
|
1594
1667
|
close();
|
|
1595
1668
|
},
|
|
1596
1669
|
onCancelled: () => {
|
|
1597
|
-
(0,
|
|
1670
|
+
(0, import_node_assert8.default)(invitationId);
|
|
1598
1671
|
invitation.invitationId = invitationId;
|
|
1599
1672
|
invitation.state = import_services4.Invitation.State.CANCELLED;
|
|
1600
1673
|
next(invitation);
|
|
@@ -1646,19 +1719,19 @@ var AbstractInvitationsService = class {
|
|
|
1646
1719
|
const observable = invitationsHandler.acceptInvitation(invitation, options);
|
|
1647
1720
|
observable.subscribe({
|
|
1648
1721
|
onConnecting: (invitation2) => {
|
|
1649
|
-
(0,
|
|
1722
|
+
(0, import_node_assert8.default)(invitation2.invitationId);
|
|
1650
1723
|
invitationId = invitation2.invitationId;
|
|
1651
1724
|
this._acceptInvitations.set(invitation2.invitationId, observable);
|
|
1652
1725
|
invitation2.state = import_services4.Invitation.State.CONNECTING;
|
|
1653
1726
|
next(invitation2);
|
|
1654
1727
|
},
|
|
1655
1728
|
onConnected: (invitation2) => {
|
|
1656
|
-
(0,
|
|
1729
|
+
(0, import_node_assert8.default)(invitation2.invitationId);
|
|
1657
1730
|
invitation2.state = import_services4.Invitation.State.CONNECTED;
|
|
1658
1731
|
next(invitation2);
|
|
1659
1732
|
},
|
|
1660
1733
|
onAuthenticating: (invitation2) => {
|
|
1661
|
-
(0,
|
|
1734
|
+
(0, import_node_assert8.default)(invitation2.invitationId);
|
|
1662
1735
|
invitation2.state = import_services4.Invitation.State.AUTHENTICATING;
|
|
1663
1736
|
next(invitation2);
|
|
1664
1737
|
},
|
|
@@ -1668,7 +1741,7 @@ var AbstractInvitationsService = class {
|
|
|
1668
1741
|
close();
|
|
1669
1742
|
},
|
|
1670
1743
|
onCancelled: () => {
|
|
1671
|
-
(0,
|
|
1744
|
+
(0, import_node_assert8.default)(invitationId);
|
|
1672
1745
|
invitation.invitationId = invitationId;
|
|
1673
1746
|
invitation.state = import_services4.Invitation.State.CANCELLED;
|
|
1674
1747
|
next(invitation);
|
|
@@ -1714,7 +1787,7 @@ var AbstractInvitationsService = class {
|
|
|
1714
1787
|
scope: this,
|
|
1715
1788
|
callSite: (f, a) => f(...a)
|
|
1716
1789
|
});
|
|
1717
|
-
(0,
|
|
1790
|
+
(0, import_node_assert8.default)(invitationId);
|
|
1718
1791
|
const observable = this._acceptInvitations.get(invitationId);
|
|
1719
1792
|
if (!observable) {
|
|
1720
1793
|
import_log7.log.warn("invalid invitation", {
|
|
@@ -1737,7 +1810,7 @@ var AbstractInvitationsService = class {
|
|
|
1737
1810
|
scope: this,
|
|
1738
1811
|
callSite: (f, a) => f(...a)
|
|
1739
1812
|
});
|
|
1740
|
-
(0,
|
|
1813
|
+
(0, import_node_assert8.default)(invitation.invitationId);
|
|
1741
1814
|
const observable = (_a = this._createInvitations.get(invitation.invitationId)) != null ? _a : this._acceptInvitations.get(invitation.invitationId);
|
|
1742
1815
|
if (!observable) {
|
|
1743
1816
|
import_log7.log.warn("invalid invitation", {
|
|
@@ -1766,10 +1839,10 @@ var HaloInvitationsServiceImpl = class extends AbstractInvitationsService {
|
|
|
1766
1839
|
};
|
|
1767
1840
|
|
|
1768
1841
|
// packages/sdk/client-services/src/packlets/invitations/space-invitations-handler.ts
|
|
1769
|
-
var
|
|
1770
|
-
var
|
|
1771
|
-
var
|
|
1772
|
-
var
|
|
1842
|
+
var import_node_assert9 = __toESM(require("node:assert"));
|
|
1843
|
+
var import_async9 = require("@dxos/async");
|
|
1844
|
+
var import_context4 = require("@dxos/context");
|
|
1845
|
+
var import_credentials8 = require("@dxos/credentials");
|
|
1773
1846
|
var import_feed_store3 = require("@dxos/feed-store");
|
|
1774
1847
|
var import_keys5 = require("@dxos/keys");
|
|
1775
1848
|
var import_log8 = require("@dxos/log");
|
|
@@ -1792,16 +1865,16 @@ var SpaceInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
1792
1865
|
createInvitation(space, options) {
|
|
1793
1866
|
let swarmConnection;
|
|
1794
1867
|
const { type, timeout = INVITATION_TIMEOUT, swarmKey } = options != null ? options : {};
|
|
1795
|
-
(0,
|
|
1796
|
-
(0,
|
|
1868
|
+
(0, import_node_assert9.default)(type !== import_services5.Invitation.Type.OFFLINE);
|
|
1869
|
+
(0, import_node_assert9.default)(space);
|
|
1797
1870
|
const invitation = {
|
|
1798
1871
|
type,
|
|
1799
1872
|
invitationId: import_keys5.PublicKey.random().toHex(),
|
|
1800
1873
|
swarmKey: swarmKey != null ? swarmKey : import_keys5.PublicKey.random(),
|
|
1801
1874
|
spaceKey: space.key,
|
|
1802
|
-
authenticationCode: (0,
|
|
1875
|
+
authenticationCode: (0, import_credentials8.generatePasscode)(AUTHENTICATION_CODE_LENGTH)
|
|
1803
1876
|
};
|
|
1804
|
-
const ctx = new
|
|
1877
|
+
const ctx = new import_context4.Context({
|
|
1805
1878
|
onError: (err) => {
|
|
1806
1879
|
void ctx.dispose();
|
|
1807
1880
|
observable.callback.onError(err);
|
|
@@ -1813,7 +1886,7 @@ var SpaceInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
1813
1886
|
let authenticationCode;
|
|
1814
1887
|
let authenticationRetry = 0;
|
|
1815
1888
|
const createExtension = () => {
|
|
1816
|
-
const complete = new
|
|
1889
|
+
const complete = new import_async9.Trigger();
|
|
1817
1890
|
let guestProfile;
|
|
1818
1891
|
const hostInvitationExtension = new HostSpaceInvitationExtension({
|
|
1819
1892
|
introduce: async ({ profile }) => {
|
|
@@ -1824,7 +1897,7 @@ var SpaceInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
1824
1897
|
spaceKey: space.key
|
|
1825
1898
|
}, {
|
|
1826
1899
|
file: "space-invitations-handler.ts",
|
|
1827
|
-
line:
|
|
1900
|
+
line: 98,
|
|
1828
1901
|
scope: this,
|
|
1829
1902
|
callSite: (f, a) => f(...a)
|
|
1830
1903
|
});
|
|
@@ -1836,7 +1909,7 @@ var SpaceInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
1836
1909
|
authenticationCode: code
|
|
1837
1910
|
}, {
|
|
1838
1911
|
file: "space-invitations-handler.ts",
|
|
1839
|
-
line:
|
|
1912
|
+
line: 112,
|
|
1840
1913
|
scope: this,
|
|
1841
1914
|
callSite: (f, a) => f(...a)
|
|
1842
1915
|
});
|
|
@@ -1866,14 +1939,14 @@ var SpaceInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
1866
1939
|
guest: deviceKey
|
|
1867
1940
|
}, {
|
|
1868
1941
|
file: "space-invitations-handler.ts",
|
|
1869
|
-
line:
|
|
1942
|
+
line: 139,
|
|
1870
1943
|
scope: this,
|
|
1871
1944
|
callSite: (f, a) => f(...a)
|
|
1872
1945
|
});
|
|
1873
|
-
const credentials = await (0,
|
|
1874
|
-
(0,
|
|
1875
|
-
const spaceMemberCredential = credentials[0].credential;
|
|
1876
|
-
(0,
|
|
1946
|
+
const credentials = await (0, import_credentials8.createAdmissionCredentials)(this._signingContext.credentialSigner, identityKey, space.key, space.inner.genesisFeedKey, guestProfile);
|
|
1947
|
+
(0, import_node_assert9.default)(credentials[0].credential);
|
|
1948
|
+
const spaceMemberCredential = credentials[0].credential.credential;
|
|
1949
|
+
(0, import_node_assert9.default)((0, import_credentials8.getCredentialAssertion)(spaceMemberCredential)["@type"] === "dxos.halo.credentials.SpaceMember");
|
|
1877
1950
|
await (0, import_feed_store3.writeMessages)(space.inner.controlPipeline.writer, credentials);
|
|
1878
1951
|
complete.wake(deviceKey);
|
|
1879
1952
|
return {
|
|
@@ -1885,14 +1958,14 @@ var SpaceInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
1885
1958
|
}
|
|
1886
1959
|
},
|
|
1887
1960
|
onOpen: () => {
|
|
1888
|
-
(0,
|
|
1961
|
+
(0, import_async9.scheduleTask)(ctx, async () => {
|
|
1889
1962
|
var _a, _b;
|
|
1890
1963
|
try {
|
|
1891
1964
|
(0, import_log8.log)("connected", {
|
|
1892
1965
|
host: this._signingContext.deviceKey
|
|
1893
1966
|
}, {
|
|
1894
1967
|
file: "space-invitations-handler.ts",
|
|
1895
|
-
line:
|
|
1968
|
+
line: 170,
|
|
1896
1969
|
scope: this,
|
|
1897
1970
|
callSite: (f, a) => f(...a)
|
|
1898
1971
|
});
|
|
@@ -1905,7 +1978,7 @@ var SpaceInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
1905
1978
|
guest: deviceKey
|
|
1906
1979
|
}, {
|
|
1907
1980
|
file: "space-invitations-handler.ts",
|
|
1908
|
-
line:
|
|
1981
|
+
line: 173,
|
|
1909
1982
|
scope: this,
|
|
1910
1983
|
callSite: (f, a) => f(...a)
|
|
1911
1984
|
});
|
|
@@ -1914,7 +1987,7 @@ var SpaceInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
1914
1987
|
if (!observable.cancelled) {
|
|
1915
1988
|
import_log8.log.error("failed", err, {
|
|
1916
1989
|
file: "space-invitations-handler.ts",
|
|
1917
|
-
line:
|
|
1990
|
+
line: 177,
|
|
1918
1991
|
scope: this,
|
|
1919
1992
|
callSite: (f, a) => f(...a)
|
|
1920
1993
|
});
|
|
@@ -1922,7 +1995,7 @@ var SpaceInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
1922
1995
|
}
|
|
1923
1996
|
} finally {
|
|
1924
1997
|
if (type !== import_services5.Invitation.Type.MULTIUSE_TESTING) {
|
|
1925
|
-
await (0,
|
|
1998
|
+
await (0, import_async9.sleep)(ON_CLOSE_DELAY);
|
|
1926
1999
|
await ctx.dispose();
|
|
1927
2000
|
}
|
|
1928
2001
|
}
|
|
@@ -1931,7 +2004,7 @@ var SpaceInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
1931
2004
|
});
|
|
1932
2005
|
return hostInvitationExtension;
|
|
1933
2006
|
};
|
|
1934
|
-
(0,
|
|
2007
|
+
(0, import_async9.scheduleTask)(ctx, async () => {
|
|
1935
2008
|
var _a, _b;
|
|
1936
2009
|
const topic = invitation.swarmKey;
|
|
1937
2010
|
const swarmConnection2 = await this._networkManager.joinSwarm({
|
|
@@ -1954,13 +2027,13 @@ var SpaceInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
1954
2027
|
*/
|
|
1955
2028
|
acceptInvitation(invitation, options) {
|
|
1956
2029
|
const { timeout = INVITATION_TIMEOUT } = options != null ? options : {};
|
|
1957
|
-
const ctx = new
|
|
2030
|
+
const ctx = new import_context4.Context({
|
|
1958
2031
|
onError: (err) => {
|
|
1959
2032
|
void ctx.dispose();
|
|
1960
2033
|
observable.callback.onError(err);
|
|
1961
2034
|
}
|
|
1962
2035
|
});
|
|
1963
|
-
const authenticated = new
|
|
2036
|
+
const authenticated = new import_async9.Trigger();
|
|
1964
2037
|
const observable = new AuthenticatingInvitationProvider({
|
|
1965
2038
|
onCancel: async () => {
|
|
1966
2039
|
await ctx.dispose();
|
|
@@ -1970,11 +2043,11 @@ var SpaceInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
1970
2043
|
}
|
|
1971
2044
|
});
|
|
1972
2045
|
let connectionCount = 0;
|
|
1973
|
-
const complete = new
|
|
2046
|
+
const complete = new import_async9.Trigger();
|
|
1974
2047
|
const createExtension = () => {
|
|
1975
2048
|
const extension = new GuestSpaceInvitationExtension({
|
|
1976
2049
|
onOpen: () => {
|
|
1977
|
-
(0,
|
|
2050
|
+
(0, import_async9.scheduleTask)(ctx, async () => {
|
|
1978
2051
|
var _a, _b, _c, _d;
|
|
1979
2052
|
try {
|
|
1980
2053
|
if (++connectionCount > 1) {
|
|
@@ -1984,7 +2057,7 @@ var SpaceInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
1984
2057
|
guest: this._signingContext.deviceKey
|
|
1985
2058
|
}, {
|
|
1986
2059
|
file: "space-invitations-handler.ts",
|
|
1987
|
-
line:
|
|
2060
|
+
line: 250,
|
|
1988
2061
|
scope: this,
|
|
1989
2062
|
callSite: (f, a) => f(...a)
|
|
1990
2063
|
});
|
|
@@ -1993,7 +2066,7 @@ var SpaceInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
1993
2066
|
guest: this._signingContext.deviceKey
|
|
1994
2067
|
}, {
|
|
1995
2068
|
file: "space-invitations-handler.ts",
|
|
1996
|
-
line:
|
|
2069
|
+
line: 254,
|
|
1997
2070
|
scope: this,
|
|
1998
2071
|
callSite: (f, a) => f(...a)
|
|
1999
2072
|
});
|
|
@@ -2004,7 +2077,7 @@ var SpaceInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
2004
2077
|
for (let attempt = 1; attempt <= MAX_OTP_ATTEMPTS; attempt++) {
|
|
2005
2078
|
(0, import_log8.log)("guest waiting for authentication code...", {}, {
|
|
2006
2079
|
file: "space-invitations-handler.ts",
|
|
2007
|
-
line:
|
|
2080
|
+
line: 263,
|
|
2008
2081
|
scope: this,
|
|
2009
2082
|
callSite: (f, a) => f(...a)
|
|
2010
2083
|
});
|
|
@@ -2014,7 +2087,7 @@ var SpaceInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
2014
2087
|
});
|
|
2015
2088
|
(0, import_log8.log)("sending authentication request", {}, {
|
|
2016
2089
|
file: "space-invitations-handler.ts",
|
|
2017
|
-
line:
|
|
2090
|
+
line: 267,
|
|
2018
2091
|
scope: this,
|
|
2019
2092
|
callSite: (f, a) => f(...a)
|
|
2020
2093
|
});
|
|
@@ -2032,7 +2105,7 @@ var SpaceInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
2032
2105
|
attempt
|
|
2033
2106
|
}, {
|
|
2034
2107
|
file: "space-invitations-handler.ts",
|
|
2035
|
-
line:
|
|
2108
|
+
line: 277,
|
|
2036
2109
|
scope: this,
|
|
2037
2110
|
callSite: (f, a) => f(...a)
|
|
2038
2111
|
});
|
|
@@ -2047,7 +2120,7 @@ var SpaceInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
2047
2120
|
guest: this._signingContext.deviceKey
|
|
2048
2121
|
}, {
|
|
2049
2122
|
file: "space-invitations-handler.ts",
|
|
2050
|
-
line:
|
|
2123
|
+
line: 288,
|
|
2051
2124
|
scope: this,
|
|
2052
2125
|
callSite: (f, a) => f(...a)
|
|
2053
2126
|
});
|
|
@@ -2057,21 +2130,20 @@ var SpaceInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
2057
2130
|
controlFeedKey,
|
|
2058
2131
|
dataFeedKey
|
|
2059
2132
|
});
|
|
2060
|
-
const assertion = (0,
|
|
2061
|
-
(0,
|
|
2062
|
-
(0,
|
|
2133
|
+
const assertion = (0, import_credentials8.getCredentialAssertion)(credential);
|
|
2134
|
+
(0, import_node_assert9.default)(assertion["@type"] === "dxos.halo.credentials.SpaceMember", "Invalid credential");
|
|
2135
|
+
(0, import_node_assert9.default)(credential.subject.id.equals(this._signingContext.identityKey));
|
|
2063
2136
|
const space = await this._spaceManager.acceptSpace({
|
|
2064
2137
|
spaceKey: assertion.spaceKey,
|
|
2065
|
-
genesisFeedKey: assertion.genesisFeedKey
|
|
2066
|
-
controlFeedKey,
|
|
2067
|
-
dataFeedKey
|
|
2138
|
+
genesisFeedKey: assertion.genesisFeedKey
|
|
2068
2139
|
});
|
|
2140
|
+
await this._signingContext.recordCredential(credential);
|
|
2069
2141
|
(0, import_log8.log)("admitted by host", {
|
|
2070
2142
|
guest: this._signingContext.deviceKey,
|
|
2071
2143
|
spaceKey: space.key
|
|
2072
2144
|
}, {
|
|
2073
2145
|
file: "space-invitations-handler.ts",
|
|
2074
|
-
line:
|
|
2146
|
+
line: 310,
|
|
2075
2147
|
scope: this,
|
|
2076
2148
|
callSite: (f, a) => f(...a)
|
|
2077
2149
|
});
|
|
@@ -2080,7 +2152,7 @@ var SpaceInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
2080
2152
|
if (!observable.cancelled) {
|
|
2081
2153
|
import_log8.log.warn("auth failed", err, {
|
|
2082
2154
|
file: "space-invitations-handler.ts",
|
|
2083
|
-
line:
|
|
2155
|
+
line: 314,
|
|
2084
2156
|
scope: this,
|
|
2085
2157
|
callSite: (f, a) => f(...a)
|
|
2086
2158
|
});
|
|
@@ -2094,9 +2166,9 @@ var SpaceInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
2094
2166
|
});
|
|
2095
2167
|
return extension;
|
|
2096
2168
|
};
|
|
2097
|
-
(0,
|
|
2169
|
+
(0, import_async9.scheduleTask)(ctx, async () => {
|
|
2098
2170
|
var _a, _b;
|
|
2099
|
-
(0,
|
|
2171
|
+
(0, import_node_assert9.default)(invitation.swarmKey);
|
|
2100
2172
|
const topic = invitation.swarmKey;
|
|
2101
2173
|
const swarmConnection = await this._networkManager.joinSwarm({
|
|
2102
2174
|
topic,
|
|
@@ -2174,7 +2246,7 @@ var SpaceInvitationsProxy = class extends AbstractInvitationsProxy {
|
|
|
2174
2246
|
};
|
|
2175
2247
|
|
|
2176
2248
|
// packages/sdk/client-services/src/packlets/invitations/space-invitations-service.ts
|
|
2177
|
-
var
|
|
2249
|
+
var import_node_assert10 = __toESM(require("node:assert"));
|
|
2178
2250
|
var SpaceInvitationsServiceImpl = class extends AbstractInvitationsService {
|
|
2179
2251
|
// prettier-ignore
|
|
2180
2252
|
constructor(identityManager, invitationsHandler, _getSpaceManager) {
|
|
@@ -2183,39 +2255,280 @@ var SpaceInvitationsServiceImpl = class extends AbstractInvitationsService {
|
|
|
2183
2255
|
this._getSpaceManager = _getSpaceManager;
|
|
2184
2256
|
}
|
|
2185
2257
|
getContext(invitation) {
|
|
2186
|
-
(0,
|
|
2258
|
+
(0, import_node_assert10.default)(invitation.spaceKey);
|
|
2187
2259
|
const spaceManager = this._getSpaceManager();
|
|
2188
2260
|
const space = spaceManager.spaces.get(invitation.spaceKey);
|
|
2189
|
-
(0,
|
|
2261
|
+
(0, import_node_assert10.default)(space);
|
|
2190
2262
|
return space;
|
|
2191
2263
|
}
|
|
2192
2264
|
};
|
|
2193
2265
|
|
|
2194
2266
|
// packages/sdk/client-services/src/packlets/services/service-context.ts
|
|
2195
2267
|
var import_async13 = require("@dxos/async");
|
|
2196
|
-
var
|
|
2268
|
+
var import_credentials11 = require("@dxos/credentials");
|
|
2269
|
+
var import_debug5 = require("@dxos/debug");
|
|
2197
2270
|
var import_echo_db3 = require("@dxos/echo-db");
|
|
2198
2271
|
var import_feed_store4 = require("@dxos/feed-store");
|
|
2199
2272
|
var import_keyring = require("@dxos/keyring");
|
|
2200
|
-
var
|
|
2273
|
+
var import_log11 = require("@dxos/log");
|
|
2201
2274
|
|
|
2202
2275
|
// packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts
|
|
2203
|
-
var
|
|
2276
|
+
var import_node_assert12 = __toESM(require("node:assert"));
|
|
2204
2277
|
var import_async12 = require("@dxos/async");
|
|
2205
|
-
var
|
|
2278
|
+
var import_context7 = require("@dxos/context");
|
|
2279
|
+
var import_credentials10 = require("@dxos/credentials");
|
|
2206
2280
|
var import_echo_db2 = require("@dxos/echo-db");
|
|
2207
|
-
var
|
|
2208
|
-
var
|
|
2281
|
+
var import_keys8 = require("@dxos/keys");
|
|
2282
|
+
var import_log10 = require("@dxos/log");
|
|
2209
2283
|
var import_teleport_extension_presence = require("@dxos/teleport-extension-presence");
|
|
2210
|
-
var
|
|
2284
|
+
var import_util6 = require("@dxos/util");
|
|
2211
2285
|
|
|
2212
2286
|
// packages/sdk/client-services/src/packlets/spaces/data-space.ts
|
|
2213
|
-
var import_node_assert10 = __toESM(require("node:assert"));
|
|
2214
2287
|
var import_async11 = require("@dxos/async");
|
|
2215
|
-
var
|
|
2288
|
+
var import_context6 = require("@dxos/context");
|
|
2289
|
+
var import_debug4 = require("@dxos/debug");
|
|
2216
2290
|
var import_echo_db = require("@dxos/echo-db");
|
|
2291
|
+
var import_keys7 = require("@dxos/keys");
|
|
2292
|
+
var import_credentials9 = require("@dxos/protocols/proto/dxos/halo/credentials");
|
|
2293
|
+
var import_util5 = require("@dxos/util");
|
|
2294
|
+
|
|
2295
|
+
// packages/sdk/client-services/src/packlets/spaces/notarization-plugin.ts
|
|
2296
|
+
var import_node_assert11 = __toESM(require("node:assert"));
|
|
2297
|
+
var import_async10 = require("@dxos/async");
|
|
2298
|
+
var import_context5 = require("@dxos/context");
|
|
2217
2299
|
var import_keys6 = require("@dxos/keys");
|
|
2300
|
+
var import_log9 = require("@dxos/log");
|
|
2301
|
+
var import_protocols5 = require("@dxos/protocols");
|
|
2302
|
+
var import_teleport3 = require("@dxos/teleport");
|
|
2218
2303
|
var import_util4 = require("@dxos/util");
|
|
2304
|
+
var RETRY_TIMEOUT = 1e3;
|
|
2305
|
+
var NOTARIZE_TIMEOUT = 1e4;
|
|
2306
|
+
var NotarizationPlugin = class {
|
|
2307
|
+
constructor() {
|
|
2308
|
+
this._ctx = new import_context5.Context();
|
|
2309
|
+
this._extensionOpened = new import_async10.Event();
|
|
2310
|
+
this._extensions = /* @__PURE__ */ new Set();
|
|
2311
|
+
this._processedCredentials = new import_util4.ComplexSet(import_keys6.PublicKey.hash);
|
|
2312
|
+
this._processCredentialsTriggers = new import_util4.ComplexMap(import_keys6.PublicKey.hash);
|
|
2313
|
+
}
|
|
2314
|
+
async open() {
|
|
2315
|
+
}
|
|
2316
|
+
async close() {
|
|
2317
|
+
await this._ctx.dispose();
|
|
2318
|
+
}
|
|
2319
|
+
/**
|
|
2320
|
+
* Request credentials to be notarized.
|
|
2321
|
+
*/
|
|
2322
|
+
async notarize(credentials) {
|
|
2323
|
+
(0, import_log9.log)("notarize", {
|
|
2324
|
+
credentials
|
|
2325
|
+
}, {
|
|
2326
|
+
file: "notarization-plugin.ts",
|
|
2327
|
+
line: 44,
|
|
2328
|
+
scope: this,
|
|
2329
|
+
callSite: (f, a) => f(...a)
|
|
2330
|
+
});
|
|
2331
|
+
(0, import_node_assert11.default)(credentials.every((credential) => credential.id), "Credentials must have an id");
|
|
2332
|
+
const errors = new import_async10.Trigger();
|
|
2333
|
+
const ctx = this._ctx.derive({
|
|
2334
|
+
onError: (err) => {
|
|
2335
|
+
import_log9.log.warn("Notarization error", {
|
|
2336
|
+
err
|
|
2337
|
+
}, {
|
|
2338
|
+
file: "notarization-plugin.ts",
|
|
2339
|
+
line: 53,
|
|
2340
|
+
scope: this,
|
|
2341
|
+
callSite: (f, a) => f(...a)
|
|
2342
|
+
});
|
|
2343
|
+
void ctx.dispose();
|
|
2344
|
+
errors.throw(err);
|
|
2345
|
+
}
|
|
2346
|
+
});
|
|
2347
|
+
(0, import_async10.scheduleTask)(ctx, () => {
|
|
2348
|
+
import_log9.log.warn("Notarization timeout", {}, {
|
|
2349
|
+
file: "notarization-plugin.ts",
|
|
2350
|
+
line: 61,
|
|
2351
|
+
scope: this,
|
|
2352
|
+
callSite: (f, a) => f(...a)
|
|
2353
|
+
});
|
|
2354
|
+
void ctx.dispose();
|
|
2355
|
+
errors.throw(new import_async10.TimeoutError(NOTARIZE_TIMEOUT, "Notarization timed out"));
|
|
2356
|
+
}, NOTARIZE_TIMEOUT);
|
|
2357
|
+
const allNotarized = Promise.all(credentials.map((credential) => this._waitUntilProcessed(credential.id)));
|
|
2358
|
+
const peersTried = /* @__PURE__ */ new Set();
|
|
2359
|
+
const notarizeTask = new import_async10.DeferredTask(ctx, async () => {
|
|
2360
|
+
try {
|
|
2361
|
+
if (this._extensions.size === 0) {
|
|
2362
|
+
import_log9.log.warn("No peers to notarize with", {}, {
|
|
2363
|
+
file: "notarization-plugin.ts",
|
|
2364
|
+
line: 76,
|
|
2365
|
+
scope: this,
|
|
2366
|
+
callSite: (f, a) => f(...a)
|
|
2367
|
+
});
|
|
2368
|
+
return;
|
|
2369
|
+
}
|
|
2370
|
+
const peer = [
|
|
2371
|
+
...this._extensions
|
|
2372
|
+
].find((peer2) => !peersTried.has(peer2));
|
|
2373
|
+
if (!peer) {
|
|
2374
|
+
import_log9.log.warn("Exhausted all peers to notarize with", {
|
|
2375
|
+
retryIn: RETRY_TIMEOUT
|
|
2376
|
+
}, {
|
|
2377
|
+
file: "notarization-plugin.ts",
|
|
2378
|
+
line: 83,
|
|
2379
|
+
scope: this,
|
|
2380
|
+
callSite: (f, a) => f(...a)
|
|
2381
|
+
});
|
|
2382
|
+
peersTried.clear();
|
|
2383
|
+
(0, import_async10.scheduleTask)(ctx, () => notarizeTask.schedule(), RETRY_TIMEOUT);
|
|
2384
|
+
return;
|
|
2385
|
+
}
|
|
2386
|
+
peersTried.add(peer);
|
|
2387
|
+
(0, import_log9.log)("try notarizing", {
|
|
2388
|
+
peer: peer.localPeerId,
|
|
2389
|
+
credentialId: credentials.map((credential) => credential.id)
|
|
2390
|
+
}, {
|
|
2391
|
+
file: "notarization-plugin.ts",
|
|
2392
|
+
line: 90,
|
|
2393
|
+
scope: this,
|
|
2394
|
+
callSite: (f, a) => f(...a)
|
|
2395
|
+
});
|
|
2396
|
+
await peer.rpc.NotarizationService.notarize({
|
|
2397
|
+
credentials: credentials.filter((credential) => !this._processedCredentials.has(credential.id))
|
|
2398
|
+
});
|
|
2399
|
+
(0, import_log9.log)("success", {}, {
|
|
2400
|
+
file: "notarization-plugin.ts",
|
|
2401
|
+
line: 94,
|
|
2402
|
+
scope: this,
|
|
2403
|
+
callSite: (f, a) => f(...a)
|
|
2404
|
+
});
|
|
2405
|
+
} catch (err) {
|
|
2406
|
+
import_log9.log.warn("error notarizing (recoverable)", err, {
|
|
2407
|
+
file: "notarization-plugin.ts",
|
|
2408
|
+
line: 96,
|
|
2409
|
+
scope: this,
|
|
2410
|
+
callSite: (f, a) => f(...a)
|
|
2411
|
+
});
|
|
2412
|
+
notarizeTask.schedule();
|
|
2413
|
+
}
|
|
2414
|
+
});
|
|
2415
|
+
notarizeTask.schedule();
|
|
2416
|
+
this._extensionOpened.on(ctx, () => notarizeTask.schedule());
|
|
2417
|
+
try {
|
|
2418
|
+
await Promise.race([
|
|
2419
|
+
allNotarized,
|
|
2420
|
+
errors.wait()
|
|
2421
|
+
]);
|
|
2422
|
+
(0, import_log9.log)("done", {}, {
|
|
2423
|
+
file: "notarization-plugin.ts",
|
|
2424
|
+
line: 107,
|
|
2425
|
+
scope: this,
|
|
2426
|
+
callSite: (f, a) => f(...a)
|
|
2427
|
+
});
|
|
2428
|
+
} finally {
|
|
2429
|
+
await ctx.dispose();
|
|
2430
|
+
}
|
|
2431
|
+
}
|
|
2432
|
+
/**
|
|
2433
|
+
* Called with credentials arriving from the control pipeline.
|
|
2434
|
+
*/
|
|
2435
|
+
async process(credential) {
|
|
2436
|
+
var _a;
|
|
2437
|
+
if (!credential.id) {
|
|
2438
|
+
return;
|
|
2439
|
+
}
|
|
2440
|
+
(_a = this._processCredentialsTriggers.get(credential.id)) == null ? void 0 : _a.wake();
|
|
2441
|
+
this._processedCredentials.add(credential.id);
|
|
2442
|
+
this._processCredentialsTriggers.delete(credential.id);
|
|
2443
|
+
}
|
|
2444
|
+
setWriter(writer) {
|
|
2445
|
+
(0, import_node_assert11.default)(!this._writer, "Writer already set.");
|
|
2446
|
+
this._writer = writer;
|
|
2447
|
+
}
|
|
2448
|
+
async _waitUntilProcessed(id) {
|
|
2449
|
+
if (this._processedCredentials.has(id)) {
|
|
2450
|
+
return;
|
|
2451
|
+
}
|
|
2452
|
+
await (0, import_util4.entry)(this._processCredentialsTriggers, id).orInsert(new import_async10.Trigger()).value.wait();
|
|
2453
|
+
}
|
|
2454
|
+
/**
|
|
2455
|
+
* Requests from other peers to notarize credentials.
|
|
2456
|
+
*/
|
|
2457
|
+
async _onNotarize(request) {
|
|
2458
|
+
var _a;
|
|
2459
|
+
if (!this._writer) {
|
|
2460
|
+
throw new Error("Writer not set");
|
|
2461
|
+
}
|
|
2462
|
+
for (const credential of (_a = request.credentials) != null ? _a : []) {
|
|
2463
|
+
(0, import_node_assert11.default)(credential.id, "Credential must have an id");
|
|
2464
|
+
if (this._processedCredentials.has(credential.id)) {
|
|
2465
|
+
continue;
|
|
2466
|
+
}
|
|
2467
|
+
await this._writer.write(credential);
|
|
2468
|
+
}
|
|
2469
|
+
}
|
|
2470
|
+
createExtension() {
|
|
2471
|
+
const extension = new NotarizationTeleportExtension({
|
|
2472
|
+
onOpen: async () => {
|
|
2473
|
+
(0, import_log9.log)("extension opened", {
|
|
2474
|
+
peer: extension.localPeerId
|
|
2475
|
+
}, {
|
|
2476
|
+
file: "notarization-plugin.ts",
|
|
2477
|
+
line: 156,
|
|
2478
|
+
scope: this,
|
|
2479
|
+
callSite: (f, a) => f(...a)
|
|
2480
|
+
});
|
|
2481
|
+
this._extensions.add(extension);
|
|
2482
|
+
this._extensionOpened.emit();
|
|
2483
|
+
},
|
|
2484
|
+
onClose: async () => {
|
|
2485
|
+
(0, import_log9.log)("extension closed", {
|
|
2486
|
+
peer: extension.localPeerId
|
|
2487
|
+
}, {
|
|
2488
|
+
file: "notarization-plugin.ts",
|
|
2489
|
+
line: 161,
|
|
2490
|
+
scope: this,
|
|
2491
|
+
callSite: (f, a) => f(...a)
|
|
2492
|
+
});
|
|
2493
|
+
this._extensions.delete(extension);
|
|
2494
|
+
},
|
|
2495
|
+
onNotarize: this._onNotarize.bind(this)
|
|
2496
|
+
});
|
|
2497
|
+
return extension;
|
|
2498
|
+
}
|
|
2499
|
+
};
|
|
2500
|
+
var NotarizationTeleportExtension = class extends import_teleport3.RpcExtension {
|
|
2501
|
+
constructor(_params) {
|
|
2502
|
+
super({
|
|
2503
|
+
requested: {
|
|
2504
|
+
NotarizationService: import_protocols5.schema.getService("dxos.mesh.teleport.notarization.NotarizationService")
|
|
2505
|
+
},
|
|
2506
|
+
exposed: {
|
|
2507
|
+
NotarizationService: import_protocols5.schema.getService("dxos.mesh.teleport.notarization.NotarizationService")
|
|
2508
|
+
}
|
|
2509
|
+
});
|
|
2510
|
+
this._params = _params;
|
|
2511
|
+
}
|
|
2512
|
+
async getHandlers() {
|
|
2513
|
+
return {
|
|
2514
|
+
NotarizationService: {
|
|
2515
|
+
notarize: async (request) => {
|
|
2516
|
+
await this._params.onNotarize(request);
|
|
2517
|
+
}
|
|
2518
|
+
}
|
|
2519
|
+
};
|
|
2520
|
+
}
|
|
2521
|
+
async onOpen(ctx) {
|
|
2522
|
+
await super.onOpen(ctx);
|
|
2523
|
+
await this._params.onOpen();
|
|
2524
|
+
}
|
|
2525
|
+
async onClose(err) {
|
|
2526
|
+
await this._params.onClose();
|
|
2527
|
+
await super.onClose(err);
|
|
2528
|
+
}
|
|
2529
|
+
};
|
|
2530
|
+
|
|
2531
|
+
// packages/sdk/client-services/src/packlets/spaces/data-space.ts
|
|
2219
2532
|
var __decorate = function(decorators, target, key, desc) {
|
|
2220
2533
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2221
2534
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
@@ -2227,11 +2540,16 @@ var __decorate = function(decorators, target, key, desc) {
|
|
|
2227
2540
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2228
2541
|
};
|
|
2229
2542
|
var AUTH_TIMEOUT2 = 3e4;
|
|
2543
|
+
var CONTROL_PIPELINE_READY_TIMEFRAME = 3e3;
|
|
2230
2544
|
var DataSpace = class DataSpace2 {
|
|
2231
2545
|
constructor(params) {
|
|
2232
|
-
this._ctx = new
|
|
2546
|
+
this._ctx = new import_context6.Context();
|
|
2233
2547
|
this._inner = params.inner;
|
|
2234
2548
|
this._presence = params.presence;
|
|
2549
|
+
this._keyring = params.keyring;
|
|
2550
|
+
this._feedStore = params.feedStore;
|
|
2551
|
+
this._metadataStore = params.metadataStore;
|
|
2552
|
+
this._signingContext = params.signingContext;
|
|
2235
2553
|
this._dataPipelineController = new import_echo_db.DataPipelineControllerImpl({
|
|
2236
2554
|
modelFactory: params.modelFactory,
|
|
2237
2555
|
metadataStore: params.metadataStore,
|
|
@@ -2242,44 +2560,102 @@ var DataSpace = class DataSpace2 {
|
|
|
2242
2560
|
snapshotId: params.snapshotId
|
|
2243
2561
|
});
|
|
2244
2562
|
this.authVerifier = new TrustedKeySetAuthVerifier({
|
|
2245
|
-
trustedKeysProvider: () => new
|
|
2563
|
+
trustedKeysProvider: () => new import_util5.ComplexSet(import_keys7.PublicKey.hash, Array.from(this._inner.spaceState.members.keys())),
|
|
2246
2564
|
update: this._inner.stateUpdate,
|
|
2247
2565
|
authTimeout: AUTH_TIMEOUT2
|
|
2248
2566
|
});
|
|
2567
|
+
this._notarizationPluginConsumer = this._inner.spaceState.registerProcessor(new NotarizationPlugin());
|
|
2249
2568
|
}
|
|
2250
2569
|
get key() {
|
|
2251
2570
|
return this._inner.key;
|
|
2252
2571
|
}
|
|
2253
|
-
get inner() {
|
|
2254
|
-
return this._inner;
|
|
2255
|
-
}
|
|
2256
2572
|
get isOpen() {
|
|
2257
2573
|
return this._inner.isOpen;
|
|
2258
2574
|
}
|
|
2575
|
+
// TODO(burdon): Can we mark this for debugging only?
|
|
2576
|
+
get inner() {
|
|
2577
|
+
return this._inner;
|
|
2578
|
+
}
|
|
2259
2579
|
get dataPipelineController() {
|
|
2260
2580
|
return this._dataPipelineController;
|
|
2261
2581
|
}
|
|
2262
|
-
get database() {
|
|
2263
|
-
(0, import_node_assert10.default)(this._dataPipelineController.database);
|
|
2264
|
-
return this._dataPipelineController.database;
|
|
2265
|
-
}
|
|
2266
2582
|
get stateUpdate() {
|
|
2267
2583
|
return this._inner.stateUpdate;
|
|
2268
2584
|
}
|
|
2269
2585
|
get presence() {
|
|
2270
2586
|
return this._presence;
|
|
2271
2587
|
}
|
|
2588
|
+
get notarizationPlugin() {
|
|
2589
|
+
return this._notarizationPluginConsumer.processor;
|
|
2590
|
+
}
|
|
2272
2591
|
async open() {
|
|
2592
|
+
await this.notarizationPlugin.open();
|
|
2593
|
+
await this._notarizationPluginConsumer.open();
|
|
2273
2594
|
await this._inner.open();
|
|
2274
|
-
await this._inner.initDataPipeline(this._dataPipelineController);
|
|
2275
2595
|
}
|
|
2276
2596
|
async close() {
|
|
2277
2597
|
await this._ctx.dispose();
|
|
2278
2598
|
await this.authVerifier.close();
|
|
2279
2599
|
await this._inner.close();
|
|
2600
|
+
await this._notarizationPluginConsumer.close();
|
|
2601
|
+
await this.notarizationPlugin.close();
|
|
2280
2602
|
await this._presence.destroy();
|
|
2281
2603
|
}
|
|
2604
|
+
async initializeDataPipeline() {
|
|
2605
|
+
await this._inner.controlPipeline.state.waitUntilReachedTargetTimeframe({
|
|
2606
|
+
timeout: CONTROL_PIPELINE_READY_TIMEFRAME
|
|
2607
|
+
});
|
|
2608
|
+
await this._createWritableFeeds();
|
|
2609
|
+
this.notarizationPlugin.setWriter((0, import_echo_db.createMappedFeedWriter)((credential) => ({
|
|
2610
|
+
credential: {
|
|
2611
|
+
credential
|
|
2612
|
+
}
|
|
2613
|
+
}), this._inner.controlPipeline.writer));
|
|
2614
|
+
await this._inner.initDataPipeline(this._dataPipelineController);
|
|
2615
|
+
}
|
|
2616
|
+
async _createWritableFeeds() {
|
|
2617
|
+
const credentials = [];
|
|
2618
|
+
if (!this.inner.controlFeedKey) {
|
|
2619
|
+
const controlFeed = await this._feedStore.openFeed(await this._keyring.createKey(), {
|
|
2620
|
+
writable: true
|
|
2621
|
+
});
|
|
2622
|
+
this.inner.setControlFeed(controlFeed);
|
|
2623
|
+
credentials.push(await this._signingContext.credentialSigner.createCredential({
|
|
2624
|
+
subject: controlFeed.key,
|
|
2625
|
+
assertion: {
|
|
2626
|
+
"@type": "dxos.halo.credentials.AdmittedFeed",
|
|
2627
|
+
spaceKey: this.key,
|
|
2628
|
+
deviceKey: this._signingContext.deviceKey,
|
|
2629
|
+
identityKey: this._signingContext.identityKey,
|
|
2630
|
+
designation: import_credentials9.AdmittedFeed.Designation.CONTROL
|
|
2631
|
+
}
|
|
2632
|
+
}));
|
|
2633
|
+
}
|
|
2634
|
+
if (!this.inner.dataFeedKey) {
|
|
2635
|
+
const dataFeed = await this._feedStore.openFeed(await this._keyring.createKey(), {
|
|
2636
|
+
writable: true
|
|
2637
|
+
});
|
|
2638
|
+
this.inner.setDataFeed(dataFeed);
|
|
2639
|
+
credentials.push(await this._signingContext.credentialSigner.createCredential({
|
|
2640
|
+
subject: dataFeed.key,
|
|
2641
|
+
assertion: {
|
|
2642
|
+
"@type": "dxos.halo.credentials.AdmittedFeed",
|
|
2643
|
+
spaceKey: this.key,
|
|
2644
|
+
deviceKey: this._signingContext.deviceKey,
|
|
2645
|
+
identityKey: this._signingContext.identityKey,
|
|
2646
|
+
designation: import_credentials9.AdmittedFeed.Designation.DATA
|
|
2647
|
+
}
|
|
2648
|
+
}));
|
|
2649
|
+
}
|
|
2650
|
+
if (credentials.length > 0) {
|
|
2651
|
+
await this.notarizationPlugin.notarize(credentials);
|
|
2652
|
+
}
|
|
2653
|
+
await this._metadataStore.setWritableFeedKeys(this.key, this.inner.controlFeedKey, this.inner.dataFeedKey);
|
|
2654
|
+
}
|
|
2282
2655
|
};
|
|
2656
|
+
__decorate([
|
|
2657
|
+
(0, import_debug4.timed)(1e4)
|
|
2658
|
+
], DataSpace.prototype, "_createWritableFeeds", null);
|
|
2283
2659
|
DataSpace = __decorate([
|
|
2284
2660
|
(0, import_async11.trackLeaks)("open", "close")
|
|
2285
2661
|
], DataSpace);
|
|
@@ -2295,18 +2671,20 @@ var __decorate2 = function(decorators, target, key, desc) {
|
|
|
2295
2671
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
2296
2672
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2297
2673
|
};
|
|
2674
|
+
var DATA_PIPELINE_READY_TIMEOUT = 3e3;
|
|
2298
2675
|
var DataSpaceManager = class DataSpaceManager2 {
|
|
2299
|
-
constructor(_spaceManager, _metadataStore, _dataServiceSubscriptions, _keyring, _signingContext, _modelFactory, _snapshotStore) {
|
|
2676
|
+
constructor(_spaceManager, _metadataStore, _dataServiceSubscriptions, _keyring, _signingContext, _modelFactory, _feedStore, _snapshotStore) {
|
|
2300
2677
|
this._spaceManager = _spaceManager;
|
|
2301
2678
|
this._metadataStore = _metadataStore;
|
|
2302
2679
|
this._dataServiceSubscriptions = _dataServiceSubscriptions;
|
|
2303
2680
|
this._keyring = _keyring;
|
|
2304
2681
|
this._signingContext = _signingContext;
|
|
2305
2682
|
this._modelFactory = _modelFactory;
|
|
2683
|
+
this._feedStore = _feedStore;
|
|
2306
2684
|
this._snapshotStore = _snapshotStore;
|
|
2307
|
-
this._ctx = new
|
|
2685
|
+
this._ctx = new import_context7.Context();
|
|
2308
2686
|
this.updated = new import_async12.Event();
|
|
2309
|
-
this._spaces = new
|
|
2687
|
+
this._spaces = new import_util6.ComplexMap(import_keys8.PublicKey.hash);
|
|
2310
2688
|
}
|
|
2311
2689
|
// TODO(burdon): Remove.
|
|
2312
2690
|
get spaces() {
|
|
@@ -2314,35 +2692,40 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2314
2692
|
}
|
|
2315
2693
|
async open() {
|
|
2316
2694
|
await this._metadataStore.load();
|
|
2317
|
-
(0,
|
|
2695
|
+
(0, import_log10.log)("metadata loaded", {
|
|
2318
2696
|
spaces: this._metadataStore.spaces.length
|
|
2319
2697
|
}, {
|
|
2320
2698
|
file: "data-space-manager.ts",
|
|
2321
|
-
line:
|
|
2699
|
+
line: 67,
|
|
2322
2700
|
scope: this,
|
|
2323
2701
|
callSite: (f, a) => f(...a)
|
|
2324
2702
|
});
|
|
2325
2703
|
for (const spaceMetadata of this._metadataStore.spaces) {
|
|
2326
|
-
(0,
|
|
2704
|
+
(0, import_log10.log)("load space", {
|
|
2327
2705
|
spaceMetadata
|
|
2328
2706
|
}, {
|
|
2329
2707
|
file: "data-space-manager.ts",
|
|
2330
|
-
line:
|
|
2708
|
+
line: 70,
|
|
2331
2709
|
scope: this,
|
|
2332
2710
|
callSite: (f, a) => f(...a)
|
|
2333
2711
|
});
|
|
2334
2712
|
const space = await this._constructSpace(spaceMetadata);
|
|
2335
|
-
|
|
2336
|
-
|
|
2713
|
+
await space.initializeDataPipeline();
|
|
2714
|
+
if (spaceMetadata.dataTimeframe) {
|
|
2715
|
+
(0, import_log10.log)("waiting for latest timeframe", {
|
|
2337
2716
|
spaceMetadata
|
|
2338
2717
|
}, {
|
|
2339
2718
|
file: "data-space-manager.ts",
|
|
2340
|
-
line:
|
|
2719
|
+
line: 74,
|
|
2341
2720
|
scope: this,
|
|
2342
2721
|
callSite: (f, a) => f(...a)
|
|
2343
2722
|
});
|
|
2344
|
-
await space.dataPipelineController.
|
|
2723
|
+
await space.dataPipelineController.pipelineState.setTargetTimeframe(spaceMetadata.dataTimeframe);
|
|
2345
2724
|
}
|
|
2725
|
+
await space.dataPipelineController.pipelineState.waitUntilReachedTargetTimeframe({
|
|
2726
|
+
timeout: DATA_PIPELINE_READY_TIMEOUT
|
|
2727
|
+
});
|
|
2728
|
+
this._dataServiceSubscriptions.registerSpace(space.key, space.dataPipelineController.databaseBackend.createDataServiceHost());
|
|
2346
2729
|
}
|
|
2347
2730
|
}
|
|
2348
2731
|
async close() {
|
|
@@ -2364,31 +2747,36 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2364
2747
|
controlFeedKey,
|
|
2365
2748
|
dataFeedKey
|
|
2366
2749
|
};
|
|
2367
|
-
(0,
|
|
2750
|
+
(0, import_log10.log)("creating space...", {
|
|
2368
2751
|
spaceKey
|
|
2369
2752
|
}, {
|
|
2370
2753
|
file: "data-space-manager.ts",
|
|
2371
|
-
line:
|
|
2754
|
+
line: 110,
|
|
2372
2755
|
scope: this,
|
|
2373
2756
|
callSite: (f, a) => f(...a)
|
|
2374
2757
|
});
|
|
2375
2758
|
const space = await this._constructSpace(metadata);
|
|
2376
|
-
await (0, import_echo_db2.spaceGenesis)(this._keyring, this._signingContext, space.inner);
|
|
2759
|
+
const credentials = await (0, import_echo_db2.spaceGenesis)(this._keyring, this._signingContext, space.inner);
|
|
2377
2760
|
await this._metadataStore.addSpace(metadata);
|
|
2761
|
+
const memberCredential = credentials[1];
|
|
2762
|
+
(0, import_node_assert12.default)((0, import_credentials10.getCredentialAssertion)(memberCredential)["@type"] === "dxos.halo.credentials.SpaceMember");
|
|
2763
|
+
await this._signingContext.recordCredential(memberCredential);
|
|
2764
|
+
await space.initializeDataPipeline();
|
|
2765
|
+
this._dataServiceSubscriptions.registerSpace(space.key, space.dataPipelineController.databaseBackend.createDataServiceHost());
|
|
2378
2766
|
this.updated.emit();
|
|
2379
2767
|
return space;
|
|
2380
2768
|
}
|
|
2381
2769
|
// TODO(burdon): Rename join space.
|
|
2382
2770
|
async acceptSpace(opts) {
|
|
2383
|
-
(0,
|
|
2771
|
+
(0, import_node_assert12.default)(!this._spaces.has(opts.spaceKey), "Space already exists.");
|
|
2384
2772
|
const metadata = {
|
|
2385
2773
|
key: opts.spaceKey,
|
|
2386
|
-
genesisFeedKey: opts.genesisFeedKey
|
|
2387
|
-
controlFeedKey: opts.controlFeedKey,
|
|
2388
|
-
dataFeedKey: opts.dataFeedKey
|
|
2774
|
+
genesisFeedKey: opts.genesisFeedKey
|
|
2389
2775
|
};
|
|
2390
2776
|
const space = await this._constructSpace(metadata);
|
|
2391
2777
|
await this._metadataStore.addSpace(metadata);
|
|
2778
|
+
await space.initializeDataPipeline();
|
|
2779
|
+
this._dataServiceSubscriptions.registerSpace(space.key, space.dataPipelineController.databaseBackend.createDataServiceHost());
|
|
2392
2780
|
this.updated.emit();
|
|
2393
2781
|
return space;
|
|
2394
2782
|
}
|
|
@@ -2400,20 +2788,29 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2400
2788
|
identityKey: this._signingContext.identityKey
|
|
2401
2789
|
});
|
|
2402
2790
|
const snapshotManager = new import_echo_db2.SnapshotManager(this._snapshotStore);
|
|
2791
|
+
const controlFeed = metadata.controlFeedKey && await this._feedStore.openFeed(metadata.controlFeedKey, {
|
|
2792
|
+
writable: true
|
|
2793
|
+
});
|
|
2794
|
+
const dataFeed = metadata.dataFeedKey && await this._feedStore.openFeed(metadata.dataFeedKey, {
|
|
2795
|
+
writable: true
|
|
2796
|
+
});
|
|
2403
2797
|
const space = await this._spaceManager.constructSpace({
|
|
2404
2798
|
metadata,
|
|
2405
2799
|
swarmIdentity: {
|
|
2406
2800
|
peerKey: this._signingContext.deviceKey,
|
|
2407
2801
|
credentialProvider: createAuthProvider(this._signingContext.credentialSigner),
|
|
2408
|
-
credentialAuthenticator: (0,
|
|
2802
|
+
credentialAuthenticator: (0, import_util6.deferFunction)(() => dataSpace.authVerifier.verifier)
|
|
2409
2803
|
},
|
|
2410
2804
|
onNetworkConnection: (session) => {
|
|
2411
2805
|
session.addExtension("dxos.mesh.teleport.presence", presence.createExtension({
|
|
2412
2806
|
remotePeerId: session.remotePeerId
|
|
2413
2807
|
}));
|
|
2414
2808
|
session.addExtension("dxos.mesh.teleport.objectsync", snapshotManager.objectSync.createExtension());
|
|
2809
|
+
session.addExtension("dxos.mesh.teleport.notarization", dataSpace.notarizationPlugin.createExtension());
|
|
2415
2810
|
}
|
|
2416
2811
|
});
|
|
2812
|
+
controlFeed && space.setControlFeed(controlFeed);
|
|
2813
|
+
dataFeed && space.setDataFeed(dataFeed);
|
|
2417
2814
|
const dataSpace = new DataSpace({
|
|
2418
2815
|
inner: space,
|
|
2419
2816
|
modelFactory: this._modelFactory,
|
|
@@ -2421,10 +2818,12 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2421
2818
|
snapshotManager,
|
|
2422
2819
|
presence,
|
|
2423
2820
|
memberKey: this._signingContext.identityKey,
|
|
2821
|
+
keyring: this._keyring,
|
|
2822
|
+
feedStore: this._feedStore,
|
|
2823
|
+
signingContext: this._signingContext,
|
|
2424
2824
|
snapshotId: metadata.snapshot
|
|
2425
2825
|
});
|
|
2426
2826
|
await dataSpace.open();
|
|
2427
|
-
this._dataServiceSubscriptions.registerSpace(space.key, dataSpace.database.createDataServiceHost());
|
|
2428
2827
|
this._spaces.set(metadata.key, dataSpace);
|
|
2429
2828
|
return dataSpace;
|
|
2430
2829
|
}
|
|
@@ -2470,13 +2869,21 @@ var ServiceContext = class {
|
|
|
2470
2869
|
feedStore: this.feedStore,
|
|
2471
2870
|
networkManager: this.networkManager
|
|
2472
2871
|
});
|
|
2473
|
-
this.identityManager = new IdentityManager(this.metadataStore, this.keyring, this.spaceManager);
|
|
2474
|
-
this.haloInvitations = new HaloInvitationsHandler(
|
|
2872
|
+
this.identityManager = new IdentityManager(this.metadataStore, this.keyring, this.feedStore, this.spaceManager);
|
|
2873
|
+
this.haloInvitations = new HaloInvitationsHandler({
|
|
2874
|
+
networkManager: this.networkManager,
|
|
2875
|
+
getIdentity: () => {
|
|
2876
|
+
var _a;
|
|
2877
|
+
return (_a = this.identityManager.identity) != null ? _a : (0, import_debug5.failUndefined)();
|
|
2878
|
+
},
|
|
2879
|
+
acceptIdentity: this._acceptIdentity.bind(this),
|
|
2880
|
+
keyring: this.keyring
|
|
2881
|
+
});
|
|
2475
2882
|
}
|
|
2476
2883
|
async open() {
|
|
2477
|
-
(0,
|
|
2884
|
+
(0, import_log11.log)("opening...", {}, {
|
|
2478
2885
|
file: "service-context.ts",
|
|
2479
|
-
line:
|
|
2886
|
+
line: 94,
|
|
2480
2887
|
scope: this,
|
|
2481
2888
|
callSite: (f, a) => f(...a)
|
|
2482
2889
|
});
|
|
@@ -2486,46 +2893,47 @@ var ServiceContext = class {
|
|
|
2486
2893
|
if (this.identityManager.identity) {
|
|
2487
2894
|
await this._initialize();
|
|
2488
2895
|
}
|
|
2489
|
-
(0,
|
|
2896
|
+
(0, import_log11.log)("opened", {}, {
|
|
2490
2897
|
file: "service-context.ts",
|
|
2491
|
-
line:
|
|
2898
|
+
line: 101,
|
|
2492
2899
|
scope: this,
|
|
2493
2900
|
callSite: (f, a) => f(...a)
|
|
2494
2901
|
});
|
|
2495
2902
|
}
|
|
2496
2903
|
async close() {
|
|
2497
|
-
var _a;
|
|
2498
|
-
(0,
|
|
2904
|
+
var _a, _b;
|
|
2905
|
+
(0, import_log11.log)("closing...", {}, {
|
|
2499
2906
|
file: "service-context.ts",
|
|
2500
|
-
line:
|
|
2907
|
+
line: 105,
|
|
2501
2908
|
scope: this,
|
|
2502
2909
|
callSite: (f, a) => f(...a)
|
|
2503
2910
|
});
|
|
2504
|
-
await ((_a = this.
|
|
2911
|
+
await ((_a = this._deviceSpaceSync) == null ? void 0 : _a.close());
|
|
2912
|
+
await ((_b = this.dataSpaceManager) == null ? void 0 : _b.close());
|
|
2505
2913
|
await this.identityManager.close();
|
|
2506
2914
|
await this.spaceManager.close();
|
|
2507
2915
|
await this.feedStore.close();
|
|
2508
2916
|
await this.networkManager.close();
|
|
2509
2917
|
this.dataServiceSubscriptions.clear();
|
|
2510
|
-
(0,
|
|
2918
|
+
(0, import_log11.log)("closed", {}, {
|
|
2511
2919
|
file: "service-context.ts",
|
|
2512
|
-
line:
|
|
2920
|
+
line: 113,
|
|
2513
2921
|
scope: this,
|
|
2514
2922
|
callSite: (f, a) => f(...a)
|
|
2515
2923
|
});
|
|
2516
2924
|
}
|
|
2517
2925
|
async reset() {
|
|
2518
|
-
(0,
|
|
2926
|
+
(0, import_log11.log)("resetting...", {}, {
|
|
2519
2927
|
file: "service-context.ts",
|
|
2520
|
-
line:
|
|
2928
|
+
line: 117,
|
|
2521
2929
|
scope: this,
|
|
2522
2930
|
callSite: (f, a) => f(...a)
|
|
2523
2931
|
});
|
|
2524
2932
|
await this.close();
|
|
2525
2933
|
await this.storage.reset();
|
|
2526
|
-
(0,
|
|
2934
|
+
(0, import_log11.log)("reset", {}, {
|
|
2527
2935
|
file: "service-context.ts",
|
|
2528
|
-
line:
|
|
2936
|
+
line: 120,
|
|
2529
2937
|
scope: this,
|
|
2530
2938
|
callSite: (f, a) => f(...a)
|
|
2531
2939
|
});
|
|
@@ -2535,53 +2943,121 @@ var ServiceContext = class {
|
|
|
2535
2943
|
await this._initialize();
|
|
2536
2944
|
return identity;
|
|
2537
2945
|
}
|
|
2946
|
+
async _acceptIdentity(params) {
|
|
2947
|
+
const identity = await this.identityManager.acceptIdentity(params);
|
|
2948
|
+
await this._initialize();
|
|
2949
|
+
return identity;
|
|
2950
|
+
}
|
|
2538
2951
|
// Called when identity is created.
|
|
2539
2952
|
async _initialize() {
|
|
2540
2953
|
var _a;
|
|
2541
|
-
(0,
|
|
2954
|
+
(0, import_log11.log)("initializing spaces...", {}, {
|
|
2542
2955
|
file: "service-context.ts",
|
|
2543
|
-
line:
|
|
2956
|
+
line: 139,
|
|
2544
2957
|
scope: this,
|
|
2545
2958
|
callSite: (f, a) => f(...a)
|
|
2546
2959
|
});
|
|
2547
|
-
const identity = (_a = this.identityManager.identity) != null ? _a : (0,
|
|
2960
|
+
const identity = (_a = this.identityManager.identity) != null ? _a : (0, import_debug5.failUndefined)();
|
|
2548
2961
|
const signingContext = {
|
|
2549
2962
|
credentialSigner: identity.getIdentityCredentialSigner(),
|
|
2550
2963
|
identityKey: identity.identityKey,
|
|
2551
2964
|
deviceKey: identity.deviceKey,
|
|
2552
|
-
profile: identity.profileDocument
|
|
2965
|
+
profile: identity.profileDocument,
|
|
2966
|
+
recordCredential: async (credential) => {
|
|
2967
|
+
await identity.controlPipeline.writer.write({
|
|
2968
|
+
credential: {
|
|
2969
|
+
credential
|
|
2970
|
+
}
|
|
2971
|
+
});
|
|
2972
|
+
}
|
|
2553
2973
|
};
|
|
2554
|
-
this.dataSpaceManager = new DataSpaceManager(this.spaceManager, this.metadataStore, this.dataServiceSubscriptions, this.keyring, signingContext, this.modelFactory, this.snapshotStore);
|
|
2974
|
+
this.dataSpaceManager = new DataSpaceManager(this.spaceManager, this.metadataStore, this.dataServiceSubscriptions, this.keyring, signingContext, this.modelFactory, this.feedStore, this.snapshotStore);
|
|
2555
2975
|
await this.dataSpaceManager.open();
|
|
2556
2976
|
this.spaceInvitations = new SpaceInvitationsHandler(this.networkManager, this.dataSpaceManager, signingContext, this.keyring);
|
|
2557
2977
|
this.initialized.wake();
|
|
2978
|
+
this._deviceSpaceSync = identity.space.spaceState.registerProcessor({
|
|
2979
|
+
process: async (credential) => {
|
|
2980
|
+
const assertion = (0, import_credentials11.getCredentialAssertion)(credential);
|
|
2981
|
+
if (assertion["@type"] !== "dxos.halo.credentials.SpaceMember") {
|
|
2982
|
+
return;
|
|
2983
|
+
}
|
|
2984
|
+
if (assertion.spaceKey.equals(identity.space.key)) {
|
|
2985
|
+
return;
|
|
2986
|
+
}
|
|
2987
|
+
if (!this.dataSpaceManager) {
|
|
2988
|
+
(0, import_log11.log)("dataSpaceManager not initialized yet, ignoring space admission", {
|
|
2989
|
+
details: assertion
|
|
2990
|
+
}, {
|
|
2991
|
+
file: "service-context.ts",
|
|
2992
|
+
line: 182,
|
|
2993
|
+
scope: this,
|
|
2994
|
+
callSite: (f, a) => f(...a)
|
|
2995
|
+
});
|
|
2996
|
+
return;
|
|
2997
|
+
}
|
|
2998
|
+
if (this.dataSpaceManager.spaces.has(assertion.spaceKey)) {
|
|
2999
|
+
(0, import_log11.log)("space already exists, ignoring space admission", {
|
|
3000
|
+
details: assertion
|
|
3001
|
+
}, {
|
|
3002
|
+
file: "service-context.ts",
|
|
3003
|
+
line: 186,
|
|
3004
|
+
scope: this,
|
|
3005
|
+
callSite: (f, a) => f(...a)
|
|
3006
|
+
});
|
|
3007
|
+
return;
|
|
3008
|
+
}
|
|
3009
|
+
try {
|
|
3010
|
+
(0, import_log11.log)("accepting space recorded in halo", {
|
|
3011
|
+
details: assertion
|
|
3012
|
+
}, {
|
|
3013
|
+
file: "service-context.ts",
|
|
3014
|
+
line: 191,
|
|
3015
|
+
scope: this,
|
|
3016
|
+
callSite: (f, a) => f(...a)
|
|
3017
|
+
});
|
|
3018
|
+
await this.dataSpaceManager.acceptSpace({
|
|
3019
|
+
spaceKey: assertion.spaceKey,
|
|
3020
|
+
genesisFeedKey: assertion.genesisFeedKey
|
|
3021
|
+
});
|
|
3022
|
+
} catch (err) {
|
|
3023
|
+
import_log11.log.catch(err, {}, {
|
|
3024
|
+
file: "service-context.ts",
|
|
3025
|
+
line: 197,
|
|
3026
|
+
scope: this,
|
|
3027
|
+
callSite: (f, a) => f(...a)
|
|
3028
|
+
});
|
|
3029
|
+
}
|
|
3030
|
+
}
|
|
3031
|
+
});
|
|
3032
|
+
await this._deviceSpaceSync.open();
|
|
2558
3033
|
}
|
|
2559
3034
|
};
|
|
2560
3035
|
|
|
2561
3036
|
// packages/sdk/client-services/src/packlets/services/service-definitions.ts
|
|
2562
|
-
var
|
|
3037
|
+
var import_protocols6 = require("@dxos/protocols");
|
|
2563
3038
|
var import_rpc = require("@dxos/rpc");
|
|
2564
3039
|
var clientServiceBundle = (0, import_rpc.createServiceBundle)({
|
|
2565
|
-
HaloInvitationsService:
|
|
2566
|
-
DevicesService:
|
|
2567
|
-
SpaceInvitationsService:
|
|
2568
|
-
SpacesService:
|
|
2569
|
-
NetworkService:
|
|
3040
|
+
HaloInvitationsService: import_protocols6.schema.getService("dxos.client.services.HaloInvitationsService"),
|
|
3041
|
+
DevicesService: import_protocols6.schema.getService("dxos.client.services.DevicesService"),
|
|
3042
|
+
SpaceInvitationsService: import_protocols6.schema.getService("dxos.client.services.SpaceInvitationsService"),
|
|
3043
|
+
SpacesService: import_protocols6.schema.getService("dxos.client.services.SpacesService"),
|
|
3044
|
+
NetworkService: import_protocols6.schema.getService("dxos.client.services.NetworkService"),
|
|
2570
3045
|
// TODO(burdon): Deprecated.
|
|
2571
|
-
SpaceService:
|
|
2572
|
-
DataService:
|
|
2573
|
-
ProfileService:
|
|
2574
|
-
SystemService:
|
|
2575
|
-
DevtoolsHost:
|
|
2576
|
-
TracingService:
|
|
3046
|
+
SpaceService: import_protocols6.schema.getService("dxos.client.SpaceService"),
|
|
3047
|
+
DataService: import_protocols6.schema.getService("dxos.echo.service.DataService"),
|
|
3048
|
+
ProfileService: import_protocols6.schema.getService("dxos.client.ProfileService"),
|
|
3049
|
+
SystemService: import_protocols6.schema.getService("dxos.client.SystemService"),
|
|
3050
|
+
DevtoolsHost: import_protocols6.schema.getService("dxos.devtools.host.DevtoolsHost"),
|
|
3051
|
+
TracingService: import_protocols6.schema.getService("dxos.devtools.host.TracingService")
|
|
2577
3052
|
});
|
|
2578
3053
|
|
|
2579
3054
|
// packages/sdk/client-services/src/packlets/services/service-host.ts
|
|
2580
|
-
var
|
|
3055
|
+
var import_debug7 = require("@dxos/debug");
|
|
3056
|
+
var import_document_model = require("@dxos/document-model");
|
|
2581
3057
|
var import_echo_db5 = require("@dxos/echo-db");
|
|
2582
|
-
var
|
|
3058
|
+
var import_log16 = require("@dxos/log");
|
|
2583
3059
|
var import_model_factory = require("@dxos/model-factory");
|
|
2584
|
-
var
|
|
3060
|
+
var import_client2 = require("@dxos/protocols/proto/dxos/client");
|
|
2585
3061
|
var import_text_model = require("@dxos/text-model");
|
|
2586
3062
|
|
|
2587
3063
|
// packages/sdk/client-services/src/packlets/identity/devices-service-impl.ts
|
|
@@ -2651,7 +3127,7 @@ var NetworkServiceImpl = class {
|
|
|
2651
3127
|
// packages/sdk/client-services/src/packlets/spaces/spaces-service.ts
|
|
2652
3128
|
var import_async15 = require("@dxos/async");
|
|
2653
3129
|
var import_codec_protobuf11 = require("@dxos/codec-protobuf");
|
|
2654
|
-
var
|
|
3130
|
+
var import_debug6 = require("@dxos/debug");
|
|
2655
3131
|
var import_echo_db4 = require("@dxos/echo-db");
|
|
2656
3132
|
var SpacesServiceImpl = class {
|
|
2657
3133
|
constructor(_spaceManager) {
|
|
@@ -2669,7 +3145,7 @@ var SpacesServiceImpl = class {
|
|
|
2669
3145
|
queryCredentials({ spaceKey }) {
|
|
2670
3146
|
return new import_codec_protobuf11.Stream(({ ctx, next }) => {
|
|
2671
3147
|
var _a;
|
|
2672
|
-
const space = (_a = this._spaceManager.spaces.get(spaceKey)) != null ? _a : (0,
|
|
3148
|
+
const space = (_a = this._spaceManager.spaces.get(spaceKey)) != null ? _a : (0, import_debug6.raise)(new import_echo_db4.SpaceNotFoundError(spaceKey));
|
|
2673
3149
|
const processor = space.spaceState.registerProcessor({
|
|
2674
3150
|
process: async (credential) => {
|
|
2675
3151
|
next(credential);
|
|
@@ -2679,6 +3155,17 @@ var SpacesServiceImpl = class {
|
|
|
2679
3155
|
(0, import_async15.scheduleTask)(ctx, () => processor.open());
|
|
2680
3156
|
});
|
|
2681
3157
|
}
|
|
3158
|
+
async writeCredentials({ spaceKey, credentials }) {
|
|
3159
|
+
var _a;
|
|
3160
|
+
const space = (_a = this._spaceManager.spaces.get(spaceKey)) != null ? _a : (0, import_debug6.raise)(new import_echo_db4.SpaceNotFoundError(spaceKey));
|
|
3161
|
+
for (const credential of credentials != null ? credentials : []) {
|
|
3162
|
+
await space.controlPipeline.writer.write({
|
|
3163
|
+
credential: {
|
|
3164
|
+
credential
|
|
3165
|
+
}
|
|
3166
|
+
});
|
|
3167
|
+
}
|
|
3168
|
+
}
|
|
2682
3169
|
};
|
|
2683
3170
|
|
|
2684
3171
|
// packages/sdk/client-services/src/packlets/storage/storage.ts
|
|
@@ -2726,165 +3213,139 @@ var toStorageType = (type) => {
|
|
|
2726
3213
|
}
|
|
2727
3214
|
};
|
|
2728
3215
|
|
|
2729
|
-
// packages/sdk/client-services/src/packlets/
|
|
2730
|
-
var
|
|
2731
|
-
|
|
2732
|
-
|
|
2733
|
-
|
|
2734
|
-
|
|
2735
|
-
|
|
2736
|
-
|
|
2737
|
-
|
|
2738
|
-
|
|
2739
|
-
|
|
2740
|
-
|
|
2741
|
-
|
|
2742
|
-
|
|
2743
|
-
|
|
2744
|
-
// packages/sdk/client-services/src/packlets/services/service-host.ts
|
|
2745
|
-
var createDefaultModelFactory = () => {
|
|
2746
|
-
return new import_model_factory.ModelFactory().registerModel(import_object_model.ObjectModel).registerModel(import_text_model.TextModel);
|
|
3216
|
+
// packages/sdk/client-services/src/packlets/vault/iframe-host-runtime.ts
|
|
3217
|
+
var import_async16 = require("@dxos/async");
|
|
3218
|
+
var import_log12 = require("@dxos/log");
|
|
3219
|
+
var import_messaging = require("@dxos/messaging");
|
|
3220
|
+
var import_network_manager3 = require("@dxos/network-manager");
|
|
3221
|
+
var import_rpc2 = require("@dxos/rpc");
|
|
3222
|
+
var __decorate3 = function(decorators, target, key, desc) {
|
|
3223
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3224
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
3225
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
3226
|
+
else
|
|
3227
|
+
for (var i = decorators.length - 1; i >= 0; i--)
|
|
3228
|
+
if (d = decorators[i])
|
|
3229
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
3230
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2747
3231
|
};
|
|
2748
|
-
var
|
|
2749
|
-
|
|
2750
|
-
|
|
2751
|
-
|
|
2752
|
-
|
|
2753
|
-
|
|
2754
|
-
|
|
2755
|
-
|
|
2756
|
-
|
|
2757
|
-
|
|
2758
|
-
|
|
2759
|
-
|
|
2760
|
-
|
|
2761
|
-
|
|
2762
|
-
|
|
2763
|
-
|
|
2764
|
-
|
|
2765
|
-
|
|
3232
|
+
var LOCK_KEY = "DXOS_RESOURCE_LOCK";
|
|
3233
|
+
var IFrameHostRuntime = class {
|
|
3234
|
+
constructor({ configProvider, appPort }) {
|
|
3235
|
+
this._transportFactory = (0, import_network_manager3.createWebRTCTransportFactory)();
|
|
3236
|
+
this._ready = new import_async16.Trigger();
|
|
3237
|
+
this._configProvider = configProvider;
|
|
3238
|
+
this._appPort = appPort;
|
|
3239
|
+
this._getService = async (find) => {
|
|
3240
|
+
const error = await this._ready.wait();
|
|
3241
|
+
if (error) {
|
|
3242
|
+
throw error;
|
|
3243
|
+
}
|
|
3244
|
+
const service = await find(this._clientServices.services);
|
|
3245
|
+
if (!service) {
|
|
3246
|
+
throw new Error("Service not found");
|
|
3247
|
+
}
|
|
3248
|
+
return service;
|
|
3249
|
+
};
|
|
2766
3250
|
}
|
|
2767
|
-
async
|
|
2768
|
-
|
|
2769
|
-
|
|
2770
|
-
|
|
2771
|
-
line: 73,
|
|
2772
|
-
scope: this,
|
|
2773
|
-
callSite: (f, a) => f(...a)
|
|
2774
|
-
});
|
|
2775
|
-
await this._initialize();
|
|
2776
|
-
await this._serviceContext.open();
|
|
2777
|
-
const deviceKey = (_a = this._serviceContext.identityManager.identity) == null ? void 0 : _a.deviceKey;
|
|
2778
|
-
(0, import_log11.log)("opened", {
|
|
2779
|
-
deviceKey
|
|
2780
|
-
}, {
|
|
2781
|
-
file: "service-host.ts",
|
|
2782
|
-
line: 77,
|
|
3251
|
+
async start() {
|
|
3252
|
+
(0, import_log12.log)("starting...", {}, {
|
|
3253
|
+
file: "iframe-host-runtime.ts",
|
|
3254
|
+
line: 63,
|
|
2783
3255
|
scope: this,
|
|
2784
3256
|
callSite: (f, a) => f(...a)
|
|
2785
3257
|
});
|
|
3258
|
+
try {
|
|
3259
|
+
this._config = await this._configProvider();
|
|
3260
|
+
const signalServer = this._config.get("runtime.services.signal.server");
|
|
3261
|
+
this._clientServices = new ClientServicesHost({
|
|
3262
|
+
lockKey: LOCK_KEY,
|
|
3263
|
+
config: this._config,
|
|
3264
|
+
networkManager: new import_network_manager3.NetworkManager({
|
|
3265
|
+
log: true,
|
|
3266
|
+
signalManager: signalServer ? new import_messaging.WebsocketSignalManager([
|
|
3267
|
+
signalServer
|
|
3268
|
+
]) : new import_messaging.MemorySignalManager(new import_messaging.MemorySignalManagerContext()),
|
|
3269
|
+
transportFactory: this._transportFactory
|
|
3270
|
+
})
|
|
3271
|
+
});
|
|
3272
|
+
this._clientRpc = (0, import_rpc2.createProtoRpcPeer)({
|
|
3273
|
+
exposed: clientServiceBundle,
|
|
3274
|
+
handlers: {
|
|
3275
|
+
DataService: async () => await this._getService((services) => services.DataService),
|
|
3276
|
+
DevicesService: async () => await this._getService((services) => services.DevicesService),
|
|
3277
|
+
DevtoolsHost: async () => await this._getService((services) => services.DevtoolsHost),
|
|
3278
|
+
HaloInvitationsService: async () => await this._getService((services) => services.HaloInvitationsService),
|
|
3279
|
+
NetworkService: async () => await this._getService((services) => services.NetworkService),
|
|
3280
|
+
ProfileService: async () => await this._getService((services) => services.ProfileService),
|
|
3281
|
+
SpaceInvitationsService: async () => await this._getService((services) => services.SpaceInvitationsService),
|
|
3282
|
+
SpaceService: async () => await this._getService((services) => services.SpaceService),
|
|
3283
|
+
SpacesService: async () => await this._getService((services) => services.SpacesService),
|
|
3284
|
+
SystemService: async () => await this._getService((services) => services.SystemService),
|
|
3285
|
+
TracingService: async () => await this._getService((services) => services.TracingService)
|
|
3286
|
+
},
|
|
3287
|
+
port: this._appPort
|
|
3288
|
+
});
|
|
3289
|
+
await Promise.all([
|
|
3290
|
+
this._clientServices.open(),
|
|
3291
|
+
this._clientRpc.open()
|
|
3292
|
+
]);
|
|
3293
|
+
this._ready.wake(void 0);
|
|
3294
|
+
(0, import_log12.log)("started", {}, {
|
|
3295
|
+
file: "iframe-host-runtime.ts",
|
|
3296
|
+
line: 99,
|
|
3297
|
+
scope: this,
|
|
3298
|
+
callSite: (f, a) => f(...a)
|
|
3299
|
+
});
|
|
3300
|
+
} catch (err) {
|
|
3301
|
+
this._ready.wake(err);
|
|
3302
|
+
import_log12.log.catch(err, {}, {
|
|
3303
|
+
file: "iframe-host-runtime.ts",
|
|
3304
|
+
line: 102,
|
|
3305
|
+
scope: this,
|
|
3306
|
+
callSite: (f, a) => f(...a)
|
|
3307
|
+
});
|
|
3308
|
+
}
|
|
2786
3309
|
}
|
|
2787
|
-
async
|
|
2788
|
-
|
|
2789
|
-
|
|
2790
|
-
|
|
2791
|
-
deviceKey
|
|
2792
|
-
}, {
|
|
2793
|
-
file: "service-host.ts",
|
|
2794
|
-
line: 82,
|
|
3310
|
+
async stop() {
|
|
3311
|
+
(0, import_log12.log)("stopping...", {}, {
|
|
3312
|
+
file: "iframe-host-runtime.ts",
|
|
3313
|
+
line: 107,
|
|
2795
3314
|
scope: this,
|
|
2796
3315
|
callSite: (f, a) => f(...a)
|
|
2797
3316
|
});
|
|
2798
|
-
await this.
|
|
2799
|
-
|
|
2800
|
-
|
|
2801
|
-
|
|
2802
|
-
|
|
2803
|
-
line: 84,
|
|
3317
|
+
await this._clientRpc.close();
|
|
3318
|
+
await this._clientServices.close();
|
|
3319
|
+
(0, import_log12.log)("stopped", {}, {
|
|
3320
|
+
file: "iframe-host-runtime.ts",
|
|
3321
|
+
line: 110,
|
|
2804
3322
|
scope: this,
|
|
2805
3323
|
callSite: (f, a) => f(...a)
|
|
2806
3324
|
});
|
|
2807
3325
|
}
|
|
2808
|
-
// TODO(burdon): Move into open.
|
|
2809
|
-
async _initialize() {
|
|
2810
|
-
this._serviceContext = new ServiceContext(this._storage, this._networkManager, this._modelFactory);
|
|
2811
|
-
this._serviceRegistry = new ServiceRegistry(clientServiceBundle, {
|
|
2812
|
-
HaloInvitationsService: new HaloInvitationsServiceImpl(this._serviceContext.identityManager, this._serviceContext.haloInvitations),
|
|
2813
|
-
DevicesService: new DevicesServiceImpl(this._serviceContext.identityManager),
|
|
2814
|
-
SpaceInvitationsService: new SpaceInvitationsServiceImpl(this._serviceContext.identityManager, () => {
|
|
2815
|
-
var _a;
|
|
2816
|
-
return (_a = this._serviceContext.spaceInvitations) != null ? _a : (0, import_debug6.raise)(new Error("SpaceInvitations not initialized"));
|
|
2817
|
-
}, () => {
|
|
2818
|
-
var _a;
|
|
2819
|
-
return (_a = this._serviceContext.dataSpaceManager) != null ? _a : (0, import_debug6.raise)(new Error("SpaceManager not initialized"));
|
|
2820
|
-
}),
|
|
2821
|
-
SpacesService: new SpacesServiceImpl(this._serviceContext.spaceManager),
|
|
2822
|
-
DataService: new import_echo_db5.DataServiceImpl(this._serviceContext.dataServiceSubscriptions),
|
|
2823
|
-
NetworkService: new NetworkServiceImpl(this._serviceContext.networkManager),
|
|
2824
|
-
// TODO(burdon): Move to new protobuf definitions.
|
|
2825
|
-
ProfileService: new ProfileServiceImpl(this._serviceContext),
|
|
2826
|
-
SpaceService: new SpaceServiceImpl(this._serviceContext),
|
|
2827
|
-
SystemService: new SystemServiceImpl(this._config, this._serviceContext),
|
|
2828
|
-
TracingService: new TracingServiceImpl(this._config),
|
|
2829
|
-
DevtoolsHost: new DevtoolsServiceImpl({
|
|
2830
|
-
events: new DevtoolsHostEvents(),
|
|
2831
|
-
config: this._config,
|
|
2832
|
-
context: this._serviceContext
|
|
2833
|
-
})
|
|
2834
|
-
});
|
|
2835
|
-
}
|
|
2836
|
-
};
|
|
2837
|
-
|
|
2838
|
-
// packages/sdk/client-services/src/packlets/services/service-proxy.ts
|
|
2839
|
-
var import_async16 = require("@dxos/async");
|
|
2840
|
-
var import_errors2 = require("@dxos/errors");
|
|
2841
|
-
var import_rpc2 = require("@dxos/rpc");
|
|
2842
|
-
var ClientServicesProxy = class {
|
|
2843
|
-
// prettier-ignore
|
|
2844
|
-
constructor(port, _timeout = 3e4) {
|
|
2845
|
-
this._timeout = _timeout;
|
|
2846
|
-
this._proxy = (0, import_rpc2.createProtoRpcPeer)({
|
|
2847
|
-
requested: clientServiceBundle,
|
|
2848
|
-
exposed: {},
|
|
2849
|
-
handlers: {},
|
|
2850
|
-
port
|
|
2851
|
-
});
|
|
2852
|
-
}
|
|
2853
|
-
get proxy() {
|
|
2854
|
-
return this._proxy;
|
|
2855
|
-
}
|
|
2856
|
-
get descriptors() {
|
|
2857
|
-
return clientServiceBundle;
|
|
2858
|
-
}
|
|
2859
|
-
get services() {
|
|
2860
|
-
return this._proxy.rpc;
|
|
2861
|
-
}
|
|
2862
|
-
async open() {
|
|
2863
|
-
await (0, import_async16.asyncTimeout)(this._proxy.open(), this._timeout, new import_errors2.RemoteServiceConnectionTimeout());
|
|
2864
|
-
}
|
|
2865
|
-
async close() {
|
|
2866
|
-
await this._proxy.close();
|
|
2867
|
-
}
|
|
2868
3326
|
};
|
|
3327
|
+
__decorate3([
|
|
3328
|
+
import_log12.logInfo
|
|
3329
|
+
], IFrameHostRuntime.prototype, "origin", void 0);
|
|
2869
3330
|
|
|
2870
|
-
// packages/sdk/client-services/src/packlets/vault/iframe-runtime.ts
|
|
2871
|
-
var
|
|
3331
|
+
// packages/sdk/client-services/src/packlets/vault/iframe-proxy-runtime.ts
|
|
3332
|
+
var import_network_manager4 = require("@dxos/network-manager");
|
|
2872
3333
|
var import_rpc3 = require("@dxos/rpc");
|
|
2873
3334
|
|
|
2874
3335
|
// packages/sdk/client-services/src/packlets/vault/services.ts
|
|
2875
|
-
var
|
|
3336
|
+
var import_protocols7 = require("@dxos/protocols");
|
|
2876
3337
|
var iframeServiceBundle = {
|
|
2877
|
-
IframeService:
|
|
2878
|
-
BridgeService:
|
|
3338
|
+
IframeService: import_protocols7.schema.getService("dxos.iframe.IframeService"),
|
|
3339
|
+
BridgeService: import_protocols7.schema.getService("dxos.mesh.bridge.BridgeService")
|
|
2879
3340
|
};
|
|
2880
3341
|
var workerServiceBundle = {
|
|
2881
|
-
WorkerService:
|
|
3342
|
+
WorkerService: import_protocols7.schema.getService("dxos.iframe.WorkerService")
|
|
2882
3343
|
};
|
|
2883
3344
|
|
|
2884
|
-
// packages/sdk/client-services/src/packlets/vault/iframe-runtime.ts
|
|
2885
|
-
var
|
|
3345
|
+
// packages/sdk/client-services/src/packlets/vault/iframe-proxy-runtime.ts
|
|
3346
|
+
var IFrameProxyRuntime = class {
|
|
2886
3347
|
constructor({ systemPort, workerAppPort, windowAppPort }) {
|
|
2887
|
-
this._transportService = new
|
|
3348
|
+
this._transportService = new import_network_manager4.WebRTCTransportService();
|
|
2888
3349
|
this._systemPort = systemPort;
|
|
2889
3350
|
this._windowAppPort = windowAppPort;
|
|
2890
3351
|
this._workerAppPort = workerAppPort;
|
|
@@ -2916,18 +3377,100 @@ var IFrameRuntime = class {
|
|
|
2916
3377
|
}
|
|
2917
3378
|
};
|
|
2918
3379
|
|
|
3380
|
+
// packages/sdk/client-services/src/packlets/vault/vault-resource-lock.ts
|
|
3381
|
+
var import_async17 = require("@dxos/async");
|
|
3382
|
+
var import_log13 = require("@dxos/log");
|
|
3383
|
+
var Message;
|
|
3384
|
+
(function(Message2) {
|
|
3385
|
+
Message2["ACQUIRING"] = "acquiring";
|
|
3386
|
+
})(Message || (Message = {}));
|
|
3387
|
+
var VaultResourceLock = class {
|
|
3388
|
+
constructor({ lockKey, onAcquire, onRelease }) {
|
|
3389
|
+
this._broadcastChannel = new BroadcastChannel("vault-resource-lock");
|
|
3390
|
+
this._releaseTrigger = new import_async17.Trigger();
|
|
3391
|
+
this._lockKey = lockKey;
|
|
3392
|
+
this._onAcquire = onAcquire;
|
|
3393
|
+
this._onRelease = onRelease;
|
|
3394
|
+
this._broadcastChannel.onmessage = this._onMessage.bind(this);
|
|
3395
|
+
}
|
|
3396
|
+
async acquire() {
|
|
3397
|
+
this._broadcastChannel.postMessage({
|
|
3398
|
+
message: Message.ACQUIRING
|
|
3399
|
+
});
|
|
3400
|
+
try {
|
|
3401
|
+
await (0, import_async17.asyncTimeout)(this._requestLock(), 3e3);
|
|
3402
|
+
} catch (e) {
|
|
3403
|
+
await this._requestLock(true);
|
|
3404
|
+
}
|
|
3405
|
+
}
|
|
3406
|
+
async release() {
|
|
3407
|
+
this._releaseTrigger.wake();
|
|
3408
|
+
}
|
|
3409
|
+
_onMessage(event) {
|
|
3410
|
+
if (event.data.message === Message.ACQUIRING) {
|
|
3411
|
+
this._releaseTrigger.wake();
|
|
3412
|
+
}
|
|
3413
|
+
}
|
|
3414
|
+
async _requestLock(steal = false) {
|
|
3415
|
+
(0, import_log13.log)("requesting lock...", {
|
|
3416
|
+
steal
|
|
3417
|
+
}, {
|
|
3418
|
+
file: "vault-resource-lock.ts",
|
|
3419
|
+
line: 56,
|
|
3420
|
+
scope: this,
|
|
3421
|
+
callSite: (f, a) => f(...a)
|
|
3422
|
+
});
|
|
3423
|
+
const acquired = new import_async17.Trigger();
|
|
3424
|
+
void navigator.locks.request(this._lockKey, {
|
|
3425
|
+
steal
|
|
3426
|
+
}, async () => {
|
|
3427
|
+
var _a, _b;
|
|
3428
|
+
await ((_a = this._onAcquire) == null ? void 0 : _a.call(this));
|
|
3429
|
+
acquired.wake();
|
|
3430
|
+
this._releaseTrigger = new import_async17.Trigger();
|
|
3431
|
+
await this._releaseTrigger.wait();
|
|
3432
|
+
(0, import_log13.log)("releasing lock...", {}, {
|
|
3433
|
+
file: "vault-resource-lock.ts",
|
|
3434
|
+
line: 65,
|
|
3435
|
+
scope: this,
|
|
3436
|
+
callSite: (f, a) => f(...a)
|
|
3437
|
+
});
|
|
3438
|
+
await ((_b = this._onRelease) == null ? void 0 : _b.call(this));
|
|
3439
|
+
(0, import_log13.log)("released lock", {}, {
|
|
3440
|
+
file: "vault-resource-lock.ts",
|
|
3441
|
+
line: 67,
|
|
3442
|
+
scope: this,
|
|
3443
|
+
callSite: (f, a) => f(...a)
|
|
3444
|
+
});
|
|
3445
|
+
}).catch(async () => {
|
|
3446
|
+
var _a;
|
|
3447
|
+
await ((_a = this._onRelease) == null ? void 0 : _a.call(this));
|
|
3448
|
+
});
|
|
3449
|
+
await acquired.wait();
|
|
3450
|
+
(0, import_log13.log)("recieved lock", {
|
|
3451
|
+
steal
|
|
3452
|
+
}, {
|
|
3453
|
+
file: "vault-resource-lock.ts",
|
|
3454
|
+
line: 74,
|
|
3455
|
+
scope: this,
|
|
3456
|
+
callSite: (f, a) => f(...a)
|
|
3457
|
+
});
|
|
3458
|
+
}
|
|
3459
|
+
};
|
|
3460
|
+
|
|
2919
3461
|
// packages/sdk/client-services/src/packlets/vault/worker-runtime.ts
|
|
2920
|
-
var
|
|
2921
|
-
var
|
|
2922
|
-
var
|
|
3462
|
+
var import_async19 = require("@dxos/async");
|
|
3463
|
+
var import_log15 = require("@dxos/log");
|
|
3464
|
+
var import_messaging2 = require("@dxos/messaging");
|
|
3465
|
+
var import_network_manager5 = require("@dxos/network-manager");
|
|
2923
3466
|
|
|
2924
3467
|
// packages/sdk/client-services/src/packlets/vault/worker-session.ts
|
|
2925
|
-
var
|
|
2926
|
-
var
|
|
2927
|
-
var
|
|
3468
|
+
var import_node_assert13 = __toESM(require("node:assert"));
|
|
3469
|
+
var import_async18 = require("@dxos/async");
|
|
3470
|
+
var import_log14 = require("@dxos/log");
|
|
2928
3471
|
var import_rpc4 = require("@dxos/rpc");
|
|
2929
|
-
var
|
|
2930
|
-
var
|
|
3472
|
+
var import_util7 = require("@dxos/util");
|
|
3473
|
+
var __decorate4 = function(decorators, target, key, desc) {
|
|
2931
3474
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2932
3475
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
2933
3476
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -2938,29 +3481,29 @@ var __decorate3 = function(decorators, target, key, desc) {
|
|
|
2938
3481
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2939
3482
|
};
|
|
2940
3483
|
var WorkerSession = class {
|
|
2941
|
-
constructor({
|
|
3484
|
+
constructor({ getService, systemPort, appPort, options = {
|
|
2942
3485
|
heartbeatInterval: 1e3
|
|
2943
3486
|
} }) {
|
|
2944
|
-
this._startTrigger = new
|
|
2945
|
-
this.onClose = new
|
|
2946
|
-
(0,
|
|
2947
|
-
(0,
|
|
3487
|
+
this._startTrigger = new import_async18.Trigger();
|
|
3488
|
+
this.onClose = new import_util7.Callback();
|
|
3489
|
+
(0, import_node_assert13.default)(options);
|
|
3490
|
+
(0, import_node_assert13.default)(getService);
|
|
2948
3491
|
this._options = options;
|
|
2949
|
-
this.
|
|
3492
|
+
this._getService = getService;
|
|
2950
3493
|
this._clientRpc = (0, import_rpc4.createProtoRpcPeer)({
|
|
2951
3494
|
exposed: clientServiceBundle,
|
|
2952
3495
|
handlers: {
|
|
2953
|
-
|
|
2954
|
-
DevicesService: async () =>
|
|
2955
|
-
|
|
2956
|
-
|
|
2957
|
-
NetworkService: async () =>
|
|
2958
|
-
|
|
2959
|
-
|
|
2960
|
-
|
|
2961
|
-
|
|
2962
|
-
|
|
2963
|
-
TracingService: async () =>
|
|
3496
|
+
DataService: async () => await this._getService((services) => services.DataService),
|
|
3497
|
+
DevicesService: async () => await this._getService((services) => services.DevicesService),
|
|
3498
|
+
DevtoolsHost: async () => await this._getService((services) => services.DevtoolsHost),
|
|
3499
|
+
HaloInvitationsService: async () => await this._getService((services) => services.HaloInvitationsService),
|
|
3500
|
+
NetworkService: async () => await this._getService((services) => services.NetworkService),
|
|
3501
|
+
ProfileService: async () => await this._getService((services) => services.ProfileService),
|
|
3502
|
+
SpaceInvitationsService: async () => await this._getService((services) => services.SpaceInvitationsService),
|
|
3503
|
+
SpaceService: async () => await this._getService((services) => services.SpaceService),
|
|
3504
|
+
SpacesService: async () => await this._getService((services) => services.SpacesService),
|
|
3505
|
+
SystemService: async () => await this._getService((services) => services.SystemService),
|
|
3506
|
+
TracingService: async () => await this._getService((services) => services.TracingService)
|
|
2964
3507
|
},
|
|
2965
3508
|
port: appPort
|
|
2966
3509
|
});
|
|
@@ -2978,7 +3521,7 @@ var WorkerSession = class {
|
|
|
2978
3521
|
try {
|
|
2979
3522
|
await this.close();
|
|
2980
3523
|
} catch (err) {
|
|
2981
|
-
|
|
3524
|
+
import_log14.log.catch(err, {}, {
|
|
2982
3525
|
file: "worker-session.ts",
|
|
2983
3526
|
line: 90,
|
|
2984
3527
|
scope: this,
|
|
@@ -2996,7 +3539,7 @@ var WorkerSession = class {
|
|
|
2996
3539
|
this.bridgeService = this._iframeRpc.rpc.BridgeService;
|
|
2997
3540
|
}
|
|
2998
3541
|
async open() {
|
|
2999
|
-
|
|
3542
|
+
import_log14.log.info("opening..", {}, {
|
|
3000
3543
|
file: "worker-session.ts",
|
|
3001
3544
|
line: 104,
|
|
3002
3545
|
scope: this,
|
|
@@ -3013,7 +3556,7 @@ var WorkerSession = class {
|
|
|
3013
3556
|
try {
|
|
3014
3557
|
await this._iframeRpc.rpc.IframeService.heartbeat();
|
|
3015
3558
|
} catch (err1) {
|
|
3016
|
-
|
|
3559
|
+
import_log14.log.warn("Heartbeat failed", {
|
|
3017
3560
|
err: err1
|
|
3018
3561
|
}, {
|
|
3019
3562
|
file: "worker-session.ts",
|
|
@@ -3024,7 +3567,7 @@ var WorkerSession = class {
|
|
|
3024
3567
|
try {
|
|
3025
3568
|
await this.close();
|
|
3026
3569
|
} catch (err) {
|
|
3027
|
-
|
|
3570
|
+
import_log14.log.catch(err, {}, {
|
|
3028
3571
|
file: "worker-session.ts",
|
|
3029
3572
|
line: 120,
|
|
3030
3573
|
scope: this,
|
|
@@ -3035,7 +3578,7 @@ var WorkerSession = class {
|
|
|
3035
3578
|
}, this._options.heartbeatInterval);
|
|
3036
3579
|
}
|
|
3037
3580
|
async close() {
|
|
3038
|
-
|
|
3581
|
+
import_log14.log.info("closing..", {}, {
|
|
3039
3582
|
file: "worker-session.ts",
|
|
3040
3583
|
line: 127,
|
|
3041
3584
|
scope: this,
|
|
@@ -3044,7 +3587,7 @@ var WorkerSession = class {
|
|
|
3044
3587
|
try {
|
|
3045
3588
|
await this.onClose.callIfSet();
|
|
3046
3589
|
} catch (err) {
|
|
3047
|
-
|
|
3590
|
+
import_log14.log.catch(err, {}, {
|
|
3048
3591
|
file: "worker-session.ts",
|
|
3049
3592
|
line: 131,
|
|
3050
3593
|
scope: this,
|
|
@@ -3060,8 +3603,8 @@ var WorkerSession = class {
|
|
|
3060
3603
|
]);
|
|
3061
3604
|
}
|
|
3062
3605
|
};
|
|
3063
|
-
|
|
3064
|
-
|
|
3606
|
+
__decorate4([
|
|
3607
|
+
import_log14.logInfo
|
|
3065
3608
|
], WorkerSession.prototype, "origin", void 0);
|
|
3066
3609
|
|
|
3067
3610
|
// packages/sdk/client-services/src/packlets/vault/worker-runtime.ts
|
|
@@ -3069,28 +3612,46 @@ var WorkerRuntime = class {
|
|
|
3069
3612
|
// prettier-ignore
|
|
3070
3613
|
constructor(_configProvider) {
|
|
3071
3614
|
this._configProvider = _configProvider;
|
|
3072
|
-
this._transportFactory = new
|
|
3073
|
-
this._ready = new
|
|
3615
|
+
this._transportFactory = new import_network_manager5.WebRTCTransportProxyFactory();
|
|
3616
|
+
this._ready = new import_async19.Trigger();
|
|
3074
3617
|
this.sessions = /* @__PURE__ */ new Set();
|
|
3075
3618
|
}
|
|
3076
3619
|
async start() {
|
|
3620
|
+
(0, import_log15.log)("starting...", {}, {
|
|
3621
|
+
file: "worker-runtime.ts",
|
|
3622
|
+
line: 41,
|
|
3623
|
+
scope: this,
|
|
3624
|
+
callSite: (f, a) => f(...a)
|
|
3625
|
+
});
|
|
3077
3626
|
try {
|
|
3078
3627
|
this._config = await this._configProvider();
|
|
3079
3628
|
const signalServer = this._config.get("runtime.services.signal.server");
|
|
3080
3629
|
this._clientServices = new ClientServicesHost({
|
|
3081
3630
|
config: this._config,
|
|
3082
|
-
networkManager: new
|
|
3631
|
+
networkManager: new import_network_manager5.NetworkManager({
|
|
3083
3632
|
log: true,
|
|
3084
|
-
signalManager: signalServer ? new
|
|
3633
|
+
signalManager: signalServer ? new import_messaging2.WebsocketSignalManager([
|
|
3085
3634
|
signalServer
|
|
3086
|
-
]) : new
|
|
3635
|
+
]) : new import_messaging2.MemorySignalManager(new import_messaging2.MemorySignalManagerContext()),
|
|
3087
3636
|
transportFactory: this._transportFactory
|
|
3088
3637
|
})
|
|
3089
3638
|
});
|
|
3090
3639
|
await this._clientServices.open();
|
|
3091
3640
|
this._ready.wake(void 0);
|
|
3641
|
+
(0, import_log15.log)("started", {}, {
|
|
3642
|
+
file: "worker-runtime.ts",
|
|
3643
|
+
line: 58,
|
|
3644
|
+
scope: this,
|
|
3645
|
+
callSite: (f, a) => f(...a)
|
|
3646
|
+
});
|
|
3092
3647
|
} catch (err) {
|
|
3093
3648
|
this._ready.wake(err);
|
|
3649
|
+
import_log15.log.catch(err, {}, {
|
|
3650
|
+
file: "worker-runtime.ts",
|
|
3651
|
+
line: 61,
|
|
3652
|
+
scope: this,
|
|
3653
|
+
callSite: (f, a) => f(...a)
|
|
3654
|
+
});
|
|
3094
3655
|
}
|
|
3095
3656
|
}
|
|
3096
3657
|
async stop() {
|
|
@@ -3101,12 +3662,16 @@ var WorkerRuntime = class {
|
|
|
3101
3662
|
*/
|
|
3102
3663
|
async createSession({ appPort, systemPort }) {
|
|
3103
3664
|
const session = new WorkerSession({
|
|
3104
|
-
|
|
3665
|
+
getService: async (find) => {
|
|
3105
3666
|
const error = await this._ready.wait();
|
|
3106
|
-
if (error
|
|
3667
|
+
if (error) {
|
|
3107
3668
|
throw error;
|
|
3108
3669
|
}
|
|
3109
|
-
|
|
3670
|
+
const service = find(this._clientServices.services);
|
|
3671
|
+
if (!service) {
|
|
3672
|
+
throw new Error("Service not found");
|
|
3673
|
+
}
|
|
3674
|
+
return service;
|
|
3110
3675
|
},
|
|
3111
3676
|
appPort,
|
|
3112
3677
|
systemPort,
|
|
@@ -3140,6 +3705,193 @@ var WorkerRuntime = class {
|
|
|
3140
3705
|
}
|
|
3141
3706
|
}
|
|
3142
3707
|
};
|
|
3708
|
+
|
|
3709
|
+
// packages/sdk/client-services/src/packlets/services/service-registry.ts
|
|
3710
|
+
var ServiceRegistry = class {
|
|
3711
|
+
// prettier-ignore
|
|
3712
|
+
constructor(_serviceBundle, _handlers) {
|
|
3713
|
+
this._serviceBundle = _serviceBundle;
|
|
3714
|
+
this._handlers = _handlers;
|
|
3715
|
+
}
|
|
3716
|
+
get descriptors() {
|
|
3717
|
+
return this._serviceBundle;
|
|
3718
|
+
}
|
|
3719
|
+
get services() {
|
|
3720
|
+
return this._handlers;
|
|
3721
|
+
}
|
|
3722
|
+
setServices(services) {
|
|
3723
|
+
this._handlers = services;
|
|
3724
|
+
}
|
|
3725
|
+
};
|
|
3726
|
+
|
|
3727
|
+
// packages/sdk/client-services/src/packlets/services/service-host.ts
|
|
3728
|
+
var createDefaultModelFactory = () => {
|
|
3729
|
+
return new import_model_factory.ModelFactory().registerModel(import_document_model.DocumentModel).registerModel(import_text_model.TextModel);
|
|
3730
|
+
};
|
|
3731
|
+
var ClientServicesHost = class {
|
|
3732
|
+
constructor({
|
|
3733
|
+
config,
|
|
3734
|
+
modelFactory = createDefaultModelFactory(),
|
|
3735
|
+
// TODO(burdon): Create ApolloLink abstraction (see Client).
|
|
3736
|
+
networkManager,
|
|
3737
|
+
storage = createStorageObjects(config.get("runtime.client.storage", {})).storage,
|
|
3738
|
+
lockKey
|
|
3739
|
+
}) {
|
|
3740
|
+
this._open = false;
|
|
3741
|
+
this._config = config;
|
|
3742
|
+
this._modelFactory = modelFactory;
|
|
3743
|
+
this._networkManager = networkManager;
|
|
3744
|
+
this._storage = storage;
|
|
3745
|
+
this._resourceLock = lockKey ? new VaultResourceLock({
|
|
3746
|
+
lockKey,
|
|
3747
|
+
onAcquire: () => this.open(),
|
|
3748
|
+
onRelease: () => this.close()
|
|
3749
|
+
}) : void 0;
|
|
3750
|
+
this._systemService = new SystemServiceImpl({
|
|
3751
|
+
config: this._config,
|
|
3752
|
+
onInit: async () => {
|
|
3753
|
+
var _a;
|
|
3754
|
+
await ((_a = this._resourceLock) == null ? void 0 : _a.acquire());
|
|
3755
|
+
},
|
|
3756
|
+
onStatus: async () => {
|
|
3757
|
+
if (!this.isOpen) {
|
|
3758
|
+
return {
|
|
3759
|
+
status: import_client2.Status.INACTIVE
|
|
3760
|
+
};
|
|
3761
|
+
}
|
|
3762
|
+
return {
|
|
3763
|
+
status: import_client2.Status.ACTIVE
|
|
3764
|
+
};
|
|
3765
|
+
},
|
|
3766
|
+
onReset: async () => {
|
|
3767
|
+
var _a;
|
|
3768
|
+
await ((_a = this._serviceContext) == null ? void 0 : _a.reset());
|
|
3769
|
+
}
|
|
3770
|
+
});
|
|
3771
|
+
this._serviceRegistry = new ServiceRegistry(clientServiceBundle, {
|
|
3772
|
+
SystemService: this._systemService
|
|
3773
|
+
});
|
|
3774
|
+
}
|
|
3775
|
+
get isOpen() {
|
|
3776
|
+
return this._open;
|
|
3777
|
+
}
|
|
3778
|
+
get descriptors() {
|
|
3779
|
+
return this._serviceRegistry.descriptors;
|
|
3780
|
+
}
|
|
3781
|
+
get services() {
|
|
3782
|
+
return this._serviceRegistry.services;
|
|
3783
|
+
}
|
|
3784
|
+
async open() {
|
|
3785
|
+
var _a;
|
|
3786
|
+
if (this._open) {
|
|
3787
|
+
return;
|
|
3788
|
+
}
|
|
3789
|
+
(0, import_log16.log)("opening...", {}, {
|
|
3790
|
+
file: "service-host.ts",
|
|
3791
|
+
line: 125,
|
|
3792
|
+
scope: this,
|
|
3793
|
+
callSite: (f, a) => f(...a)
|
|
3794
|
+
});
|
|
3795
|
+
this._serviceContext = new ServiceContext(this._storage, this._networkManager, this._modelFactory);
|
|
3796
|
+
this._serviceRegistry.setServices({
|
|
3797
|
+
// TODO(burdon): Move to new protobuf definitions.
|
|
3798
|
+
SystemService: this._systemService,
|
|
3799
|
+
HaloInvitationsService: new HaloInvitationsServiceImpl(this._serviceContext.identityManager, this._serviceContext.haloInvitations),
|
|
3800
|
+
DevicesService: new DevicesServiceImpl(this._serviceContext.identityManager),
|
|
3801
|
+
SpaceInvitationsService: new SpaceInvitationsServiceImpl(this._serviceContext.identityManager, () => {
|
|
3802
|
+
var _a2;
|
|
3803
|
+
return (_a2 = this._serviceContext.spaceInvitations) != null ? _a2 : (0, import_debug7.raise)(new Error("SpaceInvitations not initialized"));
|
|
3804
|
+
}, () => {
|
|
3805
|
+
var _a2;
|
|
3806
|
+
return (_a2 = this._serviceContext.dataSpaceManager) != null ? _a2 : (0, import_debug7.raise)(new Error("SpaceManager not initialized"));
|
|
3807
|
+
}),
|
|
3808
|
+
SpacesService: new SpacesServiceImpl(this._serviceContext.spaceManager),
|
|
3809
|
+
DataService: new import_echo_db5.DataServiceImpl(this._serviceContext.dataServiceSubscriptions),
|
|
3810
|
+
NetworkService: new NetworkServiceImpl(this._serviceContext.networkManager),
|
|
3811
|
+
// TODO(burdon): Move to new protobuf definitions.
|
|
3812
|
+
ProfileService: new ProfileServiceImpl(this._serviceContext),
|
|
3813
|
+
// TODO(burdon): Port old SubscribeSpaces to QueryServices>
|
|
3814
|
+
SpaceService: new SpaceServiceImpl(this._serviceContext),
|
|
3815
|
+
TracingService: new TracingServiceImpl(this._config),
|
|
3816
|
+
DevtoolsHost: new DevtoolsServiceImpl({
|
|
3817
|
+
events: new DevtoolsHostEvents(),
|
|
3818
|
+
config: this._config,
|
|
3819
|
+
context: this._serviceContext
|
|
3820
|
+
})
|
|
3821
|
+
});
|
|
3822
|
+
await this._serviceContext.open();
|
|
3823
|
+
this._open = true;
|
|
3824
|
+
const deviceKey = (_a = this._serviceContext.identityManager.identity) == null ? void 0 : _a.deviceKey;
|
|
3825
|
+
(0, import_log16.log)("opened", {
|
|
3826
|
+
deviceKey
|
|
3827
|
+
}, {
|
|
3828
|
+
file: "service-host.ts",
|
|
3829
|
+
line: 172,
|
|
3830
|
+
scope: this,
|
|
3831
|
+
callSite: (f, a) => f(...a)
|
|
3832
|
+
});
|
|
3833
|
+
}
|
|
3834
|
+
async close() {
|
|
3835
|
+
var _a;
|
|
3836
|
+
if (!this._open) {
|
|
3837
|
+
return;
|
|
3838
|
+
}
|
|
3839
|
+
const deviceKey = (_a = this._serviceContext.identityManager.identity) == null ? void 0 : _a.deviceKey;
|
|
3840
|
+
(0, import_log16.log)("closing...", {
|
|
3841
|
+
deviceKey
|
|
3842
|
+
}, {
|
|
3843
|
+
file: "service-host.ts",
|
|
3844
|
+
line: 181,
|
|
3845
|
+
scope: this,
|
|
3846
|
+
callSite: (f, a) => f(...a)
|
|
3847
|
+
});
|
|
3848
|
+
this._serviceRegistry.setServices({
|
|
3849
|
+
SystemService: this._systemService
|
|
3850
|
+
});
|
|
3851
|
+
await this._serviceContext.close();
|
|
3852
|
+
this._open = false;
|
|
3853
|
+
(0, import_log16.log)("closed", {
|
|
3854
|
+
deviceKey
|
|
3855
|
+
}, {
|
|
3856
|
+
file: "service-host.ts",
|
|
3857
|
+
line: 185,
|
|
3858
|
+
scope: this,
|
|
3859
|
+
callSite: (f, a) => f(...a)
|
|
3860
|
+
});
|
|
3861
|
+
}
|
|
3862
|
+
};
|
|
3863
|
+
|
|
3864
|
+
// packages/sdk/client-services/src/packlets/services/service-proxy.ts
|
|
3865
|
+
var import_async20 = require("@dxos/async");
|
|
3866
|
+
var import_errors2 = require("@dxos/errors");
|
|
3867
|
+
var import_rpc5 = require("@dxos/rpc");
|
|
3868
|
+
var ClientServicesProxy = class {
|
|
3869
|
+
// prettier-ignore
|
|
3870
|
+
constructor(port, _timeout = 3e4) {
|
|
3871
|
+
this._timeout = _timeout;
|
|
3872
|
+
this._proxy = (0, import_rpc5.createProtoRpcPeer)({
|
|
3873
|
+
requested: clientServiceBundle,
|
|
3874
|
+
exposed: {},
|
|
3875
|
+
handlers: {},
|
|
3876
|
+
port
|
|
3877
|
+
});
|
|
3878
|
+
}
|
|
3879
|
+
get proxy() {
|
|
3880
|
+
return this._proxy;
|
|
3881
|
+
}
|
|
3882
|
+
get descriptors() {
|
|
3883
|
+
return clientServiceBundle;
|
|
3884
|
+
}
|
|
3885
|
+
get services() {
|
|
3886
|
+
return this._proxy.rpc;
|
|
3887
|
+
}
|
|
3888
|
+
async open() {
|
|
3889
|
+
await (0, import_async20.asyncTimeout)(this._proxy.open(), this._timeout, new import_errors2.RemoteServiceConnectionTimeout());
|
|
3890
|
+
}
|
|
3891
|
+
async close() {
|
|
3892
|
+
await this._proxy.close();
|
|
3893
|
+
}
|
|
3894
|
+
};
|
|
3143
3895
|
// Annotate the CommonJS export names for ESM import in node:
|
|
3144
3896
|
0 && (module.exports = {
|
|
3145
3897
|
AUTHENTICATION_CODE_LENGTH,
|
|
@@ -3154,7 +3906,8 @@ var WorkerRuntime = class {
|
|
|
3154
3906
|
HaloInvitationsHandler,
|
|
3155
3907
|
HaloInvitationsProxy,
|
|
3156
3908
|
HaloInvitationsServiceImpl,
|
|
3157
|
-
|
|
3909
|
+
IFrameHostRuntime,
|
|
3910
|
+
IFrameProxyRuntime,
|
|
3158
3911
|
INVITATION_TIMEOUT,
|
|
3159
3912
|
Identity,
|
|
3160
3913
|
IdentityManager,
|
|
@@ -3171,6 +3924,7 @@ var WorkerRuntime = class {
|
|
|
3171
3924
|
SystemServiceImpl,
|
|
3172
3925
|
TracingServiceImpl,
|
|
3173
3926
|
TrustedKeySetAuthVerifier,
|
|
3927
|
+
VaultResourceLock,
|
|
3174
3928
|
WorkerRuntime,
|
|
3175
3929
|
WorkerSession,
|
|
3176
3930
|
clientServiceBundle,
|
|
@@ -3178,13 +3932,15 @@ var WorkerRuntime = class {
|
|
|
3178
3932
|
createDefaultModelFactory,
|
|
3179
3933
|
createStorageObjects,
|
|
3180
3934
|
getNetworkPeers,
|
|
3935
|
+
iframeServiceBundle,
|
|
3181
3936
|
subscribeToFeedBlocks,
|
|
3182
3937
|
subscribeToFeeds,
|
|
3183
3938
|
subscribeToNetworkStatus,
|
|
3184
3939
|
subscribeToNetworkTopics,
|
|
3185
|
-
|
|
3940
|
+
subscribeToSignal,
|
|
3186
3941
|
subscribeToSpaces,
|
|
3187
3942
|
subscribeToSwarmInfo,
|
|
3943
|
+
workerServiceBundle,
|
|
3188
3944
|
wrapObservable
|
|
3189
3945
|
});
|
|
3190
3946
|
//# sourceMappingURL=index.cjs.map
|