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