@dxos/client-services 0.1.53-main.f5aedb7 → 0.1.53-next.3ab34c0
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-PWZ2J6KS.mjs → chunk-F4BHRFH4.mjs} +250 -115
- package/dist/lib/browser/chunk-F4BHRFH4.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +20 -59
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/packlets/testing/index.mjs +19 -2
- package/dist/lib/browser/packlets/testing/index.mjs.map +3 -3
- package/dist/lib/node/index.cjs +274 -179
- 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 +247 -145
- package/dist/lib/node/packlets/testing/index.cjs.map +4 -4
- package/dist/types/src/packlets/identity/authenticator.d.ts.map +1 -1
- package/dist/types/src/packlets/identity/identity.d.ts.map +1 -1
- package/dist/types/src/packlets/services/index.d.ts +1 -0
- package/dist/types/src/packlets/services/index.d.ts.map +1 -1
- package/dist/types/src/packlets/services/service-context.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/data-space-manager.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/data-space.d.ts +11 -2
- package/dist/types/src/packlets/spaces/data-space.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/notarization-plugin.d.ts +2 -1
- package/dist/types/src/packlets/spaces/notarization-plugin.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/spaces-service.d.ts +1 -1
- package/dist/types/src/packlets/spaces/spaces-service.d.ts.map +1 -1
- package/dist/types/src/packlets/testing/test-builder.d.ts +7 -1
- package/dist/types/src/packlets/testing/test-builder.d.ts.map +1 -1
- package/dist/types/src/packlets/vault/worker-session.d.ts.map +1 -1
- package/package.json +32 -32
- package/src/packlets/identity/authenticator.ts +4 -2
- package/src/packlets/identity/identity.ts +21 -26
- package/src/packlets/services/index.ts +1 -0
- package/src/packlets/services/service-context.ts +9 -7
- package/src/packlets/spaces/data-space-manager.test.ts +75 -119
- package/src/packlets/spaces/data-space-manager.ts +13 -3
- package/src/packlets/spaces/data-space.ts +66 -20
- package/src/packlets/spaces/notarization-plugin.test.ts +1 -1
- package/src/packlets/spaces/notarization-plugin.ts +5 -1
- package/src/packlets/spaces/spaces-service.test.ts +5 -3
- package/src/packlets/spaces/spaces-service.ts +26 -8
- package/src/packlets/testing/test-builder.ts +35 -2
- package/src/packlets/vault/worker-session.ts +5 -4
- package/dist/lib/browser/chunk-PWZ2J6KS.mjs.map +0 -7
|
@@ -353,6 +353,7 @@ import { verifyCredential } from "@dxos/credentials";
|
|
|
353
353
|
import { log } from "@dxos/log";
|
|
354
354
|
import { schema } from "@dxos/protocols";
|
|
355
355
|
var __dxlog_file = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/authenticator.ts";
|
|
356
|
+
var Credential = schema.getCodecForType("dxos.halo.credentials.Credential");
|
|
356
357
|
var createAuthProvider = (signer) => async (nonce) => {
|
|
357
358
|
const credential = await signer.createCredential({
|
|
358
359
|
assertion: {
|
|
@@ -361,7 +362,7 @@ var createAuthProvider = (signer) => async (nonce) => {
|
|
|
361
362
|
subject: signer.getIssuer(),
|
|
362
363
|
nonce
|
|
363
364
|
});
|
|
364
|
-
return
|
|
365
|
+
return Credential.encode(credential);
|
|
365
366
|
};
|
|
366
367
|
var TrustedKeySetAuthVerifier = class {
|
|
367
368
|
// prettier-ignore
|
|
@@ -374,12 +375,12 @@ var TrustedKeySetAuthVerifier = class {
|
|
|
374
375
|
}
|
|
375
376
|
get verifier() {
|
|
376
377
|
return async (nonce, auth) => {
|
|
377
|
-
const credential =
|
|
378
|
+
const credential = Credential.decode(auth);
|
|
378
379
|
log("authenticating...", {
|
|
379
380
|
credential
|
|
380
381
|
}, {
|
|
381
382
|
F: __dxlog_file,
|
|
382
|
-
L:
|
|
383
|
+
L: 59,
|
|
383
384
|
S: this,
|
|
384
385
|
C: (f, a) => f(...a)
|
|
385
386
|
});
|
|
@@ -389,7 +390,7 @@ var TrustedKeySetAuthVerifier = class {
|
|
|
389
390
|
result
|
|
390
391
|
}, {
|
|
391
392
|
F: __dxlog_file,
|
|
392
|
-
L:
|
|
393
|
+
L: 63,
|
|
393
394
|
S: this,
|
|
394
395
|
C: (f, a) => f(...a)
|
|
395
396
|
});
|
|
@@ -401,7 +402,7 @@ var TrustedKeySetAuthVerifier = class {
|
|
|
401
402
|
credential
|
|
402
403
|
}, {
|
|
403
404
|
F: __dxlog_file,
|
|
404
|
-
L:
|
|
405
|
+
L: 68,
|
|
405
406
|
S: this,
|
|
406
407
|
C: (f, a) => f(...a)
|
|
407
408
|
});
|
|
@@ -412,7 +413,7 @@ var TrustedKeySetAuthVerifier = class {
|
|
|
412
413
|
key: credential.issuer
|
|
413
414
|
}, {
|
|
414
415
|
F: __dxlog_file,
|
|
415
|
-
L:
|
|
416
|
+
L: 73,
|
|
416
417
|
S: this,
|
|
417
418
|
C: (f, a) => f(...a)
|
|
418
419
|
});
|
|
@@ -428,7 +429,7 @@ var TrustedKeySetAuthVerifier = class {
|
|
|
428
429
|
key: credential.issuer
|
|
429
430
|
}, {
|
|
430
431
|
F: __dxlog_file,
|
|
431
|
-
L:
|
|
432
|
+
L: 84,
|
|
432
433
|
S: this,
|
|
433
434
|
C: (f, a) => f(...a)
|
|
434
435
|
});
|
|
@@ -438,7 +439,7 @@ var TrustedKeySetAuthVerifier = class {
|
|
|
438
439
|
key: credential.issuer
|
|
439
440
|
}, {
|
|
440
441
|
F: __dxlog_file,
|
|
441
|
-
L:
|
|
442
|
+
L: 87,
|
|
442
443
|
S: this,
|
|
443
444
|
C: (f, a) => f(...a)
|
|
444
445
|
});
|
|
@@ -478,15 +479,15 @@ var Identity = class {
|
|
|
478
479
|
this._signer = signer;
|
|
479
480
|
this.identityKey = identityKey;
|
|
480
481
|
this.deviceKey = deviceKey;
|
|
481
|
-
this._deviceStateMachine =
|
|
482
|
+
this._deviceStateMachine = new DeviceStateMachine({
|
|
482
483
|
identityKey: this.identityKey,
|
|
483
484
|
deviceKey: this.deviceKey,
|
|
484
485
|
onUpdate: () => this.stateUpdate.emit()
|
|
485
|
-
})
|
|
486
|
-
this._profileStateMachine =
|
|
486
|
+
});
|
|
487
|
+
this._profileStateMachine = new ProfileStateMachine({
|
|
487
488
|
identityKey: this.identityKey,
|
|
488
489
|
onUpdate: () => this.stateUpdate.emit()
|
|
489
|
-
})
|
|
490
|
+
});
|
|
490
491
|
this.authVerifier = new TrustedKeySetAuthVerifier({
|
|
491
492
|
trustedKeysProvider: () => this.authorizedDeviceKeys,
|
|
492
493
|
update: this.stateUpdate,
|
|
@@ -495,27 +496,27 @@ var Identity = class {
|
|
|
495
496
|
}
|
|
496
497
|
// TODO(burdon): Expose state object?
|
|
497
498
|
get authorizedDeviceKeys() {
|
|
498
|
-
return this._deviceStateMachine.
|
|
499
|
+
return this._deviceStateMachine.authorizedDeviceKeys;
|
|
499
500
|
}
|
|
500
501
|
async open() {
|
|
501
|
-
await this.
|
|
502
|
-
await this.
|
|
502
|
+
await this.space.spaceState.addCredentialProcessor(this._deviceStateMachine);
|
|
503
|
+
await this.space.spaceState.addCredentialProcessor(this._profileStateMachine);
|
|
503
504
|
await this.space.open();
|
|
504
505
|
}
|
|
505
506
|
async close() {
|
|
506
507
|
await this.authVerifier.close();
|
|
507
|
-
await this.
|
|
508
|
-
await this.
|
|
508
|
+
await this.space.spaceState.removeCredentialProcessor(this._profileStateMachine);
|
|
509
|
+
await this.space.spaceState.removeCredentialProcessor(this._deviceStateMachine);
|
|
509
510
|
await this.space.close();
|
|
510
511
|
}
|
|
511
512
|
async ready() {
|
|
512
|
-
await this._deviceStateMachine.
|
|
513
|
+
await this._deviceStateMachine.deviceChainReady.wait();
|
|
513
514
|
await this.controlPipeline.state.waitUntilReachedTargetTimeframe({
|
|
514
515
|
timeout: LOAD_CONTROL_FEEDS_TIMEOUT
|
|
515
516
|
});
|
|
516
517
|
}
|
|
517
518
|
get profileDocument() {
|
|
518
|
-
return this._profileStateMachine.
|
|
519
|
+
return this._profileStateMachine.profile;
|
|
519
520
|
}
|
|
520
521
|
/**
|
|
521
522
|
* @test-only
|
|
@@ -530,7 +531,7 @@ var Identity = class {
|
|
|
530
531
|
return this.space.genesisFeedKey;
|
|
531
532
|
}
|
|
532
533
|
get deviceCredentialChain() {
|
|
533
|
-
return this._deviceStateMachine.
|
|
534
|
+
return this._deviceStateMachine.deviceCredentialChain;
|
|
534
535
|
}
|
|
535
536
|
getAdmissionCredentials() {
|
|
536
537
|
var _a, _b;
|
|
@@ -545,8 +546,8 @@ var Identity = class {
|
|
|
545
546
|
* Requires identity to be ready.
|
|
546
547
|
*/
|
|
547
548
|
getIdentityCredentialSigner() {
|
|
548
|
-
invariant(this._deviceStateMachine.
|
|
549
|
-
return createCredentialSignerWithChain(this._signer, this._deviceStateMachine.
|
|
549
|
+
invariant(this._deviceStateMachine.deviceCredentialChain, "Device credential chain is not ready.");
|
|
550
|
+
return createCredentialSignerWithChain(this._signer, this._deviceStateMachine.deviceCredentialChain, this.deviceKey);
|
|
550
551
|
}
|
|
551
552
|
/**
|
|
552
553
|
* Issues credentials as device.
|
|
@@ -563,7 +564,7 @@ var Identity = class {
|
|
|
563
564
|
dataFeedKey
|
|
564
565
|
}, {
|
|
565
566
|
F: __dxlog_file2,
|
|
566
|
-
L:
|
|
567
|
+
L: 151,
|
|
567
568
|
S: this,
|
|
568
569
|
C: (f, a) => f(...a)
|
|
569
570
|
});
|
|
@@ -2081,8 +2082,61 @@ var SpaceInvitationProtocol = class {
|
|
|
2081
2082
|
}
|
|
2082
2083
|
};
|
|
2083
2084
|
|
|
2085
|
+
// packages/sdk/client-services/src/packlets/services/client-rpc-server.ts
|
|
2086
|
+
import { Stream as Stream9 } from "@dxos/codec-protobuf";
|
|
2087
|
+
import { raise } from "@dxos/debug";
|
|
2088
|
+
import { parseMethodName, RpcPeer } from "@dxos/rpc";
|
|
2089
|
+
var ClientRpcServer = class {
|
|
2090
|
+
constructor(params) {
|
|
2091
|
+
this._handlerCache = /* @__PURE__ */ new Map();
|
|
2092
|
+
const { serviceRegistry, handleCall, handleStream, ...rpcOptions } = params;
|
|
2093
|
+
this._handleCall = handleCall;
|
|
2094
|
+
this._handleStream = handleStream;
|
|
2095
|
+
this._serviceRegistry = serviceRegistry;
|
|
2096
|
+
this._rpcPeer = new RpcPeer({
|
|
2097
|
+
...rpcOptions,
|
|
2098
|
+
callHandler: (method, params2) => {
|
|
2099
|
+
const [serviceName, methodName] = parseMethodName(method);
|
|
2100
|
+
const handler = (method2, params3) => this._getServiceHandler(serviceName).call(method2, params3);
|
|
2101
|
+
if (this._handleCall) {
|
|
2102
|
+
return this._handleCall(methodName, params2, handler);
|
|
2103
|
+
} else {
|
|
2104
|
+
return handler(methodName, params2);
|
|
2105
|
+
}
|
|
2106
|
+
},
|
|
2107
|
+
streamHandler: (method, params2) => {
|
|
2108
|
+
const [serviceName, methodName] = parseMethodName(method);
|
|
2109
|
+
const handler = (method2, params3) => this._getServiceHandler(serviceName).callStream(method2, params3);
|
|
2110
|
+
if (this._handleStream) {
|
|
2111
|
+
return Stream9.unwrapPromise(this._handleStream(methodName, params2, handler));
|
|
2112
|
+
} else {
|
|
2113
|
+
return handler(methodName, params2);
|
|
2114
|
+
}
|
|
2115
|
+
}
|
|
2116
|
+
});
|
|
2117
|
+
}
|
|
2118
|
+
async open() {
|
|
2119
|
+
await this._rpcPeer.open();
|
|
2120
|
+
}
|
|
2121
|
+
async close() {
|
|
2122
|
+
await this._rpcPeer.close();
|
|
2123
|
+
}
|
|
2124
|
+
_getServiceHandler(serviceName) {
|
|
2125
|
+
var _a;
|
|
2126
|
+
if (!this._handlerCache.has(serviceName)) {
|
|
2127
|
+
const [key, descriptor] = (_a = Object.entries(this._serviceRegistry.descriptors).find(([key2, descriptor2]) => descriptor2.name === serviceName)) != null ? _a : raise(new Error(`Service not available: ${serviceName}`));
|
|
2128
|
+
const service = this._serviceRegistry.services[key];
|
|
2129
|
+
if (!service) {
|
|
2130
|
+
throw new Error(`Service not available: ${serviceName}`);
|
|
2131
|
+
}
|
|
2132
|
+
this._handlerCache.set(serviceName, descriptor.createServer(service));
|
|
2133
|
+
}
|
|
2134
|
+
return this._handlerCache.get(serviceName);
|
|
2135
|
+
}
|
|
2136
|
+
};
|
|
2137
|
+
|
|
2084
2138
|
// packages/sdk/client-services/src/packlets/spaces/data-space.ts
|
|
2085
|
-
import { Event as Event5, scheduleTask as scheduleTask4, trackLeaks } from "@dxos/async";
|
|
2139
|
+
import { Event as Event5, scheduleTask as scheduleTask4, synchronized, trackLeaks } from "@dxos/async";
|
|
2086
2140
|
import { AUTH_TIMEOUT as AUTH_TIMEOUT2 } from "@dxos/client-protocol";
|
|
2087
2141
|
import { cancelWithContext as cancelWithContext2, Context as Context6 } from "@dxos/context";
|
|
2088
2142
|
import { timed } from "@dxos/debug";
|
|
@@ -2117,6 +2171,9 @@ var NotarizationPlugin = class {
|
|
|
2117
2171
|
this._processedCredentials = new ComplexSet(PublicKey6.hash);
|
|
2118
2172
|
this._processCredentialsTriggers = new ComplexMap2(PublicKey6.hash);
|
|
2119
2173
|
}
|
|
2174
|
+
get hasWriter() {
|
|
2175
|
+
return !!this._writer;
|
|
2176
|
+
}
|
|
2120
2177
|
async open() {
|
|
2121
2178
|
}
|
|
2122
2179
|
async close() {
|
|
@@ -2130,7 +2187,7 @@ var NotarizationPlugin = class {
|
|
|
2130
2187
|
credentials
|
|
2131
2188
|
}, {
|
|
2132
2189
|
F: __dxlog_file8,
|
|
2133
|
-
L:
|
|
2190
|
+
L: 91,
|
|
2134
2191
|
S: this,
|
|
2135
2192
|
C: (f, a) => f(...a)
|
|
2136
2193
|
});
|
|
@@ -2142,7 +2199,7 @@ var NotarizationPlugin = class {
|
|
|
2142
2199
|
err
|
|
2143
2200
|
}, {
|
|
2144
2201
|
F: __dxlog_file8,
|
|
2145
|
-
L:
|
|
2202
|
+
L: 100,
|
|
2146
2203
|
S: this,
|
|
2147
2204
|
C: (f, a) => f(...a)
|
|
2148
2205
|
});
|
|
@@ -2158,7 +2215,7 @@ var NotarizationPlugin = class {
|
|
|
2158
2215
|
peers: Array.from(this._extensions).map((extension) => extension.remotePeerId)
|
|
2159
2216
|
}, {
|
|
2160
2217
|
F: __dxlog_file8,
|
|
2161
|
-
L:
|
|
2218
|
+
L: 112,
|
|
2162
2219
|
S: this,
|
|
2163
2220
|
C: (f, a) => f(...a)
|
|
2164
2221
|
});
|
|
@@ -2181,7 +2238,7 @@ var NotarizationPlugin = class {
|
|
|
2181
2238
|
retryIn: retryTimeout
|
|
2182
2239
|
}, {
|
|
2183
2240
|
F: __dxlog_file8,
|
|
2184
|
-
L:
|
|
2241
|
+
L: 137,
|
|
2185
2242
|
S: this,
|
|
2186
2243
|
C: (f, a) => f(...a)
|
|
2187
2244
|
});
|
|
@@ -2195,7 +2252,7 @@ var NotarizationPlugin = class {
|
|
|
2195
2252
|
credentialId: credentials.map((credential) => credential.id)
|
|
2196
2253
|
}, {
|
|
2197
2254
|
F: __dxlog_file8,
|
|
2198
|
-
L:
|
|
2255
|
+
L: 144,
|
|
2199
2256
|
S: this,
|
|
2200
2257
|
C: (f, a) => f(...a)
|
|
2201
2258
|
});
|
|
@@ -2204,7 +2261,7 @@ var NotarizationPlugin = class {
|
|
|
2204
2261
|
});
|
|
2205
2262
|
log8("success", void 0, {
|
|
2206
2263
|
F: __dxlog_file8,
|
|
2207
|
-
L:
|
|
2264
|
+
L: 148,
|
|
2208
2265
|
S: this,
|
|
2209
2266
|
C: (f, a) => f(...a)
|
|
2210
2267
|
});
|
|
@@ -2213,7 +2270,7 @@ var NotarizationPlugin = class {
|
|
|
2213
2270
|
if (!ctx.disposed && !err.message.includes(WRITER_NOT_SET_ERROR_CODE)) {
|
|
2214
2271
|
log8.warn("error notarizing (recoverable)", err, {
|
|
2215
2272
|
F: __dxlog_file8,
|
|
2216
|
-
L:
|
|
2273
|
+
L: 152,
|
|
2217
2274
|
S: this,
|
|
2218
2275
|
C: (f, a) => f(...a)
|
|
2219
2276
|
});
|
|
@@ -2231,7 +2288,7 @@ var NotarizationPlugin = class {
|
|
|
2231
2288
|
]);
|
|
2232
2289
|
log8("done", void 0, {
|
|
2233
2290
|
F: __dxlog_file8,
|
|
2234
|
-
L:
|
|
2291
|
+
L: 163,
|
|
2235
2292
|
S: this,
|
|
2236
2293
|
C: (f, a) => f(...a)
|
|
2237
2294
|
});
|
|
@@ -2242,7 +2299,7 @@ var NotarizationPlugin = class {
|
|
|
2242
2299
|
/**
|
|
2243
2300
|
* Called with credentials arriving from the control pipeline.
|
|
2244
2301
|
*/
|
|
2245
|
-
async
|
|
2302
|
+
async processCredential(credential) {
|
|
2246
2303
|
var _a;
|
|
2247
2304
|
if (!credential.id) {
|
|
2248
2305
|
return;
|
|
@@ -2284,7 +2341,7 @@ var NotarizationPlugin = class {
|
|
|
2284
2341
|
peer: extension.localPeerId
|
|
2285
2342
|
}, {
|
|
2286
2343
|
F: __dxlog_file8,
|
|
2287
|
-
L:
|
|
2344
|
+
L: 212,
|
|
2288
2345
|
S: this,
|
|
2289
2346
|
C: (f, a) => f(...a)
|
|
2290
2347
|
});
|
|
@@ -2296,7 +2353,7 @@ var NotarizationPlugin = class {
|
|
|
2296
2353
|
peer: extension.localPeerId
|
|
2297
2354
|
}, {
|
|
2298
2355
|
F: __dxlog_file8,
|
|
2299
|
-
L:
|
|
2356
|
+
L: 217,
|
|
2300
2357
|
S: this,
|
|
2301
2358
|
C: (f, a) => f(...a)
|
|
2302
2359
|
});
|
|
@@ -2353,6 +2410,7 @@ var __dxlog_file9 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/sr
|
|
|
2353
2410
|
var DataSpace = class DataSpace2 {
|
|
2354
2411
|
constructor(params) {
|
|
2355
2412
|
this._ctx = new Context6();
|
|
2413
|
+
this._notarizationPlugin = new NotarizationPlugin();
|
|
2356
2414
|
this._state = SpaceState.CLOSED;
|
|
2357
2415
|
/**
|
|
2358
2416
|
* Error for _state === SpaceState.ERROR.
|
|
@@ -2375,8 +2433,8 @@ var DataSpace = class DataSpace2 {
|
|
|
2375
2433
|
update: this._inner.stateUpdate,
|
|
2376
2434
|
authTimeout: AUTH_TIMEOUT2
|
|
2377
2435
|
});
|
|
2378
|
-
this._notarizationPluginConsumer = this._inner.spaceState.registerProcessor(new NotarizationPlugin());
|
|
2379
2436
|
this._cache = params.cache;
|
|
2437
|
+
this._state = params.initialState;
|
|
2380
2438
|
}
|
|
2381
2439
|
get key() {
|
|
2382
2440
|
return this._inner.key;
|
|
@@ -2398,25 +2456,36 @@ var DataSpace = class DataSpace2 {
|
|
|
2398
2456
|
return this._presence;
|
|
2399
2457
|
}
|
|
2400
2458
|
get notarizationPlugin() {
|
|
2401
|
-
return this.
|
|
2459
|
+
return this._notarizationPlugin;
|
|
2402
2460
|
}
|
|
2403
2461
|
get cache() {
|
|
2404
2462
|
return this._cache;
|
|
2405
2463
|
}
|
|
2406
2464
|
async open() {
|
|
2407
|
-
await this.
|
|
2408
|
-
|
|
2465
|
+
await this._open();
|
|
2466
|
+
}
|
|
2467
|
+
async _open() {
|
|
2468
|
+
await this._notarizationPlugin.open();
|
|
2469
|
+
await this._inner.spaceState.addCredentialProcessor(this._notarizationPlugin);
|
|
2409
2470
|
await this._inner.open();
|
|
2410
|
-
this._state = SpaceState.
|
|
2471
|
+
this._state = SpaceState.CONTROL_ONLY;
|
|
2472
|
+
this.stateUpdate.emit();
|
|
2473
|
+
this.metrics = {};
|
|
2411
2474
|
this.metrics.open = new Date();
|
|
2412
2475
|
}
|
|
2413
2476
|
async close() {
|
|
2477
|
+
await this._close();
|
|
2478
|
+
}
|
|
2479
|
+
async _close() {
|
|
2480
|
+
var _a, _b;
|
|
2481
|
+
await ((_b = (_a = this._callbacks).beforeClose) == null ? void 0 : _b.call(_a));
|
|
2414
2482
|
this._state = SpaceState.CLOSED;
|
|
2415
2483
|
await this._ctx.dispose();
|
|
2484
|
+
this._ctx = new Context6();
|
|
2416
2485
|
await this.authVerifier.close();
|
|
2417
2486
|
await this._inner.close();
|
|
2418
|
-
await this.
|
|
2419
|
-
await this.
|
|
2487
|
+
await this._inner.spaceState.removeCredentialProcessor(this._notarizationPlugin);
|
|
2488
|
+
await this._notarizationPlugin.close();
|
|
2420
2489
|
await this._presence.destroy();
|
|
2421
2490
|
}
|
|
2422
2491
|
async postMessage(channel, message) {
|
|
@@ -2437,7 +2506,7 @@ var DataSpace = class DataSpace2 {
|
|
|
2437
2506
|
if (err instanceof CancelledError) {
|
|
2438
2507
|
log9("Data pipeline initialization cancelled", err, {
|
|
2439
2508
|
F: __dxlog_file9,
|
|
2440
|
-
L:
|
|
2509
|
+
L: 193,
|
|
2441
2510
|
S: this,
|
|
2442
2511
|
C: (f, a) => f(...a)
|
|
2443
2512
|
});
|
|
@@ -2445,7 +2514,7 @@ var DataSpace = class DataSpace2 {
|
|
|
2445
2514
|
}
|
|
2446
2515
|
log9.error("Error initializing data pipeline", err, {
|
|
2447
2516
|
F: __dxlog_file9,
|
|
2448
|
-
L:
|
|
2517
|
+
L: 197,
|
|
2449
2518
|
S: this,
|
|
2450
2519
|
C: (f, a) => f(...a)
|
|
2451
2520
|
});
|
|
@@ -2459,7 +2528,7 @@ var DataSpace = class DataSpace2 {
|
|
|
2459
2528
|
}
|
|
2460
2529
|
async initializeDataPipeline() {
|
|
2461
2530
|
var _a, _b, _c, _d;
|
|
2462
|
-
if (this._state !== SpaceState.
|
|
2531
|
+
if (this._state !== SpaceState.CONTROL_ONLY) {
|
|
2463
2532
|
throw new SystemError("Invalid operation");
|
|
2464
2533
|
}
|
|
2465
2534
|
this._state = SpaceState.INITIALIZING;
|
|
@@ -2471,22 +2540,24 @@ var DataSpace = class DataSpace2 {
|
|
|
2471
2540
|
await this._createWritableFeeds();
|
|
2472
2541
|
log9("Writable feeds created", void 0, {
|
|
2473
2542
|
F: __dxlog_file9,
|
|
2474
|
-
L:
|
|
2543
|
+
L: 221,
|
|
2475
2544
|
S: this,
|
|
2476
2545
|
C: (f, a) => f(...a)
|
|
2477
2546
|
});
|
|
2478
2547
|
this.stateUpdate.emit();
|
|
2479
|
-
this.notarizationPlugin.
|
|
2480
|
-
credential
|
|
2481
|
-
credential
|
|
2482
|
-
|
|
2483
|
-
|
|
2548
|
+
if (!this.notarizationPlugin.hasWriter) {
|
|
2549
|
+
this.notarizationPlugin.setWriter(createMappedFeedWriter((credential) => ({
|
|
2550
|
+
credential: {
|
|
2551
|
+
credential
|
|
2552
|
+
}
|
|
2553
|
+
}), this._inner.controlPipeline.writer));
|
|
2554
|
+
}
|
|
2484
2555
|
await this._inner.initializeDataPipeline();
|
|
2485
2556
|
this.metrics.dataPipelineOpen = new Date();
|
|
2486
2557
|
await cancelWithContext2(this._ctx, this._inner.dataPipeline.ensureEpochInitialized());
|
|
2487
2558
|
log9("waiting for data pipeline to reach target timeframe", void 0, {
|
|
2488
2559
|
F: __dxlog_file9,
|
|
2489
|
-
L:
|
|
2560
|
+
L: 242,
|
|
2490
2561
|
S: this,
|
|
2491
2562
|
C: (f, a) => f(...a)
|
|
2492
2563
|
});
|
|
@@ -2497,7 +2568,7 @@ var DataSpace = class DataSpace2 {
|
|
|
2497
2568
|
this.metrics.dataPipelineReady = new Date();
|
|
2498
2569
|
log9("data pipeline ready", void 0, {
|
|
2499
2570
|
F: __dxlog_file9,
|
|
2500
|
-
L:
|
|
2571
|
+
L: 251,
|
|
2501
2572
|
S: this,
|
|
2502
2573
|
C: (f, a) => f(...a)
|
|
2503
2574
|
});
|
|
@@ -2577,17 +2648,46 @@ var DataSpace = class DataSpace2 {
|
|
|
2577
2648
|
}
|
|
2578
2649
|
}
|
|
2579
2650
|
}
|
|
2651
|
+
async activate() {
|
|
2652
|
+
if (this._state !== SpaceState.INACTIVE) {
|
|
2653
|
+
throw new SystemError("Invalid operation");
|
|
2654
|
+
}
|
|
2655
|
+
await this._metadataStore.setSpaceState(this.key, SpaceState.ACTIVE);
|
|
2656
|
+
await this._open();
|
|
2657
|
+
this.initializeDataPipelineAsync();
|
|
2658
|
+
}
|
|
2659
|
+
async deactivate() {
|
|
2660
|
+
if (this._state === SpaceState.INACTIVE) {
|
|
2661
|
+
throw new SystemError("Invalid operation");
|
|
2662
|
+
}
|
|
2663
|
+
await this._metadataStore.setSpaceState(this.key, SpaceState.INACTIVE);
|
|
2664
|
+
await this._close();
|
|
2665
|
+
this._state = SpaceState.INACTIVE;
|
|
2666
|
+
this.stateUpdate.emit();
|
|
2667
|
+
}
|
|
2580
2668
|
};
|
|
2669
|
+
_ts_decorate([
|
|
2670
|
+
synchronized
|
|
2671
|
+
], DataSpace.prototype, "open", null);
|
|
2672
|
+
_ts_decorate([
|
|
2673
|
+
synchronized
|
|
2674
|
+
], DataSpace.prototype, "close", null);
|
|
2581
2675
|
_ts_decorate([
|
|
2582
2676
|
timed(1e4)
|
|
2583
2677
|
], DataSpace.prototype, "_createWritableFeeds", null);
|
|
2678
|
+
_ts_decorate([
|
|
2679
|
+
synchronized
|
|
2680
|
+
], DataSpace.prototype, "activate", null);
|
|
2681
|
+
_ts_decorate([
|
|
2682
|
+
synchronized
|
|
2683
|
+
], DataSpace.prototype, "deactivate", null);
|
|
2584
2684
|
DataSpace = _ts_decorate([
|
|
2585
2685
|
trackLeaks("open", "close")
|
|
2586
2686
|
], DataSpace);
|
|
2587
2687
|
|
|
2588
2688
|
// packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts
|
|
2589
2689
|
import invariant10 from "tiny-invariant";
|
|
2590
|
-
import { Event as Event6, synchronized, trackLeaks as trackLeaks2 } from "@dxos/async";
|
|
2690
|
+
import { Event as Event6, synchronized as synchronized2, trackLeaks as trackLeaks2 } from "@dxos/async";
|
|
2591
2691
|
import { cancelWithContext as cancelWithContext3, Context as Context7 } from "@dxos/context";
|
|
2592
2692
|
import { getCredentialAssertion as getCredentialAssertion2 } from "@dxos/credentials";
|
|
2593
2693
|
import { PublicKey as PublicKey8 } from "@dxos/keys";
|
|
@@ -2732,14 +2832,16 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2732
2832
|
C: (f, a) => f(...a)
|
|
2733
2833
|
});
|
|
2734
2834
|
const space = await this._constructSpace(spaceMetadata);
|
|
2735
|
-
|
|
2835
|
+
if (spaceMetadata.state !== SpaceState2.INACTIVE) {
|
|
2836
|
+
space.initializeDataPipelineAsync();
|
|
2837
|
+
}
|
|
2736
2838
|
} catch (err) {
|
|
2737
2839
|
log10.error("Error loading space", {
|
|
2738
2840
|
spaceMetadata,
|
|
2739
2841
|
err
|
|
2740
2842
|
}, {
|
|
2741
2843
|
F: __dxlog_file10,
|
|
2742
|
-
L:
|
|
2844
|
+
L: 93,
|
|
2743
2845
|
S: this,
|
|
2744
2846
|
C: (f, a) => f(...a)
|
|
2745
2847
|
});
|
|
@@ -2751,7 +2853,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2751
2853
|
id: this._instanceId
|
|
2752
2854
|
}), {
|
|
2753
2855
|
F: __dxlog_file10,
|
|
2754
|
-
L:
|
|
2856
|
+
L: 99,
|
|
2755
2857
|
S: this,
|
|
2756
2858
|
C: (f, a) => f(...a)
|
|
2757
2859
|
});
|
|
@@ -2759,7 +2861,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2759
2861
|
async close() {
|
|
2760
2862
|
log10("close", void 0, {
|
|
2761
2863
|
F: __dxlog_file10,
|
|
2762
|
-
L:
|
|
2864
|
+
L: 104,
|
|
2763
2865
|
S: this,
|
|
2764
2866
|
C: (f, a) => f(...a)
|
|
2765
2867
|
});
|
|
@@ -2781,13 +2883,14 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2781
2883
|
key: spaceKey,
|
|
2782
2884
|
genesisFeedKey: controlFeedKey,
|
|
2783
2885
|
controlFeedKey,
|
|
2784
|
-
dataFeedKey
|
|
2886
|
+
dataFeedKey,
|
|
2887
|
+
state: SpaceState2.ACTIVE
|
|
2785
2888
|
};
|
|
2786
2889
|
log10("creating space...", {
|
|
2787
2890
|
spaceKey
|
|
2788
2891
|
}, {
|
|
2789
2892
|
F: __dxlog_file10,
|
|
2790
|
-
L:
|
|
2893
|
+
L: 129,
|
|
2791
2894
|
S: this,
|
|
2792
2895
|
C: (f, a) => f(...a)
|
|
2793
2896
|
});
|
|
@@ -2807,7 +2910,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2807
2910
|
opts
|
|
2808
2911
|
}, {
|
|
2809
2912
|
F: __dxlog_file10,
|
|
2810
|
-
L:
|
|
2913
|
+
L: 148,
|
|
2811
2914
|
S: this,
|
|
2812
2915
|
C: (f, a) => f(...a)
|
|
2813
2916
|
});
|
|
@@ -2841,7 +2944,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2841
2944
|
metadata
|
|
2842
2945
|
}, {
|
|
2843
2946
|
F: __dxlog_file10,
|
|
2844
|
-
L:
|
|
2947
|
+
L: 183,
|
|
2845
2948
|
S: this,
|
|
2846
2949
|
C: (f, a) => f(...a)
|
|
2847
2950
|
});
|
|
@@ -2877,7 +2980,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2877
2980
|
onAuthFailure: () => {
|
|
2878
2981
|
log10.warn("auth failure", void 0, {
|
|
2879
2982
|
F: __dxlog_file10,
|
|
2880
|
-
L:
|
|
2983
|
+
L: 214,
|
|
2881
2984
|
S: this,
|
|
2882
2985
|
C: (f, a) => f(...a)
|
|
2883
2986
|
});
|
|
@@ -2888,6 +2991,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2888
2991
|
dataFeed && space.setDataFeed(dataFeed);
|
|
2889
2992
|
const dataSpace = new DataSpace({
|
|
2890
2993
|
inner: space,
|
|
2994
|
+
initialState: metadata.state === SpaceState2.INACTIVE ? SpaceState2.INACTIVE : SpaceState2.CLOSED,
|
|
2891
2995
|
metadataStore: this._metadataStore,
|
|
2892
2996
|
gossip,
|
|
2893
2997
|
presence,
|
|
@@ -2900,11 +3004,11 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2900
3004
|
space: space.key
|
|
2901
3005
|
}, {
|
|
2902
3006
|
F: __dxlog_file10,
|
|
2903
|
-
L:
|
|
3007
|
+
L: 232,
|
|
2904
3008
|
S: this,
|
|
2905
3009
|
C: (f, a) => f(...a)
|
|
2906
3010
|
});
|
|
2907
|
-
this._dataServiceSubscriptions.registerSpace(space.key, dataSpace.dataPipeline.databaseHost.createDataServiceHost());
|
|
3011
|
+
await this._dataServiceSubscriptions.registerSpace(space.key, dataSpace.dataPipeline.databaseHost.createDataServiceHost());
|
|
2908
3012
|
},
|
|
2909
3013
|
afterReady: async () => {
|
|
2910
3014
|
log10("after space ready", {
|
|
@@ -2912,18 +3016,31 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2912
3016
|
open: this._isOpen
|
|
2913
3017
|
}, {
|
|
2914
3018
|
F: __dxlog_file10,
|
|
2915
|
-
L:
|
|
3019
|
+
L: 239,
|
|
2916
3020
|
S: this,
|
|
2917
3021
|
C: (f, a) => f(...a)
|
|
2918
3022
|
});
|
|
2919
3023
|
if (this._isOpen) {
|
|
2920
3024
|
this.updated.emit();
|
|
2921
3025
|
}
|
|
3026
|
+
},
|
|
3027
|
+
beforeClose: async () => {
|
|
3028
|
+
log10("before space close", {
|
|
3029
|
+
space: space.key
|
|
3030
|
+
}, {
|
|
3031
|
+
F: __dxlog_file10,
|
|
3032
|
+
L: 245,
|
|
3033
|
+
S: this,
|
|
3034
|
+
C: (f, a) => f(...a)
|
|
3035
|
+
});
|
|
3036
|
+
await this._dataServiceSubscriptions.unregisterSpace(space.key);
|
|
2922
3037
|
}
|
|
2923
3038
|
},
|
|
2924
3039
|
cache: metadata.cache
|
|
2925
3040
|
});
|
|
2926
|
-
|
|
3041
|
+
if (metadata.state !== SpaceState2.INACTIVE) {
|
|
3042
|
+
await dataSpace.open();
|
|
3043
|
+
}
|
|
2927
3044
|
if (metadata.controlTimeframe) {
|
|
2928
3045
|
dataSpace.inner.controlPipeline.state.setTargetTimeframe(metadata.controlTimeframe);
|
|
2929
3046
|
}
|
|
@@ -2935,16 +3052,16 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2935
3052
|
}
|
|
2936
3053
|
};
|
|
2937
3054
|
_ts_decorate2([
|
|
2938
|
-
|
|
3055
|
+
synchronized2
|
|
2939
3056
|
], DataSpaceManager.prototype, "open", null);
|
|
2940
3057
|
_ts_decorate2([
|
|
2941
|
-
|
|
3058
|
+
synchronized2
|
|
2942
3059
|
], DataSpaceManager.prototype, "close", null);
|
|
2943
3060
|
_ts_decorate2([
|
|
2944
|
-
|
|
3061
|
+
synchronized2
|
|
2945
3062
|
], DataSpaceManager.prototype, "createSpace", null);
|
|
2946
3063
|
_ts_decorate2([
|
|
2947
|
-
|
|
3064
|
+
synchronized2
|
|
2948
3065
|
], DataSpaceManager.prototype, "acceptSpace", null);
|
|
2949
3066
|
DataSpaceManager = _ts_decorate2([
|
|
2950
3067
|
trackLeaks2("open", "close")
|
|
@@ -2952,12 +3069,13 @@ DataSpaceManager = _ts_decorate2([
|
|
|
2952
3069
|
|
|
2953
3070
|
// packages/sdk/client-services/src/packlets/spaces/spaces-service.ts
|
|
2954
3071
|
import { EventSubscriptions as EventSubscriptions2, UpdateScheduler, scheduleTask as scheduleTask5 } from "@dxos/async";
|
|
2955
|
-
import { Stream as
|
|
2956
|
-
import { raise
|
|
3072
|
+
import { Stream as Stream10 } from "@dxos/codec-protobuf";
|
|
3073
|
+
import { raise as raise2 } from "@dxos/debug";
|
|
2957
3074
|
import { SpaceNotFoundError } from "@dxos/echo-pipeline";
|
|
3075
|
+
import { ApiError } from "@dxos/errors";
|
|
2958
3076
|
import { log as log11 } from "@dxos/log";
|
|
2959
3077
|
import { encodeError } from "@dxos/protocols";
|
|
2960
|
-
import { SpaceMember as SpaceMember2 } from "@dxos/protocols/proto/dxos/client/services";
|
|
3078
|
+
import { SpaceMember as SpaceMember2, SpaceState as SpaceState3 } from "@dxos/protocols/proto/dxos/client/services";
|
|
2961
3079
|
import { humanize } from "@dxos/util";
|
|
2962
3080
|
var __dxlog_file11 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/spaces-service.ts";
|
|
2963
3081
|
var SpacesServiceImpl = class {
|
|
@@ -2975,11 +3093,25 @@ var SpacesServiceImpl = class {
|
|
|
2975
3093
|
const space = await dataSpaceManager.createSpace();
|
|
2976
3094
|
return this._serializeSpace(space);
|
|
2977
3095
|
}
|
|
2978
|
-
async updateSpace(
|
|
2979
|
-
|
|
3096
|
+
async updateSpace({ spaceKey, state }) {
|
|
3097
|
+
var _a;
|
|
3098
|
+
const dataSpaceManager = await this._getDataSpaceManager();
|
|
3099
|
+
const space = (_a = dataSpaceManager.spaces.get(spaceKey)) != null ? _a : raise2(new SpaceNotFoundError(spaceKey));
|
|
3100
|
+
if (state) {
|
|
3101
|
+
switch (state) {
|
|
3102
|
+
case SpaceState3.ACTIVE:
|
|
3103
|
+
await space.activate();
|
|
3104
|
+
break;
|
|
3105
|
+
case SpaceState3.INACTIVE:
|
|
3106
|
+
await space.deactivate();
|
|
3107
|
+
break;
|
|
3108
|
+
default:
|
|
3109
|
+
throw new ApiError("Invalid space state");
|
|
3110
|
+
}
|
|
3111
|
+
}
|
|
2980
3112
|
}
|
|
2981
3113
|
querySpaces() {
|
|
2982
|
-
return new
|
|
3114
|
+
return new Stream10(({ next, ctx }) => {
|
|
2983
3115
|
const scheduler = new UpdateScheduler(ctx, async () => {
|
|
2984
3116
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
2985
3117
|
const spaces = Array.from(dataSpaceManager.spaces.values()).map((space) => this._serializeSpace(space));
|
|
@@ -2987,7 +3119,7 @@ var SpacesServiceImpl = class {
|
|
|
2987
3119
|
spaces
|
|
2988
3120
|
}, {
|
|
2989
3121
|
F: __dxlog_file11,
|
|
2990
|
-
L:
|
|
3122
|
+
L: 78,
|
|
2991
3123
|
S: this,
|
|
2992
3124
|
C: (f, a) => f(...a)
|
|
2993
3125
|
});
|
|
@@ -3030,15 +3162,15 @@ var SpacesServiceImpl = class {
|
|
|
3030
3162
|
async postMessage({ spaceKey, channel, message }) {
|
|
3031
3163
|
var _a;
|
|
3032
3164
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
3033
|
-
const space = (_a = dataSpaceManager.spaces.get(spaceKey)) != null ? _a :
|
|
3165
|
+
const space = (_a = dataSpaceManager.spaces.get(spaceKey)) != null ? _a : raise2(new SpaceNotFoundError(spaceKey));
|
|
3034
3166
|
await space.postMessage(getChannelId(channel), message);
|
|
3035
3167
|
}
|
|
3036
3168
|
subscribeMessages({ spaceKey, channel }) {
|
|
3037
|
-
return new
|
|
3169
|
+
return new Stream10(({ ctx, next }) => {
|
|
3038
3170
|
scheduleTask5(ctx, async () => {
|
|
3039
3171
|
var _a;
|
|
3040
3172
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
3041
|
-
const space = (_a = dataSpaceManager.spaces.get(spaceKey)) != null ? _a :
|
|
3173
|
+
const space = (_a = dataSpaceManager.spaces.get(spaceKey)) != null ? _a : raise2(new SpaceNotFoundError(spaceKey));
|
|
3042
3174
|
const handle = space.listen(getChannelId(channel), (message) => {
|
|
3043
3175
|
next(message);
|
|
3044
3176
|
});
|
|
@@ -3047,21 +3179,21 @@ var SpacesServiceImpl = class {
|
|
|
3047
3179
|
});
|
|
3048
3180
|
}
|
|
3049
3181
|
queryCredentials({ spaceKey }) {
|
|
3050
|
-
return new
|
|
3182
|
+
return new Stream10(({ ctx, next }) => {
|
|
3051
3183
|
var _a;
|
|
3052
|
-
const space = (_a = this._spaceManager.spaces.get(spaceKey)) != null ? _a :
|
|
3053
|
-
const processor =
|
|
3054
|
-
|
|
3184
|
+
const space = (_a = this._spaceManager.spaces.get(spaceKey)) != null ? _a : raise2(new SpaceNotFoundError(spaceKey));
|
|
3185
|
+
const processor = {
|
|
3186
|
+
processCredential: async (credential) => {
|
|
3055
3187
|
next(credential);
|
|
3056
3188
|
}
|
|
3057
|
-
}
|
|
3058
|
-
ctx.onDispose(() =>
|
|
3059
|
-
scheduleTask5(ctx, () =>
|
|
3189
|
+
};
|
|
3190
|
+
ctx.onDispose(() => space.spaceState.removeCredentialProcessor(processor));
|
|
3191
|
+
scheduleTask5(ctx, () => space.spaceState.addCredentialProcessor(processor));
|
|
3060
3192
|
});
|
|
3061
3193
|
}
|
|
3062
3194
|
async writeCredentials({ spaceKey, credentials }) {
|
|
3063
3195
|
var _a;
|
|
3064
|
-
const space = (_a = this._spaceManager.spaces.get(spaceKey)) != null ? _a :
|
|
3196
|
+
const space = (_a = this._spaceManager.spaces.get(spaceKey)) != null ? _a : raise2(new SpaceNotFoundError(spaceKey));
|
|
3065
3197
|
for (const credential of credentials != null ? credentials : []) {
|
|
3066
3198
|
await space.controlPipeline.writer.write({
|
|
3067
3199
|
credential: {
|
|
@@ -3073,7 +3205,7 @@ var SpacesServiceImpl = class {
|
|
|
3073
3205
|
async createEpoch({ spaceKey }) {
|
|
3074
3206
|
var _a;
|
|
3075
3207
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
3076
|
-
const space = (_a = dataSpaceManager.spaces.get(spaceKey)) != null ? _a :
|
|
3208
|
+
const space = (_a = dataSpaceManager.spaces.get(spaceKey)) != null ? _a : raise2(new SpaceNotFoundError(spaceKey));
|
|
3077
3209
|
await space.createEpoch();
|
|
3078
3210
|
}
|
|
3079
3211
|
_serializeSpace(space) {
|
|
@@ -3207,15 +3339,17 @@ var ServiceContext = class {
|
|
|
3207
3339
|
});
|
|
3208
3340
|
}
|
|
3209
3341
|
async close() {
|
|
3210
|
-
var _a
|
|
3342
|
+
var _a;
|
|
3211
3343
|
log12("closing...", void 0, {
|
|
3212
3344
|
F: __dxlog_file12,
|
|
3213
3345
|
L: 143,
|
|
3214
3346
|
S: this,
|
|
3215
3347
|
C: (f, a) => f(...a)
|
|
3216
3348
|
});
|
|
3217
|
-
|
|
3218
|
-
|
|
3349
|
+
if (this._deviceSpaceSync && this.identityManager.identity) {
|
|
3350
|
+
await this.identityManager.identity.space.spaceState.removeCredentialProcessor(this._deviceSpaceSync);
|
|
3351
|
+
}
|
|
3352
|
+
await ((_a = this.dataSpaceManager) == null ? void 0 : _a.close());
|
|
3219
3353
|
await this.identityManager.close();
|
|
3220
3354
|
await this.spaceManager.close();
|
|
3221
3355
|
await this.feedStore.close();
|
|
@@ -3224,7 +3358,7 @@ var ServiceContext = class {
|
|
|
3224
3358
|
this.dataServiceSubscriptions.clear();
|
|
3225
3359
|
log12("closed", void 0, {
|
|
3226
3360
|
F: __dxlog_file12,
|
|
3227
|
-
L:
|
|
3361
|
+
L: 154,
|
|
3228
3362
|
S: this,
|
|
3229
3363
|
C: (f, a) => f(...a)
|
|
3230
3364
|
});
|
|
@@ -3255,7 +3389,7 @@ var ServiceContext = class {
|
|
|
3255
3389
|
var _a;
|
|
3256
3390
|
log12("initializing spaces...", void 0, {
|
|
3257
3391
|
F: __dxlog_file12,
|
|
3258
|
-
L:
|
|
3392
|
+
L: 187,
|
|
3259
3393
|
S: this,
|
|
3260
3394
|
C: (f, a) => f(...a)
|
|
3261
3395
|
});
|
|
@@ -3280,8 +3414,8 @@ var ServiceContext = class {
|
|
|
3280
3414
|
return new SpaceInvitationProtocol(this.dataSpaceManager, signingContext, this.keyring, invitation.spaceKey);
|
|
3281
3415
|
});
|
|
3282
3416
|
this.initialized.wake();
|
|
3283
|
-
this._deviceSpaceSync =
|
|
3284
|
-
|
|
3417
|
+
this._deviceSpaceSync = {
|
|
3418
|
+
processCredential: async (credential) => {
|
|
3285
3419
|
const assertion = getCredentialAssertion3(credential);
|
|
3286
3420
|
if (assertion["@type"] !== "dxos.halo.credentials.SpaceMember") {
|
|
3287
3421
|
return;
|
|
@@ -3294,7 +3428,7 @@ var ServiceContext = class {
|
|
|
3294
3428
|
details: assertion
|
|
3295
3429
|
}, {
|
|
3296
3430
|
F: __dxlog_file12,
|
|
3297
|
-
L:
|
|
3431
|
+
L: 226,
|
|
3298
3432
|
S: this,
|
|
3299
3433
|
C: (f, a) => f(...a)
|
|
3300
3434
|
});
|
|
@@ -3305,7 +3439,7 @@ var ServiceContext = class {
|
|
|
3305
3439
|
details: assertion
|
|
3306
3440
|
}, {
|
|
3307
3441
|
F: __dxlog_file12,
|
|
3308
|
-
L:
|
|
3442
|
+
L: 230,
|
|
3309
3443
|
S: this,
|
|
3310
3444
|
C: (f, a) => f(...a)
|
|
3311
3445
|
});
|
|
@@ -3316,7 +3450,7 @@ var ServiceContext = class {
|
|
|
3316
3450
|
details: assertion
|
|
3317
3451
|
}, {
|
|
3318
3452
|
F: __dxlog_file12,
|
|
3319
|
-
L:
|
|
3453
|
+
L: 235,
|
|
3320
3454
|
S: this,
|
|
3321
3455
|
C: (f, a) => f(...a)
|
|
3322
3456
|
});
|
|
@@ -3327,14 +3461,14 @@ var ServiceContext = class {
|
|
|
3327
3461
|
} catch (err) {
|
|
3328
3462
|
log12.catch(err, void 0, {
|
|
3329
3463
|
F: __dxlog_file12,
|
|
3330
|
-
L:
|
|
3464
|
+
L: 241,
|
|
3331
3465
|
S: this,
|
|
3332
3466
|
C: (f, a) => f(...a)
|
|
3333
3467
|
});
|
|
3334
3468
|
}
|
|
3335
3469
|
}
|
|
3336
|
-
}
|
|
3337
|
-
await this._deviceSpaceSync
|
|
3470
|
+
};
|
|
3471
|
+
await identity.space.spaceState.addCredentialProcessor(this._deviceSpaceSync);
|
|
3338
3472
|
}
|
|
3339
3473
|
};
|
|
3340
3474
|
|
|
@@ -3539,7 +3673,7 @@ var ServiceRegistry = class {
|
|
|
3539
3673
|
|
|
3540
3674
|
// packages/sdk/client-services/src/packlets/services/service-host.ts
|
|
3541
3675
|
import invariant12 from "tiny-invariant";
|
|
3542
|
-
import { Event as Event8, synchronized as
|
|
3676
|
+
import { Event as Event8, synchronized as synchronized3 } from "@dxos/async";
|
|
3543
3677
|
import { clientServiceBundle } from "@dxos/client-protocol";
|
|
3544
3678
|
import { DocumentModel } from "@dxos/document-model";
|
|
3545
3679
|
import { DataServiceImpl } from "@dxos/echo-pipeline";
|
|
@@ -3554,7 +3688,7 @@ import { TextModel } from "@dxos/text-model";
|
|
|
3554
3688
|
|
|
3555
3689
|
// packages/sdk/client-services/src/packlets/devices/devices-service.ts
|
|
3556
3690
|
import { EventSubscriptions as EventSubscriptions3 } from "@dxos/async";
|
|
3557
|
-
import { Stream as
|
|
3691
|
+
import { Stream as Stream11 } from "@dxos/codec-protobuf";
|
|
3558
3692
|
import { DeviceKind } from "@dxos/protocols/proto/dxos/client/services";
|
|
3559
3693
|
var DevicesServiceImpl = class {
|
|
3560
3694
|
constructor(_identityManager) {
|
|
@@ -3564,7 +3698,7 @@ var DevicesServiceImpl = class {
|
|
|
3564
3698
|
throw new Error("Method not implemented.");
|
|
3565
3699
|
}
|
|
3566
3700
|
queryDevices() {
|
|
3567
|
-
return new
|
|
3701
|
+
return new Stream11(({ next }) => {
|
|
3568
3702
|
const update = () => {
|
|
3569
3703
|
var _a;
|
|
3570
3704
|
const deviceKeys = (_a = this._identityManager.identity) == null ? void 0 : _a.authorizedDeviceKeys;
|
|
@@ -3601,7 +3735,7 @@ var DevicesServiceImpl = class {
|
|
|
3601
3735
|
|
|
3602
3736
|
// packages/sdk/client-services/src/packlets/logging/logging-service.ts
|
|
3603
3737
|
import { Event as Event7 } from "@dxos/async";
|
|
3604
|
-
import { Stream as
|
|
3738
|
+
import { Stream as Stream12 } from "@dxos/codec-protobuf";
|
|
3605
3739
|
import { getContextFromEntry, log as log14 } from "@dxos/log";
|
|
3606
3740
|
import { QueryLogsRequest } from "@dxos/protocols/proto/dxos/client/services";
|
|
3607
3741
|
import { jsonify } from "@dxos/util";
|
|
@@ -3620,7 +3754,7 @@ var LoggingServiceImpl = class {
|
|
|
3620
3754
|
log14.runtimeConfig.processors.splice(index, 1);
|
|
3621
3755
|
}
|
|
3622
3756
|
queryLogs(request) {
|
|
3623
|
-
return new
|
|
3757
|
+
return new Stream12(({ ctx, next }) => {
|
|
3624
3758
|
const handler = (entry2) => {
|
|
3625
3759
|
var _a, _b, _c, _d, _e;
|
|
3626
3760
|
if (LOG_PROCESSING > 0) {
|
|
@@ -3676,14 +3810,14 @@ var shouldLog = (entry2, request) => {
|
|
|
3676
3810
|
var LOG_PROCESSING = 0;
|
|
3677
3811
|
|
|
3678
3812
|
// packages/sdk/client-services/src/packlets/network/network-service.ts
|
|
3679
|
-
import { Stream as
|
|
3813
|
+
import { Stream as Stream13 } from "@dxos/codec-protobuf";
|
|
3680
3814
|
var NetworkServiceImpl = class {
|
|
3681
3815
|
constructor(networkManager, signalManager) {
|
|
3682
3816
|
this.networkManager = networkManager;
|
|
3683
3817
|
this.signalManager = signalManager;
|
|
3684
3818
|
}
|
|
3685
3819
|
queryStatus() {
|
|
3686
|
-
return new
|
|
3820
|
+
return new Stream13(({ next }) => {
|
|
3687
3821
|
const update = () => {
|
|
3688
3822
|
next({
|
|
3689
3823
|
swarm: this.networkManager.connectionState,
|
|
@@ -3708,7 +3842,7 @@ var NetworkServiceImpl = class {
|
|
|
3708
3842
|
};
|
|
3709
3843
|
|
|
3710
3844
|
// packages/sdk/client-services/src/packlets/system/system-service.ts
|
|
3711
|
-
import { Stream as
|
|
3845
|
+
import { Stream as Stream14 } from "@dxos/codec-protobuf";
|
|
3712
3846
|
var SystemServiceImpl = class {
|
|
3713
3847
|
constructor({ config, statusUpdate, onUpdateStatus, getCurrentStatus, onReset }) {
|
|
3714
3848
|
this._config = config;
|
|
@@ -3725,7 +3859,7 @@ var SystemServiceImpl = class {
|
|
|
3725
3859
|
await this._onUpdateStatus(status);
|
|
3726
3860
|
}
|
|
3727
3861
|
queryStatus() {
|
|
3728
|
-
return new
|
|
3862
|
+
return new Stream14(({ next }) => {
|
|
3729
3863
|
const update = () => {
|
|
3730
3864
|
next({
|
|
3731
3865
|
status: this._getCurrentStatus()
|
|
@@ -3994,10 +4128,10 @@ var ClientServicesHost = class {
|
|
|
3994
4128
|
}
|
|
3995
4129
|
};
|
|
3996
4130
|
_ts_decorate4([
|
|
3997
|
-
|
|
4131
|
+
synchronized3
|
|
3998
4132
|
], ClientServicesHost.prototype, "open", null);
|
|
3999
4133
|
_ts_decorate4([
|
|
4000
|
-
|
|
4134
|
+
synchronized3
|
|
4001
4135
|
], ClientServicesHost.prototype, "close", null);
|
|
4002
4136
|
|
|
4003
4137
|
export {
|
|
@@ -4020,6 +4154,7 @@ export {
|
|
|
4020
4154
|
InvitationsHandler,
|
|
4021
4155
|
InvitationsServiceImpl,
|
|
4022
4156
|
SpaceInvitationProtocol,
|
|
4157
|
+
ClientRpcServer,
|
|
4023
4158
|
DataSpace,
|
|
4024
4159
|
DataSpaceManager,
|
|
4025
4160
|
SpacesServiceImpl,
|
|
@@ -4031,4 +4166,4 @@ export {
|
|
|
4031
4166
|
createDefaultModelFactory,
|
|
4032
4167
|
ClientServicesHost
|
|
4033
4168
|
};
|
|
4034
|
-
//# sourceMappingURL=chunk-
|
|
4169
|
+
//# sourceMappingURL=chunk-F4BHRFH4.mjs.map
|