@dxos/client-services 0.1.53 → 0.1.54-main.270ec56
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-6ITWCQIT.mjs → chunk-F4BHRFH4.mjs} +861 -702
- package/dist/lib/browser/chunk-F4BHRFH4.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +115 -173
- 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 +24 -7
- package/dist/lib/browser/packlets/testing/index.mjs.map +3 -3
- package/dist/lib/node/index.cjs +951 -853
- 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 +832 -708
- package/dist/lib/node/packlets/testing/index.cjs.map +4 -4
- package/dist/types/src/packlets/identity/authenticator.d.ts.map +1 -1
- package/dist/types/src/packlets/identity/identity.d.ts.map +1 -1
- package/dist/types/src/packlets/services/index.d.ts +1 -0
- package/dist/types/src/packlets/services/index.d.ts.map +1 -1
- package/dist/types/src/packlets/services/service-context.d.ts.map +1 -1
- package/dist/types/src/packlets/services/service-host.d.ts +7 -1
- package/dist/types/src/packlets/services/service-host.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/data-space-manager.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/data-space.d.ts +11 -2
- package/dist/types/src/packlets/spaces/data-space.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/notarization-plugin.d.ts +2 -1
- package/dist/types/src/packlets/spaces/notarization-plugin.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/spaces-service.d.ts +1 -1
- package/dist/types/src/packlets/spaces/spaces-service.d.ts.map +1 -1
- package/dist/types/src/packlets/testing/test-builder.d.ts +7 -1
- package/dist/types/src/packlets/testing/test-builder.d.ts.map +1 -1
- package/dist/types/src/packlets/vault/iframe-host-runtime.d.ts +1 -1
- package/dist/types/src/packlets/vault/iframe-host-runtime.d.ts.map +1 -1
- package/dist/types/src/packlets/vault/iframe-proxy-runtime.d.ts +1 -1
- package/dist/types/src/packlets/vault/iframe-proxy-runtime.d.ts.map +1 -1
- package/dist/types/src/packlets/vault/shell-runtime.d.ts +1 -21
- package/dist/types/src/packlets/vault/shell-runtime.d.ts.map +1 -1
- package/dist/types/src/packlets/vault/worker-session.d.ts.map +1 -1
- package/package.json +33 -32
- package/src/packlets/identity/authenticator.ts +4 -2
- package/src/packlets/identity/identity-manager.test.ts +1 -1
- package/src/packlets/identity/identity-manager.ts +8 -8
- package/src/packlets/identity/identity-service.ts +2 -2
- package/src/packlets/identity/identity.test.ts +1 -1
- package/src/packlets/identity/identity.ts +22 -27
- package/src/packlets/invitations/device-invitation-protocol.ts +4 -4
- package/src/packlets/invitations/invitation-extension.ts +5 -5
- package/src/packlets/invitations/invitations-handler.ts +6 -6
- package/src/packlets/invitations/invitations-service.ts +3 -3
- package/src/packlets/invitations/space-invitation-protocol.ts +9 -9
- package/src/packlets/locks/node.ts +2 -2
- package/src/packlets/logging/logging-service.ts +4 -4
- package/src/packlets/services/index.ts +1 -0
- package/src/packlets/services/service-context.test.ts +1 -1
- package/src/packlets/services/service-context.ts +12 -10
- package/src/packlets/services/service-host.test.ts +50 -2
- package/src/packlets/services/service-host.ts +25 -9
- package/src/packlets/spaces/data-space-manager.test.ts +75 -119
- package/src/packlets/spaces/data-space-manager.ts +18 -9
- package/src/packlets/spaces/data-space.ts +66 -20
- package/src/packlets/spaces/notarization-plugin.test.ts +1 -1
- package/src/packlets/spaces/notarization-plugin.ts +9 -5
- package/src/packlets/spaces/spaces-service.test.ts +5 -3
- package/src/packlets/spaces/spaces-service.ts +26 -8
- package/src/packlets/testing/invitation-utils.ts +2 -2
- package/src/packlets/testing/test-builder.ts +36 -4
- package/src/packlets/vault/iframe-host-runtime.ts +2 -2
- package/src/packlets/vault/iframe-proxy-runtime.ts +2 -2
- package/src/packlets/vault/shell-runtime.ts +3 -49
- package/src/packlets/vault/worker-runtime.ts +1 -1
- package/src/packlets/vault/worker-session.ts +7 -6
- package/dist/lib/browser/chunk-6ITWCQIT.mjs.map +0 -7
|
@@ -61,15 +61,20 @@ var createMockCredential = async ({ signer, issuer }) => (0, import_credentials.
|
|
|
61
61
|
});
|
|
62
62
|
|
|
63
63
|
// packages/sdk/client-services/src/packlets/testing/invitation-utils.ts
|
|
64
|
-
var
|
|
64
|
+
var import_tiny_invariant14 = __toESM(require("tiny-invariant"));
|
|
65
65
|
var import_async18 = require("@dxos/async");
|
|
66
66
|
var import_services13 = require("@dxos/protocols/proto/dxos/client/services");
|
|
67
67
|
|
|
68
|
+
// packages/sdk/client-services/src/packlets/services/client-rpc-server.ts
|
|
69
|
+
var import_codec_protobuf = require("@dxos/codec-protobuf");
|
|
70
|
+
var import_debug = require("@dxos/debug");
|
|
71
|
+
var import_rpc = require("@dxos/rpc");
|
|
72
|
+
|
|
68
73
|
// packages/sdk/client-services/src/packlets/services/service-context.ts
|
|
69
|
-
var
|
|
74
|
+
var import_tiny_invariant11 = __toESM(require("tiny-invariant"));
|
|
70
75
|
var import_async11 = require("@dxos/async");
|
|
71
76
|
var import_credentials14 = require("@dxos/credentials");
|
|
72
|
-
var
|
|
77
|
+
var import_debug7 = require("@dxos/debug");
|
|
73
78
|
var import_echo_pipeline3 = require("@dxos/echo-pipeline");
|
|
74
79
|
var import_feed_store3 = require("@dxos/feed-store");
|
|
75
80
|
var import_keyring = require("@dxos/keyring");
|
|
@@ -85,6 +90,8 @@ var import_context = require("@dxos/context");
|
|
|
85
90
|
var import_credentials2 = require("@dxos/credentials");
|
|
86
91
|
var import_log = require("@dxos/log");
|
|
87
92
|
var import_protocols = require("@dxos/protocols");
|
|
93
|
+
var __dxlog_file = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/authenticator.ts";
|
|
94
|
+
var Credential = import_protocols.schema.getCodecForType("dxos.halo.credentials.Credential");
|
|
88
95
|
var createAuthProvider = (signer) => async (nonce) => {
|
|
89
96
|
const credential = await signer.createCredential({
|
|
90
97
|
assertion: {
|
|
@@ -93,7 +100,7 @@ var createAuthProvider = (signer) => async (nonce) => {
|
|
|
93
100
|
subject: signer.getIssuer(),
|
|
94
101
|
nonce
|
|
95
102
|
});
|
|
96
|
-
return
|
|
103
|
+
return Credential.encode(credential);
|
|
97
104
|
};
|
|
98
105
|
var TrustedKeySetAuthVerifier = class {
|
|
99
106
|
// prettier-ignore
|
|
@@ -106,24 +113,24 @@ var TrustedKeySetAuthVerifier = class {
|
|
|
106
113
|
}
|
|
107
114
|
get verifier() {
|
|
108
115
|
return async (nonce, auth) => {
|
|
109
|
-
const credential =
|
|
116
|
+
const credential = Credential.decode(auth);
|
|
110
117
|
(0, import_log.log)("authenticating...", {
|
|
111
118
|
credential
|
|
112
119
|
}, {
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
120
|
+
F: __dxlog_file,
|
|
121
|
+
L: 59,
|
|
122
|
+
S: this,
|
|
123
|
+
C: (f, a) => f(...a)
|
|
117
124
|
});
|
|
118
125
|
const result = await (0, import_credentials2.verifyCredential)(credential);
|
|
119
126
|
if (result.kind === "fail") {
|
|
120
127
|
(0, import_log.log)("Invalid credential", {
|
|
121
128
|
result
|
|
122
129
|
}, {
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
130
|
+
F: __dxlog_file,
|
|
131
|
+
L: 63,
|
|
132
|
+
S: this,
|
|
133
|
+
C: (f, a) => f(...a)
|
|
127
134
|
});
|
|
128
135
|
return false;
|
|
129
136
|
}
|
|
@@ -132,10 +139,10 @@ var TrustedKeySetAuthVerifier = class {
|
|
|
132
139
|
nonce,
|
|
133
140
|
credential
|
|
134
141
|
}, {
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
142
|
+
F: __dxlog_file,
|
|
143
|
+
L: 68,
|
|
144
|
+
S: this,
|
|
145
|
+
C: (f, a) => f(...a)
|
|
139
146
|
});
|
|
140
147
|
return false;
|
|
141
148
|
}
|
|
@@ -143,10 +150,10 @@ var TrustedKeySetAuthVerifier = class {
|
|
|
143
150
|
(0, import_log.log)("key is not currently in trusted set, waiting...", {
|
|
144
151
|
key: credential.issuer
|
|
145
152
|
}, {
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
153
|
+
F: __dxlog_file,
|
|
154
|
+
L: 73,
|
|
155
|
+
S: this,
|
|
156
|
+
C: (f, a) => f(...a)
|
|
150
157
|
});
|
|
151
158
|
return true;
|
|
152
159
|
}
|
|
@@ -159,20 +166,20 @@ var TrustedKeySetAuthVerifier = class {
|
|
|
159
166
|
(0, import_log.log)("auth success", {
|
|
160
167
|
key: credential.issuer
|
|
161
168
|
}, {
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
169
|
+
F: __dxlog_file,
|
|
170
|
+
L: 84,
|
|
171
|
+
S: this,
|
|
172
|
+
C: (f, a) => f(...a)
|
|
166
173
|
});
|
|
167
174
|
trigger.wake(true);
|
|
168
175
|
} else {
|
|
169
176
|
(0, import_log.log)("key is not currently in trusted set, waiting...", {
|
|
170
177
|
key: credential.issuer
|
|
171
178
|
}, {
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
179
|
+
F: __dxlog_file,
|
|
180
|
+
L: 87,
|
|
181
|
+
S: this,
|
|
182
|
+
C: (f, a) => f(...a)
|
|
176
183
|
});
|
|
177
184
|
}
|
|
178
185
|
});
|
|
@@ -194,14 +201,15 @@ var TrustedKeySetAuthVerifier = class {
|
|
|
194
201
|
};
|
|
195
202
|
|
|
196
203
|
// packages/sdk/client-services/src/packlets/identity/identity.ts
|
|
197
|
-
var
|
|
204
|
+
var import_tiny_invariant = __toESM(require("tiny-invariant"));
|
|
198
205
|
var import_async2 = require("@dxos/async");
|
|
199
206
|
var import_client_protocol = require("@dxos/client-protocol");
|
|
200
207
|
var import_credentials3 = require("@dxos/credentials");
|
|
201
|
-
var
|
|
208
|
+
var import_debug2 = require("@dxos/debug");
|
|
202
209
|
var import_feed_store = require("@dxos/feed-store");
|
|
203
210
|
var import_log2 = require("@dxos/log");
|
|
204
211
|
var import_credentials4 = require("@dxos/protocols/proto/dxos/halo/credentials");
|
|
212
|
+
var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/identity.ts";
|
|
205
213
|
var Identity = class {
|
|
206
214
|
constructor({ space, signer, identityKey, deviceKey }) {
|
|
207
215
|
this.stateUpdate = new import_async2.Event();
|
|
@@ -209,15 +217,15 @@ var Identity = class {
|
|
|
209
217
|
this._signer = signer;
|
|
210
218
|
this.identityKey = identityKey;
|
|
211
219
|
this.deviceKey = deviceKey;
|
|
212
|
-
this._deviceStateMachine =
|
|
220
|
+
this._deviceStateMachine = new import_credentials3.DeviceStateMachine({
|
|
213
221
|
identityKey: this.identityKey,
|
|
214
222
|
deviceKey: this.deviceKey,
|
|
215
223
|
onUpdate: () => this.stateUpdate.emit()
|
|
216
|
-
})
|
|
217
|
-
this._profileStateMachine =
|
|
224
|
+
});
|
|
225
|
+
this._profileStateMachine = new import_credentials3.ProfileStateMachine({
|
|
218
226
|
identityKey: this.identityKey,
|
|
219
227
|
onUpdate: () => this.stateUpdate.emit()
|
|
220
|
-
})
|
|
228
|
+
});
|
|
221
229
|
this.authVerifier = new TrustedKeySetAuthVerifier({
|
|
222
230
|
trustedKeysProvider: () => this.authorizedDeviceKeys,
|
|
223
231
|
update: this.stateUpdate,
|
|
@@ -226,27 +234,27 @@ var Identity = class {
|
|
|
226
234
|
}
|
|
227
235
|
// TODO(burdon): Expose state object?
|
|
228
236
|
get authorizedDeviceKeys() {
|
|
229
|
-
return this._deviceStateMachine.
|
|
237
|
+
return this._deviceStateMachine.authorizedDeviceKeys;
|
|
230
238
|
}
|
|
231
239
|
async open() {
|
|
232
|
-
await this.
|
|
233
|
-
await this.
|
|
240
|
+
await this.space.spaceState.addCredentialProcessor(this._deviceStateMachine);
|
|
241
|
+
await this.space.spaceState.addCredentialProcessor(this._profileStateMachine);
|
|
234
242
|
await this.space.open();
|
|
235
243
|
}
|
|
236
244
|
async close() {
|
|
237
245
|
await this.authVerifier.close();
|
|
238
|
-
await this.
|
|
239
|
-
await this.
|
|
246
|
+
await this.space.spaceState.removeCredentialProcessor(this._profileStateMachine);
|
|
247
|
+
await this.space.spaceState.removeCredentialProcessor(this._deviceStateMachine);
|
|
240
248
|
await this.space.close();
|
|
241
249
|
}
|
|
242
250
|
async ready() {
|
|
243
|
-
await this._deviceStateMachine.
|
|
251
|
+
await this._deviceStateMachine.deviceChainReady.wait();
|
|
244
252
|
await this.controlPipeline.state.waitUntilReachedTargetTimeframe({
|
|
245
253
|
timeout: import_client_protocol.LOAD_CONTROL_FEEDS_TIMEOUT
|
|
246
254
|
});
|
|
247
255
|
}
|
|
248
256
|
get profileDocument() {
|
|
249
|
-
return this._profileStateMachine.
|
|
257
|
+
return this._profileStateMachine.profile;
|
|
250
258
|
}
|
|
251
259
|
/**
|
|
252
260
|
* @test-only
|
|
@@ -261,14 +269,14 @@ var Identity = class {
|
|
|
261
269
|
return this.space.genesisFeedKey;
|
|
262
270
|
}
|
|
263
271
|
get deviceCredentialChain() {
|
|
264
|
-
return this._deviceStateMachine.
|
|
272
|
+
return this._deviceStateMachine.deviceCredentialChain;
|
|
265
273
|
}
|
|
266
274
|
getAdmissionCredentials() {
|
|
267
275
|
var _a, _b;
|
|
268
276
|
return {
|
|
269
277
|
deviceKey: this.deviceKey,
|
|
270
|
-
controlFeedKey: (_a = this.space.controlFeedKey) != null ? _a : (0,
|
|
271
|
-
dataFeedKey: (_b = this.space.dataFeedKey) != null ? _b : (0,
|
|
278
|
+
controlFeedKey: (_a = this.space.controlFeedKey) != null ? _a : (0, import_debug2.failUndefined)(),
|
|
279
|
+
dataFeedKey: (_b = this.space.dataFeedKey) != null ? _b : (0, import_debug2.failUndefined)()
|
|
272
280
|
};
|
|
273
281
|
}
|
|
274
282
|
/**
|
|
@@ -276,8 +284,8 @@ var Identity = class {
|
|
|
276
284
|
* Requires identity to be ready.
|
|
277
285
|
*/
|
|
278
286
|
getIdentityCredentialSigner() {
|
|
279
|
-
(0,
|
|
280
|
-
return (0, import_credentials3.createCredentialSignerWithChain)(this._signer, this._deviceStateMachine.
|
|
287
|
+
(0, import_tiny_invariant.default)(this._deviceStateMachine.deviceCredentialChain, "Device credential chain is not ready.");
|
|
288
|
+
return (0, import_credentials3.createCredentialSignerWithChain)(this._signer, this._deviceStateMachine.deviceCredentialChain, this.deviceKey);
|
|
281
289
|
}
|
|
282
290
|
/**
|
|
283
291
|
* Issues credentials as device.
|
|
@@ -293,10 +301,10 @@ var Identity = class {
|
|
|
293
301
|
controlFeedKey,
|
|
294
302
|
dataFeedKey
|
|
295
303
|
}, {
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
304
|
+
F: __dxlog_file2,
|
|
305
|
+
L: 151,
|
|
306
|
+
S: this,
|
|
307
|
+
C: (f, a) => f(...a)
|
|
300
308
|
});
|
|
301
309
|
const signer = this.getIdentityCredentialSigner();
|
|
302
310
|
await (0, import_feed_store.writeMessages)(this.controlPipeline.writer, [
|
|
@@ -337,7 +345,7 @@ var Identity = class {
|
|
|
337
345
|
};
|
|
338
346
|
|
|
339
347
|
// packages/sdk/client-services/src/packlets/identity/identity-manager.ts
|
|
340
|
-
var
|
|
348
|
+
var import_tiny_invariant2 = __toESM(require("tiny-invariant"));
|
|
341
349
|
var import_async3 = require("@dxos/async");
|
|
342
350
|
var import_credentials5 = require("@dxos/credentials");
|
|
343
351
|
var import_keys2 = require("@dxos/keys");
|
|
@@ -345,6 +353,7 @@ var import_log3 = require("@dxos/log");
|
|
|
345
353
|
var import_protocols2 = require("@dxos/protocols");
|
|
346
354
|
var import_credentials6 = require("@dxos/protocols/proto/dxos/halo/credentials");
|
|
347
355
|
var import_util = require("@dxos/util");
|
|
356
|
+
var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/identity-manager.ts";
|
|
348
357
|
var IdentityManager = class {
|
|
349
358
|
// TODO(burdon): IdentityManagerParams.
|
|
350
359
|
// TODO(dmaretskyi): Perhaps this should take/generate the peerKey outside of an initialized identity.
|
|
@@ -364,20 +373,20 @@ var IdentityManager = class {
|
|
|
364
373
|
import_log3.log.trace("dxos.halo.identity-manager.open", import_protocols2.trace.begin({
|
|
365
374
|
id: traceId
|
|
366
375
|
}), {
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
376
|
+
F: __dxlog_file3,
|
|
377
|
+
L: 70,
|
|
378
|
+
S: this,
|
|
379
|
+
C: (f, a) => f(...a)
|
|
371
380
|
});
|
|
372
381
|
await this._metadataStore.load();
|
|
373
382
|
const identityRecord = this._metadataStore.getIdentityRecord();
|
|
374
383
|
(0, import_log3.log)("identity record", {
|
|
375
384
|
identityRecord
|
|
376
385
|
}, {
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
386
|
+
F: __dxlog_file3,
|
|
387
|
+
L: 74,
|
|
388
|
+
S: this,
|
|
389
|
+
C: (f, a) => f(...a)
|
|
381
390
|
});
|
|
382
391
|
if (identityRecord) {
|
|
383
392
|
this._identity = await this._constructIdentity(identityRecord);
|
|
@@ -387,20 +396,20 @@ var IdentityManager = class {
|
|
|
387
396
|
identityKey: identityRecord.identityKey,
|
|
388
397
|
displayName: (_a = this._identity.profileDocument) == null ? void 0 : _a.displayName
|
|
389
398
|
}, {
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
399
|
+
F: __dxlog_file3,
|
|
400
|
+
L: 79,
|
|
401
|
+
S: this,
|
|
402
|
+
C: (f, a) => f(...a)
|
|
394
403
|
});
|
|
395
404
|
this.stateUpdate.emit();
|
|
396
405
|
}
|
|
397
406
|
import_log3.log.trace("dxos.halo.identity-manager.open", import_protocols2.trace.end({
|
|
398
407
|
id: traceId
|
|
399
408
|
}), {
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
409
|
+
F: __dxlog_file3,
|
|
410
|
+
L: 85,
|
|
411
|
+
S: this,
|
|
412
|
+
C: (f, a) => f(...a)
|
|
404
413
|
});
|
|
405
414
|
}
|
|
406
415
|
async close() {
|
|
@@ -409,12 +418,12 @@ var IdentityManager = class {
|
|
|
409
418
|
}
|
|
410
419
|
async createIdentity({ displayName } = {}) {
|
|
411
420
|
var _a;
|
|
412
|
-
(0,
|
|
413
|
-
(0, import_log3.log)("creating identity...",
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
421
|
+
(0, import_tiny_invariant2.default)(!this._identity, "Identity already exists.");
|
|
422
|
+
(0, import_log3.log)("creating identity...", void 0, {
|
|
423
|
+
F: __dxlog_file3,
|
|
424
|
+
L: 94,
|
|
425
|
+
S: this,
|
|
426
|
+
C: (f, a) => f(...a)
|
|
418
427
|
});
|
|
419
428
|
const controlFeedKey = await this._keyring.createKey();
|
|
420
429
|
const identityRecord = {
|
|
@@ -431,8 +440,8 @@ var IdentityManager = class {
|
|
|
431
440
|
await identity.open();
|
|
432
441
|
{
|
|
433
442
|
const generator = new import_credentials5.CredentialGenerator(this._keyring, identityRecord.identityKey, identityRecord.deviceKey);
|
|
434
|
-
(0,
|
|
435
|
-
(0,
|
|
443
|
+
(0, import_tiny_invariant2.default)(identityRecord.haloSpace.genesisFeedKey, "Genesis feed key is required.");
|
|
444
|
+
(0, import_tiny_invariant2.default)(identityRecord.haloSpace.dataFeedKey, "Data feed key is required.");
|
|
436
445
|
const credentials = [
|
|
437
446
|
// Space genesis.
|
|
438
447
|
...await generator.createSpaceGenesis(identityRecord.haloSpace.key, identityRecord.haloSpace.genesisFeedKey),
|
|
@@ -460,20 +469,20 @@ var IdentityManager = class {
|
|
|
460
469
|
identityKey: identityRecord.identityKey,
|
|
461
470
|
displayName: (_a = this._identity.profileDocument) == null ? void 0 : _a.displayName
|
|
462
471
|
}, {
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
472
|
+
F: __dxlog_file3,
|
|
473
|
+
L: 149,
|
|
474
|
+
S: this,
|
|
475
|
+
C: (f, a) => f(...a)
|
|
467
476
|
});
|
|
468
477
|
this.stateUpdate.emit();
|
|
469
478
|
(0, import_log3.log)("created identity", {
|
|
470
479
|
identityKey: identity.identityKey,
|
|
471
480
|
deviceKey: identity.deviceKey
|
|
472
481
|
}, {
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
482
|
+
F: __dxlog_file3,
|
|
483
|
+
L: 155,
|
|
484
|
+
S: this,
|
|
485
|
+
C: (f, a) => f(...a)
|
|
477
486
|
});
|
|
478
487
|
return identity;
|
|
479
488
|
}
|
|
@@ -485,12 +494,12 @@ var IdentityManager = class {
|
|
|
485
494
|
(0, import_log3.log)("accepting identity", {
|
|
486
495
|
params
|
|
487
496
|
}, {
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
497
|
+
F: __dxlog_file3,
|
|
498
|
+
L: 163,
|
|
499
|
+
S: this,
|
|
500
|
+
C: (f, a) => f(...a)
|
|
492
501
|
});
|
|
493
|
-
(0,
|
|
502
|
+
(0, import_tiny_invariant2.default)(!this._identity, "Identity already exists.");
|
|
494
503
|
const identityRecord = {
|
|
495
504
|
identityKey: params.identityKey,
|
|
496
505
|
deviceKey: params.deviceKey,
|
|
@@ -511,38 +520,38 @@ var IdentityManager = class {
|
|
|
511
520
|
identityKey: identityRecord.identityKey,
|
|
512
521
|
displayName: (_a = this._identity.profileDocument) == null ? void 0 : _a.displayName
|
|
513
522
|
}, {
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
523
|
+
F: __dxlog_file3,
|
|
524
|
+
L: 183,
|
|
525
|
+
S: this,
|
|
526
|
+
C: (f, a) => f(...a)
|
|
518
527
|
});
|
|
519
528
|
this.stateUpdate.emit();
|
|
520
529
|
(0, import_log3.log)("accepted identity", {
|
|
521
530
|
identityKey: identity.identityKey,
|
|
522
531
|
deviceKey: identity.deviceKey
|
|
523
532
|
}, {
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
533
|
+
F: __dxlog_file3,
|
|
534
|
+
L: 189,
|
|
535
|
+
S: this,
|
|
536
|
+
C: (f, a) => f(...a)
|
|
528
537
|
});
|
|
529
538
|
return identity;
|
|
530
539
|
}
|
|
531
540
|
async _constructIdentity(identityRecord) {
|
|
532
|
-
(0,
|
|
541
|
+
(0, import_tiny_invariant2.default)(!this._identity);
|
|
533
542
|
(0, import_log3.log)("constructing identity", {
|
|
534
543
|
identityRecord
|
|
535
544
|
}, {
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
545
|
+
F: __dxlog_file3,
|
|
546
|
+
L: 195,
|
|
547
|
+
S: this,
|
|
548
|
+
C: (f, a) => f(...a)
|
|
540
549
|
});
|
|
541
|
-
(0,
|
|
550
|
+
(0, import_tiny_invariant2.default)(identityRecord.haloSpace.controlFeedKey);
|
|
542
551
|
const controlFeed = await this._feedStore.openFeed(identityRecord.haloSpace.controlFeedKey, {
|
|
543
552
|
writable: true
|
|
544
553
|
});
|
|
545
|
-
(0,
|
|
554
|
+
(0, import_tiny_invariant2.default)(identityRecord.haloSpace.dataFeedKey);
|
|
546
555
|
const dataFeed = await this._feedStore.openFeed(identityRecord.haloSpace.dataFeedKey, {
|
|
547
556
|
writable: true,
|
|
548
557
|
sparse: true
|
|
@@ -567,10 +576,10 @@ var IdentityManager = class {
|
|
|
567
576
|
(0, import_log3.log)("done", {
|
|
568
577
|
identityKey: identityRecord.identityKey
|
|
569
578
|
}, {
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
579
|
+
F: __dxlog_file3,
|
|
580
|
+
L: 226,
|
|
581
|
+
S: this,
|
|
582
|
+
C: (f, a) => f(...a)
|
|
574
583
|
});
|
|
575
584
|
if (identityRecord.haloSpace.controlTimeframe) {
|
|
576
585
|
identity.controlPipeline.state.setTargetTimeframe(identityRecord.haloSpace.controlTimeframe);
|
|
@@ -587,11 +596,11 @@ var IdentityManager = class {
|
|
|
587
596
|
onNetworkConnection: () => {
|
|
588
597
|
},
|
|
589
598
|
onAuthFailure: () => {
|
|
590
|
-
import_log3.log.warn("auth failure",
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
599
|
+
import_log3.log.warn("auth failure", void 0, {
|
|
600
|
+
F: __dxlog_file3,
|
|
601
|
+
L: 245,
|
|
602
|
+
S: this,
|
|
603
|
+
C: (f, a) => f(...a)
|
|
595
604
|
});
|
|
596
605
|
},
|
|
597
606
|
memberKey: identityKey
|
|
@@ -600,10 +609,10 @@ var IdentityManager = class {
|
|
|
600
609
|
};
|
|
601
610
|
|
|
602
611
|
// packages/sdk/client-services/src/packlets/identity/identity-service.ts
|
|
603
|
-
var
|
|
604
|
-
var
|
|
612
|
+
var import_tiny_invariant3 = __toESM(require("tiny-invariant"));
|
|
613
|
+
var import_codec_protobuf2 = require("@dxos/codec-protobuf");
|
|
605
614
|
var import_credentials7 = require("@dxos/credentials");
|
|
606
|
-
var
|
|
615
|
+
var import_debug3 = require("@dxos/debug");
|
|
607
616
|
var IdentityServiceImpl = class {
|
|
608
617
|
// TODO(wittjosiah): Remove dependency on service context.
|
|
609
618
|
constructor(_serviceContext) {
|
|
@@ -614,10 +623,10 @@ var IdentityServiceImpl = class {
|
|
|
614
623
|
return this._getIdentity();
|
|
615
624
|
}
|
|
616
625
|
async recoverIdentity(request) {
|
|
617
|
-
return (0,
|
|
626
|
+
return (0, import_debug3.todo)();
|
|
618
627
|
}
|
|
619
628
|
queryIdentity() {
|
|
620
|
-
return new
|
|
629
|
+
return new import_codec_protobuf2.Stream(({ next }) => {
|
|
621
630
|
const emitNext = () => next({
|
|
622
631
|
identity: this._getIdentity()
|
|
623
632
|
});
|
|
@@ -636,7 +645,7 @@ var IdentityServiceImpl = class {
|
|
|
636
645
|
};
|
|
637
646
|
}
|
|
638
647
|
async signPresentation({ presentation, nonce }) {
|
|
639
|
-
(0,
|
|
648
|
+
(0, import_tiny_invariant3.default)(this._serviceContext.identityManager.identity, "Identity not initialized.");
|
|
640
649
|
return await (0, import_credentials7.signPresentation)({
|
|
641
650
|
presentation,
|
|
642
651
|
signer: this._serviceContext.keyring,
|
|
@@ -648,7 +657,7 @@ var IdentityServiceImpl = class {
|
|
|
648
657
|
};
|
|
649
658
|
|
|
650
659
|
// packages/sdk/client-services/src/packlets/invitations/device-invitation-protocol.ts
|
|
651
|
-
var
|
|
660
|
+
var import_tiny_invariant4 = __toESM(require("tiny-invariant"));
|
|
652
661
|
var import_services = require("@dxos/protocols/proto/dxos/client/services");
|
|
653
662
|
var DeviceInvitationProtocol = class {
|
|
654
663
|
constructor(_keyring, _getIdentity, _acceptIdentity) {
|
|
@@ -665,7 +674,7 @@ var DeviceInvitationProtocol = class {
|
|
|
665
674
|
};
|
|
666
675
|
}
|
|
667
676
|
async admit(request) {
|
|
668
|
-
(0,
|
|
677
|
+
(0, import_tiny_invariant4.default)(request.device);
|
|
669
678
|
const identity = this._getIdentity();
|
|
670
679
|
await identity.admitDevice(request.device);
|
|
671
680
|
return {
|
|
@@ -693,9 +702,9 @@ var DeviceInvitationProtocol = class {
|
|
|
693
702
|
};
|
|
694
703
|
}
|
|
695
704
|
async accept(response, request) {
|
|
696
|
-
(0,
|
|
705
|
+
(0, import_tiny_invariant4.default)(response.device);
|
|
697
706
|
const { identityKey, haloSpaceKey, genesisFeedKey, controlTimeframe } = response.device;
|
|
698
|
-
(0,
|
|
707
|
+
(0, import_tiny_invariant4.default)(request.device);
|
|
699
708
|
const { deviceKey, controlFeedKey, dataFeedKey } = request.device;
|
|
700
709
|
await this._acceptIdentity({
|
|
701
710
|
identityKey,
|
|
@@ -713,7 +722,7 @@ var DeviceInvitationProtocol = class {
|
|
|
713
722
|
};
|
|
714
723
|
|
|
715
724
|
// packages/sdk/client-services/src/packlets/invitations/invitations-handler.ts
|
|
716
|
-
var
|
|
725
|
+
var import_tiny_invariant6 = __toESM(require("tiny-invariant"));
|
|
717
726
|
var import_async5 = require("@dxos/async");
|
|
718
727
|
var import_client_protocol2 = require("@dxos/client-protocol");
|
|
719
728
|
var import_context3 = require("@dxos/context");
|
|
@@ -727,7 +736,7 @@ var import_services3 = require("@dxos/protocols/proto/dxos/client/services");
|
|
|
727
736
|
var import_invitations2 = require("@dxos/protocols/proto/dxos/halo/invitations");
|
|
728
737
|
|
|
729
738
|
// packages/sdk/client-services/src/packlets/invitations/invitation-extension.ts
|
|
730
|
-
var
|
|
739
|
+
var import_tiny_invariant5 = __toESM(require("tiny-invariant"));
|
|
731
740
|
var import_async4 = require("@dxos/async");
|
|
732
741
|
var import_context2 = require("@dxos/context");
|
|
733
742
|
var import_errors = require("@dxos/errors");
|
|
@@ -737,6 +746,7 @@ var import_protocols3 = require("@dxos/protocols");
|
|
|
737
746
|
var import_services2 = require("@dxos/protocols/proto/dxos/client/services");
|
|
738
747
|
var import_invitations = require("@dxos/protocols/proto/dxos/halo/invitations");
|
|
739
748
|
var import_teleport = require("@dxos/teleport");
|
|
749
|
+
var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitation-extension.ts";
|
|
740
750
|
var OPTIONS_TIMEOUT = 1e4;
|
|
741
751
|
var MAX_OTP_ATTEMPTS = 3;
|
|
742
752
|
var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
@@ -764,7 +774,7 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
764
774
|
// Perhaps in the future we will have more complex logic here.
|
|
765
775
|
InvitationHostService: {
|
|
766
776
|
options: async (options) => {
|
|
767
|
-
(0,
|
|
777
|
+
(0, import_tiny_invariant5.default)(!this._remoteOptions, "Remote options already set.");
|
|
768
778
|
this._remoteOptions = options;
|
|
769
779
|
this._remoteOptionsTrigger.wake();
|
|
770
780
|
},
|
|
@@ -774,20 +784,20 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
774
784
|
import_log4.log.trace("dxos.sdk.invitation-handler.host.introduce", import_protocols3.trace.begin({
|
|
775
785
|
id: traceId
|
|
776
786
|
}), {
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
787
|
+
F: __dxlog_file4,
|
|
788
|
+
L: 98,
|
|
789
|
+
S: this,
|
|
790
|
+
C: (f, a) => f(...a)
|
|
781
791
|
});
|
|
782
792
|
const invitation = await this._callbacks.resolveInvitation(request);
|
|
783
793
|
if (!invitation) {
|
|
784
794
|
import_log4.log.warn("invitation not found", {
|
|
785
795
|
invitationId
|
|
786
796
|
}, {
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
797
|
+
F: __dxlog_file4,
|
|
798
|
+
L: 102,
|
|
799
|
+
S: this,
|
|
800
|
+
C: (f, a) => f(...a)
|
|
791
801
|
});
|
|
792
802
|
this._callbacks.onError(new Error("Invitation not found."));
|
|
793
803
|
return {
|
|
@@ -798,10 +808,10 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
798
808
|
(0, import_log4.log)("guest introduced itself", {
|
|
799
809
|
guestProfile: profile
|
|
800
810
|
}, {
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
811
|
+
F: __dxlog_file4,
|
|
812
|
+
L: 111,
|
|
813
|
+
S: this,
|
|
814
|
+
C: (f, a) => f(...a)
|
|
805
815
|
});
|
|
806
816
|
this.guestProfile = profile;
|
|
807
817
|
this._callbacks.onStateUpdate({
|
|
@@ -811,10 +821,10 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
811
821
|
import_log4.log.trace("dxos.sdk.invitation-handler.host.introduce", import_protocols3.trace.end({
|
|
812
822
|
id: traceId
|
|
813
823
|
}), {
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
824
|
+
F: __dxlog_file4,
|
|
825
|
+
L: 118,
|
|
826
|
+
S: this,
|
|
827
|
+
C: (f, a) => f(...a)
|
|
818
828
|
});
|
|
819
829
|
return {
|
|
820
830
|
spaceKey: this.invitation.authMethod === import_services2.Invitation.AuthMethod.NONE ? this.invitation.spaceKey : void 0,
|
|
@@ -826,28 +836,28 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
826
836
|
import_log4.log.trace("dxos.sdk.invitation-handler.host.authenticate", import_protocols3.trace.begin({
|
|
827
837
|
id: traceId
|
|
828
838
|
}), {
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
839
|
+
F: __dxlog_file4,
|
|
840
|
+
L: 127,
|
|
841
|
+
S: this,
|
|
842
|
+
C: (f, a) => f(...a)
|
|
833
843
|
});
|
|
834
844
|
(0, import_log4.log)("received authentication request", {
|
|
835
845
|
authCode: code
|
|
836
846
|
}, {
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
847
|
+
F: __dxlog_file4,
|
|
848
|
+
L: 128,
|
|
849
|
+
S: this,
|
|
850
|
+
C: (f, a) => f(...a)
|
|
841
851
|
});
|
|
842
852
|
let status = import_invitations.AuthenticationResponse.Status.OK;
|
|
843
|
-
(0,
|
|
853
|
+
(0, import_tiny_invariant5.default)(this.invitation, "Invitation is not set.");
|
|
844
854
|
switch (this.invitation.authMethod) {
|
|
845
855
|
case import_services2.Invitation.AuthMethod.NONE: {
|
|
846
|
-
(0, import_log4.log)("authentication not required",
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
856
|
+
(0, import_log4.log)("authentication not required", void 0, {
|
|
857
|
+
F: __dxlog_file4,
|
|
858
|
+
L: 134,
|
|
859
|
+
S: this,
|
|
860
|
+
C: (f, a) => f(...a)
|
|
851
861
|
});
|
|
852
862
|
return {
|
|
853
863
|
status: import_invitations.AuthenticationResponse.Status.OK
|
|
@@ -869,10 +879,10 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
869
879
|
import_log4.log.error("invalid authentication method", {
|
|
870
880
|
authMethod: this.invitation.authMethod
|
|
871
881
|
}, {
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
882
|
+
F: __dxlog_file4,
|
|
883
|
+
L: 152,
|
|
884
|
+
S: this,
|
|
885
|
+
C: (f, a) => f(...a)
|
|
876
886
|
});
|
|
877
887
|
status = import_invitations.AuthenticationResponse.Status.INTERNAL_ERROR;
|
|
878
888
|
break;
|
|
@@ -884,10 +894,10 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
884
894
|
status
|
|
885
895
|
}
|
|
886
896
|
}), {
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
897
|
+
F: __dxlog_file4,
|
|
898
|
+
L: 158,
|
|
899
|
+
S: this,
|
|
900
|
+
C: (f, a) => f(...a)
|
|
891
901
|
});
|
|
892
902
|
return {
|
|
893
903
|
status
|
|
@@ -898,13 +908,13 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
898
908
|
import_log4.log.trace("dxos.sdk.invitation-handler.host.admit", import_protocols3.trace.begin({
|
|
899
909
|
id: traceId
|
|
900
910
|
}), {
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
911
|
+
F: __dxlog_file4,
|
|
912
|
+
L: 164,
|
|
913
|
+
S: this,
|
|
914
|
+
C: (f, a) => f(...a)
|
|
905
915
|
});
|
|
906
916
|
try {
|
|
907
|
-
(0,
|
|
917
|
+
(0, import_tiny_invariant5.default)(this.invitation, "Invitation is not set.");
|
|
908
918
|
if (isAuthenticationRequired(this.invitation) && !this.authenticationPassed) {
|
|
909
919
|
throw new Error("Not authenticated");
|
|
910
920
|
}
|
|
@@ -912,10 +922,10 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
912
922
|
import_log4.log.trace("dxos.sdk.invitation-handler.host.admit", import_protocols3.trace.end({
|
|
913
923
|
id: traceId
|
|
914
924
|
}), {
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
925
|
+
F: __dxlog_file4,
|
|
926
|
+
L: 175,
|
|
927
|
+
S: this,
|
|
928
|
+
C: (f, a) => f(...a)
|
|
919
929
|
});
|
|
920
930
|
return response;
|
|
921
931
|
} catch (err) {
|
|
@@ -969,7 +979,7 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
|
|
|
969
979
|
return {
|
|
970
980
|
InvitationHostService: {
|
|
971
981
|
options: async (options) => {
|
|
972
|
-
(0,
|
|
982
|
+
(0, import_tiny_invariant5.default)(!this._remoteOptions, "Remote options already set.");
|
|
973
983
|
this._remoteOptions = options;
|
|
974
984
|
this._remoteOptionsTrigger.wake();
|
|
975
985
|
},
|
|
@@ -989,11 +999,11 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
|
|
|
989
999
|
var _a;
|
|
990
1000
|
await super.onOpen(context);
|
|
991
1001
|
try {
|
|
992
|
-
(0, import_log4.log)("begin options",
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
1002
|
+
(0, import_log4.log)("begin options", void 0, {
|
|
1003
|
+
F: __dxlog_file4,
|
|
1004
|
+
L: 263,
|
|
1005
|
+
S: this,
|
|
1006
|
+
C: (f, a) => f(...a)
|
|
997
1007
|
});
|
|
998
1008
|
await (0, import_context2.cancelWithContext)(this._ctx, this.rpc.InvitationHostService.options({
|
|
999
1009
|
role: import_invitations.Options.Role.GUEST
|
|
@@ -1001,11 +1011,11 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
|
|
|
1001
1011
|
await (0, import_context2.cancelWithContext)(this._ctx, this._remoteOptionsTrigger.wait({
|
|
1002
1012
|
timeout: OPTIONS_TIMEOUT
|
|
1003
1013
|
}));
|
|
1004
|
-
(0, import_log4.log)("end options",
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1014
|
+
(0, import_log4.log)("end options", void 0, {
|
|
1015
|
+
F: __dxlog_file4,
|
|
1016
|
+
L: 266,
|
|
1017
|
+
S: this,
|
|
1018
|
+
C: (f, a) => f(...a)
|
|
1009
1019
|
});
|
|
1010
1020
|
if (((_a = this._remoteOptions) == null ? void 0 : _a.role) !== import_invitations.Options.Role.HOST) {
|
|
1011
1021
|
throw new import_errors.InvalidInvitationExtensionRoleError(void 0, {
|
|
@@ -1016,20 +1026,20 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
|
|
|
1016
1026
|
this._callbacks.onOpen(this._ctx);
|
|
1017
1027
|
} catch (err) {
|
|
1018
1028
|
(0, import_log4.log)("openError", err, {
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1029
|
+
F: __dxlog_file4,
|
|
1030
|
+
L: 276,
|
|
1031
|
+
S: this,
|
|
1032
|
+
C: (f, a) => f(...a)
|
|
1023
1033
|
});
|
|
1024
1034
|
this._callbacks.onError(err);
|
|
1025
1035
|
}
|
|
1026
1036
|
}
|
|
1027
1037
|
async onClose() {
|
|
1028
|
-
(0, import_log4.log)("onClose",
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1038
|
+
(0, import_log4.log)("onClose", void 0, {
|
|
1039
|
+
F: __dxlog_file4,
|
|
1040
|
+
L: 282,
|
|
1041
|
+
S: this,
|
|
1042
|
+
C: (f, a) => f(...a)
|
|
1033
1043
|
});
|
|
1034
1044
|
await this._ctx.dispose();
|
|
1035
1045
|
}
|
|
@@ -1037,6 +1047,7 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
|
|
|
1037
1047
|
var isAuthenticationRequired = (invitation) => invitation.authMethod !== import_services2.Invitation.AuthMethod.NONE;
|
|
1038
1048
|
|
|
1039
1049
|
// packages/sdk/client-services/src/packlets/invitations/invitations-handler.ts
|
|
1050
|
+
var __dxlog_file5 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitations-handler.ts";
|
|
1040
1051
|
var InvitationsHandler = class {
|
|
1041
1052
|
/**
|
|
1042
1053
|
* @internal
|
|
@@ -1048,7 +1059,7 @@ var InvitationsHandler = class {
|
|
|
1048
1059
|
var _a;
|
|
1049
1060
|
const { invitationId = import_keys4.PublicKey.random().toHex(), type = import_services3.Invitation.Type.INTERACTIVE, authMethod = import_services3.Invitation.AuthMethod.SHARED_SECRET, state = import_services3.Invitation.State.INIT, timeout = import_client_protocol2.INVITATION_TIMEOUT, swarmKey = import_keys4.PublicKey.random() } = options != null ? options : {};
|
|
1050
1061
|
const authCode = (_a = options == null ? void 0 : options.authCode) != null ? _a : authMethod === import_services3.Invitation.AuthMethod.SHARED_SECRET ? (0, import_credentials8.generatePasscode)(import_client_protocol2.AUTHENTICATION_CODE_LENGTH) : void 0;
|
|
1051
|
-
(0,
|
|
1062
|
+
(0, import_tiny_invariant6.default)(protocol);
|
|
1052
1063
|
const invitation = {
|
|
1053
1064
|
invitationId,
|
|
1054
1065
|
type,
|
|
@@ -1070,10 +1081,10 @@ var InvitationsHandler = class {
|
|
|
1070
1081
|
(0, import_log5.log)("complete", {
|
|
1071
1082
|
...protocol.toJSON()
|
|
1072
1083
|
}, {
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1084
|
+
F: __dxlog_file5,
|
|
1085
|
+
L: 99,
|
|
1086
|
+
S: this,
|
|
1087
|
+
C: (f, a) => f(...a)
|
|
1077
1088
|
});
|
|
1078
1089
|
stream.complete();
|
|
1079
1090
|
});
|
|
@@ -1095,7 +1106,7 @@ var InvitationsHandler = class {
|
|
|
1095
1106
|
var _a2, _b, _c;
|
|
1096
1107
|
try {
|
|
1097
1108
|
const deviceKey = (_c = (_a2 = admissionRequest.device) == null ? void 0 : _a2.deviceKey) != null ? _c : (_b = admissionRequest.space) == null ? void 0 : _b.deviceKey;
|
|
1098
|
-
(0,
|
|
1109
|
+
(0, import_tiny_invariant6.default)(deviceKey);
|
|
1099
1110
|
const admissionResponse = await protocol.admit(admissionRequest, extension.guestProfile);
|
|
1100
1111
|
extension.completedTrigger.wake(deviceKey);
|
|
1101
1112
|
return admissionResponse;
|
|
@@ -1111,18 +1122,18 @@ var InvitationsHandler = class {
|
|
|
1111
1122
|
import_log5.log.trace("dxos.sdk.invitations-handler.host.onOpen", import_protocols4.trace.begin({
|
|
1112
1123
|
id: traceId
|
|
1113
1124
|
}), {
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1125
|
+
F: __dxlog_file5,
|
|
1126
|
+
L: 138,
|
|
1127
|
+
S: this,
|
|
1128
|
+
C: (f, a) => f(...a)
|
|
1118
1129
|
});
|
|
1119
1130
|
(0, import_log5.log)("connected", {
|
|
1120
1131
|
...protocol.toJSON()
|
|
1121
1132
|
}, {
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1133
|
+
F: __dxlog_file5,
|
|
1134
|
+
L: 139,
|
|
1135
|
+
S: this,
|
|
1136
|
+
C: (f, a) => f(...a)
|
|
1126
1137
|
});
|
|
1127
1138
|
stream.next({
|
|
1128
1139
|
...invitation,
|
|
@@ -1135,10 +1146,10 @@ var InvitationsHandler = class {
|
|
|
1135
1146
|
guest: deviceKey,
|
|
1136
1147
|
...protocol.toJSON()
|
|
1137
1148
|
}, {
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1149
|
+
F: __dxlog_file5,
|
|
1150
|
+
L: 142,
|
|
1151
|
+
S: this,
|
|
1152
|
+
C: (f, a) => f(...a)
|
|
1142
1153
|
});
|
|
1143
1154
|
stream.next({
|
|
1144
1155
|
...invitation,
|
|
@@ -1147,20 +1158,20 @@ var InvitationsHandler = class {
|
|
|
1147
1158
|
import_log5.log.trace("dxos.sdk.invitations-handler.host.onOpen", import_protocols4.trace.end({
|
|
1148
1159
|
id: traceId
|
|
1149
1160
|
}), {
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1161
|
+
F: __dxlog_file5,
|
|
1162
|
+
L: 144,
|
|
1163
|
+
S: this,
|
|
1164
|
+
C: (f, a) => f(...a)
|
|
1154
1165
|
});
|
|
1155
1166
|
} catch (err) {
|
|
1156
1167
|
if (err instanceof import_async5.TimeoutError) {
|
|
1157
1168
|
(0, import_log5.log)("timeout", {
|
|
1158
1169
|
...protocol.toJSON()
|
|
1159
1170
|
}, {
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1171
|
+
F: __dxlog_file5,
|
|
1172
|
+
L: 147,
|
|
1173
|
+
S: this,
|
|
1174
|
+
C: (f, a) => f(...a)
|
|
1164
1175
|
});
|
|
1165
1176
|
stream.next({
|
|
1166
1177
|
...invitation,
|
|
@@ -1168,10 +1179,10 @@ var InvitationsHandler = class {
|
|
|
1168
1179
|
});
|
|
1169
1180
|
} else {
|
|
1170
1181
|
import_log5.log.error("failed", err, {
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1182
|
+
F: __dxlog_file5,
|
|
1183
|
+
L: 150,
|
|
1184
|
+
S: this,
|
|
1185
|
+
C: (f, a) => f(...a)
|
|
1175
1186
|
});
|
|
1176
1187
|
stream.error(err);
|
|
1177
1188
|
}
|
|
@@ -1179,10 +1190,10 @@ var InvitationsHandler = class {
|
|
|
1179
1190
|
id: traceId,
|
|
1180
1191
|
error: err
|
|
1181
1192
|
}), {
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1193
|
+
F: __dxlog_file5,
|
|
1194
|
+
L: 153,
|
|
1195
|
+
S: this,
|
|
1196
|
+
C: (f, a) => f(...a)
|
|
1186
1197
|
});
|
|
1187
1198
|
} finally {
|
|
1188
1199
|
if (type !== import_services3.Invitation.Type.MULTIUSE) {
|
|
@@ -1200,10 +1211,10 @@ var InvitationsHandler = class {
|
|
|
1200
1211
|
(0, import_log5.log)("timeout", {
|
|
1201
1212
|
...protocol.toJSON()
|
|
1202
1213
|
}, {
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1214
|
+
F: __dxlog_file5,
|
|
1215
|
+
L: 168,
|
|
1216
|
+
S: this,
|
|
1217
|
+
C: (f, a) => f(...a)
|
|
1207
1218
|
});
|
|
1208
1219
|
stream.next({
|
|
1209
1220
|
...invitation,
|
|
@@ -1211,10 +1222,10 @@ var InvitationsHandler = class {
|
|
|
1211
1222
|
});
|
|
1212
1223
|
} else {
|
|
1213
1224
|
import_log5.log.error("failed", err, {
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1225
|
+
F: __dxlog_file5,
|
|
1226
|
+
L: 171,
|
|
1227
|
+
S: this,
|
|
1228
|
+
C: (f, a) => f(...a)
|
|
1218
1229
|
});
|
|
1219
1230
|
stream.error(err);
|
|
1220
1231
|
}
|
|
@@ -1254,13 +1265,13 @@ var InvitationsHandler = class {
|
|
|
1254
1265
|
}
|
|
1255
1266
|
acceptInvitation(protocol, invitation) {
|
|
1256
1267
|
const { timeout = import_client_protocol2.INVITATION_TIMEOUT } = invitation;
|
|
1257
|
-
(0,
|
|
1268
|
+
(0, import_tiny_invariant6.default)(protocol);
|
|
1258
1269
|
const authenticated = new import_async5.Trigger();
|
|
1259
1270
|
let admitted = false;
|
|
1260
1271
|
let currentState;
|
|
1261
1272
|
const stream = new import_async5.PushStream();
|
|
1262
1273
|
const setState = (newData) => {
|
|
1263
|
-
(0,
|
|
1274
|
+
(0, import_tiny_invariant6.default)(newData.state !== void 0);
|
|
1264
1275
|
currentState = newData.state;
|
|
1265
1276
|
stream.next({
|
|
1266
1277
|
...invitation,
|
|
@@ -1273,20 +1284,20 @@ var InvitationsHandler = class {
|
|
|
1273
1284
|
(0, import_log5.log)("timeout", {
|
|
1274
1285
|
...protocol.toJSON()
|
|
1275
1286
|
}, {
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1287
|
+
F: __dxlog_file5,
|
|
1288
|
+
L: 230,
|
|
1289
|
+
S: this,
|
|
1290
|
+
C: (f, a) => f(...a)
|
|
1280
1291
|
});
|
|
1281
1292
|
setState({
|
|
1282
1293
|
state: import_services3.Invitation.State.TIMEOUT
|
|
1283
1294
|
});
|
|
1284
1295
|
} else {
|
|
1285
1296
|
import_log5.log.warn("auth failed", err, {
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1297
|
+
F: __dxlog_file5,
|
|
1298
|
+
L: 233,
|
|
1299
|
+
S: this,
|
|
1300
|
+
C: (f, a) => f(...a)
|
|
1290
1301
|
});
|
|
1291
1302
|
stream.error(err);
|
|
1292
1303
|
}
|
|
@@ -1297,10 +1308,10 @@ var InvitationsHandler = class {
|
|
|
1297
1308
|
(0, import_log5.log)("complete", {
|
|
1298
1309
|
...protocol.toJSON()
|
|
1299
1310
|
}, {
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1311
|
+
F: __dxlog_file5,
|
|
1312
|
+
L: 241,
|
|
1313
|
+
S: this,
|
|
1314
|
+
C: (f, a) => f(...a)
|
|
1304
1315
|
});
|
|
1305
1316
|
stream.complete();
|
|
1306
1317
|
});
|
|
@@ -1312,10 +1323,10 @@ var InvitationsHandler = class {
|
|
|
1312
1323
|
(0, import_log5.log)("extension disposed", {
|
|
1313
1324
|
currentState
|
|
1314
1325
|
}, {
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1326
|
+
F: __dxlog_file5,
|
|
1327
|
+
L: 251,
|
|
1328
|
+
S: this,
|
|
1329
|
+
C: (f, a) => f(...a)
|
|
1319
1330
|
});
|
|
1320
1331
|
if (!admitted) {
|
|
1321
1332
|
stream.error(new Error("Remote peer disconnected."));
|
|
@@ -1327,10 +1338,10 @@ var InvitationsHandler = class {
|
|
|
1327
1338
|
import_log5.log.trace("dxos.sdk.invitations-handler.guest.onOpen", import_protocols4.trace.begin({
|
|
1328
1339
|
id: traceId
|
|
1329
1340
|
}), {
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1341
|
+
F: __dxlog_file5,
|
|
1342
|
+
L: 260,
|
|
1343
|
+
S: this,
|
|
1344
|
+
C: (f, a) => f(...a)
|
|
1334
1345
|
});
|
|
1335
1346
|
if (++connectionCount > 1) {
|
|
1336
1347
|
throw new Error(`multiple connections detected: ${connectionCount}`);
|
|
@@ -1339,10 +1350,10 @@ var InvitationsHandler = class {
|
|
|
1339
1350
|
(0, import_log5.log)("connected", {
|
|
1340
1351
|
...protocol.toJSON()
|
|
1341
1352
|
}, {
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1353
|
+
F: __dxlog_file5,
|
|
1354
|
+
L: 268,
|
|
1355
|
+
S: this,
|
|
1356
|
+
C: (f, a) => f(...a)
|
|
1346
1357
|
});
|
|
1347
1358
|
setState({
|
|
1348
1359
|
state: import_services3.Invitation.State.CONNECTED
|
|
@@ -1350,20 +1361,20 @@ var InvitationsHandler = class {
|
|
|
1350
1361
|
(0, import_log5.log)("introduce", {
|
|
1351
1362
|
...protocol.toJSON()
|
|
1352
1363
|
}, {
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1364
|
+
F: __dxlog_file5,
|
|
1365
|
+
L: 272,
|
|
1366
|
+
S: this,
|
|
1367
|
+
C: (f, a) => f(...a)
|
|
1357
1368
|
});
|
|
1358
1369
|
const introductionResponse = await extension.rpc.InvitationHostService.introduce(protocol.createIntroduction());
|
|
1359
1370
|
(0, import_log5.log)("introduce response", {
|
|
1360
1371
|
...protocol.toJSON(),
|
|
1361
1372
|
response: introductionResponse
|
|
1362
1373
|
}, {
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1374
|
+
F: __dxlog_file5,
|
|
1375
|
+
L: 276,
|
|
1376
|
+
S: this,
|
|
1377
|
+
C: (f, a) => f(...a)
|
|
1367
1378
|
});
|
|
1368
1379
|
invitation.authMethod = introductionResponse.authMethod;
|
|
1369
1380
|
if (introductionResponse.spaceKey) {
|
|
@@ -1371,11 +1382,11 @@ var InvitationsHandler = class {
|
|
|
1371
1382
|
}
|
|
1372
1383
|
if (isAuthenticationRequired(invitation)) {
|
|
1373
1384
|
for (let attempt = 1; attempt <= MAX_OTP_ATTEMPTS; attempt++) {
|
|
1374
|
-
(0, import_log5.log)("guest waiting for authentication code...",
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1385
|
+
(0, import_log5.log)("guest waiting for authentication code...", void 0, {
|
|
1386
|
+
F: __dxlog_file5,
|
|
1387
|
+
L: 285,
|
|
1388
|
+
S: this,
|
|
1389
|
+
C: (f, a) => f(...a)
|
|
1379
1390
|
});
|
|
1380
1391
|
setState({
|
|
1381
1392
|
state: import_services3.Invitation.State.READY_FOR_AUTHENTICATION
|
|
@@ -1383,11 +1394,11 @@ var InvitationsHandler = class {
|
|
|
1383
1394
|
const authCode = await authenticated.wait({
|
|
1384
1395
|
timeout
|
|
1385
1396
|
});
|
|
1386
|
-
(0, import_log5.log)("sending authentication request",
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1397
|
+
(0, import_log5.log)("sending authentication request", void 0, {
|
|
1398
|
+
F: __dxlog_file5,
|
|
1399
|
+
L: 289,
|
|
1400
|
+
S: this,
|
|
1401
|
+
C: (f, a) => f(...a)
|
|
1391
1402
|
});
|
|
1392
1403
|
setState({
|
|
1393
1404
|
state: import_services3.Invitation.State.AUTHENTICATING
|
|
@@ -1405,10 +1416,10 @@ var InvitationsHandler = class {
|
|
|
1405
1416
|
(0, import_log5.log)("retrying invalid code", {
|
|
1406
1417
|
attempt
|
|
1407
1418
|
}, {
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1419
|
+
F: __dxlog_file5,
|
|
1420
|
+
L: 300,
|
|
1421
|
+
S: this,
|
|
1422
|
+
C: (f, a) => f(...a)
|
|
1412
1423
|
});
|
|
1413
1424
|
authenticated.reset();
|
|
1414
1425
|
}
|
|
@@ -1422,10 +1433,10 @@ var InvitationsHandler = class {
|
|
|
1422
1433
|
(0, import_log5.log)("request admission", {
|
|
1423
1434
|
...protocol.toJSON()
|
|
1424
1435
|
}, {
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1436
|
+
F: __dxlog_file5,
|
|
1437
|
+
L: 311,
|
|
1438
|
+
S: this,
|
|
1439
|
+
C: (f, a) => f(...a)
|
|
1429
1440
|
});
|
|
1430
1441
|
const admissionRequest = await protocol.createAdmissionRequest();
|
|
1431
1442
|
const admissionResponse = await extension.rpc.InvitationHostService.admit(admissionRequest);
|
|
@@ -1434,10 +1445,10 @@ var InvitationsHandler = class {
|
|
|
1434
1445
|
(0, import_log5.log)("admitted by host", {
|
|
1435
1446
|
...protocol.toJSON()
|
|
1436
1447
|
}, {
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1448
|
+
F: __dxlog_file5,
|
|
1449
|
+
L: 322,
|
|
1450
|
+
S: this,
|
|
1451
|
+
C: (f, a) => f(...a)
|
|
1441
1452
|
});
|
|
1442
1453
|
setState({
|
|
1443
1454
|
...result,
|
|
@@ -1446,30 +1457,30 @@ var InvitationsHandler = class {
|
|
|
1446
1457
|
import_log5.log.trace("dxos.sdk.invitations-handler.guest.onOpen", import_protocols4.trace.end({
|
|
1447
1458
|
id: traceId
|
|
1448
1459
|
}), {
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1460
|
+
F: __dxlog_file5,
|
|
1461
|
+
L: 324,
|
|
1462
|
+
S: this,
|
|
1463
|
+
C: (f, a) => f(...a)
|
|
1453
1464
|
});
|
|
1454
1465
|
} catch (err) {
|
|
1455
1466
|
if (err instanceof import_async5.TimeoutError) {
|
|
1456
1467
|
(0, import_log5.log)("timeout", {
|
|
1457
1468
|
...protocol.toJSON()
|
|
1458
1469
|
}, {
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1470
|
+
F: __dxlog_file5,
|
|
1471
|
+
L: 327,
|
|
1472
|
+
S: this,
|
|
1473
|
+
C: (f, a) => f(...a)
|
|
1463
1474
|
});
|
|
1464
1475
|
setState({
|
|
1465
1476
|
state: import_services3.Invitation.State.TIMEOUT
|
|
1466
1477
|
});
|
|
1467
1478
|
} else {
|
|
1468
1479
|
(0, import_log5.log)("auth failed", err, {
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1480
|
+
F: __dxlog_file5,
|
|
1481
|
+
L: 330,
|
|
1482
|
+
S: this,
|
|
1483
|
+
C: (f, a) => f(...a)
|
|
1473
1484
|
});
|
|
1474
1485
|
stream.error(err);
|
|
1475
1486
|
}
|
|
@@ -1477,10 +1488,10 @@ var InvitationsHandler = class {
|
|
|
1477
1488
|
id: traceId,
|
|
1478
1489
|
error: err
|
|
1479
1490
|
}), {
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1491
|
+
F: __dxlog_file5,
|
|
1492
|
+
L: 333,
|
|
1493
|
+
S: this,
|
|
1494
|
+
C: (f, a) => f(...a)
|
|
1484
1495
|
});
|
|
1485
1496
|
} finally {
|
|
1486
1497
|
await ctx.dispose();
|
|
@@ -1495,20 +1506,20 @@ var InvitationsHandler = class {
|
|
|
1495
1506
|
(0, import_log5.log)("timeout", {
|
|
1496
1507
|
...protocol.toJSON()
|
|
1497
1508
|
}, {
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1509
|
+
F: __dxlog_file5,
|
|
1510
|
+
L: 344,
|
|
1511
|
+
S: this,
|
|
1512
|
+
C: (f, a) => f(...a)
|
|
1502
1513
|
});
|
|
1503
1514
|
setState({
|
|
1504
1515
|
state: import_services3.Invitation.State.TIMEOUT
|
|
1505
1516
|
});
|
|
1506
1517
|
} else {
|
|
1507
1518
|
(0, import_log5.log)("auth failed", err, {
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1519
|
+
F: __dxlog_file5,
|
|
1520
|
+
L: 347,
|
|
1521
|
+
S: this,
|
|
1522
|
+
C: (f, a) => f(...a)
|
|
1512
1523
|
});
|
|
1513
1524
|
stream.error(err);
|
|
1514
1525
|
}
|
|
@@ -1517,7 +1528,7 @@ var InvitationsHandler = class {
|
|
|
1517
1528
|
return extension;
|
|
1518
1529
|
};
|
|
1519
1530
|
(0, import_async5.scheduleTask)(ctx, async () => {
|
|
1520
|
-
(0,
|
|
1531
|
+
(0, import_tiny_invariant6.default)(invitation.swarmKey);
|
|
1521
1532
|
const topic = invitation.swarmKey;
|
|
1522
1533
|
const swarmConnection = await this._networkManager.joinSwarm({
|
|
1523
1534
|
topic,
|
|
@@ -1550,11 +1561,12 @@ var InvitationsHandler = class {
|
|
|
1550
1561
|
};
|
|
1551
1562
|
|
|
1552
1563
|
// packages/sdk/client-services/src/packlets/invitations/invitations-service.ts
|
|
1553
|
-
var
|
|
1564
|
+
var import_tiny_invariant7 = __toESM(require("tiny-invariant"));
|
|
1554
1565
|
var import_async6 = require("@dxos/async");
|
|
1555
|
-
var
|
|
1566
|
+
var import_codec_protobuf3 = require("@dxos/codec-protobuf");
|
|
1556
1567
|
var import_log6 = require("@dxos/log");
|
|
1557
1568
|
var import_services4 = require("@dxos/protocols/proto/dxos/client/services");
|
|
1569
|
+
var __dxlog_file6 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitations-service.ts";
|
|
1558
1570
|
var InvitationsServiceImpl = class {
|
|
1559
1571
|
constructor(_invitationsHandler, _getHandler) {
|
|
1560
1572
|
this._invitationsHandler = _invitationsHandler;
|
|
@@ -1581,7 +1593,7 @@ var InvitationsServiceImpl = class {
|
|
|
1581
1593
|
this._createInvitations.set(invitation.get().invitationId, invitation);
|
|
1582
1594
|
this._invitationCreated.emit(invitation.get());
|
|
1583
1595
|
}
|
|
1584
|
-
return new
|
|
1596
|
+
return new import_codec_protobuf3.Stream(({ next, close }) => {
|
|
1585
1597
|
invitation.subscribe((invitation2) => {
|
|
1586
1598
|
next(invitation2);
|
|
1587
1599
|
}, (err) => {
|
|
@@ -1603,7 +1615,7 @@ var InvitationsServiceImpl = class {
|
|
|
1603
1615
|
this._acceptInvitations.set(invitation.get().invitationId, invitation);
|
|
1604
1616
|
this._invitationAccepted.emit(invitation.get());
|
|
1605
1617
|
}
|
|
1606
|
-
return new
|
|
1618
|
+
return new import_codec_protobuf3.Stream(({ next, close }) => {
|
|
1607
1619
|
invitation.subscribe((invitation2) => {
|
|
1608
1620
|
next(invitation2);
|
|
1609
1621
|
}, (err) => {
|
|
@@ -1615,35 +1627,35 @@ var InvitationsServiceImpl = class {
|
|
|
1615
1627
|
});
|
|
1616
1628
|
}
|
|
1617
1629
|
async authenticate({ invitationId, authCode }) {
|
|
1618
|
-
(0, import_log6.log)("authenticating...",
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1630
|
+
(0, import_log6.log)("authenticating...", void 0, {
|
|
1631
|
+
F: __dxlog_file6,
|
|
1632
|
+
L: 103,
|
|
1633
|
+
S: this,
|
|
1634
|
+
C: (f, a) => f(...a)
|
|
1623
1635
|
});
|
|
1624
|
-
(0,
|
|
1636
|
+
(0, import_tiny_invariant7.default)(invitationId);
|
|
1625
1637
|
const observable = this._acceptInvitations.get(invitationId);
|
|
1626
1638
|
if (!observable) {
|
|
1627
1639
|
import_log6.log.warn("invalid invitation", {
|
|
1628
1640
|
invitationId
|
|
1629
1641
|
}, {
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1642
|
+
F: __dxlog_file6,
|
|
1643
|
+
L: 107,
|
|
1644
|
+
S: this,
|
|
1645
|
+
C: (f, a) => f(...a)
|
|
1634
1646
|
});
|
|
1635
1647
|
} else {
|
|
1636
1648
|
await observable.authenticate(authCode);
|
|
1637
1649
|
}
|
|
1638
1650
|
}
|
|
1639
1651
|
async cancelInvitation({ invitationId }) {
|
|
1640
|
-
(0, import_log6.log)("deleting...",
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1652
|
+
(0, import_log6.log)("deleting...", void 0, {
|
|
1653
|
+
F: __dxlog_file6,
|
|
1654
|
+
L: 114,
|
|
1655
|
+
S: this,
|
|
1656
|
+
C: (f, a) => f(...a)
|
|
1645
1657
|
});
|
|
1646
|
-
(0,
|
|
1658
|
+
(0, import_tiny_invariant7.default)(invitationId);
|
|
1647
1659
|
const created = this._createInvitations.get(invitationId);
|
|
1648
1660
|
const accepted = this._acceptInvitations.get(invitationId);
|
|
1649
1661
|
if (created) {
|
|
@@ -1658,15 +1670,15 @@ var InvitationsServiceImpl = class {
|
|
|
1658
1670
|
import_log6.log.warn("invalid invitation", {
|
|
1659
1671
|
invitationId
|
|
1660
1672
|
}, {
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1673
|
+
F: __dxlog_file6,
|
|
1674
|
+
L: 127,
|
|
1675
|
+
S: this,
|
|
1676
|
+
C: (f, a) => f(...a)
|
|
1665
1677
|
});
|
|
1666
1678
|
}
|
|
1667
1679
|
}
|
|
1668
1680
|
queryInvitations() {
|
|
1669
|
-
return new
|
|
1681
|
+
return new import_codec_protobuf3.Stream(({ next, ctx }) => {
|
|
1670
1682
|
this._invitationCreated.on(ctx, (invitation) => {
|
|
1671
1683
|
next({
|
|
1672
1684
|
action: import_services4.QueryInvitationsResponse.Action.ADDED,
|
|
@@ -1718,11 +1730,12 @@ var InvitationsServiceImpl = class {
|
|
|
1718
1730
|
};
|
|
1719
1731
|
|
|
1720
1732
|
// packages/sdk/client-services/src/packlets/invitations/space-invitation-protocol.ts
|
|
1721
|
-
var
|
|
1733
|
+
var import_tiny_invariant8 = __toESM(require("tiny-invariant"));
|
|
1722
1734
|
var import_credentials9 = require("@dxos/credentials");
|
|
1723
1735
|
var import_feed_store2 = require("@dxos/feed-store");
|
|
1724
1736
|
var import_log7 = require("@dxos/log");
|
|
1725
1737
|
var import_services5 = require("@dxos/protocols/proto/dxos/client/services");
|
|
1738
|
+
var __dxlog_file7 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/space-invitation-protocol.ts";
|
|
1726
1739
|
var SpaceInvitationProtocol = class {
|
|
1727
1740
|
constructor(_spaceManager, _signingContext, _keyring, _spaceKey) {
|
|
1728
1741
|
this._spaceManager = _spaceManager;
|
|
@@ -1744,24 +1757,24 @@ var SpaceInvitationProtocol = class {
|
|
|
1744
1757
|
}
|
|
1745
1758
|
async admit(request, guestProfile) {
|
|
1746
1759
|
var _a;
|
|
1747
|
-
(0,
|
|
1760
|
+
(0, import_tiny_invariant8.default)(this._spaceKey);
|
|
1748
1761
|
const space = await this._spaceManager.spaces.get(this._spaceKey);
|
|
1749
|
-
(0,
|
|
1750
|
-
(0,
|
|
1762
|
+
(0, import_tiny_invariant8.default)(space);
|
|
1763
|
+
(0, import_tiny_invariant8.default)(request.space);
|
|
1751
1764
|
const { identityKey, deviceKey } = request.space;
|
|
1752
1765
|
(0, import_log7.log)("writing guest credentials", {
|
|
1753
1766
|
host: this._signingContext.deviceKey,
|
|
1754
1767
|
guest: deviceKey
|
|
1755
1768
|
}, {
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1769
|
+
F: __dxlog_file7,
|
|
1770
|
+
L: 50,
|
|
1771
|
+
S: this,
|
|
1772
|
+
C: (f, a) => f(...a)
|
|
1760
1773
|
});
|
|
1761
1774
|
const credentials = await (0, import_credentials9.createAdmissionCredentials)(this._signingContext.credentialSigner, identityKey, space.key, space.inner.genesisFeedKey, guestProfile);
|
|
1762
|
-
(0,
|
|
1775
|
+
(0, import_tiny_invariant8.default)(credentials[0].credential);
|
|
1763
1776
|
const spaceMemberCredential = credentials[0].credential.credential;
|
|
1764
|
-
(0,
|
|
1777
|
+
(0, import_tiny_invariant8.default)((0, import_credentials9.getCredentialAssertion)(spaceMemberCredential)["@type"] === "dxos.halo.credentials.SpaceMember");
|
|
1765
1778
|
await (0, import_feed_store2.writeMessages)(space.inner.controlPipeline.writer, credentials);
|
|
1766
1779
|
return {
|
|
1767
1780
|
space: {
|
|
@@ -1789,11 +1802,11 @@ var SpaceInvitationProtocol = class {
|
|
|
1789
1802
|
};
|
|
1790
1803
|
}
|
|
1791
1804
|
async accept(response) {
|
|
1792
|
-
(0,
|
|
1805
|
+
(0, import_tiny_invariant8.default)(response.space);
|
|
1793
1806
|
const { credential, controlTimeframe, dataTimeframe } = response.space;
|
|
1794
1807
|
const assertion = (0, import_credentials9.getCredentialAssertion)(credential);
|
|
1795
|
-
(0,
|
|
1796
|
-
(0,
|
|
1808
|
+
(0, import_tiny_invariant8.default)(assertion["@type"] === "dxos.halo.credentials.SpaceMember", "Invalid credential");
|
|
1809
|
+
(0, import_tiny_invariant8.default)(credential.subject.id.equals(this._signingContext.identityKey));
|
|
1797
1810
|
await this._spaceManager.acceptSpace({
|
|
1798
1811
|
spaceKey: assertion.spaceKey,
|
|
1799
1812
|
genesisFeedKey: assertion.genesisFeedKey,
|
|
@@ -1808,7 +1821,7 @@ var SpaceInvitationProtocol = class {
|
|
|
1808
1821
|
};
|
|
1809
1822
|
|
|
1810
1823
|
// packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts
|
|
1811
|
-
var
|
|
1824
|
+
var import_tiny_invariant10 = __toESM(require("tiny-invariant"));
|
|
1812
1825
|
var import_async9 = require("@dxos/async");
|
|
1813
1826
|
var import_context6 = require("@dxos/context");
|
|
1814
1827
|
var import_credentials13 = require("@dxos/credentials");
|
|
@@ -1823,7 +1836,7 @@ var import_util4 = require("@dxos/util");
|
|
|
1823
1836
|
var import_async8 = require("@dxos/async");
|
|
1824
1837
|
var import_client_protocol3 = require("@dxos/client-protocol");
|
|
1825
1838
|
var import_context5 = require("@dxos/context");
|
|
1826
|
-
var
|
|
1839
|
+
var import_debug4 = require("@dxos/debug");
|
|
1827
1840
|
var import_echo_pipeline = require("@dxos/echo-pipeline");
|
|
1828
1841
|
var import_errors3 = require("@dxos/errors");
|
|
1829
1842
|
var import_keys6 = require("@dxos/keys");
|
|
@@ -1834,7 +1847,7 @@ var import_timeframe = require("@dxos/timeframe");
|
|
|
1834
1847
|
var import_util3 = require("@dxos/util");
|
|
1835
1848
|
|
|
1836
1849
|
// packages/sdk/client-services/src/packlets/spaces/notarization-plugin.ts
|
|
1837
|
-
var
|
|
1850
|
+
var import_tiny_invariant9 = __toESM(require("tiny-invariant"));
|
|
1838
1851
|
var import_async7 = require("@dxos/async");
|
|
1839
1852
|
var import_context4 = require("@dxos/context");
|
|
1840
1853
|
var import_keys5 = require("@dxos/keys");
|
|
@@ -1842,6 +1855,7 @@ var import_log8 = require("@dxos/log");
|
|
|
1842
1855
|
var import_protocols5 = require("@dxos/protocols");
|
|
1843
1856
|
var import_teleport2 = require("@dxos/teleport");
|
|
1844
1857
|
var import_util2 = require("@dxos/util");
|
|
1858
|
+
var __dxlog_file8 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/notarization-plugin.ts";
|
|
1845
1859
|
var DEFAULT_RETRY_TIMEOUT = 1e3;
|
|
1846
1860
|
var DEFAULT_SUCCESS_DELAY = 1e3;
|
|
1847
1861
|
var DEFAULT_NOTARIZE_TIMEOUT = 1e4;
|
|
@@ -1854,6 +1868,9 @@ var NotarizationPlugin = class {
|
|
|
1854
1868
|
this._processedCredentials = new import_util2.ComplexSet(import_keys5.PublicKey.hash);
|
|
1855
1869
|
this._processCredentialsTriggers = new import_util2.ComplexMap(import_keys5.PublicKey.hash);
|
|
1856
1870
|
}
|
|
1871
|
+
get hasWriter() {
|
|
1872
|
+
return !!this._writer;
|
|
1873
|
+
}
|
|
1857
1874
|
async open() {
|
|
1858
1875
|
}
|
|
1859
1876
|
async close() {
|
|
@@ -1866,22 +1883,22 @@ var NotarizationPlugin = class {
|
|
|
1866
1883
|
(0, import_log8.log)("notarize", {
|
|
1867
1884
|
credentials
|
|
1868
1885
|
}, {
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
1886
|
+
F: __dxlog_file8,
|
|
1887
|
+
L: 91,
|
|
1888
|
+
S: this,
|
|
1889
|
+
C: (f, a) => f(...a)
|
|
1873
1890
|
});
|
|
1874
|
-
(0,
|
|
1891
|
+
(0, import_tiny_invariant9.default)(credentials.every((credential) => credential.id), "Credentials must have an id");
|
|
1875
1892
|
const errors = new import_async7.Trigger();
|
|
1876
1893
|
const ctx = this._ctx.derive({
|
|
1877
1894
|
onError: (err) => {
|
|
1878
1895
|
import_log8.log.warn("Notarization error", {
|
|
1879
1896
|
err
|
|
1880
1897
|
}, {
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
|
|
1898
|
+
F: __dxlog_file8,
|
|
1899
|
+
L: 100,
|
|
1900
|
+
S: this,
|
|
1901
|
+
C: (f, a) => f(...a)
|
|
1885
1902
|
});
|
|
1886
1903
|
void ctx.dispose();
|
|
1887
1904
|
errors.throw(err);
|
|
@@ -1894,10 +1911,10 @@ var NotarizationPlugin = class {
|
|
|
1894
1911
|
timeout,
|
|
1895
1912
|
peers: Array.from(this._extensions).map((extension) => extension.remotePeerId)
|
|
1896
1913
|
}, {
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1914
|
+
F: __dxlog_file8,
|
|
1915
|
+
L: 112,
|
|
1916
|
+
S: this,
|
|
1917
|
+
C: (f, a) => f(...a)
|
|
1901
1918
|
});
|
|
1902
1919
|
void ctx.dispose();
|
|
1903
1920
|
errors.throw(new import_async7.TimeoutError(timeout, "Notarization timed out"));
|
|
@@ -1917,10 +1934,10 @@ var NotarizationPlugin = class {
|
|
|
1917
1934
|
import_log8.log.warn("Exhausted all peers to notarize with", {
|
|
1918
1935
|
retryIn: retryTimeout
|
|
1919
1936
|
}, {
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
|
|
1937
|
+
F: __dxlog_file8,
|
|
1938
|
+
L: 137,
|
|
1939
|
+
S: this,
|
|
1940
|
+
C: (f, a) => f(...a)
|
|
1924
1941
|
});
|
|
1925
1942
|
peersTried.clear();
|
|
1926
1943
|
(0, import_async7.scheduleTask)(ctx, () => notarizeTask.schedule(), retryTimeout);
|
|
@@ -1931,28 +1948,28 @@ var NotarizationPlugin = class {
|
|
|
1931
1948
|
peer: peer.localPeerId,
|
|
1932
1949
|
credentialId: credentials.map((credential) => credential.id)
|
|
1933
1950
|
}, {
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
|
|
1951
|
+
F: __dxlog_file8,
|
|
1952
|
+
L: 144,
|
|
1953
|
+
S: this,
|
|
1954
|
+
C: (f, a) => f(...a)
|
|
1938
1955
|
});
|
|
1939
1956
|
await peer.rpc.NotarizationService.notarize({
|
|
1940
1957
|
credentials: credentials.filter((credential) => !this._processedCredentials.has(credential.id))
|
|
1941
1958
|
});
|
|
1942
|
-
(0, import_log8.log)("success",
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
|
|
1959
|
+
(0, import_log8.log)("success", void 0, {
|
|
1960
|
+
F: __dxlog_file8,
|
|
1961
|
+
L: 148,
|
|
1962
|
+
S: this,
|
|
1963
|
+
C: (f, a) => f(...a)
|
|
1947
1964
|
});
|
|
1948
1965
|
await (0, import_async7.sleep)(successDelay);
|
|
1949
1966
|
} catch (err) {
|
|
1950
1967
|
if (!ctx.disposed && !err.message.includes(WRITER_NOT_SET_ERROR_CODE)) {
|
|
1951
1968
|
import_log8.log.warn("error notarizing (recoverable)", err, {
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1969
|
+
F: __dxlog_file8,
|
|
1970
|
+
L: 152,
|
|
1971
|
+
S: this,
|
|
1972
|
+
C: (f, a) => f(...a)
|
|
1956
1973
|
});
|
|
1957
1974
|
}
|
|
1958
1975
|
notarizeTask.schedule();
|
|
@@ -1966,11 +1983,11 @@ var NotarizationPlugin = class {
|
|
|
1966
1983
|
allNotarized,
|
|
1967
1984
|
errors.wait()
|
|
1968
1985
|
]);
|
|
1969
|
-
(0, import_log8.log)("done",
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
|
|
1986
|
+
(0, import_log8.log)("done", void 0, {
|
|
1987
|
+
F: __dxlog_file8,
|
|
1988
|
+
L: 163,
|
|
1989
|
+
S: this,
|
|
1990
|
+
C: (f, a) => f(...a)
|
|
1974
1991
|
});
|
|
1975
1992
|
} finally {
|
|
1976
1993
|
await ctx.dispose();
|
|
@@ -1979,7 +1996,7 @@ var NotarizationPlugin = class {
|
|
|
1979
1996
|
/**
|
|
1980
1997
|
* Called with credentials arriving from the control pipeline.
|
|
1981
1998
|
*/
|
|
1982
|
-
async
|
|
1999
|
+
async processCredential(credential) {
|
|
1983
2000
|
var _a;
|
|
1984
2001
|
if (!credential.id) {
|
|
1985
2002
|
return;
|
|
@@ -1989,7 +2006,7 @@ var NotarizationPlugin = class {
|
|
|
1989
2006
|
this._processCredentialsTriggers.delete(credential.id);
|
|
1990
2007
|
}
|
|
1991
2008
|
setWriter(writer) {
|
|
1992
|
-
(0,
|
|
2009
|
+
(0, import_tiny_invariant9.default)(!this._writer, "Writer already set.");
|
|
1993
2010
|
this._writer = writer;
|
|
1994
2011
|
}
|
|
1995
2012
|
async _waitUntilProcessed(id) {
|
|
@@ -2007,7 +2024,7 @@ var NotarizationPlugin = class {
|
|
|
2007
2024
|
throw new Error(WRITER_NOT_SET_ERROR_CODE);
|
|
2008
2025
|
}
|
|
2009
2026
|
for (const credential of (_a = request.credentials) != null ? _a : []) {
|
|
2010
|
-
(0,
|
|
2027
|
+
(0, import_tiny_invariant9.default)(credential.id, "Credential must have an id");
|
|
2011
2028
|
if (this._processedCredentials.has(credential.id)) {
|
|
2012
2029
|
continue;
|
|
2013
2030
|
}
|
|
@@ -2020,10 +2037,10 @@ var NotarizationPlugin = class {
|
|
|
2020
2037
|
(0, import_log8.log)("extension opened", {
|
|
2021
2038
|
peer: extension.localPeerId
|
|
2022
2039
|
}, {
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
|
|
2040
|
+
F: __dxlog_file8,
|
|
2041
|
+
L: 212,
|
|
2042
|
+
S: this,
|
|
2043
|
+
C: (f, a) => f(...a)
|
|
2027
2044
|
});
|
|
2028
2045
|
this._extensions.add(extension);
|
|
2029
2046
|
this._extensionOpened.emit();
|
|
@@ -2032,10 +2049,10 @@ var NotarizationPlugin = class {
|
|
|
2032
2049
|
(0, import_log8.log)("extension closed", {
|
|
2033
2050
|
peer: extension.localPeerId
|
|
2034
2051
|
}, {
|
|
2035
|
-
|
|
2036
|
-
|
|
2037
|
-
|
|
2038
|
-
|
|
2052
|
+
F: __dxlog_file8,
|
|
2053
|
+
L: 217,
|
|
2054
|
+
S: this,
|
|
2055
|
+
C: (f, a) => f(...a)
|
|
2039
2056
|
});
|
|
2040
2057
|
this._extensions.delete(extension);
|
|
2041
2058
|
},
|
|
@@ -2076,7 +2093,7 @@ var NotarizationTeleportExtension = class extends import_teleport2.RpcExtension
|
|
|
2076
2093
|
};
|
|
2077
2094
|
|
|
2078
2095
|
// packages/sdk/client-services/src/packlets/spaces/data-space.ts
|
|
2079
|
-
|
|
2096
|
+
function _ts_decorate(decorators, target, key, desc) {
|
|
2080
2097
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2081
2098
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
2082
2099
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -2085,10 +2102,12 @@ var __decorate = function(decorators, target, key, desc) {
|
|
|
2085
2102
|
if (d = decorators[i])
|
|
2086
2103
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
2087
2104
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2088
|
-
}
|
|
2105
|
+
}
|
|
2106
|
+
var __dxlog_file9 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space.ts";
|
|
2089
2107
|
var DataSpace = class DataSpace2 {
|
|
2090
2108
|
constructor(params) {
|
|
2091
2109
|
this._ctx = new import_context5.Context();
|
|
2110
|
+
this._notarizationPlugin = new NotarizationPlugin();
|
|
2092
2111
|
this._state = import_services6.SpaceState.CLOSED;
|
|
2093
2112
|
/**
|
|
2094
2113
|
* Error for _state === SpaceState.ERROR.
|
|
@@ -2111,8 +2130,8 @@ var DataSpace = class DataSpace2 {
|
|
|
2111
2130
|
update: this._inner.stateUpdate,
|
|
2112
2131
|
authTimeout: import_client_protocol3.AUTH_TIMEOUT
|
|
2113
2132
|
});
|
|
2114
|
-
this._notarizationPluginConsumer = this._inner.spaceState.registerProcessor(new NotarizationPlugin());
|
|
2115
2133
|
this._cache = params.cache;
|
|
2134
|
+
this._state = params.initialState;
|
|
2116
2135
|
}
|
|
2117
2136
|
get key() {
|
|
2118
2137
|
return this._inner.key;
|
|
@@ -2134,25 +2153,36 @@ var DataSpace = class DataSpace2 {
|
|
|
2134
2153
|
return this._presence;
|
|
2135
2154
|
}
|
|
2136
2155
|
get notarizationPlugin() {
|
|
2137
|
-
return this.
|
|
2156
|
+
return this._notarizationPlugin;
|
|
2138
2157
|
}
|
|
2139
2158
|
get cache() {
|
|
2140
2159
|
return this._cache;
|
|
2141
2160
|
}
|
|
2142
2161
|
async open() {
|
|
2143
|
-
await this.
|
|
2144
|
-
|
|
2162
|
+
await this._open();
|
|
2163
|
+
}
|
|
2164
|
+
async _open() {
|
|
2165
|
+
await this._notarizationPlugin.open();
|
|
2166
|
+
await this._inner.spaceState.addCredentialProcessor(this._notarizationPlugin);
|
|
2145
2167
|
await this._inner.open();
|
|
2146
|
-
this._state = import_services6.SpaceState.
|
|
2168
|
+
this._state = import_services6.SpaceState.CONTROL_ONLY;
|
|
2169
|
+
this.stateUpdate.emit();
|
|
2170
|
+
this.metrics = {};
|
|
2147
2171
|
this.metrics.open = new Date();
|
|
2148
2172
|
}
|
|
2149
2173
|
async close() {
|
|
2174
|
+
await this._close();
|
|
2175
|
+
}
|
|
2176
|
+
async _close() {
|
|
2177
|
+
var _a, _b;
|
|
2178
|
+
await ((_b = (_a = this._callbacks).beforeClose) == null ? void 0 : _b.call(_a));
|
|
2150
2179
|
this._state = import_services6.SpaceState.CLOSED;
|
|
2151
2180
|
await this._ctx.dispose();
|
|
2181
|
+
this._ctx = new import_context5.Context();
|
|
2152
2182
|
await this.authVerifier.close();
|
|
2153
2183
|
await this._inner.close();
|
|
2154
|
-
await this.
|
|
2155
|
-
await this.
|
|
2184
|
+
await this._inner.spaceState.removeCredentialProcessor(this._notarizationPlugin);
|
|
2185
|
+
await this._notarizationPlugin.close();
|
|
2156
2186
|
await this._presence.destroy();
|
|
2157
2187
|
}
|
|
2158
2188
|
async postMessage(channel, message) {
|
|
@@ -2172,18 +2202,18 @@ var DataSpace = class DataSpace2 {
|
|
|
2172
2202
|
} catch (err) {
|
|
2173
2203
|
if (err instanceof import_errors3.CancelledError) {
|
|
2174
2204
|
(0, import_log9.log)("Data pipeline initialization cancelled", err, {
|
|
2175
|
-
|
|
2176
|
-
|
|
2177
|
-
|
|
2178
|
-
|
|
2205
|
+
F: __dxlog_file9,
|
|
2206
|
+
L: 193,
|
|
2207
|
+
S: this,
|
|
2208
|
+
C: (f, a) => f(...a)
|
|
2179
2209
|
});
|
|
2180
2210
|
return;
|
|
2181
2211
|
}
|
|
2182
2212
|
import_log9.log.error("Error initializing data pipeline", err, {
|
|
2183
|
-
|
|
2184
|
-
|
|
2185
|
-
|
|
2186
|
-
|
|
2213
|
+
F: __dxlog_file9,
|
|
2214
|
+
L: 197,
|
|
2215
|
+
S: this,
|
|
2216
|
+
C: (f, a) => f(...a)
|
|
2187
2217
|
});
|
|
2188
2218
|
this._state = import_services6.SpaceState.ERROR;
|
|
2189
2219
|
this.error = err;
|
|
@@ -2195,7 +2225,7 @@ var DataSpace = class DataSpace2 {
|
|
|
2195
2225
|
}
|
|
2196
2226
|
async initializeDataPipeline() {
|
|
2197
2227
|
var _a, _b, _c, _d;
|
|
2198
|
-
if (this._state !== import_services6.SpaceState.
|
|
2228
|
+
if (this._state !== import_services6.SpaceState.CONTROL_ONLY) {
|
|
2199
2229
|
throw new import_errors3.SystemError("Invalid operation");
|
|
2200
2230
|
}
|
|
2201
2231
|
this._state = import_services6.SpaceState.INITIALIZING;
|
|
@@ -2205,37 +2235,39 @@ var DataSpace = class DataSpace2 {
|
|
|
2205
2235
|
});
|
|
2206
2236
|
this.metrics.controlPipelineReady = new Date();
|
|
2207
2237
|
await this._createWritableFeeds();
|
|
2208
|
-
(0, import_log9.log)("Writable feeds created",
|
|
2209
|
-
|
|
2210
|
-
|
|
2211
|
-
|
|
2212
|
-
|
|
2238
|
+
(0, import_log9.log)("Writable feeds created", void 0, {
|
|
2239
|
+
F: __dxlog_file9,
|
|
2240
|
+
L: 221,
|
|
2241
|
+
S: this,
|
|
2242
|
+
C: (f, a) => f(...a)
|
|
2213
2243
|
});
|
|
2214
2244
|
this.stateUpdate.emit();
|
|
2215
|
-
this.notarizationPlugin.
|
|
2216
|
-
credential
|
|
2217
|
-
credential
|
|
2218
|
-
|
|
2219
|
-
|
|
2245
|
+
if (!this.notarizationPlugin.hasWriter) {
|
|
2246
|
+
this.notarizationPlugin.setWriter((0, import_echo_pipeline.createMappedFeedWriter)((credential) => ({
|
|
2247
|
+
credential: {
|
|
2248
|
+
credential
|
|
2249
|
+
}
|
|
2250
|
+
}), this._inner.controlPipeline.writer));
|
|
2251
|
+
}
|
|
2220
2252
|
await this._inner.initializeDataPipeline();
|
|
2221
2253
|
this.metrics.dataPipelineOpen = new Date();
|
|
2222
2254
|
await (0, import_context5.cancelWithContext)(this._ctx, this._inner.dataPipeline.ensureEpochInitialized());
|
|
2223
|
-
(0, import_log9.log)("waiting for data pipeline to reach target timeframe",
|
|
2224
|
-
|
|
2225
|
-
|
|
2226
|
-
|
|
2227
|
-
|
|
2255
|
+
(0, import_log9.log)("waiting for data pipeline to reach target timeframe", void 0, {
|
|
2256
|
+
F: __dxlog_file9,
|
|
2257
|
+
L: 242,
|
|
2258
|
+
S: this,
|
|
2259
|
+
C: (f, a) => f(...a)
|
|
2228
2260
|
});
|
|
2229
2261
|
await this._inner.dataPipeline.pipelineState.waitUntilReachedTargetTimeframe({
|
|
2230
2262
|
ctx: this._ctx,
|
|
2231
2263
|
breakOnStall: false
|
|
2232
2264
|
});
|
|
2233
2265
|
this.metrics.dataPipelineReady = new Date();
|
|
2234
|
-
(0, import_log9.log)("data pipeline ready",
|
|
2235
|
-
|
|
2236
|
-
|
|
2237
|
-
|
|
2238
|
-
|
|
2266
|
+
(0, import_log9.log)("data pipeline ready", void 0, {
|
|
2267
|
+
F: __dxlog_file9,
|
|
2268
|
+
L: 251,
|
|
2269
|
+
S: this,
|
|
2270
|
+
C: (f, a) => f(...a)
|
|
2239
2271
|
});
|
|
2240
2272
|
await ((_b = (_a = this._callbacks).beforeReady) == null ? void 0 : _b.call(_a));
|
|
2241
2273
|
this._state = import_services6.SpaceState.READY;
|
|
@@ -2313,17 +2345,46 @@ var DataSpace = class DataSpace2 {
|
|
|
2313
2345
|
}
|
|
2314
2346
|
}
|
|
2315
2347
|
}
|
|
2348
|
+
async activate() {
|
|
2349
|
+
if (this._state !== import_services6.SpaceState.INACTIVE) {
|
|
2350
|
+
throw new import_errors3.SystemError("Invalid operation");
|
|
2351
|
+
}
|
|
2352
|
+
await this._metadataStore.setSpaceState(this.key, import_services6.SpaceState.ACTIVE);
|
|
2353
|
+
await this._open();
|
|
2354
|
+
this.initializeDataPipelineAsync();
|
|
2355
|
+
}
|
|
2356
|
+
async deactivate() {
|
|
2357
|
+
if (this._state === import_services6.SpaceState.INACTIVE) {
|
|
2358
|
+
throw new import_errors3.SystemError("Invalid operation");
|
|
2359
|
+
}
|
|
2360
|
+
await this._metadataStore.setSpaceState(this.key, import_services6.SpaceState.INACTIVE);
|
|
2361
|
+
await this._close();
|
|
2362
|
+
this._state = import_services6.SpaceState.INACTIVE;
|
|
2363
|
+
this.stateUpdate.emit();
|
|
2364
|
+
}
|
|
2316
2365
|
};
|
|
2317
|
-
|
|
2318
|
-
|
|
2366
|
+
_ts_decorate([
|
|
2367
|
+
import_async8.synchronized
|
|
2368
|
+
], DataSpace.prototype, "open", null);
|
|
2369
|
+
_ts_decorate([
|
|
2370
|
+
import_async8.synchronized
|
|
2371
|
+
], DataSpace.prototype, "close", null);
|
|
2372
|
+
_ts_decorate([
|
|
2373
|
+
(0, import_debug4.timed)(1e4)
|
|
2319
2374
|
], DataSpace.prototype, "_createWritableFeeds", null);
|
|
2320
|
-
|
|
2375
|
+
_ts_decorate([
|
|
2376
|
+
import_async8.synchronized
|
|
2377
|
+
], DataSpace.prototype, "activate", null);
|
|
2378
|
+
_ts_decorate([
|
|
2379
|
+
import_async8.synchronized
|
|
2380
|
+
], DataSpace.prototype, "deactivate", null);
|
|
2381
|
+
DataSpace = _ts_decorate([
|
|
2321
2382
|
(0, import_async8.trackLeaks)("open", "close")
|
|
2322
2383
|
], DataSpace);
|
|
2323
2384
|
|
|
2324
2385
|
// packages/sdk/client-services/src/packlets/spaces/genesis.ts
|
|
2325
2386
|
var import_credentials11 = require("@dxos/credentials");
|
|
2326
|
-
var
|
|
2387
|
+
var import_debug5 = require("@dxos/debug");
|
|
2327
2388
|
var import_credentials12 = require("@dxos/protocols/proto/dxos/halo/credentials");
|
|
2328
2389
|
var import_timeframe2 = require("@dxos/timeframe");
|
|
2329
2390
|
var spaceGenesis = async (keyring, signingContext, space) => {
|
|
@@ -2347,11 +2408,11 @@ var spaceGenesis = async (keyring, signingContext, space) => {
|
|
|
2347
2408
|
spaceKey: space.key,
|
|
2348
2409
|
role: import_credentials12.SpaceMember.Role.ADMIN,
|
|
2349
2410
|
profile: signingContext.profile,
|
|
2350
|
-
genesisFeedKey: (_a = space.controlFeedKey) != null ? _a : (0,
|
|
2411
|
+
genesisFeedKey: (_a = space.controlFeedKey) != null ? _a : (0, import_debug5.failUndefined)()
|
|
2351
2412
|
}
|
|
2352
2413
|
}),
|
|
2353
2414
|
await signingContext.credentialSigner.createCredential({
|
|
2354
|
-
subject: (_b = space.controlFeedKey) != null ? _b : (0,
|
|
2415
|
+
subject: (_b = space.controlFeedKey) != null ? _b : (0, import_debug5.failUndefined)(),
|
|
2355
2416
|
assertion: {
|
|
2356
2417
|
"@type": "dxos.halo.credentials.AdmittedFeed",
|
|
2357
2418
|
spaceKey: space.key,
|
|
@@ -2361,7 +2422,7 @@ var spaceGenesis = async (keyring, signingContext, space) => {
|
|
|
2361
2422
|
}
|
|
2362
2423
|
}),
|
|
2363
2424
|
await signingContext.credentialSigner.createCredential({
|
|
2364
|
-
subject: (_c = space.dataFeedKey) != null ? _c : (0,
|
|
2425
|
+
subject: (_c = space.dataFeedKey) != null ? _c : (0, import_debug5.failUndefined)(),
|
|
2365
2426
|
assertion: {
|
|
2366
2427
|
"@type": "dxos.halo.credentials.AdmittedFeed",
|
|
2367
2428
|
spaceKey: space.key,
|
|
@@ -2371,7 +2432,7 @@ var spaceGenesis = async (keyring, signingContext, space) => {
|
|
|
2371
2432
|
}
|
|
2372
2433
|
}),
|
|
2373
2434
|
await signingContext.credentialSigner.createCredential({
|
|
2374
|
-
subject: (_d = space.key) != null ? _d : (0,
|
|
2435
|
+
subject: (_d = space.key) != null ? _d : (0, import_debug5.failUndefined)(),
|
|
2375
2436
|
assertion: {
|
|
2376
2437
|
"@type": "dxos.halo.credentials.Epoch",
|
|
2377
2438
|
number: 0,
|
|
@@ -2392,7 +2453,7 @@ var spaceGenesis = async (keyring, signingContext, space) => {
|
|
|
2392
2453
|
};
|
|
2393
2454
|
|
|
2394
2455
|
// packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts
|
|
2395
|
-
|
|
2456
|
+
function _ts_decorate2(decorators, target, key, desc) {
|
|
2396
2457
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2397
2458
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
2398
2459
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -2401,7 +2462,8 @@ var __decorate2 = function(decorators, target, key, desc) {
|
|
|
2401
2462
|
if (d = decorators[i])
|
|
2402
2463
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
2403
2464
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2404
|
-
}
|
|
2465
|
+
}
|
|
2466
|
+
var __dxlog_file10 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts";
|
|
2405
2467
|
var DataSpaceManager = class DataSpaceManager2 {
|
|
2406
2468
|
constructor(_spaceManager, _metadataStore, _dataServiceSubscriptions, _keyring, _signingContext, _feedStore) {
|
|
2407
2469
|
this._spaceManager = _spaceManager;
|
|
@@ -2421,50 +2483,52 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2421
2483
|
return this._spaces;
|
|
2422
2484
|
}
|
|
2423
2485
|
async open() {
|
|
2424
|
-
(0, import_log10.log)("open",
|
|
2425
|
-
|
|
2426
|
-
|
|
2427
|
-
|
|
2428
|
-
|
|
2486
|
+
(0, import_log10.log)("open", void 0, {
|
|
2487
|
+
F: __dxlog_file10,
|
|
2488
|
+
L: 80,
|
|
2489
|
+
S: this,
|
|
2490
|
+
C: (f, a) => f(...a)
|
|
2429
2491
|
});
|
|
2430
2492
|
import_log10.log.trace("dxos.echo.data-space-manager.open", import_protocols6.trace.begin({
|
|
2431
2493
|
id: this._instanceId
|
|
2432
2494
|
}), {
|
|
2433
|
-
|
|
2434
|
-
|
|
2435
|
-
|
|
2436
|
-
|
|
2495
|
+
F: __dxlog_file10,
|
|
2496
|
+
L: 81,
|
|
2497
|
+
S: this,
|
|
2498
|
+
C: (f, a) => f(...a)
|
|
2437
2499
|
});
|
|
2438
2500
|
await this._metadataStore.load();
|
|
2439
2501
|
(0, import_log10.log)("metadata loaded", {
|
|
2440
2502
|
spaces: this._metadataStore.spaces.length
|
|
2441
2503
|
}, {
|
|
2442
|
-
|
|
2443
|
-
|
|
2444
|
-
|
|
2445
|
-
|
|
2504
|
+
F: __dxlog_file10,
|
|
2505
|
+
L: 83,
|
|
2506
|
+
S: this,
|
|
2507
|
+
C: (f, a) => f(...a)
|
|
2446
2508
|
});
|
|
2447
2509
|
for (const spaceMetadata of this._metadataStore.spaces) {
|
|
2448
2510
|
try {
|
|
2449
2511
|
(0, import_log10.log)("load space", {
|
|
2450
2512
|
spaceMetadata
|
|
2451
2513
|
}, {
|
|
2452
|
-
|
|
2453
|
-
|
|
2454
|
-
|
|
2455
|
-
|
|
2514
|
+
F: __dxlog_file10,
|
|
2515
|
+
L: 87,
|
|
2516
|
+
S: this,
|
|
2517
|
+
C: (f, a) => f(...a)
|
|
2456
2518
|
});
|
|
2457
2519
|
const space = await this._constructSpace(spaceMetadata);
|
|
2458
|
-
|
|
2520
|
+
if (spaceMetadata.state !== import_services7.SpaceState.INACTIVE) {
|
|
2521
|
+
space.initializeDataPipelineAsync();
|
|
2522
|
+
}
|
|
2459
2523
|
} catch (err) {
|
|
2460
2524
|
import_log10.log.error("Error loading space", {
|
|
2461
2525
|
spaceMetadata,
|
|
2462
2526
|
err
|
|
2463
2527
|
}, {
|
|
2464
|
-
|
|
2465
|
-
|
|
2466
|
-
|
|
2467
|
-
|
|
2528
|
+
F: __dxlog_file10,
|
|
2529
|
+
L: 93,
|
|
2530
|
+
S: this,
|
|
2531
|
+
C: (f, a) => f(...a)
|
|
2468
2532
|
});
|
|
2469
2533
|
}
|
|
2470
2534
|
}
|
|
@@ -2473,18 +2537,18 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2473
2537
|
import_log10.log.trace("dxos.echo.data-space-manager.open", import_protocols6.trace.end({
|
|
2474
2538
|
id: this._instanceId
|
|
2475
2539
|
}), {
|
|
2476
|
-
|
|
2477
|
-
|
|
2478
|
-
|
|
2479
|
-
|
|
2540
|
+
F: __dxlog_file10,
|
|
2541
|
+
L: 99,
|
|
2542
|
+
S: this,
|
|
2543
|
+
C: (f, a) => f(...a)
|
|
2480
2544
|
});
|
|
2481
2545
|
}
|
|
2482
2546
|
async close() {
|
|
2483
|
-
(0, import_log10.log)("close",
|
|
2484
|
-
|
|
2485
|
-
|
|
2486
|
-
|
|
2487
|
-
|
|
2547
|
+
(0, import_log10.log)("close", void 0, {
|
|
2548
|
+
F: __dxlog_file10,
|
|
2549
|
+
L: 104,
|
|
2550
|
+
S: this,
|
|
2551
|
+
C: (f, a) => f(...a)
|
|
2488
2552
|
});
|
|
2489
2553
|
this._isOpen = false;
|
|
2490
2554
|
await this._ctx.dispose();
|
|
@@ -2496,7 +2560,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2496
2560
|
* Creates a new space writing the genesis credentials to the control feed.
|
|
2497
2561
|
*/
|
|
2498
2562
|
async createSpace() {
|
|
2499
|
-
(0,
|
|
2563
|
+
(0, import_tiny_invariant10.default)(this._isOpen, "Not open.");
|
|
2500
2564
|
const spaceKey = await this._keyring.createKey();
|
|
2501
2565
|
const controlFeedKey = await this._keyring.createKey();
|
|
2502
2566
|
const dataFeedKey = await this._keyring.createKey();
|
|
@@ -2504,21 +2568,22 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2504
2568
|
key: spaceKey,
|
|
2505
2569
|
genesisFeedKey: controlFeedKey,
|
|
2506
2570
|
controlFeedKey,
|
|
2507
|
-
dataFeedKey
|
|
2571
|
+
dataFeedKey,
|
|
2572
|
+
state: import_services7.SpaceState.ACTIVE
|
|
2508
2573
|
};
|
|
2509
2574
|
(0, import_log10.log)("creating space...", {
|
|
2510
2575
|
spaceKey
|
|
2511
2576
|
}, {
|
|
2512
|
-
|
|
2513
|
-
|
|
2514
|
-
|
|
2515
|
-
|
|
2577
|
+
F: __dxlog_file10,
|
|
2578
|
+
L: 129,
|
|
2579
|
+
S: this,
|
|
2580
|
+
C: (f, a) => f(...a)
|
|
2516
2581
|
});
|
|
2517
2582
|
const space = await this._constructSpace(metadata);
|
|
2518
2583
|
const credentials = await spaceGenesis(this._keyring, this._signingContext, space.inner);
|
|
2519
2584
|
await this._metadataStore.addSpace(metadata);
|
|
2520
2585
|
const memberCredential = credentials[1];
|
|
2521
|
-
(0,
|
|
2586
|
+
(0, import_tiny_invariant10.default)((0, import_credentials13.getCredentialAssertion)(memberCredential)["@type"] === "dxos.halo.credentials.SpaceMember");
|
|
2522
2587
|
await this._signingContext.recordCredential(memberCredential);
|
|
2523
2588
|
await space.initializeDataPipeline();
|
|
2524
2589
|
this.updated.emit();
|
|
@@ -2529,13 +2594,13 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2529
2594
|
(0, import_log10.log)("accept space", {
|
|
2530
2595
|
opts
|
|
2531
2596
|
}, {
|
|
2532
|
-
|
|
2533
|
-
|
|
2534
|
-
|
|
2535
|
-
|
|
2597
|
+
F: __dxlog_file10,
|
|
2598
|
+
L: 148,
|
|
2599
|
+
S: this,
|
|
2600
|
+
C: (f, a) => f(...a)
|
|
2536
2601
|
});
|
|
2537
|
-
(0,
|
|
2538
|
-
(0,
|
|
2602
|
+
(0, import_tiny_invariant10.default)(this._isOpen, "Not open.");
|
|
2603
|
+
(0, import_tiny_invariant10.default)(!this._spaces.has(opts.spaceKey), "Space already exists.");
|
|
2539
2604
|
const metadata = {
|
|
2540
2605
|
key: opts.spaceKey,
|
|
2541
2606
|
genesisFeedKey: opts.genesisFeedKey,
|
|
@@ -2563,10 +2628,10 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2563
2628
|
(0, import_log10.log)("construct space", {
|
|
2564
2629
|
metadata
|
|
2565
2630
|
}, {
|
|
2566
|
-
|
|
2567
|
-
|
|
2568
|
-
|
|
2569
|
-
|
|
2631
|
+
F: __dxlog_file10,
|
|
2632
|
+
L: 183,
|
|
2633
|
+
S: this,
|
|
2634
|
+
C: (f, a) => f(...a)
|
|
2570
2635
|
});
|
|
2571
2636
|
const gossip = new import_teleport_extension_gossip.Gossip({
|
|
2572
2637
|
localPeerId: this._signingContext.deviceKey
|
|
@@ -2598,11 +2663,11 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2598
2663
|
session.addExtension("dxos.mesh.teleport.notarization", dataSpace.notarizationPlugin.createExtension());
|
|
2599
2664
|
},
|
|
2600
2665
|
onAuthFailure: () => {
|
|
2601
|
-
import_log10.log.warn("auth failure",
|
|
2602
|
-
|
|
2603
|
-
|
|
2604
|
-
|
|
2605
|
-
|
|
2666
|
+
import_log10.log.warn("auth failure", void 0, {
|
|
2667
|
+
F: __dxlog_file10,
|
|
2668
|
+
L: 214,
|
|
2669
|
+
S: this,
|
|
2670
|
+
C: (f, a) => f(...a)
|
|
2606
2671
|
});
|
|
2607
2672
|
},
|
|
2608
2673
|
memberKey: this._signingContext.identityKey
|
|
@@ -2611,6 +2676,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2611
2676
|
dataFeed && space.setDataFeed(dataFeed);
|
|
2612
2677
|
const dataSpace = new DataSpace({
|
|
2613
2678
|
inner: space,
|
|
2679
|
+
initialState: metadata.state === import_services7.SpaceState.INACTIVE ? import_services7.SpaceState.INACTIVE : import_services7.SpaceState.CLOSED,
|
|
2614
2680
|
metadataStore: this._metadataStore,
|
|
2615
2681
|
gossip,
|
|
2616
2682
|
presence,
|
|
@@ -2622,31 +2688,44 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2622
2688
|
(0, import_log10.log)("before space ready", {
|
|
2623
2689
|
space: space.key
|
|
2624
2690
|
}, {
|
|
2625
|
-
|
|
2626
|
-
|
|
2627
|
-
|
|
2628
|
-
|
|
2691
|
+
F: __dxlog_file10,
|
|
2692
|
+
L: 232,
|
|
2693
|
+
S: this,
|
|
2694
|
+
C: (f, a) => f(...a)
|
|
2629
2695
|
});
|
|
2630
|
-
this._dataServiceSubscriptions.registerSpace(space.key, dataSpace.dataPipeline.databaseHost.createDataServiceHost());
|
|
2696
|
+
await this._dataServiceSubscriptions.registerSpace(space.key, dataSpace.dataPipeline.databaseHost.createDataServiceHost());
|
|
2631
2697
|
},
|
|
2632
2698
|
afterReady: async () => {
|
|
2633
2699
|
(0, import_log10.log)("after space ready", {
|
|
2634
2700
|
space: space.key,
|
|
2635
2701
|
open: this._isOpen
|
|
2636
2702
|
}, {
|
|
2637
|
-
|
|
2638
|
-
|
|
2639
|
-
|
|
2640
|
-
|
|
2703
|
+
F: __dxlog_file10,
|
|
2704
|
+
L: 239,
|
|
2705
|
+
S: this,
|
|
2706
|
+
C: (f, a) => f(...a)
|
|
2641
2707
|
});
|
|
2642
2708
|
if (this._isOpen) {
|
|
2643
2709
|
this.updated.emit();
|
|
2644
2710
|
}
|
|
2711
|
+
},
|
|
2712
|
+
beforeClose: async () => {
|
|
2713
|
+
(0, import_log10.log)("before space close", {
|
|
2714
|
+
space: space.key
|
|
2715
|
+
}, {
|
|
2716
|
+
F: __dxlog_file10,
|
|
2717
|
+
L: 245,
|
|
2718
|
+
S: this,
|
|
2719
|
+
C: (f, a) => f(...a)
|
|
2720
|
+
});
|
|
2721
|
+
await this._dataServiceSubscriptions.unregisterSpace(space.key);
|
|
2645
2722
|
}
|
|
2646
2723
|
},
|
|
2647
2724
|
cache: metadata.cache
|
|
2648
2725
|
});
|
|
2649
|
-
|
|
2726
|
+
if (metadata.state !== import_services7.SpaceState.INACTIVE) {
|
|
2727
|
+
await dataSpace.open();
|
|
2728
|
+
}
|
|
2650
2729
|
if (metadata.controlTimeframe) {
|
|
2651
2730
|
dataSpace.inner.controlPipeline.state.setTargetTimeframe(metadata.controlTimeframe);
|
|
2652
2731
|
}
|
|
@@ -2657,31 +2736,33 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2657
2736
|
return dataSpace;
|
|
2658
2737
|
}
|
|
2659
2738
|
};
|
|
2660
|
-
|
|
2739
|
+
_ts_decorate2([
|
|
2661
2740
|
import_async9.synchronized
|
|
2662
2741
|
], DataSpaceManager.prototype, "open", null);
|
|
2663
|
-
|
|
2742
|
+
_ts_decorate2([
|
|
2664
2743
|
import_async9.synchronized
|
|
2665
2744
|
], DataSpaceManager.prototype, "close", null);
|
|
2666
|
-
|
|
2745
|
+
_ts_decorate2([
|
|
2667
2746
|
import_async9.synchronized
|
|
2668
2747
|
], DataSpaceManager.prototype, "createSpace", null);
|
|
2669
|
-
|
|
2748
|
+
_ts_decorate2([
|
|
2670
2749
|
import_async9.synchronized
|
|
2671
2750
|
], DataSpaceManager.prototype, "acceptSpace", null);
|
|
2672
|
-
DataSpaceManager =
|
|
2751
|
+
DataSpaceManager = _ts_decorate2([
|
|
2673
2752
|
(0, import_async9.trackLeaks)("open", "close")
|
|
2674
2753
|
], DataSpaceManager);
|
|
2675
2754
|
|
|
2676
2755
|
// packages/sdk/client-services/src/packlets/spaces/spaces-service.ts
|
|
2677
2756
|
var import_async10 = require("@dxos/async");
|
|
2678
|
-
var
|
|
2679
|
-
var
|
|
2757
|
+
var import_codec_protobuf4 = require("@dxos/codec-protobuf");
|
|
2758
|
+
var import_debug6 = require("@dxos/debug");
|
|
2680
2759
|
var import_echo_pipeline2 = require("@dxos/echo-pipeline");
|
|
2760
|
+
var import_errors4 = require("@dxos/errors");
|
|
2681
2761
|
var import_log11 = require("@dxos/log");
|
|
2682
2762
|
var import_protocols7 = require("@dxos/protocols");
|
|
2683
2763
|
var import_services8 = require("@dxos/protocols/proto/dxos/client/services");
|
|
2684
2764
|
var import_util5 = require("@dxos/util");
|
|
2765
|
+
var __dxlog_file11 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/spaces-service.ts";
|
|
2685
2766
|
var SpacesServiceImpl = class {
|
|
2686
2767
|
constructor(_identityManager, _spaceManager, _dataServiceSubscriptions, _getDataSpaceManager) {
|
|
2687
2768
|
this._identityManager = _identityManager;
|
|
@@ -2697,21 +2778,35 @@ var SpacesServiceImpl = class {
|
|
|
2697
2778
|
const space = await dataSpaceManager.createSpace();
|
|
2698
2779
|
return this._serializeSpace(space);
|
|
2699
2780
|
}
|
|
2700
|
-
async updateSpace(
|
|
2701
|
-
|
|
2781
|
+
async updateSpace({ spaceKey, state }) {
|
|
2782
|
+
var _a;
|
|
2783
|
+
const dataSpaceManager = await this._getDataSpaceManager();
|
|
2784
|
+
const space = (_a = dataSpaceManager.spaces.get(spaceKey)) != null ? _a : (0, import_debug6.raise)(new import_echo_pipeline2.SpaceNotFoundError(spaceKey));
|
|
2785
|
+
if (state) {
|
|
2786
|
+
switch (state) {
|
|
2787
|
+
case import_services8.SpaceState.ACTIVE:
|
|
2788
|
+
await space.activate();
|
|
2789
|
+
break;
|
|
2790
|
+
case import_services8.SpaceState.INACTIVE:
|
|
2791
|
+
await space.deactivate();
|
|
2792
|
+
break;
|
|
2793
|
+
default:
|
|
2794
|
+
throw new import_errors4.ApiError("Invalid space state");
|
|
2795
|
+
}
|
|
2796
|
+
}
|
|
2702
2797
|
}
|
|
2703
2798
|
querySpaces() {
|
|
2704
|
-
return new
|
|
2799
|
+
return new import_codec_protobuf4.Stream(({ next, ctx }) => {
|
|
2705
2800
|
const scheduler = new import_async10.UpdateScheduler(ctx, async () => {
|
|
2706
2801
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
2707
2802
|
const spaces = Array.from(dataSpaceManager.spaces.values()).map((space) => this._serializeSpace(space));
|
|
2708
2803
|
(0, import_log11.log)("update", {
|
|
2709
2804
|
spaces
|
|
2710
2805
|
}, {
|
|
2711
|
-
|
|
2712
|
-
|
|
2713
|
-
|
|
2714
|
-
|
|
2806
|
+
F: __dxlog_file11,
|
|
2807
|
+
L: 78,
|
|
2808
|
+
S: this,
|
|
2809
|
+
C: (f, a) => f(...a)
|
|
2715
2810
|
});
|
|
2716
2811
|
next({
|
|
2717
2812
|
spaces
|
|
@@ -2752,15 +2847,15 @@ var SpacesServiceImpl = class {
|
|
|
2752
2847
|
async postMessage({ spaceKey, channel, message }) {
|
|
2753
2848
|
var _a;
|
|
2754
2849
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
2755
|
-
const space = (_a = dataSpaceManager.spaces.get(spaceKey)) != null ? _a : (0,
|
|
2850
|
+
const space = (_a = dataSpaceManager.spaces.get(spaceKey)) != null ? _a : (0, import_debug6.raise)(new import_echo_pipeline2.SpaceNotFoundError(spaceKey));
|
|
2756
2851
|
await space.postMessage(getChannelId(channel), message);
|
|
2757
2852
|
}
|
|
2758
2853
|
subscribeMessages({ spaceKey, channel }) {
|
|
2759
|
-
return new
|
|
2854
|
+
return new import_codec_protobuf4.Stream(({ ctx, next }) => {
|
|
2760
2855
|
(0, import_async10.scheduleTask)(ctx, async () => {
|
|
2761
2856
|
var _a;
|
|
2762
2857
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
2763
|
-
const space = (_a = dataSpaceManager.spaces.get(spaceKey)) != null ? _a : (0,
|
|
2858
|
+
const space = (_a = dataSpaceManager.spaces.get(spaceKey)) != null ? _a : (0, import_debug6.raise)(new import_echo_pipeline2.SpaceNotFoundError(spaceKey));
|
|
2764
2859
|
const handle = space.listen(getChannelId(channel), (message) => {
|
|
2765
2860
|
next(message);
|
|
2766
2861
|
});
|
|
@@ -2769,21 +2864,21 @@ var SpacesServiceImpl = class {
|
|
|
2769
2864
|
});
|
|
2770
2865
|
}
|
|
2771
2866
|
queryCredentials({ spaceKey }) {
|
|
2772
|
-
return new
|
|
2867
|
+
return new import_codec_protobuf4.Stream(({ ctx, next }) => {
|
|
2773
2868
|
var _a;
|
|
2774
|
-
const space = (_a = this._spaceManager.spaces.get(spaceKey)) != null ? _a : (0,
|
|
2775
|
-
const processor =
|
|
2776
|
-
|
|
2869
|
+
const space = (_a = this._spaceManager.spaces.get(spaceKey)) != null ? _a : (0, import_debug6.raise)(new import_echo_pipeline2.SpaceNotFoundError(spaceKey));
|
|
2870
|
+
const processor = {
|
|
2871
|
+
processCredential: async (credential) => {
|
|
2777
2872
|
next(credential);
|
|
2778
2873
|
}
|
|
2779
|
-
}
|
|
2780
|
-
ctx.onDispose(() =>
|
|
2781
|
-
(0, import_async10.scheduleTask)(ctx, () =>
|
|
2874
|
+
};
|
|
2875
|
+
ctx.onDispose(() => space.spaceState.removeCredentialProcessor(processor));
|
|
2876
|
+
(0, import_async10.scheduleTask)(ctx, () => space.spaceState.addCredentialProcessor(processor));
|
|
2782
2877
|
});
|
|
2783
2878
|
}
|
|
2784
2879
|
async writeCredentials({ spaceKey, credentials }) {
|
|
2785
2880
|
var _a;
|
|
2786
|
-
const space = (_a = this._spaceManager.spaces.get(spaceKey)) != null ? _a : (0,
|
|
2881
|
+
const space = (_a = this._spaceManager.spaces.get(spaceKey)) != null ? _a : (0, import_debug6.raise)(new import_echo_pipeline2.SpaceNotFoundError(spaceKey));
|
|
2787
2882
|
for (const credential of credentials != null ? credentials : []) {
|
|
2788
2883
|
await space.controlPipeline.writer.write({
|
|
2789
2884
|
credential: {
|
|
@@ -2795,7 +2890,7 @@ var SpacesServiceImpl = class {
|
|
|
2795
2890
|
async createEpoch({ spaceKey }) {
|
|
2796
2891
|
var _a;
|
|
2797
2892
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
2798
|
-
const space = (_a = dataSpaceManager.spaces.get(spaceKey)) != null ? _a : (0,
|
|
2893
|
+
const space = (_a = dataSpaceManager.spaces.get(spaceKey)) != null ? _a : (0, import_debug6.raise)(new import_echo_pipeline2.SpaceNotFoundError(spaceKey));
|
|
2799
2894
|
await space.createEpoch();
|
|
2800
2895
|
}
|
|
2801
2896
|
_serializeSpace(space) {
|
|
@@ -2838,6 +2933,7 @@ var SpacesServiceImpl = class {
|
|
|
2838
2933
|
var getChannelId = (channel) => `user-channel/${channel}`;
|
|
2839
2934
|
|
|
2840
2935
|
// packages/sdk/client-services/src/packlets/services/service-context.ts
|
|
2936
|
+
var __dxlog_file12 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-context.ts";
|
|
2841
2937
|
var ServiceContext = class {
|
|
2842
2938
|
// prettier-ignore
|
|
2843
2939
|
constructor(storage, networkManager, signalManager, modelFactory) {
|
|
@@ -2874,24 +2970,24 @@ var ServiceContext = class {
|
|
|
2874
2970
|
this.invitations = new InvitationsHandler(this.networkManager);
|
|
2875
2971
|
this._handlerFactories.set(import_services9.Invitation.Kind.DEVICE, () => new DeviceInvitationProtocol(this.keyring, () => {
|
|
2876
2972
|
var _a;
|
|
2877
|
-
return (_a = this.identityManager.identity) != null ? _a : (0,
|
|
2973
|
+
return (_a = this.identityManager.identity) != null ? _a : (0, import_debug7.failUndefined)();
|
|
2878
2974
|
}, this._acceptIdentity.bind(this)));
|
|
2879
2975
|
}
|
|
2880
2976
|
async open() {
|
|
2881
2977
|
import_log12.log.trace("dxos.sdk.service-context.open", import_protocols8.trace.begin({
|
|
2882
2978
|
id: this._instanceId
|
|
2883
2979
|
}), {
|
|
2884
|
-
|
|
2885
|
-
|
|
2886
|
-
|
|
2887
|
-
|
|
2980
|
+
F: __dxlog_file12,
|
|
2981
|
+
L: 126,
|
|
2982
|
+
S: this,
|
|
2983
|
+
C: (f, a) => f(...a)
|
|
2888
2984
|
});
|
|
2889
2985
|
await this._checkStorageVersion();
|
|
2890
|
-
(0, import_log12.log)("opening...",
|
|
2891
|
-
|
|
2892
|
-
|
|
2893
|
-
|
|
2894
|
-
|
|
2986
|
+
(0, import_log12.log)("opening...", void 0, {
|
|
2987
|
+
F: __dxlog_file12,
|
|
2988
|
+
L: 130,
|
|
2989
|
+
S: this,
|
|
2990
|
+
C: (f, a) => f(...a)
|
|
2895
2991
|
});
|
|
2896
2992
|
await this.signalManager.open();
|
|
2897
2993
|
await this.networkManager.open();
|
|
@@ -2900,42 +2996,44 @@ var ServiceContext = class {
|
|
|
2900
2996
|
if (this.identityManager.identity) {
|
|
2901
2997
|
await this._initialize();
|
|
2902
2998
|
}
|
|
2903
|
-
(0, import_log12.log)("opened",
|
|
2904
|
-
|
|
2905
|
-
|
|
2906
|
-
|
|
2907
|
-
|
|
2999
|
+
(0, import_log12.log)("opened", void 0, {
|
|
3000
|
+
F: __dxlog_file12,
|
|
3001
|
+
L: 138,
|
|
3002
|
+
S: this,
|
|
3003
|
+
C: (f, a) => f(...a)
|
|
2908
3004
|
});
|
|
2909
3005
|
import_log12.log.trace("dxos.sdk.service-context.open", import_protocols8.trace.end({
|
|
2910
3006
|
id: this._instanceId
|
|
2911
3007
|
}), {
|
|
2912
|
-
|
|
2913
|
-
|
|
2914
|
-
|
|
2915
|
-
|
|
3008
|
+
F: __dxlog_file12,
|
|
3009
|
+
L: 139,
|
|
3010
|
+
S: this,
|
|
3011
|
+
C: (f, a) => f(...a)
|
|
2916
3012
|
});
|
|
2917
3013
|
}
|
|
2918
3014
|
async close() {
|
|
2919
|
-
var _a
|
|
2920
|
-
(0, import_log12.log)("closing...",
|
|
2921
|
-
|
|
2922
|
-
|
|
2923
|
-
|
|
2924
|
-
|
|
3015
|
+
var _a;
|
|
3016
|
+
(0, import_log12.log)("closing...", void 0, {
|
|
3017
|
+
F: __dxlog_file12,
|
|
3018
|
+
L: 143,
|
|
3019
|
+
S: this,
|
|
3020
|
+
C: (f, a) => f(...a)
|
|
2925
3021
|
});
|
|
2926
|
-
|
|
2927
|
-
|
|
3022
|
+
if (this._deviceSpaceSync && this.identityManager.identity) {
|
|
3023
|
+
await this.identityManager.identity.space.spaceState.removeCredentialProcessor(this._deviceSpaceSync);
|
|
3024
|
+
}
|
|
3025
|
+
await ((_a = this.dataSpaceManager) == null ? void 0 : _a.close());
|
|
2928
3026
|
await this.identityManager.close();
|
|
2929
3027
|
await this.spaceManager.close();
|
|
2930
3028
|
await this.feedStore.close();
|
|
2931
3029
|
await this.networkManager.close();
|
|
2932
3030
|
await this.signalManager.close();
|
|
2933
3031
|
this.dataServiceSubscriptions.clear();
|
|
2934
|
-
(0, import_log12.log)("closed",
|
|
2935
|
-
|
|
2936
|
-
|
|
2937
|
-
|
|
2938
|
-
|
|
3032
|
+
(0, import_log12.log)("closed", void 0, {
|
|
3033
|
+
F: __dxlog_file12,
|
|
3034
|
+
L: 154,
|
|
3035
|
+
S: this,
|
|
3036
|
+
C: (f, a) => f(...a)
|
|
2939
3037
|
});
|
|
2940
3038
|
}
|
|
2941
3039
|
async createIdentity(params = {}) {
|
|
@@ -2945,7 +3043,7 @@ var ServiceContext = class {
|
|
|
2945
3043
|
}
|
|
2946
3044
|
getInvitationHandler(invitation) {
|
|
2947
3045
|
const factory = this._handlerFactories.get(invitation.kind);
|
|
2948
|
-
(0,
|
|
3046
|
+
(0, import_tiny_invariant11.default)(factory, `Unknown invitation kind: ${invitation.kind}`);
|
|
2949
3047
|
return factory(invitation);
|
|
2950
3048
|
}
|
|
2951
3049
|
async _acceptIdentity(params) {
|
|
@@ -2962,13 +3060,13 @@ var ServiceContext = class {
|
|
|
2962
3060
|
// Called when identity is created.
|
|
2963
3061
|
async _initialize() {
|
|
2964
3062
|
var _a;
|
|
2965
|
-
(0, import_log12.log)("initializing spaces...",
|
|
2966
|
-
|
|
2967
|
-
|
|
2968
|
-
|
|
2969
|
-
|
|
3063
|
+
(0, import_log12.log)("initializing spaces...", void 0, {
|
|
3064
|
+
F: __dxlog_file12,
|
|
3065
|
+
L: 187,
|
|
3066
|
+
S: this,
|
|
3067
|
+
C: (f, a) => f(...a)
|
|
2970
3068
|
});
|
|
2971
|
-
const identity = (_a = this.identityManager.identity) != null ? _a : (0,
|
|
3069
|
+
const identity = (_a = this.identityManager.identity) != null ? _a : (0, import_debug7.failUndefined)();
|
|
2972
3070
|
const signingContext = {
|
|
2973
3071
|
credentialSigner: identity.getIdentityCredentialSigner(),
|
|
2974
3072
|
identityKey: identity.identityKey,
|
|
@@ -2985,12 +3083,12 @@ var ServiceContext = class {
|
|
|
2985
3083
|
this.dataSpaceManager = new DataSpaceManager(this.spaceManager, this.metadataStore, this.dataServiceSubscriptions, this.keyring, signingContext, this.feedStore);
|
|
2986
3084
|
await this.dataSpaceManager.open();
|
|
2987
3085
|
this._handlerFactories.set(import_services9.Invitation.Kind.SPACE, (invitation) => {
|
|
2988
|
-
(0,
|
|
3086
|
+
(0, import_tiny_invariant11.default)(this.dataSpaceManager, "dataSpaceManager not initialized yet");
|
|
2989
3087
|
return new SpaceInvitationProtocol(this.dataSpaceManager, signingContext, this.keyring, invitation.spaceKey);
|
|
2990
3088
|
});
|
|
2991
3089
|
this.initialized.wake();
|
|
2992
|
-
this._deviceSpaceSync =
|
|
2993
|
-
|
|
3090
|
+
this._deviceSpaceSync = {
|
|
3091
|
+
processCredential: async (credential) => {
|
|
2994
3092
|
const assertion = (0, import_credentials14.getCredentialAssertion)(credential);
|
|
2995
3093
|
if (assertion["@type"] !== "dxos.halo.credentials.SpaceMember") {
|
|
2996
3094
|
return;
|
|
@@ -3002,10 +3100,10 @@ var ServiceContext = class {
|
|
|
3002
3100
|
(0, import_log12.log)("dataSpaceManager not initialized yet, ignoring space admission", {
|
|
3003
3101
|
details: assertion
|
|
3004
3102
|
}, {
|
|
3005
|
-
|
|
3006
|
-
|
|
3007
|
-
|
|
3008
|
-
|
|
3103
|
+
F: __dxlog_file12,
|
|
3104
|
+
L: 226,
|
|
3105
|
+
S: this,
|
|
3106
|
+
C: (f, a) => f(...a)
|
|
3009
3107
|
});
|
|
3010
3108
|
return;
|
|
3011
3109
|
}
|
|
@@ -3013,10 +3111,10 @@ var ServiceContext = class {
|
|
|
3013
3111
|
(0, import_log12.log)("space already exists, ignoring space admission", {
|
|
3014
3112
|
details: assertion
|
|
3015
3113
|
}, {
|
|
3016
|
-
|
|
3017
|
-
|
|
3018
|
-
|
|
3019
|
-
|
|
3114
|
+
F: __dxlog_file12,
|
|
3115
|
+
L: 230,
|
|
3116
|
+
S: this,
|
|
3117
|
+
C: (f, a) => f(...a)
|
|
3020
3118
|
});
|
|
3021
3119
|
return;
|
|
3022
3120
|
}
|
|
@@ -3024,44 +3122,47 @@ var ServiceContext = class {
|
|
|
3024
3122
|
(0, import_log12.log)("accepting space recorded in halo", {
|
|
3025
3123
|
details: assertion
|
|
3026
3124
|
}, {
|
|
3027
|
-
|
|
3028
|
-
|
|
3029
|
-
|
|
3030
|
-
|
|
3125
|
+
F: __dxlog_file12,
|
|
3126
|
+
L: 235,
|
|
3127
|
+
S: this,
|
|
3128
|
+
C: (f, a) => f(...a)
|
|
3031
3129
|
});
|
|
3032
3130
|
await this.dataSpaceManager.acceptSpace({
|
|
3033
3131
|
spaceKey: assertion.spaceKey,
|
|
3034
3132
|
genesisFeedKey: assertion.genesisFeedKey
|
|
3035
3133
|
});
|
|
3036
3134
|
} catch (err) {
|
|
3037
|
-
import_log12.log.catch(err,
|
|
3038
|
-
|
|
3039
|
-
|
|
3040
|
-
|
|
3041
|
-
|
|
3135
|
+
import_log12.log.catch(err, void 0, {
|
|
3136
|
+
F: __dxlog_file12,
|
|
3137
|
+
L: 241,
|
|
3138
|
+
S: this,
|
|
3139
|
+
C: (f, a) => f(...a)
|
|
3042
3140
|
});
|
|
3043
3141
|
}
|
|
3044
3142
|
}
|
|
3045
|
-
}
|
|
3046
|
-
await this._deviceSpaceSync
|
|
3143
|
+
};
|
|
3144
|
+
await identity.space.spaceState.addCredentialProcessor(this._deviceSpaceSync);
|
|
3047
3145
|
}
|
|
3048
3146
|
};
|
|
3049
3147
|
|
|
3050
3148
|
// packages/sdk/client-services/src/packlets/services/service-host.ts
|
|
3051
|
-
var
|
|
3149
|
+
var import_tiny_invariant13 = __toESM(require("tiny-invariant"));
|
|
3052
3150
|
var import_async17 = require("@dxos/async");
|
|
3053
3151
|
var import_client_protocol5 = require("@dxos/client-protocol");
|
|
3152
|
+
var import_document_model = require("@dxos/document-model");
|
|
3054
3153
|
var import_echo_pipeline4 = require("@dxos/echo-pipeline");
|
|
3055
3154
|
var import_keys12 = require("@dxos/keys");
|
|
3056
3155
|
var import_log15 = require("@dxos/log");
|
|
3057
3156
|
var import_messaging = require("@dxos/messaging");
|
|
3157
|
+
var import_model_factory = require("@dxos/model-factory");
|
|
3058
3158
|
var import_network_manager2 = require("@dxos/network-manager");
|
|
3059
3159
|
var import_protocols9 = require("@dxos/protocols");
|
|
3060
3160
|
var import_services12 = require("@dxos/protocols/proto/dxos/client/services");
|
|
3161
|
+
var import_text_model = require("@dxos/text-model");
|
|
3061
3162
|
|
|
3062
3163
|
// packages/sdk/client-services/src/packlets/devices/devices-service.ts
|
|
3063
3164
|
var import_async12 = require("@dxos/async");
|
|
3064
|
-
var
|
|
3165
|
+
var import_codec_protobuf5 = require("@dxos/codec-protobuf");
|
|
3065
3166
|
var import_services10 = require("@dxos/protocols/proto/dxos/client/services");
|
|
3066
3167
|
var DevicesServiceImpl = class {
|
|
3067
3168
|
constructor(_identityManager) {
|
|
@@ -3071,7 +3172,7 @@ var DevicesServiceImpl = class {
|
|
|
3071
3172
|
throw new Error("Method not implemented.");
|
|
3072
3173
|
}
|
|
3073
3174
|
queryDevices() {
|
|
3074
|
-
return new
|
|
3175
|
+
return new import_codec_protobuf5.Stream(({ next }) => {
|
|
3075
3176
|
const update = () => {
|
|
3076
3177
|
var _a;
|
|
3077
3178
|
const deviceKeys = (_a = this._identityManager.identity) == null ? void 0 : _a.authorizedDeviceKeys;
|
|
@@ -3108,16 +3209,16 @@ var DevicesServiceImpl = class {
|
|
|
3108
3209
|
|
|
3109
3210
|
// packages/sdk/client-services/src/packlets/devtools/devtools.ts
|
|
3110
3211
|
var import_async15 = require("@dxos/async");
|
|
3111
|
-
var
|
|
3212
|
+
var import_codec_protobuf11 = require("@dxos/codec-protobuf");
|
|
3112
3213
|
|
|
3113
3214
|
// packages/sdk/client-services/src/packlets/devtools/feeds.ts
|
|
3114
3215
|
var import_async13 = require("@dxos/async");
|
|
3115
|
-
var
|
|
3216
|
+
var import_codec_protobuf6 = require("@dxos/codec-protobuf");
|
|
3116
3217
|
var import_feed_store4 = require("@dxos/feed-store");
|
|
3117
3218
|
var import_keys9 = require("@dxos/keys");
|
|
3118
3219
|
var import_util6 = require("@dxos/util");
|
|
3119
3220
|
var subscribeToFeeds = ({ feedStore }, { feedKeys }) => {
|
|
3120
|
-
return new
|
|
3221
|
+
return new import_codec_protobuf6.Stream(({ next }) => {
|
|
3121
3222
|
const subscriptions = new import_async13.EventSubscriptions();
|
|
3122
3223
|
const feedMap = new import_util6.ComplexMap(import_keys9.PublicKey.hash);
|
|
3123
3224
|
const update = () => {
|
|
@@ -3149,7 +3250,7 @@ var subscribeToFeeds = ({ feedStore }, { feedKeys }) => {
|
|
|
3149
3250
|
});
|
|
3150
3251
|
};
|
|
3151
3252
|
var subscribeToFeedBlocks = ({ feedStore }, { feedKey, maxBlocks = 10 }) => {
|
|
3152
|
-
return new
|
|
3253
|
+
return new import_codec_protobuf6.Stream(({ next }) => {
|
|
3153
3254
|
if (!feedKey) {
|
|
3154
3255
|
return;
|
|
3155
3256
|
}
|
|
@@ -3189,8 +3290,8 @@ var subscribeToFeedBlocks = ({ feedStore }, { feedKey, maxBlocks = 10 }) => {
|
|
|
3189
3290
|
|
|
3190
3291
|
// packages/sdk/client-services/src/packlets/devtools/keys.ts
|
|
3191
3292
|
var import_async14 = require("@dxos/async");
|
|
3192
|
-
var
|
|
3193
|
-
var subscribeToKeyringKeys = ({ keyring }) => new
|
|
3293
|
+
var import_codec_protobuf7 = require("@dxos/codec-protobuf");
|
|
3294
|
+
var subscribeToKeyringKeys = ({ keyring }) => new import_codec_protobuf7.Stream(({ next, ctx }) => {
|
|
3194
3295
|
const update = async () => {
|
|
3195
3296
|
next({
|
|
3196
3297
|
keys: await keyring.list()
|
|
@@ -3201,8 +3302,8 @@ var subscribeToKeyringKeys = ({ keyring }) => new import_codec_protobuf6.Stream(
|
|
|
3201
3302
|
});
|
|
3202
3303
|
|
|
3203
3304
|
// packages/sdk/client-services/src/packlets/devtools/metadata.ts
|
|
3204
|
-
var
|
|
3205
|
-
var subscribeToMetadata = ({ context }) => new
|
|
3305
|
+
var import_codec_protobuf8 = require("@dxos/codec-protobuf");
|
|
3306
|
+
var subscribeToMetadata = ({ context }) => new import_codec_protobuf8.Stream(({ next, ctx }) => {
|
|
3206
3307
|
context.metadataStore.update.on(ctx, (data) => next({
|
|
3207
3308
|
metadata: data
|
|
3208
3309
|
}));
|
|
@@ -3212,10 +3313,10 @@ var subscribeToMetadata = ({ context }) => new import_codec_protobuf7.Stream(({
|
|
|
3212
3313
|
});
|
|
3213
3314
|
|
|
3214
3315
|
// packages/sdk/client-services/src/packlets/devtools/network.ts
|
|
3215
|
-
var
|
|
3316
|
+
var import_codec_protobuf9 = require("@dxos/codec-protobuf");
|
|
3216
3317
|
var import_context7 = require("@dxos/context");
|
|
3217
3318
|
var import_keys10 = require("@dxos/keys");
|
|
3218
|
-
var subscribeToNetworkStatus = ({ signalManager }) => new
|
|
3319
|
+
var subscribeToNetworkStatus = ({ signalManager }) => new import_codec_protobuf9.Stream(({ next, close }) => {
|
|
3219
3320
|
const update = () => {
|
|
3220
3321
|
try {
|
|
3221
3322
|
const status = signalManager.getStatus();
|
|
@@ -3229,7 +3330,7 @@ var subscribeToNetworkStatus = ({ signalManager }) => new import_codec_protobuf8
|
|
|
3229
3330
|
signalManager.statusChanged.on(() => update());
|
|
3230
3331
|
update();
|
|
3231
3332
|
});
|
|
3232
|
-
var subscribeToSignal = ({ signalManager }) => new
|
|
3333
|
+
var subscribeToSignal = ({ signalManager }) => new import_codec_protobuf9.Stream(({ next }) => {
|
|
3233
3334
|
const ctx = new import_context7.Context();
|
|
3234
3335
|
signalManager.onMessage.on(ctx, (message) => {
|
|
3235
3336
|
next({
|
|
@@ -3251,7 +3352,7 @@ var subscribeToSignal = ({ signalManager }) => new import_codec_protobuf8.Stream
|
|
|
3251
3352
|
return ctx.dispose();
|
|
3252
3353
|
};
|
|
3253
3354
|
});
|
|
3254
|
-
var subscribeToSwarmInfo = ({ networkManager }) => new
|
|
3355
|
+
var subscribeToSwarmInfo = ({ networkManager }) => new import_codec_protobuf9.Stream(({ next }) => {
|
|
3255
3356
|
var _a;
|
|
3256
3357
|
const update = () => {
|
|
3257
3358
|
var _a2;
|
|
@@ -3267,9 +3368,9 @@ var subscribeToSwarmInfo = ({ networkManager }) => new import_codec_protobuf8.St
|
|
|
3267
3368
|
});
|
|
3268
3369
|
|
|
3269
3370
|
// packages/sdk/client-services/src/packlets/devtools/spaces.ts
|
|
3270
|
-
var
|
|
3371
|
+
var import_codec_protobuf10 = require("@dxos/codec-protobuf");
|
|
3271
3372
|
var subscribeToSpaces = (context, { spaceKeys = [] }) => {
|
|
3272
|
-
return new
|
|
3373
|
+
return new import_codec_protobuf10.Stream(({ next }) => {
|
|
3273
3374
|
let unsubscribe;
|
|
3274
3375
|
const update = async () => {
|
|
3275
3376
|
const spaces = [
|
|
@@ -3313,7 +3414,7 @@ var DevtoolsServiceImpl = class {
|
|
|
3313
3414
|
this.params = params;
|
|
3314
3415
|
}
|
|
3315
3416
|
events(request) {
|
|
3316
|
-
return new
|
|
3417
|
+
return new import_codec_protobuf11.Stream(({ next }) => {
|
|
3317
3418
|
this.params.events.ready.on(() => {
|
|
3318
3419
|
next({
|
|
3319
3420
|
ready: {}
|
|
@@ -3420,10 +3521,10 @@ var DevtoolsServiceImpl = class {
|
|
|
3420
3521
|
};
|
|
3421
3522
|
|
|
3422
3523
|
// packages/sdk/client-services/src/packlets/locks/node.ts
|
|
3423
|
-
var
|
|
3524
|
+
var import_tiny_invariant12 = __toESM(require("tiny-invariant"));
|
|
3424
3525
|
var import_lock_file = require("@dxos/lock-file");
|
|
3425
3526
|
var import_log13 = require("@dxos/log");
|
|
3426
|
-
|
|
3527
|
+
function _ts_decorate3(decorators, target, key, desc) {
|
|
3427
3528
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3428
3529
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
3429
3530
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -3432,7 +3533,8 @@ var __decorate3 = function(decorators, target, key, desc) {
|
|
|
3432
3533
|
if (d = decorators[i])
|
|
3433
3534
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
3434
3535
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3435
|
-
}
|
|
3536
|
+
}
|
|
3537
|
+
var __dxlog_file13 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/locks/node.ts";
|
|
3436
3538
|
var Lock = class {
|
|
3437
3539
|
constructor({ lockKey: lockPath, onAcquire, onRelease }) {
|
|
3438
3540
|
this._lockPath = lockPath;
|
|
@@ -3444,35 +3546,35 @@ var Lock = class {
|
|
|
3444
3546
|
}
|
|
3445
3547
|
async acquire() {
|
|
3446
3548
|
var _a;
|
|
3447
|
-
(0, import_log13.log)("acquiring lock...",
|
|
3448
|
-
|
|
3449
|
-
|
|
3450
|
-
|
|
3451
|
-
|
|
3549
|
+
(0, import_log13.log)("acquiring lock...", void 0, {
|
|
3550
|
+
F: __dxlog_file13,
|
|
3551
|
+
L: 32,
|
|
3552
|
+
S: this,
|
|
3553
|
+
C: (f, a) => f(...a)
|
|
3452
3554
|
});
|
|
3453
3555
|
this._fileHandle = await import_lock_file.LockFile.acquire(this._lockPath);
|
|
3454
3556
|
await ((_a = this._onAcquire) == null ? void 0 : _a.call(this));
|
|
3455
|
-
(0, import_log13.log)("acquired lock",
|
|
3456
|
-
|
|
3457
|
-
|
|
3458
|
-
|
|
3459
|
-
|
|
3557
|
+
(0, import_log13.log)("acquired lock", void 0, {
|
|
3558
|
+
F: __dxlog_file13,
|
|
3559
|
+
L: 37,
|
|
3560
|
+
S: this,
|
|
3561
|
+
C: (f, a) => f(...a)
|
|
3460
3562
|
});
|
|
3461
3563
|
}
|
|
3462
3564
|
async release() {
|
|
3463
3565
|
var _a;
|
|
3464
3566
|
await ((_a = this._onRelease) == null ? void 0 : _a.call(this));
|
|
3465
|
-
(0,
|
|
3567
|
+
(0, import_tiny_invariant12.default)(this._fileHandle, "Lock is not acquired");
|
|
3466
3568
|
await import_lock_file.LockFile.release(this._fileHandle);
|
|
3467
3569
|
}
|
|
3468
3570
|
};
|
|
3469
|
-
|
|
3571
|
+
_ts_decorate3([
|
|
3470
3572
|
import_log13.logInfo
|
|
3471
3573
|
], Lock.prototype, "lockKey", null);
|
|
3472
3574
|
|
|
3473
3575
|
// packages/sdk/client-services/src/packlets/logging/logging-service.ts
|
|
3474
3576
|
var import_async16 = require("@dxos/async");
|
|
3475
|
-
var
|
|
3577
|
+
var import_codec_protobuf12 = require("@dxos/codec-protobuf");
|
|
3476
3578
|
var import_log14 = require("@dxos/log");
|
|
3477
3579
|
var import_services11 = require("@dxos/protocols/proto/dxos/client/services");
|
|
3478
3580
|
var import_util7 = require("@dxos/util");
|
|
@@ -3491,13 +3593,13 @@ var LoggingServiceImpl = class {
|
|
|
3491
3593
|
import_log14.log.runtimeConfig.processors.splice(index, 1);
|
|
3492
3594
|
}
|
|
3493
3595
|
queryLogs(request) {
|
|
3494
|
-
return new
|
|
3596
|
+
return new import_codec_protobuf12.Stream(({ ctx, next }) => {
|
|
3495
3597
|
const handler = (entry2) => {
|
|
3496
3598
|
var _a, _b, _c, _d, _e;
|
|
3497
3599
|
if (LOG_PROCESSING > 0) {
|
|
3498
3600
|
return;
|
|
3499
3601
|
}
|
|
3500
|
-
if (((_a = entry2.meta) == null ? void 0 : _a.
|
|
3602
|
+
if (((_a = entry2.meta) == null ? void 0 : _a.F.includes("logging-service")) || entry2.context && Object.values(entry2.context).some((value) => typeof value === "string" && value.includes("LoggingService"))) {
|
|
3501
3603
|
return;
|
|
3502
3604
|
}
|
|
3503
3605
|
if (!shouldLog(entry2, request)) {
|
|
@@ -3509,8 +3611,8 @@ var LoggingServiceImpl = class {
|
|
|
3509
3611
|
timestamp: new Date(),
|
|
3510
3612
|
meta: {
|
|
3511
3613
|
// TODO(dmaretskyi): Fix proto.
|
|
3512
|
-
file: (_c = (_b = entry2.meta) == null ? void 0 : _b.
|
|
3513
|
-
line: (_e = (_d = entry2.meta) == null ? void 0 : _d.
|
|
3614
|
+
file: (_c = (_b = entry2.meta) == null ? void 0 : _b.F) != null ? _c : "",
|
|
3615
|
+
line: (_e = (_d = entry2.meta) == null ? void 0 : _d.L) != null ? _e : 0
|
|
3514
3616
|
}
|
|
3515
3617
|
};
|
|
3516
3618
|
try {
|
|
@@ -3540,21 +3642,21 @@ var shouldLog = (entry2, request) => {
|
|
|
3540
3642
|
} else {
|
|
3541
3643
|
return request.filters.some((filter) => {
|
|
3542
3644
|
var _a2, _b;
|
|
3543
|
-
return matchFilter(filter, entry2.level, (_b = (_a2 = entry2.meta) == null ? void 0 : _a2.
|
|
3645
|
+
return matchFilter(filter, entry2.level, (_b = (_a2 = entry2.meta) == null ? void 0 : _a2.F) != null ? _b : "", options);
|
|
3544
3646
|
});
|
|
3545
3647
|
}
|
|
3546
3648
|
};
|
|
3547
3649
|
var LOG_PROCESSING = 0;
|
|
3548
3650
|
|
|
3549
3651
|
// packages/sdk/client-services/src/packlets/network/network-service.ts
|
|
3550
|
-
var
|
|
3652
|
+
var import_codec_protobuf13 = require("@dxos/codec-protobuf");
|
|
3551
3653
|
var NetworkServiceImpl = class {
|
|
3552
3654
|
constructor(networkManager, signalManager) {
|
|
3553
3655
|
this.networkManager = networkManager;
|
|
3554
3656
|
this.signalManager = signalManager;
|
|
3555
3657
|
}
|
|
3556
3658
|
queryStatus() {
|
|
3557
|
-
return new
|
|
3659
|
+
return new import_codec_protobuf13.Stream(({ next }) => {
|
|
3558
3660
|
const update = () => {
|
|
3559
3661
|
next({
|
|
3560
3662
|
swarm: this.networkManager.connectionState,
|
|
@@ -3580,7 +3682,7 @@ var NetworkServiceImpl = class {
|
|
|
3580
3682
|
|
|
3581
3683
|
// packages/sdk/client-services/src/packlets/storage/storage.ts
|
|
3582
3684
|
var import_client_protocol4 = require("@dxos/client-protocol");
|
|
3583
|
-
var
|
|
3685
|
+
var import_errors5 = require("@dxos/errors");
|
|
3584
3686
|
var import_config = require("@dxos/protocols/proto/dxos/config");
|
|
3585
3687
|
var import_random_access_storage = require("@dxos/random-access-storage");
|
|
3586
3688
|
var import_util8 = require("@dxos/util");
|
|
@@ -3588,16 +3690,16 @@ var StorageDriver = import_config.Runtime.Client.Storage.StorageDriver;
|
|
|
3588
3690
|
var createStorageObjects = (config) => {
|
|
3589
3691
|
const { path = (0, import_util8.isNode)() ? import_client_protocol4.DX_DATA : "dxos/storage", storageType, keyStorage, persistent = false } = config != null ? config : {};
|
|
3590
3692
|
if (persistent && storageType === StorageDriver.RAM) {
|
|
3591
|
-
throw new
|
|
3693
|
+
throw new import_errors5.InvalidConfigError("RAM storage cannot be used in persistent mode.");
|
|
3592
3694
|
}
|
|
3593
3695
|
if (!persistent && storageType !== void 0 && storageType !== StorageDriver.RAM) {
|
|
3594
|
-
throw new
|
|
3696
|
+
throw new import_errors5.InvalidConfigError("Cannot use a persistent storage in not persistent mode.");
|
|
3595
3697
|
}
|
|
3596
3698
|
if (persistent && keyStorage === StorageDriver.RAM) {
|
|
3597
|
-
throw new
|
|
3699
|
+
throw new import_errors5.InvalidConfigError("RAM key storage cannot be used in persistent mode.");
|
|
3598
3700
|
}
|
|
3599
3701
|
if (!persistent && keyStorage !== StorageDriver.RAM && keyStorage !== void 0) {
|
|
3600
|
-
throw new
|
|
3702
|
+
throw new import_errors5.InvalidConfigError("Cannot use a persistent key storage in not persistent mode.");
|
|
3601
3703
|
}
|
|
3602
3704
|
return {
|
|
3603
3705
|
storage: (0, import_random_access_storage.createStorage)({
|
|
@@ -3628,7 +3730,7 @@ var toStorageType = (type) => {
|
|
|
3628
3730
|
};
|
|
3629
3731
|
|
|
3630
3732
|
// packages/sdk/client-services/src/packlets/system/system-service.ts
|
|
3631
|
-
var
|
|
3733
|
+
var import_codec_protobuf14 = require("@dxos/codec-protobuf");
|
|
3632
3734
|
var SystemServiceImpl = class {
|
|
3633
3735
|
constructor({ config, statusUpdate, onUpdateStatus, getCurrentStatus, onReset }) {
|
|
3634
3736
|
this._config = config;
|
|
@@ -3645,7 +3747,7 @@ var SystemServiceImpl = class {
|
|
|
3645
3747
|
await this._onUpdateStatus(status);
|
|
3646
3748
|
}
|
|
3647
3749
|
queryStatus() {
|
|
3648
|
-
return new
|
|
3750
|
+
return new import_codec_protobuf14.Stream(({ next }) => {
|
|
3649
3751
|
const update = () => {
|
|
3650
3752
|
next({
|
|
3651
3753
|
status: this._getCurrentStatus()
|
|
@@ -3690,7 +3792,7 @@ var ServiceRegistry = class {
|
|
|
3690
3792
|
};
|
|
3691
3793
|
|
|
3692
3794
|
// packages/sdk/client-services/src/packlets/services/service-host.ts
|
|
3693
|
-
|
|
3795
|
+
function _ts_decorate4(decorators, target, key, desc) {
|
|
3694
3796
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3695
3797
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
3696
3798
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -3699,24 +3801,30 @@ var __decorate4 = function(decorators, target, key, desc) {
|
|
|
3699
3801
|
if (d = decorators[i])
|
|
3700
3802
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
3701
3803
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3804
|
+
}
|
|
3805
|
+
var __dxlog_file14 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-host.ts";
|
|
3806
|
+
var createDefaultModelFactory = () => {
|
|
3807
|
+
return new import_model_factory.ModelFactory().registerModel(import_document_model.DocumentModel).registerModel(import_text_model.TextModel);
|
|
3702
3808
|
};
|
|
3703
3809
|
var ClientServicesHost = class {
|
|
3704
3810
|
constructor({
|
|
3705
3811
|
config,
|
|
3706
|
-
modelFactory =
|
|
3812
|
+
modelFactory = createDefaultModelFactory(),
|
|
3707
3813
|
// TODO(burdon): Create ApolloLink abstraction (see Client).
|
|
3708
3814
|
transportFactory,
|
|
3709
3815
|
signalManager,
|
|
3710
3816
|
connectionLog,
|
|
3711
3817
|
storage,
|
|
3712
3818
|
// TODO(wittjosiah): Turn this on by default.
|
|
3713
|
-
lockKey
|
|
3819
|
+
lockKey,
|
|
3820
|
+
callbacks
|
|
3714
3821
|
} = {}) {
|
|
3715
3822
|
this._statusUpdate = new import_async17.Event();
|
|
3716
3823
|
this._opening = false;
|
|
3717
3824
|
this._open = false;
|
|
3718
3825
|
this._storage = storage;
|
|
3719
3826
|
this._modelFactory = modelFactory;
|
|
3827
|
+
this._callbacks = callbacks;
|
|
3720
3828
|
if (config) {
|
|
3721
3829
|
this.initialize({
|
|
3722
3830
|
config,
|
|
@@ -3775,9 +3883,9 @@ var ClientServicesHost = class {
|
|
|
3775
3883
|
*/
|
|
3776
3884
|
initialize({ config, ...options }) {
|
|
3777
3885
|
var _a, _b, _c;
|
|
3778
|
-
(0,
|
|
3886
|
+
(0, import_tiny_invariant13.default)(!this._open, "service host is open");
|
|
3779
3887
|
if (config) {
|
|
3780
|
-
(0,
|
|
3888
|
+
(0, import_tiny_invariant13.default)(!this._config, "config already set");
|
|
3781
3889
|
this._config = config;
|
|
3782
3890
|
if (!this._storage) {
|
|
3783
3891
|
this._storage = createStorageObjects(config.get("runtime.client.storage", {})).storage;
|
|
@@ -3787,7 +3895,7 @@ var ClientServicesHost = class {
|
|
|
3787
3895
|
iceServers: (_a = this._config) == null ? void 0 : _a.get("runtime.services.ice")
|
|
3788
3896
|
}), signalManager = new import_messaging.WebsocketSignalManager((_c = (_b = this._config) == null ? void 0 : _b.get("runtime.services.signaling")) != null ? _c : []) } = options;
|
|
3789
3897
|
this._signalManager = signalManager;
|
|
3790
|
-
(0,
|
|
3898
|
+
(0, import_tiny_invariant13.default)(!this._networkManager, "network manager already set");
|
|
3791
3899
|
this._networkManager = new import_network_manager2.NetworkManager({
|
|
3792
3900
|
log: connectionLog,
|
|
3793
3901
|
transportFactory,
|
|
@@ -3803,23 +3911,23 @@ var ClientServicesHost = class {
|
|
|
3803
3911
|
import_log15.log.trace("dxos.sdk.client-services-host.open", import_protocols9.trace.begin({
|
|
3804
3912
|
id: traceId
|
|
3805
3913
|
}), {
|
|
3806
|
-
|
|
3807
|
-
|
|
3808
|
-
|
|
3809
|
-
|
|
3914
|
+
F: __dxlog_file14,
|
|
3915
|
+
L: 203,
|
|
3916
|
+
S: this,
|
|
3917
|
+
C: (f, a) => f(...a)
|
|
3810
3918
|
});
|
|
3811
|
-
(0,
|
|
3812
|
-
(0,
|
|
3813
|
-
(0,
|
|
3814
|
-
(0,
|
|
3919
|
+
(0, import_tiny_invariant13.default)(this._config, "config not set");
|
|
3920
|
+
(0, import_tiny_invariant13.default)(this._storage, "storage not set");
|
|
3921
|
+
(0, import_tiny_invariant13.default)(this._signalManager, "signal manager not set");
|
|
3922
|
+
(0, import_tiny_invariant13.default)(this._networkManager, "network manager not set");
|
|
3815
3923
|
this._opening = true;
|
|
3816
3924
|
(0, import_log15.log)("opening...", {
|
|
3817
3925
|
lockKey: (_a = this._resourceLock) == null ? void 0 : _a.lockKey
|
|
3818
3926
|
}, {
|
|
3819
|
-
|
|
3820
|
-
|
|
3821
|
-
|
|
3822
|
-
|
|
3927
|
+
F: __dxlog_file14,
|
|
3928
|
+
L: 211,
|
|
3929
|
+
S: this,
|
|
3930
|
+
C: (f, a) => f(...a)
|
|
3823
3931
|
});
|
|
3824
3932
|
await ((_b = this._resourceLock) == null ? void 0 : _b.acquire());
|
|
3825
3933
|
await this._loggingService.open();
|
|
@@ -3851,18 +3959,18 @@ var ClientServicesHost = class {
|
|
|
3851
3959
|
(0, import_log15.log)("opened", {
|
|
3852
3960
|
deviceKey
|
|
3853
3961
|
}, {
|
|
3854
|
-
|
|
3855
|
-
|
|
3856
|
-
|
|
3857
|
-
|
|
3962
|
+
F: __dxlog_file14,
|
|
3963
|
+
L: 266,
|
|
3964
|
+
S: this,
|
|
3965
|
+
C: (f, a) => f(...a)
|
|
3858
3966
|
});
|
|
3859
3967
|
import_log15.log.trace("dxos.sdk.client-services-host.open", import_protocols9.trace.end({
|
|
3860
3968
|
id: traceId
|
|
3861
3969
|
}), {
|
|
3862
|
-
|
|
3863
|
-
|
|
3864
|
-
|
|
3865
|
-
|
|
3970
|
+
F: __dxlog_file14,
|
|
3971
|
+
L: 267,
|
|
3972
|
+
S: this,
|
|
3973
|
+
C: (f, a) => f(...a)
|
|
3866
3974
|
});
|
|
3867
3975
|
}
|
|
3868
3976
|
async close() {
|
|
@@ -3874,10 +3982,10 @@ var ClientServicesHost = class {
|
|
|
3874
3982
|
(0, import_log15.log)("closing...", {
|
|
3875
3983
|
deviceKey
|
|
3876
3984
|
}, {
|
|
3877
|
-
|
|
3878
|
-
|
|
3879
|
-
|
|
3880
|
-
|
|
3985
|
+
F: __dxlog_file14,
|
|
3986
|
+
L: 277,
|
|
3987
|
+
S: this,
|
|
3988
|
+
C: (f, a) => f(...a)
|
|
3881
3989
|
});
|
|
3882
3990
|
this._serviceRegistry.setServices({
|
|
3883
3991
|
SystemService: this._systemService
|
|
@@ -3889,51 +3997,52 @@ var ClientServicesHost = class {
|
|
|
3889
3997
|
(0, import_log15.log)("closed", {
|
|
3890
3998
|
deviceKey
|
|
3891
3999
|
}, {
|
|
3892
|
-
|
|
3893
|
-
|
|
3894
|
-
|
|
3895
|
-
|
|
4000
|
+
F: __dxlog_file14,
|
|
4001
|
+
L: 283,
|
|
4002
|
+
S: this,
|
|
4003
|
+
C: (f, a) => f(...a)
|
|
3896
4004
|
});
|
|
3897
4005
|
}
|
|
3898
4006
|
async reset() {
|
|
3899
|
-
var _a;
|
|
4007
|
+
var _a, _b, _c;
|
|
3900
4008
|
const traceId = import_keys12.PublicKey.random().toHex();
|
|
3901
4009
|
import_log15.log.trace("dxos.sdk.client-services-host.reset", import_protocols9.trace.begin({
|
|
3902
4010
|
id: traceId
|
|
3903
4011
|
}), {
|
|
3904
|
-
|
|
3905
|
-
|
|
3906
|
-
|
|
3907
|
-
|
|
4012
|
+
F: __dxlog_file14,
|
|
4013
|
+
L: 288,
|
|
4014
|
+
S: this,
|
|
4015
|
+
C: (f, a) => f(...a)
|
|
3908
4016
|
});
|
|
3909
|
-
(0, import_log15.log)("resetting...",
|
|
3910
|
-
|
|
3911
|
-
|
|
3912
|
-
|
|
3913
|
-
|
|
4017
|
+
(0, import_log15.log)("resetting...", void 0, {
|
|
4018
|
+
F: __dxlog_file14,
|
|
4019
|
+
L: 290,
|
|
4020
|
+
S: this,
|
|
4021
|
+
C: (f, a) => f(...a)
|
|
3914
4022
|
});
|
|
3915
4023
|
await ((_a = this._serviceContext) == null ? void 0 : _a.close());
|
|
3916
4024
|
await this._storage.reset();
|
|
3917
|
-
(0, import_log15.log)("reset",
|
|
3918
|
-
|
|
3919
|
-
|
|
3920
|
-
|
|
3921
|
-
|
|
4025
|
+
(0, import_log15.log)("reset", void 0, {
|
|
4026
|
+
F: __dxlog_file14,
|
|
4027
|
+
L: 293,
|
|
4028
|
+
S: this,
|
|
4029
|
+
C: (f, a) => f(...a)
|
|
3922
4030
|
});
|
|
3923
4031
|
import_log15.log.trace("dxos.sdk.client-services-host.reset", import_protocols9.trace.end({
|
|
3924
4032
|
id: traceId
|
|
3925
4033
|
}), {
|
|
3926
|
-
|
|
3927
|
-
|
|
3928
|
-
|
|
3929
|
-
|
|
4034
|
+
F: __dxlog_file14,
|
|
4035
|
+
L: 294,
|
|
4036
|
+
S: this,
|
|
4037
|
+
C: (f, a) => f(...a)
|
|
3930
4038
|
});
|
|
4039
|
+
await ((_c = (_b = this._callbacks) == null ? void 0 : _b.onReset) == null ? void 0 : _c.call(_b));
|
|
3931
4040
|
}
|
|
3932
4041
|
};
|
|
3933
|
-
|
|
4042
|
+
_ts_decorate4([
|
|
3934
4043
|
import_async17.synchronized
|
|
3935
4044
|
], ClientServicesHost.prototype, "open", null);
|
|
3936
|
-
|
|
4045
|
+
_ts_decorate4([
|
|
3937
4046
|
import_async17.synchronized
|
|
3938
4047
|
], ClientServicesHost.prototype, "close", null);
|
|
3939
4048
|
|
|
@@ -3969,7 +4078,7 @@ var performInvitation = ({ host, guest, options, hooks }) => {
|
|
|
3969
4078
|
if ((_b2 = (_a2 = hooks == null ? void 0 : hooks.guest) == null ? void 0 : _a2.onConnecting) == null ? void 0 : _b2.call(_a2, guestObservable)) {
|
|
3970
4079
|
break;
|
|
3971
4080
|
}
|
|
3972
|
-
(0,
|
|
4081
|
+
(0, import_tiny_invariant14.default)(hostInvitation.swarmKey.equals(guestInvitation.swarmKey));
|
|
3973
4082
|
break;
|
|
3974
4083
|
}
|
|
3975
4084
|
case import_services13.Invitation.State.CONNECTED: {
|
|
@@ -4110,9 +4219,9 @@ var acceptInvitation = (guest, invitation) => {
|
|
|
4110
4219
|
};
|
|
4111
4220
|
|
|
4112
4221
|
// packages/sdk/client-services/src/packlets/testing/test-builder.ts
|
|
4113
|
-
var import_client_protocol6 = require("@dxos/client-protocol");
|
|
4114
4222
|
var import_context8 = require("@dxos/context");
|
|
4115
4223
|
var import_credentials15 = require("@dxos/credentials");
|
|
4224
|
+
var import_debug8 = require("@dxos/debug");
|
|
4116
4225
|
var import_echo_pipeline5 = require("@dxos/echo-pipeline");
|
|
4117
4226
|
var import_testing = require("@dxos/echo-pipeline/testing");
|
|
4118
4227
|
var import_feed_store5 = require("@dxos/feed-store");
|
|
@@ -4136,7 +4245,7 @@ var createServiceContext = ({ signalContext = new import_messaging2.MemorySignal
|
|
|
4136
4245
|
signalManager,
|
|
4137
4246
|
transportFactory: import_network_manager3.MemoryTransportFactory
|
|
4138
4247
|
});
|
|
4139
|
-
const modelFactory =
|
|
4248
|
+
const modelFactory = createDefaultModelFactory();
|
|
4140
4249
|
return new ServiceContext(storage, networkManager, signalManager, modelFactory);
|
|
4141
4250
|
};
|
|
4142
4251
|
var createPeers = async (numPeers) => {
|
|
@@ -4179,6 +4288,9 @@ var TestPeer = class {
|
|
|
4179
4288
|
this.opts = opts;
|
|
4180
4289
|
this._props = {};
|
|
4181
4290
|
}
|
|
4291
|
+
get props() {
|
|
4292
|
+
return this._props;
|
|
4293
|
+
}
|
|
4182
4294
|
get storage() {
|
|
4183
4295
|
var _a, _b;
|
|
4184
4296
|
return (_b = (_a = this._props).storage) != null ? _b : _a.storage = (0, import_random_access_storage2.createStorage)({
|
|
@@ -4226,11 +4338,23 @@ var TestPeer = class {
|
|
|
4226
4338
|
feedStore: this.feedStore,
|
|
4227
4339
|
networkManager: this.networkManager,
|
|
4228
4340
|
metadataStore: this.metadataStore,
|
|
4229
|
-
modelFactory:
|
|
4341
|
+
modelFactory: createDefaultModelFactory(),
|
|
4230
4342
|
snapshotStore: this.snapshotStore,
|
|
4231
4343
|
blobStore: this.blobStore
|
|
4232
4344
|
});
|
|
4233
4345
|
}
|
|
4346
|
+
get identity() {
|
|
4347
|
+
var _a;
|
|
4348
|
+
return (_a = this._props.signingContext) != null ? _a : (0, import_debug8.failUndefined)();
|
|
4349
|
+
}
|
|
4350
|
+
get dataSpaceManager() {
|
|
4351
|
+
var _a, _b;
|
|
4352
|
+
return (_b = (_a = this._props).dataSpaceManager) != null ? _b : _a.dataSpaceManager = new DataSpaceManager(this.spaceManager, this.metadataStore, new import_echo_pipeline5.DataServiceSubscriptions(), this.keyring, this.identity, this.feedStore);
|
|
4353
|
+
}
|
|
4354
|
+
async createIdentity() {
|
|
4355
|
+
var _a, _b;
|
|
4356
|
+
(_b = (_a = this._props).signingContext) != null ? _b : _a.signingContext = await createSigningContext(this.keyring);
|
|
4357
|
+
}
|
|
4234
4358
|
async destroy() {
|
|
4235
4359
|
await this.storage.reset();
|
|
4236
4360
|
}
|