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