@dxos/client-services 0.5.9-main.21b00b3 → 0.5.9-main.2230e11
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-6Y4QMNUK.mjs → chunk-FYAITMX3.mjs} +1377 -839
- package/dist/lib/browser/chunk-FYAITMX3.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 +11 -5
- package/dist/lib/browser/packlets/testing/index.mjs.map +2 -2
- package/dist/lib/node/{chunk-FYT7BPEG.cjs → chunk-VKQZK2MF.cjs} +1510 -975
- package/dist/lib/node/chunk-VKQZK2MF.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 +18 -12
- package/dist/lib/node/packlets/testing/index.cjs.map +2 -2
- 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-context.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/packlets/testing/test-builder.d.ts.map +1 -1
- 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 +33 -7
- package/src/packlets/invitations/invitations-handler.ts +13 -5
- package/src/packlets/invitations/space-invitation-protocol.ts +11 -32
- package/src/packlets/services/service-context.ts +1 -4
- 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 +76 -148
- package/src/packlets/spaces/epoch-migrations.ts +140 -0
- package/src/packlets/spaces/spaces-service.ts +54 -4
- package/src/packlets/storage/index.ts +1 -0
- package/src/packlets/storage/profile-archive.ts +97 -0
- package/src/packlets/testing/test-builder.ts +1 -4
- package/src/version.ts +1 -1
- package/dist/lib/browser/chunk-6Y4QMNUK.mjs.map +0 -7
- package/dist/lib/node/chunk-FYT7BPEG.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.2230e11";
|
|
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,43 @@ 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: 127,
|
|
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
|
+
});
|
|
1673
|
+
await Promise.race([
|
|
1674
|
+
allProcessed,
|
|
1675
|
+
recordedDefaultSpaceTrigger.wait(),
|
|
1676
|
+
sleep(DEFAULT_SPACE_SEARCH_TIMEOUT)
|
|
1677
|
+
]);
|
|
1678
|
+
if (!recodedDefaultSpace) {
|
|
1636
1679
|
await this._createDefaultSpace(dataSpaceManager);
|
|
1637
1680
|
}
|
|
1638
1681
|
}
|
|
@@ -1642,7 +1685,7 @@ var IdentityServiceImpl = class extends Resource {
|
|
|
1642
1685
|
import { invariant as invariant5 } from "@dxos/invariant";
|
|
1643
1686
|
import { AlreadyJoinedError } from "@dxos/protocols";
|
|
1644
1687
|
import { Invitation } from "@dxos/protocols/proto/dxos/client/services";
|
|
1645
|
-
var
|
|
1688
|
+
var __dxlog_file9 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/device-invitation-protocol.ts";
|
|
1646
1689
|
var DeviceInvitationProtocol = class {
|
|
1647
1690
|
constructor(_keyring, _getIdentity, _acceptIdentity) {
|
|
1648
1691
|
this._keyring = _keyring;
|
|
@@ -1668,7 +1711,7 @@ var DeviceInvitationProtocol = class {
|
|
|
1668
1711
|
}
|
|
1669
1712
|
async admit(_, request) {
|
|
1670
1713
|
invariant5(request.device, void 0, {
|
|
1671
|
-
F:
|
|
1714
|
+
F: __dxlog_file9,
|
|
1672
1715
|
L: 50,
|
|
1673
1716
|
S: this,
|
|
1674
1717
|
A: [
|
|
@@ -1714,7 +1757,7 @@ var DeviceInvitationProtocol = class {
|
|
|
1714
1757
|
}
|
|
1715
1758
|
async accept(response, request) {
|
|
1716
1759
|
invariant5(response.device, void 0, {
|
|
1717
|
-
F:
|
|
1760
|
+
F: __dxlog_file9,
|
|
1718
1761
|
L: 95,
|
|
1719
1762
|
S: this,
|
|
1720
1763
|
A: [
|
|
@@ -1724,7 +1767,7 @@ var DeviceInvitationProtocol = class {
|
|
|
1724
1767
|
});
|
|
1725
1768
|
const { identityKey, haloSpaceKey, genesisFeedKey, controlTimeframe } = response.device;
|
|
1726
1769
|
invariant5(request.device, void 0, {
|
|
1727
|
-
F:
|
|
1770
|
+
F: __dxlog_file9,
|
|
1728
1771
|
L: 98,
|
|
1729
1772
|
S: this,
|
|
1730
1773
|
A: [
|
|
@@ -1756,7 +1799,7 @@ import { ContextDisposedError as ContextDisposedError2 } from "@dxos/context";
|
|
|
1756
1799
|
import { createKeyPair, sign } from "@dxos/crypto";
|
|
1757
1800
|
import { invariant as invariant9 } from "@dxos/invariant";
|
|
1758
1801
|
import { PublicKey as PublicKey7 } from "@dxos/keys";
|
|
1759
|
-
import { log as
|
|
1802
|
+
import { log as log10 } from "@dxos/log";
|
|
1760
1803
|
import { createTeleportProtocolFactory } from "@dxos/network-manager";
|
|
1761
1804
|
import { InvalidInvitationExtensionRoleError as InvalidInvitationExtensionRoleError3, trace as trace5 } from "@dxos/protocols";
|
|
1762
1805
|
import { Invitation as Invitation4 } from "@dxos/protocols/proto/dxos/client/services";
|
|
@@ -1765,10 +1808,10 @@ import { Options as Options4 } from "@dxos/protocols/proto/dxos/halo/invitations
|
|
|
1765
1808
|
import { ComplexSet as ComplexSet3 } from "@dxos/util";
|
|
1766
1809
|
|
|
1767
1810
|
// packages/sdk/client-services/src/packlets/invitations/invitation-guest-extenstion.ts
|
|
1768
|
-
import { Trigger as
|
|
1811
|
+
import { Trigger as Trigger4 } from "@dxos/async";
|
|
1769
1812
|
import { cancelWithContext as cancelWithContext2, Context as Context4 } from "@dxos/context";
|
|
1770
1813
|
import { invariant as invariant6 } from "@dxos/invariant";
|
|
1771
|
-
import { log as
|
|
1814
|
+
import { log as log7 } from "@dxos/log";
|
|
1772
1815
|
import { InvalidInvitationExtensionRoleError, schema as schema2 } from "@dxos/protocols";
|
|
1773
1816
|
import { Options } from "@dxos/protocols/proto/dxos/halo/invitations";
|
|
1774
1817
|
import { RpcExtension } from "@dxos/teleport";
|
|
@@ -1793,7 +1836,7 @@ var tryAcquireBeforeContextDisposed = async (ctx, mutex) => {
|
|
|
1793
1836
|
};
|
|
1794
1837
|
|
|
1795
1838
|
// packages/sdk/client-services/src/packlets/invitations/invitation-guest-extenstion.ts
|
|
1796
|
-
var
|
|
1839
|
+
var __dxlog_file10 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitation-guest-extenstion.ts";
|
|
1797
1840
|
var OPTIONS_TIMEOUT = 1e4;
|
|
1798
1841
|
var InvitationGuestExtension = class extends RpcExtension {
|
|
1799
1842
|
constructor(_invitationFlowMutex, _callbacks) {
|
|
@@ -1807,8 +1850,11 @@ var InvitationGuestExtension = class extends RpcExtension {
|
|
|
1807
1850
|
});
|
|
1808
1851
|
this._invitationFlowMutex = _invitationFlowMutex;
|
|
1809
1852
|
this._callbacks = _callbacks;
|
|
1810
|
-
this._ctx = new Context4(
|
|
1811
|
-
|
|
1853
|
+
this._ctx = new Context4(void 0, {
|
|
1854
|
+
F: __dxlog_file10,
|
|
1855
|
+
L: 33
|
|
1856
|
+
});
|
|
1857
|
+
this._remoteOptionsTrigger = new Trigger4();
|
|
1812
1858
|
this._invitationFlowLock = null;
|
|
1813
1859
|
}
|
|
1814
1860
|
hasFlowLock() {
|
|
@@ -1819,7 +1865,7 @@ var InvitationGuestExtension = class extends RpcExtension {
|
|
|
1819
1865
|
InvitationHostService: {
|
|
1820
1866
|
options: async (options) => {
|
|
1821
1867
|
invariant6(!this._remoteOptions, "Remote options already set.", {
|
|
1822
|
-
F:
|
|
1868
|
+
F: __dxlog_file10,
|
|
1823
1869
|
L: 63,
|
|
1824
1870
|
S: this,
|
|
1825
1871
|
A: [
|
|
@@ -1845,15 +1891,15 @@ var InvitationGuestExtension = class extends RpcExtension {
|
|
|
1845
1891
|
async onOpen(context) {
|
|
1846
1892
|
await super.onOpen(context);
|
|
1847
1893
|
try {
|
|
1848
|
-
|
|
1849
|
-
F:
|
|
1894
|
+
log7("guest acquire lock", void 0, {
|
|
1895
|
+
F: __dxlog_file10,
|
|
1850
1896
|
L: 84,
|
|
1851
1897
|
S: this,
|
|
1852
1898
|
C: (f, a) => f(...a)
|
|
1853
1899
|
});
|
|
1854
1900
|
this._invitationFlowLock = await tryAcquireBeforeContextDisposed(this._ctx, this._invitationFlowMutex);
|
|
1855
|
-
|
|
1856
|
-
F:
|
|
1901
|
+
log7("guest lock acquired", void 0, {
|
|
1902
|
+
F: __dxlog_file10,
|
|
1857
1903
|
L: 86,
|
|
1858
1904
|
S: this,
|
|
1859
1905
|
C: (f, a) => f(...a)
|
|
@@ -1861,8 +1907,8 @@ var InvitationGuestExtension = class extends RpcExtension {
|
|
|
1861
1907
|
await cancelWithContext2(this._ctx, this.rpc.InvitationHostService.options({
|
|
1862
1908
|
role: Options.Role.GUEST
|
|
1863
1909
|
}));
|
|
1864
|
-
|
|
1865
|
-
F:
|
|
1910
|
+
log7("options sent", void 0, {
|
|
1911
|
+
F: __dxlog_file10,
|
|
1866
1912
|
L: 88,
|
|
1867
1913
|
S: this,
|
|
1868
1914
|
C: (f, a) => f(...a)
|
|
@@ -1870,8 +1916,8 @@ var InvitationGuestExtension = class extends RpcExtension {
|
|
|
1870
1916
|
await cancelWithContext2(this._ctx, this._remoteOptionsTrigger.wait({
|
|
1871
1917
|
timeout: OPTIONS_TIMEOUT
|
|
1872
1918
|
}));
|
|
1873
|
-
|
|
1874
|
-
F:
|
|
1919
|
+
log7("options received", void 0, {
|
|
1920
|
+
F: __dxlog_file10,
|
|
1875
1921
|
L: 90,
|
|
1876
1922
|
S: this,
|
|
1877
1923
|
C: (f, a) => f(...a)
|
|
@@ -1904,8 +1950,8 @@ var InvitationGuestExtension = class extends RpcExtension {
|
|
|
1904
1950
|
if (this._invitationFlowLock != null) {
|
|
1905
1951
|
this._invitationFlowLock.release();
|
|
1906
1952
|
this._invitationFlowLock = null;
|
|
1907
|
-
|
|
1908
|
-
F:
|
|
1953
|
+
log7("invitation flow lock released", void 0, {
|
|
1954
|
+
F: __dxlog_file10,
|
|
1909
1955
|
L: 123,
|
|
1910
1956
|
S: this,
|
|
1911
1957
|
C: (f, a) => f(...a)
|
|
@@ -1915,17 +1961,17 @@ var InvitationGuestExtension = class extends RpcExtension {
|
|
|
1915
1961
|
};
|
|
1916
1962
|
|
|
1917
1963
|
// packages/sdk/client-services/src/packlets/invitations/invitation-host-extension.ts
|
|
1918
|
-
import { Trigger as
|
|
1964
|
+
import { Trigger as Trigger5, scheduleTask as scheduleTask2 } from "@dxos/async";
|
|
1919
1965
|
import { cancelWithContext as cancelWithContext3, Context as Context5 } from "@dxos/context";
|
|
1920
1966
|
import { randomBytes, verify } from "@dxos/crypto";
|
|
1921
1967
|
import { invariant as invariant7, InvariantViolation } from "@dxos/invariant";
|
|
1922
1968
|
import { PublicKey as PublicKey5 } from "@dxos/keys";
|
|
1923
|
-
import { log as
|
|
1969
|
+
import { log as log8 } from "@dxos/log";
|
|
1924
1970
|
import { InvalidInvitationExtensionRoleError as InvalidInvitationExtensionRoleError2, schema as schema3, trace as trace4 } from "@dxos/protocols";
|
|
1925
1971
|
import { Invitation as Invitation3 } from "@dxos/protocols/proto/dxos/client/services";
|
|
1926
1972
|
import { AuthenticationResponse, Options as Options2 } from "@dxos/protocols/proto/dxos/halo/invitations";
|
|
1927
1973
|
import { RpcExtension as RpcExtension2 } from "@dxos/teleport";
|
|
1928
|
-
var
|
|
1974
|
+
var __dxlog_file11 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitation-host-extension.ts";
|
|
1929
1975
|
var OPTIONS_TIMEOUT2 = 1e4;
|
|
1930
1976
|
var MAX_OTP_ATTEMPTS = 3;
|
|
1931
1977
|
var InvitationHostExtension = class extends RpcExtension2 {
|
|
@@ -1940,13 +1986,16 @@ var InvitationHostExtension = class extends RpcExtension2 {
|
|
|
1940
1986
|
});
|
|
1941
1987
|
this._invitationFlowMutex = _invitationFlowMutex;
|
|
1942
1988
|
this._callbacks = _callbacks;
|
|
1943
|
-
this._ctx = new Context5(
|
|
1944
|
-
|
|
1989
|
+
this._ctx = new Context5(void 0, {
|
|
1990
|
+
F: __dxlog_file11,
|
|
1991
|
+
L: 52
|
|
1992
|
+
});
|
|
1993
|
+
this._remoteOptionsTrigger = new Trigger5();
|
|
1945
1994
|
this._challenge = void 0;
|
|
1946
1995
|
this.guestProfile = void 0;
|
|
1947
1996
|
this.authenticationPassed = false;
|
|
1948
1997
|
this.authenticationRetry = 0;
|
|
1949
|
-
this.completedTrigger = new
|
|
1998
|
+
this.completedTrigger = new Trigger5();
|
|
1950
1999
|
this._invitationFlowLock = null;
|
|
1951
2000
|
}
|
|
1952
2001
|
hasFlowLock() {
|
|
@@ -1959,7 +2008,7 @@ var InvitationHostExtension = class extends RpcExtension2 {
|
|
|
1959
2008
|
InvitationHostService: {
|
|
1960
2009
|
options: async (options) => {
|
|
1961
2010
|
invariant7(!this._remoteOptions, "Remote options already set.", {
|
|
1962
|
-
F:
|
|
2011
|
+
F: __dxlog_file11,
|
|
1963
2012
|
L: 101,
|
|
1964
2013
|
S: this,
|
|
1965
2014
|
A: [
|
|
@@ -1973,10 +2022,10 @@ var InvitationHostExtension = class extends RpcExtension2 {
|
|
|
1973
2022
|
introduce: async (request) => {
|
|
1974
2023
|
const { profile, invitationId } = request;
|
|
1975
2024
|
const traceId = PublicKey5.random().toHex();
|
|
1976
|
-
|
|
2025
|
+
log8.trace("dxos.sdk.invitation-handler.host.introduce", trace4.begin({
|
|
1977
2026
|
id: traceId
|
|
1978
2027
|
}), {
|
|
1979
|
-
F:
|
|
2028
|
+
F: __dxlog_file11,
|
|
1980
2029
|
L: 110,
|
|
1981
2030
|
S: this,
|
|
1982
2031
|
C: (f, a) => f(...a)
|
|
@@ -1984,11 +2033,11 @@ var InvitationHostExtension = class extends RpcExtension2 {
|
|
|
1984
2033
|
const invitation = this._requireActiveInvitation();
|
|
1985
2034
|
this._assertInvitationState(Invitation3.State.CONNECTED);
|
|
1986
2035
|
if (invitationId !== invitation?.invitationId) {
|
|
1987
|
-
|
|
2036
|
+
log8.warn("incorrect invitationId", {
|
|
1988
2037
|
expected: invitation.invitationId,
|
|
1989
2038
|
actual: invitationId
|
|
1990
2039
|
}, {
|
|
1991
|
-
F:
|
|
2040
|
+
F: __dxlog_file11,
|
|
1992
2041
|
L: 116,
|
|
1993
2042
|
S: this,
|
|
1994
2043
|
C: (f, a) => f(...a)
|
|
@@ -1999,10 +2048,10 @@ var InvitationHostExtension = class extends RpcExtension2 {
|
|
|
1999
2048
|
authMethod: Invitation3.AuthMethod.NONE
|
|
2000
2049
|
};
|
|
2001
2050
|
}
|
|
2002
|
-
|
|
2051
|
+
log8("guest introduced themselves", {
|
|
2003
2052
|
guestProfile: profile
|
|
2004
2053
|
}, {
|
|
2005
|
-
F:
|
|
2054
|
+
F: __dxlog_file11,
|
|
2006
2055
|
L: 125,
|
|
2007
2056
|
S: this,
|
|
2008
2057
|
C: (f, a) => f(...a)
|
|
@@ -2010,10 +2059,10 @@ var InvitationHostExtension = class extends RpcExtension2 {
|
|
|
2010
2059
|
this.guestProfile = profile;
|
|
2011
2060
|
this._callbacks.onStateUpdate(Invitation3.State.READY_FOR_AUTHENTICATION);
|
|
2012
2061
|
this._challenge = invitation.authMethod === Invitation3.AuthMethod.KNOWN_PUBLIC_KEY ? randomBytes(32) : void 0;
|
|
2013
|
-
|
|
2062
|
+
log8.trace("dxos.sdk.invitation-handler.host.introduce", trace4.end({
|
|
2014
2063
|
id: traceId
|
|
2015
2064
|
}), {
|
|
2016
|
-
F:
|
|
2065
|
+
F: __dxlog_file11,
|
|
2017
2066
|
L: 132,
|
|
2018
2067
|
S: this,
|
|
2019
2068
|
C: (f, a) => f(...a)
|
|
@@ -2025,19 +2074,19 @@ var InvitationHostExtension = class extends RpcExtension2 {
|
|
|
2025
2074
|
},
|
|
2026
2075
|
authenticate: async ({ authCode: code, signedChallenge }) => {
|
|
2027
2076
|
const traceId = PublicKey5.random().toHex();
|
|
2028
|
-
|
|
2077
|
+
log8.trace("dxos.sdk.invitation-handler.host.authenticate", trace4.begin({
|
|
2029
2078
|
id: traceId
|
|
2030
2079
|
}), {
|
|
2031
|
-
F:
|
|
2080
|
+
F: __dxlog_file11,
|
|
2032
2081
|
L: 141,
|
|
2033
2082
|
S: this,
|
|
2034
2083
|
C: (f, a) => f(...a)
|
|
2035
2084
|
});
|
|
2036
2085
|
const invitation = this._requireActiveInvitation();
|
|
2037
|
-
|
|
2086
|
+
log8("received authentication request", {
|
|
2038
2087
|
authCode: code
|
|
2039
2088
|
}, {
|
|
2040
|
-
F:
|
|
2089
|
+
F: __dxlog_file11,
|
|
2041
2090
|
L: 144,
|
|
2042
2091
|
S: this,
|
|
2043
2092
|
C: (f, a) => f(...a)
|
|
@@ -2050,8 +2099,8 @@ var InvitationHostExtension = class extends RpcExtension2 {
|
|
|
2050
2099
|
this._callbacks.onStateUpdate(Invitation3.State.AUTHENTICATING);
|
|
2051
2100
|
switch (invitation.authMethod) {
|
|
2052
2101
|
case Invitation3.AuthMethod.NONE: {
|
|
2053
|
-
|
|
2054
|
-
F:
|
|
2102
|
+
log8("authentication not required", void 0, {
|
|
2103
|
+
F: __dxlog_file11,
|
|
2055
2104
|
L: 152,
|
|
2056
2105
|
S: this,
|
|
2057
2106
|
C: (f, a) => f(...a)
|
|
@@ -2086,10 +2135,10 @@ var InvitationHostExtension = class extends RpcExtension2 {
|
|
|
2086
2135
|
break;
|
|
2087
2136
|
}
|
|
2088
2137
|
default: {
|
|
2089
|
-
|
|
2138
|
+
log8.error("invalid authentication method", {
|
|
2090
2139
|
authMethod: invitation.authMethod
|
|
2091
2140
|
}, {
|
|
2092
|
-
F:
|
|
2141
|
+
F: __dxlog_file11,
|
|
2093
2142
|
L: 190,
|
|
2094
2143
|
S: this,
|
|
2095
2144
|
C: (f, a) => f(...a)
|
|
@@ -2108,13 +2157,13 @@ var InvitationHostExtension = class extends RpcExtension2 {
|
|
|
2108
2157
|
status
|
|
2109
2158
|
};
|
|
2110
2159
|
}
|
|
2111
|
-
|
|
2160
|
+
log8.trace("dxos.sdk.invitation-handler.host.authenticate", trace4.end({
|
|
2112
2161
|
id: traceId,
|
|
2113
2162
|
data: {
|
|
2114
2163
|
status
|
|
2115
2164
|
}
|
|
2116
2165
|
}), {
|
|
2117
|
-
F:
|
|
2166
|
+
F: __dxlog_file11,
|
|
2118
2167
|
L: 202,
|
|
2119
2168
|
S: this,
|
|
2120
2169
|
C: (f, a) => f(...a)
|
|
@@ -2125,10 +2174,10 @@ var InvitationHostExtension = class extends RpcExtension2 {
|
|
|
2125
2174
|
},
|
|
2126
2175
|
admit: async (request) => {
|
|
2127
2176
|
const traceId = PublicKey5.random().toHex();
|
|
2128
|
-
|
|
2177
|
+
log8.trace("dxos.sdk.invitation-handler.host.admit", trace4.begin({
|
|
2129
2178
|
id: traceId
|
|
2130
2179
|
}), {
|
|
2131
|
-
F:
|
|
2180
|
+
F: __dxlog_file11,
|
|
2132
2181
|
L: 208,
|
|
2133
2182
|
S: this,
|
|
2134
2183
|
C: (f, a) => f(...a)
|
|
@@ -2142,10 +2191,10 @@ var InvitationHostExtension = class extends RpcExtension2 {
|
|
|
2142
2191
|
}
|
|
2143
2192
|
}
|
|
2144
2193
|
const response = await this._callbacks.admit(request);
|
|
2145
|
-
|
|
2194
|
+
log8.trace("dxos.sdk.invitation-handler.host.admit", trace4.end({
|
|
2146
2195
|
id: traceId
|
|
2147
2196
|
}), {
|
|
2148
|
-
F:
|
|
2197
|
+
F: __dxlog_file11,
|
|
2149
2198
|
L: 222,
|
|
2150
2199
|
S: this,
|
|
2151
2200
|
C: (f, a) => f(...a)
|
|
@@ -2162,15 +2211,15 @@ var InvitationHostExtension = class extends RpcExtension2 {
|
|
|
2162
2211
|
async onOpen(context) {
|
|
2163
2212
|
await super.onOpen(context);
|
|
2164
2213
|
try {
|
|
2165
|
-
|
|
2166
|
-
F:
|
|
2214
|
+
log8("host acquire lock", void 0, {
|
|
2215
|
+
F: __dxlog_file11,
|
|
2167
2216
|
L: 237,
|
|
2168
2217
|
S: this,
|
|
2169
2218
|
C: (f, a) => f(...a)
|
|
2170
2219
|
});
|
|
2171
2220
|
this._invitationFlowLock = await tryAcquireBeforeContextDisposed(this._ctx, this._invitationFlowMutex);
|
|
2172
|
-
|
|
2173
|
-
F:
|
|
2221
|
+
log8("host lock acquired", void 0, {
|
|
2222
|
+
F: __dxlog_file11,
|
|
2174
2223
|
L: 239,
|
|
2175
2224
|
S: this,
|
|
2176
2225
|
C: (f, a) => f(...a)
|
|
@@ -2180,8 +2229,8 @@ var InvitationHostExtension = class extends RpcExtension2 {
|
|
|
2180
2229
|
await this.rpc.InvitationHostService.options({
|
|
2181
2230
|
role: Options2.Role.HOST
|
|
2182
2231
|
});
|
|
2183
|
-
|
|
2184
|
-
F:
|
|
2232
|
+
log8("options sent", void 0, {
|
|
2233
|
+
F: __dxlog_file11,
|
|
2185
2234
|
L: 243,
|
|
2186
2235
|
S: this,
|
|
2187
2236
|
C: (f, a) => f(...a)
|
|
@@ -2189,8 +2238,8 @@ var InvitationHostExtension = class extends RpcExtension2 {
|
|
|
2189
2238
|
await cancelWithContext3(this._ctx, this._remoteOptionsTrigger.wait({
|
|
2190
2239
|
timeout: OPTIONS_TIMEOUT2
|
|
2191
2240
|
}));
|
|
2192
|
-
|
|
2193
|
-
F:
|
|
2241
|
+
log8("options received", void 0, {
|
|
2242
|
+
F: __dxlog_file11,
|
|
2194
2243
|
L: 245,
|
|
2195
2244
|
S: this,
|
|
2196
2245
|
C: (f, a) => f(...a)
|
|
@@ -2243,8 +2292,8 @@ var InvitationHostExtension = class extends RpcExtension2 {
|
|
|
2243
2292
|
if (this._invitationFlowLock != null) {
|
|
2244
2293
|
this._invitationFlowLock?.release();
|
|
2245
2294
|
this._invitationFlowLock = null;
|
|
2246
|
-
|
|
2247
|
-
F:
|
|
2295
|
+
log8("invitation flow lock released", void 0, {
|
|
2296
|
+
F: __dxlog_file11,
|
|
2248
2297
|
L: 300,
|
|
2249
2298
|
S: this,
|
|
2250
2299
|
C: (f, a) => f(...a)
|
|
@@ -2257,10 +2306,10 @@ var isAuthenticationRequired = (invitation) => invitation.authMethod !== Invitat
|
|
|
2257
2306
|
// packages/sdk/client-services/src/packlets/invitations/invitation-topology.ts
|
|
2258
2307
|
import { invariant as invariant8 } from "@dxos/invariant";
|
|
2259
2308
|
import { PublicKey as PublicKey6 } from "@dxos/keys";
|
|
2260
|
-
import { log as
|
|
2309
|
+
import { log as log9 } from "@dxos/log";
|
|
2261
2310
|
import { Options as Options3 } from "@dxos/protocols/proto/dxos/halo/invitations";
|
|
2262
2311
|
import { ComplexSet as ComplexSet2 } from "@dxos/util";
|
|
2263
|
-
var
|
|
2312
|
+
var __dxlog_file12 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitation-topology.ts";
|
|
2264
2313
|
var InvitationTopology = class {
|
|
2265
2314
|
constructor(_role) {
|
|
2266
2315
|
this._role = _role;
|
|
@@ -2268,7 +2317,7 @@ var InvitationTopology = class {
|
|
|
2268
2317
|
}
|
|
2269
2318
|
init(controller) {
|
|
2270
2319
|
invariant8(!this._controller, "Already initialized.", {
|
|
2271
|
-
F:
|
|
2320
|
+
F: __dxlog_file12,
|
|
2272
2321
|
L: 42,
|
|
2273
2322
|
S: this,
|
|
2274
2323
|
A: [
|
|
@@ -2280,7 +2329,7 @@ var InvitationTopology = class {
|
|
|
2280
2329
|
}
|
|
2281
2330
|
update() {
|
|
2282
2331
|
invariant8(this._controller, "Not initialized.", {
|
|
2283
|
-
F:
|
|
2332
|
+
F: __dxlog_file12,
|
|
2284
2333
|
L: 47,
|
|
2285
2334
|
S: this,
|
|
2286
2335
|
A: [
|
|
@@ -2299,11 +2348,11 @@ var InvitationTopology = class {
|
|
|
2299
2348
|
const firstUnknownPeer = candidates.find((peerId) => !this._seenPeers.has(peerId));
|
|
2300
2349
|
this._seenPeers = new ComplexSet2(PublicKey6.hash, allPeers.filter((peerId) => this._seenPeers.has(peerId)));
|
|
2301
2350
|
if (firstUnknownPeer != null) {
|
|
2302
|
-
|
|
2351
|
+
log9("invitation connect", {
|
|
2303
2352
|
ownPeerId,
|
|
2304
2353
|
remotePeerId: firstUnknownPeer
|
|
2305
2354
|
}, {
|
|
2306
|
-
F:
|
|
2355
|
+
F: __dxlog_file12,
|
|
2307
2356
|
L: 69,
|
|
2308
2357
|
S: this,
|
|
2309
2358
|
C: (f, a) => f(...a)
|
|
@@ -2314,7 +2363,7 @@ var InvitationTopology = class {
|
|
|
2314
2363
|
}
|
|
2315
2364
|
async onOffer(peer) {
|
|
2316
2365
|
invariant8(this._controller, "Not initialized.", {
|
|
2317
|
-
F:
|
|
2366
|
+
F: __dxlog_file12,
|
|
2318
2367
|
L: 76,
|
|
2319
2368
|
S: this,
|
|
2320
2369
|
A: [
|
|
@@ -2333,7 +2382,7 @@ var InvitationTopology = class {
|
|
|
2333
2382
|
};
|
|
2334
2383
|
|
|
2335
2384
|
// packages/sdk/client-services/src/packlets/invitations/invitations-handler.ts
|
|
2336
|
-
var
|
|
2385
|
+
var __dxlog_file13 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitations-handler.ts";
|
|
2337
2386
|
var MAX_DELEGATED_INVITATION_HOST_TRIES = 3;
|
|
2338
2387
|
var InvitationsHandler = class {
|
|
2339
2388
|
/**
|
|
@@ -2358,7 +2407,7 @@ var InvitationsHandler = class {
|
|
|
2358
2407
|
try {
|
|
2359
2408
|
const deviceKey = admissionRequest.device?.deviceKey ?? admissionRequest.space?.deviceKey;
|
|
2360
2409
|
invariant9(deviceKey, void 0, {
|
|
2361
|
-
F:
|
|
2410
|
+
F: __dxlog_file13,
|
|
2362
2411
|
L: 90,
|
|
2363
2412
|
S: this,
|
|
2364
2413
|
A: [
|
|
@@ -2384,18 +2433,18 @@ var InvitationsHandler = class {
|
|
|
2384
2433
|
scheduleTask3(connectionCtx, async () => {
|
|
2385
2434
|
const traceId = PublicKey7.random().toHex();
|
|
2386
2435
|
try {
|
|
2387
|
-
|
|
2436
|
+
log10.trace("dxos.sdk.invitations-handler.host.onOpen", trace5.begin({
|
|
2388
2437
|
id: traceId
|
|
2389
2438
|
}), {
|
|
2390
|
-
F:
|
|
2439
|
+
F: __dxlog_file13,
|
|
2391
2440
|
L: 115,
|
|
2392
2441
|
S: this,
|
|
2393
2442
|
C: (f, a) => f(...a)
|
|
2394
2443
|
});
|
|
2395
|
-
|
|
2444
|
+
log10("connected", {
|
|
2396
2445
|
...protocol.toJSON()
|
|
2397
2446
|
}, {
|
|
2398
|
-
F:
|
|
2447
|
+
F: __dxlog_file13,
|
|
2399
2448
|
L: 116,
|
|
2400
2449
|
S: this,
|
|
2401
2450
|
C: (f, a) => f(...a)
|
|
@@ -2403,20 +2452,20 @@ var InvitationsHandler = class {
|
|
|
2403
2452
|
const deviceKey = await extension.completedTrigger.wait({
|
|
2404
2453
|
timeout: invitation.timeout
|
|
2405
2454
|
});
|
|
2406
|
-
|
|
2455
|
+
log10("admitted guest", {
|
|
2407
2456
|
guest: deviceKey,
|
|
2408
2457
|
...protocol.toJSON()
|
|
2409
2458
|
}, {
|
|
2410
|
-
F:
|
|
2459
|
+
F: __dxlog_file13,
|
|
2411
2460
|
L: 118,
|
|
2412
2461
|
S: this,
|
|
2413
2462
|
C: (f, a) => f(...a)
|
|
2414
2463
|
});
|
|
2415
2464
|
guardedState.set(extension, Invitation4.State.SUCCESS);
|
|
2416
|
-
|
|
2465
|
+
log10.trace("dxos.sdk.invitations-handler.host.onOpen", trace5.end({
|
|
2417
2466
|
id: traceId
|
|
2418
2467
|
}), {
|
|
2419
|
-
F:
|
|
2468
|
+
F: __dxlog_file13,
|
|
2420
2469
|
L: 120,
|
|
2421
2470
|
S: this,
|
|
2422
2471
|
C: (f, a) => f(...a)
|
|
@@ -2428,10 +2477,10 @@ var InvitationsHandler = class {
|
|
|
2428
2477
|
} catch (err) {
|
|
2429
2478
|
if (err instanceof TimeoutError) {
|
|
2430
2479
|
if (guardedState.set(extension, Invitation4.State.TIMEOUT)) {
|
|
2431
|
-
|
|
2480
|
+
log10("timeout", {
|
|
2432
2481
|
...protocol.toJSON()
|
|
2433
2482
|
}, {
|
|
2434
|
-
F:
|
|
2483
|
+
F: __dxlog_file13,
|
|
2435
2484
|
L: 129,
|
|
2436
2485
|
S: this,
|
|
2437
2486
|
C: (f, a) => f(...a)
|
|
@@ -2439,19 +2488,19 @@ var InvitationsHandler = class {
|
|
|
2439
2488
|
}
|
|
2440
2489
|
} else {
|
|
2441
2490
|
if (guardedState.error(extension, err)) {
|
|
2442
|
-
|
|
2443
|
-
F:
|
|
2491
|
+
log10.error("failed", err, {
|
|
2492
|
+
F: __dxlog_file13,
|
|
2444
2493
|
L: 133,
|
|
2445
2494
|
S: this,
|
|
2446
2495
|
C: (f, a) => f(...a)
|
|
2447
2496
|
});
|
|
2448
2497
|
}
|
|
2449
2498
|
}
|
|
2450
|
-
|
|
2499
|
+
log10.trace("dxos.sdk.invitations-handler.host.onOpen", trace5.error({
|
|
2451
2500
|
id: traceId,
|
|
2452
2501
|
error: err
|
|
2453
2502
|
}), {
|
|
2454
|
-
F:
|
|
2503
|
+
F: __dxlog_file13,
|
|
2455
2504
|
L: 136,
|
|
2456
2505
|
S: this,
|
|
2457
2506
|
C: (f, a) => f(...a)
|
|
@@ -2462,10 +2511,10 @@ var InvitationsHandler = class {
|
|
|
2462
2511
|
},
|
|
2463
2512
|
onError: (err) => {
|
|
2464
2513
|
if (err instanceof InvalidInvitationExtensionRoleError3) {
|
|
2465
|
-
|
|
2514
|
+
log10("invalid role", {
|
|
2466
2515
|
...err.context
|
|
2467
2516
|
}, {
|
|
2468
|
-
F:
|
|
2517
|
+
F: __dxlog_file13,
|
|
2469
2518
|
L: 144,
|
|
2470
2519
|
S: this,
|
|
2471
2520
|
C: (f, a) => f(...a)
|
|
@@ -2474,10 +2523,10 @@ var InvitationsHandler = class {
|
|
|
2474
2523
|
}
|
|
2475
2524
|
if (err instanceof TimeoutError) {
|
|
2476
2525
|
if (guardedState.set(extension, Invitation4.State.TIMEOUT)) {
|
|
2477
|
-
|
|
2526
|
+
log10("timeout", {
|
|
2478
2527
|
err
|
|
2479
2528
|
}, {
|
|
2480
|
-
F:
|
|
2529
|
+
F: __dxlog_file13,
|
|
2481
2530
|
L: 149,
|
|
2482
2531
|
S: this,
|
|
2483
2532
|
C: (f, a) => f(...a)
|
|
@@ -2485,8 +2534,8 @@ var InvitationsHandler = class {
|
|
|
2485
2534
|
}
|
|
2486
2535
|
} else {
|
|
2487
2536
|
if (guardedState.error(extension, err)) {
|
|
2488
|
-
|
|
2489
|
-
F:
|
|
2537
|
+
log10.error("failed", err, {
|
|
2538
|
+
F: __dxlog_file13,
|
|
2490
2539
|
L: 153,
|
|
2491
2540
|
S: this,
|
|
2492
2541
|
C: (f, a) => f(...a)
|
|
@@ -2499,8 +2548,8 @@ var InvitationsHandler = class {
|
|
|
2499
2548
|
};
|
|
2500
2549
|
if (invitation.lifetime && invitation.created) {
|
|
2501
2550
|
if (invitation.created.getTime() + invitation.lifetime * 1e3 < Date.now()) {
|
|
2502
|
-
|
|
2503
|
-
F:
|
|
2551
|
+
log10.warn("invitation has already expired", void 0, {
|
|
2552
|
+
F: __dxlog_file13,
|
|
2504
2553
|
L: 164,
|
|
2505
2554
|
S: this,
|
|
2506
2555
|
C: (f, a) => f(...a)
|
|
@@ -2523,7 +2572,7 @@ var InvitationsHandler = class {
|
|
|
2523
2572
|
const { timeout = INVITATION_TIMEOUT } = invitation;
|
|
2524
2573
|
if (deviceProfile) {
|
|
2525
2574
|
invariant9(invitation.kind === Invitation4.Kind.DEVICE, "deviceProfile provided for non-device invitation", {
|
|
2526
|
-
F:
|
|
2575
|
+
F: __dxlog_file13,
|
|
2527
2576
|
L: 197,
|
|
2528
2577
|
S: this,
|
|
2529
2578
|
A: [
|
|
@@ -2536,12 +2585,12 @@ var InvitationsHandler = class {
|
|
|
2536
2585
|
const guardedState = this._createGuardedState(ctx, invitation, stream);
|
|
2537
2586
|
const shouldCancelInvitationFlow = (extension) => {
|
|
2538
2587
|
const isLockedByAnotherConnection = guardedState.mutex.isLocked() && !extension.hasFlowLock();
|
|
2539
|
-
|
|
2588
|
+
log10("should cancel invitation flow", {
|
|
2540
2589
|
isLockedByAnotherConnection,
|
|
2541
2590
|
invitationType: Invitation4.Type.DELEGATED,
|
|
2542
2591
|
triedPeers: triedPeersIds.size
|
|
2543
2592
|
}, {
|
|
2544
|
-
F:
|
|
2593
|
+
F: __dxlog_file13,
|
|
2545
2594
|
L: 205,
|
|
2546
2595
|
S: this,
|
|
2547
2596
|
C: (f, a) => f(...a)
|
|
@@ -2564,11 +2613,11 @@ var InvitationsHandler = class {
|
|
|
2564
2613
|
return;
|
|
2565
2614
|
}
|
|
2566
2615
|
connectionCtx.onDispose(async () => {
|
|
2567
|
-
|
|
2616
|
+
log10("extension disposed", {
|
|
2568
2617
|
admitted,
|
|
2569
2618
|
currentState: guardedState.current.state
|
|
2570
2619
|
}, {
|
|
2571
|
-
F:
|
|
2620
|
+
F: __dxlog_file13,
|
|
2572
2621
|
L: 233,
|
|
2573
2622
|
S: this,
|
|
2574
2623
|
C: (f, a) => f(...a)
|
|
@@ -2583,10 +2632,10 @@ var InvitationsHandler = class {
|
|
|
2583
2632
|
scheduleTask3(connectionCtx, async () => {
|
|
2584
2633
|
const traceId = PublicKey7.random().toHex();
|
|
2585
2634
|
try {
|
|
2586
|
-
|
|
2635
|
+
log10.trace("dxos.sdk.invitations-handler.guest.onOpen", trace5.begin({
|
|
2587
2636
|
id: traceId
|
|
2588
2637
|
}), {
|
|
2589
|
-
F:
|
|
2638
|
+
F: __dxlog_file13,
|
|
2590
2639
|
L: 245,
|
|
2591
2640
|
S: this,
|
|
2592
2641
|
C: (f, a) => f(...a)
|
|
@@ -2595,19 +2644,19 @@ var InvitationsHandler = class {
|
|
|
2595
2644
|
guardedState.set(extension, Invitation4.State.TIMEOUT);
|
|
2596
2645
|
extensionCtx.close();
|
|
2597
2646
|
}, timeout);
|
|
2598
|
-
|
|
2647
|
+
log10("connected", {
|
|
2599
2648
|
...protocol.toJSON()
|
|
2600
2649
|
}, {
|
|
2601
|
-
F:
|
|
2650
|
+
F: __dxlog_file13,
|
|
2602
2651
|
L: 256,
|
|
2603
2652
|
S: this,
|
|
2604
2653
|
C: (f, a) => f(...a)
|
|
2605
2654
|
});
|
|
2606
2655
|
guardedState.set(extension, Invitation4.State.CONNECTED);
|
|
2607
|
-
|
|
2656
|
+
log10("introduce", {
|
|
2608
2657
|
...protocol.toJSON()
|
|
2609
2658
|
}, {
|
|
2610
|
-
F:
|
|
2659
|
+
F: __dxlog_file13,
|
|
2611
2660
|
L: 260,
|
|
2612
2661
|
S: this,
|
|
2613
2662
|
C: (f, a) => f(...a)
|
|
@@ -2616,11 +2665,11 @@ var InvitationsHandler = class {
|
|
|
2616
2665
|
invitationId: invitation.invitationId,
|
|
2617
2666
|
...protocol.createIntroduction()
|
|
2618
2667
|
});
|
|
2619
|
-
|
|
2668
|
+
log10("introduce response", {
|
|
2620
2669
|
...protocol.toJSON(),
|
|
2621
2670
|
response: introductionResponse
|
|
2622
2671
|
}, {
|
|
2623
|
-
F:
|
|
2672
|
+
F: __dxlog_file13,
|
|
2624
2673
|
L: 265,
|
|
2625
2674
|
S: this,
|
|
2626
2675
|
C: (f, a) => f(...a)
|
|
@@ -2638,10 +2687,10 @@ var InvitationsHandler = class {
|
|
|
2638
2687
|
break;
|
|
2639
2688
|
}
|
|
2640
2689
|
}
|
|
2641
|
-
|
|
2690
|
+
log10("request admission", {
|
|
2642
2691
|
...protocol.toJSON()
|
|
2643
2692
|
}, {
|
|
2644
|
-
F:
|
|
2693
|
+
F: __dxlog_file13,
|
|
2645
2694
|
L: 291,
|
|
2646
2695
|
S: this,
|
|
2647
2696
|
C: (f, a) => f(...a)
|
|
@@ -2650,10 +2699,10 @@ var InvitationsHandler = class {
|
|
|
2650
2699
|
const admissionResponse = await extension.rpc.InvitationHostService.admit(admissionRequest);
|
|
2651
2700
|
admitted = true;
|
|
2652
2701
|
const result = await protocol.accept(admissionResponse, admissionRequest);
|
|
2653
|
-
|
|
2702
|
+
log10("admitted by host", {
|
|
2654
2703
|
...protocol.toJSON()
|
|
2655
2704
|
}, {
|
|
2656
|
-
F:
|
|
2705
|
+
F: __dxlog_file13,
|
|
2657
2706
|
L: 302,
|
|
2658
2707
|
S: this,
|
|
2659
2708
|
C: (f, a) => f(...a)
|
|
@@ -2663,28 +2712,28 @@ var InvitationsHandler = class {
|
|
|
2663
2712
|
...result,
|
|
2664
2713
|
state: Invitation4.State.SUCCESS
|
|
2665
2714
|
});
|
|
2666
|
-
|
|
2715
|
+
log10.trace("dxos.sdk.invitations-handler.guest.onOpen", trace5.end({
|
|
2667
2716
|
id: traceId
|
|
2668
2717
|
}), {
|
|
2669
|
-
F:
|
|
2718
|
+
F: __dxlog_file13,
|
|
2670
2719
|
L: 308,
|
|
2671
2720
|
S: this,
|
|
2672
2721
|
C: (f, a) => f(...a)
|
|
2673
2722
|
});
|
|
2674
2723
|
} catch (err) {
|
|
2675
2724
|
if (err instanceof TimeoutError) {
|
|
2676
|
-
|
|
2725
|
+
log10("timeout", {
|
|
2677
2726
|
...protocol.toJSON()
|
|
2678
2727
|
}, {
|
|
2679
|
-
F:
|
|
2728
|
+
F: __dxlog_file13,
|
|
2680
2729
|
L: 311,
|
|
2681
2730
|
S: this,
|
|
2682
2731
|
C: (f, a) => f(...a)
|
|
2683
2732
|
});
|
|
2684
2733
|
guardedState.set(extension, Invitation4.State.TIMEOUT);
|
|
2685
2734
|
} else {
|
|
2686
|
-
|
|
2687
|
-
F:
|
|
2735
|
+
log10("auth failed", err, {
|
|
2736
|
+
F: __dxlog_file13,
|
|
2688
2737
|
L: 314,
|
|
2689
2738
|
S: this,
|
|
2690
2739
|
C: (f, a) => f(...a)
|
|
@@ -2692,11 +2741,11 @@ var InvitationsHandler = class {
|
|
|
2692
2741
|
guardedState.error(extension, err);
|
|
2693
2742
|
}
|
|
2694
2743
|
extensionCtx.close(err);
|
|
2695
|
-
|
|
2744
|
+
log10.trace("dxos.sdk.invitations-handler.guest.onOpen", trace5.error({
|
|
2696
2745
|
id: traceId,
|
|
2697
2746
|
error: err
|
|
2698
2747
|
}), {
|
|
2699
|
-
F:
|
|
2748
|
+
F: __dxlog_file13,
|
|
2700
2749
|
L: 318,
|
|
2701
2750
|
S: this,
|
|
2702
2751
|
C: (f, a) => f(...a)
|
|
@@ -2709,18 +2758,18 @@ var InvitationsHandler = class {
|
|
|
2709
2758
|
return;
|
|
2710
2759
|
}
|
|
2711
2760
|
if (err instanceof TimeoutError) {
|
|
2712
|
-
|
|
2761
|
+
log10("timeout", {
|
|
2713
2762
|
...protocol.toJSON()
|
|
2714
2763
|
}, {
|
|
2715
|
-
F:
|
|
2764
|
+
F: __dxlog_file13,
|
|
2716
2765
|
L: 327,
|
|
2717
2766
|
S: this,
|
|
2718
2767
|
C: (f, a) => f(...a)
|
|
2719
2768
|
});
|
|
2720
2769
|
guardedState.set(extension, Invitation4.State.TIMEOUT);
|
|
2721
2770
|
} else {
|
|
2722
|
-
|
|
2723
|
-
F:
|
|
2771
|
+
log10("auth failed", err, {
|
|
2772
|
+
F: __dxlog_file13,
|
|
2724
2773
|
L: 330,
|
|
2725
2774
|
S: this,
|
|
2726
2775
|
C: (f, a) => f(...a)
|
|
@@ -2738,7 +2787,7 @@ var InvitationsHandler = class {
|
|
|
2738
2787
|
await ctx.dispose();
|
|
2739
2788
|
} else {
|
|
2740
2789
|
invariant9(invitation.swarmKey, void 0, {
|
|
2741
|
-
F:
|
|
2790
|
+
F: __dxlog_file13,
|
|
2742
2791
|
L: 345,
|
|
2743
2792
|
S: this,
|
|
2744
2793
|
A: [
|
|
@@ -2832,16 +2881,29 @@ var InvitationsHandler = class {
|
|
|
2832
2881
|
};
|
|
2833
2882
|
}
|
|
2834
2883
|
_logStateUpdate(invitation, actor, newState) {
|
|
2835
|
-
|
|
2836
|
-
|
|
2837
|
-
|
|
2838
|
-
|
|
2839
|
-
|
|
2840
|
-
|
|
2841
|
-
|
|
2842
|
-
|
|
2843
|
-
|
|
2844
|
-
|
|
2884
|
+
if (this._isNotTerminal(newState)) {
|
|
2885
|
+
log10("invitation state update", {
|
|
2886
|
+
actor: actor?.constructor.name,
|
|
2887
|
+
newState: stateToString(newState),
|
|
2888
|
+
oldState: stateToString(invitation.state)
|
|
2889
|
+
}, {
|
|
2890
|
+
F: __dxlog_file13,
|
|
2891
|
+
L: 439,
|
|
2892
|
+
S: this,
|
|
2893
|
+
C: (f, a) => f(...a)
|
|
2894
|
+
});
|
|
2895
|
+
} else {
|
|
2896
|
+
log10.info("invitation state update", {
|
|
2897
|
+
actor: actor?.constructor.name,
|
|
2898
|
+
newState: stateToString(newState),
|
|
2899
|
+
oldState: stateToString(invitation.state)
|
|
2900
|
+
}, {
|
|
2901
|
+
F: __dxlog_file13,
|
|
2902
|
+
L: 445,
|
|
2903
|
+
S: this,
|
|
2904
|
+
C: (f, a) => f(...a)
|
|
2905
|
+
});
|
|
2906
|
+
}
|
|
2845
2907
|
}
|
|
2846
2908
|
_isNotTerminal(currentState) {
|
|
2847
2909
|
return ![
|
|
@@ -2854,17 +2916,17 @@ var InvitationsHandler = class {
|
|
|
2854
2916
|
}
|
|
2855
2917
|
async _handleGuestOtpAuth(extension, setState, authenticated, options) {
|
|
2856
2918
|
for (let attempt = 1; attempt <= MAX_OTP_ATTEMPTS; attempt++) {
|
|
2857
|
-
|
|
2858
|
-
F:
|
|
2859
|
-
L:
|
|
2919
|
+
log10("guest waiting for authentication code...", void 0, {
|
|
2920
|
+
F: __dxlog_file13,
|
|
2921
|
+
L: 470,
|
|
2860
2922
|
S: this,
|
|
2861
2923
|
C: (f, a) => f(...a)
|
|
2862
2924
|
});
|
|
2863
2925
|
setState(Invitation4.State.READY_FOR_AUTHENTICATION);
|
|
2864
2926
|
const authCode = await authenticated.wait(options);
|
|
2865
|
-
|
|
2866
|
-
F:
|
|
2867
|
-
L:
|
|
2927
|
+
log10("sending authentication request", void 0, {
|
|
2928
|
+
F: __dxlog_file13,
|
|
2929
|
+
L: 474,
|
|
2868
2930
|
S: this,
|
|
2869
2931
|
C: (f, a) => f(...a)
|
|
2870
2932
|
});
|
|
@@ -2879,11 +2941,11 @@ var InvitationsHandler = class {
|
|
|
2879
2941
|
if (attempt === MAX_OTP_ATTEMPTS) {
|
|
2880
2942
|
throw new Error(`Maximum retry attempts: ${MAX_OTP_ATTEMPTS}`);
|
|
2881
2943
|
} else {
|
|
2882
|
-
|
|
2944
|
+
log10("retrying invalid code", {
|
|
2883
2945
|
attempt
|
|
2884
2946
|
}, {
|
|
2885
|
-
F:
|
|
2886
|
-
L:
|
|
2947
|
+
F: __dxlog_file13,
|
|
2948
|
+
L: 485,
|
|
2887
2949
|
S: this,
|
|
2888
2950
|
C: (f, a) => f(...a)
|
|
2889
2951
|
});
|
|
@@ -2899,9 +2961,9 @@ var InvitationsHandler = class {
|
|
|
2899
2961
|
if (introductionResponse.challenge == null) {
|
|
2900
2962
|
throw new Error("challenge missing in the introduction");
|
|
2901
2963
|
}
|
|
2902
|
-
|
|
2903
|
-
F:
|
|
2904
|
-
L:
|
|
2964
|
+
log10("sending authentication request", void 0, {
|
|
2965
|
+
F: __dxlog_file13,
|
|
2966
|
+
L: 504,
|
|
2905
2967
|
S: this,
|
|
2906
2968
|
C: (f, a) => f(...a)
|
|
2907
2969
|
});
|
|
@@ -3021,14 +3083,14 @@ var InvitationsServiceImpl = class {
|
|
|
3021
3083
|
};
|
|
3022
3084
|
|
|
3023
3085
|
// packages/sdk/client-services/src/packlets/invitations/space-invitation-protocol.ts
|
|
3024
|
-
import {
|
|
3086
|
+
import { createCancelDelegatedSpaceInvitationCredential, createDelegatedSpaceInvitationCredential, getCredentialAssertion as getCredentialAssertion2 } from "@dxos/credentials";
|
|
3025
3087
|
import { writeMessages as writeMessages2 } from "@dxos/feed-store";
|
|
3026
3088
|
import { invariant as invariant10 } from "@dxos/invariant";
|
|
3027
|
-
import { log as
|
|
3089
|
+
import { log as log11 } from "@dxos/log";
|
|
3028
3090
|
import { AlreadyJoinedError as AlreadyJoinedError2, AuthorizationError, InvalidInvitationError, SpaceNotFoundError } from "@dxos/protocols";
|
|
3029
3091
|
import { Invitation as Invitation5 } from "@dxos/protocols/proto/dxos/client/services";
|
|
3030
3092
|
import { SpaceMember as SpaceMember2 } from "@dxos/protocols/proto/dxos/halo/credentials";
|
|
3031
|
-
var
|
|
3093
|
+
var __dxlog_file14 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/space-invitation-protocol.ts";
|
|
3032
3094
|
var SpaceInvitationProtocol = class {
|
|
3033
3095
|
constructor(_spaceManager, _signingContext, _keyring, _spaceKey) {
|
|
3034
3096
|
this._spaceManager = _spaceManager;
|
|
@@ -3062,79 +3124,43 @@ var SpaceInvitationProtocol = class {
|
|
|
3062
3124
|
};
|
|
3063
3125
|
}
|
|
3064
3126
|
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,
|
|
3127
|
+
invariant10(this._spaceKey && request.space, void 0, {
|
|
3128
|
+
F: __dxlog_file14,
|
|
3129
|
+
L: 74,
|
|
3087
3130
|
S: this,
|
|
3088
3131
|
A: [
|
|
3089
|
-
"request.space",
|
|
3132
|
+
"this._spaceKey && request.space",
|
|
3090
3133
|
""
|
|
3091
3134
|
]
|
|
3092
3135
|
});
|
|
3093
|
-
|
|
3094
|
-
if (space.inner.spaceState.getMemberRole(identityKey) !== SpaceMember2.Role.REMOVED) {
|
|
3095
|
-
throw new AlreadyJoinedError2();
|
|
3096
|
-
}
|
|
3097
|
-
log10("writing guest credentials", {
|
|
3136
|
+
log11("writing guest credentials", {
|
|
3098
3137
|
host: this._signingContext.deviceKey,
|
|
3099
|
-
guest: deviceKey
|
|
3138
|
+
guest: request.space.deviceKey
|
|
3100
3139
|
}, {
|
|
3101
|
-
F:
|
|
3102
|
-
L:
|
|
3140
|
+
F: __dxlog_file14,
|
|
3141
|
+
L: 75,
|
|
3103
3142
|
S: this,
|
|
3104
3143
|
C: (f, a) => f(...a)
|
|
3105
3144
|
});
|
|
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
|
-
]
|
|
3145
|
+
const spaceMemberCredential = await this._spaceManager.admitMember({
|
|
3146
|
+
spaceKey: this._spaceKey,
|
|
3147
|
+
identityKey: request.space.identityKey,
|
|
3148
|
+
role: invitation.role ?? SpaceMember2.Role.ADMIN,
|
|
3149
|
+
profile: guestProfile,
|
|
3150
|
+
delegationCredentialId: invitation.delegationCredentialId
|
|
3125
3151
|
});
|
|
3126
|
-
|
|
3152
|
+
const space = this._spaceManager.spaces.get(this._spaceKey);
|
|
3127
3153
|
return {
|
|
3128
3154
|
space: {
|
|
3129
3155
|
credential: spaceMemberCredential,
|
|
3130
|
-
controlTimeframe: space
|
|
3156
|
+
controlTimeframe: space?.inner.controlPipeline.state.timeframe
|
|
3131
3157
|
}
|
|
3132
3158
|
};
|
|
3133
3159
|
}
|
|
3134
3160
|
async delegate(invitation) {
|
|
3135
3161
|
invariant10(this._spaceKey, void 0, {
|
|
3136
|
-
F:
|
|
3137
|
-
L:
|
|
3162
|
+
F: __dxlog_file14,
|
|
3163
|
+
L: 95,
|
|
3138
3164
|
S: this,
|
|
3139
3165
|
A: [
|
|
3140
3166
|
"this._spaceKey",
|
|
@@ -3143,8 +3169,8 @@ var SpaceInvitationProtocol = class {
|
|
|
3143
3169
|
});
|
|
3144
3170
|
const space = this._spaceManager.spaces.get(this._spaceKey);
|
|
3145
3171
|
invariant10(space, void 0, {
|
|
3146
|
-
F:
|
|
3147
|
-
L:
|
|
3172
|
+
F: __dxlog_file14,
|
|
3173
|
+
L: 97,
|
|
3148
3174
|
S: this,
|
|
3149
3175
|
A: [
|
|
3150
3176
|
"space",
|
|
@@ -3153,8 +3179,8 @@ var SpaceInvitationProtocol = class {
|
|
|
3153
3179
|
});
|
|
3154
3180
|
if (invitation.authMethod === Invitation5.AuthMethod.KNOWN_PUBLIC_KEY) {
|
|
3155
3181
|
invariant10(invitation.guestKeypair?.publicKey, void 0, {
|
|
3156
|
-
F:
|
|
3157
|
-
L:
|
|
3182
|
+
F: __dxlog_file14,
|
|
3183
|
+
L: 99,
|
|
3158
3184
|
S: this,
|
|
3159
3185
|
A: [
|
|
3160
3186
|
"invitation.guestKeypair?.publicKey",
|
|
@@ -3162,12 +3188,12 @@ var SpaceInvitationProtocol = class {
|
|
|
3162
3188
|
]
|
|
3163
3189
|
});
|
|
3164
3190
|
}
|
|
3165
|
-
|
|
3191
|
+
log11("writing delegate space invitation", {
|
|
3166
3192
|
host: this._signingContext.deviceKey,
|
|
3167
3193
|
id: invitation.invitationId
|
|
3168
3194
|
}, {
|
|
3169
|
-
F:
|
|
3170
|
-
L:
|
|
3195
|
+
F: __dxlog_file14,
|
|
3196
|
+
L: 102,
|
|
3171
3197
|
S: this,
|
|
3172
3198
|
C: (f, a) => f(...a)
|
|
3173
3199
|
});
|
|
@@ -3181,8 +3207,8 @@ var SpaceInvitationProtocol = class {
|
|
|
3181
3207
|
guestKey: invitation.authMethod === Invitation5.AuthMethod.KNOWN_PUBLIC_KEY ? invitation.guestKeypair.publicKey : void 0
|
|
3182
3208
|
});
|
|
3183
3209
|
invariant10(credential.credential, void 0, {
|
|
3184
|
-
F:
|
|
3185
|
-
L:
|
|
3210
|
+
F: __dxlog_file14,
|
|
3211
|
+
L: 122,
|
|
3186
3212
|
S: this,
|
|
3187
3213
|
A: [
|
|
3188
3214
|
"credential.credential",
|
|
@@ -3196,8 +3222,8 @@ var SpaceInvitationProtocol = class {
|
|
|
3196
3222
|
}
|
|
3197
3223
|
async cancelDelegation(invitation) {
|
|
3198
3224
|
invariant10(this._spaceKey, void 0, {
|
|
3199
|
-
F:
|
|
3200
|
-
L:
|
|
3225
|
+
F: __dxlog_file14,
|
|
3226
|
+
L: 128,
|
|
3201
3227
|
S: this,
|
|
3202
3228
|
A: [
|
|
3203
3229
|
"this._spaceKey",
|
|
@@ -3205,8 +3231,8 @@ var SpaceInvitationProtocol = class {
|
|
|
3205
3231
|
]
|
|
3206
3232
|
});
|
|
3207
3233
|
invariant10(invitation.type === Invitation5.Type.DELEGATED && invitation.delegationCredentialId, void 0, {
|
|
3208
|
-
F:
|
|
3209
|
-
L:
|
|
3234
|
+
F: __dxlog_file14,
|
|
3235
|
+
L: 129,
|
|
3210
3236
|
S: this,
|
|
3211
3237
|
A: [
|
|
3212
3238
|
"invitation.type === Invitation.Type.DELEGATED && invitation.delegationCredentialId",
|
|
@@ -3215,27 +3241,27 @@ var SpaceInvitationProtocol = class {
|
|
|
3215
3241
|
});
|
|
3216
3242
|
const space = this._spaceManager.spaces.get(this._spaceKey);
|
|
3217
3243
|
invariant10(space, void 0, {
|
|
3218
|
-
F:
|
|
3219
|
-
L:
|
|
3244
|
+
F: __dxlog_file14,
|
|
3245
|
+
L: 131,
|
|
3220
3246
|
S: this,
|
|
3221
3247
|
A: [
|
|
3222
3248
|
"space",
|
|
3223
3249
|
""
|
|
3224
3250
|
]
|
|
3225
3251
|
});
|
|
3226
|
-
|
|
3252
|
+
log11("cancelling delegated space invitation", {
|
|
3227
3253
|
host: this._signingContext.deviceKey,
|
|
3228
3254
|
id: invitation.invitationId
|
|
3229
3255
|
}, {
|
|
3230
|
-
F:
|
|
3231
|
-
L:
|
|
3256
|
+
F: __dxlog_file14,
|
|
3257
|
+
L: 133,
|
|
3232
3258
|
S: this,
|
|
3233
3259
|
C: (f, a) => f(...a)
|
|
3234
3260
|
});
|
|
3235
3261
|
const credential = await createCancelDelegatedSpaceInvitationCredential(this._signingContext.credentialSigner, space.key, invitation.delegationCredentialId);
|
|
3236
3262
|
invariant10(credential.credential, void 0, {
|
|
3237
|
-
F:
|
|
3238
|
-
L:
|
|
3263
|
+
F: __dxlog_file14,
|
|
3264
|
+
L: 140,
|
|
3239
3265
|
S: this,
|
|
3240
3266
|
A: [
|
|
3241
3267
|
"credential.credential",
|
|
@@ -3273,8 +3299,8 @@ var SpaceInvitationProtocol = class {
|
|
|
3273
3299
|
}
|
|
3274
3300
|
async accept(response) {
|
|
3275
3301
|
invariant10(response.space, void 0, {
|
|
3276
|
-
F:
|
|
3277
|
-
L:
|
|
3302
|
+
F: __dxlog_file14,
|
|
3303
|
+
L: 175,
|
|
3278
3304
|
S: this,
|
|
3279
3305
|
A: [
|
|
3280
3306
|
"response.space",
|
|
@@ -3284,8 +3310,8 @@ var SpaceInvitationProtocol = class {
|
|
|
3284
3310
|
const { credential, controlTimeframe, dataTimeframe } = response.space;
|
|
3285
3311
|
const assertion = getCredentialAssertion2(credential);
|
|
3286
3312
|
invariant10(assertion["@type"] === "dxos.halo.credentials.SpaceMember", "Invalid credential", {
|
|
3287
|
-
F:
|
|
3288
|
-
L:
|
|
3313
|
+
F: __dxlog_file14,
|
|
3314
|
+
L: 178,
|
|
3289
3315
|
S: this,
|
|
3290
3316
|
A: [
|
|
3291
3317
|
"assertion['@type'] === 'dxos.halo.credentials.SpaceMember'",
|
|
@@ -3293,8 +3319,8 @@ var SpaceInvitationProtocol = class {
|
|
|
3293
3319
|
]
|
|
3294
3320
|
});
|
|
3295
3321
|
invariant10(credential.subject.id.equals(this._signingContext.identityKey), void 0, {
|
|
3296
|
-
F:
|
|
3297
|
-
L:
|
|
3322
|
+
F: __dxlog_file14,
|
|
3323
|
+
L: 179,
|
|
3298
3324
|
S: this,
|
|
3299
3325
|
A: [
|
|
3300
3326
|
"credential.subject.id.equals(this._signingContext.identityKey)",
|
|
@@ -3318,17 +3344,17 @@ var SpaceInvitationProtocol = class {
|
|
|
3318
3344
|
};
|
|
3319
3345
|
|
|
3320
3346
|
// packages/sdk/client-services/src/packlets/invitations/invitations-manager.ts
|
|
3321
|
-
import { Event as Event3, PushStream, TimeoutError as TimeoutError2, Trigger as
|
|
3347
|
+
import { Event as Event3, PushStream, TimeoutError as TimeoutError2, Trigger as Trigger6 } from "@dxos/async";
|
|
3322
3348
|
import { AuthenticatingInvitation, AUTHENTICATION_CODE_LENGTH, CancellableInvitation, INVITATION_TIMEOUT as INVITATION_TIMEOUT2 } from "@dxos/client-protocol";
|
|
3323
3349
|
import { Context as Context6 } from "@dxos/context";
|
|
3324
3350
|
import { generatePasscode } from "@dxos/credentials";
|
|
3325
3351
|
import { hasInvitationExpired } from "@dxos/echo-pipeline";
|
|
3326
3352
|
import { invariant as invariant11 } from "@dxos/invariant";
|
|
3327
3353
|
import { PublicKey as PublicKey8 } from "@dxos/keys";
|
|
3328
|
-
import { log as
|
|
3354
|
+
import { log as log12 } from "@dxos/log";
|
|
3329
3355
|
import { Invitation as Invitation6 } from "@dxos/protocols/proto/dxos/client/services";
|
|
3330
3356
|
import { SpaceMember as SpaceMember3 } from "@dxos/protocols/proto/dxos/halo/credentials";
|
|
3331
|
-
var
|
|
3357
|
+
var __dxlog_file15 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitations-manager.ts";
|
|
3332
3358
|
var InvitationsManager = class {
|
|
3333
3359
|
constructor(_invitationsHandler, _getHandler, _metadataStore) {
|
|
3334
3360
|
this._invitationsHandler = _invitationsHandler;
|
|
@@ -3370,8 +3396,8 @@ var InvitationsManager = class {
|
|
|
3370
3396
|
try {
|
|
3371
3397
|
await this._persistIfRequired(handler, stream, invitation);
|
|
3372
3398
|
} catch (err) {
|
|
3373
|
-
|
|
3374
|
-
F:
|
|
3399
|
+
log12.catch(err, void 0, {
|
|
3400
|
+
F: __dxlog_file15,
|
|
3375
3401
|
L: 82,
|
|
3376
3402
|
S: this,
|
|
3377
3403
|
C: (f, a) => f(...a)
|
|
@@ -3394,7 +3420,7 @@ var InvitationsManager = class {
|
|
|
3394
3420
|
const freshInvitations = persistentInvitations.filter((invitation) => !hasInvitationExpired(invitation));
|
|
3395
3421
|
const loadTasks = freshInvitations.map((persistentInvitation) => {
|
|
3396
3422
|
invariant11(!this._createInvitations.get(persistentInvitation.invitationId), "invitation already exists", {
|
|
3397
|
-
F:
|
|
3423
|
+
F: __dxlog_file15,
|
|
3398
3424
|
L: 103,
|
|
3399
3425
|
S: this,
|
|
3400
3426
|
A: [
|
|
@@ -3412,8 +3438,8 @@ var InvitationsManager = class {
|
|
|
3412
3438
|
invitations: cInvitations.map((invitation) => invitation.get())
|
|
3413
3439
|
};
|
|
3414
3440
|
} catch (err) {
|
|
3415
|
-
|
|
3416
|
-
F:
|
|
3441
|
+
log12.catch(err, void 0, {
|
|
3442
|
+
F: __dxlog_file15,
|
|
3417
3443
|
L: 110,
|
|
3418
3444
|
S: this,
|
|
3419
3445
|
C: (f, a) => f(...a)
|
|
@@ -3444,14 +3470,14 @@ var InvitationsManager = class {
|
|
|
3444
3470
|
return invitation;
|
|
3445
3471
|
}
|
|
3446
3472
|
async authenticate({ invitationId, authCode }) {
|
|
3447
|
-
|
|
3448
|
-
F:
|
|
3473
|
+
log12("authenticating...", void 0, {
|
|
3474
|
+
F: __dxlog_file15,
|
|
3449
3475
|
L: 140,
|
|
3450
3476
|
S: this,
|
|
3451
3477
|
C: (f, a) => f(...a)
|
|
3452
3478
|
});
|
|
3453
3479
|
invariant11(invitationId, void 0, {
|
|
3454
|
-
F:
|
|
3480
|
+
F: __dxlog_file15,
|
|
3455
3481
|
L: 141,
|
|
3456
3482
|
S: this,
|
|
3457
3483
|
A: [
|
|
@@ -3461,10 +3487,10 @@ var InvitationsManager = class {
|
|
|
3461
3487
|
});
|
|
3462
3488
|
const observable = this._acceptInvitations.get(invitationId);
|
|
3463
3489
|
if (!observable) {
|
|
3464
|
-
|
|
3490
|
+
log12.warn("invalid invitation", {
|
|
3465
3491
|
invitationId
|
|
3466
3492
|
}, {
|
|
3467
|
-
F:
|
|
3493
|
+
F: __dxlog_file15,
|
|
3468
3494
|
L: 144,
|
|
3469
3495
|
S: this,
|
|
3470
3496
|
C: (f, a) => f(...a)
|
|
@@ -3474,16 +3500,16 @@ var InvitationsManager = class {
|
|
|
3474
3500
|
}
|
|
3475
3501
|
}
|
|
3476
3502
|
async cancelInvitation({ invitationId }) {
|
|
3477
|
-
|
|
3503
|
+
log12("cancelInvitation...", {
|
|
3478
3504
|
invitationId
|
|
3479
3505
|
}, {
|
|
3480
|
-
F:
|
|
3506
|
+
F: __dxlog_file15,
|
|
3481
3507
|
L: 151,
|
|
3482
3508
|
S: this,
|
|
3483
3509
|
C: (f, a) => f(...a)
|
|
3484
3510
|
});
|
|
3485
3511
|
invariant11(invitationId, void 0, {
|
|
3486
|
-
F:
|
|
3512
|
+
F: __dxlog_file15,
|
|
3487
3513
|
L: 152,
|
|
3488
3514
|
S: this,
|
|
3489
3515
|
A: [
|
|
@@ -3557,12 +3583,15 @@ var InvitationsManager = class {
|
|
|
3557
3583
|
stream.error(err);
|
|
3558
3584
|
void ctx.dispose();
|
|
3559
3585
|
}
|
|
3586
|
+
}, {
|
|
3587
|
+
F: __dxlog_file15,
|
|
3588
|
+
L: 234
|
|
3560
3589
|
});
|
|
3561
3590
|
ctx.onDispose(() => {
|
|
3562
|
-
|
|
3591
|
+
log12("complete", {
|
|
3563
3592
|
...handler.toJSON()
|
|
3564
3593
|
}, {
|
|
3565
|
-
F:
|
|
3594
|
+
F: __dxlog_file15,
|
|
3566
3595
|
L: 241,
|
|
3567
3596
|
S: this,
|
|
3568
3597
|
C: (f, a) => f(...a)
|
|
@@ -3587,15 +3616,15 @@ var InvitationsManager = class {
|
|
|
3587
3616
|
};
|
|
3588
3617
|
}
|
|
3589
3618
|
_createObservableAcceptingInvitation(handler, initialState) {
|
|
3590
|
-
const otpEnteredTrigger = new
|
|
3619
|
+
const otpEnteredTrigger = new Trigger6();
|
|
3591
3620
|
const stream = new PushStream();
|
|
3592
3621
|
const ctx = new Context6({
|
|
3593
3622
|
onError: (err) => {
|
|
3594
3623
|
if (err instanceof TimeoutError2) {
|
|
3595
|
-
|
|
3624
|
+
log12("timeout", {
|
|
3596
3625
|
...handler.toJSON()
|
|
3597
3626
|
}, {
|
|
3598
|
-
F:
|
|
3627
|
+
F: __dxlog_file15,
|
|
3599
3628
|
L: 261,
|
|
3600
3629
|
S: this,
|
|
3601
3630
|
C: (f, a) => f(...a)
|
|
@@ -3605,8 +3634,8 @@ var InvitationsManager = class {
|
|
|
3605
3634
|
state: Invitation6.State.TIMEOUT
|
|
3606
3635
|
});
|
|
3607
3636
|
} else {
|
|
3608
|
-
|
|
3609
|
-
F:
|
|
3637
|
+
log12.warn("auth failed", err, {
|
|
3638
|
+
F: __dxlog_file15,
|
|
3610
3639
|
L: 264,
|
|
3611
3640
|
S: this,
|
|
3612
3641
|
C: (f, a) => f(...a)
|
|
@@ -3618,12 +3647,15 @@ var InvitationsManager = class {
|
|
|
3618
3647
|
}
|
|
3619
3648
|
void ctx.dispose();
|
|
3620
3649
|
}
|
|
3650
|
+
}, {
|
|
3651
|
+
F: __dxlog_file15,
|
|
3652
|
+
L: 258
|
|
3621
3653
|
});
|
|
3622
3654
|
ctx.onDispose(() => {
|
|
3623
|
-
|
|
3655
|
+
log12("complete", {
|
|
3624
3656
|
...handler.toJSON()
|
|
3625
3657
|
}, {
|
|
3626
|
-
F:
|
|
3658
|
+
F: __dxlog_file15,
|
|
3627
3659
|
L: 271,
|
|
3628
3660
|
S: this,
|
|
3629
3661
|
C: (f, a) => f(...a)
|
|
@@ -3667,8 +3699,8 @@ var InvitationsManager = class {
|
|
|
3667
3699
|
try {
|
|
3668
3700
|
await this._metadataStore.removeInvitation(invitation.invitationId);
|
|
3669
3701
|
} catch (err) {
|
|
3670
|
-
|
|
3671
|
-
F:
|
|
3702
|
+
log12.catch(err, void 0, {
|
|
3703
|
+
F: __dxlog_file15,
|
|
3672
3704
|
L: 307,
|
|
3673
3705
|
S: this,
|
|
3674
3706
|
C: (f, a) => f(...a)
|
|
@@ -3683,33 +3715,40 @@ var InvitationsManager = class {
|
|
|
3683
3715
|
};
|
|
3684
3716
|
|
|
3685
3717
|
// packages/sdk/client-services/src/packlets/spaces/data-space.ts
|
|
3686
|
-
import { Event as Event6,
|
|
3718
|
+
import { Event as Event6, Mutex as Mutex2, scheduleTask as scheduleTask5, sleep as sleep3, synchronized, trackLeaks } from "@dxos/async";
|
|
3687
3719
|
import { AUTH_TIMEOUT as AUTH_TIMEOUT2 } from "@dxos/client-protocol";
|
|
3688
|
-
import { Context as Context8, ContextDisposedError as ContextDisposedError3, cancelWithContext as
|
|
3720
|
+
import { Context as Context8, ContextDisposedError as ContextDisposedError3, cancelWithContext as cancelWithContext5 } from "@dxos/context";
|
|
3689
3721
|
import { timed, warnAfterTimeout } from "@dxos/debug";
|
|
3690
|
-
import {
|
|
3691
|
-
import {
|
|
3692
|
-
import { failedInvariant
|
|
3722
|
+
import { createMappedFeedWriter } from "@dxos/echo-pipeline";
|
|
3723
|
+
import { SpaceDocVersion } from "@dxos/echo-protocol";
|
|
3724
|
+
import { failedInvariant } from "@dxos/invariant";
|
|
3693
3725
|
import { PublicKey as PublicKey10 } from "@dxos/keys";
|
|
3694
|
-
import { log as
|
|
3726
|
+
import { log as log15 } from "@dxos/log";
|
|
3695
3727
|
import { CancelledError, SystemError } from "@dxos/protocols";
|
|
3696
|
-
import {
|
|
3728
|
+
import { SpaceState as SpaceState2 } from "@dxos/protocols/proto/dxos/client/services";
|
|
3697
3729
|
import { AdmittedFeed as AdmittedFeed3, SpaceMember as SpaceMember4 } from "@dxos/protocols/proto/dxos/halo/credentials";
|
|
3698
3730
|
import { Timeframe as Timeframe3 } from "@dxos/timeframe";
|
|
3699
3731
|
import { trace as trace6 } from "@dxos/tracing";
|
|
3700
|
-
import { ComplexSet as ComplexSet5
|
|
3732
|
+
import { ComplexSet as ComplexSet5 } from "@dxos/util";
|
|
3701
3733
|
|
|
3702
3734
|
// packages/sdk/client-services/src/packlets/spaces/automerge-space-state.ts
|
|
3703
3735
|
import { Event as Event4 } from "@dxos/async";
|
|
3736
|
+
import { Resource as Resource2 } from "@dxos/context";
|
|
3704
3737
|
import { checkCredentialType } from "@dxos/credentials";
|
|
3705
|
-
var AutomergeSpaceState = class {
|
|
3738
|
+
var AutomergeSpaceState = class extends Resource2 {
|
|
3706
3739
|
constructor(_onNewRoot) {
|
|
3740
|
+
super();
|
|
3707
3741
|
this._onNewRoot = _onNewRoot;
|
|
3708
3742
|
this.rootUrl = void 0;
|
|
3709
3743
|
this.lastEpoch = void 0;
|
|
3710
3744
|
this.onNewEpoch = new Event4();
|
|
3711
3745
|
this._isProcessingRootDocs = false;
|
|
3712
3746
|
}
|
|
3747
|
+
async _open(ctx) {
|
|
3748
|
+
}
|
|
3749
|
+
async _close(ctx) {
|
|
3750
|
+
this._isProcessingRootDocs = false;
|
|
3751
|
+
}
|
|
3713
3752
|
async processCredential(credential) {
|
|
3714
3753
|
if (!checkCredentialType(credential, "dxos.halo.credentials.Epoch")) {
|
|
3715
3754
|
return;
|
|
@@ -3737,23 +3776,186 @@ var AutomergeSpaceState = class {
|
|
|
3737
3776
|
}
|
|
3738
3777
|
};
|
|
3739
3778
|
|
|
3779
|
+
// packages/sdk/client-services/src/packlets/spaces/epoch-migrations.ts
|
|
3780
|
+
import { asyncTimeout as asyncTimeout2 } from "@dxos/async";
|
|
3781
|
+
import { next as am } from "@dxos/automerge/automerge";
|
|
3782
|
+
import { cancelWithContext as cancelWithContext4 } from "@dxos/context";
|
|
3783
|
+
import { convertLegacyReferences, convertLegacySpaceRootDoc, findInlineObjectOfType, migrateDocument } from "@dxos/echo-db";
|
|
3784
|
+
import { AutomergeDocumentLoaderImpl } from "@dxos/echo-pipeline";
|
|
3785
|
+
import { TYPE_PROPERTIES } from "@dxos/echo-schema";
|
|
3786
|
+
import { invariant as invariant12 } from "@dxos/invariant";
|
|
3787
|
+
import { log as log13 } from "@dxos/log";
|
|
3788
|
+
import { CreateEpochRequest } from "@dxos/protocols/proto/dxos/client/services";
|
|
3789
|
+
import { assignDeep } from "@dxos/util";
|
|
3790
|
+
var __dxlog_file16 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/epoch-migrations.ts";
|
|
3791
|
+
var runEpochMigration = async (ctx, context) => {
|
|
3792
|
+
switch (context.migration) {
|
|
3793
|
+
case CreateEpochRequest.Migration.INIT_AUTOMERGE: {
|
|
3794
|
+
const document = context.repo.create();
|
|
3795
|
+
await context.repo.flush();
|
|
3796
|
+
return {
|
|
3797
|
+
newRoot: document.url
|
|
3798
|
+
};
|
|
3799
|
+
}
|
|
3800
|
+
case CreateEpochRequest.Migration.PRUNE_AUTOMERGE_ROOT_HISTORY: {
|
|
3801
|
+
if (!context.currentRoot) {
|
|
3802
|
+
throw new Error("Space does not have an automerge root");
|
|
3803
|
+
}
|
|
3804
|
+
const rootHandle = context.repo.find(context.currentRoot);
|
|
3805
|
+
await cancelWithContext4(ctx, asyncTimeout2(rootHandle.whenReady(), 1e4));
|
|
3806
|
+
const newRoot = context.repo.create(rootHandle.docSync());
|
|
3807
|
+
await context.repo.flush();
|
|
3808
|
+
return {
|
|
3809
|
+
newRoot: newRoot.url
|
|
3810
|
+
};
|
|
3811
|
+
}
|
|
3812
|
+
case CreateEpochRequest.Migration.FRAGMENT_AUTOMERGE_ROOT: {
|
|
3813
|
+
log13.info("Fragmenting", void 0, {
|
|
3814
|
+
F: __dxlog_file16,
|
|
3815
|
+
L: 63,
|
|
3816
|
+
S: void 0,
|
|
3817
|
+
C: (f, a) => f(...a)
|
|
3818
|
+
});
|
|
3819
|
+
const currentRootUrl = context.currentRoot;
|
|
3820
|
+
const rootHandle = context.repo.find(currentRootUrl);
|
|
3821
|
+
await cancelWithContext4(ctx, asyncTimeout2(rootHandle.whenReady(), 1e4));
|
|
3822
|
+
const objects = Object.entries(rootHandle.docSync().objects);
|
|
3823
|
+
const properties = findInlineObjectOfType(rootHandle.docSync(), TYPE_PROPERTIES);
|
|
3824
|
+
const otherObjects = objects.filter(([key]) => key !== properties?.[0]);
|
|
3825
|
+
invariant12(properties, "Properties not found", {
|
|
3826
|
+
F: __dxlog_file16,
|
|
3827
|
+
L: 73,
|
|
3828
|
+
S: void 0,
|
|
3829
|
+
A: [
|
|
3830
|
+
"properties",
|
|
3831
|
+
"'Properties not found'"
|
|
3832
|
+
]
|
|
3833
|
+
});
|
|
3834
|
+
const newSpaceDoc = {
|
|
3835
|
+
...rootHandle.docSync(),
|
|
3836
|
+
objects: Object.fromEntries([
|
|
3837
|
+
properties
|
|
3838
|
+
])
|
|
3839
|
+
};
|
|
3840
|
+
const newRoot = context.repo.create(newSpaceDoc);
|
|
3841
|
+
invariant12(typeof newRoot.url === "string" && newRoot.url.length > 0, void 0, {
|
|
3842
|
+
F: __dxlog_file16,
|
|
3843
|
+
L: 78,
|
|
3844
|
+
S: void 0,
|
|
3845
|
+
A: [
|
|
3846
|
+
"typeof newRoot.url === 'string' && newRoot.url.length > 0",
|
|
3847
|
+
""
|
|
3848
|
+
]
|
|
3849
|
+
});
|
|
3850
|
+
const docLoader = new AutomergeDocumentLoaderImpl(context.spaceId, context.repo, context.spaceKey);
|
|
3851
|
+
await docLoader.loadSpaceRootDocHandle(ctx, {
|
|
3852
|
+
rootUrl: newRoot.url
|
|
3853
|
+
});
|
|
3854
|
+
otherObjects.forEach(([key, value]) => {
|
|
3855
|
+
const handle = docLoader.createDocumentForObject(key);
|
|
3856
|
+
handle.change((doc) => {
|
|
3857
|
+
assignDeep(doc, [
|
|
3858
|
+
"objects",
|
|
3859
|
+
key
|
|
3860
|
+
], value);
|
|
3861
|
+
});
|
|
3862
|
+
});
|
|
3863
|
+
await context.repo.flush();
|
|
3864
|
+
return {
|
|
3865
|
+
newRoot: newRoot.url
|
|
3866
|
+
};
|
|
3867
|
+
}
|
|
3868
|
+
case CreateEpochRequest.Migration.MIGRATE_REFERENCES_TO_DXN: {
|
|
3869
|
+
const currentRootUrl = context.currentRoot;
|
|
3870
|
+
const rootHandle = context.repo.find(currentRootUrl);
|
|
3871
|
+
await cancelWithContext4(ctx, asyncTimeout2(rootHandle.whenReady(), 1e4));
|
|
3872
|
+
invariant12(rootHandle.docSync(), "Root doc not found", {
|
|
3873
|
+
F: __dxlog_file16,
|
|
3874
|
+
L: 100,
|
|
3875
|
+
S: void 0,
|
|
3876
|
+
A: [
|
|
3877
|
+
"rootHandle.docSync()",
|
|
3878
|
+
"'Root doc not found'"
|
|
3879
|
+
]
|
|
3880
|
+
});
|
|
3881
|
+
const newRootContent = await convertLegacySpaceRootDoc(structuredClone(rootHandle.docSync()));
|
|
3882
|
+
for (const [id, url] of Object.entries(newRootContent.links ?? {})) {
|
|
3883
|
+
try {
|
|
3884
|
+
const handle = context.repo.find(url);
|
|
3885
|
+
await cancelWithContext4(ctx, asyncTimeout2(handle.whenReady(), 1e4));
|
|
3886
|
+
invariant12(handle.docSync(), "Doc not found", {
|
|
3887
|
+
F: __dxlog_file16,
|
|
3888
|
+
L: 108,
|
|
3889
|
+
S: void 0,
|
|
3890
|
+
A: [
|
|
3891
|
+
"handle.docSync()",
|
|
3892
|
+
"'Doc not found'"
|
|
3893
|
+
]
|
|
3894
|
+
});
|
|
3895
|
+
const newDoc = await convertLegacyReferences(structuredClone(handle.docSync()));
|
|
3896
|
+
const migratedDoc = migrateDocument(handle.docSync(), newDoc);
|
|
3897
|
+
const newHandle = context.repo.import(am.save(migratedDoc));
|
|
3898
|
+
newRootContent.links[id] = newHandle.url;
|
|
3899
|
+
} catch (err) {
|
|
3900
|
+
log13.warn("Failed to migrate reference", {
|
|
3901
|
+
id,
|
|
3902
|
+
url,
|
|
3903
|
+
error: err
|
|
3904
|
+
}, {
|
|
3905
|
+
F: __dxlog_file16,
|
|
3906
|
+
L: 114,
|
|
3907
|
+
S: void 0,
|
|
3908
|
+
C: (f, a) => f(...a)
|
|
3909
|
+
});
|
|
3910
|
+
delete newRootContent.links[id];
|
|
3911
|
+
}
|
|
3912
|
+
}
|
|
3913
|
+
const migratedRoot = migrateDocument(rootHandle.docSync(), newRootContent);
|
|
3914
|
+
const newRoot = context.repo.import(am.save(migratedRoot));
|
|
3915
|
+
await context.repo.flush();
|
|
3916
|
+
return {
|
|
3917
|
+
newRoot: newRoot.url
|
|
3918
|
+
};
|
|
3919
|
+
}
|
|
3920
|
+
case CreateEpochRequest.Migration.REPLACE_AUTOMERGE_ROOT: {
|
|
3921
|
+
invariant12(context.newAutomergeRoot, void 0, {
|
|
3922
|
+
F: __dxlog_file16,
|
|
3923
|
+
L: 129,
|
|
3924
|
+
S: void 0,
|
|
3925
|
+
A: [
|
|
3926
|
+
"context.newAutomergeRoot",
|
|
3927
|
+
""
|
|
3928
|
+
]
|
|
3929
|
+
});
|
|
3930
|
+
await context.repo.flush();
|
|
3931
|
+
return {
|
|
3932
|
+
newRoot: context.newAutomergeRoot
|
|
3933
|
+
};
|
|
3934
|
+
}
|
|
3935
|
+
}
|
|
3936
|
+
return {};
|
|
3937
|
+
};
|
|
3938
|
+
|
|
3740
3939
|
// 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
|
|
3940
|
+
import { DeferredTask, Event as Event5, scheduleTask as scheduleTask4, sleep as sleep2, TimeoutError as TimeoutError3, Trigger as Trigger7 } from "@dxos/async";
|
|
3742
3941
|
import { Context as Context7, rejectOnDispose } from "@dxos/context";
|
|
3743
|
-
import { invariant as
|
|
3942
|
+
import { invariant as invariant13 } from "@dxos/invariant";
|
|
3744
3943
|
import { PublicKey as PublicKey9 } from "@dxos/keys";
|
|
3745
|
-
import { log as
|
|
3944
|
+
import { log as log14 } from "@dxos/log";
|
|
3746
3945
|
import { schema as schema4 } from "@dxos/protocols";
|
|
3747
3946
|
import { RpcExtension as RpcExtension3 } from "@dxos/teleport";
|
|
3748
3947
|
import { ComplexMap as ComplexMap2, ComplexSet as ComplexSet4, entry } from "@dxos/util";
|
|
3749
|
-
var
|
|
3948
|
+
var __dxlog_file17 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/notarization-plugin.ts";
|
|
3750
3949
|
var DEFAULT_RETRY_TIMEOUT = 1e3;
|
|
3751
3950
|
var DEFAULT_SUCCESS_DELAY = 1e3;
|
|
3752
3951
|
var DEFAULT_NOTARIZE_TIMEOUT = 1e4;
|
|
3753
3952
|
var WRITER_NOT_SET_ERROR_CODE = "WRITER_NOT_SET";
|
|
3754
3953
|
var NotarizationPlugin = class {
|
|
3755
3954
|
constructor() {
|
|
3756
|
-
this._ctx = new Context7(
|
|
3955
|
+
this._ctx = new Context7(void 0, {
|
|
3956
|
+
F: __dxlog_file17,
|
|
3957
|
+
L: 62
|
|
3958
|
+
});
|
|
3757
3959
|
this._extensionOpened = new Event5();
|
|
3758
3960
|
this._extensions = /* @__PURE__ */ new Set();
|
|
3759
3961
|
this._processedCredentials = new ComplexSet4(PublicKey9.hash);
|
|
@@ -3771,16 +3973,16 @@ var NotarizationPlugin = class {
|
|
|
3771
3973
|
* Request credentials to be notarized.
|
|
3772
3974
|
*/
|
|
3773
3975
|
async notarize({ ctx: opCtx, credentials, timeout = DEFAULT_NOTARIZE_TIMEOUT, retryTimeout = DEFAULT_RETRY_TIMEOUT, successDelay = DEFAULT_SUCCESS_DELAY }) {
|
|
3774
|
-
|
|
3976
|
+
log14("notarize", {
|
|
3775
3977
|
credentials
|
|
3776
3978
|
}, {
|
|
3777
|
-
F:
|
|
3979
|
+
F: __dxlog_file17,
|
|
3778
3980
|
L: 90,
|
|
3779
3981
|
S: this,
|
|
3780
3982
|
C: (f, a) => f(...a)
|
|
3781
3983
|
});
|
|
3782
|
-
|
|
3783
|
-
F:
|
|
3984
|
+
invariant13(credentials.every((credential) => credential.id), "Credentials must have an id", {
|
|
3985
|
+
F: __dxlog_file17,
|
|
3784
3986
|
L: 91,
|
|
3785
3987
|
S: this,
|
|
3786
3988
|
A: [
|
|
@@ -3788,13 +3990,13 @@ var NotarizationPlugin = class {
|
|
|
3788
3990
|
"'Credentials must have an id'"
|
|
3789
3991
|
]
|
|
3790
3992
|
});
|
|
3791
|
-
const errors = new
|
|
3993
|
+
const errors = new Trigger7();
|
|
3792
3994
|
const ctx = this._ctx.derive({
|
|
3793
3995
|
onError: (err) => {
|
|
3794
|
-
|
|
3996
|
+
log14.warn("Notarization error", {
|
|
3795
3997
|
err
|
|
3796
3998
|
}, {
|
|
3797
|
-
F:
|
|
3999
|
+
F: __dxlog_file17,
|
|
3798
4000
|
L: 99,
|
|
3799
4001
|
S: this,
|
|
3800
4002
|
C: (f, a) => f(...a)
|
|
@@ -3806,11 +4008,11 @@ var NotarizationPlugin = class {
|
|
|
3806
4008
|
opCtx?.onDispose(() => ctx.dispose());
|
|
3807
4009
|
if (timeout !== 0) {
|
|
3808
4010
|
scheduleTask4(ctx, () => {
|
|
3809
|
-
|
|
4011
|
+
log14.warn("Notarization timeout", {
|
|
3810
4012
|
timeout,
|
|
3811
4013
|
peers: Array.from(this._extensions).map((extension) => extension.remotePeerId)
|
|
3812
4014
|
}, {
|
|
3813
|
-
F:
|
|
4015
|
+
F: __dxlog_file17,
|
|
3814
4016
|
L: 111,
|
|
3815
4017
|
S: this,
|
|
3816
4018
|
C: (f, a) => f(...a)
|
|
@@ -3830,10 +4032,10 @@ var NotarizationPlugin = class {
|
|
|
3830
4032
|
...this._extensions
|
|
3831
4033
|
].find((peer2) => !peersTried.has(peer2));
|
|
3832
4034
|
if (!peer) {
|
|
3833
|
-
|
|
4035
|
+
log14.info("Exhausted all peers to notarize with", {
|
|
3834
4036
|
retryIn: retryTimeout
|
|
3835
4037
|
}, {
|
|
3836
|
-
F:
|
|
4038
|
+
F: __dxlog_file17,
|
|
3837
4039
|
L: 136,
|
|
3838
4040
|
S: this,
|
|
3839
4041
|
C: (f, a) => f(...a)
|
|
@@ -3843,11 +4045,11 @@ var NotarizationPlugin = class {
|
|
|
3843
4045
|
return;
|
|
3844
4046
|
}
|
|
3845
4047
|
peersTried.add(peer);
|
|
3846
|
-
|
|
4048
|
+
log14("try notarizing", {
|
|
3847
4049
|
peer: peer.localPeerId,
|
|
3848
4050
|
credentialId: credentials.map((credential) => credential.id)
|
|
3849
4051
|
}, {
|
|
3850
|
-
F:
|
|
4052
|
+
F: __dxlog_file17,
|
|
3851
4053
|
L: 143,
|
|
3852
4054
|
S: this,
|
|
3853
4055
|
C: (f, a) => f(...a)
|
|
@@ -3855,17 +4057,17 @@ var NotarizationPlugin = class {
|
|
|
3855
4057
|
await peer.rpc.NotarizationService.notarize({
|
|
3856
4058
|
credentials: credentials.filter((credential) => !this._processedCredentials.has(credential.id))
|
|
3857
4059
|
});
|
|
3858
|
-
|
|
3859
|
-
F:
|
|
4060
|
+
log14("success", void 0, {
|
|
4061
|
+
F: __dxlog_file17,
|
|
3860
4062
|
L: 147,
|
|
3861
4063
|
S: this,
|
|
3862
4064
|
C: (f, a) => f(...a)
|
|
3863
4065
|
});
|
|
3864
|
-
await
|
|
4066
|
+
await sleep2(successDelay);
|
|
3865
4067
|
} catch (err) {
|
|
3866
4068
|
if (!ctx.disposed && !err.message.includes(WRITER_NOT_SET_ERROR_CODE)) {
|
|
3867
|
-
|
|
3868
|
-
F:
|
|
4069
|
+
log14.info("error notarizing (recoverable)", err, {
|
|
4070
|
+
F: __dxlog_file17,
|
|
3869
4071
|
L: 151,
|
|
3870
4072
|
S: this,
|
|
3871
4073
|
C: (f, a) => f(...a)
|
|
@@ -3882,8 +4084,8 @@ var NotarizationPlugin = class {
|
|
|
3882
4084
|
allNotarized,
|
|
3883
4085
|
errors.wait()
|
|
3884
4086
|
]);
|
|
3885
|
-
|
|
3886
|
-
F:
|
|
4087
|
+
log14("done", void 0, {
|
|
4088
|
+
F: __dxlog_file17,
|
|
3887
4089
|
L: 162,
|
|
3888
4090
|
S: this,
|
|
3889
4091
|
C: (f, a) => f(...a)
|
|
@@ -3904,8 +4106,8 @@ var NotarizationPlugin = class {
|
|
|
3904
4106
|
this._processCredentialsTriggers.delete(credential.id);
|
|
3905
4107
|
}
|
|
3906
4108
|
setWriter(writer) {
|
|
3907
|
-
|
|
3908
|
-
F:
|
|
4109
|
+
invariant13(!this._writer, "Writer already set.", {
|
|
4110
|
+
F: __dxlog_file17,
|
|
3909
4111
|
L: 181,
|
|
3910
4112
|
S: this,
|
|
3911
4113
|
A: [
|
|
@@ -3919,7 +4121,7 @@ var NotarizationPlugin = class {
|
|
|
3919
4121
|
if (this._processedCredentials.has(id)) {
|
|
3920
4122
|
return;
|
|
3921
4123
|
}
|
|
3922
|
-
await entry(this._processCredentialsTriggers, id).orInsert(new
|
|
4124
|
+
await entry(this._processCredentialsTriggers, id).orInsert(new Trigger7()).value.wait();
|
|
3923
4125
|
}
|
|
3924
4126
|
/**
|
|
3925
4127
|
* Requests from other peers to notarize credentials.
|
|
@@ -3929,8 +4131,8 @@ var NotarizationPlugin = class {
|
|
|
3929
4131
|
throw new Error(WRITER_NOT_SET_ERROR_CODE);
|
|
3930
4132
|
}
|
|
3931
4133
|
for (const credential of request.credentials ?? []) {
|
|
3932
|
-
|
|
3933
|
-
F:
|
|
4134
|
+
invariant13(credential.id, "Credential must have an id", {
|
|
4135
|
+
F: __dxlog_file17,
|
|
3934
4136
|
L: 200,
|
|
3935
4137
|
S: this,
|
|
3936
4138
|
A: [
|
|
@@ -3947,10 +4149,10 @@ var NotarizationPlugin = class {
|
|
|
3947
4149
|
createExtension() {
|
|
3948
4150
|
const extension = new NotarizationTeleportExtension({
|
|
3949
4151
|
onOpen: async () => {
|
|
3950
|
-
|
|
4152
|
+
log14("extension opened", {
|
|
3951
4153
|
peer: extension.localPeerId
|
|
3952
4154
|
}, {
|
|
3953
|
-
F:
|
|
4155
|
+
F: __dxlog_file17,
|
|
3954
4156
|
L: 211,
|
|
3955
4157
|
S: this,
|
|
3956
4158
|
C: (f, a) => f(...a)
|
|
@@ -3959,10 +4161,10 @@ var NotarizationPlugin = class {
|
|
|
3959
4161
|
this._extensionOpened.emit();
|
|
3960
4162
|
},
|
|
3961
4163
|
onClose: async () => {
|
|
3962
|
-
|
|
4164
|
+
log14("extension closed", {
|
|
3963
4165
|
peer: extension.localPeerId
|
|
3964
4166
|
}, {
|
|
3965
|
-
F:
|
|
4167
|
+
F: __dxlog_file17,
|
|
3966
4168
|
L: 216,
|
|
3967
4169
|
S: this,
|
|
3968
4170
|
C: (f, a) => f(...a)
|
|
@@ -4016,15 +4218,83 @@ function _ts_decorate4(decorators, target, key, desc) {
|
|
|
4016
4218
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
4017
4219
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4018
4220
|
}
|
|
4019
|
-
|
|
4221
|
+
function _using_ctx() {
|
|
4222
|
+
var _disposeSuppressedError = typeof SuppressedError === "function" ? SuppressedError : function(error, suppressed) {
|
|
4223
|
+
var err = new Error();
|
|
4224
|
+
err.name = "SuppressedError";
|
|
4225
|
+
err.suppressed = suppressed;
|
|
4226
|
+
err.error = error;
|
|
4227
|
+
return err;
|
|
4228
|
+
}, empty = {}, stack = [];
|
|
4229
|
+
function using(isAwait, value) {
|
|
4230
|
+
if (value != null) {
|
|
4231
|
+
if (Object(value) !== value) {
|
|
4232
|
+
throw new TypeError("using declarations can only be used with objects, functions, null, or undefined.");
|
|
4233
|
+
}
|
|
4234
|
+
if (isAwait) {
|
|
4235
|
+
var dispose = value[Symbol.asyncDispose || Symbol.for("Symbol.asyncDispose")];
|
|
4236
|
+
}
|
|
4237
|
+
if (dispose == null) {
|
|
4238
|
+
dispose = value[Symbol.dispose || Symbol.for("Symbol.dispose")];
|
|
4239
|
+
}
|
|
4240
|
+
if (typeof dispose !== "function") {
|
|
4241
|
+
throw new TypeError(`Property [Symbol.dispose] is not a function.`);
|
|
4242
|
+
}
|
|
4243
|
+
stack.push({
|
|
4244
|
+
v: value,
|
|
4245
|
+
d: dispose,
|
|
4246
|
+
a: isAwait
|
|
4247
|
+
});
|
|
4248
|
+
} else if (isAwait) {
|
|
4249
|
+
stack.push({
|
|
4250
|
+
d: value,
|
|
4251
|
+
a: isAwait
|
|
4252
|
+
});
|
|
4253
|
+
}
|
|
4254
|
+
return value;
|
|
4255
|
+
}
|
|
4256
|
+
return {
|
|
4257
|
+
e: empty,
|
|
4258
|
+
u: using.bind(null, false),
|
|
4259
|
+
a: using.bind(null, true),
|
|
4260
|
+
d: function() {
|
|
4261
|
+
var error = this.e;
|
|
4262
|
+
function next() {
|
|
4263
|
+
while (resource = stack.pop()) {
|
|
4264
|
+
try {
|
|
4265
|
+
var resource, disposalResult = resource.d && resource.d.call(resource.v);
|
|
4266
|
+
if (resource.a) {
|
|
4267
|
+
return Promise.resolve(disposalResult).then(next, err);
|
|
4268
|
+
}
|
|
4269
|
+
} catch (e) {
|
|
4270
|
+
return err(e);
|
|
4271
|
+
}
|
|
4272
|
+
}
|
|
4273
|
+
if (error !== empty)
|
|
4274
|
+
throw error;
|
|
4275
|
+
}
|
|
4276
|
+
function err(e) {
|
|
4277
|
+
error = error !== empty ? new _disposeSuppressedError(error, e) : e;
|
|
4278
|
+
return next();
|
|
4279
|
+
}
|
|
4280
|
+
return next();
|
|
4281
|
+
}
|
|
4282
|
+
};
|
|
4283
|
+
}
|
|
4284
|
+
var __dxlog_file18 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space.ts";
|
|
4020
4285
|
var DataSpace = class {
|
|
4021
4286
|
constructor(params) {
|
|
4022
|
-
this._ctx = new Context8(
|
|
4287
|
+
this._ctx = new Context8(void 0, {
|
|
4288
|
+
F: __dxlog_file18,
|
|
4289
|
+
L: 84
|
|
4290
|
+
});
|
|
4023
4291
|
this._notarizationPlugin = new NotarizationPlugin();
|
|
4024
4292
|
this._cache = void 0;
|
|
4025
4293
|
// TODO(dmaretskyi): Move into Space?
|
|
4026
4294
|
this._automergeSpaceState = new AutomergeSpaceState((rootUrl) => this._onNewAutomergeRoot(rootUrl));
|
|
4295
|
+
this._epochProcessingMutex = new Mutex2();
|
|
4027
4296
|
this._state = SpaceState2.CLOSED;
|
|
4297
|
+
this._databaseRoot = null;
|
|
4028
4298
|
/**
|
|
4029
4299
|
* Error for _state === SpaceState.ERROR.
|
|
4030
4300
|
*/
|
|
@@ -4048,11 +4318,11 @@ var DataSpace = class {
|
|
|
4048
4318
|
});
|
|
4049
4319
|
this._cache = params.cache;
|
|
4050
4320
|
this._state = params.initialState;
|
|
4051
|
-
|
|
4321
|
+
log15("new state", {
|
|
4052
4322
|
state: SpaceState2[this._state]
|
|
4053
4323
|
}, {
|
|
4054
|
-
F:
|
|
4055
|
-
L:
|
|
4324
|
+
F: __dxlog_file18,
|
|
4325
|
+
L: 146,
|
|
4056
4326
|
S: this,
|
|
4057
4327
|
C: (f, a) => f(...a)
|
|
4058
4328
|
});
|
|
@@ -4085,6 +4355,9 @@ var DataSpace = class {
|
|
|
4085
4355
|
get automergeSpaceState() {
|
|
4086
4356
|
return this._automergeSpaceState;
|
|
4087
4357
|
}
|
|
4358
|
+
get databaseRoot() {
|
|
4359
|
+
return this._databaseRoot;
|
|
4360
|
+
}
|
|
4088
4361
|
get _automergeInfo() {
|
|
4089
4362
|
return {
|
|
4090
4363
|
rootUrl: this._automergeSpaceState.rootUrl,
|
|
@@ -4101,14 +4374,18 @@ var DataSpace = class {
|
|
|
4101
4374
|
await this._gossip.open();
|
|
4102
4375
|
await this._notarizationPlugin.open();
|
|
4103
4376
|
await this._inner.spaceState.addCredentialProcessor(this._notarizationPlugin);
|
|
4377
|
+
await this._automergeSpaceState.open();
|
|
4104
4378
|
await this._inner.spaceState.addCredentialProcessor(this._automergeSpaceState);
|
|
4105
|
-
await this._inner.open(new Context8(
|
|
4379
|
+
await this._inner.open(new Context8(void 0, {
|
|
4380
|
+
F: __dxlog_file18,
|
|
4381
|
+
L: 215
|
|
4382
|
+
}));
|
|
4106
4383
|
this._state = SpaceState2.CONTROL_ONLY;
|
|
4107
|
-
|
|
4384
|
+
log15("new state", {
|
|
4108
4385
|
state: SpaceState2[this._state]
|
|
4109
4386
|
}, {
|
|
4110
|
-
F:
|
|
4111
|
-
L:
|
|
4387
|
+
F: __dxlog_file18,
|
|
4388
|
+
L: 217,
|
|
4112
4389
|
S: this,
|
|
4113
4390
|
C: (f, a) => f(...a)
|
|
4114
4391
|
});
|
|
@@ -4122,19 +4399,23 @@ var DataSpace = class {
|
|
|
4122
4399
|
async _close() {
|
|
4123
4400
|
await this._callbacks.beforeClose?.();
|
|
4124
4401
|
this._state = SpaceState2.CLOSED;
|
|
4125
|
-
|
|
4402
|
+
log15("new state", {
|
|
4126
4403
|
state: SpaceState2[this._state]
|
|
4127
4404
|
}, {
|
|
4128
|
-
F:
|
|
4129
|
-
L:
|
|
4405
|
+
F: __dxlog_file18,
|
|
4406
|
+
L: 231,
|
|
4130
4407
|
S: this,
|
|
4131
4408
|
C: (f, a) => f(...a)
|
|
4132
4409
|
});
|
|
4133
4410
|
await this._ctx.dispose();
|
|
4134
|
-
this._ctx = new Context8(
|
|
4411
|
+
this._ctx = new Context8(void 0, {
|
|
4412
|
+
F: __dxlog_file18,
|
|
4413
|
+
L: 233
|
|
4414
|
+
});
|
|
4135
4415
|
await this.authVerifier.close();
|
|
4136
4416
|
await this._inner.close();
|
|
4137
4417
|
await this._inner.spaceState.removeCredentialProcessor(this._automergeSpaceState);
|
|
4418
|
+
await this._automergeSpaceState.close();
|
|
4138
4419
|
await this._inner.spaceState.removeCredentialProcessor(this._notarizationPlugin);
|
|
4139
4420
|
await this._notarizationPlugin.close();
|
|
4140
4421
|
await this._presence.close();
|
|
@@ -4156,26 +4437,26 @@ var DataSpace = class {
|
|
|
4156
4437
|
await this.initializeDataPipeline();
|
|
4157
4438
|
} catch (err) {
|
|
4158
4439
|
if (err instanceof CancelledError || err instanceof ContextDisposedError3) {
|
|
4159
|
-
|
|
4160
|
-
F:
|
|
4161
|
-
L:
|
|
4440
|
+
log15("data pipeline initialization cancelled", err, {
|
|
4441
|
+
F: __dxlog_file18,
|
|
4442
|
+
L: 265,
|
|
4162
4443
|
S: this,
|
|
4163
4444
|
C: (f, a) => f(...a)
|
|
4164
4445
|
});
|
|
4165
4446
|
return;
|
|
4166
4447
|
}
|
|
4167
|
-
|
|
4168
|
-
F:
|
|
4169
|
-
L:
|
|
4448
|
+
log15.error("Error initializing data pipeline", err, {
|
|
4449
|
+
F: __dxlog_file18,
|
|
4450
|
+
L: 269,
|
|
4170
4451
|
S: this,
|
|
4171
4452
|
C: (f, a) => f(...a)
|
|
4172
4453
|
});
|
|
4173
4454
|
this._state = SpaceState2.ERROR;
|
|
4174
|
-
|
|
4455
|
+
log15("new state", {
|
|
4175
4456
|
state: SpaceState2[this._state]
|
|
4176
4457
|
}, {
|
|
4177
|
-
F:
|
|
4178
|
-
L:
|
|
4458
|
+
F: __dxlog_file18,
|
|
4459
|
+
L: 271,
|
|
4179
4460
|
S: this,
|
|
4180
4461
|
C: (f, a) => f(...a)
|
|
4181
4462
|
});
|
|
@@ -4191,31 +4472,28 @@ var DataSpace = class {
|
|
|
4191
4472
|
throw new SystemError("Invalid operation");
|
|
4192
4473
|
}
|
|
4193
4474
|
this._state = SpaceState2.INITIALIZING;
|
|
4194
|
-
|
|
4475
|
+
log15("new state", {
|
|
4195
4476
|
state: SpaceState2[this._state]
|
|
4196
4477
|
}, {
|
|
4197
|
-
F:
|
|
4198
|
-
L:
|
|
4478
|
+
F: __dxlog_file18,
|
|
4479
|
+
L: 287,
|
|
4199
4480
|
S: this,
|
|
4200
4481
|
C: (f, a) => f(...a)
|
|
4201
4482
|
});
|
|
4202
4483
|
await this._initializeAndReadControlPipeline();
|
|
4203
|
-
await
|
|
4484
|
+
await sleep3(1);
|
|
4485
|
+
const ready = this.stateUpdate.waitForCondition(() => this._state === SpaceState2.READY);
|
|
4204
4486
|
this._automergeSpaceState.startProcessingRootDocs();
|
|
4205
|
-
await
|
|
4206
|
-
|
|
4207
|
-
|
|
4208
|
-
L: 290,
|
|
4209
|
-
S: this,
|
|
4210
|
-
C: (f, a) => f(...a)
|
|
4211
|
-
});
|
|
4487
|
+
await ready;
|
|
4488
|
+
}
|
|
4489
|
+
async _enterReadyState() {
|
|
4212
4490
|
await this._callbacks.beforeReady?.();
|
|
4213
4491
|
this._state = SpaceState2.READY;
|
|
4214
|
-
|
|
4492
|
+
log15("new state", {
|
|
4215
4493
|
state: SpaceState2[this._state]
|
|
4216
4494
|
}, {
|
|
4217
|
-
F:
|
|
4218
|
-
L:
|
|
4495
|
+
F: __dxlog_file18,
|
|
4496
|
+
L: 306,
|
|
4219
4497
|
S: this,
|
|
4220
4498
|
C: (f, a) => f(...a)
|
|
4221
4499
|
});
|
|
@@ -4229,9 +4507,9 @@ var DataSpace = class {
|
|
|
4229
4507
|
});
|
|
4230
4508
|
this.metrics.controlPipelineReady = /* @__PURE__ */ new Date();
|
|
4231
4509
|
await this._createWritableFeeds();
|
|
4232
|
-
|
|
4233
|
-
F:
|
|
4234
|
-
L:
|
|
4510
|
+
log15("writable feeds created", void 0, {
|
|
4511
|
+
F: __dxlog_file18,
|
|
4512
|
+
L: 322,
|
|
4235
4513
|
S: this,
|
|
4236
4514
|
C: (f, a) => f(...a)
|
|
4237
4515
|
});
|
|
@@ -4289,57 +4567,66 @@ var DataSpace = class {
|
|
|
4289
4567
|
}
|
|
4290
4568
|
}
|
|
4291
4569
|
_onNewAutomergeRoot(rootUrl) {
|
|
4292
|
-
|
|
4570
|
+
log15("loading automerge root doc for space", {
|
|
4293
4571
|
space: this.key,
|
|
4294
4572
|
rootUrl
|
|
4295
4573
|
}, {
|
|
4296
|
-
F:
|
|
4297
|
-
L:
|
|
4574
|
+
F: __dxlog_file18,
|
|
4575
|
+
L: 388,
|
|
4298
4576
|
S: this,
|
|
4299
4577
|
C: (f, a) => f(...a)
|
|
4300
4578
|
});
|
|
4301
|
-
this._echoHost.replicateDocument(rootUrl);
|
|
4302
4579
|
const handle = this._echoHost.automergeRepo.find(rootUrl);
|
|
4303
4580
|
queueMicrotask(async () => {
|
|
4304
4581
|
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)
|
|
4582
|
+
try {
|
|
4583
|
+
var _usingCtx = _using_ctx();
|
|
4584
|
+
await warnAfterTimeout(5e3, "Automerge root doc load timeout (DataSpace)", async () => {
|
|
4585
|
+
await cancelWithContext5(this._ctx, handle.whenReady());
|
|
4330
4586
|
});
|
|
4587
|
+
if (this._ctx.disposed) {
|
|
4588
|
+
return;
|
|
4589
|
+
}
|
|
4590
|
+
const _guard = (
|
|
4591
|
+
// Ensure only one root is processed at a time.
|
|
4592
|
+
_usingCtx.u(await this._epochProcessingMutex.acquire())
|
|
4593
|
+
);
|
|
4594
|
+
const doc = handle.docSync() ?? failedInvariant();
|
|
4595
|
+
if (!doc.access?.spaceKey) {
|
|
4596
|
+
handle.change((doc2) => {
|
|
4597
|
+
doc2.access = {
|
|
4598
|
+
spaceKey: this.key.toHex()
|
|
4599
|
+
};
|
|
4600
|
+
});
|
|
4601
|
+
}
|
|
4602
|
+
const root = await this._echoHost.openSpaceRoot(handle.url);
|
|
4603
|
+
this._databaseRoot = root;
|
|
4604
|
+
if (root.getVersion() !== SpaceDocVersion.CURRENT) {
|
|
4605
|
+
if (this._state !== SpaceState2.REQUIRES_MIGRATION) {
|
|
4606
|
+
this._state = SpaceState2.REQUIRES_MIGRATION;
|
|
4607
|
+
this.stateUpdate.emit();
|
|
4608
|
+
}
|
|
4609
|
+
} else {
|
|
4610
|
+
if (this._state !== SpaceState2.READY) {
|
|
4611
|
+
await this._enterReadyState();
|
|
4612
|
+
}
|
|
4613
|
+
}
|
|
4614
|
+
} catch (_) {
|
|
4615
|
+
_usingCtx.e = _;
|
|
4616
|
+
} finally {
|
|
4617
|
+
_usingCtx.d();
|
|
4331
4618
|
}
|
|
4332
4619
|
} catch (err) {
|
|
4333
4620
|
if (err instanceof ContextDisposedError3) {
|
|
4334
4621
|
return;
|
|
4335
4622
|
}
|
|
4336
|
-
|
|
4623
|
+
log15.warn("error loading automerge root doc", {
|
|
4337
4624
|
space: this.key,
|
|
4338
4625
|
rootUrl,
|
|
4339
4626
|
err
|
|
4340
4627
|
}, {
|
|
4341
|
-
F:
|
|
4342
|
-
L:
|
|
4628
|
+
F: __dxlog_file18,
|
|
4629
|
+
L: 431,
|
|
4343
4630
|
S: this,
|
|
4344
4631
|
C: (f, a) => f(...a)
|
|
4345
4632
|
});
|
|
@@ -4362,148 +4649,34 @@ var DataSpace = class {
|
|
|
4362
4649
|
});
|
|
4363
4650
|
}
|
|
4364
4651
|
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;
|
|
4652
|
+
const ctx = this._ctx.derive();
|
|
4653
|
+
if (!options?.migration) {
|
|
4654
|
+
return null;
|
|
4497
4655
|
}
|
|
4656
|
+
const { newRoot } = await runEpochMigration(ctx, {
|
|
4657
|
+
repo: this._echoHost.automergeRepo,
|
|
4658
|
+
spaceId: this.id,
|
|
4659
|
+
spaceKey: this.key,
|
|
4660
|
+
migration: options.migration,
|
|
4661
|
+
currentRoot: this._automergeSpaceState.rootUrl ?? null,
|
|
4662
|
+
newAutomergeRoot: options.newAutomergeRoot
|
|
4663
|
+
});
|
|
4664
|
+
const epoch = {
|
|
4665
|
+
previousId: this._automergeSpaceState.lastEpoch?.id,
|
|
4666
|
+
number: (this._automergeSpaceState.lastEpoch?.subject.assertion.number ?? -1) + 1,
|
|
4667
|
+
timeframe: this._automergeSpaceState.lastEpoch?.subject.assertion.timeframe ?? new Timeframe3(),
|
|
4668
|
+
automergeRoot: newRoot ?? this._automergeSpaceState.rootUrl
|
|
4669
|
+
};
|
|
4670
|
+
const credential = await this._signingContext.credentialSigner.createCredential({
|
|
4671
|
+
subject: this.key,
|
|
4672
|
+
assertion: {
|
|
4673
|
+
"@type": "dxos.halo.credentials.Epoch",
|
|
4674
|
+
...epoch
|
|
4675
|
+
}
|
|
4676
|
+
});
|
|
4498
4677
|
const receipt = await this.inner.controlPipeline.writer.write({
|
|
4499
4678
|
credential: {
|
|
4500
|
-
credential
|
|
4501
|
-
subject: this.key,
|
|
4502
|
-
assertion: {
|
|
4503
|
-
"@type": "dxos.halo.credentials.Epoch",
|
|
4504
|
-
...epoch
|
|
4505
|
-
}
|
|
4506
|
-
})
|
|
4679
|
+
credential
|
|
4507
4680
|
}
|
|
4508
4681
|
});
|
|
4509
4682
|
await this.inner.controlPipeline.state.waitUntilTimeframe(new Timeframe3([
|
|
@@ -4513,6 +4686,7 @@ var DataSpace = class {
|
|
|
4513
4686
|
]
|
|
4514
4687
|
]));
|
|
4515
4688
|
await this._echoHost.updateIndexes();
|
|
4689
|
+
return credential;
|
|
4516
4690
|
}
|
|
4517
4691
|
async activate() {
|
|
4518
4692
|
if (![
|
|
@@ -4534,11 +4708,11 @@ var DataSpace = class {
|
|
|
4534
4708
|
await this._close();
|
|
4535
4709
|
}
|
|
4536
4710
|
this._state = SpaceState2.INACTIVE;
|
|
4537
|
-
|
|
4711
|
+
log15("new state", {
|
|
4538
4712
|
state: SpaceState2[this._state]
|
|
4539
4713
|
}, {
|
|
4540
|
-
F:
|
|
4541
|
-
L:
|
|
4714
|
+
F: __dxlog_file18,
|
|
4715
|
+
L: 512,
|
|
4542
4716
|
S: this,
|
|
4543
4717
|
C: (f, a) => f(...a)
|
|
4544
4718
|
});
|
|
@@ -4593,36 +4767,27 @@ DataSpace = _ts_decorate4([
|
|
|
4593
4767
|
trackLeaks("open", "close"),
|
|
4594
4768
|
trace6.resource()
|
|
4595
4769
|
], 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
4770
|
|
|
4609
4771
|
// packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts
|
|
4610
4772
|
import { Event as Event7, synchronized as synchronized2, trackLeaks as trackLeaks2 } from "@dxos/async";
|
|
4611
4773
|
import { PropertiesType } from "@dxos/client-protocol";
|
|
4612
|
-
import {
|
|
4613
|
-
import { getCredentialAssertion as getCredentialAssertion3 } from "@dxos/credentials";
|
|
4774
|
+
import { Context as Context9, cancelWithContext as cancelWithContext6 } from "@dxos/context";
|
|
4775
|
+
import { getCredentialAssertion as getCredentialAssertion3, createAdmissionCredentials } from "@dxos/credentials";
|
|
4776
|
+
import { convertLegacyReferences as convertLegacyReferences2, findInlineObjectOfType as findInlineObjectOfType2 } from "@dxos/echo-db";
|
|
4614
4777
|
import { AuthStatus } from "@dxos/echo-pipeline";
|
|
4615
|
-
import {
|
|
4616
|
-
import {
|
|
4778
|
+
import { CredentialServerExtension } from "@dxos/echo-pipeline";
|
|
4779
|
+
import { LEGACY_TYPE_PROPERTIES, SpaceDocVersion as SpaceDocVersion2, encodeReference } from "@dxos/echo-protocol";
|
|
4780
|
+
import { TYPE_PROPERTIES as TYPE_PROPERTIES2, generateEchoId, getTypeReference } from "@dxos/echo-schema";
|
|
4781
|
+
import { writeMessages as writeMessages3 } from "@dxos/feed-store";
|
|
4617
4782
|
import { invariant as invariant14 } from "@dxos/invariant";
|
|
4618
4783
|
import { PublicKey as PublicKey11 } from "@dxos/keys";
|
|
4619
|
-
import { log as
|
|
4620
|
-
import { trace as Trace2 } from "@dxos/protocols";
|
|
4784
|
+
import { log as log16 } from "@dxos/log";
|
|
4785
|
+
import { trace as Trace2, AlreadyJoinedError as AlreadyJoinedError3 } from "@dxos/protocols";
|
|
4621
4786
|
import { Invitation as Invitation7, SpaceState as SpaceState3 } from "@dxos/protocols/proto/dxos/client/services";
|
|
4622
4787
|
import { SpaceMember as SpaceMember6 } from "@dxos/protocols/proto/dxos/halo/credentials";
|
|
4623
4788
|
import { Gossip as Gossip2, Presence as Presence2 } from "@dxos/teleport-extension-gossip";
|
|
4624
4789
|
import { trace as trace7 } from "@dxos/tracing";
|
|
4625
|
-
import {
|
|
4790
|
+
import { ComplexMap as ComplexMap3, assignDeep as assignDeep2, deferFunction as deferFunction2, forEachAsync } from "@dxos/util";
|
|
4626
4791
|
|
|
4627
4792
|
// packages/sdk/client-services/src/packlets/spaces/genesis.ts
|
|
4628
4793
|
import { createCredential } from "@dxos/credentials";
|
|
@@ -4705,7 +4870,7 @@ function _ts_decorate5(decorators, target, key, desc) {
|
|
|
4705
4870
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
4706
4871
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4707
4872
|
}
|
|
4708
|
-
var
|
|
4873
|
+
var __dxlog_file19 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts";
|
|
4709
4874
|
var PRESENCE_ANNOUNCE_INTERVAL = 1e4;
|
|
4710
4875
|
var PRESENCE_OFFLINE_TIMEOUT = 2e4;
|
|
4711
4876
|
var DEFAULT_SPACE_KEY = "__DEFAULT__";
|
|
@@ -4719,7 +4884,10 @@ var DataSpaceManager = class {
|
|
|
4719
4884
|
this._echoHost = _echoHost;
|
|
4720
4885
|
this._invitationsManager = _invitationsManager;
|
|
4721
4886
|
this._params = _params;
|
|
4722
|
-
this._ctx = new Context9(
|
|
4887
|
+
this._ctx = new Context9(void 0, {
|
|
4888
|
+
F: __dxlog_file19,
|
|
4889
|
+
L: 104
|
|
4890
|
+
});
|
|
4723
4891
|
this.updated = new Event7();
|
|
4724
4892
|
this._spaces = new ComplexMap3(PublicKey11.hash);
|
|
4725
4893
|
this._isOpen = false;
|
|
@@ -4732,7 +4900,7 @@ var DataSpaceManager = class {
|
|
|
4732
4900
|
const rootUrl = space.automergeSpaceState.rootUrl;
|
|
4733
4901
|
const rootHandle = rootUrl ? this._echoHost.automergeRepo.find(rootUrl) : void 0;
|
|
4734
4902
|
const rootDoc = rootHandle?.docSync();
|
|
4735
|
-
const properties = rootDoc &&
|
|
4903
|
+
const properties = rootDoc && findInlineObjectOfType2(rootDoc, TYPE_PROPERTIES2);
|
|
4736
4904
|
return {
|
|
4737
4905
|
key: space.key.toHex(),
|
|
4738
4906
|
state: SpaceState3[space.state],
|
|
@@ -4752,46 +4920,46 @@ var DataSpaceManager = class {
|
|
|
4752
4920
|
return this._spaces;
|
|
4753
4921
|
}
|
|
4754
4922
|
async open() {
|
|
4755
|
-
|
|
4756
|
-
F:
|
|
4757
|
-
L:
|
|
4923
|
+
log16("open", void 0, {
|
|
4924
|
+
F: __dxlog_file19,
|
|
4925
|
+
L: 156,
|
|
4758
4926
|
S: this,
|
|
4759
4927
|
C: (f, a) => f(...a)
|
|
4760
4928
|
});
|
|
4761
|
-
|
|
4929
|
+
log16.trace("dxos.echo.data-space-manager.open", Trace2.begin({
|
|
4762
4930
|
id: this._instanceId
|
|
4763
4931
|
}), {
|
|
4764
|
-
F:
|
|
4765
|
-
L:
|
|
4932
|
+
F: __dxlog_file19,
|
|
4933
|
+
L: 157,
|
|
4766
4934
|
S: this,
|
|
4767
4935
|
C: (f, a) => f(...a)
|
|
4768
4936
|
});
|
|
4769
|
-
|
|
4937
|
+
log16("metadata loaded", {
|
|
4770
4938
|
spaces: this._metadataStore.spaces.length
|
|
4771
4939
|
}, {
|
|
4772
|
-
F:
|
|
4773
|
-
L:
|
|
4940
|
+
F: __dxlog_file19,
|
|
4941
|
+
L: 158,
|
|
4774
4942
|
S: this,
|
|
4775
4943
|
C: (f, a) => f(...a)
|
|
4776
4944
|
});
|
|
4777
4945
|
await forEachAsync(this._metadataStore.spaces, async (spaceMetadata) => {
|
|
4778
4946
|
try {
|
|
4779
|
-
|
|
4947
|
+
log16("load space", {
|
|
4780
4948
|
spaceMetadata
|
|
4781
4949
|
}, {
|
|
4782
|
-
F:
|
|
4783
|
-
L:
|
|
4950
|
+
F: __dxlog_file19,
|
|
4951
|
+
L: 162,
|
|
4784
4952
|
S: this,
|
|
4785
4953
|
C: (f, a) => f(...a)
|
|
4786
4954
|
});
|
|
4787
4955
|
await this._constructSpace(spaceMetadata);
|
|
4788
4956
|
} catch (err) {
|
|
4789
|
-
|
|
4957
|
+
log16.error("Error loading space", {
|
|
4790
4958
|
spaceMetadata,
|
|
4791
4959
|
err
|
|
4792
4960
|
}, {
|
|
4793
|
-
F:
|
|
4794
|
-
L:
|
|
4961
|
+
F: __dxlog_file19,
|
|
4962
|
+
L: 165,
|
|
4795
4963
|
S: this,
|
|
4796
4964
|
C: (f, a) => f(...a)
|
|
4797
4965
|
});
|
|
@@ -4799,19 +4967,19 @@ var DataSpaceManager = class {
|
|
|
4799
4967
|
});
|
|
4800
4968
|
this._isOpen = true;
|
|
4801
4969
|
this.updated.emit();
|
|
4802
|
-
|
|
4970
|
+
log16.trace("dxos.echo.data-space-manager.open", Trace2.end({
|
|
4803
4971
|
id: this._instanceId
|
|
4804
4972
|
}), {
|
|
4805
|
-
F:
|
|
4806
|
-
L:
|
|
4973
|
+
F: __dxlog_file19,
|
|
4974
|
+
L: 172,
|
|
4807
4975
|
S: this,
|
|
4808
4976
|
C: (f, a) => f(...a)
|
|
4809
4977
|
});
|
|
4810
4978
|
}
|
|
4811
4979
|
async close() {
|
|
4812
|
-
|
|
4813
|
-
F:
|
|
4814
|
-
L:
|
|
4980
|
+
log16("close", void 0, {
|
|
4981
|
+
F: __dxlog_file19,
|
|
4982
|
+
L: 177,
|
|
4815
4983
|
S: this,
|
|
4816
4984
|
C: (f, a) => f(...a)
|
|
4817
4985
|
});
|
|
@@ -4827,8 +4995,8 @@ var DataSpaceManager = class {
|
|
|
4827
4995
|
*/
|
|
4828
4996
|
async createSpace() {
|
|
4829
4997
|
invariant14(this._isOpen, "Not open.", {
|
|
4830
|
-
F:
|
|
4831
|
-
L:
|
|
4998
|
+
F: __dxlog_file19,
|
|
4999
|
+
L: 191,
|
|
4832
5000
|
S: this,
|
|
4833
5001
|
A: [
|
|
4834
5002
|
"this._isOpen",
|
|
@@ -4845,11 +5013,11 @@ var DataSpaceManager = class {
|
|
|
4845
5013
|
dataFeedKey,
|
|
4846
5014
|
state: SpaceState3.ACTIVE
|
|
4847
5015
|
};
|
|
4848
|
-
|
|
5016
|
+
log16("creating space...", {
|
|
4849
5017
|
spaceKey
|
|
4850
5018
|
}, {
|
|
4851
|
-
F:
|
|
4852
|
-
L:
|
|
5019
|
+
F: __dxlog_file19,
|
|
5020
|
+
L: 203,
|
|
4853
5021
|
S: this,
|
|
4854
5022
|
C: (f, a) => f(...a)
|
|
4855
5023
|
});
|
|
@@ -4860,8 +5028,8 @@ var DataSpaceManager = class {
|
|
|
4860
5028
|
await this._metadataStore.addSpace(metadata);
|
|
4861
5029
|
const memberCredential = credentials[1];
|
|
4862
5030
|
invariant14(getCredentialAssertion3(memberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
|
|
4863
|
-
F:
|
|
4864
|
-
L:
|
|
5031
|
+
F: __dxlog_file19,
|
|
5032
|
+
L: 213,
|
|
4865
5033
|
S: this,
|
|
4866
5034
|
A: [
|
|
4867
5035
|
"getCredentialAssertion(memberCredential)['@type'] === 'dxos.halo.credentials.SpaceMember'",
|
|
@@ -4874,9 +5042,31 @@ var DataSpaceManager = class {
|
|
|
4874
5042
|
return space;
|
|
4875
5043
|
}
|
|
4876
5044
|
async isDefaultSpace(space) {
|
|
4877
|
-
|
|
4878
|
-
|
|
4879
|
-
|
|
5045
|
+
if (!space.databaseRoot) {
|
|
5046
|
+
return false;
|
|
5047
|
+
}
|
|
5048
|
+
switch (space.databaseRoot.getVersion()) {
|
|
5049
|
+
case SpaceDocVersion2.CURRENT: {
|
|
5050
|
+
const [_, properties] = findInlineObjectOfType2(space.databaseRoot.docSync(), TYPE_PROPERTIES2) ?? [];
|
|
5051
|
+
return properties?.data?.[DEFAULT_SPACE_KEY] === this._signingContext.identityKey.toHex();
|
|
5052
|
+
}
|
|
5053
|
+
case SpaceDocVersion2.LEGACY: {
|
|
5054
|
+
const convertedDoc = await convertLegacyReferences2(space.databaseRoot.docSync());
|
|
5055
|
+
const [_, properties] = findInlineObjectOfType2(convertedDoc, LEGACY_TYPE_PROPERTIES) ?? [];
|
|
5056
|
+
return properties?.data?.[DEFAULT_SPACE_KEY] === this._signingContext.identityKey.toHex();
|
|
5057
|
+
}
|
|
5058
|
+
default:
|
|
5059
|
+
log16.warn("unknown space version", {
|
|
5060
|
+
version: space.databaseRoot.getVersion(),
|
|
5061
|
+
spaceId: space.id
|
|
5062
|
+
}, {
|
|
5063
|
+
F: __dxlog_file19,
|
|
5064
|
+
L: 238,
|
|
5065
|
+
S: this,
|
|
5066
|
+
C: (f, a) => f(...a)
|
|
5067
|
+
});
|
|
5068
|
+
return false;
|
|
5069
|
+
}
|
|
4880
5070
|
}
|
|
4881
5071
|
async createDefaultSpace() {
|
|
4882
5072
|
const space = await this.createSpace();
|
|
@@ -4892,7 +5082,7 @@ var DataSpaceManager = class {
|
|
|
4892
5082
|
keys: []
|
|
4893
5083
|
}
|
|
4894
5084
|
};
|
|
4895
|
-
const propertiesId =
|
|
5085
|
+
const propertiesId = generateEchoId();
|
|
4896
5086
|
document.change((doc) => {
|
|
4897
5087
|
assignDeep2(doc, [
|
|
4898
5088
|
"objects",
|
|
@@ -4905,8 +5095,8 @@ var DataSpaceManager = class {
|
|
|
4905
5095
|
async _getSpaceRootDocument(space) {
|
|
4906
5096
|
const automergeIndex = space.automergeSpaceState.rootUrl;
|
|
4907
5097
|
invariant14(automergeIndex, void 0, {
|
|
4908
|
-
F:
|
|
4909
|
-
L:
|
|
5098
|
+
F: __dxlog_file19,
|
|
5099
|
+
L: 271,
|
|
4910
5100
|
S: this,
|
|
4911
5101
|
A: [
|
|
4912
5102
|
"automergeIndex",
|
|
@@ -4919,17 +5109,17 @@ var DataSpaceManager = class {
|
|
|
4919
5109
|
}
|
|
4920
5110
|
// TODO(burdon): Rename join space.
|
|
4921
5111
|
async acceptSpace(opts) {
|
|
4922
|
-
|
|
5112
|
+
log16("accept space", {
|
|
4923
5113
|
opts
|
|
4924
5114
|
}, {
|
|
4925
|
-
F:
|
|
4926
|
-
L:
|
|
5115
|
+
F: __dxlog_file19,
|
|
5116
|
+
L: 280,
|
|
4927
5117
|
S: this,
|
|
4928
5118
|
C: (f, a) => f(...a)
|
|
4929
5119
|
});
|
|
4930
|
-
invariant14(this._isOpen, "Not open.", {
|
|
4931
|
-
F:
|
|
4932
|
-
L:
|
|
5120
|
+
invariant14(this._isOpen, "Not open.", {
|
|
5121
|
+
F: __dxlog_file19,
|
|
5122
|
+
L: 281,
|
|
4933
5123
|
S: this,
|
|
4934
5124
|
A: [
|
|
4935
5125
|
"this._isOpen",
|
|
@@ -4937,8 +5127,8 @@ var DataSpaceManager = class {
|
|
|
4937
5127
|
]
|
|
4938
5128
|
});
|
|
4939
5129
|
invariant14(!this._spaces.has(opts.spaceKey), "Space already exists.", {
|
|
4940
|
-
F:
|
|
4941
|
-
L:
|
|
5130
|
+
F: __dxlog_file19,
|
|
5131
|
+
L: 282,
|
|
4942
5132
|
S: this,
|
|
4943
5133
|
A: [
|
|
4944
5134
|
"!this._spaces.has(opts.spaceKey)",
|
|
@@ -4958,23 +5148,72 @@ var DataSpaceManager = class {
|
|
|
4958
5148
|
this.updated.emit();
|
|
4959
5149
|
return space;
|
|
4960
5150
|
}
|
|
5151
|
+
async admitMember(options) {
|
|
5152
|
+
const space = this._spaceManager.spaces.get(options.spaceKey);
|
|
5153
|
+
invariant14(space, void 0, {
|
|
5154
|
+
F: __dxlog_file19,
|
|
5155
|
+
L: 302,
|
|
5156
|
+
S: this,
|
|
5157
|
+
A: [
|
|
5158
|
+
"space",
|
|
5159
|
+
""
|
|
5160
|
+
]
|
|
5161
|
+
});
|
|
5162
|
+
if (space.spaceState.getMemberRole(options.identityKey) !== SpaceMember6.Role.REMOVED) {
|
|
5163
|
+
throw new AlreadyJoinedError3();
|
|
5164
|
+
}
|
|
5165
|
+
const credentials = await createAdmissionCredentials(this._signingContext.credentialSigner, options.identityKey, space.key, space.genesisFeedKey, options.role, space.spaceState.membershipChainHeads, options.profile, options.delegationCredentialId);
|
|
5166
|
+
invariant14(credentials[0].credential, void 0, {
|
|
5167
|
+
F: __dxlog_file19,
|
|
5168
|
+
L: 321,
|
|
5169
|
+
S: this,
|
|
5170
|
+
A: [
|
|
5171
|
+
"credentials[0].credential",
|
|
5172
|
+
""
|
|
5173
|
+
]
|
|
5174
|
+
});
|
|
5175
|
+
const spaceMemberCredential = credentials[0].credential.credential;
|
|
5176
|
+
invariant14(getCredentialAssertion3(spaceMemberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
|
|
5177
|
+
F: __dxlog_file19,
|
|
5178
|
+
L: 323,
|
|
5179
|
+
S: this,
|
|
5180
|
+
A: [
|
|
5181
|
+
"getCredentialAssertion(spaceMemberCredential)['@type'] === 'dxos.halo.credentials.SpaceMember'",
|
|
5182
|
+
""
|
|
5183
|
+
]
|
|
5184
|
+
});
|
|
5185
|
+
await writeMessages3(space.controlPipeline.writer, credentials);
|
|
5186
|
+
return spaceMemberCredential;
|
|
5187
|
+
}
|
|
4961
5188
|
/**
|
|
4962
5189
|
* Wait until the space data pipeline is fully initialized.
|
|
4963
5190
|
* Used by invitation handler.
|
|
4964
5191
|
* TODO(dmaretskyi): Consider removing.
|
|
4965
5192
|
*/
|
|
4966
5193
|
async waitUntilSpaceReady(spaceKey) {
|
|
4967
|
-
await
|
|
5194
|
+
await cancelWithContext6(this._ctx, this.updated.waitForCondition(() => {
|
|
4968
5195
|
const space = this._spaces.get(spaceKey);
|
|
4969
5196
|
return !!space && space.state === SpaceState3.READY;
|
|
4970
5197
|
}));
|
|
4971
5198
|
}
|
|
5199
|
+
async requestSpaceAdmissionCredential(spaceKey) {
|
|
5200
|
+
return this._spaceManager.requestSpaceAdmissionCredential({
|
|
5201
|
+
spaceKey,
|
|
5202
|
+
identityKey: this._signingContext.identityKey,
|
|
5203
|
+
timeout: 15e3,
|
|
5204
|
+
swarmIdentity: {
|
|
5205
|
+
peerKey: this._signingContext.deviceKey,
|
|
5206
|
+
credentialProvider: createAuthProvider(this._signingContext.credentialSigner),
|
|
5207
|
+
credentialAuthenticator: async () => true
|
|
5208
|
+
}
|
|
5209
|
+
});
|
|
5210
|
+
}
|
|
4972
5211
|
async _constructSpace(metadata) {
|
|
4973
|
-
|
|
5212
|
+
log16("construct space", {
|
|
4974
5213
|
metadata
|
|
4975
5214
|
}, {
|
|
4976
|
-
F:
|
|
4977
|
-
L:
|
|
5215
|
+
F: __dxlog_file19,
|
|
5216
|
+
L: 358,
|
|
4978
5217
|
S: this,
|
|
4979
5218
|
C: (f, a) => f(...a)
|
|
4980
5219
|
});
|
|
@@ -5002,6 +5241,7 @@ var DataSpaceManager = class {
|
|
|
5002
5241
|
credentialAuthenticator: deferFunction2(() => dataSpace.authVerifier.verifier)
|
|
5003
5242
|
},
|
|
5004
5243
|
onAuthorizedConnection: (session) => {
|
|
5244
|
+
session.addExtension("dxos.mesh.teleport.admission-discovery", new CredentialServerExtension(space));
|
|
5005
5245
|
session.addExtension("dxos.mesh.teleport.gossip", gossip.createExtension({
|
|
5006
5246
|
remotePeerId: session.remotePeerId
|
|
5007
5247
|
}));
|
|
@@ -5010,9 +5250,9 @@ var DataSpaceManager = class {
|
|
|
5010
5250
|
session.addExtension("dxos.mesh.teleport.automerge", this._echoHost.createReplicationExtension());
|
|
5011
5251
|
},
|
|
5012
5252
|
onAuthFailure: () => {
|
|
5013
|
-
|
|
5014
|
-
F:
|
|
5015
|
-
L:
|
|
5253
|
+
log16.warn("auth failure", void 0, {
|
|
5254
|
+
F: __dxlog_file19,
|
|
5255
|
+
L: 396,
|
|
5016
5256
|
S: this,
|
|
5017
5257
|
C: (f, a) => f(...a)
|
|
5018
5258
|
});
|
|
@@ -5041,22 +5281,22 @@ var DataSpaceManager = class {
|
|
|
5041
5281
|
signingContext: this._signingContext,
|
|
5042
5282
|
callbacks: {
|
|
5043
5283
|
beforeReady: async () => {
|
|
5044
|
-
|
|
5284
|
+
log16("before space ready", {
|
|
5045
5285
|
space: space.key
|
|
5046
5286
|
}, {
|
|
5047
|
-
F:
|
|
5048
|
-
L:
|
|
5287
|
+
F: __dxlog_file19,
|
|
5288
|
+
L: 423,
|
|
5049
5289
|
S: this,
|
|
5050
5290
|
C: (f, a) => f(...a)
|
|
5051
5291
|
});
|
|
5052
5292
|
},
|
|
5053
5293
|
afterReady: async () => {
|
|
5054
|
-
|
|
5294
|
+
log16("after space ready", {
|
|
5055
5295
|
space: space.key,
|
|
5056
5296
|
open: this._isOpen
|
|
5057
5297
|
}, {
|
|
5058
|
-
F:
|
|
5059
|
-
L:
|
|
5298
|
+
F: __dxlog_file19,
|
|
5299
|
+
L: 426,
|
|
5060
5300
|
S: this,
|
|
5061
5301
|
C: (f, a) => f(...a)
|
|
5062
5302
|
});
|
|
@@ -5071,11 +5311,11 @@ var DataSpaceManager = class {
|
|
|
5071
5311
|
}
|
|
5072
5312
|
},
|
|
5073
5313
|
beforeClose: async () => {
|
|
5074
|
-
|
|
5314
|
+
log16("before space close", {
|
|
5075
5315
|
space: space.key
|
|
5076
5316
|
}, {
|
|
5077
|
-
F:
|
|
5078
|
-
L:
|
|
5317
|
+
F: __dxlog_file19,
|
|
5318
|
+
L: 434,
|
|
5079
5319
|
S: this,
|
|
5080
5320
|
C: (f, a) => f(...a)
|
|
5081
5321
|
});
|
|
@@ -5106,17 +5346,17 @@ var DataSpaceManager = class {
|
|
|
5106
5346
|
return (s && member.role === SpaceMember6.Role.REMOVED !== (s.authStatus === AuthStatus.FAILURE)) ?? false;
|
|
5107
5347
|
});
|
|
5108
5348
|
sessionsToClose.forEach((session) => {
|
|
5109
|
-
void session.close().catch(
|
|
5349
|
+
void session.close().catch(log16.error);
|
|
5110
5350
|
});
|
|
5111
5351
|
closedSessions += sessionsToClose.length;
|
|
5112
5352
|
}
|
|
5113
|
-
|
|
5353
|
+
log16("processed member role changes", {
|
|
5114
5354
|
roleChangeCount: memberInfo.length,
|
|
5115
5355
|
peersOnline: presence.getPeersOnline().length,
|
|
5116
5356
|
closedSessions
|
|
5117
5357
|
}, {
|
|
5118
|
-
F:
|
|
5119
|
-
L:
|
|
5358
|
+
F: __dxlog_file19,
|
|
5359
|
+
L: 470,
|
|
5120
5360
|
S: this,
|
|
5121
5361
|
C: (f, a) => f(...a)
|
|
5122
5362
|
});
|
|
@@ -5127,15 +5367,15 @@ var DataSpaceManager = class {
|
|
|
5127
5367
|
if (role === SpaceMember6.Role.REMOVED) {
|
|
5128
5368
|
const session = peerState.peerId && space.protocol.sessions.get(peerState.peerId);
|
|
5129
5369
|
if (session != null) {
|
|
5130
|
-
|
|
5370
|
+
log16("closing a session with a removed peer", {
|
|
5131
5371
|
peerId: peerState.peerId
|
|
5132
5372
|
}, {
|
|
5133
|
-
F:
|
|
5134
|
-
L:
|
|
5373
|
+
F: __dxlog_file19,
|
|
5374
|
+
L: 484,
|
|
5135
5375
|
S: this,
|
|
5136
5376
|
C: (f, a) => f(...a)
|
|
5137
5377
|
});
|
|
5138
|
-
void session.close().catch(
|
|
5378
|
+
void session.close().catch(log16.error);
|
|
5139
5379
|
}
|
|
5140
5380
|
}
|
|
5141
5381
|
}
|
|
@@ -5196,13 +5436,13 @@ import { EventSubscriptions as EventSubscriptions2, UpdateScheduler, scheduleTas
|
|
|
5196
5436
|
import { Stream as Stream10 } from "@dxos/codec-protobuf";
|
|
5197
5437
|
import { createAdmissionCredentials as createAdmissionCredentials2, getCredentialAssertion as getCredentialAssertion4 } from "@dxos/credentials";
|
|
5198
5438
|
import { raise as raise2 } from "@dxos/debug";
|
|
5199
|
-
import { writeMessages as
|
|
5439
|
+
import { writeMessages as writeMessages4 } from "@dxos/feed-store";
|
|
5200
5440
|
import { invariant as invariant15 } from "@dxos/invariant";
|
|
5201
|
-
import { log as
|
|
5441
|
+
import { log as log17 } from "@dxos/log";
|
|
5202
5442
|
import { ApiError, SpaceNotFoundError as SpaceNotFoundError2, encodeError, IdentityNotInitializedError, AuthorizationError as AuthorizationError2 } from "@dxos/protocols";
|
|
5203
5443
|
import { SpaceMember as SpaceMember7, SpaceState as SpaceState4 } from "@dxos/protocols/proto/dxos/client/services";
|
|
5204
5444
|
import { trace as trace8 } from "@dxos/tracing";
|
|
5205
|
-
var
|
|
5445
|
+
var __dxlog_file20 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/spaces-service.ts";
|
|
5206
5446
|
var SpacesServiceImpl = class {
|
|
5207
5447
|
constructor(_identityManager, _spaceManager, _getDataSpaceManager) {
|
|
5208
5448
|
this._identityManager = _identityManager;
|
|
@@ -5246,8 +5486,8 @@ var SpacesServiceImpl = class {
|
|
|
5246
5486
|
}
|
|
5247
5487
|
const credentials = await createAdmissionCredentials2(identity.getIdentityCredentialSigner(), request.memberKey, space.key, space.genesisFeedKey, request.newRole, space.spaceState.membershipChainHeads);
|
|
5248
5488
|
invariant15(credentials[0].credential, void 0, {
|
|
5249
|
-
F:
|
|
5250
|
-
L:
|
|
5489
|
+
F: __dxlog_file20,
|
|
5490
|
+
L: 102,
|
|
5251
5491
|
S: this,
|
|
5252
5492
|
A: [
|
|
5253
5493
|
"credentials[0].credential",
|
|
@@ -5256,26 +5496,26 @@ var SpacesServiceImpl = class {
|
|
|
5256
5496
|
});
|
|
5257
5497
|
const spaceMemberCredential = credentials[0].credential.credential;
|
|
5258
5498
|
invariant15(getCredentialAssertion4(spaceMemberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
|
|
5259
|
-
F:
|
|
5260
|
-
L:
|
|
5499
|
+
F: __dxlog_file20,
|
|
5500
|
+
L: 104,
|
|
5261
5501
|
S: this,
|
|
5262
5502
|
A: [
|
|
5263
5503
|
"getCredentialAssertion(spaceMemberCredential)['@type'] === 'dxos.halo.credentials.SpaceMember'",
|
|
5264
5504
|
""
|
|
5265
5505
|
]
|
|
5266
5506
|
});
|
|
5267
|
-
await
|
|
5507
|
+
await writeMessages4(space.controlPipeline.writer, credentials);
|
|
5268
5508
|
}
|
|
5269
5509
|
querySpaces() {
|
|
5270
5510
|
return new Stream10(({ next, ctx }) => {
|
|
5271
5511
|
const scheduler = new UpdateScheduler(ctx, async () => {
|
|
5272
5512
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
5273
5513
|
const spaces = Array.from(dataSpaceManager.spaces.values()).map((space) => this._serializeSpace(space));
|
|
5274
|
-
|
|
5514
|
+
log17("update", {
|
|
5275
5515
|
spaces
|
|
5276
5516
|
}, {
|
|
5277
|
-
F:
|
|
5278
|
-
L:
|
|
5517
|
+
F: __dxlog_file20,
|
|
5518
|
+
L: 115,
|
|
5279
5519
|
S: this,
|
|
5280
5520
|
C: (f, a) => f(...a)
|
|
5281
5521
|
});
|
|
@@ -5293,7 +5533,15 @@ var SpacesServiceImpl = class {
|
|
|
5293
5533
|
const subscribeSpaces = () => {
|
|
5294
5534
|
subscriptions.clear();
|
|
5295
5535
|
for (const space of dataSpaceManager.spaces.values()) {
|
|
5296
|
-
|
|
5536
|
+
let lastState;
|
|
5537
|
+
subscriptions.add(space.stateUpdate.on(ctx, () => {
|
|
5538
|
+
if (space.state !== lastState) {
|
|
5539
|
+
scheduler.forceTrigger();
|
|
5540
|
+
} else {
|
|
5541
|
+
scheduler.trigger();
|
|
5542
|
+
}
|
|
5543
|
+
lastState = space.state;
|
|
5544
|
+
}));
|
|
5297
5545
|
subscriptions.add(space.presence.updated.on(ctx, () => scheduler.trigger()));
|
|
5298
5546
|
subscriptions.add(space.automergeSpaceState.onNewEpoch.on(ctx, () => scheduler.trigger()));
|
|
5299
5547
|
subscriptions.add(space.inner.controlPipeline.state.timeframeUpdate.on(ctx, () => scheduler.trigger()));
|
|
@@ -5358,8 +5606,8 @@ var SpacesServiceImpl = class {
|
|
|
5358
5606
|
});
|
|
5359
5607
|
} else {
|
|
5360
5608
|
invariant15(!credential.id, "Id on unsigned credentials is not allowed", {
|
|
5361
|
-
F:
|
|
5362
|
-
L:
|
|
5609
|
+
F: __dxlog_file20,
|
|
5610
|
+
L: 213,
|
|
5363
5611
|
S: this,
|
|
5364
5612
|
A: [
|
|
5365
5613
|
"!credential.id",
|
|
@@ -5367,8 +5615,8 @@ var SpacesServiceImpl = class {
|
|
|
5367
5615
|
]
|
|
5368
5616
|
});
|
|
5369
5617
|
invariant15(this._identityManager.identity, "Identity is not available", {
|
|
5370
|
-
F:
|
|
5371
|
-
L:
|
|
5618
|
+
F: __dxlog_file20,
|
|
5619
|
+
L: 214,
|
|
5372
5620
|
S: this,
|
|
5373
5621
|
A: [
|
|
5374
5622
|
"this._identityManager.identity",
|
|
@@ -5377,8 +5625,8 @@ var SpacesServiceImpl = class {
|
|
|
5377
5625
|
});
|
|
5378
5626
|
const signer = this._identityManager.identity.getIdentityCredentialSigner();
|
|
5379
5627
|
invariant15(credential.issuer.equals(signer.getIssuer()), void 0, {
|
|
5380
|
-
F:
|
|
5381
|
-
L:
|
|
5628
|
+
F: __dxlog_file20,
|
|
5629
|
+
L: 216,
|
|
5382
5630
|
S: this,
|
|
5383
5631
|
A: [
|
|
5384
5632
|
"credential.issuer.equals(signer.getIssuer())",
|
|
@@ -5400,10 +5648,66 @@ var SpacesServiceImpl = class {
|
|
|
5400
5648
|
async createEpoch({ spaceKey, migration, automergeRootUrl }) {
|
|
5401
5649
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
5402
5650
|
const space = dataSpaceManager.spaces.get(spaceKey) ?? raise2(new SpaceNotFoundError2(spaceKey));
|
|
5403
|
-
await space.createEpoch({
|
|
5651
|
+
const credential = await space.createEpoch({
|
|
5404
5652
|
migration,
|
|
5405
5653
|
newAutomergeRoot: automergeRootUrl
|
|
5406
5654
|
});
|
|
5655
|
+
return {
|
|
5656
|
+
epochCredential: credential ?? void 0
|
|
5657
|
+
};
|
|
5658
|
+
}
|
|
5659
|
+
async admitContact(request) {
|
|
5660
|
+
const dataSpaceManager = await this._getDataSpaceManager();
|
|
5661
|
+
await dataSpaceManager.admitMember({
|
|
5662
|
+
spaceKey: request.spaceKey,
|
|
5663
|
+
identityKey: request.contact.identityKey,
|
|
5664
|
+
role: request.role
|
|
5665
|
+
});
|
|
5666
|
+
}
|
|
5667
|
+
async joinBySpaceKey({ spaceKey }) {
|
|
5668
|
+
const dataSpaceManager = await this._getDataSpaceManager();
|
|
5669
|
+
const credential = await dataSpaceManager.requestSpaceAdmissionCredential(spaceKey);
|
|
5670
|
+
return this._joinByAdmission({
|
|
5671
|
+
credential
|
|
5672
|
+
});
|
|
5673
|
+
}
|
|
5674
|
+
async _joinByAdmission({ credential }) {
|
|
5675
|
+
const assertion = getCredentialAssertion4(credential);
|
|
5676
|
+
invariant15(assertion["@type"] === "dxos.halo.credentials.SpaceMember", "Invalid credential", {
|
|
5677
|
+
F: __dxlog_file20,
|
|
5678
|
+
L: 250,
|
|
5679
|
+
S: this,
|
|
5680
|
+
A: [
|
|
5681
|
+
"assertion['@type'] === 'dxos.halo.credentials.SpaceMember'",
|
|
5682
|
+
"'Invalid credential'"
|
|
5683
|
+
]
|
|
5684
|
+
});
|
|
5685
|
+
const myIdentity = this._identityManager.identity;
|
|
5686
|
+
invariant15(myIdentity && credential.subject.id.equals(myIdentity.identityKey), void 0, {
|
|
5687
|
+
F: __dxlog_file20,
|
|
5688
|
+
L: 252,
|
|
5689
|
+
S: this,
|
|
5690
|
+
A: [
|
|
5691
|
+
"myIdentity && credential.subject.id.equals(myIdentity.identityKey)",
|
|
5692
|
+
""
|
|
5693
|
+
]
|
|
5694
|
+
});
|
|
5695
|
+
const dataSpaceManager = await this._getDataSpaceManager();
|
|
5696
|
+
let dataSpace = dataSpaceManager.spaces.get(assertion.spaceKey);
|
|
5697
|
+
if (!dataSpace) {
|
|
5698
|
+
dataSpace = await dataSpaceManager.acceptSpace({
|
|
5699
|
+
spaceKey: assertion.spaceKey,
|
|
5700
|
+
genesisFeedKey: assertion.genesisFeedKey
|
|
5701
|
+
});
|
|
5702
|
+
await myIdentity.controlPipeline.writer.write({
|
|
5703
|
+
credential: {
|
|
5704
|
+
credential
|
|
5705
|
+
}
|
|
5706
|
+
});
|
|
5707
|
+
}
|
|
5708
|
+
return {
|
|
5709
|
+
space: this._serializeSpace(dataSpace)
|
|
5710
|
+
};
|
|
5407
5711
|
}
|
|
5408
5712
|
_serializeSpace(space) {
|
|
5409
5713
|
return {
|
|
@@ -5466,8 +5770,8 @@ var SpacesServiceImpl = class {
|
|
|
5466
5770
|
var getChannelId = (channel) => `user-channel/${channel}`;
|
|
5467
5771
|
|
|
5468
5772
|
// packages/sdk/client-services/src/packlets/services/service-context.ts
|
|
5469
|
-
import { Trigger as
|
|
5470
|
-
import { Context as Context10, Resource as
|
|
5773
|
+
import { Trigger as Trigger8 } from "@dxos/async";
|
|
5774
|
+
import { Context as Context10, Resource as Resource3 } from "@dxos/context";
|
|
5471
5775
|
import { getCredentialAssertion as getCredentialAssertion5 } from "@dxos/credentials";
|
|
5472
5776
|
import { failUndefined as failUndefined2 } from "@dxos/debug";
|
|
5473
5777
|
import { EchoHost } from "@dxos/echo-db";
|
|
@@ -5476,7 +5780,7 @@ import { FeedFactory, FeedStore } from "@dxos/feed-store";
|
|
|
5476
5780
|
import { invariant as invariant16 } from "@dxos/invariant";
|
|
5477
5781
|
import { Keyring } from "@dxos/keyring";
|
|
5478
5782
|
import { PublicKey as PublicKey12 } from "@dxos/keys";
|
|
5479
|
-
import { log as
|
|
5783
|
+
import { log as log18 } from "@dxos/log";
|
|
5480
5784
|
import { InvalidStorageVersionError, STORAGE_VERSION as STORAGE_VERSION2, trace as trace9 } from "@dxos/protocols";
|
|
5481
5785
|
import { Invitation as Invitation8 } from "@dxos/protocols/proto/dxos/client/services";
|
|
5482
5786
|
import { BlobStore } from "@dxos/teleport-extension-object-sync";
|
|
@@ -5492,8 +5796,8 @@ function _ts_decorate6(decorators, target, key, desc) {
|
|
|
5492
5796
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5493
5797
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
5494
5798
|
}
|
|
5495
|
-
var
|
|
5496
|
-
var ServiceContext = class extends
|
|
5799
|
+
var __dxlog_file21 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-context.ts";
|
|
5800
|
+
var ServiceContext = class extends Resource3 {
|
|
5497
5801
|
constructor(storage, level, networkManager, signalManager, _runtimeParams) {
|
|
5498
5802
|
super();
|
|
5499
5803
|
this.storage = storage;
|
|
@@ -5501,7 +5805,7 @@ var ServiceContext = class extends Resource2 {
|
|
|
5501
5805
|
this.networkManager = networkManager;
|
|
5502
5806
|
this.signalManager = signalManager;
|
|
5503
5807
|
this._runtimeParams = _runtimeParams;
|
|
5504
|
-
this.initialized = new
|
|
5808
|
+
this.initialized = new Trigger8();
|
|
5505
5809
|
this._handlerFactories = /* @__PURE__ */ new Map();
|
|
5506
5810
|
this._instanceId = PublicKey12.random().toHex();
|
|
5507
5811
|
this.metadataStore = new MetadataStore(storage.createDirectory("metadata"));
|
|
@@ -5527,8 +5831,7 @@ var ServiceContext = class extends Resource2 {
|
|
|
5527
5831
|
});
|
|
5528
5832
|
this.identityManager = new IdentityManager(this.metadataStore, this.keyring, this.feedStore, this.spaceManager, this._runtimeParams);
|
|
5529
5833
|
this.echoHost = new EchoHost({
|
|
5530
|
-
kv: this.level
|
|
5531
|
-
storage: this.storage
|
|
5834
|
+
kv: this.level
|
|
5532
5835
|
});
|
|
5533
5836
|
this.invitations = new InvitationsHandler(this.networkManager, _runtimeParams?.invitationConnectionDefaultParams);
|
|
5534
5837
|
this.invitationsManager = new InvitationsManager(this.invitations, (invitation) => this.getInvitationHandler(invitation), this.metadataStore);
|
|
@@ -5536,17 +5839,17 @@ var ServiceContext = class extends Resource2 {
|
|
|
5536
5839
|
}
|
|
5537
5840
|
async _open(ctx) {
|
|
5538
5841
|
await this._checkStorageVersion();
|
|
5539
|
-
|
|
5540
|
-
F:
|
|
5541
|
-
L:
|
|
5842
|
+
log18("opening...", void 0, {
|
|
5843
|
+
F: __dxlog_file21,
|
|
5844
|
+
L: 149,
|
|
5542
5845
|
S: this,
|
|
5543
5846
|
C: (f, a) => f(...a)
|
|
5544
5847
|
});
|
|
5545
|
-
|
|
5848
|
+
log18.trace("dxos.sdk.service-context.open", trace9.begin({
|
|
5546
5849
|
id: this._instanceId
|
|
5547
5850
|
}), {
|
|
5548
|
-
F:
|
|
5549
|
-
L:
|
|
5851
|
+
F: __dxlog_file21,
|
|
5852
|
+
L: 150,
|
|
5550
5853
|
S: this,
|
|
5551
5854
|
C: (f, a) => f(...a)
|
|
5552
5855
|
});
|
|
@@ -5560,33 +5863,33 @@ var ServiceContext = class extends Resource2 {
|
|
|
5560
5863
|
await this._initialize(ctx);
|
|
5561
5864
|
}
|
|
5562
5865
|
const loadedInvitations = await this.invitationsManager.loadPersistentInvitations();
|
|
5563
|
-
|
|
5866
|
+
log18("loaded persistent invitations", {
|
|
5564
5867
|
count: loadedInvitations.invitations?.length
|
|
5565
5868
|
}, {
|
|
5566
|
-
F:
|
|
5567
|
-
L:
|
|
5869
|
+
F: __dxlog_file21,
|
|
5870
|
+
L: 163,
|
|
5568
5871
|
S: this,
|
|
5569
5872
|
C: (f, a) => f(...a)
|
|
5570
5873
|
});
|
|
5571
|
-
|
|
5874
|
+
log18.trace("dxos.sdk.service-context.open", trace9.end({
|
|
5572
5875
|
id: this._instanceId
|
|
5573
5876
|
}), {
|
|
5574
|
-
F:
|
|
5575
|
-
L:
|
|
5877
|
+
F: __dxlog_file21,
|
|
5878
|
+
L: 165,
|
|
5576
5879
|
S: this,
|
|
5577
5880
|
C: (f, a) => f(...a)
|
|
5578
5881
|
});
|
|
5579
|
-
|
|
5580
|
-
F:
|
|
5581
|
-
L:
|
|
5882
|
+
log18("opened", void 0, {
|
|
5883
|
+
F: __dxlog_file21,
|
|
5884
|
+
L: 166,
|
|
5582
5885
|
S: this,
|
|
5583
5886
|
C: (f, a) => f(...a)
|
|
5584
5887
|
});
|
|
5585
5888
|
}
|
|
5586
5889
|
async _close(ctx) {
|
|
5587
|
-
|
|
5588
|
-
F:
|
|
5589
|
-
L:
|
|
5890
|
+
log18("closing...", void 0, {
|
|
5891
|
+
F: __dxlog_file21,
|
|
5892
|
+
L: 170,
|
|
5590
5893
|
S: this,
|
|
5591
5894
|
C: (f, a) => f(...a)
|
|
5592
5895
|
});
|
|
@@ -5601,23 +5904,26 @@ var ServiceContext = class extends Resource2 {
|
|
|
5601
5904
|
await this.echoHost.close(ctx);
|
|
5602
5905
|
await this.networkManager.close();
|
|
5603
5906
|
await this.signalManager.close();
|
|
5604
|
-
|
|
5605
|
-
F:
|
|
5606
|
-
L:
|
|
5907
|
+
log18("closed", void 0, {
|
|
5908
|
+
F: __dxlog_file21,
|
|
5909
|
+
L: 182,
|
|
5607
5910
|
S: this,
|
|
5608
5911
|
C: (f, a) => f(...a)
|
|
5609
5912
|
});
|
|
5610
5913
|
}
|
|
5611
5914
|
async createIdentity(params = {}) {
|
|
5612
5915
|
const identity = await this.identityManager.createIdentity(params);
|
|
5613
|
-
await this._initialize(new Context10(
|
|
5916
|
+
await this._initialize(new Context10(void 0, {
|
|
5917
|
+
F: __dxlog_file21,
|
|
5918
|
+
L: 187
|
|
5919
|
+
}));
|
|
5614
5920
|
return identity;
|
|
5615
5921
|
}
|
|
5616
5922
|
getInvitationHandler(invitation) {
|
|
5617
5923
|
const factory = this._handlerFactories.get(invitation.kind);
|
|
5618
5924
|
invariant16(factory, `Unknown invitation kind: ${invitation.kind}`, {
|
|
5619
|
-
F:
|
|
5620
|
-
L:
|
|
5925
|
+
F: __dxlog_file21,
|
|
5926
|
+
L: 193,
|
|
5621
5927
|
S: this,
|
|
5622
5928
|
A: [
|
|
5623
5929
|
"factory",
|
|
@@ -5636,7 +5942,10 @@ var ServiceContext = class extends Resource2 {
|
|
|
5636
5942
|
}
|
|
5637
5943
|
async _acceptIdentity(params) {
|
|
5638
5944
|
const identity = await this.identityManager.acceptIdentity(params);
|
|
5639
|
-
await this._initialize(new Context10(
|
|
5945
|
+
await this._initialize(new Context10(void 0, {
|
|
5946
|
+
F: __dxlog_file21,
|
|
5947
|
+
L: 209
|
|
5948
|
+
}));
|
|
5640
5949
|
return identity;
|
|
5641
5950
|
}
|
|
5642
5951
|
async _checkStorageVersion() {
|
|
@@ -5647,9 +5956,9 @@ var ServiceContext = class extends Resource2 {
|
|
|
5647
5956
|
}
|
|
5648
5957
|
// Called when identity is created.
|
|
5649
5958
|
async _initialize(ctx) {
|
|
5650
|
-
|
|
5651
|
-
F:
|
|
5652
|
-
L:
|
|
5959
|
+
log18("initializing spaces...", void 0, {
|
|
5960
|
+
F: __dxlog_file21,
|
|
5961
|
+
L: 224,
|
|
5653
5962
|
S: this,
|
|
5654
5963
|
C: (f, a) => f(...a)
|
|
5655
5964
|
});
|
|
@@ -5671,8 +5980,8 @@ var ServiceContext = class extends Resource2 {
|
|
|
5671
5980
|
await this.dataSpaceManager.open();
|
|
5672
5981
|
this._handlerFactories.set(Invitation8.Kind.SPACE, (invitation) => {
|
|
5673
5982
|
invariant16(this.dataSpaceManager, "dataSpaceManager not initialized yet", {
|
|
5674
|
-
F:
|
|
5675
|
-
L:
|
|
5983
|
+
F: __dxlog_file21,
|
|
5984
|
+
L: 249,
|
|
5676
5985
|
S: this,
|
|
5677
5986
|
A: [
|
|
5678
5987
|
"this.dataSpaceManager",
|
|
@@ -5692,33 +6001,33 @@ var ServiceContext = class extends Resource2 {
|
|
|
5692
6001
|
return;
|
|
5693
6002
|
}
|
|
5694
6003
|
if (!this.dataSpaceManager) {
|
|
5695
|
-
|
|
6004
|
+
log18("dataSpaceManager not initialized yet, ignoring space admission", {
|
|
5696
6005
|
details: assertion
|
|
5697
6006
|
}, {
|
|
5698
|
-
F:
|
|
5699
|
-
L:
|
|
6007
|
+
F: __dxlog_file21,
|
|
6008
|
+
L: 265,
|
|
5700
6009
|
S: this,
|
|
5701
6010
|
C: (f, a) => f(...a)
|
|
5702
6011
|
});
|
|
5703
6012
|
return;
|
|
5704
6013
|
}
|
|
5705
6014
|
if (this.dataSpaceManager.spaces.has(assertion.spaceKey)) {
|
|
5706
|
-
|
|
6015
|
+
log18("space already exists, ignoring space admission", {
|
|
5707
6016
|
details: assertion
|
|
5708
6017
|
}, {
|
|
5709
|
-
F:
|
|
5710
|
-
L:
|
|
6018
|
+
F: __dxlog_file21,
|
|
6019
|
+
L: 269,
|
|
5711
6020
|
S: this,
|
|
5712
6021
|
C: (f, a) => f(...a)
|
|
5713
6022
|
});
|
|
5714
6023
|
return;
|
|
5715
6024
|
}
|
|
5716
6025
|
try {
|
|
5717
|
-
|
|
6026
|
+
log18("accepting space recorded in halo", {
|
|
5718
6027
|
details: assertion
|
|
5719
6028
|
}, {
|
|
5720
|
-
F:
|
|
5721
|
-
L:
|
|
6029
|
+
F: __dxlog_file21,
|
|
6030
|
+
L: 274,
|
|
5722
6031
|
S: this,
|
|
5723
6032
|
C: (f, a) => f(...a)
|
|
5724
6033
|
});
|
|
@@ -5727,9 +6036,9 @@ var ServiceContext = class extends Resource2 {
|
|
|
5727
6036
|
genesisFeedKey: assertion.genesisFeedKey
|
|
5728
6037
|
});
|
|
5729
6038
|
} catch (err) {
|
|
5730
|
-
|
|
5731
|
-
F:
|
|
5732
|
-
L:
|
|
6039
|
+
log18.catch(err, void 0, {
|
|
6040
|
+
F: __dxlog_file21,
|
|
6041
|
+
L: 280,
|
|
5733
6042
|
S: this,
|
|
5734
6043
|
C: (f, a) => f(...a)
|
|
5735
6044
|
});
|
|
@@ -5775,9 +6084,9 @@ var ServiceRegistry = class {
|
|
|
5775
6084
|
};
|
|
5776
6085
|
|
|
5777
6086
|
// packages/sdk/client-services/src/packlets/locks/browser.ts
|
|
5778
|
-
import { asyncTimeout as asyncTimeout3, Trigger as
|
|
6087
|
+
import { asyncTimeout as asyncTimeout3, Trigger as Trigger9 } from "@dxos/async";
|
|
5779
6088
|
import { RESOURCE_LOCK_TIMEOUT } from "@dxos/client-protocol";
|
|
5780
|
-
import { log as
|
|
6089
|
+
import { log as log19, logInfo } from "@dxos/log";
|
|
5781
6090
|
function _ts_decorate7(decorators, target, key, desc) {
|
|
5782
6091
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
5783
6092
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
@@ -5788,7 +6097,7 @@ function _ts_decorate7(decorators, target, key, desc) {
|
|
|
5788
6097
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5789
6098
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
5790
6099
|
}
|
|
5791
|
-
var
|
|
6100
|
+
var __dxlog_file22 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/locks/browser.ts";
|
|
5792
6101
|
var Message;
|
|
5793
6102
|
(function(Message2) {
|
|
5794
6103
|
Message2["ACQUIRING"] = "acquiring";
|
|
@@ -5796,7 +6105,7 @@ var Message;
|
|
|
5796
6105
|
var Lock = class {
|
|
5797
6106
|
constructor({ lockKey, onAcquire, onRelease }) {
|
|
5798
6107
|
this._broadcastChannel = new BroadcastChannel("vault-resource-lock");
|
|
5799
|
-
this._releaseTrigger = new
|
|
6108
|
+
this._releaseTrigger = new Trigger9();
|
|
5800
6109
|
this._lockKey = lockKey;
|
|
5801
6110
|
this._onAcquire = onAcquire;
|
|
5802
6111
|
this._onRelease = onRelease;
|
|
@@ -5810,29 +6119,29 @@ var Lock = class {
|
|
|
5810
6119
|
message: "acquiring"
|
|
5811
6120
|
});
|
|
5812
6121
|
try {
|
|
5813
|
-
|
|
5814
|
-
F:
|
|
6122
|
+
log19("aquiring lock...", void 0, {
|
|
6123
|
+
F: __dxlog_file22,
|
|
5815
6124
|
L: 42,
|
|
5816
6125
|
S: this,
|
|
5817
6126
|
C: (f, a) => f(...a)
|
|
5818
6127
|
});
|
|
5819
6128
|
await asyncTimeout3(this._requestLock(), RESOURCE_LOCK_TIMEOUT);
|
|
5820
|
-
|
|
5821
|
-
F:
|
|
6129
|
+
log19("acquired lock", void 0, {
|
|
6130
|
+
F: __dxlog_file22,
|
|
5822
6131
|
L: 44,
|
|
5823
6132
|
S: this,
|
|
5824
6133
|
C: (f, a) => f(...a)
|
|
5825
6134
|
});
|
|
5826
6135
|
} catch {
|
|
5827
|
-
|
|
5828
|
-
F:
|
|
6136
|
+
log19("stealing lock...", void 0, {
|
|
6137
|
+
F: __dxlog_file22,
|
|
5829
6138
|
L: 46,
|
|
5830
6139
|
S: this,
|
|
5831
6140
|
C: (f, a) => f(...a)
|
|
5832
6141
|
});
|
|
5833
6142
|
await this._requestLock(true);
|
|
5834
|
-
|
|
5835
|
-
F:
|
|
6143
|
+
log19("stolen lock", void 0, {
|
|
6144
|
+
F: __dxlog_file22,
|
|
5836
6145
|
L: 48,
|
|
5837
6146
|
S: this,
|
|
5838
6147
|
C: (f, a) => f(...a)
|
|
@@ -5848,31 +6157,31 @@ var Lock = class {
|
|
|
5848
6157
|
}
|
|
5849
6158
|
}
|
|
5850
6159
|
async _requestLock(steal = false) {
|
|
5851
|
-
|
|
6160
|
+
log19("requesting lock...", {
|
|
5852
6161
|
steal
|
|
5853
6162
|
}, {
|
|
5854
|
-
F:
|
|
6163
|
+
F: __dxlog_file22,
|
|
5855
6164
|
L: 63,
|
|
5856
6165
|
S: this,
|
|
5857
6166
|
C: (f, a) => f(...a)
|
|
5858
6167
|
});
|
|
5859
|
-
const acquired = new
|
|
6168
|
+
const acquired = new Trigger9();
|
|
5860
6169
|
void navigator.locks.request(this._lockKey, {
|
|
5861
6170
|
steal
|
|
5862
6171
|
}, async () => {
|
|
5863
6172
|
await this._onAcquire?.();
|
|
5864
6173
|
acquired.wake();
|
|
5865
|
-
this._releaseTrigger = new
|
|
6174
|
+
this._releaseTrigger = new Trigger9();
|
|
5866
6175
|
await this._releaseTrigger.wait();
|
|
5867
|
-
|
|
5868
|
-
F:
|
|
6176
|
+
log19("releasing lock...", void 0, {
|
|
6177
|
+
F: __dxlog_file22,
|
|
5869
6178
|
L: 72,
|
|
5870
6179
|
S: this,
|
|
5871
6180
|
C: (f, a) => f(...a)
|
|
5872
6181
|
});
|
|
5873
6182
|
await this._onRelease?.();
|
|
5874
|
-
|
|
5875
|
-
F:
|
|
6183
|
+
log19("released lock", void 0, {
|
|
6184
|
+
F: __dxlog_file22,
|
|
5876
6185
|
L: 74,
|
|
5877
6186
|
S: this,
|
|
5878
6187
|
C: (f, a) => f(...a)
|
|
@@ -5881,10 +6190,10 @@ var Lock = class {
|
|
|
5881
6190
|
await this._onRelease?.();
|
|
5882
6191
|
});
|
|
5883
6192
|
await acquired.wait();
|
|
5884
|
-
|
|
6193
|
+
log19("recieved lock", {
|
|
5885
6194
|
steal
|
|
5886
6195
|
}, {
|
|
5887
|
-
F:
|
|
6196
|
+
F: __dxlog_file22,
|
|
5888
6197
|
L: 81,
|
|
5889
6198
|
S: this,
|
|
5890
6199
|
C: (f, a) => f(...a)
|
|
@@ -5972,13 +6281,151 @@ var createLevel = async (config) => {
|
|
|
5972
6281
|
return level;
|
|
5973
6282
|
};
|
|
5974
6283
|
|
|
6284
|
+
// packages/sdk/client-services/src/packlets/storage/profile-archive.ts
|
|
6285
|
+
import { cbor } from "@dxos/automerge/automerge-repo";
|
|
6286
|
+
import { invariant as invariant17 } from "@dxos/invariant";
|
|
6287
|
+
import { log as log20 } from "@dxos/log";
|
|
6288
|
+
import { ProfileArchiveEntryType } from "@dxos/protocols";
|
|
6289
|
+
import { arrayToBuffer } from "@dxos/util";
|
|
6290
|
+
var __dxlog_file23 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/storage/profile-archive.ts";
|
|
6291
|
+
var encodeProfileArchive = (profile) => cbor.encode(profile);
|
|
6292
|
+
var decodeProfileArchive = (data) => cbor.decode(data);
|
|
6293
|
+
var exportProfileData = async ({ storage, level }) => {
|
|
6294
|
+
const archive = {
|
|
6295
|
+
storage: [],
|
|
6296
|
+
meta: {
|
|
6297
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
6298
|
+
}
|
|
6299
|
+
};
|
|
6300
|
+
{
|
|
6301
|
+
const directory = await storage.createDirectory();
|
|
6302
|
+
const files = await directory.list();
|
|
6303
|
+
log20.info("begin exporting files", {
|
|
6304
|
+
count: files.length
|
|
6305
|
+
}, {
|
|
6306
|
+
F: __dxlog_file23,
|
|
6307
|
+
L: 30,
|
|
6308
|
+
S: void 0,
|
|
6309
|
+
C: (f, a) => f(...a)
|
|
6310
|
+
});
|
|
6311
|
+
for (const filename of files) {
|
|
6312
|
+
const file = await directory.getOrCreateFile(filename);
|
|
6313
|
+
const { size } = await file.stat();
|
|
6314
|
+
const data = await file.read(0, size);
|
|
6315
|
+
archive.storage.push({
|
|
6316
|
+
type: ProfileArchiveEntryType.FILE,
|
|
6317
|
+
key: filename,
|
|
6318
|
+
value: data
|
|
6319
|
+
});
|
|
6320
|
+
}
|
|
6321
|
+
log20.info("done exporting files", {
|
|
6322
|
+
count: files.length
|
|
6323
|
+
}, {
|
|
6324
|
+
F: __dxlog_file23,
|
|
6325
|
+
L: 41,
|
|
6326
|
+
S: void 0,
|
|
6327
|
+
C: (f, a) => f(...a)
|
|
6328
|
+
});
|
|
6329
|
+
}
|
|
6330
|
+
{
|
|
6331
|
+
log20.info("begin exporting kv pairs", void 0, {
|
|
6332
|
+
F: __dxlog_file23,
|
|
6333
|
+
L: 45,
|
|
6334
|
+
S: void 0,
|
|
6335
|
+
C: (f, a) => f(...a)
|
|
6336
|
+
});
|
|
6337
|
+
const iter = await level.iterator({
|
|
6338
|
+
keyEncoding: "binary",
|
|
6339
|
+
valueEncoding: "binary"
|
|
6340
|
+
});
|
|
6341
|
+
let count = 0;
|
|
6342
|
+
for await (const [key, value] of iter) {
|
|
6343
|
+
archive.storage.push({
|
|
6344
|
+
type: ProfileArchiveEntryType.KEY_VALUE,
|
|
6345
|
+
key,
|
|
6346
|
+
value
|
|
6347
|
+
});
|
|
6348
|
+
count++;
|
|
6349
|
+
}
|
|
6350
|
+
log20.info("done exporting kv pairs", {
|
|
6351
|
+
count
|
|
6352
|
+
}, {
|
|
6353
|
+
F: __dxlog_file23,
|
|
6354
|
+
L: 56,
|
|
6355
|
+
S: void 0,
|
|
6356
|
+
C: (f, a) => f(...a)
|
|
6357
|
+
});
|
|
6358
|
+
}
|
|
6359
|
+
return archive;
|
|
6360
|
+
};
|
|
6361
|
+
var importProfileData = async ({ storage, level }, archive) => {
|
|
6362
|
+
const batch = level.batch();
|
|
6363
|
+
for (const entry2 of archive.storage) {
|
|
6364
|
+
switch (entry2.type) {
|
|
6365
|
+
case ProfileArchiveEntryType.FILE: {
|
|
6366
|
+
const directory = await storage.createDirectory();
|
|
6367
|
+
invariant17(typeof entry2.key === "string", "Invalid key type", {
|
|
6368
|
+
F: __dxlog_file23,
|
|
6369
|
+
L: 78,
|
|
6370
|
+
S: void 0,
|
|
6371
|
+
A: [
|
|
6372
|
+
"typeof entry.key === 'string'",
|
|
6373
|
+
"'Invalid key type'"
|
|
6374
|
+
]
|
|
6375
|
+
});
|
|
6376
|
+
const file = await directory.getOrCreateFile(entry2.key);
|
|
6377
|
+
invariant17(entry2.value instanceof Uint8Array, "Invalid value type", {
|
|
6378
|
+
F: __dxlog_file23,
|
|
6379
|
+
L: 80,
|
|
6380
|
+
S: void 0,
|
|
6381
|
+
A: [
|
|
6382
|
+
"entry.value instanceof Uint8Array",
|
|
6383
|
+
"'Invalid value type'"
|
|
6384
|
+
]
|
|
6385
|
+
});
|
|
6386
|
+
await file.write(0, arrayToBuffer(entry2.value));
|
|
6387
|
+
await file.close();
|
|
6388
|
+
break;
|
|
6389
|
+
}
|
|
6390
|
+
case ProfileArchiveEntryType.KEY_VALUE: {
|
|
6391
|
+
invariant17(entry2.key instanceof Uint8Array, "Invalid key type", {
|
|
6392
|
+
F: __dxlog_file23,
|
|
6393
|
+
L: 86,
|
|
6394
|
+
S: void 0,
|
|
6395
|
+
A: [
|
|
6396
|
+
"entry.key instanceof Uint8Array",
|
|
6397
|
+
"'Invalid key type'"
|
|
6398
|
+
]
|
|
6399
|
+
});
|
|
6400
|
+
invariant17(entry2.value instanceof Uint8Array, "Invalid value type", {
|
|
6401
|
+
F: __dxlog_file23,
|
|
6402
|
+
L: 87,
|
|
6403
|
+
S: void 0,
|
|
6404
|
+
A: [
|
|
6405
|
+
"entry.value instanceof Uint8Array",
|
|
6406
|
+
"'Invalid value type'"
|
|
6407
|
+
]
|
|
6408
|
+
});
|
|
6409
|
+
batch.put(entry2.key, entry2.value, {
|
|
6410
|
+
keyEncoding: "binary",
|
|
6411
|
+
valueEncoding: "binary"
|
|
6412
|
+
});
|
|
6413
|
+
break;
|
|
6414
|
+
}
|
|
6415
|
+
default:
|
|
6416
|
+
throw new Error(`Invalid entry type: ${entry2.type}`);
|
|
6417
|
+
}
|
|
6418
|
+
}
|
|
6419
|
+
await batch.write();
|
|
6420
|
+
};
|
|
6421
|
+
|
|
5975
6422
|
// packages/sdk/client-services/src/packlets/services/service-host.ts
|
|
5976
6423
|
import { Event as Event9, synchronized as synchronized3 } from "@dxos/async";
|
|
5977
6424
|
import { clientServiceBundle } from "@dxos/client-protocol";
|
|
5978
6425
|
import { Context as Context11 } from "@dxos/context";
|
|
5979
|
-
import { invariant as
|
|
5980
|
-
import { PublicKey as
|
|
5981
|
-
import { log as
|
|
6426
|
+
import { invariant as invariant19 } from "@dxos/invariant";
|
|
6427
|
+
import { PublicKey as PublicKey17 } from "@dxos/keys";
|
|
6428
|
+
import { log as log22 } from "@dxos/log";
|
|
5982
6429
|
import { WebsocketSignalManager } from "@dxos/messaging";
|
|
5983
6430
|
import { SwarmNetworkManager, createSimplePeerTransportFactory } from "@dxos/network-manager";
|
|
5984
6431
|
import { trace as trace10 } from "@dxos/protocols";
|
|
@@ -5989,9 +6436,9 @@ import { WebsocketRpcClient } from "@dxos/websocket-rpc";
|
|
|
5989
6436
|
// packages/sdk/client-services/src/packlets/devices/devices-service.ts
|
|
5990
6437
|
import { EventSubscriptions as EventSubscriptions3 } from "@dxos/async";
|
|
5991
6438
|
import { Stream as Stream11 } from "@dxos/codec-protobuf";
|
|
5992
|
-
import { invariant as
|
|
6439
|
+
import { invariant as invariant18 } from "@dxos/invariant";
|
|
5993
6440
|
import { Device as Device2, DeviceKind as DeviceKind2 } from "@dxos/protocols/proto/dxos/client/services";
|
|
5994
|
-
var
|
|
6441
|
+
var __dxlog_file24 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/devices/devices-service.ts";
|
|
5995
6442
|
var DevicesServiceImpl = class {
|
|
5996
6443
|
constructor(_identityManager) {
|
|
5997
6444
|
this._identityManager = _identityManager;
|
|
@@ -6008,8 +6455,8 @@ var DevicesServiceImpl = class {
|
|
|
6008
6455
|
devices: []
|
|
6009
6456
|
});
|
|
6010
6457
|
} else {
|
|
6011
|
-
|
|
6012
|
-
F:
|
|
6458
|
+
invariant18(this._identityManager.identity?.presence, "presence not present", {
|
|
6459
|
+
F: __dxlog_file24,
|
|
6013
6460
|
L: 32,
|
|
6014
6461
|
S: this,
|
|
6015
6462
|
A: [
|
|
@@ -6115,28 +6562,111 @@ var findConfigs = () => {
|
|
|
6115
6562
|
return configs.map((r) => r.instance.deref()).filter(nonNullable);
|
|
6116
6563
|
};
|
|
6117
6564
|
|
|
6118
|
-
// packages/sdk/client-services/src/packlets/
|
|
6119
|
-
import {
|
|
6565
|
+
// packages/sdk/client-services/src/packlets/identity/contacts-service.ts
|
|
6566
|
+
import { EventSubscriptions as EventSubscriptions4, scheduleTask as scheduleTask7, UpdateScheduler as UpdateScheduler2 } from "@dxos/async";
|
|
6120
6567
|
import { Stream as Stream12 } from "@dxos/codec-protobuf";
|
|
6121
6568
|
import { PublicKey as PublicKey15 } from "@dxos/keys";
|
|
6122
|
-
import {
|
|
6569
|
+
import { ComplexMap as ComplexMap4, ComplexSet as ComplexSet6 } from "@dxos/util";
|
|
6570
|
+
var ContactsServiceImpl = class {
|
|
6571
|
+
constructor(_identityManager, _spaceManager, _dataSpaceManagerProvider) {
|
|
6572
|
+
this._identityManager = _identityManager;
|
|
6573
|
+
this._spaceManager = _spaceManager;
|
|
6574
|
+
this._dataSpaceManagerProvider = _dataSpaceManagerProvider;
|
|
6575
|
+
}
|
|
6576
|
+
async getContacts() {
|
|
6577
|
+
const identity = this._identityManager.identity;
|
|
6578
|
+
if (identity == null) {
|
|
6579
|
+
return {
|
|
6580
|
+
contacts: []
|
|
6581
|
+
};
|
|
6582
|
+
}
|
|
6583
|
+
const contacts = [
|
|
6584
|
+
...this._spaceManager.spaces.values()
|
|
6585
|
+
].flatMap((s) => [
|
|
6586
|
+
...s.spaceState.members.values()
|
|
6587
|
+
].map((m) => [
|
|
6588
|
+
s.key,
|
|
6589
|
+
m
|
|
6590
|
+
])).reduce((acc, v) => {
|
|
6591
|
+
const [spaceKey, memberInfo] = v;
|
|
6592
|
+
if (memberInfo.key.equals(identity.identityKey)) {
|
|
6593
|
+
return acc;
|
|
6594
|
+
}
|
|
6595
|
+
const existing = acc.get(memberInfo.key);
|
|
6596
|
+
if (existing != null) {
|
|
6597
|
+
existing.profile ??= memberInfo.profile;
|
|
6598
|
+
existing.commonSpaces?.push(spaceKey);
|
|
6599
|
+
} else {
|
|
6600
|
+
acc.set(memberInfo.key, {
|
|
6601
|
+
identityKey: memberInfo.key,
|
|
6602
|
+
profile: memberInfo.profile,
|
|
6603
|
+
commonSpaces: [
|
|
6604
|
+
spaceKey
|
|
6605
|
+
]
|
|
6606
|
+
});
|
|
6607
|
+
}
|
|
6608
|
+
return acc;
|
|
6609
|
+
}, new ComplexMap4(PublicKey15.hash));
|
|
6610
|
+
return {
|
|
6611
|
+
contacts: [
|
|
6612
|
+
...contacts.values()
|
|
6613
|
+
]
|
|
6614
|
+
};
|
|
6615
|
+
}
|
|
6616
|
+
queryContacts() {
|
|
6617
|
+
const subscribedSpaceKeySet = new ComplexSet6(PublicKey15.hash);
|
|
6618
|
+
return new Stream12(({ next, ctx }) => {
|
|
6619
|
+
const pushUpdateTask = new UpdateScheduler2(ctx, async () => {
|
|
6620
|
+
const contacts = await this.getContacts();
|
|
6621
|
+
next(contacts);
|
|
6622
|
+
}, {
|
|
6623
|
+
maxFrequency: 2
|
|
6624
|
+
});
|
|
6625
|
+
scheduleTask7(ctx, async () => {
|
|
6626
|
+
const subscriptions = new EventSubscriptions4();
|
|
6627
|
+
ctx.onDispose(() => subscriptions.clear());
|
|
6628
|
+
const subscribeToSpaceAndUpdate = () => {
|
|
6629
|
+
const oldSetSize = subscribedSpaceKeySet.size;
|
|
6630
|
+
for (const space of this._spaceManager.spaces.values()) {
|
|
6631
|
+
if (!subscribedSpaceKeySet.has(space.key)) {
|
|
6632
|
+
subscriptions.add(space.stateUpdate.on(ctx, () => pushUpdateTask.trigger()));
|
|
6633
|
+
subscribedSpaceKeySet.add(space.key);
|
|
6634
|
+
}
|
|
6635
|
+
}
|
|
6636
|
+
if (oldSetSize !== subscribedSpaceKeySet.size) {
|
|
6637
|
+
pushUpdateTask.trigger();
|
|
6638
|
+
}
|
|
6639
|
+
};
|
|
6640
|
+
const unsubscribe = (await this._dataSpaceManagerProvider()).updated.on(ctx, subscribeToSpaceAndUpdate);
|
|
6641
|
+
ctx.onDispose(unsubscribe);
|
|
6642
|
+
subscribeToSpaceAndUpdate();
|
|
6643
|
+
});
|
|
6644
|
+
});
|
|
6645
|
+
}
|
|
6646
|
+
};
|
|
6647
|
+
|
|
6648
|
+
// packages/sdk/client-services/src/packlets/logging/logging-service.ts
|
|
6649
|
+
import { Event as Event8 } from "@dxos/async";
|
|
6650
|
+
import { Stream as Stream13 } from "@dxos/codec-protobuf";
|
|
6651
|
+
import { PublicKey as PublicKey16 } from "@dxos/keys";
|
|
6652
|
+
import { getContextFromEntry, log as log21 } from "@dxos/log";
|
|
6123
6653
|
import { QueryLogsRequest } from "@dxos/protocols/proto/dxos/client/services";
|
|
6124
6654
|
import { getDebugName, jsonify, numericalValues, tracer } from "@dxos/util";
|
|
6125
6655
|
var LoggingServiceImpl = class {
|
|
6126
6656
|
constructor() {
|
|
6127
6657
|
this._logs = new Event8();
|
|
6128
6658
|
this._started = Date.now();
|
|
6129
|
-
this._sessionId =
|
|
6659
|
+
this._sessionId = PublicKey16.random().toHex();
|
|
6130
6660
|
this._logProcessor = (_config, entry2) => {
|
|
6131
6661
|
this._logs.emit(entry2);
|
|
6132
6662
|
};
|
|
6133
6663
|
}
|
|
6134
6664
|
async open() {
|
|
6135
|
-
|
|
6665
|
+
log21.runtimeConfig.processors.push(this._logProcessor);
|
|
6136
6666
|
}
|
|
6137
6667
|
async close() {
|
|
6138
|
-
const index =
|
|
6139
|
-
|
|
6668
|
+
const index = log21.runtimeConfig.processors.findIndex((processor) => processor === this._logProcessor);
|
|
6669
|
+
log21.runtimeConfig.processors.splice(index, 1);
|
|
6140
6670
|
}
|
|
6141
6671
|
async controlMetrics({ reset, record }) {
|
|
6142
6672
|
if (reset) {
|
|
@@ -6162,7 +6692,7 @@ var LoggingServiceImpl = class {
|
|
|
6162
6692
|
stats: numericalValues(events, "duration")
|
|
6163
6693
|
};
|
|
6164
6694
|
};
|
|
6165
|
-
return new
|
|
6695
|
+
return new Stream13(({ next }) => {
|
|
6166
6696
|
const update = () => {
|
|
6167
6697
|
const metrics = {
|
|
6168
6698
|
timestamp: /* @__PURE__ */ new Date(),
|
|
@@ -6184,7 +6714,7 @@ var LoggingServiceImpl = class {
|
|
|
6184
6714
|
});
|
|
6185
6715
|
}
|
|
6186
6716
|
queryLogs(request) {
|
|
6187
|
-
return new
|
|
6717
|
+
return new Stream13(({ ctx, next }) => {
|
|
6188
6718
|
const handler = (entry2) => {
|
|
6189
6719
|
if (LOG_PROCESSING > 0) {
|
|
6190
6720
|
return;
|
|
@@ -6240,14 +6770,14 @@ var shouldLog = (entry2, request) => {
|
|
|
6240
6770
|
var LOG_PROCESSING = 0;
|
|
6241
6771
|
|
|
6242
6772
|
// packages/sdk/client-services/src/packlets/network/network-service.ts
|
|
6243
|
-
import { Stream as
|
|
6773
|
+
import { Stream as Stream14 } from "@dxos/codec-protobuf";
|
|
6244
6774
|
var NetworkServiceImpl = class {
|
|
6245
6775
|
constructor(networkManager, signalManager) {
|
|
6246
6776
|
this.networkManager = networkManager;
|
|
6247
6777
|
this.signalManager = signalManager;
|
|
6248
6778
|
}
|
|
6249
6779
|
queryStatus() {
|
|
6250
|
-
return new
|
|
6780
|
+
return new Stream14(({ next }) => {
|
|
6251
6781
|
const update = () => {
|
|
6252
6782
|
next({
|
|
6253
6783
|
swarm: this.networkManager.connectionState,
|
|
@@ -6273,7 +6803,7 @@ var NetworkServiceImpl = class {
|
|
|
6273
6803
|
};
|
|
6274
6804
|
|
|
6275
6805
|
// packages/sdk/client-services/src/packlets/system/system-service.ts
|
|
6276
|
-
import { Stream as
|
|
6806
|
+
import { Stream as Stream15 } from "@dxos/codec-protobuf";
|
|
6277
6807
|
import { GetDiagnosticsRequest as GetDiagnosticsRequest2 } from "@dxos/protocols/proto/dxos/client/services";
|
|
6278
6808
|
import { jsonKeyReplacer as jsonKeyReplacer2 } from "@dxos/util";
|
|
6279
6809
|
var SystemServiceImpl = class {
|
|
@@ -6309,7 +6839,7 @@ var SystemServiceImpl = class {
|
|
|
6309
6839
|
}
|
|
6310
6840
|
// TODO(burdon): Standardize interval option in stream request?
|
|
6311
6841
|
queryStatus({ interval = 3e3 } = {}) {
|
|
6312
|
-
return new
|
|
6842
|
+
return new Stream15(({ next }) => {
|
|
6313
6843
|
const update = () => {
|
|
6314
6844
|
next({
|
|
6315
6845
|
status: this._getCurrentStatus()
|
|
@@ -6340,7 +6870,7 @@ function _ts_decorate8(decorators, target, key, desc) {
|
|
|
6340
6870
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6341
6871
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6342
6872
|
}
|
|
6343
|
-
var
|
|
6873
|
+
var __dxlog_file25 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-host.ts";
|
|
6344
6874
|
var ClientServicesHost = class {
|
|
6345
6875
|
constructor({
|
|
6346
6876
|
config,
|
|
@@ -6373,7 +6903,10 @@ var ClientServicesHost = class {
|
|
|
6373
6903
|
lockKey,
|
|
6374
6904
|
onAcquire: () => {
|
|
6375
6905
|
if (!this._opening) {
|
|
6376
|
-
void this.open(new Context11(
|
|
6906
|
+
void this.open(new Context11(void 0, {
|
|
6907
|
+
F: __dxlog_file25,
|
|
6908
|
+
L: 121
|
|
6909
|
+
}));
|
|
6377
6910
|
}
|
|
6378
6911
|
},
|
|
6379
6912
|
onRelease: () => this.close()
|
|
@@ -6428,25 +6961,25 @@ var ClientServicesHost = class {
|
|
|
6428
6961
|
* Can only be called once.
|
|
6429
6962
|
*/
|
|
6430
6963
|
initialize({ config, ...options }) {
|
|
6431
|
-
|
|
6432
|
-
F:
|
|
6433
|
-
L:
|
|
6964
|
+
invariant19(!this._open, "service host is open", {
|
|
6965
|
+
F: __dxlog_file25,
|
|
6966
|
+
L: 187,
|
|
6434
6967
|
S: this,
|
|
6435
6968
|
A: [
|
|
6436
6969
|
"!this._open",
|
|
6437
6970
|
"'service host is open'"
|
|
6438
6971
|
]
|
|
6439
6972
|
});
|
|
6440
|
-
|
|
6441
|
-
F:
|
|
6442
|
-
L:
|
|
6973
|
+
log22("initializing...", void 0, {
|
|
6974
|
+
F: __dxlog_file25,
|
|
6975
|
+
L: 188,
|
|
6443
6976
|
S: this,
|
|
6444
6977
|
C: (f, a) => f(...a)
|
|
6445
6978
|
});
|
|
6446
6979
|
if (config) {
|
|
6447
|
-
|
|
6448
|
-
F:
|
|
6449
|
-
L:
|
|
6980
|
+
invariant19(!this._config, "config already set", {
|
|
6981
|
+
F: __dxlog_file25,
|
|
6982
|
+
L: 191,
|
|
6450
6983
|
S: this,
|
|
6451
6984
|
A: [
|
|
6452
6985
|
"!this._config",
|
|
@@ -6459,9 +6992,9 @@ var ClientServicesHost = class {
|
|
|
6459
6992
|
}
|
|
6460
6993
|
}
|
|
6461
6994
|
if (!options.signalManager) {
|
|
6462
|
-
|
|
6463
|
-
F:
|
|
6464
|
-
L:
|
|
6995
|
+
log22.warn("running signaling without telemetry metadata.", void 0, {
|
|
6996
|
+
F: __dxlog_file25,
|
|
6997
|
+
L: 199,
|
|
6465
6998
|
S: this,
|
|
6466
6999
|
C: (f, a) => f(...a)
|
|
6467
7000
|
});
|
|
@@ -6470,9 +7003,9 @@ var ClientServicesHost = class {
|
|
|
6470
7003
|
iceServers: this._config?.get("runtime.services.ice")
|
|
6471
7004
|
}), signalManager = new WebsocketSignalManager(this._config?.get("runtime.services.signaling") ?? []) } = options;
|
|
6472
7005
|
this._signalManager = signalManager;
|
|
6473
|
-
|
|
6474
|
-
F:
|
|
6475
|
-
L:
|
|
7006
|
+
invariant19(!this._networkManager, "network manager already set", {
|
|
7007
|
+
F: __dxlog_file25,
|
|
7008
|
+
L: 210,
|
|
6476
7009
|
S: this,
|
|
6477
7010
|
A: [
|
|
6478
7011
|
"!this._networkManager",
|
|
@@ -6484,9 +7017,9 @@ var ClientServicesHost = class {
|
|
|
6484
7017
|
transportFactory,
|
|
6485
7018
|
signalManager
|
|
6486
7019
|
});
|
|
6487
|
-
|
|
6488
|
-
F:
|
|
6489
|
-
L:
|
|
7020
|
+
log22("initialized", void 0, {
|
|
7021
|
+
F: __dxlog_file25,
|
|
7022
|
+
L: 217,
|
|
6490
7023
|
S: this,
|
|
6491
7024
|
C: (f, a) => f(...a)
|
|
6492
7025
|
});
|
|
@@ -6495,45 +7028,45 @@ var ClientServicesHost = class {
|
|
|
6495
7028
|
if (this._open) {
|
|
6496
7029
|
return;
|
|
6497
7030
|
}
|
|
6498
|
-
const traceId =
|
|
6499
|
-
|
|
7031
|
+
const traceId = PublicKey17.random().toHex();
|
|
7032
|
+
log22.trace("dxos.client-services.host.open", trace10.begin({
|
|
6500
7033
|
id: traceId
|
|
6501
7034
|
}), {
|
|
6502
|
-
F:
|
|
6503
|
-
L:
|
|
7035
|
+
F: __dxlog_file25,
|
|
7036
|
+
L: 228,
|
|
6504
7037
|
S: this,
|
|
6505
7038
|
C: (f, a) => f(...a)
|
|
6506
7039
|
});
|
|
6507
|
-
|
|
6508
|
-
F:
|
|
6509
|
-
L:
|
|
7040
|
+
invariant19(this._config, "config not set", {
|
|
7041
|
+
F: __dxlog_file25,
|
|
7042
|
+
L: 230,
|
|
6510
7043
|
S: this,
|
|
6511
7044
|
A: [
|
|
6512
7045
|
"this._config",
|
|
6513
7046
|
"'config not set'"
|
|
6514
7047
|
]
|
|
6515
7048
|
});
|
|
6516
|
-
|
|
6517
|
-
F:
|
|
6518
|
-
L:
|
|
7049
|
+
invariant19(this._storage, "storage not set", {
|
|
7050
|
+
F: __dxlog_file25,
|
|
7051
|
+
L: 231,
|
|
6519
7052
|
S: this,
|
|
6520
7053
|
A: [
|
|
6521
7054
|
"this._storage",
|
|
6522
7055
|
"'storage not set'"
|
|
6523
7056
|
]
|
|
6524
7057
|
});
|
|
6525
|
-
|
|
6526
|
-
F:
|
|
6527
|
-
L:
|
|
7058
|
+
invariant19(this._signalManager, "signal manager not set", {
|
|
7059
|
+
F: __dxlog_file25,
|
|
7060
|
+
L: 232,
|
|
6528
7061
|
S: this,
|
|
6529
7062
|
A: [
|
|
6530
7063
|
"this._signalManager",
|
|
6531
7064
|
"'signal manager not set'"
|
|
6532
7065
|
]
|
|
6533
7066
|
});
|
|
6534
|
-
|
|
6535
|
-
F:
|
|
6536
|
-
L:
|
|
7067
|
+
invariant19(this._networkManager, "network manager not set", {
|
|
7068
|
+
F: __dxlog_file25,
|
|
7069
|
+
L: 233,
|
|
6537
7070
|
S: this,
|
|
6538
7071
|
A: [
|
|
6539
7072
|
"this._networkManager",
|
|
@@ -6541,11 +7074,11 @@ var ClientServicesHost = class {
|
|
|
6541
7074
|
]
|
|
6542
7075
|
});
|
|
6543
7076
|
this._opening = true;
|
|
6544
|
-
|
|
7077
|
+
log22("opening...", {
|
|
6545
7078
|
lockKey: this._resourceLock?.lockKey
|
|
6546
7079
|
}, {
|
|
6547
|
-
F:
|
|
6548
|
-
L:
|
|
7080
|
+
F: __dxlog_file25,
|
|
7081
|
+
L: 236,
|
|
6549
7082
|
S: this,
|
|
6550
7083
|
C: (f, a) => f(...a)
|
|
6551
7084
|
});
|
|
@@ -6556,16 +7089,18 @@ var ClientServicesHost = class {
|
|
|
6556
7089
|
await this._level.open();
|
|
6557
7090
|
await this._loggingService.open();
|
|
6558
7091
|
this._serviceContext = new ServiceContext(this._storage, this._level, this._networkManager, this._signalManager, this._runtimeParams);
|
|
7092
|
+
const dataSpaceManagerProvider = async () => {
|
|
7093
|
+
await this._serviceContext.initialized.wait();
|
|
7094
|
+
return this._serviceContext.dataSpaceManager;
|
|
7095
|
+
};
|
|
6559
7096
|
const identityService = new IdentityServiceImpl(this._serviceContext.identityManager, this._serviceContext.keyring, () => this._serviceContext.dataSpaceManager, (params) => this._createIdentity(params), (profile) => this._serviceContext.broadcastProfileUpdate(profile));
|
|
6560
7097
|
this._serviceRegistry.setServices({
|
|
6561
7098
|
SystemService: this._systemService,
|
|
6562
7099
|
IdentityService: identityService,
|
|
7100
|
+
ContactsService: new ContactsServiceImpl(this._serviceContext.identityManager, this._serviceContext.spaceManager, dataSpaceManagerProvider),
|
|
6563
7101
|
InvitationsService: new InvitationsServiceImpl(this._serviceContext.invitationsManager),
|
|
6564
7102
|
DevicesService: new DevicesServiceImpl(this._serviceContext.identityManager),
|
|
6565
|
-
SpacesService: new SpacesServiceImpl(this._serviceContext.identityManager, this._serviceContext.spaceManager,
|
|
6566
|
-
await this._serviceContext.initialized.wait();
|
|
6567
|
-
return this._serviceContext.dataSpaceManager;
|
|
6568
|
-
}),
|
|
7103
|
+
SpacesService: new SpacesServiceImpl(this._serviceContext.identityManager, this._serviceContext.spaceManager, dataSpaceManagerProvider),
|
|
6569
7104
|
DataService: this._serviceContext.echoHost.dataService,
|
|
6570
7105
|
QueryService: this._serviceContext.echoHost.queryService,
|
|
6571
7106
|
NetworkService: new NetworkServiceImpl(this._serviceContext.networkManager, this._serviceContext.signalManager),
|
|
@@ -6595,19 +7130,19 @@ var ClientServicesHost = class {
|
|
|
6595
7130
|
this._open = true;
|
|
6596
7131
|
this._statusUpdate.emit();
|
|
6597
7132
|
const deviceKey = this._serviceContext.identityManager.identity?.deviceKey;
|
|
6598
|
-
|
|
7133
|
+
log22("opened", {
|
|
6599
7134
|
deviceKey
|
|
6600
7135
|
}, {
|
|
6601
|
-
F:
|
|
6602
|
-
L:
|
|
7136
|
+
F: __dxlog_file25,
|
|
7137
|
+
L: 322,
|
|
6603
7138
|
S: this,
|
|
6604
7139
|
C: (f, a) => f(...a)
|
|
6605
7140
|
});
|
|
6606
|
-
|
|
7141
|
+
log22.trace("dxos.client-services.host.open", trace10.end({
|
|
6607
7142
|
id: traceId
|
|
6608
7143
|
}), {
|
|
6609
|
-
F:
|
|
6610
|
-
L:
|
|
7144
|
+
F: __dxlog_file25,
|
|
7145
|
+
L: 323,
|
|
6611
7146
|
S: this,
|
|
6612
7147
|
C: (f, a) => f(...a)
|
|
6613
7148
|
});
|
|
@@ -6617,11 +7152,11 @@ var ClientServicesHost = class {
|
|
|
6617
7152
|
return;
|
|
6618
7153
|
}
|
|
6619
7154
|
const deviceKey = this._serviceContext.identityManager.identity?.deviceKey;
|
|
6620
|
-
|
|
7155
|
+
log22("closing...", {
|
|
6621
7156
|
deviceKey
|
|
6622
7157
|
}, {
|
|
6623
|
-
F:
|
|
6624
|
-
L:
|
|
7158
|
+
F: __dxlog_file25,
|
|
7159
|
+
L: 334,
|
|
6625
7160
|
S: this,
|
|
6626
7161
|
C: (f, a) => f(...a)
|
|
6627
7162
|
});
|
|
@@ -6635,44 +7170,44 @@ var ClientServicesHost = class {
|
|
|
6635
7170
|
await this._level?.close();
|
|
6636
7171
|
this._open = false;
|
|
6637
7172
|
this._statusUpdate.emit();
|
|
6638
|
-
|
|
7173
|
+
log22("closed", {
|
|
6639
7174
|
deviceKey
|
|
6640
7175
|
}, {
|
|
6641
|
-
F:
|
|
6642
|
-
L:
|
|
7176
|
+
F: __dxlog_file25,
|
|
7177
|
+
L: 343,
|
|
6643
7178
|
S: this,
|
|
6644
7179
|
C: (f, a) => f(...a)
|
|
6645
7180
|
});
|
|
6646
7181
|
}
|
|
6647
7182
|
async reset() {
|
|
6648
|
-
const traceId =
|
|
6649
|
-
|
|
7183
|
+
const traceId = PublicKey17.random().toHex();
|
|
7184
|
+
log22.trace("dxos.sdk.client-services-host.reset", trace10.begin({
|
|
6650
7185
|
id: traceId
|
|
6651
7186
|
}), {
|
|
6652
|
-
F:
|
|
6653
|
-
L:
|
|
7187
|
+
F: __dxlog_file25,
|
|
7188
|
+
L: 348,
|
|
6654
7189
|
S: this,
|
|
6655
7190
|
C: (f, a) => f(...a)
|
|
6656
7191
|
});
|
|
6657
|
-
|
|
6658
|
-
F:
|
|
6659
|
-
L:
|
|
7192
|
+
log22.info("resetting...", void 0, {
|
|
7193
|
+
F: __dxlog_file25,
|
|
7194
|
+
L: 350,
|
|
6660
7195
|
S: this,
|
|
6661
7196
|
C: (f, a) => f(...a)
|
|
6662
7197
|
});
|
|
6663
7198
|
await this._serviceContext?.close();
|
|
6664
7199
|
await this._storage.reset();
|
|
6665
|
-
|
|
6666
|
-
F:
|
|
6667
|
-
L:
|
|
7200
|
+
log22.info("reset", void 0, {
|
|
7201
|
+
F: __dxlog_file25,
|
|
7202
|
+
L: 353,
|
|
6668
7203
|
S: this,
|
|
6669
7204
|
C: (f, a) => f(...a)
|
|
6670
7205
|
});
|
|
6671
|
-
|
|
7206
|
+
log22.trace("dxos.sdk.client-services-host.reset", trace10.end({
|
|
6672
7207
|
id: traceId
|
|
6673
7208
|
}), {
|
|
6674
|
-
F:
|
|
6675
|
-
L:
|
|
7209
|
+
F: __dxlog_file25,
|
|
7210
|
+
L: 354,
|
|
6676
7211
|
S: this,
|
|
6677
7212
|
C: (f, a) => f(...a)
|
|
6678
7213
|
});
|
|
@@ -6730,7 +7265,6 @@ export {
|
|
|
6730
7265
|
SpaceInvitationProtocol,
|
|
6731
7266
|
InvitationsManager,
|
|
6732
7267
|
DataSpace,
|
|
6733
|
-
findPropertiesObject,
|
|
6734
7268
|
DataSpaceManager,
|
|
6735
7269
|
SpacesServiceImpl,
|
|
6736
7270
|
ServiceContext,
|
|
@@ -6739,8 +7273,12 @@ export {
|
|
|
6739
7273
|
isLocked,
|
|
6740
7274
|
createStorageObjects,
|
|
6741
7275
|
createLevel,
|
|
7276
|
+
encodeProfileArchive,
|
|
7277
|
+
decodeProfileArchive,
|
|
7278
|
+
exportProfileData,
|
|
7279
|
+
importProfileData,
|
|
6742
7280
|
ClientServicesHost,
|
|
6743
7281
|
ClientServicesProviderResource,
|
|
6744
7282
|
DiagnosticsCollector
|
|
6745
7283
|
};
|
|
6746
|
-
//# sourceMappingURL=chunk-
|
|
7284
|
+
//# sourceMappingURL=chunk-FYAITMX3.mjs.map
|