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