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