@dxos/client-services 0.3.9-main.dd8d283 → 0.3.9-main.de60860
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-QF4K6HCB.mjs → chunk-MPATL7UM.mjs} +128 -65
- package/dist/lib/browser/chunk-MPATL7UM.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 +7 -3
- package/dist/lib/browser/packlets/testing/index.mjs.map +3 -3
- package/dist/lib/node/{chunk-T4KNF2MX.cjs → chunk-NFGUIPXS.cjs} +129 -77
- package/dist/lib/node/chunk-NFGUIPXS.cjs.map +7 -0
- package/dist/lib/node/index.cjs +37 -37
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/packlets/testing/index.cjs +11 -8
- package/dist/lib/node/packlets/testing/index.cjs.map +3 -3
- package/dist/types/src/packlets/services/automerge-host.test.d.ts +2 -0
- package/dist/types/src/packlets/services/automerge-host.test.d.ts.map +1 -0
- package/dist/types/src/packlets/services/service-context.d.ts +2 -1
- package/dist/types/src/packlets/services/service-context.d.ts.map +1 -1
- package/dist/types/src/packlets/services/service-host.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/automerge-space-state.d.ts +8 -0
- package/dist/types/src/packlets/spaces/automerge-space-state.d.ts.map +1 -0
- package/dist/types/src/packlets/spaces/data-space-manager.d.ts +3 -2
- package/dist/types/src/packlets/spaces/data-space-manager.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/data-space.d.ts +7 -2
- package/dist/types/src/packlets/spaces/data-space.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/genesis.d.ts +1 -1
- package/dist/types/src/packlets/spaces/genesis.d.ts.map +1 -1
- package/dist/types/src/packlets/testing/test-builder.d.ts +3 -1
- package/dist/types/src/packlets/testing/test-builder.d.ts.map +1 -1
- package/dist/types/src/version.d.ts +1 -1
- package/package.json +35 -35
- package/src/packlets/services/automerge-host.test.ts +56 -0
- package/src/packlets/services/service-context.ts +6 -0
- package/src/packlets/services/service-host.ts +5 -2
- package/src/packlets/spaces/automerge-space-state.ts +22 -0
- package/src/packlets/spaces/data-space-manager.ts +12 -2
- package/src/packlets/spaces/data-space.ts +52 -6
- package/src/packlets/spaces/genesis.ts +7 -1
- package/src/packlets/testing/test-builder.ts +7 -0
- package/src/version.ts +1 -1
- package/dist/lib/browser/chunk-QF4K6HCB.mjs.map +0 -7
- package/dist/lib/node/chunk-T4KNF2MX.cjs.map +0 -7
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
import "@dxos/node-std/globals";
|
|
2
2
|
|
|
3
|
+
// inject-globals:@inject-globals
|
|
4
|
+
import {
|
|
5
|
+
global,
|
|
6
|
+
Buffer,
|
|
7
|
+
process
|
|
8
|
+
} from "@dxos/node-std/inject-globals";
|
|
9
|
+
|
|
3
10
|
// packages/sdk/client-services/src/packlets/devtools/feeds.ts
|
|
4
11
|
import { EventSubscriptions } from "@dxos/async";
|
|
5
12
|
import { Stream } from "@dxos/codec-protobuf";
|
|
@@ -2534,7 +2541,7 @@ var getPlatform = () => {
|
|
|
2534
2541
|
};
|
|
2535
2542
|
|
|
2536
2543
|
// packages/sdk/client-services/src/version.ts
|
|
2537
|
-
var DXOS_VERSION = "0.3.9-main.
|
|
2544
|
+
var DXOS_VERSION = "0.3.9-main.de60860";
|
|
2538
2545
|
|
|
2539
2546
|
// packages/sdk/client-services/src/packlets/services/diagnostics.ts
|
|
2540
2547
|
var __dxlog_file10 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/diagnostics.ts";
|
|
@@ -2668,12 +2675,30 @@ import { createMappedFeedWriter } from "@dxos/echo-pipeline";
|
|
|
2668
2675
|
import { PublicKey as PublicKey8 } from "@dxos/keys";
|
|
2669
2676
|
import { log as log10 } from "@dxos/log";
|
|
2670
2677
|
import { CancelledError, SystemError } from "@dxos/protocols";
|
|
2671
|
-
import { SpaceState } from "@dxos/protocols/proto/dxos/client/services";
|
|
2678
|
+
import { SpaceState, CreateEpochRequest } from "@dxos/protocols/proto/dxos/client/services";
|
|
2672
2679
|
import { AdmittedFeed as AdmittedFeed3 } from "@dxos/protocols/proto/dxos/halo/credentials";
|
|
2673
2680
|
import { Timeframe as Timeframe2 } from "@dxos/timeframe";
|
|
2674
2681
|
import { trace as trace6 } from "@dxos/tracing";
|
|
2675
2682
|
import { ComplexSet as ComplexSet3 } from "@dxos/util";
|
|
2676
2683
|
|
|
2684
|
+
// packages/sdk/client-services/src/packlets/spaces/automerge-space-state.ts
|
|
2685
|
+
import { checkCredentialType } from "@dxos/credentials";
|
|
2686
|
+
var AutomergeSpaceState = class {
|
|
2687
|
+
constructor() {
|
|
2688
|
+
this.rootUrl = void 0;
|
|
2689
|
+
this.lastEpoch = void 0;
|
|
2690
|
+
}
|
|
2691
|
+
async processCredential(credential) {
|
|
2692
|
+
if (!checkCredentialType(credential, "dxos.halo.credentials.Epoch")) {
|
|
2693
|
+
return;
|
|
2694
|
+
}
|
|
2695
|
+
this.lastEpoch = credential;
|
|
2696
|
+
if (credential.subject.assertion.automergeRoot) {
|
|
2697
|
+
this.rootUrl = credential.subject.assertion.automergeRoot;
|
|
2698
|
+
}
|
|
2699
|
+
}
|
|
2700
|
+
};
|
|
2701
|
+
|
|
2677
2702
|
// packages/sdk/client-services/src/packlets/spaces/notarization-plugin.ts
|
|
2678
2703
|
import { DeferredTask, Event as Event4, scheduleTask as scheduleTask3, sleep, TimeoutError as TimeoutError2, Trigger as Trigger4 } from "@dxos/async";
|
|
2679
2704
|
import { Context as Context6, rejectOnDispose } from "@dxos/context";
|
|
@@ -2959,6 +2984,9 @@ var DataSpace = class DataSpace2 {
|
|
|
2959
2984
|
constructor(params) {
|
|
2960
2985
|
this._ctx = new Context7();
|
|
2961
2986
|
this._notarizationPlugin = new NotarizationPlugin();
|
|
2987
|
+
this._cache = void 0;
|
|
2988
|
+
// TODO(dmaretskyi): Move into Space?
|
|
2989
|
+
this._automergeSpaceState = new AutomergeSpaceState();
|
|
2962
2990
|
this._state = SpaceState.CLOSED;
|
|
2963
2991
|
/**
|
|
2964
2992
|
* Error for _state === SpaceState.ERROR.
|
|
@@ -2975,6 +3003,7 @@ var DataSpace = class DataSpace2 {
|
|
|
2975
3003
|
this._metadataStore = params.metadataStore;
|
|
2976
3004
|
this._signingContext = params.signingContext;
|
|
2977
3005
|
this._callbacks = params.callbacks ?? {};
|
|
3006
|
+
this._automergeHost = params.automergeHost;
|
|
2978
3007
|
this.authVerifier = new TrustedKeySetAuthVerifier({
|
|
2979
3008
|
trustedKeysProvider: () => new ComplexSet3(PublicKey8.hash, Array.from(this._inner.spaceState.members.values()).filter((member) => !member.removed).map((member) => member.key)),
|
|
2980
3009
|
update: this._inner.stateUpdate,
|
|
@@ -2986,7 +3015,7 @@ var DataSpace = class DataSpace2 {
|
|
|
2986
3015
|
state: SpaceState[this._state]
|
|
2987
3016
|
}, {
|
|
2988
3017
|
F: __dxlog_file12,
|
|
2989
|
-
L:
|
|
3018
|
+
L: 137,
|
|
2990
3019
|
S: this,
|
|
2991
3020
|
C: (f, a) => f(...a)
|
|
2992
3021
|
});
|
|
@@ -3016,6 +3045,9 @@ var DataSpace = class DataSpace2 {
|
|
|
3016
3045
|
get cache() {
|
|
3017
3046
|
return this._cache;
|
|
3018
3047
|
}
|
|
3048
|
+
get automergeSpaceState() {
|
|
3049
|
+
return this._automergeSpaceState;
|
|
3050
|
+
}
|
|
3019
3051
|
async open() {
|
|
3020
3052
|
await this._open();
|
|
3021
3053
|
}
|
|
@@ -3023,13 +3055,14 @@ var DataSpace = class DataSpace2 {
|
|
|
3023
3055
|
await this._gossip.open();
|
|
3024
3056
|
await this._notarizationPlugin.open();
|
|
3025
3057
|
await this._inner.spaceState.addCredentialProcessor(this._notarizationPlugin);
|
|
3058
|
+
await this._inner.spaceState.addCredentialProcessor(this._automergeSpaceState);
|
|
3026
3059
|
await this._inner.open(new Context7());
|
|
3027
3060
|
this._state = SpaceState.CONTROL_ONLY;
|
|
3028
3061
|
log10("new state", {
|
|
3029
3062
|
state: SpaceState[this._state]
|
|
3030
3063
|
}, {
|
|
3031
3064
|
F: __dxlog_file12,
|
|
3032
|
-
L:
|
|
3065
|
+
L: 189,
|
|
3033
3066
|
S: this,
|
|
3034
3067
|
C: (f, a) => f(...a)
|
|
3035
3068
|
});
|
|
@@ -3047,7 +3080,7 @@ var DataSpace = class DataSpace2 {
|
|
|
3047
3080
|
state: SpaceState[this._state]
|
|
3048
3081
|
}, {
|
|
3049
3082
|
F: __dxlog_file12,
|
|
3050
|
-
L:
|
|
3083
|
+
L: 203,
|
|
3051
3084
|
S: this,
|
|
3052
3085
|
C: (f, a) => f(...a)
|
|
3053
3086
|
});
|
|
@@ -3055,6 +3088,7 @@ var DataSpace = class DataSpace2 {
|
|
|
3055
3088
|
this._ctx = new Context7();
|
|
3056
3089
|
await this.authVerifier.close();
|
|
3057
3090
|
await this._inner.close();
|
|
3091
|
+
await this._inner.spaceState.removeCredentialProcessor(this._automergeSpaceState);
|
|
3058
3092
|
await this._inner.spaceState.removeCredentialProcessor(this._notarizationPlugin);
|
|
3059
3093
|
await this._notarizationPlugin.close();
|
|
3060
3094
|
await this._presence.destroy();
|
|
@@ -3078,7 +3112,7 @@ var DataSpace = class DataSpace2 {
|
|
|
3078
3112
|
if (err instanceof CancelledError) {
|
|
3079
3113
|
log10("data pipeline initialization cancelled", err, {
|
|
3080
3114
|
F: __dxlog_file12,
|
|
3081
|
-
L:
|
|
3115
|
+
L: 236,
|
|
3082
3116
|
S: this,
|
|
3083
3117
|
C: (f, a) => f(...a)
|
|
3084
3118
|
});
|
|
@@ -3086,7 +3120,7 @@ var DataSpace = class DataSpace2 {
|
|
|
3086
3120
|
}
|
|
3087
3121
|
log10.error("Error initializing data pipeline", err, {
|
|
3088
3122
|
F: __dxlog_file12,
|
|
3089
|
-
L:
|
|
3123
|
+
L: 240,
|
|
3090
3124
|
S: this,
|
|
3091
3125
|
C: (f, a) => f(...a)
|
|
3092
3126
|
});
|
|
@@ -3095,7 +3129,7 @@ var DataSpace = class DataSpace2 {
|
|
|
3095
3129
|
state: SpaceState[this._state]
|
|
3096
3130
|
}, {
|
|
3097
3131
|
F: __dxlog_file12,
|
|
3098
|
-
L:
|
|
3132
|
+
L: 242,
|
|
3099
3133
|
S: this,
|
|
3100
3134
|
C: (f, a) => f(...a)
|
|
3101
3135
|
});
|
|
@@ -3115,7 +3149,7 @@ var DataSpace = class DataSpace2 {
|
|
|
3115
3149
|
state: SpaceState[this._state]
|
|
3116
3150
|
}, {
|
|
3117
3151
|
F: __dxlog_file12,
|
|
3118
|
-
L:
|
|
3152
|
+
L: 258,
|
|
3119
3153
|
S: this,
|
|
3120
3154
|
C: (f, a) => f(...a)
|
|
3121
3155
|
});
|
|
@@ -3126,7 +3160,7 @@ var DataSpace = class DataSpace2 {
|
|
|
3126
3160
|
await cancelWithContext2(this._ctx, this._inner.dataPipeline.ensureEpochInitialized());
|
|
3127
3161
|
log10("waiting for data pipeline to reach target timeframe", void 0, {
|
|
3128
3162
|
F: __dxlog_file12,
|
|
3129
|
-
L:
|
|
3163
|
+
L: 272,
|
|
3130
3164
|
S: this,
|
|
3131
3165
|
C: (f, a) => f(...a)
|
|
3132
3166
|
});
|
|
@@ -3137,7 +3171,7 @@ var DataSpace = class DataSpace2 {
|
|
|
3137
3171
|
this.metrics.dataPipelineReady = /* @__PURE__ */ new Date();
|
|
3138
3172
|
log10("data pipeline ready", void 0, {
|
|
3139
3173
|
F: __dxlog_file12,
|
|
3140
|
-
L:
|
|
3174
|
+
L: 281,
|
|
3141
3175
|
S: this,
|
|
3142
3176
|
C: (f, a) => f(...a)
|
|
3143
3177
|
});
|
|
@@ -3147,7 +3181,7 @@ var DataSpace = class DataSpace2 {
|
|
|
3147
3181
|
state: SpaceState[this._state]
|
|
3148
3182
|
}, {
|
|
3149
3183
|
F: __dxlog_file12,
|
|
3150
|
-
L:
|
|
3184
|
+
L: 285,
|
|
3151
3185
|
S: this,
|
|
3152
3186
|
C: (f, a) => f(...a)
|
|
3153
3187
|
});
|
|
@@ -3163,7 +3197,7 @@ var DataSpace = class DataSpace2 {
|
|
|
3163
3197
|
await this._createWritableFeeds();
|
|
3164
3198
|
log10("writable feeds created", void 0, {
|
|
3165
3199
|
F: __dxlog_file12,
|
|
3166
|
-
L:
|
|
3200
|
+
L: 301,
|
|
3167
3201
|
S: this,
|
|
3168
3202
|
C: (f, a) => f(...a)
|
|
3169
3203
|
});
|
|
@@ -3235,8 +3269,28 @@ var DataSpace = class DataSpace2 {
|
|
|
3235
3269
|
}
|
|
3236
3270
|
});
|
|
3237
3271
|
}
|
|
3238
|
-
async createEpoch() {
|
|
3239
|
-
|
|
3272
|
+
async createEpoch(options) {
|
|
3273
|
+
let epoch;
|
|
3274
|
+
switch (options?.migration) {
|
|
3275
|
+
case void 0:
|
|
3276
|
+
case CreateEpochRequest.Migration.NONE:
|
|
3277
|
+
{
|
|
3278
|
+
epoch = await this.dataPipeline.createEpoch();
|
|
3279
|
+
}
|
|
3280
|
+
break;
|
|
3281
|
+
case CreateEpochRequest.Migration.INIT_AUTOMERGE: {
|
|
3282
|
+
const document = this._automergeHost.repo.create();
|
|
3283
|
+
epoch = {
|
|
3284
|
+
previousId: this._automergeSpaceState.lastEpoch?.id,
|
|
3285
|
+
number: (this._automergeSpaceState.lastEpoch?.subject.assertion.number ?? -1) + 1,
|
|
3286
|
+
timeframe: this._automergeSpaceState.lastEpoch?.subject.assertion.timeframe ?? new Timeframe2(),
|
|
3287
|
+
automergeRoot: document.url
|
|
3288
|
+
};
|
|
3289
|
+
}
|
|
3290
|
+
}
|
|
3291
|
+
if (!epoch) {
|
|
3292
|
+
return;
|
|
3293
|
+
}
|
|
3240
3294
|
const receipt = await this.inner.controlPipeline.writer.write({
|
|
3241
3295
|
credential: {
|
|
3242
3296
|
credential: await this._signingContext.credentialSigner.createCredential({
|
|
@@ -3283,7 +3337,7 @@ var DataSpace = class DataSpace2 {
|
|
|
3283
3337
|
state: SpaceState[this._state]
|
|
3284
3338
|
}, {
|
|
3285
3339
|
F: __dxlog_file12,
|
|
3286
|
-
L:
|
|
3340
|
+
L: 450,
|
|
3287
3341
|
S: this,
|
|
3288
3342
|
C: (f, a) => f(...a)
|
|
3289
3343
|
});
|
|
@@ -3336,7 +3390,7 @@ import { createCredential } from "@dxos/credentials";
|
|
|
3336
3390
|
import { failUndefined as failUndefined2 } from "@dxos/debug";
|
|
3337
3391
|
import { AdmittedFeed as AdmittedFeed4, SpaceMember as SpaceMember2 } from "@dxos/protocols/proto/dxos/halo/credentials";
|
|
3338
3392
|
import { Timeframe as Timeframe3 } from "@dxos/timeframe";
|
|
3339
|
-
var spaceGenesis = async (keyring, signingContext, space) => {
|
|
3393
|
+
var spaceGenesis = async (keyring, signingContext, space, automergeRoot) => {
|
|
3340
3394
|
const credentials = [
|
|
3341
3395
|
await createCredential({
|
|
3342
3396
|
signer: keyring,
|
|
@@ -3386,7 +3440,8 @@ var spaceGenesis = async (keyring, signingContext, space) => {
|
|
|
3386
3440
|
number: 0,
|
|
3387
3441
|
previousId: void 0,
|
|
3388
3442
|
timeframe: new Timeframe3(),
|
|
3389
|
-
snapshotCid: void 0
|
|
3443
|
+
snapshotCid: void 0,
|
|
3444
|
+
automergeRoot
|
|
3390
3445
|
}
|
|
3391
3446
|
})
|
|
3392
3447
|
];
|
|
@@ -3415,13 +3470,14 @@ var __dxlog_file13 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/s
|
|
|
3415
3470
|
var PRESENCE_ANNOUNCE_INTERVAL = 1e4;
|
|
3416
3471
|
var PRESENCE_OFFLINE_TIMEOUT = 2e4;
|
|
3417
3472
|
var DataSpaceManager = class DataSpaceManager2 {
|
|
3418
|
-
constructor(_spaceManager, _metadataStore, _dataServiceSubscriptions, _keyring, _signingContext, _feedStore) {
|
|
3473
|
+
constructor(_spaceManager, _metadataStore, _dataServiceSubscriptions, _keyring, _signingContext, _feedStore, _automergeHost) {
|
|
3419
3474
|
this._spaceManager = _spaceManager;
|
|
3420
3475
|
this._metadataStore = _metadataStore;
|
|
3421
3476
|
this._dataServiceSubscriptions = _dataServiceSubscriptions;
|
|
3422
3477
|
this._keyring = _keyring;
|
|
3423
3478
|
this._signingContext = _signingContext;
|
|
3424
3479
|
this._feedStore = _feedStore;
|
|
3480
|
+
this._automergeHost = _automergeHost;
|
|
3425
3481
|
this._ctx = new Context8();
|
|
3426
3482
|
this.updated = new Event6();
|
|
3427
3483
|
this._spaces = new ComplexMap3(PublicKey9.hash);
|
|
@@ -3435,7 +3491,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
3435
3491
|
async open() {
|
|
3436
3492
|
log11("open", void 0, {
|
|
3437
3493
|
F: __dxlog_file13,
|
|
3438
|
-
L:
|
|
3494
|
+
L: 90,
|
|
3439
3495
|
S: this,
|
|
3440
3496
|
C: (f, a) => f(...a)
|
|
3441
3497
|
});
|
|
@@ -3443,7 +3499,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
3443
3499
|
id: this._instanceId
|
|
3444
3500
|
}), {
|
|
3445
3501
|
F: __dxlog_file13,
|
|
3446
|
-
L:
|
|
3502
|
+
L: 91,
|
|
3447
3503
|
S: this,
|
|
3448
3504
|
C: (f, a) => f(...a)
|
|
3449
3505
|
});
|
|
@@ -3451,7 +3507,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
3451
3507
|
spaces: this._metadataStore.spaces.length
|
|
3452
3508
|
}, {
|
|
3453
3509
|
F: __dxlog_file13,
|
|
3454
|
-
L:
|
|
3510
|
+
L: 92,
|
|
3455
3511
|
S: this,
|
|
3456
3512
|
C: (f, a) => f(...a)
|
|
3457
3513
|
});
|
|
@@ -3461,7 +3517,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
3461
3517
|
spaceMetadata
|
|
3462
3518
|
}, {
|
|
3463
3519
|
F: __dxlog_file13,
|
|
3464
|
-
L:
|
|
3520
|
+
L: 96,
|
|
3465
3521
|
S: this,
|
|
3466
3522
|
C: (f, a) => f(...a)
|
|
3467
3523
|
});
|
|
@@ -3472,7 +3528,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
3472
3528
|
err
|
|
3473
3529
|
}, {
|
|
3474
3530
|
F: __dxlog_file13,
|
|
3475
|
-
L:
|
|
3531
|
+
L: 99,
|
|
3476
3532
|
S: this,
|
|
3477
3533
|
C: (f, a) => f(...a)
|
|
3478
3534
|
});
|
|
@@ -3489,7 +3545,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
3489
3545
|
id: this._instanceId
|
|
3490
3546
|
}), {
|
|
3491
3547
|
F: __dxlog_file13,
|
|
3492
|
-
L:
|
|
3548
|
+
L: 112,
|
|
3493
3549
|
S: this,
|
|
3494
3550
|
C: (f, a) => f(...a)
|
|
3495
3551
|
});
|
|
@@ -3497,7 +3553,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
3497
3553
|
async close() {
|
|
3498
3554
|
log11("close", void 0, {
|
|
3499
3555
|
F: __dxlog_file13,
|
|
3500
|
-
L:
|
|
3556
|
+
L: 117,
|
|
3501
3557
|
S: this,
|
|
3502
3558
|
C: (f, a) => f(...a)
|
|
3503
3559
|
});
|
|
@@ -3513,7 +3569,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
3513
3569
|
async createSpace() {
|
|
3514
3570
|
invariant11(this._isOpen, "Not open.", {
|
|
3515
3571
|
F: __dxlog_file13,
|
|
3516
|
-
L:
|
|
3572
|
+
L: 130,
|
|
3517
3573
|
S: this,
|
|
3518
3574
|
A: [
|
|
3519
3575
|
"this._isOpen",
|
|
@@ -3534,17 +3590,18 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
3534
3590
|
spaceKey
|
|
3535
3591
|
}, {
|
|
3536
3592
|
F: __dxlog_file13,
|
|
3537
|
-
L:
|
|
3593
|
+
L: 142,
|
|
3538
3594
|
S: this,
|
|
3539
3595
|
C: (f, a) => f(...a)
|
|
3540
3596
|
});
|
|
3541
3597
|
const space = await this._constructSpace(metadata);
|
|
3542
|
-
const
|
|
3598
|
+
const automergeRoot = this._automergeHost.repo.create();
|
|
3599
|
+
const credentials = await spaceGenesis(this._keyring, this._signingContext, space.inner, automergeRoot.url);
|
|
3543
3600
|
await this._metadataStore.addSpace(metadata);
|
|
3544
3601
|
const memberCredential = credentials[1];
|
|
3545
3602
|
invariant11(getCredentialAssertion2(memberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
|
|
3546
3603
|
F: __dxlog_file13,
|
|
3547
|
-
L:
|
|
3604
|
+
L: 151,
|
|
3548
3605
|
S: this,
|
|
3549
3606
|
A: [
|
|
3550
3607
|
"getCredentialAssertion(memberCredential)['@type'] === 'dxos.halo.credentials.SpaceMember'",
|
|
@@ -3562,13 +3619,13 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
3562
3619
|
opts
|
|
3563
3620
|
}, {
|
|
3564
3621
|
F: __dxlog_file13,
|
|
3565
|
-
L:
|
|
3622
|
+
L: 163,
|
|
3566
3623
|
S: this,
|
|
3567
3624
|
C: (f, a) => f(...a)
|
|
3568
3625
|
});
|
|
3569
3626
|
invariant11(this._isOpen, "Not open.", {
|
|
3570
3627
|
F: __dxlog_file13,
|
|
3571
|
-
L:
|
|
3628
|
+
L: 164,
|
|
3572
3629
|
S: this,
|
|
3573
3630
|
A: [
|
|
3574
3631
|
"this._isOpen",
|
|
@@ -3577,7 +3634,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
3577
3634
|
});
|
|
3578
3635
|
invariant11(!this._spaces.has(opts.spaceKey), "Space already exists.", {
|
|
3579
3636
|
F: __dxlog_file13,
|
|
3580
|
-
L:
|
|
3637
|
+
L: 165,
|
|
3581
3638
|
S: this,
|
|
3582
3639
|
A: [
|
|
3583
3640
|
"!this._spaces.has(opts.spaceKey)",
|
|
@@ -3612,7 +3669,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
3612
3669
|
metadata
|
|
3613
3670
|
}, {
|
|
3614
3671
|
F: __dxlog_file13,
|
|
3615
|
-
L:
|
|
3672
|
+
L: 198,
|
|
3616
3673
|
S: this,
|
|
3617
3674
|
C: (f, a) => f(...a)
|
|
3618
3675
|
});
|
|
@@ -3648,7 +3705,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
3648
3705
|
onAuthFailure: () => {
|
|
3649
3706
|
log11.warn("auth failure", void 0, {
|
|
3650
3707
|
F: __dxlog_file13,
|
|
3651
|
-
L:
|
|
3708
|
+
L: 233,
|
|
3652
3709
|
S: this,
|
|
3653
3710
|
C: (f, a) => f(...a)
|
|
3654
3711
|
});
|
|
@@ -3672,7 +3729,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
3672
3729
|
space: space.key
|
|
3673
3730
|
}, {
|
|
3674
3731
|
F: __dxlog_file13,
|
|
3675
|
-
L:
|
|
3732
|
+
L: 251,
|
|
3676
3733
|
S: this,
|
|
3677
3734
|
C: (f, a) => f(...a)
|
|
3678
3735
|
});
|
|
@@ -3684,7 +3741,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
3684
3741
|
open: this._isOpen
|
|
3685
3742
|
}, {
|
|
3686
3743
|
F: __dxlog_file13,
|
|
3687
|
-
L:
|
|
3744
|
+
L: 258,
|
|
3688
3745
|
S: this,
|
|
3689
3746
|
C: (f, a) => f(...a)
|
|
3690
3747
|
});
|
|
@@ -3697,14 +3754,15 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
3697
3754
|
space: space.key
|
|
3698
3755
|
}, {
|
|
3699
3756
|
F: __dxlog_file13,
|
|
3700
|
-
L:
|
|
3757
|
+
L: 264,
|
|
3701
3758
|
S: this,
|
|
3702
3759
|
C: (f, a) => f(...a)
|
|
3703
3760
|
});
|
|
3704
3761
|
await this._dataServiceSubscriptions.unregisterSpace(space.key);
|
|
3705
3762
|
}
|
|
3706
3763
|
},
|
|
3707
|
-
cache: metadata.cache
|
|
3764
|
+
cache: metadata.cache,
|
|
3765
|
+
automergeHost: this._automergeHost
|
|
3708
3766
|
});
|
|
3709
3767
|
if (metadata.state !== SpaceState2.INACTIVE) {
|
|
3710
3768
|
await dataSpace.open();
|
|
@@ -3961,7 +4019,7 @@ import { Trigger as Trigger5 } from "@dxos/async";
|
|
|
3961
4019
|
import { Context as Context9 } from "@dxos/context";
|
|
3962
4020
|
import { getCredentialAssertion as getCredentialAssertion3 } from "@dxos/credentials";
|
|
3963
4021
|
import { failUndefined as failUndefined3 } from "@dxos/debug";
|
|
3964
|
-
import { valueEncoding, MetadataStore, SpaceManager, DataServiceSubscriptions, SnapshotStore } from "@dxos/echo-pipeline";
|
|
4022
|
+
import { valueEncoding, MetadataStore, SpaceManager, DataServiceSubscriptions, SnapshotStore, AutomergeHost } from "@dxos/echo-pipeline";
|
|
3965
4023
|
import { FeedFactory, FeedStore } from "@dxos/feed-store";
|
|
3966
4024
|
import { invariant as invariant13 } from "@dxos/invariant";
|
|
3967
4025
|
import { Keyring } from "@dxos/keyring";
|
|
@@ -4016,6 +4074,7 @@ var ServiceContext = class ServiceContext2 {
|
|
|
4016
4074
|
snapshotStore: this.snapshotStore
|
|
4017
4075
|
});
|
|
4018
4076
|
this.identityManager = new IdentityManager(this.metadataStore, this.keyring, this.feedStore, this.spaceManager);
|
|
4077
|
+
this.automergeHost = new AutomergeHost(storage.createDirectory("automerge"));
|
|
4019
4078
|
this.invitations = new InvitationsHandler(this.networkManager);
|
|
4020
4079
|
this._handlerFactories.set(Invitation6.Kind.DEVICE, () => new DeviceInvitationProtocol(this.keyring, () => this.identityManager.identity ?? failUndefined3(), this._acceptIdentity.bind(this)));
|
|
4021
4080
|
}
|
|
@@ -4023,7 +4082,7 @@ var ServiceContext = class ServiceContext2 {
|
|
|
4023
4082
|
await this._checkStorageVersion();
|
|
4024
4083
|
log13("opening...", void 0, {
|
|
4025
4084
|
F: __dxlog_file15,
|
|
4026
|
-
L:
|
|
4085
|
+
L: 133,
|
|
4027
4086
|
S: this,
|
|
4028
4087
|
C: (f, a) => f(...a)
|
|
4029
4088
|
});
|
|
@@ -4031,7 +4090,7 @@ var ServiceContext = class ServiceContext2 {
|
|
|
4031
4090
|
id: this._instanceId
|
|
4032
4091
|
}), {
|
|
4033
4092
|
F: __dxlog_file15,
|
|
4034
|
-
L:
|
|
4093
|
+
L: 134,
|
|
4035
4094
|
S: this,
|
|
4036
4095
|
C: (f, a) => f(...a)
|
|
4037
4096
|
});
|
|
@@ -4047,13 +4106,13 @@ var ServiceContext = class ServiceContext2 {
|
|
|
4047
4106
|
id: this._instanceId
|
|
4048
4107
|
}), {
|
|
4049
4108
|
F: __dxlog_file15,
|
|
4050
|
-
L:
|
|
4109
|
+
L: 144,
|
|
4051
4110
|
S: this,
|
|
4052
4111
|
C: (f, a) => f(...a)
|
|
4053
4112
|
});
|
|
4054
4113
|
log13("opened", void 0, {
|
|
4055
4114
|
F: __dxlog_file15,
|
|
4056
|
-
L:
|
|
4115
|
+
L: 145,
|
|
4057
4116
|
S: this,
|
|
4058
4117
|
C: (f, a) => f(...a)
|
|
4059
4118
|
});
|
|
@@ -4061,13 +4120,14 @@ var ServiceContext = class ServiceContext2 {
|
|
|
4061
4120
|
async close() {
|
|
4062
4121
|
log13("closing...", void 0, {
|
|
4063
4122
|
F: __dxlog_file15,
|
|
4064
|
-
L:
|
|
4123
|
+
L: 149,
|
|
4065
4124
|
S: this,
|
|
4066
4125
|
C: (f, a) => f(...a)
|
|
4067
4126
|
});
|
|
4068
4127
|
if (this._deviceSpaceSync && this.identityManager.identity) {
|
|
4069
4128
|
await this.identityManager.identity.space.spaceState.removeCredentialProcessor(this._deviceSpaceSync);
|
|
4070
4129
|
}
|
|
4130
|
+
await this.automergeHost.close();
|
|
4071
4131
|
await this.dataSpaceManager?.close();
|
|
4072
4132
|
await this.identityManager.close();
|
|
4073
4133
|
await this.spaceManager.close();
|
|
@@ -4078,7 +4138,7 @@ var ServiceContext = class ServiceContext2 {
|
|
|
4078
4138
|
await this.metadataStore.close();
|
|
4079
4139
|
log13("closed", void 0, {
|
|
4080
4140
|
F: __dxlog_file15,
|
|
4081
|
-
L:
|
|
4141
|
+
L: 162,
|
|
4082
4142
|
S: this,
|
|
4083
4143
|
C: (f, a) => f(...a)
|
|
4084
4144
|
});
|
|
@@ -4092,7 +4152,7 @@ var ServiceContext = class ServiceContext2 {
|
|
|
4092
4152
|
const factory = this._handlerFactories.get(invitation.kind);
|
|
4093
4153
|
invariant13(factory, `Unknown invitation kind: ${invitation.kind}`, {
|
|
4094
4154
|
F: __dxlog_file15,
|
|
4095
|
-
L:
|
|
4155
|
+
L: 173,
|
|
4096
4156
|
S: this,
|
|
4097
4157
|
A: [
|
|
4098
4158
|
"factory",
|
|
@@ -4124,7 +4184,7 @@ var ServiceContext = class ServiceContext2 {
|
|
|
4124
4184
|
async _initialize(ctx) {
|
|
4125
4185
|
log13("initializing spaces...", void 0, {
|
|
4126
4186
|
F: __dxlog_file15,
|
|
4127
|
-
L:
|
|
4187
|
+
L: 204,
|
|
4128
4188
|
S: this,
|
|
4129
4189
|
C: (f, a) => f(...a)
|
|
4130
4190
|
});
|
|
@@ -4142,12 +4202,12 @@ var ServiceContext = class ServiceContext2 {
|
|
|
4142
4202
|
});
|
|
4143
4203
|
}
|
|
4144
4204
|
};
|
|
4145
|
-
this.dataSpaceManager = new DataSpaceManager(this.spaceManager, this.metadataStore, this.dataServiceSubscriptions, this.keyring, signingContext, this.feedStore);
|
|
4205
|
+
this.dataSpaceManager = new DataSpaceManager(this.spaceManager, this.metadataStore, this.dataServiceSubscriptions, this.keyring, signingContext, this.feedStore, this.automergeHost);
|
|
4146
4206
|
await this.dataSpaceManager.open();
|
|
4147
4207
|
this._handlerFactories.set(Invitation6.Kind.SPACE, (invitation) => {
|
|
4148
4208
|
invariant13(this.dataSpaceManager, "dataSpaceManager not initialized yet", {
|
|
4149
4209
|
F: __dxlog_file15,
|
|
4150
|
-
L:
|
|
4210
|
+
L: 228,
|
|
4151
4211
|
S: this,
|
|
4152
4212
|
A: [
|
|
4153
4213
|
"this.dataSpaceManager",
|
|
@@ -4171,7 +4231,7 @@ var ServiceContext = class ServiceContext2 {
|
|
|
4171
4231
|
details: assertion
|
|
4172
4232
|
}, {
|
|
4173
4233
|
F: __dxlog_file15,
|
|
4174
|
-
L:
|
|
4234
|
+
L: 244,
|
|
4175
4235
|
S: this,
|
|
4176
4236
|
C: (f, a) => f(...a)
|
|
4177
4237
|
});
|
|
@@ -4182,7 +4242,7 @@ var ServiceContext = class ServiceContext2 {
|
|
|
4182
4242
|
details: assertion
|
|
4183
4243
|
}, {
|
|
4184
4244
|
F: __dxlog_file15,
|
|
4185
|
-
L:
|
|
4245
|
+
L: 248,
|
|
4186
4246
|
S: this,
|
|
4187
4247
|
C: (f, a) => f(...a)
|
|
4188
4248
|
});
|
|
@@ -4193,7 +4253,7 @@ var ServiceContext = class ServiceContext2 {
|
|
|
4193
4253
|
details: assertion
|
|
4194
4254
|
}, {
|
|
4195
4255
|
F: __dxlog_file15,
|
|
4196
|
-
L:
|
|
4256
|
+
L: 253,
|
|
4197
4257
|
S: this,
|
|
4198
4258
|
C: (f, a) => f(...a)
|
|
4199
4259
|
});
|
|
@@ -4204,7 +4264,7 @@ var ServiceContext = class ServiceContext2 {
|
|
|
4204
4264
|
} catch (err) {
|
|
4205
4265
|
log13.catch(err, void 0, {
|
|
4206
4266
|
F: __dxlog_file15,
|
|
4207
|
-
L:
|
|
4267
|
+
L: 259,
|
|
4208
4268
|
S: this,
|
|
4209
4269
|
C: (f, a) => f(...a)
|
|
4210
4270
|
});
|
|
@@ -4924,7 +4984,7 @@ var ClientServicesHost = class ClientServicesHost2 {
|
|
|
4924
4984
|
await this._serviceContext.initialized.wait();
|
|
4925
4985
|
return this._serviceContext.dataSpaceManager;
|
|
4926
4986
|
}),
|
|
4927
|
-
DataService: new DataServiceImpl(this._serviceContext.dataServiceSubscriptions),
|
|
4987
|
+
DataService: new DataServiceImpl(this._serviceContext.dataServiceSubscriptions, this._serviceContext.automergeHost),
|
|
4928
4988
|
NetworkService: new NetworkServiceImpl(this._serviceContext.networkManager, this._serviceContext.signalManager),
|
|
4929
4989
|
LoggingService: this._loggingService,
|
|
4930
4990
|
TracingService: this._tracingService,
|
|
@@ -4954,7 +5014,7 @@ var ClientServicesHost = class ClientServicesHost2 {
|
|
|
4954
5014
|
deviceKey
|
|
4955
5015
|
}, {
|
|
4956
5016
|
F: __dxlog_file17,
|
|
4957
|
-
L:
|
|
5017
|
+
L: 320,
|
|
4958
5018
|
S: this,
|
|
4959
5019
|
C: (f, a) => f(...a)
|
|
4960
5020
|
});
|
|
@@ -4962,7 +5022,7 @@ var ClientServicesHost = class ClientServicesHost2 {
|
|
|
4962
5022
|
id: traceId
|
|
4963
5023
|
}), {
|
|
4964
5024
|
F: __dxlog_file17,
|
|
4965
|
-
L:
|
|
5025
|
+
L: 321,
|
|
4966
5026
|
S: this,
|
|
4967
5027
|
C: (f, a) => f(...a)
|
|
4968
5028
|
});
|
|
@@ -4976,7 +5036,7 @@ var ClientServicesHost = class ClientServicesHost2 {
|
|
|
4976
5036
|
deviceKey
|
|
4977
5037
|
}, {
|
|
4978
5038
|
F: __dxlog_file17,
|
|
4979
|
-
L:
|
|
5039
|
+
L: 332,
|
|
4980
5040
|
S: this,
|
|
4981
5041
|
C: (f, a) => f(...a)
|
|
4982
5042
|
});
|
|
@@ -4992,7 +5052,7 @@ var ClientServicesHost = class ClientServicesHost2 {
|
|
|
4992
5052
|
deviceKey
|
|
4993
5053
|
}, {
|
|
4994
5054
|
F: __dxlog_file17,
|
|
4995
|
-
L:
|
|
5055
|
+
L: 339,
|
|
4996
5056
|
S: this,
|
|
4997
5057
|
C: (f, a) => f(...a)
|
|
4998
5058
|
});
|
|
@@ -5003,13 +5063,13 @@ var ClientServicesHost = class ClientServicesHost2 {
|
|
|
5003
5063
|
id: traceId
|
|
5004
5064
|
}), {
|
|
5005
5065
|
F: __dxlog_file17,
|
|
5006
|
-
L:
|
|
5066
|
+
L: 344,
|
|
5007
5067
|
S: this,
|
|
5008
5068
|
C: (f, a) => f(...a)
|
|
5009
5069
|
});
|
|
5010
5070
|
log16("resetting...", void 0, {
|
|
5011
5071
|
F: __dxlog_file17,
|
|
5012
|
-
L:
|
|
5072
|
+
L: 346,
|
|
5013
5073
|
S: this,
|
|
5014
5074
|
C: (f, a) => f(...a)
|
|
5015
5075
|
});
|
|
@@ -5017,7 +5077,7 @@ var ClientServicesHost = class ClientServicesHost2 {
|
|
|
5017
5077
|
await this._storage.reset();
|
|
5018
5078
|
log16("reset", void 0, {
|
|
5019
5079
|
F: __dxlog_file17,
|
|
5020
|
-
L:
|
|
5080
|
+
L: 349,
|
|
5021
5081
|
S: this,
|
|
5022
5082
|
C: (f, a) => f(...a)
|
|
5023
5083
|
});
|
|
@@ -5025,7 +5085,7 @@ var ClientServicesHost = class ClientServicesHost2 {
|
|
|
5025
5085
|
id: traceId
|
|
5026
5086
|
}), {
|
|
5027
5087
|
F: __dxlog_file17,
|
|
5028
|
-
L:
|
|
5088
|
+
L: 350,
|
|
5029
5089
|
S: this,
|
|
5030
5090
|
C: (f, a) => f(...a)
|
|
5031
5091
|
});
|
|
@@ -5035,7 +5095,9 @@ var ClientServicesHost = class ClientServicesHost2 {
|
|
|
5035
5095
|
const identity = await this._serviceContext.createIdentity(params);
|
|
5036
5096
|
await this._serviceContext.initialized.wait();
|
|
5037
5097
|
const space = await this._serviceContext.dataSpaceManager.createSpace();
|
|
5038
|
-
const obj = new Properties(
|
|
5098
|
+
const obj = new Properties(void 0, {
|
|
5099
|
+
useAutomergeBackend: false
|
|
5100
|
+
});
|
|
5039
5101
|
obj[defaultKey] = identity.identityKey.toHex();
|
|
5040
5102
|
await this._serviceRegistry.services.DataService.write({
|
|
5041
5103
|
spaceKey: space.key,
|
|
@@ -5070,6 +5132,7 @@ ClientServicesHost = _ts_decorate8([
|
|
|
5070
5132
|
], ClientServicesHost);
|
|
5071
5133
|
|
|
5072
5134
|
export {
|
|
5135
|
+
Buffer,
|
|
5073
5136
|
subscribeToFeeds,
|
|
5074
5137
|
subscribeToFeedBlocks,
|
|
5075
5138
|
subscribeToNetworkStatus,
|
|
@@ -5102,4 +5165,4 @@ export {
|
|
|
5102
5165
|
createDefaultModelFactory,
|
|
5103
5166
|
ClientServicesHost
|
|
5104
5167
|
};
|
|
5105
|
-
//# sourceMappingURL=chunk-
|
|
5168
|
+
//# sourceMappingURL=chunk-MPATL7UM.mjs.map
|