@dxos/client-services 0.5.9-main.6030c93 → 0.5.9-main.61e0d89
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-WC3HHHUZ.mjs → chunk-TP67W2QM.mjs} +1008 -615
- package/dist/lib/browser/chunk-TP67W2QM.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +13 -2
- package/dist/lib/browser/index.mjs.map +1 -1
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/packlets/testing/index.mjs +10 -3
- package/dist/lib/browser/packlets/testing/index.mjs.map +1 -1
- package/dist/lib/node/{chunk-TWLCVZQI.cjs → chunk-TBHDGC6X.cjs} +1100 -707
- package/dist/lib/node/chunk-TBHDGC6X.cjs.map +7 -0
- package/dist/lib/node/index.cjs +53 -42
- package/dist/lib/node/index.cjs.map +1 -1
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/packlets/testing/index.cjs +17 -10
- package/dist/lib/node/packlets/testing/index.cjs.map +1 -1
- package/dist/types/src/packlets/identity/contacts-service.d.ts +14 -0
- package/dist/types/src/packlets/identity/contacts-service.d.ts.map +1 -0
- package/dist/types/src/packlets/identity/identity-service.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/invitations-handler.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/space-invitation-protocol.d.ts.map +1 -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 +10 -1
- package/dist/types/src/packlets/spaces/data-space-manager.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/spaces-service.d.ts +4 -1
- package/dist/types/src/packlets/spaces/spaces-service.d.ts.map +1 -1
- package/dist/types/src/packlets/storage/index.d.ts +1 -0
- package/dist/types/src/packlets/storage/index.d.ts.map +1 -1
- package/dist/types/src/packlets/storage/profile-archive.d.ts +14 -0
- package/dist/types/src/packlets/storage/profile-archive.d.ts.map +1 -0
- package/dist/types/src/version.d.ts +1 -1
- package/package.json +36 -36
- package/src/packlets/identity/contacts-service.ts +85 -0
- package/src/packlets/identity/identity-service.ts +27 -6
- package/src/packlets/invitations/invitations-handler.ts +13 -5
- package/src/packlets/invitations/space-invitation-protocol.ts +11 -32
- package/src/packlets/services/service-host.ts +12 -4
- package/src/packlets/spaces/data-space-manager.ts +55 -2
- package/src/packlets/spaces/data-space.ts +5 -5
- package/src/packlets/spaces/spaces-service.ts +50 -2
- package/src/packlets/storage/index.ts +1 -0
- package/src/packlets/storage/profile-archive.ts +97 -0
- package/src/version.ts +1 -1
- package/dist/lib/browser/chunk-WC3HHHUZ.mjs.map +0 -7
- package/dist/lib/node/chunk-TWLCVZQI.cjs.map +0 -7
|
@@ -85,6 +85,7 @@ var subscribeToFeedBlocks = ({ feedStore }, { feedKey, maxBlocks = 10 }) => {
|
|
|
85
85
|
import { Stream as Stream2 } from "@dxos/codec-protobuf";
|
|
86
86
|
import { Context } from "@dxos/context";
|
|
87
87
|
import { PublicKey as PublicKey2 } from "@dxos/keys";
|
|
88
|
+
var __dxlog_file = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/devtools/network.ts";
|
|
88
89
|
var subscribeToNetworkStatus = ({ signalManager }) => new Stream2(({ next, close }) => {
|
|
89
90
|
const update = () => {
|
|
90
91
|
try {
|
|
@@ -100,7 +101,10 @@ var subscribeToNetworkStatus = ({ signalManager }) => new Stream2(({ next, close
|
|
|
100
101
|
update();
|
|
101
102
|
});
|
|
102
103
|
var subscribeToSignal = ({ signalManager }) => new Stream2(({ next }) => {
|
|
103
|
-
const ctx = new Context(
|
|
104
|
+
const ctx = new Context(void 0, {
|
|
105
|
+
F: __dxlog_file,
|
|
106
|
+
L: 36
|
|
107
|
+
});
|
|
104
108
|
signalManager.onMessage.on(ctx, (message) => {
|
|
105
109
|
next({
|
|
106
110
|
message: {
|
|
@@ -355,7 +359,7 @@ import { SpaceMember } from "@dxos/protocols/proto/dxos/client/services";
|
|
|
355
359
|
import { TRACE_PROCESSOR } from "@dxos/tracing";
|
|
356
360
|
|
|
357
361
|
// packages/sdk/client-services/src/version.ts
|
|
358
|
-
var DXOS_VERSION = "0.5.9-main.
|
|
362
|
+
var DXOS_VERSION = "0.5.9-main.61e0d89";
|
|
359
363
|
|
|
360
364
|
// packages/sdk/client-services/src/packlets/services/platform.ts
|
|
361
365
|
import { Platform } from "@dxos/protocols/proto/dxos/client/services";
|
|
@@ -388,7 +392,7 @@ var getPlatform = () => {
|
|
|
388
392
|
};
|
|
389
393
|
|
|
390
394
|
// packages/sdk/client-services/src/packlets/diagnostics/diagnostics.ts
|
|
391
|
-
var
|
|
395
|
+
var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/diagnostics/diagnostics.ts";
|
|
392
396
|
var DEFAULT_TIMEOUT = 1e3;
|
|
393
397
|
var createDiagnostics = async (clientServices, serviceContext, config) => {
|
|
394
398
|
const diagnostics = {
|
|
@@ -405,7 +409,7 @@ var createDiagnostics = async (clientServices, serviceContext, config) => {
|
|
|
405
409
|
await Promise.all([
|
|
406
410
|
(async () => {
|
|
407
411
|
invariant(clientServices.LoggingService, "SystemService is not available.", {
|
|
408
|
-
F:
|
|
412
|
+
F: __dxlog_file2,
|
|
409
413
|
L: 110,
|
|
410
414
|
S: void 0,
|
|
411
415
|
A: [
|
|
@@ -510,7 +514,7 @@ var getStorageDiagnostics = async () => {
|
|
|
510
514
|
// packages/sdk/client-services/src/packlets/diagnostics/browser-diagnostics-broadcast.ts
|
|
511
515
|
import { Trigger } from "@dxos/async";
|
|
512
516
|
import { log } from "@dxos/log";
|
|
513
|
-
var
|
|
517
|
+
var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/diagnostics/browser-diagnostics-broadcast.ts";
|
|
514
518
|
var CHANNEL_NAME = "dxos.diagnostics.broadcast";
|
|
515
519
|
var MessageType;
|
|
516
520
|
(function(MessageType2) {
|
|
@@ -579,7 +583,7 @@ var createCollectDiagnosticsBroadcastHandler = (systemService) => {
|
|
|
579
583
|
}
|
|
580
584
|
} catch (error) {
|
|
581
585
|
log.catch(error, void 0, {
|
|
582
|
-
F:
|
|
586
|
+
F: __dxlog_file3,
|
|
583
587
|
L: 77,
|
|
584
588
|
S: void 0,
|
|
585
589
|
C: (f, a) => f(...a)
|
|
@@ -687,7 +691,7 @@ import { Context as Context2 } from "@dxos/context";
|
|
|
687
691
|
import { verifyCredential } from "@dxos/credentials";
|
|
688
692
|
import { log as log2 } from "@dxos/log";
|
|
689
693
|
import { schema } from "@dxos/protocols";
|
|
690
|
-
var
|
|
694
|
+
var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/authenticator.ts";
|
|
691
695
|
var Credential = schema.getCodecForType("dxos.halo.credentials.Credential");
|
|
692
696
|
var createAuthProvider = (signer) => async (nonce) => {
|
|
693
697
|
const credential = await signer.createCredential({
|
|
@@ -702,7 +706,10 @@ var createAuthProvider = (signer) => async (nonce) => {
|
|
|
702
706
|
var TrustedKeySetAuthVerifier = class {
|
|
703
707
|
constructor(_params) {
|
|
704
708
|
this._params = _params;
|
|
705
|
-
this._ctx = new Context2(
|
|
709
|
+
this._ctx = new Context2(void 0, {
|
|
710
|
+
F: __dxlog_file4,
|
|
711
|
+
L: 45
|
|
712
|
+
});
|
|
706
713
|
}
|
|
707
714
|
async close() {
|
|
708
715
|
await this._ctx.dispose();
|
|
@@ -713,7 +720,7 @@ var TrustedKeySetAuthVerifier = class {
|
|
|
713
720
|
log2("authenticating...", {
|
|
714
721
|
credential
|
|
715
722
|
}, {
|
|
716
|
-
F:
|
|
723
|
+
F: __dxlog_file4,
|
|
717
724
|
L: 56,
|
|
718
725
|
S: this,
|
|
719
726
|
C: (f, a) => f(...a)
|
|
@@ -723,7 +730,7 @@ var TrustedKeySetAuthVerifier = class {
|
|
|
723
730
|
log2("Invalid credential", {
|
|
724
731
|
result
|
|
725
732
|
}, {
|
|
726
|
-
F:
|
|
733
|
+
F: __dxlog_file4,
|
|
727
734
|
L: 60,
|
|
728
735
|
S: this,
|
|
729
736
|
C: (f, a) => f(...a)
|
|
@@ -735,7 +742,7 @@ var TrustedKeySetAuthVerifier = class {
|
|
|
735
742
|
nonce,
|
|
736
743
|
credential
|
|
737
744
|
}, {
|
|
738
|
-
F:
|
|
745
|
+
F: __dxlog_file4,
|
|
739
746
|
L: 65,
|
|
740
747
|
S: this,
|
|
741
748
|
C: (f, a) => f(...a)
|
|
@@ -746,7 +753,7 @@ var TrustedKeySetAuthVerifier = class {
|
|
|
746
753
|
log2("key is not currently in trusted set, waiting...", {
|
|
747
754
|
key: credential.issuer
|
|
748
755
|
}, {
|
|
749
|
-
F:
|
|
756
|
+
F: __dxlog_file4,
|
|
750
757
|
L: 70,
|
|
751
758
|
S: this,
|
|
752
759
|
C: (f, a) => f(...a)
|
|
@@ -762,7 +769,7 @@ var TrustedKeySetAuthVerifier = class {
|
|
|
762
769
|
log2("auth success", {
|
|
763
770
|
key: credential.issuer
|
|
764
771
|
}, {
|
|
765
|
-
F:
|
|
772
|
+
F: __dxlog_file4,
|
|
766
773
|
L: 81,
|
|
767
774
|
S: this,
|
|
768
775
|
C: (f, a) => f(...a)
|
|
@@ -772,7 +779,7 @@ var TrustedKeySetAuthVerifier = class {
|
|
|
772
779
|
log2("key is not currently in trusted set, waiting...", {
|
|
773
780
|
key: credential.issuer
|
|
774
781
|
}, {
|
|
775
|
-
F:
|
|
782
|
+
F: __dxlog_file4,
|
|
776
783
|
L: 84,
|
|
777
784
|
S: this,
|
|
778
785
|
C: (f, a) => f(...a)
|
|
@@ -813,7 +820,7 @@ import { ComplexSet } from "@dxos/util";
|
|
|
813
820
|
import { getCredentialAssertion } from "@dxos/credentials";
|
|
814
821
|
import { SpaceId } from "@dxos/keys";
|
|
815
822
|
import { log as log3 } from "@dxos/log";
|
|
816
|
-
var
|
|
823
|
+
var __dxlog_file5 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/default-space-state-machine.ts";
|
|
817
824
|
var DefaultSpaceStateMachine = class {
|
|
818
825
|
constructor(_params) {
|
|
819
826
|
this._params = _params;
|
|
@@ -830,7 +837,7 @@ var DefaultSpaceStateMachine = class {
|
|
|
830
837
|
expectedIdentity: this._params.identityKey,
|
|
831
838
|
credential
|
|
832
839
|
}, {
|
|
833
|
-
F:
|
|
840
|
+
F: __dxlog_file5,
|
|
834
841
|
L: 32,
|
|
835
842
|
S: this,
|
|
836
843
|
C: (f, a) => f(...a)
|
|
@@ -841,7 +848,7 @@ var DefaultSpaceStateMachine = class {
|
|
|
841
848
|
log3.warn("Invalid default space id", {
|
|
842
849
|
id: assertion.spaceId
|
|
843
850
|
}, {
|
|
844
|
-
F:
|
|
851
|
+
F: __dxlog_file5,
|
|
845
852
|
L: 36,
|
|
846
853
|
S: this,
|
|
847
854
|
C: (f, a) => f(...a)
|
|
@@ -866,7 +873,7 @@ function _ts_decorate2(decorators, target, key, desc) {
|
|
|
866
873
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
867
874
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
868
875
|
}
|
|
869
|
-
var
|
|
876
|
+
var __dxlog_file6 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/identity.ts";
|
|
870
877
|
var Identity = class {
|
|
871
878
|
constructor({ space, signer, identityKey, deviceKey, presence }) {
|
|
872
879
|
this.stateUpdate = new Event();
|
|
@@ -878,7 +885,7 @@ var Identity = class {
|
|
|
878
885
|
log4.trace("dxos.halo.device", {
|
|
879
886
|
deviceKey
|
|
880
887
|
}, {
|
|
881
|
-
F:
|
|
888
|
+
F: __dxlog_file6,
|
|
882
889
|
L: 70,
|
|
883
890
|
S: this,
|
|
884
891
|
C: (f, a) => f(...a)
|
|
@@ -957,7 +964,7 @@ var Identity = class {
|
|
|
957
964
|
*/
|
|
958
965
|
getIdentityCredentialSigner() {
|
|
959
966
|
invariant2(this._deviceStateMachine.deviceCredentialChain, "Device credential chain is not ready.", {
|
|
960
|
-
F:
|
|
967
|
+
F: __dxlog_file6,
|
|
961
968
|
L: 159,
|
|
962
969
|
S: this,
|
|
963
970
|
A: [
|
|
@@ -1001,7 +1008,7 @@ var Identity = class {
|
|
|
1001
1008
|
controlFeedKey,
|
|
1002
1009
|
dataFeedKey
|
|
1003
1010
|
}, {
|
|
1004
|
-
F:
|
|
1011
|
+
F: __dxlog_file6,
|
|
1005
1012
|
L: 184,
|
|
1006
1013
|
S: this,
|
|
1007
1014
|
C: (f, a) => f(...a)
|
|
@@ -1078,7 +1085,7 @@ function _ts_decorate3(decorators, target, key, desc) {
|
|
|
1078
1085
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
1079
1086
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1080
1087
|
}
|
|
1081
|
-
var
|
|
1088
|
+
var __dxlog_file7 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/identity-manager.ts";
|
|
1082
1089
|
var DEVICE_PRESENCE_ANNOUNCE_INTERVAL = 1e4;
|
|
1083
1090
|
var DEVICE_PRESENCE_OFFLINE_TIMEOUT = 2e4;
|
|
1084
1091
|
var IdentityManager = class {
|
|
@@ -1102,7 +1109,7 @@ var IdentityManager = class {
|
|
|
1102
1109
|
log5.trace("dxos.halo.identity-manager.open", trace3.begin({
|
|
1103
1110
|
id: traceId
|
|
1104
1111
|
}), {
|
|
1105
|
-
F:
|
|
1112
|
+
F: __dxlog_file7,
|
|
1106
1113
|
L: 104,
|
|
1107
1114
|
S: this,
|
|
1108
1115
|
C: (f, a) => f(...a)
|
|
@@ -1111,7 +1118,7 @@ var IdentityManager = class {
|
|
|
1111
1118
|
log5("identity record", {
|
|
1112
1119
|
identityRecord
|
|
1113
1120
|
}, {
|
|
1114
|
-
F:
|
|
1121
|
+
F: __dxlog_file7,
|
|
1115
1122
|
L: 107,
|
|
1116
1123
|
S: this,
|
|
1117
1124
|
C: (f, a) => f(...a)
|
|
@@ -1124,7 +1131,7 @@ var IdentityManager = class {
|
|
|
1124
1131
|
identityKey: identityRecord.identityKey,
|
|
1125
1132
|
displayName: this._identity.profileDocument?.displayName
|
|
1126
1133
|
}, {
|
|
1127
|
-
F:
|
|
1134
|
+
F: __dxlog_file7,
|
|
1128
1135
|
L: 112,
|
|
1129
1136
|
S: this,
|
|
1130
1137
|
C: (f, a) => f(...a)
|
|
@@ -1134,18 +1141,21 @@ var IdentityManager = class {
|
|
|
1134
1141
|
log5.trace("dxos.halo.identity-manager.open", trace3.end({
|
|
1135
1142
|
id: traceId
|
|
1136
1143
|
}), {
|
|
1137
|
-
F:
|
|
1144
|
+
F: __dxlog_file7,
|
|
1138
1145
|
L: 119,
|
|
1139
1146
|
S: this,
|
|
1140
1147
|
C: (f, a) => f(...a)
|
|
1141
1148
|
});
|
|
1142
1149
|
}
|
|
1143
1150
|
async close() {
|
|
1144
|
-
await this._identity?.close(new Context3(
|
|
1151
|
+
await this._identity?.close(new Context3(void 0, {
|
|
1152
|
+
F: __dxlog_file7,
|
|
1153
|
+
L: 123
|
|
1154
|
+
}));
|
|
1145
1155
|
}
|
|
1146
1156
|
async createIdentity({ displayName, deviceProfile } = {}) {
|
|
1147
1157
|
invariant3(!this._identity, "Identity already exists.", {
|
|
1148
|
-
F:
|
|
1158
|
+
F: __dxlog_file7,
|
|
1149
1159
|
L: 128,
|
|
1150
1160
|
S: this,
|
|
1151
1161
|
A: [
|
|
@@ -1154,7 +1164,7 @@ var IdentityManager = class {
|
|
|
1154
1164
|
]
|
|
1155
1165
|
});
|
|
1156
1166
|
log5("creating identity...", void 0, {
|
|
1157
|
-
F:
|
|
1167
|
+
F: __dxlog_file7,
|
|
1158
1168
|
L: 129,
|
|
1159
1169
|
S: this,
|
|
1160
1170
|
C: (f, a) => f(...a)
|
|
@@ -1171,11 +1181,14 @@ var IdentityManager = class {
|
|
|
1171
1181
|
}
|
|
1172
1182
|
};
|
|
1173
1183
|
const identity = await this._constructIdentity(identityRecord);
|
|
1174
|
-
await identity.open(new Context3(
|
|
1184
|
+
await identity.open(new Context3(void 0, {
|
|
1185
|
+
F: __dxlog_file7,
|
|
1186
|
+
L: 144
|
|
1187
|
+
}));
|
|
1175
1188
|
{
|
|
1176
1189
|
const generator = new CredentialGenerator(this._keyring, identityRecord.identityKey, identityRecord.deviceKey);
|
|
1177
1190
|
invariant3(identityRecord.haloSpace.genesisFeedKey, "Genesis feed key is required.", {
|
|
1178
|
-
F:
|
|
1191
|
+
F: __dxlog_file7,
|
|
1179
1192
|
L: 148,
|
|
1180
1193
|
S: this,
|
|
1181
1194
|
A: [
|
|
@@ -1184,7 +1197,7 @@ var IdentityManager = class {
|
|
|
1184
1197
|
]
|
|
1185
1198
|
});
|
|
1186
1199
|
invariant3(identityRecord.haloSpace.dataFeedKey, "Data feed key is required.", {
|
|
1187
|
-
F:
|
|
1200
|
+
F: __dxlog_file7,
|
|
1188
1201
|
L: 149,
|
|
1189
1202
|
S: this,
|
|
1190
1203
|
A: [
|
|
@@ -1223,7 +1236,7 @@ var IdentityManager = class {
|
|
|
1223
1236
|
identityKey: identityRecord.identityKey,
|
|
1224
1237
|
displayName: this._identity.profileDocument?.displayName
|
|
1225
1238
|
}, {
|
|
1226
|
-
F:
|
|
1239
|
+
F: __dxlog_file7,
|
|
1227
1240
|
L: 191,
|
|
1228
1241
|
S: this,
|
|
1229
1242
|
C: (f, a) => f(...a)
|
|
@@ -1234,7 +1247,7 @@ var IdentityManager = class {
|
|
|
1234
1247
|
deviceKey: identity.deviceKey,
|
|
1235
1248
|
profile: identity.profileDocument
|
|
1236
1249
|
}, {
|
|
1237
|
-
F:
|
|
1250
|
+
F: __dxlog_file7,
|
|
1238
1251
|
L: 197,
|
|
1239
1252
|
S: this,
|
|
1240
1253
|
C: (f, a) => f(...a)
|
|
@@ -1271,13 +1284,13 @@ var IdentityManager = class {
|
|
|
1271
1284
|
log5("accepting identity", {
|
|
1272
1285
|
params
|
|
1273
1286
|
}, {
|
|
1274
|
-
F:
|
|
1287
|
+
F: __dxlog_file7,
|
|
1275
1288
|
L: 235,
|
|
1276
1289
|
S: this,
|
|
1277
1290
|
C: (f, a) => f(...a)
|
|
1278
1291
|
});
|
|
1279
1292
|
invariant3(!this._identity, "Identity already exists.", {
|
|
1280
|
-
F:
|
|
1293
|
+
F: __dxlog_file7,
|
|
1281
1294
|
L: 236,
|
|
1282
1295
|
S: this,
|
|
1283
1296
|
A: [
|
|
@@ -1297,7 +1310,10 @@ var IdentityManager = class {
|
|
|
1297
1310
|
}
|
|
1298
1311
|
};
|
|
1299
1312
|
const identity = await this._constructIdentity(identityRecord);
|
|
1300
|
-
await identity.open(new Context3(
|
|
1313
|
+
await identity.open(new Context3(void 0, {
|
|
1314
|
+
F: __dxlog_file7,
|
|
1315
|
+
L: 251
|
|
1316
|
+
}));
|
|
1301
1317
|
this._identity = identity;
|
|
1302
1318
|
await this._metadataStore.setIdentityRecord(identityRecord);
|
|
1303
1319
|
await this._identity.ready();
|
|
@@ -1305,7 +1321,7 @@ var IdentityManager = class {
|
|
|
1305
1321
|
identityKey: identityRecord.identityKey,
|
|
1306
1322
|
displayName: this._identity.profileDocument?.displayName
|
|
1307
1323
|
}, {
|
|
1308
|
-
F:
|
|
1324
|
+
F: __dxlog_file7,
|
|
1309
1325
|
L: 255,
|
|
1310
1326
|
S: this,
|
|
1311
1327
|
C: (f, a) => f(...a)
|
|
@@ -1319,7 +1335,7 @@ var IdentityManager = class {
|
|
|
1319
1335
|
identityKey: identity.identityKey,
|
|
1320
1336
|
deviceKey: identity.deviceKey
|
|
1321
1337
|
}, {
|
|
1322
|
-
F:
|
|
1338
|
+
F: __dxlog_file7,
|
|
1323
1339
|
L: 265,
|
|
1324
1340
|
S: this,
|
|
1325
1341
|
C: (f, a) => f(...a)
|
|
@@ -1331,7 +1347,7 @@ var IdentityManager = class {
|
|
|
1331
1347
|
*/
|
|
1332
1348
|
async updateProfile(profile) {
|
|
1333
1349
|
invariant3(this._identity, "Identity not initialized.", {
|
|
1334
|
-
F:
|
|
1350
|
+
F: __dxlog_file7,
|
|
1335
1351
|
L: 273,
|
|
1336
1352
|
S: this,
|
|
1337
1353
|
A: [
|
|
@@ -1362,7 +1378,7 @@ var IdentityManager = class {
|
|
|
1362
1378
|
}
|
|
1363
1379
|
async updateDeviceProfile(profile) {
|
|
1364
1380
|
invariant3(this._identity, "Identity not initialized.", {
|
|
1365
|
-
F:
|
|
1381
|
+
F: __dxlog_file7,
|
|
1366
1382
|
L: 290,
|
|
1367
1383
|
S: this,
|
|
1368
1384
|
A: [
|
|
@@ -1398,7 +1414,7 @@ var IdentityManager = class {
|
|
|
1398
1414
|
}
|
|
1399
1415
|
async _constructIdentity(identityRecord) {
|
|
1400
1416
|
invariant3(!this._identity, void 0, {
|
|
1401
|
-
F:
|
|
1417
|
+
F: __dxlog_file7,
|
|
1402
1418
|
L: 316,
|
|
1403
1419
|
S: this,
|
|
1404
1420
|
A: [
|
|
@@ -1409,7 +1425,7 @@ var IdentityManager = class {
|
|
|
1409
1425
|
log5("constructing identity", {
|
|
1410
1426
|
identityRecord
|
|
1411
1427
|
}, {
|
|
1412
|
-
F:
|
|
1428
|
+
F: __dxlog_file7,
|
|
1413
1429
|
L: 317,
|
|
1414
1430
|
S: this,
|
|
1415
1431
|
C: (f, a) => f(...a)
|
|
@@ -1424,7 +1440,7 @@ var IdentityManager = class {
|
|
|
1424
1440
|
gossip
|
|
1425
1441
|
});
|
|
1426
1442
|
invariant3(identityRecord.haloSpace.controlFeedKey, void 0, {
|
|
1427
|
-
F:
|
|
1443
|
+
F: __dxlog_file7,
|
|
1428
1444
|
L: 330,
|
|
1429
1445
|
S: this,
|
|
1430
1446
|
A: [
|
|
@@ -1436,7 +1452,7 @@ var IdentityManager = class {
|
|
|
1436
1452
|
writable: true
|
|
1437
1453
|
});
|
|
1438
1454
|
invariant3(identityRecord.haloSpace.dataFeedKey, void 0, {
|
|
1439
|
-
F:
|
|
1455
|
+
F: __dxlog_file7,
|
|
1440
1456
|
L: 334,
|
|
1441
1457
|
S: this,
|
|
1442
1458
|
A: [
|
|
@@ -1470,7 +1486,7 @@ var IdentityManager = class {
|
|
|
1470
1486
|
log5("done", {
|
|
1471
1487
|
identityKey: identityRecord.identityKey
|
|
1472
1488
|
}, {
|
|
1473
|
-
F:
|
|
1489
|
+
F: __dxlog_file7,
|
|
1474
1490
|
L: 360,
|
|
1475
1491
|
S: this,
|
|
1476
1492
|
C: (f, a) => f(...a)
|
|
@@ -1495,7 +1511,7 @@ var IdentityManager = class {
|
|
|
1495
1511
|
},
|
|
1496
1512
|
onAuthFailure: () => {
|
|
1497
1513
|
log5.warn("auth failure", void 0, {
|
|
1498
|
-
F:
|
|
1514
|
+
F: __dxlog_file7,
|
|
1499
1515
|
L: 385,
|
|
1500
1516
|
S: this,
|
|
1501
1517
|
C: (f, a) => f(...a)
|
|
@@ -1519,13 +1535,17 @@ IdentityManager = _ts_decorate3([
|
|
|
1519
1535
|
], IdentityManager);
|
|
1520
1536
|
|
|
1521
1537
|
// packages/sdk/client-services/src/packlets/identity/identity-service.ts
|
|
1538
|
+
import { Trigger as Trigger3, sleep } from "@dxos/async";
|
|
1522
1539
|
import { Stream as Stream8 } from "@dxos/codec-protobuf";
|
|
1523
1540
|
import { Resource } from "@dxos/context";
|
|
1524
1541
|
import { signPresentation } from "@dxos/credentials";
|
|
1525
1542
|
import { todo } from "@dxos/debug";
|
|
1526
1543
|
import { invariant as invariant4 } from "@dxos/invariant";
|
|
1544
|
+
import { log as log6 } from "@dxos/log";
|
|
1527
1545
|
import { SpaceState } from "@dxos/protocols/proto/dxos/client/services";
|
|
1528
|
-
|
|
1546
|
+
import { safeAwaitAll } from "@dxos/util";
|
|
1547
|
+
var __dxlog_file8 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/identity-service.ts";
|
|
1548
|
+
var DEFAULT_SPACE_SEARCH_TIMEOUT = 1e4;
|
|
1529
1549
|
var IdentityServiceImpl = class extends Resource {
|
|
1530
1550
|
constructor(_identityManager, _keyring, _dataSpaceManagerProvider, _createIdentity, _onProfileUpdate) {
|
|
1531
1551
|
super();
|
|
@@ -1554,8 +1574,8 @@ var IdentityServiceImpl = class extends Resource {
|
|
|
1554
1574
|
const space = await dataSpaceManager.createDefaultSpace();
|
|
1555
1575
|
const identity = this._identityManager.identity;
|
|
1556
1576
|
invariant4(identity, void 0, {
|
|
1557
|
-
F:
|
|
1558
|
-
L:
|
|
1577
|
+
F: __dxlog_file8,
|
|
1578
|
+
L: 59,
|
|
1559
1579
|
S: this,
|
|
1560
1580
|
A: [
|
|
1561
1581
|
"identity",
|
|
@@ -1588,8 +1608,8 @@ var IdentityServiceImpl = class extends Resource {
|
|
|
1588
1608
|
}
|
|
1589
1609
|
async updateProfile(profile) {
|
|
1590
1610
|
invariant4(this._identityManager.identity, "Identity not initialized.", {
|
|
1591
|
-
F:
|
|
1592
|
-
L:
|
|
1611
|
+
F: __dxlog_file8,
|
|
1612
|
+
L: 89,
|
|
1593
1613
|
S: this,
|
|
1594
1614
|
A: [
|
|
1595
1615
|
"this._identityManager.identity",
|
|
@@ -1602,8 +1622,8 @@ var IdentityServiceImpl = class extends Resource {
|
|
|
1602
1622
|
}
|
|
1603
1623
|
async signPresentation({ presentation, nonce }) {
|
|
1604
1624
|
invariant4(this._identityManager.identity, "Identity not initialized.", {
|
|
1605
|
-
F:
|
|
1606
|
-
L:
|
|
1625
|
+
F: __dxlog_file8,
|
|
1626
|
+
L: 96,
|
|
1607
1627
|
S: this,
|
|
1608
1628
|
A: [
|
|
1609
1629
|
"this._identityManager.identity",
|
|
@@ -1619,9 +1639,11 @@ var IdentityServiceImpl = class extends Resource {
|
|
|
1619
1639
|
});
|
|
1620
1640
|
}
|
|
1621
1641
|
async _fixIdentityWithoutDefaultSpace(identity) {
|
|
1622
|
-
let
|
|
1642
|
+
let recodedDefaultSpace = false;
|
|
1643
|
+
let foundDefaultSpace = false;
|
|
1623
1644
|
const dataSpaceManager = this._dataSpaceManagerProvider();
|
|
1624
|
-
|
|
1645
|
+
const recordedDefaultSpaceTrigger = new Trigger3();
|
|
1646
|
+
const allProcessed = safeAwaitAll(dataSpaceManager.spaces.values(), async (space) => {
|
|
1625
1647
|
if (space.state === SpaceState.CLOSED) {
|
|
1626
1648
|
await space.open();
|
|
1627
1649
|
const requiresMigration = space.stateUpdate.waitForCondition(() => space.state === SpaceState.REQUIRES_MIGRATION);
|
|
@@ -1631,12 +1653,29 @@ var IdentityServiceImpl = class extends Resource {
|
|
|
1631
1653
|
]);
|
|
1632
1654
|
}
|
|
1633
1655
|
if (await dataSpaceManager.isDefaultSpace(space)) {
|
|
1656
|
+
if (foundDefaultSpace) {
|
|
1657
|
+
log6.warn("Multiple default spaces found. Using the first one.", {
|
|
1658
|
+
duplicate: space.id
|
|
1659
|
+
}, {
|
|
1660
|
+
F: __dxlog_file8,
|
|
1661
|
+
L: 127,
|
|
1662
|
+
S: this,
|
|
1663
|
+
C: (f, a) => f(...a)
|
|
1664
|
+
});
|
|
1665
|
+
return;
|
|
1666
|
+
}
|
|
1667
|
+
foundDefaultSpace = true;
|
|
1634
1668
|
await identity.updateDefaultSpace(space.id);
|
|
1635
|
-
|
|
1636
|
-
|
|
1669
|
+
recodedDefaultSpace = true;
|
|
1670
|
+
recordedDefaultSpaceTrigger.wake();
|
|
1637
1671
|
}
|
|
1638
|
-
}
|
|
1639
|
-
|
|
1672
|
+
});
|
|
1673
|
+
await Promise.race([
|
|
1674
|
+
allProcessed,
|
|
1675
|
+
recordedDefaultSpaceTrigger.wait(),
|
|
1676
|
+
sleep(DEFAULT_SPACE_SEARCH_TIMEOUT)
|
|
1677
|
+
]);
|
|
1678
|
+
if (!recodedDefaultSpace) {
|
|
1640
1679
|
await this._createDefaultSpace(dataSpaceManager);
|
|
1641
1680
|
}
|
|
1642
1681
|
}
|
|
@@ -1646,7 +1685,7 @@ var IdentityServiceImpl = class extends Resource {
|
|
|
1646
1685
|
import { invariant as invariant5 } from "@dxos/invariant";
|
|
1647
1686
|
import { AlreadyJoinedError } from "@dxos/protocols";
|
|
1648
1687
|
import { Invitation } from "@dxos/protocols/proto/dxos/client/services";
|
|
1649
|
-
var
|
|
1688
|
+
var __dxlog_file9 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/device-invitation-protocol.ts";
|
|
1650
1689
|
var DeviceInvitationProtocol = class {
|
|
1651
1690
|
constructor(_keyring, _getIdentity, _acceptIdentity) {
|
|
1652
1691
|
this._keyring = _keyring;
|
|
@@ -1672,7 +1711,7 @@ var DeviceInvitationProtocol = class {
|
|
|
1672
1711
|
}
|
|
1673
1712
|
async admit(_, request) {
|
|
1674
1713
|
invariant5(request.device, void 0, {
|
|
1675
|
-
F:
|
|
1714
|
+
F: __dxlog_file9,
|
|
1676
1715
|
L: 50,
|
|
1677
1716
|
S: this,
|
|
1678
1717
|
A: [
|
|
@@ -1718,7 +1757,7 @@ var DeviceInvitationProtocol = class {
|
|
|
1718
1757
|
}
|
|
1719
1758
|
async accept(response, request) {
|
|
1720
1759
|
invariant5(response.device, void 0, {
|
|
1721
|
-
F:
|
|
1760
|
+
F: __dxlog_file9,
|
|
1722
1761
|
L: 95,
|
|
1723
1762
|
S: this,
|
|
1724
1763
|
A: [
|
|
@@ -1728,7 +1767,7 @@ var DeviceInvitationProtocol = class {
|
|
|
1728
1767
|
});
|
|
1729
1768
|
const { identityKey, haloSpaceKey, genesisFeedKey, controlTimeframe } = response.device;
|
|
1730
1769
|
invariant5(request.device, void 0, {
|
|
1731
|
-
F:
|
|
1770
|
+
F: __dxlog_file9,
|
|
1732
1771
|
L: 98,
|
|
1733
1772
|
S: this,
|
|
1734
1773
|
A: [
|
|
@@ -1760,7 +1799,7 @@ import { ContextDisposedError as ContextDisposedError2 } from "@dxos/context";
|
|
|
1760
1799
|
import { createKeyPair, sign } from "@dxos/crypto";
|
|
1761
1800
|
import { invariant as invariant9 } from "@dxos/invariant";
|
|
1762
1801
|
import { PublicKey as PublicKey7 } from "@dxos/keys";
|
|
1763
|
-
import { log as
|
|
1802
|
+
import { log as log10 } from "@dxos/log";
|
|
1764
1803
|
import { createTeleportProtocolFactory } from "@dxos/network-manager";
|
|
1765
1804
|
import { InvalidInvitationExtensionRoleError as InvalidInvitationExtensionRoleError3, trace as trace5 } from "@dxos/protocols";
|
|
1766
1805
|
import { Invitation as Invitation4 } from "@dxos/protocols/proto/dxos/client/services";
|
|
@@ -1769,10 +1808,10 @@ import { Options as Options4 } from "@dxos/protocols/proto/dxos/halo/invitations
|
|
|
1769
1808
|
import { ComplexSet as ComplexSet3 } from "@dxos/util";
|
|
1770
1809
|
|
|
1771
1810
|
// packages/sdk/client-services/src/packlets/invitations/invitation-guest-extenstion.ts
|
|
1772
|
-
import { Trigger as
|
|
1811
|
+
import { Trigger as Trigger4 } from "@dxos/async";
|
|
1773
1812
|
import { cancelWithContext as cancelWithContext2, Context as Context4 } from "@dxos/context";
|
|
1774
1813
|
import { invariant as invariant6 } from "@dxos/invariant";
|
|
1775
|
-
import { log as
|
|
1814
|
+
import { log as log7 } from "@dxos/log";
|
|
1776
1815
|
import { InvalidInvitationExtensionRoleError, schema as schema2 } from "@dxos/protocols";
|
|
1777
1816
|
import { Options } from "@dxos/protocols/proto/dxos/halo/invitations";
|
|
1778
1817
|
import { RpcExtension } from "@dxos/teleport";
|
|
@@ -1797,7 +1836,7 @@ var tryAcquireBeforeContextDisposed = async (ctx, mutex) => {
|
|
|
1797
1836
|
};
|
|
1798
1837
|
|
|
1799
1838
|
// packages/sdk/client-services/src/packlets/invitations/invitation-guest-extenstion.ts
|
|
1800
|
-
var
|
|
1839
|
+
var __dxlog_file10 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitation-guest-extenstion.ts";
|
|
1801
1840
|
var OPTIONS_TIMEOUT = 1e4;
|
|
1802
1841
|
var InvitationGuestExtension = class extends RpcExtension {
|
|
1803
1842
|
constructor(_invitationFlowMutex, _callbacks) {
|
|
@@ -1811,8 +1850,11 @@ var InvitationGuestExtension = class extends RpcExtension {
|
|
|
1811
1850
|
});
|
|
1812
1851
|
this._invitationFlowMutex = _invitationFlowMutex;
|
|
1813
1852
|
this._callbacks = _callbacks;
|
|
1814
|
-
this._ctx = new Context4(
|
|
1815
|
-
|
|
1853
|
+
this._ctx = new Context4(void 0, {
|
|
1854
|
+
F: __dxlog_file10,
|
|
1855
|
+
L: 33
|
|
1856
|
+
});
|
|
1857
|
+
this._remoteOptionsTrigger = new Trigger4();
|
|
1816
1858
|
this._invitationFlowLock = null;
|
|
1817
1859
|
}
|
|
1818
1860
|
hasFlowLock() {
|
|
@@ -1823,7 +1865,7 @@ var InvitationGuestExtension = class extends RpcExtension {
|
|
|
1823
1865
|
InvitationHostService: {
|
|
1824
1866
|
options: async (options) => {
|
|
1825
1867
|
invariant6(!this._remoteOptions, "Remote options already set.", {
|
|
1826
|
-
F:
|
|
1868
|
+
F: __dxlog_file10,
|
|
1827
1869
|
L: 63,
|
|
1828
1870
|
S: this,
|
|
1829
1871
|
A: [
|
|
@@ -1849,15 +1891,15 @@ var InvitationGuestExtension = class extends RpcExtension {
|
|
|
1849
1891
|
async onOpen(context) {
|
|
1850
1892
|
await super.onOpen(context);
|
|
1851
1893
|
try {
|
|
1852
|
-
|
|
1853
|
-
F:
|
|
1894
|
+
log7("guest acquire lock", void 0, {
|
|
1895
|
+
F: __dxlog_file10,
|
|
1854
1896
|
L: 84,
|
|
1855
1897
|
S: this,
|
|
1856
1898
|
C: (f, a) => f(...a)
|
|
1857
1899
|
});
|
|
1858
1900
|
this._invitationFlowLock = await tryAcquireBeforeContextDisposed(this._ctx, this._invitationFlowMutex);
|
|
1859
|
-
|
|
1860
|
-
F:
|
|
1901
|
+
log7("guest lock acquired", void 0, {
|
|
1902
|
+
F: __dxlog_file10,
|
|
1861
1903
|
L: 86,
|
|
1862
1904
|
S: this,
|
|
1863
1905
|
C: (f, a) => f(...a)
|
|
@@ -1865,8 +1907,8 @@ var InvitationGuestExtension = class extends RpcExtension {
|
|
|
1865
1907
|
await cancelWithContext2(this._ctx, this.rpc.InvitationHostService.options({
|
|
1866
1908
|
role: Options.Role.GUEST
|
|
1867
1909
|
}));
|
|
1868
|
-
|
|
1869
|
-
F:
|
|
1910
|
+
log7("options sent", void 0, {
|
|
1911
|
+
F: __dxlog_file10,
|
|
1870
1912
|
L: 88,
|
|
1871
1913
|
S: this,
|
|
1872
1914
|
C: (f, a) => f(...a)
|
|
@@ -1874,8 +1916,8 @@ var InvitationGuestExtension = class extends RpcExtension {
|
|
|
1874
1916
|
await cancelWithContext2(this._ctx, this._remoteOptionsTrigger.wait({
|
|
1875
1917
|
timeout: OPTIONS_TIMEOUT
|
|
1876
1918
|
}));
|
|
1877
|
-
|
|
1878
|
-
F:
|
|
1919
|
+
log7("options received", void 0, {
|
|
1920
|
+
F: __dxlog_file10,
|
|
1879
1921
|
L: 90,
|
|
1880
1922
|
S: this,
|
|
1881
1923
|
C: (f, a) => f(...a)
|
|
@@ -1908,8 +1950,8 @@ var InvitationGuestExtension = class extends RpcExtension {
|
|
|
1908
1950
|
if (this._invitationFlowLock != null) {
|
|
1909
1951
|
this._invitationFlowLock.release();
|
|
1910
1952
|
this._invitationFlowLock = null;
|
|
1911
|
-
|
|
1912
|
-
F:
|
|
1953
|
+
log7("invitation flow lock released", void 0, {
|
|
1954
|
+
F: __dxlog_file10,
|
|
1913
1955
|
L: 123,
|
|
1914
1956
|
S: this,
|
|
1915
1957
|
C: (f, a) => f(...a)
|
|
@@ -1919,17 +1961,17 @@ var InvitationGuestExtension = class extends RpcExtension {
|
|
|
1919
1961
|
};
|
|
1920
1962
|
|
|
1921
1963
|
// packages/sdk/client-services/src/packlets/invitations/invitation-host-extension.ts
|
|
1922
|
-
import { Trigger as
|
|
1964
|
+
import { Trigger as Trigger5, scheduleTask as scheduleTask2 } from "@dxos/async";
|
|
1923
1965
|
import { cancelWithContext as cancelWithContext3, Context as Context5 } from "@dxos/context";
|
|
1924
1966
|
import { randomBytes, verify } from "@dxos/crypto";
|
|
1925
1967
|
import { invariant as invariant7, InvariantViolation } from "@dxos/invariant";
|
|
1926
1968
|
import { PublicKey as PublicKey5 } from "@dxos/keys";
|
|
1927
|
-
import { log as
|
|
1969
|
+
import { log as log8 } from "@dxos/log";
|
|
1928
1970
|
import { InvalidInvitationExtensionRoleError as InvalidInvitationExtensionRoleError2, schema as schema3, trace as trace4 } from "@dxos/protocols";
|
|
1929
1971
|
import { Invitation as Invitation3 } from "@dxos/protocols/proto/dxos/client/services";
|
|
1930
1972
|
import { AuthenticationResponse, Options as Options2 } from "@dxos/protocols/proto/dxos/halo/invitations";
|
|
1931
1973
|
import { RpcExtension as RpcExtension2 } from "@dxos/teleport";
|
|
1932
|
-
var
|
|
1974
|
+
var __dxlog_file11 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitation-host-extension.ts";
|
|
1933
1975
|
var OPTIONS_TIMEOUT2 = 1e4;
|
|
1934
1976
|
var MAX_OTP_ATTEMPTS = 3;
|
|
1935
1977
|
var InvitationHostExtension = class extends RpcExtension2 {
|
|
@@ -1944,13 +1986,16 @@ var InvitationHostExtension = class extends RpcExtension2 {
|
|
|
1944
1986
|
});
|
|
1945
1987
|
this._invitationFlowMutex = _invitationFlowMutex;
|
|
1946
1988
|
this._callbacks = _callbacks;
|
|
1947
|
-
this._ctx = new Context5(
|
|
1948
|
-
|
|
1989
|
+
this._ctx = new Context5(void 0, {
|
|
1990
|
+
F: __dxlog_file11,
|
|
1991
|
+
L: 52
|
|
1992
|
+
});
|
|
1993
|
+
this._remoteOptionsTrigger = new Trigger5();
|
|
1949
1994
|
this._challenge = void 0;
|
|
1950
1995
|
this.guestProfile = void 0;
|
|
1951
1996
|
this.authenticationPassed = false;
|
|
1952
1997
|
this.authenticationRetry = 0;
|
|
1953
|
-
this.completedTrigger = new
|
|
1998
|
+
this.completedTrigger = new Trigger5();
|
|
1954
1999
|
this._invitationFlowLock = null;
|
|
1955
2000
|
}
|
|
1956
2001
|
hasFlowLock() {
|
|
@@ -1963,7 +2008,7 @@ var InvitationHostExtension = class extends RpcExtension2 {
|
|
|
1963
2008
|
InvitationHostService: {
|
|
1964
2009
|
options: async (options) => {
|
|
1965
2010
|
invariant7(!this._remoteOptions, "Remote options already set.", {
|
|
1966
|
-
F:
|
|
2011
|
+
F: __dxlog_file11,
|
|
1967
2012
|
L: 101,
|
|
1968
2013
|
S: this,
|
|
1969
2014
|
A: [
|
|
@@ -1977,10 +2022,10 @@ var InvitationHostExtension = class extends RpcExtension2 {
|
|
|
1977
2022
|
introduce: async (request) => {
|
|
1978
2023
|
const { profile, invitationId } = request;
|
|
1979
2024
|
const traceId = PublicKey5.random().toHex();
|
|
1980
|
-
|
|
2025
|
+
log8.trace("dxos.sdk.invitation-handler.host.introduce", trace4.begin({
|
|
1981
2026
|
id: traceId
|
|
1982
2027
|
}), {
|
|
1983
|
-
F:
|
|
2028
|
+
F: __dxlog_file11,
|
|
1984
2029
|
L: 110,
|
|
1985
2030
|
S: this,
|
|
1986
2031
|
C: (f, a) => f(...a)
|
|
@@ -1988,11 +2033,11 @@ var InvitationHostExtension = class extends RpcExtension2 {
|
|
|
1988
2033
|
const invitation = this._requireActiveInvitation();
|
|
1989
2034
|
this._assertInvitationState(Invitation3.State.CONNECTED);
|
|
1990
2035
|
if (invitationId !== invitation?.invitationId) {
|
|
1991
|
-
|
|
2036
|
+
log8.warn("incorrect invitationId", {
|
|
1992
2037
|
expected: invitation.invitationId,
|
|
1993
2038
|
actual: invitationId
|
|
1994
2039
|
}, {
|
|
1995
|
-
F:
|
|
2040
|
+
F: __dxlog_file11,
|
|
1996
2041
|
L: 116,
|
|
1997
2042
|
S: this,
|
|
1998
2043
|
C: (f, a) => f(...a)
|
|
@@ -2003,10 +2048,10 @@ var InvitationHostExtension = class extends RpcExtension2 {
|
|
|
2003
2048
|
authMethod: Invitation3.AuthMethod.NONE
|
|
2004
2049
|
};
|
|
2005
2050
|
}
|
|
2006
|
-
|
|
2051
|
+
log8("guest introduced themselves", {
|
|
2007
2052
|
guestProfile: profile
|
|
2008
2053
|
}, {
|
|
2009
|
-
F:
|
|
2054
|
+
F: __dxlog_file11,
|
|
2010
2055
|
L: 125,
|
|
2011
2056
|
S: this,
|
|
2012
2057
|
C: (f, a) => f(...a)
|
|
@@ -2014,10 +2059,10 @@ var InvitationHostExtension = class extends RpcExtension2 {
|
|
|
2014
2059
|
this.guestProfile = profile;
|
|
2015
2060
|
this._callbacks.onStateUpdate(Invitation3.State.READY_FOR_AUTHENTICATION);
|
|
2016
2061
|
this._challenge = invitation.authMethod === Invitation3.AuthMethod.KNOWN_PUBLIC_KEY ? randomBytes(32) : void 0;
|
|
2017
|
-
|
|
2062
|
+
log8.trace("dxos.sdk.invitation-handler.host.introduce", trace4.end({
|
|
2018
2063
|
id: traceId
|
|
2019
2064
|
}), {
|
|
2020
|
-
F:
|
|
2065
|
+
F: __dxlog_file11,
|
|
2021
2066
|
L: 132,
|
|
2022
2067
|
S: this,
|
|
2023
2068
|
C: (f, a) => f(...a)
|
|
@@ -2029,19 +2074,19 @@ var InvitationHostExtension = class extends RpcExtension2 {
|
|
|
2029
2074
|
},
|
|
2030
2075
|
authenticate: async ({ authCode: code, signedChallenge }) => {
|
|
2031
2076
|
const traceId = PublicKey5.random().toHex();
|
|
2032
|
-
|
|
2077
|
+
log8.trace("dxos.sdk.invitation-handler.host.authenticate", trace4.begin({
|
|
2033
2078
|
id: traceId
|
|
2034
2079
|
}), {
|
|
2035
|
-
F:
|
|
2080
|
+
F: __dxlog_file11,
|
|
2036
2081
|
L: 141,
|
|
2037
2082
|
S: this,
|
|
2038
2083
|
C: (f, a) => f(...a)
|
|
2039
2084
|
});
|
|
2040
2085
|
const invitation = this._requireActiveInvitation();
|
|
2041
|
-
|
|
2086
|
+
log8("received authentication request", {
|
|
2042
2087
|
authCode: code
|
|
2043
2088
|
}, {
|
|
2044
|
-
F:
|
|
2089
|
+
F: __dxlog_file11,
|
|
2045
2090
|
L: 144,
|
|
2046
2091
|
S: this,
|
|
2047
2092
|
C: (f, a) => f(...a)
|
|
@@ -2054,8 +2099,8 @@ var InvitationHostExtension = class extends RpcExtension2 {
|
|
|
2054
2099
|
this._callbacks.onStateUpdate(Invitation3.State.AUTHENTICATING);
|
|
2055
2100
|
switch (invitation.authMethod) {
|
|
2056
2101
|
case Invitation3.AuthMethod.NONE: {
|
|
2057
|
-
|
|
2058
|
-
F:
|
|
2102
|
+
log8("authentication not required", void 0, {
|
|
2103
|
+
F: __dxlog_file11,
|
|
2059
2104
|
L: 152,
|
|
2060
2105
|
S: this,
|
|
2061
2106
|
C: (f, a) => f(...a)
|
|
@@ -2090,10 +2135,10 @@ var InvitationHostExtension = class extends RpcExtension2 {
|
|
|
2090
2135
|
break;
|
|
2091
2136
|
}
|
|
2092
2137
|
default: {
|
|
2093
|
-
|
|
2138
|
+
log8.error("invalid authentication method", {
|
|
2094
2139
|
authMethod: invitation.authMethod
|
|
2095
2140
|
}, {
|
|
2096
|
-
F:
|
|
2141
|
+
F: __dxlog_file11,
|
|
2097
2142
|
L: 190,
|
|
2098
2143
|
S: this,
|
|
2099
2144
|
C: (f, a) => f(...a)
|
|
@@ -2112,13 +2157,13 @@ var InvitationHostExtension = class extends RpcExtension2 {
|
|
|
2112
2157
|
status
|
|
2113
2158
|
};
|
|
2114
2159
|
}
|
|
2115
|
-
|
|
2160
|
+
log8.trace("dxos.sdk.invitation-handler.host.authenticate", trace4.end({
|
|
2116
2161
|
id: traceId,
|
|
2117
2162
|
data: {
|
|
2118
2163
|
status
|
|
2119
2164
|
}
|
|
2120
2165
|
}), {
|
|
2121
|
-
F:
|
|
2166
|
+
F: __dxlog_file11,
|
|
2122
2167
|
L: 202,
|
|
2123
2168
|
S: this,
|
|
2124
2169
|
C: (f, a) => f(...a)
|
|
@@ -2129,10 +2174,10 @@ var InvitationHostExtension = class extends RpcExtension2 {
|
|
|
2129
2174
|
},
|
|
2130
2175
|
admit: async (request) => {
|
|
2131
2176
|
const traceId = PublicKey5.random().toHex();
|
|
2132
|
-
|
|
2177
|
+
log8.trace("dxos.sdk.invitation-handler.host.admit", trace4.begin({
|
|
2133
2178
|
id: traceId
|
|
2134
2179
|
}), {
|
|
2135
|
-
F:
|
|
2180
|
+
F: __dxlog_file11,
|
|
2136
2181
|
L: 208,
|
|
2137
2182
|
S: this,
|
|
2138
2183
|
C: (f, a) => f(...a)
|
|
@@ -2146,10 +2191,10 @@ var InvitationHostExtension = class extends RpcExtension2 {
|
|
|
2146
2191
|
}
|
|
2147
2192
|
}
|
|
2148
2193
|
const response = await this._callbacks.admit(request);
|
|
2149
|
-
|
|
2194
|
+
log8.trace("dxos.sdk.invitation-handler.host.admit", trace4.end({
|
|
2150
2195
|
id: traceId
|
|
2151
2196
|
}), {
|
|
2152
|
-
F:
|
|
2197
|
+
F: __dxlog_file11,
|
|
2153
2198
|
L: 222,
|
|
2154
2199
|
S: this,
|
|
2155
2200
|
C: (f, a) => f(...a)
|
|
@@ -2166,15 +2211,15 @@ var InvitationHostExtension = class extends RpcExtension2 {
|
|
|
2166
2211
|
async onOpen(context) {
|
|
2167
2212
|
await super.onOpen(context);
|
|
2168
2213
|
try {
|
|
2169
|
-
|
|
2170
|
-
F:
|
|
2214
|
+
log8("host acquire lock", void 0, {
|
|
2215
|
+
F: __dxlog_file11,
|
|
2171
2216
|
L: 237,
|
|
2172
2217
|
S: this,
|
|
2173
2218
|
C: (f, a) => f(...a)
|
|
2174
2219
|
});
|
|
2175
2220
|
this._invitationFlowLock = await tryAcquireBeforeContextDisposed(this._ctx, this._invitationFlowMutex);
|
|
2176
|
-
|
|
2177
|
-
F:
|
|
2221
|
+
log8("host lock acquired", void 0, {
|
|
2222
|
+
F: __dxlog_file11,
|
|
2178
2223
|
L: 239,
|
|
2179
2224
|
S: this,
|
|
2180
2225
|
C: (f, a) => f(...a)
|
|
@@ -2184,8 +2229,8 @@ var InvitationHostExtension = class extends RpcExtension2 {
|
|
|
2184
2229
|
await this.rpc.InvitationHostService.options({
|
|
2185
2230
|
role: Options2.Role.HOST
|
|
2186
2231
|
});
|
|
2187
|
-
|
|
2188
|
-
F:
|
|
2232
|
+
log8("options sent", void 0, {
|
|
2233
|
+
F: __dxlog_file11,
|
|
2189
2234
|
L: 243,
|
|
2190
2235
|
S: this,
|
|
2191
2236
|
C: (f, a) => f(...a)
|
|
@@ -2193,8 +2238,8 @@ var InvitationHostExtension = class extends RpcExtension2 {
|
|
|
2193
2238
|
await cancelWithContext3(this._ctx, this._remoteOptionsTrigger.wait({
|
|
2194
2239
|
timeout: OPTIONS_TIMEOUT2
|
|
2195
2240
|
}));
|
|
2196
|
-
|
|
2197
|
-
F:
|
|
2241
|
+
log8("options received", void 0, {
|
|
2242
|
+
F: __dxlog_file11,
|
|
2198
2243
|
L: 245,
|
|
2199
2244
|
S: this,
|
|
2200
2245
|
C: (f, a) => f(...a)
|
|
@@ -2247,8 +2292,8 @@ var InvitationHostExtension = class extends RpcExtension2 {
|
|
|
2247
2292
|
if (this._invitationFlowLock != null) {
|
|
2248
2293
|
this._invitationFlowLock?.release();
|
|
2249
2294
|
this._invitationFlowLock = null;
|
|
2250
|
-
|
|
2251
|
-
F:
|
|
2295
|
+
log8("invitation flow lock released", void 0, {
|
|
2296
|
+
F: __dxlog_file11,
|
|
2252
2297
|
L: 300,
|
|
2253
2298
|
S: this,
|
|
2254
2299
|
C: (f, a) => f(...a)
|
|
@@ -2261,10 +2306,10 @@ var isAuthenticationRequired = (invitation) => invitation.authMethod !== Invitat
|
|
|
2261
2306
|
// packages/sdk/client-services/src/packlets/invitations/invitation-topology.ts
|
|
2262
2307
|
import { invariant as invariant8 } from "@dxos/invariant";
|
|
2263
2308
|
import { PublicKey as PublicKey6 } from "@dxos/keys";
|
|
2264
|
-
import { log as
|
|
2309
|
+
import { log as log9 } from "@dxos/log";
|
|
2265
2310
|
import { Options as Options3 } from "@dxos/protocols/proto/dxos/halo/invitations";
|
|
2266
2311
|
import { ComplexSet as ComplexSet2 } from "@dxos/util";
|
|
2267
|
-
var
|
|
2312
|
+
var __dxlog_file12 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitation-topology.ts";
|
|
2268
2313
|
var InvitationTopology = class {
|
|
2269
2314
|
constructor(_role) {
|
|
2270
2315
|
this._role = _role;
|
|
@@ -2272,7 +2317,7 @@ var InvitationTopology = class {
|
|
|
2272
2317
|
}
|
|
2273
2318
|
init(controller) {
|
|
2274
2319
|
invariant8(!this._controller, "Already initialized.", {
|
|
2275
|
-
F:
|
|
2320
|
+
F: __dxlog_file12,
|
|
2276
2321
|
L: 42,
|
|
2277
2322
|
S: this,
|
|
2278
2323
|
A: [
|
|
@@ -2284,7 +2329,7 @@ var InvitationTopology = class {
|
|
|
2284
2329
|
}
|
|
2285
2330
|
update() {
|
|
2286
2331
|
invariant8(this._controller, "Not initialized.", {
|
|
2287
|
-
F:
|
|
2332
|
+
F: __dxlog_file12,
|
|
2288
2333
|
L: 47,
|
|
2289
2334
|
S: this,
|
|
2290
2335
|
A: [
|
|
@@ -2303,11 +2348,11 @@ var InvitationTopology = class {
|
|
|
2303
2348
|
const firstUnknownPeer = candidates.find((peerId) => !this._seenPeers.has(peerId));
|
|
2304
2349
|
this._seenPeers = new ComplexSet2(PublicKey6.hash, allPeers.filter((peerId) => this._seenPeers.has(peerId)));
|
|
2305
2350
|
if (firstUnknownPeer != null) {
|
|
2306
|
-
|
|
2351
|
+
log9("invitation connect", {
|
|
2307
2352
|
ownPeerId,
|
|
2308
2353
|
remotePeerId: firstUnknownPeer
|
|
2309
2354
|
}, {
|
|
2310
|
-
F:
|
|
2355
|
+
F: __dxlog_file12,
|
|
2311
2356
|
L: 69,
|
|
2312
2357
|
S: this,
|
|
2313
2358
|
C: (f, a) => f(...a)
|
|
@@ -2318,7 +2363,7 @@ var InvitationTopology = class {
|
|
|
2318
2363
|
}
|
|
2319
2364
|
async onOffer(peer) {
|
|
2320
2365
|
invariant8(this._controller, "Not initialized.", {
|
|
2321
|
-
F:
|
|
2366
|
+
F: __dxlog_file12,
|
|
2322
2367
|
L: 76,
|
|
2323
2368
|
S: this,
|
|
2324
2369
|
A: [
|
|
@@ -2337,7 +2382,7 @@ var InvitationTopology = class {
|
|
|
2337
2382
|
};
|
|
2338
2383
|
|
|
2339
2384
|
// packages/sdk/client-services/src/packlets/invitations/invitations-handler.ts
|
|
2340
|
-
var
|
|
2385
|
+
var __dxlog_file13 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitations-handler.ts";
|
|
2341
2386
|
var MAX_DELEGATED_INVITATION_HOST_TRIES = 3;
|
|
2342
2387
|
var InvitationsHandler = class {
|
|
2343
2388
|
/**
|
|
@@ -2362,7 +2407,7 @@ var InvitationsHandler = class {
|
|
|
2362
2407
|
try {
|
|
2363
2408
|
const deviceKey = admissionRequest.device?.deviceKey ?? admissionRequest.space?.deviceKey;
|
|
2364
2409
|
invariant9(deviceKey, void 0, {
|
|
2365
|
-
F:
|
|
2410
|
+
F: __dxlog_file13,
|
|
2366
2411
|
L: 90,
|
|
2367
2412
|
S: this,
|
|
2368
2413
|
A: [
|
|
@@ -2388,18 +2433,18 @@ var InvitationsHandler = class {
|
|
|
2388
2433
|
scheduleTask3(connectionCtx, async () => {
|
|
2389
2434
|
const traceId = PublicKey7.random().toHex();
|
|
2390
2435
|
try {
|
|
2391
|
-
|
|
2436
|
+
log10.trace("dxos.sdk.invitations-handler.host.onOpen", trace5.begin({
|
|
2392
2437
|
id: traceId
|
|
2393
2438
|
}), {
|
|
2394
|
-
F:
|
|
2439
|
+
F: __dxlog_file13,
|
|
2395
2440
|
L: 115,
|
|
2396
2441
|
S: this,
|
|
2397
2442
|
C: (f, a) => f(...a)
|
|
2398
2443
|
});
|
|
2399
|
-
|
|
2444
|
+
log10("connected", {
|
|
2400
2445
|
...protocol.toJSON()
|
|
2401
2446
|
}, {
|
|
2402
|
-
F:
|
|
2447
|
+
F: __dxlog_file13,
|
|
2403
2448
|
L: 116,
|
|
2404
2449
|
S: this,
|
|
2405
2450
|
C: (f, a) => f(...a)
|
|
@@ -2407,20 +2452,20 @@ var InvitationsHandler = class {
|
|
|
2407
2452
|
const deviceKey = await extension.completedTrigger.wait({
|
|
2408
2453
|
timeout: invitation.timeout
|
|
2409
2454
|
});
|
|
2410
|
-
|
|
2455
|
+
log10("admitted guest", {
|
|
2411
2456
|
guest: deviceKey,
|
|
2412
2457
|
...protocol.toJSON()
|
|
2413
2458
|
}, {
|
|
2414
|
-
F:
|
|
2459
|
+
F: __dxlog_file13,
|
|
2415
2460
|
L: 118,
|
|
2416
2461
|
S: this,
|
|
2417
2462
|
C: (f, a) => f(...a)
|
|
2418
2463
|
});
|
|
2419
2464
|
guardedState.set(extension, Invitation4.State.SUCCESS);
|
|
2420
|
-
|
|
2465
|
+
log10.trace("dxos.sdk.invitations-handler.host.onOpen", trace5.end({
|
|
2421
2466
|
id: traceId
|
|
2422
2467
|
}), {
|
|
2423
|
-
F:
|
|
2468
|
+
F: __dxlog_file13,
|
|
2424
2469
|
L: 120,
|
|
2425
2470
|
S: this,
|
|
2426
2471
|
C: (f, a) => f(...a)
|
|
@@ -2432,10 +2477,10 @@ var InvitationsHandler = class {
|
|
|
2432
2477
|
} catch (err) {
|
|
2433
2478
|
if (err instanceof TimeoutError) {
|
|
2434
2479
|
if (guardedState.set(extension, Invitation4.State.TIMEOUT)) {
|
|
2435
|
-
|
|
2480
|
+
log10("timeout", {
|
|
2436
2481
|
...protocol.toJSON()
|
|
2437
2482
|
}, {
|
|
2438
|
-
F:
|
|
2483
|
+
F: __dxlog_file13,
|
|
2439
2484
|
L: 129,
|
|
2440
2485
|
S: this,
|
|
2441
2486
|
C: (f, a) => f(...a)
|
|
@@ -2443,19 +2488,19 @@ var InvitationsHandler = class {
|
|
|
2443
2488
|
}
|
|
2444
2489
|
} else {
|
|
2445
2490
|
if (guardedState.error(extension, err)) {
|
|
2446
|
-
|
|
2447
|
-
F:
|
|
2491
|
+
log10.error("failed", err, {
|
|
2492
|
+
F: __dxlog_file13,
|
|
2448
2493
|
L: 133,
|
|
2449
2494
|
S: this,
|
|
2450
2495
|
C: (f, a) => f(...a)
|
|
2451
2496
|
});
|
|
2452
2497
|
}
|
|
2453
2498
|
}
|
|
2454
|
-
|
|
2499
|
+
log10.trace("dxos.sdk.invitations-handler.host.onOpen", trace5.error({
|
|
2455
2500
|
id: traceId,
|
|
2456
2501
|
error: err
|
|
2457
2502
|
}), {
|
|
2458
|
-
F:
|
|
2503
|
+
F: __dxlog_file13,
|
|
2459
2504
|
L: 136,
|
|
2460
2505
|
S: this,
|
|
2461
2506
|
C: (f, a) => f(...a)
|
|
@@ -2466,10 +2511,10 @@ var InvitationsHandler = class {
|
|
|
2466
2511
|
},
|
|
2467
2512
|
onError: (err) => {
|
|
2468
2513
|
if (err instanceof InvalidInvitationExtensionRoleError3) {
|
|
2469
|
-
|
|
2514
|
+
log10("invalid role", {
|
|
2470
2515
|
...err.context
|
|
2471
2516
|
}, {
|
|
2472
|
-
F:
|
|
2517
|
+
F: __dxlog_file13,
|
|
2473
2518
|
L: 144,
|
|
2474
2519
|
S: this,
|
|
2475
2520
|
C: (f, a) => f(...a)
|
|
@@ -2478,10 +2523,10 @@ var InvitationsHandler = class {
|
|
|
2478
2523
|
}
|
|
2479
2524
|
if (err instanceof TimeoutError) {
|
|
2480
2525
|
if (guardedState.set(extension, Invitation4.State.TIMEOUT)) {
|
|
2481
|
-
|
|
2526
|
+
log10("timeout", {
|
|
2482
2527
|
err
|
|
2483
2528
|
}, {
|
|
2484
|
-
F:
|
|
2529
|
+
F: __dxlog_file13,
|
|
2485
2530
|
L: 149,
|
|
2486
2531
|
S: this,
|
|
2487
2532
|
C: (f, a) => f(...a)
|
|
@@ -2489,8 +2534,8 @@ var InvitationsHandler = class {
|
|
|
2489
2534
|
}
|
|
2490
2535
|
} else {
|
|
2491
2536
|
if (guardedState.error(extension, err)) {
|
|
2492
|
-
|
|
2493
|
-
F:
|
|
2537
|
+
log10.error("failed", err, {
|
|
2538
|
+
F: __dxlog_file13,
|
|
2494
2539
|
L: 153,
|
|
2495
2540
|
S: this,
|
|
2496
2541
|
C: (f, a) => f(...a)
|
|
@@ -2503,8 +2548,8 @@ var InvitationsHandler = class {
|
|
|
2503
2548
|
};
|
|
2504
2549
|
if (invitation.lifetime && invitation.created) {
|
|
2505
2550
|
if (invitation.created.getTime() + invitation.lifetime * 1e3 < Date.now()) {
|
|
2506
|
-
|
|
2507
|
-
F:
|
|
2551
|
+
log10.warn("invitation has already expired", void 0, {
|
|
2552
|
+
F: __dxlog_file13,
|
|
2508
2553
|
L: 164,
|
|
2509
2554
|
S: this,
|
|
2510
2555
|
C: (f, a) => f(...a)
|
|
@@ -2527,7 +2572,7 @@ var InvitationsHandler = class {
|
|
|
2527
2572
|
const { timeout = INVITATION_TIMEOUT } = invitation;
|
|
2528
2573
|
if (deviceProfile) {
|
|
2529
2574
|
invariant9(invitation.kind === Invitation4.Kind.DEVICE, "deviceProfile provided for non-device invitation", {
|
|
2530
|
-
F:
|
|
2575
|
+
F: __dxlog_file13,
|
|
2531
2576
|
L: 197,
|
|
2532
2577
|
S: this,
|
|
2533
2578
|
A: [
|
|
@@ -2540,12 +2585,12 @@ var InvitationsHandler = class {
|
|
|
2540
2585
|
const guardedState = this._createGuardedState(ctx, invitation, stream);
|
|
2541
2586
|
const shouldCancelInvitationFlow = (extension) => {
|
|
2542
2587
|
const isLockedByAnotherConnection = guardedState.mutex.isLocked() && !extension.hasFlowLock();
|
|
2543
|
-
|
|
2588
|
+
log10("should cancel invitation flow", {
|
|
2544
2589
|
isLockedByAnotherConnection,
|
|
2545
2590
|
invitationType: Invitation4.Type.DELEGATED,
|
|
2546
2591
|
triedPeers: triedPeersIds.size
|
|
2547
2592
|
}, {
|
|
2548
|
-
F:
|
|
2593
|
+
F: __dxlog_file13,
|
|
2549
2594
|
L: 205,
|
|
2550
2595
|
S: this,
|
|
2551
2596
|
C: (f, a) => f(...a)
|
|
@@ -2568,11 +2613,11 @@ var InvitationsHandler = class {
|
|
|
2568
2613
|
return;
|
|
2569
2614
|
}
|
|
2570
2615
|
connectionCtx.onDispose(async () => {
|
|
2571
|
-
|
|
2616
|
+
log10("extension disposed", {
|
|
2572
2617
|
admitted,
|
|
2573
2618
|
currentState: guardedState.current.state
|
|
2574
2619
|
}, {
|
|
2575
|
-
F:
|
|
2620
|
+
F: __dxlog_file13,
|
|
2576
2621
|
L: 233,
|
|
2577
2622
|
S: this,
|
|
2578
2623
|
C: (f, a) => f(...a)
|
|
@@ -2587,10 +2632,10 @@ var InvitationsHandler = class {
|
|
|
2587
2632
|
scheduleTask3(connectionCtx, async () => {
|
|
2588
2633
|
const traceId = PublicKey7.random().toHex();
|
|
2589
2634
|
try {
|
|
2590
|
-
|
|
2635
|
+
log10.trace("dxos.sdk.invitations-handler.guest.onOpen", trace5.begin({
|
|
2591
2636
|
id: traceId
|
|
2592
2637
|
}), {
|
|
2593
|
-
F:
|
|
2638
|
+
F: __dxlog_file13,
|
|
2594
2639
|
L: 245,
|
|
2595
2640
|
S: this,
|
|
2596
2641
|
C: (f, a) => f(...a)
|
|
@@ -2599,19 +2644,19 @@ var InvitationsHandler = class {
|
|
|
2599
2644
|
guardedState.set(extension, Invitation4.State.TIMEOUT);
|
|
2600
2645
|
extensionCtx.close();
|
|
2601
2646
|
}, timeout);
|
|
2602
|
-
|
|
2647
|
+
log10("connected", {
|
|
2603
2648
|
...protocol.toJSON()
|
|
2604
2649
|
}, {
|
|
2605
|
-
F:
|
|
2650
|
+
F: __dxlog_file13,
|
|
2606
2651
|
L: 256,
|
|
2607
2652
|
S: this,
|
|
2608
2653
|
C: (f, a) => f(...a)
|
|
2609
2654
|
});
|
|
2610
2655
|
guardedState.set(extension, Invitation4.State.CONNECTED);
|
|
2611
|
-
|
|
2656
|
+
log10("introduce", {
|
|
2612
2657
|
...protocol.toJSON()
|
|
2613
2658
|
}, {
|
|
2614
|
-
F:
|
|
2659
|
+
F: __dxlog_file13,
|
|
2615
2660
|
L: 260,
|
|
2616
2661
|
S: this,
|
|
2617
2662
|
C: (f, a) => f(...a)
|
|
@@ -2620,11 +2665,11 @@ var InvitationsHandler = class {
|
|
|
2620
2665
|
invitationId: invitation.invitationId,
|
|
2621
2666
|
...protocol.createIntroduction()
|
|
2622
2667
|
});
|
|
2623
|
-
|
|
2668
|
+
log10("introduce response", {
|
|
2624
2669
|
...protocol.toJSON(),
|
|
2625
2670
|
response: introductionResponse
|
|
2626
2671
|
}, {
|
|
2627
|
-
F:
|
|
2672
|
+
F: __dxlog_file13,
|
|
2628
2673
|
L: 265,
|
|
2629
2674
|
S: this,
|
|
2630
2675
|
C: (f, a) => f(...a)
|
|
@@ -2642,10 +2687,10 @@ var InvitationsHandler = class {
|
|
|
2642
2687
|
break;
|
|
2643
2688
|
}
|
|
2644
2689
|
}
|
|
2645
|
-
|
|
2690
|
+
log10("request admission", {
|
|
2646
2691
|
...protocol.toJSON()
|
|
2647
2692
|
}, {
|
|
2648
|
-
F:
|
|
2693
|
+
F: __dxlog_file13,
|
|
2649
2694
|
L: 291,
|
|
2650
2695
|
S: this,
|
|
2651
2696
|
C: (f, a) => f(...a)
|
|
@@ -2654,10 +2699,10 @@ var InvitationsHandler = class {
|
|
|
2654
2699
|
const admissionResponse = await extension.rpc.InvitationHostService.admit(admissionRequest);
|
|
2655
2700
|
admitted = true;
|
|
2656
2701
|
const result = await protocol.accept(admissionResponse, admissionRequest);
|
|
2657
|
-
|
|
2702
|
+
log10("admitted by host", {
|
|
2658
2703
|
...protocol.toJSON()
|
|
2659
2704
|
}, {
|
|
2660
|
-
F:
|
|
2705
|
+
F: __dxlog_file13,
|
|
2661
2706
|
L: 302,
|
|
2662
2707
|
S: this,
|
|
2663
2708
|
C: (f, a) => f(...a)
|
|
@@ -2667,28 +2712,28 @@ var InvitationsHandler = class {
|
|
|
2667
2712
|
...result,
|
|
2668
2713
|
state: Invitation4.State.SUCCESS
|
|
2669
2714
|
});
|
|
2670
|
-
|
|
2715
|
+
log10.trace("dxos.sdk.invitations-handler.guest.onOpen", trace5.end({
|
|
2671
2716
|
id: traceId
|
|
2672
2717
|
}), {
|
|
2673
|
-
F:
|
|
2718
|
+
F: __dxlog_file13,
|
|
2674
2719
|
L: 308,
|
|
2675
2720
|
S: this,
|
|
2676
2721
|
C: (f, a) => f(...a)
|
|
2677
2722
|
});
|
|
2678
2723
|
} catch (err) {
|
|
2679
2724
|
if (err instanceof TimeoutError) {
|
|
2680
|
-
|
|
2725
|
+
log10("timeout", {
|
|
2681
2726
|
...protocol.toJSON()
|
|
2682
2727
|
}, {
|
|
2683
|
-
F:
|
|
2728
|
+
F: __dxlog_file13,
|
|
2684
2729
|
L: 311,
|
|
2685
2730
|
S: this,
|
|
2686
2731
|
C: (f, a) => f(...a)
|
|
2687
2732
|
});
|
|
2688
2733
|
guardedState.set(extension, Invitation4.State.TIMEOUT);
|
|
2689
2734
|
} else {
|
|
2690
|
-
|
|
2691
|
-
F:
|
|
2735
|
+
log10("auth failed", err, {
|
|
2736
|
+
F: __dxlog_file13,
|
|
2692
2737
|
L: 314,
|
|
2693
2738
|
S: this,
|
|
2694
2739
|
C: (f, a) => f(...a)
|
|
@@ -2696,11 +2741,11 @@ var InvitationsHandler = class {
|
|
|
2696
2741
|
guardedState.error(extension, err);
|
|
2697
2742
|
}
|
|
2698
2743
|
extensionCtx.close(err);
|
|
2699
|
-
|
|
2744
|
+
log10.trace("dxos.sdk.invitations-handler.guest.onOpen", trace5.error({
|
|
2700
2745
|
id: traceId,
|
|
2701
2746
|
error: err
|
|
2702
2747
|
}), {
|
|
2703
|
-
F:
|
|
2748
|
+
F: __dxlog_file13,
|
|
2704
2749
|
L: 318,
|
|
2705
2750
|
S: this,
|
|
2706
2751
|
C: (f, a) => f(...a)
|
|
@@ -2713,18 +2758,18 @@ var InvitationsHandler = class {
|
|
|
2713
2758
|
return;
|
|
2714
2759
|
}
|
|
2715
2760
|
if (err instanceof TimeoutError) {
|
|
2716
|
-
|
|
2761
|
+
log10("timeout", {
|
|
2717
2762
|
...protocol.toJSON()
|
|
2718
2763
|
}, {
|
|
2719
|
-
F:
|
|
2764
|
+
F: __dxlog_file13,
|
|
2720
2765
|
L: 327,
|
|
2721
2766
|
S: this,
|
|
2722
2767
|
C: (f, a) => f(...a)
|
|
2723
2768
|
});
|
|
2724
2769
|
guardedState.set(extension, Invitation4.State.TIMEOUT);
|
|
2725
2770
|
} else {
|
|
2726
|
-
|
|
2727
|
-
F:
|
|
2771
|
+
log10("auth failed", err, {
|
|
2772
|
+
F: __dxlog_file13,
|
|
2728
2773
|
L: 330,
|
|
2729
2774
|
S: this,
|
|
2730
2775
|
C: (f, a) => f(...a)
|
|
@@ -2742,7 +2787,7 @@ var InvitationsHandler = class {
|
|
|
2742
2787
|
await ctx.dispose();
|
|
2743
2788
|
} else {
|
|
2744
2789
|
invariant9(invitation.swarmKey, void 0, {
|
|
2745
|
-
F:
|
|
2790
|
+
F: __dxlog_file13,
|
|
2746
2791
|
L: 345,
|
|
2747
2792
|
S: this,
|
|
2748
2793
|
A: [
|
|
@@ -2836,16 +2881,29 @@ var InvitationsHandler = class {
|
|
|
2836
2881
|
};
|
|
2837
2882
|
}
|
|
2838
2883
|
_logStateUpdate(invitation, actor, newState) {
|
|
2839
|
-
|
|
2840
|
-
|
|
2841
|
-
|
|
2842
|
-
|
|
2843
|
-
|
|
2844
|
-
|
|
2845
|
-
|
|
2846
|
-
|
|
2847
|
-
|
|
2848
|
-
|
|
2884
|
+
if (this._isNotTerminal(newState)) {
|
|
2885
|
+
log10("invitation state update", {
|
|
2886
|
+
actor: actor?.constructor.name,
|
|
2887
|
+
newState: stateToString(newState),
|
|
2888
|
+
oldState: stateToString(invitation.state)
|
|
2889
|
+
}, {
|
|
2890
|
+
F: __dxlog_file13,
|
|
2891
|
+
L: 439,
|
|
2892
|
+
S: this,
|
|
2893
|
+
C: (f, a) => f(...a)
|
|
2894
|
+
});
|
|
2895
|
+
} else {
|
|
2896
|
+
log10.info("invitation state update", {
|
|
2897
|
+
actor: actor?.constructor.name,
|
|
2898
|
+
newState: stateToString(newState),
|
|
2899
|
+
oldState: stateToString(invitation.state)
|
|
2900
|
+
}, {
|
|
2901
|
+
F: __dxlog_file13,
|
|
2902
|
+
L: 445,
|
|
2903
|
+
S: this,
|
|
2904
|
+
C: (f, a) => f(...a)
|
|
2905
|
+
});
|
|
2906
|
+
}
|
|
2849
2907
|
}
|
|
2850
2908
|
_isNotTerminal(currentState) {
|
|
2851
2909
|
return ![
|
|
@@ -2858,17 +2916,17 @@ var InvitationsHandler = class {
|
|
|
2858
2916
|
}
|
|
2859
2917
|
async _handleGuestOtpAuth(extension, setState, authenticated, options) {
|
|
2860
2918
|
for (let attempt = 1; attempt <= MAX_OTP_ATTEMPTS; attempt++) {
|
|
2861
|
-
|
|
2862
|
-
F:
|
|
2863
|
-
L:
|
|
2919
|
+
log10("guest waiting for authentication code...", void 0, {
|
|
2920
|
+
F: __dxlog_file13,
|
|
2921
|
+
L: 470,
|
|
2864
2922
|
S: this,
|
|
2865
2923
|
C: (f, a) => f(...a)
|
|
2866
2924
|
});
|
|
2867
2925
|
setState(Invitation4.State.READY_FOR_AUTHENTICATION);
|
|
2868
2926
|
const authCode = await authenticated.wait(options);
|
|
2869
|
-
|
|
2870
|
-
F:
|
|
2871
|
-
L:
|
|
2927
|
+
log10("sending authentication request", void 0, {
|
|
2928
|
+
F: __dxlog_file13,
|
|
2929
|
+
L: 474,
|
|
2872
2930
|
S: this,
|
|
2873
2931
|
C: (f, a) => f(...a)
|
|
2874
2932
|
});
|
|
@@ -2883,11 +2941,11 @@ var InvitationsHandler = class {
|
|
|
2883
2941
|
if (attempt === MAX_OTP_ATTEMPTS) {
|
|
2884
2942
|
throw new Error(`Maximum retry attempts: ${MAX_OTP_ATTEMPTS}`);
|
|
2885
2943
|
} else {
|
|
2886
|
-
|
|
2944
|
+
log10("retrying invalid code", {
|
|
2887
2945
|
attempt
|
|
2888
2946
|
}, {
|
|
2889
|
-
F:
|
|
2890
|
-
L:
|
|
2947
|
+
F: __dxlog_file13,
|
|
2948
|
+
L: 485,
|
|
2891
2949
|
S: this,
|
|
2892
2950
|
C: (f, a) => f(...a)
|
|
2893
2951
|
});
|
|
@@ -2903,9 +2961,9 @@ var InvitationsHandler = class {
|
|
|
2903
2961
|
if (introductionResponse.challenge == null) {
|
|
2904
2962
|
throw new Error("challenge missing in the introduction");
|
|
2905
2963
|
}
|
|
2906
|
-
|
|
2907
|
-
F:
|
|
2908
|
-
L:
|
|
2964
|
+
log10("sending authentication request", void 0, {
|
|
2965
|
+
F: __dxlog_file13,
|
|
2966
|
+
L: 504,
|
|
2909
2967
|
S: this,
|
|
2910
2968
|
C: (f, a) => f(...a)
|
|
2911
2969
|
});
|
|
@@ -3025,14 +3083,14 @@ var InvitationsServiceImpl = class {
|
|
|
3025
3083
|
};
|
|
3026
3084
|
|
|
3027
3085
|
// packages/sdk/client-services/src/packlets/invitations/space-invitation-protocol.ts
|
|
3028
|
-
import {
|
|
3086
|
+
import { createCancelDelegatedSpaceInvitationCredential, createDelegatedSpaceInvitationCredential, getCredentialAssertion as getCredentialAssertion2 } from "@dxos/credentials";
|
|
3029
3087
|
import { writeMessages as writeMessages2 } from "@dxos/feed-store";
|
|
3030
3088
|
import { invariant as invariant10 } from "@dxos/invariant";
|
|
3031
|
-
import { log as
|
|
3089
|
+
import { log as log11 } from "@dxos/log";
|
|
3032
3090
|
import { AlreadyJoinedError as AlreadyJoinedError2, AuthorizationError, InvalidInvitationError, SpaceNotFoundError } from "@dxos/protocols";
|
|
3033
3091
|
import { Invitation as Invitation5 } from "@dxos/protocols/proto/dxos/client/services";
|
|
3034
3092
|
import { SpaceMember as SpaceMember2 } from "@dxos/protocols/proto/dxos/halo/credentials";
|
|
3035
|
-
var
|
|
3093
|
+
var __dxlog_file14 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/space-invitation-protocol.ts";
|
|
3036
3094
|
var SpaceInvitationProtocol = class {
|
|
3037
3095
|
constructor(_spaceManager, _signingContext, _keyring, _spaceKey) {
|
|
3038
3096
|
this._spaceManager = _spaceManager;
|
|
@@ -3066,79 +3124,43 @@ var SpaceInvitationProtocol = class {
|
|
|
3066
3124
|
};
|
|
3067
3125
|
}
|
|
3068
3126
|
async admit(invitation, request, guestProfile) {
|
|
3069
|
-
invariant10(this._spaceKey, void 0, {
|
|
3070
|
-
F:
|
|
3071
|
-
L:
|
|
3072
|
-
S: this,
|
|
3073
|
-
A: [
|
|
3074
|
-
"this._spaceKey",
|
|
3075
|
-
""
|
|
3076
|
-
]
|
|
3077
|
-
});
|
|
3078
|
-
const space = this._spaceManager.spaces.get(this._spaceKey);
|
|
3079
|
-
invariant10(space, void 0, {
|
|
3080
|
-
F: __dxlog_file13,
|
|
3081
|
-
L: 78,
|
|
3082
|
-
S: this,
|
|
3083
|
-
A: [
|
|
3084
|
-
"space",
|
|
3085
|
-
""
|
|
3086
|
-
]
|
|
3087
|
-
});
|
|
3088
|
-
invariant10(request.space, void 0, {
|
|
3089
|
-
F: __dxlog_file13,
|
|
3090
|
-
L: 80,
|
|
3127
|
+
invariant10(this._spaceKey && request.space, void 0, {
|
|
3128
|
+
F: __dxlog_file14,
|
|
3129
|
+
L: 74,
|
|
3091
3130
|
S: this,
|
|
3092
3131
|
A: [
|
|
3093
|
-
"request.space",
|
|
3132
|
+
"this._spaceKey && request.space",
|
|
3094
3133
|
""
|
|
3095
3134
|
]
|
|
3096
3135
|
});
|
|
3097
|
-
|
|
3098
|
-
if (space.inner.spaceState.getMemberRole(identityKey) !== SpaceMember2.Role.REMOVED) {
|
|
3099
|
-
throw new AlreadyJoinedError2();
|
|
3100
|
-
}
|
|
3101
|
-
log10("writing guest credentials", {
|
|
3136
|
+
log11("writing guest credentials", {
|
|
3102
3137
|
host: this._signingContext.deviceKey,
|
|
3103
|
-
guest: deviceKey
|
|
3138
|
+
guest: request.space.deviceKey
|
|
3104
3139
|
}, {
|
|
3105
|
-
F:
|
|
3106
|
-
L:
|
|
3140
|
+
F: __dxlog_file14,
|
|
3141
|
+
L: 75,
|
|
3107
3142
|
S: this,
|
|
3108
3143
|
C: (f, a) => f(...a)
|
|
3109
3144
|
});
|
|
3110
|
-
const
|
|
3111
|
-
|
|
3112
|
-
|
|
3113
|
-
|
|
3114
|
-
|
|
3115
|
-
|
|
3116
|
-
"credentials[0].credential",
|
|
3117
|
-
""
|
|
3118
|
-
]
|
|
3119
|
-
});
|
|
3120
|
-
const spaceMemberCredential = credentials[0].credential.credential;
|
|
3121
|
-
invariant10(getCredentialAssertion2(spaceMemberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
|
|
3122
|
-
F: __dxlog_file13,
|
|
3123
|
-
L: 103,
|
|
3124
|
-
S: this,
|
|
3125
|
-
A: [
|
|
3126
|
-
"getCredentialAssertion(spaceMemberCredential)['@type'] === 'dxos.halo.credentials.SpaceMember'",
|
|
3127
|
-
""
|
|
3128
|
-
]
|
|
3145
|
+
const spaceMemberCredential = await this._spaceManager.admitMember({
|
|
3146
|
+
spaceKey: this._spaceKey,
|
|
3147
|
+
identityKey: request.space.identityKey,
|
|
3148
|
+
role: invitation.role ?? SpaceMember2.Role.ADMIN,
|
|
3149
|
+
profile: guestProfile,
|
|
3150
|
+
delegationCredentialId: invitation.delegationCredentialId
|
|
3129
3151
|
});
|
|
3130
|
-
|
|
3152
|
+
const space = this._spaceManager.spaces.get(this._spaceKey);
|
|
3131
3153
|
return {
|
|
3132
3154
|
space: {
|
|
3133
3155
|
credential: spaceMemberCredential,
|
|
3134
|
-
controlTimeframe: space
|
|
3156
|
+
controlTimeframe: space?.inner.controlPipeline.state.timeframe
|
|
3135
3157
|
}
|
|
3136
3158
|
};
|
|
3137
3159
|
}
|
|
3138
3160
|
async delegate(invitation) {
|
|
3139
3161
|
invariant10(this._spaceKey, void 0, {
|
|
3140
|
-
F:
|
|
3141
|
-
L:
|
|
3162
|
+
F: __dxlog_file14,
|
|
3163
|
+
L: 95,
|
|
3142
3164
|
S: this,
|
|
3143
3165
|
A: [
|
|
3144
3166
|
"this._spaceKey",
|
|
@@ -3147,8 +3169,8 @@ var SpaceInvitationProtocol = class {
|
|
|
3147
3169
|
});
|
|
3148
3170
|
const space = this._spaceManager.spaces.get(this._spaceKey);
|
|
3149
3171
|
invariant10(space, void 0, {
|
|
3150
|
-
F:
|
|
3151
|
-
L:
|
|
3172
|
+
F: __dxlog_file14,
|
|
3173
|
+
L: 97,
|
|
3152
3174
|
S: this,
|
|
3153
3175
|
A: [
|
|
3154
3176
|
"space",
|
|
@@ -3157,8 +3179,8 @@ var SpaceInvitationProtocol = class {
|
|
|
3157
3179
|
});
|
|
3158
3180
|
if (invitation.authMethod === Invitation5.AuthMethod.KNOWN_PUBLIC_KEY) {
|
|
3159
3181
|
invariant10(invitation.guestKeypair?.publicKey, void 0, {
|
|
3160
|
-
F:
|
|
3161
|
-
L:
|
|
3182
|
+
F: __dxlog_file14,
|
|
3183
|
+
L: 99,
|
|
3162
3184
|
S: this,
|
|
3163
3185
|
A: [
|
|
3164
3186
|
"invitation.guestKeypair?.publicKey",
|
|
@@ -3166,12 +3188,12 @@ var SpaceInvitationProtocol = class {
|
|
|
3166
3188
|
]
|
|
3167
3189
|
});
|
|
3168
3190
|
}
|
|
3169
|
-
|
|
3191
|
+
log11("writing delegate space invitation", {
|
|
3170
3192
|
host: this._signingContext.deviceKey,
|
|
3171
3193
|
id: invitation.invitationId
|
|
3172
3194
|
}, {
|
|
3173
|
-
F:
|
|
3174
|
-
L:
|
|
3195
|
+
F: __dxlog_file14,
|
|
3196
|
+
L: 102,
|
|
3175
3197
|
S: this,
|
|
3176
3198
|
C: (f, a) => f(...a)
|
|
3177
3199
|
});
|
|
@@ -3185,8 +3207,8 @@ var SpaceInvitationProtocol = class {
|
|
|
3185
3207
|
guestKey: invitation.authMethod === Invitation5.AuthMethod.KNOWN_PUBLIC_KEY ? invitation.guestKeypair.publicKey : void 0
|
|
3186
3208
|
});
|
|
3187
3209
|
invariant10(credential.credential, void 0, {
|
|
3188
|
-
F:
|
|
3189
|
-
L:
|
|
3210
|
+
F: __dxlog_file14,
|
|
3211
|
+
L: 122,
|
|
3190
3212
|
S: this,
|
|
3191
3213
|
A: [
|
|
3192
3214
|
"credential.credential",
|
|
@@ -3200,8 +3222,8 @@ var SpaceInvitationProtocol = class {
|
|
|
3200
3222
|
}
|
|
3201
3223
|
async cancelDelegation(invitation) {
|
|
3202
3224
|
invariant10(this._spaceKey, void 0, {
|
|
3203
|
-
F:
|
|
3204
|
-
L:
|
|
3225
|
+
F: __dxlog_file14,
|
|
3226
|
+
L: 128,
|
|
3205
3227
|
S: this,
|
|
3206
3228
|
A: [
|
|
3207
3229
|
"this._spaceKey",
|
|
@@ -3209,8 +3231,8 @@ var SpaceInvitationProtocol = class {
|
|
|
3209
3231
|
]
|
|
3210
3232
|
});
|
|
3211
3233
|
invariant10(invitation.type === Invitation5.Type.DELEGATED && invitation.delegationCredentialId, void 0, {
|
|
3212
|
-
F:
|
|
3213
|
-
L:
|
|
3234
|
+
F: __dxlog_file14,
|
|
3235
|
+
L: 129,
|
|
3214
3236
|
S: this,
|
|
3215
3237
|
A: [
|
|
3216
3238
|
"invitation.type === Invitation.Type.DELEGATED && invitation.delegationCredentialId",
|
|
@@ -3219,27 +3241,27 @@ var SpaceInvitationProtocol = class {
|
|
|
3219
3241
|
});
|
|
3220
3242
|
const space = this._spaceManager.spaces.get(this._spaceKey);
|
|
3221
3243
|
invariant10(space, void 0, {
|
|
3222
|
-
F:
|
|
3223
|
-
L:
|
|
3244
|
+
F: __dxlog_file14,
|
|
3245
|
+
L: 131,
|
|
3224
3246
|
S: this,
|
|
3225
3247
|
A: [
|
|
3226
3248
|
"space",
|
|
3227
3249
|
""
|
|
3228
3250
|
]
|
|
3229
3251
|
});
|
|
3230
|
-
|
|
3252
|
+
log11("cancelling delegated space invitation", {
|
|
3231
3253
|
host: this._signingContext.deviceKey,
|
|
3232
3254
|
id: invitation.invitationId
|
|
3233
3255
|
}, {
|
|
3234
|
-
F:
|
|
3235
|
-
L:
|
|
3256
|
+
F: __dxlog_file14,
|
|
3257
|
+
L: 133,
|
|
3236
3258
|
S: this,
|
|
3237
3259
|
C: (f, a) => f(...a)
|
|
3238
3260
|
});
|
|
3239
3261
|
const credential = await createCancelDelegatedSpaceInvitationCredential(this._signingContext.credentialSigner, space.key, invitation.delegationCredentialId);
|
|
3240
3262
|
invariant10(credential.credential, void 0, {
|
|
3241
|
-
F:
|
|
3242
|
-
L:
|
|
3263
|
+
F: __dxlog_file14,
|
|
3264
|
+
L: 140,
|
|
3243
3265
|
S: this,
|
|
3244
3266
|
A: [
|
|
3245
3267
|
"credential.credential",
|
|
@@ -3277,8 +3299,8 @@ var SpaceInvitationProtocol = class {
|
|
|
3277
3299
|
}
|
|
3278
3300
|
async accept(response) {
|
|
3279
3301
|
invariant10(response.space, void 0, {
|
|
3280
|
-
F:
|
|
3281
|
-
L:
|
|
3302
|
+
F: __dxlog_file14,
|
|
3303
|
+
L: 175,
|
|
3282
3304
|
S: this,
|
|
3283
3305
|
A: [
|
|
3284
3306
|
"response.space",
|
|
@@ -3288,8 +3310,8 @@ var SpaceInvitationProtocol = class {
|
|
|
3288
3310
|
const { credential, controlTimeframe, dataTimeframe } = response.space;
|
|
3289
3311
|
const assertion = getCredentialAssertion2(credential);
|
|
3290
3312
|
invariant10(assertion["@type"] === "dxos.halo.credentials.SpaceMember", "Invalid credential", {
|
|
3291
|
-
F:
|
|
3292
|
-
L:
|
|
3313
|
+
F: __dxlog_file14,
|
|
3314
|
+
L: 178,
|
|
3293
3315
|
S: this,
|
|
3294
3316
|
A: [
|
|
3295
3317
|
"assertion['@type'] === 'dxos.halo.credentials.SpaceMember'",
|
|
@@ -3297,8 +3319,8 @@ var SpaceInvitationProtocol = class {
|
|
|
3297
3319
|
]
|
|
3298
3320
|
});
|
|
3299
3321
|
invariant10(credential.subject.id.equals(this._signingContext.identityKey), void 0, {
|
|
3300
|
-
F:
|
|
3301
|
-
L:
|
|
3322
|
+
F: __dxlog_file14,
|
|
3323
|
+
L: 179,
|
|
3302
3324
|
S: this,
|
|
3303
3325
|
A: [
|
|
3304
3326
|
"credential.subject.id.equals(this._signingContext.identityKey)",
|
|
@@ -3322,17 +3344,17 @@ var SpaceInvitationProtocol = class {
|
|
|
3322
3344
|
};
|
|
3323
3345
|
|
|
3324
3346
|
// packages/sdk/client-services/src/packlets/invitations/invitations-manager.ts
|
|
3325
|
-
import { Event as Event3, PushStream, TimeoutError as TimeoutError2, Trigger as
|
|
3347
|
+
import { Event as Event3, PushStream, TimeoutError as TimeoutError2, Trigger as Trigger6 } from "@dxos/async";
|
|
3326
3348
|
import { AuthenticatingInvitation, AUTHENTICATION_CODE_LENGTH, CancellableInvitation, INVITATION_TIMEOUT as INVITATION_TIMEOUT2 } from "@dxos/client-protocol";
|
|
3327
3349
|
import { Context as Context6 } from "@dxos/context";
|
|
3328
3350
|
import { generatePasscode } from "@dxos/credentials";
|
|
3329
3351
|
import { hasInvitationExpired } from "@dxos/echo-pipeline";
|
|
3330
3352
|
import { invariant as invariant11 } from "@dxos/invariant";
|
|
3331
3353
|
import { PublicKey as PublicKey8 } from "@dxos/keys";
|
|
3332
|
-
import { log as
|
|
3354
|
+
import { log as log12 } from "@dxos/log";
|
|
3333
3355
|
import { Invitation as Invitation6 } from "@dxos/protocols/proto/dxos/client/services";
|
|
3334
3356
|
import { SpaceMember as SpaceMember3 } from "@dxos/protocols/proto/dxos/halo/credentials";
|
|
3335
|
-
var
|
|
3357
|
+
var __dxlog_file15 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitations-manager.ts";
|
|
3336
3358
|
var InvitationsManager = class {
|
|
3337
3359
|
constructor(_invitationsHandler, _getHandler, _metadataStore) {
|
|
3338
3360
|
this._invitationsHandler = _invitationsHandler;
|
|
@@ -3374,8 +3396,8 @@ var InvitationsManager = class {
|
|
|
3374
3396
|
try {
|
|
3375
3397
|
await this._persistIfRequired(handler, stream, invitation);
|
|
3376
3398
|
} catch (err) {
|
|
3377
|
-
|
|
3378
|
-
F:
|
|
3399
|
+
log12.catch(err, void 0, {
|
|
3400
|
+
F: __dxlog_file15,
|
|
3379
3401
|
L: 82,
|
|
3380
3402
|
S: this,
|
|
3381
3403
|
C: (f, a) => f(...a)
|
|
@@ -3398,7 +3420,7 @@ var InvitationsManager = class {
|
|
|
3398
3420
|
const freshInvitations = persistentInvitations.filter((invitation) => !hasInvitationExpired(invitation));
|
|
3399
3421
|
const loadTasks = freshInvitations.map((persistentInvitation) => {
|
|
3400
3422
|
invariant11(!this._createInvitations.get(persistentInvitation.invitationId), "invitation already exists", {
|
|
3401
|
-
F:
|
|
3423
|
+
F: __dxlog_file15,
|
|
3402
3424
|
L: 103,
|
|
3403
3425
|
S: this,
|
|
3404
3426
|
A: [
|
|
@@ -3416,8 +3438,8 @@ var InvitationsManager = class {
|
|
|
3416
3438
|
invitations: cInvitations.map((invitation) => invitation.get())
|
|
3417
3439
|
};
|
|
3418
3440
|
} catch (err) {
|
|
3419
|
-
|
|
3420
|
-
F:
|
|
3441
|
+
log12.catch(err, void 0, {
|
|
3442
|
+
F: __dxlog_file15,
|
|
3421
3443
|
L: 110,
|
|
3422
3444
|
S: this,
|
|
3423
3445
|
C: (f, a) => f(...a)
|
|
@@ -3448,14 +3470,14 @@ var InvitationsManager = class {
|
|
|
3448
3470
|
return invitation;
|
|
3449
3471
|
}
|
|
3450
3472
|
async authenticate({ invitationId, authCode }) {
|
|
3451
|
-
|
|
3452
|
-
F:
|
|
3473
|
+
log12("authenticating...", void 0, {
|
|
3474
|
+
F: __dxlog_file15,
|
|
3453
3475
|
L: 140,
|
|
3454
3476
|
S: this,
|
|
3455
3477
|
C: (f, a) => f(...a)
|
|
3456
3478
|
});
|
|
3457
3479
|
invariant11(invitationId, void 0, {
|
|
3458
|
-
F:
|
|
3480
|
+
F: __dxlog_file15,
|
|
3459
3481
|
L: 141,
|
|
3460
3482
|
S: this,
|
|
3461
3483
|
A: [
|
|
@@ -3465,10 +3487,10 @@ var InvitationsManager = class {
|
|
|
3465
3487
|
});
|
|
3466
3488
|
const observable = this._acceptInvitations.get(invitationId);
|
|
3467
3489
|
if (!observable) {
|
|
3468
|
-
|
|
3490
|
+
log12.warn("invalid invitation", {
|
|
3469
3491
|
invitationId
|
|
3470
3492
|
}, {
|
|
3471
|
-
F:
|
|
3493
|
+
F: __dxlog_file15,
|
|
3472
3494
|
L: 144,
|
|
3473
3495
|
S: this,
|
|
3474
3496
|
C: (f, a) => f(...a)
|
|
@@ -3478,16 +3500,16 @@ var InvitationsManager = class {
|
|
|
3478
3500
|
}
|
|
3479
3501
|
}
|
|
3480
3502
|
async cancelInvitation({ invitationId }) {
|
|
3481
|
-
|
|
3503
|
+
log12("cancelInvitation...", {
|
|
3482
3504
|
invitationId
|
|
3483
3505
|
}, {
|
|
3484
|
-
F:
|
|
3506
|
+
F: __dxlog_file15,
|
|
3485
3507
|
L: 151,
|
|
3486
3508
|
S: this,
|
|
3487
3509
|
C: (f, a) => f(...a)
|
|
3488
3510
|
});
|
|
3489
3511
|
invariant11(invitationId, void 0, {
|
|
3490
|
-
F:
|
|
3512
|
+
F: __dxlog_file15,
|
|
3491
3513
|
L: 152,
|
|
3492
3514
|
S: this,
|
|
3493
3515
|
A: [
|
|
@@ -3561,12 +3583,15 @@ var InvitationsManager = class {
|
|
|
3561
3583
|
stream.error(err);
|
|
3562
3584
|
void ctx.dispose();
|
|
3563
3585
|
}
|
|
3586
|
+
}, {
|
|
3587
|
+
F: __dxlog_file15,
|
|
3588
|
+
L: 234
|
|
3564
3589
|
});
|
|
3565
3590
|
ctx.onDispose(() => {
|
|
3566
|
-
|
|
3591
|
+
log12("complete", {
|
|
3567
3592
|
...handler.toJSON()
|
|
3568
3593
|
}, {
|
|
3569
|
-
F:
|
|
3594
|
+
F: __dxlog_file15,
|
|
3570
3595
|
L: 241,
|
|
3571
3596
|
S: this,
|
|
3572
3597
|
C: (f, a) => f(...a)
|
|
@@ -3591,15 +3616,15 @@ var InvitationsManager = class {
|
|
|
3591
3616
|
};
|
|
3592
3617
|
}
|
|
3593
3618
|
_createObservableAcceptingInvitation(handler, initialState) {
|
|
3594
|
-
const otpEnteredTrigger = new
|
|
3619
|
+
const otpEnteredTrigger = new Trigger6();
|
|
3595
3620
|
const stream = new PushStream();
|
|
3596
3621
|
const ctx = new Context6({
|
|
3597
3622
|
onError: (err) => {
|
|
3598
3623
|
if (err instanceof TimeoutError2) {
|
|
3599
|
-
|
|
3624
|
+
log12("timeout", {
|
|
3600
3625
|
...handler.toJSON()
|
|
3601
3626
|
}, {
|
|
3602
|
-
F:
|
|
3627
|
+
F: __dxlog_file15,
|
|
3603
3628
|
L: 261,
|
|
3604
3629
|
S: this,
|
|
3605
3630
|
C: (f, a) => f(...a)
|
|
@@ -3609,8 +3634,8 @@ var InvitationsManager = class {
|
|
|
3609
3634
|
state: Invitation6.State.TIMEOUT
|
|
3610
3635
|
});
|
|
3611
3636
|
} else {
|
|
3612
|
-
|
|
3613
|
-
F:
|
|
3637
|
+
log12.warn("auth failed", err, {
|
|
3638
|
+
F: __dxlog_file15,
|
|
3614
3639
|
L: 264,
|
|
3615
3640
|
S: this,
|
|
3616
3641
|
C: (f, a) => f(...a)
|
|
@@ -3622,12 +3647,15 @@ var InvitationsManager = class {
|
|
|
3622
3647
|
}
|
|
3623
3648
|
void ctx.dispose();
|
|
3624
3649
|
}
|
|
3650
|
+
}, {
|
|
3651
|
+
F: __dxlog_file15,
|
|
3652
|
+
L: 258
|
|
3625
3653
|
});
|
|
3626
3654
|
ctx.onDispose(() => {
|
|
3627
|
-
|
|
3655
|
+
log12("complete", {
|
|
3628
3656
|
...handler.toJSON()
|
|
3629
3657
|
}, {
|
|
3630
|
-
F:
|
|
3658
|
+
F: __dxlog_file15,
|
|
3631
3659
|
L: 271,
|
|
3632
3660
|
S: this,
|
|
3633
3661
|
C: (f, a) => f(...a)
|
|
@@ -3671,8 +3699,8 @@ var InvitationsManager = class {
|
|
|
3671
3699
|
try {
|
|
3672
3700
|
await this._metadataStore.removeInvitation(invitation.invitationId);
|
|
3673
3701
|
} catch (err) {
|
|
3674
|
-
|
|
3675
|
-
F:
|
|
3702
|
+
log12.catch(err, void 0, {
|
|
3703
|
+
F: __dxlog_file15,
|
|
3676
3704
|
L: 307,
|
|
3677
3705
|
S: this,
|
|
3678
3706
|
C: (f, a) => f(...a)
|
|
@@ -3687,7 +3715,7 @@ var InvitationsManager = class {
|
|
|
3687
3715
|
};
|
|
3688
3716
|
|
|
3689
3717
|
// packages/sdk/client-services/src/packlets/spaces/data-space.ts
|
|
3690
|
-
import { Event as Event6, Mutex as Mutex2, scheduleTask as scheduleTask5, sleep as
|
|
3718
|
+
import { Event as Event6, Mutex as Mutex2, scheduleTask as scheduleTask5, sleep as sleep3, synchronized, trackLeaks } from "@dxos/async";
|
|
3691
3719
|
import { AUTH_TIMEOUT as AUTH_TIMEOUT2 } from "@dxos/client-protocol";
|
|
3692
3720
|
import { Context as Context8, ContextDisposedError as ContextDisposedError3, cancelWithContext as cancelWithContext5 } from "@dxos/context";
|
|
3693
3721
|
import { timed, warnAfterTimeout } from "@dxos/debug";
|
|
@@ -3695,7 +3723,7 @@ import { createMappedFeedWriter } from "@dxos/echo-pipeline";
|
|
|
3695
3723
|
import { SpaceDocVersion } from "@dxos/echo-protocol";
|
|
3696
3724
|
import { failedInvariant } from "@dxos/invariant";
|
|
3697
3725
|
import { PublicKey as PublicKey10 } from "@dxos/keys";
|
|
3698
|
-
import { log as
|
|
3726
|
+
import { log as log15 } from "@dxos/log";
|
|
3699
3727
|
import { CancelledError, SystemError } from "@dxos/protocols";
|
|
3700
3728
|
import { SpaceState as SpaceState2 } from "@dxos/protocols/proto/dxos/client/services";
|
|
3701
3729
|
import { AdmittedFeed as AdmittedFeed3, SpaceMember as SpaceMember4 } from "@dxos/protocols/proto/dxos/halo/credentials";
|
|
@@ -3756,10 +3784,10 @@ import { convertLegacyReferences, convertLegacySpaceRootDoc, findInlineObjectOfT
|
|
|
3756
3784
|
import { AutomergeDocumentLoaderImpl } from "@dxos/echo-pipeline";
|
|
3757
3785
|
import { TYPE_PROPERTIES } from "@dxos/echo-schema";
|
|
3758
3786
|
import { invariant as invariant12 } from "@dxos/invariant";
|
|
3759
|
-
import { log as
|
|
3787
|
+
import { log as log13 } from "@dxos/log";
|
|
3760
3788
|
import { CreateEpochRequest } from "@dxos/protocols/proto/dxos/client/services";
|
|
3761
3789
|
import { assignDeep } from "@dxos/util";
|
|
3762
|
-
var
|
|
3790
|
+
var __dxlog_file16 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/epoch-migrations.ts";
|
|
3763
3791
|
var runEpochMigration = async (ctx, context) => {
|
|
3764
3792
|
switch (context.migration) {
|
|
3765
3793
|
case CreateEpochRequest.Migration.INIT_AUTOMERGE: {
|
|
@@ -3782,8 +3810,8 @@ var runEpochMigration = async (ctx, context) => {
|
|
|
3782
3810
|
};
|
|
3783
3811
|
}
|
|
3784
3812
|
case CreateEpochRequest.Migration.FRAGMENT_AUTOMERGE_ROOT: {
|
|
3785
|
-
|
|
3786
|
-
F:
|
|
3813
|
+
log13.info("Fragmenting", void 0, {
|
|
3814
|
+
F: __dxlog_file16,
|
|
3787
3815
|
L: 63,
|
|
3788
3816
|
S: void 0,
|
|
3789
3817
|
C: (f, a) => f(...a)
|
|
@@ -3795,7 +3823,7 @@ var runEpochMigration = async (ctx, context) => {
|
|
|
3795
3823
|
const properties = findInlineObjectOfType(rootHandle.docSync(), TYPE_PROPERTIES);
|
|
3796
3824
|
const otherObjects = objects.filter(([key]) => key !== properties?.[0]);
|
|
3797
3825
|
invariant12(properties, "Properties not found", {
|
|
3798
|
-
F:
|
|
3826
|
+
F: __dxlog_file16,
|
|
3799
3827
|
L: 73,
|
|
3800
3828
|
S: void 0,
|
|
3801
3829
|
A: [
|
|
@@ -3811,7 +3839,7 @@ var runEpochMigration = async (ctx, context) => {
|
|
|
3811
3839
|
};
|
|
3812
3840
|
const newRoot = context.repo.create(newSpaceDoc);
|
|
3813
3841
|
invariant12(typeof newRoot.url === "string" && newRoot.url.length > 0, void 0, {
|
|
3814
|
-
F:
|
|
3842
|
+
F: __dxlog_file16,
|
|
3815
3843
|
L: 78,
|
|
3816
3844
|
S: void 0,
|
|
3817
3845
|
A: [
|
|
@@ -3842,7 +3870,7 @@ var runEpochMigration = async (ctx, context) => {
|
|
|
3842
3870
|
const rootHandle = context.repo.find(currentRootUrl);
|
|
3843
3871
|
await cancelWithContext4(ctx, asyncTimeout2(rootHandle.whenReady(), 1e4));
|
|
3844
3872
|
invariant12(rootHandle.docSync(), "Root doc not found", {
|
|
3845
|
-
F:
|
|
3873
|
+
F: __dxlog_file16,
|
|
3846
3874
|
L: 100,
|
|
3847
3875
|
S: void 0,
|
|
3848
3876
|
A: [
|
|
@@ -3855,7 +3883,7 @@ var runEpochMigration = async (ctx, context) => {
|
|
|
3855
3883
|
const handle = context.repo.find(url);
|
|
3856
3884
|
await cancelWithContext4(ctx, asyncTimeout2(handle.whenReady(), 1e4));
|
|
3857
3885
|
invariant12(handle.docSync(), "Doc not found", {
|
|
3858
|
-
F:
|
|
3886
|
+
F: __dxlog_file16,
|
|
3859
3887
|
L: 107,
|
|
3860
3888
|
S: void 0,
|
|
3861
3889
|
A: [
|
|
@@ -3877,7 +3905,7 @@ var runEpochMigration = async (ctx, context) => {
|
|
|
3877
3905
|
}
|
|
3878
3906
|
case CreateEpochRequest.Migration.REPLACE_AUTOMERGE_ROOT: {
|
|
3879
3907
|
invariant12(context.newAutomergeRoot, void 0, {
|
|
3880
|
-
F:
|
|
3908
|
+
F: __dxlog_file16,
|
|
3881
3909
|
L: 124,
|
|
3882
3910
|
S: void 0,
|
|
3883
3911
|
A: [
|
|
@@ -3895,22 +3923,25 @@ var runEpochMigration = async (ctx, context) => {
|
|
|
3895
3923
|
};
|
|
3896
3924
|
|
|
3897
3925
|
// packages/sdk/client-services/src/packlets/spaces/notarization-plugin.ts
|
|
3898
|
-
import { DeferredTask, Event as Event5, scheduleTask as scheduleTask4, sleep, TimeoutError as TimeoutError3, Trigger as
|
|
3926
|
+
import { DeferredTask, Event as Event5, scheduleTask as scheduleTask4, sleep as sleep2, TimeoutError as TimeoutError3, Trigger as Trigger7 } from "@dxos/async";
|
|
3899
3927
|
import { Context as Context7, rejectOnDispose } from "@dxos/context";
|
|
3900
3928
|
import { invariant as invariant13 } from "@dxos/invariant";
|
|
3901
3929
|
import { PublicKey as PublicKey9 } from "@dxos/keys";
|
|
3902
|
-
import { log as
|
|
3930
|
+
import { log as log14 } from "@dxos/log";
|
|
3903
3931
|
import { schema as schema4 } from "@dxos/protocols";
|
|
3904
3932
|
import { RpcExtension as RpcExtension3 } from "@dxos/teleport";
|
|
3905
3933
|
import { ComplexMap as ComplexMap2, ComplexSet as ComplexSet4, entry } from "@dxos/util";
|
|
3906
|
-
var
|
|
3934
|
+
var __dxlog_file17 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/notarization-plugin.ts";
|
|
3907
3935
|
var DEFAULT_RETRY_TIMEOUT = 1e3;
|
|
3908
3936
|
var DEFAULT_SUCCESS_DELAY = 1e3;
|
|
3909
3937
|
var DEFAULT_NOTARIZE_TIMEOUT = 1e4;
|
|
3910
3938
|
var WRITER_NOT_SET_ERROR_CODE = "WRITER_NOT_SET";
|
|
3911
3939
|
var NotarizationPlugin = class {
|
|
3912
3940
|
constructor() {
|
|
3913
|
-
this._ctx = new Context7(
|
|
3941
|
+
this._ctx = new Context7(void 0, {
|
|
3942
|
+
F: __dxlog_file17,
|
|
3943
|
+
L: 62
|
|
3944
|
+
});
|
|
3914
3945
|
this._extensionOpened = new Event5();
|
|
3915
3946
|
this._extensions = /* @__PURE__ */ new Set();
|
|
3916
3947
|
this._processedCredentials = new ComplexSet4(PublicKey9.hash);
|
|
@@ -3928,16 +3959,16 @@ var NotarizationPlugin = class {
|
|
|
3928
3959
|
* Request credentials to be notarized.
|
|
3929
3960
|
*/
|
|
3930
3961
|
async notarize({ ctx: opCtx, credentials, timeout = DEFAULT_NOTARIZE_TIMEOUT, retryTimeout = DEFAULT_RETRY_TIMEOUT, successDelay = DEFAULT_SUCCESS_DELAY }) {
|
|
3931
|
-
|
|
3962
|
+
log14("notarize", {
|
|
3932
3963
|
credentials
|
|
3933
3964
|
}, {
|
|
3934
|
-
F:
|
|
3965
|
+
F: __dxlog_file17,
|
|
3935
3966
|
L: 90,
|
|
3936
3967
|
S: this,
|
|
3937
3968
|
C: (f, a) => f(...a)
|
|
3938
3969
|
});
|
|
3939
3970
|
invariant13(credentials.every((credential) => credential.id), "Credentials must have an id", {
|
|
3940
|
-
F:
|
|
3971
|
+
F: __dxlog_file17,
|
|
3941
3972
|
L: 91,
|
|
3942
3973
|
S: this,
|
|
3943
3974
|
A: [
|
|
@@ -3945,13 +3976,13 @@ var NotarizationPlugin = class {
|
|
|
3945
3976
|
"'Credentials must have an id'"
|
|
3946
3977
|
]
|
|
3947
3978
|
});
|
|
3948
|
-
const errors = new
|
|
3979
|
+
const errors = new Trigger7();
|
|
3949
3980
|
const ctx = this._ctx.derive({
|
|
3950
3981
|
onError: (err) => {
|
|
3951
|
-
|
|
3982
|
+
log14.warn("Notarization error", {
|
|
3952
3983
|
err
|
|
3953
3984
|
}, {
|
|
3954
|
-
F:
|
|
3985
|
+
F: __dxlog_file17,
|
|
3955
3986
|
L: 99,
|
|
3956
3987
|
S: this,
|
|
3957
3988
|
C: (f, a) => f(...a)
|
|
@@ -3963,11 +3994,11 @@ var NotarizationPlugin = class {
|
|
|
3963
3994
|
opCtx?.onDispose(() => ctx.dispose());
|
|
3964
3995
|
if (timeout !== 0) {
|
|
3965
3996
|
scheduleTask4(ctx, () => {
|
|
3966
|
-
|
|
3997
|
+
log14.warn("Notarization timeout", {
|
|
3967
3998
|
timeout,
|
|
3968
3999
|
peers: Array.from(this._extensions).map((extension) => extension.remotePeerId)
|
|
3969
4000
|
}, {
|
|
3970
|
-
F:
|
|
4001
|
+
F: __dxlog_file17,
|
|
3971
4002
|
L: 111,
|
|
3972
4003
|
S: this,
|
|
3973
4004
|
C: (f, a) => f(...a)
|
|
@@ -3987,10 +4018,10 @@ var NotarizationPlugin = class {
|
|
|
3987
4018
|
...this._extensions
|
|
3988
4019
|
].find((peer2) => !peersTried.has(peer2));
|
|
3989
4020
|
if (!peer) {
|
|
3990
|
-
|
|
4021
|
+
log14.info("Exhausted all peers to notarize with", {
|
|
3991
4022
|
retryIn: retryTimeout
|
|
3992
4023
|
}, {
|
|
3993
|
-
F:
|
|
4024
|
+
F: __dxlog_file17,
|
|
3994
4025
|
L: 136,
|
|
3995
4026
|
S: this,
|
|
3996
4027
|
C: (f, a) => f(...a)
|
|
@@ -4000,11 +4031,11 @@ var NotarizationPlugin = class {
|
|
|
4000
4031
|
return;
|
|
4001
4032
|
}
|
|
4002
4033
|
peersTried.add(peer);
|
|
4003
|
-
|
|
4034
|
+
log14("try notarizing", {
|
|
4004
4035
|
peer: peer.localPeerId,
|
|
4005
4036
|
credentialId: credentials.map((credential) => credential.id)
|
|
4006
4037
|
}, {
|
|
4007
|
-
F:
|
|
4038
|
+
F: __dxlog_file17,
|
|
4008
4039
|
L: 143,
|
|
4009
4040
|
S: this,
|
|
4010
4041
|
C: (f, a) => f(...a)
|
|
@@ -4012,17 +4043,17 @@ var NotarizationPlugin = class {
|
|
|
4012
4043
|
await peer.rpc.NotarizationService.notarize({
|
|
4013
4044
|
credentials: credentials.filter((credential) => !this._processedCredentials.has(credential.id))
|
|
4014
4045
|
});
|
|
4015
|
-
|
|
4016
|
-
F:
|
|
4046
|
+
log14("success", void 0, {
|
|
4047
|
+
F: __dxlog_file17,
|
|
4017
4048
|
L: 147,
|
|
4018
4049
|
S: this,
|
|
4019
4050
|
C: (f, a) => f(...a)
|
|
4020
4051
|
});
|
|
4021
|
-
await
|
|
4052
|
+
await sleep2(successDelay);
|
|
4022
4053
|
} catch (err) {
|
|
4023
4054
|
if (!ctx.disposed && !err.message.includes(WRITER_NOT_SET_ERROR_CODE)) {
|
|
4024
|
-
|
|
4025
|
-
F:
|
|
4055
|
+
log14.info("error notarizing (recoverable)", err, {
|
|
4056
|
+
F: __dxlog_file17,
|
|
4026
4057
|
L: 151,
|
|
4027
4058
|
S: this,
|
|
4028
4059
|
C: (f, a) => f(...a)
|
|
@@ -4039,8 +4070,8 @@ var NotarizationPlugin = class {
|
|
|
4039
4070
|
allNotarized,
|
|
4040
4071
|
errors.wait()
|
|
4041
4072
|
]);
|
|
4042
|
-
|
|
4043
|
-
F:
|
|
4073
|
+
log14("done", void 0, {
|
|
4074
|
+
F: __dxlog_file17,
|
|
4044
4075
|
L: 162,
|
|
4045
4076
|
S: this,
|
|
4046
4077
|
C: (f, a) => f(...a)
|
|
@@ -4062,7 +4093,7 @@ var NotarizationPlugin = class {
|
|
|
4062
4093
|
}
|
|
4063
4094
|
setWriter(writer) {
|
|
4064
4095
|
invariant13(!this._writer, "Writer already set.", {
|
|
4065
|
-
F:
|
|
4096
|
+
F: __dxlog_file17,
|
|
4066
4097
|
L: 181,
|
|
4067
4098
|
S: this,
|
|
4068
4099
|
A: [
|
|
@@ -4076,7 +4107,7 @@ var NotarizationPlugin = class {
|
|
|
4076
4107
|
if (this._processedCredentials.has(id)) {
|
|
4077
4108
|
return;
|
|
4078
4109
|
}
|
|
4079
|
-
await entry(this._processCredentialsTriggers, id).orInsert(new
|
|
4110
|
+
await entry(this._processCredentialsTriggers, id).orInsert(new Trigger7()).value.wait();
|
|
4080
4111
|
}
|
|
4081
4112
|
/**
|
|
4082
4113
|
* Requests from other peers to notarize credentials.
|
|
@@ -4087,7 +4118,7 @@ var NotarizationPlugin = class {
|
|
|
4087
4118
|
}
|
|
4088
4119
|
for (const credential of request.credentials ?? []) {
|
|
4089
4120
|
invariant13(credential.id, "Credential must have an id", {
|
|
4090
|
-
F:
|
|
4121
|
+
F: __dxlog_file17,
|
|
4091
4122
|
L: 200,
|
|
4092
4123
|
S: this,
|
|
4093
4124
|
A: [
|
|
@@ -4104,10 +4135,10 @@ var NotarizationPlugin = class {
|
|
|
4104
4135
|
createExtension() {
|
|
4105
4136
|
const extension = new NotarizationTeleportExtension({
|
|
4106
4137
|
onOpen: async () => {
|
|
4107
|
-
|
|
4138
|
+
log14("extension opened", {
|
|
4108
4139
|
peer: extension.localPeerId
|
|
4109
4140
|
}, {
|
|
4110
|
-
F:
|
|
4141
|
+
F: __dxlog_file17,
|
|
4111
4142
|
L: 211,
|
|
4112
4143
|
S: this,
|
|
4113
4144
|
C: (f, a) => f(...a)
|
|
@@ -4116,10 +4147,10 @@ var NotarizationPlugin = class {
|
|
|
4116
4147
|
this._extensionOpened.emit();
|
|
4117
4148
|
},
|
|
4118
4149
|
onClose: async () => {
|
|
4119
|
-
|
|
4150
|
+
log14("extension closed", {
|
|
4120
4151
|
peer: extension.localPeerId
|
|
4121
4152
|
}, {
|
|
4122
|
-
F:
|
|
4153
|
+
F: __dxlog_file17,
|
|
4123
4154
|
L: 216,
|
|
4124
4155
|
S: this,
|
|
4125
4156
|
C: (f, a) => f(...a)
|
|
@@ -4236,10 +4267,13 @@ function _using_ctx() {
|
|
|
4236
4267
|
}
|
|
4237
4268
|
};
|
|
4238
4269
|
}
|
|
4239
|
-
var
|
|
4270
|
+
var __dxlog_file18 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space.ts";
|
|
4240
4271
|
var DataSpace = class {
|
|
4241
4272
|
constructor(params) {
|
|
4242
|
-
this._ctx = new Context8(
|
|
4273
|
+
this._ctx = new Context8(void 0, {
|
|
4274
|
+
F: __dxlog_file18,
|
|
4275
|
+
L: 84
|
|
4276
|
+
});
|
|
4243
4277
|
this._notarizationPlugin = new NotarizationPlugin();
|
|
4244
4278
|
this._cache = void 0;
|
|
4245
4279
|
// TODO(dmaretskyi): Move into Space?
|
|
@@ -4270,10 +4304,10 @@ var DataSpace = class {
|
|
|
4270
4304
|
});
|
|
4271
4305
|
this._cache = params.cache;
|
|
4272
4306
|
this._state = params.initialState;
|
|
4273
|
-
|
|
4307
|
+
log15("new state", {
|
|
4274
4308
|
state: SpaceState2[this._state]
|
|
4275
4309
|
}, {
|
|
4276
|
-
F:
|
|
4310
|
+
F: __dxlog_file18,
|
|
4277
4311
|
L: 146,
|
|
4278
4312
|
S: this,
|
|
4279
4313
|
C: (f, a) => f(...a)
|
|
@@ -4328,12 +4362,15 @@ var DataSpace = class {
|
|
|
4328
4362
|
await this._inner.spaceState.addCredentialProcessor(this._notarizationPlugin);
|
|
4329
4363
|
await this._automergeSpaceState.open();
|
|
4330
4364
|
await this._inner.spaceState.addCredentialProcessor(this._automergeSpaceState);
|
|
4331
|
-
await this._inner.open(new Context8(
|
|
4365
|
+
await this._inner.open(new Context8(void 0, {
|
|
4366
|
+
F: __dxlog_file18,
|
|
4367
|
+
L: 215
|
|
4368
|
+
}));
|
|
4332
4369
|
this._state = SpaceState2.CONTROL_ONLY;
|
|
4333
|
-
|
|
4370
|
+
log15("new state", {
|
|
4334
4371
|
state: SpaceState2[this._state]
|
|
4335
4372
|
}, {
|
|
4336
|
-
F:
|
|
4373
|
+
F: __dxlog_file18,
|
|
4337
4374
|
L: 217,
|
|
4338
4375
|
S: this,
|
|
4339
4376
|
C: (f, a) => f(...a)
|
|
@@ -4348,16 +4385,19 @@ var DataSpace = class {
|
|
|
4348
4385
|
async _close() {
|
|
4349
4386
|
await this._callbacks.beforeClose?.();
|
|
4350
4387
|
this._state = SpaceState2.CLOSED;
|
|
4351
|
-
|
|
4388
|
+
log15("new state", {
|
|
4352
4389
|
state: SpaceState2[this._state]
|
|
4353
4390
|
}, {
|
|
4354
|
-
F:
|
|
4391
|
+
F: __dxlog_file18,
|
|
4355
4392
|
L: 231,
|
|
4356
4393
|
S: this,
|
|
4357
4394
|
C: (f, a) => f(...a)
|
|
4358
4395
|
});
|
|
4359
4396
|
await this._ctx.dispose();
|
|
4360
|
-
this._ctx = new Context8(
|
|
4397
|
+
this._ctx = new Context8(void 0, {
|
|
4398
|
+
F: __dxlog_file18,
|
|
4399
|
+
L: 233
|
|
4400
|
+
});
|
|
4361
4401
|
await this.authVerifier.close();
|
|
4362
4402
|
await this._inner.close();
|
|
4363
4403
|
await this._inner.spaceState.removeCredentialProcessor(this._automergeSpaceState);
|
|
@@ -4383,25 +4423,25 @@ var DataSpace = class {
|
|
|
4383
4423
|
await this.initializeDataPipeline();
|
|
4384
4424
|
} catch (err) {
|
|
4385
4425
|
if (err instanceof CancelledError || err instanceof ContextDisposedError3) {
|
|
4386
|
-
|
|
4387
|
-
F:
|
|
4426
|
+
log15("data pipeline initialization cancelled", err, {
|
|
4427
|
+
F: __dxlog_file18,
|
|
4388
4428
|
L: 265,
|
|
4389
4429
|
S: this,
|
|
4390
4430
|
C: (f, a) => f(...a)
|
|
4391
4431
|
});
|
|
4392
4432
|
return;
|
|
4393
4433
|
}
|
|
4394
|
-
|
|
4395
|
-
F:
|
|
4434
|
+
log15.error("Error initializing data pipeline", err, {
|
|
4435
|
+
F: __dxlog_file18,
|
|
4396
4436
|
L: 269,
|
|
4397
4437
|
S: this,
|
|
4398
4438
|
C: (f, a) => f(...a)
|
|
4399
4439
|
});
|
|
4400
4440
|
this._state = SpaceState2.ERROR;
|
|
4401
|
-
|
|
4441
|
+
log15("new state", {
|
|
4402
4442
|
state: SpaceState2[this._state]
|
|
4403
4443
|
}, {
|
|
4404
|
-
F:
|
|
4444
|
+
F: __dxlog_file18,
|
|
4405
4445
|
L: 271,
|
|
4406
4446
|
S: this,
|
|
4407
4447
|
C: (f, a) => f(...a)
|
|
@@ -4418,16 +4458,16 @@ var DataSpace = class {
|
|
|
4418
4458
|
throw new SystemError("Invalid operation");
|
|
4419
4459
|
}
|
|
4420
4460
|
this._state = SpaceState2.INITIALIZING;
|
|
4421
|
-
|
|
4461
|
+
log15("new state", {
|
|
4422
4462
|
state: SpaceState2[this._state]
|
|
4423
4463
|
}, {
|
|
4424
|
-
F:
|
|
4464
|
+
F: __dxlog_file18,
|
|
4425
4465
|
L: 287,
|
|
4426
4466
|
S: this,
|
|
4427
4467
|
C: (f, a) => f(...a)
|
|
4428
4468
|
});
|
|
4429
4469
|
await this._initializeAndReadControlPipeline();
|
|
4430
|
-
await
|
|
4470
|
+
await sleep3(1);
|
|
4431
4471
|
const ready = this.stateUpdate.waitForCondition(() => this._state === SpaceState2.READY);
|
|
4432
4472
|
this._automergeSpaceState.startProcessingRootDocs();
|
|
4433
4473
|
await ready;
|
|
@@ -4435,10 +4475,10 @@ var DataSpace = class {
|
|
|
4435
4475
|
async _enterReadyState() {
|
|
4436
4476
|
await this._callbacks.beforeReady?.();
|
|
4437
4477
|
this._state = SpaceState2.READY;
|
|
4438
|
-
|
|
4478
|
+
log15("new state", {
|
|
4439
4479
|
state: SpaceState2[this._state]
|
|
4440
4480
|
}, {
|
|
4441
|
-
F:
|
|
4481
|
+
F: __dxlog_file18,
|
|
4442
4482
|
L: 306,
|
|
4443
4483
|
S: this,
|
|
4444
4484
|
C: (f, a) => f(...a)
|
|
@@ -4453,8 +4493,8 @@ var DataSpace = class {
|
|
|
4453
4493
|
});
|
|
4454
4494
|
this.metrics.controlPipelineReady = /* @__PURE__ */ new Date();
|
|
4455
4495
|
await this._createWritableFeeds();
|
|
4456
|
-
|
|
4457
|
-
F:
|
|
4496
|
+
log15("writable feeds created", void 0, {
|
|
4497
|
+
F: __dxlog_file18,
|
|
4458
4498
|
L: 322,
|
|
4459
4499
|
S: this,
|
|
4460
4500
|
C: (f, a) => f(...a)
|
|
@@ -4513,16 +4553,15 @@ var DataSpace = class {
|
|
|
4513
4553
|
}
|
|
4514
4554
|
}
|
|
4515
4555
|
_onNewAutomergeRoot(rootUrl) {
|
|
4516
|
-
|
|
4556
|
+
log15("loading automerge root doc for space", {
|
|
4517
4557
|
space: this.key,
|
|
4518
4558
|
rootUrl
|
|
4519
4559
|
}, {
|
|
4520
|
-
F:
|
|
4560
|
+
F: __dxlog_file18,
|
|
4521
4561
|
L: 388,
|
|
4522
4562
|
S: this,
|
|
4523
4563
|
C: (f, a) => f(...a)
|
|
4524
4564
|
});
|
|
4525
|
-
this._echoHost.replicateDocument(rootUrl);
|
|
4526
4565
|
const handle = this._echoHost.automergeRepo.find(rootUrl);
|
|
4527
4566
|
queueMicrotask(async () => {
|
|
4528
4567
|
try {
|
|
@@ -4549,8 +4588,10 @@ var DataSpace = class {
|
|
|
4549
4588
|
const root = await this._echoHost.openSpaceRoot(handle.url);
|
|
4550
4589
|
this._databaseRoot = root;
|
|
4551
4590
|
if (root.getVersion() !== SpaceDocVersion.CURRENT) {
|
|
4552
|
-
this._state
|
|
4553
|
-
|
|
4591
|
+
if (this._state !== SpaceState2.REQUIRES_MIGRATION) {
|
|
4592
|
+
this._state = SpaceState2.REQUIRES_MIGRATION;
|
|
4593
|
+
this.stateUpdate.emit();
|
|
4594
|
+
}
|
|
4554
4595
|
} else {
|
|
4555
4596
|
if (this._state !== SpaceState2.READY) {
|
|
4556
4597
|
await this._enterReadyState();
|
|
@@ -4565,12 +4606,12 @@ var DataSpace = class {
|
|
|
4565
4606
|
if (err instanceof ContextDisposedError3) {
|
|
4566
4607
|
return;
|
|
4567
4608
|
}
|
|
4568
|
-
|
|
4609
|
+
log15.warn("error loading automerge root doc", {
|
|
4569
4610
|
space: this.key,
|
|
4570
4611
|
rootUrl,
|
|
4571
4612
|
err
|
|
4572
4613
|
}, {
|
|
4573
|
-
F:
|
|
4614
|
+
F: __dxlog_file18,
|
|
4574
4615
|
L: 431,
|
|
4575
4616
|
S: this,
|
|
4576
4617
|
C: (f, a) => f(...a)
|
|
@@ -4653,10 +4694,10 @@ var DataSpace = class {
|
|
|
4653
4694
|
await this._close();
|
|
4654
4695
|
}
|
|
4655
4696
|
this._state = SpaceState2.INACTIVE;
|
|
4656
|
-
|
|
4697
|
+
log15("new state", {
|
|
4657
4698
|
state: SpaceState2[this._state]
|
|
4658
4699
|
}, {
|
|
4659
|
-
F:
|
|
4700
|
+
F: __dxlog_file18,
|
|
4660
4701
|
L: 512,
|
|
4661
4702
|
S: this,
|
|
4662
4703
|
C: (f, a) => f(...a)
|
|
@@ -4717,15 +4758,17 @@ DataSpace = _ts_decorate4([
|
|
|
4717
4758
|
import { Event as Event7, synchronized as synchronized2, trackLeaks as trackLeaks2 } from "@dxos/async";
|
|
4718
4759
|
import { PropertiesType } from "@dxos/client-protocol";
|
|
4719
4760
|
import { Context as Context9, cancelWithContext as cancelWithContext6 } from "@dxos/context";
|
|
4720
|
-
import { getCredentialAssertion as getCredentialAssertion3 } from "@dxos/credentials";
|
|
4761
|
+
import { getCredentialAssertion as getCredentialAssertion3, createAdmissionCredentials } from "@dxos/credentials";
|
|
4721
4762
|
import { convertLegacyReferences as convertLegacyReferences2, findInlineObjectOfType as findInlineObjectOfType2 } from "@dxos/echo-db";
|
|
4722
4763
|
import { AuthStatus } from "@dxos/echo-pipeline";
|
|
4764
|
+
import { CredentialServerExtension } from "@dxos/echo-pipeline";
|
|
4723
4765
|
import { LEGACY_TYPE_PROPERTIES, SpaceDocVersion as SpaceDocVersion2, encodeReference } from "@dxos/echo-protocol";
|
|
4724
4766
|
import { TYPE_PROPERTIES as TYPE_PROPERTIES2, generateEchoId, getTypeReference } from "@dxos/echo-schema";
|
|
4767
|
+
import { writeMessages as writeMessages3 } from "@dxos/feed-store";
|
|
4725
4768
|
import { invariant as invariant14 } from "@dxos/invariant";
|
|
4726
4769
|
import { PublicKey as PublicKey11 } from "@dxos/keys";
|
|
4727
|
-
import { log as
|
|
4728
|
-
import { trace as Trace2 } from "@dxos/protocols";
|
|
4770
|
+
import { log as log16 } from "@dxos/log";
|
|
4771
|
+
import { trace as Trace2, AlreadyJoinedError as AlreadyJoinedError3 } from "@dxos/protocols";
|
|
4729
4772
|
import { Invitation as Invitation7, SpaceState as SpaceState3 } from "@dxos/protocols/proto/dxos/client/services";
|
|
4730
4773
|
import { SpaceMember as SpaceMember6 } from "@dxos/protocols/proto/dxos/halo/credentials";
|
|
4731
4774
|
import { Gossip as Gossip2, Presence as Presence2 } from "@dxos/teleport-extension-gossip";
|
|
@@ -4813,7 +4856,7 @@ function _ts_decorate5(decorators, target, key, desc) {
|
|
|
4813
4856
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
4814
4857
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4815
4858
|
}
|
|
4816
|
-
var
|
|
4859
|
+
var __dxlog_file19 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts";
|
|
4817
4860
|
var PRESENCE_ANNOUNCE_INTERVAL = 1e4;
|
|
4818
4861
|
var PRESENCE_OFFLINE_TIMEOUT = 2e4;
|
|
4819
4862
|
var DEFAULT_SPACE_KEY = "__DEFAULT__";
|
|
@@ -4827,7 +4870,10 @@ var DataSpaceManager = class {
|
|
|
4827
4870
|
this._echoHost = _echoHost;
|
|
4828
4871
|
this._invitationsManager = _invitationsManager;
|
|
4829
4872
|
this._params = _params;
|
|
4830
|
-
this._ctx = new Context9(
|
|
4873
|
+
this._ctx = new Context9(void 0, {
|
|
4874
|
+
F: __dxlog_file19,
|
|
4875
|
+
L: 104
|
|
4876
|
+
});
|
|
4831
4877
|
this.updated = new Event7();
|
|
4832
4878
|
this._spaces = new ComplexMap3(PublicKey11.hash);
|
|
4833
4879
|
this._isOpen = false;
|
|
@@ -4860,46 +4906,46 @@ var DataSpaceManager = class {
|
|
|
4860
4906
|
return this._spaces;
|
|
4861
4907
|
}
|
|
4862
4908
|
async open() {
|
|
4863
|
-
|
|
4864
|
-
F:
|
|
4865
|
-
L:
|
|
4909
|
+
log16("open", void 0, {
|
|
4910
|
+
F: __dxlog_file19,
|
|
4911
|
+
L: 156,
|
|
4866
4912
|
S: this,
|
|
4867
4913
|
C: (f, a) => f(...a)
|
|
4868
4914
|
});
|
|
4869
|
-
|
|
4915
|
+
log16.trace("dxos.echo.data-space-manager.open", Trace2.begin({
|
|
4870
4916
|
id: this._instanceId
|
|
4871
4917
|
}), {
|
|
4872
|
-
F:
|
|
4873
|
-
L:
|
|
4918
|
+
F: __dxlog_file19,
|
|
4919
|
+
L: 157,
|
|
4874
4920
|
S: this,
|
|
4875
4921
|
C: (f, a) => f(...a)
|
|
4876
4922
|
});
|
|
4877
|
-
|
|
4923
|
+
log16("metadata loaded", {
|
|
4878
4924
|
spaces: this._metadataStore.spaces.length
|
|
4879
4925
|
}, {
|
|
4880
|
-
F:
|
|
4881
|
-
L:
|
|
4926
|
+
F: __dxlog_file19,
|
|
4927
|
+
L: 158,
|
|
4882
4928
|
S: this,
|
|
4883
4929
|
C: (f, a) => f(...a)
|
|
4884
4930
|
});
|
|
4885
4931
|
await forEachAsync(this._metadataStore.spaces, async (spaceMetadata) => {
|
|
4886
4932
|
try {
|
|
4887
|
-
|
|
4933
|
+
log16("load space", {
|
|
4888
4934
|
spaceMetadata
|
|
4889
4935
|
}, {
|
|
4890
|
-
F:
|
|
4891
|
-
L:
|
|
4936
|
+
F: __dxlog_file19,
|
|
4937
|
+
L: 162,
|
|
4892
4938
|
S: this,
|
|
4893
4939
|
C: (f, a) => f(...a)
|
|
4894
4940
|
});
|
|
4895
4941
|
await this._constructSpace(spaceMetadata);
|
|
4896
4942
|
} catch (err) {
|
|
4897
|
-
|
|
4943
|
+
log16.error("Error loading space", {
|
|
4898
4944
|
spaceMetadata,
|
|
4899
4945
|
err
|
|
4900
4946
|
}, {
|
|
4901
|
-
F:
|
|
4902
|
-
L:
|
|
4947
|
+
F: __dxlog_file19,
|
|
4948
|
+
L: 165,
|
|
4903
4949
|
S: this,
|
|
4904
4950
|
C: (f, a) => f(...a)
|
|
4905
4951
|
});
|
|
@@ -4907,19 +4953,19 @@ var DataSpaceManager = class {
|
|
|
4907
4953
|
});
|
|
4908
4954
|
this._isOpen = true;
|
|
4909
4955
|
this.updated.emit();
|
|
4910
|
-
|
|
4956
|
+
log16.trace("dxos.echo.data-space-manager.open", Trace2.end({
|
|
4911
4957
|
id: this._instanceId
|
|
4912
4958
|
}), {
|
|
4913
|
-
F:
|
|
4914
|
-
L:
|
|
4959
|
+
F: __dxlog_file19,
|
|
4960
|
+
L: 172,
|
|
4915
4961
|
S: this,
|
|
4916
4962
|
C: (f, a) => f(...a)
|
|
4917
4963
|
});
|
|
4918
4964
|
}
|
|
4919
4965
|
async close() {
|
|
4920
|
-
|
|
4921
|
-
F:
|
|
4922
|
-
L:
|
|
4966
|
+
log16("close", void 0, {
|
|
4967
|
+
F: __dxlog_file19,
|
|
4968
|
+
L: 177,
|
|
4923
4969
|
S: this,
|
|
4924
4970
|
C: (f, a) => f(...a)
|
|
4925
4971
|
});
|
|
@@ -4935,8 +4981,8 @@ var DataSpaceManager = class {
|
|
|
4935
4981
|
*/
|
|
4936
4982
|
async createSpace() {
|
|
4937
4983
|
invariant14(this._isOpen, "Not open.", {
|
|
4938
|
-
F:
|
|
4939
|
-
L:
|
|
4984
|
+
F: __dxlog_file19,
|
|
4985
|
+
L: 191,
|
|
4940
4986
|
S: this,
|
|
4941
4987
|
A: [
|
|
4942
4988
|
"this._isOpen",
|
|
@@ -4953,11 +4999,11 @@ var DataSpaceManager = class {
|
|
|
4953
4999
|
dataFeedKey,
|
|
4954
5000
|
state: SpaceState3.ACTIVE
|
|
4955
5001
|
};
|
|
4956
|
-
|
|
5002
|
+
log16("creating space...", {
|
|
4957
5003
|
spaceKey
|
|
4958
5004
|
}, {
|
|
4959
|
-
F:
|
|
4960
|
-
L:
|
|
5005
|
+
F: __dxlog_file19,
|
|
5006
|
+
L: 203,
|
|
4961
5007
|
S: this,
|
|
4962
5008
|
C: (f, a) => f(...a)
|
|
4963
5009
|
});
|
|
@@ -4968,8 +5014,8 @@ var DataSpaceManager = class {
|
|
|
4968
5014
|
await this._metadataStore.addSpace(metadata);
|
|
4969
5015
|
const memberCredential = credentials[1];
|
|
4970
5016
|
invariant14(getCredentialAssertion3(memberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
|
|
4971
|
-
F:
|
|
4972
|
-
L:
|
|
5017
|
+
F: __dxlog_file19,
|
|
5018
|
+
L: 213,
|
|
4973
5019
|
S: this,
|
|
4974
5020
|
A: [
|
|
4975
5021
|
"getCredentialAssertion(memberCredential)['@type'] === 'dxos.halo.credentials.SpaceMember'",
|
|
@@ -4996,12 +5042,12 @@ var DataSpaceManager = class {
|
|
|
4996
5042
|
return properties?.data?.[DEFAULT_SPACE_KEY] === this._signingContext.identityKey.toHex();
|
|
4997
5043
|
}
|
|
4998
5044
|
default:
|
|
4999
|
-
|
|
5045
|
+
log16.warn("unknown space version", {
|
|
5000
5046
|
version: space.databaseRoot.getVersion(),
|
|
5001
5047
|
spaceId: space.id
|
|
5002
5048
|
}, {
|
|
5003
|
-
F:
|
|
5004
|
-
L:
|
|
5049
|
+
F: __dxlog_file19,
|
|
5050
|
+
L: 238,
|
|
5005
5051
|
S: this,
|
|
5006
5052
|
C: (f, a) => f(...a)
|
|
5007
5053
|
});
|
|
@@ -5035,8 +5081,8 @@ var DataSpaceManager = class {
|
|
|
5035
5081
|
async _getSpaceRootDocument(space) {
|
|
5036
5082
|
const automergeIndex = space.automergeSpaceState.rootUrl;
|
|
5037
5083
|
invariant14(automergeIndex, void 0, {
|
|
5038
|
-
F:
|
|
5039
|
-
L:
|
|
5084
|
+
F: __dxlog_file19,
|
|
5085
|
+
L: 271,
|
|
5040
5086
|
S: this,
|
|
5041
5087
|
A: [
|
|
5042
5088
|
"automergeIndex",
|
|
@@ -5049,17 +5095,17 @@ var DataSpaceManager = class {
|
|
|
5049
5095
|
}
|
|
5050
5096
|
// TODO(burdon): Rename join space.
|
|
5051
5097
|
async acceptSpace(opts) {
|
|
5052
|
-
|
|
5098
|
+
log16("accept space", {
|
|
5053
5099
|
opts
|
|
5054
5100
|
}, {
|
|
5055
|
-
F:
|
|
5056
|
-
L:
|
|
5101
|
+
F: __dxlog_file19,
|
|
5102
|
+
L: 280,
|
|
5057
5103
|
S: this,
|
|
5058
5104
|
C: (f, a) => f(...a)
|
|
5059
5105
|
});
|
|
5060
5106
|
invariant14(this._isOpen, "Not open.", {
|
|
5061
|
-
F:
|
|
5062
|
-
L:
|
|
5107
|
+
F: __dxlog_file19,
|
|
5108
|
+
L: 281,
|
|
5063
5109
|
S: this,
|
|
5064
5110
|
A: [
|
|
5065
5111
|
"this._isOpen",
|
|
@@ -5067,8 +5113,8 @@ var DataSpaceManager = class {
|
|
|
5067
5113
|
]
|
|
5068
5114
|
});
|
|
5069
5115
|
invariant14(!this._spaces.has(opts.spaceKey), "Space already exists.", {
|
|
5070
|
-
F:
|
|
5071
|
-
L:
|
|
5116
|
+
F: __dxlog_file19,
|
|
5117
|
+
L: 282,
|
|
5072
5118
|
S: this,
|
|
5073
5119
|
A: [
|
|
5074
5120
|
"!this._spaces.has(opts.spaceKey)",
|
|
@@ -5088,6 +5134,43 @@ var DataSpaceManager = class {
|
|
|
5088
5134
|
this.updated.emit();
|
|
5089
5135
|
return space;
|
|
5090
5136
|
}
|
|
5137
|
+
async admitMember(options) {
|
|
5138
|
+
const space = this._spaceManager.spaces.get(options.spaceKey);
|
|
5139
|
+
invariant14(space, void 0, {
|
|
5140
|
+
F: __dxlog_file19,
|
|
5141
|
+
L: 302,
|
|
5142
|
+
S: this,
|
|
5143
|
+
A: [
|
|
5144
|
+
"space",
|
|
5145
|
+
""
|
|
5146
|
+
]
|
|
5147
|
+
});
|
|
5148
|
+
if (space.spaceState.getMemberRole(options.identityKey) !== SpaceMember6.Role.REMOVED) {
|
|
5149
|
+
throw new AlreadyJoinedError3();
|
|
5150
|
+
}
|
|
5151
|
+
const credentials = await createAdmissionCredentials(this._signingContext.credentialSigner, options.identityKey, space.key, space.genesisFeedKey, options.role, space.spaceState.membershipChainHeads, options.profile, options.delegationCredentialId);
|
|
5152
|
+
invariant14(credentials[0].credential, void 0, {
|
|
5153
|
+
F: __dxlog_file19,
|
|
5154
|
+
L: 321,
|
|
5155
|
+
S: this,
|
|
5156
|
+
A: [
|
|
5157
|
+
"credentials[0].credential",
|
|
5158
|
+
""
|
|
5159
|
+
]
|
|
5160
|
+
});
|
|
5161
|
+
const spaceMemberCredential = credentials[0].credential.credential;
|
|
5162
|
+
invariant14(getCredentialAssertion3(spaceMemberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
|
|
5163
|
+
F: __dxlog_file19,
|
|
5164
|
+
L: 323,
|
|
5165
|
+
S: this,
|
|
5166
|
+
A: [
|
|
5167
|
+
"getCredentialAssertion(spaceMemberCredential)['@type'] === 'dxos.halo.credentials.SpaceMember'",
|
|
5168
|
+
""
|
|
5169
|
+
]
|
|
5170
|
+
});
|
|
5171
|
+
await writeMessages3(space.controlPipeline.writer, credentials);
|
|
5172
|
+
return spaceMemberCredential;
|
|
5173
|
+
}
|
|
5091
5174
|
/**
|
|
5092
5175
|
* Wait until the space data pipeline is fully initialized.
|
|
5093
5176
|
* Used by invitation handler.
|
|
@@ -5099,12 +5182,24 @@ var DataSpaceManager = class {
|
|
|
5099
5182
|
return !!space && space.state === SpaceState3.READY;
|
|
5100
5183
|
}));
|
|
5101
5184
|
}
|
|
5185
|
+
async requestSpaceAdmissionCredential(spaceKey) {
|
|
5186
|
+
return this._spaceManager.requestSpaceAdmissionCredential({
|
|
5187
|
+
spaceKey,
|
|
5188
|
+
identityKey: this._signingContext.identityKey,
|
|
5189
|
+
timeout: 15e3,
|
|
5190
|
+
swarmIdentity: {
|
|
5191
|
+
peerKey: this._signingContext.deviceKey,
|
|
5192
|
+
credentialProvider: createAuthProvider(this._signingContext.credentialSigner),
|
|
5193
|
+
credentialAuthenticator: async () => true
|
|
5194
|
+
}
|
|
5195
|
+
});
|
|
5196
|
+
}
|
|
5102
5197
|
async _constructSpace(metadata) {
|
|
5103
|
-
|
|
5198
|
+
log16("construct space", {
|
|
5104
5199
|
metadata
|
|
5105
5200
|
}, {
|
|
5106
|
-
F:
|
|
5107
|
-
L:
|
|
5201
|
+
F: __dxlog_file19,
|
|
5202
|
+
L: 358,
|
|
5108
5203
|
S: this,
|
|
5109
5204
|
C: (f, a) => f(...a)
|
|
5110
5205
|
});
|
|
@@ -5132,6 +5227,7 @@ var DataSpaceManager = class {
|
|
|
5132
5227
|
credentialAuthenticator: deferFunction2(() => dataSpace.authVerifier.verifier)
|
|
5133
5228
|
},
|
|
5134
5229
|
onAuthorizedConnection: (session) => {
|
|
5230
|
+
session.addExtension("dxos.mesh.teleport.admission-discovery", new CredentialServerExtension(space));
|
|
5135
5231
|
session.addExtension("dxos.mesh.teleport.gossip", gossip.createExtension({
|
|
5136
5232
|
remotePeerId: session.remotePeerId
|
|
5137
5233
|
}));
|
|
@@ -5140,9 +5236,9 @@ var DataSpaceManager = class {
|
|
|
5140
5236
|
session.addExtension("dxos.mesh.teleport.automerge", this._echoHost.createReplicationExtension());
|
|
5141
5237
|
},
|
|
5142
5238
|
onAuthFailure: () => {
|
|
5143
|
-
|
|
5144
|
-
F:
|
|
5145
|
-
L:
|
|
5239
|
+
log16.warn("auth failure", void 0, {
|
|
5240
|
+
F: __dxlog_file19,
|
|
5241
|
+
L: 396,
|
|
5146
5242
|
S: this,
|
|
5147
5243
|
C: (f, a) => f(...a)
|
|
5148
5244
|
});
|
|
@@ -5171,22 +5267,22 @@ var DataSpaceManager = class {
|
|
|
5171
5267
|
signingContext: this._signingContext,
|
|
5172
5268
|
callbacks: {
|
|
5173
5269
|
beforeReady: async () => {
|
|
5174
|
-
|
|
5270
|
+
log16("before space ready", {
|
|
5175
5271
|
space: space.key
|
|
5176
5272
|
}, {
|
|
5177
|
-
F:
|
|
5178
|
-
L:
|
|
5273
|
+
F: __dxlog_file19,
|
|
5274
|
+
L: 423,
|
|
5179
5275
|
S: this,
|
|
5180
5276
|
C: (f, a) => f(...a)
|
|
5181
5277
|
});
|
|
5182
5278
|
},
|
|
5183
5279
|
afterReady: async () => {
|
|
5184
|
-
|
|
5280
|
+
log16("after space ready", {
|
|
5185
5281
|
space: space.key,
|
|
5186
5282
|
open: this._isOpen
|
|
5187
5283
|
}, {
|
|
5188
|
-
F:
|
|
5189
|
-
L:
|
|
5284
|
+
F: __dxlog_file19,
|
|
5285
|
+
L: 426,
|
|
5190
5286
|
S: this,
|
|
5191
5287
|
C: (f, a) => f(...a)
|
|
5192
5288
|
});
|
|
@@ -5201,11 +5297,11 @@ var DataSpaceManager = class {
|
|
|
5201
5297
|
}
|
|
5202
5298
|
},
|
|
5203
5299
|
beforeClose: async () => {
|
|
5204
|
-
|
|
5300
|
+
log16("before space close", {
|
|
5205
5301
|
space: space.key
|
|
5206
5302
|
}, {
|
|
5207
|
-
F:
|
|
5208
|
-
L:
|
|
5303
|
+
F: __dxlog_file19,
|
|
5304
|
+
L: 434,
|
|
5209
5305
|
S: this,
|
|
5210
5306
|
C: (f, a) => f(...a)
|
|
5211
5307
|
});
|
|
@@ -5236,17 +5332,17 @@ var DataSpaceManager = class {
|
|
|
5236
5332
|
return (s && member.role === SpaceMember6.Role.REMOVED !== (s.authStatus === AuthStatus.FAILURE)) ?? false;
|
|
5237
5333
|
});
|
|
5238
5334
|
sessionsToClose.forEach((session) => {
|
|
5239
|
-
void session.close().catch(
|
|
5335
|
+
void session.close().catch(log16.error);
|
|
5240
5336
|
});
|
|
5241
5337
|
closedSessions += sessionsToClose.length;
|
|
5242
5338
|
}
|
|
5243
|
-
|
|
5339
|
+
log16("processed member role changes", {
|
|
5244
5340
|
roleChangeCount: memberInfo.length,
|
|
5245
5341
|
peersOnline: presence.getPeersOnline().length,
|
|
5246
5342
|
closedSessions
|
|
5247
5343
|
}, {
|
|
5248
|
-
F:
|
|
5249
|
-
L:
|
|
5344
|
+
F: __dxlog_file19,
|
|
5345
|
+
L: 470,
|
|
5250
5346
|
S: this,
|
|
5251
5347
|
C: (f, a) => f(...a)
|
|
5252
5348
|
});
|
|
@@ -5257,15 +5353,15 @@ var DataSpaceManager = class {
|
|
|
5257
5353
|
if (role === SpaceMember6.Role.REMOVED) {
|
|
5258
5354
|
const session = peerState.peerId && space.protocol.sessions.get(peerState.peerId);
|
|
5259
5355
|
if (session != null) {
|
|
5260
|
-
|
|
5356
|
+
log16("closing a session with a removed peer", {
|
|
5261
5357
|
peerId: peerState.peerId
|
|
5262
5358
|
}, {
|
|
5263
|
-
F:
|
|
5264
|
-
L:
|
|
5359
|
+
F: __dxlog_file19,
|
|
5360
|
+
L: 484,
|
|
5265
5361
|
S: this,
|
|
5266
5362
|
C: (f, a) => f(...a)
|
|
5267
5363
|
});
|
|
5268
|
-
void session.close().catch(
|
|
5364
|
+
void session.close().catch(log16.error);
|
|
5269
5365
|
}
|
|
5270
5366
|
}
|
|
5271
5367
|
}
|
|
@@ -5326,13 +5422,13 @@ import { EventSubscriptions as EventSubscriptions2, UpdateScheduler, scheduleTas
|
|
|
5326
5422
|
import { Stream as Stream10 } from "@dxos/codec-protobuf";
|
|
5327
5423
|
import { createAdmissionCredentials as createAdmissionCredentials2, getCredentialAssertion as getCredentialAssertion4 } from "@dxos/credentials";
|
|
5328
5424
|
import { raise as raise2 } from "@dxos/debug";
|
|
5329
|
-
import { writeMessages as
|
|
5425
|
+
import { writeMessages as writeMessages4 } from "@dxos/feed-store";
|
|
5330
5426
|
import { invariant as invariant15 } from "@dxos/invariant";
|
|
5331
|
-
import { log as
|
|
5427
|
+
import { log as log17 } from "@dxos/log";
|
|
5332
5428
|
import { ApiError, SpaceNotFoundError as SpaceNotFoundError2, encodeError, IdentityNotInitializedError, AuthorizationError as AuthorizationError2 } from "@dxos/protocols";
|
|
5333
5429
|
import { SpaceMember as SpaceMember7, SpaceState as SpaceState4 } from "@dxos/protocols/proto/dxos/client/services";
|
|
5334
5430
|
import { trace as trace8 } from "@dxos/tracing";
|
|
5335
|
-
var
|
|
5431
|
+
var __dxlog_file20 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/spaces-service.ts";
|
|
5336
5432
|
var SpacesServiceImpl = class {
|
|
5337
5433
|
constructor(_identityManager, _spaceManager, _getDataSpaceManager) {
|
|
5338
5434
|
this._identityManager = _identityManager;
|
|
@@ -5376,8 +5472,8 @@ var SpacesServiceImpl = class {
|
|
|
5376
5472
|
}
|
|
5377
5473
|
const credentials = await createAdmissionCredentials2(identity.getIdentityCredentialSigner(), request.memberKey, space.key, space.genesisFeedKey, request.newRole, space.spaceState.membershipChainHeads);
|
|
5378
5474
|
invariant15(credentials[0].credential, void 0, {
|
|
5379
|
-
F:
|
|
5380
|
-
L:
|
|
5475
|
+
F: __dxlog_file20,
|
|
5476
|
+
L: 102,
|
|
5381
5477
|
S: this,
|
|
5382
5478
|
A: [
|
|
5383
5479
|
"credentials[0].credential",
|
|
@@ -5386,26 +5482,26 @@ var SpacesServiceImpl = class {
|
|
|
5386
5482
|
});
|
|
5387
5483
|
const spaceMemberCredential = credentials[0].credential.credential;
|
|
5388
5484
|
invariant15(getCredentialAssertion4(spaceMemberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
|
|
5389
|
-
F:
|
|
5390
|
-
L:
|
|
5485
|
+
F: __dxlog_file20,
|
|
5486
|
+
L: 104,
|
|
5391
5487
|
S: this,
|
|
5392
5488
|
A: [
|
|
5393
5489
|
"getCredentialAssertion(spaceMemberCredential)['@type'] === 'dxos.halo.credentials.SpaceMember'",
|
|
5394
5490
|
""
|
|
5395
5491
|
]
|
|
5396
5492
|
});
|
|
5397
|
-
await
|
|
5493
|
+
await writeMessages4(space.controlPipeline.writer, credentials);
|
|
5398
5494
|
}
|
|
5399
5495
|
querySpaces() {
|
|
5400
5496
|
return new Stream10(({ next, ctx }) => {
|
|
5401
5497
|
const scheduler = new UpdateScheduler(ctx, async () => {
|
|
5402
5498
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
5403
5499
|
const spaces = Array.from(dataSpaceManager.spaces.values()).map((space) => this._serializeSpace(space));
|
|
5404
|
-
|
|
5500
|
+
log17("update", {
|
|
5405
5501
|
spaces
|
|
5406
5502
|
}, {
|
|
5407
|
-
F:
|
|
5408
|
-
L:
|
|
5503
|
+
F: __dxlog_file20,
|
|
5504
|
+
L: 115,
|
|
5409
5505
|
S: this,
|
|
5410
5506
|
C: (f, a) => f(...a)
|
|
5411
5507
|
});
|
|
@@ -5423,7 +5519,15 @@ var SpacesServiceImpl = class {
|
|
|
5423
5519
|
const subscribeSpaces = () => {
|
|
5424
5520
|
subscriptions.clear();
|
|
5425
5521
|
for (const space of dataSpaceManager.spaces.values()) {
|
|
5426
|
-
|
|
5522
|
+
let lastState;
|
|
5523
|
+
subscriptions.add(space.stateUpdate.on(ctx, () => {
|
|
5524
|
+
if (space.state !== lastState) {
|
|
5525
|
+
scheduler.forceTrigger();
|
|
5526
|
+
} else {
|
|
5527
|
+
scheduler.trigger();
|
|
5528
|
+
}
|
|
5529
|
+
lastState = space.state;
|
|
5530
|
+
}));
|
|
5427
5531
|
subscriptions.add(space.presence.updated.on(ctx, () => scheduler.trigger()));
|
|
5428
5532
|
subscriptions.add(space.automergeSpaceState.onNewEpoch.on(ctx, () => scheduler.trigger()));
|
|
5429
5533
|
subscriptions.add(space.inner.controlPipeline.state.timeframeUpdate.on(ctx, () => scheduler.trigger()));
|
|
@@ -5488,8 +5592,8 @@ var SpacesServiceImpl = class {
|
|
|
5488
5592
|
});
|
|
5489
5593
|
} else {
|
|
5490
5594
|
invariant15(!credential.id, "Id on unsigned credentials is not allowed", {
|
|
5491
|
-
F:
|
|
5492
|
-
L:
|
|
5595
|
+
F: __dxlog_file20,
|
|
5596
|
+
L: 213,
|
|
5493
5597
|
S: this,
|
|
5494
5598
|
A: [
|
|
5495
5599
|
"!credential.id",
|
|
@@ -5497,8 +5601,8 @@ var SpacesServiceImpl = class {
|
|
|
5497
5601
|
]
|
|
5498
5602
|
});
|
|
5499
5603
|
invariant15(this._identityManager.identity, "Identity is not available", {
|
|
5500
|
-
F:
|
|
5501
|
-
L:
|
|
5604
|
+
F: __dxlog_file20,
|
|
5605
|
+
L: 214,
|
|
5502
5606
|
S: this,
|
|
5503
5607
|
A: [
|
|
5504
5608
|
"this._identityManager.identity",
|
|
@@ -5507,8 +5611,8 @@ var SpacesServiceImpl = class {
|
|
|
5507
5611
|
});
|
|
5508
5612
|
const signer = this._identityManager.identity.getIdentityCredentialSigner();
|
|
5509
5613
|
invariant15(credential.issuer.equals(signer.getIssuer()), void 0, {
|
|
5510
|
-
F:
|
|
5511
|
-
L:
|
|
5614
|
+
F: __dxlog_file20,
|
|
5615
|
+
L: 216,
|
|
5512
5616
|
S: this,
|
|
5513
5617
|
A: [
|
|
5514
5618
|
"credential.issuer.equals(signer.getIssuer())",
|
|
@@ -5538,6 +5642,59 @@ var SpacesServiceImpl = class {
|
|
|
5538
5642
|
epochCredential: credential ?? void 0
|
|
5539
5643
|
};
|
|
5540
5644
|
}
|
|
5645
|
+
async admitContact(request) {
|
|
5646
|
+
const dataSpaceManager = await this._getDataSpaceManager();
|
|
5647
|
+
await dataSpaceManager.admitMember({
|
|
5648
|
+
spaceKey: request.spaceKey,
|
|
5649
|
+
identityKey: request.contact.identityKey,
|
|
5650
|
+
role: request.role
|
|
5651
|
+
});
|
|
5652
|
+
}
|
|
5653
|
+
async joinBySpaceKey({ spaceKey }) {
|
|
5654
|
+
const dataSpaceManager = await this._getDataSpaceManager();
|
|
5655
|
+
const credential = await dataSpaceManager.requestSpaceAdmissionCredential(spaceKey);
|
|
5656
|
+
return this._joinByAdmission({
|
|
5657
|
+
credential
|
|
5658
|
+
});
|
|
5659
|
+
}
|
|
5660
|
+
async _joinByAdmission({ credential }) {
|
|
5661
|
+
const assertion = getCredentialAssertion4(credential);
|
|
5662
|
+
invariant15(assertion["@type"] === "dxos.halo.credentials.SpaceMember", "Invalid credential", {
|
|
5663
|
+
F: __dxlog_file20,
|
|
5664
|
+
L: 250,
|
|
5665
|
+
S: this,
|
|
5666
|
+
A: [
|
|
5667
|
+
"assertion['@type'] === 'dxos.halo.credentials.SpaceMember'",
|
|
5668
|
+
"'Invalid credential'"
|
|
5669
|
+
]
|
|
5670
|
+
});
|
|
5671
|
+
const myIdentity = this._identityManager.identity;
|
|
5672
|
+
invariant15(myIdentity && credential.subject.id.equals(myIdentity.identityKey), void 0, {
|
|
5673
|
+
F: __dxlog_file20,
|
|
5674
|
+
L: 252,
|
|
5675
|
+
S: this,
|
|
5676
|
+
A: [
|
|
5677
|
+
"myIdentity && credential.subject.id.equals(myIdentity.identityKey)",
|
|
5678
|
+
""
|
|
5679
|
+
]
|
|
5680
|
+
});
|
|
5681
|
+
const dataSpaceManager = await this._getDataSpaceManager();
|
|
5682
|
+
let dataSpace = dataSpaceManager.spaces.get(assertion.spaceKey);
|
|
5683
|
+
if (!dataSpace) {
|
|
5684
|
+
dataSpace = await dataSpaceManager.acceptSpace({
|
|
5685
|
+
spaceKey: assertion.spaceKey,
|
|
5686
|
+
genesisFeedKey: assertion.genesisFeedKey
|
|
5687
|
+
});
|
|
5688
|
+
await myIdentity.controlPipeline.writer.write({
|
|
5689
|
+
credential: {
|
|
5690
|
+
credential
|
|
5691
|
+
}
|
|
5692
|
+
});
|
|
5693
|
+
}
|
|
5694
|
+
return {
|
|
5695
|
+
space: this._serializeSpace(dataSpace)
|
|
5696
|
+
};
|
|
5697
|
+
}
|
|
5541
5698
|
_serializeSpace(space) {
|
|
5542
5699
|
return {
|
|
5543
5700
|
id: space.id,
|
|
@@ -5599,7 +5756,7 @@ var SpacesServiceImpl = class {
|
|
|
5599
5756
|
var getChannelId = (channel) => `user-channel/${channel}`;
|
|
5600
5757
|
|
|
5601
5758
|
// packages/sdk/client-services/src/packlets/services/service-context.ts
|
|
5602
|
-
import { Trigger as
|
|
5759
|
+
import { Trigger as Trigger8 } from "@dxos/async";
|
|
5603
5760
|
import { Context as Context10, Resource as Resource3 } from "@dxos/context";
|
|
5604
5761
|
import { getCredentialAssertion as getCredentialAssertion5 } from "@dxos/credentials";
|
|
5605
5762
|
import { failUndefined as failUndefined2 } from "@dxos/debug";
|
|
@@ -5609,7 +5766,7 @@ import { FeedFactory, FeedStore } from "@dxos/feed-store";
|
|
|
5609
5766
|
import { invariant as invariant16 } from "@dxos/invariant";
|
|
5610
5767
|
import { Keyring } from "@dxos/keyring";
|
|
5611
5768
|
import { PublicKey as PublicKey12 } from "@dxos/keys";
|
|
5612
|
-
import { log as
|
|
5769
|
+
import { log as log18 } from "@dxos/log";
|
|
5613
5770
|
import { InvalidStorageVersionError, STORAGE_VERSION as STORAGE_VERSION2, trace as trace9 } from "@dxos/protocols";
|
|
5614
5771
|
import { Invitation as Invitation8 } from "@dxos/protocols/proto/dxos/client/services";
|
|
5615
5772
|
import { BlobStore } from "@dxos/teleport-extension-object-sync";
|
|
@@ -5625,7 +5782,7 @@ function _ts_decorate6(decorators, target, key, desc) {
|
|
|
5625
5782
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5626
5783
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
5627
5784
|
}
|
|
5628
|
-
var
|
|
5785
|
+
var __dxlog_file21 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-context.ts";
|
|
5629
5786
|
var ServiceContext = class extends Resource3 {
|
|
5630
5787
|
constructor(storage, level, networkManager, signalManager, _runtimeParams) {
|
|
5631
5788
|
super();
|
|
@@ -5634,7 +5791,7 @@ var ServiceContext = class extends Resource3 {
|
|
|
5634
5791
|
this.networkManager = networkManager;
|
|
5635
5792
|
this.signalManager = signalManager;
|
|
5636
5793
|
this._runtimeParams = _runtimeParams;
|
|
5637
|
-
this.initialized = new
|
|
5794
|
+
this.initialized = new Trigger8();
|
|
5638
5795
|
this._handlerFactories = /* @__PURE__ */ new Map();
|
|
5639
5796
|
this._instanceId = PublicKey12.random().toHex();
|
|
5640
5797
|
this.metadataStore = new MetadataStore(storage.createDirectory("metadata"));
|
|
@@ -5668,16 +5825,16 @@ var ServiceContext = class extends Resource3 {
|
|
|
5668
5825
|
}
|
|
5669
5826
|
async _open(ctx) {
|
|
5670
5827
|
await this._checkStorageVersion();
|
|
5671
|
-
|
|
5672
|
-
F:
|
|
5828
|
+
log18("opening...", void 0, {
|
|
5829
|
+
F: __dxlog_file21,
|
|
5673
5830
|
L: 149,
|
|
5674
5831
|
S: this,
|
|
5675
5832
|
C: (f, a) => f(...a)
|
|
5676
5833
|
});
|
|
5677
|
-
|
|
5834
|
+
log18.trace("dxos.sdk.service-context.open", trace9.begin({
|
|
5678
5835
|
id: this._instanceId
|
|
5679
5836
|
}), {
|
|
5680
|
-
F:
|
|
5837
|
+
F: __dxlog_file21,
|
|
5681
5838
|
L: 150,
|
|
5682
5839
|
S: this,
|
|
5683
5840
|
C: (f, a) => f(...a)
|
|
@@ -5692,32 +5849,32 @@ var ServiceContext = class extends Resource3 {
|
|
|
5692
5849
|
await this._initialize(ctx);
|
|
5693
5850
|
}
|
|
5694
5851
|
const loadedInvitations = await this.invitationsManager.loadPersistentInvitations();
|
|
5695
|
-
|
|
5852
|
+
log18("loaded persistent invitations", {
|
|
5696
5853
|
count: loadedInvitations.invitations?.length
|
|
5697
5854
|
}, {
|
|
5698
|
-
F:
|
|
5855
|
+
F: __dxlog_file21,
|
|
5699
5856
|
L: 163,
|
|
5700
5857
|
S: this,
|
|
5701
5858
|
C: (f, a) => f(...a)
|
|
5702
5859
|
});
|
|
5703
|
-
|
|
5860
|
+
log18.trace("dxos.sdk.service-context.open", trace9.end({
|
|
5704
5861
|
id: this._instanceId
|
|
5705
5862
|
}), {
|
|
5706
|
-
F:
|
|
5863
|
+
F: __dxlog_file21,
|
|
5707
5864
|
L: 165,
|
|
5708
5865
|
S: this,
|
|
5709
5866
|
C: (f, a) => f(...a)
|
|
5710
5867
|
});
|
|
5711
|
-
|
|
5712
|
-
F:
|
|
5868
|
+
log18("opened", void 0, {
|
|
5869
|
+
F: __dxlog_file21,
|
|
5713
5870
|
L: 166,
|
|
5714
5871
|
S: this,
|
|
5715
5872
|
C: (f, a) => f(...a)
|
|
5716
5873
|
});
|
|
5717
5874
|
}
|
|
5718
5875
|
async _close(ctx) {
|
|
5719
|
-
|
|
5720
|
-
F:
|
|
5876
|
+
log18("closing...", void 0, {
|
|
5877
|
+
F: __dxlog_file21,
|
|
5721
5878
|
L: 170,
|
|
5722
5879
|
S: this,
|
|
5723
5880
|
C: (f, a) => f(...a)
|
|
@@ -5733,8 +5890,8 @@ var ServiceContext = class extends Resource3 {
|
|
|
5733
5890
|
await this.echoHost.close(ctx);
|
|
5734
5891
|
await this.networkManager.close();
|
|
5735
5892
|
await this.signalManager.close();
|
|
5736
|
-
|
|
5737
|
-
F:
|
|
5893
|
+
log18("closed", void 0, {
|
|
5894
|
+
F: __dxlog_file21,
|
|
5738
5895
|
L: 182,
|
|
5739
5896
|
S: this,
|
|
5740
5897
|
C: (f, a) => f(...a)
|
|
@@ -5742,13 +5899,16 @@ var ServiceContext = class extends Resource3 {
|
|
|
5742
5899
|
}
|
|
5743
5900
|
async createIdentity(params = {}) {
|
|
5744
5901
|
const identity = await this.identityManager.createIdentity(params);
|
|
5745
|
-
await this._initialize(new Context10(
|
|
5902
|
+
await this._initialize(new Context10(void 0, {
|
|
5903
|
+
F: __dxlog_file21,
|
|
5904
|
+
L: 187
|
|
5905
|
+
}));
|
|
5746
5906
|
return identity;
|
|
5747
5907
|
}
|
|
5748
5908
|
getInvitationHandler(invitation) {
|
|
5749
5909
|
const factory = this._handlerFactories.get(invitation.kind);
|
|
5750
5910
|
invariant16(factory, `Unknown invitation kind: ${invitation.kind}`, {
|
|
5751
|
-
F:
|
|
5911
|
+
F: __dxlog_file21,
|
|
5752
5912
|
L: 193,
|
|
5753
5913
|
S: this,
|
|
5754
5914
|
A: [
|
|
@@ -5768,7 +5928,10 @@ var ServiceContext = class extends Resource3 {
|
|
|
5768
5928
|
}
|
|
5769
5929
|
async _acceptIdentity(params) {
|
|
5770
5930
|
const identity = await this.identityManager.acceptIdentity(params);
|
|
5771
|
-
await this._initialize(new Context10(
|
|
5931
|
+
await this._initialize(new Context10(void 0, {
|
|
5932
|
+
F: __dxlog_file21,
|
|
5933
|
+
L: 209
|
|
5934
|
+
}));
|
|
5772
5935
|
return identity;
|
|
5773
5936
|
}
|
|
5774
5937
|
async _checkStorageVersion() {
|
|
@@ -5779,8 +5942,8 @@ var ServiceContext = class extends Resource3 {
|
|
|
5779
5942
|
}
|
|
5780
5943
|
// Called when identity is created.
|
|
5781
5944
|
async _initialize(ctx) {
|
|
5782
|
-
|
|
5783
|
-
F:
|
|
5945
|
+
log18("initializing spaces...", void 0, {
|
|
5946
|
+
F: __dxlog_file21,
|
|
5784
5947
|
L: 224,
|
|
5785
5948
|
S: this,
|
|
5786
5949
|
C: (f, a) => f(...a)
|
|
@@ -5803,7 +5966,7 @@ var ServiceContext = class extends Resource3 {
|
|
|
5803
5966
|
await this.dataSpaceManager.open();
|
|
5804
5967
|
this._handlerFactories.set(Invitation8.Kind.SPACE, (invitation) => {
|
|
5805
5968
|
invariant16(this.dataSpaceManager, "dataSpaceManager not initialized yet", {
|
|
5806
|
-
F:
|
|
5969
|
+
F: __dxlog_file21,
|
|
5807
5970
|
L: 249,
|
|
5808
5971
|
S: this,
|
|
5809
5972
|
A: [
|
|
@@ -5824,10 +5987,10 @@ var ServiceContext = class extends Resource3 {
|
|
|
5824
5987
|
return;
|
|
5825
5988
|
}
|
|
5826
5989
|
if (!this.dataSpaceManager) {
|
|
5827
|
-
|
|
5990
|
+
log18("dataSpaceManager not initialized yet, ignoring space admission", {
|
|
5828
5991
|
details: assertion
|
|
5829
5992
|
}, {
|
|
5830
|
-
F:
|
|
5993
|
+
F: __dxlog_file21,
|
|
5831
5994
|
L: 265,
|
|
5832
5995
|
S: this,
|
|
5833
5996
|
C: (f, a) => f(...a)
|
|
@@ -5835,10 +5998,10 @@ var ServiceContext = class extends Resource3 {
|
|
|
5835
5998
|
return;
|
|
5836
5999
|
}
|
|
5837
6000
|
if (this.dataSpaceManager.spaces.has(assertion.spaceKey)) {
|
|
5838
|
-
|
|
6001
|
+
log18("space already exists, ignoring space admission", {
|
|
5839
6002
|
details: assertion
|
|
5840
6003
|
}, {
|
|
5841
|
-
F:
|
|
6004
|
+
F: __dxlog_file21,
|
|
5842
6005
|
L: 269,
|
|
5843
6006
|
S: this,
|
|
5844
6007
|
C: (f, a) => f(...a)
|
|
@@ -5846,10 +6009,10 @@ var ServiceContext = class extends Resource3 {
|
|
|
5846
6009
|
return;
|
|
5847
6010
|
}
|
|
5848
6011
|
try {
|
|
5849
|
-
|
|
6012
|
+
log18("accepting space recorded in halo", {
|
|
5850
6013
|
details: assertion
|
|
5851
6014
|
}, {
|
|
5852
|
-
F:
|
|
6015
|
+
F: __dxlog_file21,
|
|
5853
6016
|
L: 274,
|
|
5854
6017
|
S: this,
|
|
5855
6018
|
C: (f, a) => f(...a)
|
|
@@ -5859,8 +6022,8 @@ var ServiceContext = class extends Resource3 {
|
|
|
5859
6022
|
genesisFeedKey: assertion.genesisFeedKey
|
|
5860
6023
|
});
|
|
5861
6024
|
} catch (err) {
|
|
5862
|
-
|
|
5863
|
-
F:
|
|
6025
|
+
log18.catch(err, void 0, {
|
|
6026
|
+
F: __dxlog_file21,
|
|
5864
6027
|
L: 280,
|
|
5865
6028
|
S: this,
|
|
5866
6029
|
C: (f, a) => f(...a)
|
|
@@ -5907,9 +6070,9 @@ var ServiceRegistry = class {
|
|
|
5907
6070
|
};
|
|
5908
6071
|
|
|
5909
6072
|
// packages/sdk/client-services/src/packlets/locks/browser.ts
|
|
5910
|
-
import { asyncTimeout as asyncTimeout3, Trigger as
|
|
6073
|
+
import { asyncTimeout as asyncTimeout3, Trigger as Trigger9 } from "@dxos/async";
|
|
5911
6074
|
import { RESOURCE_LOCK_TIMEOUT } from "@dxos/client-protocol";
|
|
5912
|
-
import { log as
|
|
6075
|
+
import { log as log19, logInfo } from "@dxos/log";
|
|
5913
6076
|
function _ts_decorate7(decorators, target, key, desc) {
|
|
5914
6077
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
5915
6078
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
@@ -5920,7 +6083,7 @@ function _ts_decorate7(decorators, target, key, desc) {
|
|
|
5920
6083
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5921
6084
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
5922
6085
|
}
|
|
5923
|
-
var
|
|
6086
|
+
var __dxlog_file22 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/locks/browser.ts";
|
|
5924
6087
|
var Message;
|
|
5925
6088
|
(function(Message2) {
|
|
5926
6089
|
Message2["ACQUIRING"] = "acquiring";
|
|
@@ -5928,7 +6091,7 @@ var Message;
|
|
|
5928
6091
|
var Lock = class {
|
|
5929
6092
|
constructor({ lockKey, onAcquire, onRelease }) {
|
|
5930
6093
|
this._broadcastChannel = new BroadcastChannel("vault-resource-lock");
|
|
5931
|
-
this._releaseTrigger = new
|
|
6094
|
+
this._releaseTrigger = new Trigger9();
|
|
5932
6095
|
this._lockKey = lockKey;
|
|
5933
6096
|
this._onAcquire = onAcquire;
|
|
5934
6097
|
this._onRelease = onRelease;
|
|
@@ -5942,29 +6105,29 @@ var Lock = class {
|
|
|
5942
6105
|
message: "acquiring"
|
|
5943
6106
|
});
|
|
5944
6107
|
try {
|
|
5945
|
-
|
|
5946
|
-
F:
|
|
6108
|
+
log19("aquiring lock...", void 0, {
|
|
6109
|
+
F: __dxlog_file22,
|
|
5947
6110
|
L: 42,
|
|
5948
6111
|
S: this,
|
|
5949
6112
|
C: (f, a) => f(...a)
|
|
5950
6113
|
});
|
|
5951
6114
|
await asyncTimeout3(this._requestLock(), RESOURCE_LOCK_TIMEOUT);
|
|
5952
|
-
|
|
5953
|
-
F:
|
|
6115
|
+
log19("acquired lock", void 0, {
|
|
6116
|
+
F: __dxlog_file22,
|
|
5954
6117
|
L: 44,
|
|
5955
6118
|
S: this,
|
|
5956
6119
|
C: (f, a) => f(...a)
|
|
5957
6120
|
});
|
|
5958
6121
|
} catch {
|
|
5959
|
-
|
|
5960
|
-
F:
|
|
6122
|
+
log19("stealing lock...", void 0, {
|
|
6123
|
+
F: __dxlog_file22,
|
|
5961
6124
|
L: 46,
|
|
5962
6125
|
S: this,
|
|
5963
6126
|
C: (f, a) => f(...a)
|
|
5964
6127
|
});
|
|
5965
6128
|
await this._requestLock(true);
|
|
5966
|
-
|
|
5967
|
-
F:
|
|
6129
|
+
log19("stolen lock", void 0, {
|
|
6130
|
+
F: __dxlog_file22,
|
|
5968
6131
|
L: 48,
|
|
5969
6132
|
S: this,
|
|
5970
6133
|
C: (f, a) => f(...a)
|
|
@@ -5980,31 +6143,31 @@ var Lock = class {
|
|
|
5980
6143
|
}
|
|
5981
6144
|
}
|
|
5982
6145
|
async _requestLock(steal = false) {
|
|
5983
|
-
|
|
6146
|
+
log19("requesting lock...", {
|
|
5984
6147
|
steal
|
|
5985
6148
|
}, {
|
|
5986
|
-
F:
|
|
6149
|
+
F: __dxlog_file22,
|
|
5987
6150
|
L: 63,
|
|
5988
6151
|
S: this,
|
|
5989
6152
|
C: (f, a) => f(...a)
|
|
5990
6153
|
});
|
|
5991
|
-
const acquired = new
|
|
6154
|
+
const acquired = new Trigger9();
|
|
5992
6155
|
void navigator.locks.request(this._lockKey, {
|
|
5993
6156
|
steal
|
|
5994
6157
|
}, async () => {
|
|
5995
6158
|
await this._onAcquire?.();
|
|
5996
6159
|
acquired.wake();
|
|
5997
|
-
this._releaseTrigger = new
|
|
6160
|
+
this._releaseTrigger = new Trigger9();
|
|
5998
6161
|
await this._releaseTrigger.wait();
|
|
5999
|
-
|
|
6000
|
-
F:
|
|
6162
|
+
log19("releasing lock...", void 0, {
|
|
6163
|
+
F: __dxlog_file22,
|
|
6001
6164
|
L: 72,
|
|
6002
6165
|
S: this,
|
|
6003
6166
|
C: (f, a) => f(...a)
|
|
6004
6167
|
});
|
|
6005
6168
|
await this._onRelease?.();
|
|
6006
|
-
|
|
6007
|
-
F:
|
|
6169
|
+
log19("released lock", void 0, {
|
|
6170
|
+
F: __dxlog_file22,
|
|
6008
6171
|
L: 74,
|
|
6009
6172
|
S: this,
|
|
6010
6173
|
C: (f, a) => f(...a)
|
|
@@ -6013,10 +6176,10 @@ var Lock = class {
|
|
|
6013
6176
|
await this._onRelease?.();
|
|
6014
6177
|
});
|
|
6015
6178
|
await acquired.wait();
|
|
6016
|
-
|
|
6179
|
+
log19("recieved lock", {
|
|
6017
6180
|
steal
|
|
6018
6181
|
}, {
|
|
6019
|
-
F:
|
|
6182
|
+
F: __dxlog_file22,
|
|
6020
6183
|
L: 81,
|
|
6021
6184
|
S: this,
|
|
6022
6185
|
C: (f, a) => f(...a)
|
|
@@ -6104,13 +6267,151 @@ var createLevel = async (config) => {
|
|
|
6104
6267
|
return level;
|
|
6105
6268
|
};
|
|
6106
6269
|
|
|
6270
|
+
// packages/sdk/client-services/src/packlets/storage/profile-archive.ts
|
|
6271
|
+
import { cbor } from "@dxos/automerge/automerge-repo";
|
|
6272
|
+
import { invariant as invariant17 } from "@dxos/invariant";
|
|
6273
|
+
import { log as log20 } from "@dxos/log";
|
|
6274
|
+
import { ProfileArchiveEntryType } from "@dxos/protocols";
|
|
6275
|
+
import { arrayToBuffer } from "@dxos/util";
|
|
6276
|
+
var __dxlog_file23 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/storage/profile-archive.ts";
|
|
6277
|
+
var encodeProfileArchive = (profile) => cbor.encode(profile);
|
|
6278
|
+
var decodeProfileArchive = (data) => cbor.decode(data);
|
|
6279
|
+
var exportProfileData = async ({ storage, level }) => {
|
|
6280
|
+
const archive = {
|
|
6281
|
+
storage: [],
|
|
6282
|
+
meta: {
|
|
6283
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
6284
|
+
}
|
|
6285
|
+
};
|
|
6286
|
+
{
|
|
6287
|
+
const directory = await storage.createDirectory();
|
|
6288
|
+
const files = await directory.list();
|
|
6289
|
+
log20.info("begin exporting files", {
|
|
6290
|
+
count: files.length
|
|
6291
|
+
}, {
|
|
6292
|
+
F: __dxlog_file23,
|
|
6293
|
+
L: 30,
|
|
6294
|
+
S: void 0,
|
|
6295
|
+
C: (f, a) => f(...a)
|
|
6296
|
+
});
|
|
6297
|
+
for (const filename of files) {
|
|
6298
|
+
const file = await directory.getOrCreateFile(filename);
|
|
6299
|
+
const { size } = await file.stat();
|
|
6300
|
+
const data = await file.read(0, size);
|
|
6301
|
+
archive.storage.push({
|
|
6302
|
+
type: ProfileArchiveEntryType.FILE,
|
|
6303
|
+
key: filename,
|
|
6304
|
+
value: data
|
|
6305
|
+
});
|
|
6306
|
+
}
|
|
6307
|
+
log20.info("done exporting files", {
|
|
6308
|
+
count: files.length
|
|
6309
|
+
}, {
|
|
6310
|
+
F: __dxlog_file23,
|
|
6311
|
+
L: 41,
|
|
6312
|
+
S: void 0,
|
|
6313
|
+
C: (f, a) => f(...a)
|
|
6314
|
+
});
|
|
6315
|
+
}
|
|
6316
|
+
{
|
|
6317
|
+
log20.info("begin exporting kv pairs", void 0, {
|
|
6318
|
+
F: __dxlog_file23,
|
|
6319
|
+
L: 45,
|
|
6320
|
+
S: void 0,
|
|
6321
|
+
C: (f, a) => f(...a)
|
|
6322
|
+
});
|
|
6323
|
+
const iter = await level.iterator({
|
|
6324
|
+
keyEncoding: "binary",
|
|
6325
|
+
valueEncoding: "binary"
|
|
6326
|
+
});
|
|
6327
|
+
let count = 0;
|
|
6328
|
+
for await (const [key, value] of iter) {
|
|
6329
|
+
archive.storage.push({
|
|
6330
|
+
type: ProfileArchiveEntryType.KEY_VALUE,
|
|
6331
|
+
key,
|
|
6332
|
+
value
|
|
6333
|
+
});
|
|
6334
|
+
count++;
|
|
6335
|
+
}
|
|
6336
|
+
log20.info("done exporting kv pairs", {
|
|
6337
|
+
count
|
|
6338
|
+
}, {
|
|
6339
|
+
F: __dxlog_file23,
|
|
6340
|
+
L: 56,
|
|
6341
|
+
S: void 0,
|
|
6342
|
+
C: (f, a) => f(...a)
|
|
6343
|
+
});
|
|
6344
|
+
}
|
|
6345
|
+
return archive;
|
|
6346
|
+
};
|
|
6347
|
+
var importProfileData = async ({ storage, level }, archive) => {
|
|
6348
|
+
const batch = level.batch();
|
|
6349
|
+
for (const entry2 of archive.storage) {
|
|
6350
|
+
switch (entry2.type) {
|
|
6351
|
+
case ProfileArchiveEntryType.FILE: {
|
|
6352
|
+
const directory = await storage.createDirectory();
|
|
6353
|
+
invariant17(typeof entry2.key === "string", "Invalid key type", {
|
|
6354
|
+
F: __dxlog_file23,
|
|
6355
|
+
L: 78,
|
|
6356
|
+
S: void 0,
|
|
6357
|
+
A: [
|
|
6358
|
+
"typeof entry.key === 'string'",
|
|
6359
|
+
"'Invalid key type'"
|
|
6360
|
+
]
|
|
6361
|
+
});
|
|
6362
|
+
const file = await directory.getOrCreateFile(entry2.key);
|
|
6363
|
+
invariant17(entry2.value instanceof Uint8Array, "Invalid value type", {
|
|
6364
|
+
F: __dxlog_file23,
|
|
6365
|
+
L: 80,
|
|
6366
|
+
S: void 0,
|
|
6367
|
+
A: [
|
|
6368
|
+
"entry.value instanceof Uint8Array",
|
|
6369
|
+
"'Invalid value type'"
|
|
6370
|
+
]
|
|
6371
|
+
});
|
|
6372
|
+
await file.write(0, arrayToBuffer(entry2.value));
|
|
6373
|
+
await file.close();
|
|
6374
|
+
break;
|
|
6375
|
+
}
|
|
6376
|
+
case ProfileArchiveEntryType.KEY_VALUE: {
|
|
6377
|
+
invariant17(entry2.key instanceof Uint8Array, "Invalid key type", {
|
|
6378
|
+
F: __dxlog_file23,
|
|
6379
|
+
L: 86,
|
|
6380
|
+
S: void 0,
|
|
6381
|
+
A: [
|
|
6382
|
+
"entry.key instanceof Uint8Array",
|
|
6383
|
+
"'Invalid key type'"
|
|
6384
|
+
]
|
|
6385
|
+
});
|
|
6386
|
+
invariant17(entry2.value instanceof Uint8Array, "Invalid value type", {
|
|
6387
|
+
F: __dxlog_file23,
|
|
6388
|
+
L: 87,
|
|
6389
|
+
S: void 0,
|
|
6390
|
+
A: [
|
|
6391
|
+
"entry.value instanceof Uint8Array",
|
|
6392
|
+
"'Invalid value type'"
|
|
6393
|
+
]
|
|
6394
|
+
});
|
|
6395
|
+
batch.put(entry2.key, entry2.value, {
|
|
6396
|
+
keyEncoding: "binary",
|
|
6397
|
+
valueEncoding: "binary"
|
|
6398
|
+
});
|
|
6399
|
+
break;
|
|
6400
|
+
}
|
|
6401
|
+
default:
|
|
6402
|
+
throw new Error(`Invalid entry type: ${entry2.type}`);
|
|
6403
|
+
}
|
|
6404
|
+
}
|
|
6405
|
+
await batch.write();
|
|
6406
|
+
};
|
|
6407
|
+
|
|
6107
6408
|
// packages/sdk/client-services/src/packlets/services/service-host.ts
|
|
6108
6409
|
import { Event as Event9, synchronized as synchronized3 } from "@dxos/async";
|
|
6109
6410
|
import { clientServiceBundle } from "@dxos/client-protocol";
|
|
6110
6411
|
import { Context as Context11 } from "@dxos/context";
|
|
6111
|
-
import { invariant as
|
|
6112
|
-
import { PublicKey as
|
|
6113
|
-
import { log as
|
|
6412
|
+
import { invariant as invariant19 } from "@dxos/invariant";
|
|
6413
|
+
import { PublicKey as PublicKey17 } from "@dxos/keys";
|
|
6414
|
+
import { log as log22 } from "@dxos/log";
|
|
6114
6415
|
import { WebsocketSignalManager } from "@dxos/messaging";
|
|
6115
6416
|
import { SwarmNetworkManager, createSimplePeerTransportFactory } from "@dxos/network-manager";
|
|
6116
6417
|
import { trace as trace10 } from "@dxos/protocols";
|
|
@@ -6121,9 +6422,9 @@ import { WebsocketRpcClient } from "@dxos/websocket-rpc";
|
|
|
6121
6422
|
// packages/sdk/client-services/src/packlets/devices/devices-service.ts
|
|
6122
6423
|
import { EventSubscriptions as EventSubscriptions3 } from "@dxos/async";
|
|
6123
6424
|
import { Stream as Stream11 } from "@dxos/codec-protobuf";
|
|
6124
|
-
import { invariant as
|
|
6425
|
+
import { invariant as invariant18 } from "@dxos/invariant";
|
|
6125
6426
|
import { Device as Device2, DeviceKind as DeviceKind2 } from "@dxos/protocols/proto/dxos/client/services";
|
|
6126
|
-
var
|
|
6427
|
+
var __dxlog_file24 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/devices/devices-service.ts";
|
|
6127
6428
|
var DevicesServiceImpl = class {
|
|
6128
6429
|
constructor(_identityManager) {
|
|
6129
6430
|
this._identityManager = _identityManager;
|
|
@@ -6140,8 +6441,8 @@ var DevicesServiceImpl = class {
|
|
|
6140
6441
|
devices: []
|
|
6141
6442
|
});
|
|
6142
6443
|
} else {
|
|
6143
|
-
|
|
6144
|
-
F:
|
|
6444
|
+
invariant18(this._identityManager.identity?.presence, "presence not present", {
|
|
6445
|
+
F: __dxlog_file24,
|
|
6145
6446
|
L: 32,
|
|
6146
6447
|
S: this,
|
|
6147
6448
|
A: [
|
|
@@ -6247,28 +6548,111 @@ var findConfigs = () => {
|
|
|
6247
6548
|
return configs.map((r) => r.instance.deref()).filter(nonNullable);
|
|
6248
6549
|
};
|
|
6249
6550
|
|
|
6250
|
-
// packages/sdk/client-services/src/packlets/
|
|
6251
|
-
import {
|
|
6551
|
+
// packages/sdk/client-services/src/packlets/identity/contacts-service.ts
|
|
6552
|
+
import { EventSubscriptions as EventSubscriptions4, scheduleTask as scheduleTask7, UpdateScheduler as UpdateScheduler2 } from "@dxos/async";
|
|
6252
6553
|
import { Stream as Stream12 } from "@dxos/codec-protobuf";
|
|
6253
6554
|
import { PublicKey as PublicKey15 } from "@dxos/keys";
|
|
6254
|
-
import {
|
|
6555
|
+
import { ComplexMap as ComplexMap4, ComplexSet as ComplexSet6 } from "@dxos/util";
|
|
6556
|
+
var ContactsServiceImpl = class {
|
|
6557
|
+
constructor(_identityManager, _spaceManager, _dataSpaceManagerProvider) {
|
|
6558
|
+
this._identityManager = _identityManager;
|
|
6559
|
+
this._spaceManager = _spaceManager;
|
|
6560
|
+
this._dataSpaceManagerProvider = _dataSpaceManagerProvider;
|
|
6561
|
+
}
|
|
6562
|
+
async getContacts() {
|
|
6563
|
+
const identity = this._identityManager.identity;
|
|
6564
|
+
if (identity == null) {
|
|
6565
|
+
return {
|
|
6566
|
+
contacts: []
|
|
6567
|
+
};
|
|
6568
|
+
}
|
|
6569
|
+
const contacts = [
|
|
6570
|
+
...this._spaceManager.spaces.values()
|
|
6571
|
+
].flatMap((s) => [
|
|
6572
|
+
...s.spaceState.members.values()
|
|
6573
|
+
].map((m) => [
|
|
6574
|
+
s.key,
|
|
6575
|
+
m
|
|
6576
|
+
])).reduce((acc, v) => {
|
|
6577
|
+
const [spaceKey, memberInfo] = v;
|
|
6578
|
+
if (memberInfo.key.equals(identity.identityKey)) {
|
|
6579
|
+
return acc;
|
|
6580
|
+
}
|
|
6581
|
+
const existing = acc.get(memberInfo.key);
|
|
6582
|
+
if (existing != null) {
|
|
6583
|
+
existing.profile ??= memberInfo.profile;
|
|
6584
|
+
existing.commonSpaces?.push(spaceKey);
|
|
6585
|
+
} else {
|
|
6586
|
+
acc.set(memberInfo.key, {
|
|
6587
|
+
identityKey: memberInfo.key,
|
|
6588
|
+
profile: memberInfo.profile,
|
|
6589
|
+
commonSpaces: [
|
|
6590
|
+
spaceKey
|
|
6591
|
+
]
|
|
6592
|
+
});
|
|
6593
|
+
}
|
|
6594
|
+
return acc;
|
|
6595
|
+
}, new ComplexMap4(PublicKey15.hash));
|
|
6596
|
+
return {
|
|
6597
|
+
contacts: [
|
|
6598
|
+
...contacts.values()
|
|
6599
|
+
]
|
|
6600
|
+
};
|
|
6601
|
+
}
|
|
6602
|
+
queryContacts() {
|
|
6603
|
+
const subscribedSpaceKeySet = new ComplexSet6(PublicKey15.hash);
|
|
6604
|
+
return new Stream12(({ next, ctx }) => {
|
|
6605
|
+
const pushUpdateTask = new UpdateScheduler2(ctx, async () => {
|
|
6606
|
+
const contacts = await this.getContacts();
|
|
6607
|
+
next(contacts);
|
|
6608
|
+
}, {
|
|
6609
|
+
maxFrequency: 2
|
|
6610
|
+
});
|
|
6611
|
+
scheduleTask7(ctx, async () => {
|
|
6612
|
+
const subscriptions = new EventSubscriptions4();
|
|
6613
|
+
ctx.onDispose(() => subscriptions.clear());
|
|
6614
|
+
const subscribeToSpaceAndUpdate = () => {
|
|
6615
|
+
const oldSetSize = subscribedSpaceKeySet.size;
|
|
6616
|
+
for (const space of this._spaceManager.spaces.values()) {
|
|
6617
|
+
if (!subscribedSpaceKeySet.has(space.key)) {
|
|
6618
|
+
subscriptions.add(space.stateUpdate.on(ctx, () => pushUpdateTask.trigger()));
|
|
6619
|
+
subscribedSpaceKeySet.add(space.key);
|
|
6620
|
+
}
|
|
6621
|
+
}
|
|
6622
|
+
if (oldSetSize !== subscribedSpaceKeySet.size) {
|
|
6623
|
+
pushUpdateTask.trigger();
|
|
6624
|
+
}
|
|
6625
|
+
};
|
|
6626
|
+
const unsubscribe = (await this._dataSpaceManagerProvider()).updated.on(ctx, subscribeToSpaceAndUpdate);
|
|
6627
|
+
ctx.onDispose(unsubscribe);
|
|
6628
|
+
subscribeToSpaceAndUpdate();
|
|
6629
|
+
});
|
|
6630
|
+
});
|
|
6631
|
+
}
|
|
6632
|
+
};
|
|
6633
|
+
|
|
6634
|
+
// packages/sdk/client-services/src/packlets/logging/logging-service.ts
|
|
6635
|
+
import { Event as Event8 } from "@dxos/async";
|
|
6636
|
+
import { Stream as Stream13 } from "@dxos/codec-protobuf";
|
|
6637
|
+
import { PublicKey as PublicKey16 } from "@dxos/keys";
|
|
6638
|
+
import { getContextFromEntry, log as log21 } from "@dxos/log";
|
|
6255
6639
|
import { QueryLogsRequest } from "@dxos/protocols/proto/dxos/client/services";
|
|
6256
6640
|
import { getDebugName, jsonify, numericalValues, tracer } from "@dxos/util";
|
|
6257
6641
|
var LoggingServiceImpl = class {
|
|
6258
6642
|
constructor() {
|
|
6259
6643
|
this._logs = new Event8();
|
|
6260
6644
|
this._started = Date.now();
|
|
6261
|
-
this._sessionId =
|
|
6645
|
+
this._sessionId = PublicKey16.random().toHex();
|
|
6262
6646
|
this._logProcessor = (_config, entry2) => {
|
|
6263
6647
|
this._logs.emit(entry2);
|
|
6264
6648
|
};
|
|
6265
6649
|
}
|
|
6266
6650
|
async open() {
|
|
6267
|
-
|
|
6651
|
+
log21.runtimeConfig.processors.push(this._logProcessor);
|
|
6268
6652
|
}
|
|
6269
6653
|
async close() {
|
|
6270
|
-
const index =
|
|
6271
|
-
|
|
6654
|
+
const index = log21.runtimeConfig.processors.findIndex((processor) => processor === this._logProcessor);
|
|
6655
|
+
log21.runtimeConfig.processors.splice(index, 1);
|
|
6272
6656
|
}
|
|
6273
6657
|
async controlMetrics({ reset, record }) {
|
|
6274
6658
|
if (reset) {
|
|
@@ -6294,7 +6678,7 @@ var LoggingServiceImpl = class {
|
|
|
6294
6678
|
stats: numericalValues(events, "duration")
|
|
6295
6679
|
};
|
|
6296
6680
|
};
|
|
6297
|
-
return new
|
|
6681
|
+
return new Stream13(({ next }) => {
|
|
6298
6682
|
const update = () => {
|
|
6299
6683
|
const metrics = {
|
|
6300
6684
|
timestamp: /* @__PURE__ */ new Date(),
|
|
@@ -6316,7 +6700,7 @@ var LoggingServiceImpl = class {
|
|
|
6316
6700
|
});
|
|
6317
6701
|
}
|
|
6318
6702
|
queryLogs(request) {
|
|
6319
|
-
return new
|
|
6703
|
+
return new Stream13(({ ctx, next }) => {
|
|
6320
6704
|
const handler = (entry2) => {
|
|
6321
6705
|
if (LOG_PROCESSING > 0) {
|
|
6322
6706
|
return;
|
|
@@ -6372,14 +6756,14 @@ var shouldLog = (entry2, request) => {
|
|
|
6372
6756
|
var LOG_PROCESSING = 0;
|
|
6373
6757
|
|
|
6374
6758
|
// packages/sdk/client-services/src/packlets/network/network-service.ts
|
|
6375
|
-
import { Stream as
|
|
6759
|
+
import { Stream as Stream14 } from "@dxos/codec-protobuf";
|
|
6376
6760
|
var NetworkServiceImpl = class {
|
|
6377
6761
|
constructor(networkManager, signalManager) {
|
|
6378
6762
|
this.networkManager = networkManager;
|
|
6379
6763
|
this.signalManager = signalManager;
|
|
6380
6764
|
}
|
|
6381
6765
|
queryStatus() {
|
|
6382
|
-
return new
|
|
6766
|
+
return new Stream14(({ next }) => {
|
|
6383
6767
|
const update = () => {
|
|
6384
6768
|
next({
|
|
6385
6769
|
swarm: this.networkManager.connectionState,
|
|
@@ -6405,7 +6789,7 @@ var NetworkServiceImpl = class {
|
|
|
6405
6789
|
};
|
|
6406
6790
|
|
|
6407
6791
|
// packages/sdk/client-services/src/packlets/system/system-service.ts
|
|
6408
|
-
import { Stream as
|
|
6792
|
+
import { Stream as Stream15 } from "@dxos/codec-protobuf";
|
|
6409
6793
|
import { GetDiagnosticsRequest as GetDiagnosticsRequest2 } from "@dxos/protocols/proto/dxos/client/services";
|
|
6410
6794
|
import { jsonKeyReplacer as jsonKeyReplacer2 } from "@dxos/util";
|
|
6411
6795
|
var SystemServiceImpl = class {
|
|
@@ -6441,7 +6825,7 @@ var SystemServiceImpl = class {
|
|
|
6441
6825
|
}
|
|
6442
6826
|
// TODO(burdon): Standardize interval option in stream request?
|
|
6443
6827
|
queryStatus({ interval = 3e3 } = {}) {
|
|
6444
|
-
return new
|
|
6828
|
+
return new Stream15(({ next }) => {
|
|
6445
6829
|
const update = () => {
|
|
6446
6830
|
next({
|
|
6447
6831
|
status: this._getCurrentStatus()
|
|
@@ -6472,7 +6856,7 @@ function _ts_decorate8(decorators, target, key, desc) {
|
|
|
6472
6856
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6473
6857
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6474
6858
|
}
|
|
6475
|
-
var
|
|
6859
|
+
var __dxlog_file25 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-host.ts";
|
|
6476
6860
|
var ClientServicesHost = class {
|
|
6477
6861
|
constructor({
|
|
6478
6862
|
config,
|
|
@@ -6505,7 +6889,10 @@ var ClientServicesHost = class {
|
|
|
6505
6889
|
lockKey,
|
|
6506
6890
|
onAcquire: () => {
|
|
6507
6891
|
if (!this._opening) {
|
|
6508
|
-
void this.open(new Context11(
|
|
6892
|
+
void this.open(new Context11(void 0, {
|
|
6893
|
+
F: __dxlog_file25,
|
|
6894
|
+
L: 121
|
|
6895
|
+
}));
|
|
6509
6896
|
}
|
|
6510
6897
|
},
|
|
6511
6898
|
onRelease: () => this.close()
|
|
@@ -6560,25 +6947,25 @@ var ClientServicesHost = class {
|
|
|
6560
6947
|
* Can only be called once.
|
|
6561
6948
|
*/
|
|
6562
6949
|
initialize({ config, ...options }) {
|
|
6563
|
-
|
|
6564
|
-
F:
|
|
6565
|
-
L:
|
|
6950
|
+
invariant19(!this._open, "service host is open", {
|
|
6951
|
+
F: __dxlog_file25,
|
|
6952
|
+
L: 187,
|
|
6566
6953
|
S: this,
|
|
6567
6954
|
A: [
|
|
6568
6955
|
"!this._open",
|
|
6569
6956
|
"'service host is open'"
|
|
6570
6957
|
]
|
|
6571
6958
|
});
|
|
6572
|
-
|
|
6573
|
-
F:
|
|
6574
|
-
L:
|
|
6959
|
+
log22("initializing...", void 0, {
|
|
6960
|
+
F: __dxlog_file25,
|
|
6961
|
+
L: 188,
|
|
6575
6962
|
S: this,
|
|
6576
6963
|
C: (f, a) => f(...a)
|
|
6577
6964
|
});
|
|
6578
6965
|
if (config) {
|
|
6579
|
-
|
|
6580
|
-
F:
|
|
6581
|
-
L:
|
|
6966
|
+
invariant19(!this._config, "config already set", {
|
|
6967
|
+
F: __dxlog_file25,
|
|
6968
|
+
L: 191,
|
|
6582
6969
|
S: this,
|
|
6583
6970
|
A: [
|
|
6584
6971
|
"!this._config",
|
|
@@ -6591,9 +6978,9 @@ var ClientServicesHost = class {
|
|
|
6591
6978
|
}
|
|
6592
6979
|
}
|
|
6593
6980
|
if (!options.signalManager) {
|
|
6594
|
-
|
|
6595
|
-
F:
|
|
6596
|
-
L:
|
|
6981
|
+
log22.warn("running signaling without telemetry metadata.", void 0, {
|
|
6982
|
+
F: __dxlog_file25,
|
|
6983
|
+
L: 199,
|
|
6597
6984
|
S: this,
|
|
6598
6985
|
C: (f, a) => f(...a)
|
|
6599
6986
|
});
|
|
@@ -6602,9 +6989,9 @@ var ClientServicesHost = class {
|
|
|
6602
6989
|
iceServers: this._config?.get("runtime.services.ice")
|
|
6603
6990
|
}), signalManager = new WebsocketSignalManager(this._config?.get("runtime.services.signaling") ?? []) } = options;
|
|
6604
6991
|
this._signalManager = signalManager;
|
|
6605
|
-
|
|
6606
|
-
F:
|
|
6607
|
-
L:
|
|
6992
|
+
invariant19(!this._networkManager, "network manager already set", {
|
|
6993
|
+
F: __dxlog_file25,
|
|
6994
|
+
L: 210,
|
|
6608
6995
|
S: this,
|
|
6609
6996
|
A: [
|
|
6610
6997
|
"!this._networkManager",
|
|
@@ -6616,9 +7003,9 @@ var ClientServicesHost = class {
|
|
|
6616
7003
|
transportFactory,
|
|
6617
7004
|
signalManager
|
|
6618
7005
|
});
|
|
6619
|
-
|
|
6620
|
-
F:
|
|
6621
|
-
L:
|
|
7006
|
+
log22("initialized", void 0, {
|
|
7007
|
+
F: __dxlog_file25,
|
|
7008
|
+
L: 217,
|
|
6622
7009
|
S: this,
|
|
6623
7010
|
C: (f, a) => f(...a)
|
|
6624
7011
|
});
|
|
@@ -6627,45 +7014,45 @@ var ClientServicesHost = class {
|
|
|
6627
7014
|
if (this._open) {
|
|
6628
7015
|
return;
|
|
6629
7016
|
}
|
|
6630
|
-
const traceId =
|
|
6631
|
-
|
|
7017
|
+
const traceId = PublicKey17.random().toHex();
|
|
7018
|
+
log22.trace("dxos.client-services.host.open", trace10.begin({
|
|
6632
7019
|
id: traceId
|
|
6633
7020
|
}), {
|
|
6634
|
-
F:
|
|
6635
|
-
L:
|
|
7021
|
+
F: __dxlog_file25,
|
|
7022
|
+
L: 228,
|
|
6636
7023
|
S: this,
|
|
6637
7024
|
C: (f, a) => f(...a)
|
|
6638
7025
|
});
|
|
6639
|
-
|
|
6640
|
-
F:
|
|
6641
|
-
L:
|
|
7026
|
+
invariant19(this._config, "config not set", {
|
|
7027
|
+
F: __dxlog_file25,
|
|
7028
|
+
L: 230,
|
|
6642
7029
|
S: this,
|
|
6643
7030
|
A: [
|
|
6644
7031
|
"this._config",
|
|
6645
7032
|
"'config not set'"
|
|
6646
7033
|
]
|
|
6647
7034
|
});
|
|
6648
|
-
|
|
6649
|
-
F:
|
|
6650
|
-
L:
|
|
7035
|
+
invariant19(this._storage, "storage not set", {
|
|
7036
|
+
F: __dxlog_file25,
|
|
7037
|
+
L: 231,
|
|
6651
7038
|
S: this,
|
|
6652
7039
|
A: [
|
|
6653
7040
|
"this._storage",
|
|
6654
7041
|
"'storage not set'"
|
|
6655
7042
|
]
|
|
6656
7043
|
});
|
|
6657
|
-
|
|
6658
|
-
F:
|
|
6659
|
-
L:
|
|
7044
|
+
invariant19(this._signalManager, "signal manager not set", {
|
|
7045
|
+
F: __dxlog_file25,
|
|
7046
|
+
L: 232,
|
|
6660
7047
|
S: this,
|
|
6661
7048
|
A: [
|
|
6662
7049
|
"this._signalManager",
|
|
6663
7050
|
"'signal manager not set'"
|
|
6664
7051
|
]
|
|
6665
7052
|
});
|
|
6666
|
-
|
|
6667
|
-
F:
|
|
6668
|
-
L:
|
|
7053
|
+
invariant19(this._networkManager, "network manager not set", {
|
|
7054
|
+
F: __dxlog_file25,
|
|
7055
|
+
L: 233,
|
|
6669
7056
|
S: this,
|
|
6670
7057
|
A: [
|
|
6671
7058
|
"this._networkManager",
|
|
@@ -6673,11 +7060,11 @@ var ClientServicesHost = class {
|
|
|
6673
7060
|
]
|
|
6674
7061
|
});
|
|
6675
7062
|
this._opening = true;
|
|
6676
|
-
|
|
7063
|
+
log22("opening...", {
|
|
6677
7064
|
lockKey: this._resourceLock?.lockKey
|
|
6678
7065
|
}, {
|
|
6679
|
-
F:
|
|
6680
|
-
L:
|
|
7066
|
+
F: __dxlog_file25,
|
|
7067
|
+
L: 236,
|
|
6681
7068
|
S: this,
|
|
6682
7069
|
C: (f, a) => f(...a)
|
|
6683
7070
|
});
|
|
@@ -6688,16 +7075,18 @@ var ClientServicesHost = class {
|
|
|
6688
7075
|
await this._level.open();
|
|
6689
7076
|
await this._loggingService.open();
|
|
6690
7077
|
this._serviceContext = new ServiceContext(this._storage, this._level, this._networkManager, this._signalManager, this._runtimeParams);
|
|
7078
|
+
const dataSpaceManagerProvider = async () => {
|
|
7079
|
+
await this._serviceContext.initialized.wait();
|
|
7080
|
+
return this._serviceContext.dataSpaceManager;
|
|
7081
|
+
};
|
|
6691
7082
|
const identityService = new IdentityServiceImpl(this._serviceContext.identityManager, this._serviceContext.keyring, () => this._serviceContext.dataSpaceManager, (params) => this._createIdentity(params), (profile) => this._serviceContext.broadcastProfileUpdate(profile));
|
|
6692
7083
|
this._serviceRegistry.setServices({
|
|
6693
7084
|
SystemService: this._systemService,
|
|
6694
7085
|
IdentityService: identityService,
|
|
7086
|
+
ContactsService: new ContactsServiceImpl(this._serviceContext.identityManager, this._serviceContext.spaceManager, dataSpaceManagerProvider),
|
|
6695
7087
|
InvitationsService: new InvitationsServiceImpl(this._serviceContext.invitationsManager),
|
|
6696
7088
|
DevicesService: new DevicesServiceImpl(this._serviceContext.identityManager),
|
|
6697
|
-
SpacesService: new SpacesServiceImpl(this._serviceContext.identityManager, this._serviceContext.spaceManager,
|
|
6698
|
-
await this._serviceContext.initialized.wait();
|
|
6699
|
-
return this._serviceContext.dataSpaceManager;
|
|
6700
|
-
}),
|
|
7089
|
+
SpacesService: new SpacesServiceImpl(this._serviceContext.identityManager, this._serviceContext.spaceManager, dataSpaceManagerProvider),
|
|
6701
7090
|
DataService: this._serviceContext.echoHost.dataService,
|
|
6702
7091
|
QueryService: this._serviceContext.echoHost.queryService,
|
|
6703
7092
|
NetworkService: new NetworkServiceImpl(this._serviceContext.networkManager, this._serviceContext.signalManager),
|
|
@@ -6727,19 +7116,19 @@ var ClientServicesHost = class {
|
|
|
6727
7116
|
this._open = true;
|
|
6728
7117
|
this._statusUpdate.emit();
|
|
6729
7118
|
const deviceKey = this._serviceContext.identityManager.identity?.deviceKey;
|
|
6730
|
-
|
|
7119
|
+
log22("opened", {
|
|
6731
7120
|
deviceKey
|
|
6732
7121
|
}, {
|
|
6733
|
-
F:
|
|
6734
|
-
L:
|
|
7122
|
+
F: __dxlog_file25,
|
|
7123
|
+
L: 322,
|
|
6735
7124
|
S: this,
|
|
6736
7125
|
C: (f, a) => f(...a)
|
|
6737
7126
|
});
|
|
6738
|
-
|
|
7127
|
+
log22.trace("dxos.client-services.host.open", trace10.end({
|
|
6739
7128
|
id: traceId
|
|
6740
7129
|
}), {
|
|
6741
|
-
F:
|
|
6742
|
-
L:
|
|
7130
|
+
F: __dxlog_file25,
|
|
7131
|
+
L: 323,
|
|
6743
7132
|
S: this,
|
|
6744
7133
|
C: (f, a) => f(...a)
|
|
6745
7134
|
});
|
|
@@ -6749,11 +7138,11 @@ var ClientServicesHost = class {
|
|
|
6749
7138
|
return;
|
|
6750
7139
|
}
|
|
6751
7140
|
const deviceKey = this._serviceContext.identityManager.identity?.deviceKey;
|
|
6752
|
-
|
|
7141
|
+
log22("closing...", {
|
|
6753
7142
|
deviceKey
|
|
6754
7143
|
}, {
|
|
6755
|
-
F:
|
|
6756
|
-
L:
|
|
7144
|
+
F: __dxlog_file25,
|
|
7145
|
+
L: 334,
|
|
6757
7146
|
S: this,
|
|
6758
7147
|
C: (f, a) => f(...a)
|
|
6759
7148
|
});
|
|
@@ -6767,44 +7156,44 @@ var ClientServicesHost = class {
|
|
|
6767
7156
|
await this._level?.close();
|
|
6768
7157
|
this._open = false;
|
|
6769
7158
|
this._statusUpdate.emit();
|
|
6770
|
-
|
|
7159
|
+
log22("closed", {
|
|
6771
7160
|
deviceKey
|
|
6772
7161
|
}, {
|
|
6773
|
-
F:
|
|
6774
|
-
L:
|
|
7162
|
+
F: __dxlog_file25,
|
|
7163
|
+
L: 343,
|
|
6775
7164
|
S: this,
|
|
6776
7165
|
C: (f, a) => f(...a)
|
|
6777
7166
|
});
|
|
6778
7167
|
}
|
|
6779
7168
|
async reset() {
|
|
6780
|
-
const traceId =
|
|
6781
|
-
|
|
7169
|
+
const traceId = PublicKey17.random().toHex();
|
|
7170
|
+
log22.trace("dxos.sdk.client-services-host.reset", trace10.begin({
|
|
6782
7171
|
id: traceId
|
|
6783
7172
|
}), {
|
|
6784
|
-
F:
|
|
6785
|
-
L:
|
|
7173
|
+
F: __dxlog_file25,
|
|
7174
|
+
L: 348,
|
|
6786
7175
|
S: this,
|
|
6787
7176
|
C: (f, a) => f(...a)
|
|
6788
7177
|
});
|
|
6789
|
-
|
|
6790
|
-
F:
|
|
6791
|
-
L:
|
|
7178
|
+
log22.info("resetting...", void 0, {
|
|
7179
|
+
F: __dxlog_file25,
|
|
7180
|
+
L: 350,
|
|
6792
7181
|
S: this,
|
|
6793
7182
|
C: (f, a) => f(...a)
|
|
6794
7183
|
});
|
|
6795
7184
|
await this._serviceContext?.close();
|
|
6796
7185
|
await this._storage.reset();
|
|
6797
|
-
|
|
6798
|
-
F:
|
|
6799
|
-
L:
|
|
7186
|
+
log22.info("reset", void 0, {
|
|
7187
|
+
F: __dxlog_file25,
|
|
7188
|
+
L: 353,
|
|
6800
7189
|
S: this,
|
|
6801
7190
|
C: (f, a) => f(...a)
|
|
6802
7191
|
});
|
|
6803
|
-
|
|
7192
|
+
log22.trace("dxos.sdk.client-services-host.reset", trace10.end({
|
|
6804
7193
|
id: traceId
|
|
6805
7194
|
}), {
|
|
6806
|
-
F:
|
|
6807
|
-
L:
|
|
7195
|
+
F: __dxlog_file25,
|
|
7196
|
+
L: 354,
|
|
6808
7197
|
S: this,
|
|
6809
7198
|
C: (f, a) => f(...a)
|
|
6810
7199
|
});
|
|
@@ -6870,8 +7259,12 @@ export {
|
|
|
6870
7259
|
isLocked,
|
|
6871
7260
|
createStorageObjects,
|
|
6872
7261
|
createLevel,
|
|
7262
|
+
encodeProfileArchive,
|
|
7263
|
+
decodeProfileArchive,
|
|
7264
|
+
exportProfileData,
|
|
7265
|
+
importProfileData,
|
|
6873
7266
|
ClientServicesHost,
|
|
6874
7267
|
ClientServicesProviderResource,
|
|
6875
7268
|
DiagnosticsCollector
|
|
6876
7269
|
};
|
|
6877
|
-
//# sourceMappingURL=chunk-
|
|
7270
|
+
//# sourceMappingURL=chunk-TP67W2QM.mjs.map
|