@dxos/client-services 0.3.2-main.648180e → 0.3.2-main.ce2190e
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-DUT4WEQ5.mjs → chunk-ZGPBGQ4M.mjs} +131 -67
- package/dist/lib/browser/chunk-ZGPBGQ4M.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 +190 -126
- 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 +164 -100
- 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 +3 -3
- package/src/version.ts +1 -1
- package/dist/lib/browser/chunk-DUT4WEQ5.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")
|
|
@@ -491,7 +493,7 @@ var Identity = class Identity2 {
|
|
|
491
493
|
onUpdate: () => this.stateUpdate.emit()
|
|
492
494
|
});
|
|
493
495
|
this.authVerifier = new TrustedKeySetAuthVerifier({
|
|
494
|
-
trustedKeysProvider: () => this.authorizedDeviceKeys,
|
|
496
|
+
trustedKeysProvider: () => new ComplexSet(PublicKey3.hash, this.authorizedDeviceKeys.keys()),
|
|
495
497
|
update: this.stateUpdate,
|
|
496
498
|
authTimeout: AUTH_TIMEOUT
|
|
497
499
|
});
|
|
@@ -629,7 +631,7 @@ import { Event as Event2 } from "@dxos/async";
|
|
|
629
631
|
import { Context as Context3 } from "@dxos/context";
|
|
630
632
|
import { createCredentialSignerWithKey as createCredentialSignerWithKey2, CredentialGenerator } from "@dxos/credentials";
|
|
631
633
|
import { invariant as invariant2 } from "@dxos/invariant";
|
|
632
|
-
import { PublicKey as
|
|
634
|
+
import { PublicKey as PublicKey4 } from "@dxos/keys";
|
|
633
635
|
import { log as log3 } from "@dxos/log";
|
|
634
636
|
import { trace as trace2 } from "@dxos/protocols";
|
|
635
637
|
import { AdmittedFeed as AdmittedFeed2 } from "@dxos/protocols/proto/dxos/halo/credentials";
|
|
@@ -661,7 +663,7 @@ var IdentityManager = class IdentityManager2 {
|
|
|
661
663
|
return this._identity;
|
|
662
664
|
}
|
|
663
665
|
async open(ctx) {
|
|
664
|
-
const traceId =
|
|
666
|
+
const traceId = PublicKey4.random().toHex();
|
|
665
667
|
log3.trace("dxos.halo.identity-manager.open", trace2.begin({
|
|
666
668
|
id: traceId
|
|
667
669
|
}), {
|
|
@@ -891,10 +893,51 @@ var IdentityManager = class IdentityManager2 {
|
|
|
891
893
|
this.stateUpdate.emit();
|
|
892
894
|
return profile;
|
|
893
895
|
}
|
|
896
|
+
async updateDevice({ deviceKey, profile }) {
|
|
897
|
+
invariant2(this._identity, "Identity not initialized.", {
|
|
898
|
+
F: __dxlog_file3,
|
|
899
|
+
L: 216,
|
|
900
|
+
S: this,
|
|
901
|
+
A: [
|
|
902
|
+
"this._identity",
|
|
903
|
+
"'Identity not initialized.'"
|
|
904
|
+
]
|
|
905
|
+
});
|
|
906
|
+
invariant2(this._identity.authorizedDeviceKeys.has(deviceKey), "Device not authorized.", {
|
|
907
|
+
F: __dxlog_file3,
|
|
908
|
+
L: 218,
|
|
909
|
+
S: this,
|
|
910
|
+
A: [
|
|
911
|
+
"this._identity.authorizedDeviceKeys.has(deviceKey)",
|
|
912
|
+
"'Device not authorized.'"
|
|
913
|
+
]
|
|
914
|
+
});
|
|
915
|
+
const credential = await this._identity.getIdentityCredentialSigner().createCredential({
|
|
916
|
+
subject: this._identity.identityKey,
|
|
917
|
+
assertion: {
|
|
918
|
+
"@type": "dxos.halo.credentials.DeviceProfile",
|
|
919
|
+
deviceKey,
|
|
920
|
+
profile
|
|
921
|
+
}
|
|
922
|
+
});
|
|
923
|
+
const receipt = await this._identity.controlPipeline.writer.write({
|
|
924
|
+
credential: {
|
|
925
|
+
credential
|
|
926
|
+
}
|
|
927
|
+
});
|
|
928
|
+
await this._identity.controlPipeline.state.waitUntilTimeframe(new Timeframe([
|
|
929
|
+
[
|
|
930
|
+
receipt.feedKey,
|
|
931
|
+
receipt.seq
|
|
932
|
+
]
|
|
933
|
+
]));
|
|
934
|
+
this.stateUpdate.emit();
|
|
935
|
+
return profile;
|
|
936
|
+
}
|
|
894
937
|
async _constructIdentity(identityRecord) {
|
|
895
938
|
invariant2(!this._identity, void 0, {
|
|
896
939
|
F: __dxlog_file3,
|
|
897
|
-
L:
|
|
940
|
+
L: 236,
|
|
898
941
|
S: this,
|
|
899
942
|
A: [
|
|
900
943
|
"!this._identity",
|
|
@@ -905,13 +948,13 @@ var IdentityManager = class IdentityManager2 {
|
|
|
905
948
|
identityRecord
|
|
906
949
|
}, {
|
|
907
950
|
F: __dxlog_file3,
|
|
908
|
-
L:
|
|
951
|
+
L: 237,
|
|
909
952
|
S: this,
|
|
910
953
|
C: (f, a) => f(...a)
|
|
911
954
|
});
|
|
912
955
|
invariant2(identityRecord.haloSpace.controlFeedKey, void 0, {
|
|
913
956
|
F: __dxlog_file3,
|
|
914
|
-
L:
|
|
957
|
+
L: 240,
|
|
915
958
|
S: this,
|
|
916
959
|
A: [
|
|
917
960
|
"identityRecord.haloSpace.controlFeedKey",
|
|
@@ -923,7 +966,7 @@ var IdentityManager = class IdentityManager2 {
|
|
|
923
966
|
});
|
|
924
967
|
invariant2(identityRecord.haloSpace.dataFeedKey, void 0, {
|
|
925
968
|
F: __dxlog_file3,
|
|
926
|
-
L:
|
|
969
|
+
L: 244,
|
|
927
970
|
S: this,
|
|
928
971
|
A: [
|
|
929
972
|
"identityRecord.haloSpace.dataFeedKey",
|
|
@@ -955,7 +998,7 @@ var IdentityManager = class IdentityManager2 {
|
|
|
955
998
|
identityKey: identityRecord.identityKey
|
|
956
999
|
}, {
|
|
957
1000
|
F: __dxlog_file3,
|
|
958
|
-
L:
|
|
1001
|
+
L: 268,
|
|
959
1002
|
S: this,
|
|
960
1003
|
C: (f, a) => f(...a)
|
|
961
1004
|
});
|
|
@@ -976,7 +1019,7 @@ var IdentityManager = class IdentityManager2 {
|
|
|
976
1019
|
onAuthFailure: () => {
|
|
977
1020
|
log3.warn("auth failure", void 0, {
|
|
978
1021
|
F: __dxlog_file3,
|
|
979
|
-
L:
|
|
1022
|
+
L: 287,
|
|
980
1023
|
S: this,
|
|
981
1024
|
C: (f, a) => f(...a)
|
|
982
1025
|
});
|
|
@@ -1161,7 +1204,7 @@ import { AuthenticatingInvitation, AUTHENTICATION_CODE_LENGTH, CancellableInvita
|
|
|
1161
1204
|
import { Context as Context5 } from "@dxos/context";
|
|
1162
1205
|
import { generatePasscode } from "@dxos/credentials";
|
|
1163
1206
|
import { invariant as invariant6 } from "@dxos/invariant";
|
|
1164
|
-
import { PublicKey as
|
|
1207
|
+
import { PublicKey as PublicKey6 } from "@dxos/keys";
|
|
1165
1208
|
import { log as log5 } from "@dxos/log";
|
|
1166
1209
|
import { createTeleportProtocolFactory, StarTopology } from "@dxos/network-manager";
|
|
1167
1210
|
import { InvalidInvitationExtensionRoleError as InvalidInvitationExtensionRoleError2, trace as trace4 } from "@dxos/protocols";
|
|
@@ -1172,7 +1215,7 @@ import { AuthenticationResponse as AuthenticationResponse2 } from "@dxos/protoco
|
|
|
1172
1215
|
import { Trigger as Trigger2 } from "@dxos/async";
|
|
1173
1216
|
import { cancelWithContext, Context as Context4 } from "@dxos/context";
|
|
1174
1217
|
import { invariant as invariant5 } from "@dxos/invariant";
|
|
1175
|
-
import { PublicKey as
|
|
1218
|
+
import { PublicKey as PublicKey5 } from "@dxos/keys";
|
|
1176
1219
|
import { log as log4 } from "@dxos/log";
|
|
1177
1220
|
import { InvalidInvitationExtensionRoleError, schema as schema2, trace as trace3 } from "@dxos/protocols";
|
|
1178
1221
|
import { Invitation as Invitation2 } from "@dxos/protocols/proto/dxos/client/services";
|
|
@@ -1220,7 +1263,7 @@ var InvitationHostExtension = class extends RpcExtension {
|
|
|
1220
1263
|
},
|
|
1221
1264
|
introduce: async (request) => {
|
|
1222
1265
|
const { profile, invitationId } = request;
|
|
1223
|
-
const traceId =
|
|
1266
|
+
const traceId = PublicKey5.random().toHex();
|
|
1224
1267
|
log4.trace("dxos.sdk.invitation-handler.host.introduce", trace3.begin({
|
|
1225
1268
|
id: traceId
|
|
1226
1269
|
}), {
|
|
@@ -1272,7 +1315,7 @@ var InvitationHostExtension = class extends RpcExtension {
|
|
|
1272
1315
|
};
|
|
1273
1316
|
},
|
|
1274
1317
|
authenticate: async ({ authCode: code }) => {
|
|
1275
|
-
const traceId =
|
|
1318
|
+
const traceId = PublicKey5.random().toHex();
|
|
1276
1319
|
log4.trace("dxos.sdk.invitation-handler.host.authenticate", trace3.begin({
|
|
1277
1320
|
id: traceId
|
|
1278
1321
|
}), {
|
|
@@ -1352,7 +1395,7 @@ var InvitationHostExtension = class extends RpcExtension {
|
|
|
1352
1395
|
};
|
|
1353
1396
|
},
|
|
1354
1397
|
admit: async (request) => {
|
|
1355
|
-
const traceId =
|
|
1398
|
+
const traceId = PublicKey5.random().toHex();
|
|
1356
1399
|
log4.trace("dxos.sdk.invitation-handler.host.admit", trace3.begin({
|
|
1357
1400
|
id: traceId
|
|
1358
1401
|
}), {
|
|
@@ -1518,7 +1561,7 @@ var InvitationsHandler = class {
|
|
|
1518
1561
|
this._networkManager = _networkManager;
|
|
1519
1562
|
}
|
|
1520
1563
|
createInvitation(protocol, options) {
|
|
1521
|
-
const { invitationId =
|
|
1564
|
+
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
1565
|
const authCode = options?.authCode ?? (authMethod === Invitation3.AuthMethod.SHARED_SECRET ? generatePasscode(AUTHENTICATION_CODE_LENGTH) : void 0);
|
|
1523
1566
|
invariant6(protocol, void 0, {
|
|
1524
1567
|
F: __dxlog_file7,
|
|
@@ -1593,7 +1636,7 @@ var InvitationsHandler = class {
|
|
|
1593
1636
|
},
|
|
1594
1637
|
onOpen: () => {
|
|
1595
1638
|
scheduleTask2(ctx, async () => {
|
|
1596
|
-
const traceId =
|
|
1639
|
+
const traceId = PublicKey6.random().toHex();
|
|
1597
1640
|
try {
|
|
1598
1641
|
log5.trace("dxos.sdk.invitations-handler.host.onOpen", trace4.begin({
|
|
1599
1642
|
id: traceId
|
|
@@ -1826,7 +1869,7 @@ var InvitationsHandler = class {
|
|
|
1826
1869
|
}
|
|
1827
1870
|
});
|
|
1828
1871
|
scheduleTask2(ctx, async () => {
|
|
1829
|
-
const traceId =
|
|
1872
|
+
const traceId = PublicKey6.random().toHex();
|
|
1830
1873
|
try {
|
|
1831
1874
|
log5.trace("dxos.sdk.invitations-handler.guest.onOpen", trace4.begin({
|
|
1832
1875
|
id: traceId
|
|
@@ -2033,7 +2076,7 @@ var InvitationsHandler = class {
|
|
|
2033
2076
|
const topic = invitation.swarmKey;
|
|
2034
2077
|
const swarmConnection = await this._networkManager.joinSwarm({
|
|
2035
2078
|
topic,
|
|
2036
|
-
peerId:
|
|
2079
|
+
peerId: PublicKey6.random(),
|
|
2037
2080
|
protocolProvider: createTeleportProtocolFactory(async (teleport) => {
|
|
2038
2081
|
teleport.addExtension("dxos.halo.invitations", createExtension());
|
|
2039
2082
|
}),
|
|
@@ -2498,7 +2541,7 @@ var getPlatform = () => {
|
|
|
2498
2541
|
};
|
|
2499
2542
|
|
|
2500
2543
|
// packages/sdk/client-services/src/version.ts
|
|
2501
|
-
var DXOS_VERSION = "0.3.2-main.
|
|
2544
|
+
var DXOS_VERSION = "0.3.2-main.ce2190e";
|
|
2502
2545
|
|
|
2503
2546
|
// packages/sdk/client-services/src/packlets/services/diagnostics.ts
|
|
2504
2547
|
var __dxlog_file10 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/diagnostics.ts";
|
|
@@ -2624,24 +2667,24 @@ import { AUTH_TIMEOUT as AUTH_TIMEOUT2 } from "@dxos/client-protocol";
|
|
|
2624
2667
|
import { cancelWithContext as cancelWithContext2, Context as Context7 } from "@dxos/context";
|
|
2625
2668
|
import { timed } from "@dxos/debug";
|
|
2626
2669
|
import { createMappedFeedWriter } from "@dxos/echo-pipeline";
|
|
2627
|
-
import { PublicKey as
|
|
2670
|
+
import { PublicKey as PublicKey8 } from "@dxos/keys";
|
|
2628
2671
|
import { log as log10 } from "@dxos/log";
|
|
2629
2672
|
import { CancelledError, SystemError } from "@dxos/protocols";
|
|
2630
2673
|
import { SpaceState } from "@dxos/protocols/proto/dxos/client/services";
|
|
2631
2674
|
import { AdmittedFeed as AdmittedFeed3 } from "@dxos/protocols/proto/dxos/halo/credentials";
|
|
2632
2675
|
import { Timeframe as Timeframe2 } from "@dxos/timeframe";
|
|
2633
2676
|
import { trace as trace5 } from "@dxos/tracing";
|
|
2634
|
-
import { ComplexSet as
|
|
2677
|
+
import { ComplexSet as ComplexSet3 } from "@dxos/util";
|
|
2635
2678
|
|
|
2636
2679
|
// packages/sdk/client-services/src/packlets/spaces/notarization-plugin.ts
|
|
2637
2680
|
import { DeferredTask, Event as Event4, scheduleTask as scheduleTask3, sleep, TimeoutError as TimeoutError2, Trigger as Trigger4 } from "@dxos/async";
|
|
2638
2681
|
import { Context as Context6, rejectOnDispose } from "@dxos/context";
|
|
2639
2682
|
import { invariant as invariant10 } from "@dxos/invariant";
|
|
2640
|
-
import { PublicKey as
|
|
2683
|
+
import { PublicKey as PublicKey7 } from "@dxos/keys";
|
|
2641
2684
|
import { log as log9 } from "@dxos/log";
|
|
2642
2685
|
import { schema as schema3 } from "@dxos/protocols";
|
|
2643
2686
|
import { RpcExtension as RpcExtension2 } from "@dxos/teleport";
|
|
2644
|
-
import { ComplexMap as ComplexMap2, ComplexSet, entry } from "@dxos/util";
|
|
2687
|
+
import { ComplexMap as ComplexMap2, ComplexSet as ComplexSet2, entry } from "@dxos/util";
|
|
2645
2688
|
var __dxlog_file11 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/notarization-plugin.ts";
|
|
2646
2689
|
var DEFAULT_RETRY_TIMEOUT = 1e3;
|
|
2647
2690
|
var DEFAULT_SUCCESS_DELAY = 1e3;
|
|
@@ -2652,8 +2695,8 @@ var NotarizationPlugin = class {
|
|
|
2652
2695
|
this._ctx = new Context6();
|
|
2653
2696
|
this._extensionOpened = new Event4();
|
|
2654
2697
|
this._extensions = /* @__PURE__ */ new Set();
|
|
2655
|
-
this._processedCredentials = new
|
|
2656
|
-
this._processCredentialsTriggers = new ComplexMap2(
|
|
2698
|
+
this._processedCredentials = new ComplexSet2(PublicKey7.hash);
|
|
2699
|
+
this._processCredentialsTriggers = new ComplexMap2(PublicKey7.hash);
|
|
2657
2700
|
}
|
|
2658
2701
|
get hasWriter() {
|
|
2659
2702
|
return !!this._writer;
|
|
@@ -2935,7 +2978,7 @@ var DataSpace = class DataSpace2 {
|
|
|
2935
2978
|
this._signingContext = params.signingContext;
|
|
2936
2979
|
this._callbacks = params.callbacks ?? {};
|
|
2937
2980
|
this.authVerifier = new TrustedKeySetAuthVerifier({
|
|
2938
|
-
trustedKeysProvider: () => new
|
|
2981
|
+
trustedKeysProvider: () => new ComplexSet3(PublicKey8.hash, Array.from(this._inner.spaceState.members.values()).filter((member) => !member.removed).map((member) => member.key)),
|
|
2939
2982
|
update: this._inner.stateUpdate,
|
|
2940
2983
|
authTimeout: AUTH_TIMEOUT2
|
|
2941
2984
|
});
|
|
@@ -3268,7 +3311,7 @@ import { Event as Event6, synchronized as synchronized2, trackLeaks as trackLeak
|
|
|
3268
3311
|
import { cancelWithContext as cancelWithContext3, Context as Context8 } from "@dxos/context";
|
|
3269
3312
|
import { getCredentialAssertion as getCredentialAssertion2 } from "@dxos/credentials";
|
|
3270
3313
|
import { invariant as invariant11 } from "@dxos/invariant";
|
|
3271
|
-
import { PublicKey as
|
|
3314
|
+
import { PublicKey as PublicKey9 } from "@dxos/keys";
|
|
3272
3315
|
import { log as log11 } from "@dxos/log";
|
|
3273
3316
|
import { trace as trace6 } from "@dxos/protocols";
|
|
3274
3317
|
import { SpaceState as SpaceState2 } from "@dxos/protocols/proto/dxos/client/services";
|
|
@@ -3366,9 +3409,9 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
3366
3409
|
this._feedStore = _feedStore;
|
|
3367
3410
|
this._ctx = new Context8();
|
|
3368
3411
|
this.updated = new Event6();
|
|
3369
|
-
this._spaces = new ComplexMap3(
|
|
3412
|
+
this._spaces = new ComplexMap3(PublicKey9.hash);
|
|
3370
3413
|
this._isOpen = false;
|
|
3371
|
-
this._instanceId =
|
|
3414
|
+
this._instanceId = PublicKey9.random().toHex();
|
|
3372
3415
|
}
|
|
3373
3416
|
// TODO(burdon): Remove.
|
|
3374
3417
|
get spaces() {
|
|
@@ -3907,7 +3950,7 @@ import { valueEncoding, MetadataStore, SpaceManager, DataServiceSubscriptions, S
|
|
|
3907
3950
|
import { FeedFactory, FeedStore } from "@dxos/feed-store";
|
|
3908
3951
|
import { invariant as invariant13 } from "@dxos/invariant";
|
|
3909
3952
|
import { Keyring } from "@dxos/keyring";
|
|
3910
|
-
import { PublicKey as
|
|
3953
|
+
import { PublicKey as PublicKey10 } from "@dxos/keys";
|
|
3911
3954
|
import { log as log13 } from "@dxos/log";
|
|
3912
3955
|
import { InvalidStorageVersionError, STORAGE_VERSION as STORAGE_VERSION2, trace as trace7 } from "@dxos/protocols";
|
|
3913
3956
|
import { Invitation as Invitation6 } from "@dxos/protocols/proto/dxos/client/services";
|
|
@@ -3934,7 +3977,7 @@ var ServiceContext = class ServiceContext2 {
|
|
|
3934
3977
|
this.initialized = new Trigger5();
|
|
3935
3978
|
this.dataServiceSubscriptions = new DataServiceSubscriptions();
|
|
3936
3979
|
this._handlerFactories = /* @__PURE__ */ new Map();
|
|
3937
|
-
this._instanceId =
|
|
3980
|
+
this._instanceId = PublicKey10.random().toHex();
|
|
3938
3981
|
this.metadataStore = new MetadataStore(storage.createDirectory("metadata"));
|
|
3939
3982
|
this.snapshotStore = new SnapshotStore(storage.createDirectory("snapshots"));
|
|
3940
3983
|
this.blobStore = new BlobStore(storage.createDirectory("blobs"));
|
|
@@ -4363,8 +4406,8 @@ import { Context as Context10 } from "@dxos/context";
|
|
|
4363
4406
|
import { DocumentModel as DocumentModel2 } from "@dxos/document-model";
|
|
4364
4407
|
import { DataServiceImpl } from "@dxos/echo-pipeline";
|
|
4365
4408
|
import { base } from "@dxos/echo-schema";
|
|
4366
|
-
import { invariant as
|
|
4367
|
-
import { PublicKey as
|
|
4409
|
+
import { invariant as invariant15 } from "@dxos/invariant";
|
|
4410
|
+
import { PublicKey as PublicKey11 } from "@dxos/keys";
|
|
4368
4411
|
import { log as log16 } from "@dxos/log";
|
|
4369
4412
|
import { WebsocketSignalManager } from "@dxos/messaging";
|
|
4370
4413
|
import { ModelFactory } from "@dxos/model-factory";
|
|
@@ -4378,13 +4421,33 @@ import { WebsocketRpcClient } from "@dxos/websocket-rpc";
|
|
|
4378
4421
|
// packages/sdk/client-services/src/packlets/devices/devices-service.ts
|
|
4379
4422
|
import { EventSubscriptions as EventSubscriptions3 } from "@dxos/async";
|
|
4380
4423
|
import { Stream as Stream11 } from "@dxos/codec-protobuf";
|
|
4424
|
+
import { invariant as invariant14 } from "@dxos/invariant";
|
|
4381
4425
|
import { DeviceKind } from "@dxos/protocols/proto/dxos/client/services";
|
|
4426
|
+
var __dxlog_file17 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/devices/devices-service.ts";
|
|
4382
4427
|
var DevicesServiceImpl = class {
|
|
4383
4428
|
constructor(_identityManager) {
|
|
4384
4429
|
this._identityManager = _identityManager;
|
|
4385
4430
|
}
|
|
4386
|
-
updateDevice(
|
|
4387
|
-
|
|
4431
|
+
async updateDevice(profile) {
|
|
4432
|
+
invariant14(this._identityManager.identity, "Identity not initialized", {
|
|
4433
|
+
F: __dxlog_file17,
|
|
4434
|
+
L: 17,
|
|
4435
|
+
S: this,
|
|
4436
|
+
A: [
|
|
4437
|
+
"this._identityManager.identity",
|
|
4438
|
+
"'Identity not initialized'"
|
|
4439
|
+
]
|
|
4440
|
+
});
|
|
4441
|
+
const deviceKey = this._identityManager.identity.deviceKey;
|
|
4442
|
+
await this._identityManager.updateDevice({
|
|
4443
|
+
deviceKey,
|
|
4444
|
+
profile
|
|
4445
|
+
});
|
|
4446
|
+
return {
|
|
4447
|
+
deviceKey,
|
|
4448
|
+
kind: DeviceKind.CURRENT,
|
|
4449
|
+
profile
|
|
4450
|
+
};
|
|
4388
4451
|
}
|
|
4389
4452
|
queryDevices() {
|
|
4390
4453
|
return new Stream11(({ next }) => {
|
|
@@ -4396,9 +4459,10 @@ var DevicesServiceImpl = class {
|
|
|
4396
4459
|
});
|
|
4397
4460
|
} else {
|
|
4398
4461
|
next({
|
|
4399
|
-
devices: Array.from(deviceKeys.
|
|
4462
|
+
devices: Array.from(deviceKeys.entries()).map(([key, profile]) => ({
|
|
4400
4463
|
deviceKey: key,
|
|
4401
|
-
kind: this._identityManager.identity?.deviceKey.equals(key) ? DeviceKind.CURRENT : DeviceKind.TRUSTED
|
|
4464
|
+
kind: this._identityManager.identity?.deviceKey.equals(key) ? DeviceKind.CURRENT : DeviceKind.TRUSTED,
|
|
4465
|
+
profile
|
|
4402
4466
|
}))
|
|
4403
4467
|
});
|
|
4404
4468
|
}
|
|
@@ -4632,7 +4696,7 @@ function _ts_decorate7(decorators, target, key, desc) {
|
|
|
4632
4696
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
4633
4697
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4634
4698
|
}
|
|
4635
|
-
var
|
|
4699
|
+
var __dxlog_file18 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-host.ts";
|
|
4636
4700
|
var createDefaultModelFactory = () => {
|
|
4637
4701
|
return new ModelFactory().registerModel(DocumentModel2).registerModel(TextModel);
|
|
4638
4702
|
};
|
|
@@ -4732,8 +4796,8 @@ var ClientServicesHost = class ClientServicesHost2 {
|
|
|
4732
4796
|
* Can only be called once.
|
|
4733
4797
|
*/
|
|
4734
4798
|
initialize({ config, ...options }) {
|
|
4735
|
-
|
|
4736
|
-
F:
|
|
4799
|
+
invariant15(!this._open, "service host is open", {
|
|
4800
|
+
F: __dxlog_file18,
|
|
4737
4801
|
L: 201,
|
|
4738
4802
|
S: this,
|
|
4739
4803
|
A: [
|
|
@@ -4742,14 +4806,14 @@ var ClientServicesHost = class ClientServicesHost2 {
|
|
|
4742
4806
|
]
|
|
4743
4807
|
});
|
|
4744
4808
|
log16("initializing...", void 0, {
|
|
4745
|
-
F:
|
|
4809
|
+
F: __dxlog_file18,
|
|
4746
4810
|
L: 202,
|
|
4747
4811
|
S: this,
|
|
4748
4812
|
C: (f, a) => f(...a)
|
|
4749
4813
|
});
|
|
4750
4814
|
if (config) {
|
|
4751
|
-
|
|
4752
|
-
F:
|
|
4815
|
+
invariant15(!this._config, "config already set", {
|
|
4816
|
+
F: __dxlog_file18,
|
|
4753
4817
|
L: 205,
|
|
4754
4818
|
S: this,
|
|
4755
4819
|
A: [
|
|
@@ -4766,8 +4830,8 @@ var ClientServicesHost = class ClientServicesHost2 {
|
|
|
4766
4830
|
iceServers: this._config?.get("runtime.services.ice")
|
|
4767
4831
|
}), signalManager = new WebsocketSignalManager(this._config?.get("runtime.services.signaling") ?? []) } = options;
|
|
4768
4832
|
this._signalManager = signalManager;
|
|
4769
|
-
|
|
4770
|
-
F:
|
|
4833
|
+
invariant15(!this._networkManager, "network manager already set", {
|
|
4834
|
+
F: __dxlog_file18,
|
|
4771
4835
|
L: 221,
|
|
4772
4836
|
S: this,
|
|
4773
4837
|
A: [
|
|
@@ -4781,7 +4845,7 @@ var ClientServicesHost = class ClientServicesHost2 {
|
|
|
4781
4845
|
signalManager
|
|
4782
4846
|
});
|
|
4783
4847
|
log16("initialized", void 0, {
|
|
4784
|
-
F:
|
|
4848
|
+
F: __dxlog_file18,
|
|
4785
4849
|
L: 228,
|
|
4786
4850
|
S: this,
|
|
4787
4851
|
C: (f, a) => f(...a)
|
|
@@ -4791,17 +4855,17 @@ var ClientServicesHost = class ClientServicesHost2 {
|
|
|
4791
4855
|
if (this._open) {
|
|
4792
4856
|
return;
|
|
4793
4857
|
}
|
|
4794
|
-
const traceId =
|
|
4858
|
+
const traceId = PublicKey11.random().toHex();
|
|
4795
4859
|
log16.trace("dxos.client-services.host.open", trace8.begin({
|
|
4796
4860
|
id: traceId
|
|
4797
4861
|
}), {
|
|
4798
|
-
F:
|
|
4862
|
+
F: __dxlog_file18,
|
|
4799
4863
|
L: 239,
|
|
4800
4864
|
S: this,
|
|
4801
4865
|
C: (f, a) => f(...a)
|
|
4802
4866
|
});
|
|
4803
|
-
|
|
4804
|
-
F:
|
|
4867
|
+
invariant15(this._config, "config not set", {
|
|
4868
|
+
F: __dxlog_file18,
|
|
4805
4869
|
L: 241,
|
|
4806
4870
|
S: this,
|
|
4807
4871
|
A: [
|
|
@@ -4809,8 +4873,8 @@ var ClientServicesHost = class ClientServicesHost2 {
|
|
|
4809
4873
|
"'config not set'"
|
|
4810
4874
|
]
|
|
4811
4875
|
});
|
|
4812
|
-
|
|
4813
|
-
F:
|
|
4876
|
+
invariant15(this._storage, "storage not set", {
|
|
4877
|
+
F: __dxlog_file18,
|
|
4814
4878
|
L: 242,
|
|
4815
4879
|
S: this,
|
|
4816
4880
|
A: [
|
|
@@ -4818,8 +4882,8 @@ var ClientServicesHost = class ClientServicesHost2 {
|
|
|
4818
4882
|
"'storage not set'"
|
|
4819
4883
|
]
|
|
4820
4884
|
});
|
|
4821
|
-
|
|
4822
|
-
F:
|
|
4885
|
+
invariant15(this._signalManager, "signal manager not set", {
|
|
4886
|
+
F: __dxlog_file18,
|
|
4823
4887
|
L: 243,
|
|
4824
4888
|
S: this,
|
|
4825
4889
|
A: [
|
|
@@ -4827,8 +4891,8 @@ var ClientServicesHost = class ClientServicesHost2 {
|
|
|
4827
4891
|
"'signal manager not set'"
|
|
4828
4892
|
]
|
|
4829
4893
|
});
|
|
4830
|
-
|
|
4831
|
-
F:
|
|
4894
|
+
invariant15(this._networkManager, "network manager not set", {
|
|
4895
|
+
F: __dxlog_file18,
|
|
4832
4896
|
L: 244,
|
|
4833
4897
|
S: this,
|
|
4834
4898
|
A: [
|
|
@@ -4840,7 +4904,7 @@ var ClientServicesHost = class ClientServicesHost2 {
|
|
|
4840
4904
|
log16("opening...", {
|
|
4841
4905
|
lockKey: this._resourceLock?.lockKey
|
|
4842
4906
|
}, {
|
|
4843
|
-
F:
|
|
4907
|
+
F: __dxlog_file18,
|
|
4844
4908
|
L: 247,
|
|
4845
4909
|
S: this,
|
|
4846
4910
|
C: (f, a) => f(...a)
|
|
@@ -4886,7 +4950,7 @@ var ClientServicesHost = class ClientServicesHost2 {
|
|
|
4886
4950
|
log16("opened", {
|
|
4887
4951
|
deviceKey
|
|
4888
4952
|
}, {
|
|
4889
|
-
F:
|
|
4953
|
+
F: __dxlog_file18,
|
|
4890
4954
|
L: 316,
|
|
4891
4955
|
S: this,
|
|
4892
4956
|
C: (f, a) => f(...a)
|
|
@@ -4894,7 +4958,7 @@ var ClientServicesHost = class ClientServicesHost2 {
|
|
|
4894
4958
|
log16.trace("dxos.client-services.host.open", trace8.end({
|
|
4895
4959
|
id: traceId
|
|
4896
4960
|
}), {
|
|
4897
|
-
F:
|
|
4961
|
+
F: __dxlog_file18,
|
|
4898
4962
|
L: 317,
|
|
4899
4963
|
S: this,
|
|
4900
4964
|
C: (f, a) => f(...a)
|
|
@@ -4908,7 +4972,7 @@ var ClientServicesHost = class ClientServicesHost2 {
|
|
|
4908
4972
|
log16("closing...", {
|
|
4909
4973
|
deviceKey
|
|
4910
4974
|
}, {
|
|
4911
|
-
F:
|
|
4975
|
+
F: __dxlog_file18,
|
|
4912
4976
|
L: 328,
|
|
4913
4977
|
S: this,
|
|
4914
4978
|
C: (f, a) => f(...a)
|
|
@@ -4924,24 +4988,24 @@ var ClientServicesHost = class ClientServicesHost2 {
|
|
|
4924
4988
|
log16("closed", {
|
|
4925
4989
|
deviceKey
|
|
4926
4990
|
}, {
|
|
4927
|
-
F:
|
|
4991
|
+
F: __dxlog_file18,
|
|
4928
4992
|
L: 335,
|
|
4929
4993
|
S: this,
|
|
4930
4994
|
C: (f, a) => f(...a)
|
|
4931
4995
|
});
|
|
4932
4996
|
}
|
|
4933
4997
|
async reset() {
|
|
4934
|
-
const traceId =
|
|
4998
|
+
const traceId = PublicKey11.random().toHex();
|
|
4935
4999
|
log16.trace("dxos.sdk.client-services-host.reset", trace8.begin({
|
|
4936
5000
|
id: traceId
|
|
4937
5001
|
}), {
|
|
4938
|
-
F:
|
|
5002
|
+
F: __dxlog_file18,
|
|
4939
5003
|
L: 340,
|
|
4940
5004
|
S: this,
|
|
4941
5005
|
C: (f, a) => f(...a)
|
|
4942
5006
|
});
|
|
4943
5007
|
log16("resetting...", void 0, {
|
|
4944
|
-
F:
|
|
5008
|
+
F: __dxlog_file18,
|
|
4945
5009
|
L: 342,
|
|
4946
5010
|
S: this,
|
|
4947
5011
|
C: (f, a) => f(...a)
|
|
@@ -4949,7 +5013,7 @@ var ClientServicesHost = class ClientServicesHost2 {
|
|
|
4949
5013
|
await this._serviceContext?.close();
|
|
4950
5014
|
await this._storage.reset();
|
|
4951
5015
|
log16("reset", void 0, {
|
|
4952
|
-
F:
|
|
5016
|
+
F: __dxlog_file18,
|
|
4953
5017
|
L: 345,
|
|
4954
5018
|
S: this,
|
|
4955
5019
|
C: (f, a) => f(...a)
|
|
@@ -4957,7 +5021,7 @@ var ClientServicesHost = class ClientServicesHost2 {
|
|
|
4957
5021
|
log16.trace("dxos.sdk.client-services-host.reset", trace8.end({
|
|
4958
5022
|
id: traceId
|
|
4959
5023
|
}), {
|
|
4960
|
-
F:
|
|
5024
|
+
F: __dxlog_file18,
|
|
4961
5025
|
L: 346,
|
|
4962
5026
|
S: this,
|
|
4963
5027
|
C: (f, a) => f(...a)
|
|
@@ -5035,4 +5099,4 @@ export {
|
|
|
5035
5099
|
createDefaultModelFactory,
|
|
5036
5100
|
ClientServicesHost
|
|
5037
5101
|
};
|
|
5038
|
-
//# sourceMappingURL=chunk-
|
|
5102
|
+
//# sourceMappingURL=chunk-ZGPBGQ4M.mjs.map
|