@dxos/client-services 0.1.52-main.e73bc9f → 0.1.52
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-2GQ7337P.mjs → chunk-C3SPTMW3.mjs} +238 -261
- package/dist/lib/browser/{chunk-2GQ7337P.mjs.map → chunk-C3SPTMW3.mjs.map} +4 -4
- package/dist/lib/browser/index.mjs +3 -5
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/packlets/testing/index.mjs +1 -1
- package/dist/lib/node/index.cjs +440 -462
- package/dist/lib/node/index.cjs.map +4 -4
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/packlets/testing/index.cjs +1496 -1494
- package/dist/lib/node/packlets/testing/index.cjs.map +4 -4
- package/dist/types/src/packlets/services/index.d.ts +0 -1
- package/dist/types/src/packlets/services/index.d.ts.map +1 -1
- package/dist/types/src/packlets/vault/iframe-host-runtime.d.ts +2 -2
- package/dist/types/src/packlets/vault/iframe-host-runtime.d.ts.map +1 -1
- package/package.json +32 -32
- package/src/packlets/services/index.ts +0 -1
- package/src/packlets/vault/iframe-host-runtime.ts +4 -4
- package/dist/types/src/packlets/services/local-client-services.d.ts +0 -16
- package/dist/types/src/packlets/services/local-client-services.d.ts.map +0 -1
- package/src/packlets/services/local-client-services.ts +0 -39
package/dist/lib/node/index.cjs
CHANGED
|
@@ -43,7 +43,6 @@ __export(src_exports, {
|
|
|
43
43
|
IdentityServiceImpl: () => IdentityServiceImpl,
|
|
44
44
|
InvitationsHandler: () => InvitationsHandler,
|
|
45
45
|
InvitationsServiceImpl: () => InvitationsServiceImpl,
|
|
46
|
-
LocalClientServices: () => LocalClientServices,
|
|
47
46
|
Lock: () => Lock,
|
|
48
47
|
MemoryShellRuntime: () => MemoryShellRuntime,
|
|
49
48
|
ServiceContext: () => ServiceContext,
|
|
@@ -2140,260 +2139,55 @@ var SpaceInvitationProtocol = class {
|
|
|
2140
2139
|
}
|
|
2141
2140
|
};
|
|
2142
2141
|
|
|
2143
|
-
// packages/sdk/client-services/src/packlets/services/service-
|
|
2144
|
-
var import_node_assert13 = __toESM(require("node:assert"));
|
|
2145
|
-
var import_async17 = require("@dxos/async");
|
|
2146
|
-
var import_client_protocol5 = require("@dxos/client-protocol");
|
|
2147
|
-
var import_echo_pipeline4 = require("@dxos/echo-pipeline");
|
|
2148
|
-
var import_keys11 = require("@dxos/keys");
|
|
2149
|
-
var import_log15 = require("@dxos/log");
|
|
2150
|
-
var import_messaging = require("@dxos/messaging");
|
|
2151
|
-
var import_network_manager2 = require("@dxos/network-manager");
|
|
2152
|
-
var import_protocols9 = require("@dxos/protocols");
|
|
2153
|
-
var import_services12 = require("@dxos/protocols/proto/dxos/client/services");
|
|
2154
|
-
|
|
2155
|
-
// packages/sdk/client-services/src/packlets/devices/devices-service.ts
|
|
2156
|
-
var import_async10 = require("@dxos/async");
|
|
2157
|
-
var import_codec_protobuf9 = require("@dxos/codec-protobuf");
|
|
2158
|
-
var import_services6 = require("@dxos/protocols/proto/dxos/client/services");
|
|
2159
|
-
var DevicesServiceImpl = class {
|
|
2160
|
-
constructor(_identityManager) {
|
|
2161
|
-
this._identityManager = _identityManager;
|
|
2162
|
-
}
|
|
2163
|
-
updateDevice(request) {
|
|
2164
|
-
throw new Error("Method not implemented.");
|
|
2165
|
-
}
|
|
2166
|
-
queryDevices() {
|
|
2167
|
-
return new import_codec_protobuf9.Stream(({ next }) => {
|
|
2168
|
-
const update = () => {
|
|
2169
|
-
var _a;
|
|
2170
|
-
const deviceKeys = (_a = this._identityManager.identity) == null ? void 0 : _a.authorizedDeviceKeys;
|
|
2171
|
-
if (!deviceKeys) {
|
|
2172
|
-
next({
|
|
2173
|
-
devices: []
|
|
2174
|
-
});
|
|
2175
|
-
} else {
|
|
2176
|
-
next({
|
|
2177
|
-
devices: Array.from(deviceKeys.values()).map((key) => {
|
|
2178
|
-
var _a2;
|
|
2179
|
-
return {
|
|
2180
|
-
deviceKey: key,
|
|
2181
|
-
kind: ((_a2 = this._identityManager.identity) == null ? void 0 : _a2.deviceKey.equals(key)) ? import_services6.DeviceKind.CURRENT : import_services6.DeviceKind.TRUSTED
|
|
2182
|
-
};
|
|
2183
|
-
})
|
|
2184
|
-
});
|
|
2185
|
-
}
|
|
2186
|
-
};
|
|
2187
|
-
const subscriptions = new import_async10.EventSubscriptions();
|
|
2188
|
-
subscriptions.add(this._identityManager.stateUpdate.on(() => {
|
|
2189
|
-
update();
|
|
2190
|
-
if (this._identityManager.identity) {
|
|
2191
|
-
subscriptions.add(this._identityManager.identity.stateUpdate.on(() => {
|
|
2192
|
-
update();
|
|
2193
|
-
}));
|
|
2194
|
-
}
|
|
2195
|
-
}));
|
|
2196
|
-
update();
|
|
2197
|
-
return () => subscriptions.clear();
|
|
2198
|
-
});
|
|
2199
|
-
}
|
|
2200
|
-
};
|
|
2201
|
-
|
|
2202
|
-
// packages/sdk/client-services/src/packlets/locks/node.ts
|
|
2203
|
-
var import_node_assert9 = __toESM(require("node:assert"));
|
|
2204
|
-
var import_lock_file = require("@dxos/lock-file");
|
|
2205
|
-
var import_log8 = require("@dxos/log");
|
|
2206
|
-
var __decorate = function(decorators, target, key, desc) {
|
|
2207
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2208
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
2209
|
-
r = Reflect.decorate(decorators, target, key, desc);
|
|
2210
|
-
else
|
|
2211
|
-
for (var i = decorators.length - 1; i >= 0; i--)
|
|
2212
|
-
if (d = decorators[i])
|
|
2213
|
-
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
2214
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2215
|
-
};
|
|
2216
|
-
var Lock = class {
|
|
2217
|
-
constructor({ lockKey: lockPath, onAcquire, onRelease }) {
|
|
2218
|
-
this._lockPath = lockPath;
|
|
2219
|
-
this._onAcquire = onAcquire;
|
|
2220
|
-
this._onRelease = onRelease;
|
|
2221
|
-
}
|
|
2222
|
-
get lockKey() {
|
|
2223
|
-
return this._lockPath;
|
|
2224
|
-
}
|
|
2225
|
-
async acquire() {
|
|
2226
|
-
var _a;
|
|
2227
|
-
(0, import_log8.log)("acquiring lock...", {}, {
|
|
2228
|
-
file: "node.ts",
|
|
2229
|
-
line: 32,
|
|
2230
|
-
scope: this,
|
|
2231
|
-
callSite: (f, a) => f(...a)
|
|
2232
|
-
});
|
|
2233
|
-
this._fileHandle = await import_lock_file.LockFile.acquire(this._lockPath);
|
|
2234
|
-
await ((_a = this._onAcquire) == null ? void 0 : _a.call(this));
|
|
2235
|
-
(0, import_log8.log)("acquired lock", {}, {
|
|
2236
|
-
file: "node.ts",
|
|
2237
|
-
line: 37,
|
|
2238
|
-
scope: this,
|
|
2239
|
-
callSite: (f, a) => f(...a)
|
|
2240
|
-
});
|
|
2241
|
-
}
|
|
2242
|
-
async release() {
|
|
2243
|
-
var _a;
|
|
2244
|
-
await ((_a = this._onRelease) == null ? void 0 : _a.call(this));
|
|
2245
|
-
(0, import_node_assert9.default)(this._fileHandle, "Lock is not acquired");
|
|
2246
|
-
await import_lock_file.LockFile.release(this._fileHandle);
|
|
2247
|
-
}
|
|
2248
|
-
};
|
|
2249
|
-
__decorate([
|
|
2250
|
-
import_log8.logInfo
|
|
2251
|
-
], Lock.prototype, "lockKey", null);
|
|
2252
|
-
var isLocked = (lockPath) => import_lock_file.LockFile.isLocked(lockPath);
|
|
2253
|
-
|
|
2254
|
-
// packages/sdk/client-services/src/packlets/logging/logging-service.ts
|
|
2255
|
-
var import_async11 = require("@dxos/async");
|
|
2256
|
-
var import_codec_protobuf10 = require("@dxos/codec-protobuf");
|
|
2257
|
-
var import_log9 = require("@dxos/log");
|
|
2258
|
-
var import_services7 = require("@dxos/protocols/proto/dxos/client/services");
|
|
2259
|
-
var import_util3 = require("@dxos/util");
|
|
2260
|
-
var LoggingServiceImpl = class {
|
|
2261
|
-
constructor() {
|
|
2262
|
-
this._logs = new import_async11.Event();
|
|
2263
|
-
this._logProcessor = (_config, entry2) => {
|
|
2264
|
-
this._logs.emit(entry2);
|
|
2265
|
-
};
|
|
2266
|
-
}
|
|
2267
|
-
async open() {
|
|
2268
|
-
import_log9.log.runtimeConfig.processors.push(this._logProcessor);
|
|
2269
|
-
}
|
|
2270
|
-
async close() {
|
|
2271
|
-
const index = import_log9.log.runtimeConfig.processors.findIndex((processor) => processor === this._logProcessor);
|
|
2272
|
-
import_log9.log.runtimeConfig.processors.splice(index, 1);
|
|
2273
|
-
}
|
|
2274
|
-
queryLogs(request) {
|
|
2275
|
-
return new import_codec_protobuf10.Stream(({ ctx, next }) => {
|
|
2276
|
-
const handler = (entry2) => {
|
|
2277
|
-
var _a, _b, _c, _d, _e;
|
|
2278
|
-
if (LOG_PROCESSING > 0) {
|
|
2279
|
-
return;
|
|
2280
|
-
}
|
|
2281
|
-
if (((_a = entry2.meta) == null ? void 0 : _a.file.includes("logging-service")) || entry2.context && Object.values(entry2.context).some((value) => typeof value === "string" && value.includes("LoggingService"))) {
|
|
2282
|
-
return;
|
|
2283
|
-
}
|
|
2284
|
-
if (!shouldLog(entry2, request)) {
|
|
2285
|
-
return;
|
|
2286
|
-
}
|
|
2287
|
-
const record = {
|
|
2288
|
-
...entry2,
|
|
2289
|
-
context: (0, import_util3.jsonify)((0, import_log9.getContextFromEntry)(entry2)),
|
|
2290
|
-
timestamp: new Date(),
|
|
2291
|
-
meta: {
|
|
2292
|
-
// TODO(dmaretskyi): Fix proto.
|
|
2293
|
-
file: (_c = (_b = entry2.meta) == null ? void 0 : _b.file) != null ? _c : "",
|
|
2294
|
-
line: (_e = (_d = entry2.meta) == null ? void 0 : _d.line) != null ? _e : 0
|
|
2295
|
-
}
|
|
2296
|
-
};
|
|
2297
|
-
try {
|
|
2298
|
-
LOG_PROCESSING++;
|
|
2299
|
-
next(record);
|
|
2300
|
-
} finally {
|
|
2301
|
-
LOG_PROCESSING--;
|
|
2302
|
-
}
|
|
2303
|
-
};
|
|
2304
|
-
this._logs.on(ctx, handler);
|
|
2305
|
-
});
|
|
2306
|
-
}
|
|
2307
|
-
};
|
|
2308
|
-
var matchFilter = (filter, level, path, options) => {
|
|
2309
|
-
switch (options) {
|
|
2310
|
-
case import_services7.QueryLogsRequest.MatchingOptions.INCLUSIVE:
|
|
2311
|
-
return level >= filter.level && (!filter.pattern || path.includes(filter.pattern));
|
|
2312
|
-
case import_services7.QueryLogsRequest.MatchingOptions.EXPLICIT:
|
|
2313
|
-
return level === filter.level && (!filter.pattern || path.includes(filter.pattern));
|
|
2314
|
-
}
|
|
2315
|
-
};
|
|
2316
|
-
var shouldLog = (entry2, request) => {
|
|
2317
|
-
var _a;
|
|
2318
|
-
const options = (_a = request.options) != null ? _a : import_services7.QueryLogsRequest.MatchingOptions.INCLUSIVE;
|
|
2319
|
-
if (request.filters === void 0) {
|
|
2320
|
-
return options === import_services7.QueryLogsRequest.MatchingOptions.INCLUSIVE;
|
|
2321
|
-
} else {
|
|
2322
|
-
return request.filters.some((filter) => {
|
|
2323
|
-
var _a2, _b;
|
|
2324
|
-
return matchFilter(filter, entry2.level, (_b = (_a2 = entry2.meta) == null ? void 0 : _a2.file) != null ? _b : "", options);
|
|
2325
|
-
});
|
|
2326
|
-
}
|
|
2327
|
-
};
|
|
2328
|
-
var LOG_PROCESSING = 0;
|
|
2329
|
-
|
|
2330
|
-
// packages/sdk/client-services/src/packlets/network/network-service.ts
|
|
2331
|
-
var import_codec_protobuf11 = require("@dxos/codec-protobuf");
|
|
2332
|
-
var NetworkServiceImpl = class {
|
|
2333
|
-
constructor(networkManager, signalManager) {
|
|
2334
|
-
this.networkManager = networkManager;
|
|
2335
|
-
this.signalManager = signalManager;
|
|
2336
|
-
}
|
|
2337
|
-
queryStatus() {
|
|
2338
|
-
return new import_codec_protobuf11.Stream(({ next }) => {
|
|
2339
|
-
const update = () => {
|
|
2340
|
-
next({
|
|
2341
|
-
swarm: this.networkManager.connectionState,
|
|
2342
|
-
signaling: this.signalManager.getStatus().map(({ host, state }) => ({
|
|
2343
|
-
server: host,
|
|
2344
|
-
state
|
|
2345
|
-
}))
|
|
2346
|
-
});
|
|
2347
|
-
};
|
|
2348
|
-
const unsubscribeSwarm = this.networkManager.connectionStateChanged.on(() => update());
|
|
2349
|
-
const unsubscribeSignal = this.signalManager.statusChanged.on(() => update());
|
|
2350
|
-
update();
|
|
2351
|
-
return () => {
|
|
2352
|
-
unsubscribeSwarm();
|
|
2353
|
-
unsubscribeSignal();
|
|
2354
|
-
};
|
|
2355
|
-
});
|
|
2356
|
-
}
|
|
2357
|
-
async updateConfig(request) {
|
|
2358
|
-
await this.networkManager.setConnectionState(request.swarm);
|
|
2359
|
-
}
|
|
2360
|
-
};
|
|
2361
|
-
|
|
2362
|
-
// packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts
|
|
2142
|
+
// packages/sdk/client-services/src/packlets/services/service-context.ts
|
|
2363
2143
|
var import_node_assert11 = __toESM(require("node:assert"));
|
|
2364
2144
|
var import_async14 = require("@dxos/async");
|
|
2145
|
+
var import_credentials13 = require("@dxos/credentials");
|
|
2146
|
+
var import_debug6 = require("@dxos/debug");
|
|
2147
|
+
var import_echo_pipeline3 = require("@dxos/echo-pipeline");
|
|
2148
|
+
var import_feed_store4 = require("@dxos/feed-store");
|
|
2149
|
+
var import_keyring = require("@dxos/keyring");
|
|
2150
|
+
var import_keys10 = require("@dxos/keys");
|
|
2151
|
+
var import_log12 = require("@dxos/log");
|
|
2152
|
+
var import_protocols8 = require("@dxos/protocols");
|
|
2153
|
+
var import_services9 = require("@dxos/protocols/proto/dxos/client/services");
|
|
2154
|
+
var import_teleport_extension_object_sync = require("@dxos/teleport-extension-object-sync");
|
|
2155
|
+
|
|
2156
|
+
// packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts
|
|
2157
|
+
var import_node_assert10 = __toESM(require("node:assert"));
|
|
2158
|
+
var import_async12 = require("@dxos/async");
|
|
2365
2159
|
var import_context7 = require("@dxos/context");
|
|
2366
2160
|
var import_credentials12 = require("@dxos/credentials");
|
|
2367
2161
|
var import_keys9 = require("@dxos/keys");
|
|
2368
|
-
var
|
|
2162
|
+
var import_log10 = require("@dxos/log");
|
|
2369
2163
|
var import_protocols6 = require("@dxos/protocols");
|
|
2370
|
-
var
|
|
2164
|
+
var import_services7 = require("@dxos/protocols/proto/dxos/client/services");
|
|
2371
2165
|
var import_teleport_extension_gossip = require("@dxos/teleport-extension-gossip");
|
|
2372
|
-
var
|
|
2166
|
+
var import_util5 = require("@dxos/util");
|
|
2373
2167
|
|
|
2374
2168
|
// packages/sdk/client-services/src/packlets/spaces/data-space.ts
|
|
2375
|
-
var
|
|
2169
|
+
var import_async11 = require("@dxos/async");
|
|
2376
2170
|
var import_client_protocol3 = require("@dxos/client-protocol");
|
|
2377
2171
|
var import_context6 = require("@dxos/context");
|
|
2378
2172
|
var import_debug3 = require("@dxos/debug");
|
|
2379
2173
|
var import_echo_pipeline = require("@dxos/echo-pipeline");
|
|
2380
2174
|
var import_errors3 = require("@dxos/errors");
|
|
2381
2175
|
var import_keys8 = require("@dxos/keys");
|
|
2382
|
-
var
|
|
2383
|
-
var
|
|
2176
|
+
var import_log9 = require("@dxos/log");
|
|
2177
|
+
var import_services6 = require("@dxos/protocols/proto/dxos/client/services");
|
|
2384
2178
|
var import_credentials9 = require("@dxos/protocols/proto/dxos/halo/credentials");
|
|
2385
2179
|
var import_timeframe = require("@dxos/timeframe");
|
|
2386
|
-
var
|
|
2180
|
+
var import_util4 = require("@dxos/util");
|
|
2387
2181
|
|
|
2388
2182
|
// packages/sdk/client-services/src/packlets/spaces/notarization-plugin.ts
|
|
2389
|
-
var
|
|
2390
|
-
var
|
|
2183
|
+
var import_node_assert9 = __toESM(require("node:assert"));
|
|
2184
|
+
var import_async10 = require("@dxos/async");
|
|
2391
2185
|
var import_context5 = require("@dxos/context");
|
|
2392
2186
|
var import_keys7 = require("@dxos/keys");
|
|
2393
|
-
var
|
|
2187
|
+
var import_log8 = require("@dxos/log");
|
|
2394
2188
|
var import_protocols5 = require("@dxos/protocols");
|
|
2395
2189
|
var import_teleport2 = require("@dxos/teleport");
|
|
2396
|
-
var
|
|
2190
|
+
var import_util3 = require("@dxos/util");
|
|
2397
2191
|
var DEFAULT_RETRY_TIMEOUT = 1e3;
|
|
2398
2192
|
var DEFAULT_SUCCESS_DELAY = 1e3;
|
|
2399
2193
|
var DEFAULT_NOTARIZE_TIMEOUT = 1e4;
|
|
@@ -2401,10 +2195,10 @@ var WRITER_NOT_SET_ERROR_CODE = "WRITER_NOT_SET";
|
|
|
2401
2195
|
var NotarizationPlugin = class {
|
|
2402
2196
|
constructor() {
|
|
2403
2197
|
this._ctx = new import_context5.Context();
|
|
2404
|
-
this._extensionOpened = new
|
|
2198
|
+
this._extensionOpened = new import_async10.Event();
|
|
2405
2199
|
this._extensions = /* @__PURE__ */ new Set();
|
|
2406
|
-
this._processedCredentials = new
|
|
2407
|
-
this._processCredentialsTriggers = new
|
|
2200
|
+
this._processedCredentials = new import_util3.ComplexSet(import_keys7.PublicKey.hash);
|
|
2201
|
+
this._processCredentialsTriggers = new import_util3.ComplexMap(import_keys7.PublicKey.hash);
|
|
2408
2202
|
}
|
|
2409
2203
|
async open() {
|
|
2410
2204
|
}
|
|
@@ -2415,7 +2209,7 @@ var NotarizationPlugin = class {
|
|
|
2415
2209
|
* Request credentials to be notarized.
|
|
2416
2210
|
*/
|
|
2417
2211
|
async notarize({ ctx: opCtx, credentials, timeout = DEFAULT_NOTARIZE_TIMEOUT, retryTimeout = DEFAULT_RETRY_TIMEOUT, successDelay = DEFAULT_SUCCESS_DELAY }) {
|
|
2418
|
-
(0,
|
|
2212
|
+
(0, import_log8.log)("notarize", {
|
|
2419
2213
|
credentials
|
|
2420
2214
|
}, {
|
|
2421
2215
|
file: "notarization-plugin.ts",
|
|
@@ -2423,11 +2217,11 @@ var NotarizationPlugin = class {
|
|
|
2423
2217
|
scope: this,
|
|
2424
2218
|
callSite: (f, a) => f(...a)
|
|
2425
2219
|
});
|
|
2426
|
-
(0,
|
|
2427
|
-
const errors = new
|
|
2220
|
+
(0, import_node_assert9.default)(credentials.every((credential) => credential.id), "Credentials must have an id");
|
|
2221
|
+
const errors = new import_async10.Trigger();
|
|
2428
2222
|
const ctx = this._ctx.derive({
|
|
2429
2223
|
onError: (err) => {
|
|
2430
|
-
|
|
2224
|
+
import_log8.log.warn("Notarization error", {
|
|
2431
2225
|
err
|
|
2432
2226
|
}, {
|
|
2433
2227
|
file: "notarization-plugin.ts",
|
|
@@ -2441,8 +2235,8 @@ var NotarizationPlugin = class {
|
|
|
2441
2235
|
});
|
|
2442
2236
|
opCtx == null ? void 0 : opCtx.onDispose(() => ctx.dispose());
|
|
2443
2237
|
if (timeout !== 0) {
|
|
2444
|
-
(0,
|
|
2445
|
-
|
|
2238
|
+
(0, import_async10.scheduleTask)(ctx, () => {
|
|
2239
|
+
import_log8.log.warn("Notarization timeout", {
|
|
2446
2240
|
timeout,
|
|
2447
2241
|
peers: Array.from(this._extensions).map((extension) => extension.remotePeerId)
|
|
2448
2242
|
}, {
|
|
@@ -2452,12 +2246,12 @@ var NotarizationPlugin = class {
|
|
|
2452
2246
|
callSite: (f, a) => f(...a)
|
|
2453
2247
|
});
|
|
2454
2248
|
void ctx.dispose();
|
|
2455
|
-
errors.throw(new
|
|
2249
|
+
errors.throw(new import_async10.TimeoutError(timeout, "Notarization timed out"));
|
|
2456
2250
|
}, timeout);
|
|
2457
2251
|
}
|
|
2458
2252
|
const allNotarized = Promise.all(credentials.map((credential) => this._waitUntilProcessed(credential.id)));
|
|
2459
2253
|
const peersTried = /* @__PURE__ */ new Set();
|
|
2460
|
-
const notarizeTask = new
|
|
2254
|
+
const notarizeTask = new import_async10.DeferredTask(ctx, async () => {
|
|
2461
2255
|
try {
|
|
2462
2256
|
if (this._extensions.size === 0) {
|
|
2463
2257
|
return;
|
|
@@ -2466,7 +2260,7 @@ var NotarizationPlugin = class {
|
|
|
2466
2260
|
...this._extensions
|
|
2467
2261
|
].find((peer2) => !peersTried.has(peer2));
|
|
2468
2262
|
if (!peer) {
|
|
2469
|
-
|
|
2263
|
+
import_log8.log.warn("Exhausted all peers to notarize with", {
|
|
2470
2264
|
retryIn: retryTimeout
|
|
2471
2265
|
}, {
|
|
2472
2266
|
file: "notarization-plugin.ts",
|
|
@@ -2475,11 +2269,11 @@ var NotarizationPlugin = class {
|
|
|
2475
2269
|
callSite: (f, a) => f(...a)
|
|
2476
2270
|
});
|
|
2477
2271
|
peersTried.clear();
|
|
2478
|
-
(0,
|
|
2272
|
+
(0, import_async10.scheduleTask)(ctx, () => notarizeTask.schedule(), retryTimeout);
|
|
2479
2273
|
return;
|
|
2480
2274
|
}
|
|
2481
2275
|
peersTried.add(peer);
|
|
2482
|
-
(0,
|
|
2276
|
+
(0, import_log8.log)("try notarizing", {
|
|
2483
2277
|
peer: peer.localPeerId,
|
|
2484
2278
|
credentialId: credentials.map((credential) => credential.id)
|
|
2485
2279
|
}, {
|
|
@@ -2491,16 +2285,16 @@ var NotarizationPlugin = class {
|
|
|
2491
2285
|
await peer.rpc.NotarizationService.notarize({
|
|
2492
2286
|
credentials: credentials.filter((credential) => !this._processedCredentials.has(credential.id))
|
|
2493
2287
|
});
|
|
2494
|
-
(0,
|
|
2288
|
+
(0, import_log8.log)("success", {}, {
|
|
2495
2289
|
file: "notarization-plugin.ts",
|
|
2496
2290
|
line: 144,
|
|
2497
2291
|
scope: this,
|
|
2498
2292
|
callSite: (f, a) => f(...a)
|
|
2499
2293
|
});
|
|
2500
|
-
await (0,
|
|
2294
|
+
await (0, import_async10.sleep)(successDelay);
|
|
2501
2295
|
} catch (err) {
|
|
2502
2296
|
if (!ctx.disposed && !err.message.includes(WRITER_NOT_SET_ERROR_CODE)) {
|
|
2503
|
-
|
|
2297
|
+
import_log8.log.warn("error notarizing (recoverable)", err, {
|
|
2504
2298
|
file: "notarization-plugin.ts",
|
|
2505
2299
|
line: 148,
|
|
2506
2300
|
scope: this,
|
|
@@ -2518,7 +2312,7 @@ var NotarizationPlugin = class {
|
|
|
2518
2312
|
allNotarized,
|
|
2519
2313
|
errors.wait()
|
|
2520
2314
|
]);
|
|
2521
|
-
(0,
|
|
2315
|
+
(0, import_log8.log)("done", {}, {
|
|
2522
2316
|
file: "notarization-plugin.ts",
|
|
2523
2317
|
line: 159,
|
|
2524
2318
|
scope: this,
|
|
@@ -2541,14 +2335,14 @@ var NotarizationPlugin = class {
|
|
|
2541
2335
|
this._processCredentialsTriggers.delete(credential.id);
|
|
2542
2336
|
}
|
|
2543
2337
|
setWriter(writer) {
|
|
2544
|
-
(0,
|
|
2338
|
+
(0, import_node_assert9.default)(!this._writer, "Writer already set.");
|
|
2545
2339
|
this._writer = writer;
|
|
2546
2340
|
}
|
|
2547
2341
|
async _waitUntilProcessed(id) {
|
|
2548
2342
|
if (this._processedCredentials.has(id)) {
|
|
2549
2343
|
return;
|
|
2550
2344
|
}
|
|
2551
|
-
await (0,
|
|
2345
|
+
await (0, import_util3.entry)(this._processCredentialsTriggers, id).orInsert(new import_async10.Trigger()).value.wait();
|
|
2552
2346
|
}
|
|
2553
2347
|
/**
|
|
2554
2348
|
* Requests from other peers to notarize credentials.
|
|
@@ -2559,7 +2353,7 @@ var NotarizationPlugin = class {
|
|
|
2559
2353
|
throw new Error(WRITER_NOT_SET_ERROR_CODE);
|
|
2560
2354
|
}
|
|
2561
2355
|
for (const credential of (_a = request.credentials) != null ? _a : []) {
|
|
2562
|
-
(0,
|
|
2356
|
+
(0, import_node_assert9.default)(credential.id, "Credential must have an id");
|
|
2563
2357
|
if (this._processedCredentials.has(credential.id)) {
|
|
2564
2358
|
continue;
|
|
2565
2359
|
}
|
|
@@ -2569,7 +2363,7 @@ var NotarizationPlugin = class {
|
|
|
2569
2363
|
createExtension() {
|
|
2570
2364
|
const extension = new NotarizationTeleportExtension({
|
|
2571
2365
|
onOpen: async () => {
|
|
2572
|
-
(0,
|
|
2366
|
+
(0, import_log8.log)("extension opened", {
|
|
2573
2367
|
peer: extension.localPeerId
|
|
2574
2368
|
}, {
|
|
2575
2369
|
file: "notarization-plugin.ts",
|
|
@@ -2581,7 +2375,7 @@ var NotarizationPlugin = class {
|
|
|
2581
2375
|
this._extensionOpened.emit();
|
|
2582
2376
|
},
|
|
2583
2377
|
onClose: async () => {
|
|
2584
|
-
(0,
|
|
2378
|
+
(0, import_log8.log)("extension closed", {
|
|
2585
2379
|
peer: extension.localPeerId
|
|
2586
2380
|
}, {
|
|
2587
2381
|
file: "notarization-plugin.ts",
|
|
@@ -2628,7 +2422,7 @@ var NotarizationTeleportExtension = class extends import_teleport2.RpcExtension
|
|
|
2628
2422
|
};
|
|
2629
2423
|
|
|
2630
2424
|
// packages/sdk/client-services/src/packlets/spaces/data-space.ts
|
|
2631
|
-
var
|
|
2425
|
+
var __decorate = function(decorators, target, key, desc) {
|
|
2632
2426
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2633
2427
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
2634
2428
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -2641,12 +2435,12 @@ var __decorate2 = function(decorators, target, key, desc) {
|
|
|
2641
2435
|
var DataSpace = class DataSpace2 {
|
|
2642
2436
|
constructor(params) {
|
|
2643
2437
|
this._ctx = new import_context6.Context();
|
|
2644
|
-
this._state =
|
|
2438
|
+
this._state = import_services6.SpaceState.CLOSED;
|
|
2645
2439
|
/**
|
|
2646
2440
|
* Error for _state === SpaceState.ERROR.
|
|
2647
2441
|
*/
|
|
2648
2442
|
this.error = void 0;
|
|
2649
|
-
this.stateUpdate = new
|
|
2443
|
+
this.stateUpdate = new import_async11.Event();
|
|
2650
2444
|
this.metrics = {};
|
|
2651
2445
|
var _a;
|
|
2652
2446
|
this._inner = params.inner;
|
|
@@ -2659,7 +2453,7 @@ var DataSpace = class DataSpace2 {
|
|
|
2659
2453
|
this._signingContext = params.signingContext;
|
|
2660
2454
|
this._callbacks = (_a = params.callbacks) != null ? _a : {};
|
|
2661
2455
|
this.authVerifier = new TrustedKeySetAuthVerifier({
|
|
2662
|
-
trustedKeysProvider: () => new
|
|
2456
|
+
trustedKeysProvider: () => new import_util4.ComplexSet(import_keys8.PublicKey.hash, Array.from(this._inner.spaceState.members.keys())),
|
|
2663
2457
|
update: this._inner.stateUpdate,
|
|
2664
2458
|
authTimeout: import_client_protocol3.AUTH_TIMEOUT
|
|
2665
2459
|
});
|
|
@@ -2695,11 +2489,11 @@ var DataSpace = class DataSpace2 {
|
|
|
2695
2489
|
await this.notarizationPlugin.open();
|
|
2696
2490
|
await this._notarizationPluginConsumer.open();
|
|
2697
2491
|
await this._inner.open();
|
|
2698
|
-
this._state =
|
|
2492
|
+
this._state = import_services6.SpaceState.INACTIVE;
|
|
2699
2493
|
this.metrics.open = new Date();
|
|
2700
2494
|
}
|
|
2701
2495
|
async close() {
|
|
2702
|
-
this._state =
|
|
2496
|
+
this._state = import_services6.SpaceState.CLOSED;
|
|
2703
2497
|
await this._ctx.dispose();
|
|
2704
2498
|
await this.authVerifier.close();
|
|
2705
2499
|
await this._inner.close();
|
|
@@ -2717,13 +2511,13 @@ var DataSpace = class DataSpace2 {
|
|
|
2717
2511
|
* Initialize the data pipeline in a separate task.
|
|
2718
2512
|
*/
|
|
2719
2513
|
initializeDataPipelineAsync() {
|
|
2720
|
-
(0,
|
|
2514
|
+
(0, import_async11.scheduleTask)(this._ctx, async () => {
|
|
2721
2515
|
try {
|
|
2722
2516
|
this.metrics.pipelineInitBegin = new Date();
|
|
2723
2517
|
await this.initializeDataPipeline();
|
|
2724
2518
|
} catch (err) {
|
|
2725
2519
|
if (err instanceof import_errors3.CancelledError) {
|
|
2726
|
-
(0,
|
|
2520
|
+
(0, import_log9.log)("Data pipeline initialization cancelled", err, {
|
|
2727
2521
|
file: "data-space.ts",
|
|
2728
2522
|
line: 173,
|
|
2729
2523
|
scope: this,
|
|
@@ -2731,13 +2525,13 @@ var DataSpace = class DataSpace2 {
|
|
|
2731
2525
|
});
|
|
2732
2526
|
return;
|
|
2733
2527
|
}
|
|
2734
|
-
|
|
2528
|
+
import_log9.log.error("Error initializing data pipeline", err, {
|
|
2735
2529
|
file: "data-space.ts",
|
|
2736
2530
|
line: 177,
|
|
2737
2531
|
scope: this,
|
|
2738
2532
|
callSite: (f, a) => f(...a)
|
|
2739
2533
|
});
|
|
2740
|
-
this._state =
|
|
2534
|
+
this._state = import_services6.SpaceState.ERROR;
|
|
2741
2535
|
this.error = err;
|
|
2742
2536
|
this.stateUpdate.emit();
|
|
2743
2537
|
} finally {
|
|
@@ -2747,17 +2541,17 @@ var DataSpace = class DataSpace2 {
|
|
|
2747
2541
|
}
|
|
2748
2542
|
async initializeDataPipeline() {
|
|
2749
2543
|
var _a, _b, _c, _d;
|
|
2750
|
-
if (this._state !==
|
|
2544
|
+
if (this._state !== import_services6.SpaceState.INACTIVE) {
|
|
2751
2545
|
throw new import_errors3.SystemError("Invalid operation");
|
|
2752
2546
|
}
|
|
2753
|
-
this._state =
|
|
2547
|
+
this._state = import_services6.SpaceState.INITIALIZING;
|
|
2754
2548
|
await this._inner.controlPipeline.state.waitUntilReachedTargetTimeframe({
|
|
2755
2549
|
ctx: this._ctx,
|
|
2756
2550
|
breakOnStall: false
|
|
2757
2551
|
});
|
|
2758
2552
|
this.metrics.controlPipelineReady = new Date();
|
|
2759
2553
|
await this._createWritableFeeds();
|
|
2760
|
-
(0,
|
|
2554
|
+
(0, import_log9.log)("Writable feeds created", {}, {
|
|
2761
2555
|
file: "data-space.ts",
|
|
2762
2556
|
line: 201,
|
|
2763
2557
|
scope: this,
|
|
@@ -2772,7 +2566,7 @@ var DataSpace = class DataSpace2 {
|
|
|
2772
2566
|
await this._inner.initializeDataPipeline();
|
|
2773
2567
|
this.metrics.dataPipelineOpen = new Date();
|
|
2774
2568
|
await (0, import_context6.cancelWithContext)(this._ctx, this._inner.dataPipeline.ensureEpochInitialized());
|
|
2775
|
-
(0,
|
|
2569
|
+
(0, import_log9.log)("waiting for data pipeline to reach target timeframe", {}, {
|
|
2776
2570
|
file: "data-space.ts",
|
|
2777
2571
|
line: 220,
|
|
2778
2572
|
scope: this,
|
|
@@ -2783,14 +2577,14 @@ var DataSpace = class DataSpace2 {
|
|
|
2783
2577
|
breakOnStall: false
|
|
2784
2578
|
});
|
|
2785
2579
|
this.metrics.dataPipelineReady = new Date();
|
|
2786
|
-
(0,
|
|
2580
|
+
(0, import_log9.log)("data pipeline ready", {}, {
|
|
2787
2581
|
file: "data-space.ts",
|
|
2788
2582
|
line: 229,
|
|
2789
2583
|
scope: this,
|
|
2790
2584
|
callSite: (f, a) => f(...a)
|
|
2791
2585
|
});
|
|
2792
2586
|
await ((_b = (_a = this._callbacks).beforeReady) == null ? void 0 : _b.call(_a));
|
|
2793
|
-
this._state =
|
|
2587
|
+
this._state = import_services6.SpaceState.READY;
|
|
2794
2588
|
this.stateUpdate.emit();
|
|
2795
2589
|
await ((_d = (_c = this._callbacks).afterReady) == null ? void 0 : _d.call(_c));
|
|
2796
2590
|
}
|
|
@@ -2866,11 +2660,11 @@ var DataSpace = class DataSpace2 {
|
|
|
2866
2660
|
}
|
|
2867
2661
|
}
|
|
2868
2662
|
};
|
|
2869
|
-
|
|
2663
|
+
__decorate([
|
|
2870
2664
|
(0, import_debug3.timed)(1e4)
|
|
2871
2665
|
], DataSpace.prototype, "_createWritableFeeds", null);
|
|
2872
|
-
DataSpace =
|
|
2873
|
-
(0,
|
|
2666
|
+
DataSpace = __decorate([
|
|
2667
|
+
(0, import_async11.trackLeaks)("open", "close")
|
|
2874
2668
|
], DataSpace);
|
|
2875
2669
|
|
|
2876
2670
|
// packages/sdk/client-services/src/packlets/spaces/genesis.ts
|
|
@@ -2944,7 +2738,7 @@ var spaceGenesis = async (keyring, signingContext, space) => {
|
|
|
2944
2738
|
};
|
|
2945
2739
|
|
|
2946
2740
|
// packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts
|
|
2947
|
-
var
|
|
2741
|
+
var __decorate2 = function(decorators, target, key, desc) {
|
|
2948
2742
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2949
2743
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
2950
2744
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -2963,8 +2757,8 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2963
2757
|
this._signingContext = _signingContext;
|
|
2964
2758
|
this._feedStore = _feedStore;
|
|
2965
2759
|
this._ctx = new import_context7.Context();
|
|
2966
|
-
this.updated = new
|
|
2967
|
-
this._spaces = new
|
|
2760
|
+
this.updated = new import_async12.Event();
|
|
2761
|
+
this._spaces = new import_util5.ComplexMap(import_keys9.PublicKey.hash);
|
|
2968
2762
|
this._isOpen = false;
|
|
2969
2763
|
this._instanceId = import_keys9.PublicKey.random().toHex();
|
|
2970
2764
|
}
|
|
@@ -2973,13 +2767,13 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2973
2767
|
return this._spaces;
|
|
2974
2768
|
}
|
|
2975
2769
|
async open() {
|
|
2976
|
-
(0,
|
|
2770
|
+
(0, import_log10.log)("open", {}, {
|
|
2977
2771
|
file: "data-space-manager.ts",
|
|
2978
2772
|
line: 80,
|
|
2979
2773
|
scope: this,
|
|
2980
2774
|
callSite: (f, a) => f(...a)
|
|
2981
2775
|
});
|
|
2982
|
-
|
|
2776
|
+
import_log10.log.trace("dxos.echo.data-space-manager.open", import_protocols6.trace.begin({
|
|
2983
2777
|
id: this._instanceId
|
|
2984
2778
|
}), {
|
|
2985
2779
|
file: "data-space-manager.ts",
|
|
@@ -2988,7 +2782,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2988
2782
|
callSite: (f, a) => f(...a)
|
|
2989
2783
|
});
|
|
2990
2784
|
await this._metadataStore.load();
|
|
2991
|
-
(0,
|
|
2785
|
+
(0, import_log10.log)("metadata loaded", {
|
|
2992
2786
|
spaces: this._metadataStore.spaces.length
|
|
2993
2787
|
}, {
|
|
2994
2788
|
file: "data-space-manager.ts",
|
|
@@ -2998,7 +2792,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2998
2792
|
});
|
|
2999
2793
|
for (const spaceMetadata of this._metadataStore.spaces) {
|
|
3000
2794
|
try {
|
|
3001
|
-
(0,
|
|
2795
|
+
(0, import_log10.log)("load space", {
|
|
3002
2796
|
spaceMetadata
|
|
3003
2797
|
}, {
|
|
3004
2798
|
file: "data-space-manager.ts",
|
|
@@ -3009,7 +2803,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
3009
2803
|
const space = await this._constructSpace(spaceMetadata);
|
|
3010
2804
|
space.initializeDataPipelineAsync();
|
|
3011
2805
|
} catch (err) {
|
|
3012
|
-
|
|
2806
|
+
import_log10.log.error("Error loading space", {
|
|
3013
2807
|
spaceMetadata,
|
|
3014
2808
|
err
|
|
3015
2809
|
}, {
|
|
@@ -3022,7 +2816,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
3022
2816
|
}
|
|
3023
2817
|
this._isOpen = true;
|
|
3024
2818
|
this.updated.emit();
|
|
3025
|
-
|
|
2819
|
+
import_log10.log.trace("dxos.echo.data-space-manager.open", import_protocols6.trace.end({
|
|
3026
2820
|
id: this._instanceId
|
|
3027
2821
|
}), {
|
|
3028
2822
|
file: "data-space-manager.ts",
|
|
@@ -3032,7 +2826,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
3032
2826
|
});
|
|
3033
2827
|
}
|
|
3034
2828
|
async close() {
|
|
3035
|
-
(0,
|
|
2829
|
+
(0, import_log10.log)("close", {}, {
|
|
3036
2830
|
file: "data-space-manager.ts",
|
|
3037
2831
|
line: 102,
|
|
3038
2832
|
scope: this,
|
|
@@ -3048,7 +2842,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
3048
2842
|
* Creates a new space writing the genesis credentials to the control feed.
|
|
3049
2843
|
*/
|
|
3050
2844
|
async createSpace() {
|
|
3051
|
-
(0,
|
|
2845
|
+
(0, import_node_assert10.default)(this._isOpen, "Not open.");
|
|
3052
2846
|
const spaceKey = await this._keyring.createKey();
|
|
3053
2847
|
const controlFeedKey = await this._keyring.createKey();
|
|
3054
2848
|
const dataFeedKey = await this._keyring.createKey();
|
|
@@ -3058,7 +2852,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
3058
2852
|
controlFeedKey,
|
|
3059
2853
|
dataFeedKey
|
|
3060
2854
|
};
|
|
3061
|
-
(0,
|
|
2855
|
+
(0, import_log10.log)("creating space...", {
|
|
3062
2856
|
spaceKey
|
|
3063
2857
|
}, {
|
|
3064
2858
|
file: "data-space-manager.ts",
|
|
@@ -3070,7 +2864,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
3070
2864
|
const credentials = await spaceGenesis(this._keyring, this._signingContext, space.inner);
|
|
3071
2865
|
await this._metadataStore.addSpace(metadata);
|
|
3072
2866
|
const memberCredential = credentials[1];
|
|
3073
|
-
(0,
|
|
2867
|
+
(0, import_node_assert10.default)((0, import_credentials12.getCredentialAssertion)(memberCredential)["@type"] === "dxos.halo.credentials.SpaceMember");
|
|
3074
2868
|
await this._signingContext.recordCredential(memberCredential);
|
|
3075
2869
|
await space.initializeDataPipeline();
|
|
3076
2870
|
this.updated.emit();
|
|
@@ -3078,7 +2872,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
3078
2872
|
}
|
|
3079
2873
|
// TODO(burdon): Rename join space.
|
|
3080
2874
|
async acceptSpace(opts) {
|
|
3081
|
-
(0,
|
|
2875
|
+
(0, import_log10.log)("accept space", {
|
|
3082
2876
|
opts
|
|
3083
2877
|
}, {
|
|
3084
2878
|
file: "data-space-manager.ts",
|
|
@@ -3086,8 +2880,8 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
3086
2880
|
scope: this,
|
|
3087
2881
|
callSite: (f, a) => f(...a)
|
|
3088
2882
|
});
|
|
3089
|
-
(0,
|
|
3090
|
-
(0,
|
|
2883
|
+
(0, import_node_assert10.default)(this._isOpen, "Not open.");
|
|
2884
|
+
(0, import_node_assert10.default)(!this._spaces.has(opts.spaceKey), "Space already exists.");
|
|
3091
2885
|
const metadata = {
|
|
3092
2886
|
key: opts.spaceKey,
|
|
3093
2887
|
genesisFeedKey: opts.genesisFeedKey,
|
|
@@ -3108,11 +2902,11 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
3108
2902
|
async waitUntilSpaceReady(spaceKey) {
|
|
3109
2903
|
await (0, import_context7.cancelWithContext)(this._ctx, this.updated.waitForCondition(() => {
|
|
3110
2904
|
const space = this._spaces.get(spaceKey);
|
|
3111
|
-
return !!space && space.state ===
|
|
2905
|
+
return !!space && space.state === import_services7.SpaceState.READY;
|
|
3112
2906
|
}));
|
|
3113
2907
|
}
|
|
3114
2908
|
async _constructSpace(metadata) {
|
|
3115
|
-
(0,
|
|
2909
|
+
(0, import_log10.log)("construct space", {
|
|
3116
2910
|
metadata
|
|
3117
2911
|
}, {
|
|
3118
2912
|
file: "data-space-manager.ts",
|
|
@@ -3141,7 +2935,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
3141
2935
|
swarmIdentity: {
|
|
3142
2936
|
peerKey: this._signingContext.deviceKey,
|
|
3143
2937
|
credentialProvider: createAuthProvider(this._signingContext.credentialSigner),
|
|
3144
|
-
credentialAuthenticator: (0,
|
|
2938
|
+
credentialAuthenticator: (0, import_util5.deferFunction)(() => dataSpace.authVerifier.verifier)
|
|
3145
2939
|
},
|
|
3146
2940
|
onNetworkConnection: (session) => {
|
|
3147
2941
|
session.addExtension("dxos.mesh.teleport.gossip", gossip.createExtension({
|
|
@@ -3150,7 +2944,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
3150
2944
|
session.addExtension("dxos.mesh.teleport.notarization", dataSpace.notarizationPlugin.createExtension());
|
|
3151
2945
|
},
|
|
3152
2946
|
onAuthFailure: () => {
|
|
3153
|
-
|
|
2947
|
+
import_log10.log.warn("auth failure", {}, {
|
|
3154
2948
|
file: "data-space-manager.ts",
|
|
3155
2949
|
line: 212,
|
|
3156
2950
|
scope: this,
|
|
@@ -3171,7 +2965,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
3171
2965
|
signingContext: this._signingContext,
|
|
3172
2966
|
callbacks: {
|
|
3173
2967
|
beforeReady: async () => {
|
|
3174
|
-
(0,
|
|
2968
|
+
(0, import_log10.log)("before space ready", {
|
|
3175
2969
|
space: space.key
|
|
3176
2970
|
}, {
|
|
3177
2971
|
file: "data-space-manager.ts",
|
|
@@ -3182,7 +2976,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
3182
2976
|
this._dataServiceSubscriptions.registerSpace(space.key, dataSpace.dataPipeline.databaseHost.createDataServiceHost());
|
|
3183
2977
|
},
|
|
3184
2978
|
afterReady: async () => {
|
|
3185
|
-
(0,
|
|
2979
|
+
(0, import_log10.log)("after space ready", {
|
|
3186
2980
|
space: space.key,
|
|
3187
2981
|
open: this._isOpen
|
|
3188
2982
|
}, {
|
|
@@ -3209,31 +3003,31 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
3209
3003
|
return dataSpace;
|
|
3210
3004
|
}
|
|
3211
3005
|
};
|
|
3212
|
-
|
|
3213
|
-
|
|
3006
|
+
__decorate2([
|
|
3007
|
+
import_async12.synchronized
|
|
3214
3008
|
], DataSpaceManager.prototype, "open", null);
|
|
3215
|
-
|
|
3216
|
-
|
|
3009
|
+
__decorate2([
|
|
3010
|
+
import_async12.synchronized
|
|
3217
3011
|
], DataSpaceManager.prototype, "close", null);
|
|
3218
|
-
|
|
3219
|
-
|
|
3012
|
+
__decorate2([
|
|
3013
|
+
import_async12.synchronized
|
|
3220
3014
|
], DataSpaceManager.prototype, "createSpace", null);
|
|
3221
|
-
|
|
3222
|
-
|
|
3015
|
+
__decorate2([
|
|
3016
|
+
import_async12.synchronized
|
|
3223
3017
|
], DataSpaceManager.prototype, "acceptSpace", null);
|
|
3224
|
-
DataSpaceManager =
|
|
3225
|
-
(0,
|
|
3018
|
+
DataSpaceManager = __decorate2([
|
|
3019
|
+
(0, import_async12.trackLeaks)("open", "close")
|
|
3226
3020
|
], DataSpaceManager);
|
|
3227
3021
|
|
|
3228
3022
|
// packages/sdk/client-services/src/packlets/spaces/spaces-service.ts
|
|
3229
|
-
var
|
|
3230
|
-
var
|
|
3231
|
-
var import_debug5 = require("@dxos/debug");
|
|
3023
|
+
var import_async13 = require("@dxos/async");
|
|
3024
|
+
var import_codec_protobuf9 = require("@dxos/codec-protobuf");
|
|
3025
|
+
var import_debug5 = require("@dxos/debug");
|
|
3232
3026
|
var import_echo_pipeline2 = require("@dxos/echo-pipeline");
|
|
3233
|
-
var
|
|
3027
|
+
var import_log11 = require("@dxos/log");
|
|
3234
3028
|
var import_protocols7 = require("@dxos/protocols");
|
|
3235
|
-
var
|
|
3236
|
-
var
|
|
3029
|
+
var import_services8 = require("@dxos/protocols/proto/dxos/client/services");
|
|
3030
|
+
var import_util6 = require("@dxos/util");
|
|
3237
3031
|
var TIMEFRAME_UPDATE_DEBOUNCE_TIME = 500;
|
|
3238
3032
|
var SpacesServiceImpl = class {
|
|
3239
3033
|
constructor(_identityManager, _spaceManager, _dataServiceSubscriptions, _getDataSpaceManager) {
|
|
@@ -3254,11 +3048,11 @@ var SpacesServiceImpl = class {
|
|
|
3254
3048
|
(0, import_debug5.todo)();
|
|
3255
3049
|
}
|
|
3256
3050
|
querySpaces() {
|
|
3257
|
-
return new
|
|
3051
|
+
return new import_codec_protobuf9.Stream(({ next, ctx }) => {
|
|
3258
3052
|
const onUpdate = async () => {
|
|
3259
3053
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
3260
3054
|
const spaces = Array.from(dataSpaceManager.spaces.values()).map((space) => this._transformSpace(space));
|
|
3261
|
-
(0,
|
|
3055
|
+
(0, import_log11.log)("update", {
|
|
3262
3056
|
spaces
|
|
3263
3057
|
}, {
|
|
3264
3058
|
file: "spaces-service.ts",
|
|
@@ -3270,9 +3064,9 @@ var SpacesServiceImpl = class {
|
|
|
3270
3064
|
spaces
|
|
3271
3065
|
});
|
|
3272
3066
|
};
|
|
3273
|
-
(0,
|
|
3067
|
+
(0, import_async13.scheduleTask)(ctx, async () => {
|
|
3274
3068
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
3275
|
-
const subscriptions = new
|
|
3069
|
+
const subscriptions = new import_async13.EventSubscriptions();
|
|
3276
3070
|
ctx.onDispose(() => subscriptions.clear());
|
|
3277
3071
|
const subscribeSpaces = () => {
|
|
3278
3072
|
subscriptions.clear();
|
|
@@ -3307,8 +3101,8 @@ var SpacesServiceImpl = class {
|
|
|
3307
3101
|
await space.postMessage(getChannelId(channel), message);
|
|
3308
3102
|
}
|
|
3309
3103
|
subscribeMessages({ spaceKey, channel }) {
|
|
3310
|
-
return new
|
|
3311
|
-
(0,
|
|
3104
|
+
return new import_codec_protobuf9.Stream(({ ctx, next }) => {
|
|
3105
|
+
(0, import_async13.scheduleTask)(ctx, async () => {
|
|
3312
3106
|
var _a;
|
|
3313
3107
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
3314
3108
|
const space = (_a = dataSpaceManager.spaces.get(spaceKey)) != null ? _a : (0, import_debug5.raise)(new import_echo_pipeline2.SpaceNotFoundError(spaceKey));
|
|
@@ -3320,7 +3114,7 @@ var SpacesServiceImpl = class {
|
|
|
3320
3114
|
});
|
|
3321
3115
|
}
|
|
3322
3116
|
queryCredentials({ spaceKey }) {
|
|
3323
|
-
return new
|
|
3117
|
+
return new import_codec_protobuf9.Stream(({ ctx, next }) => {
|
|
3324
3118
|
var _a;
|
|
3325
3119
|
const space = (_a = this._spaceManager.spaces.get(spaceKey)) != null ? _a : (0, import_debug5.raise)(new import_echo_pipeline2.SpaceNotFoundError(spaceKey));
|
|
3326
3120
|
const processor = space.spaceState.registerProcessor({
|
|
@@ -3329,7 +3123,7 @@ var SpacesServiceImpl = class {
|
|
|
3329
3123
|
}
|
|
3330
3124
|
});
|
|
3331
3125
|
ctx.onDispose(() => processor.close());
|
|
3332
|
-
(0,
|
|
3126
|
+
(0, import_async13.scheduleTask)(ctx, () => processor.open());
|
|
3333
3127
|
});
|
|
3334
3128
|
}
|
|
3335
3129
|
async writeCredentials({ spaceKey, credentials }) {
|
|
@@ -3374,10 +3168,10 @@ var SpacesServiceImpl = class {
|
|
|
3374
3168
|
identity: {
|
|
3375
3169
|
identityKey: member.key,
|
|
3376
3170
|
profile: {
|
|
3377
|
-
displayName: (_b2 = (_a2 = member.assertion.profile) == null ? void 0 : _a2.displayName) != null ? _b2 : (0,
|
|
3171
|
+
displayName: (_b2 = (_a2 = member.assertion.profile) == null ? void 0 : _a2.displayName) != null ? _b2 : (0, import_util6.humanize)(member.key)
|
|
3378
3172
|
}
|
|
3379
3173
|
},
|
|
3380
|
-
presence: ((_c2 = this._identityManager.identity) == null ? void 0 : _c2.identityKey.equals(member.key)) || space.presence.getPeersOnline().filter(({ identityKey }) => identityKey.equals(member.key)).length > 0 ?
|
|
3174
|
+
presence: ((_c2 = this._identityManager.identity) == null ? void 0 : _c2.identityKey.equals(member.key)) || space.presence.getPeersOnline().filter(({ identityKey }) => identityKey.equals(member.key)).length > 0 ? import_services8.SpaceMember.PresenceState.ONLINE : import_services8.SpaceMember.PresenceState.OFFLINE
|
|
3381
3175
|
};
|
|
3382
3176
|
}),
|
|
3383
3177
|
creator: (_g = space.inner.spaceState.creator) == null ? void 0 : _g.key,
|
|
@@ -3388,106 +3182,7 @@ var SpacesServiceImpl = class {
|
|
|
3388
3182
|
};
|
|
3389
3183
|
var getChannelId = (channel) => `user-channel/${channel}`;
|
|
3390
3184
|
|
|
3391
|
-
// packages/sdk/client-services/src/packlets/storage/storage.ts
|
|
3392
|
-
var import_client_protocol4 = require("@dxos/client-protocol");
|
|
3393
|
-
var import_errors4 = require("@dxos/errors");
|
|
3394
|
-
var import_config = require("@dxos/protocols/proto/dxos/config");
|
|
3395
|
-
var import_random_access_storage = require("@dxos/random-access-storage");
|
|
3396
|
-
var import_util8 = require("@dxos/util");
|
|
3397
|
-
var StorageDriver = import_config.Runtime.Client.Storage.StorageDriver;
|
|
3398
|
-
var createStorageObjects = (config) => {
|
|
3399
|
-
const { path = (0, import_util8.isNode)() ? import_client_protocol4.DX_DATA : "dxos/storage", storageType, keyStorage, persistent = false } = config != null ? config : {};
|
|
3400
|
-
if (persistent && storageType === StorageDriver.RAM) {
|
|
3401
|
-
throw new import_errors4.InvalidConfigError("RAM storage cannot be used in persistent mode.");
|
|
3402
|
-
}
|
|
3403
|
-
if (!persistent && storageType !== void 0 && storageType !== StorageDriver.RAM) {
|
|
3404
|
-
throw new import_errors4.InvalidConfigError("Cannot use a persistent storage in not persistent mode.");
|
|
3405
|
-
}
|
|
3406
|
-
if (persistent && keyStorage === StorageDriver.RAM) {
|
|
3407
|
-
throw new import_errors4.InvalidConfigError("RAM key storage cannot be used in persistent mode.");
|
|
3408
|
-
}
|
|
3409
|
-
if (!persistent && keyStorage !== StorageDriver.RAM && keyStorage !== void 0) {
|
|
3410
|
-
throw new import_errors4.InvalidConfigError("Cannot use a persistent key storage in not persistent mode.");
|
|
3411
|
-
}
|
|
3412
|
-
return {
|
|
3413
|
-
storage: (0, import_random_access_storage.createStorage)({
|
|
3414
|
-
type: persistent ? toStorageType(storageType) : import_random_access_storage.StorageType.RAM,
|
|
3415
|
-
root: `${path}/`
|
|
3416
|
-
})
|
|
3417
|
-
};
|
|
3418
|
-
};
|
|
3419
|
-
var toStorageType = (type) => {
|
|
3420
|
-
switch (type) {
|
|
3421
|
-
case void 0:
|
|
3422
|
-
return void 0;
|
|
3423
|
-
case StorageDriver.RAM:
|
|
3424
|
-
return import_random_access_storage.StorageType.RAM;
|
|
3425
|
-
case StorageDriver.CHROME:
|
|
3426
|
-
return import_random_access_storage.StorageType.CHROME;
|
|
3427
|
-
case StorageDriver.FIREFOX:
|
|
3428
|
-
return import_random_access_storage.StorageType.FIREFOX;
|
|
3429
|
-
case StorageDriver.IDB:
|
|
3430
|
-
return import_random_access_storage.StorageType.IDB;
|
|
3431
|
-
case StorageDriver.NODE:
|
|
3432
|
-
return import_random_access_storage.StorageType.NODE;
|
|
3433
|
-
case StorageDriver.WEBFS:
|
|
3434
|
-
return import_random_access_storage.StorageType.WEBFS;
|
|
3435
|
-
default:
|
|
3436
|
-
throw new Error(`Invalid storage type: ${StorageDriver[type]}`);
|
|
3437
|
-
}
|
|
3438
|
-
};
|
|
3439
|
-
|
|
3440
|
-
// packages/sdk/client-services/src/packlets/system/system-service.ts
|
|
3441
|
-
var import_codec_protobuf13 = require("@dxos/codec-protobuf");
|
|
3442
|
-
var SystemServiceImpl = class {
|
|
3443
|
-
constructor({ config, statusUpdate, onUpdateStatus, getCurrentStatus, onReset }) {
|
|
3444
|
-
this._config = config;
|
|
3445
|
-
this._statusUpdate = statusUpdate;
|
|
3446
|
-
this._getCurrentStatus = getCurrentStatus;
|
|
3447
|
-
this._onUpdateStatus = onUpdateStatus;
|
|
3448
|
-
this._onReset = onReset;
|
|
3449
|
-
}
|
|
3450
|
-
async getConfig() {
|
|
3451
|
-
var _a, _b;
|
|
3452
|
-
return (_b = (_a = this._config) == null ? void 0 : _a.values) != null ? _b : {};
|
|
3453
|
-
}
|
|
3454
|
-
async updateStatus({ status }) {
|
|
3455
|
-
await this._onUpdateStatus(status);
|
|
3456
|
-
}
|
|
3457
|
-
queryStatus() {
|
|
3458
|
-
return new import_codec_protobuf13.Stream(({ next }) => {
|
|
3459
|
-
const update = () => {
|
|
3460
|
-
next({
|
|
3461
|
-
status: this._getCurrentStatus()
|
|
3462
|
-
});
|
|
3463
|
-
};
|
|
3464
|
-
update();
|
|
3465
|
-
const unsubscribe = this._statusUpdate.on(() => update());
|
|
3466
|
-
const interval = setInterval(update, 3e3);
|
|
3467
|
-
return () => {
|
|
3468
|
-
clearInterval(interval);
|
|
3469
|
-
unsubscribe();
|
|
3470
|
-
};
|
|
3471
|
-
});
|
|
3472
|
-
}
|
|
3473
|
-
async reset() {
|
|
3474
|
-
await this._onReset();
|
|
3475
|
-
}
|
|
3476
|
-
};
|
|
3477
|
-
|
|
3478
3185
|
// packages/sdk/client-services/src/packlets/services/service-context.ts
|
|
3479
|
-
var import_node_assert12 = __toESM(require("node:assert"));
|
|
3480
|
-
var import_async16 = require("@dxos/async");
|
|
3481
|
-
var import_credentials13 = require("@dxos/credentials");
|
|
3482
|
-
var import_debug6 = require("@dxos/debug");
|
|
3483
|
-
var import_echo_pipeline3 = require("@dxos/echo-pipeline");
|
|
3484
|
-
var import_feed_store4 = require("@dxos/feed-store");
|
|
3485
|
-
var import_keyring = require("@dxos/keyring");
|
|
3486
|
-
var import_keys10 = require("@dxos/keys");
|
|
3487
|
-
var import_log14 = require("@dxos/log");
|
|
3488
|
-
var import_protocols8 = require("@dxos/protocols");
|
|
3489
|
-
var import_services11 = require("@dxos/protocols/proto/dxos/client/services");
|
|
3490
|
-
var import_teleport_extension_object_sync = require("@dxos/teleport-extension-object-sync");
|
|
3491
3186
|
var ServiceContext = class {
|
|
3492
3187
|
// prettier-ignore
|
|
3493
3188
|
constructor(storage, networkManager, signalManager, modelFactory) {
|
|
@@ -3495,7 +3190,7 @@ var ServiceContext = class {
|
|
|
3495
3190
|
this.networkManager = networkManager;
|
|
3496
3191
|
this.signalManager = signalManager;
|
|
3497
3192
|
this.modelFactory = modelFactory;
|
|
3498
|
-
this.initialized = new
|
|
3193
|
+
this.initialized = new import_async14.Trigger();
|
|
3499
3194
|
this.dataServiceSubscriptions = new import_echo_pipeline3.DataServiceSubscriptions();
|
|
3500
3195
|
this._handlerFactories = /* @__PURE__ */ new Map();
|
|
3501
3196
|
this._instanceId = import_keys10.PublicKey.random().toHex();
|
|
@@ -3522,13 +3217,13 @@ var ServiceContext = class {
|
|
|
3522
3217
|
});
|
|
3523
3218
|
this.identityManager = new IdentityManager(this.metadataStore, this.keyring, this.feedStore, this.spaceManager);
|
|
3524
3219
|
this.invitations = new InvitationsHandler(this.networkManager);
|
|
3525
|
-
this._handlerFactories.set(
|
|
3220
|
+
this._handlerFactories.set(import_services9.Invitation.Kind.DEVICE, () => new DeviceInvitationProtocol(this.keyring, () => {
|
|
3526
3221
|
var _a;
|
|
3527
3222
|
return (_a = this.identityManager.identity) != null ? _a : (0, import_debug6.failUndefined)();
|
|
3528
3223
|
}, this._acceptIdentity.bind(this)));
|
|
3529
3224
|
}
|
|
3530
3225
|
async open() {
|
|
3531
|
-
|
|
3226
|
+
import_log12.log.trace("dxos.sdk.service-context.open", import_protocols8.trace.begin({
|
|
3532
3227
|
id: this._instanceId
|
|
3533
3228
|
}), {
|
|
3534
3229
|
file: "service-context.ts",
|
|
@@ -3537,7 +3232,7 @@ var ServiceContext = class {
|
|
|
3537
3232
|
callSite: (f, a) => f(...a)
|
|
3538
3233
|
});
|
|
3539
3234
|
await this._checkStorageVersion();
|
|
3540
|
-
(0,
|
|
3235
|
+
(0, import_log12.log)("opening...", {}, {
|
|
3541
3236
|
file: "service-context.ts",
|
|
3542
3237
|
line: 130,
|
|
3543
3238
|
scope: this,
|
|
@@ -3550,13 +3245,13 @@ var ServiceContext = class {
|
|
|
3550
3245
|
if (this.identityManager.identity) {
|
|
3551
3246
|
await this._initialize();
|
|
3552
3247
|
}
|
|
3553
|
-
(0,
|
|
3248
|
+
(0, import_log12.log)("opened", {}, {
|
|
3554
3249
|
file: "service-context.ts",
|
|
3555
3250
|
line: 138,
|
|
3556
3251
|
scope: this,
|
|
3557
3252
|
callSite: (f, a) => f(...a)
|
|
3558
3253
|
});
|
|
3559
|
-
|
|
3254
|
+
import_log12.log.trace("dxos.sdk.service-context.open", import_protocols8.trace.end({
|
|
3560
3255
|
id: this._instanceId
|
|
3561
3256
|
}), {
|
|
3562
3257
|
file: "service-context.ts",
|
|
@@ -3567,7 +3262,7 @@ var ServiceContext = class {
|
|
|
3567
3262
|
}
|
|
3568
3263
|
async close() {
|
|
3569
3264
|
var _a, _b;
|
|
3570
|
-
(0,
|
|
3265
|
+
(0, import_log12.log)("closing...", {}, {
|
|
3571
3266
|
file: "service-context.ts",
|
|
3572
3267
|
line: 143,
|
|
3573
3268
|
scope: this,
|
|
@@ -3581,7 +3276,7 @@ var ServiceContext = class {
|
|
|
3581
3276
|
await this.networkManager.close();
|
|
3582
3277
|
await this.signalManager.close();
|
|
3583
3278
|
this.dataServiceSubscriptions.clear();
|
|
3584
|
-
(0,
|
|
3279
|
+
(0, import_log12.log)("closed", {}, {
|
|
3585
3280
|
file: "service-context.ts",
|
|
3586
3281
|
line: 152,
|
|
3587
3282
|
scope: this,
|
|
@@ -3595,7 +3290,7 @@ var ServiceContext = class {
|
|
|
3595
3290
|
}
|
|
3596
3291
|
getInvitationHandler(invitation) {
|
|
3597
3292
|
const factory = this._handlerFactories.get(invitation.kind);
|
|
3598
|
-
(0,
|
|
3293
|
+
(0, import_node_assert11.default)(factory, `Unknown invitation kind: ${invitation.kind}`);
|
|
3599
3294
|
return factory(invitation);
|
|
3600
3295
|
}
|
|
3601
3296
|
async _acceptIdentity(params) {
|
|
@@ -3612,7 +3307,7 @@ var ServiceContext = class {
|
|
|
3612
3307
|
// Called when identity is created.
|
|
3613
3308
|
async _initialize() {
|
|
3614
3309
|
var _a;
|
|
3615
|
-
(0,
|
|
3310
|
+
(0, import_log12.log)("initializing spaces...", {}, {
|
|
3616
3311
|
file: "service-context.ts",
|
|
3617
3312
|
line: 185,
|
|
3618
3313
|
scope: this,
|
|
@@ -3634,8 +3329,8 @@ var ServiceContext = class {
|
|
|
3634
3329
|
};
|
|
3635
3330
|
this.dataSpaceManager = new DataSpaceManager(this.spaceManager, this.metadataStore, this.dataServiceSubscriptions, this.keyring, signingContext, this.feedStore);
|
|
3636
3331
|
await this.dataSpaceManager.open();
|
|
3637
|
-
this._handlerFactories.set(
|
|
3638
|
-
(0,
|
|
3332
|
+
this._handlerFactories.set(import_services9.Invitation.Kind.SPACE, (invitation) => {
|
|
3333
|
+
(0, import_node_assert11.default)(this.dataSpaceManager, "dataSpaceManager not initialized yet");
|
|
3639
3334
|
return new SpaceInvitationProtocol(this.dataSpaceManager, signingContext, this.keyring, invitation.spaceKey);
|
|
3640
3335
|
});
|
|
3641
3336
|
this.initialized.wake();
|
|
@@ -3649,7 +3344,7 @@ var ServiceContext = class {
|
|
|
3649
3344
|
return;
|
|
3650
3345
|
}
|
|
3651
3346
|
if (!this.dataSpaceManager) {
|
|
3652
|
-
(0,
|
|
3347
|
+
(0, import_log12.log)("dataSpaceManager not initialized yet, ignoring space admission", {
|
|
3653
3348
|
details: assertion
|
|
3654
3349
|
}, {
|
|
3655
3350
|
file: "service-context.ts",
|
|
@@ -3660,7 +3355,7 @@ var ServiceContext = class {
|
|
|
3660
3355
|
return;
|
|
3661
3356
|
}
|
|
3662
3357
|
if (this.dataSpaceManager.spaces.has(assertion.spaceKey)) {
|
|
3663
|
-
(0,
|
|
3358
|
+
(0, import_log12.log)("space already exists, ignoring space admission", {
|
|
3664
3359
|
details: assertion
|
|
3665
3360
|
}, {
|
|
3666
3361
|
file: "service-context.ts",
|
|
@@ -3671,7 +3366,7 @@ var ServiceContext = class {
|
|
|
3671
3366
|
return;
|
|
3672
3367
|
}
|
|
3673
3368
|
try {
|
|
3674
|
-
(0,
|
|
3369
|
+
(0, import_log12.log)("accepting space recorded in halo", {
|
|
3675
3370
|
details: assertion
|
|
3676
3371
|
}, {
|
|
3677
3372
|
file: "service-context.ts",
|
|
@@ -3684,7 +3379,7 @@ var ServiceContext = class {
|
|
|
3684
3379
|
genesisFeedKey: assertion.genesisFeedKey
|
|
3685
3380
|
});
|
|
3686
3381
|
} catch (err) {
|
|
3687
|
-
|
|
3382
|
+
import_log12.log.catch(err, {}, {
|
|
3688
3383
|
file: "service-context.ts",
|
|
3689
3384
|
line: 239,
|
|
3690
3385
|
scope: this,
|
|
@@ -3697,6 +3392,312 @@ var ServiceContext = class {
|
|
|
3697
3392
|
}
|
|
3698
3393
|
};
|
|
3699
3394
|
|
|
3395
|
+
// packages/sdk/client-services/src/packlets/services/service-host.ts
|
|
3396
|
+
var import_node_assert13 = __toESM(require("node:assert"));
|
|
3397
|
+
var import_async17 = require("@dxos/async");
|
|
3398
|
+
var import_client_protocol5 = require("@dxos/client-protocol");
|
|
3399
|
+
var import_echo_pipeline4 = require("@dxos/echo-pipeline");
|
|
3400
|
+
var import_keys11 = require("@dxos/keys");
|
|
3401
|
+
var import_log15 = require("@dxos/log");
|
|
3402
|
+
var import_messaging = require("@dxos/messaging");
|
|
3403
|
+
var import_network_manager2 = require("@dxos/network-manager");
|
|
3404
|
+
var import_protocols9 = require("@dxos/protocols");
|
|
3405
|
+
var import_services12 = require("@dxos/protocols/proto/dxos/client/services");
|
|
3406
|
+
|
|
3407
|
+
// packages/sdk/client-services/src/packlets/devices/devices-service.ts
|
|
3408
|
+
var import_async15 = require("@dxos/async");
|
|
3409
|
+
var import_codec_protobuf10 = require("@dxos/codec-protobuf");
|
|
3410
|
+
var import_services10 = require("@dxos/protocols/proto/dxos/client/services");
|
|
3411
|
+
var DevicesServiceImpl = class {
|
|
3412
|
+
constructor(_identityManager) {
|
|
3413
|
+
this._identityManager = _identityManager;
|
|
3414
|
+
}
|
|
3415
|
+
updateDevice(request) {
|
|
3416
|
+
throw new Error("Method not implemented.");
|
|
3417
|
+
}
|
|
3418
|
+
queryDevices() {
|
|
3419
|
+
return new import_codec_protobuf10.Stream(({ next }) => {
|
|
3420
|
+
const update = () => {
|
|
3421
|
+
var _a;
|
|
3422
|
+
const deviceKeys = (_a = this._identityManager.identity) == null ? void 0 : _a.authorizedDeviceKeys;
|
|
3423
|
+
if (!deviceKeys) {
|
|
3424
|
+
next({
|
|
3425
|
+
devices: []
|
|
3426
|
+
});
|
|
3427
|
+
} else {
|
|
3428
|
+
next({
|
|
3429
|
+
devices: Array.from(deviceKeys.values()).map((key) => {
|
|
3430
|
+
var _a2;
|
|
3431
|
+
return {
|
|
3432
|
+
deviceKey: key,
|
|
3433
|
+
kind: ((_a2 = this._identityManager.identity) == null ? void 0 : _a2.deviceKey.equals(key)) ? import_services10.DeviceKind.CURRENT : import_services10.DeviceKind.TRUSTED
|
|
3434
|
+
};
|
|
3435
|
+
})
|
|
3436
|
+
});
|
|
3437
|
+
}
|
|
3438
|
+
};
|
|
3439
|
+
const subscriptions = new import_async15.EventSubscriptions();
|
|
3440
|
+
subscriptions.add(this._identityManager.stateUpdate.on(() => {
|
|
3441
|
+
update();
|
|
3442
|
+
if (this._identityManager.identity) {
|
|
3443
|
+
subscriptions.add(this._identityManager.identity.stateUpdate.on(() => {
|
|
3444
|
+
update();
|
|
3445
|
+
}));
|
|
3446
|
+
}
|
|
3447
|
+
}));
|
|
3448
|
+
update();
|
|
3449
|
+
return () => subscriptions.clear();
|
|
3450
|
+
});
|
|
3451
|
+
}
|
|
3452
|
+
};
|
|
3453
|
+
|
|
3454
|
+
// packages/sdk/client-services/src/packlets/locks/node.ts
|
|
3455
|
+
var import_node_assert12 = __toESM(require("node:assert"));
|
|
3456
|
+
var import_lock_file = require("@dxos/lock-file");
|
|
3457
|
+
var import_log13 = require("@dxos/log");
|
|
3458
|
+
var __decorate3 = function(decorators, target, key, desc) {
|
|
3459
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3460
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
3461
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
3462
|
+
else
|
|
3463
|
+
for (var i = decorators.length - 1; i >= 0; i--)
|
|
3464
|
+
if (d = decorators[i])
|
|
3465
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
3466
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3467
|
+
};
|
|
3468
|
+
var Lock = class {
|
|
3469
|
+
constructor({ lockKey: lockPath, onAcquire, onRelease }) {
|
|
3470
|
+
this._lockPath = lockPath;
|
|
3471
|
+
this._onAcquire = onAcquire;
|
|
3472
|
+
this._onRelease = onRelease;
|
|
3473
|
+
}
|
|
3474
|
+
get lockKey() {
|
|
3475
|
+
return this._lockPath;
|
|
3476
|
+
}
|
|
3477
|
+
async acquire() {
|
|
3478
|
+
var _a;
|
|
3479
|
+
(0, import_log13.log)("acquiring lock...", {}, {
|
|
3480
|
+
file: "node.ts",
|
|
3481
|
+
line: 32,
|
|
3482
|
+
scope: this,
|
|
3483
|
+
callSite: (f, a) => f(...a)
|
|
3484
|
+
});
|
|
3485
|
+
this._fileHandle = await import_lock_file.LockFile.acquire(this._lockPath);
|
|
3486
|
+
await ((_a = this._onAcquire) == null ? void 0 : _a.call(this));
|
|
3487
|
+
(0, import_log13.log)("acquired lock", {}, {
|
|
3488
|
+
file: "node.ts",
|
|
3489
|
+
line: 37,
|
|
3490
|
+
scope: this,
|
|
3491
|
+
callSite: (f, a) => f(...a)
|
|
3492
|
+
});
|
|
3493
|
+
}
|
|
3494
|
+
async release() {
|
|
3495
|
+
var _a;
|
|
3496
|
+
await ((_a = this._onRelease) == null ? void 0 : _a.call(this));
|
|
3497
|
+
(0, import_node_assert12.default)(this._fileHandle, "Lock is not acquired");
|
|
3498
|
+
await import_lock_file.LockFile.release(this._fileHandle);
|
|
3499
|
+
}
|
|
3500
|
+
};
|
|
3501
|
+
__decorate3([
|
|
3502
|
+
import_log13.logInfo
|
|
3503
|
+
], Lock.prototype, "lockKey", null);
|
|
3504
|
+
var isLocked = (lockPath) => import_lock_file.LockFile.isLocked(lockPath);
|
|
3505
|
+
|
|
3506
|
+
// packages/sdk/client-services/src/packlets/logging/logging-service.ts
|
|
3507
|
+
var import_async16 = require("@dxos/async");
|
|
3508
|
+
var import_codec_protobuf11 = require("@dxos/codec-protobuf");
|
|
3509
|
+
var import_log14 = require("@dxos/log");
|
|
3510
|
+
var import_services11 = require("@dxos/protocols/proto/dxos/client/services");
|
|
3511
|
+
var import_util7 = require("@dxos/util");
|
|
3512
|
+
var LoggingServiceImpl = class {
|
|
3513
|
+
constructor() {
|
|
3514
|
+
this._logs = new import_async16.Event();
|
|
3515
|
+
this._logProcessor = (_config, entry2) => {
|
|
3516
|
+
this._logs.emit(entry2);
|
|
3517
|
+
};
|
|
3518
|
+
}
|
|
3519
|
+
async open() {
|
|
3520
|
+
import_log14.log.runtimeConfig.processors.push(this._logProcessor);
|
|
3521
|
+
}
|
|
3522
|
+
async close() {
|
|
3523
|
+
const index = import_log14.log.runtimeConfig.processors.findIndex((processor) => processor === this._logProcessor);
|
|
3524
|
+
import_log14.log.runtimeConfig.processors.splice(index, 1);
|
|
3525
|
+
}
|
|
3526
|
+
queryLogs(request) {
|
|
3527
|
+
return new import_codec_protobuf11.Stream(({ ctx, next }) => {
|
|
3528
|
+
const handler = (entry2) => {
|
|
3529
|
+
var _a, _b, _c, _d, _e;
|
|
3530
|
+
if (LOG_PROCESSING > 0) {
|
|
3531
|
+
return;
|
|
3532
|
+
}
|
|
3533
|
+
if (((_a = entry2.meta) == null ? void 0 : _a.file.includes("logging-service")) || entry2.context && Object.values(entry2.context).some((value) => typeof value === "string" && value.includes("LoggingService"))) {
|
|
3534
|
+
return;
|
|
3535
|
+
}
|
|
3536
|
+
if (!shouldLog(entry2, request)) {
|
|
3537
|
+
return;
|
|
3538
|
+
}
|
|
3539
|
+
const record = {
|
|
3540
|
+
...entry2,
|
|
3541
|
+
context: (0, import_util7.jsonify)((0, import_log14.getContextFromEntry)(entry2)),
|
|
3542
|
+
timestamp: new Date(),
|
|
3543
|
+
meta: {
|
|
3544
|
+
// TODO(dmaretskyi): Fix proto.
|
|
3545
|
+
file: (_c = (_b = entry2.meta) == null ? void 0 : _b.file) != null ? _c : "",
|
|
3546
|
+
line: (_e = (_d = entry2.meta) == null ? void 0 : _d.line) != null ? _e : 0
|
|
3547
|
+
}
|
|
3548
|
+
};
|
|
3549
|
+
try {
|
|
3550
|
+
LOG_PROCESSING++;
|
|
3551
|
+
next(record);
|
|
3552
|
+
} finally {
|
|
3553
|
+
LOG_PROCESSING--;
|
|
3554
|
+
}
|
|
3555
|
+
};
|
|
3556
|
+
this._logs.on(ctx, handler);
|
|
3557
|
+
});
|
|
3558
|
+
}
|
|
3559
|
+
};
|
|
3560
|
+
var matchFilter = (filter, level, path, options) => {
|
|
3561
|
+
switch (options) {
|
|
3562
|
+
case import_services11.QueryLogsRequest.MatchingOptions.INCLUSIVE:
|
|
3563
|
+
return level >= filter.level && (!filter.pattern || path.includes(filter.pattern));
|
|
3564
|
+
case import_services11.QueryLogsRequest.MatchingOptions.EXPLICIT:
|
|
3565
|
+
return level === filter.level && (!filter.pattern || path.includes(filter.pattern));
|
|
3566
|
+
}
|
|
3567
|
+
};
|
|
3568
|
+
var shouldLog = (entry2, request) => {
|
|
3569
|
+
var _a;
|
|
3570
|
+
const options = (_a = request.options) != null ? _a : import_services11.QueryLogsRequest.MatchingOptions.INCLUSIVE;
|
|
3571
|
+
if (request.filters === void 0) {
|
|
3572
|
+
return options === import_services11.QueryLogsRequest.MatchingOptions.INCLUSIVE;
|
|
3573
|
+
} else {
|
|
3574
|
+
return request.filters.some((filter) => {
|
|
3575
|
+
var _a2, _b;
|
|
3576
|
+
return matchFilter(filter, entry2.level, (_b = (_a2 = entry2.meta) == null ? void 0 : _a2.file) != null ? _b : "", options);
|
|
3577
|
+
});
|
|
3578
|
+
}
|
|
3579
|
+
};
|
|
3580
|
+
var LOG_PROCESSING = 0;
|
|
3581
|
+
|
|
3582
|
+
// packages/sdk/client-services/src/packlets/network/network-service.ts
|
|
3583
|
+
var import_codec_protobuf12 = require("@dxos/codec-protobuf");
|
|
3584
|
+
var NetworkServiceImpl = class {
|
|
3585
|
+
constructor(networkManager, signalManager) {
|
|
3586
|
+
this.networkManager = networkManager;
|
|
3587
|
+
this.signalManager = signalManager;
|
|
3588
|
+
}
|
|
3589
|
+
queryStatus() {
|
|
3590
|
+
return new import_codec_protobuf12.Stream(({ next }) => {
|
|
3591
|
+
const update = () => {
|
|
3592
|
+
next({
|
|
3593
|
+
swarm: this.networkManager.connectionState,
|
|
3594
|
+
signaling: this.signalManager.getStatus().map(({ host, state }) => ({
|
|
3595
|
+
server: host,
|
|
3596
|
+
state
|
|
3597
|
+
}))
|
|
3598
|
+
});
|
|
3599
|
+
};
|
|
3600
|
+
const unsubscribeSwarm = this.networkManager.connectionStateChanged.on(() => update());
|
|
3601
|
+
const unsubscribeSignal = this.signalManager.statusChanged.on(() => update());
|
|
3602
|
+
update();
|
|
3603
|
+
return () => {
|
|
3604
|
+
unsubscribeSwarm();
|
|
3605
|
+
unsubscribeSignal();
|
|
3606
|
+
};
|
|
3607
|
+
});
|
|
3608
|
+
}
|
|
3609
|
+
async updateConfig(request) {
|
|
3610
|
+
await this.networkManager.setConnectionState(request.swarm);
|
|
3611
|
+
}
|
|
3612
|
+
};
|
|
3613
|
+
|
|
3614
|
+
// packages/sdk/client-services/src/packlets/storage/storage.ts
|
|
3615
|
+
var import_client_protocol4 = require("@dxos/client-protocol");
|
|
3616
|
+
var import_errors4 = require("@dxos/errors");
|
|
3617
|
+
var import_config = require("@dxos/protocols/proto/dxos/config");
|
|
3618
|
+
var import_random_access_storage = require("@dxos/random-access-storage");
|
|
3619
|
+
var import_util8 = require("@dxos/util");
|
|
3620
|
+
var StorageDriver = import_config.Runtime.Client.Storage.StorageDriver;
|
|
3621
|
+
var createStorageObjects = (config) => {
|
|
3622
|
+
const { path = (0, import_util8.isNode)() ? import_client_protocol4.DX_DATA : "dxos/storage", storageType, keyStorage, persistent = false } = config != null ? config : {};
|
|
3623
|
+
if (persistent && storageType === StorageDriver.RAM) {
|
|
3624
|
+
throw new import_errors4.InvalidConfigError("RAM storage cannot be used in persistent mode.");
|
|
3625
|
+
}
|
|
3626
|
+
if (!persistent && storageType !== void 0 && storageType !== StorageDriver.RAM) {
|
|
3627
|
+
throw new import_errors4.InvalidConfigError("Cannot use a persistent storage in not persistent mode.");
|
|
3628
|
+
}
|
|
3629
|
+
if (persistent && keyStorage === StorageDriver.RAM) {
|
|
3630
|
+
throw new import_errors4.InvalidConfigError("RAM key storage cannot be used in persistent mode.");
|
|
3631
|
+
}
|
|
3632
|
+
if (!persistent && keyStorage !== StorageDriver.RAM && keyStorage !== void 0) {
|
|
3633
|
+
throw new import_errors4.InvalidConfigError("Cannot use a persistent key storage in not persistent mode.");
|
|
3634
|
+
}
|
|
3635
|
+
return {
|
|
3636
|
+
storage: (0, import_random_access_storage.createStorage)({
|
|
3637
|
+
type: persistent ? toStorageType(storageType) : import_random_access_storage.StorageType.RAM,
|
|
3638
|
+
root: `${path}/`
|
|
3639
|
+
})
|
|
3640
|
+
};
|
|
3641
|
+
};
|
|
3642
|
+
var toStorageType = (type) => {
|
|
3643
|
+
switch (type) {
|
|
3644
|
+
case void 0:
|
|
3645
|
+
return void 0;
|
|
3646
|
+
case StorageDriver.RAM:
|
|
3647
|
+
return import_random_access_storage.StorageType.RAM;
|
|
3648
|
+
case StorageDriver.CHROME:
|
|
3649
|
+
return import_random_access_storage.StorageType.CHROME;
|
|
3650
|
+
case StorageDriver.FIREFOX:
|
|
3651
|
+
return import_random_access_storage.StorageType.FIREFOX;
|
|
3652
|
+
case StorageDriver.IDB:
|
|
3653
|
+
return import_random_access_storage.StorageType.IDB;
|
|
3654
|
+
case StorageDriver.NODE:
|
|
3655
|
+
return import_random_access_storage.StorageType.NODE;
|
|
3656
|
+
case StorageDriver.WEBFS:
|
|
3657
|
+
return import_random_access_storage.StorageType.WEBFS;
|
|
3658
|
+
default:
|
|
3659
|
+
throw new Error(`Invalid storage type: ${StorageDriver[type]}`);
|
|
3660
|
+
}
|
|
3661
|
+
};
|
|
3662
|
+
|
|
3663
|
+
// packages/sdk/client-services/src/packlets/system/system-service.ts
|
|
3664
|
+
var import_codec_protobuf13 = require("@dxos/codec-protobuf");
|
|
3665
|
+
var SystemServiceImpl = class {
|
|
3666
|
+
constructor({ config, statusUpdate, onUpdateStatus, getCurrentStatus, onReset }) {
|
|
3667
|
+
this._config = config;
|
|
3668
|
+
this._statusUpdate = statusUpdate;
|
|
3669
|
+
this._getCurrentStatus = getCurrentStatus;
|
|
3670
|
+
this._onUpdateStatus = onUpdateStatus;
|
|
3671
|
+
this._onReset = onReset;
|
|
3672
|
+
}
|
|
3673
|
+
async getConfig() {
|
|
3674
|
+
var _a, _b;
|
|
3675
|
+
return (_b = (_a = this._config) == null ? void 0 : _a.values) != null ? _b : {};
|
|
3676
|
+
}
|
|
3677
|
+
async updateStatus({ status }) {
|
|
3678
|
+
await this._onUpdateStatus(status);
|
|
3679
|
+
}
|
|
3680
|
+
queryStatus() {
|
|
3681
|
+
return new import_codec_protobuf13.Stream(({ next }) => {
|
|
3682
|
+
const update = () => {
|
|
3683
|
+
next({
|
|
3684
|
+
status: this._getCurrentStatus()
|
|
3685
|
+
});
|
|
3686
|
+
};
|
|
3687
|
+
update();
|
|
3688
|
+
const unsubscribe = this._statusUpdate.on(() => update());
|
|
3689
|
+
const interval = setInterval(update, 3e3);
|
|
3690
|
+
return () => {
|
|
3691
|
+
clearInterval(interval);
|
|
3692
|
+
unsubscribe();
|
|
3693
|
+
};
|
|
3694
|
+
});
|
|
3695
|
+
}
|
|
3696
|
+
async reset() {
|
|
3697
|
+
await this._onReset();
|
|
3698
|
+
}
|
|
3699
|
+
};
|
|
3700
|
+
|
|
3700
3701
|
// packages/sdk/client-services/src/packlets/services/service-registry.ts
|
|
3701
3702
|
var ServiceRegistry = class {
|
|
3702
3703
|
// prettier-ignore
|
|
@@ -3953,28 +3954,6 @@ var ClientServicesHost = class {
|
|
|
3953
3954
|
}
|
|
3954
3955
|
};
|
|
3955
3956
|
|
|
3956
|
-
// packages/sdk/client-services/src/packlets/services/local-client-services.ts
|
|
3957
|
-
var LocalClientServices = class {
|
|
3958
|
-
constructor(params) {
|
|
3959
|
-
this._host = new ClientServicesHost(params);
|
|
3960
|
-
}
|
|
3961
|
-
get descriptors() {
|
|
3962
|
-
return this._host.descriptors;
|
|
3963
|
-
}
|
|
3964
|
-
get services() {
|
|
3965
|
-
return this._host.services;
|
|
3966
|
-
}
|
|
3967
|
-
get host() {
|
|
3968
|
-
return this._host;
|
|
3969
|
-
}
|
|
3970
|
-
async open() {
|
|
3971
|
-
await this._host.open();
|
|
3972
|
-
}
|
|
3973
|
-
async close() {
|
|
3974
|
-
await this._host.close();
|
|
3975
|
-
}
|
|
3976
|
-
};
|
|
3977
|
-
|
|
3978
3957
|
// packages/sdk/client-services/src/packlets/vault/iframe-host-runtime.ts
|
|
3979
3958
|
var import_async19 = require("@dxos/async");
|
|
3980
3959
|
var import_client_protocol7 = require("@dxos/client-protocol");
|
|
@@ -4168,7 +4147,7 @@ var IFrameHostRuntime = class {
|
|
|
4168
4147
|
iceServers: this._config.get("runtime.services.ice")
|
|
4169
4148
|
});
|
|
4170
4149
|
const signals = this._config.get("runtime.services.signaling");
|
|
4171
|
-
this._clientServices = new
|
|
4150
|
+
this._clientServices = new ClientServicesHost({
|
|
4172
4151
|
lockKey: LOCK_KEY,
|
|
4173
4152
|
config: this._config,
|
|
4174
4153
|
signalManager: signals ? new import_messaging2.WebsocketSignalManager(signals) : new import_messaging2.MemorySignalManager(new import_messaging2.MemorySignalManagerContext()),
|
|
@@ -4195,7 +4174,7 @@ var IFrameHostRuntime = class {
|
|
|
4195
4174
|
}
|
|
4196
4175
|
};
|
|
4197
4176
|
this._clientRpc = new ClientRpcServer({
|
|
4198
|
-
serviceRegistry: this._clientServices.
|
|
4177
|
+
serviceRegistry: this._clientServices.serviceRegistry,
|
|
4199
4178
|
port: this._appPort,
|
|
4200
4179
|
...middleware
|
|
4201
4180
|
});
|
|
@@ -4585,7 +4564,6 @@ var WorkerRuntime = class {
|
|
|
4585
4564
|
IdentityServiceImpl,
|
|
4586
4565
|
InvitationsHandler,
|
|
4587
4566
|
InvitationsServiceImpl,
|
|
4588
|
-
LocalClientServices,
|
|
4589
4567
|
Lock,
|
|
4590
4568
|
MemoryShellRuntime,
|
|
4591
4569
|
ServiceContext,
|