@dxos/client-services 0.3.11-main.a8d7a97 → 0.3.11-main.afa73e0
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-6DHQ2QXZ.mjs → chunk-YD2GBB3W.mjs} +199 -103
- package/dist/lib/browser/chunk-YD2GBB3W.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +1 -1
- 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 +4 -11
- package/dist/lib/browser/packlets/testing/index.mjs.map +3 -3
- package/dist/lib/node/{chunk-O3RVCYRH.cjs → chunk-S5IK5PCE.cjs} +282 -186
- package/dist/lib/node/chunk-S5IK5PCE.cjs.map +7 -0
- package/dist/lib/node/index.cjs +37 -37
- 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 +11 -18
- package/dist/lib/node/packlets/testing/index.cjs.map +3 -3
- package/dist/types/src/packlets/identity/identity-service.d.ts +3 -3
- package/dist/types/src/packlets/identity/identity-service.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/device-invitation-protocol.d.ts +2 -0
- package/dist/types/src/packlets/invitations/device-invitation-protocol.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/invitation-protocol.d.ts +28 -3
- package/dist/types/src/packlets/invitations/invitation-protocol.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 +2 -0
- package/dist/types/src/packlets/invitations/space-invitation-protocol.d.ts.map +1 -1
- package/dist/types/src/packlets/services/diagnostics.d.ts +4 -0
- package/dist/types/src/packlets/services/diagnostics.d.ts.map +1 -1
- package/dist/types/src/packlets/services/service-host.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/automerge-space-state.d.ts +2 -0
- package/dist/types/src/packlets/spaces/automerge-space-state.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/data-space-manager.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/data-space.d.ts +1 -0
- package/dist/types/src/packlets/spaces/data-space.d.ts.map +1 -1
- package/dist/types/src/packlets/testing/invitation-utils.d.ts.map +1 -1
- package/dist/types/src/version.d.ts +1 -1
- package/package.json +35 -35
- package/src/packlets/identity/identity-manager.ts +1 -1
- package/src/packlets/identity/identity-service.test.ts +1 -1
- package/src/packlets/identity/identity-service.ts +6 -3
- package/src/packlets/invitations/device-invitation-protocol.test.ts +14 -0
- package/src/packlets/invitations/device-invitation-protocol.ts +14 -0
- package/src/packlets/invitations/invitation-protocol.ts +44 -6
- package/src/packlets/invitations/invitations-handler.ts +19 -17
- package/src/packlets/invitations/space-invitation-protocol.test.ts +28 -0
- package/src/packlets/invitations/space-invitation-protocol.ts +11 -0
- package/src/packlets/services/diagnostics.ts +18 -0
- package/src/packlets/services/service-host.ts +27 -12
- package/src/packlets/spaces/automerge-space-state.ts +4 -0
- package/src/packlets/spaces/data-space-manager.ts +5 -1
- package/src/packlets/spaces/data-space.ts +21 -1
- package/src/packlets/spaces/spaces-service.ts +1 -1
- package/src/packlets/testing/invitation-utils.ts +2 -10
- package/src/version.ts +1 -1
- package/dist/lib/browser/chunk-6DHQ2QXZ.mjs.map +0 -7
- package/dist/lib/node/chunk-O3RVCYRH.cjs.map +0 -7
|
@@ -26,8 +26,8 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
26
26
|
mod
|
|
27
27
|
));
|
|
28
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
var
|
|
30
|
-
__export(
|
|
29
|
+
var chunk_S5IK5PCE_exports = {};
|
|
30
|
+
__export(chunk_S5IK5PCE_exports, {
|
|
31
31
|
ClientRpcServer: () => ClientRpcServer,
|
|
32
32
|
ClientServicesHost: () => ClientServicesHost,
|
|
33
33
|
DataSpace: () => DataSpace,
|
|
@@ -60,7 +60,7 @@ __export(chunk_O3RVCYRH_exports, {
|
|
|
60
60
|
subscribeToSpaces: () => subscribeToSpaces,
|
|
61
61
|
subscribeToSwarmInfo: () => subscribeToSwarmInfo
|
|
62
62
|
});
|
|
63
|
-
module.exports = __toCommonJS(
|
|
63
|
+
module.exports = __toCommonJS(chunk_S5IK5PCE_exports);
|
|
64
64
|
var import_async = require("@dxos/async");
|
|
65
65
|
var import_codec_protobuf = require("@dxos/codec-protobuf");
|
|
66
66
|
var import_feed_store = require("@dxos/feed-store");
|
|
@@ -108,6 +108,7 @@ var import_credentials6 = require("@dxos/credentials");
|
|
|
108
108
|
var import_debug2 = require("@dxos/debug");
|
|
109
109
|
var import_invariant3 = require("@dxos/invariant");
|
|
110
110
|
var import_invariant4 = require("@dxos/invariant");
|
|
111
|
+
var import_protocols3 = require("@dxos/protocols");
|
|
111
112
|
var import_services = require("@dxos/protocols/proto/dxos/client/services");
|
|
112
113
|
var import_async7 = require("@dxos/async");
|
|
113
114
|
var import_client_protocol2 = require("@dxos/client-protocol");
|
|
@@ -117,7 +118,7 @@ var import_invariant5 = require("@dxos/invariant");
|
|
|
117
118
|
var import_keys5 = require("@dxos/keys");
|
|
118
119
|
var import_log4 = require("@dxos/log");
|
|
119
120
|
var import_network_manager = require("@dxos/network-manager");
|
|
120
|
-
var
|
|
121
|
+
var import_protocols4 = require("@dxos/protocols");
|
|
121
122
|
var import_services2 = require("@dxos/protocols/proto/dxos/client/services");
|
|
122
123
|
var import_invitations = require("@dxos/protocols/proto/dxos/halo/invitations");
|
|
123
124
|
var import_async8 = require("@dxos/async");
|
|
@@ -125,7 +126,7 @@ var import_context5 = require("@dxos/context");
|
|
|
125
126
|
var import_invariant6 = require("@dxos/invariant");
|
|
126
127
|
var import_keys6 = require("@dxos/keys");
|
|
127
128
|
var import_log5 = require("@dxos/log");
|
|
128
|
-
var
|
|
129
|
+
var import_protocols5 = require("@dxos/protocols");
|
|
129
130
|
var import_services3 = require("@dxos/protocols/proto/dxos/client/services");
|
|
130
131
|
var import_invitations2 = require("@dxos/protocols/proto/dxos/halo/invitations");
|
|
131
132
|
var import_teleport = require("@dxos/teleport");
|
|
@@ -138,6 +139,7 @@ var import_credentials8 = require("@dxos/credentials");
|
|
|
138
139
|
var import_feed_store3 = require("@dxos/feed-store");
|
|
139
140
|
var import_invariant8 = require("@dxos/invariant");
|
|
140
141
|
var import_log7 = require("@dxos/log");
|
|
142
|
+
var import_protocols6 = require("@dxos/protocols");
|
|
141
143
|
var import_services5 = require("@dxos/protocols/proto/dxos/client/services");
|
|
142
144
|
var import_codec_protobuf9 = require("@dxos/codec-protobuf");
|
|
143
145
|
var import_debug3 = require("@dxos/debug");
|
|
@@ -149,16 +151,17 @@ var import_document_model = require("@dxos/document-model");
|
|
|
149
151
|
var import_echo_db = require("@dxos/echo-db");
|
|
150
152
|
var import_invariant9 = require("@dxos/invariant");
|
|
151
153
|
var import_log8 = require("@dxos/log");
|
|
152
|
-
var
|
|
154
|
+
var import_protocols7 = require("@dxos/protocols");
|
|
153
155
|
var import_services6 = require("@dxos/protocols/proto/dxos/client/services");
|
|
154
156
|
var import_async10 = require("@dxos/async");
|
|
155
157
|
var import_client_protocol3 = require("@dxos/client-protocol");
|
|
156
158
|
var import_context6 = require("@dxos/context");
|
|
157
159
|
var import_debug4 = require("@dxos/debug");
|
|
158
160
|
var import_echo_pipeline = require("@dxos/echo-pipeline");
|
|
161
|
+
var import_invariant10 = require("@dxos/invariant");
|
|
159
162
|
var import_keys7 = require("@dxos/keys");
|
|
160
163
|
var import_log9 = require("@dxos/log");
|
|
161
|
-
var
|
|
164
|
+
var import_protocols8 = require("@dxos/protocols");
|
|
162
165
|
var import_services7 = require("@dxos/protocols/proto/dxos/client/services");
|
|
163
166
|
var import_credentials10 = require("@dxos/protocols/proto/dxos/halo/credentials");
|
|
164
167
|
var import_timeframe2 = require("@dxos/timeframe");
|
|
@@ -167,19 +170,19 @@ var import_util4 = require("@dxos/util");
|
|
|
167
170
|
var import_credentials11 = require("@dxos/credentials");
|
|
168
171
|
var import_async11 = require("@dxos/async");
|
|
169
172
|
var import_context7 = require("@dxos/context");
|
|
170
|
-
var
|
|
173
|
+
var import_invariant11 = require("@dxos/invariant");
|
|
171
174
|
var import_keys8 = require("@dxos/keys");
|
|
172
175
|
var import_log10 = require("@dxos/log");
|
|
173
|
-
var
|
|
176
|
+
var import_protocols9 = require("@dxos/protocols");
|
|
174
177
|
var import_teleport2 = require("@dxos/teleport");
|
|
175
178
|
var import_util5 = require("@dxos/util");
|
|
176
179
|
var import_async12 = require("@dxos/async");
|
|
177
180
|
var import_context8 = require("@dxos/context");
|
|
178
181
|
var import_credentials12 = require("@dxos/credentials");
|
|
179
|
-
var
|
|
182
|
+
var import_invariant12 = require("@dxos/invariant");
|
|
180
183
|
var import_keys9 = require("@dxos/keys");
|
|
181
184
|
var import_log11 = require("@dxos/log");
|
|
182
|
-
var
|
|
185
|
+
var import_protocols10 = require("@dxos/protocols");
|
|
183
186
|
var import_services8 = require("@dxos/protocols/proto/dxos/client/services");
|
|
184
187
|
var import_teleport_extension_gossip = require("@dxos/teleport-extension-gossip");
|
|
185
188
|
var import_util6 = require("@dxos/util");
|
|
@@ -190,9 +193,9 @@ var import_timeframe3 = require("@dxos/timeframe");
|
|
|
190
193
|
var import_async13 = require("@dxos/async");
|
|
191
194
|
var import_codec_protobuf11 = require("@dxos/codec-protobuf");
|
|
192
195
|
var import_debug6 = require("@dxos/debug");
|
|
193
|
-
var
|
|
196
|
+
var import_invariant13 = require("@dxos/invariant");
|
|
194
197
|
var import_log12 = require("@dxos/log");
|
|
195
|
-
var
|
|
198
|
+
var import_protocols11 = require("@dxos/protocols");
|
|
196
199
|
var import_services9 = require("@dxos/protocols/proto/dxos/client/services");
|
|
197
200
|
var import_async14 = require("@dxos/async");
|
|
198
201
|
var import_context9 = require("@dxos/context");
|
|
@@ -200,20 +203,20 @@ var import_credentials15 = require("@dxos/credentials");
|
|
|
200
203
|
var import_debug7 = require("@dxos/debug");
|
|
201
204
|
var import_echo_pipeline2 = require("@dxos/echo-pipeline");
|
|
202
205
|
var import_feed_store4 = require("@dxos/feed-store");
|
|
203
|
-
var
|
|
206
|
+
var import_invariant14 = require("@dxos/invariant");
|
|
204
207
|
var import_keyring = require("@dxos/keyring");
|
|
205
208
|
var import_keys10 = require("@dxos/keys");
|
|
206
209
|
var import_log13 = require("@dxos/log");
|
|
207
|
-
var
|
|
210
|
+
var import_protocols12 = require("@dxos/protocols");
|
|
208
211
|
var import_services10 = require("@dxos/protocols/proto/dxos/client/services");
|
|
209
212
|
var import_teleport_extension_object_sync = require("@dxos/teleport-extension-object-sync");
|
|
210
213
|
var import_tracing5 = require("@dxos/tracing");
|
|
211
214
|
var import_util7 = require("@dxos/util");
|
|
212
|
-
var
|
|
215
|
+
var import_invariant15 = require("@dxos/invariant");
|
|
213
216
|
var import_lock_file = require("@dxos/lock-file");
|
|
214
217
|
var import_log14 = require("@dxos/log");
|
|
215
218
|
var import_client_protocol4 = require("@dxos/client-protocol");
|
|
216
|
-
var
|
|
219
|
+
var import_protocols13 = require("@dxos/protocols");
|
|
217
220
|
var import_config = require("@dxos/protocols/proto/dxos/config");
|
|
218
221
|
var import_random_access_storage = require("@dxos/random-access-storage");
|
|
219
222
|
var import_util8 = require("@dxos/util");
|
|
@@ -223,13 +226,13 @@ var import_context10 = require("@dxos/context");
|
|
|
223
226
|
var import_document_model2 = require("@dxos/document-model");
|
|
224
227
|
var import_echo_pipeline3 = require("@dxos/echo-pipeline");
|
|
225
228
|
var import_echo_schema = require("@dxos/echo-schema");
|
|
226
|
-
var
|
|
229
|
+
var import_invariant16 = require("@dxos/invariant");
|
|
227
230
|
var import_keys11 = require("@dxos/keys");
|
|
228
231
|
var import_log15 = require("@dxos/log");
|
|
229
232
|
var import_messaging = require("@dxos/messaging");
|
|
230
233
|
var import_model_factory = require("@dxos/model-factory");
|
|
231
234
|
var import_network_manager2 = require("@dxos/network-manager");
|
|
232
|
-
var
|
|
235
|
+
var import_protocols14 = require("@dxos/protocols");
|
|
233
236
|
var import_services11 = require("@dxos/protocols/proto/dxos/client/services");
|
|
234
237
|
var import_text_model = require("@dxos/text-model");
|
|
235
238
|
var import_tracing6 = require("@dxos/tracing");
|
|
@@ -675,7 +678,7 @@ function _ts_decorate(decorators, target, key, desc) {
|
|
|
675
678
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
676
679
|
}
|
|
677
680
|
var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/identity.ts";
|
|
678
|
-
var Identity = class
|
|
681
|
+
var Identity = class {
|
|
679
682
|
constructor({ space, signer, identityKey, deviceKey }) {
|
|
680
683
|
this.stateUpdate = new import_async5.Event();
|
|
681
684
|
this.space = space;
|
|
@@ -843,7 +846,7 @@ function _ts_decorate2(decorators, target, key, desc) {
|
|
|
843
846
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
844
847
|
}
|
|
845
848
|
var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/identity-manager.ts";
|
|
846
|
-
var IdentityManager = class
|
|
849
|
+
var IdentityManager = class {
|
|
847
850
|
// TODO(burdon): IdentityManagerParams.
|
|
848
851
|
// TODO(dmaretskyi): Perhaps this should take/generate the peerKey outside of an initialized identity.
|
|
849
852
|
constructor(_metadataStore, _keyring, _feedStore, _spaceManager) {
|
|
@@ -1174,7 +1177,7 @@ var IdentityManager = class IdentityManager2 {
|
|
|
1174
1177
|
genesisFeedKey: spaceRecord.genesisFeedKey
|
|
1175
1178
|
},
|
|
1176
1179
|
swarmIdentity,
|
|
1177
|
-
|
|
1180
|
+
onAuthorizedConnection: () => {
|
|
1178
1181
|
},
|
|
1179
1182
|
onAuthFailure: () => {
|
|
1180
1183
|
import_log3.log.warn("auth failure", void 0, {
|
|
@@ -1197,6 +1200,7 @@ IdentityManager = _ts_decorate2([
|
|
|
1197
1200
|
import_tracing2.trace.resource()
|
|
1198
1201
|
], IdentityManager);
|
|
1199
1202
|
var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/identity-service.ts";
|
|
1203
|
+
var CREATE_PROFILE_WITH_AUTOMERGE_DEFAULT = true;
|
|
1200
1204
|
var IdentityServiceImpl = class {
|
|
1201
1205
|
constructor(_createIdentity, _identityManager, _keyring, _onProfileUpdate) {
|
|
1202
1206
|
this._createIdentity = _createIdentity;
|
|
@@ -1205,7 +1209,7 @@ var IdentityServiceImpl = class {
|
|
|
1205
1209
|
this._onProfileUpdate = _onProfileUpdate;
|
|
1206
1210
|
}
|
|
1207
1211
|
async createIdentity(request) {
|
|
1208
|
-
await this._createIdentity(request);
|
|
1212
|
+
await this._createIdentity(request.profile ?? {}, request.useAutomerge ?? CREATE_PROFILE_WITH_AUTOMERGE_DEFAULT);
|
|
1209
1213
|
return this._getIdentity();
|
|
1210
1214
|
}
|
|
1211
1215
|
async recoverIdentity(request) {
|
|
@@ -1233,7 +1237,7 @@ var IdentityServiceImpl = class {
|
|
|
1233
1237
|
async updateProfile(profile) {
|
|
1234
1238
|
(0, import_invariant3.invariant)(this._identityManager.identity, "Identity not initialized.", {
|
|
1235
1239
|
F: __dxlog_file4,
|
|
1236
|
-
L:
|
|
1240
|
+
L: 63,
|
|
1237
1241
|
S: this,
|
|
1238
1242
|
A: [
|
|
1239
1243
|
"this._identityManager.identity",
|
|
@@ -1247,7 +1251,7 @@ var IdentityServiceImpl = class {
|
|
|
1247
1251
|
async signPresentation({ presentation, nonce }) {
|
|
1248
1252
|
(0, import_invariant3.invariant)(this._identityManager.identity, "Identity not initialized.", {
|
|
1249
1253
|
F: __dxlog_file4,
|
|
1250
|
-
L:
|
|
1254
|
+
L: 70,
|
|
1251
1255
|
S: this,
|
|
1252
1256
|
A: [
|
|
1253
1257
|
"this._identityManager.identity",
|
|
@@ -1281,7 +1285,7 @@ var DeviceInvitationProtocol = class {
|
|
|
1281
1285
|
async admit(request) {
|
|
1282
1286
|
(0, import_invariant4.invariant)(request.device, void 0, {
|
|
1283
1287
|
F: __dxlog_file5,
|
|
1284
|
-
L:
|
|
1288
|
+
L: 36,
|
|
1285
1289
|
S: this,
|
|
1286
1290
|
A: [
|
|
1287
1291
|
"request.device",
|
|
@@ -1299,6 +1303,15 @@ var DeviceInvitationProtocol = class {
|
|
|
1299
1303
|
}
|
|
1300
1304
|
};
|
|
1301
1305
|
}
|
|
1306
|
+
checkInvitation(invitation) {
|
|
1307
|
+
try {
|
|
1308
|
+
const identity = this._getIdentity();
|
|
1309
|
+
if (identity) {
|
|
1310
|
+
return new import_protocols3.AlreadyJoinedError("Currently only one identity per client is supported.");
|
|
1311
|
+
}
|
|
1312
|
+
} catch {
|
|
1313
|
+
}
|
|
1314
|
+
}
|
|
1302
1315
|
createIntroduction() {
|
|
1303
1316
|
return {};
|
|
1304
1317
|
}
|
|
@@ -1317,7 +1330,7 @@ var DeviceInvitationProtocol = class {
|
|
|
1317
1330
|
async accept(response, request) {
|
|
1318
1331
|
(0, import_invariant4.invariant)(response.device, void 0, {
|
|
1319
1332
|
F: __dxlog_file5,
|
|
1320
|
-
L:
|
|
1333
|
+
L: 80,
|
|
1321
1334
|
S: this,
|
|
1322
1335
|
A: [
|
|
1323
1336
|
"response.device",
|
|
@@ -1327,7 +1340,7 @@ var DeviceInvitationProtocol = class {
|
|
|
1327
1340
|
const { identityKey, haloSpaceKey, genesisFeedKey, controlTimeframe } = response.device;
|
|
1328
1341
|
(0, import_invariant4.invariant)(request.device, void 0, {
|
|
1329
1342
|
F: __dxlog_file5,
|
|
1330
|
-
L:
|
|
1343
|
+
L: 83,
|
|
1331
1344
|
S: this,
|
|
1332
1345
|
A: [
|
|
1333
1346
|
"request.device",
|
|
@@ -1356,10 +1369,10 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
1356
1369
|
constructor(_callbacks) {
|
|
1357
1370
|
super({
|
|
1358
1371
|
requested: {
|
|
1359
|
-
InvitationHostService:
|
|
1372
|
+
InvitationHostService: import_protocols5.schema.getService("dxos.halo.invitations.InvitationHostService")
|
|
1360
1373
|
},
|
|
1361
1374
|
exposed: {
|
|
1362
|
-
InvitationHostService:
|
|
1375
|
+
InvitationHostService: import_protocols5.schema.getService("dxos.halo.invitations.InvitationHostService")
|
|
1363
1376
|
}
|
|
1364
1377
|
});
|
|
1365
1378
|
this._callbacks = _callbacks;
|
|
@@ -1392,7 +1405,7 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
1392
1405
|
introduce: async (request) => {
|
|
1393
1406
|
const { profile, invitationId } = request;
|
|
1394
1407
|
const traceId = import_keys6.PublicKey.random().toHex();
|
|
1395
|
-
import_log5.log.trace("dxos.sdk.invitation-handler.host.introduce",
|
|
1408
|
+
import_log5.log.trace("dxos.sdk.invitation-handler.host.introduce", import_protocols5.trace.begin({
|
|
1396
1409
|
id: traceId
|
|
1397
1410
|
}), {
|
|
1398
1411
|
F: __dxlog_file6,
|
|
@@ -1429,7 +1442,7 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
1429
1442
|
...this.invitation,
|
|
1430
1443
|
state: import_services3.Invitation.State.READY_FOR_AUTHENTICATION
|
|
1431
1444
|
});
|
|
1432
|
-
import_log5.log.trace("dxos.sdk.invitation-handler.host.introduce",
|
|
1445
|
+
import_log5.log.trace("dxos.sdk.invitation-handler.host.introduce", import_protocols5.trace.end({
|
|
1433
1446
|
id: traceId
|
|
1434
1447
|
}), {
|
|
1435
1448
|
F: __dxlog_file6,
|
|
@@ -1443,7 +1456,7 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
1443
1456
|
},
|
|
1444
1457
|
authenticate: async ({ authCode: code }) => {
|
|
1445
1458
|
const traceId = import_keys6.PublicKey.random().toHex();
|
|
1446
|
-
import_log5.log.trace("dxos.sdk.invitation-handler.host.authenticate",
|
|
1459
|
+
import_log5.log.trace("dxos.sdk.invitation-handler.host.authenticate", import_protocols5.trace.begin({
|
|
1447
1460
|
id: traceId
|
|
1448
1461
|
}), {
|
|
1449
1462
|
F: __dxlog_file6,
|
|
@@ -1506,7 +1519,7 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
1506
1519
|
break;
|
|
1507
1520
|
}
|
|
1508
1521
|
}
|
|
1509
|
-
import_log5.log.trace("dxos.sdk.invitation-handler.host.authenticate",
|
|
1522
|
+
import_log5.log.trace("dxos.sdk.invitation-handler.host.authenticate", import_protocols5.trace.end({
|
|
1510
1523
|
id: traceId,
|
|
1511
1524
|
data: {
|
|
1512
1525
|
status
|
|
@@ -1523,7 +1536,7 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
1523
1536
|
},
|
|
1524
1537
|
admit: async (request) => {
|
|
1525
1538
|
const traceId = import_keys6.PublicKey.random().toHex();
|
|
1526
|
-
import_log5.log.trace("dxos.sdk.invitation-handler.host.admit",
|
|
1539
|
+
import_log5.log.trace("dxos.sdk.invitation-handler.host.admit", import_protocols5.trace.begin({
|
|
1527
1540
|
id: traceId
|
|
1528
1541
|
}), {
|
|
1529
1542
|
F: __dxlog_file6,
|
|
@@ -1545,7 +1558,7 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
1545
1558
|
throw new Error("Not authenticated");
|
|
1546
1559
|
}
|
|
1547
1560
|
const response = await this._callbacks.admit(request);
|
|
1548
|
-
import_log5.log.trace("dxos.sdk.invitation-handler.host.admit",
|
|
1561
|
+
import_log5.log.trace("dxos.sdk.invitation-handler.host.admit", import_protocols5.trace.end({
|
|
1549
1562
|
id: traceId
|
|
1550
1563
|
}), {
|
|
1551
1564
|
F: __dxlog_file6,
|
|
@@ -1572,7 +1585,7 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
1572
1585
|
timeout: OPTIONS_TIMEOUT
|
|
1573
1586
|
}));
|
|
1574
1587
|
if (this._remoteOptions?.role !== import_invitations2.Options.Role.GUEST) {
|
|
1575
|
-
throw new
|
|
1588
|
+
throw new import_protocols5.InvalidInvitationExtensionRoleError(void 0, {
|
|
1576
1589
|
expected: import_invitations2.Options.Role.GUEST,
|
|
1577
1590
|
remoteOptions: this._remoteOptions
|
|
1578
1591
|
});
|
|
@@ -1590,10 +1603,10 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
|
|
|
1590
1603
|
constructor(_callbacks) {
|
|
1591
1604
|
super({
|
|
1592
1605
|
requested: {
|
|
1593
|
-
InvitationHostService:
|
|
1606
|
+
InvitationHostService: import_protocols5.schema.getService("dxos.halo.invitations.InvitationHostService")
|
|
1594
1607
|
},
|
|
1595
1608
|
exposed: {
|
|
1596
|
-
InvitationHostService:
|
|
1609
|
+
InvitationHostService: import_protocols5.schema.getService("dxos.halo.invitations.InvitationHostService")
|
|
1597
1610
|
}
|
|
1598
1611
|
});
|
|
1599
1612
|
this._callbacks = _callbacks;
|
|
@@ -1650,7 +1663,7 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
|
|
|
1650
1663
|
C: (f, a) => f(...a)
|
|
1651
1664
|
});
|
|
1652
1665
|
if (this._remoteOptions?.role !== import_invitations2.Options.Role.HOST) {
|
|
1653
|
-
throw new
|
|
1666
|
+
throw new import_protocols5.InvalidInvitationExtensionRoleError(void 0, {
|
|
1654
1667
|
expected: import_invitations2.Options.Role.HOST,
|
|
1655
1668
|
remoteOptions: this._remoteOptions
|
|
1656
1669
|
});
|
|
@@ -1763,7 +1776,7 @@ var InvitationsHandler = class {
|
|
|
1763
1776
|
(0, import_async7.scheduleTask)(ctx, async () => {
|
|
1764
1777
|
const traceId = import_keys5.PublicKey.random().toHex();
|
|
1765
1778
|
try {
|
|
1766
|
-
import_log4.log.trace("dxos.sdk.invitations-handler.host.onOpen",
|
|
1779
|
+
import_log4.log.trace("dxos.sdk.invitations-handler.host.onOpen", import_protocols4.trace.begin({
|
|
1767
1780
|
id: traceId
|
|
1768
1781
|
}), {
|
|
1769
1782
|
F: __dxlog_file7,
|
|
@@ -1799,7 +1812,7 @@ var InvitationsHandler = class {
|
|
|
1799
1812
|
...invitation,
|
|
1800
1813
|
state: import_services2.Invitation.State.SUCCESS
|
|
1801
1814
|
});
|
|
1802
|
-
import_log4.log.trace("dxos.sdk.invitations-handler.host.onOpen",
|
|
1815
|
+
import_log4.log.trace("dxos.sdk.invitations-handler.host.onOpen", import_protocols4.trace.end({
|
|
1803
1816
|
id: traceId
|
|
1804
1817
|
}), {
|
|
1805
1818
|
F: __dxlog_file7,
|
|
@@ -1830,7 +1843,7 @@ var InvitationsHandler = class {
|
|
|
1830
1843
|
});
|
|
1831
1844
|
stream.error(err);
|
|
1832
1845
|
}
|
|
1833
|
-
import_log4.log.trace("dxos.sdk.invitations-handler.host.onOpen",
|
|
1846
|
+
import_log4.log.trace("dxos.sdk.invitations-handler.host.onOpen", import_protocols4.trace.error({
|
|
1834
1847
|
id: traceId,
|
|
1835
1848
|
error: err
|
|
1836
1849
|
}), {
|
|
@@ -1848,7 +1861,7 @@ var InvitationsHandler = class {
|
|
|
1848
1861
|
});
|
|
1849
1862
|
},
|
|
1850
1863
|
onError: (err) => {
|
|
1851
|
-
if (err instanceof
|
|
1864
|
+
if (err instanceof import_protocols4.InvalidInvitationExtensionRoleError) {
|
|
1852
1865
|
return;
|
|
1853
1866
|
}
|
|
1854
1867
|
if (err instanceof import_async7.TimeoutError) {
|
|
@@ -1996,7 +2009,7 @@ var InvitationsHandler = class {
|
|
|
1996
2009
|
(0, import_async7.scheduleTask)(ctx, async () => {
|
|
1997
2010
|
const traceId = import_keys5.PublicKey.random().toHex();
|
|
1998
2011
|
try {
|
|
1999
|
-
import_log4.log.trace("dxos.sdk.invitations-handler.guest.onOpen",
|
|
2012
|
+
import_log4.log.trace("dxos.sdk.invitations-handler.guest.onOpen", import_protocols4.trace.begin({
|
|
2000
2013
|
id: traceId
|
|
2001
2014
|
}), {
|
|
2002
2015
|
F: __dxlog_file7,
|
|
@@ -2083,16 +2096,12 @@ var InvitationsHandler = class {
|
|
|
2083
2096
|
}
|
|
2084
2097
|
}
|
|
2085
2098
|
}
|
|
2086
|
-
} else {
|
|
2087
|
-
setState({
|
|
2088
|
-
state: import_services2.Invitation.State.READY_FOR_AUTHENTICATION
|
|
2089
|
-
});
|
|
2090
2099
|
}
|
|
2091
2100
|
(0, import_log4.log)("request admission", {
|
|
2092
2101
|
...protocol.toJSON()
|
|
2093
2102
|
}, {
|
|
2094
2103
|
F: __dxlog_file7,
|
|
2095
|
-
L:
|
|
2104
|
+
L: 309,
|
|
2096
2105
|
S: this,
|
|
2097
2106
|
C: (f, a) => f(...a)
|
|
2098
2107
|
});
|
|
@@ -2104,7 +2113,7 @@ var InvitationsHandler = class {
|
|
|
2104
2113
|
...protocol.toJSON()
|
|
2105
2114
|
}, {
|
|
2106
2115
|
F: __dxlog_file7,
|
|
2107
|
-
L:
|
|
2116
|
+
L: 320,
|
|
2108
2117
|
S: this,
|
|
2109
2118
|
C: (f, a) => f(...a)
|
|
2110
2119
|
});
|
|
@@ -2113,11 +2122,11 @@ var InvitationsHandler = class {
|
|
|
2113
2122
|
target: invitation.target,
|
|
2114
2123
|
state: import_services2.Invitation.State.SUCCESS
|
|
2115
2124
|
});
|
|
2116
|
-
import_log4.log.trace("dxos.sdk.invitations-handler.guest.onOpen",
|
|
2125
|
+
import_log4.log.trace("dxos.sdk.invitations-handler.guest.onOpen", import_protocols4.trace.end({
|
|
2117
2126
|
id: traceId
|
|
2118
2127
|
}), {
|
|
2119
2128
|
F: __dxlog_file7,
|
|
2120
|
-
L:
|
|
2129
|
+
L: 322,
|
|
2121
2130
|
S: this,
|
|
2122
2131
|
C: (f, a) => f(...a)
|
|
2123
2132
|
});
|
|
@@ -2127,7 +2136,7 @@ var InvitationsHandler = class {
|
|
|
2127
2136
|
...protocol.toJSON()
|
|
2128
2137
|
}, {
|
|
2129
2138
|
F: __dxlog_file7,
|
|
2130
|
-
L:
|
|
2139
|
+
L: 325,
|
|
2131
2140
|
S: this,
|
|
2132
2141
|
C: (f, a) => f(...a)
|
|
2133
2142
|
});
|
|
@@ -2137,18 +2146,18 @@ var InvitationsHandler = class {
|
|
|
2137
2146
|
} else {
|
|
2138
2147
|
(0, import_log4.log)("auth failed", err, {
|
|
2139
2148
|
F: __dxlog_file7,
|
|
2140
|
-
L:
|
|
2149
|
+
L: 328,
|
|
2141
2150
|
S: this,
|
|
2142
2151
|
C: (f, a) => f(...a)
|
|
2143
2152
|
});
|
|
2144
2153
|
stream.error(err);
|
|
2145
2154
|
}
|
|
2146
|
-
import_log4.log.trace("dxos.sdk.invitations-handler.guest.onOpen",
|
|
2155
|
+
import_log4.log.trace("dxos.sdk.invitations-handler.guest.onOpen", import_protocols4.trace.error({
|
|
2147
2156
|
id: traceId,
|
|
2148
2157
|
error: err
|
|
2149
2158
|
}), {
|
|
2150
2159
|
F: __dxlog_file7,
|
|
2151
|
-
L:
|
|
2160
|
+
L: 331,
|
|
2152
2161
|
S: this,
|
|
2153
2162
|
C: (f, a) => f(...a)
|
|
2154
2163
|
});
|
|
@@ -2158,7 +2167,7 @@ var InvitationsHandler = class {
|
|
|
2158
2167
|
});
|
|
2159
2168
|
},
|
|
2160
2169
|
onError: (err) => {
|
|
2161
|
-
if (err instanceof
|
|
2170
|
+
if (err instanceof import_protocols4.InvalidInvitationExtensionRoleError) {
|
|
2162
2171
|
return;
|
|
2163
2172
|
}
|
|
2164
2173
|
if (err instanceof import_async7.TimeoutError) {
|
|
@@ -2166,7 +2175,7 @@ var InvitationsHandler = class {
|
|
|
2166
2175
|
...protocol.toJSON()
|
|
2167
2176
|
}, {
|
|
2168
2177
|
F: __dxlog_file7,
|
|
2169
|
-
L:
|
|
2178
|
+
L: 342,
|
|
2170
2179
|
S: this,
|
|
2171
2180
|
C: (f, a) => f(...a)
|
|
2172
2181
|
});
|
|
@@ -2176,7 +2185,7 @@ var InvitationsHandler = class {
|
|
|
2176
2185
|
} else {
|
|
2177
2186
|
(0, import_log4.log)("auth failed", err, {
|
|
2178
2187
|
F: __dxlog_file7,
|
|
2179
|
-
L:
|
|
2188
|
+
L: 345,
|
|
2180
2189
|
S: this,
|
|
2181
2190
|
C: (f, a) => f(...a)
|
|
2182
2191
|
});
|
|
@@ -2187,29 +2196,34 @@ var InvitationsHandler = class {
|
|
|
2187
2196
|
return extension;
|
|
2188
2197
|
};
|
|
2189
2198
|
(0, import_async7.scheduleTask)(ctx, async () => {
|
|
2190
|
-
|
|
2191
|
-
|
|
2192
|
-
|
|
2193
|
-
|
|
2194
|
-
|
|
2195
|
-
|
|
2196
|
-
|
|
2197
|
-
|
|
2198
|
-
|
|
2199
|
-
|
|
2200
|
-
|
|
2201
|
-
|
|
2202
|
-
|
|
2203
|
-
|
|
2204
|
-
|
|
2205
|
-
|
|
2206
|
-
|
|
2207
|
-
|
|
2208
|
-
|
|
2209
|
-
|
|
2210
|
-
|
|
2211
|
-
|
|
2212
|
-
|
|
2199
|
+
const error = protocol.checkInvitation(invitation);
|
|
2200
|
+
if (error) {
|
|
2201
|
+
stream.error(error);
|
|
2202
|
+
} else {
|
|
2203
|
+
(0, import_invariant5.invariant)(invitation.swarmKey, void 0, {
|
|
2204
|
+
F: __dxlog_file7,
|
|
2205
|
+
L: 359,
|
|
2206
|
+
S: this,
|
|
2207
|
+
A: [
|
|
2208
|
+
"invitation.swarmKey",
|
|
2209
|
+
""
|
|
2210
|
+
]
|
|
2211
|
+
});
|
|
2212
|
+
const topic = invitation.swarmKey;
|
|
2213
|
+
const swarmConnection = await this._networkManager.joinSwarm({
|
|
2214
|
+
topic,
|
|
2215
|
+
peerId: import_keys5.PublicKey.random(),
|
|
2216
|
+
protocolProvider: (0, import_network_manager.createTeleportProtocolFactory)(async (teleport) => {
|
|
2217
|
+
teleport.addExtension("dxos.halo.invitations", createExtension());
|
|
2218
|
+
}),
|
|
2219
|
+
topology: new import_network_manager.StarTopology(topic),
|
|
2220
|
+
label: "invitation guest"
|
|
2221
|
+
});
|
|
2222
|
+
ctx.onDispose(() => swarmConnection.close());
|
|
2223
|
+
setState({
|
|
2224
|
+
state: import_services2.Invitation.State.CONNECTING
|
|
2225
|
+
});
|
|
2226
|
+
}
|
|
2213
2227
|
});
|
|
2214
2228
|
const observable = new import_client_protocol2.AuthenticatingInvitation({
|
|
2215
2229
|
initialInvitation: invitation,
|
|
@@ -2425,7 +2439,7 @@ var SpaceInvitationProtocol = class {
|
|
|
2425
2439
|
async admit(request, guestProfile) {
|
|
2426
2440
|
(0, import_invariant8.invariant)(this._spaceKey, void 0, {
|
|
2427
2441
|
F: __dxlog_file9,
|
|
2428
|
-
L:
|
|
2442
|
+
L: 47,
|
|
2429
2443
|
S: this,
|
|
2430
2444
|
A: [
|
|
2431
2445
|
"this._spaceKey",
|
|
@@ -2435,7 +2449,7 @@ var SpaceInvitationProtocol = class {
|
|
|
2435
2449
|
const space = await this._spaceManager.spaces.get(this._spaceKey);
|
|
2436
2450
|
(0, import_invariant8.invariant)(space, void 0, {
|
|
2437
2451
|
F: __dxlog_file9,
|
|
2438
|
-
L:
|
|
2452
|
+
L: 49,
|
|
2439
2453
|
S: this,
|
|
2440
2454
|
A: [
|
|
2441
2455
|
"space",
|
|
@@ -2444,7 +2458,7 @@ var SpaceInvitationProtocol = class {
|
|
|
2444
2458
|
});
|
|
2445
2459
|
(0, import_invariant8.invariant)(request.space, void 0, {
|
|
2446
2460
|
F: __dxlog_file9,
|
|
2447
|
-
L:
|
|
2461
|
+
L: 51,
|
|
2448
2462
|
S: this,
|
|
2449
2463
|
A: [
|
|
2450
2464
|
"request.space",
|
|
@@ -2457,14 +2471,14 @@ var SpaceInvitationProtocol = class {
|
|
|
2457
2471
|
guest: deviceKey
|
|
2458
2472
|
}, {
|
|
2459
2473
|
F: __dxlog_file9,
|
|
2460
|
-
L:
|
|
2474
|
+
L: 54,
|
|
2461
2475
|
S: this,
|
|
2462
2476
|
C: (f, a) => f(...a)
|
|
2463
2477
|
});
|
|
2464
2478
|
const credentials = await (0, import_credentials8.createAdmissionCredentials)(this._signingContext.credentialSigner, identityKey, space.key, space.inner.genesisFeedKey, guestProfile);
|
|
2465
2479
|
(0, import_invariant8.invariant)(credentials[0].credential, void 0, {
|
|
2466
2480
|
F: __dxlog_file9,
|
|
2467
|
-
L:
|
|
2481
|
+
L: 65,
|
|
2468
2482
|
S: this,
|
|
2469
2483
|
A: [
|
|
2470
2484
|
"credentials[0].credential",
|
|
@@ -2474,7 +2488,7 @@ var SpaceInvitationProtocol = class {
|
|
|
2474
2488
|
const spaceMemberCredential = credentials[0].credential.credential;
|
|
2475
2489
|
(0, import_invariant8.invariant)((0, import_credentials8.getCredentialAssertion)(spaceMemberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
|
|
2476
2490
|
F: __dxlog_file9,
|
|
2477
|
-
L:
|
|
2491
|
+
L: 67,
|
|
2478
2492
|
S: this,
|
|
2479
2493
|
A: [
|
|
2480
2494
|
"getCredentialAssertion(spaceMemberCredential)['@type'] === 'dxos.halo.credentials.SpaceMember'",
|
|
@@ -2490,6 +2504,11 @@ var SpaceInvitationProtocol = class {
|
|
|
2490
2504
|
}
|
|
2491
2505
|
};
|
|
2492
2506
|
}
|
|
2507
|
+
checkInvitation(invitation) {
|
|
2508
|
+
if (invitation.spaceKey && this._spaceManager.spaces.has(invitation.spaceKey)) {
|
|
2509
|
+
return new import_protocols6.AlreadyJoinedError("Already joined space.");
|
|
2510
|
+
}
|
|
2511
|
+
}
|
|
2493
2512
|
createIntroduction() {
|
|
2494
2513
|
return {
|
|
2495
2514
|
profile: this._signingContext.getProfile()
|
|
@@ -2510,7 +2529,7 @@ var SpaceInvitationProtocol = class {
|
|
|
2510
2529
|
async accept(response) {
|
|
2511
2530
|
(0, import_invariant8.invariant)(response.space, void 0, {
|
|
2512
2531
|
F: __dxlog_file9,
|
|
2513
|
-
L:
|
|
2532
|
+
L: 108,
|
|
2514
2533
|
S: this,
|
|
2515
2534
|
A: [
|
|
2516
2535
|
"response.space",
|
|
@@ -2521,7 +2540,7 @@ var SpaceInvitationProtocol = class {
|
|
|
2521
2540
|
const assertion = (0, import_credentials8.getCredentialAssertion)(credential);
|
|
2522
2541
|
(0, import_invariant8.invariant)(assertion["@type"] === "dxos.halo.credentials.SpaceMember", "Invalid credential", {
|
|
2523
2542
|
F: __dxlog_file9,
|
|
2524
|
-
L:
|
|
2543
|
+
L: 111,
|
|
2525
2544
|
S: this,
|
|
2526
2545
|
A: [
|
|
2527
2546
|
"assertion['@type'] === 'dxos.halo.credentials.SpaceMember'",
|
|
@@ -2530,13 +2549,16 @@ var SpaceInvitationProtocol = class {
|
|
|
2530
2549
|
});
|
|
2531
2550
|
(0, import_invariant8.invariant)(credential.subject.id.equals(this._signingContext.identityKey), void 0, {
|
|
2532
2551
|
F: __dxlog_file9,
|
|
2533
|
-
L:
|
|
2552
|
+
L: 112,
|
|
2534
2553
|
S: this,
|
|
2535
2554
|
A: [
|
|
2536
2555
|
"credential.subject.id.equals(this._signingContext.identityKey)",
|
|
2537
2556
|
""
|
|
2538
2557
|
]
|
|
2539
2558
|
});
|
|
2559
|
+
if (this._spaceManager.spaces.has(assertion.spaceKey)) {
|
|
2560
|
+
throw new import_protocols6.AlreadyJoinedError("Already joined space.");
|
|
2561
|
+
}
|
|
2540
2562
|
await this._spaceManager.acceptSpace({
|
|
2541
2563
|
spaceKey: assertion.spaceKey,
|
|
2542
2564
|
genesisFeedKey: assertion.genesisFeedKey,
|
|
@@ -2559,7 +2581,7 @@ function _ts_decorate3(decorators, target, key, desc) {
|
|
|
2559
2581
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
2560
2582
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2561
2583
|
}
|
|
2562
|
-
var ClientRpcServer = class
|
|
2584
|
+
var ClientRpcServer = class {
|
|
2563
2585
|
constructor(params) {
|
|
2564
2586
|
this._handlerCache = /* @__PURE__ */ new Map();
|
|
2565
2587
|
this._callMetrics = new import_tracing3.MapCounter();
|
|
@@ -2650,7 +2672,7 @@ var getPlatform = () => {
|
|
|
2650
2672
|
};
|
|
2651
2673
|
}
|
|
2652
2674
|
};
|
|
2653
|
-
var DXOS_VERSION = "0.3.11-main.
|
|
2675
|
+
var DXOS_VERSION = "0.3.11-main.afa73e0";
|
|
2654
2676
|
var __dxlog_file10 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/diagnostics.ts";
|
|
2655
2677
|
var DEFAULT_TIMEOUT = 1e3;
|
|
2656
2678
|
var createDiagnostics = async (clientServices, serviceContext, config) => {
|
|
@@ -2660,14 +2682,14 @@ var createDiagnostics = async (clientServices, serviceContext, config) => {
|
|
|
2660
2682
|
client: {
|
|
2661
2683
|
version: DXOS_VERSION,
|
|
2662
2684
|
storage: {
|
|
2663
|
-
version:
|
|
2685
|
+
version: import_protocols7.STORAGE_VERSION
|
|
2664
2686
|
}
|
|
2665
2687
|
}
|
|
2666
2688
|
};
|
|
2667
2689
|
{
|
|
2668
2690
|
(0, import_invariant9.invariant)(clientServices.LoggingService, "SystemService is not available.", {
|
|
2669
2691
|
F: __dxlog_file10,
|
|
2670
|
-
L:
|
|
2692
|
+
L: 93,
|
|
2671
2693
|
S: void 0,
|
|
2672
2694
|
A: [
|
|
2673
2695
|
"clientServices.LoggingService",
|
|
@@ -2678,6 +2700,21 @@ var createDiagnostics = async (clientServices, serviceContext, config) => {
|
|
|
2678
2700
|
timeout: DEFAULT_TIMEOUT
|
|
2679
2701
|
}).catch(() => void 0);
|
|
2680
2702
|
}
|
|
2703
|
+
if (typeof navigator !== "undefined" && navigator.storage) {
|
|
2704
|
+
const map = /* @__PURE__ */ new Map();
|
|
2705
|
+
const dir = await navigator.storage.getDirectory();
|
|
2706
|
+
for await (const filename of dir?.keys()) {
|
|
2707
|
+
const idx = filename.indexOf("-", filename.indexOf("-") + 1);
|
|
2708
|
+
if (idx === -1) {
|
|
2709
|
+
continue;
|
|
2710
|
+
}
|
|
2711
|
+
map.set(filename.slice(0, idx), (map.get(filename.slice(0, idx)) ?? 0) + 1);
|
|
2712
|
+
}
|
|
2713
|
+
diagnostics.storage = Array.from(map.entries()).sort((a, b) => b[1] - a[1]).map(([file, count]) => ({
|
|
2714
|
+
file,
|
|
2715
|
+
count
|
|
2716
|
+
}));
|
|
2717
|
+
}
|
|
2681
2718
|
const identity = serviceContext.identityManager.identity;
|
|
2682
2719
|
if (identity) {
|
|
2683
2720
|
diagnostics.identity = {
|
|
@@ -2718,7 +2755,7 @@ var getProperties = (space) => {
|
|
|
2718
2755
|
} catch (err) {
|
|
2719
2756
|
import_log8.log.warn(err.message, void 0, {
|
|
2720
2757
|
F: __dxlog_file10,
|
|
2721
|
-
L:
|
|
2758
|
+
L: 178,
|
|
2722
2759
|
S: void 0,
|
|
2723
2760
|
C: (f, a) => f(...a)
|
|
2724
2761
|
});
|
|
@@ -2773,7 +2810,8 @@ var getSpaceStats = async (space) => {
|
|
|
2773
2810
|
return stats;
|
|
2774
2811
|
};
|
|
2775
2812
|
var AutomergeSpaceState = class {
|
|
2776
|
-
constructor() {
|
|
2813
|
+
constructor(_onNewRoot) {
|
|
2814
|
+
this._onNewRoot = _onNewRoot;
|
|
2777
2815
|
this.rootUrl = void 0;
|
|
2778
2816
|
this.lastEpoch = void 0;
|
|
2779
2817
|
}
|
|
@@ -2784,6 +2822,7 @@ var AutomergeSpaceState = class {
|
|
|
2784
2822
|
this.lastEpoch = credential;
|
|
2785
2823
|
if (credential.subject.assertion.automergeRoot) {
|
|
2786
2824
|
this.rootUrl = credential.subject.assertion.automergeRoot;
|
|
2825
|
+
this._onNewRoot(this.rootUrl);
|
|
2787
2826
|
}
|
|
2788
2827
|
}
|
|
2789
2828
|
};
|
|
@@ -2820,7 +2859,7 @@ var NotarizationPlugin = class {
|
|
|
2820
2859
|
S: this,
|
|
2821
2860
|
C: (f, a) => f(...a)
|
|
2822
2861
|
});
|
|
2823
|
-
(0,
|
|
2862
|
+
(0, import_invariant11.invariant)(credentials.every((credential) => credential.id), "Credentials must have an id", {
|
|
2824
2863
|
F: __dxlog_file11,
|
|
2825
2864
|
L: 91,
|
|
2826
2865
|
S: this,
|
|
@@ -2945,7 +2984,7 @@ var NotarizationPlugin = class {
|
|
|
2945
2984
|
this._processCredentialsTriggers.delete(credential.id);
|
|
2946
2985
|
}
|
|
2947
2986
|
setWriter(writer) {
|
|
2948
|
-
(0,
|
|
2987
|
+
(0, import_invariant11.invariant)(!this._writer, "Writer already set.", {
|
|
2949
2988
|
F: __dxlog_file11,
|
|
2950
2989
|
L: 181,
|
|
2951
2990
|
S: this,
|
|
@@ -2970,7 +3009,7 @@ var NotarizationPlugin = class {
|
|
|
2970
3009
|
throw new Error(WRITER_NOT_SET_ERROR_CODE);
|
|
2971
3010
|
}
|
|
2972
3011
|
for (const credential of request.credentials ?? []) {
|
|
2973
|
-
(0,
|
|
3012
|
+
(0, import_invariant11.invariant)(credential.id, "Credential must have an id", {
|
|
2974
3013
|
F: __dxlog_file11,
|
|
2975
3014
|
L: 200,
|
|
2976
3015
|
S: this,
|
|
@@ -3019,10 +3058,10 @@ var NotarizationTeleportExtension = class extends import_teleport2.RpcExtension
|
|
|
3019
3058
|
constructor(_params) {
|
|
3020
3059
|
super({
|
|
3021
3060
|
requested: {
|
|
3022
|
-
NotarizationService:
|
|
3061
|
+
NotarizationService: import_protocols9.schema.getService("dxos.mesh.teleport.notarization.NotarizationService")
|
|
3023
3062
|
},
|
|
3024
3063
|
exposed: {
|
|
3025
|
-
NotarizationService:
|
|
3064
|
+
NotarizationService: import_protocols9.schema.getService("dxos.mesh.teleport.notarization.NotarizationService")
|
|
3026
3065
|
}
|
|
3027
3066
|
});
|
|
3028
3067
|
this._params = _params;
|
|
@@ -3057,12 +3096,12 @@ function _ts_decorate4(decorators, target, key, desc) {
|
|
|
3057
3096
|
}
|
|
3058
3097
|
var __dxlog_file12 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space.ts";
|
|
3059
3098
|
var ENABLE_FEED_PURGE = false;
|
|
3060
|
-
var DataSpace = class
|
|
3099
|
+
var DataSpace = class {
|
|
3061
3100
|
constructor(params) {
|
|
3062
3101
|
this._ctx = new import_context6.Context();
|
|
3063
3102
|
this._notarizationPlugin = new NotarizationPlugin();
|
|
3064
3103
|
this._cache = void 0;
|
|
3065
|
-
this._automergeSpaceState = new AutomergeSpaceState();
|
|
3104
|
+
this._automergeSpaceState = new AutomergeSpaceState((rootUrl) => this._onNewAutomergeRoot(rootUrl));
|
|
3066
3105
|
this._state = import_services7.SpaceState.CLOSED;
|
|
3067
3106
|
this.error = void 0;
|
|
3068
3107
|
this.stateUpdate = new import_async10.Event();
|
|
@@ -3088,7 +3127,7 @@ var DataSpace = class DataSpace2 {
|
|
|
3088
3127
|
state: import_services7.SpaceState[this._state]
|
|
3089
3128
|
}, {
|
|
3090
3129
|
F: __dxlog_file12,
|
|
3091
|
-
L:
|
|
3130
|
+
L: 138,
|
|
3092
3131
|
S: this,
|
|
3093
3132
|
C: (f, a) => f(...a)
|
|
3094
3133
|
});
|
|
@@ -3135,7 +3174,7 @@ var DataSpace = class DataSpace2 {
|
|
|
3135
3174
|
state: import_services7.SpaceState[this._state]
|
|
3136
3175
|
}, {
|
|
3137
3176
|
F: __dxlog_file12,
|
|
3138
|
-
L:
|
|
3177
|
+
L: 190,
|
|
3139
3178
|
S: this,
|
|
3140
3179
|
C: (f, a) => f(...a)
|
|
3141
3180
|
});
|
|
@@ -3153,7 +3192,7 @@ var DataSpace = class DataSpace2 {
|
|
|
3153
3192
|
state: import_services7.SpaceState[this._state]
|
|
3154
3193
|
}, {
|
|
3155
3194
|
F: __dxlog_file12,
|
|
3156
|
-
L:
|
|
3195
|
+
L: 204,
|
|
3157
3196
|
S: this,
|
|
3158
3197
|
C: (f, a) => f(...a)
|
|
3159
3198
|
});
|
|
@@ -3182,10 +3221,10 @@ var DataSpace = class DataSpace2 {
|
|
|
3182
3221
|
this.metrics.pipelineInitBegin = /* @__PURE__ */ new Date();
|
|
3183
3222
|
await this.initializeDataPipeline();
|
|
3184
3223
|
} catch (err) {
|
|
3185
|
-
if (err instanceof
|
|
3224
|
+
if (err instanceof import_protocols8.CancelledError) {
|
|
3186
3225
|
(0, import_log9.log)("data pipeline initialization cancelled", err, {
|
|
3187
3226
|
F: __dxlog_file12,
|
|
3188
|
-
L:
|
|
3227
|
+
L: 237,
|
|
3189
3228
|
S: this,
|
|
3190
3229
|
C: (f, a) => f(...a)
|
|
3191
3230
|
});
|
|
@@ -3193,7 +3232,7 @@ var DataSpace = class DataSpace2 {
|
|
|
3193
3232
|
}
|
|
3194
3233
|
import_log9.log.error("Error initializing data pipeline", err, {
|
|
3195
3234
|
F: __dxlog_file12,
|
|
3196
|
-
L:
|
|
3235
|
+
L: 241,
|
|
3197
3236
|
S: this,
|
|
3198
3237
|
C: (f, a) => f(...a)
|
|
3199
3238
|
});
|
|
@@ -3202,7 +3241,7 @@ var DataSpace = class DataSpace2 {
|
|
|
3202
3241
|
state: import_services7.SpaceState[this._state]
|
|
3203
3242
|
}, {
|
|
3204
3243
|
F: __dxlog_file12,
|
|
3205
|
-
L:
|
|
3244
|
+
L: 243,
|
|
3206
3245
|
S: this,
|
|
3207
3246
|
C: (f, a) => f(...a)
|
|
3208
3247
|
});
|
|
@@ -3215,14 +3254,14 @@ var DataSpace = class DataSpace2 {
|
|
|
3215
3254
|
}
|
|
3216
3255
|
async initializeDataPipeline() {
|
|
3217
3256
|
if (this._state !== import_services7.SpaceState.CONTROL_ONLY) {
|
|
3218
|
-
throw new
|
|
3257
|
+
throw new import_protocols8.SystemError("Invalid operation");
|
|
3219
3258
|
}
|
|
3220
3259
|
this._state = import_services7.SpaceState.INITIALIZING;
|
|
3221
3260
|
(0, import_log9.log)("new state", {
|
|
3222
3261
|
state: import_services7.SpaceState[this._state]
|
|
3223
3262
|
}, {
|
|
3224
3263
|
F: __dxlog_file12,
|
|
3225
|
-
L:
|
|
3264
|
+
L: 259,
|
|
3226
3265
|
S: this,
|
|
3227
3266
|
C: (f, a) => f(...a)
|
|
3228
3267
|
});
|
|
@@ -3233,7 +3272,7 @@ var DataSpace = class DataSpace2 {
|
|
|
3233
3272
|
await (0, import_context6.cancelWithContext)(this._ctx, this._inner.dataPipeline.ensureEpochInitialized());
|
|
3234
3273
|
(0, import_log9.log)("waiting for data pipeline to reach target timeframe", void 0, {
|
|
3235
3274
|
F: __dxlog_file12,
|
|
3236
|
-
L:
|
|
3275
|
+
L: 273,
|
|
3237
3276
|
S: this,
|
|
3238
3277
|
C: (f, a) => f(...a)
|
|
3239
3278
|
});
|
|
@@ -3244,7 +3283,7 @@ var DataSpace = class DataSpace2 {
|
|
|
3244
3283
|
this.metrics.dataPipelineReady = /* @__PURE__ */ new Date();
|
|
3245
3284
|
(0, import_log9.log)("data pipeline ready", void 0, {
|
|
3246
3285
|
F: __dxlog_file12,
|
|
3247
|
-
L:
|
|
3286
|
+
L: 282,
|
|
3248
3287
|
S: this,
|
|
3249
3288
|
C: (f, a) => f(...a)
|
|
3250
3289
|
});
|
|
@@ -3254,7 +3293,7 @@ var DataSpace = class DataSpace2 {
|
|
|
3254
3293
|
state: import_services7.SpaceState[this._state]
|
|
3255
3294
|
}, {
|
|
3256
3295
|
F: __dxlog_file12,
|
|
3257
|
-
L:
|
|
3296
|
+
L: 286,
|
|
3258
3297
|
S: this,
|
|
3259
3298
|
C: (f, a) => f(...a)
|
|
3260
3299
|
});
|
|
@@ -3270,7 +3309,7 @@ var DataSpace = class DataSpace2 {
|
|
|
3270
3309
|
await this._createWritableFeeds();
|
|
3271
3310
|
(0, import_log9.log)("writable feeds created", void 0, {
|
|
3272
3311
|
F: __dxlog_file12,
|
|
3273
|
-
L:
|
|
3312
|
+
L: 302,
|
|
3274
3313
|
S: this,
|
|
3275
3314
|
C: (f, a) => f(...a)
|
|
3276
3315
|
});
|
|
@@ -3327,6 +3366,40 @@ var DataSpace = class DataSpace2 {
|
|
|
3327
3366
|
await this._metadataStore.setWritableFeedKeys(this.key, this.inner.controlFeedKey, this.inner.dataFeedKey);
|
|
3328
3367
|
}
|
|
3329
3368
|
}
|
|
3369
|
+
_onNewAutomergeRoot(rootUrl) {
|
|
3370
|
+
import_log9.log.info("loading automerge root doc for space", {
|
|
3371
|
+
space: this.key,
|
|
3372
|
+
rootUrl
|
|
3373
|
+
}, {
|
|
3374
|
+
F: __dxlog_file12,
|
|
3375
|
+
L: 368,
|
|
3376
|
+
S: this,
|
|
3377
|
+
C: (f, a) => f(...a)
|
|
3378
|
+
});
|
|
3379
|
+
const handle = this._automergeHost.repo.find(rootUrl);
|
|
3380
|
+
queueMicrotask(async () => {
|
|
3381
|
+
try {
|
|
3382
|
+
await handle.whenReady();
|
|
3383
|
+
const doc = handle.docSync() ?? (0, import_invariant10.failedInvariant)();
|
|
3384
|
+
if (!doc.experimental_spaceKey) {
|
|
3385
|
+
handle.change((doc2) => {
|
|
3386
|
+
doc2.experimental_spaceKey = this.key.toHex();
|
|
3387
|
+
});
|
|
3388
|
+
}
|
|
3389
|
+
} catch (err) {
|
|
3390
|
+
import_log9.log.warn("error loading automerge root doc", {
|
|
3391
|
+
space: this.key,
|
|
3392
|
+
rootUrl,
|
|
3393
|
+
err
|
|
3394
|
+
}, {
|
|
3395
|
+
F: __dxlog_file12,
|
|
3396
|
+
L: 381,
|
|
3397
|
+
S: this,
|
|
3398
|
+
C: (f, a) => f(...a)
|
|
3399
|
+
});
|
|
3400
|
+
}
|
|
3401
|
+
});
|
|
3402
|
+
}
|
|
3330
3403
|
// TODO(dmaretskyi): Use profile from signing context.
|
|
3331
3404
|
async updateOwnProfile(profile) {
|
|
3332
3405
|
const credential = await this._signingContext.credentialSigner.createCredential({
|
|
@@ -3410,7 +3483,7 @@ var DataSpace = class DataSpace2 {
|
|
|
3410
3483
|
state: import_services7.SpaceState[this._state]
|
|
3411
3484
|
}, {
|
|
3412
3485
|
F: __dxlog_file12,
|
|
3413
|
-
L:
|
|
3486
|
+
L: 470,
|
|
3414
3487
|
S: this,
|
|
3415
3488
|
C: (f, a) => f(...a)
|
|
3416
3489
|
});
|
|
@@ -3522,7 +3595,7 @@ function _ts_decorate5(decorators, target, key, desc) {
|
|
|
3522
3595
|
var __dxlog_file13 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts";
|
|
3523
3596
|
var PRESENCE_ANNOUNCE_INTERVAL = 1e4;
|
|
3524
3597
|
var PRESENCE_OFFLINE_TIMEOUT = 2e4;
|
|
3525
|
-
var DataSpaceManager = class
|
|
3598
|
+
var DataSpaceManager = class {
|
|
3526
3599
|
constructor(_spaceManager, _metadataStore, _dataServiceSubscriptions, _keyring, _signingContext, _feedStore, _automergeHost) {
|
|
3527
3600
|
this._spaceManager = _spaceManager;
|
|
3528
3601
|
this._metadataStore = _metadataStore;
|
|
@@ -3548,7 +3621,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
3548
3621
|
S: this,
|
|
3549
3622
|
C: (f, a) => f(...a)
|
|
3550
3623
|
});
|
|
3551
|
-
import_log11.log.trace("dxos.echo.data-space-manager.open",
|
|
3624
|
+
import_log11.log.trace("dxos.echo.data-space-manager.open", import_protocols10.trace.begin({
|
|
3552
3625
|
id: this._instanceId
|
|
3553
3626
|
}), {
|
|
3554
3627
|
F: __dxlog_file13,
|
|
@@ -3594,7 +3667,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
3594
3667
|
space.initializeDataPipelineAsync();
|
|
3595
3668
|
}
|
|
3596
3669
|
}
|
|
3597
|
-
import_log11.log.trace("dxos.echo.data-space-manager.open",
|
|
3670
|
+
import_log11.log.trace("dxos.echo.data-space-manager.open", import_protocols10.trace.end({
|
|
3598
3671
|
id: this._instanceId
|
|
3599
3672
|
}), {
|
|
3600
3673
|
F: __dxlog_file13,
|
|
@@ -3620,7 +3693,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
3620
3693
|
* Creates a new space writing the genesis credentials to the control feed.
|
|
3621
3694
|
*/
|
|
3622
3695
|
async createSpace() {
|
|
3623
|
-
(0,
|
|
3696
|
+
(0, import_invariant12.invariant)(this._isOpen, "Not open.", {
|
|
3624
3697
|
F: __dxlog_file13,
|
|
3625
3698
|
L: 130,
|
|
3626
3699
|
S: this,
|
|
@@ -3649,12 +3722,15 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
3649
3722
|
});
|
|
3650
3723
|
const space = await this._constructSpace(metadata);
|
|
3651
3724
|
const automergeRoot = this._automergeHost.repo.create();
|
|
3725
|
+
automergeRoot.change((doc) => {
|
|
3726
|
+
doc.experimental_spaceKey = spaceKey.toHex();
|
|
3727
|
+
});
|
|
3652
3728
|
const credentials = await spaceGenesis(this._keyring, this._signingContext, space.inner, automergeRoot.url);
|
|
3653
3729
|
await this._metadataStore.addSpace(metadata);
|
|
3654
3730
|
const memberCredential = credentials[1];
|
|
3655
|
-
(0,
|
|
3731
|
+
(0, import_invariant12.invariant)((0, import_credentials12.getCredentialAssertion)(memberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
|
|
3656
3732
|
F: __dxlog_file13,
|
|
3657
|
-
L:
|
|
3733
|
+
L: 154,
|
|
3658
3734
|
S: this,
|
|
3659
3735
|
A: [
|
|
3660
3736
|
"getCredentialAssertion(memberCredential)['@type'] === 'dxos.halo.credentials.SpaceMember'",
|
|
@@ -3672,22 +3748,22 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
3672
3748
|
opts
|
|
3673
3749
|
}, {
|
|
3674
3750
|
F: __dxlog_file13,
|
|
3675
|
-
L:
|
|
3751
|
+
L: 166,
|
|
3676
3752
|
S: this,
|
|
3677
3753
|
C: (f, a) => f(...a)
|
|
3678
3754
|
});
|
|
3679
|
-
(0,
|
|
3755
|
+
(0, import_invariant12.invariant)(this._isOpen, "Not open.", {
|
|
3680
3756
|
F: __dxlog_file13,
|
|
3681
|
-
L:
|
|
3757
|
+
L: 167,
|
|
3682
3758
|
S: this,
|
|
3683
3759
|
A: [
|
|
3684
3760
|
"this._isOpen",
|
|
3685
3761
|
"'Not open.'"
|
|
3686
3762
|
]
|
|
3687
3763
|
});
|
|
3688
|
-
(0,
|
|
3764
|
+
(0, import_invariant12.invariant)(!this._spaces.has(opts.spaceKey), "Space already exists.", {
|
|
3689
3765
|
F: __dxlog_file13,
|
|
3690
|
-
L:
|
|
3766
|
+
L: 168,
|
|
3691
3767
|
S: this,
|
|
3692
3768
|
A: [
|
|
3693
3769
|
"!this._spaces.has(opts.spaceKey)",
|
|
@@ -3722,7 +3798,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
3722
3798
|
metadata
|
|
3723
3799
|
}, {
|
|
3724
3800
|
F: __dxlog_file13,
|
|
3725
|
-
L:
|
|
3801
|
+
L: 201,
|
|
3726
3802
|
S: this,
|
|
3727
3803
|
C: (f, a) => f(...a)
|
|
3728
3804
|
});
|
|
@@ -3749,17 +3825,18 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
3749
3825
|
credentialProvider: createAuthProvider(this._signingContext.credentialSigner),
|
|
3750
3826
|
credentialAuthenticator: (0, import_util6.deferFunction)(() => dataSpace.authVerifier.verifier)
|
|
3751
3827
|
},
|
|
3752
|
-
|
|
3828
|
+
onAuthorizedConnection: (session) => {
|
|
3753
3829
|
session.addExtension("dxos.mesh.teleport.gossip", gossip.createExtension({
|
|
3754
3830
|
remotePeerId: session.remotePeerId
|
|
3755
3831
|
}));
|
|
3756
3832
|
session.addExtension("dxos.mesh.teleport.notarization", dataSpace.notarizationPlugin.createExtension());
|
|
3833
|
+
this._automergeHost.authorizeDevice(space.key, session.remotePeerId);
|
|
3757
3834
|
session.addExtension("dxos.mesh.teleport.automerge", this._automergeHost.createExtension());
|
|
3758
3835
|
},
|
|
3759
3836
|
onAuthFailure: () => {
|
|
3760
3837
|
import_log11.log.warn("auth failure", void 0, {
|
|
3761
3838
|
F: __dxlog_file13,
|
|
3762
|
-
L:
|
|
3839
|
+
L: 238,
|
|
3763
3840
|
S: this,
|
|
3764
3841
|
C: (f, a) => f(...a)
|
|
3765
3842
|
});
|
|
@@ -3783,7 +3860,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
3783
3860
|
space: space.key
|
|
3784
3861
|
}, {
|
|
3785
3862
|
F: __dxlog_file13,
|
|
3786
|
-
L:
|
|
3863
|
+
L: 256,
|
|
3787
3864
|
S: this,
|
|
3788
3865
|
C: (f, a) => f(...a)
|
|
3789
3866
|
});
|
|
@@ -3795,7 +3872,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
3795
3872
|
open: this._isOpen
|
|
3796
3873
|
}, {
|
|
3797
3874
|
F: __dxlog_file13,
|
|
3798
|
-
L:
|
|
3875
|
+
L: 263,
|
|
3799
3876
|
S: this,
|
|
3800
3877
|
C: (f, a) => f(...a)
|
|
3801
3878
|
});
|
|
@@ -3808,7 +3885,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
3808
3885
|
space: space.key
|
|
3809
3886
|
}, {
|
|
3810
3887
|
F: __dxlog_file13,
|
|
3811
|
-
L:
|
|
3888
|
+
L: 269,
|
|
3812
3889
|
S: this,
|
|
3813
3890
|
C: (f, a) => f(...a)
|
|
3814
3891
|
});
|
|
@@ -3856,7 +3933,7 @@ var SpacesServiceImpl = class {
|
|
|
3856
3933
|
}
|
|
3857
3934
|
async createSpace() {
|
|
3858
3935
|
if (!this._identityManager.identity) {
|
|
3859
|
-
throw new Error("This device has no HALO identity available. See https://docs.dxos.org/guide/halo");
|
|
3936
|
+
throw new Error("This device has no HALO identity available. See https://docs.dxos.org/guide/platform/halo");
|
|
3860
3937
|
}
|
|
3861
3938
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
3862
3939
|
const space = await dataSpaceManager.createSpace();
|
|
@@ -3864,7 +3941,7 @@ var SpacesServiceImpl = class {
|
|
|
3864
3941
|
}
|
|
3865
3942
|
async updateSpace({ spaceKey, state }) {
|
|
3866
3943
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
3867
|
-
const space = dataSpaceManager.spaces.get(spaceKey) ?? (0, import_debug6.raise)(new
|
|
3944
|
+
const space = dataSpaceManager.spaces.get(spaceKey) ?? (0, import_debug6.raise)(new import_protocols11.SpaceNotFoundError(spaceKey));
|
|
3868
3945
|
if (state) {
|
|
3869
3946
|
switch (state) {
|
|
3870
3947
|
case import_services9.SpaceState.ACTIVE:
|
|
@@ -3874,7 +3951,7 @@ var SpacesServiceImpl = class {
|
|
|
3874
3951
|
await space.deactivate();
|
|
3875
3952
|
break;
|
|
3876
3953
|
default:
|
|
3877
|
-
throw new
|
|
3954
|
+
throw new import_protocols11.ApiError("Invalid space state");
|
|
3878
3955
|
}
|
|
3879
3956
|
}
|
|
3880
3957
|
}
|
|
@@ -3929,14 +4006,14 @@ var SpacesServiceImpl = class {
|
|
|
3929
4006
|
}
|
|
3930
4007
|
async postMessage({ spaceKey, channel, message }) {
|
|
3931
4008
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
3932
|
-
const space = dataSpaceManager.spaces.get(spaceKey) ?? (0, import_debug6.raise)(new
|
|
4009
|
+
const space = dataSpaceManager.spaces.get(spaceKey) ?? (0, import_debug6.raise)(new import_protocols11.SpaceNotFoundError(spaceKey));
|
|
3933
4010
|
await space.postMessage(getChannelId(channel), message);
|
|
3934
4011
|
}
|
|
3935
4012
|
subscribeMessages({ spaceKey, channel }) {
|
|
3936
4013
|
return new import_codec_protobuf11.Stream(({ ctx, next }) => {
|
|
3937
4014
|
(0, import_async13.scheduleTask)(ctx, async () => {
|
|
3938
4015
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
3939
|
-
const space = dataSpaceManager.spaces.get(spaceKey) ?? (0, import_debug6.raise)(new
|
|
4016
|
+
const space = dataSpaceManager.spaces.get(spaceKey) ?? (0, import_debug6.raise)(new import_protocols11.SpaceNotFoundError(spaceKey));
|
|
3940
4017
|
const handle = space.listen(getChannelId(channel), (message) => {
|
|
3941
4018
|
next(message);
|
|
3942
4019
|
});
|
|
@@ -3946,7 +4023,7 @@ var SpacesServiceImpl = class {
|
|
|
3946
4023
|
}
|
|
3947
4024
|
queryCredentials({ spaceKey, noTail }) {
|
|
3948
4025
|
return new import_codec_protobuf11.Stream(({ ctx, next, close }) => {
|
|
3949
|
-
const space = this._spaceManager.spaces.get(spaceKey) ?? (0, import_debug6.raise)(new
|
|
4026
|
+
const space = this._spaceManager.spaces.get(spaceKey) ?? (0, import_debug6.raise)(new import_protocols11.SpaceNotFoundError(spaceKey));
|
|
3950
4027
|
const processor = {
|
|
3951
4028
|
processCredential: async (credential) => {
|
|
3952
4029
|
next(credential);
|
|
@@ -3962,7 +4039,7 @@ var SpacesServiceImpl = class {
|
|
|
3962
4039
|
});
|
|
3963
4040
|
}
|
|
3964
4041
|
async writeCredentials({ spaceKey, credentials }) {
|
|
3965
|
-
const space = this._spaceManager.spaces.get(spaceKey) ?? (0, import_debug6.raise)(new
|
|
4042
|
+
const space = this._spaceManager.spaces.get(spaceKey) ?? (0, import_debug6.raise)(new import_protocols11.SpaceNotFoundError(spaceKey));
|
|
3966
4043
|
for (const credential of credentials ?? []) {
|
|
3967
4044
|
if (credential.proof) {
|
|
3968
4045
|
await space.controlPipeline.writer.write({
|
|
@@ -3971,7 +4048,7 @@ var SpacesServiceImpl = class {
|
|
|
3971
4048
|
}
|
|
3972
4049
|
});
|
|
3973
4050
|
} else {
|
|
3974
|
-
(0,
|
|
4051
|
+
(0, import_invariant13.invariant)(!credential.id, "Id on unsigned credentials is not allowed", {
|
|
3975
4052
|
F: __dxlog_file14,
|
|
3976
4053
|
L: 168,
|
|
3977
4054
|
S: this,
|
|
@@ -3980,7 +4057,7 @@ var SpacesServiceImpl = class {
|
|
|
3980
4057
|
"'Id on unsigned credentials is not allowed'"
|
|
3981
4058
|
]
|
|
3982
4059
|
});
|
|
3983
|
-
(0,
|
|
4060
|
+
(0, import_invariant13.invariant)(this._identityManager.identity, "Identity is not available", {
|
|
3984
4061
|
F: __dxlog_file14,
|
|
3985
4062
|
L: 169,
|
|
3986
4063
|
S: this,
|
|
@@ -3990,7 +4067,7 @@ var SpacesServiceImpl = class {
|
|
|
3990
4067
|
]
|
|
3991
4068
|
});
|
|
3992
4069
|
const signer = this._identityManager.identity.getIdentityCredentialSigner();
|
|
3993
|
-
(0,
|
|
4070
|
+
(0, import_invariant13.invariant)(credential.issuer.equals(signer.getIssuer()), void 0, {
|
|
3994
4071
|
F: __dxlog_file14,
|
|
3995
4072
|
L: 171,
|
|
3996
4073
|
S: this,
|
|
@@ -4013,14 +4090,14 @@ var SpacesServiceImpl = class {
|
|
|
4013
4090
|
}
|
|
4014
4091
|
async createEpoch({ spaceKey }) {
|
|
4015
4092
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
4016
|
-
const space = dataSpaceManager.spaces.get(spaceKey) ?? (0, import_debug6.raise)(new
|
|
4093
|
+
const space = dataSpaceManager.spaces.get(spaceKey) ?? (0, import_debug6.raise)(new import_protocols11.SpaceNotFoundError(spaceKey));
|
|
4017
4094
|
await space.createEpoch();
|
|
4018
4095
|
}
|
|
4019
4096
|
_serializeSpace(space) {
|
|
4020
4097
|
return {
|
|
4021
4098
|
spaceKey: space.key,
|
|
4022
4099
|
state: space.state,
|
|
4023
|
-
error: space.error ? (0,
|
|
4100
|
+
error: space.error ? (0, import_protocols11.encodeError)(space.error) : void 0,
|
|
4024
4101
|
pipeline: {
|
|
4025
4102
|
currentEpoch: space.dataPipeline.currentEpoch,
|
|
4026
4103
|
appliedEpoch: space.dataPipeline.appliedEpoch,
|
|
@@ -4069,7 +4146,7 @@ function _ts_decorate6(decorators, target, key, desc) {
|
|
|
4069
4146
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4070
4147
|
}
|
|
4071
4148
|
var __dxlog_file15 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-context.ts";
|
|
4072
|
-
var ServiceContext = class
|
|
4149
|
+
var ServiceContext = class {
|
|
4073
4150
|
constructor(storage, networkManager, signalManager, modelFactory) {
|
|
4074
4151
|
this.storage = storage;
|
|
4075
4152
|
this.networkManager = networkManager;
|
|
@@ -4114,7 +4191,7 @@ var ServiceContext = class ServiceContext2 {
|
|
|
4114
4191
|
S: this,
|
|
4115
4192
|
C: (f, a) => f(...a)
|
|
4116
4193
|
});
|
|
4117
|
-
import_log13.log.trace("dxos.sdk.service-context.open",
|
|
4194
|
+
import_log13.log.trace("dxos.sdk.service-context.open", import_protocols12.trace.begin({
|
|
4118
4195
|
id: this._instanceId
|
|
4119
4196
|
}), {
|
|
4120
4197
|
F: __dxlog_file15,
|
|
@@ -4130,7 +4207,7 @@ var ServiceContext = class ServiceContext2 {
|
|
|
4130
4207
|
if (this.identityManager.identity) {
|
|
4131
4208
|
await this._initialize(ctx);
|
|
4132
4209
|
}
|
|
4133
|
-
import_log13.log.trace("dxos.sdk.service-context.open",
|
|
4210
|
+
import_log13.log.trace("dxos.sdk.service-context.open", import_protocols12.trace.end({
|
|
4134
4211
|
id: this._instanceId
|
|
4135
4212
|
}), {
|
|
4136
4213
|
F: __dxlog_file15,
|
|
@@ -4178,7 +4255,7 @@ var ServiceContext = class ServiceContext2 {
|
|
|
4178
4255
|
}
|
|
4179
4256
|
getInvitationHandler(invitation) {
|
|
4180
4257
|
const factory = this._handlerFactories.get(invitation.kind);
|
|
4181
|
-
(0,
|
|
4258
|
+
(0, import_invariant14.invariant)(factory, `Unknown invitation kind: ${invitation.kind}`, {
|
|
4182
4259
|
F: __dxlog_file15,
|
|
4183
4260
|
L: 173,
|
|
4184
4261
|
S: this,
|
|
@@ -4204,8 +4281,8 @@ var ServiceContext = class ServiceContext2 {
|
|
|
4204
4281
|
}
|
|
4205
4282
|
async _checkStorageVersion() {
|
|
4206
4283
|
await this.metadataStore.load();
|
|
4207
|
-
if (this.metadataStore.version !==
|
|
4208
|
-
throw new
|
|
4284
|
+
if (this.metadataStore.version !== import_protocols12.STORAGE_VERSION) {
|
|
4285
|
+
throw new import_protocols12.InvalidStorageVersionError(import_protocols12.STORAGE_VERSION, this.metadataStore.version);
|
|
4209
4286
|
}
|
|
4210
4287
|
}
|
|
4211
4288
|
// Called when identity is created.
|
|
@@ -4233,7 +4310,7 @@ var ServiceContext = class ServiceContext2 {
|
|
|
4233
4310
|
this.dataSpaceManager = new DataSpaceManager(this.spaceManager, this.metadataStore, this.dataServiceSubscriptions, this.keyring, signingContext, this.feedStore, this.automergeHost);
|
|
4234
4311
|
await this.dataSpaceManager.open();
|
|
4235
4312
|
this._handlerFactories.set(import_services10.Invitation.Kind.SPACE, (invitation) => {
|
|
4236
|
-
(0,
|
|
4313
|
+
(0, import_invariant14.invariant)(this.dataSpaceManager, "dataSpaceManager not initialized yet", {
|
|
4237
4314
|
F: __dxlog_file15,
|
|
4238
4315
|
L: 228,
|
|
4239
4316
|
S: this,
|
|
@@ -4372,7 +4449,7 @@ var Lock = class {
|
|
|
4372
4449
|
}
|
|
4373
4450
|
async release() {
|
|
4374
4451
|
await this._onRelease?.();
|
|
4375
|
-
(0,
|
|
4452
|
+
(0, import_invariant15.invariant)(this._fileHandle, "Lock is not acquired", {
|
|
4376
4453
|
F: __dxlog_file16,
|
|
4377
4454
|
L: 42,
|
|
4378
4455
|
S: this,
|
|
@@ -4392,16 +4469,16 @@ var StorageDriver = import_config.Runtime.Client.Storage.StorageDriver;
|
|
|
4392
4469
|
var createStorageObjects = (config) => {
|
|
4393
4470
|
const { persistent = false, keyStore, dataStore, dataRoot = (0, import_util8.isNode)() ? import_client_protocol4.DX_DATA : "dxos/storage" } = config ?? {};
|
|
4394
4471
|
if (persistent && dataStore === StorageDriver.RAM) {
|
|
4395
|
-
throw new
|
|
4472
|
+
throw new import_protocols13.InvalidConfigError("RAM storage cannot be used in persistent mode.");
|
|
4396
4473
|
}
|
|
4397
4474
|
if (!persistent && dataStore !== void 0 && dataStore !== StorageDriver.RAM) {
|
|
4398
|
-
throw new
|
|
4475
|
+
throw new import_protocols13.InvalidConfigError("Cannot use a persistent storage in not persistent mode.");
|
|
4399
4476
|
}
|
|
4400
4477
|
if (persistent && keyStore === StorageDriver.RAM) {
|
|
4401
|
-
throw new
|
|
4478
|
+
throw new import_protocols13.InvalidConfigError("RAM key storage cannot be used in persistent mode.");
|
|
4402
4479
|
}
|
|
4403
4480
|
if (!persistent && keyStore !== StorageDriver.RAM && keyStore !== void 0) {
|
|
4404
|
-
throw new
|
|
4481
|
+
throw new import_protocols13.InvalidConfigError("Cannot use a persistent key storage in not persistent mode.");
|
|
4405
4482
|
}
|
|
4406
4483
|
return {
|
|
4407
4484
|
storage: (0, import_random_access_storage.createStorage)({
|
|
@@ -4683,7 +4760,7 @@ var createGenesisMutationFromTypedObject = (obj) => {
|
|
|
4683
4760
|
}
|
|
4684
4761
|
};
|
|
4685
4762
|
};
|
|
4686
|
-
var ClientServicesHost = class
|
|
4763
|
+
var ClientServicesHost = class {
|
|
4687
4764
|
constructor({
|
|
4688
4765
|
config,
|
|
4689
4766
|
modelFactory = createDefaultModelFactory(),
|
|
@@ -4767,7 +4844,7 @@ var ClientServicesHost = class ClientServicesHost2 {
|
|
|
4767
4844
|
* Can only be called once.
|
|
4768
4845
|
*/
|
|
4769
4846
|
initialize({ config, ...options }) {
|
|
4770
|
-
(0,
|
|
4847
|
+
(0, import_invariant16.invariant)(!this._open, "service host is open", {
|
|
4771
4848
|
F: __dxlog_file17,
|
|
4772
4849
|
L: 201,
|
|
4773
4850
|
S: this,
|
|
@@ -4783,7 +4860,7 @@ var ClientServicesHost = class ClientServicesHost2 {
|
|
|
4783
4860
|
C: (f, a) => f(...a)
|
|
4784
4861
|
});
|
|
4785
4862
|
if (config) {
|
|
4786
|
-
(0,
|
|
4863
|
+
(0, import_invariant16.invariant)(!this._config, "config already set", {
|
|
4787
4864
|
F: __dxlog_file17,
|
|
4788
4865
|
L: 205,
|
|
4789
4866
|
S: this,
|
|
@@ -4801,7 +4878,7 @@ var ClientServicesHost = class ClientServicesHost2 {
|
|
|
4801
4878
|
iceServers: this._config?.get("runtime.services.ice")
|
|
4802
4879
|
}), signalManager = new import_messaging.WebsocketSignalManager(this._config?.get("runtime.services.signaling") ?? []) } = options;
|
|
4803
4880
|
this._signalManager = signalManager;
|
|
4804
|
-
(0,
|
|
4881
|
+
(0, import_invariant16.invariant)(!this._networkManager, "network manager already set", {
|
|
4805
4882
|
F: __dxlog_file17,
|
|
4806
4883
|
L: 221,
|
|
4807
4884
|
S: this,
|
|
@@ -4827,7 +4904,7 @@ var ClientServicesHost = class ClientServicesHost2 {
|
|
|
4827
4904
|
return;
|
|
4828
4905
|
}
|
|
4829
4906
|
const traceId = import_keys11.PublicKey.random().toHex();
|
|
4830
|
-
import_log15.log.trace("dxos.client-services.host.open",
|
|
4907
|
+
import_log15.log.trace("dxos.client-services.host.open", import_protocols14.trace.begin({
|
|
4831
4908
|
id: traceId
|
|
4832
4909
|
}), {
|
|
4833
4910
|
F: __dxlog_file17,
|
|
@@ -4835,7 +4912,7 @@ var ClientServicesHost = class ClientServicesHost2 {
|
|
|
4835
4912
|
S: this,
|
|
4836
4913
|
C: (f, a) => f(...a)
|
|
4837
4914
|
});
|
|
4838
|
-
(0,
|
|
4915
|
+
(0, import_invariant16.invariant)(this._config, "config not set", {
|
|
4839
4916
|
F: __dxlog_file17,
|
|
4840
4917
|
L: 241,
|
|
4841
4918
|
S: this,
|
|
@@ -4844,7 +4921,7 @@ var ClientServicesHost = class ClientServicesHost2 {
|
|
|
4844
4921
|
"'config not set'"
|
|
4845
4922
|
]
|
|
4846
4923
|
});
|
|
4847
|
-
(0,
|
|
4924
|
+
(0, import_invariant16.invariant)(this._storage, "storage not set", {
|
|
4848
4925
|
F: __dxlog_file17,
|
|
4849
4926
|
L: 242,
|
|
4850
4927
|
S: this,
|
|
@@ -4853,7 +4930,7 @@ var ClientServicesHost = class ClientServicesHost2 {
|
|
|
4853
4930
|
"'storage not set'"
|
|
4854
4931
|
]
|
|
4855
4932
|
});
|
|
4856
|
-
(0,
|
|
4933
|
+
(0, import_invariant16.invariant)(this._signalManager, "signal manager not set", {
|
|
4857
4934
|
F: __dxlog_file17,
|
|
4858
4935
|
L: 243,
|
|
4859
4936
|
S: this,
|
|
@@ -4862,7 +4939,7 @@ var ClientServicesHost = class ClientServicesHost2 {
|
|
|
4862
4939
|
"'signal manager not set'"
|
|
4863
4940
|
]
|
|
4864
4941
|
});
|
|
4865
|
-
(0,
|
|
4942
|
+
(0, import_invariant16.invariant)(this._networkManager, "network manager not set", {
|
|
4866
4943
|
F: __dxlog_file17,
|
|
4867
4944
|
L: 244,
|
|
4868
4945
|
S: this,
|
|
@@ -4885,7 +4962,7 @@ var ClientServicesHost = class ClientServicesHost2 {
|
|
|
4885
4962
|
this._serviceContext = new ServiceContext(this._storage, this._networkManager, this._signalManager, this._modelFactory);
|
|
4886
4963
|
this._serviceRegistry.setServices({
|
|
4887
4964
|
SystemService: this._systemService,
|
|
4888
|
-
IdentityService: new IdentityServiceImpl((params) => this._createIdentity(params), this._serviceContext.identityManager, this._serviceContext.keyring, (profile) => this._serviceContext.broadcastProfileUpdate(profile)),
|
|
4965
|
+
IdentityService: new IdentityServiceImpl((params, useAutomerge) => this._createIdentity(params, useAutomerge), this._serviceContext.identityManager, this._serviceContext.keyring, (profile) => this._serviceContext.broadcastProfileUpdate(profile)),
|
|
4889
4966
|
InvitationsService: new InvitationsServiceImpl(this._serviceContext.invitations, (invitation) => this._serviceContext.getInvitationHandler(invitation)),
|
|
4890
4967
|
DevicesService: new DevicesServiceImpl(this._serviceContext.identityManager),
|
|
4891
4968
|
SpacesService: new SpacesServiceImpl(this._serviceContext.identityManager, this._serviceContext.spaceManager, this._serviceContext.dataServiceSubscriptions, async () => {
|
|
@@ -4926,7 +5003,7 @@ var ClientServicesHost = class ClientServicesHost2 {
|
|
|
4926
5003
|
S: this,
|
|
4927
5004
|
C: (f, a) => f(...a)
|
|
4928
5005
|
});
|
|
4929
|
-
import_log15.log.trace("dxos.client-services.host.open",
|
|
5006
|
+
import_log15.log.trace("dxos.client-services.host.open", import_protocols14.trace.end({
|
|
4930
5007
|
id: traceId
|
|
4931
5008
|
}), {
|
|
4932
5009
|
F: __dxlog_file17,
|
|
@@ -4967,7 +5044,7 @@ var ClientServicesHost = class ClientServicesHost2 {
|
|
|
4967
5044
|
}
|
|
4968
5045
|
async reset() {
|
|
4969
5046
|
const traceId = import_keys11.PublicKey.random().toHex();
|
|
4970
|
-
import_log15.log.trace("dxos.sdk.client-services-host.reset",
|
|
5047
|
+
import_log15.log.trace("dxos.sdk.client-services-host.reset", import_protocols14.trace.begin({
|
|
4971
5048
|
id: traceId
|
|
4972
5049
|
}), {
|
|
4973
5050
|
F: __dxlog_file17,
|
|
@@ -4989,7 +5066,7 @@ var ClientServicesHost = class ClientServicesHost2 {
|
|
|
4989
5066
|
S: this,
|
|
4990
5067
|
C: (f, a) => f(...a)
|
|
4991
5068
|
});
|
|
4992
|
-
import_log15.log.trace("dxos.sdk.client-services-host.reset",
|
|
5069
|
+
import_log15.log.trace("dxos.sdk.client-services-host.reset", import_protocols14.trace.end({
|
|
4993
5070
|
id: traceId
|
|
4994
5071
|
}), {
|
|
4995
5072
|
F: __dxlog_file17,
|
|
@@ -4999,25 +5076,44 @@ var ClientServicesHost = class ClientServicesHost2 {
|
|
|
4999
5076
|
});
|
|
5000
5077
|
await this._callbacks?.onReset?.();
|
|
5001
5078
|
}
|
|
5002
|
-
async _createIdentity(params) {
|
|
5079
|
+
async _createIdentity(params, useAutomerge) {
|
|
5003
5080
|
const identity = await this._serviceContext.createIdentity(params);
|
|
5004
5081
|
await this._serviceContext.initialized.wait();
|
|
5005
5082
|
const space = await this._serviceContext.dataSpaceManager.createSpace();
|
|
5006
5083
|
const obj = new import_client_protocol5.Properties(void 0, {
|
|
5007
|
-
automerge:
|
|
5084
|
+
automerge: useAutomerge
|
|
5008
5085
|
});
|
|
5009
5086
|
obj[import_client_protocol5.defaultKey] = identity.identityKey.toHex();
|
|
5010
|
-
|
|
5011
|
-
|
|
5012
|
-
|
|
5013
|
-
|
|
5014
|
-
|
|
5087
|
+
if (!useAutomerge) {
|
|
5088
|
+
await this._serviceRegistry.services.DataService.write({
|
|
5089
|
+
spaceKey: space.key,
|
|
5090
|
+
batch: {
|
|
5091
|
+
objects: [
|
|
5092
|
+
createGenesisMutationFromTypedObject(obj)
|
|
5093
|
+
]
|
|
5094
|
+
}
|
|
5095
|
+
});
|
|
5096
|
+
await this._serviceRegistry.services.DataService.flush({
|
|
5097
|
+
spaceKey: space.key
|
|
5098
|
+
});
|
|
5099
|
+
} else {
|
|
5100
|
+
const automergeIndex = space.automergeSpaceState.rootUrl;
|
|
5101
|
+
(0, import_invariant16.invariant)(automergeIndex, void 0, {
|
|
5102
|
+
F: __dxlog_file17,
|
|
5103
|
+
L: 375,
|
|
5104
|
+
S: this,
|
|
5105
|
+
A: [
|
|
5106
|
+
"automergeIndex",
|
|
5107
|
+
""
|
|
5015
5108
|
]
|
|
5016
|
-
}
|
|
5017
|
-
|
|
5018
|
-
|
|
5019
|
-
|
|
5020
|
-
|
|
5109
|
+
});
|
|
5110
|
+
const document = await this._serviceContext.automergeHost.repo.find(automergeIndex);
|
|
5111
|
+
await document.whenReady();
|
|
5112
|
+
document.change((doc) => {
|
|
5113
|
+
doc.objects ??= {};
|
|
5114
|
+
doc.objects[obj[import_echo_schema.base]._id] = (0, import_echo_schema.getRawDoc)(obj).handle.docSync();
|
|
5115
|
+
});
|
|
5116
|
+
}
|
|
5021
5117
|
return identity;
|
|
5022
5118
|
}
|
|
5023
5119
|
};
|
|
@@ -5072,4 +5168,4 @@ ClientServicesHost = _ts_decorate8([
|
|
|
5072
5168
|
subscribeToSpaces,
|
|
5073
5169
|
subscribeToSwarmInfo
|
|
5074
5170
|
});
|
|
5075
|
-
//# sourceMappingURL=chunk-
|
|
5171
|
+
//# sourceMappingURL=chunk-S5IK5PCE.cjs.map
|