@dxos/client-services 0.1.53-next.db41187 → 0.1.53-next.e9dc2bc
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/browser/{chunk-6ITWCQIT.mjs → chunk-3EI4PM2V.mjs} +790 -685
- package/dist/lib/browser/chunk-3EI4PM2V.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +101 -120
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/packlets/testing/index.mjs +24 -7
- package/dist/lib/browser/packlets/testing/index.mjs.map +3 -3
- package/dist/lib/node/index.cjs +856 -772
- package/dist/lib/node/index.cjs.map +3 -3
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/packlets/testing/index.cjs +773 -654
- package/dist/lib/node/packlets/testing/index.cjs.map +3 -3
- package/dist/types/src/packlets/identity/authenticator.d.ts.map +1 -1
- package/dist/types/src/packlets/identity/identity.d.ts.map +1 -1
- package/dist/types/src/packlets/services/service-context.d.ts.map +1 -1
- package/dist/types/src/packlets/services/service-host.d.ts +7 -1
- package/dist/types/src/packlets/services/service-host.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/data-space-manager.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/data-space.d.ts +11 -2
- package/dist/types/src/packlets/spaces/data-space.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/notarization-plugin.d.ts +2 -1
- package/dist/types/src/packlets/spaces/notarization-plugin.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/spaces-service.d.ts +1 -1
- package/dist/types/src/packlets/spaces/spaces-service.d.ts.map +1 -1
- package/dist/types/src/packlets/testing/test-builder.d.ts +7 -1
- package/dist/types/src/packlets/testing/test-builder.d.ts.map +1 -1
- package/dist/types/src/packlets/vault/iframe-host-runtime.d.ts +1 -1
- package/dist/types/src/packlets/vault/iframe-host-runtime.d.ts.map +1 -1
- package/dist/types/src/packlets/vault/iframe-proxy-runtime.d.ts +1 -1
- package/dist/types/src/packlets/vault/iframe-proxy-runtime.d.ts.map +1 -1
- package/dist/types/src/packlets/vault/shell-runtime.d.ts +1 -21
- package/dist/types/src/packlets/vault/shell-runtime.d.ts.map +1 -1
- package/package.json +33 -32
- package/src/packlets/identity/authenticator.ts +4 -2
- package/src/packlets/identity/identity-manager.test.ts +1 -1
- package/src/packlets/identity/identity-manager.ts +8 -8
- package/src/packlets/identity/identity-service.ts +2 -2
- package/src/packlets/identity/identity.test.ts +1 -1
- package/src/packlets/identity/identity.ts +22 -27
- package/src/packlets/invitations/device-invitation-protocol.ts +4 -4
- package/src/packlets/invitations/invitation-extension.ts +5 -5
- package/src/packlets/invitations/invitations-handler.ts +6 -6
- package/src/packlets/invitations/invitations-service.ts +3 -3
- package/src/packlets/invitations/space-invitation-protocol.ts +9 -9
- package/src/packlets/locks/node.ts +2 -2
- package/src/packlets/logging/logging-service.ts +4 -4
- package/src/packlets/services/service-context.test.ts +1 -1
- package/src/packlets/services/service-context.ts +12 -10
- package/src/packlets/services/service-host.test.ts +50 -2
- package/src/packlets/services/service-host.ts +25 -9
- package/src/packlets/spaces/data-space-manager.test.ts +75 -119
- package/src/packlets/spaces/data-space-manager.ts +18 -9
- package/src/packlets/spaces/data-space.ts +66 -20
- package/src/packlets/spaces/notarization-plugin.test.ts +1 -1
- package/src/packlets/spaces/notarization-plugin.ts +9 -5
- package/src/packlets/spaces/spaces-service.test.ts +5 -3
- package/src/packlets/spaces/spaces-service.ts +26 -8
- package/src/packlets/testing/invitation-utils.ts +2 -2
- package/src/packlets/testing/test-builder.ts +36 -4
- package/src/packlets/vault/iframe-host-runtime.ts +2 -2
- package/src/packlets/vault/iframe-proxy-runtime.ts +2 -2
- package/src/packlets/vault/shell-runtime.ts +3 -49
- package/src/packlets/vault/worker-runtime.ts +1 -1
- package/src/packlets/vault/worker-session.ts +2 -2
- package/dist/lib/browser/chunk-6ITWCQIT.mjs.map +0 -7
|
@@ -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,
|
|
@@ -2075,7 +2083,7 @@ var SpaceInvitationProtocol = class {
|
|
|
2075
2083
|
};
|
|
2076
2084
|
|
|
2077
2085
|
// packages/sdk/client-services/src/packlets/spaces/data-space.ts
|
|
2078
|
-
import { Event as Event5, scheduleTask as scheduleTask4, trackLeaks } from "@dxos/async";
|
|
2086
|
+
import { Event as Event5, scheduleTask as scheduleTask4, synchronized, trackLeaks } from "@dxos/async";
|
|
2079
2087
|
import { AUTH_TIMEOUT as AUTH_TIMEOUT2 } from "@dxos/client-protocol";
|
|
2080
2088
|
import { cancelWithContext as cancelWithContext2, Context as Context6 } from "@dxos/context";
|
|
2081
2089
|
import { timed } from "@dxos/debug";
|
|
@@ -2089,7 +2097,7 @@ import { Timeframe } from "@dxos/timeframe";
|
|
|
2089
2097
|
import { ComplexSet as ComplexSet2 } from "@dxos/util";
|
|
2090
2098
|
|
|
2091
2099
|
// packages/sdk/client-services/src/packlets/spaces/notarization-plugin.ts
|
|
2092
|
-
import
|
|
2100
|
+
import invariant9 from "tiny-invariant";
|
|
2093
2101
|
import { DeferredTask, Event as Event4, scheduleTask as scheduleTask3, sleep, TimeoutError as TimeoutError2, Trigger as Trigger4 } from "@dxos/async";
|
|
2094
2102
|
import { Context as Context5, rejectOnDispose } from "@dxos/context";
|
|
2095
2103
|
import { PublicKey as PublicKey6 } from "@dxos/keys";
|
|
@@ -2097,6 +2105,7 @@ import { log as log8 } from "@dxos/log";
|
|
|
2097
2105
|
import { schema as schema3 } from "@dxos/protocols";
|
|
2098
2106
|
import { RpcExtension as RpcExtension2 } from "@dxos/teleport";
|
|
2099
2107
|
import { ComplexMap as ComplexMap2, ComplexSet, entry } from "@dxos/util";
|
|
2108
|
+
var __dxlog_file8 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/notarization-plugin.ts";
|
|
2100
2109
|
var DEFAULT_RETRY_TIMEOUT = 1e3;
|
|
2101
2110
|
var DEFAULT_SUCCESS_DELAY = 1e3;
|
|
2102
2111
|
var DEFAULT_NOTARIZE_TIMEOUT = 1e4;
|
|
@@ -2109,6 +2118,9 @@ var NotarizationPlugin = class {
|
|
|
2109
2118
|
this._processedCredentials = new ComplexSet(PublicKey6.hash);
|
|
2110
2119
|
this._processCredentialsTriggers = new ComplexMap2(PublicKey6.hash);
|
|
2111
2120
|
}
|
|
2121
|
+
get hasWriter() {
|
|
2122
|
+
return !!this._writer;
|
|
2123
|
+
}
|
|
2112
2124
|
async open() {
|
|
2113
2125
|
}
|
|
2114
2126
|
async close() {
|
|
@@ -2121,22 +2133,22 @@ var NotarizationPlugin = class {
|
|
|
2121
2133
|
log8("notarize", {
|
|
2122
2134
|
credentials
|
|
2123
2135
|
}, {
|
|
2124
|
-
|
|
2125
|
-
|
|
2126
|
-
|
|
2127
|
-
|
|
2136
|
+
F: __dxlog_file8,
|
|
2137
|
+
L: 91,
|
|
2138
|
+
S: this,
|
|
2139
|
+
C: (f, a) => f(...a)
|
|
2128
2140
|
});
|
|
2129
|
-
|
|
2141
|
+
invariant9(credentials.every((credential) => credential.id), "Credentials must have an id");
|
|
2130
2142
|
const errors = new Trigger4();
|
|
2131
2143
|
const ctx = this._ctx.derive({
|
|
2132
2144
|
onError: (err) => {
|
|
2133
2145
|
log8.warn("Notarization error", {
|
|
2134
2146
|
err
|
|
2135
2147
|
}, {
|
|
2136
|
-
|
|
2137
|
-
|
|
2138
|
-
|
|
2139
|
-
|
|
2148
|
+
F: __dxlog_file8,
|
|
2149
|
+
L: 100,
|
|
2150
|
+
S: this,
|
|
2151
|
+
C: (f, a) => f(...a)
|
|
2140
2152
|
});
|
|
2141
2153
|
void ctx.dispose();
|
|
2142
2154
|
errors.throw(err);
|
|
@@ -2149,10 +2161,10 @@ var NotarizationPlugin = class {
|
|
|
2149
2161
|
timeout,
|
|
2150
2162
|
peers: Array.from(this._extensions).map((extension) => extension.remotePeerId)
|
|
2151
2163
|
}, {
|
|
2152
|
-
|
|
2153
|
-
|
|
2154
|
-
|
|
2155
|
-
|
|
2164
|
+
F: __dxlog_file8,
|
|
2165
|
+
L: 112,
|
|
2166
|
+
S: this,
|
|
2167
|
+
C: (f, a) => f(...a)
|
|
2156
2168
|
});
|
|
2157
2169
|
void ctx.dispose();
|
|
2158
2170
|
errors.throw(new TimeoutError2(timeout, "Notarization timed out"));
|
|
@@ -2172,10 +2184,10 @@ var NotarizationPlugin = class {
|
|
|
2172
2184
|
log8.warn("Exhausted all peers to notarize with", {
|
|
2173
2185
|
retryIn: retryTimeout
|
|
2174
2186
|
}, {
|
|
2175
|
-
|
|
2176
|
-
|
|
2177
|
-
|
|
2178
|
-
|
|
2187
|
+
F: __dxlog_file8,
|
|
2188
|
+
L: 137,
|
|
2189
|
+
S: this,
|
|
2190
|
+
C: (f, a) => f(...a)
|
|
2179
2191
|
});
|
|
2180
2192
|
peersTried.clear();
|
|
2181
2193
|
scheduleTask3(ctx, () => notarizeTask.schedule(), retryTimeout);
|
|
@@ -2186,28 +2198,28 @@ var NotarizationPlugin = class {
|
|
|
2186
2198
|
peer: peer.localPeerId,
|
|
2187
2199
|
credentialId: credentials.map((credential) => credential.id)
|
|
2188
2200
|
}, {
|
|
2189
|
-
|
|
2190
|
-
|
|
2191
|
-
|
|
2192
|
-
|
|
2201
|
+
F: __dxlog_file8,
|
|
2202
|
+
L: 144,
|
|
2203
|
+
S: this,
|
|
2204
|
+
C: (f, a) => f(...a)
|
|
2193
2205
|
});
|
|
2194
2206
|
await peer.rpc.NotarizationService.notarize({
|
|
2195
2207
|
credentials: credentials.filter((credential) => !this._processedCredentials.has(credential.id))
|
|
2196
2208
|
});
|
|
2197
|
-
log8("success",
|
|
2198
|
-
|
|
2199
|
-
|
|
2200
|
-
|
|
2201
|
-
|
|
2209
|
+
log8("success", void 0, {
|
|
2210
|
+
F: __dxlog_file8,
|
|
2211
|
+
L: 148,
|
|
2212
|
+
S: this,
|
|
2213
|
+
C: (f, a) => f(...a)
|
|
2202
2214
|
});
|
|
2203
2215
|
await sleep(successDelay);
|
|
2204
2216
|
} catch (err) {
|
|
2205
2217
|
if (!ctx.disposed && !err.message.includes(WRITER_NOT_SET_ERROR_CODE)) {
|
|
2206
2218
|
log8.warn("error notarizing (recoverable)", err, {
|
|
2207
|
-
|
|
2208
|
-
|
|
2209
|
-
|
|
2210
|
-
|
|
2219
|
+
F: __dxlog_file8,
|
|
2220
|
+
L: 152,
|
|
2221
|
+
S: this,
|
|
2222
|
+
C: (f, a) => f(...a)
|
|
2211
2223
|
});
|
|
2212
2224
|
}
|
|
2213
2225
|
notarizeTask.schedule();
|
|
@@ -2221,11 +2233,11 @@ var NotarizationPlugin = class {
|
|
|
2221
2233
|
allNotarized,
|
|
2222
2234
|
errors.wait()
|
|
2223
2235
|
]);
|
|
2224
|
-
log8("done",
|
|
2225
|
-
|
|
2226
|
-
|
|
2227
|
-
|
|
2228
|
-
|
|
2236
|
+
log8("done", void 0, {
|
|
2237
|
+
F: __dxlog_file8,
|
|
2238
|
+
L: 163,
|
|
2239
|
+
S: this,
|
|
2240
|
+
C: (f, a) => f(...a)
|
|
2229
2241
|
});
|
|
2230
2242
|
} finally {
|
|
2231
2243
|
await ctx.dispose();
|
|
@@ -2234,7 +2246,7 @@ var NotarizationPlugin = class {
|
|
|
2234
2246
|
/**
|
|
2235
2247
|
* Called with credentials arriving from the control pipeline.
|
|
2236
2248
|
*/
|
|
2237
|
-
async
|
|
2249
|
+
async processCredential(credential) {
|
|
2238
2250
|
var _a;
|
|
2239
2251
|
if (!credential.id) {
|
|
2240
2252
|
return;
|
|
@@ -2244,7 +2256,7 @@ var NotarizationPlugin = class {
|
|
|
2244
2256
|
this._processCredentialsTriggers.delete(credential.id);
|
|
2245
2257
|
}
|
|
2246
2258
|
setWriter(writer) {
|
|
2247
|
-
|
|
2259
|
+
invariant9(!this._writer, "Writer already set.");
|
|
2248
2260
|
this._writer = writer;
|
|
2249
2261
|
}
|
|
2250
2262
|
async _waitUntilProcessed(id) {
|
|
@@ -2262,7 +2274,7 @@ var NotarizationPlugin = class {
|
|
|
2262
2274
|
throw new Error(WRITER_NOT_SET_ERROR_CODE);
|
|
2263
2275
|
}
|
|
2264
2276
|
for (const credential of (_a = request.credentials) != null ? _a : []) {
|
|
2265
|
-
|
|
2277
|
+
invariant9(credential.id, "Credential must have an id");
|
|
2266
2278
|
if (this._processedCredentials.has(credential.id)) {
|
|
2267
2279
|
continue;
|
|
2268
2280
|
}
|
|
@@ -2275,10 +2287,10 @@ var NotarizationPlugin = class {
|
|
|
2275
2287
|
log8("extension opened", {
|
|
2276
2288
|
peer: extension.localPeerId
|
|
2277
2289
|
}, {
|
|
2278
|
-
|
|
2279
|
-
|
|
2280
|
-
|
|
2281
|
-
|
|
2290
|
+
F: __dxlog_file8,
|
|
2291
|
+
L: 212,
|
|
2292
|
+
S: this,
|
|
2293
|
+
C: (f, a) => f(...a)
|
|
2282
2294
|
});
|
|
2283
2295
|
this._extensions.add(extension);
|
|
2284
2296
|
this._extensionOpened.emit();
|
|
@@ -2287,10 +2299,10 @@ var NotarizationPlugin = class {
|
|
|
2287
2299
|
log8("extension closed", {
|
|
2288
2300
|
peer: extension.localPeerId
|
|
2289
2301
|
}, {
|
|
2290
|
-
|
|
2291
|
-
|
|
2292
|
-
|
|
2293
|
-
|
|
2302
|
+
F: __dxlog_file8,
|
|
2303
|
+
L: 217,
|
|
2304
|
+
S: this,
|
|
2305
|
+
C: (f, a) => f(...a)
|
|
2294
2306
|
});
|
|
2295
2307
|
this._extensions.delete(extension);
|
|
2296
2308
|
},
|
|
@@ -2331,7 +2343,7 @@ var NotarizationTeleportExtension = class extends RpcExtension2 {
|
|
|
2331
2343
|
};
|
|
2332
2344
|
|
|
2333
2345
|
// packages/sdk/client-services/src/packlets/spaces/data-space.ts
|
|
2334
|
-
|
|
2346
|
+
function _ts_decorate(decorators, target, key, desc) {
|
|
2335
2347
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2336
2348
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
2337
2349
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -2340,10 +2352,12 @@ var __decorate = function(decorators, target, key, desc) {
|
|
|
2340
2352
|
if (d = decorators[i])
|
|
2341
2353
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
2342
2354
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2343
|
-
}
|
|
2355
|
+
}
|
|
2356
|
+
var __dxlog_file9 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space.ts";
|
|
2344
2357
|
var DataSpace = class DataSpace2 {
|
|
2345
2358
|
constructor(params) {
|
|
2346
2359
|
this._ctx = new Context6();
|
|
2360
|
+
this._notarizationPlugin = new NotarizationPlugin();
|
|
2347
2361
|
this._state = SpaceState.CLOSED;
|
|
2348
2362
|
/**
|
|
2349
2363
|
* Error for _state === SpaceState.ERROR.
|
|
@@ -2366,8 +2380,8 @@ var DataSpace = class DataSpace2 {
|
|
|
2366
2380
|
update: this._inner.stateUpdate,
|
|
2367
2381
|
authTimeout: AUTH_TIMEOUT2
|
|
2368
2382
|
});
|
|
2369
|
-
this._notarizationPluginConsumer = this._inner.spaceState.registerProcessor(new NotarizationPlugin());
|
|
2370
2383
|
this._cache = params.cache;
|
|
2384
|
+
this._state = params.initialState;
|
|
2371
2385
|
}
|
|
2372
2386
|
get key() {
|
|
2373
2387
|
return this._inner.key;
|
|
@@ -2389,25 +2403,36 @@ var DataSpace = class DataSpace2 {
|
|
|
2389
2403
|
return this._presence;
|
|
2390
2404
|
}
|
|
2391
2405
|
get notarizationPlugin() {
|
|
2392
|
-
return this.
|
|
2406
|
+
return this._notarizationPlugin;
|
|
2393
2407
|
}
|
|
2394
2408
|
get cache() {
|
|
2395
2409
|
return this._cache;
|
|
2396
2410
|
}
|
|
2397
2411
|
async open() {
|
|
2398
|
-
await this.
|
|
2399
|
-
|
|
2412
|
+
await this._open();
|
|
2413
|
+
}
|
|
2414
|
+
async _open() {
|
|
2415
|
+
await this._notarizationPlugin.open();
|
|
2416
|
+
await this._inner.spaceState.addCredentialProcessor(this._notarizationPlugin);
|
|
2400
2417
|
await this._inner.open();
|
|
2401
|
-
this._state = SpaceState.
|
|
2418
|
+
this._state = SpaceState.CONTROL_ONLY;
|
|
2419
|
+
this.stateUpdate.emit();
|
|
2420
|
+
this.metrics = {};
|
|
2402
2421
|
this.metrics.open = new Date();
|
|
2403
2422
|
}
|
|
2404
2423
|
async close() {
|
|
2424
|
+
await this._close();
|
|
2425
|
+
}
|
|
2426
|
+
async _close() {
|
|
2427
|
+
var _a, _b;
|
|
2428
|
+
await ((_b = (_a = this._callbacks).beforeClose) == null ? void 0 : _b.call(_a));
|
|
2405
2429
|
this._state = SpaceState.CLOSED;
|
|
2406
2430
|
await this._ctx.dispose();
|
|
2431
|
+
this._ctx = new Context6();
|
|
2407
2432
|
await this.authVerifier.close();
|
|
2408
2433
|
await this._inner.close();
|
|
2409
|
-
await this.
|
|
2410
|
-
await this.
|
|
2434
|
+
await this._inner.spaceState.removeCredentialProcessor(this._notarizationPlugin);
|
|
2435
|
+
await this._notarizationPlugin.close();
|
|
2411
2436
|
await this._presence.destroy();
|
|
2412
2437
|
}
|
|
2413
2438
|
async postMessage(channel, message) {
|
|
@@ -2427,18 +2452,18 @@ var DataSpace = class DataSpace2 {
|
|
|
2427
2452
|
} catch (err) {
|
|
2428
2453
|
if (err instanceof CancelledError) {
|
|
2429
2454
|
log9("Data pipeline initialization cancelled", err, {
|
|
2430
|
-
|
|
2431
|
-
|
|
2432
|
-
|
|
2433
|
-
|
|
2455
|
+
F: __dxlog_file9,
|
|
2456
|
+
L: 193,
|
|
2457
|
+
S: this,
|
|
2458
|
+
C: (f, a) => f(...a)
|
|
2434
2459
|
});
|
|
2435
2460
|
return;
|
|
2436
2461
|
}
|
|
2437
2462
|
log9.error("Error initializing data pipeline", err, {
|
|
2438
|
-
|
|
2439
|
-
|
|
2440
|
-
|
|
2441
|
-
|
|
2463
|
+
F: __dxlog_file9,
|
|
2464
|
+
L: 197,
|
|
2465
|
+
S: this,
|
|
2466
|
+
C: (f, a) => f(...a)
|
|
2442
2467
|
});
|
|
2443
2468
|
this._state = SpaceState.ERROR;
|
|
2444
2469
|
this.error = err;
|
|
@@ -2450,7 +2475,7 @@ var DataSpace = class DataSpace2 {
|
|
|
2450
2475
|
}
|
|
2451
2476
|
async initializeDataPipeline() {
|
|
2452
2477
|
var _a, _b, _c, _d;
|
|
2453
|
-
if (this._state !== SpaceState.
|
|
2478
|
+
if (this._state !== SpaceState.CONTROL_ONLY) {
|
|
2454
2479
|
throw new SystemError("Invalid operation");
|
|
2455
2480
|
}
|
|
2456
2481
|
this._state = SpaceState.INITIALIZING;
|
|
@@ -2460,37 +2485,39 @@ var DataSpace = class DataSpace2 {
|
|
|
2460
2485
|
});
|
|
2461
2486
|
this.metrics.controlPipelineReady = new Date();
|
|
2462
2487
|
await this._createWritableFeeds();
|
|
2463
|
-
log9("Writable feeds created",
|
|
2464
|
-
|
|
2465
|
-
|
|
2466
|
-
|
|
2467
|
-
|
|
2488
|
+
log9("Writable feeds created", void 0, {
|
|
2489
|
+
F: __dxlog_file9,
|
|
2490
|
+
L: 221,
|
|
2491
|
+
S: this,
|
|
2492
|
+
C: (f, a) => f(...a)
|
|
2468
2493
|
});
|
|
2469
2494
|
this.stateUpdate.emit();
|
|
2470
|
-
this.notarizationPlugin.
|
|
2471
|
-
credential
|
|
2472
|
-
credential
|
|
2473
|
-
|
|
2474
|
-
|
|
2495
|
+
if (!this.notarizationPlugin.hasWriter) {
|
|
2496
|
+
this.notarizationPlugin.setWriter(createMappedFeedWriter((credential) => ({
|
|
2497
|
+
credential: {
|
|
2498
|
+
credential
|
|
2499
|
+
}
|
|
2500
|
+
}), this._inner.controlPipeline.writer));
|
|
2501
|
+
}
|
|
2475
2502
|
await this._inner.initializeDataPipeline();
|
|
2476
2503
|
this.metrics.dataPipelineOpen = new Date();
|
|
2477
2504
|
await cancelWithContext2(this._ctx, this._inner.dataPipeline.ensureEpochInitialized());
|
|
2478
|
-
log9("waiting for data pipeline to reach target timeframe",
|
|
2479
|
-
|
|
2480
|
-
|
|
2481
|
-
|
|
2482
|
-
|
|
2505
|
+
log9("waiting for data pipeline to reach target timeframe", void 0, {
|
|
2506
|
+
F: __dxlog_file9,
|
|
2507
|
+
L: 242,
|
|
2508
|
+
S: this,
|
|
2509
|
+
C: (f, a) => f(...a)
|
|
2483
2510
|
});
|
|
2484
2511
|
await this._inner.dataPipeline.pipelineState.waitUntilReachedTargetTimeframe({
|
|
2485
2512
|
ctx: this._ctx,
|
|
2486
2513
|
breakOnStall: false
|
|
2487
2514
|
});
|
|
2488
2515
|
this.metrics.dataPipelineReady = new Date();
|
|
2489
|
-
log9("data pipeline ready",
|
|
2490
|
-
|
|
2491
|
-
|
|
2492
|
-
|
|
2493
|
-
|
|
2516
|
+
log9("data pipeline ready", void 0, {
|
|
2517
|
+
F: __dxlog_file9,
|
|
2518
|
+
L: 251,
|
|
2519
|
+
S: this,
|
|
2520
|
+
C: (f, a) => f(...a)
|
|
2494
2521
|
});
|
|
2495
2522
|
await ((_b = (_a = this._callbacks).beforeReady) == null ? void 0 : _b.call(_a));
|
|
2496
2523
|
this._state = SpaceState.READY;
|
|
@@ -2568,17 +2595,46 @@ var DataSpace = class DataSpace2 {
|
|
|
2568
2595
|
}
|
|
2569
2596
|
}
|
|
2570
2597
|
}
|
|
2598
|
+
async activate() {
|
|
2599
|
+
if (this._state !== SpaceState.INACTIVE) {
|
|
2600
|
+
throw new SystemError("Invalid operation");
|
|
2601
|
+
}
|
|
2602
|
+
await this._metadataStore.setSpaceState(this.key, SpaceState.ACTIVE);
|
|
2603
|
+
await this._open();
|
|
2604
|
+
this.initializeDataPipelineAsync();
|
|
2605
|
+
}
|
|
2606
|
+
async deactivate() {
|
|
2607
|
+
if (this._state === SpaceState.INACTIVE) {
|
|
2608
|
+
throw new SystemError("Invalid operation");
|
|
2609
|
+
}
|
|
2610
|
+
await this._metadataStore.setSpaceState(this.key, SpaceState.INACTIVE);
|
|
2611
|
+
await this._close();
|
|
2612
|
+
this._state = SpaceState.INACTIVE;
|
|
2613
|
+
this.stateUpdate.emit();
|
|
2614
|
+
}
|
|
2571
2615
|
};
|
|
2572
|
-
|
|
2616
|
+
_ts_decorate([
|
|
2617
|
+
synchronized
|
|
2618
|
+
], DataSpace.prototype, "open", null);
|
|
2619
|
+
_ts_decorate([
|
|
2620
|
+
synchronized
|
|
2621
|
+
], DataSpace.prototype, "close", null);
|
|
2622
|
+
_ts_decorate([
|
|
2573
2623
|
timed(1e4)
|
|
2574
2624
|
], DataSpace.prototype, "_createWritableFeeds", null);
|
|
2575
|
-
|
|
2625
|
+
_ts_decorate([
|
|
2626
|
+
synchronized
|
|
2627
|
+
], DataSpace.prototype, "activate", null);
|
|
2628
|
+
_ts_decorate([
|
|
2629
|
+
synchronized
|
|
2630
|
+
], DataSpace.prototype, "deactivate", null);
|
|
2631
|
+
DataSpace = _ts_decorate([
|
|
2576
2632
|
trackLeaks("open", "close")
|
|
2577
2633
|
], DataSpace);
|
|
2578
2634
|
|
|
2579
2635
|
// 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";
|
|
2636
|
+
import invariant10 from "tiny-invariant";
|
|
2637
|
+
import { Event as Event6, synchronized as synchronized2, trackLeaks as trackLeaks2 } from "@dxos/async";
|
|
2582
2638
|
import { cancelWithContext as cancelWithContext3, Context as Context7 } from "@dxos/context";
|
|
2583
2639
|
import { getCredentialAssertion as getCredentialAssertion2 } from "@dxos/credentials";
|
|
2584
2640
|
import { PublicKey as PublicKey8 } from "@dxos/keys";
|
|
@@ -2659,7 +2715,7 @@ var spaceGenesis = async (keyring, signingContext, space) => {
|
|
|
2659
2715
|
};
|
|
2660
2716
|
|
|
2661
2717
|
// packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts
|
|
2662
|
-
|
|
2718
|
+
function _ts_decorate2(decorators, target, key, desc) {
|
|
2663
2719
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2664
2720
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
2665
2721
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -2668,7 +2724,8 @@ var __decorate2 = function(decorators, target, key, desc) {
|
|
|
2668
2724
|
if (d = decorators[i])
|
|
2669
2725
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
2670
2726
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2671
|
-
}
|
|
2727
|
+
}
|
|
2728
|
+
var __dxlog_file10 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts";
|
|
2672
2729
|
var DataSpaceManager = class DataSpaceManager2 {
|
|
2673
2730
|
constructor(_spaceManager, _metadataStore, _dataServiceSubscriptions, _keyring, _signingContext, _feedStore) {
|
|
2674
2731
|
this._spaceManager = _spaceManager;
|
|
@@ -2688,50 +2745,52 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2688
2745
|
return this._spaces;
|
|
2689
2746
|
}
|
|
2690
2747
|
async open() {
|
|
2691
|
-
log10("open",
|
|
2692
|
-
|
|
2693
|
-
|
|
2694
|
-
|
|
2695
|
-
|
|
2748
|
+
log10("open", void 0, {
|
|
2749
|
+
F: __dxlog_file10,
|
|
2750
|
+
L: 80,
|
|
2751
|
+
S: this,
|
|
2752
|
+
C: (f, a) => f(...a)
|
|
2696
2753
|
});
|
|
2697
2754
|
log10.trace("dxos.echo.data-space-manager.open", trace4.begin({
|
|
2698
2755
|
id: this._instanceId
|
|
2699
2756
|
}), {
|
|
2700
|
-
|
|
2701
|
-
|
|
2702
|
-
|
|
2703
|
-
|
|
2757
|
+
F: __dxlog_file10,
|
|
2758
|
+
L: 81,
|
|
2759
|
+
S: this,
|
|
2760
|
+
C: (f, a) => f(...a)
|
|
2704
2761
|
});
|
|
2705
2762
|
await this._metadataStore.load();
|
|
2706
2763
|
log10("metadata loaded", {
|
|
2707
2764
|
spaces: this._metadataStore.spaces.length
|
|
2708
2765
|
}, {
|
|
2709
|
-
|
|
2710
|
-
|
|
2711
|
-
|
|
2712
|
-
|
|
2766
|
+
F: __dxlog_file10,
|
|
2767
|
+
L: 83,
|
|
2768
|
+
S: this,
|
|
2769
|
+
C: (f, a) => f(...a)
|
|
2713
2770
|
});
|
|
2714
2771
|
for (const spaceMetadata of this._metadataStore.spaces) {
|
|
2715
2772
|
try {
|
|
2716
2773
|
log10("load space", {
|
|
2717
2774
|
spaceMetadata
|
|
2718
2775
|
}, {
|
|
2719
|
-
|
|
2720
|
-
|
|
2721
|
-
|
|
2722
|
-
|
|
2776
|
+
F: __dxlog_file10,
|
|
2777
|
+
L: 87,
|
|
2778
|
+
S: this,
|
|
2779
|
+
C: (f, a) => f(...a)
|
|
2723
2780
|
});
|
|
2724
2781
|
const space = await this._constructSpace(spaceMetadata);
|
|
2725
|
-
|
|
2782
|
+
if (spaceMetadata.state !== SpaceState2.INACTIVE) {
|
|
2783
|
+
space.initializeDataPipelineAsync();
|
|
2784
|
+
}
|
|
2726
2785
|
} catch (err) {
|
|
2727
2786
|
log10.error("Error loading space", {
|
|
2728
2787
|
spaceMetadata,
|
|
2729
2788
|
err
|
|
2730
2789
|
}, {
|
|
2731
|
-
|
|
2732
|
-
|
|
2733
|
-
|
|
2734
|
-
|
|
2790
|
+
F: __dxlog_file10,
|
|
2791
|
+
L: 93,
|
|
2792
|
+
S: this,
|
|
2793
|
+
C: (f, a) => f(...a)
|
|
2735
2794
|
});
|
|
2736
2795
|
}
|
|
2737
2796
|
}
|
|
@@ -2740,18 +2799,18 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2740
2799
|
log10.trace("dxos.echo.data-space-manager.open", trace4.end({
|
|
2741
2800
|
id: this._instanceId
|
|
2742
2801
|
}), {
|
|
2743
|
-
|
|
2744
|
-
|
|
2745
|
-
|
|
2746
|
-
|
|
2802
|
+
F: __dxlog_file10,
|
|
2803
|
+
L: 99,
|
|
2804
|
+
S: this,
|
|
2805
|
+
C: (f, a) => f(...a)
|
|
2747
2806
|
});
|
|
2748
2807
|
}
|
|
2749
2808
|
async close() {
|
|
2750
|
-
log10("close",
|
|
2751
|
-
|
|
2752
|
-
|
|
2753
|
-
|
|
2754
|
-
|
|
2809
|
+
log10("close", void 0, {
|
|
2810
|
+
F: __dxlog_file10,
|
|
2811
|
+
L: 104,
|
|
2812
|
+
S: this,
|
|
2813
|
+
C: (f, a) => f(...a)
|
|
2755
2814
|
});
|
|
2756
2815
|
this._isOpen = false;
|
|
2757
2816
|
await this._ctx.dispose();
|
|
@@ -2763,7 +2822,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2763
2822
|
* Creates a new space writing the genesis credentials to the control feed.
|
|
2764
2823
|
*/
|
|
2765
2824
|
async createSpace() {
|
|
2766
|
-
|
|
2825
|
+
invariant10(this._isOpen, "Not open.");
|
|
2767
2826
|
const spaceKey = await this._keyring.createKey();
|
|
2768
2827
|
const controlFeedKey = await this._keyring.createKey();
|
|
2769
2828
|
const dataFeedKey = await this._keyring.createKey();
|
|
@@ -2771,21 +2830,22 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2771
2830
|
key: spaceKey,
|
|
2772
2831
|
genesisFeedKey: controlFeedKey,
|
|
2773
2832
|
controlFeedKey,
|
|
2774
|
-
dataFeedKey
|
|
2833
|
+
dataFeedKey,
|
|
2834
|
+
state: SpaceState2.ACTIVE
|
|
2775
2835
|
};
|
|
2776
2836
|
log10("creating space...", {
|
|
2777
2837
|
spaceKey
|
|
2778
2838
|
}, {
|
|
2779
|
-
|
|
2780
|
-
|
|
2781
|
-
|
|
2782
|
-
|
|
2839
|
+
F: __dxlog_file10,
|
|
2840
|
+
L: 129,
|
|
2841
|
+
S: this,
|
|
2842
|
+
C: (f, a) => f(...a)
|
|
2783
2843
|
});
|
|
2784
2844
|
const space = await this._constructSpace(metadata);
|
|
2785
2845
|
const credentials = await spaceGenesis(this._keyring, this._signingContext, space.inner);
|
|
2786
2846
|
await this._metadataStore.addSpace(metadata);
|
|
2787
2847
|
const memberCredential = credentials[1];
|
|
2788
|
-
|
|
2848
|
+
invariant10(getCredentialAssertion2(memberCredential)["@type"] === "dxos.halo.credentials.SpaceMember");
|
|
2789
2849
|
await this._signingContext.recordCredential(memberCredential);
|
|
2790
2850
|
await space.initializeDataPipeline();
|
|
2791
2851
|
this.updated.emit();
|
|
@@ -2796,13 +2856,13 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2796
2856
|
log10("accept space", {
|
|
2797
2857
|
opts
|
|
2798
2858
|
}, {
|
|
2799
|
-
|
|
2800
|
-
|
|
2801
|
-
|
|
2802
|
-
|
|
2859
|
+
F: __dxlog_file10,
|
|
2860
|
+
L: 148,
|
|
2861
|
+
S: this,
|
|
2862
|
+
C: (f, a) => f(...a)
|
|
2803
2863
|
});
|
|
2804
|
-
|
|
2805
|
-
|
|
2864
|
+
invariant10(this._isOpen, "Not open.");
|
|
2865
|
+
invariant10(!this._spaces.has(opts.spaceKey), "Space already exists.");
|
|
2806
2866
|
const metadata = {
|
|
2807
2867
|
key: opts.spaceKey,
|
|
2808
2868
|
genesisFeedKey: opts.genesisFeedKey,
|
|
@@ -2830,10 +2890,10 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2830
2890
|
log10("construct space", {
|
|
2831
2891
|
metadata
|
|
2832
2892
|
}, {
|
|
2833
|
-
|
|
2834
|
-
|
|
2835
|
-
|
|
2836
|
-
|
|
2893
|
+
F: __dxlog_file10,
|
|
2894
|
+
L: 183,
|
|
2895
|
+
S: this,
|
|
2896
|
+
C: (f, a) => f(...a)
|
|
2837
2897
|
});
|
|
2838
2898
|
const gossip = new Gossip({
|
|
2839
2899
|
localPeerId: this._signingContext.deviceKey
|
|
@@ -2865,11 +2925,11 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2865
2925
|
session.addExtension("dxos.mesh.teleport.notarization", dataSpace.notarizationPlugin.createExtension());
|
|
2866
2926
|
},
|
|
2867
2927
|
onAuthFailure: () => {
|
|
2868
|
-
log10.warn("auth failure",
|
|
2869
|
-
|
|
2870
|
-
|
|
2871
|
-
|
|
2872
|
-
|
|
2928
|
+
log10.warn("auth failure", void 0, {
|
|
2929
|
+
F: __dxlog_file10,
|
|
2930
|
+
L: 214,
|
|
2931
|
+
S: this,
|
|
2932
|
+
C: (f, a) => f(...a)
|
|
2873
2933
|
});
|
|
2874
2934
|
},
|
|
2875
2935
|
memberKey: this._signingContext.identityKey
|
|
@@ -2878,6 +2938,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2878
2938
|
dataFeed && space.setDataFeed(dataFeed);
|
|
2879
2939
|
const dataSpace = new DataSpace({
|
|
2880
2940
|
inner: space,
|
|
2941
|
+
initialState: metadata.state === SpaceState2.INACTIVE ? SpaceState2.INACTIVE : SpaceState2.CLOSED,
|
|
2881
2942
|
metadataStore: this._metadataStore,
|
|
2882
2943
|
gossip,
|
|
2883
2944
|
presence,
|
|
@@ -2889,31 +2950,44 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2889
2950
|
log10("before space ready", {
|
|
2890
2951
|
space: space.key
|
|
2891
2952
|
}, {
|
|
2892
|
-
|
|
2893
|
-
|
|
2894
|
-
|
|
2895
|
-
|
|
2953
|
+
F: __dxlog_file10,
|
|
2954
|
+
L: 232,
|
|
2955
|
+
S: this,
|
|
2956
|
+
C: (f, a) => f(...a)
|
|
2896
2957
|
});
|
|
2897
|
-
this._dataServiceSubscriptions.registerSpace(space.key, dataSpace.dataPipeline.databaseHost.createDataServiceHost());
|
|
2958
|
+
await this._dataServiceSubscriptions.registerSpace(space.key, dataSpace.dataPipeline.databaseHost.createDataServiceHost());
|
|
2898
2959
|
},
|
|
2899
2960
|
afterReady: async () => {
|
|
2900
2961
|
log10("after space ready", {
|
|
2901
2962
|
space: space.key,
|
|
2902
2963
|
open: this._isOpen
|
|
2903
2964
|
}, {
|
|
2904
|
-
|
|
2905
|
-
|
|
2906
|
-
|
|
2907
|
-
|
|
2965
|
+
F: __dxlog_file10,
|
|
2966
|
+
L: 239,
|
|
2967
|
+
S: this,
|
|
2968
|
+
C: (f, a) => f(...a)
|
|
2908
2969
|
});
|
|
2909
2970
|
if (this._isOpen) {
|
|
2910
2971
|
this.updated.emit();
|
|
2911
2972
|
}
|
|
2973
|
+
},
|
|
2974
|
+
beforeClose: async () => {
|
|
2975
|
+
log10("before space close", {
|
|
2976
|
+
space: space.key
|
|
2977
|
+
}, {
|
|
2978
|
+
F: __dxlog_file10,
|
|
2979
|
+
L: 245,
|
|
2980
|
+
S: this,
|
|
2981
|
+
C: (f, a) => f(...a)
|
|
2982
|
+
});
|
|
2983
|
+
await this._dataServiceSubscriptions.unregisterSpace(space.key);
|
|
2912
2984
|
}
|
|
2913
2985
|
},
|
|
2914
2986
|
cache: metadata.cache
|
|
2915
2987
|
});
|
|
2916
|
-
|
|
2988
|
+
if (metadata.state !== SpaceState2.INACTIVE) {
|
|
2989
|
+
await dataSpace.open();
|
|
2990
|
+
}
|
|
2917
2991
|
if (metadata.controlTimeframe) {
|
|
2918
2992
|
dataSpace.inner.controlPipeline.state.setTargetTimeframe(metadata.controlTimeframe);
|
|
2919
2993
|
}
|
|
@@ -2924,31 +2998,33 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2924
2998
|
return dataSpace;
|
|
2925
2999
|
}
|
|
2926
3000
|
};
|
|
2927
|
-
|
|
2928
|
-
|
|
3001
|
+
_ts_decorate2([
|
|
3002
|
+
synchronized2
|
|
2929
3003
|
], DataSpaceManager.prototype, "open", null);
|
|
2930
|
-
|
|
2931
|
-
|
|
3004
|
+
_ts_decorate2([
|
|
3005
|
+
synchronized2
|
|
2932
3006
|
], DataSpaceManager.prototype, "close", null);
|
|
2933
|
-
|
|
2934
|
-
|
|
3007
|
+
_ts_decorate2([
|
|
3008
|
+
synchronized2
|
|
2935
3009
|
], DataSpaceManager.prototype, "createSpace", null);
|
|
2936
|
-
|
|
2937
|
-
|
|
3010
|
+
_ts_decorate2([
|
|
3011
|
+
synchronized2
|
|
2938
3012
|
], DataSpaceManager.prototype, "acceptSpace", null);
|
|
2939
|
-
DataSpaceManager =
|
|
3013
|
+
DataSpaceManager = _ts_decorate2([
|
|
2940
3014
|
trackLeaks2("open", "close")
|
|
2941
3015
|
], DataSpaceManager);
|
|
2942
3016
|
|
|
2943
3017
|
// packages/sdk/client-services/src/packlets/spaces/spaces-service.ts
|
|
2944
3018
|
import { EventSubscriptions as EventSubscriptions2, UpdateScheduler, scheduleTask as scheduleTask5 } from "@dxos/async";
|
|
2945
3019
|
import { Stream as Stream9 } from "@dxos/codec-protobuf";
|
|
2946
|
-
import { raise
|
|
3020
|
+
import { raise } from "@dxos/debug";
|
|
2947
3021
|
import { SpaceNotFoundError } from "@dxos/echo-pipeline";
|
|
3022
|
+
import { ApiError } from "@dxos/errors";
|
|
2948
3023
|
import { log as log11 } from "@dxos/log";
|
|
2949
3024
|
import { encodeError } from "@dxos/protocols";
|
|
2950
|
-
import { SpaceMember as SpaceMember2 } from "@dxos/protocols/proto/dxos/client/services";
|
|
3025
|
+
import { SpaceMember as SpaceMember2, SpaceState as SpaceState3 } from "@dxos/protocols/proto/dxos/client/services";
|
|
2951
3026
|
import { humanize } from "@dxos/util";
|
|
3027
|
+
var __dxlog_file11 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/spaces-service.ts";
|
|
2952
3028
|
var SpacesServiceImpl = class {
|
|
2953
3029
|
constructor(_identityManager, _spaceManager, _dataServiceSubscriptions, _getDataSpaceManager) {
|
|
2954
3030
|
this._identityManager = _identityManager;
|
|
@@ -2964,8 +3040,22 @@ var SpacesServiceImpl = class {
|
|
|
2964
3040
|
const space = await dataSpaceManager.createSpace();
|
|
2965
3041
|
return this._serializeSpace(space);
|
|
2966
3042
|
}
|
|
2967
|
-
async updateSpace(
|
|
2968
|
-
|
|
3043
|
+
async updateSpace({ spaceKey, state }) {
|
|
3044
|
+
var _a;
|
|
3045
|
+
const dataSpaceManager = await this._getDataSpaceManager();
|
|
3046
|
+
const space = (_a = dataSpaceManager.spaces.get(spaceKey)) != null ? _a : raise(new SpaceNotFoundError(spaceKey));
|
|
3047
|
+
if (state) {
|
|
3048
|
+
switch (state) {
|
|
3049
|
+
case SpaceState3.ACTIVE:
|
|
3050
|
+
await space.activate();
|
|
3051
|
+
break;
|
|
3052
|
+
case SpaceState3.INACTIVE:
|
|
3053
|
+
await space.deactivate();
|
|
3054
|
+
break;
|
|
3055
|
+
default:
|
|
3056
|
+
throw new ApiError("Invalid space state");
|
|
3057
|
+
}
|
|
3058
|
+
}
|
|
2969
3059
|
}
|
|
2970
3060
|
querySpaces() {
|
|
2971
3061
|
return new Stream9(({ next, ctx }) => {
|
|
@@ -2975,10 +3065,10 @@ var SpacesServiceImpl = class {
|
|
|
2975
3065
|
log11("update", {
|
|
2976
3066
|
spaces
|
|
2977
3067
|
}, {
|
|
2978
|
-
|
|
2979
|
-
|
|
2980
|
-
|
|
2981
|
-
|
|
3068
|
+
F: __dxlog_file11,
|
|
3069
|
+
L: 78,
|
|
3070
|
+
S: this,
|
|
3071
|
+
C: (f, a) => f(...a)
|
|
2982
3072
|
});
|
|
2983
3073
|
next({
|
|
2984
3074
|
spaces
|
|
@@ -3039,13 +3129,13 @@ var SpacesServiceImpl = class {
|
|
|
3039
3129
|
return new Stream9(({ ctx, next }) => {
|
|
3040
3130
|
var _a;
|
|
3041
3131
|
const space = (_a = this._spaceManager.spaces.get(spaceKey)) != null ? _a : raise(new SpaceNotFoundError(spaceKey));
|
|
3042
|
-
const processor =
|
|
3043
|
-
|
|
3132
|
+
const processor = {
|
|
3133
|
+
processCredential: async (credential) => {
|
|
3044
3134
|
next(credential);
|
|
3045
3135
|
}
|
|
3046
|
-
}
|
|
3047
|
-
ctx.onDispose(() =>
|
|
3048
|
-
scheduleTask5(ctx, () =>
|
|
3136
|
+
};
|
|
3137
|
+
ctx.onDispose(() => space.spaceState.removeCredentialProcessor(processor));
|
|
3138
|
+
scheduleTask5(ctx, () => space.spaceState.addCredentialProcessor(processor));
|
|
3049
3139
|
});
|
|
3050
3140
|
}
|
|
3051
3141
|
async writeCredentials({ spaceKey, credentials }) {
|
|
@@ -3105,7 +3195,7 @@ var SpacesServiceImpl = class {
|
|
|
3105
3195
|
var getChannelId = (channel) => `user-channel/${channel}`;
|
|
3106
3196
|
|
|
3107
3197
|
// packages/sdk/client-services/src/packlets/services/service-context.ts
|
|
3108
|
-
import
|
|
3198
|
+
import invariant11 from "tiny-invariant";
|
|
3109
3199
|
import { Trigger as Trigger5 } from "@dxos/async";
|
|
3110
3200
|
import { getCredentialAssertion as getCredentialAssertion3 } from "@dxos/credentials";
|
|
3111
3201
|
import { failUndefined as failUndefined3 } from "@dxos/debug";
|
|
@@ -3117,6 +3207,7 @@ import { log as log12 } from "@dxos/log";
|
|
|
3117
3207
|
import { STORAGE_VERSION, trace as trace5 } from "@dxos/protocols";
|
|
3118
3208
|
import { Invitation as Invitation5 } from "@dxos/protocols/proto/dxos/client/services";
|
|
3119
3209
|
import { BlobStore } from "@dxos/teleport-extension-object-sync";
|
|
3210
|
+
var __dxlog_file12 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-context.ts";
|
|
3120
3211
|
var ServiceContext = class {
|
|
3121
3212
|
// prettier-ignore
|
|
3122
3213
|
constructor(storage, networkManager, signalManager, modelFactory) {
|
|
@@ -3160,17 +3251,17 @@ var ServiceContext = class {
|
|
|
3160
3251
|
log12.trace("dxos.sdk.service-context.open", trace5.begin({
|
|
3161
3252
|
id: this._instanceId
|
|
3162
3253
|
}), {
|
|
3163
|
-
|
|
3164
|
-
|
|
3165
|
-
|
|
3166
|
-
|
|
3254
|
+
F: __dxlog_file12,
|
|
3255
|
+
L: 126,
|
|
3256
|
+
S: this,
|
|
3257
|
+
C: (f, a) => f(...a)
|
|
3167
3258
|
});
|
|
3168
3259
|
await this._checkStorageVersion();
|
|
3169
|
-
log12("opening...",
|
|
3170
|
-
|
|
3171
|
-
|
|
3172
|
-
|
|
3173
|
-
|
|
3260
|
+
log12("opening...", void 0, {
|
|
3261
|
+
F: __dxlog_file12,
|
|
3262
|
+
L: 130,
|
|
3263
|
+
S: this,
|
|
3264
|
+
C: (f, a) => f(...a)
|
|
3174
3265
|
});
|
|
3175
3266
|
await this.signalManager.open();
|
|
3176
3267
|
await this.networkManager.open();
|
|
@@ -3179,42 +3270,44 @@ var ServiceContext = class {
|
|
|
3179
3270
|
if (this.identityManager.identity) {
|
|
3180
3271
|
await this._initialize();
|
|
3181
3272
|
}
|
|
3182
|
-
log12("opened",
|
|
3183
|
-
|
|
3184
|
-
|
|
3185
|
-
|
|
3186
|
-
|
|
3273
|
+
log12("opened", void 0, {
|
|
3274
|
+
F: __dxlog_file12,
|
|
3275
|
+
L: 138,
|
|
3276
|
+
S: this,
|
|
3277
|
+
C: (f, a) => f(...a)
|
|
3187
3278
|
});
|
|
3188
3279
|
log12.trace("dxos.sdk.service-context.open", trace5.end({
|
|
3189
3280
|
id: this._instanceId
|
|
3190
3281
|
}), {
|
|
3191
|
-
|
|
3192
|
-
|
|
3193
|
-
|
|
3194
|
-
|
|
3282
|
+
F: __dxlog_file12,
|
|
3283
|
+
L: 139,
|
|
3284
|
+
S: this,
|
|
3285
|
+
C: (f, a) => f(...a)
|
|
3195
3286
|
});
|
|
3196
3287
|
}
|
|
3197
3288
|
async close() {
|
|
3198
|
-
var _a
|
|
3199
|
-
log12("closing...",
|
|
3200
|
-
|
|
3201
|
-
|
|
3202
|
-
|
|
3203
|
-
|
|
3204
|
-
});
|
|
3205
|
-
|
|
3206
|
-
|
|
3289
|
+
var _a;
|
|
3290
|
+
log12("closing...", void 0, {
|
|
3291
|
+
F: __dxlog_file12,
|
|
3292
|
+
L: 143,
|
|
3293
|
+
S: this,
|
|
3294
|
+
C: (f, a) => f(...a)
|
|
3295
|
+
});
|
|
3296
|
+
if (this._deviceSpaceSync && this.identityManager.identity) {
|
|
3297
|
+
await this.identityManager.identity.space.spaceState.removeCredentialProcessor(this._deviceSpaceSync);
|
|
3298
|
+
}
|
|
3299
|
+
await ((_a = this.dataSpaceManager) == null ? void 0 : _a.close());
|
|
3207
3300
|
await this.identityManager.close();
|
|
3208
3301
|
await this.spaceManager.close();
|
|
3209
3302
|
await this.feedStore.close();
|
|
3210
3303
|
await this.networkManager.close();
|
|
3211
3304
|
await this.signalManager.close();
|
|
3212
3305
|
this.dataServiceSubscriptions.clear();
|
|
3213
|
-
log12("closed",
|
|
3214
|
-
|
|
3215
|
-
|
|
3216
|
-
|
|
3217
|
-
|
|
3306
|
+
log12("closed", void 0, {
|
|
3307
|
+
F: __dxlog_file12,
|
|
3308
|
+
L: 154,
|
|
3309
|
+
S: this,
|
|
3310
|
+
C: (f, a) => f(...a)
|
|
3218
3311
|
});
|
|
3219
3312
|
}
|
|
3220
3313
|
async createIdentity(params = {}) {
|
|
@@ -3224,7 +3317,7 @@ var ServiceContext = class {
|
|
|
3224
3317
|
}
|
|
3225
3318
|
getInvitationHandler(invitation) {
|
|
3226
3319
|
const factory = this._handlerFactories.get(invitation.kind);
|
|
3227
|
-
|
|
3320
|
+
invariant11(factory, `Unknown invitation kind: ${invitation.kind}`);
|
|
3228
3321
|
return factory(invitation);
|
|
3229
3322
|
}
|
|
3230
3323
|
async _acceptIdentity(params) {
|
|
@@ -3241,11 +3334,11 @@ var ServiceContext = class {
|
|
|
3241
3334
|
// Called when identity is created.
|
|
3242
3335
|
async _initialize() {
|
|
3243
3336
|
var _a;
|
|
3244
|
-
log12("initializing spaces...",
|
|
3245
|
-
|
|
3246
|
-
|
|
3247
|
-
|
|
3248
|
-
|
|
3337
|
+
log12("initializing spaces...", void 0, {
|
|
3338
|
+
F: __dxlog_file12,
|
|
3339
|
+
L: 187,
|
|
3340
|
+
S: this,
|
|
3341
|
+
C: (f, a) => f(...a)
|
|
3249
3342
|
});
|
|
3250
3343
|
const identity = (_a = this.identityManager.identity) != null ? _a : failUndefined3();
|
|
3251
3344
|
const signingContext = {
|
|
@@ -3264,12 +3357,12 @@ var ServiceContext = class {
|
|
|
3264
3357
|
this.dataSpaceManager = new DataSpaceManager(this.spaceManager, this.metadataStore, this.dataServiceSubscriptions, this.keyring, signingContext, this.feedStore);
|
|
3265
3358
|
await this.dataSpaceManager.open();
|
|
3266
3359
|
this._handlerFactories.set(Invitation5.Kind.SPACE, (invitation) => {
|
|
3267
|
-
|
|
3360
|
+
invariant11(this.dataSpaceManager, "dataSpaceManager not initialized yet");
|
|
3268
3361
|
return new SpaceInvitationProtocol(this.dataSpaceManager, signingContext, this.keyring, invitation.spaceKey);
|
|
3269
3362
|
});
|
|
3270
3363
|
this.initialized.wake();
|
|
3271
|
-
this._deviceSpaceSync =
|
|
3272
|
-
|
|
3364
|
+
this._deviceSpaceSync = {
|
|
3365
|
+
processCredential: async (credential) => {
|
|
3273
3366
|
const assertion = getCredentialAssertion3(credential);
|
|
3274
3367
|
if (assertion["@type"] !== "dxos.halo.credentials.SpaceMember") {
|
|
3275
3368
|
return;
|
|
@@ -3281,10 +3374,10 @@ var ServiceContext = class {
|
|
|
3281
3374
|
log12("dataSpaceManager not initialized yet, ignoring space admission", {
|
|
3282
3375
|
details: assertion
|
|
3283
3376
|
}, {
|
|
3284
|
-
|
|
3285
|
-
|
|
3286
|
-
|
|
3287
|
-
|
|
3377
|
+
F: __dxlog_file12,
|
|
3378
|
+
L: 226,
|
|
3379
|
+
S: this,
|
|
3380
|
+
C: (f, a) => f(...a)
|
|
3288
3381
|
});
|
|
3289
3382
|
return;
|
|
3290
3383
|
}
|
|
@@ -3292,10 +3385,10 @@ var ServiceContext = class {
|
|
|
3292
3385
|
log12("space already exists, ignoring space admission", {
|
|
3293
3386
|
details: assertion
|
|
3294
3387
|
}, {
|
|
3295
|
-
|
|
3296
|
-
|
|
3297
|
-
|
|
3298
|
-
|
|
3388
|
+
F: __dxlog_file12,
|
|
3389
|
+
L: 230,
|
|
3390
|
+
S: this,
|
|
3391
|
+
C: (f, a) => f(...a)
|
|
3299
3392
|
});
|
|
3300
3393
|
return;
|
|
3301
3394
|
}
|
|
@@ -3303,26 +3396,26 @@ var ServiceContext = class {
|
|
|
3303
3396
|
log12("accepting space recorded in halo", {
|
|
3304
3397
|
details: assertion
|
|
3305
3398
|
}, {
|
|
3306
|
-
|
|
3307
|
-
|
|
3308
|
-
|
|
3309
|
-
|
|
3399
|
+
F: __dxlog_file12,
|
|
3400
|
+
L: 235,
|
|
3401
|
+
S: this,
|
|
3402
|
+
C: (f, a) => f(...a)
|
|
3310
3403
|
});
|
|
3311
3404
|
await this.dataSpaceManager.acceptSpace({
|
|
3312
3405
|
spaceKey: assertion.spaceKey,
|
|
3313
3406
|
genesisFeedKey: assertion.genesisFeedKey
|
|
3314
3407
|
});
|
|
3315
3408
|
} catch (err) {
|
|
3316
|
-
log12.catch(err,
|
|
3317
|
-
|
|
3318
|
-
|
|
3319
|
-
|
|
3320
|
-
|
|
3409
|
+
log12.catch(err, void 0, {
|
|
3410
|
+
F: __dxlog_file12,
|
|
3411
|
+
L: 241,
|
|
3412
|
+
S: this,
|
|
3413
|
+
C: (f, a) => f(...a)
|
|
3321
3414
|
});
|
|
3322
3415
|
}
|
|
3323
3416
|
}
|
|
3324
|
-
}
|
|
3325
|
-
await this._deviceSpaceSync
|
|
3417
|
+
};
|
|
3418
|
+
await identity.space.spaceState.addCredentialProcessor(this._deviceSpaceSync);
|
|
3326
3419
|
}
|
|
3327
3420
|
};
|
|
3328
3421
|
|
|
@@ -3330,7 +3423,7 @@ var ServiceContext = class {
|
|
|
3330
3423
|
import { asyncTimeout, Trigger as Trigger6 } from "@dxos/async";
|
|
3331
3424
|
import { RESOURCE_LOCK_TIMEOUT } from "@dxos/client-protocol";
|
|
3332
3425
|
import { log as log13, logInfo } from "@dxos/log";
|
|
3333
|
-
|
|
3426
|
+
function _ts_decorate3(decorators, target, key, desc) {
|
|
3334
3427
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3335
3428
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
3336
3429
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -3339,7 +3432,8 @@ var __decorate3 = function(decorators, target, key, desc) {
|
|
|
3339
3432
|
if (d = decorators[i])
|
|
3340
3433
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
3341
3434
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3342
|
-
}
|
|
3435
|
+
}
|
|
3436
|
+
var __dxlog_file13 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/locks/browser.ts";
|
|
3343
3437
|
var Message;
|
|
3344
3438
|
(function(Message2) {
|
|
3345
3439
|
Message2["ACQUIRING"] = "acquiring";
|
|
@@ -3361,32 +3455,32 @@ var Lock = class {
|
|
|
3361
3455
|
message: Message.ACQUIRING
|
|
3362
3456
|
});
|
|
3363
3457
|
try {
|
|
3364
|
-
log13("aquiring lock...",
|
|
3365
|
-
|
|
3366
|
-
|
|
3367
|
-
|
|
3368
|
-
|
|
3458
|
+
log13("aquiring lock...", void 0, {
|
|
3459
|
+
F: __dxlog_file13,
|
|
3460
|
+
L: 42,
|
|
3461
|
+
S: this,
|
|
3462
|
+
C: (f, a) => f(...a)
|
|
3369
3463
|
});
|
|
3370
3464
|
await asyncTimeout(this._requestLock(), RESOURCE_LOCK_TIMEOUT);
|
|
3371
|
-
log13("acquired lock",
|
|
3372
|
-
|
|
3373
|
-
|
|
3374
|
-
|
|
3375
|
-
|
|
3465
|
+
log13("acquired lock", void 0, {
|
|
3466
|
+
F: __dxlog_file13,
|
|
3467
|
+
L: 44,
|
|
3468
|
+
S: this,
|
|
3469
|
+
C: (f, a) => f(...a)
|
|
3376
3470
|
});
|
|
3377
3471
|
} catch (e) {
|
|
3378
|
-
log13("stealing lock...",
|
|
3379
|
-
|
|
3380
|
-
|
|
3381
|
-
|
|
3382
|
-
|
|
3472
|
+
log13("stealing lock...", void 0, {
|
|
3473
|
+
F: __dxlog_file13,
|
|
3474
|
+
L: 46,
|
|
3475
|
+
S: this,
|
|
3476
|
+
C: (f, a) => f(...a)
|
|
3383
3477
|
});
|
|
3384
3478
|
await this._requestLock(true);
|
|
3385
|
-
log13("stolen lock",
|
|
3386
|
-
|
|
3387
|
-
|
|
3388
|
-
|
|
3389
|
-
|
|
3479
|
+
log13("stolen lock", void 0, {
|
|
3480
|
+
F: __dxlog_file13,
|
|
3481
|
+
L: 48,
|
|
3482
|
+
S: this,
|
|
3483
|
+
C: (f, a) => f(...a)
|
|
3390
3484
|
});
|
|
3391
3485
|
}
|
|
3392
3486
|
}
|
|
@@ -3402,10 +3496,10 @@ var Lock = class {
|
|
|
3402
3496
|
log13("requesting lock...", {
|
|
3403
3497
|
steal
|
|
3404
3498
|
}, {
|
|
3405
|
-
|
|
3406
|
-
|
|
3407
|
-
|
|
3408
|
-
|
|
3499
|
+
F: __dxlog_file13,
|
|
3500
|
+
L: 63,
|
|
3501
|
+
S: this,
|
|
3502
|
+
C: (f, a) => f(...a)
|
|
3409
3503
|
});
|
|
3410
3504
|
const acquired = new Trigger6();
|
|
3411
3505
|
void navigator.locks.request(this._lockKey, {
|
|
@@ -3416,18 +3510,18 @@ var Lock = class {
|
|
|
3416
3510
|
acquired.wake();
|
|
3417
3511
|
this._releaseTrigger = new Trigger6();
|
|
3418
3512
|
await this._releaseTrigger.wait();
|
|
3419
|
-
log13("releasing lock...",
|
|
3420
|
-
|
|
3421
|
-
|
|
3422
|
-
|
|
3423
|
-
|
|
3513
|
+
log13("releasing lock...", void 0, {
|
|
3514
|
+
F: __dxlog_file13,
|
|
3515
|
+
L: 72,
|
|
3516
|
+
S: this,
|
|
3517
|
+
C: (f, a) => f(...a)
|
|
3424
3518
|
});
|
|
3425
3519
|
await ((_b = this._onRelease) == null ? void 0 : _b.call(this));
|
|
3426
|
-
log13("released lock",
|
|
3427
|
-
|
|
3428
|
-
|
|
3429
|
-
|
|
3430
|
-
|
|
3520
|
+
log13("released lock", void 0, {
|
|
3521
|
+
F: __dxlog_file13,
|
|
3522
|
+
L: 74,
|
|
3523
|
+
S: this,
|
|
3524
|
+
C: (f, a) => f(...a)
|
|
3431
3525
|
});
|
|
3432
3526
|
}).catch(async () => {
|
|
3433
3527
|
var _a;
|
|
@@ -3437,14 +3531,14 @@ var Lock = class {
|
|
|
3437
3531
|
log13("recieved lock", {
|
|
3438
3532
|
steal
|
|
3439
3533
|
}, {
|
|
3440
|
-
|
|
3441
|
-
|
|
3442
|
-
|
|
3443
|
-
|
|
3534
|
+
F: __dxlog_file13,
|
|
3535
|
+
L: 81,
|
|
3536
|
+
S: this,
|
|
3537
|
+
C: (f, a) => f(...a)
|
|
3444
3538
|
});
|
|
3445
3539
|
}
|
|
3446
3540
|
};
|
|
3447
|
-
|
|
3541
|
+
_ts_decorate3([
|
|
3448
3542
|
logInfo
|
|
3449
3543
|
], Lock.prototype, "lockKey", null);
|
|
3450
3544
|
var isLocked = (lockPath) => {
|
|
@@ -3525,16 +3619,19 @@ var ServiceRegistry = class {
|
|
|
3525
3619
|
};
|
|
3526
3620
|
|
|
3527
3621
|
// packages/sdk/client-services/src/packlets/services/service-host.ts
|
|
3528
|
-
import
|
|
3529
|
-
import { Event as Event8, synchronized as
|
|
3530
|
-
import { clientServiceBundle
|
|
3622
|
+
import invariant12 from "tiny-invariant";
|
|
3623
|
+
import { Event as Event8, synchronized as synchronized3 } from "@dxos/async";
|
|
3624
|
+
import { clientServiceBundle } from "@dxos/client-protocol";
|
|
3625
|
+
import { DocumentModel } from "@dxos/document-model";
|
|
3531
3626
|
import { DataServiceImpl } from "@dxos/echo-pipeline";
|
|
3532
3627
|
import { PublicKey as PublicKey10 } from "@dxos/keys";
|
|
3533
3628
|
import { log as log15 } from "@dxos/log";
|
|
3534
3629
|
import { WebsocketSignalManager } from "@dxos/messaging";
|
|
3630
|
+
import { ModelFactory } from "@dxos/model-factory";
|
|
3535
3631
|
import { createWebRTCTransportFactory, NetworkManager } from "@dxos/network-manager";
|
|
3536
3632
|
import { trace as trace6 } from "@dxos/protocols";
|
|
3537
3633
|
import { SystemStatus } from "@dxos/protocols/proto/dxos/client/services";
|
|
3634
|
+
import { TextModel } from "@dxos/text-model";
|
|
3538
3635
|
|
|
3539
3636
|
// packages/sdk/client-services/src/packlets/devices/devices-service.ts
|
|
3540
3637
|
import { EventSubscriptions as EventSubscriptions3 } from "@dxos/async";
|
|
@@ -3610,7 +3707,7 @@ var LoggingServiceImpl = class {
|
|
|
3610
3707
|
if (LOG_PROCESSING > 0) {
|
|
3611
3708
|
return;
|
|
3612
3709
|
}
|
|
3613
|
-
if (((_a = entry2.meta) == null ? void 0 : _a.
|
|
3710
|
+
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
3711
|
return;
|
|
3615
3712
|
}
|
|
3616
3713
|
if (!shouldLog(entry2, request)) {
|
|
@@ -3622,8 +3719,8 @@ var LoggingServiceImpl = class {
|
|
|
3622
3719
|
timestamp: new Date(),
|
|
3623
3720
|
meta: {
|
|
3624
3721
|
// TODO(dmaretskyi): Fix proto.
|
|
3625
|
-
file: (_c = (_b = entry2.meta) == null ? void 0 : _b.
|
|
3626
|
-
line: (_e = (_d = entry2.meta) == null ? void 0 : _d.
|
|
3722
|
+
file: (_c = (_b = entry2.meta) == null ? void 0 : _b.F) != null ? _c : "",
|
|
3723
|
+
line: (_e = (_d = entry2.meta) == null ? void 0 : _d.L) != null ? _e : 0
|
|
3627
3724
|
}
|
|
3628
3725
|
};
|
|
3629
3726
|
try {
|
|
@@ -3653,7 +3750,7 @@ var shouldLog = (entry2, request) => {
|
|
|
3653
3750
|
} else {
|
|
3654
3751
|
return request.filters.some((filter) => {
|
|
3655
3752
|
var _a2, _b;
|
|
3656
|
-
return matchFilter(filter, entry2.level, (_b = (_a2 = entry2.meta) == null ? void 0 : _a2.
|
|
3753
|
+
return matchFilter(filter, entry2.level, (_b = (_a2 = entry2.meta) == null ? void 0 : _a2.F) != null ? _b : "", options);
|
|
3657
3754
|
});
|
|
3658
3755
|
}
|
|
3659
3756
|
};
|
|
@@ -3730,7 +3827,7 @@ var SystemServiceImpl = class {
|
|
|
3730
3827
|
};
|
|
3731
3828
|
|
|
3732
3829
|
// packages/sdk/client-services/src/packlets/services/service-host.ts
|
|
3733
|
-
|
|
3830
|
+
function _ts_decorate4(decorators, target, key, desc) {
|
|
3734
3831
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3735
3832
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
3736
3833
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -3739,6 +3836,10 @@ var __decorate4 = function(decorators, target, key, desc) {
|
|
|
3739
3836
|
if (d = decorators[i])
|
|
3740
3837
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
3741
3838
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3839
|
+
}
|
|
3840
|
+
var __dxlog_file14 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-host.ts";
|
|
3841
|
+
var createDefaultModelFactory = () => {
|
|
3842
|
+
return new ModelFactory().registerModel(DocumentModel).registerModel(TextModel);
|
|
3742
3843
|
};
|
|
3743
3844
|
var ClientServicesHost = class {
|
|
3744
3845
|
constructor({
|
|
@@ -3750,13 +3851,15 @@ var ClientServicesHost = class {
|
|
|
3750
3851
|
connectionLog,
|
|
3751
3852
|
storage,
|
|
3752
3853
|
// TODO(wittjosiah): Turn this on by default.
|
|
3753
|
-
lockKey
|
|
3854
|
+
lockKey,
|
|
3855
|
+
callbacks
|
|
3754
3856
|
} = {}) {
|
|
3755
3857
|
this._statusUpdate = new Event8();
|
|
3756
3858
|
this._opening = false;
|
|
3757
3859
|
this._open = false;
|
|
3758
3860
|
this._storage = storage;
|
|
3759
3861
|
this._modelFactory = modelFactory;
|
|
3862
|
+
this._callbacks = callbacks;
|
|
3760
3863
|
if (config) {
|
|
3761
3864
|
this.initialize({
|
|
3762
3865
|
config,
|
|
@@ -3815,9 +3918,9 @@ var ClientServicesHost = class {
|
|
|
3815
3918
|
*/
|
|
3816
3919
|
initialize({ config, ...options }) {
|
|
3817
3920
|
var _a, _b, _c;
|
|
3818
|
-
|
|
3921
|
+
invariant12(!this._open, "service host is open");
|
|
3819
3922
|
if (config) {
|
|
3820
|
-
|
|
3923
|
+
invariant12(!this._config, "config already set");
|
|
3821
3924
|
this._config = config;
|
|
3822
3925
|
if (!this._storage) {
|
|
3823
3926
|
this._storage = createStorageObjects(config.get("runtime.client.storage", {})).storage;
|
|
@@ -3827,7 +3930,7 @@ var ClientServicesHost = class {
|
|
|
3827
3930
|
iceServers: (_a = this._config) == null ? void 0 : _a.get("runtime.services.ice")
|
|
3828
3931
|
}), signalManager = new WebsocketSignalManager((_c = (_b = this._config) == null ? void 0 : _b.get("runtime.services.signaling")) != null ? _c : []) } = options;
|
|
3829
3932
|
this._signalManager = signalManager;
|
|
3830
|
-
|
|
3933
|
+
invariant12(!this._networkManager, "network manager already set");
|
|
3831
3934
|
this._networkManager = new NetworkManager({
|
|
3832
3935
|
log: connectionLog,
|
|
3833
3936
|
transportFactory,
|
|
@@ -3843,23 +3946,23 @@ var ClientServicesHost = class {
|
|
|
3843
3946
|
log15.trace("dxos.sdk.client-services-host.open", trace6.begin({
|
|
3844
3947
|
id: traceId
|
|
3845
3948
|
}), {
|
|
3846
|
-
|
|
3847
|
-
|
|
3848
|
-
|
|
3849
|
-
|
|
3850
|
-
});
|
|
3851
|
-
|
|
3852
|
-
|
|
3853
|
-
|
|
3854
|
-
|
|
3949
|
+
F: __dxlog_file14,
|
|
3950
|
+
L: 203,
|
|
3951
|
+
S: this,
|
|
3952
|
+
C: (f, a) => f(...a)
|
|
3953
|
+
});
|
|
3954
|
+
invariant12(this._config, "config not set");
|
|
3955
|
+
invariant12(this._storage, "storage not set");
|
|
3956
|
+
invariant12(this._signalManager, "signal manager not set");
|
|
3957
|
+
invariant12(this._networkManager, "network manager not set");
|
|
3855
3958
|
this._opening = true;
|
|
3856
3959
|
log15("opening...", {
|
|
3857
3960
|
lockKey: (_a = this._resourceLock) == null ? void 0 : _a.lockKey
|
|
3858
3961
|
}, {
|
|
3859
|
-
|
|
3860
|
-
|
|
3861
|
-
|
|
3862
|
-
|
|
3962
|
+
F: __dxlog_file14,
|
|
3963
|
+
L: 211,
|
|
3964
|
+
S: this,
|
|
3965
|
+
C: (f, a) => f(...a)
|
|
3863
3966
|
});
|
|
3864
3967
|
await ((_b = this._resourceLock) == null ? void 0 : _b.acquire());
|
|
3865
3968
|
await this._loggingService.open();
|
|
@@ -3891,18 +3994,18 @@ var ClientServicesHost = class {
|
|
|
3891
3994
|
log15("opened", {
|
|
3892
3995
|
deviceKey
|
|
3893
3996
|
}, {
|
|
3894
|
-
|
|
3895
|
-
|
|
3896
|
-
|
|
3897
|
-
|
|
3997
|
+
F: __dxlog_file14,
|
|
3998
|
+
L: 266,
|
|
3999
|
+
S: this,
|
|
4000
|
+
C: (f, a) => f(...a)
|
|
3898
4001
|
});
|
|
3899
4002
|
log15.trace("dxos.sdk.client-services-host.open", trace6.end({
|
|
3900
4003
|
id: traceId
|
|
3901
4004
|
}), {
|
|
3902
|
-
|
|
3903
|
-
|
|
3904
|
-
|
|
3905
|
-
|
|
4005
|
+
F: __dxlog_file14,
|
|
4006
|
+
L: 267,
|
|
4007
|
+
S: this,
|
|
4008
|
+
C: (f, a) => f(...a)
|
|
3906
4009
|
});
|
|
3907
4010
|
}
|
|
3908
4011
|
async close() {
|
|
@@ -3914,10 +4017,10 @@ var ClientServicesHost = class {
|
|
|
3914
4017
|
log15("closing...", {
|
|
3915
4018
|
deviceKey
|
|
3916
4019
|
}, {
|
|
3917
|
-
|
|
3918
|
-
|
|
3919
|
-
|
|
3920
|
-
|
|
4020
|
+
F: __dxlog_file14,
|
|
4021
|
+
L: 277,
|
|
4022
|
+
S: this,
|
|
4023
|
+
C: (f, a) => f(...a)
|
|
3921
4024
|
});
|
|
3922
4025
|
this._serviceRegistry.setServices({
|
|
3923
4026
|
SystemService: this._systemService
|
|
@@ -3929,52 +4032,53 @@ var ClientServicesHost = class {
|
|
|
3929
4032
|
log15("closed", {
|
|
3930
4033
|
deviceKey
|
|
3931
4034
|
}, {
|
|
3932
|
-
|
|
3933
|
-
|
|
3934
|
-
|
|
3935
|
-
|
|
4035
|
+
F: __dxlog_file14,
|
|
4036
|
+
L: 283,
|
|
4037
|
+
S: this,
|
|
4038
|
+
C: (f, a) => f(...a)
|
|
3936
4039
|
});
|
|
3937
4040
|
}
|
|
3938
4041
|
async reset() {
|
|
3939
|
-
var _a;
|
|
4042
|
+
var _a, _b, _c;
|
|
3940
4043
|
const traceId = PublicKey10.random().toHex();
|
|
3941
4044
|
log15.trace("dxos.sdk.client-services-host.reset", trace6.begin({
|
|
3942
4045
|
id: traceId
|
|
3943
4046
|
}), {
|
|
3944
|
-
|
|
3945
|
-
|
|
3946
|
-
|
|
3947
|
-
|
|
4047
|
+
F: __dxlog_file14,
|
|
4048
|
+
L: 288,
|
|
4049
|
+
S: this,
|
|
4050
|
+
C: (f, a) => f(...a)
|
|
3948
4051
|
});
|
|
3949
|
-
log15("resetting...",
|
|
3950
|
-
|
|
3951
|
-
|
|
3952
|
-
|
|
3953
|
-
|
|
4052
|
+
log15("resetting...", void 0, {
|
|
4053
|
+
F: __dxlog_file14,
|
|
4054
|
+
L: 290,
|
|
4055
|
+
S: this,
|
|
4056
|
+
C: (f, a) => f(...a)
|
|
3954
4057
|
});
|
|
3955
4058
|
await ((_a = this._serviceContext) == null ? void 0 : _a.close());
|
|
3956
4059
|
await this._storage.reset();
|
|
3957
|
-
log15("reset",
|
|
3958
|
-
|
|
3959
|
-
|
|
3960
|
-
|
|
3961
|
-
|
|
4060
|
+
log15("reset", void 0, {
|
|
4061
|
+
F: __dxlog_file14,
|
|
4062
|
+
L: 293,
|
|
4063
|
+
S: this,
|
|
4064
|
+
C: (f, a) => f(...a)
|
|
3962
4065
|
});
|
|
3963
4066
|
log15.trace("dxos.sdk.client-services-host.reset", trace6.end({
|
|
3964
4067
|
id: traceId
|
|
3965
4068
|
}), {
|
|
3966
|
-
|
|
3967
|
-
|
|
3968
|
-
|
|
3969
|
-
|
|
4069
|
+
F: __dxlog_file14,
|
|
4070
|
+
L: 294,
|
|
4071
|
+
S: this,
|
|
4072
|
+
C: (f, a) => f(...a)
|
|
3970
4073
|
});
|
|
4074
|
+
await ((_c = (_b = this._callbacks) == null ? void 0 : _b.onReset) == null ? void 0 : _c.call(_b));
|
|
3971
4075
|
}
|
|
3972
4076
|
};
|
|
3973
|
-
|
|
3974
|
-
|
|
4077
|
+
_ts_decorate4([
|
|
4078
|
+
synchronized3
|
|
3975
4079
|
], ClientServicesHost.prototype, "open", null);
|
|
3976
|
-
|
|
3977
|
-
|
|
4080
|
+
_ts_decorate4([
|
|
4081
|
+
synchronized3
|
|
3978
4082
|
], ClientServicesHost.prototype, "close", null);
|
|
3979
4083
|
|
|
3980
4084
|
export {
|
|
@@ -4005,6 +4109,7 @@ export {
|
|
|
4005
4109
|
isLocked,
|
|
4006
4110
|
createStorageObjects,
|
|
4007
4111
|
ServiceRegistry,
|
|
4112
|
+
createDefaultModelFactory,
|
|
4008
4113
|
ClientServicesHost
|
|
4009
4114
|
};
|
|
4010
|
-
//# sourceMappingURL=chunk-
|
|
4115
|
+
//# sourceMappingURL=chunk-3EI4PM2V.mjs.map
|