@dxos/client-services 0.4.10-main.bf8d896 → 0.4.10-main.c16d37b
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-3Z5ZPB7G.mjs → chunk-GZI6A3HL.mjs} +387 -335
- package/dist/lib/browser/chunk-GZI6A3HL.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +3 -1
- package/dist/lib/browser/index.mjs.map +1 -1
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/packlets/testing/index.mjs +3 -2
- package/dist/lib/browser/packlets/testing/index.mjs.map +3 -3
- package/dist/lib/node/{chunk-A2VEEQ4M.cjs → chunk-HI6XTPBD.cjs} +382 -331
- package/dist/lib/node/chunk-HI6XTPBD.cjs.map +7 -0
- package/dist/lib/node/index.cjs +44 -42
- 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 +8 -7
- package/dist/lib/node/packlets/testing/index.cjs.map +3 -3
- package/dist/types/src/packlets/indexing/util.d.ts +2 -1
- package/dist/types/src/packlets/indexing/util.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/invitations-handler.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/invitations-manager.d.ts +42 -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/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 +3 -2
- package/dist/types/src/packlets/services/service-host.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/data-space.d.ts.map +1 -1
- package/dist/types/src/packlets/testing/test-builder.d.ts +3 -4
- 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/indexing/util.ts +15 -8
- package/src/packlets/invitations/index.ts +1 -0
- package/src/packlets/invitations/invitations-handler.ts +1 -2
- package/src/packlets/invitations/invitations-manager.ts +197 -0
- package/src/packlets/invitations/invitations-service.ts +21 -168
- package/src/packlets/services/automerge-host.test.ts +1 -1
- package/src/packlets/services/service-context.ts +14 -3
- package/src/packlets/services/service-host.ts +15 -19
- package/src/packlets/spaces/data-space.ts +1 -1
- package/src/packlets/testing/test-builder.ts +4 -4
- package/src/version.ts +1 -1
- package/dist/lib/browser/chunk-3Z5ZPB7G.mjs.map +0 -7
- package/dist/lib/node/chunk-A2VEEQ4M.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_HI6XTPBD_exports = {};
|
|
30
|
+
__export(chunk_HI6XTPBD_exports, {
|
|
31
31
|
ClientRpcServer: () => ClientRpcServer,
|
|
32
32
|
ClientServicesHost: () => ClientServicesHost,
|
|
33
33
|
ClientServicesProviderResource: () => ClientServicesProviderResource,
|
|
@@ -41,6 +41,7 @@ __export(chunk_A2VEEQ4M_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,
|
|
@@ -65,7 +66,7 @@ __export(chunk_A2VEEQ4M_exports, {
|
|
|
65
66
|
subscribeToSpaces: () => subscribeToSpaces,
|
|
66
67
|
subscribeToSwarmInfo: () => subscribeToSwarmInfo
|
|
67
68
|
});
|
|
68
|
-
module.exports = __toCommonJS(
|
|
69
|
+
module.exports = __toCommonJS(chunk_HI6XTPBD_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");
|
|
@@ -138,30 +139,29 @@ var import_protocols5 = require("@dxos/protocols");
|
|
|
138
139
|
var import_services4 = require("@dxos/protocols/proto/dxos/client/services");
|
|
139
140
|
var import_invitations2 = require("@dxos/protocols/proto/dxos/halo/invitations");
|
|
140
141
|
var import_teleport = require("@dxos/teleport");
|
|
141
|
-
var import_async9 = require("@dxos/async");
|
|
142
142
|
var import_codec_protobuf8 = require("@dxos/codec-protobuf");
|
|
143
|
-
var import_context6 = require("@dxos/context");
|
|
144
|
-
var import_echo_pipeline = require("@dxos/echo-pipeline");
|
|
145
|
-
var import_invariant7 = require("@dxos/invariant");
|
|
146
|
-
var import_log6 = require("@dxos/log");
|
|
147
143
|
var import_services5 = require("@dxos/protocols/proto/dxos/client/services");
|
|
148
144
|
var import_credentials8 = require("@dxos/credentials");
|
|
149
145
|
var import_feed_store3 = require("@dxos/feed-store");
|
|
150
|
-
var
|
|
151
|
-
var
|
|
146
|
+
var import_invariant7 = require("@dxos/invariant");
|
|
147
|
+
var import_log6 = require("@dxos/log");
|
|
152
148
|
var import_protocols6 = require("@dxos/protocols");
|
|
153
149
|
var import_services6 = require("@dxos/protocols/proto/dxos/client/services");
|
|
150
|
+
var import_async9 = require("@dxos/async");
|
|
151
|
+
var import_echo_pipeline = require("@dxos/echo-pipeline");
|
|
152
|
+
var import_invariant8 = require("@dxos/invariant");
|
|
153
|
+
var import_log7 = require("@dxos/log");
|
|
154
154
|
var import_codec_protobuf9 = require("@dxos/codec-protobuf");
|
|
155
155
|
var import_debug2 = require("@dxos/debug");
|
|
156
156
|
var import_rpc = require("@dxos/rpc");
|
|
157
157
|
var import_tracing3 = require("@dxos/tracing");
|
|
158
158
|
var import_async10 = require("@dxos/async");
|
|
159
159
|
var import_client_protocol3 = require("@dxos/client-protocol");
|
|
160
|
-
var
|
|
160
|
+
var import_context6 = require("@dxos/context");
|
|
161
161
|
var import_debug3 = require("@dxos/debug");
|
|
162
|
-
var import_echo_db = require("@dxos/echo-db");
|
|
163
162
|
var import_echo_pipeline2 = require("@dxos/echo-pipeline");
|
|
164
163
|
var import_echo_pipeline3 = require("@dxos/echo-pipeline");
|
|
164
|
+
var import_echo_schema = require("@dxos/echo-schema");
|
|
165
165
|
var import_invariant9 = require("@dxos/invariant");
|
|
166
166
|
var import_keys7 = require("@dxos/keys");
|
|
167
167
|
var import_log8 = require("@dxos/log");
|
|
@@ -174,7 +174,7 @@ var import_util4 = require("@dxos/util");
|
|
|
174
174
|
var import_async11 = require("@dxos/async");
|
|
175
175
|
var import_credentials10 = require("@dxos/credentials");
|
|
176
176
|
var import_async12 = require("@dxos/async");
|
|
177
|
-
var
|
|
177
|
+
var import_context7 = require("@dxos/context");
|
|
178
178
|
var import_invariant10 = require("@dxos/invariant");
|
|
179
179
|
var import_keys8 = require("@dxos/keys");
|
|
180
180
|
var import_log9 = require("@dxos/log");
|
|
@@ -182,7 +182,7 @@ var import_protocols8 = require("@dxos/protocols");
|
|
|
182
182
|
var import_teleport2 = require("@dxos/teleport");
|
|
183
183
|
var import_util5 = require("@dxos/util");
|
|
184
184
|
var import_async13 = require("@dxos/async");
|
|
185
|
-
var
|
|
185
|
+
var import_context8 = require("@dxos/context");
|
|
186
186
|
var import_credentials11 = require("@dxos/credentials");
|
|
187
187
|
var import_invariant11 = require("@dxos/invariant");
|
|
188
188
|
var import_keys9 = require("@dxos/keys");
|
|
@@ -203,7 +203,7 @@ var import_log11 = require("@dxos/log");
|
|
|
203
203
|
var import_protocols10 = require("@dxos/protocols");
|
|
204
204
|
var import_services9 = require("@dxos/protocols/proto/dxos/client/services");
|
|
205
205
|
var import_async15 = require("@dxos/async");
|
|
206
|
-
var
|
|
206
|
+
var import_context9 = require("@dxos/context");
|
|
207
207
|
var import_credentials14 = require("@dxos/credentials");
|
|
208
208
|
var import_debug6 = require("@dxos/debug");
|
|
209
209
|
var import_echo_pipeline4 = require("@dxos/echo-pipeline");
|
|
@@ -219,7 +219,6 @@ var import_teleport_extension_object_sync = require("@dxos/teleport-extension-ob
|
|
|
219
219
|
var import_tracing5 = require("@dxos/tracing");
|
|
220
220
|
var import_util7 = require("@dxos/util");
|
|
221
221
|
var import_automerge = require("@dxos/automerge/automerge");
|
|
222
|
-
var import_debug7 = require("@dxos/debug");
|
|
223
222
|
var import_protocols12 = require("@dxos/protocols");
|
|
224
223
|
var import_codec_protobuf11 = require("@dxos/codec-protobuf");
|
|
225
224
|
var import_credentials15 = require("@dxos/credentials");
|
|
@@ -234,9 +233,9 @@ var import_tracing7 = require("@dxos/tracing");
|
|
|
234
233
|
var import_util8 = require("@dxos/util");
|
|
235
234
|
var import_async16 = require("@dxos/async");
|
|
236
235
|
var import_client_protocol4 = require("@dxos/client-protocol");
|
|
237
|
-
var
|
|
236
|
+
var import_context10 = require("@dxos/context");
|
|
238
237
|
var import_echo_pipeline5 = require("@dxos/echo-pipeline");
|
|
239
|
-
var
|
|
238
|
+
var import_echo_schema2 = require("@dxos/echo-schema");
|
|
240
239
|
var import_indexing2 = require("@dxos/indexing");
|
|
241
240
|
var import_invariant15 = require("@dxos/invariant");
|
|
242
241
|
var import_keys11 = require("@dxos/keys");
|
|
@@ -2021,7 +2020,7 @@ var InvitationsHandler = class {
|
|
|
2021
2020
|
});
|
|
2022
2021
|
return extension;
|
|
2023
2022
|
};
|
|
2024
|
-
if (invitation.lifetime && invitation.created
|
|
2023
|
+
if (invitation.lifetime && invitation.created) {
|
|
2025
2024
|
if (invitation.created.getTime() + invitation.lifetime * 1e3 < Date.now()) {
|
|
2026
2025
|
import_log4.log.warn("invitation has already expired", void 0, {
|
|
2027
2026
|
F: __dxlog_file7,
|
|
@@ -2086,7 +2085,7 @@ var InvitationsHandler = class {
|
|
|
2086
2085
|
if (deviceProfile) {
|
|
2087
2086
|
(0, import_invariant5.invariant)(invitation.kind === import_services3.Invitation.Kind.DEVICE, "deviceProfile provided for non-device invitation", {
|
|
2088
2087
|
F: __dxlog_file7,
|
|
2089
|
-
L:
|
|
2088
|
+
L: 255,
|
|
2090
2089
|
S: this,
|
|
2091
2090
|
A: [
|
|
2092
2091
|
"invitation.kind === Invitation.Kind.DEVICE",
|
|
@@ -2101,7 +2100,7 @@ var InvitationsHandler = class {
|
|
|
2101
2100
|
const setState = (newData) => {
|
|
2102
2101
|
(0, import_invariant5.invariant)(newData.state !== void 0, void 0, {
|
|
2103
2102
|
F: __dxlog_file7,
|
|
2104
|
-
L:
|
|
2103
|
+
L: 266,
|
|
2105
2104
|
S: this,
|
|
2106
2105
|
A: [
|
|
2107
2106
|
"newData.state !== undefined",
|
|
@@ -2121,7 +2120,7 @@ var InvitationsHandler = class {
|
|
|
2121
2120
|
...protocol.toJSON()
|
|
2122
2121
|
}, {
|
|
2123
2122
|
F: __dxlog_file7,
|
|
2124
|
-
L:
|
|
2123
|
+
L: 274,
|
|
2125
2124
|
S: this,
|
|
2126
2125
|
C: (f, a) => f(...a)
|
|
2127
2126
|
});
|
|
@@ -2131,7 +2130,7 @@ var InvitationsHandler = class {
|
|
|
2131
2130
|
} else {
|
|
2132
2131
|
import_log4.log.warn("auth failed", err, {
|
|
2133
2132
|
F: __dxlog_file7,
|
|
2134
|
-
L:
|
|
2133
|
+
L: 277,
|
|
2135
2134
|
S: this,
|
|
2136
2135
|
C: (f, a) => f(...a)
|
|
2137
2136
|
});
|
|
@@ -2145,7 +2144,7 @@ var InvitationsHandler = class {
|
|
|
2145
2144
|
...protocol.toJSON()
|
|
2146
2145
|
}, {
|
|
2147
2146
|
F: __dxlog_file7,
|
|
2148
|
-
L:
|
|
2147
|
+
L: 285,
|
|
2149
2148
|
S: this,
|
|
2150
2149
|
C: (f, a) => f(...a)
|
|
2151
2150
|
});
|
|
@@ -2160,7 +2159,7 @@ var InvitationsHandler = class {
|
|
|
2160
2159
|
currentState
|
|
2161
2160
|
}, {
|
|
2162
2161
|
F: __dxlog_file7,
|
|
2163
|
-
L:
|
|
2162
|
+
L: 295,
|
|
2164
2163
|
S: this,
|
|
2165
2164
|
C: (f, a) => f(...a)
|
|
2166
2165
|
});
|
|
@@ -2175,7 +2174,7 @@ var InvitationsHandler = class {
|
|
|
2175
2174
|
id: traceId
|
|
2176
2175
|
}), {
|
|
2177
2176
|
F: __dxlog_file7,
|
|
2178
|
-
L:
|
|
2177
|
+
L: 304,
|
|
2179
2178
|
S: this,
|
|
2180
2179
|
C: (f, a) => f(...a)
|
|
2181
2180
|
});
|
|
@@ -2187,7 +2186,7 @@ var InvitationsHandler = class {
|
|
|
2187
2186
|
...protocol.toJSON()
|
|
2188
2187
|
}, {
|
|
2189
2188
|
F: __dxlog_file7,
|
|
2190
|
-
L:
|
|
2189
|
+
L: 312,
|
|
2191
2190
|
S: this,
|
|
2192
2191
|
C: (f, a) => f(...a)
|
|
2193
2192
|
});
|
|
@@ -2198,7 +2197,7 @@ var InvitationsHandler = class {
|
|
|
2198
2197
|
...protocol.toJSON()
|
|
2199
2198
|
}, {
|
|
2200
2199
|
F: __dxlog_file7,
|
|
2201
|
-
L:
|
|
2200
|
+
L: 316,
|
|
2202
2201
|
S: this,
|
|
2203
2202
|
C: (f, a) => f(...a)
|
|
2204
2203
|
});
|
|
@@ -2208,7 +2207,7 @@ var InvitationsHandler = class {
|
|
|
2208
2207
|
response: introductionResponse
|
|
2209
2208
|
}, {
|
|
2210
2209
|
F: __dxlog_file7,
|
|
2211
|
-
L:
|
|
2210
|
+
L: 320,
|
|
2212
2211
|
S: this,
|
|
2213
2212
|
C: (f, a) => f(...a)
|
|
2214
2213
|
});
|
|
@@ -2229,7 +2228,7 @@ var InvitationsHandler = class {
|
|
|
2229
2228
|
...protocol.toJSON()
|
|
2230
2229
|
}, {
|
|
2231
2230
|
F: __dxlog_file7,
|
|
2232
|
-
L:
|
|
2231
|
+
L: 336,
|
|
2233
2232
|
S: this,
|
|
2234
2233
|
C: (f, a) => f(...a)
|
|
2235
2234
|
});
|
|
@@ -2241,7 +2240,7 @@ var InvitationsHandler = class {
|
|
|
2241
2240
|
...protocol.toJSON()
|
|
2242
2241
|
}, {
|
|
2243
2242
|
F: __dxlog_file7,
|
|
2244
|
-
L:
|
|
2243
|
+
L: 347,
|
|
2245
2244
|
S: this,
|
|
2246
2245
|
C: (f, a) => f(...a)
|
|
2247
2246
|
});
|
|
@@ -2254,7 +2253,7 @@ var InvitationsHandler = class {
|
|
|
2254
2253
|
id: traceId
|
|
2255
2254
|
}), {
|
|
2256
2255
|
F: __dxlog_file7,
|
|
2257
|
-
L:
|
|
2256
|
+
L: 349,
|
|
2258
2257
|
S: this,
|
|
2259
2258
|
C: (f, a) => f(...a)
|
|
2260
2259
|
});
|
|
@@ -2264,7 +2263,7 @@ var InvitationsHandler = class {
|
|
|
2264
2263
|
...protocol.toJSON()
|
|
2265
2264
|
}, {
|
|
2266
2265
|
F: __dxlog_file7,
|
|
2267
|
-
L:
|
|
2266
|
+
L: 352,
|
|
2268
2267
|
S: this,
|
|
2269
2268
|
C: (f, a) => f(...a)
|
|
2270
2269
|
});
|
|
@@ -2274,7 +2273,7 @@ var InvitationsHandler = class {
|
|
|
2274
2273
|
} else {
|
|
2275
2274
|
(0, import_log4.log)("auth failed", err, {
|
|
2276
2275
|
F: __dxlog_file7,
|
|
2277
|
-
L:
|
|
2276
|
+
L: 355,
|
|
2278
2277
|
S: this,
|
|
2279
2278
|
C: (f, a) => f(...a)
|
|
2280
2279
|
});
|
|
@@ -2285,7 +2284,7 @@ var InvitationsHandler = class {
|
|
|
2285
2284
|
error: err
|
|
2286
2285
|
}), {
|
|
2287
2286
|
F: __dxlog_file7,
|
|
2288
|
-
L:
|
|
2287
|
+
L: 358,
|
|
2289
2288
|
S: this,
|
|
2290
2289
|
C: (f, a) => f(...a)
|
|
2291
2290
|
});
|
|
@@ -2303,7 +2302,7 @@ var InvitationsHandler = class {
|
|
|
2303
2302
|
...protocol.toJSON()
|
|
2304
2303
|
}, {
|
|
2305
2304
|
F: __dxlog_file7,
|
|
2306
|
-
L:
|
|
2305
|
+
L: 369,
|
|
2307
2306
|
S: this,
|
|
2308
2307
|
C: (f, a) => f(...a)
|
|
2309
2308
|
});
|
|
@@ -2313,7 +2312,7 @@ var InvitationsHandler = class {
|
|
|
2313
2312
|
} else {
|
|
2314
2313
|
(0, import_log4.log)("auth failed", err, {
|
|
2315
2314
|
F: __dxlog_file7,
|
|
2316
|
-
L:
|
|
2315
|
+
L: 372,
|
|
2317
2316
|
S: this,
|
|
2318
2317
|
C: (f, a) => f(...a)
|
|
2319
2318
|
});
|
|
@@ -2330,7 +2329,7 @@ var InvitationsHandler = class {
|
|
|
2330
2329
|
} else {
|
|
2331
2330
|
(0, import_invariant5.invariant)(invitation.swarmKey, void 0, {
|
|
2332
2331
|
F: __dxlog_file7,
|
|
2333
|
-
L:
|
|
2332
|
+
L: 386,
|
|
2334
2333
|
S: this,
|
|
2335
2334
|
A: [
|
|
2336
2335
|
"invitation.swarmKey",
|
|
@@ -2372,7 +2371,7 @@ var InvitationsHandler = class {
|
|
|
2372
2371
|
for (let attempt = 1; attempt <= MAX_OTP_ATTEMPTS; attempt++) {
|
|
2373
2372
|
(0, import_log4.log)("guest waiting for authentication code...", void 0, {
|
|
2374
2373
|
F: __dxlog_file7,
|
|
2375
|
-
L:
|
|
2374
|
+
L: 426,
|
|
2376
2375
|
S: this,
|
|
2377
2376
|
C: (f, a) => f(...a)
|
|
2378
2377
|
});
|
|
@@ -2382,7 +2381,7 @@ var InvitationsHandler = class {
|
|
|
2382
2381
|
const authCode = await authenticated.wait(options);
|
|
2383
2382
|
(0, import_log4.log)("sending authentication request", void 0, {
|
|
2384
2383
|
F: __dxlog_file7,
|
|
2385
|
-
L:
|
|
2384
|
+
L: 430,
|
|
2386
2385
|
S: this,
|
|
2387
2386
|
C: (f, a) => f(...a)
|
|
2388
2387
|
});
|
|
@@ -2403,7 +2402,7 @@ var InvitationsHandler = class {
|
|
|
2403
2402
|
attempt
|
|
2404
2403
|
}, {
|
|
2405
2404
|
F: __dxlog_file7,
|
|
2406
|
-
L:
|
|
2405
|
+
L: 441,
|
|
2407
2406
|
S: this,
|
|
2408
2407
|
C: (f, a) => f(...a)
|
|
2409
2408
|
});
|
|
@@ -2421,7 +2420,7 @@ var InvitationsHandler = class {
|
|
|
2421
2420
|
}
|
|
2422
2421
|
(0, import_log4.log)("sending authentication request", void 0, {
|
|
2423
2422
|
F: __dxlog_file7,
|
|
2424
|
-
L:
|
|
2423
|
+
L: 460,
|
|
2425
2424
|
S: this,
|
|
2426
2425
|
C: (f, a) => f(...a)
|
|
2427
2426
|
});
|
|
@@ -2444,194 +2443,35 @@ var createAdmissionKeypair = () => {
|
|
|
2444
2443
|
privateKey: keypair.secretKey
|
|
2445
2444
|
};
|
|
2446
2445
|
};
|
|
2447
|
-
var __dxlog_file8 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitations-service.ts";
|
|
2448
2446
|
var InvitationsServiceImpl = class {
|
|
2449
|
-
constructor(
|
|
2450
|
-
this.
|
|
2451
|
-
this._getHandler = _getHandler;
|
|
2452
|
-
this._metadataStore = _metadataStore;
|
|
2453
|
-
this._createInvitations = /* @__PURE__ */ new Map();
|
|
2454
|
-
this._acceptInvitations = /* @__PURE__ */ new Map();
|
|
2455
|
-
this._invitationCreated = new import_async9.Event();
|
|
2456
|
-
this._invitationAccepted = new import_async9.Event();
|
|
2457
|
-
this._removedCreated = new import_async9.Event();
|
|
2458
|
-
this._removedAccepted = new import_async9.Event();
|
|
2459
|
-
this._saved = new import_async9.Event();
|
|
2460
|
-
this._persistentInvitationsLoadedEvent = new import_async9.Event();
|
|
2461
|
-
this._persistentInvitationsLoaded = false;
|
|
2447
|
+
constructor(_invitationsManager) {
|
|
2448
|
+
this._invitationsManager = _invitationsManager;
|
|
2462
2449
|
}
|
|
2463
2450
|
// TODO(burdon): Guest/host label.
|
|
2464
2451
|
getLoggingContext() {
|
|
2465
2452
|
return {};
|
|
2466
2453
|
}
|
|
2467
2454
|
createInvitation(options) {
|
|
2468
|
-
|
|
2469
|
-
const savePersistentInvitationCtx = new import_context6.Context();
|
|
2470
|
-
const existingInvitation = this._createInvitations.get(options.invitationId);
|
|
2471
|
-
if (existingInvitation) {
|
|
2472
|
-
invitation = existingInvitation;
|
|
2473
|
-
} else {
|
|
2474
|
-
const handler = this._getHandler(options);
|
|
2475
|
-
invitation = this._invitationsHandler.createInvitation(handler, options);
|
|
2476
|
-
this._createInvitations.set(invitation.get().invitationId, invitation);
|
|
2477
|
-
this._invitationCreated.emit(invitation.get());
|
|
2478
|
-
}
|
|
2455
|
+
const invitation = this._invitationsManager.createInvitation(options);
|
|
2479
2456
|
return new import_codec_protobuf8.Stream(({ next, close }) => {
|
|
2480
|
-
|
|
2481
|
-
(0, import_async9.scheduleTask)(savePersistentInvitationCtx, async () => {
|
|
2482
|
-
try {
|
|
2483
|
-
await this._metadataStore.addInvitation(invitation.get());
|
|
2484
|
-
this._saved.emit(invitation.get());
|
|
2485
|
-
} catch (err) {
|
|
2486
|
-
close(err);
|
|
2487
|
-
}
|
|
2488
|
-
});
|
|
2489
|
-
}
|
|
2490
|
-
invitation.subscribe((invitation2) => {
|
|
2491
|
-
next(invitation2);
|
|
2492
|
-
}, async (err) => {
|
|
2493
|
-
await savePersistentInvitationCtx.dispose();
|
|
2494
|
-
close(err);
|
|
2495
|
-
}, async () => {
|
|
2496
|
-
close();
|
|
2497
|
-
if (invitation.get().persistent) {
|
|
2498
|
-
await savePersistentInvitationCtx.dispose();
|
|
2499
|
-
await this._metadataStore.removeInvitation(invitation.get().invitationId);
|
|
2500
|
-
}
|
|
2501
|
-
this._createInvitations.delete(invitation.get().invitationId);
|
|
2502
|
-
if (!invitation.get().multiUse) {
|
|
2503
|
-
this._removedCreated.emit(invitation.get());
|
|
2504
|
-
}
|
|
2505
|
-
});
|
|
2457
|
+
invitation.subscribe(next, close, close);
|
|
2506
2458
|
});
|
|
2507
2459
|
}
|
|
2508
|
-
|
|
2509
|
-
const
|
|
2510
|
-
const freshInvitations = persistentInvitations.filter(async (invitation) => !(0, import_echo_pipeline.hasInvitationExpired)(invitation));
|
|
2511
|
-
const cInvitations = freshInvitations.map((persistentInvitation) => {
|
|
2512
|
-
(0, import_invariant7.invariant)(!this._createInvitations.get(persistentInvitation.invitationId), "invitation already exists", {
|
|
2513
|
-
F: __dxlog_file8,
|
|
2514
|
-
L: 109,
|
|
2515
|
-
S: this,
|
|
2516
|
-
A: [
|
|
2517
|
-
"!this._createInvitations.get(persistentInvitation.invitationId)",
|
|
2518
|
-
"'invitation already exists'"
|
|
2519
|
-
]
|
|
2520
|
-
});
|
|
2521
|
-
const handler = this._getHandler(persistentInvitation);
|
|
2522
|
-
const invitation = this._invitationsHandler.createInvitation(handler, persistentInvitation);
|
|
2523
|
-
this._createInvitations.set(invitation.get().invitationId, invitation);
|
|
2524
|
-
this._invitationCreated.emit(invitation.get());
|
|
2525
|
-
return persistentInvitation;
|
|
2526
|
-
});
|
|
2527
|
-
this._persistentInvitationsLoadedEvent.emit();
|
|
2528
|
-
this._persistentInvitationsLoaded = true;
|
|
2529
|
-
return {
|
|
2530
|
-
invitations: cInvitations
|
|
2531
|
-
};
|
|
2532
|
-
}
|
|
2533
|
-
acceptInvitation({ invitation: options, deviceProfile }) {
|
|
2534
|
-
let invitation;
|
|
2535
|
-
if (deviceProfile) {
|
|
2536
|
-
(0, import_invariant7.invariant)(options.kind === import_services5.Invitation.Kind.DEVICE, "deviceProfile provided for non-device invitation", {
|
|
2537
|
-
F: __dxlog_file8,
|
|
2538
|
-
L: 127,
|
|
2539
|
-
S: this,
|
|
2540
|
-
A: [
|
|
2541
|
-
"options.kind === Invitation.Kind.DEVICE",
|
|
2542
|
-
"'deviceProfile provided for non-device invitation'"
|
|
2543
|
-
]
|
|
2544
|
-
});
|
|
2545
|
-
}
|
|
2546
|
-
const existingInvitation = this._acceptInvitations.get(options.invitationId);
|
|
2547
|
-
if (existingInvitation) {
|
|
2548
|
-
invitation = existingInvitation;
|
|
2549
|
-
} else {
|
|
2550
|
-
const handler = this._getHandler(options);
|
|
2551
|
-
invitation = this._invitationsHandler.acceptInvitation(handler, options, deviceProfile);
|
|
2552
|
-
this._acceptInvitations.set(invitation.get().invitationId, invitation);
|
|
2553
|
-
this._invitationAccepted.emit(invitation.get());
|
|
2554
|
-
}
|
|
2460
|
+
acceptInvitation(request) {
|
|
2461
|
+
const invitation = this._invitationsManager.acceptInvitation(request);
|
|
2555
2462
|
return new import_codec_protobuf8.Stream(({ next, close }) => {
|
|
2556
|
-
invitation.subscribe(
|
|
2557
|
-
next(invitation2);
|
|
2558
|
-
}, (err) => {
|
|
2559
|
-
close(err);
|
|
2560
|
-
}, () => {
|
|
2561
|
-
close();
|
|
2562
|
-
this._acceptInvitations.delete(invitation.get().invitationId);
|
|
2563
|
-
if (!invitation.get().multiUse) {
|
|
2564
|
-
this._removedAccepted.emit(invitation.get());
|
|
2565
|
-
}
|
|
2566
|
-
});
|
|
2463
|
+
invitation.subscribe(next, close, close);
|
|
2567
2464
|
});
|
|
2568
2465
|
}
|
|
2569
|
-
async authenticate(
|
|
2570
|
-
|
|
2571
|
-
F: __dxlog_file8,
|
|
2572
|
-
L: 160,
|
|
2573
|
-
S: this,
|
|
2574
|
-
C: (f, a) => f(...a)
|
|
2575
|
-
});
|
|
2576
|
-
(0, import_invariant7.invariant)(invitationId, void 0, {
|
|
2577
|
-
F: __dxlog_file8,
|
|
2578
|
-
L: 161,
|
|
2579
|
-
S: this,
|
|
2580
|
-
A: [
|
|
2581
|
-
"invitationId",
|
|
2582
|
-
""
|
|
2583
|
-
]
|
|
2584
|
-
});
|
|
2585
|
-
const observable = this._acceptInvitations.get(invitationId);
|
|
2586
|
-
if (!observable) {
|
|
2587
|
-
import_log6.log.warn("invalid invitation", {
|
|
2588
|
-
invitationId
|
|
2589
|
-
}, {
|
|
2590
|
-
F: __dxlog_file8,
|
|
2591
|
-
L: 164,
|
|
2592
|
-
S: this,
|
|
2593
|
-
C: (f, a) => f(...a)
|
|
2594
|
-
});
|
|
2595
|
-
} else {
|
|
2596
|
-
await observable.authenticate(authCode);
|
|
2597
|
-
}
|
|
2466
|
+
async authenticate(request) {
|
|
2467
|
+
return this._invitationsManager.authenticate(request);
|
|
2598
2468
|
}
|
|
2599
|
-
async cancelInvitation(
|
|
2600
|
-
|
|
2601
|
-
invitationId
|
|
2602
|
-
}, {
|
|
2603
|
-
F: __dxlog_file8,
|
|
2604
|
-
L: 171,
|
|
2605
|
-
S: this,
|
|
2606
|
-
C: (f, a) => f(...a)
|
|
2607
|
-
});
|
|
2608
|
-
(0, import_invariant7.invariant)(invitationId, void 0, {
|
|
2609
|
-
F: __dxlog_file8,
|
|
2610
|
-
L: 172,
|
|
2611
|
-
S: this,
|
|
2612
|
-
A: [
|
|
2613
|
-
"invitationId",
|
|
2614
|
-
""
|
|
2615
|
-
]
|
|
2616
|
-
});
|
|
2617
|
-
const created = this._createInvitations.get(invitationId);
|
|
2618
|
-
const accepted = this._acceptInvitations.get(invitationId);
|
|
2619
|
-
if (created) {
|
|
2620
|
-
await created.cancel();
|
|
2621
|
-
this._createInvitations.delete(invitationId);
|
|
2622
|
-
this._removedCreated.emit(created.get());
|
|
2623
|
-
if (created.get().persistent) {
|
|
2624
|
-
await this._metadataStore.removeInvitation(created.get().invitationId);
|
|
2625
|
-
}
|
|
2626
|
-
} else if (accepted) {
|
|
2627
|
-
await accepted.cancel();
|
|
2628
|
-
this._acceptInvitations.delete(invitationId);
|
|
2629
|
-
this._removedAccepted.emit(accepted.get());
|
|
2630
|
-
}
|
|
2469
|
+
async cancelInvitation(request) {
|
|
2470
|
+
return this._invitationsManager.cancelInvitation(request);
|
|
2631
2471
|
}
|
|
2632
2472
|
queryInvitations() {
|
|
2633
2473
|
return new import_codec_protobuf8.Stream(({ next, ctx }) => {
|
|
2634
|
-
this.
|
|
2474
|
+
this._invitationsManager.invitationCreated.on(ctx, (invitation) => {
|
|
2635
2475
|
next({
|
|
2636
2476
|
action: import_services5.QueryInvitationsResponse.Action.ADDED,
|
|
2637
2477
|
type: import_services5.QueryInvitationsResponse.Type.CREATED,
|
|
@@ -2640,7 +2480,7 @@ var InvitationsServiceImpl = class {
|
|
|
2640
2480
|
]
|
|
2641
2481
|
});
|
|
2642
2482
|
});
|
|
2643
|
-
this.
|
|
2483
|
+
this._invitationsManager.invitationAccepted.on(ctx, (invitation) => {
|
|
2644
2484
|
next({
|
|
2645
2485
|
action: import_services5.QueryInvitationsResponse.Action.ADDED,
|
|
2646
2486
|
type: import_services5.QueryInvitationsResponse.Type.ACCEPTED,
|
|
@@ -2649,7 +2489,7 @@ var InvitationsServiceImpl = class {
|
|
|
2649
2489
|
]
|
|
2650
2490
|
});
|
|
2651
2491
|
});
|
|
2652
|
-
this.
|
|
2492
|
+
this._invitationsManager.removedCreated.on(ctx, (invitation) => {
|
|
2653
2493
|
next({
|
|
2654
2494
|
action: import_services5.QueryInvitationsResponse.Action.REMOVED,
|
|
2655
2495
|
type: import_services5.QueryInvitationsResponse.Type.CREATED,
|
|
@@ -2658,7 +2498,7 @@ var InvitationsServiceImpl = class {
|
|
|
2658
2498
|
]
|
|
2659
2499
|
});
|
|
2660
2500
|
});
|
|
2661
|
-
this.
|
|
2501
|
+
this._invitationsManager.removedAccepted.on(ctx, (invitation) => {
|
|
2662
2502
|
next({
|
|
2663
2503
|
action: import_services5.QueryInvitationsResponse.Action.REMOVED,
|
|
2664
2504
|
type: import_services5.QueryInvitationsResponse.Type.ACCEPTED,
|
|
@@ -2667,7 +2507,7 @@ var InvitationsServiceImpl = class {
|
|
|
2667
2507
|
]
|
|
2668
2508
|
});
|
|
2669
2509
|
});
|
|
2670
|
-
this.
|
|
2510
|
+
this._invitationsManager.saved.on(ctx, (invitation) => {
|
|
2671
2511
|
next({
|
|
2672
2512
|
action: import_services5.QueryInvitationsResponse.Action.SAVED,
|
|
2673
2513
|
type: import_services5.QueryInvitationsResponse.Type.CREATED,
|
|
@@ -2679,32 +2519,25 @@ var InvitationsServiceImpl = class {
|
|
|
2679
2519
|
next({
|
|
2680
2520
|
action: import_services5.QueryInvitationsResponse.Action.ADDED,
|
|
2681
2521
|
type: import_services5.QueryInvitationsResponse.Type.CREATED,
|
|
2682
|
-
invitations:
|
|
2522
|
+
invitations: this._invitationsManager.getCreatedInvitations(),
|
|
2683
2523
|
existing: true
|
|
2684
2524
|
});
|
|
2685
2525
|
next({
|
|
2686
2526
|
action: import_services5.QueryInvitationsResponse.Action.ADDED,
|
|
2687
2527
|
type: import_services5.QueryInvitationsResponse.Type.ACCEPTED,
|
|
2688
|
-
invitations:
|
|
2528
|
+
invitations: this._invitationsManager.getAcceptedInvitations(),
|
|
2689
2529
|
existing: true
|
|
2690
2530
|
});
|
|
2691
|
-
|
|
2531
|
+
this._invitationsManager.onPersistentInvitationsLoaded(ctx, () => {
|
|
2692
2532
|
next({
|
|
2693
2533
|
action: import_services5.QueryInvitationsResponse.Action.LOAD_COMPLETE,
|
|
2694
2534
|
type: import_services5.QueryInvitationsResponse.Type.CREATED
|
|
2695
2535
|
});
|
|
2696
|
-
}
|
|
2697
|
-
this._persistentInvitationsLoadedEvent.on(ctx, () => {
|
|
2698
|
-
next({
|
|
2699
|
-
action: import_services5.QueryInvitationsResponse.Action.LOAD_COMPLETE,
|
|
2700
|
-
type: import_services5.QueryInvitationsResponse.Type.CREATED
|
|
2701
|
-
});
|
|
2702
|
-
});
|
|
2703
|
-
}
|
|
2536
|
+
});
|
|
2704
2537
|
});
|
|
2705
2538
|
}
|
|
2706
2539
|
};
|
|
2707
|
-
var
|
|
2540
|
+
var __dxlog_file8 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/space-invitation-protocol.ts";
|
|
2708
2541
|
var SpaceInvitationProtocol = class {
|
|
2709
2542
|
constructor(_spaceManager, _signingContext, _keyring, _spaceKey) {
|
|
2710
2543
|
this._spaceManager = _spaceManager;
|
|
@@ -2725,8 +2558,8 @@ var SpaceInvitationProtocol = class {
|
|
|
2725
2558
|
};
|
|
2726
2559
|
}
|
|
2727
2560
|
async admit(request, guestProfile) {
|
|
2728
|
-
(0,
|
|
2729
|
-
F:
|
|
2561
|
+
(0, import_invariant7.invariant)(this._spaceKey, void 0, {
|
|
2562
|
+
F: __dxlog_file8,
|
|
2730
2563
|
L: 47,
|
|
2731
2564
|
S: this,
|
|
2732
2565
|
A: [
|
|
@@ -2735,8 +2568,8 @@ var SpaceInvitationProtocol = class {
|
|
|
2735
2568
|
]
|
|
2736
2569
|
});
|
|
2737
2570
|
const space = await this._spaceManager.spaces.get(this._spaceKey);
|
|
2738
|
-
(0,
|
|
2739
|
-
F:
|
|
2571
|
+
(0, import_invariant7.invariant)(space, void 0, {
|
|
2572
|
+
F: __dxlog_file8,
|
|
2740
2573
|
L: 49,
|
|
2741
2574
|
S: this,
|
|
2742
2575
|
A: [
|
|
@@ -2744,8 +2577,8 @@ var SpaceInvitationProtocol = class {
|
|
|
2744
2577
|
""
|
|
2745
2578
|
]
|
|
2746
2579
|
});
|
|
2747
|
-
(0,
|
|
2748
|
-
F:
|
|
2580
|
+
(0, import_invariant7.invariant)(request.space, void 0, {
|
|
2581
|
+
F: __dxlog_file8,
|
|
2749
2582
|
L: 51,
|
|
2750
2583
|
S: this,
|
|
2751
2584
|
A: [
|
|
@@ -2754,18 +2587,18 @@ var SpaceInvitationProtocol = class {
|
|
|
2754
2587
|
]
|
|
2755
2588
|
});
|
|
2756
2589
|
const { identityKey, deviceKey } = request.space;
|
|
2757
|
-
(0,
|
|
2590
|
+
(0, import_log6.log)("writing guest credentials", {
|
|
2758
2591
|
host: this._signingContext.deviceKey,
|
|
2759
2592
|
guest: deviceKey
|
|
2760
2593
|
}, {
|
|
2761
|
-
F:
|
|
2594
|
+
F: __dxlog_file8,
|
|
2762
2595
|
L: 54,
|
|
2763
2596
|
S: this,
|
|
2764
2597
|
C: (f, a) => f(...a)
|
|
2765
2598
|
});
|
|
2766
2599
|
const credentials = await (0, import_credentials8.createAdmissionCredentials)(this._signingContext.credentialSigner, identityKey, space.key, space.inner.genesisFeedKey, guestProfile);
|
|
2767
|
-
(0,
|
|
2768
|
-
F:
|
|
2600
|
+
(0, import_invariant7.invariant)(credentials[0].credential, void 0, {
|
|
2601
|
+
F: __dxlog_file8,
|
|
2769
2602
|
L: 65,
|
|
2770
2603
|
S: this,
|
|
2771
2604
|
A: [
|
|
@@ -2774,8 +2607,8 @@ var SpaceInvitationProtocol = class {
|
|
|
2774
2607
|
]
|
|
2775
2608
|
});
|
|
2776
2609
|
const spaceMemberCredential = credentials[0].credential.credential;
|
|
2777
|
-
(0,
|
|
2778
|
-
F:
|
|
2610
|
+
(0, import_invariant7.invariant)((0, import_credentials8.getCredentialAssertion)(spaceMemberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
|
|
2611
|
+
F: __dxlog_file8,
|
|
2779
2612
|
L: 67,
|
|
2780
2613
|
S: this,
|
|
2781
2614
|
A: [
|
|
@@ -2814,8 +2647,8 @@ var SpaceInvitationProtocol = class {
|
|
|
2814
2647
|
};
|
|
2815
2648
|
}
|
|
2816
2649
|
async accept(response) {
|
|
2817
|
-
(0,
|
|
2818
|
-
F:
|
|
2650
|
+
(0, import_invariant7.invariant)(response.space, void 0, {
|
|
2651
|
+
F: __dxlog_file8,
|
|
2819
2652
|
L: 107,
|
|
2820
2653
|
S: this,
|
|
2821
2654
|
A: [
|
|
@@ -2825,8 +2658,8 @@ var SpaceInvitationProtocol = class {
|
|
|
2825
2658
|
});
|
|
2826
2659
|
const { credential, controlTimeframe, dataTimeframe } = response.space;
|
|
2827
2660
|
const assertion = (0, import_credentials8.getCredentialAssertion)(credential);
|
|
2828
|
-
(0,
|
|
2829
|
-
F:
|
|
2661
|
+
(0, import_invariant7.invariant)(assertion["@type"] === "dxos.halo.credentials.SpaceMember", "Invalid credential", {
|
|
2662
|
+
F: __dxlog_file8,
|
|
2830
2663
|
L: 110,
|
|
2831
2664
|
S: this,
|
|
2832
2665
|
A: [
|
|
@@ -2834,8 +2667,8 @@ var SpaceInvitationProtocol = class {
|
|
|
2834
2667
|
"'Invalid credential'"
|
|
2835
2668
|
]
|
|
2836
2669
|
});
|
|
2837
|
-
(0,
|
|
2838
|
-
F:
|
|
2670
|
+
(0, import_invariant7.invariant)(credential.subject.id.equals(this._signingContext.identityKey), void 0, {
|
|
2671
|
+
F: __dxlog_file8,
|
|
2839
2672
|
L: 111,
|
|
2840
2673
|
S: this,
|
|
2841
2674
|
A: [
|
|
@@ -2858,6 +2691,221 @@ var SpaceInvitationProtocol = class {
|
|
|
2858
2691
|
};
|
|
2859
2692
|
}
|
|
2860
2693
|
};
|
|
2694
|
+
var __dxlog_file9 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitations-manager.ts";
|
|
2695
|
+
var InvitationsManager = class {
|
|
2696
|
+
constructor(_invitationsHandler, _getHandler, _metadataStore) {
|
|
2697
|
+
this._invitationsHandler = _invitationsHandler;
|
|
2698
|
+
this._getHandler = _getHandler;
|
|
2699
|
+
this._metadataStore = _metadataStore;
|
|
2700
|
+
this._createInvitations = /* @__PURE__ */ new Map();
|
|
2701
|
+
this._acceptInvitations = /* @__PURE__ */ new Map();
|
|
2702
|
+
this.invitationCreated = new import_async9.Event();
|
|
2703
|
+
this.invitationAccepted = new import_async9.Event();
|
|
2704
|
+
this.removedCreated = new import_async9.Event();
|
|
2705
|
+
this.removedAccepted = new import_async9.Event();
|
|
2706
|
+
this.saved = new import_async9.Event();
|
|
2707
|
+
this._persistentInvitationsLoadedEvent = new import_async9.Event();
|
|
2708
|
+
this._persistentInvitationsLoaded = false;
|
|
2709
|
+
}
|
|
2710
|
+
createInvitation(options) {
|
|
2711
|
+
const existingInvitation = this._createInvitations.get(options.invitationId);
|
|
2712
|
+
if (existingInvitation) {
|
|
2713
|
+
return existingInvitation;
|
|
2714
|
+
}
|
|
2715
|
+
const handler = this._getHandler(options);
|
|
2716
|
+
const invitation = this._invitationsHandler.createInvitation(handler, options);
|
|
2717
|
+
this._createInvitations.set(invitation.get().invitationId, invitation);
|
|
2718
|
+
this.invitationCreated.emit(invitation.get());
|
|
2719
|
+
const saveInvitationTask = invitation.get().persistent ? this._safePersistInBackground(invitation) : Promise.resolve();
|
|
2720
|
+
this._onInvitationComplete(invitation, async () => {
|
|
2721
|
+
this._createInvitations.delete(invitation.get().invitationId);
|
|
2722
|
+
this.removedCreated.emit(invitation.get());
|
|
2723
|
+
if (invitation.get().persistent) {
|
|
2724
|
+
await saveInvitationTask;
|
|
2725
|
+
await this._safeDeleteInvitation(invitation.get());
|
|
2726
|
+
}
|
|
2727
|
+
});
|
|
2728
|
+
return invitation;
|
|
2729
|
+
}
|
|
2730
|
+
async loadPersistentInvitations() {
|
|
2731
|
+
if (this._persistentInvitationsLoaded) {
|
|
2732
|
+
const invitations = this.getCreatedInvitations().filter((i) => i.persistent);
|
|
2733
|
+
return {
|
|
2734
|
+
invitations
|
|
2735
|
+
};
|
|
2736
|
+
}
|
|
2737
|
+
try {
|
|
2738
|
+
const persistentInvitations = this._metadataStore.getInvitations();
|
|
2739
|
+
const freshInvitations = persistentInvitations.filter((invitation) => !(0, import_echo_pipeline.hasInvitationExpired)(invitation));
|
|
2740
|
+
const cInvitations = freshInvitations.map((persistentInvitation) => {
|
|
2741
|
+
(0, import_invariant8.invariant)(!this._createInvitations.get(persistentInvitation.invitationId), "invitation already exists", {
|
|
2742
|
+
F: __dxlog_file9,
|
|
2743
|
+
L: 82,
|
|
2744
|
+
S: this,
|
|
2745
|
+
A: [
|
|
2746
|
+
"!this._createInvitations.get(persistentInvitation.invitationId)",
|
|
2747
|
+
"'invitation already exists'"
|
|
2748
|
+
]
|
|
2749
|
+
});
|
|
2750
|
+
return this.createInvitation({
|
|
2751
|
+
...persistentInvitation,
|
|
2752
|
+
persistent: false
|
|
2753
|
+
}).get();
|
|
2754
|
+
});
|
|
2755
|
+
return {
|
|
2756
|
+
invitations: cInvitations
|
|
2757
|
+
};
|
|
2758
|
+
} catch (err) {
|
|
2759
|
+
import_log7.log.catch(err, void 0, {
|
|
2760
|
+
F: __dxlog_file9,
|
|
2761
|
+
L: 88,
|
|
2762
|
+
S: this,
|
|
2763
|
+
C: (f, a) => f(...a)
|
|
2764
|
+
});
|
|
2765
|
+
return {
|
|
2766
|
+
invitations: []
|
|
2767
|
+
};
|
|
2768
|
+
} finally {
|
|
2769
|
+
this._persistentInvitationsLoadedEvent.emit();
|
|
2770
|
+
this._persistentInvitationsLoaded = true;
|
|
2771
|
+
}
|
|
2772
|
+
}
|
|
2773
|
+
acceptInvitation(request) {
|
|
2774
|
+
const options = request.invitation;
|
|
2775
|
+
const existingInvitation = this._acceptInvitations.get(options.invitationId);
|
|
2776
|
+
if (existingInvitation) {
|
|
2777
|
+
return existingInvitation;
|
|
2778
|
+
}
|
|
2779
|
+
const handler = this._getHandler(options);
|
|
2780
|
+
const invitation = this._invitationsHandler.acceptInvitation(handler, options, request.deviceProfile);
|
|
2781
|
+
this._acceptInvitations.set(invitation.get().invitationId, invitation);
|
|
2782
|
+
this.invitationAccepted.emit(invitation.get());
|
|
2783
|
+
this._onInvitationComplete(invitation, () => {
|
|
2784
|
+
this._acceptInvitations.delete(invitation.get().invitationId);
|
|
2785
|
+
this.removedAccepted.emit(invitation.get());
|
|
2786
|
+
});
|
|
2787
|
+
return invitation;
|
|
2788
|
+
}
|
|
2789
|
+
async authenticate({ invitationId, authCode }) {
|
|
2790
|
+
(0, import_log7.log)("authenticating...", void 0, {
|
|
2791
|
+
F: __dxlog_file9,
|
|
2792
|
+
L: 117,
|
|
2793
|
+
S: this,
|
|
2794
|
+
C: (f, a) => f(...a)
|
|
2795
|
+
});
|
|
2796
|
+
(0, import_invariant8.invariant)(invitationId, void 0, {
|
|
2797
|
+
F: __dxlog_file9,
|
|
2798
|
+
L: 118,
|
|
2799
|
+
S: this,
|
|
2800
|
+
A: [
|
|
2801
|
+
"invitationId",
|
|
2802
|
+
""
|
|
2803
|
+
]
|
|
2804
|
+
});
|
|
2805
|
+
const observable = this._acceptInvitations.get(invitationId);
|
|
2806
|
+
if (!observable) {
|
|
2807
|
+
import_log7.log.warn("invalid invitation", {
|
|
2808
|
+
invitationId
|
|
2809
|
+
}, {
|
|
2810
|
+
F: __dxlog_file9,
|
|
2811
|
+
L: 121,
|
|
2812
|
+
S: this,
|
|
2813
|
+
C: (f, a) => f(...a)
|
|
2814
|
+
});
|
|
2815
|
+
} else {
|
|
2816
|
+
await observable.authenticate(authCode);
|
|
2817
|
+
}
|
|
2818
|
+
}
|
|
2819
|
+
async cancelInvitation({ invitationId }) {
|
|
2820
|
+
(0, import_log7.log)("cancelInvitation...", {
|
|
2821
|
+
invitationId
|
|
2822
|
+
}, {
|
|
2823
|
+
F: __dxlog_file9,
|
|
2824
|
+
L: 128,
|
|
2825
|
+
S: this,
|
|
2826
|
+
C: (f, a) => f(...a)
|
|
2827
|
+
});
|
|
2828
|
+
(0, import_invariant8.invariant)(invitationId, void 0, {
|
|
2829
|
+
F: __dxlog_file9,
|
|
2830
|
+
L: 129,
|
|
2831
|
+
S: this,
|
|
2832
|
+
A: [
|
|
2833
|
+
"invitationId",
|
|
2834
|
+
""
|
|
2835
|
+
]
|
|
2836
|
+
});
|
|
2837
|
+
const created = this._createInvitations.get(invitationId);
|
|
2838
|
+
if (created) {
|
|
2839
|
+
if (created.get().persistent) {
|
|
2840
|
+
await this._metadataStore.removeInvitation(invitationId);
|
|
2841
|
+
}
|
|
2842
|
+
await created.cancel();
|
|
2843
|
+
this._createInvitations.delete(invitationId);
|
|
2844
|
+
this.removedCreated.emit(created.get());
|
|
2845
|
+
return;
|
|
2846
|
+
}
|
|
2847
|
+
const accepted = this._acceptInvitations.get(invitationId);
|
|
2848
|
+
if (accepted) {
|
|
2849
|
+
await accepted.cancel();
|
|
2850
|
+
this._acceptInvitations.delete(invitationId);
|
|
2851
|
+
this.removedAccepted.emit(accepted.get());
|
|
2852
|
+
}
|
|
2853
|
+
}
|
|
2854
|
+
getCreatedInvitations() {
|
|
2855
|
+
return [
|
|
2856
|
+
...this._createInvitations.values()
|
|
2857
|
+
].map((i) => i.get());
|
|
2858
|
+
}
|
|
2859
|
+
getAcceptedInvitations() {
|
|
2860
|
+
return [
|
|
2861
|
+
...this._acceptInvitations.values()
|
|
2862
|
+
].map((i) => i.get());
|
|
2863
|
+
}
|
|
2864
|
+
onPersistentInvitationsLoaded(ctx, callback) {
|
|
2865
|
+
if (this._persistentInvitationsLoaded) {
|
|
2866
|
+
callback();
|
|
2867
|
+
} else {
|
|
2868
|
+
this._persistentInvitationsLoadedEvent.once(ctx, () => callback());
|
|
2869
|
+
}
|
|
2870
|
+
}
|
|
2871
|
+
_safePersistInBackground(invitation) {
|
|
2872
|
+
return new Promise((resolve) => {
|
|
2873
|
+
setTimeout(async () => {
|
|
2874
|
+
try {
|
|
2875
|
+
await this._metadataStore.addInvitation(invitation.get());
|
|
2876
|
+
this.saved.emit(invitation.get());
|
|
2877
|
+
} catch (err) {
|
|
2878
|
+
import_log7.log.catch(err, void 0, {
|
|
2879
|
+
F: __dxlog_file9,
|
|
2880
|
+
L: 173,
|
|
2881
|
+
S: this,
|
|
2882
|
+
C: (f, a) => f(...a)
|
|
2883
|
+
});
|
|
2884
|
+
await invitation.cancel();
|
|
2885
|
+
} finally {
|
|
2886
|
+
resolve();
|
|
2887
|
+
}
|
|
2888
|
+
});
|
|
2889
|
+
});
|
|
2890
|
+
}
|
|
2891
|
+
async _safeDeleteInvitation(invitation) {
|
|
2892
|
+
try {
|
|
2893
|
+
await this._metadataStore.removeInvitation(invitation.invitationId);
|
|
2894
|
+
} catch (err) {
|
|
2895
|
+
import_log7.log.catch(err, void 0, {
|
|
2896
|
+
F: __dxlog_file9,
|
|
2897
|
+
L: 186,
|
|
2898
|
+
S: this,
|
|
2899
|
+
C: (f, a) => f(...a)
|
|
2900
|
+
});
|
|
2901
|
+
}
|
|
2902
|
+
}
|
|
2903
|
+
_onInvitationComplete(invitation, callback) {
|
|
2904
|
+
invitation.subscribe(() => {
|
|
2905
|
+
}, () => {
|
|
2906
|
+
}, callback);
|
|
2907
|
+
}
|
|
2908
|
+
};
|
|
2861
2909
|
function _ts_decorate3(decorators, target, key, desc) {
|
|
2862
2910
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2863
2911
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
@@ -2974,7 +3022,7 @@ var DEFAULT_NOTARIZE_TIMEOUT = 1e4;
|
|
|
2974
3022
|
var WRITER_NOT_SET_ERROR_CODE = "WRITER_NOT_SET";
|
|
2975
3023
|
var NotarizationPlugin = class {
|
|
2976
3024
|
constructor() {
|
|
2977
|
-
this._ctx = new
|
|
3025
|
+
this._ctx = new import_context7.Context();
|
|
2978
3026
|
this._extensionOpened = new import_async12.Event();
|
|
2979
3027
|
this._extensions = /* @__PURE__ */ new Set();
|
|
2980
3028
|
this._processedCredentials = new import_util5.ComplexSet(import_keys8.PublicKey.hash);
|
|
@@ -3099,7 +3147,7 @@ var NotarizationPlugin = class {
|
|
|
3099
3147
|
this._extensionOpened.on(ctx, () => notarizeTask.schedule());
|
|
3100
3148
|
try {
|
|
3101
3149
|
await Promise.race([
|
|
3102
|
-
(0,
|
|
3150
|
+
(0, import_context7.rejectOnDispose)(ctx),
|
|
3103
3151
|
allNotarized,
|
|
3104
3152
|
errors.wait()
|
|
3105
3153
|
]);
|
|
@@ -3238,7 +3286,7 @@ function _ts_decorate4(decorators, target, key, desc) {
|
|
|
3238
3286
|
var __dxlog_file11 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space.ts";
|
|
3239
3287
|
var DataSpace = class {
|
|
3240
3288
|
constructor(params) {
|
|
3241
|
-
this._ctx = new
|
|
3289
|
+
this._ctx = new import_context6.Context();
|
|
3242
3290
|
this._notarizationPlugin = new NotarizationPlugin();
|
|
3243
3291
|
this._cache = void 0;
|
|
3244
3292
|
this._automergeSpaceState = new AutomergeSpaceState((rootUrl) => this._onNewAutomergeRoot(rootUrl));
|
|
@@ -3311,7 +3359,7 @@ var DataSpace = class {
|
|
|
3311
3359
|
await this._notarizationPlugin.open();
|
|
3312
3360
|
await this._inner.spaceState.addCredentialProcessor(this._notarizationPlugin);
|
|
3313
3361
|
await this._inner.spaceState.addCredentialProcessor(this._automergeSpaceState);
|
|
3314
|
-
await this._inner.open(new
|
|
3362
|
+
await this._inner.open(new import_context6.Context());
|
|
3315
3363
|
this._state = import_services7.SpaceState.CONTROL_ONLY;
|
|
3316
3364
|
(0, import_log8.log)("new state", {
|
|
3317
3365
|
state: import_services7.SpaceState[this._state]
|
|
@@ -3340,7 +3388,7 @@ var DataSpace = class {
|
|
|
3340
3388
|
C: (f, a) => f(...a)
|
|
3341
3389
|
});
|
|
3342
3390
|
await this._ctx.dispose();
|
|
3343
|
-
this._ctx = new
|
|
3391
|
+
this._ctx = new import_context6.Context();
|
|
3344
3392
|
await this.authVerifier.close();
|
|
3345
3393
|
await this._inner.close();
|
|
3346
3394
|
await this._inner.spaceState.removeCredentialProcessor(this._automergeSpaceState);
|
|
@@ -3364,7 +3412,7 @@ var DataSpace = class {
|
|
|
3364
3412
|
this.metrics.pipelineInitBegin = /* @__PURE__ */ new Date();
|
|
3365
3413
|
await this.initializeDataPipeline();
|
|
3366
3414
|
} catch (err) {
|
|
3367
|
-
if (err instanceof import_protocols7.CancelledError || err instanceof
|
|
3415
|
+
if (err instanceof import_protocols7.CancelledError || err instanceof import_context6.ContextDisposedError) {
|
|
3368
3416
|
(0, import_log8.log)("data pipeline initialization cancelled", err, {
|
|
3369
3417
|
F: __dxlog_file11,
|
|
3370
3418
|
L: 245,
|
|
@@ -3411,7 +3459,7 @@ var DataSpace = class {
|
|
|
3411
3459
|
await this._initializeAndReadControlPipeline();
|
|
3412
3460
|
await (0, import_async10.sleep)(1);
|
|
3413
3461
|
this._automergeSpaceState.startProcessingRootDocs();
|
|
3414
|
-
await (0,
|
|
3462
|
+
await (0, import_context6.cancelWithContext)(this._ctx, this.automergeSpaceState.ensureEpochInitialized());
|
|
3415
3463
|
(0, import_log8.log)("data pipeline ready", void 0, {
|
|
3416
3464
|
F: __dxlog_file11,
|
|
3417
3465
|
L: 279,
|
|
@@ -3512,7 +3560,7 @@ var DataSpace = class {
|
|
|
3512
3560
|
queueMicrotask(async () => {
|
|
3513
3561
|
try {
|
|
3514
3562
|
await (0, import_debug3.warnAfterTimeout)(5e3, "Automerge root doc load timeout (DataSpace)", async () => {
|
|
3515
|
-
await (0,
|
|
3563
|
+
await (0, import_context6.cancelWithContext)(this._ctx, handle.whenReady());
|
|
3516
3564
|
});
|
|
3517
3565
|
if (this._ctx.disposed) {
|
|
3518
3566
|
return;
|
|
@@ -3526,7 +3574,7 @@ var DataSpace = class {
|
|
|
3526
3574
|
});
|
|
3527
3575
|
}
|
|
3528
3576
|
} catch (err) {
|
|
3529
|
-
if (err instanceof
|
|
3577
|
+
if (err instanceof import_context6.ContextDisposedError) {
|
|
3530
3578
|
return;
|
|
3531
3579
|
}
|
|
3532
3580
|
import_log8.log.warn("error loading automerge root doc", {
|
|
@@ -3586,7 +3634,7 @@ var DataSpace = class {
|
|
|
3586
3634
|
{
|
|
3587
3635
|
const currentRootUrl = this._automergeSpaceState.rootUrl;
|
|
3588
3636
|
const rootHandle = this._automergeHost.repo.find(currentRootUrl);
|
|
3589
|
-
await (0,
|
|
3637
|
+
await (0, import_context6.cancelWithContext)(this._ctx, (0, import_async10.asyncTimeout)(rootHandle.whenReady(), 1e4));
|
|
3590
3638
|
const newRoot = this._automergeHost.repo.create(rootHandle.docSync());
|
|
3591
3639
|
(0, import_invariant9.invariant)(typeof newRoot.url === "string" && newRoot.url.length > 0, void 0, {
|
|
3592
3640
|
F: __dxlog_file11,
|
|
@@ -3615,9 +3663,9 @@ var DataSpace = class {
|
|
|
3615
3663
|
});
|
|
3616
3664
|
const currentRootUrl = this._automergeSpaceState.rootUrl;
|
|
3617
3665
|
const rootHandle = this._automergeHost.repo.find(currentRootUrl);
|
|
3618
|
-
await (0,
|
|
3666
|
+
await (0, import_context6.cancelWithContext)(this._ctx, (0, import_async10.asyncTimeout)(rootHandle.whenReady(), 1e4));
|
|
3619
3667
|
const objects = Object.entries(rootHandle.docSync().objects);
|
|
3620
|
-
const properties = objects.find(([_, value]) => value.system.type?.itemId ===
|
|
3668
|
+
const properties = objects.find(([_, value]) => value.system.type?.itemId === import_echo_schema.TYPE_PROPERTIES);
|
|
3621
3669
|
const otherObjects = objects.filter(([key]) => key !== properties?.[0]);
|
|
3622
3670
|
(0, import_invariant9.invariant)(properties, "Properties not found", {
|
|
3623
3671
|
F: __dxlog_file11,
|
|
@@ -3843,7 +3891,7 @@ var DataSpaceManager = class {
|
|
|
3843
3891
|
this._signingContext = _signingContext;
|
|
3844
3892
|
this._feedStore = _feedStore;
|
|
3845
3893
|
this._automergeHost = _automergeHost;
|
|
3846
|
-
this._ctx = new
|
|
3894
|
+
this._ctx = new import_context8.Context();
|
|
3847
3895
|
this.updated = new import_async13.Event();
|
|
3848
3896
|
this._spaces = new import_util6.ComplexMap(import_keys9.PublicKey.hash);
|
|
3849
3897
|
this._isOpen = false;
|
|
@@ -4032,7 +4080,7 @@ var DataSpaceManager = class {
|
|
|
4032
4080
|
* TODO(dmaretskyi): Consider removing.
|
|
4033
4081
|
*/
|
|
4034
4082
|
async waitUntilSpaceReady(spaceKey) {
|
|
4035
|
-
await (0,
|
|
4083
|
+
await (0, import_context8.cancelWithContext)(this._ctx, this.updated.waitForCondition(() => {
|
|
4036
4084
|
const space = this._spaces.get(spaceKey);
|
|
4037
4085
|
return !!space && space.state === import_services8.SpaceState.READY;
|
|
4038
4086
|
}));
|
|
@@ -4379,8 +4427,10 @@ var createSelectedDocumentsIterator = (automergeHost) => (
|
|
|
4379
4427
|
async function* loadDocuments(ids) {
|
|
4380
4428
|
for (const id of ids) {
|
|
4381
4429
|
const { documentId, objectId } = import_protocols12.idCodec.decode(id);
|
|
4382
|
-
const handle = automergeHost.repo.find(documentId);
|
|
4383
|
-
|
|
4430
|
+
const handle = automergeHost.repo.handles[documentId] ?? automergeHost.repo.find(documentId);
|
|
4431
|
+
if (!handle.isReady()) {
|
|
4432
|
+
await handle.whenReady();
|
|
4433
|
+
}
|
|
4384
4434
|
const doc = handle.docSync();
|
|
4385
4435
|
const hash = (0, import_automerge.getHeads)(doc).join("");
|
|
4386
4436
|
yield doc.objects?.[objectId] ? [
|
|
@@ -4405,7 +4455,9 @@ var createDocumentsIterator = (automergeHost) => (
|
|
|
4405
4455
|
if (visited.has(handle.documentId)) {
|
|
4406
4456
|
return;
|
|
4407
4457
|
}
|
|
4408
|
-
|
|
4458
|
+
if (!handle.isReady()) {
|
|
4459
|
+
await handle.whenReady();
|
|
4460
|
+
}
|
|
4409
4461
|
const doc = handle.docSync();
|
|
4410
4462
|
const heads = (0, import_automerge.getHeads)(doc);
|
|
4411
4463
|
if (doc.objects) {
|
|
@@ -4425,7 +4477,7 @@ var createDocumentsIterator = (automergeHost) => (
|
|
|
4425
4477
|
if (visited.has(id)) {
|
|
4426
4478
|
continue;
|
|
4427
4479
|
}
|
|
4428
|
-
const linkHandle = automergeHost.repo.find(id);
|
|
4480
|
+
const linkHandle = automergeHost.repo.handles[id] ?? automergeHost.repo.find(id);
|
|
4429
4481
|
for await (const result of getObjectsFromHandle(linkHandle)) {
|
|
4430
4482
|
yield result;
|
|
4431
4483
|
}
|
|
@@ -4455,7 +4507,7 @@ function _ts_decorate6(decorators, target, key, desc) {
|
|
|
4455
4507
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4456
4508
|
}
|
|
4457
4509
|
var __dxlog_file14 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-context.ts";
|
|
4458
|
-
var ServiceContext = class extends
|
|
4510
|
+
var ServiceContext = class extends import_context9.Resource {
|
|
4459
4511
|
constructor(storage, level, networkManager, signalManager, _runtimeParams) {
|
|
4460
4512
|
super();
|
|
4461
4513
|
this.storage = storage;
|
|
@@ -4494,24 +4546,28 @@ var ServiceContext = class extends import_context10.Resource {
|
|
|
4494
4546
|
this.automergeHost = new import_echo_pipeline4.AutomergeHost({
|
|
4495
4547
|
directory: storage.createDirectory("automerge"),
|
|
4496
4548
|
db: level.sublevel("automerge"),
|
|
4497
|
-
|
|
4549
|
+
storageCallbacks: (0, import_indexing.createStorageCallbacks)({
|
|
4550
|
+
host: () => this.automergeHost,
|
|
4551
|
+
metadata: this.indexMetadata
|
|
4552
|
+
})
|
|
4498
4553
|
});
|
|
4499
4554
|
this.indexer = new import_indexing.Indexer({
|
|
4500
4555
|
indexStore: new import_indexing.IndexStore({
|
|
4501
|
-
|
|
4556
|
+
db: level.sublevel("index-storage")
|
|
4502
4557
|
}),
|
|
4503
4558
|
metadataStore: this.indexMetadata,
|
|
4504
4559
|
loadDocuments: createSelectedDocumentsIterator(this.automergeHost),
|
|
4505
4560
|
getAllDocuments: createDocumentsIterator(this.automergeHost)
|
|
4506
4561
|
});
|
|
4507
4562
|
this.invitations = new InvitationsHandler(this.networkManager);
|
|
4563
|
+
this.invitationsManager = new InvitationsManager(this.invitations, (invitation) => this.getInvitationHandler(invitation), this.metadataStore);
|
|
4508
4564
|
this._handlerFactories.set(import_services10.Invitation.Kind.DEVICE, () => new DeviceInvitationProtocol(this.keyring, () => this.identityManager.identity ?? (0, import_debug6.failUndefined)(), this._acceptIdentity.bind(this)));
|
|
4509
4565
|
}
|
|
4510
4566
|
async _open(ctx) {
|
|
4511
4567
|
await this._checkStorageVersion();
|
|
4512
4568
|
(0, import_log12.log)("opening...", void 0, {
|
|
4513
4569
|
F: __dxlog_file14,
|
|
4514
|
-
L:
|
|
4570
|
+
L: 164,
|
|
4515
4571
|
S: this,
|
|
4516
4572
|
C: (f, a) => f(...a)
|
|
4517
4573
|
});
|
|
@@ -4519,7 +4575,7 @@ var ServiceContext = class extends import_context10.Resource {
|
|
|
4519
4575
|
id: this._instanceId
|
|
4520
4576
|
}), {
|
|
4521
4577
|
F: __dxlog_file14,
|
|
4522
|
-
L:
|
|
4578
|
+
L: 165,
|
|
4523
4579
|
S: this,
|
|
4524
4580
|
C: (f, a) => f(...a)
|
|
4525
4581
|
});
|
|
@@ -4532,17 +4588,26 @@ var ServiceContext = class extends import_context10.Resource {
|
|
|
4532
4588
|
if (this.identityManager.identity) {
|
|
4533
4589
|
await this._initialize(ctx);
|
|
4534
4590
|
}
|
|
4591
|
+
const loadedInvitations = await this.invitationsManager.loadPersistentInvitations();
|
|
4592
|
+
(0, import_log12.log)("loaded persistent invitations", {
|
|
4593
|
+
count: loadedInvitations.invitations?.length
|
|
4594
|
+
}, {
|
|
4595
|
+
F: __dxlog_file14,
|
|
4596
|
+
L: 178,
|
|
4597
|
+
S: this,
|
|
4598
|
+
C: (f, a) => f(...a)
|
|
4599
|
+
});
|
|
4535
4600
|
import_log12.log.trace("dxos.sdk.service-context.open", import_protocols11.trace.end({
|
|
4536
4601
|
id: this._instanceId
|
|
4537
4602
|
}), {
|
|
4538
4603
|
F: __dxlog_file14,
|
|
4539
|
-
L:
|
|
4604
|
+
L: 180,
|
|
4540
4605
|
S: this,
|
|
4541
4606
|
C: (f, a) => f(...a)
|
|
4542
4607
|
});
|
|
4543
4608
|
(0, import_log12.log)("opened", void 0, {
|
|
4544
4609
|
F: __dxlog_file14,
|
|
4545
|
-
L:
|
|
4610
|
+
L: 181,
|
|
4546
4611
|
S: this,
|
|
4547
4612
|
C: (f, a) => f(...a)
|
|
4548
4613
|
});
|
|
@@ -4550,7 +4615,7 @@ var ServiceContext = class extends import_context10.Resource {
|
|
|
4550
4615
|
async _close() {
|
|
4551
4616
|
(0, import_log12.log)("closing...", void 0, {
|
|
4552
4617
|
F: __dxlog_file14,
|
|
4553
|
-
L:
|
|
4618
|
+
L: 185,
|
|
4554
4619
|
S: this,
|
|
4555
4620
|
C: (f, a) => f(...a)
|
|
4556
4621
|
});
|
|
@@ -4568,21 +4633,21 @@ var ServiceContext = class extends import_context10.Resource {
|
|
|
4568
4633
|
await this.indexer.destroy();
|
|
4569
4634
|
(0, import_log12.log)("closed", void 0, {
|
|
4570
4635
|
F: __dxlog_file14,
|
|
4571
|
-
L:
|
|
4636
|
+
L: 198,
|
|
4572
4637
|
S: this,
|
|
4573
4638
|
C: (f, a) => f(...a)
|
|
4574
4639
|
});
|
|
4575
4640
|
}
|
|
4576
4641
|
async createIdentity(params = {}) {
|
|
4577
4642
|
const identity = await this.identityManager.createIdentity(params);
|
|
4578
|
-
await this._initialize(new
|
|
4643
|
+
await this._initialize(new import_context9.Context());
|
|
4579
4644
|
return identity;
|
|
4580
4645
|
}
|
|
4581
4646
|
getInvitationHandler(invitation) {
|
|
4582
4647
|
const factory = this._handlerFactories.get(invitation.kind);
|
|
4583
4648
|
(0, import_invariant13.invariant)(factory, `Unknown invitation kind: ${invitation.kind}`, {
|
|
4584
4649
|
F: __dxlog_file14,
|
|
4585
|
-
L:
|
|
4650
|
+
L: 209,
|
|
4586
4651
|
S: this,
|
|
4587
4652
|
A: [
|
|
4588
4653
|
"factory",
|
|
@@ -4601,7 +4666,7 @@ var ServiceContext = class extends import_context10.Resource {
|
|
|
4601
4666
|
}
|
|
4602
4667
|
async _acceptIdentity(params) {
|
|
4603
4668
|
const identity = await this.identityManager.acceptIdentity(params);
|
|
4604
|
-
await this._initialize(new
|
|
4669
|
+
await this._initialize(new import_context9.Context());
|
|
4605
4670
|
return identity;
|
|
4606
4671
|
}
|
|
4607
4672
|
async _checkStorageVersion() {
|
|
@@ -4614,7 +4679,7 @@ var ServiceContext = class extends import_context10.Resource {
|
|
|
4614
4679
|
async _initialize(ctx) {
|
|
4615
4680
|
(0, import_log12.log)("initializing spaces...", void 0, {
|
|
4616
4681
|
F: __dxlog_file14,
|
|
4617
|
-
L:
|
|
4682
|
+
L: 240,
|
|
4618
4683
|
S: this,
|
|
4619
4684
|
C: (f, a) => f(...a)
|
|
4620
4685
|
});
|
|
@@ -4637,7 +4702,7 @@ var ServiceContext = class extends import_context10.Resource {
|
|
|
4637
4702
|
this._handlerFactories.set(import_services10.Invitation.Kind.SPACE, (invitation) => {
|
|
4638
4703
|
(0, import_invariant13.invariant)(this.dataSpaceManager, "dataSpaceManager not initialized yet", {
|
|
4639
4704
|
F: __dxlog_file14,
|
|
4640
|
-
L:
|
|
4705
|
+
L: 264,
|
|
4641
4706
|
S: this,
|
|
4642
4707
|
A: [
|
|
4643
4708
|
"this.dataSpaceManager",
|
|
@@ -4661,7 +4726,7 @@ var ServiceContext = class extends import_context10.Resource {
|
|
|
4661
4726
|
details: assertion
|
|
4662
4727
|
}, {
|
|
4663
4728
|
F: __dxlog_file14,
|
|
4664
|
-
L:
|
|
4729
|
+
L: 280,
|
|
4665
4730
|
S: this,
|
|
4666
4731
|
C: (f, a) => f(...a)
|
|
4667
4732
|
});
|
|
@@ -4672,7 +4737,7 @@ var ServiceContext = class extends import_context10.Resource {
|
|
|
4672
4737
|
details: assertion
|
|
4673
4738
|
}, {
|
|
4674
4739
|
F: __dxlog_file14,
|
|
4675
|
-
L:
|
|
4740
|
+
L: 284,
|
|
4676
4741
|
S: this,
|
|
4677
4742
|
C: (f, a) => f(...a)
|
|
4678
4743
|
});
|
|
@@ -4683,7 +4748,7 @@ var ServiceContext = class extends import_context10.Resource {
|
|
|
4683
4748
|
details: assertion
|
|
4684
4749
|
}, {
|
|
4685
4750
|
F: __dxlog_file14,
|
|
4686
|
-
L:
|
|
4751
|
+
L: 289,
|
|
4687
4752
|
S: this,
|
|
4688
4753
|
C: (f, a) => f(...a)
|
|
4689
4754
|
});
|
|
@@ -4694,7 +4759,7 @@ var ServiceContext = class extends import_context10.Resource {
|
|
|
4694
4759
|
} catch (err) {
|
|
4695
4760
|
import_log12.log.catch(err, void 0, {
|
|
4696
4761
|
F: __dxlog_file14,
|
|
4697
|
-
L:
|
|
4762
|
+
L: 295,
|
|
4698
4763
|
S: this,
|
|
4699
4764
|
C: (f, a) => f(...a)
|
|
4700
4765
|
});
|
|
@@ -4736,7 +4801,7 @@ var ServiceRegistry = class {
|
|
|
4736
4801
|
delete this._handlers[name];
|
|
4737
4802
|
}
|
|
4738
4803
|
};
|
|
4739
|
-
var DXOS_VERSION = "0.4.10-main.
|
|
4804
|
+
var DXOS_VERSION = "0.4.10-main.c16d37b";
|
|
4740
4805
|
var getPlatform = () => {
|
|
4741
4806
|
if (process.browser) {
|
|
4742
4807
|
if (typeof window !== "undefined") {
|
|
@@ -5312,7 +5377,7 @@ var ClientServicesHost = class {
|
|
|
5312
5377
|
lockKey,
|
|
5313
5378
|
onAcquire: () => {
|
|
5314
5379
|
if (!this._opening) {
|
|
5315
|
-
void this.open(new
|
|
5380
|
+
void this.open(new import_context10.Context());
|
|
5316
5381
|
}
|
|
5317
5382
|
},
|
|
5318
5383
|
onRelease: () => this.close()
|
|
@@ -5369,7 +5434,7 @@ var ClientServicesHost = class {
|
|
|
5369
5434
|
initialize({ config, ...options }) {
|
|
5370
5435
|
(0, import_invariant15.invariant)(!this._open, "service host is open", {
|
|
5371
5436
|
F: __dxlog_file18,
|
|
5372
|
-
L:
|
|
5437
|
+
L: 198,
|
|
5373
5438
|
S: this,
|
|
5374
5439
|
A: [
|
|
5375
5440
|
"!this._open",
|
|
@@ -5378,14 +5443,14 @@ var ClientServicesHost = class {
|
|
|
5378
5443
|
});
|
|
5379
5444
|
(0, import_log13.log)("initializing...", void 0, {
|
|
5380
5445
|
F: __dxlog_file18,
|
|
5381
|
-
L:
|
|
5446
|
+
L: 199,
|
|
5382
5447
|
S: this,
|
|
5383
5448
|
C: (f, a) => f(...a)
|
|
5384
5449
|
});
|
|
5385
5450
|
if (config) {
|
|
5386
5451
|
(0, import_invariant15.invariant)(!this._config, "config already set", {
|
|
5387
5452
|
F: __dxlog_file18,
|
|
5388
|
-
L:
|
|
5453
|
+
L: 202,
|
|
5389
5454
|
S: this,
|
|
5390
5455
|
A: [
|
|
5391
5456
|
"!this._config",
|
|
@@ -5400,7 +5465,7 @@ var ClientServicesHost = class {
|
|
|
5400
5465
|
if (!options.signalManager) {
|
|
5401
5466
|
import_log13.log.warn("running signaling without telemetry metadata.", void 0, {
|
|
5402
5467
|
F: __dxlog_file18,
|
|
5403
|
-
L:
|
|
5468
|
+
L: 210,
|
|
5404
5469
|
S: this,
|
|
5405
5470
|
C: (f, a) => f(...a)
|
|
5406
5471
|
});
|
|
@@ -5411,7 +5476,7 @@ var ClientServicesHost = class {
|
|
|
5411
5476
|
this._signalManager = signalManager;
|
|
5412
5477
|
(0, import_invariant15.invariant)(!this._networkManager, "network manager already set", {
|
|
5413
5478
|
F: __dxlog_file18,
|
|
5414
|
-
L:
|
|
5479
|
+
L: 221,
|
|
5415
5480
|
S: this,
|
|
5416
5481
|
A: [
|
|
5417
5482
|
"!this._networkManager",
|
|
@@ -5425,7 +5490,7 @@ var ClientServicesHost = class {
|
|
|
5425
5490
|
});
|
|
5426
5491
|
(0, import_log13.log)("initialized", void 0, {
|
|
5427
5492
|
F: __dxlog_file18,
|
|
5428
|
-
L:
|
|
5493
|
+
L: 228,
|
|
5429
5494
|
S: this,
|
|
5430
5495
|
C: (f, a) => f(...a)
|
|
5431
5496
|
});
|
|
@@ -5439,13 +5504,13 @@ var ClientServicesHost = class {
|
|
|
5439
5504
|
id: traceId
|
|
5440
5505
|
}), {
|
|
5441
5506
|
F: __dxlog_file18,
|
|
5442
|
-
L:
|
|
5507
|
+
L: 239,
|
|
5443
5508
|
S: this,
|
|
5444
5509
|
C: (f, a) => f(...a)
|
|
5445
5510
|
});
|
|
5446
5511
|
(0, import_invariant15.invariant)(this._config, "config not set", {
|
|
5447
5512
|
F: __dxlog_file18,
|
|
5448
|
-
L:
|
|
5513
|
+
L: 241,
|
|
5449
5514
|
S: this,
|
|
5450
5515
|
A: [
|
|
5451
5516
|
"this._config",
|
|
@@ -5454,7 +5519,7 @@ var ClientServicesHost = class {
|
|
|
5454
5519
|
});
|
|
5455
5520
|
(0, import_invariant15.invariant)(this._storage, "storage not set", {
|
|
5456
5521
|
F: __dxlog_file18,
|
|
5457
|
-
L:
|
|
5522
|
+
L: 242,
|
|
5458
5523
|
S: this,
|
|
5459
5524
|
A: [
|
|
5460
5525
|
"this._storage",
|
|
@@ -5463,7 +5528,7 @@ var ClientServicesHost = class {
|
|
|
5463
5528
|
});
|
|
5464
5529
|
(0, import_invariant15.invariant)(this._signalManager, "signal manager not set", {
|
|
5465
5530
|
F: __dxlog_file18,
|
|
5466
|
-
L:
|
|
5531
|
+
L: 243,
|
|
5467
5532
|
S: this,
|
|
5468
5533
|
A: [
|
|
5469
5534
|
"this._signalManager",
|
|
@@ -5472,7 +5537,7 @@ var ClientServicesHost = class {
|
|
|
5472
5537
|
});
|
|
5473
5538
|
(0, import_invariant15.invariant)(this._networkManager, "network manager not set", {
|
|
5474
5539
|
F: __dxlog_file18,
|
|
5475
|
-
L:
|
|
5540
|
+
L: 244,
|
|
5476
5541
|
S: this,
|
|
5477
5542
|
A: [
|
|
5478
5543
|
"this._networkManager",
|
|
@@ -5484,7 +5549,7 @@ var ClientServicesHost = class {
|
|
|
5484
5549
|
lockKey: this._resourceLock?.lockKey
|
|
5485
5550
|
}, {
|
|
5486
5551
|
F: __dxlog_file18,
|
|
5487
|
-
L:
|
|
5552
|
+
L: 247,
|
|
5488
5553
|
S: this,
|
|
5489
5554
|
C: (f, a) => f(...a)
|
|
5490
5555
|
});
|
|
@@ -5495,20 +5560,22 @@ var ClientServicesHost = class {
|
|
|
5495
5560
|
await this._resourceLock?.acquire();
|
|
5496
5561
|
await this._loggingService.open();
|
|
5497
5562
|
this._serviceContext = new ServiceContext(this._storage, this._level, this._networkManager, this._signalManager, this._runtimeParams);
|
|
5563
|
+
this._queryService = new import_indexing2.QueryServiceImpl({
|
|
5564
|
+
indexer: this._serviceContext.indexer,
|
|
5565
|
+
automergeHost: this._serviceContext.automergeHost
|
|
5566
|
+
});
|
|
5567
|
+
await this._queryService.open(ctx);
|
|
5498
5568
|
this._serviceRegistry.setServices({
|
|
5499
5569
|
SystemService: this._systemService,
|
|
5500
5570
|
IdentityService: new IdentityServiceImpl((params) => this._createIdentity(params), this._serviceContext.identityManager, this._serviceContext.keyring, (profile) => this._serviceContext.broadcastProfileUpdate(profile)),
|
|
5501
|
-
InvitationsService: new InvitationsServiceImpl(this._serviceContext.
|
|
5571
|
+
InvitationsService: new InvitationsServiceImpl(this._serviceContext.invitationsManager),
|
|
5502
5572
|
DevicesService: new DevicesServiceImpl(this._serviceContext.identityManager),
|
|
5503
5573
|
SpacesService: new SpacesServiceImpl(this._serviceContext.identityManager, this._serviceContext.spaceManager, async () => {
|
|
5504
5574
|
await this._serviceContext.initialized.wait();
|
|
5505
5575
|
return this._serviceContext.dataSpaceManager;
|
|
5506
5576
|
}),
|
|
5507
5577
|
DataService: new import_echo_pipeline5.DataServiceImpl(this._serviceContext.automergeHost),
|
|
5508
|
-
|
|
5509
|
-
indexer: this._serviceContext.indexer,
|
|
5510
|
-
automergeHost: this._serviceContext.automergeHost
|
|
5511
|
-
}),
|
|
5578
|
+
QueryService: this._queryService,
|
|
5512
5579
|
NetworkService: new NetworkServiceImpl(this._serviceContext.networkManager, this._serviceContext.signalManager),
|
|
5513
5580
|
LoggingService: this._loggingService,
|
|
5514
5581
|
TracingService: this._tracingService,
|
|
@@ -5520,24 +5587,6 @@ var ClientServicesHost = class {
|
|
|
5520
5587
|
})
|
|
5521
5588
|
});
|
|
5522
5589
|
await this._serviceContext.open(ctx);
|
|
5523
|
-
(0, import_invariant15.invariant)(this.serviceRegistry.services.InvitationsService, void 0, {
|
|
5524
|
-
F: __dxlog_file18,
|
|
5525
|
-
L: 314,
|
|
5526
|
-
S: this,
|
|
5527
|
-
A: [
|
|
5528
|
-
"this.serviceRegistry.services.InvitationsService",
|
|
5529
|
-
""
|
|
5530
|
-
]
|
|
5531
|
-
});
|
|
5532
|
-
const loadedInvitations = await this.serviceRegistry.services.InvitationsService.loadPersistentInvitations();
|
|
5533
|
-
(0, import_log13.log)("loaded persistent invitations", {
|
|
5534
|
-
count: loadedInvitations.invitations?.length
|
|
5535
|
-
}, {
|
|
5536
|
-
F: __dxlog_file18,
|
|
5537
|
-
L: 317,
|
|
5538
|
-
S: this,
|
|
5539
|
-
C: (f, a) => f(...a)
|
|
5540
|
-
});
|
|
5541
5590
|
const devtoolsProxy = this._config?.get("runtime.client.devtoolsProxy");
|
|
5542
5591
|
if (devtoolsProxy) {
|
|
5543
5592
|
this._devtoolsProxy = new import_websocket_rpc.WebsocketRpcClient({
|
|
@@ -5557,7 +5606,7 @@ var ClientServicesHost = class {
|
|
|
5557
5606
|
deviceKey
|
|
5558
5607
|
}, {
|
|
5559
5608
|
F: __dxlog_file18,
|
|
5560
|
-
L:
|
|
5609
|
+
L: 330,
|
|
5561
5610
|
S: this,
|
|
5562
5611
|
C: (f, a) => f(...a)
|
|
5563
5612
|
});
|
|
@@ -5565,7 +5614,7 @@ var ClientServicesHost = class {
|
|
|
5565
5614
|
id: traceId
|
|
5566
5615
|
}), {
|
|
5567
5616
|
F: __dxlog_file18,
|
|
5568
|
-
L:
|
|
5617
|
+
L: 331,
|
|
5569
5618
|
S: this,
|
|
5570
5619
|
C: (f, a) => f(...a)
|
|
5571
5620
|
});
|
|
@@ -5579,7 +5628,7 @@ var ClientServicesHost = class {
|
|
|
5579
5628
|
deviceKey
|
|
5580
5629
|
}, {
|
|
5581
5630
|
F: __dxlog_file18,
|
|
5582
|
-
L:
|
|
5631
|
+
L: 342,
|
|
5583
5632
|
S: this,
|
|
5584
5633
|
C: (f, a) => f(...a)
|
|
5585
5634
|
});
|
|
@@ -5589,6 +5638,7 @@ var ClientServicesHost = class {
|
|
|
5589
5638
|
SystemService: this._systemService
|
|
5590
5639
|
});
|
|
5591
5640
|
await this._loggingService.close();
|
|
5641
|
+
await this._queryService.close();
|
|
5592
5642
|
await this._serviceContext.close();
|
|
5593
5643
|
await this._level?.close();
|
|
5594
5644
|
this._open = false;
|
|
@@ -5597,7 +5647,7 @@ var ClientServicesHost = class {
|
|
|
5597
5647
|
deviceKey
|
|
5598
5648
|
}, {
|
|
5599
5649
|
F: __dxlog_file18,
|
|
5600
|
-
L:
|
|
5650
|
+
L: 352,
|
|
5601
5651
|
S: this,
|
|
5602
5652
|
C: (f, a) => f(...a)
|
|
5603
5653
|
});
|
|
@@ -5608,13 +5658,13 @@ var ClientServicesHost = class {
|
|
|
5608
5658
|
id: traceId
|
|
5609
5659
|
}), {
|
|
5610
5660
|
F: __dxlog_file18,
|
|
5611
|
-
L:
|
|
5661
|
+
L: 357,
|
|
5612
5662
|
S: this,
|
|
5613
5663
|
C: (f, a) => f(...a)
|
|
5614
5664
|
});
|
|
5615
5665
|
(0, import_log13.log)("resetting...", void 0, {
|
|
5616
5666
|
F: __dxlog_file18,
|
|
5617
|
-
L:
|
|
5667
|
+
L: 359,
|
|
5618
5668
|
S: this,
|
|
5619
5669
|
C: (f, a) => f(...a)
|
|
5620
5670
|
});
|
|
@@ -5622,7 +5672,7 @@ var ClientServicesHost = class {
|
|
|
5622
5672
|
await this._storage.reset();
|
|
5623
5673
|
(0, import_log13.log)("reset", void 0, {
|
|
5624
5674
|
F: __dxlog_file18,
|
|
5625
|
-
L:
|
|
5675
|
+
L: 362,
|
|
5626
5676
|
S: this,
|
|
5627
5677
|
C: (f, a) => f(...a)
|
|
5628
5678
|
});
|
|
@@ -5630,7 +5680,7 @@ var ClientServicesHost = class {
|
|
|
5630
5680
|
id: traceId
|
|
5631
5681
|
}), {
|
|
5632
5682
|
F: __dxlog_file18,
|
|
5633
|
-
L:
|
|
5683
|
+
L: 363,
|
|
5634
5684
|
S: this,
|
|
5635
5685
|
C: (f, a) => f(...a)
|
|
5636
5686
|
});
|
|
@@ -5643,7 +5693,7 @@ var ClientServicesHost = class {
|
|
|
5643
5693
|
const automergeIndex = space.automergeSpaceState.rootUrl;
|
|
5644
5694
|
(0, import_invariant15.invariant)(automergeIndex, void 0, {
|
|
5645
5695
|
F: __dxlog_file18,
|
|
5646
|
-
L:
|
|
5696
|
+
L: 375,
|
|
5647
5697
|
S: this,
|
|
5648
5698
|
A: [
|
|
5649
5699
|
"automergeIndex",
|
|
@@ -5654,7 +5704,7 @@ var ClientServicesHost = class {
|
|
|
5654
5704
|
await document.whenReady();
|
|
5655
5705
|
const properties = {
|
|
5656
5706
|
system: {
|
|
5657
|
-
type: (0, import_echo_pipeline5.encodeReference)(
|
|
5707
|
+
type: (0, import_echo_pipeline5.encodeReference)((0, import_echo_schema2.getTypeReference)(import_client_protocol4.Properties))
|
|
5658
5708
|
},
|
|
5659
5709
|
data: {
|
|
5660
5710
|
[import_client_protocol4.defaultKey]: identity.identityKey.toHex()
|
|
@@ -5738,6 +5788,7 @@ var findConfigs = () => {
|
|
|
5738
5788
|
IdentityManager,
|
|
5739
5789
|
IdentityServiceImpl,
|
|
5740
5790
|
InvitationsHandler,
|
|
5791
|
+
InvitationsManager,
|
|
5741
5792
|
InvitationsServiceImpl,
|
|
5742
5793
|
Lock,
|
|
5743
5794
|
ServiceContext,
|
|
@@ -5762,4 +5813,4 @@ var findConfigs = () => {
|
|
|
5762
5813
|
subscribeToSpaces,
|
|
5763
5814
|
subscribeToSwarmInfo
|
|
5764
5815
|
});
|
|
5765
|
-
//# sourceMappingURL=chunk-
|
|
5816
|
+
//# sourceMappingURL=chunk-HI6XTPBD.cjs.map
|