@dxos/client-services 0.1.53-main.706990e → 0.1.53-main.770f0f5
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-CPSUVMSC.mjs → chunk-EYXOVYW5.mjs} +802 -697
- package/dist/lib/browser/chunk-EYXOVYW5.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 +867 -783
- 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 +784 -665
- package/dist/lib/node/packlets/testing/index.cjs.map +3 -3
- 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/identity/identity-manager.test.ts +1 -1
- package/src/packlets/identity/identity-manager.ts +8 -8
- package/src/packlets/identity/identity-service.ts +2 -2
- package/src/packlets/identity/identity.test.ts +1 -1
- package/src/packlets/identity/identity.ts +22 -27
- package/src/packlets/invitations/device-invitation-protocol.ts +4 -4
- package/src/packlets/invitations/invitation-extension.ts +5 -5
- package/src/packlets/invitations/invitations-handler.ts +6 -6
- package/src/packlets/invitations/invitations-service.ts +3 -3
- package/src/packlets/invitations/space-invitation-protocol.ts +9 -9
- package/src/packlets/locks/node.ts +2 -2
- package/src/packlets/logging/logging-service.ts +4 -4
- package/src/packlets/services/service-context.test.ts +1 -1
- package/src/packlets/services/service-context.ts +12 -10
- package/src/packlets/services/service-host.test.ts +50 -2
- package/src/packlets/services/service-host.ts +25 -9
- package/src/packlets/spaces/data-space-manager.test.ts +72 -118
- 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.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-CPSUVMSC.mjs.map +0 -7
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import "@dxos/node-std/globals"
|
|
1
|
+
import "@dxos/node-std/globals";
|
|
2
2
|
|
|
3
3
|
// packages/sdk/client-services/src/packlets/devtools/feeds.ts
|
|
4
4
|
import { EventSubscriptions } from "@dxos/async";
|
|
@@ -352,6 +352,7 @@ import { Context as Context2 } from "@dxos/context";
|
|
|
352
352
|
import { verifyCredential } from "@dxos/credentials";
|
|
353
353
|
import { log } from "@dxos/log";
|
|
354
354
|
import { schema } from "@dxos/protocols";
|
|
355
|
+
var __dxlog_file = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/authenticator.ts";
|
|
355
356
|
var createAuthProvider = (signer) => async (nonce) => {
|
|
356
357
|
const credential = await signer.createCredential({
|
|
357
358
|
assertion: {
|
|
@@ -377,20 +378,20 @@ var TrustedKeySetAuthVerifier = class {
|
|
|
377
378
|
log("authenticating...", {
|
|
378
379
|
credential
|
|
379
380
|
}, {
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
381
|
+
F: __dxlog_file,
|
|
382
|
+
L: 57,
|
|
383
|
+
S: this,
|
|
384
|
+
C: (f, a) => f(...a)
|
|
384
385
|
});
|
|
385
386
|
const result = await verifyCredential(credential);
|
|
386
387
|
if (result.kind === "fail") {
|
|
387
388
|
log("Invalid credential", {
|
|
388
389
|
result
|
|
389
390
|
}, {
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
391
|
+
F: __dxlog_file,
|
|
392
|
+
L: 61,
|
|
393
|
+
S: this,
|
|
394
|
+
C: (f, a) => f(...a)
|
|
394
395
|
});
|
|
395
396
|
return false;
|
|
396
397
|
}
|
|
@@ -399,10 +400,10 @@ var TrustedKeySetAuthVerifier = class {
|
|
|
399
400
|
nonce,
|
|
400
401
|
credential
|
|
401
402
|
}, {
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
403
|
+
F: __dxlog_file,
|
|
404
|
+
L: 66,
|
|
405
|
+
S: this,
|
|
406
|
+
C: (f, a) => f(...a)
|
|
406
407
|
});
|
|
407
408
|
return false;
|
|
408
409
|
}
|
|
@@ -410,10 +411,10 @@ var TrustedKeySetAuthVerifier = class {
|
|
|
410
411
|
log("key is not currently in trusted set, waiting...", {
|
|
411
412
|
key: credential.issuer
|
|
412
413
|
}, {
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
414
|
+
F: __dxlog_file,
|
|
415
|
+
L: 71,
|
|
416
|
+
S: this,
|
|
417
|
+
C: (f, a) => f(...a)
|
|
417
418
|
});
|
|
418
419
|
return true;
|
|
419
420
|
}
|
|
@@ -426,20 +427,20 @@ var TrustedKeySetAuthVerifier = class {
|
|
|
426
427
|
log("auth success", {
|
|
427
428
|
key: credential.issuer
|
|
428
429
|
}, {
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
430
|
+
F: __dxlog_file,
|
|
431
|
+
L: 82,
|
|
432
|
+
S: this,
|
|
433
|
+
C: (f, a) => f(...a)
|
|
433
434
|
});
|
|
434
435
|
trigger.wake(true);
|
|
435
436
|
} else {
|
|
436
437
|
log("key is not currently in trusted set, waiting...", {
|
|
437
438
|
key: credential.issuer
|
|
438
439
|
}, {
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
440
|
+
F: __dxlog_file,
|
|
441
|
+
L: 85,
|
|
442
|
+
S: this,
|
|
443
|
+
C: (f, a) => f(...a)
|
|
443
444
|
});
|
|
444
445
|
}
|
|
445
446
|
});
|
|
@@ -461,7 +462,7 @@ var TrustedKeySetAuthVerifier = class {
|
|
|
461
462
|
};
|
|
462
463
|
|
|
463
464
|
// packages/sdk/client-services/src/packlets/identity/identity.ts
|
|
464
|
-
import
|
|
465
|
+
import invariant from "tiny-invariant";
|
|
465
466
|
import { Event } from "@dxos/async";
|
|
466
467
|
import { AUTH_TIMEOUT, LOAD_CONTROL_FEEDS_TIMEOUT } from "@dxos/client-protocol";
|
|
467
468
|
import { DeviceStateMachine, createCredentialSignerWithKey, createCredentialSignerWithChain, ProfileStateMachine } from "@dxos/credentials";
|
|
@@ -469,6 +470,7 @@ import { failUndefined } from "@dxos/debug";
|
|
|
469
470
|
import { writeMessages } from "@dxos/feed-store";
|
|
470
471
|
import { log as log2 } from "@dxos/log";
|
|
471
472
|
import { AdmittedFeed } from "@dxos/protocols/proto/dxos/halo/credentials";
|
|
473
|
+
var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/identity.ts";
|
|
472
474
|
var Identity = class {
|
|
473
475
|
constructor({ space, signer, identityKey, deviceKey }) {
|
|
474
476
|
this.stateUpdate = new Event();
|
|
@@ -476,15 +478,15 @@ var Identity = class {
|
|
|
476
478
|
this._signer = signer;
|
|
477
479
|
this.identityKey = identityKey;
|
|
478
480
|
this.deviceKey = deviceKey;
|
|
479
|
-
this._deviceStateMachine =
|
|
481
|
+
this._deviceStateMachine = new DeviceStateMachine({
|
|
480
482
|
identityKey: this.identityKey,
|
|
481
483
|
deviceKey: this.deviceKey,
|
|
482
484
|
onUpdate: () => this.stateUpdate.emit()
|
|
483
|
-
})
|
|
484
|
-
this._profileStateMachine =
|
|
485
|
+
});
|
|
486
|
+
this._profileStateMachine = new ProfileStateMachine({
|
|
485
487
|
identityKey: this.identityKey,
|
|
486
488
|
onUpdate: () => this.stateUpdate.emit()
|
|
487
|
-
})
|
|
489
|
+
});
|
|
488
490
|
this.authVerifier = new TrustedKeySetAuthVerifier({
|
|
489
491
|
trustedKeysProvider: () => this.authorizedDeviceKeys,
|
|
490
492
|
update: this.stateUpdate,
|
|
@@ -493,27 +495,27 @@ var Identity = class {
|
|
|
493
495
|
}
|
|
494
496
|
// TODO(burdon): Expose state object?
|
|
495
497
|
get authorizedDeviceKeys() {
|
|
496
|
-
return this._deviceStateMachine.
|
|
498
|
+
return this._deviceStateMachine.authorizedDeviceKeys;
|
|
497
499
|
}
|
|
498
500
|
async open() {
|
|
499
|
-
await this.
|
|
500
|
-
await this.
|
|
501
|
+
await this.space.spaceState.addCredentialProcessor(this._deviceStateMachine);
|
|
502
|
+
await this.space.spaceState.addCredentialProcessor(this._profileStateMachine);
|
|
501
503
|
await this.space.open();
|
|
502
504
|
}
|
|
503
505
|
async close() {
|
|
504
506
|
await this.authVerifier.close();
|
|
505
|
-
await this.
|
|
506
|
-
await this.
|
|
507
|
+
await this.space.spaceState.removeCredentialProcessor(this._profileStateMachine);
|
|
508
|
+
await this.space.spaceState.removeCredentialProcessor(this._deviceStateMachine);
|
|
507
509
|
await this.space.close();
|
|
508
510
|
}
|
|
509
511
|
async ready() {
|
|
510
|
-
await this._deviceStateMachine.
|
|
512
|
+
await this._deviceStateMachine.deviceChainReady.wait();
|
|
511
513
|
await this.controlPipeline.state.waitUntilReachedTargetTimeframe({
|
|
512
514
|
timeout: LOAD_CONTROL_FEEDS_TIMEOUT
|
|
513
515
|
});
|
|
514
516
|
}
|
|
515
517
|
get profileDocument() {
|
|
516
|
-
return this._profileStateMachine.
|
|
518
|
+
return this._profileStateMachine.profile;
|
|
517
519
|
}
|
|
518
520
|
/**
|
|
519
521
|
* @test-only
|
|
@@ -528,7 +530,7 @@ var Identity = class {
|
|
|
528
530
|
return this.space.genesisFeedKey;
|
|
529
531
|
}
|
|
530
532
|
get deviceCredentialChain() {
|
|
531
|
-
return this._deviceStateMachine.
|
|
533
|
+
return this._deviceStateMachine.deviceCredentialChain;
|
|
532
534
|
}
|
|
533
535
|
getAdmissionCredentials() {
|
|
534
536
|
var _a, _b;
|
|
@@ -543,8 +545,8 @@ var Identity = class {
|
|
|
543
545
|
* Requires identity to be ready.
|
|
544
546
|
*/
|
|
545
547
|
getIdentityCredentialSigner() {
|
|
546
|
-
|
|
547
|
-
return createCredentialSignerWithChain(this._signer, this._deviceStateMachine.
|
|
548
|
+
invariant(this._deviceStateMachine.deviceCredentialChain, "Device credential chain is not ready.");
|
|
549
|
+
return createCredentialSignerWithChain(this._signer, this._deviceStateMachine.deviceCredentialChain, this.deviceKey);
|
|
548
550
|
}
|
|
549
551
|
/**
|
|
550
552
|
* Issues credentials as device.
|
|
@@ -560,10 +562,10 @@ var Identity = class {
|
|
|
560
562
|
controlFeedKey,
|
|
561
563
|
dataFeedKey
|
|
562
564
|
}, {
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
565
|
+
F: __dxlog_file2,
|
|
566
|
+
L: 151,
|
|
567
|
+
S: this,
|
|
568
|
+
C: (f, a) => f(...a)
|
|
567
569
|
});
|
|
568
570
|
const signer = this.getIdentityCredentialSigner();
|
|
569
571
|
await writeMessages(this.controlPipeline.writer, [
|
|
@@ -604,7 +606,7 @@ var Identity = class {
|
|
|
604
606
|
};
|
|
605
607
|
|
|
606
608
|
// packages/sdk/client-services/src/packlets/identity/identity-manager.ts
|
|
607
|
-
import
|
|
609
|
+
import invariant2 from "tiny-invariant";
|
|
608
610
|
import { Event as Event2 } from "@dxos/async";
|
|
609
611
|
import { createCredentialSignerWithKey as createCredentialSignerWithKey2, CredentialGenerator } from "@dxos/credentials";
|
|
610
612
|
import { PublicKey as PublicKey3 } from "@dxos/keys";
|
|
@@ -612,6 +614,7 @@ import { log as log3 } from "@dxos/log";
|
|
|
612
614
|
import { trace } from "@dxos/protocols";
|
|
613
615
|
import { AdmittedFeed as AdmittedFeed2 } from "@dxos/protocols/proto/dxos/halo/credentials";
|
|
614
616
|
import { deferFunction } from "@dxos/util";
|
|
617
|
+
var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/identity-manager.ts";
|
|
615
618
|
var IdentityManager = class {
|
|
616
619
|
// TODO(burdon): IdentityManagerParams.
|
|
617
620
|
// TODO(dmaretskyi): Perhaps this should take/generate the peerKey outside of an initialized identity.
|
|
@@ -631,20 +634,20 @@ var IdentityManager = class {
|
|
|
631
634
|
log3.trace("dxos.halo.identity-manager.open", trace.begin({
|
|
632
635
|
id: traceId
|
|
633
636
|
}), {
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
637
|
+
F: __dxlog_file3,
|
|
638
|
+
L: 70,
|
|
639
|
+
S: this,
|
|
640
|
+
C: (f, a) => f(...a)
|
|
638
641
|
});
|
|
639
642
|
await this._metadataStore.load();
|
|
640
643
|
const identityRecord = this._metadataStore.getIdentityRecord();
|
|
641
644
|
log3("identity record", {
|
|
642
645
|
identityRecord
|
|
643
646
|
}, {
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
647
|
+
F: __dxlog_file3,
|
|
648
|
+
L: 74,
|
|
649
|
+
S: this,
|
|
650
|
+
C: (f, a) => f(...a)
|
|
648
651
|
});
|
|
649
652
|
if (identityRecord) {
|
|
650
653
|
this._identity = await this._constructIdentity(identityRecord);
|
|
@@ -654,20 +657,20 @@ var IdentityManager = class {
|
|
|
654
657
|
identityKey: identityRecord.identityKey,
|
|
655
658
|
displayName: (_a = this._identity.profileDocument) == null ? void 0 : _a.displayName
|
|
656
659
|
}, {
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
660
|
+
F: __dxlog_file3,
|
|
661
|
+
L: 79,
|
|
662
|
+
S: this,
|
|
663
|
+
C: (f, a) => f(...a)
|
|
661
664
|
});
|
|
662
665
|
this.stateUpdate.emit();
|
|
663
666
|
}
|
|
664
667
|
log3.trace("dxos.halo.identity-manager.open", trace.end({
|
|
665
668
|
id: traceId
|
|
666
669
|
}), {
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
670
|
+
F: __dxlog_file3,
|
|
671
|
+
L: 85,
|
|
672
|
+
S: this,
|
|
673
|
+
C: (f, a) => f(...a)
|
|
671
674
|
});
|
|
672
675
|
}
|
|
673
676
|
async close() {
|
|
@@ -676,12 +679,12 @@ var IdentityManager = class {
|
|
|
676
679
|
}
|
|
677
680
|
async createIdentity({ displayName } = {}) {
|
|
678
681
|
var _a;
|
|
679
|
-
|
|
680
|
-
log3("creating identity...",
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
682
|
+
invariant2(!this._identity, "Identity already exists.");
|
|
683
|
+
log3("creating identity...", void 0, {
|
|
684
|
+
F: __dxlog_file3,
|
|
685
|
+
L: 94,
|
|
686
|
+
S: this,
|
|
687
|
+
C: (f, a) => f(...a)
|
|
685
688
|
});
|
|
686
689
|
const controlFeedKey = await this._keyring.createKey();
|
|
687
690
|
const identityRecord = {
|
|
@@ -698,8 +701,8 @@ var IdentityManager = class {
|
|
|
698
701
|
await identity.open();
|
|
699
702
|
{
|
|
700
703
|
const generator = new CredentialGenerator(this._keyring, identityRecord.identityKey, identityRecord.deviceKey);
|
|
701
|
-
|
|
702
|
-
|
|
704
|
+
invariant2(identityRecord.haloSpace.genesisFeedKey, "Genesis feed key is required.");
|
|
705
|
+
invariant2(identityRecord.haloSpace.dataFeedKey, "Data feed key is required.");
|
|
703
706
|
const credentials = [
|
|
704
707
|
// Space genesis.
|
|
705
708
|
...await generator.createSpaceGenesis(identityRecord.haloSpace.key, identityRecord.haloSpace.genesisFeedKey),
|
|
@@ -727,20 +730,20 @@ var IdentityManager = class {
|
|
|
727
730
|
identityKey: identityRecord.identityKey,
|
|
728
731
|
displayName: (_a = this._identity.profileDocument) == null ? void 0 : _a.displayName
|
|
729
732
|
}, {
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
733
|
+
F: __dxlog_file3,
|
|
734
|
+
L: 149,
|
|
735
|
+
S: this,
|
|
736
|
+
C: (f, a) => f(...a)
|
|
734
737
|
});
|
|
735
738
|
this.stateUpdate.emit();
|
|
736
739
|
log3("created identity", {
|
|
737
740
|
identityKey: identity.identityKey,
|
|
738
741
|
deviceKey: identity.deviceKey
|
|
739
742
|
}, {
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
743
|
+
F: __dxlog_file3,
|
|
744
|
+
L: 155,
|
|
745
|
+
S: this,
|
|
746
|
+
C: (f, a) => f(...a)
|
|
744
747
|
});
|
|
745
748
|
return identity;
|
|
746
749
|
}
|
|
@@ -752,12 +755,12 @@ var IdentityManager = class {
|
|
|
752
755
|
log3("accepting identity", {
|
|
753
756
|
params
|
|
754
757
|
}, {
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
758
|
+
F: __dxlog_file3,
|
|
759
|
+
L: 163,
|
|
760
|
+
S: this,
|
|
761
|
+
C: (f, a) => f(...a)
|
|
759
762
|
});
|
|
760
|
-
|
|
763
|
+
invariant2(!this._identity, "Identity already exists.");
|
|
761
764
|
const identityRecord = {
|
|
762
765
|
identityKey: params.identityKey,
|
|
763
766
|
deviceKey: params.deviceKey,
|
|
@@ -778,38 +781,38 @@ var IdentityManager = class {
|
|
|
778
781
|
identityKey: identityRecord.identityKey,
|
|
779
782
|
displayName: (_a = this._identity.profileDocument) == null ? void 0 : _a.displayName
|
|
780
783
|
}, {
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
784
|
+
F: __dxlog_file3,
|
|
785
|
+
L: 183,
|
|
786
|
+
S: this,
|
|
787
|
+
C: (f, a) => f(...a)
|
|
785
788
|
});
|
|
786
789
|
this.stateUpdate.emit();
|
|
787
790
|
log3("accepted identity", {
|
|
788
791
|
identityKey: identity.identityKey,
|
|
789
792
|
deviceKey: identity.deviceKey
|
|
790
793
|
}, {
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
794
|
+
F: __dxlog_file3,
|
|
795
|
+
L: 189,
|
|
796
|
+
S: this,
|
|
797
|
+
C: (f, a) => f(...a)
|
|
795
798
|
});
|
|
796
799
|
return identity;
|
|
797
800
|
}
|
|
798
801
|
async _constructIdentity(identityRecord) {
|
|
799
|
-
|
|
802
|
+
invariant2(!this._identity);
|
|
800
803
|
log3("constructing identity", {
|
|
801
804
|
identityRecord
|
|
802
805
|
}, {
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
806
|
+
F: __dxlog_file3,
|
|
807
|
+
L: 195,
|
|
808
|
+
S: this,
|
|
809
|
+
C: (f, a) => f(...a)
|
|
807
810
|
});
|
|
808
|
-
|
|
811
|
+
invariant2(identityRecord.haloSpace.controlFeedKey);
|
|
809
812
|
const controlFeed = await this._feedStore.openFeed(identityRecord.haloSpace.controlFeedKey, {
|
|
810
813
|
writable: true
|
|
811
814
|
});
|
|
812
|
-
|
|
815
|
+
invariant2(identityRecord.haloSpace.dataFeedKey);
|
|
813
816
|
const dataFeed = await this._feedStore.openFeed(identityRecord.haloSpace.dataFeedKey, {
|
|
814
817
|
writable: true,
|
|
815
818
|
sparse: true
|
|
@@ -834,10 +837,10 @@ var IdentityManager = class {
|
|
|
834
837
|
log3("done", {
|
|
835
838
|
identityKey: identityRecord.identityKey
|
|
836
839
|
}, {
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
840
|
+
F: __dxlog_file3,
|
|
841
|
+
L: 226,
|
|
842
|
+
S: this,
|
|
843
|
+
C: (f, a) => f(...a)
|
|
841
844
|
});
|
|
842
845
|
if (identityRecord.haloSpace.controlTimeframe) {
|
|
843
846
|
identity.controlPipeline.state.setTargetTimeframe(identityRecord.haloSpace.controlTimeframe);
|
|
@@ -854,11 +857,11 @@ var IdentityManager = class {
|
|
|
854
857
|
onNetworkConnection: () => {
|
|
855
858
|
},
|
|
856
859
|
onAuthFailure: () => {
|
|
857
|
-
log3.warn("auth failure",
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
860
|
+
log3.warn("auth failure", void 0, {
|
|
861
|
+
F: __dxlog_file3,
|
|
862
|
+
L: 245,
|
|
863
|
+
S: this,
|
|
864
|
+
C: (f, a) => f(...a)
|
|
862
865
|
});
|
|
863
866
|
},
|
|
864
867
|
memberKey: identityKey
|
|
@@ -867,7 +870,7 @@ var IdentityManager = class {
|
|
|
867
870
|
};
|
|
868
871
|
|
|
869
872
|
// packages/sdk/client-services/src/packlets/identity/identity-service.ts
|
|
870
|
-
import
|
|
873
|
+
import invariant3 from "tiny-invariant";
|
|
871
874
|
import { Stream as Stream7 } from "@dxos/codec-protobuf";
|
|
872
875
|
import { signPresentation } from "@dxos/credentials";
|
|
873
876
|
import { todo } from "@dxos/debug";
|
|
@@ -903,7 +906,7 @@ var IdentityServiceImpl = class {
|
|
|
903
906
|
};
|
|
904
907
|
}
|
|
905
908
|
async signPresentation({ presentation, nonce }) {
|
|
906
|
-
|
|
909
|
+
invariant3(this._serviceContext.identityManager.identity, "Identity not initialized.");
|
|
907
910
|
return await signPresentation({
|
|
908
911
|
presentation,
|
|
909
912
|
signer: this._serviceContext.keyring,
|
|
@@ -915,7 +918,7 @@ var IdentityServiceImpl = class {
|
|
|
915
918
|
};
|
|
916
919
|
|
|
917
920
|
// packages/sdk/client-services/src/packlets/invitations/device-invitation-protocol.ts
|
|
918
|
-
import
|
|
921
|
+
import invariant4 from "tiny-invariant";
|
|
919
922
|
import { Invitation } from "@dxos/protocols/proto/dxos/client/services";
|
|
920
923
|
var DeviceInvitationProtocol = class {
|
|
921
924
|
constructor(_keyring, _getIdentity, _acceptIdentity) {
|
|
@@ -932,7 +935,7 @@ var DeviceInvitationProtocol = class {
|
|
|
932
935
|
};
|
|
933
936
|
}
|
|
934
937
|
async admit(request) {
|
|
935
|
-
|
|
938
|
+
invariant4(request.device);
|
|
936
939
|
const identity = this._getIdentity();
|
|
937
940
|
await identity.admitDevice(request.device);
|
|
938
941
|
return {
|
|
@@ -960,9 +963,9 @@ var DeviceInvitationProtocol = class {
|
|
|
960
963
|
};
|
|
961
964
|
}
|
|
962
965
|
async accept(response, request) {
|
|
963
|
-
|
|
966
|
+
invariant4(response.device);
|
|
964
967
|
const { identityKey, haloSpaceKey, genesisFeedKey, controlTimeframe } = response.device;
|
|
965
|
-
|
|
968
|
+
invariant4(request.device);
|
|
966
969
|
const { deviceKey, controlFeedKey, dataFeedKey } = request.device;
|
|
967
970
|
await this._acceptIdentity({
|
|
968
971
|
identityKey,
|
|
@@ -980,7 +983,7 @@ var DeviceInvitationProtocol = class {
|
|
|
980
983
|
};
|
|
981
984
|
|
|
982
985
|
// packages/sdk/client-services/src/packlets/invitations/invitations-handler.ts
|
|
983
|
-
import
|
|
986
|
+
import invariant6 from "tiny-invariant";
|
|
984
987
|
import { PushStream, scheduleTask as scheduleTask2, TimeoutError, Trigger as Trigger3 } from "@dxos/async";
|
|
985
988
|
import { AuthenticatingInvitationObservable, AUTHENTICATION_CODE_LENGTH, CancellableInvitationObservable, INVITATION_TIMEOUT } from "@dxos/client-protocol";
|
|
986
989
|
import { Context as Context4 } from "@dxos/context";
|
|
@@ -994,7 +997,7 @@ import { Invitation as Invitation3 } from "@dxos/protocols/proto/dxos/client/ser
|
|
|
994
997
|
import { AuthenticationResponse as AuthenticationResponse2 } from "@dxos/protocols/proto/dxos/halo/invitations";
|
|
995
998
|
|
|
996
999
|
// packages/sdk/client-services/src/packlets/invitations/invitation-extension.ts
|
|
997
|
-
import
|
|
1000
|
+
import invariant5 from "tiny-invariant";
|
|
998
1001
|
import { Trigger as Trigger2 } from "@dxos/async";
|
|
999
1002
|
import { cancelWithContext, Context as Context3 } from "@dxos/context";
|
|
1000
1003
|
import { InvalidInvitationExtensionRoleError } from "@dxos/errors";
|
|
@@ -1004,6 +1007,7 @@ import { schema as schema2, trace as trace2 } from "@dxos/protocols";
|
|
|
1004
1007
|
import { Invitation as Invitation2 } from "@dxos/protocols/proto/dxos/client/services";
|
|
1005
1008
|
import { AuthenticationResponse, Options } from "@dxos/protocols/proto/dxos/halo/invitations";
|
|
1006
1009
|
import { RpcExtension } from "@dxos/teleport";
|
|
1010
|
+
var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitation-extension.ts";
|
|
1007
1011
|
var OPTIONS_TIMEOUT = 1e4;
|
|
1008
1012
|
var MAX_OTP_ATTEMPTS = 3;
|
|
1009
1013
|
var InvitationHostExtension = class extends RpcExtension {
|
|
@@ -1031,7 +1035,7 @@ var InvitationHostExtension = class extends RpcExtension {
|
|
|
1031
1035
|
// Perhaps in the future we will have more complex logic here.
|
|
1032
1036
|
InvitationHostService: {
|
|
1033
1037
|
options: async (options) => {
|
|
1034
|
-
|
|
1038
|
+
invariant5(!this._remoteOptions, "Remote options already set.");
|
|
1035
1039
|
this._remoteOptions = options;
|
|
1036
1040
|
this._remoteOptionsTrigger.wake();
|
|
1037
1041
|
},
|
|
@@ -1041,20 +1045,20 @@ var InvitationHostExtension = class extends RpcExtension {
|
|
|
1041
1045
|
log4.trace("dxos.sdk.invitation-handler.host.introduce", trace2.begin({
|
|
1042
1046
|
id: traceId
|
|
1043
1047
|
}), {
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
+
F: __dxlog_file4,
|
|
1049
|
+
L: 98,
|
|
1050
|
+
S: this,
|
|
1051
|
+
C: (f, a) => f(...a)
|
|
1048
1052
|
});
|
|
1049
1053
|
const invitation = await this._callbacks.resolveInvitation(request);
|
|
1050
1054
|
if (!invitation) {
|
|
1051
1055
|
log4.warn("invitation not found", {
|
|
1052
1056
|
invitationId
|
|
1053
1057
|
}, {
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
+
F: __dxlog_file4,
|
|
1059
|
+
L: 102,
|
|
1060
|
+
S: this,
|
|
1061
|
+
C: (f, a) => f(...a)
|
|
1058
1062
|
});
|
|
1059
1063
|
this._callbacks.onError(new Error("Invitation not found."));
|
|
1060
1064
|
return {
|
|
@@ -1065,10 +1069,10 @@ var InvitationHostExtension = class extends RpcExtension {
|
|
|
1065
1069
|
log4("guest introduced itself", {
|
|
1066
1070
|
guestProfile: profile
|
|
1067
1071
|
}, {
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
+
F: __dxlog_file4,
|
|
1073
|
+
L: 111,
|
|
1074
|
+
S: this,
|
|
1075
|
+
C: (f, a) => f(...a)
|
|
1072
1076
|
});
|
|
1073
1077
|
this.guestProfile = profile;
|
|
1074
1078
|
this._callbacks.onStateUpdate({
|
|
@@ -1078,10 +1082,10 @@ var InvitationHostExtension = class extends RpcExtension {
|
|
|
1078
1082
|
log4.trace("dxos.sdk.invitation-handler.host.introduce", trace2.end({
|
|
1079
1083
|
id: traceId
|
|
1080
1084
|
}), {
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
+
F: __dxlog_file4,
|
|
1086
|
+
L: 118,
|
|
1087
|
+
S: this,
|
|
1088
|
+
C: (f, a) => f(...a)
|
|
1085
1089
|
});
|
|
1086
1090
|
return {
|
|
1087
1091
|
spaceKey: this.invitation.authMethod === Invitation2.AuthMethod.NONE ? this.invitation.spaceKey : void 0,
|
|
@@ -1093,28 +1097,28 @@ var InvitationHostExtension = class extends RpcExtension {
|
|
|
1093
1097
|
log4.trace("dxos.sdk.invitation-handler.host.authenticate", trace2.begin({
|
|
1094
1098
|
id: traceId
|
|
1095
1099
|
}), {
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
+
F: __dxlog_file4,
|
|
1101
|
+
L: 127,
|
|
1102
|
+
S: this,
|
|
1103
|
+
C: (f, a) => f(...a)
|
|
1100
1104
|
});
|
|
1101
1105
|
log4("received authentication request", {
|
|
1102
1106
|
authCode: code
|
|
1103
1107
|
}, {
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
+
F: __dxlog_file4,
|
|
1109
|
+
L: 128,
|
|
1110
|
+
S: this,
|
|
1111
|
+
C: (f, a) => f(...a)
|
|
1108
1112
|
});
|
|
1109
1113
|
let status = AuthenticationResponse.Status.OK;
|
|
1110
|
-
|
|
1114
|
+
invariant5(this.invitation, "Invitation is not set.");
|
|
1111
1115
|
switch (this.invitation.authMethod) {
|
|
1112
1116
|
case Invitation2.AuthMethod.NONE: {
|
|
1113
|
-
log4("authentication not required",
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1117
|
+
log4("authentication not required", void 0, {
|
|
1118
|
+
F: __dxlog_file4,
|
|
1119
|
+
L: 134,
|
|
1120
|
+
S: this,
|
|
1121
|
+
C: (f, a) => f(...a)
|
|
1118
1122
|
});
|
|
1119
1123
|
return {
|
|
1120
1124
|
status: AuthenticationResponse.Status.OK
|
|
@@ -1136,10 +1140,10 @@ var InvitationHostExtension = class extends RpcExtension {
|
|
|
1136
1140
|
log4.error("invalid authentication method", {
|
|
1137
1141
|
authMethod: this.invitation.authMethod
|
|
1138
1142
|
}, {
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
+
F: __dxlog_file4,
|
|
1144
|
+
L: 152,
|
|
1145
|
+
S: this,
|
|
1146
|
+
C: (f, a) => f(...a)
|
|
1143
1147
|
});
|
|
1144
1148
|
status = AuthenticationResponse.Status.INTERNAL_ERROR;
|
|
1145
1149
|
break;
|
|
@@ -1151,10 +1155,10 @@ var InvitationHostExtension = class extends RpcExtension {
|
|
|
1151
1155
|
status
|
|
1152
1156
|
}
|
|
1153
1157
|
}), {
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
+
F: __dxlog_file4,
|
|
1159
|
+
L: 158,
|
|
1160
|
+
S: this,
|
|
1161
|
+
C: (f, a) => f(...a)
|
|
1158
1162
|
});
|
|
1159
1163
|
return {
|
|
1160
1164
|
status
|
|
@@ -1165,13 +1169,13 @@ var InvitationHostExtension = class extends RpcExtension {
|
|
|
1165
1169
|
log4.trace("dxos.sdk.invitation-handler.host.admit", trace2.begin({
|
|
1166
1170
|
id: traceId
|
|
1167
1171
|
}), {
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
+
F: __dxlog_file4,
|
|
1173
|
+
L: 164,
|
|
1174
|
+
S: this,
|
|
1175
|
+
C: (f, a) => f(...a)
|
|
1172
1176
|
});
|
|
1173
1177
|
try {
|
|
1174
|
-
|
|
1178
|
+
invariant5(this.invitation, "Invitation is not set.");
|
|
1175
1179
|
if (isAuthenticationRequired(this.invitation) && !this.authenticationPassed) {
|
|
1176
1180
|
throw new Error("Not authenticated");
|
|
1177
1181
|
}
|
|
@@ -1179,10 +1183,10 @@ var InvitationHostExtension = class extends RpcExtension {
|
|
|
1179
1183
|
log4.trace("dxos.sdk.invitation-handler.host.admit", trace2.end({
|
|
1180
1184
|
id: traceId
|
|
1181
1185
|
}), {
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
+
F: __dxlog_file4,
|
|
1187
|
+
L: 175,
|
|
1188
|
+
S: this,
|
|
1189
|
+
C: (f, a) => f(...a)
|
|
1186
1190
|
});
|
|
1187
1191
|
return response;
|
|
1188
1192
|
} catch (err) {
|
|
@@ -1236,7 +1240,7 @@ var InvitationGuestExtension = class extends RpcExtension {
|
|
|
1236
1240
|
return {
|
|
1237
1241
|
InvitationHostService: {
|
|
1238
1242
|
options: async (options) => {
|
|
1239
|
-
|
|
1243
|
+
invariant5(!this._remoteOptions, "Remote options already set.");
|
|
1240
1244
|
this._remoteOptions = options;
|
|
1241
1245
|
this._remoteOptionsTrigger.wake();
|
|
1242
1246
|
},
|
|
@@ -1256,11 +1260,11 @@ var InvitationGuestExtension = class extends RpcExtension {
|
|
|
1256
1260
|
var _a;
|
|
1257
1261
|
await super.onOpen(context);
|
|
1258
1262
|
try {
|
|
1259
|
-
log4("begin options",
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1263
|
+
log4("begin options", void 0, {
|
|
1264
|
+
F: __dxlog_file4,
|
|
1265
|
+
L: 263,
|
|
1266
|
+
S: this,
|
|
1267
|
+
C: (f, a) => f(...a)
|
|
1264
1268
|
});
|
|
1265
1269
|
await cancelWithContext(this._ctx, this.rpc.InvitationHostService.options({
|
|
1266
1270
|
role: Options.Role.GUEST
|
|
@@ -1268,11 +1272,11 @@ var InvitationGuestExtension = class extends RpcExtension {
|
|
|
1268
1272
|
await cancelWithContext(this._ctx, this._remoteOptionsTrigger.wait({
|
|
1269
1273
|
timeout: OPTIONS_TIMEOUT
|
|
1270
1274
|
}));
|
|
1271
|
-
log4("end options",
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1275
|
+
log4("end options", void 0, {
|
|
1276
|
+
F: __dxlog_file4,
|
|
1277
|
+
L: 266,
|
|
1278
|
+
S: this,
|
|
1279
|
+
C: (f, a) => f(...a)
|
|
1276
1280
|
});
|
|
1277
1281
|
if (((_a = this._remoteOptions) == null ? void 0 : _a.role) !== Options.Role.HOST) {
|
|
1278
1282
|
throw new InvalidInvitationExtensionRoleError(void 0, {
|
|
@@ -1283,20 +1287,20 @@ var InvitationGuestExtension = class extends RpcExtension {
|
|
|
1283
1287
|
this._callbacks.onOpen(this._ctx);
|
|
1284
1288
|
} catch (err) {
|
|
1285
1289
|
log4("openError", err, {
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
+
F: __dxlog_file4,
|
|
1291
|
+
L: 276,
|
|
1292
|
+
S: this,
|
|
1293
|
+
C: (f, a) => f(...a)
|
|
1290
1294
|
});
|
|
1291
1295
|
this._callbacks.onError(err);
|
|
1292
1296
|
}
|
|
1293
1297
|
}
|
|
1294
1298
|
async onClose() {
|
|
1295
|
-
log4("onClose",
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1299
|
+
log4("onClose", void 0, {
|
|
1300
|
+
F: __dxlog_file4,
|
|
1301
|
+
L: 282,
|
|
1302
|
+
S: this,
|
|
1303
|
+
C: (f, a) => f(...a)
|
|
1300
1304
|
});
|
|
1301
1305
|
await this._ctx.dispose();
|
|
1302
1306
|
}
|
|
@@ -1304,6 +1308,7 @@ var InvitationGuestExtension = class extends RpcExtension {
|
|
|
1304
1308
|
var isAuthenticationRequired = (invitation) => invitation.authMethod !== Invitation2.AuthMethod.NONE;
|
|
1305
1309
|
|
|
1306
1310
|
// packages/sdk/client-services/src/packlets/invitations/invitations-handler.ts
|
|
1311
|
+
var __dxlog_file5 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitations-handler.ts";
|
|
1307
1312
|
var InvitationsHandler = class {
|
|
1308
1313
|
/**
|
|
1309
1314
|
* @internal
|
|
@@ -1315,7 +1320,7 @@ var InvitationsHandler = class {
|
|
|
1315
1320
|
var _a;
|
|
1316
1321
|
const { invitationId = PublicKey5.random().toHex(), type = Invitation3.Type.INTERACTIVE, authMethod = Invitation3.AuthMethod.SHARED_SECRET, state = Invitation3.State.INIT, timeout = INVITATION_TIMEOUT, swarmKey = PublicKey5.random() } = options != null ? options : {};
|
|
1317
1322
|
const authCode = (_a = options == null ? void 0 : options.authCode) != null ? _a : authMethod === Invitation3.AuthMethod.SHARED_SECRET ? generatePasscode(AUTHENTICATION_CODE_LENGTH) : void 0;
|
|
1318
|
-
|
|
1323
|
+
invariant6(protocol);
|
|
1319
1324
|
const invitation = {
|
|
1320
1325
|
invitationId,
|
|
1321
1326
|
type,
|
|
@@ -1337,10 +1342,10 @@ var InvitationsHandler = class {
|
|
|
1337
1342
|
log5("complete", {
|
|
1338
1343
|
...protocol.toJSON()
|
|
1339
1344
|
}, {
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1345
|
+
F: __dxlog_file5,
|
|
1346
|
+
L: 99,
|
|
1347
|
+
S: this,
|
|
1348
|
+
C: (f, a) => f(...a)
|
|
1344
1349
|
});
|
|
1345
1350
|
stream.complete();
|
|
1346
1351
|
});
|
|
@@ -1362,7 +1367,7 @@ var InvitationsHandler = class {
|
|
|
1362
1367
|
var _a2, _b, _c;
|
|
1363
1368
|
try {
|
|
1364
1369
|
const deviceKey = (_c = (_a2 = admissionRequest.device) == null ? void 0 : _a2.deviceKey) != null ? _c : (_b = admissionRequest.space) == null ? void 0 : _b.deviceKey;
|
|
1365
|
-
|
|
1370
|
+
invariant6(deviceKey);
|
|
1366
1371
|
const admissionResponse = await protocol.admit(admissionRequest, extension.guestProfile);
|
|
1367
1372
|
extension.completedTrigger.wake(deviceKey);
|
|
1368
1373
|
return admissionResponse;
|
|
@@ -1378,18 +1383,18 @@ var InvitationsHandler = class {
|
|
|
1378
1383
|
log5.trace("dxos.sdk.invitations-handler.host.onOpen", trace3.begin({
|
|
1379
1384
|
id: traceId
|
|
1380
1385
|
}), {
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1386
|
+
F: __dxlog_file5,
|
|
1387
|
+
L: 138,
|
|
1388
|
+
S: this,
|
|
1389
|
+
C: (f, a) => f(...a)
|
|
1385
1390
|
});
|
|
1386
1391
|
log5("connected", {
|
|
1387
1392
|
...protocol.toJSON()
|
|
1388
1393
|
}, {
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1394
|
+
F: __dxlog_file5,
|
|
1395
|
+
L: 139,
|
|
1396
|
+
S: this,
|
|
1397
|
+
C: (f, a) => f(...a)
|
|
1393
1398
|
});
|
|
1394
1399
|
stream.next({
|
|
1395
1400
|
...invitation,
|
|
@@ -1402,10 +1407,10 @@ var InvitationsHandler = class {
|
|
|
1402
1407
|
guest: deviceKey,
|
|
1403
1408
|
...protocol.toJSON()
|
|
1404
1409
|
}, {
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1410
|
+
F: __dxlog_file5,
|
|
1411
|
+
L: 142,
|
|
1412
|
+
S: this,
|
|
1413
|
+
C: (f, a) => f(...a)
|
|
1409
1414
|
});
|
|
1410
1415
|
stream.next({
|
|
1411
1416
|
...invitation,
|
|
@@ -1414,20 +1419,20 @@ var InvitationsHandler = class {
|
|
|
1414
1419
|
log5.trace("dxos.sdk.invitations-handler.host.onOpen", trace3.end({
|
|
1415
1420
|
id: traceId
|
|
1416
1421
|
}), {
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1422
|
+
F: __dxlog_file5,
|
|
1423
|
+
L: 144,
|
|
1424
|
+
S: this,
|
|
1425
|
+
C: (f, a) => f(...a)
|
|
1421
1426
|
});
|
|
1422
1427
|
} catch (err) {
|
|
1423
1428
|
if (err instanceof TimeoutError) {
|
|
1424
1429
|
log5("timeout", {
|
|
1425
1430
|
...protocol.toJSON()
|
|
1426
1431
|
}, {
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1432
|
+
F: __dxlog_file5,
|
|
1433
|
+
L: 147,
|
|
1434
|
+
S: this,
|
|
1435
|
+
C: (f, a) => f(...a)
|
|
1431
1436
|
});
|
|
1432
1437
|
stream.next({
|
|
1433
1438
|
...invitation,
|
|
@@ -1435,10 +1440,10 @@ var InvitationsHandler = class {
|
|
|
1435
1440
|
});
|
|
1436
1441
|
} else {
|
|
1437
1442
|
log5.error("failed", err, {
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1443
|
+
F: __dxlog_file5,
|
|
1444
|
+
L: 150,
|
|
1445
|
+
S: this,
|
|
1446
|
+
C: (f, a) => f(...a)
|
|
1442
1447
|
});
|
|
1443
1448
|
stream.error(err);
|
|
1444
1449
|
}
|
|
@@ -1446,10 +1451,10 @@ var InvitationsHandler = class {
|
|
|
1446
1451
|
id: traceId,
|
|
1447
1452
|
error: err
|
|
1448
1453
|
}), {
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1454
|
+
F: __dxlog_file5,
|
|
1455
|
+
L: 153,
|
|
1456
|
+
S: this,
|
|
1457
|
+
C: (f, a) => f(...a)
|
|
1453
1458
|
});
|
|
1454
1459
|
} finally {
|
|
1455
1460
|
if (type !== Invitation3.Type.MULTIUSE) {
|
|
@@ -1467,10 +1472,10 @@ var InvitationsHandler = class {
|
|
|
1467
1472
|
log5("timeout", {
|
|
1468
1473
|
...protocol.toJSON()
|
|
1469
1474
|
}, {
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1475
|
+
F: __dxlog_file5,
|
|
1476
|
+
L: 168,
|
|
1477
|
+
S: this,
|
|
1478
|
+
C: (f, a) => f(...a)
|
|
1474
1479
|
});
|
|
1475
1480
|
stream.next({
|
|
1476
1481
|
...invitation,
|
|
@@ -1478,10 +1483,10 @@ var InvitationsHandler = class {
|
|
|
1478
1483
|
});
|
|
1479
1484
|
} else {
|
|
1480
1485
|
log5.error("failed", err, {
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1486
|
+
F: __dxlog_file5,
|
|
1487
|
+
L: 171,
|
|
1488
|
+
S: this,
|
|
1489
|
+
C: (f, a) => f(...a)
|
|
1485
1490
|
});
|
|
1486
1491
|
stream.error(err);
|
|
1487
1492
|
}
|
|
@@ -1521,13 +1526,13 @@ var InvitationsHandler = class {
|
|
|
1521
1526
|
}
|
|
1522
1527
|
acceptInvitation(protocol, invitation) {
|
|
1523
1528
|
const { timeout = INVITATION_TIMEOUT } = invitation;
|
|
1524
|
-
|
|
1529
|
+
invariant6(protocol);
|
|
1525
1530
|
const authenticated = new Trigger3();
|
|
1526
1531
|
let admitted = false;
|
|
1527
1532
|
let currentState;
|
|
1528
1533
|
const stream = new PushStream();
|
|
1529
1534
|
const setState = (newData) => {
|
|
1530
|
-
|
|
1535
|
+
invariant6(newData.state !== void 0);
|
|
1531
1536
|
currentState = newData.state;
|
|
1532
1537
|
stream.next({
|
|
1533
1538
|
...invitation,
|
|
@@ -1540,20 +1545,20 @@ var InvitationsHandler = class {
|
|
|
1540
1545
|
log5("timeout", {
|
|
1541
1546
|
...protocol.toJSON()
|
|
1542
1547
|
}, {
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1548
|
+
F: __dxlog_file5,
|
|
1549
|
+
L: 230,
|
|
1550
|
+
S: this,
|
|
1551
|
+
C: (f, a) => f(...a)
|
|
1547
1552
|
});
|
|
1548
1553
|
setState({
|
|
1549
1554
|
state: Invitation3.State.TIMEOUT
|
|
1550
1555
|
});
|
|
1551
1556
|
} else {
|
|
1552
1557
|
log5.warn("auth failed", err, {
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1558
|
+
F: __dxlog_file5,
|
|
1559
|
+
L: 233,
|
|
1560
|
+
S: this,
|
|
1561
|
+
C: (f, a) => f(...a)
|
|
1557
1562
|
});
|
|
1558
1563
|
stream.error(err);
|
|
1559
1564
|
}
|
|
@@ -1564,10 +1569,10 @@ var InvitationsHandler = class {
|
|
|
1564
1569
|
log5("complete", {
|
|
1565
1570
|
...protocol.toJSON()
|
|
1566
1571
|
}, {
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1572
|
+
F: __dxlog_file5,
|
|
1573
|
+
L: 241,
|
|
1574
|
+
S: this,
|
|
1575
|
+
C: (f, a) => f(...a)
|
|
1571
1576
|
});
|
|
1572
1577
|
stream.complete();
|
|
1573
1578
|
});
|
|
@@ -1579,10 +1584,10 @@ var InvitationsHandler = class {
|
|
|
1579
1584
|
log5("extension disposed", {
|
|
1580
1585
|
currentState
|
|
1581
1586
|
}, {
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1587
|
+
F: __dxlog_file5,
|
|
1588
|
+
L: 251,
|
|
1589
|
+
S: this,
|
|
1590
|
+
C: (f, a) => f(...a)
|
|
1586
1591
|
});
|
|
1587
1592
|
if (!admitted) {
|
|
1588
1593
|
stream.error(new Error("Remote peer disconnected."));
|
|
@@ -1594,10 +1599,10 @@ var InvitationsHandler = class {
|
|
|
1594
1599
|
log5.trace("dxos.sdk.invitations-handler.guest.onOpen", trace3.begin({
|
|
1595
1600
|
id: traceId
|
|
1596
1601
|
}), {
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1602
|
+
F: __dxlog_file5,
|
|
1603
|
+
L: 260,
|
|
1604
|
+
S: this,
|
|
1605
|
+
C: (f, a) => f(...a)
|
|
1601
1606
|
});
|
|
1602
1607
|
if (++connectionCount > 1) {
|
|
1603
1608
|
throw new Error(`multiple connections detected: ${connectionCount}`);
|
|
@@ -1606,10 +1611,10 @@ var InvitationsHandler = class {
|
|
|
1606
1611
|
log5("connected", {
|
|
1607
1612
|
...protocol.toJSON()
|
|
1608
1613
|
}, {
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1614
|
+
F: __dxlog_file5,
|
|
1615
|
+
L: 268,
|
|
1616
|
+
S: this,
|
|
1617
|
+
C: (f, a) => f(...a)
|
|
1613
1618
|
});
|
|
1614
1619
|
setState({
|
|
1615
1620
|
state: Invitation3.State.CONNECTED
|
|
@@ -1617,20 +1622,20 @@ var InvitationsHandler = class {
|
|
|
1617
1622
|
log5("introduce", {
|
|
1618
1623
|
...protocol.toJSON()
|
|
1619
1624
|
}, {
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1625
|
+
F: __dxlog_file5,
|
|
1626
|
+
L: 272,
|
|
1627
|
+
S: this,
|
|
1628
|
+
C: (f, a) => f(...a)
|
|
1624
1629
|
});
|
|
1625
1630
|
const introductionResponse = await extension.rpc.InvitationHostService.introduce(protocol.createIntroduction());
|
|
1626
1631
|
log5("introduce response", {
|
|
1627
1632
|
...protocol.toJSON(),
|
|
1628
1633
|
response: introductionResponse
|
|
1629
1634
|
}, {
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1635
|
+
F: __dxlog_file5,
|
|
1636
|
+
L: 276,
|
|
1637
|
+
S: this,
|
|
1638
|
+
C: (f, a) => f(...a)
|
|
1634
1639
|
});
|
|
1635
1640
|
invitation.authMethod = introductionResponse.authMethod;
|
|
1636
1641
|
if (introductionResponse.spaceKey) {
|
|
@@ -1638,11 +1643,11 @@ var InvitationsHandler = class {
|
|
|
1638
1643
|
}
|
|
1639
1644
|
if (isAuthenticationRequired(invitation)) {
|
|
1640
1645
|
for (let attempt = 1; attempt <= MAX_OTP_ATTEMPTS; attempt++) {
|
|
1641
|
-
log5("guest waiting for authentication code...",
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
+
log5("guest waiting for authentication code...", void 0, {
|
|
1647
|
+
F: __dxlog_file5,
|
|
1648
|
+
L: 285,
|
|
1649
|
+
S: this,
|
|
1650
|
+
C: (f, a) => f(...a)
|
|
1646
1651
|
});
|
|
1647
1652
|
setState({
|
|
1648
1653
|
state: Invitation3.State.READY_FOR_AUTHENTICATION
|
|
@@ -1650,11 +1655,11 @@ var InvitationsHandler = class {
|
|
|
1650
1655
|
const authCode = await authenticated.wait({
|
|
1651
1656
|
timeout
|
|
1652
1657
|
});
|
|
1653
|
-
log5("sending authentication request",
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
+
log5("sending authentication request", void 0, {
|
|
1659
|
+
F: __dxlog_file5,
|
|
1660
|
+
L: 289,
|
|
1661
|
+
S: this,
|
|
1662
|
+
C: (f, a) => f(...a)
|
|
1658
1663
|
});
|
|
1659
1664
|
setState({
|
|
1660
1665
|
state: Invitation3.State.AUTHENTICATING
|
|
@@ -1672,10 +1677,10 @@ var InvitationsHandler = class {
|
|
|
1672
1677
|
log5("retrying invalid code", {
|
|
1673
1678
|
attempt
|
|
1674
1679
|
}, {
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1680
|
+
F: __dxlog_file5,
|
|
1681
|
+
L: 300,
|
|
1682
|
+
S: this,
|
|
1683
|
+
C: (f, a) => f(...a)
|
|
1679
1684
|
});
|
|
1680
1685
|
authenticated.reset();
|
|
1681
1686
|
}
|
|
@@ -1689,10 +1694,10 @@ var InvitationsHandler = class {
|
|
|
1689
1694
|
log5("request admission", {
|
|
1690
1695
|
...protocol.toJSON()
|
|
1691
1696
|
}, {
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1697
|
+
F: __dxlog_file5,
|
|
1698
|
+
L: 311,
|
|
1699
|
+
S: this,
|
|
1700
|
+
C: (f, a) => f(...a)
|
|
1696
1701
|
});
|
|
1697
1702
|
const admissionRequest = await protocol.createAdmissionRequest();
|
|
1698
1703
|
const admissionResponse = await extension.rpc.InvitationHostService.admit(admissionRequest);
|
|
@@ -1701,10 +1706,10 @@ var InvitationsHandler = class {
|
|
|
1701
1706
|
log5("admitted by host", {
|
|
1702
1707
|
...protocol.toJSON()
|
|
1703
1708
|
}, {
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1709
|
+
F: __dxlog_file5,
|
|
1710
|
+
L: 322,
|
|
1711
|
+
S: this,
|
|
1712
|
+
C: (f, a) => f(...a)
|
|
1708
1713
|
});
|
|
1709
1714
|
setState({
|
|
1710
1715
|
...result,
|
|
@@ -1713,30 +1718,30 @@ var InvitationsHandler = class {
|
|
|
1713
1718
|
log5.trace("dxos.sdk.invitations-handler.guest.onOpen", trace3.end({
|
|
1714
1719
|
id: traceId
|
|
1715
1720
|
}), {
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1721
|
+
F: __dxlog_file5,
|
|
1722
|
+
L: 324,
|
|
1723
|
+
S: this,
|
|
1724
|
+
C: (f, a) => f(...a)
|
|
1720
1725
|
});
|
|
1721
1726
|
} catch (err) {
|
|
1722
1727
|
if (err instanceof TimeoutError) {
|
|
1723
1728
|
log5("timeout", {
|
|
1724
1729
|
...protocol.toJSON()
|
|
1725
1730
|
}, {
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1731
|
+
F: __dxlog_file5,
|
|
1732
|
+
L: 327,
|
|
1733
|
+
S: this,
|
|
1734
|
+
C: (f, a) => f(...a)
|
|
1730
1735
|
});
|
|
1731
1736
|
setState({
|
|
1732
1737
|
state: Invitation3.State.TIMEOUT
|
|
1733
1738
|
});
|
|
1734
1739
|
} else {
|
|
1735
1740
|
log5("auth failed", err, {
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1741
|
+
F: __dxlog_file5,
|
|
1742
|
+
L: 330,
|
|
1743
|
+
S: this,
|
|
1744
|
+
C: (f, a) => f(...a)
|
|
1740
1745
|
});
|
|
1741
1746
|
stream.error(err);
|
|
1742
1747
|
}
|
|
@@ -1744,10 +1749,10 @@ var InvitationsHandler = class {
|
|
|
1744
1749
|
id: traceId,
|
|
1745
1750
|
error: err
|
|
1746
1751
|
}), {
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1752
|
+
F: __dxlog_file5,
|
|
1753
|
+
L: 333,
|
|
1754
|
+
S: this,
|
|
1755
|
+
C: (f, a) => f(...a)
|
|
1751
1756
|
});
|
|
1752
1757
|
} finally {
|
|
1753
1758
|
await ctx.dispose();
|
|
@@ -1762,20 +1767,20 @@ var InvitationsHandler = class {
|
|
|
1762
1767
|
log5("timeout", {
|
|
1763
1768
|
...protocol.toJSON()
|
|
1764
1769
|
}, {
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1770
|
+
F: __dxlog_file5,
|
|
1771
|
+
L: 344,
|
|
1772
|
+
S: this,
|
|
1773
|
+
C: (f, a) => f(...a)
|
|
1769
1774
|
});
|
|
1770
1775
|
setState({
|
|
1771
1776
|
state: Invitation3.State.TIMEOUT
|
|
1772
1777
|
});
|
|
1773
1778
|
} else {
|
|
1774
1779
|
log5("auth failed", err, {
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1780
|
+
F: __dxlog_file5,
|
|
1781
|
+
L: 347,
|
|
1782
|
+
S: this,
|
|
1783
|
+
C: (f, a) => f(...a)
|
|
1779
1784
|
});
|
|
1780
1785
|
stream.error(err);
|
|
1781
1786
|
}
|
|
@@ -1784,7 +1789,7 @@ var InvitationsHandler = class {
|
|
|
1784
1789
|
return extension;
|
|
1785
1790
|
};
|
|
1786
1791
|
scheduleTask2(ctx, async () => {
|
|
1787
|
-
|
|
1792
|
+
invariant6(invitation.swarmKey);
|
|
1788
1793
|
const topic = invitation.swarmKey;
|
|
1789
1794
|
const swarmConnection = await this._networkManager.joinSwarm({
|
|
1790
1795
|
topic,
|
|
@@ -1817,11 +1822,12 @@ var InvitationsHandler = class {
|
|
|
1817
1822
|
};
|
|
1818
1823
|
|
|
1819
1824
|
// packages/sdk/client-services/src/packlets/invitations/invitations-service.ts
|
|
1820
|
-
import
|
|
1825
|
+
import invariant7 from "tiny-invariant";
|
|
1821
1826
|
import { Event as Event3 } from "@dxos/async";
|
|
1822
1827
|
import { Stream as Stream8 } from "@dxos/codec-protobuf";
|
|
1823
1828
|
import { log as log6 } from "@dxos/log";
|
|
1824
1829
|
import { QueryInvitationsResponse } from "@dxos/protocols/proto/dxos/client/services";
|
|
1830
|
+
var __dxlog_file6 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitations-service.ts";
|
|
1825
1831
|
var InvitationsServiceImpl = class {
|
|
1826
1832
|
constructor(_invitationsHandler, _getHandler) {
|
|
1827
1833
|
this._invitationsHandler = _invitationsHandler;
|
|
@@ -1882,35 +1888,35 @@ var InvitationsServiceImpl = class {
|
|
|
1882
1888
|
});
|
|
1883
1889
|
}
|
|
1884
1890
|
async authenticate({ invitationId, authCode }) {
|
|
1885
|
-
log6("authenticating...",
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
1891
|
+
log6("authenticating...", void 0, {
|
|
1892
|
+
F: __dxlog_file6,
|
|
1893
|
+
L: 103,
|
|
1894
|
+
S: this,
|
|
1895
|
+
C: (f, a) => f(...a)
|
|
1890
1896
|
});
|
|
1891
|
-
|
|
1897
|
+
invariant7(invitationId);
|
|
1892
1898
|
const observable = this._acceptInvitations.get(invitationId);
|
|
1893
1899
|
if (!observable) {
|
|
1894
1900
|
log6.warn("invalid invitation", {
|
|
1895
1901
|
invitationId
|
|
1896
1902
|
}, {
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1903
|
+
F: __dxlog_file6,
|
|
1904
|
+
L: 107,
|
|
1905
|
+
S: this,
|
|
1906
|
+
C: (f, a) => f(...a)
|
|
1901
1907
|
});
|
|
1902
1908
|
} else {
|
|
1903
1909
|
await observable.authenticate(authCode);
|
|
1904
1910
|
}
|
|
1905
1911
|
}
|
|
1906
1912
|
async cancelInvitation({ invitationId }) {
|
|
1907
|
-
log6("deleting...",
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
|
|
1913
|
+
log6("deleting...", void 0, {
|
|
1914
|
+
F: __dxlog_file6,
|
|
1915
|
+
L: 114,
|
|
1916
|
+
S: this,
|
|
1917
|
+
C: (f, a) => f(...a)
|
|
1912
1918
|
});
|
|
1913
|
-
|
|
1919
|
+
invariant7(invitationId);
|
|
1914
1920
|
const created = this._createInvitations.get(invitationId);
|
|
1915
1921
|
const accepted = this._acceptInvitations.get(invitationId);
|
|
1916
1922
|
if (created) {
|
|
@@ -1925,10 +1931,10 @@ var InvitationsServiceImpl = class {
|
|
|
1925
1931
|
log6.warn("invalid invitation", {
|
|
1926
1932
|
invitationId
|
|
1927
1933
|
}, {
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
1934
|
+
F: __dxlog_file6,
|
|
1935
|
+
L: 127,
|
|
1936
|
+
S: this,
|
|
1937
|
+
C: (f, a) => f(...a)
|
|
1932
1938
|
});
|
|
1933
1939
|
}
|
|
1934
1940
|
}
|
|
@@ -1985,11 +1991,12 @@ var InvitationsServiceImpl = class {
|
|
|
1985
1991
|
};
|
|
1986
1992
|
|
|
1987
1993
|
// packages/sdk/client-services/src/packlets/invitations/space-invitation-protocol.ts
|
|
1988
|
-
import
|
|
1994
|
+
import invariant8 from "tiny-invariant";
|
|
1989
1995
|
import { createAdmissionCredentials, getCredentialAssertion } from "@dxos/credentials";
|
|
1990
1996
|
import { writeMessages as writeMessages2 } from "@dxos/feed-store";
|
|
1991
1997
|
import { log as log7 } from "@dxos/log";
|
|
1992
1998
|
import { Invitation as Invitation4 } from "@dxos/protocols/proto/dxos/client/services";
|
|
1999
|
+
var __dxlog_file7 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/space-invitation-protocol.ts";
|
|
1993
2000
|
var SpaceInvitationProtocol = class {
|
|
1994
2001
|
constructor(_spaceManager, _signingContext, _keyring, _spaceKey) {
|
|
1995
2002
|
this._spaceManager = _spaceManager;
|
|
@@ -2011,24 +2018,24 @@ var SpaceInvitationProtocol = class {
|
|
|
2011
2018
|
}
|
|
2012
2019
|
async admit(request, guestProfile) {
|
|
2013
2020
|
var _a;
|
|
2014
|
-
|
|
2021
|
+
invariant8(this._spaceKey);
|
|
2015
2022
|
const space = await this._spaceManager.spaces.get(this._spaceKey);
|
|
2016
|
-
|
|
2017
|
-
|
|
2023
|
+
invariant8(space);
|
|
2024
|
+
invariant8(request.space);
|
|
2018
2025
|
const { identityKey, deviceKey } = request.space;
|
|
2019
2026
|
log7("writing guest credentials", {
|
|
2020
2027
|
host: this._signingContext.deviceKey,
|
|
2021
2028
|
guest: deviceKey
|
|
2022
2029
|
}, {
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
|
|
2030
|
+
F: __dxlog_file7,
|
|
2031
|
+
L: 50,
|
|
2032
|
+
S: this,
|
|
2033
|
+
C: (f, a) => f(...a)
|
|
2027
2034
|
});
|
|
2028
2035
|
const credentials = await createAdmissionCredentials(this._signingContext.credentialSigner, identityKey, space.key, space.inner.genesisFeedKey, guestProfile);
|
|
2029
|
-
|
|
2036
|
+
invariant8(credentials[0].credential);
|
|
2030
2037
|
const spaceMemberCredential = credentials[0].credential.credential;
|
|
2031
|
-
|
|
2038
|
+
invariant8(getCredentialAssertion(spaceMemberCredential)["@type"] === "dxos.halo.credentials.SpaceMember");
|
|
2032
2039
|
await writeMessages2(space.inner.controlPipeline.writer, credentials);
|
|
2033
2040
|
return {
|
|
2034
2041
|
space: {
|
|
@@ -2056,11 +2063,11 @@ var SpaceInvitationProtocol = class {
|
|
|
2056
2063
|
};
|
|
2057
2064
|
}
|
|
2058
2065
|
async accept(response) {
|
|
2059
|
-
|
|
2066
|
+
invariant8(response.space);
|
|
2060
2067
|
const { credential, controlTimeframe, dataTimeframe } = response.space;
|
|
2061
2068
|
const assertion = getCredentialAssertion(credential);
|
|
2062
|
-
|
|
2063
|
-
|
|
2069
|
+
invariant8(assertion["@type"] === "dxos.halo.credentials.SpaceMember", "Invalid credential");
|
|
2070
|
+
invariant8(credential.subject.id.equals(this._signingContext.identityKey));
|
|
2064
2071
|
await this._spaceManager.acceptSpace({
|
|
2065
2072
|
spaceKey: assertion.spaceKey,
|
|
2066
2073
|
genesisFeedKey: assertion.genesisFeedKey,
|
|
@@ -2075,7 +2082,7 @@ var SpaceInvitationProtocol = class {
|
|
|
2075
2082
|
};
|
|
2076
2083
|
|
|
2077
2084
|
// packages/sdk/client-services/src/packlets/spaces/data-space.ts
|
|
2078
|
-
import { Event as Event5, scheduleTask as scheduleTask4, trackLeaks } from "@dxos/async";
|
|
2085
|
+
import { Event as Event5, scheduleTask as scheduleTask4, synchronized, trackLeaks } from "@dxos/async";
|
|
2079
2086
|
import { AUTH_TIMEOUT as AUTH_TIMEOUT2 } from "@dxos/client-protocol";
|
|
2080
2087
|
import { cancelWithContext as cancelWithContext2, Context as Context6 } from "@dxos/context";
|
|
2081
2088
|
import { timed } from "@dxos/debug";
|
|
@@ -2089,7 +2096,7 @@ import { Timeframe } from "@dxos/timeframe";
|
|
|
2089
2096
|
import { ComplexSet as ComplexSet2 } from "@dxos/util";
|
|
2090
2097
|
|
|
2091
2098
|
// packages/sdk/client-services/src/packlets/spaces/notarization-plugin.ts
|
|
2092
|
-
import
|
|
2099
|
+
import invariant9 from "tiny-invariant";
|
|
2093
2100
|
import { DeferredTask, Event as Event4, scheduleTask as scheduleTask3, sleep, TimeoutError as TimeoutError2, Trigger as Trigger4 } from "@dxos/async";
|
|
2094
2101
|
import { Context as Context5, rejectOnDispose } from "@dxos/context";
|
|
2095
2102
|
import { PublicKey as PublicKey6 } from "@dxos/keys";
|
|
@@ -2097,6 +2104,7 @@ import { log as log8 } from "@dxos/log";
|
|
|
2097
2104
|
import { schema as schema3 } from "@dxos/protocols";
|
|
2098
2105
|
import { RpcExtension as RpcExtension2 } from "@dxos/teleport";
|
|
2099
2106
|
import { ComplexMap as ComplexMap2, ComplexSet, entry } from "@dxos/util";
|
|
2107
|
+
var __dxlog_file8 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/notarization-plugin.ts";
|
|
2100
2108
|
var DEFAULT_RETRY_TIMEOUT = 1e3;
|
|
2101
2109
|
var DEFAULT_SUCCESS_DELAY = 1e3;
|
|
2102
2110
|
var DEFAULT_NOTARIZE_TIMEOUT = 1e4;
|
|
@@ -2109,6 +2117,9 @@ var NotarizationPlugin = class {
|
|
|
2109
2117
|
this._processedCredentials = new ComplexSet(PublicKey6.hash);
|
|
2110
2118
|
this._processCredentialsTriggers = new ComplexMap2(PublicKey6.hash);
|
|
2111
2119
|
}
|
|
2120
|
+
get hasWriter() {
|
|
2121
|
+
return !!this._writer;
|
|
2122
|
+
}
|
|
2112
2123
|
async open() {
|
|
2113
2124
|
}
|
|
2114
2125
|
async close() {
|
|
@@ -2121,22 +2132,22 @@ var NotarizationPlugin = class {
|
|
|
2121
2132
|
log8("notarize", {
|
|
2122
2133
|
credentials
|
|
2123
2134
|
}, {
|
|
2124
|
-
|
|
2125
|
-
|
|
2126
|
-
|
|
2127
|
-
|
|
2135
|
+
F: __dxlog_file8,
|
|
2136
|
+
L: 91,
|
|
2137
|
+
S: this,
|
|
2138
|
+
C: (f, a) => f(...a)
|
|
2128
2139
|
});
|
|
2129
|
-
|
|
2140
|
+
invariant9(credentials.every((credential) => credential.id), "Credentials must have an id");
|
|
2130
2141
|
const errors = new Trigger4();
|
|
2131
2142
|
const ctx = this._ctx.derive({
|
|
2132
2143
|
onError: (err) => {
|
|
2133
2144
|
log8.warn("Notarization error", {
|
|
2134
2145
|
err
|
|
2135
2146
|
}, {
|
|
2136
|
-
|
|
2137
|
-
|
|
2138
|
-
|
|
2139
|
-
|
|
2147
|
+
F: __dxlog_file8,
|
|
2148
|
+
L: 100,
|
|
2149
|
+
S: this,
|
|
2150
|
+
C: (f, a) => f(...a)
|
|
2140
2151
|
});
|
|
2141
2152
|
void ctx.dispose();
|
|
2142
2153
|
errors.throw(err);
|
|
@@ -2149,10 +2160,10 @@ var NotarizationPlugin = class {
|
|
|
2149
2160
|
timeout,
|
|
2150
2161
|
peers: Array.from(this._extensions).map((extension) => extension.remotePeerId)
|
|
2151
2162
|
}, {
|
|
2152
|
-
|
|
2153
|
-
|
|
2154
|
-
|
|
2155
|
-
|
|
2163
|
+
F: __dxlog_file8,
|
|
2164
|
+
L: 112,
|
|
2165
|
+
S: this,
|
|
2166
|
+
C: (f, a) => f(...a)
|
|
2156
2167
|
});
|
|
2157
2168
|
void ctx.dispose();
|
|
2158
2169
|
errors.throw(new TimeoutError2(timeout, "Notarization timed out"));
|
|
@@ -2172,10 +2183,10 @@ var NotarizationPlugin = class {
|
|
|
2172
2183
|
log8.warn("Exhausted all peers to notarize with", {
|
|
2173
2184
|
retryIn: retryTimeout
|
|
2174
2185
|
}, {
|
|
2175
|
-
|
|
2176
|
-
|
|
2177
|
-
|
|
2178
|
-
|
|
2186
|
+
F: __dxlog_file8,
|
|
2187
|
+
L: 137,
|
|
2188
|
+
S: this,
|
|
2189
|
+
C: (f, a) => f(...a)
|
|
2179
2190
|
});
|
|
2180
2191
|
peersTried.clear();
|
|
2181
2192
|
scheduleTask3(ctx, () => notarizeTask.schedule(), retryTimeout);
|
|
@@ -2186,28 +2197,28 @@ var NotarizationPlugin = class {
|
|
|
2186
2197
|
peer: peer.localPeerId,
|
|
2187
2198
|
credentialId: credentials.map((credential) => credential.id)
|
|
2188
2199
|
}, {
|
|
2189
|
-
|
|
2190
|
-
|
|
2191
|
-
|
|
2192
|
-
|
|
2200
|
+
F: __dxlog_file8,
|
|
2201
|
+
L: 144,
|
|
2202
|
+
S: this,
|
|
2203
|
+
C: (f, a) => f(...a)
|
|
2193
2204
|
});
|
|
2194
2205
|
await peer.rpc.NotarizationService.notarize({
|
|
2195
2206
|
credentials: credentials.filter((credential) => !this._processedCredentials.has(credential.id))
|
|
2196
2207
|
});
|
|
2197
|
-
log8("success",
|
|
2198
|
-
|
|
2199
|
-
|
|
2200
|
-
|
|
2201
|
-
|
|
2208
|
+
log8("success", void 0, {
|
|
2209
|
+
F: __dxlog_file8,
|
|
2210
|
+
L: 148,
|
|
2211
|
+
S: this,
|
|
2212
|
+
C: (f, a) => f(...a)
|
|
2202
2213
|
});
|
|
2203
2214
|
await sleep(successDelay);
|
|
2204
2215
|
} catch (err) {
|
|
2205
2216
|
if (!ctx.disposed && !err.message.includes(WRITER_NOT_SET_ERROR_CODE)) {
|
|
2206
2217
|
log8.warn("error notarizing (recoverable)", err, {
|
|
2207
|
-
|
|
2208
|
-
|
|
2209
|
-
|
|
2210
|
-
|
|
2218
|
+
F: __dxlog_file8,
|
|
2219
|
+
L: 152,
|
|
2220
|
+
S: this,
|
|
2221
|
+
C: (f, a) => f(...a)
|
|
2211
2222
|
});
|
|
2212
2223
|
}
|
|
2213
2224
|
notarizeTask.schedule();
|
|
@@ -2221,11 +2232,11 @@ var NotarizationPlugin = class {
|
|
|
2221
2232
|
allNotarized,
|
|
2222
2233
|
errors.wait()
|
|
2223
2234
|
]);
|
|
2224
|
-
log8("done",
|
|
2225
|
-
|
|
2226
|
-
|
|
2227
|
-
|
|
2228
|
-
|
|
2235
|
+
log8("done", void 0, {
|
|
2236
|
+
F: __dxlog_file8,
|
|
2237
|
+
L: 163,
|
|
2238
|
+
S: this,
|
|
2239
|
+
C: (f, a) => f(...a)
|
|
2229
2240
|
});
|
|
2230
2241
|
} finally {
|
|
2231
2242
|
await ctx.dispose();
|
|
@@ -2234,7 +2245,7 @@ var NotarizationPlugin = class {
|
|
|
2234
2245
|
/**
|
|
2235
2246
|
* Called with credentials arriving from the control pipeline.
|
|
2236
2247
|
*/
|
|
2237
|
-
async
|
|
2248
|
+
async processCredential(credential) {
|
|
2238
2249
|
var _a;
|
|
2239
2250
|
if (!credential.id) {
|
|
2240
2251
|
return;
|
|
@@ -2244,7 +2255,7 @@ var NotarizationPlugin = class {
|
|
|
2244
2255
|
this._processCredentialsTriggers.delete(credential.id);
|
|
2245
2256
|
}
|
|
2246
2257
|
setWriter(writer) {
|
|
2247
|
-
|
|
2258
|
+
invariant9(!this._writer, "Writer already set.");
|
|
2248
2259
|
this._writer = writer;
|
|
2249
2260
|
}
|
|
2250
2261
|
async _waitUntilProcessed(id) {
|
|
@@ -2262,7 +2273,7 @@ var NotarizationPlugin = class {
|
|
|
2262
2273
|
throw new Error(WRITER_NOT_SET_ERROR_CODE);
|
|
2263
2274
|
}
|
|
2264
2275
|
for (const credential of (_a = request.credentials) != null ? _a : []) {
|
|
2265
|
-
|
|
2276
|
+
invariant9(credential.id, "Credential must have an id");
|
|
2266
2277
|
if (this._processedCredentials.has(credential.id)) {
|
|
2267
2278
|
continue;
|
|
2268
2279
|
}
|
|
@@ -2275,10 +2286,10 @@ var NotarizationPlugin = class {
|
|
|
2275
2286
|
log8("extension opened", {
|
|
2276
2287
|
peer: extension.localPeerId
|
|
2277
2288
|
}, {
|
|
2278
|
-
|
|
2279
|
-
|
|
2280
|
-
|
|
2281
|
-
|
|
2289
|
+
F: __dxlog_file8,
|
|
2290
|
+
L: 212,
|
|
2291
|
+
S: this,
|
|
2292
|
+
C: (f, a) => f(...a)
|
|
2282
2293
|
});
|
|
2283
2294
|
this._extensions.add(extension);
|
|
2284
2295
|
this._extensionOpened.emit();
|
|
@@ -2287,10 +2298,10 @@ var NotarizationPlugin = class {
|
|
|
2287
2298
|
log8("extension closed", {
|
|
2288
2299
|
peer: extension.localPeerId
|
|
2289
2300
|
}, {
|
|
2290
|
-
|
|
2291
|
-
|
|
2292
|
-
|
|
2293
|
-
|
|
2301
|
+
F: __dxlog_file8,
|
|
2302
|
+
L: 217,
|
|
2303
|
+
S: this,
|
|
2304
|
+
C: (f, a) => f(...a)
|
|
2294
2305
|
});
|
|
2295
2306
|
this._extensions.delete(extension);
|
|
2296
2307
|
},
|
|
@@ -2331,7 +2342,7 @@ var NotarizationTeleportExtension = class extends RpcExtension2 {
|
|
|
2331
2342
|
};
|
|
2332
2343
|
|
|
2333
2344
|
// packages/sdk/client-services/src/packlets/spaces/data-space.ts
|
|
2334
|
-
|
|
2345
|
+
function _ts_decorate(decorators, target, key, desc) {
|
|
2335
2346
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2336
2347
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
2337
2348
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -2340,10 +2351,12 @@ var __decorate = function(decorators, target, key, desc) {
|
|
|
2340
2351
|
if (d = decorators[i])
|
|
2341
2352
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
2342
2353
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2343
|
-
}
|
|
2354
|
+
}
|
|
2355
|
+
var __dxlog_file9 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space.ts";
|
|
2344
2356
|
var DataSpace = class DataSpace2 {
|
|
2345
2357
|
constructor(params) {
|
|
2346
2358
|
this._ctx = new Context6();
|
|
2359
|
+
this._notarizationPlugin = new NotarizationPlugin();
|
|
2347
2360
|
this._state = SpaceState.CLOSED;
|
|
2348
2361
|
/**
|
|
2349
2362
|
* Error for _state === SpaceState.ERROR.
|
|
@@ -2366,8 +2379,8 @@ var DataSpace = class DataSpace2 {
|
|
|
2366
2379
|
update: this._inner.stateUpdate,
|
|
2367
2380
|
authTimeout: AUTH_TIMEOUT2
|
|
2368
2381
|
});
|
|
2369
|
-
this._notarizationPluginConsumer = this._inner.spaceState.registerProcessor(new NotarizationPlugin());
|
|
2370
2382
|
this._cache = params.cache;
|
|
2383
|
+
this._state = params.initialState;
|
|
2371
2384
|
}
|
|
2372
2385
|
get key() {
|
|
2373
2386
|
return this._inner.key;
|
|
@@ -2389,25 +2402,36 @@ var DataSpace = class DataSpace2 {
|
|
|
2389
2402
|
return this._presence;
|
|
2390
2403
|
}
|
|
2391
2404
|
get notarizationPlugin() {
|
|
2392
|
-
return this.
|
|
2405
|
+
return this._notarizationPlugin;
|
|
2393
2406
|
}
|
|
2394
2407
|
get cache() {
|
|
2395
2408
|
return this._cache;
|
|
2396
2409
|
}
|
|
2397
2410
|
async open() {
|
|
2398
|
-
await this.
|
|
2399
|
-
|
|
2411
|
+
await this._open();
|
|
2412
|
+
}
|
|
2413
|
+
async _open() {
|
|
2414
|
+
await this._notarizationPlugin.open();
|
|
2415
|
+
await this._inner.spaceState.addCredentialProcessor(this._notarizationPlugin);
|
|
2400
2416
|
await this._inner.open();
|
|
2401
|
-
this._state = SpaceState.
|
|
2417
|
+
this._state = SpaceState.CONTROL_ONLY;
|
|
2418
|
+
this.stateUpdate.emit();
|
|
2419
|
+
this.metrics = {};
|
|
2402
2420
|
this.metrics.open = new Date();
|
|
2403
2421
|
}
|
|
2404
2422
|
async close() {
|
|
2423
|
+
await this._close();
|
|
2424
|
+
}
|
|
2425
|
+
async _close() {
|
|
2426
|
+
var _a, _b;
|
|
2427
|
+
await ((_b = (_a = this._callbacks).beforeClose) == null ? void 0 : _b.call(_a));
|
|
2405
2428
|
this._state = SpaceState.CLOSED;
|
|
2406
2429
|
await this._ctx.dispose();
|
|
2430
|
+
this._ctx = new Context6();
|
|
2407
2431
|
await this.authVerifier.close();
|
|
2408
2432
|
await this._inner.close();
|
|
2409
|
-
await this.
|
|
2410
|
-
await this.
|
|
2433
|
+
await this._inner.spaceState.removeCredentialProcessor(this._notarizationPlugin);
|
|
2434
|
+
await this._notarizationPlugin.close();
|
|
2411
2435
|
await this._presence.destroy();
|
|
2412
2436
|
}
|
|
2413
2437
|
async postMessage(channel, message) {
|
|
@@ -2427,18 +2451,18 @@ var DataSpace = class DataSpace2 {
|
|
|
2427
2451
|
} catch (err) {
|
|
2428
2452
|
if (err instanceof CancelledError) {
|
|
2429
2453
|
log9("Data pipeline initialization cancelled", err, {
|
|
2430
|
-
|
|
2431
|
-
|
|
2432
|
-
|
|
2433
|
-
|
|
2454
|
+
F: __dxlog_file9,
|
|
2455
|
+
L: 193,
|
|
2456
|
+
S: this,
|
|
2457
|
+
C: (f, a) => f(...a)
|
|
2434
2458
|
});
|
|
2435
2459
|
return;
|
|
2436
2460
|
}
|
|
2437
2461
|
log9.error("Error initializing data pipeline", err, {
|
|
2438
|
-
|
|
2439
|
-
|
|
2440
|
-
|
|
2441
|
-
|
|
2462
|
+
F: __dxlog_file9,
|
|
2463
|
+
L: 197,
|
|
2464
|
+
S: this,
|
|
2465
|
+
C: (f, a) => f(...a)
|
|
2442
2466
|
});
|
|
2443
2467
|
this._state = SpaceState.ERROR;
|
|
2444
2468
|
this.error = err;
|
|
@@ -2450,7 +2474,7 @@ var DataSpace = class DataSpace2 {
|
|
|
2450
2474
|
}
|
|
2451
2475
|
async initializeDataPipeline() {
|
|
2452
2476
|
var _a, _b, _c, _d;
|
|
2453
|
-
if (this._state !== SpaceState.
|
|
2477
|
+
if (this._state !== SpaceState.CONTROL_ONLY) {
|
|
2454
2478
|
throw new SystemError("Invalid operation");
|
|
2455
2479
|
}
|
|
2456
2480
|
this._state = SpaceState.INITIALIZING;
|
|
@@ -2460,37 +2484,39 @@ var DataSpace = class DataSpace2 {
|
|
|
2460
2484
|
});
|
|
2461
2485
|
this.metrics.controlPipelineReady = new Date();
|
|
2462
2486
|
await this._createWritableFeeds();
|
|
2463
|
-
log9("Writable feeds created",
|
|
2464
|
-
|
|
2465
|
-
|
|
2466
|
-
|
|
2467
|
-
|
|
2487
|
+
log9("Writable feeds created", void 0, {
|
|
2488
|
+
F: __dxlog_file9,
|
|
2489
|
+
L: 221,
|
|
2490
|
+
S: this,
|
|
2491
|
+
C: (f, a) => f(...a)
|
|
2468
2492
|
});
|
|
2469
2493
|
this.stateUpdate.emit();
|
|
2470
|
-
this.notarizationPlugin.
|
|
2471
|
-
credential
|
|
2472
|
-
credential
|
|
2473
|
-
|
|
2474
|
-
|
|
2494
|
+
if (!this.notarizationPlugin.hasWriter) {
|
|
2495
|
+
this.notarizationPlugin.setWriter(createMappedFeedWriter((credential) => ({
|
|
2496
|
+
credential: {
|
|
2497
|
+
credential
|
|
2498
|
+
}
|
|
2499
|
+
}), this._inner.controlPipeline.writer));
|
|
2500
|
+
}
|
|
2475
2501
|
await this._inner.initializeDataPipeline();
|
|
2476
2502
|
this.metrics.dataPipelineOpen = new Date();
|
|
2477
2503
|
await cancelWithContext2(this._ctx, this._inner.dataPipeline.ensureEpochInitialized());
|
|
2478
|
-
log9("waiting for data pipeline to reach target timeframe",
|
|
2479
|
-
|
|
2480
|
-
|
|
2481
|
-
|
|
2482
|
-
|
|
2504
|
+
log9("waiting for data pipeline to reach target timeframe", void 0, {
|
|
2505
|
+
F: __dxlog_file9,
|
|
2506
|
+
L: 242,
|
|
2507
|
+
S: this,
|
|
2508
|
+
C: (f, a) => f(...a)
|
|
2483
2509
|
});
|
|
2484
2510
|
await this._inner.dataPipeline.pipelineState.waitUntilReachedTargetTimeframe({
|
|
2485
2511
|
ctx: this._ctx,
|
|
2486
2512
|
breakOnStall: false
|
|
2487
2513
|
});
|
|
2488
2514
|
this.metrics.dataPipelineReady = new Date();
|
|
2489
|
-
log9("data pipeline ready",
|
|
2490
|
-
|
|
2491
|
-
|
|
2492
|
-
|
|
2493
|
-
|
|
2515
|
+
log9("data pipeline ready", void 0, {
|
|
2516
|
+
F: __dxlog_file9,
|
|
2517
|
+
L: 251,
|
|
2518
|
+
S: this,
|
|
2519
|
+
C: (f, a) => f(...a)
|
|
2494
2520
|
});
|
|
2495
2521
|
await ((_b = (_a = this._callbacks).beforeReady) == null ? void 0 : _b.call(_a));
|
|
2496
2522
|
this._state = SpaceState.READY;
|
|
@@ -2568,17 +2594,46 @@ var DataSpace = class DataSpace2 {
|
|
|
2568
2594
|
}
|
|
2569
2595
|
}
|
|
2570
2596
|
}
|
|
2597
|
+
async activate() {
|
|
2598
|
+
if (this._state !== SpaceState.INACTIVE) {
|
|
2599
|
+
throw new SystemError("Invalid operation");
|
|
2600
|
+
}
|
|
2601
|
+
await this._metadataStore.setSpaceState(this.key, SpaceState.ACTIVE);
|
|
2602
|
+
await this._open();
|
|
2603
|
+
this.initializeDataPipelineAsync();
|
|
2604
|
+
}
|
|
2605
|
+
async deactivate() {
|
|
2606
|
+
if (this._state === SpaceState.INACTIVE) {
|
|
2607
|
+
throw new SystemError("Invalid operation");
|
|
2608
|
+
}
|
|
2609
|
+
await this._metadataStore.setSpaceState(this.key, SpaceState.INACTIVE);
|
|
2610
|
+
await this._close();
|
|
2611
|
+
this._state = SpaceState.INACTIVE;
|
|
2612
|
+
this.stateUpdate.emit();
|
|
2613
|
+
}
|
|
2571
2614
|
};
|
|
2572
|
-
|
|
2615
|
+
_ts_decorate([
|
|
2616
|
+
synchronized
|
|
2617
|
+
], DataSpace.prototype, "open", null);
|
|
2618
|
+
_ts_decorate([
|
|
2619
|
+
synchronized
|
|
2620
|
+
], DataSpace.prototype, "close", null);
|
|
2621
|
+
_ts_decorate([
|
|
2573
2622
|
timed(1e4)
|
|
2574
2623
|
], DataSpace.prototype, "_createWritableFeeds", null);
|
|
2575
|
-
|
|
2624
|
+
_ts_decorate([
|
|
2625
|
+
synchronized
|
|
2626
|
+
], DataSpace.prototype, "activate", null);
|
|
2627
|
+
_ts_decorate([
|
|
2628
|
+
synchronized
|
|
2629
|
+
], DataSpace.prototype, "deactivate", null);
|
|
2630
|
+
DataSpace = _ts_decorate([
|
|
2576
2631
|
trackLeaks("open", "close")
|
|
2577
2632
|
], DataSpace);
|
|
2578
2633
|
|
|
2579
2634
|
// packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts
|
|
2580
|
-
import
|
|
2581
|
-
import { Event as Event6, synchronized, trackLeaks as trackLeaks2 } from "@dxos/async";
|
|
2635
|
+
import invariant10 from "tiny-invariant";
|
|
2636
|
+
import { Event as Event6, synchronized as synchronized2, trackLeaks as trackLeaks2 } from "@dxos/async";
|
|
2582
2637
|
import { cancelWithContext as cancelWithContext3, Context as Context7 } from "@dxos/context";
|
|
2583
2638
|
import { getCredentialAssertion as getCredentialAssertion2 } from "@dxos/credentials";
|
|
2584
2639
|
import { PublicKey as PublicKey8 } from "@dxos/keys";
|
|
@@ -2659,7 +2714,7 @@ var spaceGenesis = async (keyring, signingContext, space) => {
|
|
|
2659
2714
|
};
|
|
2660
2715
|
|
|
2661
2716
|
// packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts
|
|
2662
|
-
|
|
2717
|
+
function _ts_decorate2(decorators, target, key, desc) {
|
|
2663
2718
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2664
2719
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
2665
2720
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -2668,7 +2723,8 @@ var __decorate2 = function(decorators, target, key, desc) {
|
|
|
2668
2723
|
if (d = decorators[i])
|
|
2669
2724
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
2670
2725
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2671
|
-
}
|
|
2726
|
+
}
|
|
2727
|
+
var __dxlog_file10 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts";
|
|
2672
2728
|
var DataSpaceManager = class DataSpaceManager2 {
|
|
2673
2729
|
constructor(_spaceManager, _metadataStore, _dataServiceSubscriptions, _keyring, _signingContext, _feedStore) {
|
|
2674
2730
|
this._spaceManager = _spaceManager;
|
|
@@ -2688,50 +2744,52 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2688
2744
|
return this._spaces;
|
|
2689
2745
|
}
|
|
2690
2746
|
async open() {
|
|
2691
|
-
log10("open",
|
|
2692
|
-
|
|
2693
|
-
|
|
2694
|
-
|
|
2695
|
-
|
|
2747
|
+
log10("open", void 0, {
|
|
2748
|
+
F: __dxlog_file10,
|
|
2749
|
+
L: 80,
|
|
2750
|
+
S: this,
|
|
2751
|
+
C: (f, a) => f(...a)
|
|
2696
2752
|
});
|
|
2697
2753
|
log10.trace("dxos.echo.data-space-manager.open", trace4.begin({
|
|
2698
2754
|
id: this._instanceId
|
|
2699
2755
|
}), {
|
|
2700
|
-
|
|
2701
|
-
|
|
2702
|
-
|
|
2703
|
-
|
|
2756
|
+
F: __dxlog_file10,
|
|
2757
|
+
L: 81,
|
|
2758
|
+
S: this,
|
|
2759
|
+
C: (f, a) => f(...a)
|
|
2704
2760
|
});
|
|
2705
2761
|
await this._metadataStore.load();
|
|
2706
2762
|
log10("metadata loaded", {
|
|
2707
2763
|
spaces: this._metadataStore.spaces.length
|
|
2708
2764
|
}, {
|
|
2709
|
-
|
|
2710
|
-
|
|
2711
|
-
|
|
2712
|
-
|
|
2765
|
+
F: __dxlog_file10,
|
|
2766
|
+
L: 83,
|
|
2767
|
+
S: this,
|
|
2768
|
+
C: (f, a) => f(...a)
|
|
2713
2769
|
});
|
|
2714
2770
|
for (const spaceMetadata of this._metadataStore.spaces) {
|
|
2715
2771
|
try {
|
|
2716
2772
|
log10("load space", {
|
|
2717
2773
|
spaceMetadata
|
|
2718
2774
|
}, {
|
|
2719
|
-
|
|
2720
|
-
|
|
2721
|
-
|
|
2722
|
-
|
|
2775
|
+
F: __dxlog_file10,
|
|
2776
|
+
L: 87,
|
|
2777
|
+
S: this,
|
|
2778
|
+
C: (f, a) => f(...a)
|
|
2723
2779
|
});
|
|
2724
2780
|
const space = await this._constructSpace(spaceMetadata);
|
|
2725
|
-
|
|
2781
|
+
if (spaceMetadata.state !== SpaceState2.INACTIVE) {
|
|
2782
|
+
space.initializeDataPipelineAsync();
|
|
2783
|
+
}
|
|
2726
2784
|
} catch (err) {
|
|
2727
2785
|
log10.error("Error loading space", {
|
|
2728
2786
|
spaceMetadata,
|
|
2729
2787
|
err
|
|
2730
2788
|
}, {
|
|
2731
|
-
|
|
2732
|
-
|
|
2733
|
-
|
|
2734
|
-
|
|
2789
|
+
F: __dxlog_file10,
|
|
2790
|
+
L: 93,
|
|
2791
|
+
S: this,
|
|
2792
|
+
C: (f, a) => f(...a)
|
|
2735
2793
|
});
|
|
2736
2794
|
}
|
|
2737
2795
|
}
|
|
@@ -2740,18 +2798,18 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2740
2798
|
log10.trace("dxos.echo.data-space-manager.open", trace4.end({
|
|
2741
2799
|
id: this._instanceId
|
|
2742
2800
|
}), {
|
|
2743
|
-
|
|
2744
|
-
|
|
2745
|
-
|
|
2746
|
-
|
|
2801
|
+
F: __dxlog_file10,
|
|
2802
|
+
L: 99,
|
|
2803
|
+
S: this,
|
|
2804
|
+
C: (f, a) => f(...a)
|
|
2747
2805
|
});
|
|
2748
2806
|
}
|
|
2749
2807
|
async close() {
|
|
2750
|
-
log10("close",
|
|
2751
|
-
|
|
2752
|
-
|
|
2753
|
-
|
|
2754
|
-
|
|
2808
|
+
log10("close", void 0, {
|
|
2809
|
+
F: __dxlog_file10,
|
|
2810
|
+
L: 104,
|
|
2811
|
+
S: this,
|
|
2812
|
+
C: (f, a) => f(...a)
|
|
2755
2813
|
});
|
|
2756
2814
|
this._isOpen = false;
|
|
2757
2815
|
await this._ctx.dispose();
|
|
@@ -2763,7 +2821,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2763
2821
|
* Creates a new space writing the genesis credentials to the control feed.
|
|
2764
2822
|
*/
|
|
2765
2823
|
async createSpace() {
|
|
2766
|
-
|
|
2824
|
+
invariant10(this._isOpen, "Not open.");
|
|
2767
2825
|
const spaceKey = await this._keyring.createKey();
|
|
2768
2826
|
const controlFeedKey = await this._keyring.createKey();
|
|
2769
2827
|
const dataFeedKey = await this._keyring.createKey();
|
|
@@ -2771,21 +2829,22 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2771
2829
|
key: spaceKey,
|
|
2772
2830
|
genesisFeedKey: controlFeedKey,
|
|
2773
2831
|
controlFeedKey,
|
|
2774
|
-
dataFeedKey
|
|
2832
|
+
dataFeedKey,
|
|
2833
|
+
state: SpaceState2.ACTIVE
|
|
2775
2834
|
};
|
|
2776
2835
|
log10("creating space...", {
|
|
2777
2836
|
spaceKey
|
|
2778
2837
|
}, {
|
|
2779
|
-
|
|
2780
|
-
|
|
2781
|
-
|
|
2782
|
-
|
|
2838
|
+
F: __dxlog_file10,
|
|
2839
|
+
L: 129,
|
|
2840
|
+
S: this,
|
|
2841
|
+
C: (f, a) => f(...a)
|
|
2783
2842
|
});
|
|
2784
2843
|
const space = await this._constructSpace(metadata);
|
|
2785
2844
|
const credentials = await spaceGenesis(this._keyring, this._signingContext, space.inner);
|
|
2786
2845
|
await this._metadataStore.addSpace(metadata);
|
|
2787
2846
|
const memberCredential = credentials[1];
|
|
2788
|
-
|
|
2847
|
+
invariant10(getCredentialAssertion2(memberCredential)["@type"] === "dxos.halo.credentials.SpaceMember");
|
|
2789
2848
|
await this._signingContext.recordCredential(memberCredential);
|
|
2790
2849
|
await space.initializeDataPipeline();
|
|
2791
2850
|
this.updated.emit();
|
|
@@ -2796,13 +2855,13 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2796
2855
|
log10("accept space", {
|
|
2797
2856
|
opts
|
|
2798
2857
|
}, {
|
|
2799
|
-
|
|
2800
|
-
|
|
2801
|
-
|
|
2802
|
-
|
|
2858
|
+
F: __dxlog_file10,
|
|
2859
|
+
L: 148,
|
|
2860
|
+
S: this,
|
|
2861
|
+
C: (f, a) => f(...a)
|
|
2803
2862
|
});
|
|
2804
|
-
|
|
2805
|
-
|
|
2863
|
+
invariant10(this._isOpen, "Not open.");
|
|
2864
|
+
invariant10(!this._spaces.has(opts.spaceKey), "Space already exists.");
|
|
2806
2865
|
const metadata = {
|
|
2807
2866
|
key: opts.spaceKey,
|
|
2808
2867
|
genesisFeedKey: opts.genesisFeedKey,
|
|
@@ -2830,10 +2889,10 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2830
2889
|
log10("construct space", {
|
|
2831
2890
|
metadata
|
|
2832
2891
|
}, {
|
|
2833
|
-
|
|
2834
|
-
|
|
2835
|
-
|
|
2836
|
-
|
|
2892
|
+
F: __dxlog_file10,
|
|
2893
|
+
L: 183,
|
|
2894
|
+
S: this,
|
|
2895
|
+
C: (f, a) => f(...a)
|
|
2837
2896
|
});
|
|
2838
2897
|
const gossip = new Gossip({
|
|
2839
2898
|
localPeerId: this._signingContext.deviceKey
|
|
@@ -2865,11 +2924,11 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2865
2924
|
session.addExtension("dxos.mesh.teleport.notarization", dataSpace.notarizationPlugin.createExtension());
|
|
2866
2925
|
},
|
|
2867
2926
|
onAuthFailure: () => {
|
|
2868
|
-
log10.warn("auth failure",
|
|
2869
|
-
|
|
2870
|
-
|
|
2871
|
-
|
|
2872
|
-
|
|
2927
|
+
log10.warn("auth failure", void 0, {
|
|
2928
|
+
F: __dxlog_file10,
|
|
2929
|
+
L: 214,
|
|
2930
|
+
S: this,
|
|
2931
|
+
C: (f, a) => f(...a)
|
|
2873
2932
|
});
|
|
2874
2933
|
},
|
|
2875
2934
|
memberKey: this._signingContext.identityKey
|
|
@@ -2878,6 +2937,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2878
2937
|
dataFeed && space.setDataFeed(dataFeed);
|
|
2879
2938
|
const dataSpace = new DataSpace({
|
|
2880
2939
|
inner: space,
|
|
2940
|
+
initialState: metadata.state === SpaceState2.INACTIVE ? SpaceState2.INACTIVE : SpaceState2.CLOSED,
|
|
2881
2941
|
metadataStore: this._metadataStore,
|
|
2882
2942
|
gossip,
|
|
2883
2943
|
presence,
|
|
@@ -2889,31 +2949,44 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2889
2949
|
log10("before space ready", {
|
|
2890
2950
|
space: space.key
|
|
2891
2951
|
}, {
|
|
2892
|
-
|
|
2893
|
-
|
|
2894
|
-
|
|
2895
|
-
|
|
2952
|
+
F: __dxlog_file10,
|
|
2953
|
+
L: 232,
|
|
2954
|
+
S: this,
|
|
2955
|
+
C: (f, a) => f(...a)
|
|
2896
2956
|
});
|
|
2897
|
-
this._dataServiceSubscriptions.registerSpace(space.key, dataSpace.dataPipeline.databaseHost.createDataServiceHost());
|
|
2957
|
+
await this._dataServiceSubscriptions.registerSpace(space.key, dataSpace.dataPipeline.databaseHost.createDataServiceHost());
|
|
2898
2958
|
},
|
|
2899
2959
|
afterReady: async () => {
|
|
2900
2960
|
log10("after space ready", {
|
|
2901
2961
|
space: space.key,
|
|
2902
2962
|
open: this._isOpen
|
|
2903
2963
|
}, {
|
|
2904
|
-
|
|
2905
|
-
|
|
2906
|
-
|
|
2907
|
-
|
|
2964
|
+
F: __dxlog_file10,
|
|
2965
|
+
L: 239,
|
|
2966
|
+
S: this,
|
|
2967
|
+
C: (f, a) => f(...a)
|
|
2908
2968
|
});
|
|
2909
2969
|
if (this._isOpen) {
|
|
2910
2970
|
this.updated.emit();
|
|
2911
2971
|
}
|
|
2972
|
+
},
|
|
2973
|
+
beforeClose: async () => {
|
|
2974
|
+
log10("before space close", {
|
|
2975
|
+
space: space.key
|
|
2976
|
+
}, {
|
|
2977
|
+
F: __dxlog_file10,
|
|
2978
|
+
L: 245,
|
|
2979
|
+
S: this,
|
|
2980
|
+
C: (f, a) => f(...a)
|
|
2981
|
+
});
|
|
2982
|
+
await this._dataServiceSubscriptions.unregisterSpace(space.key);
|
|
2912
2983
|
}
|
|
2913
2984
|
},
|
|
2914
2985
|
cache: metadata.cache
|
|
2915
2986
|
});
|
|
2916
|
-
|
|
2987
|
+
if (metadata.state !== SpaceState2.INACTIVE) {
|
|
2988
|
+
await dataSpace.open();
|
|
2989
|
+
}
|
|
2917
2990
|
if (metadata.controlTimeframe) {
|
|
2918
2991
|
dataSpace.inner.controlPipeline.state.setTargetTimeframe(metadata.controlTimeframe);
|
|
2919
2992
|
}
|
|
@@ -2924,32 +2997,33 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2924
2997
|
return dataSpace;
|
|
2925
2998
|
}
|
|
2926
2999
|
};
|
|
2927
|
-
|
|
2928
|
-
|
|
3000
|
+
_ts_decorate2([
|
|
3001
|
+
synchronized2
|
|
2929
3002
|
], DataSpaceManager.prototype, "open", null);
|
|
2930
|
-
|
|
2931
|
-
|
|
3003
|
+
_ts_decorate2([
|
|
3004
|
+
synchronized2
|
|
2932
3005
|
], DataSpaceManager.prototype, "close", null);
|
|
2933
|
-
|
|
2934
|
-
|
|
3006
|
+
_ts_decorate2([
|
|
3007
|
+
synchronized2
|
|
2935
3008
|
], DataSpaceManager.prototype, "createSpace", null);
|
|
2936
|
-
|
|
2937
|
-
|
|
3009
|
+
_ts_decorate2([
|
|
3010
|
+
synchronized2
|
|
2938
3011
|
], DataSpaceManager.prototype, "acceptSpace", null);
|
|
2939
|
-
DataSpaceManager =
|
|
3012
|
+
DataSpaceManager = _ts_decorate2([
|
|
2940
3013
|
trackLeaks2("open", "close")
|
|
2941
3014
|
], DataSpaceManager);
|
|
2942
3015
|
|
|
2943
3016
|
// packages/sdk/client-services/src/packlets/spaces/spaces-service.ts
|
|
2944
|
-
import { EventSubscriptions as EventSubscriptions2, scheduleTask as scheduleTask5 } from "@dxos/async";
|
|
3017
|
+
import { EventSubscriptions as EventSubscriptions2, UpdateScheduler, scheduleTask as scheduleTask5 } from "@dxos/async";
|
|
2945
3018
|
import { Stream as Stream9 } from "@dxos/codec-protobuf";
|
|
2946
|
-
import { raise
|
|
3019
|
+
import { raise } from "@dxos/debug";
|
|
2947
3020
|
import { SpaceNotFoundError } from "@dxos/echo-pipeline";
|
|
3021
|
+
import { ApiError } from "@dxos/errors";
|
|
2948
3022
|
import { log as log11 } from "@dxos/log";
|
|
2949
3023
|
import { encodeError } from "@dxos/protocols";
|
|
2950
|
-
import { SpaceMember as SpaceMember2 } from "@dxos/protocols/proto/dxos/client/services";
|
|
3024
|
+
import { SpaceMember as SpaceMember2, SpaceState as SpaceState3 } from "@dxos/protocols/proto/dxos/client/services";
|
|
2951
3025
|
import { humanize } from "@dxos/util";
|
|
2952
|
-
var
|
|
3026
|
+
var __dxlog_file11 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/spaces-service.ts";
|
|
2953
3027
|
var SpacesServiceImpl = class {
|
|
2954
3028
|
constructor(_identityManager, _spaceManager, _dataServiceSubscriptions, _getDataSpaceManager) {
|
|
2955
3029
|
this._identityManager = _identityManager;
|
|
@@ -2963,28 +3037,44 @@ var SpacesServiceImpl = class {
|
|
|
2963
3037
|
}
|
|
2964
3038
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
2965
3039
|
const space = await dataSpaceManager.createSpace();
|
|
2966
|
-
return this.
|
|
3040
|
+
return this._serializeSpace(space);
|
|
2967
3041
|
}
|
|
2968
|
-
async updateSpace(
|
|
2969
|
-
|
|
3042
|
+
async updateSpace({ spaceKey, state }) {
|
|
3043
|
+
var _a;
|
|
3044
|
+
const dataSpaceManager = await this._getDataSpaceManager();
|
|
3045
|
+
const space = (_a = dataSpaceManager.spaces.get(spaceKey)) != null ? _a : raise(new SpaceNotFoundError(spaceKey));
|
|
3046
|
+
if (state) {
|
|
3047
|
+
switch (state) {
|
|
3048
|
+
case SpaceState3.ACTIVE:
|
|
3049
|
+
await space.activate();
|
|
3050
|
+
break;
|
|
3051
|
+
case SpaceState3.INACTIVE:
|
|
3052
|
+
await space.deactivate();
|
|
3053
|
+
break;
|
|
3054
|
+
default:
|
|
3055
|
+
throw new ApiError("Invalid space state");
|
|
3056
|
+
}
|
|
3057
|
+
}
|
|
2970
3058
|
}
|
|
2971
3059
|
querySpaces() {
|
|
2972
3060
|
return new Stream9(({ next, ctx }) => {
|
|
2973
|
-
const
|
|
3061
|
+
const scheduler = new UpdateScheduler(ctx, async () => {
|
|
2974
3062
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
2975
|
-
const spaces = Array.from(dataSpaceManager.spaces.values()).map((space) => this.
|
|
3063
|
+
const spaces = Array.from(dataSpaceManager.spaces.values()).map((space) => this._serializeSpace(space));
|
|
2976
3064
|
log11("update", {
|
|
2977
3065
|
spaces
|
|
2978
3066
|
}, {
|
|
2979
|
-
|
|
2980
|
-
|
|
2981
|
-
|
|
2982
|
-
|
|
3067
|
+
F: __dxlog_file11,
|
|
3068
|
+
L: 78,
|
|
3069
|
+
S: this,
|
|
3070
|
+
C: (f, a) => f(...a)
|
|
2983
3071
|
});
|
|
2984
3072
|
next({
|
|
2985
3073
|
spaces
|
|
2986
3074
|
});
|
|
2987
|
-
}
|
|
3075
|
+
}, {
|
|
3076
|
+
maxFrequency: 2
|
|
3077
|
+
});
|
|
2988
3078
|
scheduleTask5(ctx, async () => {
|
|
2989
3079
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
2990
3080
|
const subscriptions = new EventSubscriptions2();
|
|
@@ -2992,21 +3082,21 @@ var SpacesServiceImpl = class {
|
|
|
2992
3082
|
const subscribeSpaces = () => {
|
|
2993
3083
|
subscriptions.clear();
|
|
2994
3084
|
for (const space of dataSpaceManager.spaces.values()) {
|
|
2995
|
-
subscriptions.add(space.stateUpdate.on(ctx,
|
|
2996
|
-
subscriptions.add(space.presence.updated.on(ctx,
|
|
2997
|
-
subscriptions.add(space.dataPipeline.onNewEpoch.on(ctx,
|
|
2998
|
-
space.inner.controlPipeline.state.timeframeUpdate.
|
|
3085
|
+
subscriptions.add(space.stateUpdate.on(ctx, () => scheduler.trigger()));
|
|
3086
|
+
subscriptions.add(space.presence.updated.on(ctx, () => scheduler.trigger()));
|
|
3087
|
+
subscriptions.add(space.dataPipeline.onNewEpoch.on(ctx, () => scheduler.trigger()));
|
|
3088
|
+
space.inner.controlPipeline.state.timeframeUpdate.on(ctx, () => scheduler.trigger());
|
|
2999
3089
|
if (space.dataPipeline.pipelineState) {
|
|
3000
|
-
subscriptions.add(space.dataPipeline.pipelineState.timeframeUpdate.
|
|
3090
|
+
subscriptions.add(space.dataPipeline.pipelineState.timeframeUpdate.on(ctx, () => scheduler.trigger()));
|
|
3001
3091
|
}
|
|
3002
3092
|
}
|
|
3003
3093
|
};
|
|
3004
3094
|
dataSpaceManager.updated.on(ctx, () => {
|
|
3005
3095
|
subscribeSpaces();
|
|
3006
|
-
|
|
3096
|
+
scheduler.trigger();
|
|
3007
3097
|
});
|
|
3008
3098
|
subscribeSpaces();
|
|
3009
|
-
|
|
3099
|
+
scheduler.trigger();
|
|
3010
3100
|
});
|
|
3011
3101
|
if (!this._identityManager.identity) {
|
|
3012
3102
|
next({
|
|
@@ -3038,13 +3128,13 @@ var SpacesServiceImpl = class {
|
|
|
3038
3128
|
return new Stream9(({ ctx, next }) => {
|
|
3039
3129
|
var _a;
|
|
3040
3130
|
const space = (_a = this._spaceManager.spaces.get(spaceKey)) != null ? _a : raise(new SpaceNotFoundError(spaceKey));
|
|
3041
|
-
const processor =
|
|
3042
|
-
|
|
3131
|
+
const processor = {
|
|
3132
|
+
processCredential: async (credential) => {
|
|
3043
3133
|
next(credential);
|
|
3044
3134
|
}
|
|
3045
|
-
}
|
|
3046
|
-
ctx.onDispose(() =>
|
|
3047
|
-
scheduleTask5(ctx, () =>
|
|
3135
|
+
};
|
|
3136
|
+
ctx.onDispose(() => space.spaceState.removeCredentialProcessor(processor));
|
|
3137
|
+
scheduleTask5(ctx, () => space.spaceState.addCredentialProcessor(processor));
|
|
3048
3138
|
});
|
|
3049
3139
|
}
|
|
3050
3140
|
async writeCredentials({ spaceKey, credentials }) {
|
|
@@ -3064,7 +3154,7 @@ var SpacesServiceImpl = class {
|
|
|
3064
3154
|
const space = (_a = dataSpaceManager.spaces.get(spaceKey)) != null ? _a : raise(new SpaceNotFoundError(spaceKey));
|
|
3065
3155
|
await space.createEpoch();
|
|
3066
3156
|
}
|
|
3067
|
-
|
|
3157
|
+
_serializeSpace(space) {
|
|
3068
3158
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
3069
3159
|
return {
|
|
3070
3160
|
spaceKey: space.key,
|
|
@@ -3104,7 +3194,7 @@ var SpacesServiceImpl = class {
|
|
|
3104
3194
|
var getChannelId = (channel) => `user-channel/${channel}`;
|
|
3105
3195
|
|
|
3106
3196
|
// packages/sdk/client-services/src/packlets/services/service-context.ts
|
|
3107
|
-
import
|
|
3197
|
+
import invariant11 from "tiny-invariant";
|
|
3108
3198
|
import { Trigger as Trigger5 } from "@dxos/async";
|
|
3109
3199
|
import { getCredentialAssertion as getCredentialAssertion3 } from "@dxos/credentials";
|
|
3110
3200
|
import { failUndefined as failUndefined3 } from "@dxos/debug";
|
|
@@ -3116,6 +3206,7 @@ import { log as log12 } from "@dxos/log";
|
|
|
3116
3206
|
import { STORAGE_VERSION, trace as trace5 } from "@dxos/protocols";
|
|
3117
3207
|
import { Invitation as Invitation5 } from "@dxos/protocols/proto/dxos/client/services";
|
|
3118
3208
|
import { BlobStore } from "@dxos/teleport-extension-object-sync";
|
|
3209
|
+
var __dxlog_file12 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-context.ts";
|
|
3119
3210
|
var ServiceContext = class {
|
|
3120
3211
|
// prettier-ignore
|
|
3121
3212
|
constructor(storage, networkManager, signalManager, modelFactory) {
|
|
@@ -3159,17 +3250,17 @@ var ServiceContext = class {
|
|
|
3159
3250
|
log12.trace("dxos.sdk.service-context.open", trace5.begin({
|
|
3160
3251
|
id: this._instanceId
|
|
3161
3252
|
}), {
|
|
3162
|
-
|
|
3163
|
-
|
|
3164
|
-
|
|
3165
|
-
|
|
3253
|
+
F: __dxlog_file12,
|
|
3254
|
+
L: 126,
|
|
3255
|
+
S: this,
|
|
3256
|
+
C: (f, a) => f(...a)
|
|
3166
3257
|
});
|
|
3167
3258
|
await this._checkStorageVersion();
|
|
3168
|
-
log12("opening...",
|
|
3169
|
-
|
|
3170
|
-
|
|
3171
|
-
|
|
3172
|
-
|
|
3259
|
+
log12("opening...", void 0, {
|
|
3260
|
+
F: __dxlog_file12,
|
|
3261
|
+
L: 130,
|
|
3262
|
+
S: this,
|
|
3263
|
+
C: (f, a) => f(...a)
|
|
3173
3264
|
});
|
|
3174
3265
|
await this.signalManager.open();
|
|
3175
3266
|
await this.networkManager.open();
|
|
@@ -3178,42 +3269,44 @@ var ServiceContext = class {
|
|
|
3178
3269
|
if (this.identityManager.identity) {
|
|
3179
3270
|
await this._initialize();
|
|
3180
3271
|
}
|
|
3181
|
-
log12("opened",
|
|
3182
|
-
|
|
3183
|
-
|
|
3184
|
-
|
|
3185
|
-
|
|
3272
|
+
log12("opened", void 0, {
|
|
3273
|
+
F: __dxlog_file12,
|
|
3274
|
+
L: 138,
|
|
3275
|
+
S: this,
|
|
3276
|
+
C: (f, a) => f(...a)
|
|
3186
3277
|
});
|
|
3187
3278
|
log12.trace("dxos.sdk.service-context.open", trace5.end({
|
|
3188
3279
|
id: this._instanceId
|
|
3189
3280
|
}), {
|
|
3190
|
-
|
|
3191
|
-
|
|
3192
|
-
|
|
3193
|
-
|
|
3281
|
+
F: __dxlog_file12,
|
|
3282
|
+
L: 139,
|
|
3283
|
+
S: this,
|
|
3284
|
+
C: (f, a) => f(...a)
|
|
3194
3285
|
});
|
|
3195
3286
|
}
|
|
3196
3287
|
async close() {
|
|
3197
|
-
var _a
|
|
3198
|
-
log12("closing...",
|
|
3199
|
-
|
|
3200
|
-
|
|
3201
|
-
|
|
3202
|
-
|
|
3203
|
-
});
|
|
3204
|
-
|
|
3205
|
-
|
|
3288
|
+
var _a;
|
|
3289
|
+
log12("closing...", void 0, {
|
|
3290
|
+
F: __dxlog_file12,
|
|
3291
|
+
L: 143,
|
|
3292
|
+
S: this,
|
|
3293
|
+
C: (f, a) => f(...a)
|
|
3294
|
+
});
|
|
3295
|
+
if (this._deviceSpaceSync && this.identityManager.identity) {
|
|
3296
|
+
await this.identityManager.identity.space.spaceState.removeCredentialProcessor(this._deviceSpaceSync);
|
|
3297
|
+
}
|
|
3298
|
+
await ((_a = this.dataSpaceManager) == null ? void 0 : _a.close());
|
|
3206
3299
|
await this.identityManager.close();
|
|
3207
3300
|
await this.spaceManager.close();
|
|
3208
3301
|
await this.feedStore.close();
|
|
3209
3302
|
await this.networkManager.close();
|
|
3210
3303
|
await this.signalManager.close();
|
|
3211
3304
|
this.dataServiceSubscriptions.clear();
|
|
3212
|
-
log12("closed",
|
|
3213
|
-
|
|
3214
|
-
|
|
3215
|
-
|
|
3216
|
-
|
|
3305
|
+
log12("closed", void 0, {
|
|
3306
|
+
F: __dxlog_file12,
|
|
3307
|
+
L: 154,
|
|
3308
|
+
S: this,
|
|
3309
|
+
C: (f, a) => f(...a)
|
|
3217
3310
|
});
|
|
3218
3311
|
}
|
|
3219
3312
|
async createIdentity(params = {}) {
|
|
@@ -3223,7 +3316,7 @@ var ServiceContext = class {
|
|
|
3223
3316
|
}
|
|
3224
3317
|
getInvitationHandler(invitation) {
|
|
3225
3318
|
const factory = this._handlerFactories.get(invitation.kind);
|
|
3226
|
-
|
|
3319
|
+
invariant11(factory, `Unknown invitation kind: ${invitation.kind}`);
|
|
3227
3320
|
return factory(invitation);
|
|
3228
3321
|
}
|
|
3229
3322
|
async _acceptIdentity(params) {
|
|
@@ -3240,11 +3333,11 @@ var ServiceContext = class {
|
|
|
3240
3333
|
// Called when identity is created.
|
|
3241
3334
|
async _initialize() {
|
|
3242
3335
|
var _a;
|
|
3243
|
-
log12("initializing spaces...",
|
|
3244
|
-
|
|
3245
|
-
|
|
3246
|
-
|
|
3247
|
-
|
|
3336
|
+
log12("initializing spaces...", void 0, {
|
|
3337
|
+
F: __dxlog_file12,
|
|
3338
|
+
L: 187,
|
|
3339
|
+
S: this,
|
|
3340
|
+
C: (f, a) => f(...a)
|
|
3248
3341
|
});
|
|
3249
3342
|
const identity = (_a = this.identityManager.identity) != null ? _a : failUndefined3();
|
|
3250
3343
|
const signingContext = {
|
|
@@ -3263,12 +3356,12 @@ var ServiceContext = class {
|
|
|
3263
3356
|
this.dataSpaceManager = new DataSpaceManager(this.spaceManager, this.metadataStore, this.dataServiceSubscriptions, this.keyring, signingContext, this.feedStore);
|
|
3264
3357
|
await this.dataSpaceManager.open();
|
|
3265
3358
|
this._handlerFactories.set(Invitation5.Kind.SPACE, (invitation) => {
|
|
3266
|
-
|
|
3359
|
+
invariant11(this.dataSpaceManager, "dataSpaceManager not initialized yet");
|
|
3267
3360
|
return new SpaceInvitationProtocol(this.dataSpaceManager, signingContext, this.keyring, invitation.spaceKey);
|
|
3268
3361
|
});
|
|
3269
3362
|
this.initialized.wake();
|
|
3270
|
-
this._deviceSpaceSync =
|
|
3271
|
-
|
|
3363
|
+
this._deviceSpaceSync = {
|
|
3364
|
+
processCredential: async (credential) => {
|
|
3272
3365
|
const assertion = getCredentialAssertion3(credential);
|
|
3273
3366
|
if (assertion["@type"] !== "dxos.halo.credentials.SpaceMember") {
|
|
3274
3367
|
return;
|
|
@@ -3280,10 +3373,10 @@ var ServiceContext = class {
|
|
|
3280
3373
|
log12("dataSpaceManager not initialized yet, ignoring space admission", {
|
|
3281
3374
|
details: assertion
|
|
3282
3375
|
}, {
|
|
3283
|
-
|
|
3284
|
-
|
|
3285
|
-
|
|
3286
|
-
|
|
3376
|
+
F: __dxlog_file12,
|
|
3377
|
+
L: 226,
|
|
3378
|
+
S: this,
|
|
3379
|
+
C: (f, a) => f(...a)
|
|
3287
3380
|
});
|
|
3288
3381
|
return;
|
|
3289
3382
|
}
|
|
@@ -3291,10 +3384,10 @@ var ServiceContext = class {
|
|
|
3291
3384
|
log12("space already exists, ignoring space admission", {
|
|
3292
3385
|
details: assertion
|
|
3293
3386
|
}, {
|
|
3294
|
-
|
|
3295
|
-
|
|
3296
|
-
|
|
3297
|
-
|
|
3387
|
+
F: __dxlog_file12,
|
|
3388
|
+
L: 230,
|
|
3389
|
+
S: this,
|
|
3390
|
+
C: (f, a) => f(...a)
|
|
3298
3391
|
});
|
|
3299
3392
|
return;
|
|
3300
3393
|
}
|
|
@@ -3302,26 +3395,26 @@ var ServiceContext = class {
|
|
|
3302
3395
|
log12("accepting space recorded in halo", {
|
|
3303
3396
|
details: assertion
|
|
3304
3397
|
}, {
|
|
3305
|
-
|
|
3306
|
-
|
|
3307
|
-
|
|
3308
|
-
|
|
3398
|
+
F: __dxlog_file12,
|
|
3399
|
+
L: 235,
|
|
3400
|
+
S: this,
|
|
3401
|
+
C: (f, a) => f(...a)
|
|
3309
3402
|
});
|
|
3310
3403
|
await this.dataSpaceManager.acceptSpace({
|
|
3311
3404
|
spaceKey: assertion.spaceKey,
|
|
3312
3405
|
genesisFeedKey: assertion.genesisFeedKey
|
|
3313
3406
|
});
|
|
3314
3407
|
} catch (err) {
|
|
3315
|
-
log12.catch(err,
|
|
3316
|
-
|
|
3317
|
-
|
|
3318
|
-
|
|
3319
|
-
|
|
3408
|
+
log12.catch(err, void 0, {
|
|
3409
|
+
F: __dxlog_file12,
|
|
3410
|
+
L: 241,
|
|
3411
|
+
S: this,
|
|
3412
|
+
C: (f, a) => f(...a)
|
|
3320
3413
|
});
|
|
3321
3414
|
}
|
|
3322
3415
|
}
|
|
3323
|
-
}
|
|
3324
|
-
await this._deviceSpaceSync
|
|
3416
|
+
};
|
|
3417
|
+
await identity.space.spaceState.addCredentialProcessor(this._deviceSpaceSync);
|
|
3325
3418
|
}
|
|
3326
3419
|
};
|
|
3327
3420
|
|
|
@@ -3329,7 +3422,7 @@ var ServiceContext = class {
|
|
|
3329
3422
|
import { asyncTimeout, Trigger as Trigger6 } from "@dxos/async";
|
|
3330
3423
|
import { RESOURCE_LOCK_TIMEOUT } from "@dxos/client-protocol";
|
|
3331
3424
|
import { log as log13, logInfo } from "@dxos/log";
|
|
3332
|
-
|
|
3425
|
+
function _ts_decorate3(decorators, target, key, desc) {
|
|
3333
3426
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3334
3427
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
3335
3428
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -3338,7 +3431,8 @@ var __decorate3 = function(decorators, target, key, desc) {
|
|
|
3338
3431
|
if (d = decorators[i])
|
|
3339
3432
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
3340
3433
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3341
|
-
}
|
|
3434
|
+
}
|
|
3435
|
+
var __dxlog_file13 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/locks/browser.ts";
|
|
3342
3436
|
var Message;
|
|
3343
3437
|
(function(Message2) {
|
|
3344
3438
|
Message2["ACQUIRING"] = "acquiring";
|
|
@@ -3360,32 +3454,32 @@ var Lock = class {
|
|
|
3360
3454
|
message: Message.ACQUIRING
|
|
3361
3455
|
});
|
|
3362
3456
|
try {
|
|
3363
|
-
log13("aquiring lock...",
|
|
3364
|
-
|
|
3365
|
-
|
|
3366
|
-
|
|
3367
|
-
|
|
3457
|
+
log13("aquiring lock...", void 0, {
|
|
3458
|
+
F: __dxlog_file13,
|
|
3459
|
+
L: 42,
|
|
3460
|
+
S: this,
|
|
3461
|
+
C: (f, a) => f(...a)
|
|
3368
3462
|
});
|
|
3369
3463
|
await asyncTimeout(this._requestLock(), RESOURCE_LOCK_TIMEOUT);
|
|
3370
|
-
log13("acquired lock",
|
|
3371
|
-
|
|
3372
|
-
|
|
3373
|
-
|
|
3374
|
-
|
|
3464
|
+
log13("acquired lock", void 0, {
|
|
3465
|
+
F: __dxlog_file13,
|
|
3466
|
+
L: 44,
|
|
3467
|
+
S: this,
|
|
3468
|
+
C: (f, a) => f(...a)
|
|
3375
3469
|
});
|
|
3376
3470
|
} catch (e) {
|
|
3377
|
-
log13("stealing lock...",
|
|
3378
|
-
|
|
3379
|
-
|
|
3380
|
-
|
|
3381
|
-
|
|
3471
|
+
log13("stealing lock...", void 0, {
|
|
3472
|
+
F: __dxlog_file13,
|
|
3473
|
+
L: 46,
|
|
3474
|
+
S: this,
|
|
3475
|
+
C: (f, a) => f(...a)
|
|
3382
3476
|
});
|
|
3383
3477
|
await this._requestLock(true);
|
|
3384
|
-
log13("stolen lock",
|
|
3385
|
-
|
|
3386
|
-
|
|
3387
|
-
|
|
3388
|
-
|
|
3478
|
+
log13("stolen lock", void 0, {
|
|
3479
|
+
F: __dxlog_file13,
|
|
3480
|
+
L: 48,
|
|
3481
|
+
S: this,
|
|
3482
|
+
C: (f, a) => f(...a)
|
|
3389
3483
|
});
|
|
3390
3484
|
}
|
|
3391
3485
|
}
|
|
@@ -3401,10 +3495,10 @@ var Lock = class {
|
|
|
3401
3495
|
log13("requesting lock...", {
|
|
3402
3496
|
steal
|
|
3403
3497
|
}, {
|
|
3404
|
-
|
|
3405
|
-
|
|
3406
|
-
|
|
3407
|
-
|
|
3498
|
+
F: __dxlog_file13,
|
|
3499
|
+
L: 63,
|
|
3500
|
+
S: this,
|
|
3501
|
+
C: (f, a) => f(...a)
|
|
3408
3502
|
});
|
|
3409
3503
|
const acquired = new Trigger6();
|
|
3410
3504
|
void navigator.locks.request(this._lockKey, {
|
|
@@ -3415,18 +3509,18 @@ var Lock = class {
|
|
|
3415
3509
|
acquired.wake();
|
|
3416
3510
|
this._releaseTrigger = new Trigger6();
|
|
3417
3511
|
await this._releaseTrigger.wait();
|
|
3418
|
-
log13("releasing lock...",
|
|
3419
|
-
|
|
3420
|
-
|
|
3421
|
-
|
|
3422
|
-
|
|
3512
|
+
log13("releasing lock...", void 0, {
|
|
3513
|
+
F: __dxlog_file13,
|
|
3514
|
+
L: 72,
|
|
3515
|
+
S: this,
|
|
3516
|
+
C: (f, a) => f(...a)
|
|
3423
3517
|
});
|
|
3424
3518
|
await ((_b = this._onRelease) == null ? void 0 : _b.call(this));
|
|
3425
|
-
log13("released lock",
|
|
3426
|
-
|
|
3427
|
-
|
|
3428
|
-
|
|
3429
|
-
|
|
3519
|
+
log13("released lock", void 0, {
|
|
3520
|
+
F: __dxlog_file13,
|
|
3521
|
+
L: 74,
|
|
3522
|
+
S: this,
|
|
3523
|
+
C: (f, a) => f(...a)
|
|
3430
3524
|
});
|
|
3431
3525
|
}).catch(async () => {
|
|
3432
3526
|
var _a;
|
|
@@ -3436,14 +3530,14 @@ var Lock = class {
|
|
|
3436
3530
|
log13("recieved lock", {
|
|
3437
3531
|
steal
|
|
3438
3532
|
}, {
|
|
3439
|
-
|
|
3440
|
-
|
|
3441
|
-
|
|
3442
|
-
|
|
3533
|
+
F: __dxlog_file13,
|
|
3534
|
+
L: 81,
|
|
3535
|
+
S: this,
|
|
3536
|
+
C: (f, a) => f(...a)
|
|
3443
3537
|
});
|
|
3444
3538
|
}
|
|
3445
3539
|
};
|
|
3446
|
-
|
|
3540
|
+
_ts_decorate3([
|
|
3447
3541
|
logInfo
|
|
3448
3542
|
], Lock.prototype, "lockKey", null);
|
|
3449
3543
|
var isLocked = (lockPath) => {
|
|
@@ -3524,16 +3618,19 @@ var ServiceRegistry = class {
|
|
|
3524
3618
|
};
|
|
3525
3619
|
|
|
3526
3620
|
// packages/sdk/client-services/src/packlets/services/service-host.ts
|
|
3527
|
-
import
|
|
3528
|
-
import { Event as Event8, synchronized as
|
|
3529
|
-
import { clientServiceBundle
|
|
3621
|
+
import invariant12 from "tiny-invariant";
|
|
3622
|
+
import { Event as Event8, synchronized as synchronized3 } from "@dxos/async";
|
|
3623
|
+
import { clientServiceBundle } from "@dxos/client-protocol";
|
|
3624
|
+
import { DocumentModel } from "@dxos/document-model";
|
|
3530
3625
|
import { DataServiceImpl } from "@dxos/echo-pipeline";
|
|
3531
3626
|
import { PublicKey as PublicKey10 } from "@dxos/keys";
|
|
3532
3627
|
import { log as log15 } from "@dxos/log";
|
|
3533
3628
|
import { WebsocketSignalManager } from "@dxos/messaging";
|
|
3629
|
+
import { ModelFactory } from "@dxos/model-factory";
|
|
3534
3630
|
import { createWebRTCTransportFactory, NetworkManager } from "@dxos/network-manager";
|
|
3535
3631
|
import { trace as trace6 } from "@dxos/protocols";
|
|
3536
3632
|
import { SystemStatus } from "@dxos/protocols/proto/dxos/client/services";
|
|
3633
|
+
import { TextModel } from "@dxos/text-model";
|
|
3537
3634
|
|
|
3538
3635
|
// packages/sdk/client-services/src/packlets/devices/devices-service.ts
|
|
3539
3636
|
import { EventSubscriptions as EventSubscriptions3 } from "@dxos/async";
|
|
@@ -3609,7 +3706,7 @@ var LoggingServiceImpl = class {
|
|
|
3609
3706
|
if (LOG_PROCESSING > 0) {
|
|
3610
3707
|
return;
|
|
3611
3708
|
}
|
|
3612
|
-
if (((_a = entry2.meta) == null ? void 0 : _a.
|
|
3709
|
+
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"))) {
|
|
3613
3710
|
return;
|
|
3614
3711
|
}
|
|
3615
3712
|
if (!shouldLog(entry2, request)) {
|
|
@@ -3621,8 +3718,8 @@ var LoggingServiceImpl = class {
|
|
|
3621
3718
|
timestamp: new Date(),
|
|
3622
3719
|
meta: {
|
|
3623
3720
|
// TODO(dmaretskyi): Fix proto.
|
|
3624
|
-
file: (_c = (_b = entry2.meta) == null ? void 0 : _b.
|
|
3625
|
-
line: (_e = (_d = entry2.meta) == null ? void 0 : _d.
|
|
3721
|
+
file: (_c = (_b = entry2.meta) == null ? void 0 : _b.F) != null ? _c : "",
|
|
3722
|
+
line: (_e = (_d = entry2.meta) == null ? void 0 : _d.L) != null ? _e : 0
|
|
3626
3723
|
}
|
|
3627
3724
|
};
|
|
3628
3725
|
try {
|
|
@@ -3652,7 +3749,7 @@ var shouldLog = (entry2, request) => {
|
|
|
3652
3749
|
} else {
|
|
3653
3750
|
return request.filters.some((filter) => {
|
|
3654
3751
|
var _a2, _b;
|
|
3655
|
-
return matchFilter(filter, entry2.level, (_b = (_a2 = entry2.meta) == null ? void 0 : _a2.
|
|
3752
|
+
return matchFilter(filter, entry2.level, (_b = (_a2 = entry2.meta) == null ? void 0 : _a2.F) != null ? _b : "", options);
|
|
3656
3753
|
});
|
|
3657
3754
|
}
|
|
3658
3755
|
};
|
|
@@ -3729,7 +3826,7 @@ var SystemServiceImpl = class {
|
|
|
3729
3826
|
};
|
|
3730
3827
|
|
|
3731
3828
|
// packages/sdk/client-services/src/packlets/services/service-host.ts
|
|
3732
|
-
|
|
3829
|
+
function _ts_decorate4(decorators, target, key, desc) {
|
|
3733
3830
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3734
3831
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
3735
3832
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -3738,6 +3835,10 @@ var __decorate4 = function(decorators, target, key, desc) {
|
|
|
3738
3835
|
if (d = decorators[i])
|
|
3739
3836
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
3740
3837
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3838
|
+
}
|
|
3839
|
+
var __dxlog_file14 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-host.ts";
|
|
3840
|
+
var createDefaultModelFactory = () => {
|
|
3841
|
+
return new ModelFactory().registerModel(DocumentModel).registerModel(TextModel);
|
|
3741
3842
|
};
|
|
3742
3843
|
var ClientServicesHost = class {
|
|
3743
3844
|
constructor({
|
|
@@ -3749,13 +3850,15 @@ var ClientServicesHost = class {
|
|
|
3749
3850
|
connectionLog,
|
|
3750
3851
|
storage,
|
|
3751
3852
|
// TODO(wittjosiah): Turn this on by default.
|
|
3752
|
-
lockKey
|
|
3853
|
+
lockKey,
|
|
3854
|
+
callbacks
|
|
3753
3855
|
} = {}) {
|
|
3754
3856
|
this._statusUpdate = new Event8();
|
|
3755
3857
|
this._opening = false;
|
|
3756
3858
|
this._open = false;
|
|
3757
3859
|
this._storage = storage;
|
|
3758
3860
|
this._modelFactory = modelFactory;
|
|
3861
|
+
this._callbacks = callbacks;
|
|
3759
3862
|
if (config) {
|
|
3760
3863
|
this.initialize({
|
|
3761
3864
|
config,
|
|
@@ -3814,9 +3917,9 @@ var ClientServicesHost = class {
|
|
|
3814
3917
|
*/
|
|
3815
3918
|
initialize({ config, ...options }) {
|
|
3816
3919
|
var _a, _b, _c;
|
|
3817
|
-
|
|
3920
|
+
invariant12(!this._open, "service host is open");
|
|
3818
3921
|
if (config) {
|
|
3819
|
-
|
|
3922
|
+
invariant12(!this._config, "config already set");
|
|
3820
3923
|
this._config = config;
|
|
3821
3924
|
if (!this._storage) {
|
|
3822
3925
|
this._storage = createStorageObjects(config.get("runtime.client.storage", {})).storage;
|
|
@@ -3826,7 +3929,7 @@ var ClientServicesHost = class {
|
|
|
3826
3929
|
iceServers: (_a = this._config) == null ? void 0 : _a.get("runtime.services.ice")
|
|
3827
3930
|
}), signalManager = new WebsocketSignalManager((_c = (_b = this._config) == null ? void 0 : _b.get("runtime.services.signaling")) != null ? _c : []) } = options;
|
|
3828
3931
|
this._signalManager = signalManager;
|
|
3829
|
-
|
|
3932
|
+
invariant12(!this._networkManager, "network manager already set");
|
|
3830
3933
|
this._networkManager = new NetworkManager({
|
|
3831
3934
|
log: connectionLog,
|
|
3832
3935
|
transportFactory,
|
|
@@ -3842,23 +3945,23 @@ var ClientServicesHost = class {
|
|
|
3842
3945
|
log15.trace("dxos.sdk.client-services-host.open", trace6.begin({
|
|
3843
3946
|
id: traceId
|
|
3844
3947
|
}), {
|
|
3845
|
-
|
|
3846
|
-
|
|
3847
|
-
|
|
3848
|
-
|
|
3849
|
-
});
|
|
3850
|
-
|
|
3851
|
-
|
|
3852
|
-
|
|
3853
|
-
|
|
3948
|
+
F: __dxlog_file14,
|
|
3949
|
+
L: 203,
|
|
3950
|
+
S: this,
|
|
3951
|
+
C: (f, a) => f(...a)
|
|
3952
|
+
});
|
|
3953
|
+
invariant12(this._config, "config not set");
|
|
3954
|
+
invariant12(this._storage, "storage not set");
|
|
3955
|
+
invariant12(this._signalManager, "signal manager not set");
|
|
3956
|
+
invariant12(this._networkManager, "network manager not set");
|
|
3854
3957
|
this._opening = true;
|
|
3855
3958
|
log15("opening...", {
|
|
3856
3959
|
lockKey: (_a = this._resourceLock) == null ? void 0 : _a.lockKey
|
|
3857
3960
|
}, {
|
|
3858
|
-
|
|
3859
|
-
|
|
3860
|
-
|
|
3861
|
-
|
|
3961
|
+
F: __dxlog_file14,
|
|
3962
|
+
L: 211,
|
|
3963
|
+
S: this,
|
|
3964
|
+
C: (f, a) => f(...a)
|
|
3862
3965
|
});
|
|
3863
3966
|
await ((_b = this._resourceLock) == null ? void 0 : _b.acquire());
|
|
3864
3967
|
await this._loggingService.open();
|
|
@@ -3890,18 +3993,18 @@ var ClientServicesHost = class {
|
|
|
3890
3993
|
log15("opened", {
|
|
3891
3994
|
deviceKey
|
|
3892
3995
|
}, {
|
|
3893
|
-
|
|
3894
|
-
|
|
3895
|
-
|
|
3896
|
-
|
|
3996
|
+
F: __dxlog_file14,
|
|
3997
|
+
L: 266,
|
|
3998
|
+
S: this,
|
|
3999
|
+
C: (f, a) => f(...a)
|
|
3897
4000
|
});
|
|
3898
4001
|
log15.trace("dxos.sdk.client-services-host.open", trace6.end({
|
|
3899
4002
|
id: traceId
|
|
3900
4003
|
}), {
|
|
3901
|
-
|
|
3902
|
-
|
|
3903
|
-
|
|
3904
|
-
|
|
4004
|
+
F: __dxlog_file14,
|
|
4005
|
+
L: 267,
|
|
4006
|
+
S: this,
|
|
4007
|
+
C: (f, a) => f(...a)
|
|
3905
4008
|
});
|
|
3906
4009
|
}
|
|
3907
4010
|
async close() {
|
|
@@ -3913,10 +4016,10 @@ var ClientServicesHost = class {
|
|
|
3913
4016
|
log15("closing...", {
|
|
3914
4017
|
deviceKey
|
|
3915
4018
|
}, {
|
|
3916
|
-
|
|
3917
|
-
|
|
3918
|
-
|
|
3919
|
-
|
|
4019
|
+
F: __dxlog_file14,
|
|
4020
|
+
L: 277,
|
|
4021
|
+
S: this,
|
|
4022
|
+
C: (f, a) => f(...a)
|
|
3920
4023
|
});
|
|
3921
4024
|
this._serviceRegistry.setServices({
|
|
3922
4025
|
SystemService: this._systemService
|
|
@@ -3928,52 +4031,53 @@ var ClientServicesHost = class {
|
|
|
3928
4031
|
log15("closed", {
|
|
3929
4032
|
deviceKey
|
|
3930
4033
|
}, {
|
|
3931
|
-
|
|
3932
|
-
|
|
3933
|
-
|
|
3934
|
-
|
|
4034
|
+
F: __dxlog_file14,
|
|
4035
|
+
L: 283,
|
|
4036
|
+
S: this,
|
|
4037
|
+
C: (f, a) => f(...a)
|
|
3935
4038
|
});
|
|
3936
4039
|
}
|
|
3937
4040
|
async reset() {
|
|
3938
|
-
var _a;
|
|
4041
|
+
var _a, _b, _c;
|
|
3939
4042
|
const traceId = PublicKey10.random().toHex();
|
|
3940
4043
|
log15.trace("dxos.sdk.client-services-host.reset", trace6.begin({
|
|
3941
4044
|
id: traceId
|
|
3942
4045
|
}), {
|
|
3943
|
-
|
|
3944
|
-
|
|
3945
|
-
|
|
3946
|
-
|
|
4046
|
+
F: __dxlog_file14,
|
|
4047
|
+
L: 288,
|
|
4048
|
+
S: this,
|
|
4049
|
+
C: (f, a) => f(...a)
|
|
3947
4050
|
});
|
|
3948
|
-
log15("resetting...",
|
|
3949
|
-
|
|
3950
|
-
|
|
3951
|
-
|
|
3952
|
-
|
|
4051
|
+
log15("resetting...", void 0, {
|
|
4052
|
+
F: __dxlog_file14,
|
|
4053
|
+
L: 290,
|
|
4054
|
+
S: this,
|
|
4055
|
+
C: (f, a) => f(...a)
|
|
3953
4056
|
});
|
|
3954
4057
|
await ((_a = this._serviceContext) == null ? void 0 : _a.close());
|
|
3955
4058
|
await this._storage.reset();
|
|
3956
|
-
log15("reset",
|
|
3957
|
-
|
|
3958
|
-
|
|
3959
|
-
|
|
3960
|
-
|
|
4059
|
+
log15("reset", void 0, {
|
|
4060
|
+
F: __dxlog_file14,
|
|
4061
|
+
L: 293,
|
|
4062
|
+
S: this,
|
|
4063
|
+
C: (f, a) => f(...a)
|
|
3961
4064
|
});
|
|
3962
4065
|
log15.trace("dxos.sdk.client-services-host.reset", trace6.end({
|
|
3963
4066
|
id: traceId
|
|
3964
4067
|
}), {
|
|
3965
|
-
|
|
3966
|
-
|
|
3967
|
-
|
|
3968
|
-
|
|
4068
|
+
F: __dxlog_file14,
|
|
4069
|
+
L: 294,
|
|
4070
|
+
S: this,
|
|
4071
|
+
C: (f, a) => f(...a)
|
|
3969
4072
|
});
|
|
4073
|
+
await ((_c = (_b = this._callbacks) == null ? void 0 : _b.onReset) == null ? void 0 : _c.call(_b));
|
|
3970
4074
|
}
|
|
3971
4075
|
};
|
|
3972
|
-
|
|
3973
|
-
|
|
4076
|
+
_ts_decorate4([
|
|
4077
|
+
synchronized3
|
|
3974
4078
|
], ClientServicesHost.prototype, "open", null);
|
|
3975
|
-
|
|
3976
|
-
|
|
4079
|
+
_ts_decorate4([
|
|
4080
|
+
synchronized3
|
|
3977
4081
|
], ClientServicesHost.prototype, "close", null);
|
|
3978
4082
|
|
|
3979
4083
|
export {
|
|
@@ -4004,6 +4108,7 @@ export {
|
|
|
4004
4108
|
isLocked,
|
|
4005
4109
|
createStorageObjects,
|
|
4006
4110
|
ServiceRegistry,
|
|
4111
|
+
createDefaultModelFactory,
|
|
4007
4112
|
ClientServicesHost
|
|
4008
4113
|
};
|
|
4009
|
-
//# sourceMappingURL=chunk-
|
|
4114
|
+
//# sourceMappingURL=chunk-EYXOVYW5.mjs.map
|