@dxos/client-services 0.5.9-main.bf0ae3e → 0.5.9-main.bf3bb8f
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-4IR3JP4U.mjs → chunk-IUSAD4RP.mjs} +1405 -824
- package/dist/lib/browser/chunk-IUSAD4RP.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +13 -4
- 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-ZBIDLLZ4.cjs → chunk-5PALJZPW.cjs} +1534 -956
- package/dist/lib/node/chunk-5PALJZPW.cjs.map +7 -0
- package/dist/lib/node/index.cjs +53 -44
- 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/automerge-space-state.d.ts +4 -1
- package/dist/types/src/packlets/spaces/automerge-space-state.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/data-space.d.ts +9 -9
- package/dist/types/src/packlets/spaces/data-space.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/epoch-migrations.d.ts +23 -0
- package/dist/types/src/packlets/spaces/epoch-migrations.d.ts.map +1 -0
- package/dist/types/src/packlets/spaces/spaces-service.d.ts +5 -2
- 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 +45 -13
- 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/automerge-space-state.ts +11 -2
- package/src/packlets/spaces/data-space-manager.ts +90 -16
- package/src/packlets/spaces/data-space.ts +78 -148
- package/src/packlets/spaces/epoch-migrations.ts +154 -0
- package/src/packlets/spaces/spaces-service.ts +56 -4
- package/src/packlets/storage/index.ts +1 -0
- package/src/packlets/storage/profile-archive.ts +111 -0
- package/src/version.ts +1 -1
- package/dist/lib/browser/chunk-4IR3JP4U.mjs.map +0 -7
- package/dist/lib/node/chunk-ZBIDLLZ4.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.bf3bb8f";
|
|
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,20 +1639,50 @@ 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);
|
|
1650
|
+
await Promise.race([
|
|
1651
|
+
space.initializeDataPipeline(),
|
|
1652
|
+
requiresMigration
|
|
1653
|
+
]);
|
|
1628
1654
|
}
|
|
1629
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: 129,
|
|
1662
|
+
S: this,
|
|
1663
|
+
C: (f, a) => f(...a)
|
|
1664
|
+
});
|
|
1665
|
+
return;
|
|
1666
|
+
}
|
|
1667
|
+
foundDefaultSpace = true;
|
|
1630
1668
|
await identity.updateDefaultSpace(space.id);
|
|
1631
|
-
|
|
1632
|
-
|
|
1669
|
+
recodedDefaultSpace = true;
|
|
1670
|
+
recordedDefaultSpaceTrigger.wake();
|
|
1633
1671
|
}
|
|
1634
|
-
}
|
|
1635
|
-
|
|
1672
|
+
}, (err) => {
|
|
1673
|
+
log6.catch(err, void 0, {
|
|
1674
|
+
F: __dxlog_file8,
|
|
1675
|
+
L: 140,
|
|
1676
|
+
S: this,
|
|
1677
|
+
C: (f, a) => f(...a)
|
|
1678
|
+
});
|
|
1679
|
+
});
|
|
1680
|
+
await Promise.race([
|
|
1681
|
+
allProcessed,
|
|
1682
|
+
recordedDefaultSpaceTrigger.wait(),
|
|
1683
|
+
sleep(DEFAULT_SPACE_SEARCH_TIMEOUT)
|
|
1684
|
+
]);
|
|
1685
|
+
if (!recodedDefaultSpace) {
|
|
1636
1686
|
await this._createDefaultSpace(dataSpaceManager);
|
|
1637
1687
|
}
|
|
1638
1688
|
}
|
|
@@ -1642,7 +1692,7 @@ var IdentityServiceImpl = class extends Resource {
|
|
|
1642
1692
|
import { invariant as invariant5 } from "@dxos/invariant";
|
|
1643
1693
|
import { AlreadyJoinedError } from "@dxos/protocols";
|
|
1644
1694
|
import { Invitation } from "@dxos/protocols/proto/dxos/client/services";
|
|
1645
|
-
var
|
|
1695
|
+
var __dxlog_file9 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/device-invitation-protocol.ts";
|
|
1646
1696
|
var DeviceInvitationProtocol = class {
|
|
1647
1697
|
constructor(_keyring, _getIdentity, _acceptIdentity) {
|
|
1648
1698
|
this._keyring = _keyring;
|
|
@@ -1668,7 +1718,7 @@ var DeviceInvitationProtocol = class {
|
|
|
1668
1718
|
}
|
|
1669
1719
|
async admit(_, request) {
|
|
1670
1720
|
invariant5(request.device, void 0, {
|
|
1671
|
-
F:
|
|
1721
|
+
F: __dxlog_file9,
|
|
1672
1722
|
L: 50,
|
|
1673
1723
|
S: this,
|
|
1674
1724
|
A: [
|
|
@@ -1714,7 +1764,7 @@ var DeviceInvitationProtocol = class {
|
|
|
1714
1764
|
}
|
|
1715
1765
|
async accept(response, request) {
|
|
1716
1766
|
invariant5(response.device, void 0, {
|
|
1717
|
-
F:
|
|
1767
|
+
F: __dxlog_file9,
|
|
1718
1768
|
L: 95,
|
|
1719
1769
|
S: this,
|
|
1720
1770
|
A: [
|
|
@@ -1724,7 +1774,7 @@ var DeviceInvitationProtocol = class {
|
|
|
1724
1774
|
});
|
|
1725
1775
|
const { identityKey, haloSpaceKey, genesisFeedKey, controlTimeframe } = response.device;
|
|
1726
1776
|
invariant5(request.device, void 0, {
|
|
1727
|
-
F:
|
|
1777
|
+
F: __dxlog_file9,
|
|
1728
1778
|
L: 98,
|
|
1729
1779
|
S: this,
|
|
1730
1780
|
A: [
|
|
@@ -1756,7 +1806,7 @@ import { ContextDisposedError as ContextDisposedError2 } from "@dxos/context";
|
|
|
1756
1806
|
import { createKeyPair, sign } from "@dxos/crypto";
|
|
1757
1807
|
import { invariant as invariant9 } from "@dxos/invariant";
|
|
1758
1808
|
import { PublicKey as PublicKey7 } from "@dxos/keys";
|
|
1759
|
-
import { log as
|
|
1809
|
+
import { log as log10 } from "@dxos/log";
|
|
1760
1810
|
import { createTeleportProtocolFactory } from "@dxos/network-manager";
|
|
1761
1811
|
import { InvalidInvitationExtensionRoleError as InvalidInvitationExtensionRoleError3, trace as trace5 } from "@dxos/protocols";
|
|
1762
1812
|
import { Invitation as Invitation4 } from "@dxos/protocols/proto/dxos/client/services";
|
|
@@ -1765,10 +1815,10 @@ import { Options as Options4 } from "@dxos/protocols/proto/dxos/halo/invitations
|
|
|
1765
1815
|
import { ComplexSet as ComplexSet3 } from "@dxos/util";
|
|
1766
1816
|
|
|
1767
1817
|
// packages/sdk/client-services/src/packlets/invitations/invitation-guest-extenstion.ts
|
|
1768
|
-
import { Trigger as
|
|
1818
|
+
import { Trigger as Trigger4 } from "@dxos/async";
|
|
1769
1819
|
import { cancelWithContext as cancelWithContext2, Context as Context4 } from "@dxos/context";
|
|
1770
1820
|
import { invariant as invariant6 } from "@dxos/invariant";
|
|
1771
|
-
import { log as
|
|
1821
|
+
import { log as log7 } from "@dxos/log";
|
|
1772
1822
|
import { InvalidInvitationExtensionRoleError, schema as schema2 } from "@dxos/protocols";
|
|
1773
1823
|
import { Options } from "@dxos/protocols/proto/dxos/halo/invitations";
|
|
1774
1824
|
import { RpcExtension } from "@dxos/teleport";
|
|
@@ -1793,7 +1843,7 @@ var tryAcquireBeforeContextDisposed = async (ctx, mutex) => {
|
|
|
1793
1843
|
};
|
|
1794
1844
|
|
|
1795
1845
|
// packages/sdk/client-services/src/packlets/invitations/invitation-guest-extenstion.ts
|
|
1796
|
-
var
|
|
1846
|
+
var __dxlog_file10 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitation-guest-extenstion.ts";
|
|
1797
1847
|
var OPTIONS_TIMEOUT = 1e4;
|
|
1798
1848
|
var InvitationGuestExtension = class extends RpcExtension {
|
|
1799
1849
|
constructor(_invitationFlowMutex, _callbacks) {
|
|
@@ -1807,8 +1857,11 @@ var InvitationGuestExtension = class extends RpcExtension {
|
|
|
1807
1857
|
});
|
|
1808
1858
|
this._invitationFlowMutex = _invitationFlowMutex;
|
|
1809
1859
|
this._callbacks = _callbacks;
|
|
1810
|
-
this._ctx = new Context4(
|
|
1811
|
-
|
|
1860
|
+
this._ctx = new Context4(void 0, {
|
|
1861
|
+
F: __dxlog_file10,
|
|
1862
|
+
L: 33
|
|
1863
|
+
});
|
|
1864
|
+
this._remoteOptionsTrigger = new Trigger4();
|
|
1812
1865
|
this._invitationFlowLock = null;
|
|
1813
1866
|
}
|
|
1814
1867
|
hasFlowLock() {
|
|
@@ -1819,7 +1872,7 @@ var InvitationGuestExtension = class extends RpcExtension {
|
|
|
1819
1872
|
InvitationHostService: {
|
|
1820
1873
|
options: async (options) => {
|
|
1821
1874
|
invariant6(!this._remoteOptions, "Remote options already set.", {
|
|
1822
|
-
F:
|
|
1875
|
+
F: __dxlog_file10,
|
|
1823
1876
|
L: 63,
|
|
1824
1877
|
S: this,
|
|
1825
1878
|
A: [
|
|
@@ -1845,15 +1898,15 @@ var InvitationGuestExtension = class extends RpcExtension {
|
|
|
1845
1898
|
async onOpen(context) {
|
|
1846
1899
|
await super.onOpen(context);
|
|
1847
1900
|
try {
|
|
1848
|
-
|
|
1849
|
-
F:
|
|
1901
|
+
log7("guest acquire lock", void 0, {
|
|
1902
|
+
F: __dxlog_file10,
|
|
1850
1903
|
L: 84,
|
|
1851
1904
|
S: this,
|
|
1852
1905
|
C: (f, a) => f(...a)
|
|
1853
1906
|
});
|
|
1854
1907
|
this._invitationFlowLock = await tryAcquireBeforeContextDisposed(this._ctx, this._invitationFlowMutex);
|
|
1855
|
-
|
|
1856
|
-
F:
|
|
1908
|
+
log7("guest lock acquired", void 0, {
|
|
1909
|
+
F: __dxlog_file10,
|
|
1857
1910
|
L: 86,
|
|
1858
1911
|
S: this,
|
|
1859
1912
|
C: (f, a) => f(...a)
|
|
@@ -1861,8 +1914,8 @@ var InvitationGuestExtension = class extends RpcExtension {
|
|
|
1861
1914
|
await cancelWithContext2(this._ctx, this.rpc.InvitationHostService.options({
|
|
1862
1915
|
role: Options.Role.GUEST
|
|
1863
1916
|
}));
|
|
1864
|
-
|
|
1865
|
-
F:
|
|
1917
|
+
log7("options sent", void 0, {
|
|
1918
|
+
F: __dxlog_file10,
|
|
1866
1919
|
L: 88,
|
|
1867
1920
|
S: this,
|
|
1868
1921
|
C: (f, a) => f(...a)
|
|
@@ -1870,8 +1923,8 @@ var InvitationGuestExtension = class extends RpcExtension {
|
|
|
1870
1923
|
await cancelWithContext2(this._ctx, this._remoteOptionsTrigger.wait({
|
|
1871
1924
|
timeout: OPTIONS_TIMEOUT
|
|
1872
1925
|
}));
|
|
1873
|
-
|
|
1874
|
-
F:
|
|
1926
|
+
log7("options received", void 0, {
|
|
1927
|
+
F: __dxlog_file10,
|
|
1875
1928
|
L: 90,
|
|
1876
1929
|
S: this,
|
|
1877
1930
|
C: (f, a) => f(...a)
|
|
@@ -1904,8 +1957,8 @@ var InvitationGuestExtension = class extends RpcExtension {
|
|
|
1904
1957
|
if (this._invitationFlowLock != null) {
|
|
1905
1958
|
this._invitationFlowLock.release();
|
|
1906
1959
|
this._invitationFlowLock = null;
|
|
1907
|
-
|
|
1908
|
-
F:
|
|
1960
|
+
log7("invitation flow lock released", void 0, {
|
|
1961
|
+
F: __dxlog_file10,
|
|
1909
1962
|
L: 123,
|
|
1910
1963
|
S: this,
|
|
1911
1964
|
C: (f, a) => f(...a)
|
|
@@ -1915,17 +1968,17 @@ var InvitationGuestExtension = class extends RpcExtension {
|
|
|
1915
1968
|
};
|
|
1916
1969
|
|
|
1917
1970
|
// packages/sdk/client-services/src/packlets/invitations/invitation-host-extension.ts
|
|
1918
|
-
import { Trigger as
|
|
1971
|
+
import { Trigger as Trigger5, scheduleTask as scheduleTask2 } from "@dxos/async";
|
|
1919
1972
|
import { cancelWithContext as cancelWithContext3, Context as Context5 } from "@dxos/context";
|
|
1920
1973
|
import { randomBytes, verify } from "@dxos/crypto";
|
|
1921
1974
|
import { invariant as invariant7, InvariantViolation } from "@dxos/invariant";
|
|
1922
1975
|
import { PublicKey as PublicKey5 } from "@dxos/keys";
|
|
1923
|
-
import { log as
|
|
1976
|
+
import { log as log8 } from "@dxos/log";
|
|
1924
1977
|
import { InvalidInvitationExtensionRoleError as InvalidInvitationExtensionRoleError2, schema as schema3, trace as trace4 } from "@dxos/protocols";
|
|
1925
1978
|
import { Invitation as Invitation3 } from "@dxos/protocols/proto/dxos/client/services";
|
|
1926
1979
|
import { AuthenticationResponse, Options as Options2 } from "@dxos/protocols/proto/dxos/halo/invitations";
|
|
1927
1980
|
import { RpcExtension as RpcExtension2 } from "@dxos/teleport";
|
|
1928
|
-
var
|
|
1981
|
+
var __dxlog_file11 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitation-host-extension.ts";
|
|
1929
1982
|
var OPTIONS_TIMEOUT2 = 1e4;
|
|
1930
1983
|
var MAX_OTP_ATTEMPTS = 3;
|
|
1931
1984
|
var InvitationHostExtension = class extends RpcExtension2 {
|
|
@@ -1940,13 +1993,16 @@ var InvitationHostExtension = class extends RpcExtension2 {
|
|
|
1940
1993
|
});
|
|
1941
1994
|
this._invitationFlowMutex = _invitationFlowMutex;
|
|
1942
1995
|
this._callbacks = _callbacks;
|
|
1943
|
-
this._ctx = new Context5(
|
|
1944
|
-
|
|
1996
|
+
this._ctx = new Context5(void 0, {
|
|
1997
|
+
F: __dxlog_file11,
|
|
1998
|
+
L: 52
|
|
1999
|
+
});
|
|
2000
|
+
this._remoteOptionsTrigger = new Trigger5();
|
|
1945
2001
|
this._challenge = void 0;
|
|
1946
2002
|
this.guestProfile = void 0;
|
|
1947
2003
|
this.authenticationPassed = false;
|
|
1948
2004
|
this.authenticationRetry = 0;
|
|
1949
|
-
this.completedTrigger = new
|
|
2005
|
+
this.completedTrigger = new Trigger5();
|
|
1950
2006
|
this._invitationFlowLock = null;
|
|
1951
2007
|
}
|
|
1952
2008
|
hasFlowLock() {
|
|
@@ -1959,7 +2015,7 @@ var InvitationHostExtension = class extends RpcExtension2 {
|
|
|
1959
2015
|
InvitationHostService: {
|
|
1960
2016
|
options: async (options) => {
|
|
1961
2017
|
invariant7(!this._remoteOptions, "Remote options already set.", {
|
|
1962
|
-
F:
|
|
2018
|
+
F: __dxlog_file11,
|
|
1963
2019
|
L: 101,
|
|
1964
2020
|
S: this,
|
|
1965
2021
|
A: [
|
|
@@ -1973,10 +2029,10 @@ var InvitationHostExtension = class extends RpcExtension2 {
|
|
|
1973
2029
|
introduce: async (request) => {
|
|
1974
2030
|
const { profile, invitationId } = request;
|
|
1975
2031
|
const traceId = PublicKey5.random().toHex();
|
|
1976
|
-
|
|
2032
|
+
log8.trace("dxos.sdk.invitation-handler.host.introduce", trace4.begin({
|
|
1977
2033
|
id: traceId
|
|
1978
2034
|
}), {
|
|
1979
|
-
F:
|
|
2035
|
+
F: __dxlog_file11,
|
|
1980
2036
|
L: 110,
|
|
1981
2037
|
S: this,
|
|
1982
2038
|
C: (f, a) => f(...a)
|
|
@@ -1984,11 +2040,11 @@ var InvitationHostExtension = class extends RpcExtension2 {
|
|
|
1984
2040
|
const invitation = this._requireActiveInvitation();
|
|
1985
2041
|
this._assertInvitationState(Invitation3.State.CONNECTED);
|
|
1986
2042
|
if (invitationId !== invitation?.invitationId) {
|
|
1987
|
-
|
|
2043
|
+
log8.warn("incorrect invitationId", {
|
|
1988
2044
|
expected: invitation.invitationId,
|
|
1989
2045
|
actual: invitationId
|
|
1990
2046
|
}, {
|
|
1991
|
-
F:
|
|
2047
|
+
F: __dxlog_file11,
|
|
1992
2048
|
L: 116,
|
|
1993
2049
|
S: this,
|
|
1994
2050
|
C: (f, a) => f(...a)
|
|
@@ -1999,10 +2055,10 @@ var InvitationHostExtension = class extends RpcExtension2 {
|
|
|
1999
2055
|
authMethod: Invitation3.AuthMethod.NONE
|
|
2000
2056
|
};
|
|
2001
2057
|
}
|
|
2002
|
-
|
|
2058
|
+
log8("guest introduced themselves", {
|
|
2003
2059
|
guestProfile: profile
|
|
2004
2060
|
}, {
|
|
2005
|
-
F:
|
|
2061
|
+
F: __dxlog_file11,
|
|
2006
2062
|
L: 125,
|
|
2007
2063
|
S: this,
|
|
2008
2064
|
C: (f, a) => f(...a)
|
|
@@ -2010,10 +2066,10 @@ var InvitationHostExtension = class extends RpcExtension2 {
|
|
|
2010
2066
|
this.guestProfile = profile;
|
|
2011
2067
|
this._callbacks.onStateUpdate(Invitation3.State.READY_FOR_AUTHENTICATION);
|
|
2012
2068
|
this._challenge = invitation.authMethod === Invitation3.AuthMethod.KNOWN_PUBLIC_KEY ? randomBytes(32) : void 0;
|
|
2013
|
-
|
|
2069
|
+
log8.trace("dxos.sdk.invitation-handler.host.introduce", trace4.end({
|
|
2014
2070
|
id: traceId
|
|
2015
2071
|
}), {
|
|
2016
|
-
F:
|
|
2072
|
+
F: __dxlog_file11,
|
|
2017
2073
|
L: 132,
|
|
2018
2074
|
S: this,
|
|
2019
2075
|
C: (f, a) => f(...a)
|
|
@@ -2025,19 +2081,19 @@ var InvitationHostExtension = class extends RpcExtension2 {
|
|
|
2025
2081
|
},
|
|
2026
2082
|
authenticate: async ({ authCode: code, signedChallenge }) => {
|
|
2027
2083
|
const traceId = PublicKey5.random().toHex();
|
|
2028
|
-
|
|
2084
|
+
log8.trace("dxos.sdk.invitation-handler.host.authenticate", trace4.begin({
|
|
2029
2085
|
id: traceId
|
|
2030
2086
|
}), {
|
|
2031
|
-
F:
|
|
2087
|
+
F: __dxlog_file11,
|
|
2032
2088
|
L: 141,
|
|
2033
2089
|
S: this,
|
|
2034
2090
|
C: (f, a) => f(...a)
|
|
2035
2091
|
});
|
|
2036
2092
|
const invitation = this._requireActiveInvitation();
|
|
2037
|
-
|
|
2093
|
+
log8("received authentication request", {
|
|
2038
2094
|
authCode: code
|
|
2039
2095
|
}, {
|
|
2040
|
-
F:
|
|
2096
|
+
F: __dxlog_file11,
|
|
2041
2097
|
L: 144,
|
|
2042
2098
|
S: this,
|
|
2043
2099
|
C: (f, a) => f(...a)
|
|
@@ -2050,8 +2106,8 @@ var InvitationHostExtension = class extends RpcExtension2 {
|
|
|
2050
2106
|
this._callbacks.onStateUpdate(Invitation3.State.AUTHENTICATING);
|
|
2051
2107
|
switch (invitation.authMethod) {
|
|
2052
2108
|
case Invitation3.AuthMethod.NONE: {
|
|
2053
|
-
|
|
2054
|
-
F:
|
|
2109
|
+
log8("authentication not required", void 0, {
|
|
2110
|
+
F: __dxlog_file11,
|
|
2055
2111
|
L: 152,
|
|
2056
2112
|
S: this,
|
|
2057
2113
|
C: (f, a) => f(...a)
|
|
@@ -2086,10 +2142,10 @@ var InvitationHostExtension = class extends RpcExtension2 {
|
|
|
2086
2142
|
break;
|
|
2087
2143
|
}
|
|
2088
2144
|
default: {
|
|
2089
|
-
|
|
2145
|
+
log8.error("invalid authentication method", {
|
|
2090
2146
|
authMethod: invitation.authMethod
|
|
2091
2147
|
}, {
|
|
2092
|
-
F:
|
|
2148
|
+
F: __dxlog_file11,
|
|
2093
2149
|
L: 190,
|
|
2094
2150
|
S: this,
|
|
2095
2151
|
C: (f, a) => f(...a)
|
|
@@ -2108,13 +2164,13 @@ var InvitationHostExtension = class extends RpcExtension2 {
|
|
|
2108
2164
|
status
|
|
2109
2165
|
};
|
|
2110
2166
|
}
|
|
2111
|
-
|
|
2167
|
+
log8.trace("dxos.sdk.invitation-handler.host.authenticate", trace4.end({
|
|
2112
2168
|
id: traceId,
|
|
2113
2169
|
data: {
|
|
2114
2170
|
status
|
|
2115
2171
|
}
|
|
2116
2172
|
}), {
|
|
2117
|
-
F:
|
|
2173
|
+
F: __dxlog_file11,
|
|
2118
2174
|
L: 202,
|
|
2119
2175
|
S: this,
|
|
2120
2176
|
C: (f, a) => f(...a)
|
|
@@ -2125,10 +2181,10 @@ var InvitationHostExtension = class extends RpcExtension2 {
|
|
|
2125
2181
|
},
|
|
2126
2182
|
admit: async (request) => {
|
|
2127
2183
|
const traceId = PublicKey5.random().toHex();
|
|
2128
|
-
|
|
2184
|
+
log8.trace("dxos.sdk.invitation-handler.host.admit", trace4.begin({
|
|
2129
2185
|
id: traceId
|
|
2130
2186
|
}), {
|
|
2131
|
-
F:
|
|
2187
|
+
F: __dxlog_file11,
|
|
2132
2188
|
L: 208,
|
|
2133
2189
|
S: this,
|
|
2134
2190
|
C: (f, a) => f(...a)
|
|
@@ -2142,10 +2198,10 @@ var InvitationHostExtension = class extends RpcExtension2 {
|
|
|
2142
2198
|
}
|
|
2143
2199
|
}
|
|
2144
2200
|
const response = await this._callbacks.admit(request);
|
|
2145
|
-
|
|
2201
|
+
log8.trace("dxos.sdk.invitation-handler.host.admit", trace4.end({
|
|
2146
2202
|
id: traceId
|
|
2147
2203
|
}), {
|
|
2148
|
-
F:
|
|
2204
|
+
F: __dxlog_file11,
|
|
2149
2205
|
L: 222,
|
|
2150
2206
|
S: this,
|
|
2151
2207
|
C: (f, a) => f(...a)
|
|
@@ -2162,15 +2218,15 @@ var InvitationHostExtension = class extends RpcExtension2 {
|
|
|
2162
2218
|
async onOpen(context) {
|
|
2163
2219
|
await super.onOpen(context);
|
|
2164
2220
|
try {
|
|
2165
|
-
|
|
2166
|
-
F:
|
|
2221
|
+
log8("host acquire lock", void 0, {
|
|
2222
|
+
F: __dxlog_file11,
|
|
2167
2223
|
L: 237,
|
|
2168
2224
|
S: this,
|
|
2169
2225
|
C: (f, a) => f(...a)
|
|
2170
2226
|
});
|
|
2171
2227
|
this._invitationFlowLock = await tryAcquireBeforeContextDisposed(this._ctx, this._invitationFlowMutex);
|
|
2172
|
-
|
|
2173
|
-
F:
|
|
2228
|
+
log8("host lock acquired", void 0, {
|
|
2229
|
+
F: __dxlog_file11,
|
|
2174
2230
|
L: 239,
|
|
2175
2231
|
S: this,
|
|
2176
2232
|
C: (f, a) => f(...a)
|
|
@@ -2180,8 +2236,8 @@ var InvitationHostExtension = class extends RpcExtension2 {
|
|
|
2180
2236
|
await this.rpc.InvitationHostService.options({
|
|
2181
2237
|
role: Options2.Role.HOST
|
|
2182
2238
|
});
|
|
2183
|
-
|
|
2184
|
-
F:
|
|
2239
|
+
log8("options sent", void 0, {
|
|
2240
|
+
F: __dxlog_file11,
|
|
2185
2241
|
L: 243,
|
|
2186
2242
|
S: this,
|
|
2187
2243
|
C: (f, a) => f(...a)
|
|
@@ -2189,8 +2245,8 @@ var InvitationHostExtension = class extends RpcExtension2 {
|
|
|
2189
2245
|
await cancelWithContext3(this._ctx, this._remoteOptionsTrigger.wait({
|
|
2190
2246
|
timeout: OPTIONS_TIMEOUT2
|
|
2191
2247
|
}));
|
|
2192
|
-
|
|
2193
|
-
F:
|
|
2248
|
+
log8("options received", void 0, {
|
|
2249
|
+
F: __dxlog_file11,
|
|
2194
2250
|
L: 245,
|
|
2195
2251
|
S: this,
|
|
2196
2252
|
C: (f, a) => f(...a)
|
|
@@ -2243,8 +2299,8 @@ var InvitationHostExtension = class extends RpcExtension2 {
|
|
|
2243
2299
|
if (this._invitationFlowLock != null) {
|
|
2244
2300
|
this._invitationFlowLock?.release();
|
|
2245
2301
|
this._invitationFlowLock = null;
|
|
2246
|
-
|
|
2247
|
-
F:
|
|
2302
|
+
log8("invitation flow lock released", void 0, {
|
|
2303
|
+
F: __dxlog_file11,
|
|
2248
2304
|
L: 300,
|
|
2249
2305
|
S: this,
|
|
2250
2306
|
C: (f, a) => f(...a)
|
|
@@ -2257,10 +2313,10 @@ var isAuthenticationRequired = (invitation) => invitation.authMethod !== Invitat
|
|
|
2257
2313
|
// packages/sdk/client-services/src/packlets/invitations/invitation-topology.ts
|
|
2258
2314
|
import { invariant as invariant8 } from "@dxos/invariant";
|
|
2259
2315
|
import { PublicKey as PublicKey6 } from "@dxos/keys";
|
|
2260
|
-
import { log as
|
|
2316
|
+
import { log as log9 } from "@dxos/log";
|
|
2261
2317
|
import { Options as Options3 } from "@dxos/protocols/proto/dxos/halo/invitations";
|
|
2262
2318
|
import { ComplexSet as ComplexSet2 } from "@dxos/util";
|
|
2263
|
-
var
|
|
2319
|
+
var __dxlog_file12 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitation-topology.ts";
|
|
2264
2320
|
var InvitationTopology = class {
|
|
2265
2321
|
constructor(_role) {
|
|
2266
2322
|
this._role = _role;
|
|
@@ -2268,7 +2324,7 @@ var InvitationTopology = class {
|
|
|
2268
2324
|
}
|
|
2269
2325
|
init(controller) {
|
|
2270
2326
|
invariant8(!this._controller, "Already initialized.", {
|
|
2271
|
-
F:
|
|
2327
|
+
F: __dxlog_file12,
|
|
2272
2328
|
L: 42,
|
|
2273
2329
|
S: this,
|
|
2274
2330
|
A: [
|
|
@@ -2280,7 +2336,7 @@ var InvitationTopology = class {
|
|
|
2280
2336
|
}
|
|
2281
2337
|
update() {
|
|
2282
2338
|
invariant8(this._controller, "Not initialized.", {
|
|
2283
|
-
F:
|
|
2339
|
+
F: __dxlog_file12,
|
|
2284
2340
|
L: 47,
|
|
2285
2341
|
S: this,
|
|
2286
2342
|
A: [
|
|
@@ -2299,11 +2355,11 @@ var InvitationTopology = class {
|
|
|
2299
2355
|
const firstUnknownPeer = candidates.find((peerId) => !this._seenPeers.has(peerId));
|
|
2300
2356
|
this._seenPeers = new ComplexSet2(PublicKey6.hash, allPeers.filter((peerId) => this._seenPeers.has(peerId)));
|
|
2301
2357
|
if (firstUnknownPeer != null) {
|
|
2302
|
-
|
|
2358
|
+
log9("invitation connect", {
|
|
2303
2359
|
ownPeerId,
|
|
2304
2360
|
remotePeerId: firstUnknownPeer
|
|
2305
2361
|
}, {
|
|
2306
|
-
F:
|
|
2362
|
+
F: __dxlog_file12,
|
|
2307
2363
|
L: 69,
|
|
2308
2364
|
S: this,
|
|
2309
2365
|
C: (f, a) => f(...a)
|
|
@@ -2314,7 +2370,7 @@ var InvitationTopology = class {
|
|
|
2314
2370
|
}
|
|
2315
2371
|
async onOffer(peer) {
|
|
2316
2372
|
invariant8(this._controller, "Not initialized.", {
|
|
2317
|
-
F:
|
|
2373
|
+
F: __dxlog_file12,
|
|
2318
2374
|
L: 76,
|
|
2319
2375
|
S: this,
|
|
2320
2376
|
A: [
|
|
@@ -2333,7 +2389,7 @@ var InvitationTopology = class {
|
|
|
2333
2389
|
};
|
|
2334
2390
|
|
|
2335
2391
|
// packages/sdk/client-services/src/packlets/invitations/invitations-handler.ts
|
|
2336
|
-
var
|
|
2392
|
+
var __dxlog_file13 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitations-handler.ts";
|
|
2337
2393
|
var MAX_DELEGATED_INVITATION_HOST_TRIES = 3;
|
|
2338
2394
|
var InvitationsHandler = class {
|
|
2339
2395
|
/**
|
|
@@ -2358,7 +2414,7 @@ var InvitationsHandler = class {
|
|
|
2358
2414
|
try {
|
|
2359
2415
|
const deviceKey = admissionRequest.device?.deviceKey ?? admissionRequest.space?.deviceKey;
|
|
2360
2416
|
invariant9(deviceKey, void 0, {
|
|
2361
|
-
F:
|
|
2417
|
+
F: __dxlog_file13,
|
|
2362
2418
|
L: 90,
|
|
2363
2419
|
S: this,
|
|
2364
2420
|
A: [
|
|
@@ -2384,18 +2440,18 @@ var InvitationsHandler = class {
|
|
|
2384
2440
|
scheduleTask3(connectionCtx, async () => {
|
|
2385
2441
|
const traceId = PublicKey7.random().toHex();
|
|
2386
2442
|
try {
|
|
2387
|
-
|
|
2443
|
+
log10.trace("dxos.sdk.invitations-handler.host.onOpen", trace5.begin({
|
|
2388
2444
|
id: traceId
|
|
2389
2445
|
}), {
|
|
2390
|
-
F:
|
|
2446
|
+
F: __dxlog_file13,
|
|
2391
2447
|
L: 115,
|
|
2392
2448
|
S: this,
|
|
2393
2449
|
C: (f, a) => f(...a)
|
|
2394
2450
|
});
|
|
2395
|
-
|
|
2451
|
+
log10("connected", {
|
|
2396
2452
|
...protocol.toJSON()
|
|
2397
2453
|
}, {
|
|
2398
|
-
F:
|
|
2454
|
+
F: __dxlog_file13,
|
|
2399
2455
|
L: 116,
|
|
2400
2456
|
S: this,
|
|
2401
2457
|
C: (f, a) => f(...a)
|
|
@@ -2403,20 +2459,20 @@ var InvitationsHandler = class {
|
|
|
2403
2459
|
const deviceKey = await extension.completedTrigger.wait({
|
|
2404
2460
|
timeout: invitation.timeout
|
|
2405
2461
|
});
|
|
2406
|
-
|
|
2462
|
+
log10("admitted guest", {
|
|
2407
2463
|
guest: deviceKey,
|
|
2408
2464
|
...protocol.toJSON()
|
|
2409
2465
|
}, {
|
|
2410
|
-
F:
|
|
2466
|
+
F: __dxlog_file13,
|
|
2411
2467
|
L: 118,
|
|
2412
2468
|
S: this,
|
|
2413
2469
|
C: (f, a) => f(...a)
|
|
2414
2470
|
});
|
|
2415
2471
|
guardedState.set(extension, Invitation4.State.SUCCESS);
|
|
2416
|
-
|
|
2472
|
+
log10.trace("dxos.sdk.invitations-handler.host.onOpen", trace5.end({
|
|
2417
2473
|
id: traceId
|
|
2418
2474
|
}), {
|
|
2419
|
-
F:
|
|
2475
|
+
F: __dxlog_file13,
|
|
2420
2476
|
L: 120,
|
|
2421
2477
|
S: this,
|
|
2422
2478
|
C: (f, a) => f(...a)
|
|
@@ -2428,10 +2484,10 @@ var InvitationsHandler = class {
|
|
|
2428
2484
|
} catch (err) {
|
|
2429
2485
|
if (err instanceof TimeoutError) {
|
|
2430
2486
|
if (guardedState.set(extension, Invitation4.State.TIMEOUT)) {
|
|
2431
|
-
|
|
2487
|
+
log10("timeout", {
|
|
2432
2488
|
...protocol.toJSON()
|
|
2433
2489
|
}, {
|
|
2434
|
-
F:
|
|
2490
|
+
F: __dxlog_file13,
|
|
2435
2491
|
L: 129,
|
|
2436
2492
|
S: this,
|
|
2437
2493
|
C: (f, a) => f(...a)
|
|
@@ -2439,19 +2495,19 @@ var InvitationsHandler = class {
|
|
|
2439
2495
|
}
|
|
2440
2496
|
} else {
|
|
2441
2497
|
if (guardedState.error(extension, err)) {
|
|
2442
|
-
|
|
2443
|
-
F:
|
|
2498
|
+
log10.error("failed", err, {
|
|
2499
|
+
F: __dxlog_file13,
|
|
2444
2500
|
L: 133,
|
|
2445
2501
|
S: this,
|
|
2446
2502
|
C: (f, a) => f(...a)
|
|
2447
2503
|
});
|
|
2448
2504
|
}
|
|
2449
2505
|
}
|
|
2450
|
-
|
|
2506
|
+
log10.trace("dxos.sdk.invitations-handler.host.onOpen", trace5.error({
|
|
2451
2507
|
id: traceId,
|
|
2452
2508
|
error: err
|
|
2453
2509
|
}), {
|
|
2454
|
-
F:
|
|
2510
|
+
F: __dxlog_file13,
|
|
2455
2511
|
L: 136,
|
|
2456
2512
|
S: this,
|
|
2457
2513
|
C: (f, a) => f(...a)
|
|
@@ -2462,10 +2518,10 @@ var InvitationsHandler = class {
|
|
|
2462
2518
|
},
|
|
2463
2519
|
onError: (err) => {
|
|
2464
2520
|
if (err instanceof InvalidInvitationExtensionRoleError3) {
|
|
2465
|
-
|
|
2521
|
+
log10("invalid role", {
|
|
2466
2522
|
...err.context
|
|
2467
2523
|
}, {
|
|
2468
|
-
F:
|
|
2524
|
+
F: __dxlog_file13,
|
|
2469
2525
|
L: 144,
|
|
2470
2526
|
S: this,
|
|
2471
2527
|
C: (f, a) => f(...a)
|
|
@@ -2474,10 +2530,10 @@ var InvitationsHandler = class {
|
|
|
2474
2530
|
}
|
|
2475
2531
|
if (err instanceof TimeoutError) {
|
|
2476
2532
|
if (guardedState.set(extension, Invitation4.State.TIMEOUT)) {
|
|
2477
|
-
|
|
2533
|
+
log10("timeout", {
|
|
2478
2534
|
err
|
|
2479
2535
|
}, {
|
|
2480
|
-
F:
|
|
2536
|
+
F: __dxlog_file13,
|
|
2481
2537
|
L: 149,
|
|
2482
2538
|
S: this,
|
|
2483
2539
|
C: (f, a) => f(...a)
|
|
@@ -2485,8 +2541,8 @@ var InvitationsHandler = class {
|
|
|
2485
2541
|
}
|
|
2486
2542
|
} else {
|
|
2487
2543
|
if (guardedState.error(extension, err)) {
|
|
2488
|
-
|
|
2489
|
-
F:
|
|
2544
|
+
log10.error("failed", err, {
|
|
2545
|
+
F: __dxlog_file13,
|
|
2490
2546
|
L: 153,
|
|
2491
2547
|
S: this,
|
|
2492
2548
|
C: (f, a) => f(...a)
|
|
@@ -2499,8 +2555,8 @@ var InvitationsHandler = class {
|
|
|
2499
2555
|
};
|
|
2500
2556
|
if (invitation.lifetime && invitation.created) {
|
|
2501
2557
|
if (invitation.created.getTime() + invitation.lifetime * 1e3 < Date.now()) {
|
|
2502
|
-
|
|
2503
|
-
F:
|
|
2558
|
+
log10.warn("invitation has already expired", void 0, {
|
|
2559
|
+
F: __dxlog_file13,
|
|
2504
2560
|
L: 164,
|
|
2505
2561
|
S: this,
|
|
2506
2562
|
C: (f, a) => f(...a)
|
|
@@ -2523,7 +2579,7 @@ var InvitationsHandler = class {
|
|
|
2523
2579
|
const { timeout = INVITATION_TIMEOUT } = invitation;
|
|
2524
2580
|
if (deviceProfile) {
|
|
2525
2581
|
invariant9(invitation.kind === Invitation4.Kind.DEVICE, "deviceProfile provided for non-device invitation", {
|
|
2526
|
-
F:
|
|
2582
|
+
F: __dxlog_file13,
|
|
2527
2583
|
L: 197,
|
|
2528
2584
|
S: this,
|
|
2529
2585
|
A: [
|
|
@@ -2536,12 +2592,12 @@ var InvitationsHandler = class {
|
|
|
2536
2592
|
const guardedState = this._createGuardedState(ctx, invitation, stream);
|
|
2537
2593
|
const shouldCancelInvitationFlow = (extension) => {
|
|
2538
2594
|
const isLockedByAnotherConnection = guardedState.mutex.isLocked() && !extension.hasFlowLock();
|
|
2539
|
-
|
|
2595
|
+
log10("should cancel invitation flow", {
|
|
2540
2596
|
isLockedByAnotherConnection,
|
|
2541
2597
|
invitationType: Invitation4.Type.DELEGATED,
|
|
2542
2598
|
triedPeers: triedPeersIds.size
|
|
2543
2599
|
}, {
|
|
2544
|
-
F:
|
|
2600
|
+
F: __dxlog_file13,
|
|
2545
2601
|
L: 205,
|
|
2546
2602
|
S: this,
|
|
2547
2603
|
C: (f, a) => f(...a)
|
|
@@ -2564,11 +2620,11 @@ var InvitationsHandler = class {
|
|
|
2564
2620
|
return;
|
|
2565
2621
|
}
|
|
2566
2622
|
connectionCtx.onDispose(async () => {
|
|
2567
|
-
|
|
2623
|
+
log10("extension disposed", {
|
|
2568
2624
|
admitted,
|
|
2569
2625
|
currentState: guardedState.current.state
|
|
2570
2626
|
}, {
|
|
2571
|
-
F:
|
|
2627
|
+
F: __dxlog_file13,
|
|
2572
2628
|
L: 233,
|
|
2573
2629
|
S: this,
|
|
2574
2630
|
C: (f, a) => f(...a)
|
|
@@ -2583,10 +2639,10 @@ var InvitationsHandler = class {
|
|
|
2583
2639
|
scheduleTask3(connectionCtx, async () => {
|
|
2584
2640
|
const traceId = PublicKey7.random().toHex();
|
|
2585
2641
|
try {
|
|
2586
|
-
|
|
2642
|
+
log10.trace("dxos.sdk.invitations-handler.guest.onOpen", trace5.begin({
|
|
2587
2643
|
id: traceId
|
|
2588
2644
|
}), {
|
|
2589
|
-
F:
|
|
2645
|
+
F: __dxlog_file13,
|
|
2590
2646
|
L: 245,
|
|
2591
2647
|
S: this,
|
|
2592
2648
|
C: (f, a) => f(...a)
|
|
@@ -2595,19 +2651,19 @@ var InvitationsHandler = class {
|
|
|
2595
2651
|
guardedState.set(extension, Invitation4.State.TIMEOUT);
|
|
2596
2652
|
extensionCtx.close();
|
|
2597
2653
|
}, timeout);
|
|
2598
|
-
|
|
2654
|
+
log10("connected", {
|
|
2599
2655
|
...protocol.toJSON()
|
|
2600
2656
|
}, {
|
|
2601
|
-
F:
|
|
2657
|
+
F: __dxlog_file13,
|
|
2602
2658
|
L: 256,
|
|
2603
2659
|
S: this,
|
|
2604
2660
|
C: (f, a) => f(...a)
|
|
2605
2661
|
});
|
|
2606
2662
|
guardedState.set(extension, Invitation4.State.CONNECTED);
|
|
2607
|
-
|
|
2663
|
+
log10("introduce", {
|
|
2608
2664
|
...protocol.toJSON()
|
|
2609
2665
|
}, {
|
|
2610
|
-
F:
|
|
2666
|
+
F: __dxlog_file13,
|
|
2611
2667
|
L: 260,
|
|
2612
2668
|
S: this,
|
|
2613
2669
|
C: (f, a) => f(...a)
|
|
@@ -2616,11 +2672,11 @@ var InvitationsHandler = class {
|
|
|
2616
2672
|
invitationId: invitation.invitationId,
|
|
2617
2673
|
...protocol.createIntroduction()
|
|
2618
2674
|
});
|
|
2619
|
-
|
|
2675
|
+
log10("introduce response", {
|
|
2620
2676
|
...protocol.toJSON(),
|
|
2621
2677
|
response: introductionResponse
|
|
2622
2678
|
}, {
|
|
2623
|
-
F:
|
|
2679
|
+
F: __dxlog_file13,
|
|
2624
2680
|
L: 265,
|
|
2625
2681
|
S: this,
|
|
2626
2682
|
C: (f, a) => f(...a)
|
|
@@ -2638,10 +2694,10 @@ var InvitationsHandler = class {
|
|
|
2638
2694
|
break;
|
|
2639
2695
|
}
|
|
2640
2696
|
}
|
|
2641
|
-
|
|
2697
|
+
log10("request admission", {
|
|
2642
2698
|
...protocol.toJSON()
|
|
2643
2699
|
}, {
|
|
2644
|
-
F:
|
|
2700
|
+
F: __dxlog_file13,
|
|
2645
2701
|
L: 291,
|
|
2646
2702
|
S: this,
|
|
2647
2703
|
C: (f, a) => f(...a)
|
|
@@ -2650,10 +2706,10 @@ var InvitationsHandler = class {
|
|
|
2650
2706
|
const admissionResponse = await extension.rpc.InvitationHostService.admit(admissionRequest);
|
|
2651
2707
|
admitted = true;
|
|
2652
2708
|
const result = await protocol.accept(admissionResponse, admissionRequest);
|
|
2653
|
-
|
|
2709
|
+
log10("admitted by host", {
|
|
2654
2710
|
...protocol.toJSON()
|
|
2655
2711
|
}, {
|
|
2656
|
-
F:
|
|
2712
|
+
F: __dxlog_file13,
|
|
2657
2713
|
L: 302,
|
|
2658
2714
|
S: this,
|
|
2659
2715
|
C: (f, a) => f(...a)
|
|
@@ -2663,28 +2719,28 @@ var InvitationsHandler = class {
|
|
|
2663
2719
|
...result,
|
|
2664
2720
|
state: Invitation4.State.SUCCESS
|
|
2665
2721
|
});
|
|
2666
|
-
|
|
2722
|
+
log10.trace("dxos.sdk.invitations-handler.guest.onOpen", trace5.end({
|
|
2667
2723
|
id: traceId
|
|
2668
2724
|
}), {
|
|
2669
|
-
F:
|
|
2725
|
+
F: __dxlog_file13,
|
|
2670
2726
|
L: 308,
|
|
2671
2727
|
S: this,
|
|
2672
2728
|
C: (f, a) => f(...a)
|
|
2673
2729
|
});
|
|
2674
2730
|
} catch (err) {
|
|
2675
2731
|
if (err instanceof TimeoutError) {
|
|
2676
|
-
|
|
2732
|
+
log10("timeout", {
|
|
2677
2733
|
...protocol.toJSON()
|
|
2678
2734
|
}, {
|
|
2679
|
-
F:
|
|
2735
|
+
F: __dxlog_file13,
|
|
2680
2736
|
L: 311,
|
|
2681
2737
|
S: this,
|
|
2682
2738
|
C: (f, a) => f(...a)
|
|
2683
2739
|
});
|
|
2684
2740
|
guardedState.set(extension, Invitation4.State.TIMEOUT);
|
|
2685
2741
|
} else {
|
|
2686
|
-
|
|
2687
|
-
F:
|
|
2742
|
+
log10("auth failed", err, {
|
|
2743
|
+
F: __dxlog_file13,
|
|
2688
2744
|
L: 314,
|
|
2689
2745
|
S: this,
|
|
2690
2746
|
C: (f, a) => f(...a)
|
|
@@ -2692,11 +2748,11 @@ var InvitationsHandler = class {
|
|
|
2692
2748
|
guardedState.error(extension, err);
|
|
2693
2749
|
}
|
|
2694
2750
|
extensionCtx.close(err);
|
|
2695
|
-
|
|
2751
|
+
log10.trace("dxos.sdk.invitations-handler.guest.onOpen", trace5.error({
|
|
2696
2752
|
id: traceId,
|
|
2697
2753
|
error: err
|
|
2698
2754
|
}), {
|
|
2699
|
-
F:
|
|
2755
|
+
F: __dxlog_file13,
|
|
2700
2756
|
L: 318,
|
|
2701
2757
|
S: this,
|
|
2702
2758
|
C: (f, a) => f(...a)
|
|
@@ -2709,18 +2765,18 @@ var InvitationsHandler = class {
|
|
|
2709
2765
|
return;
|
|
2710
2766
|
}
|
|
2711
2767
|
if (err instanceof TimeoutError) {
|
|
2712
|
-
|
|
2768
|
+
log10("timeout", {
|
|
2713
2769
|
...protocol.toJSON()
|
|
2714
2770
|
}, {
|
|
2715
|
-
F:
|
|
2771
|
+
F: __dxlog_file13,
|
|
2716
2772
|
L: 327,
|
|
2717
2773
|
S: this,
|
|
2718
2774
|
C: (f, a) => f(...a)
|
|
2719
2775
|
});
|
|
2720
2776
|
guardedState.set(extension, Invitation4.State.TIMEOUT);
|
|
2721
2777
|
} else {
|
|
2722
|
-
|
|
2723
|
-
F:
|
|
2778
|
+
log10("auth failed", err, {
|
|
2779
|
+
F: __dxlog_file13,
|
|
2724
2780
|
L: 330,
|
|
2725
2781
|
S: this,
|
|
2726
2782
|
C: (f, a) => f(...a)
|
|
@@ -2738,7 +2794,7 @@ var InvitationsHandler = class {
|
|
|
2738
2794
|
await ctx.dispose();
|
|
2739
2795
|
} else {
|
|
2740
2796
|
invariant9(invitation.swarmKey, void 0, {
|
|
2741
|
-
F:
|
|
2797
|
+
F: __dxlog_file13,
|
|
2742
2798
|
L: 345,
|
|
2743
2799
|
S: this,
|
|
2744
2800
|
A: [
|
|
@@ -2832,16 +2888,29 @@ var InvitationsHandler = class {
|
|
|
2832
2888
|
};
|
|
2833
2889
|
}
|
|
2834
2890
|
_logStateUpdate(invitation, actor, newState) {
|
|
2835
|
-
|
|
2836
|
-
|
|
2837
|
-
|
|
2838
|
-
|
|
2839
|
-
|
|
2840
|
-
|
|
2841
|
-
|
|
2842
|
-
|
|
2843
|
-
|
|
2844
|
-
|
|
2891
|
+
if (this._isNotTerminal(newState)) {
|
|
2892
|
+
log10("invitation state update", {
|
|
2893
|
+
actor: actor?.constructor.name,
|
|
2894
|
+
newState: stateToString(newState),
|
|
2895
|
+
oldState: stateToString(invitation.state)
|
|
2896
|
+
}, {
|
|
2897
|
+
F: __dxlog_file13,
|
|
2898
|
+
L: 439,
|
|
2899
|
+
S: this,
|
|
2900
|
+
C: (f, a) => f(...a)
|
|
2901
|
+
});
|
|
2902
|
+
} else {
|
|
2903
|
+
log10.info("invitation state update", {
|
|
2904
|
+
actor: actor?.constructor.name,
|
|
2905
|
+
newState: stateToString(newState),
|
|
2906
|
+
oldState: stateToString(invitation.state)
|
|
2907
|
+
}, {
|
|
2908
|
+
F: __dxlog_file13,
|
|
2909
|
+
L: 445,
|
|
2910
|
+
S: this,
|
|
2911
|
+
C: (f, a) => f(...a)
|
|
2912
|
+
});
|
|
2913
|
+
}
|
|
2845
2914
|
}
|
|
2846
2915
|
_isNotTerminal(currentState) {
|
|
2847
2916
|
return ![
|
|
@@ -2854,17 +2923,17 @@ var InvitationsHandler = class {
|
|
|
2854
2923
|
}
|
|
2855
2924
|
async _handleGuestOtpAuth(extension, setState, authenticated, options) {
|
|
2856
2925
|
for (let attempt = 1; attempt <= MAX_OTP_ATTEMPTS; attempt++) {
|
|
2857
|
-
|
|
2858
|
-
F:
|
|
2859
|
-
L:
|
|
2926
|
+
log10("guest waiting for authentication code...", void 0, {
|
|
2927
|
+
F: __dxlog_file13,
|
|
2928
|
+
L: 470,
|
|
2860
2929
|
S: this,
|
|
2861
2930
|
C: (f, a) => f(...a)
|
|
2862
2931
|
});
|
|
2863
2932
|
setState(Invitation4.State.READY_FOR_AUTHENTICATION);
|
|
2864
2933
|
const authCode = await authenticated.wait(options);
|
|
2865
|
-
|
|
2866
|
-
F:
|
|
2867
|
-
L:
|
|
2934
|
+
log10("sending authentication request", void 0, {
|
|
2935
|
+
F: __dxlog_file13,
|
|
2936
|
+
L: 474,
|
|
2868
2937
|
S: this,
|
|
2869
2938
|
C: (f, a) => f(...a)
|
|
2870
2939
|
});
|
|
@@ -2879,11 +2948,11 @@ var InvitationsHandler = class {
|
|
|
2879
2948
|
if (attempt === MAX_OTP_ATTEMPTS) {
|
|
2880
2949
|
throw new Error(`Maximum retry attempts: ${MAX_OTP_ATTEMPTS}`);
|
|
2881
2950
|
} else {
|
|
2882
|
-
|
|
2951
|
+
log10("retrying invalid code", {
|
|
2883
2952
|
attempt
|
|
2884
2953
|
}, {
|
|
2885
|
-
F:
|
|
2886
|
-
L:
|
|
2954
|
+
F: __dxlog_file13,
|
|
2955
|
+
L: 485,
|
|
2887
2956
|
S: this,
|
|
2888
2957
|
C: (f, a) => f(...a)
|
|
2889
2958
|
});
|
|
@@ -2899,9 +2968,9 @@ var InvitationsHandler = class {
|
|
|
2899
2968
|
if (introductionResponse.challenge == null) {
|
|
2900
2969
|
throw new Error("challenge missing in the introduction");
|
|
2901
2970
|
}
|
|
2902
|
-
|
|
2903
|
-
F:
|
|
2904
|
-
L:
|
|
2971
|
+
log10("sending authentication request", void 0, {
|
|
2972
|
+
F: __dxlog_file13,
|
|
2973
|
+
L: 504,
|
|
2905
2974
|
S: this,
|
|
2906
2975
|
C: (f, a) => f(...a)
|
|
2907
2976
|
});
|
|
@@ -3021,14 +3090,14 @@ var InvitationsServiceImpl = class {
|
|
|
3021
3090
|
};
|
|
3022
3091
|
|
|
3023
3092
|
// packages/sdk/client-services/src/packlets/invitations/space-invitation-protocol.ts
|
|
3024
|
-
import {
|
|
3093
|
+
import { createCancelDelegatedSpaceInvitationCredential, createDelegatedSpaceInvitationCredential, getCredentialAssertion as getCredentialAssertion2 } from "@dxos/credentials";
|
|
3025
3094
|
import { writeMessages as writeMessages2 } from "@dxos/feed-store";
|
|
3026
3095
|
import { invariant as invariant10 } from "@dxos/invariant";
|
|
3027
|
-
import { log as
|
|
3096
|
+
import { log as log11 } from "@dxos/log";
|
|
3028
3097
|
import { AlreadyJoinedError as AlreadyJoinedError2, AuthorizationError, InvalidInvitationError, SpaceNotFoundError } from "@dxos/protocols";
|
|
3029
3098
|
import { Invitation as Invitation5 } from "@dxos/protocols/proto/dxos/client/services";
|
|
3030
3099
|
import { SpaceMember as SpaceMember2 } from "@dxos/protocols/proto/dxos/halo/credentials";
|
|
3031
|
-
var
|
|
3100
|
+
var __dxlog_file14 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/space-invitation-protocol.ts";
|
|
3032
3101
|
var SpaceInvitationProtocol = class {
|
|
3033
3102
|
constructor(_spaceManager, _signingContext, _keyring, _spaceKey) {
|
|
3034
3103
|
this._spaceManager = _spaceManager;
|
|
@@ -3062,79 +3131,43 @@ var SpaceInvitationProtocol = class {
|
|
|
3062
3131
|
};
|
|
3063
3132
|
}
|
|
3064
3133
|
async admit(invitation, request, guestProfile) {
|
|
3065
|
-
invariant10(this._spaceKey, void 0, {
|
|
3066
|
-
F:
|
|
3067
|
-
L:
|
|
3068
|
-
S: this,
|
|
3069
|
-
A: [
|
|
3070
|
-
"this._spaceKey",
|
|
3071
|
-
""
|
|
3072
|
-
]
|
|
3073
|
-
});
|
|
3074
|
-
const space = this._spaceManager.spaces.get(this._spaceKey);
|
|
3075
|
-
invariant10(space, void 0, {
|
|
3076
|
-
F: __dxlog_file13,
|
|
3077
|
-
L: 78,
|
|
3078
|
-
S: this,
|
|
3079
|
-
A: [
|
|
3080
|
-
"space",
|
|
3081
|
-
""
|
|
3082
|
-
]
|
|
3083
|
-
});
|
|
3084
|
-
invariant10(request.space, void 0, {
|
|
3085
|
-
F: __dxlog_file13,
|
|
3086
|
-
L: 80,
|
|
3134
|
+
invariant10(this._spaceKey && request.space, void 0, {
|
|
3135
|
+
F: __dxlog_file14,
|
|
3136
|
+
L: 74,
|
|
3087
3137
|
S: this,
|
|
3088
3138
|
A: [
|
|
3089
|
-
"request.space",
|
|
3139
|
+
"this._spaceKey && request.space",
|
|
3090
3140
|
""
|
|
3091
3141
|
]
|
|
3092
3142
|
});
|
|
3093
|
-
|
|
3094
|
-
if (space.inner.spaceState.getMemberRole(identityKey) !== SpaceMember2.Role.REMOVED) {
|
|
3095
|
-
throw new AlreadyJoinedError2();
|
|
3096
|
-
}
|
|
3097
|
-
log10("writing guest credentials", {
|
|
3143
|
+
log11("writing guest credentials", {
|
|
3098
3144
|
host: this._signingContext.deviceKey,
|
|
3099
|
-
guest: deviceKey
|
|
3145
|
+
guest: request.space.deviceKey
|
|
3100
3146
|
}, {
|
|
3101
|
-
F:
|
|
3102
|
-
L:
|
|
3147
|
+
F: __dxlog_file14,
|
|
3148
|
+
L: 75,
|
|
3103
3149
|
S: this,
|
|
3104
3150
|
C: (f, a) => f(...a)
|
|
3105
3151
|
});
|
|
3106
|
-
const
|
|
3107
|
-
|
|
3108
|
-
|
|
3109
|
-
|
|
3110
|
-
|
|
3111
|
-
|
|
3112
|
-
"credentials[0].credential",
|
|
3113
|
-
""
|
|
3114
|
-
]
|
|
3115
|
-
});
|
|
3116
|
-
const spaceMemberCredential = credentials[0].credential.credential;
|
|
3117
|
-
invariant10(getCredentialAssertion2(spaceMemberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
|
|
3118
|
-
F: __dxlog_file13,
|
|
3119
|
-
L: 103,
|
|
3120
|
-
S: this,
|
|
3121
|
-
A: [
|
|
3122
|
-
"getCredentialAssertion(spaceMemberCredential)['@type'] === 'dxos.halo.credentials.SpaceMember'",
|
|
3123
|
-
""
|
|
3124
|
-
]
|
|
3152
|
+
const spaceMemberCredential = await this._spaceManager.admitMember({
|
|
3153
|
+
spaceKey: this._spaceKey,
|
|
3154
|
+
identityKey: request.space.identityKey,
|
|
3155
|
+
role: invitation.role ?? SpaceMember2.Role.ADMIN,
|
|
3156
|
+
profile: guestProfile,
|
|
3157
|
+
delegationCredentialId: invitation.delegationCredentialId
|
|
3125
3158
|
});
|
|
3126
|
-
|
|
3159
|
+
const space = this._spaceManager.spaces.get(this._spaceKey);
|
|
3127
3160
|
return {
|
|
3128
3161
|
space: {
|
|
3129
3162
|
credential: spaceMemberCredential,
|
|
3130
|
-
controlTimeframe: space
|
|
3163
|
+
controlTimeframe: space?.inner.controlPipeline.state.timeframe
|
|
3131
3164
|
}
|
|
3132
3165
|
};
|
|
3133
3166
|
}
|
|
3134
3167
|
async delegate(invitation) {
|
|
3135
3168
|
invariant10(this._spaceKey, void 0, {
|
|
3136
|
-
F:
|
|
3137
|
-
L:
|
|
3169
|
+
F: __dxlog_file14,
|
|
3170
|
+
L: 95,
|
|
3138
3171
|
S: this,
|
|
3139
3172
|
A: [
|
|
3140
3173
|
"this._spaceKey",
|
|
@@ -3143,8 +3176,8 @@ var SpaceInvitationProtocol = class {
|
|
|
3143
3176
|
});
|
|
3144
3177
|
const space = this._spaceManager.spaces.get(this._spaceKey);
|
|
3145
3178
|
invariant10(space, void 0, {
|
|
3146
|
-
F:
|
|
3147
|
-
L:
|
|
3179
|
+
F: __dxlog_file14,
|
|
3180
|
+
L: 97,
|
|
3148
3181
|
S: this,
|
|
3149
3182
|
A: [
|
|
3150
3183
|
"space",
|
|
@@ -3153,8 +3186,8 @@ var SpaceInvitationProtocol = class {
|
|
|
3153
3186
|
});
|
|
3154
3187
|
if (invitation.authMethod === Invitation5.AuthMethod.KNOWN_PUBLIC_KEY) {
|
|
3155
3188
|
invariant10(invitation.guestKeypair?.publicKey, void 0, {
|
|
3156
|
-
F:
|
|
3157
|
-
L:
|
|
3189
|
+
F: __dxlog_file14,
|
|
3190
|
+
L: 99,
|
|
3158
3191
|
S: this,
|
|
3159
3192
|
A: [
|
|
3160
3193
|
"invitation.guestKeypair?.publicKey",
|
|
@@ -3162,12 +3195,12 @@ var SpaceInvitationProtocol = class {
|
|
|
3162
3195
|
]
|
|
3163
3196
|
});
|
|
3164
3197
|
}
|
|
3165
|
-
|
|
3198
|
+
log11("writing delegate space invitation", {
|
|
3166
3199
|
host: this._signingContext.deviceKey,
|
|
3167
3200
|
id: invitation.invitationId
|
|
3168
3201
|
}, {
|
|
3169
|
-
F:
|
|
3170
|
-
L:
|
|
3202
|
+
F: __dxlog_file14,
|
|
3203
|
+
L: 102,
|
|
3171
3204
|
S: this,
|
|
3172
3205
|
C: (f, a) => f(...a)
|
|
3173
3206
|
});
|
|
@@ -3181,8 +3214,8 @@ var SpaceInvitationProtocol = class {
|
|
|
3181
3214
|
guestKey: invitation.authMethod === Invitation5.AuthMethod.KNOWN_PUBLIC_KEY ? invitation.guestKeypair.publicKey : void 0
|
|
3182
3215
|
});
|
|
3183
3216
|
invariant10(credential.credential, void 0, {
|
|
3184
|
-
F:
|
|
3185
|
-
L:
|
|
3217
|
+
F: __dxlog_file14,
|
|
3218
|
+
L: 122,
|
|
3186
3219
|
S: this,
|
|
3187
3220
|
A: [
|
|
3188
3221
|
"credential.credential",
|
|
@@ -3196,8 +3229,8 @@ var SpaceInvitationProtocol = class {
|
|
|
3196
3229
|
}
|
|
3197
3230
|
async cancelDelegation(invitation) {
|
|
3198
3231
|
invariant10(this._spaceKey, void 0, {
|
|
3199
|
-
F:
|
|
3200
|
-
L:
|
|
3232
|
+
F: __dxlog_file14,
|
|
3233
|
+
L: 128,
|
|
3201
3234
|
S: this,
|
|
3202
3235
|
A: [
|
|
3203
3236
|
"this._spaceKey",
|
|
@@ -3205,8 +3238,8 @@ var SpaceInvitationProtocol = class {
|
|
|
3205
3238
|
]
|
|
3206
3239
|
});
|
|
3207
3240
|
invariant10(invitation.type === Invitation5.Type.DELEGATED && invitation.delegationCredentialId, void 0, {
|
|
3208
|
-
F:
|
|
3209
|
-
L:
|
|
3241
|
+
F: __dxlog_file14,
|
|
3242
|
+
L: 129,
|
|
3210
3243
|
S: this,
|
|
3211
3244
|
A: [
|
|
3212
3245
|
"invitation.type === Invitation.Type.DELEGATED && invitation.delegationCredentialId",
|
|
@@ -3215,27 +3248,27 @@ var SpaceInvitationProtocol = class {
|
|
|
3215
3248
|
});
|
|
3216
3249
|
const space = this._spaceManager.spaces.get(this._spaceKey);
|
|
3217
3250
|
invariant10(space, void 0, {
|
|
3218
|
-
F:
|
|
3219
|
-
L:
|
|
3251
|
+
F: __dxlog_file14,
|
|
3252
|
+
L: 131,
|
|
3220
3253
|
S: this,
|
|
3221
3254
|
A: [
|
|
3222
3255
|
"space",
|
|
3223
3256
|
""
|
|
3224
3257
|
]
|
|
3225
3258
|
});
|
|
3226
|
-
|
|
3259
|
+
log11("cancelling delegated space invitation", {
|
|
3227
3260
|
host: this._signingContext.deviceKey,
|
|
3228
3261
|
id: invitation.invitationId
|
|
3229
3262
|
}, {
|
|
3230
|
-
F:
|
|
3231
|
-
L:
|
|
3263
|
+
F: __dxlog_file14,
|
|
3264
|
+
L: 133,
|
|
3232
3265
|
S: this,
|
|
3233
3266
|
C: (f, a) => f(...a)
|
|
3234
3267
|
});
|
|
3235
3268
|
const credential = await createCancelDelegatedSpaceInvitationCredential(this._signingContext.credentialSigner, space.key, invitation.delegationCredentialId);
|
|
3236
3269
|
invariant10(credential.credential, void 0, {
|
|
3237
|
-
F:
|
|
3238
|
-
L:
|
|
3270
|
+
F: __dxlog_file14,
|
|
3271
|
+
L: 140,
|
|
3239
3272
|
S: this,
|
|
3240
3273
|
A: [
|
|
3241
3274
|
"credential.credential",
|
|
@@ -3273,8 +3306,8 @@ var SpaceInvitationProtocol = class {
|
|
|
3273
3306
|
}
|
|
3274
3307
|
async accept(response) {
|
|
3275
3308
|
invariant10(response.space, void 0, {
|
|
3276
|
-
F:
|
|
3277
|
-
L:
|
|
3309
|
+
F: __dxlog_file14,
|
|
3310
|
+
L: 175,
|
|
3278
3311
|
S: this,
|
|
3279
3312
|
A: [
|
|
3280
3313
|
"response.space",
|
|
@@ -3284,8 +3317,8 @@ var SpaceInvitationProtocol = class {
|
|
|
3284
3317
|
const { credential, controlTimeframe, dataTimeframe } = response.space;
|
|
3285
3318
|
const assertion = getCredentialAssertion2(credential);
|
|
3286
3319
|
invariant10(assertion["@type"] === "dxos.halo.credentials.SpaceMember", "Invalid credential", {
|
|
3287
|
-
F:
|
|
3288
|
-
L:
|
|
3320
|
+
F: __dxlog_file14,
|
|
3321
|
+
L: 178,
|
|
3289
3322
|
S: this,
|
|
3290
3323
|
A: [
|
|
3291
3324
|
"assertion['@type'] === 'dxos.halo.credentials.SpaceMember'",
|
|
@@ -3293,8 +3326,8 @@ var SpaceInvitationProtocol = class {
|
|
|
3293
3326
|
]
|
|
3294
3327
|
});
|
|
3295
3328
|
invariant10(credential.subject.id.equals(this._signingContext.identityKey), void 0, {
|
|
3296
|
-
F:
|
|
3297
|
-
L:
|
|
3329
|
+
F: __dxlog_file14,
|
|
3330
|
+
L: 179,
|
|
3298
3331
|
S: this,
|
|
3299
3332
|
A: [
|
|
3300
3333
|
"credential.subject.id.equals(this._signingContext.identityKey)",
|
|
@@ -3318,17 +3351,17 @@ var SpaceInvitationProtocol = class {
|
|
|
3318
3351
|
};
|
|
3319
3352
|
|
|
3320
3353
|
// packages/sdk/client-services/src/packlets/invitations/invitations-manager.ts
|
|
3321
|
-
import { Event as Event3, PushStream, TimeoutError as TimeoutError2, Trigger as
|
|
3354
|
+
import { Event as Event3, PushStream, TimeoutError as TimeoutError2, Trigger as Trigger6 } from "@dxos/async";
|
|
3322
3355
|
import { AuthenticatingInvitation, AUTHENTICATION_CODE_LENGTH, CancellableInvitation, INVITATION_TIMEOUT as INVITATION_TIMEOUT2 } from "@dxos/client-protocol";
|
|
3323
3356
|
import { Context as Context6 } from "@dxos/context";
|
|
3324
3357
|
import { generatePasscode } from "@dxos/credentials";
|
|
3325
3358
|
import { hasInvitationExpired } from "@dxos/echo-pipeline";
|
|
3326
3359
|
import { invariant as invariant11 } from "@dxos/invariant";
|
|
3327
3360
|
import { PublicKey as PublicKey8 } from "@dxos/keys";
|
|
3328
|
-
import { log as
|
|
3361
|
+
import { log as log12 } from "@dxos/log";
|
|
3329
3362
|
import { Invitation as Invitation6 } from "@dxos/protocols/proto/dxos/client/services";
|
|
3330
3363
|
import { SpaceMember as SpaceMember3 } from "@dxos/protocols/proto/dxos/halo/credentials";
|
|
3331
|
-
var
|
|
3364
|
+
var __dxlog_file15 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitations-manager.ts";
|
|
3332
3365
|
var InvitationsManager = class {
|
|
3333
3366
|
constructor(_invitationsHandler, _getHandler, _metadataStore) {
|
|
3334
3367
|
this._invitationsHandler = _invitationsHandler;
|
|
@@ -3370,8 +3403,8 @@ var InvitationsManager = class {
|
|
|
3370
3403
|
try {
|
|
3371
3404
|
await this._persistIfRequired(handler, stream, invitation);
|
|
3372
3405
|
} catch (err) {
|
|
3373
|
-
|
|
3374
|
-
F:
|
|
3406
|
+
log12.catch(err, void 0, {
|
|
3407
|
+
F: __dxlog_file15,
|
|
3375
3408
|
L: 82,
|
|
3376
3409
|
S: this,
|
|
3377
3410
|
C: (f, a) => f(...a)
|
|
@@ -3394,7 +3427,7 @@ var InvitationsManager = class {
|
|
|
3394
3427
|
const freshInvitations = persistentInvitations.filter((invitation) => !hasInvitationExpired(invitation));
|
|
3395
3428
|
const loadTasks = freshInvitations.map((persistentInvitation) => {
|
|
3396
3429
|
invariant11(!this._createInvitations.get(persistentInvitation.invitationId), "invitation already exists", {
|
|
3397
|
-
F:
|
|
3430
|
+
F: __dxlog_file15,
|
|
3398
3431
|
L: 103,
|
|
3399
3432
|
S: this,
|
|
3400
3433
|
A: [
|
|
@@ -3412,8 +3445,8 @@ var InvitationsManager = class {
|
|
|
3412
3445
|
invitations: cInvitations.map((invitation) => invitation.get())
|
|
3413
3446
|
};
|
|
3414
3447
|
} catch (err) {
|
|
3415
|
-
|
|
3416
|
-
F:
|
|
3448
|
+
log12.catch(err, void 0, {
|
|
3449
|
+
F: __dxlog_file15,
|
|
3417
3450
|
L: 110,
|
|
3418
3451
|
S: this,
|
|
3419
3452
|
C: (f, a) => f(...a)
|
|
@@ -3444,14 +3477,14 @@ var InvitationsManager = class {
|
|
|
3444
3477
|
return invitation;
|
|
3445
3478
|
}
|
|
3446
3479
|
async authenticate({ invitationId, authCode }) {
|
|
3447
|
-
|
|
3448
|
-
F:
|
|
3480
|
+
log12("authenticating...", void 0, {
|
|
3481
|
+
F: __dxlog_file15,
|
|
3449
3482
|
L: 140,
|
|
3450
3483
|
S: this,
|
|
3451
3484
|
C: (f, a) => f(...a)
|
|
3452
3485
|
});
|
|
3453
3486
|
invariant11(invitationId, void 0, {
|
|
3454
|
-
F:
|
|
3487
|
+
F: __dxlog_file15,
|
|
3455
3488
|
L: 141,
|
|
3456
3489
|
S: this,
|
|
3457
3490
|
A: [
|
|
@@ -3461,10 +3494,10 @@ var InvitationsManager = class {
|
|
|
3461
3494
|
});
|
|
3462
3495
|
const observable = this._acceptInvitations.get(invitationId);
|
|
3463
3496
|
if (!observable) {
|
|
3464
|
-
|
|
3497
|
+
log12.warn("invalid invitation", {
|
|
3465
3498
|
invitationId
|
|
3466
3499
|
}, {
|
|
3467
|
-
F:
|
|
3500
|
+
F: __dxlog_file15,
|
|
3468
3501
|
L: 144,
|
|
3469
3502
|
S: this,
|
|
3470
3503
|
C: (f, a) => f(...a)
|
|
@@ -3474,16 +3507,16 @@ var InvitationsManager = class {
|
|
|
3474
3507
|
}
|
|
3475
3508
|
}
|
|
3476
3509
|
async cancelInvitation({ invitationId }) {
|
|
3477
|
-
|
|
3510
|
+
log12("cancelInvitation...", {
|
|
3478
3511
|
invitationId
|
|
3479
3512
|
}, {
|
|
3480
|
-
F:
|
|
3513
|
+
F: __dxlog_file15,
|
|
3481
3514
|
L: 151,
|
|
3482
3515
|
S: this,
|
|
3483
3516
|
C: (f, a) => f(...a)
|
|
3484
3517
|
});
|
|
3485
3518
|
invariant11(invitationId, void 0, {
|
|
3486
|
-
F:
|
|
3519
|
+
F: __dxlog_file15,
|
|
3487
3520
|
L: 152,
|
|
3488
3521
|
S: this,
|
|
3489
3522
|
A: [
|
|
@@ -3557,12 +3590,15 @@ var InvitationsManager = class {
|
|
|
3557
3590
|
stream.error(err);
|
|
3558
3591
|
void ctx.dispose();
|
|
3559
3592
|
}
|
|
3593
|
+
}, {
|
|
3594
|
+
F: __dxlog_file15,
|
|
3595
|
+
L: 234
|
|
3560
3596
|
});
|
|
3561
3597
|
ctx.onDispose(() => {
|
|
3562
|
-
|
|
3598
|
+
log12("complete", {
|
|
3563
3599
|
...handler.toJSON()
|
|
3564
3600
|
}, {
|
|
3565
|
-
F:
|
|
3601
|
+
F: __dxlog_file15,
|
|
3566
3602
|
L: 241,
|
|
3567
3603
|
S: this,
|
|
3568
3604
|
C: (f, a) => f(...a)
|
|
@@ -3587,15 +3623,15 @@ var InvitationsManager = class {
|
|
|
3587
3623
|
};
|
|
3588
3624
|
}
|
|
3589
3625
|
_createObservableAcceptingInvitation(handler, initialState) {
|
|
3590
|
-
const otpEnteredTrigger = new
|
|
3626
|
+
const otpEnteredTrigger = new Trigger6();
|
|
3591
3627
|
const stream = new PushStream();
|
|
3592
3628
|
const ctx = new Context6({
|
|
3593
3629
|
onError: (err) => {
|
|
3594
3630
|
if (err instanceof TimeoutError2) {
|
|
3595
|
-
|
|
3631
|
+
log12("timeout", {
|
|
3596
3632
|
...handler.toJSON()
|
|
3597
3633
|
}, {
|
|
3598
|
-
F:
|
|
3634
|
+
F: __dxlog_file15,
|
|
3599
3635
|
L: 261,
|
|
3600
3636
|
S: this,
|
|
3601
3637
|
C: (f, a) => f(...a)
|
|
@@ -3605,8 +3641,8 @@ var InvitationsManager = class {
|
|
|
3605
3641
|
state: Invitation6.State.TIMEOUT
|
|
3606
3642
|
});
|
|
3607
3643
|
} else {
|
|
3608
|
-
|
|
3609
|
-
F:
|
|
3644
|
+
log12.warn("auth failed", err, {
|
|
3645
|
+
F: __dxlog_file15,
|
|
3610
3646
|
L: 264,
|
|
3611
3647
|
S: this,
|
|
3612
3648
|
C: (f, a) => f(...a)
|
|
@@ -3618,12 +3654,15 @@ var InvitationsManager = class {
|
|
|
3618
3654
|
}
|
|
3619
3655
|
void ctx.dispose();
|
|
3620
3656
|
}
|
|
3621
|
-
}
|
|
3657
|
+
}, {
|
|
3658
|
+
F: __dxlog_file15,
|
|
3659
|
+
L: 258
|
|
3660
|
+
});
|
|
3622
3661
|
ctx.onDispose(() => {
|
|
3623
|
-
|
|
3662
|
+
log12("complete", {
|
|
3624
3663
|
...handler.toJSON()
|
|
3625
3664
|
}, {
|
|
3626
|
-
F:
|
|
3665
|
+
F: __dxlog_file15,
|
|
3627
3666
|
L: 271,
|
|
3628
3667
|
S: this,
|
|
3629
3668
|
C: (f, a) => f(...a)
|
|
@@ -3667,8 +3706,8 @@ var InvitationsManager = class {
|
|
|
3667
3706
|
try {
|
|
3668
3707
|
await this._metadataStore.removeInvitation(invitation.invitationId);
|
|
3669
3708
|
} catch (err) {
|
|
3670
|
-
|
|
3671
|
-
F:
|
|
3709
|
+
log12.catch(err, void 0, {
|
|
3710
|
+
F: __dxlog_file15,
|
|
3672
3711
|
L: 307,
|
|
3673
3712
|
S: this,
|
|
3674
3713
|
C: (f, a) => f(...a)
|
|
@@ -3683,33 +3722,40 @@ var InvitationsManager = class {
|
|
|
3683
3722
|
};
|
|
3684
3723
|
|
|
3685
3724
|
// packages/sdk/client-services/src/packlets/spaces/data-space.ts
|
|
3686
|
-
import { Event as Event6,
|
|
3725
|
+
import { Event as Event6, Mutex as Mutex2, scheduleTask as scheduleTask5, sleep as sleep3, synchronized, trackLeaks } from "@dxos/async";
|
|
3687
3726
|
import { AUTH_TIMEOUT as AUTH_TIMEOUT2 } from "@dxos/client-protocol";
|
|
3688
3727
|
import { Context as Context8, ContextDisposedError as ContextDisposedError3, cancelWithContext as cancelWithContext4 } from "@dxos/context";
|
|
3689
3728
|
import { timed, warnAfterTimeout } from "@dxos/debug";
|
|
3690
|
-
import {
|
|
3691
|
-
import {
|
|
3692
|
-
import { failedInvariant
|
|
3729
|
+
import { createMappedFeedWriter } from "@dxos/echo-pipeline";
|
|
3730
|
+
import { SpaceDocVersion as SpaceDocVersion2 } from "@dxos/echo-protocol";
|
|
3731
|
+
import { failedInvariant } from "@dxos/invariant";
|
|
3693
3732
|
import { PublicKey as PublicKey10 } from "@dxos/keys";
|
|
3694
|
-
import { log as
|
|
3733
|
+
import { log as log15 } from "@dxos/log";
|
|
3695
3734
|
import { CancelledError, SystemError } from "@dxos/protocols";
|
|
3696
|
-
import {
|
|
3735
|
+
import { SpaceState as SpaceState2 } from "@dxos/protocols/proto/dxos/client/services";
|
|
3697
3736
|
import { AdmittedFeed as AdmittedFeed3, SpaceMember as SpaceMember4 } from "@dxos/protocols/proto/dxos/halo/credentials";
|
|
3698
3737
|
import { Timeframe as Timeframe3 } from "@dxos/timeframe";
|
|
3699
3738
|
import { trace as trace6 } from "@dxos/tracing";
|
|
3700
|
-
import { ComplexSet as ComplexSet5
|
|
3739
|
+
import { ComplexSet as ComplexSet5 } from "@dxos/util";
|
|
3701
3740
|
|
|
3702
3741
|
// packages/sdk/client-services/src/packlets/spaces/automerge-space-state.ts
|
|
3703
3742
|
import { Event as Event4 } from "@dxos/async";
|
|
3743
|
+
import { Resource as Resource2 } from "@dxos/context";
|
|
3704
3744
|
import { checkCredentialType } from "@dxos/credentials";
|
|
3705
|
-
var AutomergeSpaceState = class {
|
|
3745
|
+
var AutomergeSpaceState = class extends Resource2 {
|
|
3706
3746
|
constructor(_onNewRoot) {
|
|
3747
|
+
super();
|
|
3707
3748
|
this._onNewRoot = _onNewRoot;
|
|
3708
3749
|
this.rootUrl = void 0;
|
|
3709
3750
|
this.lastEpoch = void 0;
|
|
3710
3751
|
this.onNewEpoch = new Event4();
|
|
3711
3752
|
this._isProcessingRootDocs = false;
|
|
3712
3753
|
}
|
|
3754
|
+
async _open(ctx) {
|
|
3755
|
+
}
|
|
3756
|
+
async _close(ctx) {
|
|
3757
|
+
this._isProcessingRootDocs = false;
|
|
3758
|
+
}
|
|
3713
3759
|
async processCredential(credential) {
|
|
3714
3760
|
if (!checkCredentialType(credential, "dxos.halo.credentials.Epoch")) {
|
|
3715
3761
|
return;
|
|
@@ -3737,23 +3783,199 @@ var AutomergeSpaceState = class {
|
|
|
3737
3783
|
}
|
|
3738
3784
|
};
|
|
3739
3785
|
|
|
3786
|
+
// packages/sdk/client-services/src/packlets/spaces/epoch-migrations.ts
|
|
3787
|
+
import { convertLegacyReferences, convertLegacySpaceRootDoc, findInlineObjectOfType, migrateDocument } from "@dxos/echo-db";
|
|
3788
|
+
import { SpaceDocVersion } from "@dxos/echo-protocol";
|
|
3789
|
+
import { TYPE_PROPERTIES } from "@dxos/echo-schema";
|
|
3790
|
+
import { invariant as invariant12 } from "@dxos/invariant";
|
|
3791
|
+
import { log as log13 } from "@dxos/log";
|
|
3792
|
+
import { CreateEpochRequest } from "@dxos/protocols/proto/dxos/client/services";
|
|
3793
|
+
var __dxlog_file16 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/epoch-migrations.ts";
|
|
3794
|
+
var LOAD_DOC_TIMEOUT = 1e4;
|
|
3795
|
+
var runEpochMigration = async (ctx, context) => {
|
|
3796
|
+
switch (context.migration) {
|
|
3797
|
+
case CreateEpochRequest.Migration.INIT_AUTOMERGE: {
|
|
3798
|
+
const document = context.echoHost.createDoc();
|
|
3799
|
+
await context.echoHost.flush();
|
|
3800
|
+
return {
|
|
3801
|
+
newRoot: document.url
|
|
3802
|
+
};
|
|
3803
|
+
}
|
|
3804
|
+
case CreateEpochRequest.Migration.PRUNE_AUTOMERGE_ROOT_HISTORY: {
|
|
3805
|
+
if (!context.currentRoot) {
|
|
3806
|
+
throw new Error("Space does not have an automerge root");
|
|
3807
|
+
}
|
|
3808
|
+
const rootHandle = await context.echoHost.loadDoc(ctx, context.currentRoot, {
|
|
3809
|
+
timeout: LOAD_DOC_TIMEOUT
|
|
3810
|
+
});
|
|
3811
|
+
const newRoot = context.echoHost.createDoc(rootHandle.docSync());
|
|
3812
|
+
await context.echoHost.flush();
|
|
3813
|
+
return {
|
|
3814
|
+
newRoot: newRoot.url
|
|
3815
|
+
};
|
|
3816
|
+
}
|
|
3817
|
+
case CreateEpochRequest.Migration.FRAGMENT_AUTOMERGE_ROOT: {
|
|
3818
|
+
log13.info("Fragmenting", void 0, {
|
|
3819
|
+
F: __dxlog_file16,
|
|
3820
|
+
L: 64,
|
|
3821
|
+
S: void 0,
|
|
3822
|
+
C: (f, a) => f(...a)
|
|
3823
|
+
});
|
|
3824
|
+
const currentRootUrl = context.currentRoot;
|
|
3825
|
+
const rootHandle = await context.echoHost.loadDoc(ctx, currentRootUrl, {
|
|
3826
|
+
timeout: LOAD_DOC_TIMEOUT
|
|
3827
|
+
});
|
|
3828
|
+
const objects = Object.entries(rootHandle.docSync().objects);
|
|
3829
|
+
const properties = findInlineObjectOfType(rootHandle.docSync(), TYPE_PROPERTIES);
|
|
3830
|
+
const otherObjects = objects.filter(([key]) => key !== properties?.[0]);
|
|
3831
|
+
invariant12(properties, "Properties not found", {
|
|
3832
|
+
F: __dxlog_file16,
|
|
3833
|
+
L: 75,
|
|
3834
|
+
S: void 0,
|
|
3835
|
+
A: [
|
|
3836
|
+
"properties",
|
|
3837
|
+
"'Properties not found'"
|
|
3838
|
+
]
|
|
3839
|
+
});
|
|
3840
|
+
const newRoot = context.echoHost.createDoc({
|
|
3841
|
+
...rootHandle.docSync(),
|
|
3842
|
+
objects: Object.fromEntries([
|
|
3843
|
+
properties
|
|
3844
|
+
])
|
|
3845
|
+
});
|
|
3846
|
+
invariant12(typeof newRoot.url === "string" && newRoot.url.length > 0, void 0, {
|
|
3847
|
+
F: __dxlog_file16,
|
|
3848
|
+
L: 82,
|
|
3849
|
+
S: void 0,
|
|
3850
|
+
A: [
|
|
3851
|
+
"typeof newRoot.url === 'string' && newRoot.url.length > 0",
|
|
3852
|
+
""
|
|
3853
|
+
]
|
|
3854
|
+
});
|
|
3855
|
+
const newLinks = [];
|
|
3856
|
+
for (const [id, objData] of otherObjects) {
|
|
3857
|
+
const handle = context.echoHost.createDoc({
|
|
3858
|
+
version: SpaceDocVersion.CURRENT,
|
|
3859
|
+
access: {
|
|
3860
|
+
spaceKey: context.spaceKey.toHex()
|
|
3861
|
+
},
|
|
3862
|
+
objects: {
|
|
3863
|
+
[id]: objData
|
|
3864
|
+
}
|
|
3865
|
+
});
|
|
3866
|
+
newLinks.push([
|
|
3867
|
+
id,
|
|
3868
|
+
handle.url
|
|
3869
|
+
]);
|
|
3870
|
+
}
|
|
3871
|
+
newRoot.change((doc) => {
|
|
3872
|
+
doc.links ??= {};
|
|
3873
|
+
for (const [id, url] of newLinks) {
|
|
3874
|
+
doc.links[id] = url;
|
|
3875
|
+
}
|
|
3876
|
+
});
|
|
3877
|
+
await context.echoHost.flush();
|
|
3878
|
+
return {
|
|
3879
|
+
newRoot: newRoot.url
|
|
3880
|
+
};
|
|
3881
|
+
}
|
|
3882
|
+
case CreateEpochRequest.Migration.MIGRATE_REFERENCES_TO_DXN: {
|
|
3883
|
+
const currentRootUrl = context.currentRoot;
|
|
3884
|
+
const rootHandle = await context.echoHost.loadDoc(ctx, currentRootUrl, {
|
|
3885
|
+
timeout: LOAD_DOC_TIMEOUT
|
|
3886
|
+
});
|
|
3887
|
+
invariant12(rootHandle.docSync(), "Root doc not found", {
|
|
3888
|
+
F: __dxlog_file16,
|
|
3889
|
+
L: 115,
|
|
3890
|
+
S: void 0,
|
|
3891
|
+
A: [
|
|
3892
|
+
"rootHandle.docSync()",
|
|
3893
|
+
"'Root doc not found'"
|
|
3894
|
+
]
|
|
3895
|
+
});
|
|
3896
|
+
const newRootContent = await convertLegacySpaceRootDoc(structuredClone(rootHandle.docSync()));
|
|
3897
|
+
for (const [id, url] of Object.entries(newRootContent.links ?? {})) {
|
|
3898
|
+
try {
|
|
3899
|
+
const handle = await context.echoHost.loadDoc(ctx, url, {
|
|
3900
|
+
timeout: LOAD_DOC_TIMEOUT
|
|
3901
|
+
});
|
|
3902
|
+
invariant12(handle.docSync(), void 0, {
|
|
3903
|
+
F: __dxlog_file16,
|
|
3904
|
+
L: 122,
|
|
3905
|
+
S: void 0,
|
|
3906
|
+
A: [
|
|
3907
|
+
"handle.docSync()",
|
|
3908
|
+
""
|
|
3909
|
+
]
|
|
3910
|
+
});
|
|
3911
|
+
const newDoc = await convertLegacyReferences(structuredClone(handle.docSync()));
|
|
3912
|
+
const migratedDoc = migrateDocument(handle.docSync(), newDoc);
|
|
3913
|
+
const newHandle = context.echoHost.createDoc(migratedDoc, {
|
|
3914
|
+
preserveHistory: true
|
|
3915
|
+
});
|
|
3916
|
+
newRootContent.links[id] = newHandle.url;
|
|
3917
|
+
} catch (err) {
|
|
3918
|
+
log13.warn("Failed to migrate reference", {
|
|
3919
|
+
id,
|
|
3920
|
+
url,
|
|
3921
|
+
error: err
|
|
3922
|
+
}, {
|
|
3923
|
+
F: __dxlog_file16,
|
|
3924
|
+
L: 128,
|
|
3925
|
+
S: void 0,
|
|
3926
|
+
C: (f, a) => f(...a)
|
|
3927
|
+
});
|
|
3928
|
+
delete newRootContent.links[id];
|
|
3929
|
+
}
|
|
3930
|
+
}
|
|
3931
|
+
const migratedRoot = migrateDocument(rootHandle.docSync(), newRootContent);
|
|
3932
|
+
const newRoot = context.echoHost.createDoc(migratedRoot, {
|
|
3933
|
+
preserveHistory: true
|
|
3934
|
+
});
|
|
3935
|
+
await context.echoHost.flush();
|
|
3936
|
+
return {
|
|
3937
|
+
newRoot: newRoot.url
|
|
3938
|
+
};
|
|
3939
|
+
}
|
|
3940
|
+
case CreateEpochRequest.Migration.REPLACE_AUTOMERGE_ROOT: {
|
|
3941
|
+
invariant12(context.newAutomergeRoot, void 0, {
|
|
3942
|
+
F: __dxlog_file16,
|
|
3943
|
+
L: 143,
|
|
3944
|
+
S: void 0,
|
|
3945
|
+
A: [
|
|
3946
|
+
"context.newAutomergeRoot",
|
|
3947
|
+
""
|
|
3948
|
+
]
|
|
3949
|
+
});
|
|
3950
|
+
await context.echoHost.flush();
|
|
3951
|
+
return {
|
|
3952
|
+
newRoot: context.newAutomergeRoot
|
|
3953
|
+
};
|
|
3954
|
+
}
|
|
3955
|
+
}
|
|
3956
|
+
return {};
|
|
3957
|
+
};
|
|
3958
|
+
|
|
3740
3959
|
// packages/sdk/client-services/src/packlets/spaces/notarization-plugin.ts
|
|
3741
|
-
import { DeferredTask, Event as Event5, scheduleTask as scheduleTask4, sleep, TimeoutError as TimeoutError3, Trigger as
|
|
3960
|
+
import { DeferredTask, Event as Event5, scheduleTask as scheduleTask4, sleep as sleep2, TimeoutError as TimeoutError3, Trigger as Trigger7 } from "@dxos/async";
|
|
3742
3961
|
import { Context as Context7, rejectOnDispose } from "@dxos/context";
|
|
3743
|
-
import { invariant as
|
|
3962
|
+
import { invariant as invariant13 } from "@dxos/invariant";
|
|
3744
3963
|
import { PublicKey as PublicKey9 } from "@dxos/keys";
|
|
3745
|
-
import { log as
|
|
3964
|
+
import { log as log14 } from "@dxos/log";
|
|
3746
3965
|
import { schema as schema4 } from "@dxos/protocols";
|
|
3747
3966
|
import { RpcExtension as RpcExtension3 } from "@dxos/teleport";
|
|
3748
3967
|
import { ComplexMap as ComplexMap2, ComplexSet as ComplexSet4, entry } from "@dxos/util";
|
|
3749
|
-
var
|
|
3968
|
+
var __dxlog_file17 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/notarization-plugin.ts";
|
|
3750
3969
|
var DEFAULT_RETRY_TIMEOUT = 1e3;
|
|
3751
3970
|
var DEFAULT_SUCCESS_DELAY = 1e3;
|
|
3752
3971
|
var DEFAULT_NOTARIZE_TIMEOUT = 1e4;
|
|
3753
3972
|
var WRITER_NOT_SET_ERROR_CODE = "WRITER_NOT_SET";
|
|
3754
3973
|
var NotarizationPlugin = class {
|
|
3755
3974
|
constructor() {
|
|
3756
|
-
this._ctx = new Context7(
|
|
3975
|
+
this._ctx = new Context7(void 0, {
|
|
3976
|
+
F: __dxlog_file17,
|
|
3977
|
+
L: 62
|
|
3978
|
+
});
|
|
3757
3979
|
this._extensionOpened = new Event5();
|
|
3758
3980
|
this._extensions = /* @__PURE__ */ new Set();
|
|
3759
3981
|
this._processedCredentials = new ComplexSet4(PublicKey9.hash);
|
|
@@ -3771,16 +3993,16 @@ var NotarizationPlugin = class {
|
|
|
3771
3993
|
* Request credentials to be notarized.
|
|
3772
3994
|
*/
|
|
3773
3995
|
async notarize({ ctx: opCtx, credentials, timeout = DEFAULT_NOTARIZE_TIMEOUT, retryTimeout = DEFAULT_RETRY_TIMEOUT, successDelay = DEFAULT_SUCCESS_DELAY }) {
|
|
3774
|
-
|
|
3996
|
+
log14("notarize", {
|
|
3775
3997
|
credentials
|
|
3776
3998
|
}, {
|
|
3777
|
-
F:
|
|
3999
|
+
F: __dxlog_file17,
|
|
3778
4000
|
L: 90,
|
|
3779
4001
|
S: this,
|
|
3780
4002
|
C: (f, a) => f(...a)
|
|
3781
4003
|
});
|
|
3782
|
-
|
|
3783
|
-
F:
|
|
4004
|
+
invariant13(credentials.every((credential) => credential.id), "Credentials must have an id", {
|
|
4005
|
+
F: __dxlog_file17,
|
|
3784
4006
|
L: 91,
|
|
3785
4007
|
S: this,
|
|
3786
4008
|
A: [
|
|
@@ -3788,13 +4010,13 @@ var NotarizationPlugin = class {
|
|
|
3788
4010
|
"'Credentials must have an id'"
|
|
3789
4011
|
]
|
|
3790
4012
|
});
|
|
3791
|
-
const errors = new
|
|
4013
|
+
const errors = new Trigger7();
|
|
3792
4014
|
const ctx = this._ctx.derive({
|
|
3793
4015
|
onError: (err) => {
|
|
3794
|
-
|
|
4016
|
+
log14.warn("Notarization error", {
|
|
3795
4017
|
err
|
|
3796
4018
|
}, {
|
|
3797
|
-
F:
|
|
4019
|
+
F: __dxlog_file17,
|
|
3798
4020
|
L: 99,
|
|
3799
4021
|
S: this,
|
|
3800
4022
|
C: (f, a) => f(...a)
|
|
@@ -3806,11 +4028,11 @@ var NotarizationPlugin = class {
|
|
|
3806
4028
|
opCtx?.onDispose(() => ctx.dispose());
|
|
3807
4029
|
if (timeout !== 0) {
|
|
3808
4030
|
scheduleTask4(ctx, () => {
|
|
3809
|
-
|
|
4031
|
+
log14.warn("Notarization timeout", {
|
|
3810
4032
|
timeout,
|
|
3811
4033
|
peers: Array.from(this._extensions).map((extension) => extension.remotePeerId)
|
|
3812
4034
|
}, {
|
|
3813
|
-
F:
|
|
4035
|
+
F: __dxlog_file17,
|
|
3814
4036
|
L: 111,
|
|
3815
4037
|
S: this,
|
|
3816
4038
|
C: (f, a) => f(...a)
|
|
@@ -3830,10 +4052,10 @@ var NotarizationPlugin = class {
|
|
|
3830
4052
|
...this._extensions
|
|
3831
4053
|
].find((peer2) => !peersTried.has(peer2));
|
|
3832
4054
|
if (!peer) {
|
|
3833
|
-
|
|
4055
|
+
log14.info("Exhausted all peers to notarize with", {
|
|
3834
4056
|
retryIn: retryTimeout
|
|
3835
4057
|
}, {
|
|
3836
|
-
F:
|
|
4058
|
+
F: __dxlog_file17,
|
|
3837
4059
|
L: 136,
|
|
3838
4060
|
S: this,
|
|
3839
4061
|
C: (f, a) => f(...a)
|
|
@@ -3843,11 +4065,11 @@ var NotarizationPlugin = class {
|
|
|
3843
4065
|
return;
|
|
3844
4066
|
}
|
|
3845
4067
|
peersTried.add(peer);
|
|
3846
|
-
|
|
4068
|
+
log14("try notarizing", {
|
|
3847
4069
|
peer: peer.localPeerId,
|
|
3848
4070
|
credentialId: credentials.map((credential) => credential.id)
|
|
3849
4071
|
}, {
|
|
3850
|
-
F:
|
|
4072
|
+
F: __dxlog_file17,
|
|
3851
4073
|
L: 143,
|
|
3852
4074
|
S: this,
|
|
3853
4075
|
C: (f, a) => f(...a)
|
|
@@ -3855,17 +4077,17 @@ var NotarizationPlugin = class {
|
|
|
3855
4077
|
await peer.rpc.NotarizationService.notarize({
|
|
3856
4078
|
credentials: credentials.filter((credential) => !this._processedCredentials.has(credential.id))
|
|
3857
4079
|
});
|
|
3858
|
-
|
|
3859
|
-
F:
|
|
4080
|
+
log14("success", void 0, {
|
|
4081
|
+
F: __dxlog_file17,
|
|
3860
4082
|
L: 147,
|
|
3861
4083
|
S: this,
|
|
3862
4084
|
C: (f, a) => f(...a)
|
|
3863
4085
|
});
|
|
3864
|
-
await
|
|
4086
|
+
await sleep2(successDelay);
|
|
3865
4087
|
} catch (err) {
|
|
3866
4088
|
if (!ctx.disposed && !err.message.includes(WRITER_NOT_SET_ERROR_CODE)) {
|
|
3867
|
-
|
|
3868
|
-
F:
|
|
4089
|
+
log14.info("error notarizing (recoverable)", err, {
|
|
4090
|
+
F: __dxlog_file17,
|
|
3869
4091
|
L: 151,
|
|
3870
4092
|
S: this,
|
|
3871
4093
|
C: (f, a) => f(...a)
|
|
@@ -3882,8 +4104,8 @@ var NotarizationPlugin = class {
|
|
|
3882
4104
|
allNotarized,
|
|
3883
4105
|
errors.wait()
|
|
3884
4106
|
]);
|
|
3885
|
-
|
|
3886
|
-
F:
|
|
4107
|
+
log14("done", void 0, {
|
|
4108
|
+
F: __dxlog_file17,
|
|
3887
4109
|
L: 162,
|
|
3888
4110
|
S: this,
|
|
3889
4111
|
C: (f, a) => f(...a)
|
|
@@ -3904,8 +4126,8 @@ var NotarizationPlugin = class {
|
|
|
3904
4126
|
this._processCredentialsTriggers.delete(credential.id);
|
|
3905
4127
|
}
|
|
3906
4128
|
setWriter(writer) {
|
|
3907
|
-
|
|
3908
|
-
F:
|
|
4129
|
+
invariant13(!this._writer, "Writer already set.", {
|
|
4130
|
+
F: __dxlog_file17,
|
|
3909
4131
|
L: 181,
|
|
3910
4132
|
S: this,
|
|
3911
4133
|
A: [
|
|
@@ -3919,7 +4141,7 @@ var NotarizationPlugin = class {
|
|
|
3919
4141
|
if (this._processedCredentials.has(id)) {
|
|
3920
4142
|
return;
|
|
3921
4143
|
}
|
|
3922
|
-
await entry(this._processCredentialsTriggers, id).orInsert(new
|
|
4144
|
+
await entry(this._processCredentialsTriggers, id).orInsert(new Trigger7()).value.wait();
|
|
3923
4145
|
}
|
|
3924
4146
|
/**
|
|
3925
4147
|
* Requests from other peers to notarize credentials.
|
|
@@ -3929,8 +4151,8 @@ var NotarizationPlugin = class {
|
|
|
3929
4151
|
throw new Error(WRITER_NOT_SET_ERROR_CODE);
|
|
3930
4152
|
}
|
|
3931
4153
|
for (const credential of request.credentials ?? []) {
|
|
3932
|
-
|
|
3933
|
-
F:
|
|
4154
|
+
invariant13(credential.id, "Credential must have an id", {
|
|
4155
|
+
F: __dxlog_file17,
|
|
3934
4156
|
L: 200,
|
|
3935
4157
|
S: this,
|
|
3936
4158
|
A: [
|
|
@@ -3947,10 +4169,10 @@ var NotarizationPlugin = class {
|
|
|
3947
4169
|
createExtension() {
|
|
3948
4170
|
const extension = new NotarizationTeleportExtension({
|
|
3949
4171
|
onOpen: async () => {
|
|
3950
|
-
|
|
4172
|
+
log14("extension opened", {
|
|
3951
4173
|
peer: extension.localPeerId
|
|
3952
4174
|
}, {
|
|
3953
|
-
F:
|
|
4175
|
+
F: __dxlog_file17,
|
|
3954
4176
|
L: 211,
|
|
3955
4177
|
S: this,
|
|
3956
4178
|
C: (f, a) => f(...a)
|
|
@@ -3959,10 +4181,10 @@ var NotarizationPlugin = class {
|
|
|
3959
4181
|
this._extensionOpened.emit();
|
|
3960
4182
|
},
|
|
3961
4183
|
onClose: async () => {
|
|
3962
|
-
|
|
4184
|
+
log14("extension closed", {
|
|
3963
4185
|
peer: extension.localPeerId
|
|
3964
4186
|
}, {
|
|
3965
|
-
F:
|
|
4187
|
+
F: __dxlog_file17,
|
|
3966
4188
|
L: 216,
|
|
3967
4189
|
S: this,
|
|
3968
4190
|
C: (f, a) => f(...a)
|
|
@@ -4016,15 +4238,83 @@ function _ts_decorate4(decorators, target, key, desc) {
|
|
|
4016
4238
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
4017
4239
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4018
4240
|
}
|
|
4019
|
-
|
|
4241
|
+
function _using_ctx() {
|
|
4242
|
+
var _disposeSuppressedError = typeof SuppressedError === "function" ? SuppressedError : function(error, suppressed) {
|
|
4243
|
+
var err = new Error();
|
|
4244
|
+
err.name = "SuppressedError";
|
|
4245
|
+
err.suppressed = suppressed;
|
|
4246
|
+
err.error = error;
|
|
4247
|
+
return err;
|
|
4248
|
+
}, empty = {}, stack = [];
|
|
4249
|
+
function using(isAwait, value) {
|
|
4250
|
+
if (value != null) {
|
|
4251
|
+
if (Object(value) !== value) {
|
|
4252
|
+
throw new TypeError("using declarations can only be used with objects, functions, null, or undefined.");
|
|
4253
|
+
}
|
|
4254
|
+
if (isAwait) {
|
|
4255
|
+
var dispose = value[Symbol.asyncDispose || Symbol.for("Symbol.asyncDispose")];
|
|
4256
|
+
}
|
|
4257
|
+
if (dispose == null) {
|
|
4258
|
+
dispose = value[Symbol.dispose || Symbol.for("Symbol.dispose")];
|
|
4259
|
+
}
|
|
4260
|
+
if (typeof dispose !== "function") {
|
|
4261
|
+
throw new TypeError(`Property [Symbol.dispose] is not a function.`);
|
|
4262
|
+
}
|
|
4263
|
+
stack.push({
|
|
4264
|
+
v: value,
|
|
4265
|
+
d: dispose,
|
|
4266
|
+
a: isAwait
|
|
4267
|
+
});
|
|
4268
|
+
} else if (isAwait) {
|
|
4269
|
+
stack.push({
|
|
4270
|
+
d: value,
|
|
4271
|
+
a: isAwait
|
|
4272
|
+
});
|
|
4273
|
+
}
|
|
4274
|
+
return value;
|
|
4275
|
+
}
|
|
4276
|
+
return {
|
|
4277
|
+
e: empty,
|
|
4278
|
+
u: using.bind(null, false),
|
|
4279
|
+
a: using.bind(null, true),
|
|
4280
|
+
d: function() {
|
|
4281
|
+
var error = this.e;
|
|
4282
|
+
function next() {
|
|
4283
|
+
while (resource = stack.pop()) {
|
|
4284
|
+
try {
|
|
4285
|
+
var resource, disposalResult = resource.d && resource.d.call(resource.v);
|
|
4286
|
+
if (resource.a) {
|
|
4287
|
+
return Promise.resolve(disposalResult).then(next, err);
|
|
4288
|
+
}
|
|
4289
|
+
} catch (e) {
|
|
4290
|
+
return err(e);
|
|
4291
|
+
}
|
|
4292
|
+
}
|
|
4293
|
+
if (error !== empty)
|
|
4294
|
+
throw error;
|
|
4295
|
+
}
|
|
4296
|
+
function err(e) {
|
|
4297
|
+
error = error !== empty ? new _disposeSuppressedError(error, e) : e;
|
|
4298
|
+
return next();
|
|
4299
|
+
}
|
|
4300
|
+
return next();
|
|
4301
|
+
}
|
|
4302
|
+
};
|
|
4303
|
+
}
|
|
4304
|
+
var __dxlog_file18 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space.ts";
|
|
4020
4305
|
var DataSpace = class {
|
|
4021
4306
|
constructor(params) {
|
|
4022
|
-
this._ctx = new Context8(
|
|
4307
|
+
this._ctx = new Context8(void 0, {
|
|
4308
|
+
F: __dxlog_file18,
|
|
4309
|
+
L: 84
|
|
4310
|
+
});
|
|
4023
4311
|
this._notarizationPlugin = new NotarizationPlugin();
|
|
4024
4312
|
this._cache = void 0;
|
|
4025
4313
|
// TODO(dmaretskyi): Move into Space?
|
|
4026
4314
|
this._automergeSpaceState = new AutomergeSpaceState((rootUrl) => this._onNewAutomergeRoot(rootUrl));
|
|
4315
|
+
this._epochProcessingMutex = new Mutex2();
|
|
4027
4316
|
this._state = SpaceState2.CLOSED;
|
|
4317
|
+
this._databaseRoot = null;
|
|
4028
4318
|
/**
|
|
4029
4319
|
* Error for _state === SpaceState.ERROR.
|
|
4030
4320
|
*/
|
|
@@ -4048,11 +4338,11 @@ var DataSpace = class {
|
|
|
4048
4338
|
});
|
|
4049
4339
|
this._cache = params.cache;
|
|
4050
4340
|
this._state = params.initialState;
|
|
4051
|
-
|
|
4341
|
+
log15("new state", {
|
|
4052
4342
|
state: SpaceState2[this._state]
|
|
4053
4343
|
}, {
|
|
4054
|
-
F:
|
|
4055
|
-
L:
|
|
4344
|
+
F: __dxlog_file18,
|
|
4345
|
+
L: 146,
|
|
4056
4346
|
S: this,
|
|
4057
4347
|
C: (f, a) => f(...a)
|
|
4058
4348
|
});
|
|
@@ -4085,6 +4375,9 @@ var DataSpace = class {
|
|
|
4085
4375
|
get automergeSpaceState() {
|
|
4086
4376
|
return this._automergeSpaceState;
|
|
4087
4377
|
}
|
|
4378
|
+
get databaseRoot() {
|
|
4379
|
+
return this._databaseRoot;
|
|
4380
|
+
}
|
|
4088
4381
|
get _automergeInfo() {
|
|
4089
4382
|
return {
|
|
4090
4383
|
rootUrl: this._automergeSpaceState.rootUrl,
|
|
@@ -4101,14 +4394,18 @@ var DataSpace = class {
|
|
|
4101
4394
|
await this._gossip.open();
|
|
4102
4395
|
await this._notarizationPlugin.open();
|
|
4103
4396
|
await this._inner.spaceState.addCredentialProcessor(this._notarizationPlugin);
|
|
4397
|
+
await this._automergeSpaceState.open();
|
|
4104
4398
|
await this._inner.spaceState.addCredentialProcessor(this._automergeSpaceState);
|
|
4105
|
-
await this._inner.open(new Context8(
|
|
4399
|
+
await this._inner.open(new Context8(void 0, {
|
|
4400
|
+
F: __dxlog_file18,
|
|
4401
|
+
L: 215
|
|
4402
|
+
}));
|
|
4106
4403
|
this._state = SpaceState2.CONTROL_ONLY;
|
|
4107
|
-
|
|
4404
|
+
log15("new state", {
|
|
4108
4405
|
state: SpaceState2[this._state]
|
|
4109
4406
|
}, {
|
|
4110
|
-
F:
|
|
4111
|
-
L:
|
|
4407
|
+
F: __dxlog_file18,
|
|
4408
|
+
L: 217,
|
|
4112
4409
|
S: this,
|
|
4113
4410
|
C: (f, a) => f(...a)
|
|
4114
4411
|
});
|
|
@@ -4122,19 +4419,23 @@ var DataSpace = class {
|
|
|
4122
4419
|
async _close() {
|
|
4123
4420
|
await this._callbacks.beforeClose?.();
|
|
4124
4421
|
this._state = SpaceState2.CLOSED;
|
|
4125
|
-
|
|
4422
|
+
log15("new state", {
|
|
4126
4423
|
state: SpaceState2[this._state]
|
|
4127
4424
|
}, {
|
|
4128
|
-
F:
|
|
4129
|
-
L:
|
|
4425
|
+
F: __dxlog_file18,
|
|
4426
|
+
L: 231,
|
|
4130
4427
|
S: this,
|
|
4131
4428
|
C: (f, a) => f(...a)
|
|
4132
4429
|
});
|
|
4133
4430
|
await this._ctx.dispose();
|
|
4134
|
-
this._ctx = new Context8(
|
|
4431
|
+
this._ctx = new Context8(void 0, {
|
|
4432
|
+
F: __dxlog_file18,
|
|
4433
|
+
L: 233
|
|
4434
|
+
});
|
|
4135
4435
|
await this.authVerifier.close();
|
|
4136
4436
|
await this._inner.close();
|
|
4137
4437
|
await this._inner.spaceState.removeCredentialProcessor(this._automergeSpaceState);
|
|
4438
|
+
await this._automergeSpaceState.close();
|
|
4138
4439
|
await this._inner.spaceState.removeCredentialProcessor(this._notarizationPlugin);
|
|
4139
4440
|
await this._notarizationPlugin.close();
|
|
4140
4441
|
await this._presence.close();
|
|
@@ -4156,26 +4457,26 @@ var DataSpace = class {
|
|
|
4156
4457
|
await this.initializeDataPipeline();
|
|
4157
4458
|
} catch (err) {
|
|
4158
4459
|
if (err instanceof CancelledError || err instanceof ContextDisposedError3) {
|
|
4159
|
-
|
|
4160
|
-
F:
|
|
4161
|
-
L:
|
|
4460
|
+
log15("data pipeline initialization cancelled", err, {
|
|
4461
|
+
F: __dxlog_file18,
|
|
4462
|
+
L: 265,
|
|
4162
4463
|
S: this,
|
|
4163
4464
|
C: (f, a) => f(...a)
|
|
4164
4465
|
});
|
|
4165
4466
|
return;
|
|
4166
4467
|
}
|
|
4167
|
-
|
|
4168
|
-
F:
|
|
4169
|
-
L:
|
|
4468
|
+
log15.error("Error initializing data pipeline", err, {
|
|
4469
|
+
F: __dxlog_file18,
|
|
4470
|
+
L: 269,
|
|
4170
4471
|
S: this,
|
|
4171
4472
|
C: (f, a) => f(...a)
|
|
4172
4473
|
});
|
|
4173
4474
|
this._state = SpaceState2.ERROR;
|
|
4174
|
-
|
|
4475
|
+
log15("new state", {
|
|
4175
4476
|
state: SpaceState2[this._state]
|
|
4176
4477
|
}, {
|
|
4177
|
-
F:
|
|
4178
|
-
L:
|
|
4478
|
+
F: __dxlog_file18,
|
|
4479
|
+
L: 271,
|
|
4179
4480
|
S: this,
|
|
4180
4481
|
C: (f, a) => f(...a)
|
|
4181
4482
|
});
|
|
@@ -4191,31 +4492,28 @@ var DataSpace = class {
|
|
|
4191
4492
|
throw new SystemError("Invalid operation");
|
|
4192
4493
|
}
|
|
4193
4494
|
this._state = SpaceState2.INITIALIZING;
|
|
4194
|
-
|
|
4495
|
+
log15("new state", {
|
|
4195
4496
|
state: SpaceState2[this._state]
|
|
4196
4497
|
}, {
|
|
4197
|
-
F:
|
|
4198
|
-
L:
|
|
4498
|
+
F: __dxlog_file18,
|
|
4499
|
+
L: 287,
|
|
4199
4500
|
S: this,
|
|
4200
4501
|
C: (f, a) => f(...a)
|
|
4201
4502
|
});
|
|
4202
4503
|
await this._initializeAndReadControlPipeline();
|
|
4203
|
-
await
|
|
4504
|
+
await sleep3(1);
|
|
4505
|
+
const ready = this.stateUpdate.waitForCondition(() => this._state === SpaceState2.READY);
|
|
4204
4506
|
this._automergeSpaceState.startProcessingRootDocs();
|
|
4205
|
-
await
|
|
4206
|
-
|
|
4207
|
-
|
|
4208
|
-
L: 290,
|
|
4209
|
-
S: this,
|
|
4210
|
-
C: (f, a) => f(...a)
|
|
4211
|
-
});
|
|
4507
|
+
await ready;
|
|
4508
|
+
}
|
|
4509
|
+
async _enterReadyState() {
|
|
4212
4510
|
await this._callbacks.beforeReady?.();
|
|
4213
4511
|
this._state = SpaceState2.READY;
|
|
4214
|
-
|
|
4512
|
+
log15("new state", {
|
|
4215
4513
|
state: SpaceState2[this._state]
|
|
4216
4514
|
}, {
|
|
4217
|
-
F:
|
|
4218
|
-
L:
|
|
4515
|
+
F: __dxlog_file18,
|
|
4516
|
+
L: 306,
|
|
4219
4517
|
S: this,
|
|
4220
4518
|
C: (f, a) => f(...a)
|
|
4221
4519
|
});
|
|
@@ -4229,9 +4527,9 @@ var DataSpace = class {
|
|
|
4229
4527
|
});
|
|
4230
4528
|
this.metrics.controlPipelineReady = /* @__PURE__ */ new Date();
|
|
4231
4529
|
await this._createWritableFeeds();
|
|
4232
|
-
|
|
4233
|
-
F:
|
|
4234
|
-
L:
|
|
4530
|
+
log15("writable feeds created", void 0, {
|
|
4531
|
+
F: __dxlog_file18,
|
|
4532
|
+
L: 322,
|
|
4235
4533
|
S: this,
|
|
4236
4534
|
C: (f, a) => f(...a)
|
|
4237
4535
|
});
|
|
@@ -4289,57 +4587,66 @@ var DataSpace = class {
|
|
|
4289
4587
|
}
|
|
4290
4588
|
}
|
|
4291
4589
|
_onNewAutomergeRoot(rootUrl) {
|
|
4292
|
-
|
|
4590
|
+
log15("loading automerge root doc for space", {
|
|
4293
4591
|
space: this.key,
|
|
4294
4592
|
rootUrl
|
|
4295
4593
|
}, {
|
|
4296
|
-
F:
|
|
4297
|
-
L:
|
|
4594
|
+
F: __dxlog_file18,
|
|
4595
|
+
L: 388,
|
|
4298
4596
|
S: this,
|
|
4299
4597
|
C: (f, a) => f(...a)
|
|
4300
4598
|
});
|
|
4301
|
-
this._echoHost.replicateDocument(rootUrl);
|
|
4302
4599
|
const handle = this._echoHost.automergeRepo.find(rootUrl);
|
|
4303
4600
|
queueMicrotask(async () => {
|
|
4304
4601
|
try {
|
|
4305
|
-
|
|
4306
|
-
|
|
4307
|
-
|
|
4308
|
-
|
|
4309
|
-
return;
|
|
4310
|
-
}
|
|
4311
|
-
const doc = handle.docSync() ?? failedInvariant();
|
|
4312
|
-
if (!doc.access?.spaceKey) {
|
|
4313
|
-
handle.change((doc2) => {
|
|
4314
|
-
doc2.access = {
|
|
4315
|
-
spaceKey: this.key.toHex()
|
|
4316
|
-
};
|
|
4317
|
-
});
|
|
4318
|
-
}
|
|
4319
|
-
if (!this._echoHost.roots.has(handle.documentId)) {
|
|
4320
|
-
await this._echoHost.openSpaceRoot(handle.url);
|
|
4321
|
-
} else {
|
|
4322
|
-
log13.warn("echo database root already exists", {
|
|
4323
|
-
space: this.key,
|
|
4324
|
-
rootUrl
|
|
4325
|
-
}, {
|
|
4326
|
-
F: __dxlog_file16,
|
|
4327
|
-
L: 403,
|
|
4328
|
-
S: this,
|
|
4329
|
-
C: (f, a) => f(...a)
|
|
4602
|
+
try {
|
|
4603
|
+
var _usingCtx = _using_ctx();
|
|
4604
|
+
await warnAfterTimeout(5e3, "Automerge root doc load timeout (DataSpace)", async () => {
|
|
4605
|
+
await cancelWithContext4(this._ctx, handle.whenReady());
|
|
4330
4606
|
});
|
|
4607
|
+
if (this._ctx.disposed) {
|
|
4608
|
+
return;
|
|
4609
|
+
}
|
|
4610
|
+
const _guard = (
|
|
4611
|
+
// Ensure only one root is processed at a time.
|
|
4612
|
+
_usingCtx.u(await this._epochProcessingMutex.acquire())
|
|
4613
|
+
);
|
|
4614
|
+
const doc = handle.docSync() ?? failedInvariant();
|
|
4615
|
+
if (!doc.access?.spaceKey) {
|
|
4616
|
+
handle.change((doc2) => {
|
|
4617
|
+
doc2.access = {
|
|
4618
|
+
spaceKey: this.key.toHex()
|
|
4619
|
+
};
|
|
4620
|
+
});
|
|
4621
|
+
}
|
|
4622
|
+
const root = await this._echoHost.openSpaceRoot(handle.url);
|
|
4623
|
+
this._databaseRoot = root;
|
|
4624
|
+
if (root.getVersion() !== SpaceDocVersion2.CURRENT) {
|
|
4625
|
+
if (this._state !== SpaceState2.REQUIRES_MIGRATION) {
|
|
4626
|
+
this._state = SpaceState2.REQUIRES_MIGRATION;
|
|
4627
|
+
this.stateUpdate.emit();
|
|
4628
|
+
}
|
|
4629
|
+
} else {
|
|
4630
|
+
if (this._state !== SpaceState2.READY) {
|
|
4631
|
+
await this._enterReadyState();
|
|
4632
|
+
}
|
|
4633
|
+
}
|
|
4634
|
+
} catch (_) {
|
|
4635
|
+
_usingCtx.e = _;
|
|
4636
|
+
} finally {
|
|
4637
|
+
_usingCtx.d();
|
|
4331
4638
|
}
|
|
4332
4639
|
} catch (err) {
|
|
4333
4640
|
if (err instanceof ContextDisposedError3) {
|
|
4334
4641
|
return;
|
|
4335
4642
|
}
|
|
4336
|
-
|
|
4643
|
+
log15.warn("error loading automerge root doc", {
|
|
4337
4644
|
space: this.key,
|
|
4338
4645
|
rootUrl,
|
|
4339
4646
|
err
|
|
4340
4647
|
}, {
|
|
4341
|
-
F:
|
|
4342
|
-
L:
|
|
4648
|
+
F: __dxlog_file18,
|
|
4649
|
+
L: 433,
|
|
4343
4650
|
S: this,
|
|
4344
4651
|
C: (f, a) => f(...a)
|
|
4345
4652
|
});
|
|
@@ -4362,148 +4669,34 @@ var DataSpace = class {
|
|
|
4362
4669
|
});
|
|
4363
4670
|
}
|
|
4364
4671
|
async createEpoch(options) {
|
|
4365
|
-
|
|
4366
|
-
|
|
4367
|
-
|
|
4368
|
-
case CreateEpochRequest.Migration.NONE:
|
|
4369
|
-
{
|
|
4370
|
-
epoch = {
|
|
4371
|
-
previousId: this._automergeSpaceState.lastEpoch?.id,
|
|
4372
|
-
number: (this._automergeSpaceState.lastEpoch?.subject.assertion.number ?? -1) + 1,
|
|
4373
|
-
timeframe: this._automergeSpaceState.lastEpoch?.subject.assertion.timeframe ?? new Timeframe3(),
|
|
4374
|
-
automergeRoot: this._automergeSpaceState.lastEpoch?.subject.assertion?.automergeRoot
|
|
4375
|
-
};
|
|
4376
|
-
}
|
|
4377
|
-
break;
|
|
4378
|
-
case CreateEpochRequest.Migration.INIT_AUTOMERGE:
|
|
4379
|
-
{
|
|
4380
|
-
const document = this._echoHost.automergeRepo.create();
|
|
4381
|
-
epoch = {
|
|
4382
|
-
previousId: this._automergeSpaceState.lastEpoch?.id,
|
|
4383
|
-
number: (this._automergeSpaceState.lastEpoch?.subject.assertion.number ?? -1) + 1,
|
|
4384
|
-
timeframe: this._automergeSpaceState.lastEpoch?.subject.assertion.timeframe ?? new Timeframe3(),
|
|
4385
|
-
automergeRoot: document.url
|
|
4386
|
-
};
|
|
4387
|
-
}
|
|
4388
|
-
break;
|
|
4389
|
-
case CreateEpochRequest.Migration.PRUNE_AUTOMERGE_ROOT_HISTORY:
|
|
4390
|
-
{
|
|
4391
|
-
const currentRootUrl = this._automergeSpaceState.rootUrl;
|
|
4392
|
-
const rootHandle = this._echoHost.automergeRepo.find(currentRootUrl);
|
|
4393
|
-
await cancelWithContext4(this._ctx, asyncTimeout2(rootHandle.whenReady(), 1e4));
|
|
4394
|
-
const newRoot = this._echoHost.automergeRepo.create(rootHandle.docSync());
|
|
4395
|
-
await this._echoHost.automergeRepo.flush([
|
|
4396
|
-
newRoot.documentId
|
|
4397
|
-
]);
|
|
4398
|
-
invariant13(typeof newRoot.url === "string" && newRoot.url.length > 0, void 0, {
|
|
4399
|
-
F: __dxlog_file16,
|
|
4400
|
-
L: 460,
|
|
4401
|
-
S: this,
|
|
4402
|
-
A: [
|
|
4403
|
-
"typeof newRoot.url === 'string' && newRoot.url.length > 0",
|
|
4404
|
-
""
|
|
4405
|
-
]
|
|
4406
|
-
});
|
|
4407
|
-
epoch = {
|
|
4408
|
-
previousId: this._automergeSpaceState.lastEpoch?.id,
|
|
4409
|
-
number: (this._automergeSpaceState.lastEpoch?.subject.assertion.number ?? -1) + 1,
|
|
4410
|
-
timeframe: this._automergeSpaceState.lastEpoch?.subject.assertion.timeframe ?? new Timeframe3(),
|
|
4411
|
-
automergeRoot: newRoot.url
|
|
4412
|
-
};
|
|
4413
|
-
}
|
|
4414
|
-
break;
|
|
4415
|
-
case CreateEpochRequest.Migration.FRAGMENT_AUTOMERGE_ROOT:
|
|
4416
|
-
{
|
|
4417
|
-
log13.info("Fragmenting", void 0, {
|
|
4418
|
-
F: __dxlog_file16,
|
|
4419
|
-
L: 472,
|
|
4420
|
-
S: this,
|
|
4421
|
-
C: (f, a) => f(...a)
|
|
4422
|
-
});
|
|
4423
|
-
const currentRootUrl = this._automergeSpaceState.rootUrl;
|
|
4424
|
-
const rootHandle = this._echoHost.automergeRepo.find(currentRootUrl);
|
|
4425
|
-
await cancelWithContext4(this._ctx, asyncTimeout2(rootHandle.whenReady(), 1e4));
|
|
4426
|
-
const objects = Object.entries(rootHandle.docSync().objects);
|
|
4427
|
-
const properties = findPropertiesObject(rootHandle.docSync());
|
|
4428
|
-
const otherObjects = objects.filter(([key]) => key !== properties?.[0]);
|
|
4429
|
-
invariant13(properties, "Properties not found", {
|
|
4430
|
-
F: __dxlog_file16,
|
|
4431
|
-
L: 482,
|
|
4432
|
-
S: this,
|
|
4433
|
-
A: [
|
|
4434
|
-
"properties",
|
|
4435
|
-
"'Properties not found'"
|
|
4436
|
-
]
|
|
4437
|
-
});
|
|
4438
|
-
const newSpaceDoc = {
|
|
4439
|
-
...rootHandle.docSync(),
|
|
4440
|
-
objects: Object.fromEntries([
|
|
4441
|
-
properties
|
|
4442
|
-
])
|
|
4443
|
-
};
|
|
4444
|
-
const newRoot = this._echoHost.automergeRepo.create(newSpaceDoc);
|
|
4445
|
-
invariant13(typeof newRoot.url === "string" && newRoot.url.length > 0, void 0, {
|
|
4446
|
-
F: __dxlog_file16,
|
|
4447
|
-
L: 487,
|
|
4448
|
-
S: this,
|
|
4449
|
-
A: [
|
|
4450
|
-
"typeof newRoot.url === 'string' && newRoot.url.length > 0",
|
|
4451
|
-
""
|
|
4452
|
-
]
|
|
4453
|
-
});
|
|
4454
|
-
const docLoader = new AutomergeDocumentLoaderImpl(await createIdFromSpaceKey(this.key), this._echoHost.automergeRepo, this.key);
|
|
4455
|
-
await docLoader.loadSpaceRootDocHandle(this._ctx, {
|
|
4456
|
-
rootUrl: newRoot.url
|
|
4457
|
-
});
|
|
4458
|
-
otherObjects.forEach(([key, value]) => {
|
|
4459
|
-
const handle = docLoader.createDocumentForObject(key);
|
|
4460
|
-
handle.change((doc) => {
|
|
4461
|
-
assignDeep(doc, [
|
|
4462
|
-
"objects",
|
|
4463
|
-
key
|
|
4464
|
-
], value);
|
|
4465
|
-
});
|
|
4466
|
-
});
|
|
4467
|
-
epoch = {
|
|
4468
|
-
previousId: this._automergeSpaceState.lastEpoch?.id,
|
|
4469
|
-
number: (this._automergeSpaceState.lastEpoch?.subject.assertion.number ?? -1) + 1,
|
|
4470
|
-
timeframe: this._automergeSpaceState.lastEpoch?.subject.assertion.timeframe ?? new Timeframe3(),
|
|
4471
|
-
automergeRoot: newRoot.url
|
|
4472
|
-
};
|
|
4473
|
-
}
|
|
4474
|
-
break;
|
|
4475
|
-
case CreateEpochRequest.Migration.REPLACE_AUTOMERGE_ROOT:
|
|
4476
|
-
{
|
|
4477
|
-
invariant13(options.newAutomergeRoot, void 0, {
|
|
4478
|
-
F: __dxlog_file16,
|
|
4479
|
-
L: 517,
|
|
4480
|
-
S: this,
|
|
4481
|
-
A: [
|
|
4482
|
-
"options.newAutomergeRoot",
|
|
4483
|
-
""
|
|
4484
|
-
]
|
|
4485
|
-
});
|
|
4486
|
-
epoch = {
|
|
4487
|
-
previousId: this._automergeSpaceState.lastEpoch?.id,
|
|
4488
|
-
number: (this._automergeSpaceState.lastEpoch?.subject.assertion.number ?? -1) + 1,
|
|
4489
|
-
timeframe: this._automergeSpaceState.lastEpoch?.subject.assertion.timeframe ?? new Timeframe3(),
|
|
4490
|
-
automergeRoot: options.newAutomergeRoot
|
|
4491
|
-
};
|
|
4492
|
-
}
|
|
4493
|
-
break;
|
|
4494
|
-
}
|
|
4495
|
-
if (!epoch) {
|
|
4496
|
-
return;
|
|
4672
|
+
const ctx = this._ctx.derive();
|
|
4673
|
+
if (!options?.migration) {
|
|
4674
|
+
return null;
|
|
4497
4675
|
}
|
|
4676
|
+
const { newRoot } = await runEpochMigration(ctx, {
|
|
4677
|
+
echoHost: this._echoHost,
|
|
4678
|
+
spaceId: this.id,
|
|
4679
|
+
spaceKey: this.key,
|
|
4680
|
+
migration: options.migration,
|
|
4681
|
+
currentRoot: this._automergeSpaceState.rootUrl ?? null,
|
|
4682
|
+
newAutomergeRoot: options.newAutomergeRoot
|
|
4683
|
+
});
|
|
4684
|
+
const epoch = {
|
|
4685
|
+
previousId: this._automergeSpaceState.lastEpoch?.id,
|
|
4686
|
+
number: (this._automergeSpaceState.lastEpoch?.subject.assertion.number ?? -1) + 1,
|
|
4687
|
+
timeframe: this._automergeSpaceState.lastEpoch?.subject.assertion.timeframe ?? new Timeframe3(),
|
|
4688
|
+
automergeRoot: newRoot ?? this._automergeSpaceState.rootUrl
|
|
4689
|
+
};
|
|
4690
|
+
const credential = await this._signingContext.credentialSigner.createCredential({
|
|
4691
|
+
subject: this.key,
|
|
4692
|
+
assertion: {
|
|
4693
|
+
"@type": "dxos.halo.credentials.Epoch",
|
|
4694
|
+
...epoch
|
|
4695
|
+
}
|
|
4696
|
+
});
|
|
4498
4697
|
const receipt = await this.inner.controlPipeline.writer.write({
|
|
4499
4698
|
credential: {
|
|
4500
|
-
credential
|
|
4501
|
-
subject: this.key,
|
|
4502
|
-
assertion: {
|
|
4503
|
-
"@type": "dxos.halo.credentials.Epoch",
|
|
4504
|
-
...epoch
|
|
4505
|
-
}
|
|
4506
|
-
})
|
|
4699
|
+
credential
|
|
4507
4700
|
}
|
|
4508
4701
|
});
|
|
4509
4702
|
await this.inner.controlPipeline.state.waitUntilTimeframe(new Timeframe3([
|
|
@@ -4513,6 +4706,7 @@ var DataSpace = class {
|
|
|
4513
4706
|
]
|
|
4514
4707
|
]));
|
|
4515
4708
|
await this._echoHost.updateIndexes();
|
|
4709
|
+
return credential;
|
|
4516
4710
|
}
|
|
4517
4711
|
async activate() {
|
|
4518
4712
|
if (![
|
|
@@ -4534,11 +4728,11 @@ var DataSpace = class {
|
|
|
4534
4728
|
await this._close();
|
|
4535
4729
|
}
|
|
4536
4730
|
this._state = SpaceState2.INACTIVE;
|
|
4537
|
-
|
|
4731
|
+
log15("new state", {
|
|
4538
4732
|
state: SpaceState2[this._state]
|
|
4539
4733
|
}, {
|
|
4540
|
-
F:
|
|
4541
|
-
L:
|
|
4734
|
+
F: __dxlog_file18,
|
|
4735
|
+
L: 514,
|
|
4542
4736
|
S: this,
|
|
4543
4737
|
C: (f, a) => f(...a)
|
|
4544
4738
|
});
|
|
@@ -4593,36 +4787,27 @@ DataSpace = _ts_decorate4([
|
|
|
4593
4787
|
trackLeaks("open", "close"),
|
|
4594
4788
|
trace6.resource()
|
|
4595
4789
|
], DataSpace);
|
|
4596
|
-
var findPropertiesObject = (spaceDoc) => {
|
|
4597
|
-
for (const id in spaceDoc.objects ?? {}) {
|
|
4598
|
-
const obj = spaceDoc.objects[id];
|
|
4599
|
-
if (obj.system.type?.itemId === TYPE_PROPERTIES) {
|
|
4600
|
-
return [
|
|
4601
|
-
id,
|
|
4602
|
-
obj
|
|
4603
|
-
];
|
|
4604
|
-
}
|
|
4605
|
-
}
|
|
4606
|
-
return void 0;
|
|
4607
|
-
};
|
|
4608
4790
|
|
|
4609
4791
|
// packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts
|
|
4610
4792
|
import { Event as Event7, synchronized as synchronized2, trackLeaks as trackLeaks2 } from "@dxos/async";
|
|
4611
4793
|
import { PropertiesType } from "@dxos/client-protocol";
|
|
4612
|
-
import {
|
|
4613
|
-
import { getCredentialAssertion as getCredentialAssertion3 } from "@dxos/credentials";
|
|
4794
|
+
import { Context as Context9, cancelWithContext as cancelWithContext5 } from "@dxos/context";
|
|
4795
|
+
import { getCredentialAssertion as getCredentialAssertion3, createAdmissionCredentials } from "@dxos/credentials";
|
|
4796
|
+
import { convertLegacyReferences as convertLegacyReferences2, findInlineObjectOfType as findInlineObjectOfType2 } from "@dxos/echo-db";
|
|
4614
4797
|
import { AuthStatus } from "@dxos/echo-pipeline";
|
|
4615
|
-
import {
|
|
4616
|
-
import {
|
|
4798
|
+
import { CredentialServerExtension } from "@dxos/echo-pipeline";
|
|
4799
|
+
import { LEGACY_TYPE_PROPERTIES, SpaceDocVersion as SpaceDocVersion3, encodeReference } from "@dxos/echo-protocol";
|
|
4800
|
+
import { TYPE_PROPERTIES as TYPE_PROPERTIES2, generateEchoId, getTypeReference } from "@dxos/echo-schema";
|
|
4801
|
+
import { writeMessages as writeMessages3 } from "@dxos/feed-store";
|
|
4617
4802
|
import { invariant as invariant14 } from "@dxos/invariant";
|
|
4618
4803
|
import { PublicKey as PublicKey11 } from "@dxos/keys";
|
|
4619
|
-
import { log as
|
|
4620
|
-
import { trace as Trace2 } from "@dxos/protocols";
|
|
4804
|
+
import { log as log16 } from "@dxos/log";
|
|
4805
|
+
import { trace as Trace2, AlreadyJoinedError as AlreadyJoinedError3 } from "@dxos/protocols";
|
|
4621
4806
|
import { Invitation as Invitation7, SpaceState as SpaceState3 } from "@dxos/protocols/proto/dxos/client/services";
|
|
4622
4807
|
import { SpaceMember as SpaceMember6 } from "@dxos/protocols/proto/dxos/halo/credentials";
|
|
4623
4808
|
import { Gossip as Gossip2, Presence as Presence2 } from "@dxos/teleport-extension-gossip";
|
|
4624
4809
|
import { trace as trace7 } from "@dxos/tracing";
|
|
4625
|
-
import {
|
|
4810
|
+
import { ComplexMap as ComplexMap3, assignDeep, deferFunction as deferFunction2, forEachAsync } from "@dxos/util";
|
|
4626
4811
|
|
|
4627
4812
|
// packages/sdk/client-services/src/packlets/spaces/genesis.ts
|
|
4628
4813
|
import { createCredential } from "@dxos/credentials";
|
|
@@ -4705,7 +4890,7 @@ function _ts_decorate5(decorators, target, key, desc) {
|
|
|
4705
4890
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
4706
4891
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4707
4892
|
}
|
|
4708
|
-
var
|
|
4893
|
+
var __dxlog_file19 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts";
|
|
4709
4894
|
var PRESENCE_ANNOUNCE_INTERVAL = 1e4;
|
|
4710
4895
|
var PRESENCE_OFFLINE_TIMEOUT = 2e4;
|
|
4711
4896
|
var DEFAULT_SPACE_KEY = "__DEFAULT__";
|
|
@@ -4719,7 +4904,10 @@ var DataSpaceManager = class {
|
|
|
4719
4904
|
this._echoHost = _echoHost;
|
|
4720
4905
|
this._invitationsManager = _invitationsManager;
|
|
4721
4906
|
this._params = _params;
|
|
4722
|
-
this._ctx = new Context9(
|
|
4907
|
+
this._ctx = new Context9(void 0, {
|
|
4908
|
+
F: __dxlog_file19,
|
|
4909
|
+
L: 104
|
|
4910
|
+
});
|
|
4723
4911
|
this.updated = new Event7();
|
|
4724
4912
|
this._spaces = new ComplexMap3(PublicKey11.hash);
|
|
4725
4913
|
this._isOpen = false;
|
|
@@ -4732,7 +4920,7 @@ var DataSpaceManager = class {
|
|
|
4732
4920
|
const rootUrl = space.automergeSpaceState.rootUrl;
|
|
4733
4921
|
const rootHandle = rootUrl ? this._echoHost.automergeRepo.find(rootUrl) : void 0;
|
|
4734
4922
|
const rootDoc = rootHandle?.docSync();
|
|
4735
|
-
const properties = rootDoc &&
|
|
4923
|
+
const properties = rootDoc && findInlineObjectOfType2(rootDoc, TYPE_PROPERTIES2);
|
|
4736
4924
|
return {
|
|
4737
4925
|
key: space.key.toHex(),
|
|
4738
4926
|
state: SpaceState3[space.state],
|
|
@@ -4752,46 +4940,46 @@ var DataSpaceManager = class {
|
|
|
4752
4940
|
return this._spaces;
|
|
4753
4941
|
}
|
|
4754
4942
|
async open() {
|
|
4755
|
-
|
|
4756
|
-
F:
|
|
4757
|
-
L:
|
|
4943
|
+
log16("open", void 0, {
|
|
4944
|
+
F: __dxlog_file19,
|
|
4945
|
+
L: 156,
|
|
4758
4946
|
S: this,
|
|
4759
4947
|
C: (f, a) => f(...a)
|
|
4760
4948
|
});
|
|
4761
|
-
|
|
4949
|
+
log16.trace("dxos.echo.data-space-manager.open", Trace2.begin({
|
|
4762
4950
|
id: this._instanceId
|
|
4763
4951
|
}), {
|
|
4764
|
-
F:
|
|
4765
|
-
L:
|
|
4952
|
+
F: __dxlog_file19,
|
|
4953
|
+
L: 157,
|
|
4766
4954
|
S: this,
|
|
4767
4955
|
C: (f, a) => f(...a)
|
|
4768
4956
|
});
|
|
4769
|
-
|
|
4957
|
+
log16("metadata loaded", {
|
|
4770
4958
|
spaces: this._metadataStore.spaces.length
|
|
4771
4959
|
}, {
|
|
4772
|
-
F:
|
|
4773
|
-
L:
|
|
4960
|
+
F: __dxlog_file19,
|
|
4961
|
+
L: 158,
|
|
4774
4962
|
S: this,
|
|
4775
4963
|
C: (f, a) => f(...a)
|
|
4776
4964
|
});
|
|
4777
4965
|
await forEachAsync(this._metadataStore.spaces, async (spaceMetadata) => {
|
|
4778
4966
|
try {
|
|
4779
|
-
|
|
4967
|
+
log16("load space", {
|
|
4780
4968
|
spaceMetadata
|
|
4781
4969
|
}, {
|
|
4782
|
-
F:
|
|
4783
|
-
L:
|
|
4970
|
+
F: __dxlog_file19,
|
|
4971
|
+
L: 162,
|
|
4784
4972
|
S: this,
|
|
4785
4973
|
C: (f, a) => f(...a)
|
|
4786
4974
|
});
|
|
4787
4975
|
await this._constructSpace(spaceMetadata);
|
|
4788
4976
|
} catch (err) {
|
|
4789
|
-
|
|
4977
|
+
log16.error("Error loading space", {
|
|
4790
4978
|
spaceMetadata,
|
|
4791
4979
|
err
|
|
4792
4980
|
}, {
|
|
4793
|
-
F:
|
|
4794
|
-
L:
|
|
4981
|
+
F: __dxlog_file19,
|
|
4982
|
+
L: 165,
|
|
4795
4983
|
S: this,
|
|
4796
4984
|
C: (f, a) => f(...a)
|
|
4797
4985
|
});
|
|
@@ -4799,19 +4987,19 @@ var DataSpaceManager = class {
|
|
|
4799
4987
|
});
|
|
4800
4988
|
this._isOpen = true;
|
|
4801
4989
|
this.updated.emit();
|
|
4802
|
-
|
|
4990
|
+
log16.trace("dxos.echo.data-space-manager.open", Trace2.end({
|
|
4803
4991
|
id: this._instanceId
|
|
4804
4992
|
}), {
|
|
4805
|
-
F:
|
|
4806
|
-
L:
|
|
4993
|
+
F: __dxlog_file19,
|
|
4994
|
+
L: 172,
|
|
4807
4995
|
S: this,
|
|
4808
4996
|
C: (f, a) => f(...a)
|
|
4809
4997
|
});
|
|
4810
4998
|
}
|
|
4811
4999
|
async close() {
|
|
4812
|
-
|
|
4813
|
-
F:
|
|
4814
|
-
L:
|
|
5000
|
+
log16("close", void 0, {
|
|
5001
|
+
F: __dxlog_file19,
|
|
5002
|
+
L: 177,
|
|
4815
5003
|
S: this,
|
|
4816
5004
|
C: (f, a) => f(...a)
|
|
4817
5005
|
});
|
|
@@ -4827,8 +5015,8 @@ var DataSpaceManager = class {
|
|
|
4827
5015
|
*/
|
|
4828
5016
|
async createSpace() {
|
|
4829
5017
|
invariant14(this._isOpen, "Not open.", {
|
|
4830
|
-
F:
|
|
4831
|
-
L:
|
|
5018
|
+
F: __dxlog_file19,
|
|
5019
|
+
L: 191,
|
|
4832
5020
|
S: this,
|
|
4833
5021
|
A: [
|
|
4834
5022
|
"this._isOpen",
|
|
@@ -4845,11 +5033,11 @@ var DataSpaceManager = class {
|
|
|
4845
5033
|
dataFeedKey,
|
|
4846
5034
|
state: SpaceState3.ACTIVE
|
|
4847
5035
|
};
|
|
4848
|
-
|
|
5036
|
+
log16("creating space...", {
|
|
4849
5037
|
spaceKey
|
|
4850
5038
|
}, {
|
|
4851
|
-
F:
|
|
4852
|
-
L:
|
|
5039
|
+
F: __dxlog_file19,
|
|
5040
|
+
L: 203,
|
|
4853
5041
|
S: this,
|
|
4854
5042
|
C: (f, a) => f(...a)
|
|
4855
5043
|
});
|
|
@@ -4860,8 +5048,8 @@ var DataSpaceManager = class {
|
|
|
4860
5048
|
await this._metadataStore.addSpace(metadata);
|
|
4861
5049
|
const memberCredential = credentials[1];
|
|
4862
5050
|
invariant14(getCredentialAssertion3(memberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
|
|
4863
|
-
F:
|
|
4864
|
-
L:
|
|
5051
|
+
F: __dxlog_file19,
|
|
5052
|
+
L: 213,
|
|
4865
5053
|
S: this,
|
|
4866
5054
|
A: [
|
|
4867
5055
|
"getCredentialAssertion(memberCredential)['@type'] === 'dxos.halo.credentials.SpaceMember'",
|
|
@@ -4874,9 +5062,31 @@ var DataSpaceManager = class {
|
|
|
4874
5062
|
return space;
|
|
4875
5063
|
}
|
|
4876
5064
|
async isDefaultSpace(space) {
|
|
4877
|
-
|
|
4878
|
-
|
|
4879
|
-
|
|
5065
|
+
if (!space.databaseRoot) {
|
|
5066
|
+
return false;
|
|
5067
|
+
}
|
|
5068
|
+
switch (space.databaseRoot.getVersion()) {
|
|
5069
|
+
case SpaceDocVersion3.CURRENT: {
|
|
5070
|
+
const [_, properties] = findInlineObjectOfType2(space.databaseRoot.docSync(), TYPE_PROPERTIES2) ?? [];
|
|
5071
|
+
return properties?.data?.[DEFAULT_SPACE_KEY] === this._signingContext.identityKey.toHex();
|
|
5072
|
+
}
|
|
5073
|
+
case SpaceDocVersion3.LEGACY: {
|
|
5074
|
+
const convertedDoc = await convertLegacyReferences2(space.databaseRoot.docSync());
|
|
5075
|
+
const [_, properties] = findInlineObjectOfType2(convertedDoc, LEGACY_TYPE_PROPERTIES) ?? [];
|
|
5076
|
+
return properties?.data?.[DEFAULT_SPACE_KEY] === this._signingContext.identityKey.toHex();
|
|
5077
|
+
}
|
|
5078
|
+
default:
|
|
5079
|
+
log16.warn("unknown space version", {
|
|
5080
|
+
version: space.databaseRoot.getVersion(),
|
|
5081
|
+
spaceId: space.id
|
|
5082
|
+
}, {
|
|
5083
|
+
F: __dxlog_file19,
|
|
5084
|
+
L: 238,
|
|
5085
|
+
S: this,
|
|
5086
|
+
C: (f, a) => f(...a)
|
|
5087
|
+
});
|
|
5088
|
+
return false;
|
|
5089
|
+
}
|
|
4880
5090
|
}
|
|
4881
5091
|
async createDefaultSpace() {
|
|
4882
5092
|
const space = await this.createSpace();
|
|
@@ -4892,9 +5102,9 @@ var DataSpaceManager = class {
|
|
|
4892
5102
|
keys: []
|
|
4893
5103
|
}
|
|
4894
5104
|
};
|
|
4895
|
-
const propertiesId =
|
|
5105
|
+
const propertiesId = generateEchoId();
|
|
4896
5106
|
document.change((doc) => {
|
|
4897
|
-
|
|
5107
|
+
assignDeep(doc, [
|
|
4898
5108
|
"objects",
|
|
4899
5109
|
propertiesId
|
|
4900
5110
|
], properties);
|
|
@@ -4905,8 +5115,8 @@ var DataSpaceManager = class {
|
|
|
4905
5115
|
async _getSpaceRootDocument(space) {
|
|
4906
5116
|
const automergeIndex = space.automergeSpaceState.rootUrl;
|
|
4907
5117
|
invariant14(automergeIndex, void 0, {
|
|
4908
|
-
F:
|
|
4909
|
-
L:
|
|
5118
|
+
F: __dxlog_file19,
|
|
5119
|
+
L: 271,
|
|
4910
5120
|
S: this,
|
|
4911
5121
|
A: [
|
|
4912
5122
|
"automergeIndex",
|
|
@@ -4919,17 +5129,17 @@ var DataSpaceManager = class {
|
|
|
4919
5129
|
}
|
|
4920
5130
|
// TODO(burdon): Rename join space.
|
|
4921
5131
|
async acceptSpace(opts) {
|
|
4922
|
-
|
|
5132
|
+
log16("accept space", {
|
|
4923
5133
|
opts
|
|
4924
5134
|
}, {
|
|
4925
|
-
F:
|
|
4926
|
-
L:
|
|
5135
|
+
F: __dxlog_file19,
|
|
5136
|
+
L: 280,
|
|
4927
5137
|
S: this,
|
|
4928
5138
|
C: (f, a) => f(...a)
|
|
4929
5139
|
});
|
|
4930
5140
|
invariant14(this._isOpen, "Not open.", {
|
|
4931
|
-
F:
|
|
4932
|
-
L:
|
|
5141
|
+
F: __dxlog_file19,
|
|
5142
|
+
L: 281,
|
|
4933
5143
|
S: this,
|
|
4934
5144
|
A: [
|
|
4935
5145
|
"this._isOpen",
|
|
@@ -4937,8 +5147,8 @@ var DataSpaceManager = class {
|
|
|
4937
5147
|
]
|
|
4938
5148
|
});
|
|
4939
5149
|
invariant14(!this._spaces.has(opts.spaceKey), "Space already exists.", {
|
|
4940
|
-
F:
|
|
4941
|
-
L:
|
|
5150
|
+
F: __dxlog_file19,
|
|
5151
|
+
L: 282,
|
|
4942
5152
|
S: this,
|
|
4943
5153
|
A: [
|
|
4944
5154
|
"!this._spaces.has(opts.spaceKey)",
|
|
@@ -4958,6 +5168,43 @@ var DataSpaceManager = class {
|
|
|
4958
5168
|
this.updated.emit();
|
|
4959
5169
|
return space;
|
|
4960
5170
|
}
|
|
5171
|
+
async admitMember(options) {
|
|
5172
|
+
const space = this._spaceManager.spaces.get(options.spaceKey);
|
|
5173
|
+
invariant14(space, void 0, {
|
|
5174
|
+
F: __dxlog_file19,
|
|
5175
|
+
L: 302,
|
|
5176
|
+
S: this,
|
|
5177
|
+
A: [
|
|
5178
|
+
"space",
|
|
5179
|
+
""
|
|
5180
|
+
]
|
|
5181
|
+
});
|
|
5182
|
+
if (space.spaceState.getMemberRole(options.identityKey) !== SpaceMember6.Role.REMOVED) {
|
|
5183
|
+
throw new AlreadyJoinedError3();
|
|
5184
|
+
}
|
|
5185
|
+
const credentials = await createAdmissionCredentials(this._signingContext.credentialSigner, options.identityKey, space.key, space.genesisFeedKey, options.role, space.spaceState.membershipChainHeads, options.profile, options.delegationCredentialId);
|
|
5186
|
+
invariant14(credentials[0].credential, void 0, {
|
|
5187
|
+
F: __dxlog_file19,
|
|
5188
|
+
L: 321,
|
|
5189
|
+
S: this,
|
|
5190
|
+
A: [
|
|
5191
|
+
"credentials[0].credential",
|
|
5192
|
+
""
|
|
5193
|
+
]
|
|
5194
|
+
});
|
|
5195
|
+
const spaceMemberCredential = credentials[0].credential.credential;
|
|
5196
|
+
invariant14(getCredentialAssertion3(spaceMemberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
|
|
5197
|
+
F: __dxlog_file19,
|
|
5198
|
+
L: 323,
|
|
5199
|
+
S: this,
|
|
5200
|
+
A: [
|
|
5201
|
+
"getCredentialAssertion(spaceMemberCredential)['@type'] === 'dxos.halo.credentials.SpaceMember'",
|
|
5202
|
+
""
|
|
5203
|
+
]
|
|
5204
|
+
});
|
|
5205
|
+
await writeMessages3(space.controlPipeline.writer, credentials);
|
|
5206
|
+
return spaceMemberCredential;
|
|
5207
|
+
}
|
|
4961
5208
|
/**
|
|
4962
5209
|
* Wait until the space data pipeline is fully initialized.
|
|
4963
5210
|
* Used by invitation handler.
|
|
@@ -4969,12 +5216,24 @@ var DataSpaceManager = class {
|
|
|
4969
5216
|
return !!space && space.state === SpaceState3.READY;
|
|
4970
5217
|
}));
|
|
4971
5218
|
}
|
|
5219
|
+
async requestSpaceAdmissionCredential(spaceKey) {
|
|
5220
|
+
return this._spaceManager.requestSpaceAdmissionCredential({
|
|
5221
|
+
spaceKey,
|
|
5222
|
+
identityKey: this._signingContext.identityKey,
|
|
5223
|
+
timeout: 15e3,
|
|
5224
|
+
swarmIdentity: {
|
|
5225
|
+
peerKey: this._signingContext.deviceKey,
|
|
5226
|
+
credentialProvider: createAuthProvider(this._signingContext.credentialSigner),
|
|
5227
|
+
credentialAuthenticator: async () => true
|
|
5228
|
+
}
|
|
5229
|
+
});
|
|
5230
|
+
}
|
|
4972
5231
|
async _constructSpace(metadata) {
|
|
4973
|
-
|
|
5232
|
+
log16("construct space", {
|
|
4974
5233
|
metadata
|
|
4975
5234
|
}, {
|
|
4976
|
-
F:
|
|
4977
|
-
L:
|
|
5235
|
+
F: __dxlog_file19,
|
|
5236
|
+
L: 358,
|
|
4978
5237
|
S: this,
|
|
4979
5238
|
C: (f, a) => f(...a)
|
|
4980
5239
|
});
|
|
@@ -5002,6 +5261,7 @@ var DataSpaceManager = class {
|
|
|
5002
5261
|
credentialAuthenticator: deferFunction2(() => dataSpace.authVerifier.verifier)
|
|
5003
5262
|
},
|
|
5004
5263
|
onAuthorizedConnection: (session) => {
|
|
5264
|
+
session.addExtension("dxos.mesh.teleport.admission-discovery", new CredentialServerExtension(space));
|
|
5005
5265
|
session.addExtension("dxos.mesh.teleport.gossip", gossip.createExtension({
|
|
5006
5266
|
remotePeerId: session.remotePeerId
|
|
5007
5267
|
}));
|
|
@@ -5010,9 +5270,9 @@ var DataSpaceManager = class {
|
|
|
5010
5270
|
session.addExtension("dxos.mesh.teleport.automerge", this._echoHost.createReplicationExtension());
|
|
5011
5271
|
},
|
|
5012
5272
|
onAuthFailure: () => {
|
|
5013
|
-
|
|
5014
|
-
F:
|
|
5015
|
-
L:
|
|
5273
|
+
log16.warn("auth failure", void 0, {
|
|
5274
|
+
F: __dxlog_file19,
|
|
5275
|
+
L: 396,
|
|
5016
5276
|
S: this,
|
|
5017
5277
|
C: (f, a) => f(...a)
|
|
5018
5278
|
});
|
|
@@ -5041,22 +5301,22 @@ var DataSpaceManager = class {
|
|
|
5041
5301
|
signingContext: this._signingContext,
|
|
5042
5302
|
callbacks: {
|
|
5043
5303
|
beforeReady: async () => {
|
|
5044
|
-
|
|
5304
|
+
log16("before space ready", {
|
|
5045
5305
|
space: space.key
|
|
5046
5306
|
}, {
|
|
5047
|
-
F:
|
|
5048
|
-
L:
|
|
5307
|
+
F: __dxlog_file19,
|
|
5308
|
+
L: 423,
|
|
5049
5309
|
S: this,
|
|
5050
5310
|
C: (f, a) => f(...a)
|
|
5051
5311
|
});
|
|
5052
5312
|
},
|
|
5053
5313
|
afterReady: async () => {
|
|
5054
|
-
|
|
5314
|
+
log16("after space ready", {
|
|
5055
5315
|
space: space.key,
|
|
5056
5316
|
open: this._isOpen
|
|
5057
5317
|
}, {
|
|
5058
|
-
F:
|
|
5059
|
-
L:
|
|
5318
|
+
F: __dxlog_file19,
|
|
5319
|
+
L: 426,
|
|
5060
5320
|
S: this,
|
|
5061
5321
|
C: (f, a) => f(...a)
|
|
5062
5322
|
});
|
|
@@ -5071,11 +5331,11 @@ var DataSpaceManager = class {
|
|
|
5071
5331
|
}
|
|
5072
5332
|
},
|
|
5073
5333
|
beforeClose: async () => {
|
|
5074
|
-
|
|
5334
|
+
log16("before space close", {
|
|
5075
5335
|
space: space.key
|
|
5076
5336
|
}, {
|
|
5077
|
-
F:
|
|
5078
|
-
L:
|
|
5337
|
+
F: __dxlog_file19,
|
|
5338
|
+
L: 434,
|
|
5079
5339
|
S: this,
|
|
5080
5340
|
C: (f, a) => f(...a)
|
|
5081
5341
|
});
|
|
@@ -5106,17 +5366,17 @@ var DataSpaceManager = class {
|
|
|
5106
5366
|
return (s && member.role === SpaceMember6.Role.REMOVED !== (s.authStatus === AuthStatus.FAILURE)) ?? false;
|
|
5107
5367
|
});
|
|
5108
5368
|
sessionsToClose.forEach((session) => {
|
|
5109
|
-
void session.close().catch(
|
|
5369
|
+
void session.close().catch(log16.error);
|
|
5110
5370
|
});
|
|
5111
5371
|
closedSessions += sessionsToClose.length;
|
|
5112
5372
|
}
|
|
5113
|
-
|
|
5373
|
+
log16("processed member role changes", {
|
|
5114
5374
|
roleChangeCount: memberInfo.length,
|
|
5115
5375
|
peersOnline: presence.getPeersOnline().length,
|
|
5116
5376
|
closedSessions
|
|
5117
5377
|
}, {
|
|
5118
|
-
F:
|
|
5119
|
-
L:
|
|
5378
|
+
F: __dxlog_file19,
|
|
5379
|
+
L: 470,
|
|
5120
5380
|
S: this,
|
|
5121
5381
|
C: (f, a) => f(...a)
|
|
5122
5382
|
});
|
|
@@ -5127,15 +5387,15 @@ var DataSpaceManager = class {
|
|
|
5127
5387
|
if (role === SpaceMember6.Role.REMOVED) {
|
|
5128
5388
|
const session = peerState.peerId && space.protocol.sessions.get(peerState.peerId);
|
|
5129
5389
|
if (session != null) {
|
|
5130
|
-
|
|
5390
|
+
log16("closing a session with a removed peer", {
|
|
5131
5391
|
peerId: peerState.peerId
|
|
5132
5392
|
}, {
|
|
5133
|
-
F:
|
|
5134
|
-
L:
|
|
5393
|
+
F: __dxlog_file19,
|
|
5394
|
+
L: 484,
|
|
5135
5395
|
S: this,
|
|
5136
5396
|
C: (f, a) => f(...a)
|
|
5137
5397
|
});
|
|
5138
|
-
void session.close().catch(
|
|
5398
|
+
void session.close().catch(log16.error);
|
|
5139
5399
|
}
|
|
5140
5400
|
}
|
|
5141
5401
|
}
|
|
@@ -5196,13 +5456,13 @@ import { EventSubscriptions as EventSubscriptions2, UpdateScheduler, scheduleTas
|
|
|
5196
5456
|
import { Stream as Stream10 } from "@dxos/codec-protobuf";
|
|
5197
5457
|
import { createAdmissionCredentials as createAdmissionCredentials2, getCredentialAssertion as getCredentialAssertion4 } from "@dxos/credentials";
|
|
5198
5458
|
import { raise as raise2 } from "@dxos/debug";
|
|
5199
|
-
import { writeMessages as
|
|
5459
|
+
import { writeMessages as writeMessages4 } from "@dxos/feed-store";
|
|
5200
5460
|
import { invariant as invariant15 } from "@dxos/invariant";
|
|
5201
|
-
import { log as
|
|
5461
|
+
import { log as log17 } from "@dxos/log";
|
|
5202
5462
|
import { ApiError, SpaceNotFoundError as SpaceNotFoundError2, encodeError, IdentityNotInitializedError, AuthorizationError as AuthorizationError2 } from "@dxos/protocols";
|
|
5203
5463
|
import { SpaceMember as SpaceMember7, SpaceState as SpaceState4 } from "@dxos/protocols/proto/dxos/client/services";
|
|
5204
5464
|
import { trace as trace8 } from "@dxos/tracing";
|
|
5205
|
-
var
|
|
5465
|
+
var __dxlog_file20 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/spaces-service.ts";
|
|
5206
5466
|
var SpacesServiceImpl = class {
|
|
5207
5467
|
constructor(_identityManager, _spaceManager, _getDataSpaceManager) {
|
|
5208
5468
|
this._identityManager = _identityManager;
|
|
@@ -5246,8 +5506,8 @@ var SpacesServiceImpl = class {
|
|
|
5246
5506
|
}
|
|
5247
5507
|
const credentials = await createAdmissionCredentials2(identity.getIdentityCredentialSigner(), request.memberKey, space.key, space.genesisFeedKey, request.newRole, space.spaceState.membershipChainHeads);
|
|
5248
5508
|
invariant15(credentials[0].credential, void 0, {
|
|
5249
|
-
F:
|
|
5250
|
-
L:
|
|
5509
|
+
F: __dxlog_file20,
|
|
5510
|
+
L: 102,
|
|
5251
5511
|
S: this,
|
|
5252
5512
|
A: [
|
|
5253
5513
|
"credentials[0].credential",
|
|
@@ -5256,26 +5516,26 @@ var SpacesServiceImpl = class {
|
|
|
5256
5516
|
});
|
|
5257
5517
|
const spaceMemberCredential = credentials[0].credential.credential;
|
|
5258
5518
|
invariant15(getCredentialAssertion4(spaceMemberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
|
|
5259
|
-
F:
|
|
5260
|
-
L:
|
|
5519
|
+
F: __dxlog_file20,
|
|
5520
|
+
L: 104,
|
|
5261
5521
|
S: this,
|
|
5262
5522
|
A: [
|
|
5263
5523
|
"getCredentialAssertion(spaceMemberCredential)['@type'] === 'dxos.halo.credentials.SpaceMember'",
|
|
5264
5524
|
""
|
|
5265
5525
|
]
|
|
5266
5526
|
});
|
|
5267
|
-
await
|
|
5527
|
+
await writeMessages4(space.controlPipeline.writer, credentials);
|
|
5268
5528
|
}
|
|
5269
5529
|
querySpaces() {
|
|
5270
5530
|
return new Stream10(({ next, ctx }) => {
|
|
5271
5531
|
const scheduler = new UpdateScheduler(ctx, async () => {
|
|
5272
5532
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
5273
5533
|
const spaces = Array.from(dataSpaceManager.spaces.values()).map((space) => this._serializeSpace(space));
|
|
5274
|
-
|
|
5534
|
+
log17("update", {
|
|
5275
5535
|
spaces
|
|
5276
5536
|
}, {
|
|
5277
|
-
F:
|
|
5278
|
-
L:
|
|
5537
|
+
F: __dxlog_file20,
|
|
5538
|
+
L: 115,
|
|
5279
5539
|
S: this,
|
|
5280
5540
|
C: (f, a) => f(...a)
|
|
5281
5541
|
});
|
|
@@ -5293,7 +5553,15 @@ var SpacesServiceImpl = class {
|
|
|
5293
5553
|
const subscribeSpaces = () => {
|
|
5294
5554
|
subscriptions.clear();
|
|
5295
5555
|
for (const space of dataSpaceManager.spaces.values()) {
|
|
5296
|
-
|
|
5556
|
+
let lastState;
|
|
5557
|
+
subscriptions.add(space.stateUpdate.on(ctx, () => {
|
|
5558
|
+
if (space.state !== lastState) {
|
|
5559
|
+
scheduler.forceTrigger();
|
|
5560
|
+
} else {
|
|
5561
|
+
scheduler.trigger();
|
|
5562
|
+
}
|
|
5563
|
+
lastState = space.state;
|
|
5564
|
+
}));
|
|
5297
5565
|
subscriptions.add(space.presence.updated.on(ctx, () => scheduler.trigger()));
|
|
5298
5566
|
subscriptions.add(space.automergeSpaceState.onNewEpoch.on(ctx, () => scheduler.trigger()));
|
|
5299
5567
|
subscriptions.add(space.inner.controlPipeline.state.timeframeUpdate.on(ctx, () => scheduler.trigger()));
|
|
@@ -5358,8 +5626,8 @@ var SpacesServiceImpl = class {
|
|
|
5358
5626
|
});
|
|
5359
5627
|
} else {
|
|
5360
5628
|
invariant15(!credential.id, "Id on unsigned credentials is not allowed", {
|
|
5361
|
-
F:
|
|
5362
|
-
L:
|
|
5629
|
+
F: __dxlog_file20,
|
|
5630
|
+
L: 213,
|
|
5363
5631
|
S: this,
|
|
5364
5632
|
A: [
|
|
5365
5633
|
"!credential.id",
|
|
@@ -5367,8 +5635,8 @@ var SpacesServiceImpl = class {
|
|
|
5367
5635
|
]
|
|
5368
5636
|
});
|
|
5369
5637
|
invariant15(this._identityManager.identity, "Identity is not available", {
|
|
5370
|
-
F:
|
|
5371
|
-
L:
|
|
5638
|
+
F: __dxlog_file20,
|
|
5639
|
+
L: 214,
|
|
5372
5640
|
S: this,
|
|
5373
5641
|
A: [
|
|
5374
5642
|
"this._identityManager.identity",
|
|
@@ -5377,8 +5645,8 @@ var SpacesServiceImpl = class {
|
|
|
5377
5645
|
});
|
|
5378
5646
|
const signer = this._identityManager.identity.getIdentityCredentialSigner();
|
|
5379
5647
|
invariant15(credential.issuer.equals(signer.getIssuer()), void 0, {
|
|
5380
|
-
F:
|
|
5381
|
-
L:
|
|
5648
|
+
F: __dxlog_file20,
|
|
5649
|
+
L: 216,
|
|
5382
5650
|
S: this,
|
|
5383
5651
|
A: [
|
|
5384
5652
|
"credential.issuer.equals(signer.getIssuer())",
|
|
@@ -5400,10 +5668,66 @@ var SpacesServiceImpl = class {
|
|
|
5400
5668
|
async createEpoch({ spaceKey, migration, automergeRootUrl }) {
|
|
5401
5669
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
5402
5670
|
const space = dataSpaceManager.spaces.get(spaceKey) ?? raise2(new SpaceNotFoundError2(spaceKey));
|
|
5403
|
-
await space.createEpoch({
|
|
5671
|
+
const credential = await space.createEpoch({
|
|
5404
5672
|
migration,
|
|
5405
5673
|
newAutomergeRoot: automergeRootUrl
|
|
5406
5674
|
});
|
|
5675
|
+
return {
|
|
5676
|
+
epochCredential: credential ?? void 0
|
|
5677
|
+
};
|
|
5678
|
+
}
|
|
5679
|
+
async admitContact(request) {
|
|
5680
|
+
const dataSpaceManager = await this._getDataSpaceManager();
|
|
5681
|
+
await dataSpaceManager.admitMember({
|
|
5682
|
+
spaceKey: request.spaceKey,
|
|
5683
|
+
identityKey: request.contact.identityKey,
|
|
5684
|
+
role: request.role
|
|
5685
|
+
});
|
|
5686
|
+
}
|
|
5687
|
+
async joinBySpaceKey({ spaceKey }) {
|
|
5688
|
+
const dataSpaceManager = await this._getDataSpaceManager();
|
|
5689
|
+
const credential = await dataSpaceManager.requestSpaceAdmissionCredential(spaceKey);
|
|
5690
|
+
return this._joinByAdmission({
|
|
5691
|
+
credential
|
|
5692
|
+
});
|
|
5693
|
+
}
|
|
5694
|
+
async _joinByAdmission({ credential }) {
|
|
5695
|
+
const assertion = getCredentialAssertion4(credential);
|
|
5696
|
+
invariant15(assertion["@type"] === "dxos.halo.credentials.SpaceMember", "Invalid credential", {
|
|
5697
|
+
F: __dxlog_file20,
|
|
5698
|
+
L: 250,
|
|
5699
|
+
S: this,
|
|
5700
|
+
A: [
|
|
5701
|
+
"assertion['@type'] === 'dxos.halo.credentials.SpaceMember'",
|
|
5702
|
+
"'Invalid credential'"
|
|
5703
|
+
]
|
|
5704
|
+
});
|
|
5705
|
+
const myIdentity = this._identityManager.identity;
|
|
5706
|
+
invariant15(myIdentity && credential.subject.id.equals(myIdentity.identityKey), void 0, {
|
|
5707
|
+
F: __dxlog_file20,
|
|
5708
|
+
L: 252,
|
|
5709
|
+
S: this,
|
|
5710
|
+
A: [
|
|
5711
|
+
"myIdentity && credential.subject.id.equals(myIdentity.identityKey)",
|
|
5712
|
+
""
|
|
5713
|
+
]
|
|
5714
|
+
});
|
|
5715
|
+
const dataSpaceManager = await this._getDataSpaceManager();
|
|
5716
|
+
let dataSpace = dataSpaceManager.spaces.get(assertion.spaceKey);
|
|
5717
|
+
if (!dataSpace) {
|
|
5718
|
+
dataSpace = await dataSpaceManager.acceptSpace({
|
|
5719
|
+
spaceKey: assertion.spaceKey,
|
|
5720
|
+
genesisFeedKey: assertion.genesisFeedKey
|
|
5721
|
+
});
|
|
5722
|
+
await myIdentity.controlPipeline.writer.write({
|
|
5723
|
+
credential: {
|
|
5724
|
+
credential
|
|
5725
|
+
}
|
|
5726
|
+
});
|
|
5727
|
+
}
|
|
5728
|
+
return {
|
|
5729
|
+
space: this._serializeSpace(dataSpace)
|
|
5730
|
+
};
|
|
5407
5731
|
}
|
|
5408
5732
|
_serializeSpace(space) {
|
|
5409
5733
|
return {
|
|
@@ -5422,7 +5746,8 @@ var SpacesServiceImpl = class {
|
|
|
5422
5746
|
startDataTimeframe: void 0,
|
|
5423
5747
|
currentDataTimeframe: void 0,
|
|
5424
5748
|
targetDataTimeframe: void 0,
|
|
5425
|
-
totalDataTimeframe: void 0
|
|
5749
|
+
totalDataTimeframe: void 0,
|
|
5750
|
+
spaceRootUrl: space.databaseRoot?.url
|
|
5426
5751
|
},
|
|
5427
5752
|
members: Array.from(space.inner.spaceState.members.values()).map((member) => {
|
|
5428
5753
|
const peers = space.presence.getPeersOnline().filter(({ identityKey }) => identityKey.equals(member.key));
|
|
@@ -5466,8 +5791,8 @@ var SpacesServiceImpl = class {
|
|
|
5466
5791
|
var getChannelId = (channel) => `user-channel/${channel}`;
|
|
5467
5792
|
|
|
5468
5793
|
// packages/sdk/client-services/src/packlets/services/service-context.ts
|
|
5469
|
-
import { Trigger as
|
|
5470
|
-
import { Context as Context10, Resource as
|
|
5794
|
+
import { Trigger as Trigger8 } from "@dxos/async";
|
|
5795
|
+
import { Context as Context10, Resource as Resource3 } from "@dxos/context";
|
|
5471
5796
|
import { getCredentialAssertion as getCredentialAssertion5 } from "@dxos/credentials";
|
|
5472
5797
|
import { failUndefined as failUndefined2 } from "@dxos/debug";
|
|
5473
5798
|
import { EchoHost } from "@dxos/echo-db";
|
|
@@ -5476,7 +5801,7 @@ import { FeedFactory, FeedStore } from "@dxos/feed-store";
|
|
|
5476
5801
|
import { invariant as invariant16 } from "@dxos/invariant";
|
|
5477
5802
|
import { Keyring } from "@dxos/keyring";
|
|
5478
5803
|
import { PublicKey as PublicKey12 } from "@dxos/keys";
|
|
5479
|
-
import { log as
|
|
5804
|
+
import { log as log18 } from "@dxos/log";
|
|
5480
5805
|
import { InvalidStorageVersionError, STORAGE_VERSION as STORAGE_VERSION2, trace as trace9 } from "@dxos/protocols";
|
|
5481
5806
|
import { Invitation as Invitation8 } from "@dxos/protocols/proto/dxos/client/services";
|
|
5482
5807
|
import { BlobStore } from "@dxos/teleport-extension-object-sync";
|
|
@@ -5492,8 +5817,8 @@ function _ts_decorate6(decorators, target, key, desc) {
|
|
|
5492
5817
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5493
5818
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
5494
5819
|
}
|
|
5495
|
-
var
|
|
5496
|
-
var ServiceContext = class extends
|
|
5820
|
+
var __dxlog_file21 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-context.ts";
|
|
5821
|
+
var ServiceContext = class extends Resource3 {
|
|
5497
5822
|
constructor(storage, level, networkManager, signalManager, _runtimeParams) {
|
|
5498
5823
|
super();
|
|
5499
5824
|
this.storage = storage;
|
|
@@ -5501,7 +5826,7 @@ var ServiceContext = class extends Resource2 {
|
|
|
5501
5826
|
this.networkManager = networkManager;
|
|
5502
5827
|
this.signalManager = signalManager;
|
|
5503
5828
|
this._runtimeParams = _runtimeParams;
|
|
5504
|
-
this.initialized = new
|
|
5829
|
+
this.initialized = new Trigger8();
|
|
5505
5830
|
this._handlerFactories = /* @__PURE__ */ new Map();
|
|
5506
5831
|
this._instanceId = PublicKey12.random().toHex();
|
|
5507
5832
|
this.metadataStore = new MetadataStore(storage.createDirectory("metadata"));
|
|
@@ -5535,16 +5860,16 @@ var ServiceContext = class extends Resource2 {
|
|
|
5535
5860
|
}
|
|
5536
5861
|
async _open(ctx) {
|
|
5537
5862
|
await this._checkStorageVersion();
|
|
5538
|
-
|
|
5539
|
-
F:
|
|
5863
|
+
log18("opening...", void 0, {
|
|
5864
|
+
F: __dxlog_file21,
|
|
5540
5865
|
L: 149,
|
|
5541
5866
|
S: this,
|
|
5542
5867
|
C: (f, a) => f(...a)
|
|
5543
5868
|
});
|
|
5544
|
-
|
|
5869
|
+
log18.trace("dxos.sdk.service-context.open", trace9.begin({
|
|
5545
5870
|
id: this._instanceId
|
|
5546
5871
|
}), {
|
|
5547
|
-
F:
|
|
5872
|
+
F: __dxlog_file21,
|
|
5548
5873
|
L: 150,
|
|
5549
5874
|
S: this,
|
|
5550
5875
|
C: (f, a) => f(...a)
|
|
@@ -5559,32 +5884,32 @@ var ServiceContext = class extends Resource2 {
|
|
|
5559
5884
|
await this._initialize(ctx);
|
|
5560
5885
|
}
|
|
5561
5886
|
const loadedInvitations = await this.invitationsManager.loadPersistentInvitations();
|
|
5562
|
-
|
|
5887
|
+
log18("loaded persistent invitations", {
|
|
5563
5888
|
count: loadedInvitations.invitations?.length
|
|
5564
5889
|
}, {
|
|
5565
|
-
F:
|
|
5890
|
+
F: __dxlog_file21,
|
|
5566
5891
|
L: 163,
|
|
5567
5892
|
S: this,
|
|
5568
5893
|
C: (f, a) => f(...a)
|
|
5569
5894
|
});
|
|
5570
|
-
|
|
5895
|
+
log18.trace("dxos.sdk.service-context.open", trace9.end({
|
|
5571
5896
|
id: this._instanceId
|
|
5572
5897
|
}), {
|
|
5573
|
-
F:
|
|
5898
|
+
F: __dxlog_file21,
|
|
5574
5899
|
L: 165,
|
|
5575
5900
|
S: this,
|
|
5576
5901
|
C: (f, a) => f(...a)
|
|
5577
5902
|
});
|
|
5578
|
-
|
|
5579
|
-
F:
|
|
5903
|
+
log18("opened", void 0, {
|
|
5904
|
+
F: __dxlog_file21,
|
|
5580
5905
|
L: 166,
|
|
5581
5906
|
S: this,
|
|
5582
5907
|
C: (f, a) => f(...a)
|
|
5583
5908
|
});
|
|
5584
5909
|
}
|
|
5585
5910
|
async _close(ctx) {
|
|
5586
|
-
|
|
5587
|
-
F:
|
|
5911
|
+
log18("closing...", void 0, {
|
|
5912
|
+
F: __dxlog_file21,
|
|
5588
5913
|
L: 170,
|
|
5589
5914
|
S: this,
|
|
5590
5915
|
C: (f, a) => f(...a)
|
|
@@ -5600,8 +5925,8 @@ var ServiceContext = class extends Resource2 {
|
|
|
5600
5925
|
await this.echoHost.close(ctx);
|
|
5601
5926
|
await this.networkManager.close();
|
|
5602
5927
|
await this.signalManager.close();
|
|
5603
|
-
|
|
5604
|
-
F:
|
|
5928
|
+
log18("closed", void 0, {
|
|
5929
|
+
F: __dxlog_file21,
|
|
5605
5930
|
L: 182,
|
|
5606
5931
|
S: this,
|
|
5607
5932
|
C: (f, a) => f(...a)
|
|
@@ -5609,13 +5934,16 @@ var ServiceContext = class extends Resource2 {
|
|
|
5609
5934
|
}
|
|
5610
5935
|
async createIdentity(params = {}) {
|
|
5611
5936
|
const identity = await this.identityManager.createIdentity(params);
|
|
5612
|
-
await this._initialize(new Context10(
|
|
5937
|
+
await this._initialize(new Context10(void 0, {
|
|
5938
|
+
F: __dxlog_file21,
|
|
5939
|
+
L: 187
|
|
5940
|
+
}));
|
|
5613
5941
|
return identity;
|
|
5614
5942
|
}
|
|
5615
5943
|
getInvitationHandler(invitation) {
|
|
5616
5944
|
const factory = this._handlerFactories.get(invitation.kind);
|
|
5617
5945
|
invariant16(factory, `Unknown invitation kind: ${invitation.kind}`, {
|
|
5618
|
-
F:
|
|
5946
|
+
F: __dxlog_file21,
|
|
5619
5947
|
L: 193,
|
|
5620
5948
|
S: this,
|
|
5621
5949
|
A: [
|
|
@@ -5635,7 +5963,10 @@ var ServiceContext = class extends Resource2 {
|
|
|
5635
5963
|
}
|
|
5636
5964
|
async _acceptIdentity(params) {
|
|
5637
5965
|
const identity = await this.identityManager.acceptIdentity(params);
|
|
5638
|
-
await this._initialize(new Context10(
|
|
5966
|
+
await this._initialize(new Context10(void 0, {
|
|
5967
|
+
F: __dxlog_file21,
|
|
5968
|
+
L: 209
|
|
5969
|
+
}));
|
|
5639
5970
|
return identity;
|
|
5640
5971
|
}
|
|
5641
5972
|
async _checkStorageVersion() {
|
|
@@ -5646,8 +5977,8 @@ var ServiceContext = class extends Resource2 {
|
|
|
5646
5977
|
}
|
|
5647
5978
|
// Called when identity is created.
|
|
5648
5979
|
async _initialize(ctx) {
|
|
5649
|
-
|
|
5650
|
-
F:
|
|
5980
|
+
log18("initializing spaces...", void 0, {
|
|
5981
|
+
F: __dxlog_file21,
|
|
5651
5982
|
L: 224,
|
|
5652
5983
|
S: this,
|
|
5653
5984
|
C: (f, a) => f(...a)
|
|
@@ -5670,7 +6001,7 @@ var ServiceContext = class extends Resource2 {
|
|
|
5670
6001
|
await this.dataSpaceManager.open();
|
|
5671
6002
|
this._handlerFactories.set(Invitation8.Kind.SPACE, (invitation) => {
|
|
5672
6003
|
invariant16(this.dataSpaceManager, "dataSpaceManager not initialized yet", {
|
|
5673
|
-
F:
|
|
6004
|
+
F: __dxlog_file21,
|
|
5674
6005
|
L: 249,
|
|
5675
6006
|
S: this,
|
|
5676
6007
|
A: [
|
|
@@ -5691,10 +6022,10 @@ var ServiceContext = class extends Resource2 {
|
|
|
5691
6022
|
return;
|
|
5692
6023
|
}
|
|
5693
6024
|
if (!this.dataSpaceManager) {
|
|
5694
|
-
|
|
6025
|
+
log18("dataSpaceManager not initialized yet, ignoring space admission", {
|
|
5695
6026
|
details: assertion
|
|
5696
6027
|
}, {
|
|
5697
|
-
F:
|
|
6028
|
+
F: __dxlog_file21,
|
|
5698
6029
|
L: 265,
|
|
5699
6030
|
S: this,
|
|
5700
6031
|
C: (f, a) => f(...a)
|
|
@@ -5702,10 +6033,10 @@ var ServiceContext = class extends Resource2 {
|
|
|
5702
6033
|
return;
|
|
5703
6034
|
}
|
|
5704
6035
|
if (this.dataSpaceManager.spaces.has(assertion.spaceKey)) {
|
|
5705
|
-
|
|
6036
|
+
log18("space already exists, ignoring space admission", {
|
|
5706
6037
|
details: assertion
|
|
5707
6038
|
}, {
|
|
5708
|
-
F:
|
|
6039
|
+
F: __dxlog_file21,
|
|
5709
6040
|
L: 269,
|
|
5710
6041
|
S: this,
|
|
5711
6042
|
C: (f, a) => f(...a)
|
|
@@ -5713,10 +6044,10 @@ var ServiceContext = class extends Resource2 {
|
|
|
5713
6044
|
return;
|
|
5714
6045
|
}
|
|
5715
6046
|
try {
|
|
5716
|
-
|
|
6047
|
+
log18("accepting space recorded in halo", {
|
|
5717
6048
|
details: assertion
|
|
5718
6049
|
}, {
|
|
5719
|
-
F:
|
|
6050
|
+
F: __dxlog_file21,
|
|
5720
6051
|
L: 274,
|
|
5721
6052
|
S: this,
|
|
5722
6053
|
C: (f, a) => f(...a)
|
|
@@ -5726,8 +6057,8 @@ var ServiceContext = class extends Resource2 {
|
|
|
5726
6057
|
genesisFeedKey: assertion.genesisFeedKey
|
|
5727
6058
|
});
|
|
5728
6059
|
} catch (err) {
|
|
5729
|
-
|
|
5730
|
-
F:
|
|
6060
|
+
log18.catch(err, void 0, {
|
|
6061
|
+
F: __dxlog_file21,
|
|
5731
6062
|
L: 280,
|
|
5732
6063
|
S: this,
|
|
5733
6064
|
C: (f, a) => f(...a)
|
|
@@ -5774,9 +6105,9 @@ var ServiceRegistry = class {
|
|
|
5774
6105
|
};
|
|
5775
6106
|
|
|
5776
6107
|
// packages/sdk/client-services/src/packlets/locks/browser.ts
|
|
5777
|
-
import { asyncTimeout as
|
|
6108
|
+
import { asyncTimeout as asyncTimeout2, Trigger as Trigger9 } from "@dxos/async";
|
|
5778
6109
|
import { RESOURCE_LOCK_TIMEOUT } from "@dxos/client-protocol";
|
|
5779
|
-
import { log as
|
|
6110
|
+
import { log as log19, logInfo } from "@dxos/log";
|
|
5780
6111
|
function _ts_decorate7(decorators, target, key, desc) {
|
|
5781
6112
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
5782
6113
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
@@ -5787,7 +6118,7 @@ function _ts_decorate7(decorators, target, key, desc) {
|
|
|
5787
6118
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5788
6119
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
5789
6120
|
}
|
|
5790
|
-
var
|
|
6121
|
+
var __dxlog_file22 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/locks/browser.ts";
|
|
5791
6122
|
var Message;
|
|
5792
6123
|
(function(Message2) {
|
|
5793
6124
|
Message2["ACQUIRING"] = "acquiring";
|
|
@@ -5795,7 +6126,7 @@ var Message;
|
|
|
5795
6126
|
var Lock = class {
|
|
5796
6127
|
constructor({ lockKey, onAcquire, onRelease }) {
|
|
5797
6128
|
this._broadcastChannel = new BroadcastChannel("vault-resource-lock");
|
|
5798
|
-
this._releaseTrigger = new
|
|
6129
|
+
this._releaseTrigger = new Trigger9();
|
|
5799
6130
|
this._lockKey = lockKey;
|
|
5800
6131
|
this._onAcquire = onAcquire;
|
|
5801
6132
|
this._onRelease = onRelease;
|
|
@@ -5809,29 +6140,29 @@ var Lock = class {
|
|
|
5809
6140
|
message: "acquiring"
|
|
5810
6141
|
});
|
|
5811
6142
|
try {
|
|
5812
|
-
|
|
5813
|
-
F:
|
|
6143
|
+
log19("aquiring lock...", void 0, {
|
|
6144
|
+
F: __dxlog_file22,
|
|
5814
6145
|
L: 42,
|
|
5815
6146
|
S: this,
|
|
5816
6147
|
C: (f, a) => f(...a)
|
|
5817
6148
|
});
|
|
5818
|
-
await
|
|
5819
|
-
|
|
5820
|
-
F:
|
|
6149
|
+
await asyncTimeout2(this._requestLock(), RESOURCE_LOCK_TIMEOUT);
|
|
6150
|
+
log19("acquired lock", void 0, {
|
|
6151
|
+
F: __dxlog_file22,
|
|
5821
6152
|
L: 44,
|
|
5822
6153
|
S: this,
|
|
5823
6154
|
C: (f, a) => f(...a)
|
|
5824
6155
|
});
|
|
5825
6156
|
} catch {
|
|
5826
|
-
|
|
5827
|
-
F:
|
|
6157
|
+
log19("stealing lock...", void 0, {
|
|
6158
|
+
F: __dxlog_file22,
|
|
5828
6159
|
L: 46,
|
|
5829
6160
|
S: this,
|
|
5830
6161
|
C: (f, a) => f(...a)
|
|
5831
6162
|
});
|
|
5832
6163
|
await this._requestLock(true);
|
|
5833
|
-
|
|
5834
|
-
F:
|
|
6164
|
+
log19("stolen lock", void 0, {
|
|
6165
|
+
F: __dxlog_file22,
|
|
5835
6166
|
L: 48,
|
|
5836
6167
|
S: this,
|
|
5837
6168
|
C: (f, a) => f(...a)
|
|
@@ -5847,31 +6178,31 @@ var Lock = class {
|
|
|
5847
6178
|
}
|
|
5848
6179
|
}
|
|
5849
6180
|
async _requestLock(steal = false) {
|
|
5850
|
-
|
|
6181
|
+
log19("requesting lock...", {
|
|
5851
6182
|
steal
|
|
5852
6183
|
}, {
|
|
5853
|
-
F:
|
|
6184
|
+
F: __dxlog_file22,
|
|
5854
6185
|
L: 63,
|
|
5855
6186
|
S: this,
|
|
5856
6187
|
C: (f, a) => f(...a)
|
|
5857
6188
|
});
|
|
5858
|
-
const acquired = new
|
|
6189
|
+
const acquired = new Trigger9();
|
|
5859
6190
|
void navigator.locks.request(this._lockKey, {
|
|
5860
6191
|
steal
|
|
5861
6192
|
}, async () => {
|
|
5862
6193
|
await this._onAcquire?.();
|
|
5863
6194
|
acquired.wake();
|
|
5864
|
-
this._releaseTrigger = new
|
|
6195
|
+
this._releaseTrigger = new Trigger9();
|
|
5865
6196
|
await this._releaseTrigger.wait();
|
|
5866
|
-
|
|
5867
|
-
F:
|
|
6197
|
+
log19("releasing lock...", void 0, {
|
|
6198
|
+
F: __dxlog_file22,
|
|
5868
6199
|
L: 72,
|
|
5869
6200
|
S: this,
|
|
5870
6201
|
C: (f, a) => f(...a)
|
|
5871
6202
|
});
|
|
5872
6203
|
await this._onRelease?.();
|
|
5873
|
-
|
|
5874
|
-
F:
|
|
6204
|
+
log19("released lock", void 0, {
|
|
6205
|
+
F: __dxlog_file22,
|
|
5875
6206
|
L: 74,
|
|
5876
6207
|
S: this,
|
|
5877
6208
|
C: (f, a) => f(...a)
|
|
@@ -5880,10 +6211,10 @@ var Lock = class {
|
|
|
5880
6211
|
await this._onRelease?.();
|
|
5881
6212
|
});
|
|
5882
6213
|
await acquired.wait();
|
|
5883
|
-
|
|
6214
|
+
log19("recieved lock", {
|
|
5884
6215
|
steal
|
|
5885
6216
|
}, {
|
|
5886
|
-
F:
|
|
6217
|
+
F: __dxlog_file22,
|
|
5887
6218
|
L: 81,
|
|
5888
6219
|
S: this,
|
|
5889
6220
|
C: (f, a) => f(...a)
|
|
@@ -5971,13 +6302,172 @@ var createLevel = async (config) => {
|
|
|
5971
6302
|
return level;
|
|
5972
6303
|
};
|
|
5973
6304
|
|
|
6305
|
+
// packages/sdk/client-services/src/packlets/storage/profile-archive.ts
|
|
6306
|
+
import { cbor } from "@dxos/automerge/automerge-repo";
|
|
6307
|
+
import { invariant as invariant17 } from "@dxos/invariant";
|
|
6308
|
+
import { log as log20 } from "@dxos/log";
|
|
6309
|
+
import { ProfileArchiveEntryType } from "@dxos/protocols";
|
|
6310
|
+
import { arrayToBuffer } from "@dxos/util";
|
|
6311
|
+
var __dxlog_file23 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/storage/profile-archive.ts";
|
|
6312
|
+
var encodeProfileArchive = (profile) => cbor.encode(profile);
|
|
6313
|
+
var decodeProfileArchive = (data) => cbor.decode(data);
|
|
6314
|
+
var exportProfileData = async ({ storage, level }) => {
|
|
6315
|
+
const archive = {
|
|
6316
|
+
storage: [],
|
|
6317
|
+
meta: {
|
|
6318
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
6319
|
+
}
|
|
6320
|
+
};
|
|
6321
|
+
{
|
|
6322
|
+
const directory = await storage.createDirectory();
|
|
6323
|
+
const files = await directory.list();
|
|
6324
|
+
log20.info("begin exporting files", {
|
|
6325
|
+
count: files.length
|
|
6326
|
+
}, {
|
|
6327
|
+
F: __dxlog_file23,
|
|
6328
|
+
L: 30,
|
|
6329
|
+
S: void 0,
|
|
6330
|
+
C: (f, a) => f(...a)
|
|
6331
|
+
});
|
|
6332
|
+
for (const filename of files) {
|
|
6333
|
+
const file = await directory.getOrCreateFile(filename);
|
|
6334
|
+
const { size } = await file.stat();
|
|
6335
|
+
const data = await file.read(0, size);
|
|
6336
|
+
archive.storage.push({
|
|
6337
|
+
type: ProfileArchiveEntryType.FILE,
|
|
6338
|
+
key: filename,
|
|
6339
|
+
value: data
|
|
6340
|
+
});
|
|
6341
|
+
}
|
|
6342
|
+
log20.info("done exporting files", {
|
|
6343
|
+
count: files.length
|
|
6344
|
+
}, {
|
|
6345
|
+
F: __dxlog_file23,
|
|
6346
|
+
L: 41,
|
|
6347
|
+
S: void 0,
|
|
6348
|
+
C: (f, a) => f(...a)
|
|
6349
|
+
});
|
|
6350
|
+
}
|
|
6351
|
+
{
|
|
6352
|
+
log20.info("begin exporting kv pairs", void 0, {
|
|
6353
|
+
F: __dxlog_file23,
|
|
6354
|
+
L: 45,
|
|
6355
|
+
S: void 0,
|
|
6356
|
+
C: (f, a) => f(...a)
|
|
6357
|
+
});
|
|
6358
|
+
const iter = await level.iterator({
|
|
6359
|
+
keyEncoding: "binary",
|
|
6360
|
+
valueEncoding: "binary"
|
|
6361
|
+
});
|
|
6362
|
+
let count = 0;
|
|
6363
|
+
for await (const [key, value] of iter) {
|
|
6364
|
+
archive.storage.push({
|
|
6365
|
+
type: ProfileArchiveEntryType.KEY_VALUE,
|
|
6366
|
+
key,
|
|
6367
|
+
value
|
|
6368
|
+
});
|
|
6369
|
+
count++;
|
|
6370
|
+
}
|
|
6371
|
+
log20.info("done exporting kv pairs", {
|
|
6372
|
+
count
|
|
6373
|
+
}, {
|
|
6374
|
+
F: __dxlog_file23,
|
|
6375
|
+
L: 56,
|
|
6376
|
+
S: void 0,
|
|
6377
|
+
C: (f, a) => f(...a)
|
|
6378
|
+
});
|
|
6379
|
+
}
|
|
6380
|
+
return archive;
|
|
6381
|
+
};
|
|
6382
|
+
var importProfileData = async ({ storage, level }, archive) => {
|
|
6383
|
+
let batch = level.batch();
|
|
6384
|
+
let count = 0;
|
|
6385
|
+
for (const entry2 of archive.storage) {
|
|
6386
|
+
switch (entry2.type) {
|
|
6387
|
+
case ProfileArchiveEntryType.FILE: {
|
|
6388
|
+
const directory = await storage.createDirectory();
|
|
6389
|
+
invariant17(typeof entry2.key === "string", "Invalid key type", {
|
|
6390
|
+
F: __dxlog_file23,
|
|
6391
|
+
L: 79,
|
|
6392
|
+
S: void 0,
|
|
6393
|
+
A: [
|
|
6394
|
+
"typeof entry.key === 'string'",
|
|
6395
|
+
"'Invalid key type'"
|
|
6396
|
+
]
|
|
6397
|
+
});
|
|
6398
|
+
const file = await directory.getOrCreateFile(entry2.key);
|
|
6399
|
+
invariant17(entry2.value instanceof Uint8Array, "Invalid value type", {
|
|
6400
|
+
F: __dxlog_file23,
|
|
6401
|
+
L: 81,
|
|
6402
|
+
S: void 0,
|
|
6403
|
+
A: [
|
|
6404
|
+
"entry.value instanceof Uint8Array",
|
|
6405
|
+
"'Invalid value type'"
|
|
6406
|
+
]
|
|
6407
|
+
});
|
|
6408
|
+
await file.write(0, arrayToBuffer(entry2.value));
|
|
6409
|
+
await file.close();
|
|
6410
|
+
break;
|
|
6411
|
+
}
|
|
6412
|
+
case ProfileArchiveEntryType.KEY_VALUE: {
|
|
6413
|
+
invariant17(entry2.key instanceof Uint8Array, "Invalid key type", {
|
|
6414
|
+
F: __dxlog_file23,
|
|
6415
|
+
L: 87,
|
|
6416
|
+
S: void 0,
|
|
6417
|
+
A: [
|
|
6418
|
+
"entry.key instanceof Uint8Array",
|
|
6419
|
+
"'Invalid key type'"
|
|
6420
|
+
]
|
|
6421
|
+
});
|
|
6422
|
+
invariant17(entry2.value instanceof Uint8Array, "Invalid value type", {
|
|
6423
|
+
F: __dxlog_file23,
|
|
6424
|
+
L: 88,
|
|
6425
|
+
S: void 0,
|
|
6426
|
+
A: [
|
|
6427
|
+
"entry.value instanceof Uint8Array",
|
|
6428
|
+
"'Invalid value type'"
|
|
6429
|
+
]
|
|
6430
|
+
});
|
|
6431
|
+
batch.put(entry2.key, entry2.value, {
|
|
6432
|
+
keyEncoding: "binary",
|
|
6433
|
+
valueEncoding: "binary"
|
|
6434
|
+
});
|
|
6435
|
+
break;
|
|
6436
|
+
}
|
|
6437
|
+
default:
|
|
6438
|
+
throw new Error(`Invalid entry type: ${entry2.type}`);
|
|
6439
|
+
}
|
|
6440
|
+
if (++count % 1e3 === 0) {
|
|
6441
|
+
await batch.write();
|
|
6442
|
+
batch = level.batch();
|
|
6443
|
+
log20.info("importing", {
|
|
6444
|
+
count,
|
|
6445
|
+
total: archive.storage.length,
|
|
6446
|
+
progress: `${(count / archive.storage.length * 100).toFixed()}%`
|
|
6447
|
+
}, {
|
|
6448
|
+
F: __dxlog_file23,
|
|
6449
|
+
L: 101,
|
|
6450
|
+
S: void 0,
|
|
6451
|
+
C: (f, a) => f(...a)
|
|
6452
|
+
});
|
|
6453
|
+
}
|
|
6454
|
+
}
|
|
6455
|
+
log20.info("committing changes..", void 0, {
|
|
6456
|
+
F: __dxlog_file23,
|
|
6457
|
+
L: 109,
|
|
6458
|
+
S: void 0,
|
|
6459
|
+
C: (f, a) => f(...a)
|
|
6460
|
+
});
|
|
6461
|
+
await batch.write();
|
|
6462
|
+
};
|
|
6463
|
+
|
|
5974
6464
|
// packages/sdk/client-services/src/packlets/services/service-host.ts
|
|
5975
6465
|
import { Event as Event9, synchronized as synchronized3 } from "@dxos/async";
|
|
5976
6466
|
import { clientServiceBundle } from "@dxos/client-protocol";
|
|
5977
6467
|
import { Context as Context11 } from "@dxos/context";
|
|
5978
|
-
import { invariant as
|
|
5979
|
-
import { PublicKey as
|
|
5980
|
-
import { log as
|
|
6468
|
+
import { invariant as invariant19 } from "@dxos/invariant";
|
|
6469
|
+
import { PublicKey as PublicKey17 } from "@dxos/keys";
|
|
6470
|
+
import { log as log22 } from "@dxos/log";
|
|
5981
6471
|
import { WebsocketSignalManager } from "@dxos/messaging";
|
|
5982
6472
|
import { SwarmNetworkManager, createSimplePeerTransportFactory } from "@dxos/network-manager";
|
|
5983
6473
|
import { trace as trace10 } from "@dxos/protocols";
|
|
@@ -5988,9 +6478,9 @@ import { WebsocketRpcClient } from "@dxos/websocket-rpc";
|
|
|
5988
6478
|
// packages/sdk/client-services/src/packlets/devices/devices-service.ts
|
|
5989
6479
|
import { EventSubscriptions as EventSubscriptions3 } from "@dxos/async";
|
|
5990
6480
|
import { Stream as Stream11 } from "@dxos/codec-protobuf";
|
|
5991
|
-
import { invariant as
|
|
6481
|
+
import { invariant as invariant18 } from "@dxos/invariant";
|
|
5992
6482
|
import { Device as Device2, DeviceKind as DeviceKind2 } from "@dxos/protocols/proto/dxos/client/services";
|
|
5993
|
-
var
|
|
6483
|
+
var __dxlog_file24 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/devices/devices-service.ts";
|
|
5994
6484
|
var DevicesServiceImpl = class {
|
|
5995
6485
|
constructor(_identityManager) {
|
|
5996
6486
|
this._identityManager = _identityManager;
|
|
@@ -6007,8 +6497,8 @@ var DevicesServiceImpl = class {
|
|
|
6007
6497
|
devices: []
|
|
6008
6498
|
});
|
|
6009
6499
|
} else {
|
|
6010
|
-
|
|
6011
|
-
F:
|
|
6500
|
+
invariant18(this._identityManager.identity?.presence, "presence not present", {
|
|
6501
|
+
F: __dxlog_file24,
|
|
6012
6502
|
L: 32,
|
|
6013
6503
|
S: this,
|
|
6014
6504
|
A: [
|
|
@@ -6114,28 +6604,111 @@ var findConfigs = () => {
|
|
|
6114
6604
|
return configs.map((r) => r.instance.deref()).filter(nonNullable);
|
|
6115
6605
|
};
|
|
6116
6606
|
|
|
6117
|
-
// packages/sdk/client-services/src/packlets/
|
|
6118
|
-
import {
|
|
6607
|
+
// packages/sdk/client-services/src/packlets/identity/contacts-service.ts
|
|
6608
|
+
import { EventSubscriptions as EventSubscriptions4, scheduleTask as scheduleTask7, UpdateScheduler as UpdateScheduler2 } from "@dxos/async";
|
|
6119
6609
|
import { Stream as Stream12 } from "@dxos/codec-protobuf";
|
|
6120
6610
|
import { PublicKey as PublicKey15 } from "@dxos/keys";
|
|
6121
|
-
import {
|
|
6611
|
+
import { ComplexMap as ComplexMap4, ComplexSet as ComplexSet6 } from "@dxos/util";
|
|
6612
|
+
var ContactsServiceImpl = class {
|
|
6613
|
+
constructor(_identityManager, _spaceManager, _dataSpaceManagerProvider) {
|
|
6614
|
+
this._identityManager = _identityManager;
|
|
6615
|
+
this._spaceManager = _spaceManager;
|
|
6616
|
+
this._dataSpaceManagerProvider = _dataSpaceManagerProvider;
|
|
6617
|
+
}
|
|
6618
|
+
async getContacts() {
|
|
6619
|
+
const identity = this._identityManager.identity;
|
|
6620
|
+
if (identity == null) {
|
|
6621
|
+
return {
|
|
6622
|
+
contacts: []
|
|
6623
|
+
};
|
|
6624
|
+
}
|
|
6625
|
+
const contacts = [
|
|
6626
|
+
...this._spaceManager.spaces.values()
|
|
6627
|
+
].flatMap((s) => [
|
|
6628
|
+
...s.spaceState.members.values()
|
|
6629
|
+
].map((m) => [
|
|
6630
|
+
s.key,
|
|
6631
|
+
m
|
|
6632
|
+
])).reduce((acc, v) => {
|
|
6633
|
+
const [spaceKey, memberInfo] = v;
|
|
6634
|
+
if (memberInfo.key.equals(identity.identityKey)) {
|
|
6635
|
+
return acc;
|
|
6636
|
+
}
|
|
6637
|
+
const existing = acc.get(memberInfo.key);
|
|
6638
|
+
if (existing != null) {
|
|
6639
|
+
existing.profile ??= memberInfo.profile;
|
|
6640
|
+
existing.commonSpaces?.push(spaceKey);
|
|
6641
|
+
} else {
|
|
6642
|
+
acc.set(memberInfo.key, {
|
|
6643
|
+
identityKey: memberInfo.key,
|
|
6644
|
+
profile: memberInfo.profile,
|
|
6645
|
+
commonSpaces: [
|
|
6646
|
+
spaceKey
|
|
6647
|
+
]
|
|
6648
|
+
});
|
|
6649
|
+
}
|
|
6650
|
+
return acc;
|
|
6651
|
+
}, new ComplexMap4(PublicKey15.hash));
|
|
6652
|
+
return {
|
|
6653
|
+
contacts: [
|
|
6654
|
+
...contacts.values()
|
|
6655
|
+
]
|
|
6656
|
+
};
|
|
6657
|
+
}
|
|
6658
|
+
queryContacts() {
|
|
6659
|
+
const subscribedSpaceKeySet = new ComplexSet6(PublicKey15.hash);
|
|
6660
|
+
return new Stream12(({ next, ctx }) => {
|
|
6661
|
+
const pushUpdateTask = new UpdateScheduler2(ctx, async () => {
|
|
6662
|
+
const contacts = await this.getContacts();
|
|
6663
|
+
next(contacts);
|
|
6664
|
+
}, {
|
|
6665
|
+
maxFrequency: 2
|
|
6666
|
+
});
|
|
6667
|
+
scheduleTask7(ctx, async () => {
|
|
6668
|
+
const subscriptions = new EventSubscriptions4();
|
|
6669
|
+
ctx.onDispose(() => subscriptions.clear());
|
|
6670
|
+
const subscribeToSpaceAndUpdate = () => {
|
|
6671
|
+
const oldSetSize = subscribedSpaceKeySet.size;
|
|
6672
|
+
for (const space of this._spaceManager.spaces.values()) {
|
|
6673
|
+
if (!subscribedSpaceKeySet.has(space.key)) {
|
|
6674
|
+
subscriptions.add(space.stateUpdate.on(ctx, () => pushUpdateTask.trigger()));
|
|
6675
|
+
subscribedSpaceKeySet.add(space.key);
|
|
6676
|
+
}
|
|
6677
|
+
}
|
|
6678
|
+
if (oldSetSize !== subscribedSpaceKeySet.size) {
|
|
6679
|
+
pushUpdateTask.trigger();
|
|
6680
|
+
}
|
|
6681
|
+
};
|
|
6682
|
+
const unsubscribe = (await this._dataSpaceManagerProvider()).updated.on(ctx, subscribeToSpaceAndUpdate);
|
|
6683
|
+
ctx.onDispose(unsubscribe);
|
|
6684
|
+
subscribeToSpaceAndUpdate();
|
|
6685
|
+
});
|
|
6686
|
+
});
|
|
6687
|
+
}
|
|
6688
|
+
};
|
|
6689
|
+
|
|
6690
|
+
// packages/sdk/client-services/src/packlets/logging/logging-service.ts
|
|
6691
|
+
import { Event as Event8 } from "@dxos/async";
|
|
6692
|
+
import { Stream as Stream13 } from "@dxos/codec-protobuf";
|
|
6693
|
+
import { PublicKey as PublicKey16 } from "@dxos/keys";
|
|
6694
|
+
import { getContextFromEntry, log as log21 } from "@dxos/log";
|
|
6122
6695
|
import { QueryLogsRequest } from "@dxos/protocols/proto/dxos/client/services";
|
|
6123
6696
|
import { getDebugName, jsonify, numericalValues, tracer } from "@dxos/util";
|
|
6124
6697
|
var LoggingServiceImpl = class {
|
|
6125
6698
|
constructor() {
|
|
6126
6699
|
this._logs = new Event8();
|
|
6127
6700
|
this._started = Date.now();
|
|
6128
|
-
this._sessionId =
|
|
6701
|
+
this._sessionId = PublicKey16.random().toHex();
|
|
6129
6702
|
this._logProcessor = (_config, entry2) => {
|
|
6130
6703
|
this._logs.emit(entry2);
|
|
6131
6704
|
};
|
|
6132
6705
|
}
|
|
6133
6706
|
async open() {
|
|
6134
|
-
|
|
6707
|
+
log21.runtimeConfig.processors.push(this._logProcessor);
|
|
6135
6708
|
}
|
|
6136
6709
|
async close() {
|
|
6137
|
-
const index =
|
|
6138
|
-
|
|
6710
|
+
const index = log21.runtimeConfig.processors.findIndex((processor) => processor === this._logProcessor);
|
|
6711
|
+
log21.runtimeConfig.processors.splice(index, 1);
|
|
6139
6712
|
}
|
|
6140
6713
|
async controlMetrics({ reset, record }) {
|
|
6141
6714
|
if (reset) {
|
|
@@ -6161,7 +6734,7 @@ var LoggingServiceImpl = class {
|
|
|
6161
6734
|
stats: numericalValues(events, "duration")
|
|
6162
6735
|
};
|
|
6163
6736
|
};
|
|
6164
|
-
return new
|
|
6737
|
+
return new Stream13(({ next }) => {
|
|
6165
6738
|
const update = () => {
|
|
6166
6739
|
const metrics = {
|
|
6167
6740
|
timestamp: /* @__PURE__ */ new Date(),
|
|
@@ -6183,7 +6756,7 @@ var LoggingServiceImpl = class {
|
|
|
6183
6756
|
});
|
|
6184
6757
|
}
|
|
6185
6758
|
queryLogs(request) {
|
|
6186
|
-
return new
|
|
6759
|
+
return new Stream13(({ ctx, next }) => {
|
|
6187
6760
|
const handler = (entry2) => {
|
|
6188
6761
|
if (LOG_PROCESSING > 0) {
|
|
6189
6762
|
return;
|
|
@@ -6239,14 +6812,14 @@ var shouldLog = (entry2, request) => {
|
|
|
6239
6812
|
var LOG_PROCESSING = 0;
|
|
6240
6813
|
|
|
6241
6814
|
// packages/sdk/client-services/src/packlets/network/network-service.ts
|
|
6242
|
-
import { Stream as
|
|
6815
|
+
import { Stream as Stream14 } from "@dxos/codec-protobuf";
|
|
6243
6816
|
var NetworkServiceImpl = class {
|
|
6244
6817
|
constructor(networkManager, signalManager) {
|
|
6245
6818
|
this.networkManager = networkManager;
|
|
6246
6819
|
this.signalManager = signalManager;
|
|
6247
6820
|
}
|
|
6248
6821
|
queryStatus() {
|
|
6249
|
-
return new
|
|
6822
|
+
return new Stream14(({ next }) => {
|
|
6250
6823
|
const update = () => {
|
|
6251
6824
|
next({
|
|
6252
6825
|
swarm: this.networkManager.connectionState,
|
|
@@ -6272,7 +6845,7 @@ var NetworkServiceImpl = class {
|
|
|
6272
6845
|
};
|
|
6273
6846
|
|
|
6274
6847
|
// packages/sdk/client-services/src/packlets/system/system-service.ts
|
|
6275
|
-
import { Stream as
|
|
6848
|
+
import { Stream as Stream15 } from "@dxos/codec-protobuf";
|
|
6276
6849
|
import { GetDiagnosticsRequest as GetDiagnosticsRequest2 } from "@dxos/protocols/proto/dxos/client/services";
|
|
6277
6850
|
import { jsonKeyReplacer as jsonKeyReplacer2 } from "@dxos/util";
|
|
6278
6851
|
var SystemServiceImpl = class {
|
|
@@ -6308,7 +6881,7 @@ var SystemServiceImpl = class {
|
|
|
6308
6881
|
}
|
|
6309
6882
|
// TODO(burdon): Standardize interval option in stream request?
|
|
6310
6883
|
queryStatus({ interval = 3e3 } = {}) {
|
|
6311
|
-
return new
|
|
6884
|
+
return new Stream15(({ next }) => {
|
|
6312
6885
|
const update = () => {
|
|
6313
6886
|
next({
|
|
6314
6887
|
status: this._getCurrentStatus()
|
|
@@ -6339,7 +6912,7 @@ function _ts_decorate8(decorators, target, key, desc) {
|
|
|
6339
6912
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6340
6913
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6341
6914
|
}
|
|
6342
|
-
var
|
|
6915
|
+
var __dxlog_file25 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-host.ts";
|
|
6343
6916
|
var ClientServicesHost = class {
|
|
6344
6917
|
constructor({
|
|
6345
6918
|
config,
|
|
@@ -6372,7 +6945,10 @@ var ClientServicesHost = class {
|
|
|
6372
6945
|
lockKey,
|
|
6373
6946
|
onAcquire: () => {
|
|
6374
6947
|
if (!this._opening) {
|
|
6375
|
-
void this.open(new Context11(
|
|
6948
|
+
void this.open(new Context11(void 0, {
|
|
6949
|
+
F: __dxlog_file25,
|
|
6950
|
+
L: 121
|
|
6951
|
+
}));
|
|
6376
6952
|
}
|
|
6377
6953
|
},
|
|
6378
6954
|
onRelease: () => this.close()
|
|
@@ -6427,25 +7003,25 @@ var ClientServicesHost = class {
|
|
|
6427
7003
|
* Can only be called once.
|
|
6428
7004
|
*/
|
|
6429
7005
|
initialize({ config, ...options }) {
|
|
6430
|
-
|
|
6431
|
-
F:
|
|
6432
|
-
L:
|
|
7006
|
+
invariant19(!this._open, "service host is open", {
|
|
7007
|
+
F: __dxlog_file25,
|
|
7008
|
+
L: 187,
|
|
6433
7009
|
S: this,
|
|
6434
7010
|
A: [
|
|
6435
7011
|
"!this._open",
|
|
6436
7012
|
"'service host is open'"
|
|
6437
7013
|
]
|
|
6438
7014
|
});
|
|
6439
|
-
|
|
6440
|
-
F:
|
|
6441
|
-
L:
|
|
7015
|
+
log22("initializing...", void 0, {
|
|
7016
|
+
F: __dxlog_file25,
|
|
7017
|
+
L: 188,
|
|
6442
7018
|
S: this,
|
|
6443
7019
|
C: (f, a) => f(...a)
|
|
6444
7020
|
});
|
|
6445
7021
|
if (config) {
|
|
6446
|
-
|
|
6447
|
-
F:
|
|
6448
|
-
L:
|
|
7022
|
+
invariant19(!this._config, "config already set", {
|
|
7023
|
+
F: __dxlog_file25,
|
|
7024
|
+
L: 191,
|
|
6449
7025
|
S: this,
|
|
6450
7026
|
A: [
|
|
6451
7027
|
"!this._config",
|
|
@@ -6458,9 +7034,9 @@ var ClientServicesHost = class {
|
|
|
6458
7034
|
}
|
|
6459
7035
|
}
|
|
6460
7036
|
if (!options.signalManager) {
|
|
6461
|
-
|
|
6462
|
-
F:
|
|
6463
|
-
L:
|
|
7037
|
+
log22.warn("running signaling without telemetry metadata.", void 0, {
|
|
7038
|
+
F: __dxlog_file25,
|
|
7039
|
+
L: 199,
|
|
6464
7040
|
S: this,
|
|
6465
7041
|
C: (f, a) => f(...a)
|
|
6466
7042
|
});
|
|
@@ -6469,9 +7045,9 @@ var ClientServicesHost = class {
|
|
|
6469
7045
|
iceServers: this._config?.get("runtime.services.ice")
|
|
6470
7046
|
}), signalManager = new WebsocketSignalManager(this._config?.get("runtime.services.signaling") ?? []) } = options;
|
|
6471
7047
|
this._signalManager = signalManager;
|
|
6472
|
-
|
|
6473
|
-
F:
|
|
6474
|
-
L:
|
|
7048
|
+
invariant19(!this._networkManager, "network manager already set", {
|
|
7049
|
+
F: __dxlog_file25,
|
|
7050
|
+
L: 210,
|
|
6475
7051
|
S: this,
|
|
6476
7052
|
A: [
|
|
6477
7053
|
"!this._networkManager",
|
|
@@ -6483,9 +7059,9 @@ var ClientServicesHost = class {
|
|
|
6483
7059
|
transportFactory,
|
|
6484
7060
|
signalManager
|
|
6485
7061
|
});
|
|
6486
|
-
|
|
6487
|
-
F:
|
|
6488
|
-
L:
|
|
7062
|
+
log22("initialized", void 0, {
|
|
7063
|
+
F: __dxlog_file25,
|
|
7064
|
+
L: 217,
|
|
6489
7065
|
S: this,
|
|
6490
7066
|
C: (f, a) => f(...a)
|
|
6491
7067
|
});
|
|
@@ -6494,45 +7070,45 @@ var ClientServicesHost = class {
|
|
|
6494
7070
|
if (this._open) {
|
|
6495
7071
|
return;
|
|
6496
7072
|
}
|
|
6497
|
-
const traceId =
|
|
6498
|
-
|
|
7073
|
+
const traceId = PublicKey17.random().toHex();
|
|
7074
|
+
log22.trace("dxos.client-services.host.open", trace10.begin({
|
|
6499
7075
|
id: traceId
|
|
6500
7076
|
}), {
|
|
6501
|
-
F:
|
|
6502
|
-
L:
|
|
7077
|
+
F: __dxlog_file25,
|
|
7078
|
+
L: 228,
|
|
6503
7079
|
S: this,
|
|
6504
7080
|
C: (f, a) => f(...a)
|
|
6505
7081
|
});
|
|
6506
|
-
|
|
6507
|
-
F:
|
|
6508
|
-
L:
|
|
7082
|
+
invariant19(this._config, "config not set", {
|
|
7083
|
+
F: __dxlog_file25,
|
|
7084
|
+
L: 230,
|
|
6509
7085
|
S: this,
|
|
6510
7086
|
A: [
|
|
6511
7087
|
"this._config",
|
|
6512
7088
|
"'config not set'"
|
|
6513
7089
|
]
|
|
6514
7090
|
});
|
|
6515
|
-
|
|
6516
|
-
F:
|
|
6517
|
-
L:
|
|
7091
|
+
invariant19(this._storage, "storage not set", {
|
|
7092
|
+
F: __dxlog_file25,
|
|
7093
|
+
L: 231,
|
|
6518
7094
|
S: this,
|
|
6519
7095
|
A: [
|
|
6520
7096
|
"this._storage",
|
|
6521
7097
|
"'storage not set'"
|
|
6522
7098
|
]
|
|
6523
7099
|
});
|
|
6524
|
-
|
|
6525
|
-
F:
|
|
6526
|
-
L:
|
|
7100
|
+
invariant19(this._signalManager, "signal manager not set", {
|
|
7101
|
+
F: __dxlog_file25,
|
|
7102
|
+
L: 232,
|
|
6527
7103
|
S: this,
|
|
6528
7104
|
A: [
|
|
6529
7105
|
"this._signalManager",
|
|
6530
7106
|
"'signal manager not set'"
|
|
6531
7107
|
]
|
|
6532
7108
|
});
|
|
6533
|
-
|
|
6534
|
-
F:
|
|
6535
|
-
L:
|
|
7109
|
+
invariant19(this._networkManager, "network manager not set", {
|
|
7110
|
+
F: __dxlog_file25,
|
|
7111
|
+
L: 233,
|
|
6536
7112
|
S: this,
|
|
6537
7113
|
A: [
|
|
6538
7114
|
"this._networkManager",
|
|
@@ -6540,11 +7116,11 @@ var ClientServicesHost = class {
|
|
|
6540
7116
|
]
|
|
6541
7117
|
});
|
|
6542
7118
|
this._opening = true;
|
|
6543
|
-
|
|
7119
|
+
log22("opening...", {
|
|
6544
7120
|
lockKey: this._resourceLock?.lockKey
|
|
6545
7121
|
}, {
|
|
6546
|
-
F:
|
|
6547
|
-
L:
|
|
7122
|
+
F: __dxlog_file25,
|
|
7123
|
+
L: 236,
|
|
6548
7124
|
S: this,
|
|
6549
7125
|
C: (f, a) => f(...a)
|
|
6550
7126
|
});
|
|
@@ -6555,16 +7131,18 @@ var ClientServicesHost = class {
|
|
|
6555
7131
|
await this._level.open();
|
|
6556
7132
|
await this._loggingService.open();
|
|
6557
7133
|
this._serviceContext = new ServiceContext(this._storage, this._level, this._networkManager, this._signalManager, this._runtimeParams);
|
|
7134
|
+
const dataSpaceManagerProvider = async () => {
|
|
7135
|
+
await this._serviceContext.initialized.wait();
|
|
7136
|
+
return this._serviceContext.dataSpaceManager;
|
|
7137
|
+
};
|
|
6558
7138
|
const identityService = new IdentityServiceImpl(this._serviceContext.identityManager, this._serviceContext.keyring, () => this._serviceContext.dataSpaceManager, (params) => this._createIdentity(params), (profile) => this._serviceContext.broadcastProfileUpdate(profile));
|
|
6559
7139
|
this._serviceRegistry.setServices({
|
|
6560
7140
|
SystemService: this._systemService,
|
|
6561
7141
|
IdentityService: identityService,
|
|
7142
|
+
ContactsService: new ContactsServiceImpl(this._serviceContext.identityManager, this._serviceContext.spaceManager, dataSpaceManagerProvider),
|
|
6562
7143
|
InvitationsService: new InvitationsServiceImpl(this._serviceContext.invitationsManager),
|
|
6563
7144
|
DevicesService: new DevicesServiceImpl(this._serviceContext.identityManager),
|
|
6564
|
-
SpacesService: new SpacesServiceImpl(this._serviceContext.identityManager, this._serviceContext.spaceManager,
|
|
6565
|
-
await this._serviceContext.initialized.wait();
|
|
6566
|
-
return this._serviceContext.dataSpaceManager;
|
|
6567
|
-
}),
|
|
7145
|
+
SpacesService: new SpacesServiceImpl(this._serviceContext.identityManager, this._serviceContext.spaceManager, dataSpaceManagerProvider),
|
|
6568
7146
|
DataService: this._serviceContext.echoHost.dataService,
|
|
6569
7147
|
QueryService: this._serviceContext.echoHost.queryService,
|
|
6570
7148
|
NetworkService: new NetworkServiceImpl(this._serviceContext.networkManager, this._serviceContext.signalManager),
|
|
@@ -6594,19 +7172,19 @@ var ClientServicesHost = class {
|
|
|
6594
7172
|
this._open = true;
|
|
6595
7173
|
this._statusUpdate.emit();
|
|
6596
7174
|
const deviceKey = this._serviceContext.identityManager.identity?.deviceKey;
|
|
6597
|
-
|
|
7175
|
+
log22("opened", {
|
|
6598
7176
|
deviceKey
|
|
6599
7177
|
}, {
|
|
6600
|
-
F:
|
|
6601
|
-
L:
|
|
7178
|
+
F: __dxlog_file25,
|
|
7179
|
+
L: 322,
|
|
6602
7180
|
S: this,
|
|
6603
7181
|
C: (f, a) => f(...a)
|
|
6604
7182
|
});
|
|
6605
|
-
|
|
7183
|
+
log22.trace("dxos.client-services.host.open", trace10.end({
|
|
6606
7184
|
id: traceId
|
|
6607
7185
|
}), {
|
|
6608
|
-
F:
|
|
6609
|
-
L:
|
|
7186
|
+
F: __dxlog_file25,
|
|
7187
|
+
L: 323,
|
|
6610
7188
|
S: this,
|
|
6611
7189
|
C: (f, a) => f(...a)
|
|
6612
7190
|
});
|
|
@@ -6616,11 +7194,11 @@ var ClientServicesHost = class {
|
|
|
6616
7194
|
return;
|
|
6617
7195
|
}
|
|
6618
7196
|
const deviceKey = this._serviceContext.identityManager.identity?.deviceKey;
|
|
6619
|
-
|
|
7197
|
+
log22("closing...", {
|
|
6620
7198
|
deviceKey
|
|
6621
7199
|
}, {
|
|
6622
|
-
F:
|
|
6623
|
-
L:
|
|
7200
|
+
F: __dxlog_file25,
|
|
7201
|
+
L: 334,
|
|
6624
7202
|
S: this,
|
|
6625
7203
|
C: (f, a) => f(...a)
|
|
6626
7204
|
});
|
|
@@ -6634,44 +7212,44 @@ var ClientServicesHost = class {
|
|
|
6634
7212
|
await this._level?.close();
|
|
6635
7213
|
this._open = false;
|
|
6636
7214
|
this._statusUpdate.emit();
|
|
6637
|
-
|
|
7215
|
+
log22("closed", {
|
|
6638
7216
|
deviceKey
|
|
6639
7217
|
}, {
|
|
6640
|
-
F:
|
|
6641
|
-
L:
|
|
7218
|
+
F: __dxlog_file25,
|
|
7219
|
+
L: 343,
|
|
6642
7220
|
S: this,
|
|
6643
7221
|
C: (f, a) => f(...a)
|
|
6644
7222
|
});
|
|
6645
7223
|
}
|
|
6646
7224
|
async reset() {
|
|
6647
|
-
const traceId =
|
|
6648
|
-
|
|
7225
|
+
const traceId = PublicKey17.random().toHex();
|
|
7226
|
+
log22.trace("dxos.sdk.client-services-host.reset", trace10.begin({
|
|
6649
7227
|
id: traceId
|
|
6650
7228
|
}), {
|
|
6651
|
-
F:
|
|
6652
|
-
L:
|
|
7229
|
+
F: __dxlog_file25,
|
|
7230
|
+
L: 348,
|
|
6653
7231
|
S: this,
|
|
6654
7232
|
C: (f, a) => f(...a)
|
|
6655
7233
|
});
|
|
6656
|
-
|
|
6657
|
-
F:
|
|
6658
|
-
L:
|
|
7234
|
+
log22.info("resetting...", void 0, {
|
|
7235
|
+
F: __dxlog_file25,
|
|
7236
|
+
L: 350,
|
|
6659
7237
|
S: this,
|
|
6660
7238
|
C: (f, a) => f(...a)
|
|
6661
7239
|
});
|
|
6662
7240
|
await this._serviceContext?.close();
|
|
6663
7241
|
await this._storage.reset();
|
|
6664
|
-
|
|
6665
|
-
F:
|
|
6666
|
-
L:
|
|
7242
|
+
log22.info("reset", void 0, {
|
|
7243
|
+
F: __dxlog_file25,
|
|
7244
|
+
L: 353,
|
|
6667
7245
|
S: this,
|
|
6668
7246
|
C: (f, a) => f(...a)
|
|
6669
7247
|
});
|
|
6670
|
-
|
|
7248
|
+
log22.trace("dxos.sdk.client-services-host.reset", trace10.end({
|
|
6671
7249
|
id: traceId
|
|
6672
7250
|
}), {
|
|
6673
|
-
F:
|
|
6674
|
-
L:
|
|
7251
|
+
F: __dxlog_file25,
|
|
7252
|
+
L: 354,
|
|
6675
7253
|
S: this,
|
|
6676
7254
|
C: (f, a) => f(...a)
|
|
6677
7255
|
});
|
|
@@ -6729,7 +7307,6 @@ export {
|
|
|
6729
7307
|
SpaceInvitationProtocol,
|
|
6730
7308
|
InvitationsManager,
|
|
6731
7309
|
DataSpace,
|
|
6732
|
-
findPropertiesObject,
|
|
6733
7310
|
DataSpaceManager,
|
|
6734
7311
|
SpacesServiceImpl,
|
|
6735
7312
|
ServiceContext,
|
|
@@ -6738,8 +7315,12 @@ export {
|
|
|
6738
7315
|
isLocked,
|
|
6739
7316
|
createStorageObjects,
|
|
6740
7317
|
createLevel,
|
|
7318
|
+
encodeProfileArchive,
|
|
7319
|
+
decodeProfileArchive,
|
|
7320
|
+
exportProfileData,
|
|
7321
|
+
importProfileData,
|
|
6741
7322
|
ClientServicesHost,
|
|
6742
7323
|
ClientServicesProviderResource,
|
|
6743
7324
|
DiagnosticsCollector
|
|
6744
7325
|
};
|
|
6745
|
-
//# sourceMappingURL=chunk-
|
|
7326
|
+
//# sourceMappingURL=chunk-IUSAD4RP.mjs.map
|