@dxos/client-services 0.1.52 → 0.1.53-main.01c99c0
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-C3SPTMW3.mjs → chunk-3EI4PM2V.mjs} +820 -696
- 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 +887 -784
- 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 +804 -666
- package/dist/lib/node/packlets/testing/index.cjs.map +3 -3
- package/dist/types/src/packlets/devtools/devtools.d.ts.map +1 -1
- 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 +2 -2
- 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/devtools/devtools.ts +2 -2
- 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 +28 -10
- 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 +46 -32
- 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-C3SPTMW3.mjs.map +0 -7
package/dist/lib/node/index.cjs
CHANGED
|
@@ -44,7 +44,6 @@ __export(src_exports, {
|
|
|
44
44
|
InvitationsHandler: () => InvitationsHandler,
|
|
45
45
|
InvitationsServiceImpl: () => InvitationsServiceImpl,
|
|
46
46
|
Lock: () => Lock,
|
|
47
|
-
MemoryShellRuntime: () => MemoryShellRuntime,
|
|
48
47
|
ServiceContext: () => ServiceContext,
|
|
49
48
|
ServiceRegistry: () => ServiceRegistry,
|
|
50
49
|
ShellRuntimeImpl: () => ShellRuntimeImpl,
|
|
@@ -54,6 +53,7 @@ __export(src_exports, {
|
|
|
54
53
|
WorkerRuntime: () => WorkerRuntime,
|
|
55
54
|
WorkerSession: () => WorkerSession,
|
|
56
55
|
createAuthProvider: () => createAuthProvider,
|
|
56
|
+
createDefaultModelFactory: () => createDefaultModelFactory,
|
|
57
57
|
createStorageObjects: () => createStorageObjects,
|
|
58
58
|
getNetworkPeers: () => getNetworkPeers,
|
|
59
59
|
isLocked: () => isLocked,
|
|
@@ -315,8 +315,10 @@ var DevtoolsServiceImpl = class {
|
|
|
315
315
|
});
|
|
316
316
|
});
|
|
317
317
|
}
|
|
318
|
-
getConfig(request) {
|
|
319
|
-
|
|
318
|
+
async getConfig(request) {
|
|
319
|
+
return {
|
|
320
|
+
config: JSON.stringify(this.params.config.values)
|
|
321
|
+
};
|
|
320
322
|
}
|
|
321
323
|
async getStorageInfo() {
|
|
322
324
|
var _a, _b, _c, _d, _e;
|
|
@@ -417,6 +419,8 @@ var import_context2 = require("@dxos/context");
|
|
|
417
419
|
var import_credentials = require("@dxos/credentials");
|
|
418
420
|
var import_log = require("@dxos/log");
|
|
419
421
|
var import_protocols = require("@dxos/protocols");
|
|
422
|
+
var __dxlog_file = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/authenticator.ts";
|
|
423
|
+
var Credential = import_protocols.schema.getCodecForType("dxos.halo.credentials.Credential");
|
|
420
424
|
var createAuthProvider = (signer) => async (nonce) => {
|
|
421
425
|
const credential = await signer.createCredential({
|
|
422
426
|
assertion: {
|
|
@@ -425,7 +429,7 @@ var createAuthProvider = (signer) => async (nonce) => {
|
|
|
425
429
|
subject: signer.getIssuer(),
|
|
426
430
|
nonce
|
|
427
431
|
});
|
|
428
|
-
return
|
|
432
|
+
return Credential.encode(credential);
|
|
429
433
|
};
|
|
430
434
|
var TrustedKeySetAuthVerifier = class {
|
|
431
435
|
// prettier-ignore
|
|
@@ -438,24 +442,24 @@ var TrustedKeySetAuthVerifier = class {
|
|
|
438
442
|
}
|
|
439
443
|
get verifier() {
|
|
440
444
|
return async (nonce, auth) => {
|
|
441
|
-
const credential =
|
|
445
|
+
const credential = Credential.decode(auth);
|
|
442
446
|
(0, import_log.log)("authenticating...", {
|
|
443
447
|
credential
|
|
444
448
|
}, {
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
+
F: __dxlog_file,
|
|
450
|
+
L: 59,
|
|
451
|
+
S: this,
|
|
452
|
+
C: (f, a) => f(...a)
|
|
449
453
|
});
|
|
450
454
|
const result = await (0, import_credentials.verifyCredential)(credential);
|
|
451
455
|
if (result.kind === "fail") {
|
|
452
456
|
(0, import_log.log)("Invalid credential", {
|
|
453
457
|
result
|
|
454
458
|
}, {
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
+
F: __dxlog_file,
|
|
460
|
+
L: 63,
|
|
461
|
+
S: this,
|
|
462
|
+
C: (f, a) => f(...a)
|
|
459
463
|
});
|
|
460
464
|
return false;
|
|
461
465
|
}
|
|
@@ -464,10 +468,10 @@ var TrustedKeySetAuthVerifier = class {
|
|
|
464
468
|
nonce,
|
|
465
469
|
credential
|
|
466
470
|
}, {
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
+
F: __dxlog_file,
|
|
472
|
+
L: 68,
|
|
473
|
+
S: this,
|
|
474
|
+
C: (f, a) => f(...a)
|
|
471
475
|
});
|
|
472
476
|
return false;
|
|
473
477
|
}
|
|
@@ -475,10 +479,10 @@ var TrustedKeySetAuthVerifier = class {
|
|
|
475
479
|
(0, import_log.log)("key is not currently in trusted set, waiting...", {
|
|
476
480
|
key: credential.issuer
|
|
477
481
|
}, {
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
+
F: __dxlog_file,
|
|
483
|
+
L: 73,
|
|
484
|
+
S: this,
|
|
485
|
+
C: (f, a) => f(...a)
|
|
482
486
|
});
|
|
483
487
|
return true;
|
|
484
488
|
}
|
|
@@ -491,20 +495,20 @@ var TrustedKeySetAuthVerifier = class {
|
|
|
491
495
|
(0, import_log.log)("auth success", {
|
|
492
496
|
key: credential.issuer
|
|
493
497
|
}, {
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
+
F: __dxlog_file,
|
|
499
|
+
L: 84,
|
|
500
|
+
S: this,
|
|
501
|
+
C: (f, a) => f(...a)
|
|
498
502
|
});
|
|
499
503
|
trigger.wake(true);
|
|
500
504
|
} else {
|
|
501
505
|
(0, import_log.log)("key is not currently in trusted set, waiting...", {
|
|
502
506
|
key: credential.issuer
|
|
503
507
|
}, {
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
+
F: __dxlog_file,
|
|
509
|
+
L: 87,
|
|
510
|
+
S: this,
|
|
511
|
+
C: (f, a) => f(...a)
|
|
508
512
|
});
|
|
509
513
|
}
|
|
510
514
|
});
|
|
@@ -526,7 +530,7 @@ var TrustedKeySetAuthVerifier = class {
|
|
|
526
530
|
};
|
|
527
531
|
|
|
528
532
|
// packages/sdk/client-services/src/packlets/identity/identity.ts
|
|
529
|
-
var
|
|
533
|
+
var import_tiny_invariant = __toESM(require("tiny-invariant"));
|
|
530
534
|
var import_async5 = require("@dxos/async");
|
|
531
535
|
var import_client_protocol = require("@dxos/client-protocol");
|
|
532
536
|
var import_credentials2 = require("@dxos/credentials");
|
|
@@ -534,6 +538,7 @@ var import_debug = require("@dxos/debug");
|
|
|
534
538
|
var import_feed_store2 = require("@dxos/feed-store");
|
|
535
539
|
var import_log2 = require("@dxos/log");
|
|
536
540
|
var import_credentials3 = require("@dxos/protocols/proto/dxos/halo/credentials");
|
|
541
|
+
var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/identity.ts";
|
|
537
542
|
var Identity = class {
|
|
538
543
|
constructor({ space, signer, identityKey, deviceKey }) {
|
|
539
544
|
this.stateUpdate = new import_async5.Event();
|
|
@@ -541,15 +546,15 @@ var Identity = class {
|
|
|
541
546
|
this._signer = signer;
|
|
542
547
|
this.identityKey = identityKey;
|
|
543
548
|
this.deviceKey = deviceKey;
|
|
544
|
-
this._deviceStateMachine =
|
|
549
|
+
this._deviceStateMachine = new import_credentials2.DeviceStateMachine({
|
|
545
550
|
identityKey: this.identityKey,
|
|
546
551
|
deviceKey: this.deviceKey,
|
|
547
552
|
onUpdate: () => this.stateUpdate.emit()
|
|
548
|
-
})
|
|
549
|
-
this._profileStateMachine =
|
|
553
|
+
});
|
|
554
|
+
this._profileStateMachine = new import_credentials2.ProfileStateMachine({
|
|
550
555
|
identityKey: this.identityKey,
|
|
551
556
|
onUpdate: () => this.stateUpdate.emit()
|
|
552
|
-
})
|
|
557
|
+
});
|
|
553
558
|
this.authVerifier = new TrustedKeySetAuthVerifier({
|
|
554
559
|
trustedKeysProvider: () => this.authorizedDeviceKeys,
|
|
555
560
|
update: this.stateUpdate,
|
|
@@ -558,27 +563,27 @@ var Identity = class {
|
|
|
558
563
|
}
|
|
559
564
|
// TODO(burdon): Expose state object?
|
|
560
565
|
get authorizedDeviceKeys() {
|
|
561
|
-
return this._deviceStateMachine.
|
|
566
|
+
return this._deviceStateMachine.authorizedDeviceKeys;
|
|
562
567
|
}
|
|
563
568
|
async open() {
|
|
564
|
-
await this.
|
|
565
|
-
await this.
|
|
569
|
+
await this.space.spaceState.addCredentialProcessor(this._deviceStateMachine);
|
|
570
|
+
await this.space.spaceState.addCredentialProcessor(this._profileStateMachine);
|
|
566
571
|
await this.space.open();
|
|
567
572
|
}
|
|
568
573
|
async close() {
|
|
569
574
|
await this.authVerifier.close();
|
|
570
|
-
await this.
|
|
571
|
-
await this.
|
|
575
|
+
await this.space.spaceState.removeCredentialProcessor(this._profileStateMachine);
|
|
576
|
+
await this.space.spaceState.removeCredentialProcessor(this._deviceStateMachine);
|
|
572
577
|
await this.space.close();
|
|
573
578
|
}
|
|
574
579
|
async ready() {
|
|
575
|
-
await this._deviceStateMachine.
|
|
580
|
+
await this._deviceStateMachine.deviceChainReady.wait();
|
|
576
581
|
await this.controlPipeline.state.waitUntilReachedTargetTimeframe({
|
|
577
582
|
timeout: import_client_protocol.LOAD_CONTROL_FEEDS_TIMEOUT
|
|
578
583
|
});
|
|
579
584
|
}
|
|
580
585
|
get profileDocument() {
|
|
581
|
-
return this._profileStateMachine.
|
|
586
|
+
return this._profileStateMachine.profile;
|
|
582
587
|
}
|
|
583
588
|
/**
|
|
584
589
|
* @test-only
|
|
@@ -593,7 +598,7 @@ var Identity = class {
|
|
|
593
598
|
return this.space.genesisFeedKey;
|
|
594
599
|
}
|
|
595
600
|
get deviceCredentialChain() {
|
|
596
|
-
return this._deviceStateMachine.
|
|
601
|
+
return this._deviceStateMachine.deviceCredentialChain;
|
|
597
602
|
}
|
|
598
603
|
getAdmissionCredentials() {
|
|
599
604
|
var _a, _b;
|
|
@@ -608,8 +613,8 @@ var Identity = class {
|
|
|
608
613
|
* Requires identity to be ready.
|
|
609
614
|
*/
|
|
610
615
|
getIdentityCredentialSigner() {
|
|
611
|
-
(0,
|
|
612
|
-
return (0, import_credentials2.createCredentialSignerWithChain)(this._signer, this._deviceStateMachine.
|
|
616
|
+
(0, import_tiny_invariant.default)(this._deviceStateMachine.deviceCredentialChain, "Device credential chain is not ready.");
|
|
617
|
+
return (0, import_credentials2.createCredentialSignerWithChain)(this._signer, this._deviceStateMachine.deviceCredentialChain, this.deviceKey);
|
|
613
618
|
}
|
|
614
619
|
/**
|
|
615
620
|
* Issues credentials as device.
|
|
@@ -625,10 +630,10 @@ var Identity = class {
|
|
|
625
630
|
controlFeedKey,
|
|
626
631
|
dataFeedKey
|
|
627
632
|
}, {
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
633
|
+
F: __dxlog_file2,
|
|
634
|
+
L: 151,
|
|
635
|
+
S: this,
|
|
636
|
+
C: (f, a) => f(...a)
|
|
632
637
|
});
|
|
633
638
|
const signer = this.getIdentityCredentialSigner();
|
|
634
639
|
await (0, import_feed_store2.writeMessages)(this.controlPipeline.writer, [
|
|
@@ -669,7 +674,7 @@ var Identity = class {
|
|
|
669
674
|
};
|
|
670
675
|
|
|
671
676
|
// packages/sdk/client-services/src/packlets/identity/identity-manager.ts
|
|
672
|
-
var
|
|
677
|
+
var import_tiny_invariant2 = __toESM(require("tiny-invariant"));
|
|
673
678
|
var import_async6 = require("@dxos/async");
|
|
674
679
|
var import_credentials4 = require("@dxos/credentials");
|
|
675
680
|
var import_keys4 = require("@dxos/keys");
|
|
@@ -677,6 +682,7 @@ var import_log3 = require("@dxos/log");
|
|
|
677
682
|
var import_protocols2 = require("@dxos/protocols");
|
|
678
683
|
var import_credentials5 = require("@dxos/protocols/proto/dxos/halo/credentials");
|
|
679
684
|
var import_util2 = require("@dxos/util");
|
|
685
|
+
var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/identity-manager.ts";
|
|
680
686
|
var IdentityManager = class {
|
|
681
687
|
// TODO(burdon): IdentityManagerParams.
|
|
682
688
|
// TODO(dmaretskyi): Perhaps this should take/generate the peerKey outside of an initialized identity.
|
|
@@ -696,20 +702,20 @@ var IdentityManager = class {
|
|
|
696
702
|
import_log3.log.trace("dxos.halo.identity-manager.open", import_protocols2.trace.begin({
|
|
697
703
|
id: traceId
|
|
698
704
|
}), {
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
705
|
+
F: __dxlog_file3,
|
|
706
|
+
L: 70,
|
|
707
|
+
S: this,
|
|
708
|
+
C: (f, a) => f(...a)
|
|
703
709
|
});
|
|
704
710
|
await this._metadataStore.load();
|
|
705
711
|
const identityRecord = this._metadataStore.getIdentityRecord();
|
|
706
712
|
(0, import_log3.log)("identity record", {
|
|
707
713
|
identityRecord
|
|
708
714
|
}, {
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
715
|
+
F: __dxlog_file3,
|
|
716
|
+
L: 74,
|
|
717
|
+
S: this,
|
|
718
|
+
C: (f, a) => f(...a)
|
|
713
719
|
});
|
|
714
720
|
if (identityRecord) {
|
|
715
721
|
this._identity = await this._constructIdentity(identityRecord);
|
|
@@ -719,20 +725,20 @@ var IdentityManager = class {
|
|
|
719
725
|
identityKey: identityRecord.identityKey,
|
|
720
726
|
displayName: (_a = this._identity.profileDocument) == null ? void 0 : _a.displayName
|
|
721
727
|
}, {
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
728
|
+
F: __dxlog_file3,
|
|
729
|
+
L: 79,
|
|
730
|
+
S: this,
|
|
731
|
+
C: (f, a) => f(...a)
|
|
726
732
|
});
|
|
727
733
|
this.stateUpdate.emit();
|
|
728
734
|
}
|
|
729
735
|
import_log3.log.trace("dxos.halo.identity-manager.open", import_protocols2.trace.end({
|
|
730
736
|
id: traceId
|
|
731
737
|
}), {
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
738
|
+
F: __dxlog_file3,
|
|
739
|
+
L: 85,
|
|
740
|
+
S: this,
|
|
741
|
+
C: (f, a) => f(...a)
|
|
736
742
|
});
|
|
737
743
|
}
|
|
738
744
|
async close() {
|
|
@@ -741,12 +747,12 @@ var IdentityManager = class {
|
|
|
741
747
|
}
|
|
742
748
|
async createIdentity({ displayName } = {}) {
|
|
743
749
|
var _a;
|
|
744
|
-
(0,
|
|
745
|
-
(0, import_log3.log)("creating identity...",
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
+
(0, import_tiny_invariant2.default)(!this._identity, "Identity already exists.");
|
|
751
|
+
(0, import_log3.log)("creating identity...", void 0, {
|
|
752
|
+
F: __dxlog_file3,
|
|
753
|
+
L: 94,
|
|
754
|
+
S: this,
|
|
755
|
+
C: (f, a) => f(...a)
|
|
750
756
|
});
|
|
751
757
|
const controlFeedKey = await this._keyring.createKey();
|
|
752
758
|
const identityRecord = {
|
|
@@ -763,8 +769,8 @@ var IdentityManager = class {
|
|
|
763
769
|
await identity.open();
|
|
764
770
|
{
|
|
765
771
|
const generator = new import_credentials4.CredentialGenerator(this._keyring, identityRecord.identityKey, identityRecord.deviceKey);
|
|
766
|
-
(0,
|
|
767
|
-
(0,
|
|
772
|
+
(0, import_tiny_invariant2.default)(identityRecord.haloSpace.genesisFeedKey, "Genesis feed key is required.");
|
|
773
|
+
(0, import_tiny_invariant2.default)(identityRecord.haloSpace.dataFeedKey, "Data feed key is required.");
|
|
768
774
|
const credentials = [
|
|
769
775
|
// Space genesis.
|
|
770
776
|
...await generator.createSpaceGenesis(identityRecord.haloSpace.key, identityRecord.haloSpace.genesisFeedKey),
|
|
@@ -792,20 +798,20 @@ var IdentityManager = class {
|
|
|
792
798
|
identityKey: identityRecord.identityKey,
|
|
793
799
|
displayName: (_a = this._identity.profileDocument) == null ? void 0 : _a.displayName
|
|
794
800
|
}, {
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
801
|
+
F: __dxlog_file3,
|
|
802
|
+
L: 149,
|
|
803
|
+
S: this,
|
|
804
|
+
C: (f, a) => f(...a)
|
|
799
805
|
});
|
|
800
806
|
this.stateUpdate.emit();
|
|
801
807
|
(0, import_log3.log)("created identity", {
|
|
802
808
|
identityKey: identity.identityKey,
|
|
803
809
|
deviceKey: identity.deviceKey
|
|
804
810
|
}, {
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
811
|
+
F: __dxlog_file3,
|
|
812
|
+
L: 155,
|
|
813
|
+
S: this,
|
|
814
|
+
C: (f, a) => f(...a)
|
|
809
815
|
});
|
|
810
816
|
return identity;
|
|
811
817
|
}
|
|
@@ -817,12 +823,12 @@ var IdentityManager = class {
|
|
|
817
823
|
(0, import_log3.log)("accepting identity", {
|
|
818
824
|
params
|
|
819
825
|
}, {
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
826
|
+
F: __dxlog_file3,
|
|
827
|
+
L: 163,
|
|
828
|
+
S: this,
|
|
829
|
+
C: (f, a) => f(...a)
|
|
824
830
|
});
|
|
825
|
-
(0,
|
|
831
|
+
(0, import_tiny_invariant2.default)(!this._identity, "Identity already exists.");
|
|
826
832
|
const identityRecord = {
|
|
827
833
|
identityKey: params.identityKey,
|
|
828
834
|
deviceKey: params.deviceKey,
|
|
@@ -843,38 +849,38 @@ var IdentityManager = class {
|
|
|
843
849
|
identityKey: identityRecord.identityKey,
|
|
844
850
|
displayName: (_a = this._identity.profileDocument) == null ? void 0 : _a.displayName
|
|
845
851
|
}, {
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
852
|
+
F: __dxlog_file3,
|
|
853
|
+
L: 183,
|
|
854
|
+
S: this,
|
|
855
|
+
C: (f, a) => f(...a)
|
|
850
856
|
});
|
|
851
857
|
this.stateUpdate.emit();
|
|
852
858
|
(0, import_log3.log)("accepted identity", {
|
|
853
859
|
identityKey: identity.identityKey,
|
|
854
860
|
deviceKey: identity.deviceKey
|
|
855
861
|
}, {
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
862
|
+
F: __dxlog_file3,
|
|
863
|
+
L: 189,
|
|
864
|
+
S: this,
|
|
865
|
+
C: (f, a) => f(...a)
|
|
860
866
|
});
|
|
861
867
|
return identity;
|
|
862
868
|
}
|
|
863
869
|
async _constructIdentity(identityRecord) {
|
|
864
|
-
(0,
|
|
870
|
+
(0, import_tiny_invariant2.default)(!this._identity);
|
|
865
871
|
(0, import_log3.log)("constructing identity", {
|
|
866
872
|
identityRecord
|
|
867
873
|
}, {
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
874
|
+
F: __dxlog_file3,
|
|
875
|
+
L: 195,
|
|
876
|
+
S: this,
|
|
877
|
+
C: (f, a) => f(...a)
|
|
872
878
|
});
|
|
873
|
-
(0,
|
|
879
|
+
(0, import_tiny_invariant2.default)(identityRecord.haloSpace.controlFeedKey);
|
|
874
880
|
const controlFeed = await this._feedStore.openFeed(identityRecord.haloSpace.controlFeedKey, {
|
|
875
881
|
writable: true
|
|
876
882
|
});
|
|
877
|
-
(0,
|
|
883
|
+
(0, import_tiny_invariant2.default)(identityRecord.haloSpace.dataFeedKey);
|
|
878
884
|
const dataFeed = await this._feedStore.openFeed(identityRecord.haloSpace.dataFeedKey, {
|
|
879
885
|
writable: true,
|
|
880
886
|
sparse: true
|
|
@@ -899,10 +905,10 @@ var IdentityManager = class {
|
|
|
899
905
|
(0, import_log3.log)("done", {
|
|
900
906
|
identityKey: identityRecord.identityKey
|
|
901
907
|
}, {
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
908
|
+
F: __dxlog_file3,
|
|
909
|
+
L: 226,
|
|
910
|
+
S: this,
|
|
911
|
+
C: (f, a) => f(...a)
|
|
906
912
|
});
|
|
907
913
|
if (identityRecord.haloSpace.controlTimeframe) {
|
|
908
914
|
identity.controlPipeline.state.setTargetTimeframe(identityRecord.haloSpace.controlTimeframe);
|
|
@@ -919,11 +925,11 @@ var IdentityManager = class {
|
|
|
919
925
|
onNetworkConnection: () => {
|
|
920
926
|
},
|
|
921
927
|
onAuthFailure: () => {
|
|
922
|
-
import_log3.log.warn("auth failure",
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
928
|
+
import_log3.log.warn("auth failure", void 0, {
|
|
929
|
+
F: __dxlog_file3,
|
|
930
|
+
L: 245,
|
|
931
|
+
S: this,
|
|
932
|
+
C: (f, a) => f(...a)
|
|
927
933
|
});
|
|
928
934
|
},
|
|
929
935
|
memberKey: identityKey
|
|
@@ -932,7 +938,7 @@ var IdentityManager = class {
|
|
|
932
938
|
};
|
|
933
939
|
|
|
934
940
|
// packages/sdk/client-services/src/packlets/identity/identity-service.ts
|
|
935
|
-
var
|
|
941
|
+
var import_tiny_invariant3 = __toESM(require("tiny-invariant"));
|
|
936
942
|
var import_codec_protobuf7 = require("@dxos/codec-protobuf");
|
|
937
943
|
var import_credentials6 = require("@dxos/credentials");
|
|
938
944
|
var import_debug2 = require("@dxos/debug");
|
|
@@ -968,7 +974,7 @@ var IdentityServiceImpl = class {
|
|
|
968
974
|
};
|
|
969
975
|
}
|
|
970
976
|
async signPresentation({ presentation, nonce }) {
|
|
971
|
-
(0,
|
|
977
|
+
(0, import_tiny_invariant3.default)(this._serviceContext.identityManager.identity, "Identity not initialized.");
|
|
972
978
|
return await (0, import_credentials6.signPresentation)({
|
|
973
979
|
presentation,
|
|
974
980
|
signer: this._serviceContext.keyring,
|
|
@@ -980,7 +986,7 @@ var IdentityServiceImpl = class {
|
|
|
980
986
|
};
|
|
981
987
|
|
|
982
988
|
// packages/sdk/client-services/src/packlets/invitations/device-invitation-protocol.ts
|
|
983
|
-
var
|
|
989
|
+
var import_tiny_invariant4 = __toESM(require("tiny-invariant"));
|
|
984
990
|
var import_services = require("@dxos/protocols/proto/dxos/client/services");
|
|
985
991
|
var DeviceInvitationProtocol = class {
|
|
986
992
|
constructor(_keyring, _getIdentity, _acceptIdentity) {
|
|
@@ -997,7 +1003,7 @@ var DeviceInvitationProtocol = class {
|
|
|
997
1003
|
};
|
|
998
1004
|
}
|
|
999
1005
|
async admit(request) {
|
|
1000
|
-
(0,
|
|
1006
|
+
(0, import_tiny_invariant4.default)(request.device);
|
|
1001
1007
|
const identity = this._getIdentity();
|
|
1002
1008
|
await identity.admitDevice(request.device);
|
|
1003
1009
|
return {
|
|
@@ -1025,9 +1031,9 @@ var DeviceInvitationProtocol = class {
|
|
|
1025
1031
|
};
|
|
1026
1032
|
}
|
|
1027
1033
|
async accept(response, request) {
|
|
1028
|
-
(0,
|
|
1034
|
+
(0, import_tiny_invariant4.default)(response.device);
|
|
1029
1035
|
const { identityKey, haloSpaceKey, genesisFeedKey, controlTimeframe } = response.device;
|
|
1030
|
-
(0,
|
|
1036
|
+
(0, import_tiny_invariant4.default)(request.device);
|
|
1031
1037
|
const { deviceKey, controlFeedKey, dataFeedKey } = request.device;
|
|
1032
1038
|
await this._acceptIdentity({
|
|
1033
1039
|
identityKey,
|
|
@@ -1045,7 +1051,7 @@ var DeviceInvitationProtocol = class {
|
|
|
1045
1051
|
};
|
|
1046
1052
|
|
|
1047
1053
|
// packages/sdk/client-services/src/packlets/invitations/invitations-handler.ts
|
|
1048
|
-
var
|
|
1054
|
+
var import_tiny_invariant6 = __toESM(require("tiny-invariant"));
|
|
1049
1055
|
var import_async8 = require("@dxos/async");
|
|
1050
1056
|
var import_client_protocol2 = require("@dxos/client-protocol");
|
|
1051
1057
|
var import_context4 = require("@dxos/context");
|
|
@@ -1059,7 +1065,7 @@ var import_services3 = require("@dxos/protocols/proto/dxos/client/services");
|
|
|
1059
1065
|
var import_invitations2 = require("@dxos/protocols/proto/dxos/halo/invitations");
|
|
1060
1066
|
|
|
1061
1067
|
// packages/sdk/client-services/src/packlets/invitations/invitation-extension.ts
|
|
1062
|
-
var
|
|
1068
|
+
var import_tiny_invariant5 = __toESM(require("tiny-invariant"));
|
|
1063
1069
|
var import_async7 = require("@dxos/async");
|
|
1064
1070
|
var import_context3 = require("@dxos/context");
|
|
1065
1071
|
var import_errors = require("@dxos/errors");
|
|
@@ -1069,6 +1075,7 @@ var import_protocols3 = require("@dxos/protocols");
|
|
|
1069
1075
|
var import_services2 = require("@dxos/protocols/proto/dxos/client/services");
|
|
1070
1076
|
var import_invitations = require("@dxos/protocols/proto/dxos/halo/invitations");
|
|
1071
1077
|
var import_teleport = require("@dxos/teleport");
|
|
1078
|
+
var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitation-extension.ts";
|
|
1072
1079
|
var OPTIONS_TIMEOUT = 1e4;
|
|
1073
1080
|
var MAX_OTP_ATTEMPTS = 3;
|
|
1074
1081
|
var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
@@ -1096,7 +1103,7 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
1096
1103
|
// Perhaps in the future we will have more complex logic here.
|
|
1097
1104
|
InvitationHostService: {
|
|
1098
1105
|
options: async (options) => {
|
|
1099
|
-
(0,
|
|
1106
|
+
(0, import_tiny_invariant5.default)(!this._remoteOptions, "Remote options already set.");
|
|
1100
1107
|
this._remoteOptions = options;
|
|
1101
1108
|
this._remoteOptionsTrigger.wake();
|
|
1102
1109
|
},
|
|
@@ -1106,20 +1113,20 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
1106
1113
|
import_log4.log.trace("dxos.sdk.invitation-handler.host.introduce", import_protocols3.trace.begin({
|
|
1107
1114
|
id: traceId
|
|
1108
1115
|
}), {
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1116
|
+
F: __dxlog_file4,
|
|
1117
|
+
L: 98,
|
|
1118
|
+
S: this,
|
|
1119
|
+
C: (f, a) => f(...a)
|
|
1113
1120
|
});
|
|
1114
1121
|
const invitation = await this._callbacks.resolveInvitation(request);
|
|
1115
1122
|
if (!invitation) {
|
|
1116
1123
|
import_log4.log.warn("invitation not found", {
|
|
1117
1124
|
invitationId
|
|
1118
1125
|
}, {
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1126
|
+
F: __dxlog_file4,
|
|
1127
|
+
L: 102,
|
|
1128
|
+
S: this,
|
|
1129
|
+
C: (f, a) => f(...a)
|
|
1123
1130
|
});
|
|
1124
1131
|
this._callbacks.onError(new Error("Invitation not found."));
|
|
1125
1132
|
return {
|
|
@@ -1130,10 +1137,10 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
1130
1137
|
(0, import_log4.log)("guest introduced itself", {
|
|
1131
1138
|
guestProfile: profile
|
|
1132
1139
|
}, {
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1140
|
+
F: __dxlog_file4,
|
|
1141
|
+
L: 111,
|
|
1142
|
+
S: this,
|
|
1143
|
+
C: (f, a) => f(...a)
|
|
1137
1144
|
});
|
|
1138
1145
|
this.guestProfile = profile;
|
|
1139
1146
|
this._callbacks.onStateUpdate({
|
|
@@ -1143,10 +1150,10 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
1143
1150
|
import_log4.log.trace("dxos.sdk.invitation-handler.host.introduce", import_protocols3.trace.end({
|
|
1144
1151
|
id: traceId
|
|
1145
1152
|
}), {
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1153
|
+
F: __dxlog_file4,
|
|
1154
|
+
L: 118,
|
|
1155
|
+
S: this,
|
|
1156
|
+
C: (f, a) => f(...a)
|
|
1150
1157
|
});
|
|
1151
1158
|
return {
|
|
1152
1159
|
spaceKey: this.invitation.authMethod === import_services2.Invitation.AuthMethod.NONE ? this.invitation.spaceKey : void 0,
|
|
@@ -1158,28 +1165,28 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
1158
1165
|
import_log4.log.trace("dxos.sdk.invitation-handler.host.authenticate", import_protocols3.trace.begin({
|
|
1159
1166
|
id: traceId
|
|
1160
1167
|
}), {
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1168
|
+
F: __dxlog_file4,
|
|
1169
|
+
L: 127,
|
|
1170
|
+
S: this,
|
|
1171
|
+
C: (f, a) => f(...a)
|
|
1165
1172
|
});
|
|
1166
1173
|
(0, import_log4.log)("received authentication request", {
|
|
1167
1174
|
authCode: code
|
|
1168
1175
|
}, {
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1176
|
+
F: __dxlog_file4,
|
|
1177
|
+
L: 128,
|
|
1178
|
+
S: this,
|
|
1179
|
+
C: (f, a) => f(...a)
|
|
1173
1180
|
});
|
|
1174
1181
|
let status = import_invitations.AuthenticationResponse.Status.OK;
|
|
1175
|
-
(0,
|
|
1182
|
+
(0, import_tiny_invariant5.default)(this.invitation, "Invitation is not set.");
|
|
1176
1183
|
switch (this.invitation.authMethod) {
|
|
1177
1184
|
case import_services2.Invitation.AuthMethod.NONE: {
|
|
1178
|
-
(0, import_log4.log)("authentication not required",
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1185
|
+
(0, import_log4.log)("authentication not required", void 0, {
|
|
1186
|
+
F: __dxlog_file4,
|
|
1187
|
+
L: 134,
|
|
1188
|
+
S: this,
|
|
1189
|
+
C: (f, a) => f(...a)
|
|
1183
1190
|
});
|
|
1184
1191
|
return {
|
|
1185
1192
|
status: import_invitations.AuthenticationResponse.Status.OK
|
|
@@ -1201,10 +1208,10 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
1201
1208
|
import_log4.log.error("invalid authentication method", {
|
|
1202
1209
|
authMethod: this.invitation.authMethod
|
|
1203
1210
|
}, {
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1211
|
+
F: __dxlog_file4,
|
|
1212
|
+
L: 152,
|
|
1213
|
+
S: this,
|
|
1214
|
+
C: (f, a) => f(...a)
|
|
1208
1215
|
});
|
|
1209
1216
|
status = import_invitations.AuthenticationResponse.Status.INTERNAL_ERROR;
|
|
1210
1217
|
break;
|
|
@@ -1216,10 +1223,10 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
1216
1223
|
status
|
|
1217
1224
|
}
|
|
1218
1225
|
}), {
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1226
|
+
F: __dxlog_file4,
|
|
1227
|
+
L: 158,
|
|
1228
|
+
S: this,
|
|
1229
|
+
C: (f, a) => f(...a)
|
|
1223
1230
|
});
|
|
1224
1231
|
return {
|
|
1225
1232
|
status
|
|
@@ -1230,13 +1237,13 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
1230
1237
|
import_log4.log.trace("dxos.sdk.invitation-handler.host.admit", import_protocols3.trace.begin({
|
|
1231
1238
|
id: traceId
|
|
1232
1239
|
}), {
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1240
|
+
F: __dxlog_file4,
|
|
1241
|
+
L: 164,
|
|
1242
|
+
S: this,
|
|
1243
|
+
C: (f, a) => f(...a)
|
|
1237
1244
|
});
|
|
1238
1245
|
try {
|
|
1239
|
-
(0,
|
|
1246
|
+
(0, import_tiny_invariant5.default)(this.invitation, "Invitation is not set.");
|
|
1240
1247
|
if (isAuthenticationRequired(this.invitation) && !this.authenticationPassed) {
|
|
1241
1248
|
throw new Error("Not authenticated");
|
|
1242
1249
|
}
|
|
@@ -1244,10 +1251,10 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
1244
1251
|
import_log4.log.trace("dxos.sdk.invitation-handler.host.admit", import_protocols3.trace.end({
|
|
1245
1252
|
id: traceId
|
|
1246
1253
|
}), {
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1254
|
+
F: __dxlog_file4,
|
|
1255
|
+
L: 175,
|
|
1256
|
+
S: this,
|
|
1257
|
+
C: (f, a) => f(...a)
|
|
1251
1258
|
});
|
|
1252
1259
|
return response;
|
|
1253
1260
|
} catch (err) {
|
|
@@ -1301,7 +1308,7 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
|
|
|
1301
1308
|
return {
|
|
1302
1309
|
InvitationHostService: {
|
|
1303
1310
|
options: async (options) => {
|
|
1304
|
-
(0,
|
|
1311
|
+
(0, import_tiny_invariant5.default)(!this._remoteOptions, "Remote options already set.");
|
|
1305
1312
|
this._remoteOptions = options;
|
|
1306
1313
|
this._remoteOptionsTrigger.wake();
|
|
1307
1314
|
},
|
|
@@ -1321,11 +1328,11 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
|
|
|
1321
1328
|
var _a;
|
|
1322
1329
|
await super.onOpen(context);
|
|
1323
1330
|
try {
|
|
1324
|
-
(0, import_log4.log)("begin options",
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1331
|
+
(0, import_log4.log)("begin options", void 0, {
|
|
1332
|
+
F: __dxlog_file4,
|
|
1333
|
+
L: 263,
|
|
1334
|
+
S: this,
|
|
1335
|
+
C: (f, a) => f(...a)
|
|
1329
1336
|
});
|
|
1330
1337
|
await (0, import_context3.cancelWithContext)(this._ctx, this.rpc.InvitationHostService.options({
|
|
1331
1338
|
role: import_invitations.Options.Role.GUEST
|
|
@@ -1333,11 +1340,11 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
|
|
|
1333
1340
|
await (0, import_context3.cancelWithContext)(this._ctx, this._remoteOptionsTrigger.wait({
|
|
1334
1341
|
timeout: OPTIONS_TIMEOUT
|
|
1335
1342
|
}));
|
|
1336
|
-
(0, import_log4.log)("end options",
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1343
|
+
(0, import_log4.log)("end options", void 0, {
|
|
1344
|
+
F: __dxlog_file4,
|
|
1345
|
+
L: 266,
|
|
1346
|
+
S: this,
|
|
1347
|
+
C: (f, a) => f(...a)
|
|
1341
1348
|
});
|
|
1342
1349
|
if (((_a = this._remoteOptions) == null ? void 0 : _a.role) !== import_invitations.Options.Role.HOST) {
|
|
1343
1350
|
throw new import_errors.InvalidInvitationExtensionRoleError(void 0, {
|
|
@@ -1348,20 +1355,20 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
|
|
|
1348
1355
|
this._callbacks.onOpen(this._ctx);
|
|
1349
1356
|
} catch (err) {
|
|
1350
1357
|
(0, import_log4.log)("openError", err, {
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1358
|
+
F: __dxlog_file4,
|
|
1359
|
+
L: 276,
|
|
1360
|
+
S: this,
|
|
1361
|
+
C: (f, a) => f(...a)
|
|
1355
1362
|
});
|
|
1356
1363
|
this._callbacks.onError(err);
|
|
1357
1364
|
}
|
|
1358
1365
|
}
|
|
1359
1366
|
async onClose() {
|
|
1360
|
-
(0, import_log4.log)("onClose",
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1367
|
+
(0, import_log4.log)("onClose", void 0, {
|
|
1368
|
+
F: __dxlog_file4,
|
|
1369
|
+
L: 282,
|
|
1370
|
+
S: this,
|
|
1371
|
+
C: (f, a) => f(...a)
|
|
1365
1372
|
});
|
|
1366
1373
|
await this._ctx.dispose();
|
|
1367
1374
|
}
|
|
@@ -1369,6 +1376,7 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
|
|
|
1369
1376
|
var isAuthenticationRequired = (invitation) => invitation.authMethod !== import_services2.Invitation.AuthMethod.NONE;
|
|
1370
1377
|
|
|
1371
1378
|
// packages/sdk/client-services/src/packlets/invitations/invitations-handler.ts
|
|
1379
|
+
var __dxlog_file5 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitations-handler.ts";
|
|
1372
1380
|
var InvitationsHandler = class {
|
|
1373
1381
|
/**
|
|
1374
1382
|
* @internal
|
|
@@ -1380,7 +1388,7 @@ var InvitationsHandler = class {
|
|
|
1380
1388
|
var _a;
|
|
1381
1389
|
const { invitationId = import_keys6.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_keys6.PublicKey.random() } = options != null ? options : {};
|
|
1382
1390
|
const authCode = (_a = options == null ? void 0 : options.authCode) != null ? _a : authMethod === import_services3.Invitation.AuthMethod.SHARED_SECRET ? (0, import_credentials7.generatePasscode)(import_client_protocol2.AUTHENTICATION_CODE_LENGTH) : void 0;
|
|
1383
|
-
(0,
|
|
1391
|
+
(0, import_tiny_invariant6.default)(protocol);
|
|
1384
1392
|
const invitation = {
|
|
1385
1393
|
invitationId,
|
|
1386
1394
|
type,
|
|
@@ -1402,10 +1410,10 @@ var InvitationsHandler = class {
|
|
|
1402
1410
|
(0, import_log5.log)("complete", {
|
|
1403
1411
|
...protocol.toJSON()
|
|
1404
1412
|
}, {
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1413
|
+
F: __dxlog_file5,
|
|
1414
|
+
L: 99,
|
|
1415
|
+
S: this,
|
|
1416
|
+
C: (f, a) => f(...a)
|
|
1409
1417
|
});
|
|
1410
1418
|
stream.complete();
|
|
1411
1419
|
});
|
|
@@ -1427,7 +1435,7 @@ var InvitationsHandler = class {
|
|
|
1427
1435
|
var _a2, _b, _c;
|
|
1428
1436
|
try {
|
|
1429
1437
|
const deviceKey = (_c = (_a2 = admissionRequest.device) == null ? void 0 : _a2.deviceKey) != null ? _c : (_b = admissionRequest.space) == null ? void 0 : _b.deviceKey;
|
|
1430
|
-
(0,
|
|
1438
|
+
(0, import_tiny_invariant6.default)(deviceKey);
|
|
1431
1439
|
const admissionResponse = await protocol.admit(admissionRequest, extension.guestProfile);
|
|
1432
1440
|
extension.completedTrigger.wake(deviceKey);
|
|
1433
1441
|
return admissionResponse;
|
|
@@ -1443,18 +1451,18 @@ var InvitationsHandler = class {
|
|
|
1443
1451
|
import_log5.log.trace("dxos.sdk.invitations-handler.host.onOpen", import_protocols4.trace.begin({
|
|
1444
1452
|
id: traceId
|
|
1445
1453
|
}), {
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1454
|
+
F: __dxlog_file5,
|
|
1455
|
+
L: 138,
|
|
1456
|
+
S: this,
|
|
1457
|
+
C: (f, a) => f(...a)
|
|
1450
1458
|
});
|
|
1451
1459
|
(0, import_log5.log)("connected", {
|
|
1452
1460
|
...protocol.toJSON()
|
|
1453
1461
|
}, {
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1462
|
+
F: __dxlog_file5,
|
|
1463
|
+
L: 139,
|
|
1464
|
+
S: this,
|
|
1465
|
+
C: (f, a) => f(...a)
|
|
1458
1466
|
});
|
|
1459
1467
|
stream.next({
|
|
1460
1468
|
...invitation,
|
|
@@ -1467,10 +1475,10 @@ var InvitationsHandler = class {
|
|
|
1467
1475
|
guest: deviceKey,
|
|
1468
1476
|
...protocol.toJSON()
|
|
1469
1477
|
}, {
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1478
|
+
F: __dxlog_file5,
|
|
1479
|
+
L: 142,
|
|
1480
|
+
S: this,
|
|
1481
|
+
C: (f, a) => f(...a)
|
|
1474
1482
|
});
|
|
1475
1483
|
stream.next({
|
|
1476
1484
|
...invitation,
|
|
@@ -1479,20 +1487,20 @@ var InvitationsHandler = class {
|
|
|
1479
1487
|
import_log5.log.trace("dxos.sdk.invitations-handler.host.onOpen", import_protocols4.trace.end({
|
|
1480
1488
|
id: traceId
|
|
1481
1489
|
}), {
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1490
|
+
F: __dxlog_file5,
|
|
1491
|
+
L: 144,
|
|
1492
|
+
S: this,
|
|
1493
|
+
C: (f, a) => f(...a)
|
|
1486
1494
|
});
|
|
1487
1495
|
} catch (err) {
|
|
1488
1496
|
if (err instanceof import_async8.TimeoutError) {
|
|
1489
1497
|
(0, import_log5.log)("timeout", {
|
|
1490
1498
|
...protocol.toJSON()
|
|
1491
1499
|
}, {
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1500
|
+
F: __dxlog_file5,
|
|
1501
|
+
L: 147,
|
|
1502
|
+
S: this,
|
|
1503
|
+
C: (f, a) => f(...a)
|
|
1496
1504
|
});
|
|
1497
1505
|
stream.next({
|
|
1498
1506
|
...invitation,
|
|
@@ -1500,10 +1508,10 @@ var InvitationsHandler = class {
|
|
|
1500
1508
|
});
|
|
1501
1509
|
} else {
|
|
1502
1510
|
import_log5.log.error("failed", err, {
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1511
|
+
F: __dxlog_file5,
|
|
1512
|
+
L: 150,
|
|
1513
|
+
S: this,
|
|
1514
|
+
C: (f, a) => f(...a)
|
|
1507
1515
|
});
|
|
1508
1516
|
stream.error(err);
|
|
1509
1517
|
}
|
|
@@ -1511,10 +1519,10 @@ var InvitationsHandler = class {
|
|
|
1511
1519
|
id: traceId,
|
|
1512
1520
|
error: err
|
|
1513
1521
|
}), {
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1522
|
+
F: __dxlog_file5,
|
|
1523
|
+
L: 153,
|
|
1524
|
+
S: this,
|
|
1525
|
+
C: (f, a) => f(...a)
|
|
1518
1526
|
});
|
|
1519
1527
|
} finally {
|
|
1520
1528
|
if (type !== import_services3.Invitation.Type.MULTIUSE) {
|
|
@@ -1532,10 +1540,10 @@ var InvitationsHandler = class {
|
|
|
1532
1540
|
(0, import_log5.log)("timeout", {
|
|
1533
1541
|
...protocol.toJSON()
|
|
1534
1542
|
}, {
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1543
|
+
F: __dxlog_file5,
|
|
1544
|
+
L: 168,
|
|
1545
|
+
S: this,
|
|
1546
|
+
C: (f, a) => f(...a)
|
|
1539
1547
|
});
|
|
1540
1548
|
stream.next({
|
|
1541
1549
|
...invitation,
|
|
@@ -1543,10 +1551,10 @@ var InvitationsHandler = class {
|
|
|
1543
1551
|
});
|
|
1544
1552
|
} else {
|
|
1545
1553
|
import_log5.log.error("failed", err, {
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1554
|
+
F: __dxlog_file5,
|
|
1555
|
+
L: 171,
|
|
1556
|
+
S: this,
|
|
1557
|
+
C: (f, a) => f(...a)
|
|
1550
1558
|
});
|
|
1551
1559
|
stream.error(err);
|
|
1552
1560
|
}
|
|
@@ -1586,13 +1594,13 @@ var InvitationsHandler = class {
|
|
|
1586
1594
|
}
|
|
1587
1595
|
acceptInvitation(protocol, invitation) {
|
|
1588
1596
|
const { timeout = import_client_protocol2.INVITATION_TIMEOUT } = invitation;
|
|
1589
|
-
(0,
|
|
1597
|
+
(0, import_tiny_invariant6.default)(protocol);
|
|
1590
1598
|
const authenticated = new import_async8.Trigger();
|
|
1591
1599
|
let admitted = false;
|
|
1592
1600
|
let currentState;
|
|
1593
1601
|
const stream = new import_async8.PushStream();
|
|
1594
1602
|
const setState = (newData) => {
|
|
1595
|
-
(0,
|
|
1603
|
+
(0, import_tiny_invariant6.default)(newData.state !== void 0);
|
|
1596
1604
|
currentState = newData.state;
|
|
1597
1605
|
stream.next({
|
|
1598
1606
|
...invitation,
|
|
@@ -1605,20 +1613,20 @@ var InvitationsHandler = class {
|
|
|
1605
1613
|
(0, import_log5.log)("timeout", {
|
|
1606
1614
|
...protocol.toJSON()
|
|
1607
1615
|
}, {
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1616
|
+
F: __dxlog_file5,
|
|
1617
|
+
L: 230,
|
|
1618
|
+
S: this,
|
|
1619
|
+
C: (f, a) => f(...a)
|
|
1612
1620
|
});
|
|
1613
1621
|
setState({
|
|
1614
1622
|
state: import_services3.Invitation.State.TIMEOUT
|
|
1615
1623
|
});
|
|
1616
1624
|
} else {
|
|
1617
1625
|
import_log5.log.warn("auth failed", err, {
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1626
|
+
F: __dxlog_file5,
|
|
1627
|
+
L: 233,
|
|
1628
|
+
S: this,
|
|
1629
|
+
C: (f, a) => f(...a)
|
|
1622
1630
|
});
|
|
1623
1631
|
stream.error(err);
|
|
1624
1632
|
}
|
|
@@ -1629,10 +1637,10 @@ var InvitationsHandler = class {
|
|
|
1629
1637
|
(0, import_log5.log)("complete", {
|
|
1630
1638
|
...protocol.toJSON()
|
|
1631
1639
|
}, {
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1640
|
+
F: __dxlog_file5,
|
|
1641
|
+
L: 241,
|
|
1642
|
+
S: this,
|
|
1643
|
+
C: (f, a) => f(...a)
|
|
1636
1644
|
});
|
|
1637
1645
|
stream.complete();
|
|
1638
1646
|
});
|
|
@@ -1644,10 +1652,10 @@ var InvitationsHandler = class {
|
|
|
1644
1652
|
(0, import_log5.log)("extension disposed", {
|
|
1645
1653
|
currentState
|
|
1646
1654
|
}, {
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1655
|
+
F: __dxlog_file5,
|
|
1656
|
+
L: 251,
|
|
1657
|
+
S: this,
|
|
1658
|
+
C: (f, a) => f(...a)
|
|
1651
1659
|
});
|
|
1652
1660
|
if (!admitted) {
|
|
1653
1661
|
stream.error(new Error("Remote peer disconnected."));
|
|
@@ -1659,10 +1667,10 @@ var InvitationsHandler = class {
|
|
|
1659
1667
|
import_log5.log.trace("dxos.sdk.invitations-handler.guest.onOpen", import_protocols4.trace.begin({
|
|
1660
1668
|
id: traceId
|
|
1661
1669
|
}), {
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1670
|
+
F: __dxlog_file5,
|
|
1671
|
+
L: 260,
|
|
1672
|
+
S: this,
|
|
1673
|
+
C: (f, a) => f(...a)
|
|
1666
1674
|
});
|
|
1667
1675
|
if (++connectionCount > 1) {
|
|
1668
1676
|
throw new Error(`multiple connections detected: ${connectionCount}`);
|
|
@@ -1671,10 +1679,10 @@ var InvitationsHandler = class {
|
|
|
1671
1679
|
(0, import_log5.log)("connected", {
|
|
1672
1680
|
...protocol.toJSON()
|
|
1673
1681
|
}, {
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1682
|
+
F: __dxlog_file5,
|
|
1683
|
+
L: 268,
|
|
1684
|
+
S: this,
|
|
1685
|
+
C: (f, a) => f(...a)
|
|
1678
1686
|
});
|
|
1679
1687
|
setState({
|
|
1680
1688
|
state: import_services3.Invitation.State.CONNECTED
|
|
@@ -1682,20 +1690,20 @@ var InvitationsHandler = class {
|
|
|
1682
1690
|
(0, import_log5.log)("introduce", {
|
|
1683
1691
|
...protocol.toJSON()
|
|
1684
1692
|
}, {
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1693
|
+
F: __dxlog_file5,
|
|
1694
|
+
L: 272,
|
|
1695
|
+
S: this,
|
|
1696
|
+
C: (f, a) => f(...a)
|
|
1689
1697
|
});
|
|
1690
1698
|
const introductionResponse = await extension.rpc.InvitationHostService.introduce(protocol.createIntroduction());
|
|
1691
1699
|
(0, import_log5.log)("introduce response", {
|
|
1692
1700
|
...protocol.toJSON(),
|
|
1693
1701
|
response: introductionResponse
|
|
1694
1702
|
}, {
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1703
|
+
F: __dxlog_file5,
|
|
1704
|
+
L: 276,
|
|
1705
|
+
S: this,
|
|
1706
|
+
C: (f, a) => f(...a)
|
|
1699
1707
|
});
|
|
1700
1708
|
invitation.authMethod = introductionResponse.authMethod;
|
|
1701
1709
|
if (introductionResponse.spaceKey) {
|
|
@@ -1703,11 +1711,11 @@ var InvitationsHandler = class {
|
|
|
1703
1711
|
}
|
|
1704
1712
|
if (isAuthenticationRequired(invitation)) {
|
|
1705
1713
|
for (let attempt = 1; attempt <= MAX_OTP_ATTEMPTS; attempt++) {
|
|
1706
|
-
(0, import_log5.log)("guest waiting for authentication code...",
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1714
|
+
(0, import_log5.log)("guest waiting for authentication code...", void 0, {
|
|
1715
|
+
F: __dxlog_file5,
|
|
1716
|
+
L: 285,
|
|
1717
|
+
S: this,
|
|
1718
|
+
C: (f, a) => f(...a)
|
|
1711
1719
|
});
|
|
1712
1720
|
setState({
|
|
1713
1721
|
state: import_services3.Invitation.State.READY_FOR_AUTHENTICATION
|
|
@@ -1715,11 +1723,11 @@ var InvitationsHandler = class {
|
|
|
1715
1723
|
const authCode = await authenticated.wait({
|
|
1716
1724
|
timeout
|
|
1717
1725
|
});
|
|
1718
|
-
(0, import_log5.log)("sending authentication request",
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1726
|
+
(0, import_log5.log)("sending authentication request", void 0, {
|
|
1727
|
+
F: __dxlog_file5,
|
|
1728
|
+
L: 289,
|
|
1729
|
+
S: this,
|
|
1730
|
+
C: (f, a) => f(...a)
|
|
1723
1731
|
});
|
|
1724
1732
|
setState({
|
|
1725
1733
|
state: import_services3.Invitation.State.AUTHENTICATING
|
|
@@ -1737,10 +1745,10 @@ var InvitationsHandler = class {
|
|
|
1737
1745
|
(0, import_log5.log)("retrying invalid code", {
|
|
1738
1746
|
attempt
|
|
1739
1747
|
}, {
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1748
|
+
F: __dxlog_file5,
|
|
1749
|
+
L: 300,
|
|
1750
|
+
S: this,
|
|
1751
|
+
C: (f, a) => f(...a)
|
|
1744
1752
|
});
|
|
1745
1753
|
authenticated.reset();
|
|
1746
1754
|
}
|
|
@@ -1754,10 +1762,10 @@ var InvitationsHandler = class {
|
|
|
1754
1762
|
(0, import_log5.log)("request admission", {
|
|
1755
1763
|
...protocol.toJSON()
|
|
1756
1764
|
}, {
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1765
|
+
F: __dxlog_file5,
|
|
1766
|
+
L: 311,
|
|
1767
|
+
S: this,
|
|
1768
|
+
C: (f, a) => f(...a)
|
|
1761
1769
|
});
|
|
1762
1770
|
const admissionRequest = await protocol.createAdmissionRequest();
|
|
1763
1771
|
const admissionResponse = await extension.rpc.InvitationHostService.admit(admissionRequest);
|
|
@@ -1766,10 +1774,10 @@ var InvitationsHandler = class {
|
|
|
1766
1774
|
(0, import_log5.log)("admitted by host", {
|
|
1767
1775
|
...protocol.toJSON()
|
|
1768
1776
|
}, {
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1777
|
+
F: __dxlog_file5,
|
|
1778
|
+
L: 322,
|
|
1779
|
+
S: this,
|
|
1780
|
+
C: (f, a) => f(...a)
|
|
1773
1781
|
});
|
|
1774
1782
|
setState({
|
|
1775
1783
|
...result,
|
|
@@ -1778,30 +1786,30 @@ var InvitationsHandler = class {
|
|
|
1778
1786
|
import_log5.log.trace("dxos.sdk.invitations-handler.guest.onOpen", import_protocols4.trace.end({
|
|
1779
1787
|
id: traceId
|
|
1780
1788
|
}), {
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1789
|
+
F: __dxlog_file5,
|
|
1790
|
+
L: 324,
|
|
1791
|
+
S: this,
|
|
1792
|
+
C: (f, a) => f(...a)
|
|
1785
1793
|
});
|
|
1786
1794
|
} catch (err) {
|
|
1787
1795
|
if (err instanceof import_async8.TimeoutError) {
|
|
1788
1796
|
(0, import_log5.log)("timeout", {
|
|
1789
1797
|
...protocol.toJSON()
|
|
1790
1798
|
}, {
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1799
|
+
F: __dxlog_file5,
|
|
1800
|
+
L: 327,
|
|
1801
|
+
S: this,
|
|
1802
|
+
C: (f, a) => f(...a)
|
|
1795
1803
|
});
|
|
1796
1804
|
setState({
|
|
1797
1805
|
state: import_services3.Invitation.State.TIMEOUT
|
|
1798
1806
|
});
|
|
1799
1807
|
} else {
|
|
1800
1808
|
(0, import_log5.log)("auth failed", err, {
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1809
|
+
F: __dxlog_file5,
|
|
1810
|
+
L: 330,
|
|
1811
|
+
S: this,
|
|
1812
|
+
C: (f, a) => f(...a)
|
|
1805
1813
|
});
|
|
1806
1814
|
stream.error(err);
|
|
1807
1815
|
}
|
|
@@ -1809,10 +1817,10 @@ var InvitationsHandler = class {
|
|
|
1809
1817
|
id: traceId,
|
|
1810
1818
|
error: err
|
|
1811
1819
|
}), {
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1820
|
+
F: __dxlog_file5,
|
|
1821
|
+
L: 333,
|
|
1822
|
+
S: this,
|
|
1823
|
+
C: (f, a) => f(...a)
|
|
1816
1824
|
});
|
|
1817
1825
|
} finally {
|
|
1818
1826
|
await ctx.dispose();
|
|
@@ -1827,20 +1835,20 @@ var InvitationsHandler = class {
|
|
|
1827
1835
|
(0, import_log5.log)("timeout", {
|
|
1828
1836
|
...protocol.toJSON()
|
|
1829
1837
|
}, {
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
1838
|
+
F: __dxlog_file5,
|
|
1839
|
+
L: 344,
|
|
1840
|
+
S: this,
|
|
1841
|
+
C: (f, a) => f(...a)
|
|
1834
1842
|
});
|
|
1835
1843
|
setState({
|
|
1836
1844
|
state: import_services3.Invitation.State.TIMEOUT
|
|
1837
1845
|
});
|
|
1838
1846
|
} else {
|
|
1839
1847
|
(0, import_log5.log)("auth failed", err, {
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1848
|
+
F: __dxlog_file5,
|
|
1849
|
+
L: 347,
|
|
1850
|
+
S: this,
|
|
1851
|
+
C: (f, a) => f(...a)
|
|
1844
1852
|
});
|
|
1845
1853
|
stream.error(err);
|
|
1846
1854
|
}
|
|
@@ -1849,7 +1857,7 @@ var InvitationsHandler = class {
|
|
|
1849
1857
|
return extension;
|
|
1850
1858
|
};
|
|
1851
1859
|
(0, import_async8.scheduleTask)(ctx, async () => {
|
|
1852
|
-
(0,
|
|
1860
|
+
(0, import_tiny_invariant6.default)(invitation.swarmKey);
|
|
1853
1861
|
const topic = invitation.swarmKey;
|
|
1854
1862
|
const swarmConnection = await this._networkManager.joinSwarm({
|
|
1855
1863
|
topic,
|
|
@@ -1882,11 +1890,12 @@ var InvitationsHandler = class {
|
|
|
1882
1890
|
};
|
|
1883
1891
|
|
|
1884
1892
|
// packages/sdk/client-services/src/packlets/invitations/invitations-service.ts
|
|
1885
|
-
var
|
|
1893
|
+
var import_tiny_invariant7 = __toESM(require("tiny-invariant"));
|
|
1886
1894
|
var import_async9 = require("@dxos/async");
|
|
1887
1895
|
var import_codec_protobuf8 = require("@dxos/codec-protobuf");
|
|
1888
1896
|
var import_log6 = require("@dxos/log");
|
|
1889
1897
|
var import_services4 = require("@dxos/protocols/proto/dxos/client/services");
|
|
1898
|
+
var __dxlog_file6 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitations-service.ts";
|
|
1890
1899
|
var InvitationsServiceImpl = class {
|
|
1891
1900
|
constructor(_invitationsHandler, _getHandler) {
|
|
1892
1901
|
this._invitationsHandler = _invitationsHandler;
|
|
@@ -1947,35 +1956,35 @@ var InvitationsServiceImpl = class {
|
|
|
1947
1956
|
});
|
|
1948
1957
|
}
|
|
1949
1958
|
async authenticate({ invitationId, authCode }) {
|
|
1950
|
-
(0, import_log6.log)("authenticating...",
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1959
|
+
(0, import_log6.log)("authenticating...", void 0, {
|
|
1960
|
+
F: __dxlog_file6,
|
|
1961
|
+
L: 103,
|
|
1962
|
+
S: this,
|
|
1963
|
+
C: (f, a) => f(...a)
|
|
1955
1964
|
});
|
|
1956
|
-
(0,
|
|
1965
|
+
(0, import_tiny_invariant7.default)(invitationId);
|
|
1957
1966
|
const observable = this._acceptInvitations.get(invitationId);
|
|
1958
1967
|
if (!observable) {
|
|
1959
1968
|
import_log6.log.warn("invalid invitation", {
|
|
1960
1969
|
invitationId
|
|
1961
1970
|
}, {
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1971
|
+
F: __dxlog_file6,
|
|
1972
|
+
L: 107,
|
|
1973
|
+
S: this,
|
|
1974
|
+
C: (f, a) => f(...a)
|
|
1966
1975
|
});
|
|
1967
1976
|
} else {
|
|
1968
1977
|
await observable.authenticate(authCode);
|
|
1969
1978
|
}
|
|
1970
1979
|
}
|
|
1971
1980
|
async cancelInvitation({ invitationId }) {
|
|
1972
|
-
(0, import_log6.log)("deleting...",
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
|
|
1981
|
+
(0, import_log6.log)("deleting...", void 0, {
|
|
1982
|
+
F: __dxlog_file6,
|
|
1983
|
+
L: 114,
|
|
1984
|
+
S: this,
|
|
1985
|
+
C: (f, a) => f(...a)
|
|
1977
1986
|
});
|
|
1978
|
-
(0,
|
|
1987
|
+
(0, import_tiny_invariant7.default)(invitationId);
|
|
1979
1988
|
const created = this._createInvitations.get(invitationId);
|
|
1980
1989
|
const accepted = this._acceptInvitations.get(invitationId);
|
|
1981
1990
|
if (created) {
|
|
@@ -1990,10 +1999,10 @@ var InvitationsServiceImpl = class {
|
|
|
1990
1999
|
import_log6.log.warn("invalid invitation", {
|
|
1991
2000
|
invitationId
|
|
1992
2001
|
}, {
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
|
|
2002
|
+
F: __dxlog_file6,
|
|
2003
|
+
L: 127,
|
|
2004
|
+
S: this,
|
|
2005
|
+
C: (f, a) => f(...a)
|
|
1997
2006
|
});
|
|
1998
2007
|
}
|
|
1999
2008
|
}
|
|
@@ -2050,11 +2059,12 @@ var InvitationsServiceImpl = class {
|
|
|
2050
2059
|
};
|
|
2051
2060
|
|
|
2052
2061
|
// packages/sdk/client-services/src/packlets/invitations/space-invitation-protocol.ts
|
|
2053
|
-
var
|
|
2062
|
+
var import_tiny_invariant8 = __toESM(require("tiny-invariant"));
|
|
2054
2063
|
var import_credentials8 = require("@dxos/credentials");
|
|
2055
2064
|
var import_feed_store3 = require("@dxos/feed-store");
|
|
2056
2065
|
var import_log7 = require("@dxos/log");
|
|
2057
2066
|
var import_services5 = require("@dxos/protocols/proto/dxos/client/services");
|
|
2067
|
+
var __dxlog_file7 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/space-invitation-protocol.ts";
|
|
2058
2068
|
var SpaceInvitationProtocol = class {
|
|
2059
2069
|
constructor(_spaceManager, _signingContext, _keyring, _spaceKey) {
|
|
2060
2070
|
this._spaceManager = _spaceManager;
|
|
@@ -2076,24 +2086,24 @@ var SpaceInvitationProtocol = class {
|
|
|
2076
2086
|
}
|
|
2077
2087
|
async admit(request, guestProfile) {
|
|
2078
2088
|
var _a;
|
|
2079
|
-
(0,
|
|
2089
|
+
(0, import_tiny_invariant8.default)(this._spaceKey);
|
|
2080
2090
|
const space = await this._spaceManager.spaces.get(this._spaceKey);
|
|
2081
|
-
(0,
|
|
2082
|
-
(0,
|
|
2091
|
+
(0, import_tiny_invariant8.default)(space);
|
|
2092
|
+
(0, import_tiny_invariant8.default)(request.space);
|
|
2083
2093
|
const { identityKey, deviceKey } = request.space;
|
|
2084
2094
|
(0, import_log7.log)("writing guest credentials", {
|
|
2085
2095
|
host: this._signingContext.deviceKey,
|
|
2086
2096
|
guest: deviceKey
|
|
2087
2097
|
}, {
|
|
2088
|
-
|
|
2089
|
-
|
|
2090
|
-
|
|
2091
|
-
|
|
2098
|
+
F: __dxlog_file7,
|
|
2099
|
+
L: 50,
|
|
2100
|
+
S: this,
|
|
2101
|
+
C: (f, a) => f(...a)
|
|
2092
2102
|
});
|
|
2093
2103
|
const credentials = await (0, import_credentials8.createAdmissionCredentials)(this._signingContext.credentialSigner, identityKey, space.key, space.inner.genesisFeedKey, guestProfile);
|
|
2094
|
-
(0,
|
|
2104
|
+
(0, import_tiny_invariant8.default)(credentials[0].credential);
|
|
2095
2105
|
const spaceMemberCredential = credentials[0].credential.credential;
|
|
2096
|
-
(0,
|
|
2106
|
+
(0, import_tiny_invariant8.default)((0, import_credentials8.getCredentialAssertion)(spaceMemberCredential)["@type"] === "dxos.halo.credentials.SpaceMember");
|
|
2097
2107
|
await (0, import_feed_store3.writeMessages)(space.inner.controlPipeline.writer, credentials);
|
|
2098
2108
|
return {
|
|
2099
2109
|
space: {
|
|
@@ -2121,11 +2131,11 @@ var SpaceInvitationProtocol = class {
|
|
|
2121
2131
|
};
|
|
2122
2132
|
}
|
|
2123
2133
|
async accept(response) {
|
|
2124
|
-
(0,
|
|
2134
|
+
(0, import_tiny_invariant8.default)(response.space);
|
|
2125
2135
|
const { credential, controlTimeframe, dataTimeframe } = response.space;
|
|
2126
2136
|
const assertion = (0, import_credentials8.getCredentialAssertion)(credential);
|
|
2127
|
-
(0,
|
|
2128
|
-
(0,
|
|
2137
|
+
(0, import_tiny_invariant8.default)(assertion["@type"] === "dxos.halo.credentials.SpaceMember", "Invalid credential");
|
|
2138
|
+
(0, import_tiny_invariant8.default)(credential.subject.id.equals(this._signingContext.identityKey));
|
|
2129
2139
|
await this._spaceManager.acceptSpace({
|
|
2130
2140
|
spaceKey: assertion.spaceKey,
|
|
2131
2141
|
genesisFeedKey: assertion.genesisFeedKey,
|
|
@@ -2140,7 +2150,7 @@ var SpaceInvitationProtocol = class {
|
|
|
2140
2150
|
};
|
|
2141
2151
|
|
|
2142
2152
|
// packages/sdk/client-services/src/packlets/services/service-context.ts
|
|
2143
|
-
var
|
|
2153
|
+
var import_tiny_invariant11 = __toESM(require("tiny-invariant"));
|
|
2144
2154
|
var import_async14 = require("@dxos/async");
|
|
2145
2155
|
var import_credentials13 = require("@dxos/credentials");
|
|
2146
2156
|
var import_debug6 = require("@dxos/debug");
|
|
@@ -2154,7 +2164,7 @@ var import_services9 = require("@dxos/protocols/proto/dxos/client/services");
|
|
|
2154
2164
|
var import_teleport_extension_object_sync = require("@dxos/teleport-extension-object-sync");
|
|
2155
2165
|
|
|
2156
2166
|
// packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts
|
|
2157
|
-
var
|
|
2167
|
+
var import_tiny_invariant10 = __toESM(require("tiny-invariant"));
|
|
2158
2168
|
var import_async12 = require("@dxos/async");
|
|
2159
2169
|
var import_context7 = require("@dxos/context");
|
|
2160
2170
|
var import_credentials12 = require("@dxos/credentials");
|
|
@@ -2180,7 +2190,7 @@ var import_timeframe = require("@dxos/timeframe");
|
|
|
2180
2190
|
var import_util4 = require("@dxos/util");
|
|
2181
2191
|
|
|
2182
2192
|
// packages/sdk/client-services/src/packlets/spaces/notarization-plugin.ts
|
|
2183
|
-
var
|
|
2193
|
+
var import_tiny_invariant9 = __toESM(require("tiny-invariant"));
|
|
2184
2194
|
var import_async10 = require("@dxos/async");
|
|
2185
2195
|
var import_context5 = require("@dxos/context");
|
|
2186
2196
|
var import_keys7 = require("@dxos/keys");
|
|
@@ -2188,6 +2198,7 @@ var import_log8 = require("@dxos/log");
|
|
|
2188
2198
|
var import_protocols5 = require("@dxos/protocols");
|
|
2189
2199
|
var import_teleport2 = require("@dxos/teleport");
|
|
2190
2200
|
var import_util3 = require("@dxos/util");
|
|
2201
|
+
var __dxlog_file8 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/notarization-plugin.ts";
|
|
2191
2202
|
var DEFAULT_RETRY_TIMEOUT = 1e3;
|
|
2192
2203
|
var DEFAULT_SUCCESS_DELAY = 1e3;
|
|
2193
2204
|
var DEFAULT_NOTARIZE_TIMEOUT = 1e4;
|
|
@@ -2200,6 +2211,9 @@ var NotarizationPlugin = class {
|
|
|
2200
2211
|
this._processedCredentials = new import_util3.ComplexSet(import_keys7.PublicKey.hash);
|
|
2201
2212
|
this._processCredentialsTriggers = new import_util3.ComplexMap(import_keys7.PublicKey.hash);
|
|
2202
2213
|
}
|
|
2214
|
+
get hasWriter() {
|
|
2215
|
+
return !!this._writer;
|
|
2216
|
+
}
|
|
2203
2217
|
async open() {
|
|
2204
2218
|
}
|
|
2205
2219
|
async close() {
|
|
@@ -2212,22 +2226,22 @@ var NotarizationPlugin = class {
|
|
|
2212
2226
|
(0, import_log8.log)("notarize", {
|
|
2213
2227
|
credentials
|
|
2214
2228
|
}, {
|
|
2215
|
-
|
|
2216
|
-
|
|
2217
|
-
|
|
2218
|
-
|
|
2229
|
+
F: __dxlog_file8,
|
|
2230
|
+
L: 91,
|
|
2231
|
+
S: this,
|
|
2232
|
+
C: (f, a) => f(...a)
|
|
2219
2233
|
});
|
|
2220
|
-
(0,
|
|
2234
|
+
(0, import_tiny_invariant9.default)(credentials.every((credential) => credential.id), "Credentials must have an id");
|
|
2221
2235
|
const errors = new import_async10.Trigger();
|
|
2222
2236
|
const ctx = this._ctx.derive({
|
|
2223
2237
|
onError: (err) => {
|
|
2224
2238
|
import_log8.log.warn("Notarization error", {
|
|
2225
2239
|
err
|
|
2226
2240
|
}, {
|
|
2227
|
-
|
|
2228
|
-
|
|
2229
|
-
|
|
2230
|
-
|
|
2241
|
+
F: __dxlog_file8,
|
|
2242
|
+
L: 100,
|
|
2243
|
+
S: this,
|
|
2244
|
+
C: (f, a) => f(...a)
|
|
2231
2245
|
});
|
|
2232
2246
|
void ctx.dispose();
|
|
2233
2247
|
errors.throw(err);
|
|
@@ -2240,10 +2254,10 @@ var NotarizationPlugin = class {
|
|
|
2240
2254
|
timeout,
|
|
2241
2255
|
peers: Array.from(this._extensions).map((extension) => extension.remotePeerId)
|
|
2242
2256
|
}, {
|
|
2243
|
-
|
|
2244
|
-
|
|
2245
|
-
|
|
2246
|
-
|
|
2257
|
+
F: __dxlog_file8,
|
|
2258
|
+
L: 112,
|
|
2259
|
+
S: this,
|
|
2260
|
+
C: (f, a) => f(...a)
|
|
2247
2261
|
});
|
|
2248
2262
|
void ctx.dispose();
|
|
2249
2263
|
errors.throw(new import_async10.TimeoutError(timeout, "Notarization timed out"));
|
|
@@ -2263,10 +2277,10 @@ var NotarizationPlugin = class {
|
|
|
2263
2277
|
import_log8.log.warn("Exhausted all peers to notarize with", {
|
|
2264
2278
|
retryIn: retryTimeout
|
|
2265
2279
|
}, {
|
|
2266
|
-
|
|
2267
|
-
|
|
2268
|
-
|
|
2269
|
-
|
|
2280
|
+
F: __dxlog_file8,
|
|
2281
|
+
L: 137,
|
|
2282
|
+
S: this,
|
|
2283
|
+
C: (f, a) => f(...a)
|
|
2270
2284
|
});
|
|
2271
2285
|
peersTried.clear();
|
|
2272
2286
|
(0, import_async10.scheduleTask)(ctx, () => notarizeTask.schedule(), retryTimeout);
|
|
@@ -2277,28 +2291,28 @@ var NotarizationPlugin = class {
|
|
|
2277
2291
|
peer: peer.localPeerId,
|
|
2278
2292
|
credentialId: credentials.map((credential) => credential.id)
|
|
2279
2293
|
}, {
|
|
2280
|
-
|
|
2281
|
-
|
|
2282
|
-
|
|
2283
|
-
|
|
2294
|
+
F: __dxlog_file8,
|
|
2295
|
+
L: 144,
|
|
2296
|
+
S: this,
|
|
2297
|
+
C: (f, a) => f(...a)
|
|
2284
2298
|
});
|
|
2285
2299
|
await peer.rpc.NotarizationService.notarize({
|
|
2286
2300
|
credentials: credentials.filter((credential) => !this._processedCredentials.has(credential.id))
|
|
2287
2301
|
});
|
|
2288
|
-
(0, import_log8.log)("success",
|
|
2289
|
-
|
|
2290
|
-
|
|
2291
|
-
|
|
2292
|
-
|
|
2302
|
+
(0, import_log8.log)("success", void 0, {
|
|
2303
|
+
F: __dxlog_file8,
|
|
2304
|
+
L: 148,
|
|
2305
|
+
S: this,
|
|
2306
|
+
C: (f, a) => f(...a)
|
|
2293
2307
|
});
|
|
2294
2308
|
await (0, import_async10.sleep)(successDelay);
|
|
2295
2309
|
} catch (err) {
|
|
2296
2310
|
if (!ctx.disposed && !err.message.includes(WRITER_NOT_SET_ERROR_CODE)) {
|
|
2297
2311
|
import_log8.log.warn("error notarizing (recoverable)", err, {
|
|
2298
|
-
|
|
2299
|
-
|
|
2300
|
-
|
|
2301
|
-
|
|
2312
|
+
F: __dxlog_file8,
|
|
2313
|
+
L: 152,
|
|
2314
|
+
S: this,
|
|
2315
|
+
C: (f, a) => f(...a)
|
|
2302
2316
|
});
|
|
2303
2317
|
}
|
|
2304
2318
|
notarizeTask.schedule();
|
|
@@ -2312,11 +2326,11 @@ var NotarizationPlugin = class {
|
|
|
2312
2326
|
allNotarized,
|
|
2313
2327
|
errors.wait()
|
|
2314
2328
|
]);
|
|
2315
|
-
(0, import_log8.log)("done",
|
|
2316
|
-
|
|
2317
|
-
|
|
2318
|
-
|
|
2319
|
-
|
|
2329
|
+
(0, import_log8.log)("done", void 0, {
|
|
2330
|
+
F: __dxlog_file8,
|
|
2331
|
+
L: 163,
|
|
2332
|
+
S: this,
|
|
2333
|
+
C: (f, a) => f(...a)
|
|
2320
2334
|
});
|
|
2321
2335
|
} finally {
|
|
2322
2336
|
await ctx.dispose();
|
|
@@ -2325,7 +2339,7 @@ var NotarizationPlugin = class {
|
|
|
2325
2339
|
/**
|
|
2326
2340
|
* Called with credentials arriving from the control pipeline.
|
|
2327
2341
|
*/
|
|
2328
|
-
async
|
|
2342
|
+
async processCredential(credential) {
|
|
2329
2343
|
var _a;
|
|
2330
2344
|
if (!credential.id) {
|
|
2331
2345
|
return;
|
|
@@ -2335,7 +2349,7 @@ var NotarizationPlugin = class {
|
|
|
2335
2349
|
this._processCredentialsTriggers.delete(credential.id);
|
|
2336
2350
|
}
|
|
2337
2351
|
setWriter(writer) {
|
|
2338
|
-
(0,
|
|
2352
|
+
(0, import_tiny_invariant9.default)(!this._writer, "Writer already set.");
|
|
2339
2353
|
this._writer = writer;
|
|
2340
2354
|
}
|
|
2341
2355
|
async _waitUntilProcessed(id) {
|
|
@@ -2353,7 +2367,7 @@ var NotarizationPlugin = class {
|
|
|
2353
2367
|
throw new Error(WRITER_NOT_SET_ERROR_CODE);
|
|
2354
2368
|
}
|
|
2355
2369
|
for (const credential of (_a = request.credentials) != null ? _a : []) {
|
|
2356
|
-
(0,
|
|
2370
|
+
(0, import_tiny_invariant9.default)(credential.id, "Credential must have an id");
|
|
2357
2371
|
if (this._processedCredentials.has(credential.id)) {
|
|
2358
2372
|
continue;
|
|
2359
2373
|
}
|
|
@@ -2366,10 +2380,10 @@ var NotarizationPlugin = class {
|
|
|
2366
2380
|
(0, import_log8.log)("extension opened", {
|
|
2367
2381
|
peer: extension.localPeerId
|
|
2368
2382
|
}, {
|
|
2369
|
-
|
|
2370
|
-
|
|
2371
|
-
|
|
2372
|
-
|
|
2383
|
+
F: __dxlog_file8,
|
|
2384
|
+
L: 212,
|
|
2385
|
+
S: this,
|
|
2386
|
+
C: (f, a) => f(...a)
|
|
2373
2387
|
});
|
|
2374
2388
|
this._extensions.add(extension);
|
|
2375
2389
|
this._extensionOpened.emit();
|
|
@@ -2378,10 +2392,10 @@ var NotarizationPlugin = class {
|
|
|
2378
2392
|
(0, import_log8.log)("extension closed", {
|
|
2379
2393
|
peer: extension.localPeerId
|
|
2380
2394
|
}, {
|
|
2381
|
-
|
|
2382
|
-
|
|
2383
|
-
|
|
2384
|
-
|
|
2395
|
+
F: __dxlog_file8,
|
|
2396
|
+
L: 217,
|
|
2397
|
+
S: this,
|
|
2398
|
+
C: (f, a) => f(...a)
|
|
2385
2399
|
});
|
|
2386
2400
|
this._extensions.delete(extension);
|
|
2387
2401
|
},
|
|
@@ -2422,7 +2436,7 @@ var NotarizationTeleportExtension = class extends import_teleport2.RpcExtension
|
|
|
2422
2436
|
};
|
|
2423
2437
|
|
|
2424
2438
|
// packages/sdk/client-services/src/packlets/spaces/data-space.ts
|
|
2425
|
-
|
|
2439
|
+
function _ts_decorate(decorators, target, key, desc) {
|
|
2426
2440
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2427
2441
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
2428
2442
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -2431,10 +2445,12 @@ var __decorate = function(decorators, target, key, desc) {
|
|
|
2431
2445
|
if (d = decorators[i])
|
|
2432
2446
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
2433
2447
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2434
|
-
}
|
|
2448
|
+
}
|
|
2449
|
+
var __dxlog_file9 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space.ts";
|
|
2435
2450
|
var DataSpace = class DataSpace2 {
|
|
2436
2451
|
constructor(params) {
|
|
2437
2452
|
this._ctx = new import_context6.Context();
|
|
2453
|
+
this._notarizationPlugin = new NotarizationPlugin();
|
|
2438
2454
|
this._state = import_services6.SpaceState.CLOSED;
|
|
2439
2455
|
/**
|
|
2440
2456
|
* Error for _state === SpaceState.ERROR.
|
|
@@ -2457,8 +2473,8 @@ var DataSpace = class DataSpace2 {
|
|
|
2457
2473
|
update: this._inner.stateUpdate,
|
|
2458
2474
|
authTimeout: import_client_protocol3.AUTH_TIMEOUT
|
|
2459
2475
|
});
|
|
2460
|
-
this._notarizationPluginConsumer = this._inner.spaceState.registerProcessor(new NotarizationPlugin());
|
|
2461
2476
|
this._cache = params.cache;
|
|
2477
|
+
this._state = params.initialState;
|
|
2462
2478
|
}
|
|
2463
2479
|
get key() {
|
|
2464
2480
|
return this._inner.key;
|
|
@@ -2480,25 +2496,36 @@ var DataSpace = class DataSpace2 {
|
|
|
2480
2496
|
return this._presence;
|
|
2481
2497
|
}
|
|
2482
2498
|
get notarizationPlugin() {
|
|
2483
|
-
return this.
|
|
2499
|
+
return this._notarizationPlugin;
|
|
2484
2500
|
}
|
|
2485
2501
|
get cache() {
|
|
2486
2502
|
return this._cache;
|
|
2487
2503
|
}
|
|
2488
2504
|
async open() {
|
|
2489
|
-
await this.
|
|
2490
|
-
|
|
2505
|
+
await this._open();
|
|
2506
|
+
}
|
|
2507
|
+
async _open() {
|
|
2508
|
+
await this._notarizationPlugin.open();
|
|
2509
|
+
await this._inner.spaceState.addCredentialProcessor(this._notarizationPlugin);
|
|
2491
2510
|
await this._inner.open();
|
|
2492
|
-
this._state = import_services6.SpaceState.
|
|
2511
|
+
this._state = import_services6.SpaceState.CONTROL_ONLY;
|
|
2512
|
+
this.stateUpdate.emit();
|
|
2513
|
+
this.metrics = {};
|
|
2493
2514
|
this.metrics.open = new Date();
|
|
2494
2515
|
}
|
|
2495
2516
|
async close() {
|
|
2517
|
+
await this._close();
|
|
2518
|
+
}
|
|
2519
|
+
async _close() {
|
|
2520
|
+
var _a, _b;
|
|
2521
|
+
await ((_b = (_a = this._callbacks).beforeClose) == null ? void 0 : _b.call(_a));
|
|
2496
2522
|
this._state = import_services6.SpaceState.CLOSED;
|
|
2497
2523
|
await this._ctx.dispose();
|
|
2524
|
+
this._ctx = new import_context6.Context();
|
|
2498
2525
|
await this.authVerifier.close();
|
|
2499
2526
|
await this._inner.close();
|
|
2500
|
-
await this.
|
|
2501
|
-
await this.
|
|
2527
|
+
await this._inner.spaceState.removeCredentialProcessor(this._notarizationPlugin);
|
|
2528
|
+
await this._notarizationPlugin.close();
|
|
2502
2529
|
await this._presence.destroy();
|
|
2503
2530
|
}
|
|
2504
2531
|
async postMessage(channel, message) {
|
|
@@ -2518,18 +2545,18 @@ var DataSpace = class DataSpace2 {
|
|
|
2518
2545
|
} catch (err) {
|
|
2519
2546
|
if (err instanceof import_errors3.CancelledError) {
|
|
2520
2547
|
(0, import_log9.log)("Data pipeline initialization cancelled", err, {
|
|
2521
|
-
|
|
2522
|
-
|
|
2523
|
-
|
|
2524
|
-
|
|
2548
|
+
F: __dxlog_file9,
|
|
2549
|
+
L: 193,
|
|
2550
|
+
S: this,
|
|
2551
|
+
C: (f, a) => f(...a)
|
|
2525
2552
|
});
|
|
2526
2553
|
return;
|
|
2527
2554
|
}
|
|
2528
2555
|
import_log9.log.error("Error initializing data pipeline", err, {
|
|
2529
|
-
|
|
2530
|
-
|
|
2531
|
-
|
|
2532
|
-
|
|
2556
|
+
F: __dxlog_file9,
|
|
2557
|
+
L: 197,
|
|
2558
|
+
S: this,
|
|
2559
|
+
C: (f, a) => f(...a)
|
|
2533
2560
|
});
|
|
2534
2561
|
this._state = import_services6.SpaceState.ERROR;
|
|
2535
2562
|
this.error = err;
|
|
@@ -2541,7 +2568,7 @@ var DataSpace = class DataSpace2 {
|
|
|
2541
2568
|
}
|
|
2542
2569
|
async initializeDataPipeline() {
|
|
2543
2570
|
var _a, _b, _c, _d;
|
|
2544
|
-
if (this._state !== import_services6.SpaceState.
|
|
2571
|
+
if (this._state !== import_services6.SpaceState.CONTROL_ONLY) {
|
|
2545
2572
|
throw new import_errors3.SystemError("Invalid operation");
|
|
2546
2573
|
}
|
|
2547
2574
|
this._state = import_services6.SpaceState.INITIALIZING;
|
|
@@ -2551,37 +2578,39 @@ var DataSpace = class DataSpace2 {
|
|
|
2551
2578
|
});
|
|
2552
2579
|
this.metrics.controlPipelineReady = new Date();
|
|
2553
2580
|
await this._createWritableFeeds();
|
|
2554
|
-
(0, import_log9.log)("Writable feeds created",
|
|
2555
|
-
|
|
2556
|
-
|
|
2557
|
-
|
|
2558
|
-
|
|
2581
|
+
(0, import_log9.log)("Writable feeds created", void 0, {
|
|
2582
|
+
F: __dxlog_file9,
|
|
2583
|
+
L: 221,
|
|
2584
|
+
S: this,
|
|
2585
|
+
C: (f, a) => f(...a)
|
|
2559
2586
|
});
|
|
2560
2587
|
this.stateUpdate.emit();
|
|
2561
|
-
this.notarizationPlugin.
|
|
2562
|
-
credential
|
|
2563
|
-
credential
|
|
2564
|
-
|
|
2565
|
-
|
|
2588
|
+
if (!this.notarizationPlugin.hasWriter) {
|
|
2589
|
+
this.notarizationPlugin.setWriter((0, import_echo_pipeline.createMappedFeedWriter)((credential) => ({
|
|
2590
|
+
credential: {
|
|
2591
|
+
credential
|
|
2592
|
+
}
|
|
2593
|
+
}), this._inner.controlPipeline.writer));
|
|
2594
|
+
}
|
|
2566
2595
|
await this._inner.initializeDataPipeline();
|
|
2567
2596
|
this.metrics.dataPipelineOpen = new Date();
|
|
2568
2597
|
await (0, import_context6.cancelWithContext)(this._ctx, this._inner.dataPipeline.ensureEpochInitialized());
|
|
2569
|
-
(0, import_log9.log)("waiting for data pipeline to reach target timeframe",
|
|
2570
|
-
|
|
2571
|
-
|
|
2572
|
-
|
|
2573
|
-
|
|
2598
|
+
(0, import_log9.log)("waiting for data pipeline to reach target timeframe", void 0, {
|
|
2599
|
+
F: __dxlog_file9,
|
|
2600
|
+
L: 242,
|
|
2601
|
+
S: this,
|
|
2602
|
+
C: (f, a) => f(...a)
|
|
2574
2603
|
});
|
|
2575
2604
|
await this._inner.dataPipeline.pipelineState.waitUntilReachedTargetTimeframe({
|
|
2576
2605
|
ctx: this._ctx,
|
|
2577
2606
|
breakOnStall: false
|
|
2578
2607
|
});
|
|
2579
2608
|
this.metrics.dataPipelineReady = new Date();
|
|
2580
|
-
(0, import_log9.log)("data pipeline ready",
|
|
2581
|
-
|
|
2582
|
-
|
|
2583
|
-
|
|
2584
|
-
|
|
2609
|
+
(0, import_log9.log)("data pipeline ready", void 0, {
|
|
2610
|
+
F: __dxlog_file9,
|
|
2611
|
+
L: 251,
|
|
2612
|
+
S: this,
|
|
2613
|
+
C: (f, a) => f(...a)
|
|
2585
2614
|
});
|
|
2586
2615
|
await ((_b = (_a = this._callbacks).beforeReady) == null ? void 0 : _b.call(_a));
|
|
2587
2616
|
this._state = import_services6.SpaceState.READY;
|
|
@@ -2659,11 +2688,40 @@ var DataSpace = class DataSpace2 {
|
|
|
2659
2688
|
}
|
|
2660
2689
|
}
|
|
2661
2690
|
}
|
|
2691
|
+
async activate() {
|
|
2692
|
+
if (this._state !== import_services6.SpaceState.INACTIVE) {
|
|
2693
|
+
throw new import_errors3.SystemError("Invalid operation");
|
|
2694
|
+
}
|
|
2695
|
+
await this._metadataStore.setSpaceState(this.key, import_services6.SpaceState.ACTIVE);
|
|
2696
|
+
await this._open();
|
|
2697
|
+
this.initializeDataPipelineAsync();
|
|
2698
|
+
}
|
|
2699
|
+
async deactivate() {
|
|
2700
|
+
if (this._state === import_services6.SpaceState.INACTIVE) {
|
|
2701
|
+
throw new import_errors3.SystemError("Invalid operation");
|
|
2702
|
+
}
|
|
2703
|
+
await this._metadataStore.setSpaceState(this.key, import_services6.SpaceState.INACTIVE);
|
|
2704
|
+
await this._close();
|
|
2705
|
+
this._state = import_services6.SpaceState.INACTIVE;
|
|
2706
|
+
this.stateUpdate.emit();
|
|
2707
|
+
}
|
|
2662
2708
|
};
|
|
2663
|
-
|
|
2709
|
+
_ts_decorate([
|
|
2710
|
+
import_async11.synchronized
|
|
2711
|
+
], DataSpace.prototype, "open", null);
|
|
2712
|
+
_ts_decorate([
|
|
2713
|
+
import_async11.synchronized
|
|
2714
|
+
], DataSpace.prototype, "close", null);
|
|
2715
|
+
_ts_decorate([
|
|
2664
2716
|
(0, import_debug3.timed)(1e4)
|
|
2665
2717
|
], DataSpace.prototype, "_createWritableFeeds", null);
|
|
2666
|
-
|
|
2718
|
+
_ts_decorate([
|
|
2719
|
+
import_async11.synchronized
|
|
2720
|
+
], DataSpace.prototype, "activate", null);
|
|
2721
|
+
_ts_decorate([
|
|
2722
|
+
import_async11.synchronized
|
|
2723
|
+
], DataSpace.prototype, "deactivate", null);
|
|
2724
|
+
DataSpace = _ts_decorate([
|
|
2667
2725
|
(0, import_async11.trackLeaks)("open", "close")
|
|
2668
2726
|
], DataSpace);
|
|
2669
2727
|
|
|
@@ -2738,7 +2796,7 @@ var spaceGenesis = async (keyring, signingContext, space) => {
|
|
|
2738
2796
|
};
|
|
2739
2797
|
|
|
2740
2798
|
// packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts
|
|
2741
|
-
|
|
2799
|
+
function _ts_decorate2(decorators, target, key, desc) {
|
|
2742
2800
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2743
2801
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
2744
2802
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -2747,7 +2805,8 @@ var __decorate2 = function(decorators, target, key, desc) {
|
|
|
2747
2805
|
if (d = decorators[i])
|
|
2748
2806
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
2749
2807
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2750
|
-
}
|
|
2808
|
+
}
|
|
2809
|
+
var __dxlog_file10 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts";
|
|
2751
2810
|
var DataSpaceManager = class DataSpaceManager2 {
|
|
2752
2811
|
constructor(_spaceManager, _metadataStore, _dataServiceSubscriptions, _keyring, _signingContext, _feedStore) {
|
|
2753
2812
|
this._spaceManager = _spaceManager;
|
|
@@ -2767,50 +2826,52 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2767
2826
|
return this._spaces;
|
|
2768
2827
|
}
|
|
2769
2828
|
async open() {
|
|
2770
|
-
(0, import_log10.log)("open",
|
|
2771
|
-
|
|
2772
|
-
|
|
2773
|
-
|
|
2774
|
-
|
|
2829
|
+
(0, import_log10.log)("open", void 0, {
|
|
2830
|
+
F: __dxlog_file10,
|
|
2831
|
+
L: 80,
|
|
2832
|
+
S: this,
|
|
2833
|
+
C: (f, a) => f(...a)
|
|
2775
2834
|
});
|
|
2776
2835
|
import_log10.log.trace("dxos.echo.data-space-manager.open", import_protocols6.trace.begin({
|
|
2777
2836
|
id: this._instanceId
|
|
2778
2837
|
}), {
|
|
2779
|
-
|
|
2780
|
-
|
|
2781
|
-
|
|
2782
|
-
|
|
2838
|
+
F: __dxlog_file10,
|
|
2839
|
+
L: 81,
|
|
2840
|
+
S: this,
|
|
2841
|
+
C: (f, a) => f(...a)
|
|
2783
2842
|
});
|
|
2784
2843
|
await this._metadataStore.load();
|
|
2785
2844
|
(0, import_log10.log)("metadata loaded", {
|
|
2786
2845
|
spaces: this._metadataStore.spaces.length
|
|
2787
2846
|
}, {
|
|
2788
|
-
|
|
2789
|
-
|
|
2790
|
-
|
|
2791
|
-
|
|
2847
|
+
F: __dxlog_file10,
|
|
2848
|
+
L: 83,
|
|
2849
|
+
S: this,
|
|
2850
|
+
C: (f, a) => f(...a)
|
|
2792
2851
|
});
|
|
2793
2852
|
for (const spaceMetadata of this._metadataStore.spaces) {
|
|
2794
2853
|
try {
|
|
2795
2854
|
(0, import_log10.log)("load space", {
|
|
2796
2855
|
spaceMetadata
|
|
2797
2856
|
}, {
|
|
2798
|
-
|
|
2799
|
-
|
|
2800
|
-
|
|
2801
|
-
|
|
2857
|
+
F: __dxlog_file10,
|
|
2858
|
+
L: 87,
|
|
2859
|
+
S: this,
|
|
2860
|
+
C: (f, a) => f(...a)
|
|
2802
2861
|
});
|
|
2803
2862
|
const space = await this._constructSpace(spaceMetadata);
|
|
2804
|
-
|
|
2863
|
+
if (spaceMetadata.state !== import_services7.SpaceState.INACTIVE) {
|
|
2864
|
+
space.initializeDataPipelineAsync();
|
|
2865
|
+
}
|
|
2805
2866
|
} catch (err) {
|
|
2806
2867
|
import_log10.log.error("Error loading space", {
|
|
2807
2868
|
spaceMetadata,
|
|
2808
2869
|
err
|
|
2809
2870
|
}, {
|
|
2810
|
-
|
|
2811
|
-
|
|
2812
|
-
|
|
2813
|
-
|
|
2871
|
+
F: __dxlog_file10,
|
|
2872
|
+
L: 93,
|
|
2873
|
+
S: this,
|
|
2874
|
+
C: (f, a) => f(...a)
|
|
2814
2875
|
});
|
|
2815
2876
|
}
|
|
2816
2877
|
}
|
|
@@ -2819,18 +2880,18 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2819
2880
|
import_log10.log.trace("dxos.echo.data-space-manager.open", import_protocols6.trace.end({
|
|
2820
2881
|
id: this._instanceId
|
|
2821
2882
|
}), {
|
|
2822
|
-
|
|
2823
|
-
|
|
2824
|
-
|
|
2825
|
-
|
|
2883
|
+
F: __dxlog_file10,
|
|
2884
|
+
L: 99,
|
|
2885
|
+
S: this,
|
|
2886
|
+
C: (f, a) => f(...a)
|
|
2826
2887
|
});
|
|
2827
2888
|
}
|
|
2828
2889
|
async close() {
|
|
2829
|
-
(0, import_log10.log)("close",
|
|
2830
|
-
|
|
2831
|
-
|
|
2832
|
-
|
|
2833
|
-
|
|
2890
|
+
(0, import_log10.log)("close", void 0, {
|
|
2891
|
+
F: __dxlog_file10,
|
|
2892
|
+
L: 104,
|
|
2893
|
+
S: this,
|
|
2894
|
+
C: (f, a) => f(...a)
|
|
2834
2895
|
});
|
|
2835
2896
|
this._isOpen = false;
|
|
2836
2897
|
await this._ctx.dispose();
|
|
@@ -2842,7 +2903,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2842
2903
|
* Creates a new space writing the genesis credentials to the control feed.
|
|
2843
2904
|
*/
|
|
2844
2905
|
async createSpace() {
|
|
2845
|
-
(0,
|
|
2906
|
+
(0, import_tiny_invariant10.default)(this._isOpen, "Not open.");
|
|
2846
2907
|
const spaceKey = await this._keyring.createKey();
|
|
2847
2908
|
const controlFeedKey = await this._keyring.createKey();
|
|
2848
2909
|
const dataFeedKey = await this._keyring.createKey();
|
|
@@ -2850,21 +2911,22 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2850
2911
|
key: spaceKey,
|
|
2851
2912
|
genesisFeedKey: controlFeedKey,
|
|
2852
2913
|
controlFeedKey,
|
|
2853
|
-
dataFeedKey
|
|
2914
|
+
dataFeedKey,
|
|
2915
|
+
state: import_services7.SpaceState.ACTIVE
|
|
2854
2916
|
};
|
|
2855
2917
|
(0, import_log10.log)("creating space...", {
|
|
2856
2918
|
spaceKey
|
|
2857
2919
|
}, {
|
|
2858
|
-
|
|
2859
|
-
|
|
2860
|
-
|
|
2861
|
-
|
|
2920
|
+
F: __dxlog_file10,
|
|
2921
|
+
L: 129,
|
|
2922
|
+
S: this,
|
|
2923
|
+
C: (f, a) => f(...a)
|
|
2862
2924
|
});
|
|
2863
2925
|
const space = await this._constructSpace(metadata);
|
|
2864
2926
|
const credentials = await spaceGenesis(this._keyring, this._signingContext, space.inner);
|
|
2865
2927
|
await this._metadataStore.addSpace(metadata);
|
|
2866
2928
|
const memberCredential = credentials[1];
|
|
2867
|
-
(0,
|
|
2929
|
+
(0, import_tiny_invariant10.default)((0, import_credentials12.getCredentialAssertion)(memberCredential)["@type"] === "dxos.halo.credentials.SpaceMember");
|
|
2868
2930
|
await this._signingContext.recordCredential(memberCredential);
|
|
2869
2931
|
await space.initializeDataPipeline();
|
|
2870
2932
|
this.updated.emit();
|
|
@@ -2875,13 +2937,13 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2875
2937
|
(0, import_log10.log)("accept space", {
|
|
2876
2938
|
opts
|
|
2877
2939
|
}, {
|
|
2878
|
-
|
|
2879
|
-
|
|
2880
|
-
|
|
2881
|
-
|
|
2940
|
+
F: __dxlog_file10,
|
|
2941
|
+
L: 148,
|
|
2942
|
+
S: this,
|
|
2943
|
+
C: (f, a) => f(...a)
|
|
2882
2944
|
});
|
|
2883
|
-
(0,
|
|
2884
|
-
(0,
|
|
2945
|
+
(0, import_tiny_invariant10.default)(this._isOpen, "Not open.");
|
|
2946
|
+
(0, import_tiny_invariant10.default)(!this._spaces.has(opts.spaceKey), "Space already exists.");
|
|
2885
2947
|
const metadata = {
|
|
2886
2948
|
key: opts.spaceKey,
|
|
2887
2949
|
genesisFeedKey: opts.genesisFeedKey,
|
|
@@ -2909,10 +2971,10 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2909
2971
|
(0, import_log10.log)("construct space", {
|
|
2910
2972
|
metadata
|
|
2911
2973
|
}, {
|
|
2912
|
-
|
|
2913
|
-
|
|
2914
|
-
|
|
2915
|
-
|
|
2974
|
+
F: __dxlog_file10,
|
|
2975
|
+
L: 183,
|
|
2976
|
+
S: this,
|
|
2977
|
+
C: (f, a) => f(...a)
|
|
2916
2978
|
});
|
|
2917
2979
|
const gossip = new import_teleport_extension_gossip.Gossip({
|
|
2918
2980
|
localPeerId: this._signingContext.deviceKey
|
|
@@ -2944,11 +3006,11 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2944
3006
|
session.addExtension("dxos.mesh.teleport.notarization", dataSpace.notarizationPlugin.createExtension());
|
|
2945
3007
|
},
|
|
2946
3008
|
onAuthFailure: () => {
|
|
2947
|
-
import_log10.log.warn("auth failure",
|
|
2948
|
-
|
|
2949
|
-
|
|
2950
|
-
|
|
2951
|
-
|
|
3009
|
+
import_log10.log.warn("auth failure", void 0, {
|
|
3010
|
+
F: __dxlog_file10,
|
|
3011
|
+
L: 214,
|
|
3012
|
+
S: this,
|
|
3013
|
+
C: (f, a) => f(...a)
|
|
2952
3014
|
});
|
|
2953
3015
|
},
|
|
2954
3016
|
memberKey: this._signingContext.identityKey
|
|
@@ -2957,6 +3019,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2957
3019
|
dataFeed && space.setDataFeed(dataFeed);
|
|
2958
3020
|
const dataSpace = new DataSpace({
|
|
2959
3021
|
inner: space,
|
|
3022
|
+
initialState: metadata.state === import_services7.SpaceState.INACTIVE ? import_services7.SpaceState.INACTIVE : import_services7.SpaceState.CLOSED,
|
|
2960
3023
|
metadataStore: this._metadataStore,
|
|
2961
3024
|
gossip,
|
|
2962
3025
|
presence,
|
|
@@ -2968,31 +3031,44 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2968
3031
|
(0, import_log10.log)("before space ready", {
|
|
2969
3032
|
space: space.key
|
|
2970
3033
|
}, {
|
|
2971
|
-
|
|
2972
|
-
|
|
2973
|
-
|
|
2974
|
-
|
|
3034
|
+
F: __dxlog_file10,
|
|
3035
|
+
L: 232,
|
|
3036
|
+
S: this,
|
|
3037
|
+
C: (f, a) => f(...a)
|
|
2975
3038
|
});
|
|
2976
|
-
this._dataServiceSubscriptions.registerSpace(space.key, dataSpace.dataPipeline.databaseHost.createDataServiceHost());
|
|
3039
|
+
await this._dataServiceSubscriptions.registerSpace(space.key, dataSpace.dataPipeline.databaseHost.createDataServiceHost());
|
|
2977
3040
|
},
|
|
2978
3041
|
afterReady: async () => {
|
|
2979
3042
|
(0, import_log10.log)("after space ready", {
|
|
2980
3043
|
space: space.key,
|
|
2981
3044
|
open: this._isOpen
|
|
2982
3045
|
}, {
|
|
2983
|
-
|
|
2984
|
-
|
|
2985
|
-
|
|
2986
|
-
|
|
3046
|
+
F: __dxlog_file10,
|
|
3047
|
+
L: 239,
|
|
3048
|
+
S: this,
|
|
3049
|
+
C: (f, a) => f(...a)
|
|
2987
3050
|
});
|
|
2988
3051
|
if (this._isOpen) {
|
|
2989
3052
|
this.updated.emit();
|
|
2990
3053
|
}
|
|
3054
|
+
},
|
|
3055
|
+
beforeClose: async () => {
|
|
3056
|
+
(0, import_log10.log)("before space close", {
|
|
3057
|
+
space: space.key
|
|
3058
|
+
}, {
|
|
3059
|
+
F: __dxlog_file10,
|
|
3060
|
+
L: 245,
|
|
3061
|
+
S: this,
|
|
3062
|
+
C: (f, a) => f(...a)
|
|
3063
|
+
});
|
|
3064
|
+
await this._dataServiceSubscriptions.unregisterSpace(space.key);
|
|
2991
3065
|
}
|
|
2992
3066
|
},
|
|
2993
3067
|
cache: metadata.cache
|
|
2994
3068
|
});
|
|
2995
|
-
|
|
3069
|
+
if (metadata.state !== import_services7.SpaceState.INACTIVE) {
|
|
3070
|
+
await dataSpace.open();
|
|
3071
|
+
}
|
|
2996
3072
|
if (metadata.controlTimeframe) {
|
|
2997
3073
|
dataSpace.inner.controlPipeline.state.setTargetTimeframe(metadata.controlTimeframe);
|
|
2998
3074
|
}
|
|
@@ -3003,19 +3079,19 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
3003
3079
|
return dataSpace;
|
|
3004
3080
|
}
|
|
3005
3081
|
};
|
|
3006
|
-
|
|
3082
|
+
_ts_decorate2([
|
|
3007
3083
|
import_async12.synchronized
|
|
3008
3084
|
], DataSpaceManager.prototype, "open", null);
|
|
3009
|
-
|
|
3085
|
+
_ts_decorate2([
|
|
3010
3086
|
import_async12.synchronized
|
|
3011
3087
|
], DataSpaceManager.prototype, "close", null);
|
|
3012
|
-
|
|
3088
|
+
_ts_decorate2([
|
|
3013
3089
|
import_async12.synchronized
|
|
3014
3090
|
], DataSpaceManager.prototype, "createSpace", null);
|
|
3015
|
-
|
|
3091
|
+
_ts_decorate2([
|
|
3016
3092
|
import_async12.synchronized
|
|
3017
3093
|
], DataSpaceManager.prototype, "acceptSpace", null);
|
|
3018
|
-
DataSpaceManager =
|
|
3094
|
+
DataSpaceManager = _ts_decorate2([
|
|
3019
3095
|
(0, import_async12.trackLeaks)("open", "close")
|
|
3020
3096
|
], DataSpaceManager);
|
|
3021
3097
|
|
|
@@ -3024,11 +3100,12 @@ var import_async13 = require("@dxos/async");
|
|
|
3024
3100
|
var import_codec_protobuf9 = require("@dxos/codec-protobuf");
|
|
3025
3101
|
var import_debug5 = require("@dxos/debug");
|
|
3026
3102
|
var import_echo_pipeline2 = require("@dxos/echo-pipeline");
|
|
3103
|
+
var import_errors4 = require("@dxos/errors");
|
|
3027
3104
|
var import_log11 = require("@dxos/log");
|
|
3028
3105
|
var import_protocols7 = require("@dxos/protocols");
|
|
3029
3106
|
var import_services8 = require("@dxos/protocols/proto/dxos/client/services");
|
|
3030
3107
|
var import_util6 = require("@dxos/util");
|
|
3031
|
-
var
|
|
3108
|
+
var __dxlog_file11 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/spaces-service.ts";
|
|
3032
3109
|
var SpacesServiceImpl = class {
|
|
3033
3110
|
constructor(_identityManager, _spaceManager, _dataServiceSubscriptions, _getDataSpaceManager) {
|
|
3034
3111
|
this._identityManager = _identityManager;
|
|
@@ -3042,28 +3119,44 @@ var SpacesServiceImpl = class {
|
|
|
3042
3119
|
}
|
|
3043
3120
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
3044
3121
|
const space = await dataSpaceManager.createSpace();
|
|
3045
|
-
return this.
|
|
3122
|
+
return this._serializeSpace(space);
|
|
3046
3123
|
}
|
|
3047
|
-
async updateSpace(
|
|
3048
|
-
|
|
3124
|
+
async updateSpace({ spaceKey, state }) {
|
|
3125
|
+
var _a;
|
|
3126
|
+
const dataSpaceManager = await this._getDataSpaceManager();
|
|
3127
|
+
const space = (_a = dataSpaceManager.spaces.get(spaceKey)) != null ? _a : (0, import_debug5.raise)(new import_echo_pipeline2.SpaceNotFoundError(spaceKey));
|
|
3128
|
+
if (state) {
|
|
3129
|
+
switch (state) {
|
|
3130
|
+
case import_services8.SpaceState.ACTIVE:
|
|
3131
|
+
await space.activate();
|
|
3132
|
+
break;
|
|
3133
|
+
case import_services8.SpaceState.INACTIVE:
|
|
3134
|
+
await space.deactivate();
|
|
3135
|
+
break;
|
|
3136
|
+
default:
|
|
3137
|
+
throw new import_errors4.ApiError("Invalid space state");
|
|
3138
|
+
}
|
|
3139
|
+
}
|
|
3049
3140
|
}
|
|
3050
3141
|
querySpaces() {
|
|
3051
3142
|
return new import_codec_protobuf9.Stream(({ next, ctx }) => {
|
|
3052
|
-
const
|
|
3143
|
+
const scheduler = new import_async13.UpdateScheduler(ctx, async () => {
|
|
3053
3144
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
3054
|
-
const spaces = Array.from(dataSpaceManager.spaces.values()).map((space) => this.
|
|
3145
|
+
const spaces = Array.from(dataSpaceManager.spaces.values()).map((space) => this._serializeSpace(space));
|
|
3055
3146
|
(0, import_log11.log)("update", {
|
|
3056
3147
|
spaces
|
|
3057
3148
|
}, {
|
|
3058
|
-
|
|
3059
|
-
|
|
3060
|
-
|
|
3061
|
-
|
|
3149
|
+
F: __dxlog_file11,
|
|
3150
|
+
L: 78,
|
|
3151
|
+
S: this,
|
|
3152
|
+
C: (f, a) => f(...a)
|
|
3062
3153
|
});
|
|
3063
3154
|
next({
|
|
3064
3155
|
spaces
|
|
3065
3156
|
});
|
|
3066
|
-
}
|
|
3157
|
+
}, {
|
|
3158
|
+
maxFrequency: 2
|
|
3159
|
+
});
|
|
3067
3160
|
(0, import_async13.scheduleTask)(ctx, async () => {
|
|
3068
3161
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
3069
3162
|
const subscriptions = new import_async13.EventSubscriptions();
|
|
@@ -3071,21 +3164,21 @@ var SpacesServiceImpl = class {
|
|
|
3071
3164
|
const subscribeSpaces = () => {
|
|
3072
3165
|
subscriptions.clear();
|
|
3073
3166
|
for (const space of dataSpaceManager.spaces.values()) {
|
|
3074
|
-
subscriptions.add(space.stateUpdate.on(ctx,
|
|
3075
|
-
subscriptions.add(space.presence.updated.on(ctx,
|
|
3076
|
-
subscriptions.add(space.dataPipeline.onNewEpoch.on(ctx,
|
|
3077
|
-
space.inner.controlPipeline.state.timeframeUpdate.
|
|
3167
|
+
subscriptions.add(space.stateUpdate.on(ctx, () => scheduler.trigger()));
|
|
3168
|
+
subscriptions.add(space.presence.updated.on(ctx, () => scheduler.trigger()));
|
|
3169
|
+
subscriptions.add(space.dataPipeline.onNewEpoch.on(ctx, () => scheduler.trigger()));
|
|
3170
|
+
space.inner.controlPipeline.state.timeframeUpdate.on(ctx, () => scheduler.trigger());
|
|
3078
3171
|
if (space.dataPipeline.pipelineState) {
|
|
3079
|
-
subscriptions.add(space.dataPipeline.pipelineState.timeframeUpdate.
|
|
3172
|
+
subscriptions.add(space.dataPipeline.pipelineState.timeframeUpdate.on(ctx, () => scheduler.trigger()));
|
|
3080
3173
|
}
|
|
3081
3174
|
}
|
|
3082
3175
|
};
|
|
3083
3176
|
dataSpaceManager.updated.on(ctx, () => {
|
|
3084
3177
|
subscribeSpaces();
|
|
3085
|
-
|
|
3178
|
+
scheduler.trigger();
|
|
3086
3179
|
});
|
|
3087
3180
|
subscribeSpaces();
|
|
3088
|
-
|
|
3181
|
+
scheduler.trigger();
|
|
3089
3182
|
});
|
|
3090
3183
|
if (!this._identityManager.identity) {
|
|
3091
3184
|
next({
|
|
@@ -3117,13 +3210,13 @@ var SpacesServiceImpl = class {
|
|
|
3117
3210
|
return new import_codec_protobuf9.Stream(({ ctx, next }) => {
|
|
3118
3211
|
var _a;
|
|
3119
3212
|
const space = (_a = this._spaceManager.spaces.get(spaceKey)) != null ? _a : (0, import_debug5.raise)(new import_echo_pipeline2.SpaceNotFoundError(spaceKey));
|
|
3120
|
-
const processor =
|
|
3121
|
-
|
|
3213
|
+
const processor = {
|
|
3214
|
+
processCredential: async (credential) => {
|
|
3122
3215
|
next(credential);
|
|
3123
3216
|
}
|
|
3124
|
-
}
|
|
3125
|
-
ctx.onDispose(() =>
|
|
3126
|
-
(0, import_async13.scheduleTask)(ctx, () =>
|
|
3217
|
+
};
|
|
3218
|
+
ctx.onDispose(() => space.spaceState.removeCredentialProcessor(processor));
|
|
3219
|
+
(0, import_async13.scheduleTask)(ctx, () => space.spaceState.addCredentialProcessor(processor));
|
|
3127
3220
|
});
|
|
3128
3221
|
}
|
|
3129
3222
|
async writeCredentials({ spaceKey, credentials }) {
|
|
@@ -3143,7 +3236,7 @@ var SpacesServiceImpl = class {
|
|
|
3143
3236
|
const space = (_a = dataSpaceManager.spaces.get(spaceKey)) != null ? _a : (0, import_debug5.raise)(new import_echo_pipeline2.SpaceNotFoundError(spaceKey));
|
|
3144
3237
|
await space.createEpoch();
|
|
3145
3238
|
}
|
|
3146
|
-
|
|
3239
|
+
_serializeSpace(space) {
|
|
3147
3240
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
3148
3241
|
return {
|
|
3149
3242
|
spaceKey: space.key,
|
|
@@ -3183,6 +3276,7 @@ var SpacesServiceImpl = class {
|
|
|
3183
3276
|
var getChannelId = (channel) => `user-channel/${channel}`;
|
|
3184
3277
|
|
|
3185
3278
|
// packages/sdk/client-services/src/packlets/services/service-context.ts
|
|
3279
|
+
var __dxlog_file12 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-context.ts";
|
|
3186
3280
|
var ServiceContext = class {
|
|
3187
3281
|
// prettier-ignore
|
|
3188
3282
|
constructor(storage, networkManager, signalManager, modelFactory) {
|
|
@@ -3226,17 +3320,17 @@ var ServiceContext = class {
|
|
|
3226
3320
|
import_log12.log.trace("dxos.sdk.service-context.open", import_protocols8.trace.begin({
|
|
3227
3321
|
id: this._instanceId
|
|
3228
3322
|
}), {
|
|
3229
|
-
|
|
3230
|
-
|
|
3231
|
-
|
|
3232
|
-
|
|
3323
|
+
F: __dxlog_file12,
|
|
3324
|
+
L: 126,
|
|
3325
|
+
S: this,
|
|
3326
|
+
C: (f, a) => f(...a)
|
|
3233
3327
|
});
|
|
3234
3328
|
await this._checkStorageVersion();
|
|
3235
|
-
(0, import_log12.log)("opening...",
|
|
3236
|
-
|
|
3237
|
-
|
|
3238
|
-
|
|
3239
|
-
|
|
3329
|
+
(0, import_log12.log)("opening...", void 0, {
|
|
3330
|
+
F: __dxlog_file12,
|
|
3331
|
+
L: 130,
|
|
3332
|
+
S: this,
|
|
3333
|
+
C: (f, a) => f(...a)
|
|
3240
3334
|
});
|
|
3241
3335
|
await this.signalManager.open();
|
|
3242
3336
|
await this.networkManager.open();
|
|
@@ -3245,42 +3339,44 @@ var ServiceContext = class {
|
|
|
3245
3339
|
if (this.identityManager.identity) {
|
|
3246
3340
|
await this._initialize();
|
|
3247
3341
|
}
|
|
3248
|
-
(0, import_log12.log)("opened",
|
|
3249
|
-
|
|
3250
|
-
|
|
3251
|
-
|
|
3252
|
-
|
|
3342
|
+
(0, import_log12.log)("opened", void 0, {
|
|
3343
|
+
F: __dxlog_file12,
|
|
3344
|
+
L: 138,
|
|
3345
|
+
S: this,
|
|
3346
|
+
C: (f, a) => f(...a)
|
|
3253
3347
|
});
|
|
3254
3348
|
import_log12.log.trace("dxos.sdk.service-context.open", import_protocols8.trace.end({
|
|
3255
3349
|
id: this._instanceId
|
|
3256
3350
|
}), {
|
|
3257
|
-
|
|
3258
|
-
|
|
3259
|
-
|
|
3260
|
-
|
|
3351
|
+
F: __dxlog_file12,
|
|
3352
|
+
L: 139,
|
|
3353
|
+
S: this,
|
|
3354
|
+
C: (f, a) => f(...a)
|
|
3261
3355
|
});
|
|
3262
3356
|
}
|
|
3263
3357
|
async close() {
|
|
3264
|
-
var _a
|
|
3265
|
-
(0, import_log12.log)("closing...",
|
|
3266
|
-
|
|
3267
|
-
|
|
3268
|
-
|
|
3269
|
-
|
|
3270
|
-
});
|
|
3271
|
-
|
|
3272
|
-
|
|
3358
|
+
var _a;
|
|
3359
|
+
(0, import_log12.log)("closing...", void 0, {
|
|
3360
|
+
F: __dxlog_file12,
|
|
3361
|
+
L: 143,
|
|
3362
|
+
S: this,
|
|
3363
|
+
C: (f, a) => f(...a)
|
|
3364
|
+
});
|
|
3365
|
+
if (this._deviceSpaceSync && this.identityManager.identity) {
|
|
3366
|
+
await this.identityManager.identity.space.spaceState.removeCredentialProcessor(this._deviceSpaceSync);
|
|
3367
|
+
}
|
|
3368
|
+
await ((_a = this.dataSpaceManager) == null ? void 0 : _a.close());
|
|
3273
3369
|
await this.identityManager.close();
|
|
3274
3370
|
await this.spaceManager.close();
|
|
3275
3371
|
await this.feedStore.close();
|
|
3276
3372
|
await this.networkManager.close();
|
|
3277
3373
|
await this.signalManager.close();
|
|
3278
3374
|
this.dataServiceSubscriptions.clear();
|
|
3279
|
-
(0, import_log12.log)("closed",
|
|
3280
|
-
|
|
3281
|
-
|
|
3282
|
-
|
|
3283
|
-
|
|
3375
|
+
(0, import_log12.log)("closed", void 0, {
|
|
3376
|
+
F: __dxlog_file12,
|
|
3377
|
+
L: 154,
|
|
3378
|
+
S: this,
|
|
3379
|
+
C: (f, a) => f(...a)
|
|
3284
3380
|
});
|
|
3285
3381
|
}
|
|
3286
3382
|
async createIdentity(params = {}) {
|
|
@@ -3290,7 +3386,7 @@ var ServiceContext = class {
|
|
|
3290
3386
|
}
|
|
3291
3387
|
getInvitationHandler(invitation) {
|
|
3292
3388
|
const factory = this._handlerFactories.get(invitation.kind);
|
|
3293
|
-
(0,
|
|
3389
|
+
(0, import_tiny_invariant11.default)(factory, `Unknown invitation kind: ${invitation.kind}`);
|
|
3294
3390
|
return factory(invitation);
|
|
3295
3391
|
}
|
|
3296
3392
|
async _acceptIdentity(params) {
|
|
@@ -3307,11 +3403,11 @@ var ServiceContext = class {
|
|
|
3307
3403
|
// Called when identity is created.
|
|
3308
3404
|
async _initialize() {
|
|
3309
3405
|
var _a;
|
|
3310
|
-
(0, import_log12.log)("initializing spaces...",
|
|
3311
|
-
|
|
3312
|
-
|
|
3313
|
-
|
|
3314
|
-
|
|
3406
|
+
(0, import_log12.log)("initializing spaces...", void 0, {
|
|
3407
|
+
F: __dxlog_file12,
|
|
3408
|
+
L: 187,
|
|
3409
|
+
S: this,
|
|
3410
|
+
C: (f, a) => f(...a)
|
|
3315
3411
|
});
|
|
3316
3412
|
const identity = (_a = this.identityManager.identity) != null ? _a : (0, import_debug6.failUndefined)();
|
|
3317
3413
|
const signingContext = {
|
|
@@ -3330,12 +3426,12 @@ var ServiceContext = class {
|
|
|
3330
3426
|
this.dataSpaceManager = new DataSpaceManager(this.spaceManager, this.metadataStore, this.dataServiceSubscriptions, this.keyring, signingContext, this.feedStore);
|
|
3331
3427
|
await this.dataSpaceManager.open();
|
|
3332
3428
|
this._handlerFactories.set(import_services9.Invitation.Kind.SPACE, (invitation) => {
|
|
3333
|
-
(0,
|
|
3429
|
+
(0, import_tiny_invariant11.default)(this.dataSpaceManager, "dataSpaceManager not initialized yet");
|
|
3334
3430
|
return new SpaceInvitationProtocol(this.dataSpaceManager, signingContext, this.keyring, invitation.spaceKey);
|
|
3335
3431
|
});
|
|
3336
3432
|
this.initialized.wake();
|
|
3337
|
-
this._deviceSpaceSync =
|
|
3338
|
-
|
|
3433
|
+
this._deviceSpaceSync = {
|
|
3434
|
+
processCredential: async (credential) => {
|
|
3339
3435
|
const assertion = (0, import_credentials13.getCredentialAssertion)(credential);
|
|
3340
3436
|
if (assertion["@type"] !== "dxos.halo.credentials.SpaceMember") {
|
|
3341
3437
|
return;
|
|
@@ -3347,10 +3443,10 @@ var ServiceContext = class {
|
|
|
3347
3443
|
(0, import_log12.log)("dataSpaceManager not initialized yet, ignoring space admission", {
|
|
3348
3444
|
details: assertion
|
|
3349
3445
|
}, {
|
|
3350
|
-
|
|
3351
|
-
|
|
3352
|
-
|
|
3353
|
-
|
|
3446
|
+
F: __dxlog_file12,
|
|
3447
|
+
L: 226,
|
|
3448
|
+
S: this,
|
|
3449
|
+
C: (f, a) => f(...a)
|
|
3354
3450
|
});
|
|
3355
3451
|
return;
|
|
3356
3452
|
}
|
|
@@ -3358,10 +3454,10 @@ var ServiceContext = class {
|
|
|
3358
3454
|
(0, import_log12.log)("space already exists, ignoring space admission", {
|
|
3359
3455
|
details: assertion
|
|
3360
3456
|
}, {
|
|
3361
|
-
|
|
3362
|
-
|
|
3363
|
-
|
|
3364
|
-
|
|
3457
|
+
F: __dxlog_file12,
|
|
3458
|
+
L: 230,
|
|
3459
|
+
S: this,
|
|
3460
|
+
C: (f, a) => f(...a)
|
|
3365
3461
|
});
|
|
3366
3462
|
return;
|
|
3367
3463
|
}
|
|
@@ -3369,40 +3465,43 @@ var ServiceContext = class {
|
|
|
3369
3465
|
(0, import_log12.log)("accepting space recorded in halo", {
|
|
3370
3466
|
details: assertion
|
|
3371
3467
|
}, {
|
|
3372
|
-
|
|
3373
|
-
|
|
3374
|
-
|
|
3375
|
-
|
|
3468
|
+
F: __dxlog_file12,
|
|
3469
|
+
L: 235,
|
|
3470
|
+
S: this,
|
|
3471
|
+
C: (f, a) => f(...a)
|
|
3376
3472
|
});
|
|
3377
3473
|
await this.dataSpaceManager.acceptSpace({
|
|
3378
3474
|
spaceKey: assertion.spaceKey,
|
|
3379
3475
|
genesisFeedKey: assertion.genesisFeedKey
|
|
3380
3476
|
});
|
|
3381
3477
|
} catch (err) {
|
|
3382
|
-
import_log12.log.catch(err,
|
|
3383
|
-
|
|
3384
|
-
|
|
3385
|
-
|
|
3386
|
-
|
|
3478
|
+
import_log12.log.catch(err, void 0, {
|
|
3479
|
+
F: __dxlog_file12,
|
|
3480
|
+
L: 241,
|
|
3481
|
+
S: this,
|
|
3482
|
+
C: (f, a) => f(...a)
|
|
3387
3483
|
});
|
|
3388
3484
|
}
|
|
3389
3485
|
}
|
|
3390
|
-
}
|
|
3391
|
-
await this._deviceSpaceSync
|
|
3486
|
+
};
|
|
3487
|
+
await identity.space.spaceState.addCredentialProcessor(this._deviceSpaceSync);
|
|
3392
3488
|
}
|
|
3393
3489
|
};
|
|
3394
3490
|
|
|
3395
3491
|
// packages/sdk/client-services/src/packlets/services/service-host.ts
|
|
3396
|
-
var
|
|
3492
|
+
var import_tiny_invariant13 = __toESM(require("tiny-invariant"));
|
|
3397
3493
|
var import_async17 = require("@dxos/async");
|
|
3398
3494
|
var import_client_protocol5 = require("@dxos/client-protocol");
|
|
3495
|
+
var import_document_model = require("@dxos/document-model");
|
|
3399
3496
|
var import_echo_pipeline4 = require("@dxos/echo-pipeline");
|
|
3400
3497
|
var import_keys11 = require("@dxos/keys");
|
|
3401
3498
|
var import_log15 = require("@dxos/log");
|
|
3402
3499
|
var import_messaging = require("@dxos/messaging");
|
|
3500
|
+
var import_model_factory = require("@dxos/model-factory");
|
|
3403
3501
|
var import_network_manager2 = require("@dxos/network-manager");
|
|
3404
3502
|
var import_protocols9 = require("@dxos/protocols");
|
|
3405
3503
|
var import_services12 = require("@dxos/protocols/proto/dxos/client/services");
|
|
3504
|
+
var import_text_model = require("@dxos/text-model");
|
|
3406
3505
|
|
|
3407
3506
|
// packages/sdk/client-services/src/packlets/devices/devices-service.ts
|
|
3408
3507
|
var import_async15 = require("@dxos/async");
|
|
@@ -3452,10 +3551,10 @@ var DevicesServiceImpl = class {
|
|
|
3452
3551
|
};
|
|
3453
3552
|
|
|
3454
3553
|
// packages/sdk/client-services/src/packlets/locks/node.ts
|
|
3455
|
-
var
|
|
3554
|
+
var import_tiny_invariant12 = __toESM(require("tiny-invariant"));
|
|
3456
3555
|
var import_lock_file = require("@dxos/lock-file");
|
|
3457
3556
|
var import_log13 = require("@dxos/log");
|
|
3458
|
-
|
|
3557
|
+
function _ts_decorate3(decorators, target, key, desc) {
|
|
3459
3558
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3460
3559
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
3461
3560
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -3464,7 +3563,8 @@ var __decorate3 = function(decorators, target, key, desc) {
|
|
|
3464
3563
|
if (d = decorators[i])
|
|
3465
3564
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
3466
3565
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3467
|
-
}
|
|
3566
|
+
}
|
|
3567
|
+
var __dxlog_file13 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/locks/node.ts";
|
|
3468
3568
|
var Lock = class {
|
|
3469
3569
|
constructor({ lockKey: lockPath, onAcquire, onRelease }) {
|
|
3470
3570
|
this._lockPath = lockPath;
|
|
@@ -3476,29 +3576,29 @@ var Lock = class {
|
|
|
3476
3576
|
}
|
|
3477
3577
|
async acquire() {
|
|
3478
3578
|
var _a;
|
|
3479
|
-
(0, import_log13.log)("acquiring lock...",
|
|
3480
|
-
|
|
3481
|
-
|
|
3482
|
-
|
|
3483
|
-
|
|
3579
|
+
(0, import_log13.log)("acquiring lock...", void 0, {
|
|
3580
|
+
F: __dxlog_file13,
|
|
3581
|
+
L: 32,
|
|
3582
|
+
S: this,
|
|
3583
|
+
C: (f, a) => f(...a)
|
|
3484
3584
|
});
|
|
3485
3585
|
this._fileHandle = await import_lock_file.LockFile.acquire(this._lockPath);
|
|
3486
3586
|
await ((_a = this._onAcquire) == null ? void 0 : _a.call(this));
|
|
3487
|
-
(0, import_log13.log)("acquired lock",
|
|
3488
|
-
|
|
3489
|
-
|
|
3490
|
-
|
|
3491
|
-
|
|
3587
|
+
(0, import_log13.log)("acquired lock", void 0, {
|
|
3588
|
+
F: __dxlog_file13,
|
|
3589
|
+
L: 37,
|
|
3590
|
+
S: this,
|
|
3591
|
+
C: (f, a) => f(...a)
|
|
3492
3592
|
});
|
|
3493
3593
|
}
|
|
3494
3594
|
async release() {
|
|
3495
3595
|
var _a;
|
|
3496
3596
|
await ((_a = this._onRelease) == null ? void 0 : _a.call(this));
|
|
3497
|
-
(0,
|
|
3597
|
+
(0, import_tiny_invariant12.default)(this._fileHandle, "Lock is not acquired");
|
|
3498
3598
|
await import_lock_file.LockFile.release(this._fileHandle);
|
|
3499
3599
|
}
|
|
3500
3600
|
};
|
|
3501
|
-
|
|
3601
|
+
_ts_decorate3([
|
|
3502
3602
|
import_log13.logInfo
|
|
3503
3603
|
], Lock.prototype, "lockKey", null);
|
|
3504
3604
|
var isLocked = (lockPath) => import_lock_file.LockFile.isLocked(lockPath);
|
|
@@ -3530,7 +3630,7 @@ var LoggingServiceImpl = class {
|
|
|
3530
3630
|
if (LOG_PROCESSING > 0) {
|
|
3531
3631
|
return;
|
|
3532
3632
|
}
|
|
3533
|
-
if (((_a = entry2.meta) == null ? void 0 : _a.
|
|
3633
|
+
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"))) {
|
|
3534
3634
|
return;
|
|
3535
3635
|
}
|
|
3536
3636
|
if (!shouldLog(entry2, request)) {
|
|
@@ -3542,8 +3642,8 @@ var LoggingServiceImpl = class {
|
|
|
3542
3642
|
timestamp: new Date(),
|
|
3543
3643
|
meta: {
|
|
3544
3644
|
// TODO(dmaretskyi): Fix proto.
|
|
3545
|
-
file: (_c = (_b = entry2.meta) == null ? void 0 : _b.
|
|
3546
|
-
line: (_e = (_d = entry2.meta) == null ? void 0 : _d.
|
|
3645
|
+
file: (_c = (_b = entry2.meta) == null ? void 0 : _b.F) != null ? _c : "",
|
|
3646
|
+
line: (_e = (_d = entry2.meta) == null ? void 0 : _d.L) != null ? _e : 0
|
|
3547
3647
|
}
|
|
3548
3648
|
};
|
|
3549
3649
|
try {
|
|
@@ -3573,7 +3673,7 @@ var shouldLog = (entry2, request) => {
|
|
|
3573
3673
|
} else {
|
|
3574
3674
|
return request.filters.some((filter) => {
|
|
3575
3675
|
var _a2, _b;
|
|
3576
|
-
return matchFilter(filter, entry2.level, (_b = (_a2 = entry2.meta) == null ? void 0 : _a2.
|
|
3676
|
+
return matchFilter(filter, entry2.level, (_b = (_a2 = entry2.meta) == null ? void 0 : _a2.F) != null ? _b : "", options);
|
|
3577
3677
|
});
|
|
3578
3678
|
}
|
|
3579
3679
|
};
|
|
@@ -3613,7 +3713,7 @@ var NetworkServiceImpl = class {
|
|
|
3613
3713
|
|
|
3614
3714
|
// packages/sdk/client-services/src/packlets/storage/storage.ts
|
|
3615
3715
|
var import_client_protocol4 = require("@dxos/client-protocol");
|
|
3616
|
-
var
|
|
3716
|
+
var import_errors5 = require("@dxos/errors");
|
|
3617
3717
|
var import_config = require("@dxos/protocols/proto/dxos/config");
|
|
3618
3718
|
var import_random_access_storage = require("@dxos/random-access-storage");
|
|
3619
3719
|
var import_util8 = require("@dxos/util");
|
|
@@ -3621,16 +3721,16 @@ var StorageDriver = import_config.Runtime.Client.Storage.StorageDriver;
|
|
|
3621
3721
|
var createStorageObjects = (config) => {
|
|
3622
3722
|
const { path = (0, import_util8.isNode)() ? import_client_protocol4.DX_DATA : "dxos/storage", storageType, keyStorage, persistent = false } = config != null ? config : {};
|
|
3623
3723
|
if (persistent && storageType === StorageDriver.RAM) {
|
|
3624
|
-
throw new
|
|
3724
|
+
throw new import_errors5.InvalidConfigError("RAM storage cannot be used in persistent mode.");
|
|
3625
3725
|
}
|
|
3626
3726
|
if (!persistent && storageType !== void 0 && storageType !== StorageDriver.RAM) {
|
|
3627
|
-
throw new
|
|
3727
|
+
throw new import_errors5.InvalidConfigError("Cannot use a persistent storage in not persistent mode.");
|
|
3628
3728
|
}
|
|
3629
3729
|
if (persistent && keyStorage === StorageDriver.RAM) {
|
|
3630
|
-
throw new
|
|
3730
|
+
throw new import_errors5.InvalidConfigError("RAM key storage cannot be used in persistent mode.");
|
|
3631
3731
|
}
|
|
3632
3732
|
if (!persistent && keyStorage !== StorageDriver.RAM && keyStorage !== void 0) {
|
|
3633
|
-
throw new
|
|
3733
|
+
throw new import_errors5.InvalidConfigError("Cannot use a persistent key storage in not persistent mode.");
|
|
3634
3734
|
}
|
|
3635
3735
|
return {
|
|
3636
3736
|
storage: (0, import_random_access_storage.createStorage)({
|
|
@@ -3723,23 +3823,39 @@ var ServiceRegistry = class {
|
|
|
3723
3823
|
};
|
|
3724
3824
|
|
|
3725
3825
|
// packages/sdk/client-services/src/packlets/services/service-host.ts
|
|
3826
|
+
function _ts_decorate4(decorators, target, key, desc) {
|
|
3827
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3828
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
3829
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
3830
|
+
else
|
|
3831
|
+
for (var i = decorators.length - 1; i >= 0; i--)
|
|
3832
|
+
if (d = decorators[i])
|
|
3833
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
3834
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3835
|
+
}
|
|
3836
|
+
var __dxlog_file14 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-host.ts";
|
|
3837
|
+
var createDefaultModelFactory = () => {
|
|
3838
|
+
return new import_model_factory.ModelFactory().registerModel(import_document_model.DocumentModel).registerModel(import_text_model.TextModel);
|
|
3839
|
+
};
|
|
3726
3840
|
var ClientServicesHost = class {
|
|
3727
3841
|
constructor({
|
|
3728
3842
|
config,
|
|
3729
|
-
modelFactory =
|
|
3843
|
+
modelFactory = createDefaultModelFactory(),
|
|
3730
3844
|
// TODO(burdon): Create ApolloLink abstraction (see Client).
|
|
3731
3845
|
transportFactory,
|
|
3732
3846
|
signalManager,
|
|
3733
3847
|
connectionLog,
|
|
3734
3848
|
storage,
|
|
3735
3849
|
// TODO(wittjosiah): Turn this on by default.
|
|
3736
|
-
lockKey
|
|
3850
|
+
lockKey,
|
|
3851
|
+
callbacks
|
|
3737
3852
|
} = {}) {
|
|
3738
3853
|
this._statusUpdate = new import_async17.Event();
|
|
3739
3854
|
this._opening = false;
|
|
3740
3855
|
this._open = false;
|
|
3741
3856
|
this._storage = storage;
|
|
3742
3857
|
this._modelFactory = modelFactory;
|
|
3858
|
+
this._callbacks = callbacks;
|
|
3743
3859
|
if (config) {
|
|
3744
3860
|
this.initialize({
|
|
3745
3861
|
config,
|
|
@@ -3798,9 +3914,9 @@ var ClientServicesHost = class {
|
|
|
3798
3914
|
*/
|
|
3799
3915
|
initialize({ config, ...options }) {
|
|
3800
3916
|
var _a, _b, _c;
|
|
3801
|
-
(0,
|
|
3917
|
+
(0, import_tiny_invariant13.default)(!this._open, "service host is open");
|
|
3802
3918
|
if (config) {
|
|
3803
|
-
(0,
|
|
3919
|
+
(0, import_tiny_invariant13.default)(!this._config, "config already set");
|
|
3804
3920
|
this._config = config;
|
|
3805
3921
|
if (!this._storage) {
|
|
3806
3922
|
this._storage = createStorageObjects(config.get("runtime.client.storage", {})).storage;
|
|
@@ -3810,7 +3926,7 @@ var ClientServicesHost = class {
|
|
|
3810
3926
|
iceServers: (_a = this._config) == null ? void 0 : _a.get("runtime.services.ice")
|
|
3811
3927
|
}), signalManager = new import_messaging.WebsocketSignalManager((_c = (_b = this._config) == null ? void 0 : _b.get("runtime.services.signaling")) != null ? _c : []) } = options;
|
|
3812
3928
|
this._signalManager = signalManager;
|
|
3813
|
-
(0,
|
|
3929
|
+
(0, import_tiny_invariant13.default)(!this._networkManager, "network manager already set");
|
|
3814
3930
|
this._networkManager = new import_network_manager2.NetworkManager({
|
|
3815
3931
|
log: connectionLog,
|
|
3816
3932
|
transportFactory,
|
|
@@ -3826,23 +3942,23 @@ var ClientServicesHost = class {
|
|
|
3826
3942
|
import_log15.log.trace("dxos.sdk.client-services-host.open", import_protocols9.trace.begin({
|
|
3827
3943
|
id: traceId
|
|
3828
3944
|
}), {
|
|
3829
|
-
|
|
3830
|
-
|
|
3831
|
-
|
|
3832
|
-
|
|
3833
|
-
});
|
|
3834
|
-
(0,
|
|
3835
|
-
(0,
|
|
3836
|
-
(0,
|
|
3837
|
-
(0,
|
|
3945
|
+
F: __dxlog_file14,
|
|
3946
|
+
L: 203,
|
|
3947
|
+
S: this,
|
|
3948
|
+
C: (f, a) => f(...a)
|
|
3949
|
+
});
|
|
3950
|
+
(0, import_tiny_invariant13.default)(this._config, "config not set");
|
|
3951
|
+
(0, import_tiny_invariant13.default)(this._storage, "storage not set");
|
|
3952
|
+
(0, import_tiny_invariant13.default)(this._signalManager, "signal manager not set");
|
|
3953
|
+
(0, import_tiny_invariant13.default)(this._networkManager, "network manager not set");
|
|
3838
3954
|
this._opening = true;
|
|
3839
3955
|
(0, import_log15.log)("opening...", {
|
|
3840
3956
|
lockKey: (_a = this._resourceLock) == null ? void 0 : _a.lockKey
|
|
3841
3957
|
}, {
|
|
3842
|
-
|
|
3843
|
-
|
|
3844
|
-
|
|
3845
|
-
|
|
3958
|
+
F: __dxlog_file14,
|
|
3959
|
+
L: 211,
|
|
3960
|
+
S: this,
|
|
3961
|
+
C: (f, a) => f(...a)
|
|
3846
3962
|
});
|
|
3847
3963
|
await ((_b = this._resourceLock) == null ? void 0 : _b.acquire());
|
|
3848
3964
|
await this._loggingService.open();
|
|
@@ -3874,18 +3990,18 @@ var ClientServicesHost = class {
|
|
|
3874
3990
|
(0, import_log15.log)("opened", {
|
|
3875
3991
|
deviceKey
|
|
3876
3992
|
}, {
|
|
3877
|
-
|
|
3878
|
-
|
|
3879
|
-
|
|
3880
|
-
|
|
3993
|
+
F: __dxlog_file14,
|
|
3994
|
+
L: 266,
|
|
3995
|
+
S: this,
|
|
3996
|
+
C: (f, a) => f(...a)
|
|
3881
3997
|
});
|
|
3882
3998
|
import_log15.log.trace("dxos.sdk.client-services-host.open", import_protocols9.trace.end({
|
|
3883
3999
|
id: traceId
|
|
3884
4000
|
}), {
|
|
3885
|
-
|
|
3886
|
-
|
|
3887
|
-
|
|
3888
|
-
|
|
4001
|
+
F: __dxlog_file14,
|
|
4002
|
+
L: 267,
|
|
4003
|
+
S: this,
|
|
4004
|
+
C: (f, a) => f(...a)
|
|
3889
4005
|
});
|
|
3890
4006
|
}
|
|
3891
4007
|
async close() {
|
|
@@ -3897,10 +4013,10 @@ var ClientServicesHost = class {
|
|
|
3897
4013
|
(0, import_log15.log)("closing...", {
|
|
3898
4014
|
deviceKey
|
|
3899
4015
|
}, {
|
|
3900
|
-
|
|
3901
|
-
|
|
3902
|
-
|
|
3903
|
-
|
|
4016
|
+
F: __dxlog_file14,
|
|
4017
|
+
L: 277,
|
|
4018
|
+
S: this,
|
|
4019
|
+
C: (f, a) => f(...a)
|
|
3904
4020
|
});
|
|
3905
4021
|
this._serviceRegistry.setServices({
|
|
3906
4022
|
SystemService: this._systemService
|
|
@@ -3912,47 +4028,54 @@ var ClientServicesHost = class {
|
|
|
3912
4028
|
(0, import_log15.log)("closed", {
|
|
3913
4029
|
deviceKey
|
|
3914
4030
|
}, {
|
|
3915
|
-
|
|
3916
|
-
|
|
3917
|
-
|
|
3918
|
-
|
|
4031
|
+
F: __dxlog_file14,
|
|
4032
|
+
L: 283,
|
|
4033
|
+
S: this,
|
|
4034
|
+
C: (f, a) => f(...a)
|
|
3919
4035
|
});
|
|
3920
4036
|
}
|
|
3921
4037
|
async reset() {
|
|
3922
|
-
var _a;
|
|
4038
|
+
var _a, _b, _c;
|
|
3923
4039
|
const traceId = import_keys11.PublicKey.random().toHex();
|
|
3924
4040
|
import_log15.log.trace("dxos.sdk.client-services-host.reset", import_protocols9.trace.begin({
|
|
3925
4041
|
id: traceId
|
|
3926
4042
|
}), {
|
|
3927
|
-
|
|
3928
|
-
|
|
3929
|
-
|
|
3930
|
-
|
|
4043
|
+
F: __dxlog_file14,
|
|
4044
|
+
L: 288,
|
|
4045
|
+
S: this,
|
|
4046
|
+
C: (f, a) => f(...a)
|
|
3931
4047
|
});
|
|
3932
|
-
(0, import_log15.log)("resetting...",
|
|
3933
|
-
|
|
3934
|
-
|
|
3935
|
-
|
|
3936
|
-
|
|
4048
|
+
(0, import_log15.log)("resetting...", void 0, {
|
|
4049
|
+
F: __dxlog_file14,
|
|
4050
|
+
L: 290,
|
|
4051
|
+
S: this,
|
|
4052
|
+
C: (f, a) => f(...a)
|
|
3937
4053
|
});
|
|
3938
4054
|
await ((_a = this._serviceContext) == null ? void 0 : _a.close());
|
|
3939
4055
|
await this._storage.reset();
|
|
3940
|
-
(0, import_log15.log)("reset",
|
|
3941
|
-
|
|
3942
|
-
|
|
3943
|
-
|
|
3944
|
-
|
|
4056
|
+
(0, import_log15.log)("reset", void 0, {
|
|
4057
|
+
F: __dxlog_file14,
|
|
4058
|
+
L: 293,
|
|
4059
|
+
S: this,
|
|
4060
|
+
C: (f, a) => f(...a)
|
|
3945
4061
|
});
|
|
3946
4062
|
import_log15.log.trace("dxos.sdk.client-services-host.reset", import_protocols9.trace.end({
|
|
3947
4063
|
id: traceId
|
|
3948
4064
|
}), {
|
|
3949
|
-
|
|
3950
|
-
|
|
3951
|
-
|
|
3952
|
-
|
|
4065
|
+
F: __dxlog_file14,
|
|
4066
|
+
L: 294,
|
|
4067
|
+
S: this,
|
|
4068
|
+
C: (f, a) => f(...a)
|
|
3953
4069
|
});
|
|
4070
|
+
await ((_c = (_b = this._callbacks) == null ? void 0 : _b.onReset) == null ? void 0 : _c.call(_b));
|
|
3954
4071
|
}
|
|
3955
4072
|
};
|
|
4073
|
+
_ts_decorate4([
|
|
4074
|
+
import_async17.synchronized
|
|
4075
|
+
], ClientServicesHost.prototype, "open", null);
|
|
4076
|
+
_ts_decorate4([
|
|
4077
|
+
import_async17.synchronized
|
|
4078
|
+
], ClientServicesHost.prototype, "close", null);
|
|
3956
4079
|
|
|
3957
4080
|
// packages/sdk/client-services/src/packlets/vault/iframe-host-runtime.ts
|
|
3958
4081
|
var import_async19 = require("@dxos/async");
|
|
@@ -4016,7 +4139,7 @@ var ClientRpcServer = class {
|
|
|
4016
4139
|
};
|
|
4017
4140
|
|
|
4018
4141
|
// packages/sdk/client-services/src/packlets/vault/shell-runtime.ts
|
|
4019
|
-
var
|
|
4142
|
+
var import_tiny_invariant14 = __toESM(require("tiny-invariant"));
|
|
4020
4143
|
var import_async18 = require("@dxos/async");
|
|
4021
4144
|
var import_client_protocol6 = require("@dxos/client-protocol");
|
|
4022
4145
|
var import_iframe = require("@dxos/protocols/proto/dxos/iframe");
|
|
@@ -4046,7 +4169,7 @@ var ShellRuntimeImpl = class {
|
|
|
4046
4169
|
});
|
|
4047
4170
|
}
|
|
4048
4171
|
async setAppContext(context) {
|
|
4049
|
-
(0,
|
|
4172
|
+
(0, import_tiny_invariant14.default)(this._appRpc, "runtime not open");
|
|
4050
4173
|
await this._appRpc.rpc.AppService.setContext(context);
|
|
4051
4174
|
}
|
|
4052
4175
|
async open() {
|
|
@@ -4073,39 +4196,9 @@ var ShellRuntimeImpl = class {
|
|
|
4073
4196
|
this._appRpc = void 0;
|
|
4074
4197
|
}
|
|
4075
4198
|
};
|
|
4076
|
-
var MemoryShellRuntime = class {
|
|
4077
|
-
constructor({ layout, invitationCode, spaceKey } = {}) {
|
|
4078
|
-
this.layoutUpdate = new import_async18.Event();
|
|
4079
|
-
this.contextUpdate = new import_async18.Event();
|
|
4080
|
-
this._layout = layout != null ? layout : import_iframe.ShellLayout.DEFAULT;
|
|
4081
|
-
this._invitationCode = invitationCode;
|
|
4082
|
-
this._spaceKey = spaceKey;
|
|
4083
|
-
}
|
|
4084
|
-
get layout() {
|
|
4085
|
-
return this._layout;
|
|
4086
|
-
}
|
|
4087
|
-
get invitationCode() {
|
|
4088
|
-
return this._invitationCode;
|
|
4089
|
-
}
|
|
4090
|
-
get spaceKey() {
|
|
4091
|
-
return this._spaceKey;
|
|
4092
|
-
}
|
|
4093
|
-
setLayout(layout, options = {}) {
|
|
4094
|
-
this._layout = layout;
|
|
4095
|
-
this._invitationCode = options.invitationCode;
|
|
4096
|
-
this._spaceKey = options.spaceKey;
|
|
4097
|
-
this.layoutUpdate.emit({
|
|
4098
|
-
layout,
|
|
4099
|
-
...options
|
|
4100
|
-
});
|
|
4101
|
-
}
|
|
4102
|
-
async setAppContext(context) {
|
|
4103
|
-
this.contextUpdate.emit(context);
|
|
4104
|
-
}
|
|
4105
|
-
};
|
|
4106
4199
|
|
|
4107
4200
|
// packages/sdk/client-services/src/packlets/vault/iframe-host-runtime.ts
|
|
4108
|
-
|
|
4201
|
+
function _ts_decorate5(decorators, target, key, desc) {
|
|
4109
4202
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4110
4203
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
4111
4204
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -4114,7 +4207,8 @@ var __decorate4 = function(decorators, target, key, desc) {
|
|
|
4114
4207
|
if (d = decorators[i])
|
|
4115
4208
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
4116
4209
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4117
|
-
}
|
|
4210
|
+
}
|
|
4211
|
+
var __dxlog_file15 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/vault/iframe-host-runtime.ts";
|
|
4118
4212
|
var LOCK_KEY = "DXOS_RESOURCE_LOCK";
|
|
4119
4213
|
var IFrameHostRuntime = class {
|
|
4120
4214
|
constructor({ config, origin, appPort, shellPort }) {
|
|
@@ -4135,11 +4229,11 @@ var IFrameHostRuntime = class {
|
|
|
4135
4229
|
}
|
|
4136
4230
|
async start() {
|
|
4137
4231
|
var _a;
|
|
4138
|
-
(0, import_log16.log)("starting...",
|
|
4139
|
-
|
|
4140
|
-
|
|
4141
|
-
|
|
4142
|
-
|
|
4232
|
+
(0, import_log16.log)("starting...", void 0, {
|
|
4233
|
+
F: __dxlog_file15,
|
|
4234
|
+
L: 70,
|
|
4235
|
+
S: this,
|
|
4236
|
+
C: (f, a) => f(...a)
|
|
4143
4237
|
});
|
|
4144
4238
|
try {
|
|
4145
4239
|
this._config = await (0, import_util9.getAsyncValue)(this._configProvider);
|
|
@@ -4184,53 +4278,54 @@ var IFrameHostRuntime = class {
|
|
|
4184
4278
|
(_a = this._shellRuntime) == null ? void 0 : _a.open()
|
|
4185
4279
|
]);
|
|
4186
4280
|
this._ready.wake(void 0);
|
|
4187
|
-
(0, import_log16.log)("started",
|
|
4188
|
-
|
|
4189
|
-
|
|
4190
|
-
|
|
4191
|
-
|
|
4281
|
+
(0, import_log16.log)("started", void 0, {
|
|
4282
|
+
F: __dxlog_file15,
|
|
4283
|
+
L: 113,
|
|
4284
|
+
S: this,
|
|
4285
|
+
C: (f, a) => f(...a)
|
|
4192
4286
|
});
|
|
4193
4287
|
} catch (err) {
|
|
4194
4288
|
this._ready.wake(err);
|
|
4195
|
-
import_log16.log.catch(err,
|
|
4196
|
-
|
|
4197
|
-
|
|
4198
|
-
|
|
4199
|
-
|
|
4289
|
+
import_log16.log.catch(err, void 0, {
|
|
4290
|
+
F: __dxlog_file15,
|
|
4291
|
+
L: 116,
|
|
4292
|
+
S: this,
|
|
4293
|
+
C: (f, a) => f(...a)
|
|
4200
4294
|
});
|
|
4201
4295
|
}
|
|
4202
4296
|
}
|
|
4203
4297
|
async stop() {
|
|
4204
4298
|
var _a;
|
|
4205
|
-
(0, import_log16.log)("stopping...",
|
|
4206
|
-
|
|
4207
|
-
|
|
4208
|
-
|
|
4209
|
-
|
|
4299
|
+
(0, import_log16.log)("stopping...", void 0, {
|
|
4300
|
+
F: __dxlog_file15,
|
|
4301
|
+
L: 121,
|
|
4302
|
+
S: this,
|
|
4303
|
+
C: (f, a) => f(...a)
|
|
4210
4304
|
});
|
|
4211
4305
|
await this._clientRpc.close();
|
|
4212
4306
|
await this._clientServices.close();
|
|
4213
4307
|
await ((_a = this._shellRuntime) == null ? void 0 : _a.close());
|
|
4214
|
-
(0, import_log16.log)("stopped",
|
|
4215
|
-
|
|
4216
|
-
|
|
4217
|
-
|
|
4218
|
-
|
|
4308
|
+
(0, import_log16.log)("stopped", void 0, {
|
|
4309
|
+
F: __dxlog_file15,
|
|
4310
|
+
L: 125,
|
|
4311
|
+
S: this,
|
|
4312
|
+
C: (f, a) => f(...a)
|
|
4219
4313
|
});
|
|
4220
4314
|
}
|
|
4221
4315
|
};
|
|
4222
|
-
|
|
4316
|
+
_ts_decorate5([
|
|
4223
4317
|
import_log16.logInfo
|
|
4224
4318
|
], IFrameHostRuntime.prototype, "origin", void 0);
|
|
4225
4319
|
|
|
4226
4320
|
// packages/sdk/client-services/src/packlets/vault/iframe-proxy-runtime.ts
|
|
4227
4321
|
var import_async20 = require("@dxos/async");
|
|
4228
4322
|
var import_client_protocol8 = require("@dxos/client-protocol");
|
|
4229
|
-
var
|
|
4323
|
+
var import_errors6 = require("@dxos/errors");
|
|
4230
4324
|
var import_log17 = require("@dxos/log");
|
|
4231
4325
|
var import_network_manager4 = require("@dxos/network-manager");
|
|
4232
4326
|
var import_rpc3 = require("@dxos/rpc");
|
|
4233
4327
|
var import_util10 = require("@dxos/util");
|
|
4328
|
+
var __dxlog_file16 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/vault/iframe-proxy-runtime.ts";
|
|
4234
4329
|
var IFrameProxyRuntime = class {
|
|
4235
4330
|
constructor({ config, systemPort, shellPort }) {
|
|
4236
4331
|
this._id = String(Math.floor(Math.random() * 1e6));
|
|
@@ -4278,13 +4373,13 @@ var IFrameProxyRuntime = class {
|
|
|
4278
4373
|
lockKey
|
|
4279
4374
|
});
|
|
4280
4375
|
} catch (err) {
|
|
4281
|
-
import_log17.log.catch(err,
|
|
4282
|
-
|
|
4283
|
-
|
|
4284
|
-
|
|
4285
|
-
|
|
4376
|
+
import_log17.log.catch(err, void 0, {
|
|
4377
|
+
F: __dxlog_file16,
|
|
4378
|
+
L: 85,
|
|
4379
|
+
S: this,
|
|
4380
|
+
C: (f, a) => f(...a)
|
|
4286
4381
|
});
|
|
4287
|
-
throw new
|
|
4382
|
+
throw new import_errors6.RemoteServiceConnectionError("Failed to connect to worker");
|
|
4288
4383
|
}
|
|
4289
4384
|
await ((_a = this._shellRuntime) == null ? void 0 : _a.open());
|
|
4290
4385
|
}
|
|
@@ -4307,13 +4402,13 @@ var import_messaging3 = require("@dxos/messaging");
|
|
|
4307
4402
|
var import_network_manager5 = require("@dxos/network-manager");
|
|
4308
4403
|
|
|
4309
4404
|
// packages/sdk/client-services/src/packlets/vault/worker-session.ts
|
|
4310
|
-
var
|
|
4405
|
+
var import_tiny_invariant15 = __toESM(require("tiny-invariant"));
|
|
4311
4406
|
var import_async21 = require("@dxos/async");
|
|
4312
4407
|
var import_client_protocol9 = require("@dxos/client-protocol");
|
|
4313
4408
|
var import_log18 = require("@dxos/log");
|
|
4314
4409
|
var import_rpc4 = require("@dxos/rpc");
|
|
4315
4410
|
var import_util11 = require("@dxos/util");
|
|
4316
|
-
|
|
4411
|
+
function _ts_decorate6(decorators, target, key, desc) {
|
|
4317
4412
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4318
4413
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
4319
4414
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -4322,12 +4417,13 @@ var __decorate5 = function(decorators, target, key, desc) {
|
|
|
4322
4417
|
if (d = decorators[i])
|
|
4323
4418
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
4324
4419
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4325
|
-
}
|
|
4420
|
+
}
|
|
4421
|
+
var __dxlog_file17 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/vault/worker-session.ts";
|
|
4326
4422
|
var WorkerSession = class {
|
|
4327
4423
|
constructor({ serviceHost, systemPort, appPort, shellPort, readySignal }) {
|
|
4328
4424
|
this._startTrigger = new import_async21.Trigger();
|
|
4329
4425
|
this.onClose = new import_util11.Callback();
|
|
4330
|
-
(0,
|
|
4426
|
+
(0, import_tiny_invariant15.default)(serviceHost);
|
|
4331
4427
|
this._serviceHost = serviceHost;
|
|
4332
4428
|
const middleware = {
|
|
4333
4429
|
handleCall: async (method, params, handler) => {
|
|
@@ -4374,11 +4470,11 @@ var WorkerSession = class {
|
|
|
4374
4470
|
try {
|
|
4375
4471
|
await this.close();
|
|
4376
4472
|
} catch (err) {
|
|
4377
|
-
import_log18.log.catch(err,
|
|
4378
|
-
|
|
4379
|
-
|
|
4380
|
-
|
|
4381
|
-
|
|
4473
|
+
import_log18.log.catch(err, void 0, {
|
|
4474
|
+
F: __dxlog_file17,
|
|
4475
|
+
L: 100,
|
|
4476
|
+
S: this,
|
|
4477
|
+
C: (f, a) => f(...a)
|
|
4382
4478
|
});
|
|
4383
4479
|
}
|
|
4384
4480
|
});
|
|
@@ -4391,11 +4487,11 @@ var WorkerSession = class {
|
|
|
4391
4487
|
this.bridgeService = this._iframeRpc.rpc.BridgeService;
|
|
4392
4488
|
}
|
|
4393
4489
|
async open() {
|
|
4394
|
-
import_log18.log.info("opening..",
|
|
4395
|
-
|
|
4396
|
-
|
|
4397
|
-
|
|
4398
|
-
|
|
4490
|
+
import_log18.log.info("opening..", void 0, {
|
|
4491
|
+
F: __dxlog_file17,
|
|
4492
|
+
L: 114,
|
|
4493
|
+
S: this,
|
|
4494
|
+
C: (f, a) => f(...a)
|
|
4399
4495
|
});
|
|
4400
4496
|
await Promise.all([
|
|
4401
4497
|
this._clientRpc.open(),
|
|
@@ -4410,20 +4506,20 @@ var WorkerSession = class {
|
|
|
4410
4506
|
}
|
|
4411
4507
|
}
|
|
4412
4508
|
async close() {
|
|
4413
|
-
import_log18.log.info("closing..",
|
|
4414
|
-
|
|
4415
|
-
|
|
4416
|
-
|
|
4417
|
-
|
|
4509
|
+
import_log18.log.info("closing..", void 0, {
|
|
4510
|
+
F: __dxlog_file17,
|
|
4511
|
+
L: 124,
|
|
4512
|
+
S: this,
|
|
4513
|
+
C: (f, a) => f(...a)
|
|
4418
4514
|
});
|
|
4419
4515
|
try {
|
|
4420
4516
|
await this.onClose.callIfSet();
|
|
4421
4517
|
} catch (err) {
|
|
4422
|
-
import_log18.log.catch(err,
|
|
4423
|
-
|
|
4424
|
-
|
|
4425
|
-
|
|
4426
|
-
|
|
4518
|
+
import_log18.log.catch(err, void 0, {
|
|
4519
|
+
F: __dxlog_file17,
|
|
4520
|
+
L: 128,
|
|
4521
|
+
S: this,
|
|
4522
|
+
C: (f, a) => f(...a)
|
|
4427
4523
|
});
|
|
4428
4524
|
}
|
|
4429
4525
|
await Promise.all([
|
|
@@ -4435,11 +4531,11 @@ var WorkerSession = class {
|
|
|
4435
4531
|
try {
|
|
4436
4532
|
await (0, import_async21.asyncTimeout)(this._shellClientRpc.open(), 1e3);
|
|
4437
4533
|
} catch (e) {
|
|
4438
|
-
import_log18.log.info("No shell connected.",
|
|
4439
|
-
|
|
4440
|
-
|
|
4441
|
-
|
|
4442
|
-
|
|
4534
|
+
import_log18.log.info("No shell connected.", void 0, {
|
|
4535
|
+
F: __dxlog_file17,
|
|
4536
|
+
L: 138,
|
|
4537
|
+
S: this,
|
|
4538
|
+
C: (f, a) => f(...a)
|
|
4443
4539
|
});
|
|
4444
4540
|
}
|
|
4445
4541
|
}
|
|
@@ -4448,14 +4544,15 @@ var WorkerSession = class {
|
|
|
4448
4544
|
}).then(callback);
|
|
4449
4545
|
}
|
|
4450
4546
|
};
|
|
4451
|
-
|
|
4547
|
+
_ts_decorate6([
|
|
4452
4548
|
import_log18.logInfo
|
|
4453
4549
|
], WorkerSession.prototype, "origin", void 0);
|
|
4454
|
-
|
|
4550
|
+
_ts_decorate6([
|
|
4455
4551
|
import_log18.logInfo
|
|
4456
4552
|
], WorkerSession.prototype, "lockKey", void 0);
|
|
4457
4553
|
|
|
4458
4554
|
// packages/sdk/client-services/src/packlets/vault/worker-runtime.ts
|
|
4555
|
+
var __dxlog_file18 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/vault/worker-runtime.ts";
|
|
4459
4556
|
var WorkerRuntime = class {
|
|
4460
4557
|
// prettier-ignore
|
|
4461
4558
|
constructor(_configProvider) {
|
|
@@ -4463,17 +4560,23 @@ var WorkerRuntime = class {
|
|
|
4463
4560
|
this._transportFactory = new import_network_manager5.WebRTCTransportProxyFactory();
|
|
4464
4561
|
this._ready = new import_async22.Trigger();
|
|
4465
4562
|
this.sessions = /* @__PURE__ */ new Set();
|
|
4466
|
-
this._clientServices = new ClientServicesHost(
|
|
4563
|
+
this._clientServices = new ClientServicesHost({
|
|
4564
|
+
callbacks: {
|
|
4565
|
+
onReset: async () => {
|
|
4566
|
+
self.close();
|
|
4567
|
+
}
|
|
4568
|
+
}
|
|
4569
|
+
});
|
|
4467
4570
|
}
|
|
4468
4571
|
get host() {
|
|
4469
4572
|
return this._clientServices;
|
|
4470
4573
|
}
|
|
4471
4574
|
async start() {
|
|
4472
|
-
(0, import_log19.log)("starting...",
|
|
4473
|
-
|
|
4474
|
-
|
|
4475
|
-
|
|
4476
|
-
|
|
4575
|
+
(0, import_log19.log)("starting...", void 0, {
|
|
4576
|
+
F: __dxlog_file18,
|
|
4577
|
+
L: 48,
|
|
4578
|
+
S: this,
|
|
4579
|
+
C: (f, a) => f(...a)
|
|
4477
4580
|
});
|
|
4478
4581
|
try {
|
|
4479
4582
|
this._config = await this._configProvider();
|
|
@@ -4485,19 +4588,19 @@ var WorkerRuntime = class {
|
|
|
4485
4588
|
});
|
|
4486
4589
|
await this._clientServices.open();
|
|
4487
4590
|
this._ready.wake(void 0);
|
|
4488
|
-
(0, import_log19.log)("started",
|
|
4489
|
-
|
|
4490
|
-
|
|
4491
|
-
|
|
4492
|
-
|
|
4591
|
+
(0, import_log19.log)("started", void 0, {
|
|
4592
|
+
F: __dxlog_file18,
|
|
4593
|
+
L: 62,
|
|
4594
|
+
S: this,
|
|
4595
|
+
C: (f, a) => f(...a)
|
|
4493
4596
|
});
|
|
4494
4597
|
} catch (err) {
|
|
4495
4598
|
this._ready.wake(err);
|
|
4496
|
-
import_log19.log.catch(err,
|
|
4497
|
-
|
|
4498
|
-
|
|
4499
|
-
|
|
4500
|
-
|
|
4599
|
+
import_log19.log.catch(err, void 0, {
|
|
4600
|
+
F: __dxlog_file18,
|
|
4601
|
+
L: 65,
|
|
4602
|
+
S: this,
|
|
4603
|
+
C: (f, a) => f(...a)
|
|
4501
4604
|
});
|
|
4502
4605
|
}
|
|
4503
4606
|
}
|
|
@@ -4527,11 +4630,11 @@ var WorkerRuntime = class {
|
|
|
4527
4630
|
* Selects one of the existing session fro WebRTC networking.
|
|
4528
4631
|
*/
|
|
4529
4632
|
_reconnectWebrtc() {
|
|
4530
|
-
(0, import_log19.log)("reconnecting webrtc...",
|
|
4531
|
-
|
|
4532
|
-
|
|
4533
|
-
|
|
4534
|
-
|
|
4633
|
+
(0, import_log19.log)("reconnecting webrtc...", void 0, {
|
|
4634
|
+
F: __dxlog_file18,
|
|
4635
|
+
L: 102,
|
|
4636
|
+
S: this,
|
|
4637
|
+
C: (f, a) => f(...a)
|
|
4535
4638
|
});
|
|
4536
4639
|
if (this._sessionForNetworking) {
|
|
4537
4640
|
if (!this.sessions.has(this._sessionForNetworking)) {
|
|
@@ -4565,7 +4668,6 @@ var WorkerRuntime = class {
|
|
|
4565
4668
|
InvitationsHandler,
|
|
4566
4669
|
InvitationsServiceImpl,
|
|
4567
4670
|
Lock,
|
|
4568
|
-
MemoryShellRuntime,
|
|
4569
4671
|
ServiceContext,
|
|
4570
4672
|
ServiceRegistry,
|
|
4571
4673
|
ShellRuntimeImpl,
|
|
@@ -4575,6 +4677,7 @@ var WorkerRuntime = class {
|
|
|
4575
4677
|
WorkerRuntime,
|
|
4576
4678
|
WorkerSession,
|
|
4577
4679
|
createAuthProvider,
|
|
4680
|
+
createDefaultModelFactory,
|
|
4578
4681
|
createStorageObjects,
|
|
4579
4682
|
getNetworkPeers,
|
|
4580
4683
|
isLocked,
|