@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
|
@@ -1853,7 +1853,7 @@ var InvitationsHandler = class {
|
|
|
1853
1853
|
});
|
|
1854
1854
|
return extension;
|
|
1855
1855
|
};
|
|
1856
|
-
if (invitation.lifetime && invitation.created
|
|
1856
|
+
if (invitation.lifetime && invitation.created) {
|
|
1857
1857
|
if (invitation.created.getTime() + invitation.lifetime * 1e3 < Date.now()) {
|
|
1858
1858
|
log5.warn("invitation has already expired", void 0, {
|
|
1859
1859
|
F: __dxlog_file7,
|
|
@@ -1918,7 +1918,7 @@ var InvitationsHandler = class {
|
|
|
1918
1918
|
if (deviceProfile) {
|
|
1919
1919
|
invariant6(invitation.kind === Invitation3.Kind.DEVICE, "deviceProfile provided for non-device invitation", {
|
|
1920
1920
|
F: __dxlog_file7,
|
|
1921
|
-
L:
|
|
1921
|
+
L: 255,
|
|
1922
1922
|
S: this,
|
|
1923
1923
|
A: [
|
|
1924
1924
|
"invitation.kind === Invitation.Kind.DEVICE",
|
|
@@ -1933,7 +1933,7 @@ var InvitationsHandler = class {
|
|
|
1933
1933
|
const setState = (newData) => {
|
|
1934
1934
|
invariant6(newData.state !== void 0, void 0, {
|
|
1935
1935
|
F: __dxlog_file7,
|
|
1936
|
-
L:
|
|
1936
|
+
L: 266,
|
|
1937
1937
|
S: this,
|
|
1938
1938
|
A: [
|
|
1939
1939
|
"newData.state !== undefined",
|
|
@@ -1953,7 +1953,7 @@ var InvitationsHandler = class {
|
|
|
1953
1953
|
...protocol.toJSON()
|
|
1954
1954
|
}, {
|
|
1955
1955
|
F: __dxlog_file7,
|
|
1956
|
-
L:
|
|
1956
|
+
L: 274,
|
|
1957
1957
|
S: this,
|
|
1958
1958
|
C: (f, a) => f(...a)
|
|
1959
1959
|
});
|
|
@@ -1963,7 +1963,7 @@ var InvitationsHandler = class {
|
|
|
1963
1963
|
} else {
|
|
1964
1964
|
log5.warn("auth failed", err, {
|
|
1965
1965
|
F: __dxlog_file7,
|
|
1966
|
-
L:
|
|
1966
|
+
L: 277,
|
|
1967
1967
|
S: this,
|
|
1968
1968
|
C: (f, a) => f(...a)
|
|
1969
1969
|
});
|
|
@@ -1977,7 +1977,7 @@ var InvitationsHandler = class {
|
|
|
1977
1977
|
...protocol.toJSON()
|
|
1978
1978
|
}, {
|
|
1979
1979
|
F: __dxlog_file7,
|
|
1980
|
-
L:
|
|
1980
|
+
L: 285,
|
|
1981
1981
|
S: this,
|
|
1982
1982
|
C: (f, a) => f(...a)
|
|
1983
1983
|
});
|
|
@@ -1992,7 +1992,7 @@ var InvitationsHandler = class {
|
|
|
1992
1992
|
currentState
|
|
1993
1993
|
}, {
|
|
1994
1994
|
F: __dxlog_file7,
|
|
1995
|
-
L:
|
|
1995
|
+
L: 295,
|
|
1996
1996
|
S: this,
|
|
1997
1997
|
C: (f, a) => f(...a)
|
|
1998
1998
|
});
|
|
@@ -2007,7 +2007,7 @@ var InvitationsHandler = class {
|
|
|
2007
2007
|
id: traceId
|
|
2008
2008
|
}), {
|
|
2009
2009
|
F: __dxlog_file7,
|
|
2010
|
-
L:
|
|
2010
|
+
L: 304,
|
|
2011
2011
|
S: this,
|
|
2012
2012
|
C: (f, a) => f(...a)
|
|
2013
2013
|
});
|
|
@@ -2019,7 +2019,7 @@ var InvitationsHandler = class {
|
|
|
2019
2019
|
...protocol.toJSON()
|
|
2020
2020
|
}, {
|
|
2021
2021
|
F: __dxlog_file7,
|
|
2022
|
-
L:
|
|
2022
|
+
L: 312,
|
|
2023
2023
|
S: this,
|
|
2024
2024
|
C: (f, a) => f(...a)
|
|
2025
2025
|
});
|
|
@@ -2030,7 +2030,7 @@ var InvitationsHandler = class {
|
|
|
2030
2030
|
...protocol.toJSON()
|
|
2031
2031
|
}, {
|
|
2032
2032
|
F: __dxlog_file7,
|
|
2033
|
-
L:
|
|
2033
|
+
L: 316,
|
|
2034
2034
|
S: this,
|
|
2035
2035
|
C: (f, a) => f(...a)
|
|
2036
2036
|
});
|
|
@@ -2040,7 +2040,7 @@ var InvitationsHandler = class {
|
|
|
2040
2040
|
response: introductionResponse
|
|
2041
2041
|
}, {
|
|
2042
2042
|
F: __dxlog_file7,
|
|
2043
|
-
L:
|
|
2043
|
+
L: 320,
|
|
2044
2044
|
S: this,
|
|
2045
2045
|
C: (f, a) => f(...a)
|
|
2046
2046
|
});
|
|
@@ -2061,7 +2061,7 @@ var InvitationsHandler = class {
|
|
|
2061
2061
|
...protocol.toJSON()
|
|
2062
2062
|
}, {
|
|
2063
2063
|
F: __dxlog_file7,
|
|
2064
|
-
L:
|
|
2064
|
+
L: 336,
|
|
2065
2065
|
S: this,
|
|
2066
2066
|
C: (f, a) => f(...a)
|
|
2067
2067
|
});
|
|
@@ -2073,7 +2073,7 @@ var InvitationsHandler = class {
|
|
|
2073
2073
|
...protocol.toJSON()
|
|
2074
2074
|
}, {
|
|
2075
2075
|
F: __dxlog_file7,
|
|
2076
|
-
L:
|
|
2076
|
+
L: 347,
|
|
2077
2077
|
S: this,
|
|
2078
2078
|
C: (f, a) => f(...a)
|
|
2079
2079
|
});
|
|
@@ -2086,7 +2086,7 @@ var InvitationsHandler = class {
|
|
|
2086
2086
|
id: traceId
|
|
2087
2087
|
}), {
|
|
2088
2088
|
F: __dxlog_file7,
|
|
2089
|
-
L:
|
|
2089
|
+
L: 349,
|
|
2090
2090
|
S: this,
|
|
2091
2091
|
C: (f, a) => f(...a)
|
|
2092
2092
|
});
|
|
@@ -2096,7 +2096,7 @@ var InvitationsHandler = class {
|
|
|
2096
2096
|
...protocol.toJSON()
|
|
2097
2097
|
}, {
|
|
2098
2098
|
F: __dxlog_file7,
|
|
2099
|
-
L:
|
|
2099
|
+
L: 352,
|
|
2100
2100
|
S: this,
|
|
2101
2101
|
C: (f, a) => f(...a)
|
|
2102
2102
|
});
|
|
@@ -2106,7 +2106,7 @@ var InvitationsHandler = class {
|
|
|
2106
2106
|
} else {
|
|
2107
2107
|
log5("auth failed", err, {
|
|
2108
2108
|
F: __dxlog_file7,
|
|
2109
|
-
L:
|
|
2109
|
+
L: 355,
|
|
2110
2110
|
S: this,
|
|
2111
2111
|
C: (f, a) => f(...a)
|
|
2112
2112
|
});
|
|
@@ -2117,7 +2117,7 @@ var InvitationsHandler = class {
|
|
|
2117
2117
|
error: err
|
|
2118
2118
|
}), {
|
|
2119
2119
|
F: __dxlog_file7,
|
|
2120
|
-
L:
|
|
2120
|
+
L: 358,
|
|
2121
2121
|
S: this,
|
|
2122
2122
|
C: (f, a) => f(...a)
|
|
2123
2123
|
});
|
|
@@ -2135,7 +2135,7 @@ var InvitationsHandler = class {
|
|
|
2135
2135
|
...protocol.toJSON()
|
|
2136
2136
|
}, {
|
|
2137
2137
|
F: __dxlog_file7,
|
|
2138
|
-
L:
|
|
2138
|
+
L: 369,
|
|
2139
2139
|
S: this,
|
|
2140
2140
|
C: (f, a) => f(...a)
|
|
2141
2141
|
});
|
|
@@ -2145,7 +2145,7 @@ var InvitationsHandler = class {
|
|
|
2145
2145
|
} else {
|
|
2146
2146
|
log5("auth failed", err, {
|
|
2147
2147
|
F: __dxlog_file7,
|
|
2148
|
-
L:
|
|
2148
|
+
L: 372,
|
|
2149
2149
|
S: this,
|
|
2150
2150
|
C: (f, a) => f(...a)
|
|
2151
2151
|
});
|
|
@@ -2162,7 +2162,7 @@ var InvitationsHandler = class {
|
|
|
2162
2162
|
} else {
|
|
2163
2163
|
invariant6(invitation.swarmKey, void 0, {
|
|
2164
2164
|
F: __dxlog_file7,
|
|
2165
|
-
L:
|
|
2165
|
+
L: 386,
|
|
2166
2166
|
S: this,
|
|
2167
2167
|
A: [
|
|
2168
2168
|
"invitation.swarmKey",
|
|
@@ -2204,7 +2204,7 @@ var InvitationsHandler = class {
|
|
|
2204
2204
|
for (let attempt = 1; attempt <= MAX_OTP_ATTEMPTS; attempt++) {
|
|
2205
2205
|
log5("guest waiting for authentication code...", void 0, {
|
|
2206
2206
|
F: __dxlog_file7,
|
|
2207
|
-
L:
|
|
2207
|
+
L: 426,
|
|
2208
2208
|
S: this,
|
|
2209
2209
|
C: (f, a) => f(...a)
|
|
2210
2210
|
});
|
|
@@ -2214,7 +2214,7 @@ var InvitationsHandler = class {
|
|
|
2214
2214
|
const authCode = await authenticated.wait(options);
|
|
2215
2215
|
log5("sending authentication request", void 0, {
|
|
2216
2216
|
F: __dxlog_file7,
|
|
2217
|
-
L:
|
|
2217
|
+
L: 430,
|
|
2218
2218
|
S: this,
|
|
2219
2219
|
C: (f, a) => f(...a)
|
|
2220
2220
|
});
|
|
@@ -2235,7 +2235,7 @@ var InvitationsHandler = class {
|
|
|
2235
2235
|
attempt
|
|
2236
2236
|
}, {
|
|
2237
2237
|
F: __dxlog_file7,
|
|
2238
|
-
L:
|
|
2238
|
+
L: 441,
|
|
2239
2239
|
S: this,
|
|
2240
2240
|
C: (f, a) => f(...a)
|
|
2241
2241
|
});
|
|
@@ -2253,7 +2253,7 @@ var InvitationsHandler = class {
|
|
|
2253
2253
|
}
|
|
2254
2254
|
log5("sending authentication request", void 0, {
|
|
2255
2255
|
F: __dxlog_file7,
|
|
2256
|
-
L:
|
|
2256
|
+
L: 460,
|
|
2257
2257
|
S: this,
|
|
2258
2258
|
C: (f, a) => f(...a)
|
|
2259
2259
|
});
|
|
@@ -2278,201 +2278,37 @@ var createAdmissionKeypair = () => {
|
|
|
2278
2278
|
};
|
|
2279
2279
|
|
|
2280
2280
|
// packages/sdk/client-services/src/packlets/invitations/invitations-service.ts
|
|
2281
|
-
import { Event as Event3, scheduleTask as scheduleTask3 } from "@dxos/async";
|
|
2282
2281
|
import { Stream as Stream8 } from "@dxos/codec-protobuf";
|
|
2283
|
-
import {
|
|
2284
|
-
import { hasInvitationExpired } from "@dxos/echo-pipeline";
|
|
2285
|
-
import { invariant as invariant7 } from "@dxos/invariant";
|
|
2286
|
-
import { log as log6 } from "@dxos/log";
|
|
2287
|
-
import { Invitation as Invitation4, QueryInvitationsResponse } from "@dxos/protocols/proto/dxos/client/services";
|
|
2288
|
-
var __dxlog_file8 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitations-service.ts";
|
|
2282
|
+
import { QueryInvitationsResponse } from "@dxos/protocols/proto/dxos/client/services";
|
|
2289
2283
|
var InvitationsServiceImpl = class {
|
|
2290
|
-
constructor(
|
|
2291
|
-
this.
|
|
2292
|
-
this._getHandler = _getHandler;
|
|
2293
|
-
this._metadataStore = _metadataStore;
|
|
2294
|
-
this._createInvitations = /* @__PURE__ */ new Map();
|
|
2295
|
-
this._acceptInvitations = /* @__PURE__ */ new Map();
|
|
2296
|
-
this._invitationCreated = new Event3();
|
|
2297
|
-
this._invitationAccepted = new Event3();
|
|
2298
|
-
this._removedCreated = new Event3();
|
|
2299
|
-
this._removedAccepted = new Event3();
|
|
2300
|
-
this._saved = new Event3();
|
|
2301
|
-
this._persistentInvitationsLoadedEvent = new Event3();
|
|
2302
|
-
this._persistentInvitationsLoaded = false;
|
|
2284
|
+
constructor(_invitationsManager) {
|
|
2285
|
+
this._invitationsManager = _invitationsManager;
|
|
2303
2286
|
}
|
|
2304
2287
|
// TODO(burdon): Guest/host label.
|
|
2305
2288
|
getLoggingContext() {
|
|
2306
2289
|
return {};
|
|
2307
2290
|
}
|
|
2308
2291
|
createInvitation(options) {
|
|
2309
|
-
|
|
2310
|
-
const savePersistentInvitationCtx = new Context6();
|
|
2311
|
-
const existingInvitation = this._createInvitations.get(options.invitationId);
|
|
2312
|
-
if (existingInvitation) {
|
|
2313
|
-
invitation = existingInvitation;
|
|
2314
|
-
} else {
|
|
2315
|
-
const handler = this._getHandler(options);
|
|
2316
|
-
invitation = this._invitationsHandler.createInvitation(handler, options);
|
|
2317
|
-
this._createInvitations.set(invitation.get().invitationId, invitation);
|
|
2318
|
-
this._invitationCreated.emit(invitation.get());
|
|
2319
|
-
}
|
|
2292
|
+
const invitation = this._invitationsManager.createInvitation(options);
|
|
2320
2293
|
return new Stream8(({ next, close }) => {
|
|
2321
|
-
|
|
2322
|
-
scheduleTask3(savePersistentInvitationCtx, async () => {
|
|
2323
|
-
try {
|
|
2324
|
-
await this._metadataStore.addInvitation(invitation.get());
|
|
2325
|
-
this._saved.emit(invitation.get());
|
|
2326
|
-
} catch (err) {
|
|
2327
|
-
close(err);
|
|
2328
|
-
}
|
|
2329
|
-
});
|
|
2330
|
-
}
|
|
2331
|
-
invitation.subscribe((invitation2) => {
|
|
2332
|
-
next(invitation2);
|
|
2333
|
-
}, async (err) => {
|
|
2334
|
-
await savePersistentInvitationCtx.dispose();
|
|
2335
|
-
close(err);
|
|
2336
|
-
}, async () => {
|
|
2337
|
-
close();
|
|
2338
|
-
if (invitation.get().persistent) {
|
|
2339
|
-
await savePersistentInvitationCtx.dispose();
|
|
2340
|
-
await this._metadataStore.removeInvitation(invitation.get().invitationId);
|
|
2341
|
-
}
|
|
2342
|
-
this._createInvitations.delete(invitation.get().invitationId);
|
|
2343
|
-
if (!invitation.get().multiUse) {
|
|
2344
|
-
this._removedCreated.emit(invitation.get());
|
|
2345
|
-
}
|
|
2346
|
-
});
|
|
2294
|
+
invitation.subscribe(next, close, close);
|
|
2347
2295
|
});
|
|
2348
2296
|
}
|
|
2349
|
-
|
|
2350
|
-
const
|
|
2351
|
-
const freshInvitations = persistentInvitations.filter(async (invitation) => !hasInvitationExpired(invitation));
|
|
2352
|
-
const cInvitations = freshInvitations.map((persistentInvitation) => {
|
|
2353
|
-
invariant7(!this._createInvitations.get(persistentInvitation.invitationId), "invitation already exists", {
|
|
2354
|
-
F: __dxlog_file8,
|
|
2355
|
-
L: 109,
|
|
2356
|
-
S: this,
|
|
2357
|
-
A: [
|
|
2358
|
-
"!this._createInvitations.get(persistentInvitation.invitationId)",
|
|
2359
|
-
"'invitation already exists'"
|
|
2360
|
-
]
|
|
2361
|
-
});
|
|
2362
|
-
const handler = this._getHandler(persistentInvitation);
|
|
2363
|
-
const invitation = this._invitationsHandler.createInvitation(handler, persistentInvitation);
|
|
2364
|
-
this._createInvitations.set(invitation.get().invitationId, invitation);
|
|
2365
|
-
this._invitationCreated.emit(invitation.get());
|
|
2366
|
-
return persistentInvitation;
|
|
2367
|
-
});
|
|
2368
|
-
this._persistentInvitationsLoadedEvent.emit();
|
|
2369
|
-
this._persistentInvitationsLoaded = true;
|
|
2370
|
-
return {
|
|
2371
|
-
invitations: cInvitations
|
|
2372
|
-
};
|
|
2373
|
-
}
|
|
2374
|
-
acceptInvitation({ invitation: options, deviceProfile }) {
|
|
2375
|
-
let invitation;
|
|
2376
|
-
if (deviceProfile) {
|
|
2377
|
-
invariant7(options.kind === Invitation4.Kind.DEVICE, "deviceProfile provided for non-device invitation", {
|
|
2378
|
-
F: __dxlog_file8,
|
|
2379
|
-
L: 127,
|
|
2380
|
-
S: this,
|
|
2381
|
-
A: [
|
|
2382
|
-
"options.kind === Invitation.Kind.DEVICE",
|
|
2383
|
-
"'deviceProfile provided for non-device invitation'"
|
|
2384
|
-
]
|
|
2385
|
-
});
|
|
2386
|
-
}
|
|
2387
|
-
const existingInvitation = this._acceptInvitations.get(options.invitationId);
|
|
2388
|
-
if (existingInvitation) {
|
|
2389
|
-
invitation = existingInvitation;
|
|
2390
|
-
} else {
|
|
2391
|
-
const handler = this._getHandler(options);
|
|
2392
|
-
invitation = this._invitationsHandler.acceptInvitation(handler, options, deviceProfile);
|
|
2393
|
-
this._acceptInvitations.set(invitation.get().invitationId, invitation);
|
|
2394
|
-
this._invitationAccepted.emit(invitation.get());
|
|
2395
|
-
}
|
|
2297
|
+
acceptInvitation(request) {
|
|
2298
|
+
const invitation = this._invitationsManager.acceptInvitation(request);
|
|
2396
2299
|
return new Stream8(({ next, close }) => {
|
|
2397
|
-
invitation.subscribe(
|
|
2398
|
-
next(invitation2);
|
|
2399
|
-
}, (err) => {
|
|
2400
|
-
close(err);
|
|
2401
|
-
}, () => {
|
|
2402
|
-
close();
|
|
2403
|
-
this._acceptInvitations.delete(invitation.get().invitationId);
|
|
2404
|
-
if (!invitation.get().multiUse) {
|
|
2405
|
-
this._removedAccepted.emit(invitation.get());
|
|
2406
|
-
}
|
|
2407
|
-
});
|
|
2300
|
+
invitation.subscribe(next, close, close);
|
|
2408
2301
|
});
|
|
2409
2302
|
}
|
|
2410
|
-
async authenticate(
|
|
2411
|
-
|
|
2412
|
-
F: __dxlog_file8,
|
|
2413
|
-
L: 160,
|
|
2414
|
-
S: this,
|
|
2415
|
-
C: (f, a) => f(...a)
|
|
2416
|
-
});
|
|
2417
|
-
invariant7(invitationId, void 0, {
|
|
2418
|
-
F: __dxlog_file8,
|
|
2419
|
-
L: 161,
|
|
2420
|
-
S: this,
|
|
2421
|
-
A: [
|
|
2422
|
-
"invitationId",
|
|
2423
|
-
""
|
|
2424
|
-
]
|
|
2425
|
-
});
|
|
2426
|
-
const observable = this._acceptInvitations.get(invitationId);
|
|
2427
|
-
if (!observable) {
|
|
2428
|
-
log6.warn("invalid invitation", {
|
|
2429
|
-
invitationId
|
|
2430
|
-
}, {
|
|
2431
|
-
F: __dxlog_file8,
|
|
2432
|
-
L: 164,
|
|
2433
|
-
S: this,
|
|
2434
|
-
C: (f, a) => f(...a)
|
|
2435
|
-
});
|
|
2436
|
-
} else {
|
|
2437
|
-
await observable.authenticate(authCode);
|
|
2438
|
-
}
|
|
2303
|
+
async authenticate(request) {
|
|
2304
|
+
return this._invitationsManager.authenticate(request);
|
|
2439
2305
|
}
|
|
2440
|
-
async cancelInvitation(
|
|
2441
|
-
|
|
2442
|
-
invitationId
|
|
2443
|
-
}, {
|
|
2444
|
-
F: __dxlog_file8,
|
|
2445
|
-
L: 171,
|
|
2446
|
-
S: this,
|
|
2447
|
-
C: (f, a) => f(...a)
|
|
2448
|
-
});
|
|
2449
|
-
invariant7(invitationId, void 0, {
|
|
2450
|
-
F: __dxlog_file8,
|
|
2451
|
-
L: 172,
|
|
2452
|
-
S: this,
|
|
2453
|
-
A: [
|
|
2454
|
-
"invitationId",
|
|
2455
|
-
""
|
|
2456
|
-
]
|
|
2457
|
-
});
|
|
2458
|
-
const created = this._createInvitations.get(invitationId);
|
|
2459
|
-
const accepted = this._acceptInvitations.get(invitationId);
|
|
2460
|
-
if (created) {
|
|
2461
|
-
await created.cancel();
|
|
2462
|
-
this._createInvitations.delete(invitationId);
|
|
2463
|
-
this._removedCreated.emit(created.get());
|
|
2464
|
-
if (created.get().persistent) {
|
|
2465
|
-
await this._metadataStore.removeInvitation(created.get().invitationId);
|
|
2466
|
-
}
|
|
2467
|
-
} else if (accepted) {
|
|
2468
|
-
await accepted.cancel();
|
|
2469
|
-
this._acceptInvitations.delete(invitationId);
|
|
2470
|
-
this._removedAccepted.emit(accepted.get());
|
|
2471
|
-
}
|
|
2306
|
+
async cancelInvitation(request) {
|
|
2307
|
+
return this._invitationsManager.cancelInvitation(request);
|
|
2472
2308
|
}
|
|
2473
2309
|
queryInvitations() {
|
|
2474
2310
|
return new Stream8(({ next, ctx }) => {
|
|
2475
|
-
this.
|
|
2311
|
+
this._invitationsManager.invitationCreated.on(ctx, (invitation) => {
|
|
2476
2312
|
next({
|
|
2477
2313
|
action: QueryInvitationsResponse.Action.ADDED,
|
|
2478
2314
|
type: QueryInvitationsResponse.Type.CREATED,
|
|
@@ -2481,7 +2317,7 @@ var InvitationsServiceImpl = class {
|
|
|
2481
2317
|
]
|
|
2482
2318
|
});
|
|
2483
2319
|
});
|
|
2484
|
-
this.
|
|
2320
|
+
this._invitationsManager.invitationAccepted.on(ctx, (invitation) => {
|
|
2485
2321
|
next({
|
|
2486
2322
|
action: QueryInvitationsResponse.Action.ADDED,
|
|
2487
2323
|
type: QueryInvitationsResponse.Type.ACCEPTED,
|
|
@@ -2490,7 +2326,7 @@ var InvitationsServiceImpl = class {
|
|
|
2490
2326
|
]
|
|
2491
2327
|
});
|
|
2492
2328
|
});
|
|
2493
|
-
this.
|
|
2329
|
+
this._invitationsManager.removedCreated.on(ctx, (invitation) => {
|
|
2494
2330
|
next({
|
|
2495
2331
|
action: QueryInvitationsResponse.Action.REMOVED,
|
|
2496
2332
|
type: QueryInvitationsResponse.Type.CREATED,
|
|
@@ -2499,7 +2335,7 @@ var InvitationsServiceImpl = class {
|
|
|
2499
2335
|
]
|
|
2500
2336
|
});
|
|
2501
2337
|
});
|
|
2502
|
-
this.
|
|
2338
|
+
this._invitationsManager.removedAccepted.on(ctx, (invitation) => {
|
|
2503
2339
|
next({
|
|
2504
2340
|
action: QueryInvitationsResponse.Action.REMOVED,
|
|
2505
2341
|
type: QueryInvitationsResponse.Type.ACCEPTED,
|
|
@@ -2508,7 +2344,7 @@ var InvitationsServiceImpl = class {
|
|
|
2508
2344
|
]
|
|
2509
2345
|
});
|
|
2510
2346
|
});
|
|
2511
|
-
this.
|
|
2347
|
+
this._invitationsManager.saved.on(ctx, (invitation) => {
|
|
2512
2348
|
next({
|
|
2513
2349
|
action: QueryInvitationsResponse.Action.SAVED,
|
|
2514
2350
|
type: QueryInvitationsResponse.Type.CREATED,
|
|
@@ -2520,28 +2356,21 @@ var InvitationsServiceImpl = class {
|
|
|
2520
2356
|
next({
|
|
2521
2357
|
action: QueryInvitationsResponse.Action.ADDED,
|
|
2522
2358
|
type: QueryInvitationsResponse.Type.CREATED,
|
|
2523
|
-
invitations:
|
|
2359
|
+
invitations: this._invitationsManager.getCreatedInvitations(),
|
|
2524
2360
|
existing: true
|
|
2525
2361
|
});
|
|
2526
2362
|
next({
|
|
2527
2363
|
action: QueryInvitationsResponse.Action.ADDED,
|
|
2528
2364
|
type: QueryInvitationsResponse.Type.ACCEPTED,
|
|
2529
|
-
invitations:
|
|
2365
|
+
invitations: this._invitationsManager.getAcceptedInvitations(),
|
|
2530
2366
|
existing: true
|
|
2531
2367
|
});
|
|
2532
|
-
|
|
2368
|
+
this._invitationsManager.onPersistentInvitationsLoaded(ctx, () => {
|
|
2533
2369
|
next({
|
|
2534
2370
|
action: QueryInvitationsResponse.Action.LOAD_COMPLETE,
|
|
2535
2371
|
type: QueryInvitationsResponse.Type.CREATED
|
|
2536
2372
|
});
|
|
2537
|
-
}
|
|
2538
|
-
this._persistentInvitationsLoadedEvent.on(ctx, () => {
|
|
2539
|
-
next({
|
|
2540
|
-
action: QueryInvitationsResponse.Action.LOAD_COMPLETE,
|
|
2541
|
-
type: QueryInvitationsResponse.Type.CREATED
|
|
2542
|
-
});
|
|
2543
|
-
});
|
|
2544
|
-
}
|
|
2373
|
+
});
|
|
2545
2374
|
});
|
|
2546
2375
|
}
|
|
2547
2376
|
};
|
|
@@ -2549,11 +2378,11 @@ var InvitationsServiceImpl = class {
|
|
|
2549
2378
|
// packages/sdk/client-services/src/packlets/invitations/space-invitation-protocol.ts
|
|
2550
2379
|
import { createAdmissionCredentials, getCredentialAssertion } from "@dxos/credentials";
|
|
2551
2380
|
import { writeMessages as writeMessages2 } from "@dxos/feed-store";
|
|
2552
|
-
import { invariant as
|
|
2553
|
-
import { log as
|
|
2381
|
+
import { invariant as invariant7 } from "@dxos/invariant";
|
|
2382
|
+
import { log as log6 } from "@dxos/log";
|
|
2554
2383
|
import { AlreadyJoinedError as AlreadyJoinedError2 } from "@dxos/protocols";
|
|
2555
|
-
import { Invitation as
|
|
2556
|
-
var
|
|
2384
|
+
import { Invitation as Invitation4 } from "@dxos/protocols/proto/dxos/client/services";
|
|
2385
|
+
var __dxlog_file8 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/space-invitation-protocol.ts";
|
|
2557
2386
|
var SpaceInvitationProtocol = class {
|
|
2558
2387
|
constructor(_spaceManager, _signingContext, _keyring, _spaceKey) {
|
|
2559
2388
|
this._spaceManager = _spaceManager;
|
|
@@ -2569,13 +2398,13 @@ var SpaceInvitationProtocol = class {
|
|
|
2569
2398
|
}
|
|
2570
2399
|
getInvitationContext() {
|
|
2571
2400
|
return {
|
|
2572
|
-
kind:
|
|
2401
|
+
kind: Invitation4.Kind.SPACE,
|
|
2573
2402
|
spaceKey: this._spaceKey
|
|
2574
2403
|
};
|
|
2575
2404
|
}
|
|
2576
2405
|
async admit(request, guestProfile) {
|
|
2577
|
-
|
|
2578
|
-
F:
|
|
2406
|
+
invariant7(this._spaceKey, void 0, {
|
|
2407
|
+
F: __dxlog_file8,
|
|
2579
2408
|
L: 47,
|
|
2580
2409
|
S: this,
|
|
2581
2410
|
A: [
|
|
@@ -2584,8 +2413,8 @@ var SpaceInvitationProtocol = class {
|
|
|
2584
2413
|
]
|
|
2585
2414
|
});
|
|
2586
2415
|
const space = await this._spaceManager.spaces.get(this._spaceKey);
|
|
2587
|
-
|
|
2588
|
-
F:
|
|
2416
|
+
invariant7(space, void 0, {
|
|
2417
|
+
F: __dxlog_file8,
|
|
2589
2418
|
L: 49,
|
|
2590
2419
|
S: this,
|
|
2591
2420
|
A: [
|
|
@@ -2593,8 +2422,8 @@ var SpaceInvitationProtocol = class {
|
|
|
2593
2422
|
""
|
|
2594
2423
|
]
|
|
2595
2424
|
});
|
|
2596
|
-
|
|
2597
|
-
F:
|
|
2425
|
+
invariant7(request.space, void 0, {
|
|
2426
|
+
F: __dxlog_file8,
|
|
2598
2427
|
L: 51,
|
|
2599
2428
|
S: this,
|
|
2600
2429
|
A: [
|
|
@@ -2603,18 +2432,18 @@ var SpaceInvitationProtocol = class {
|
|
|
2603
2432
|
]
|
|
2604
2433
|
});
|
|
2605
2434
|
const { identityKey, deviceKey } = request.space;
|
|
2606
|
-
|
|
2435
|
+
log6("writing guest credentials", {
|
|
2607
2436
|
host: this._signingContext.deviceKey,
|
|
2608
2437
|
guest: deviceKey
|
|
2609
2438
|
}, {
|
|
2610
|
-
F:
|
|
2439
|
+
F: __dxlog_file8,
|
|
2611
2440
|
L: 54,
|
|
2612
2441
|
S: this,
|
|
2613
2442
|
C: (f, a) => f(...a)
|
|
2614
2443
|
});
|
|
2615
2444
|
const credentials = await createAdmissionCredentials(this._signingContext.credentialSigner, identityKey, space.key, space.inner.genesisFeedKey, guestProfile);
|
|
2616
|
-
|
|
2617
|
-
F:
|
|
2445
|
+
invariant7(credentials[0].credential, void 0, {
|
|
2446
|
+
F: __dxlog_file8,
|
|
2618
2447
|
L: 65,
|
|
2619
2448
|
S: this,
|
|
2620
2449
|
A: [
|
|
@@ -2623,8 +2452,8 @@ var SpaceInvitationProtocol = class {
|
|
|
2623
2452
|
]
|
|
2624
2453
|
});
|
|
2625
2454
|
const spaceMemberCredential = credentials[0].credential.credential;
|
|
2626
|
-
|
|
2627
|
-
F:
|
|
2455
|
+
invariant7(getCredentialAssertion(spaceMemberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
|
|
2456
|
+
F: __dxlog_file8,
|
|
2628
2457
|
L: 67,
|
|
2629
2458
|
S: this,
|
|
2630
2459
|
A: [
|
|
@@ -2663,8 +2492,8 @@ var SpaceInvitationProtocol = class {
|
|
|
2663
2492
|
};
|
|
2664
2493
|
}
|
|
2665
2494
|
async accept(response) {
|
|
2666
|
-
|
|
2667
|
-
F:
|
|
2495
|
+
invariant7(response.space, void 0, {
|
|
2496
|
+
F: __dxlog_file8,
|
|
2668
2497
|
L: 107,
|
|
2669
2498
|
S: this,
|
|
2670
2499
|
A: [
|
|
@@ -2674,8 +2503,8 @@ var SpaceInvitationProtocol = class {
|
|
|
2674
2503
|
});
|
|
2675
2504
|
const { credential, controlTimeframe, dataTimeframe } = response.space;
|
|
2676
2505
|
const assertion = getCredentialAssertion(credential);
|
|
2677
|
-
|
|
2678
|
-
F:
|
|
2506
|
+
invariant7(assertion["@type"] === "dxos.halo.credentials.SpaceMember", "Invalid credential", {
|
|
2507
|
+
F: __dxlog_file8,
|
|
2679
2508
|
L: 110,
|
|
2680
2509
|
S: this,
|
|
2681
2510
|
A: [
|
|
@@ -2683,8 +2512,8 @@ var SpaceInvitationProtocol = class {
|
|
|
2683
2512
|
"'Invalid credential'"
|
|
2684
2513
|
]
|
|
2685
2514
|
});
|
|
2686
|
-
|
|
2687
|
-
F:
|
|
2515
|
+
invariant7(credential.subject.id.equals(this._signingContext.identityKey), void 0, {
|
|
2516
|
+
F: __dxlog_file8,
|
|
2688
2517
|
L: 111,
|
|
2689
2518
|
S: this,
|
|
2690
2519
|
A: [
|
|
@@ -2708,6 +2537,227 @@ var SpaceInvitationProtocol = class {
|
|
|
2708
2537
|
}
|
|
2709
2538
|
};
|
|
2710
2539
|
|
|
2540
|
+
// packages/sdk/client-services/src/packlets/invitations/invitations-manager.ts
|
|
2541
|
+
import { Event as Event3 } from "@dxos/async";
|
|
2542
|
+
import { hasInvitationExpired } from "@dxos/echo-pipeline";
|
|
2543
|
+
import { invariant as invariant8 } from "@dxos/invariant";
|
|
2544
|
+
import { log as log7 } from "@dxos/log";
|
|
2545
|
+
var __dxlog_file9 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitations-manager.ts";
|
|
2546
|
+
var InvitationsManager = class {
|
|
2547
|
+
constructor(_invitationsHandler, _getHandler, _metadataStore) {
|
|
2548
|
+
this._invitationsHandler = _invitationsHandler;
|
|
2549
|
+
this._getHandler = _getHandler;
|
|
2550
|
+
this._metadataStore = _metadataStore;
|
|
2551
|
+
this._createInvitations = /* @__PURE__ */ new Map();
|
|
2552
|
+
this._acceptInvitations = /* @__PURE__ */ new Map();
|
|
2553
|
+
this.invitationCreated = new Event3();
|
|
2554
|
+
this.invitationAccepted = new Event3();
|
|
2555
|
+
this.removedCreated = new Event3();
|
|
2556
|
+
this.removedAccepted = new Event3();
|
|
2557
|
+
this.saved = new Event3();
|
|
2558
|
+
this._persistentInvitationsLoadedEvent = new Event3();
|
|
2559
|
+
this._persistentInvitationsLoaded = false;
|
|
2560
|
+
}
|
|
2561
|
+
createInvitation(options) {
|
|
2562
|
+
const existingInvitation = this._createInvitations.get(options.invitationId);
|
|
2563
|
+
if (existingInvitation) {
|
|
2564
|
+
return existingInvitation;
|
|
2565
|
+
}
|
|
2566
|
+
const handler = this._getHandler(options);
|
|
2567
|
+
const invitation = this._invitationsHandler.createInvitation(handler, options);
|
|
2568
|
+
this._createInvitations.set(invitation.get().invitationId, invitation);
|
|
2569
|
+
this.invitationCreated.emit(invitation.get());
|
|
2570
|
+
const saveInvitationTask = invitation.get().persistent ? this._safePersistInBackground(invitation) : Promise.resolve();
|
|
2571
|
+
this._onInvitationComplete(invitation, async () => {
|
|
2572
|
+
this._createInvitations.delete(invitation.get().invitationId);
|
|
2573
|
+
this.removedCreated.emit(invitation.get());
|
|
2574
|
+
if (invitation.get().persistent) {
|
|
2575
|
+
await saveInvitationTask;
|
|
2576
|
+
await this._safeDeleteInvitation(invitation.get());
|
|
2577
|
+
}
|
|
2578
|
+
});
|
|
2579
|
+
return invitation;
|
|
2580
|
+
}
|
|
2581
|
+
async loadPersistentInvitations() {
|
|
2582
|
+
if (this._persistentInvitationsLoaded) {
|
|
2583
|
+
const invitations = this.getCreatedInvitations().filter((i) => i.persistent);
|
|
2584
|
+
return {
|
|
2585
|
+
invitations
|
|
2586
|
+
};
|
|
2587
|
+
}
|
|
2588
|
+
try {
|
|
2589
|
+
const persistentInvitations = this._metadataStore.getInvitations();
|
|
2590
|
+
const freshInvitations = persistentInvitations.filter((invitation) => !hasInvitationExpired(invitation));
|
|
2591
|
+
const cInvitations = freshInvitations.map((persistentInvitation) => {
|
|
2592
|
+
invariant8(!this._createInvitations.get(persistentInvitation.invitationId), "invitation already exists", {
|
|
2593
|
+
F: __dxlog_file9,
|
|
2594
|
+
L: 82,
|
|
2595
|
+
S: this,
|
|
2596
|
+
A: [
|
|
2597
|
+
"!this._createInvitations.get(persistentInvitation.invitationId)",
|
|
2598
|
+
"'invitation already exists'"
|
|
2599
|
+
]
|
|
2600
|
+
});
|
|
2601
|
+
return this.createInvitation({
|
|
2602
|
+
...persistentInvitation,
|
|
2603
|
+
persistent: false
|
|
2604
|
+
}).get();
|
|
2605
|
+
});
|
|
2606
|
+
return {
|
|
2607
|
+
invitations: cInvitations
|
|
2608
|
+
};
|
|
2609
|
+
} catch (err) {
|
|
2610
|
+
log7.catch(err, void 0, {
|
|
2611
|
+
F: __dxlog_file9,
|
|
2612
|
+
L: 88,
|
|
2613
|
+
S: this,
|
|
2614
|
+
C: (f, a) => f(...a)
|
|
2615
|
+
});
|
|
2616
|
+
return {
|
|
2617
|
+
invitations: []
|
|
2618
|
+
};
|
|
2619
|
+
} finally {
|
|
2620
|
+
this._persistentInvitationsLoadedEvent.emit();
|
|
2621
|
+
this._persistentInvitationsLoaded = true;
|
|
2622
|
+
}
|
|
2623
|
+
}
|
|
2624
|
+
acceptInvitation(request) {
|
|
2625
|
+
const options = request.invitation;
|
|
2626
|
+
const existingInvitation = this._acceptInvitations.get(options.invitationId);
|
|
2627
|
+
if (existingInvitation) {
|
|
2628
|
+
return existingInvitation;
|
|
2629
|
+
}
|
|
2630
|
+
const handler = this._getHandler(options);
|
|
2631
|
+
const invitation = this._invitationsHandler.acceptInvitation(handler, options, request.deviceProfile);
|
|
2632
|
+
this._acceptInvitations.set(invitation.get().invitationId, invitation);
|
|
2633
|
+
this.invitationAccepted.emit(invitation.get());
|
|
2634
|
+
this._onInvitationComplete(invitation, () => {
|
|
2635
|
+
this._acceptInvitations.delete(invitation.get().invitationId);
|
|
2636
|
+
this.removedAccepted.emit(invitation.get());
|
|
2637
|
+
});
|
|
2638
|
+
return invitation;
|
|
2639
|
+
}
|
|
2640
|
+
async authenticate({ invitationId, authCode }) {
|
|
2641
|
+
log7("authenticating...", void 0, {
|
|
2642
|
+
F: __dxlog_file9,
|
|
2643
|
+
L: 117,
|
|
2644
|
+
S: this,
|
|
2645
|
+
C: (f, a) => f(...a)
|
|
2646
|
+
});
|
|
2647
|
+
invariant8(invitationId, void 0, {
|
|
2648
|
+
F: __dxlog_file9,
|
|
2649
|
+
L: 118,
|
|
2650
|
+
S: this,
|
|
2651
|
+
A: [
|
|
2652
|
+
"invitationId",
|
|
2653
|
+
""
|
|
2654
|
+
]
|
|
2655
|
+
});
|
|
2656
|
+
const observable = this._acceptInvitations.get(invitationId);
|
|
2657
|
+
if (!observable) {
|
|
2658
|
+
log7.warn("invalid invitation", {
|
|
2659
|
+
invitationId
|
|
2660
|
+
}, {
|
|
2661
|
+
F: __dxlog_file9,
|
|
2662
|
+
L: 121,
|
|
2663
|
+
S: this,
|
|
2664
|
+
C: (f, a) => f(...a)
|
|
2665
|
+
});
|
|
2666
|
+
} else {
|
|
2667
|
+
await observable.authenticate(authCode);
|
|
2668
|
+
}
|
|
2669
|
+
}
|
|
2670
|
+
async cancelInvitation({ invitationId }) {
|
|
2671
|
+
log7("cancelInvitation...", {
|
|
2672
|
+
invitationId
|
|
2673
|
+
}, {
|
|
2674
|
+
F: __dxlog_file9,
|
|
2675
|
+
L: 128,
|
|
2676
|
+
S: this,
|
|
2677
|
+
C: (f, a) => f(...a)
|
|
2678
|
+
});
|
|
2679
|
+
invariant8(invitationId, void 0, {
|
|
2680
|
+
F: __dxlog_file9,
|
|
2681
|
+
L: 129,
|
|
2682
|
+
S: this,
|
|
2683
|
+
A: [
|
|
2684
|
+
"invitationId",
|
|
2685
|
+
""
|
|
2686
|
+
]
|
|
2687
|
+
});
|
|
2688
|
+
const created = this._createInvitations.get(invitationId);
|
|
2689
|
+
if (created) {
|
|
2690
|
+
if (created.get().persistent) {
|
|
2691
|
+
await this._metadataStore.removeInvitation(invitationId);
|
|
2692
|
+
}
|
|
2693
|
+
await created.cancel();
|
|
2694
|
+
this._createInvitations.delete(invitationId);
|
|
2695
|
+
this.removedCreated.emit(created.get());
|
|
2696
|
+
return;
|
|
2697
|
+
}
|
|
2698
|
+
const accepted = this._acceptInvitations.get(invitationId);
|
|
2699
|
+
if (accepted) {
|
|
2700
|
+
await accepted.cancel();
|
|
2701
|
+
this._acceptInvitations.delete(invitationId);
|
|
2702
|
+
this.removedAccepted.emit(accepted.get());
|
|
2703
|
+
}
|
|
2704
|
+
}
|
|
2705
|
+
getCreatedInvitations() {
|
|
2706
|
+
return [
|
|
2707
|
+
...this._createInvitations.values()
|
|
2708
|
+
].map((i) => i.get());
|
|
2709
|
+
}
|
|
2710
|
+
getAcceptedInvitations() {
|
|
2711
|
+
return [
|
|
2712
|
+
...this._acceptInvitations.values()
|
|
2713
|
+
].map((i) => i.get());
|
|
2714
|
+
}
|
|
2715
|
+
onPersistentInvitationsLoaded(ctx, callback) {
|
|
2716
|
+
if (this._persistentInvitationsLoaded) {
|
|
2717
|
+
callback();
|
|
2718
|
+
} else {
|
|
2719
|
+
this._persistentInvitationsLoadedEvent.once(ctx, () => callback());
|
|
2720
|
+
}
|
|
2721
|
+
}
|
|
2722
|
+
_safePersistInBackground(invitation) {
|
|
2723
|
+
return new Promise((resolve) => {
|
|
2724
|
+
setTimeout(async () => {
|
|
2725
|
+
try {
|
|
2726
|
+
await this._metadataStore.addInvitation(invitation.get());
|
|
2727
|
+
this.saved.emit(invitation.get());
|
|
2728
|
+
} catch (err) {
|
|
2729
|
+
log7.catch(err, void 0, {
|
|
2730
|
+
F: __dxlog_file9,
|
|
2731
|
+
L: 173,
|
|
2732
|
+
S: this,
|
|
2733
|
+
C: (f, a) => f(...a)
|
|
2734
|
+
});
|
|
2735
|
+
await invitation.cancel();
|
|
2736
|
+
} finally {
|
|
2737
|
+
resolve();
|
|
2738
|
+
}
|
|
2739
|
+
});
|
|
2740
|
+
});
|
|
2741
|
+
}
|
|
2742
|
+
async _safeDeleteInvitation(invitation) {
|
|
2743
|
+
try {
|
|
2744
|
+
await this._metadataStore.removeInvitation(invitation.invitationId);
|
|
2745
|
+
} catch (err) {
|
|
2746
|
+
log7.catch(err, void 0, {
|
|
2747
|
+
F: __dxlog_file9,
|
|
2748
|
+
L: 186,
|
|
2749
|
+
S: this,
|
|
2750
|
+
C: (f, a) => f(...a)
|
|
2751
|
+
});
|
|
2752
|
+
}
|
|
2753
|
+
}
|
|
2754
|
+
_onInvitationComplete(invitation, callback) {
|
|
2755
|
+
invitation.subscribe(() => {
|
|
2756
|
+
}, () => {
|
|
2757
|
+
}, callback);
|
|
2758
|
+
}
|
|
2759
|
+
};
|
|
2760
|
+
|
|
2711
2761
|
// packages/sdk/client-services/src/packlets/services/client-rpc-server.ts
|
|
2712
2762
|
import { Stream as Stream9 } from "@dxos/codec-protobuf";
|
|
2713
2763
|
import { raise } from "@dxos/debug";
|
|
@@ -2790,13 +2840,13 @@ ClientRpcServer = _ts_decorate3([
|
|
|
2790
2840
|
], ClientRpcServer);
|
|
2791
2841
|
|
|
2792
2842
|
// packages/sdk/client-services/src/packlets/spaces/data-space.ts
|
|
2793
|
-
import { Event as Event6, asyncTimeout, scheduleTask as
|
|
2843
|
+
import { Event as Event6, asyncTimeout, scheduleTask as scheduleTask4, sleep as sleep2, synchronized, trackLeaks } from "@dxos/async";
|
|
2794
2844
|
import { AUTH_TIMEOUT as AUTH_TIMEOUT2 } from "@dxos/client-protocol";
|
|
2795
|
-
import { cancelWithContext as cancelWithContext2, Context as
|
|
2845
|
+
import { cancelWithContext as cancelWithContext2, Context as Context7, ContextDisposedError } from "@dxos/context";
|
|
2796
2846
|
import { timed, warnAfterTimeout } from "@dxos/debug";
|
|
2797
|
-
import { TYPE_PROPERTIES } from "@dxos/echo-db";
|
|
2798
2847
|
import { createMappedFeedWriter } from "@dxos/echo-pipeline";
|
|
2799
2848
|
import { AutomergeDocumentLoaderImpl } from "@dxos/echo-pipeline";
|
|
2849
|
+
import { TYPE_PROPERTIES } from "@dxos/echo-schema";
|
|
2800
2850
|
import { failedInvariant, invariant as invariant10 } from "@dxos/invariant";
|
|
2801
2851
|
import { PublicKey as PublicKey8 } from "@dxos/keys";
|
|
2802
2852
|
import { log as log9 } from "@dxos/log";
|
|
@@ -2846,8 +2896,8 @@ var AutomergeSpaceState = class {
|
|
|
2846
2896
|
};
|
|
2847
2897
|
|
|
2848
2898
|
// packages/sdk/client-services/src/packlets/spaces/notarization-plugin.ts
|
|
2849
|
-
import { DeferredTask, Event as Event5, scheduleTask as
|
|
2850
|
-
import { Context as
|
|
2899
|
+
import { DeferredTask, Event as Event5, scheduleTask as scheduleTask3, sleep, TimeoutError as TimeoutError2, Trigger as Trigger4 } from "@dxos/async";
|
|
2900
|
+
import { Context as Context6, rejectOnDispose } from "@dxos/context";
|
|
2851
2901
|
import { invariant as invariant9 } from "@dxos/invariant";
|
|
2852
2902
|
import { PublicKey as PublicKey7 } from "@dxos/keys";
|
|
2853
2903
|
import { log as log8 } from "@dxos/log";
|
|
@@ -2861,7 +2911,7 @@ var DEFAULT_NOTARIZE_TIMEOUT = 1e4;
|
|
|
2861
2911
|
var WRITER_NOT_SET_ERROR_CODE = "WRITER_NOT_SET";
|
|
2862
2912
|
var NotarizationPlugin = class {
|
|
2863
2913
|
constructor() {
|
|
2864
|
-
this._ctx = new
|
|
2914
|
+
this._ctx = new Context6();
|
|
2865
2915
|
this._extensionOpened = new Event5();
|
|
2866
2916
|
this._extensions = /* @__PURE__ */ new Set();
|
|
2867
2917
|
this._processedCredentials = new ComplexSet2(PublicKey7.hash);
|
|
@@ -2913,7 +2963,7 @@ var NotarizationPlugin = class {
|
|
|
2913
2963
|
});
|
|
2914
2964
|
opCtx?.onDispose(() => ctx.dispose());
|
|
2915
2965
|
if (timeout !== 0) {
|
|
2916
|
-
|
|
2966
|
+
scheduleTask3(ctx, () => {
|
|
2917
2967
|
log8.warn("Notarization timeout", {
|
|
2918
2968
|
timeout,
|
|
2919
2969
|
peers: Array.from(this._extensions).map((extension) => extension.remotePeerId)
|
|
@@ -2947,7 +2997,7 @@ var NotarizationPlugin = class {
|
|
|
2947
2997
|
C: (f, a) => f(...a)
|
|
2948
2998
|
});
|
|
2949
2999
|
peersTried.clear();
|
|
2950
|
-
|
|
3000
|
+
scheduleTask3(ctx, () => notarizeTask.schedule(), retryTimeout);
|
|
2951
3001
|
return;
|
|
2952
3002
|
}
|
|
2953
3003
|
peersTried.add(peer);
|
|
@@ -3127,7 +3177,7 @@ function _ts_decorate4(decorators, target, key, desc) {
|
|
|
3127
3177
|
var __dxlog_file11 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space.ts";
|
|
3128
3178
|
var DataSpace = class {
|
|
3129
3179
|
constructor(params) {
|
|
3130
|
-
this._ctx = new
|
|
3180
|
+
this._ctx = new Context7();
|
|
3131
3181
|
this._notarizationPlugin = new NotarizationPlugin();
|
|
3132
3182
|
this._cache = void 0;
|
|
3133
3183
|
// TODO(dmaretskyi): Move into Space?
|
|
@@ -3204,7 +3254,7 @@ var DataSpace = class {
|
|
|
3204
3254
|
await this._notarizationPlugin.open();
|
|
3205
3255
|
await this._inner.spaceState.addCredentialProcessor(this._notarizationPlugin);
|
|
3206
3256
|
await this._inner.spaceState.addCredentialProcessor(this._automergeSpaceState);
|
|
3207
|
-
await this._inner.open(new
|
|
3257
|
+
await this._inner.open(new Context7());
|
|
3208
3258
|
this._state = SpaceState.CONTROL_ONLY;
|
|
3209
3259
|
log9("new state", {
|
|
3210
3260
|
state: SpaceState[this._state]
|
|
@@ -3233,7 +3283,7 @@ var DataSpace = class {
|
|
|
3233
3283
|
C: (f, a) => f(...a)
|
|
3234
3284
|
});
|
|
3235
3285
|
await this._ctx.dispose();
|
|
3236
|
-
this._ctx = new
|
|
3286
|
+
this._ctx = new Context7();
|
|
3237
3287
|
await this.authVerifier.close();
|
|
3238
3288
|
await this._inner.close();
|
|
3239
3289
|
await this._inner.spaceState.removeCredentialProcessor(this._automergeSpaceState);
|
|
@@ -3252,7 +3302,7 @@ var DataSpace = class {
|
|
|
3252
3302
|
* Initialize the data pipeline in a separate task.
|
|
3253
3303
|
*/
|
|
3254
3304
|
initializeDataPipelineAsync() {
|
|
3255
|
-
|
|
3305
|
+
scheduleTask4(this._ctx, async () => {
|
|
3256
3306
|
try {
|
|
3257
3307
|
this.metrics.pipelineInitBegin = /* @__PURE__ */ new Date();
|
|
3258
3308
|
await this.initializeDataPipeline();
|
|
@@ -3654,7 +3704,7 @@ DataSpace = _ts_decorate4([
|
|
|
3654
3704
|
|
|
3655
3705
|
// packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts
|
|
3656
3706
|
import { Event as Event7, synchronized as synchronized2, trackLeaks as trackLeaks2 } from "@dxos/async";
|
|
3657
|
-
import { Context as
|
|
3707
|
+
import { Context as Context8, cancelWithContext as cancelWithContext3 } from "@dxos/context";
|
|
3658
3708
|
import { getCredentialAssertion as getCredentialAssertion2 } from "@dxos/credentials";
|
|
3659
3709
|
import { invariant as invariant11 } from "@dxos/invariant";
|
|
3660
3710
|
import { PublicKey as PublicKey9 } from "@dxos/keys";
|
|
@@ -3756,7 +3806,7 @@ var DataSpaceManager = class {
|
|
|
3756
3806
|
this._signingContext = _signingContext;
|
|
3757
3807
|
this._feedStore = _feedStore;
|
|
3758
3808
|
this._automergeHost = _automergeHost;
|
|
3759
|
-
this._ctx = new
|
|
3809
|
+
this._ctx = new Context8();
|
|
3760
3810
|
this.updated = new Event7();
|
|
3761
3811
|
this._spaces = new ComplexMap3(PublicKey9.hash);
|
|
3762
3812
|
this._isOpen = false;
|
|
@@ -4077,7 +4127,7 @@ DataSpaceManager = _ts_decorate5([
|
|
|
4077
4127
|
], DataSpaceManager);
|
|
4078
4128
|
|
|
4079
4129
|
// packages/sdk/client-services/src/packlets/spaces/spaces-service.ts
|
|
4080
|
-
import { EventSubscriptions as EventSubscriptions2, UpdateScheduler, scheduleTask as
|
|
4130
|
+
import { EventSubscriptions as EventSubscriptions2, UpdateScheduler, scheduleTask as scheduleTask5 } from "@dxos/async";
|
|
4081
4131
|
import { Stream as Stream10 } from "@dxos/codec-protobuf";
|
|
4082
4132
|
import { raise as raise2 } from "@dxos/debug";
|
|
4083
4133
|
import { invariant as invariant12 } from "@dxos/invariant";
|
|
@@ -4134,7 +4184,7 @@ var SpacesServiceImpl = class {
|
|
|
4134
4184
|
}, {
|
|
4135
4185
|
maxFrequency: false ? void 0 : 2
|
|
4136
4186
|
});
|
|
4137
|
-
|
|
4187
|
+
scheduleTask5(ctx, async () => {
|
|
4138
4188
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
4139
4189
|
const subscriptions = new EventSubscriptions2();
|
|
4140
4190
|
ctx.onDispose(() => subscriptions.clear());
|
|
@@ -4168,7 +4218,7 @@ var SpacesServiceImpl = class {
|
|
|
4168
4218
|
}
|
|
4169
4219
|
subscribeMessages({ spaceKey, channel }) {
|
|
4170
4220
|
return new Stream10(({ ctx, next }) => {
|
|
4171
|
-
|
|
4221
|
+
scheduleTask5(ctx, async () => {
|
|
4172
4222
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
4173
4223
|
const space = dataSpaceManager.spaces.get(spaceKey) ?? raise2(new SpaceNotFoundError(spaceKey));
|
|
4174
4224
|
const handle = space.listen(getChannelId(channel), (message) => {
|
|
@@ -4187,7 +4237,7 @@ var SpacesServiceImpl = class {
|
|
|
4187
4237
|
}
|
|
4188
4238
|
};
|
|
4189
4239
|
ctx.onDispose(() => space.spaceState.removeCredentialProcessor(processor));
|
|
4190
|
-
|
|
4240
|
+
scheduleTask5(ctx, async () => {
|
|
4191
4241
|
await space.spaceState.addCredentialProcessor(processor);
|
|
4192
4242
|
if (noTail) {
|
|
4193
4243
|
close();
|
|
@@ -4295,25 +4345,24 @@ var getChannelId = (channel) => `user-channel/${channel}`;
|
|
|
4295
4345
|
|
|
4296
4346
|
// packages/sdk/client-services/src/packlets/services/service-context.ts
|
|
4297
4347
|
import { Trigger as Trigger5 } from "@dxos/async";
|
|
4298
|
-
import { Context as
|
|
4348
|
+
import { Context as Context9, Resource } from "@dxos/context";
|
|
4299
4349
|
import { getCredentialAssertion as getCredentialAssertion3 } from "@dxos/credentials";
|
|
4300
4350
|
import { failUndefined as failUndefined2 } from "@dxos/debug";
|
|
4301
4351
|
import { AutomergeHost, MetadataStore, SnapshotStore, SpaceManager, valueEncoding } from "@dxos/echo-pipeline";
|
|
4302
4352
|
import { FeedFactory, FeedStore } from "@dxos/feed-store";
|
|
4303
|
-
import { IndexMetadataStore, IndexStore, Indexer } from "@dxos/indexing";
|
|
4353
|
+
import { IndexMetadataStore, IndexStore, Indexer, createStorageCallbacks } from "@dxos/indexing";
|
|
4304
4354
|
import { invariant as invariant13 } from "@dxos/invariant";
|
|
4305
4355
|
import { Keyring } from "@dxos/keyring";
|
|
4306
4356
|
import { PublicKey as PublicKey10 } from "@dxos/keys";
|
|
4307
4357
|
import { log as log12 } from "@dxos/log";
|
|
4308
4358
|
import { InvalidStorageVersionError, STORAGE_VERSION, trace as trace8 } from "@dxos/protocols";
|
|
4309
|
-
import { Invitation as
|
|
4359
|
+
import { Invitation as Invitation5 } from "@dxos/protocols/proto/dxos/client/services";
|
|
4310
4360
|
import { BlobStore } from "@dxos/teleport-extension-object-sync";
|
|
4311
4361
|
import { trace as Trace2 } from "@dxos/tracing";
|
|
4312
4362
|
import { safeInstanceof } from "@dxos/util";
|
|
4313
4363
|
|
|
4314
4364
|
// packages/sdk/client-services/src/packlets/indexing/util.ts
|
|
4315
4365
|
import { getHeads } from "@dxos/automerge/automerge";
|
|
4316
|
-
import { warnAfterTimeout as warnAfterTimeout2 } from "@dxos/debug";
|
|
4317
4366
|
import { idCodec } from "@dxos/protocols";
|
|
4318
4367
|
var createSelectedDocumentsIterator = (automergeHost) => (
|
|
4319
4368
|
/**
|
|
@@ -4324,8 +4373,10 @@ var createSelectedDocumentsIterator = (automergeHost) => (
|
|
|
4324
4373
|
async function* loadDocuments(ids) {
|
|
4325
4374
|
for (const id of ids) {
|
|
4326
4375
|
const { documentId, objectId } = idCodec.decode(id);
|
|
4327
|
-
const handle = automergeHost.repo.find(documentId);
|
|
4328
|
-
|
|
4376
|
+
const handle = automergeHost.repo.handles[documentId] ?? automergeHost.repo.find(documentId);
|
|
4377
|
+
if (!handle.isReady()) {
|
|
4378
|
+
await handle.whenReady();
|
|
4379
|
+
}
|
|
4329
4380
|
const doc = handle.docSync();
|
|
4330
4381
|
const hash = getHeads(doc).join("");
|
|
4331
4382
|
yield doc.objects?.[objectId] ? [
|
|
@@ -4350,7 +4401,9 @@ var createDocumentsIterator = (automergeHost) => (
|
|
|
4350
4401
|
if (visited.has(handle.documentId)) {
|
|
4351
4402
|
return;
|
|
4352
4403
|
}
|
|
4353
|
-
|
|
4404
|
+
if (!handle.isReady()) {
|
|
4405
|
+
await handle.whenReady();
|
|
4406
|
+
}
|
|
4354
4407
|
const doc = handle.docSync();
|
|
4355
4408
|
const heads = getHeads(doc);
|
|
4356
4409
|
if (doc.objects) {
|
|
@@ -4370,7 +4423,7 @@ var createDocumentsIterator = (automergeHost) => (
|
|
|
4370
4423
|
if (visited.has(id)) {
|
|
4371
4424
|
continue;
|
|
4372
4425
|
}
|
|
4373
|
-
const linkHandle = automergeHost.repo.find(id);
|
|
4426
|
+
const linkHandle = automergeHost.repo.handles[id] ?? automergeHost.repo.find(id);
|
|
4374
4427
|
for await (const result of getObjectsFromHandle(linkHandle)) {
|
|
4375
4428
|
yield result;
|
|
4376
4429
|
}
|
|
@@ -4441,24 +4494,28 @@ var ServiceContext = class extends Resource {
|
|
|
4441
4494
|
this.automergeHost = new AutomergeHost({
|
|
4442
4495
|
directory: storage.createDirectory("automerge"),
|
|
4443
4496
|
db: level.sublevel("automerge"),
|
|
4444
|
-
|
|
4497
|
+
storageCallbacks: createStorageCallbacks({
|
|
4498
|
+
host: () => this.automergeHost,
|
|
4499
|
+
metadata: this.indexMetadata
|
|
4500
|
+
})
|
|
4445
4501
|
});
|
|
4446
4502
|
this.indexer = new Indexer({
|
|
4447
4503
|
indexStore: new IndexStore({
|
|
4448
|
-
|
|
4504
|
+
db: level.sublevel("index-storage")
|
|
4449
4505
|
}),
|
|
4450
4506
|
metadataStore: this.indexMetadata,
|
|
4451
4507
|
loadDocuments: createSelectedDocumentsIterator(this.automergeHost),
|
|
4452
4508
|
getAllDocuments: createDocumentsIterator(this.automergeHost)
|
|
4453
4509
|
});
|
|
4454
4510
|
this.invitations = new InvitationsHandler(this.networkManager);
|
|
4455
|
-
this.
|
|
4511
|
+
this.invitationsManager = new InvitationsManager(this.invitations, (invitation) => this.getInvitationHandler(invitation), this.metadataStore);
|
|
4512
|
+
this._handlerFactories.set(Invitation5.Kind.DEVICE, () => new DeviceInvitationProtocol(this.keyring, () => this.identityManager.identity ?? failUndefined2(), this._acceptIdentity.bind(this)));
|
|
4456
4513
|
}
|
|
4457
4514
|
async _open(ctx) {
|
|
4458
4515
|
await this._checkStorageVersion();
|
|
4459
4516
|
log12("opening...", void 0, {
|
|
4460
4517
|
F: __dxlog_file14,
|
|
4461
|
-
L:
|
|
4518
|
+
L: 164,
|
|
4462
4519
|
S: this,
|
|
4463
4520
|
C: (f, a) => f(...a)
|
|
4464
4521
|
});
|
|
@@ -4466,7 +4523,7 @@ var ServiceContext = class extends Resource {
|
|
|
4466
4523
|
id: this._instanceId
|
|
4467
4524
|
}), {
|
|
4468
4525
|
F: __dxlog_file14,
|
|
4469
|
-
L:
|
|
4526
|
+
L: 165,
|
|
4470
4527
|
S: this,
|
|
4471
4528
|
C: (f, a) => f(...a)
|
|
4472
4529
|
});
|
|
@@ -4479,17 +4536,26 @@ var ServiceContext = class extends Resource {
|
|
|
4479
4536
|
if (this.identityManager.identity) {
|
|
4480
4537
|
await this._initialize(ctx);
|
|
4481
4538
|
}
|
|
4539
|
+
const loadedInvitations = await this.invitationsManager.loadPersistentInvitations();
|
|
4540
|
+
log12("loaded persistent invitations", {
|
|
4541
|
+
count: loadedInvitations.invitations?.length
|
|
4542
|
+
}, {
|
|
4543
|
+
F: __dxlog_file14,
|
|
4544
|
+
L: 178,
|
|
4545
|
+
S: this,
|
|
4546
|
+
C: (f, a) => f(...a)
|
|
4547
|
+
});
|
|
4482
4548
|
log12.trace("dxos.sdk.service-context.open", trace8.end({
|
|
4483
4549
|
id: this._instanceId
|
|
4484
4550
|
}), {
|
|
4485
4551
|
F: __dxlog_file14,
|
|
4486
|
-
L:
|
|
4552
|
+
L: 180,
|
|
4487
4553
|
S: this,
|
|
4488
4554
|
C: (f, a) => f(...a)
|
|
4489
4555
|
});
|
|
4490
4556
|
log12("opened", void 0, {
|
|
4491
4557
|
F: __dxlog_file14,
|
|
4492
|
-
L:
|
|
4558
|
+
L: 181,
|
|
4493
4559
|
S: this,
|
|
4494
4560
|
C: (f, a) => f(...a)
|
|
4495
4561
|
});
|
|
@@ -4497,7 +4563,7 @@ var ServiceContext = class extends Resource {
|
|
|
4497
4563
|
async _close() {
|
|
4498
4564
|
log12("closing...", void 0, {
|
|
4499
4565
|
F: __dxlog_file14,
|
|
4500
|
-
L:
|
|
4566
|
+
L: 185,
|
|
4501
4567
|
S: this,
|
|
4502
4568
|
C: (f, a) => f(...a)
|
|
4503
4569
|
});
|
|
@@ -4515,21 +4581,21 @@ var ServiceContext = class extends Resource {
|
|
|
4515
4581
|
await this.indexer.destroy();
|
|
4516
4582
|
log12("closed", void 0, {
|
|
4517
4583
|
F: __dxlog_file14,
|
|
4518
|
-
L:
|
|
4584
|
+
L: 198,
|
|
4519
4585
|
S: this,
|
|
4520
4586
|
C: (f, a) => f(...a)
|
|
4521
4587
|
});
|
|
4522
4588
|
}
|
|
4523
4589
|
async createIdentity(params = {}) {
|
|
4524
4590
|
const identity = await this.identityManager.createIdentity(params);
|
|
4525
|
-
await this._initialize(new
|
|
4591
|
+
await this._initialize(new Context9());
|
|
4526
4592
|
return identity;
|
|
4527
4593
|
}
|
|
4528
4594
|
getInvitationHandler(invitation) {
|
|
4529
4595
|
const factory = this._handlerFactories.get(invitation.kind);
|
|
4530
4596
|
invariant13(factory, `Unknown invitation kind: ${invitation.kind}`, {
|
|
4531
4597
|
F: __dxlog_file14,
|
|
4532
|
-
L:
|
|
4598
|
+
L: 209,
|
|
4533
4599
|
S: this,
|
|
4534
4600
|
A: [
|
|
4535
4601
|
"factory",
|
|
@@ -4548,7 +4614,7 @@ var ServiceContext = class extends Resource {
|
|
|
4548
4614
|
}
|
|
4549
4615
|
async _acceptIdentity(params) {
|
|
4550
4616
|
const identity = await this.identityManager.acceptIdentity(params);
|
|
4551
|
-
await this._initialize(new
|
|
4617
|
+
await this._initialize(new Context9());
|
|
4552
4618
|
return identity;
|
|
4553
4619
|
}
|
|
4554
4620
|
async _checkStorageVersion() {
|
|
@@ -4561,7 +4627,7 @@ var ServiceContext = class extends Resource {
|
|
|
4561
4627
|
async _initialize(ctx) {
|
|
4562
4628
|
log12("initializing spaces...", void 0, {
|
|
4563
4629
|
F: __dxlog_file14,
|
|
4564
|
-
L:
|
|
4630
|
+
L: 240,
|
|
4565
4631
|
S: this,
|
|
4566
4632
|
C: (f, a) => f(...a)
|
|
4567
4633
|
});
|
|
@@ -4581,10 +4647,10 @@ var ServiceContext = class extends Resource {
|
|
|
4581
4647
|
};
|
|
4582
4648
|
this.dataSpaceManager = new DataSpaceManager(this.spaceManager, this.metadataStore, this.keyring, signingContext, this.feedStore, this.automergeHost, this._runtimeParams);
|
|
4583
4649
|
await this.dataSpaceManager.open();
|
|
4584
|
-
this._handlerFactories.set(
|
|
4650
|
+
this._handlerFactories.set(Invitation5.Kind.SPACE, (invitation) => {
|
|
4585
4651
|
invariant13(this.dataSpaceManager, "dataSpaceManager not initialized yet", {
|
|
4586
4652
|
F: __dxlog_file14,
|
|
4587
|
-
L:
|
|
4653
|
+
L: 264,
|
|
4588
4654
|
S: this,
|
|
4589
4655
|
A: [
|
|
4590
4656
|
"this.dataSpaceManager",
|
|
@@ -4608,7 +4674,7 @@ var ServiceContext = class extends Resource {
|
|
|
4608
4674
|
details: assertion
|
|
4609
4675
|
}, {
|
|
4610
4676
|
F: __dxlog_file14,
|
|
4611
|
-
L:
|
|
4677
|
+
L: 280,
|
|
4612
4678
|
S: this,
|
|
4613
4679
|
C: (f, a) => f(...a)
|
|
4614
4680
|
});
|
|
@@ -4619,7 +4685,7 @@ var ServiceContext = class extends Resource {
|
|
|
4619
4685
|
details: assertion
|
|
4620
4686
|
}, {
|
|
4621
4687
|
F: __dxlog_file14,
|
|
4622
|
-
L:
|
|
4688
|
+
L: 284,
|
|
4623
4689
|
S: this,
|
|
4624
4690
|
C: (f, a) => f(...a)
|
|
4625
4691
|
});
|
|
@@ -4630,7 +4696,7 @@ var ServiceContext = class extends Resource {
|
|
|
4630
4696
|
details: assertion
|
|
4631
4697
|
}, {
|
|
4632
4698
|
F: __dxlog_file14,
|
|
4633
|
-
L:
|
|
4699
|
+
L: 289,
|
|
4634
4700
|
S: this,
|
|
4635
4701
|
C: (f, a) => f(...a)
|
|
4636
4702
|
});
|
|
@@ -4641,7 +4707,7 @@ var ServiceContext = class extends Resource {
|
|
|
4641
4707
|
} catch (err) {
|
|
4642
4708
|
log12.catch(err, void 0, {
|
|
4643
4709
|
F: __dxlog_file14,
|
|
4644
|
-
L:
|
|
4710
|
+
L: 295,
|
|
4645
4711
|
S: this,
|
|
4646
4712
|
C: (f, a) => f(...a)
|
|
4647
4713
|
});
|
|
@@ -4695,7 +4761,7 @@ import { SpaceMember as SpaceMember3 } from "@dxos/protocols/proto/dxos/client/s
|
|
|
4695
4761
|
import { TRACE_PROCESSOR } from "@dxos/tracing";
|
|
4696
4762
|
|
|
4697
4763
|
// packages/sdk/client-services/src/version.ts
|
|
4698
|
-
var DXOS_VERSION = "0.4.10-main.
|
|
4764
|
+
var DXOS_VERSION = "0.4.10-main.c16d37b";
|
|
4699
4765
|
|
|
4700
4766
|
// packages/sdk/client-services/src/packlets/services/platform.ts
|
|
4701
4767
|
import { Platform } from "@dxos/protocols/proto/dxos/client/services";
|
|
@@ -4938,10 +5004,10 @@ import { jsonKeyReplacer as jsonKeyReplacer2, nonNullable } from "@dxos/util";
|
|
|
4938
5004
|
// packages/sdk/client-services/src/packlets/services/service-host.ts
|
|
4939
5005
|
import { Event as Event9, synchronized as synchronized3 } from "@dxos/async";
|
|
4940
5006
|
import { clientServiceBundle, defaultKey, Properties } from "@dxos/client-protocol";
|
|
4941
|
-
import { Context as
|
|
5007
|
+
import { Context as Context10 } from "@dxos/context";
|
|
4942
5008
|
import { DataServiceImpl, encodeReference } from "@dxos/echo-pipeline";
|
|
4943
|
-
import
|
|
4944
|
-
import {
|
|
5009
|
+
import { getTypeReference } from "@dxos/echo-schema";
|
|
5010
|
+
import { QueryServiceImpl } from "@dxos/indexing";
|
|
4945
5011
|
import { invariant as invariant16 } from "@dxos/invariant";
|
|
4946
5012
|
import { PublicKey as PublicKey13 } from "@dxos/keys";
|
|
4947
5013
|
import { log as log16 } from "@dxos/log";
|
|
@@ -5491,7 +5557,7 @@ var ClientServicesHost = class {
|
|
|
5491
5557
|
lockKey,
|
|
5492
5558
|
onAcquire: () => {
|
|
5493
5559
|
if (!this._opening) {
|
|
5494
|
-
void this.open(new
|
|
5560
|
+
void this.open(new Context10());
|
|
5495
5561
|
}
|
|
5496
5562
|
},
|
|
5497
5563
|
onRelease: () => this.close()
|
|
@@ -5548,7 +5614,7 @@ var ClientServicesHost = class {
|
|
|
5548
5614
|
initialize({ config, ...options }) {
|
|
5549
5615
|
invariant16(!this._open, "service host is open", {
|
|
5550
5616
|
F: __dxlog_file19,
|
|
5551
|
-
L:
|
|
5617
|
+
L: 198,
|
|
5552
5618
|
S: this,
|
|
5553
5619
|
A: [
|
|
5554
5620
|
"!this._open",
|
|
@@ -5557,14 +5623,14 @@ var ClientServicesHost = class {
|
|
|
5557
5623
|
});
|
|
5558
5624
|
log16("initializing...", void 0, {
|
|
5559
5625
|
F: __dxlog_file19,
|
|
5560
|
-
L:
|
|
5626
|
+
L: 199,
|
|
5561
5627
|
S: this,
|
|
5562
5628
|
C: (f, a) => f(...a)
|
|
5563
5629
|
});
|
|
5564
5630
|
if (config) {
|
|
5565
5631
|
invariant16(!this._config, "config already set", {
|
|
5566
5632
|
F: __dxlog_file19,
|
|
5567
|
-
L:
|
|
5633
|
+
L: 202,
|
|
5568
5634
|
S: this,
|
|
5569
5635
|
A: [
|
|
5570
5636
|
"!this._config",
|
|
@@ -5579,7 +5645,7 @@ var ClientServicesHost = class {
|
|
|
5579
5645
|
if (!options.signalManager) {
|
|
5580
5646
|
log16.warn("running signaling without telemetry metadata.", void 0, {
|
|
5581
5647
|
F: __dxlog_file19,
|
|
5582
|
-
L:
|
|
5648
|
+
L: 210,
|
|
5583
5649
|
S: this,
|
|
5584
5650
|
C: (f, a) => f(...a)
|
|
5585
5651
|
});
|
|
@@ -5590,7 +5656,7 @@ var ClientServicesHost = class {
|
|
|
5590
5656
|
this._signalManager = signalManager;
|
|
5591
5657
|
invariant16(!this._networkManager, "network manager already set", {
|
|
5592
5658
|
F: __dxlog_file19,
|
|
5593
|
-
L:
|
|
5659
|
+
L: 221,
|
|
5594
5660
|
S: this,
|
|
5595
5661
|
A: [
|
|
5596
5662
|
"!this._networkManager",
|
|
@@ -5604,7 +5670,7 @@ var ClientServicesHost = class {
|
|
|
5604
5670
|
});
|
|
5605
5671
|
log16("initialized", void 0, {
|
|
5606
5672
|
F: __dxlog_file19,
|
|
5607
|
-
L:
|
|
5673
|
+
L: 228,
|
|
5608
5674
|
S: this,
|
|
5609
5675
|
C: (f, a) => f(...a)
|
|
5610
5676
|
});
|
|
@@ -5618,13 +5684,13 @@ var ClientServicesHost = class {
|
|
|
5618
5684
|
id: traceId
|
|
5619
5685
|
}), {
|
|
5620
5686
|
F: __dxlog_file19,
|
|
5621
|
-
L:
|
|
5687
|
+
L: 239,
|
|
5622
5688
|
S: this,
|
|
5623
5689
|
C: (f, a) => f(...a)
|
|
5624
5690
|
});
|
|
5625
5691
|
invariant16(this._config, "config not set", {
|
|
5626
5692
|
F: __dxlog_file19,
|
|
5627
|
-
L:
|
|
5693
|
+
L: 241,
|
|
5628
5694
|
S: this,
|
|
5629
5695
|
A: [
|
|
5630
5696
|
"this._config",
|
|
@@ -5633,7 +5699,7 @@ var ClientServicesHost = class {
|
|
|
5633
5699
|
});
|
|
5634
5700
|
invariant16(this._storage, "storage not set", {
|
|
5635
5701
|
F: __dxlog_file19,
|
|
5636
|
-
L:
|
|
5702
|
+
L: 242,
|
|
5637
5703
|
S: this,
|
|
5638
5704
|
A: [
|
|
5639
5705
|
"this._storage",
|
|
@@ -5642,7 +5708,7 @@ var ClientServicesHost = class {
|
|
|
5642
5708
|
});
|
|
5643
5709
|
invariant16(this._signalManager, "signal manager not set", {
|
|
5644
5710
|
F: __dxlog_file19,
|
|
5645
|
-
L:
|
|
5711
|
+
L: 243,
|
|
5646
5712
|
S: this,
|
|
5647
5713
|
A: [
|
|
5648
5714
|
"this._signalManager",
|
|
@@ -5651,7 +5717,7 @@ var ClientServicesHost = class {
|
|
|
5651
5717
|
});
|
|
5652
5718
|
invariant16(this._networkManager, "network manager not set", {
|
|
5653
5719
|
F: __dxlog_file19,
|
|
5654
|
-
L:
|
|
5720
|
+
L: 244,
|
|
5655
5721
|
S: this,
|
|
5656
5722
|
A: [
|
|
5657
5723
|
"this._networkManager",
|
|
@@ -5663,7 +5729,7 @@ var ClientServicesHost = class {
|
|
|
5663
5729
|
lockKey: this._resourceLock?.lockKey
|
|
5664
5730
|
}, {
|
|
5665
5731
|
F: __dxlog_file19,
|
|
5666
|
-
L:
|
|
5732
|
+
L: 247,
|
|
5667
5733
|
S: this,
|
|
5668
5734
|
C: (f, a) => f(...a)
|
|
5669
5735
|
});
|
|
@@ -5674,20 +5740,22 @@ var ClientServicesHost = class {
|
|
|
5674
5740
|
await this._resourceLock?.acquire();
|
|
5675
5741
|
await this._loggingService.open();
|
|
5676
5742
|
this._serviceContext = new ServiceContext(this._storage, this._level, this._networkManager, this._signalManager, this._runtimeParams);
|
|
5743
|
+
this._queryService = new QueryServiceImpl({
|
|
5744
|
+
indexer: this._serviceContext.indexer,
|
|
5745
|
+
automergeHost: this._serviceContext.automergeHost
|
|
5746
|
+
});
|
|
5747
|
+
await this._queryService.open(ctx);
|
|
5677
5748
|
this._serviceRegistry.setServices({
|
|
5678
5749
|
SystemService: this._systemService,
|
|
5679
5750
|
IdentityService: new IdentityServiceImpl((params) => this._createIdentity(params), this._serviceContext.identityManager, this._serviceContext.keyring, (profile) => this._serviceContext.broadcastProfileUpdate(profile)),
|
|
5680
|
-
InvitationsService: new InvitationsServiceImpl(this._serviceContext.
|
|
5751
|
+
InvitationsService: new InvitationsServiceImpl(this._serviceContext.invitationsManager),
|
|
5681
5752
|
DevicesService: new DevicesServiceImpl(this._serviceContext.identityManager),
|
|
5682
5753
|
SpacesService: new SpacesServiceImpl(this._serviceContext.identityManager, this._serviceContext.spaceManager, async () => {
|
|
5683
5754
|
await this._serviceContext.initialized.wait();
|
|
5684
5755
|
return this._serviceContext.dataSpaceManager;
|
|
5685
5756
|
}),
|
|
5686
5757
|
DataService: new DataServiceImpl(this._serviceContext.automergeHost),
|
|
5687
|
-
|
|
5688
|
-
indexer: this._serviceContext.indexer,
|
|
5689
|
-
automergeHost: this._serviceContext.automergeHost
|
|
5690
|
-
}),
|
|
5758
|
+
QueryService: this._queryService,
|
|
5691
5759
|
NetworkService: new NetworkServiceImpl(this._serviceContext.networkManager, this._serviceContext.signalManager),
|
|
5692
5760
|
LoggingService: this._loggingService,
|
|
5693
5761
|
TracingService: this._tracingService,
|
|
@@ -5699,24 +5767,6 @@ var ClientServicesHost = class {
|
|
|
5699
5767
|
})
|
|
5700
5768
|
});
|
|
5701
5769
|
await this._serviceContext.open(ctx);
|
|
5702
|
-
invariant16(this.serviceRegistry.services.InvitationsService, void 0, {
|
|
5703
|
-
F: __dxlog_file19,
|
|
5704
|
-
L: 314,
|
|
5705
|
-
S: this,
|
|
5706
|
-
A: [
|
|
5707
|
-
"this.serviceRegistry.services.InvitationsService",
|
|
5708
|
-
""
|
|
5709
|
-
]
|
|
5710
|
-
});
|
|
5711
|
-
const loadedInvitations = await this.serviceRegistry.services.InvitationsService.loadPersistentInvitations();
|
|
5712
|
-
log16("loaded persistent invitations", {
|
|
5713
|
-
count: loadedInvitations.invitations?.length
|
|
5714
|
-
}, {
|
|
5715
|
-
F: __dxlog_file19,
|
|
5716
|
-
L: 317,
|
|
5717
|
-
S: this,
|
|
5718
|
-
C: (f, a) => f(...a)
|
|
5719
|
-
});
|
|
5720
5770
|
const devtoolsProxy = this._config?.get("runtime.client.devtoolsProxy");
|
|
5721
5771
|
if (devtoolsProxy) {
|
|
5722
5772
|
this._devtoolsProxy = new WebsocketRpcClient({
|
|
@@ -5736,7 +5786,7 @@ var ClientServicesHost = class {
|
|
|
5736
5786
|
deviceKey
|
|
5737
5787
|
}, {
|
|
5738
5788
|
F: __dxlog_file19,
|
|
5739
|
-
L:
|
|
5789
|
+
L: 330,
|
|
5740
5790
|
S: this,
|
|
5741
5791
|
C: (f, a) => f(...a)
|
|
5742
5792
|
});
|
|
@@ -5744,7 +5794,7 @@ var ClientServicesHost = class {
|
|
|
5744
5794
|
id: traceId
|
|
5745
5795
|
}), {
|
|
5746
5796
|
F: __dxlog_file19,
|
|
5747
|
-
L:
|
|
5797
|
+
L: 331,
|
|
5748
5798
|
S: this,
|
|
5749
5799
|
C: (f, a) => f(...a)
|
|
5750
5800
|
});
|
|
@@ -5758,7 +5808,7 @@ var ClientServicesHost = class {
|
|
|
5758
5808
|
deviceKey
|
|
5759
5809
|
}, {
|
|
5760
5810
|
F: __dxlog_file19,
|
|
5761
|
-
L:
|
|
5811
|
+
L: 342,
|
|
5762
5812
|
S: this,
|
|
5763
5813
|
C: (f, a) => f(...a)
|
|
5764
5814
|
});
|
|
@@ -5768,6 +5818,7 @@ var ClientServicesHost = class {
|
|
|
5768
5818
|
SystemService: this._systemService
|
|
5769
5819
|
});
|
|
5770
5820
|
await this._loggingService.close();
|
|
5821
|
+
await this._queryService.close();
|
|
5771
5822
|
await this._serviceContext.close();
|
|
5772
5823
|
await this._level?.close();
|
|
5773
5824
|
this._open = false;
|
|
@@ -5776,7 +5827,7 @@ var ClientServicesHost = class {
|
|
|
5776
5827
|
deviceKey
|
|
5777
5828
|
}, {
|
|
5778
5829
|
F: __dxlog_file19,
|
|
5779
|
-
L:
|
|
5830
|
+
L: 352,
|
|
5780
5831
|
S: this,
|
|
5781
5832
|
C: (f, a) => f(...a)
|
|
5782
5833
|
});
|
|
@@ -5787,13 +5838,13 @@ var ClientServicesHost = class {
|
|
|
5787
5838
|
id: traceId
|
|
5788
5839
|
}), {
|
|
5789
5840
|
F: __dxlog_file19,
|
|
5790
|
-
L:
|
|
5841
|
+
L: 357,
|
|
5791
5842
|
S: this,
|
|
5792
5843
|
C: (f, a) => f(...a)
|
|
5793
5844
|
});
|
|
5794
5845
|
log16("resetting...", void 0, {
|
|
5795
5846
|
F: __dxlog_file19,
|
|
5796
|
-
L:
|
|
5847
|
+
L: 359,
|
|
5797
5848
|
S: this,
|
|
5798
5849
|
C: (f, a) => f(...a)
|
|
5799
5850
|
});
|
|
@@ -5801,7 +5852,7 @@ var ClientServicesHost = class {
|
|
|
5801
5852
|
await this._storage.reset();
|
|
5802
5853
|
log16("reset", void 0, {
|
|
5803
5854
|
F: __dxlog_file19,
|
|
5804
|
-
L:
|
|
5855
|
+
L: 362,
|
|
5805
5856
|
S: this,
|
|
5806
5857
|
C: (f, a) => f(...a)
|
|
5807
5858
|
});
|
|
@@ -5809,7 +5860,7 @@ var ClientServicesHost = class {
|
|
|
5809
5860
|
id: traceId
|
|
5810
5861
|
}), {
|
|
5811
5862
|
F: __dxlog_file19,
|
|
5812
|
-
L:
|
|
5863
|
+
L: 363,
|
|
5813
5864
|
S: this,
|
|
5814
5865
|
C: (f, a) => f(...a)
|
|
5815
5866
|
});
|
|
@@ -5822,7 +5873,7 @@ var ClientServicesHost = class {
|
|
|
5822
5873
|
const automergeIndex = space.automergeSpaceState.rootUrl;
|
|
5823
5874
|
invariant16(automergeIndex, void 0, {
|
|
5824
5875
|
F: __dxlog_file19,
|
|
5825
|
-
L:
|
|
5876
|
+
L: 375,
|
|
5826
5877
|
S: this,
|
|
5827
5878
|
A: [
|
|
5828
5879
|
"automergeIndex",
|
|
@@ -5833,7 +5884,7 @@ var ClientServicesHost = class {
|
|
|
5833
5884
|
await document.whenReady();
|
|
5834
5885
|
const properties = {
|
|
5835
5886
|
system: {
|
|
5836
|
-
type: encodeReference(
|
|
5887
|
+
type: encodeReference(getTypeReference(Properties))
|
|
5837
5888
|
},
|
|
5838
5889
|
data: {
|
|
5839
5890
|
[defaultKey]: identity.identityKey.toHex()
|
|
@@ -5931,6 +5982,7 @@ export {
|
|
|
5931
5982
|
createAdmissionKeypair,
|
|
5932
5983
|
InvitationsServiceImpl,
|
|
5933
5984
|
SpaceInvitationProtocol,
|
|
5985
|
+
InvitationsManager,
|
|
5934
5986
|
ClientRpcServer,
|
|
5935
5987
|
DataSpace,
|
|
5936
5988
|
DataSpaceManager,
|
|
@@ -5948,4 +6000,4 @@ export {
|
|
|
5948
6000
|
ClientServicesHost,
|
|
5949
6001
|
ClientServicesProviderResource
|
|
5950
6002
|
};
|
|
5951
|
-
//# sourceMappingURL=chunk-
|
|
6003
|
+
//# sourceMappingURL=chunk-GZI6A3HL.mjs.map
|