@dxos/client-services 0.8.4-main.5ea62a8 → 0.8.4-main.66e292d
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-JBVOLD57.mjs → chunk-PWKWJATU.mjs} +899 -1209
- package/dist/lib/browser/chunk-PWKWJATU.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +110 -135
- package/dist/lib/browser/index.mjs.map +2 -2
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/testing/index.mjs +37 -66
- package/dist/lib/browser/testing/index.mjs.map +2 -2
- package/dist/lib/node-esm/{chunk-AADRC6MD.mjs → chunk-7NQQ5F2Q.mjs} +900 -1210
- package/dist/lib/node-esm/chunk-7NQQ5F2Q.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +110 -135
- package/dist/lib/node-esm/index.mjs.map +2 -2
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/testing/index.mjs +37 -66
- package/dist/lib/node-esm/testing/index.mjs.map +2 -2
- package/dist/types/src/packlets/agents/edge-agent-service.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/device-invitation-protocol.d.ts +2 -2
- package/dist/types/src/packlets/invitations/device-invitation-protocol.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/invitation-guest-extenstion.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/invitation-host-extension.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/invitation-protocol.d.ts +2 -3
- package/dist/types/src/packlets/invitations/invitation-protocol.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/space-invitation-protocol.d.ts +2 -2
- package/dist/types/src/packlets/invitations/space-invitation-protocol.d.ts.map +1 -1
- package/dist/types/src/packlets/services/service-host.d.ts.map +1 -1
- package/dist/types/src/packlets/space-export/space-archive-writer.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/spaces-service.d.ts.map +1 -1
- package/dist/types/src/version.d.ts +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +39 -39
- package/src/packlets/agents/edge-agent-service.ts +11 -1
- package/src/packlets/devices/devices-service.ts +1 -1
- package/src/packlets/identity/identity.test.ts +4 -4
- package/src/packlets/invitations/device-invitation-protocol.ts +3 -3
- package/src/packlets/invitations/invitation-guest-extenstion.ts +6 -4
- package/src/packlets/invitations/invitation-host-extension.ts +6 -4
- package/src/packlets/invitations/invitation-protocol.ts +2 -3
- package/src/packlets/invitations/invitations-handler.ts +1 -1
- package/src/packlets/invitations/space-invitation-protocol.ts +7 -13
- package/src/packlets/logging/logging-service.ts +1 -1
- package/src/packlets/services/service-host.ts +6 -0
- package/src/packlets/space-export/space-archive-reader.ts +2 -2
- package/src/packlets/space-export/space-archive-writer.ts +4 -3
- package/src/packlets/spaces/data-space-manager.ts +28 -8
- package/src/packlets/spaces/data-space.ts +1 -1
- package/src/packlets/spaces/edge-feed-replicator.test.ts +1 -1
- package/src/packlets/spaces/edge-feed-replicator.ts +1 -1
- package/src/packlets/spaces/notarization-plugin.ts +2 -2
- package/src/packlets/spaces/spaces-service.ts +11 -8
- package/src/packlets/storage/storage.ts +4 -4
- package/src/version.ts +1 -1
- package/dist/lib/browser/chunk-JBVOLD57.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-AADRC6MD.mjs.map +0 -7
|
@@ -274,25 +274,14 @@ var subscribeToMetadata = ({ context }) => new Stream5(({ next, ctx }) => {
|
|
|
274
274
|
});
|
|
275
275
|
|
|
276
276
|
// src/packlets/devtools/devtools.ts
|
|
277
|
-
function _define_property(obj, key, value) {
|
|
278
|
-
if (key in obj) {
|
|
279
|
-
Object.defineProperty(obj, key, {
|
|
280
|
-
value,
|
|
281
|
-
enumerable: true,
|
|
282
|
-
configurable: true,
|
|
283
|
-
writable: true
|
|
284
|
-
});
|
|
285
|
-
} else {
|
|
286
|
-
obj[key] = value;
|
|
287
|
-
}
|
|
288
|
-
return obj;
|
|
289
|
-
}
|
|
290
277
|
var DevtoolsHostEvents = class {
|
|
291
|
-
|
|
292
|
-
_define_property(this, "ready", new AsyncEvent());
|
|
293
|
-
}
|
|
278
|
+
ready = new AsyncEvent();
|
|
294
279
|
};
|
|
295
280
|
var DevtoolsServiceImpl = class {
|
|
281
|
+
params;
|
|
282
|
+
constructor(params) {
|
|
283
|
+
this.params = params;
|
|
284
|
+
}
|
|
296
285
|
events(_request) {
|
|
297
286
|
return new Stream6(({ next }) => {
|
|
298
287
|
this.params.events.ready.on(() => {
|
|
@@ -395,10 +384,6 @@ var DevtoolsServiceImpl = class {
|
|
|
395
384
|
context: this.params.context
|
|
396
385
|
});
|
|
397
386
|
}
|
|
398
|
-
constructor(params) {
|
|
399
|
-
_define_property(this, "params", void 0);
|
|
400
|
-
this.params = params;
|
|
401
|
-
}
|
|
402
387
|
};
|
|
403
388
|
|
|
404
389
|
// src/packlets/diagnostics/diagnostics.ts
|
|
@@ -411,7 +396,7 @@ import { SpaceMember } from "@dxos/protocols/proto/dxos/client/services";
|
|
|
411
396
|
import { TRACE_PROCESSOR } from "@dxos/tracing";
|
|
412
397
|
|
|
413
398
|
// src/version.ts
|
|
414
|
-
var DXOS_VERSION = "0.8.4-main.
|
|
399
|
+
var DXOS_VERSION = "0.8.4-main.66e292d";
|
|
415
400
|
|
|
416
401
|
// src/packlets/services/platform.ts
|
|
417
402
|
import { Platform } from "@dxos/protocols/proto/dxos/client/services";
|
|
@@ -657,21 +642,9 @@ import { ConfigResource } from "@dxos/config";
|
|
|
657
642
|
import { GetDiagnosticsRequest } from "@dxos/protocols/proto/dxos/client/services";
|
|
658
643
|
import { TRACE_PROCESSOR as TRACE_PROCESSOR2 } from "@dxos/tracing";
|
|
659
644
|
import { isNonNullable, jsonKeyReplacer } from "@dxos/util";
|
|
660
|
-
function _define_property2(obj, key, value) {
|
|
661
|
-
if (key in obj) {
|
|
662
|
-
Object.defineProperty(obj, key, {
|
|
663
|
-
value,
|
|
664
|
-
enumerable: true,
|
|
665
|
-
configurable: true,
|
|
666
|
-
writable: true
|
|
667
|
-
});
|
|
668
|
-
} else {
|
|
669
|
-
obj[key] = value;
|
|
670
|
-
}
|
|
671
|
-
return obj;
|
|
672
|
-
}
|
|
673
645
|
var GET_DIAGNOSTICS_RPC_TIMEOUT = 1e4;
|
|
674
646
|
var DiagnosticsCollector = class {
|
|
647
|
+
static broadcastSender = createCollectDiagnosticsBroadcastSender();
|
|
675
648
|
static async collect(config = findConfigs(), services = findSystemServiceProvider(), options = {}) {
|
|
676
649
|
const serviceDiagnostics = await services?.services?.SystemService?.getDiagnostics({
|
|
677
650
|
keys: options.humanize ? GetDiagnosticsRequest.KEY_OPTION.HUMANIZE : options.truncate ? GetDiagnosticsRequest.KEY_OPTION.TRUNCATE : void 0
|
|
@@ -692,7 +665,6 @@ var DiagnosticsCollector = class {
|
|
|
692
665
|
return JSON.parse(JSON.stringify(diagnostics, jsonKeyReplacer(options)));
|
|
693
666
|
}
|
|
694
667
|
};
|
|
695
|
-
_define_property2(DiagnosticsCollector, "broadcastSender", createCollectDiagnosticsBroadcastSender());
|
|
696
668
|
var findSystemServiceProvider = () => {
|
|
697
669
|
const serviceProviders = TRACE_PROCESSOR2.findResourcesByAnnotation(ClientServicesProviderResource);
|
|
698
670
|
const providerResource = serviceProviders.find((r) => r.instance.deref()?.services?.SystemService != null);
|
|
@@ -709,19 +681,6 @@ import { Context as Context2 } from "@dxos/context";
|
|
|
709
681
|
import { verifyCredential } from "@dxos/credentials";
|
|
710
682
|
import { log as log3 } from "@dxos/log";
|
|
711
683
|
import { schema } from "@dxos/protocols/proto";
|
|
712
|
-
function _define_property3(obj, key, value) {
|
|
713
|
-
if (key in obj) {
|
|
714
|
-
Object.defineProperty(obj, key, {
|
|
715
|
-
value,
|
|
716
|
-
enumerable: true,
|
|
717
|
-
configurable: true,
|
|
718
|
-
writable: true
|
|
719
|
-
});
|
|
720
|
-
} else {
|
|
721
|
-
obj[key] = value;
|
|
722
|
-
}
|
|
723
|
-
return obj;
|
|
724
|
-
}
|
|
725
684
|
var __dxlog_file5 = "/__w/dxos/dxos/packages/sdk/client-services/src/packlets/identity/authenticator.ts";
|
|
726
685
|
var Credential = schema.getCodecForType("dxos.halo.credentials.Credential");
|
|
727
686
|
var createAuthProvider = (signer) => async (nonce) => {
|
|
@@ -735,6 +694,14 @@ var createAuthProvider = (signer) => async (nonce) => {
|
|
|
735
694
|
return Credential.encode(credential);
|
|
736
695
|
};
|
|
737
696
|
var TrustedKeySetAuthVerifier = class {
|
|
697
|
+
_params;
|
|
698
|
+
_ctx = new Context2(void 0, {
|
|
699
|
+
F: __dxlog_file5,
|
|
700
|
+
L: 45
|
|
701
|
+
});
|
|
702
|
+
constructor(_params) {
|
|
703
|
+
this._params = _params;
|
|
704
|
+
}
|
|
738
705
|
async close() {
|
|
739
706
|
await this._ctx.dispose();
|
|
740
707
|
}
|
|
@@ -828,15 +795,6 @@ var TrustedKeySetAuthVerifier = class {
|
|
|
828
795
|
const deviceSet = this._params.trustedKeysProvider();
|
|
829
796
|
return deviceSet.has(deviceKey);
|
|
830
797
|
}
|
|
831
|
-
constructor(_params) {
|
|
832
|
-
_define_property3(this, "_params", void 0);
|
|
833
|
-
_define_property3(this, "_ctx", void 0);
|
|
834
|
-
this._params = _params;
|
|
835
|
-
this._ctx = new Context2(void 0, {
|
|
836
|
-
F: __dxlog_file5,
|
|
837
|
-
L: 45
|
|
838
|
-
});
|
|
839
|
-
}
|
|
840
798
|
};
|
|
841
799
|
|
|
842
800
|
// src/packlets/spaces/edge-feed-replicator.ts
|
|
@@ -852,19 +810,6 @@ import { buf } from "@dxos/protocols/buf";
|
|
|
852
810
|
import { MessageSchema as RouterMessageSchema } from "@dxos/protocols/buf/dxos/edge/messenger_pb";
|
|
853
811
|
import { EdgeStatus } from "@dxos/protocols/proto/dxos/client/services";
|
|
854
812
|
import { ComplexMap as ComplexMap2, arrayToBuffer, bufferToArray, defaultMap, rangeFromTo } from "@dxos/util";
|
|
855
|
-
function _define_property4(obj, key, value) {
|
|
856
|
-
if (key in obj) {
|
|
857
|
-
Object.defineProperty(obj, key, {
|
|
858
|
-
value,
|
|
859
|
-
enumerable: true,
|
|
860
|
-
configurable: true,
|
|
861
|
-
writable: true
|
|
862
|
-
});
|
|
863
|
-
} else {
|
|
864
|
-
obj[key] = value;
|
|
865
|
-
}
|
|
866
|
-
return obj;
|
|
867
|
-
}
|
|
868
813
|
function _ts_decorate(decorators, target, key, desc) {
|
|
869
814
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
870
815
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -938,6 +883,24 @@ function _ts_dispose_resources(env) {
|
|
|
938
883
|
}
|
|
939
884
|
var __dxlog_file6 = "/__w/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/edge-feed-replicator.ts";
|
|
940
885
|
var EdgeFeedReplicator = class extends Resource {
|
|
886
|
+
_messenger;
|
|
887
|
+
_spaceId;
|
|
888
|
+
_feeds = new ComplexMap2(PublicKey3.hash);
|
|
889
|
+
_connectionCtx = void 0;
|
|
890
|
+
_connected = false;
|
|
891
|
+
/**
|
|
892
|
+
* Feed length at service.
|
|
893
|
+
*/
|
|
894
|
+
_remoteLength = new ComplexMap2(PublicKey3.hash);
|
|
895
|
+
/**
|
|
896
|
+
* Protects against concurrent pushes so that remote length is updated consistently.
|
|
897
|
+
*/
|
|
898
|
+
_pushMutex = new ComplexMap2(PublicKey3.hash);
|
|
899
|
+
constructor({ messenger, spaceId }) {
|
|
900
|
+
super();
|
|
901
|
+
this._messenger = messenger;
|
|
902
|
+
this._spaceId = spaceId;
|
|
903
|
+
}
|
|
941
904
|
async _open() {
|
|
942
905
|
log4("open", void 0, {
|
|
943
906
|
F: __dxlog_file6,
|
|
@@ -985,7 +948,7 @@ var EdgeFeedReplicator = class extends Resource {
|
|
|
985
948
|
}
|
|
986
949
|
async _handleReconnect() {
|
|
987
950
|
await this._resetConnection();
|
|
988
|
-
if (this._messenger.status === EdgeStatus.CONNECTED) {
|
|
951
|
+
if (this._messenger.status.state === EdgeStatus.ConnectionState.CONNECTED) {
|
|
989
952
|
this._startReplication();
|
|
990
953
|
}
|
|
991
954
|
}
|
|
@@ -1334,17 +1297,6 @@ var EdgeFeedReplicator = class extends Resource {
|
|
|
1334
1297
|
});
|
|
1335
1298
|
return connectionCtx;
|
|
1336
1299
|
}
|
|
1337
|
-
constructor({ messenger, spaceId }) {
|
|
1338
|
-
super(), _define_property4(this, "_messenger", void 0), _define_property4(this, "_spaceId", void 0), _define_property4(this, "_feeds", new ComplexMap2(PublicKey3.hash)), _define_property4(this, "_connectionCtx", void 0), _define_property4(this, "_connected", false), /**
|
|
1339
|
-
* Feed length at service.
|
|
1340
|
-
*/
|
|
1341
|
-
_define_property4(this, "_remoteLength", new ComplexMap2(PublicKey3.hash)), /**
|
|
1342
|
-
* Protects against concurrent pushes so that remote length is updated consistently.
|
|
1343
|
-
*/
|
|
1344
|
-
_define_property4(this, "_pushMutex", new ComplexMap2(PublicKey3.hash));
|
|
1345
|
-
this._messenger = messenger;
|
|
1346
|
-
this._spaceId = spaceId;
|
|
1347
|
-
}
|
|
1348
1300
|
};
|
|
1349
1301
|
_ts_decorate([
|
|
1350
1302
|
logInfo
|
|
@@ -1394,15 +1346,16 @@ import { ComplexSet } from "@dxos/util";
|
|
|
1394
1346
|
// src/packlets/spaces/data-space-manager.ts
|
|
1395
1347
|
import { interpretAsDocumentId } from "@automerge/automerge-repo";
|
|
1396
1348
|
import { Event as Event2, synchronized, trackLeaks } from "@dxos/async";
|
|
1397
|
-
import {
|
|
1349
|
+
import { SpaceProperties } from "@dxos/client-protocol";
|
|
1398
1350
|
import { Context as Context4, LifecycleState, Resource as Resource2, cancelWithContext } from "@dxos/context";
|
|
1399
1351
|
import { createAdmissionCredentials, getCredentialAssertion } from "@dxos/credentials";
|
|
1352
|
+
import { Type } from "@dxos/echo";
|
|
1353
|
+
import { getTypeReference } from "@dxos/echo/internal";
|
|
1400
1354
|
import { AuthStatus, CredentialServerExtension, DatabaseRoot, FIND_PARAMS, findInlineObjectOfType } from "@dxos/echo-pipeline";
|
|
1401
1355
|
import { SpaceDocVersion, createIdFromSpaceKey, encodeReference } from "@dxos/echo-protocol";
|
|
1402
|
-
import { ObjectId, getTypeReference } from "@dxos/echo-schema";
|
|
1403
1356
|
import { writeMessages } from "@dxos/feed-store";
|
|
1404
1357
|
import { assertArgument, assertState, failedInvariant, invariant as invariant3 } from "@dxos/invariant";
|
|
1405
|
-
import { PublicKey as PublicKey4 } from "@dxos/keys";
|
|
1358
|
+
import { ObjectId, PublicKey as PublicKey4 } from "@dxos/keys";
|
|
1406
1359
|
import { log as log5 } from "@dxos/log";
|
|
1407
1360
|
import { AlreadyJoinedError, trace as Trace } from "@dxos/protocols";
|
|
1408
1361
|
import { Invitation, SpaceState } from "@dxos/protocols/proto/dxos/client/services";
|
|
@@ -1483,19 +1436,6 @@ var spaceGenesis = async (keyring, signingContext, space, automergeRoot) => {
|
|
|
1483
1436
|
};
|
|
1484
1437
|
|
|
1485
1438
|
// src/packlets/spaces/data-space-manager.ts
|
|
1486
|
-
function _define_property5(obj, key, value) {
|
|
1487
|
-
if (key in obj) {
|
|
1488
|
-
Object.defineProperty(obj, key, {
|
|
1489
|
-
value,
|
|
1490
|
-
enumerable: true,
|
|
1491
|
-
configurable: true,
|
|
1492
|
-
writable: true
|
|
1493
|
-
});
|
|
1494
|
-
} else {
|
|
1495
|
-
obj[key] = value;
|
|
1496
|
-
}
|
|
1497
|
-
return obj;
|
|
1498
|
-
}
|
|
1499
1439
|
function _ts_decorate2(decorators, target, key, desc) {
|
|
1500
1440
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1501
1441
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -1507,6 +1447,61 @@ var PRESENCE_ANNOUNCE_INTERVAL = 1e4;
|
|
|
1507
1447
|
var PRESENCE_OFFLINE_TIMEOUT = 2e4;
|
|
1508
1448
|
var DEFAULT_SPACE_KEY = "__DEFAULT__";
|
|
1509
1449
|
var DataSpaceManager = class extends Resource2 {
|
|
1450
|
+
updated = new Event2();
|
|
1451
|
+
_spaces = new ComplexMap3(PublicKey4.hash);
|
|
1452
|
+
_instanceId = PublicKey4.random().toHex();
|
|
1453
|
+
_spaceManager;
|
|
1454
|
+
_metadataStore;
|
|
1455
|
+
_keyring;
|
|
1456
|
+
_signingContext;
|
|
1457
|
+
_feedStore;
|
|
1458
|
+
_echoHost;
|
|
1459
|
+
_invitationsManager;
|
|
1460
|
+
_edgeConnection = void 0;
|
|
1461
|
+
_edgeHttpClient = void 0;
|
|
1462
|
+
_edgeFeatures = void 0;
|
|
1463
|
+
_meshReplicator = void 0;
|
|
1464
|
+
_echoEdgeReplicator = void 0;
|
|
1465
|
+
_runtimeParams = void 0;
|
|
1466
|
+
constructor(params) {
|
|
1467
|
+
super();
|
|
1468
|
+
this._spaceManager = params.spaceManager;
|
|
1469
|
+
this._metadataStore = params.metadataStore;
|
|
1470
|
+
this._keyring = params.keyring;
|
|
1471
|
+
this._signingContext = params.signingContext;
|
|
1472
|
+
this._feedStore = params.feedStore;
|
|
1473
|
+
this._echoHost = params.echoHost;
|
|
1474
|
+
this._meshReplicator = params.meshReplicator;
|
|
1475
|
+
this._invitationsManager = params.invitationsManager;
|
|
1476
|
+
this._edgeConnection = params.edgeConnection;
|
|
1477
|
+
this._edgeFeatures = params.edgeFeatures;
|
|
1478
|
+
this._echoEdgeReplicator = params.echoEdgeReplicator;
|
|
1479
|
+
this._edgeHttpClient = params.edgeHttpClient;
|
|
1480
|
+
this._runtimeParams = params.runtimeParams;
|
|
1481
|
+
trace.diagnostic({
|
|
1482
|
+
id: "spaces",
|
|
1483
|
+
name: "Spaces",
|
|
1484
|
+
fetch: async () => {
|
|
1485
|
+
return Promise.all(Array.from(this._spaces.values()).map(async (space) => {
|
|
1486
|
+
const rootUrl = space.automergeSpaceState.rootUrl;
|
|
1487
|
+
const rootHandle = rootUrl ? await this._echoHost.automergeRepo.find(rootUrl, FIND_PARAMS) : void 0;
|
|
1488
|
+
await rootHandle?.whenReady();
|
|
1489
|
+
const rootDoc = rootHandle?.doc();
|
|
1490
|
+
const properties = rootDoc && findInlineObjectOfType(rootDoc, Type.getTypename(SpaceProperties));
|
|
1491
|
+
return {
|
|
1492
|
+
key: space.key.toHex(),
|
|
1493
|
+
state: SpaceState[space.state],
|
|
1494
|
+
name: properties?.[1].data.name ?? null,
|
|
1495
|
+
inlineObjects: rootDoc ? Object.keys(rootDoc.objects ?? {}).length : null,
|
|
1496
|
+
linkedObjects: rootDoc ? Object.keys(rootDoc.links ?? {}).length : null,
|
|
1497
|
+
credentials: space.inner.spaceState.credentials.length,
|
|
1498
|
+
members: space.inner.spaceState.members.size,
|
|
1499
|
+
rootUrl
|
|
1500
|
+
};
|
|
1501
|
+
}));
|
|
1502
|
+
}
|
|
1503
|
+
});
|
|
1504
|
+
}
|
|
1510
1505
|
// TODO(burdon): Remove.
|
|
1511
1506
|
get spaces() {
|
|
1512
1507
|
return this._spaces;
|
|
@@ -1519,7 +1514,7 @@ var DataSpaceManager = class extends Resource2 {
|
|
|
1519
1514
|
async _open() {
|
|
1520
1515
|
log5("open", void 0, {
|
|
1521
1516
|
F: __dxlog_file7,
|
|
1522
|
-
L:
|
|
1517
|
+
L: 217,
|
|
1523
1518
|
S: this,
|
|
1524
1519
|
C: (f, a) => f(...a)
|
|
1525
1520
|
});
|
|
@@ -1527,7 +1522,7 @@ var DataSpaceManager = class extends Resource2 {
|
|
|
1527
1522
|
id: this._instanceId
|
|
1528
1523
|
}), {
|
|
1529
1524
|
F: __dxlog_file7,
|
|
1530
|
-
L:
|
|
1525
|
+
L: 218,
|
|
1531
1526
|
S: this,
|
|
1532
1527
|
C: (f, a) => f(...a)
|
|
1533
1528
|
});
|
|
@@ -1535,7 +1530,7 @@ var DataSpaceManager = class extends Resource2 {
|
|
|
1535
1530
|
spaces: this._metadataStore.spaces.length
|
|
1536
1531
|
}, {
|
|
1537
1532
|
F: __dxlog_file7,
|
|
1538
|
-
L:
|
|
1533
|
+
L: 219,
|
|
1539
1534
|
S: this,
|
|
1540
1535
|
C: (f, a) => f(...a)
|
|
1541
1536
|
});
|
|
@@ -1545,7 +1540,7 @@ var DataSpaceManager = class extends Resource2 {
|
|
|
1545
1540
|
spaceMetadata
|
|
1546
1541
|
}, {
|
|
1547
1542
|
F: __dxlog_file7,
|
|
1548
|
-
L:
|
|
1543
|
+
L: 223,
|
|
1549
1544
|
S: this,
|
|
1550
1545
|
C: (f, a) => f(...a)
|
|
1551
1546
|
});
|
|
@@ -1556,7 +1551,7 @@ var DataSpaceManager = class extends Resource2 {
|
|
|
1556
1551
|
err
|
|
1557
1552
|
}, {
|
|
1558
1553
|
F: __dxlog_file7,
|
|
1559
|
-
L:
|
|
1554
|
+
L: 226,
|
|
1560
1555
|
S: this,
|
|
1561
1556
|
C: (f, a) => f(...a)
|
|
1562
1557
|
});
|
|
@@ -1567,7 +1562,7 @@ var DataSpaceManager = class extends Resource2 {
|
|
|
1567
1562
|
id: this._instanceId
|
|
1568
1563
|
}), {
|
|
1569
1564
|
F: __dxlog_file7,
|
|
1570
|
-
L:
|
|
1565
|
+
L: 232,
|
|
1571
1566
|
S: this,
|
|
1572
1567
|
C: (f, a) => f(...a)
|
|
1573
1568
|
});
|
|
@@ -1575,7 +1570,7 @@ var DataSpaceManager = class extends Resource2 {
|
|
|
1575
1570
|
async _close() {
|
|
1576
1571
|
log5("close", void 0, {
|
|
1577
1572
|
F: __dxlog_file7,
|
|
1578
|
-
L:
|
|
1573
|
+
L: 237,
|
|
1579
1574
|
S: this,
|
|
1580
1575
|
C: (f, a) => f(...a)
|
|
1581
1576
|
});
|
|
@@ -1588,7 +1583,7 @@ var DataSpaceManager = class extends Resource2 {
|
|
|
1588
1583
|
* Creates a new space writing the genesis credentials to the control feed.
|
|
1589
1584
|
*/
|
|
1590
1585
|
async createSpace(options = {}) {
|
|
1591
|
-
assertArgument(!!options.rootUrl === !!options.documents, "root url must be required when providing documents");
|
|
1586
|
+
assertArgument(!!options.rootUrl === !!options.documents, "options", "root url must be required when providing documents");
|
|
1592
1587
|
assertState(this._lifecycleState === LifecycleState.OPEN, "Not open.");
|
|
1593
1588
|
const spaceKey = await this._keyring.createKey();
|
|
1594
1589
|
const controlFeedKey = await this._keyring.createKey();
|
|
@@ -1606,7 +1601,7 @@ var DataSpaceManager = class extends Resource2 {
|
|
|
1606
1601
|
spaceKey
|
|
1607
1602
|
}, {
|
|
1608
1603
|
F: __dxlog_file7,
|
|
1609
|
-
L:
|
|
1604
|
+
L: 270,
|
|
1610
1605
|
S: this,
|
|
1611
1606
|
C: (f, a) => f(...a)
|
|
1612
1607
|
});
|
|
@@ -1614,7 +1609,7 @@ var DataSpaceManager = class extends Resource2 {
|
|
|
1614
1609
|
if (options.documents) {
|
|
1615
1610
|
invariant3(Object.keys(options.documents).every((documentId) => /^[a-zA-Z0-9]+$/.test(documentId)), "Invalid document IDs", {
|
|
1616
1611
|
F: __dxlog_file7,
|
|
1617
|
-
L:
|
|
1612
|
+
L: 275,
|
|
1618
1613
|
S: this,
|
|
1619
1614
|
A: [
|
|
1620
1615
|
"Object.keys(options.documents).every((documentId) => /^[a-zA-Z0-9]+$/.test(documentId))",
|
|
@@ -1626,13 +1621,18 @@ var DataSpaceManager = class extends Resource2 {
|
|
|
1626
1621
|
documentId
|
|
1627
1622
|
}, {
|
|
1628
1623
|
F: __dxlog_file7,
|
|
1629
|
-
L:
|
|
1624
|
+
L: 282,
|
|
1630
1625
|
S: this,
|
|
1631
1626
|
C: (f, a) => f(...a)
|
|
1632
1627
|
});
|
|
1633
1628
|
const newDoc = await this._echoHost.createDoc(data, {
|
|
1634
1629
|
preserveHistory: true
|
|
1635
1630
|
});
|
|
1631
|
+
if (newDoc.doc().access !== void 0 && newDoc.doc().access.spaceKey !== spaceKey.toHex()) {
|
|
1632
|
+
newDoc.change((doc) => {
|
|
1633
|
+
doc.access.spaceKey = spaceKey.toHex();
|
|
1634
|
+
});
|
|
1635
|
+
}
|
|
1636
1636
|
documentIdMapping[documentId] = newDoc.documentId;
|
|
1637
1637
|
}));
|
|
1638
1638
|
}
|
|
@@ -1640,7 +1640,7 @@ var DataSpaceManager = class extends Resource2 {
|
|
|
1640
1640
|
spaceKey
|
|
1641
1641
|
}, {
|
|
1642
1642
|
F: __dxlog_file7,
|
|
1643
|
-
L:
|
|
1643
|
+
L: 300,
|
|
1644
1644
|
S: this,
|
|
1645
1645
|
C: (f, a) => f(...a)
|
|
1646
1646
|
});
|
|
@@ -1649,18 +1649,19 @@ var DataSpaceManager = class extends Resource2 {
|
|
|
1649
1649
|
const newRootDocId = documentIdMapping[interpretAsDocumentId(options.rootUrl)] ?? failedInvariant();
|
|
1650
1650
|
const rootDocHandle = await this._echoHost.loadDoc(Context4.default(void 0, {
|
|
1651
1651
|
F: __dxlog_file7,
|
|
1652
|
-
L:
|
|
1652
|
+
L: 305
|
|
1653
1653
|
}), newRootDocId);
|
|
1654
1654
|
DatabaseRoot.mapLinks(rootDocHandle, documentIdMapping);
|
|
1655
1655
|
root = await this._echoHost.openSpaceRoot(spaceId, `automerge:${newRootDocId}`);
|
|
1656
1656
|
} else {
|
|
1657
1657
|
root = await this._echoHost.createSpaceRoot(spaceKey);
|
|
1658
1658
|
}
|
|
1659
|
+
await this._echoHost.flush();
|
|
1659
1660
|
log5("constructing space...", {
|
|
1660
1661
|
spaceKey
|
|
1661
1662
|
}, {
|
|
1662
1663
|
F: __dxlog_file7,
|
|
1663
|
-
L:
|
|
1664
|
+
L: 314,
|
|
1664
1665
|
S: this,
|
|
1665
1666
|
C: (f, a) => f(...a)
|
|
1666
1667
|
});
|
|
@@ -1670,7 +1671,7 @@ var DataSpaceManager = class extends Resource2 {
|
|
|
1670
1671
|
spaceKey
|
|
1671
1672
|
}, {
|
|
1672
1673
|
F: __dxlog_file7,
|
|
1673
|
-
L:
|
|
1674
|
+
L: 319,
|
|
1674
1675
|
S: this,
|
|
1675
1676
|
C: (f, a) => f(...a)
|
|
1676
1677
|
});
|
|
@@ -1679,7 +1680,7 @@ var DataSpaceManager = class extends Resource2 {
|
|
|
1679
1680
|
const memberCredential = credentials[1];
|
|
1680
1681
|
invariant3(getCredentialAssertion(memberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
|
|
1681
1682
|
F: __dxlog_file7,
|
|
1682
|
-
L:
|
|
1683
|
+
L: 325,
|
|
1683
1684
|
S: this,
|
|
1684
1685
|
A: [
|
|
1685
1686
|
"getCredentialAssertion(memberCredential)['@type'] === 'dxos.halo.credentials.SpaceMember'",
|
|
@@ -1693,7 +1694,7 @@ var DataSpaceManager = class extends Resource2 {
|
|
|
1693
1694
|
spaceKey
|
|
1694
1695
|
}, {
|
|
1695
1696
|
F: __dxlog_file7,
|
|
1696
|
-
L:
|
|
1697
|
+
L: 330,
|
|
1697
1698
|
S: this,
|
|
1698
1699
|
C: (f, a) => f(...a)
|
|
1699
1700
|
});
|
|
@@ -1711,13 +1712,13 @@ var DataSpaceManager = class extends Resource2 {
|
|
|
1711
1712
|
spaceId: space.id
|
|
1712
1713
|
}, {
|
|
1713
1714
|
F: __dxlog_file7,
|
|
1714
|
-
L:
|
|
1715
|
+
L: 343,
|
|
1715
1716
|
S: this,
|
|
1716
1717
|
C: (f, a) => f(...a)
|
|
1717
1718
|
});
|
|
1718
1719
|
await space.databaseRoot.handle.whenReady();
|
|
1719
1720
|
}
|
|
1720
|
-
const [_, properties] = findInlineObjectOfType(space.databaseRoot.doc(),
|
|
1721
|
+
const [_, properties] = findInlineObjectOfType(space.databaseRoot.doc(), Type.getTypename(SpaceProperties)) ?? [];
|
|
1721
1722
|
return properties?.data?.[DEFAULT_SPACE_KEY] === this._signingContext.identityKey.toHex();
|
|
1722
1723
|
}
|
|
1723
1724
|
case SpaceDocVersion.LEGACY: {
|
|
@@ -1729,7 +1730,7 @@ var DataSpaceManager = class extends Resource2 {
|
|
|
1729
1730
|
spaceId: space.id
|
|
1730
1731
|
}, {
|
|
1731
1732
|
F: __dxlog_file7,
|
|
1732
|
-
L:
|
|
1733
|
+
L: 357,
|
|
1733
1734
|
S: this,
|
|
1734
1735
|
C: (f, a) => f(...a)
|
|
1735
1736
|
});
|
|
@@ -1741,7 +1742,7 @@ var DataSpaceManager = class extends Resource2 {
|
|
|
1741
1742
|
const document = await this._getSpaceRootDocument(space);
|
|
1742
1743
|
const properties = {
|
|
1743
1744
|
system: {
|
|
1744
|
-
type: encodeReference(getTypeReference(
|
|
1745
|
+
type: encodeReference(getTypeReference(SpaceProperties))
|
|
1745
1746
|
},
|
|
1746
1747
|
data: {
|
|
1747
1748
|
[DEFAULT_SPACE_KEY]: this._signingContext.identityKey.toHex()
|
|
@@ -1764,7 +1765,7 @@ var DataSpaceManager = class extends Resource2 {
|
|
|
1764
1765
|
const automergeIndex = space.automergeSpaceState.rootUrl;
|
|
1765
1766
|
invariant3(automergeIndex, void 0, {
|
|
1766
1767
|
F: __dxlog_file7,
|
|
1767
|
-
L:
|
|
1768
|
+
L: 390,
|
|
1768
1769
|
S: this,
|
|
1769
1770
|
A: [
|
|
1770
1771
|
"automergeIndex",
|
|
@@ -1781,13 +1782,13 @@ var DataSpaceManager = class extends Resource2 {
|
|
|
1781
1782
|
opts
|
|
1782
1783
|
}, {
|
|
1783
1784
|
F: __dxlog_file7,
|
|
1784
|
-
L:
|
|
1785
|
+
L: 399,
|
|
1785
1786
|
S: this,
|
|
1786
1787
|
C: (f, a) => f(...a)
|
|
1787
1788
|
});
|
|
1788
1789
|
invariant3(this._lifecycleState === LifecycleState.OPEN, "Not open.", {
|
|
1789
1790
|
F: __dxlog_file7,
|
|
1790
|
-
L:
|
|
1791
|
+
L: 400,
|
|
1791
1792
|
S: this,
|
|
1792
1793
|
A: [
|
|
1793
1794
|
"this._lifecycleState === LifecycleState.OPEN",
|
|
@@ -1796,7 +1797,7 @@ var DataSpaceManager = class extends Resource2 {
|
|
|
1796
1797
|
});
|
|
1797
1798
|
invariant3(!this._spaces.has(opts.spaceKey), "Space already exists.", {
|
|
1798
1799
|
F: __dxlog_file7,
|
|
1799
|
-
L:
|
|
1800
|
+
L: 401,
|
|
1800
1801
|
S: this,
|
|
1801
1802
|
A: [
|
|
1802
1803
|
"!this._spaces.has(opts.spaceKey)",
|
|
@@ -1820,7 +1821,7 @@ var DataSpaceManager = class extends Resource2 {
|
|
|
1820
1821
|
const space = this._spaceManager.spaces.get(options.spaceKey);
|
|
1821
1822
|
invariant3(space, void 0, {
|
|
1822
1823
|
F: __dxlog_file7,
|
|
1823
|
-
L:
|
|
1824
|
+
L: 421,
|
|
1824
1825
|
S: this,
|
|
1825
1826
|
A: [
|
|
1826
1827
|
"space",
|
|
@@ -1833,7 +1834,7 @@ var DataSpaceManager = class extends Resource2 {
|
|
|
1833
1834
|
const credentials = await createAdmissionCredentials(this._signingContext.credentialSigner, options.identityKey, space.key, space.genesisFeedKey, options.role, space.spaceState.membershipChainHeads, options.profile, options.delegationCredentialId);
|
|
1834
1835
|
invariant3(credentials[0].credential, void 0, {
|
|
1835
1836
|
F: __dxlog_file7,
|
|
1836
|
-
L:
|
|
1837
|
+
L: 440,
|
|
1837
1838
|
S: this,
|
|
1838
1839
|
A: [
|
|
1839
1840
|
"credentials[0].credential",
|
|
@@ -1843,7 +1844,7 @@ var DataSpaceManager = class extends Resource2 {
|
|
|
1843
1844
|
const spaceMemberCredential = credentials[0].credential.credential;
|
|
1844
1845
|
invariant3(getCredentialAssertion(spaceMemberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
|
|
1845
1846
|
F: __dxlog_file7,
|
|
1846
|
-
L:
|
|
1847
|
+
L: 442,
|
|
1847
1848
|
S: this,
|
|
1848
1849
|
A: [
|
|
1849
1850
|
"getCredentialAssertion(spaceMemberCredential)['@type'] === 'dxos.halo.credentials.SpaceMember'",
|
|
@@ -1881,7 +1882,7 @@ var DataSpaceManager = class extends Resource2 {
|
|
|
1881
1882
|
const space = this._spaces.get(spaceKey);
|
|
1882
1883
|
invariant3(space, "Space not found.", {
|
|
1883
1884
|
F: __dxlog_file7,
|
|
1884
|
-
L:
|
|
1885
|
+
L: 479,
|
|
1885
1886
|
S: this,
|
|
1886
1887
|
A: [
|
|
1887
1888
|
"space",
|
|
@@ -1906,7 +1907,7 @@ var DataSpaceManager = class extends Resource2 {
|
|
|
1906
1907
|
metadata
|
|
1907
1908
|
}, {
|
|
1908
1909
|
F: __dxlog_file7,
|
|
1909
|
-
L:
|
|
1910
|
+
L: 498,
|
|
1910
1911
|
S: this,
|
|
1911
1912
|
C: (f, a) => f(...a)
|
|
1912
1913
|
});
|
|
@@ -1950,7 +1951,7 @@ var DataSpaceManager = class extends Resource2 {
|
|
|
1950
1951
|
err
|
|
1951
1952
|
}, {
|
|
1952
1953
|
F: __dxlog_file7,
|
|
1953
|
-
L:
|
|
1954
|
+
L: 540,
|
|
1954
1955
|
S: this,
|
|
1955
1956
|
C: (f, a) => f(...a)
|
|
1956
1957
|
});
|
|
@@ -1960,7 +1961,7 @@ var DataSpaceManager = class extends Resource2 {
|
|
|
1960
1961
|
onAuthFailure: () => {
|
|
1961
1962
|
log5.warn("auth failure", void 0, {
|
|
1962
1963
|
F: __dxlog_file7,
|
|
1963
|
-
L:
|
|
1964
|
+
L: 545,
|
|
1964
1965
|
S: this,
|
|
1965
1966
|
C: (f, a) => f(...a)
|
|
1966
1967
|
});
|
|
@@ -1993,7 +1994,7 @@ var DataSpaceManager = class extends Resource2 {
|
|
|
1993
1994
|
space: space.key
|
|
1994
1995
|
}, {
|
|
1995
1996
|
F: __dxlog_file7,
|
|
1996
|
-
L:
|
|
1997
|
+
L: 572,
|
|
1997
1998
|
S: this,
|
|
1998
1999
|
C: (f, a) => f(...a)
|
|
1999
2000
|
});
|
|
@@ -2004,7 +2005,7 @@ var DataSpaceManager = class extends Resource2 {
|
|
|
2004
2005
|
open: this._lifecycleState === LifecycleState.OPEN
|
|
2005
2006
|
}, {
|
|
2006
2007
|
F: __dxlog_file7,
|
|
2007
|
-
L:
|
|
2008
|
+
L: 575,
|
|
2008
2009
|
S: this,
|
|
2009
2010
|
C: (f, a) => f(...a)
|
|
2010
2011
|
});
|
|
@@ -2023,7 +2024,7 @@ var DataSpaceManager = class extends Resource2 {
|
|
|
2023
2024
|
space: space.key
|
|
2024
2025
|
}, {
|
|
2025
2026
|
F: __dxlog_file7,
|
|
2026
|
-
L:
|
|
2027
|
+
L: 583,
|
|
2027
2028
|
S: this,
|
|
2028
2029
|
C: (f, a) => f(...a)
|
|
2029
2030
|
});
|
|
@@ -2044,7 +2045,7 @@ var DataSpaceManager = class extends Resource2 {
|
|
|
2044
2045
|
spaceId: dataSpace.id
|
|
2045
2046
|
}, {
|
|
2046
2047
|
F: __dxlog_file7,
|
|
2047
|
-
L:
|
|
2048
|
+
L: 597,
|
|
2048
2049
|
S: this,
|
|
2049
2050
|
C: (f, a) => f(...a)
|
|
2050
2051
|
});
|
|
@@ -2074,7 +2075,7 @@ var DataSpaceManager = class extends Resource2 {
|
|
|
2074
2075
|
space: space.key
|
|
2075
2076
|
}, {
|
|
2076
2077
|
F: __dxlog_file7,
|
|
2077
|
-
L:
|
|
2078
|
+
L: 624,
|
|
2078
2079
|
S: this,
|
|
2079
2080
|
C: (f, a) => f(...a)
|
|
2080
2081
|
});
|
|
@@ -2107,7 +2108,7 @@ var DataSpaceManager = class extends Resource2 {
|
|
|
2107
2108
|
closedSessions
|
|
2108
2109
|
}, {
|
|
2109
2110
|
F: __dxlog_file7,
|
|
2110
|
-
L:
|
|
2111
|
+
L: 650,
|
|
2111
2112
|
S: this,
|
|
2112
2113
|
C: (f, a) => f(...a)
|
|
2113
2114
|
});
|
|
@@ -2122,7 +2123,7 @@ var DataSpaceManager = class extends Resource2 {
|
|
|
2122
2123
|
peerId: peerState.peerId
|
|
2123
2124
|
}, {
|
|
2124
2125
|
F: __dxlog_file7,
|
|
2125
|
-
L:
|
|
2126
|
+
L: 664,
|
|
2126
2127
|
S: this,
|
|
2127
2128
|
C: (f, a) => f(...a)
|
|
2128
2129
|
});
|
|
@@ -2165,45 +2166,6 @@ var DataSpaceManager = class extends Resource2 {
|
|
|
2165
2166
|
});
|
|
2166
2167
|
await Promise.all(tasks);
|
|
2167
2168
|
}
|
|
2168
|
-
constructor(params) {
|
|
2169
|
-
super(), _define_property5(this, "updated", new Event2()), _define_property5(this, "_spaces", new ComplexMap3(PublicKey4.hash)), _define_property5(this, "_instanceId", PublicKey4.random().toHex()), _define_property5(this, "_spaceManager", void 0), _define_property5(this, "_metadataStore", void 0), _define_property5(this, "_keyring", void 0), _define_property5(this, "_signingContext", void 0), _define_property5(this, "_feedStore", void 0), _define_property5(this, "_echoHost", void 0), _define_property5(this, "_invitationsManager", void 0), _define_property5(this, "_edgeConnection", void 0), _define_property5(this, "_edgeHttpClient", void 0), _define_property5(this, "_edgeFeatures", void 0), _define_property5(this, "_meshReplicator", void 0), _define_property5(this, "_echoEdgeReplicator", void 0), _define_property5(this, "_runtimeParams", void 0);
|
|
2170
|
-
this._spaceManager = params.spaceManager;
|
|
2171
|
-
this._metadataStore = params.metadataStore;
|
|
2172
|
-
this._keyring = params.keyring;
|
|
2173
|
-
this._signingContext = params.signingContext;
|
|
2174
|
-
this._feedStore = params.feedStore;
|
|
2175
|
-
this._echoHost = params.echoHost;
|
|
2176
|
-
this._meshReplicator = params.meshReplicator;
|
|
2177
|
-
this._invitationsManager = params.invitationsManager;
|
|
2178
|
-
this._edgeConnection = params.edgeConnection;
|
|
2179
|
-
this._edgeFeatures = params.edgeFeatures;
|
|
2180
|
-
this._echoEdgeReplicator = params.echoEdgeReplicator;
|
|
2181
|
-
this._edgeHttpClient = params.edgeHttpClient;
|
|
2182
|
-
this._runtimeParams = params.runtimeParams;
|
|
2183
|
-
trace.diagnostic({
|
|
2184
|
-
id: "spaces",
|
|
2185
|
-
name: "Spaces",
|
|
2186
|
-
fetch: async () => {
|
|
2187
|
-
return Promise.all(Array.from(this._spaces.values()).map(async (space) => {
|
|
2188
|
-
const rootUrl = space.automergeSpaceState.rootUrl;
|
|
2189
|
-
const rootHandle = rootUrl ? await this._echoHost.automergeRepo.find(rootUrl, FIND_PARAMS) : void 0;
|
|
2190
|
-
await rootHandle?.whenReady();
|
|
2191
|
-
const rootDoc = rootHandle?.doc();
|
|
2192
|
-
const properties = rootDoc && findInlineObjectOfType(rootDoc, TYPE_PROPERTIES);
|
|
2193
|
-
return {
|
|
2194
|
-
key: space.key.toHex(),
|
|
2195
|
-
state: SpaceState[space.state],
|
|
2196
|
-
name: properties?.[1].data.name ?? null,
|
|
2197
|
-
inlineObjects: rootDoc ? Object.keys(rootDoc.objects ?? {}).length : null,
|
|
2198
|
-
linkedObjects: rootDoc ? Object.keys(rootDoc.links ?? {}).length : null,
|
|
2199
|
-
credentials: space.inner.spaceState.credentials.length,
|
|
2200
|
-
members: space.inner.spaceState.members.size,
|
|
2201
|
-
rootUrl
|
|
2202
|
-
};
|
|
2203
|
-
}));
|
|
2204
|
-
}
|
|
2205
|
-
});
|
|
2206
|
-
}
|
|
2207
2169
|
};
|
|
2208
2170
|
_ts_decorate2([
|
|
2209
2171
|
synchronized
|
|
@@ -2238,21 +2200,12 @@ import { trace as trace2 } from "@dxos/tracing";
|
|
|
2238
2200
|
import { Resource as Resource3 } from "@dxos/context";
|
|
2239
2201
|
import { assertArgument as assertArgument2, assertState as assertState2 } from "@dxos/invariant";
|
|
2240
2202
|
import { SpaceArchiveFileStructure, SpaceArchiveVersion } from "@dxos/protocols";
|
|
2241
|
-
function _define_property6(obj, key, value) {
|
|
2242
|
-
if (key in obj) {
|
|
2243
|
-
Object.defineProperty(obj, key, {
|
|
2244
|
-
value,
|
|
2245
|
-
enumerable: true,
|
|
2246
|
-
configurable: true,
|
|
2247
|
-
writable: true
|
|
2248
|
-
});
|
|
2249
|
-
} else {
|
|
2250
|
-
obj[key] = value;
|
|
2251
|
-
}
|
|
2252
|
-
return obj;
|
|
2253
|
-
}
|
|
2254
2203
|
var CURRENT_VERSION = SpaceArchiveVersion.V1;
|
|
2255
2204
|
var SpaceArchiveWriter = class extends Resource3 {
|
|
2205
|
+
_tar;
|
|
2206
|
+
_archive;
|
|
2207
|
+
_meta = void 0;
|
|
2208
|
+
_currentRootUrl = void 0;
|
|
2256
2209
|
async _open(ctx) {
|
|
2257
2210
|
this._tar = await import("@obsidize/tar-browserify");
|
|
2258
2211
|
}
|
|
@@ -2266,13 +2219,13 @@ var SpaceArchiveWriter = class extends Resource3 {
|
|
|
2266
2219
|
this._archive = new this._tar.Archive();
|
|
2267
2220
|
}
|
|
2268
2221
|
async setCurrentRootUrl(url) {
|
|
2269
|
-
assertArgument2(url.startsWith("automerge:"), "Invalid root URL");
|
|
2222
|
+
assertArgument2(url.startsWith("automerge:"), "url", "Invalid root URL");
|
|
2270
2223
|
assertState2(this._tar, "Not open");
|
|
2271
2224
|
assertState2(this._meta, "Not started");
|
|
2272
2225
|
this._currentRootUrl = url;
|
|
2273
2226
|
}
|
|
2274
2227
|
async writeDocument(documentId, data) {
|
|
2275
|
-
assertArgument2(!documentId.startsWith("automerge:"), "Invalid document ID");
|
|
2228
|
+
assertArgument2(!documentId.startsWith("automerge:"), "documentId", "Invalid document ID");
|
|
2276
2229
|
assertState2(this._archive, "Not open");
|
|
2277
2230
|
this._archive.addBinaryFile(`${SpaceArchiveFileStructure.documents}/${documentId}.bin`, data);
|
|
2278
2231
|
}
|
|
@@ -2292,13 +2245,11 @@ var SpaceArchiveWriter = class extends Resource3 {
|
|
|
2292
2245
|
this._archive.addTextFile(SpaceArchiveFileStructure.metadata, JSON.stringify(metadata));
|
|
2293
2246
|
const binary = this._archive.toUint8Array();
|
|
2294
2247
|
return {
|
|
2295
|
-
|
|
2248
|
+
// TODO(wittjosiah): Factor out file name construction.
|
|
2249
|
+
filename: `${(/* @__PURE__ */ new Date()).toISOString()}-${this._meta.spaceId}.tar`,
|
|
2296
2250
|
contents: binary
|
|
2297
2251
|
};
|
|
2298
2252
|
}
|
|
2299
|
-
constructor(...args) {
|
|
2300
|
-
super(...args), _define_property6(this, "_tar", void 0), _define_property6(this, "_archive", void 0), _define_property6(this, "_meta", void 0), _define_property6(this, "_currentRootUrl", void 0);
|
|
2301
|
-
}
|
|
2302
2253
|
};
|
|
2303
2254
|
|
|
2304
2255
|
// src/packlets/space-export/space-archive-reader.ts
|
|
@@ -2310,7 +2261,7 @@ var extractSpaceArchive = async (archive) => {
|
|
|
2310
2261
|
const { Archive } = await import("@obsidize/tar-browserify");
|
|
2311
2262
|
const { entries } = await Archive.extract(archive.contents);
|
|
2312
2263
|
const metadataEntry = entries.find((entry2) => entry2.fileName === SpaceArchiveFileStructure2.metadata);
|
|
2313
|
-
assertArgument3(metadataEntry, "Metadata entry not found");
|
|
2264
|
+
assertArgument3(metadataEntry, "metadataEntry", "Metadata entry not found");
|
|
2314
2265
|
const metadata = JSON.parse(metadataEntry.getContentAsText());
|
|
2315
2266
|
const documents = {};
|
|
2316
2267
|
for (const entry2 of entries.filter((entry3) => entry3.fileName.startsWith(`${SpaceArchiveFileStructure2.documents}/`))) {
|
|
@@ -2326,7 +2277,7 @@ var extractSpaceArchive = async (archive) => {
|
|
|
2326
2277
|
});
|
|
2327
2278
|
documents[documentId] = entry2.content ?? failedInvariant2();
|
|
2328
2279
|
}
|
|
2329
|
-
log6
|
|
2280
|
+
log6("extracted space archive", {
|
|
2330
2281
|
metadata,
|
|
2331
2282
|
documents
|
|
2332
2283
|
}, {
|
|
@@ -2342,19 +2293,6 @@ var extractSpaceArchive = async (archive) => {
|
|
|
2342
2293
|
};
|
|
2343
2294
|
|
|
2344
2295
|
// src/packlets/spaces/spaces-service.ts
|
|
2345
|
-
function _define_property7(obj, key, value) {
|
|
2346
|
-
if (key in obj) {
|
|
2347
|
-
Object.defineProperty(obj, key, {
|
|
2348
|
-
value,
|
|
2349
|
-
enumerable: true,
|
|
2350
|
-
configurable: true,
|
|
2351
|
-
writable: true
|
|
2352
|
-
});
|
|
2353
|
-
} else {
|
|
2354
|
-
obj[key] = value;
|
|
2355
|
-
}
|
|
2356
|
-
return obj;
|
|
2357
|
-
}
|
|
2358
2296
|
function _ts_add_disposable_resource2(env, value, async) {
|
|
2359
2297
|
if (value !== null && value !== void 0) {
|
|
2360
2298
|
if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected.");
|
|
@@ -2422,6 +2360,14 @@ function _ts_dispose_resources2(env) {
|
|
|
2422
2360
|
}
|
|
2423
2361
|
var __dxlog_file9 = "/__w/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/spaces-service.ts";
|
|
2424
2362
|
var SpacesServiceImpl = class {
|
|
2363
|
+
_identityManager;
|
|
2364
|
+
_spaceManager;
|
|
2365
|
+
_getDataSpaceManager;
|
|
2366
|
+
constructor(_identityManager, _spaceManager, _getDataSpaceManager) {
|
|
2367
|
+
this._identityManager = _identityManager;
|
|
2368
|
+
this._spaceManager = _spaceManager;
|
|
2369
|
+
this._getDataSpaceManager = _getDataSpaceManager;
|
|
2370
|
+
}
|
|
2425
2371
|
async createSpace() {
|
|
2426
2372
|
this._requireIdentity();
|
|
2427
2373
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
@@ -2441,7 +2387,9 @@ var SpacesServiceImpl = class {
|
|
|
2441
2387
|
await space.deactivate();
|
|
2442
2388
|
break;
|
|
2443
2389
|
default:
|
|
2444
|
-
throw new ApiError(
|
|
2390
|
+
throw new ApiError({
|
|
2391
|
+
message: "Invalid space state"
|
|
2392
|
+
});
|
|
2445
2393
|
}
|
|
2446
2394
|
}
|
|
2447
2395
|
if (edgeReplication !== void 0) {
|
|
@@ -2455,15 +2403,18 @@ var SpacesServiceImpl = class {
|
|
|
2455
2403
|
throw new SpaceNotFoundError(request.spaceKey);
|
|
2456
2404
|
}
|
|
2457
2405
|
if (!space.spaceState.hasMembershipManagementPermission(identity.identityKey)) {
|
|
2458
|
-
throw new AuthorizationError(
|
|
2459
|
-
|
|
2460
|
-
|
|
2406
|
+
throw new AuthorizationError({
|
|
2407
|
+
message: "No member management permission.",
|
|
2408
|
+
context: {
|
|
2409
|
+
spaceKey: space.key,
|
|
2410
|
+
role: space.spaceState.getMemberRole(identity.identityKey)
|
|
2411
|
+
}
|
|
2461
2412
|
});
|
|
2462
2413
|
}
|
|
2463
2414
|
const credentials = await createAdmissionCredentials2(identity.getIdentityCredentialSigner(), request.memberKey, space.key, space.genesisFeedKey, request.newRole, space.spaceState.membershipChainHeads);
|
|
2464
2415
|
invariant5(credentials[0].credential, void 0, {
|
|
2465
2416
|
F: __dxlog_file9,
|
|
2466
|
-
L:
|
|
2417
|
+
L: 123,
|
|
2467
2418
|
S: this,
|
|
2468
2419
|
A: [
|
|
2469
2420
|
"credentials[0].credential",
|
|
@@ -2473,7 +2424,7 @@ var SpacesServiceImpl = class {
|
|
|
2473
2424
|
const spaceMemberCredential = credentials[0].credential.credential;
|
|
2474
2425
|
invariant5(getCredentialAssertion2(spaceMemberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
|
|
2475
2426
|
F: __dxlog_file9,
|
|
2476
|
-
L:
|
|
2427
|
+
L: 125,
|
|
2477
2428
|
S: this,
|
|
2478
2429
|
A: [
|
|
2479
2430
|
"getCredentialAssertion(spaceMemberCredential)['@type'] === 'dxos.halo.credentials.SpaceMember'",
|
|
@@ -2491,7 +2442,7 @@ var SpacesServiceImpl = class {
|
|
|
2491
2442
|
ids: spaces.map((space) => space.id)
|
|
2492
2443
|
}), {
|
|
2493
2444
|
F: __dxlog_file9,
|
|
2494
|
-
L:
|
|
2445
|
+
L: 138,
|
|
2495
2446
|
S: this,
|
|
2496
2447
|
C: (f, a) => f(...a)
|
|
2497
2448
|
});
|
|
@@ -2583,7 +2534,7 @@ var SpacesServiceImpl = class {
|
|
|
2583
2534
|
} else {
|
|
2584
2535
|
invariant5(!credential.id, "Id on unsigned credentials is not allowed", {
|
|
2585
2536
|
F: __dxlog_file9,
|
|
2586
|
-
L:
|
|
2537
|
+
L: 236,
|
|
2587
2538
|
S: this,
|
|
2588
2539
|
A: [
|
|
2589
2540
|
"!credential.id",
|
|
@@ -2592,7 +2543,7 @@ var SpacesServiceImpl = class {
|
|
|
2592
2543
|
});
|
|
2593
2544
|
invariant5(this._identityManager.identity, "Identity is not available", {
|
|
2594
2545
|
F: __dxlog_file9,
|
|
2595
|
-
L:
|
|
2546
|
+
L: 237,
|
|
2596
2547
|
S: this,
|
|
2597
2548
|
A: [
|
|
2598
2549
|
"this._identityManager.identity",
|
|
@@ -2602,7 +2553,7 @@ var SpacesServiceImpl = class {
|
|
|
2602
2553
|
const signer = this._identityManager.identity.getIdentityCredentialSigner();
|
|
2603
2554
|
invariant5(credential.issuer.equals(signer.getIssuer()), void 0, {
|
|
2604
2555
|
F: __dxlog_file9,
|
|
2605
|
-
L:
|
|
2556
|
+
L: 239,
|
|
2606
2557
|
S: this,
|
|
2607
2558
|
A: [
|
|
2608
2559
|
"credential.issuer.equals(signer.getIssuer())",
|
|
@@ -2656,7 +2607,7 @@ var SpacesServiceImpl = class {
|
|
|
2656
2607
|
};
|
|
2657
2608
|
try {
|
|
2658
2609
|
const writer = _ts_add_disposable_resource2(env, await new SpaceArchiveWriter().open(), true);
|
|
2659
|
-
assertArgument4(SpaceId.isValid(request.spaceId), "Invalid space ID");
|
|
2610
|
+
assertArgument4(SpaceId.isValid(request.spaceId), "spaceId", "Invalid space ID");
|
|
2660
2611
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
2661
2612
|
const space = dataSpaceManager.getSpaceById(request.spaceId) ?? raise(new Error("Space not found"));
|
|
2662
2613
|
await writer.begin({
|
|
@@ -2685,7 +2636,7 @@ var SpacesServiceImpl = class {
|
|
|
2685
2636
|
const extracted = await extractSpaceArchive(request.archive);
|
|
2686
2637
|
invariant5(extracted.metadata.echo?.currentRootUrl, "Space archive does not contain a root URL", {
|
|
2687
2638
|
F: __dxlog_file9,
|
|
2688
|
-
L:
|
|
2639
|
+
L: 293,
|
|
2689
2640
|
S: this,
|
|
2690
2641
|
A: [
|
|
2691
2642
|
"extracted.metadata.echo?.currentRootUrl",
|
|
@@ -2705,7 +2656,7 @@ var SpacesServiceImpl = class {
|
|
|
2705
2656
|
const assertion = getCredentialAssertion2(credential);
|
|
2706
2657
|
invariant5(assertion["@type"] === "dxos.halo.credentials.SpaceMember", "Invalid credential", {
|
|
2707
2658
|
F: __dxlog_file9,
|
|
2708
|
-
L:
|
|
2659
|
+
L: 304,
|
|
2709
2660
|
S: this,
|
|
2710
2661
|
A: [
|
|
2711
2662
|
"assertion['@type'] === 'dxos.halo.credentials.SpaceMember'",
|
|
@@ -2715,7 +2666,7 @@ var SpacesServiceImpl = class {
|
|
|
2715
2666
|
const myIdentity = this._identityManager.identity;
|
|
2716
2667
|
invariant5(myIdentity && credential.subject.id.equals(myIdentity.identityKey), void 0, {
|
|
2717
2668
|
F: __dxlog_file9,
|
|
2718
|
-
L:
|
|
2669
|
+
L: 306,
|
|
2719
2670
|
S: this,
|
|
2720
2671
|
A: [
|
|
2721
2672
|
"myIdentity && credential.subject.id.equals(myIdentity.identityKey)",
|
|
@@ -2784,7 +2735,9 @@ var SpacesServiceImpl = class {
|
|
|
2784
2735
|
}
|
|
2785
2736
|
_requireIdentity() {
|
|
2786
2737
|
if (!this._identityManager.identity) {
|
|
2787
|
-
throw new IdentityNotInitializedError(
|
|
2738
|
+
throw new IdentityNotInitializedError({
|
|
2739
|
+
message: "This device has no HALO identity available. See https://docs.dxos.org/guide/platform/halo"
|
|
2740
|
+
});
|
|
2788
2741
|
}
|
|
2789
2742
|
return this._identityManager.identity;
|
|
2790
2743
|
}
|
|
@@ -2799,14 +2752,6 @@ var SpacesServiceImpl = class {
|
|
|
2799
2752
|
});
|
|
2800
2753
|
}
|
|
2801
2754
|
}
|
|
2802
|
-
constructor(_identityManager, _spaceManager, _getDataSpaceManager) {
|
|
2803
|
-
_define_property7(this, "_identityManager", void 0);
|
|
2804
|
-
_define_property7(this, "_spaceManager", void 0);
|
|
2805
|
-
_define_property7(this, "_getDataSpaceManager", void 0);
|
|
2806
|
-
this._identityManager = _identityManager;
|
|
2807
|
-
this._spaceManager = _spaceManager;
|
|
2808
|
-
this._getDataSpaceManager = _getDataSpaceManager;
|
|
2809
|
-
}
|
|
2810
2755
|
};
|
|
2811
2756
|
var getChannelId = (channel) => `user-channel/${channel}`;
|
|
2812
2757
|
|
|
@@ -2814,21 +2759,13 @@ var getChannelId = (channel) => `user-channel/${channel}`;
|
|
|
2814
2759
|
import { getCredentialAssertion as getCredentialAssertion3 } from "@dxos/credentials";
|
|
2815
2760
|
import { SpaceId as SpaceId2 } from "@dxos/keys";
|
|
2816
2761
|
import { log as log8 } from "@dxos/log";
|
|
2817
|
-
function _define_property8(obj, key, value) {
|
|
2818
|
-
if (key in obj) {
|
|
2819
|
-
Object.defineProperty(obj, key, {
|
|
2820
|
-
value,
|
|
2821
|
-
enumerable: true,
|
|
2822
|
-
configurable: true,
|
|
2823
|
-
writable: true
|
|
2824
|
-
});
|
|
2825
|
-
} else {
|
|
2826
|
-
obj[key] = value;
|
|
2827
|
-
}
|
|
2828
|
-
return obj;
|
|
2829
|
-
}
|
|
2830
2762
|
var __dxlog_file10 = "/__w/dxos/dxos/packages/sdk/client-services/src/packlets/identity/default-space-state-machine.ts";
|
|
2831
2763
|
var DefaultSpaceStateMachine = class {
|
|
2764
|
+
_params;
|
|
2765
|
+
_spaceId;
|
|
2766
|
+
constructor(_params) {
|
|
2767
|
+
this._params = _params;
|
|
2768
|
+
}
|
|
2832
2769
|
get spaceId() {
|
|
2833
2770
|
return this._spaceId;
|
|
2834
2771
|
}
|
|
@@ -2864,27 +2801,9 @@ var DefaultSpaceStateMachine = class {
|
|
|
2864
2801
|
}
|
|
2865
2802
|
}
|
|
2866
2803
|
}
|
|
2867
|
-
constructor(_params) {
|
|
2868
|
-
_define_property8(this, "_params", void 0);
|
|
2869
|
-
_define_property8(this, "_spaceId", void 0);
|
|
2870
|
-
this._params = _params;
|
|
2871
|
-
}
|
|
2872
2804
|
};
|
|
2873
2805
|
|
|
2874
2806
|
// src/packlets/identity/identity.ts
|
|
2875
|
-
function _define_property9(obj, key, value) {
|
|
2876
|
-
if (key in obj) {
|
|
2877
|
-
Object.defineProperty(obj, key, {
|
|
2878
|
-
value,
|
|
2879
|
-
enumerable: true,
|
|
2880
|
-
configurable: true,
|
|
2881
|
-
writable: true
|
|
2882
|
-
});
|
|
2883
|
-
} else {
|
|
2884
|
-
obj[key] = value;
|
|
2885
|
-
}
|
|
2886
|
-
return obj;
|
|
2887
|
-
}
|
|
2888
2807
|
function _ts_decorate3(decorators, target, key, desc) {
|
|
2889
2808
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2890
2809
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -2893,6 +2812,58 @@ function _ts_decorate3(decorators, target, key, desc) {
|
|
|
2893
2812
|
}
|
|
2894
2813
|
var __dxlog_file11 = "/__w/dxos/dxos/packages/sdk/client-services/src/packlets/identity/identity.ts";
|
|
2895
2814
|
var Identity = class {
|
|
2815
|
+
space;
|
|
2816
|
+
_signer;
|
|
2817
|
+
_presence;
|
|
2818
|
+
_deviceStateMachine;
|
|
2819
|
+
_profileStateMachine;
|
|
2820
|
+
_defaultSpaceStateMachine;
|
|
2821
|
+
_edgeFeedReplicator = void 0;
|
|
2822
|
+
authVerifier;
|
|
2823
|
+
did;
|
|
2824
|
+
identityKey;
|
|
2825
|
+
deviceKey;
|
|
2826
|
+
stateUpdate = new Event3();
|
|
2827
|
+
constructor(params) {
|
|
2828
|
+
this.space = params.space;
|
|
2829
|
+
this._signer = params.signer;
|
|
2830
|
+
this._presence = params.presence;
|
|
2831
|
+
this.did = params.did;
|
|
2832
|
+
this.identityKey = params.identityKey;
|
|
2833
|
+
this.deviceKey = params.deviceKey;
|
|
2834
|
+
log9.trace("dxos.halo.device", {
|
|
2835
|
+
deviceKey: params.deviceKey
|
|
2836
|
+
}, {
|
|
2837
|
+
F: __dxlog_file11,
|
|
2838
|
+
L: 83,
|
|
2839
|
+
S: this,
|
|
2840
|
+
C: (f, a) => f(...a)
|
|
2841
|
+
});
|
|
2842
|
+
this._deviceStateMachine = new DeviceStateMachine({
|
|
2843
|
+
identityKey: this.identityKey,
|
|
2844
|
+
deviceKey: this.deviceKey,
|
|
2845
|
+
onUpdate: () => this.stateUpdate.emit()
|
|
2846
|
+
});
|
|
2847
|
+
this._profileStateMachine = new ProfileStateMachine({
|
|
2848
|
+
identityKey: this.identityKey,
|
|
2849
|
+
onUpdate: () => this.stateUpdate.emit()
|
|
2850
|
+
});
|
|
2851
|
+
this._defaultSpaceStateMachine = new DefaultSpaceStateMachine({
|
|
2852
|
+
identityKey: this.identityKey,
|
|
2853
|
+
onUpdate: () => this.stateUpdate.emit()
|
|
2854
|
+
});
|
|
2855
|
+
this.authVerifier = new TrustedKeySetAuthVerifier({
|
|
2856
|
+
trustedKeysProvider: () => new ComplexSet(PublicKey5.hash, this.authorizedDeviceKeys.keys()),
|
|
2857
|
+
update: this.stateUpdate,
|
|
2858
|
+
authTimeout: AUTH_TIMEOUT
|
|
2859
|
+
});
|
|
2860
|
+
if (params.edgeConnection && params.edgeFeatures?.feedReplicator) {
|
|
2861
|
+
this._edgeFeedReplicator = new EdgeFeedReplicator({
|
|
2862
|
+
messenger: params.edgeConnection,
|
|
2863
|
+
spaceId: this.space.id
|
|
2864
|
+
});
|
|
2865
|
+
}
|
|
2866
|
+
}
|
|
2896
2867
|
// TODO(burdon): Expose state object?
|
|
2897
2868
|
get authorizedDeviceKeys() {
|
|
2898
2869
|
return this._deviceStateMachine.authorizedDeviceKeys;
|
|
@@ -3052,61 +3023,9 @@ var Identity = class {
|
|
|
3052
3023
|
})));
|
|
3053
3024
|
return deviceCredential;
|
|
3054
3025
|
}
|
|
3055
|
-
|
|
3056
|
-
|
|
3057
|
-
|
|
3058
|
-
_define_property9(this, "_presence", void 0);
|
|
3059
|
-
_define_property9(this, "_deviceStateMachine", void 0);
|
|
3060
|
-
_define_property9(this, "_profileStateMachine", void 0);
|
|
3061
|
-
_define_property9(this, "_defaultSpaceStateMachine", void 0);
|
|
3062
|
-
_define_property9(this, "_edgeFeedReplicator", void 0);
|
|
3063
|
-
_define_property9(this, "authVerifier", void 0);
|
|
3064
|
-
_define_property9(this, "did", void 0);
|
|
3065
|
-
_define_property9(this, "identityKey", void 0);
|
|
3066
|
-
_define_property9(this, "deviceKey", void 0);
|
|
3067
|
-
_define_property9(this, "stateUpdate", new Event3());
|
|
3068
|
-
_define_property9(this, "_onFeedAdded", async (feed) => {
|
|
3069
|
-
await this._edgeFeedReplicator.addFeed(feed);
|
|
3070
|
-
});
|
|
3071
|
-
this.space = params.space;
|
|
3072
|
-
this._signer = params.signer;
|
|
3073
|
-
this._presence = params.presence;
|
|
3074
|
-
this.did = params.did;
|
|
3075
|
-
this.identityKey = params.identityKey;
|
|
3076
|
-
this.deviceKey = params.deviceKey;
|
|
3077
|
-
log9.trace("dxos.halo.device", {
|
|
3078
|
-
deviceKey: params.deviceKey
|
|
3079
|
-
}, {
|
|
3080
|
-
F: __dxlog_file11,
|
|
3081
|
-
L: 83,
|
|
3082
|
-
S: this,
|
|
3083
|
-
C: (f, a) => f(...a)
|
|
3084
|
-
});
|
|
3085
|
-
this._deviceStateMachine = new DeviceStateMachine({
|
|
3086
|
-
identityKey: this.identityKey,
|
|
3087
|
-
deviceKey: this.deviceKey,
|
|
3088
|
-
onUpdate: () => this.stateUpdate.emit()
|
|
3089
|
-
});
|
|
3090
|
-
this._profileStateMachine = new ProfileStateMachine({
|
|
3091
|
-
identityKey: this.identityKey,
|
|
3092
|
-
onUpdate: () => this.stateUpdate.emit()
|
|
3093
|
-
});
|
|
3094
|
-
this._defaultSpaceStateMachine = new DefaultSpaceStateMachine({
|
|
3095
|
-
identityKey: this.identityKey,
|
|
3096
|
-
onUpdate: () => this.stateUpdate.emit()
|
|
3097
|
-
});
|
|
3098
|
-
this.authVerifier = new TrustedKeySetAuthVerifier({
|
|
3099
|
-
trustedKeysProvider: () => new ComplexSet(PublicKey5.hash, this.authorizedDeviceKeys.keys()),
|
|
3100
|
-
update: this.stateUpdate,
|
|
3101
|
-
authTimeout: AUTH_TIMEOUT
|
|
3102
|
-
});
|
|
3103
|
-
if (params.edgeConnection && params.edgeFeatures?.feedReplicator) {
|
|
3104
|
-
this._edgeFeedReplicator = new EdgeFeedReplicator({
|
|
3105
|
-
messenger: params.edgeConnection,
|
|
3106
|
-
spaceId: this.space.id
|
|
3107
|
-
});
|
|
3108
|
-
}
|
|
3109
|
-
}
|
|
3026
|
+
_onFeedAdded = async (feed) => {
|
|
3027
|
+
await this._edgeFeedReplicator.addFeed(feed);
|
|
3028
|
+
};
|
|
3110
3029
|
};
|
|
3111
3030
|
_ts_decorate3([
|
|
3112
3031
|
trace3.span()
|
|
@@ -3133,19 +3052,6 @@ import { Gossip as Gossip2, Presence as Presence2 } from "@dxos/teleport-extensi
|
|
|
3133
3052
|
import { Timeframe as Timeframe3 } from "@dxos/timeframe";
|
|
3134
3053
|
import { trace as Trace2 } from "@dxos/tracing";
|
|
3135
3054
|
import { deferFunction as deferFunction2, isNode } from "@dxos/util";
|
|
3136
|
-
function _define_property10(obj, key, value) {
|
|
3137
|
-
if (key in obj) {
|
|
3138
|
-
Object.defineProperty(obj, key, {
|
|
3139
|
-
value,
|
|
3140
|
-
enumerable: true,
|
|
3141
|
-
configurable: true,
|
|
3142
|
-
writable: true
|
|
3143
|
-
});
|
|
3144
|
-
} else {
|
|
3145
|
-
obj[key] = value;
|
|
3146
|
-
}
|
|
3147
|
-
return obj;
|
|
3148
|
-
}
|
|
3149
3055
|
function _ts_decorate4(decorators, target, key, desc) {
|
|
3150
3056
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3151
3057
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -3156,6 +3062,27 @@ var __dxlog_file12 = "/__w/dxos/dxos/packages/sdk/client-services/src/packlets/i
|
|
|
3156
3062
|
var DEVICE_PRESENCE_ANNOUNCE_INTERVAL = 1e4;
|
|
3157
3063
|
var DEVICE_PRESENCE_OFFLINE_TIMEOUT = 2e4;
|
|
3158
3064
|
var IdentityManager = class {
|
|
3065
|
+
stateUpdate = new Event4();
|
|
3066
|
+
_metadataStore;
|
|
3067
|
+
_keyring;
|
|
3068
|
+
_feedStore;
|
|
3069
|
+
_spaceManager;
|
|
3070
|
+
_devicePresenceAnnounceInterval;
|
|
3071
|
+
_devicePresenceOfflineTimeout;
|
|
3072
|
+
_edgeConnection;
|
|
3073
|
+
_edgeFeatures;
|
|
3074
|
+
_identity;
|
|
3075
|
+
// TODO(dmaretskyi): Perhaps this should take/generate the peerKey outside of an initialized identity.
|
|
3076
|
+
constructor(params) {
|
|
3077
|
+
this._metadataStore = params.metadataStore;
|
|
3078
|
+
this._keyring = params.keyring;
|
|
3079
|
+
this._feedStore = params.feedStore;
|
|
3080
|
+
this._spaceManager = params.spaceManager;
|
|
3081
|
+
this._edgeConnection = params.edgeConnection;
|
|
3082
|
+
this._edgeFeatures = params.edgeFeatures;
|
|
3083
|
+
this._devicePresenceAnnounceInterval = params.devicePresenceAnnounceInterval ?? DEVICE_PRESENCE_ANNOUNCE_INTERVAL;
|
|
3084
|
+
this._devicePresenceOfflineTimeout = params.devicePresenceOfflineTimeout ?? DEVICE_PRESENCE_OFFLINE_TIMEOUT;
|
|
3085
|
+
}
|
|
3159
3086
|
get identity() {
|
|
3160
3087
|
return this._identity;
|
|
3161
3088
|
}
|
|
@@ -3590,27 +3517,6 @@ var IdentityManager = class {
|
|
|
3590
3517
|
}
|
|
3591
3518
|
});
|
|
3592
3519
|
}
|
|
3593
|
-
// TODO(dmaretskyi): Perhaps this should take/generate the peerKey outside of an initialized identity.
|
|
3594
|
-
constructor(params) {
|
|
3595
|
-
_define_property10(this, "stateUpdate", new Event4());
|
|
3596
|
-
_define_property10(this, "_metadataStore", void 0);
|
|
3597
|
-
_define_property10(this, "_keyring", void 0);
|
|
3598
|
-
_define_property10(this, "_feedStore", void 0);
|
|
3599
|
-
_define_property10(this, "_spaceManager", void 0);
|
|
3600
|
-
_define_property10(this, "_devicePresenceAnnounceInterval", void 0);
|
|
3601
|
-
_define_property10(this, "_devicePresenceOfflineTimeout", void 0);
|
|
3602
|
-
_define_property10(this, "_edgeConnection", void 0);
|
|
3603
|
-
_define_property10(this, "_edgeFeatures", void 0);
|
|
3604
|
-
_define_property10(this, "_identity", void 0);
|
|
3605
|
-
this._metadataStore = params.metadataStore;
|
|
3606
|
-
this._keyring = params.keyring;
|
|
3607
|
-
this._feedStore = params.feedStore;
|
|
3608
|
-
this._spaceManager = params.spaceManager;
|
|
3609
|
-
this._edgeConnection = params.edgeConnection;
|
|
3610
|
-
this._edgeFeatures = params.edgeFeatures;
|
|
3611
|
-
this._devicePresenceAnnounceInterval = params.devicePresenceAnnounceInterval ?? DEVICE_PRESENCE_ANNOUNCE_INTERVAL;
|
|
3612
|
-
this._devicePresenceOfflineTimeout = params.devicePresenceOfflineTimeout ?? DEVICE_PRESENCE_OFFLINE_TIMEOUT;
|
|
3613
|
-
}
|
|
3614
3520
|
};
|
|
3615
3521
|
_ts_decorate4([
|
|
3616
3522
|
Trace2.span({
|
|
@@ -3630,22 +3536,18 @@ import { invariant as invariant8 } from "@dxos/invariant";
|
|
|
3630
3536
|
import { log as log11 } from "@dxos/log";
|
|
3631
3537
|
import { SpaceState as SpaceState3 } from "@dxos/protocols/proto/dxos/client/services";
|
|
3632
3538
|
import { safeAwaitAll } from "@dxos/util";
|
|
3633
|
-
function _define_property11(obj, key, value) {
|
|
3634
|
-
if (key in obj) {
|
|
3635
|
-
Object.defineProperty(obj, key, {
|
|
3636
|
-
value,
|
|
3637
|
-
enumerable: true,
|
|
3638
|
-
configurable: true,
|
|
3639
|
-
writable: true
|
|
3640
|
-
});
|
|
3641
|
-
} else {
|
|
3642
|
-
obj[key] = value;
|
|
3643
|
-
}
|
|
3644
|
-
return obj;
|
|
3645
|
-
}
|
|
3646
3539
|
var __dxlog_file13 = "/__w/dxos/dxos/packages/sdk/client-services/src/packlets/identity/identity-service.ts";
|
|
3647
3540
|
var DEFAULT_SPACE_SEARCH_TIMEOUT = 1e4;
|
|
3648
3541
|
var IdentityServiceImpl = class extends Resource4 {
|
|
3542
|
+
_identityManager;
|
|
3543
|
+
_recoveryManager;
|
|
3544
|
+
_keyring;
|
|
3545
|
+
_dataSpaceManagerProvider;
|
|
3546
|
+
_createIdentity;
|
|
3547
|
+
_onProfileUpdate;
|
|
3548
|
+
constructor(_identityManager, _recoveryManager, _keyring, _dataSpaceManagerProvider, _createIdentity, _onProfileUpdate) {
|
|
3549
|
+
super(), this._identityManager = _identityManager, this._recoveryManager = _recoveryManager, this._keyring = _keyring, this._dataSpaceManagerProvider = _dataSpaceManagerProvider, this._createIdentity = _createIdentity, this._onProfileUpdate = _onProfileUpdate;
|
|
3550
|
+
}
|
|
3649
3551
|
async _open() {
|
|
3650
3552
|
const identity = this._identityManager.identity;
|
|
3651
3553
|
if (identity && !identity.defaultSpaceId) {
|
|
@@ -3820,29 +3722,21 @@ var IdentityServiceImpl = class extends Resource4 {
|
|
|
3820
3722
|
await this._createDefaultSpace(dataSpaceManager);
|
|
3821
3723
|
}
|
|
3822
3724
|
}
|
|
3823
|
-
constructor(_identityManager, _recoveryManager, _keyring, _dataSpaceManagerProvider, _createIdentity, _onProfileUpdate) {
|
|
3824
|
-
super(), _define_property11(this, "_identityManager", void 0), _define_property11(this, "_recoveryManager", void 0), _define_property11(this, "_keyring", void 0), _define_property11(this, "_dataSpaceManagerProvider", void 0), _define_property11(this, "_createIdentity", void 0), _define_property11(this, "_onProfileUpdate", void 0), this._identityManager = _identityManager, this._recoveryManager = _recoveryManager, this._keyring = _keyring, this._dataSpaceManagerProvider = _dataSpaceManagerProvider, this._createIdentity = _createIdentity, this._onProfileUpdate = _onProfileUpdate;
|
|
3825
|
-
}
|
|
3826
3725
|
};
|
|
3827
3726
|
|
|
3828
3727
|
// src/packlets/spaces/automerge-space-state.ts
|
|
3829
3728
|
import { Event as Event5 } from "@dxos/async";
|
|
3830
3729
|
import { Resource as Resource5 } from "@dxos/context";
|
|
3831
3730
|
import { checkCredentialType } from "@dxos/credentials";
|
|
3832
|
-
function _define_property12(obj, key, value) {
|
|
3833
|
-
if (key in obj) {
|
|
3834
|
-
Object.defineProperty(obj, key, {
|
|
3835
|
-
value,
|
|
3836
|
-
enumerable: true,
|
|
3837
|
-
configurable: true,
|
|
3838
|
-
writable: true
|
|
3839
|
-
});
|
|
3840
|
-
} else {
|
|
3841
|
-
obj[key] = value;
|
|
3842
|
-
}
|
|
3843
|
-
return obj;
|
|
3844
|
-
}
|
|
3845
3731
|
var AutomergeSpaceState = class extends Resource5 {
|
|
3732
|
+
_onNewRoot;
|
|
3733
|
+
rootUrl = void 0;
|
|
3734
|
+
lastEpoch = void 0;
|
|
3735
|
+
onNewEpoch = new Event5();
|
|
3736
|
+
_isProcessingRootDocs = false;
|
|
3737
|
+
constructor(_onNewRoot) {
|
|
3738
|
+
super(), this._onNewRoot = _onNewRoot;
|
|
3739
|
+
}
|
|
3846
3740
|
async _open(ctx) {
|
|
3847
3741
|
}
|
|
3848
3742
|
async _close(ctx) {
|
|
@@ -3873,9 +3767,6 @@ var AutomergeSpaceState = class extends Resource5 {
|
|
|
3873
3767
|
async ensureEpochInitialized() {
|
|
3874
3768
|
await this.onNewEpoch.waitForCondition(() => !!this.lastEpoch);
|
|
3875
3769
|
}
|
|
3876
|
-
constructor(_onNewRoot) {
|
|
3877
|
-
super(), _define_property12(this, "_onNewRoot", void 0), _define_property12(this, "rootUrl", void 0), _define_property12(this, "lastEpoch", void 0), _define_property12(this, "onNewEpoch", void 0), _define_property12(this, "_isProcessingRootDocs", void 0), this._onNewRoot = _onNewRoot, this.rootUrl = void 0, this.lastEpoch = void 0, this.onNewEpoch = new Event5(), this._isProcessingRootDocs = false;
|
|
3878
|
-
}
|
|
3879
3770
|
};
|
|
3880
3771
|
|
|
3881
3772
|
// src/packlets/spaces/epoch-migrations.ts
|
|
@@ -3942,19 +3833,6 @@ import { EdgeCallFailedError } from "@dxos/protocols";
|
|
|
3942
3833
|
import { schema as schema2 } from "@dxos/protocols/proto";
|
|
3943
3834
|
import { RpcExtension } from "@dxos/teleport";
|
|
3944
3835
|
import { ComplexMap as ComplexMap4, ComplexSet as ComplexSet2, entry } from "@dxos/util";
|
|
3945
|
-
function _define_property13(obj, key, value) {
|
|
3946
|
-
if (key in obj) {
|
|
3947
|
-
Object.defineProperty(obj, key, {
|
|
3948
|
-
value,
|
|
3949
|
-
enumerable: true,
|
|
3950
|
-
configurable: true,
|
|
3951
|
-
writable: true
|
|
3952
|
-
});
|
|
3953
|
-
} else {
|
|
3954
|
-
obj[key] = value;
|
|
3955
|
-
}
|
|
3956
|
-
return obj;
|
|
3957
|
-
}
|
|
3958
3836
|
function _ts_decorate5(decorators, target, key, desc) {
|
|
3959
3837
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3960
3838
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -3970,6 +3848,24 @@ var MAX_EDGE_RETRIES = 2;
|
|
|
3970
3848
|
var WRITER_NOT_SET_ERROR_CODE = "WRITER_NOT_SET";
|
|
3971
3849
|
var credentialCodec = schema2.getCodecForType("dxos.halo.credentials.Credential");
|
|
3972
3850
|
var NotarizationPlugin = class extends Resource6 {
|
|
3851
|
+
_extensionOpened = new Event6();
|
|
3852
|
+
_writer;
|
|
3853
|
+
_extensions = /* @__PURE__ */ new Set();
|
|
3854
|
+
_processedCredentials = new ComplexSet2(PublicKey7.hash);
|
|
3855
|
+
_processCredentialsTriggers = new ComplexMap4(PublicKey7.hash);
|
|
3856
|
+
_activeEdgePollingIntervalHandle = void 0;
|
|
3857
|
+
_activeEdgePollingInterval;
|
|
3858
|
+
_activeEdgePollingEnabled = false;
|
|
3859
|
+
_spaceId;
|
|
3860
|
+
_edgeClient;
|
|
3861
|
+
constructor(params) {
|
|
3862
|
+
super();
|
|
3863
|
+
this._spaceId = params.spaceId;
|
|
3864
|
+
this._activeEdgePollingInterval = params.activeEdgePollingInterval ?? DEFAULT_ACTIVE_EDGE_POLLING_INTERVAL;
|
|
3865
|
+
if (params.edgeClient && params.edgeFeatures?.feedReplicator) {
|
|
3866
|
+
this._edgeClient = params.edgeClient;
|
|
3867
|
+
}
|
|
3868
|
+
}
|
|
3973
3869
|
setActiveEdgePollingEnabled(enabled) {
|
|
3974
3870
|
const client = this._edgeClient;
|
|
3975
3871
|
invariant10(client, void 0, {
|
|
@@ -4329,20 +4225,12 @@ var NotarizationPlugin = class extends Resource6 {
|
|
|
4329
4225
|
errors.throw(new TimeoutError(timeout, "Notarization timed out"));
|
|
4330
4226
|
}, timeout);
|
|
4331
4227
|
}
|
|
4332
|
-
constructor(params) {
|
|
4333
|
-
super(), _define_property13(this, "_extensionOpened", new Event6()), _define_property13(this, "_writer", void 0), _define_property13(this, "_extensions", /* @__PURE__ */ new Set()), _define_property13(this, "_processedCredentials", new ComplexSet2(PublicKey7.hash)), _define_property13(this, "_processCredentialsTriggers", new ComplexMap4(PublicKey7.hash)), _define_property13(this, "_activeEdgePollingIntervalHandle", void 0), _define_property13(this, "_activeEdgePollingInterval", void 0), _define_property13(this, "_activeEdgePollingEnabled", false), _define_property13(this, "_spaceId", void 0), _define_property13(this, "_edgeClient", void 0);
|
|
4334
|
-
this._spaceId = params.spaceId;
|
|
4335
|
-
this._activeEdgePollingInterval = params.activeEdgePollingInterval ?? DEFAULT_ACTIVE_EDGE_POLLING_INTERVAL;
|
|
4336
|
-
if (params.edgeClient && params.edgeFeatures?.feedReplicator) {
|
|
4337
|
-
this._edgeClient = params.edgeClient;
|
|
4338
|
-
}
|
|
4339
|
-
}
|
|
4340
4228
|
};
|
|
4341
4229
|
_ts_decorate5([
|
|
4342
4230
|
logInfo2
|
|
4343
4231
|
], NotarizationPlugin.prototype, "_spaceId", void 0);
|
|
4344
4232
|
var handleEdgeError = (error) => {
|
|
4345
|
-
if (!(error instanceof EdgeCallFailedError) || error.
|
|
4233
|
+
if (!(error instanceof EdgeCallFailedError) || error.data) {
|
|
4346
4234
|
log12.catch(error, void 0, {
|
|
4347
4235
|
F: __dxlog_file15,
|
|
4348
4236
|
L: 396,
|
|
@@ -4351,7 +4239,7 @@ var handleEdgeError = (error) => {
|
|
|
4351
4239
|
});
|
|
4352
4240
|
} else {
|
|
4353
4241
|
log12.info("Edge notarization failure", {
|
|
4354
|
-
|
|
4242
|
+
message: error.message
|
|
4355
4243
|
}, {
|
|
4356
4244
|
F: __dxlog_file15,
|
|
4357
4245
|
L: 398,
|
|
@@ -4361,6 +4249,17 @@ var handleEdgeError = (error) => {
|
|
|
4361
4249
|
}
|
|
4362
4250
|
};
|
|
4363
4251
|
var NotarizationTeleportExtension = class extends RpcExtension {
|
|
4252
|
+
_params;
|
|
4253
|
+
constructor(_params) {
|
|
4254
|
+
super({
|
|
4255
|
+
requested: {
|
|
4256
|
+
NotarizationService: schema2.getService("dxos.mesh.teleport.notarization.NotarizationService")
|
|
4257
|
+
},
|
|
4258
|
+
exposed: {
|
|
4259
|
+
NotarizationService: schema2.getService("dxos.mesh.teleport.notarization.NotarizationService")
|
|
4260
|
+
}
|
|
4261
|
+
}), this._params = _params;
|
|
4262
|
+
}
|
|
4364
4263
|
async getHandlers() {
|
|
4365
4264
|
return {
|
|
4366
4265
|
NotarizationService: {
|
|
@@ -4378,32 +4277,9 @@ var NotarizationTeleportExtension = class extends RpcExtension {
|
|
|
4378
4277
|
await this._params.onClose();
|
|
4379
4278
|
await super.onClose(err);
|
|
4380
4279
|
}
|
|
4381
|
-
constructor(_params) {
|
|
4382
|
-
super({
|
|
4383
|
-
requested: {
|
|
4384
|
-
NotarizationService: schema2.getService("dxos.mesh.teleport.notarization.NotarizationService")
|
|
4385
|
-
},
|
|
4386
|
-
exposed: {
|
|
4387
|
-
NotarizationService: schema2.getService("dxos.mesh.teleport.notarization.NotarizationService")
|
|
4388
|
-
}
|
|
4389
|
-
}), _define_property13(this, "_params", void 0), this._params = _params;
|
|
4390
|
-
}
|
|
4391
4280
|
};
|
|
4392
4281
|
|
|
4393
4282
|
// src/packlets/spaces/data-space.ts
|
|
4394
|
-
function _define_property14(obj, key, value) {
|
|
4395
|
-
if (key in obj) {
|
|
4396
|
-
Object.defineProperty(obj, key, {
|
|
4397
|
-
value,
|
|
4398
|
-
enumerable: true,
|
|
4399
|
-
configurable: true,
|
|
4400
|
-
writable: true
|
|
4401
|
-
});
|
|
4402
|
-
} else {
|
|
4403
|
-
obj[key] = value;
|
|
4404
|
-
}
|
|
4405
|
-
return obj;
|
|
4406
|
-
}
|
|
4407
4283
|
function _ts_decorate6(decorators, target, key, desc) {
|
|
4408
4284
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4409
4285
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -4477,6 +4353,75 @@ function _ts_dispose_resources3(env) {
|
|
|
4477
4353
|
}
|
|
4478
4354
|
var __dxlog_file16 = "/__w/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space.ts";
|
|
4479
4355
|
var DataSpace = class {
|
|
4356
|
+
_ctx = new Context6(void 0, {
|
|
4357
|
+
F: __dxlog_file16,
|
|
4358
|
+
L: 101
|
|
4359
|
+
});
|
|
4360
|
+
_inner;
|
|
4361
|
+
_gossip;
|
|
4362
|
+
_presence;
|
|
4363
|
+
_keyring;
|
|
4364
|
+
_feedStore;
|
|
4365
|
+
_metadataStore;
|
|
4366
|
+
_signingContext;
|
|
4367
|
+
_notarizationPlugin;
|
|
4368
|
+
_callbacks;
|
|
4369
|
+
_cache = void 0;
|
|
4370
|
+
_echoHost;
|
|
4371
|
+
_edgeFeedReplicator = void 0;
|
|
4372
|
+
// TODO(dmaretskyi): Move into Space?
|
|
4373
|
+
_automergeSpaceState = new AutomergeSpaceState((rootUrl) => this._onNewAutomergeRoot(rootUrl));
|
|
4374
|
+
_epochProcessingMutex = new Mutex2();
|
|
4375
|
+
_state = SpaceState4.SPACE_CLOSED;
|
|
4376
|
+
_databaseRoot = null;
|
|
4377
|
+
/**
|
|
4378
|
+
* Error for _state === SpaceState.SPACE_ERROR.
|
|
4379
|
+
*/
|
|
4380
|
+
error = void 0;
|
|
4381
|
+
authVerifier;
|
|
4382
|
+
stateUpdate = new Event7();
|
|
4383
|
+
postOpen = new CallbackCollection();
|
|
4384
|
+
preClose = new CallbackCollection();
|
|
4385
|
+
metrics = {};
|
|
4386
|
+
constructor(params) {
|
|
4387
|
+
this._inner = params.inner;
|
|
4388
|
+
this._inner.stateUpdate.on(this._ctx, () => this.stateUpdate.emit());
|
|
4389
|
+
this._gossip = params.gossip;
|
|
4390
|
+
this._presence = params.presence;
|
|
4391
|
+
this._keyring = params.keyring;
|
|
4392
|
+
this._feedStore = params.feedStore;
|
|
4393
|
+
this._metadataStore = params.metadataStore;
|
|
4394
|
+
this._signingContext = params.signingContext;
|
|
4395
|
+
this._callbacks = params.callbacks ?? {};
|
|
4396
|
+
this._echoHost = params.echoHost;
|
|
4397
|
+
this._notarizationPlugin = new NotarizationPlugin({
|
|
4398
|
+
spaceId: this._inner.id,
|
|
4399
|
+
edgeClient: params.edgeHttpClient,
|
|
4400
|
+
edgeFeatures: params.edgeFeatures,
|
|
4401
|
+
activeEdgePollingInterval: params.activeEdgeNotarizationPollingInterval
|
|
4402
|
+
});
|
|
4403
|
+
this.authVerifier = new TrustedKeySetAuthVerifier({
|
|
4404
|
+
trustedKeysProvider: () => new ComplexSet3(PublicKey8.hash, Array.from(this._inner.spaceState.members.values()).filter((member) => member.role !== SpaceMember5.Role.REMOVED).map((member) => member.key)),
|
|
4405
|
+
update: this._inner.stateUpdate,
|
|
4406
|
+
authTimeout: AUTH_TIMEOUT2
|
|
4407
|
+
});
|
|
4408
|
+
this._cache = params.cache;
|
|
4409
|
+
if (params.edgeConnection && params.edgeFeatures?.feedReplicator) {
|
|
4410
|
+
this._edgeFeedReplicator = new EdgeFeedReplicator({
|
|
4411
|
+
messenger: params.edgeConnection,
|
|
4412
|
+
spaceId: this.id
|
|
4413
|
+
});
|
|
4414
|
+
}
|
|
4415
|
+
this._state = params.initialState;
|
|
4416
|
+
log13("new state", {
|
|
4417
|
+
state: SpaceState4[this._state]
|
|
4418
|
+
}, {
|
|
4419
|
+
F: __dxlog_file16,
|
|
4420
|
+
L: 177,
|
|
4421
|
+
S: this,
|
|
4422
|
+
C: (f, a) => f(...a)
|
|
4423
|
+
});
|
|
4424
|
+
}
|
|
4480
4425
|
get id() {
|
|
4481
4426
|
return this._inner.id;
|
|
4482
4427
|
}
|
|
@@ -4630,7 +4575,9 @@ var DataSpace = class {
|
|
|
4630
4575
|
}
|
|
4631
4576
|
async initializeDataPipeline() {
|
|
4632
4577
|
if (this._state !== SpaceState4.SPACE_CONTROL_ONLY) {
|
|
4633
|
-
throw new SystemError(
|
|
4578
|
+
throw new SystemError({
|
|
4579
|
+
message: "Invalid operation"
|
|
4580
|
+
});
|
|
4634
4581
|
}
|
|
4635
4582
|
this._state = SpaceState4.SPACE_INITIALIZING;
|
|
4636
4583
|
log13("new state", {
|
|
@@ -4963,74 +4910,9 @@ var DataSpace = class {
|
|
|
4963
4910
|
getEdgeReplicationSetting() {
|
|
4964
4911
|
return this._metadataStore.getSpaceEdgeReplicationSetting(this.key);
|
|
4965
4912
|
}
|
|
4966
|
-
|
|
4967
|
-
|
|
4968
|
-
|
|
4969
|
-
L: 101
|
|
4970
|
-
}));
|
|
4971
|
-
_define_property14(this, "_inner", void 0);
|
|
4972
|
-
_define_property14(this, "_gossip", void 0);
|
|
4973
|
-
_define_property14(this, "_presence", void 0);
|
|
4974
|
-
_define_property14(this, "_keyring", void 0);
|
|
4975
|
-
_define_property14(this, "_feedStore", void 0);
|
|
4976
|
-
_define_property14(this, "_metadataStore", void 0);
|
|
4977
|
-
_define_property14(this, "_signingContext", void 0);
|
|
4978
|
-
_define_property14(this, "_notarizationPlugin", void 0);
|
|
4979
|
-
_define_property14(this, "_callbacks", void 0);
|
|
4980
|
-
_define_property14(this, "_cache", void 0);
|
|
4981
|
-
_define_property14(this, "_echoHost", void 0);
|
|
4982
|
-
_define_property14(this, "_edgeFeedReplicator", void 0);
|
|
4983
|
-
_define_property14(this, "_automergeSpaceState", new AutomergeSpaceState((rootUrl) => this._onNewAutomergeRoot(rootUrl)));
|
|
4984
|
-
_define_property14(this, "_epochProcessingMutex", new Mutex2());
|
|
4985
|
-
_define_property14(this, "_state", SpaceState4.SPACE_CLOSED);
|
|
4986
|
-
_define_property14(this, "_databaseRoot", null);
|
|
4987
|
-
_define_property14(this, "error", void 0);
|
|
4988
|
-
_define_property14(this, "authVerifier", void 0);
|
|
4989
|
-
_define_property14(this, "stateUpdate", new Event7());
|
|
4990
|
-
_define_property14(this, "postOpen", new CallbackCollection());
|
|
4991
|
-
_define_property14(this, "preClose", new CallbackCollection());
|
|
4992
|
-
_define_property14(this, "metrics", {});
|
|
4993
|
-
_define_property14(this, "_onFeedAdded", async (feed) => {
|
|
4994
|
-
await this._edgeFeedReplicator.addFeed(feed);
|
|
4995
|
-
});
|
|
4996
|
-
this._inner = params.inner;
|
|
4997
|
-
this._inner.stateUpdate.on(this._ctx, () => this.stateUpdate.emit());
|
|
4998
|
-
this._gossip = params.gossip;
|
|
4999
|
-
this._presence = params.presence;
|
|
5000
|
-
this._keyring = params.keyring;
|
|
5001
|
-
this._feedStore = params.feedStore;
|
|
5002
|
-
this._metadataStore = params.metadataStore;
|
|
5003
|
-
this._signingContext = params.signingContext;
|
|
5004
|
-
this._callbacks = params.callbacks ?? {};
|
|
5005
|
-
this._echoHost = params.echoHost;
|
|
5006
|
-
this._notarizationPlugin = new NotarizationPlugin({
|
|
5007
|
-
spaceId: this._inner.id,
|
|
5008
|
-
edgeClient: params.edgeHttpClient,
|
|
5009
|
-
edgeFeatures: params.edgeFeatures,
|
|
5010
|
-
activeEdgePollingInterval: params.activeEdgeNotarizationPollingInterval
|
|
5011
|
-
});
|
|
5012
|
-
this.authVerifier = new TrustedKeySetAuthVerifier({
|
|
5013
|
-
trustedKeysProvider: () => new ComplexSet3(PublicKey8.hash, Array.from(this._inner.spaceState.members.values()).filter((member) => member.role !== SpaceMember5.Role.REMOVED).map((member) => member.key)),
|
|
5014
|
-
update: this._inner.stateUpdate,
|
|
5015
|
-
authTimeout: AUTH_TIMEOUT2
|
|
5016
|
-
});
|
|
5017
|
-
this._cache = params.cache;
|
|
5018
|
-
if (params.edgeConnection && params.edgeFeatures?.feedReplicator) {
|
|
5019
|
-
this._edgeFeedReplicator = new EdgeFeedReplicator({
|
|
5020
|
-
messenger: params.edgeConnection,
|
|
5021
|
-
spaceId: this.id
|
|
5022
|
-
});
|
|
5023
|
-
}
|
|
5024
|
-
this._state = params.initialState;
|
|
5025
|
-
log13("new state", {
|
|
5026
|
-
state: SpaceState4[this._state]
|
|
5027
|
-
}, {
|
|
5028
|
-
F: __dxlog_file16,
|
|
5029
|
-
L: 177,
|
|
5030
|
-
S: this,
|
|
5031
|
-
C: (f, a) => f(...a)
|
|
5032
|
-
});
|
|
5033
|
-
}
|
|
4913
|
+
_onFeedAdded = async (feed) => {
|
|
4914
|
+
await this._edgeFeedReplicator.addFeed(feed);
|
|
4915
|
+
};
|
|
5034
4916
|
};
|
|
5035
4917
|
_ts_decorate6([
|
|
5036
4918
|
trace5.info()
|
|
@@ -5086,21 +4968,16 @@ import { getCredentialAssertion as getCredentialAssertion4 } from "@dxos/credent
|
|
|
5086
4968
|
import { invariant as invariant12 } from "@dxos/invariant";
|
|
5087
4969
|
import { AlreadyJoinedError as AlreadyJoinedError2 } from "@dxos/protocols";
|
|
5088
4970
|
import { Invitation as Invitation2 } from "@dxos/protocols/proto/dxos/client/services";
|
|
5089
|
-
function _define_property15(obj, key, value) {
|
|
5090
|
-
if (key in obj) {
|
|
5091
|
-
Object.defineProperty(obj, key, {
|
|
5092
|
-
value,
|
|
5093
|
-
enumerable: true,
|
|
5094
|
-
configurable: true,
|
|
5095
|
-
writable: true
|
|
5096
|
-
});
|
|
5097
|
-
} else {
|
|
5098
|
-
obj[key] = value;
|
|
5099
|
-
}
|
|
5100
|
-
return obj;
|
|
5101
|
-
}
|
|
5102
4971
|
var __dxlog_file17 = "/__w/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/device-invitation-protocol.ts";
|
|
5103
4972
|
var DeviceInvitationProtocol = class {
|
|
4973
|
+
_keyring;
|
|
4974
|
+
_getIdentity;
|
|
4975
|
+
_acceptIdentity;
|
|
4976
|
+
constructor(_keyring, _getIdentity, _acceptIdentity) {
|
|
4977
|
+
this._keyring = _keyring;
|
|
4978
|
+
this._getIdentity = _getIdentity;
|
|
4979
|
+
this._acceptIdentity = _acceptIdentity;
|
|
4980
|
+
}
|
|
5104
4981
|
toJSON() {
|
|
5105
4982
|
return {
|
|
5106
4983
|
kind: "device"
|
|
@@ -5155,7 +5032,9 @@ var DeviceInvitationProtocol = class {
|
|
|
5155
5032
|
try {
|
|
5156
5033
|
const identity = this._getIdentity();
|
|
5157
5034
|
if (identity) {
|
|
5158
|
-
return new AlreadyJoinedError2(
|
|
5035
|
+
return new AlreadyJoinedError2({
|
|
5036
|
+
message: "Currently only one identity per client is supported."
|
|
5037
|
+
});
|
|
5159
5038
|
}
|
|
5160
5039
|
} catch {
|
|
5161
5040
|
}
|
|
@@ -5212,14 +5091,6 @@ var DeviceInvitationProtocol = class {
|
|
|
5212
5091
|
identityKey
|
|
5213
5092
|
};
|
|
5214
5093
|
}
|
|
5215
|
-
constructor(_keyring, _getIdentity, _acceptIdentity) {
|
|
5216
|
-
_define_property15(this, "_keyring", void 0);
|
|
5217
|
-
_define_property15(this, "_getIdentity", void 0);
|
|
5218
|
-
_define_property15(this, "_acceptIdentity", void 0);
|
|
5219
|
-
this._keyring = _keyring;
|
|
5220
|
-
this._getIdentity = _getIdentity;
|
|
5221
|
-
this._acceptIdentity = _acceptIdentity;
|
|
5222
|
-
}
|
|
5223
5094
|
};
|
|
5224
5095
|
|
|
5225
5096
|
// src/packlets/invitations/invitations-handler.ts
|
|
@@ -5274,24 +5145,22 @@ var tryAcquireBeforeContextDisposed = async (ctx, mutex) => {
|
|
|
5274
5145
|
};
|
|
5275
5146
|
|
|
5276
5147
|
// src/packlets/invitations/edge-invitation-handler.ts
|
|
5277
|
-
function _define_property16(obj, key, value) {
|
|
5278
|
-
if (key in obj) {
|
|
5279
|
-
Object.defineProperty(obj, key, {
|
|
5280
|
-
value,
|
|
5281
|
-
enumerable: true,
|
|
5282
|
-
configurable: true,
|
|
5283
|
-
writable: true
|
|
5284
|
-
});
|
|
5285
|
-
} else {
|
|
5286
|
-
obj[key] = value;
|
|
5287
|
-
}
|
|
5288
|
-
return obj;
|
|
5289
|
-
}
|
|
5290
5148
|
var __dxlog_file18 = "/__w/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/edge-invitation-handler.ts";
|
|
5291
5149
|
var MAX_RETRIES_PER_INVITATION = 5;
|
|
5292
5150
|
var DEFAULT_REQUEST_RETRY_INTERVAL_MS = 3e3;
|
|
5293
5151
|
var DEFAULT_REQUEST_RETRY_JITTER_MS = 500;
|
|
5294
5152
|
var EdgeInvitationHandler = class {
|
|
5153
|
+
_client;
|
|
5154
|
+
_callbacks;
|
|
5155
|
+
_flowLock;
|
|
5156
|
+
_retryInterval;
|
|
5157
|
+
_retryJitter;
|
|
5158
|
+
constructor(config, _client, _callbacks) {
|
|
5159
|
+
this._client = _client;
|
|
5160
|
+
this._callbacks = _callbacks;
|
|
5161
|
+
this._retryInterval = config?.retryInterval ?? DEFAULT_REQUEST_RETRY_INTERVAL_MS;
|
|
5162
|
+
this._retryJitter = config?.retryJitter ?? DEFAULT_REQUEST_RETRY_JITTER_MS;
|
|
5163
|
+
}
|
|
5295
5164
|
handle(ctx, guardedState, protocol, deviceProfile) {
|
|
5296
5165
|
if (!this._client) {
|
|
5297
5166
|
log14("edge disabled", void 0, {
|
|
@@ -5434,17 +5303,6 @@ var EdgeInvitationHandler = class {
|
|
|
5434
5303
|
_calculateNextRetryMs() {
|
|
5435
5304
|
return this._retryInterval + Math.random() * this._retryJitter;
|
|
5436
5305
|
}
|
|
5437
|
-
constructor(config, _client, _callbacks) {
|
|
5438
|
-
_define_property16(this, "_client", void 0);
|
|
5439
|
-
_define_property16(this, "_callbacks", void 0);
|
|
5440
|
-
_define_property16(this, "_flowLock", void 0);
|
|
5441
|
-
_define_property16(this, "_retryInterval", void 0);
|
|
5442
|
-
_define_property16(this, "_retryJitter", void 0);
|
|
5443
|
-
this._client = _client;
|
|
5444
|
-
this._callbacks = _callbacks;
|
|
5445
|
-
this._retryInterval = config?.retryInterval ?? DEFAULT_REQUEST_RETRY_INTERVAL_MS;
|
|
5446
|
-
this._retryJitter = config?.retryJitter ?? DEFAULT_REQUEST_RETRY_JITTER_MS;
|
|
5447
|
-
}
|
|
5448
5306
|
};
|
|
5449
5307
|
|
|
5450
5308
|
// src/packlets/invitations/invitation-guest-extenstion.ts
|
|
@@ -5456,22 +5314,31 @@ import { InvalidInvitationExtensionRoleError } from "@dxos/protocols";
|
|
|
5456
5314
|
import { schema as schema4 } from "@dxos/protocols/proto";
|
|
5457
5315
|
import { InvitationOptions } from "@dxos/protocols/proto/dxos/halo/invitations";
|
|
5458
5316
|
import { RpcExtension as RpcExtension2 } from "@dxos/teleport";
|
|
5459
|
-
function _define_property17(obj, key, value) {
|
|
5460
|
-
if (key in obj) {
|
|
5461
|
-
Object.defineProperty(obj, key, {
|
|
5462
|
-
value,
|
|
5463
|
-
enumerable: true,
|
|
5464
|
-
configurable: true,
|
|
5465
|
-
writable: true
|
|
5466
|
-
});
|
|
5467
|
-
} else {
|
|
5468
|
-
obj[key] = value;
|
|
5469
|
-
}
|
|
5470
|
-
return obj;
|
|
5471
|
-
}
|
|
5472
5317
|
var __dxlog_file19 = "/__w/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitation-guest-extenstion.ts";
|
|
5473
5318
|
var OPTIONS_TIMEOUT = 1e4;
|
|
5474
5319
|
var InvitationGuestExtension = class extends RpcExtension2 {
|
|
5320
|
+
_invitationFlowMutex;
|
|
5321
|
+
_callbacks;
|
|
5322
|
+
_ctx = new Context7(void 0, {
|
|
5323
|
+
F: __dxlog_file19,
|
|
5324
|
+
L: 38
|
|
5325
|
+
});
|
|
5326
|
+
_remoteOptions;
|
|
5327
|
+
_remoteOptionsTrigger = new Trigger5();
|
|
5328
|
+
/**
|
|
5329
|
+
* Held to allow only one invitation flow at a time to be active.
|
|
5330
|
+
*/
|
|
5331
|
+
_invitationFlowLock = null;
|
|
5332
|
+
constructor(_invitationFlowMutex, _callbacks) {
|
|
5333
|
+
super({
|
|
5334
|
+
requested: {
|
|
5335
|
+
InvitationHostService: schema4.getService("dxos.halo.invitations.InvitationHostService")
|
|
5336
|
+
},
|
|
5337
|
+
exposed: {
|
|
5338
|
+
InvitationHostService: schema4.getService("dxos.halo.invitations.InvitationHostService")
|
|
5339
|
+
}
|
|
5340
|
+
}), this._invitationFlowMutex = _invitationFlowMutex, this._callbacks = _callbacks;
|
|
5341
|
+
}
|
|
5475
5342
|
hasFlowLock() {
|
|
5476
5343
|
return this._invitationFlowLock != null;
|
|
5477
5344
|
}
|
|
@@ -5538,10 +5405,12 @@ var InvitationGuestExtension = class extends RpcExtension2 {
|
|
|
5538
5405
|
C: (f, a) => f(...a)
|
|
5539
5406
|
});
|
|
5540
5407
|
if (this._remoteOptions?.role !== InvitationOptions.Role.HOST) {
|
|
5541
|
-
throw new InvalidInvitationExtensionRoleError(
|
|
5542
|
-
|
|
5543
|
-
|
|
5544
|
-
|
|
5408
|
+
throw new InvalidInvitationExtensionRoleError({
|
|
5409
|
+
context: {
|
|
5410
|
+
expected: InvitationOptions.Role.HOST,
|
|
5411
|
+
remoteOptions: this._remoteOptions,
|
|
5412
|
+
remotePeerId: context.remotePeerId
|
|
5413
|
+
}
|
|
5545
5414
|
});
|
|
5546
5415
|
}
|
|
5547
5416
|
this._callbacks.onOpen(this._ctx, context);
|
|
@@ -5567,28 +5436,12 @@ var InvitationGuestExtension = class extends RpcExtension2 {
|
|
|
5567
5436
|
this._invitationFlowLock = null;
|
|
5568
5437
|
log15.verbose("invitation flow lock released", void 0, {
|
|
5569
5438
|
F: __dxlog_file19,
|
|
5570
|
-
L:
|
|
5439
|
+
L: 133,
|
|
5571
5440
|
S: this,
|
|
5572
5441
|
C: (f, a) => f(...a)
|
|
5573
5442
|
});
|
|
5574
5443
|
}
|
|
5575
5444
|
}
|
|
5576
|
-
constructor(_invitationFlowMutex, _callbacks) {
|
|
5577
|
-
super({
|
|
5578
|
-
requested: {
|
|
5579
|
-
InvitationHostService: schema4.getService("dxos.halo.invitations.InvitationHostService")
|
|
5580
|
-
},
|
|
5581
|
-
exposed: {
|
|
5582
|
-
InvitationHostService: schema4.getService("dxos.halo.invitations.InvitationHostService")
|
|
5583
|
-
}
|
|
5584
|
-
}), _define_property17(this, "_invitationFlowMutex", void 0), _define_property17(this, "_callbacks", void 0), _define_property17(this, "_ctx", void 0), _define_property17(this, "_remoteOptions", void 0), _define_property17(this, "_remoteOptionsTrigger", void 0), /**
|
|
5585
|
-
* Held to allow only one invitation flow at a time to be active.
|
|
5586
|
-
*/
|
|
5587
|
-
_define_property17(this, "_invitationFlowLock", void 0), this._invitationFlowMutex = _invitationFlowMutex, this._callbacks = _callbacks, this._ctx = new Context7(void 0, {
|
|
5588
|
-
F: __dxlog_file19,
|
|
5589
|
-
L: 38
|
|
5590
|
-
}), this._remoteOptionsTrigger = new Trigger5(), this._invitationFlowLock = null;
|
|
5591
|
-
}
|
|
5592
5445
|
};
|
|
5593
5446
|
|
|
5594
5447
|
// src/packlets/invitations/invitation-host-extension.ts
|
|
@@ -5603,23 +5456,46 @@ import { schema as schema5 } from "@dxos/protocols/proto";
|
|
|
5603
5456
|
import { Invitation as Invitation5 } from "@dxos/protocols/proto/dxos/client/services";
|
|
5604
5457
|
import { AuthenticationResponse, InvitationOptions as InvitationOptions2 } from "@dxos/protocols/proto/dxos/halo/invitations";
|
|
5605
5458
|
import { RpcExtension as RpcExtension3 } from "@dxos/teleport";
|
|
5606
|
-
function _define_property18(obj, key, value) {
|
|
5607
|
-
if (key in obj) {
|
|
5608
|
-
Object.defineProperty(obj, key, {
|
|
5609
|
-
value,
|
|
5610
|
-
enumerable: true,
|
|
5611
|
-
configurable: true,
|
|
5612
|
-
writable: true
|
|
5613
|
-
});
|
|
5614
|
-
} else {
|
|
5615
|
-
obj[key] = value;
|
|
5616
|
-
}
|
|
5617
|
-
return obj;
|
|
5618
|
-
}
|
|
5619
5459
|
var __dxlog_file20 = "/__w/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitation-host-extension.ts";
|
|
5620
5460
|
var OPTIONS_TIMEOUT2 = 1e4;
|
|
5621
5461
|
var MAX_OTP_ATTEMPTS = 3;
|
|
5622
5462
|
var InvitationHostExtension = class extends RpcExtension3 {
|
|
5463
|
+
_invitationFlowMutex;
|
|
5464
|
+
_callbacks;
|
|
5465
|
+
/**
|
|
5466
|
+
* @internal
|
|
5467
|
+
*/
|
|
5468
|
+
_ctx = new Context8(void 0, {
|
|
5469
|
+
F: __dxlog_file20,
|
|
5470
|
+
L: 57
|
|
5471
|
+
});
|
|
5472
|
+
_remoteOptions;
|
|
5473
|
+
_remoteOptionsTrigger = new Trigger6();
|
|
5474
|
+
_challenge = void 0;
|
|
5475
|
+
guestProfile = void 0;
|
|
5476
|
+
authenticationPassed = false;
|
|
5477
|
+
/**
|
|
5478
|
+
* Retry counter for SHARED_SECRET authentication method.
|
|
5479
|
+
*/
|
|
5480
|
+
authenticationRetry = 0;
|
|
5481
|
+
/**
|
|
5482
|
+
* Resolved when admission is completed.
|
|
5483
|
+
*/
|
|
5484
|
+
completedTrigger = new Trigger6();
|
|
5485
|
+
/**
|
|
5486
|
+
* Held to allow only one invitation flow at a time to be active.
|
|
5487
|
+
*/
|
|
5488
|
+
_invitationFlowLock = null;
|
|
5489
|
+
constructor(_invitationFlowMutex, _callbacks) {
|
|
5490
|
+
super({
|
|
5491
|
+
requested: {
|
|
5492
|
+
InvitationHostService: schema5.getService("dxos.halo.invitations.InvitationHostService")
|
|
5493
|
+
},
|
|
5494
|
+
exposed: {
|
|
5495
|
+
InvitationHostService: schema5.getService("dxos.halo.invitations.InvitationHostService")
|
|
5496
|
+
}
|
|
5497
|
+
}), this._invitationFlowMutex = _invitationFlowMutex, this._callbacks = _callbacks;
|
|
5498
|
+
}
|
|
5623
5499
|
hasFlowLock() {
|
|
5624
5500
|
return this._invitationFlowLock != null;
|
|
5625
5501
|
}
|
|
@@ -5866,10 +5742,12 @@ var InvitationHostExtension = class extends RpcExtension3 {
|
|
|
5866
5742
|
C: (f, a) => f(...a)
|
|
5867
5743
|
});
|
|
5868
5744
|
if (this._remoteOptions?.role !== InvitationOptions2.Role.GUEST) {
|
|
5869
|
-
throw new InvalidInvitationExtensionRoleError2(
|
|
5870
|
-
|
|
5871
|
-
|
|
5872
|
-
|
|
5745
|
+
throw new InvalidInvitationExtensionRoleError2({
|
|
5746
|
+
context: {
|
|
5747
|
+
expected: InvitationOptions2.Role.GUEST,
|
|
5748
|
+
remoteOptions: this._remoteOptions,
|
|
5749
|
+
remotePeerId: context.remotePeerId
|
|
5750
|
+
}
|
|
5873
5751
|
});
|
|
5874
5752
|
}
|
|
5875
5753
|
this._callbacks.onStateUpdate(Invitation5.State.CONNECTED);
|
|
@@ -5914,37 +5792,12 @@ var InvitationHostExtension = class extends RpcExtension3 {
|
|
|
5914
5792
|
this._invitationFlowLock = null;
|
|
5915
5793
|
log16.verbose("invitation flow lock released", void 0, {
|
|
5916
5794
|
F: __dxlog_file20,
|
|
5917
|
-
L:
|
|
5795
|
+
L: 301,
|
|
5918
5796
|
S: this,
|
|
5919
5797
|
C: (f, a) => f(...a)
|
|
5920
5798
|
});
|
|
5921
5799
|
}
|
|
5922
5800
|
}
|
|
5923
|
-
constructor(_invitationFlowMutex, _callbacks) {
|
|
5924
|
-
super({
|
|
5925
|
-
requested: {
|
|
5926
|
-
InvitationHostService: schema5.getService("dxos.halo.invitations.InvitationHostService")
|
|
5927
|
-
},
|
|
5928
|
-
exposed: {
|
|
5929
|
-
InvitationHostService: schema5.getService("dxos.halo.invitations.InvitationHostService")
|
|
5930
|
-
}
|
|
5931
|
-
}), _define_property18(this, "_invitationFlowMutex", void 0), _define_property18(this, "_callbacks", void 0), /**
|
|
5932
|
-
* @internal
|
|
5933
|
-
*/
|
|
5934
|
-
_define_property18(this, "_ctx", void 0), _define_property18(this, "_remoteOptions", void 0), _define_property18(this, "_remoteOptionsTrigger", void 0), _define_property18(this, "_challenge", void 0), _define_property18(this, "guestProfile", void 0), _define_property18(this, "authenticationPassed", void 0), /**
|
|
5935
|
-
* Retry counter for SHARED_SECRET authentication method.
|
|
5936
|
-
*/
|
|
5937
|
-
_define_property18(this, "authenticationRetry", void 0), /**
|
|
5938
|
-
* Resolved when admission is completed.
|
|
5939
|
-
*/
|
|
5940
|
-
_define_property18(this, "completedTrigger", void 0), /**
|
|
5941
|
-
* Held to allow only one invitation flow at a time to be active.
|
|
5942
|
-
*/
|
|
5943
|
-
_define_property18(this, "_invitationFlowLock", void 0), this._invitationFlowMutex = _invitationFlowMutex, this._callbacks = _callbacks, this._ctx = new Context8(void 0, {
|
|
5944
|
-
F: __dxlog_file20,
|
|
5945
|
-
L: 57
|
|
5946
|
-
}), this._remoteOptionsTrigger = new Trigger6(), this._challenge = void 0, this.guestProfile = void 0, this.authenticationPassed = false, this.authenticationRetry = 0, this.completedTrigger = new Trigger6(), this._invitationFlowLock = null;
|
|
5947
|
-
}
|
|
5948
5801
|
};
|
|
5949
5802
|
var isAuthenticationRequired = (invitation) => invitation.authMethod !== Invitation5.AuthMethod.NONE;
|
|
5950
5803
|
|
|
@@ -6050,21 +5903,22 @@ import { PublicKey as PublicKey10 } from "@dxos/keys";
|
|
|
6050
5903
|
import { log as log18 } from "@dxos/log";
|
|
6051
5904
|
import { InvitationOptions as InvitationOptions3 } from "@dxos/protocols/proto/dxos/halo/invitations";
|
|
6052
5905
|
import { ComplexSet as ComplexSet4 } from "@dxos/util";
|
|
6053
|
-
function _define_property19(obj, key, value) {
|
|
6054
|
-
if (key in obj) {
|
|
6055
|
-
Object.defineProperty(obj, key, {
|
|
6056
|
-
value,
|
|
6057
|
-
enumerable: true,
|
|
6058
|
-
configurable: true,
|
|
6059
|
-
writable: true
|
|
6060
|
-
});
|
|
6061
|
-
} else {
|
|
6062
|
-
obj[key] = value;
|
|
6063
|
-
}
|
|
6064
|
-
return obj;
|
|
6065
|
-
}
|
|
6066
5906
|
var __dxlog_file22 = "/__w/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitation-topology.ts";
|
|
6067
5907
|
var InvitationTopology = class {
|
|
5908
|
+
_role;
|
|
5909
|
+
_controller;
|
|
5910
|
+
/**
|
|
5911
|
+
* Peers we tried to establish a connection with.
|
|
5912
|
+
* In invitation flow peers are assigned random ids when they join the swarm, so we'll retry
|
|
5913
|
+
* a peer if they reload an invitation.
|
|
5914
|
+
*
|
|
5915
|
+
* Consider keeping a separate set for peers we know are hosts and have some retry timeout
|
|
5916
|
+
* for guests we failed an invitation flow with (potentially due to a network error).
|
|
5917
|
+
*/
|
|
5918
|
+
_seenPeers = new ComplexSet4(PublicKey10.hash);
|
|
5919
|
+
constructor(_role) {
|
|
5920
|
+
this._role = _role;
|
|
5921
|
+
}
|
|
6068
5922
|
init(controller) {
|
|
6069
5923
|
invariant16(!this._controller, "Already initialized.", {
|
|
6070
5924
|
F: __dxlog_file22,
|
|
@@ -6129,33 +5983,24 @@ var InvitationTopology = class {
|
|
|
6129
5983
|
toString() {
|
|
6130
5984
|
return `InvitationTopology(${this._role === InvitationOptions3.Role.GUEST ? "guest" : "host"})`;
|
|
6131
5985
|
}
|
|
6132
|
-
constructor(_role) {
|
|
6133
|
-
_define_property19(this, "_role", void 0);
|
|
6134
|
-
_define_property19(this, "_controller", void 0);
|
|
6135
|
-
_define_property19(this, "_seenPeers", void 0);
|
|
6136
|
-
this._role = _role;
|
|
6137
|
-
this._seenPeers = new ComplexSet4(PublicKey10.hash);
|
|
6138
|
-
}
|
|
6139
5986
|
};
|
|
6140
5987
|
|
|
6141
5988
|
// src/packlets/invitations/invitations-handler.ts
|
|
6142
|
-
function _define_property20(obj, key, value) {
|
|
6143
|
-
if (key in obj) {
|
|
6144
|
-
Object.defineProperty(obj, key, {
|
|
6145
|
-
value,
|
|
6146
|
-
enumerable: true,
|
|
6147
|
-
configurable: true,
|
|
6148
|
-
writable: true
|
|
6149
|
-
});
|
|
6150
|
-
} else {
|
|
6151
|
-
obj[key] = value;
|
|
6152
|
-
}
|
|
6153
|
-
return obj;
|
|
6154
|
-
}
|
|
6155
5989
|
var __dxlog_file23 = "/__w/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitations-handler.ts";
|
|
6156
5990
|
var metrics = _trace.metrics;
|
|
6157
5991
|
var MAX_DELEGATED_INVITATION_HOST_TRIES = 3;
|
|
6158
5992
|
var InvitationsHandler = class {
|
|
5993
|
+
_networkManager;
|
|
5994
|
+
_edgeClient;
|
|
5995
|
+
_connectionParams;
|
|
5996
|
+
/**
|
|
5997
|
+
* @internal
|
|
5998
|
+
*/
|
|
5999
|
+
constructor(_networkManager, _edgeClient, _connectionParams) {
|
|
6000
|
+
this._networkManager = _networkManager;
|
|
6001
|
+
this._edgeClient = _edgeClient;
|
|
6002
|
+
this._connectionParams = _connectionParams;
|
|
6003
|
+
}
|
|
6159
6004
|
handleInvitationFlow(ctx, stream, protocol, invitation) {
|
|
6160
6005
|
log19.verbose("dxos.sdk.invitations-handler.handleInvitationFlow", {
|
|
6161
6006
|
state: invitation.state,
|
|
@@ -6726,22 +6571,13 @@ var InvitationsHandler = class {
|
|
|
6726
6571
|
throw new Error(`Authentication failed with code: ${response.status}`);
|
|
6727
6572
|
}
|
|
6728
6573
|
}
|
|
6729
|
-
/**
|
|
6730
|
-
* @internal
|
|
6731
|
-
*/
|
|
6732
|
-
constructor(_networkManager, _edgeClient, _connectionParams) {
|
|
6733
|
-
_define_property20(this, "_networkManager", void 0);
|
|
6734
|
-
_define_property20(this, "_edgeClient", void 0);
|
|
6735
|
-
_define_property20(this, "_connectionParams", void 0);
|
|
6736
|
-
this._networkManager = _networkManager;
|
|
6737
|
-
this._edgeClient = _edgeClient;
|
|
6738
|
-
this._connectionParams = _connectionParams;
|
|
6739
|
-
}
|
|
6740
6574
|
};
|
|
6741
6575
|
var checkInvitation = (protocol, invitation) => {
|
|
6742
6576
|
const expiresOn = getExpirationTime(invitation);
|
|
6743
6577
|
if (expiresOn && expiresOn.getTime() < Date.now()) {
|
|
6744
|
-
return new InvalidInvitationError(
|
|
6578
|
+
return new InvalidInvitationError({
|
|
6579
|
+
message: "Invitation already expired."
|
|
6580
|
+
});
|
|
6745
6581
|
}
|
|
6746
6582
|
return protocol.checkInvitation(invitation);
|
|
6747
6583
|
};
|
|
@@ -6757,20 +6593,11 @@ var createAdmissionKeypair = () => {
|
|
|
6757
6593
|
import { Stream as Stream9 } from "@dxos/codec-protobuf/stream";
|
|
6758
6594
|
import { QueryInvitationsResponse } from "@dxos/protocols/proto/dxos/client/services";
|
|
6759
6595
|
import { trace as trace8 } from "@dxos/tracing";
|
|
6760
|
-
function _define_property21(obj, key, value) {
|
|
6761
|
-
if (key in obj) {
|
|
6762
|
-
Object.defineProperty(obj, key, {
|
|
6763
|
-
value,
|
|
6764
|
-
enumerable: true,
|
|
6765
|
-
configurable: true,
|
|
6766
|
-
writable: true
|
|
6767
|
-
});
|
|
6768
|
-
} else {
|
|
6769
|
-
obj[key] = value;
|
|
6770
|
-
}
|
|
6771
|
-
return obj;
|
|
6772
|
-
}
|
|
6773
6596
|
var InvitationsServiceImpl = class {
|
|
6597
|
+
_invitationsManager;
|
|
6598
|
+
constructor(_invitationsManager) {
|
|
6599
|
+
this._invitationsManager = _invitationsManager;
|
|
6600
|
+
}
|
|
6774
6601
|
// TODO(burdon): Guest/host label.
|
|
6775
6602
|
getLoggingContext() {
|
|
6776
6603
|
return {};
|
|
@@ -6862,10 +6689,6 @@ var InvitationsServiceImpl = class {
|
|
|
6862
6689
|
});
|
|
6863
6690
|
});
|
|
6864
6691
|
}
|
|
6865
|
-
constructor(_invitationsManager) {
|
|
6866
|
-
_define_property21(this, "_invitationsManager", void 0);
|
|
6867
|
-
this._invitationsManager = _invitationsManager;
|
|
6868
|
-
}
|
|
6869
6692
|
};
|
|
6870
6693
|
|
|
6871
6694
|
// src/packlets/invitations/space-invitation-protocol.ts
|
|
@@ -6876,21 +6699,18 @@ import { log as log20 } from "@dxos/log";
|
|
|
6876
6699
|
import { AlreadyJoinedError as AlreadyJoinedError3, AuthorizationError as AuthorizationError2, InvalidInvitationError as InvalidInvitationError2, SpaceNotFoundError as SpaceNotFoundError2 } from "@dxos/protocols";
|
|
6877
6700
|
import { Invitation as Invitation8 } from "@dxos/protocols/proto/dxos/client/services";
|
|
6878
6701
|
import { SpaceMember as SpaceMember6 } from "@dxos/protocols/proto/dxos/halo/credentials";
|
|
6879
|
-
function _define_property22(obj, key, value) {
|
|
6880
|
-
if (key in obj) {
|
|
6881
|
-
Object.defineProperty(obj, key, {
|
|
6882
|
-
value,
|
|
6883
|
-
enumerable: true,
|
|
6884
|
-
configurable: true,
|
|
6885
|
-
writable: true
|
|
6886
|
-
});
|
|
6887
|
-
} else {
|
|
6888
|
-
obj[key] = value;
|
|
6889
|
-
}
|
|
6890
|
-
return obj;
|
|
6891
|
-
}
|
|
6892
6702
|
var __dxlog_file24 = "/__w/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/space-invitation-protocol.ts";
|
|
6893
6703
|
var SpaceInvitationProtocol = class {
|
|
6704
|
+
_spaceManager;
|
|
6705
|
+
_signingContext;
|
|
6706
|
+
_keyring;
|
|
6707
|
+
_spaceKey;
|
|
6708
|
+
constructor(_spaceManager, _signingContext, _keyring, _spaceKey) {
|
|
6709
|
+
this._spaceManager = _spaceManager;
|
|
6710
|
+
this._signingContext = _signingContext;
|
|
6711
|
+
this._keyring = _keyring;
|
|
6712
|
+
this._spaceKey = _spaceKey;
|
|
6713
|
+
}
|
|
6894
6714
|
toJSON() {
|
|
6895
6715
|
return {
|
|
6896
6716
|
kind: "space",
|
|
@@ -6900,21 +6720,25 @@ var SpaceInvitationProtocol = class {
|
|
|
6900
6720
|
}
|
|
6901
6721
|
checkCanInviteNewMembers() {
|
|
6902
6722
|
if (this._spaceKey == null) {
|
|
6903
|
-
return new InvalidInvitationError2(
|
|
6723
|
+
return new InvalidInvitationError2({
|
|
6724
|
+
message: "No spaceKey was provided for a space invitation."
|
|
6725
|
+
});
|
|
6904
6726
|
}
|
|
6905
6727
|
const space = this._spaceManager.spaces.get(this._spaceKey);
|
|
6906
6728
|
if (space == null) {
|
|
6907
6729
|
return new SpaceNotFoundError2(this._spaceKey);
|
|
6908
6730
|
}
|
|
6909
6731
|
if (!space?.inner.spaceState.hasMembershipManagementPermission(this._signingContext.identityKey)) {
|
|
6910
|
-
return new AuthorizationError2(
|
|
6732
|
+
return new AuthorizationError2({
|
|
6733
|
+
message: "No member management permission."
|
|
6734
|
+
});
|
|
6911
6735
|
}
|
|
6912
6736
|
return void 0;
|
|
6913
6737
|
}
|
|
6914
6738
|
getInvitationContext() {
|
|
6915
6739
|
invariant18(this._spaceKey, void 0, {
|
|
6916
6740
|
F: __dxlog_file24,
|
|
6917
|
-
L:
|
|
6741
|
+
L: 60,
|
|
6918
6742
|
S: this,
|
|
6919
6743
|
A: [
|
|
6920
6744
|
"this._spaceKey",
|
|
@@ -6924,7 +6748,7 @@ var SpaceInvitationProtocol = class {
|
|
|
6924
6748
|
const space = this._spaceManager.spaces.get(this._spaceKey);
|
|
6925
6749
|
invariant18(space, void 0, {
|
|
6926
6750
|
F: __dxlog_file24,
|
|
6927
|
-
L:
|
|
6751
|
+
L: 62,
|
|
6928
6752
|
S: this,
|
|
6929
6753
|
A: [
|
|
6930
6754
|
"space",
|
|
@@ -6940,7 +6764,7 @@ var SpaceInvitationProtocol = class {
|
|
|
6940
6764
|
async admit(invitation, request, guestProfile) {
|
|
6941
6765
|
invariant18(this._spaceKey && request.space, void 0, {
|
|
6942
6766
|
F: __dxlog_file24,
|
|
6943
|
-
L:
|
|
6767
|
+
L: 75,
|
|
6944
6768
|
S: this,
|
|
6945
6769
|
A: [
|
|
6946
6770
|
"this._spaceKey && request.space",
|
|
@@ -6952,7 +6776,7 @@ var SpaceInvitationProtocol = class {
|
|
|
6952
6776
|
guest: request.space.deviceKey
|
|
6953
6777
|
}, {
|
|
6954
6778
|
F: __dxlog_file24,
|
|
6955
|
-
L:
|
|
6779
|
+
L: 76,
|
|
6956
6780
|
S: this,
|
|
6957
6781
|
C: (f, a) => f(...a)
|
|
6958
6782
|
});
|
|
@@ -6974,7 +6798,7 @@ var SpaceInvitationProtocol = class {
|
|
|
6974
6798
|
async delegate(invitation) {
|
|
6975
6799
|
invariant18(this._spaceKey, void 0, {
|
|
6976
6800
|
F: __dxlog_file24,
|
|
6977
|
-
L:
|
|
6801
|
+
L: 96,
|
|
6978
6802
|
S: this,
|
|
6979
6803
|
A: [
|
|
6980
6804
|
"this._spaceKey",
|
|
@@ -6984,7 +6808,7 @@ var SpaceInvitationProtocol = class {
|
|
|
6984
6808
|
const space = this._spaceManager.spaces.get(this._spaceKey);
|
|
6985
6809
|
invariant18(space, void 0, {
|
|
6986
6810
|
F: __dxlog_file24,
|
|
6987
|
-
L:
|
|
6811
|
+
L: 98,
|
|
6988
6812
|
S: this,
|
|
6989
6813
|
A: [
|
|
6990
6814
|
"space",
|
|
@@ -6994,7 +6818,7 @@ var SpaceInvitationProtocol = class {
|
|
|
6994
6818
|
if (invitation.authMethod === Invitation8.AuthMethod.KNOWN_PUBLIC_KEY) {
|
|
6995
6819
|
invariant18(invitation.guestKeypair?.publicKey, void 0, {
|
|
6996
6820
|
F: __dxlog_file24,
|
|
6997
|
-
L:
|
|
6821
|
+
L: 100,
|
|
6998
6822
|
S: this,
|
|
6999
6823
|
A: [
|
|
7000
6824
|
"invitation.guestKeypair?.publicKey",
|
|
@@ -7007,7 +6831,7 @@ var SpaceInvitationProtocol = class {
|
|
|
7007
6831
|
id: invitation.invitationId
|
|
7008
6832
|
}, {
|
|
7009
6833
|
F: __dxlog_file24,
|
|
7010
|
-
L:
|
|
6834
|
+
L: 103,
|
|
7011
6835
|
S: this,
|
|
7012
6836
|
C: (f, a) => f(...a)
|
|
7013
6837
|
});
|
|
@@ -7022,7 +6846,7 @@ var SpaceInvitationProtocol = class {
|
|
|
7022
6846
|
});
|
|
7023
6847
|
invariant18(credential.credential, void 0, {
|
|
7024
6848
|
F: __dxlog_file24,
|
|
7025
|
-
L:
|
|
6849
|
+
L: 121,
|
|
7026
6850
|
S: this,
|
|
7027
6851
|
A: [
|
|
7028
6852
|
"credential.credential",
|
|
@@ -7037,7 +6861,7 @@ var SpaceInvitationProtocol = class {
|
|
|
7037
6861
|
async cancelDelegation(invitation) {
|
|
7038
6862
|
invariant18(this._spaceKey, void 0, {
|
|
7039
6863
|
F: __dxlog_file24,
|
|
7040
|
-
L:
|
|
6864
|
+
L: 127,
|
|
7041
6865
|
S: this,
|
|
7042
6866
|
A: [
|
|
7043
6867
|
"this._spaceKey",
|
|
@@ -7046,7 +6870,7 @@ var SpaceInvitationProtocol = class {
|
|
|
7046
6870
|
});
|
|
7047
6871
|
invariant18(invitation.type === Invitation8.Type.DELEGATED && invitation.delegationCredentialId, void 0, {
|
|
7048
6872
|
F: __dxlog_file24,
|
|
7049
|
-
L:
|
|
6873
|
+
L: 128,
|
|
7050
6874
|
S: this,
|
|
7051
6875
|
A: [
|
|
7052
6876
|
"invitation.type === Invitation.Type.DELEGATED && invitation.delegationCredentialId",
|
|
@@ -7056,7 +6880,7 @@ var SpaceInvitationProtocol = class {
|
|
|
7056
6880
|
const space = this._spaceManager.spaces.get(this._spaceKey);
|
|
7057
6881
|
invariant18(space, void 0, {
|
|
7058
6882
|
F: __dxlog_file24,
|
|
7059
|
-
L:
|
|
6883
|
+
L: 130,
|
|
7060
6884
|
S: this,
|
|
7061
6885
|
A: [
|
|
7062
6886
|
"space",
|
|
@@ -7068,14 +6892,14 @@ var SpaceInvitationProtocol = class {
|
|
|
7068
6892
|
id: invitation.invitationId
|
|
7069
6893
|
}, {
|
|
7070
6894
|
F: __dxlog_file24,
|
|
7071
|
-
L:
|
|
6895
|
+
L: 132,
|
|
7072
6896
|
S: this,
|
|
7073
6897
|
C: (f, a) => f(...a)
|
|
7074
6898
|
});
|
|
7075
6899
|
const credential = await createCancelDelegatedSpaceInvitationCredential(this._signingContext.credentialSigner, space.key, invitation.delegationCredentialId);
|
|
7076
6900
|
invariant18(credential.credential, void 0, {
|
|
7077
6901
|
F: __dxlog_file24,
|
|
7078
|
-
L:
|
|
6902
|
+
L: 139,
|
|
7079
6903
|
S: this,
|
|
7080
6904
|
A: [
|
|
7081
6905
|
"credential.credential",
|
|
@@ -7088,10 +6912,14 @@ var SpaceInvitationProtocol = class {
|
|
|
7088
6912
|
}
|
|
7089
6913
|
checkInvitation(invitation) {
|
|
7090
6914
|
if (invitation.spaceKey == null) {
|
|
7091
|
-
return new InvalidInvitationError2(
|
|
6915
|
+
return new InvalidInvitationError2({
|
|
6916
|
+
message: "No spaceKey was provided for a space invitation."
|
|
6917
|
+
});
|
|
7092
6918
|
}
|
|
7093
6919
|
if (this._spaceManager.spaces.has(invitation.spaceKey)) {
|
|
7094
|
-
return new AlreadyJoinedError3(
|
|
6920
|
+
return new AlreadyJoinedError3({
|
|
6921
|
+
message: "Already joined space."
|
|
6922
|
+
});
|
|
7095
6923
|
}
|
|
7096
6924
|
}
|
|
7097
6925
|
createIntroduction() {
|
|
@@ -7114,7 +6942,7 @@ var SpaceInvitationProtocol = class {
|
|
|
7114
6942
|
async accept(response) {
|
|
7115
6943
|
invariant18(response.space, void 0, {
|
|
7116
6944
|
F: __dxlog_file24,
|
|
7117
|
-
L:
|
|
6945
|
+
L: 174,
|
|
7118
6946
|
S: this,
|
|
7119
6947
|
A: [
|
|
7120
6948
|
"response.space",
|
|
@@ -7125,7 +6953,7 @@ var SpaceInvitationProtocol = class {
|
|
|
7125
6953
|
const assertion = getCredentialAssertion5(credential);
|
|
7126
6954
|
invariant18(assertion["@type"] === "dxos.halo.credentials.SpaceMember", "Invalid credential", {
|
|
7127
6955
|
F: __dxlog_file24,
|
|
7128
|
-
L:
|
|
6956
|
+
L: 177,
|
|
7129
6957
|
S: this,
|
|
7130
6958
|
A: [
|
|
7131
6959
|
"assertion['@type'] === 'dxos.halo.credentials.SpaceMember'",
|
|
@@ -7134,7 +6962,7 @@ var SpaceInvitationProtocol = class {
|
|
|
7134
6962
|
});
|
|
7135
6963
|
invariant18(credential.subject.id.equals(this._signingContext.identityKey), void 0, {
|
|
7136
6964
|
F: __dxlog_file24,
|
|
7137
|
-
L:
|
|
6965
|
+
L: 178,
|
|
7138
6966
|
S: this,
|
|
7139
6967
|
A: [
|
|
7140
6968
|
"credential.subject.id.equals(this._signingContext.identityKey)",
|
|
@@ -7142,7 +6970,9 @@ var SpaceInvitationProtocol = class {
|
|
|
7142
6970
|
]
|
|
7143
6971
|
});
|
|
7144
6972
|
if (this._spaceManager.spaces.has(assertion.spaceKey)) {
|
|
7145
|
-
throw new AlreadyJoinedError3(
|
|
6973
|
+
throw new AlreadyJoinedError3({
|
|
6974
|
+
message: "Already joined space."
|
|
6975
|
+
});
|
|
7146
6976
|
}
|
|
7147
6977
|
await this._spaceManager.acceptSpace({
|
|
7148
6978
|
spaceKey: assertion.spaceKey,
|
|
@@ -7155,16 +6985,6 @@ var SpaceInvitationProtocol = class {
|
|
|
7155
6985
|
spaceKey: assertion.spaceKey
|
|
7156
6986
|
};
|
|
7157
6987
|
}
|
|
7158
|
-
constructor(_spaceManager, _signingContext, _keyring, _spaceKey) {
|
|
7159
|
-
_define_property22(this, "_spaceManager", void 0);
|
|
7160
|
-
_define_property22(this, "_signingContext", void 0);
|
|
7161
|
-
_define_property22(this, "_keyring", void 0);
|
|
7162
|
-
_define_property22(this, "_spaceKey", void 0);
|
|
7163
|
-
this._spaceManager = _spaceManager;
|
|
7164
|
-
this._signingContext = _signingContext;
|
|
7165
|
-
this._keyring = _keyring;
|
|
7166
|
-
this._spaceKey = _spaceKey;
|
|
7167
|
-
}
|
|
7168
6988
|
};
|
|
7169
6989
|
|
|
7170
6990
|
// src/packlets/invitations/invitations-manager.ts
|
|
@@ -7178,21 +6998,25 @@ import { PublicKey as PublicKey12 } from "@dxos/keys";
|
|
|
7178
6998
|
import { log as log21 } from "@dxos/log";
|
|
7179
6999
|
import { Invitation as Invitation9 } from "@dxos/protocols/proto/dxos/client/services";
|
|
7180
7000
|
import { SpaceMember as SpaceMember7 } from "@dxos/protocols/proto/dxos/halo/credentials";
|
|
7181
|
-
function _define_property23(obj, key, value) {
|
|
7182
|
-
if (key in obj) {
|
|
7183
|
-
Object.defineProperty(obj, key, {
|
|
7184
|
-
value,
|
|
7185
|
-
enumerable: true,
|
|
7186
|
-
configurable: true,
|
|
7187
|
-
writable: true
|
|
7188
|
-
});
|
|
7189
|
-
} else {
|
|
7190
|
-
obj[key] = value;
|
|
7191
|
-
}
|
|
7192
|
-
return obj;
|
|
7193
|
-
}
|
|
7194
7001
|
var __dxlog_file25 = "/__w/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitations-manager.ts";
|
|
7195
7002
|
var InvitationsManager = class {
|
|
7003
|
+
_invitationsHandler;
|
|
7004
|
+
_getHandler;
|
|
7005
|
+
_metadataStore;
|
|
7006
|
+
_createInvitations = /* @__PURE__ */ new Map();
|
|
7007
|
+
_acceptInvitations = /* @__PURE__ */ new Map();
|
|
7008
|
+
invitationCreated = new Event8();
|
|
7009
|
+
invitationAccepted = new Event8();
|
|
7010
|
+
removedCreated = new Event8();
|
|
7011
|
+
removedAccepted = new Event8();
|
|
7012
|
+
saved = new Event8();
|
|
7013
|
+
_persistentInvitationsLoadedEvent = new Event8();
|
|
7014
|
+
_persistentInvitationsLoaded = false;
|
|
7015
|
+
constructor(_invitationsHandler, _getHandler, _metadataStore) {
|
|
7016
|
+
this._invitationsHandler = _invitationsHandler;
|
|
7017
|
+
this._getHandler = _getHandler;
|
|
7018
|
+
this._metadataStore = _metadataStore;
|
|
7019
|
+
}
|
|
7196
7020
|
async createInvitation(options) {
|
|
7197
7021
|
if (options.invitationId) {
|
|
7198
7022
|
const existingInvitation = this._createInvitations.get(options.invitationId);
|
|
@@ -7536,51 +7360,12 @@ var InvitationsManager = class {
|
|
|
7536
7360
|
}, () => {
|
|
7537
7361
|
}, callback);
|
|
7538
7362
|
}
|
|
7539
|
-
constructor(_invitationsHandler, _getHandler, _metadataStore) {
|
|
7540
|
-
_define_property23(this, "_invitationsHandler", void 0);
|
|
7541
|
-
_define_property23(this, "_getHandler", void 0);
|
|
7542
|
-
_define_property23(this, "_metadataStore", void 0);
|
|
7543
|
-
_define_property23(this, "_createInvitations", void 0);
|
|
7544
|
-
_define_property23(this, "_acceptInvitations", void 0);
|
|
7545
|
-
_define_property23(this, "invitationCreated", void 0);
|
|
7546
|
-
_define_property23(this, "invitationAccepted", void 0);
|
|
7547
|
-
_define_property23(this, "removedCreated", void 0);
|
|
7548
|
-
_define_property23(this, "removedAccepted", void 0);
|
|
7549
|
-
_define_property23(this, "saved", void 0);
|
|
7550
|
-
_define_property23(this, "_persistentInvitationsLoadedEvent", void 0);
|
|
7551
|
-
_define_property23(this, "_persistentInvitationsLoaded", void 0);
|
|
7552
|
-
this._invitationsHandler = _invitationsHandler;
|
|
7553
|
-
this._getHandler = _getHandler;
|
|
7554
|
-
this._metadataStore = _metadataStore;
|
|
7555
|
-
this._createInvitations = /* @__PURE__ */ new Map();
|
|
7556
|
-
this._acceptInvitations = /* @__PURE__ */ new Map();
|
|
7557
|
-
this.invitationCreated = new Event8();
|
|
7558
|
-
this.invitationAccepted = new Event8();
|
|
7559
|
-
this.removedCreated = new Event8();
|
|
7560
|
-
this.removedAccepted = new Event8();
|
|
7561
|
-
this.saved = new Event8();
|
|
7562
|
-
this._persistentInvitationsLoadedEvent = new Event8();
|
|
7563
|
-
this._persistentInvitationsLoaded = false;
|
|
7564
|
-
}
|
|
7565
7363
|
};
|
|
7566
7364
|
|
|
7567
7365
|
// src/packlets/locks/browser.ts
|
|
7568
7366
|
import { Trigger as Trigger8, asyncTimeout as asyncTimeout2 } from "@dxos/async";
|
|
7569
7367
|
import { RESOURCE_LOCK_TIMEOUT } from "@dxos/client-protocol";
|
|
7570
7368
|
import { log as log22, logInfo as logInfo3 } from "@dxos/log";
|
|
7571
|
-
function _define_property24(obj, key, value) {
|
|
7572
|
-
if (key in obj) {
|
|
7573
|
-
Object.defineProperty(obj, key, {
|
|
7574
|
-
value,
|
|
7575
|
-
enumerable: true,
|
|
7576
|
-
configurable: true,
|
|
7577
|
-
writable: true
|
|
7578
|
-
});
|
|
7579
|
-
} else {
|
|
7580
|
-
obj[key] = value;
|
|
7581
|
-
}
|
|
7582
|
-
return obj;
|
|
7583
|
-
}
|
|
7584
7369
|
function _ts_decorate7(decorators, target, key, desc) {
|
|
7585
7370
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
7586
7371
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -7589,6 +7374,17 @@ function _ts_decorate7(decorators, target, key, desc) {
|
|
|
7589
7374
|
}
|
|
7590
7375
|
var __dxlog_file26 = "/__w/dxos/dxos/packages/sdk/client-services/src/packlets/locks/browser.ts";
|
|
7591
7376
|
var Lock = class {
|
|
7377
|
+
_broadcastChannel = new BroadcastChannel("vault-resource-lock");
|
|
7378
|
+
_lockKey;
|
|
7379
|
+
_onAcquire;
|
|
7380
|
+
_onRelease;
|
|
7381
|
+
_releaseTrigger = new Trigger8();
|
|
7382
|
+
constructor({ lockKey, onAcquire, onRelease }) {
|
|
7383
|
+
this._lockKey = lockKey;
|
|
7384
|
+
this._onAcquire = onAcquire;
|
|
7385
|
+
this._onRelease = onRelease;
|
|
7386
|
+
this._broadcastChannel.onmessage = this._onMessage.bind(this);
|
|
7387
|
+
}
|
|
7592
7388
|
get lockKey() {
|
|
7593
7389
|
return this._lockKey;
|
|
7594
7390
|
}
|
|
@@ -7677,17 +7473,6 @@ var Lock = class {
|
|
|
7677
7473
|
C: (f, a) => f(...a)
|
|
7678
7474
|
});
|
|
7679
7475
|
}
|
|
7680
|
-
constructor({ lockKey, onAcquire, onRelease }) {
|
|
7681
|
-
_define_property24(this, "_broadcastChannel", new BroadcastChannel("vault-resource-lock"));
|
|
7682
|
-
_define_property24(this, "_lockKey", void 0);
|
|
7683
|
-
_define_property24(this, "_onAcquire", void 0);
|
|
7684
|
-
_define_property24(this, "_onRelease", void 0);
|
|
7685
|
-
_define_property24(this, "_releaseTrigger", new Trigger8());
|
|
7686
|
-
this._lockKey = lockKey;
|
|
7687
|
-
this._onAcquire = onAcquire;
|
|
7688
|
-
this._onRelease = onRelease;
|
|
7689
|
-
this._broadcastChannel.onmessage = this._onMessage.bind(this);
|
|
7690
|
-
}
|
|
7691
7476
|
};
|
|
7692
7477
|
_ts_decorate7([
|
|
7693
7478
|
logInfo3
|
|
@@ -7701,19 +7486,6 @@ import { Stream as Stream10 } from "@dxos/codec-protobuf";
|
|
|
7701
7486
|
import { raise as raise2 } from "@dxos/debug";
|
|
7702
7487
|
import { RpcPeer, parseMethodName } from "@dxos/rpc";
|
|
7703
7488
|
import { MapCounter, trace as trace9 } from "@dxos/tracing";
|
|
7704
|
-
function _define_property25(obj, key, value) {
|
|
7705
|
-
if (key in obj) {
|
|
7706
|
-
Object.defineProperty(obj, key, {
|
|
7707
|
-
value,
|
|
7708
|
-
enumerable: true,
|
|
7709
|
-
configurable: true,
|
|
7710
|
-
writable: true
|
|
7711
|
-
});
|
|
7712
|
-
} else {
|
|
7713
|
-
obj[key] = value;
|
|
7714
|
-
}
|
|
7715
|
-
return obj;
|
|
7716
|
-
}
|
|
7717
7489
|
function _ts_decorate8(decorators, target, key, desc) {
|
|
7718
7490
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
7719
7491
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -7721,33 +7493,16 @@ function _ts_decorate8(decorators, target, key, desc) {
|
|
|
7721
7493
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7722
7494
|
}
|
|
7723
7495
|
var ClientRpcServer = class {
|
|
7496
|
+
_serviceRegistry;
|
|
7497
|
+
_rpcPeer;
|
|
7498
|
+
_handlerCache = /* @__PURE__ */ new Map();
|
|
7499
|
+
_handleCall;
|
|
7500
|
+
_handleStream;
|
|
7501
|
+
_callMetrics = new MapCounter();
|
|
7724
7502
|
get _services() {
|
|
7725
7503
|
return Object.keys(this._serviceRegistry.services);
|
|
7726
7504
|
}
|
|
7727
|
-
async open() {
|
|
7728
|
-
await this._rpcPeer.open();
|
|
7729
|
-
}
|
|
7730
|
-
async close() {
|
|
7731
|
-
await this._rpcPeer.close();
|
|
7732
|
-
}
|
|
7733
|
-
_getServiceHandler(serviceName) {
|
|
7734
|
-
if (!this._handlerCache.has(serviceName)) {
|
|
7735
|
-
const [key, descriptor] = Object.entries(this._serviceRegistry.descriptors).find(([key2, descriptor2]) => descriptor2.name === serviceName) ?? raise2(new Error(`Service not available: ${serviceName}`));
|
|
7736
|
-
const service = this._serviceRegistry.services[key];
|
|
7737
|
-
if (!service) {
|
|
7738
|
-
throw new Error(`Service not available: ${serviceName}`);
|
|
7739
|
-
}
|
|
7740
|
-
this._handlerCache.set(serviceName, descriptor.createServer(service));
|
|
7741
|
-
}
|
|
7742
|
-
return this._handlerCache.get(serviceName);
|
|
7743
|
-
}
|
|
7744
7505
|
constructor(params) {
|
|
7745
|
-
_define_property25(this, "_serviceRegistry", void 0);
|
|
7746
|
-
_define_property25(this, "_rpcPeer", void 0);
|
|
7747
|
-
_define_property25(this, "_handlerCache", /* @__PURE__ */ new Map());
|
|
7748
|
-
_define_property25(this, "_handleCall", void 0);
|
|
7749
|
-
_define_property25(this, "_handleStream", void 0);
|
|
7750
|
-
_define_property25(this, "_callMetrics", new MapCounter());
|
|
7751
7506
|
const { serviceRegistry, handleCall, handleStream, ...rpcOptions } = params;
|
|
7752
7507
|
this._handleCall = handleCall;
|
|
7753
7508
|
this._handleStream = handleStream;
|
|
@@ -7779,6 +7534,23 @@ var ClientRpcServer = class {
|
|
|
7779
7534
|
}
|
|
7780
7535
|
});
|
|
7781
7536
|
}
|
|
7537
|
+
async open() {
|
|
7538
|
+
await this._rpcPeer.open();
|
|
7539
|
+
}
|
|
7540
|
+
async close() {
|
|
7541
|
+
await this._rpcPeer.close();
|
|
7542
|
+
}
|
|
7543
|
+
_getServiceHandler(serviceName) {
|
|
7544
|
+
if (!this._handlerCache.has(serviceName)) {
|
|
7545
|
+
const [key, descriptor] = Object.entries(this._serviceRegistry.descriptors).find(([key2, descriptor2]) => descriptor2.name === serviceName) ?? raise2(new Error(`Service not available: ${serviceName}`));
|
|
7546
|
+
const service = this._serviceRegistry.services[key];
|
|
7547
|
+
if (!service) {
|
|
7548
|
+
throw new Error(`Service not available: ${serviceName}`);
|
|
7549
|
+
}
|
|
7550
|
+
this._handlerCache.set(serviceName, descriptor.createServer(service));
|
|
7551
|
+
}
|
|
7552
|
+
return this._handlerCache.get(serviceName);
|
|
7553
|
+
}
|
|
7782
7554
|
};
|
|
7783
7555
|
_ts_decorate8([
|
|
7784
7556
|
trace9.metricsCounter()
|
|
@@ -7799,19 +7571,6 @@ import { log as log23 } from "@dxos/log";
|
|
|
7799
7571
|
import { EdgeAgentStatus, EdgeCallFailedError as EdgeCallFailedError3 } from "@dxos/protocols";
|
|
7800
7572
|
import { SpaceState as SpaceState5 } from "@dxos/protocols/proto/dxos/client/services";
|
|
7801
7573
|
import { EdgeReplicationSetting as EdgeReplicationSetting2 } from "@dxos/protocols/proto/dxos/echo/metadata";
|
|
7802
|
-
function _define_property26(obj, key, value) {
|
|
7803
|
-
if (key in obj) {
|
|
7804
|
-
Object.defineProperty(obj, key, {
|
|
7805
|
-
value,
|
|
7806
|
-
enumerable: true,
|
|
7807
|
-
configurable: true,
|
|
7808
|
-
writable: true
|
|
7809
|
-
});
|
|
7810
|
-
} else {
|
|
7811
|
-
obj[key] = value;
|
|
7812
|
-
}
|
|
7813
|
-
return obj;
|
|
7814
|
-
}
|
|
7815
7574
|
function _ts_decorate9(decorators, target, key, desc) {
|
|
7816
7575
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
7817
7576
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -7823,6 +7582,18 @@ var AGENT_STATUS_QUERY_RETRY_INTERVAL = 5e3;
|
|
|
7823
7582
|
var AGENT_STATUS_QUERY_RETRY_JITTER = 1e3;
|
|
7824
7583
|
var AGENT_FEED_ADDED_CHECK_INTERVAL_MS = 3e3;
|
|
7825
7584
|
var EdgeAgentManager = class extends Resource7 {
|
|
7585
|
+
_edgeFeatures;
|
|
7586
|
+
_edgeHttpClient;
|
|
7587
|
+
_dataSpaceManager;
|
|
7588
|
+
_identity;
|
|
7589
|
+
agentStatusChanged = new Event9();
|
|
7590
|
+
_agentDeviceKey;
|
|
7591
|
+
_agentStatus;
|
|
7592
|
+
_lastKnownDeviceCount = 0;
|
|
7593
|
+
_fetchAgentStatusTask;
|
|
7594
|
+
constructor(_edgeFeatures, _edgeHttpClient, _dataSpaceManager, _identity) {
|
|
7595
|
+
super(), this._edgeFeatures = _edgeFeatures, this._edgeHttpClient = _edgeHttpClient, this._dataSpaceManager = _dataSpaceManager, this._identity = _identity;
|
|
7596
|
+
}
|
|
7826
7597
|
get agentStatus() {
|
|
7827
7598
|
return this._agentStatus;
|
|
7828
7599
|
}
|
|
@@ -8031,9 +7802,6 @@ var EdgeAgentManager = class extends Resource7 {
|
|
|
8031
7802
|
C: (f, a) => f(...a)
|
|
8032
7803
|
});
|
|
8033
7804
|
}
|
|
8034
|
-
constructor(_edgeFeatures, _edgeHttpClient, _dataSpaceManager, _identity) {
|
|
8035
|
-
super(), _define_property26(this, "_edgeFeatures", void 0), _define_property26(this, "_edgeHttpClient", void 0), _define_property26(this, "_dataSpaceManager", void 0), _define_property26(this, "_identity", void 0), _define_property26(this, "agentStatusChanged", void 0), _define_property26(this, "_agentDeviceKey", void 0), _define_property26(this, "_agentStatus", void 0), _define_property26(this, "_lastKnownDeviceCount", void 0), _define_property26(this, "_fetchAgentStatusTask", void 0), this._edgeFeatures = _edgeFeatures, this._edgeHttpClient = _edgeHttpClient, this._dataSpaceManager = _dataSpaceManager, this._identity = _identity, this.agentStatusChanged = new Event9(), this._lastKnownDeviceCount = 0;
|
|
8036
|
-
}
|
|
8037
7805
|
};
|
|
8038
7806
|
_ts_decorate9([
|
|
8039
7807
|
synchronized3
|
|
@@ -8043,26 +7811,27 @@ _ts_decorate9([
|
|
|
8043
7811
|
import { Stream as Stream11 } from "@dxos/codec-protobuf/stream";
|
|
8044
7812
|
import { EdgeAgentStatus as EdgeAgentStatus2 } from "@dxos/protocols";
|
|
8045
7813
|
import { EdgeStatus as EdgeStatus2, QueryAgentStatusResponse } from "@dxos/protocols/proto/dxos/client/services";
|
|
8046
|
-
function _define_property27(obj, key, value) {
|
|
8047
|
-
if (key in obj) {
|
|
8048
|
-
Object.defineProperty(obj, key, {
|
|
8049
|
-
value,
|
|
8050
|
-
enumerable: true,
|
|
8051
|
-
configurable: true,
|
|
8052
|
-
writable: true
|
|
8053
|
-
});
|
|
8054
|
-
} else {
|
|
8055
|
-
obj[key] = value;
|
|
8056
|
-
}
|
|
8057
|
-
return obj;
|
|
8058
|
-
}
|
|
8059
7814
|
var EdgeAgentServiceImpl = class {
|
|
7815
|
+
_agentManagerProvider;
|
|
7816
|
+
_edgeConnection;
|
|
7817
|
+
constructor(_agentManagerProvider, _edgeConnection) {
|
|
7818
|
+
this._agentManagerProvider = _agentManagerProvider;
|
|
7819
|
+
this._edgeConnection = _edgeConnection;
|
|
7820
|
+
}
|
|
8060
7821
|
// TODO(mykola): Reconcile with NetworkService.queryStatus.
|
|
8061
7822
|
queryEdgeStatus() {
|
|
8062
7823
|
return new Stream11(({ ctx, next }) => {
|
|
8063
7824
|
const update = () => {
|
|
8064
7825
|
next({
|
|
8065
|
-
status: this._edgeConnection?.status ??
|
|
7826
|
+
status: this._edgeConnection?.status ?? {
|
|
7827
|
+
state: EdgeStatus2.ConnectionState.NOT_CONNECTED,
|
|
7828
|
+
rtt: 0,
|
|
7829
|
+
uptime: 0,
|
|
7830
|
+
rateBytesUp: 0,
|
|
7831
|
+
rateBytesDown: 0,
|
|
7832
|
+
messagesSent: 0,
|
|
7833
|
+
messagesReceived: 0
|
|
7834
|
+
}
|
|
8066
7835
|
});
|
|
8067
7836
|
};
|
|
8068
7837
|
this._edgeConnection?.statusChanged.on(ctx, update);
|
|
@@ -8089,12 +7858,6 @@ var EdgeAgentServiceImpl = class {
|
|
|
8089
7858
|
});
|
|
8090
7859
|
});
|
|
8091
7860
|
}
|
|
8092
|
-
constructor(_agentManagerProvider, _edgeConnection) {
|
|
8093
|
-
_define_property27(this, "_agentManagerProvider", void 0);
|
|
8094
|
-
_define_property27(this, "_edgeConnection", void 0);
|
|
8095
|
-
this._agentManagerProvider = _agentManagerProvider;
|
|
8096
|
-
this._edgeConnection = _edgeConnection;
|
|
8097
|
-
}
|
|
8098
7861
|
};
|
|
8099
7862
|
var mapStatus = (agentStatus) => {
|
|
8100
7863
|
switch (agentStatus) {
|
|
@@ -8136,21 +7899,18 @@ import { log as log24 } from "@dxos/log";
|
|
|
8136
7899
|
import { EdgeAuthChallengeError as EdgeAuthChallengeError2 } from "@dxos/protocols";
|
|
8137
7900
|
import { schema as schema6 } from "@dxos/protocols/proto";
|
|
8138
7901
|
import { Timeframe as Timeframe5 } from "@dxos/timeframe";
|
|
8139
|
-
function _define_property28(obj, key, value) {
|
|
8140
|
-
if (key in obj) {
|
|
8141
|
-
Object.defineProperty(obj, key, {
|
|
8142
|
-
value,
|
|
8143
|
-
enumerable: true,
|
|
8144
|
-
configurable: true,
|
|
8145
|
-
writable: true
|
|
8146
|
-
});
|
|
8147
|
-
} else {
|
|
8148
|
-
obj[key] = value;
|
|
8149
|
-
}
|
|
8150
|
-
return obj;
|
|
8151
|
-
}
|
|
8152
7902
|
var __dxlog_file28 = "/__w/dxos/dxos/packages/sdk/client-services/src/packlets/identity/identity-recovery-manager.ts";
|
|
8153
7903
|
var EdgeIdentityRecoveryManager = class {
|
|
7904
|
+
_keyring;
|
|
7905
|
+
_edgeClient;
|
|
7906
|
+
_identityProvider;
|
|
7907
|
+
_acceptRecoveredIdentity;
|
|
7908
|
+
constructor(_keyring, _edgeClient, _identityProvider, _acceptRecoveredIdentity) {
|
|
7909
|
+
this._keyring = _keyring;
|
|
7910
|
+
this._edgeClient = _edgeClient;
|
|
7911
|
+
this._identityProvider = _identityProvider;
|
|
7912
|
+
this._acceptRecoveredIdentity = _acceptRecoveredIdentity;
|
|
7913
|
+
}
|
|
8154
7914
|
async createRecoveryCredential({ data }) {
|
|
8155
7915
|
const identity = this._identityProvider();
|
|
8156
7916
|
invariant21(identity, void 0, {
|
|
@@ -8343,16 +8103,6 @@ var EdgeIdentityRecoveryManager = class {
|
|
|
8343
8103
|
dataFeedKey: await this._keyring.createKey()
|
|
8344
8104
|
});
|
|
8345
8105
|
}
|
|
8346
|
-
constructor(_keyring, _edgeClient, _identityProvider, _acceptRecoveredIdentity) {
|
|
8347
|
-
_define_property28(this, "_keyring", void 0);
|
|
8348
|
-
_define_property28(this, "_edgeClient", void 0);
|
|
8349
|
-
_define_property28(this, "_identityProvider", void 0);
|
|
8350
|
-
_define_property28(this, "_acceptRecoveredIdentity", void 0);
|
|
8351
|
-
this._keyring = _keyring;
|
|
8352
|
-
this._edgeClient = _edgeClient;
|
|
8353
|
-
this._identityProvider = _identityProvider;
|
|
8354
|
-
this._acceptRecoveredIdentity = _acceptRecoveredIdentity;
|
|
8355
|
-
}
|
|
8356
8106
|
};
|
|
8357
8107
|
var decodeCredential = (credentialBase64) => {
|
|
8358
8108
|
const credentialBytes = Buffer.from(credentialBase64, "base64");
|
|
@@ -8361,19 +8111,6 @@ var decodeCredential = (credentialBase64) => {
|
|
|
8361
8111
|
};
|
|
8362
8112
|
|
|
8363
8113
|
// src/packlets/services/service-context.ts
|
|
8364
|
-
function _define_property29(obj, key, value) {
|
|
8365
|
-
if (key in obj) {
|
|
8366
|
-
Object.defineProperty(obj, key, {
|
|
8367
|
-
value,
|
|
8368
|
-
enumerable: true,
|
|
8369
|
-
configurable: true,
|
|
8370
|
-
writable: true
|
|
8371
|
-
});
|
|
8372
|
-
} else {
|
|
8373
|
-
obj[key] = value;
|
|
8374
|
-
}
|
|
8375
|
-
return obj;
|
|
8376
|
-
}
|
|
8377
8114
|
function _ts_decorate10(decorators, target, key, desc) {
|
|
8378
8115
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
8379
8116
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -8447,18 +8184,101 @@ function _ts_dispose_resources4(env) {
|
|
|
8447
8184
|
}
|
|
8448
8185
|
var __dxlog_file29 = "/__w/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-context.ts";
|
|
8449
8186
|
var ServiceContext = class extends Resource8 {
|
|
8450
|
-
|
|
8451
|
-
|
|
8452
|
-
|
|
8453
|
-
|
|
8454
|
-
|
|
8455
|
-
|
|
8456
|
-
|
|
8457
|
-
|
|
8458
|
-
|
|
8459
|
-
|
|
8460
|
-
|
|
8461
|
-
|
|
8187
|
+
storage;
|
|
8188
|
+
level;
|
|
8189
|
+
networkManager;
|
|
8190
|
+
signalManager;
|
|
8191
|
+
_edgeConnection;
|
|
8192
|
+
_edgeHttpClient;
|
|
8193
|
+
_runtimeParams;
|
|
8194
|
+
_edgeFeatures;
|
|
8195
|
+
_edgeIdentityUpdateMutex = new Mutex4();
|
|
8196
|
+
initialized = new Trigger9();
|
|
8197
|
+
metadataStore;
|
|
8198
|
+
blobStore;
|
|
8199
|
+
feedStore;
|
|
8200
|
+
keyring;
|
|
8201
|
+
spaceManager;
|
|
8202
|
+
identityManager;
|
|
8203
|
+
recoveryManager;
|
|
8204
|
+
invitations;
|
|
8205
|
+
invitationsManager;
|
|
8206
|
+
echoHost;
|
|
8207
|
+
_meshReplicator = void 0;
|
|
8208
|
+
_echoEdgeReplicator = void 0;
|
|
8209
|
+
// Initialized after identity is initialized.
|
|
8210
|
+
dataSpaceManager;
|
|
8211
|
+
edgeAgentManager;
|
|
8212
|
+
_handlerFactories = /* @__PURE__ */ new Map();
|
|
8213
|
+
_deviceSpaceSync;
|
|
8214
|
+
_instanceId = PublicKey15.random().toHex();
|
|
8215
|
+
constructor(storage, level, networkManager, signalManager, _edgeConnection, _edgeHttpClient, _runtimeParams, _edgeFeatures) {
|
|
8216
|
+
super(), this.storage = storage, this.level = level, this.networkManager = networkManager, this.signalManager = signalManager, this._edgeConnection = _edgeConnection, this._edgeHttpClient = _edgeHttpClient, this._runtimeParams = _runtimeParams, this._edgeFeatures = _edgeFeatures;
|
|
8217
|
+
this.metadataStore = new MetadataStore(storage.createDirectory("metadata"));
|
|
8218
|
+
this.blobStore = new BlobStore(storage.createDirectory("blobs"));
|
|
8219
|
+
this.keyring = new Keyring(storage.createDirectory("keyring"));
|
|
8220
|
+
this.feedStore = new FeedStore({
|
|
8221
|
+
factory: new FeedFactory({
|
|
8222
|
+
root: storage.createDirectory("feeds"),
|
|
8223
|
+
signer: this.keyring,
|
|
8224
|
+
hypercore: {
|
|
8225
|
+
valueEncoding,
|
|
8226
|
+
stats: true
|
|
8227
|
+
}
|
|
8228
|
+
})
|
|
8229
|
+
});
|
|
8230
|
+
this.spaceManager = new SpaceManager({
|
|
8231
|
+
feedStore: this.feedStore,
|
|
8232
|
+
networkManager: this.networkManager,
|
|
8233
|
+
blobStore: this.blobStore,
|
|
8234
|
+
metadataStore: this.metadataStore,
|
|
8235
|
+
disableP2pReplication: this._runtimeParams?.disableP2pReplication
|
|
8236
|
+
});
|
|
8237
|
+
this.identityManager = new IdentityManager({
|
|
8238
|
+
metadataStore: this.metadataStore,
|
|
8239
|
+
keyring: this.keyring,
|
|
8240
|
+
feedStore: this.feedStore,
|
|
8241
|
+
spaceManager: this.spaceManager,
|
|
8242
|
+
devicePresenceOfflineTimeout: this._runtimeParams?.devicePresenceOfflineTimeout,
|
|
8243
|
+
devicePresenceAnnounceInterval: this._runtimeParams?.devicePresenceAnnounceInterval,
|
|
8244
|
+
edgeConnection: this._edgeConnection,
|
|
8245
|
+
edgeFeatures: this._edgeFeatures
|
|
8246
|
+
});
|
|
8247
|
+
this.recoveryManager = new EdgeIdentityRecoveryManager(this.keyring, this._edgeHttpClient, () => this.identityManager.identity, this._acceptIdentity.bind(this));
|
|
8248
|
+
this.echoHost = new EchoHost({
|
|
8249
|
+
kv: this.level,
|
|
8250
|
+
peerIdProvider: () => this.identityManager.identity?.deviceKey?.toHex(),
|
|
8251
|
+
getSpaceKeyByRootDocumentId: (documentId) => this.spaceManager.findSpaceByRootDocumentId(documentId)?.key,
|
|
8252
|
+
indexing: {
|
|
8253
|
+
vector: this._runtimeParams?.enableVectorIndexing
|
|
8254
|
+
}
|
|
8255
|
+
});
|
|
8256
|
+
this._meshReplicator = new MeshEchoReplicator();
|
|
8257
|
+
this.invitations = new InvitationsHandler(this.networkManager, this._edgeHttpClient, _runtimeParams?.invitationConnectionDefaultParams);
|
|
8258
|
+
this.invitationsManager = new InvitationsManager(this.invitations, (invitation) => this.getInvitationHandler(invitation), this.metadataStore);
|
|
8259
|
+
this._handlerFactories.set(Invitation10.Kind.DEVICE, () => new DeviceInvitationProtocol(this.keyring, () => this.identityManager.identity ?? failUndefined2(), this._acceptIdentity.bind(this)));
|
|
8260
|
+
if (!this._runtimeParams?.disableP2pReplication) {
|
|
8261
|
+
this._meshReplicator = new MeshEchoReplicator();
|
|
8262
|
+
}
|
|
8263
|
+
if (this._edgeConnection && this._edgeFeatures?.echoReplicator && this._edgeHttpClient) {
|
|
8264
|
+
this._echoEdgeReplicator = new EchoEdgeReplicator({
|
|
8265
|
+
edgeConnection: this._edgeConnection,
|
|
8266
|
+
edgeHttpClient: this._edgeHttpClient
|
|
8267
|
+
});
|
|
8268
|
+
}
|
|
8269
|
+
}
|
|
8270
|
+
async _open(ctx) {
|
|
8271
|
+
await this._checkStorageVersion();
|
|
8272
|
+
log25("opening...", void 0, {
|
|
8273
|
+
F: __dxlog_file29,
|
|
8274
|
+
L: 204,
|
|
8275
|
+
S: this,
|
|
8276
|
+
C: (f, a) => f(...a)
|
|
8277
|
+
});
|
|
8278
|
+
log25.trace("dxos.sdk.service-context.open", trace10.begin({
|
|
8279
|
+
id: this._instanceId
|
|
8280
|
+
}), {
|
|
8281
|
+
F: __dxlog_file29,
|
|
8462
8282
|
L: 205,
|
|
8463
8283
|
S: this,
|
|
8464
8284
|
C: (f, a) => f(...a)
|
|
@@ -8749,62 +8569,6 @@ var ServiceContext = class extends Resource8 {
|
|
|
8749
8569
|
_ts_dispose_resources4(env);
|
|
8750
8570
|
}
|
|
8751
8571
|
}
|
|
8752
|
-
constructor(storage, level, networkManager, signalManager, _edgeConnection, _edgeHttpClient, _runtimeParams, _edgeFeatures) {
|
|
8753
|
-
super(), _define_property29(this, "storage", void 0), _define_property29(this, "level", void 0), _define_property29(this, "networkManager", void 0), _define_property29(this, "signalManager", void 0), _define_property29(this, "_edgeConnection", void 0), _define_property29(this, "_edgeHttpClient", void 0), _define_property29(this, "_runtimeParams", void 0), _define_property29(this, "_edgeFeatures", void 0), _define_property29(this, "_edgeIdentityUpdateMutex", void 0), _define_property29(this, "initialized", void 0), _define_property29(this, "metadataStore", void 0), _define_property29(this, "blobStore", void 0), _define_property29(this, "feedStore", void 0), _define_property29(this, "keyring", void 0), _define_property29(this, "spaceManager", void 0), _define_property29(this, "identityManager", void 0), _define_property29(this, "recoveryManager", void 0), _define_property29(this, "invitations", void 0), _define_property29(this, "invitationsManager", void 0), _define_property29(this, "echoHost", void 0), _define_property29(this, "_meshReplicator", void 0), _define_property29(this, "_echoEdgeReplicator", void 0), // Initialized after identity is initialized.
|
|
8754
|
-
_define_property29(this, "dataSpaceManager", void 0), _define_property29(this, "edgeAgentManager", void 0), _define_property29(this, "_handlerFactories", void 0), _define_property29(this, "_deviceSpaceSync", void 0), _define_property29(this, "_instanceId", void 0), this.storage = storage, this.level = level, this.networkManager = networkManager, this.signalManager = signalManager, this._edgeConnection = _edgeConnection, this._edgeHttpClient = _edgeHttpClient, this._runtimeParams = _runtimeParams, this._edgeFeatures = _edgeFeatures, this._edgeIdentityUpdateMutex = new Mutex4(), this.initialized = new Trigger9(), this._meshReplicator = void 0, this._echoEdgeReplicator = void 0, this._handlerFactories = /* @__PURE__ */ new Map(), this._instanceId = PublicKey15.random().toHex();
|
|
8755
|
-
this.metadataStore = new MetadataStore(storage.createDirectory("metadata"));
|
|
8756
|
-
this.blobStore = new BlobStore(storage.createDirectory("blobs"));
|
|
8757
|
-
this.keyring = new Keyring(storage.createDirectory("keyring"));
|
|
8758
|
-
this.feedStore = new FeedStore({
|
|
8759
|
-
factory: new FeedFactory({
|
|
8760
|
-
root: storage.createDirectory("feeds"),
|
|
8761
|
-
signer: this.keyring,
|
|
8762
|
-
hypercore: {
|
|
8763
|
-
valueEncoding,
|
|
8764
|
-
stats: true
|
|
8765
|
-
}
|
|
8766
|
-
})
|
|
8767
|
-
});
|
|
8768
|
-
this.spaceManager = new SpaceManager({
|
|
8769
|
-
feedStore: this.feedStore,
|
|
8770
|
-
networkManager: this.networkManager,
|
|
8771
|
-
blobStore: this.blobStore,
|
|
8772
|
-
metadataStore: this.metadataStore,
|
|
8773
|
-
disableP2pReplication: this._runtimeParams?.disableP2pReplication
|
|
8774
|
-
});
|
|
8775
|
-
this.identityManager = new IdentityManager({
|
|
8776
|
-
metadataStore: this.metadataStore,
|
|
8777
|
-
keyring: this.keyring,
|
|
8778
|
-
feedStore: this.feedStore,
|
|
8779
|
-
spaceManager: this.spaceManager,
|
|
8780
|
-
devicePresenceOfflineTimeout: this._runtimeParams?.devicePresenceOfflineTimeout,
|
|
8781
|
-
devicePresenceAnnounceInterval: this._runtimeParams?.devicePresenceAnnounceInterval,
|
|
8782
|
-
edgeConnection: this._edgeConnection,
|
|
8783
|
-
edgeFeatures: this._edgeFeatures
|
|
8784
|
-
});
|
|
8785
|
-
this.recoveryManager = new EdgeIdentityRecoveryManager(this.keyring, this._edgeHttpClient, () => this.identityManager.identity, this._acceptIdentity.bind(this));
|
|
8786
|
-
this.echoHost = new EchoHost({
|
|
8787
|
-
kv: this.level,
|
|
8788
|
-
peerIdProvider: () => this.identityManager.identity?.deviceKey?.toHex(),
|
|
8789
|
-
getSpaceKeyByRootDocumentId: (documentId) => this.spaceManager.findSpaceByRootDocumentId(documentId)?.key,
|
|
8790
|
-
indexing: {
|
|
8791
|
-
vector: this._runtimeParams?.enableVectorIndexing
|
|
8792
|
-
}
|
|
8793
|
-
});
|
|
8794
|
-
this._meshReplicator = new MeshEchoReplicator();
|
|
8795
|
-
this.invitations = new InvitationsHandler(this.networkManager, this._edgeHttpClient, _runtimeParams?.invitationConnectionDefaultParams);
|
|
8796
|
-
this.invitationsManager = new InvitationsManager(this.invitations, (invitation) => this.getInvitationHandler(invitation), this.metadataStore);
|
|
8797
|
-
this._handlerFactories.set(Invitation10.Kind.DEVICE, () => new DeviceInvitationProtocol(this.keyring, () => this.identityManager.identity ?? failUndefined2(), this._acceptIdentity.bind(this)));
|
|
8798
|
-
if (!this._runtimeParams?.disableP2pReplication) {
|
|
8799
|
-
this._meshReplicator = new MeshEchoReplicator();
|
|
8800
|
-
}
|
|
8801
|
-
if (this._edgeConnection && this._edgeFeatures?.echoReplicator && this._edgeHttpClient) {
|
|
8802
|
-
this._echoEdgeReplicator = new EchoEdgeReplicator({
|
|
8803
|
-
edgeConnection: this._edgeConnection,
|
|
8804
|
-
edgeHttpClient: this._edgeHttpClient
|
|
8805
|
-
});
|
|
8806
|
-
}
|
|
8807
|
-
}
|
|
8808
8572
|
};
|
|
8809
8573
|
_ts_decorate10([
|
|
8810
8574
|
Trace3.span()
|
|
@@ -8840,16 +8604,24 @@ var StorageDriver = Runtime2.Client.Storage.StorageDriver;
|
|
|
8840
8604
|
var createStorageObjects = (config) => {
|
|
8841
8605
|
const { persistent = false, keyStore, dataStore } = config ?? {};
|
|
8842
8606
|
if (persistent && dataStore === StorageDriver.RAM) {
|
|
8843
|
-
throw new InvalidConfigError(
|
|
8607
|
+
throw new InvalidConfigError({
|
|
8608
|
+
message: "RAM storage cannot be used in persistent mode."
|
|
8609
|
+
});
|
|
8844
8610
|
}
|
|
8845
8611
|
if (!persistent && dataStore !== void 0 && dataStore !== StorageDriver.RAM) {
|
|
8846
|
-
throw new InvalidConfigError(
|
|
8612
|
+
throw new InvalidConfigError({
|
|
8613
|
+
message: "Cannot use a persistent storage in not persistent mode."
|
|
8614
|
+
});
|
|
8847
8615
|
}
|
|
8848
8616
|
if (persistent && keyStore === StorageDriver.RAM) {
|
|
8849
|
-
throw new InvalidConfigError(
|
|
8617
|
+
throw new InvalidConfigError({
|
|
8618
|
+
message: "RAM key storage cannot be used in persistent mode."
|
|
8619
|
+
});
|
|
8850
8620
|
}
|
|
8851
8621
|
if (!persistent && keyStore !== StorageDriver.RAM && keyStore !== void 0) {
|
|
8852
|
-
throw new InvalidConfigError(
|
|
8622
|
+
throw new InvalidConfigError({
|
|
8623
|
+
message: "Cannot use a persistent key storage in not persistent mode."
|
|
8624
|
+
});
|
|
8853
8625
|
}
|
|
8854
8626
|
return {
|
|
8855
8627
|
storage: createStorage({
|
|
@@ -9051,20 +8823,14 @@ var importProfileData = async ({ storage, level }, archive) => {
|
|
|
9051
8823
|
};
|
|
9052
8824
|
|
|
9053
8825
|
// src/packlets/services/service-registry.ts
|
|
9054
|
-
function _define_property30(obj, key, value) {
|
|
9055
|
-
if (key in obj) {
|
|
9056
|
-
Object.defineProperty(obj, key, {
|
|
9057
|
-
value,
|
|
9058
|
-
enumerable: true,
|
|
9059
|
-
configurable: true,
|
|
9060
|
-
writable: true
|
|
9061
|
-
});
|
|
9062
|
-
} else {
|
|
9063
|
-
obj[key] = value;
|
|
9064
|
-
}
|
|
9065
|
-
return obj;
|
|
9066
|
-
}
|
|
9067
8826
|
var ServiceRegistry = class {
|
|
8827
|
+
_serviceBundle;
|
|
8828
|
+
_handlers;
|
|
8829
|
+
// prettier-ignore
|
|
8830
|
+
constructor(_serviceBundle, _handlers = {}) {
|
|
8831
|
+
this._serviceBundle = _serviceBundle;
|
|
8832
|
+
this._handlers = _handlers;
|
|
8833
|
+
}
|
|
9068
8834
|
get descriptors() {
|
|
9069
8835
|
return this._serviceBundle;
|
|
9070
8836
|
}
|
|
@@ -9080,13 +8846,6 @@ var ServiceRegistry = class {
|
|
|
9080
8846
|
removeService(name) {
|
|
9081
8847
|
delete this._handlers[name];
|
|
9082
8848
|
}
|
|
9083
|
-
// prettier-ignore
|
|
9084
|
-
constructor(_serviceBundle, _handlers = {}) {
|
|
9085
|
-
_define_property30(this, "_serviceBundle", void 0);
|
|
9086
|
-
_define_property30(this, "_handlers", void 0);
|
|
9087
|
-
this._serviceBundle = _serviceBundle;
|
|
9088
|
-
this._handlers = _handlers;
|
|
9089
|
-
}
|
|
9090
8849
|
};
|
|
9091
8850
|
|
|
9092
8851
|
// src/packlets/services/service-host.ts
|
|
@@ -9109,21 +8868,14 @@ import { SubscriptionList as SubscriptionList3 } from "@dxos/async";
|
|
|
9109
8868
|
import { Stream as Stream12 } from "@dxos/codec-protobuf/stream";
|
|
9110
8869
|
import { invariant as invariant24 } from "@dxos/invariant";
|
|
9111
8870
|
import { Device as Device2, DeviceKind as DeviceKind2, EdgeStatus as EdgeStatus3 } from "@dxos/protocols/proto/dxos/client/services";
|
|
9112
|
-
function _define_property31(obj, key, value) {
|
|
9113
|
-
if (key in obj) {
|
|
9114
|
-
Object.defineProperty(obj, key, {
|
|
9115
|
-
value,
|
|
9116
|
-
enumerable: true,
|
|
9117
|
-
configurable: true,
|
|
9118
|
-
writable: true
|
|
9119
|
-
});
|
|
9120
|
-
} else {
|
|
9121
|
-
obj[key] = value;
|
|
9122
|
-
}
|
|
9123
|
-
return obj;
|
|
9124
|
-
}
|
|
9125
8871
|
var __dxlog_file31 = "/__w/dxos/dxos/packages/sdk/client-services/src/packlets/devices/devices-service.ts";
|
|
9126
8872
|
var DevicesServiceImpl = class {
|
|
8873
|
+
_identityManager;
|
|
8874
|
+
_edgeConnection;
|
|
8875
|
+
constructor(_identityManager, _edgeConnection) {
|
|
8876
|
+
this._identityManager = _identityManager;
|
|
8877
|
+
this._edgeConnection = _edgeConnection;
|
|
8878
|
+
}
|
|
9127
8879
|
async updateDevice(profile) {
|
|
9128
8880
|
return this._identityManager.updateDeviceProfile(profile);
|
|
9129
8881
|
}
|
|
@@ -9153,7 +8905,7 @@ var DevicesServiceImpl = class {
|
|
|
9153
8905
|
if (isMe) {
|
|
9154
8906
|
presence = Device2.PresenceState.ONLINE;
|
|
9155
8907
|
} else if (profile.os?.toUpperCase() === "EDGE") {
|
|
9156
|
-
presence = this._edgeConnection?.status === EdgeStatus3.CONNECTED ? Device2.PresenceState.ONLINE : Device2.PresenceState.OFFLINE;
|
|
8908
|
+
presence = this._edgeConnection?.status.state === EdgeStatus3.ConnectionState.CONNECTED ? Device2.PresenceState.ONLINE : Device2.PresenceState.OFFLINE;
|
|
9157
8909
|
} else {
|
|
9158
8910
|
presence = peers.some((peer) => peer.identityKey.equals(key)) ? Device2.PresenceState.ONLINE : Device2.PresenceState.OFFLINE;
|
|
9159
8911
|
}
|
|
@@ -9201,12 +8953,6 @@ var DevicesServiceImpl = class {
|
|
|
9201
8953
|
return () => subscriptions.clear();
|
|
9202
8954
|
});
|
|
9203
8955
|
}
|
|
9204
|
-
constructor(_identityManager, _edgeConnection) {
|
|
9205
|
-
_define_property31(this, "_identityManager", void 0);
|
|
9206
|
-
_define_property31(this, "_edgeConnection", void 0);
|
|
9207
|
-
this._identityManager = _identityManager;
|
|
9208
|
-
this._edgeConnection = _edgeConnection;
|
|
9209
|
-
}
|
|
9210
8956
|
};
|
|
9211
8957
|
|
|
9212
8958
|
// src/packlets/identity/contacts-service.ts
|
|
@@ -9214,20 +8960,15 @@ import { SubscriptionList as SubscriptionList4, UpdateScheduler as UpdateSchedul
|
|
|
9214
8960
|
import { Stream as Stream13 } from "@dxos/codec-protobuf/stream";
|
|
9215
8961
|
import { PublicKey as PublicKey17 } from "@dxos/keys";
|
|
9216
8962
|
import { ComplexMap as ComplexMap5, ComplexSet as ComplexSet6 } from "@dxos/util";
|
|
9217
|
-
function _define_property32(obj, key, value) {
|
|
9218
|
-
if (key in obj) {
|
|
9219
|
-
Object.defineProperty(obj, key, {
|
|
9220
|
-
value,
|
|
9221
|
-
enumerable: true,
|
|
9222
|
-
configurable: true,
|
|
9223
|
-
writable: true
|
|
9224
|
-
});
|
|
9225
|
-
} else {
|
|
9226
|
-
obj[key] = value;
|
|
9227
|
-
}
|
|
9228
|
-
return obj;
|
|
9229
|
-
}
|
|
9230
8963
|
var ContactsServiceImpl = class {
|
|
8964
|
+
_identityManager;
|
|
8965
|
+
_spaceManager;
|
|
8966
|
+
_dataSpaceManagerProvider;
|
|
8967
|
+
constructor(_identityManager, _spaceManager, _dataSpaceManagerProvider) {
|
|
8968
|
+
this._identityManager = _identityManager;
|
|
8969
|
+
this._spaceManager = _spaceManager;
|
|
8970
|
+
this._dataSpaceManagerProvider = _dataSpaceManagerProvider;
|
|
8971
|
+
}
|
|
9231
8972
|
async getContacts() {
|
|
9232
8973
|
const identity = this._identityManager.identity;
|
|
9233
8974
|
if (identity == null) {
|
|
@@ -9249,8 +8990,7 @@ var ContactsServiceImpl = class {
|
|
|
9249
8990
|
}
|
|
9250
8991
|
const existing = acc.get(memberInfo.key);
|
|
9251
8992
|
if (existing != null) {
|
|
9252
|
-
|
|
9253
|
-
(_existing = existing).profile ?? (_existing.profile = memberInfo.profile);
|
|
8993
|
+
existing.profile ??= memberInfo.profile;
|
|
9254
8994
|
existing.commonSpaces?.push(spaceKey);
|
|
9255
8995
|
} else {
|
|
9256
8996
|
acc.set(memberInfo.key, {
|
|
@@ -9299,14 +9039,6 @@ var ContactsServiceImpl = class {
|
|
|
9299
9039
|
});
|
|
9300
9040
|
});
|
|
9301
9041
|
}
|
|
9302
|
-
constructor(_identityManager, _spaceManager, _dataSpaceManagerProvider) {
|
|
9303
|
-
_define_property32(this, "_identityManager", void 0);
|
|
9304
|
-
_define_property32(this, "_spaceManager", void 0);
|
|
9305
|
-
_define_property32(this, "_dataSpaceManagerProvider", void 0);
|
|
9306
|
-
this._identityManager = _identityManager;
|
|
9307
|
-
this._spaceManager = _spaceManager;
|
|
9308
|
-
this._dataSpaceManagerProvider = _dataSpaceManagerProvider;
|
|
9309
|
-
}
|
|
9310
9042
|
};
|
|
9311
9043
|
|
|
9312
9044
|
// src/packlets/logging/logging-service.ts
|
|
@@ -9316,20 +9048,10 @@ import { PublicKey as PublicKey18 } from "@dxos/keys";
|
|
|
9316
9048
|
import { getContextFromEntry, log as log27 } from "@dxos/log";
|
|
9317
9049
|
import { QueryLogsRequest } from "@dxos/protocols/proto/dxos/client/services";
|
|
9318
9050
|
import { getDebugName, jsonify, numericalValues, tracer } from "@dxos/util";
|
|
9319
|
-
function _define_property33(obj, key, value) {
|
|
9320
|
-
if (key in obj) {
|
|
9321
|
-
Object.defineProperty(obj, key, {
|
|
9322
|
-
value,
|
|
9323
|
-
enumerable: true,
|
|
9324
|
-
configurable: true,
|
|
9325
|
-
writable: true
|
|
9326
|
-
});
|
|
9327
|
-
} else {
|
|
9328
|
-
obj[key] = value;
|
|
9329
|
-
}
|
|
9330
|
-
return obj;
|
|
9331
|
-
}
|
|
9332
9051
|
var LoggingServiceImpl = class {
|
|
9052
|
+
_logs = new Event10();
|
|
9053
|
+
_started = Date.now();
|
|
9054
|
+
_sessionId = PublicKey18.random().toHex();
|
|
9333
9055
|
async open() {
|
|
9334
9056
|
log27.runtimeConfig.processors.push(this._logProcessor);
|
|
9335
9057
|
}
|
|
@@ -9420,14 +9142,9 @@ var LoggingServiceImpl = class {
|
|
|
9420
9142
|
this._logs.on(ctx, handler);
|
|
9421
9143
|
});
|
|
9422
9144
|
}
|
|
9423
|
-
|
|
9424
|
-
|
|
9425
|
-
|
|
9426
|
-
_define_property33(this, "_sessionId", PublicKey18.random().toHex());
|
|
9427
|
-
_define_property33(this, "_logProcessor", (_config, entry2) => {
|
|
9428
|
-
this._logs.emit(entry2);
|
|
9429
|
-
});
|
|
9430
|
-
}
|
|
9145
|
+
_logProcessor = (_config, entry2) => {
|
|
9146
|
+
this._logs.emit(entry2);
|
|
9147
|
+
};
|
|
9431
9148
|
};
|
|
9432
9149
|
var matchFilter = (filter, level, path2, options) => {
|
|
9433
9150
|
switch (options) {
|
|
@@ -9449,20 +9166,15 @@ var LOG_PROCESSING = 0;
|
|
|
9449
9166
|
|
|
9450
9167
|
// src/packlets/network/network-service.ts
|
|
9451
9168
|
import { Stream as Stream15 } from "@dxos/codec-protobuf/stream";
|
|
9452
|
-
function _define_property34(obj, key, value) {
|
|
9453
|
-
if (key in obj) {
|
|
9454
|
-
Object.defineProperty(obj, key, {
|
|
9455
|
-
value,
|
|
9456
|
-
enumerable: true,
|
|
9457
|
-
configurable: true,
|
|
9458
|
-
writable: true
|
|
9459
|
-
});
|
|
9460
|
-
} else {
|
|
9461
|
-
obj[key] = value;
|
|
9462
|
-
}
|
|
9463
|
-
return obj;
|
|
9464
|
-
}
|
|
9465
9169
|
var NetworkServiceImpl = class {
|
|
9170
|
+
networkManager;
|
|
9171
|
+
signalManager;
|
|
9172
|
+
edgeConnection;
|
|
9173
|
+
constructor(networkManager, signalManager, edgeConnection) {
|
|
9174
|
+
this.networkManager = networkManager;
|
|
9175
|
+
this.signalManager = signalManager;
|
|
9176
|
+
this.edgeConnection = edgeConnection;
|
|
9177
|
+
}
|
|
9466
9178
|
queryStatus() {
|
|
9467
9179
|
return new Stream15(({ ctx, next }) => {
|
|
9468
9180
|
const update = () => {
|
|
@@ -9513,34 +9225,27 @@ var NetworkServiceImpl = class {
|
|
|
9513
9225
|
});
|
|
9514
9226
|
});
|
|
9515
9227
|
}
|
|
9516
|
-
constructor(networkManager, signalManager, edgeConnection) {
|
|
9517
|
-
_define_property34(this, "networkManager", void 0);
|
|
9518
|
-
_define_property34(this, "signalManager", void 0);
|
|
9519
|
-
_define_property34(this, "edgeConnection", void 0);
|
|
9520
|
-
this.networkManager = networkManager;
|
|
9521
|
-
this.signalManager = signalManager;
|
|
9522
|
-
this.edgeConnection = edgeConnection;
|
|
9523
|
-
}
|
|
9524
9228
|
};
|
|
9525
9229
|
|
|
9526
9230
|
// src/packlets/system/system-service.ts
|
|
9527
9231
|
import { Stream as Stream16 } from "@dxos/codec-protobuf/stream";
|
|
9528
9232
|
import { GetDiagnosticsRequest as GetDiagnosticsRequest2 } from "@dxos/protocols/proto/dxos/client/services";
|
|
9529
9233
|
import { jsonKeyReplacer as jsonKeyReplacer2 } from "@dxos/util";
|
|
9530
|
-
function _define_property35(obj, key, value) {
|
|
9531
|
-
if (key in obj) {
|
|
9532
|
-
Object.defineProperty(obj, key, {
|
|
9533
|
-
value,
|
|
9534
|
-
enumerable: true,
|
|
9535
|
-
configurable: true,
|
|
9536
|
-
writable: true
|
|
9537
|
-
});
|
|
9538
|
-
} else {
|
|
9539
|
-
obj[key] = value;
|
|
9540
|
-
}
|
|
9541
|
-
return obj;
|
|
9542
|
-
}
|
|
9543
9234
|
var SystemServiceImpl = class {
|
|
9235
|
+
_config;
|
|
9236
|
+
_statusUpdate;
|
|
9237
|
+
_getCurrentStatus;
|
|
9238
|
+
_onUpdateStatus;
|
|
9239
|
+
_onReset;
|
|
9240
|
+
_getDiagnostics;
|
|
9241
|
+
constructor({ config, statusUpdate, getDiagnostics, onUpdateStatus, getCurrentStatus, onReset }) {
|
|
9242
|
+
this._config = config;
|
|
9243
|
+
this._statusUpdate = statusUpdate;
|
|
9244
|
+
this._getCurrentStatus = getCurrentStatus;
|
|
9245
|
+
this._getDiagnostics = getDiagnostics;
|
|
9246
|
+
this._onUpdateStatus = onUpdateStatus;
|
|
9247
|
+
this._onReset = onReset;
|
|
9248
|
+
}
|
|
9544
9249
|
async getConfig() {
|
|
9545
9250
|
return (await this._config?.())?.values ?? {};
|
|
9546
9251
|
}
|
|
@@ -9583,36 +9288,9 @@ var SystemServiceImpl = class {
|
|
|
9583
9288
|
async reset() {
|
|
9584
9289
|
await this._onReset();
|
|
9585
9290
|
}
|
|
9586
|
-
constructor({ config, statusUpdate, getDiagnostics, onUpdateStatus, getCurrentStatus, onReset }) {
|
|
9587
|
-
_define_property35(this, "_config", void 0);
|
|
9588
|
-
_define_property35(this, "_statusUpdate", void 0);
|
|
9589
|
-
_define_property35(this, "_getCurrentStatus", void 0);
|
|
9590
|
-
_define_property35(this, "_onUpdateStatus", void 0);
|
|
9591
|
-
_define_property35(this, "_onReset", void 0);
|
|
9592
|
-
_define_property35(this, "_getDiagnostics", void 0);
|
|
9593
|
-
this._config = config;
|
|
9594
|
-
this._statusUpdate = statusUpdate;
|
|
9595
|
-
this._getCurrentStatus = getCurrentStatus;
|
|
9596
|
-
this._getDiagnostics = getDiagnostics;
|
|
9597
|
-
this._onUpdateStatus = onUpdateStatus;
|
|
9598
|
-
this._onReset = onReset;
|
|
9599
|
-
}
|
|
9600
9291
|
};
|
|
9601
9292
|
|
|
9602
9293
|
// src/packlets/services/service-host.ts
|
|
9603
|
-
function _define_property36(obj, key, value) {
|
|
9604
|
-
if (key in obj) {
|
|
9605
|
-
Object.defineProperty(obj, key, {
|
|
9606
|
-
value,
|
|
9607
|
-
enumerable: true,
|
|
9608
|
-
configurable: true,
|
|
9609
|
-
writable: true
|
|
9610
|
-
});
|
|
9611
|
-
} else {
|
|
9612
|
-
obj[key] = value;
|
|
9613
|
-
}
|
|
9614
|
-
return obj;
|
|
9615
|
-
}
|
|
9616
9294
|
function _ts_decorate11(decorators, target, key, desc) {
|
|
9617
9295
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
9618
9296
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -9621,6 +9299,94 @@ function _ts_decorate11(decorators, target, key, desc) {
|
|
|
9621
9299
|
}
|
|
9622
9300
|
var __dxlog_file32 = "/__w/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-host.ts";
|
|
9623
9301
|
var ClientServicesHost = class {
|
|
9302
|
+
_resourceLock;
|
|
9303
|
+
_serviceRegistry;
|
|
9304
|
+
_systemService;
|
|
9305
|
+
_loggingService;
|
|
9306
|
+
_tracingService = TRACE_PROCESSOR3.createTraceSender();
|
|
9307
|
+
_statusUpdate = new Event11();
|
|
9308
|
+
_config;
|
|
9309
|
+
_signalManager;
|
|
9310
|
+
_networkManager;
|
|
9311
|
+
_storage;
|
|
9312
|
+
_level;
|
|
9313
|
+
_callbacks;
|
|
9314
|
+
_devtoolsProxy;
|
|
9315
|
+
_edgeConnection = void 0;
|
|
9316
|
+
_edgeHttpClient = void 0;
|
|
9317
|
+
_serviceContext;
|
|
9318
|
+
_runtimeParams;
|
|
9319
|
+
diagnosticsBroadcastHandler;
|
|
9320
|
+
_opening = false;
|
|
9321
|
+
_open = false;
|
|
9322
|
+
_resetting = false;
|
|
9323
|
+
constructor({
|
|
9324
|
+
config,
|
|
9325
|
+
transportFactory,
|
|
9326
|
+
signalManager,
|
|
9327
|
+
storage,
|
|
9328
|
+
level,
|
|
9329
|
+
// TODO(wittjosiah): Turn this on by default.
|
|
9330
|
+
lockKey,
|
|
9331
|
+
callbacks,
|
|
9332
|
+
runtimeParams
|
|
9333
|
+
} = {}) {
|
|
9334
|
+
this._storage = storage;
|
|
9335
|
+
this._level = level;
|
|
9336
|
+
this._callbacks = callbacks;
|
|
9337
|
+
this._runtimeParams = runtimeParams ?? {};
|
|
9338
|
+
if (this._runtimeParams.disableP2pReplication === void 0) {
|
|
9339
|
+
this._runtimeParams.disableP2pReplication = config?.get("runtime.client.disableP2pReplication", false);
|
|
9340
|
+
}
|
|
9341
|
+
if (this._runtimeParams.enableVectorIndexing === void 0) {
|
|
9342
|
+
this._runtimeParams.enableVectorIndexing = config?.get("runtime.client.enableVectorIndexing", false);
|
|
9343
|
+
}
|
|
9344
|
+
if (config) {
|
|
9345
|
+
this.initialize({
|
|
9346
|
+
config,
|
|
9347
|
+
transportFactory,
|
|
9348
|
+
signalManager
|
|
9349
|
+
});
|
|
9350
|
+
}
|
|
9351
|
+
if (lockKey) {
|
|
9352
|
+
this._resourceLock = new Lock({
|
|
9353
|
+
lockKey,
|
|
9354
|
+
onAcquire: () => {
|
|
9355
|
+
if (!this._opening) {
|
|
9356
|
+
void this.open(new Context11(void 0, {
|
|
9357
|
+
F: __dxlog_file32,
|
|
9358
|
+
L: 143
|
|
9359
|
+
}));
|
|
9360
|
+
}
|
|
9361
|
+
},
|
|
9362
|
+
onRelease: () => this.close()
|
|
9363
|
+
});
|
|
9364
|
+
}
|
|
9365
|
+
this._systemService = new SystemServiceImpl({
|
|
9366
|
+
config: () => this._config,
|
|
9367
|
+
statusUpdate: this._statusUpdate,
|
|
9368
|
+
getCurrentStatus: () => this.isOpen && !this._resetting ? SystemStatus.ACTIVE : SystemStatus.INACTIVE,
|
|
9369
|
+
getDiagnostics: () => {
|
|
9370
|
+
return createDiagnostics(this._serviceRegistry.services, this._serviceContext, this._config);
|
|
9371
|
+
},
|
|
9372
|
+
onUpdateStatus: async (status) => {
|
|
9373
|
+
if (!this.isOpen && status === SystemStatus.ACTIVE) {
|
|
9374
|
+
await this._resourceLock?.acquire();
|
|
9375
|
+
} else if (this.isOpen && status === SystemStatus.INACTIVE) {
|
|
9376
|
+
await this._resourceLock?.release();
|
|
9377
|
+
}
|
|
9378
|
+
},
|
|
9379
|
+
onReset: async () => {
|
|
9380
|
+
await this.reset();
|
|
9381
|
+
}
|
|
9382
|
+
});
|
|
9383
|
+
this.diagnosticsBroadcastHandler = createCollectDiagnosticsBroadcastHandler(this._systemService);
|
|
9384
|
+
this._loggingService = new LoggingServiceImpl();
|
|
9385
|
+
this._serviceRegistry = new ServiceRegistry(clientServiceBundle, {
|
|
9386
|
+
SystemService: this._systemService,
|
|
9387
|
+
TracingService: this._tracingService
|
|
9388
|
+
});
|
|
9389
|
+
}
|
|
9624
9390
|
get isOpen() {
|
|
9625
9391
|
return this._open;
|
|
9626
9392
|
}
|
|
@@ -9894,10 +9660,22 @@ var ClientServicesHost = class {
|
|
|
9894
9660
|
this._resetting = true;
|
|
9895
9661
|
this._statusUpdate.emit();
|
|
9896
9662
|
await this._serviceContext?.close();
|
|
9663
|
+
try {
|
|
9664
|
+
await this._level.clear();
|
|
9665
|
+
} catch (err) {
|
|
9666
|
+
log28.warn("failed to clear leveldb during reset", {
|
|
9667
|
+
err
|
|
9668
|
+
}, {
|
|
9669
|
+
F: __dxlog_file32,
|
|
9670
|
+
L: 415,
|
|
9671
|
+
S: this,
|
|
9672
|
+
C: (f, a) => f(...a)
|
|
9673
|
+
});
|
|
9674
|
+
}
|
|
9897
9675
|
await this._storage.reset();
|
|
9898
9676
|
log28.info("reset", void 0, {
|
|
9899
9677
|
F: __dxlog_file32,
|
|
9900
|
-
L:
|
|
9678
|
+
L: 418,
|
|
9901
9679
|
S: this,
|
|
9902
9680
|
C: (f, a) => f(...a)
|
|
9903
9681
|
});
|
|
@@ -9905,7 +9683,7 @@ var ClientServicesHost = class {
|
|
|
9905
9683
|
id: traceId
|
|
9906
9684
|
}), {
|
|
9907
9685
|
F: __dxlog_file32,
|
|
9908
|
-
L:
|
|
9686
|
+
L: 419,
|
|
9909
9687
|
S: this,
|
|
9910
9688
|
C: (f, a) => f(...a)
|
|
9911
9689
|
});
|
|
@@ -9916,94 +9694,6 @@ var ClientServicesHost = class {
|
|
|
9916
9694
|
await this._serviceContext.initialized.wait();
|
|
9917
9695
|
return identity;
|
|
9918
9696
|
}
|
|
9919
|
-
constructor({
|
|
9920
|
-
config,
|
|
9921
|
-
transportFactory,
|
|
9922
|
-
signalManager,
|
|
9923
|
-
storage,
|
|
9924
|
-
level,
|
|
9925
|
-
// TODO(wittjosiah): Turn this on by default.
|
|
9926
|
-
lockKey,
|
|
9927
|
-
callbacks,
|
|
9928
|
-
runtimeParams
|
|
9929
|
-
} = {}) {
|
|
9930
|
-
_define_property36(this, "_resourceLock", void 0);
|
|
9931
|
-
_define_property36(this, "_serviceRegistry", void 0);
|
|
9932
|
-
_define_property36(this, "_systemService", void 0);
|
|
9933
|
-
_define_property36(this, "_loggingService", void 0);
|
|
9934
|
-
_define_property36(this, "_tracingService", TRACE_PROCESSOR3.createTraceSender());
|
|
9935
|
-
_define_property36(this, "_statusUpdate", new Event11());
|
|
9936
|
-
_define_property36(this, "_config", void 0);
|
|
9937
|
-
_define_property36(this, "_signalManager", void 0);
|
|
9938
|
-
_define_property36(this, "_networkManager", void 0);
|
|
9939
|
-
_define_property36(this, "_storage", void 0);
|
|
9940
|
-
_define_property36(this, "_level", void 0);
|
|
9941
|
-
_define_property36(this, "_callbacks", void 0);
|
|
9942
|
-
_define_property36(this, "_devtoolsProxy", void 0);
|
|
9943
|
-
_define_property36(this, "_edgeConnection", void 0);
|
|
9944
|
-
_define_property36(this, "_edgeHttpClient", void 0);
|
|
9945
|
-
_define_property36(this, "_serviceContext", void 0);
|
|
9946
|
-
_define_property36(this, "_runtimeParams", void 0);
|
|
9947
|
-
_define_property36(this, "diagnosticsBroadcastHandler", void 0);
|
|
9948
|
-
_define_property36(this, "_opening", false);
|
|
9949
|
-
_define_property36(this, "_open", false);
|
|
9950
|
-
_define_property36(this, "_resetting", false);
|
|
9951
|
-
this._storage = storage;
|
|
9952
|
-
this._level = level;
|
|
9953
|
-
this._callbacks = callbacks;
|
|
9954
|
-
this._runtimeParams = runtimeParams ?? {};
|
|
9955
|
-
if (this._runtimeParams.disableP2pReplication === void 0) {
|
|
9956
|
-
this._runtimeParams.disableP2pReplication = config?.get("runtime.client.disableP2pReplication", false);
|
|
9957
|
-
}
|
|
9958
|
-
if (this._runtimeParams.enableVectorIndexing === void 0) {
|
|
9959
|
-
this._runtimeParams.enableVectorIndexing = config?.get("runtime.client.enableVectorIndexing", false);
|
|
9960
|
-
}
|
|
9961
|
-
if (config) {
|
|
9962
|
-
this.initialize({
|
|
9963
|
-
config,
|
|
9964
|
-
transportFactory,
|
|
9965
|
-
signalManager
|
|
9966
|
-
});
|
|
9967
|
-
}
|
|
9968
|
-
if (lockKey) {
|
|
9969
|
-
this._resourceLock = new Lock({
|
|
9970
|
-
lockKey,
|
|
9971
|
-
onAcquire: () => {
|
|
9972
|
-
if (!this._opening) {
|
|
9973
|
-
void this.open(new Context11(void 0, {
|
|
9974
|
-
F: __dxlog_file32,
|
|
9975
|
-
L: 143
|
|
9976
|
-
}));
|
|
9977
|
-
}
|
|
9978
|
-
},
|
|
9979
|
-
onRelease: () => this.close()
|
|
9980
|
-
});
|
|
9981
|
-
}
|
|
9982
|
-
this._systemService = new SystemServiceImpl({
|
|
9983
|
-
config: () => this._config,
|
|
9984
|
-
statusUpdate: this._statusUpdate,
|
|
9985
|
-
getCurrentStatus: () => this.isOpen && !this._resetting ? SystemStatus.ACTIVE : SystemStatus.INACTIVE,
|
|
9986
|
-
getDiagnostics: () => {
|
|
9987
|
-
return createDiagnostics(this._serviceRegistry.services, this._serviceContext, this._config);
|
|
9988
|
-
},
|
|
9989
|
-
onUpdateStatus: async (status) => {
|
|
9990
|
-
if (!this.isOpen && status === SystemStatus.ACTIVE) {
|
|
9991
|
-
await this._resourceLock?.acquire();
|
|
9992
|
-
} else if (this.isOpen && status === SystemStatus.INACTIVE) {
|
|
9993
|
-
await this._resourceLock?.release();
|
|
9994
|
-
}
|
|
9995
|
-
},
|
|
9996
|
-
onReset: async () => {
|
|
9997
|
-
await this.reset();
|
|
9998
|
-
}
|
|
9999
|
-
});
|
|
10000
|
-
this.diagnosticsBroadcastHandler = createCollectDiagnosticsBroadcastHandler(this._systemService);
|
|
10001
|
-
this._loggingService = new LoggingServiceImpl();
|
|
10002
|
-
this._serviceRegistry = new ServiceRegistry(clientServiceBundle, {
|
|
10003
|
-
SystemService: this._systemService,
|
|
10004
|
-
TracingService: this._tracingService
|
|
10005
|
-
});
|
|
10006
|
-
}
|
|
10007
9697
|
};
|
|
10008
9698
|
_ts_decorate11([
|
|
10009
9699
|
Trace4.info()
|
|
@@ -10071,4 +9761,4 @@ export {
|
|
|
10071
9761
|
ServiceRegistry,
|
|
10072
9762
|
ClientServicesHost
|
|
10073
9763
|
};
|
|
10074
|
-
//# sourceMappingURL=chunk-
|
|
9764
|
+
//# sourceMappingURL=chunk-PWKWJATU.mjs.map
|