@dxos/client-services 0.1.53-main.52ca4e9 → 0.1.53-main.5bcfb84
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-EYXOVYW5.mjs} +170 -90
- package/dist/lib/browser/chunk-EYXOVYW5.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +1 -1
- 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 +165 -85
- package/dist/lib/node/index.cjs.map +3 -3
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/packlets/testing/index.cjs +179 -83
- package/dist/lib/node/packlets/testing/index.cjs.map +3 -3
- package/dist/types/src/packlets/identity/identity.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/package.json +32 -32
- package/src/packlets/identity/identity.ts +21 -26
- package/src/packlets/services/service-context.ts +9 -7
- package/src/packlets/spaces/data-space-manager.test.ts +72 -118
- 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.ts +26 -8
- package/src/packlets/testing/test-builder.ts +35 -2
- package/dist/lib/browser/chunk-PWZ2J6KS.mjs.map +0 -7
|
@@ -211,15 +211,15 @@ var Identity = class {
|
|
|
211
211
|
this._signer = signer;
|
|
212
212
|
this.identityKey = identityKey;
|
|
213
213
|
this.deviceKey = deviceKey;
|
|
214
|
-
this._deviceStateMachine =
|
|
214
|
+
this._deviceStateMachine = new import_credentials3.DeviceStateMachine({
|
|
215
215
|
identityKey: this.identityKey,
|
|
216
216
|
deviceKey: this.deviceKey,
|
|
217
217
|
onUpdate: () => this.stateUpdate.emit()
|
|
218
|
-
})
|
|
219
|
-
this._profileStateMachine =
|
|
218
|
+
});
|
|
219
|
+
this._profileStateMachine = new import_credentials3.ProfileStateMachine({
|
|
220
220
|
identityKey: this.identityKey,
|
|
221
221
|
onUpdate: () => this.stateUpdate.emit()
|
|
222
|
-
})
|
|
222
|
+
});
|
|
223
223
|
this.authVerifier = new TrustedKeySetAuthVerifier({
|
|
224
224
|
trustedKeysProvider: () => this.authorizedDeviceKeys,
|
|
225
225
|
update: this.stateUpdate,
|
|
@@ -228,27 +228,27 @@ var Identity = class {
|
|
|
228
228
|
}
|
|
229
229
|
// TODO(burdon): Expose state object?
|
|
230
230
|
get authorizedDeviceKeys() {
|
|
231
|
-
return this._deviceStateMachine.
|
|
231
|
+
return this._deviceStateMachine.authorizedDeviceKeys;
|
|
232
232
|
}
|
|
233
233
|
async open() {
|
|
234
|
-
await this.
|
|
235
|
-
await this.
|
|
234
|
+
await this.space.spaceState.addCredentialProcessor(this._deviceStateMachine);
|
|
235
|
+
await this.space.spaceState.addCredentialProcessor(this._profileStateMachine);
|
|
236
236
|
await this.space.open();
|
|
237
237
|
}
|
|
238
238
|
async close() {
|
|
239
239
|
await this.authVerifier.close();
|
|
240
|
-
await this.
|
|
241
|
-
await this.
|
|
240
|
+
await this.space.spaceState.removeCredentialProcessor(this._profileStateMachine);
|
|
241
|
+
await this.space.spaceState.removeCredentialProcessor(this._deviceStateMachine);
|
|
242
242
|
await this.space.close();
|
|
243
243
|
}
|
|
244
244
|
async ready() {
|
|
245
|
-
await this._deviceStateMachine.
|
|
245
|
+
await this._deviceStateMachine.deviceChainReady.wait();
|
|
246
246
|
await this.controlPipeline.state.waitUntilReachedTargetTimeframe({
|
|
247
247
|
timeout: import_client_protocol.LOAD_CONTROL_FEEDS_TIMEOUT
|
|
248
248
|
});
|
|
249
249
|
}
|
|
250
250
|
get profileDocument() {
|
|
251
|
-
return this._profileStateMachine.
|
|
251
|
+
return this._profileStateMachine.profile;
|
|
252
252
|
}
|
|
253
253
|
/**
|
|
254
254
|
* @test-only
|
|
@@ -263,7 +263,7 @@ var Identity = class {
|
|
|
263
263
|
return this.space.genesisFeedKey;
|
|
264
264
|
}
|
|
265
265
|
get deviceCredentialChain() {
|
|
266
|
-
return this._deviceStateMachine.
|
|
266
|
+
return this._deviceStateMachine.deviceCredentialChain;
|
|
267
267
|
}
|
|
268
268
|
getAdmissionCredentials() {
|
|
269
269
|
var _a, _b;
|
|
@@ -278,8 +278,8 @@ var Identity = class {
|
|
|
278
278
|
* Requires identity to be ready.
|
|
279
279
|
*/
|
|
280
280
|
getIdentityCredentialSigner() {
|
|
281
|
-
(0, import_tiny_invariant.default)(this._deviceStateMachine.
|
|
282
|
-
return (0, import_credentials3.createCredentialSignerWithChain)(this._signer, this._deviceStateMachine.
|
|
281
|
+
(0, import_tiny_invariant.default)(this._deviceStateMachine.deviceCredentialChain, "Device credential chain is not ready.");
|
|
282
|
+
return (0, import_credentials3.createCredentialSignerWithChain)(this._signer, this._deviceStateMachine.deviceCredentialChain, this.deviceKey);
|
|
283
283
|
}
|
|
284
284
|
/**
|
|
285
285
|
* Issues credentials as device.
|
|
@@ -296,7 +296,7 @@ var Identity = class {
|
|
|
296
296
|
dataFeedKey
|
|
297
297
|
}, {
|
|
298
298
|
F: __dxlog_file2,
|
|
299
|
-
L:
|
|
299
|
+
L: 151,
|
|
300
300
|
S: this,
|
|
301
301
|
C: (f, a) => f(...a)
|
|
302
302
|
});
|
|
@@ -1862,6 +1862,9 @@ var NotarizationPlugin = class {
|
|
|
1862
1862
|
this._processedCredentials = new import_util2.ComplexSet(import_keys5.PublicKey.hash);
|
|
1863
1863
|
this._processCredentialsTriggers = new import_util2.ComplexMap(import_keys5.PublicKey.hash);
|
|
1864
1864
|
}
|
|
1865
|
+
get hasWriter() {
|
|
1866
|
+
return !!this._writer;
|
|
1867
|
+
}
|
|
1865
1868
|
async open() {
|
|
1866
1869
|
}
|
|
1867
1870
|
async close() {
|
|
@@ -1875,7 +1878,7 @@ var NotarizationPlugin = class {
|
|
|
1875
1878
|
credentials
|
|
1876
1879
|
}, {
|
|
1877
1880
|
F: __dxlog_file8,
|
|
1878
|
-
L:
|
|
1881
|
+
L: 91,
|
|
1879
1882
|
S: this,
|
|
1880
1883
|
C: (f, a) => f(...a)
|
|
1881
1884
|
});
|
|
@@ -1887,7 +1890,7 @@ var NotarizationPlugin = class {
|
|
|
1887
1890
|
err
|
|
1888
1891
|
}, {
|
|
1889
1892
|
F: __dxlog_file8,
|
|
1890
|
-
L:
|
|
1893
|
+
L: 100,
|
|
1891
1894
|
S: this,
|
|
1892
1895
|
C: (f, a) => f(...a)
|
|
1893
1896
|
});
|
|
@@ -1903,7 +1906,7 @@ var NotarizationPlugin = class {
|
|
|
1903
1906
|
peers: Array.from(this._extensions).map((extension) => extension.remotePeerId)
|
|
1904
1907
|
}, {
|
|
1905
1908
|
F: __dxlog_file8,
|
|
1906
|
-
L:
|
|
1909
|
+
L: 112,
|
|
1907
1910
|
S: this,
|
|
1908
1911
|
C: (f, a) => f(...a)
|
|
1909
1912
|
});
|
|
@@ -1926,7 +1929,7 @@ var NotarizationPlugin = class {
|
|
|
1926
1929
|
retryIn: retryTimeout
|
|
1927
1930
|
}, {
|
|
1928
1931
|
F: __dxlog_file8,
|
|
1929
|
-
L:
|
|
1932
|
+
L: 137,
|
|
1930
1933
|
S: this,
|
|
1931
1934
|
C: (f, a) => f(...a)
|
|
1932
1935
|
});
|
|
@@ -1940,7 +1943,7 @@ var NotarizationPlugin = class {
|
|
|
1940
1943
|
credentialId: credentials.map((credential) => credential.id)
|
|
1941
1944
|
}, {
|
|
1942
1945
|
F: __dxlog_file8,
|
|
1943
|
-
L:
|
|
1946
|
+
L: 144,
|
|
1944
1947
|
S: this,
|
|
1945
1948
|
C: (f, a) => f(...a)
|
|
1946
1949
|
});
|
|
@@ -1949,7 +1952,7 @@ var NotarizationPlugin = class {
|
|
|
1949
1952
|
});
|
|
1950
1953
|
(0, import_log8.log)("success", void 0, {
|
|
1951
1954
|
F: __dxlog_file8,
|
|
1952
|
-
L:
|
|
1955
|
+
L: 148,
|
|
1953
1956
|
S: this,
|
|
1954
1957
|
C: (f, a) => f(...a)
|
|
1955
1958
|
});
|
|
@@ -1958,7 +1961,7 @@ var NotarizationPlugin = class {
|
|
|
1958
1961
|
if (!ctx.disposed && !err.message.includes(WRITER_NOT_SET_ERROR_CODE)) {
|
|
1959
1962
|
import_log8.log.warn("error notarizing (recoverable)", err, {
|
|
1960
1963
|
F: __dxlog_file8,
|
|
1961
|
-
L:
|
|
1964
|
+
L: 152,
|
|
1962
1965
|
S: this,
|
|
1963
1966
|
C: (f, a) => f(...a)
|
|
1964
1967
|
});
|
|
@@ -1976,7 +1979,7 @@ var NotarizationPlugin = class {
|
|
|
1976
1979
|
]);
|
|
1977
1980
|
(0, import_log8.log)("done", void 0, {
|
|
1978
1981
|
F: __dxlog_file8,
|
|
1979
|
-
L:
|
|
1982
|
+
L: 163,
|
|
1980
1983
|
S: this,
|
|
1981
1984
|
C: (f, a) => f(...a)
|
|
1982
1985
|
});
|
|
@@ -1987,7 +1990,7 @@ var NotarizationPlugin = class {
|
|
|
1987
1990
|
/**
|
|
1988
1991
|
* Called with credentials arriving from the control pipeline.
|
|
1989
1992
|
*/
|
|
1990
|
-
async
|
|
1993
|
+
async processCredential(credential) {
|
|
1991
1994
|
var _a;
|
|
1992
1995
|
if (!credential.id) {
|
|
1993
1996
|
return;
|
|
@@ -2029,7 +2032,7 @@ var NotarizationPlugin = class {
|
|
|
2029
2032
|
peer: extension.localPeerId
|
|
2030
2033
|
}, {
|
|
2031
2034
|
F: __dxlog_file8,
|
|
2032
|
-
L:
|
|
2035
|
+
L: 212,
|
|
2033
2036
|
S: this,
|
|
2034
2037
|
C: (f, a) => f(...a)
|
|
2035
2038
|
});
|
|
@@ -2041,7 +2044,7 @@ var NotarizationPlugin = class {
|
|
|
2041
2044
|
peer: extension.localPeerId
|
|
2042
2045
|
}, {
|
|
2043
2046
|
F: __dxlog_file8,
|
|
2044
|
-
L:
|
|
2047
|
+
L: 217,
|
|
2045
2048
|
S: this,
|
|
2046
2049
|
C: (f, a) => f(...a)
|
|
2047
2050
|
});
|
|
@@ -2098,6 +2101,7 @@ var __dxlog_file9 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/sr
|
|
|
2098
2101
|
var DataSpace = class DataSpace2 {
|
|
2099
2102
|
constructor(params) {
|
|
2100
2103
|
this._ctx = new import_context5.Context();
|
|
2104
|
+
this._notarizationPlugin = new NotarizationPlugin();
|
|
2101
2105
|
this._state = import_services6.SpaceState.CLOSED;
|
|
2102
2106
|
/**
|
|
2103
2107
|
* Error for _state === SpaceState.ERROR.
|
|
@@ -2120,8 +2124,8 @@ var DataSpace = class DataSpace2 {
|
|
|
2120
2124
|
update: this._inner.stateUpdate,
|
|
2121
2125
|
authTimeout: import_client_protocol3.AUTH_TIMEOUT
|
|
2122
2126
|
});
|
|
2123
|
-
this._notarizationPluginConsumer = this._inner.spaceState.registerProcessor(new NotarizationPlugin());
|
|
2124
2127
|
this._cache = params.cache;
|
|
2128
|
+
this._state = params.initialState;
|
|
2125
2129
|
}
|
|
2126
2130
|
get key() {
|
|
2127
2131
|
return this._inner.key;
|
|
@@ -2143,25 +2147,36 @@ var DataSpace = class DataSpace2 {
|
|
|
2143
2147
|
return this._presence;
|
|
2144
2148
|
}
|
|
2145
2149
|
get notarizationPlugin() {
|
|
2146
|
-
return this.
|
|
2150
|
+
return this._notarizationPlugin;
|
|
2147
2151
|
}
|
|
2148
2152
|
get cache() {
|
|
2149
2153
|
return this._cache;
|
|
2150
2154
|
}
|
|
2151
2155
|
async open() {
|
|
2152
|
-
await this.
|
|
2153
|
-
|
|
2156
|
+
await this._open();
|
|
2157
|
+
}
|
|
2158
|
+
async _open() {
|
|
2159
|
+
await this._notarizationPlugin.open();
|
|
2160
|
+
await this._inner.spaceState.addCredentialProcessor(this._notarizationPlugin);
|
|
2154
2161
|
await this._inner.open();
|
|
2155
|
-
this._state = import_services6.SpaceState.
|
|
2162
|
+
this._state = import_services6.SpaceState.CONTROL_ONLY;
|
|
2163
|
+
this.stateUpdate.emit();
|
|
2164
|
+
this.metrics = {};
|
|
2156
2165
|
this.metrics.open = new Date();
|
|
2157
2166
|
}
|
|
2158
2167
|
async close() {
|
|
2168
|
+
await this._close();
|
|
2169
|
+
}
|
|
2170
|
+
async _close() {
|
|
2171
|
+
var _a, _b;
|
|
2172
|
+
await ((_b = (_a = this._callbacks).beforeClose) == null ? void 0 : _b.call(_a));
|
|
2159
2173
|
this._state = import_services6.SpaceState.CLOSED;
|
|
2160
2174
|
await this._ctx.dispose();
|
|
2175
|
+
this._ctx = new import_context5.Context();
|
|
2161
2176
|
await this.authVerifier.close();
|
|
2162
2177
|
await this._inner.close();
|
|
2163
|
-
await this.
|
|
2164
|
-
await this.
|
|
2178
|
+
await this._inner.spaceState.removeCredentialProcessor(this._notarizationPlugin);
|
|
2179
|
+
await this._notarizationPlugin.close();
|
|
2165
2180
|
await this._presence.destroy();
|
|
2166
2181
|
}
|
|
2167
2182
|
async postMessage(channel, message) {
|
|
@@ -2182,7 +2197,7 @@ var DataSpace = class DataSpace2 {
|
|
|
2182
2197
|
if (err instanceof import_errors3.CancelledError) {
|
|
2183
2198
|
(0, import_log9.log)("Data pipeline initialization cancelled", err, {
|
|
2184
2199
|
F: __dxlog_file9,
|
|
2185
|
-
L:
|
|
2200
|
+
L: 193,
|
|
2186
2201
|
S: this,
|
|
2187
2202
|
C: (f, a) => f(...a)
|
|
2188
2203
|
});
|
|
@@ -2190,7 +2205,7 @@ var DataSpace = class DataSpace2 {
|
|
|
2190
2205
|
}
|
|
2191
2206
|
import_log9.log.error("Error initializing data pipeline", err, {
|
|
2192
2207
|
F: __dxlog_file9,
|
|
2193
|
-
L:
|
|
2208
|
+
L: 197,
|
|
2194
2209
|
S: this,
|
|
2195
2210
|
C: (f, a) => f(...a)
|
|
2196
2211
|
});
|
|
@@ -2204,7 +2219,7 @@ var DataSpace = class DataSpace2 {
|
|
|
2204
2219
|
}
|
|
2205
2220
|
async initializeDataPipeline() {
|
|
2206
2221
|
var _a, _b, _c, _d;
|
|
2207
|
-
if (this._state !== import_services6.SpaceState.
|
|
2222
|
+
if (this._state !== import_services6.SpaceState.CONTROL_ONLY) {
|
|
2208
2223
|
throw new import_errors3.SystemError("Invalid operation");
|
|
2209
2224
|
}
|
|
2210
2225
|
this._state = import_services6.SpaceState.INITIALIZING;
|
|
@@ -2216,22 +2231,24 @@ var DataSpace = class DataSpace2 {
|
|
|
2216
2231
|
await this._createWritableFeeds();
|
|
2217
2232
|
(0, import_log9.log)("Writable feeds created", void 0, {
|
|
2218
2233
|
F: __dxlog_file9,
|
|
2219
|
-
L:
|
|
2234
|
+
L: 221,
|
|
2220
2235
|
S: this,
|
|
2221
2236
|
C: (f, a) => f(...a)
|
|
2222
2237
|
});
|
|
2223
2238
|
this.stateUpdate.emit();
|
|
2224
|
-
this.notarizationPlugin.
|
|
2225
|
-
credential
|
|
2226
|
-
credential
|
|
2227
|
-
|
|
2228
|
-
|
|
2239
|
+
if (!this.notarizationPlugin.hasWriter) {
|
|
2240
|
+
this.notarizationPlugin.setWriter((0, import_echo_pipeline.createMappedFeedWriter)((credential) => ({
|
|
2241
|
+
credential: {
|
|
2242
|
+
credential
|
|
2243
|
+
}
|
|
2244
|
+
}), this._inner.controlPipeline.writer));
|
|
2245
|
+
}
|
|
2229
2246
|
await this._inner.initializeDataPipeline();
|
|
2230
2247
|
this.metrics.dataPipelineOpen = new Date();
|
|
2231
2248
|
await (0, import_context5.cancelWithContext)(this._ctx, this._inner.dataPipeline.ensureEpochInitialized());
|
|
2232
2249
|
(0, import_log9.log)("waiting for data pipeline to reach target timeframe", void 0, {
|
|
2233
2250
|
F: __dxlog_file9,
|
|
2234
|
-
L:
|
|
2251
|
+
L: 242,
|
|
2235
2252
|
S: this,
|
|
2236
2253
|
C: (f, a) => f(...a)
|
|
2237
2254
|
});
|
|
@@ -2242,7 +2259,7 @@ var DataSpace = class DataSpace2 {
|
|
|
2242
2259
|
this.metrics.dataPipelineReady = new Date();
|
|
2243
2260
|
(0, import_log9.log)("data pipeline ready", void 0, {
|
|
2244
2261
|
F: __dxlog_file9,
|
|
2245
|
-
L:
|
|
2262
|
+
L: 251,
|
|
2246
2263
|
S: this,
|
|
2247
2264
|
C: (f, a) => f(...a)
|
|
2248
2265
|
});
|
|
@@ -2322,10 +2339,39 @@ var DataSpace = class DataSpace2 {
|
|
|
2322
2339
|
}
|
|
2323
2340
|
}
|
|
2324
2341
|
}
|
|
2342
|
+
async activate() {
|
|
2343
|
+
if (this._state !== import_services6.SpaceState.INACTIVE) {
|
|
2344
|
+
throw new import_errors3.SystemError("Invalid operation");
|
|
2345
|
+
}
|
|
2346
|
+
await this._metadataStore.setSpaceState(this.key, import_services6.SpaceState.ACTIVE);
|
|
2347
|
+
await this._open();
|
|
2348
|
+
this.initializeDataPipelineAsync();
|
|
2349
|
+
}
|
|
2350
|
+
async deactivate() {
|
|
2351
|
+
if (this._state === import_services6.SpaceState.INACTIVE) {
|
|
2352
|
+
throw new import_errors3.SystemError("Invalid operation");
|
|
2353
|
+
}
|
|
2354
|
+
await this._metadataStore.setSpaceState(this.key, import_services6.SpaceState.INACTIVE);
|
|
2355
|
+
await this._close();
|
|
2356
|
+
this._state = import_services6.SpaceState.INACTIVE;
|
|
2357
|
+
this.stateUpdate.emit();
|
|
2358
|
+
}
|
|
2325
2359
|
};
|
|
2360
|
+
_ts_decorate([
|
|
2361
|
+
import_async8.synchronized
|
|
2362
|
+
], DataSpace.prototype, "open", null);
|
|
2363
|
+
_ts_decorate([
|
|
2364
|
+
import_async8.synchronized
|
|
2365
|
+
], DataSpace.prototype, "close", null);
|
|
2326
2366
|
_ts_decorate([
|
|
2327
2367
|
(0, import_debug3.timed)(1e4)
|
|
2328
2368
|
], DataSpace.prototype, "_createWritableFeeds", null);
|
|
2369
|
+
_ts_decorate([
|
|
2370
|
+
import_async8.synchronized
|
|
2371
|
+
], DataSpace.prototype, "activate", null);
|
|
2372
|
+
_ts_decorate([
|
|
2373
|
+
import_async8.synchronized
|
|
2374
|
+
], DataSpace.prototype, "deactivate", null);
|
|
2329
2375
|
DataSpace = _ts_decorate([
|
|
2330
2376
|
(0, import_async8.trackLeaks)("open", "close")
|
|
2331
2377
|
], DataSpace);
|
|
@@ -2465,14 +2511,16 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2465
2511
|
C: (f, a) => f(...a)
|
|
2466
2512
|
});
|
|
2467
2513
|
const space = await this._constructSpace(spaceMetadata);
|
|
2468
|
-
|
|
2514
|
+
if (spaceMetadata.state !== import_services7.SpaceState.INACTIVE) {
|
|
2515
|
+
space.initializeDataPipelineAsync();
|
|
2516
|
+
}
|
|
2469
2517
|
} catch (err) {
|
|
2470
2518
|
import_log10.log.error("Error loading space", {
|
|
2471
2519
|
spaceMetadata,
|
|
2472
2520
|
err
|
|
2473
2521
|
}, {
|
|
2474
2522
|
F: __dxlog_file10,
|
|
2475
|
-
L:
|
|
2523
|
+
L: 93,
|
|
2476
2524
|
S: this,
|
|
2477
2525
|
C: (f, a) => f(...a)
|
|
2478
2526
|
});
|
|
@@ -2484,7 +2532,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2484
2532
|
id: this._instanceId
|
|
2485
2533
|
}), {
|
|
2486
2534
|
F: __dxlog_file10,
|
|
2487
|
-
L:
|
|
2535
|
+
L: 99,
|
|
2488
2536
|
S: this,
|
|
2489
2537
|
C: (f, a) => f(...a)
|
|
2490
2538
|
});
|
|
@@ -2492,7 +2540,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2492
2540
|
async close() {
|
|
2493
2541
|
(0, import_log10.log)("close", void 0, {
|
|
2494
2542
|
F: __dxlog_file10,
|
|
2495
|
-
L:
|
|
2543
|
+
L: 104,
|
|
2496
2544
|
S: this,
|
|
2497
2545
|
C: (f, a) => f(...a)
|
|
2498
2546
|
});
|
|
@@ -2514,13 +2562,14 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2514
2562
|
key: spaceKey,
|
|
2515
2563
|
genesisFeedKey: controlFeedKey,
|
|
2516
2564
|
controlFeedKey,
|
|
2517
|
-
dataFeedKey
|
|
2565
|
+
dataFeedKey,
|
|
2566
|
+
state: import_services7.SpaceState.ACTIVE
|
|
2518
2567
|
};
|
|
2519
2568
|
(0, import_log10.log)("creating space...", {
|
|
2520
2569
|
spaceKey
|
|
2521
2570
|
}, {
|
|
2522
2571
|
F: __dxlog_file10,
|
|
2523
|
-
L:
|
|
2572
|
+
L: 129,
|
|
2524
2573
|
S: this,
|
|
2525
2574
|
C: (f, a) => f(...a)
|
|
2526
2575
|
});
|
|
@@ -2540,7 +2589,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2540
2589
|
opts
|
|
2541
2590
|
}, {
|
|
2542
2591
|
F: __dxlog_file10,
|
|
2543
|
-
L:
|
|
2592
|
+
L: 148,
|
|
2544
2593
|
S: this,
|
|
2545
2594
|
C: (f, a) => f(...a)
|
|
2546
2595
|
});
|
|
@@ -2574,7 +2623,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2574
2623
|
metadata
|
|
2575
2624
|
}, {
|
|
2576
2625
|
F: __dxlog_file10,
|
|
2577
|
-
L:
|
|
2626
|
+
L: 183,
|
|
2578
2627
|
S: this,
|
|
2579
2628
|
C: (f, a) => f(...a)
|
|
2580
2629
|
});
|
|
@@ -2610,7 +2659,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2610
2659
|
onAuthFailure: () => {
|
|
2611
2660
|
import_log10.log.warn("auth failure", void 0, {
|
|
2612
2661
|
F: __dxlog_file10,
|
|
2613
|
-
L:
|
|
2662
|
+
L: 214,
|
|
2614
2663
|
S: this,
|
|
2615
2664
|
C: (f, a) => f(...a)
|
|
2616
2665
|
});
|
|
@@ -2621,6 +2670,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2621
2670
|
dataFeed && space.setDataFeed(dataFeed);
|
|
2622
2671
|
const dataSpace = new DataSpace({
|
|
2623
2672
|
inner: space,
|
|
2673
|
+
initialState: metadata.state === import_services7.SpaceState.INACTIVE ? import_services7.SpaceState.INACTIVE : import_services7.SpaceState.CLOSED,
|
|
2624
2674
|
metadataStore: this._metadataStore,
|
|
2625
2675
|
gossip,
|
|
2626
2676
|
presence,
|
|
@@ -2633,11 +2683,11 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2633
2683
|
space: space.key
|
|
2634
2684
|
}, {
|
|
2635
2685
|
F: __dxlog_file10,
|
|
2636
|
-
L:
|
|
2686
|
+
L: 232,
|
|
2637
2687
|
S: this,
|
|
2638
2688
|
C: (f, a) => f(...a)
|
|
2639
2689
|
});
|
|
2640
|
-
this._dataServiceSubscriptions.registerSpace(space.key, dataSpace.dataPipeline.databaseHost.createDataServiceHost());
|
|
2690
|
+
await this._dataServiceSubscriptions.registerSpace(space.key, dataSpace.dataPipeline.databaseHost.createDataServiceHost());
|
|
2641
2691
|
},
|
|
2642
2692
|
afterReady: async () => {
|
|
2643
2693
|
(0, import_log10.log)("after space ready", {
|
|
@@ -2645,18 +2695,31 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2645
2695
|
open: this._isOpen
|
|
2646
2696
|
}, {
|
|
2647
2697
|
F: __dxlog_file10,
|
|
2648
|
-
L:
|
|
2698
|
+
L: 239,
|
|
2649
2699
|
S: this,
|
|
2650
2700
|
C: (f, a) => f(...a)
|
|
2651
2701
|
});
|
|
2652
2702
|
if (this._isOpen) {
|
|
2653
2703
|
this.updated.emit();
|
|
2654
2704
|
}
|
|
2705
|
+
},
|
|
2706
|
+
beforeClose: async () => {
|
|
2707
|
+
(0, import_log10.log)("before space close", {
|
|
2708
|
+
space: space.key
|
|
2709
|
+
}, {
|
|
2710
|
+
F: __dxlog_file10,
|
|
2711
|
+
L: 245,
|
|
2712
|
+
S: this,
|
|
2713
|
+
C: (f, a) => f(...a)
|
|
2714
|
+
});
|
|
2715
|
+
await this._dataServiceSubscriptions.unregisterSpace(space.key);
|
|
2655
2716
|
}
|
|
2656
2717
|
},
|
|
2657
2718
|
cache: metadata.cache
|
|
2658
2719
|
});
|
|
2659
|
-
|
|
2720
|
+
if (metadata.state !== import_services7.SpaceState.INACTIVE) {
|
|
2721
|
+
await dataSpace.open();
|
|
2722
|
+
}
|
|
2660
2723
|
if (metadata.controlTimeframe) {
|
|
2661
2724
|
dataSpace.inner.controlPipeline.state.setTargetTimeframe(metadata.controlTimeframe);
|
|
2662
2725
|
}
|
|
@@ -2688,6 +2751,7 @@ var import_async10 = require("@dxos/async");
|
|
|
2688
2751
|
var import_codec_protobuf3 = require("@dxos/codec-protobuf");
|
|
2689
2752
|
var import_debug5 = require("@dxos/debug");
|
|
2690
2753
|
var import_echo_pipeline2 = require("@dxos/echo-pipeline");
|
|
2754
|
+
var import_errors4 = require("@dxos/errors");
|
|
2691
2755
|
var import_log11 = require("@dxos/log");
|
|
2692
2756
|
var import_protocols7 = require("@dxos/protocols");
|
|
2693
2757
|
var import_services8 = require("@dxos/protocols/proto/dxos/client/services");
|
|
@@ -2708,8 +2772,22 @@ var SpacesServiceImpl = class {
|
|
|
2708
2772
|
const space = await dataSpaceManager.createSpace();
|
|
2709
2773
|
return this._serializeSpace(space);
|
|
2710
2774
|
}
|
|
2711
|
-
async updateSpace(
|
|
2712
|
-
|
|
2775
|
+
async updateSpace({ spaceKey, state }) {
|
|
2776
|
+
var _a;
|
|
2777
|
+
const dataSpaceManager = await this._getDataSpaceManager();
|
|
2778
|
+
const space = (_a = dataSpaceManager.spaces.get(spaceKey)) != null ? _a : (0, import_debug5.raise)(new import_echo_pipeline2.SpaceNotFoundError(spaceKey));
|
|
2779
|
+
if (state) {
|
|
2780
|
+
switch (state) {
|
|
2781
|
+
case import_services8.SpaceState.ACTIVE:
|
|
2782
|
+
await space.activate();
|
|
2783
|
+
break;
|
|
2784
|
+
case import_services8.SpaceState.INACTIVE:
|
|
2785
|
+
await space.deactivate();
|
|
2786
|
+
break;
|
|
2787
|
+
default:
|
|
2788
|
+
throw new import_errors4.ApiError("Invalid space state");
|
|
2789
|
+
}
|
|
2790
|
+
}
|
|
2713
2791
|
}
|
|
2714
2792
|
querySpaces() {
|
|
2715
2793
|
return new import_codec_protobuf3.Stream(({ next, ctx }) => {
|
|
@@ -2720,7 +2798,7 @@ var SpacesServiceImpl = class {
|
|
|
2720
2798
|
spaces
|
|
2721
2799
|
}, {
|
|
2722
2800
|
F: __dxlog_file11,
|
|
2723
|
-
L:
|
|
2801
|
+
L: 78,
|
|
2724
2802
|
S: this,
|
|
2725
2803
|
C: (f, a) => f(...a)
|
|
2726
2804
|
});
|
|
@@ -2783,13 +2861,13 @@ var SpacesServiceImpl = class {
|
|
|
2783
2861
|
return new import_codec_protobuf3.Stream(({ ctx, next }) => {
|
|
2784
2862
|
var _a;
|
|
2785
2863
|
const space = (_a = this._spaceManager.spaces.get(spaceKey)) != null ? _a : (0, import_debug5.raise)(new import_echo_pipeline2.SpaceNotFoundError(spaceKey));
|
|
2786
|
-
const processor =
|
|
2787
|
-
|
|
2864
|
+
const processor = {
|
|
2865
|
+
processCredential: async (credential) => {
|
|
2788
2866
|
next(credential);
|
|
2789
2867
|
}
|
|
2790
|
-
}
|
|
2791
|
-
ctx.onDispose(() =>
|
|
2792
|
-
(0, import_async10.scheduleTask)(ctx, () =>
|
|
2868
|
+
};
|
|
2869
|
+
ctx.onDispose(() => space.spaceState.removeCredentialProcessor(processor));
|
|
2870
|
+
(0, import_async10.scheduleTask)(ctx, () => space.spaceState.addCredentialProcessor(processor));
|
|
2793
2871
|
});
|
|
2794
2872
|
}
|
|
2795
2873
|
async writeCredentials({ spaceKey, credentials }) {
|
|
@@ -2928,15 +3006,17 @@ var ServiceContext = class {
|
|
|
2928
3006
|
});
|
|
2929
3007
|
}
|
|
2930
3008
|
async close() {
|
|
2931
|
-
var _a
|
|
3009
|
+
var _a;
|
|
2932
3010
|
(0, import_log12.log)("closing...", void 0, {
|
|
2933
3011
|
F: __dxlog_file12,
|
|
2934
3012
|
L: 143,
|
|
2935
3013
|
S: this,
|
|
2936
3014
|
C: (f, a) => f(...a)
|
|
2937
3015
|
});
|
|
2938
|
-
|
|
2939
|
-
|
|
3016
|
+
if (this._deviceSpaceSync && this.identityManager.identity) {
|
|
3017
|
+
await this.identityManager.identity.space.spaceState.removeCredentialProcessor(this._deviceSpaceSync);
|
|
3018
|
+
}
|
|
3019
|
+
await ((_a = this.dataSpaceManager) == null ? void 0 : _a.close());
|
|
2940
3020
|
await this.identityManager.close();
|
|
2941
3021
|
await this.spaceManager.close();
|
|
2942
3022
|
await this.feedStore.close();
|
|
@@ -2945,7 +3025,7 @@ var ServiceContext = class {
|
|
|
2945
3025
|
this.dataServiceSubscriptions.clear();
|
|
2946
3026
|
(0, import_log12.log)("closed", void 0, {
|
|
2947
3027
|
F: __dxlog_file12,
|
|
2948
|
-
L:
|
|
3028
|
+
L: 154,
|
|
2949
3029
|
S: this,
|
|
2950
3030
|
C: (f, a) => f(...a)
|
|
2951
3031
|
});
|
|
@@ -2976,7 +3056,7 @@ var ServiceContext = class {
|
|
|
2976
3056
|
var _a;
|
|
2977
3057
|
(0, import_log12.log)("initializing spaces...", void 0, {
|
|
2978
3058
|
F: __dxlog_file12,
|
|
2979
|
-
L:
|
|
3059
|
+
L: 187,
|
|
2980
3060
|
S: this,
|
|
2981
3061
|
C: (f, a) => f(...a)
|
|
2982
3062
|
});
|
|
@@ -3001,8 +3081,8 @@ var ServiceContext = class {
|
|
|
3001
3081
|
return new SpaceInvitationProtocol(this.dataSpaceManager, signingContext, this.keyring, invitation.spaceKey);
|
|
3002
3082
|
});
|
|
3003
3083
|
this.initialized.wake();
|
|
3004
|
-
this._deviceSpaceSync =
|
|
3005
|
-
|
|
3084
|
+
this._deviceSpaceSync = {
|
|
3085
|
+
processCredential: async (credential) => {
|
|
3006
3086
|
const assertion = (0, import_credentials14.getCredentialAssertion)(credential);
|
|
3007
3087
|
if (assertion["@type"] !== "dxos.halo.credentials.SpaceMember") {
|
|
3008
3088
|
return;
|
|
@@ -3015,7 +3095,7 @@ var ServiceContext = class {
|
|
|
3015
3095
|
details: assertion
|
|
3016
3096
|
}, {
|
|
3017
3097
|
F: __dxlog_file12,
|
|
3018
|
-
L:
|
|
3098
|
+
L: 226,
|
|
3019
3099
|
S: this,
|
|
3020
3100
|
C: (f, a) => f(...a)
|
|
3021
3101
|
});
|
|
@@ -3026,7 +3106,7 @@ var ServiceContext = class {
|
|
|
3026
3106
|
details: assertion
|
|
3027
3107
|
}, {
|
|
3028
3108
|
F: __dxlog_file12,
|
|
3029
|
-
L:
|
|
3109
|
+
L: 230,
|
|
3030
3110
|
S: this,
|
|
3031
3111
|
C: (f, a) => f(...a)
|
|
3032
3112
|
});
|
|
@@ -3037,7 +3117,7 @@ var ServiceContext = class {
|
|
|
3037
3117
|
details: assertion
|
|
3038
3118
|
}, {
|
|
3039
3119
|
F: __dxlog_file12,
|
|
3040
|
-
L:
|
|
3120
|
+
L: 235,
|
|
3041
3121
|
S: this,
|
|
3042
3122
|
C: (f, a) => f(...a)
|
|
3043
3123
|
});
|
|
@@ -3048,14 +3128,14 @@ var ServiceContext = class {
|
|
|
3048
3128
|
} catch (err) {
|
|
3049
3129
|
import_log12.log.catch(err, void 0, {
|
|
3050
3130
|
F: __dxlog_file12,
|
|
3051
|
-
L:
|
|
3131
|
+
L: 241,
|
|
3052
3132
|
S: this,
|
|
3053
3133
|
C: (f, a) => f(...a)
|
|
3054
3134
|
});
|
|
3055
3135
|
}
|
|
3056
3136
|
}
|
|
3057
|
-
}
|
|
3058
|
-
await this._deviceSpaceSync
|
|
3137
|
+
};
|
|
3138
|
+
await identity.space.spaceState.addCredentialProcessor(this._deviceSpaceSync);
|
|
3059
3139
|
}
|
|
3060
3140
|
};
|
|
3061
3141
|
|
|
@@ -3596,7 +3676,7 @@ var NetworkServiceImpl = class {
|
|
|
3596
3676
|
|
|
3597
3677
|
// packages/sdk/client-services/src/packlets/storage/storage.ts
|
|
3598
3678
|
var import_client_protocol4 = require("@dxos/client-protocol");
|
|
3599
|
-
var
|
|
3679
|
+
var import_errors5 = require("@dxos/errors");
|
|
3600
3680
|
var import_config = require("@dxos/protocols/proto/dxos/config");
|
|
3601
3681
|
var import_random_access_storage = require("@dxos/random-access-storage");
|
|
3602
3682
|
var import_util8 = require("@dxos/util");
|
|
@@ -3604,16 +3684,16 @@ var StorageDriver = import_config.Runtime.Client.Storage.StorageDriver;
|
|
|
3604
3684
|
var createStorageObjects = (config) => {
|
|
3605
3685
|
const { path = (0, import_util8.isNode)() ? import_client_protocol4.DX_DATA : "dxos/storage", storageType, keyStorage, persistent = false } = config != null ? config : {};
|
|
3606
3686
|
if (persistent && storageType === StorageDriver.RAM) {
|
|
3607
|
-
throw new
|
|
3687
|
+
throw new import_errors5.InvalidConfigError("RAM storage cannot be used in persistent mode.");
|
|
3608
3688
|
}
|
|
3609
3689
|
if (!persistent && storageType !== void 0 && storageType !== StorageDriver.RAM) {
|
|
3610
|
-
throw new
|
|
3690
|
+
throw new import_errors5.InvalidConfigError("Cannot use a persistent storage in not persistent mode.");
|
|
3611
3691
|
}
|
|
3612
3692
|
if (persistent && keyStorage === StorageDriver.RAM) {
|
|
3613
|
-
throw new
|
|
3693
|
+
throw new import_errors5.InvalidConfigError("RAM key storage cannot be used in persistent mode.");
|
|
3614
3694
|
}
|
|
3615
3695
|
if (!persistent && keyStorage !== StorageDriver.RAM && keyStorage !== void 0) {
|
|
3616
|
-
throw new
|
|
3696
|
+
throw new import_errors5.InvalidConfigError("Cannot use a persistent key storage in not persistent mode.");
|
|
3617
3697
|
}
|
|
3618
3698
|
return {
|
|
3619
3699
|
storage: (0, import_random_access_storage.createStorage)({
|
|
@@ -4135,6 +4215,7 @@ var acceptInvitation = (guest, invitation) => {
|
|
|
4135
4215
|
// packages/sdk/client-services/src/packlets/testing/test-builder.ts
|
|
4136
4216
|
var import_context8 = require("@dxos/context");
|
|
4137
4217
|
var import_credentials15 = require("@dxos/credentials");
|
|
4218
|
+
var import_debug7 = require("@dxos/debug");
|
|
4138
4219
|
var import_echo_pipeline5 = require("@dxos/echo-pipeline");
|
|
4139
4220
|
var import_testing = require("@dxos/echo-pipeline/testing");
|
|
4140
4221
|
var import_feed_store5 = require("@dxos/feed-store");
|
|
@@ -4201,6 +4282,9 @@ var TestPeer = class {
|
|
|
4201
4282
|
this.opts = opts;
|
|
4202
4283
|
this._props = {};
|
|
4203
4284
|
}
|
|
4285
|
+
get props() {
|
|
4286
|
+
return this._props;
|
|
4287
|
+
}
|
|
4204
4288
|
get storage() {
|
|
4205
4289
|
var _a, _b;
|
|
4206
4290
|
return (_b = (_a = this._props).storage) != null ? _b : _a.storage = (0, import_random_access_storage2.createStorage)({
|
|
@@ -4253,6 +4337,18 @@ var TestPeer = class {
|
|
|
4253
4337
|
blobStore: this.blobStore
|
|
4254
4338
|
});
|
|
4255
4339
|
}
|
|
4340
|
+
get identity() {
|
|
4341
|
+
var _a;
|
|
4342
|
+
return (_a = this._props.signingContext) != null ? _a : (0, import_debug7.failUndefined)();
|
|
4343
|
+
}
|
|
4344
|
+
get dataSpaceManager() {
|
|
4345
|
+
var _a, _b;
|
|
4346
|
+
return (_b = (_a = this._props).dataSpaceManager) != null ? _b : _a.dataSpaceManager = new DataSpaceManager(this.spaceManager, this.metadataStore, new import_echo_pipeline5.DataServiceSubscriptions(), this.keyring, this.identity, this.feedStore);
|
|
4347
|
+
}
|
|
4348
|
+
async createIdentity() {
|
|
4349
|
+
var _a, _b;
|
|
4350
|
+
(_b = (_a = this._props).signingContext) != null ? _b : _a.signingContext = await createSigningContext(this.keyring);
|
|
4351
|
+
}
|
|
4256
4352
|
async destroy() {
|
|
4257
4353
|
await this.storage.reset();
|
|
4258
4354
|
}
|