@dxos/client-services 0.3.11-main.ec7a2b3 → 0.3.11-main.ee2b64c
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-XM2TLK6X.mjs → chunk-3DRZQ4U6.mjs} +244 -117
- package/dist/lib/browser/chunk-3DRZQ4U6.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-YNYJIGPD.cjs → chunk-JUJNN3NE.cjs} +383 -256
- package/dist/lib/node/chunk-JUJNN3NE.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/network/network-service.d.ts.map +1 -1
- package/dist/types/src/packlets/services/diagnostics.d.ts +32 -16
- package/dist/types/src/packlets/services/diagnostics.d.ts.map +1 -1
- package/dist/types/src/packlets/services/platform.d.ts +1 -14
- package/dist/types/src/packlets/services/platform.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 +2 -0
- package/dist/types/src/packlets/spaces/data-space.d.ts.map +1 -1
- package/dist/types/src/packlets/system/system-service.d.ts +3 -2
- package/dist/types/src/packlets/system/system-service.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/network/network-service.ts +5 -1
- package/src/packlets/services/diagnostics.ts +52 -16
- package/src/packlets/services/platform.ts +7 -19
- 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 +37 -4
- package/src/packlets/spaces/spaces-service.ts +3 -3
- package/src/packlets/system/system-service.ts +7 -1
- package/src/packlets/testing/invitation-utils.ts +2 -10
- package/src/version.ts +1 -1
- package/dist/lib/browser/chunk-XM2TLK6X.mjs.map +0 -7
- package/dist/lib/node/chunk-YNYJIGPD.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_JUJNN3NE_exports = {};
|
|
30
|
+
__export(chunk_JUJNN3NE_exports, {
|
|
31
31
|
ClientRpcServer: () => ClientRpcServer,
|
|
32
32
|
ClientServicesHost: () => ClientServicesHost,
|
|
33
33
|
DataSpace: () => DataSpace,
|
|
@@ -60,7 +60,7 @@ __export(chunk_YNYJIGPD_exports, {
|
|
|
60
60
|
subscribeToSpaces: () => subscribeToSpaces,
|
|
61
61
|
subscribeToSwarmInfo: () => subscribeToSwarmInfo
|
|
62
62
|
});
|
|
63
|
-
module.exports = __toCommonJS(
|
|
63
|
+
module.exports = __toCommonJS(chunk_JUJNN3NE_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,38 +151,41 @@ 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");
|
|
156
|
+
var import_tracing4 = require("@dxos/tracing");
|
|
157
|
+
var import_services7 = require("@dxos/protocols/proto/dxos/client/services");
|
|
154
158
|
var import_async10 = require("@dxos/async");
|
|
155
159
|
var import_client_protocol3 = require("@dxos/client-protocol");
|
|
156
160
|
var import_context6 = require("@dxos/context");
|
|
157
161
|
var import_debug4 = require("@dxos/debug");
|
|
158
162
|
var import_echo_pipeline = require("@dxos/echo-pipeline");
|
|
163
|
+
var import_invariant10 = require("@dxos/invariant");
|
|
159
164
|
var import_keys7 = require("@dxos/keys");
|
|
160
165
|
var import_log9 = require("@dxos/log");
|
|
161
|
-
var
|
|
162
|
-
var
|
|
166
|
+
var import_protocols8 = require("@dxos/protocols");
|
|
167
|
+
var import_services8 = require("@dxos/protocols/proto/dxos/client/services");
|
|
163
168
|
var import_credentials10 = require("@dxos/protocols/proto/dxos/halo/credentials");
|
|
164
169
|
var import_timeframe2 = require("@dxos/timeframe");
|
|
165
|
-
var
|
|
170
|
+
var import_tracing5 = require("@dxos/tracing");
|
|
166
171
|
var import_util4 = require("@dxos/util");
|
|
167
172
|
var import_credentials11 = require("@dxos/credentials");
|
|
168
173
|
var import_async11 = require("@dxos/async");
|
|
169
174
|
var import_context7 = require("@dxos/context");
|
|
170
|
-
var
|
|
175
|
+
var import_invariant11 = require("@dxos/invariant");
|
|
171
176
|
var import_keys8 = require("@dxos/keys");
|
|
172
177
|
var import_log10 = require("@dxos/log");
|
|
173
|
-
var
|
|
178
|
+
var import_protocols9 = require("@dxos/protocols");
|
|
174
179
|
var import_teleport2 = require("@dxos/teleport");
|
|
175
180
|
var import_util5 = require("@dxos/util");
|
|
176
181
|
var import_async12 = require("@dxos/async");
|
|
177
182
|
var import_context8 = require("@dxos/context");
|
|
178
183
|
var import_credentials12 = require("@dxos/credentials");
|
|
179
|
-
var
|
|
184
|
+
var import_invariant12 = require("@dxos/invariant");
|
|
180
185
|
var import_keys9 = require("@dxos/keys");
|
|
181
186
|
var import_log11 = require("@dxos/log");
|
|
182
|
-
var
|
|
183
|
-
var
|
|
187
|
+
var import_protocols10 = require("@dxos/protocols");
|
|
188
|
+
var import_services9 = require("@dxos/protocols/proto/dxos/client/services");
|
|
184
189
|
var import_teleport_extension_gossip = require("@dxos/teleport-extension-gossip");
|
|
185
190
|
var import_util6 = require("@dxos/util");
|
|
186
191
|
var import_credentials13 = require("@dxos/credentials");
|
|
@@ -190,30 +195,30 @@ var import_timeframe3 = require("@dxos/timeframe");
|
|
|
190
195
|
var import_async13 = require("@dxos/async");
|
|
191
196
|
var import_codec_protobuf11 = require("@dxos/codec-protobuf");
|
|
192
197
|
var import_debug6 = require("@dxos/debug");
|
|
193
|
-
var
|
|
198
|
+
var import_invariant13 = require("@dxos/invariant");
|
|
194
199
|
var import_log12 = require("@dxos/log");
|
|
195
|
-
var
|
|
196
|
-
var
|
|
200
|
+
var import_protocols11 = require("@dxos/protocols");
|
|
201
|
+
var import_services10 = require("@dxos/protocols/proto/dxos/client/services");
|
|
197
202
|
var import_async14 = require("@dxos/async");
|
|
198
203
|
var import_context9 = require("@dxos/context");
|
|
199
204
|
var import_credentials15 = require("@dxos/credentials");
|
|
200
205
|
var import_debug7 = require("@dxos/debug");
|
|
201
206
|
var import_echo_pipeline2 = require("@dxos/echo-pipeline");
|
|
202
207
|
var import_feed_store4 = require("@dxos/feed-store");
|
|
203
|
-
var
|
|
208
|
+
var import_invariant14 = require("@dxos/invariant");
|
|
204
209
|
var import_keyring = require("@dxos/keyring");
|
|
205
210
|
var import_keys10 = require("@dxos/keys");
|
|
206
211
|
var import_log13 = require("@dxos/log");
|
|
207
|
-
var
|
|
208
|
-
var
|
|
212
|
+
var import_protocols12 = require("@dxos/protocols");
|
|
213
|
+
var import_services11 = require("@dxos/protocols/proto/dxos/client/services");
|
|
209
214
|
var import_teleport_extension_object_sync = require("@dxos/teleport-extension-object-sync");
|
|
210
|
-
var
|
|
215
|
+
var import_tracing6 = require("@dxos/tracing");
|
|
211
216
|
var import_util7 = require("@dxos/util");
|
|
212
|
-
var
|
|
217
|
+
var import_invariant15 = require("@dxos/invariant");
|
|
213
218
|
var import_lock_file = require("@dxos/lock-file");
|
|
214
219
|
var import_log14 = require("@dxos/log");
|
|
215
220
|
var import_client_protocol4 = require("@dxos/client-protocol");
|
|
216
|
-
var
|
|
221
|
+
var import_protocols13 = require("@dxos/protocols");
|
|
217
222
|
var import_config = require("@dxos/protocols/proto/dxos/config");
|
|
218
223
|
var import_random_access_storage = require("@dxos/random-access-storage");
|
|
219
224
|
var import_util8 = require("@dxos/util");
|
|
@@ -223,28 +228,28 @@ var import_context10 = require("@dxos/context");
|
|
|
223
228
|
var import_document_model2 = require("@dxos/document-model");
|
|
224
229
|
var import_echo_pipeline3 = require("@dxos/echo-pipeline");
|
|
225
230
|
var import_echo_schema = require("@dxos/echo-schema");
|
|
226
|
-
var
|
|
231
|
+
var import_invariant16 = require("@dxos/invariant");
|
|
227
232
|
var import_keys11 = require("@dxos/keys");
|
|
228
233
|
var import_log15 = require("@dxos/log");
|
|
229
234
|
var import_messaging = require("@dxos/messaging");
|
|
230
235
|
var import_model_factory = require("@dxos/model-factory");
|
|
231
236
|
var import_network_manager2 = require("@dxos/network-manager");
|
|
232
|
-
var
|
|
233
|
-
var
|
|
237
|
+
var import_protocols14 = require("@dxos/protocols");
|
|
238
|
+
var import_services12 = require("@dxos/protocols/proto/dxos/client/services");
|
|
234
239
|
var import_text_model = require("@dxos/text-model");
|
|
235
|
-
var
|
|
240
|
+
var import_tracing7 = require("@dxos/tracing");
|
|
236
241
|
var import_websocket_rpc = require("@dxos/websocket-rpc");
|
|
237
242
|
var import_async16 = require("@dxos/async");
|
|
238
243
|
var import_codec_protobuf12 = require("@dxos/codec-protobuf");
|
|
239
|
-
var
|
|
244
|
+
var import_services13 = require("@dxos/protocols/proto/dxos/client/services");
|
|
240
245
|
var import_async17 = require("@dxos/async");
|
|
241
246
|
var import_codec_protobuf13 = require("@dxos/codec-protobuf");
|
|
242
247
|
var import_log16 = require("@dxos/log");
|
|
243
|
-
var
|
|
248
|
+
var import_services14 = require("@dxos/protocols/proto/dxos/client/services");
|
|
244
249
|
var import_util9 = require("@dxos/util");
|
|
245
250
|
var import_codec_protobuf14 = require("@dxos/codec-protobuf");
|
|
246
251
|
var import_codec_protobuf15 = require("@dxos/codec-protobuf");
|
|
247
|
-
var
|
|
252
|
+
var import_services15 = require("@dxos/protocols/proto/dxos/client/services");
|
|
248
253
|
var import_util10 = require("@dxos/util");
|
|
249
254
|
var subscribeToFeeds = ({ feedStore }, { feedKeys }) => {
|
|
250
255
|
return new import_codec_protobuf.Stream(({ next }) => {
|
|
@@ -675,7 +680,7 @@ function _ts_decorate(decorators, target, key, desc) {
|
|
|
675
680
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
676
681
|
}
|
|
677
682
|
var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/identity.ts";
|
|
678
|
-
var Identity = class
|
|
683
|
+
var Identity = class {
|
|
679
684
|
constructor({ space, signer, identityKey, deviceKey }) {
|
|
680
685
|
this.stateUpdate = new import_async5.Event();
|
|
681
686
|
this.space = space;
|
|
@@ -843,7 +848,7 @@ function _ts_decorate2(decorators, target, key, desc) {
|
|
|
843
848
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
844
849
|
}
|
|
845
850
|
var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/identity-manager.ts";
|
|
846
|
-
var IdentityManager = class
|
|
851
|
+
var IdentityManager = class {
|
|
847
852
|
// TODO(burdon): IdentityManagerParams.
|
|
848
853
|
// TODO(dmaretskyi): Perhaps this should take/generate the peerKey outside of an initialized identity.
|
|
849
854
|
constructor(_metadataStore, _keyring, _feedStore, _spaceManager) {
|
|
@@ -1174,7 +1179,7 @@ var IdentityManager = class IdentityManager2 {
|
|
|
1174
1179
|
genesisFeedKey: spaceRecord.genesisFeedKey
|
|
1175
1180
|
},
|
|
1176
1181
|
swarmIdentity,
|
|
1177
|
-
|
|
1182
|
+
onAuthorizedConnection: () => {
|
|
1178
1183
|
},
|
|
1179
1184
|
onAuthFailure: () => {
|
|
1180
1185
|
import_log3.log.warn("auth failure", void 0, {
|
|
@@ -1197,6 +1202,7 @@ IdentityManager = _ts_decorate2([
|
|
|
1197
1202
|
import_tracing2.trace.resource()
|
|
1198
1203
|
], IdentityManager);
|
|
1199
1204
|
var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/identity-service.ts";
|
|
1205
|
+
var CREATE_PROFILE_WITH_AUTOMERGE_DEFAULT = true;
|
|
1200
1206
|
var IdentityServiceImpl = class {
|
|
1201
1207
|
constructor(_createIdentity, _identityManager, _keyring, _onProfileUpdate) {
|
|
1202
1208
|
this._createIdentity = _createIdentity;
|
|
@@ -1205,7 +1211,7 @@ var IdentityServiceImpl = class {
|
|
|
1205
1211
|
this._onProfileUpdate = _onProfileUpdate;
|
|
1206
1212
|
}
|
|
1207
1213
|
async createIdentity(request) {
|
|
1208
|
-
await this._createIdentity(request);
|
|
1214
|
+
await this._createIdentity(request.profile ?? {}, request.useAutomerge ?? CREATE_PROFILE_WITH_AUTOMERGE_DEFAULT);
|
|
1209
1215
|
return this._getIdentity();
|
|
1210
1216
|
}
|
|
1211
1217
|
async recoverIdentity(request) {
|
|
@@ -1233,7 +1239,7 @@ var IdentityServiceImpl = class {
|
|
|
1233
1239
|
async updateProfile(profile) {
|
|
1234
1240
|
(0, import_invariant3.invariant)(this._identityManager.identity, "Identity not initialized.", {
|
|
1235
1241
|
F: __dxlog_file4,
|
|
1236
|
-
L:
|
|
1242
|
+
L: 63,
|
|
1237
1243
|
S: this,
|
|
1238
1244
|
A: [
|
|
1239
1245
|
"this._identityManager.identity",
|
|
@@ -1247,7 +1253,7 @@ var IdentityServiceImpl = class {
|
|
|
1247
1253
|
async signPresentation({ presentation, nonce }) {
|
|
1248
1254
|
(0, import_invariant3.invariant)(this._identityManager.identity, "Identity not initialized.", {
|
|
1249
1255
|
F: __dxlog_file4,
|
|
1250
|
-
L:
|
|
1256
|
+
L: 70,
|
|
1251
1257
|
S: this,
|
|
1252
1258
|
A: [
|
|
1253
1259
|
"this._identityManager.identity",
|
|
@@ -1281,7 +1287,7 @@ var DeviceInvitationProtocol = class {
|
|
|
1281
1287
|
async admit(request) {
|
|
1282
1288
|
(0, import_invariant4.invariant)(request.device, void 0, {
|
|
1283
1289
|
F: __dxlog_file5,
|
|
1284
|
-
L:
|
|
1290
|
+
L: 36,
|
|
1285
1291
|
S: this,
|
|
1286
1292
|
A: [
|
|
1287
1293
|
"request.device",
|
|
@@ -1299,6 +1305,15 @@ var DeviceInvitationProtocol = class {
|
|
|
1299
1305
|
}
|
|
1300
1306
|
};
|
|
1301
1307
|
}
|
|
1308
|
+
checkInvitation(invitation) {
|
|
1309
|
+
try {
|
|
1310
|
+
const identity = this._getIdentity();
|
|
1311
|
+
if (identity) {
|
|
1312
|
+
return new import_protocols3.AlreadyJoinedError("Currently only one identity per client is supported.");
|
|
1313
|
+
}
|
|
1314
|
+
} catch {
|
|
1315
|
+
}
|
|
1316
|
+
}
|
|
1302
1317
|
createIntroduction() {
|
|
1303
1318
|
return {};
|
|
1304
1319
|
}
|
|
@@ -1317,7 +1332,7 @@ var DeviceInvitationProtocol = class {
|
|
|
1317
1332
|
async accept(response, request) {
|
|
1318
1333
|
(0, import_invariant4.invariant)(response.device, void 0, {
|
|
1319
1334
|
F: __dxlog_file5,
|
|
1320
|
-
L:
|
|
1335
|
+
L: 80,
|
|
1321
1336
|
S: this,
|
|
1322
1337
|
A: [
|
|
1323
1338
|
"response.device",
|
|
@@ -1327,7 +1342,7 @@ var DeviceInvitationProtocol = class {
|
|
|
1327
1342
|
const { identityKey, haloSpaceKey, genesisFeedKey, controlTimeframe } = response.device;
|
|
1328
1343
|
(0, import_invariant4.invariant)(request.device, void 0, {
|
|
1329
1344
|
F: __dxlog_file5,
|
|
1330
|
-
L:
|
|
1345
|
+
L: 83,
|
|
1331
1346
|
S: this,
|
|
1332
1347
|
A: [
|
|
1333
1348
|
"request.device",
|
|
@@ -1356,10 +1371,10 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
1356
1371
|
constructor(_callbacks) {
|
|
1357
1372
|
super({
|
|
1358
1373
|
requested: {
|
|
1359
|
-
InvitationHostService:
|
|
1374
|
+
InvitationHostService: import_protocols5.schema.getService("dxos.halo.invitations.InvitationHostService")
|
|
1360
1375
|
},
|
|
1361
1376
|
exposed: {
|
|
1362
|
-
InvitationHostService:
|
|
1377
|
+
InvitationHostService: import_protocols5.schema.getService("dxos.halo.invitations.InvitationHostService")
|
|
1363
1378
|
}
|
|
1364
1379
|
});
|
|
1365
1380
|
this._callbacks = _callbacks;
|
|
@@ -1392,7 +1407,7 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
1392
1407
|
introduce: async (request) => {
|
|
1393
1408
|
const { profile, invitationId } = request;
|
|
1394
1409
|
const traceId = import_keys6.PublicKey.random().toHex();
|
|
1395
|
-
import_log5.log.trace("dxos.sdk.invitation-handler.host.introduce",
|
|
1410
|
+
import_log5.log.trace("dxos.sdk.invitation-handler.host.introduce", import_protocols5.trace.begin({
|
|
1396
1411
|
id: traceId
|
|
1397
1412
|
}), {
|
|
1398
1413
|
F: __dxlog_file6,
|
|
@@ -1429,7 +1444,7 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
1429
1444
|
...this.invitation,
|
|
1430
1445
|
state: import_services3.Invitation.State.READY_FOR_AUTHENTICATION
|
|
1431
1446
|
});
|
|
1432
|
-
import_log5.log.trace("dxos.sdk.invitation-handler.host.introduce",
|
|
1447
|
+
import_log5.log.trace("dxos.sdk.invitation-handler.host.introduce", import_protocols5.trace.end({
|
|
1433
1448
|
id: traceId
|
|
1434
1449
|
}), {
|
|
1435
1450
|
F: __dxlog_file6,
|
|
@@ -1443,7 +1458,7 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
1443
1458
|
},
|
|
1444
1459
|
authenticate: async ({ authCode: code }) => {
|
|
1445
1460
|
const traceId = import_keys6.PublicKey.random().toHex();
|
|
1446
|
-
import_log5.log.trace("dxos.sdk.invitation-handler.host.authenticate",
|
|
1461
|
+
import_log5.log.trace("dxos.sdk.invitation-handler.host.authenticate", import_protocols5.trace.begin({
|
|
1447
1462
|
id: traceId
|
|
1448
1463
|
}), {
|
|
1449
1464
|
F: __dxlog_file6,
|
|
@@ -1506,7 +1521,7 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
1506
1521
|
break;
|
|
1507
1522
|
}
|
|
1508
1523
|
}
|
|
1509
|
-
import_log5.log.trace("dxos.sdk.invitation-handler.host.authenticate",
|
|
1524
|
+
import_log5.log.trace("dxos.sdk.invitation-handler.host.authenticate", import_protocols5.trace.end({
|
|
1510
1525
|
id: traceId,
|
|
1511
1526
|
data: {
|
|
1512
1527
|
status
|
|
@@ -1523,7 +1538,7 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
1523
1538
|
},
|
|
1524
1539
|
admit: async (request) => {
|
|
1525
1540
|
const traceId = import_keys6.PublicKey.random().toHex();
|
|
1526
|
-
import_log5.log.trace("dxos.sdk.invitation-handler.host.admit",
|
|
1541
|
+
import_log5.log.trace("dxos.sdk.invitation-handler.host.admit", import_protocols5.trace.begin({
|
|
1527
1542
|
id: traceId
|
|
1528
1543
|
}), {
|
|
1529
1544
|
F: __dxlog_file6,
|
|
@@ -1545,7 +1560,7 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
1545
1560
|
throw new Error("Not authenticated");
|
|
1546
1561
|
}
|
|
1547
1562
|
const response = await this._callbacks.admit(request);
|
|
1548
|
-
import_log5.log.trace("dxos.sdk.invitation-handler.host.admit",
|
|
1563
|
+
import_log5.log.trace("dxos.sdk.invitation-handler.host.admit", import_protocols5.trace.end({
|
|
1549
1564
|
id: traceId
|
|
1550
1565
|
}), {
|
|
1551
1566
|
F: __dxlog_file6,
|
|
@@ -1572,7 +1587,7 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
1572
1587
|
timeout: OPTIONS_TIMEOUT
|
|
1573
1588
|
}));
|
|
1574
1589
|
if (this._remoteOptions?.role !== import_invitations2.Options.Role.GUEST) {
|
|
1575
|
-
throw new
|
|
1590
|
+
throw new import_protocols5.InvalidInvitationExtensionRoleError(void 0, {
|
|
1576
1591
|
expected: import_invitations2.Options.Role.GUEST,
|
|
1577
1592
|
remoteOptions: this._remoteOptions
|
|
1578
1593
|
});
|
|
@@ -1590,10 +1605,10 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
|
|
|
1590
1605
|
constructor(_callbacks) {
|
|
1591
1606
|
super({
|
|
1592
1607
|
requested: {
|
|
1593
|
-
InvitationHostService:
|
|
1608
|
+
InvitationHostService: import_protocols5.schema.getService("dxos.halo.invitations.InvitationHostService")
|
|
1594
1609
|
},
|
|
1595
1610
|
exposed: {
|
|
1596
|
-
InvitationHostService:
|
|
1611
|
+
InvitationHostService: import_protocols5.schema.getService("dxos.halo.invitations.InvitationHostService")
|
|
1597
1612
|
}
|
|
1598
1613
|
});
|
|
1599
1614
|
this._callbacks = _callbacks;
|
|
@@ -1650,7 +1665,7 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
|
|
|
1650
1665
|
C: (f, a) => f(...a)
|
|
1651
1666
|
});
|
|
1652
1667
|
if (this._remoteOptions?.role !== import_invitations2.Options.Role.HOST) {
|
|
1653
|
-
throw new
|
|
1668
|
+
throw new import_protocols5.InvalidInvitationExtensionRoleError(void 0, {
|
|
1654
1669
|
expected: import_invitations2.Options.Role.HOST,
|
|
1655
1670
|
remoteOptions: this._remoteOptions
|
|
1656
1671
|
});
|
|
@@ -1763,7 +1778,7 @@ var InvitationsHandler = class {
|
|
|
1763
1778
|
(0, import_async7.scheduleTask)(ctx, async () => {
|
|
1764
1779
|
const traceId = import_keys5.PublicKey.random().toHex();
|
|
1765
1780
|
try {
|
|
1766
|
-
import_log4.log.trace("dxos.sdk.invitations-handler.host.onOpen",
|
|
1781
|
+
import_log4.log.trace("dxos.sdk.invitations-handler.host.onOpen", import_protocols4.trace.begin({
|
|
1767
1782
|
id: traceId
|
|
1768
1783
|
}), {
|
|
1769
1784
|
F: __dxlog_file7,
|
|
@@ -1799,7 +1814,7 @@ var InvitationsHandler = class {
|
|
|
1799
1814
|
...invitation,
|
|
1800
1815
|
state: import_services2.Invitation.State.SUCCESS
|
|
1801
1816
|
});
|
|
1802
|
-
import_log4.log.trace("dxos.sdk.invitations-handler.host.onOpen",
|
|
1817
|
+
import_log4.log.trace("dxos.sdk.invitations-handler.host.onOpen", import_protocols4.trace.end({
|
|
1803
1818
|
id: traceId
|
|
1804
1819
|
}), {
|
|
1805
1820
|
F: __dxlog_file7,
|
|
@@ -1830,7 +1845,7 @@ var InvitationsHandler = class {
|
|
|
1830
1845
|
});
|
|
1831
1846
|
stream.error(err);
|
|
1832
1847
|
}
|
|
1833
|
-
import_log4.log.trace("dxos.sdk.invitations-handler.host.onOpen",
|
|
1848
|
+
import_log4.log.trace("dxos.sdk.invitations-handler.host.onOpen", import_protocols4.trace.error({
|
|
1834
1849
|
id: traceId,
|
|
1835
1850
|
error: err
|
|
1836
1851
|
}), {
|
|
@@ -1848,7 +1863,7 @@ var InvitationsHandler = class {
|
|
|
1848
1863
|
});
|
|
1849
1864
|
},
|
|
1850
1865
|
onError: (err) => {
|
|
1851
|
-
if (err instanceof
|
|
1866
|
+
if (err instanceof import_protocols4.InvalidInvitationExtensionRoleError) {
|
|
1852
1867
|
return;
|
|
1853
1868
|
}
|
|
1854
1869
|
if (err instanceof import_async7.TimeoutError) {
|
|
@@ -1996,7 +2011,7 @@ var InvitationsHandler = class {
|
|
|
1996
2011
|
(0, import_async7.scheduleTask)(ctx, async () => {
|
|
1997
2012
|
const traceId = import_keys5.PublicKey.random().toHex();
|
|
1998
2013
|
try {
|
|
1999
|
-
import_log4.log.trace("dxos.sdk.invitations-handler.guest.onOpen",
|
|
2014
|
+
import_log4.log.trace("dxos.sdk.invitations-handler.guest.onOpen", import_protocols4.trace.begin({
|
|
2000
2015
|
id: traceId
|
|
2001
2016
|
}), {
|
|
2002
2017
|
F: __dxlog_file7,
|
|
@@ -2083,16 +2098,12 @@ var InvitationsHandler = class {
|
|
|
2083
2098
|
}
|
|
2084
2099
|
}
|
|
2085
2100
|
}
|
|
2086
|
-
} else {
|
|
2087
|
-
setState({
|
|
2088
|
-
state: import_services2.Invitation.State.READY_FOR_AUTHENTICATION
|
|
2089
|
-
});
|
|
2090
2101
|
}
|
|
2091
2102
|
(0, import_log4.log)("request admission", {
|
|
2092
2103
|
...protocol.toJSON()
|
|
2093
2104
|
}, {
|
|
2094
2105
|
F: __dxlog_file7,
|
|
2095
|
-
L:
|
|
2106
|
+
L: 309,
|
|
2096
2107
|
S: this,
|
|
2097
2108
|
C: (f, a) => f(...a)
|
|
2098
2109
|
});
|
|
@@ -2104,7 +2115,7 @@ var InvitationsHandler = class {
|
|
|
2104
2115
|
...protocol.toJSON()
|
|
2105
2116
|
}, {
|
|
2106
2117
|
F: __dxlog_file7,
|
|
2107
|
-
L:
|
|
2118
|
+
L: 320,
|
|
2108
2119
|
S: this,
|
|
2109
2120
|
C: (f, a) => f(...a)
|
|
2110
2121
|
});
|
|
@@ -2113,11 +2124,11 @@ var InvitationsHandler = class {
|
|
|
2113
2124
|
target: invitation.target,
|
|
2114
2125
|
state: import_services2.Invitation.State.SUCCESS
|
|
2115
2126
|
});
|
|
2116
|
-
import_log4.log.trace("dxos.sdk.invitations-handler.guest.onOpen",
|
|
2127
|
+
import_log4.log.trace("dxos.sdk.invitations-handler.guest.onOpen", import_protocols4.trace.end({
|
|
2117
2128
|
id: traceId
|
|
2118
2129
|
}), {
|
|
2119
2130
|
F: __dxlog_file7,
|
|
2120
|
-
L:
|
|
2131
|
+
L: 322,
|
|
2121
2132
|
S: this,
|
|
2122
2133
|
C: (f, a) => f(...a)
|
|
2123
2134
|
});
|
|
@@ -2127,7 +2138,7 @@ var InvitationsHandler = class {
|
|
|
2127
2138
|
...protocol.toJSON()
|
|
2128
2139
|
}, {
|
|
2129
2140
|
F: __dxlog_file7,
|
|
2130
|
-
L:
|
|
2141
|
+
L: 325,
|
|
2131
2142
|
S: this,
|
|
2132
2143
|
C: (f, a) => f(...a)
|
|
2133
2144
|
});
|
|
@@ -2137,18 +2148,18 @@ var InvitationsHandler = class {
|
|
|
2137
2148
|
} else {
|
|
2138
2149
|
(0, import_log4.log)("auth failed", err, {
|
|
2139
2150
|
F: __dxlog_file7,
|
|
2140
|
-
L:
|
|
2151
|
+
L: 328,
|
|
2141
2152
|
S: this,
|
|
2142
2153
|
C: (f, a) => f(...a)
|
|
2143
2154
|
});
|
|
2144
2155
|
stream.error(err);
|
|
2145
2156
|
}
|
|
2146
|
-
import_log4.log.trace("dxos.sdk.invitations-handler.guest.onOpen",
|
|
2157
|
+
import_log4.log.trace("dxos.sdk.invitations-handler.guest.onOpen", import_protocols4.trace.error({
|
|
2147
2158
|
id: traceId,
|
|
2148
2159
|
error: err
|
|
2149
2160
|
}), {
|
|
2150
2161
|
F: __dxlog_file7,
|
|
2151
|
-
L:
|
|
2162
|
+
L: 331,
|
|
2152
2163
|
S: this,
|
|
2153
2164
|
C: (f, a) => f(...a)
|
|
2154
2165
|
});
|
|
@@ -2158,7 +2169,7 @@ var InvitationsHandler = class {
|
|
|
2158
2169
|
});
|
|
2159
2170
|
},
|
|
2160
2171
|
onError: (err) => {
|
|
2161
|
-
if (err instanceof
|
|
2172
|
+
if (err instanceof import_protocols4.InvalidInvitationExtensionRoleError) {
|
|
2162
2173
|
return;
|
|
2163
2174
|
}
|
|
2164
2175
|
if (err instanceof import_async7.TimeoutError) {
|
|
@@ -2166,7 +2177,7 @@ var InvitationsHandler = class {
|
|
|
2166
2177
|
...protocol.toJSON()
|
|
2167
2178
|
}, {
|
|
2168
2179
|
F: __dxlog_file7,
|
|
2169
|
-
L:
|
|
2180
|
+
L: 342,
|
|
2170
2181
|
S: this,
|
|
2171
2182
|
C: (f, a) => f(...a)
|
|
2172
2183
|
});
|
|
@@ -2176,7 +2187,7 @@ var InvitationsHandler = class {
|
|
|
2176
2187
|
} else {
|
|
2177
2188
|
(0, import_log4.log)("auth failed", err, {
|
|
2178
2189
|
F: __dxlog_file7,
|
|
2179
|
-
L:
|
|
2190
|
+
L: 345,
|
|
2180
2191
|
S: this,
|
|
2181
2192
|
C: (f, a) => f(...a)
|
|
2182
2193
|
});
|
|
@@ -2187,29 +2198,34 @@ var InvitationsHandler = class {
|
|
|
2187
2198
|
return extension;
|
|
2188
2199
|
};
|
|
2189
2200
|
(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
|
-
|
|
2201
|
+
const error = protocol.checkInvitation(invitation);
|
|
2202
|
+
if (error) {
|
|
2203
|
+
stream.error(error);
|
|
2204
|
+
} else {
|
|
2205
|
+
(0, import_invariant5.invariant)(invitation.swarmKey, void 0, {
|
|
2206
|
+
F: __dxlog_file7,
|
|
2207
|
+
L: 359,
|
|
2208
|
+
S: this,
|
|
2209
|
+
A: [
|
|
2210
|
+
"invitation.swarmKey",
|
|
2211
|
+
""
|
|
2212
|
+
]
|
|
2213
|
+
});
|
|
2214
|
+
const topic = invitation.swarmKey;
|
|
2215
|
+
const swarmConnection = await this._networkManager.joinSwarm({
|
|
2216
|
+
topic,
|
|
2217
|
+
peerId: import_keys5.PublicKey.random(),
|
|
2218
|
+
protocolProvider: (0, import_network_manager.createTeleportProtocolFactory)(async (teleport) => {
|
|
2219
|
+
teleport.addExtension("dxos.halo.invitations", createExtension());
|
|
2220
|
+
}),
|
|
2221
|
+
topology: new import_network_manager.StarTopology(topic),
|
|
2222
|
+
label: "invitation guest"
|
|
2223
|
+
});
|
|
2224
|
+
ctx.onDispose(() => swarmConnection.close());
|
|
2225
|
+
setState({
|
|
2226
|
+
state: import_services2.Invitation.State.CONNECTING
|
|
2227
|
+
});
|
|
2228
|
+
}
|
|
2213
2229
|
});
|
|
2214
2230
|
const observable = new import_client_protocol2.AuthenticatingInvitation({
|
|
2215
2231
|
initialInvitation: invitation,
|
|
@@ -2425,7 +2441,7 @@ var SpaceInvitationProtocol = class {
|
|
|
2425
2441
|
async admit(request, guestProfile) {
|
|
2426
2442
|
(0, import_invariant8.invariant)(this._spaceKey, void 0, {
|
|
2427
2443
|
F: __dxlog_file9,
|
|
2428
|
-
L:
|
|
2444
|
+
L: 47,
|
|
2429
2445
|
S: this,
|
|
2430
2446
|
A: [
|
|
2431
2447
|
"this._spaceKey",
|
|
@@ -2435,7 +2451,7 @@ var SpaceInvitationProtocol = class {
|
|
|
2435
2451
|
const space = await this._spaceManager.spaces.get(this._spaceKey);
|
|
2436
2452
|
(0, import_invariant8.invariant)(space, void 0, {
|
|
2437
2453
|
F: __dxlog_file9,
|
|
2438
|
-
L:
|
|
2454
|
+
L: 49,
|
|
2439
2455
|
S: this,
|
|
2440
2456
|
A: [
|
|
2441
2457
|
"space",
|
|
@@ -2444,7 +2460,7 @@ var SpaceInvitationProtocol = class {
|
|
|
2444
2460
|
});
|
|
2445
2461
|
(0, import_invariant8.invariant)(request.space, void 0, {
|
|
2446
2462
|
F: __dxlog_file9,
|
|
2447
|
-
L:
|
|
2463
|
+
L: 51,
|
|
2448
2464
|
S: this,
|
|
2449
2465
|
A: [
|
|
2450
2466
|
"request.space",
|
|
@@ -2457,14 +2473,14 @@ var SpaceInvitationProtocol = class {
|
|
|
2457
2473
|
guest: deviceKey
|
|
2458
2474
|
}, {
|
|
2459
2475
|
F: __dxlog_file9,
|
|
2460
|
-
L:
|
|
2476
|
+
L: 54,
|
|
2461
2477
|
S: this,
|
|
2462
2478
|
C: (f, a) => f(...a)
|
|
2463
2479
|
});
|
|
2464
2480
|
const credentials = await (0, import_credentials8.createAdmissionCredentials)(this._signingContext.credentialSigner, identityKey, space.key, space.inner.genesisFeedKey, guestProfile);
|
|
2465
2481
|
(0, import_invariant8.invariant)(credentials[0].credential, void 0, {
|
|
2466
2482
|
F: __dxlog_file9,
|
|
2467
|
-
L:
|
|
2483
|
+
L: 65,
|
|
2468
2484
|
S: this,
|
|
2469
2485
|
A: [
|
|
2470
2486
|
"credentials[0].credential",
|
|
@@ -2474,7 +2490,7 @@ var SpaceInvitationProtocol = class {
|
|
|
2474
2490
|
const spaceMemberCredential = credentials[0].credential.credential;
|
|
2475
2491
|
(0, import_invariant8.invariant)((0, import_credentials8.getCredentialAssertion)(spaceMemberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
|
|
2476
2492
|
F: __dxlog_file9,
|
|
2477
|
-
L:
|
|
2493
|
+
L: 67,
|
|
2478
2494
|
S: this,
|
|
2479
2495
|
A: [
|
|
2480
2496
|
"getCredentialAssertion(spaceMemberCredential)['@type'] === 'dxos.halo.credentials.SpaceMember'",
|
|
@@ -2490,6 +2506,11 @@ var SpaceInvitationProtocol = class {
|
|
|
2490
2506
|
}
|
|
2491
2507
|
};
|
|
2492
2508
|
}
|
|
2509
|
+
checkInvitation(invitation) {
|
|
2510
|
+
if (invitation.spaceKey && this._spaceManager.spaces.has(invitation.spaceKey)) {
|
|
2511
|
+
return new import_protocols6.AlreadyJoinedError("Already joined space.");
|
|
2512
|
+
}
|
|
2513
|
+
}
|
|
2493
2514
|
createIntroduction() {
|
|
2494
2515
|
return {
|
|
2495
2516
|
profile: this._signingContext.getProfile()
|
|
@@ -2510,7 +2531,7 @@ var SpaceInvitationProtocol = class {
|
|
|
2510
2531
|
async accept(response) {
|
|
2511
2532
|
(0, import_invariant8.invariant)(response.space, void 0, {
|
|
2512
2533
|
F: __dxlog_file9,
|
|
2513
|
-
L:
|
|
2534
|
+
L: 108,
|
|
2514
2535
|
S: this,
|
|
2515
2536
|
A: [
|
|
2516
2537
|
"response.space",
|
|
@@ -2521,7 +2542,7 @@ var SpaceInvitationProtocol = class {
|
|
|
2521
2542
|
const assertion = (0, import_credentials8.getCredentialAssertion)(credential);
|
|
2522
2543
|
(0, import_invariant8.invariant)(assertion["@type"] === "dxos.halo.credentials.SpaceMember", "Invalid credential", {
|
|
2523
2544
|
F: __dxlog_file9,
|
|
2524
|
-
L:
|
|
2545
|
+
L: 111,
|
|
2525
2546
|
S: this,
|
|
2526
2547
|
A: [
|
|
2527
2548
|
"assertion['@type'] === 'dxos.halo.credentials.SpaceMember'",
|
|
@@ -2530,13 +2551,16 @@ var SpaceInvitationProtocol = class {
|
|
|
2530
2551
|
});
|
|
2531
2552
|
(0, import_invariant8.invariant)(credential.subject.id.equals(this._signingContext.identityKey), void 0, {
|
|
2532
2553
|
F: __dxlog_file9,
|
|
2533
|
-
L:
|
|
2554
|
+
L: 112,
|
|
2534
2555
|
S: this,
|
|
2535
2556
|
A: [
|
|
2536
2557
|
"credential.subject.id.equals(this._signingContext.identityKey)",
|
|
2537
2558
|
""
|
|
2538
2559
|
]
|
|
2539
2560
|
});
|
|
2561
|
+
if (this._spaceManager.spaces.has(assertion.spaceKey)) {
|
|
2562
|
+
throw new import_protocols6.AlreadyJoinedError("Already joined space.");
|
|
2563
|
+
}
|
|
2540
2564
|
await this._spaceManager.acceptSpace({
|
|
2541
2565
|
spaceKey: assertion.spaceKey,
|
|
2542
2566
|
genesisFeedKey: assertion.genesisFeedKey,
|
|
@@ -2559,7 +2583,7 @@ function _ts_decorate3(decorators, target, key, desc) {
|
|
|
2559
2583
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
2560
2584
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2561
2585
|
}
|
|
2562
|
-
var ClientRpcServer = class
|
|
2586
|
+
var ClientRpcServer = class {
|
|
2563
2587
|
constructor(params) {
|
|
2564
2588
|
this._handlerCache = /* @__PURE__ */ new Map();
|
|
2565
2589
|
this._callMetrics = new import_tracing3.MapCounter();
|
|
@@ -2629,28 +2653,29 @@ var getPlatform = () => {
|
|
|
2629
2653
|
if (typeof window !== "undefined") {
|
|
2630
2654
|
const { userAgent } = window.navigator;
|
|
2631
2655
|
return {
|
|
2632
|
-
type:
|
|
2656
|
+
type: import_services7.Platform.PLATFORM_TYPE.BROWSER,
|
|
2633
2657
|
userAgent,
|
|
2634
2658
|
uptime: Math.floor((Date.now() - window.performance.timeOrigin) / 1e3)
|
|
2635
2659
|
};
|
|
2636
2660
|
} else {
|
|
2637
2661
|
return {
|
|
2638
|
-
type:
|
|
2662
|
+
type: import_services7.Platform.PLATFORM_TYPE.SHARED_WORKER,
|
|
2639
2663
|
uptime: Math.floor((Date.now() - performance.timeOrigin) / 1e3)
|
|
2640
2664
|
};
|
|
2641
2665
|
}
|
|
2642
2666
|
} else {
|
|
2643
2667
|
const { platform: platform2, version, arch } = process;
|
|
2644
2668
|
return {
|
|
2645
|
-
type:
|
|
2646
|
-
platform:
|
|
2647
|
-
|
|
2669
|
+
type: import_services7.Platform.PLATFORM_TYPE.NODE,
|
|
2670
|
+
platform: platform2,
|
|
2671
|
+
arch,
|
|
2672
|
+
runtime: version,
|
|
2648
2673
|
uptime: Math.floor(process.uptime()),
|
|
2649
2674
|
memory: process.memoryUsage()
|
|
2650
2675
|
};
|
|
2651
2676
|
}
|
|
2652
2677
|
};
|
|
2653
|
-
var DXOS_VERSION = "0.3.11-main.
|
|
2678
|
+
var DXOS_VERSION = "0.3.11-main.ee2b64c";
|
|
2654
2679
|
var __dxlog_file10 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/diagnostics.ts";
|
|
2655
2680
|
var DEFAULT_TIMEOUT = 1e3;
|
|
2656
2681
|
var createDiagnostics = async (clientServices, serviceContext, config) => {
|
|
@@ -2660,14 +2685,15 @@ var createDiagnostics = async (clientServices, serviceContext, config) => {
|
|
|
2660
2685
|
client: {
|
|
2661
2686
|
version: DXOS_VERSION,
|
|
2662
2687
|
storage: {
|
|
2663
|
-
version:
|
|
2688
|
+
version: import_protocols7.STORAGE_VERSION
|
|
2664
2689
|
}
|
|
2665
|
-
}
|
|
2690
|
+
},
|
|
2691
|
+
trace: import_tracing4.TRACE_PROCESSOR.getDiagnostics()
|
|
2666
2692
|
};
|
|
2667
2693
|
{
|
|
2668
2694
|
(0, import_invariant9.invariant)(clientServices.LoggingService, "SystemService is not available.", {
|
|
2669
2695
|
F: __dxlog_file10,
|
|
2670
|
-
L:
|
|
2696
|
+
L: 111,
|
|
2671
2697
|
S: void 0,
|
|
2672
2698
|
A: [
|
|
2673
2699
|
"clientServices.LoggingService",
|
|
@@ -2678,6 +2704,21 @@ var createDiagnostics = async (clientServices, serviceContext, config) => {
|
|
|
2678
2704
|
timeout: DEFAULT_TIMEOUT
|
|
2679
2705
|
}).catch(() => void 0);
|
|
2680
2706
|
}
|
|
2707
|
+
if (typeof navigator !== "undefined" && navigator.storage) {
|
|
2708
|
+
const map = /* @__PURE__ */ new Map();
|
|
2709
|
+
const dir = await navigator.storage.getDirectory();
|
|
2710
|
+
for await (const filename of dir?.keys()) {
|
|
2711
|
+
const idx = filename.indexOf("-", filename.indexOf("-") + 1);
|
|
2712
|
+
if (idx === -1) {
|
|
2713
|
+
continue;
|
|
2714
|
+
}
|
|
2715
|
+
map.set(filename.slice(0, idx), (map.get(filename.slice(0, idx)) ?? 0) + 1);
|
|
2716
|
+
}
|
|
2717
|
+
diagnostics.storage = Array.from(map.entries()).sort((a, b) => b[1] - a[1]).map(([file, count]) => ({
|
|
2718
|
+
file,
|
|
2719
|
+
count
|
|
2720
|
+
}));
|
|
2721
|
+
}
|
|
2681
2722
|
const identity = serviceContext.identityManager.identity;
|
|
2682
2723
|
if (identity) {
|
|
2683
2724
|
diagnostics.identity = {
|
|
@@ -2718,7 +2759,7 @@ var getProperties = (space) => {
|
|
|
2718
2759
|
} catch (err) {
|
|
2719
2760
|
import_log8.log.warn(err.message, void 0, {
|
|
2720
2761
|
F: __dxlog_file10,
|
|
2721
|
-
L:
|
|
2762
|
+
L: 196,
|
|
2722
2763
|
S: void 0,
|
|
2723
2764
|
C: (f, a) => f(...a)
|
|
2724
2765
|
});
|
|
@@ -2773,7 +2814,8 @@ var getSpaceStats = async (space) => {
|
|
|
2773
2814
|
return stats;
|
|
2774
2815
|
};
|
|
2775
2816
|
var AutomergeSpaceState = class {
|
|
2776
|
-
constructor() {
|
|
2817
|
+
constructor(_onNewRoot) {
|
|
2818
|
+
this._onNewRoot = _onNewRoot;
|
|
2777
2819
|
this.rootUrl = void 0;
|
|
2778
2820
|
this.lastEpoch = void 0;
|
|
2779
2821
|
}
|
|
@@ -2784,6 +2826,7 @@ var AutomergeSpaceState = class {
|
|
|
2784
2826
|
this.lastEpoch = credential;
|
|
2785
2827
|
if (credential.subject.assertion.automergeRoot) {
|
|
2786
2828
|
this.rootUrl = credential.subject.assertion.automergeRoot;
|
|
2829
|
+
this._onNewRoot(this.rootUrl);
|
|
2787
2830
|
}
|
|
2788
2831
|
}
|
|
2789
2832
|
};
|
|
@@ -2820,7 +2863,7 @@ var NotarizationPlugin = class {
|
|
|
2820
2863
|
S: this,
|
|
2821
2864
|
C: (f, a) => f(...a)
|
|
2822
2865
|
});
|
|
2823
|
-
(0,
|
|
2866
|
+
(0, import_invariant11.invariant)(credentials.every((credential) => credential.id), "Credentials must have an id", {
|
|
2824
2867
|
F: __dxlog_file11,
|
|
2825
2868
|
L: 91,
|
|
2826
2869
|
S: this,
|
|
@@ -2945,7 +2988,7 @@ var NotarizationPlugin = class {
|
|
|
2945
2988
|
this._processCredentialsTriggers.delete(credential.id);
|
|
2946
2989
|
}
|
|
2947
2990
|
setWriter(writer) {
|
|
2948
|
-
(0,
|
|
2991
|
+
(0, import_invariant11.invariant)(!this._writer, "Writer already set.", {
|
|
2949
2992
|
F: __dxlog_file11,
|
|
2950
2993
|
L: 181,
|
|
2951
2994
|
S: this,
|
|
@@ -2970,7 +3013,7 @@ var NotarizationPlugin = class {
|
|
|
2970
3013
|
throw new Error(WRITER_NOT_SET_ERROR_CODE);
|
|
2971
3014
|
}
|
|
2972
3015
|
for (const credential of request.credentials ?? []) {
|
|
2973
|
-
(0,
|
|
3016
|
+
(0, import_invariant11.invariant)(credential.id, "Credential must have an id", {
|
|
2974
3017
|
F: __dxlog_file11,
|
|
2975
3018
|
L: 200,
|
|
2976
3019
|
S: this,
|
|
@@ -3019,10 +3062,10 @@ var NotarizationTeleportExtension = class extends import_teleport2.RpcExtension
|
|
|
3019
3062
|
constructor(_params) {
|
|
3020
3063
|
super({
|
|
3021
3064
|
requested: {
|
|
3022
|
-
NotarizationService:
|
|
3065
|
+
NotarizationService: import_protocols9.schema.getService("dxos.mesh.teleport.notarization.NotarizationService")
|
|
3023
3066
|
},
|
|
3024
3067
|
exposed: {
|
|
3025
|
-
NotarizationService:
|
|
3068
|
+
NotarizationService: import_protocols9.schema.getService("dxos.mesh.teleport.notarization.NotarizationService")
|
|
3026
3069
|
}
|
|
3027
3070
|
});
|
|
3028
3071
|
this._params = _params;
|
|
@@ -3057,13 +3100,13 @@ function _ts_decorate4(decorators, target, key, desc) {
|
|
|
3057
3100
|
}
|
|
3058
3101
|
var __dxlog_file12 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space.ts";
|
|
3059
3102
|
var ENABLE_FEED_PURGE = false;
|
|
3060
|
-
var DataSpace = class
|
|
3103
|
+
var DataSpace = class {
|
|
3061
3104
|
constructor(params) {
|
|
3062
3105
|
this._ctx = new import_context6.Context();
|
|
3063
3106
|
this._notarizationPlugin = new NotarizationPlugin();
|
|
3064
3107
|
this._cache = void 0;
|
|
3065
|
-
this._automergeSpaceState = new AutomergeSpaceState();
|
|
3066
|
-
this._state =
|
|
3108
|
+
this._automergeSpaceState = new AutomergeSpaceState((rootUrl) => this._onNewAutomergeRoot(rootUrl));
|
|
3109
|
+
this._state = import_services8.SpaceState.CLOSED;
|
|
3067
3110
|
this.error = void 0;
|
|
3068
3111
|
this.stateUpdate = new import_async10.Event();
|
|
3069
3112
|
this.metrics = {};
|
|
@@ -3085,10 +3128,10 @@ var DataSpace = class DataSpace2 {
|
|
|
3085
3128
|
this._cache = params.cache;
|
|
3086
3129
|
this._state = params.initialState;
|
|
3087
3130
|
(0, import_log9.log)("new state", {
|
|
3088
|
-
state:
|
|
3131
|
+
state: import_services8.SpaceState[this._state]
|
|
3089
3132
|
}, {
|
|
3090
3133
|
F: __dxlog_file12,
|
|
3091
|
-
L:
|
|
3134
|
+
L: 141,
|
|
3092
3135
|
S: this,
|
|
3093
3136
|
C: (f, a) => f(...a)
|
|
3094
3137
|
});
|
|
@@ -3121,6 +3164,12 @@ var DataSpace = class DataSpace2 {
|
|
|
3121
3164
|
get automergeSpaceState() {
|
|
3122
3165
|
return this._automergeSpaceState;
|
|
3123
3166
|
}
|
|
3167
|
+
get _automergeInfo() {
|
|
3168
|
+
return {
|
|
3169
|
+
rootUrl: this._automergeSpaceState.rootUrl,
|
|
3170
|
+
lastEpoch: this._automergeSpaceState.lastEpoch
|
|
3171
|
+
};
|
|
3172
|
+
}
|
|
3124
3173
|
async open() {
|
|
3125
3174
|
await this._open();
|
|
3126
3175
|
}
|
|
@@ -3130,12 +3179,12 @@ var DataSpace = class DataSpace2 {
|
|
|
3130
3179
|
await this._inner.spaceState.addCredentialProcessor(this._notarizationPlugin);
|
|
3131
3180
|
await this._inner.spaceState.addCredentialProcessor(this._automergeSpaceState);
|
|
3132
3181
|
await this._inner.open(new import_context6.Context());
|
|
3133
|
-
this._state =
|
|
3182
|
+
this._state = import_services8.SpaceState.CONTROL_ONLY;
|
|
3134
3183
|
(0, import_log9.log)("new state", {
|
|
3135
|
-
state:
|
|
3184
|
+
state: import_services8.SpaceState[this._state]
|
|
3136
3185
|
}, {
|
|
3137
3186
|
F: __dxlog_file12,
|
|
3138
|
-
L:
|
|
3187
|
+
L: 203,
|
|
3139
3188
|
S: this,
|
|
3140
3189
|
C: (f, a) => f(...a)
|
|
3141
3190
|
});
|
|
@@ -3148,12 +3197,12 @@ var DataSpace = class DataSpace2 {
|
|
|
3148
3197
|
}
|
|
3149
3198
|
async _close() {
|
|
3150
3199
|
await this._callbacks.beforeClose?.();
|
|
3151
|
-
this._state =
|
|
3200
|
+
this._state = import_services8.SpaceState.CLOSED;
|
|
3152
3201
|
(0, import_log9.log)("new state", {
|
|
3153
|
-
state:
|
|
3202
|
+
state: import_services8.SpaceState[this._state]
|
|
3154
3203
|
}, {
|
|
3155
3204
|
F: __dxlog_file12,
|
|
3156
|
-
L:
|
|
3205
|
+
L: 217,
|
|
3157
3206
|
S: this,
|
|
3158
3207
|
C: (f, a) => f(...a)
|
|
3159
3208
|
});
|
|
@@ -3182,10 +3231,10 @@ var DataSpace = class DataSpace2 {
|
|
|
3182
3231
|
this.metrics.pipelineInitBegin = /* @__PURE__ */ new Date();
|
|
3183
3232
|
await this.initializeDataPipeline();
|
|
3184
3233
|
} catch (err) {
|
|
3185
|
-
if (err instanceof
|
|
3234
|
+
if (err instanceof import_protocols8.CancelledError || err instanceof import_context6.ContextDisposedError) {
|
|
3186
3235
|
(0, import_log9.log)("data pipeline initialization cancelled", err, {
|
|
3187
3236
|
F: __dxlog_file12,
|
|
3188
|
-
L:
|
|
3237
|
+
L: 250,
|
|
3189
3238
|
S: this,
|
|
3190
3239
|
C: (f, a) => f(...a)
|
|
3191
3240
|
});
|
|
@@ -3193,16 +3242,16 @@ var DataSpace = class DataSpace2 {
|
|
|
3193
3242
|
}
|
|
3194
3243
|
import_log9.log.error("Error initializing data pipeline", err, {
|
|
3195
3244
|
F: __dxlog_file12,
|
|
3196
|
-
L:
|
|
3245
|
+
L: 254,
|
|
3197
3246
|
S: this,
|
|
3198
3247
|
C: (f, a) => f(...a)
|
|
3199
3248
|
});
|
|
3200
|
-
this._state =
|
|
3249
|
+
this._state = import_services8.SpaceState.ERROR;
|
|
3201
3250
|
(0, import_log9.log)("new state", {
|
|
3202
|
-
state:
|
|
3251
|
+
state: import_services8.SpaceState[this._state]
|
|
3203
3252
|
}, {
|
|
3204
3253
|
F: __dxlog_file12,
|
|
3205
|
-
L:
|
|
3254
|
+
L: 256,
|
|
3206
3255
|
S: this,
|
|
3207
3256
|
C: (f, a) => f(...a)
|
|
3208
3257
|
});
|
|
@@ -3214,15 +3263,15 @@ var DataSpace = class DataSpace2 {
|
|
|
3214
3263
|
});
|
|
3215
3264
|
}
|
|
3216
3265
|
async initializeDataPipeline() {
|
|
3217
|
-
if (this._state !==
|
|
3218
|
-
throw new
|
|
3266
|
+
if (this._state !== import_services8.SpaceState.CONTROL_ONLY) {
|
|
3267
|
+
throw new import_protocols8.SystemError("Invalid operation");
|
|
3219
3268
|
}
|
|
3220
|
-
this._state =
|
|
3269
|
+
this._state = import_services8.SpaceState.INITIALIZING;
|
|
3221
3270
|
(0, import_log9.log)("new state", {
|
|
3222
|
-
state:
|
|
3271
|
+
state: import_services8.SpaceState[this._state]
|
|
3223
3272
|
}, {
|
|
3224
3273
|
F: __dxlog_file12,
|
|
3225
|
-
L:
|
|
3274
|
+
L: 272,
|
|
3226
3275
|
S: this,
|
|
3227
3276
|
C: (f, a) => f(...a)
|
|
3228
3277
|
});
|
|
@@ -3233,7 +3282,7 @@ var DataSpace = class DataSpace2 {
|
|
|
3233
3282
|
await (0, import_context6.cancelWithContext)(this._ctx, this._inner.dataPipeline.ensureEpochInitialized());
|
|
3234
3283
|
(0, import_log9.log)("waiting for data pipeline to reach target timeframe", void 0, {
|
|
3235
3284
|
F: __dxlog_file12,
|
|
3236
|
-
L:
|
|
3285
|
+
L: 286,
|
|
3237
3286
|
S: this,
|
|
3238
3287
|
C: (f, a) => f(...a)
|
|
3239
3288
|
});
|
|
@@ -3244,17 +3293,17 @@ var DataSpace = class DataSpace2 {
|
|
|
3244
3293
|
this.metrics.dataPipelineReady = /* @__PURE__ */ new Date();
|
|
3245
3294
|
(0, import_log9.log)("data pipeline ready", void 0, {
|
|
3246
3295
|
F: __dxlog_file12,
|
|
3247
|
-
L:
|
|
3296
|
+
L: 295,
|
|
3248
3297
|
S: this,
|
|
3249
3298
|
C: (f, a) => f(...a)
|
|
3250
3299
|
});
|
|
3251
3300
|
await this._callbacks.beforeReady?.();
|
|
3252
|
-
this._state =
|
|
3301
|
+
this._state = import_services8.SpaceState.READY;
|
|
3253
3302
|
(0, import_log9.log)("new state", {
|
|
3254
|
-
state:
|
|
3303
|
+
state: import_services8.SpaceState[this._state]
|
|
3255
3304
|
}, {
|
|
3256
3305
|
F: __dxlog_file12,
|
|
3257
|
-
L:
|
|
3306
|
+
L: 299,
|
|
3258
3307
|
S: this,
|
|
3259
3308
|
C: (f, a) => f(...a)
|
|
3260
3309
|
});
|
|
@@ -3270,7 +3319,7 @@ var DataSpace = class DataSpace2 {
|
|
|
3270
3319
|
await this._createWritableFeeds();
|
|
3271
3320
|
(0, import_log9.log)("writable feeds created", void 0, {
|
|
3272
3321
|
F: __dxlog_file12,
|
|
3273
|
-
L:
|
|
3322
|
+
L: 315,
|
|
3274
3323
|
S: this,
|
|
3275
3324
|
C: (f, a) => f(...a)
|
|
3276
3325
|
});
|
|
@@ -3327,6 +3376,40 @@ var DataSpace = class DataSpace2 {
|
|
|
3327
3376
|
await this._metadataStore.setWritableFeedKeys(this.key, this.inner.controlFeedKey, this.inner.dataFeedKey);
|
|
3328
3377
|
}
|
|
3329
3378
|
}
|
|
3379
|
+
_onNewAutomergeRoot(rootUrl) {
|
|
3380
|
+
(0, import_log9.log)("loading automerge root doc for space", {
|
|
3381
|
+
space: this.key,
|
|
3382
|
+
rootUrl
|
|
3383
|
+
}, {
|
|
3384
|
+
F: __dxlog_file12,
|
|
3385
|
+
L: 381,
|
|
3386
|
+
S: this,
|
|
3387
|
+
C: (f, a) => f(...a)
|
|
3388
|
+
});
|
|
3389
|
+
const handle = this._automergeHost.repo.find(rootUrl);
|
|
3390
|
+
queueMicrotask(async () => {
|
|
3391
|
+
try {
|
|
3392
|
+
await (0, import_async10.asyncTimeout)(handle.whenReady(), 5e3);
|
|
3393
|
+
const doc = handle.docSync() ?? (0, import_invariant10.failedInvariant)();
|
|
3394
|
+
if (!doc.experimental_spaceKey) {
|
|
3395
|
+
handle.change((doc2) => {
|
|
3396
|
+
doc2.experimental_spaceKey = this.key.toHex();
|
|
3397
|
+
});
|
|
3398
|
+
}
|
|
3399
|
+
} catch (err) {
|
|
3400
|
+
import_log9.log.warn("error loading automerge root doc", {
|
|
3401
|
+
space: this.key,
|
|
3402
|
+
rootUrl,
|
|
3403
|
+
err
|
|
3404
|
+
}, {
|
|
3405
|
+
F: __dxlog_file12,
|
|
3406
|
+
L: 394,
|
|
3407
|
+
S: this,
|
|
3408
|
+
C: (f, a) => f(...a)
|
|
3409
|
+
});
|
|
3410
|
+
}
|
|
3411
|
+
});
|
|
3412
|
+
}
|
|
3330
3413
|
// TODO(dmaretskyi): Use profile from signing context.
|
|
3331
3414
|
async updateOwnProfile(profile) {
|
|
3332
3415
|
const credential = await this._signingContext.credentialSigner.createCredential({
|
|
@@ -3346,12 +3429,12 @@ var DataSpace = class DataSpace2 {
|
|
|
3346
3429
|
let epoch;
|
|
3347
3430
|
switch (options?.migration) {
|
|
3348
3431
|
case void 0:
|
|
3349
|
-
case
|
|
3432
|
+
case import_services8.CreateEpochRequest.Migration.NONE:
|
|
3350
3433
|
{
|
|
3351
3434
|
epoch = await this.dataPipeline.createEpoch();
|
|
3352
3435
|
}
|
|
3353
3436
|
break;
|
|
3354
|
-
case
|
|
3437
|
+
case import_services8.CreateEpochRequest.Migration.INIT_AUTOMERGE: {
|
|
3355
3438
|
const document = this._automergeHost.repo.create();
|
|
3356
3439
|
epoch = {
|
|
3357
3440
|
previousId: this._automergeSpaceState.lastEpoch?.id,
|
|
@@ -3392,31 +3475,47 @@ var DataSpace = class DataSpace2 {
|
|
|
3392
3475
|
}
|
|
3393
3476
|
}
|
|
3394
3477
|
async activate() {
|
|
3395
|
-
if (this._state !==
|
|
3478
|
+
if (this._state !== import_services8.SpaceState.INACTIVE) {
|
|
3396
3479
|
return;
|
|
3397
3480
|
}
|
|
3398
|
-
await this._metadataStore.setSpaceState(this.key,
|
|
3481
|
+
await this._metadataStore.setSpaceState(this.key, import_services8.SpaceState.ACTIVE);
|
|
3399
3482
|
await this._open();
|
|
3400
3483
|
this.initializeDataPipelineAsync();
|
|
3401
3484
|
}
|
|
3402
3485
|
async deactivate() {
|
|
3403
|
-
if (this._state ===
|
|
3486
|
+
if (this._state === import_services8.SpaceState.INACTIVE) {
|
|
3404
3487
|
return;
|
|
3405
3488
|
}
|
|
3406
|
-
await this._metadataStore.setSpaceState(this.key,
|
|
3489
|
+
await this._metadataStore.setSpaceState(this.key, import_services8.SpaceState.INACTIVE);
|
|
3407
3490
|
await this._close();
|
|
3408
|
-
this._state =
|
|
3491
|
+
this._state = import_services8.SpaceState.INACTIVE;
|
|
3409
3492
|
(0, import_log9.log)("new state", {
|
|
3410
|
-
state:
|
|
3493
|
+
state: import_services8.SpaceState[this._state]
|
|
3411
3494
|
}, {
|
|
3412
3495
|
F: __dxlog_file12,
|
|
3413
|
-
L:
|
|
3496
|
+
L: 483,
|
|
3414
3497
|
S: this,
|
|
3415
3498
|
C: (f, a) => f(...a)
|
|
3416
3499
|
});
|
|
3417
3500
|
this.stateUpdate.emit();
|
|
3418
3501
|
}
|
|
3419
3502
|
};
|
|
3503
|
+
_ts_decorate4([
|
|
3504
|
+
import_tracing5.trace.info()
|
|
3505
|
+
], DataSpace.prototype, "_inner", void 0);
|
|
3506
|
+
_ts_decorate4([
|
|
3507
|
+
import_tracing5.trace.info()
|
|
3508
|
+
], DataSpace.prototype, "key", null);
|
|
3509
|
+
_ts_decorate4([
|
|
3510
|
+
import_tracing5.trace.info({
|
|
3511
|
+
enum: import_services8.SpaceState
|
|
3512
|
+
})
|
|
3513
|
+
], DataSpace.prototype, "state", null);
|
|
3514
|
+
_ts_decorate4([
|
|
3515
|
+
import_tracing5.trace.info({
|
|
3516
|
+
depth: null
|
|
3517
|
+
})
|
|
3518
|
+
], DataSpace.prototype, "_automergeInfo", null);
|
|
3420
3519
|
_ts_decorate4([
|
|
3421
3520
|
import_async10.synchronized
|
|
3422
3521
|
], DataSpace.prototype, "open", null);
|
|
@@ -3424,12 +3523,12 @@ _ts_decorate4([
|
|
|
3424
3523
|
import_async10.synchronized
|
|
3425
3524
|
], DataSpace.prototype, "close", null);
|
|
3426
3525
|
_ts_decorate4([
|
|
3427
|
-
|
|
3526
|
+
import_tracing5.trace.span({
|
|
3428
3527
|
showInBrowserTimeline: true
|
|
3429
3528
|
})
|
|
3430
3529
|
], DataSpace.prototype, "initializeDataPipeline", null);
|
|
3431
3530
|
_ts_decorate4([
|
|
3432
|
-
|
|
3531
|
+
import_tracing5.trace.span({
|
|
3433
3532
|
showInBrowserTimeline: true
|
|
3434
3533
|
})
|
|
3435
3534
|
], DataSpace.prototype, "_initializeAndReadControlPipeline", null);
|
|
@@ -3443,7 +3542,8 @@ _ts_decorate4([
|
|
|
3443
3542
|
import_async10.synchronized
|
|
3444
3543
|
], DataSpace.prototype, "deactivate", null);
|
|
3445
3544
|
DataSpace = _ts_decorate4([
|
|
3446
|
-
(0, import_async10.trackLeaks)("open", "close")
|
|
3545
|
+
(0, import_async10.trackLeaks)("open", "close"),
|
|
3546
|
+
import_tracing5.trace.resource()
|
|
3447
3547
|
], DataSpace);
|
|
3448
3548
|
var spaceGenesis = async (keyring, signingContext, space, automergeRoot) => {
|
|
3449
3549
|
const credentials = [
|
|
@@ -3522,7 +3622,7 @@ function _ts_decorate5(decorators, target, key, desc) {
|
|
|
3522
3622
|
var __dxlog_file13 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts";
|
|
3523
3623
|
var PRESENCE_ANNOUNCE_INTERVAL = 1e4;
|
|
3524
3624
|
var PRESENCE_OFFLINE_TIMEOUT = 2e4;
|
|
3525
|
-
var DataSpaceManager = class
|
|
3625
|
+
var DataSpaceManager = class {
|
|
3526
3626
|
constructor(_spaceManager, _metadataStore, _dataServiceSubscriptions, _keyring, _signingContext, _feedStore, _automergeHost) {
|
|
3527
3627
|
this._spaceManager = _spaceManager;
|
|
3528
3628
|
this._metadataStore = _metadataStore;
|
|
@@ -3548,7 +3648,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
3548
3648
|
S: this,
|
|
3549
3649
|
C: (f, a) => f(...a)
|
|
3550
3650
|
});
|
|
3551
|
-
import_log11.log.trace("dxos.echo.data-space-manager.open",
|
|
3651
|
+
import_log11.log.trace("dxos.echo.data-space-manager.open", import_protocols10.trace.begin({
|
|
3552
3652
|
id: this._instanceId
|
|
3553
3653
|
}), {
|
|
3554
3654
|
F: __dxlog_file13,
|
|
@@ -3590,11 +3690,11 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
3590
3690
|
this._isOpen = true;
|
|
3591
3691
|
this.updated.emit();
|
|
3592
3692
|
for (const space of this._spaces.values()) {
|
|
3593
|
-
if (space.state !==
|
|
3693
|
+
if (space.state !== import_services9.SpaceState.INACTIVE) {
|
|
3594
3694
|
space.initializeDataPipelineAsync();
|
|
3595
3695
|
}
|
|
3596
3696
|
}
|
|
3597
|
-
import_log11.log.trace("dxos.echo.data-space-manager.open",
|
|
3697
|
+
import_log11.log.trace("dxos.echo.data-space-manager.open", import_protocols10.trace.end({
|
|
3598
3698
|
id: this._instanceId
|
|
3599
3699
|
}), {
|
|
3600
3700
|
F: __dxlog_file13,
|
|
@@ -3620,7 +3720,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
3620
3720
|
* Creates a new space writing the genesis credentials to the control feed.
|
|
3621
3721
|
*/
|
|
3622
3722
|
async createSpace() {
|
|
3623
|
-
(0,
|
|
3723
|
+
(0, import_invariant12.invariant)(this._isOpen, "Not open.", {
|
|
3624
3724
|
F: __dxlog_file13,
|
|
3625
3725
|
L: 130,
|
|
3626
3726
|
S: this,
|
|
@@ -3637,7 +3737,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
3637
3737
|
genesisFeedKey: controlFeedKey,
|
|
3638
3738
|
controlFeedKey,
|
|
3639
3739
|
dataFeedKey,
|
|
3640
|
-
state:
|
|
3740
|
+
state: import_services9.SpaceState.ACTIVE
|
|
3641
3741
|
};
|
|
3642
3742
|
(0, import_log11.log)("creating space...", {
|
|
3643
3743
|
spaceKey
|
|
@@ -3649,12 +3749,15 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
3649
3749
|
});
|
|
3650
3750
|
const space = await this._constructSpace(metadata);
|
|
3651
3751
|
const automergeRoot = this._automergeHost.repo.create();
|
|
3752
|
+
automergeRoot.change((doc) => {
|
|
3753
|
+
doc.experimental_spaceKey = spaceKey.toHex();
|
|
3754
|
+
});
|
|
3652
3755
|
const credentials = await spaceGenesis(this._keyring, this._signingContext, space.inner, automergeRoot.url);
|
|
3653
3756
|
await this._metadataStore.addSpace(metadata);
|
|
3654
3757
|
const memberCredential = credentials[1];
|
|
3655
|
-
(0,
|
|
3758
|
+
(0, import_invariant12.invariant)((0, import_credentials12.getCredentialAssertion)(memberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
|
|
3656
3759
|
F: __dxlog_file13,
|
|
3657
|
-
L:
|
|
3760
|
+
L: 154,
|
|
3658
3761
|
S: this,
|
|
3659
3762
|
A: [
|
|
3660
3763
|
"getCredentialAssertion(memberCredential)['@type'] === 'dxos.halo.credentials.SpaceMember'",
|
|
@@ -3672,22 +3775,22 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
3672
3775
|
opts
|
|
3673
3776
|
}, {
|
|
3674
3777
|
F: __dxlog_file13,
|
|
3675
|
-
L:
|
|
3778
|
+
L: 166,
|
|
3676
3779
|
S: this,
|
|
3677
3780
|
C: (f, a) => f(...a)
|
|
3678
3781
|
});
|
|
3679
|
-
(0,
|
|
3782
|
+
(0, import_invariant12.invariant)(this._isOpen, "Not open.", {
|
|
3680
3783
|
F: __dxlog_file13,
|
|
3681
|
-
L:
|
|
3784
|
+
L: 167,
|
|
3682
3785
|
S: this,
|
|
3683
3786
|
A: [
|
|
3684
3787
|
"this._isOpen",
|
|
3685
3788
|
"'Not open.'"
|
|
3686
3789
|
]
|
|
3687
3790
|
});
|
|
3688
|
-
(0,
|
|
3791
|
+
(0, import_invariant12.invariant)(!this._spaces.has(opts.spaceKey), "Space already exists.", {
|
|
3689
3792
|
F: __dxlog_file13,
|
|
3690
|
-
L:
|
|
3793
|
+
L: 168,
|
|
3691
3794
|
S: this,
|
|
3692
3795
|
A: [
|
|
3693
3796
|
"!this._spaces.has(opts.spaceKey)",
|
|
@@ -3714,7 +3817,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
3714
3817
|
async waitUntilSpaceReady(spaceKey) {
|
|
3715
3818
|
await (0, import_context8.cancelWithContext)(this._ctx, this.updated.waitForCondition(() => {
|
|
3716
3819
|
const space = this._spaces.get(spaceKey);
|
|
3717
|
-
return !!space && space.state ===
|
|
3820
|
+
return !!space && space.state === import_services9.SpaceState.READY;
|
|
3718
3821
|
}));
|
|
3719
3822
|
}
|
|
3720
3823
|
async _constructSpace(metadata) {
|
|
@@ -3722,7 +3825,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
3722
3825
|
metadata
|
|
3723
3826
|
}, {
|
|
3724
3827
|
F: __dxlog_file13,
|
|
3725
|
-
L:
|
|
3828
|
+
L: 201,
|
|
3726
3829
|
S: this,
|
|
3727
3830
|
C: (f, a) => f(...a)
|
|
3728
3831
|
});
|
|
@@ -3749,17 +3852,18 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
3749
3852
|
credentialProvider: createAuthProvider(this._signingContext.credentialSigner),
|
|
3750
3853
|
credentialAuthenticator: (0, import_util6.deferFunction)(() => dataSpace.authVerifier.verifier)
|
|
3751
3854
|
},
|
|
3752
|
-
|
|
3855
|
+
onAuthorizedConnection: (session) => {
|
|
3753
3856
|
session.addExtension("dxos.mesh.teleport.gossip", gossip.createExtension({
|
|
3754
3857
|
remotePeerId: session.remotePeerId
|
|
3755
3858
|
}));
|
|
3756
3859
|
session.addExtension("dxos.mesh.teleport.notarization", dataSpace.notarizationPlugin.createExtension());
|
|
3860
|
+
this._automergeHost.authorizeDevice(space.key, session.remotePeerId);
|
|
3757
3861
|
session.addExtension("dxos.mesh.teleport.automerge", this._automergeHost.createExtension());
|
|
3758
3862
|
},
|
|
3759
3863
|
onAuthFailure: () => {
|
|
3760
3864
|
import_log11.log.warn("auth failure", void 0, {
|
|
3761
3865
|
F: __dxlog_file13,
|
|
3762
|
-
L:
|
|
3866
|
+
L: 238,
|
|
3763
3867
|
S: this,
|
|
3764
3868
|
C: (f, a) => f(...a)
|
|
3765
3869
|
});
|
|
@@ -3770,7 +3874,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
3770
3874
|
dataFeed && space.setDataFeed(dataFeed);
|
|
3771
3875
|
const dataSpace = new DataSpace({
|
|
3772
3876
|
inner: space,
|
|
3773
|
-
initialState: metadata.state ===
|
|
3877
|
+
initialState: metadata.state === import_services9.SpaceState.INACTIVE ? import_services9.SpaceState.INACTIVE : import_services9.SpaceState.CLOSED,
|
|
3774
3878
|
metadataStore: this._metadataStore,
|
|
3775
3879
|
gossip,
|
|
3776
3880
|
presence,
|
|
@@ -3783,7 +3887,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
3783
3887
|
space: space.key
|
|
3784
3888
|
}, {
|
|
3785
3889
|
F: __dxlog_file13,
|
|
3786
|
-
L:
|
|
3890
|
+
L: 256,
|
|
3787
3891
|
S: this,
|
|
3788
3892
|
C: (f, a) => f(...a)
|
|
3789
3893
|
});
|
|
@@ -3795,7 +3899,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
3795
3899
|
open: this._isOpen
|
|
3796
3900
|
}, {
|
|
3797
3901
|
F: __dxlog_file13,
|
|
3798
|
-
L:
|
|
3902
|
+
L: 263,
|
|
3799
3903
|
S: this,
|
|
3800
3904
|
C: (f, a) => f(...a)
|
|
3801
3905
|
});
|
|
@@ -3808,7 +3912,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
3808
3912
|
space: space.key
|
|
3809
3913
|
}, {
|
|
3810
3914
|
F: __dxlog_file13,
|
|
3811
|
-
L:
|
|
3915
|
+
L: 269,
|
|
3812
3916
|
S: this,
|
|
3813
3917
|
C: (f, a) => f(...a)
|
|
3814
3918
|
});
|
|
@@ -3818,7 +3922,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
3818
3922
|
cache: metadata.cache,
|
|
3819
3923
|
automergeHost: this._automergeHost
|
|
3820
3924
|
});
|
|
3821
|
-
if (metadata.state !==
|
|
3925
|
+
if (metadata.state !== import_services9.SpaceState.INACTIVE) {
|
|
3822
3926
|
await dataSpace.open();
|
|
3823
3927
|
}
|
|
3824
3928
|
if (metadata.controlTimeframe) {
|
|
@@ -3856,7 +3960,7 @@ var SpacesServiceImpl = class {
|
|
|
3856
3960
|
}
|
|
3857
3961
|
async createSpace() {
|
|
3858
3962
|
if (!this._identityManager.identity) {
|
|
3859
|
-
throw new Error("This device has no HALO identity available. See https://docs.dxos.org/guide/halo");
|
|
3963
|
+
throw new Error("This device has no HALO identity available. See https://docs.dxos.org/guide/platform/halo");
|
|
3860
3964
|
}
|
|
3861
3965
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
3862
3966
|
const space = await dataSpaceManager.createSpace();
|
|
@@ -3864,17 +3968,17 @@ var SpacesServiceImpl = class {
|
|
|
3864
3968
|
}
|
|
3865
3969
|
async updateSpace({ spaceKey, state }) {
|
|
3866
3970
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
3867
|
-
const space = dataSpaceManager.spaces.get(spaceKey) ?? (0, import_debug6.raise)(new
|
|
3971
|
+
const space = dataSpaceManager.spaces.get(spaceKey) ?? (0, import_debug6.raise)(new import_protocols11.SpaceNotFoundError(spaceKey));
|
|
3868
3972
|
if (state) {
|
|
3869
3973
|
switch (state) {
|
|
3870
|
-
case
|
|
3974
|
+
case import_services10.SpaceState.ACTIVE:
|
|
3871
3975
|
await space.activate();
|
|
3872
3976
|
break;
|
|
3873
|
-
case
|
|
3977
|
+
case import_services10.SpaceState.INACTIVE:
|
|
3874
3978
|
await space.deactivate();
|
|
3875
3979
|
break;
|
|
3876
3980
|
default:
|
|
3877
|
-
throw new
|
|
3981
|
+
throw new import_protocols11.ApiError("Invalid space state");
|
|
3878
3982
|
}
|
|
3879
3983
|
}
|
|
3880
3984
|
}
|
|
@@ -3929,14 +4033,14 @@ var SpacesServiceImpl = class {
|
|
|
3929
4033
|
}
|
|
3930
4034
|
async postMessage({ spaceKey, channel, message }) {
|
|
3931
4035
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
3932
|
-
const space = dataSpaceManager.spaces.get(spaceKey) ?? (0, import_debug6.raise)(new
|
|
4036
|
+
const space = dataSpaceManager.spaces.get(spaceKey) ?? (0, import_debug6.raise)(new import_protocols11.SpaceNotFoundError(spaceKey));
|
|
3933
4037
|
await space.postMessage(getChannelId(channel), message);
|
|
3934
4038
|
}
|
|
3935
4039
|
subscribeMessages({ spaceKey, channel }) {
|
|
3936
4040
|
return new import_codec_protobuf11.Stream(({ ctx, next }) => {
|
|
3937
4041
|
(0, import_async13.scheduleTask)(ctx, async () => {
|
|
3938
4042
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
3939
|
-
const space = dataSpaceManager.spaces.get(spaceKey) ?? (0, import_debug6.raise)(new
|
|
4043
|
+
const space = dataSpaceManager.spaces.get(spaceKey) ?? (0, import_debug6.raise)(new import_protocols11.SpaceNotFoundError(spaceKey));
|
|
3940
4044
|
const handle = space.listen(getChannelId(channel), (message) => {
|
|
3941
4045
|
next(message);
|
|
3942
4046
|
});
|
|
@@ -3946,7 +4050,7 @@ var SpacesServiceImpl = class {
|
|
|
3946
4050
|
}
|
|
3947
4051
|
queryCredentials({ spaceKey, noTail }) {
|
|
3948
4052
|
return new import_codec_protobuf11.Stream(({ ctx, next, close }) => {
|
|
3949
|
-
const space = this._spaceManager.spaces.get(spaceKey) ?? (0, import_debug6.raise)(new
|
|
4053
|
+
const space = this._spaceManager.spaces.get(spaceKey) ?? (0, import_debug6.raise)(new import_protocols11.SpaceNotFoundError(spaceKey));
|
|
3950
4054
|
const processor = {
|
|
3951
4055
|
processCredential: async (credential) => {
|
|
3952
4056
|
next(credential);
|
|
@@ -3962,7 +4066,7 @@ var SpacesServiceImpl = class {
|
|
|
3962
4066
|
});
|
|
3963
4067
|
}
|
|
3964
4068
|
async writeCredentials({ spaceKey, credentials }) {
|
|
3965
|
-
const space = this._spaceManager.spaces.get(spaceKey) ?? (0, import_debug6.raise)(new
|
|
4069
|
+
const space = this._spaceManager.spaces.get(spaceKey) ?? (0, import_debug6.raise)(new import_protocols11.SpaceNotFoundError(spaceKey));
|
|
3966
4070
|
for (const credential of credentials ?? []) {
|
|
3967
4071
|
if (credential.proof) {
|
|
3968
4072
|
await space.controlPipeline.writer.write({
|
|
@@ -3971,7 +4075,7 @@ var SpacesServiceImpl = class {
|
|
|
3971
4075
|
}
|
|
3972
4076
|
});
|
|
3973
4077
|
} else {
|
|
3974
|
-
(0,
|
|
4078
|
+
(0, import_invariant13.invariant)(!credential.id, "Id on unsigned credentials is not allowed", {
|
|
3975
4079
|
F: __dxlog_file14,
|
|
3976
4080
|
L: 168,
|
|
3977
4081
|
S: this,
|
|
@@ -3980,7 +4084,7 @@ var SpacesServiceImpl = class {
|
|
|
3980
4084
|
"'Id on unsigned credentials is not allowed'"
|
|
3981
4085
|
]
|
|
3982
4086
|
});
|
|
3983
|
-
(0,
|
|
4087
|
+
(0, import_invariant13.invariant)(this._identityManager.identity, "Identity is not available", {
|
|
3984
4088
|
F: __dxlog_file14,
|
|
3985
4089
|
L: 169,
|
|
3986
4090
|
S: this,
|
|
@@ -3990,7 +4094,7 @@ var SpacesServiceImpl = class {
|
|
|
3990
4094
|
]
|
|
3991
4095
|
});
|
|
3992
4096
|
const signer = this._identityManager.identity.getIdentityCredentialSigner();
|
|
3993
|
-
(0,
|
|
4097
|
+
(0, import_invariant13.invariant)(credential.issuer.equals(signer.getIssuer()), void 0, {
|
|
3994
4098
|
F: __dxlog_file14,
|
|
3995
4099
|
L: 171,
|
|
3996
4100
|
S: this,
|
|
@@ -4013,14 +4117,14 @@ var SpacesServiceImpl = class {
|
|
|
4013
4117
|
}
|
|
4014
4118
|
async createEpoch({ spaceKey }) {
|
|
4015
4119
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
4016
|
-
const space = dataSpaceManager.spaces.get(spaceKey) ?? (0, import_debug6.raise)(new
|
|
4120
|
+
const space = dataSpaceManager.spaces.get(spaceKey) ?? (0, import_debug6.raise)(new import_protocols11.SpaceNotFoundError(spaceKey));
|
|
4017
4121
|
await space.createEpoch();
|
|
4018
4122
|
}
|
|
4019
4123
|
_serializeSpace(space) {
|
|
4020
4124
|
return {
|
|
4021
4125
|
spaceKey: space.key,
|
|
4022
4126
|
state: space.state,
|
|
4023
|
-
error: space.error ? (0,
|
|
4127
|
+
error: space.error ? (0, import_protocols11.encodeError)(space.error) : void 0,
|
|
4024
4128
|
pipeline: {
|
|
4025
4129
|
currentEpoch: space.dataPipeline.currentEpoch,
|
|
4026
4130
|
appliedEpoch: space.dataPipeline.appliedEpoch,
|
|
@@ -4047,7 +4151,7 @@ var SpacesServiceImpl = class {
|
|
|
4047
4151
|
displayName: member.profile?.displayName
|
|
4048
4152
|
}
|
|
4049
4153
|
},
|
|
4050
|
-
presence: member.removed ?
|
|
4154
|
+
presence: member.removed ? import_services10.SpaceMember.PresenceState.REMOVED : isMe || peers.length > 0 ? import_services10.SpaceMember.PresenceState.ONLINE : import_services10.SpaceMember.PresenceState.OFFLINE,
|
|
4051
4155
|
peerStates: peers
|
|
4052
4156
|
};
|
|
4053
4157
|
}),
|
|
@@ -4069,7 +4173,7 @@ function _ts_decorate6(decorators, target, key, desc) {
|
|
|
4069
4173
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4070
4174
|
}
|
|
4071
4175
|
var __dxlog_file15 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-context.ts";
|
|
4072
|
-
var ServiceContext = class
|
|
4176
|
+
var ServiceContext = class {
|
|
4073
4177
|
constructor(storage, networkManager, signalManager, modelFactory) {
|
|
4074
4178
|
this.storage = storage;
|
|
4075
4179
|
this.networkManager = networkManager;
|
|
@@ -4104,7 +4208,7 @@ var ServiceContext = class ServiceContext2 {
|
|
|
4104
4208
|
this.identityManager = new IdentityManager(this.metadataStore, this.keyring, this.feedStore, this.spaceManager);
|
|
4105
4209
|
this.automergeHost = new import_echo_pipeline2.AutomergeHost(storage.createDirectory("automerge"));
|
|
4106
4210
|
this.invitations = new InvitationsHandler(this.networkManager);
|
|
4107
|
-
this._handlerFactories.set(
|
|
4211
|
+
this._handlerFactories.set(import_services11.Invitation.Kind.DEVICE, () => new DeviceInvitationProtocol(this.keyring, () => this.identityManager.identity ?? (0, import_debug7.failUndefined)(), this._acceptIdentity.bind(this)));
|
|
4108
4212
|
}
|
|
4109
4213
|
async open(ctx) {
|
|
4110
4214
|
await this._checkStorageVersion();
|
|
@@ -4114,7 +4218,7 @@ var ServiceContext = class ServiceContext2 {
|
|
|
4114
4218
|
S: this,
|
|
4115
4219
|
C: (f, a) => f(...a)
|
|
4116
4220
|
});
|
|
4117
|
-
import_log13.log.trace("dxos.sdk.service-context.open",
|
|
4221
|
+
import_log13.log.trace("dxos.sdk.service-context.open", import_protocols12.trace.begin({
|
|
4118
4222
|
id: this._instanceId
|
|
4119
4223
|
}), {
|
|
4120
4224
|
F: __dxlog_file15,
|
|
@@ -4130,7 +4234,7 @@ var ServiceContext = class ServiceContext2 {
|
|
|
4130
4234
|
if (this.identityManager.identity) {
|
|
4131
4235
|
await this._initialize(ctx);
|
|
4132
4236
|
}
|
|
4133
|
-
import_log13.log.trace("dxos.sdk.service-context.open",
|
|
4237
|
+
import_log13.log.trace("dxos.sdk.service-context.open", import_protocols12.trace.end({
|
|
4134
4238
|
id: this._instanceId
|
|
4135
4239
|
}), {
|
|
4136
4240
|
F: __dxlog_file15,
|
|
@@ -4178,7 +4282,7 @@ var ServiceContext = class ServiceContext2 {
|
|
|
4178
4282
|
}
|
|
4179
4283
|
getInvitationHandler(invitation) {
|
|
4180
4284
|
const factory = this._handlerFactories.get(invitation.kind);
|
|
4181
|
-
(0,
|
|
4285
|
+
(0, import_invariant14.invariant)(factory, `Unknown invitation kind: ${invitation.kind}`, {
|
|
4182
4286
|
F: __dxlog_file15,
|
|
4183
4287
|
L: 173,
|
|
4184
4288
|
S: this,
|
|
@@ -4204,8 +4308,8 @@ var ServiceContext = class ServiceContext2 {
|
|
|
4204
4308
|
}
|
|
4205
4309
|
async _checkStorageVersion() {
|
|
4206
4310
|
await this.metadataStore.load();
|
|
4207
|
-
if (this.metadataStore.version !==
|
|
4208
|
-
throw new
|
|
4311
|
+
if (this.metadataStore.version !== import_protocols12.STORAGE_VERSION) {
|
|
4312
|
+
throw new import_protocols12.InvalidStorageVersionError(import_protocols12.STORAGE_VERSION, this.metadataStore.version);
|
|
4209
4313
|
}
|
|
4210
4314
|
}
|
|
4211
4315
|
// Called when identity is created.
|
|
@@ -4232,8 +4336,8 @@ var ServiceContext = class ServiceContext2 {
|
|
|
4232
4336
|
};
|
|
4233
4337
|
this.dataSpaceManager = new DataSpaceManager(this.spaceManager, this.metadataStore, this.dataServiceSubscriptions, this.keyring, signingContext, this.feedStore, this.automergeHost);
|
|
4234
4338
|
await this.dataSpaceManager.open();
|
|
4235
|
-
this._handlerFactories.set(
|
|
4236
|
-
(0,
|
|
4339
|
+
this._handlerFactories.set(import_services11.Invitation.Kind.SPACE, (invitation) => {
|
|
4340
|
+
(0, import_invariant14.invariant)(this.dataSpaceManager, "dataSpaceManager not initialized yet", {
|
|
4237
4341
|
F: __dxlog_file15,
|
|
4238
4342
|
L: 228,
|
|
4239
4343
|
S: this,
|
|
@@ -4303,14 +4407,14 @@ var ServiceContext = class ServiceContext2 {
|
|
|
4303
4407
|
}
|
|
4304
4408
|
};
|
|
4305
4409
|
_ts_decorate6([
|
|
4306
|
-
|
|
4410
|
+
import_tracing6.trace.span()
|
|
4307
4411
|
], ServiceContext.prototype, "open", null);
|
|
4308
4412
|
_ts_decorate6([
|
|
4309
|
-
|
|
4413
|
+
import_tracing6.trace.span()
|
|
4310
4414
|
], ServiceContext.prototype, "_initialize", null);
|
|
4311
4415
|
ServiceContext = _ts_decorate6([
|
|
4312
4416
|
(0, import_util7.safeInstanceof)("dxos.client-services.ServiceContext"),
|
|
4313
|
-
|
|
4417
|
+
import_tracing6.trace.resource()
|
|
4314
4418
|
], ServiceContext);
|
|
4315
4419
|
var ServiceRegistry = class {
|
|
4316
4420
|
// prettier-ignore
|
|
@@ -4372,7 +4476,7 @@ var Lock = class {
|
|
|
4372
4476
|
}
|
|
4373
4477
|
async release() {
|
|
4374
4478
|
await this._onRelease?.();
|
|
4375
|
-
(0,
|
|
4479
|
+
(0, import_invariant15.invariant)(this._fileHandle, "Lock is not acquired", {
|
|
4376
4480
|
F: __dxlog_file16,
|
|
4377
4481
|
L: 42,
|
|
4378
4482
|
S: this,
|
|
@@ -4392,16 +4496,16 @@ var StorageDriver = import_config.Runtime.Client.Storage.StorageDriver;
|
|
|
4392
4496
|
var createStorageObjects = (config) => {
|
|
4393
4497
|
const { persistent = false, keyStore, dataStore, dataRoot = (0, import_util8.isNode)() ? import_client_protocol4.DX_DATA : "dxos/storage" } = config ?? {};
|
|
4394
4498
|
if (persistent && dataStore === StorageDriver.RAM) {
|
|
4395
|
-
throw new
|
|
4499
|
+
throw new import_protocols13.InvalidConfigError("RAM storage cannot be used in persistent mode.");
|
|
4396
4500
|
}
|
|
4397
4501
|
if (!persistent && dataStore !== void 0 && dataStore !== StorageDriver.RAM) {
|
|
4398
|
-
throw new
|
|
4502
|
+
throw new import_protocols13.InvalidConfigError("Cannot use a persistent storage in not persistent mode.");
|
|
4399
4503
|
}
|
|
4400
4504
|
if (persistent && keyStore === StorageDriver.RAM) {
|
|
4401
|
-
throw new
|
|
4505
|
+
throw new import_protocols13.InvalidConfigError("RAM key storage cannot be used in persistent mode.");
|
|
4402
4506
|
}
|
|
4403
4507
|
if (!persistent && keyStore !== StorageDriver.RAM && keyStore !== void 0) {
|
|
4404
|
-
throw new
|
|
4508
|
+
throw new import_protocols13.InvalidConfigError("Cannot use a persistent key storage in not persistent mode.");
|
|
4405
4509
|
}
|
|
4406
4510
|
return {
|
|
4407
4511
|
storage: (0, import_random_access_storage.createStorage)({
|
|
@@ -4449,7 +4553,7 @@ var DevicesServiceImpl = class {
|
|
|
4449
4553
|
next({
|
|
4450
4554
|
devices: Array.from(deviceKeys.entries()).map(([key, profile]) => ({
|
|
4451
4555
|
deviceKey: key,
|
|
4452
|
-
kind: this._identityManager.identity?.deviceKey.equals(key) ?
|
|
4556
|
+
kind: this._identityManager.identity?.deviceKey.equals(key) ? import_services13.DeviceKind.CURRENT : import_services13.DeviceKind.TRUSTED,
|
|
4453
4557
|
profile
|
|
4454
4558
|
}))
|
|
4455
4559
|
});
|
|
@@ -4564,16 +4668,16 @@ var LoggingServiceImpl = class {
|
|
|
4564
4668
|
};
|
|
4565
4669
|
var matchFilter = (filter, level, path, options) => {
|
|
4566
4670
|
switch (options) {
|
|
4567
|
-
case
|
|
4671
|
+
case import_services14.QueryLogsRequest.MatchingOptions.INCLUSIVE:
|
|
4568
4672
|
return level >= filter.level && (!filter.pattern || path.includes(filter.pattern));
|
|
4569
|
-
case
|
|
4673
|
+
case import_services14.QueryLogsRequest.MatchingOptions.EXPLICIT:
|
|
4570
4674
|
return level === filter.level && (!filter.pattern || path.includes(filter.pattern));
|
|
4571
4675
|
}
|
|
4572
4676
|
};
|
|
4573
4677
|
var shouldLog = (entry2, request) => {
|
|
4574
|
-
const options = request.options ??
|
|
4678
|
+
const options = request.options ?? import_services14.QueryLogsRequest.MatchingOptions.INCLUSIVE;
|
|
4575
4679
|
if (request.filters === void 0) {
|
|
4576
|
-
return options ===
|
|
4680
|
+
return options === import_services14.QueryLogsRequest.MatchingOptions.INCLUSIVE;
|
|
4577
4681
|
} else {
|
|
4578
4682
|
return request.filters.some((filter) => matchFilter(filter, entry2.level, entry2.meta?.F ?? "", options));
|
|
4579
4683
|
}
|
|
@@ -4589,6 +4693,7 @@ var NetworkServiceImpl = class {
|
|
|
4589
4693
|
const update = () => {
|
|
4590
4694
|
next({
|
|
4591
4695
|
swarm: this.networkManager.connectionState,
|
|
4696
|
+
connectionInfo: this.networkManager.connectionLog?.swarms,
|
|
4592
4697
|
signaling: this.signalManager.getStatus().map(({ host, state }) => ({
|
|
4593
4698
|
server: host,
|
|
4594
4699
|
state
|
|
@@ -4628,11 +4733,14 @@ var SystemServiceImpl = class {
|
|
|
4628
4733
|
return {
|
|
4629
4734
|
timestamp: /* @__PURE__ */ new Date(),
|
|
4630
4735
|
diagnostics: JSON.parse(JSON.stringify(diagnostics, (0, import_util10.jsonKeyReplacer)({
|
|
4631
|
-
truncate: keys ===
|
|
4632
|
-
humanize: keys ===
|
|
4736
|
+
truncate: keys === import_services15.GetDiagnosticsRequest.KEY_OPTION.TRUNCATE,
|
|
4737
|
+
humanize: keys === import_services15.GetDiagnosticsRequest.KEY_OPTION.HUMANIZE
|
|
4633
4738
|
})))
|
|
4634
4739
|
};
|
|
4635
4740
|
}
|
|
4741
|
+
async getPlatform() {
|
|
4742
|
+
return getPlatform();
|
|
4743
|
+
}
|
|
4636
4744
|
async updateStatus({ status }) {
|
|
4637
4745
|
await this._onUpdateStatus(status);
|
|
4638
4746
|
}
|
|
@@ -4683,7 +4791,7 @@ var createGenesisMutationFromTypedObject = (obj) => {
|
|
|
4683
4791
|
}
|
|
4684
4792
|
};
|
|
4685
4793
|
};
|
|
4686
|
-
var ClientServicesHost = class
|
|
4794
|
+
var ClientServicesHost = class {
|
|
4687
4795
|
constructor({
|
|
4688
4796
|
config,
|
|
4689
4797
|
modelFactory = createDefaultModelFactory(),
|
|
@@ -4694,7 +4802,7 @@ var ClientServicesHost = class ClientServicesHost2 {
|
|
|
4694
4802
|
lockKey,
|
|
4695
4803
|
callbacks
|
|
4696
4804
|
} = {}) {
|
|
4697
|
-
this._tracingService =
|
|
4805
|
+
this._tracingService = import_tracing7.TRACE_PROCESSOR.createTraceSender();
|
|
4698
4806
|
this._statusUpdate = new import_async15.Event();
|
|
4699
4807
|
this._opening = false;
|
|
4700
4808
|
this._open = false;
|
|
@@ -4722,14 +4830,14 @@ var ClientServicesHost = class ClientServicesHost2 {
|
|
|
4722
4830
|
this._systemService = new SystemServiceImpl({
|
|
4723
4831
|
config: this._config,
|
|
4724
4832
|
statusUpdate: this._statusUpdate,
|
|
4725
|
-
getCurrentStatus: () => this.isOpen ?
|
|
4833
|
+
getCurrentStatus: () => this.isOpen ? import_services12.SystemStatus.ACTIVE : import_services12.SystemStatus.INACTIVE,
|
|
4726
4834
|
getDiagnostics: () => {
|
|
4727
4835
|
return createDiagnostics(this._serviceRegistry.services, this._serviceContext, this._config);
|
|
4728
4836
|
},
|
|
4729
4837
|
onUpdateStatus: async (status) => {
|
|
4730
|
-
if (!this.isOpen && status ===
|
|
4838
|
+
if (!this.isOpen && status === import_services12.SystemStatus.ACTIVE) {
|
|
4731
4839
|
await this._resourceLock?.acquire();
|
|
4732
|
-
} else if (this.isOpen && status ===
|
|
4840
|
+
} else if (this.isOpen && status === import_services12.SystemStatus.INACTIVE) {
|
|
4733
4841
|
await this._resourceLock?.release();
|
|
4734
4842
|
}
|
|
4735
4843
|
},
|
|
@@ -4767,7 +4875,7 @@ var ClientServicesHost = class ClientServicesHost2 {
|
|
|
4767
4875
|
* Can only be called once.
|
|
4768
4876
|
*/
|
|
4769
4877
|
initialize({ config, ...options }) {
|
|
4770
|
-
(0,
|
|
4878
|
+
(0, import_invariant16.invariant)(!this._open, "service host is open", {
|
|
4771
4879
|
F: __dxlog_file17,
|
|
4772
4880
|
L: 201,
|
|
4773
4881
|
S: this,
|
|
@@ -4783,7 +4891,7 @@ var ClientServicesHost = class ClientServicesHost2 {
|
|
|
4783
4891
|
C: (f, a) => f(...a)
|
|
4784
4892
|
});
|
|
4785
4893
|
if (config) {
|
|
4786
|
-
(0,
|
|
4894
|
+
(0, import_invariant16.invariant)(!this._config, "config already set", {
|
|
4787
4895
|
F: __dxlog_file17,
|
|
4788
4896
|
L: 205,
|
|
4789
4897
|
S: this,
|
|
@@ -4801,7 +4909,7 @@ var ClientServicesHost = class ClientServicesHost2 {
|
|
|
4801
4909
|
iceServers: this._config?.get("runtime.services.ice")
|
|
4802
4910
|
}), signalManager = new import_messaging.WebsocketSignalManager(this._config?.get("runtime.services.signaling") ?? []) } = options;
|
|
4803
4911
|
this._signalManager = signalManager;
|
|
4804
|
-
(0,
|
|
4912
|
+
(0, import_invariant16.invariant)(!this._networkManager, "network manager already set", {
|
|
4805
4913
|
F: __dxlog_file17,
|
|
4806
4914
|
L: 221,
|
|
4807
4915
|
S: this,
|
|
@@ -4827,7 +4935,7 @@ var ClientServicesHost = class ClientServicesHost2 {
|
|
|
4827
4935
|
return;
|
|
4828
4936
|
}
|
|
4829
4937
|
const traceId = import_keys11.PublicKey.random().toHex();
|
|
4830
|
-
import_log15.log.trace("dxos.client-services.host.open",
|
|
4938
|
+
import_log15.log.trace("dxos.client-services.host.open", import_protocols14.trace.begin({
|
|
4831
4939
|
id: traceId
|
|
4832
4940
|
}), {
|
|
4833
4941
|
F: __dxlog_file17,
|
|
@@ -4835,7 +4943,7 @@ var ClientServicesHost = class ClientServicesHost2 {
|
|
|
4835
4943
|
S: this,
|
|
4836
4944
|
C: (f, a) => f(...a)
|
|
4837
4945
|
});
|
|
4838
|
-
(0,
|
|
4946
|
+
(0, import_invariant16.invariant)(this._config, "config not set", {
|
|
4839
4947
|
F: __dxlog_file17,
|
|
4840
4948
|
L: 241,
|
|
4841
4949
|
S: this,
|
|
@@ -4844,7 +4952,7 @@ var ClientServicesHost = class ClientServicesHost2 {
|
|
|
4844
4952
|
"'config not set'"
|
|
4845
4953
|
]
|
|
4846
4954
|
});
|
|
4847
|
-
(0,
|
|
4955
|
+
(0, import_invariant16.invariant)(this._storage, "storage not set", {
|
|
4848
4956
|
F: __dxlog_file17,
|
|
4849
4957
|
L: 242,
|
|
4850
4958
|
S: this,
|
|
@@ -4853,7 +4961,7 @@ var ClientServicesHost = class ClientServicesHost2 {
|
|
|
4853
4961
|
"'storage not set'"
|
|
4854
4962
|
]
|
|
4855
4963
|
});
|
|
4856
|
-
(0,
|
|
4964
|
+
(0, import_invariant16.invariant)(this._signalManager, "signal manager not set", {
|
|
4857
4965
|
F: __dxlog_file17,
|
|
4858
4966
|
L: 243,
|
|
4859
4967
|
S: this,
|
|
@@ -4862,7 +4970,7 @@ var ClientServicesHost = class ClientServicesHost2 {
|
|
|
4862
4970
|
"'signal manager not set'"
|
|
4863
4971
|
]
|
|
4864
4972
|
});
|
|
4865
|
-
(0,
|
|
4973
|
+
(0, import_invariant16.invariant)(this._networkManager, "network manager not set", {
|
|
4866
4974
|
F: __dxlog_file17,
|
|
4867
4975
|
L: 244,
|
|
4868
4976
|
S: this,
|
|
@@ -4885,7 +4993,7 @@ var ClientServicesHost = class ClientServicesHost2 {
|
|
|
4885
4993
|
this._serviceContext = new ServiceContext(this._storage, this._networkManager, this._signalManager, this._modelFactory);
|
|
4886
4994
|
this._serviceRegistry.setServices({
|
|
4887
4995
|
SystemService: this._systemService,
|
|
4888
|
-
IdentityService: new IdentityServiceImpl((params) => this._createIdentity(params), this._serviceContext.identityManager, this._serviceContext.keyring, (profile) => this._serviceContext.broadcastProfileUpdate(profile)),
|
|
4996
|
+
IdentityService: new IdentityServiceImpl((params, useAutomerge) => this._createIdentity(params, useAutomerge), this._serviceContext.identityManager, this._serviceContext.keyring, (profile) => this._serviceContext.broadcastProfileUpdate(profile)),
|
|
4889
4997
|
InvitationsService: new InvitationsServiceImpl(this._serviceContext.invitations, (invitation) => this._serviceContext.getInvitationHandler(invitation)),
|
|
4890
4998
|
DevicesService: new DevicesServiceImpl(this._serviceContext.identityManager),
|
|
4891
4999
|
SpacesService: new SpacesServiceImpl(this._serviceContext.identityManager, this._serviceContext.spaceManager, this._serviceContext.dataServiceSubscriptions, async () => {
|
|
@@ -4926,7 +5034,7 @@ var ClientServicesHost = class ClientServicesHost2 {
|
|
|
4926
5034
|
S: this,
|
|
4927
5035
|
C: (f, a) => f(...a)
|
|
4928
5036
|
});
|
|
4929
|
-
import_log15.log.trace("dxos.client-services.host.open",
|
|
5037
|
+
import_log15.log.trace("dxos.client-services.host.open", import_protocols14.trace.end({
|
|
4930
5038
|
id: traceId
|
|
4931
5039
|
}), {
|
|
4932
5040
|
F: __dxlog_file17,
|
|
@@ -4967,7 +5075,7 @@ var ClientServicesHost = class ClientServicesHost2 {
|
|
|
4967
5075
|
}
|
|
4968
5076
|
async reset() {
|
|
4969
5077
|
const traceId = import_keys11.PublicKey.random().toHex();
|
|
4970
|
-
import_log15.log.trace("dxos.sdk.client-services-host.reset",
|
|
5078
|
+
import_log15.log.trace("dxos.sdk.client-services-host.reset", import_protocols14.trace.begin({
|
|
4971
5079
|
id: traceId
|
|
4972
5080
|
}), {
|
|
4973
5081
|
F: __dxlog_file17,
|
|
@@ -4989,7 +5097,7 @@ var ClientServicesHost = class ClientServicesHost2 {
|
|
|
4989
5097
|
S: this,
|
|
4990
5098
|
C: (f, a) => f(...a)
|
|
4991
5099
|
});
|
|
4992
|
-
import_log15.log.trace("dxos.sdk.client-services-host.reset",
|
|
5100
|
+
import_log15.log.trace("dxos.sdk.client-services-host.reset", import_protocols14.trace.end({
|
|
4993
5101
|
id: traceId
|
|
4994
5102
|
}), {
|
|
4995
5103
|
F: __dxlog_file17,
|
|
@@ -4999,44 +5107,63 @@ var ClientServicesHost = class ClientServicesHost2 {
|
|
|
4999
5107
|
});
|
|
5000
5108
|
await this._callbacks?.onReset?.();
|
|
5001
5109
|
}
|
|
5002
|
-
async _createIdentity(params) {
|
|
5110
|
+
async _createIdentity(params, useAutomerge) {
|
|
5003
5111
|
const identity = await this._serviceContext.createIdentity(params);
|
|
5004
5112
|
await this._serviceContext.initialized.wait();
|
|
5005
5113
|
const space = await this._serviceContext.dataSpaceManager.createSpace();
|
|
5006
5114
|
const obj = new import_client_protocol5.Properties(void 0, {
|
|
5007
|
-
automerge:
|
|
5115
|
+
automerge: useAutomerge
|
|
5008
5116
|
});
|
|
5009
5117
|
obj[import_client_protocol5.defaultKey] = identity.identityKey.toHex();
|
|
5010
|
-
|
|
5011
|
-
|
|
5012
|
-
|
|
5013
|
-
|
|
5014
|
-
|
|
5118
|
+
if (!useAutomerge) {
|
|
5119
|
+
await this._serviceRegistry.services.DataService.write({
|
|
5120
|
+
spaceKey: space.key,
|
|
5121
|
+
batch: {
|
|
5122
|
+
objects: [
|
|
5123
|
+
createGenesisMutationFromTypedObject(obj)
|
|
5124
|
+
]
|
|
5125
|
+
}
|
|
5126
|
+
});
|
|
5127
|
+
await this._serviceRegistry.services.DataService.flush({
|
|
5128
|
+
spaceKey: space.key
|
|
5129
|
+
});
|
|
5130
|
+
} else {
|
|
5131
|
+
const automergeIndex = space.automergeSpaceState.rootUrl;
|
|
5132
|
+
(0, import_invariant16.invariant)(automergeIndex, void 0, {
|
|
5133
|
+
F: __dxlog_file17,
|
|
5134
|
+
L: 375,
|
|
5135
|
+
S: this,
|
|
5136
|
+
A: [
|
|
5137
|
+
"automergeIndex",
|
|
5138
|
+
""
|
|
5015
5139
|
]
|
|
5016
|
-
}
|
|
5017
|
-
|
|
5018
|
-
|
|
5019
|
-
|
|
5020
|
-
|
|
5140
|
+
});
|
|
5141
|
+
const document = await this._serviceContext.automergeHost.repo.find(automergeIndex);
|
|
5142
|
+
await document.whenReady();
|
|
5143
|
+
document.change((doc) => {
|
|
5144
|
+
doc.objects ??= {};
|
|
5145
|
+
doc.objects[obj[import_echo_schema.base]._id] = (0, import_echo_schema.getRawDoc)(obj).handle.docSync();
|
|
5146
|
+
});
|
|
5147
|
+
}
|
|
5021
5148
|
return identity;
|
|
5022
5149
|
}
|
|
5023
5150
|
};
|
|
5024
5151
|
_ts_decorate8([
|
|
5025
|
-
|
|
5152
|
+
import_tracing7.trace.info()
|
|
5026
5153
|
], ClientServicesHost.prototype, "_opening", void 0);
|
|
5027
5154
|
_ts_decorate8([
|
|
5028
|
-
|
|
5155
|
+
import_tracing7.trace.info()
|
|
5029
5156
|
], ClientServicesHost.prototype, "_open", void 0);
|
|
5030
5157
|
_ts_decorate8([
|
|
5031
5158
|
import_async15.synchronized,
|
|
5032
|
-
|
|
5159
|
+
import_tracing7.trace.span()
|
|
5033
5160
|
], ClientServicesHost.prototype, "open", null);
|
|
5034
5161
|
_ts_decorate8([
|
|
5035
5162
|
import_async15.synchronized,
|
|
5036
|
-
|
|
5163
|
+
import_tracing7.trace.span()
|
|
5037
5164
|
], ClientServicesHost.prototype, "close", null);
|
|
5038
5165
|
ClientServicesHost = _ts_decorate8([
|
|
5039
|
-
|
|
5166
|
+
import_tracing7.trace.resource()
|
|
5040
5167
|
], ClientServicesHost);
|
|
5041
5168
|
// Annotate the CommonJS export names for ESM import in node:
|
|
5042
5169
|
0 && (module.exports = {
|
|
@@ -5072,4 +5199,4 @@ ClientServicesHost = _ts_decorate8([
|
|
|
5072
5199
|
subscribeToSpaces,
|
|
5073
5200
|
subscribeToSwarmInfo
|
|
5074
5201
|
});
|
|
5075
|
-
//# sourceMappingURL=chunk-
|
|
5202
|
+
//# sourceMappingURL=chunk-JUJNN3NE.cjs.map
|