@dxos/client-services 0.4.10-main.b9b4602 → 0.4.10-main.bb9f1bf
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-TPPBOJTA.mjs → chunk-TM5QAJBN.mjs} +756 -572
- package/dist/lib/browser/chunk-TM5QAJBN.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +5 -3
- package/dist/lib/browser/index.mjs.map +1 -1
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/packlets/testing/index.mjs +133 -115
- package/dist/lib/browser/packlets/testing/index.mjs.map +3 -3
- package/dist/lib/node/{chunk-33Q7F4MM.cjs → chunk-ZMWT7BZY.cjs} +848 -665
- package/dist/lib/node/chunk-ZMWT7BZY.cjs.map +7 -0
- package/dist/lib/node/index.cjs +45 -43
- package/dist/lib/node/index.cjs.map +1 -1
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/packlets/testing/index.cjs +133 -118
- package/dist/lib/node/packlets/testing/index.cjs.map +3 -3
- package/dist/types/src/packlets/identity/identity-manager.d.ts.map +1 -1
- package/dist/types/src/packlets/indexing/util.d.ts +2 -6
- package/dist/types/src/packlets/indexing/util.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/device-invitation-protocol.d.ts +3 -1
- package/dist/types/src/packlets/invitations/device-invitation-protocol.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/index.d.ts +1 -0
- package/dist/types/src/packlets/invitations/index.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/invitation-extension.d.ts +1 -0
- package/dist/types/src/packlets/invitations/invitation-extension.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/invitation-protocol.d.ts +6 -1
- package/dist/types/src/packlets/invitations/invitation-protocol.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/invitations-handler.d.ts +8 -4
- package/dist/types/src/packlets/invitations/invitations-handler.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/invitations-manager.d.ts +44 -0
- package/dist/types/src/packlets/invitations/invitations-manager.d.ts.map +1 -0
- package/dist/types/src/packlets/invitations/invitations-service.d.ts +7 -23
- package/dist/types/src/packlets/invitations/invitations-service.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/space-invitation-protocol.d.ts +2 -1
- package/dist/types/src/packlets/invitations/space-invitation-protocol.d.ts.map +1 -1
- package/dist/types/src/packlets/services/service-context.d.ts +2 -0
- package/dist/types/src/packlets/services/service-context.d.ts.map +1 -1
- package/dist/types/src/packlets/services/service-host.d.ts +4 -1
- package/dist/types/src/packlets/services/service-host.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/data-space-manager.d.ts +5 -1
- package/dist/types/src/packlets/spaces/data-space-manager.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/data-space.d.ts.map +1 -1
- package/dist/types/src/packlets/testing/invitation-utils.d.ts.map +1 -1
- package/dist/types/src/packlets/testing/test-builder.d.ts +6 -1
- package/dist/types/src/packlets/testing/test-builder.d.ts.map +1 -1
- package/dist/types/src/version.d.ts +1 -1
- package/package.json +34 -34
- package/src/packlets/identity/identity-manager.ts +1 -0
- package/src/packlets/identity/identity.test.ts +3 -0
- package/src/packlets/indexing/util.ts +9 -66
- package/src/packlets/invitations/device-invitation-protocol.ts +6 -1
- package/src/packlets/invitations/index.ts +1 -0
- package/src/packlets/invitations/invitation-extension.ts +28 -1
- package/src/packlets/invitations/invitation-protocol.ts +7 -1
- package/src/packlets/invitations/invitations-handler.ts +75 -96
- package/src/packlets/invitations/invitations-manager.ts +271 -0
- package/src/packlets/invitations/invitations-service.ts +23 -168
- package/src/packlets/invitations/space-invitation-protocol.ts +45 -3
- package/src/packlets/services/automerge-host.test.ts +10 -4
- package/src/packlets/services/service-context.test.ts +4 -1
- package/src/packlets/services/service-context.ts +19 -5
- package/src/packlets/services/service-host.ts +25 -18
- package/src/packlets/spaces/data-space-manager.test.ts +4 -4
- package/src/packlets/spaces/data-space-manager.ts +48 -2
- package/src/packlets/spaces/data-space.ts +1 -1
- package/src/packlets/storage/level.ts +1 -1
- package/src/packlets/testing/invitation-utils.ts +100 -97
- package/src/packlets/testing/test-builder.ts +39 -5
- package/src/version.ts +1 -1
- package/dist/lib/browser/chunk-TPPBOJTA.mjs.map +0 -7
- package/dist/lib/node/chunk-33Q7F4MM.cjs.map +0 -7
|
@@ -26,8 +26,8 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
26
26
|
mod
|
|
27
27
|
));
|
|
28
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
var
|
|
30
|
-
__export(
|
|
29
|
+
var chunk_ZMWT7BZY_exports = {};
|
|
30
|
+
__export(chunk_ZMWT7BZY_exports, {
|
|
31
31
|
ClientRpcServer: () => ClientRpcServer,
|
|
32
32
|
ClientServicesHost: () => ClientServicesHost,
|
|
33
33
|
ClientServicesProviderResource: () => ClientServicesProviderResource,
|
|
@@ -41,6 +41,7 @@ __export(chunk_33Q7F4MM_exports, {
|
|
|
41
41
|
IdentityManager: () => IdentityManager,
|
|
42
42
|
IdentityServiceImpl: () => IdentityServiceImpl,
|
|
43
43
|
InvitationsHandler: () => InvitationsHandler,
|
|
44
|
+
InvitationsManager: () => InvitationsManager,
|
|
44
45
|
InvitationsServiceImpl: () => InvitationsServiceImpl,
|
|
45
46
|
Lock: () => Lock,
|
|
46
47
|
ServiceContext: () => ServiceContext,
|
|
@@ -48,6 +49,7 @@ __export(chunk_33Q7F4MM_exports, {
|
|
|
48
49
|
SpaceInvitationProtocol: () => SpaceInvitationProtocol,
|
|
49
50
|
SpacesServiceImpl: () => SpacesServiceImpl,
|
|
50
51
|
TrustedKeySetAuthVerifier: () => TrustedKeySetAuthVerifier,
|
|
52
|
+
createAdmissionKeypair: () => createAdmissionKeypair,
|
|
51
53
|
createAuthProvider: () => createAuthProvider,
|
|
52
54
|
createCollectDiagnosticsBroadcastHandler: () => createCollectDiagnosticsBroadcastHandler,
|
|
53
55
|
createCollectDiagnosticsBroadcastSender: () => createCollectDiagnosticsBroadcastSender,
|
|
@@ -55,7 +57,6 @@ __export(chunk_33Q7F4MM_exports, {
|
|
|
55
57
|
createLevel: () => createLevel,
|
|
56
58
|
createStorageObjects: () => createStorageObjects,
|
|
57
59
|
getNetworkPeers: () => getNetworkPeers,
|
|
58
|
-
invitationExpired: () => invitationExpired,
|
|
59
60
|
isLocked: () => isLocked,
|
|
60
61
|
subscribeToFeedBlocks: () => subscribeToFeedBlocks,
|
|
61
62
|
subscribeToFeeds: () => subscribeToFeeds,
|
|
@@ -65,7 +66,7 @@ __export(chunk_33Q7F4MM_exports, {
|
|
|
65
66
|
subscribeToSpaces: () => subscribeToSpaces,
|
|
66
67
|
subscribeToSwarmInfo: () => subscribeToSwarmInfo
|
|
67
68
|
});
|
|
68
|
-
module.exports = __toCommonJS(
|
|
69
|
+
module.exports = __toCommonJS(chunk_ZMWT7BZY_exports);
|
|
69
70
|
var import_async = require("@dxos/async");
|
|
70
71
|
var import_codec_protobuf = require("@dxos/codec-protobuf");
|
|
71
72
|
var import_feed_store = require("@dxos/feed-store");
|
|
@@ -119,7 +120,7 @@ var import_services2 = require("@dxos/protocols/proto/dxos/client/services");
|
|
|
119
120
|
var import_async7 = require("@dxos/async");
|
|
120
121
|
var import_client_protocol2 = require("@dxos/client-protocol");
|
|
121
122
|
var import_context4 = require("@dxos/context");
|
|
122
|
-
var
|
|
123
|
+
var import_crypto = require("@dxos/crypto");
|
|
123
124
|
var import_invariant5 = require("@dxos/invariant");
|
|
124
125
|
var import_keys5 = require("@dxos/keys");
|
|
125
126
|
var import_log4 = require("@dxos/log");
|
|
@@ -129,6 +130,7 @@ var import_services3 = require("@dxos/protocols/proto/dxos/client/services");
|
|
|
129
130
|
var import_invitations = require("@dxos/protocols/proto/dxos/halo/invitations");
|
|
130
131
|
var import_async8 = require("@dxos/async");
|
|
131
132
|
var import_context5 = require("@dxos/context");
|
|
133
|
+
var import_crypto2 = require("@dxos/crypto");
|
|
132
134
|
var import_invariant6 = require("@dxos/invariant");
|
|
133
135
|
var import_keys6 = require("@dxos/keys");
|
|
134
136
|
var import_log5 = require("@dxos/log");
|
|
@@ -136,61 +138,67 @@ var import_protocols5 = require("@dxos/protocols");
|
|
|
136
138
|
var import_services4 = require("@dxos/protocols/proto/dxos/client/services");
|
|
137
139
|
var import_invitations2 = require("@dxos/protocols/proto/dxos/halo/invitations");
|
|
138
140
|
var import_teleport = require("@dxos/teleport");
|
|
139
|
-
var import_async9 = require("@dxos/async");
|
|
140
141
|
var import_codec_protobuf8 = require("@dxos/codec-protobuf");
|
|
141
|
-
var import_context6 = require("@dxos/context");
|
|
142
|
-
var import_invariant7 = require("@dxos/invariant");
|
|
143
|
-
var import_log6 = require("@dxos/log");
|
|
144
142
|
var import_services5 = require("@dxos/protocols/proto/dxos/client/services");
|
|
145
|
-
var
|
|
143
|
+
var import_credentials7 = require("@dxos/credentials");
|
|
146
144
|
var import_feed_store3 = require("@dxos/feed-store");
|
|
147
|
-
var
|
|
148
|
-
var
|
|
145
|
+
var import_invariant7 = require("@dxos/invariant");
|
|
146
|
+
var import_log6 = require("@dxos/log");
|
|
149
147
|
var import_protocols6 = require("@dxos/protocols");
|
|
150
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");
|
|
151
159
|
var import_codec_protobuf9 = require("@dxos/codec-protobuf");
|
|
152
160
|
var import_debug2 = require("@dxos/debug");
|
|
153
161
|
var import_rpc = require("@dxos/rpc");
|
|
154
162
|
var import_tracing3 = require("@dxos/tracing");
|
|
155
163
|
var import_async10 = require("@dxos/async");
|
|
156
|
-
var
|
|
164
|
+
var import_client_protocol4 = require("@dxos/client-protocol");
|
|
157
165
|
var import_context7 = require("@dxos/context");
|
|
158
166
|
var import_debug3 = require("@dxos/debug");
|
|
159
|
-
var import_echo_db = require("@dxos/echo-db");
|
|
160
|
-
var import_echo_pipeline = require("@dxos/echo-pipeline");
|
|
161
167
|
var import_echo_pipeline2 = require("@dxos/echo-pipeline");
|
|
168
|
+
var import_echo_pipeline3 = require("@dxos/echo-pipeline");
|
|
169
|
+
var import_echo_schema = require("@dxos/echo-schema");
|
|
162
170
|
var import_invariant9 = require("@dxos/invariant");
|
|
163
|
-
var
|
|
171
|
+
var import_keys8 = require("@dxos/keys");
|
|
164
172
|
var import_log8 = require("@dxos/log");
|
|
165
173
|
var import_protocols7 = require("@dxos/protocols");
|
|
166
|
-
var
|
|
167
|
-
var
|
|
174
|
+
var import_services8 = require("@dxos/protocols/proto/dxos/client/services");
|
|
175
|
+
var import_credentials10 = require("@dxos/protocols/proto/dxos/halo/credentials");
|
|
168
176
|
var import_timeframe2 = require("@dxos/timeframe");
|
|
169
177
|
var import_tracing4 = require("@dxos/tracing");
|
|
170
178
|
var import_util4 = require("@dxos/util");
|
|
171
179
|
var import_async11 = require("@dxos/async");
|
|
172
|
-
var
|
|
180
|
+
var import_credentials11 = require("@dxos/credentials");
|
|
173
181
|
var import_async12 = require("@dxos/async");
|
|
174
182
|
var import_context8 = require("@dxos/context");
|
|
175
183
|
var import_invariant10 = require("@dxos/invariant");
|
|
176
|
-
var
|
|
184
|
+
var import_keys9 = require("@dxos/keys");
|
|
177
185
|
var import_log9 = require("@dxos/log");
|
|
178
186
|
var import_protocols8 = require("@dxos/protocols");
|
|
179
187
|
var import_teleport2 = require("@dxos/teleport");
|
|
180
188
|
var import_util5 = require("@dxos/util");
|
|
181
189
|
var import_async13 = require("@dxos/async");
|
|
182
190
|
var import_context9 = require("@dxos/context");
|
|
183
|
-
var
|
|
191
|
+
var import_credentials12 = require("@dxos/credentials");
|
|
184
192
|
var import_invariant11 = require("@dxos/invariant");
|
|
185
|
-
var
|
|
193
|
+
var import_keys10 = require("@dxos/keys");
|
|
186
194
|
var import_log10 = require("@dxos/log");
|
|
187
195
|
var import_protocols9 = require("@dxos/protocols");
|
|
188
|
-
var
|
|
196
|
+
var import_services9 = require("@dxos/protocols/proto/dxos/client/services");
|
|
189
197
|
var import_teleport_extension_gossip2 = require("@dxos/teleport-extension-gossip");
|
|
190
198
|
var import_util6 = require("@dxos/util");
|
|
191
|
-
var
|
|
199
|
+
var import_credentials13 = require("@dxos/credentials");
|
|
192
200
|
var import_debug4 = require("@dxos/debug");
|
|
193
|
-
var
|
|
201
|
+
var import_credentials14 = require("@dxos/protocols/proto/dxos/halo/credentials");
|
|
194
202
|
var import_timeframe3 = require("@dxos/timeframe");
|
|
195
203
|
var import_async14 = require("@dxos/async");
|
|
196
204
|
var import_codec_protobuf10 = require("@dxos/codec-protobuf");
|
|
@@ -198,80 +206,79 @@ var import_debug5 = require("@dxos/debug");
|
|
|
198
206
|
var import_invariant12 = require("@dxos/invariant");
|
|
199
207
|
var import_log11 = require("@dxos/log");
|
|
200
208
|
var import_protocols10 = require("@dxos/protocols");
|
|
201
|
-
var
|
|
209
|
+
var import_services10 = require("@dxos/protocols/proto/dxos/client/services");
|
|
202
210
|
var import_async15 = require("@dxos/async");
|
|
203
211
|
var import_context10 = require("@dxos/context");
|
|
204
|
-
var
|
|
212
|
+
var import_credentials15 = require("@dxos/credentials");
|
|
205
213
|
var import_debug6 = require("@dxos/debug");
|
|
206
|
-
var
|
|
214
|
+
var import_echo_pipeline4 = require("@dxos/echo-pipeline");
|
|
207
215
|
var import_feed_store4 = require("@dxos/feed-store");
|
|
208
216
|
var import_indexing = require("@dxos/indexing");
|
|
209
217
|
var import_invariant13 = require("@dxos/invariant");
|
|
210
218
|
var import_keyring = require("@dxos/keyring");
|
|
211
|
-
var
|
|
219
|
+
var import_keys11 = require("@dxos/keys");
|
|
212
220
|
var import_log12 = require("@dxos/log");
|
|
213
221
|
var import_protocols11 = require("@dxos/protocols");
|
|
214
|
-
var
|
|
222
|
+
var import_services11 = require("@dxos/protocols/proto/dxos/client/services");
|
|
215
223
|
var import_teleport_extension_object_sync = require("@dxos/teleport-extension-object-sync");
|
|
216
224
|
var import_tracing5 = require("@dxos/tracing");
|
|
217
225
|
var import_util7 = require("@dxos/util");
|
|
218
226
|
var import_automerge = require("@dxos/automerge/automerge");
|
|
219
|
-
var import_debug7 = require("@dxos/debug");
|
|
220
227
|
var import_protocols12 = require("@dxos/protocols");
|
|
221
228
|
var import_codec_protobuf11 = require("@dxos/codec-protobuf");
|
|
222
|
-
var
|
|
229
|
+
var import_credentials16 = require("@dxos/credentials");
|
|
223
230
|
var import_invariant14 = require("@dxos/invariant");
|
|
224
231
|
var import_protocols13 = require("@dxos/protocols");
|
|
225
|
-
var import_services11 = require("@dxos/protocols/proto/dxos/client/services");
|
|
226
|
-
var import_tracing6 = require("@dxos/tracing");
|
|
227
232
|
var import_services12 = require("@dxos/protocols/proto/dxos/client/services");
|
|
228
|
-
var
|
|
233
|
+
var import_tracing6 = require("@dxos/tracing");
|
|
229
234
|
var import_services13 = require("@dxos/protocols/proto/dxos/client/services");
|
|
235
|
+
var import_config = require("@dxos/config");
|
|
236
|
+
var import_services14 = require("@dxos/protocols/proto/dxos/client/services");
|
|
230
237
|
var import_tracing7 = require("@dxos/tracing");
|
|
231
238
|
var import_util8 = require("@dxos/util");
|
|
232
239
|
var import_async16 = require("@dxos/async");
|
|
233
|
-
var
|
|
240
|
+
var import_client_protocol5 = require("@dxos/client-protocol");
|
|
234
241
|
var import_context11 = require("@dxos/context");
|
|
235
|
-
var
|
|
236
|
-
var
|
|
242
|
+
var import_echo_pipeline5 = require("@dxos/echo-pipeline");
|
|
243
|
+
var import_echo_schema2 = require("@dxos/echo-schema");
|
|
237
244
|
var import_indexing2 = require("@dxos/indexing");
|
|
238
245
|
var import_invariant15 = require("@dxos/invariant");
|
|
239
|
-
var
|
|
246
|
+
var import_keys12 = require("@dxos/keys");
|
|
240
247
|
var import_log13 = require("@dxos/log");
|
|
241
248
|
var import_messaging = require("@dxos/messaging");
|
|
242
249
|
var import_network_manager2 = require("@dxos/network-manager");
|
|
243
250
|
var import_protocols14 = require("@dxos/protocols");
|
|
244
|
-
var
|
|
251
|
+
var import_services15 = require("@dxos/protocols/proto/dxos/client/services");
|
|
245
252
|
var import_tracing8 = require("@dxos/tracing");
|
|
246
253
|
var import_util9 = require("@dxos/util");
|
|
247
254
|
var import_websocket_rpc = require("@dxos/websocket-rpc");
|
|
248
255
|
var import_async17 = require("@dxos/async");
|
|
249
256
|
var import_codec_protobuf12 = require("@dxos/codec-protobuf");
|
|
250
257
|
var import_invariant16 = require("@dxos/invariant");
|
|
251
|
-
var
|
|
258
|
+
var import_services16 = require("@dxos/protocols/proto/dxos/client/services");
|
|
252
259
|
var import_invariant17 = require("@dxos/invariant");
|
|
253
260
|
var import_lock_file = require("@dxos/lock-file");
|
|
254
261
|
var import_log14 = require("@dxos/log");
|
|
255
262
|
var import_async18 = require("@dxos/async");
|
|
256
263
|
var import_codec_protobuf13 = require("@dxos/codec-protobuf");
|
|
257
|
-
var
|
|
264
|
+
var import_keys13 = require("@dxos/keys");
|
|
258
265
|
var import_log15 = require("@dxos/log");
|
|
259
|
-
var
|
|
266
|
+
var import_services17 = require("@dxos/protocols/proto/dxos/client/services");
|
|
260
267
|
var import_util10 = require("@dxos/util");
|
|
261
268
|
var import_codec_protobuf14 = require("@dxos/codec-protobuf");
|
|
262
269
|
var import_protocols15 = require("@dxos/protocols");
|
|
263
270
|
var import_config2 = require("@dxos/protocols/proto/dxos/config");
|
|
264
271
|
var import_random_access_storage = require("@dxos/random-access-storage");
|
|
265
|
-
var
|
|
272
|
+
var import_client_protocol6 = require("@dxos/client-protocol");
|
|
266
273
|
var import_config3 = require("@dxos/protocols/proto/dxos/config");
|
|
267
274
|
var import_util11 = require("@dxos/util");
|
|
268
275
|
var import_level = require("level");
|
|
269
276
|
var import_node_path = __toESM(require("node:path"));
|
|
270
|
-
var
|
|
277
|
+
var import_keys14 = require("@dxos/keys");
|
|
271
278
|
var import_codec_protobuf15 = require("@dxos/codec-protobuf");
|
|
272
|
-
var
|
|
279
|
+
var import_services18 = require("@dxos/protocols/proto/dxos/client/services");
|
|
273
280
|
var import_util12 = require("@dxos/util");
|
|
274
|
-
var
|
|
281
|
+
var import_keys15 = require("@dxos/keys");
|
|
275
282
|
var import_util13 = require("@dxos/util");
|
|
276
283
|
var subscribeToFeeds = ({ feedStore }, { feedKeys }) => {
|
|
277
284
|
return new import_codec_protobuf.Stream(({ next }) => {
|
|
@@ -1290,7 +1297,9 @@ var IdentityManager = class {
|
|
|
1290
1297
|
C: (f, a) => f(...a)
|
|
1291
1298
|
});
|
|
1292
1299
|
},
|
|
1293
|
-
memberKey: identityKey
|
|
1300
|
+
memberKey: identityKey,
|
|
1301
|
+
onDelegatedInvitationStatusChange: async () => {
|
|
1302
|
+
}
|
|
1294
1303
|
});
|
|
1295
1304
|
}
|
|
1296
1305
|
};
|
|
@@ -1387,10 +1396,13 @@ var DeviceInvitationProtocol = class {
|
|
|
1387
1396
|
kind: import_services2.Invitation.Kind.DEVICE
|
|
1388
1397
|
};
|
|
1389
1398
|
}
|
|
1390
|
-
async
|
|
1399
|
+
async delegate(invitation) {
|
|
1400
|
+
throw new Error("delegation not supported");
|
|
1401
|
+
}
|
|
1402
|
+
async admit(_, request) {
|
|
1391
1403
|
(0, import_invariant4.invariant)(request.device, void 0, {
|
|
1392
1404
|
F: __dxlog_file5,
|
|
1393
|
-
L:
|
|
1405
|
+
L: 42,
|
|
1394
1406
|
S: this,
|
|
1395
1407
|
A: [
|
|
1396
1408
|
"request.device",
|
|
@@ -1436,7 +1448,7 @@ var DeviceInvitationProtocol = class {
|
|
|
1436
1448
|
async accept(response, request) {
|
|
1437
1449
|
(0, import_invariant4.invariant)(response.device, void 0, {
|
|
1438
1450
|
F: __dxlog_file5,
|
|
1439
|
-
L:
|
|
1451
|
+
L: 87,
|
|
1440
1452
|
S: this,
|
|
1441
1453
|
A: [
|
|
1442
1454
|
"response.device",
|
|
@@ -1446,7 +1458,7 @@ var DeviceInvitationProtocol = class {
|
|
|
1446
1458
|
const { identityKey, haloSpaceKey, genesisFeedKey, controlTimeframe } = response.device;
|
|
1447
1459
|
(0, import_invariant4.invariant)(request.device, void 0, {
|
|
1448
1460
|
F: __dxlog_file5,
|
|
1449
|
-
L:
|
|
1461
|
+
L: 90,
|
|
1450
1462
|
S: this,
|
|
1451
1463
|
A: [
|
|
1452
1464
|
"request.device",
|
|
@@ -1485,6 +1497,7 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
1485
1497
|
this._callbacks = _callbacks;
|
|
1486
1498
|
this._ctx = new import_context5.Context();
|
|
1487
1499
|
this._remoteOptionsTrigger = new import_async8.Trigger();
|
|
1500
|
+
this._challenge = void 0;
|
|
1488
1501
|
this.invitation = void 0;
|
|
1489
1502
|
this.guestProfile = void 0;
|
|
1490
1503
|
this.authenticationPassed = false;
|
|
@@ -1499,7 +1512,7 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
1499
1512
|
options: async (options) => {
|
|
1500
1513
|
(0, import_invariant6.invariant)(!this._remoteOptions, "Remote options already set.", {
|
|
1501
1514
|
F: __dxlog_file6,
|
|
1502
|
-
L:
|
|
1515
|
+
L: 90,
|
|
1503
1516
|
S: this,
|
|
1504
1517
|
A: [
|
|
1505
1518
|
"!this._remoteOptions",
|
|
@@ -1516,7 +1529,7 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
1516
1529
|
id: traceId
|
|
1517
1530
|
}), {
|
|
1518
1531
|
F: __dxlog_file6,
|
|
1519
|
-
L:
|
|
1532
|
+
L: 99,
|
|
1520
1533
|
S: this,
|
|
1521
1534
|
C: (f, a) => f(...a)
|
|
1522
1535
|
});
|
|
@@ -1526,7 +1539,7 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
1526
1539
|
invitationId
|
|
1527
1540
|
}, {
|
|
1528
1541
|
F: __dxlog_file6,
|
|
1529
|
-
L:
|
|
1542
|
+
L: 103,
|
|
1530
1543
|
S: this,
|
|
1531
1544
|
C: (f, a) => f(...a)
|
|
1532
1545
|
});
|
|
@@ -1540,7 +1553,7 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
1540
1553
|
guestProfile: profile
|
|
1541
1554
|
}, {
|
|
1542
1555
|
F: __dxlog_file6,
|
|
1543
|
-
L:
|
|
1556
|
+
L: 112,
|
|
1544
1557
|
S: this,
|
|
1545
1558
|
C: (f, a) => f(...a)
|
|
1546
1559
|
});
|
|
@@ -1549,25 +1562,27 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
1549
1562
|
...this.invitation,
|
|
1550
1563
|
state: import_services4.Invitation.State.READY_FOR_AUTHENTICATION
|
|
1551
1564
|
});
|
|
1565
|
+
this._challenge = this.invitation.authMethod === import_services4.Invitation.AuthMethod.KNOWN_PUBLIC_KEY ? (0, import_crypto2.randomBytes)(32) : void 0;
|
|
1552
1566
|
import_log5.log.trace("dxos.sdk.invitation-handler.host.introduce", import_protocols5.trace.end({
|
|
1553
1567
|
id: traceId
|
|
1554
1568
|
}), {
|
|
1555
1569
|
F: __dxlog_file6,
|
|
1556
|
-
L:
|
|
1570
|
+
L: 122,
|
|
1557
1571
|
S: this,
|
|
1558
1572
|
C: (f, a) => f(...a)
|
|
1559
1573
|
});
|
|
1560
1574
|
return {
|
|
1561
|
-
authMethod: this.invitation.authMethod
|
|
1575
|
+
authMethod: this.invitation.authMethod,
|
|
1576
|
+
challenge: this._challenge
|
|
1562
1577
|
};
|
|
1563
1578
|
},
|
|
1564
|
-
authenticate: async ({ authCode: code }) => {
|
|
1579
|
+
authenticate: async ({ authCode: code, signedChallenge }) => {
|
|
1565
1580
|
const traceId = import_keys6.PublicKey.random().toHex();
|
|
1566
1581
|
import_log5.log.trace("dxos.sdk.invitation-handler.host.authenticate", import_protocols5.trace.begin({
|
|
1567
1582
|
id: traceId
|
|
1568
1583
|
}), {
|
|
1569
1584
|
F: __dxlog_file6,
|
|
1570
|
-
L:
|
|
1585
|
+
L: 131,
|
|
1571
1586
|
S: this,
|
|
1572
1587
|
C: (f, a) => f(...a)
|
|
1573
1588
|
});
|
|
@@ -1575,14 +1590,14 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
1575
1590
|
authCode: code
|
|
1576
1591
|
}, {
|
|
1577
1592
|
F: __dxlog_file6,
|
|
1578
|
-
L:
|
|
1593
|
+
L: 132,
|
|
1579
1594
|
S: this,
|
|
1580
1595
|
C: (f, a) => f(...a)
|
|
1581
1596
|
});
|
|
1582
1597
|
let status = import_invitations2.AuthenticationResponse.Status.OK;
|
|
1583
1598
|
(0, import_invariant6.invariant)(this.invitation, "Invitation is not set.", {
|
|
1584
1599
|
F: __dxlog_file6,
|
|
1585
|
-
L:
|
|
1600
|
+
L: 135,
|
|
1586
1601
|
S: this,
|
|
1587
1602
|
A: [
|
|
1588
1603
|
"this.invitation",
|
|
@@ -1593,7 +1608,7 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
1593
1608
|
case import_services4.Invitation.AuthMethod.NONE: {
|
|
1594
1609
|
(0, import_log5.log)("authentication not required", void 0, {
|
|
1595
1610
|
F: __dxlog_file6,
|
|
1596
|
-
L:
|
|
1611
|
+
L: 138,
|
|
1597
1612
|
S: this,
|
|
1598
1613
|
C: (f, a) => f(...a)
|
|
1599
1614
|
});
|
|
@@ -1613,12 +1628,25 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
1613
1628
|
}
|
|
1614
1629
|
break;
|
|
1615
1630
|
}
|
|
1631
|
+
case import_services4.Invitation.AuthMethod.KNOWN_PUBLIC_KEY: {
|
|
1632
|
+
if (!this.invitation.guestKeypair) {
|
|
1633
|
+
status = import_invitations2.AuthenticationResponse.Status.INTERNAL_ERROR;
|
|
1634
|
+
break;
|
|
1635
|
+
}
|
|
1636
|
+
const isSignatureValid = this._challenge && (0, import_crypto2.verify)(this._challenge, Buffer.from(signedChallenge ?? []), this.invitation.guestKeypair.publicKey.asBuffer());
|
|
1637
|
+
if (isSignatureValid) {
|
|
1638
|
+
this.authenticationPassed = true;
|
|
1639
|
+
} else {
|
|
1640
|
+
status = import_invitations2.AuthenticationResponse.Status.INVALID_SIGNATURE;
|
|
1641
|
+
}
|
|
1642
|
+
break;
|
|
1643
|
+
}
|
|
1616
1644
|
default: {
|
|
1617
1645
|
import_log5.log.error("invalid authentication method", {
|
|
1618
1646
|
authMethod: this.invitation.authMethod
|
|
1619
1647
|
}, {
|
|
1620
1648
|
F: __dxlog_file6,
|
|
1621
|
-
L:
|
|
1649
|
+
L: 176,
|
|
1622
1650
|
S: this,
|
|
1623
1651
|
C: (f, a) => f(...a)
|
|
1624
1652
|
});
|
|
@@ -1633,7 +1661,7 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
1633
1661
|
}
|
|
1634
1662
|
}), {
|
|
1635
1663
|
F: __dxlog_file6,
|
|
1636
|
-
L:
|
|
1664
|
+
L: 182,
|
|
1637
1665
|
S: this,
|
|
1638
1666
|
C: (f, a) => f(...a)
|
|
1639
1667
|
});
|
|
@@ -1647,14 +1675,14 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
1647
1675
|
id: traceId
|
|
1648
1676
|
}), {
|
|
1649
1677
|
F: __dxlog_file6,
|
|
1650
|
-
L:
|
|
1678
|
+
L: 188,
|
|
1651
1679
|
S: this,
|
|
1652
1680
|
C: (f, a) => f(...a)
|
|
1653
1681
|
});
|
|
1654
1682
|
try {
|
|
1655
1683
|
(0, import_invariant6.invariant)(this.invitation, "Invitation is not set.", {
|
|
1656
1684
|
F: __dxlog_file6,
|
|
1657
|
-
L:
|
|
1685
|
+
L: 191,
|
|
1658
1686
|
S: this,
|
|
1659
1687
|
A: [
|
|
1660
1688
|
"this.invitation",
|
|
@@ -1669,7 +1697,7 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
1669
1697
|
id: traceId
|
|
1670
1698
|
}), {
|
|
1671
1699
|
F: __dxlog_file6,
|
|
1672
|
-
L:
|
|
1700
|
+
L: 199,
|
|
1673
1701
|
S: this,
|
|
1674
1702
|
C: (f, a) => f(...a)
|
|
1675
1703
|
});
|
|
@@ -1726,7 +1754,7 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
|
|
|
1726
1754
|
options: async (options) => {
|
|
1727
1755
|
(0, import_invariant6.invariant)(!this._remoteOptions, "Remote options already set.", {
|
|
1728
1756
|
F: __dxlog_file6,
|
|
1729
|
-
L:
|
|
1757
|
+
L: 266,
|
|
1730
1758
|
S: this,
|
|
1731
1759
|
A: [
|
|
1732
1760
|
"!this._remoteOptions",
|
|
@@ -1753,7 +1781,7 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
|
|
|
1753
1781
|
try {
|
|
1754
1782
|
(0, import_log5.log)("begin options", void 0, {
|
|
1755
1783
|
F: __dxlog_file6,
|
|
1756
|
-
L:
|
|
1784
|
+
L: 287,
|
|
1757
1785
|
S: this,
|
|
1758
1786
|
C: (f, a) => f(...a)
|
|
1759
1787
|
});
|
|
@@ -1765,7 +1793,7 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
|
|
|
1765
1793
|
}));
|
|
1766
1794
|
(0, import_log5.log)("end options", void 0, {
|
|
1767
1795
|
F: __dxlog_file6,
|
|
1768
|
-
L:
|
|
1796
|
+
L: 290,
|
|
1769
1797
|
S: this,
|
|
1770
1798
|
C: (f, a) => f(...a)
|
|
1771
1799
|
});
|
|
@@ -1779,7 +1807,7 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
|
|
|
1779
1807
|
} catch (err) {
|
|
1780
1808
|
(0, import_log5.log)("openError", err, {
|
|
1781
1809
|
F: __dxlog_file6,
|
|
1782
|
-
L:
|
|
1810
|
+
L: 300,
|
|
1783
1811
|
S: this,
|
|
1784
1812
|
C: (f, a) => f(...a)
|
|
1785
1813
|
});
|
|
@@ -1789,7 +1817,7 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
|
|
|
1789
1817
|
async onClose() {
|
|
1790
1818
|
(0, import_log5.log)("onClose", void 0, {
|
|
1791
1819
|
F: __dxlog_file6,
|
|
1792
|
-
L:
|
|
1820
|
+
L: 306,
|
|
1793
1821
|
S: this,
|
|
1794
1822
|
C: (f, a) => f(...a)
|
|
1795
1823
|
});
|
|
@@ -1805,49 +1833,7 @@ var InvitationsHandler = class {
|
|
|
1805
1833
|
constructor(_networkManager) {
|
|
1806
1834
|
this._networkManager = _networkManager;
|
|
1807
1835
|
}
|
|
1808
|
-
|
|
1809
|
-
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 ?? {};
|
|
1810
|
-
const authCode = options?.authCode ?? (authMethod === import_services3.Invitation.AuthMethod.SHARED_SECRET ? (0, import_credentials7.generatePasscode)(import_client_protocol2.AUTHENTICATION_CODE_LENGTH) : void 0);
|
|
1811
|
-
(0, import_invariant5.invariant)(protocol, void 0, {
|
|
1812
|
-
F: __dxlog_file7,
|
|
1813
|
-
L: 84,
|
|
1814
|
-
S: this,
|
|
1815
|
-
A: [
|
|
1816
|
-
"protocol",
|
|
1817
|
-
""
|
|
1818
|
-
]
|
|
1819
|
-
});
|
|
1820
|
-
const invitation = {
|
|
1821
|
-
invitationId,
|
|
1822
|
-
type,
|
|
1823
|
-
authMethod,
|
|
1824
|
-
state,
|
|
1825
|
-
swarmKey,
|
|
1826
|
-
authCode,
|
|
1827
|
-
timeout,
|
|
1828
|
-
persistent,
|
|
1829
|
-
created,
|
|
1830
|
-
lifetime,
|
|
1831
|
-
...protocol.getInvitationContext()
|
|
1832
|
-
};
|
|
1833
|
-
const stream = new import_async7.PushStream();
|
|
1834
|
-
const ctx = new import_context4.Context({
|
|
1835
|
-
onError: (err) => {
|
|
1836
|
-
stream.error(err);
|
|
1837
|
-
void ctx.dispose();
|
|
1838
|
-
}
|
|
1839
|
-
});
|
|
1840
|
-
ctx.onDispose(() => {
|
|
1841
|
-
(0, import_log4.log)("complete", {
|
|
1842
|
-
...protocol.toJSON()
|
|
1843
|
-
}, {
|
|
1844
|
-
F: __dxlog_file7,
|
|
1845
|
-
L: 109,
|
|
1846
|
-
S: this,
|
|
1847
|
-
C: (f, a) => f(...a)
|
|
1848
|
-
});
|
|
1849
|
-
stream.complete();
|
|
1850
|
-
});
|
|
1836
|
+
handleInvitationFlow(ctx, stream, protocol, invitation) {
|
|
1851
1837
|
const createExtension = () => {
|
|
1852
1838
|
const extension = new InvitationHostExtension({
|
|
1853
1839
|
onStateUpdate: (invitation2) => {
|
|
@@ -1856,8 +1842,8 @@ var InvitationsHandler = class {
|
|
|
1856
1842
|
state: import_services3.Invitation.State.READY_FOR_AUTHENTICATION
|
|
1857
1843
|
});
|
|
1858
1844
|
},
|
|
1859
|
-
resolveInvitation: async ({ invitationId
|
|
1860
|
-
if (
|
|
1845
|
+
resolveInvitation: async ({ invitationId }) => {
|
|
1846
|
+
if (invitationId && invitationId !== invitation.invitationId) {
|
|
1861
1847
|
return void 0;
|
|
1862
1848
|
}
|
|
1863
1849
|
return invitation;
|
|
@@ -1867,14 +1853,14 @@ var InvitationsHandler = class {
|
|
|
1867
1853
|
const deviceKey = admissionRequest.device?.deviceKey ?? admissionRequest.space?.deviceKey;
|
|
1868
1854
|
(0, import_invariant5.invariant)(deviceKey, void 0, {
|
|
1869
1855
|
F: __dxlog_file7,
|
|
1870
|
-
L:
|
|
1856
|
+
L: 87,
|
|
1871
1857
|
S: this,
|
|
1872
1858
|
A: [
|
|
1873
1859
|
"deviceKey",
|
|
1874
1860
|
""
|
|
1875
1861
|
]
|
|
1876
1862
|
});
|
|
1877
|
-
const admissionResponse = await protocol.admit(admissionRequest, extension.guestProfile);
|
|
1863
|
+
const admissionResponse = await protocol.admit(invitation, admissionRequest, extension.guestProfile);
|
|
1878
1864
|
extension.completedTrigger.wake(deviceKey);
|
|
1879
1865
|
return admissionResponse;
|
|
1880
1866
|
} catch (err) {
|
|
@@ -1890,7 +1876,7 @@ var InvitationsHandler = class {
|
|
|
1890
1876
|
id: traceId
|
|
1891
1877
|
}), {
|
|
1892
1878
|
F: __dxlog_file7,
|
|
1893
|
-
L:
|
|
1879
|
+
L: 105,
|
|
1894
1880
|
S: this,
|
|
1895
1881
|
C: (f, a) => f(...a)
|
|
1896
1882
|
});
|
|
@@ -1898,7 +1884,7 @@ var InvitationsHandler = class {
|
|
|
1898
1884
|
...protocol.toJSON()
|
|
1899
1885
|
}, {
|
|
1900
1886
|
F: __dxlog_file7,
|
|
1901
|
-
L:
|
|
1887
|
+
L: 106,
|
|
1902
1888
|
S: this,
|
|
1903
1889
|
C: (f, a) => f(...a)
|
|
1904
1890
|
});
|
|
@@ -1907,14 +1893,14 @@ var InvitationsHandler = class {
|
|
|
1907
1893
|
state: import_services3.Invitation.State.CONNECTED
|
|
1908
1894
|
});
|
|
1909
1895
|
const deviceKey = await extension.completedTrigger.wait({
|
|
1910
|
-
timeout
|
|
1896
|
+
timeout: invitation.timeout
|
|
1911
1897
|
});
|
|
1912
1898
|
(0, import_log4.log)("admitted guest", {
|
|
1913
1899
|
guest: deviceKey,
|
|
1914
1900
|
...protocol.toJSON()
|
|
1915
1901
|
}, {
|
|
1916
1902
|
F: __dxlog_file7,
|
|
1917
|
-
L:
|
|
1903
|
+
L: 109,
|
|
1918
1904
|
S: this,
|
|
1919
1905
|
C: (f, a) => f(...a)
|
|
1920
1906
|
});
|
|
@@ -1926,7 +1912,7 @@ var InvitationsHandler = class {
|
|
|
1926
1912
|
id: traceId
|
|
1927
1913
|
}), {
|
|
1928
1914
|
F: __dxlog_file7,
|
|
1929
|
-
L:
|
|
1915
|
+
L: 111,
|
|
1930
1916
|
S: this,
|
|
1931
1917
|
C: (f, a) => f(...a)
|
|
1932
1918
|
});
|
|
@@ -1936,7 +1922,7 @@ var InvitationsHandler = class {
|
|
|
1936
1922
|
...protocol.toJSON()
|
|
1937
1923
|
}, {
|
|
1938
1924
|
F: __dxlog_file7,
|
|
1939
|
-
L:
|
|
1925
|
+
L: 114,
|
|
1940
1926
|
S: this,
|
|
1941
1927
|
C: (f, a) => f(...a)
|
|
1942
1928
|
});
|
|
@@ -1947,7 +1933,7 @@ var InvitationsHandler = class {
|
|
|
1947
1933
|
} else {
|
|
1948
1934
|
import_log4.log.error("failed", err, {
|
|
1949
1935
|
F: __dxlog_file7,
|
|
1950
|
-
L:
|
|
1936
|
+
L: 117,
|
|
1951
1937
|
S: this,
|
|
1952
1938
|
C: (f, a) => f(...a)
|
|
1953
1939
|
});
|
|
@@ -1958,12 +1944,12 @@ var InvitationsHandler = class {
|
|
|
1958
1944
|
error: err
|
|
1959
1945
|
}), {
|
|
1960
1946
|
F: __dxlog_file7,
|
|
1961
|
-
L:
|
|
1947
|
+
L: 120,
|
|
1962
1948
|
S: this,
|
|
1963
1949
|
C: (f, a) => f(...a)
|
|
1964
1950
|
});
|
|
1965
1951
|
} finally {
|
|
1966
|
-
if (
|
|
1952
|
+
if (!invitation.multiUse) {
|
|
1967
1953
|
await swarmConnection.close();
|
|
1968
1954
|
await ctx.dispose();
|
|
1969
1955
|
}
|
|
@@ -1979,7 +1965,7 @@ var InvitationsHandler = class {
|
|
|
1979
1965
|
...protocol.toJSON()
|
|
1980
1966
|
}, {
|
|
1981
1967
|
F: __dxlog_file7,
|
|
1982
|
-
L:
|
|
1968
|
+
L: 135,
|
|
1983
1969
|
S: this,
|
|
1984
1970
|
C: (f, a) => f(...a)
|
|
1985
1971
|
});
|
|
@@ -1990,7 +1976,7 @@ var InvitationsHandler = class {
|
|
|
1990
1976
|
} else {
|
|
1991
1977
|
import_log4.log.error("failed", err, {
|
|
1992
1978
|
F: __dxlog_file7,
|
|
1993
|
-
L:
|
|
1979
|
+
L: 138,
|
|
1994
1980
|
S: this,
|
|
1995
1981
|
C: (f, a) => f(...a)
|
|
1996
1982
|
});
|
|
@@ -2000,11 +1986,11 @@ var InvitationsHandler = class {
|
|
|
2000
1986
|
});
|
|
2001
1987
|
return extension;
|
|
2002
1988
|
};
|
|
2003
|
-
if (invitation.lifetime && invitation.created
|
|
1989
|
+
if (invitation.lifetime && invitation.created) {
|
|
2004
1990
|
if (invitation.created.getTime() + invitation.lifetime * 1e3 < Date.now()) {
|
|
2005
1991
|
import_log4.log.warn("invitation has already expired", void 0, {
|
|
2006
1992
|
F: __dxlog_file7,
|
|
2007
|
-
L:
|
|
1993
|
+
L: 149,
|
|
2008
1994
|
S: this,
|
|
2009
1995
|
C: (f, a) => f(...a)
|
|
2010
1996
|
});
|
|
@@ -2038,24 +2024,12 @@ var InvitationsHandler = class {
|
|
|
2038
2024
|
state: import_services3.Invitation.State.CONNECTING
|
|
2039
2025
|
});
|
|
2040
2026
|
});
|
|
2041
|
-
const observable = new import_client_protocol2.CancellableInvitation({
|
|
2042
|
-
initialInvitation: invitation,
|
|
2043
|
-
subscriber: stream.observable,
|
|
2044
|
-
onCancel: async () => {
|
|
2045
|
-
stream.next({
|
|
2046
|
-
...invitation,
|
|
2047
|
-
state: import_services3.Invitation.State.CANCELLED
|
|
2048
|
-
});
|
|
2049
|
-
await ctx.dispose();
|
|
2050
|
-
}
|
|
2051
|
-
});
|
|
2052
|
-
return observable;
|
|
2053
2027
|
}
|
|
2054
2028
|
acceptInvitation(protocol, invitation, deviceProfile) {
|
|
2055
2029
|
const { timeout = import_client_protocol2.INVITATION_TIMEOUT } = invitation;
|
|
2056
2030
|
(0, import_invariant5.invariant)(protocol, void 0, {
|
|
2057
2031
|
F: __dxlog_file7,
|
|
2058
|
-
L:
|
|
2032
|
+
L: 191,
|
|
2059
2033
|
S: this,
|
|
2060
2034
|
A: [
|
|
2061
2035
|
"protocol",
|
|
@@ -2065,7 +2039,7 @@ var InvitationsHandler = class {
|
|
|
2065
2039
|
if (deviceProfile) {
|
|
2066
2040
|
(0, import_invariant5.invariant)(invitation.kind === import_services3.Invitation.Kind.DEVICE, "deviceProfile provided for non-device invitation", {
|
|
2067
2041
|
F: __dxlog_file7,
|
|
2068
|
-
L:
|
|
2042
|
+
L: 194,
|
|
2069
2043
|
S: this,
|
|
2070
2044
|
A: [
|
|
2071
2045
|
"invitation.kind === Invitation.Kind.DEVICE",
|
|
@@ -2080,7 +2054,7 @@ var InvitationsHandler = class {
|
|
|
2080
2054
|
const setState = (newData) => {
|
|
2081
2055
|
(0, import_invariant5.invariant)(newData.state !== void 0, void 0, {
|
|
2082
2056
|
F: __dxlog_file7,
|
|
2083
|
-
L:
|
|
2057
|
+
L: 205,
|
|
2084
2058
|
S: this,
|
|
2085
2059
|
A: [
|
|
2086
2060
|
"newData.state !== undefined",
|
|
@@ -2100,7 +2074,7 @@ var InvitationsHandler = class {
|
|
|
2100
2074
|
...protocol.toJSON()
|
|
2101
2075
|
}, {
|
|
2102
2076
|
F: __dxlog_file7,
|
|
2103
|
-
L:
|
|
2077
|
+
L: 213,
|
|
2104
2078
|
S: this,
|
|
2105
2079
|
C: (f, a) => f(...a)
|
|
2106
2080
|
});
|
|
@@ -2110,7 +2084,7 @@ var InvitationsHandler = class {
|
|
|
2110
2084
|
} else {
|
|
2111
2085
|
import_log4.log.warn("auth failed", err, {
|
|
2112
2086
|
F: __dxlog_file7,
|
|
2113
|
-
L:
|
|
2087
|
+
L: 216,
|
|
2114
2088
|
S: this,
|
|
2115
2089
|
C: (f, a) => f(...a)
|
|
2116
2090
|
});
|
|
@@ -2124,7 +2098,7 @@ var InvitationsHandler = class {
|
|
|
2124
2098
|
...protocol.toJSON()
|
|
2125
2099
|
}, {
|
|
2126
2100
|
F: __dxlog_file7,
|
|
2127
|
-
L:
|
|
2101
|
+
L: 224,
|
|
2128
2102
|
S: this,
|
|
2129
2103
|
C: (f, a) => f(...a)
|
|
2130
2104
|
});
|
|
@@ -2139,7 +2113,7 @@ var InvitationsHandler = class {
|
|
|
2139
2113
|
currentState
|
|
2140
2114
|
}, {
|
|
2141
2115
|
F: __dxlog_file7,
|
|
2142
|
-
L:
|
|
2116
|
+
L: 234,
|
|
2143
2117
|
S: this,
|
|
2144
2118
|
C: (f, a) => f(...a)
|
|
2145
2119
|
});
|
|
@@ -2154,7 +2128,7 @@ var InvitationsHandler = class {
|
|
|
2154
2128
|
id: traceId
|
|
2155
2129
|
}), {
|
|
2156
2130
|
F: __dxlog_file7,
|
|
2157
|
-
L:
|
|
2131
|
+
L: 243,
|
|
2158
2132
|
S: this,
|
|
2159
2133
|
C: (f, a) => f(...a)
|
|
2160
2134
|
});
|
|
@@ -2166,7 +2140,7 @@ var InvitationsHandler = class {
|
|
|
2166
2140
|
...protocol.toJSON()
|
|
2167
2141
|
}, {
|
|
2168
2142
|
F: __dxlog_file7,
|
|
2169
|
-
L:
|
|
2143
|
+
L: 251,
|
|
2170
2144
|
S: this,
|
|
2171
2145
|
C: (f, a) => f(...a)
|
|
2172
2146
|
});
|
|
@@ -2177,7 +2151,7 @@ var InvitationsHandler = class {
|
|
|
2177
2151
|
...protocol.toJSON()
|
|
2178
2152
|
}, {
|
|
2179
2153
|
F: __dxlog_file7,
|
|
2180
|
-
L:
|
|
2154
|
+
L: 255,
|
|
2181
2155
|
S: this,
|
|
2182
2156
|
C: (f, a) => f(...a)
|
|
2183
2157
|
});
|
|
@@ -2187,62 +2161,28 @@ var InvitationsHandler = class {
|
|
|
2187
2161
|
response: introductionResponse
|
|
2188
2162
|
}, {
|
|
2189
2163
|
F: __dxlog_file7,
|
|
2190
|
-
L:
|
|
2164
|
+
L: 259,
|
|
2191
2165
|
S: this,
|
|
2192
2166
|
C: (f, a) => f(...a)
|
|
2193
2167
|
});
|
|
2194
2168
|
invitation.authMethod = introductionResponse.authMethod;
|
|
2195
2169
|
if (isAuthenticationRequired(invitation)) {
|
|
2196
|
-
|
|
2197
|
-
|
|
2198
|
-
|
|
2199
|
-
|
|
2200
|
-
|
|
2201
|
-
|
|
2202
|
-
|
|
2203
|
-
|
|
2204
|
-
state: import_services3.Invitation.State.READY_FOR_AUTHENTICATION
|
|
2205
|
-
});
|
|
2206
|
-
const authCode = await authenticated.wait({
|
|
2207
|
-
timeout
|
|
2208
|
-
});
|
|
2209
|
-
(0, import_log4.log)("sending authentication request", void 0, {
|
|
2210
|
-
F: __dxlog_file7,
|
|
2211
|
-
L: 325,
|
|
2212
|
-
S: this,
|
|
2213
|
-
C: (f, a) => f(...a)
|
|
2214
|
-
});
|
|
2215
|
-
setState({
|
|
2216
|
-
state: import_services3.Invitation.State.AUTHENTICATING
|
|
2217
|
-
});
|
|
2218
|
-
const response = await extension.rpc.InvitationHostService.authenticate({
|
|
2219
|
-
authCode
|
|
2220
|
-
});
|
|
2221
|
-
if (response.status === void 0 || response.status === import_invitations.AuthenticationResponse.Status.OK) {
|
|
2170
|
+
switch (invitation.authMethod) {
|
|
2171
|
+
case import_services3.Invitation.AuthMethod.SHARED_SECRET:
|
|
2172
|
+
await this._handleGuestOtpAuth(extension, setState, authenticated, {
|
|
2173
|
+
timeout
|
|
2174
|
+
});
|
|
2175
|
+
break;
|
|
2176
|
+
case import_services3.Invitation.AuthMethod.KNOWN_PUBLIC_KEY:
|
|
2177
|
+
await this._handleGuestKpkAuth(extension, setState, invitation, introductionResponse);
|
|
2222
2178
|
break;
|
|
2223
|
-
}
|
|
2224
|
-
if (response.status === import_invitations.AuthenticationResponse.Status.INVALID_OTP) {
|
|
2225
|
-
if (attempt === MAX_OTP_ATTEMPTS) {
|
|
2226
|
-
throw new Error(`Maximum retry attempts: ${MAX_OTP_ATTEMPTS}`);
|
|
2227
|
-
} else {
|
|
2228
|
-
(0, import_log4.log)("retrying invalid code", {
|
|
2229
|
-
attempt
|
|
2230
|
-
}, {
|
|
2231
|
-
F: __dxlog_file7,
|
|
2232
|
-
L: 336,
|
|
2233
|
-
S: this,
|
|
2234
|
-
C: (f, a) => f(...a)
|
|
2235
|
-
});
|
|
2236
|
-
authenticated.reset();
|
|
2237
|
-
}
|
|
2238
|
-
}
|
|
2239
2179
|
}
|
|
2240
2180
|
}
|
|
2241
2181
|
(0, import_log4.log)("request admission", {
|
|
2242
2182
|
...protocol.toJSON()
|
|
2243
2183
|
}, {
|
|
2244
2184
|
F: __dxlog_file7,
|
|
2245
|
-
L:
|
|
2185
|
+
L: 275,
|
|
2246
2186
|
S: this,
|
|
2247
2187
|
C: (f, a) => f(...a)
|
|
2248
2188
|
});
|
|
@@ -2254,7 +2194,7 @@ var InvitationsHandler = class {
|
|
|
2254
2194
|
...protocol.toJSON()
|
|
2255
2195
|
}, {
|
|
2256
2196
|
F: __dxlog_file7,
|
|
2257
|
-
L:
|
|
2197
|
+
L: 286,
|
|
2258
2198
|
S: this,
|
|
2259
2199
|
C: (f, a) => f(...a)
|
|
2260
2200
|
});
|
|
@@ -2267,7 +2207,7 @@ var InvitationsHandler = class {
|
|
|
2267
2207
|
id: traceId
|
|
2268
2208
|
}), {
|
|
2269
2209
|
F: __dxlog_file7,
|
|
2270
|
-
L:
|
|
2210
|
+
L: 288,
|
|
2271
2211
|
S: this,
|
|
2272
2212
|
C: (f, a) => f(...a)
|
|
2273
2213
|
});
|
|
@@ -2277,7 +2217,7 @@ var InvitationsHandler = class {
|
|
|
2277
2217
|
...protocol.toJSON()
|
|
2278
2218
|
}, {
|
|
2279
2219
|
F: __dxlog_file7,
|
|
2280
|
-
L:
|
|
2220
|
+
L: 291,
|
|
2281
2221
|
S: this,
|
|
2282
2222
|
C: (f, a) => f(...a)
|
|
2283
2223
|
});
|
|
@@ -2287,7 +2227,7 @@ var InvitationsHandler = class {
|
|
|
2287
2227
|
} else {
|
|
2288
2228
|
(0, import_log4.log)("auth failed", err, {
|
|
2289
2229
|
F: __dxlog_file7,
|
|
2290
|
-
L:
|
|
2230
|
+
L: 294,
|
|
2291
2231
|
S: this,
|
|
2292
2232
|
C: (f, a) => f(...a)
|
|
2293
2233
|
});
|
|
@@ -2298,7 +2238,7 @@ var InvitationsHandler = class {
|
|
|
2298
2238
|
error: err
|
|
2299
2239
|
}), {
|
|
2300
2240
|
F: __dxlog_file7,
|
|
2301
|
-
L:
|
|
2241
|
+
L: 297,
|
|
2302
2242
|
S: this,
|
|
2303
2243
|
C: (f, a) => f(...a)
|
|
2304
2244
|
});
|
|
@@ -2316,7 +2256,7 @@ var InvitationsHandler = class {
|
|
|
2316
2256
|
...protocol.toJSON()
|
|
2317
2257
|
}, {
|
|
2318
2258
|
F: __dxlog_file7,
|
|
2319
|
-
L:
|
|
2259
|
+
L: 308,
|
|
2320
2260
|
S: this,
|
|
2321
2261
|
C: (f, a) => f(...a)
|
|
2322
2262
|
});
|
|
@@ -2326,7 +2266,7 @@ var InvitationsHandler = class {
|
|
|
2326
2266
|
} else {
|
|
2327
2267
|
(0, import_log4.log)("auth failed", err, {
|
|
2328
2268
|
F: __dxlog_file7,
|
|
2329
|
-
L:
|
|
2269
|
+
L: 311,
|
|
2330
2270
|
S: this,
|
|
2331
2271
|
C: (f, a) => f(...a)
|
|
2332
2272
|
});
|
|
@@ -2343,7 +2283,7 @@ var InvitationsHandler = class {
|
|
|
2343
2283
|
} else {
|
|
2344
2284
|
(0, import_invariant5.invariant)(invitation.swarmKey, void 0, {
|
|
2345
2285
|
F: __dxlog_file7,
|
|
2346
|
-
L:
|
|
2286
|
+
L: 325,
|
|
2347
2287
|
S: this,
|
|
2348
2288
|
A: [
|
|
2349
2289
|
"invitation.swarmKey",
|
|
@@ -2381,198 +2321,110 @@ var InvitationsHandler = class {
|
|
|
2381
2321
|
});
|
|
2382
2322
|
return observable;
|
|
2383
2323
|
}
|
|
2324
|
+
async _handleGuestOtpAuth(extension, setState, authenticated, options) {
|
|
2325
|
+
for (let attempt = 1; attempt <= MAX_OTP_ATTEMPTS; attempt++) {
|
|
2326
|
+
(0, import_log4.log)("guest waiting for authentication code...", void 0, {
|
|
2327
|
+
F: __dxlog_file7,
|
|
2328
|
+
L: 365,
|
|
2329
|
+
S: this,
|
|
2330
|
+
C: (f, a) => f(...a)
|
|
2331
|
+
});
|
|
2332
|
+
setState({
|
|
2333
|
+
state: import_services3.Invitation.State.READY_FOR_AUTHENTICATION
|
|
2334
|
+
});
|
|
2335
|
+
const authCode = await authenticated.wait(options);
|
|
2336
|
+
(0, import_log4.log)("sending authentication request", void 0, {
|
|
2337
|
+
F: __dxlog_file7,
|
|
2338
|
+
L: 369,
|
|
2339
|
+
S: this,
|
|
2340
|
+
C: (f, a) => f(...a)
|
|
2341
|
+
});
|
|
2342
|
+
setState({
|
|
2343
|
+
state: import_services3.Invitation.State.AUTHENTICATING
|
|
2344
|
+
});
|
|
2345
|
+
const response = await extension.rpc.InvitationHostService.authenticate({
|
|
2346
|
+
authCode
|
|
2347
|
+
});
|
|
2348
|
+
if (response.status === void 0 || response.status === import_invitations.AuthenticationResponse.Status.OK) {
|
|
2349
|
+
break;
|
|
2350
|
+
}
|
|
2351
|
+
if (response.status === import_invitations.AuthenticationResponse.Status.INVALID_OTP) {
|
|
2352
|
+
if (attempt === MAX_OTP_ATTEMPTS) {
|
|
2353
|
+
throw new Error(`Maximum retry attempts: ${MAX_OTP_ATTEMPTS}`);
|
|
2354
|
+
} else {
|
|
2355
|
+
(0, import_log4.log)("retrying invalid code", {
|
|
2356
|
+
attempt
|
|
2357
|
+
}, {
|
|
2358
|
+
F: __dxlog_file7,
|
|
2359
|
+
L: 380,
|
|
2360
|
+
S: this,
|
|
2361
|
+
C: (f, a) => f(...a)
|
|
2362
|
+
});
|
|
2363
|
+
authenticated.reset();
|
|
2364
|
+
}
|
|
2365
|
+
}
|
|
2366
|
+
}
|
|
2367
|
+
}
|
|
2368
|
+
async _handleGuestKpkAuth(extension, setState, invitation, introductionResponse) {
|
|
2369
|
+
if (invitation.guestKeypair?.privateKey == null) {
|
|
2370
|
+
throw new Error("keypair missing in the invitation");
|
|
2371
|
+
}
|
|
2372
|
+
if (introductionResponse.challenge == null) {
|
|
2373
|
+
throw new Error("challenge missing in the introduction");
|
|
2374
|
+
}
|
|
2375
|
+
(0, import_log4.log)("sending authentication request", void 0, {
|
|
2376
|
+
F: __dxlog_file7,
|
|
2377
|
+
L: 399,
|
|
2378
|
+
S: this,
|
|
2379
|
+
C: (f, a) => f(...a)
|
|
2380
|
+
});
|
|
2381
|
+
setState({
|
|
2382
|
+
state: import_services3.Invitation.State.AUTHENTICATING
|
|
2383
|
+
});
|
|
2384
|
+
const signature = (0, import_crypto.sign)(Buffer.from(introductionResponse.challenge), invitation.guestKeypair.privateKey);
|
|
2385
|
+
const response = await extension.rpc.InvitationHostService.authenticate({
|
|
2386
|
+
signedChallenge: signature
|
|
2387
|
+
});
|
|
2388
|
+
if (response.status !== import_invitations.AuthenticationResponse.Status.OK) {
|
|
2389
|
+
throw new Error(`Authentication failed with code: ${response.status}`);
|
|
2390
|
+
}
|
|
2391
|
+
}
|
|
2384
2392
|
};
|
|
2385
|
-
var
|
|
2386
|
-
|
|
2393
|
+
var createAdmissionKeypair = () => {
|
|
2394
|
+
const keypair = (0, import_crypto.createKeyPair)();
|
|
2395
|
+
return {
|
|
2396
|
+
publicKey: import_keys5.PublicKey.from(keypair.publicKey),
|
|
2397
|
+
privateKey: keypair.secretKey
|
|
2398
|
+
};
|
|
2387
2399
|
};
|
|
2388
|
-
var __dxlog_file8 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitations-service.ts";
|
|
2389
2400
|
var InvitationsServiceImpl = class {
|
|
2390
|
-
constructor(
|
|
2391
|
-
this.
|
|
2392
|
-
this._getHandler = _getHandler;
|
|
2393
|
-
this._metadataStore = _metadataStore;
|
|
2394
|
-
this._createInvitations = /* @__PURE__ */ new Map();
|
|
2395
|
-
this._acceptInvitations = /* @__PURE__ */ new Map();
|
|
2396
|
-
this._invitationCreated = new import_async9.Event();
|
|
2397
|
-
this._invitationAccepted = new import_async9.Event();
|
|
2398
|
-
this._removedCreated = new import_async9.Event();
|
|
2399
|
-
this._removedAccepted = new import_async9.Event();
|
|
2400
|
-
this._saved = new import_async9.Event();
|
|
2401
|
-
this._persistentInvitationsLoadedEvent = new import_async9.Event();
|
|
2402
|
-
this._persistentInvitationsLoaded = false;
|
|
2401
|
+
constructor(_invitationsManager) {
|
|
2402
|
+
this._invitationsManager = _invitationsManager;
|
|
2403
2403
|
}
|
|
2404
2404
|
// TODO(burdon): Guest/host label.
|
|
2405
2405
|
getLoggingContext() {
|
|
2406
2406
|
return {};
|
|
2407
2407
|
}
|
|
2408
2408
|
createInvitation(options) {
|
|
2409
|
-
let invitation;
|
|
2410
|
-
const savePersistentInvitationCtx = new import_context6.Context();
|
|
2411
|
-
const existingInvitation = this._createInvitations.get(options.invitationId);
|
|
2412
|
-
if (existingInvitation) {
|
|
2413
|
-
invitation = existingInvitation;
|
|
2414
|
-
} else {
|
|
2415
|
-
const handler = this._getHandler(options);
|
|
2416
|
-
invitation = this._invitationsHandler.createInvitation(handler, options);
|
|
2417
|
-
this._createInvitations.set(invitation.get().invitationId, invitation);
|
|
2418
|
-
this._invitationCreated.emit(invitation.get());
|
|
2419
|
-
}
|
|
2420
2409
|
return new import_codec_protobuf8.Stream(({ next, close }) => {
|
|
2421
|
-
|
|
2422
|
-
(0, import_async9.scheduleTask)(savePersistentInvitationCtx, async () => {
|
|
2423
|
-
try {
|
|
2424
|
-
await this._metadataStore.addInvitation(invitation.get());
|
|
2425
|
-
this._saved.emit(invitation.get());
|
|
2426
|
-
} catch (err) {
|
|
2427
|
-
close(err);
|
|
2428
|
-
}
|
|
2429
|
-
});
|
|
2430
|
-
}
|
|
2431
|
-
invitation.subscribe((invitation2) => {
|
|
2432
|
-
next(invitation2);
|
|
2433
|
-
}, async (err) => {
|
|
2434
|
-
await savePersistentInvitationCtx.dispose();
|
|
2435
|
-
close(err);
|
|
2436
|
-
}, async () => {
|
|
2437
|
-
close();
|
|
2438
|
-
if (invitation.get().persistent) {
|
|
2439
|
-
await savePersistentInvitationCtx.dispose();
|
|
2440
|
-
await this._metadataStore.removeInvitation(invitation.get().invitationId);
|
|
2441
|
-
}
|
|
2442
|
-
this._createInvitations.delete(invitation.get().invitationId);
|
|
2443
|
-
if (invitation.get().type !== import_services5.Invitation.Type.MULTIUSE) {
|
|
2444
|
-
this._removedCreated.emit(invitation.get());
|
|
2445
|
-
}
|
|
2446
|
-
});
|
|
2410
|
+
void this._invitationsManager.createInvitation(options).then((invitation) => invitation.subscribe(next, close, close)).catch(close);
|
|
2447
2411
|
});
|
|
2448
2412
|
}
|
|
2449
|
-
|
|
2450
|
-
const
|
|
2451
|
-
const freshInvitations = persistentInvitations.filter(async (invitation) => !invitationExpired(invitation));
|
|
2452
|
-
const cInvitations = freshInvitations.map((persistentInvitation) => {
|
|
2453
|
-
(0, import_invariant7.invariant)(!this._createInvitations.get(persistentInvitation.invitationId), "invitation already exists", {
|
|
2454
|
-
F: __dxlog_file8,
|
|
2455
|
-
L: 109,
|
|
2456
|
-
S: this,
|
|
2457
|
-
A: [
|
|
2458
|
-
"!this._createInvitations.get(persistentInvitation.invitationId)",
|
|
2459
|
-
"'invitation already exists'"
|
|
2460
|
-
]
|
|
2461
|
-
});
|
|
2462
|
-
const handler = this._getHandler(persistentInvitation);
|
|
2463
|
-
const invitation = this._invitationsHandler.createInvitation(handler, persistentInvitation);
|
|
2464
|
-
this._createInvitations.set(invitation.get().invitationId, invitation);
|
|
2465
|
-
this._invitationCreated.emit(invitation.get());
|
|
2466
|
-
return persistentInvitation;
|
|
2467
|
-
});
|
|
2468
|
-
this._persistentInvitationsLoadedEvent.emit();
|
|
2469
|
-
this._persistentInvitationsLoaded = true;
|
|
2470
|
-
return {
|
|
2471
|
-
invitations: cInvitations
|
|
2472
|
-
};
|
|
2473
|
-
}
|
|
2474
|
-
acceptInvitation({ invitation: options, deviceProfile }) {
|
|
2475
|
-
let invitation;
|
|
2476
|
-
if (deviceProfile) {
|
|
2477
|
-
(0, import_invariant7.invariant)(options.kind === import_services5.Invitation.Kind.DEVICE, "deviceProfile provided for non-device invitation", {
|
|
2478
|
-
F: __dxlog_file8,
|
|
2479
|
-
L: 127,
|
|
2480
|
-
S: this,
|
|
2481
|
-
A: [
|
|
2482
|
-
"options.kind === Invitation.Kind.DEVICE",
|
|
2483
|
-
"'deviceProfile provided for non-device invitation'"
|
|
2484
|
-
]
|
|
2485
|
-
});
|
|
2486
|
-
}
|
|
2487
|
-
const existingInvitation = this._acceptInvitations.get(options.invitationId);
|
|
2488
|
-
if (existingInvitation) {
|
|
2489
|
-
invitation = existingInvitation;
|
|
2490
|
-
} else {
|
|
2491
|
-
const handler = this._getHandler(options);
|
|
2492
|
-
invitation = this._invitationsHandler.acceptInvitation(handler, options, deviceProfile);
|
|
2493
|
-
this._acceptInvitations.set(invitation.get().invitationId, invitation);
|
|
2494
|
-
this._invitationAccepted.emit(invitation.get());
|
|
2495
|
-
}
|
|
2413
|
+
acceptInvitation(request) {
|
|
2414
|
+
const invitation = this._invitationsManager.acceptInvitation(request);
|
|
2496
2415
|
return new import_codec_protobuf8.Stream(({ next, close }) => {
|
|
2497
|
-
invitation.subscribe(
|
|
2498
|
-
next(invitation2);
|
|
2499
|
-
}, (err) => {
|
|
2500
|
-
close(err);
|
|
2501
|
-
}, () => {
|
|
2502
|
-
close();
|
|
2503
|
-
this._acceptInvitations.delete(invitation.get().invitationId);
|
|
2504
|
-
if (invitation.get().type !== import_services5.Invitation.Type.MULTIUSE) {
|
|
2505
|
-
this._removedAccepted.emit(invitation.get());
|
|
2506
|
-
}
|
|
2507
|
-
});
|
|
2416
|
+
invitation.subscribe(next, close, close);
|
|
2508
2417
|
});
|
|
2509
2418
|
}
|
|
2510
|
-
async authenticate(
|
|
2511
|
-
|
|
2512
|
-
F: __dxlog_file8,
|
|
2513
|
-
L: 160,
|
|
2514
|
-
S: this,
|
|
2515
|
-
C: (f, a) => f(...a)
|
|
2516
|
-
});
|
|
2517
|
-
(0, import_invariant7.invariant)(invitationId, void 0, {
|
|
2518
|
-
F: __dxlog_file8,
|
|
2519
|
-
L: 161,
|
|
2520
|
-
S: this,
|
|
2521
|
-
A: [
|
|
2522
|
-
"invitationId",
|
|
2523
|
-
""
|
|
2524
|
-
]
|
|
2525
|
-
});
|
|
2526
|
-
const observable = this._acceptInvitations.get(invitationId);
|
|
2527
|
-
if (!observable) {
|
|
2528
|
-
import_log6.log.warn("invalid invitation", {
|
|
2529
|
-
invitationId
|
|
2530
|
-
}, {
|
|
2531
|
-
F: __dxlog_file8,
|
|
2532
|
-
L: 164,
|
|
2533
|
-
S: this,
|
|
2534
|
-
C: (f, a) => f(...a)
|
|
2535
|
-
});
|
|
2536
|
-
} else {
|
|
2537
|
-
await observable.authenticate(authCode);
|
|
2538
|
-
}
|
|
2419
|
+
async authenticate(request) {
|
|
2420
|
+
return this._invitationsManager.authenticate(request);
|
|
2539
2421
|
}
|
|
2540
|
-
async cancelInvitation(
|
|
2541
|
-
|
|
2542
|
-
invitationId
|
|
2543
|
-
}, {
|
|
2544
|
-
F: __dxlog_file8,
|
|
2545
|
-
L: 171,
|
|
2546
|
-
S: this,
|
|
2547
|
-
C: (f, a) => f(...a)
|
|
2548
|
-
});
|
|
2549
|
-
(0, import_invariant7.invariant)(invitationId, void 0, {
|
|
2550
|
-
F: __dxlog_file8,
|
|
2551
|
-
L: 172,
|
|
2552
|
-
S: this,
|
|
2553
|
-
A: [
|
|
2554
|
-
"invitationId",
|
|
2555
|
-
""
|
|
2556
|
-
]
|
|
2557
|
-
});
|
|
2558
|
-
const created = this._createInvitations.get(invitationId);
|
|
2559
|
-
const accepted = this._acceptInvitations.get(invitationId);
|
|
2560
|
-
if (created) {
|
|
2561
|
-
await created.cancel();
|
|
2562
|
-
this._createInvitations.delete(invitationId);
|
|
2563
|
-
this._removedCreated.emit(created.get());
|
|
2564
|
-
if (created.get().persistent) {
|
|
2565
|
-
await this._metadataStore.removeInvitation(created.get().invitationId);
|
|
2566
|
-
}
|
|
2567
|
-
} else if (accepted) {
|
|
2568
|
-
await accepted.cancel();
|
|
2569
|
-
this._acceptInvitations.delete(invitationId);
|
|
2570
|
-
this._removedAccepted.emit(accepted.get());
|
|
2571
|
-
}
|
|
2422
|
+
async cancelInvitation(request) {
|
|
2423
|
+
return this._invitationsManager.cancelInvitation(request);
|
|
2572
2424
|
}
|
|
2573
2425
|
queryInvitations() {
|
|
2574
2426
|
return new import_codec_protobuf8.Stream(({ next, ctx }) => {
|
|
2575
|
-
this.
|
|
2427
|
+
this._invitationsManager.invitationCreated.on(ctx, (invitation) => {
|
|
2576
2428
|
next({
|
|
2577
2429
|
action: import_services5.QueryInvitationsResponse.Action.ADDED,
|
|
2578
2430
|
type: import_services5.QueryInvitationsResponse.Type.CREATED,
|
|
@@ -2581,7 +2433,7 @@ var InvitationsServiceImpl = class {
|
|
|
2581
2433
|
]
|
|
2582
2434
|
});
|
|
2583
2435
|
});
|
|
2584
|
-
this.
|
|
2436
|
+
this._invitationsManager.invitationAccepted.on(ctx, (invitation) => {
|
|
2585
2437
|
next({
|
|
2586
2438
|
action: import_services5.QueryInvitationsResponse.Action.ADDED,
|
|
2587
2439
|
type: import_services5.QueryInvitationsResponse.Type.ACCEPTED,
|
|
@@ -2590,7 +2442,7 @@ var InvitationsServiceImpl = class {
|
|
|
2590
2442
|
]
|
|
2591
2443
|
});
|
|
2592
2444
|
});
|
|
2593
|
-
this.
|
|
2445
|
+
this._invitationsManager.removedCreated.on(ctx, (invitation) => {
|
|
2594
2446
|
next({
|
|
2595
2447
|
action: import_services5.QueryInvitationsResponse.Action.REMOVED,
|
|
2596
2448
|
type: import_services5.QueryInvitationsResponse.Type.CREATED,
|
|
@@ -2599,7 +2451,7 @@ var InvitationsServiceImpl = class {
|
|
|
2599
2451
|
]
|
|
2600
2452
|
});
|
|
2601
2453
|
});
|
|
2602
|
-
this.
|
|
2454
|
+
this._invitationsManager.removedAccepted.on(ctx, (invitation) => {
|
|
2603
2455
|
next({
|
|
2604
2456
|
action: import_services5.QueryInvitationsResponse.Action.REMOVED,
|
|
2605
2457
|
type: import_services5.QueryInvitationsResponse.Type.ACCEPTED,
|
|
@@ -2608,7 +2460,7 @@ var InvitationsServiceImpl = class {
|
|
|
2608
2460
|
]
|
|
2609
2461
|
});
|
|
2610
2462
|
});
|
|
2611
|
-
this.
|
|
2463
|
+
this._invitationsManager.saved.on(ctx, (invitation) => {
|
|
2612
2464
|
next({
|
|
2613
2465
|
action: import_services5.QueryInvitationsResponse.Action.SAVED,
|
|
2614
2466
|
type: import_services5.QueryInvitationsResponse.Type.CREATED,
|
|
@@ -2620,32 +2472,25 @@ var InvitationsServiceImpl = class {
|
|
|
2620
2472
|
next({
|
|
2621
2473
|
action: import_services5.QueryInvitationsResponse.Action.ADDED,
|
|
2622
2474
|
type: import_services5.QueryInvitationsResponse.Type.CREATED,
|
|
2623
|
-
invitations:
|
|
2475
|
+
invitations: this._invitationsManager.getCreatedInvitations(),
|
|
2624
2476
|
existing: true
|
|
2625
2477
|
});
|
|
2626
2478
|
next({
|
|
2627
2479
|
action: import_services5.QueryInvitationsResponse.Action.ADDED,
|
|
2628
2480
|
type: import_services5.QueryInvitationsResponse.Type.ACCEPTED,
|
|
2629
|
-
invitations:
|
|
2481
|
+
invitations: this._invitationsManager.getAcceptedInvitations(),
|
|
2630
2482
|
existing: true
|
|
2631
2483
|
});
|
|
2632
|
-
|
|
2484
|
+
this._invitationsManager.onPersistentInvitationsLoaded(ctx, () => {
|
|
2633
2485
|
next({
|
|
2634
2486
|
action: import_services5.QueryInvitationsResponse.Action.LOAD_COMPLETE,
|
|
2635
2487
|
type: import_services5.QueryInvitationsResponse.Type.CREATED
|
|
2636
2488
|
});
|
|
2637
|
-
}
|
|
2638
|
-
this._persistentInvitationsLoadedEvent.on(ctx, () => {
|
|
2639
|
-
next({
|
|
2640
|
-
action: import_services5.QueryInvitationsResponse.Action.LOAD_COMPLETE,
|
|
2641
|
-
type: import_services5.QueryInvitationsResponse.Type.CREATED
|
|
2642
|
-
});
|
|
2643
|
-
});
|
|
2644
|
-
}
|
|
2489
|
+
});
|
|
2645
2490
|
});
|
|
2646
2491
|
}
|
|
2647
2492
|
};
|
|
2648
|
-
var
|
|
2493
|
+
var __dxlog_file8 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/space-invitation-protocol.ts";
|
|
2649
2494
|
var SpaceInvitationProtocol = class {
|
|
2650
2495
|
constructor(_spaceManager, _signingContext, _keyring, _spaceKey) {
|
|
2651
2496
|
this._spaceManager = _spaceManager;
|
|
@@ -2665,10 +2510,10 @@ var SpaceInvitationProtocol = class {
|
|
|
2665
2510
|
spaceKey: this._spaceKey
|
|
2666
2511
|
};
|
|
2667
2512
|
}
|
|
2668
|
-
async admit(request, guestProfile) {
|
|
2669
|
-
(0,
|
|
2670
|
-
F:
|
|
2671
|
-
L:
|
|
2513
|
+
async admit(invitation, request, guestProfile) {
|
|
2514
|
+
(0, import_invariant7.invariant)(this._spaceKey, void 0, {
|
|
2515
|
+
F: __dxlog_file8,
|
|
2516
|
+
L: 55,
|
|
2672
2517
|
S: this,
|
|
2673
2518
|
A: [
|
|
2674
2519
|
"this._spaceKey",
|
|
@@ -2676,18 +2521,18 @@ var SpaceInvitationProtocol = class {
|
|
|
2676
2521
|
]
|
|
2677
2522
|
});
|
|
2678
2523
|
const space = await this._spaceManager.spaces.get(this._spaceKey);
|
|
2679
|
-
(0,
|
|
2680
|
-
F:
|
|
2681
|
-
L:
|
|
2524
|
+
(0, import_invariant7.invariant)(space, void 0, {
|
|
2525
|
+
F: __dxlog_file8,
|
|
2526
|
+
L: 57,
|
|
2682
2527
|
S: this,
|
|
2683
2528
|
A: [
|
|
2684
2529
|
"space",
|
|
2685
2530
|
""
|
|
2686
2531
|
]
|
|
2687
2532
|
});
|
|
2688
|
-
(0,
|
|
2689
|
-
F:
|
|
2690
|
-
L:
|
|
2533
|
+
(0, import_invariant7.invariant)(request.space, void 0, {
|
|
2534
|
+
F: __dxlog_file8,
|
|
2535
|
+
L: 59,
|
|
2691
2536
|
S: this,
|
|
2692
2537
|
A: [
|
|
2693
2538
|
"request.space",
|
|
@@ -2695,42 +2540,105 @@ var SpaceInvitationProtocol = class {
|
|
|
2695
2540
|
]
|
|
2696
2541
|
});
|
|
2697
2542
|
const { identityKey, deviceKey } = request.space;
|
|
2698
|
-
(0,
|
|
2543
|
+
(0, import_log6.log)("writing guest credentials", {
|
|
2699
2544
|
host: this._signingContext.deviceKey,
|
|
2700
2545
|
guest: deviceKey
|
|
2701
2546
|
}, {
|
|
2702
|
-
F:
|
|
2703
|
-
L:
|
|
2547
|
+
F: __dxlog_file8,
|
|
2548
|
+
L: 62,
|
|
2549
|
+
S: this,
|
|
2550
|
+
C: (f, a) => f(...a)
|
|
2551
|
+
});
|
|
2552
|
+
const credentials = await (0, import_credentials7.createAdmissionCredentials)(this._signingContext.credentialSigner, identityKey, space.key, space.inner.genesisFeedKey, guestProfile, invitation.delegationCredentialId);
|
|
2553
|
+
(0, import_invariant7.invariant)(credentials[0].credential, void 0, {
|
|
2554
|
+
F: __dxlog_file8,
|
|
2555
|
+
L: 74,
|
|
2556
|
+
S: this,
|
|
2557
|
+
A: [
|
|
2558
|
+
"credentials[0].credential",
|
|
2559
|
+
""
|
|
2560
|
+
]
|
|
2561
|
+
});
|
|
2562
|
+
const spaceMemberCredential = credentials[0].credential.credential;
|
|
2563
|
+
(0, import_invariant7.invariant)((0, import_credentials7.getCredentialAssertion)(spaceMemberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
|
|
2564
|
+
F: __dxlog_file8,
|
|
2565
|
+
L: 76,
|
|
2566
|
+
S: this,
|
|
2567
|
+
A: [
|
|
2568
|
+
"getCredentialAssertion(spaceMemberCredential)['@type'] === 'dxos.halo.credentials.SpaceMember'",
|
|
2569
|
+
""
|
|
2570
|
+
]
|
|
2571
|
+
});
|
|
2572
|
+
await (0, import_feed_store3.writeMessages)(space.inner.controlPipeline.writer, credentials);
|
|
2573
|
+
return {
|
|
2574
|
+
space: {
|
|
2575
|
+
credential: spaceMemberCredential,
|
|
2576
|
+
controlTimeframe: space.inner.controlPipeline.state.timeframe
|
|
2577
|
+
}
|
|
2578
|
+
};
|
|
2579
|
+
}
|
|
2580
|
+
async delegate(invitation) {
|
|
2581
|
+
(0, import_invariant7.invariant)(this._spaceKey, void 0, {
|
|
2582
|
+
F: __dxlog_file8,
|
|
2583
|
+
L: 89,
|
|
2584
|
+
S: this,
|
|
2585
|
+
A: [
|
|
2586
|
+
"this._spaceKey",
|
|
2587
|
+
""
|
|
2588
|
+
]
|
|
2589
|
+
});
|
|
2590
|
+
const space = await this._spaceManager.spaces.get(this._spaceKey);
|
|
2591
|
+
(0, import_invariant7.invariant)(space, void 0, {
|
|
2592
|
+
F: __dxlog_file8,
|
|
2593
|
+
L: 91,
|
|
2594
|
+
S: this,
|
|
2595
|
+
A: [
|
|
2596
|
+
"space",
|
|
2597
|
+
""
|
|
2598
|
+
]
|
|
2599
|
+
});
|
|
2600
|
+
if (invitation.authMethod === import_services6.Invitation.AuthMethod.KNOWN_PUBLIC_KEY) {
|
|
2601
|
+
(0, import_invariant7.invariant)(invitation.guestKeypair?.publicKey, void 0, {
|
|
2602
|
+
F: __dxlog_file8,
|
|
2603
|
+
L: 93,
|
|
2604
|
+
S: this,
|
|
2605
|
+
A: [
|
|
2606
|
+
"invitation.guestKeypair?.publicKey",
|
|
2607
|
+
""
|
|
2608
|
+
]
|
|
2609
|
+
});
|
|
2610
|
+
}
|
|
2611
|
+
(0, import_log6.log)("writing delegate space invitation", {
|
|
2612
|
+
host: this._signingContext.deviceKey,
|
|
2613
|
+
id: invitation.invitationId
|
|
2614
|
+
}, {
|
|
2615
|
+
F: __dxlog_file8,
|
|
2616
|
+
L: 96,
|
|
2704
2617
|
S: this,
|
|
2705
2618
|
C: (f, a) => f(...a)
|
|
2706
2619
|
});
|
|
2707
|
-
const
|
|
2708
|
-
|
|
2709
|
-
|
|
2710
|
-
|
|
2711
|
-
|
|
2712
|
-
|
|
2713
|
-
|
|
2714
|
-
|
|
2715
|
-
]
|
|
2620
|
+
const credential = await (0, import_credentials7.createDelegatedSpaceInvitationCredential)(this._signingContext.credentialSigner, space.key, {
|
|
2621
|
+
invitationId: invitation.invitationId,
|
|
2622
|
+
authMethod: invitation.authMethod,
|
|
2623
|
+
swarmKey: invitation.swarmKey,
|
|
2624
|
+
role: import_credentials8.SpaceMember.Role.ADMIN,
|
|
2625
|
+
expiresOn: invitation.lifetime ? new Date((invitation.created?.getTime() ?? Date.now()) + invitation.lifetime) : void 0,
|
|
2626
|
+
multiUse: invitation.multiUse ?? false,
|
|
2627
|
+
guestKey: invitation.authMethod === import_services6.Invitation.AuthMethod.KNOWN_PUBLIC_KEY ? invitation.guestKeypair.publicKey : void 0
|
|
2716
2628
|
});
|
|
2717
|
-
|
|
2718
|
-
|
|
2719
|
-
|
|
2720
|
-
L: 67,
|
|
2629
|
+
(0, import_invariant7.invariant)(credential.credential, void 0, {
|
|
2630
|
+
F: __dxlog_file8,
|
|
2631
|
+
L: 116,
|
|
2721
2632
|
S: this,
|
|
2722
2633
|
A: [
|
|
2723
|
-
"
|
|
2634
|
+
"credential.credential",
|
|
2724
2635
|
""
|
|
2725
2636
|
]
|
|
2726
2637
|
});
|
|
2727
|
-
await (0, import_feed_store3.writeMessages)(space.inner.controlPipeline.writer,
|
|
2728
|
-
|
|
2729
|
-
|
|
2730
|
-
|
|
2731
|
-
controlTimeframe: space.inner.controlPipeline.state.timeframe
|
|
2732
|
-
}
|
|
2733
|
-
};
|
|
2638
|
+
await (0, import_feed_store3.writeMessages)(space.inner.controlPipeline.writer, [
|
|
2639
|
+
credential
|
|
2640
|
+
]);
|
|
2641
|
+
return credential.credential.credential.id;
|
|
2734
2642
|
}
|
|
2735
2643
|
checkInvitation(invitation) {
|
|
2736
2644
|
if (invitation.spaceKey && this._spaceManager.spaces.has(invitation.spaceKey)) {
|
|
@@ -2755,9 +2663,9 @@ var SpaceInvitationProtocol = class {
|
|
|
2755
2663
|
};
|
|
2756
2664
|
}
|
|
2757
2665
|
async accept(response) {
|
|
2758
|
-
(0,
|
|
2759
|
-
F:
|
|
2760
|
-
L:
|
|
2666
|
+
(0, import_invariant7.invariant)(response.space, void 0, {
|
|
2667
|
+
F: __dxlog_file8,
|
|
2668
|
+
L: 149,
|
|
2761
2669
|
S: this,
|
|
2762
2670
|
A: [
|
|
2763
2671
|
"response.space",
|
|
@@ -2765,19 +2673,19 @@ var SpaceInvitationProtocol = class {
|
|
|
2765
2673
|
]
|
|
2766
2674
|
});
|
|
2767
2675
|
const { credential, controlTimeframe, dataTimeframe } = response.space;
|
|
2768
|
-
const assertion = (0,
|
|
2769
|
-
(0,
|
|
2770
|
-
F:
|
|
2771
|
-
L:
|
|
2676
|
+
const assertion = (0, import_credentials7.getCredentialAssertion)(credential);
|
|
2677
|
+
(0, import_invariant7.invariant)(assertion["@type"] === "dxos.halo.credentials.SpaceMember", "Invalid credential", {
|
|
2678
|
+
F: __dxlog_file8,
|
|
2679
|
+
L: 152,
|
|
2772
2680
|
S: this,
|
|
2773
2681
|
A: [
|
|
2774
2682
|
"assertion['@type'] === 'dxos.halo.credentials.SpaceMember'",
|
|
2775
2683
|
"'Invalid credential'"
|
|
2776
2684
|
]
|
|
2777
2685
|
});
|
|
2778
|
-
(0,
|
|
2779
|
-
F:
|
|
2780
|
-
L:
|
|
2686
|
+
(0, import_invariant7.invariant)(credential.subject.id.equals(this._signingContext.identityKey), void 0, {
|
|
2687
|
+
F: __dxlog_file8,
|
|
2688
|
+
L: 153,
|
|
2781
2689
|
S: this,
|
|
2782
2690
|
A: [
|
|
2783
2691
|
"credential.subject.id.equals(this._signingContext.identityKey)",
|
|
@@ -2799,6 +2707,284 @@ var SpaceInvitationProtocol = class {
|
|
|
2799
2707
|
};
|
|
2800
2708
|
}
|
|
2801
2709
|
};
|
|
2710
|
+
var __dxlog_file9 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitations-manager.ts";
|
|
2711
|
+
var InvitationsManager = class {
|
|
2712
|
+
constructor(_invitationsHandler, _getHandler, _metadataStore) {
|
|
2713
|
+
this._invitationsHandler = _invitationsHandler;
|
|
2714
|
+
this._getHandler = _getHandler;
|
|
2715
|
+
this._metadataStore = _metadataStore;
|
|
2716
|
+
this._createInvitations = /* @__PURE__ */ new Map();
|
|
2717
|
+
this._acceptInvitations = /* @__PURE__ */ new Map();
|
|
2718
|
+
this.invitationCreated = new import_async9.Event();
|
|
2719
|
+
this.invitationAccepted = new import_async9.Event();
|
|
2720
|
+
this.removedCreated = new import_async9.Event();
|
|
2721
|
+
this.removedAccepted = new import_async9.Event();
|
|
2722
|
+
this.saved = new import_async9.Event();
|
|
2723
|
+
this._persistentInvitationsLoadedEvent = new import_async9.Event();
|
|
2724
|
+
this._persistentInvitationsLoaded = false;
|
|
2725
|
+
}
|
|
2726
|
+
async createInvitation(options) {
|
|
2727
|
+
if (options.invitationId) {
|
|
2728
|
+
const existingInvitation = this._createInvitations.get(options.invitationId);
|
|
2729
|
+
if (existingInvitation) {
|
|
2730
|
+
return existingInvitation;
|
|
2731
|
+
}
|
|
2732
|
+
}
|
|
2733
|
+
const handler = this._getHandler(options);
|
|
2734
|
+
const invitation = this._createInvitation(handler, options);
|
|
2735
|
+
const { ctx, stream, observableInvitation } = this._createObservableInvitation(handler, invitation);
|
|
2736
|
+
this._createInvitations.set(invitation.invitationId, observableInvitation);
|
|
2737
|
+
this.invitationCreated.emit(invitation);
|
|
2738
|
+
this._onInvitationComplete(observableInvitation, async () => {
|
|
2739
|
+
this._createInvitations.delete(observableInvitation.get().invitationId);
|
|
2740
|
+
this.removedCreated.emit(observableInvitation.get());
|
|
2741
|
+
if (observableInvitation.get().persistent) {
|
|
2742
|
+
await this._safeDeleteInvitation(observableInvitation.get());
|
|
2743
|
+
}
|
|
2744
|
+
});
|
|
2745
|
+
try {
|
|
2746
|
+
await this._persistIfRequired(handler, stream, invitation);
|
|
2747
|
+
} catch (err) {
|
|
2748
|
+
import_log7.log.catch(err, void 0, {
|
|
2749
|
+
F: __dxlog_file9,
|
|
2750
|
+
L: 76,
|
|
2751
|
+
S: this,
|
|
2752
|
+
C: (f, a) => f(...a)
|
|
2753
|
+
});
|
|
2754
|
+
await observableInvitation.cancel();
|
|
2755
|
+
return observableInvitation;
|
|
2756
|
+
}
|
|
2757
|
+
this._invitationsHandler.handleInvitationFlow(ctx, stream, handler, observableInvitation.get());
|
|
2758
|
+
return observableInvitation;
|
|
2759
|
+
}
|
|
2760
|
+
async loadPersistentInvitations() {
|
|
2761
|
+
if (this._persistentInvitationsLoaded) {
|
|
2762
|
+
const invitations = this.getCreatedInvitations().filter((i) => i.persistent);
|
|
2763
|
+
return {
|
|
2764
|
+
invitations
|
|
2765
|
+
};
|
|
2766
|
+
}
|
|
2767
|
+
try {
|
|
2768
|
+
const persistentInvitations = this._metadataStore.getInvitations();
|
|
2769
|
+
const freshInvitations = persistentInvitations.filter((invitation) => !(0, import_echo_pipeline.hasInvitationExpired)(invitation));
|
|
2770
|
+
const loadTasks = freshInvitations.map((persistentInvitation) => {
|
|
2771
|
+
(0, import_invariant8.invariant)(!this._createInvitations.get(persistentInvitation.invitationId), "invitation already exists", {
|
|
2772
|
+
F: __dxlog_file9,
|
|
2773
|
+
L: 97,
|
|
2774
|
+
S: this,
|
|
2775
|
+
A: [
|
|
2776
|
+
"!this._createInvitations.get(persistentInvitation.invitationId)",
|
|
2777
|
+
"'invitation already exists'"
|
|
2778
|
+
]
|
|
2779
|
+
});
|
|
2780
|
+
return this.createInvitation({
|
|
2781
|
+
...persistentInvitation,
|
|
2782
|
+
persistent: false
|
|
2783
|
+
});
|
|
2784
|
+
});
|
|
2785
|
+
const cInvitations = await Promise.all(loadTasks);
|
|
2786
|
+
return {
|
|
2787
|
+
invitations: cInvitations.map((invitation) => invitation.get())
|
|
2788
|
+
};
|
|
2789
|
+
} catch (err) {
|
|
2790
|
+
import_log7.log.catch(err, void 0, {
|
|
2791
|
+
F: __dxlog_file9,
|
|
2792
|
+
L: 104,
|
|
2793
|
+
S: this,
|
|
2794
|
+
C: (f, a) => f(...a)
|
|
2795
|
+
});
|
|
2796
|
+
return {
|
|
2797
|
+
invitations: []
|
|
2798
|
+
};
|
|
2799
|
+
} finally {
|
|
2800
|
+
this._persistentInvitationsLoadedEvent.emit();
|
|
2801
|
+
this._persistentInvitationsLoaded = true;
|
|
2802
|
+
}
|
|
2803
|
+
}
|
|
2804
|
+
acceptInvitation(request) {
|
|
2805
|
+
const options = request.invitation;
|
|
2806
|
+
const existingInvitation = this._acceptInvitations.get(options.invitationId);
|
|
2807
|
+
if (existingInvitation) {
|
|
2808
|
+
return existingInvitation;
|
|
2809
|
+
}
|
|
2810
|
+
const handler = this._getHandler(options);
|
|
2811
|
+
const invitation = this._invitationsHandler.acceptInvitation(handler, options, request.deviceProfile);
|
|
2812
|
+
this._acceptInvitations.set(invitation.get().invitationId, invitation);
|
|
2813
|
+
this.invitationAccepted.emit(invitation.get());
|
|
2814
|
+
this._onInvitationComplete(invitation, () => {
|
|
2815
|
+
this._acceptInvitations.delete(invitation.get().invitationId);
|
|
2816
|
+
this.removedAccepted.emit(invitation.get());
|
|
2817
|
+
});
|
|
2818
|
+
return invitation;
|
|
2819
|
+
}
|
|
2820
|
+
async authenticate({ invitationId, authCode }) {
|
|
2821
|
+
(0, import_log7.log)("authenticating...", void 0, {
|
|
2822
|
+
F: __dxlog_file9,
|
|
2823
|
+
L: 133,
|
|
2824
|
+
S: this,
|
|
2825
|
+
C: (f, a) => f(...a)
|
|
2826
|
+
});
|
|
2827
|
+
(0, import_invariant8.invariant)(invitationId, void 0, {
|
|
2828
|
+
F: __dxlog_file9,
|
|
2829
|
+
L: 134,
|
|
2830
|
+
S: this,
|
|
2831
|
+
A: [
|
|
2832
|
+
"invitationId",
|
|
2833
|
+
""
|
|
2834
|
+
]
|
|
2835
|
+
});
|
|
2836
|
+
const observable = this._acceptInvitations.get(invitationId);
|
|
2837
|
+
if (!observable) {
|
|
2838
|
+
import_log7.log.warn("invalid invitation", {
|
|
2839
|
+
invitationId
|
|
2840
|
+
}, {
|
|
2841
|
+
F: __dxlog_file9,
|
|
2842
|
+
L: 137,
|
|
2843
|
+
S: this,
|
|
2844
|
+
C: (f, a) => f(...a)
|
|
2845
|
+
});
|
|
2846
|
+
} else {
|
|
2847
|
+
await observable.authenticate(authCode);
|
|
2848
|
+
}
|
|
2849
|
+
}
|
|
2850
|
+
async cancelInvitation({ invitationId }) {
|
|
2851
|
+
(0, import_log7.log)("cancelInvitation...", {
|
|
2852
|
+
invitationId
|
|
2853
|
+
}, {
|
|
2854
|
+
F: __dxlog_file9,
|
|
2855
|
+
L: 144,
|
|
2856
|
+
S: this,
|
|
2857
|
+
C: (f, a) => f(...a)
|
|
2858
|
+
});
|
|
2859
|
+
(0, import_invariant8.invariant)(invitationId, void 0, {
|
|
2860
|
+
F: __dxlog_file9,
|
|
2861
|
+
L: 145,
|
|
2862
|
+
S: this,
|
|
2863
|
+
A: [
|
|
2864
|
+
"invitationId",
|
|
2865
|
+
""
|
|
2866
|
+
]
|
|
2867
|
+
});
|
|
2868
|
+
const created = this._createInvitations.get(invitationId);
|
|
2869
|
+
if (created) {
|
|
2870
|
+
if (created.get().persistent) {
|
|
2871
|
+
await this._metadataStore.removeInvitation(invitationId);
|
|
2872
|
+
}
|
|
2873
|
+
await created.cancel();
|
|
2874
|
+
this._createInvitations.delete(invitationId);
|
|
2875
|
+
this.removedCreated.emit(created.get());
|
|
2876
|
+
return;
|
|
2877
|
+
}
|
|
2878
|
+
const accepted = this._acceptInvitations.get(invitationId);
|
|
2879
|
+
if (accepted) {
|
|
2880
|
+
await accepted.cancel();
|
|
2881
|
+
this._acceptInvitations.delete(invitationId);
|
|
2882
|
+
this.removedAccepted.emit(accepted.get());
|
|
2883
|
+
}
|
|
2884
|
+
}
|
|
2885
|
+
getCreatedInvitations() {
|
|
2886
|
+
return [
|
|
2887
|
+
...this._createInvitations.values()
|
|
2888
|
+
].map((i) => i.get());
|
|
2889
|
+
}
|
|
2890
|
+
getAcceptedInvitations() {
|
|
2891
|
+
return [
|
|
2892
|
+
...this._acceptInvitations.values()
|
|
2893
|
+
].map((i) => i.get());
|
|
2894
|
+
}
|
|
2895
|
+
onPersistentInvitationsLoaded(ctx, callback) {
|
|
2896
|
+
if (this._persistentInvitationsLoaded) {
|
|
2897
|
+
callback();
|
|
2898
|
+
} else {
|
|
2899
|
+
this._persistentInvitationsLoadedEvent.once(ctx, () => callback());
|
|
2900
|
+
}
|
|
2901
|
+
}
|
|
2902
|
+
_createInvitation(protocol, options) {
|
|
2903
|
+
const { invitationId = import_keys7.PublicKey.random().toHex(), type = import_services7.Invitation.Type.INTERACTIVE, authMethod = import_services7.Invitation.AuthMethod.SHARED_SECRET, state = import_services7.Invitation.State.INIT, timeout = import_client_protocol3.INVITATION_TIMEOUT, swarmKey = import_keys7.PublicKey.random(), persistent = options?.authMethod !== import_services7.Invitation.AuthMethod.KNOWN_PUBLIC_KEY, created = /* @__PURE__ */ new Date(), guestKeypair = void 0, lifetime = 86400, multiUse = false } = options ?? {};
|
|
2904
|
+
const authCode = options?.authCode ?? (authMethod === import_services7.Invitation.AuthMethod.SHARED_SECRET ? (0, import_credentials9.generatePasscode)(import_client_protocol3.AUTHENTICATION_CODE_LENGTH) : void 0);
|
|
2905
|
+
return {
|
|
2906
|
+
invitationId,
|
|
2907
|
+
type,
|
|
2908
|
+
authMethod,
|
|
2909
|
+
state,
|
|
2910
|
+
swarmKey,
|
|
2911
|
+
authCode,
|
|
2912
|
+
timeout,
|
|
2913
|
+
persistent: persistent && type !== import_services7.Invitation.Type.DELEGATED,
|
|
2914
|
+
guestKeypair: guestKeypair ?? (authMethod === import_services7.Invitation.AuthMethod.KNOWN_PUBLIC_KEY ? createAdmissionKeypair() : void 0),
|
|
2915
|
+
created,
|
|
2916
|
+
lifetime,
|
|
2917
|
+
multiUse,
|
|
2918
|
+
delegationCredentialId: options?.delegationCredentialId,
|
|
2919
|
+
...protocol.getInvitationContext()
|
|
2920
|
+
};
|
|
2921
|
+
}
|
|
2922
|
+
_createObservableInvitation(handler, invitation) {
|
|
2923
|
+
const stream = new import_async9.PushStream();
|
|
2924
|
+
const ctx = new import_context6.Context({
|
|
2925
|
+
onError: (err) => {
|
|
2926
|
+
stream.error(err);
|
|
2927
|
+
void ctx.dispose();
|
|
2928
|
+
}
|
|
2929
|
+
});
|
|
2930
|
+
ctx.onDispose(() => {
|
|
2931
|
+
(0, import_log7.log)("complete", {
|
|
2932
|
+
...handler.toJSON()
|
|
2933
|
+
}, {
|
|
2934
|
+
F: __dxlog_file9,
|
|
2935
|
+
L: 228,
|
|
2936
|
+
S: this,
|
|
2937
|
+
C: (f, a) => f(...a)
|
|
2938
|
+
});
|
|
2939
|
+
stream.complete();
|
|
2940
|
+
});
|
|
2941
|
+
const observableInvitation = new import_client_protocol3.CancellableInvitation({
|
|
2942
|
+
initialInvitation: invitation,
|
|
2943
|
+
subscriber: stream.observable,
|
|
2944
|
+
onCancel: async () => {
|
|
2945
|
+
stream.next({
|
|
2946
|
+
...invitation,
|
|
2947
|
+
state: import_services7.Invitation.State.CANCELLED
|
|
2948
|
+
});
|
|
2949
|
+
await ctx.dispose();
|
|
2950
|
+
}
|
|
2951
|
+
});
|
|
2952
|
+
return {
|
|
2953
|
+
ctx,
|
|
2954
|
+
stream,
|
|
2955
|
+
observableInvitation
|
|
2956
|
+
};
|
|
2957
|
+
}
|
|
2958
|
+
async _persistIfRequired(handler, changeStream, invitation) {
|
|
2959
|
+
if (invitation.type === import_services7.Invitation.Type.DELEGATED && invitation.delegationCredentialId == null) {
|
|
2960
|
+
const delegationCredentialId = await handler.delegate(invitation);
|
|
2961
|
+
changeStream.next({
|
|
2962
|
+
...invitation,
|
|
2963
|
+
delegationCredentialId
|
|
2964
|
+
});
|
|
2965
|
+
} else if (invitation.persistent) {
|
|
2966
|
+
await this._metadataStore.addInvitation(invitation);
|
|
2967
|
+
this.saved.emit(invitation);
|
|
2968
|
+
}
|
|
2969
|
+
}
|
|
2970
|
+
async _safeDeleteInvitation(invitation) {
|
|
2971
|
+
try {
|
|
2972
|
+
await this._metadataStore.removeInvitation(invitation.invitationId);
|
|
2973
|
+
} catch (err) {
|
|
2974
|
+
import_log7.log.catch(err, void 0, {
|
|
2975
|
+
F: __dxlog_file9,
|
|
2976
|
+
L: 260,
|
|
2977
|
+
S: this,
|
|
2978
|
+
C: (f, a) => f(...a)
|
|
2979
|
+
});
|
|
2980
|
+
}
|
|
2981
|
+
}
|
|
2982
|
+
_onInvitationComplete(invitation, callback) {
|
|
2983
|
+
invitation.subscribe(() => {
|
|
2984
|
+
}, () => {
|
|
2985
|
+
}, callback);
|
|
2986
|
+
}
|
|
2987
|
+
};
|
|
2802
2988
|
function _ts_decorate3(decorators, target, key, desc) {
|
|
2803
2989
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2804
2990
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
@@ -2883,7 +3069,7 @@ var AutomergeSpaceState = class {
|
|
|
2883
3069
|
this._isProcessingRootDocs = false;
|
|
2884
3070
|
}
|
|
2885
3071
|
async processCredential(credential) {
|
|
2886
|
-
if (!(0,
|
|
3072
|
+
if (!(0, import_credentials11.checkCredentialType)(credential, "dxos.halo.credentials.Epoch")) {
|
|
2887
3073
|
return;
|
|
2888
3074
|
}
|
|
2889
3075
|
this.lastEpoch = credential;
|
|
@@ -2918,8 +3104,8 @@ var NotarizationPlugin = class {
|
|
|
2918
3104
|
this._ctx = new import_context8.Context();
|
|
2919
3105
|
this._extensionOpened = new import_async12.Event();
|
|
2920
3106
|
this._extensions = /* @__PURE__ */ new Set();
|
|
2921
|
-
this._processedCredentials = new import_util5.ComplexSet(
|
|
2922
|
-
this._processCredentialsTriggers = new import_util5.ComplexMap(
|
|
3107
|
+
this._processedCredentials = new import_util5.ComplexSet(import_keys9.PublicKey.hash);
|
|
3108
|
+
this._processCredentialsTriggers = new import_util5.ComplexMap(import_keys9.PublicKey.hash);
|
|
2923
3109
|
}
|
|
2924
3110
|
get hasWriter() {
|
|
2925
3111
|
return !!this._writer;
|
|
@@ -3183,7 +3369,7 @@ var DataSpace = class {
|
|
|
3183
3369
|
this._notarizationPlugin = new NotarizationPlugin();
|
|
3184
3370
|
this._cache = void 0;
|
|
3185
3371
|
this._automergeSpaceState = new AutomergeSpaceState((rootUrl) => this._onNewAutomergeRoot(rootUrl));
|
|
3186
|
-
this._state =
|
|
3372
|
+
this._state = import_services8.SpaceState.CLOSED;
|
|
3187
3373
|
this.error = void 0;
|
|
3188
3374
|
this.stateUpdate = new import_async10.Event();
|
|
3189
3375
|
this.metrics = {};
|
|
@@ -3198,14 +3384,14 @@ var DataSpace = class {
|
|
|
3198
3384
|
this._callbacks = params.callbacks ?? {};
|
|
3199
3385
|
this._automergeHost = params.automergeHost;
|
|
3200
3386
|
this.authVerifier = new TrustedKeySetAuthVerifier({
|
|
3201
|
-
trustedKeysProvider: () => new import_util4.ComplexSet(
|
|
3387
|
+
trustedKeysProvider: () => new import_util4.ComplexSet(import_keys8.PublicKey.hash, Array.from(this._inner.spaceState.members.values()).filter((member) => !member.removed).map((member) => member.key)),
|
|
3202
3388
|
update: this._inner.stateUpdate,
|
|
3203
|
-
authTimeout:
|
|
3389
|
+
authTimeout: import_client_protocol4.AUTH_TIMEOUT
|
|
3204
3390
|
});
|
|
3205
3391
|
this._cache = params.cache;
|
|
3206
3392
|
this._state = params.initialState;
|
|
3207
3393
|
(0, import_log8.log)("new state", {
|
|
3208
|
-
state:
|
|
3394
|
+
state: import_services8.SpaceState[this._state]
|
|
3209
3395
|
}, {
|
|
3210
3396
|
F: __dxlog_file11,
|
|
3211
3397
|
L: 140,
|
|
@@ -3253,9 +3439,9 @@ var DataSpace = class {
|
|
|
3253
3439
|
await this._inner.spaceState.addCredentialProcessor(this._notarizationPlugin);
|
|
3254
3440
|
await this._inner.spaceState.addCredentialProcessor(this._automergeSpaceState);
|
|
3255
3441
|
await this._inner.open(new import_context7.Context());
|
|
3256
|
-
this._state =
|
|
3442
|
+
this._state = import_services8.SpaceState.CONTROL_ONLY;
|
|
3257
3443
|
(0, import_log8.log)("new state", {
|
|
3258
|
-
state:
|
|
3444
|
+
state: import_services8.SpaceState[this._state]
|
|
3259
3445
|
}, {
|
|
3260
3446
|
F: __dxlog_file11,
|
|
3261
3447
|
L: 198,
|
|
@@ -3271,9 +3457,9 @@ var DataSpace = class {
|
|
|
3271
3457
|
}
|
|
3272
3458
|
async _close() {
|
|
3273
3459
|
await this._callbacks.beforeClose?.();
|
|
3274
|
-
this._state =
|
|
3460
|
+
this._state = import_services8.SpaceState.CLOSED;
|
|
3275
3461
|
(0, import_log8.log)("new state", {
|
|
3276
|
-
state:
|
|
3462
|
+
state: import_services8.SpaceState[this._state]
|
|
3277
3463
|
}, {
|
|
3278
3464
|
F: __dxlog_file11,
|
|
3279
3465
|
L: 212,
|
|
@@ -3320,9 +3506,9 @@ var DataSpace = class {
|
|
|
3320
3506
|
S: this,
|
|
3321
3507
|
C: (f, a) => f(...a)
|
|
3322
3508
|
});
|
|
3323
|
-
this._state =
|
|
3509
|
+
this._state = import_services8.SpaceState.ERROR;
|
|
3324
3510
|
(0, import_log8.log)("new state", {
|
|
3325
|
-
state:
|
|
3511
|
+
state: import_services8.SpaceState[this._state]
|
|
3326
3512
|
}, {
|
|
3327
3513
|
F: __dxlog_file11,
|
|
3328
3514
|
L: 251,
|
|
@@ -3337,12 +3523,12 @@ var DataSpace = class {
|
|
|
3337
3523
|
});
|
|
3338
3524
|
}
|
|
3339
3525
|
async initializeDataPipeline() {
|
|
3340
|
-
if (this._state !==
|
|
3526
|
+
if (this._state !== import_services8.SpaceState.CONTROL_ONLY) {
|
|
3341
3527
|
throw new import_protocols7.SystemError("Invalid operation");
|
|
3342
3528
|
}
|
|
3343
|
-
this._state =
|
|
3529
|
+
this._state = import_services8.SpaceState.INITIALIZING;
|
|
3344
3530
|
(0, import_log8.log)("new state", {
|
|
3345
|
-
state:
|
|
3531
|
+
state: import_services8.SpaceState[this._state]
|
|
3346
3532
|
}, {
|
|
3347
3533
|
F: __dxlog_file11,
|
|
3348
3534
|
L: 267,
|
|
@@ -3360,9 +3546,9 @@ var DataSpace = class {
|
|
|
3360
3546
|
C: (f, a) => f(...a)
|
|
3361
3547
|
});
|
|
3362
3548
|
await this._callbacks.beforeReady?.();
|
|
3363
|
-
this._state =
|
|
3549
|
+
this._state = import_services8.SpaceState.READY;
|
|
3364
3550
|
(0, import_log8.log)("new state", {
|
|
3365
|
-
state:
|
|
3551
|
+
state: import_services8.SpaceState[this._state]
|
|
3366
3552
|
}, {
|
|
3367
3553
|
F: __dxlog_file11,
|
|
3368
3554
|
L: 283,
|
|
@@ -3387,7 +3573,7 @@ var DataSpace = class {
|
|
|
3387
3573
|
});
|
|
3388
3574
|
this.stateUpdate.emit();
|
|
3389
3575
|
if (!this.notarizationPlugin.hasWriter) {
|
|
3390
|
-
this.notarizationPlugin.setWriter((0,
|
|
3576
|
+
this.notarizationPlugin.setWriter((0, import_echo_pipeline2.createMappedFeedWriter)((credential) => ({
|
|
3391
3577
|
credential: {
|
|
3392
3578
|
credential
|
|
3393
3579
|
}
|
|
@@ -3408,7 +3594,7 @@ var DataSpace = class {
|
|
|
3408
3594
|
spaceKey: this.key,
|
|
3409
3595
|
deviceKey: this._signingContext.deviceKey,
|
|
3410
3596
|
identityKey: this._signingContext.identityKey,
|
|
3411
|
-
designation:
|
|
3597
|
+
designation: import_credentials10.AdmittedFeed.Designation.CONTROL
|
|
3412
3598
|
}
|
|
3413
3599
|
}));
|
|
3414
3600
|
}
|
|
@@ -3425,7 +3611,7 @@ var DataSpace = class {
|
|
|
3425
3611
|
spaceKey: this.key,
|
|
3426
3612
|
deviceKey: this._signingContext.deviceKey,
|
|
3427
3613
|
identityKey: this._signingContext.identityKey,
|
|
3428
|
-
designation:
|
|
3614
|
+
designation: import_credentials10.AdmittedFeed.Designation.DATA
|
|
3429
3615
|
}
|
|
3430
3616
|
}));
|
|
3431
3617
|
}
|
|
@@ -3502,7 +3688,7 @@ var DataSpace = class {
|
|
|
3502
3688
|
let epoch;
|
|
3503
3689
|
switch (options?.migration) {
|
|
3504
3690
|
case void 0:
|
|
3505
|
-
case
|
|
3691
|
+
case import_services8.CreateEpochRequest.Migration.NONE:
|
|
3506
3692
|
{
|
|
3507
3693
|
epoch = {
|
|
3508
3694
|
previousId: this._automergeSpaceState.lastEpoch?.id,
|
|
@@ -3512,7 +3698,7 @@ var DataSpace = class {
|
|
|
3512
3698
|
};
|
|
3513
3699
|
}
|
|
3514
3700
|
break;
|
|
3515
|
-
case
|
|
3701
|
+
case import_services8.CreateEpochRequest.Migration.INIT_AUTOMERGE:
|
|
3516
3702
|
{
|
|
3517
3703
|
const document = this._automergeHost.repo.create();
|
|
3518
3704
|
epoch = {
|
|
@@ -3523,7 +3709,7 @@ var DataSpace = class {
|
|
|
3523
3709
|
};
|
|
3524
3710
|
}
|
|
3525
3711
|
break;
|
|
3526
|
-
case
|
|
3712
|
+
case import_services8.CreateEpochRequest.Migration.PRUNE_AUTOMERGE_ROOT_HISTORY:
|
|
3527
3713
|
{
|
|
3528
3714
|
const currentRootUrl = this._automergeSpaceState.rootUrl;
|
|
3529
3715
|
const rootHandle = this._automergeHost.repo.find(currentRootUrl);
|
|
@@ -3546,7 +3732,7 @@ var DataSpace = class {
|
|
|
3546
3732
|
};
|
|
3547
3733
|
}
|
|
3548
3734
|
break;
|
|
3549
|
-
case
|
|
3735
|
+
case import_services8.CreateEpochRequest.Migration.FRAGMENT_AUTOMERGE_ROOT:
|
|
3550
3736
|
{
|
|
3551
3737
|
import_log8.log.info("Fragmenting", void 0, {
|
|
3552
3738
|
F: __dxlog_file11,
|
|
@@ -3558,7 +3744,7 @@ var DataSpace = class {
|
|
|
3558
3744
|
const rootHandle = this._automergeHost.repo.find(currentRootUrl);
|
|
3559
3745
|
await (0, import_context7.cancelWithContext)(this._ctx, (0, import_async10.asyncTimeout)(rootHandle.whenReady(), 1e4));
|
|
3560
3746
|
const objects = Object.entries(rootHandle.docSync().objects);
|
|
3561
|
-
const properties = objects.find(([_, value]) => value.system.type?.itemId ===
|
|
3747
|
+
const properties = objects.find(([_, value]) => value.system.type?.itemId === import_echo_schema.TYPE_PROPERTIES);
|
|
3562
3748
|
const otherObjects = objects.filter(([key]) => key !== properties?.[0]);
|
|
3563
3749
|
(0, import_invariant9.invariant)(properties, "Properties not found", {
|
|
3564
3750
|
F: __dxlog_file11,
|
|
@@ -3585,7 +3771,7 @@ var DataSpace = class {
|
|
|
3585
3771
|
""
|
|
3586
3772
|
]
|
|
3587
3773
|
});
|
|
3588
|
-
const docLoader = new
|
|
3774
|
+
const docLoader = new import_echo_pipeline3.AutomergeDocumentLoaderImpl(this.key, this._automergeHost.repo);
|
|
3589
3775
|
await docLoader.loadSpaceRootDocHandle(this._ctx, {
|
|
3590
3776
|
rootUrl: newRoot.url
|
|
3591
3777
|
});
|
|
@@ -3629,22 +3815,22 @@ var DataSpace = class {
|
|
|
3629
3815
|
]));
|
|
3630
3816
|
}
|
|
3631
3817
|
async activate() {
|
|
3632
|
-
if (this._state !==
|
|
3818
|
+
if (this._state !== import_services8.SpaceState.INACTIVE) {
|
|
3633
3819
|
return;
|
|
3634
3820
|
}
|
|
3635
|
-
await this._metadataStore.setSpaceState(this.key,
|
|
3821
|
+
await this._metadataStore.setSpaceState(this.key, import_services8.SpaceState.ACTIVE);
|
|
3636
3822
|
await this._open();
|
|
3637
3823
|
this.initializeDataPipelineAsync();
|
|
3638
3824
|
}
|
|
3639
3825
|
async deactivate() {
|
|
3640
|
-
if (this._state ===
|
|
3826
|
+
if (this._state === import_services8.SpaceState.INACTIVE) {
|
|
3641
3827
|
return;
|
|
3642
3828
|
}
|
|
3643
|
-
await this._metadataStore.setSpaceState(this.key,
|
|
3829
|
+
await this._metadataStore.setSpaceState(this.key, import_services8.SpaceState.INACTIVE);
|
|
3644
3830
|
await this._close();
|
|
3645
|
-
this._state =
|
|
3831
|
+
this._state = import_services8.SpaceState.INACTIVE;
|
|
3646
3832
|
(0, import_log8.log)("new state", {
|
|
3647
|
-
state:
|
|
3833
|
+
state: import_services8.SpaceState[this._state]
|
|
3648
3834
|
}, {
|
|
3649
3835
|
F: __dxlog_file11,
|
|
3650
3836
|
L: 531,
|
|
@@ -3662,7 +3848,7 @@ _ts_decorate4([
|
|
|
3662
3848
|
], DataSpace.prototype, "key", null);
|
|
3663
3849
|
_ts_decorate4([
|
|
3664
3850
|
import_tracing4.trace.info({
|
|
3665
|
-
enum:
|
|
3851
|
+
enum: import_services8.SpaceState
|
|
3666
3852
|
})
|
|
3667
3853
|
], DataSpace.prototype, "state", null);
|
|
3668
3854
|
_ts_decorate4([
|
|
@@ -3701,7 +3887,7 @@ DataSpace = _ts_decorate4([
|
|
|
3701
3887
|
], DataSpace);
|
|
3702
3888
|
var spaceGenesis = async (keyring, signingContext, space, automergeRoot) => {
|
|
3703
3889
|
const credentials = [
|
|
3704
|
-
await (0,
|
|
3890
|
+
await (0, import_credentials13.createCredential)({
|
|
3705
3891
|
signer: keyring,
|
|
3706
3892
|
issuer: space.key,
|
|
3707
3893
|
subject: space.key,
|
|
@@ -3710,14 +3896,14 @@ var spaceGenesis = async (keyring, signingContext, space, automergeRoot) => {
|
|
|
3710
3896
|
spaceKey: space.key
|
|
3711
3897
|
}
|
|
3712
3898
|
}),
|
|
3713
|
-
await (0,
|
|
3899
|
+
await (0, import_credentials13.createCredential)({
|
|
3714
3900
|
signer: keyring,
|
|
3715
3901
|
issuer: space.key,
|
|
3716
3902
|
subject: signingContext.identityKey,
|
|
3717
3903
|
assertion: {
|
|
3718
3904
|
"@type": "dxos.halo.credentials.SpaceMember",
|
|
3719
3905
|
spaceKey: space.key,
|
|
3720
|
-
role:
|
|
3906
|
+
role: import_credentials14.SpaceMember.Role.ADMIN,
|
|
3721
3907
|
profile: signingContext.getProfile(),
|
|
3722
3908
|
genesisFeedKey: space.controlFeedKey ?? (0, import_debug4.failUndefined)()
|
|
3723
3909
|
}
|
|
@@ -3729,7 +3915,7 @@ var spaceGenesis = async (keyring, signingContext, space, automergeRoot) => {
|
|
|
3729
3915
|
spaceKey: space.key,
|
|
3730
3916
|
identityKey: signingContext.identityKey,
|
|
3731
3917
|
deviceKey: signingContext.deviceKey,
|
|
3732
|
-
designation:
|
|
3918
|
+
designation: import_credentials14.AdmittedFeed.Designation.CONTROL
|
|
3733
3919
|
}
|
|
3734
3920
|
}),
|
|
3735
3921
|
await signingContext.credentialSigner.createCredential({
|
|
@@ -3739,7 +3925,7 @@ var spaceGenesis = async (keyring, signingContext, space, automergeRoot) => {
|
|
|
3739
3925
|
spaceKey: space.key,
|
|
3740
3926
|
identityKey: signingContext.identityKey,
|
|
3741
3927
|
deviceKey: signingContext.deviceKey,
|
|
3742
|
-
designation:
|
|
3928
|
+
designation: import_credentials14.AdmittedFeed.Designation.DATA
|
|
3743
3929
|
}
|
|
3744
3930
|
}),
|
|
3745
3931
|
await signingContext.credentialSigner.createCredential({
|
|
@@ -3777,18 +3963,19 @@ var __dxlog_file12 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/s
|
|
|
3777
3963
|
var PRESENCE_ANNOUNCE_INTERVAL = 1e4;
|
|
3778
3964
|
var PRESENCE_OFFLINE_TIMEOUT = 2e4;
|
|
3779
3965
|
var DataSpaceManager = class {
|
|
3780
|
-
constructor(_spaceManager, _metadataStore, _keyring, _signingContext, _feedStore, _automergeHost, params) {
|
|
3966
|
+
constructor(_spaceManager, _metadataStore, _keyring, _signingContext, _feedStore, _automergeHost, _invitationsManager, params) {
|
|
3781
3967
|
this._spaceManager = _spaceManager;
|
|
3782
3968
|
this._metadataStore = _metadataStore;
|
|
3783
3969
|
this._keyring = _keyring;
|
|
3784
3970
|
this._signingContext = _signingContext;
|
|
3785
3971
|
this._feedStore = _feedStore;
|
|
3786
3972
|
this._automergeHost = _automergeHost;
|
|
3973
|
+
this._invitationsManager = _invitationsManager;
|
|
3787
3974
|
this._ctx = new import_context9.Context();
|
|
3788
3975
|
this.updated = new import_async13.Event();
|
|
3789
|
-
this._spaces = new import_util6.ComplexMap(
|
|
3976
|
+
this._spaces = new import_util6.ComplexMap(import_keys10.PublicKey.hash);
|
|
3790
3977
|
this._isOpen = false;
|
|
3791
|
-
this._instanceId =
|
|
3978
|
+
this._instanceId = import_keys10.PublicKey.random().toHex();
|
|
3792
3979
|
const { spaceMemberPresenceAnnounceInterval = PRESENCE_ANNOUNCE_INTERVAL, spaceMemberPresenceOfflineTimeout = PRESENCE_OFFLINE_TIMEOUT } = params ?? {};
|
|
3793
3980
|
this._spaceMemberPresenceAnnounceInterval = spaceMemberPresenceAnnounceInterval;
|
|
3794
3981
|
this._spaceMemberPresenceOfflineTimeout = spaceMemberPresenceOfflineTimeout;
|
|
@@ -3800,7 +3987,7 @@ var DataSpaceManager = class {
|
|
|
3800
3987
|
async open() {
|
|
3801
3988
|
(0, import_log10.log)("open", void 0, {
|
|
3802
3989
|
F: __dxlog_file12,
|
|
3803
|
-
L:
|
|
3990
|
+
L: 101,
|
|
3804
3991
|
S: this,
|
|
3805
3992
|
C: (f, a) => f(...a)
|
|
3806
3993
|
});
|
|
@@ -3808,7 +3995,7 @@ var DataSpaceManager = class {
|
|
|
3808
3995
|
id: this._instanceId
|
|
3809
3996
|
}), {
|
|
3810
3997
|
F: __dxlog_file12,
|
|
3811
|
-
L:
|
|
3998
|
+
L: 102,
|
|
3812
3999
|
S: this,
|
|
3813
4000
|
C: (f, a) => f(...a)
|
|
3814
4001
|
});
|
|
@@ -3816,7 +4003,7 @@ var DataSpaceManager = class {
|
|
|
3816
4003
|
spaces: this._metadataStore.spaces.length
|
|
3817
4004
|
}, {
|
|
3818
4005
|
F: __dxlog_file12,
|
|
3819
|
-
L:
|
|
4006
|
+
L: 103,
|
|
3820
4007
|
S: this,
|
|
3821
4008
|
C: (f, a) => f(...a)
|
|
3822
4009
|
});
|
|
@@ -3826,7 +4013,7 @@ var DataSpaceManager = class {
|
|
|
3826
4013
|
spaceMetadata
|
|
3827
4014
|
}, {
|
|
3828
4015
|
F: __dxlog_file12,
|
|
3829
|
-
L:
|
|
4016
|
+
L: 107,
|
|
3830
4017
|
S: this,
|
|
3831
4018
|
C: (f, a) => f(...a)
|
|
3832
4019
|
});
|
|
@@ -3837,7 +4024,7 @@ var DataSpaceManager = class {
|
|
|
3837
4024
|
err
|
|
3838
4025
|
}, {
|
|
3839
4026
|
F: __dxlog_file12,
|
|
3840
|
-
L:
|
|
4027
|
+
L: 110,
|
|
3841
4028
|
S: this,
|
|
3842
4029
|
C: (f, a) => f(...a)
|
|
3843
4030
|
});
|
|
@@ -3846,7 +4033,7 @@ var DataSpaceManager = class {
|
|
|
3846
4033
|
this._isOpen = true;
|
|
3847
4034
|
this.updated.emit();
|
|
3848
4035
|
for (const space of this._spaces.values()) {
|
|
3849
|
-
if (space.state !==
|
|
4036
|
+
if (space.state !== import_services9.SpaceState.INACTIVE) {
|
|
3850
4037
|
space.initializeDataPipelineAsync();
|
|
3851
4038
|
}
|
|
3852
4039
|
}
|
|
@@ -3854,7 +4041,7 @@ var DataSpaceManager = class {
|
|
|
3854
4041
|
id: this._instanceId
|
|
3855
4042
|
}), {
|
|
3856
4043
|
F: __dxlog_file12,
|
|
3857
|
-
L:
|
|
4044
|
+
L: 123,
|
|
3858
4045
|
S: this,
|
|
3859
4046
|
C: (f, a) => f(...a)
|
|
3860
4047
|
});
|
|
@@ -3862,7 +4049,7 @@ var DataSpaceManager = class {
|
|
|
3862
4049
|
async close() {
|
|
3863
4050
|
(0, import_log10.log)("close", void 0, {
|
|
3864
4051
|
F: __dxlog_file12,
|
|
3865
|
-
L:
|
|
4052
|
+
L: 128,
|
|
3866
4053
|
S: this,
|
|
3867
4054
|
C: (f, a) => f(...a)
|
|
3868
4055
|
});
|
|
@@ -3878,7 +4065,7 @@ var DataSpaceManager = class {
|
|
|
3878
4065
|
async createSpace() {
|
|
3879
4066
|
(0, import_invariant11.invariant)(this._isOpen, "Not open.", {
|
|
3880
4067
|
F: __dxlog_file12,
|
|
3881
|
-
L:
|
|
4068
|
+
L: 141,
|
|
3882
4069
|
S: this,
|
|
3883
4070
|
A: [
|
|
3884
4071
|
"this._isOpen",
|
|
@@ -3893,13 +4080,13 @@ var DataSpaceManager = class {
|
|
|
3893
4080
|
genesisFeedKey: controlFeedKey,
|
|
3894
4081
|
controlFeedKey,
|
|
3895
4082
|
dataFeedKey,
|
|
3896
|
-
state:
|
|
4083
|
+
state: import_services9.SpaceState.ACTIVE
|
|
3897
4084
|
};
|
|
3898
4085
|
(0, import_log10.log)("creating space...", {
|
|
3899
4086
|
spaceKey
|
|
3900
4087
|
}, {
|
|
3901
4088
|
F: __dxlog_file12,
|
|
3902
|
-
L:
|
|
4089
|
+
L: 153,
|
|
3903
4090
|
S: this,
|
|
3904
4091
|
C: (f, a) => f(...a)
|
|
3905
4092
|
});
|
|
@@ -3913,9 +4100,9 @@ var DataSpaceManager = class {
|
|
|
3913
4100
|
const credentials = await spaceGenesis(this._keyring, this._signingContext, space.inner, automergeRoot.url);
|
|
3914
4101
|
await this._metadataStore.addSpace(metadata);
|
|
3915
4102
|
const memberCredential = credentials[1];
|
|
3916
|
-
(0, import_invariant11.invariant)((0,
|
|
4103
|
+
(0, import_invariant11.invariant)((0, import_credentials12.getCredentialAssertion)(memberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
|
|
3917
4104
|
F: __dxlog_file12,
|
|
3918
|
-
L:
|
|
4105
|
+
L: 166,
|
|
3919
4106
|
S: this,
|
|
3920
4107
|
A: [
|
|
3921
4108
|
"getCredentialAssertion(memberCredential)['@type'] === 'dxos.halo.credentials.SpaceMember'",
|
|
@@ -3933,13 +4120,13 @@ var DataSpaceManager = class {
|
|
|
3933
4120
|
opts
|
|
3934
4121
|
}, {
|
|
3935
4122
|
F: __dxlog_file12,
|
|
3936
|
-
L:
|
|
4123
|
+
L: 178,
|
|
3937
4124
|
S: this,
|
|
3938
4125
|
C: (f, a) => f(...a)
|
|
3939
4126
|
});
|
|
3940
4127
|
(0, import_invariant11.invariant)(this._isOpen, "Not open.", {
|
|
3941
4128
|
F: __dxlog_file12,
|
|
3942
|
-
L:
|
|
4129
|
+
L: 179,
|
|
3943
4130
|
S: this,
|
|
3944
4131
|
A: [
|
|
3945
4132
|
"this._isOpen",
|
|
@@ -3948,7 +4135,7 @@ var DataSpaceManager = class {
|
|
|
3948
4135
|
});
|
|
3949
4136
|
(0, import_invariant11.invariant)(!this._spaces.has(opts.spaceKey), "Space already exists.", {
|
|
3950
4137
|
F: __dxlog_file12,
|
|
3951
|
-
L:
|
|
4138
|
+
L: 180,
|
|
3952
4139
|
S: this,
|
|
3953
4140
|
A: [
|
|
3954
4141
|
"!this._spaces.has(opts.spaceKey)",
|
|
@@ -3975,7 +4162,7 @@ var DataSpaceManager = class {
|
|
|
3975
4162
|
async waitUntilSpaceReady(spaceKey) {
|
|
3976
4163
|
await (0, import_context9.cancelWithContext)(this._ctx, this.updated.waitForCondition(() => {
|
|
3977
4164
|
const space = this._spaces.get(spaceKey);
|
|
3978
|
-
return !!space && space.state ===
|
|
4165
|
+
return !!space && space.state === import_services9.SpaceState.READY;
|
|
3979
4166
|
}));
|
|
3980
4167
|
}
|
|
3981
4168
|
async _constructSpace(metadata) {
|
|
@@ -3983,7 +4170,7 @@ var DataSpaceManager = class {
|
|
|
3983
4170
|
metadata
|
|
3984
4171
|
}, {
|
|
3985
4172
|
F: __dxlog_file12,
|
|
3986
|
-
L:
|
|
4173
|
+
L: 213,
|
|
3987
4174
|
S: this,
|
|
3988
4175
|
C: (f, a) => f(...a)
|
|
3989
4176
|
});
|
|
@@ -4021,18 +4208,21 @@ var DataSpaceManager = class {
|
|
|
4021
4208
|
onAuthFailure: () => {
|
|
4022
4209
|
import_log10.log.warn("auth failure", void 0, {
|
|
4023
4210
|
F: __dxlog_file12,
|
|
4024
|
-
L:
|
|
4211
|
+
L: 250,
|
|
4025
4212
|
S: this,
|
|
4026
4213
|
C: (f, a) => f(...a)
|
|
4027
4214
|
});
|
|
4028
4215
|
},
|
|
4029
|
-
memberKey: this._signingContext.identityKey
|
|
4216
|
+
memberKey: this._signingContext.identityKey,
|
|
4217
|
+
onDelegatedInvitationStatusChange: (invitation, isActive) => {
|
|
4218
|
+
return this._handleInvitationStatusChange(dataSpace, invitation, isActive);
|
|
4219
|
+
}
|
|
4030
4220
|
});
|
|
4031
4221
|
controlFeed && await space.setControlFeed(controlFeed);
|
|
4032
4222
|
dataFeed && await space.setDataFeed(dataFeed);
|
|
4033
4223
|
const dataSpace = new DataSpace({
|
|
4034
4224
|
inner: space,
|
|
4035
|
-
initialState: metadata.state ===
|
|
4225
|
+
initialState: metadata.state === import_services9.SpaceState.INACTIVE ? import_services9.SpaceState.INACTIVE : import_services9.SpaceState.CLOSED,
|
|
4036
4226
|
metadataStore: this._metadataStore,
|
|
4037
4227
|
gossip,
|
|
4038
4228
|
presence,
|
|
@@ -4045,7 +4235,7 @@ var DataSpaceManager = class {
|
|
|
4045
4235
|
space: space.key
|
|
4046
4236
|
}, {
|
|
4047
4237
|
F: __dxlog_file12,
|
|
4048
|
-
L:
|
|
4238
|
+
L: 271,
|
|
4049
4239
|
S: this,
|
|
4050
4240
|
C: (f, a) => f(...a)
|
|
4051
4241
|
});
|
|
@@ -4056,11 +4246,14 @@ var DataSpaceManager = class {
|
|
|
4056
4246
|
open: this._isOpen
|
|
4057
4247
|
}, {
|
|
4058
4248
|
F: __dxlog_file12,
|
|
4059
|
-
L:
|
|
4249
|
+
L: 274,
|
|
4060
4250
|
S: this,
|
|
4061
4251
|
C: (f, a) => f(...a)
|
|
4062
4252
|
});
|
|
4063
4253
|
if (this._isOpen) {
|
|
4254
|
+
await this._createDelegatedInvitations(dataSpace, [
|
|
4255
|
+
...space.spaceState.invitations.entries()
|
|
4256
|
+
]);
|
|
4064
4257
|
this.updated.emit();
|
|
4065
4258
|
}
|
|
4066
4259
|
},
|
|
@@ -4069,7 +4262,7 @@ var DataSpaceManager = class {
|
|
|
4069
4262
|
space: space.key
|
|
4070
4263
|
}, {
|
|
4071
4264
|
F: __dxlog_file12,
|
|
4072
|
-
L:
|
|
4265
|
+
L: 281,
|
|
4073
4266
|
S: this,
|
|
4074
4267
|
C: (f, a) => f(...a)
|
|
4075
4268
|
});
|
|
@@ -4078,7 +4271,7 @@ var DataSpaceManager = class {
|
|
|
4078
4271
|
cache: metadata.cache,
|
|
4079
4272
|
automergeHost: this._automergeHost
|
|
4080
4273
|
});
|
|
4081
|
-
if (metadata.state !==
|
|
4274
|
+
if (metadata.state !== import_services9.SpaceState.INACTIVE) {
|
|
4082
4275
|
await dataSpace.open();
|
|
4083
4276
|
}
|
|
4084
4277
|
if (metadata.controlTimeframe) {
|
|
@@ -4087,6 +4280,41 @@ var DataSpaceManager = class {
|
|
|
4087
4280
|
this._spaces.set(metadata.key, dataSpace);
|
|
4088
4281
|
return dataSpace;
|
|
4089
4282
|
}
|
|
4283
|
+
async _handleInvitationStatusChange(dataSpace, delegatedInvitation, isActive) {
|
|
4284
|
+
if (dataSpace?.state !== import_services9.SpaceState.READY) {
|
|
4285
|
+
return;
|
|
4286
|
+
}
|
|
4287
|
+
if (isActive) {
|
|
4288
|
+
await this._createDelegatedInvitations(dataSpace, [
|
|
4289
|
+
[
|
|
4290
|
+
delegatedInvitation.credentialId,
|
|
4291
|
+
delegatedInvitation.invitation
|
|
4292
|
+
]
|
|
4293
|
+
]);
|
|
4294
|
+
} else {
|
|
4295
|
+
await this._invitationsManager.cancelInvitation(delegatedInvitation.invitation);
|
|
4296
|
+
}
|
|
4297
|
+
}
|
|
4298
|
+
async _createDelegatedInvitations(space, invitations) {
|
|
4299
|
+
const tasks = invitations.map(([credentialId, invitation]) => {
|
|
4300
|
+
return this._invitationsManager.createInvitation({
|
|
4301
|
+
type: import_services9.Invitation.Type.DELEGATED,
|
|
4302
|
+
kind: import_services9.Invitation.Kind.SPACE,
|
|
4303
|
+
spaceKey: space.key,
|
|
4304
|
+
authMethod: invitation.authMethod,
|
|
4305
|
+
invitationId: invitation.invitationId,
|
|
4306
|
+
swarmKey: invitation.swarmKey,
|
|
4307
|
+
guestKeypair: invitation.guestKey ? {
|
|
4308
|
+
publicKey: invitation.guestKey
|
|
4309
|
+
} : void 0,
|
|
4310
|
+
lifetime: invitation.expiresOn ? invitation.expiresOn.getTime() - Date.now() : void 0,
|
|
4311
|
+
multiUse: invitation.multiUse,
|
|
4312
|
+
delegationCredentialId: credentialId,
|
|
4313
|
+
persistent: false
|
|
4314
|
+
});
|
|
4315
|
+
});
|
|
4316
|
+
await Promise.all(tasks);
|
|
4317
|
+
}
|
|
4090
4318
|
};
|
|
4091
4319
|
_ts_decorate5([
|
|
4092
4320
|
import_async13.synchronized
|
|
@@ -4123,10 +4351,10 @@ var SpacesServiceImpl = class {
|
|
|
4123
4351
|
const space = dataSpaceManager.spaces.get(spaceKey) ?? (0, import_debug5.raise)(new import_protocols10.SpaceNotFoundError(spaceKey));
|
|
4124
4352
|
if (state) {
|
|
4125
4353
|
switch (state) {
|
|
4126
|
-
case
|
|
4354
|
+
case import_services10.SpaceState.ACTIVE:
|
|
4127
4355
|
await space.activate();
|
|
4128
4356
|
break;
|
|
4129
|
-
case
|
|
4357
|
+
case import_services10.SpaceState.INACTIVE:
|
|
4130
4358
|
await space.deactivate();
|
|
4131
4359
|
break;
|
|
4132
4360
|
default:
|
|
@@ -4300,7 +4528,7 @@ var SpacesServiceImpl = class {
|
|
|
4300
4528
|
identityKey: member.key,
|
|
4301
4529
|
profile: member.profile ?? {}
|
|
4302
4530
|
},
|
|
4303
|
-
presence: member.removed ?
|
|
4531
|
+
presence: member.removed ? import_services10.SpaceMember.PresenceState.REMOVED : isMe || peers.length > 0 ? import_services10.SpaceMember.PresenceState.ONLINE : import_services10.SpaceMember.PresenceState.OFFLINE,
|
|
4304
4532
|
peerStates: peers
|
|
4305
4533
|
};
|
|
4306
4534
|
}),
|
|
@@ -4320,8 +4548,10 @@ var createSelectedDocumentsIterator = (automergeHost) => (
|
|
|
4320
4548
|
async function* loadDocuments(ids) {
|
|
4321
4549
|
for (const id of ids) {
|
|
4322
4550
|
const { documentId, objectId } = import_protocols12.idCodec.decode(id);
|
|
4323
|
-
const handle = automergeHost.repo.find(documentId);
|
|
4324
|
-
|
|
4551
|
+
const handle = automergeHost.repo.handles[documentId] ?? automergeHost.repo.find(documentId);
|
|
4552
|
+
if (!handle.isReady()) {
|
|
4553
|
+
await handle.whenReady();
|
|
4554
|
+
}
|
|
4325
4555
|
const doc = handle.docSync();
|
|
4326
4556
|
const hash = (0, import_automerge.getHeads)(doc).join("");
|
|
4327
4557
|
yield doc.objects?.[objectId] ? [
|
|
@@ -4334,57 +4564,6 @@ var createSelectedDocumentsIterator = (automergeHost) => (
|
|
|
4334
4564
|
}
|
|
4335
4565
|
}
|
|
4336
4566
|
);
|
|
4337
|
-
var createDocumentsIterator = (automergeHost) => (
|
|
4338
|
-
/**
|
|
4339
|
-
* Recursively get all object data blobs from Automerge Repo.
|
|
4340
|
-
* @param ids
|
|
4341
|
-
*/
|
|
4342
|
-
// TODO(mykola): Unload automerge handles after usage.
|
|
4343
|
-
async function* getAllDocuments() {
|
|
4344
|
-
const visited = /* @__PURE__ */ new Set();
|
|
4345
|
-
async function* getObjectsFromHandle(handle) {
|
|
4346
|
-
if (visited.has(handle.documentId)) {
|
|
4347
|
-
return;
|
|
4348
|
-
}
|
|
4349
|
-
await (0, import_debug7.warnAfterTimeout)(5e3, "to long to load doc", () => handle.whenReady());
|
|
4350
|
-
const doc = handle.docSync();
|
|
4351
|
-
const heads = (0, import_automerge.getHeads)(doc);
|
|
4352
|
-
if (doc.objects) {
|
|
4353
|
-
yield Object.entries(doc.objects).map(([objectId, object]) => {
|
|
4354
|
-
return {
|
|
4355
|
-
id: import_protocols12.idCodec.encode({
|
|
4356
|
-
documentId: handle.documentId,
|
|
4357
|
-
objectId
|
|
4358
|
-
}),
|
|
4359
|
-
object,
|
|
4360
|
-
currentHash: heads.join("")
|
|
4361
|
-
};
|
|
4362
|
-
});
|
|
4363
|
-
}
|
|
4364
|
-
if (doc.links) {
|
|
4365
|
-
for (const id of Object.values(doc.links)) {
|
|
4366
|
-
if (visited.has(id)) {
|
|
4367
|
-
continue;
|
|
4368
|
-
}
|
|
4369
|
-
const linkHandle = automergeHost.repo.find(id);
|
|
4370
|
-
for await (const result of getObjectsFromHandle(linkHandle)) {
|
|
4371
|
-
yield result;
|
|
4372
|
-
}
|
|
4373
|
-
}
|
|
4374
|
-
}
|
|
4375
|
-
visited.add(handle.documentId);
|
|
4376
|
-
}
|
|
4377
|
-
for (const handle of Object.values(automergeHost.repo.handles)) {
|
|
4378
|
-
if (visited.has(handle.documentId)) {
|
|
4379
|
-
continue;
|
|
4380
|
-
}
|
|
4381
|
-
for await (const result of getObjectsFromHandle(handle)) {
|
|
4382
|
-
yield result;
|
|
4383
|
-
}
|
|
4384
|
-
visited.add(handle.documentId);
|
|
4385
|
-
}
|
|
4386
|
-
}
|
|
4387
|
-
);
|
|
4388
4567
|
function _ts_decorate6(decorators, target, key, desc) {
|
|
4389
4568
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4390
4569
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
@@ -4406,9 +4585,9 @@ var ServiceContext = class extends import_context10.Resource {
|
|
|
4406
4585
|
this._runtimeParams = _runtimeParams;
|
|
4407
4586
|
this.initialized = new import_async15.Trigger();
|
|
4408
4587
|
this._handlerFactories = /* @__PURE__ */ new Map();
|
|
4409
|
-
this._instanceId =
|
|
4410
|
-
this.metadataStore = new
|
|
4411
|
-
this.snapshotStore = new
|
|
4588
|
+
this._instanceId = import_keys11.PublicKey.random().toHex();
|
|
4589
|
+
this.metadataStore = new import_echo_pipeline4.MetadataStore(storage.createDirectory("metadata"));
|
|
4590
|
+
this.snapshotStore = new import_echo_pipeline4.SnapshotStore(storage.createDirectory("snapshots"));
|
|
4412
4591
|
this.blobStore = new import_teleport_extension_object_sync.BlobStore(storage.createDirectory("blobs"));
|
|
4413
4592
|
this.keyring = new import_keyring.Keyring(storage.createDirectory("keyring"));
|
|
4414
4593
|
this.feedStore = new import_feed_store4.FeedStore({
|
|
@@ -4416,12 +4595,12 @@ var ServiceContext = class extends import_context10.Resource {
|
|
|
4416
4595
|
root: storage.createDirectory("feeds"),
|
|
4417
4596
|
signer: this.keyring,
|
|
4418
4597
|
hypercore: {
|
|
4419
|
-
valueEncoding:
|
|
4598
|
+
valueEncoding: import_echo_pipeline4.valueEncoding,
|
|
4420
4599
|
stats: true
|
|
4421
4600
|
}
|
|
4422
4601
|
})
|
|
4423
4602
|
});
|
|
4424
|
-
this.spaceManager = new
|
|
4603
|
+
this.spaceManager = new import_echo_pipeline4.SpaceManager({
|
|
4425
4604
|
feedStore: this.feedStore,
|
|
4426
4605
|
networkManager: this.networkManager,
|
|
4427
4606
|
blobStore: this.blobStore,
|
|
@@ -4432,26 +4611,31 @@ var ServiceContext = class extends import_context10.Resource {
|
|
|
4432
4611
|
this.indexMetadata = new import_indexing.IndexMetadataStore({
|
|
4433
4612
|
db: level.sublevel("index-metadata")
|
|
4434
4613
|
});
|
|
4435
|
-
this.automergeHost = new
|
|
4614
|
+
this.automergeHost = new import_echo_pipeline4.AutomergeHost({
|
|
4436
4615
|
directory: storage.createDirectory("automerge"),
|
|
4437
|
-
|
|
4616
|
+
db: level.sublevel("automerge"),
|
|
4617
|
+
storageCallbacks: (0, import_indexing.createStorageCallbacks)({
|
|
4618
|
+
host: () => this.automergeHost,
|
|
4619
|
+
metadata: this.indexMetadata
|
|
4620
|
+
})
|
|
4438
4621
|
});
|
|
4439
4622
|
this.indexer = new import_indexing.Indexer({
|
|
4623
|
+
db: this.level,
|
|
4440
4624
|
indexStore: new import_indexing.IndexStore({
|
|
4441
|
-
|
|
4625
|
+
db: level.sublevel("index-storage")
|
|
4442
4626
|
}),
|
|
4443
4627
|
metadataStore: this.indexMetadata,
|
|
4444
|
-
loadDocuments: createSelectedDocumentsIterator(this.automergeHost)
|
|
4445
|
-
getAllDocuments: createDocumentsIterator(this.automergeHost)
|
|
4628
|
+
loadDocuments: createSelectedDocumentsIterator(this.automergeHost)
|
|
4446
4629
|
});
|
|
4447
4630
|
this.invitations = new InvitationsHandler(this.networkManager);
|
|
4448
|
-
this.
|
|
4631
|
+
this.invitationsManager = new InvitationsManager(this.invitations, (invitation) => this.getInvitationHandler(invitation), this.metadataStore);
|
|
4632
|
+
this._handlerFactories.set(import_services11.Invitation.Kind.DEVICE, () => new DeviceInvitationProtocol(this.keyring, () => this.identityManager.identity ?? (0, import_debug6.failUndefined)(), this._acceptIdentity.bind(this)));
|
|
4449
4633
|
}
|
|
4450
4634
|
async _open(ctx) {
|
|
4451
4635
|
await this._checkStorageVersion();
|
|
4452
4636
|
(0, import_log12.log)("opening...", void 0, {
|
|
4453
4637
|
F: __dxlog_file14,
|
|
4454
|
-
L:
|
|
4638
|
+
L: 164,
|
|
4455
4639
|
S: this,
|
|
4456
4640
|
C: (f, a) => f(...a)
|
|
4457
4641
|
});
|
|
@@ -4459,29 +4643,39 @@ var ServiceContext = class extends import_context10.Resource {
|
|
|
4459
4643
|
id: this._instanceId
|
|
4460
4644
|
}), {
|
|
4461
4645
|
F: __dxlog_file14,
|
|
4462
|
-
L:
|
|
4646
|
+
L: 165,
|
|
4463
4647
|
S: this,
|
|
4464
4648
|
C: (f, a) => f(...a)
|
|
4465
4649
|
});
|
|
4466
4650
|
await this.signalManager.open();
|
|
4467
4651
|
await this.networkManager.open();
|
|
4652
|
+
await this.automergeHost.open();
|
|
4468
4653
|
await this.metadataStore.load();
|
|
4469
4654
|
await this.spaceManager.open();
|
|
4470
4655
|
await this.identityManager.open(ctx);
|
|
4471
4656
|
if (this.identityManager.identity) {
|
|
4472
4657
|
await this._initialize(ctx);
|
|
4473
4658
|
}
|
|
4659
|
+
const loadedInvitations = await this.invitationsManager.loadPersistentInvitations();
|
|
4660
|
+
(0, import_log12.log)("loaded persistent invitations", {
|
|
4661
|
+
count: loadedInvitations.invitations?.length
|
|
4662
|
+
}, {
|
|
4663
|
+
F: __dxlog_file14,
|
|
4664
|
+
L: 178,
|
|
4665
|
+
S: this,
|
|
4666
|
+
C: (f, a) => f(...a)
|
|
4667
|
+
});
|
|
4474
4668
|
import_log12.log.trace("dxos.sdk.service-context.open", import_protocols11.trace.end({
|
|
4475
4669
|
id: this._instanceId
|
|
4476
4670
|
}), {
|
|
4477
4671
|
F: __dxlog_file14,
|
|
4478
|
-
L:
|
|
4672
|
+
L: 180,
|
|
4479
4673
|
S: this,
|
|
4480
4674
|
C: (f, a) => f(...a)
|
|
4481
4675
|
});
|
|
4482
4676
|
(0, import_log12.log)("opened", void 0, {
|
|
4483
4677
|
F: __dxlog_file14,
|
|
4484
|
-
L:
|
|
4678
|
+
L: 181,
|
|
4485
4679
|
S: this,
|
|
4486
4680
|
C: (f, a) => f(...a)
|
|
4487
4681
|
});
|
|
@@ -4489,7 +4683,7 @@ var ServiceContext = class extends import_context10.Resource {
|
|
|
4489
4683
|
async _close() {
|
|
4490
4684
|
(0, import_log12.log)("closing...", void 0, {
|
|
4491
4685
|
F: __dxlog_file14,
|
|
4492
|
-
L:
|
|
4686
|
+
L: 185,
|
|
4493
4687
|
S: this,
|
|
4494
4688
|
C: (f, a) => f(...a)
|
|
4495
4689
|
});
|
|
@@ -4507,7 +4701,7 @@ var ServiceContext = class extends import_context10.Resource {
|
|
|
4507
4701
|
await this.indexer.destroy();
|
|
4508
4702
|
(0, import_log12.log)("closed", void 0, {
|
|
4509
4703
|
F: __dxlog_file14,
|
|
4510
|
-
L:
|
|
4704
|
+
L: 198,
|
|
4511
4705
|
S: this,
|
|
4512
4706
|
C: (f, a) => f(...a)
|
|
4513
4707
|
});
|
|
@@ -4521,7 +4715,7 @@ var ServiceContext = class extends import_context10.Resource {
|
|
|
4521
4715
|
const factory = this._handlerFactories.get(invitation.kind);
|
|
4522
4716
|
(0, import_invariant13.invariant)(factory, `Unknown invitation kind: ${invitation.kind}`, {
|
|
4523
4717
|
F: __dxlog_file14,
|
|
4524
|
-
L:
|
|
4718
|
+
L: 209,
|
|
4525
4719
|
S: this,
|
|
4526
4720
|
A: [
|
|
4527
4721
|
"factory",
|
|
@@ -4553,7 +4747,7 @@ var ServiceContext = class extends import_context10.Resource {
|
|
|
4553
4747
|
async _initialize(ctx) {
|
|
4554
4748
|
(0, import_log12.log)("initializing spaces...", void 0, {
|
|
4555
4749
|
F: __dxlog_file14,
|
|
4556
|
-
L:
|
|
4750
|
+
L: 240,
|
|
4557
4751
|
S: this,
|
|
4558
4752
|
C: (f, a) => f(...a)
|
|
4559
4753
|
});
|
|
@@ -4571,12 +4765,12 @@ var ServiceContext = class extends import_context10.Resource {
|
|
|
4571
4765
|
});
|
|
4572
4766
|
}
|
|
4573
4767
|
};
|
|
4574
|
-
this.dataSpaceManager = new DataSpaceManager(this.spaceManager, this.metadataStore, this.keyring, signingContext, this.feedStore, this.automergeHost, this._runtimeParams);
|
|
4768
|
+
this.dataSpaceManager = new DataSpaceManager(this.spaceManager, this.metadataStore, this.keyring, signingContext, this.feedStore, this.automergeHost, this.invitationsManager, this._runtimeParams);
|
|
4575
4769
|
await this.dataSpaceManager.open();
|
|
4576
|
-
this._handlerFactories.set(
|
|
4770
|
+
this._handlerFactories.set(import_services11.Invitation.Kind.SPACE, (invitation) => {
|
|
4577
4771
|
(0, import_invariant13.invariant)(this.dataSpaceManager, "dataSpaceManager not initialized yet", {
|
|
4578
4772
|
F: __dxlog_file14,
|
|
4579
|
-
L:
|
|
4773
|
+
L: 265,
|
|
4580
4774
|
S: this,
|
|
4581
4775
|
A: [
|
|
4582
4776
|
"this.dataSpaceManager",
|
|
@@ -4588,7 +4782,7 @@ var ServiceContext = class extends import_context10.Resource {
|
|
|
4588
4782
|
this.initialized.wake();
|
|
4589
4783
|
this._deviceSpaceSync = {
|
|
4590
4784
|
processCredential: async (credential) => {
|
|
4591
|
-
const assertion = (0,
|
|
4785
|
+
const assertion = (0, import_credentials15.getCredentialAssertion)(credential);
|
|
4592
4786
|
if (assertion["@type"] !== "dxos.halo.credentials.SpaceMember") {
|
|
4593
4787
|
return;
|
|
4594
4788
|
}
|
|
@@ -4600,7 +4794,7 @@ var ServiceContext = class extends import_context10.Resource {
|
|
|
4600
4794
|
details: assertion
|
|
4601
4795
|
}, {
|
|
4602
4796
|
F: __dxlog_file14,
|
|
4603
|
-
L:
|
|
4797
|
+
L: 281,
|
|
4604
4798
|
S: this,
|
|
4605
4799
|
C: (f, a) => f(...a)
|
|
4606
4800
|
});
|
|
@@ -4611,7 +4805,7 @@ var ServiceContext = class extends import_context10.Resource {
|
|
|
4611
4805
|
details: assertion
|
|
4612
4806
|
}, {
|
|
4613
4807
|
F: __dxlog_file14,
|
|
4614
|
-
L:
|
|
4808
|
+
L: 285,
|
|
4615
4809
|
S: this,
|
|
4616
4810
|
C: (f, a) => f(...a)
|
|
4617
4811
|
});
|
|
@@ -4622,7 +4816,7 @@ var ServiceContext = class extends import_context10.Resource {
|
|
|
4622
4816
|
details: assertion
|
|
4623
4817
|
}, {
|
|
4624
4818
|
F: __dxlog_file14,
|
|
4625
|
-
L:
|
|
4819
|
+
L: 290,
|
|
4626
4820
|
S: this,
|
|
4627
4821
|
C: (f, a) => f(...a)
|
|
4628
4822
|
});
|
|
@@ -4633,7 +4827,7 @@ var ServiceContext = class extends import_context10.Resource {
|
|
|
4633
4827
|
} catch (err) {
|
|
4634
4828
|
import_log12.log.catch(err, void 0, {
|
|
4635
4829
|
F: __dxlog_file14,
|
|
4636
|
-
L:
|
|
4830
|
+
L: 296,
|
|
4637
4831
|
S: this,
|
|
4638
4832
|
C: (f, a) => f(...a)
|
|
4639
4833
|
});
|
|
@@ -4675,26 +4869,26 @@ var ServiceRegistry = class {
|
|
|
4675
4869
|
delete this._handlers[name];
|
|
4676
4870
|
}
|
|
4677
4871
|
};
|
|
4678
|
-
var DXOS_VERSION = "0.4.10-main.
|
|
4872
|
+
var DXOS_VERSION = "0.4.10-main.bb9f1bf";
|
|
4679
4873
|
var getPlatform = () => {
|
|
4680
4874
|
if (process.browser) {
|
|
4681
4875
|
if (typeof window !== "undefined") {
|
|
4682
4876
|
const { userAgent } = window.navigator;
|
|
4683
4877
|
return {
|
|
4684
|
-
type:
|
|
4878
|
+
type: import_services13.Platform.PLATFORM_TYPE.BROWSER,
|
|
4685
4879
|
userAgent,
|
|
4686
4880
|
uptime: Math.floor((Date.now() - window.performance.timeOrigin) / 1e3)
|
|
4687
4881
|
};
|
|
4688
4882
|
} else {
|
|
4689
4883
|
return {
|
|
4690
|
-
type:
|
|
4884
|
+
type: import_services13.Platform.PLATFORM_TYPE.SHARED_WORKER,
|
|
4691
4885
|
uptime: Math.floor((Date.now() - performance.timeOrigin) / 1e3)
|
|
4692
4886
|
};
|
|
4693
4887
|
}
|
|
4694
4888
|
} else {
|
|
4695
4889
|
const { platform: platform2, version, arch } = process;
|
|
4696
4890
|
return {
|
|
4697
|
-
type:
|
|
4891
|
+
type: import_services13.Platform.PLATFORM_TYPE.NODE,
|
|
4698
4892
|
platform: platform2,
|
|
4699
4893
|
arch,
|
|
4700
4894
|
runtime: version,
|
|
@@ -4781,7 +4975,7 @@ var getSpaceStats = async (space) => {
|
|
|
4781
4975
|
const stats = {
|
|
4782
4976
|
key: space.key,
|
|
4783
4977
|
metrics: space.metrics,
|
|
4784
|
-
epochs: space.inner.spaceState.credentials.filter((0,
|
|
4978
|
+
epochs: space.inner.spaceState.credentials.filter((0, import_credentials16.credentialTypeFilter)("dxos.halo.credentials.Epoch")).map((credential) => ({
|
|
4785
4979
|
...credential.subject.assertion,
|
|
4786
4980
|
id: credential.id
|
|
4787
4981
|
})),
|
|
@@ -4792,7 +4986,7 @@ var getSpaceStats = async (space) => {
|
|
|
4792
4986
|
displayName: member.assertion.profile?.displayName
|
|
4793
4987
|
}
|
|
4794
4988
|
},
|
|
4795
|
-
presence: space.presence.getPeersOnline().filter(({ identityKey }) => identityKey.equals(member.key)).length > 0 ?
|
|
4989
|
+
presence: space.presence.getPeersOnline().filter(({ identityKey }) => identityKey.equals(member.key)).length > 0 ? import_services12.SpaceMember.PresenceState.ONLINE : import_services12.SpaceMember.PresenceState.OFFLINE
|
|
4796
4990
|
})),
|
|
4797
4991
|
pipeline: {
|
|
4798
4992
|
// TODO(burdon): Pick properties from credentials if needed.
|
|
@@ -4856,9 +5050,9 @@ var DevicesServiceImpl = class {
|
|
|
4856
5050
|
const peerState = peers.find((peer) => peer.identityKey.equals(key));
|
|
4857
5051
|
return {
|
|
4858
5052
|
deviceKey: key,
|
|
4859
|
-
kind: this._identityManager.identity?.deviceKey.equals(key) ?
|
|
5053
|
+
kind: this._identityManager.identity?.deviceKey.equals(key) ? import_services16.DeviceKind.CURRENT : import_services16.DeviceKind.TRUSTED,
|
|
4860
5054
|
profile,
|
|
4861
|
-
presence: isMe ?
|
|
5055
|
+
presence: isMe ? import_services16.Device.PresenceState.ONLINE : peerState ? import_services16.Device.PresenceState.ONLINE : import_services16.Device.PresenceState.OFFLINE
|
|
4862
5056
|
};
|
|
4863
5057
|
})
|
|
4864
5058
|
});
|
|
@@ -4957,7 +5151,7 @@ var LoggingServiceImpl = class {
|
|
|
4957
5151
|
constructor() {
|
|
4958
5152
|
this._logs = new import_async18.Event();
|
|
4959
5153
|
this._started = Date.now();
|
|
4960
|
-
this._sessionId =
|
|
5154
|
+
this._sessionId = import_keys13.PublicKey.random().toHex();
|
|
4961
5155
|
this._logProcessor = (_config, entry2) => {
|
|
4962
5156
|
this._logs.emit(entry2);
|
|
4963
5157
|
};
|
|
@@ -5054,16 +5248,16 @@ var LoggingServiceImpl = class {
|
|
|
5054
5248
|
};
|
|
5055
5249
|
var matchFilter = (filter, level, path2, options) => {
|
|
5056
5250
|
switch (options) {
|
|
5057
|
-
case
|
|
5251
|
+
case import_services17.QueryLogsRequest.MatchingOptions.INCLUSIVE:
|
|
5058
5252
|
return level >= filter.level && (!filter.pattern || path2.includes(filter.pattern));
|
|
5059
|
-
case
|
|
5253
|
+
case import_services17.QueryLogsRequest.MatchingOptions.EXPLICIT:
|
|
5060
5254
|
return level === filter.level && (!filter.pattern || path2.includes(filter.pattern));
|
|
5061
5255
|
}
|
|
5062
5256
|
};
|
|
5063
5257
|
var shouldLog = (entry2, request) => {
|
|
5064
|
-
const options = request.options ??
|
|
5258
|
+
const options = request.options ?? import_services17.QueryLogsRequest.MatchingOptions.INCLUSIVE;
|
|
5065
5259
|
if (request.filters === void 0) {
|
|
5066
|
-
return options ===
|
|
5260
|
+
return options === import_services17.QueryLogsRequest.MatchingOptions.INCLUSIVE;
|
|
5067
5261
|
} else {
|
|
5068
5262
|
return request.filters.some((filter) => matchFilter(filter, entry2.level, entry2.meta?.F ?? "", options));
|
|
5069
5263
|
}
|
|
@@ -5100,7 +5294,7 @@ var NetworkServiceImpl = class {
|
|
|
5100
5294
|
}
|
|
5101
5295
|
};
|
|
5102
5296
|
var getRootPath = (config) => {
|
|
5103
|
-
const { dataRoot = (0, import_util11.isNode)() ?
|
|
5297
|
+
const { dataRoot = (0, import_util11.isNode)() ? import_client_protocol6.DX_DATA : "dxos/storage" } = config ?? {};
|
|
5104
5298
|
return `${dataRoot}/`;
|
|
5105
5299
|
};
|
|
5106
5300
|
var isPersistent = (config) => {
|
|
@@ -5151,7 +5345,7 @@ var toStorageType = (type) => {
|
|
|
5151
5345
|
};
|
|
5152
5346
|
var createLevel = async (config) => {
|
|
5153
5347
|
const persistent = isPersistent(config);
|
|
5154
|
-
const storagePath = persistent ?
|
|
5348
|
+
const storagePath = persistent ? import_node_path.default.join(getRootPath(config), "level") : `/tmp/dxos-${import_keys14.PublicKey.random().toHex()}`;
|
|
5155
5349
|
const level = new import_level.Level(storagePath);
|
|
5156
5350
|
await level.open();
|
|
5157
5351
|
return level;
|
|
@@ -5176,8 +5370,8 @@ var SystemServiceImpl = class {
|
|
|
5176
5370
|
return {
|
|
5177
5371
|
timestamp: /* @__PURE__ */ new Date(),
|
|
5178
5372
|
diagnostics: JSON.parse(JSON.stringify(diagnostics, (0, import_util12.jsonKeyReplacer)({
|
|
5179
|
-
truncate: keys ===
|
|
5180
|
-
humanize: keys ===
|
|
5373
|
+
truncate: keys === import_services18.GetDiagnosticsRequest.KEY_OPTION.TRUNCATE,
|
|
5374
|
+
humanize: keys === import_services18.GetDiagnosticsRequest.KEY_OPTION.HUMANIZE
|
|
5181
5375
|
})))
|
|
5182
5376
|
};
|
|
5183
5377
|
}
|
|
@@ -5225,6 +5419,7 @@ var ClientServicesHost = class {
|
|
|
5225
5419
|
transportFactory,
|
|
5226
5420
|
signalManager,
|
|
5227
5421
|
storage,
|
|
5422
|
+
level,
|
|
5228
5423
|
// TODO(wittjosiah): Turn this on by default.
|
|
5229
5424
|
lockKey,
|
|
5230
5425
|
callbacks,
|
|
@@ -5235,6 +5430,7 @@ var ClientServicesHost = class {
|
|
|
5235
5430
|
this._opening = false;
|
|
5236
5431
|
this._open = false;
|
|
5237
5432
|
this._storage = storage;
|
|
5433
|
+
this._level = level;
|
|
5238
5434
|
this._callbacks = callbacks;
|
|
5239
5435
|
this._runtimeParams = runtimeParams;
|
|
5240
5436
|
if (config) {
|
|
@@ -5258,14 +5454,14 @@ var ClientServicesHost = class {
|
|
|
5258
5454
|
this._systemService = new SystemServiceImpl({
|
|
5259
5455
|
config: () => this._config,
|
|
5260
5456
|
statusUpdate: this._statusUpdate,
|
|
5261
|
-
getCurrentStatus: () => this.isOpen ?
|
|
5457
|
+
getCurrentStatus: () => this.isOpen ? import_services15.SystemStatus.ACTIVE : import_services15.SystemStatus.INACTIVE,
|
|
5262
5458
|
getDiagnostics: () => {
|
|
5263
5459
|
return createDiagnostics(this._serviceRegistry.services, this._serviceContext, this._config);
|
|
5264
5460
|
},
|
|
5265
5461
|
onUpdateStatus: async (status) => {
|
|
5266
|
-
if (!this.isOpen && status ===
|
|
5462
|
+
if (!this.isOpen && status === import_services15.SystemStatus.ACTIVE) {
|
|
5267
5463
|
await this._resourceLock?.acquire();
|
|
5268
|
-
} else if (this.isOpen && status ===
|
|
5464
|
+
} else if (this.isOpen && status === import_services15.SystemStatus.INACTIVE) {
|
|
5269
5465
|
await this._resourceLock?.release();
|
|
5270
5466
|
}
|
|
5271
5467
|
},
|
|
@@ -5275,7 +5471,7 @@ var ClientServicesHost = class {
|
|
|
5275
5471
|
});
|
|
5276
5472
|
this.diagnosticsBroadcastHandler = createCollectDiagnosticsBroadcastHandler(this._systemService);
|
|
5277
5473
|
this._loggingService = new LoggingServiceImpl();
|
|
5278
|
-
this._serviceRegistry = new ServiceRegistry(
|
|
5474
|
+
this._serviceRegistry = new ServiceRegistry(import_client_protocol5.clientServiceBundle, {
|
|
5279
5475
|
SystemService: this._systemService,
|
|
5280
5476
|
TracingService: this._tracingService
|
|
5281
5477
|
});
|
|
@@ -5306,7 +5502,7 @@ var ClientServicesHost = class {
|
|
|
5306
5502
|
initialize({ config, ...options }) {
|
|
5307
5503
|
(0, import_invariant15.invariant)(!this._open, "service host is open", {
|
|
5308
5504
|
F: __dxlog_file18,
|
|
5309
|
-
L:
|
|
5505
|
+
L: 198,
|
|
5310
5506
|
S: this,
|
|
5311
5507
|
A: [
|
|
5312
5508
|
"!this._open",
|
|
@@ -5315,14 +5511,14 @@ var ClientServicesHost = class {
|
|
|
5315
5511
|
});
|
|
5316
5512
|
(0, import_log13.log)("initializing...", void 0, {
|
|
5317
5513
|
F: __dxlog_file18,
|
|
5318
|
-
L:
|
|
5514
|
+
L: 199,
|
|
5319
5515
|
S: this,
|
|
5320
5516
|
C: (f, a) => f(...a)
|
|
5321
5517
|
});
|
|
5322
5518
|
if (config) {
|
|
5323
5519
|
(0, import_invariant15.invariant)(!this._config, "config already set", {
|
|
5324
5520
|
F: __dxlog_file18,
|
|
5325
|
-
L:
|
|
5521
|
+
L: 202,
|
|
5326
5522
|
S: this,
|
|
5327
5523
|
A: [
|
|
5328
5524
|
"!this._config",
|
|
@@ -5337,7 +5533,7 @@ var ClientServicesHost = class {
|
|
|
5337
5533
|
if (!options.signalManager) {
|
|
5338
5534
|
import_log13.log.warn("running signaling without telemetry metadata.", void 0, {
|
|
5339
5535
|
F: __dxlog_file18,
|
|
5340
|
-
L:
|
|
5536
|
+
L: 210,
|
|
5341
5537
|
S: this,
|
|
5342
5538
|
C: (f, a) => f(...a)
|
|
5343
5539
|
});
|
|
@@ -5348,7 +5544,7 @@ var ClientServicesHost = class {
|
|
|
5348
5544
|
this._signalManager = signalManager;
|
|
5349
5545
|
(0, import_invariant15.invariant)(!this._networkManager, "network manager already set", {
|
|
5350
5546
|
F: __dxlog_file18,
|
|
5351
|
-
L:
|
|
5547
|
+
L: 221,
|
|
5352
5548
|
S: this,
|
|
5353
5549
|
A: [
|
|
5354
5550
|
"!this._networkManager",
|
|
@@ -5362,7 +5558,7 @@ var ClientServicesHost = class {
|
|
|
5362
5558
|
});
|
|
5363
5559
|
(0, import_log13.log)("initialized", void 0, {
|
|
5364
5560
|
F: __dxlog_file18,
|
|
5365
|
-
L:
|
|
5561
|
+
L: 228,
|
|
5366
5562
|
S: this,
|
|
5367
5563
|
C: (f, a) => f(...a)
|
|
5368
5564
|
});
|
|
@@ -5371,18 +5567,18 @@ var ClientServicesHost = class {
|
|
|
5371
5567
|
if (this._open) {
|
|
5372
5568
|
return;
|
|
5373
5569
|
}
|
|
5374
|
-
const traceId =
|
|
5570
|
+
const traceId = import_keys12.PublicKey.random().toHex();
|
|
5375
5571
|
import_log13.log.trace("dxos.client-services.host.open", import_protocols14.trace.begin({
|
|
5376
5572
|
id: traceId
|
|
5377
5573
|
}), {
|
|
5378
5574
|
F: __dxlog_file18,
|
|
5379
|
-
L:
|
|
5575
|
+
L: 239,
|
|
5380
5576
|
S: this,
|
|
5381
5577
|
C: (f, a) => f(...a)
|
|
5382
5578
|
});
|
|
5383
5579
|
(0, import_invariant15.invariant)(this._config, "config not set", {
|
|
5384
5580
|
F: __dxlog_file18,
|
|
5385
|
-
L:
|
|
5581
|
+
L: 241,
|
|
5386
5582
|
S: this,
|
|
5387
5583
|
A: [
|
|
5388
5584
|
"this._config",
|
|
@@ -5391,7 +5587,7 @@ var ClientServicesHost = class {
|
|
|
5391
5587
|
});
|
|
5392
5588
|
(0, import_invariant15.invariant)(this._storage, "storage not set", {
|
|
5393
5589
|
F: __dxlog_file18,
|
|
5394
|
-
L:
|
|
5590
|
+
L: 242,
|
|
5395
5591
|
S: this,
|
|
5396
5592
|
A: [
|
|
5397
5593
|
"this._storage",
|
|
@@ -5400,7 +5596,7 @@ var ClientServicesHost = class {
|
|
|
5400
5596
|
});
|
|
5401
5597
|
(0, import_invariant15.invariant)(this._signalManager, "signal manager not set", {
|
|
5402
5598
|
F: __dxlog_file18,
|
|
5403
|
-
L:
|
|
5599
|
+
L: 243,
|
|
5404
5600
|
S: this,
|
|
5405
5601
|
A: [
|
|
5406
5602
|
"this._signalManager",
|
|
@@ -5409,7 +5605,7 @@ var ClientServicesHost = class {
|
|
|
5409
5605
|
});
|
|
5410
5606
|
(0, import_invariant15.invariant)(this._networkManager, "network manager not set", {
|
|
5411
5607
|
F: __dxlog_file18,
|
|
5412
|
-
L:
|
|
5608
|
+
L: 244,
|
|
5413
5609
|
S: this,
|
|
5414
5610
|
A: [
|
|
5415
5611
|
"this._networkManager",
|
|
@@ -5421,30 +5617,33 @@ var ClientServicesHost = class {
|
|
|
5421
5617
|
lockKey: this._resourceLock?.lockKey
|
|
5422
5618
|
}, {
|
|
5423
5619
|
F: __dxlog_file18,
|
|
5424
|
-
L:
|
|
5620
|
+
L: 247,
|
|
5425
5621
|
S: this,
|
|
5426
5622
|
C: (f, a) => f(...a)
|
|
5427
5623
|
});
|
|
5428
5624
|
if (!this._level) {
|
|
5429
5625
|
this._level = await createLevel(this._config.get("runtime.client.storage", {}));
|
|
5430
5626
|
}
|
|
5627
|
+
await this._level.open();
|
|
5431
5628
|
await this._resourceLock?.acquire();
|
|
5432
5629
|
await this._loggingService.open();
|
|
5433
5630
|
this._serviceContext = new ServiceContext(this._storage, this._level, this._networkManager, this._signalManager, this._runtimeParams);
|
|
5631
|
+
this._queryService = new import_indexing2.QueryServiceImpl({
|
|
5632
|
+
indexer: this._serviceContext.indexer,
|
|
5633
|
+
automergeHost: this._serviceContext.automergeHost
|
|
5634
|
+
});
|
|
5635
|
+
await this._queryService.open(ctx);
|
|
5434
5636
|
this._serviceRegistry.setServices({
|
|
5435
5637
|
SystemService: this._systemService,
|
|
5436
5638
|
IdentityService: new IdentityServiceImpl((params) => this._createIdentity(params), this._serviceContext.identityManager, this._serviceContext.keyring, (profile) => this._serviceContext.broadcastProfileUpdate(profile)),
|
|
5437
|
-
InvitationsService: new InvitationsServiceImpl(this._serviceContext.
|
|
5639
|
+
InvitationsService: new InvitationsServiceImpl(this._serviceContext.invitationsManager),
|
|
5438
5640
|
DevicesService: new DevicesServiceImpl(this._serviceContext.identityManager),
|
|
5439
5641
|
SpacesService: new SpacesServiceImpl(this._serviceContext.identityManager, this._serviceContext.spaceManager, async () => {
|
|
5440
5642
|
await this._serviceContext.initialized.wait();
|
|
5441
5643
|
return this._serviceContext.dataSpaceManager;
|
|
5442
5644
|
}),
|
|
5443
|
-
DataService: new
|
|
5444
|
-
|
|
5445
|
-
indexer: this._serviceContext.indexer,
|
|
5446
|
-
automergeHost: this._serviceContext.automergeHost
|
|
5447
|
-
}),
|
|
5645
|
+
DataService: new import_echo_pipeline5.DataServiceImpl(this._serviceContext.automergeHost),
|
|
5646
|
+
QueryService: this._queryService,
|
|
5448
5647
|
NetworkService: new NetworkServiceImpl(this._serviceContext.networkManager, this._serviceContext.signalManager),
|
|
5449
5648
|
LoggingService: this._loggingService,
|
|
5450
5649
|
TracingService: this._tracingService,
|
|
@@ -5456,30 +5655,12 @@ var ClientServicesHost = class {
|
|
|
5456
5655
|
})
|
|
5457
5656
|
});
|
|
5458
5657
|
await this._serviceContext.open(ctx);
|
|
5459
|
-
(0, import_invariant15.invariant)(this.serviceRegistry.services.InvitationsService, void 0, {
|
|
5460
|
-
F: __dxlog_file18,
|
|
5461
|
-
L: 303,
|
|
5462
|
-
S: this,
|
|
5463
|
-
A: [
|
|
5464
|
-
"this.serviceRegistry.services.InvitationsService",
|
|
5465
|
-
""
|
|
5466
|
-
]
|
|
5467
|
-
});
|
|
5468
|
-
const loadedInvitations = await this.serviceRegistry.services.InvitationsService.loadPersistentInvitations();
|
|
5469
|
-
(0, import_log13.log)("loaded persistent invitations", {
|
|
5470
|
-
count: loadedInvitations.invitations?.length
|
|
5471
|
-
}, {
|
|
5472
|
-
F: __dxlog_file18,
|
|
5473
|
-
L: 306,
|
|
5474
|
-
S: this,
|
|
5475
|
-
C: (f, a) => f(...a)
|
|
5476
|
-
});
|
|
5477
5658
|
const devtoolsProxy = this._config?.get("runtime.client.devtoolsProxy");
|
|
5478
5659
|
if (devtoolsProxy) {
|
|
5479
5660
|
this._devtoolsProxy = new import_websocket_rpc.WebsocketRpcClient({
|
|
5480
5661
|
url: devtoolsProxy,
|
|
5481
5662
|
requested: {},
|
|
5482
|
-
exposed:
|
|
5663
|
+
exposed: import_client_protocol5.clientServiceBundle,
|
|
5483
5664
|
handlers: this.services
|
|
5484
5665
|
});
|
|
5485
5666
|
void this._devtoolsProxy.open();
|
|
@@ -5493,7 +5674,7 @@ var ClientServicesHost = class {
|
|
|
5493
5674
|
deviceKey
|
|
5494
5675
|
}, {
|
|
5495
5676
|
F: __dxlog_file18,
|
|
5496
|
-
L:
|
|
5677
|
+
L: 330,
|
|
5497
5678
|
S: this,
|
|
5498
5679
|
C: (f, a) => f(...a)
|
|
5499
5680
|
});
|
|
@@ -5501,7 +5682,7 @@ var ClientServicesHost = class {
|
|
|
5501
5682
|
id: traceId
|
|
5502
5683
|
}), {
|
|
5503
5684
|
F: __dxlog_file18,
|
|
5504
|
-
L:
|
|
5685
|
+
L: 331,
|
|
5505
5686
|
S: this,
|
|
5506
5687
|
C: (f, a) => f(...a)
|
|
5507
5688
|
});
|
|
@@ -5515,7 +5696,7 @@ var ClientServicesHost = class {
|
|
|
5515
5696
|
deviceKey
|
|
5516
5697
|
}, {
|
|
5517
5698
|
F: __dxlog_file18,
|
|
5518
|
-
L:
|
|
5699
|
+
L: 342,
|
|
5519
5700
|
S: this,
|
|
5520
5701
|
C: (f, a) => f(...a)
|
|
5521
5702
|
});
|
|
@@ -5525,6 +5706,7 @@ var ClientServicesHost = class {
|
|
|
5525
5706
|
SystemService: this._systemService
|
|
5526
5707
|
});
|
|
5527
5708
|
await this._loggingService.close();
|
|
5709
|
+
await this._queryService.close();
|
|
5528
5710
|
await this._serviceContext.close();
|
|
5529
5711
|
await this._level?.close();
|
|
5530
5712
|
this._open = false;
|
|
@@ -5533,24 +5715,24 @@ var ClientServicesHost = class {
|
|
|
5533
5715
|
deviceKey
|
|
5534
5716
|
}, {
|
|
5535
5717
|
F: __dxlog_file18,
|
|
5536
|
-
L:
|
|
5718
|
+
L: 352,
|
|
5537
5719
|
S: this,
|
|
5538
5720
|
C: (f, a) => f(...a)
|
|
5539
5721
|
});
|
|
5540
5722
|
}
|
|
5541
5723
|
async reset() {
|
|
5542
|
-
const traceId =
|
|
5724
|
+
const traceId = import_keys12.PublicKey.random().toHex();
|
|
5543
5725
|
import_log13.log.trace("dxos.sdk.client-services-host.reset", import_protocols14.trace.begin({
|
|
5544
5726
|
id: traceId
|
|
5545
5727
|
}), {
|
|
5546
5728
|
F: __dxlog_file18,
|
|
5547
|
-
L:
|
|
5729
|
+
L: 357,
|
|
5548
5730
|
S: this,
|
|
5549
5731
|
C: (f, a) => f(...a)
|
|
5550
5732
|
});
|
|
5551
5733
|
(0, import_log13.log)("resetting...", void 0, {
|
|
5552
5734
|
F: __dxlog_file18,
|
|
5553
|
-
L:
|
|
5735
|
+
L: 359,
|
|
5554
5736
|
S: this,
|
|
5555
5737
|
C: (f, a) => f(...a)
|
|
5556
5738
|
});
|
|
@@ -5558,7 +5740,7 @@ var ClientServicesHost = class {
|
|
|
5558
5740
|
await this._storage.reset();
|
|
5559
5741
|
(0, import_log13.log)("reset", void 0, {
|
|
5560
5742
|
F: __dxlog_file18,
|
|
5561
|
-
L:
|
|
5743
|
+
L: 362,
|
|
5562
5744
|
S: this,
|
|
5563
5745
|
C: (f, a) => f(...a)
|
|
5564
5746
|
});
|
|
@@ -5566,7 +5748,7 @@ var ClientServicesHost = class {
|
|
|
5566
5748
|
id: traceId
|
|
5567
5749
|
}), {
|
|
5568
5750
|
F: __dxlog_file18,
|
|
5569
|
-
L:
|
|
5751
|
+
L: 363,
|
|
5570
5752
|
S: this,
|
|
5571
5753
|
C: (f, a) => f(...a)
|
|
5572
5754
|
});
|
|
@@ -5579,7 +5761,7 @@ var ClientServicesHost = class {
|
|
|
5579
5761
|
const automergeIndex = space.automergeSpaceState.rootUrl;
|
|
5580
5762
|
(0, import_invariant15.invariant)(automergeIndex, void 0, {
|
|
5581
5763
|
F: __dxlog_file18,
|
|
5582
|
-
L:
|
|
5764
|
+
L: 375,
|
|
5583
5765
|
S: this,
|
|
5584
5766
|
A: [
|
|
5585
5767
|
"automergeIndex",
|
|
@@ -5590,16 +5772,16 @@ var ClientServicesHost = class {
|
|
|
5590
5772
|
await document.whenReady();
|
|
5591
5773
|
const properties = {
|
|
5592
5774
|
system: {
|
|
5593
|
-
type: (0,
|
|
5775
|
+
type: (0, import_echo_pipeline5.encodeReference)((0, import_echo_schema2.getTypeReference)(import_client_protocol5.Properties))
|
|
5594
5776
|
},
|
|
5595
5777
|
data: {
|
|
5596
|
-
[
|
|
5778
|
+
[import_client_protocol5.defaultKey]: identity.identityKey.toHex()
|
|
5597
5779
|
},
|
|
5598
5780
|
meta: {
|
|
5599
5781
|
keys: []
|
|
5600
5782
|
}
|
|
5601
5783
|
};
|
|
5602
|
-
const propertiesId =
|
|
5784
|
+
const propertiesId = import_keys12.PublicKey.random().toHex();
|
|
5603
5785
|
document.change((doc) => {
|
|
5604
5786
|
(0, import_util9.assignDeep)(doc, [
|
|
5605
5787
|
"objects",
|
|
@@ -5634,7 +5816,7 @@ var DiagnosticsCollector = class {
|
|
|
5634
5816
|
}
|
|
5635
5817
|
static async collect(config = findConfigs(), services = findSystemServiceProvider(), options = {}) {
|
|
5636
5818
|
const serviceDiagnostics = await services?.services?.SystemService?.getDiagnostics({
|
|
5637
|
-
keys: options.humanize ?
|
|
5819
|
+
keys: options.humanize ? import_services14.GetDiagnosticsRequest.KEY_OPTION.HUMANIZE : options.truncate ? import_services14.GetDiagnosticsRequest.KEY_OPTION.TRUNCATE : void 0
|
|
5638
5820
|
});
|
|
5639
5821
|
const clientDiagnostics = {
|
|
5640
5822
|
config,
|
|
@@ -5674,6 +5856,7 @@ var findConfigs = () => {
|
|
|
5674
5856
|
IdentityManager,
|
|
5675
5857
|
IdentityServiceImpl,
|
|
5676
5858
|
InvitationsHandler,
|
|
5859
|
+
InvitationsManager,
|
|
5677
5860
|
InvitationsServiceImpl,
|
|
5678
5861
|
Lock,
|
|
5679
5862
|
ServiceContext,
|
|
@@ -5681,6 +5864,7 @@ var findConfigs = () => {
|
|
|
5681
5864
|
SpaceInvitationProtocol,
|
|
5682
5865
|
SpacesServiceImpl,
|
|
5683
5866
|
TrustedKeySetAuthVerifier,
|
|
5867
|
+
createAdmissionKeypair,
|
|
5684
5868
|
createAuthProvider,
|
|
5685
5869
|
createCollectDiagnosticsBroadcastHandler,
|
|
5686
5870
|
createCollectDiagnosticsBroadcastSender,
|
|
@@ -5688,7 +5872,6 @@ var findConfigs = () => {
|
|
|
5688
5872
|
createLevel,
|
|
5689
5873
|
createStorageObjects,
|
|
5690
5874
|
getNetworkPeers,
|
|
5691
|
-
invitationExpired,
|
|
5692
5875
|
isLocked,
|
|
5693
5876
|
subscribeToFeedBlocks,
|
|
5694
5877
|
subscribeToFeeds,
|
|
@@ -5698,4 +5881,4 @@ var findConfigs = () => {
|
|
|
5698
5881
|
subscribeToSpaces,
|
|
5699
5882
|
subscribeToSwarmInfo
|
|
5700
5883
|
});
|
|
5701
|
-
//# sourceMappingURL=chunk-
|
|
5884
|
+
//# sourceMappingURL=chunk-ZMWT7BZY.cjs.map
|