@dxos/client-services 0.1.53-main.304e2d2 → 0.1.53-main.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-EYXOVYW5.mjs → chunk-F4BHRFH4.mjs} +83 -28
- 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 +1 -1
- package/dist/lib/node/index.cjs +110 -95
- 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 +71 -65
- 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/services/index.d.ts +1 -0
- package/dist/types/src/packlets/services/index.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/services/index.ts +1 -0
- package/src/packlets/spaces/data-space-manager.test.ts +3 -1
- package/src/packlets/spaces/spaces-service.test.ts +5 -3
- package/src/packlets/vault/worker-session.ts +5 -4
- package/dist/lib/browser/chunk-EYXOVYW5.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
|
});
|
|
@@ -2081,6 +2082,59 @@ 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
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";
|
|
@@ -3015,8 +3069,8 @@ DataSpaceManager = _ts_decorate2([
|
|
|
3015
3069
|
|
|
3016
3070
|
// packages/sdk/client-services/src/packlets/spaces/spaces-service.ts
|
|
3017
3071
|
import { EventSubscriptions as EventSubscriptions2, UpdateScheduler, scheduleTask as scheduleTask5 } from "@dxos/async";
|
|
3018
|
-
import { Stream as
|
|
3019
|
-
import { raise } from "@dxos/debug";
|
|
3072
|
+
import { Stream as Stream10 } from "@dxos/codec-protobuf";
|
|
3073
|
+
import { raise as raise2 } from "@dxos/debug";
|
|
3020
3074
|
import { SpaceNotFoundError } from "@dxos/echo-pipeline";
|
|
3021
3075
|
import { ApiError } from "@dxos/errors";
|
|
3022
3076
|
import { log as log11 } from "@dxos/log";
|
|
@@ -3042,7 +3096,7 @@ var SpacesServiceImpl = class {
|
|
|
3042
3096
|
async updateSpace({ spaceKey, state }) {
|
|
3043
3097
|
var _a;
|
|
3044
3098
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
3045
|
-
const space = (_a = dataSpaceManager.spaces.get(spaceKey)) != null ? _a :
|
|
3099
|
+
const space = (_a = dataSpaceManager.spaces.get(spaceKey)) != null ? _a : raise2(new SpaceNotFoundError(spaceKey));
|
|
3046
3100
|
if (state) {
|
|
3047
3101
|
switch (state) {
|
|
3048
3102
|
case SpaceState3.ACTIVE:
|
|
@@ -3057,7 +3111,7 @@ var SpacesServiceImpl = class {
|
|
|
3057
3111
|
}
|
|
3058
3112
|
}
|
|
3059
3113
|
querySpaces() {
|
|
3060
|
-
return new
|
|
3114
|
+
return new Stream10(({ next, ctx }) => {
|
|
3061
3115
|
const scheduler = new UpdateScheduler(ctx, async () => {
|
|
3062
3116
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
3063
3117
|
const spaces = Array.from(dataSpaceManager.spaces.values()).map((space) => this._serializeSpace(space));
|
|
@@ -3108,15 +3162,15 @@ var SpacesServiceImpl = class {
|
|
|
3108
3162
|
async postMessage({ spaceKey, channel, message }) {
|
|
3109
3163
|
var _a;
|
|
3110
3164
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
3111
|
-
const space = (_a = dataSpaceManager.spaces.get(spaceKey)) != null ? _a :
|
|
3165
|
+
const space = (_a = dataSpaceManager.spaces.get(spaceKey)) != null ? _a : raise2(new SpaceNotFoundError(spaceKey));
|
|
3112
3166
|
await space.postMessage(getChannelId(channel), message);
|
|
3113
3167
|
}
|
|
3114
3168
|
subscribeMessages({ spaceKey, channel }) {
|
|
3115
|
-
return new
|
|
3169
|
+
return new Stream10(({ ctx, next }) => {
|
|
3116
3170
|
scheduleTask5(ctx, async () => {
|
|
3117
3171
|
var _a;
|
|
3118
3172
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
3119
|
-
const space = (_a = dataSpaceManager.spaces.get(spaceKey)) != null ? _a :
|
|
3173
|
+
const space = (_a = dataSpaceManager.spaces.get(spaceKey)) != null ? _a : raise2(new SpaceNotFoundError(spaceKey));
|
|
3120
3174
|
const handle = space.listen(getChannelId(channel), (message) => {
|
|
3121
3175
|
next(message);
|
|
3122
3176
|
});
|
|
@@ -3125,9 +3179,9 @@ var SpacesServiceImpl = class {
|
|
|
3125
3179
|
});
|
|
3126
3180
|
}
|
|
3127
3181
|
queryCredentials({ spaceKey }) {
|
|
3128
|
-
return new
|
|
3182
|
+
return new Stream10(({ ctx, next }) => {
|
|
3129
3183
|
var _a;
|
|
3130
|
-
const space = (_a = this._spaceManager.spaces.get(spaceKey)) != null ? _a :
|
|
3184
|
+
const space = (_a = this._spaceManager.spaces.get(spaceKey)) != null ? _a : raise2(new SpaceNotFoundError(spaceKey));
|
|
3131
3185
|
const processor = {
|
|
3132
3186
|
processCredential: async (credential) => {
|
|
3133
3187
|
next(credential);
|
|
@@ -3139,7 +3193,7 @@ var SpacesServiceImpl = class {
|
|
|
3139
3193
|
}
|
|
3140
3194
|
async writeCredentials({ spaceKey, credentials }) {
|
|
3141
3195
|
var _a;
|
|
3142
|
-
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));
|
|
3143
3197
|
for (const credential of credentials != null ? credentials : []) {
|
|
3144
3198
|
await space.controlPipeline.writer.write({
|
|
3145
3199
|
credential: {
|
|
@@ -3151,7 +3205,7 @@ var SpacesServiceImpl = class {
|
|
|
3151
3205
|
async createEpoch({ spaceKey }) {
|
|
3152
3206
|
var _a;
|
|
3153
3207
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
3154
|
-
const space = (_a = dataSpaceManager.spaces.get(spaceKey)) != null ? _a :
|
|
3208
|
+
const space = (_a = dataSpaceManager.spaces.get(spaceKey)) != null ? _a : raise2(new SpaceNotFoundError(spaceKey));
|
|
3155
3209
|
await space.createEpoch();
|
|
3156
3210
|
}
|
|
3157
3211
|
_serializeSpace(space) {
|
|
@@ -3634,7 +3688,7 @@ import { TextModel } from "@dxos/text-model";
|
|
|
3634
3688
|
|
|
3635
3689
|
// packages/sdk/client-services/src/packlets/devices/devices-service.ts
|
|
3636
3690
|
import { EventSubscriptions as EventSubscriptions3 } from "@dxos/async";
|
|
3637
|
-
import { Stream as
|
|
3691
|
+
import { Stream as Stream11 } from "@dxos/codec-protobuf";
|
|
3638
3692
|
import { DeviceKind } from "@dxos/protocols/proto/dxos/client/services";
|
|
3639
3693
|
var DevicesServiceImpl = class {
|
|
3640
3694
|
constructor(_identityManager) {
|
|
@@ -3644,7 +3698,7 @@ var DevicesServiceImpl = class {
|
|
|
3644
3698
|
throw new Error("Method not implemented.");
|
|
3645
3699
|
}
|
|
3646
3700
|
queryDevices() {
|
|
3647
|
-
return new
|
|
3701
|
+
return new Stream11(({ next }) => {
|
|
3648
3702
|
const update = () => {
|
|
3649
3703
|
var _a;
|
|
3650
3704
|
const deviceKeys = (_a = this._identityManager.identity) == null ? void 0 : _a.authorizedDeviceKeys;
|
|
@@ -3681,7 +3735,7 @@ var DevicesServiceImpl = class {
|
|
|
3681
3735
|
|
|
3682
3736
|
// packages/sdk/client-services/src/packlets/logging/logging-service.ts
|
|
3683
3737
|
import { Event as Event7 } from "@dxos/async";
|
|
3684
|
-
import { Stream as
|
|
3738
|
+
import { Stream as Stream12 } from "@dxos/codec-protobuf";
|
|
3685
3739
|
import { getContextFromEntry, log as log14 } from "@dxos/log";
|
|
3686
3740
|
import { QueryLogsRequest } from "@dxos/protocols/proto/dxos/client/services";
|
|
3687
3741
|
import { jsonify } from "@dxos/util";
|
|
@@ -3700,7 +3754,7 @@ var LoggingServiceImpl = class {
|
|
|
3700
3754
|
log14.runtimeConfig.processors.splice(index, 1);
|
|
3701
3755
|
}
|
|
3702
3756
|
queryLogs(request) {
|
|
3703
|
-
return new
|
|
3757
|
+
return new Stream12(({ ctx, next }) => {
|
|
3704
3758
|
const handler = (entry2) => {
|
|
3705
3759
|
var _a, _b, _c, _d, _e;
|
|
3706
3760
|
if (LOG_PROCESSING > 0) {
|
|
@@ -3756,14 +3810,14 @@ var shouldLog = (entry2, request) => {
|
|
|
3756
3810
|
var LOG_PROCESSING = 0;
|
|
3757
3811
|
|
|
3758
3812
|
// packages/sdk/client-services/src/packlets/network/network-service.ts
|
|
3759
|
-
import { Stream as
|
|
3813
|
+
import { Stream as Stream13 } from "@dxos/codec-protobuf";
|
|
3760
3814
|
var NetworkServiceImpl = class {
|
|
3761
3815
|
constructor(networkManager, signalManager) {
|
|
3762
3816
|
this.networkManager = networkManager;
|
|
3763
3817
|
this.signalManager = signalManager;
|
|
3764
3818
|
}
|
|
3765
3819
|
queryStatus() {
|
|
3766
|
-
return new
|
|
3820
|
+
return new Stream13(({ next }) => {
|
|
3767
3821
|
const update = () => {
|
|
3768
3822
|
next({
|
|
3769
3823
|
swarm: this.networkManager.connectionState,
|
|
@@ -3788,7 +3842,7 @@ var NetworkServiceImpl = class {
|
|
|
3788
3842
|
};
|
|
3789
3843
|
|
|
3790
3844
|
// packages/sdk/client-services/src/packlets/system/system-service.ts
|
|
3791
|
-
import { Stream as
|
|
3845
|
+
import { Stream as Stream14 } from "@dxos/codec-protobuf";
|
|
3792
3846
|
var SystemServiceImpl = class {
|
|
3793
3847
|
constructor({ config, statusUpdate, onUpdateStatus, getCurrentStatus, onReset }) {
|
|
3794
3848
|
this._config = config;
|
|
@@ -3805,7 +3859,7 @@ var SystemServiceImpl = class {
|
|
|
3805
3859
|
await this._onUpdateStatus(status);
|
|
3806
3860
|
}
|
|
3807
3861
|
queryStatus() {
|
|
3808
|
-
return new
|
|
3862
|
+
return new Stream14(({ next }) => {
|
|
3809
3863
|
const update = () => {
|
|
3810
3864
|
next({
|
|
3811
3865
|
status: this._getCurrentStatus()
|
|
@@ -4100,6 +4154,7 @@ export {
|
|
|
4100
4154
|
InvitationsHandler,
|
|
4101
4155
|
InvitationsServiceImpl,
|
|
4102
4156
|
SpaceInvitationProtocol,
|
|
4157
|
+
ClientRpcServer,
|
|
4103
4158
|
DataSpace,
|
|
4104
4159
|
DataSpaceManager,
|
|
4105
4160
|
SpacesServiceImpl,
|
|
@@ -4111,4 +4166,4 @@ export {
|
|
|
4111
4166
|
createDefaultModelFactory,
|
|
4112
4167
|
ClientServicesHost
|
|
4113
4168
|
};
|
|
4114
|
-
//# sourceMappingURL=chunk-
|
|
4169
|
+
//# sourceMappingURL=chunk-F4BHRFH4.mjs.map
|