@dxos/client-services 0.3.2-main.48c28c7 → 0.3.2-main.988f99c
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-AUQLXFE6.mjs → chunk-3GWSYNJC.mjs} +141 -69
- package/dist/lib/browser/chunk-3GWSYNJC.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +1 -1
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/packlets/testing/index.mjs +1 -1
- package/dist/lib/node/index.cjs +200 -128
- 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 +174 -102
- package/dist/lib/node/packlets/testing/index.cjs.map +3 -3
- package/dist/types/src/packlets/devices/devices-service.d.ts +1 -1
- package/dist/types/src/packlets/devices/devices-service.d.ts.map +1 -1
- package/dist/types/src/packlets/identity/identity-manager.d.ts +4 -0
- package/dist/types/src/packlets/identity/identity-manager.d.ts.map +1 -1
- package/dist/types/src/packlets/identity/identity.d.ts +2 -2
- package/dist/types/src/packlets/identity/identity.d.ts.map +1 -1
- package/dist/types/src/version.d.ts +1 -1
- package/package.json +35 -35
- package/src/packlets/devices/devices-service.ts +16 -3
- package/src/packlets/identity/identity-manager.test.ts +11 -0
- package/src/packlets/identity/identity-manager.ts +20 -0
- package/src/packlets/identity/identity.test.ts +2 -2
- package/src/packlets/identity/identity.ts +5 -3
- package/src/version.ts +1 -1
- package/dist/lib/browser/chunk-AUQLXFE6.mjs.map +0 -7
|
@@ -460,9 +460,11 @@ import { DeviceStateMachine, createCredentialSignerWithKey, createCredentialSign
|
|
|
460
460
|
import { failUndefined } from "@dxos/debug";
|
|
461
461
|
import { writeMessages } from "@dxos/feed-store";
|
|
462
462
|
import { invariant } from "@dxos/invariant";
|
|
463
|
+
import { PublicKey as PublicKey3 } from "@dxos/keys";
|
|
463
464
|
import { log as log2 } from "@dxos/log";
|
|
464
465
|
import { AdmittedFeed } from "@dxos/protocols/proto/dxos/halo/credentials";
|
|
465
466
|
import { trace } from "@dxos/tracing";
|
|
467
|
+
import { ComplexSet } from "@dxos/util";
|
|
466
468
|
function _ts_decorate(decorators, target, key, desc) {
|
|
467
469
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
468
470
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
@@ -481,6 +483,14 @@ var Identity = class Identity2 {
|
|
|
481
483
|
this._signer = signer;
|
|
482
484
|
this.identityKey = identityKey;
|
|
483
485
|
this.deviceKey = deviceKey;
|
|
486
|
+
log2.trace("dxos.halo.device", {
|
|
487
|
+
deviceKey
|
|
488
|
+
}, {
|
|
489
|
+
F: __dxlog_file2,
|
|
490
|
+
L: 60,
|
|
491
|
+
S: this,
|
|
492
|
+
C: (f, a) => f(...a)
|
|
493
|
+
});
|
|
484
494
|
this._deviceStateMachine = new DeviceStateMachine({
|
|
485
495
|
identityKey: this.identityKey,
|
|
486
496
|
deviceKey: this.deviceKey,
|
|
@@ -491,7 +501,7 @@ var Identity = class Identity2 {
|
|
|
491
501
|
onUpdate: () => this.stateUpdate.emit()
|
|
492
502
|
});
|
|
493
503
|
this.authVerifier = new TrustedKeySetAuthVerifier({
|
|
494
|
-
trustedKeysProvider: () => this.authorizedDeviceKeys,
|
|
504
|
+
trustedKeysProvider: () => new ComplexSet(PublicKey3.hash, this.authorizedDeviceKeys.keys()),
|
|
495
505
|
update: this.stateUpdate,
|
|
496
506
|
authTimeout: AUTH_TIMEOUT
|
|
497
507
|
});
|
|
@@ -549,7 +559,7 @@ var Identity = class Identity2 {
|
|
|
549
559
|
getIdentityCredentialSigner() {
|
|
550
560
|
invariant(this._deviceStateMachine.deviceCredentialChain, "Device credential chain is not ready.", {
|
|
551
561
|
F: __dxlog_file2,
|
|
552
|
-
L:
|
|
562
|
+
L: 141,
|
|
553
563
|
S: this,
|
|
554
564
|
A: [
|
|
555
565
|
"this._deviceStateMachine.deviceCredentialChain",
|
|
@@ -573,7 +583,7 @@ var Identity = class Identity2 {
|
|
|
573
583
|
dataFeedKey
|
|
574
584
|
}, {
|
|
575
585
|
F: __dxlog_file2,
|
|
576
|
-
L:
|
|
586
|
+
L: 157,
|
|
577
587
|
S: this,
|
|
578
588
|
C: (f, a) => f(...a)
|
|
579
589
|
});
|
|
@@ -629,7 +639,7 @@ import { Event as Event2 } from "@dxos/async";
|
|
|
629
639
|
import { Context as Context3 } from "@dxos/context";
|
|
630
640
|
import { createCredentialSignerWithKey as createCredentialSignerWithKey2, CredentialGenerator } from "@dxos/credentials";
|
|
631
641
|
import { invariant as invariant2 } from "@dxos/invariant";
|
|
632
|
-
import { PublicKey as
|
|
642
|
+
import { PublicKey as PublicKey4 } from "@dxos/keys";
|
|
633
643
|
import { log as log3 } from "@dxos/log";
|
|
634
644
|
import { trace as trace2 } from "@dxos/protocols";
|
|
635
645
|
import { AdmittedFeed as AdmittedFeed2 } from "@dxos/protocols/proto/dxos/halo/credentials";
|
|
@@ -661,7 +671,7 @@ var IdentityManager = class IdentityManager2 {
|
|
|
661
671
|
return this._identity;
|
|
662
672
|
}
|
|
663
673
|
async open(ctx) {
|
|
664
|
-
const traceId =
|
|
674
|
+
const traceId = PublicKey4.random().toHex();
|
|
665
675
|
log3.trace("dxos.halo.identity-manager.open", trace2.begin({
|
|
666
676
|
id: traceId
|
|
667
677
|
}), {
|
|
@@ -891,10 +901,51 @@ var IdentityManager = class IdentityManager2 {
|
|
|
891
901
|
this.stateUpdate.emit();
|
|
892
902
|
return profile;
|
|
893
903
|
}
|
|
904
|
+
async updateDevice({ deviceKey, profile }) {
|
|
905
|
+
invariant2(this._identity, "Identity not initialized.", {
|
|
906
|
+
F: __dxlog_file3,
|
|
907
|
+
L: 216,
|
|
908
|
+
S: this,
|
|
909
|
+
A: [
|
|
910
|
+
"this._identity",
|
|
911
|
+
"'Identity not initialized.'"
|
|
912
|
+
]
|
|
913
|
+
});
|
|
914
|
+
invariant2(this._identity.authorizedDeviceKeys.has(deviceKey), "Device not authorized.", {
|
|
915
|
+
F: __dxlog_file3,
|
|
916
|
+
L: 218,
|
|
917
|
+
S: this,
|
|
918
|
+
A: [
|
|
919
|
+
"this._identity.authorizedDeviceKeys.has(deviceKey)",
|
|
920
|
+
"'Device not authorized.'"
|
|
921
|
+
]
|
|
922
|
+
});
|
|
923
|
+
const credential = await this._identity.getIdentityCredentialSigner().createCredential({
|
|
924
|
+
subject: this._identity.identityKey,
|
|
925
|
+
assertion: {
|
|
926
|
+
"@type": "dxos.halo.credentials.DeviceProfile",
|
|
927
|
+
deviceKey,
|
|
928
|
+
profile
|
|
929
|
+
}
|
|
930
|
+
});
|
|
931
|
+
const receipt = await this._identity.controlPipeline.writer.write({
|
|
932
|
+
credential: {
|
|
933
|
+
credential
|
|
934
|
+
}
|
|
935
|
+
});
|
|
936
|
+
await this._identity.controlPipeline.state.waitUntilTimeframe(new Timeframe([
|
|
937
|
+
[
|
|
938
|
+
receipt.feedKey,
|
|
939
|
+
receipt.seq
|
|
940
|
+
]
|
|
941
|
+
]));
|
|
942
|
+
this.stateUpdate.emit();
|
|
943
|
+
return profile;
|
|
944
|
+
}
|
|
894
945
|
async _constructIdentity(identityRecord) {
|
|
895
946
|
invariant2(!this._identity, void 0, {
|
|
896
947
|
F: __dxlog_file3,
|
|
897
|
-
L:
|
|
948
|
+
L: 236,
|
|
898
949
|
S: this,
|
|
899
950
|
A: [
|
|
900
951
|
"!this._identity",
|
|
@@ -905,13 +956,13 @@ var IdentityManager = class IdentityManager2 {
|
|
|
905
956
|
identityRecord
|
|
906
957
|
}, {
|
|
907
958
|
F: __dxlog_file3,
|
|
908
|
-
L:
|
|
959
|
+
L: 237,
|
|
909
960
|
S: this,
|
|
910
961
|
C: (f, a) => f(...a)
|
|
911
962
|
});
|
|
912
963
|
invariant2(identityRecord.haloSpace.controlFeedKey, void 0, {
|
|
913
964
|
F: __dxlog_file3,
|
|
914
|
-
L:
|
|
965
|
+
L: 240,
|
|
915
966
|
S: this,
|
|
916
967
|
A: [
|
|
917
968
|
"identityRecord.haloSpace.controlFeedKey",
|
|
@@ -923,7 +974,7 @@ var IdentityManager = class IdentityManager2 {
|
|
|
923
974
|
});
|
|
924
975
|
invariant2(identityRecord.haloSpace.dataFeedKey, void 0, {
|
|
925
976
|
F: __dxlog_file3,
|
|
926
|
-
L:
|
|
977
|
+
L: 244,
|
|
927
978
|
S: this,
|
|
928
979
|
A: [
|
|
929
980
|
"identityRecord.haloSpace.dataFeedKey",
|
|
@@ -955,7 +1006,7 @@ var IdentityManager = class IdentityManager2 {
|
|
|
955
1006
|
identityKey: identityRecord.identityKey
|
|
956
1007
|
}, {
|
|
957
1008
|
F: __dxlog_file3,
|
|
958
|
-
L:
|
|
1009
|
+
L: 268,
|
|
959
1010
|
S: this,
|
|
960
1011
|
C: (f, a) => f(...a)
|
|
961
1012
|
});
|
|
@@ -976,7 +1027,7 @@ var IdentityManager = class IdentityManager2 {
|
|
|
976
1027
|
onAuthFailure: () => {
|
|
977
1028
|
log3.warn("auth failure", void 0, {
|
|
978
1029
|
F: __dxlog_file3,
|
|
979
|
-
L:
|
|
1030
|
+
L: 287,
|
|
980
1031
|
S: this,
|
|
981
1032
|
C: (f, a) => f(...a)
|
|
982
1033
|
});
|
|
@@ -1161,7 +1212,7 @@ import { AuthenticatingInvitation, AUTHENTICATION_CODE_LENGTH, CancellableInvita
|
|
|
1161
1212
|
import { Context as Context5 } from "@dxos/context";
|
|
1162
1213
|
import { generatePasscode } from "@dxos/credentials";
|
|
1163
1214
|
import { invariant as invariant6 } from "@dxos/invariant";
|
|
1164
|
-
import { PublicKey as
|
|
1215
|
+
import { PublicKey as PublicKey6 } from "@dxos/keys";
|
|
1165
1216
|
import { log as log5 } from "@dxos/log";
|
|
1166
1217
|
import { createTeleportProtocolFactory, StarTopology } from "@dxos/network-manager";
|
|
1167
1218
|
import { InvalidInvitationExtensionRoleError as InvalidInvitationExtensionRoleError2, trace as trace4 } from "@dxos/protocols";
|
|
@@ -1172,7 +1223,7 @@ import { AuthenticationResponse as AuthenticationResponse2 } from "@dxos/protoco
|
|
|
1172
1223
|
import { Trigger as Trigger2 } from "@dxos/async";
|
|
1173
1224
|
import { cancelWithContext, Context as Context4 } from "@dxos/context";
|
|
1174
1225
|
import { invariant as invariant5 } from "@dxos/invariant";
|
|
1175
|
-
import { PublicKey as
|
|
1226
|
+
import { PublicKey as PublicKey5 } from "@dxos/keys";
|
|
1176
1227
|
import { log as log4 } from "@dxos/log";
|
|
1177
1228
|
import { InvalidInvitationExtensionRoleError, schema as schema2, trace as trace3 } from "@dxos/protocols";
|
|
1178
1229
|
import { Invitation as Invitation2 } from "@dxos/protocols/proto/dxos/client/services";
|
|
@@ -1220,7 +1271,7 @@ var InvitationHostExtension = class extends RpcExtension {
|
|
|
1220
1271
|
},
|
|
1221
1272
|
introduce: async (request) => {
|
|
1222
1273
|
const { profile, invitationId } = request;
|
|
1223
|
-
const traceId =
|
|
1274
|
+
const traceId = PublicKey5.random().toHex();
|
|
1224
1275
|
log4.trace("dxos.sdk.invitation-handler.host.introduce", trace3.begin({
|
|
1225
1276
|
id: traceId
|
|
1226
1277
|
}), {
|
|
@@ -1272,7 +1323,7 @@ var InvitationHostExtension = class extends RpcExtension {
|
|
|
1272
1323
|
};
|
|
1273
1324
|
},
|
|
1274
1325
|
authenticate: async ({ authCode: code }) => {
|
|
1275
|
-
const traceId =
|
|
1326
|
+
const traceId = PublicKey5.random().toHex();
|
|
1276
1327
|
log4.trace("dxos.sdk.invitation-handler.host.authenticate", trace3.begin({
|
|
1277
1328
|
id: traceId
|
|
1278
1329
|
}), {
|
|
@@ -1352,7 +1403,7 @@ var InvitationHostExtension = class extends RpcExtension {
|
|
|
1352
1403
|
};
|
|
1353
1404
|
},
|
|
1354
1405
|
admit: async (request) => {
|
|
1355
|
-
const traceId =
|
|
1406
|
+
const traceId = PublicKey5.random().toHex();
|
|
1356
1407
|
log4.trace("dxos.sdk.invitation-handler.host.admit", trace3.begin({
|
|
1357
1408
|
id: traceId
|
|
1358
1409
|
}), {
|
|
@@ -1518,7 +1569,7 @@ var InvitationsHandler = class {
|
|
|
1518
1569
|
this._networkManager = _networkManager;
|
|
1519
1570
|
}
|
|
1520
1571
|
createInvitation(protocol, options) {
|
|
1521
|
-
const { invitationId =
|
|
1572
|
+
const { invitationId = PublicKey6.random().toHex(), type = Invitation3.Type.INTERACTIVE, authMethod = Invitation3.AuthMethod.SHARED_SECRET, state = Invitation3.State.INIT, timeout = INVITATION_TIMEOUT, swarmKey = PublicKey6.random() } = options ?? {};
|
|
1522
1573
|
const authCode = options?.authCode ?? (authMethod === Invitation3.AuthMethod.SHARED_SECRET ? generatePasscode(AUTHENTICATION_CODE_LENGTH) : void 0);
|
|
1523
1574
|
invariant6(protocol, void 0, {
|
|
1524
1575
|
F: __dxlog_file7,
|
|
@@ -1593,7 +1644,7 @@ var InvitationsHandler = class {
|
|
|
1593
1644
|
},
|
|
1594
1645
|
onOpen: () => {
|
|
1595
1646
|
scheduleTask2(ctx, async () => {
|
|
1596
|
-
const traceId =
|
|
1647
|
+
const traceId = PublicKey6.random().toHex();
|
|
1597
1648
|
try {
|
|
1598
1649
|
log5.trace("dxos.sdk.invitations-handler.host.onOpen", trace4.begin({
|
|
1599
1650
|
id: traceId
|
|
@@ -1826,7 +1877,7 @@ var InvitationsHandler = class {
|
|
|
1826
1877
|
}
|
|
1827
1878
|
});
|
|
1828
1879
|
scheduleTask2(ctx, async () => {
|
|
1829
|
-
const traceId =
|
|
1880
|
+
const traceId = PublicKey6.random().toHex();
|
|
1830
1881
|
try {
|
|
1831
1882
|
log5.trace("dxos.sdk.invitations-handler.guest.onOpen", trace4.begin({
|
|
1832
1883
|
id: traceId
|
|
@@ -2033,7 +2084,7 @@ var InvitationsHandler = class {
|
|
|
2033
2084
|
const topic = invitation.swarmKey;
|
|
2034
2085
|
const swarmConnection = await this._networkManager.joinSwarm({
|
|
2035
2086
|
topic,
|
|
2036
|
-
peerId:
|
|
2087
|
+
peerId: PublicKey6.random(),
|
|
2037
2088
|
protocolProvider: createTeleportProtocolFactory(async (teleport) => {
|
|
2038
2089
|
teleport.addExtension("dxos.halo.invitations", createExtension());
|
|
2039
2090
|
}),
|
|
@@ -2498,7 +2549,7 @@ var getPlatform = () => {
|
|
|
2498
2549
|
};
|
|
2499
2550
|
|
|
2500
2551
|
// packages/sdk/client-services/src/version.ts
|
|
2501
|
-
var DXOS_VERSION = "0.3.2-main.
|
|
2552
|
+
var DXOS_VERSION = "0.3.2-main.988f99c";
|
|
2502
2553
|
|
|
2503
2554
|
// packages/sdk/client-services/src/packlets/services/diagnostics.ts
|
|
2504
2555
|
var __dxlog_file10 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/diagnostics.ts";
|
|
@@ -2624,24 +2675,24 @@ import { AUTH_TIMEOUT as AUTH_TIMEOUT2 } from "@dxos/client-protocol";
|
|
|
2624
2675
|
import { cancelWithContext as cancelWithContext2, Context as Context7 } from "@dxos/context";
|
|
2625
2676
|
import { timed } from "@dxos/debug";
|
|
2626
2677
|
import { createMappedFeedWriter } from "@dxos/echo-pipeline";
|
|
2627
|
-
import { PublicKey as
|
|
2678
|
+
import { PublicKey as PublicKey8 } from "@dxos/keys";
|
|
2628
2679
|
import { log as log10 } from "@dxos/log";
|
|
2629
2680
|
import { CancelledError, SystemError } from "@dxos/protocols";
|
|
2630
2681
|
import { SpaceState } from "@dxos/protocols/proto/dxos/client/services";
|
|
2631
2682
|
import { AdmittedFeed as AdmittedFeed3 } from "@dxos/protocols/proto/dxos/halo/credentials";
|
|
2632
2683
|
import { Timeframe as Timeframe2 } from "@dxos/timeframe";
|
|
2633
2684
|
import { trace as trace5 } from "@dxos/tracing";
|
|
2634
|
-
import { ComplexSet as
|
|
2685
|
+
import { ComplexSet as ComplexSet3 } from "@dxos/util";
|
|
2635
2686
|
|
|
2636
2687
|
// packages/sdk/client-services/src/packlets/spaces/notarization-plugin.ts
|
|
2637
2688
|
import { DeferredTask, Event as Event4, scheduleTask as scheduleTask3, sleep, TimeoutError as TimeoutError2, Trigger as Trigger4 } from "@dxos/async";
|
|
2638
2689
|
import { Context as Context6, rejectOnDispose } from "@dxos/context";
|
|
2639
2690
|
import { invariant as invariant10 } from "@dxos/invariant";
|
|
2640
|
-
import { PublicKey as
|
|
2691
|
+
import { PublicKey as PublicKey7 } from "@dxos/keys";
|
|
2641
2692
|
import { log as log9 } from "@dxos/log";
|
|
2642
2693
|
import { schema as schema3 } from "@dxos/protocols";
|
|
2643
2694
|
import { RpcExtension as RpcExtension2 } from "@dxos/teleport";
|
|
2644
|
-
import { ComplexMap as ComplexMap2, ComplexSet, entry } from "@dxos/util";
|
|
2695
|
+
import { ComplexMap as ComplexMap2, ComplexSet as ComplexSet2, entry } from "@dxos/util";
|
|
2645
2696
|
var __dxlog_file11 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/notarization-plugin.ts";
|
|
2646
2697
|
var DEFAULT_RETRY_TIMEOUT = 1e3;
|
|
2647
2698
|
var DEFAULT_SUCCESS_DELAY = 1e3;
|
|
@@ -2652,8 +2703,8 @@ var NotarizationPlugin = class {
|
|
|
2652
2703
|
this._ctx = new Context6();
|
|
2653
2704
|
this._extensionOpened = new Event4();
|
|
2654
2705
|
this._extensions = /* @__PURE__ */ new Set();
|
|
2655
|
-
this._processedCredentials = new
|
|
2656
|
-
this._processCredentialsTriggers = new ComplexMap2(
|
|
2706
|
+
this._processedCredentials = new ComplexSet2(PublicKey7.hash);
|
|
2707
|
+
this._processCredentialsTriggers = new ComplexMap2(PublicKey7.hash);
|
|
2657
2708
|
}
|
|
2658
2709
|
get hasWriter() {
|
|
2659
2710
|
return !!this._writer;
|
|
@@ -2935,7 +2986,7 @@ var DataSpace = class DataSpace2 {
|
|
|
2935
2986
|
this._signingContext = params.signingContext;
|
|
2936
2987
|
this._callbacks = params.callbacks ?? {};
|
|
2937
2988
|
this.authVerifier = new TrustedKeySetAuthVerifier({
|
|
2938
|
-
trustedKeysProvider: () => new
|
|
2989
|
+
trustedKeysProvider: () => new ComplexSet3(PublicKey8.hash, Array.from(this._inner.spaceState.members.values()).filter((member) => !member.removed).map((member) => member.key)),
|
|
2939
2990
|
update: this._inner.stateUpdate,
|
|
2940
2991
|
authTimeout: AUTH_TIMEOUT2
|
|
2941
2992
|
});
|
|
@@ -3268,7 +3319,7 @@ import { Event as Event6, synchronized as synchronized2, trackLeaks as trackLeak
|
|
|
3268
3319
|
import { cancelWithContext as cancelWithContext3, Context as Context8 } from "@dxos/context";
|
|
3269
3320
|
import { getCredentialAssertion as getCredentialAssertion2 } from "@dxos/credentials";
|
|
3270
3321
|
import { invariant as invariant11 } from "@dxos/invariant";
|
|
3271
|
-
import { PublicKey as
|
|
3322
|
+
import { PublicKey as PublicKey9 } from "@dxos/keys";
|
|
3272
3323
|
import { log as log11 } from "@dxos/log";
|
|
3273
3324
|
import { trace as trace6 } from "@dxos/protocols";
|
|
3274
3325
|
import { SpaceState as SpaceState2 } from "@dxos/protocols/proto/dxos/client/services";
|
|
@@ -3366,9 +3417,9 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
3366
3417
|
this._feedStore = _feedStore;
|
|
3367
3418
|
this._ctx = new Context8();
|
|
3368
3419
|
this.updated = new Event6();
|
|
3369
|
-
this._spaces = new ComplexMap3(
|
|
3420
|
+
this._spaces = new ComplexMap3(PublicKey9.hash);
|
|
3370
3421
|
this._isOpen = false;
|
|
3371
|
-
this._instanceId =
|
|
3422
|
+
this._instanceId = PublicKey9.random().toHex();
|
|
3372
3423
|
}
|
|
3373
3424
|
// TODO(burdon): Remove.
|
|
3374
3425
|
get spaces() {
|
|
@@ -3907,7 +3958,7 @@ import { valueEncoding, MetadataStore, SpaceManager, DataServiceSubscriptions, S
|
|
|
3907
3958
|
import { FeedFactory, FeedStore } from "@dxos/feed-store";
|
|
3908
3959
|
import { invariant as invariant13 } from "@dxos/invariant";
|
|
3909
3960
|
import { Keyring } from "@dxos/keyring";
|
|
3910
|
-
import { PublicKey as
|
|
3961
|
+
import { PublicKey as PublicKey10 } from "@dxos/keys";
|
|
3911
3962
|
import { log as log13 } from "@dxos/log";
|
|
3912
3963
|
import { InvalidStorageVersionError, STORAGE_VERSION as STORAGE_VERSION2, trace as trace7 } from "@dxos/protocols";
|
|
3913
3964
|
import { Invitation as Invitation6 } from "@dxos/protocols/proto/dxos/client/services";
|
|
@@ -3934,7 +3985,7 @@ var ServiceContext = class ServiceContext2 {
|
|
|
3934
3985
|
this.initialized = new Trigger5();
|
|
3935
3986
|
this.dataServiceSubscriptions = new DataServiceSubscriptions();
|
|
3936
3987
|
this._handlerFactories = /* @__PURE__ */ new Map();
|
|
3937
|
-
this._instanceId =
|
|
3988
|
+
this._instanceId = PublicKey10.random().toHex();
|
|
3938
3989
|
this.metadataStore = new MetadataStore(storage.createDirectory("metadata"));
|
|
3939
3990
|
this.snapshotStore = new SnapshotStore(storage.createDirectory("snapshots"));
|
|
3940
3991
|
this.blobStore = new BlobStore(storage.createDirectory("blobs"));
|
|
@@ -4363,8 +4414,8 @@ import { Context as Context10 } from "@dxos/context";
|
|
|
4363
4414
|
import { DocumentModel as DocumentModel2 } from "@dxos/document-model";
|
|
4364
4415
|
import { DataServiceImpl } from "@dxos/echo-pipeline";
|
|
4365
4416
|
import { base } from "@dxos/echo-schema";
|
|
4366
|
-
import { invariant as
|
|
4367
|
-
import { PublicKey as
|
|
4417
|
+
import { invariant as invariant15 } from "@dxos/invariant";
|
|
4418
|
+
import { PublicKey as PublicKey11 } from "@dxos/keys";
|
|
4368
4419
|
import { log as log16 } from "@dxos/log";
|
|
4369
4420
|
import { WebsocketSignalManager } from "@dxos/messaging";
|
|
4370
4421
|
import { ModelFactory } from "@dxos/model-factory";
|
|
@@ -4378,13 +4429,33 @@ import { WebsocketRpcClient } from "@dxos/websocket-rpc";
|
|
|
4378
4429
|
// packages/sdk/client-services/src/packlets/devices/devices-service.ts
|
|
4379
4430
|
import { EventSubscriptions as EventSubscriptions3 } from "@dxos/async";
|
|
4380
4431
|
import { Stream as Stream11 } from "@dxos/codec-protobuf";
|
|
4432
|
+
import { invariant as invariant14 } from "@dxos/invariant";
|
|
4381
4433
|
import { DeviceKind } from "@dxos/protocols/proto/dxos/client/services";
|
|
4434
|
+
var __dxlog_file17 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/devices/devices-service.ts";
|
|
4382
4435
|
var DevicesServiceImpl = class {
|
|
4383
4436
|
constructor(_identityManager) {
|
|
4384
4437
|
this._identityManager = _identityManager;
|
|
4385
4438
|
}
|
|
4386
|
-
updateDevice(
|
|
4387
|
-
|
|
4439
|
+
async updateDevice(profile) {
|
|
4440
|
+
invariant14(this._identityManager.identity, "Identity not initialized", {
|
|
4441
|
+
F: __dxlog_file17,
|
|
4442
|
+
L: 17,
|
|
4443
|
+
S: this,
|
|
4444
|
+
A: [
|
|
4445
|
+
"this._identityManager.identity",
|
|
4446
|
+
"'Identity not initialized'"
|
|
4447
|
+
]
|
|
4448
|
+
});
|
|
4449
|
+
const deviceKey = this._identityManager.identity.deviceKey;
|
|
4450
|
+
await this._identityManager.updateDevice({
|
|
4451
|
+
deviceKey,
|
|
4452
|
+
profile
|
|
4453
|
+
});
|
|
4454
|
+
return {
|
|
4455
|
+
deviceKey,
|
|
4456
|
+
kind: DeviceKind.CURRENT,
|
|
4457
|
+
profile
|
|
4458
|
+
};
|
|
4388
4459
|
}
|
|
4389
4460
|
queryDevices() {
|
|
4390
4461
|
return new Stream11(({ next }) => {
|
|
@@ -4396,9 +4467,10 @@ var DevicesServiceImpl = class {
|
|
|
4396
4467
|
});
|
|
4397
4468
|
} else {
|
|
4398
4469
|
next({
|
|
4399
|
-
devices: Array.from(deviceKeys.
|
|
4470
|
+
devices: Array.from(deviceKeys.entries()).map(([key, profile]) => ({
|
|
4400
4471
|
deviceKey: key,
|
|
4401
|
-
kind: this._identityManager.identity?.deviceKey.equals(key) ? DeviceKind.CURRENT : DeviceKind.TRUSTED
|
|
4472
|
+
kind: this._identityManager.identity?.deviceKey.equals(key) ? DeviceKind.CURRENT : DeviceKind.TRUSTED,
|
|
4473
|
+
profile
|
|
4402
4474
|
}))
|
|
4403
4475
|
});
|
|
4404
4476
|
}
|
|
@@ -4632,7 +4704,7 @@ function _ts_decorate7(decorators, target, key, desc) {
|
|
|
4632
4704
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
4633
4705
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4634
4706
|
}
|
|
4635
|
-
var
|
|
4707
|
+
var __dxlog_file18 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-host.ts";
|
|
4636
4708
|
var createDefaultModelFactory = () => {
|
|
4637
4709
|
return new ModelFactory().registerModel(DocumentModel2).registerModel(TextModel);
|
|
4638
4710
|
};
|
|
@@ -4732,8 +4804,8 @@ var ClientServicesHost = class ClientServicesHost2 {
|
|
|
4732
4804
|
* Can only be called once.
|
|
4733
4805
|
*/
|
|
4734
4806
|
initialize({ config, ...options }) {
|
|
4735
|
-
|
|
4736
|
-
F:
|
|
4807
|
+
invariant15(!this._open, "service host is open", {
|
|
4808
|
+
F: __dxlog_file18,
|
|
4737
4809
|
L: 201,
|
|
4738
4810
|
S: this,
|
|
4739
4811
|
A: [
|
|
@@ -4742,14 +4814,14 @@ var ClientServicesHost = class ClientServicesHost2 {
|
|
|
4742
4814
|
]
|
|
4743
4815
|
});
|
|
4744
4816
|
log16("initializing...", void 0, {
|
|
4745
|
-
F:
|
|
4817
|
+
F: __dxlog_file18,
|
|
4746
4818
|
L: 202,
|
|
4747
4819
|
S: this,
|
|
4748
4820
|
C: (f, a) => f(...a)
|
|
4749
4821
|
});
|
|
4750
4822
|
if (config) {
|
|
4751
|
-
|
|
4752
|
-
F:
|
|
4823
|
+
invariant15(!this._config, "config already set", {
|
|
4824
|
+
F: __dxlog_file18,
|
|
4753
4825
|
L: 205,
|
|
4754
4826
|
S: this,
|
|
4755
4827
|
A: [
|
|
@@ -4766,8 +4838,8 @@ var ClientServicesHost = class ClientServicesHost2 {
|
|
|
4766
4838
|
iceServers: this._config?.get("runtime.services.ice")
|
|
4767
4839
|
}), signalManager = new WebsocketSignalManager(this._config?.get("runtime.services.signaling") ?? []) } = options;
|
|
4768
4840
|
this._signalManager = signalManager;
|
|
4769
|
-
|
|
4770
|
-
F:
|
|
4841
|
+
invariant15(!this._networkManager, "network manager already set", {
|
|
4842
|
+
F: __dxlog_file18,
|
|
4771
4843
|
L: 221,
|
|
4772
4844
|
S: this,
|
|
4773
4845
|
A: [
|
|
@@ -4781,7 +4853,7 @@ var ClientServicesHost = class ClientServicesHost2 {
|
|
|
4781
4853
|
signalManager
|
|
4782
4854
|
});
|
|
4783
4855
|
log16("initialized", void 0, {
|
|
4784
|
-
F:
|
|
4856
|
+
F: __dxlog_file18,
|
|
4785
4857
|
L: 228,
|
|
4786
4858
|
S: this,
|
|
4787
4859
|
C: (f, a) => f(...a)
|
|
@@ -4791,17 +4863,17 @@ var ClientServicesHost = class ClientServicesHost2 {
|
|
|
4791
4863
|
if (this._open) {
|
|
4792
4864
|
return;
|
|
4793
4865
|
}
|
|
4794
|
-
const traceId =
|
|
4866
|
+
const traceId = PublicKey11.random().toHex();
|
|
4795
4867
|
log16.trace("dxos.client-services.host.open", trace8.begin({
|
|
4796
4868
|
id: traceId
|
|
4797
4869
|
}), {
|
|
4798
|
-
F:
|
|
4870
|
+
F: __dxlog_file18,
|
|
4799
4871
|
L: 239,
|
|
4800
4872
|
S: this,
|
|
4801
4873
|
C: (f, a) => f(...a)
|
|
4802
4874
|
});
|
|
4803
|
-
|
|
4804
|
-
F:
|
|
4875
|
+
invariant15(this._config, "config not set", {
|
|
4876
|
+
F: __dxlog_file18,
|
|
4805
4877
|
L: 241,
|
|
4806
4878
|
S: this,
|
|
4807
4879
|
A: [
|
|
@@ -4809,8 +4881,8 @@ var ClientServicesHost = class ClientServicesHost2 {
|
|
|
4809
4881
|
"'config not set'"
|
|
4810
4882
|
]
|
|
4811
4883
|
});
|
|
4812
|
-
|
|
4813
|
-
F:
|
|
4884
|
+
invariant15(this._storage, "storage not set", {
|
|
4885
|
+
F: __dxlog_file18,
|
|
4814
4886
|
L: 242,
|
|
4815
4887
|
S: this,
|
|
4816
4888
|
A: [
|
|
@@ -4818,8 +4890,8 @@ var ClientServicesHost = class ClientServicesHost2 {
|
|
|
4818
4890
|
"'storage not set'"
|
|
4819
4891
|
]
|
|
4820
4892
|
});
|
|
4821
|
-
|
|
4822
|
-
F:
|
|
4893
|
+
invariant15(this._signalManager, "signal manager not set", {
|
|
4894
|
+
F: __dxlog_file18,
|
|
4823
4895
|
L: 243,
|
|
4824
4896
|
S: this,
|
|
4825
4897
|
A: [
|
|
@@ -4827,8 +4899,8 @@ var ClientServicesHost = class ClientServicesHost2 {
|
|
|
4827
4899
|
"'signal manager not set'"
|
|
4828
4900
|
]
|
|
4829
4901
|
});
|
|
4830
|
-
|
|
4831
|
-
F:
|
|
4902
|
+
invariant15(this._networkManager, "network manager not set", {
|
|
4903
|
+
F: __dxlog_file18,
|
|
4832
4904
|
L: 244,
|
|
4833
4905
|
S: this,
|
|
4834
4906
|
A: [
|
|
@@ -4840,7 +4912,7 @@ var ClientServicesHost = class ClientServicesHost2 {
|
|
|
4840
4912
|
log16("opening...", {
|
|
4841
4913
|
lockKey: this._resourceLock?.lockKey
|
|
4842
4914
|
}, {
|
|
4843
|
-
F:
|
|
4915
|
+
F: __dxlog_file18,
|
|
4844
4916
|
L: 247,
|
|
4845
4917
|
S: this,
|
|
4846
4918
|
C: (f, a) => f(...a)
|
|
@@ -4886,7 +4958,7 @@ var ClientServicesHost = class ClientServicesHost2 {
|
|
|
4886
4958
|
log16("opened", {
|
|
4887
4959
|
deviceKey
|
|
4888
4960
|
}, {
|
|
4889
|
-
F:
|
|
4961
|
+
F: __dxlog_file18,
|
|
4890
4962
|
L: 316,
|
|
4891
4963
|
S: this,
|
|
4892
4964
|
C: (f, a) => f(...a)
|
|
@@ -4894,7 +4966,7 @@ var ClientServicesHost = class ClientServicesHost2 {
|
|
|
4894
4966
|
log16.trace("dxos.client-services.host.open", trace8.end({
|
|
4895
4967
|
id: traceId
|
|
4896
4968
|
}), {
|
|
4897
|
-
F:
|
|
4969
|
+
F: __dxlog_file18,
|
|
4898
4970
|
L: 317,
|
|
4899
4971
|
S: this,
|
|
4900
4972
|
C: (f, a) => f(...a)
|
|
@@ -4908,7 +4980,7 @@ var ClientServicesHost = class ClientServicesHost2 {
|
|
|
4908
4980
|
log16("closing...", {
|
|
4909
4981
|
deviceKey
|
|
4910
4982
|
}, {
|
|
4911
|
-
F:
|
|
4983
|
+
F: __dxlog_file18,
|
|
4912
4984
|
L: 328,
|
|
4913
4985
|
S: this,
|
|
4914
4986
|
C: (f, a) => f(...a)
|
|
@@ -4924,24 +4996,24 @@ var ClientServicesHost = class ClientServicesHost2 {
|
|
|
4924
4996
|
log16("closed", {
|
|
4925
4997
|
deviceKey
|
|
4926
4998
|
}, {
|
|
4927
|
-
F:
|
|
4999
|
+
F: __dxlog_file18,
|
|
4928
5000
|
L: 335,
|
|
4929
5001
|
S: this,
|
|
4930
5002
|
C: (f, a) => f(...a)
|
|
4931
5003
|
});
|
|
4932
5004
|
}
|
|
4933
5005
|
async reset() {
|
|
4934
|
-
const traceId =
|
|
5006
|
+
const traceId = PublicKey11.random().toHex();
|
|
4935
5007
|
log16.trace("dxos.sdk.client-services-host.reset", trace8.begin({
|
|
4936
5008
|
id: traceId
|
|
4937
5009
|
}), {
|
|
4938
|
-
F:
|
|
5010
|
+
F: __dxlog_file18,
|
|
4939
5011
|
L: 340,
|
|
4940
5012
|
S: this,
|
|
4941
5013
|
C: (f, a) => f(...a)
|
|
4942
5014
|
});
|
|
4943
5015
|
log16("resetting...", void 0, {
|
|
4944
|
-
F:
|
|
5016
|
+
F: __dxlog_file18,
|
|
4945
5017
|
L: 342,
|
|
4946
5018
|
S: this,
|
|
4947
5019
|
C: (f, a) => f(...a)
|
|
@@ -4949,7 +5021,7 @@ var ClientServicesHost = class ClientServicesHost2 {
|
|
|
4949
5021
|
await this._serviceContext?.close();
|
|
4950
5022
|
await this._storage.reset();
|
|
4951
5023
|
log16("reset", void 0, {
|
|
4952
|
-
F:
|
|
5024
|
+
F: __dxlog_file18,
|
|
4953
5025
|
L: 345,
|
|
4954
5026
|
S: this,
|
|
4955
5027
|
C: (f, a) => f(...a)
|
|
@@ -4957,7 +5029,7 @@ var ClientServicesHost = class ClientServicesHost2 {
|
|
|
4957
5029
|
log16.trace("dxos.sdk.client-services-host.reset", trace8.end({
|
|
4958
5030
|
id: traceId
|
|
4959
5031
|
}), {
|
|
4960
|
-
F:
|
|
5032
|
+
F: __dxlog_file18,
|
|
4961
5033
|
L: 346,
|
|
4962
5034
|
S: this,
|
|
4963
5035
|
C: (f, a) => f(...a)
|
|
@@ -5035,4 +5107,4 @@ export {
|
|
|
5035
5107
|
createDefaultModelFactory,
|
|
5036
5108
|
ClientServicesHost
|
|
5037
5109
|
};
|
|
5038
|
-
//# sourceMappingURL=chunk-
|
|
5110
|
+
//# sourceMappingURL=chunk-3GWSYNJC.mjs.map
|