@dxos/client-services 0.4.10-main.f635fb0 → 0.4.10-main.f937af6
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-OYOZOELW.mjs → chunk-N2WDHCKA.mjs} +357 -311
- package/dist/lib/browser/chunk-N2WDHCKA.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 +1 -1
- package/dist/lib/node/{chunk-CLDZACGI.cjs → chunk-KIKQMYZ7.cjs} +353 -308
- package/dist/lib/node/chunk-KIKQMYZ7.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 +6 -6
- 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.map +1 -1
- package/dist/types/src/version.d.ts +1 -1
- package/package.json +34 -34
- package/src/packlets/indexing/util.ts +8 -3
- 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/service-context.ts +12 -1
- package/src/packlets/services/service-host.ts +1 -10
- package/src/version.ts +1 -1
- package/dist/lib/browser/chunk-OYOZOELW.mjs.map +0 -7
- package/dist/lib/node/chunk-CLDZACGI.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,9 +2840,9 @@ 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
2847
|
import { TYPE_PROPERTIES } from "@dxos/echo-db";
|
|
2798
2848
|
import { createMappedFeedWriter } from "@dxos/echo-pipeline";
|
|
@@ -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,7 +4345,7 @@ 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";
|
|
@@ -4306,14 +4356,13 @@ 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
|
/**
|
|
@@ -4325,7 +4374,9 @@ var createSelectedDocumentsIterator = (automergeHost) => (
|
|
|
4325
4374
|
for (const id of ids) {
|
|
4326
4375
|
const { documentId, objectId } = idCodec.decode(id);
|
|
4327
4376
|
const handle = automergeHost.repo.find(documentId);
|
|
4328
|
-
|
|
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) {
|
|
@@ -4448,20 +4501,21 @@ var ServiceContext = class extends Resource {
|
|
|
4448
4501
|
});
|
|
4449
4502
|
this.indexer = new Indexer({
|
|
4450
4503
|
indexStore: new IndexStore({
|
|
4451
|
-
db: level.sublevel("index-
|
|
4504
|
+
db: level.sublevel("index-storage")
|
|
4452
4505
|
}),
|
|
4453
4506
|
metadataStore: this.indexMetadata,
|
|
4454
4507
|
loadDocuments: createSelectedDocumentsIterator(this.automergeHost),
|
|
4455
4508
|
getAllDocuments: createDocumentsIterator(this.automergeHost)
|
|
4456
4509
|
});
|
|
4457
4510
|
this.invitations = new InvitationsHandler(this.networkManager);
|
|
4458
|
-
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)));
|
|
4459
4513
|
}
|
|
4460
4514
|
async _open(ctx) {
|
|
4461
4515
|
await this._checkStorageVersion();
|
|
4462
4516
|
log12("opening...", void 0, {
|
|
4463
4517
|
F: __dxlog_file14,
|
|
4464
|
-
L:
|
|
4518
|
+
L: 164,
|
|
4465
4519
|
S: this,
|
|
4466
4520
|
C: (f, a) => f(...a)
|
|
4467
4521
|
});
|
|
@@ -4469,7 +4523,7 @@ var ServiceContext = class extends Resource {
|
|
|
4469
4523
|
id: this._instanceId
|
|
4470
4524
|
}), {
|
|
4471
4525
|
F: __dxlog_file14,
|
|
4472
|
-
L:
|
|
4526
|
+
L: 165,
|
|
4473
4527
|
S: this,
|
|
4474
4528
|
C: (f, a) => f(...a)
|
|
4475
4529
|
});
|
|
@@ -4482,17 +4536,26 @@ var ServiceContext = class extends Resource {
|
|
|
4482
4536
|
if (this.identityManager.identity) {
|
|
4483
4537
|
await this._initialize(ctx);
|
|
4484
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
|
+
});
|
|
4485
4548
|
log12.trace("dxos.sdk.service-context.open", trace8.end({
|
|
4486
4549
|
id: this._instanceId
|
|
4487
4550
|
}), {
|
|
4488
4551
|
F: __dxlog_file14,
|
|
4489
|
-
L:
|
|
4552
|
+
L: 180,
|
|
4490
4553
|
S: this,
|
|
4491
4554
|
C: (f, a) => f(...a)
|
|
4492
4555
|
});
|
|
4493
4556
|
log12("opened", void 0, {
|
|
4494
4557
|
F: __dxlog_file14,
|
|
4495
|
-
L:
|
|
4558
|
+
L: 181,
|
|
4496
4559
|
S: this,
|
|
4497
4560
|
C: (f, a) => f(...a)
|
|
4498
4561
|
});
|
|
@@ -4500,7 +4563,7 @@ var ServiceContext = class extends Resource {
|
|
|
4500
4563
|
async _close() {
|
|
4501
4564
|
log12("closing...", void 0, {
|
|
4502
4565
|
F: __dxlog_file14,
|
|
4503
|
-
L:
|
|
4566
|
+
L: 185,
|
|
4504
4567
|
S: this,
|
|
4505
4568
|
C: (f, a) => f(...a)
|
|
4506
4569
|
});
|
|
@@ -4518,21 +4581,21 @@ var ServiceContext = class extends Resource {
|
|
|
4518
4581
|
await this.indexer.destroy();
|
|
4519
4582
|
log12("closed", void 0, {
|
|
4520
4583
|
F: __dxlog_file14,
|
|
4521
|
-
L:
|
|
4584
|
+
L: 198,
|
|
4522
4585
|
S: this,
|
|
4523
4586
|
C: (f, a) => f(...a)
|
|
4524
4587
|
});
|
|
4525
4588
|
}
|
|
4526
4589
|
async createIdentity(params = {}) {
|
|
4527
4590
|
const identity = await this.identityManager.createIdentity(params);
|
|
4528
|
-
await this._initialize(new
|
|
4591
|
+
await this._initialize(new Context9());
|
|
4529
4592
|
return identity;
|
|
4530
4593
|
}
|
|
4531
4594
|
getInvitationHandler(invitation) {
|
|
4532
4595
|
const factory = this._handlerFactories.get(invitation.kind);
|
|
4533
4596
|
invariant13(factory, `Unknown invitation kind: ${invitation.kind}`, {
|
|
4534
4597
|
F: __dxlog_file14,
|
|
4535
|
-
L:
|
|
4598
|
+
L: 209,
|
|
4536
4599
|
S: this,
|
|
4537
4600
|
A: [
|
|
4538
4601
|
"factory",
|
|
@@ -4551,7 +4614,7 @@ var ServiceContext = class extends Resource {
|
|
|
4551
4614
|
}
|
|
4552
4615
|
async _acceptIdentity(params) {
|
|
4553
4616
|
const identity = await this.identityManager.acceptIdentity(params);
|
|
4554
|
-
await this._initialize(new
|
|
4617
|
+
await this._initialize(new Context9());
|
|
4555
4618
|
return identity;
|
|
4556
4619
|
}
|
|
4557
4620
|
async _checkStorageVersion() {
|
|
@@ -4564,7 +4627,7 @@ var ServiceContext = class extends Resource {
|
|
|
4564
4627
|
async _initialize(ctx) {
|
|
4565
4628
|
log12("initializing spaces...", void 0, {
|
|
4566
4629
|
F: __dxlog_file14,
|
|
4567
|
-
L:
|
|
4630
|
+
L: 240,
|
|
4568
4631
|
S: this,
|
|
4569
4632
|
C: (f, a) => f(...a)
|
|
4570
4633
|
});
|
|
@@ -4584,10 +4647,10 @@ var ServiceContext = class extends Resource {
|
|
|
4584
4647
|
};
|
|
4585
4648
|
this.dataSpaceManager = new DataSpaceManager(this.spaceManager, this.metadataStore, this.keyring, signingContext, this.feedStore, this.automergeHost, this._runtimeParams);
|
|
4586
4649
|
await this.dataSpaceManager.open();
|
|
4587
|
-
this._handlerFactories.set(
|
|
4650
|
+
this._handlerFactories.set(Invitation5.Kind.SPACE, (invitation) => {
|
|
4588
4651
|
invariant13(this.dataSpaceManager, "dataSpaceManager not initialized yet", {
|
|
4589
4652
|
F: __dxlog_file14,
|
|
4590
|
-
L:
|
|
4653
|
+
L: 264,
|
|
4591
4654
|
S: this,
|
|
4592
4655
|
A: [
|
|
4593
4656
|
"this.dataSpaceManager",
|
|
@@ -4611,7 +4674,7 @@ var ServiceContext = class extends Resource {
|
|
|
4611
4674
|
details: assertion
|
|
4612
4675
|
}, {
|
|
4613
4676
|
F: __dxlog_file14,
|
|
4614
|
-
L:
|
|
4677
|
+
L: 280,
|
|
4615
4678
|
S: this,
|
|
4616
4679
|
C: (f, a) => f(...a)
|
|
4617
4680
|
});
|
|
@@ -4622,7 +4685,7 @@ var ServiceContext = class extends Resource {
|
|
|
4622
4685
|
details: assertion
|
|
4623
4686
|
}, {
|
|
4624
4687
|
F: __dxlog_file14,
|
|
4625
|
-
L:
|
|
4688
|
+
L: 284,
|
|
4626
4689
|
S: this,
|
|
4627
4690
|
C: (f, a) => f(...a)
|
|
4628
4691
|
});
|
|
@@ -4633,7 +4696,7 @@ var ServiceContext = class extends Resource {
|
|
|
4633
4696
|
details: assertion
|
|
4634
4697
|
}, {
|
|
4635
4698
|
F: __dxlog_file14,
|
|
4636
|
-
L:
|
|
4699
|
+
L: 289,
|
|
4637
4700
|
S: this,
|
|
4638
4701
|
C: (f, a) => f(...a)
|
|
4639
4702
|
});
|
|
@@ -4644,7 +4707,7 @@ var ServiceContext = class extends Resource {
|
|
|
4644
4707
|
} catch (err) {
|
|
4645
4708
|
log12.catch(err, void 0, {
|
|
4646
4709
|
F: __dxlog_file14,
|
|
4647
|
-
L:
|
|
4710
|
+
L: 295,
|
|
4648
4711
|
S: this,
|
|
4649
4712
|
C: (f, a) => f(...a)
|
|
4650
4713
|
});
|
|
@@ -4698,7 +4761,7 @@ import { SpaceMember as SpaceMember3 } from "@dxos/protocols/proto/dxos/client/s
|
|
|
4698
4761
|
import { TRACE_PROCESSOR } from "@dxos/tracing";
|
|
4699
4762
|
|
|
4700
4763
|
// packages/sdk/client-services/src/version.ts
|
|
4701
|
-
var DXOS_VERSION = "0.4.10-main.
|
|
4764
|
+
var DXOS_VERSION = "0.4.10-main.f937af6";
|
|
4702
4765
|
|
|
4703
4766
|
// packages/sdk/client-services/src/packlets/services/platform.ts
|
|
4704
4767
|
import { Platform } from "@dxos/protocols/proto/dxos/client/services";
|
|
@@ -4941,7 +5004,7 @@ import { jsonKeyReplacer as jsonKeyReplacer2, nonNullable } from "@dxos/util";
|
|
|
4941
5004
|
// packages/sdk/client-services/src/packlets/services/service-host.ts
|
|
4942
5005
|
import { Event as Event9, synchronized as synchronized3 } from "@dxos/async";
|
|
4943
5006
|
import { clientServiceBundle, defaultKey, Properties } from "@dxos/client-protocol";
|
|
4944
|
-
import { Context as
|
|
5007
|
+
import { Context as Context10 } from "@dxos/context";
|
|
4945
5008
|
import { DataServiceImpl, encodeReference } from "@dxos/echo-pipeline";
|
|
4946
5009
|
import { getTypeReference } from "@dxos/echo-schema";
|
|
4947
5010
|
import { IndexServiceImpl } from "@dxos/indexing";
|
|
@@ -5494,7 +5557,7 @@ var ClientServicesHost = class {
|
|
|
5494
5557
|
lockKey,
|
|
5495
5558
|
onAcquire: () => {
|
|
5496
5559
|
if (!this._opening) {
|
|
5497
|
-
void this.open(new
|
|
5560
|
+
void this.open(new Context10());
|
|
5498
5561
|
}
|
|
5499
5562
|
},
|
|
5500
5563
|
onRelease: () => this.close()
|
|
@@ -5680,7 +5743,7 @@ var ClientServicesHost = class {
|
|
|
5680
5743
|
this._serviceRegistry.setServices({
|
|
5681
5744
|
SystemService: this._systemService,
|
|
5682
5745
|
IdentityService: new IdentityServiceImpl((params) => this._createIdentity(params), this._serviceContext.identityManager, this._serviceContext.keyring, (profile) => this._serviceContext.broadcastProfileUpdate(profile)),
|
|
5683
|
-
InvitationsService: new InvitationsServiceImpl(this._serviceContext.
|
|
5746
|
+
InvitationsService: new InvitationsServiceImpl(this._serviceContext.invitationsManager),
|
|
5684
5747
|
DevicesService: new DevicesServiceImpl(this._serviceContext.identityManager),
|
|
5685
5748
|
SpacesService: new SpacesServiceImpl(this._serviceContext.identityManager, this._serviceContext.spaceManager, async () => {
|
|
5686
5749
|
await this._serviceContext.initialized.wait();
|
|
@@ -5702,24 +5765,6 @@ var ClientServicesHost = class {
|
|
|
5702
5765
|
})
|
|
5703
5766
|
});
|
|
5704
5767
|
await this._serviceContext.open(ctx);
|
|
5705
|
-
invariant16(this.serviceRegistry.services.InvitationsService, void 0, {
|
|
5706
|
-
F: __dxlog_file19,
|
|
5707
|
-
L: 314,
|
|
5708
|
-
S: this,
|
|
5709
|
-
A: [
|
|
5710
|
-
"this.serviceRegistry.services.InvitationsService",
|
|
5711
|
-
""
|
|
5712
|
-
]
|
|
5713
|
-
});
|
|
5714
|
-
const loadedInvitations = await this.serviceRegistry.services.InvitationsService.loadPersistentInvitations();
|
|
5715
|
-
log16("loaded persistent invitations", {
|
|
5716
|
-
count: loadedInvitations.invitations?.length
|
|
5717
|
-
}, {
|
|
5718
|
-
F: __dxlog_file19,
|
|
5719
|
-
L: 317,
|
|
5720
|
-
S: this,
|
|
5721
|
-
C: (f, a) => f(...a)
|
|
5722
|
-
});
|
|
5723
5768
|
const devtoolsProxy = this._config?.get("runtime.client.devtoolsProxy");
|
|
5724
5769
|
if (devtoolsProxy) {
|
|
5725
5770
|
this._devtoolsProxy = new WebsocketRpcClient({
|
|
@@ -5739,7 +5784,7 @@ var ClientServicesHost = class {
|
|
|
5739
5784
|
deviceKey
|
|
5740
5785
|
}, {
|
|
5741
5786
|
F: __dxlog_file19,
|
|
5742
|
-
L:
|
|
5787
|
+
L: 326,
|
|
5743
5788
|
S: this,
|
|
5744
5789
|
C: (f, a) => f(...a)
|
|
5745
5790
|
});
|
|
@@ -5747,7 +5792,7 @@ var ClientServicesHost = class {
|
|
|
5747
5792
|
id: traceId
|
|
5748
5793
|
}), {
|
|
5749
5794
|
F: __dxlog_file19,
|
|
5750
|
-
L:
|
|
5795
|
+
L: 327,
|
|
5751
5796
|
S: this,
|
|
5752
5797
|
C: (f, a) => f(...a)
|
|
5753
5798
|
});
|
|
@@ -5761,7 +5806,7 @@ var ClientServicesHost = class {
|
|
|
5761
5806
|
deviceKey
|
|
5762
5807
|
}, {
|
|
5763
5808
|
F: __dxlog_file19,
|
|
5764
|
-
L:
|
|
5809
|
+
L: 338,
|
|
5765
5810
|
S: this,
|
|
5766
5811
|
C: (f, a) => f(...a)
|
|
5767
5812
|
});
|
|
@@ -5779,7 +5824,7 @@ var ClientServicesHost = class {
|
|
|
5779
5824
|
deviceKey
|
|
5780
5825
|
}, {
|
|
5781
5826
|
F: __dxlog_file19,
|
|
5782
|
-
L:
|
|
5827
|
+
L: 347,
|
|
5783
5828
|
S: this,
|
|
5784
5829
|
C: (f, a) => f(...a)
|
|
5785
5830
|
});
|
|
@@ -5790,13 +5835,13 @@ var ClientServicesHost = class {
|
|
|
5790
5835
|
id: traceId
|
|
5791
5836
|
}), {
|
|
5792
5837
|
F: __dxlog_file19,
|
|
5793
|
-
L:
|
|
5838
|
+
L: 352,
|
|
5794
5839
|
S: this,
|
|
5795
5840
|
C: (f, a) => f(...a)
|
|
5796
5841
|
});
|
|
5797
5842
|
log16("resetting...", void 0, {
|
|
5798
5843
|
F: __dxlog_file19,
|
|
5799
|
-
L:
|
|
5844
|
+
L: 354,
|
|
5800
5845
|
S: this,
|
|
5801
5846
|
C: (f, a) => f(...a)
|
|
5802
5847
|
});
|
|
@@ -5804,7 +5849,7 @@ var ClientServicesHost = class {
|
|
|
5804
5849
|
await this._storage.reset();
|
|
5805
5850
|
log16("reset", void 0, {
|
|
5806
5851
|
F: __dxlog_file19,
|
|
5807
|
-
L:
|
|
5852
|
+
L: 357,
|
|
5808
5853
|
S: this,
|
|
5809
5854
|
C: (f, a) => f(...a)
|
|
5810
5855
|
});
|
|
@@ -5812,7 +5857,7 @@ var ClientServicesHost = class {
|
|
|
5812
5857
|
id: traceId
|
|
5813
5858
|
}), {
|
|
5814
5859
|
F: __dxlog_file19,
|
|
5815
|
-
L:
|
|
5860
|
+
L: 358,
|
|
5816
5861
|
S: this,
|
|
5817
5862
|
C: (f, a) => f(...a)
|
|
5818
5863
|
});
|
|
@@ -5825,7 +5870,7 @@ var ClientServicesHost = class {
|
|
|
5825
5870
|
const automergeIndex = space.automergeSpaceState.rootUrl;
|
|
5826
5871
|
invariant16(automergeIndex, void 0, {
|
|
5827
5872
|
F: __dxlog_file19,
|
|
5828
|
-
L:
|
|
5873
|
+
L: 370,
|
|
5829
5874
|
S: this,
|
|
5830
5875
|
A: [
|
|
5831
5876
|
"automergeIndex",
|
|
@@ -5934,6 +5979,7 @@ export {
|
|
|
5934
5979
|
createAdmissionKeypair,
|
|
5935
5980
|
InvitationsServiceImpl,
|
|
5936
5981
|
SpaceInvitationProtocol,
|
|
5982
|
+
InvitationsManager,
|
|
5937
5983
|
ClientRpcServer,
|
|
5938
5984
|
DataSpace,
|
|
5939
5985
|
DataSpaceManager,
|
|
@@ -5951,4 +5997,4 @@ export {
|
|
|
5951
5997
|
ClientServicesHost,
|
|
5952
5998
|
ClientServicesProviderResource
|
|
5953
5999
|
};
|
|
5954
|
-
//# sourceMappingURL=chunk-
|
|
6000
|
+
//# sourceMappingURL=chunk-N2WDHCKA.mjs.map
|