@dxos/client-services 0.3.11-main.dafb7f2 → 0.3.11-main.df1e30a
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-TFTFBP6C.mjs → chunk-NA7EQA7E.mjs} +200 -103
- package/dist/lib/browser/chunk-NA7EQA7E.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-Y77542J4.cjs → chunk-LTQYCVFH.cjs} +283 -186
- package/dist/lib/node/chunk-LTQYCVFH.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 +20 -18
- 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-TFTFBP6C.mjs.map +0 -7
- package/dist/lib/node/chunk-Y77542J4.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_LTQYCVFH_exports = {};
|
|
30
|
+
__export(chunk_LTQYCVFH_exports, {
|
|
31
31
|
ClientRpcServer: () => ClientRpcServer,
|
|
32
32
|
ClientServicesHost: () => ClientServicesHost,
|
|
33
33
|
DataSpace: () => DataSpace,
|
|
@@ -60,7 +60,7 @@ __export(chunk_Y77542J4_exports, {
|
|
|
60
60
|
subscribeToSpaces: () => subscribeToSpaces,
|
|
61
61
|
subscribeToSwarmInfo: () => subscribeToSwarmInfo
|
|
62
62
|
});
|
|
63
|
-
module.exports = __toCommonJS(
|
|
63
|
+
module.exports = __toCommonJS(chunk_LTQYCVFH_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,19 +2113,20 @@ 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
|
});
|
|
2111
2120
|
setState({
|
|
2112
2121
|
...result,
|
|
2122
|
+
target: invitation.target,
|
|
2113
2123
|
state: import_services2.Invitation.State.SUCCESS
|
|
2114
2124
|
});
|
|
2115
|
-
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({
|
|
2116
2126
|
id: traceId
|
|
2117
2127
|
}), {
|
|
2118
2128
|
F: __dxlog_file7,
|
|
2119
|
-
L:
|
|
2129
|
+
L: 322,
|
|
2120
2130
|
S: this,
|
|
2121
2131
|
C: (f, a) => f(...a)
|
|
2122
2132
|
});
|
|
@@ -2126,7 +2136,7 @@ var InvitationsHandler = class {
|
|
|
2126
2136
|
...protocol.toJSON()
|
|
2127
2137
|
}, {
|
|
2128
2138
|
F: __dxlog_file7,
|
|
2129
|
-
L:
|
|
2139
|
+
L: 325,
|
|
2130
2140
|
S: this,
|
|
2131
2141
|
C: (f, a) => f(...a)
|
|
2132
2142
|
});
|
|
@@ -2136,18 +2146,18 @@ var InvitationsHandler = class {
|
|
|
2136
2146
|
} else {
|
|
2137
2147
|
(0, import_log4.log)("auth failed", err, {
|
|
2138
2148
|
F: __dxlog_file7,
|
|
2139
|
-
L:
|
|
2149
|
+
L: 328,
|
|
2140
2150
|
S: this,
|
|
2141
2151
|
C: (f, a) => f(...a)
|
|
2142
2152
|
});
|
|
2143
2153
|
stream.error(err);
|
|
2144
2154
|
}
|
|
2145
|
-
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({
|
|
2146
2156
|
id: traceId,
|
|
2147
2157
|
error: err
|
|
2148
2158
|
}), {
|
|
2149
2159
|
F: __dxlog_file7,
|
|
2150
|
-
L:
|
|
2160
|
+
L: 331,
|
|
2151
2161
|
S: this,
|
|
2152
2162
|
C: (f, a) => f(...a)
|
|
2153
2163
|
});
|
|
@@ -2157,7 +2167,7 @@ var InvitationsHandler = class {
|
|
|
2157
2167
|
});
|
|
2158
2168
|
},
|
|
2159
2169
|
onError: (err) => {
|
|
2160
|
-
if (err instanceof
|
|
2170
|
+
if (err instanceof import_protocols4.InvalidInvitationExtensionRoleError) {
|
|
2161
2171
|
return;
|
|
2162
2172
|
}
|
|
2163
2173
|
if (err instanceof import_async7.TimeoutError) {
|
|
@@ -2165,7 +2175,7 @@ var InvitationsHandler = class {
|
|
|
2165
2175
|
...protocol.toJSON()
|
|
2166
2176
|
}, {
|
|
2167
2177
|
F: __dxlog_file7,
|
|
2168
|
-
L:
|
|
2178
|
+
L: 342,
|
|
2169
2179
|
S: this,
|
|
2170
2180
|
C: (f, a) => f(...a)
|
|
2171
2181
|
});
|
|
@@ -2175,7 +2185,7 @@ var InvitationsHandler = class {
|
|
|
2175
2185
|
} else {
|
|
2176
2186
|
(0, import_log4.log)("auth failed", err, {
|
|
2177
2187
|
F: __dxlog_file7,
|
|
2178
|
-
L:
|
|
2188
|
+
L: 345,
|
|
2179
2189
|
S: this,
|
|
2180
2190
|
C: (f, a) => f(...a)
|
|
2181
2191
|
});
|
|
@@ -2186,29 +2196,34 @@ var InvitationsHandler = class {
|
|
|
2186
2196
|
return extension;
|
|
2187
2197
|
};
|
|
2188
2198
|
(0, import_async7.scheduleTask)(ctx, async () => {
|
|
2189
|
-
|
|
2190
|
-
|
|
2191
|
-
|
|
2192
|
-
|
|
2193
|
-
|
|
2194
|
-
|
|
2195
|
-
|
|
2196
|
-
|
|
2197
|
-
|
|
2198
|
-
|
|
2199
|
-
|
|
2200
|
-
|
|
2201
|
-
|
|
2202
|
-
|
|
2203
|
-
|
|
2204
|
-
|
|
2205
|
-
|
|
2206
|
-
|
|
2207
|
-
|
|
2208
|
-
|
|
2209
|
-
|
|
2210
|
-
|
|
2211
|
-
|
|
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
|
+
}
|
|
2212
2227
|
});
|
|
2213
2228
|
const observable = new import_client_protocol2.AuthenticatingInvitation({
|
|
2214
2229
|
initialInvitation: invitation,
|
|
@@ -2424,7 +2439,7 @@ var SpaceInvitationProtocol = class {
|
|
|
2424
2439
|
async admit(request, guestProfile) {
|
|
2425
2440
|
(0, import_invariant8.invariant)(this._spaceKey, void 0, {
|
|
2426
2441
|
F: __dxlog_file9,
|
|
2427
|
-
L:
|
|
2442
|
+
L: 47,
|
|
2428
2443
|
S: this,
|
|
2429
2444
|
A: [
|
|
2430
2445
|
"this._spaceKey",
|
|
@@ -2434,7 +2449,7 @@ var SpaceInvitationProtocol = class {
|
|
|
2434
2449
|
const space = await this._spaceManager.spaces.get(this._spaceKey);
|
|
2435
2450
|
(0, import_invariant8.invariant)(space, void 0, {
|
|
2436
2451
|
F: __dxlog_file9,
|
|
2437
|
-
L:
|
|
2452
|
+
L: 49,
|
|
2438
2453
|
S: this,
|
|
2439
2454
|
A: [
|
|
2440
2455
|
"space",
|
|
@@ -2443,7 +2458,7 @@ var SpaceInvitationProtocol = class {
|
|
|
2443
2458
|
});
|
|
2444
2459
|
(0, import_invariant8.invariant)(request.space, void 0, {
|
|
2445
2460
|
F: __dxlog_file9,
|
|
2446
|
-
L:
|
|
2461
|
+
L: 51,
|
|
2447
2462
|
S: this,
|
|
2448
2463
|
A: [
|
|
2449
2464
|
"request.space",
|
|
@@ -2456,14 +2471,14 @@ var SpaceInvitationProtocol = class {
|
|
|
2456
2471
|
guest: deviceKey
|
|
2457
2472
|
}, {
|
|
2458
2473
|
F: __dxlog_file9,
|
|
2459
|
-
L:
|
|
2474
|
+
L: 54,
|
|
2460
2475
|
S: this,
|
|
2461
2476
|
C: (f, a) => f(...a)
|
|
2462
2477
|
});
|
|
2463
2478
|
const credentials = await (0, import_credentials8.createAdmissionCredentials)(this._signingContext.credentialSigner, identityKey, space.key, space.inner.genesisFeedKey, guestProfile);
|
|
2464
2479
|
(0, import_invariant8.invariant)(credentials[0].credential, void 0, {
|
|
2465
2480
|
F: __dxlog_file9,
|
|
2466
|
-
L:
|
|
2481
|
+
L: 65,
|
|
2467
2482
|
S: this,
|
|
2468
2483
|
A: [
|
|
2469
2484
|
"credentials[0].credential",
|
|
@@ -2473,7 +2488,7 @@ var SpaceInvitationProtocol = class {
|
|
|
2473
2488
|
const spaceMemberCredential = credentials[0].credential.credential;
|
|
2474
2489
|
(0, import_invariant8.invariant)((0, import_credentials8.getCredentialAssertion)(spaceMemberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
|
|
2475
2490
|
F: __dxlog_file9,
|
|
2476
|
-
L:
|
|
2491
|
+
L: 67,
|
|
2477
2492
|
S: this,
|
|
2478
2493
|
A: [
|
|
2479
2494
|
"getCredentialAssertion(spaceMemberCredential)['@type'] === 'dxos.halo.credentials.SpaceMember'",
|
|
@@ -2489,6 +2504,11 @@ var SpaceInvitationProtocol = class {
|
|
|
2489
2504
|
}
|
|
2490
2505
|
};
|
|
2491
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
|
+
}
|
|
2492
2512
|
createIntroduction() {
|
|
2493
2513
|
return {
|
|
2494
2514
|
profile: this._signingContext.getProfile()
|
|
@@ -2509,7 +2529,7 @@ var SpaceInvitationProtocol = class {
|
|
|
2509
2529
|
async accept(response) {
|
|
2510
2530
|
(0, import_invariant8.invariant)(response.space, void 0, {
|
|
2511
2531
|
F: __dxlog_file9,
|
|
2512
|
-
L:
|
|
2532
|
+
L: 108,
|
|
2513
2533
|
S: this,
|
|
2514
2534
|
A: [
|
|
2515
2535
|
"response.space",
|
|
@@ -2520,7 +2540,7 @@ var SpaceInvitationProtocol = class {
|
|
|
2520
2540
|
const assertion = (0, import_credentials8.getCredentialAssertion)(credential);
|
|
2521
2541
|
(0, import_invariant8.invariant)(assertion["@type"] === "dxos.halo.credentials.SpaceMember", "Invalid credential", {
|
|
2522
2542
|
F: __dxlog_file9,
|
|
2523
|
-
L:
|
|
2543
|
+
L: 111,
|
|
2524
2544
|
S: this,
|
|
2525
2545
|
A: [
|
|
2526
2546
|
"assertion['@type'] === 'dxos.halo.credentials.SpaceMember'",
|
|
@@ -2529,13 +2549,16 @@ var SpaceInvitationProtocol = class {
|
|
|
2529
2549
|
});
|
|
2530
2550
|
(0, import_invariant8.invariant)(credential.subject.id.equals(this._signingContext.identityKey), void 0, {
|
|
2531
2551
|
F: __dxlog_file9,
|
|
2532
|
-
L:
|
|
2552
|
+
L: 112,
|
|
2533
2553
|
S: this,
|
|
2534
2554
|
A: [
|
|
2535
2555
|
"credential.subject.id.equals(this._signingContext.identityKey)",
|
|
2536
2556
|
""
|
|
2537
2557
|
]
|
|
2538
2558
|
});
|
|
2559
|
+
if (this._spaceManager.spaces.has(assertion.spaceKey)) {
|
|
2560
|
+
throw new import_protocols6.AlreadyJoinedError("Already joined space.");
|
|
2561
|
+
}
|
|
2539
2562
|
await this._spaceManager.acceptSpace({
|
|
2540
2563
|
spaceKey: assertion.spaceKey,
|
|
2541
2564
|
genesisFeedKey: assertion.genesisFeedKey,
|
|
@@ -2558,7 +2581,7 @@ function _ts_decorate3(decorators, target, key, desc) {
|
|
|
2558
2581
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
2559
2582
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2560
2583
|
}
|
|
2561
|
-
var ClientRpcServer = class
|
|
2584
|
+
var ClientRpcServer = class {
|
|
2562
2585
|
constructor(params) {
|
|
2563
2586
|
this._handlerCache = /* @__PURE__ */ new Map();
|
|
2564
2587
|
this._callMetrics = new import_tracing3.MapCounter();
|
|
@@ -2649,7 +2672,7 @@ var getPlatform = () => {
|
|
|
2649
2672
|
};
|
|
2650
2673
|
}
|
|
2651
2674
|
};
|
|
2652
|
-
var DXOS_VERSION = "0.3.11-main.
|
|
2675
|
+
var DXOS_VERSION = "0.3.11-main.df1e30a";
|
|
2653
2676
|
var __dxlog_file10 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/diagnostics.ts";
|
|
2654
2677
|
var DEFAULT_TIMEOUT = 1e3;
|
|
2655
2678
|
var createDiagnostics = async (clientServices, serviceContext, config) => {
|
|
@@ -2659,14 +2682,14 @@ var createDiagnostics = async (clientServices, serviceContext, config) => {
|
|
|
2659
2682
|
client: {
|
|
2660
2683
|
version: DXOS_VERSION,
|
|
2661
2684
|
storage: {
|
|
2662
|
-
version:
|
|
2685
|
+
version: import_protocols7.STORAGE_VERSION
|
|
2663
2686
|
}
|
|
2664
2687
|
}
|
|
2665
2688
|
};
|
|
2666
2689
|
{
|
|
2667
2690
|
(0, import_invariant9.invariant)(clientServices.LoggingService, "SystemService is not available.", {
|
|
2668
2691
|
F: __dxlog_file10,
|
|
2669
|
-
L:
|
|
2692
|
+
L: 93,
|
|
2670
2693
|
S: void 0,
|
|
2671
2694
|
A: [
|
|
2672
2695
|
"clientServices.LoggingService",
|
|
@@ -2677,6 +2700,21 @@ var createDiagnostics = async (clientServices, serviceContext, config) => {
|
|
|
2677
2700
|
timeout: DEFAULT_TIMEOUT
|
|
2678
2701
|
}).catch(() => void 0);
|
|
2679
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
|
+
}
|
|
2680
2718
|
const identity = serviceContext.identityManager.identity;
|
|
2681
2719
|
if (identity) {
|
|
2682
2720
|
diagnostics.identity = {
|
|
@@ -2717,7 +2755,7 @@ var getProperties = (space) => {
|
|
|
2717
2755
|
} catch (err) {
|
|
2718
2756
|
import_log8.log.warn(err.message, void 0, {
|
|
2719
2757
|
F: __dxlog_file10,
|
|
2720
|
-
L:
|
|
2758
|
+
L: 178,
|
|
2721
2759
|
S: void 0,
|
|
2722
2760
|
C: (f, a) => f(...a)
|
|
2723
2761
|
});
|
|
@@ -2772,7 +2810,8 @@ var getSpaceStats = async (space) => {
|
|
|
2772
2810
|
return stats;
|
|
2773
2811
|
};
|
|
2774
2812
|
var AutomergeSpaceState = class {
|
|
2775
|
-
constructor() {
|
|
2813
|
+
constructor(_onNewRoot) {
|
|
2814
|
+
this._onNewRoot = _onNewRoot;
|
|
2776
2815
|
this.rootUrl = void 0;
|
|
2777
2816
|
this.lastEpoch = void 0;
|
|
2778
2817
|
}
|
|
@@ -2783,6 +2822,7 @@ var AutomergeSpaceState = class {
|
|
|
2783
2822
|
this.lastEpoch = credential;
|
|
2784
2823
|
if (credential.subject.assertion.automergeRoot) {
|
|
2785
2824
|
this.rootUrl = credential.subject.assertion.automergeRoot;
|
|
2825
|
+
this._onNewRoot(this.rootUrl);
|
|
2786
2826
|
}
|
|
2787
2827
|
}
|
|
2788
2828
|
};
|
|
@@ -2819,7 +2859,7 @@ var NotarizationPlugin = class {
|
|
|
2819
2859
|
S: this,
|
|
2820
2860
|
C: (f, a) => f(...a)
|
|
2821
2861
|
});
|
|
2822
|
-
(0,
|
|
2862
|
+
(0, import_invariant11.invariant)(credentials.every((credential) => credential.id), "Credentials must have an id", {
|
|
2823
2863
|
F: __dxlog_file11,
|
|
2824
2864
|
L: 91,
|
|
2825
2865
|
S: this,
|
|
@@ -2944,7 +2984,7 @@ var NotarizationPlugin = class {
|
|
|
2944
2984
|
this._processCredentialsTriggers.delete(credential.id);
|
|
2945
2985
|
}
|
|
2946
2986
|
setWriter(writer) {
|
|
2947
|
-
(0,
|
|
2987
|
+
(0, import_invariant11.invariant)(!this._writer, "Writer already set.", {
|
|
2948
2988
|
F: __dxlog_file11,
|
|
2949
2989
|
L: 181,
|
|
2950
2990
|
S: this,
|
|
@@ -2969,7 +3009,7 @@ var NotarizationPlugin = class {
|
|
|
2969
3009
|
throw new Error(WRITER_NOT_SET_ERROR_CODE);
|
|
2970
3010
|
}
|
|
2971
3011
|
for (const credential of request.credentials ?? []) {
|
|
2972
|
-
(0,
|
|
3012
|
+
(0, import_invariant11.invariant)(credential.id, "Credential must have an id", {
|
|
2973
3013
|
F: __dxlog_file11,
|
|
2974
3014
|
L: 200,
|
|
2975
3015
|
S: this,
|
|
@@ -3018,10 +3058,10 @@ var NotarizationTeleportExtension = class extends import_teleport2.RpcExtension
|
|
|
3018
3058
|
constructor(_params) {
|
|
3019
3059
|
super({
|
|
3020
3060
|
requested: {
|
|
3021
|
-
NotarizationService:
|
|
3061
|
+
NotarizationService: import_protocols9.schema.getService("dxos.mesh.teleport.notarization.NotarizationService")
|
|
3022
3062
|
},
|
|
3023
3063
|
exposed: {
|
|
3024
|
-
NotarizationService:
|
|
3064
|
+
NotarizationService: import_protocols9.schema.getService("dxos.mesh.teleport.notarization.NotarizationService")
|
|
3025
3065
|
}
|
|
3026
3066
|
});
|
|
3027
3067
|
this._params = _params;
|
|
@@ -3056,12 +3096,12 @@ function _ts_decorate4(decorators, target, key, desc) {
|
|
|
3056
3096
|
}
|
|
3057
3097
|
var __dxlog_file12 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space.ts";
|
|
3058
3098
|
var ENABLE_FEED_PURGE = false;
|
|
3059
|
-
var DataSpace = class
|
|
3099
|
+
var DataSpace = class {
|
|
3060
3100
|
constructor(params) {
|
|
3061
3101
|
this._ctx = new import_context6.Context();
|
|
3062
3102
|
this._notarizationPlugin = new NotarizationPlugin();
|
|
3063
3103
|
this._cache = void 0;
|
|
3064
|
-
this._automergeSpaceState = new AutomergeSpaceState();
|
|
3104
|
+
this._automergeSpaceState = new AutomergeSpaceState((rootUrl) => this._onNewAutomergeRoot(rootUrl));
|
|
3065
3105
|
this._state = import_services7.SpaceState.CLOSED;
|
|
3066
3106
|
this.error = void 0;
|
|
3067
3107
|
this.stateUpdate = new import_async10.Event();
|
|
@@ -3087,7 +3127,7 @@ var DataSpace = class DataSpace2 {
|
|
|
3087
3127
|
state: import_services7.SpaceState[this._state]
|
|
3088
3128
|
}, {
|
|
3089
3129
|
F: __dxlog_file12,
|
|
3090
|
-
L:
|
|
3130
|
+
L: 138,
|
|
3091
3131
|
S: this,
|
|
3092
3132
|
C: (f, a) => f(...a)
|
|
3093
3133
|
});
|
|
@@ -3134,7 +3174,7 @@ var DataSpace = class DataSpace2 {
|
|
|
3134
3174
|
state: import_services7.SpaceState[this._state]
|
|
3135
3175
|
}, {
|
|
3136
3176
|
F: __dxlog_file12,
|
|
3137
|
-
L:
|
|
3177
|
+
L: 190,
|
|
3138
3178
|
S: this,
|
|
3139
3179
|
C: (f, a) => f(...a)
|
|
3140
3180
|
});
|
|
@@ -3152,7 +3192,7 @@ var DataSpace = class DataSpace2 {
|
|
|
3152
3192
|
state: import_services7.SpaceState[this._state]
|
|
3153
3193
|
}, {
|
|
3154
3194
|
F: __dxlog_file12,
|
|
3155
|
-
L:
|
|
3195
|
+
L: 204,
|
|
3156
3196
|
S: this,
|
|
3157
3197
|
C: (f, a) => f(...a)
|
|
3158
3198
|
});
|
|
@@ -3181,10 +3221,10 @@ var DataSpace = class DataSpace2 {
|
|
|
3181
3221
|
this.metrics.pipelineInitBegin = /* @__PURE__ */ new Date();
|
|
3182
3222
|
await this.initializeDataPipeline();
|
|
3183
3223
|
} catch (err) {
|
|
3184
|
-
if (err instanceof
|
|
3224
|
+
if (err instanceof import_protocols8.CancelledError) {
|
|
3185
3225
|
(0, import_log9.log)("data pipeline initialization cancelled", err, {
|
|
3186
3226
|
F: __dxlog_file12,
|
|
3187
|
-
L:
|
|
3227
|
+
L: 237,
|
|
3188
3228
|
S: this,
|
|
3189
3229
|
C: (f, a) => f(...a)
|
|
3190
3230
|
});
|
|
@@ -3192,7 +3232,7 @@ var DataSpace = class DataSpace2 {
|
|
|
3192
3232
|
}
|
|
3193
3233
|
import_log9.log.error("Error initializing data pipeline", err, {
|
|
3194
3234
|
F: __dxlog_file12,
|
|
3195
|
-
L:
|
|
3235
|
+
L: 241,
|
|
3196
3236
|
S: this,
|
|
3197
3237
|
C: (f, a) => f(...a)
|
|
3198
3238
|
});
|
|
@@ -3201,7 +3241,7 @@ var DataSpace = class DataSpace2 {
|
|
|
3201
3241
|
state: import_services7.SpaceState[this._state]
|
|
3202
3242
|
}, {
|
|
3203
3243
|
F: __dxlog_file12,
|
|
3204
|
-
L:
|
|
3244
|
+
L: 243,
|
|
3205
3245
|
S: this,
|
|
3206
3246
|
C: (f, a) => f(...a)
|
|
3207
3247
|
});
|
|
@@ -3214,14 +3254,14 @@ var DataSpace = class DataSpace2 {
|
|
|
3214
3254
|
}
|
|
3215
3255
|
async initializeDataPipeline() {
|
|
3216
3256
|
if (this._state !== import_services7.SpaceState.CONTROL_ONLY) {
|
|
3217
|
-
throw new
|
|
3257
|
+
throw new import_protocols8.SystemError("Invalid operation");
|
|
3218
3258
|
}
|
|
3219
3259
|
this._state = import_services7.SpaceState.INITIALIZING;
|
|
3220
3260
|
(0, import_log9.log)("new state", {
|
|
3221
3261
|
state: import_services7.SpaceState[this._state]
|
|
3222
3262
|
}, {
|
|
3223
3263
|
F: __dxlog_file12,
|
|
3224
|
-
L:
|
|
3264
|
+
L: 259,
|
|
3225
3265
|
S: this,
|
|
3226
3266
|
C: (f, a) => f(...a)
|
|
3227
3267
|
});
|
|
@@ -3232,7 +3272,7 @@ var DataSpace = class DataSpace2 {
|
|
|
3232
3272
|
await (0, import_context6.cancelWithContext)(this._ctx, this._inner.dataPipeline.ensureEpochInitialized());
|
|
3233
3273
|
(0, import_log9.log)("waiting for data pipeline to reach target timeframe", void 0, {
|
|
3234
3274
|
F: __dxlog_file12,
|
|
3235
|
-
L:
|
|
3275
|
+
L: 273,
|
|
3236
3276
|
S: this,
|
|
3237
3277
|
C: (f, a) => f(...a)
|
|
3238
3278
|
});
|
|
@@ -3243,7 +3283,7 @@ var DataSpace = class DataSpace2 {
|
|
|
3243
3283
|
this.metrics.dataPipelineReady = /* @__PURE__ */ new Date();
|
|
3244
3284
|
(0, import_log9.log)("data pipeline ready", void 0, {
|
|
3245
3285
|
F: __dxlog_file12,
|
|
3246
|
-
L:
|
|
3286
|
+
L: 282,
|
|
3247
3287
|
S: this,
|
|
3248
3288
|
C: (f, a) => f(...a)
|
|
3249
3289
|
});
|
|
@@ -3253,7 +3293,7 @@ var DataSpace = class DataSpace2 {
|
|
|
3253
3293
|
state: import_services7.SpaceState[this._state]
|
|
3254
3294
|
}, {
|
|
3255
3295
|
F: __dxlog_file12,
|
|
3256
|
-
L:
|
|
3296
|
+
L: 286,
|
|
3257
3297
|
S: this,
|
|
3258
3298
|
C: (f, a) => f(...a)
|
|
3259
3299
|
});
|
|
@@ -3269,7 +3309,7 @@ var DataSpace = class DataSpace2 {
|
|
|
3269
3309
|
await this._createWritableFeeds();
|
|
3270
3310
|
(0, import_log9.log)("writable feeds created", void 0, {
|
|
3271
3311
|
F: __dxlog_file12,
|
|
3272
|
-
L:
|
|
3312
|
+
L: 302,
|
|
3273
3313
|
S: this,
|
|
3274
3314
|
C: (f, a) => f(...a)
|
|
3275
3315
|
});
|
|
@@ -3326,6 +3366,40 @@ var DataSpace = class DataSpace2 {
|
|
|
3326
3366
|
await this._metadataStore.setWritableFeedKeys(this.key, this.inner.controlFeedKey, this.inner.dataFeedKey);
|
|
3327
3367
|
}
|
|
3328
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
|
+
}
|
|
3329
3403
|
// TODO(dmaretskyi): Use profile from signing context.
|
|
3330
3404
|
async updateOwnProfile(profile) {
|
|
3331
3405
|
const credential = await this._signingContext.credentialSigner.createCredential({
|
|
@@ -3409,7 +3483,7 @@ var DataSpace = class DataSpace2 {
|
|
|
3409
3483
|
state: import_services7.SpaceState[this._state]
|
|
3410
3484
|
}, {
|
|
3411
3485
|
F: __dxlog_file12,
|
|
3412
|
-
L:
|
|
3486
|
+
L: 470,
|
|
3413
3487
|
S: this,
|
|
3414
3488
|
C: (f, a) => f(...a)
|
|
3415
3489
|
});
|
|
@@ -3521,7 +3595,7 @@ function _ts_decorate5(decorators, target, key, desc) {
|
|
|
3521
3595
|
var __dxlog_file13 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts";
|
|
3522
3596
|
var PRESENCE_ANNOUNCE_INTERVAL = 1e4;
|
|
3523
3597
|
var PRESENCE_OFFLINE_TIMEOUT = 2e4;
|
|
3524
|
-
var DataSpaceManager = class
|
|
3598
|
+
var DataSpaceManager = class {
|
|
3525
3599
|
constructor(_spaceManager, _metadataStore, _dataServiceSubscriptions, _keyring, _signingContext, _feedStore, _automergeHost) {
|
|
3526
3600
|
this._spaceManager = _spaceManager;
|
|
3527
3601
|
this._metadataStore = _metadataStore;
|
|
@@ -3547,7 +3621,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
3547
3621
|
S: this,
|
|
3548
3622
|
C: (f, a) => f(...a)
|
|
3549
3623
|
});
|
|
3550
|
-
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({
|
|
3551
3625
|
id: this._instanceId
|
|
3552
3626
|
}), {
|
|
3553
3627
|
F: __dxlog_file13,
|
|
@@ -3593,7 +3667,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
3593
3667
|
space.initializeDataPipelineAsync();
|
|
3594
3668
|
}
|
|
3595
3669
|
}
|
|
3596
|
-
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({
|
|
3597
3671
|
id: this._instanceId
|
|
3598
3672
|
}), {
|
|
3599
3673
|
F: __dxlog_file13,
|
|
@@ -3619,7 +3693,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
3619
3693
|
* Creates a new space writing the genesis credentials to the control feed.
|
|
3620
3694
|
*/
|
|
3621
3695
|
async createSpace() {
|
|
3622
|
-
(0,
|
|
3696
|
+
(0, import_invariant12.invariant)(this._isOpen, "Not open.", {
|
|
3623
3697
|
F: __dxlog_file13,
|
|
3624
3698
|
L: 130,
|
|
3625
3699
|
S: this,
|
|
@@ -3648,12 +3722,15 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
3648
3722
|
});
|
|
3649
3723
|
const space = await this._constructSpace(metadata);
|
|
3650
3724
|
const automergeRoot = this._automergeHost.repo.create();
|
|
3725
|
+
automergeRoot.change((doc) => {
|
|
3726
|
+
doc.experimental_spaceKey = spaceKey.toHex();
|
|
3727
|
+
});
|
|
3651
3728
|
const credentials = await spaceGenesis(this._keyring, this._signingContext, space.inner, automergeRoot.url);
|
|
3652
3729
|
await this._metadataStore.addSpace(metadata);
|
|
3653
3730
|
const memberCredential = credentials[1];
|
|
3654
|
-
(0,
|
|
3731
|
+
(0, import_invariant12.invariant)((0, import_credentials12.getCredentialAssertion)(memberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
|
|
3655
3732
|
F: __dxlog_file13,
|
|
3656
|
-
L:
|
|
3733
|
+
L: 154,
|
|
3657
3734
|
S: this,
|
|
3658
3735
|
A: [
|
|
3659
3736
|
"getCredentialAssertion(memberCredential)['@type'] === 'dxos.halo.credentials.SpaceMember'",
|
|
@@ -3671,22 +3748,22 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
3671
3748
|
opts
|
|
3672
3749
|
}, {
|
|
3673
3750
|
F: __dxlog_file13,
|
|
3674
|
-
L:
|
|
3751
|
+
L: 166,
|
|
3675
3752
|
S: this,
|
|
3676
3753
|
C: (f, a) => f(...a)
|
|
3677
3754
|
});
|
|
3678
|
-
(0,
|
|
3755
|
+
(0, import_invariant12.invariant)(this._isOpen, "Not open.", {
|
|
3679
3756
|
F: __dxlog_file13,
|
|
3680
|
-
L:
|
|
3757
|
+
L: 167,
|
|
3681
3758
|
S: this,
|
|
3682
3759
|
A: [
|
|
3683
3760
|
"this._isOpen",
|
|
3684
3761
|
"'Not open.'"
|
|
3685
3762
|
]
|
|
3686
3763
|
});
|
|
3687
|
-
(0,
|
|
3764
|
+
(0, import_invariant12.invariant)(!this._spaces.has(opts.spaceKey), "Space already exists.", {
|
|
3688
3765
|
F: __dxlog_file13,
|
|
3689
|
-
L:
|
|
3766
|
+
L: 168,
|
|
3690
3767
|
S: this,
|
|
3691
3768
|
A: [
|
|
3692
3769
|
"!this._spaces.has(opts.spaceKey)",
|
|
@@ -3721,7 +3798,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
3721
3798
|
metadata
|
|
3722
3799
|
}, {
|
|
3723
3800
|
F: __dxlog_file13,
|
|
3724
|
-
L:
|
|
3801
|
+
L: 201,
|
|
3725
3802
|
S: this,
|
|
3726
3803
|
C: (f, a) => f(...a)
|
|
3727
3804
|
});
|
|
@@ -3748,17 +3825,18 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
3748
3825
|
credentialProvider: createAuthProvider(this._signingContext.credentialSigner),
|
|
3749
3826
|
credentialAuthenticator: (0, import_util6.deferFunction)(() => dataSpace.authVerifier.verifier)
|
|
3750
3827
|
},
|
|
3751
|
-
|
|
3828
|
+
onAuthorizedConnection: (session) => {
|
|
3752
3829
|
session.addExtension("dxos.mesh.teleport.gossip", gossip.createExtension({
|
|
3753
3830
|
remotePeerId: session.remotePeerId
|
|
3754
3831
|
}));
|
|
3755
3832
|
session.addExtension("dxos.mesh.teleport.notarization", dataSpace.notarizationPlugin.createExtension());
|
|
3833
|
+
this._automergeHost.authorizeDevice(space.key, session.remotePeerId);
|
|
3756
3834
|
session.addExtension("dxos.mesh.teleport.automerge", this._automergeHost.createExtension());
|
|
3757
3835
|
},
|
|
3758
3836
|
onAuthFailure: () => {
|
|
3759
3837
|
import_log11.log.warn("auth failure", void 0, {
|
|
3760
3838
|
F: __dxlog_file13,
|
|
3761
|
-
L:
|
|
3839
|
+
L: 238,
|
|
3762
3840
|
S: this,
|
|
3763
3841
|
C: (f, a) => f(...a)
|
|
3764
3842
|
});
|
|
@@ -3782,7 +3860,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
3782
3860
|
space: space.key
|
|
3783
3861
|
}, {
|
|
3784
3862
|
F: __dxlog_file13,
|
|
3785
|
-
L:
|
|
3863
|
+
L: 256,
|
|
3786
3864
|
S: this,
|
|
3787
3865
|
C: (f, a) => f(...a)
|
|
3788
3866
|
});
|
|
@@ -3794,7 +3872,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
3794
3872
|
open: this._isOpen
|
|
3795
3873
|
}, {
|
|
3796
3874
|
F: __dxlog_file13,
|
|
3797
|
-
L:
|
|
3875
|
+
L: 263,
|
|
3798
3876
|
S: this,
|
|
3799
3877
|
C: (f, a) => f(...a)
|
|
3800
3878
|
});
|
|
@@ -3807,7 +3885,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
3807
3885
|
space: space.key
|
|
3808
3886
|
}, {
|
|
3809
3887
|
F: __dxlog_file13,
|
|
3810
|
-
L:
|
|
3888
|
+
L: 269,
|
|
3811
3889
|
S: this,
|
|
3812
3890
|
C: (f, a) => f(...a)
|
|
3813
3891
|
});
|
|
@@ -3855,7 +3933,7 @@ var SpacesServiceImpl = class {
|
|
|
3855
3933
|
}
|
|
3856
3934
|
async createSpace() {
|
|
3857
3935
|
if (!this._identityManager.identity) {
|
|
3858
|
-
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");
|
|
3859
3937
|
}
|
|
3860
3938
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
3861
3939
|
const space = await dataSpaceManager.createSpace();
|
|
@@ -3863,7 +3941,7 @@ var SpacesServiceImpl = class {
|
|
|
3863
3941
|
}
|
|
3864
3942
|
async updateSpace({ spaceKey, state }) {
|
|
3865
3943
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
3866
|
-
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));
|
|
3867
3945
|
if (state) {
|
|
3868
3946
|
switch (state) {
|
|
3869
3947
|
case import_services9.SpaceState.ACTIVE:
|
|
@@ -3873,7 +3951,7 @@ var SpacesServiceImpl = class {
|
|
|
3873
3951
|
await space.deactivate();
|
|
3874
3952
|
break;
|
|
3875
3953
|
default:
|
|
3876
|
-
throw new
|
|
3954
|
+
throw new import_protocols11.ApiError("Invalid space state");
|
|
3877
3955
|
}
|
|
3878
3956
|
}
|
|
3879
3957
|
}
|
|
@@ -3928,14 +4006,14 @@ var SpacesServiceImpl = class {
|
|
|
3928
4006
|
}
|
|
3929
4007
|
async postMessage({ spaceKey, channel, message }) {
|
|
3930
4008
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
3931
|
-
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));
|
|
3932
4010
|
await space.postMessage(getChannelId(channel), message);
|
|
3933
4011
|
}
|
|
3934
4012
|
subscribeMessages({ spaceKey, channel }) {
|
|
3935
4013
|
return new import_codec_protobuf11.Stream(({ ctx, next }) => {
|
|
3936
4014
|
(0, import_async13.scheduleTask)(ctx, async () => {
|
|
3937
4015
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
3938
|
-
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));
|
|
3939
4017
|
const handle = space.listen(getChannelId(channel), (message) => {
|
|
3940
4018
|
next(message);
|
|
3941
4019
|
});
|
|
@@ -3945,7 +4023,7 @@ var SpacesServiceImpl = class {
|
|
|
3945
4023
|
}
|
|
3946
4024
|
queryCredentials({ spaceKey, noTail }) {
|
|
3947
4025
|
return new import_codec_protobuf11.Stream(({ ctx, next, close }) => {
|
|
3948
|
-
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));
|
|
3949
4027
|
const processor = {
|
|
3950
4028
|
processCredential: async (credential) => {
|
|
3951
4029
|
next(credential);
|
|
@@ -3961,7 +4039,7 @@ var SpacesServiceImpl = class {
|
|
|
3961
4039
|
});
|
|
3962
4040
|
}
|
|
3963
4041
|
async writeCredentials({ spaceKey, credentials }) {
|
|
3964
|
-
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));
|
|
3965
4043
|
for (const credential of credentials ?? []) {
|
|
3966
4044
|
if (credential.proof) {
|
|
3967
4045
|
await space.controlPipeline.writer.write({
|
|
@@ -3970,7 +4048,7 @@ var SpacesServiceImpl = class {
|
|
|
3970
4048
|
}
|
|
3971
4049
|
});
|
|
3972
4050
|
} else {
|
|
3973
|
-
(0,
|
|
4051
|
+
(0, import_invariant13.invariant)(!credential.id, "Id on unsigned credentials is not allowed", {
|
|
3974
4052
|
F: __dxlog_file14,
|
|
3975
4053
|
L: 168,
|
|
3976
4054
|
S: this,
|
|
@@ -3979,7 +4057,7 @@ var SpacesServiceImpl = class {
|
|
|
3979
4057
|
"'Id on unsigned credentials is not allowed'"
|
|
3980
4058
|
]
|
|
3981
4059
|
});
|
|
3982
|
-
(0,
|
|
4060
|
+
(0, import_invariant13.invariant)(this._identityManager.identity, "Identity is not available", {
|
|
3983
4061
|
F: __dxlog_file14,
|
|
3984
4062
|
L: 169,
|
|
3985
4063
|
S: this,
|
|
@@ -3989,7 +4067,7 @@ var SpacesServiceImpl = class {
|
|
|
3989
4067
|
]
|
|
3990
4068
|
});
|
|
3991
4069
|
const signer = this._identityManager.identity.getIdentityCredentialSigner();
|
|
3992
|
-
(0,
|
|
4070
|
+
(0, import_invariant13.invariant)(credential.issuer.equals(signer.getIssuer()), void 0, {
|
|
3993
4071
|
F: __dxlog_file14,
|
|
3994
4072
|
L: 171,
|
|
3995
4073
|
S: this,
|
|
@@ -4012,14 +4090,14 @@ var SpacesServiceImpl = class {
|
|
|
4012
4090
|
}
|
|
4013
4091
|
async createEpoch({ spaceKey }) {
|
|
4014
4092
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
4015
|
-
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));
|
|
4016
4094
|
await space.createEpoch();
|
|
4017
4095
|
}
|
|
4018
4096
|
_serializeSpace(space) {
|
|
4019
4097
|
return {
|
|
4020
4098
|
spaceKey: space.key,
|
|
4021
4099
|
state: space.state,
|
|
4022
|
-
error: space.error ? (0,
|
|
4100
|
+
error: space.error ? (0, import_protocols11.encodeError)(space.error) : void 0,
|
|
4023
4101
|
pipeline: {
|
|
4024
4102
|
currentEpoch: space.dataPipeline.currentEpoch,
|
|
4025
4103
|
appliedEpoch: space.dataPipeline.appliedEpoch,
|
|
@@ -4068,7 +4146,7 @@ function _ts_decorate6(decorators, target, key, desc) {
|
|
|
4068
4146
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4069
4147
|
}
|
|
4070
4148
|
var __dxlog_file15 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-context.ts";
|
|
4071
|
-
var ServiceContext = class
|
|
4149
|
+
var ServiceContext = class {
|
|
4072
4150
|
constructor(storage, networkManager, signalManager, modelFactory) {
|
|
4073
4151
|
this.storage = storage;
|
|
4074
4152
|
this.networkManager = networkManager;
|
|
@@ -4113,7 +4191,7 @@ var ServiceContext = class ServiceContext2 {
|
|
|
4113
4191
|
S: this,
|
|
4114
4192
|
C: (f, a) => f(...a)
|
|
4115
4193
|
});
|
|
4116
|
-
import_log13.log.trace("dxos.sdk.service-context.open",
|
|
4194
|
+
import_log13.log.trace("dxos.sdk.service-context.open", import_protocols12.trace.begin({
|
|
4117
4195
|
id: this._instanceId
|
|
4118
4196
|
}), {
|
|
4119
4197
|
F: __dxlog_file15,
|
|
@@ -4129,7 +4207,7 @@ var ServiceContext = class ServiceContext2 {
|
|
|
4129
4207
|
if (this.identityManager.identity) {
|
|
4130
4208
|
await this._initialize(ctx);
|
|
4131
4209
|
}
|
|
4132
|
-
import_log13.log.trace("dxos.sdk.service-context.open",
|
|
4210
|
+
import_log13.log.trace("dxos.sdk.service-context.open", import_protocols12.trace.end({
|
|
4133
4211
|
id: this._instanceId
|
|
4134
4212
|
}), {
|
|
4135
4213
|
F: __dxlog_file15,
|
|
@@ -4177,7 +4255,7 @@ var ServiceContext = class ServiceContext2 {
|
|
|
4177
4255
|
}
|
|
4178
4256
|
getInvitationHandler(invitation) {
|
|
4179
4257
|
const factory = this._handlerFactories.get(invitation.kind);
|
|
4180
|
-
(0,
|
|
4258
|
+
(0, import_invariant14.invariant)(factory, `Unknown invitation kind: ${invitation.kind}`, {
|
|
4181
4259
|
F: __dxlog_file15,
|
|
4182
4260
|
L: 173,
|
|
4183
4261
|
S: this,
|
|
@@ -4203,8 +4281,8 @@ var ServiceContext = class ServiceContext2 {
|
|
|
4203
4281
|
}
|
|
4204
4282
|
async _checkStorageVersion() {
|
|
4205
4283
|
await this.metadataStore.load();
|
|
4206
|
-
if (this.metadataStore.version !==
|
|
4207
|
-
throw new
|
|
4284
|
+
if (this.metadataStore.version !== import_protocols12.STORAGE_VERSION) {
|
|
4285
|
+
throw new import_protocols12.InvalidStorageVersionError(import_protocols12.STORAGE_VERSION, this.metadataStore.version);
|
|
4208
4286
|
}
|
|
4209
4287
|
}
|
|
4210
4288
|
// Called when identity is created.
|
|
@@ -4232,7 +4310,7 @@ var ServiceContext = class ServiceContext2 {
|
|
|
4232
4310
|
this.dataSpaceManager = new DataSpaceManager(this.spaceManager, this.metadataStore, this.dataServiceSubscriptions, this.keyring, signingContext, this.feedStore, this.automergeHost);
|
|
4233
4311
|
await this.dataSpaceManager.open();
|
|
4234
4312
|
this._handlerFactories.set(import_services10.Invitation.Kind.SPACE, (invitation) => {
|
|
4235
|
-
(0,
|
|
4313
|
+
(0, import_invariant14.invariant)(this.dataSpaceManager, "dataSpaceManager not initialized yet", {
|
|
4236
4314
|
F: __dxlog_file15,
|
|
4237
4315
|
L: 228,
|
|
4238
4316
|
S: this,
|
|
@@ -4371,7 +4449,7 @@ var Lock = class {
|
|
|
4371
4449
|
}
|
|
4372
4450
|
async release() {
|
|
4373
4451
|
await this._onRelease?.();
|
|
4374
|
-
(0,
|
|
4452
|
+
(0, import_invariant15.invariant)(this._fileHandle, "Lock is not acquired", {
|
|
4375
4453
|
F: __dxlog_file16,
|
|
4376
4454
|
L: 42,
|
|
4377
4455
|
S: this,
|
|
@@ -4391,16 +4469,16 @@ var StorageDriver = import_config.Runtime.Client.Storage.StorageDriver;
|
|
|
4391
4469
|
var createStorageObjects = (config) => {
|
|
4392
4470
|
const { persistent = false, keyStore, dataStore, dataRoot = (0, import_util8.isNode)() ? import_client_protocol4.DX_DATA : "dxos/storage" } = config ?? {};
|
|
4393
4471
|
if (persistent && dataStore === StorageDriver.RAM) {
|
|
4394
|
-
throw new
|
|
4472
|
+
throw new import_protocols13.InvalidConfigError("RAM storage cannot be used in persistent mode.");
|
|
4395
4473
|
}
|
|
4396
4474
|
if (!persistent && dataStore !== void 0 && dataStore !== StorageDriver.RAM) {
|
|
4397
|
-
throw new
|
|
4475
|
+
throw new import_protocols13.InvalidConfigError("Cannot use a persistent storage in not persistent mode.");
|
|
4398
4476
|
}
|
|
4399
4477
|
if (persistent && keyStore === StorageDriver.RAM) {
|
|
4400
|
-
throw new
|
|
4478
|
+
throw new import_protocols13.InvalidConfigError("RAM key storage cannot be used in persistent mode.");
|
|
4401
4479
|
}
|
|
4402
4480
|
if (!persistent && keyStore !== StorageDriver.RAM && keyStore !== void 0) {
|
|
4403
|
-
throw new
|
|
4481
|
+
throw new import_protocols13.InvalidConfigError("Cannot use a persistent key storage in not persistent mode.");
|
|
4404
4482
|
}
|
|
4405
4483
|
return {
|
|
4406
4484
|
storage: (0, import_random_access_storage.createStorage)({
|
|
@@ -4682,7 +4760,7 @@ var createGenesisMutationFromTypedObject = (obj) => {
|
|
|
4682
4760
|
}
|
|
4683
4761
|
};
|
|
4684
4762
|
};
|
|
4685
|
-
var ClientServicesHost = class
|
|
4763
|
+
var ClientServicesHost = class {
|
|
4686
4764
|
constructor({
|
|
4687
4765
|
config,
|
|
4688
4766
|
modelFactory = createDefaultModelFactory(),
|
|
@@ -4766,7 +4844,7 @@ var ClientServicesHost = class ClientServicesHost2 {
|
|
|
4766
4844
|
* Can only be called once.
|
|
4767
4845
|
*/
|
|
4768
4846
|
initialize({ config, ...options }) {
|
|
4769
|
-
(0,
|
|
4847
|
+
(0, import_invariant16.invariant)(!this._open, "service host is open", {
|
|
4770
4848
|
F: __dxlog_file17,
|
|
4771
4849
|
L: 201,
|
|
4772
4850
|
S: this,
|
|
@@ -4782,7 +4860,7 @@ var ClientServicesHost = class ClientServicesHost2 {
|
|
|
4782
4860
|
C: (f, a) => f(...a)
|
|
4783
4861
|
});
|
|
4784
4862
|
if (config) {
|
|
4785
|
-
(0,
|
|
4863
|
+
(0, import_invariant16.invariant)(!this._config, "config already set", {
|
|
4786
4864
|
F: __dxlog_file17,
|
|
4787
4865
|
L: 205,
|
|
4788
4866
|
S: this,
|
|
@@ -4800,7 +4878,7 @@ var ClientServicesHost = class ClientServicesHost2 {
|
|
|
4800
4878
|
iceServers: this._config?.get("runtime.services.ice")
|
|
4801
4879
|
}), signalManager = new import_messaging.WebsocketSignalManager(this._config?.get("runtime.services.signaling") ?? []) } = options;
|
|
4802
4880
|
this._signalManager = signalManager;
|
|
4803
|
-
(0,
|
|
4881
|
+
(0, import_invariant16.invariant)(!this._networkManager, "network manager already set", {
|
|
4804
4882
|
F: __dxlog_file17,
|
|
4805
4883
|
L: 221,
|
|
4806
4884
|
S: this,
|
|
@@ -4826,7 +4904,7 @@ var ClientServicesHost = class ClientServicesHost2 {
|
|
|
4826
4904
|
return;
|
|
4827
4905
|
}
|
|
4828
4906
|
const traceId = import_keys11.PublicKey.random().toHex();
|
|
4829
|
-
import_log15.log.trace("dxos.client-services.host.open",
|
|
4907
|
+
import_log15.log.trace("dxos.client-services.host.open", import_protocols14.trace.begin({
|
|
4830
4908
|
id: traceId
|
|
4831
4909
|
}), {
|
|
4832
4910
|
F: __dxlog_file17,
|
|
@@ -4834,7 +4912,7 @@ var ClientServicesHost = class ClientServicesHost2 {
|
|
|
4834
4912
|
S: this,
|
|
4835
4913
|
C: (f, a) => f(...a)
|
|
4836
4914
|
});
|
|
4837
|
-
(0,
|
|
4915
|
+
(0, import_invariant16.invariant)(this._config, "config not set", {
|
|
4838
4916
|
F: __dxlog_file17,
|
|
4839
4917
|
L: 241,
|
|
4840
4918
|
S: this,
|
|
@@ -4843,7 +4921,7 @@ var ClientServicesHost = class ClientServicesHost2 {
|
|
|
4843
4921
|
"'config not set'"
|
|
4844
4922
|
]
|
|
4845
4923
|
});
|
|
4846
|
-
(0,
|
|
4924
|
+
(0, import_invariant16.invariant)(this._storage, "storage not set", {
|
|
4847
4925
|
F: __dxlog_file17,
|
|
4848
4926
|
L: 242,
|
|
4849
4927
|
S: this,
|
|
@@ -4852,7 +4930,7 @@ var ClientServicesHost = class ClientServicesHost2 {
|
|
|
4852
4930
|
"'storage not set'"
|
|
4853
4931
|
]
|
|
4854
4932
|
});
|
|
4855
|
-
(0,
|
|
4933
|
+
(0, import_invariant16.invariant)(this._signalManager, "signal manager not set", {
|
|
4856
4934
|
F: __dxlog_file17,
|
|
4857
4935
|
L: 243,
|
|
4858
4936
|
S: this,
|
|
@@ -4861,7 +4939,7 @@ var ClientServicesHost = class ClientServicesHost2 {
|
|
|
4861
4939
|
"'signal manager not set'"
|
|
4862
4940
|
]
|
|
4863
4941
|
});
|
|
4864
|
-
(0,
|
|
4942
|
+
(0, import_invariant16.invariant)(this._networkManager, "network manager not set", {
|
|
4865
4943
|
F: __dxlog_file17,
|
|
4866
4944
|
L: 244,
|
|
4867
4945
|
S: this,
|
|
@@ -4884,7 +4962,7 @@ var ClientServicesHost = class ClientServicesHost2 {
|
|
|
4884
4962
|
this._serviceContext = new ServiceContext(this._storage, this._networkManager, this._signalManager, this._modelFactory);
|
|
4885
4963
|
this._serviceRegistry.setServices({
|
|
4886
4964
|
SystemService: this._systemService,
|
|
4887
|
-
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)),
|
|
4888
4966
|
InvitationsService: new InvitationsServiceImpl(this._serviceContext.invitations, (invitation) => this._serviceContext.getInvitationHandler(invitation)),
|
|
4889
4967
|
DevicesService: new DevicesServiceImpl(this._serviceContext.identityManager),
|
|
4890
4968
|
SpacesService: new SpacesServiceImpl(this._serviceContext.identityManager, this._serviceContext.spaceManager, this._serviceContext.dataServiceSubscriptions, async () => {
|
|
@@ -4925,7 +5003,7 @@ var ClientServicesHost = class ClientServicesHost2 {
|
|
|
4925
5003
|
S: this,
|
|
4926
5004
|
C: (f, a) => f(...a)
|
|
4927
5005
|
});
|
|
4928
|
-
import_log15.log.trace("dxos.client-services.host.open",
|
|
5006
|
+
import_log15.log.trace("dxos.client-services.host.open", import_protocols14.trace.end({
|
|
4929
5007
|
id: traceId
|
|
4930
5008
|
}), {
|
|
4931
5009
|
F: __dxlog_file17,
|
|
@@ -4966,7 +5044,7 @@ var ClientServicesHost = class ClientServicesHost2 {
|
|
|
4966
5044
|
}
|
|
4967
5045
|
async reset() {
|
|
4968
5046
|
const traceId = import_keys11.PublicKey.random().toHex();
|
|
4969
|
-
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({
|
|
4970
5048
|
id: traceId
|
|
4971
5049
|
}), {
|
|
4972
5050
|
F: __dxlog_file17,
|
|
@@ -4988,7 +5066,7 @@ var ClientServicesHost = class ClientServicesHost2 {
|
|
|
4988
5066
|
S: this,
|
|
4989
5067
|
C: (f, a) => f(...a)
|
|
4990
5068
|
});
|
|
4991
|
-
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({
|
|
4992
5070
|
id: traceId
|
|
4993
5071
|
}), {
|
|
4994
5072
|
F: __dxlog_file17,
|
|
@@ -4998,25 +5076,44 @@ var ClientServicesHost = class ClientServicesHost2 {
|
|
|
4998
5076
|
});
|
|
4999
5077
|
await this._callbacks?.onReset?.();
|
|
5000
5078
|
}
|
|
5001
|
-
async _createIdentity(params) {
|
|
5079
|
+
async _createIdentity(params, useAutomerge) {
|
|
5002
5080
|
const identity = await this._serviceContext.createIdentity(params);
|
|
5003
5081
|
await this._serviceContext.initialized.wait();
|
|
5004
5082
|
const space = await this._serviceContext.dataSpaceManager.createSpace();
|
|
5005
5083
|
const obj = new import_client_protocol5.Properties(void 0, {
|
|
5006
|
-
automerge:
|
|
5084
|
+
automerge: useAutomerge
|
|
5007
5085
|
});
|
|
5008
5086
|
obj[import_client_protocol5.defaultKey] = identity.identityKey.toHex();
|
|
5009
|
-
|
|
5010
|
-
|
|
5011
|
-
|
|
5012
|
-
|
|
5013
|
-
|
|
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
|
+
""
|
|
5014
5108
|
]
|
|
5015
|
-
}
|
|
5016
|
-
|
|
5017
|
-
|
|
5018
|
-
|
|
5019
|
-
|
|
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
|
+
}
|
|
5020
5117
|
return identity;
|
|
5021
5118
|
}
|
|
5022
5119
|
};
|
|
@@ -5071,4 +5168,4 @@ ClientServicesHost = _ts_decorate8([
|
|
|
5071
5168
|
subscribeToSpaces,
|
|
5072
5169
|
subscribeToSwarmInfo
|
|
5073
5170
|
});
|
|
5074
|
-
//# sourceMappingURL=chunk-
|
|
5171
|
+
//# sourceMappingURL=chunk-LTQYCVFH.cjs.map
|