@dxos/client-services 0.4.10-main.35cfb0c → 0.4.10-main.36e0428
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-RKIUEUQW.mjs → chunk-T4NJPSMU.mjs} +1413 -1144
- package/dist/lib/browser/chunk-T4NJPSMU.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +18 -6
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/packlets/testing/index.mjs +138 -118
- package/dist/lib/browser/packlets/testing/index.mjs.map +3 -3
- package/dist/lib/node/{chunk-JQCOIA5N.cjs → chunk-2L6Y2DJQ.cjs} +1306 -1116
- package/dist/lib/node/chunk-2L6Y2DJQ.cjs.map +7 -0
- package/dist/lib/node/index.cjs +54 -42
- package/dist/lib/node/index.cjs.map +3 -3
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/packlets/testing/index.cjs +137 -120
- package/dist/lib/node/packlets/testing/index.cjs.map +3 -3
- package/dist/types/src/index.d.ts +1 -0
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/packlets/diagnostics/browser-diagnostics-broadcast.d.ts +5 -0
- package/dist/types/src/packlets/diagnostics/browser-diagnostics-broadcast.d.ts.map +1 -0
- package/dist/types/src/packlets/diagnostics/diagnostics-broadcast.d.ts +5 -0
- package/dist/types/src/packlets/diagnostics/diagnostics-broadcast.d.ts.map +1 -0
- package/dist/types/src/packlets/diagnostics/diagnostics-collector.d.ts +15 -0
- package/dist/types/src/packlets/diagnostics/diagnostics-collector.d.ts.map +1 -0
- package/dist/types/src/packlets/{services → diagnostics}/diagnostics.d.ts +1 -1
- package/dist/types/src/packlets/diagnostics/diagnostics.d.ts.map +1 -0
- package/dist/types/src/packlets/diagnostics/index.d.ts +4 -0
- package/dist/types/src/packlets/diagnostics/index.d.ts.map +1 -0
- package/dist/types/src/packlets/identity/identity-manager.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/device-invitation-protocol.d.ts +3 -1
- package/dist/types/src/packlets/invitations/device-invitation-protocol.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/index.d.ts +1 -0
- package/dist/types/src/packlets/invitations/index.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/invitation-extension.d.ts +1 -0
- package/dist/types/src/packlets/invitations/invitation-extension.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/invitation-protocol.d.ts +6 -1
- package/dist/types/src/packlets/invitations/invitation-protocol.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/invitations-handler.d.ts +8 -4
- package/dist/types/src/packlets/invitations/invitations-handler.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/invitations-manager.d.ts +44 -0
- package/dist/types/src/packlets/invitations/invitations-manager.d.ts.map +1 -0
- package/dist/types/src/packlets/invitations/invitations-service.d.ts +7 -23
- package/dist/types/src/packlets/invitations/invitations-service.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/space-invitation-protocol.d.ts +2 -1
- package/dist/types/src/packlets/invitations/space-invitation-protocol.d.ts.map +1 -1
- package/dist/types/src/packlets/services/index.d.ts +1 -1
- package/dist/types/src/packlets/services/index.d.ts.map +1 -1
- package/dist/types/src/packlets/services/service-context.d.ts +6 -6
- package/dist/types/src/packlets/services/service-context.d.ts.map +1 -1
- package/dist/types/src/packlets/services/service-host.d.ts +4 -1
- package/dist/types/src/packlets/services/service-host.d.ts.map +1 -1
- package/dist/types/src/packlets/services/util.d.ts +1 -0
- package/dist/types/src/packlets/services/util.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/data-space-manager.d.ts +8 -3
- package/dist/types/src/packlets/spaces/data-space-manager.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/data-space.d.ts +4 -3
- package/dist/types/src/packlets/spaces/data-space.d.ts.map +1 -1
- package/dist/types/src/packlets/storage/level.d.ts.map +1 -1
- package/dist/types/src/packlets/system/system-service.d.ts +1 -1
- 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/packlets/testing/test-builder.d.ts +9 -3
- package/dist/types/src/packlets/testing/test-builder.d.ts.map +1 -1
- package/dist/types/src/packlets/vault/worker-runtime.d.ts.map +1 -1
- package/dist/types/src/version.d.ts +1 -1
- package/package.json +35 -34
- package/src/index.ts +1 -0
- package/src/packlets/diagnostics/browser-diagnostics-broadcast.ts +94 -0
- package/src/packlets/diagnostics/diagnostics-broadcast.ts +20 -0
- package/src/packlets/diagnostics/diagnostics-collector.ts +65 -0
- package/src/packlets/{services → diagnostics}/diagnostics.ts +2 -2
- package/src/packlets/diagnostics/index.ts +7 -0
- package/src/packlets/identity/identity-manager.ts +1 -0
- package/src/packlets/identity/identity.test.ts +3 -0
- package/src/packlets/invitations/device-invitation-protocol.ts +6 -1
- package/src/packlets/invitations/index.ts +1 -0
- package/src/packlets/invitations/invitation-extension.ts +28 -1
- package/src/packlets/invitations/invitation-protocol.ts +7 -1
- package/src/packlets/invitations/invitations-handler.ts +75 -96
- package/src/packlets/invitations/invitations-manager.ts +271 -0
- package/src/packlets/invitations/invitations-service.ts +23 -168
- package/src/packlets/invitations/space-invitation-protocol.ts +45 -3
- package/src/packlets/services/automerge-host.test.ts +13 -7
- package/src/packlets/services/index.ts +1 -1
- package/src/packlets/services/service-context.test.ts +4 -1
- package/src/packlets/services/service-context.ts +23 -23
- package/src/packlets/services/service-host.test.ts +6 -0
- package/src/packlets/services/service-host.ts +22 -23
- package/src/packlets/services/util.ts +2 -0
- package/src/packlets/spaces/data-space-manager.test.ts +4 -4
- package/src/packlets/spaces/data-space-manager.ts +56 -13
- package/src/packlets/spaces/data-space.ts +14 -19
- package/src/packlets/storage/level.ts +2 -1
- package/src/packlets/system/system-service.ts +1 -1
- package/src/packlets/testing/invitation-utils.ts +100 -97
- package/src/packlets/testing/test-builder.ts +37 -8
- package/src/packlets/vault/worker-runtime.ts +3 -1
- package/src/version.ts +1 -1
- package/dist/lib/browser/chunk-RKIUEUQW.mjs.map +0 -7
- package/dist/lib/node/chunk-JQCOIA5N.cjs.map +0 -7
- package/dist/types/src/packlets/indexing/index.d.ts +0 -2
- package/dist/types/src/packlets/indexing/index.d.ts.map +0 -1
- package/dist/types/src/packlets/indexing/util.d.ts +0 -15
- package/dist/types/src/packlets/indexing/util.d.ts.map +0 -1
- package/dist/types/src/packlets/services/diagnostics.d.ts.map +0 -1
- package/src/packlets/indexing/index.ts +0 -5
- package/src/packlets/indexing/util.ts +0 -89
|
@@ -26,19 +26,22 @@ 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_2L6Y2DJQ_exports = {};
|
|
30
|
+
__export(chunk_2L6Y2DJQ_exports, {
|
|
31
31
|
ClientRpcServer: () => ClientRpcServer,
|
|
32
32
|
ClientServicesHost: () => ClientServicesHost,
|
|
33
|
+
ClientServicesProviderResource: () => ClientServicesProviderResource,
|
|
33
34
|
DataSpace: () => DataSpace,
|
|
34
35
|
DataSpaceManager: () => DataSpaceManager,
|
|
35
36
|
DeviceInvitationProtocol: () => DeviceInvitationProtocol,
|
|
36
37
|
DevtoolsHostEvents: () => DevtoolsHostEvents,
|
|
37
38
|
DevtoolsServiceImpl: () => DevtoolsServiceImpl,
|
|
39
|
+
DiagnosticsCollector: () => DiagnosticsCollector,
|
|
38
40
|
Identity: () => Identity,
|
|
39
41
|
IdentityManager: () => IdentityManager,
|
|
40
42
|
IdentityServiceImpl: () => IdentityServiceImpl,
|
|
41
43
|
InvitationsHandler: () => InvitationsHandler,
|
|
44
|
+
InvitationsManager: () => InvitationsManager,
|
|
42
45
|
InvitationsServiceImpl: () => InvitationsServiceImpl,
|
|
43
46
|
Lock: () => Lock,
|
|
44
47
|
ServiceContext: () => ServiceContext,
|
|
@@ -46,12 +49,14 @@ __export(chunk_JQCOIA5N_exports, {
|
|
|
46
49
|
SpaceInvitationProtocol: () => SpaceInvitationProtocol,
|
|
47
50
|
SpacesServiceImpl: () => SpacesServiceImpl,
|
|
48
51
|
TrustedKeySetAuthVerifier: () => TrustedKeySetAuthVerifier,
|
|
52
|
+
createAdmissionKeypair: () => createAdmissionKeypair,
|
|
49
53
|
createAuthProvider: () => createAuthProvider,
|
|
54
|
+
createCollectDiagnosticsBroadcastHandler: () => createCollectDiagnosticsBroadcastHandler,
|
|
55
|
+
createCollectDiagnosticsBroadcastSender: () => createCollectDiagnosticsBroadcastSender,
|
|
50
56
|
createDiagnostics: () => createDiagnostics,
|
|
51
57
|
createLevel: () => createLevel,
|
|
52
58
|
createStorageObjects: () => createStorageObjects,
|
|
53
59
|
getNetworkPeers: () => getNetworkPeers,
|
|
54
|
-
invitationExpired: () => invitationExpired,
|
|
55
60
|
isLocked: () => isLocked,
|
|
56
61
|
subscribeToFeedBlocks: () => subscribeToFeedBlocks,
|
|
57
62
|
subscribeToFeeds: () => subscribeToFeeds,
|
|
@@ -61,7 +66,7 @@ __export(chunk_JQCOIA5N_exports, {
|
|
|
61
66
|
subscribeToSpaces: () => subscribeToSpaces,
|
|
62
67
|
subscribeToSwarmInfo: () => subscribeToSwarmInfo
|
|
63
68
|
});
|
|
64
|
-
module.exports = __toCommonJS(
|
|
69
|
+
module.exports = __toCommonJS(chunk_2L6Y2DJQ_exports);
|
|
65
70
|
var import_async = require("@dxos/async");
|
|
66
71
|
var import_codec_protobuf = require("@dxos/codec-protobuf");
|
|
67
72
|
var import_feed_store = require("@dxos/feed-store");
|
|
@@ -115,7 +120,7 @@ var import_services2 = require("@dxos/protocols/proto/dxos/client/services");
|
|
|
115
120
|
var import_async7 = require("@dxos/async");
|
|
116
121
|
var import_client_protocol2 = require("@dxos/client-protocol");
|
|
117
122
|
var import_context4 = require("@dxos/context");
|
|
118
|
-
var
|
|
123
|
+
var import_crypto = require("@dxos/crypto");
|
|
119
124
|
var import_invariant5 = require("@dxos/invariant");
|
|
120
125
|
var import_keys5 = require("@dxos/keys");
|
|
121
126
|
var import_log4 = require("@dxos/log");
|
|
@@ -125,6 +130,7 @@ var import_services3 = require("@dxos/protocols/proto/dxos/client/services");
|
|
|
125
130
|
var import_invitations = require("@dxos/protocols/proto/dxos/halo/invitations");
|
|
126
131
|
var import_async8 = require("@dxos/async");
|
|
127
132
|
var import_context5 = require("@dxos/context");
|
|
133
|
+
var import_crypto2 = require("@dxos/crypto");
|
|
128
134
|
var import_invariant6 = require("@dxos/invariant");
|
|
129
135
|
var import_keys6 = require("@dxos/keys");
|
|
130
136
|
var import_log5 = require("@dxos/log");
|
|
@@ -132,63 +138,62 @@ var import_protocols5 = require("@dxos/protocols");
|
|
|
132
138
|
var import_services4 = require("@dxos/protocols/proto/dxos/client/services");
|
|
133
139
|
var import_invitations2 = require("@dxos/protocols/proto/dxos/halo/invitations");
|
|
134
140
|
var import_teleport = require("@dxos/teleport");
|
|
135
|
-
var import_async9 = require("@dxos/async");
|
|
136
141
|
var import_codec_protobuf8 = require("@dxos/codec-protobuf");
|
|
137
|
-
var import_context6 = require("@dxos/context");
|
|
138
|
-
var import_invariant7 = require("@dxos/invariant");
|
|
139
|
-
var import_log6 = require("@dxos/log");
|
|
140
142
|
var import_services5 = require("@dxos/protocols/proto/dxos/client/services");
|
|
141
|
-
var
|
|
143
|
+
var import_credentials7 = require("@dxos/credentials");
|
|
142
144
|
var import_feed_store3 = require("@dxos/feed-store");
|
|
143
|
-
var
|
|
144
|
-
var
|
|
145
|
+
var import_invariant7 = require("@dxos/invariant");
|
|
146
|
+
var import_log6 = require("@dxos/log");
|
|
145
147
|
var import_protocols6 = require("@dxos/protocols");
|
|
146
148
|
var import_services6 = require("@dxos/protocols/proto/dxos/client/services");
|
|
149
|
+
var import_credentials8 = require("@dxos/protocols/proto/dxos/halo/credentials");
|
|
150
|
+
var import_async9 = require("@dxos/async");
|
|
151
|
+
var import_client_protocol3 = require("@dxos/client-protocol");
|
|
152
|
+
var import_context6 = require("@dxos/context");
|
|
153
|
+
var import_credentials9 = require("@dxos/credentials");
|
|
154
|
+
var import_echo_pipeline = require("@dxos/echo-pipeline");
|
|
155
|
+
var import_invariant8 = require("@dxos/invariant");
|
|
156
|
+
var import_keys7 = require("@dxos/keys");
|
|
157
|
+
var import_log7 = require("@dxos/log");
|
|
158
|
+
var import_services7 = require("@dxos/protocols/proto/dxos/client/services");
|
|
147
159
|
var import_codec_protobuf9 = require("@dxos/codec-protobuf");
|
|
148
160
|
var import_debug2 = require("@dxos/debug");
|
|
149
161
|
var import_rpc = require("@dxos/rpc");
|
|
150
162
|
var import_tracing3 = require("@dxos/tracing");
|
|
151
|
-
var import_codec_protobuf10 = require("@dxos/codec-protobuf");
|
|
152
|
-
var import_credentials9 = require("@dxos/credentials");
|
|
153
|
-
var import_invariant9 = require("@dxos/invariant");
|
|
154
|
-
var import_protocols7 = require("@dxos/protocols");
|
|
155
|
-
var import_services7 = require("@dxos/protocols/proto/dxos/client/services");
|
|
156
|
-
var import_tracing4 = require("@dxos/tracing");
|
|
157
|
-
var import_services8 = require("@dxos/protocols/proto/dxos/client/services");
|
|
158
163
|
var import_async10 = require("@dxos/async");
|
|
159
|
-
var
|
|
164
|
+
var import_client_protocol4 = require("@dxos/client-protocol");
|
|
160
165
|
var import_context7 = require("@dxos/context");
|
|
161
166
|
var import_debug3 = require("@dxos/debug");
|
|
162
|
-
var import_echo_db = require("@dxos/echo-db");
|
|
163
|
-
var import_echo_pipeline = require("@dxos/echo-pipeline");
|
|
164
167
|
var import_echo_pipeline2 = require("@dxos/echo-pipeline");
|
|
165
|
-
var
|
|
166
|
-
var
|
|
168
|
+
var import_echo_pipeline3 = require("@dxos/echo-pipeline");
|
|
169
|
+
var import_echo_schema = require("@dxos/echo-schema");
|
|
170
|
+
var import_invariant9 = require("@dxos/invariant");
|
|
171
|
+
var import_keys8 = require("@dxos/keys");
|
|
167
172
|
var import_log8 = require("@dxos/log");
|
|
168
|
-
var
|
|
169
|
-
var
|
|
173
|
+
var import_protocols7 = require("@dxos/protocols");
|
|
174
|
+
var import_services8 = require("@dxos/protocols/proto/dxos/client/services");
|
|
170
175
|
var import_credentials10 = require("@dxos/protocols/proto/dxos/halo/credentials");
|
|
171
176
|
var import_timeframe2 = require("@dxos/timeframe");
|
|
172
|
-
var
|
|
177
|
+
var import_tracing4 = require("@dxos/tracing");
|
|
173
178
|
var import_util4 = require("@dxos/util");
|
|
174
179
|
var import_async11 = require("@dxos/async");
|
|
175
180
|
var import_credentials11 = require("@dxos/credentials");
|
|
176
181
|
var import_async12 = require("@dxos/async");
|
|
177
182
|
var import_context8 = require("@dxos/context");
|
|
178
|
-
var
|
|
179
|
-
var
|
|
183
|
+
var import_invariant10 = require("@dxos/invariant");
|
|
184
|
+
var import_keys9 = require("@dxos/keys");
|
|
180
185
|
var import_log9 = require("@dxos/log");
|
|
181
|
-
var
|
|
186
|
+
var import_protocols8 = require("@dxos/protocols");
|
|
182
187
|
var import_teleport2 = require("@dxos/teleport");
|
|
183
188
|
var import_util5 = require("@dxos/util");
|
|
184
189
|
var import_async13 = require("@dxos/async");
|
|
185
190
|
var import_context9 = require("@dxos/context");
|
|
186
191
|
var import_credentials12 = require("@dxos/credentials");
|
|
187
|
-
var
|
|
188
|
-
var
|
|
192
|
+
var import_invariant11 = require("@dxos/invariant");
|
|
193
|
+
var import_keys10 = require("@dxos/keys");
|
|
189
194
|
var import_log10 = require("@dxos/log");
|
|
190
|
-
var
|
|
191
|
-
var
|
|
195
|
+
var import_protocols9 = require("@dxos/protocols");
|
|
196
|
+
var import_services9 = require("@dxos/protocols/proto/dxos/client/services");
|
|
192
197
|
var import_teleport_extension_gossip2 = require("@dxos/teleport-extension-gossip");
|
|
193
198
|
var import_util6 = require("@dxos/util");
|
|
194
199
|
var import_credentials13 = require("@dxos/credentials");
|
|
@@ -196,73 +201,82 @@ var import_debug4 = require("@dxos/debug");
|
|
|
196
201
|
var import_credentials14 = require("@dxos/protocols/proto/dxos/halo/credentials");
|
|
197
202
|
var import_timeframe3 = require("@dxos/timeframe");
|
|
198
203
|
var import_async14 = require("@dxos/async");
|
|
199
|
-
var
|
|
204
|
+
var import_codec_protobuf10 = require("@dxos/codec-protobuf");
|
|
200
205
|
var import_debug5 = require("@dxos/debug");
|
|
201
|
-
var
|
|
206
|
+
var import_invariant12 = require("@dxos/invariant");
|
|
202
207
|
var import_log11 = require("@dxos/log");
|
|
203
|
-
var
|
|
204
|
-
var
|
|
208
|
+
var import_protocols10 = require("@dxos/protocols");
|
|
209
|
+
var import_services10 = require("@dxos/protocols/proto/dxos/client/services");
|
|
205
210
|
var import_async15 = require("@dxos/async");
|
|
206
211
|
var import_context10 = require("@dxos/context");
|
|
207
212
|
var import_credentials15 = require("@dxos/credentials");
|
|
208
213
|
var import_debug6 = require("@dxos/debug");
|
|
209
|
-
var
|
|
214
|
+
var import_echo_db = require("@dxos/echo-db");
|
|
215
|
+
var import_echo_pipeline4 = require("@dxos/echo-pipeline");
|
|
210
216
|
var import_feed_store4 = require("@dxos/feed-store");
|
|
211
|
-
var
|
|
212
|
-
var import_invariant14 = require("@dxos/invariant");
|
|
217
|
+
var import_invariant13 = require("@dxos/invariant");
|
|
213
218
|
var import_keyring = require("@dxos/keyring");
|
|
214
|
-
var
|
|
219
|
+
var import_keys11 = require("@dxos/keys");
|
|
215
220
|
var import_log12 = require("@dxos/log");
|
|
221
|
+
var import_protocols11 = require("@dxos/protocols");
|
|
222
|
+
var import_services11 = require("@dxos/protocols/proto/dxos/client/services");
|
|
223
|
+
var import_teleport_extension_object_sync = require("@dxos/teleport-extension-object-sync");
|
|
224
|
+
var import_tracing5 = require("@dxos/tracing");
|
|
225
|
+
var import_util7 = require("@dxos/util");
|
|
226
|
+
var import_codec_protobuf11 = require("@dxos/codec-protobuf");
|
|
227
|
+
var import_credentials16 = require("@dxos/credentials");
|
|
228
|
+
var import_invariant14 = require("@dxos/invariant");
|
|
216
229
|
var import_protocols12 = require("@dxos/protocols");
|
|
217
230
|
var import_services12 = require("@dxos/protocols/proto/dxos/client/services");
|
|
218
|
-
var import_teleport_extension_object_sync = require("@dxos/teleport-extension-object-sync");
|
|
219
231
|
var import_tracing6 = require("@dxos/tracing");
|
|
220
|
-
var
|
|
221
|
-
var
|
|
222
|
-
var
|
|
223
|
-
var
|
|
224
|
-
var import_invariant15 = require("@dxos/invariant");
|
|
225
|
-
var import_lock_file = require("@dxos/lock-file");
|
|
226
|
-
var import_log13 = require("@dxos/log");
|
|
227
|
-
var import_protocols14 = require("@dxos/protocols");
|
|
228
|
-
var import_config = require("@dxos/protocols/proto/dxos/config");
|
|
229
|
-
var import_random_access_storage = require("@dxos/random-access-storage");
|
|
230
|
-
var import_client_protocol4 = require("@dxos/client-protocol");
|
|
231
|
-
var import_config2 = require("@dxos/protocols/proto/dxos/config");
|
|
232
|
+
var import_services13 = require("@dxos/protocols/proto/dxos/client/services");
|
|
233
|
+
var import_config = require("@dxos/config");
|
|
234
|
+
var import_services14 = require("@dxos/protocols/proto/dxos/client/services");
|
|
235
|
+
var import_tracing7 = require("@dxos/tracing");
|
|
232
236
|
var import_util8 = require("@dxos/util");
|
|
233
|
-
var import_level = require("level");
|
|
234
|
-
var import_node_path = __toESM(require("node:path"));
|
|
235
|
-
var import_keys11 = require("@dxos/keys");
|
|
236
237
|
var import_async16 = require("@dxos/async");
|
|
237
238
|
var import_client_protocol5 = require("@dxos/client-protocol");
|
|
238
239
|
var import_context11 = require("@dxos/context");
|
|
239
|
-
var
|
|
240
|
-
var
|
|
241
|
-
var
|
|
242
|
-
var import_invariant16 = require("@dxos/invariant");
|
|
240
|
+
var import_echo_pipeline5 = require("@dxos/echo-pipeline");
|
|
241
|
+
var import_echo_schema2 = require("@dxos/echo-schema");
|
|
242
|
+
var import_invariant15 = require("@dxos/invariant");
|
|
243
243
|
var import_keys12 = require("@dxos/keys");
|
|
244
|
-
var
|
|
244
|
+
var import_log13 = require("@dxos/log");
|
|
245
245
|
var import_messaging = require("@dxos/messaging");
|
|
246
246
|
var import_network_manager2 = require("@dxos/network-manager");
|
|
247
|
-
var
|
|
248
|
-
var
|
|
249
|
-
var
|
|
247
|
+
var import_protocols13 = require("@dxos/protocols");
|
|
248
|
+
var import_services15 = require("@dxos/protocols/proto/dxos/client/services");
|
|
249
|
+
var import_tracing8 = require("@dxos/tracing");
|
|
250
250
|
var import_util9 = require("@dxos/util");
|
|
251
251
|
var import_websocket_rpc = require("@dxos/websocket-rpc");
|
|
252
252
|
var import_async17 = require("@dxos/async");
|
|
253
253
|
var import_codec_protobuf12 = require("@dxos/codec-protobuf");
|
|
254
|
+
var import_invariant16 = require("@dxos/invariant");
|
|
255
|
+
var import_services16 = require("@dxos/protocols/proto/dxos/client/services");
|
|
254
256
|
var import_invariant17 = require("@dxos/invariant");
|
|
255
|
-
var
|
|
257
|
+
var import_lock_file = require("@dxos/lock-file");
|
|
258
|
+
var import_log14 = require("@dxos/log");
|
|
256
259
|
var import_async18 = require("@dxos/async");
|
|
257
260
|
var import_codec_protobuf13 = require("@dxos/codec-protobuf");
|
|
258
261
|
var import_keys13 = require("@dxos/keys");
|
|
259
262
|
var import_log15 = require("@dxos/log");
|
|
260
|
-
var
|
|
263
|
+
var import_services17 = require("@dxos/protocols/proto/dxos/client/services");
|
|
261
264
|
var import_util10 = require("@dxos/util");
|
|
262
265
|
var import_codec_protobuf14 = require("@dxos/codec-protobuf");
|
|
263
|
-
var
|
|
264
|
-
var
|
|
266
|
+
var import_protocols14 = require("@dxos/protocols");
|
|
267
|
+
var import_config2 = require("@dxos/protocols/proto/dxos/config");
|
|
268
|
+
var import_random_access_storage = require("@dxos/random-access-storage");
|
|
269
|
+
var import_client_protocol6 = require("@dxos/client-protocol");
|
|
270
|
+
var import_config3 = require("@dxos/protocols/proto/dxos/config");
|
|
265
271
|
var import_util11 = require("@dxos/util");
|
|
272
|
+
var import_level = require("level");
|
|
273
|
+
var import_node_path = __toESM(require("node:path"));
|
|
274
|
+
var import_keys14 = require("@dxos/keys");
|
|
275
|
+
var import_codec_protobuf15 = require("@dxos/codec-protobuf");
|
|
276
|
+
var import_services18 = require("@dxos/protocols/proto/dxos/client/services");
|
|
277
|
+
var import_util12 = require("@dxos/util");
|
|
278
|
+
var import_keys15 = require("@dxos/keys");
|
|
279
|
+
var import_util13 = require("@dxos/util");
|
|
266
280
|
var subscribeToFeeds = ({ feedStore }, { feedKeys }) => {
|
|
267
281
|
return new import_codec_protobuf.Stream(({ next }) => {
|
|
268
282
|
const subscriptions = new import_async.EventSubscriptions();
|
|
@@ -1280,7 +1294,9 @@ var IdentityManager = class {
|
|
|
1280
1294
|
C: (f, a) => f(...a)
|
|
1281
1295
|
});
|
|
1282
1296
|
},
|
|
1283
|
-
memberKey: identityKey
|
|
1297
|
+
memberKey: identityKey,
|
|
1298
|
+
onDelegatedInvitationStatusChange: async () => {
|
|
1299
|
+
}
|
|
1284
1300
|
});
|
|
1285
1301
|
}
|
|
1286
1302
|
};
|
|
@@ -1377,10 +1393,13 @@ var DeviceInvitationProtocol = class {
|
|
|
1377
1393
|
kind: import_services2.Invitation.Kind.DEVICE
|
|
1378
1394
|
};
|
|
1379
1395
|
}
|
|
1380
|
-
async
|
|
1396
|
+
async delegate(invitation) {
|
|
1397
|
+
throw new Error("delegation not supported");
|
|
1398
|
+
}
|
|
1399
|
+
async admit(_, request) {
|
|
1381
1400
|
(0, import_invariant4.invariant)(request.device, void 0, {
|
|
1382
1401
|
F: __dxlog_file5,
|
|
1383
|
-
L:
|
|
1402
|
+
L: 42,
|
|
1384
1403
|
S: this,
|
|
1385
1404
|
A: [
|
|
1386
1405
|
"request.device",
|
|
@@ -1426,7 +1445,7 @@ var DeviceInvitationProtocol = class {
|
|
|
1426
1445
|
async accept(response, request) {
|
|
1427
1446
|
(0, import_invariant4.invariant)(response.device, void 0, {
|
|
1428
1447
|
F: __dxlog_file5,
|
|
1429
|
-
L:
|
|
1448
|
+
L: 87,
|
|
1430
1449
|
S: this,
|
|
1431
1450
|
A: [
|
|
1432
1451
|
"response.device",
|
|
@@ -1436,7 +1455,7 @@ var DeviceInvitationProtocol = class {
|
|
|
1436
1455
|
const { identityKey, haloSpaceKey, genesisFeedKey, controlTimeframe } = response.device;
|
|
1437
1456
|
(0, import_invariant4.invariant)(request.device, void 0, {
|
|
1438
1457
|
F: __dxlog_file5,
|
|
1439
|
-
L:
|
|
1458
|
+
L: 90,
|
|
1440
1459
|
S: this,
|
|
1441
1460
|
A: [
|
|
1442
1461
|
"request.device",
|
|
@@ -1475,6 +1494,7 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
1475
1494
|
this._callbacks = _callbacks;
|
|
1476
1495
|
this._ctx = new import_context5.Context();
|
|
1477
1496
|
this._remoteOptionsTrigger = new import_async8.Trigger();
|
|
1497
|
+
this._challenge = void 0;
|
|
1478
1498
|
this.invitation = void 0;
|
|
1479
1499
|
this.guestProfile = void 0;
|
|
1480
1500
|
this.authenticationPassed = false;
|
|
@@ -1489,7 +1509,7 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
1489
1509
|
options: async (options) => {
|
|
1490
1510
|
(0, import_invariant6.invariant)(!this._remoteOptions, "Remote options already set.", {
|
|
1491
1511
|
F: __dxlog_file6,
|
|
1492
|
-
L:
|
|
1512
|
+
L: 90,
|
|
1493
1513
|
S: this,
|
|
1494
1514
|
A: [
|
|
1495
1515
|
"!this._remoteOptions",
|
|
@@ -1506,7 +1526,7 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
1506
1526
|
id: traceId
|
|
1507
1527
|
}), {
|
|
1508
1528
|
F: __dxlog_file6,
|
|
1509
|
-
L:
|
|
1529
|
+
L: 99,
|
|
1510
1530
|
S: this,
|
|
1511
1531
|
C: (f, a) => f(...a)
|
|
1512
1532
|
});
|
|
@@ -1516,7 +1536,7 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
1516
1536
|
invitationId
|
|
1517
1537
|
}, {
|
|
1518
1538
|
F: __dxlog_file6,
|
|
1519
|
-
L:
|
|
1539
|
+
L: 103,
|
|
1520
1540
|
S: this,
|
|
1521
1541
|
C: (f, a) => f(...a)
|
|
1522
1542
|
});
|
|
@@ -1530,7 +1550,7 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
1530
1550
|
guestProfile: profile
|
|
1531
1551
|
}, {
|
|
1532
1552
|
F: __dxlog_file6,
|
|
1533
|
-
L:
|
|
1553
|
+
L: 112,
|
|
1534
1554
|
S: this,
|
|
1535
1555
|
C: (f, a) => f(...a)
|
|
1536
1556
|
});
|
|
@@ -1539,25 +1559,27 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
1539
1559
|
...this.invitation,
|
|
1540
1560
|
state: import_services4.Invitation.State.READY_FOR_AUTHENTICATION
|
|
1541
1561
|
});
|
|
1562
|
+
this._challenge = this.invitation.authMethod === import_services4.Invitation.AuthMethod.KNOWN_PUBLIC_KEY ? (0, import_crypto2.randomBytes)(32) : void 0;
|
|
1542
1563
|
import_log5.log.trace("dxos.sdk.invitation-handler.host.introduce", import_protocols5.trace.end({
|
|
1543
1564
|
id: traceId
|
|
1544
1565
|
}), {
|
|
1545
1566
|
F: __dxlog_file6,
|
|
1546
|
-
L:
|
|
1567
|
+
L: 122,
|
|
1547
1568
|
S: this,
|
|
1548
1569
|
C: (f, a) => f(...a)
|
|
1549
1570
|
});
|
|
1550
1571
|
return {
|
|
1551
|
-
authMethod: this.invitation.authMethod
|
|
1572
|
+
authMethod: this.invitation.authMethod,
|
|
1573
|
+
challenge: this._challenge
|
|
1552
1574
|
};
|
|
1553
1575
|
},
|
|
1554
|
-
authenticate: async ({ authCode: code }) => {
|
|
1576
|
+
authenticate: async ({ authCode: code, signedChallenge }) => {
|
|
1555
1577
|
const traceId = import_keys6.PublicKey.random().toHex();
|
|
1556
1578
|
import_log5.log.trace("dxos.sdk.invitation-handler.host.authenticate", import_protocols5.trace.begin({
|
|
1557
1579
|
id: traceId
|
|
1558
1580
|
}), {
|
|
1559
1581
|
F: __dxlog_file6,
|
|
1560
|
-
L:
|
|
1582
|
+
L: 131,
|
|
1561
1583
|
S: this,
|
|
1562
1584
|
C: (f, a) => f(...a)
|
|
1563
1585
|
});
|
|
@@ -1565,14 +1587,14 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
1565
1587
|
authCode: code
|
|
1566
1588
|
}, {
|
|
1567
1589
|
F: __dxlog_file6,
|
|
1568
|
-
L:
|
|
1590
|
+
L: 132,
|
|
1569
1591
|
S: this,
|
|
1570
1592
|
C: (f, a) => f(...a)
|
|
1571
1593
|
});
|
|
1572
1594
|
let status = import_invitations2.AuthenticationResponse.Status.OK;
|
|
1573
1595
|
(0, import_invariant6.invariant)(this.invitation, "Invitation is not set.", {
|
|
1574
1596
|
F: __dxlog_file6,
|
|
1575
|
-
L:
|
|
1597
|
+
L: 135,
|
|
1576
1598
|
S: this,
|
|
1577
1599
|
A: [
|
|
1578
1600
|
"this.invitation",
|
|
@@ -1583,7 +1605,7 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
1583
1605
|
case import_services4.Invitation.AuthMethod.NONE: {
|
|
1584
1606
|
(0, import_log5.log)("authentication not required", void 0, {
|
|
1585
1607
|
F: __dxlog_file6,
|
|
1586
|
-
L:
|
|
1608
|
+
L: 138,
|
|
1587
1609
|
S: this,
|
|
1588
1610
|
C: (f, a) => f(...a)
|
|
1589
1611
|
});
|
|
@@ -1603,12 +1625,25 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
1603
1625
|
}
|
|
1604
1626
|
break;
|
|
1605
1627
|
}
|
|
1628
|
+
case import_services4.Invitation.AuthMethod.KNOWN_PUBLIC_KEY: {
|
|
1629
|
+
if (!this.invitation.guestKeypair) {
|
|
1630
|
+
status = import_invitations2.AuthenticationResponse.Status.INTERNAL_ERROR;
|
|
1631
|
+
break;
|
|
1632
|
+
}
|
|
1633
|
+
const isSignatureValid = this._challenge && (0, import_crypto2.verify)(this._challenge, Buffer.from(signedChallenge ?? []), this.invitation.guestKeypair.publicKey.asBuffer());
|
|
1634
|
+
if (isSignatureValid) {
|
|
1635
|
+
this.authenticationPassed = true;
|
|
1636
|
+
} else {
|
|
1637
|
+
status = import_invitations2.AuthenticationResponse.Status.INVALID_SIGNATURE;
|
|
1638
|
+
}
|
|
1639
|
+
break;
|
|
1640
|
+
}
|
|
1606
1641
|
default: {
|
|
1607
1642
|
import_log5.log.error("invalid authentication method", {
|
|
1608
1643
|
authMethod: this.invitation.authMethod
|
|
1609
1644
|
}, {
|
|
1610
1645
|
F: __dxlog_file6,
|
|
1611
|
-
L:
|
|
1646
|
+
L: 176,
|
|
1612
1647
|
S: this,
|
|
1613
1648
|
C: (f, a) => f(...a)
|
|
1614
1649
|
});
|
|
@@ -1623,7 +1658,7 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
1623
1658
|
}
|
|
1624
1659
|
}), {
|
|
1625
1660
|
F: __dxlog_file6,
|
|
1626
|
-
L:
|
|
1661
|
+
L: 182,
|
|
1627
1662
|
S: this,
|
|
1628
1663
|
C: (f, a) => f(...a)
|
|
1629
1664
|
});
|
|
@@ -1637,14 +1672,14 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
1637
1672
|
id: traceId
|
|
1638
1673
|
}), {
|
|
1639
1674
|
F: __dxlog_file6,
|
|
1640
|
-
L:
|
|
1675
|
+
L: 188,
|
|
1641
1676
|
S: this,
|
|
1642
1677
|
C: (f, a) => f(...a)
|
|
1643
1678
|
});
|
|
1644
1679
|
try {
|
|
1645
1680
|
(0, import_invariant6.invariant)(this.invitation, "Invitation is not set.", {
|
|
1646
1681
|
F: __dxlog_file6,
|
|
1647
|
-
L:
|
|
1682
|
+
L: 191,
|
|
1648
1683
|
S: this,
|
|
1649
1684
|
A: [
|
|
1650
1685
|
"this.invitation",
|
|
@@ -1659,7 +1694,7 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
1659
1694
|
id: traceId
|
|
1660
1695
|
}), {
|
|
1661
1696
|
F: __dxlog_file6,
|
|
1662
|
-
L:
|
|
1697
|
+
L: 199,
|
|
1663
1698
|
S: this,
|
|
1664
1699
|
C: (f, a) => f(...a)
|
|
1665
1700
|
});
|
|
@@ -1716,7 +1751,7 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
|
|
|
1716
1751
|
options: async (options) => {
|
|
1717
1752
|
(0, import_invariant6.invariant)(!this._remoteOptions, "Remote options already set.", {
|
|
1718
1753
|
F: __dxlog_file6,
|
|
1719
|
-
L:
|
|
1754
|
+
L: 266,
|
|
1720
1755
|
S: this,
|
|
1721
1756
|
A: [
|
|
1722
1757
|
"!this._remoteOptions",
|
|
@@ -1743,7 +1778,7 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
|
|
|
1743
1778
|
try {
|
|
1744
1779
|
(0, import_log5.log)("begin options", void 0, {
|
|
1745
1780
|
F: __dxlog_file6,
|
|
1746
|
-
L:
|
|
1781
|
+
L: 287,
|
|
1747
1782
|
S: this,
|
|
1748
1783
|
C: (f, a) => f(...a)
|
|
1749
1784
|
});
|
|
@@ -1755,7 +1790,7 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
|
|
|
1755
1790
|
}));
|
|
1756
1791
|
(0, import_log5.log)("end options", void 0, {
|
|
1757
1792
|
F: __dxlog_file6,
|
|
1758
|
-
L:
|
|
1793
|
+
L: 290,
|
|
1759
1794
|
S: this,
|
|
1760
1795
|
C: (f, a) => f(...a)
|
|
1761
1796
|
});
|
|
@@ -1769,7 +1804,7 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
|
|
|
1769
1804
|
} catch (err) {
|
|
1770
1805
|
(0, import_log5.log)("openError", err, {
|
|
1771
1806
|
F: __dxlog_file6,
|
|
1772
|
-
L:
|
|
1807
|
+
L: 300,
|
|
1773
1808
|
S: this,
|
|
1774
1809
|
C: (f, a) => f(...a)
|
|
1775
1810
|
});
|
|
@@ -1779,7 +1814,7 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
|
|
|
1779
1814
|
async onClose() {
|
|
1780
1815
|
(0, import_log5.log)("onClose", void 0, {
|
|
1781
1816
|
F: __dxlog_file6,
|
|
1782
|
-
L:
|
|
1817
|
+
L: 306,
|
|
1783
1818
|
S: this,
|
|
1784
1819
|
C: (f, a) => f(...a)
|
|
1785
1820
|
});
|
|
@@ -1795,49 +1830,7 @@ var InvitationsHandler = class {
|
|
|
1795
1830
|
constructor(_networkManager) {
|
|
1796
1831
|
this._networkManager = _networkManager;
|
|
1797
1832
|
}
|
|
1798
|
-
|
|
1799
|
-
const { invitationId = import_keys5.PublicKey.random().toHex(), type = import_services3.Invitation.Type.INTERACTIVE, authMethod = import_services3.Invitation.AuthMethod.SHARED_SECRET, state = import_services3.Invitation.State.INIT, timeout = import_client_protocol2.INVITATION_TIMEOUT, swarmKey = import_keys5.PublicKey.random(), persistent = true, created = /* @__PURE__ */ new Date(), lifetime = 86400 } = options ?? {};
|
|
1800
|
-
const authCode = options?.authCode ?? (authMethod === import_services3.Invitation.AuthMethod.SHARED_SECRET ? (0, import_credentials7.generatePasscode)(import_client_protocol2.AUTHENTICATION_CODE_LENGTH) : void 0);
|
|
1801
|
-
(0, import_invariant5.invariant)(protocol, void 0, {
|
|
1802
|
-
F: __dxlog_file7,
|
|
1803
|
-
L: 84,
|
|
1804
|
-
S: this,
|
|
1805
|
-
A: [
|
|
1806
|
-
"protocol",
|
|
1807
|
-
""
|
|
1808
|
-
]
|
|
1809
|
-
});
|
|
1810
|
-
const invitation = {
|
|
1811
|
-
invitationId,
|
|
1812
|
-
type,
|
|
1813
|
-
authMethod,
|
|
1814
|
-
state,
|
|
1815
|
-
swarmKey,
|
|
1816
|
-
authCode,
|
|
1817
|
-
timeout,
|
|
1818
|
-
persistent,
|
|
1819
|
-
created,
|
|
1820
|
-
lifetime,
|
|
1821
|
-
...protocol.getInvitationContext()
|
|
1822
|
-
};
|
|
1823
|
-
const stream = new import_async7.PushStream();
|
|
1824
|
-
const ctx = new import_context4.Context({
|
|
1825
|
-
onError: (err) => {
|
|
1826
|
-
stream.error(err);
|
|
1827
|
-
void ctx.dispose();
|
|
1828
|
-
}
|
|
1829
|
-
});
|
|
1830
|
-
ctx.onDispose(() => {
|
|
1831
|
-
(0, import_log4.log)("complete", {
|
|
1832
|
-
...protocol.toJSON()
|
|
1833
|
-
}, {
|
|
1834
|
-
F: __dxlog_file7,
|
|
1835
|
-
L: 109,
|
|
1836
|
-
S: this,
|
|
1837
|
-
C: (f, a) => f(...a)
|
|
1838
|
-
});
|
|
1839
|
-
stream.complete();
|
|
1840
|
-
});
|
|
1833
|
+
handleInvitationFlow(ctx, stream, protocol, invitation) {
|
|
1841
1834
|
const createExtension = () => {
|
|
1842
1835
|
const extension = new InvitationHostExtension({
|
|
1843
1836
|
onStateUpdate: (invitation2) => {
|
|
@@ -1846,8 +1839,8 @@ var InvitationsHandler = class {
|
|
|
1846
1839
|
state: import_services3.Invitation.State.READY_FOR_AUTHENTICATION
|
|
1847
1840
|
});
|
|
1848
1841
|
},
|
|
1849
|
-
resolveInvitation: async ({ invitationId
|
|
1850
|
-
if (
|
|
1842
|
+
resolveInvitation: async ({ invitationId }) => {
|
|
1843
|
+
if (invitationId && invitationId !== invitation.invitationId) {
|
|
1851
1844
|
return void 0;
|
|
1852
1845
|
}
|
|
1853
1846
|
return invitation;
|
|
@@ -1857,14 +1850,14 @@ var InvitationsHandler = class {
|
|
|
1857
1850
|
const deviceKey = admissionRequest.device?.deviceKey ?? admissionRequest.space?.deviceKey;
|
|
1858
1851
|
(0, import_invariant5.invariant)(deviceKey, void 0, {
|
|
1859
1852
|
F: __dxlog_file7,
|
|
1860
|
-
L:
|
|
1853
|
+
L: 87,
|
|
1861
1854
|
S: this,
|
|
1862
1855
|
A: [
|
|
1863
1856
|
"deviceKey",
|
|
1864
1857
|
""
|
|
1865
1858
|
]
|
|
1866
1859
|
});
|
|
1867
|
-
const admissionResponse = await protocol.admit(admissionRequest, extension.guestProfile);
|
|
1860
|
+
const admissionResponse = await protocol.admit(invitation, admissionRequest, extension.guestProfile);
|
|
1868
1861
|
extension.completedTrigger.wake(deviceKey);
|
|
1869
1862
|
return admissionResponse;
|
|
1870
1863
|
} catch (err) {
|
|
@@ -1880,7 +1873,7 @@ var InvitationsHandler = class {
|
|
|
1880
1873
|
id: traceId
|
|
1881
1874
|
}), {
|
|
1882
1875
|
F: __dxlog_file7,
|
|
1883
|
-
L:
|
|
1876
|
+
L: 105,
|
|
1884
1877
|
S: this,
|
|
1885
1878
|
C: (f, a) => f(...a)
|
|
1886
1879
|
});
|
|
@@ -1888,7 +1881,7 @@ var InvitationsHandler = class {
|
|
|
1888
1881
|
...protocol.toJSON()
|
|
1889
1882
|
}, {
|
|
1890
1883
|
F: __dxlog_file7,
|
|
1891
|
-
L:
|
|
1884
|
+
L: 106,
|
|
1892
1885
|
S: this,
|
|
1893
1886
|
C: (f, a) => f(...a)
|
|
1894
1887
|
});
|
|
@@ -1897,14 +1890,14 @@ var InvitationsHandler = class {
|
|
|
1897
1890
|
state: import_services3.Invitation.State.CONNECTED
|
|
1898
1891
|
});
|
|
1899
1892
|
const deviceKey = await extension.completedTrigger.wait({
|
|
1900
|
-
timeout
|
|
1893
|
+
timeout: invitation.timeout
|
|
1901
1894
|
});
|
|
1902
1895
|
(0, import_log4.log)("admitted guest", {
|
|
1903
1896
|
guest: deviceKey,
|
|
1904
1897
|
...protocol.toJSON()
|
|
1905
1898
|
}, {
|
|
1906
1899
|
F: __dxlog_file7,
|
|
1907
|
-
L:
|
|
1900
|
+
L: 109,
|
|
1908
1901
|
S: this,
|
|
1909
1902
|
C: (f, a) => f(...a)
|
|
1910
1903
|
});
|
|
@@ -1916,7 +1909,7 @@ var InvitationsHandler = class {
|
|
|
1916
1909
|
id: traceId
|
|
1917
1910
|
}), {
|
|
1918
1911
|
F: __dxlog_file7,
|
|
1919
|
-
L:
|
|
1912
|
+
L: 111,
|
|
1920
1913
|
S: this,
|
|
1921
1914
|
C: (f, a) => f(...a)
|
|
1922
1915
|
});
|
|
@@ -1926,7 +1919,7 @@ var InvitationsHandler = class {
|
|
|
1926
1919
|
...protocol.toJSON()
|
|
1927
1920
|
}, {
|
|
1928
1921
|
F: __dxlog_file7,
|
|
1929
|
-
L:
|
|
1922
|
+
L: 114,
|
|
1930
1923
|
S: this,
|
|
1931
1924
|
C: (f, a) => f(...a)
|
|
1932
1925
|
});
|
|
@@ -1937,7 +1930,7 @@ var InvitationsHandler = class {
|
|
|
1937
1930
|
} else {
|
|
1938
1931
|
import_log4.log.error("failed", err, {
|
|
1939
1932
|
F: __dxlog_file7,
|
|
1940
|
-
L:
|
|
1933
|
+
L: 117,
|
|
1941
1934
|
S: this,
|
|
1942
1935
|
C: (f, a) => f(...a)
|
|
1943
1936
|
});
|
|
@@ -1948,12 +1941,12 @@ var InvitationsHandler = class {
|
|
|
1948
1941
|
error: err
|
|
1949
1942
|
}), {
|
|
1950
1943
|
F: __dxlog_file7,
|
|
1951
|
-
L:
|
|
1944
|
+
L: 120,
|
|
1952
1945
|
S: this,
|
|
1953
1946
|
C: (f, a) => f(...a)
|
|
1954
1947
|
});
|
|
1955
1948
|
} finally {
|
|
1956
|
-
if (
|
|
1949
|
+
if (!invitation.multiUse) {
|
|
1957
1950
|
await swarmConnection.close();
|
|
1958
1951
|
await ctx.dispose();
|
|
1959
1952
|
}
|
|
@@ -1969,7 +1962,7 @@ var InvitationsHandler = class {
|
|
|
1969
1962
|
...protocol.toJSON()
|
|
1970
1963
|
}, {
|
|
1971
1964
|
F: __dxlog_file7,
|
|
1972
|
-
L:
|
|
1965
|
+
L: 135,
|
|
1973
1966
|
S: this,
|
|
1974
1967
|
C: (f, a) => f(...a)
|
|
1975
1968
|
});
|
|
@@ -1980,7 +1973,7 @@ var InvitationsHandler = class {
|
|
|
1980
1973
|
} else {
|
|
1981
1974
|
import_log4.log.error("failed", err, {
|
|
1982
1975
|
F: __dxlog_file7,
|
|
1983
|
-
L:
|
|
1976
|
+
L: 138,
|
|
1984
1977
|
S: this,
|
|
1985
1978
|
C: (f, a) => f(...a)
|
|
1986
1979
|
});
|
|
@@ -1990,11 +1983,11 @@ var InvitationsHandler = class {
|
|
|
1990
1983
|
});
|
|
1991
1984
|
return extension;
|
|
1992
1985
|
};
|
|
1993
|
-
if (invitation.lifetime && invitation.created
|
|
1986
|
+
if (invitation.lifetime && invitation.created) {
|
|
1994
1987
|
if (invitation.created.getTime() + invitation.lifetime * 1e3 < Date.now()) {
|
|
1995
1988
|
import_log4.log.warn("invitation has already expired", void 0, {
|
|
1996
1989
|
F: __dxlog_file7,
|
|
1997
|
-
L:
|
|
1990
|
+
L: 149,
|
|
1998
1991
|
S: this,
|
|
1999
1992
|
C: (f, a) => f(...a)
|
|
2000
1993
|
});
|
|
@@ -2028,24 +2021,12 @@ var InvitationsHandler = class {
|
|
|
2028
2021
|
state: import_services3.Invitation.State.CONNECTING
|
|
2029
2022
|
});
|
|
2030
2023
|
});
|
|
2031
|
-
const observable = new import_client_protocol2.CancellableInvitation({
|
|
2032
|
-
initialInvitation: invitation,
|
|
2033
|
-
subscriber: stream.observable,
|
|
2034
|
-
onCancel: async () => {
|
|
2035
|
-
stream.next({
|
|
2036
|
-
...invitation,
|
|
2037
|
-
state: import_services3.Invitation.State.CANCELLED
|
|
2038
|
-
});
|
|
2039
|
-
await ctx.dispose();
|
|
2040
|
-
}
|
|
2041
|
-
});
|
|
2042
|
-
return observable;
|
|
2043
2024
|
}
|
|
2044
2025
|
acceptInvitation(protocol, invitation, deviceProfile) {
|
|
2045
2026
|
const { timeout = import_client_protocol2.INVITATION_TIMEOUT } = invitation;
|
|
2046
2027
|
(0, import_invariant5.invariant)(protocol, void 0, {
|
|
2047
2028
|
F: __dxlog_file7,
|
|
2048
|
-
L:
|
|
2029
|
+
L: 191,
|
|
2049
2030
|
S: this,
|
|
2050
2031
|
A: [
|
|
2051
2032
|
"protocol",
|
|
@@ -2055,7 +2036,7 @@ var InvitationsHandler = class {
|
|
|
2055
2036
|
if (deviceProfile) {
|
|
2056
2037
|
(0, import_invariant5.invariant)(invitation.kind === import_services3.Invitation.Kind.DEVICE, "deviceProfile provided for non-device invitation", {
|
|
2057
2038
|
F: __dxlog_file7,
|
|
2058
|
-
L:
|
|
2039
|
+
L: 194,
|
|
2059
2040
|
S: this,
|
|
2060
2041
|
A: [
|
|
2061
2042
|
"invitation.kind === Invitation.Kind.DEVICE",
|
|
@@ -2070,7 +2051,7 @@ var InvitationsHandler = class {
|
|
|
2070
2051
|
const setState = (newData) => {
|
|
2071
2052
|
(0, import_invariant5.invariant)(newData.state !== void 0, void 0, {
|
|
2072
2053
|
F: __dxlog_file7,
|
|
2073
|
-
L:
|
|
2054
|
+
L: 205,
|
|
2074
2055
|
S: this,
|
|
2075
2056
|
A: [
|
|
2076
2057
|
"newData.state !== undefined",
|
|
@@ -2090,7 +2071,7 @@ var InvitationsHandler = class {
|
|
|
2090
2071
|
...protocol.toJSON()
|
|
2091
2072
|
}, {
|
|
2092
2073
|
F: __dxlog_file7,
|
|
2093
|
-
L:
|
|
2074
|
+
L: 213,
|
|
2094
2075
|
S: this,
|
|
2095
2076
|
C: (f, a) => f(...a)
|
|
2096
2077
|
});
|
|
@@ -2100,7 +2081,7 @@ var InvitationsHandler = class {
|
|
|
2100
2081
|
} else {
|
|
2101
2082
|
import_log4.log.warn("auth failed", err, {
|
|
2102
2083
|
F: __dxlog_file7,
|
|
2103
|
-
L:
|
|
2084
|
+
L: 216,
|
|
2104
2085
|
S: this,
|
|
2105
2086
|
C: (f, a) => f(...a)
|
|
2106
2087
|
});
|
|
@@ -2114,7 +2095,7 @@ var InvitationsHandler = class {
|
|
|
2114
2095
|
...protocol.toJSON()
|
|
2115
2096
|
}, {
|
|
2116
2097
|
F: __dxlog_file7,
|
|
2117
|
-
L:
|
|
2098
|
+
L: 224,
|
|
2118
2099
|
S: this,
|
|
2119
2100
|
C: (f, a) => f(...a)
|
|
2120
2101
|
});
|
|
@@ -2129,7 +2110,7 @@ var InvitationsHandler = class {
|
|
|
2129
2110
|
currentState
|
|
2130
2111
|
}, {
|
|
2131
2112
|
F: __dxlog_file7,
|
|
2132
|
-
L:
|
|
2113
|
+
L: 234,
|
|
2133
2114
|
S: this,
|
|
2134
2115
|
C: (f, a) => f(...a)
|
|
2135
2116
|
});
|
|
@@ -2144,7 +2125,7 @@ var InvitationsHandler = class {
|
|
|
2144
2125
|
id: traceId
|
|
2145
2126
|
}), {
|
|
2146
2127
|
F: __dxlog_file7,
|
|
2147
|
-
L:
|
|
2128
|
+
L: 243,
|
|
2148
2129
|
S: this,
|
|
2149
2130
|
C: (f, a) => f(...a)
|
|
2150
2131
|
});
|
|
@@ -2156,7 +2137,7 @@ var InvitationsHandler = class {
|
|
|
2156
2137
|
...protocol.toJSON()
|
|
2157
2138
|
}, {
|
|
2158
2139
|
F: __dxlog_file7,
|
|
2159
|
-
L:
|
|
2140
|
+
L: 251,
|
|
2160
2141
|
S: this,
|
|
2161
2142
|
C: (f, a) => f(...a)
|
|
2162
2143
|
});
|
|
@@ -2167,7 +2148,7 @@ var InvitationsHandler = class {
|
|
|
2167
2148
|
...protocol.toJSON()
|
|
2168
2149
|
}, {
|
|
2169
2150
|
F: __dxlog_file7,
|
|
2170
|
-
L:
|
|
2151
|
+
L: 255,
|
|
2171
2152
|
S: this,
|
|
2172
2153
|
C: (f, a) => f(...a)
|
|
2173
2154
|
});
|
|
@@ -2177,62 +2158,28 @@ var InvitationsHandler = class {
|
|
|
2177
2158
|
response: introductionResponse
|
|
2178
2159
|
}, {
|
|
2179
2160
|
F: __dxlog_file7,
|
|
2180
|
-
L:
|
|
2161
|
+
L: 259,
|
|
2181
2162
|
S: this,
|
|
2182
2163
|
C: (f, a) => f(...a)
|
|
2183
2164
|
});
|
|
2184
2165
|
invitation.authMethod = introductionResponse.authMethod;
|
|
2185
2166
|
if (isAuthenticationRequired(invitation)) {
|
|
2186
|
-
|
|
2187
|
-
|
|
2188
|
-
|
|
2189
|
-
|
|
2190
|
-
|
|
2191
|
-
|
|
2192
|
-
|
|
2193
|
-
|
|
2194
|
-
state: import_services3.Invitation.State.READY_FOR_AUTHENTICATION
|
|
2195
|
-
});
|
|
2196
|
-
const authCode = await authenticated.wait({
|
|
2197
|
-
timeout
|
|
2198
|
-
});
|
|
2199
|
-
(0, import_log4.log)("sending authentication request", void 0, {
|
|
2200
|
-
F: __dxlog_file7,
|
|
2201
|
-
L: 325,
|
|
2202
|
-
S: this,
|
|
2203
|
-
C: (f, a) => f(...a)
|
|
2204
|
-
});
|
|
2205
|
-
setState({
|
|
2206
|
-
state: import_services3.Invitation.State.AUTHENTICATING
|
|
2207
|
-
});
|
|
2208
|
-
const response = await extension.rpc.InvitationHostService.authenticate({
|
|
2209
|
-
authCode
|
|
2210
|
-
});
|
|
2211
|
-
if (response.status === void 0 || response.status === import_invitations.AuthenticationResponse.Status.OK) {
|
|
2167
|
+
switch (invitation.authMethod) {
|
|
2168
|
+
case import_services3.Invitation.AuthMethod.SHARED_SECRET:
|
|
2169
|
+
await this._handleGuestOtpAuth(extension, setState, authenticated, {
|
|
2170
|
+
timeout
|
|
2171
|
+
});
|
|
2172
|
+
break;
|
|
2173
|
+
case import_services3.Invitation.AuthMethod.KNOWN_PUBLIC_KEY:
|
|
2174
|
+
await this._handleGuestKpkAuth(extension, setState, invitation, introductionResponse);
|
|
2212
2175
|
break;
|
|
2213
|
-
}
|
|
2214
|
-
if (response.status === import_invitations.AuthenticationResponse.Status.INVALID_OTP) {
|
|
2215
|
-
if (attempt === MAX_OTP_ATTEMPTS) {
|
|
2216
|
-
throw new Error(`Maximum retry attempts: ${MAX_OTP_ATTEMPTS}`);
|
|
2217
|
-
} else {
|
|
2218
|
-
(0, import_log4.log)("retrying invalid code", {
|
|
2219
|
-
attempt
|
|
2220
|
-
}, {
|
|
2221
|
-
F: __dxlog_file7,
|
|
2222
|
-
L: 336,
|
|
2223
|
-
S: this,
|
|
2224
|
-
C: (f, a) => f(...a)
|
|
2225
|
-
});
|
|
2226
|
-
authenticated.reset();
|
|
2227
|
-
}
|
|
2228
|
-
}
|
|
2229
2176
|
}
|
|
2230
2177
|
}
|
|
2231
2178
|
(0, import_log4.log)("request admission", {
|
|
2232
2179
|
...protocol.toJSON()
|
|
2233
2180
|
}, {
|
|
2234
2181
|
F: __dxlog_file7,
|
|
2235
|
-
L:
|
|
2182
|
+
L: 275,
|
|
2236
2183
|
S: this,
|
|
2237
2184
|
C: (f, a) => f(...a)
|
|
2238
2185
|
});
|
|
@@ -2244,7 +2191,7 @@ var InvitationsHandler = class {
|
|
|
2244
2191
|
...protocol.toJSON()
|
|
2245
2192
|
}, {
|
|
2246
2193
|
F: __dxlog_file7,
|
|
2247
|
-
L:
|
|
2194
|
+
L: 286,
|
|
2248
2195
|
S: this,
|
|
2249
2196
|
C: (f, a) => f(...a)
|
|
2250
2197
|
});
|
|
@@ -2257,7 +2204,7 @@ var InvitationsHandler = class {
|
|
|
2257
2204
|
id: traceId
|
|
2258
2205
|
}), {
|
|
2259
2206
|
F: __dxlog_file7,
|
|
2260
|
-
L:
|
|
2207
|
+
L: 288,
|
|
2261
2208
|
S: this,
|
|
2262
2209
|
C: (f, a) => f(...a)
|
|
2263
2210
|
});
|
|
@@ -2267,7 +2214,7 @@ var InvitationsHandler = class {
|
|
|
2267
2214
|
...protocol.toJSON()
|
|
2268
2215
|
}, {
|
|
2269
2216
|
F: __dxlog_file7,
|
|
2270
|
-
L:
|
|
2217
|
+
L: 291,
|
|
2271
2218
|
S: this,
|
|
2272
2219
|
C: (f, a) => f(...a)
|
|
2273
2220
|
});
|
|
@@ -2277,7 +2224,7 @@ var InvitationsHandler = class {
|
|
|
2277
2224
|
} else {
|
|
2278
2225
|
(0, import_log4.log)("auth failed", err, {
|
|
2279
2226
|
F: __dxlog_file7,
|
|
2280
|
-
L:
|
|
2227
|
+
L: 294,
|
|
2281
2228
|
S: this,
|
|
2282
2229
|
C: (f, a) => f(...a)
|
|
2283
2230
|
});
|
|
@@ -2288,7 +2235,7 @@ var InvitationsHandler = class {
|
|
|
2288
2235
|
error: err
|
|
2289
2236
|
}), {
|
|
2290
2237
|
F: __dxlog_file7,
|
|
2291
|
-
L:
|
|
2238
|
+
L: 297,
|
|
2292
2239
|
S: this,
|
|
2293
2240
|
C: (f, a) => f(...a)
|
|
2294
2241
|
});
|
|
@@ -2306,7 +2253,7 @@ var InvitationsHandler = class {
|
|
|
2306
2253
|
...protocol.toJSON()
|
|
2307
2254
|
}, {
|
|
2308
2255
|
F: __dxlog_file7,
|
|
2309
|
-
L:
|
|
2256
|
+
L: 308,
|
|
2310
2257
|
S: this,
|
|
2311
2258
|
C: (f, a) => f(...a)
|
|
2312
2259
|
});
|
|
@@ -2316,7 +2263,7 @@ var InvitationsHandler = class {
|
|
|
2316
2263
|
} else {
|
|
2317
2264
|
(0, import_log4.log)("auth failed", err, {
|
|
2318
2265
|
F: __dxlog_file7,
|
|
2319
|
-
L:
|
|
2266
|
+
L: 311,
|
|
2320
2267
|
S: this,
|
|
2321
2268
|
C: (f, a) => f(...a)
|
|
2322
2269
|
});
|
|
@@ -2333,7 +2280,7 @@ var InvitationsHandler = class {
|
|
|
2333
2280
|
} else {
|
|
2334
2281
|
(0, import_invariant5.invariant)(invitation.swarmKey, void 0, {
|
|
2335
2282
|
F: __dxlog_file7,
|
|
2336
|
-
L:
|
|
2283
|
+
L: 325,
|
|
2337
2284
|
S: this,
|
|
2338
2285
|
A: [
|
|
2339
2286
|
"invitation.swarmKey",
|
|
@@ -2371,198 +2318,110 @@ var InvitationsHandler = class {
|
|
|
2371
2318
|
});
|
|
2372
2319
|
return observable;
|
|
2373
2320
|
}
|
|
2321
|
+
async _handleGuestOtpAuth(extension, setState, authenticated, options) {
|
|
2322
|
+
for (let attempt = 1; attempt <= MAX_OTP_ATTEMPTS; attempt++) {
|
|
2323
|
+
(0, import_log4.log)("guest waiting for authentication code...", void 0, {
|
|
2324
|
+
F: __dxlog_file7,
|
|
2325
|
+
L: 365,
|
|
2326
|
+
S: this,
|
|
2327
|
+
C: (f, a) => f(...a)
|
|
2328
|
+
});
|
|
2329
|
+
setState({
|
|
2330
|
+
state: import_services3.Invitation.State.READY_FOR_AUTHENTICATION
|
|
2331
|
+
});
|
|
2332
|
+
const authCode = await authenticated.wait(options);
|
|
2333
|
+
(0, import_log4.log)("sending authentication request", void 0, {
|
|
2334
|
+
F: __dxlog_file7,
|
|
2335
|
+
L: 369,
|
|
2336
|
+
S: this,
|
|
2337
|
+
C: (f, a) => f(...a)
|
|
2338
|
+
});
|
|
2339
|
+
setState({
|
|
2340
|
+
state: import_services3.Invitation.State.AUTHENTICATING
|
|
2341
|
+
});
|
|
2342
|
+
const response = await extension.rpc.InvitationHostService.authenticate({
|
|
2343
|
+
authCode
|
|
2344
|
+
});
|
|
2345
|
+
if (response.status === void 0 || response.status === import_invitations.AuthenticationResponse.Status.OK) {
|
|
2346
|
+
break;
|
|
2347
|
+
}
|
|
2348
|
+
if (response.status === import_invitations.AuthenticationResponse.Status.INVALID_OTP) {
|
|
2349
|
+
if (attempt === MAX_OTP_ATTEMPTS) {
|
|
2350
|
+
throw new Error(`Maximum retry attempts: ${MAX_OTP_ATTEMPTS}`);
|
|
2351
|
+
} else {
|
|
2352
|
+
(0, import_log4.log)("retrying invalid code", {
|
|
2353
|
+
attempt
|
|
2354
|
+
}, {
|
|
2355
|
+
F: __dxlog_file7,
|
|
2356
|
+
L: 380,
|
|
2357
|
+
S: this,
|
|
2358
|
+
C: (f, a) => f(...a)
|
|
2359
|
+
});
|
|
2360
|
+
authenticated.reset();
|
|
2361
|
+
}
|
|
2362
|
+
}
|
|
2363
|
+
}
|
|
2364
|
+
}
|
|
2365
|
+
async _handleGuestKpkAuth(extension, setState, invitation, introductionResponse) {
|
|
2366
|
+
if (invitation.guestKeypair?.privateKey == null) {
|
|
2367
|
+
throw new Error("keypair missing in the invitation");
|
|
2368
|
+
}
|
|
2369
|
+
if (introductionResponse.challenge == null) {
|
|
2370
|
+
throw new Error("challenge missing in the introduction");
|
|
2371
|
+
}
|
|
2372
|
+
(0, import_log4.log)("sending authentication request", void 0, {
|
|
2373
|
+
F: __dxlog_file7,
|
|
2374
|
+
L: 399,
|
|
2375
|
+
S: this,
|
|
2376
|
+
C: (f, a) => f(...a)
|
|
2377
|
+
});
|
|
2378
|
+
setState({
|
|
2379
|
+
state: import_services3.Invitation.State.AUTHENTICATING
|
|
2380
|
+
});
|
|
2381
|
+
const signature = (0, import_crypto.sign)(Buffer.from(introductionResponse.challenge), invitation.guestKeypair.privateKey);
|
|
2382
|
+
const response = await extension.rpc.InvitationHostService.authenticate({
|
|
2383
|
+
signedChallenge: signature
|
|
2384
|
+
});
|
|
2385
|
+
if (response.status !== import_invitations.AuthenticationResponse.Status.OK) {
|
|
2386
|
+
throw new Error(`Authentication failed with code: ${response.status}`);
|
|
2387
|
+
}
|
|
2388
|
+
}
|
|
2374
2389
|
};
|
|
2375
|
-
var
|
|
2376
|
-
|
|
2390
|
+
var createAdmissionKeypair = () => {
|
|
2391
|
+
const keypair = (0, import_crypto.createKeyPair)();
|
|
2392
|
+
return {
|
|
2393
|
+
publicKey: import_keys5.PublicKey.from(keypair.publicKey),
|
|
2394
|
+
privateKey: keypair.secretKey
|
|
2395
|
+
};
|
|
2377
2396
|
};
|
|
2378
|
-
var __dxlog_file8 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitations-service.ts";
|
|
2379
2397
|
var InvitationsServiceImpl = class {
|
|
2380
|
-
constructor(
|
|
2381
|
-
this.
|
|
2382
|
-
this._getHandler = _getHandler;
|
|
2383
|
-
this._metadataStore = _metadataStore;
|
|
2384
|
-
this._createInvitations = /* @__PURE__ */ new Map();
|
|
2385
|
-
this._acceptInvitations = /* @__PURE__ */ new Map();
|
|
2386
|
-
this._invitationCreated = new import_async9.Event();
|
|
2387
|
-
this._invitationAccepted = new import_async9.Event();
|
|
2388
|
-
this._removedCreated = new import_async9.Event();
|
|
2389
|
-
this._removedAccepted = new import_async9.Event();
|
|
2390
|
-
this._saved = new import_async9.Event();
|
|
2391
|
-
this._persistentInvitationsLoadedEvent = new import_async9.Event();
|
|
2392
|
-
this._persistentInvitationsLoaded = false;
|
|
2398
|
+
constructor(_invitationsManager) {
|
|
2399
|
+
this._invitationsManager = _invitationsManager;
|
|
2393
2400
|
}
|
|
2394
2401
|
// TODO(burdon): Guest/host label.
|
|
2395
2402
|
getLoggingContext() {
|
|
2396
2403
|
return {};
|
|
2397
2404
|
}
|
|
2398
2405
|
createInvitation(options) {
|
|
2399
|
-
let invitation;
|
|
2400
|
-
const savePersistentInvitationCtx = new import_context6.Context();
|
|
2401
|
-
const existingInvitation = this._createInvitations.get(options.invitationId);
|
|
2402
|
-
if (existingInvitation) {
|
|
2403
|
-
invitation = existingInvitation;
|
|
2404
|
-
} else {
|
|
2405
|
-
const handler = this._getHandler(options);
|
|
2406
|
-
invitation = this._invitationsHandler.createInvitation(handler, options);
|
|
2407
|
-
this._createInvitations.set(invitation.get().invitationId, invitation);
|
|
2408
|
-
this._invitationCreated.emit(invitation.get());
|
|
2409
|
-
}
|
|
2410
2406
|
return new import_codec_protobuf8.Stream(({ next, close }) => {
|
|
2411
|
-
|
|
2412
|
-
(0, import_async9.scheduleTask)(savePersistentInvitationCtx, async () => {
|
|
2413
|
-
try {
|
|
2414
|
-
await this._metadataStore.addInvitation(invitation.get());
|
|
2415
|
-
this._saved.emit(invitation.get());
|
|
2416
|
-
} catch (err) {
|
|
2417
|
-
close(err);
|
|
2418
|
-
}
|
|
2419
|
-
});
|
|
2420
|
-
}
|
|
2421
|
-
invitation.subscribe((invitation2) => {
|
|
2422
|
-
next(invitation2);
|
|
2423
|
-
}, async (err) => {
|
|
2424
|
-
await savePersistentInvitationCtx.dispose();
|
|
2425
|
-
close(err);
|
|
2426
|
-
}, async () => {
|
|
2427
|
-
close();
|
|
2428
|
-
if (invitation.get().persistent) {
|
|
2429
|
-
await savePersistentInvitationCtx.dispose();
|
|
2430
|
-
await this._metadataStore.removeInvitation(invitation.get().invitationId);
|
|
2431
|
-
}
|
|
2432
|
-
this._createInvitations.delete(invitation.get().invitationId);
|
|
2433
|
-
if (invitation.get().type !== import_services5.Invitation.Type.MULTIUSE) {
|
|
2434
|
-
this._removedCreated.emit(invitation.get());
|
|
2435
|
-
}
|
|
2436
|
-
});
|
|
2407
|
+
void this._invitationsManager.createInvitation(options).then((invitation) => invitation.subscribe(next, close, close)).catch(close);
|
|
2437
2408
|
});
|
|
2438
2409
|
}
|
|
2439
|
-
|
|
2440
|
-
const
|
|
2441
|
-
const freshInvitations = persistentInvitations.filter(async (invitation) => !invitationExpired(invitation));
|
|
2442
|
-
const cInvitations = freshInvitations.map((persistentInvitation) => {
|
|
2443
|
-
(0, import_invariant7.invariant)(!this._createInvitations.get(persistentInvitation.invitationId), "invitation already exists", {
|
|
2444
|
-
F: __dxlog_file8,
|
|
2445
|
-
L: 109,
|
|
2446
|
-
S: this,
|
|
2447
|
-
A: [
|
|
2448
|
-
"!this._createInvitations.get(persistentInvitation.invitationId)",
|
|
2449
|
-
"'invitation already exists'"
|
|
2450
|
-
]
|
|
2451
|
-
});
|
|
2452
|
-
const handler = this._getHandler(persistentInvitation);
|
|
2453
|
-
const invitation = this._invitationsHandler.createInvitation(handler, persistentInvitation);
|
|
2454
|
-
this._createInvitations.set(invitation.get().invitationId, invitation);
|
|
2455
|
-
this._invitationCreated.emit(invitation.get());
|
|
2456
|
-
return persistentInvitation;
|
|
2457
|
-
});
|
|
2458
|
-
this._persistentInvitationsLoadedEvent.emit();
|
|
2459
|
-
this._persistentInvitationsLoaded = true;
|
|
2460
|
-
return {
|
|
2461
|
-
invitations: cInvitations
|
|
2462
|
-
};
|
|
2463
|
-
}
|
|
2464
|
-
acceptInvitation({ invitation: options, deviceProfile }) {
|
|
2465
|
-
let invitation;
|
|
2466
|
-
if (deviceProfile) {
|
|
2467
|
-
(0, import_invariant7.invariant)(options.kind === import_services5.Invitation.Kind.DEVICE, "deviceProfile provided for non-device invitation", {
|
|
2468
|
-
F: __dxlog_file8,
|
|
2469
|
-
L: 127,
|
|
2470
|
-
S: this,
|
|
2471
|
-
A: [
|
|
2472
|
-
"options.kind === Invitation.Kind.DEVICE",
|
|
2473
|
-
"'deviceProfile provided for non-device invitation'"
|
|
2474
|
-
]
|
|
2475
|
-
});
|
|
2476
|
-
}
|
|
2477
|
-
const existingInvitation = this._acceptInvitations.get(options.invitationId);
|
|
2478
|
-
if (existingInvitation) {
|
|
2479
|
-
invitation = existingInvitation;
|
|
2480
|
-
} else {
|
|
2481
|
-
const handler = this._getHandler(options);
|
|
2482
|
-
invitation = this._invitationsHandler.acceptInvitation(handler, options, deviceProfile);
|
|
2483
|
-
this._acceptInvitations.set(invitation.get().invitationId, invitation);
|
|
2484
|
-
this._invitationAccepted.emit(invitation.get());
|
|
2485
|
-
}
|
|
2410
|
+
acceptInvitation(request) {
|
|
2411
|
+
const invitation = this._invitationsManager.acceptInvitation(request);
|
|
2486
2412
|
return new import_codec_protobuf8.Stream(({ next, close }) => {
|
|
2487
|
-
invitation.subscribe(
|
|
2488
|
-
next(invitation2);
|
|
2489
|
-
}, (err) => {
|
|
2490
|
-
close(err);
|
|
2491
|
-
}, () => {
|
|
2492
|
-
close();
|
|
2493
|
-
this._acceptInvitations.delete(invitation.get().invitationId);
|
|
2494
|
-
if (invitation.get().type !== import_services5.Invitation.Type.MULTIUSE) {
|
|
2495
|
-
this._removedAccepted.emit(invitation.get());
|
|
2496
|
-
}
|
|
2497
|
-
});
|
|
2413
|
+
invitation.subscribe(next, close, close);
|
|
2498
2414
|
});
|
|
2499
2415
|
}
|
|
2500
|
-
async authenticate(
|
|
2501
|
-
|
|
2502
|
-
F: __dxlog_file8,
|
|
2503
|
-
L: 160,
|
|
2504
|
-
S: this,
|
|
2505
|
-
C: (f, a) => f(...a)
|
|
2506
|
-
});
|
|
2507
|
-
(0, import_invariant7.invariant)(invitationId, void 0, {
|
|
2508
|
-
F: __dxlog_file8,
|
|
2509
|
-
L: 161,
|
|
2510
|
-
S: this,
|
|
2511
|
-
A: [
|
|
2512
|
-
"invitationId",
|
|
2513
|
-
""
|
|
2514
|
-
]
|
|
2515
|
-
});
|
|
2516
|
-
const observable = this._acceptInvitations.get(invitationId);
|
|
2517
|
-
if (!observable) {
|
|
2518
|
-
import_log6.log.warn("invalid invitation", {
|
|
2519
|
-
invitationId
|
|
2520
|
-
}, {
|
|
2521
|
-
F: __dxlog_file8,
|
|
2522
|
-
L: 164,
|
|
2523
|
-
S: this,
|
|
2524
|
-
C: (f, a) => f(...a)
|
|
2525
|
-
});
|
|
2526
|
-
} else {
|
|
2527
|
-
await observable.authenticate(authCode);
|
|
2528
|
-
}
|
|
2416
|
+
async authenticate(request) {
|
|
2417
|
+
return this._invitationsManager.authenticate(request);
|
|
2529
2418
|
}
|
|
2530
|
-
async cancelInvitation(
|
|
2531
|
-
|
|
2532
|
-
invitationId
|
|
2533
|
-
}, {
|
|
2534
|
-
F: __dxlog_file8,
|
|
2535
|
-
L: 171,
|
|
2536
|
-
S: this,
|
|
2537
|
-
C: (f, a) => f(...a)
|
|
2538
|
-
});
|
|
2539
|
-
(0, import_invariant7.invariant)(invitationId, void 0, {
|
|
2540
|
-
F: __dxlog_file8,
|
|
2541
|
-
L: 172,
|
|
2542
|
-
S: this,
|
|
2543
|
-
A: [
|
|
2544
|
-
"invitationId",
|
|
2545
|
-
""
|
|
2546
|
-
]
|
|
2547
|
-
});
|
|
2548
|
-
const created = this._createInvitations.get(invitationId);
|
|
2549
|
-
const accepted = this._acceptInvitations.get(invitationId);
|
|
2550
|
-
if (created) {
|
|
2551
|
-
await created.cancel();
|
|
2552
|
-
this._createInvitations.delete(invitationId);
|
|
2553
|
-
this._removedCreated.emit(created.get());
|
|
2554
|
-
if (created.get().persistent) {
|
|
2555
|
-
await this._metadataStore.removeInvitation(created.get().invitationId);
|
|
2556
|
-
}
|
|
2557
|
-
} else if (accepted) {
|
|
2558
|
-
await accepted.cancel();
|
|
2559
|
-
this._acceptInvitations.delete(invitationId);
|
|
2560
|
-
this._removedAccepted.emit(accepted.get());
|
|
2561
|
-
}
|
|
2419
|
+
async cancelInvitation(request) {
|
|
2420
|
+
return this._invitationsManager.cancelInvitation(request);
|
|
2562
2421
|
}
|
|
2563
2422
|
queryInvitations() {
|
|
2564
2423
|
return new import_codec_protobuf8.Stream(({ next, ctx }) => {
|
|
2565
|
-
this.
|
|
2424
|
+
this._invitationsManager.invitationCreated.on(ctx, (invitation) => {
|
|
2566
2425
|
next({
|
|
2567
2426
|
action: import_services5.QueryInvitationsResponse.Action.ADDED,
|
|
2568
2427
|
type: import_services5.QueryInvitationsResponse.Type.CREATED,
|
|
@@ -2571,7 +2430,7 @@ var InvitationsServiceImpl = class {
|
|
|
2571
2430
|
]
|
|
2572
2431
|
});
|
|
2573
2432
|
});
|
|
2574
|
-
this.
|
|
2433
|
+
this._invitationsManager.invitationAccepted.on(ctx, (invitation) => {
|
|
2575
2434
|
next({
|
|
2576
2435
|
action: import_services5.QueryInvitationsResponse.Action.ADDED,
|
|
2577
2436
|
type: import_services5.QueryInvitationsResponse.Type.ACCEPTED,
|
|
@@ -2580,7 +2439,7 @@ var InvitationsServiceImpl = class {
|
|
|
2580
2439
|
]
|
|
2581
2440
|
});
|
|
2582
2441
|
});
|
|
2583
|
-
this.
|
|
2442
|
+
this._invitationsManager.removedCreated.on(ctx, (invitation) => {
|
|
2584
2443
|
next({
|
|
2585
2444
|
action: import_services5.QueryInvitationsResponse.Action.REMOVED,
|
|
2586
2445
|
type: import_services5.QueryInvitationsResponse.Type.CREATED,
|
|
@@ -2589,7 +2448,7 @@ var InvitationsServiceImpl = class {
|
|
|
2589
2448
|
]
|
|
2590
2449
|
});
|
|
2591
2450
|
});
|
|
2592
|
-
this.
|
|
2451
|
+
this._invitationsManager.removedAccepted.on(ctx, (invitation) => {
|
|
2593
2452
|
next({
|
|
2594
2453
|
action: import_services5.QueryInvitationsResponse.Action.REMOVED,
|
|
2595
2454
|
type: import_services5.QueryInvitationsResponse.Type.ACCEPTED,
|
|
@@ -2598,7 +2457,7 @@ var InvitationsServiceImpl = class {
|
|
|
2598
2457
|
]
|
|
2599
2458
|
});
|
|
2600
2459
|
});
|
|
2601
|
-
this.
|
|
2460
|
+
this._invitationsManager.saved.on(ctx, (invitation) => {
|
|
2602
2461
|
next({
|
|
2603
2462
|
action: import_services5.QueryInvitationsResponse.Action.SAVED,
|
|
2604
2463
|
type: import_services5.QueryInvitationsResponse.Type.CREATED,
|
|
@@ -2610,32 +2469,25 @@ var InvitationsServiceImpl = class {
|
|
|
2610
2469
|
next({
|
|
2611
2470
|
action: import_services5.QueryInvitationsResponse.Action.ADDED,
|
|
2612
2471
|
type: import_services5.QueryInvitationsResponse.Type.CREATED,
|
|
2613
|
-
invitations:
|
|
2472
|
+
invitations: this._invitationsManager.getCreatedInvitations(),
|
|
2614
2473
|
existing: true
|
|
2615
2474
|
});
|
|
2616
2475
|
next({
|
|
2617
2476
|
action: import_services5.QueryInvitationsResponse.Action.ADDED,
|
|
2618
2477
|
type: import_services5.QueryInvitationsResponse.Type.ACCEPTED,
|
|
2619
|
-
invitations:
|
|
2478
|
+
invitations: this._invitationsManager.getAcceptedInvitations(),
|
|
2620
2479
|
existing: true
|
|
2621
2480
|
});
|
|
2622
|
-
|
|
2481
|
+
this._invitationsManager.onPersistentInvitationsLoaded(ctx, () => {
|
|
2623
2482
|
next({
|
|
2624
2483
|
action: import_services5.QueryInvitationsResponse.Action.LOAD_COMPLETE,
|
|
2625
2484
|
type: import_services5.QueryInvitationsResponse.Type.CREATED
|
|
2626
2485
|
});
|
|
2627
|
-
}
|
|
2628
|
-
this._persistentInvitationsLoadedEvent.on(ctx, () => {
|
|
2629
|
-
next({
|
|
2630
|
-
action: import_services5.QueryInvitationsResponse.Action.LOAD_COMPLETE,
|
|
2631
|
-
type: import_services5.QueryInvitationsResponse.Type.CREATED
|
|
2632
|
-
});
|
|
2633
|
-
});
|
|
2634
|
-
}
|
|
2486
|
+
});
|
|
2635
2487
|
});
|
|
2636
2488
|
}
|
|
2637
2489
|
};
|
|
2638
|
-
var
|
|
2490
|
+
var __dxlog_file8 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/space-invitation-protocol.ts";
|
|
2639
2491
|
var SpaceInvitationProtocol = class {
|
|
2640
2492
|
constructor(_spaceManager, _signingContext, _keyring, _spaceKey) {
|
|
2641
2493
|
this._spaceManager = _spaceManager;
|
|
@@ -2655,10 +2507,10 @@ var SpaceInvitationProtocol = class {
|
|
|
2655
2507
|
spaceKey: this._spaceKey
|
|
2656
2508
|
};
|
|
2657
2509
|
}
|
|
2658
|
-
async admit(request, guestProfile) {
|
|
2659
|
-
(0,
|
|
2660
|
-
F:
|
|
2661
|
-
L:
|
|
2510
|
+
async admit(invitation, request, guestProfile) {
|
|
2511
|
+
(0, import_invariant7.invariant)(this._spaceKey, void 0, {
|
|
2512
|
+
F: __dxlog_file8,
|
|
2513
|
+
L: 55,
|
|
2662
2514
|
S: this,
|
|
2663
2515
|
A: [
|
|
2664
2516
|
"this._spaceKey",
|
|
@@ -2666,18 +2518,18 @@ var SpaceInvitationProtocol = class {
|
|
|
2666
2518
|
]
|
|
2667
2519
|
});
|
|
2668
2520
|
const space = await this._spaceManager.spaces.get(this._spaceKey);
|
|
2669
|
-
(0,
|
|
2670
|
-
F:
|
|
2671
|
-
L:
|
|
2521
|
+
(0, import_invariant7.invariant)(space, void 0, {
|
|
2522
|
+
F: __dxlog_file8,
|
|
2523
|
+
L: 57,
|
|
2672
2524
|
S: this,
|
|
2673
2525
|
A: [
|
|
2674
2526
|
"space",
|
|
2675
2527
|
""
|
|
2676
2528
|
]
|
|
2677
2529
|
});
|
|
2678
|
-
(0,
|
|
2679
|
-
F:
|
|
2680
|
-
L:
|
|
2530
|
+
(0, import_invariant7.invariant)(request.space, void 0, {
|
|
2531
|
+
F: __dxlog_file8,
|
|
2532
|
+
L: 59,
|
|
2681
2533
|
S: this,
|
|
2682
2534
|
A: [
|
|
2683
2535
|
"request.space",
|
|
@@ -2685,19 +2537,19 @@ var SpaceInvitationProtocol = class {
|
|
|
2685
2537
|
]
|
|
2686
2538
|
});
|
|
2687
2539
|
const { identityKey, deviceKey } = request.space;
|
|
2688
|
-
(0,
|
|
2540
|
+
(0, import_log6.log)("writing guest credentials", {
|
|
2689
2541
|
host: this._signingContext.deviceKey,
|
|
2690
2542
|
guest: deviceKey
|
|
2691
2543
|
}, {
|
|
2692
|
-
F:
|
|
2693
|
-
L:
|
|
2544
|
+
F: __dxlog_file8,
|
|
2545
|
+
L: 62,
|
|
2694
2546
|
S: this,
|
|
2695
2547
|
C: (f, a) => f(...a)
|
|
2696
2548
|
});
|
|
2697
|
-
const credentials = await (0,
|
|
2698
|
-
(0,
|
|
2699
|
-
F:
|
|
2700
|
-
L:
|
|
2549
|
+
const credentials = await (0, import_credentials7.createAdmissionCredentials)(this._signingContext.credentialSigner, identityKey, space.key, space.inner.genesisFeedKey, guestProfile, invitation.delegationCredentialId);
|
|
2550
|
+
(0, import_invariant7.invariant)(credentials[0].credential, void 0, {
|
|
2551
|
+
F: __dxlog_file8,
|
|
2552
|
+
L: 74,
|
|
2701
2553
|
S: this,
|
|
2702
2554
|
A: [
|
|
2703
2555
|
"credentials[0].credential",
|
|
@@ -2705,9 +2557,9 @@ var SpaceInvitationProtocol = class {
|
|
|
2705
2557
|
]
|
|
2706
2558
|
});
|
|
2707
2559
|
const spaceMemberCredential = credentials[0].credential.credential;
|
|
2708
|
-
(0,
|
|
2709
|
-
F:
|
|
2710
|
-
L:
|
|
2560
|
+
(0, import_invariant7.invariant)((0, import_credentials7.getCredentialAssertion)(spaceMemberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
|
|
2561
|
+
F: __dxlog_file8,
|
|
2562
|
+
L: 76,
|
|
2711
2563
|
S: this,
|
|
2712
2564
|
A: [
|
|
2713
2565
|
"getCredentialAssertion(spaceMemberCredential)['@type'] === 'dxos.halo.credentials.SpaceMember'",
|
|
@@ -2722,6 +2574,69 @@ var SpaceInvitationProtocol = class {
|
|
|
2722
2574
|
}
|
|
2723
2575
|
};
|
|
2724
2576
|
}
|
|
2577
|
+
async delegate(invitation) {
|
|
2578
|
+
(0, import_invariant7.invariant)(this._spaceKey, void 0, {
|
|
2579
|
+
F: __dxlog_file8,
|
|
2580
|
+
L: 89,
|
|
2581
|
+
S: this,
|
|
2582
|
+
A: [
|
|
2583
|
+
"this._spaceKey",
|
|
2584
|
+
""
|
|
2585
|
+
]
|
|
2586
|
+
});
|
|
2587
|
+
const space = await this._spaceManager.spaces.get(this._spaceKey);
|
|
2588
|
+
(0, import_invariant7.invariant)(space, void 0, {
|
|
2589
|
+
F: __dxlog_file8,
|
|
2590
|
+
L: 91,
|
|
2591
|
+
S: this,
|
|
2592
|
+
A: [
|
|
2593
|
+
"space",
|
|
2594
|
+
""
|
|
2595
|
+
]
|
|
2596
|
+
});
|
|
2597
|
+
if (invitation.authMethod === import_services6.Invitation.AuthMethod.KNOWN_PUBLIC_KEY) {
|
|
2598
|
+
(0, import_invariant7.invariant)(invitation.guestKeypair?.publicKey, void 0, {
|
|
2599
|
+
F: __dxlog_file8,
|
|
2600
|
+
L: 93,
|
|
2601
|
+
S: this,
|
|
2602
|
+
A: [
|
|
2603
|
+
"invitation.guestKeypair?.publicKey",
|
|
2604
|
+
""
|
|
2605
|
+
]
|
|
2606
|
+
});
|
|
2607
|
+
}
|
|
2608
|
+
(0, import_log6.log)("writing delegate space invitation", {
|
|
2609
|
+
host: this._signingContext.deviceKey,
|
|
2610
|
+
id: invitation.invitationId
|
|
2611
|
+
}, {
|
|
2612
|
+
F: __dxlog_file8,
|
|
2613
|
+
L: 96,
|
|
2614
|
+
S: this,
|
|
2615
|
+
C: (f, a) => f(...a)
|
|
2616
|
+
});
|
|
2617
|
+
const credential = await (0, import_credentials7.createDelegatedSpaceInvitationCredential)(this._signingContext.credentialSigner, space.key, {
|
|
2618
|
+
invitationId: invitation.invitationId,
|
|
2619
|
+
authMethod: invitation.authMethod,
|
|
2620
|
+
swarmKey: invitation.swarmKey,
|
|
2621
|
+
role: import_credentials8.SpaceMember.Role.ADMIN,
|
|
2622
|
+
expiresOn: invitation.lifetime ? new Date((invitation.created?.getTime() ?? Date.now()) + invitation.lifetime) : void 0,
|
|
2623
|
+
multiUse: invitation.multiUse ?? false,
|
|
2624
|
+
guestKey: invitation.authMethod === import_services6.Invitation.AuthMethod.KNOWN_PUBLIC_KEY ? invitation.guestKeypair.publicKey : void 0
|
|
2625
|
+
});
|
|
2626
|
+
(0, import_invariant7.invariant)(credential.credential, void 0, {
|
|
2627
|
+
F: __dxlog_file8,
|
|
2628
|
+
L: 116,
|
|
2629
|
+
S: this,
|
|
2630
|
+
A: [
|
|
2631
|
+
"credential.credential",
|
|
2632
|
+
""
|
|
2633
|
+
]
|
|
2634
|
+
});
|
|
2635
|
+
await (0, import_feed_store3.writeMessages)(space.inner.controlPipeline.writer, [
|
|
2636
|
+
credential
|
|
2637
|
+
]);
|
|
2638
|
+
return credential.credential.credential.id;
|
|
2639
|
+
}
|
|
2725
2640
|
checkInvitation(invitation) {
|
|
2726
2641
|
if (invitation.spaceKey && this._spaceManager.spaces.has(invitation.spaceKey)) {
|
|
2727
2642
|
return new import_protocols6.AlreadyJoinedError("Already joined space.");
|
|
@@ -2745,9 +2660,9 @@ var SpaceInvitationProtocol = class {
|
|
|
2745
2660
|
};
|
|
2746
2661
|
}
|
|
2747
2662
|
async accept(response) {
|
|
2748
|
-
(0,
|
|
2749
|
-
F:
|
|
2750
|
-
L:
|
|
2663
|
+
(0, import_invariant7.invariant)(response.space, void 0, {
|
|
2664
|
+
F: __dxlog_file8,
|
|
2665
|
+
L: 149,
|
|
2751
2666
|
S: this,
|
|
2752
2667
|
A: [
|
|
2753
2668
|
"response.space",
|
|
@@ -2755,19 +2670,19 @@ var SpaceInvitationProtocol = class {
|
|
|
2755
2670
|
]
|
|
2756
2671
|
});
|
|
2757
2672
|
const { credential, controlTimeframe, dataTimeframe } = response.space;
|
|
2758
|
-
const assertion = (0,
|
|
2759
|
-
(0,
|
|
2760
|
-
F:
|
|
2761
|
-
L:
|
|
2673
|
+
const assertion = (0, import_credentials7.getCredentialAssertion)(credential);
|
|
2674
|
+
(0, import_invariant7.invariant)(assertion["@type"] === "dxos.halo.credentials.SpaceMember", "Invalid credential", {
|
|
2675
|
+
F: __dxlog_file8,
|
|
2676
|
+
L: 152,
|
|
2762
2677
|
S: this,
|
|
2763
2678
|
A: [
|
|
2764
2679
|
"assertion['@type'] === 'dxos.halo.credentials.SpaceMember'",
|
|
2765
2680
|
"'Invalid credential'"
|
|
2766
2681
|
]
|
|
2767
2682
|
});
|
|
2768
|
-
(0,
|
|
2769
|
-
F:
|
|
2770
|
-
L:
|
|
2683
|
+
(0, import_invariant7.invariant)(credential.subject.id.equals(this._signingContext.identityKey), void 0, {
|
|
2684
|
+
F: __dxlog_file8,
|
|
2685
|
+
L: 153,
|
|
2771
2686
|
S: this,
|
|
2772
2687
|
A: [
|
|
2773
2688
|
"credential.subject.id.equals(this._signingContext.identityKey)",
|
|
@@ -2789,6 +2704,284 @@ var SpaceInvitationProtocol = class {
|
|
|
2789
2704
|
};
|
|
2790
2705
|
}
|
|
2791
2706
|
};
|
|
2707
|
+
var __dxlog_file9 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitations-manager.ts";
|
|
2708
|
+
var InvitationsManager = class {
|
|
2709
|
+
constructor(_invitationsHandler, _getHandler, _metadataStore) {
|
|
2710
|
+
this._invitationsHandler = _invitationsHandler;
|
|
2711
|
+
this._getHandler = _getHandler;
|
|
2712
|
+
this._metadataStore = _metadataStore;
|
|
2713
|
+
this._createInvitations = /* @__PURE__ */ new Map();
|
|
2714
|
+
this._acceptInvitations = /* @__PURE__ */ new Map();
|
|
2715
|
+
this.invitationCreated = new import_async9.Event();
|
|
2716
|
+
this.invitationAccepted = new import_async9.Event();
|
|
2717
|
+
this.removedCreated = new import_async9.Event();
|
|
2718
|
+
this.removedAccepted = new import_async9.Event();
|
|
2719
|
+
this.saved = new import_async9.Event();
|
|
2720
|
+
this._persistentInvitationsLoadedEvent = new import_async9.Event();
|
|
2721
|
+
this._persistentInvitationsLoaded = false;
|
|
2722
|
+
}
|
|
2723
|
+
async createInvitation(options) {
|
|
2724
|
+
if (options.invitationId) {
|
|
2725
|
+
const existingInvitation = this._createInvitations.get(options.invitationId);
|
|
2726
|
+
if (existingInvitation) {
|
|
2727
|
+
return existingInvitation;
|
|
2728
|
+
}
|
|
2729
|
+
}
|
|
2730
|
+
const handler = this._getHandler(options);
|
|
2731
|
+
const invitation = this._createInvitation(handler, options);
|
|
2732
|
+
const { ctx, stream, observableInvitation } = this._createObservableInvitation(handler, invitation);
|
|
2733
|
+
this._createInvitations.set(invitation.invitationId, observableInvitation);
|
|
2734
|
+
this.invitationCreated.emit(invitation);
|
|
2735
|
+
this._onInvitationComplete(observableInvitation, async () => {
|
|
2736
|
+
this._createInvitations.delete(observableInvitation.get().invitationId);
|
|
2737
|
+
this.removedCreated.emit(observableInvitation.get());
|
|
2738
|
+
if (observableInvitation.get().persistent) {
|
|
2739
|
+
await this._safeDeleteInvitation(observableInvitation.get());
|
|
2740
|
+
}
|
|
2741
|
+
});
|
|
2742
|
+
try {
|
|
2743
|
+
await this._persistIfRequired(handler, stream, invitation);
|
|
2744
|
+
} catch (err) {
|
|
2745
|
+
import_log7.log.catch(err, void 0, {
|
|
2746
|
+
F: __dxlog_file9,
|
|
2747
|
+
L: 76,
|
|
2748
|
+
S: this,
|
|
2749
|
+
C: (f, a) => f(...a)
|
|
2750
|
+
});
|
|
2751
|
+
await observableInvitation.cancel();
|
|
2752
|
+
return observableInvitation;
|
|
2753
|
+
}
|
|
2754
|
+
this._invitationsHandler.handleInvitationFlow(ctx, stream, handler, observableInvitation.get());
|
|
2755
|
+
return observableInvitation;
|
|
2756
|
+
}
|
|
2757
|
+
async loadPersistentInvitations() {
|
|
2758
|
+
if (this._persistentInvitationsLoaded) {
|
|
2759
|
+
const invitations = this.getCreatedInvitations().filter((i) => i.persistent);
|
|
2760
|
+
return {
|
|
2761
|
+
invitations
|
|
2762
|
+
};
|
|
2763
|
+
}
|
|
2764
|
+
try {
|
|
2765
|
+
const persistentInvitations = this._metadataStore.getInvitations();
|
|
2766
|
+
const freshInvitations = persistentInvitations.filter((invitation) => !(0, import_echo_pipeline.hasInvitationExpired)(invitation));
|
|
2767
|
+
const loadTasks = freshInvitations.map((persistentInvitation) => {
|
|
2768
|
+
(0, import_invariant8.invariant)(!this._createInvitations.get(persistentInvitation.invitationId), "invitation already exists", {
|
|
2769
|
+
F: __dxlog_file9,
|
|
2770
|
+
L: 97,
|
|
2771
|
+
S: this,
|
|
2772
|
+
A: [
|
|
2773
|
+
"!this._createInvitations.get(persistentInvitation.invitationId)",
|
|
2774
|
+
"'invitation already exists'"
|
|
2775
|
+
]
|
|
2776
|
+
});
|
|
2777
|
+
return this.createInvitation({
|
|
2778
|
+
...persistentInvitation,
|
|
2779
|
+
persistent: false
|
|
2780
|
+
});
|
|
2781
|
+
});
|
|
2782
|
+
const cInvitations = await Promise.all(loadTasks);
|
|
2783
|
+
return {
|
|
2784
|
+
invitations: cInvitations.map((invitation) => invitation.get())
|
|
2785
|
+
};
|
|
2786
|
+
} catch (err) {
|
|
2787
|
+
import_log7.log.catch(err, void 0, {
|
|
2788
|
+
F: __dxlog_file9,
|
|
2789
|
+
L: 104,
|
|
2790
|
+
S: this,
|
|
2791
|
+
C: (f, a) => f(...a)
|
|
2792
|
+
});
|
|
2793
|
+
return {
|
|
2794
|
+
invitations: []
|
|
2795
|
+
};
|
|
2796
|
+
} finally {
|
|
2797
|
+
this._persistentInvitationsLoadedEvent.emit();
|
|
2798
|
+
this._persistentInvitationsLoaded = true;
|
|
2799
|
+
}
|
|
2800
|
+
}
|
|
2801
|
+
acceptInvitation(request) {
|
|
2802
|
+
const options = request.invitation;
|
|
2803
|
+
const existingInvitation = this._acceptInvitations.get(options.invitationId);
|
|
2804
|
+
if (existingInvitation) {
|
|
2805
|
+
return existingInvitation;
|
|
2806
|
+
}
|
|
2807
|
+
const handler = this._getHandler(options);
|
|
2808
|
+
const invitation = this._invitationsHandler.acceptInvitation(handler, options, request.deviceProfile);
|
|
2809
|
+
this._acceptInvitations.set(invitation.get().invitationId, invitation);
|
|
2810
|
+
this.invitationAccepted.emit(invitation.get());
|
|
2811
|
+
this._onInvitationComplete(invitation, () => {
|
|
2812
|
+
this._acceptInvitations.delete(invitation.get().invitationId);
|
|
2813
|
+
this.removedAccepted.emit(invitation.get());
|
|
2814
|
+
});
|
|
2815
|
+
return invitation;
|
|
2816
|
+
}
|
|
2817
|
+
async authenticate({ invitationId, authCode }) {
|
|
2818
|
+
(0, import_log7.log)("authenticating...", void 0, {
|
|
2819
|
+
F: __dxlog_file9,
|
|
2820
|
+
L: 133,
|
|
2821
|
+
S: this,
|
|
2822
|
+
C: (f, a) => f(...a)
|
|
2823
|
+
});
|
|
2824
|
+
(0, import_invariant8.invariant)(invitationId, void 0, {
|
|
2825
|
+
F: __dxlog_file9,
|
|
2826
|
+
L: 134,
|
|
2827
|
+
S: this,
|
|
2828
|
+
A: [
|
|
2829
|
+
"invitationId",
|
|
2830
|
+
""
|
|
2831
|
+
]
|
|
2832
|
+
});
|
|
2833
|
+
const observable = this._acceptInvitations.get(invitationId);
|
|
2834
|
+
if (!observable) {
|
|
2835
|
+
import_log7.log.warn("invalid invitation", {
|
|
2836
|
+
invitationId
|
|
2837
|
+
}, {
|
|
2838
|
+
F: __dxlog_file9,
|
|
2839
|
+
L: 137,
|
|
2840
|
+
S: this,
|
|
2841
|
+
C: (f, a) => f(...a)
|
|
2842
|
+
});
|
|
2843
|
+
} else {
|
|
2844
|
+
await observable.authenticate(authCode);
|
|
2845
|
+
}
|
|
2846
|
+
}
|
|
2847
|
+
async cancelInvitation({ invitationId }) {
|
|
2848
|
+
(0, import_log7.log)("cancelInvitation...", {
|
|
2849
|
+
invitationId
|
|
2850
|
+
}, {
|
|
2851
|
+
F: __dxlog_file9,
|
|
2852
|
+
L: 144,
|
|
2853
|
+
S: this,
|
|
2854
|
+
C: (f, a) => f(...a)
|
|
2855
|
+
});
|
|
2856
|
+
(0, import_invariant8.invariant)(invitationId, void 0, {
|
|
2857
|
+
F: __dxlog_file9,
|
|
2858
|
+
L: 145,
|
|
2859
|
+
S: this,
|
|
2860
|
+
A: [
|
|
2861
|
+
"invitationId",
|
|
2862
|
+
""
|
|
2863
|
+
]
|
|
2864
|
+
});
|
|
2865
|
+
const created = this._createInvitations.get(invitationId);
|
|
2866
|
+
if (created) {
|
|
2867
|
+
if (created.get().persistent) {
|
|
2868
|
+
await this._metadataStore.removeInvitation(invitationId);
|
|
2869
|
+
}
|
|
2870
|
+
await created.cancel();
|
|
2871
|
+
this._createInvitations.delete(invitationId);
|
|
2872
|
+
this.removedCreated.emit(created.get());
|
|
2873
|
+
return;
|
|
2874
|
+
}
|
|
2875
|
+
const accepted = this._acceptInvitations.get(invitationId);
|
|
2876
|
+
if (accepted) {
|
|
2877
|
+
await accepted.cancel();
|
|
2878
|
+
this._acceptInvitations.delete(invitationId);
|
|
2879
|
+
this.removedAccepted.emit(accepted.get());
|
|
2880
|
+
}
|
|
2881
|
+
}
|
|
2882
|
+
getCreatedInvitations() {
|
|
2883
|
+
return [
|
|
2884
|
+
...this._createInvitations.values()
|
|
2885
|
+
].map((i) => i.get());
|
|
2886
|
+
}
|
|
2887
|
+
getAcceptedInvitations() {
|
|
2888
|
+
return [
|
|
2889
|
+
...this._acceptInvitations.values()
|
|
2890
|
+
].map((i) => i.get());
|
|
2891
|
+
}
|
|
2892
|
+
onPersistentInvitationsLoaded(ctx, callback) {
|
|
2893
|
+
if (this._persistentInvitationsLoaded) {
|
|
2894
|
+
callback();
|
|
2895
|
+
} else {
|
|
2896
|
+
this._persistentInvitationsLoadedEvent.once(ctx, () => callback());
|
|
2897
|
+
}
|
|
2898
|
+
}
|
|
2899
|
+
_createInvitation(protocol, options) {
|
|
2900
|
+
const { invitationId = import_keys7.PublicKey.random().toHex(), type = import_services7.Invitation.Type.INTERACTIVE, authMethod = import_services7.Invitation.AuthMethod.SHARED_SECRET, state = import_services7.Invitation.State.INIT, timeout = import_client_protocol3.INVITATION_TIMEOUT, swarmKey = import_keys7.PublicKey.random(), persistent = options?.authMethod !== import_services7.Invitation.AuthMethod.KNOWN_PUBLIC_KEY, created = /* @__PURE__ */ new Date(), guestKeypair = void 0, lifetime = 86400, multiUse = false } = options ?? {};
|
|
2901
|
+
const authCode = options?.authCode ?? (authMethod === import_services7.Invitation.AuthMethod.SHARED_SECRET ? (0, import_credentials9.generatePasscode)(import_client_protocol3.AUTHENTICATION_CODE_LENGTH) : void 0);
|
|
2902
|
+
return {
|
|
2903
|
+
invitationId,
|
|
2904
|
+
type,
|
|
2905
|
+
authMethod,
|
|
2906
|
+
state,
|
|
2907
|
+
swarmKey,
|
|
2908
|
+
authCode,
|
|
2909
|
+
timeout,
|
|
2910
|
+
persistent: persistent && type !== import_services7.Invitation.Type.DELEGATED,
|
|
2911
|
+
guestKeypair: guestKeypair ?? (authMethod === import_services7.Invitation.AuthMethod.KNOWN_PUBLIC_KEY ? createAdmissionKeypair() : void 0),
|
|
2912
|
+
created,
|
|
2913
|
+
lifetime,
|
|
2914
|
+
multiUse,
|
|
2915
|
+
delegationCredentialId: options?.delegationCredentialId,
|
|
2916
|
+
...protocol.getInvitationContext()
|
|
2917
|
+
};
|
|
2918
|
+
}
|
|
2919
|
+
_createObservableInvitation(handler, invitation) {
|
|
2920
|
+
const stream = new import_async9.PushStream();
|
|
2921
|
+
const ctx = new import_context6.Context({
|
|
2922
|
+
onError: (err) => {
|
|
2923
|
+
stream.error(err);
|
|
2924
|
+
void ctx.dispose();
|
|
2925
|
+
}
|
|
2926
|
+
});
|
|
2927
|
+
ctx.onDispose(() => {
|
|
2928
|
+
(0, import_log7.log)("complete", {
|
|
2929
|
+
...handler.toJSON()
|
|
2930
|
+
}, {
|
|
2931
|
+
F: __dxlog_file9,
|
|
2932
|
+
L: 228,
|
|
2933
|
+
S: this,
|
|
2934
|
+
C: (f, a) => f(...a)
|
|
2935
|
+
});
|
|
2936
|
+
stream.complete();
|
|
2937
|
+
});
|
|
2938
|
+
const observableInvitation = new import_client_protocol3.CancellableInvitation({
|
|
2939
|
+
initialInvitation: invitation,
|
|
2940
|
+
subscriber: stream.observable,
|
|
2941
|
+
onCancel: async () => {
|
|
2942
|
+
stream.next({
|
|
2943
|
+
...invitation,
|
|
2944
|
+
state: import_services7.Invitation.State.CANCELLED
|
|
2945
|
+
});
|
|
2946
|
+
await ctx.dispose();
|
|
2947
|
+
}
|
|
2948
|
+
});
|
|
2949
|
+
return {
|
|
2950
|
+
ctx,
|
|
2951
|
+
stream,
|
|
2952
|
+
observableInvitation
|
|
2953
|
+
};
|
|
2954
|
+
}
|
|
2955
|
+
async _persistIfRequired(handler, changeStream, invitation) {
|
|
2956
|
+
if (invitation.type === import_services7.Invitation.Type.DELEGATED && invitation.delegationCredentialId == null) {
|
|
2957
|
+
const delegationCredentialId = await handler.delegate(invitation);
|
|
2958
|
+
changeStream.next({
|
|
2959
|
+
...invitation,
|
|
2960
|
+
delegationCredentialId
|
|
2961
|
+
});
|
|
2962
|
+
} else if (invitation.persistent) {
|
|
2963
|
+
await this._metadataStore.addInvitation(invitation);
|
|
2964
|
+
this.saved.emit(invitation);
|
|
2965
|
+
}
|
|
2966
|
+
}
|
|
2967
|
+
async _safeDeleteInvitation(invitation) {
|
|
2968
|
+
try {
|
|
2969
|
+
await this._metadataStore.removeInvitation(invitation.invitationId);
|
|
2970
|
+
} catch (err) {
|
|
2971
|
+
import_log7.log.catch(err, void 0, {
|
|
2972
|
+
F: __dxlog_file9,
|
|
2973
|
+
L: 260,
|
|
2974
|
+
S: this,
|
|
2975
|
+
C: (f, a) => f(...a)
|
|
2976
|
+
});
|
|
2977
|
+
}
|
|
2978
|
+
}
|
|
2979
|
+
_onInvitationComplete(invitation, callback) {
|
|
2980
|
+
invitation.subscribe(() => {
|
|
2981
|
+
}, () => {
|
|
2982
|
+
}, callback);
|
|
2983
|
+
}
|
|
2984
|
+
};
|
|
2792
2985
|
function _ts_decorate3(decorators, target, key, desc) {
|
|
2793
2986
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2794
2987
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
@@ -2836,169 +3029,34 @@ var ClientRpcServer = class {
|
|
|
2836
3029
|
}
|
|
2837
3030
|
get _services() {
|
|
2838
3031
|
return Object.keys(this._serviceRegistry.services);
|
|
2839
|
-
}
|
|
2840
|
-
async open() {
|
|
2841
|
-
await this._rpcPeer.open();
|
|
2842
|
-
}
|
|
2843
|
-
async close() {
|
|
2844
|
-
await this._rpcPeer.close();
|
|
2845
|
-
}
|
|
2846
|
-
_getServiceHandler(serviceName) {
|
|
2847
|
-
if (!this._handlerCache.has(serviceName)) {
|
|
2848
|
-
const [key, descriptor] = Object.entries(this._serviceRegistry.descriptors).find(([key2, descriptor2]) => descriptor2.name === serviceName) ?? (0, import_debug2.raise)(new Error(`Service not available: ${serviceName}`));
|
|
2849
|
-
const service = this._serviceRegistry.services[key];
|
|
2850
|
-
if (!service) {
|
|
2851
|
-
throw new Error(`Service not available: ${serviceName}`);
|
|
2852
|
-
}
|
|
2853
|
-
this._handlerCache.set(serviceName, descriptor.createServer(service));
|
|
2854
|
-
}
|
|
2855
|
-
return this._handlerCache.get(serviceName);
|
|
2856
|
-
}
|
|
2857
|
-
};
|
|
2858
|
-
_ts_decorate3([
|
|
2859
|
-
import_tracing3.trace.metricsCounter()
|
|
2860
|
-
], ClientRpcServer.prototype, "_callMetrics", void 0);
|
|
2861
|
-
_ts_decorate3([
|
|
2862
|
-
import_tracing3.trace.info()
|
|
2863
|
-
], ClientRpcServer.prototype, "_services", null);
|
|
2864
|
-
ClientRpcServer = _ts_decorate3([
|
|
2865
|
-
import_tracing3.trace.resource()
|
|
2866
|
-
], ClientRpcServer);
|
|
2867
|
-
var getPlatform = () => {
|
|
2868
|
-
if (process.browser) {
|
|
2869
|
-
if (typeof window !== "undefined") {
|
|
2870
|
-
const { userAgent } = window.navigator;
|
|
2871
|
-
return {
|
|
2872
|
-
type: import_services8.Platform.PLATFORM_TYPE.BROWSER,
|
|
2873
|
-
userAgent,
|
|
2874
|
-
uptime: Math.floor((Date.now() - window.performance.timeOrigin) / 1e3)
|
|
2875
|
-
};
|
|
2876
|
-
} else {
|
|
2877
|
-
return {
|
|
2878
|
-
type: import_services8.Platform.PLATFORM_TYPE.SHARED_WORKER,
|
|
2879
|
-
uptime: Math.floor((Date.now() - performance.timeOrigin) / 1e3)
|
|
2880
|
-
};
|
|
2881
|
-
}
|
|
2882
|
-
} else {
|
|
2883
|
-
const { platform: platform2, version, arch } = process;
|
|
2884
|
-
return {
|
|
2885
|
-
type: import_services8.Platform.PLATFORM_TYPE.NODE,
|
|
2886
|
-
platform: platform2,
|
|
2887
|
-
arch,
|
|
2888
|
-
runtime: version,
|
|
2889
|
-
uptime: Math.floor(process.uptime()),
|
|
2890
|
-
memory: process.memoryUsage()
|
|
2891
|
-
};
|
|
2892
|
-
}
|
|
2893
|
-
};
|
|
2894
|
-
var DXOS_VERSION = "0.4.10-main.35cfb0c";
|
|
2895
|
-
var __dxlog_file10 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/diagnostics.ts";
|
|
2896
|
-
var DEFAULT_TIMEOUT = 1e3;
|
|
2897
|
-
var createDiagnostics = async (clientServices, serviceContext, config) => {
|
|
2898
|
-
const diagnostics = {
|
|
2899
|
-
created: (/* @__PURE__ */ new Date()).toISOString(),
|
|
2900
|
-
platform: getPlatform(),
|
|
2901
|
-
client: {
|
|
2902
|
-
version: DXOS_VERSION,
|
|
2903
|
-
storage: {
|
|
2904
|
-
version: import_protocols7.STORAGE_VERSION
|
|
2905
|
-
}
|
|
2906
|
-
},
|
|
2907
|
-
trace: import_tracing4.TRACE_PROCESSOR.getDiagnostics()
|
|
2908
|
-
};
|
|
2909
|
-
{
|
|
2910
|
-
(0, import_invariant9.invariant)(clientServices.LoggingService, "SystemService is not available.", {
|
|
2911
|
-
F: __dxlog_file10,
|
|
2912
|
-
L: 108,
|
|
2913
|
-
S: void 0,
|
|
2914
|
-
A: [
|
|
2915
|
-
"clientServices.LoggingService",
|
|
2916
|
-
"'SystemService is not available.'"
|
|
2917
|
-
]
|
|
2918
|
-
});
|
|
2919
|
-
diagnostics.metrics = await (0, import_codec_protobuf10.getFirstStreamValue)(clientServices.LoggingService.queryMetrics({}), {
|
|
2920
|
-
timeout: DEFAULT_TIMEOUT
|
|
2921
|
-
}).catch(() => void 0);
|
|
2922
|
-
}
|
|
2923
|
-
if (typeof navigator !== "undefined" && navigator.storage) {
|
|
2924
|
-
const map = /* @__PURE__ */ new Map();
|
|
2925
|
-
const dir = await navigator.storage.getDirectory();
|
|
2926
|
-
for await (const filename of dir?.keys()) {
|
|
2927
|
-
const idx = filename.indexOf("-", filename.indexOf("-") + 1);
|
|
2928
|
-
if (idx === -1) {
|
|
2929
|
-
continue;
|
|
2930
|
-
}
|
|
2931
|
-
map.set(filename.slice(0, idx), (map.get(filename.slice(0, idx)) ?? 0) + 1);
|
|
2932
|
-
}
|
|
2933
|
-
diagnostics.storage = Array.from(map.entries()).sort((a, b) => b[1] - a[1]).map(([file, count]) => ({
|
|
2934
|
-
file,
|
|
2935
|
-
count
|
|
2936
|
-
}));
|
|
2937
|
-
}
|
|
2938
|
-
const identity = serviceContext.identityManager.identity;
|
|
2939
|
-
if (identity) {
|
|
2940
|
-
diagnostics.identity = {
|
|
2941
|
-
identityKey: identity.identityKey,
|
|
2942
|
-
spaceKey: identity.space.key,
|
|
2943
|
-
profile: identity.profileDocument
|
|
2944
|
-
};
|
|
2945
|
-
const { devices } = await (0, import_codec_protobuf10.getFirstStreamValue)(clientServices.DevicesService.queryDevices(), {
|
|
2946
|
-
timeout: DEFAULT_TIMEOUT
|
|
2947
|
-
}).catch(() => void 0) ?? {};
|
|
2948
|
-
diagnostics.devices = devices;
|
|
2949
|
-
if (serviceContext.dataSpaceManager) {
|
|
2950
|
-
diagnostics.spaces = await Promise.all(Array.from(serviceContext.dataSpaceManager.spaces.values()).map((space) => getSpaceStats(space)) ?? []);
|
|
2951
|
-
}
|
|
2952
|
-
const { feeds = [] } = await (0, import_codec_protobuf10.getFirstStreamValue)(clientServices.DevtoolsHost.subscribeToFeeds({}), {
|
|
2953
|
-
timeout: DEFAULT_TIMEOUT
|
|
2954
|
-
}).catch(() => void 0) ?? {};
|
|
2955
|
-
diagnostics.feeds = feeds.map(({ feedKey, bytes, length }) => ({
|
|
2956
|
-
feedKey,
|
|
2957
|
-
bytes,
|
|
2958
|
-
length
|
|
2959
|
-
}));
|
|
2960
|
-
const status = await (0, import_codec_protobuf10.getFirstStreamValue)(clientServices.NetworkService.queryStatus(), {
|
|
2961
|
-
timeout: DEFAULT_TIMEOUT
|
|
2962
|
-
}).catch(() => void 0);
|
|
2963
|
-
diagnostics.networkStatus = status;
|
|
2964
|
-
diagnostics.swarms = serviceContext.networkManager.connectionLog?.swarms;
|
|
2965
|
-
}
|
|
2966
|
-
diagnostics.config = config.values;
|
|
2967
|
-
return diagnostics;
|
|
2968
|
-
};
|
|
2969
|
-
var getSpaceStats = async (space) => {
|
|
2970
|
-
const stats = {
|
|
2971
|
-
key: space.key,
|
|
2972
|
-
metrics: space.metrics,
|
|
2973
|
-
epochs: space.inner.spaceState.credentials.filter((0, import_credentials9.credentialTypeFilter)("dxos.halo.credentials.Epoch")).map((credential) => ({
|
|
2974
|
-
...credential.subject.assertion,
|
|
2975
|
-
id: credential.id
|
|
2976
|
-
})),
|
|
2977
|
-
members: Array.from(space.inner.spaceState.members.values()).map((member) => ({
|
|
2978
|
-
identity: {
|
|
2979
|
-
identityKey: member.key,
|
|
2980
|
-
profile: {
|
|
2981
|
-
displayName: member.assertion.profile?.displayName
|
|
2982
|
-
}
|
|
2983
|
-
},
|
|
2984
|
-
presence: space.presence.getPeersOnline().filter(({ identityKey }) => identityKey.equals(member.key)).length > 0 ? import_services7.SpaceMember.PresenceState.ONLINE : import_services7.SpaceMember.PresenceState.OFFLINE
|
|
2985
|
-
})),
|
|
2986
|
-
pipeline: {
|
|
2987
|
-
// TODO(burdon): Pick properties from credentials if needed.
|
|
2988
|
-
currentEpoch: space.automergeSpaceState.lastEpoch,
|
|
2989
|
-
appliedEpoch: space.automergeSpaceState.lastEpoch,
|
|
2990
|
-
controlFeeds: space.inner.controlPipeline.state.feeds.map((feed) => feed.key),
|
|
2991
|
-
currentControlTimeframe: space.inner.controlPipeline.state.timeframe,
|
|
2992
|
-
targetControlTimeframe: space.inner.controlPipeline.state.targetTimeframe,
|
|
2993
|
-
totalControlTimeframe: space.inner.controlPipeline.state.endTimeframe
|
|
3032
|
+
}
|
|
3033
|
+
async open() {
|
|
3034
|
+
await this._rpcPeer.open();
|
|
3035
|
+
}
|
|
3036
|
+
async close() {
|
|
3037
|
+
await this._rpcPeer.close();
|
|
3038
|
+
}
|
|
3039
|
+
_getServiceHandler(serviceName) {
|
|
3040
|
+
if (!this._handlerCache.has(serviceName)) {
|
|
3041
|
+
const [key, descriptor] = Object.entries(this._serviceRegistry.descriptors).find(([key2, descriptor2]) => descriptor2.name === serviceName) ?? (0, import_debug2.raise)(new Error(`Service not available: ${serviceName}`));
|
|
3042
|
+
const service = this._serviceRegistry.services[key];
|
|
3043
|
+
if (!service) {
|
|
3044
|
+
throw new Error(`Service not available: ${serviceName}`);
|
|
3045
|
+
}
|
|
3046
|
+
this._handlerCache.set(serviceName, descriptor.createServer(service));
|
|
2994
3047
|
}
|
|
2995
|
-
|
|
2996
|
-
if (stats.metrics) {
|
|
2997
|
-
const { open, ready } = stats.metrics;
|
|
2998
|
-
stats.metrics.startupTime = open && ready && ready.getTime() - open.getTime();
|
|
3048
|
+
return this._handlerCache.get(serviceName);
|
|
2999
3049
|
}
|
|
3000
|
-
return stats;
|
|
3001
3050
|
};
|
|
3051
|
+
_ts_decorate3([
|
|
3052
|
+
import_tracing3.trace.metricsCounter()
|
|
3053
|
+
], ClientRpcServer.prototype, "_callMetrics", void 0);
|
|
3054
|
+
_ts_decorate3([
|
|
3055
|
+
import_tracing3.trace.info()
|
|
3056
|
+
], ClientRpcServer.prototype, "_services", null);
|
|
3057
|
+
ClientRpcServer = _ts_decorate3([
|
|
3058
|
+
import_tracing3.trace.resource()
|
|
3059
|
+
], ClientRpcServer);
|
|
3002
3060
|
var AutomergeSpaceState = class {
|
|
3003
3061
|
constructor(_onNewRoot) {
|
|
3004
3062
|
this._onNewRoot = _onNewRoot;
|
|
@@ -3033,7 +3091,7 @@ var AutomergeSpaceState = class {
|
|
|
3033
3091
|
await this.onNewEpoch.waitForCondition(() => !!this.lastEpoch);
|
|
3034
3092
|
}
|
|
3035
3093
|
};
|
|
3036
|
-
var
|
|
3094
|
+
var __dxlog_file10 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/notarization-plugin.ts";
|
|
3037
3095
|
var DEFAULT_RETRY_TIMEOUT = 1e3;
|
|
3038
3096
|
var DEFAULT_SUCCESS_DELAY = 1e3;
|
|
3039
3097
|
var DEFAULT_NOTARIZE_TIMEOUT = 1e4;
|
|
@@ -3043,8 +3101,8 @@ var NotarizationPlugin = class {
|
|
|
3043
3101
|
this._ctx = new import_context8.Context();
|
|
3044
3102
|
this._extensionOpened = new import_async12.Event();
|
|
3045
3103
|
this._extensions = /* @__PURE__ */ new Set();
|
|
3046
|
-
this._processedCredentials = new import_util5.ComplexSet(
|
|
3047
|
-
this._processCredentialsTriggers = new import_util5.ComplexMap(
|
|
3104
|
+
this._processedCredentials = new import_util5.ComplexSet(import_keys9.PublicKey.hash);
|
|
3105
|
+
this._processCredentialsTriggers = new import_util5.ComplexMap(import_keys9.PublicKey.hash);
|
|
3048
3106
|
}
|
|
3049
3107
|
get hasWriter() {
|
|
3050
3108
|
return !!this._writer;
|
|
@@ -3061,13 +3119,13 @@ var NotarizationPlugin = class {
|
|
|
3061
3119
|
(0, import_log9.log)("notarize", {
|
|
3062
3120
|
credentials
|
|
3063
3121
|
}, {
|
|
3064
|
-
F:
|
|
3122
|
+
F: __dxlog_file10,
|
|
3065
3123
|
L: 90,
|
|
3066
3124
|
S: this,
|
|
3067
3125
|
C: (f, a) => f(...a)
|
|
3068
3126
|
});
|
|
3069
|
-
(0,
|
|
3070
|
-
F:
|
|
3127
|
+
(0, import_invariant10.invariant)(credentials.every((credential) => credential.id), "Credentials must have an id", {
|
|
3128
|
+
F: __dxlog_file10,
|
|
3071
3129
|
L: 91,
|
|
3072
3130
|
S: this,
|
|
3073
3131
|
A: [
|
|
@@ -3081,7 +3139,7 @@ var NotarizationPlugin = class {
|
|
|
3081
3139
|
import_log9.log.warn("Notarization error", {
|
|
3082
3140
|
err
|
|
3083
3141
|
}, {
|
|
3084
|
-
F:
|
|
3142
|
+
F: __dxlog_file10,
|
|
3085
3143
|
L: 99,
|
|
3086
3144
|
S: this,
|
|
3087
3145
|
C: (f, a) => f(...a)
|
|
@@ -3097,7 +3155,7 @@ var NotarizationPlugin = class {
|
|
|
3097
3155
|
timeout,
|
|
3098
3156
|
peers: Array.from(this._extensions).map((extension) => extension.remotePeerId)
|
|
3099
3157
|
}, {
|
|
3100
|
-
F:
|
|
3158
|
+
F: __dxlog_file10,
|
|
3101
3159
|
L: 111,
|
|
3102
3160
|
S: this,
|
|
3103
3161
|
C: (f, a) => f(...a)
|
|
@@ -3120,7 +3178,7 @@ var NotarizationPlugin = class {
|
|
|
3120
3178
|
import_log9.log.info("Exhausted all peers to notarize with", {
|
|
3121
3179
|
retryIn: retryTimeout
|
|
3122
3180
|
}, {
|
|
3123
|
-
F:
|
|
3181
|
+
F: __dxlog_file10,
|
|
3124
3182
|
L: 136,
|
|
3125
3183
|
S: this,
|
|
3126
3184
|
C: (f, a) => f(...a)
|
|
@@ -3134,7 +3192,7 @@ var NotarizationPlugin = class {
|
|
|
3134
3192
|
peer: peer.localPeerId,
|
|
3135
3193
|
credentialId: credentials.map((credential) => credential.id)
|
|
3136
3194
|
}, {
|
|
3137
|
-
F:
|
|
3195
|
+
F: __dxlog_file10,
|
|
3138
3196
|
L: 143,
|
|
3139
3197
|
S: this,
|
|
3140
3198
|
C: (f, a) => f(...a)
|
|
@@ -3143,7 +3201,7 @@ var NotarizationPlugin = class {
|
|
|
3143
3201
|
credentials: credentials.filter((credential) => !this._processedCredentials.has(credential.id))
|
|
3144
3202
|
});
|
|
3145
3203
|
(0, import_log9.log)("success", void 0, {
|
|
3146
|
-
F:
|
|
3204
|
+
F: __dxlog_file10,
|
|
3147
3205
|
L: 147,
|
|
3148
3206
|
S: this,
|
|
3149
3207
|
C: (f, a) => f(...a)
|
|
@@ -3152,7 +3210,7 @@ var NotarizationPlugin = class {
|
|
|
3152
3210
|
} catch (err) {
|
|
3153
3211
|
if (!ctx.disposed && !err.message.includes(WRITER_NOT_SET_ERROR_CODE)) {
|
|
3154
3212
|
import_log9.log.info("error notarizing (recoverable)", err, {
|
|
3155
|
-
F:
|
|
3213
|
+
F: __dxlog_file10,
|
|
3156
3214
|
L: 151,
|
|
3157
3215
|
S: this,
|
|
3158
3216
|
C: (f, a) => f(...a)
|
|
@@ -3170,7 +3228,7 @@ var NotarizationPlugin = class {
|
|
|
3170
3228
|
errors.wait()
|
|
3171
3229
|
]);
|
|
3172
3230
|
(0, import_log9.log)("done", void 0, {
|
|
3173
|
-
F:
|
|
3231
|
+
F: __dxlog_file10,
|
|
3174
3232
|
L: 162,
|
|
3175
3233
|
S: this,
|
|
3176
3234
|
C: (f, a) => f(...a)
|
|
@@ -3191,8 +3249,8 @@ var NotarizationPlugin = class {
|
|
|
3191
3249
|
this._processCredentialsTriggers.delete(credential.id);
|
|
3192
3250
|
}
|
|
3193
3251
|
setWriter(writer) {
|
|
3194
|
-
(0,
|
|
3195
|
-
F:
|
|
3252
|
+
(0, import_invariant10.invariant)(!this._writer, "Writer already set.", {
|
|
3253
|
+
F: __dxlog_file10,
|
|
3196
3254
|
L: 181,
|
|
3197
3255
|
S: this,
|
|
3198
3256
|
A: [
|
|
@@ -3216,8 +3274,8 @@ var NotarizationPlugin = class {
|
|
|
3216
3274
|
throw new Error(WRITER_NOT_SET_ERROR_CODE);
|
|
3217
3275
|
}
|
|
3218
3276
|
for (const credential of request.credentials ?? []) {
|
|
3219
|
-
(0,
|
|
3220
|
-
F:
|
|
3277
|
+
(0, import_invariant10.invariant)(credential.id, "Credential must have an id", {
|
|
3278
|
+
F: __dxlog_file10,
|
|
3221
3279
|
L: 200,
|
|
3222
3280
|
S: this,
|
|
3223
3281
|
A: [
|
|
@@ -3237,7 +3295,7 @@ var NotarizationPlugin = class {
|
|
|
3237
3295
|
(0, import_log9.log)("extension opened", {
|
|
3238
3296
|
peer: extension.localPeerId
|
|
3239
3297
|
}, {
|
|
3240
|
-
F:
|
|
3298
|
+
F: __dxlog_file10,
|
|
3241
3299
|
L: 211,
|
|
3242
3300
|
S: this,
|
|
3243
3301
|
C: (f, a) => f(...a)
|
|
@@ -3249,7 +3307,7 @@ var NotarizationPlugin = class {
|
|
|
3249
3307
|
(0, import_log9.log)("extension closed", {
|
|
3250
3308
|
peer: extension.localPeerId
|
|
3251
3309
|
}, {
|
|
3252
|
-
F:
|
|
3310
|
+
F: __dxlog_file10,
|
|
3253
3311
|
L: 216,
|
|
3254
3312
|
S: this,
|
|
3255
3313
|
C: (f, a) => f(...a)
|
|
@@ -3265,10 +3323,10 @@ var NotarizationTeleportExtension = class extends import_teleport2.RpcExtension
|
|
|
3265
3323
|
constructor(_params) {
|
|
3266
3324
|
super({
|
|
3267
3325
|
requested: {
|
|
3268
|
-
NotarizationService:
|
|
3326
|
+
NotarizationService: import_protocols8.schema.getService("dxos.mesh.teleport.notarization.NotarizationService")
|
|
3269
3327
|
},
|
|
3270
3328
|
exposed: {
|
|
3271
|
-
NotarizationService:
|
|
3329
|
+
NotarizationService: import_protocols8.schema.getService("dxos.mesh.teleport.notarization.NotarizationService")
|
|
3272
3330
|
}
|
|
3273
3331
|
});
|
|
3274
3332
|
this._params = _params;
|
|
@@ -3301,14 +3359,14 @@ function _ts_decorate4(decorators, target, key, desc) {
|
|
|
3301
3359
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
3302
3360
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3303
3361
|
}
|
|
3304
|
-
var
|
|
3362
|
+
var __dxlog_file11 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space.ts";
|
|
3305
3363
|
var DataSpace = class {
|
|
3306
3364
|
constructor(params) {
|
|
3307
3365
|
this._ctx = new import_context7.Context();
|
|
3308
3366
|
this._notarizationPlugin = new NotarizationPlugin();
|
|
3309
3367
|
this._cache = void 0;
|
|
3310
3368
|
this._automergeSpaceState = new AutomergeSpaceState((rootUrl) => this._onNewAutomergeRoot(rootUrl));
|
|
3311
|
-
this._state =
|
|
3369
|
+
this._state = import_services8.SpaceState.CLOSED;
|
|
3312
3370
|
this.error = void 0;
|
|
3313
3371
|
this.stateUpdate = new import_async10.Event();
|
|
3314
3372
|
this.metrics = {};
|
|
@@ -3321,19 +3379,19 @@ var DataSpace = class {
|
|
|
3321
3379
|
this._metadataStore = params.metadataStore;
|
|
3322
3380
|
this._signingContext = params.signingContext;
|
|
3323
3381
|
this._callbacks = params.callbacks ?? {};
|
|
3324
|
-
this.
|
|
3382
|
+
this._echoHost = params.echoHost;
|
|
3325
3383
|
this.authVerifier = new TrustedKeySetAuthVerifier({
|
|
3326
|
-
trustedKeysProvider: () => new import_util4.ComplexSet(
|
|
3384
|
+
trustedKeysProvider: () => new import_util4.ComplexSet(import_keys8.PublicKey.hash, Array.from(this._inner.spaceState.members.values()).filter((member) => !member.removed).map((member) => member.key)),
|
|
3327
3385
|
update: this._inner.stateUpdate,
|
|
3328
|
-
authTimeout:
|
|
3386
|
+
authTimeout: import_client_protocol4.AUTH_TIMEOUT
|
|
3329
3387
|
});
|
|
3330
3388
|
this._cache = params.cache;
|
|
3331
3389
|
this._state = params.initialState;
|
|
3332
3390
|
(0, import_log8.log)("new state", {
|
|
3333
|
-
state:
|
|
3391
|
+
state: import_services8.SpaceState[this._state]
|
|
3334
3392
|
}, {
|
|
3335
|
-
F:
|
|
3336
|
-
L:
|
|
3393
|
+
F: __dxlog_file11,
|
|
3394
|
+
L: 135,
|
|
3337
3395
|
S: this,
|
|
3338
3396
|
C: (f, a) => f(...a)
|
|
3339
3397
|
});
|
|
@@ -3378,12 +3436,12 @@ var DataSpace = class {
|
|
|
3378
3436
|
await this._inner.spaceState.addCredentialProcessor(this._notarizationPlugin);
|
|
3379
3437
|
await this._inner.spaceState.addCredentialProcessor(this._automergeSpaceState);
|
|
3380
3438
|
await this._inner.open(new import_context7.Context());
|
|
3381
|
-
this._state =
|
|
3439
|
+
this._state = import_services8.SpaceState.CONTROL_ONLY;
|
|
3382
3440
|
(0, import_log8.log)("new state", {
|
|
3383
|
-
state:
|
|
3441
|
+
state: import_services8.SpaceState[this._state]
|
|
3384
3442
|
}, {
|
|
3385
|
-
F:
|
|
3386
|
-
L:
|
|
3443
|
+
F: __dxlog_file11,
|
|
3444
|
+
L: 193,
|
|
3387
3445
|
S: this,
|
|
3388
3446
|
C: (f, a) => f(...a)
|
|
3389
3447
|
});
|
|
@@ -3396,12 +3454,12 @@ var DataSpace = class {
|
|
|
3396
3454
|
}
|
|
3397
3455
|
async _close() {
|
|
3398
3456
|
await this._callbacks.beforeClose?.();
|
|
3399
|
-
this._state =
|
|
3457
|
+
this._state = import_services8.SpaceState.CLOSED;
|
|
3400
3458
|
(0, import_log8.log)("new state", {
|
|
3401
|
-
state:
|
|
3459
|
+
state: import_services8.SpaceState[this._state]
|
|
3402
3460
|
}, {
|
|
3403
|
-
F:
|
|
3404
|
-
L:
|
|
3461
|
+
F: __dxlog_file11,
|
|
3462
|
+
L: 207,
|
|
3405
3463
|
S: this,
|
|
3406
3464
|
C: (f, a) => f(...a)
|
|
3407
3465
|
});
|
|
@@ -3430,27 +3488,27 @@ var DataSpace = class {
|
|
|
3430
3488
|
this.metrics.pipelineInitBegin = /* @__PURE__ */ new Date();
|
|
3431
3489
|
await this.initializeDataPipeline();
|
|
3432
3490
|
} catch (err) {
|
|
3433
|
-
if (err instanceof
|
|
3491
|
+
if (err instanceof import_protocols7.CancelledError || err instanceof import_context7.ContextDisposedError) {
|
|
3434
3492
|
(0, import_log8.log)("data pipeline initialization cancelled", err, {
|
|
3435
|
-
F:
|
|
3436
|
-
L:
|
|
3493
|
+
F: __dxlog_file11,
|
|
3494
|
+
L: 240,
|
|
3437
3495
|
S: this,
|
|
3438
3496
|
C: (f, a) => f(...a)
|
|
3439
3497
|
});
|
|
3440
3498
|
return;
|
|
3441
3499
|
}
|
|
3442
3500
|
import_log8.log.error("Error initializing data pipeline", err, {
|
|
3443
|
-
F:
|
|
3444
|
-
L:
|
|
3501
|
+
F: __dxlog_file11,
|
|
3502
|
+
L: 244,
|
|
3445
3503
|
S: this,
|
|
3446
3504
|
C: (f, a) => f(...a)
|
|
3447
3505
|
});
|
|
3448
|
-
this._state =
|
|
3506
|
+
this._state = import_services8.SpaceState.ERROR;
|
|
3449
3507
|
(0, import_log8.log)("new state", {
|
|
3450
|
-
state:
|
|
3508
|
+
state: import_services8.SpaceState[this._state]
|
|
3451
3509
|
}, {
|
|
3452
|
-
F:
|
|
3453
|
-
L:
|
|
3510
|
+
F: __dxlog_file11,
|
|
3511
|
+
L: 246,
|
|
3454
3512
|
S: this,
|
|
3455
3513
|
C: (f, a) => f(...a)
|
|
3456
3514
|
});
|
|
@@ -3462,15 +3520,15 @@ var DataSpace = class {
|
|
|
3462
3520
|
});
|
|
3463
3521
|
}
|
|
3464
3522
|
async initializeDataPipeline() {
|
|
3465
|
-
if (this._state !==
|
|
3466
|
-
throw new
|
|
3523
|
+
if (this._state !== import_services8.SpaceState.CONTROL_ONLY) {
|
|
3524
|
+
throw new import_protocols7.SystemError("Invalid operation");
|
|
3467
3525
|
}
|
|
3468
|
-
this._state =
|
|
3526
|
+
this._state = import_services8.SpaceState.INITIALIZING;
|
|
3469
3527
|
(0, import_log8.log)("new state", {
|
|
3470
|
-
state:
|
|
3528
|
+
state: import_services8.SpaceState[this._state]
|
|
3471
3529
|
}, {
|
|
3472
|
-
F:
|
|
3473
|
-
L:
|
|
3530
|
+
F: __dxlog_file11,
|
|
3531
|
+
L: 262,
|
|
3474
3532
|
S: this,
|
|
3475
3533
|
C: (f, a) => f(...a)
|
|
3476
3534
|
});
|
|
@@ -3479,18 +3537,18 @@ var DataSpace = class {
|
|
|
3479
3537
|
this._automergeSpaceState.startProcessingRootDocs();
|
|
3480
3538
|
await (0, import_context7.cancelWithContext)(this._ctx, this.automergeSpaceState.ensureEpochInitialized());
|
|
3481
3539
|
(0, import_log8.log)("data pipeline ready", void 0, {
|
|
3482
|
-
F:
|
|
3483
|
-
L:
|
|
3540
|
+
F: __dxlog_file11,
|
|
3541
|
+
L: 274,
|
|
3484
3542
|
S: this,
|
|
3485
3543
|
C: (f, a) => f(...a)
|
|
3486
3544
|
});
|
|
3487
3545
|
await this._callbacks.beforeReady?.();
|
|
3488
|
-
this._state =
|
|
3546
|
+
this._state = import_services8.SpaceState.READY;
|
|
3489
3547
|
(0, import_log8.log)("new state", {
|
|
3490
|
-
state:
|
|
3548
|
+
state: import_services8.SpaceState[this._state]
|
|
3491
3549
|
}, {
|
|
3492
|
-
F:
|
|
3493
|
-
L:
|
|
3550
|
+
F: __dxlog_file11,
|
|
3551
|
+
L: 278,
|
|
3494
3552
|
S: this,
|
|
3495
3553
|
C: (f, a) => f(...a)
|
|
3496
3554
|
});
|
|
@@ -3505,14 +3563,14 @@ var DataSpace = class {
|
|
|
3505
3563
|
this.metrics.controlPipelineReady = /* @__PURE__ */ new Date();
|
|
3506
3564
|
await this._createWritableFeeds();
|
|
3507
3565
|
(0, import_log8.log)("writable feeds created", void 0, {
|
|
3508
|
-
F:
|
|
3509
|
-
L:
|
|
3566
|
+
F: __dxlog_file11,
|
|
3567
|
+
L: 294,
|
|
3510
3568
|
S: this,
|
|
3511
3569
|
C: (f, a) => f(...a)
|
|
3512
3570
|
});
|
|
3513
3571
|
this.stateUpdate.emit();
|
|
3514
3572
|
if (!this.notarizationPlugin.hasWriter) {
|
|
3515
|
-
this.notarizationPlugin.setWriter((0,
|
|
3573
|
+
this.notarizationPlugin.setWriter((0, import_echo_pipeline2.createMappedFeedWriter)((credential) => ({
|
|
3516
3574
|
credential: {
|
|
3517
3575
|
credential
|
|
3518
3576
|
}
|
|
@@ -3568,13 +3626,13 @@ var DataSpace = class {
|
|
|
3568
3626
|
space: this.key,
|
|
3569
3627
|
rootUrl
|
|
3570
3628
|
}, {
|
|
3571
|
-
F:
|
|
3572
|
-
L:
|
|
3629
|
+
F: __dxlog_file11,
|
|
3630
|
+
L: 360,
|
|
3573
3631
|
S: this,
|
|
3574
3632
|
C: (f, a) => f(...a)
|
|
3575
3633
|
});
|
|
3576
|
-
this.
|
|
3577
|
-
const handle = this.
|
|
3634
|
+
this._echoHost.replicateDocument(rootUrl);
|
|
3635
|
+
const handle = this._echoHost.automergeRepo.find(rootUrl);
|
|
3578
3636
|
queueMicrotask(async () => {
|
|
3579
3637
|
try {
|
|
3580
3638
|
await (0, import_debug3.warnAfterTimeout)(5e3, "Automerge root doc load timeout (DataSpace)", async () => {
|
|
@@ -3583,7 +3641,7 @@ var DataSpace = class {
|
|
|
3583
3641
|
if (this._ctx.disposed) {
|
|
3584
3642
|
return;
|
|
3585
3643
|
}
|
|
3586
|
-
const doc = handle.docSync() ?? (0,
|
|
3644
|
+
const doc = handle.docSync() ?? (0, import_invariant9.failedInvariant)();
|
|
3587
3645
|
if (!doc.access?.spaceKey) {
|
|
3588
3646
|
handle.change((doc2) => {
|
|
3589
3647
|
doc2.access = {
|
|
@@ -3600,8 +3658,8 @@ var DataSpace = class {
|
|
|
3600
3658
|
rootUrl,
|
|
3601
3659
|
err
|
|
3602
3660
|
}, {
|
|
3603
|
-
F:
|
|
3604
|
-
L:
|
|
3661
|
+
F: __dxlog_file11,
|
|
3662
|
+
L: 383,
|
|
3605
3663
|
S: this,
|
|
3606
3664
|
C: (f, a) => f(...a)
|
|
3607
3665
|
});
|
|
@@ -3627,7 +3685,7 @@ var DataSpace = class {
|
|
|
3627
3685
|
let epoch;
|
|
3628
3686
|
switch (options?.migration) {
|
|
3629
3687
|
case void 0:
|
|
3630
|
-
case
|
|
3688
|
+
case import_services8.CreateEpochRequest.Migration.NONE:
|
|
3631
3689
|
{
|
|
3632
3690
|
epoch = {
|
|
3633
3691
|
previousId: this._automergeSpaceState.lastEpoch?.id,
|
|
@@ -3637,9 +3695,9 @@ var DataSpace = class {
|
|
|
3637
3695
|
};
|
|
3638
3696
|
}
|
|
3639
3697
|
break;
|
|
3640
|
-
case
|
|
3698
|
+
case import_services8.CreateEpochRequest.Migration.INIT_AUTOMERGE:
|
|
3641
3699
|
{
|
|
3642
|
-
const document = this.
|
|
3700
|
+
const document = this._echoHost.automergeRepo.create();
|
|
3643
3701
|
epoch = {
|
|
3644
3702
|
previousId: this._automergeSpaceState.lastEpoch?.id,
|
|
3645
3703
|
number: (this._automergeSpaceState.lastEpoch?.subject.assertion.number ?? -1) + 1,
|
|
@@ -3648,15 +3706,15 @@ var DataSpace = class {
|
|
|
3648
3706
|
};
|
|
3649
3707
|
}
|
|
3650
3708
|
break;
|
|
3651
|
-
case
|
|
3709
|
+
case import_services8.CreateEpochRequest.Migration.PRUNE_AUTOMERGE_ROOT_HISTORY:
|
|
3652
3710
|
{
|
|
3653
3711
|
const currentRootUrl = this._automergeSpaceState.rootUrl;
|
|
3654
|
-
const rootHandle = this.
|
|
3712
|
+
const rootHandle = this._echoHost.automergeRepo.find(currentRootUrl);
|
|
3655
3713
|
await (0, import_context7.cancelWithContext)(this._ctx, (0, import_async10.asyncTimeout)(rootHandle.whenReady(), 1e4));
|
|
3656
|
-
const newRoot = this.
|
|
3657
|
-
(0,
|
|
3658
|
-
F:
|
|
3659
|
-
L:
|
|
3714
|
+
const newRoot = this._echoHost.automergeRepo.create(rootHandle.docSync());
|
|
3715
|
+
(0, import_invariant9.invariant)(typeof newRoot.url === "string" && newRoot.url.length > 0, void 0, {
|
|
3716
|
+
F: __dxlog_file11,
|
|
3717
|
+
L: 433,
|
|
3660
3718
|
S: this,
|
|
3661
3719
|
A: [
|
|
3662
3720
|
"typeof newRoot.url === 'string' && newRoot.url.length > 0",
|
|
@@ -3671,23 +3729,23 @@ var DataSpace = class {
|
|
|
3671
3729
|
};
|
|
3672
3730
|
}
|
|
3673
3731
|
break;
|
|
3674
|
-
case
|
|
3732
|
+
case import_services8.CreateEpochRequest.Migration.FRAGMENT_AUTOMERGE_ROOT:
|
|
3675
3733
|
{
|
|
3676
3734
|
import_log8.log.info("Fragmenting", void 0, {
|
|
3677
|
-
F:
|
|
3678
|
-
L:
|
|
3735
|
+
F: __dxlog_file11,
|
|
3736
|
+
L: 445,
|
|
3679
3737
|
S: this,
|
|
3680
3738
|
C: (f, a) => f(...a)
|
|
3681
3739
|
});
|
|
3682
3740
|
const currentRootUrl = this._automergeSpaceState.rootUrl;
|
|
3683
|
-
const rootHandle = this.
|
|
3741
|
+
const rootHandle = this._echoHost.automergeRepo.find(currentRootUrl);
|
|
3684
3742
|
await (0, import_context7.cancelWithContext)(this._ctx, (0, import_async10.asyncTimeout)(rootHandle.whenReady(), 1e4));
|
|
3685
3743
|
const objects = Object.entries(rootHandle.docSync().objects);
|
|
3686
|
-
const properties = objects.find(([_, value]) => value.system.type?.itemId ===
|
|
3744
|
+
const properties = objects.find(([_, value]) => value.system.type?.itemId === import_echo_schema.TYPE_PROPERTIES);
|
|
3687
3745
|
const otherObjects = objects.filter(([key]) => key !== properties?.[0]);
|
|
3688
|
-
(0,
|
|
3689
|
-
F:
|
|
3690
|
-
L:
|
|
3746
|
+
(0, import_invariant9.invariant)(properties, "Properties not found", {
|
|
3747
|
+
F: __dxlog_file11,
|
|
3748
|
+
L: 455,
|
|
3691
3749
|
S: this,
|
|
3692
3750
|
A: [
|
|
3693
3751
|
"properties",
|
|
@@ -3700,17 +3758,17 @@ var DataSpace = class {
|
|
|
3700
3758
|
properties
|
|
3701
3759
|
])
|
|
3702
3760
|
};
|
|
3703
|
-
const newRoot = this.
|
|
3704
|
-
(0,
|
|
3705
|
-
F:
|
|
3706
|
-
L:
|
|
3761
|
+
const newRoot = this._echoHost.automergeRepo.create(newSpaceDoc);
|
|
3762
|
+
(0, import_invariant9.invariant)(typeof newRoot.url === "string" && newRoot.url.length > 0, void 0, {
|
|
3763
|
+
F: __dxlog_file11,
|
|
3764
|
+
L: 460,
|
|
3707
3765
|
S: this,
|
|
3708
3766
|
A: [
|
|
3709
3767
|
"typeof newRoot.url === 'string' && newRoot.url.length > 0",
|
|
3710
3768
|
""
|
|
3711
3769
|
]
|
|
3712
3770
|
});
|
|
3713
|
-
const docLoader = new
|
|
3771
|
+
const docLoader = new import_echo_pipeline3.AutomergeDocumentLoaderImpl(this.key, this._echoHost.automergeRepo);
|
|
3714
3772
|
await docLoader.loadSpaceRootDocHandle(this._ctx, {
|
|
3715
3773
|
rootUrl: newRoot.url
|
|
3716
3774
|
});
|
|
@@ -3754,25 +3812,25 @@ var DataSpace = class {
|
|
|
3754
3812
|
]));
|
|
3755
3813
|
}
|
|
3756
3814
|
async activate() {
|
|
3757
|
-
if (this._state !==
|
|
3815
|
+
if (this._state !== import_services8.SpaceState.INACTIVE) {
|
|
3758
3816
|
return;
|
|
3759
3817
|
}
|
|
3760
|
-
await this._metadataStore.setSpaceState(this.key,
|
|
3818
|
+
await this._metadataStore.setSpaceState(this.key, import_services8.SpaceState.ACTIVE);
|
|
3761
3819
|
await this._open();
|
|
3762
3820
|
this.initializeDataPipelineAsync();
|
|
3763
3821
|
}
|
|
3764
3822
|
async deactivate() {
|
|
3765
|
-
if (this._state ===
|
|
3823
|
+
if (this._state === import_services8.SpaceState.INACTIVE) {
|
|
3766
3824
|
return;
|
|
3767
3825
|
}
|
|
3768
|
-
await this._metadataStore.setSpaceState(this.key,
|
|
3826
|
+
await this._metadataStore.setSpaceState(this.key, import_services8.SpaceState.INACTIVE);
|
|
3769
3827
|
await this._close();
|
|
3770
|
-
this._state =
|
|
3828
|
+
this._state = import_services8.SpaceState.INACTIVE;
|
|
3771
3829
|
(0, import_log8.log)("new state", {
|
|
3772
|
-
state:
|
|
3830
|
+
state: import_services8.SpaceState[this._state]
|
|
3773
3831
|
}, {
|
|
3774
|
-
F:
|
|
3775
|
-
L:
|
|
3832
|
+
F: __dxlog_file11,
|
|
3833
|
+
L: 526,
|
|
3776
3834
|
S: this,
|
|
3777
3835
|
C: (f, a) => f(...a)
|
|
3778
3836
|
});
|
|
@@ -3780,18 +3838,18 @@ var DataSpace = class {
|
|
|
3780
3838
|
}
|
|
3781
3839
|
};
|
|
3782
3840
|
_ts_decorate4([
|
|
3783
|
-
|
|
3841
|
+
import_tracing4.trace.info()
|
|
3784
3842
|
], DataSpace.prototype, "_inner", void 0);
|
|
3785
3843
|
_ts_decorate4([
|
|
3786
|
-
|
|
3844
|
+
import_tracing4.trace.info()
|
|
3787
3845
|
], DataSpace.prototype, "key", null);
|
|
3788
3846
|
_ts_decorate4([
|
|
3789
|
-
|
|
3790
|
-
enum:
|
|
3847
|
+
import_tracing4.trace.info({
|
|
3848
|
+
enum: import_services8.SpaceState
|
|
3791
3849
|
})
|
|
3792
3850
|
], DataSpace.prototype, "state", null);
|
|
3793
3851
|
_ts_decorate4([
|
|
3794
|
-
|
|
3852
|
+
import_tracing4.trace.info({
|
|
3795
3853
|
depth: null
|
|
3796
3854
|
})
|
|
3797
3855
|
], DataSpace.prototype, "_automergeInfo", null);
|
|
@@ -3802,12 +3860,12 @@ _ts_decorate4([
|
|
|
3802
3860
|
import_async10.synchronized
|
|
3803
3861
|
], DataSpace.prototype, "close", null);
|
|
3804
3862
|
_ts_decorate4([
|
|
3805
|
-
|
|
3863
|
+
import_tracing4.trace.span({
|
|
3806
3864
|
showInBrowserTimeline: true
|
|
3807
3865
|
})
|
|
3808
3866
|
], DataSpace.prototype, "initializeDataPipeline", null);
|
|
3809
3867
|
_ts_decorate4([
|
|
3810
|
-
|
|
3868
|
+
import_tracing4.trace.span({
|
|
3811
3869
|
showInBrowserTimeline: true
|
|
3812
3870
|
})
|
|
3813
3871
|
], DataSpace.prototype, "_initializeAndReadControlPipeline", null);
|
|
@@ -3822,7 +3880,7 @@ _ts_decorate4([
|
|
|
3822
3880
|
], DataSpace.prototype, "deactivate", null);
|
|
3823
3881
|
DataSpace = _ts_decorate4([
|
|
3824
3882
|
(0, import_async10.trackLeaks)("open", "close"),
|
|
3825
|
-
|
|
3883
|
+
import_tracing4.trace.resource()
|
|
3826
3884
|
], DataSpace);
|
|
3827
3885
|
var spaceGenesis = async (keyring, signingContext, space, automergeRoot) => {
|
|
3828
3886
|
const credentials = [
|
|
@@ -3898,22 +3956,23 @@ function _ts_decorate5(decorators, target, key, desc) {
|
|
|
3898
3956
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
3899
3957
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3900
3958
|
}
|
|
3901
|
-
var
|
|
3959
|
+
var __dxlog_file12 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts";
|
|
3902
3960
|
var PRESENCE_ANNOUNCE_INTERVAL = 1e4;
|
|
3903
3961
|
var PRESENCE_OFFLINE_TIMEOUT = 2e4;
|
|
3904
3962
|
var DataSpaceManager = class {
|
|
3905
|
-
constructor(_spaceManager, _metadataStore, _keyring, _signingContext, _feedStore,
|
|
3963
|
+
constructor(_spaceManager, _metadataStore, _keyring, _signingContext, _feedStore, _echoHost, _invitationsManager, params) {
|
|
3906
3964
|
this._spaceManager = _spaceManager;
|
|
3907
3965
|
this._metadataStore = _metadataStore;
|
|
3908
3966
|
this._keyring = _keyring;
|
|
3909
3967
|
this._signingContext = _signingContext;
|
|
3910
3968
|
this._feedStore = _feedStore;
|
|
3911
|
-
this.
|
|
3969
|
+
this._echoHost = _echoHost;
|
|
3970
|
+
this._invitationsManager = _invitationsManager;
|
|
3912
3971
|
this._ctx = new import_context9.Context();
|
|
3913
3972
|
this.updated = new import_async13.Event();
|
|
3914
|
-
this._spaces = new import_util6.ComplexMap(
|
|
3973
|
+
this._spaces = new import_util6.ComplexMap(import_keys10.PublicKey.hash);
|
|
3915
3974
|
this._isOpen = false;
|
|
3916
|
-
this._instanceId =
|
|
3975
|
+
this._instanceId = import_keys10.PublicKey.random().toHex();
|
|
3917
3976
|
const { spaceMemberPresenceAnnounceInterval = PRESENCE_ANNOUNCE_INTERVAL, spaceMemberPresenceOfflineTimeout = PRESENCE_OFFLINE_TIMEOUT } = params ?? {};
|
|
3918
3977
|
this._spaceMemberPresenceAnnounceInterval = spaceMemberPresenceAnnounceInterval;
|
|
3919
3978
|
this._spaceMemberPresenceOfflineTimeout = spaceMemberPresenceOfflineTimeout;
|
|
@@ -3924,24 +3983,24 @@ var DataSpaceManager = class {
|
|
|
3924
3983
|
}
|
|
3925
3984
|
async open() {
|
|
3926
3985
|
(0, import_log10.log)("open", void 0, {
|
|
3927
|
-
F:
|
|
3928
|
-
L:
|
|
3986
|
+
F: __dxlog_file12,
|
|
3987
|
+
L: 102,
|
|
3929
3988
|
S: this,
|
|
3930
3989
|
C: (f, a) => f(...a)
|
|
3931
3990
|
});
|
|
3932
|
-
import_log10.log.trace("dxos.echo.data-space-manager.open",
|
|
3991
|
+
import_log10.log.trace("dxos.echo.data-space-manager.open", import_protocols9.trace.begin({
|
|
3933
3992
|
id: this._instanceId
|
|
3934
3993
|
}), {
|
|
3935
|
-
F:
|
|
3936
|
-
L:
|
|
3994
|
+
F: __dxlog_file12,
|
|
3995
|
+
L: 103,
|
|
3937
3996
|
S: this,
|
|
3938
3997
|
C: (f, a) => f(...a)
|
|
3939
3998
|
});
|
|
3940
3999
|
(0, import_log10.log)("metadata loaded", {
|
|
3941
4000
|
spaces: this._metadataStore.spaces.length
|
|
3942
4001
|
}, {
|
|
3943
|
-
F:
|
|
3944
|
-
L:
|
|
4002
|
+
F: __dxlog_file12,
|
|
4003
|
+
L: 104,
|
|
3945
4004
|
S: this,
|
|
3946
4005
|
C: (f, a) => f(...a)
|
|
3947
4006
|
});
|
|
@@ -3950,8 +4009,8 @@ var DataSpaceManager = class {
|
|
|
3950
4009
|
(0, import_log10.log)("load space", {
|
|
3951
4010
|
spaceMetadata
|
|
3952
4011
|
}, {
|
|
3953
|
-
F:
|
|
3954
|
-
L:
|
|
4012
|
+
F: __dxlog_file12,
|
|
4013
|
+
L: 108,
|
|
3955
4014
|
S: this,
|
|
3956
4015
|
C: (f, a) => f(...a)
|
|
3957
4016
|
});
|
|
@@ -3961,8 +4020,8 @@ var DataSpaceManager = class {
|
|
|
3961
4020
|
spaceMetadata,
|
|
3962
4021
|
err
|
|
3963
4022
|
}, {
|
|
3964
|
-
F:
|
|
3965
|
-
L:
|
|
4023
|
+
F: __dxlog_file12,
|
|
4024
|
+
L: 111,
|
|
3966
4025
|
S: this,
|
|
3967
4026
|
C: (f, a) => f(...a)
|
|
3968
4027
|
});
|
|
@@ -3971,23 +4030,23 @@ var DataSpaceManager = class {
|
|
|
3971
4030
|
this._isOpen = true;
|
|
3972
4031
|
this.updated.emit();
|
|
3973
4032
|
for (const space of this._spaces.values()) {
|
|
3974
|
-
if (space.state !==
|
|
4033
|
+
if (space.state !== import_services9.SpaceState.INACTIVE) {
|
|
3975
4034
|
space.initializeDataPipelineAsync();
|
|
3976
4035
|
}
|
|
3977
4036
|
}
|
|
3978
|
-
import_log10.log.trace("dxos.echo.data-space-manager.open",
|
|
4037
|
+
import_log10.log.trace("dxos.echo.data-space-manager.open", import_protocols9.trace.end({
|
|
3979
4038
|
id: this._instanceId
|
|
3980
4039
|
}), {
|
|
3981
|
-
F:
|
|
3982
|
-
L:
|
|
4040
|
+
F: __dxlog_file12,
|
|
4041
|
+
L: 124,
|
|
3983
4042
|
S: this,
|
|
3984
4043
|
C: (f, a) => f(...a)
|
|
3985
4044
|
});
|
|
3986
4045
|
}
|
|
3987
4046
|
async close() {
|
|
3988
4047
|
(0, import_log10.log)("close", void 0, {
|
|
3989
|
-
F:
|
|
3990
|
-
L:
|
|
4048
|
+
F: __dxlog_file12,
|
|
4049
|
+
L: 129,
|
|
3991
4050
|
S: this,
|
|
3992
4051
|
C: (f, a) => f(...a)
|
|
3993
4052
|
});
|
|
@@ -4001,9 +4060,9 @@ var DataSpaceManager = class {
|
|
|
4001
4060
|
* Creates a new space writing the genesis credentials to the control feed.
|
|
4002
4061
|
*/
|
|
4003
4062
|
async createSpace() {
|
|
4004
|
-
(0,
|
|
4005
|
-
F:
|
|
4006
|
-
L:
|
|
4063
|
+
(0, import_invariant11.invariant)(this._isOpen, "Not open.", {
|
|
4064
|
+
F: __dxlog_file12,
|
|
4065
|
+
L: 142,
|
|
4007
4066
|
S: this,
|
|
4008
4067
|
A: [
|
|
4009
4068
|
"this._isOpen",
|
|
@@ -4018,28 +4077,23 @@ var DataSpaceManager = class {
|
|
|
4018
4077
|
genesisFeedKey: controlFeedKey,
|
|
4019
4078
|
controlFeedKey,
|
|
4020
4079
|
dataFeedKey,
|
|
4021
|
-
state:
|
|
4080
|
+
state: import_services9.SpaceState.ACTIVE
|
|
4022
4081
|
};
|
|
4023
4082
|
(0, import_log10.log)("creating space...", {
|
|
4024
4083
|
spaceKey
|
|
4025
4084
|
}, {
|
|
4026
|
-
F:
|
|
4027
|
-
L:
|
|
4085
|
+
F: __dxlog_file12,
|
|
4086
|
+
L: 154,
|
|
4028
4087
|
S: this,
|
|
4029
4088
|
C: (f, a) => f(...a)
|
|
4030
4089
|
});
|
|
4031
|
-
const
|
|
4032
|
-
automergeRoot.change((doc) => {
|
|
4033
|
-
doc.access = {
|
|
4034
|
-
spaceKey: spaceKey.toHex()
|
|
4035
|
-
};
|
|
4036
|
-
});
|
|
4090
|
+
const automergeRootUrl = await this._echoHost.createSpaceRoot(spaceKey);
|
|
4037
4091
|
const space = await this._constructSpace(metadata);
|
|
4038
|
-
const credentials = await spaceGenesis(this._keyring, this._signingContext, space.inner,
|
|
4092
|
+
const credentials = await spaceGenesis(this._keyring, this._signingContext, space.inner, automergeRootUrl);
|
|
4039
4093
|
await this._metadataStore.addSpace(metadata);
|
|
4040
4094
|
const memberCredential = credentials[1];
|
|
4041
|
-
(0,
|
|
4042
|
-
F:
|
|
4095
|
+
(0, import_invariant11.invariant)((0, import_credentials12.getCredentialAssertion)(memberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
|
|
4096
|
+
F: __dxlog_file12,
|
|
4043
4097
|
L: 163,
|
|
4044
4098
|
S: this,
|
|
4045
4099
|
A: [
|
|
@@ -4057,13 +4111,13 @@ var DataSpaceManager = class {
|
|
|
4057
4111
|
(0, import_log10.log)("accept space", {
|
|
4058
4112
|
opts
|
|
4059
4113
|
}, {
|
|
4060
|
-
F:
|
|
4114
|
+
F: __dxlog_file12,
|
|
4061
4115
|
L: 175,
|
|
4062
4116
|
S: this,
|
|
4063
4117
|
C: (f, a) => f(...a)
|
|
4064
4118
|
});
|
|
4065
|
-
(0,
|
|
4066
|
-
F:
|
|
4119
|
+
(0, import_invariant11.invariant)(this._isOpen, "Not open.", {
|
|
4120
|
+
F: __dxlog_file12,
|
|
4067
4121
|
L: 176,
|
|
4068
4122
|
S: this,
|
|
4069
4123
|
A: [
|
|
@@ -4071,8 +4125,8 @@ var DataSpaceManager = class {
|
|
|
4071
4125
|
"'Not open.'"
|
|
4072
4126
|
]
|
|
4073
4127
|
});
|
|
4074
|
-
(0,
|
|
4075
|
-
F:
|
|
4128
|
+
(0, import_invariant11.invariant)(!this._spaces.has(opts.spaceKey), "Space already exists.", {
|
|
4129
|
+
F: __dxlog_file12,
|
|
4076
4130
|
L: 177,
|
|
4077
4131
|
S: this,
|
|
4078
4132
|
A: [
|
|
@@ -4100,14 +4154,14 @@ var DataSpaceManager = class {
|
|
|
4100
4154
|
async waitUntilSpaceReady(spaceKey) {
|
|
4101
4155
|
await (0, import_context9.cancelWithContext)(this._ctx, this.updated.waitForCondition(() => {
|
|
4102
4156
|
const space = this._spaces.get(spaceKey);
|
|
4103
|
-
return !!space && space.state ===
|
|
4157
|
+
return !!space && space.state === import_services9.SpaceState.READY;
|
|
4104
4158
|
}));
|
|
4105
4159
|
}
|
|
4106
4160
|
async _constructSpace(metadata) {
|
|
4107
4161
|
(0, import_log10.log)("construct space", {
|
|
4108
4162
|
metadata
|
|
4109
4163
|
}, {
|
|
4110
|
-
F:
|
|
4164
|
+
F: __dxlog_file12,
|
|
4111
4165
|
L: 210,
|
|
4112
4166
|
S: this,
|
|
4113
4167
|
C: (f, a) => f(...a)
|
|
@@ -4140,37 +4194,41 @@ var DataSpaceManager = class {
|
|
|
4140
4194
|
remotePeerId: session.remotePeerId
|
|
4141
4195
|
}));
|
|
4142
4196
|
session.addExtension("dxos.mesh.teleport.notarization", dataSpace.notarizationPlugin.createExtension());
|
|
4143
|
-
this.
|
|
4144
|
-
session.addExtension("dxos.mesh.teleport.automerge", this.
|
|
4197
|
+
this._echoHost.authorizeDevice(space.key, session.remotePeerId);
|
|
4198
|
+
session.addExtension("dxos.mesh.teleport.automerge", this._echoHost.createReplicationExtension());
|
|
4145
4199
|
},
|
|
4146
4200
|
onAuthFailure: () => {
|
|
4147
4201
|
import_log10.log.warn("auth failure", void 0, {
|
|
4148
|
-
F:
|
|
4202
|
+
F: __dxlog_file12,
|
|
4149
4203
|
L: 247,
|
|
4150
4204
|
S: this,
|
|
4151
4205
|
C: (f, a) => f(...a)
|
|
4152
4206
|
});
|
|
4153
4207
|
},
|
|
4154
|
-
memberKey: this._signingContext.identityKey
|
|
4208
|
+
memberKey: this._signingContext.identityKey,
|
|
4209
|
+
onDelegatedInvitationStatusChange: (invitation, isActive) => {
|
|
4210
|
+
return this._handleInvitationStatusChange(dataSpace, invitation, isActive);
|
|
4211
|
+
}
|
|
4155
4212
|
});
|
|
4156
4213
|
controlFeed && await space.setControlFeed(controlFeed);
|
|
4157
4214
|
dataFeed && await space.setDataFeed(dataFeed);
|
|
4158
4215
|
const dataSpace = new DataSpace({
|
|
4159
4216
|
inner: space,
|
|
4160
|
-
initialState: metadata.state ===
|
|
4217
|
+
initialState: metadata.state === import_services9.SpaceState.INACTIVE ? import_services9.SpaceState.INACTIVE : import_services9.SpaceState.CLOSED,
|
|
4161
4218
|
metadataStore: this._metadataStore,
|
|
4162
4219
|
gossip,
|
|
4163
4220
|
presence,
|
|
4164
4221
|
keyring: this._keyring,
|
|
4165
4222
|
feedStore: this._feedStore,
|
|
4223
|
+
echoHost: this._echoHost,
|
|
4166
4224
|
signingContext: this._signingContext,
|
|
4167
4225
|
callbacks: {
|
|
4168
4226
|
beforeReady: async () => {
|
|
4169
4227
|
(0, import_log10.log)("before space ready", {
|
|
4170
4228
|
space: space.key
|
|
4171
4229
|
}, {
|
|
4172
|
-
F:
|
|
4173
|
-
L:
|
|
4230
|
+
F: __dxlog_file12,
|
|
4231
|
+
L: 269,
|
|
4174
4232
|
S: this,
|
|
4175
4233
|
C: (f, a) => f(...a)
|
|
4176
4234
|
});
|
|
@@ -4180,12 +4238,15 @@ var DataSpaceManager = class {
|
|
|
4180
4238
|
space: space.key,
|
|
4181
4239
|
open: this._isOpen
|
|
4182
4240
|
}, {
|
|
4183
|
-
F:
|
|
4184
|
-
L:
|
|
4241
|
+
F: __dxlog_file12,
|
|
4242
|
+
L: 272,
|
|
4185
4243
|
S: this,
|
|
4186
4244
|
C: (f, a) => f(...a)
|
|
4187
4245
|
});
|
|
4188
4246
|
if (this._isOpen) {
|
|
4247
|
+
await this._createDelegatedInvitations(dataSpace, [
|
|
4248
|
+
...space.spaceState.invitations.entries()
|
|
4249
|
+
]);
|
|
4189
4250
|
this.updated.emit();
|
|
4190
4251
|
}
|
|
4191
4252
|
},
|
|
@@ -4193,17 +4254,16 @@ var DataSpaceManager = class {
|
|
|
4193
4254
|
(0, import_log10.log)("before space close", {
|
|
4194
4255
|
space: space.key
|
|
4195
4256
|
}, {
|
|
4196
|
-
F:
|
|
4197
|
-
L:
|
|
4257
|
+
F: __dxlog_file12,
|
|
4258
|
+
L: 279,
|
|
4198
4259
|
S: this,
|
|
4199
4260
|
C: (f, a) => f(...a)
|
|
4200
4261
|
});
|
|
4201
4262
|
}
|
|
4202
4263
|
},
|
|
4203
|
-
cache: metadata.cache
|
|
4204
|
-
automergeHost: this._automergeHost
|
|
4264
|
+
cache: metadata.cache
|
|
4205
4265
|
});
|
|
4206
|
-
if (metadata.state !==
|
|
4266
|
+
if (metadata.state !== import_services9.SpaceState.INACTIVE) {
|
|
4207
4267
|
await dataSpace.open();
|
|
4208
4268
|
}
|
|
4209
4269
|
if (metadata.controlTimeframe) {
|
|
@@ -4212,6 +4272,41 @@ var DataSpaceManager = class {
|
|
|
4212
4272
|
this._spaces.set(metadata.key, dataSpace);
|
|
4213
4273
|
return dataSpace;
|
|
4214
4274
|
}
|
|
4275
|
+
async _handleInvitationStatusChange(dataSpace, delegatedInvitation, isActive) {
|
|
4276
|
+
if (dataSpace?.state !== import_services9.SpaceState.READY) {
|
|
4277
|
+
return;
|
|
4278
|
+
}
|
|
4279
|
+
if (isActive) {
|
|
4280
|
+
await this._createDelegatedInvitations(dataSpace, [
|
|
4281
|
+
[
|
|
4282
|
+
delegatedInvitation.credentialId,
|
|
4283
|
+
delegatedInvitation.invitation
|
|
4284
|
+
]
|
|
4285
|
+
]);
|
|
4286
|
+
} else {
|
|
4287
|
+
await this._invitationsManager.cancelInvitation(delegatedInvitation.invitation);
|
|
4288
|
+
}
|
|
4289
|
+
}
|
|
4290
|
+
async _createDelegatedInvitations(space, invitations) {
|
|
4291
|
+
const tasks = invitations.map(([credentialId, invitation]) => {
|
|
4292
|
+
return this._invitationsManager.createInvitation({
|
|
4293
|
+
type: import_services9.Invitation.Type.DELEGATED,
|
|
4294
|
+
kind: import_services9.Invitation.Kind.SPACE,
|
|
4295
|
+
spaceKey: space.key,
|
|
4296
|
+
authMethod: invitation.authMethod,
|
|
4297
|
+
invitationId: invitation.invitationId,
|
|
4298
|
+
swarmKey: invitation.swarmKey,
|
|
4299
|
+
guestKeypair: invitation.guestKey ? {
|
|
4300
|
+
publicKey: invitation.guestKey
|
|
4301
|
+
} : void 0,
|
|
4302
|
+
lifetime: invitation.expiresOn ? invitation.expiresOn.getTime() - Date.now() : void 0,
|
|
4303
|
+
multiUse: invitation.multiUse,
|
|
4304
|
+
delegationCredentialId: credentialId,
|
|
4305
|
+
persistent: false
|
|
4306
|
+
});
|
|
4307
|
+
});
|
|
4308
|
+
await Promise.all(tasks);
|
|
4309
|
+
}
|
|
4215
4310
|
};
|
|
4216
4311
|
_ts_decorate5([
|
|
4217
4312
|
import_async13.synchronized
|
|
@@ -4228,7 +4323,7 @@ _ts_decorate5([
|
|
|
4228
4323
|
DataSpaceManager = _ts_decorate5([
|
|
4229
4324
|
(0, import_async13.trackLeaks)("open", "close")
|
|
4230
4325
|
], DataSpaceManager);
|
|
4231
|
-
var
|
|
4326
|
+
var __dxlog_file13 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/spaces-service.ts";
|
|
4232
4327
|
var SpacesServiceImpl = class {
|
|
4233
4328
|
constructor(_identityManager, _spaceManager, _getDataSpaceManager) {
|
|
4234
4329
|
this._identityManager = _identityManager;
|
|
@@ -4245,29 +4340,29 @@ var SpacesServiceImpl = class {
|
|
|
4245
4340
|
}
|
|
4246
4341
|
async updateSpace({ spaceKey, state }) {
|
|
4247
4342
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
4248
|
-
const space = dataSpaceManager.spaces.get(spaceKey) ?? (0, import_debug5.raise)(new
|
|
4343
|
+
const space = dataSpaceManager.spaces.get(spaceKey) ?? (0, import_debug5.raise)(new import_protocols10.SpaceNotFoundError(spaceKey));
|
|
4249
4344
|
if (state) {
|
|
4250
4345
|
switch (state) {
|
|
4251
|
-
case
|
|
4346
|
+
case import_services10.SpaceState.ACTIVE:
|
|
4252
4347
|
await space.activate();
|
|
4253
4348
|
break;
|
|
4254
|
-
case
|
|
4349
|
+
case import_services10.SpaceState.INACTIVE:
|
|
4255
4350
|
await space.deactivate();
|
|
4256
4351
|
break;
|
|
4257
4352
|
default:
|
|
4258
|
-
throw new
|
|
4353
|
+
throw new import_protocols10.ApiError("Invalid space state");
|
|
4259
4354
|
}
|
|
4260
4355
|
}
|
|
4261
4356
|
}
|
|
4262
4357
|
querySpaces() {
|
|
4263
|
-
return new
|
|
4358
|
+
return new import_codec_protobuf10.Stream(({ next, ctx }) => {
|
|
4264
4359
|
const scheduler = new import_async14.UpdateScheduler(ctx, async () => {
|
|
4265
4360
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
4266
4361
|
const spaces = Array.from(dataSpaceManager.spaces.values()).map((space) => this._serializeSpace(space));
|
|
4267
4362
|
(0, import_log11.log)("update", {
|
|
4268
4363
|
spaces
|
|
4269
4364
|
}, {
|
|
4270
|
-
F:
|
|
4365
|
+
F: __dxlog_file13,
|
|
4271
4366
|
L: 77,
|
|
4272
4367
|
S: this,
|
|
4273
4368
|
C: (f, a) => f(...a)
|
|
@@ -4307,14 +4402,14 @@ var SpacesServiceImpl = class {
|
|
|
4307
4402
|
}
|
|
4308
4403
|
async postMessage({ spaceKey, channel, message }) {
|
|
4309
4404
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
4310
|
-
const space = dataSpaceManager.spaces.get(spaceKey) ?? (0, import_debug5.raise)(new
|
|
4405
|
+
const space = dataSpaceManager.spaces.get(spaceKey) ?? (0, import_debug5.raise)(new import_protocols10.SpaceNotFoundError(spaceKey));
|
|
4311
4406
|
await space.postMessage(getChannelId(channel), message);
|
|
4312
4407
|
}
|
|
4313
4408
|
subscribeMessages({ spaceKey, channel }) {
|
|
4314
|
-
return new
|
|
4409
|
+
return new import_codec_protobuf10.Stream(({ ctx, next }) => {
|
|
4315
4410
|
(0, import_async14.scheduleTask)(ctx, async () => {
|
|
4316
4411
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
4317
|
-
const space = dataSpaceManager.spaces.get(spaceKey) ?? (0, import_debug5.raise)(new
|
|
4412
|
+
const space = dataSpaceManager.spaces.get(spaceKey) ?? (0, import_debug5.raise)(new import_protocols10.SpaceNotFoundError(spaceKey));
|
|
4318
4413
|
const handle = space.listen(getChannelId(channel), (message) => {
|
|
4319
4414
|
next(message);
|
|
4320
4415
|
});
|
|
@@ -4323,8 +4418,8 @@ var SpacesServiceImpl = class {
|
|
|
4323
4418
|
});
|
|
4324
4419
|
}
|
|
4325
4420
|
queryCredentials({ spaceKey, noTail }) {
|
|
4326
|
-
return new
|
|
4327
|
-
const space = this._spaceManager.spaces.get(spaceKey) ?? (0, import_debug5.raise)(new
|
|
4421
|
+
return new import_codec_protobuf10.Stream(({ ctx, next, close }) => {
|
|
4422
|
+
const space = this._spaceManager.spaces.get(spaceKey) ?? (0, import_debug5.raise)(new import_protocols10.SpaceNotFoundError(spaceKey));
|
|
4328
4423
|
const processor = {
|
|
4329
4424
|
processCredential: async (credential) => {
|
|
4330
4425
|
next(credential);
|
|
@@ -4340,7 +4435,7 @@ var SpacesServiceImpl = class {
|
|
|
4340
4435
|
});
|
|
4341
4436
|
}
|
|
4342
4437
|
async writeCredentials({ spaceKey, credentials }) {
|
|
4343
|
-
const space = this._spaceManager.spaces.get(spaceKey) ?? (0, import_debug5.raise)(new
|
|
4438
|
+
const space = this._spaceManager.spaces.get(spaceKey) ?? (0, import_debug5.raise)(new import_protocols10.SpaceNotFoundError(spaceKey));
|
|
4344
4439
|
for (const credential of credentials ?? []) {
|
|
4345
4440
|
if (credential.proof) {
|
|
4346
4441
|
await space.controlPipeline.writer.write({
|
|
@@ -4349,8 +4444,8 @@ var SpacesServiceImpl = class {
|
|
|
4349
4444
|
}
|
|
4350
4445
|
});
|
|
4351
4446
|
} else {
|
|
4352
|
-
(0,
|
|
4353
|
-
F:
|
|
4447
|
+
(0, import_invariant12.invariant)(!credential.id, "Id on unsigned credentials is not allowed", {
|
|
4448
|
+
F: __dxlog_file13,
|
|
4354
4449
|
L: 164,
|
|
4355
4450
|
S: this,
|
|
4356
4451
|
A: [
|
|
@@ -4358,8 +4453,8 @@ var SpacesServiceImpl = class {
|
|
|
4358
4453
|
"'Id on unsigned credentials is not allowed'"
|
|
4359
4454
|
]
|
|
4360
4455
|
});
|
|
4361
|
-
(0,
|
|
4362
|
-
F:
|
|
4456
|
+
(0, import_invariant12.invariant)(this._identityManager.identity, "Identity is not available", {
|
|
4457
|
+
F: __dxlog_file13,
|
|
4363
4458
|
L: 165,
|
|
4364
4459
|
S: this,
|
|
4365
4460
|
A: [
|
|
@@ -4368,8 +4463,8 @@ var SpacesServiceImpl = class {
|
|
|
4368
4463
|
]
|
|
4369
4464
|
});
|
|
4370
4465
|
const signer = this._identityManager.identity.getIdentityCredentialSigner();
|
|
4371
|
-
(0,
|
|
4372
|
-
F:
|
|
4466
|
+
(0, import_invariant12.invariant)(credential.issuer.equals(signer.getIssuer()), void 0, {
|
|
4467
|
+
F: __dxlog_file13,
|
|
4373
4468
|
L: 167,
|
|
4374
4469
|
S: this,
|
|
4375
4470
|
A: [
|
|
@@ -4391,7 +4486,7 @@ var SpacesServiceImpl = class {
|
|
|
4391
4486
|
}
|
|
4392
4487
|
async createEpoch({ spaceKey, migration }) {
|
|
4393
4488
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
4394
|
-
const space = dataSpaceManager.spaces.get(spaceKey) ?? (0, import_debug5.raise)(new
|
|
4489
|
+
const space = dataSpaceManager.spaces.get(spaceKey) ?? (0, import_debug5.raise)(new import_protocols10.SpaceNotFoundError(spaceKey));
|
|
4395
4490
|
await space.createEpoch({
|
|
4396
4491
|
migration
|
|
4397
4492
|
});
|
|
@@ -4400,7 +4495,7 @@ var SpacesServiceImpl = class {
|
|
|
4400
4495
|
return {
|
|
4401
4496
|
spaceKey: space.key,
|
|
4402
4497
|
state: space.state,
|
|
4403
|
-
error: space.error ? (0,
|
|
4498
|
+
error: space.error ? (0, import_protocols10.encodeError)(space.error) : void 0,
|
|
4404
4499
|
pipeline: {
|
|
4405
4500
|
currentEpoch: space.automergeSpaceState.lastEpoch,
|
|
4406
4501
|
appliedEpoch: space.automergeSpaceState.lastEpoch,
|
|
@@ -4425,7 +4520,7 @@ var SpacesServiceImpl = class {
|
|
|
4425
4520
|
identityKey: member.key,
|
|
4426
4521
|
profile: member.profile ?? {}
|
|
4427
4522
|
},
|
|
4428
|
-
presence: member.removed ?
|
|
4523
|
+
presence: member.removed ? import_services10.SpaceMember.PresenceState.REMOVED : isMe || peers.length > 0 ? import_services10.SpaceMember.PresenceState.ONLINE : import_services10.SpaceMember.PresenceState.OFFLINE,
|
|
4429
4524
|
peerStates: peers
|
|
4430
4525
|
};
|
|
4431
4526
|
}),
|
|
@@ -4436,80 +4531,6 @@ var SpacesServiceImpl = class {
|
|
|
4436
4531
|
}
|
|
4437
4532
|
};
|
|
4438
4533
|
var getChannelId = (channel) => `user-channel/${channel}`;
|
|
4439
|
-
var createSelectedDocumentsIterator = (automergeHost) => (
|
|
4440
|
-
/**
|
|
4441
|
-
* Get object data blobs from Automerge Repo by ids.
|
|
4442
|
-
* @param ids
|
|
4443
|
-
*/
|
|
4444
|
-
// TODO(mykola): Unload automerge handles after usage.
|
|
4445
|
-
async function* loadDocuments(ids) {
|
|
4446
|
-
for (const id of ids) {
|
|
4447
|
-
const { documentId, objectId } = import_protocols13.idCodec.decode(id);
|
|
4448
|
-
const handle = automergeHost.repo.find(documentId);
|
|
4449
|
-
await (0, import_debug7.warnAfterTimeout)(5e3, "to long to load doc", () => handle.whenReady());
|
|
4450
|
-
const doc = handle.docSync();
|
|
4451
|
-
const hash = (0, import_automerge.getHeads)(doc).join("");
|
|
4452
|
-
yield doc.objects?.[objectId] ? [
|
|
4453
|
-
{
|
|
4454
|
-
id,
|
|
4455
|
-
object: doc.objects[objectId],
|
|
4456
|
-
currentHash: hash
|
|
4457
|
-
}
|
|
4458
|
-
] : [];
|
|
4459
|
-
}
|
|
4460
|
-
}
|
|
4461
|
-
);
|
|
4462
|
-
var createDocumentsIterator = (automergeHost) => (
|
|
4463
|
-
/**
|
|
4464
|
-
* Recursively get all object data blobs from Automerge Repo.
|
|
4465
|
-
* @param ids
|
|
4466
|
-
*/
|
|
4467
|
-
// TODO(mykola): Unload automerge handles after usage.
|
|
4468
|
-
async function* getAllDocuments() {
|
|
4469
|
-
const visited = /* @__PURE__ */ new Set();
|
|
4470
|
-
async function* getObjectsFromHandle(handle) {
|
|
4471
|
-
if (visited.has(handle.documentId)) {
|
|
4472
|
-
return;
|
|
4473
|
-
}
|
|
4474
|
-
await (0, import_debug7.warnAfterTimeout)(5e3, "to long to load doc", () => handle.whenReady());
|
|
4475
|
-
const doc = handle.docSync();
|
|
4476
|
-
const heads = (0, import_automerge.getHeads)(doc);
|
|
4477
|
-
if (doc.objects) {
|
|
4478
|
-
yield Object.entries(doc.objects).map(([objectId, object]) => {
|
|
4479
|
-
return {
|
|
4480
|
-
id: import_protocols13.idCodec.encode({
|
|
4481
|
-
documentId: handle.documentId,
|
|
4482
|
-
objectId
|
|
4483
|
-
}),
|
|
4484
|
-
object,
|
|
4485
|
-
currentHash: heads.join("")
|
|
4486
|
-
};
|
|
4487
|
-
});
|
|
4488
|
-
}
|
|
4489
|
-
if (doc.links) {
|
|
4490
|
-
for (const id of Object.values(doc.links)) {
|
|
4491
|
-
if (visited.has(id)) {
|
|
4492
|
-
continue;
|
|
4493
|
-
}
|
|
4494
|
-
const linkHandle = automergeHost.repo.find(id);
|
|
4495
|
-
for await (const result of getObjectsFromHandle(linkHandle)) {
|
|
4496
|
-
yield result;
|
|
4497
|
-
}
|
|
4498
|
-
}
|
|
4499
|
-
}
|
|
4500
|
-
visited.add(handle.documentId);
|
|
4501
|
-
}
|
|
4502
|
-
for (const handle of Object.values(automergeHost.repo.handles)) {
|
|
4503
|
-
if (visited.has(handle.documentId)) {
|
|
4504
|
-
continue;
|
|
4505
|
-
}
|
|
4506
|
-
for await (const result of getObjectsFromHandle(handle)) {
|
|
4507
|
-
yield result;
|
|
4508
|
-
}
|
|
4509
|
-
visited.add(handle.documentId);
|
|
4510
|
-
}
|
|
4511
|
-
}
|
|
4512
|
-
);
|
|
4513
4534
|
function _ts_decorate6(decorators, target, key, desc) {
|
|
4514
4535
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4515
4536
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
@@ -4520,7 +4541,7 @@ function _ts_decorate6(decorators, target, key, desc) {
|
|
|
4520
4541
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
4521
4542
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4522
4543
|
}
|
|
4523
|
-
var
|
|
4544
|
+
var __dxlog_file14 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-context.ts";
|
|
4524
4545
|
var ServiceContext = class extends import_context10.Resource {
|
|
4525
4546
|
constructor(storage, level, networkManager, signalManager, _runtimeParams) {
|
|
4526
4547
|
super();
|
|
@@ -4531,9 +4552,9 @@ var ServiceContext = class extends import_context10.Resource {
|
|
|
4531
4552
|
this._runtimeParams = _runtimeParams;
|
|
4532
4553
|
this.initialized = new import_async15.Trigger();
|
|
4533
4554
|
this._handlerFactories = /* @__PURE__ */ new Map();
|
|
4534
|
-
this._instanceId =
|
|
4535
|
-
this.metadataStore = new
|
|
4536
|
-
this.snapshotStore = new
|
|
4555
|
+
this._instanceId = import_keys11.PublicKey.random().toHex();
|
|
4556
|
+
this.metadataStore = new import_echo_pipeline4.MetadataStore(storage.createDirectory("metadata"));
|
|
4557
|
+
this.snapshotStore = new import_echo_pipeline4.SnapshotStore(storage.createDirectory("snapshots"));
|
|
4537
4558
|
this.blobStore = new import_teleport_extension_object_sync.BlobStore(storage.createDirectory("blobs"));
|
|
4538
4559
|
this.keyring = new import_keyring.Keyring(storage.createDirectory("keyring"));
|
|
4539
4560
|
this.feedStore = new import_feed_store4.FeedStore({
|
|
@@ -4541,12 +4562,12 @@ var ServiceContext = class extends import_context10.Resource {
|
|
|
4541
4562
|
root: storage.createDirectory("feeds"),
|
|
4542
4563
|
signer: this.keyring,
|
|
4543
4564
|
hypercore: {
|
|
4544
|
-
valueEncoding:
|
|
4565
|
+
valueEncoding: import_echo_pipeline4.valueEncoding,
|
|
4545
4566
|
stats: true
|
|
4546
4567
|
}
|
|
4547
4568
|
})
|
|
4548
4569
|
});
|
|
4549
|
-
this.spaceManager = new
|
|
4570
|
+
this.spaceManager = new import_echo_pipeline4.SpaceManager({
|
|
4550
4571
|
feedStore: this.feedStore,
|
|
4551
4572
|
networkManager: this.networkManager,
|
|
4552
4573
|
blobStore: this.blobStore,
|
|
@@ -4554,66 +4575,66 @@ var ServiceContext = class extends import_context10.Resource {
|
|
|
4554
4575
|
snapshotStore: this.snapshotStore
|
|
4555
4576
|
});
|
|
4556
4577
|
this.identityManager = new IdentityManager(this.metadataStore, this.keyring, this.feedStore, this.spaceManager, this._runtimeParams);
|
|
4557
|
-
this.
|
|
4558
|
-
|
|
4559
|
-
|
|
4560
|
-
this.automergeHost = new import_echo_pipeline3.AutomergeHost({
|
|
4561
|
-
directory: storage.createDirectory("automerge"),
|
|
4562
|
-
metadata: this.indexMetadata
|
|
4563
|
-
});
|
|
4564
|
-
this.indexer = new import_indexing.Indexer({
|
|
4565
|
-
indexStore: new import_indexing.IndexStore({
|
|
4566
|
-
directory: storage.createDirectory("index-store")
|
|
4567
|
-
}),
|
|
4568
|
-
metadataStore: this.indexMetadata,
|
|
4569
|
-
loadDocuments: createSelectedDocumentsIterator(this.automergeHost),
|
|
4570
|
-
getAllDocuments: createDocumentsIterator(this.automergeHost)
|
|
4578
|
+
this.echoHost = new import_echo_db.EchoHost({
|
|
4579
|
+
kv: this.level,
|
|
4580
|
+
storage: this.storage
|
|
4571
4581
|
});
|
|
4572
4582
|
this.invitations = new InvitationsHandler(this.networkManager);
|
|
4573
|
-
this.
|
|
4583
|
+
this.invitationsManager = new InvitationsManager(this.invitations, (invitation) => this.getInvitationHandler(invitation), this.metadataStore);
|
|
4584
|
+
this._handlerFactories.set(import_services11.Invitation.Kind.DEVICE, () => new DeviceInvitationProtocol(this.keyring, () => this.identityManager.identity ?? (0, import_debug6.failUndefined)(), this._acceptIdentity.bind(this)));
|
|
4574
4585
|
}
|
|
4575
4586
|
async _open(ctx) {
|
|
4576
4587
|
await this._checkStorageVersion();
|
|
4577
4588
|
(0, import_log12.log)("opening...", void 0, {
|
|
4578
|
-
F:
|
|
4579
|
-
L:
|
|
4589
|
+
F: __dxlog_file14,
|
|
4590
|
+
L: 151,
|
|
4580
4591
|
S: this,
|
|
4581
4592
|
C: (f, a) => f(...a)
|
|
4582
4593
|
});
|
|
4583
|
-
import_log12.log.trace("dxos.sdk.service-context.open",
|
|
4594
|
+
import_log12.log.trace("dxos.sdk.service-context.open", import_protocols11.trace.begin({
|
|
4584
4595
|
id: this._instanceId
|
|
4585
4596
|
}), {
|
|
4586
|
-
F:
|
|
4587
|
-
L:
|
|
4597
|
+
F: __dxlog_file14,
|
|
4598
|
+
L: 152,
|
|
4588
4599
|
S: this,
|
|
4589
4600
|
C: (f, a) => f(...a)
|
|
4590
4601
|
});
|
|
4591
4602
|
await this.signalManager.open();
|
|
4592
4603
|
await this.networkManager.open();
|
|
4604
|
+
await this.echoHost.open(ctx);
|
|
4593
4605
|
await this.metadataStore.load();
|
|
4594
4606
|
await this.spaceManager.open();
|
|
4595
4607
|
await this.identityManager.open(ctx);
|
|
4596
4608
|
if (this.identityManager.identity) {
|
|
4597
4609
|
await this._initialize(ctx);
|
|
4598
4610
|
}
|
|
4599
|
-
|
|
4611
|
+
const loadedInvitations = await this.invitationsManager.loadPersistentInvitations();
|
|
4612
|
+
(0, import_log12.log)("loaded persistent invitations", {
|
|
4613
|
+
count: loadedInvitations.invitations?.length
|
|
4614
|
+
}, {
|
|
4615
|
+
F: __dxlog_file14,
|
|
4616
|
+
L: 165,
|
|
4617
|
+
S: this,
|
|
4618
|
+
C: (f, a) => f(...a)
|
|
4619
|
+
});
|
|
4620
|
+
import_log12.log.trace("dxos.sdk.service-context.open", import_protocols11.trace.end({
|
|
4600
4621
|
id: this._instanceId
|
|
4601
4622
|
}), {
|
|
4602
|
-
F:
|
|
4623
|
+
F: __dxlog_file14,
|
|
4603
4624
|
L: 167,
|
|
4604
4625
|
S: this,
|
|
4605
4626
|
C: (f, a) => f(...a)
|
|
4606
4627
|
});
|
|
4607
4628
|
(0, import_log12.log)("opened", void 0, {
|
|
4608
|
-
F:
|
|
4629
|
+
F: __dxlog_file14,
|
|
4609
4630
|
L: 168,
|
|
4610
4631
|
S: this,
|
|
4611
4632
|
C: (f, a) => f(...a)
|
|
4612
4633
|
});
|
|
4613
4634
|
}
|
|
4614
|
-
async _close() {
|
|
4635
|
+
async _close(ctx) {
|
|
4615
4636
|
(0, import_log12.log)("closing...", void 0, {
|
|
4616
|
-
F:
|
|
4637
|
+
F: __dxlog_file14,
|
|
4617
4638
|
L: 172,
|
|
4618
4639
|
S: this,
|
|
4619
4640
|
C: (f, a) => f(...a)
|
|
@@ -4621,18 +4642,17 @@ var ServiceContext = class extends import_context10.Resource {
|
|
|
4621
4642
|
if (this._deviceSpaceSync && this.identityManager.identity) {
|
|
4622
4643
|
await this.identityManager.identity.space.spaceState.removeCredentialProcessor(this._deviceSpaceSync);
|
|
4623
4644
|
}
|
|
4624
|
-
await this.automergeHost.close();
|
|
4625
4645
|
await this.dataSpaceManager?.close();
|
|
4626
4646
|
await this.identityManager.close();
|
|
4627
4647
|
await this.spaceManager.close();
|
|
4628
4648
|
await this.feedStore.close();
|
|
4649
|
+
await this.metadataStore.close();
|
|
4650
|
+
await this.echoHost.close(ctx);
|
|
4629
4651
|
await this.networkManager.close();
|
|
4630
4652
|
await this.signalManager.close();
|
|
4631
|
-
await this.metadataStore.close();
|
|
4632
|
-
await this.indexer.destroy();
|
|
4633
4653
|
(0, import_log12.log)("closed", void 0, {
|
|
4634
|
-
F:
|
|
4635
|
-
L:
|
|
4654
|
+
F: __dxlog_file14,
|
|
4655
|
+
L: 184,
|
|
4636
4656
|
S: this,
|
|
4637
4657
|
C: (f, a) => f(...a)
|
|
4638
4658
|
});
|
|
@@ -4644,9 +4664,9 @@ var ServiceContext = class extends import_context10.Resource {
|
|
|
4644
4664
|
}
|
|
4645
4665
|
getInvitationHandler(invitation) {
|
|
4646
4666
|
const factory = this._handlerFactories.get(invitation.kind);
|
|
4647
|
-
(0,
|
|
4648
|
-
F:
|
|
4649
|
-
L:
|
|
4667
|
+
(0, import_invariant13.invariant)(factory, `Unknown invitation kind: ${invitation.kind}`, {
|
|
4668
|
+
F: __dxlog_file14,
|
|
4669
|
+
L: 195,
|
|
4650
4670
|
S: this,
|
|
4651
4671
|
A: [
|
|
4652
4672
|
"factory",
|
|
@@ -4670,15 +4690,15 @@ var ServiceContext = class extends import_context10.Resource {
|
|
|
4670
4690
|
}
|
|
4671
4691
|
async _checkStorageVersion() {
|
|
4672
4692
|
await this.metadataStore.load();
|
|
4673
|
-
if (this.metadataStore.version !==
|
|
4674
|
-
throw new
|
|
4693
|
+
if (this.metadataStore.version !== import_protocols11.STORAGE_VERSION) {
|
|
4694
|
+
throw new import_protocols11.InvalidStorageVersionError(import_protocols11.STORAGE_VERSION, this.metadataStore.version);
|
|
4675
4695
|
}
|
|
4676
4696
|
}
|
|
4677
4697
|
// Called when identity is created.
|
|
4678
4698
|
async _initialize(ctx) {
|
|
4679
4699
|
(0, import_log12.log)("initializing spaces...", void 0, {
|
|
4680
|
-
F:
|
|
4681
|
-
L:
|
|
4700
|
+
F: __dxlog_file14,
|
|
4701
|
+
L: 226,
|
|
4682
4702
|
S: this,
|
|
4683
4703
|
C: (f, a) => f(...a)
|
|
4684
4704
|
});
|
|
@@ -4696,11 +4716,11 @@ var ServiceContext = class extends import_context10.Resource {
|
|
|
4696
4716
|
});
|
|
4697
4717
|
}
|
|
4698
4718
|
};
|
|
4699
|
-
this.dataSpaceManager = new DataSpaceManager(this.spaceManager, this.metadataStore, this.keyring, signingContext, this.feedStore, this.
|
|
4719
|
+
this.dataSpaceManager = new DataSpaceManager(this.spaceManager, this.metadataStore, this.keyring, signingContext, this.feedStore, this.echoHost, this.invitationsManager, this._runtimeParams);
|
|
4700
4720
|
await this.dataSpaceManager.open();
|
|
4701
|
-
this._handlerFactories.set(
|
|
4702
|
-
(0,
|
|
4703
|
-
F:
|
|
4721
|
+
this._handlerFactories.set(import_services11.Invitation.Kind.SPACE, (invitation) => {
|
|
4722
|
+
(0, import_invariant13.invariant)(this.dataSpaceManager, "dataSpaceManager not initialized yet", {
|
|
4723
|
+
F: __dxlog_file14,
|
|
4704
4724
|
L: 251,
|
|
4705
4725
|
S: this,
|
|
4706
4726
|
A: [
|
|
@@ -4724,7 +4744,7 @@ var ServiceContext = class extends import_context10.Resource {
|
|
|
4724
4744
|
(0, import_log12.log)("dataSpaceManager not initialized yet, ignoring space admission", {
|
|
4725
4745
|
details: assertion
|
|
4726
4746
|
}, {
|
|
4727
|
-
F:
|
|
4747
|
+
F: __dxlog_file14,
|
|
4728
4748
|
L: 267,
|
|
4729
4749
|
S: this,
|
|
4730
4750
|
C: (f, a) => f(...a)
|
|
@@ -4735,7 +4755,7 @@ var ServiceContext = class extends import_context10.Resource {
|
|
|
4735
4755
|
(0, import_log12.log)("space already exists, ignoring space admission", {
|
|
4736
4756
|
details: assertion
|
|
4737
4757
|
}, {
|
|
4738
|
-
F:
|
|
4758
|
+
F: __dxlog_file14,
|
|
4739
4759
|
L: 271,
|
|
4740
4760
|
S: this,
|
|
4741
4761
|
C: (f, a) => f(...a)
|
|
@@ -4746,7 +4766,7 @@ var ServiceContext = class extends import_context10.Resource {
|
|
|
4746
4766
|
(0, import_log12.log)("accepting space recorded in halo", {
|
|
4747
4767
|
details: assertion
|
|
4748
4768
|
}, {
|
|
4749
|
-
F:
|
|
4769
|
+
F: __dxlog_file14,
|
|
4750
4770
|
L: 276,
|
|
4751
4771
|
S: this,
|
|
4752
4772
|
C: (f, a) => f(...a)
|
|
@@ -4757,7 +4777,7 @@ var ServiceContext = class extends import_context10.Resource {
|
|
|
4757
4777
|
});
|
|
4758
4778
|
} catch (err) {
|
|
4759
4779
|
import_log12.log.catch(err, void 0, {
|
|
4760
|
-
F:
|
|
4780
|
+
F: __dxlog_file14,
|
|
4761
4781
|
L: 282,
|
|
4762
4782
|
S: this,
|
|
4763
4783
|
C: (f, a) => f(...a)
|
|
@@ -4769,14 +4789,14 @@ var ServiceContext = class extends import_context10.Resource {
|
|
|
4769
4789
|
}
|
|
4770
4790
|
};
|
|
4771
4791
|
_ts_decorate6([
|
|
4772
|
-
|
|
4792
|
+
import_tracing5.trace.span()
|
|
4773
4793
|
], ServiceContext.prototype, "_open", null);
|
|
4774
4794
|
_ts_decorate6([
|
|
4775
|
-
|
|
4795
|
+
import_tracing5.trace.span()
|
|
4776
4796
|
], ServiceContext.prototype, "_initialize", null);
|
|
4777
4797
|
ServiceContext = _ts_decorate6([
|
|
4778
4798
|
(0, import_util7.safeInstanceof)("dxos.client-services.ServiceContext"),
|
|
4779
|
-
|
|
4799
|
+
import_tracing5.trace.resource()
|
|
4780
4800
|
], ServiceContext);
|
|
4781
4801
|
var ServiceRegistry = class {
|
|
4782
4802
|
// prettier-ignore
|
|
@@ -4800,118 +4820,155 @@ var ServiceRegistry = class {
|
|
|
4800
4820
|
delete this._handlers[name];
|
|
4801
4821
|
}
|
|
4802
4822
|
};
|
|
4803
|
-
|
|
4804
|
-
|
|
4805
|
-
if (
|
|
4806
|
-
|
|
4807
|
-
|
|
4808
|
-
|
|
4809
|
-
|
|
4810
|
-
|
|
4811
|
-
|
|
4812
|
-
}
|
|
4813
|
-
|
|
4814
|
-
|
|
4815
|
-
|
|
4816
|
-
|
|
4817
|
-
|
|
4818
|
-
|
|
4819
|
-
}
|
|
4820
|
-
|
|
4821
|
-
return
|
|
4822
|
-
|
|
4823
|
-
|
|
4824
|
-
|
|
4825
|
-
|
|
4826
|
-
|
|
4827
|
-
|
|
4828
|
-
|
|
4829
|
-
});
|
|
4830
|
-
this._fileHandle = await import_lock_file.LockFile.acquire(this._lockPath);
|
|
4831
|
-
await this._onAcquire?.();
|
|
4832
|
-
(0, import_log13.log)("acquired lock", void 0, {
|
|
4833
|
-
F: __dxlog_file16,
|
|
4834
|
-
L: 37,
|
|
4835
|
-
S: this,
|
|
4836
|
-
C: (f, a) => f(...a)
|
|
4837
|
-
});
|
|
4838
|
-
}
|
|
4839
|
-
async release() {
|
|
4840
|
-
await this._onRelease?.();
|
|
4841
|
-
(0, import_invariant15.invariant)(this._fileHandle, "Lock is not acquired", {
|
|
4842
|
-
F: __dxlog_file16,
|
|
4843
|
-
L: 42,
|
|
4844
|
-
S: this,
|
|
4845
|
-
A: [
|
|
4846
|
-
"this._fileHandle",
|
|
4847
|
-
"'Lock is not acquired'"
|
|
4848
|
-
]
|
|
4849
|
-
});
|
|
4850
|
-
await import_lock_file.LockFile.release(this._fileHandle);
|
|
4823
|
+
var DXOS_VERSION = "0.4.10-main.36e0428";
|
|
4824
|
+
var getPlatform = () => {
|
|
4825
|
+
if (process.browser) {
|
|
4826
|
+
if (typeof window !== "undefined") {
|
|
4827
|
+
const { userAgent } = window.navigator;
|
|
4828
|
+
return {
|
|
4829
|
+
type: import_services13.Platform.PLATFORM_TYPE.BROWSER,
|
|
4830
|
+
userAgent,
|
|
4831
|
+
uptime: Math.floor((Date.now() - window.performance.timeOrigin) / 1e3)
|
|
4832
|
+
};
|
|
4833
|
+
} else {
|
|
4834
|
+
return {
|
|
4835
|
+
type: import_services13.Platform.PLATFORM_TYPE.SHARED_WORKER,
|
|
4836
|
+
uptime: Math.floor((Date.now() - performance.timeOrigin) / 1e3)
|
|
4837
|
+
};
|
|
4838
|
+
}
|
|
4839
|
+
} else {
|
|
4840
|
+
const { platform: platform2, version, arch } = process;
|
|
4841
|
+
return {
|
|
4842
|
+
type: import_services13.Platform.PLATFORM_TYPE.NODE,
|
|
4843
|
+
platform: platform2,
|
|
4844
|
+
arch,
|
|
4845
|
+
runtime: version,
|
|
4846
|
+
uptime: Math.floor(process.uptime()),
|
|
4847
|
+
memory: process.memoryUsage()
|
|
4848
|
+
};
|
|
4851
4849
|
}
|
|
4852
4850
|
};
|
|
4853
|
-
|
|
4854
|
-
|
|
4855
|
-
|
|
4856
|
-
|
|
4857
|
-
|
|
4858
|
-
|
|
4859
|
-
|
|
4860
|
-
|
|
4861
|
-
|
|
4862
|
-
|
|
4863
|
-
|
|
4864
|
-
}
|
|
4865
|
-
|
|
4866
|
-
|
|
4867
|
-
|
|
4868
|
-
|
|
4869
|
-
|
|
4851
|
+
var __dxlog_file15 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/diagnostics/diagnostics.ts";
|
|
4852
|
+
var DEFAULT_TIMEOUT = 1e3;
|
|
4853
|
+
var createDiagnostics = async (clientServices, serviceContext, config) => {
|
|
4854
|
+
const diagnostics = {
|
|
4855
|
+
created: (/* @__PURE__ */ new Date()).toISOString(),
|
|
4856
|
+
platform: getPlatform(),
|
|
4857
|
+
client: {
|
|
4858
|
+
version: DXOS_VERSION,
|
|
4859
|
+
storage: {
|
|
4860
|
+
version: import_protocols12.STORAGE_VERSION
|
|
4861
|
+
}
|
|
4862
|
+
},
|
|
4863
|
+
trace: import_tracing6.TRACE_PROCESSOR.getDiagnostics()
|
|
4864
|
+
};
|
|
4865
|
+
{
|
|
4866
|
+
(0, import_invariant14.invariant)(clientServices.LoggingService, "SystemService is not available.", {
|
|
4867
|
+
F: __dxlog_file15,
|
|
4868
|
+
L: 108,
|
|
4869
|
+
S: void 0,
|
|
4870
|
+
A: [
|
|
4871
|
+
"clientServices.LoggingService",
|
|
4872
|
+
"'SystemService is not available.'"
|
|
4873
|
+
]
|
|
4874
|
+
});
|
|
4875
|
+
diagnostics.metrics = await (0, import_codec_protobuf11.getFirstStreamValue)(clientServices.LoggingService.queryMetrics({}), {
|
|
4876
|
+
timeout: DEFAULT_TIMEOUT
|
|
4877
|
+
}).catch(() => void 0);
|
|
4870
4878
|
}
|
|
4871
|
-
if (
|
|
4872
|
-
|
|
4879
|
+
if (typeof navigator !== "undefined" && navigator.storage) {
|
|
4880
|
+
const map = /* @__PURE__ */ new Map();
|
|
4881
|
+
const dir = await navigator.storage.getDirectory();
|
|
4882
|
+
for await (const filename of dir?.keys()) {
|
|
4883
|
+
const idx = filename.indexOf("-", filename.indexOf("-") + 1);
|
|
4884
|
+
if (idx === -1) {
|
|
4885
|
+
continue;
|
|
4886
|
+
}
|
|
4887
|
+
map.set(filename.slice(0, idx), (map.get(filename.slice(0, idx)) ?? 0) + 1);
|
|
4888
|
+
}
|
|
4889
|
+
diagnostics.storage = Array.from(map.entries()).sort((a, b) => b[1] - a[1]).map(([file, count]) => ({
|
|
4890
|
+
file,
|
|
4891
|
+
count
|
|
4892
|
+
}));
|
|
4873
4893
|
}
|
|
4874
|
-
|
|
4875
|
-
|
|
4894
|
+
const identity = serviceContext.identityManager.identity;
|
|
4895
|
+
if (identity) {
|
|
4896
|
+
diagnostics.identity = {
|
|
4897
|
+
identityKey: identity.identityKey,
|
|
4898
|
+
spaceKey: identity.space.key,
|
|
4899
|
+
profile: identity.profileDocument
|
|
4900
|
+
};
|
|
4901
|
+
const { devices } = await (0, import_codec_protobuf11.getFirstStreamValue)(clientServices.DevicesService.queryDevices(), {
|
|
4902
|
+
timeout: DEFAULT_TIMEOUT
|
|
4903
|
+
}).catch(() => void 0) ?? {};
|
|
4904
|
+
diagnostics.devices = devices;
|
|
4905
|
+
if (serviceContext.dataSpaceManager) {
|
|
4906
|
+
diagnostics.spaces = await Promise.all(Array.from(serviceContext.dataSpaceManager.spaces.values()).map((space) => getSpaceStats(space)) ?? []);
|
|
4907
|
+
}
|
|
4908
|
+
const { feeds = [] } = await (0, import_codec_protobuf11.getFirstStreamValue)(clientServices.DevtoolsHost.subscribeToFeeds({}), {
|
|
4909
|
+
timeout: DEFAULT_TIMEOUT
|
|
4910
|
+
}).catch(() => void 0) ?? {};
|
|
4911
|
+
diagnostics.feeds = feeds.map(({ feedKey, bytes, length }) => ({
|
|
4912
|
+
feedKey,
|
|
4913
|
+
bytes,
|
|
4914
|
+
length
|
|
4915
|
+
}));
|
|
4916
|
+
const status = await (0, import_codec_protobuf11.getFirstStreamValue)(clientServices.NetworkService.queryStatus(), {
|
|
4917
|
+
timeout: DEFAULT_TIMEOUT
|
|
4918
|
+
}).catch(() => void 0);
|
|
4919
|
+
diagnostics.networkStatus = status;
|
|
4920
|
+
diagnostics.swarms = serviceContext.networkManager.connectionLog?.swarms;
|
|
4876
4921
|
}
|
|
4877
|
-
|
|
4878
|
-
|
|
4922
|
+
diagnostics.config = config.values;
|
|
4923
|
+
return diagnostics;
|
|
4924
|
+
};
|
|
4925
|
+
var getSpaceStats = async (space) => {
|
|
4926
|
+
const stats = {
|
|
4927
|
+
key: space.key,
|
|
4928
|
+
metrics: space.metrics,
|
|
4929
|
+
epochs: space.inner.spaceState.credentials.filter((0, import_credentials16.credentialTypeFilter)("dxos.halo.credentials.Epoch")).map((credential) => ({
|
|
4930
|
+
...credential.subject.assertion,
|
|
4931
|
+
id: credential.id
|
|
4932
|
+
})),
|
|
4933
|
+
members: Array.from(space.inner.spaceState.members.values()).map((member) => ({
|
|
4934
|
+
identity: {
|
|
4935
|
+
identityKey: member.key,
|
|
4936
|
+
profile: {
|
|
4937
|
+
displayName: member.assertion.profile?.displayName
|
|
4938
|
+
}
|
|
4939
|
+
},
|
|
4940
|
+
presence: space.presence.getPeersOnline().filter(({ identityKey }) => identityKey.equals(member.key)).length > 0 ? import_services12.SpaceMember.PresenceState.ONLINE : import_services12.SpaceMember.PresenceState.OFFLINE
|
|
4941
|
+
})),
|
|
4942
|
+
pipeline: {
|
|
4943
|
+
// TODO(burdon): Pick properties from credentials if needed.
|
|
4944
|
+
currentEpoch: space.automergeSpaceState.lastEpoch,
|
|
4945
|
+
appliedEpoch: space.automergeSpaceState.lastEpoch,
|
|
4946
|
+
controlFeeds: space.inner.controlPipeline.state.feeds.map((feed) => feed.key),
|
|
4947
|
+
currentControlTimeframe: space.inner.controlPipeline.state.timeframe,
|
|
4948
|
+
targetControlTimeframe: space.inner.controlPipeline.state.targetTimeframe,
|
|
4949
|
+
totalControlTimeframe: space.inner.controlPipeline.state.endTimeframe
|
|
4950
|
+
}
|
|
4951
|
+
};
|
|
4952
|
+
if (stats.metrics) {
|
|
4953
|
+
const { open, ready } = stats.metrics;
|
|
4954
|
+
stats.metrics.startupTime = open && ready && ready.getTime() - open.getTime();
|
|
4879
4955
|
}
|
|
4956
|
+
return stats;
|
|
4957
|
+
};
|
|
4958
|
+
var createCollectDiagnosticsBroadcastSender = () => {
|
|
4880
4959
|
return {
|
|
4881
|
-
|
|
4882
|
-
type: persistent ? toStorageType(dataStore) : import_random_access_storage.StorageType.RAM,
|
|
4883
|
-
root: getRootPath(config)
|
|
4884
|
-
})
|
|
4960
|
+
broadcastDiagnosticsRequest: async () => void 0
|
|
4885
4961
|
};
|
|
4886
4962
|
};
|
|
4887
|
-
var
|
|
4888
|
-
|
|
4889
|
-
|
|
4890
|
-
|
|
4891
|
-
|
|
4892
|
-
|
|
4893
|
-
|
|
4894
|
-
return import_random_access_storage.StorageType.CHROME;
|
|
4895
|
-
case StorageDriver.FIREFOX:
|
|
4896
|
-
return import_random_access_storage.StorageType.FIREFOX;
|
|
4897
|
-
case StorageDriver.IDB:
|
|
4898
|
-
return import_random_access_storage.StorageType.IDB;
|
|
4899
|
-
case StorageDriver.NODE:
|
|
4900
|
-
return import_random_access_storage.StorageType.NODE;
|
|
4901
|
-
case StorageDriver.WEBFS:
|
|
4902
|
-
return import_random_access_storage.StorageType.WEBFS;
|
|
4903
|
-
default:
|
|
4904
|
-
throw new Error(`Invalid storage type: ${StorageDriver[type]}`);
|
|
4905
|
-
}
|
|
4906
|
-
};
|
|
4907
|
-
var createLevel = async (config) => {
|
|
4908
|
-
const persistent = isPersistent(config);
|
|
4909
|
-
const storagePath = persistent ? getRootPath(config) : import_node_path.default.join("tmp", "level", import_keys11.PublicKey.random().toHex());
|
|
4910
|
-
const level = new import_level.Level(storagePath);
|
|
4911
|
-
await level.open();
|
|
4912
|
-
return level;
|
|
4963
|
+
var createCollectDiagnosticsBroadcastHandler = (_) => {
|
|
4964
|
+
return {
|
|
4965
|
+
start: () => {
|
|
4966
|
+
},
|
|
4967
|
+
stop: () => {
|
|
4968
|
+
}
|
|
4969
|
+
};
|
|
4913
4970
|
};
|
|
4914
|
-
var
|
|
4971
|
+
var __dxlog_file16 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/devices/devices-service.ts";
|
|
4915
4972
|
var DevicesServiceImpl = class {
|
|
4916
4973
|
constructor(_identityManager) {
|
|
4917
4974
|
this._identityManager = _identityManager;
|
|
@@ -4928,8 +4985,8 @@ var DevicesServiceImpl = class {
|
|
|
4928
4985
|
devices: []
|
|
4929
4986
|
});
|
|
4930
4987
|
} else {
|
|
4931
|
-
(0,
|
|
4932
|
-
F:
|
|
4988
|
+
(0, import_invariant16.invariant)(this._identityManager.identity?.presence, "presence not present", {
|
|
4989
|
+
F: __dxlog_file16,
|
|
4933
4990
|
L: 32,
|
|
4934
4991
|
S: this,
|
|
4935
4992
|
A: [
|
|
@@ -4944,9 +5001,9 @@ var DevicesServiceImpl = class {
|
|
|
4944
5001
|
const peerState = peers.find((peer) => peer.identityKey.equals(key));
|
|
4945
5002
|
return {
|
|
4946
5003
|
deviceKey: key,
|
|
4947
|
-
kind: this._identityManager.identity?.deviceKey.equals(key) ?
|
|
5004
|
+
kind: this._identityManager.identity?.deviceKey.equals(key) ? import_services16.DeviceKind.CURRENT : import_services16.DeviceKind.TRUSTED,
|
|
4948
5005
|
profile,
|
|
4949
|
-
presence: isMe ?
|
|
5006
|
+
presence: isMe ? import_services16.Device.PresenceState.ONLINE : peerState ? import_services16.Device.PresenceState.ONLINE : import_services16.Device.PresenceState.OFFLINE
|
|
4950
5007
|
};
|
|
4951
5008
|
})
|
|
4952
5009
|
});
|
|
@@ -4987,6 +5044,60 @@ var DevicesServiceImpl = class {
|
|
|
4987
5044
|
});
|
|
4988
5045
|
}
|
|
4989
5046
|
};
|
|
5047
|
+
function _ts_decorate7(decorators, target, key, desc) {
|
|
5048
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
5049
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
5050
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
5051
|
+
else
|
|
5052
|
+
for (var i = decorators.length - 1; i >= 0; i--)
|
|
5053
|
+
if (d = decorators[i])
|
|
5054
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5055
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
5056
|
+
}
|
|
5057
|
+
var __dxlog_file17 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/locks/node.ts";
|
|
5058
|
+
var Lock = class {
|
|
5059
|
+
constructor({ lockKey: lockPath, onAcquire, onRelease }) {
|
|
5060
|
+
this._lockPath = lockPath;
|
|
5061
|
+
this._onAcquire = onAcquire;
|
|
5062
|
+
this._onRelease = onRelease;
|
|
5063
|
+
}
|
|
5064
|
+
get lockKey() {
|
|
5065
|
+
return this._lockPath;
|
|
5066
|
+
}
|
|
5067
|
+
async acquire() {
|
|
5068
|
+
(0, import_log14.log)("acquiring lock...", void 0, {
|
|
5069
|
+
F: __dxlog_file17,
|
|
5070
|
+
L: 32,
|
|
5071
|
+
S: this,
|
|
5072
|
+
C: (f, a) => f(...a)
|
|
5073
|
+
});
|
|
5074
|
+
this._fileHandle = await import_lock_file.LockFile.acquire(this._lockPath);
|
|
5075
|
+
await this._onAcquire?.();
|
|
5076
|
+
(0, import_log14.log)("acquired lock", void 0, {
|
|
5077
|
+
F: __dxlog_file17,
|
|
5078
|
+
L: 37,
|
|
5079
|
+
S: this,
|
|
5080
|
+
C: (f, a) => f(...a)
|
|
5081
|
+
});
|
|
5082
|
+
}
|
|
5083
|
+
async release() {
|
|
5084
|
+
await this._onRelease?.();
|
|
5085
|
+
(0, import_invariant17.invariant)(this._fileHandle, "Lock is not acquired", {
|
|
5086
|
+
F: __dxlog_file17,
|
|
5087
|
+
L: 42,
|
|
5088
|
+
S: this,
|
|
5089
|
+
A: [
|
|
5090
|
+
"this._fileHandle",
|
|
5091
|
+
"'Lock is not acquired'"
|
|
5092
|
+
]
|
|
5093
|
+
});
|
|
5094
|
+
await import_lock_file.LockFile.release(this._fileHandle);
|
|
5095
|
+
}
|
|
5096
|
+
};
|
|
5097
|
+
_ts_decorate7([
|
|
5098
|
+
import_log14.logInfo
|
|
5099
|
+
], Lock.prototype, "lockKey", null);
|
|
5100
|
+
var isLocked = (lockPath) => import_lock_file.LockFile.isLocked(lockPath);
|
|
4990
5101
|
var LoggingServiceImpl = class {
|
|
4991
5102
|
constructor() {
|
|
4992
5103
|
this._logs = new import_async18.Event();
|
|
@@ -5088,16 +5199,16 @@ var LoggingServiceImpl = class {
|
|
|
5088
5199
|
};
|
|
5089
5200
|
var matchFilter = (filter, level, path2, options) => {
|
|
5090
5201
|
switch (options) {
|
|
5091
|
-
case
|
|
5202
|
+
case import_services17.QueryLogsRequest.MatchingOptions.INCLUSIVE:
|
|
5092
5203
|
return level >= filter.level && (!filter.pattern || path2.includes(filter.pattern));
|
|
5093
|
-
case
|
|
5204
|
+
case import_services17.QueryLogsRequest.MatchingOptions.EXPLICIT:
|
|
5094
5205
|
return level === filter.level && (!filter.pattern || path2.includes(filter.pattern));
|
|
5095
5206
|
}
|
|
5096
5207
|
};
|
|
5097
5208
|
var shouldLog = (entry2, request) => {
|
|
5098
|
-
const options = request.options ??
|
|
5209
|
+
const options = request.options ?? import_services17.QueryLogsRequest.MatchingOptions.INCLUSIVE;
|
|
5099
5210
|
if (request.filters === void 0) {
|
|
5100
|
-
return options ===
|
|
5211
|
+
return options === import_services17.QueryLogsRequest.MatchingOptions.INCLUSIVE;
|
|
5101
5212
|
} else {
|
|
5102
5213
|
return request.filters.some((filter) => matchFilter(filter, entry2.level, entry2.meta?.F ?? "", options));
|
|
5103
5214
|
}
|
|
@@ -5133,6 +5244,63 @@ var NetworkServiceImpl = class {
|
|
|
5133
5244
|
await this.networkManager.setConnectionState(request.swarm);
|
|
5134
5245
|
}
|
|
5135
5246
|
};
|
|
5247
|
+
var getRootPath = (config) => {
|
|
5248
|
+
const { dataRoot = (0, import_util11.isNode)() ? import_client_protocol6.DX_DATA : "dxos/storage" } = config ?? {};
|
|
5249
|
+
return `${dataRoot}/`;
|
|
5250
|
+
};
|
|
5251
|
+
var isPersistent = (config) => {
|
|
5252
|
+
const { persistent = false } = config ?? {};
|
|
5253
|
+
return config.dataStore !== void 0 && config.dataStore !== import_config3.Runtime.Client.Storage.StorageDriver.RAM || persistent;
|
|
5254
|
+
};
|
|
5255
|
+
var StorageDriver = import_config2.Runtime.Client.Storage.StorageDriver;
|
|
5256
|
+
var createStorageObjects = (config) => {
|
|
5257
|
+
const { persistent = false, keyStore, dataStore } = config ?? {};
|
|
5258
|
+
if (persistent && dataStore === StorageDriver.RAM) {
|
|
5259
|
+
throw new import_protocols14.InvalidConfigError("RAM storage cannot be used in persistent mode.");
|
|
5260
|
+
}
|
|
5261
|
+
if (!persistent && dataStore !== void 0 && dataStore !== StorageDriver.RAM) {
|
|
5262
|
+
throw new import_protocols14.InvalidConfigError("Cannot use a persistent storage in not persistent mode.");
|
|
5263
|
+
}
|
|
5264
|
+
if (persistent && keyStore === StorageDriver.RAM) {
|
|
5265
|
+
throw new import_protocols14.InvalidConfigError("RAM key storage cannot be used in persistent mode.");
|
|
5266
|
+
}
|
|
5267
|
+
if (!persistent && keyStore !== StorageDriver.RAM && keyStore !== void 0) {
|
|
5268
|
+
throw new import_protocols14.InvalidConfigError("Cannot use a persistent key storage in not persistent mode.");
|
|
5269
|
+
}
|
|
5270
|
+
return {
|
|
5271
|
+
storage: (0, import_random_access_storage.createStorage)({
|
|
5272
|
+
type: persistent ? toStorageType(dataStore) : import_random_access_storage.StorageType.RAM,
|
|
5273
|
+
root: getRootPath(config)
|
|
5274
|
+
})
|
|
5275
|
+
};
|
|
5276
|
+
};
|
|
5277
|
+
var toStorageType = (type) => {
|
|
5278
|
+
switch (type) {
|
|
5279
|
+
case void 0:
|
|
5280
|
+
return void 0;
|
|
5281
|
+
case StorageDriver.RAM:
|
|
5282
|
+
return import_random_access_storage.StorageType.RAM;
|
|
5283
|
+
case StorageDriver.CHROME:
|
|
5284
|
+
return import_random_access_storage.StorageType.CHROME;
|
|
5285
|
+
case StorageDriver.FIREFOX:
|
|
5286
|
+
return import_random_access_storage.StorageType.FIREFOX;
|
|
5287
|
+
case StorageDriver.IDB:
|
|
5288
|
+
return import_random_access_storage.StorageType.IDB;
|
|
5289
|
+
case StorageDriver.NODE:
|
|
5290
|
+
return import_random_access_storage.StorageType.NODE;
|
|
5291
|
+
case StorageDriver.WEBFS:
|
|
5292
|
+
return import_random_access_storage.StorageType.WEBFS;
|
|
5293
|
+
default:
|
|
5294
|
+
throw new Error(`Invalid storage type: ${StorageDriver[type]}`);
|
|
5295
|
+
}
|
|
5296
|
+
};
|
|
5297
|
+
var createLevel = async (config) => {
|
|
5298
|
+
const persistent = isPersistent(config);
|
|
5299
|
+
const storagePath = persistent ? import_node_path.default.join(getRootPath(config), "level") : `/tmp/dxos-${import_keys14.PublicKey.random().toHex()}`;
|
|
5300
|
+
const level = new import_level.Level(storagePath);
|
|
5301
|
+
await level.open();
|
|
5302
|
+
return level;
|
|
5303
|
+
};
|
|
5136
5304
|
var SystemServiceImpl = class {
|
|
5137
5305
|
constructor({ config, statusUpdate, getDiagnostics, onUpdateStatus, getCurrentStatus, onReset }) {
|
|
5138
5306
|
this._config = config;
|
|
@@ -5152,9 +5320,9 @@ var SystemServiceImpl = class {
|
|
|
5152
5320
|
const diagnostics = await this._getDiagnostics();
|
|
5153
5321
|
return {
|
|
5154
5322
|
timestamp: /* @__PURE__ */ new Date(),
|
|
5155
|
-
diagnostics: JSON.parse(JSON.stringify(diagnostics, (0,
|
|
5156
|
-
truncate: keys ===
|
|
5157
|
-
humanize: keys ===
|
|
5323
|
+
diagnostics: JSON.parse(JSON.stringify(diagnostics, (0, import_util12.jsonKeyReplacer)({
|
|
5324
|
+
truncate: keys === import_services18.GetDiagnosticsRequest.KEY_OPTION.TRUNCATE,
|
|
5325
|
+
humanize: keys === import_services18.GetDiagnosticsRequest.KEY_OPTION.HUMANIZE
|
|
5158
5326
|
})))
|
|
5159
5327
|
};
|
|
5160
5328
|
}
|
|
@@ -5202,16 +5370,18 @@ var ClientServicesHost = class {
|
|
|
5202
5370
|
transportFactory,
|
|
5203
5371
|
signalManager,
|
|
5204
5372
|
storage,
|
|
5373
|
+
level,
|
|
5205
5374
|
// TODO(wittjosiah): Turn this on by default.
|
|
5206
5375
|
lockKey,
|
|
5207
5376
|
callbacks,
|
|
5208
5377
|
runtimeParams
|
|
5209
5378
|
} = {}) {
|
|
5210
|
-
this._tracingService =
|
|
5379
|
+
this._tracingService = import_tracing8.TRACE_PROCESSOR.createTraceSender();
|
|
5211
5380
|
this._statusUpdate = new import_async16.Event();
|
|
5212
5381
|
this._opening = false;
|
|
5213
5382
|
this._open = false;
|
|
5214
5383
|
this._storage = storage;
|
|
5384
|
+
this._level = level;
|
|
5215
5385
|
this._callbacks = callbacks;
|
|
5216
5386
|
this._runtimeParams = runtimeParams;
|
|
5217
5387
|
if (config) {
|
|
@@ -5235,14 +5405,14 @@ var ClientServicesHost = class {
|
|
|
5235
5405
|
this._systemService = new SystemServiceImpl({
|
|
5236
5406
|
config: () => this._config,
|
|
5237
5407
|
statusUpdate: this._statusUpdate,
|
|
5238
|
-
getCurrentStatus: () => this.isOpen ?
|
|
5408
|
+
getCurrentStatus: () => this.isOpen ? import_services15.SystemStatus.ACTIVE : import_services15.SystemStatus.INACTIVE,
|
|
5239
5409
|
getDiagnostics: () => {
|
|
5240
5410
|
return createDiagnostics(this._serviceRegistry.services, this._serviceContext, this._config);
|
|
5241
5411
|
},
|
|
5242
5412
|
onUpdateStatus: async (status) => {
|
|
5243
|
-
if (!this.isOpen && status ===
|
|
5413
|
+
if (!this.isOpen && status === import_services15.SystemStatus.ACTIVE) {
|
|
5244
5414
|
await this._resourceLock?.acquire();
|
|
5245
|
-
} else if (this.isOpen && status ===
|
|
5415
|
+
} else if (this.isOpen && status === import_services15.SystemStatus.INACTIVE) {
|
|
5246
5416
|
await this._resourceLock?.release();
|
|
5247
5417
|
}
|
|
5248
5418
|
},
|
|
@@ -5250,6 +5420,7 @@ var ClientServicesHost = class {
|
|
|
5250
5420
|
await this.reset();
|
|
5251
5421
|
}
|
|
5252
5422
|
});
|
|
5423
|
+
this.diagnosticsBroadcastHandler = createCollectDiagnosticsBroadcastHandler(this._systemService);
|
|
5253
5424
|
this._loggingService = new LoggingServiceImpl();
|
|
5254
5425
|
this._serviceRegistry = new ServiceRegistry(import_client_protocol5.clientServiceBundle, {
|
|
5255
5426
|
SystemService: this._systemService,
|
|
@@ -5280,25 +5451,25 @@ var ClientServicesHost = class {
|
|
|
5280
5451
|
* Can only be called once.
|
|
5281
5452
|
*/
|
|
5282
5453
|
initialize({ config, ...options }) {
|
|
5283
|
-
(0,
|
|
5454
|
+
(0, import_invariant15.invariant)(!this._open, "service host is open", {
|
|
5284
5455
|
F: __dxlog_file18,
|
|
5285
|
-
L:
|
|
5456
|
+
L: 190,
|
|
5286
5457
|
S: this,
|
|
5287
5458
|
A: [
|
|
5288
5459
|
"!this._open",
|
|
5289
5460
|
"'service host is open'"
|
|
5290
5461
|
]
|
|
5291
5462
|
});
|
|
5292
|
-
(0,
|
|
5463
|
+
(0, import_log13.log)("initializing...", void 0, {
|
|
5293
5464
|
F: __dxlog_file18,
|
|
5294
|
-
L:
|
|
5465
|
+
L: 191,
|
|
5295
5466
|
S: this,
|
|
5296
5467
|
C: (f, a) => f(...a)
|
|
5297
5468
|
});
|
|
5298
5469
|
if (config) {
|
|
5299
|
-
(0,
|
|
5470
|
+
(0, import_invariant15.invariant)(!this._config, "config already set", {
|
|
5300
5471
|
F: __dxlog_file18,
|
|
5301
|
-
L:
|
|
5472
|
+
L: 194,
|
|
5302
5473
|
S: this,
|
|
5303
5474
|
A: [
|
|
5304
5475
|
"!this._config",
|
|
@@ -5311,9 +5482,9 @@ var ClientServicesHost = class {
|
|
|
5311
5482
|
}
|
|
5312
5483
|
}
|
|
5313
5484
|
if (!options.signalManager) {
|
|
5314
|
-
|
|
5485
|
+
import_log13.log.warn("running signaling without telemetry metadata.", void 0, {
|
|
5315
5486
|
F: __dxlog_file18,
|
|
5316
|
-
L:
|
|
5487
|
+
L: 202,
|
|
5317
5488
|
S: this,
|
|
5318
5489
|
C: (f, a) => f(...a)
|
|
5319
5490
|
});
|
|
@@ -5322,9 +5493,9 @@ var ClientServicesHost = class {
|
|
|
5322
5493
|
iceServers: this._config?.get("runtime.services.ice")
|
|
5323
5494
|
}), signalManager = new import_messaging.WebsocketSignalManager(this._config?.get("runtime.services.signaling") ?? []) } = options;
|
|
5324
5495
|
this._signalManager = signalManager;
|
|
5325
|
-
(0,
|
|
5496
|
+
(0, import_invariant15.invariant)(!this._networkManager, "network manager already set", {
|
|
5326
5497
|
F: __dxlog_file18,
|
|
5327
|
-
L:
|
|
5498
|
+
L: 213,
|
|
5328
5499
|
S: this,
|
|
5329
5500
|
A: [
|
|
5330
5501
|
"!this._networkManager",
|
|
@@ -5336,9 +5507,9 @@ var ClientServicesHost = class {
|
|
|
5336
5507
|
transportFactory,
|
|
5337
5508
|
signalManager
|
|
5338
5509
|
});
|
|
5339
|
-
(0,
|
|
5510
|
+
(0, import_log13.log)("initialized", void 0, {
|
|
5340
5511
|
F: __dxlog_file18,
|
|
5341
|
-
L:
|
|
5512
|
+
L: 220,
|
|
5342
5513
|
S: this,
|
|
5343
5514
|
C: (f, a) => f(...a)
|
|
5344
5515
|
});
|
|
@@ -5348,44 +5519,44 @@ var ClientServicesHost = class {
|
|
|
5348
5519
|
return;
|
|
5349
5520
|
}
|
|
5350
5521
|
const traceId = import_keys12.PublicKey.random().toHex();
|
|
5351
|
-
|
|
5522
|
+
import_log13.log.trace("dxos.client-services.host.open", import_protocols13.trace.begin({
|
|
5352
5523
|
id: traceId
|
|
5353
5524
|
}), {
|
|
5354
5525
|
F: __dxlog_file18,
|
|
5355
|
-
L:
|
|
5526
|
+
L: 231,
|
|
5356
5527
|
S: this,
|
|
5357
5528
|
C: (f, a) => f(...a)
|
|
5358
5529
|
});
|
|
5359
|
-
(0,
|
|
5530
|
+
(0, import_invariant15.invariant)(this._config, "config not set", {
|
|
5360
5531
|
F: __dxlog_file18,
|
|
5361
|
-
L:
|
|
5532
|
+
L: 233,
|
|
5362
5533
|
S: this,
|
|
5363
5534
|
A: [
|
|
5364
5535
|
"this._config",
|
|
5365
5536
|
"'config not set'"
|
|
5366
5537
|
]
|
|
5367
5538
|
});
|
|
5368
|
-
(0,
|
|
5539
|
+
(0, import_invariant15.invariant)(this._storage, "storage not set", {
|
|
5369
5540
|
F: __dxlog_file18,
|
|
5370
|
-
L:
|
|
5541
|
+
L: 234,
|
|
5371
5542
|
S: this,
|
|
5372
5543
|
A: [
|
|
5373
5544
|
"this._storage",
|
|
5374
5545
|
"'storage not set'"
|
|
5375
5546
|
]
|
|
5376
5547
|
});
|
|
5377
|
-
(0,
|
|
5548
|
+
(0, import_invariant15.invariant)(this._signalManager, "signal manager not set", {
|
|
5378
5549
|
F: __dxlog_file18,
|
|
5379
|
-
L:
|
|
5550
|
+
L: 235,
|
|
5380
5551
|
S: this,
|
|
5381
5552
|
A: [
|
|
5382
5553
|
"this._signalManager",
|
|
5383
5554
|
"'signal manager not set'"
|
|
5384
5555
|
]
|
|
5385
5556
|
});
|
|
5386
|
-
(0,
|
|
5557
|
+
(0, import_invariant15.invariant)(this._networkManager, "network manager not set", {
|
|
5387
5558
|
F: __dxlog_file18,
|
|
5388
|
-
L:
|
|
5559
|
+
L: 236,
|
|
5389
5560
|
S: this,
|
|
5390
5561
|
A: [
|
|
5391
5562
|
"this._networkManager",
|
|
@@ -5393,34 +5564,32 @@ var ClientServicesHost = class {
|
|
|
5393
5564
|
]
|
|
5394
5565
|
});
|
|
5395
5566
|
this._opening = true;
|
|
5396
|
-
(0,
|
|
5567
|
+
(0, import_log13.log)("opening...", {
|
|
5397
5568
|
lockKey: this._resourceLock?.lockKey
|
|
5398
5569
|
}, {
|
|
5399
5570
|
F: __dxlog_file18,
|
|
5400
|
-
L:
|
|
5571
|
+
L: 239,
|
|
5401
5572
|
S: this,
|
|
5402
5573
|
C: (f, a) => f(...a)
|
|
5403
5574
|
});
|
|
5404
5575
|
if (!this._level) {
|
|
5405
5576
|
this._level = await createLevel(this._config.get("runtime.client.storage", {}));
|
|
5406
5577
|
}
|
|
5578
|
+
await this._level.open();
|
|
5407
5579
|
await this._resourceLock?.acquire();
|
|
5408
5580
|
await this._loggingService.open();
|
|
5409
5581
|
this._serviceContext = new ServiceContext(this._storage, this._level, this._networkManager, this._signalManager, this._runtimeParams);
|
|
5410
5582
|
this._serviceRegistry.setServices({
|
|
5411
5583
|
SystemService: this._systemService,
|
|
5412
5584
|
IdentityService: new IdentityServiceImpl((params) => this._createIdentity(params), this._serviceContext.identityManager, this._serviceContext.keyring, (profile) => this._serviceContext.broadcastProfileUpdate(profile)),
|
|
5413
|
-
InvitationsService: new InvitationsServiceImpl(this._serviceContext.
|
|
5585
|
+
InvitationsService: new InvitationsServiceImpl(this._serviceContext.invitationsManager),
|
|
5414
5586
|
DevicesService: new DevicesServiceImpl(this._serviceContext.identityManager),
|
|
5415
5587
|
SpacesService: new SpacesServiceImpl(this._serviceContext.identityManager, this._serviceContext.spaceManager, async () => {
|
|
5416
5588
|
await this._serviceContext.initialized.wait();
|
|
5417
5589
|
return this._serviceContext.dataSpaceManager;
|
|
5418
5590
|
}),
|
|
5419
|
-
DataService:
|
|
5420
|
-
|
|
5421
|
-
indexer: this._serviceContext.indexer,
|
|
5422
|
-
automergeHost: this._serviceContext.automergeHost
|
|
5423
|
-
}),
|
|
5591
|
+
DataService: this._serviceContext.echoHost.dataService,
|
|
5592
|
+
QueryService: this._serviceContext.echoHost.queryService,
|
|
5424
5593
|
NetworkService: new NetworkServiceImpl(this._serviceContext.networkManager, this._serviceContext.signalManager),
|
|
5425
5594
|
LoggingService: this._loggingService,
|
|
5426
5595
|
TracingService: this._tracingService,
|
|
@@ -5432,24 +5601,6 @@ var ClientServicesHost = class {
|
|
|
5432
5601
|
})
|
|
5433
5602
|
});
|
|
5434
5603
|
await this._serviceContext.open(ctx);
|
|
5435
|
-
(0, import_invariant16.invariant)(this.serviceRegistry.services.InvitationsService, void 0, {
|
|
5436
|
-
F: __dxlog_file18,
|
|
5437
|
-
L: 297,
|
|
5438
|
-
S: this,
|
|
5439
|
-
A: [
|
|
5440
|
-
"this.serviceRegistry.services.InvitationsService",
|
|
5441
|
-
""
|
|
5442
|
-
]
|
|
5443
|
-
});
|
|
5444
|
-
const loadedInvitations = await this.serviceRegistry.services.InvitationsService.loadPersistentInvitations();
|
|
5445
|
-
(0, import_log14.log)("loaded persistent invitations", {
|
|
5446
|
-
count: loadedInvitations.invitations?.length
|
|
5447
|
-
}, {
|
|
5448
|
-
F: __dxlog_file18,
|
|
5449
|
-
L: 300,
|
|
5450
|
-
S: this,
|
|
5451
|
-
C: (f, a) => f(...a)
|
|
5452
|
-
});
|
|
5453
5604
|
const devtoolsProxy = this._config?.get("runtime.client.devtoolsProxy");
|
|
5454
5605
|
if (devtoolsProxy) {
|
|
5455
5606
|
this._devtoolsProxy = new import_websocket_rpc.WebsocketRpcClient({
|
|
@@ -5460,23 +5611,24 @@ var ClientServicesHost = class {
|
|
|
5460
5611
|
});
|
|
5461
5612
|
void this._devtoolsProxy.open();
|
|
5462
5613
|
}
|
|
5614
|
+
this.diagnosticsBroadcastHandler.start();
|
|
5463
5615
|
this._opening = false;
|
|
5464
5616
|
this._open = true;
|
|
5465
5617
|
this._statusUpdate.emit();
|
|
5466
5618
|
const deviceKey = this._serviceContext.identityManager.identity?.deviceKey;
|
|
5467
|
-
(0,
|
|
5619
|
+
(0, import_log13.log)("opened", {
|
|
5468
5620
|
deviceKey
|
|
5469
5621
|
}, {
|
|
5470
5622
|
F: __dxlog_file18,
|
|
5471
|
-
L:
|
|
5623
|
+
L: 315,
|
|
5472
5624
|
S: this,
|
|
5473
5625
|
C: (f, a) => f(...a)
|
|
5474
5626
|
});
|
|
5475
|
-
|
|
5627
|
+
import_log13.log.trace("dxos.client-services.host.open", import_protocols13.trace.end({
|
|
5476
5628
|
id: traceId
|
|
5477
5629
|
}), {
|
|
5478
5630
|
F: __dxlog_file18,
|
|
5479
|
-
L:
|
|
5631
|
+
L: 316,
|
|
5480
5632
|
S: this,
|
|
5481
5633
|
C: (f, a) => f(...a)
|
|
5482
5634
|
});
|
|
@@ -5486,14 +5638,15 @@ var ClientServicesHost = class {
|
|
|
5486
5638
|
return;
|
|
5487
5639
|
}
|
|
5488
5640
|
const deviceKey = this._serviceContext.identityManager.identity?.deviceKey;
|
|
5489
|
-
(0,
|
|
5641
|
+
(0, import_log13.log)("closing...", {
|
|
5490
5642
|
deviceKey
|
|
5491
5643
|
}, {
|
|
5492
5644
|
F: __dxlog_file18,
|
|
5493
|
-
L:
|
|
5645
|
+
L: 327,
|
|
5494
5646
|
S: this,
|
|
5495
5647
|
C: (f, a) => f(...a)
|
|
5496
5648
|
});
|
|
5649
|
+
this.diagnosticsBroadcastHandler.stop();
|
|
5497
5650
|
await this._devtoolsProxy?.close();
|
|
5498
5651
|
this._serviceRegistry.setServices({
|
|
5499
5652
|
SystemService: this._systemService
|
|
@@ -5503,44 +5656,44 @@ var ClientServicesHost = class {
|
|
|
5503
5656
|
await this._level?.close();
|
|
5504
5657
|
this._open = false;
|
|
5505
5658
|
this._statusUpdate.emit();
|
|
5506
|
-
(0,
|
|
5659
|
+
(0, import_log13.log)("closed", {
|
|
5507
5660
|
deviceKey
|
|
5508
5661
|
}, {
|
|
5509
5662
|
F: __dxlog_file18,
|
|
5510
|
-
L:
|
|
5663
|
+
L: 336,
|
|
5511
5664
|
S: this,
|
|
5512
5665
|
C: (f, a) => f(...a)
|
|
5513
5666
|
});
|
|
5514
5667
|
}
|
|
5515
5668
|
async reset() {
|
|
5516
5669
|
const traceId = import_keys12.PublicKey.random().toHex();
|
|
5517
|
-
|
|
5670
|
+
import_log13.log.trace("dxos.sdk.client-services-host.reset", import_protocols13.trace.begin({
|
|
5518
5671
|
id: traceId
|
|
5519
5672
|
}), {
|
|
5520
5673
|
F: __dxlog_file18,
|
|
5521
|
-
L:
|
|
5674
|
+
L: 341,
|
|
5522
5675
|
S: this,
|
|
5523
5676
|
C: (f, a) => f(...a)
|
|
5524
5677
|
});
|
|
5525
|
-
(0,
|
|
5678
|
+
(0, import_log13.log)("resetting...", void 0, {
|
|
5526
5679
|
F: __dxlog_file18,
|
|
5527
|
-
L:
|
|
5680
|
+
L: 343,
|
|
5528
5681
|
S: this,
|
|
5529
5682
|
C: (f, a) => f(...a)
|
|
5530
5683
|
});
|
|
5531
5684
|
await this._serviceContext?.close();
|
|
5532
5685
|
await this._storage.reset();
|
|
5533
|
-
(0,
|
|
5686
|
+
(0, import_log13.log)("reset", void 0, {
|
|
5534
5687
|
F: __dxlog_file18,
|
|
5535
|
-
L:
|
|
5688
|
+
L: 346,
|
|
5536
5689
|
S: this,
|
|
5537
5690
|
C: (f, a) => f(...a)
|
|
5538
5691
|
});
|
|
5539
|
-
|
|
5692
|
+
import_log13.log.trace("dxos.sdk.client-services-host.reset", import_protocols13.trace.end({
|
|
5540
5693
|
id: traceId
|
|
5541
5694
|
}), {
|
|
5542
5695
|
F: __dxlog_file18,
|
|
5543
|
-
L:
|
|
5696
|
+
L: 347,
|
|
5544
5697
|
S: this,
|
|
5545
5698
|
C: (f, a) => f(...a)
|
|
5546
5699
|
});
|
|
@@ -5551,20 +5704,20 @@ var ClientServicesHost = class {
|
|
|
5551
5704
|
await this._serviceContext.initialized.wait();
|
|
5552
5705
|
const space = await this._serviceContext.dataSpaceManager.createSpace();
|
|
5553
5706
|
const automergeIndex = space.automergeSpaceState.rootUrl;
|
|
5554
|
-
(0,
|
|
5707
|
+
(0, import_invariant15.invariant)(automergeIndex, void 0, {
|
|
5555
5708
|
F: __dxlog_file18,
|
|
5556
|
-
L:
|
|
5709
|
+
L: 359,
|
|
5557
5710
|
S: this,
|
|
5558
5711
|
A: [
|
|
5559
5712
|
"automergeIndex",
|
|
5560
5713
|
""
|
|
5561
5714
|
]
|
|
5562
5715
|
});
|
|
5563
|
-
const document = await this._serviceContext.
|
|
5716
|
+
const document = await this._serviceContext.echoHost.automergeRepo.find(automergeIndex);
|
|
5564
5717
|
await document.whenReady();
|
|
5565
5718
|
const properties = {
|
|
5566
5719
|
system: {
|
|
5567
|
-
type: (0,
|
|
5720
|
+
type: (0, import_echo_pipeline5.encodeReference)((0, import_echo_schema2.getTypeReference)(import_client_protocol5.Properties))
|
|
5568
5721
|
},
|
|
5569
5722
|
data: {
|
|
5570
5723
|
[import_client_protocol5.defaultKey]: identity.identityKey.toHex()
|
|
@@ -5580,40 +5733,75 @@ var ClientServicesHost = class {
|
|
|
5580
5733
|
propertiesId
|
|
5581
5734
|
], properties);
|
|
5582
5735
|
});
|
|
5583
|
-
await this._serviceContext.
|
|
5736
|
+
await this._serviceContext.echoHost.flush();
|
|
5584
5737
|
return identity;
|
|
5585
5738
|
}
|
|
5586
5739
|
};
|
|
5587
5740
|
_ts_decorate8([
|
|
5588
|
-
|
|
5741
|
+
import_tracing8.trace.info()
|
|
5589
5742
|
], ClientServicesHost.prototype, "_opening", void 0);
|
|
5590
5743
|
_ts_decorate8([
|
|
5591
|
-
|
|
5744
|
+
import_tracing8.trace.info()
|
|
5592
5745
|
], ClientServicesHost.prototype, "_open", void 0);
|
|
5593
5746
|
_ts_decorate8([
|
|
5594
5747
|
import_async16.synchronized,
|
|
5595
|
-
|
|
5748
|
+
import_tracing8.trace.span()
|
|
5596
5749
|
], ClientServicesHost.prototype, "open", null);
|
|
5597
5750
|
_ts_decorate8([
|
|
5598
5751
|
import_async16.synchronized,
|
|
5599
|
-
|
|
5752
|
+
import_tracing8.trace.span()
|
|
5600
5753
|
], ClientServicesHost.prototype, "close", null);
|
|
5601
5754
|
ClientServicesHost = _ts_decorate8([
|
|
5602
|
-
|
|
5755
|
+
import_tracing8.trace.resource()
|
|
5603
5756
|
], ClientServicesHost);
|
|
5757
|
+
var ClientServicesProviderResource = Symbol.for("dxos.resource.ClientServices");
|
|
5758
|
+
var DiagnosticsCollector = class {
|
|
5759
|
+
static {
|
|
5760
|
+
this.broadcastSender = createCollectDiagnosticsBroadcastSender();
|
|
5761
|
+
}
|
|
5762
|
+
static async collect(config = findConfigs(), services = findSystemServiceProvider(), options = {}) {
|
|
5763
|
+
const serviceDiagnostics = await services?.services?.SystemService?.getDiagnostics({
|
|
5764
|
+
keys: options.humanize ? import_services14.GetDiagnosticsRequest.KEY_OPTION.HUMANIZE : options.truncate ? import_services14.GetDiagnosticsRequest.KEY_OPTION.TRUNCATE : void 0
|
|
5765
|
+
});
|
|
5766
|
+
const clientDiagnostics = {
|
|
5767
|
+
config,
|
|
5768
|
+
trace: import_tracing7.TRACE_PROCESSOR.getDiagnostics()
|
|
5769
|
+
};
|
|
5770
|
+
const diagnostics = serviceDiagnostics != null ? {
|
|
5771
|
+
client: clientDiagnostics,
|
|
5772
|
+
services: serviceDiagnostics
|
|
5773
|
+
} : {
|
|
5774
|
+
client: clientDiagnostics,
|
|
5775
|
+
broadcast: await this.broadcastSender.broadcastDiagnosticsRequest()
|
|
5776
|
+
};
|
|
5777
|
+
return JSON.parse(JSON.stringify(diagnostics, (0, import_util8.jsonKeyReplacer)(options)));
|
|
5778
|
+
}
|
|
5779
|
+
};
|
|
5780
|
+
var findSystemServiceProvider = () => {
|
|
5781
|
+
const serviceProviders = import_tracing7.TRACE_PROCESSOR.findByAnnotation(ClientServicesProviderResource);
|
|
5782
|
+
const providerResource = serviceProviders.find((r) => r.instance.deref()?.services?.SystemService != null);
|
|
5783
|
+
return providerResource?.instance?.deref() ?? null;
|
|
5784
|
+
};
|
|
5785
|
+
var findConfigs = () => {
|
|
5786
|
+
const configs = import_tracing7.TRACE_PROCESSOR.findByAnnotation(import_config.ConfigResource);
|
|
5787
|
+
return configs.map((r) => r.instance.deref()).filter(import_util8.nonNullable);
|
|
5788
|
+
};
|
|
5604
5789
|
// Annotate the CommonJS export names for ESM import in node:
|
|
5605
5790
|
0 && (module.exports = {
|
|
5606
5791
|
ClientRpcServer,
|
|
5607
5792
|
ClientServicesHost,
|
|
5793
|
+
ClientServicesProviderResource,
|
|
5608
5794
|
DataSpace,
|
|
5609
5795
|
DataSpaceManager,
|
|
5610
5796
|
DeviceInvitationProtocol,
|
|
5611
5797
|
DevtoolsHostEvents,
|
|
5612
5798
|
DevtoolsServiceImpl,
|
|
5799
|
+
DiagnosticsCollector,
|
|
5613
5800
|
Identity,
|
|
5614
5801
|
IdentityManager,
|
|
5615
5802
|
IdentityServiceImpl,
|
|
5616
5803
|
InvitationsHandler,
|
|
5804
|
+
InvitationsManager,
|
|
5617
5805
|
InvitationsServiceImpl,
|
|
5618
5806
|
Lock,
|
|
5619
5807
|
ServiceContext,
|
|
@@ -5621,12 +5809,14 @@ ClientServicesHost = _ts_decorate8([
|
|
|
5621
5809
|
SpaceInvitationProtocol,
|
|
5622
5810
|
SpacesServiceImpl,
|
|
5623
5811
|
TrustedKeySetAuthVerifier,
|
|
5812
|
+
createAdmissionKeypair,
|
|
5624
5813
|
createAuthProvider,
|
|
5814
|
+
createCollectDiagnosticsBroadcastHandler,
|
|
5815
|
+
createCollectDiagnosticsBroadcastSender,
|
|
5625
5816
|
createDiagnostics,
|
|
5626
5817
|
createLevel,
|
|
5627
5818
|
createStorageObjects,
|
|
5628
5819
|
getNetworkPeers,
|
|
5629
|
-
invitationExpired,
|
|
5630
5820
|
isLocked,
|
|
5631
5821
|
subscribeToFeedBlocks,
|
|
5632
5822
|
subscribeToFeeds,
|
|
@@ -5636,4 +5826,4 @@ ClientServicesHost = _ts_decorate8([
|
|
|
5636
5826
|
subscribeToSpaces,
|
|
5637
5827
|
subscribeToSwarmInfo
|
|
5638
5828
|
});
|
|
5639
|
-
//# sourceMappingURL=chunk-
|
|
5829
|
+
//# sourceMappingURL=chunk-2L6Y2DJQ.cjs.map
|