@dxos/client-services 0.1.53-next.db41187 → 0.1.53-next.e9dc2bc
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-3EI4PM2V.mjs} +790 -685
- package/dist/lib/browser/chunk-3EI4PM2V.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +101 -120
- package/dist/lib/browser/index.mjs.map +3 -3
- 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 +856 -772
- package/dist/lib/node/index.cjs.map +3 -3
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/packlets/testing/index.cjs +773 -654
- package/dist/lib/node/packlets/testing/index.cjs.map +3 -3
- 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/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/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/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 +2 -2
- package/dist/lib/browser/chunk-6ITWCQIT.mjs.map +0 -7
|
@@ -61,12 +61,12 @@ 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
68
|
// packages/sdk/client-services/src/packlets/services/service-context.ts
|
|
69
|
-
var
|
|
69
|
+
var import_tiny_invariant11 = __toESM(require("tiny-invariant"));
|
|
70
70
|
var import_async11 = require("@dxos/async");
|
|
71
71
|
var import_credentials14 = require("@dxos/credentials");
|
|
72
72
|
var import_debug6 = require("@dxos/debug");
|
|
@@ -85,6 +85,8 @@ var import_context = require("@dxos/context");
|
|
|
85
85
|
var import_credentials2 = require("@dxos/credentials");
|
|
86
86
|
var import_log = require("@dxos/log");
|
|
87
87
|
var import_protocols = require("@dxos/protocols");
|
|
88
|
+
var __dxlog_file = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/authenticator.ts";
|
|
89
|
+
var Credential = import_protocols.schema.getCodecForType("dxos.halo.credentials.Credential");
|
|
88
90
|
var createAuthProvider = (signer) => async (nonce) => {
|
|
89
91
|
const credential = await signer.createCredential({
|
|
90
92
|
assertion: {
|
|
@@ -93,7 +95,7 @@ var createAuthProvider = (signer) => async (nonce) => {
|
|
|
93
95
|
subject: signer.getIssuer(),
|
|
94
96
|
nonce
|
|
95
97
|
});
|
|
96
|
-
return
|
|
98
|
+
return Credential.encode(credential);
|
|
97
99
|
};
|
|
98
100
|
var TrustedKeySetAuthVerifier = class {
|
|
99
101
|
// prettier-ignore
|
|
@@ -106,24 +108,24 @@ var TrustedKeySetAuthVerifier = class {
|
|
|
106
108
|
}
|
|
107
109
|
get verifier() {
|
|
108
110
|
return async (nonce, auth) => {
|
|
109
|
-
const credential =
|
|
111
|
+
const credential = Credential.decode(auth);
|
|
110
112
|
(0, import_log.log)("authenticating...", {
|
|
111
113
|
credential
|
|
112
114
|
}, {
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
115
|
+
F: __dxlog_file,
|
|
116
|
+
L: 59,
|
|
117
|
+
S: this,
|
|
118
|
+
C: (f, a) => f(...a)
|
|
117
119
|
});
|
|
118
120
|
const result = await (0, import_credentials2.verifyCredential)(credential);
|
|
119
121
|
if (result.kind === "fail") {
|
|
120
122
|
(0, import_log.log)("Invalid credential", {
|
|
121
123
|
result
|
|
122
124
|
}, {
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
125
|
+
F: __dxlog_file,
|
|
126
|
+
L: 63,
|
|
127
|
+
S: this,
|
|
128
|
+
C: (f, a) => f(...a)
|
|
127
129
|
});
|
|
128
130
|
return false;
|
|
129
131
|
}
|
|
@@ -132,10 +134,10 @@ var TrustedKeySetAuthVerifier = class {
|
|
|
132
134
|
nonce,
|
|
133
135
|
credential
|
|
134
136
|
}, {
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
137
|
+
F: __dxlog_file,
|
|
138
|
+
L: 68,
|
|
139
|
+
S: this,
|
|
140
|
+
C: (f, a) => f(...a)
|
|
139
141
|
});
|
|
140
142
|
return false;
|
|
141
143
|
}
|
|
@@ -143,10 +145,10 @@ var TrustedKeySetAuthVerifier = class {
|
|
|
143
145
|
(0, import_log.log)("key is not currently in trusted set, waiting...", {
|
|
144
146
|
key: credential.issuer
|
|
145
147
|
}, {
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
148
|
+
F: __dxlog_file,
|
|
149
|
+
L: 73,
|
|
150
|
+
S: this,
|
|
151
|
+
C: (f, a) => f(...a)
|
|
150
152
|
});
|
|
151
153
|
return true;
|
|
152
154
|
}
|
|
@@ -159,20 +161,20 @@ var TrustedKeySetAuthVerifier = class {
|
|
|
159
161
|
(0, import_log.log)("auth success", {
|
|
160
162
|
key: credential.issuer
|
|
161
163
|
}, {
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
164
|
+
F: __dxlog_file,
|
|
165
|
+
L: 84,
|
|
166
|
+
S: this,
|
|
167
|
+
C: (f, a) => f(...a)
|
|
166
168
|
});
|
|
167
169
|
trigger.wake(true);
|
|
168
170
|
} else {
|
|
169
171
|
(0, import_log.log)("key is not currently in trusted set, waiting...", {
|
|
170
172
|
key: credential.issuer
|
|
171
173
|
}, {
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
174
|
+
F: __dxlog_file,
|
|
175
|
+
L: 87,
|
|
176
|
+
S: this,
|
|
177
|
+
C: (f, a) => f(...a)
|
|
176
178
|
});
|
|
177
179
|
}
|
|
178
180
|
});
|
|
@@ -194,7 +196,7 @@ var TrustedKeySetAuthVerifier = class {
|
|
|
194
196
|
};
|
|
195
197
|
|
|
196
198
|
// packages/sdk/client-services/src/packlets/identity/identity.ts
|
|
197
|
-
var
|
|
199
|
+
var import_tiny_invariant = __toESM(require("tiny-invariant"));
|
|
198
200
|
var import_async2 = require("@dxos/async");
|
|
199
201
|
var import_client_protocol = require("@dxos/client-protocol");
|
|
200
202
|
var import_credentials3 = require("@dxos/credentials");
|
|
@@ -202,6 +204,7 @@ var import_debug = require("@dxos/debug");
|
|
|
202
204
|
var import_feed_store = require("@dxos/feed-store");
|
|
203
205
|
var import_log2 = require("@dxos/log");
|
|
204
206
|
var import_credentials4 = require("@dxos/protocols/proto/dxos/halo/credentials");
|
|
207
|
+
var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/identity.ts";
|
|
205
208
|
var Identity = class {
|
|
206
209
|
constructor({ space, signer, identityKey, deviceKey }) {
|
|
207
210
|
this.stateUpdate = new import_async2.Event();
|
|
@@ -209,15 +212,15 @@ var Identity = class {
|
|
|
209
212
|
this._signer = signer;
|
|
210
213
|
this.identityKey = identityKey;
|
|
211
214
|
this.deviceKey = deviceKey;
|
|
212
|
-
this._deviceStateMachine =
|
|
215
|
+
this._deviceStateMachine = new import_credentials3.DeviceStateMachine({
|
|
213
216
|
identityKey: this.identityKey,
|
|
214
217
|
deviceKey: this.deviceKey,
|
|
215
218
|
onUpdate: () => this.stateUpdate.emit()
|
|
216
|
-
})
|
|
217
|
-
this._profileStateMachine =
|
|
219
|
+
});
|
|
220
|
+
this._profileStateMachine = new import_credentials3.ProfileStateMachine({
|
|
218
221
|
identityKey: this.identityKey,
|
|
219
222
|
onUpdate: () => this.stateUpdate.emit()
|
|
220
|
-
})
|
|
223
|
+
});
|
|
221
224
|
this.authVerifier = new TrustedKeySetAuthVerifier({
|
|
222
225
|
trustedKeysProvider: () => this.authorizedDeviceKeys,
|
|
223
226
|
update: this.stateUpdate,
|
|
@@ -226,27 +229,27 @@ var Identity = class {
|
|
|
226
229
|
}
|
|
227
230
|
// TODO(burdon): Expose state object?
|
|
228
231
|
get authorizedDeviceKeys() {
|
|
229
|
-
return this._deviceStateMachine.
|
|
232
|
+
return this._deviceStateMachine.authorizedDeviceKeys;
|
|
230
233
|
}
|
|
231
234
|
async open() {
|
|
232
|
-
await this.
|
|
233
|
-
await this.
|
|
235
|
+
await this.space.spaceState.addCredentialProcessor(this._deviceStateMachine);
|
|
236
|
+
await this.space.spaceState.addCredentialProcessor(this._profileStateMachine);
|
|
234
237
|
await this.space.open();
|
|
235
238
|
}
|
|
236
239
|
async close() {
|
|
237
240
|
await this.authVerifier.close();
|
|
238
|
-
await this.
|
|
239
|
-
await this.
|
|
241
|
+
await this.space.spaceState.removeCredentialProcessor(this._profileStateMachine);
|
|
242
|
+
await this.space.spaceState.removeCredentialProcessor(this._deviceStateMachine);
|
|
240
243
|
await this.space.close();
|
|
241
244
|
}
|
|
242
245
|
async ready() {
|
|
243
|
-
await this._deviceStateMachine.
|
|
246
|
+
await this._deviceStateMachine.deviceChainReady.wait();
|
|
244
247
|
await this.controlPipeline.state.waitUntilReachedTargetTimeframe({
|
|
245
248
|
timeout: import_client_protocol.LOAD_CONTROL_FEEDS_TIMEOUT
|
|
246
249
|
});
|
|
247
250
|
}
|
|
248
251
|
get profileDocument() {
|
|
249
|
-
return this._profileStateMachine.
|
|
252
|
+
return this._profileStateMachine.profile;
|
|
250
253
|
}
|
|
251
254
|
/**
|
|
252
255
|
* @test-only
|
|
@@ -261,7 +264,7 @@ var Identity = class {
|
|
|
261
264
|
return this.space.genesisFeedKey;
|
|
262
265
|
}
|
|
263
266
|
get deviceCredentialChain() {
|
|
264
|
-
return this._deviceStateMachine.
|
|
267
|
+
return this._deviceStateMachine.deviceCredentialChain;
|
|
265
268
|
}
|
|
266
269
|
getAdmissionCredentials() {
|
|
267
270
|
var _a, _b;
|
|
@@ -276,8 +279,8 @@ var Identity = class {
|
|
|
276
279
|
* Requires identity to be ready.
|
|
277
280
|
*/
|
|
278
281
|
getIdentityCredentialSigner() {
|
|
279
|
-
(0,
|
|
280
|
-
return (0, import_credentials3.createCredentialSignerWithChain)(this._signer, this._deviceStateMachine.
|
|
282
|
+
(0, import_tiny_invariant.default)(this._deviceStateMachine.deviceCredentialChain, "Device credential chain is not ready.");
|
|
283
|
+
return (0, import_credentials3.createCredentialSignerWithChain)(this._signer, this._deviceStateMachine.deviceCredentialChain, this.deviceKey);
|
|
281
284
|
}
|
|
282
285
|
/**
|
|
283
286
|
* Issues credentials as device.
|
|
@@ -293,10 +296,10 @@ var Identity = class {
|
|
|
293
296
|
controlFeedKey,
|
|
294
297
|
dataFeedKey
|
|
295
298
|
}, {
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
299
|
+
F: __dxlog_file2,
|
|
300
|
+
L: 151,
|
|
301
|
+
S: this,
|
|
302
|
+
C: (f, a) => f(...a)
|
|
300
303
|
});
|
|
301
304
|
const signer = this.getIdentityCredentialSigner();
|
|
302
305
|
await (0, import_feed_store.writeMessages)(this.controlPipeline.writer, [
|
|
@@ -337,7 +340,7 @@ var Identity = class {
|
|
|
337
340
|
};
|
|
338
341
|
|
|
339
342
|
// packages/sdk/client-services/src/packlets/identity/identity-manager.ts
|
|
340
|
-
var
|
|
343
|
+
var import_tiny_invariant2 = __toESM(require("tiny-invariant"));
|
|
341
344
|
var import_async3 = require("@dxos/async");
|
|
342
345
|
var import_credentials5 = require("@dxos/credentials");
|
|
343
346
|
var import_keys2 = require("@dxos/keys");
|
|
@@ -345,6 +348,7 @@ var import_log3 = require("@dxos/log");
|
|
|
345
348
|
var import_protocols2 = require("@dxos/protocols");
|
|
346
349
|
var import_credentials6 = require("@dxos/protocols/proto/dxos/halo/credentials");
|
|
347
350
|
var import_util = require("@dxos/util");
|
|
351
|
+
var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/identity-manager.ts";
|
|
348
352
|
var IdentityManager = class {
|
|
349
353
|
// TODO(burdon): IdentityManagerParams.
|
|
350
354
|
// TODO(dmaretskyi): Perhaps this should take/generate the peerKey outside of an initialized identity.
|
|
@@ -364,20 +368,20 @@ var IdentityManager = class {
|
|
|
364
368
|
import_log3.log.trace("dxos.halo.identity-manager.open", import_protocols2.trace.begin({
|
|
365
369
|
id: traceId
|
|
366
370
|
}), {
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
+
F: __dxlog_file3,
|
|
372
|
+
L: 70,
|
|
373
|
+
S: this,
|
|
374
|
+
C: (f, a) => f(...a)
|
|
371
375
|
});
|
|
372
376
|
await this._metadataStore.load();
|
|
373
377
|
const identityRecord = this._metadataStore.getIdentityRecord();
|
|
374
378
|
(0, import_log3.log)("identity record", {
|
|
375
379
|
identityRecord
|
|
376
380
|
}, {
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
+
F: __dxlog_file3,
|
|
382
|
+
L: 74,
|
|
383
|
+
S: this,
|
|
384
|
+
C: (f, a) => f(...a)
|
|
381
385
|
});
|
|
382
386
|
if (identityRecord) {
|
|
383
387
|
this._identity = await this._constructIdentity(identityRecord);
|
|
@@ -387,20 +391,20 @@ var IdentityManager = class {
|
|
|
387
391
|
identityKey: identityRecord.identityKey,
|
|
388
392
|
displayName: (_a = this._identity.profileDocument) == null ? void 0 : _a.displayName
|
|
389
393
|
}, {
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
+
F: __dxlog_file3,
|
|
395
|
+
L: 79,
|
|
396
|
+
S: this,
|
|
397
|
+
C: (f, a) => f(...a)
|
|
394
398
|
});
|
|
395
399
|
this.stateUpdate.emit();
|
|
396
400
|
}
|
|
397
401
|
import_log3.log.trace("dxos.halo.identity-manager.open", import_protocols2.trace.end({
|
|
398
402
|
id: traceId
|
|
399
403
|
}), {
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
+
F: __dxlog_file3,
|
|
405
|
+
L: 85,
|
|
406
|
+
S: this,
|
|
407
|
+
C: (f, a) => f(...a)
|
|
404
408
|
});
|
|
405
409
|
}
|
|
406
410
|
async close() {
|
|
@@ -409,12 +413,12 @@ var IdentityManager = class {
|
|
|
409
413
|
}
|
|
410
414
|
async createIdentity({ displayName } = {}) {
|
|
411
415
|
var _a;
|
|
412
|
-
(0,
|
|
413
|
-
(0, import_log3.log)("creating identity...",
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
416
|
+
(0, import_tiny_invariant2.default)(!this._identity, "Identity already exists.");
|
|
417
|
+
(0, import_log3.log)("creating identity...", void 0, {
|
|
418
|
+
F: __dxlog_file3,
|
|
419
|
+
L: 94,
|
|
420
|
+
S: this,
|
|
421
|
+
C: (f, a) => f(...a)
|
|
418
422
|
});
|
|
419
423
|
const controlFeedKey = await this._keyring.createKey();
|
|
420
424
|
const identityRecord = {
|
|
@@ -431,8 +435,8 @@ var IdentityManager = class {
|
|
|
431
435
|
await identity.open();
|
|
432
436
|
{
|
|
433
437
|
const generator = new import_credentials5.CredentialGenerator(this._keyring, identityRecord.identityKey, identityRecord.deviceKey);
|
|
434
|
-
(0,
|
|
435
|
-
(0,
|
|
438
|
+
(0, import_tiny_invariant2.default)(identityRecord.haloSpace.genesisFeedKey, "Genesis feed key is required.");
|
|
439
|
+
(0, import_tiny_invariant2.default)(identityRecord.haloSpace.dataFeedKey, "Data feed key is required.");
|
|
436
440
|
const credentials = [
|
|
437
441
|
// Space genesis.
|
|
438
442
|
...await generator.createSpaceGenesis(identityRecord.haloSpace.key, identityRecord.haloSpace.genesisFeedKey),
|
|
@@ -460,20 +464,20 @@ var IdentityManager = class {
|
|
|
460
464
|
identityKey: identityRecord.identityKey,
|
|
461
465
|
displayName: (_a = this._identity.profileDocument) == null ? void 0 : _a.displayName
|
|
462
466
|
}, {
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
+
F: __dxlog_file3,
|
|
468
|
+
L: 149,
|
|
469
|
+
S: this,
|
|
470
|
+
C: (f, a) => f(...a)
|
|
467
471
|
});
|
|
468
472
|
this.stateUpdate.emit();
|
|
469
473
|
(0, import_log3.log)("created identity", {
|
|
470
474
|
identityKey: identity.identityKey,
|
|
471
475
|
deviceKey: identity.deviceKey
|
|
472
476
|
}, {
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
+
F: __dxlog_file3,
|
|
478
|
+
L: 155,
|
|
479
|
+
S: this,
|
|
480
|
+
C: (f, a) => f(...a)
|
|
477
481
|
});
|
|
478
482
|
return identity;
|
|
479
483
|
}
|
|
@@ -485,12 +489,12 @@ var IdentityManager = class {
|
|
|
485
489
|
(0, import_log3.log)("accepting identity", {
|
|
486
490
|
params
|
|
487
491
|
}, {
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
+
F: __dxlog_file3,
|
|
493
|
+
L: 163,
|
|
494
|
+
S: this,
|
|
495
|
+
C: (f, a) => f(...a)
|
|
492
496
|
});
|
|
493
|
-
(0,
|
|
497
|
+
(0, import_tiny_invariant2.default)(!this._identity, "Identity already exists.");
|
|
494
498
|
const identityRecord = {
|
|
495
499
|
identityKey: params.identityKey,
|
|
496
500
|
deviceKey: params.deviceKey,
|
|
@@ -511,38 +515,38 @@ var IdentityManager = class {
|
|
|
511
515
|
identityKey: identityRecord.identityKey,
|
|
512
516
|
displayName: (_a = this._identity.profileDocument) == null ? void 0 : _a.displayName
|
|
513
517
|
}, {
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
+
F: __dxlog_file3,
|
|
519
|
+
L: 183,
|
|
520
|
+
S: this,
|
|
521
|
+
C: (f, a) => f(...a)
|
|
518
522
|
});
|
|
519
523
|
this.stateUpdate.emit();
|
|
520
524
|
(0, import_log3.log)("accepted identity", {
|
|
521
525
|
identityKey: identity.identityKey,
|
|
522
526
|
deviceKey: identity.deviceKey
|
|
523
527
|
}, {
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
+
F: __dxlog_file3,
|
|
529
|
+
L: 189,
|
|
530
|
+
S: this,
|
|
531
|
+
C: (f, a) => f(...a)
|
|
528
532
|
});
|
|
529
533
|
return identity;
|
|
530
534
|
}
|
|
531
535
|
async _constructIdentity(identityRecord) {
|
|
532
|
-
(0,
|
|
536
|
+
(0, import_tiny_invariant2.default)(!this._identity);
|
|
533
537
|
(0, import_log3.log)("constructing identity", {
|
|
534
538
|
identityRecord
|
|
535
539
|
}, {
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
+
F: __dxlog_file3,
|
|
541
|
+
L: 195,
|
|
542
|
+
S: this,
|
|
543
|
+
C: (f, a) => f(...a)
|
|
540
544
|
});
|
|
541
|
-
(0,
|
|
545
|
+
(0, import_tiny_invariant2.default)(identityRecord.haloSpace.controlFeedKey);
|
|
542
546
|
const controlFeed = await this._feedStore.openFeed(identityRecord.haloSpace.controlFeedKey, {
|
|
543
547
|
writable: true
|
|
544
548
|
});
|
|
545
|
-
(0,
|
|
549
|
+
(0, import_tiny_invariant2.default)(identityRecord.haloSpace.dataFeedKey);
|
|
546
550
|
const dataFeed = await this._feedStore.openFeed(identityRecord.haloSpace.dataFeedKey, {
|
|
547
551
|
writable: true,
|
|
548
552
|
sparse: true
|
|
@@ -567,10 +571,10 @@ var IdentityManager = class {
|
|
|
567
571
|
(0, import_log3.log)("done", {
|
|
568
572
|
identityKey: identityRecord.identityKey
|
|
569
573
|
}, {
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
+
F: __dxlog_file3,
|
|
575
|
+
L: 226,
|
|
576
|
+
S: this,
|
|
577
|
+
C: (f, a) => f(...a)
|
|
574
578
|
});
|
|
575
579
|
if (identityRecord.haloSpace.controlTimeframe) {
|
|
576
580
|
identity.controlPipeline.state.setTargetTimeframe(identityRecord.haloSpace.controlTimeframe);
|
|
@@ -587,11 +591,11 @@ var IdentityManager = class {
|
|
|
587
591
|
onNetworkConnection: () => {
|
|
588
592
|
},
|
|
589
593
|
onAuthFailure: () => {
|
|
590
|
-
import_log3.log.warn("auth failure",
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
594
|
+
import_log3.log.warn("auth failure", void 0, {
|
|
595
|
+
F: __dxlog_file3,
|
|
596
|
+
L: 245,
|
|
597
|
+
S: this,
|
|
598
|
+
C: (f, a) => f(...a)
|
|
595
599
|
});
|
|
596
600
|
},
|
|
597
601
|
memberKey: identityKey
|
|
@@ -600,7 +604,7 @@ var IdentityManager = class {
|
|
|
600
604
|
};
|
|
601
605
|
|
|
602
606
|
// packages/sdk/client-services/src/packlets/identity/identity-service.ts
|
|
603
|
-
var
|
|
607
|
+
var import_tiny_invariant3 = __toESM(require("tiny-invariant"));
|
|
604
608
|
var import_codec_protobuf = require("@dxos/codec-protobuf");
|
|
605
609
|
var import_credentials7 = require("@dxos/credentials");
|
|
606
610
|
var import_debug2 = require("@dxos/debug");
|
|
@@ -636,7 +640,7 @@ var IdentityServiceImpl = class {
|
|
|
636
640
|
};
|
|
637
641
|
}
|
|
638
642
|
async signPresentation({ presentation, nonce }) {
|
|
639
|
-
(0,
|
|
643
|
+
(0, import_tiny_invariant3.default)(this._serviceContext.identityManager.identity, "Identity not initialized.");
|
|
640
644
|
return await (0, import_credentials7.signPresentation)({
|
|
641
645
|
presentation,
|
|
642
646
|
signer: this._serviceContext.keyring,
|
|
@@ -648,7 +652,7 @@ var IdentityServiceImpl = class {
|
|
|
648
652
|
};
|
|
649
653
|
|
|
650
654
|
// packages/sdk/client-services/src/packlets/invitations/device-invitation-protocol.ts
|
|
651
|
-
var
|
|
655
|
+
var import_tiny_invariant4 = __toESM(require("tiny-invariant"));
|
|
652
656
|
var import_services = require("@dxos/protocols/proto/dxos/client/services");
|
|
653
657
|
var DeviceInvitationProtocol = class {
|
|
654
658
|
constructor(_keyring, _getIdentity, _acceptIdentity) {
|
|
@@ -665,7 +669,7 @@ var DeviceInvitationProtocol = class {
|
|
|
665
669
|
};
|
|
666
670
|
}
|
|
667
671
|
async admit(request) {
|
|
668
|
-
(0,
|
|
672
|
+
(0, import_tiny_invariant4.default)(request.device);
|
|
669
673
|
const identity = this._getIdentity();
|
|
670
674
|
await identity.admitDevice(request.device);
|
|
671
675
|
return {
|
|
@@ -693,9 +697,9 @@ var DeviceInvitationProtocol = class {
|
|
|
693
697
|
};
|
|
694
698
|
}
|
|
695
699
|
async accept(response, request) {
|
|
696
|
-
(0,
|
|
700
|
+
(0, import_tiny_invariant4.default)(response.device);
|
|
697
701
|
const { identityKey, haloSpaceKey, genesisFeedKey, controlTimeframe } = response.device;
|
|
698
|
-
(0,
|
|
702
|
+
(0, import_tiny_invariant4.default)(request.device);
|
|
699
703
|
const { deviceKey, controlFeedKey, dataFeedKey } = request.device;
|
|
700
704
|
await this._acceptIdentity({
|
|
701
705
|
identityKey,
|
|
@@ -713,7 +717,7 @@ var DeviceInvitationProtocol = class {
|
|
|
713
717
|
};
|
|
714
718
|
|
|
715
719
|
// packages/sdk/client-services/src/packlets/invitations/invitations-handler.ts
|
|
716
|
-
var
|
|
720
|
+
var import_tiny_invariant6 = __toESM(require("tiny-invariant"));
|
|
717
721
|
var import_async5 = require("@dxos/async");
|
|
718
722
|
var import_client_protocol2 = require("@dxos/client-protocol");
|
|
719
723
|
var import_context3 = require("@dxos/context");
|
|
@@ -727,7 +731,7 @@ var import_services3 = require("@dxos/protocols/proto/dxos/client/services");
|
|
|
727
731
|
var import_invitations2 = require("@dxos/protocols/proto/dxos/halo/invitations");
|
|
728
732
|
|
|
729
733
|
// packages/sdk/client-services/src/packlets/invitations/invitation-extension.ts
|
|
730
|
-
var
|
|
734
|
+
var import_tiny_invariant5 = __toESM(require("tiny-invariant"));
|
|
731
735
|
var import_async4 = require("@dxos/async");
|
|
732
736
|
var import_context2 = require("@dxos/context");
|
|
733
737
|
var import_errors = require("@dxos/errors");
|
|
@@ -737,6 +741,7 @@ var import_protocols3 = require("@dxos/protocols");
|
|
|
737
741
|
var import_services2 = require("@dxos/protocols/proto/dxos/client/services");
|
|
738
742
|
var import_invitations = require("@dxos/protocols/proto/dxos/halo/invitations");
|
|
739
743
|
var import_teleport = require("@dxos/teleport");
|
|
744
|
+
var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitation-extension.ts";
|
|
740
745
|
var OPTIONS_TIMEOUT = 1e4;
|
|
741
746
|
var MAX_OTP_ATTEMPTS = 3;
|
|
742
747
|
var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
@@ -764,7 +769,7 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
764
769
|
// Perhaps in the future we will have more complex logic here.
|
|
765
770
|
InvitationHostService: {
|
|
766
771
|
options: async (options) => {
|
|
767
|
-
(0,
|
|
772
|
+
(0, import_tiny_invariant5.default)(!this._remoteOptions, "Remote options already set.");
|
|
768
773
|
this._remoteOptions = options;
|
|
769
774
|
this._remoteOptionsTrigger.wake();
|
|
770
775
|
},
|
|
@@ -774,20 +779,20 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
774
779
|
import_log4.log.trace("dxos.sdk.invitation-handler.host.introduce", import_protocols3.trace.begin({
|
|
775
780
|
id: traceId
|
|
776
781
|
}), {
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
782
|
+
F: __dxlog_file4,
|
|
783
|
+
L: 98,
|
|
784
|
+
S: this,
|
|
785
|
+
C: (f, a) => f(...a)
|
|
781
786
|
});
|
|
782
787
|
const invitation = await this._callbacks.resolveInvitation(request);
|
|
783
788
|
if (!invitation) {
|
|
784
789
|
import_log4.log.warn("invitation not found", {
|
|
785
790
|
invitationId
|
|
786
791
|
}, {
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
792
|
+
F: __dxlog_file4,
|
|
793
|
+
L: 102,
|
|
794
|
+
S: this,
|
|
795
|
+
C: (f, a) => f(...a)
|
|
791
796
|
});
|
|
792
797
|
this._callbacks.onError(new Error("Invitation not found."));
|
|
793
798
|
return {
|
|
@@ -798,10 +803,10 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
798
803
|
(0, import_log4.log)("guest introduced itself", {
|
|
799
804
|
guestProfile: profile
|
|
800
805
|
}, {
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
806
|
+
F: __dxlog_file4,
|
|
807
|
+
L: 111,
|
|
808
|
+
S: this,
|
|
809
|
+
C: (f, a) => f(...a)
|
|
805
810
|
});
|
|
806
811
|
this.guestProfile = profile;
|
|
807
812
|
this._callbacks.onStateUpdate({
|
|
@@ -811,10 +816,10 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
811
816
|
import_log4.log.trace("dxos.sdk.invitation-handler.host.introduce", import_protocols3.trace.end({
|
|
812
817
|
id: traceId
|
|
813
818
|
}), {
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
819
|
+
F: __dxlog_file4,
|
|
820
|
+
L: 118,
|
|
821
|
+
S: this,
|
|
822
|
+
C: (f, a) => f(...a)
|
|
818
823
|
});
|
|
819
824
|
return {
|
|
820
825
|
spaceKey: this.invitation.authMethod === import_services2.Invitation.AuthMethod.NONE ? this.invitation.spaceKey : void 0,
|
|
@@ -826,28 +831,28 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
826
831
|
import_log4.log.trace("dxos.sdk.invitation-handler.host.authenticate", import_protocols3.trace.begin({
|
|
827
832
|
id: traceId
|
|
828
833
|
}), {
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
834
|
+
F: __dxlog_file4,
|
|
835
|
+
L: 127,
|
|
836
|
+
S: this,
|
|
837
|
+
C: (f, a) => f(...a)
|
|
833
838
|
});
|
|
834
839
|
(0, import_log4.log)("received authentication request", {
|
|
835
840
|
authCode: code
|
|
836
841
|
}, {
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
842
|
+
F: __dxlog_file4,
|
|
843
|
+
L: 128,
|
|
844
|
+
S: this,
|
|
845
|
+
C: (f, a) => f(...a)
|
|
841
846
|
});
|
|
842
847
|
let status = import_invitations.AuthenticationResponse.Status.OK;
|
|
843
|
-
(0,
|
|
848
|
+
(0, import_tiny_invariant5.default)(this.invitation, "Invitation is not set.");
|
|
844
849
|
switch (this.invitation.authMethod) {
|
|
845
850
|
case import_services2.Invitation.AuthMethod.NONE: {
|
|
846
|
-
(0, import_log4.log)("authentication not required",
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
+
(0, import_log4.log)("authentication not required", void 0, {
|
|
852
|
+
F: __dxlog_file4,
|
|
853
|
+
L: 134,
|
|
854
|
+
S: this,
|
|
855
|
+
C: (f, a) => f(...a)
|
|
851
856
|
});
|
|
852
857
|
return {
|
|
853
858
|
status: import_invitations.AuthenticationResponse.Status.OK
|
|
@@ -869,10 +874,10 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
869
874
|
import_log4.log.error("invalid authentication method", {
|
|
870
875
|
authMethod: this.invitation.authMethod
|
|
871
876
|
}, {
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
877
|
+
F: __dxlog_file4,
|
|
878
|
+
L: 152,
|
|
879
|
+
S: this,
|
|
880
|
+
C: (f, a) => f(...a)
|
|
876
881
|
});
|
|
877
882
|
status = import_invitations.AuthenticationResponse.Status.INTERNAL_ERROR;
|
|
878
883
|
break;
|
|
@@ -884,10 +889,10 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
884
889
|
status
|
|
885
890
|
}
|
|
886
891
|
}), {
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
892
|
+
F: __dxlog_file4,
|
|
893
|
+
L: 158,
|
|
894
|
+
S: this,
|
|
895
|
+
C: (f, a) => f(...a)
|
|
891
896
|
});
|
|
892
897
|
return {
|
|
893
898
|
status
|
|
@@ -898,13 +903,13 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
898
903
|
import_log4.log.trace("dxos.sdk.invitation-handler.host.admit", import_protocols3.trace.begin({
|
|
899
904
|
id: traceId
|
|
900
905
|
}), {
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
906
|
+
F: __dxlog_file4,
|
|
907
|
+
L: 164,
|
|
908
|
+
S: this,
|
|
909
|
+
C: (f, a) => f(...a)
|
|
905
910
|
});
|
|
906
911
|
try {
|
|
907
|
-
(0,
|
|
912
|
+
(0, import_tiny_invariant5.default)(this.invitation, "Invitation is not set.");
|
|
908
913
|
if (isAuthenticationRequired(this.invitation) && !this.authenticationPassed) {
|
|
909
914
|
throw new Error("Not authenticated");
|
|
910
915
|
}
|
|
@@ -912,10 +917,10 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
912
917
|
import_log4.log.trace("dxos.sdk.invitation-handler.host.admit", import_protocols3.trace.end({
|
|
913
918
|
id: traceId
|
|
914
919
|
}), {
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
920
|
+
F: __dxlog_file4,
|
|
921
|
+
L: 175,
|
|
922
|
+
S: this,
|
|
923
|
+
C: (f, a) => f(...a)
|
|
919
924
|
});
|
|
920
925
|
return response;
|
|
921
926
|
} catch (err) {
|
|
@@ -969,7 +974,7 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
|
|
|
969
974
|
return {
|
|
970
975
|
InvitationHostService: {
|
|
971
976
|
options: async (options) => {
|
|
972
|
-
(0,
|
|
977
|
+
(0, import_tiny_invariant5.default)(!this._remoteOptions, "Remote options already set.");
|
|
973
978
|
this._remoteOptions = options;
|
|
974
979
|
this._remoteOptionsTrigger.wake();
|
|
975
980
|
},
|
|
@@ -989,11 +994,11 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
|
|
|
989
994
|
var _a;
|
|
990
995
|
await super.onOpen(context);
|
|
991
996
|
try {
|
|
992
|
-
(0, import_log4.log)("begin options",
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
+
(0, import_log4.log)("begin options", void 0, {
|
|
998
|
+
F: __dxlog_file4,
|
|
999
|
+
L: 263,
|
|
1000
|
+
S: this,
|
|
1001
|
+
C: (f, a) => f(...a)
|
|
997
1002
|
});
|
|
998
1003
|
await (0, import_context2.cancelWithContext)(this._ctx, this.rpc.InvitationHostService.options({
|
|
999
1004
|
role: import_invitations.Options.Role.GUEST
|
|
@@ -1001,11 +1006,11 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
|
|
|
1001
1006
|
await (0, import_context2.cancelWithContext)(this._ctx, this._remoteOptionsTrigger.wait({
|
|
1002
1007
|
timeout: OPTIONS_TIMEOUT
|
|
1003
1008
|
}));
|
|
1004
|
-
(0, import_log4.log)("end options",
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
+
(0, import_log4.log)("end options", void 0, {
|
|
1010
|
+
F: __dxlog_file4,
|
|
1011
|
+
L: 266,
|
|
1012
|
+
S: this,
|
|
1013
|
+
C: (f, a) => f(...a)
|
|
1009
1014
|
});
|
|
1010
1015
|
if (((_a = this._remoteOptions) == null ? void 0 : _a.role) !== import_invitations.Options.Role.HOST) {
|
|
1011
1016
|
throw new import_errors.InvalidInvitationExtensionRoleError(void 0, {
|
|
@@ -1016,20 +1021,20 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
|
|
|
1016
1021
|
this._callbacks.onOpen(this._ctx);
|
|
1017
1022
|
} catch (err) {
|
|
1018
1023
|
(0, import_log4.log)("openError", err, {
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1024
|
+
F: __dxlog_file4,
|
|
1025
|
+
L: 276,
|
|
1026
|
+
S: this,
|
|
1027
|
+
C: (f, a) => f(...a)
|
|
1023
1028
|
});
|
|
1024
1029
|
this._callbacks.onError(err);
|
|
1025
1030
|
}
|
|
1026
1031
|
}
|
|
1027
1032
|
async onClose() {
|
|
1028
|
-
(0, import_log4.log)("onClose",
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
+
(0, import_log4.log)("onClose", void 0, {
|
|
1034
|
+
F: __dxlog_file4,
|
|
1035
|
+
L: 282,
|
|
1036
|
+
S: this,
|
|
1037
|
+
C: (f, a) => f(...a)
|
|
1033
1038
|
});
|
|
1034
1039
|
await this._ctx.dispose();
|
|
1035
1040
|
}
|
|
@@ -1037,6 +1042,7 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
|
|
|
1037
1042
|
var isAuthenticationRequired = (invitation) => invitation.authMethod !== import_services2.Invitation.AuthMethod.NONE;
|
|
1038
1043
|
|
|
1039
1044
|
// packages/sdk/client-services/src/packlets/invitations/invitations-handler.ts
|
|
1045
|
+
var __dxlog_file5 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitations-handler.ts";
|
|
1040
1046
|
var InvitationsHandler = class {
|
|
1041
1047
|
/**
|
|
1042
1048
|
* @internal
|
|
@@ -1048,7 +1054,7 @@ var InvitationsHandler = class {
|
|
|
1048
1054
|
var _a;
|
|
1049
1055
|
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
1056
|
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,
|
|
1057
|
+
(0, import_tiny_invariant6.default)(protocol);
|
|
1052
1058
|
const invitation = {
|
|
1053
1059
|
invitationId,
|
|
1054
1060
|
type,
|
|
@@ -1070,10 +1076,10 @@ var InvitationsHandler = class {
|
|
|
1070
1076
|
(0, import_log5.log)("complete", {
|
|
1071
1077
|
...protocol.toJSON()
|
|
1072
1078
|
}, {
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1079
|
+
F: __dxlog_file5,
|
|
1080
|
+
L: 99,
|
|
1081
|
+
S: this,
|
|
1082
|
+
C: (f, a) => f(...a)
|
|
1077
1083
|
});
|
|
1078
1084
|
stream.complete();
|
|
1079
1085
|
});
|
|
@@ -1095,7 +1101,7 @@ var InvitationsHandler = class {
|
|
|
1095
1101
|
var _a2, _b, _c;
|
|
1096
1102
|
try {
|
|
1097
1103
|
const deviceKey = (_c = (_a2 = admissionRequest.device) == null ? void 0 : _a2.deviceKey) != null ? _c : (_b = admissionRequest.space) == null ? void 0 : _b.deviceKey;
|
|
1098
|
-
(0,
|
|
1104
|
+
(0, import_tiny_invariant6.default)(deviceKey);
|
|
1099
1105
|
const admissionResponse = await protocol.admit(admissionRequest, extension.guestProfile);
|
|
1100
1106
|
extension.completedTrigger.wake(deviceKey);
|
|
1101
1107
|
return admissionResponse;
|
|
@@ -1111,18 +1117,18 @@ var InvitationsHandler = class {
|
|
|
1111
1117
|
import_log5.log.trace("dxos.sdk.invitations-handler.host.onOpen", import_protocols4.trace.begin({
|
|
1112
1118
|
id: traceId
|
|
1113
1119
|
}), {
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1120
|
+
F: __dxlog_file5,
|
|
1121
|
+
L: 138,
|
|
1122
|
+
S: this,
|
|
1123
|
+
C: (f, a) => f(...a)
|
|
1118
1124
|
});
|
|
1119
1125
|
(0, import_log5.log)("connected", {
|
|
1120
1126
|
...protocol.toJSON()
|
|
1121
1127
|
}, {
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1128
|
+
F: __dxlog_file5,
|
|
1129
|
+
L: 139,
|
|
1130
|
+
S: this,
|
|
1131
|
+
C: (f, a) => f(...a)
|
|
1126
1132
|
});
|
|
1127
1133
|
stream.next({
|
|
1128
1134
|
...invitation,
|
|
@@ -1135,10 +1141,10 @@ var InvitationsHandler = class {
|
|
|
1135
1141
|
guest: deviceKey,
|
|
1136
1142
|
...protocol.toJSON()
|
|
1137
1143
|
}, {
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1144
|
+
F: __dxlog_file5,
|
|
1145
|
+
L: 142,
|
|
1146
|
+
S: this,
|
|
1147
|
+
C: (f, a) => f(...a)
|
|
1142
1148
|
});
|
|
1143
1149
|
stream.next({
|
|
1144
1150
|
...invitation,
|
|
@@ -1147,20 +1153,20 @@ var InvitationsHandler = class {
|
|
|
1147
1153
|
import_log5.log.trace("dxos.sdk.invitations-handler.host.onOpen", import_protocols4.trace.end({
|
|
1148
1154
|
id: traceId
|
|
1149
1155
|
}), {
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1156
|
+
F: __dxlog_file5,
|
|
1157
|
+
L: 144,
|
|
1158
|
+
S: this,
|
|
1159
|
+
C: (f, a) => f(...a)
|
|
1154
1160
|
});
|
|
1155
1161
|
} catch (err) {
|
|
1156
1162
|
if (err instanceof import_async5.TimeoutError) {
|
|
1157
1163
|
(0, import_log5.log)("timeout", {
|
|
1158
1164
|
...protocol.toJSON()
|
|
1159
1165
|
}, {
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1166
|
+
F: __dxlog_file5,
|
|
1167
|
+
L: 147,
|
|
1168
|
+
S: this,
|
|
1169
|
+
C: (f, a) => f(...a)
|
|
1164
1170
|
});
|
|
1165
1171
|
stream.next({
|
|
1166
1172
|
...invitation,
|
|
@@ -1168,10 +1174,10 @@ var InvitationsHandler = class {
|
|
|
1168
1174
|
});
|
|
1169
1175
|
} else {
|
|
1170
1176
|
import_log5.log.error("failed", err, {
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1177
|
+
F: __dxlog_file5,
|
|
1178
|
+
L: 150,
|
|
1179
|
+
S: this,
|
|
1180
|
+
C: (f, a) => f(...a)
|
|
1175
1181
|
});
|
|
1176
1182
|
stream.error(err);
|
|
1177
1183
|
}
|
|
@@ -1179,10 +1185,10 @@ var InvitationsHandler = class {
|
|
|
1179
1185
|
id: traceId,
|
|
1180
1186
|
error: err
|
|
1181
1187
|
}), {
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1188
|
+
F: __dxlog_file5,
|
|
1189
|
+
L: 153,
|
|
1190
|
+
S: this,
|
|
1191
|
+
C: (f, a) => f(...a)
|
|
1186
1192
|
});
|
|
1187
1193
|
} finally {
|
|
1188
1194
|
if (type !== import_services3.Invitation.Type.MULTIUSE) {
|
|
@@ -1200,10 +1206,10 @@ var InvitationsHandler = class {
|
|
|
1200
1206
|
(0, import_log5.log)("timeout", {
|
|
1201
1207
|
...protocol.toJSON()
|
|
1202
1208
|
}, {
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1209
|
+
F: __dxlog_file5,
|
|
1210
|
+
L: 168,
|
|
1211
|
+
S: this,
|
|
1212
|
+
C: (f, a) => f(...a)
|
|
1207
1213
|
});
|
|
1208
1214
|
stream.next({
|
|
1209
1215
|
...invitation,
|
|
@@ -1211,10 +1217,10 @@ var InvitationsHandler = class {
|
|
|
1211
1217
|
});
|
|
1212
1218
|
} else {
|
|
1213
1219
|
import_log5.log.error("failed", err, {
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1220
|
+
F: __dxlog_file5,
|
|
1221
|
+
L: 171,
|
|
1222
|
+
S: this,
|
|
1223
|
+
C: (f, a) => f(...a)
|
|
1218
1224
|
});
|
|
1219
1225
|
stream.error(err);
|
|
1220
1226
|
}
|
|
@@ -1254,13 +1260,13 @@ var InvitationsHandler = class {
|
|
|
1254
1260
|
}
|
|
1255
1261
|
acceptInvitation(protocol, invitation) {
|
|
1256
1262
|
const { timeout = import_client_protocol2.INVITATION_TIMEOUT } = invitation;
|
|
1257
|
-
(0,
|
|
1263
|
+
(0, import_tiny_invariant6.default)(protocol);
|
|
1258
1264
|
const authenticated = new import_async5.Trigger();
|
|
1259
1265
|
let admitted = false;
|
|
1260
1266
|
let currentState;
|
|
1261
1267
|
const stream = new import_async5.PushStream();
|
|
1262
1268
|
const setState = (newData) => {
|
|
1263
|
-
(0,
|
|
1269
|
+
(0, import_tiny_invariant6.default)(newData.state !== void 0);
|
|
1264
1270
|
currentState = newData.state;
|
|
1265
1271
|
stream.next({
|
|
1266
1272
|
...invitation,
|
|
@@ -1273,20 +1279,20 @@ var InvitationsHandler = class {
|
|
|
1273
1279
|
(0, import_log5.log)("timeout", {
|
|
1274
1280
|
...protocol.toJSON()
|
|
1275
1281
|
}, {
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1282
|
+
F: __dxlog_file5,
|
|
1283
|
+
L: 230,
|
|
1284
|
+
S: this,
|
|
1285
|
+
C: (f, a) => f(...a)
|
|
1280
1286
|
});
|
|
1281
1287
|
setState({
|
|
1282
1288
|
state: import_services3.Invitation.State.TIMEOUT
|
|
1283
1289
|
});
|
|
1284
1290
|
} else {
|
|
1285
1291
|
import_log5.log.warn("auth failed", err, {
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1292
|
+
F: __dxlog_file5,
|
|
1293
|
+
L: 233,
|
|
1294
|
+
S: this,
|
|
1295
|
+
C: (f, a) => f(...a)
|
|
1290
1296
|
});
|
|
1291
1297
|
stream.error(err);
|
|
1292
1298
|
}
|
|
@@ -1297,10 +1303,10 @@ var InvitationsHandler = class {
|
|
|
1297
1303
|
(0, import_log5.log)("complete", {
|
|
1298
1304
|
...protocol.toJSON()
|
|
1299
1305
|
}, {
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1306
|
+
F: __dxlog_file5,
|
|
1307
|
+
L: 241,
|
|
1308
|
+
S: this,
|
|
1309
|
+
C: (f, a) => f(...a)
|
|
1304
1310
|
});
|
|
1305
1311
|
stream.complete();
|
|
1306
1312
|
});
|
|
@@ -1312,10 +1318,10 @@ var InvitationsHandler = class {
|
|
|
1312
1318
|
(0, import_log5.log)("extension disposed", {
|
|
1313
1319
|
currentState
|
|
1314
1320
|
}, {
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1321
|
+
F: __dxlog_file5,
|
|
1322
|
+
L: 251,
|
|
1323
|
+
S: this,
|
|
1324
|
+
C: (f, a) => f(...a)
|
|
1319
1325
|
});
|
|
1320
1326
|
if (!admitted) {
|
|
1321
1327
|
stream.error(new Error("Remote peer disconnected."));
|
|
@@ -1327,10 +1333,10 @@ var InvitationsHandler = class {
|
|
|
1327
1333
|
import_log5.log.trace("dxos.sdk.invitations-handler.guest.onOpen", import_protocols4.trace.begin({
|
|
1328
1334
|
id: traceId
|
|
1329
1335
|
}), {
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1336
|
+
F: __dxlog_file5,
|
|
1337
|
+
L: 260,
|
|
1338
|
+
S: this,
|
|
1339
|
+
C: (f, a) => f(...a)
|
|
1334
1340
|
});
|
|
1335
1341
|
if (++connectionCount > 1) {
|
|
1336
1342
|
throw new Error(`multiple connections detected: ${connectionCount}`);
|
|
@@ -1339,10 +1345,10 @@ var InvitationsHandler = class {
|
|
|
1339
1345
|
(0, import_log5.log)("connected", {
|
|
1340
1346
|
...protocol.toJSON()
|
|
1341
1347
|
}, {
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1348
|
+
F: __dxlog_file5,
|
|
1349
|
+
L: 268,
|
|
1350
|
+
S: this,
|
|
1351
|
+
C: (f, a) => f(...a)
|
|
1346
1352
|
});
|
|
1347
1353
|
setState({
|
|
1348
1354
|
state: import_services3.Invitation.State.CONNECTED
|
|
@@ -1350,20 +1356,20 @@ var InvitationsHandler = class {
|
|
|
1350
1356
|
(0, import_log5.log)("introduce", {
|
|
1351
1357
|
...protocol.toJSON()
|
|
1352
1358
|
}, {
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1359
|
+
F: __dxlog_file5,
|
|
1360
|
+
L: 272,
|
|
1361
|
+
S: this,
|
|
1362
|
+
C: (f, a) => f(...a)
|
|
1357
1363
|
});
|
|
1358
1364
|
const introductionResponse = await extension.rpc.InvitationHostService.introduce(protocol.createIntroduction());
|
|
1359
1365
|
(0, import_log5.log)("introduce response", {
|
|
1360
1366
|
...protocol.toJSON(),
|
|
1361
1367
|
response: introductionResponse
|
|
1362
1368
|
}, {
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1369
|
+
F: __dxlog_file5,
|
|
1370
|
+
L: 276,
|
|
1371
|
+
S: this,
|
|
1372
|
+
C: (f, a) => f(...a)
|
|
1367
1373
|
});
|
|
1368
1374
|
invitation.authMethod = introductionResponse.authMethod;
|
|
1369
1375
|
if (introductionResponse.spaceKey) {
|
|
@@ -1371,11 +1377,11 @@ var InvitationsHandler = class {
|
|
|
1371
1377
|
}
|
|
1372
1378
|
if (isAuthenticationRequired(invitation)) {
|
|
1373
1379
|
for (let attempt = 1; attempt <= MAX_OTP_ATTEMPTS; attempt++) {
|
|
1374
|
-
(0, import_log5.log)("guest waiting for authentication code...",
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1380
|
+
(0, import_log5.log)("guest waiting for authentication code...", void 0, {
|
|
1381
|
+
F: __dxlog_file5,
|
|
1382
|
+
L: 285,
|
|
1383
|
+
S: this,
|
|
1384
|
+
C: (f, a) => f(...a)
|
|
1379
1385
|
});
|
|
1380
1386
|
setState({
|
|
1381
1387
|
state: import_services3.Invitation.State.READY_FOR_AUTHENTICATION
|
|
@@ -1383,11 +1389,11 @@ var InvitationsHandler = class {
|
|
|
1383
1389
|
const authCode = await authenticated.wait({
|
|
1384
1390
|
timeout
|
|
1385
1391
|
});
|
|
1386
|
-
(0, import_log5.log)("sending authentication request",
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1392
|
+
(0, import_log5.log)("sending authentication request", void 0, {
|
|
1393
|
+
F: __dxlog_file5,
|
|
1394
|
+
L: 289,
|
|
1395
|
+
S: this,
|
|
1396
|
+
C: (f, a) => f(...a)
|
|
1391
1397
|
});
|
|
1392
1398
|
setState({
|
|
1393
1399
|
state: import_services3.Invitation.State.AUTHENTICATING
|
|
@@ -1405,10 +1411,10 @@ var InvitationsHandler = class {
|
|
|
1405
1411
|
(0, import_log5.log)("retrying invalid code", {
|
|
1406
1412
|
attempt
|
|
1407
1413
|
}, {
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1414
|
+
F: __dxlog_file5,
|
|
1415
|
+
L: 300,
|
|
1416
|
+
S: this,
|
|
1417
|
+
C: (f, a) => f(...a)
|
|
1412
1418
|
});
|
|
1413
1419
|
authenticated.reset();
|
|
1414
1420
|
}
|
|
@@ -1422,10 +1428,10 @@ var InvitationsHandler = class {
|
|
|
1422
1428
|
(0, import_log5.log)("request admission", {
|
|
1423
1429
|
...protocol.toJSON()
|
|
1424
1430
|
}, {
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1431
|
+
F: __dxlog_file5,
|
|
1432
|
+
L: 311,
|
|
1433
|
+
S: this,
|
|
1434
|
+
C: (f, a) => f(...a)
|
|
1429
1435
|
});
|
|
1430
1436
|
const admissionRequest = await protocol.createAdmissionRequest();
|
|
1431
1437
|
const admissionResponse = await extension.rpc.InvitationHostService.admit(admissionRequest);
|
|
@@ -1434,10 +1440,10 @@ var InvitationsHandler = class {
|
|
|
1434
1440
|
(0, import_log5.log)("admitted by host", {
|
|
1435
1441
|
...protocol.toJSON()
|
|
1436
1442
|
}, {
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1443
|
+
F: __dxlog_file5,
|
|
1444
|
+
L: 322,
|
|
1445
|
+
S: this,
|
|
1446
|
+
C: (f, a) => f(...a)
|
|
1441
1447
|
});
|
|
1442
1448
|
setState({
|
|
1443
1449
|
...result,
|
|
@@ -1446,30 +1452,30 @@ var InvitationsHandler = class {
|
|
|
1446
1452
|
import_log5.log.trace("dxos.sdk.invitations-handler.guest.onOpen", import_protocols4.trace.end({
|
|
1447
1453
|
id: traceId
|
|
1448
1454
|
}), {
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1455
|
+
F: __dxlog_file5,
|
|
1456
|
+
L: 324,
|
|
1457
|
+
S: this,
|
|
1458
|
+
C: (f, a) => f(...a)
|
|
1453
1459
|
});
|
|
1454
1460
|
} catch (err) {
|
|
1455
1461
|
if (err instanceof import_async5.TimeoutError) {
|
|
1456
1462
|
(0, import_log5.log)("timeout", {
|
|
1457
1463
|
...protocol.toJSON()
|
|
1458
1464
|
}, {
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1465
|
+
F: __dxlog_file5,
|
|
1466
|
+
L: 327,
|
|
1467
|
+
S: this,
|
|
1468
|
+
C: (f, a) => f(...a)
|
|
1463
1469
|
});
|
|
1464
1470
|
setState({
|
|
1465
1471
|
state: import_services3.Invitation.State.TIMEOUT
|
|
1466
1472
|
});
|
|
1467
1473
|
} else {
|
|
1468
1474
|
(0, import_log5.log)("auth failed", err, {
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1475
|
+
F: __dxlog_file5,
|
|
1476
|
+
L: 330,
|
|
1477
|
+
S: this,
|
|
1478
|
+
C: (f, a) => f(...a)
|
|
1473
1479
|
});
|
|
1474
1480
|
stream.error(err);
|
|
1475
1481
|
}
|
|
@@ -1477,10 +1483,10 @@ var InvitationsHandler = class {
|
|
|
1477
1483
|
id: traceId,
|
|
1478
1484
|
error: err
|
|
1479
1485
|
}), {
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1486
|
+
F: __dxlog_file5,
|
|
1487
|
+
L: 333,
|
|
1488
|
+
S: this,
|
|
1489
|
+
C: (f, a) => f(...a)
|
|
1484
1490
|
});
|
|
1485
1491
|
} finally {
|
|
1486
1492
|
await ctx.dispose();
|
|
@@ -1495,20 +1501,20 @@ var InvitationsHandler = class {
|
|
|
1495
1501
|
(0, import_log5.log)("timeout", {
|
|
1496
1502
|
...protocol.toJSON()
|
|
1497
1503
|
}, {
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1504
|
+
F: __dxlog_file5,
|
|
1505
|
+
L: 344,
|
|
1506
|
+
S: this,
|
|
1507
|
+
C: (f, a) => f(...a)
|
|
1502
1508
|
});
|
|
1503
1509
|
setState({
|
|
1504
1510
|
state: import_services3.Invitation.State.TIMEOUT
|
|
1505
1511
|
});
|
|
1506
1512
|
} else {
|
|
1507
1513
|
(0, import_log5.log)("auth failed", err, {
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1514
|
+
F: __dxlog_file5,
|
|
1515
|
+
L: 347,
|
|
1516
|
+
S: this,
|
|
1517
|
+
C: (f, a) => f(...a)
|
|
1512
1518
|
});
|
|
1513
1519
|
stream.error(err);
|
|
1514
1520
|
}
|
|
@@ -1517,7 +1523,7 @@ var InvitationsHandler = class {
|
|
|
1517
1523
|
return extension;
|
|
1518
1524
|
};
|
|
1519
1525
|
(0, import_async5.scheduleTask)(ctx, async () => {
|
|
1520
|
-
(0,
|
|
1526
|
+
(0, import_tiny_invariant6.default)(invitation.swarmKey);
|
|
1521
1527
|
const topic = invitation.swarmKey;
|
|
1522
1528
|
const swarmConnection = await this._networkManager.joinSwarm({
|
|
1523
1529
|
topic,
|
|
@@ -1550,11 +1556,12 @@ var InvitationsHandler = class {
|
|
|
1550
1556
|
};
|
|
1551
1557
|
|
|
1552
1558
|
// packages/sdk/client-services/src/packlets/invitations/invitations-service.ts
|
|
1553
|
-
var
|
|
1559
|
+
var import_tiny_invariant7 = __toESM(require("tiny-invariant"));
|
|
1554
1560
|
var import_async6 = require("@dxos/async");
|
|
1555
1561
|
var import_codec_protobuf2 = require("@dxos/codec-protobuf");
|
|
1556
1562
|
var import_log6 = require("@dxos/log");
|
|
1557
1563
|
var import_services4 = require("@dxos/protocols/proto/dxos/client/services");
|
|
1564
|
+
var __dxlog_file6 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitations-service.ts";
|
|
1558
1565
|
var InvitationsServiceImpl = class {
|
|
1559
1566
|
constructor(_invitationsHandler, _getHandler) {
|
|
1560
1567
|
this._invitationsHandler = _invitationsHandler;
|
|
@@ -1615,35 +1622,35 @@ var InvitationsServiceImpl = class {
|
|
|
1615
1622
|
});
|
|
1616
1623
|
}
|
|
1617
1624
|
async authenticate({ invitationId, authCode }) {
|
|
1618
|
-
(0, import_log6.log)("authenticating...",
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1625
|
+
(0, import_log6.log)("authenticating...", void 0, {
|
|
1626
|
+
F: __dxlog_file6,
|
|
1627
|
+
L: 103,
|
|
1628
|
+
S: this,
|
|
1629
|
+
C: (f, a) => f(...a)
|
|
1623
1630
|
});
|
|
1624
|
-
(0,
|
|
1631
|
+
(0, import_tiny_invariant7.default)(invitationId);
|
|
1625
1632
|
const observable = this._acceptInvitations.get(invitationId);
|
|
1626
1633
|
if (!observable) {
|
|
1627
1634
|
import_log6.log.warn("invalid invitation", {
|
|
1628
1635
|
invitationId
|
|
1629
1636
|
}, {
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1637
|
+
F: __dxlog_file6,
|
|
1638
|
+
L: 107,
|
|
1639
|
+
S: this,
|
|
1640
|
+
C: (f, a) => f(...a)
|
|
1634
1641
|
});
|
|
1635
1642
|
} else {
|
|
1636
1643
|
await observable.authenticate(authCode);
|
|
1637
1644
|
}
|
|
1638
1645
|
}
|
|
1639
1646
|
async cancelInvitation({ invitationId }) {
|
|
1640
|
-
(0, import_log6.log)("deleting...",
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1647
|
+
(0, import_log6.log)("deleting...", void 0, {
|
|
1648
|
+
F: __dxlog_file6,
|
|
1649
|
+
L: 114,
|
|
1650
|
+
S: this,
|
|
1651
|
+
C: (f, a) => f(...a)
|
|
1645
1652
|
});
|
|
1646
|
-
(0,
|
|
1653
|
+
(0, import_tiny_invariant7.default)(invitationId);
|
|
1647
1654
|
const created = this._createInvitations.get(invitationId);
|
|
1648
1655
|
const accepted = this._acceptInvitations.get(invitationId);
|
|
1649
1656
|
if (created) {
|
|
@@ -1658,10 +1665,10 @@ var InvitationsServiceImpl = class {
|
|
|
1658
1665
|
import_log6.log.warn("invalid invitation", {
|
|
1659
1666
|
invitationId
|
|
1660
1667
|
}, {
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1668
|
+
F: __dxlog_file6,
|
|
1669
|
+
L: 127,
|
|
1670
|
+
S: this,
|
|
1671
|
+
C: (f, a) => f(...a)
|
|
1665
1672
|
});
|
|
1666
1673
|
}
|
|
1667
1674
|
}
|
|
@@ -1718,11 +1725,12 @@ var InvitationsServiceImpl = class {
|
|
|
1718
1725
|
};
|
|
1719
1726
|
|
|
1720
1727
|
// packages/sdk/client-services/src/packlets/invitations/space-invitation-protocol.ts
|
|
1721
|
-
var
|
|
1728
|
+
var import_tiny_invariant8 = __toESM(require("tiny-invariant"));
|
|
1722
1729
|
var import_credentials9 = require("@dxos/credentials");
|
|
1723
1730
|
var import_feed_store2 = require("@dxos/feed-store");
|
|
1724
1731
|
var import_log7 = require("@dxos/log");
|
|
1725
1732
|
var import_services5 = require("@dxos/protocols/proto/dxos/client/services");
|
|
1733
|
+
var __dxlog_file7 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/space-invitation-protocol.ts";
|
|
1726
1734
|
var SpaceInvitationProtocol = class {
|
|
1727
1735
|
constructor(_spaceManager, _signingContext, _keyring, _spaceKey) {
|
|
1728
1736
|
this._spaceManager = _spaceManager;
|
|
@@ -1744,24 +1752,24 @@ var SpaceInvitationProtocol = class {
|
|
|
1744
1752
|
}
|
|
1745
1753
|
async admit(request, guestProfile) {
|
|
1746
1754
|
var _a;
|
|
1747
|
-
(0,
|
|
1755
|
+
(0, import_tiny_invariant8.default)(this._spaceKey);
|
|
1748
1756
|
const space = await this._spaceManager.spaces.get(this._spaceKey);
|
|
1749
|
-
(0,
|
|
1750
|
-
(0,
|
|
1757
|
+
(0, import_tiny_invariant8.default)(space);
|
|
1758
|
+
(0, import_tiny_invariant8.default)(request.space);
|
|
1751
1759
|
const { identityKey, deviceKey } = request.space;
|
|
1752
1760
|
(0, import_log7.log)("writing guest credentials", {
|
|
1753
1761
|
host: this._signingContext.deviceKey,
|
|
1754
1762
|
guest: deviceKey
|
|
1755
1763
|
}, {
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1764
|
+
F: __dxlog_file7,
|
|
1765
|
+
L: 50,
|
|
1766
|
+
S: this,
|
|
1767
|
+
C: (f, a) => f(...a)
|
|
1760
1768
|
});
|
|
1761
1769
|
const credentials = await (0, import_credentials9.createAdmissionCredentials)(this._signingContext.credentialSigner, identityKey, space.key, space.inner.genesisFeedKey, guestProfile);
|
|
1762
|
-
(0,
|
|
1770
|
+
(0, import_tiny_invariant8.default)(credentials[0].credential);
|
|
1763
1771
|
const spaceMemberCredential = credentials[0].credential.credential;
|
|
1764
|
-
(0,
|
|
1772
|
+
(0, import_tiny_invariant8.default)((0, import_credentials9.getCredentialAssertion)(spaceMemberCredential)["@type"] === "dxos.halo.credentials.SpaceMember");
|
|
1765
1773
|
await (0, import_feed_store2.writeMessages)(space.inner.controlPipeline.writer, credentials);
|
|
1766
1774
|
return {
|
|
1767
1775
|
space: {
|
|
@@ -1789,11 +1797,11 @@ var SpaceInvitationProtocol = class {
|
|
|
1789
1797
|
};
|
|
1790
1798
|
}
|
|
1791
1799
|
async accept(response) {
|
|
1792
|
-
(0,
|
|
1800
|
+
(0, import_tiny_invariant8.default)(response.space);
|
|
1793
1801
|
const { credential, controlTimeframe, dataTimeframe } = response.space;
|
|
1794
1802
|
const assertion = (0, import_credentials9.getCredentialAssertion)(credential);
|
|
1795
|
-
(0,
|
|
1796
|
-
(0,
|
|
1803
|
+
(0, import_tiny_invariant8.default)(assertion["@type"] === "dxos.halo.credentials.SpaceMember", "Invalid credential");
|
|
1804
|
+
(0, import_tiny_invariant8.default)(credential.subject.id.equals(this._signingContext.identityKey));
|
|
1797
1805
|
await this._spaceManager.acceptSpace({
|
|
1798
1806
|
spaceKey: assertion.spaceKey,
|
|
1799
1807
|
genesisFeedKey: assertion.genesisFeedKey,
|
|
@@ -1808,7 +1816,7 @@ var SpaceInvitationProtocol = class {
|
|
|
1808
1816
|
};
|
|
1809
1817
|
|
|
1810
1818
|
// packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts
|
|
1811
|
-
var
|
|
1819
|
+
var import_tiny_invariant10 = __toESM(require("tiny-invariant"));
|
|
1812
1820
|
var import_async9 = require("@dxos/async");
|
|
1813
1821
|
var import_context6 = require("@dxos/context");
|
|
1814
1822
|
var import_credentials13 = require("@dxos/credentials");
|
|
@@ -1834,7 +1842,7 @@ var import_timeframe = require("@dxos/timeframe");
|
|
|
1834
1842
|
var import_util3 = require("@dxos/util");
|
|
1835
1843
|
|
|
1836
1844
|
// packages/sdk/client-services/src/packlets/spaces/notarization-plugin.ts
|
|
1837
|
-
var
|
|
1845
|
+
var import_tiny_invariant9 = __toESM(require("tiny-invariant"));
|
|
1838
1846
|
var import_async7 = require("@dxos/async");
|
|
1839
1847
|
var import_context4 = require("@dxos/context");
|
|
1840
1848
|
var import_keys5 = require("@dxos/keys");
|
|
@@ -1842,6 +1850,7 @@ var import_log8 = require("@dxos/log");
|
|
|
1842
1850
|
var import_protocols5 = require("@dxos/protocols");
|
|
1843
1851
|
var import_teleport2 = require("@dxos/teleport");
|
|
1844
1852
|
var import_util2 = require("@dxos/util");
|
|
1853
|
+
var __dxlog_file8 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/notarization-plugin.ts";
|
|
1845
1854
|
var DEFAULT_RETRY_TIMEOUT = 1e3;
|
|
1846
1855
|
var DEFAULT_SUCCESS_DELAY = 1e3;
|
|
1847
1856
|
var DEFAULT_NOTARIZE_TIMEOUT = 1e4;
|
|
@@ -1854,6 +1863,9 @@ var NotarizationPlugin = class {
|
|
|
1854
1863
|
this._processedCredentials = new import_util2.ComplexSet(import_keys5.PublicKey.hash);
|
|
1855
1864
|
this._processCredentialsTriggers = new import_util2.ComplexMap(import_keys5.PublicKey.hash);
|
|
1856
1865
|
}
|
|
1866
|
+
get hasWriter() {
|
|
1867
|
+
return !!this._writer;
|
|
1868
|
+
}
|
|
1857
1869
|
async open() {
|
|
1858
1870
|
}
|
|
1859
1871
|
async close() {
|
|
@@ -1866,22 +1878,22 @@ var NotarizationPlugin = class {
|
|
|
1866
1878
|
(0, import_log8.log)("notarize", {
|
|
1867
1879
|
credentials
|
|
1868
1880
|
}, {
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
1881
|
+
F: __dxlog_file8,
|
|
1882
|
+
L: 91,
|
|
1883
|
+
S: this,
|
|
1884
|
+
C: (f, a) => f(...a)
|
|
1873
1885
|
});
|
|
1874
|
-
(0,
|
|
1886
|
+
(0, import_tiny_invariant9.default)(credentials.every((credential) => credential.id), "Credentials must have an id");
|
|
1875
1887
|
const errors = new import_async7.Trigger();
|
|
1876
1888
|
const ctx = this._ctx.derive({
|
|
1877
1889
|
onError: (err) => {
|
|
1878
1890
|
import_log8.log.warn("Notarization error", {
|
|
1879
1891
|
err
|
|
1880
1892
|
}, {
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
|
|
1893
|
+
F: __dxlog_file8,
|
|
1894
|
+
L: 100,
|
|
1895
|
+
S: this,
|
|
1896
|
+
C: (f, a) => f(...a)
|
|
1885
1897
|
});
|
|
1886
1898
|
void ctx.dispose();
|
|
1887
1899
|
errors.throw(err);
|
|
@@ -1894,10 +1906,10 @@ var NotarizationPlugin = class {
|
|
|
1894
1906
|
timeout,
|
|
1895
1907
|
peers: Array.from(this._extensions).map((extension) => extension.remotePeerId)
|
|
1896
1908
|
}, {
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1909
|
+
F: __dxlog_file8,
|
|
1910
|
+
L: 112,
|
|
1911
|
+
S: this,
|
|
1912
|
+
C: (f, a) => f(...a)
|
|
1901
1913
|
});
|
|
1902
1914
|
void ctx.dispose();
|
|
1903
1915
|
errors.throw(new import_async7.TimeoutError(timeout, "Notarization timed out"));
|
|
@@ -1917,10 +1929,10 @@ var NotarizationPlugin = class {
|
|
|
1917
1929
|
import_log8.log.warn("Exhausted all peers to notarize with", {
|
|
1918
1930
|
retryIn: retryTimeout
|
|
1919
1931
|
}, {
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
|
|
1932
|
+
F: __dxlog_file8,
|
|
1933
|
+
L: 137,
|
|
1934
|
+
S: this,
|
|
1935
|
+
C: (f, a) => f(...a)
|
|
1924
1936
|
});
|
|
1925
1937
|
peersTried.clear();
|
|
1926
1938
|
(0, import_async7.scheduleTask)(ctx, () => notarizeTask.schedule(), retryTimeout);
|
|
@@ -1931,28 +1943,28 @@ var NotarizationPlugin = class {
|
|
|
1931
1943
|
peer: peer.localPeerId,
|
|
1932
1944
|
credentialId: credentials.map((credential) => credential.id)
|
|
1933
1945
|
}, {
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
|
|
1946
|
+
F: __dxlog_file8,
|
|
1947
|
+
L: 144,
|
|
1948
|
+
S: this,
|
|
1949
|
+
C: (f, a) => f(...a)
|
|
1938
1950
|
});
|
|
1939
1951
|
await peer.rpc.NotarizationService.notarize({
|
|
1940
1952
|
credentials: credentials.filter((credential) => !this._processedCredentials.has(credential.id))
|
|
1941
1953
|
});
|
|
1942
|
-
(0, import_log8.log)("success",
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
|
|
1954
|
+
(0, import_log8.log)("success", void 0, {
|
|
1955
|
+
F: __dxlog_file8,
|
|
1956
|
+
L: 148,
|
|
1957
|
+
S: this,
|
|
1958
|
+
C: (f, a) => f(...a)
|
|
1947
1959
|
});
|
|
1948
1960
|
await (0, import_async7.sleep)(successDelay);
|
|
1949
1961
|
} catch (err) {
|
|
1950
1962
|
if (!ctx.disposed && !err.message.includes(WRITER_NOT_SET_ERROR_CODE)) {
|
|
1951
1963
|
import_log8.log.warn("error notarizing (recoverable)", err, {
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1964
|
+
F: __dxlog_file8,
|
|
1965
|
+
L: 152,
|
|
1966
|
+
S: this,
|
|
1967
|
+
C: (f, a) => f(...a)
|
|
1956
1968
|
});
|
|
1957
1969
|
}
|
|
1958
1970
|
notarizeTask.schedule();
|
|
@@ -1966,11 +1978,11 @@ var NotarizationPlugin = class {
|
|
|
1966
1978
|
allNotarized,
|
|
1967
1979
|
errors.wait()
|
|
1968
1980
|
]);
|
|
1969
|
-
(0, import_log8.log)("done",
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
|
|
1981
|
+
(0, import_log8.log)("done", void 0, {
|
|
1982
|
+
F: __dxlog_file8,
|
|
1983
|
+
L: 163,
|
|
1984
|
+
S: this,
|
|
1985
|
+
C: (f, a) => f(...a)
|
|
1974
1986
|
});
|
|
1975
1987
|
} finally {
|
|
1976
1988
|
await ctx.dispose();
|
|
@@ -1979,7 +1991,7 @@ var NotarizationPlugin = class {
|
|
|
1979
1991
|
/**
|
|
1980
1992
|
* Called with credentials arriving from the control pipeline.
|
|
1981
1993
|
*/
|
|
1982
|
-
async
|
|
1994
|
+
async processCredential(credential) {
|
|
1983
1995
|
var _a;
|
|
1984
1996
|
if (!credential.id) {
|
|
1985
1997
|
return;
|
|
@@ -1989,7 +2001,7 @@ var NotarizationPlugin = class {
|
|
|
1989
2001
|
this._processCredentialsTriggers.delete(credential.id);
|
|
1990
2002
|
}
|
|
1991
2003
|
setWriter(writer) {
|
|
1992
|
-
(0,
|
|
2004
|
+
(0, import_tiny_invariant9.default)(!this._writer, "Writer already set.");
|
|
1993
2005
|
this._writer = writer;
|
|
1994
2006
|
}
|
|
1995
2007
|
async _waitUntilProcessed(id) {
|
|
@@ -2007,7 +2019,7 @@ var NotarizationPlugin = class {
|
|
|
2007
2019
|
throw new Error(WRITER_NOT_SET_ERROR_CODE);
|
|
2008
2020
|
}
|
|
2009
2021
|
for (const credential of (_a = request.credentials) != null ? _a : []) {
|
|
2010
|
-
(0,
|
|
2022
|
+
(0, import_tiny_invariant9.default)(credential.id, "Credential must have an id");
|
|
2011
2023
|
if (this._processedCredentials.has(credential.id)) {
|
|
2012
2024
|
continue;
|
|
2013
2025
|
}
|
|
@@ -2020,10 +2032,10 @@ var NotarizationPlugin = class {
|
|
|
2020
2032
|
(0, import_log8.log)("extension opened", {
|
|
2021
2033
|
peer: extension.localPeerId
|
|
2022
2034
|
}, {
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
|
|
2035
|
+
F: __dxlog_file8,
|
|
2036
|
+
L: 212,
|
|
2037
|
+
S: this,
|
|
2038
|
+
C: (f, a) => f(...a)
|
|
2027
2039
|
});
|
|
2028
2040
|
this._extensions.add(extension);
|
|
2029
2041
|
this._extensionOpened.emit();
|
|
@@ -2032,10 +2044,10 @@ var NotarizationPlugin = class {
|
|
|
2032
2044
|
(0, import_log8.log)("extension closed", {
|
|
2033
2045
|
peer: extension.localPeerId
|
|
2034
2046
|
}, {
|
|
2035
|
-
|
|
2036
|
-
|
|
2037
|
-
|
|
2038
|
-
|
|
2047
|
+
F: __dxlog_file8,
|
|
2048
|
+
L: 217,
|
|
2049
|
+
S: this,
|
|
2050
|
+
C: (f, a) => f(...a)
|
|
2039
2051
|
});
|
|
2040
2052
|
this._extensions.delete(extension);
|
|
2041
2053
|
},
|
|
@@ -2076,7 +2088,7 @@ var NotarizationTeleportExtension = class extends import_teleport2.RpcExtension
|
|
|
2076
2088
|
};
|
|
2077
2089
|
|
|
2078
2090
|
// packages/sdk/client-services/src/packlets/spaces/data-space.ts
|
|
2079
|
-
|
|
2091
|
+
function _ts_decorate(decorators, target, key, desc) {
|
|
2080
2092
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2081
2093
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
2082
2094
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -2085,10 +2097,12 @@ var __decorate = function(decorators, target, key, desc) {
|
|
|
2085
2097
|
if (d = decorators[i])
|
|
2086
2098
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
2087
2099
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2088
|
-
}
|
|
2100
|
+
}
|
|
2101
|
+
var __dxlog_file9 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space.ts";
|
|
2089
2102
|
var DataSpace = class DataSpace2 {
|
|
2090
2103
|
constructor(params) {
|
|
2091
2104
|
this._ctx = new import_context5.Context();
|
|
2105
|
+
this._notarizationPlugin = new NotarizationPlugin();
|
|
2092
2106
|
this._state = import_services6.SpaceState.CLOSED;
|
|
2093
2107
|
/**
|
|
2094
2108
|
* Error for _state === SpaceState.ERROR.
|
|
@@ -2111,8 +2125,8 @@ var DataSpace = class DataSpace2 {
|
|
|
2111
2125
|
update: this._inner.stateUpdate,
|
|
2112
2126
|
authTimeout: import_client_protocol3.AUTH_TIMEOUT
|
|
2113
2127
|
});
|
|
2114
|
-
this._notarizationPluginConsumer = this._inner.spaceState.registerProcessor(new NotarizationPlugin());
|
|
2115
2128
|
this._cache = params.cache;
|
|
2129
|
+
this._state = params.initialState;
|
|
2116
2130
|
}
|
|
2117
2131
|
get key() {
|
|
2118
2132
|
return this._inner.key;
|
|
@@ -2134,25 +2148,36 @@ var DataSpace = class DataSpace2 {
|
|
|
2134
2148
|
return this._presence;
|
|
2135
2149
|
}
|
|
2136
2150
|
get notarizationPlugin() {
|
|
2137
|
-
return this.
|
|
2151
|
+
return this._notarizationPlugin;
|
|
2138
2152
|
}
|
|
2139
2153
|
get cache() {
|
|
2140
2154
|
return this._cache;
|
|
2141
2155
|
}
|
|
2142
2156
|
async open() {
|
|
2143
|
-
await this.
|
|
2144
|
-
|
|
2157
|
+
await this._open();
|
|
2158
|
+
}
|
|
2159
|
+
async _open() {
|
|
2160
|
+
await this._notarizationPlugin.open();
|
|
2161
|
+
await this._inner.spaceState.addCredentialProcessor(this._notarizationPlugin);
|
|
2145
2162
|
await this._inner.open();
|
|
2146
|
-
this._state = import_services6.SpaceState.
|
|
2163
|
+
this._state = import_services6.SpaceState.CONTROL_ONLY;
|
|
2164
|
+
this.stateUpdate.emit();
|
|
2165
|
+
this.metrics = {};
|
|
2147
2166
|
this.metrics.open = new Date();
|
|
2148
2167
|
}
|
|
2149
2168
|
async close() {
|
|
2169
|
+
await this._close();
|
|
2170
|
+
}
|
|
2171
|
+
async _close() {
|
|
2172
|
+
var _a, _b;
|
|
2173
|
+
await ((_b = (_a = this._callbacks).beforeClose) == null ? void 0 : _b.call(_a));
|
|
2150
2174
|
this._state = import_services6.SpaceState.CLOSED;
|
|
2151
2175
|
await this._ctx.dispose();
|
|
2176
|
+
this._ctx = new import_context5.Context();
|
|
2152
2177
|
await this.authVerifier.close();
|
|
2153
2178
|
await this._inner.close();
|
|
2154
|
-
await this.
|
|
2155
|
-
await this.
|
|
2179
|
+
await this._inner.spaceState.removeCredentialProcessor(this._notarizationPlugin);
|
|
2180
|
+
await this._notarizationPlugin.close();
|
|
2156
2181
|
await this._presence.destroy();
|
|
2157
2182
|
}
|
|
2158
2183
|
async postMessage(channel, message) {
|
|
@@ -2172,18 +2197,18 @@ var DataSpace = class DataSpace2 {
|
|
|
2172
2197
|
} catch (err) {
|
|
2173
2198
|
if (err instanceof import_errors3.CancelledError) {
|
|
2174
2199
|
(0, import_log9.log)("Data pipeline initialization cancelled", err, {
|
|
2175
|
-
|
|
2176
|
-
|
|
2177
|
-
|
|
2178
|
-
|
|
2200
|
+
F: __dxlog_file9,
|
|
2201
|
+
L: 193,
|
|
2202
|
+
S: this,
|
|
2203
|
+
C: (f, a) => f(...a)
|
|
2179
2204
|
});
|
|
2180
2205
|
return;
|
|
2181
2206
|
}
|
|
2182
2207
|
import_log9.log.error("Error initializing data pipeline", err, {
|
|
2183
|
-
|
|
2184
|
-
|
|
2185
|
-
|
|
2186
|
-
|
|
2208
|
+
F: __dxlog_file9,
|
|
2209
|
+
L: 197,
|
|
2210
|
+
S: this,
|
|
2211
|
+
C: (f, a) => f(...a)
|
|
2187
2212
|
});
|
|
2188
2213
|
this._state = import_services6.SpaceState.ERROR;
|
|
2189
2214
|
this.error = err;
|
|
@@ -2195,7 +2220,7 @@ var DataSpace = class DataSpace2 {
|
|
|
2195
2220
|
}
|
|
2196
2221
|
async initializeDataPipeline() {
|
|
2197
2222
|
var _a, _b, _c, _d;
|
|
2198
|
-
if (this._state !== import_services6.SpaceState.
|
|
2223
|
+
if (this._state !== import_services6.SpaceState.CONTROL_ONLY) {
|
|
2199
2224
|
throw new import_errors3.SystemError("Invalid operation");
|
|
2200
2225
|
}
|
|
2201
2226
|
this._state = import_services6.SpaceState.INITIALIZING;
|
|
@@ -2205,37 +2230,39 @@ var DataSpace = class DataSpace2 {
|
|
|
2205
2230
|
});
|
|
2206
2231
|
this.metrics.controlPipelineReady = new Date();
|
|
2207
2232
|
await this._createWritableFeeds();
|
|
2208
|
-
(0, import_log9.log)("Writable feeds created",
|
|
2209
|
-
|
|
2210
|
-
|
|
2211
|
-
|
|
2212
|
-
|
|
2233
|
+
(0, import_log9.log)("Writable feeds created", void 0, {
|
|
2234
|
+
F: __dxlog_file9,
|
|
2235
|
+
L: 221,
|
|
2236
|
+
S: this,
|
|
2237
|
+
C: (f, a) => f(...a)
|
|
2213
2238
|
});
|
|
2214
2239
|
this.stateUpdate.emit();
|
|
2215
|
-
this.notarizationPlugin.
|
|
2216
|
-
credential
|
|
2217
|
-
credential
|
|
2218
|
-
|
|
2219
|
-
|
|
2240
|
+
if (!this.notarizationPlugin.hasWriter) {
|
|
2241
|
+
this.notarizationPlugin.setWriter((0, import_echo_pipeline.createMappedFeedWriter)((credential) => ({
|
|
2242
|
+
credential: {
|
|
2243
|
+
credential
|
|
2244
|
+
}
|
|
2245
|
+
}), this._inner.controlPipeline.writer));
|
|
2246
|
+
}
|
|
2220
2247
|
await this._inner.initializeDataPipeline();
|
|
2221
2248
|
this.metrics.dataPipelineOpen = new Date();
|
|
2222
2249
|
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
|
-
|
|
2250
|
+
(0, import_log9.log)("waiting for data pipeline to reach target timeframe", void 0, {
|
|
2251
|
+
F: __dxlog_file9,
|
|
2252
|
+
L: 242,
|
|
2253
|
+
S: this,
|
|
2254
|
+
C: (f, a) => f(...a)
|
|
2228
2255
|
});
|
|
2229
2256
|
await this._inner.dataPipeline.pipelineState.waitUntilReachedTargetTimeframe({
|
|
2230
2257
|
ctx: this._ctx,
|
|
2231
2258
|
breakOnStall: false
|
|
2232
2259
|
});
|
|
2233
2260
|
this.metrics.dataPipelineReady = new Date();
|
|
2234
|
-
(0, import_log9.log)("data pipeline ready",
|
|
2235
|
-
|
|
2236
|
-
|
|
2237
|
-
|
|
2238
|
-
|
|
2261
|
+
(0, import_log9.log)("data pipeline ready", void 0, {
|
|
2262
|
+
F: __dxlog_file9,
|
|
2263
|
+
L: 251,
|
|
2264
|
+
S: this,
|
|
2265
|
+
C: (f, a) => f(...a)
|
|
2239
2266
|
});
|
|
2240
2267
|
await ((_b = (_a = this._callbacks).beforeReady) == null ? void 0 : _b.call(_a));
|
|
2241
2268
|
this._state = import_services6.SpaceState.READY;
|
|
@@ -2313,11 +2340,40 @@ var DataSpace = class DataSpace2 {
|
|
|
2313
2340
|
}
|
|
2314
2341
|
}
|
|
2315
2342
|
}
|
|
2343
|
+
async activate() {
|
|
2344
|
+
if (this._state !== import_services6.SpaceState.INACTIVE) {
|
|
2345
|
+
throw new import_errors3.SystemError("Invalid operation");
|
|
2346
|
+
}
|
|
2347
|
+
await this._metadataStore.setSpaceState(this.key, import_services6.SpaceState.ACTIVE);
|
|
2348
|
+
await this._open();
|
|
2349
|
+
this.initializeDataPipelineAsync();
|
|
2350
|
+
}
|
|
2351
|
+
async deactivate() {
|
|
2352
|
+
if (this._state === import_services6.SpaceState.INACTIVE) {
|
|
2353
|
+
throw new import_errors3.SystemError("Invalid operation");
|
|
2354
|
+
}
|
|
2355
|
+
await this._metadataStore.setSpaceState(this.key, import_services6.SpaceState.INACTIVE);
|
|
2356
|
+
await this._close();
|
|
2357
|
+
this._state = import_services6.SpaceState.INACTIVE;
|
|
2358
|
+
this.stateUpdate.emit();
|
|
2359
|
+
}
|
|
2316
2360
|
};
|
|
2317
|
-
|
|
2361
|
+
_ts_decorate([
|
|
2362
|
+
import_async8.synchronized
|
|
2363
|
+
], DataSpace.prototype, "open", null);
|
|
2364
|
+
_ts_decorate([
|
|
2365
|
+
import_async8.synchronized
|
|
2366
|
+
], DataSpace.prototype, "close", null);
|
|
2367
|
+
_ts_decorate([
|
|
2318
2368
|
(0, import_debug3.timed)(1e4)
|
|
2319
2369
|
], DataSpace.prototype, "_createWritableFeeds", null);
|
|
2320
|
-
|
|
2370
|
+
_ts_decorate([
|
|
2371
|
+
import_async8.synchronized
|
|
2372
|
+
], DataSpace.prototype, "activate", null);
|
|
2373
|
+
_ts_decorate([
|
|
2374
|
+
import_async8.synchronized
|
|
2375
|
+
], DataSpace.prototype, "deactivate", null);
|
|
2376
|
+
DataSpace = _ts_decorate([
|
|
2321
2377
|
(0, import_async8.trackLeaks)("open", "close")
|
|
2322
2378
|
], DataSpace);
|
|
2323
2379
|
|
|
@@ -2392,7 +2448,7 @@ var spaceGenesis = async (keyring, signingContext, space) => {
|
|
|
2392
2448
|
};
|
|
2393
2449
|
|
|
2394
2450
|
// packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts
|
|
2395
|
-
|
|
2451
|
+
function _ts_decorate2(decorators, target, key, desc) {
|
|
2396
2452
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2397
2453
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
2398
2454
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -2401,7 +2457,8 @@ var __decorate2 = function(decorators, target, key, desc) {
|
|
|
2401
2457
|
if (d = decorators[i])
|
|
2402
2458
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
2403
2459
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2404
|
-
}
|
|
2460
|
+
}
|
|
2461
|
+
var __dxlog_file10 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts";
|
|
2405
2462
|
var DataSpaceManager = class DataSpaceManager2 {
|
|
2406
2463
|
constructor(_spaceManager, _metadataStore, _dataServiceSubscriptions, _keyring, _signingContext, _feedStore) {
|
|
2407
2464
|
this._spaceManager = _spaceManager;
|
|
@@ -2421,50 +2478,52 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2421
2478
|
return this._spaces;
|
|
2422
2479
|
}
|
|
2423
2480
|
async open() {
|
|
2424
|
-
(0, import_log10.log)("open",
|
|
2425
|
-
|
|
2426
|
-
|
|
2427
|
-
|
|
2428
|
-
|
|
2481
|
+
(0, import_log10.log)("open", void 0, {
|
|
2482
|
+
F: __dxlog_file10,
|
|
2483
|
+
L: 80,
|
|
2484
|
+
S: this,
|
|
2485
|
+
C: (f, a) => f(...a)
|
|
2429
2486
|
});
|
|
2430
2487
|
import_log10.log.trace("dxos.echo.data-space-manager.open", import_protocols6.trace.begin({
|
|
2431
2488
|
id: this._instanceId
|
|
2432
2489
|
}), {
|
|
2433
|
-
|
|
2434
|
-
|
|
2435
|
-
|
|
2436
|
-
|
|
2490
|
+
F: __dxlog_file10,
|
|
2491
|
+
L: 81,
|
|
2492
|
+
S: this,
|
|
2493
|
+
C: (f, a) => f(...a)
|
|
2437
2494
|
});
|
|
2438
2495
|
await this._metadataStore.load();
|
|
2439
2496
|
(0, import_log10.log)("metadata loaded", {
|
|
2440
2497
|
spaces: this._metadataStore.spaces.length
|
|
2441
2498
|
}, {
|
|
2442
|
-
|
|
2443
|
-
|
|
2444
|
-
|
|
2445
|
-
|
|
2499
|
+
F: __dxlog_file10,
|
|
2500
|
+
L: 83,
|
|
2501
|
+
S: this,
|
|
2502
|
+
C: (f, a) => f(...a)
|
|
2446
2503
|
});
|
|
2447
2504
|
for (const spaceMetadata of this._metadataStore.spaces) {
|
|
2448
2505
|
try {
|
|
2449
2506
|
(0, import_log10.log)("load space", {
|
|
2450
2507
|
spaceMetadata
|
|
2451
2508
|
}, {
|
|
2452
|
-
|
|
2453
|
-
|
|
2454
|
-
|
|
2455
|
-
|
|
2509
|
+
F: __dxlog_file10,
|
|
2510
|
+
L: 87,
|
|
2511
|
+
S: this,
|
|
2512
|
+
C: (f, a) => f(...a)
|
|
2456
2513
|
});
|
|
2457
2514
|
const space = await this._constructSpace(spaceMetadata);
|
|
2458
|
-
|
|
2515
|
+
if (spaceMetadata.state !== import_services7.SpaceState.INACTIVE) {
|
|
2516
|
+
space.initializeDataPipelineAsync();
|
|
2517
|
+
}
|
|
2459
2518
|
} catch (err) {
|
|
2460
2519
|
import_log10.log.error("Error loading space", {
|
|
2461
2520
|
spaceMetadata,
|
|
2462
2521
|
err
|
|
2463
2522
|
}, {
|
|
2464
|
-
|
|
2465
|
-
|
|
2466
|
-
|
|
2467
|
-
|
|
2523
|
+
F: __dxlog_file10,
|
|
2524
|
+
L: 93,
|
|
2525
|
+
S: this,
|
|
2526
|
+
C: (f, a) => f(...a)
|
|
2468
2527
|
});
|
|
2469
2528
|
}
|
|
2470
2529
|
}
|
|
@@ -2473,18 +2532,18 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2473
2532
|
import_log10.log.trace("dxos.echo.data-space-manager.open", import_protocols6.trace.end({
|
|
2474
2533
|
id: this._instanceId
|
|
2475
2534
|
}), {
|
|
2476
|
-
|
|
2477
|
-
|
|
2478
|
-
|
|
2479
|
-
|
|
2535
|
+
F: __dxlog_file10,
|
|
2536
|
+
L: 99,
|
|
2537
|
+
S: this,
|
|
2538
|
+
C: (f, a) => f(...a)
|
|
2480
2539
|
});
|
|
2481
2540
|
}
|
|
2482
2541
|
async close() {
|
|
2483
|
-
(0, import_log10.log)("close",
|
|
2484
|
-
|
|
2485
|
-
|
|
2486
|
-
|
|
2487
|
-
|
|
2542
|
+
(0, import_log10.log)("close", void 0, {
|
|
2543
|
+
F: __dxlog_file10,
|
|
2544
|
+
L: 104,
|
|
2545
|
+
S: this,
|
|
2546
|
+
C: (f, a) => f(...a)
|
|
2488
2547
|
});
|
|
2489
2548
|
this._isOpen = false;
|
|
2490
2549
|
await this._ctx.dispose();
|
|
@@ -2496,7 +2555,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2496
2555
|
* Creates a new space writing the genesis credentials to the control feed.
|
|
2497
2556
|
*/
|
|
2498
2557
|
async createSpace() {
|
|
2499
|
-
(0,
|
|
2558
|
+
(0, import_tiny_invariant10.default)(this._isOpen, "Not open.");
|
|
2500
2559
|
const spaceKey = await this._keyring.createKey();
|
|
2501
2560
|
const controlFeedKey = await this._keyring.createKey();
|
|
2502
2561
|
const dataFeedKey = await this._keyring.createKey();
|
|
@@ -2504,21 +2563,22 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2504
2563
|
key: spaceKey,
|
|
2505
2564
|
genesisFeedKey: controlFeedKey,
|
|
2506
2565
|
controlFeedKey,
|
|
2507
|
-
dataFeedKey
|
|
2566
|
+
dataFeedKey,
|
|
2567
|
+
state: import_services7.SpaceState.ACTIVE
|
|
2508
2568
|
};
|
|
2509
2569
|
(0, import_log10.log)("creating space...", {
|
|
2510
2570
|
spaceKey
|
|
2511
2571
|
}, {
|
|
2512
|
-
|
|
2513
|
-
|
|
2514
|
-
|
|
2515
|
-
|
|
2572
|
+
F: __dxlog_file10,
|
|
2573
|
+
L: 129,
|
|
2574
|
+
S: this,
|
|
2575
|
+
C: (f, a) => f(...a)
|
|
2516
2576
|
});
|
|
2517
2577
|
const space = await this._constructSpace(metadata);
|
|
2518
2578
|
const credentials = await spaceGenesis(this._keyring, this._signingContext, space.inner);
|
|
2519
2579
|
await this._metadataStore.addSpace(metadata);
|
|
2520
2580
|
const memberCredential = credentials[1];
|
|
2521
|
-
(0,
|
|
2581
|
+
(0, import_tiny_invariant10.default)((0, import_credentials13.getCredentialAssertion)(memberCredential)["@type"] === "dxos.halo.credentials.SpaceMember");
|
|
2522
2582
|
await this._signingContext.recordCredential(memberCredential);
|
|
2523
2583
|
await space.initializeDataPipeline();
|
|
2524
2584
|
this.updated.emit();
|
|
@@ -2529,13 +2589,13 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2529
2589
|
(0, import_log10.log)("accept space", {
|
|
2530
2590
|
opts
|
|
2531
2591
|
}, {
|
|
2532
|
-
|
|
2533
|
-
|
|
2534
|
-
|
|
2535
|
-
|
|
2592
|
+
F: __dxlog_file10,
|
|
2593
|
+
L: 148,
|
|
2594
|
+
S: this,
|
|
2595
|
+
C: (f, a) => f(...a)
|
|
2536
2596
|
});
|
|
2537
|
-
(0,
|
|
2538
|
-
(0,
|
|
2597
|
+
(0, import_tiny_invariant10.default)(this._isOpen, "Not open.");
|
|
2598
|
+
(0, import_tiny_invariant10.default)(!this._spaces.has(opts.spaceKey), "Space already exists.");
|
|
2539
2599
|
const metadata = {
|
|
2540
2600
|
key: opts.spaceKey,
|
|
2541
2601
|
genesisFeedKey: opts.genesisFeedKey,
|
|
@@ -2563,10 +2623,10 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2563
2623
|
(0, import_log10.log)("construct space", {
|
|
2564
2624
|
metadata
|
|
2565
2625
|
}, {
|
|
2566
|
-
|
|
2567
|
-
|
|
2568
|
-
|
|
2569
|
-
|
|
2626
|
+
F: __dxlog_file10,
|
|
2627
|
+
L: 183,
|
|
2628
|
+
S: this,
|
|
2629
|
+
C: (f, a) => f(...a)
|
|
2570
2630
|
});
|
|
2571
2631
|
const gossip = new import_teleport_extension_gossip.Gossip({
|
|
2572
2632
|
localPeerId: this._signingContext.deviceKey
|
|
@@ -2598,11 +2658,11 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2598
2658
|
session.addExtension("dxos.mesh.teleport.notarization", dataSpace.notarizationPlugin.createExtension());
|
|
2599
2659
|
},
|
|
2600
2660
|
onAuthFailure: () => {
|
|
2601
|
-
import_log10.log.warn("auth failure",
|
|
2602
|
-
|
|
2603
|
-
|
|
2604
|
-
|
|
2605
|
-
|
|
2661
|
+
import_log10.log.warn("auth failure", void 0, {
|
|
2662
|
+
F: __dxlog_file10,
|
|
2663
|
+
L: 214,
|
|
2664
|
+
S: this,
|
|
2665
|
+
C: (f, a) => f(...a)
|
|
2606
2666
|
});
|
|
2607
2667
|
},
|
|
2608
2668
|
memberKey: this._signingContext.identityKey
|
|
@@ -2611,6 +2671,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2611
2671
|
dataFeed && space.setDataFeed(dataFeed);
|
|
2612
2672
|
const dataSpace = new DataSpace({
|
|
2613
2673
|
inner: space,
|
|
2674
|
+
initialState: metadata.state === import_services7.SpaceState.INACTIVE ? import_services7.SpaceState.INACTIVE : import_services7.SpaceState.CLOSED,
|
|
2614
2675
|
metadataStore: this._metadataStore,
|
|
2615
2676
|
gossip,
|
|
2616
2677
|
presence,
|
|
@@ -2622,31 +2683,44 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2622
2683
|
(0, import_log10.log)("before space ready", {
|
|
2623
2684
|
space: space.key
|
|
2624
2685
|
}, {
|
|
2625
|
-
|
|
2626
|
-
|
|
2627
|
-
|
|
2628
|
-
|
|
2686
|
+
F: __dxlog_file10,
|
|
2687
|
+
L: 232,
|
|
2688
|
+
S: this,
|
|
2689
|
+
C: (f, a) => f(...a)
|
|
2629
2690
|
});
|
|
2630
|
-
this._dataServiceSubscriptions.registerSpace(space.key, dataSpace.dataPipeline.databaseHost.createDataServiceHost());
|
|
2691
|
+
await this._dataServiceSubscriptions.registerSpace(space.key, dataSpace.dataPipeline.databaseHost.createDataServiceHost());
|
|
2631
2692
|
},
|
|
2632
2693
|
afterReady: async () => {
|
|
2633
2694
|
(0, import_log10.log)("after space ready", {
|
|
2634
2695
|
space: space.key,
|
|
2635
2696
|
open: this._isOpen
|
|
2636
2697
|
}, {
|
|
2637
|
-
|
|
2638
|
-
|
|
2639
|
-
|
|
2640
|
-
|
|
2698
|
+
F: __dxlog_file10,
|
|
2699
|
+
L: 239,
|
|
2700
|
+
S: this,
|
|
2701
|
+
C: (f, a) => f(...a)
|
|
2641
2702
|
});
|
|
2642
2703
|
if (this._isOpen) {
|
|
2643
2704
|
this.updated.emit();
|
|
2644
2705
|
}
|
|
2706
|
+
},
|
|
2707
|
+
beforeClose: async () => {
|
|
2708
|
+
(0, import_log10.log)("before space close", {
|
|
2709
|
+
space: space.key
|
|
2710
|
+
}, {
|
|
2711
|
+
F: __dxlog_file10,
|
|
2712
|
+
L: 245,
|
|
2713
|
+
S: this,
|
|
2714
|
+
C: (f, a) => f(...a)
|
|
2715
|
+
});
|
|
2716
|
+
await this._dataServiceSubscriptions.unregisterSpace(space.key);
|
|
2645
2717
|
}
|
|
2646
2718
|
},
|
|
2647
2719
|
cache: metadata.cache
|
|
2648
2720
|
});
|
|
2649
|
-
|
|
2721
|
+
if (metadata.state !== import_services7.SpaceState.INACTIVE) {
|
|
2722
|
+
await dataSpace.open();
|
|
2723
|
+
}
|
|
2650
2724
|
if (metadata.controlTimeframe) {
|
|
2651
2725
|
dataSpace.inner.controlPipeline.state.setTargetTimeframe(metadata.controlTimeframe);
|
|
2652
2726
|
}
|
|
@@ -2657,19 +2731,19 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2657
2731
|
return dataSpace;
|
|
2658
2732
|
}
|
|
2659
2733
|
};
|
|
2660
|
-
|
|
2734
|
+
_ts_decorate2([
|
|
2661
2735
|
import_async9.synchronized
|
|
2662
2736
|
], DataSpaceManager.prototype, "open", null);
|
|
2663
|
-
|
|
2737
|
+
_ts_decorate2([
|
|
2664
2738
|
import_async9.synchronized
|
|
2665
2739
|
], DataSpaceManager.prototype, "close", null);
|
|
2666
|
-
|
|
2740
|
+
_ts_decorate2([
|
|
2667
2741
|
import_async9.synchronized
|
|
2668
2742
|
], DataSpaceManager.prototype, "createSpace", null);
|
|
2669
|
-
|
|
2743
|
+
_ts_decorate2([
|
|
2670
2744
|
import_async9.synchronized
|
|
2671
2745
|
], DataSpaceManager.prototype, "acceptSpace", null);
|
|
2672
|
-
DataSpaceManager =
|
|
2746
|
+
DataSpaceManager = _ts_decorate2([
|
|
2673
2747
|
(0, import_async9.trackLeaks)("open", "close")
|
|
2674
2748
|
], DataSpaceManager);
|
|
2675
2749
|
|
|
@@ -2678,10 +2752,12 @@ var import_async10 = require("@dxos/async");
|
|
|
2678
2752
|
var import_codec_protobuf3 = require("@dxos/codec-protobuf");
|
|
2679
2753
|
var import_debug5 = require("@dxos/debug");
|
|
2680
2754
|
var import_echo_pipeline2 = require("@dxos/echo-pipeline");
|
|
2755
|
+
var import_errors4 = require("@dxos/errors");
|
|
2681
2756
|
var import_log11 = require("@dxos/log");
|
|
2682
2757
|
var import_protocols7 = require("@dxos/protocols");
|
|
2683
2758
|
var import_services8 = require("@dxos/protocols/proto/dxos/client/services");
|
|
2684
2759
|
var import_util5 = require("@dxos/util");
|
|
2760
|
+
var __dxlog_file11 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/spaces-service.ts";
|
|
2685
2761
|
var SpacesServiceImpl = class {
|
|
2686
2762
|
constructor(_identityManager, _spaceManager, _dataServiceSubscriptions, _getDataSpaceManager) {
|
|
2687
2763
|
this._identityManager = _identityManager;
|
|
@@ -2697,8 +2773,22 @@ var SpacesServiceImpl = class {
|
|
|
2697
2773
|
const space = await dataSpaceManager.createSpace();
|
|
2698
2774
|
return this._serializeSpace(space);
|
|
2699
2775
|
}
|
|
2700
|
-
async updateSpace(
|
|
2701
|
-
|
|
2776
|
+
async updateSpace({ spaceKey, state }) {
|
|
2777
|
+
var _a;
|
|
2778
|
+
const dataSpaceManager = await this._getDataSpaceManager();
|
|
2779
|
+
const space = (_a = dataSpaceManager.spaces.get(spaceKey)) != null ? _a : (0, import_debug5.raise)(new import_echo_pipeline2.SpaceNotFoundError(spaceKey));
|
|
2780
|
+
if (state) {
|
|
2781
|
+
switch (state) {
|
|
2782
|
+
case import_services8.SpaceState.ACTIVE:
|
|
2783
|
+
await space.activate();
|
|
2784
|
+
break;
|
|
2785
|
+
case import_services8.SpaceState.INACTIVE:
|
|
2786
|
+
await space.deactivate();
|
|
2787
|
+
break;
|
|
2788
|
+
default:
|
|
2789
|
+
throw new import_errors4.ApiError("Invalid space state");
|
|
2790
|
+
}
|
|
2791
|
+
}
|
|
2702
2792
|
}
|
|
2703
2793
|
querySpaces() {
|
|
2704
2794
|
return new import_codec_protobuf3.Stream(({ next, ctx }) => {
|
|
@@ -2708,10 +2798,10 @@ var SpacesServiceImpl = class {
|
|
|
2708
2798
|
(0, import_log11.log)("update", {
|
|
2709
2799
|
spaces
|
|
2710
2800
|
}, {
|
|
2711
|
-
|
|
2712
|
-
|
|
2713
|
-
|
|
2714
|
-
|
|
2801
|
+
F: __dxlog_file11,
|
|
2802
|
+
L: 78,
|
|
2803
|
+
S: this,
|
|
2804
|
+
C: (f, a) => f(...a)
|
|
2715
2805
|
});
|
|
2716
2806
|
next({
|
|
2717
2807
|
spaces
|
|
@@ -2772,13 +2862,13 @@ var SpacesServiceImpl = class {
|
|
|
2772
2862
|
return new import_codec_protobuf3.Stream(({ ctx, next }) => {
|
|
2773
2863
|
var _a;
|
|
2774
2864
|
const space = (_a = this._spaceManager.spaces.get(spaceKey)) != null ? _a : (0, import_debug5.raise)(new import_echo_pipeline2.SpaceNotFoundError(spaceKey));
|
|
2775
|
-
const processor =
|
|
2776
|
-
|
|
2865
|
+
const processor = {
|
|
2866
|
+
processCredential: async (credential) => {
|
|
2777
2867
|
next(credential);
|
|
2778
2868
|
}
|
|
2779
|
-
}
|
|
2780
|
-
ctx.onDispose(() =>
|
|
2781
|
-
(0, import_async10.scheduleTask)(ctx, () =>
|
|
2869
|
+
};
|
|
2870
|
+
ctx.onDispose(() => space.spaceState.removeCredentialProcessor(processor));
|
|
2871
|
+
(0, import_async10.scheduleTask)(ctx, () => space.spaceState.addCredentialProcessor(processor));
|
|
2782
2872
|
});
|
|
2783
2873
|
}
|
|
2784
2874
|
async writeCredentials({ spaceKey, credentials }) {
|
|
@@ -2838,6 +2928,7 @@ var SpacesServiceImpl = class {
|
|
|
2838
2928
|
var getChannelId = (channel) => `user-channel/${channel}`;
|
|
2839
2929
|
|
|
2840
2930
|
// packages/sdk/client-services/src/packlets/services/service-context.ts
|
|
2931
|
+
var __dxlog_file12 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-context.ts";
|
|
2841
2932
|
var ServiceContext = class {
|
|
2842
2933
|
// prettier-ignore
|
|
2843
2934
|
constructor(storage, networkManager, signalManager, modelFactory) {
|
|
@@ -2881,17 +2972,17 @@ var ServiceContext = class {
|
|
|
2881
2972
|
import_log12.log.trace("dxos.sdk.service-context.open", import_protocols8.trace.begin({
|
|
2882
2973
|
id: this._instanceId
|
|
2883
2974
|
}), {
|
|
2884
|
-
|
|
2885
|
-
|
|
2886
|
-
|
|
2887
|
-
|
|
2975
|
+
F: __dxlog_file12,
|
|
2976
|
+
L: 126,
|
|
2977
|
+
S: this,
|
|
2978
|
+
C: (f, a) => f(...a)
|
|
2888
2979
|
});
|
|
2889
2980
|
await this._checkStorageVersion();
|
|
2890
|
-
(0, import_log12.log)("opening...",
|
|
2891
|
-
|
|
2892
|
-
|
|
2893
|
-
|
|
2894
|
-
|
|
2981
|
+
(0, import_log12.log)("opening...", void 0, {
|
|
2982
|
+
F: __dxlog_file12,
|
|
2983
|
+
L: 130,
|
|
2984
|
+
S: this,
|
|
2985
|
+
C: (f, a) => f(...a)
|
|
2895
2986
|
});
|
|
2896
2987
|
await this.signalManager.open();
|
|
2897
2988
|
await this.networkManager.open();
|
|
@@ -2900,42 +2991,44 @@ var ServiceContext = class {
|
|
|
2900
2991
|
if (this.identityManager.identity) {
|
|
2901
2992
|
await this._initialize();
|
|
2902
2993
|
}
|
|
2903
|
-
(0, import_log12.log)("opened",
|
|
2904
|
-
|
|
2905
|
-
|
|
2906
|
-
|
|
2907
|
-
|
|
2994
|
+
(0, import_log12.log)("opened", void 0, {
|
|
2995
|
+
F: __dxlog_file12,
|
|
2996
|
+
L: 138,
|
|
2997
|
+
S: this,
|
|
2998
|
+
C: (f, a) => f(...a)
|
|
2908
2999
|
});
|
|
2909
3000
|
import_log12.log.trace("dxos.sdk.service-context.open", import_protocols8.trace.end({
|
|
2910
3001
|
id: this._instanceId
|
|
2911
3002
|
}), {
|
|
2912
|
-
|
|
2913
|
-
|
|
2914
|
-
|
|
2915
|
-
|
|
3003
|
+
F: __dxlog_file12,
|
|
3004
|
+
L: 139,
|
|
3005
|
+
S: this,
|
|
3006
|
+
C: (f, a) => f(...a)
|
|
2916
3007
|
});
|
|
2917
3008
|
}
|
|
2918
3009
|
async close() {
|
|
2919
|
-
var _a
|
|
2920
|
-
(0, import_log12.log)("closing...",
|
|
2921
|
-
|
|
2922
|
-
|
|
2923
|
-
|
|
2924
|
-
|
|
3010
|
+
var _a;
|
|
3011
|
+
(0, import_log12.log)("closing...", void 0, {
|
|
3012
|
+
F: __dxlog_file12,
|
|
3013
|
+
L: 143,
|
|
3014
|
+
S: this,
|
|
3015
|
+
C: (f, a) => f(...a)
|
|
2925
3016
|
});
|
|
2926
|
-
|
|
2927
|
-
|
|
3017
|
+
if (this._deviceSpaceSync && this.identityManager.identity) {
|
|
3018
|
+
await this.identityManager.identity.space.spaceState.removeCredentialProcessor(this._deviceSpaceSync);
|
|
3019
|
+
}
|
|
3020
|
+
await ((_a = this.dataSpaceManager) == null ? void 0 : _a.close());
|
|
2928
3021
|
await this.identityManager.close();
|
|
2929
3022
|
await this.spaceManager.close();
|
|
2930
3023
|
await this.feedStore.close();
|
|
2931
3024
|
await this.networkManager.close();
|
|
2932
3025
|
await this.signalManager.close();
|
|
2933
3026
|
this.dataServiceSubscriptions.clear();
|
|
2934
|
-
(0, import_log12.log)("closed",
|
|
2935
|
-
|
|
2936
|
-
|
|
2937
|
-
|
|
2938
|
-
|
|
3027
|
+
(0, import_log12.log)("closed", void 0, {
|
|
3028
|
+
F: __dxlog_file12,
|
|
3029
|
+
L: 154,
|
|
3030
|
+
S: this,
|
|
3031
|
+
C: (f, a) => f(...a)
|
|
2939
3032
|
});
|
|
2940
3033
|
}
|
|
2941
3034
|
async createIdentity(params = {}) {
|
|
@@ -2945,7 +3038,7 @@ var ServiceContext = class {
|
|
|
2945
3038
|
}
|
|
2946
3039
|
getInvitationHandler(invitation) {
|
|
2947
3040
|
const factory = this._handlerFactories.get(invitation.kind);
|
|
2948
|
-
(0,
|
|
3041
|
+
(0, import_tiny_invariant11.default)(factory, `Unknown invitation kind: ${invitation.kind}`);
|
|
2949
3042
|
return factory(invitation);
|
|
2950
3043
|
}
|
|
2951
3044
|
async _acceptIdentity(params) {
|
|
@@ -2962,11 +3055,11 @@ var ServiceContext = class {
|
|
|
2962
3055
|
// Called when identity is created.
|
|
2963
3056
|
async _initialize() {
|
|
2964
3057
|
var _a;
|
|
2965
|
-
(0, import_log12.log)("initializing spaces...",
|
|
2966
|
-
|
|
2967
|
-
|
|
2968
|
-
|
|
2969
|
-
|
|
3058
|
+
(0, import_log12.log)("initializing spaces...", void 0, {
|
|
3059
|
+
F: __dxlog_file12,
|
|
3060
|
+
L: 187,
|
|
3061
|
+
S: this,
|
|
3062
|
+
C: (f, a) => f(...a)
|
|
2970
3063
|
});
|
|
2971
3064
|
const identity = (_a = this.identityManager.identity) != null ? _a : (0, import_debug6.failUndefined)();
|
|
2972
3065
|
const signingContext = {
|
|
@@ -2985,12 +3078,12 @@ var ServiceContext = class {
|
|
|
2985
3078
|
this.dataSpaceManager = new DataSpaceManager(this.spaceManager, this.metadataStore, this.dataServiceSubscriptions, this.keyring, signingContext, this.feedStore);
|
|
2986
3079
|
await this.dataSpaceManager.open();
|
|
2987
3080
|
this._handlerFactories.set(import_services9.Invitation.Kind.SPACE, (invitation) => {
|
|
2988
|
-
(0,
|
|
3081
|
+
(0, import_tiny_invariant11.default)(this.dataSpaceManager, "dataSpaceManager not initialized yet");
|
|
2989
3082
|
return new SpaceInvitationProtocol(this.dataSpaceManager, signingContext, this.keyring, invitation.spaceKey);
|
|
2990
3083
|
});
|
|
2991
3084
|
this.initialized.wake();
|
|
2992
|
-
this._deviceSpaceSync =
|
|
2993
|
-
|
|
3085
|
+
this._deviceSpaceSync = {
|
|
3086
|
+
processCredential: async (credential) => {
|
|
2994
3087
|
const assertion = (0, import_credentials14.getCredentialAssertion)(credential);
|
|
2995
3088
|
if (assertion["@type"] !== "dxos.halo.credentials.SpaceMember") {
|
|
2996
3089
|
return;
|
|
@@ -3002,10 +3095,10 @@ var ServiceContext = class {
|
|
|
3002
3095
|
(0, import_log12.log)("dataSpaceManager not initialized yet, ignoring space admission", {
|
|
3003
3096
|
details: assertion
|
|
3004
3097
|
}, {
|
|
3005
|
-
|
|
3006
|
-
|
|
3007
|
-
|
|
3008
|
-
|
|
3098
|
+
F: __dxlog_file12,
|
|
3099
|
+
L: 226,
|
|
3100
|
+
S: this,
|
|
3101
|
+
C: (f, a) => f(...a)
|
|
3009
3102
|
});
|
|
3010
3103
|
return;
|
|
3011
3104
|
}
|
|
@@ -3013,10 +3106,10 @@ var ServiceContext = class {
|
|
|
3013
3106
|
(0, import_log12.log)("space already exists, ignoring space admission", {
|
|
3014
3107
|
details: assertion
|
|
3015
3108
|
}, {
|
|
3016
|
-
|
|
3017
|
-
|
|
3018
|
-
|
|
3019
|
-
|
|
3109
|
+
F: __dxlog_file12,
|
|
3110
|
+
L: 230,
|
|
3111
|
+
S: this,
|
|
3112
|
+
C: (f, a) => f(...a)
|
|
3020
3113
|
});
|
|
3021
3114
|
return;
|
|
3022
3115
|
}
|
|
@@ -3024,40 +3117,43 @@ var ServiceContext = class {
|
|
|
3024
3117
|
(0, import_log12.log)("accepting space recorded in halo", {
|
|
3025
3118
|
details: assertion
|
|
3026
3119
|
}, {
|
|
3027
|
-
|
|
3028
|
-
|
|
3029
|
-
|
|
3030
|
-
|
|
3120
|
+
F: __dxlog_file12,
|
|
3121
|
+
L: 235,
|
|
3122
|
+
S: this,
|
|
3123
|
+
C: (f, a) => f(...a)
|
|
3031
3124
|
});
|
|
3032
3125
|
await this.dataSpaceManager.acceptSpace({
|
|
3033
3126
|
spaceKey: assertion.spaceKey,
|
|
3034
3127
|
genesisFeedKey: assertion.genesisFeedKey
|
|
3035
3128
|
});
|
|
3036
3129
|
} catch (err) {
|
|
3037
|
-
import_log12.log.catch(err,
|
|
3038
|
-
|
|
3039
|
-
|
|
3040
|
-
|
|
3041
|
-
|
|
3130
|
+
import_log12.log.catch(err, void 0, {
|
|
3131
|
+
F: __dxlog_file12,
|
|
3132
|
+
L: 241,
|
|
3133
|
+
S: this,
|
|
3134
|
+
C: (f, a) => f(...a)
|
|
3042
3135
|
});
|
|
3043
3136
|
}
|
|
3044
3137
|
}
|
|
3045
|
-
}
|
|
3046
|
-
await this._deviceSpaceSync
|
|
3138
|
+
};
|
|
3139
|
+
await identity.space.spaceState.addCredentialProcessor(this._deviceSpaceSync);
|
|
3047
3140
|
}
|
|
3048
3141
|
};
|
|
3049
3142
|
|
|
3050
3143
|
// packages/sdk/client-services/src/packlets/services/service-host.ts
|
|
3051
|
-
var
|
|
3144
|
+
var import_tiny_invariant13 = __toESM(require("tiny-invariant"));
|
|
3052
3145
|
var import_async17 = require("@dxos/async");
|
|
3053
3146
|
var import_client_protocol5 = require("@dxos/client-protocol");
|
|
3147
|
+
var import_document_model = require("@dxos/document-model");
|
|
3054
3148
|
var import_echo_pipeline4 = require("@dxos/echo-pipeline");
|
|
3055
3149
|
var import_keys12 = require("@dxos/keys");
|
|
3056
3150
|
var import_log15 = require("@dxos/log");
|
|
3057
3151
|
var import_messaging = require("@dxos/messaging");
|
|
3152
|
+
var import_model_factory = require("@dxos/model-factory");
|
|
3058
3153
|
var import_network_manager2 = require("@dxos/network-manager");
|
|
3059
3154
|
var import_protocols9 = require("@dxos/protocols");
|
|
3060
3155
|
var import_services12 = require("@dxos/protocols/proto/dxos/client/services");
|
|
3156
|
+
var import_text_model = require("@dxos/text-model");
|
|
3061
3157
|
|
|
3062
3158
|
// packages/sdk/client-services/src/packlets/devices/devices-service.ts
|
|
3063
3159
|
var import_async12 = require("@dxos/async");
|
|
@@ -3420,10 +3516,10 @@ var DevtoolsServiceImpl = class {
|
|
|
3420
3516
|
};
|
|
3421
3517
|
|
|
3422
3518
|
// packages/sdk/client-services/src/packlets/locks/node.ts
|
|
3423
|
-
var
|
|
3519
|
+
var import_tiny_invariant12 = __toESM(require("tiny-invariant"));
|
|
3424
3520
|
var import_lock_file = require("@dxos/lock-file");
|
|
3425
3521
|
var import_log13 = require("@dxos/log");
|
|
3426
|
-
|
|
3522
|
+
function _ts_decorate3(decorators, target, key, desc) {
|
|
3427
3523
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3428
3524
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
3429
3525
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -3432,7 +3528,8 @@ var __decorate3 = function(decorators, target, key, desc) {
|
|
|
3432
3528
|
if (d = decorators[i])
|
|
3433
3529
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
3434
3530
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3435
|
-
}
|
|
3531
|
+
}
|
|
3532
|
+
var __dxlog_file13 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/locks/node.ts";
|
|
3436
3533
|
var Lock = class {
|
|
3437
3534
|
constructor({ lockKey: lockPath, onAcquire, onRelease }) {
|
|
3438
3535
|
this._lockPath = lockPath;
|
|
@@ -3444,29 +3541,29 @@ var Lock = class {
|
|
|
3444
3541
|
}
|
|
3445
3542
|
async acquire() {
|
|
3446
3543
|
var _a;
|
|
3447
|
-
(0, import_log13.log)("acquiring lock...",
|
|
3448
|
-
|
|
3449
|
-
|
|
3450
|
-
|
|
3451
|
-
|
|
3544
|
+
(0, import_log13.log)("acquiring lock...", void 0, {
|
|
3545
|
+
F: __dxlog_file13,
|
|
3546
|
+
L: 32,
|
|
3547
|
+
S: this,
|
|
3548
|
+
C: (f, a) => f(...a)
|
|
3452
3549
|
});
|
|
3453
3550
|
this._fileHandle = await import_lock_file.LockFile.acquire(this._lockPath);
|
|
3454
3551
|
await ((_a = this._onAcquire) == null ? void 0 : _a.call(this));
|
|
3455
|
-
(0, import_log13.log)("acquired lock",
|
|
3456
|
-
|
|
3457
|
-
|
|
3458
|
-
|
|
3459
|
-
|
|
3552
|
+
(0, import_log13.log)("acquired lock", void 0, {
|
|
3553
|
+
F: __dxlog_file13,
|
|
3554
|
+
L: 37,
|
|
3555
|
+
S: this,
|
|
3556
|
+
C: (f, a) => f(...a)
|
|
3460
3557
|
});
|
|
3461
3558
|
}
|
|
3462
3559
|
async release() {
|
|
3463
3560
|
var _a;
|
|
3464
3561
|
await ((_a = this._onRelease) == null ? void 0 : _a.call(this));
|
|
3465
|
-
(0,
|
|
3562
|
+
(0, import_tiny_invariant12.default)(this._fileHandle, "Lock is not acquired");
|
|
3466
3563
|
await import_lock_file.LockFile.release(this._fileHandle);
|
|
3467
3564
|
}
|
|
3468
3565
|
};
|
|
3469
|
-
|
|
3566
|
+
_ts_decorate3([
|
|
3470
3567
|
import_log13.logInfo
|
|
3471
3568
|
], Lock.prototype, "lockKey", null);
|
|
3472
3569
|
|
|
@@ -3497,7 +3594,7 @@ var LoggingServiceImpl = class {
|
|
|
3497
3594
|
if (LOG_PROCESSING > 0) {
|
|
3498
3595
|
return;
|
|
3499
3596
|
}
|
|
3500
|
-
if (((_a = entry2.meta) == null ? void 0 : _a.
|
|
3597
|
+
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
3598
|
return;
|
|
3502
3599
|
}
|
|
3503
3600
|
if (!shouldLog(entry2, request)) {
|
|
@@ -3509,8 +3606,8 @@ var LoggingServiceImpl = class {
|
|
|
3509
3606
|
timestamp: new Date(),
|
|
3510
3607
|
meta: {
|
|
3511
3608
|
// TODO(dmaretskyi): Fix proto.
|
|
3512
|
-
file: (_c = (_b = entry2.meta) == null ? void 0 : _b.
|
|
3513
|
-
line: (_e = (_d = entry2.meta) == null ? void 0 : _d.
|
|
3609
|
+
file: (_c = (_b = entry2.meta) == null ? void 0 : _b.F) != null ? _c : "",
|
|
3610
|
+
line: (_e = (_d = entry2.meta) == null ? void 0 : _d.L) != null ? _e : 0
|
|
3514
3611
|
}
|
|
3515
3612
|
};
|
|
3516
3613
|
try {
|
|
@@ -3540,7 +3637,7 @@ var shouldLog = (entry2, request) => {
|
|
|
3540
3637
|
} else {
|
|
3541
3638
|
return request.filters.some((filter) => {
|
|
3542
3639
|
var _a2, _b;
|
|
3543
|
-
return matchFilter(filter, entry2.level, (_b = (_a2 = entry2.meta) == null ? void 0 : _a2.
|
|
3640
|
+
return matchFilter(filter, entry2.level, (_b = (_a2 = entry2.meta) == null ? void 0 : _a2.F) != null ? _b : "", options);
|
|
3544
3641
|
});
|
|
3545
3642
|
}
|
|
3546
3643
|
};
|
|
@@ -3580,7 +3677,7 @@ var NetworkServiceImpl = class {
|
|
|
3580
3677
|
|
|
3581
3678
|
// packages/sdk/client-services/src/packlets/storage/storage.ts
|
|
3582
3679
|
var import_client_protocol4 = require("@dxos/client-protocol");
|
|
3583
|
-
var
|
|
3680
|
+
var import_errors5 = require("@dxos/errors");
|
|
3584
3681
|
var import_config = require("@dxos/protocols/proto/dxos/config");
|
|
3585
3682
|
var import_random_access_storage = require("@dxos/random-access-storage");
|
|
3586
3683
|
var import_util8 = require("@dxos/util");
|
|
@@ -3588,16 +3685,16 @@ var StorageDriver = import_config.Runtime.Client.Storage.StorageDriver;
|
|
|
3588
3685
|
var createStorageObjects = (config) => {
|
|
3589
3686
|
const { path = (0, import_util8.isNode)() ? import_client_protocol4.DX_DATA : "dxos/storage", storageType, keyStorage, persistent = false } = config != null ? config : {};
|
|
3590
3687
|
if (persistent && storageType === StorageDriver.RAM) {
|
|
3591
|
-
throw new
|
|
3688
|
+
throw new import_errors5.InvalidConfigError("RAM storage cannot be used in persistent mode.");
|
|
3592
3689
|
}
|
|
3593
3690
|
if (!persistent && storageType !== void 0 && storageType !== StorageDriver.RAM) {
|
|
3594
|
-
throw new
|
|
3691
|
+
throw new import_errors5.InvalidConfigError("Cannot use a persistent storage in not persistent mode.");
|
|
3595
3692
|
}
|
|
3596
3693
|
if (persistent && keyStorage === StorageDriver.RAM) {
|
|
3597
|
-
throw new
|
|
3694
|
+
throw new import_errors5.InvalidConfigError("RAM key storage cannot be used in persistent mode.");
|
|
3598
3695
|
}
|
|
3599
3696
|
if (!persistent && keyStorage !== StorageDriver.RAM && keyStorage !== void 0) {
|
|
3600
|
-
throw new
|
|
3697
|
+
throw new import_errors5.InvalidConfigError("Cannot use a persistent key storage in not persistent mode.");
|
|
3601
3698
|
}
|
|
3602
3699
|
return {
|
|
3603
3700
|
storage: (0, import_random_access_storage.createStorage)({
|
|
@@ -3690,7 +3787,7 @@ var ServiceRegistry = class {
|
|
|
3690
3787
|
};
|
|
3691
3788
|
|
|
3692
3789
|
// packages/sdk/client-services/src/packlets/services/service-host.ts
|
|
3693
|
-
|
|
3790
|
+
function _ts_decorate4(decorators, target, key, desc) {
|
|
3694
3791
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3695
3792
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
3696
3793
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -3699,24 +3796,30 @@ var __decorate4 = function(decorators, target, key, desc) {
|
|
|
3699
3796
|
if (d = decorators[i])
|
|
3700
3797
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
3701
3798
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3799
|
+
}
|
|
3800
|
+
var __dxlog_file14 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-host.ts";
|
|
3801
|
+
var createDefaultModelFactory = () => {
|
|
3802
|
+
return new import_model_factory.ModelFactory().registerModel(import_document_model.DocumentModel).registerModel(import_text_model.TextModel);
|
|
3702
3803
|
};
|
|
3703
3804
|
var ClientServicesHost = class {
|
|
3704
3805
|
constructor({
|
|
3705
3806
|
config,
|
|
3706
|
-
modelFactory =
|
|
3807
|
+
modelFactory = createDefaultModelFactory(),
|
|
3707
3808
|
// TODO(burdon): Create ApolloLink abstraction (see Client).
|
|
3708
3809
|
transportFactory,
|
|
3709
3810
|
signalManager,
|
|
3710
3811
|
connectionLog,
|
|
3711
3812
|
storage,
|
|
3712
3813
|
// TODO(wittjosiah): Turn this on by default.
|
|
3713
|
-
lockKey
|
|
3814
|
+
lockKey,
|
|
3815
|
+
callbacks
|
|
3714
3816
|
} = {}) {
|
|
3715
3817
|
this._statusUpdate = new import_async17.Event();
|
|
3716
3818
|
this._opening = false;
|
|
3717
3819
|
this._open = false;
|
|
3718
3820
|
this._storage = storage;
|
|
3719
3821
|
this._modelFactory = modelFactory;
|
|
3822
|
+
this._callbacks = callbacks;
|
|
3720
3823
|
if (config) {
|
|
3721
3824
|
this.initialize({
|
|
3722
3825
|
config,
|
|
@@ -3775,9 +3878,9 @@ var ClientServicesHost = class {
|
|
|
3775
3878
|
*/
|
|
3776
3879
|
initialize({ config, ...options }) {
|
|
3777
3880
|
var _a, _b, _c;
|
|
3778
|
-
(0,
|
|
3881
|
+
(0, import_tiny_invariant13.default)(!this._open, "service host is open");
|
|
3779
3882
|
if (config) {
|
|
3780
|
-
(0,
|
|
3883
|
+
(0, import_tiny_invariant13.default)(!this._config, "config already set");
|
|
3781
3884
|
this._config = config;
|
|
3782
3885
|
if (!this._storage) {
|
|
3783
3886
|
this._storage = createStorageObjects(config.get("runtime.client.storage", {})).storage;
|
|
@@ -3787,7 +3890,7 @@ var ClientServicesHost = class {
|
|
|
3787
3890
|
iceServers: (_a = this._config) == null ? void 0 : _a.get("runtime.services.ice")
|
|
3788
3891
|
}), signalManager = new import_messaging.WebsocketSignalManager((_c = (_b = this._config) == null ? void 0 : _b.get("runtime.services.signaling")) != null ? _c : []) } = options;
|
|
3789
3892
|
this._signalManager = signalManager;
|
|
3790
|
-
(0,
|
|
3893
|
+
(0, import_tiny_invariant13.default)(!this._networkManager, "network manager already set");
|
|
3791
3894
|
this._networkManager = new import_network_manager2.NetworkManager({
|
|
3792
3895
|
log: connectionLog,
|
|
3793
3896
|
transportFactory,
|
|
@@ -3803,23 +3906,23 @@ var ClientServicesHost = class {
|
|
|
3803
3906
|
import_log15.log.trace("dxos.sdk.client-services-host.open", import_protocols9.trace.begin({
|
|
3804
3907
|
id: traceId
|
|
3805
3908
|
}), {
|
|
3806
|
-
|
|
3807
|
-
|
|
3808
|
-
|
|
3809
|
-
|
|
3909
|
+
F: __dxlog_file14,
|
|
3910
|
+
L: 203,
|
|
3911
|
+
S: this,
|
|
3912
|
+
C: (f, a) => f(...a)
|
|
3810
3913
|
});
|
|
3811
|
-
(0,
|
|
3812
|
-
(0,
|
|
3813
|
-
(0,
|
|
3814
|
-
(0,
|
|
3914
|
+
(0, import_tiny_invariant13.default)(this._config, "config not set");
|
|
3915
|
+
(0, import_tiny_invariant13.default)(this._storage, "storage not set");
|
|
3916
|
+
(0, import_tiny_invariant13.default)(this._signalManager, "signal manager not set");
|
|
3917
|
+
(0, import_tiny_invariant13.default)(this._networkManager, "network manager not set");
|
|
3815
3918
|
this._opening = true;
|
|
3816
3919
|
(0, import_log15.log)("opening...", {
|
|
3817
3920
|
lockKey: (_a = this._resourceLock) == null ? void 0 : _a.lockKey
|
|
3818
3921
|
}, {
|
|
3819
|
-
|
|
3820
|
-
|
|
3821
|
-
|
|
3822
|
-
|
|
3922
|
+
F: __dxlog_file14,
|
|
3923
|
+
L: 211,
|
|
3924
|
+
S: this,
|
|
3925
|
+
C: (f, a) => f(...a)
|
|
3823
3926
|
});
|
|
3824
3927
|
await ((_b = this._resourceLock) == null ? void 0 : _b.acquire());
|
|
3825
3928
|
await this._loggingService.open();
|
|
@@ -3851,18 +3954,18 @@ var ClientServicesHost = class {
|
|
|
3851
3954
|
(0, import_log15.log)("opened", {
|
|
3852
3955
|
deviceKey
|
|
3853
3956
|
}, {
|
|
3854
|
-
|
|
3855
|
-
|
|
3856
|
-
|
|
3857
|
-
|
|
3957
|
+
F: __dxlog_file14,
|
|
3958
|
+
L: 266,
|
|
3959
|
+
S: this,
|
|
3960
|
+
C: (f, a) => f(...a)
|
|
3858
3961
|
});
|
|
3859
3962
|
import_log15.log.trace("dxos.sdk.client-services-host.open", import_protocols9.trace.end({
|
|
3860
3963
|
id: traceId
|
|
3861
3964
|
}), {
|
|
3862
|
-
|
|
3863
|
-
|
|
3864
|
-
|
|
3865
|
-
|
|
3965
|
+
F: __dxlog_file14,
|
|
3966
|
+
L: 267,
|
|
3967
|
+
S: this,
|
|
3968
|
+
C: (f, a) => f(...a)
|
|
3866
3969
|
});
|
|
3867
3970
|
}
|
|
3868
3971
|
async close() {
|
|
@@ -3874,10 +3977,10 @@ var ClientServicesHost = class {
|
|
|
3874
3977
|
(0, import_log15.log)("closing...", {
|
|
3875
3978
|
deviceKey
|
|
3876
3979
|
}, {
|
|
3877
|
-
|
|
3878
|
-
|
|
3879
|
-
|
|
3880
|
-
|
|
3980
|
+
F: __dxlog_file14,
|
|
3981
|
+
L: 277,
|
|
3982
|
+
S: this,
|
|
3983
|
+
C: (f, a) => f(...a)
|
|
3881
3984
|
});
|
|
3882
3985
|
this._serviceRegistry.setServices({
|
|
3883
3986
|
SystemService: this._systemService
|
|
@@ -3889,51 +3992,52 @@ var ClientServicesHost = class {
|
|
|
3889
3992
|
(0, import_log15.log)("closed", {
|
|
3890
3993
|
deviceKey
|
|
3891
3994
|
}, {
|
|
3892
|
-
|
|
3893
|
-
|
|
3894
|
-
|
|
3895
|
-
|
|
3995
|
+
F: __dxlog_file14,
|
|
3996
|
+
L: 283,
|
|
3997
|
+
S: this,
|
|
3998
|
+
C: (f, a) => f(...a)
|
|
3896
3999
|
});
|
|
3897
4000
|
}
|
|
3898
4001
|
async reset() {
|
|
3899
|
-
var _a;
|
|
4002
|
+
var _a, _b, _c;
|
|
3900
4003
|
const traceId = import_keys12.PublicKey.random().toHex();
|
|
3901
4004
|
import_log15.log.trace("dxos.sdk.client-services-host.reset", import_protocols9.trace.begin({
|
|
3902
4005
|
id: traceId
|
|
3903
4006
|
}), {
|
|
3904
|
-
|
|
3905
|
-
|
|
3906
|
-
|
|
3907
|
-
|
|
4007
|
+
F: __dxlog_file14,
|
|
4008
|
+
L: 288,
|
|
4009
|
+
S: this,
|
|
4010
|
+
C: (f, a) => f(...a)
|
|
3908
4011
|
});
|
|
3909
|
-
(0, import_log15.log)("resetting...",
|
|
3910
|
-
|
|
3911
|
-
|
|
3912
|
-
|
|
3913
|
-
|
|
4012
|
+
(0, import_log15.log)("resetting...", void 0, {
|
|
4013
|
+
F: __dxlog_file14,
|
|
4014
|
+
L: 290,
|
|
4015
|
+
S: this,
|
|
4016
|
+
C: (f, a) => f(...a)
|
|
3914
4017
|
});
|
|
3915
4018
|
await ((_a = this._serviceContext) == null ? void 0 : _a.close());
|
|
3916
4019
|
await this._storage.reset();
|
|
3917
|
-
(0, import_log15.log)("reset",
|
|
3918
|
-
|
|
3919
|
-
|
|
3920
|
-
|
|
3921
|
-
|
|
4020
|
+
(0, import_log15.log)("reset", void 0, {
|
|
4021
|
+
F: __dxlog_file14,
|
|
4022
|
+
L: 293,
|
|
4023
|
+
S: this,
|
|
4024
|
+
C: (f, a) => f(...a)
|
|
3922
4025
|
});
|
|
3923
4026
|
import_log15.log.trace("dxos.sdk.client-services-host.reset", import_protocols9.trace.end({
|
|
3924
4027
|
id: traceId
|
|
3925
4028
|
}), {
|
|
3926
|
-
|
|
3927
|
-
|
|
3928
|
-
|
|
3929
|
-
|
|
4029
|
+
F: __dxlog_file14,
|
|
4030
|
+
L: 294,
|
|
4031
|
+
S: this,
|
|
4032
|
+
C: (f, a) => f(...a)
|
|
3930
4033
|
});
|
|
4034
|
+
await ((_c = (_b = this._callbacks) == null ? void 0 : _b.onReset) == null ? void 0 : _c.call(_b));
|
|
3931
4035
|
}
|
|
3932
4036
|
};
|
|
3933
|
-
|
|
4037
|
+
_ts_decorate4([
|
|
3934
4038
|
import_async17.synchronized
|
|
3935
4039
|
], ClientServicesHost.prototype, "open", null);
|
|
3936
|
-
|
|
4040
|
+
_ts_decorate4([
|
|
3937
4041
|
import_async17.synchronized
|
|
3938
4042
|
], ClientServicesHost.prototype, "close", null);
|
|
3939
4043
|
|
|
@@ -3969,7 +4073,7 @@ var performInvitation = ({ host, guest, options, hooks }) => {
|
|
|
3969
4073
|
if ((_b2 = (_a2 = hooks == null ? void 0 : hooks.guest) == null ? void 0 : _a2.onConnecting) == null ? void 0 : _b2.call(_a2, guestObservable)) {
|
|
3970
4074
|
break;
|
|
3971
4075
|
}
|
|
3972
|
-
(0,
|
|
4076
|
+
(0, import_tiny_invariant14.default)(hostInvitation.swarmKey.equals(guestInvitation.swarmKey));
|
|
3973
4077
|
break;
|
|
3974
4078
|
}
|
|
3975
4079
|
case import_services13.Invitation.State.CONNECTED: {
|
|
@@ -4110,9 +4214,9 @@ var acceptInvitation = (guest, invitation) => {
|
|
|
4110
4214
|
};
|
|
4111
4215
|
|
|
4112
4216
|
// packages/sdk/client-services/src/packlets/testing/test-builder.ts
|
|
4113
|
-
var import_client_protocol6 = require("@dxos/client-protocol");
|
|
4114
4217
|
var import_context8 = require("@dxos/context");
|
|
4115
4218
|
var import_credentials15 = require("@dxos/credentials");
|
|
4219
|
+
var import_debug7 = require("@dxos/debug");
|
|
4116
4220
|
var import_echo_pipeline5 = require("@dxos/echo-pipeline");
|
|
4117
4221
|
var import_testing = require("@dxos/echo-pipeline/testing");
|
|
4118
4222
|
var import_feed_store5 = require("@dxos/feed-store");
|
|
@@ -4136,7 +4240,7 @@ var createServiceContext = ({ signalContext = new import_messaging2.MemorySignal
|
|
|
4136
4240
|
signalManager,
|
|
4137
4241
|
transportFactory: import_network_manager3.MemoryTransportFactory
|
|
4138
4242
|
});
|
|
4139
|
-
const modelFactory =
|
|
4243
|
+
const modelFactory = createDefaultModelFactory();
|
|
4140
4244
|
return new ServiceContext(storage, networkManager, signalManager, modelFactory);
|
|
4141
4245
|
};
|
|
4142
4246
|
var createPeers = async (numPeers) => {
|
|
@@ -4179,6 +4283,9 @@ var TestPeer = class {
|
|
|
4179
4283
|
this.opts = opts;
|
|
4180
4284
|
this._props = {};
|
|
4181
4285
|
}
|
|
4286
|
+
get props() {
|
|
4287
|
+
return this._props;
|
|
4288
|
+
}
|
|
4182
4289
|
get storage() {
|
|
4183
4290
|
var _a, _b;
|
|
4184
4291
|
return (_b = (_a = this._props).storage) != null ? _b : _a.storage = (0, import_random_access_storage2.createStorage)({
|
|
@@ -4226,11 +4333,23 @@ var TestPeer = class {
|
|
|
4226
4333
|
feedStore: this.feedStore,
|
|
4227
4334
|
networkManager: this.networkManager,
|
|
4228
4335
|
metadataStore: this.metadataStore,
|
|
4229
|
-
modelFactory:
|
|
4336
|
+
modelFactory: createDefaultModelFactory(),
|
|
4230
4337
|
snapshotStore: this.snapshotStore,
|
|
4231
4338
|
blobStore: this.blobStore
|
|
4232
4339
|
});
|
|
4233
4340
|
}
|
|
4341
|
+
get identity() {
|
|
4342
|
+
var _a;
|
|
4343
|
+
return (_a = this._props.signingContext) != null ? _a : (0, import_debug7.failUndefined)();
|
|
4344
|
+
}
|
|
4345
|
+
get dataSpaceManager() {
|
|
4346
|
+
var _a, _b;
|
|
4347
|
+
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);
|
|
4348
|
+
}
|
|
4349
|
+
async createIdentity() {
|
|
4350
|
+
var _a, _b;
|
|
4351
|
+
(_b = (_a = this._props).signingContext) != null ? _b : _a.signingContext = await createSigningContext(this.keyring);
|
|
4352
|
+
}
|
|
4234
4353
|
async destroy() {
|
|
4235
4354
|
await this.storage.reset();
|
|
4236
4355
|
}
|