@dxos/client-services 0.6.3-next.2f65b78 → 0.6.3-staging.0f23fb2
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-XDR7UKWW.mjs → chunk-UR2AY5N5.mjs} +704 -690
- package/dist/lib/browser/chunk-UR2AY5N5.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +1 -3
- package/dist/lib/browser/index.mjs.map +1 -1
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/packlets/testing/index.mjs +1 -1
- package/dist/lib/node/{chunk-PQML4EXM.cjs → chunk-A2CBSXQP.cjs} +755 -738
- package/dist/lib/node/chunk-A2CBSXQP.cjs.map +7 -0
- package/dist/lib/node/index.cjs +44 -46
- package/dist/lib/node/index.cjs.map +1 -1
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/packlets/testing/index.cjs +8 -8
- package/dist/types/src/packlets/diagnostics/diagnostics-collector.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-topology.d.ts +2 -2
- package/dist/types/src/packlets/invitations/invitation-topology.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/invitations-handler.d.ts.map +1 -1
- package/dist/types/src/packlets/services/index.d.ts +0 -1
- package/dist/types/src/packlets/services/index.d.ts.map +1 -1
- package/dist/types/src/packlets/services/util.d.ts +0 -1
- package/dist/types/src/packlets/services/util.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/data-space-manager.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/data-space.d.ts +8 -2
- package/dist/types/src/packlets/spaces/data-space.d.ts.map +1 -1
- package/dist/types/src/version.d.ts +1 -1
- package/dist/types/src/version.d.ts.map +1 -1
- package/package.json +36 -36
- package/src/packlets/diagnostics/diagnostics-collector.ts +1 -2
- package/src/packlets/identity/identity-service.ts +2 -2
- package/src/packlets/invitations/invitation-guest-extenstion.ts +8 -5
- package/src/packlets/invitations/invitation-host-extension.ts +5 -5
- package/src/packlets/invitations/invitation-topology.ts +4 -4
- package/src/packlets/invitations/invitations-handler.ts +13 -12
- package/src/packlets/services/index.ts +0 -1
- package/src/packlets/services/util.ts +0 -2
- package/src/packlets/spaces/data-space-manager.test.ts +6 -6
- package/src/packlets/spaces/data-space-manager.ts +28 -16
- package/src/packlets/spaces/data-space.ts +31 -27
- package/src/packlets/spaces/spaces-service.ts +6 -6
- package/src/version.ts +1 -1
- package/dist/lib/browser/chunk-XDR7UKWW.mjs.map +0 -7
- package/dist/lib/node/chunk-PQML4EXM.cjs.map +0 -7
|
@@ -359,7 +359,7 @@ import { SpaceMember } from "@dxos/protocols/proto/dxos/client/services";
|
|
|
359
359
|
import { TRACE_PROCESSOR } from "@dxos/tracing";
|
|
360
360
|
|
|
361
361
|
// packages/sdk/client-services/src/version.ts
|
|
362
|
-
var DXOS_VERSION = "0.6.3-
|
|
362
|
+
var DXOS_VERSION = "0.6.3-staging.0f23fb2";
|
|
363
363
|
|
|
364
364
|
// packages/sdk/client-services/src/packlets/services/platform.ts
|
|
365
365
|
import { Platform } from "@dxos/protocols/proto/dxos/client/services";
|
|
@@ -604,86 +604,46 @@ var safeClose = (channel) => {
|
|
|
604
604
|
}
|
|
605
605
|
};
|
|
606
606
|
|
|
607
|
-
// packages/sdk/client-services/src/packlets/
|
|
608
|
-
import {
|
|
609
|
-
import {
|
|
610
|
-
import {
|
|
611
|
-
import {
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
for (var i = decorators.length - 1; i >= 0; i--)
|
|
618
|
-
if (d = decorators[i])
|
|
619
|
-
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
620
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
621
|
-
}
|
|
622
|
-
var ClientRpcServer = class {
|
|
623
|
-
constructor(params) {
|
|
624
|
-
this._handlerCache = /* @__PURE__ */ new Map();
|
|
625
|
-
this._callMetrics = new MapCounter();
|
|
626
|
-
const { serviceRegistry, handleCall, handleStream, ...rpcOptions } = params;
|
|
627
|
-
this._handleCall = handleCall;
|
|
628
|
-
this._handleStream = handleStream;
|
|
629
|
-
this._serviceRegistry = serviceRegistry;
|
|
630
|
-
this._rpcPeer = new RpcPeer({
|
|
631
|
-
...rpcOptions,
|
|
632
|
-
callHandler: (method, params2) => {
|
|
633
|
-
const [serviceName, methodName] = parseMethodName(method);
|
|
634
|
-
const handler = (method2, params3) => this._getServiceHandler(serviceName).call(method2, params3);
|
|
635
|
-
this._callMetrics.inc(`${serviceName}.${methodName} request`);
|
|
636
|
-
if (this._handleCall) {
|
|
637
|
-
return this._handleCall(methodName, params2, handler);
|
|
638
|
-
} else {
|
|
639
|
-
return handler(methodName, params2);
|
|
640
|
-
}
|
|
641
|
-
},
|
|
642
|
-
streamHandler: (method, params2) => {
|
|
643
|
-
const [serviceName, methodName] = parseMethodName(method);
|
|
644
|
-
const handler = (method2, params3) => this._getServiceHandler(serviceName).callStream(method2, params3);
|
|
645
|
-
this._callMetrics.inc(`${serviceName}.${methodName} request stream`);
|
|
646
|
-
if (this._handleStream) {
|
|
647
|
-
return Stream7.map(Stream7.unwrapPromise(this._handleStream(methodName, params2, handler)), (data) => {
|
|
648
|
-
this._callMetrics.inc(`${serviceName}.${methodName} response stream`);
|
|
649
|
-
return data;
|
|
650
|
-
});
|
|
651
|
-
} else {
|
|
652
|
-
return handler(methodName, params2);
|
|
653
|
-
}
|
|
654
|
-
}
|
|
655
|
-
});
|
|
656
|
-
}
|
|
657
|
-
get _services() {
|
|
658
|
-
return Object.keys(this._serviceRegistry.services);
|
|
659
|
-
}
|
|
660
|
-
async open() {
|
|
661
|
-
await this._rpcPeer.open();
|
|
662
|
-
}
|
|
663
|
-
async close() {
|
|
664
|
-
await this._rpcPeer.close();
|
|
607
|
+
// packages/sdk/client-services/src/packlets/diagnostics/diagnostics-collector.ts
|
|
608
|
+
import { ClientServicesProviderResource } from "@dxos/client-protocol";
|
|
609
|
+
import { ConfigResource } from "@dxos/config";
|
|
610
|
+
import { GetDiagnosticsRequest } from "@dxos/protocols/proto/dxos/client/services";
|
|
611
|
+
import { TRACE_PROCESSOR as TRACE_PROCESSOR2 } from "@dxos/tracing";
|
|
612
|
+
import { jsonKeyReplacer, nonNullable } from "@dxos/util";
|
|
613
|
+
var GET_DIAGNOSTICS_RPC_TIMEOUT = 1e4;
|
|
614
|
+
var DiagnosticsCollector = class {
|
|
615
|
+
static {
|
|
616
|
+
this.broadcastSender = createCollectDiagnosticsBroadcastSender();
|
|
665
617
|
}
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
618
|
+
static async collect(config = findConfigs(), services = findSystemServiceProvider(), options = {}) {
|
|
619
|
+
const serviceDiagnostics = await services?.services?.SystemService?.getDiagnostics({
|
|
620
|
+
keys: options.humanize ? GetDiagnosticsRequest.KEY_OPTION.HUMANIZE : options.truncate ? GetDiagnosticsRequest.KEY_OPTION.TRUNCATE : void 0
|
|
621
|
+
}, {
|
|
622
|
+
timeout: GET_DIAGNOSTICS_RPC_TIMEOUT
|
|
623
|
+
});
|
|
624
|
+
const clientDiagnostics = {
|
|
625
|
+
config,
|
|
626
|
+
trace: TRACE_PROCESSOR2.getDiagnostics()
|
|
627
|
+
};
|
|
628
|
+
const diagnostics = serviceDiagnostics != null ? {
|
|
629
|
+
client: clientDiagnostics,
|
|
630
|
+
services: serviceDiagnostics
|
|
631
|
+
} : {
|
|
632
|
+
client: clientDiagnostics,
|
|
633
|
+
broadcast: await this.broadcastSender.broadcastDiagnosticsRequest()
|
|
634
|
+
};
|
|
635
|
+
return JSON.parse(JSON.stringify(diagnostics, jsonKeyReplacer(options)));
|
|
676
636
|
}
|
|
677
637
|
};
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
638
|
+
var findSystemServiceProvider = () => {
|
|
639
|
+
const serviceProviders = TRACE_PROCESSOR2.findResourcesByAnnotation(ClientServicesProviderResource);
|
|
640
|
+
const providerResource = serviceProviders.find((r) => r.instance.deref()?.services?.SystemService != null);
|
|
641
|
+
return providerResource?.instance?.deref() ?? null;
|
|
642
|
+
};
|
|
643
|
+
var findConfigs = () => {
|
|
644
|
+
const configs = TRACE_PROCESSOR2.findResourcesByAnnotation(ConfigResource);
|
|
645
|
+
return configs.map((r) => r.instance.deref()).filter(nonNullable);
|
|
646
|
+
};
|
|
687
647
|
|
|
688
648
|
// packages/sdk/client-services/src/packlets/identity/authenticator.ts
|
|
689
649
|
import { Trigger as Trigger2 } from "@dxos/async";
|
|
@@ -813,7 +773,7 @@ import { PublicKey as PublicKey3 } from "@dxos/keys";
|
|
|
813
773
|
import { log as log4 } from "@dxos/log";
|
|
814
774
|
import { AdmittedFeed } from "@dxos/protocols/proto/dxos/halo/credentials";
|
|
815
775
|
import { Timeframe } from "@dxos/timeframe";
|
|
816
|
-
import { trace
|
|
776
|
+
import { trace } from "@dxos/tracing";
|
|
817
777
|
import { ComplexSet } from "@dxos/util";
|
|
818
778
|
|
|
819
779
|
// packages/sdk/client-services/src/packlets/identity/default-space-state-machine.ts
|
|
@@ -863,7 +823,7 @@ var DefaultSpaceStateMachine = class {
|
|
|
863
823
|
};
|
|
864
824
|
|
|
865
825
|
// packages/sdk/client-services/src/packlets/identity/identity.ts
|
|
866
|
-
function
|
|
826
|
+
function _ts_decorate(decorators, target, key, desc) {
|
|
867
827
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
868
828
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
869
829
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -1050,14 +1010,14 @@ var Identity = class {
|
|
|
1050
1010
|
})));
|
|
1051
1011
|
}
|
|
1052
1012
|
};
|
|
1053
|
-
|
|
1054
|
-
|
|
1013
|
+
_ts_decorate([
|
|
1014
|
+
trace.span()
|
|
1055
1015
|
], Identity.prototype, "open", null);
|
|
1056
|
-
|
|
1057
|
-
|
|
1016
|
+
_ts_decorate([
|
|
1017
|
+
trace.span()
|
|
1058
1018
|
], Identity.prototype, "close", null);
|
|
1059
|
-
Identity =
|
|
1060
|
-
|
|
1019
|
+
Identity = _ts_decorate([
|
|
1020
|
+
trace.resource()
|
|
1061
1021
|
], Identity);
|
|
1062
1022
|
|
|
1063
1023
|
// packages/sdk/client-services/src/packlets/identity/identity-manager.ts
|
|
@@ -1068,14 +1028,14 @@ import { createCredentialSignerWithKey as createCredentialSignerWithKey2, Creden
|
|
|
1068
1028
|
import { invariant as invariant3 } from "@dxos/invariant";
|
|
1069
1029
|
import { PublicKey as PublicKey4 } from "@dxos/keys";
|
|
1070
1030
|
import { log as log5 } from "@dxos/log";
|
|
1071
|
-
import { trace as
|
|
1031
|
+
import { trace as trace2 } from "@dxos/protocols";
|
|
1072
1032
|
import { Device, DeviceKind } from "@dxos/protocols/proto/dxos/client/services";
|
|
1073
1033
|
import { AdmittedFeed as AdmittedFeed2, DeviceType } from "@dxos/protocols/proto/dxos/halo/credentials";
|
|
1074
1034
|
import { Gossip, Presence } from "@dxos/teleport-extension-gossip";
|
|
1075
1035
|
import { Timeframe as Timeframe2 } from "@dxos/timeframe";
|
|
1076
1036
|
import { trace as Trace } from "@dxos/tracing";
|
|
1077
1037
|
import { isNode, deferFunction } from "@dxos/util";
|
|
1078
|
-
function
|
|
1038
|
+
function _ts_decorate2(decorators, target, key, desc) {
|
|
1079
1039
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1080
1040
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
1081
1041
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -1106,7 +1066,7 @@ var IdentityManager = class {
|
|
|
1106
1066
|
}
|
|
1107
1067
|
async open(ctx) {
|
|
1108
1068
|
const traceId = PublicKey4.random().toHex();
|
|
1109
|
-
log5.trace("dxos.halo.identity-manager.open",
|
|
1069
|
+
log5.trace("dxos.halo.identity-manager.open", trace2.begin({
|
|
1110
1070
|
id: traceId
|
|
1111
1071
|
}), {
|
|
1112
1072
|
F: __dxlog_file7,
|
|
@@ -1138,7 +1098,7 @@ var IdentityManager = class {
|
|
|
1138
1098
|
});
|
|
1139
1099
|
this.stateUpdate.emit();
|
|
1140
1100
|
}
|
|
1141
|
-
log5.trace("dxos.halo.identity-manager.open",
|
|
1101
|
+
log5.trace("dxos.halo.identity-manager.open", trace2.end({
|
|
1142
1102
|
id: traceId
|
|
1143
1103
|
}), {
|
|
1144
1104
|
F: __dxlog_file7,
|
|
@@ -1525,18 +1485,18 @@ var IdentityManager = class {
|
|
|
1525
1485
|
});
|
|
1526
1486
|
}
|
|
1527
1487
|
};
|
|
1528
|
-
|
|
1488
|
+
_ts_decorate2([
|
|
1529
1489
|
Trace.span({
|
|
1530
1490
|
showInBrowserTimeline: true
|
|
1531
1491
|
})
|
|
1532
1492
|
], IdentityManager.prototype, "open", null);
|
|
1533
|
-
IdentityManager =
|
|
1493
|
+
IdentityManager = _ts_decorate2([
|
|
1534
1494
|
Trace.resource()
|
|
1535
1495
|
], IdentityManager);
|
|
1536
1496
|
|
|
1537
1497
|
// packages/sdk/client-services/src/packlets/identity/identity-service.ts
|
|
1538
1498
|
import { Trigger as Trigger3, sleep } from "@dxos/async";
|
|
1539
|
-
import { Stream as
|
|
1499
|
+
import { Stream as Stream7 } from "@dxos/codec-protobuf";
|
|
1540
1500
|
import { Resource } from "@dxos/context";
|
|
1541
1501
|
import { signPresentation } from "@dxos/credentials";
|
|
1542
1502
|
import { todo } from "@dxos/debug";
|
|
@@ -1588,7 +1548,7 @@ var IdentityServiceImpl = class extends Resource {
|
|
|
1588
1548
|
return todo();
|
|
1589
1549
|
}
|
|
1590
1550
|
queryIdentity() {
|
|
1591
|
-
return new
|
|
1551
|
+
return new Stream7(({ next }) => {
|
|
1592
1552
|
const emitNext = () => next({
|
|
1593
1553
|
identity: this._getIdentity()
|
|
1594
1554
|
});
|
|
@@ -1644,9 +1604,9 @@ var IdentityServiceImpl = class extends Resource {
|
|
|
1644
1604
|
const dataSpaceManager = this._dataSpaceManagerProvider();
|
|
1645
1605
|
const recordedDefaultSpaceTrigger = new Trigger3();
|
|
1646
1606
|
const allProcessed = safeAwaitAll(dataSpaceManager.spaces.values(), async (space) => {
|
|
1647
|
-
if (space.state === SpaceState.
|
|
1607
|
+
if (space.state === SpaceState.SPACE_CLOSED) {
|
|
1648
1608
|
await space.open();
|
|
1649
|
-
const requiresMigration = space.stateUpdate.waitForCondition(() => space.state === SpaceState.
|
|
1609
|
+
const requiresMigration = space.stateUpdate.waitForCondition(() => space.state === SpaceState.SPACE_REQUIRES_MIGRATION);
|
|
1650
1610
|
await Promise.race([
|
|
1651
1611
|
space.initializeDataPipeline(),
|
|
1652
1612
|
requiresMigration
|
|
@@ -1808,10 +1768,10 @@ import { invariant as invariant9 } from "@dxos/invariant";
|
|
|
1808
1768
|
import { PublicKey as PublicKey7 } from "@dxos/keys";
|
|
1809
1769
|
import { log as log10 } from "@dxos/log";
|
|
1810
1770
|
import { createTeleportProtocolFactory } from "@dxos/network-manager";
|
|
1811
|
-
import { InvalidInvitationExtensionRoleError as InvalidInvitationExtensionRoleError3, trace as
|
|
1771
|
+
import { InvalidInvitationExtensionRoleError as InvalidInvitationExtensionRoleError3, trace as trace4 } from "@dxos/protocols";
|
|
1812
1772
|
import { Invitation as Invitation4 } from "@dxos/protocols/proto/dxos/client/services";
|
|
1813
1773
|
import { AuthenticationResponse as AuthenticationResponse2 } from "@dxos/protocols/proto/dxos/halo/invitations";
|
|
1814
|
-
import {
|
|
1774
|
+
import { InvitationOptions as InvitationOptions4 } from "@dxos/protocols/proto/dxos/halo/invitations";
|
|
1815
1775
|
import { trace as _trace } from "@dxos/tracing";
|
|
1816
1776
|
import { ComplexSet as ComplexSet3 } from "@dxos/util";
|
|
1817
1777
|
|
|
@@ -1821,7 +1781,7 @@ import { cancelWithContext as cancelWithContext2, Context as Context4 } from "@d
|
|
|
1821
1781
|
import { invariant as invariant6 } from "@dxos/invariant";
|
|
1822
1782
|
import { log as log7 } from "@dxos/log";
|
|
1823
1783
|
import { InvalidInvitationExtensionRoleError, schema as schema2 } from "@dxos/protocols";
|
|
1824
|
-
import {
|
|
1784
|
+
import { InvitationOptions } from "@dxos/protocols/proto/dxos/halo/invitations";
|
|
1825
1785
|
import { RpcExtension } from "@dxos/teleport";
|
|
1826
1786
|
|
|
1827
1787
|
// packages/sdk/client-services/src/packlets/invitations/utils.ts
|
|
@@ -1913,11 +1873,11 @@ var InvitationGuestExtension = class extends RpcExtension {
|
|
|
1913
1873
|
C: (f, a) => f(...a)
|
|
1914
1874
|
});
|
|
1915
1875
|
await cancelWithContext2(this._ctx, this.rpc.InvitationHostService.options({
|
|
1916
|
-
role:
|
|
1876
|
+
role: InvitationOptions.Role.GUEST
|
|
1917
1877
|
}));
|
|
1918
1878
|
log7("options sent", void 0, {
|
|
1919
1879
|
F: __dxlog_file10,
|
|
1920
|
-
L:
|
|
1880
|
+
L: 91,
|
|
1921
1881
|
S: this,
|
|
1922
1882
|
C: (f, a) => f(...a)
|
|
1923
1883
|
});
|
|
@@ -1926,13 +1886,13 @@ var InvitationGuestExtension = class extends RpcExtension {
|
|
|
1926
1886
|
}));
|
|
1927
1887
|
log7("options received", void 0, {
|
|
1928
1888
|
F: __dxlog_file10,
|
|
1929
|
-
L:
|
|
1889
|
+
L: 93,
|
|
1930
1890
|
S: this,
|
|
1931
1891
|
C: (f, a) => f(...a)
|
|
1932
1892
|
});
|
|
1933
|
-
if (this._remoteOptions?.role !==
|
|
1893
|
+
if (this._remoteOptions?.role !== InvitationOptions.Role.HOST) {
|
|
1934
1894
|
throw new InvalidInvitationExtensionRoleError(void 0, {
|
|
1935
|
-
expected:
|
|
1895
|
+
expected: InvitationOptions.Role.HOST,
|
|
1936
1896
|
remoteOptions: this._remoteOptions,
|
|
1937
1897
|
remotePeerId: context.remotePeerId
|
|
1938
1898
|
});
|
|
@@ -1960,7 +1920,7 @@ var InvitationGuestExtension = class extends RpcExtension {
|
|
|
1960
1920
|
this._invitationFlowLock = null;
|
|
1961
1921
|
log7("invitation flow lock released", void 0, {
|
|
1962
1922
|
F: __dxlog_file10,
|
|
1963
|
-
L:
|
|
1923
|
+
L: 126,
|
|
1964
1924
|
S: this,
|
|
1965
1925
|
C: (f, a) => f(...a)
|
|
1966
1926
|
});
|
|
@@ -1975,9 +1935,9 @@ import { randomBytes, verify } from "@dxos/crypto";
|
|
|
1975
1935
|
import { invariant as invariant7, InvariantViolation } from "@dxos/invariant";
|
|
1976
1936
|
import { PublicKey as PublicKey5 } from "@dxos/keys";
|
|
1977
1937
|
import { log as log8 } from "@dxos/log";
|
|
1978
|
-
import { InvalidInvitationExtensionRoleError as InvalidInvitationExtensionRoleError2, schema as schema3, trace as
|
|
1938
|
+
import { InvalidInvitationExtensionRoleError as InvalidInvitationExtensionRoleError2, schema as schema3, trace as trace3 } from "@dxos/protocols";
|
|
1979
1939
|
import { Invitation as Invitation3 } from "@dxos/protocols/proto/dxos/client/services";
|
|
1980
|
-
import { AuthenticationResponse,
|
|
1940
|
+
import { AuthenticationResponse, InvitationOptions as InvitationOptions2 } from "@dxos/protocols/proto/dxos/halo/invitations";
|
|
1981
1941
|
import { RpcExtension as RpcExtension2 } from "@dxos/teleport";
|
|
1982
1942
|
var __dxlog_file11 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitation-host-extension.ts";
|
|
1983
1943
|
var OPTIONS_TIMEOUT2 = 1e4;
|
|
@@ -2030,7 +1990,7 @@ var InvitationHostExtension = class extends RpcExtension2 {
|
|
|
2030
1990
|
introduce: async (request) => {
|
|
2031
1991
|
const { profile, invitationId } = request;
|
|
2032
1992
|
const traceId = PublicKey5.random().toHex();
|
|
2033
|
-
log8.trace("dxos.sdk.invitation-handler.host.introduce",
|
|
1993
|
+
log8.trace("dxos.sdk.invitation-handler.host.introduce", trace3.begin({
|
|
2034
1994
|
id: traceId
|
|
2035
1995
|
}), {
|
|
2036
1996
|
F: __dxlog_file11,
|
|
@@ -2067,7 +2027,7 @@ var InvitationHostExtension = class extends RpcExtension2 {
|
|
|
2067
2027
|
this.guestProfile = profile;
|
|
2068
2028
|
this._callbacks.onStateUpdate(Invitation3.State.READY_FOR_AUTHENTICATION);
|
|
2069
2029
|
this._challenge = invitation.authMethod === Invitation3.AuthMethod.KNOWN_PUBLIC_KEY ? randomBytes(32) : void 0;
|
|
2070
|
-
log8.trace("dxos.sdk.invitation-handler.host.introduce",
|
|
2030
|
+
log8.trace("dxos.sdk.invitation-handler.host.introduce", trace3.end({
|
|
2071
2031
|
id: traceId
|
|
2072
2032
|
}), {
|
|
2073
2033
|
F: __dxlog_file11,
|
|
@@ -2082,7 +2042,7 @@ var InvitationHostExtension = class extends RpcExtension2 {
|
|
|
2082
2042
|
},
|
|
2083
2043
|
authenticate: async ({ authCode: code, signedChallenge }) => {
|
|
2084
2044
|
const traceId = PublicKey5.random().toHex();
|
|
2085
|
-
log8.trace("dxos.sdk.invitation-handler.host.authenticate",
|
|
2045
|
+
log8.trace("dxos.sdk.invitation-handler.host.authenticate", trace3.begin({
|
|
2086
2046
|
id: traceId
|
|
2087
2047
|
}), {
|
|
2088
2048
|
F: __dxlog_file11,
|
|
@@ -2165,7 +2125,7 @@ var InvitationHostExtension = class extends RpcExtension2 {
|
|
|
2165
2125
|
status
|
|
2166
2126
|
};
|
|
2167
2127
|
}
|
|
2168
|
-
log8.trace("dxos.sdk.invitation-handler.host.authenticate",
|
|
2128
|
+
log8.trace("dxos.sdk.invitation-handler.host.authenticate", trace3.end({
|
|
2169
2129
|
id: traceId,
|
|
2170
2130
|
data: {
|
|
2171
2131
|
status
|
|
@@ -2182,7 +2142,7 @@ var InvitationHostExtension = class extends RpcExtension2 {
|
|
|
2182
2142
|
},
|
|
2183
2143
|
admit: async (request) => {
|
|
2184
2144
|
const traceId = PublicKey5.random().toHex();
|
|
2185
|
-
log8.trace("dxos.sdk.invitation-handler.host.admit",
|
|
2145
|
+
log8.trace("dxos.sdk.invitation-handler.host.admit", trace3.begin({
|
|
2186
2146
|
id: traceId
|
|
2187
2147
|
}), {
|
|
2188
2148
|
F: __dxlog_file11,
|
|
@@ -2199,7 +2159,7 @@ var InvitationHostExtension = class extends RpcExtension2 {
|
|
|
2199
2159
|
}
|
|
2200
2160
|
}
|
|
2201
2161
|
const response = await this._callbacks.admit(request);
|
|
2202
|
-
log8.trace("dxos.sdk.invitation-handler.host.admit",
|
|
2162
|
+
log8.trace("dxos.sdk.invitation-handler.host.admit", trace3.end({
|
|
2203
2163
|
id: traceId
|
|
2204
2164
|
}), {
|
|
2205
2165
|
F: __dxlog_file11,
|
|
@@ -2235,7 +2195,7 @@ var InvitationHostExtension = class extends RpcExtension2 {
|
|
|
2235
2195
|
const lastState = this._requireActiveInvitation().state;
|
|
2236
2196
|
this._callbacks.onStateUpdate(Invitation3.State.CONNECTING);
|
|
2237
2197
|
await this.rpc.InvitationHostService.options({
|
|
2238
|
-
role:
|
|
2198
|
+
role: InvitationOptions2.Role.HOST
|
|
2239
2199
|
});
|
|
2240
2200
|
log8("options sent", void 0, {
|
|
2241
2201
|
F: __dxlog_file11,
|
|
@@ -2252,10 +2212,10 @@ var InvitationHostExtension = class extends RpcExtension2 {
|
|
|
2252
2212
|
S: this,
|
|
2253
2213
|
C: (f, a) => f(...a)
|
|
2254
2214
|
});
|
|
2255
|
-
if (this._remoteOptions?.role !==
|
|
2215
|
+
if (this._remoteOptions?.role !== InvitationOptions2.Role.GUEST) {
|
|
2256
2216
|
this._callbacks.onStateUpdate(lastState);
|
|
2257
2217
|
throw new InvalidInvitationExtensionRoleError2(void 0, {
|
|
2258
|
-
expected:
|
|
2218
|
+
expected: InvitationOptions2.Role.GUEST,
|
|
2259
2219
|
remoteOptions: this._remoteOptions,
|
|
2260
2220
|
remotePeerId: context.remotePeerId
|
|
2261
2221
|
});
|
|
@@ -2315,7 +2275,7 @@ var isAuthenticationRequired = (invitation) => invitation.authMethod !== Invitat
|
|
|
2315
2275
|
import { invariant as invariant8 } from "@dxos/invariant";
|
|
2316
2276
|
import { PublicKey as PublicKey6 } from "@dxos/keys";
|
|
2317
2277
|
import { log as log9 } from "@dxos/log";
|
|
2318
|
-
import {
|
|
2278
|
+
import { InvitationOptions as InvitationOptions3 } from "@dxos/protocols/proto/dxos/halo/invitations";
|
|
2319
2279
|
import { ComplexSet as ComplexSet2 } from "@dxos/util";
|
|
2320
2280
|
var __dxlog_file12 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitation-topology.ts";
|
|
2321
2281
|
var InvitationTopology = class {
|
|
@@ -2346,7 +2306,7 @@ var InvitationTopology = class {
|
|
|
2346
2306
|
]
|
|
2347
2307
|
});
|
|
2348
2308
|
const { ownPeerId, candidates, connected, allPeers } = this._controller.getState();
|
|
2349
|
-
if (this._role ===
|
|
2309
|
+
if (this._role === InvitationOptions3.Role.GUEST) {
|
|
2350
2310
|
return;
|
|
2351
2311
|
}
|
|
2352
2312
|
if (connected.length > 0) {
|
|
@@ -2385,7 +2345,7 @@ var InvitationTopology = class {
|
|
|
2385
2345
|
this._seenPeers.clear();
|
|
2386
2346
|
}
|
|
2387
2347
|
toString() {
|
|
2388
|
-
return `InvitationTopology(${this._role ===
|
|
2348
|
+
return `InvitationTopology(${this._role === InvitationOptions3.Role.GUEST ? "guest" : "host"})`;
|
|
2389
2349
|
}
|
|
2390
2350
|
};
|
|
2391
2351
|
|
|
@@ -2402,7 +2362,7 @@ var InvitationsHandler = class {
|
|
|
2402
2362
|
this._defaultTeleportParams = _defaultTeleportParams;
|
|
2403
2363
|
}
|
|
2404
2364
|
handleInvitationFlow(ctx, stream, protocol, invitation) {
|
|
2405
|
-
metrics.increment("invitation.created");
|
|
2365
|
+
metrics.increment("dxos.invitation.created");
|
|
2406
2366
|
const guardedState = this._createGuardedState(ctx, invitation, stream);
|
|
2407
2367
|
const createExtension = () => {
|
|
2408
2368
|
const extension = new InvitationHostExtension(guardedState.mutex, {
|
|
@@ -2418,7 +2378,7 @@ var InvitationsHandler = class {
|
|
|
2418
2378
|
const deviceKey = admissionRequest.device?.deviceKey ?? admissionRequest.space?.deviceKey;
|
|
2419
2379
|
invariant9(deviceKey, void 0, {
|
|
2420
2380
|
F: __dxlog_file13,
|
|
2421
|
-
L:
|
|
2381
|
+
L: 94,
|
|
2422
2382
|
S: this,
|
|
2423
2383
|
A: [
|
|
2424
2384
|
"deviceKey",
|
|
@@ -2443,11 +2403,11 @@ var InvitationsHandler = class {
|
|
|
2443
2403
|
scheduleTask3(connectionCtx, async () => {
|
|
2444
2404
|
const traceId = PublicKey7.random().toHex();
|
|
2445
2405
|
try {
|
|
2446
|
-
log10.trace("dxos.sdk.invitations-handler.host.onOpen",
|
|
2406
|
+
log10.trace("dxos.sdk.invitations-handler.host.onOpen", trace4.begin({
|
|
2447
2407
|
id: traceId
|
|
2448
2408
|
}), {
|
|
2449
2409
|
F: __dxlog_file13,
|
|
2450
|
-
L:
|
|
2410
|
+
L: 119,
|
|
2451
2411
|
S: this,
|
|
2452
2412
|
C: (f, a) => f(...a)
|
|
2453
2413
|
});
|
|
@@ -2455,7 +2415,7 @@ var InvitationsHandler = class {
|
|
|
2455
2415
|
...protocol.toJSON()
|
|
2456
2416
|
}, {
|
|
2457
2417
|
F: __dxlog_file13,
|
|
2458
|
-
L:
|
|
2418
|
+
L: 120,
|
|
2459
2419
|
S: this,
|
|
2460
2420
|
C: (f, a) => f(...a)
|
|
2461
2421
|
});
|
|
@@ -2467,17 +2427,17 @@ var InvitationsHandler = class {
|
|
|
2467
2427
|
...protocol.toJSON()
|
|
2468
2428
|
}, {
|
|
2469
2429
|
F: __dxlog_file13,
|
|
2470
|
-
L:
|
|
2430
|
+
L: 122,
|
|
2471
2431
|
S: this,
|
|
2472
2432
|
C: (f, a) => f(...a)
|
|
2473
2433
|
});
|
|
2474
2434
|
guardedState.set(extension, Invitation4.State.SUCCESS);
|
|
2475
|
-
metrics.increment("invitation.success");
|
|
2476
|
-
log10.trace("dxos.sdk.invitations-handler.host.onOpen",
|
|
2435
|
+
metrics.increment("dxos.invitation.success");
|
|
2436
|
+
log10.trace("dxos.sdk.invitations-handler.host.onOpen", trace4.end({
|
|
2477
2437
|
id: traceId
|
|
2478
2438
|
}), {
|
|
2479
2439
|
F: __dxlog_file13,
|
|
2480
|
-
L:
|
|
2440
|
+
L: 125,
|
|
2481
2441
|
S: this,
|
|
2482
2442
|
C: (f, a) => f(...a)
|
|
2483
2443
|
});
|
|
@@ -2488,33 +2448,33 @@ var InvitationsHandler = class {
|
|
|
2488
2448
|
} catch (err) {
|
|
2489
2449
|
if (err instanceof TimeoutError) {
|
|
2490
2450
|
if (guardedState.set(extension, Invitation4.State.TIMEOUT)) {
|
|
2491
|
-
metrics.increment("invitation.timeout");
|
|
2451
|
+
metrics.increment("dxos.invitation.timeout");
|
|
2492
2452
|
log10("timeout", {
|
|
2493
2453
|
...protocol.toJSON()
|
|
2494
2454
|
}, {
|
|
2495
2455
|
F: __dxlog_file13,
|
|
2496
|
-
L:
|
|
2456
|
+
L: 135,
|
|
2497
2457
|
S: this,
|
|
2498
2458
|
C: (f, a) => f(...a)
|
|
2499
2459
|
});
|
|
2500
2460
|
}
|
|
2501
2461
|
} else {
|
|
2502
2462
|
if (guardedState.error(extension, err)) {
|
|
2503
|
-
metrics.increment("invitation.failed");
|
|
2463
|
+
metrics.increment("dxos.invitation.failed");
|
|
2504
2464
|
log10.error("failed", err, {
|
|
2505
2465
|
F: __dxlog_file13,
|
|
2506
|
-
L:
|
|
2466
|
+
L: 140,
|
|
2507
2467
|
S: this,
|
|
2508
2468
|
C: (f, a) => f(...a)
|
|
2509
2469
|
});
|
|
2510
2470
|
}
|
|
2511
2471
|
}
|
|
2512
|
-
log10.trace("dxos.sdk.invitations-handler.host.onOpen",
|
|
2472
|
+
log10.trace("dxos.sdk.invitations-handler.host.onOpen", trace4.error({
|
|
2513
2473
|
id: traceId,
|
|
2514
2474
|
error: err
|
|
2515
2475
|
}), {
|
|
2516
2476
|
F: __dxlog_file13,
|
|
2517
|
-
L:
|
|
2477
|
+
L: 143,
|
|
2518
2478
|
S: this,
|
|
2519
2479
|
C: (f, a) => f(...a)
|
|
2520
2480
|
});
|
|
@@ -2528,7 +2488,7 @@ var InvitationsHandler = class {
|
|
|
2528
2488
|
...err.context
|
|
2529
2489
|
}, {
|
|
2530
2490
|
F: __dxlog_file13,
|
|
2531
|
-
L:
|
|
2491
|
+
L: 151,
|
|
2532
2492
|
S: this,
|
|
2533
2493
|
C: (f, a) => f(...a)
|
|
2534
2494
|
});
|
|
@@ -2536,22 +2496,22 @@ var InvitationsHandler = class {
|
|
|
2536
2496
|
}
|
|
2537
2497
|
if (err instanceof TimeoutError) {
|
|
2538
2498
|
if (guardedState.set(extension, Invitation4.State.TIMEOUT)) {
|
|
2539
|
-
metrics.increment("invitation.timeout");
|
|
2499
|
+
metrics.increment("dxos.invitation.timeout");
|
|
2540
2500
|
log10("timeout", {
|
|
2541
2501
|
err
|
|
2542
2502
|
}, {
|
|
2543
2503
|
F: __dxlog_file13,
|
|
2544
|
-
L:
|
|
2504
|
+
L: 157,
|
|
2545
2505
|
S: this,
|
|
2546
2506
|
C: (f, a) => f(...a)
|
|
2547
2507
|
});
|
|
2548
2508
|
}
|
|
2549
2509
|
} else {
|
|
2550
2510
|
if (guardedState.error(extension, err)) {
|
|
2551
|
-
metrics.increment("invitation.failed");
|
|
2511
|
+
metrics.increment("dxos.invitation.failed");
|
|
2552
2512
|
log10.error("failed", err, {
|
|
2553
2513
|
F: __dxlog_file13,
|
|
2554
|
-
L:
|
|
2514
|
+
L: 162,
|
|
2555
2515
|
S: this,
|
|
2556
2516
|
C: (f, a) => f(...a)
|
|
2557
2517
|
});
|
|
@@ -2565,7 +2525,7 @@ var InvitationsHandler = class {
|
|
|
2565
2525
|
if (invitation.created.getTime() + invitation.lifetime * 1e3 < Date.now()) {
|
|
2566
2526
|
log10.warn("invitation has already expired", void 0, {
|
|
2567
2527
|
F: __dxlog_file13,
|
|
2568
|
-
L:
|
|
2528
|
+
L: 173,
|
|
2569
2529
|
S: this,
|
|
2570
2530
|
C: (f, a) => f(...a)
|
|
2571
2531
|
});
|
|
@@ -2573,14 +2533,14 @@ var InvitationsHandler = class {
|
|
|
2573
2533
|
scheduleTask3(ctx, async () => {
|
|
2574
2534
|
await swarmConnection.close();
|
|
2575
2535
|
guardedState.set(null, Invitation4.State.EXPIRED);
|
|
2576
|
-
metrics.increment("invitation.expired");
|
|
2536
|
+
metrics.increment("dxos.invitation.expired");
|
|
2577
2537
|
await ctx.dispose();
|
|
2578
2538
|
}, invitation.created.getTime() + invitation.lifetime * 1e3 - Date.now());
|
|
2579
2539
|
}
|
|
2580
2540
|
}
|
|
2581
2541
|
let swarmConnection;
|
|
2582
2542
|
scheduleTask3(ctx, async () => {
|
|
2583
|
-
swarmConnection = await this._joinSwarm(ctx, invitation,
|
|
2543
|
+
swarmConnection = await this._joinSwarm(ctx, invitation, InvitationOptions4.Role.HOST, createExtension);
|
|
2584
2544
|
guardedState.set(null, Invitation4.State.CONNECTING);
|
|
2585
2545
|
});
|
|
2586
2546
|
}
|
|
@@ -2589,7 +2549,7 @@ var InvitationsHandler = class {
|
|
|
2589
2549
|
if (deviceProfile) {
|
|
2590
2550
|
invariant9(invitation.kind === Invitation4.Kind.DEVICE, "deviceProfile provided for non-device invitation", {
|
|
2591
2551
|
F: __dxlog_file13,
|
|
2592
|
-
L:
|
|
2552
|
+
L: 207,
|
|
2593
2553
|
S: this,
|
|
2594
2554
|
A: [
|
|
2595
2555
|
"invitation.kind === Invitation.Kind.DEVICE",
|
|
@@ -2607,7 +2567,7 @@ var InvitationsHandler = class {
|
|
|
2607
2567
|
triedPeers: triedPeersIds.size
|
|
2608
2568
|
}, {
|
|
2609
2569
|
F: __dxlog_file13,
|
|
2610
|
-
L:
|
|
2570
|
+
L: 215,
|
|
2611
2571
|
S: this,
|
|
2612
2572
|
C: (f, a) => f(...a)
|
|
2613
2573
|
});
|
|
@@ -2634,7 +2594,7 @@ var InvitationsHandler = class {
|
|
|
2634
2594
|
currentState: guardedState.current.state
|
|
2635
2595
|
}, {
|
|
2636
2596
|
F: __dxlog_file13,
|
|
2637
|
-
L:
|
|
2597
|
+
L: 243,
|
|
2638
2598
|
S: this,
|
|
2639
2599
|
C: (f, a) => f(...a)
|
|
2640
2600
|
});
|
|
@@ -2648,11 +2608,11 @@ var InvitationsHandler = class {
|
|
|
2648
2608
|
scheduleTask3(connectionCtx, async () => {
|
|
2649
2609
|
const traceId = PublicKey7.random().toHex();
|
|
2650
2610
|
try {
|
|
2651
|
-
log10.trace("dxos.sdk.invitations-handler.guest.onOpen",
|
|
2611
|
+
log10.trace("dxos.sdk.invitations-handler.guest.onOpen", trace4.begin({
|
|
2652
2612
|
id: traceId
|
|
2653
2613
|
}), {
|
|
2654
2614
|
F: __dxlog_file13,
|
|
2655
|
-
L:
|
|
2615
|
+
L: 255,
|
|
2656
2616
|
S: this,
|
|
2657
2617
|
C: (f, a) => f(...a)
|
|
2658
2618
|
});
|
|
@@ -2664,7 +2624,7 @@ var InvitationsHandler = class {
|
|
|
2664
2624
|
...protocol.toJSON()
|
|
2665
2625
|
}, {
|
|
2666
2626
|
F: __dxlog_file13,
|
|
2667
|
-
L:
|
|
2627
|
+
L: 266,
|
|
2668
2628
|
S: this,
|
|
2669
2629
|
C: (f, a) => f(...a)
|
|
2670
2630
|
});
|
|
@@ -2673,7 +2633,7 @@ var InvitationsHandler = class {
|
|
|
2673
2633
|
...protocol.toJSON()
|
|
2674
2634
|
}, {
|
|
2675
2635
|
F: __dxlog_file13,
|
|
2676
|
-
L:
|
|
2636
|
+
L: 270,
|
|
2677
2637
|
S: this,
|
|
2678
2638
|
C: (f, a) => f(...a)
|
|
2679
2639
|
});
|
|
@@ -2686,7 +2646,7 @@ var InvitationsHandler = class {
|
|
|
2686
2646
|
response: introductionResponse
|
|
2687
2647
|
}, {
|
|
2688
2648
|
F: __dxlog_file13,
|
|
2689
|
-
L:
|
|
2649
|
+
L: 275,
|
|
2690
2650
|
S: this,
|
|
2691
2651
|
C: (f, a) => f(...a)
|
|
2692
2652
|
});
|
|
@@ -2707,7 +2667,7 @@ var InvitationsHandler = class {
|
|
|
2707
2667
|
...protocol.toJSON()
|
|
2708
2668
|
}, {
|
|
2709
2669
|
F: __dxlog_file13,
|
|
2710
|
-
L:
|
|
2670
|
+
L: 301,
|
|
2711
2671
|
S: this,
|
|
2712
2672
|
C: (f, a) => f(...a)
|
|
2713
2673
|
});
|
|
@@ -2719,7 +2679,7 @@ var InvitationsHandler = class {
|
|
|
2719
2679
|
...protocol.toJSON()
|
|
2720
2680
|
}, {
|
|
2721
2681
|
F: __dxlog_file13,
|
|
2722
|
-
L:
|
|
2682
|
+
L: 312,
|
|
2723
2683
|
S: this,
|
|
2724
2684
|
C: (f, a) => f(...a)
|
|
2725
2685
|
});
|
|
@@ -2728,11 +2688,11 @@ var InvitationsHandler = class {
|
|
|
2728
2688
|
...result,
|
|
2729
2689
|
state: Invitation4.State.SUCCESS
|
|
2730
2690
|
});
|
|
2731
|
-
log10.trace("dxos.sdk.invitations-handler.guest.onOpen",
|
|
2691
|
+
log10.trace("dxos.sdk.invitations-handler.guest.onOpen", trace4.end({
|
|
2732
2692
|
id: traceId
|
|
2733
2693
|
}), {
|
|
2734
2694
|
F: __dxlog_file13,
|
|
2735
|
-
L:
|
|
2695
|
+
L: 318,
|
|
2736
2696
|
S: this,
|
|
2737
2697
|
C: (f, a) => f(...a)
|
|
2738
2698
|
});
|
|
@@ -2742,7 +2702,7 @@ var InvitationsHandler = class {
|
|
|
2742
2702
|
...protocol.toJSON()
|
|
2743
2703
|
}, {
|
|
2744
2704
|
F: __dxlog_file13,
|
|
2745
|
-
L:
|
|
2705
|
+
L: 321,
|
|
2746
2706
|
S: this,
|
|
2747
2707
|
C: (f, a) => f(...a)
|
|
2748
2708
|
});
|
|
@@ -2750,19 +2710,19 @@ var InvitationsHandler = class {
|
|
|
2750
2710
|
} else {
|
|
2751
2711
|
log10("auth failed", err, {
|
|
2752
2712
|
F: __dxlog_file13,
|
|
2753
|
-
L:
|
|
2713
|
+
L: 324,
|
|
2754
2714
|
S: this,
|
|
2755
2715
|
C: (f, a) => f(...a)
|
|
2756
2716
|
});
|
|
2757
2717
|
guardedState.error(extension, err);
|
|
2758
2718
|
}
|
|
2759
2719
|
extensionCtx.close(err);
|
|
2760
|
-
log10.trace("dxos.sdk.invitations-handler.guest.onOpen",
|
|
2720
|
+
log10.trace("dxos.sdk.invitations-handler.guest.onOpen", trace4.error({
|
|
2761
2721
|
id: traceId,
|
|
2762
2722
|
error: err
|
|
2763
2723
|
}), {
|
|
2764
2724
|
F: __dxlog_file13,
|
|
2765
|
-
L:
|
|
2725
|
+
L: 328,
|
|
2766
2726
|
S: this,
|
|
2767
2727
|
C: (f, a) => f(...a)
|
|
2768
2728
|
});
|
|
@@ -2778,7 +2738,7 @@ var InvitationsHandler = class {
|
|
|
2778
2738
|
...protocol.toJSON()
|
|
2779
2739
|
}, {
|
|
2780
2740
|
F: __dxlog_file13,
|
|
2781
|
-
L:
|
|
2741
|
+
L: 337,
|
|
2782
2742
|
S: this,
|
|
2783
2743
|
C: (f, a) => f(...a)
|
|
2784
2744
|
});
|
|
@@ -2786,7 +2746,7 @@ var InvitationsHandler = class {
|
|
|
2786
2746
|
} else {
|
|
2787
2747
|
log10("auth failed", err, {
|
|
2788
2748
|
F: __dxlog_file13,
|
|
2789
|
-
L:
|
|
2749
|
+
L: 340,
|
|
2790
2750
|
S: this,
|
|
2791
2751
|
C: (f, a) => f(...a)
|
|
2792
2752
|
});
|
|
@@ -2804,21 +2764,21 @@ var InvitationsHandler = class {
|
|
|
2804
2764
|
} else {
|
|
2805
2765
|
invariant9(invitation.swarmKey, void 0, {
|
|
2806
2766
|
F: __dxlog_file13,
|
|
2807
|
-
L:
|
|
2767
|
+
L: 355,
|
|
2808
2768
|
S: this,
|
|
2809
2769
|
A: [
|
|
2810
2770
|
"invitation.swarmKey",
|
|
2811
2771
|
""
|
|
2812
2772
|
]
|
|
2813
2773
|
});
|
|
2814
|
-
await this._joinSwarm(ctx, invitation,
|
|
2774
|
+
await this._joinSwarm(ctx, invitation, InvitationOptions4.Role.GUEST, createExtension);
|
|
2815
2775
|
guardedState.set(null, Invitation4.State.CONNECTING);
|
|
2816
2776
|
}
|
|
2817
2777
|
});
|
|
2818
2778
|
}
|
|
2819
2779
|
async _joinSwarm(ctx, invitation, role, extensionFactory) {
|
|
2820
2780
|
let label;
|
|
2821
|
-
if (role ===
|
|
2781
|
+
if (role === InvitationOptions4.Role.GUEST) {
|
|
2822
2782
|
label = "invitation guest";
|
|
2823
2783
|
} else if (invitation.kind === Invitation4.Kind.DEVICE) {
|
|
2824
2784
|
label = "invitation host for device";
|
|
@@ -2904,7 +2864,7 @@ var InvitationsHandler = class {
|
|
|
2904
2864
|
oldState: stateToString(invitation.state)
|
|
2905
2865
|
}, {
|
|
2906
2866
|
F: __dxlog_file13,
|
|
2907
|
-
L:
|
|
2867
|
+
L: 449,
|
|
2908
2868
|
S: this,
|
|
2909
2869
|
C: (f, a) => f(...a)
|
|
2910
2870
|
});
|
|
@@ -2915,7 +2875,7 @@ var InvitationsHandler = class {
|
|
|
2915
2875
|
oldState: stateToString(invitation.state)
|
|
2916
2876
|
}, {
|
|
2917
2877
|
F: __dxlog_file13,
|
|
2918
|
-
L:
|
|
2878
|
+
L: 455,
|
|
2919
2879
|
S: this,
|
|
2920
2880
|
C: (f, a) => f(...a)
|
|
2921
2881
|
});
|
|
@@ -2934,7 +2894,7 @@ var InvitationsHandler = class {
|
|
|
2934
2894
|
for (let attempt = 1; attempt <= MAX_OTP_ATTEMPTS; attempt++) {
|
|
2935
2895
|
log10("guest waiting for authentication code...", void 0, {
|
|
2936
2896
|
F: __dxlog_file13,
|
|
2937
|
-
L:
|
|
2897
|
+
L: 480,
|
|
2938
2898
|
S: this,
|
|
2939
2899
|
C: (f, a) => f(...a)
|
|
2940
2900
|
});
|
|
@@ -2942,7 +2902,7 @@ var InvitationsHandler = class {
|
|
|
2942
2902
|
const authCode = await authenticated.wait(options);
|
|
2943
2903
|
log10("sending authentication request", void 0, {
|
|
2944
2904
|
F: __dxlog_file13,
|
|
2945
|
-
L:
|
|
2905
|
+
L: 484,
|
|
2946
2906
|
S: this,
|
|
2947
2907
|
C: (f, a) => f(...a)
|
|
2948
2908
|
});
|
|
@@ -2961,7 +2921,7 @@ var InvitationsHandler = class {
|
|
|
2961
2921
|
attempt
|
|
2962
2922
|
}, {
|
|
2963
2923
|
F: __dxlog_file13,
|
|
2964
|
-
L:
|
|
2924
|
+
L: 495,
|
|
2965
2925
|
S: this,
|
|
2966
2926
|
C: (f, a) => f(...a)
|
|
2967
2927
|
});
|
|
@@ -2979,7 +2939,7 @@ var InvitationsHandler = class {
|
|
|
2979
2939
|
}
|
|
2980
2940
|
log10("sending authentication request", void 0, {
|
|
2981
2941
|
F: __dxlog_file13,
|
|
2982
|
-
L:
|
|
2942
|
+
L: 514,
|
|
2983
2943
|
S: this,
|
|
2984
2944
|
C: (f, a) => f(...a)
|
|
2985
2945
|
});
|
|
@@ -3002,7 +2962,7 @@ var createAdmissionKeypair = () => {
|
|
|
3002
2962
|
};
|
|
3003
2963
|
|
|
3004
2964
|
// packages/sdk/client-services/src/packlets/invitations/invitations-service.ts
|
|
3005
|
-
import { Stream as
|
|
2965
|
+
import { Stream as Stream8 } from "@dxos/codec-protobuf";
|
|
3006
2966
|
import { QueryInvitationsResponse } from "@dxos/protocols/proto/dxos/client/services";
|
|
3007
2967
|
var InvitationsServiceImpl = class {
|
|
3008
2968
|
constructor(_invitationsManager) {
|
|
@@ -3013,13 +2973,13 @@ var InvitationsServiceImpl = class {
|
|
|
3013
2973
|
return {};
|
|
3014
2974
|
}
|
|
3015
2975
|
createInvitation(options) {
|
|
3016
|
-
return new
|
|
2976
|
+
return new Stream8(({ next, close }) => {
|
|
3017
2977
|
void this._invitationsManager.createInvitation(options).then((invitation) => invitation.subscribe(next, close, close)).catch(close);
|
|
3018
2978
|
});
|
|
3019
2979
|
}
|
|
3020
2980
|
acceptInvitation(request) {
|
|
3021
2981
|
const invitation = this._invitationsManager.acceptInvitation(request);
|
|
3022
|
-
return new
|
|
2982
|
+
return new Stream8(({ next, close }) => {
|
|
3023
2983
|
invitation.subscribe(next, close, close);
|
|
3024
2984
|
});
|
|
3025
2985
|
}
|
|
@@ -3030,7 +2990,7 @@ var InvitationsServiceImpl = class {
|
|
|
3030
2990
|
return this._invitationsManager.cancelInvitation(request);
|
|
3031
2991
|
}
|
|
3032
2992
|
queryInvitations() {
|
|
3033
|
-
return new
|
|
2993
|
+
return new Stream8(({ next, ctx }) => {
|
|
3034
2994
|
this._invitationsManager.invitationCreated.on(ctx, (invitation) => {
|
|
3035
2995
|
next({
|
|
3036
2996
|
action: QueryInvitationsResponse.Action.ADDED,
|
|
@@ -3730,107 +3690,312 @@ var InvitationsManager = class {
|
|
|
3730
3690
|
}
|
|
3731
3691
|
};
|
|
3732
3692
|
|
|
3733
|
-
// packages/sdk/client-services/src/packlets/
|
|
3734
|
-
import {
|
|
3735
|
-
import {
|
|
3736
|
-
import {
|
|
3737
|
-
|
|
3738
|
-
|
|
3739
|
-
|
|
3740
|
-
|
|
3741
|
-
|
|
3742
|
-
|
|
3743
|
-
|
|
3744
|
-
|
|
3745
|
-
|
|
3746
|
-
|
|
3747
|
-
|
|
3748
|
-
|
|
3749
|
-
|
|
3750
|
-
|
|
3751
|
-
|
|
3752
|
-
|
|
3753
|
-
|
|
3754
|
-
|
|
3755
|
-
|
|
3756
|
-
|
|
3757
|
-
this.
|
|
3758
|
-
this.
|
|
3759
|
-
this.
|
|
3760
|
-
this.onNewEpoch = new Event4();
|
|
3761
|
-
this._isProcessingRootDocs = false;
|
|
3762
|
-
}
|
|
3763
|
-
async _open(ctx) {
|
|
3764
|
-
}
|
|
3765
|
-
async _close(ctx) {
|
|
3766
|
-
this._isProcessingRootDocs = false;
|
|
3767
|
-
}
|
|
3768
|
-
async processCredential(credential) {
|
|
3769
|
-
if (!checkCredentialType(credential, "dxos.halo.credentials.Epoch")) {
|
|
3770
|
-
return;
|
|
3771
|
-
}
|
|
3772
|
-
this.lastEpoch = credential;
|
|
3773
|
-
if (credential.subject.assertion.automergeRoot) {
|
|
3774
|
-
this.rootUrl = credential.subject.assertion.automergeRoot;
|
|
3775
|
-
if (this._isProcessingRootDocs) {
|
|
3776
|
-
this._onNewRoot(this.rootUrl);
|
|
3777
|
-
}
|
|
3778
|
-
}
|
|
3779
|
-
this.onNewEpoch.emit(credential);
|
|
3780
|
-
}
|
|
3781
|
-
startProcessingRootDocs() {
|
|
3782
|
-
if (this._isProcessingRootDocs) {
|
|
3783
|
-
return;
|
|
3784
|
-
}
|
|
3785
|
-
if (this.rootUrl) {
|
|
3786
|
-
this._onNewRoot(this.rootUrl);
|
|
3787
|
-
}
|
|
3788
|
-
this._isProcessingRootDocs = true;
|
|
3693
|
+
// packages/sdk/client-services/src/packlets/locks/browser.ts
|
|
3694
|
+
import { asyncTimeout as asyncTimeout2, Trigger as Trigger7 } from "@dxos/async";
|
|
3695
|
+
import { RESOURCE_LOCK_TIMEOUT } from "@dxos/client-protocol";
|
|
3696
|
+
import { log as log13, logInfo } from "@dxos/log";
|
|
3697
|
+
function _ts_decorate3(decorators, target, key, desc) {
|
|
3698
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3699
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
3700
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
3701
|
+
else
|
|
3702
|
+
for (var i = decorators.length - 1; i >= 0; i--)
|
|
3703
|
+
if (d = decorators[i])
|
|
3704
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
3705
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3706
|
+
}
|
|
3707
|
+
var __dxlog_file16 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/locks/browser.ts";
|
|
3708
|
+
var Message;
|
|
3709
|
+
(function(Message2) {
|
|
3710
|
+
Message2["ACQUIRING"] = "acquiring";
|
|
3711
|
+
})(Message || (Message = {}));
|
|
3712
|
+
var Lock = class {
|
|
3713
|
+
constructor({ lockKey, onAcquire, onRelease }) {
|
|
3714
|
+
this._broadcastChannel = new BroadcastChannel("vault-resource-lock");
|
|
3715
|
+
this._releaseTrigger = new Trigger7();
|
|
3716
|
+
this._lockKey = lockKey;
|
|
3717
|
+
this._onAcquire = onAcquire;
|
|
3718
|
+
this._onRelease = onRelease;
|
|
3719
|
+
this._broadcastChannel.onmessage = this._onMessage.bind(this);
|
|
3789
3720
|
}
|
|
3790
|
-
|
|
3791
|
-
|
|
3721
|
+
get lockKey() {
|
|
3722
|
+
return this._lockKey;
|
|
3792
3723
|
}
|
|
3793
|
-
|
|
3794
|
-
|
|
3795
|
-
|
|
3796
|
-
|
|
3797
|
-
|
|
3798
|
-
|
|
3799
|
-
|
|
3800
|
-
|
|
3801
|
-
|
|
3802
|
-
|
|
3803
|
-
var LOAD_DOC_TIMEOUT = 1e4;
|
|
3804
|
-
var runEpochMigration = async (ctx, context) => {
|
|
3805
|
-
switch (context.migration) {
|
|
3806
|
-
case CreateEpochRequest.Migration.INIT_AUTOMERGE: {
|
|
3807
|
-
const document = context.echoHost.createDoc();
|
|
3808
|
-
await context.echoHost.flush();
|
|
3809
|
-
return {
|
|
3810
|
-
newRoot: document.url
|
|
3811
|
-
};
|
|
3812
|
-
}
|
|
3813
|
-
case CreateEpochRequest.Migration.PRUNE_AUTOMERGE_ROOT_HISTORY: {
|
|
3814
|
-
if (!context.currentRoot) {
|
|
3815
|
-
throw new Error("Space does not have an automerge root");
|
|
3816
|
-
}
|
|
3817
|
-
const rootHandle = await context.echoHost.loadDoc(ctx, context.currentRoot, {
|
|
3818
|
-
timeout: LOAD_DOC_TIMEOUT
|
|
3724
|
+
async acquire() {
|
|
3725
|
+
this._broadcastChannel.postMessage({
|
|
3726
|
+
message: "acquiring"
|
|
3727
|
+
});
|
|
3728
|
+
try {
|
|
3729
|
+
log13("aquiring lock...", void 0, {
|
|
3730
|
+
F: __dxlog_file16,
|
|
3731
|
+
L: 42,
|
|
3732
|
+
S: this,
|
|
3733
|
+
C: (f, a) => f(...a)
|
|
3819
3734
|
});
|
|
3820
|
-
|
|
3821
|
-
|
|
3822
|
-
return {
|
|
3823
|
-
newRoot: newRoot.url
|
|
3824
|
-
};
|
|
3825
|
-
}
|
|
3826
|
-
case CreateEpochRequest.Migration.FRAGMENT_AUTOMERGE_ROOT: {
|
|
3827
|
-
log13.info("Fragmenting", void 0, {
|
|
3735
|
+
await asyncTimeout2(this._requestLock(), RESOURCE_LOCK_TIMEOUT);
|
|
3736
|
+
log13("acquired lock", void 0, {
|
|
3828
3737
|
F: __dxlog_file16,
|
|
3829
|
-
L:
|
|
3830
|
-
S:
|
|
3738
|
+
L: 44,
|
|
3739
|
+
S: this,
|
|
3831
3740
|
C: (f, a) => f(...a)
|
|
3832
3741
|
});
|
|
3833
|
-
|
|
3742
|
+
} catch {
|
|
3743
|
+
log13("stealing lock...", void 0, {
|
|
3744
|
+
F: __dxlog_file16,
|
|
3745
|
+
L: 46,
|
|
3746
|
+
S: this,
|
|
3747
|
+
C: (f, a) => f(...a)
|
|
3748
|
+
});
|
|
3749
|
+
await this._requestLock(true);
|
|
3750
|
+
log13("stolen lock", void 0, {
|
|
3751
|
+
F: __dxlog_file16,
|
|
3752
|
+
L: 48,
|
|
3753
|
+
S: this,
|
|
3754
|
+
C: (f, a) => f(...a)
|
|
3755
|
+
});
|
|
3756
|
+
}
|
|
3757
|
+
}
|
|
3758
|
+
async release() {
|
|
3759
|
+
this._releaseTrigger.wake();
|
|
3760
|
+
}
|
|
3761
|
+
_onMessage(event) {
|
|
3762
|
+
if (event.data.message === "acquiring") {
|
|
3763
|
+
this._releaseTrigger.wake();
|
|
3764
|
+
}
|
|
3765
|
+
}
|
|
3766
|
+
async _requestLock(steal = false) {
|
|
3767
|
+
log13("requesting lock...", {
|
|
3768
|
+
steal
|
|
3769
|
+
}, {
|
|
3770
|
+
F: __dxlog_file16,
|
|
3771
|
+
L: 63,
|
|
3772
|
+
S: this,
|
|
3773
|
+
C: (f, a) => f(...a)
|
|
3774
|
+
});
|
|
3775
|
+
const acquired = new Trigger7();
|
|
3776
|
+
void navigator.locks.request(this._lockKey, {
|
|
3777
|
+
steal
|
|
3778
|
+
}, async () => {
|
|
3779
|
+
await this._onAcquire?.();
|
|
3780
|
+
acquired.wake();
|
|
3781
|
+
this._releaseTrigger = new Trigger7();
|
|
3782
|
+
await this._releaseTrigger.wait();
|
|
3783
|
+
log13("releasing lock...", void 0, {
|
|
3784
|
+
F: __dxlog_file16,
|
|
3785
|
+
L: 72,
|
|
3786
|
+
S: this,
|
|
3787
|
+
C: (f, a) => f(...a)
|
|
3788
|
+
});
|
|
3789
|
+
await this._onRelease?.();
|
|
3790
|
+
log13("released lock", void 0, {
|
|
3791
|
+
F: __dxlog_file16,
|
|
3792
|
+
L: 74,
|
|
3793
|
+
S: this,
|
|
3794
|
+
C: (f, a) => f(...a)
|
|
3795
|
+
});
|
|
3796
|
+
}).catch(async () => {
|
|
3797
|
+
await this._onRelease?.();
|
|
3798
|
+
});
|
|
3799
|
+
await acquired.wait();
|
|
3800
|
+
log13("recieved lock", {
|
|
3801
|
+
steal
|
|
3802
|
+
}, {
|
|
3803
|
+
F: __dxlog_file16,
|
|
3804
|
+
L: 81,
|
|
3805
|
+
S: this,
|
|
3806
|
+
C: (f, a) => f(...a)
|
|
3807
|
+
});
|
|
3808
|
+
}
|
|
3809
|
+
};
|
|
3810
|
+
_ts_decorate3([
|
|
3811
|
+
logInfo
|
|
3812
|
+
], Lock.prototype, "lockKey", null);
|
|
3813
|
+
var isLocked = (lockPath) => {
|
|
3814
|
+
throw new Error("Not implemented");
|
|
3815
|
+
};
|
|
3816
|
+
|
|
3817
|
+
// packages/sdk/client-services/src/packlets/services/client-rpc-server.ts
|
|
3818
|
+
import { Stream as Stream9 } from "@dxos/codec-protobuf";
|
|
3819
|
+
import { raise } from "@dxos/debug";
|
|
3820
|
+
import { parseMethodName, RpcPeer } from "@dxos/rpc";
|
|
3821
|
+
import { MapCounter, trace as trace5 } from "@dxos/tracing";
|
|
3822
|
+
function _ts_decorate4(decorators, target, key, desc) {
|
|
3823
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3824
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
3825
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
3826
|
+
else
|
|
3827
|
+
for (var i = decorators.length - 1; i >= 0; i--)
|
|
3828
|
+
if (d = decorators[i])
|
|
3829
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
3830
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3831
|
+
}
|
|
3832
|
+
var ClientRpcServer = class {
|
|
3833
|
+
constructor(params) {
|
|
3834
|
+
this._handlerCache = /* @__PURE__ */ new Map();
|
|
3835
|
+
this._callMetrics = new MapCounter();
|
|
3836
|
+
const { serviceRegistry, handleCall, handleStream, ...rpcOptions } = params;
|
|
3837
|
+
this._handleCall = handleCall;
|
|
3838
|
+
this._handleStream = handleStream;
|
|
3839
|
+
this._serviceRegistry = serviceRegistry;
|
|
3840
|
+
this._rpcPeer = new RpcPeer({
|
|
3841
|
+
...rpcOptions,
|
|
3842
|
+
callHandler: (method, params2) => {
|
|
3843
|
+
const [serviceName, methodName] = parseMethodName(method);
|
|
3844
|
+
const handler = (method2, params3) => this._getServiceHandler(serviceName).call(method2, params3);
|
|
3845
|
+
this._callMetrics.inc(`${serviceName}.${methodName} request`);
|
|
3846
|
+
if (this._handleCall) {
|
|
3847
|
+
return this._handleCall(methodName, params2, handler);
|
|
3848
|
+
} else {
|
|
3849
|
+
return handler(methodName, params2);
|
|
3850
|
+
}
|
|
3851
|
+
},
|
|
3852
|
+
streamHandler: (method, params2) => {
|
|
3853
|
+
const [serviceName, methodName] = parseMethodName(method);
|
|
3854
|
+
const handler = (method2, params3) => this._getServiceHandler(serviceName).callStream(method2, params3);
|
|
3855
|
+
this._callMetrics.inc(`${serviceName}.${methodName} request stream`);
|
|
3856
|
+
if (this._handleStream) {
|
|
3857
|
+
return Stream9.map(Stream9.unwrapPromise(this._handleStream(methodName, params2, handler)), (data) => {
|
|
3858
|
+
this._callMetrics.inc(`${serviceName}.${methodName} response stream`);
|
|
3859
|
+
return data;
|
|
3860
|
+
});
|
|
3861
|
+
} else {
|
|
3862
|
+
return handler(methodName, params2);
|
|
3863
|
+
}
|
|
3864
|
+
}
|
|
3865
|
+
});
|
|
3866
|
+
}
|
|
3867
|
+
get _services() {
|
|
3868
|
+
return Object.keys(this._serviceRegistry.services);
|
|
3869
|
+
}
|
|
3870
|
+
async open() {
|
|
3871
|
+
await this._rpcPeer.open();
|
|
3872
|
+
}
|
|
3873
|
+
async close() {
|
|
3874
|
+
await this._rpcPeer.close();
|
|
3875
|
+
}
|
|
3876
|
+
_getServiceHandler(serviceName) {
|
|
3877
|
+
if (!this._handlerCache.has(serviceName)) {
|
|
3878
|
+
const [key, descriptor] = Object.entries(this._serviceRegistry.descriptors).find(([key2, descriptor2]) => descriptor2.name === serviceName) ?? raise(new Error(`Service not available: ${serviceName}`));
|
|
3879
|
+
const service = this._serviceRegistry.services[key];
|
|
3880
|
+
if (!service) {
|
|
3881
|
+
throw new Error(`Service not available: ${serviceName}`);
|
|
3882
|
+
}
|
|
3883
|
+
this._handlerCache.set(serviceName, descriptor.createServer(service));
|
|
3884
|
+
}
|
|
3885
|
+
return this._handlerCache.get(serviceName);
|
|
3886
|
+
}
|
|
3887
|
+
};
|
|
3888
|
+
_ts_decorate4([
|
|
3889
|
+
trace5.metricsCounter()
|
|
3890
|
+
], ClientRpcServer.prototype, "_callMetrics", void 0);
|
|
3891
|
+
_ts_decorate4([
|
|
3892
|
+
trace5.info()
|
|
3893
|
+
], ClientRpcServer.prototype, "_services", null);
|
|
3894
|
+
ClientRpcServer = _ts_decorate4([
|
|
3895
|
+
trace5.resource()
|
|
3896
|
+
], ClientRpcServer);
|
|
3897
|
+
|
|
3898
|
+
// packages/sdk/client-services/src/packlets/spaces/data-space.ts
|
|
3899
|
+
import { Event as Event6, Mutex as Mutex2, scheduleTask as scheduleTask5, sleep as sleep3, synchronized, trackLeaks } from "@dxos/async";
|
|
3900
|
+
import { AUTH_TIMEOUT as AUTH_TIMEOUT2 } from "@dxos/client-protocol";
|
|
3901
|
+
import { Context as Context8, ContextDisposedError as ContextDisposedError3, cancelWithContext as cancelWithContext4 } from "@dxos/context";
|
|
3902
|
+
import { timed, warnAfterTimeout } from "@dxos/debug";
|
|
3903
|
+
import { createMappedFeedWriter } from "@dxos/echo-pipeline";
|
|
3904
|
+
import { SpaceDocVersion as SpaceDocVersion2 } from "@dxos/echo-protocol";
|
|
3905
|
+
import { failedInvariant } from "@dxos/invariant";
|
|
3906
|
+
import { PublicKey as PublicKey10 } from "@dxos/keys";
|
|
3907
|
+
import { log as log16 } from "@dxos/log";
|
|
3908
|
+
import { CancelledError, SystemError } from "@dxos/protocols";
|
|
3909
|
+
import { SpaceState as SpaceState2 } from "@dxos/protocols/proto/dxos/client/services";
|
|
3910
|
+
import { AdmittedFeed as AdmittedFeed3, SpaceMember as SpaceMember4 } from "@dxos/protocols/proto/dxos/halo/credentials";
|
|
3911
|
+
import { Timeframe as Timeframe3 } from "@dxos/timeframe";
|
|
3912
|
+
import { trace as trace6 } from "@dxos/tracing";
|
|
3913
|
+
import { ComplexSet as ComplexSet5 } from "@dxos/util";
|
|
3914
|
+
|
|
3915
|
+
// packages/sdk/client-services/src/packlets/spaces/automerge-space-state.ts
|
|
3916
|
+
import { Event as Event4 } from "@dxos/async";
|
|
3917
|
+
import { Resource as Resource2 } from "@dxos/context";
|
|
3918
|
+
import { checkCredentialType } from "@dxos/credentials";
|
|
3919
|
+
var AutomergeSpaceState = class extends Resource2 {
|
|
3920
|
+
constructor(_onNewRoot) {
|
|
3921
|
+
super();
|
|
3922
|
+
this._onNewRoot = _onNewRoot;
|
|
3923
|
+
this.rootUrl = void 0;
|
|
3924
|
+
this.lastEpoch = void 0;
|
|
3925
|
+
this.onNewEpoch = new Event4();
|
|
3926
|
+
this._isProcessingRootDocs = false;
|
|
3927
|
+
}
|
|
3928
|
+
async _open(ctx) {
|
|
3929
|
+
}
|
|
3930
|
+
async _close(ctx) {
|
|
3931
|
+
this._isProcessingRootDocs = false;
|
|
3932
|
+
}
|
|
3933
|
+
async processCredential(credential) {
|
|
3934
|
+
if (!checkCredentialType(credential, "dxos.halo.credentials.Epoch")) {
|
|
3935
|
+
return;
|
|
3936
|
+
}
|
|
3937
|
+
this.lastEpoch = credential;
|
|
3938
|
+
if (credential.subject.assertion.automergeRoot) {
|
|
3939
|
+
this.rootUrl = credential.subject.assertion.automergeRoot;
|
|
3940
|
+
if (this._isProcessingRootDocs) {
|
|
3941
|
+
this._onNewRoot(this.rootUrl);
|
|
3942
|
+
}
|
|
3943
|
+
}
|
|
3944
|
+
this.onNewEpoch.emit(credential);
|
|
3945
|
+
}
|
|
3946
|
+
startProcessingRootDocs() {
|
|
3947
|
+
if (this._isProcessingRootDocs) {
|
|
3948
|
+
return;
|
|
3949
|
+
}
|
|
3950
|
+
if (this.rootUrl) {
|
|
3951
|
+
this._onNewRoot(this.rootUrl);
|
|
3952
|
+
}
|
|
3953
|
+
this._isProcessingRootDocs = true;
|
|
3954
|
+
}
|
|
3955
|
+
async ensureEpochInitialized() {
|
|
3956
|
+
await this.onNewEpoch.waitForCondition(() => !!this.lastEpoch);
|
|
3957
|
+
}
|
|
3958
|
+
};
|
|
3959
|
+
|
|
3960
|
+
// packages/sdk/client-services/src/packlets/spaces/epoch-migrations.ts
|
|
3961
|
+
import { convertLegacyReferences, convertLegacySpaceRootDoc, findInlineObjectOfType, migrateDocument } from "@dxos/echo-db";
|
|
3962
|
+
import { SpaceDocVersion } from "@dxos/echo-protocol";
|
|
3963
|
+
import { TYPE_PROPERTIES } from "@dxos/echo-schema";
|
|
3964
|
+
import { invariant as invariant12 } from "@dxos/invariant";
|
|
3965
|
+
import { log as log14 } from "@dxos/log";
|
|
3966
|
+
import { CreateEpochRequest } from "@dxos/protocols/proto/dxos/client/services";
|
|
3967
|
+
var __dxlog_file17 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/epoch-migrations.ts";
|
|
3968
|
+
var LOAD_DOC_TIMEOUT = 1e4;
|
|
3969
|
+
var runEpochMigration = async (ctx, context) => {
|
|
3970
|
+
switch (context.migration) {
|
|
3971
|
+
case CreateEpochRequest.Migration.INIT_AUTOMERGE: {
|
|
3972
|
+
const document = context.echoHost.createDoc();
|
|
3973
|
+
await context.echoHost.flush();
|
|
3974
|
+
return {
|
|
3975
|
+
newRoot: document.url
|
|
3976
|
+
};
|
|
3977
|
+
}
|
|
3978
|
+
case CreateEpochRequest.Migration.PRUNE_AUTOMERGE_ROOT_HISTORY: {
|
|
3979
|
+
if (!context.currentRoot) {
|
|
3980
|
+
throw new Error("Space does not have an automerge root");
|
|
3981
|
+
}
|
|
3982
|
+
const rootHandle = await context.echoHost.loadDoc(ctx, context.currentRoot, {
|
|
3983
|
+
timeout: LOAD_DOC_TIMEOUT
|
|
3984
|
+
});
|
|
3985
|
+
const newRoot = context.echoHost.createDoc(rootHandle.docSync());
|
|
3986
|
+
await context.echoHost.flush();
|
|
3987
|
+
return {
|
|
3988
|
+
newRoot: newRoot.url
|
|
3989
|
+
};
|
|
3990
|
+
}
|
|
3991
|
+
case CreateEpochRequest.Migration.FRAGMENT_AUTOMERGE_ROOT: {
|
|
3992
|
+
log14.info("Fragmenting", void 0, {
|
|
3993
|
+
F: __dxlog_file17,
|
|
3994
|
+
L: 64,
|
|
3995
|
+
S: void 0,
|
|
3996
|
+
C: (f, a) => f(...a)
|
|
3997
|
+
});
|
|
3998
|
+
const currentRootUrl = context.currentRoot;
|
|
3834
3999
|
const rootHandle = await context.echoHost.loadDoc(ctx, currentRootUrl, {
|
|
3835
4000
|
timeout: LOAD_DOC_TIMEOUT
|
|
3836
4001
|
});
|
|
@@ -3838,7 +4003,7 @@ var runEpochMigration = async (ctx, context) => {
|
|
|
3838
4003
|
const properties = findInlineObjectOfType(rootHandle.docSync(), TYPE_PROPERTIES);
|
|
3839
4004
|
const otherObjects = objects.filter(([key]) => key !== properties?.[0]);
|
|
3840
4005
|
invariant12(properties, "Properties not found", {
|
|
3841
|
-
F:
|
|
4006
|
+
F: __dxlog_file17,
|
|
3842
4007
|
L: 75,
|
|
3843
4008
|
S: void 0,
|
|
3844
4009
|
A: [
|
|
@@ -3853,7 +4018,7 @@ var runEpochMigration = async (ctx, context) => {
|
|
|
3853
4018
|
])
|
|
3854
4019
|
});
|
|
3855
4020
|
invariant12(typeof newRoot.url === "string" && newRoot.url.length > 0, void 0, {
|
|
3856
|
-
F:
|
|
4021
|
+
F: __dxlog_file17,
|
|
3857
4022
|
L: 82,
|
|
3858
4023
|
S: void 0,
|
|
3859
4024
|
A: [
|
|
@@ -3894,7 +4059,7 @@ var runEpochMigration = async (ctx, context) => {
|
|
|
3894
4059
|
timeout: LOAD_DOC_TIMEOUT
|
|
3895
4060
|
});
|
|
3896
4061
|
invariant12(rootHandle.docSync(), "Root doc not found", {
|
|
3897
|
-
F:
|
|
4062
|
+
F: __dxlog_file17,
|
|
3898
4063
|
L: 115,
|
|
3899
4064
|
S: void 0,
|
|
3900
4065
|
A: [
|
|
@@ -3909,7 +4074,7 @@ var runEpochMigration = async (ctx, context) => {
|
|
|
3909
4074
|
timeout: LOAD_DOC_TIMEOUT
|
|
3910
4075
|
});
|
|
3911
4076
|
invariant12(handle.docSync(), void 0, {
|
|
3912
|
-
F:
|
|
4077
|
+
F: __dxlog_file17,
|
|
3913
4078
|
L: 122,
|
|
3914
4079
|
S: void 0,
|
|
3915
4080
|
A: [
|
|
@@ -3924,12 +4089,12 @@ var runEpochMigration = async (ctx, context) => {
|
|
|
3924
4089
|
});
|
|
3925
4090
|
newRootContent.links[id] = newHandle.url;
|
|
3926
4091
|
} catch (err) {
|
|
3927
|
-
|
|
4092
|
+
log14.warn("Failed to migrate reference", {
|
|
3928
4093
|
id,
|
|
3929
4094
|
url,
|
|
3930
4095
|
error: err
|
|
3931
4096
|
}, {
|
|
3932
|
-
F:
|
|
4097
|
+
F: __dxlog_file17,
|
|
3933
4098
|
L: 128,
|
|
3934
4099
|
S: void 0,
|
|
3935
4100
|
C: (f, a) => f(...a)
|
|
@@ -3948,7 +4113,7 @@ var runEpochMigration = async (ctx, context) => {
|
|
|
3948
4113
|
}
|
|
3949
4114
|
case CreateEpochRequest.Migration.REPLACE_AUTOMERGE_ROOT: {
|
|
3950
4115
|
invariant12(context.newAutomergeRoot, void 0, {
|
|
3951
|
-
F:
|
|
4116
|
+
F: __dxlog_file17,
|
|
3952
4117
|
L: 143,
|
|
3953
4118
|
S: void 0,
|
|
3954
4119
|
A: [
|
|
@@ -3966,15 +4131,15 @@ var runEpochMigration = async (ctx, context) => {
|
|
|
3966
4131
|
};
|
|
3967
4132
|
|
|
3968
4133
|
// packages/sdk/client-services/src/packlets/spaces/notarization-plugin.ts
|
|
3969
|
-
import { DeferredTask, Event as Event5, scheduleTask as scheduleTask4, sleep as sleep2, TimeoutError as TimeoutError3, Trigger as
|
|
4134
|
+
import { DeferredTask, Event as Event5, scheduleTask as scheduleTask4, sleep as sleep2, TimeoutError as TimeoutError3, Trigger as Trigger8 } from "@dxos/async";
|
|
3970
4135
|
import { Context as Context7, rejectOnDispose } from "@dxos/context";
|
|
3971
4136
|
import { invariant as invariant13 } from "@dxos/invariant";
|
|
3972
4137
|
import { PublicKey as PublicKey9 } from "@dxos/keys";
|
|
3973
|
-
import { log as
|
|
4138
|
+
import { log as log15 } from "@dxos/log";
|
|
3974
4139
|
import { schema as schema4 } from "@dxos/protocols";
|
|
3975
4140
|
import { RpcExtension as RpcExtension3 } from "@dxos/teleport";
|
|
3976
4141
|
import { ComplexMap as ComplexMap2, ComplexSet as ComplexSet4, entry } from "@dxos/util";
|
|
3977
|
-
var
|
|
4142
|
+
var __dxlog_file18 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/notarization-plugin.ts";
|
|
3978
4143
|
var DEFAULT_RETRY_TIMEOUT = 1e3;
|
|
3979
4144
|
var DEFAULT_SUCCESS_DELAY = 1e3;
|
|
3980
4145
|
var DEFAULT_NOTARIZE_TIMEOUT = 1e4;
|
|
@@ -3982,7 +4147,7 @@ var WRITER_NOT_SET_ERROR_CODE = "WRITER_NOT_SET";
|
|
|
3982
4147
|
var NotarizationPlugin = class {
|
|
3983
4148
|
constructor() {
|
|
3984
4149
|
this._ctx = new Context7(void 0, {
|
|
3985
|
-
F:
|
|
4150
|
+
F: __dxlog_file18,
|
|
3986
4151
|
L: 62
|
|
3987
4152
|
});
|
|
3988
4153
|
this._extensionOpened = new Event5();
|
|
@@ -4002,16 +4167,16 @@ var NotarizationPlugin = class {
|
|
|
4002
4167
|
* Request credentials to be notarized.
|
|
4003
4168
|
*/
|
|
4004
4169
|
async notarize({ ctx: opCtx, credentials, timeout = DEFAULT_NOTARIZE_TIMEOUT, retryTimeout = DEFAULT_RETRY_TIMEOUT, successDelay = DEFAULT_SUCCESS_DELAY }) {
|
|
4005
|
-
|
|
4170
|
+
log15("notarize", {
|
|
4006
4171
|
credentials
|
|
4007
4172
|
}, {
|
|
4008
|
-
F:
|
|
4173
|
+
F: __dxlog_file18,
|
|
4009
4174
|
L: 90,
|
|
4010
4175
|
S: this,
|
|
4011
4176
|
C: (f, a) => f(...a)
|
|
4012
4177
|
});
|
|
4013
4178
|
invariant13(credentials.every((credential) => credential.id), "Credentials must have an id", {
|
|
4014
|
-
F:
|
|
4179
|
+
F: __dxlog_file18,
|
|
4015
4180
|
L: 91,
|
|
4016
4181
|
S: this,
|
|
4017
4182
|
A: [
|
|
@@ -4019,13 +4184,13 @@ var NotarizationPlugin = class {
|
|
|
4019
4184
|
"'Credentials must have an id'"
|
|
4020
4185
|
]
|
|
4021
4186
|
});
|
|
4022
|
-
const errors = new
|
|
4187
|
+
const errors = new Trigger8();
|
|
4023
4188
|
const ctx = this._ctx.derive({
|
|
4024
4189
|
onError: (err) => {
|
|
4025
|
-
|
|
4190
|
+
log15.warn("Notarization error", {
|
|
4026
4191
|
err
|
|
4027
4192
|
}, {
|
|
4028
|
-
F:
|
|
4193
|
+
F: __dxlog_file18,
|
|
4029
4194
|
L: 99,
|
|
4030
4195
|
S: this,
|
|
4031
4196
|
C: (f, a) => f(...a)
|
|
@@ -4037,11 +4202,11 @@ var NotarizationPlugin = class {
|
|
|
4037
4202
|
opCtx?.onDispose(() => ctx.dispose());
|
|
4038
4203
|
if (timeout !== 0) {
|
|
4039
4204
|
scheduleTask4(ctx, () => {
|
|
4040
|
-
|
|
4205
|
+
log15.warn("Notarization timeout", {
|
|
4041
4206
|
timeout,
|
|
4042
4207
|
peers: Array.from(this._extensions).map((extension) => extension.remotePeerId)
|
|
4043
4208
|
}, {
|
|
4044
|
-
F:
|
|
4209
|
+
F: __dxlog_file18,
|
|
4045
4210
|
L: 111,
|
|
4046
4211
|
S: this,
|
|
4047
4212
|
C: (f, a) => f(...a)
|
|
@@ -4061,10 +4226,10 @@ var NotarizationPlugin = class {
|
|
|
4061
4226
|
...this._extensions
|
|
4062
4227
|
].find((peer2) => !peersTried.has(peer2));
|
|
4063
4228
|
if (!peer) {
|
|
4064
|
-
|
|
4229
|
+
log15.info("Exhausted all peers to notarize with", {
|
|
4065
4230
|
retryIn: retryTimeout
|
|
4066
4231
|
}, {
|
|
4067
|
-
F:
|
|
4232
|
+
F: __dxlog_file18,
|
|
4068
4233
|
L: 136,
|
|
4069
4234
|
S: this,
|
|
4070
4235
|
C: (f, a) => f(...a)
|
|
@@ -4074,11 +4239,11 @@ var NotarizationPlugin = class {
|
|
|
4074
4239
|
return;
|
|
4075
4240
|
}
|
|
4076
4241
|
peersTried.add(peer);
|
|
4077
|
-
|
|
4242
|
+
log15("try notarizing", {
|
|
4078
4243
|
peer: peer.localPeerId,
|
|
4079
4244
|
credentialId: credentials.map((credential) => credential.id)
|
|
4080
4245
|
}, {
|
|
4081
|
-
F:
|
|
4246
|
+
F: __dxlog_file18,
|
|
4082
4247
|
L: 143,
|
|
4083
4248
|
S: this,
|
|
4084
4249
|
C: (f, a) => f(...a)
|
|
@@ -4086,8 +4251,8 @@ var NotarizationPlugin = class {
|
|
|
4086
4251
|
await peer.rpc.NotarizationService.notarize({
|
|
4087
4252
|
credentials: credentials.filter((credential) => !this._processedCredentials.has(credential.id))
|
|
4088
4253
|
});
|
|
4089
|
-
|
|
4090
|
-
F:
|
|
4254
|
+
log15("success", void 0, {
|
|
4255
|
+
F: __dxlog_file18,
|
|
4091
4256
|
L: 147,
|
|
4092
4257
|
S: this,
|
|
4093
4258
|
C: (f, a) => f(...a)
|
|
@@ -4095,8 +4260,8 @@ var NotarizationPlugin = class {
|
|
|
4095
4260
|
await sleep2(successDelay);
|
|
4096
4261
|
} catch (err) {
|
|
4097
4262
|
if (!ctx.disposed && !err.message.includes(WRITER_NOT_SET_ERROR_CODE)) {
|
|
4098
|
-
|
|
4099
|
-
F:
|
|
4263
|
+
log15.info("error notarizing (recoverable)", err, {
|
|
4264
|
+
F: __dxlog_file18,
|
|
4100
4265
|
L: 151,
|
|
4101
4266
|
S: this,
|
|
4102
4267
|
C: (f, a) => f(...a)
|
|
@@ -4113,8 +4278,8 @@ var NotarizationPlugin = class {
|
|
|
4113
4278
|
allNotarized,
|
|
4114
4279
|
errors.wait()
|
|
4115
4280
|
]);
|
|
4116
|
-
|
|
4117
|
-
F:
|
|
4281
|
+
log15("done", void 0, {
|
|
4282
|
+
F: __dxlog_file18,
|
|
4118
4283
|
L: 162,
|
|
4119
4284
|
S: this,
|
|
4120
4285
|
C: (f, a) => f(...a)
|
|
@@ -4136,7 +4301,7 @@ var NotarizationPlugin = class {
|
|
|
4136
4301
|
}
|
|
4137
4302
|
setWriter(writer) {
|
|
4138
4303
|
invariant13(!this._writer, "Writer already set.", {
|
|
4139
|
-
F:
|
|
4304
|
+
F: __dxlog_file18,
|
|
4140
4305
|
L: 181,
|
|
4141
4306
|
S: this,
|
|
4142
4307
|
A: [
|
|
@@ -4150,7 +4315,7 @@ var NotarizationPlugin = class {
|
|
|
4150
4315
|
if (this._processedCredentials.has(id)) {
|
|
4151
4316
|
return;
|
|
4152
4317
|
}
|
|
4153
|
-
await entry(this._processCredentialsTriggers, id).orInsert(new
|
|
4318
|
+
await entry(this._processCredentialsTriggers, id).orInsert(new Trigger8()).value.wait();
|
|
4154
4319
|
}
|
|
4155
4320
|
/**
|
|
4156
4321
|
* Requests from other peers to notarize credentials.
|
|
@@ -4161,7 +4326,7 @@ var NotarizationPlugin = class {
|
|
|
4161
4326
|
}
|
|
4162
4327
|
for (const credential of request.credentials ?? []) {
|
|
4163
4328
|
invariant13(credential.id, "Credential must have an id", {
|
|
4164
|
-
F:
|
|
4329
|
+
F: __dxlog_file18,
|
|
4165
4330
|
L: 200,
|
|
4166
4331
|
S: this,
|
|
4167
4332
|
A: [
|
|
@@ -4178,10 +4343,10 @@ var NotarizationPlugin = class {
|
|
|
4178
4343
|
createExtension() {
|
|
4179
4344
|
const extension = new NotarizationTeleportExtension({
|
|
4180
4345
|
onOpen: async () => {
|
|
4181
|
-
|
|
4346
|
+
log15("extension opened", {
|
|
4182
4347
|
peer: extension.localPeerId
|
|
4183
4348
|
}, {
|
|
4184
|
-
F:
|
|
4349
|
+
F: __dxlog_file18,
|
|
4185
4350
|
L: 211,
|
|
4186
4351
|
S: this,
|
|
4187
4352
|
C: (f, a) => f(...a)
|
|
@@ -4190,10 +4355,10 @@ var NotarizationPlugin = class {
|
|
|
4190
4355
|
this._extensionOpened.emit();
|
|
4191
4356
|
},
|
|
4192
4357
|
onClose: async () => {
|
|
4193
|
-
|
|
4358
|
+
log15("extension closed", {
|
|
4194
4359
|
peer: extension.localPeerId
|
|
4195
4360
|
}, {
|
|
4196
|
-
F:
|
|
4361
|
+
F: __dxlog_file18,
|
|
4197
4362
|
L: 216,
|
|
4198
4363
|
S: this,
|
|
4199
4364
|
C: (f, a) => f(...a)
|
|
@@ -4237,7 +4402,7 @@ var NotarizationTeleportExtension = class extends RpcExtension3 {
|
|
|
4237
4402
|
};
|
|
4238
4403
|
|
|
4239
4404
|
// packages/sdk/client-services/src/packlets/spaces/data-space.ts
|
|
4240
|
-
function
|
|
4405
|
+
function _ts_decorate5(decorators, target, key, desc) {
|
|
4241
4406
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4242
4407
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
4243
4408
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -4310,11 +4475,11 @@ function _using_ctx() {
|
|
|
4310
4475
|
}
|
|
4311
4476
|
};
|
|
4312
4477
|
}
|
|
4313
|
-
var
|
|
4478
|
+
var __dxlog_file19 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space.ts";
|
|
4314
4479
|
var DataSpace = class {
|
|
4315
4480
|
constructor(params) {
|
|
4316
4481
|
this._ctx = new Context8(void 0, {
|
|
4317
|
-
F:
|
|
4482
|
+
F: __dxlog_file19,
|
|
4318
4483
|
L: 84
|
|
4319
4484
|
});
|
|
4320
4485
|
this._notarizationPlugin = new NotarizationPlugin();
|
|
@@ -4322,10 +4487,10 @@ var DataSpace = class {
|
|
|
4322
4487
|
// TODO(dmaretskyi): Move into Space?
|
|
4323
4488
|
this._automergeSpaceState = new AutomergeSpaceState((rootUrl) => this._onNewAutomergeRoot(rootUrl));
|
|
4324
4489
|
this._epochProcessingMutex = new Mutex2();
|
|
4325
|
-
this._state = SpaceState2.
|
|
4490
|
+
this._state = SpaceState2.SPACE_CLOSED;
|
|
4326
4491
|
this._databaseRoot = null;
|
|
4327
4492
|
/**
|
|
4328
|
-
* Error for _state === SpaceState.
|
|
4493
|
+
* Error for _state === SpaceState.SPACE_ERROR.
|
|
4329
4494
|
*/
|
|
4330
4495
|
this.error = void 0;
|
|
4331
4496
|
this.stateUpdate = new Event6();
|
|
@@ -4347,10 +4512,10 @@ var DataSpace = class {
|
|
|
4347
4512
|
});
|
|
4348
4513
|
this._cache = params.cache;
|
|
4349
4514
|
this._state = params.initialState;
|
|
4350
|
-
|
|
4515
|
+
log16("new state", {
|
|
4351
4516
|
state: SpaceState2[this._state]
|
|
4352
4517
|
}, {
|
|
4353
|
-
F:
|
|
4518
|
+
F: __dxlog_file19,
|
|
4354
4519
|
L: 146,
|
|
4355
4520
|
S: this,
|
|
4356
4521
|
C: (f, a) => f(...a)
|
|
@@ -4394,7 +4559,7 @@ var DataSpace = class {
|
|
|
4394
4559
|
};
|
|
4395
4560
|
}
|
|
4396
4561
|
async open() {
|
|
4397
|
-
if (this._state === SpaceState2.
|
|
4562
|
+
if (this._state === SpaceState2.SPACE_CLOSED) {
|
|
4398
4563
|
await this._open();
|
|
4399
4564
|
}
|
|
4400
4565
|
}
|
|
@@ -4406,14 +4571,14 @@ var DataSpace = class {
|
|
|
4406
4571
|
await this._automergeSpaceState.open();
|
|
4407
4572
|
await this._inner.spaceState.addCredentialProcessor(this._automergeSpaceState);
|
|
4408
4573
|
await this._inner.open(new Context8(void 0, {
|
|
4409
|
-
F:
|
|
4574
|
+
F: __dxlog_file19,
|
|
4410
4575
|
L: 215
|
|
4411
4576
|
}));
|
|
4412
|
-
this._state = SpaceState2.
|
|
4413
|
-
|
|
4577
|
+
this._state = SpaceState2.SPACE_CONTROL_ONLY;
|
|
4578
|
+
log16("new state", {
|
|
4414
4579
|
state: SpaceState2[this._state]
|
|
4415
4580
|
}, {
|
|
4416
|
-
F:
|
|
4581
|
+
F: __dxlog_file19,
|
|
4417
4582
|
L: 217,
|
|
4418
4583
|
S: this,
|
|
4419
4584
|
C: (f, a) => f(...a)
|
|
@@ -4427,18 +4592,18 @@ var DataSpace = class {
|
|
|
4427
4592
|
}
|
|
4428
4593
|
async _close() {
|
|
4429
4594
|
await this._callbacks.beforeClose?.();
|
|
4430
|
-
this._state = SpaceState2.
|
|
4431
|
-
|
|
4595
|
+
this._state = SpaceState2.SPACE_CLOSED;
|
|
4596
|
+
log16("new state", {
|
|
4432
4597
|
state: SpaceState2[this._state]
|
|
4433
4598
|
}, {
|
|
4434
|
-
F:
|
|
4599
|
+
F: __dxlog_file19,
|
|
4435
4600
|
L: 231,
|
|
4436
4601
|
S: this,
|
|
4437
4602
|
C: (f, a) => f(...a)
|
|
4438
4603
|
});
|
|
4439
4604
|
await this._ctx.dispose();
|
|
4440
4605
|
this._ctx = new Context8(void 0, {
|
|
4441
|
-
F:
|
|
4606
|
+
F: __dxlog_file19,
|
|
4442
4607
|
L: 233
|
|
4443
4608
|
});
|
|
4444
4609
|
await this.authVerifier.close();
|
|
@@ -4466,25 +4631,25 @@ var DataSpace = class {
|
|
|
4466
4631
|
await this.initializeDataPipeline();
|
|
4467
4632
|
} catch (err) {
|
|
4468
4633
|
if (err instanceof CancelledError || err instanceof ContextDisposedError3) {
|
|
4469
|
-
|
|
4470
|
-
F:
|
|
4634
|
+
log16("data pipeline initialization cancelled", err, {
|
|
4635
|
+
F: __dxlog_file19,
|
|
4471
4636
|
L: 265,
|
|
4472
4637
|
S: this,
|
|
4473
4638
|
C: (f, a) => f(...a)
|
|
4474
4639
|
});
|
|
4475
4640
|
return;
|
|
4476
4641
|
}
|
|
4477
|
-
|
|
4478
|
-
F:
|
|
4642
|
+
log16.error("Error initializing data pipeline", err, {
|
|
4643
|
+
F: __dxlog_file19,
|
|
4479
4644
|
L: 269,
|
|
4480
4645
|
S: this,
|
|
4481
4646
|
C: (f, a) => f(...a)
|
|
4482
4647
|
});
|
|
4483
|
-
this._state = SpaceState2.
|
|
4484
|
-
|
|
4648
|
+
this._state = SpaceState2.SPACE_ERROR;
|
|
4649
|
+
log16("new state", {
|
|
4485
4650
|
state: SpaceState2[this._state]
|
|
4486
4651
|
}, {
|
|
4487
|
-
F:
|
|
4652
|
+
F: __dxlog_file19,
|
|
4488
4653
|
L: 271,
|
|
4489
4654
|
S: this,
|
|
4490
4655
|
C: (f, a) => f(...a)
|
|
@@ -4497,31 +4662,31 @@ var DataSpace = class {
|
|
|
4497
4662
|
});
|
|
4498
4663
|
}
|
|
4499
4664
|
async initializeDataPipeline() {
|
|
4500
|
-
if (this._state !== SpaceState2.
|
|
4665
|
+
if (this._state !== SpaceState2.SPACE_CONTROL_ONLY) {
|
|
4501
4666
|
throw new SystemError("Invalid operation");
|
|
4502
4667
|
}
|
|
4503
|
-
this._state = SpaceState2.
|
|
4504
|
-
|
|
4668
|
+
this._state = SpaceState2.SPACE_INITIALIZING;
|
|
4669
|
+
log16("new state", {
|
|
4505
4670
|
state: SpaceState2[this._state]
|
|
4506
4671
|
}, {
|
|
4507
|
-
F:
|
|
4672
|
+
F: __dxlog_file19,
|
|
4508
4673
|
L: 287,
|
|
4509
4674
|
S: this,
|
|
4510
4675
|
C: (f, a) => f(...a)
|
|
4511
4676
|
});
|
|
4512
4677
|
await this._initializeAndReadControlPipeline();
|
|
4513
4678
|
await sleep3(1);
|
|
4514
|
-
const ready = this.stateUpdate.waitForCondition(() => this._state === SpaceState2.
|
|
4679
|
+
const ready = this.stateUpdate.waitForCondition(() => this._state === SpaceState2.SPACE_READY);
|
|
4515
4680
|
this._automergeSpaceState.startProcessingRootDocs();
|
|
4516
4681
|
await ready;
|
|
4517
4682
|
}
|
|
4518
4683
|
async _enterReadyState() {
|
|
4519
4684
|
await this._callbacks.beforeReady?.();
|
|
4520
|
-
this._state = SpaceState2.
|
|
4521
|
-
|
|
4685
|
+
this._state = SpaceState2.SPACE_READY;
|
|
4686
|
+
log16("new state", {
|
|
4522
4687
|
state: SpaceState2[this._state]
|
|
4523
4688
|
}, {
|
|
4524
|
-
F:
|
|
4689
|
+
F: __dxlog_file19,
|
|
4525
4690
|
L: 306,
|
|
4526
4691
|
S: this,
|
|
4527
4692
|
C: (f, a) => f(...a)
|
|
@@ -4536,8 +4701,8 @@ var DataSpace = class {
|
|
|
4536
4701
|
});
|
|
4537
4702
|
this.metrics.controlPipelineReady = /* @__PURE__ */ new Date();
|
|
4538
4703
|
await this._createWritableFeeds();
|
|
4539
|
-
|
|
4540
|
-
F:
|
|
4704
|
+
log16("writable feeds created", void 0, {
|
|
4705
|
+
F: __dxlog_file19,
|
|
4541
4706
|
L: 322,
|
|
4542
4707
|
S: this,
|
|
4543
4708
|
C: (f, a) => f(...a)
|
|
@@ -4596,11 +4761,11 @@ var DataSpace = class {
|
|
|
4596
4761
|
}
|
|
4597
4762
|
}
|
|
4598
4763
|
_onNewAutomergeRoot(rootUrl) {
|
|
4599
|
-
|
|
4764
|
+
log16("loading automerge root doc for space", {
|
|
4600
4765
|
space: this.key,
|
|
4601
4766
|
rootUrl
|
|
4602
4767
|
}, {
|
|
4603
|
-
F:
|
|
4768
|
+
F: __dxlog_file19,
|
|
4604
4769
|
L: 388,
|
|
4605
4770
|
S: this,
|
|
4606
4771
|
C: (f, a) => f(...a)
|
|
@@ -4628,17 +4793,15 @@ var DataSpace = class {
|
|
|
4628
4793
|
};
|
|
4629
4794
|
});
|
|
4630
4795
|
}
|
|
4631
|
-
const root = await this._echoHost.openSpaceRoot(handle.url);
|
|
4796
|
+
const root = await this._echoHost.openSpaceRoot(this.id, handle.url);
|
|
4632
4797
|
this._databaseRoot = root;
|
|
4633
4798
|
if (root.getVersion() !== SpaceDocVersion2.CURRENT) {
|
|
4634
|
-
|
|
4635
|
-
|
|
4636
|
-
|
|
4637
|
-
|
|
4799
|
+
this._state = SpaceState2.SPACE_REQUIRES_MIGRATION;
|
|
4800
|
+
this.stateUpdate.emit();
|
|
4801
|
+
} else if (this._state !== SpaceState2.SPACE_READY) {
|
|
4802
|
+
await this._enterReadyState();
|
|
4638
4803
|
} else {
|
|
4639
|
-
|
|
4640
|
-
await this._enterReadyState();
|
|
4641
|
-
}
|
|
4804
|
+
this.stateUpdate.emit();
|
|
4642
4805
|
}
|
|
4643
4806
|
} catch (_) {
|
|
4644
4807
|
_usingCtx.e = _;
|
|
@@ -4649,13 +4812,13 @@ var DataSpace = class {
|
|
|
4649
4812
|
if (err instanceof ContextDisposedError3) {
|
|
4650
4813
|
return;
|
|
4651
4814
|
}
|
|
4652
|
-
|
|
4815
|
+
log16.warn("error loading automerge root doc", {
|
|
4653
4816
|
space: this.key,
|
|
4654
4817
|
rootUrl,
|
|
4655
4818
|
err
|
|
4656
4819
|
}, {
|
|
4657
|
-
F:
|
|
4658
|
-
L:
|
|
4820
|
+
F: __dxlog_file19,
|
|
4821
|
+
L: 431,
|
|
4659
4822
|
S: this,
|
|
4660
4823
|
C: (f, a) => f(...a)
|
|
4661
4824
|
});
|
|
@@ -4708,91 +4871,95 @@ var DataSpace = class {
|
|
|
4708
4871
|
credential
|
|
4709
4872
|
}
|
|
4710
4873
|
});
|
|
4711
|
-
|
|
4874
|
+
const timeframe = new Timeframe3([
|
|
4712
4875
|
[
|
|
4713
4876
|
receipt.feedKey,
|
|
4714
4877
|
receipt.seq
|
|
4715
4878
|
]
|
|
4716
|
-
])
|
|
4879
|
+
]);
|
|
4880
|
+
await this.inner.controlPipeline.state.waitUntilTimeframe(timeframe);
|
|
4717
4881
|
await this._echoHost.updateIndexes();
|
|
4718
|
-
return
|
|
4882
|
+
return {
|
|
4883
|
+
credential,
|
|
4884
|
+
timeframe
|
|
4885
|
+
};
|
|
4719
4886
|
}
|
|
4720
4887
|
async activate() {
|
|
4721
4888
|
if (![
|
|
4722
|
-
SpaceState2.
|
|
4723
|
-
SpaceState2.
|
|
4889
|
+
SpaceState2.SPACE_CLOSED,
|
|
4890
|
+
SpaceState2.SPACE_INACTIVE
|
|
4724
4891
|
].includes(this._state)) {
|
|
4725
4892
|
return;
|
|
4726
4893
|
}
|
|
4727
|
-
await this._metadataStore.setSpaceState(this.key, SpaceState2.
|
|
4894
|
+
await this._metadataStore.setSpaceState(this.key, SpaceState2.SPACE_ACTIVE);
|
|
4728
4895
|
await this._open();
|
|
4729
4896
|
this.initializeDataPipelineAsync();
|
|
4730
4897
|
}
|
|
4731
4898
|
async deactivate() {
|
|
4732
|
-
if (this._state === SpaceState2.
|
|
4899
|
+
if (this._state === SpaceState2.SPACE_INACTIVE) {
|
|
4733
4900
|
return;
|
|
4734
4901
|
}
|
|
4735
|
-
await this._metadataStore.setSpaceState(this.key, SpaceState2.
|
|
4736
|
-
if (this._state !== SpaceState2.
|
|
4902
|
+
await this._metadataStore.setSpaceState(this.key, SpaceState2.SPACE_INACTIVE);
|
|
4903
|
+
if (this._state !== SpaceState2.SPACE_CLOSED) {
|
|
4737
4904
|
await this._close();
|
|
4738
4905
|
}
|
|
4739
|
-
this._state = SpaceState2.
|
|
4740
|
-
|
|
4906
|
+
this._state = SpaceState2.SPACE_INACTIVE;
|
|
4907
|
+
log16("new state", {
|
|
4741
4908
|
state: SpaceState2[this._state]
|
|
4742
4909
|
}, {
|
|
4743
|
-
F:
|
|
4744
|
-
L:
|
|
4910
|
+
F: __dxlog_file19,
|
|
4911
|
+
L: 513,
|
|
4745
4912
|
S: this,
|
|
4746
4913
|
C: (f, a) => f(...a)
|
|
4747
4914
|
});
|
|
4748
4915
|
this.stateUpdate.emit();
|
|
4749
4916
|
}
|
|
4750
4917
|
};
|
|
4751
|
-
|
|
4918
|
+
_ts_decorate5([
|
|
4752
4919
|
trace6.info()
|
|
4753
4920
|
], DataSpace.prototype, "_inner", void 0);
|
|
4754
|
-
|
|
4921
|
+
_ts_decorate5([
|
|
4755
4922
|
trace6.info()
|
|
4756
4923
|
], DataSpace.prototype, "id", null);
|
|
4757
|
-
|
|
4924
|
+
_ts_decorate5([
|
|
4758
4925
|
trace6.info()
|
|
4759
4926
|
], DataSpace.prototype, "key", null);
|
|
4760
|
-
|
|
4927
|
+
_ts_decorate5([
|
|
4761
4928
|
trace6.info({
|
|
4762
4929
|
enum: SpaceState2
|
|
4763
4930
|
})
|
|
4764
4931
|
], DataSpace.prototype, "state", null);
|
|
4765
|
-
|
|
4932
|
+
_ts_decorate5([
|
|
4766
4933
|
trace6.info({
|
|
4767
4934
|
depth: null
|
|
4768
4935
|
})
|
|
4769
4936
|
], DataSpace.prototype, "_automergeInfo", null);
|
|
4770
|
-
|
|
4937
|
+
_ts_decorate5([
|
|
4771
4938
|
synchronized
|
|
4772
4939
|
], DataSpace.prototype, "open", null);
|
|
4773
|
-
|
|
4940
|
+
_ts_decorate5([
|
|
4774
4941
|
synchronized
|
|
4775
4942
|
], DataSpace.prototype, "close", null);
|
|
4776
|
-
|
|
4943
|
+
_ts_decorate5([
|
|
4777
4944
|
trace6.span({
|
|
4778
4945
|
showInBrowserTimeline: true
|
|
4779
4946
|
})
|
|
4780
4947
|
], DataSpace.prototype, "initializeDataPipeline", null);
|
|
4781
|
-
|
|
4948
|
+
_ts_decorate5([
|
|
4782
4949
|
trace6.span({
|
|
4783
4950
|
showInBrowserTimeline: true
|
|
4784
4951
|
})
|
|
4785
4952
|
], DataSpace.prototype, "_initializeAndReadControlPipeline", null);
|
|
4786
|
-
|
|
4953
|
+
_ts_decorate5([
|
|
4787
4954
|
timed(1e4)
|
|
4788
4955
|
], DataSpace.prototype, "_createWritableFeeds", null);
|
|
4789
|
-
|
|
4956
|
+
_ts_decorate5([
|
|
4790
4957
|
synchronized
|
|
4791
4958
|
], DataSpace.prototype, "activate", null);
|
|
4792
|
-
|
|
4959
|
+
_ts_decorate5([
|
|
4793
4960
|
synchronized
|
|
4794
4961
|
], DataSpace.prototype, "deactivate", null);
|
|
4795
|
-
DataSpace =
|
|
4962
|
+
DataSpace = _ts_decorate5([
|
|
4796
4963
|
trackLeaks("open", "close"),
|
|
4797
4964
|
trace6.resource()
|
|
4798
4965
|
], DataSpace);
|
|
@@ -4810,7 +4977,7 @@ import { TYPE_PROPERTIES as TYPE_PROPERTIES2, generateEchoId, getTypeReference }
|
|
|
4810
4977
|
import { writeMessages as writeMessages3 } from "@dxos/feed-store";
|
|
4811
4978
|
import { invariant as invariant14 } from "@dxos/invariant";
|
|
4812
4979
|
import { PublicKey as PublicKey11 } from "@dxos/keys";
|
|
4813
|
-
import { log as
|
|
4980
|
+
import { log as log17 } from "@dxos/log";
|
|
4814
4981
|
import { trace as Trace2, AlreadyJoinedError as AlreadyJoinedError3 } from "@dxos/protocols";
|
|
4815
4982
|
import { Invitation as Invitation7, SpaceState as SpaceState3 } from "@dxos/protocols/proto/dxos/client/services";
|
|
4816
4983
|
import { SpaceMember as SpaceMember6 } from "@dxos/protocols/proto/dxos/halo/credentials";
|
|
@@ -4889,7 +5056,7 @@ var spaceGenesis = async (keyring, signingContext, space, automergeRoot) => {
|
|
|
4889
5056
|
};
|
|
4890
5057
|
|
|
4891
5058
|
// packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts
|
|
4892
|
-
function
|
|
5059
|
+
function _ts_decorate6(decorators, target, key, desc) {
|
|
4893
5060
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4894
5061
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
4895
5062
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -4899,7 +5066,7 @@ function _ts_decorate5(decorators, target, key, desc) {
|
|
|
4899
5066
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
4900
5067
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4901
5068
|
}
|
|
4902
|
-
var
|
|
5069
|
+
var __dxlog_file20 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts";
|
|
4903
5070
|
var PRESENCE_ANNOUNCE_INTERVAL = 1e4;
|
|
4904
5071
|
var PRESENCE_OFFLINE_TIMEOUT = 2e4;
|
|
4905
5072
|
var DEFAULT_SPACE_KEY = "__DEFAULT__";
|
|
@@ -4914,7 +5081,7 @@ var DataSpaceManager = class {
|
|
|
4914
5081
|
this._invitationsManager = _invitationsManager;
|
|
4915
5082
|
this._params = _params;
|
|
4916
5083
|
this._ctx = new Context9(void 0, {
|
|
4917
|
-
F:
|
|
5084
|
+
F: __dxlog_file20,
|
|
4918
5085
|
L: 104
|
|
4919
5086
|
});
|
|
4920
5087
|
this.updated = new Event7();
|
|
@@ -4949,45 +5116,45 @@ var DataSpaceManager = class {
|
|
|
4949
5116
|
return this._spaces;
|
|
4950
5117
|
}
|
|
4951
5118
|
async open() {
|
|
4952
|
-
|
|
4953
|
-
F:
|
|
5119
|
+
log17("open", void 0, {
|
|
5120
|
+
F: __dxlog_file20,
|
|
4954
5121
|
L: 156,
|
|
4955
5122
|
S: this,
|
|
4956
5123
|
C: (f, a) => f(...a)
|
|
4957
5124
|
});
|
|
4958
|
-
|
|
5125
|
+
log17.trace("dxos.echo.data-space-manager.open", Trace2.begin({
|
|
4959
5126
|
id: this._instanceId
|
|
4960
5127
|
}), {
|
|
4961
|
-
F:
|
|
5128
|
+
F: __dxlog_file20,
|
|
4962
5129
|
L: 157,
|
|
4963
5130
|
S: this,
|
|
4964
5131
|
C: (f, a) => f(...a)
|
|
4965
5132
|
});
|
|
4966
|
-
|
|
5133
|
+
log17("metadata loaded", {
|
|
4967
5134
|
spaces: this._metadataStore.spaces.length
|
|
4968
5135
|
}, {
|
|
4969
|
-
F:
|
|
5136
|
+
F: __dxlog_file20,
|
|
4970
5137
|
L: 158,
|
|
4971
5138
|
S: this,
|
|
4972
5139
|
C: (f, a) => f(...a)
|
|
4973
5140
|
});
|
|
4974
5141
|
await forEachAsync(this._metadataStore.spaces, async (spaceMetadata) => {
|
|
4975
5142
|
try {
|
|
4976
|
-
|
|
5143
|
+
log17("load space", {
|
|
4977
5144
|
spaceMetadata
|
|
4978
5145
|
}, {
|
|
4979
|
-
F:
|
|
5146
|
+
F: __dxlog_file20,
|
|
4980
5147
|
L: 162,
|
|
4981
5148
|
S: this,
|
|
4982
5149
|
C: (f, a) => f(...a)
|
|
4983
5150
|
});
|
|
4984
5151
|
await this._constructSpace(spaceMetadata);
|
|
4985
5152
|
} catch (err) {
|
|
4986
|
-
|
|
5153
|
+
log17.error("Error loading space", {
|
|
4987
5154
|
spaceMetadata,
|
|
4988
5155
|
err
|
|
4989
5156
|
}, {
|
|
4990
|
-
F:
|
|
5157
|
+
F: __dxlog_file20,
|
|
4991
5158
|
L: 165,
|
|
4992
5159
|
S: this,
|
|
4993
5160
|
C: (f, a) => f(...a)
|
|
@@ -4996,18 +5163,18 @@ var DataSpaceManager = class {
|
|
|
4996
5163
|
});
|
|
4997
5164
|
this._isOpen = true;
|
|
4998
5165
|
this.updated.emit();
|
|
4999
|
-
|
|
5166
|
+
log17.trace("dxos.echo.data-space-manager.open", Trace2.end({
|
|
5000
5167
|
id: this._instanceId
|
|
5001
5168
|
}), {
|
|
5002
|
-
F:
|
|
5169
|
+
F: __dxlog_file20,
|
|
5003
5170
|
L: 172,
|
|
5004
5171
|
S: this,
|
|
5005
5172
|
C: (f, a) => f(...a)
|
|
5006
5173
|
});
|
|
5007
5174
|
}
|
|
5008
5175
|
async close() {
|
|
5009
|
-
|
|
5010
|
-
F:
|
|
5176
|
+
log17("close", void 0, {
|
|
5177
|
+
F: __dxlog_file20,
|
|
5011
5178
|
L: 177,
|
|
5012
5179
|
S: this,
|
|
5013
5180
|
C: (f, a) => f(...a)
|
|
@@ -5024,7 +5191,7 @@ var DataSpaceManager = class {
|
|
|
5024
5191
|
*/
|
|
5025
5192
|
async createSpace() {
|
|
5026
5193
|
invariant14(this._isOpen, "Not open.", {
|
|
5027
|
-
F:
|
|
5194
|
+
F: __dxlog_file20,
|
|
5028
5195
|
L: 191,
|
|
5029
5196
|
S: this,
|
|
5030
5197
|
A: [
|
|
@@ -5040,12 +5207,12 @@ var DataSpaceManager = class {
|
|
|
5040
5207
|
genesisFeedKey: controlFeedKey,
|
|
5041
5208
|
controlFeedKey,
|
|
5042
5209
|
dataFeedKey,
|
|
5043
|
-
state: SpaceState3.
|
|
5210
|
+
state: SpaceState3.SPACE_ACTIVE
|
|
5044
5211
|
};
|
|
5045
|
-
|
|
5212
|
+
log17("creating space...", {
|
|
5046
5213
|
spaceKey
|
|
5047
5214
|
}, {
|
|
5048
|
-
F:
|
|
5215
|
+
F: __dxlog_file20,
|
|
5049
5216
|
L: 203,
|
|
5050
5217
|
S: this,
|
|
5051
5218
|
C: (f, a) => f(...a)
|
|
@@ -5057,7 +5224,7 @@ var DataSpaceManager = class {
|
|
|
5057
5224
|
await this._metadataStore.addSpace(metadata);
|
|
5058
5225
|
const memberCredential = credentials[1];
|
|
5059
5226
|
invariant14(getCredentialAssertion3(memberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
|
|
5060
|
-
F:
|
|
5227
|
+
F: __dxlog_file20,
|
|
5061
5228
|
L: 213,
|
|
5062
5229
|
S: this,
|
|
5063
5230
|
A: [
|
|
@@ -5085,11 +5252,11 @@ var DataSpaceManager = class {
|
|
|
5085
5252
|
return properties?.data?.[DEFAULT_SPACE_KEY] === this._signingContext.identityKey.toHex();
|
|
5086
5253
|
}
|
|
5087
5254
|
default:
|
|
5088
|
-
|
|
5255
|
+
log17.warn("unknown space version", {
|
|
5089
5256
|
version: space.databaseRoot.getVersion(),
|
|
5090
5257
|
spaceId: space.id
|
|
5091
5258
|
}, {
|
|
5092
|
-
F:
|
|
5259
|
+
F: __dxlog_file20,
|
|
5093
5260
|
L: 238,
|
|
5094
5261
|
S: this,
|
|
5095
5262
|
C: (f, a) => f(...a)
|
|
@@ -5124,7 +5291,7 @@ var DataSpaceManager = class {
|
|
|
5124
5291
|
async _getSpaceRootDocument(space) {
|
|
5125
5292
|
const automergeIndex = space.automergeSpaceState.rootUrl;
|
|
5126
5293
|
invariant14(automergeIndex, void 0, {
|
|
5127
|
-
F:
|
|
5294
|
+
F: __dxlog_file20,
|
|
5128
5295
|
L: 271,
|
|
5129
5296
|
S: this,
|
|
5130
5297
|
A: [
|
|
@@ -5138,16 +5305,16 @@ var DataSpaceManager = class {
|
|
|
5138
5305
|
}
|
|
5139
5306
|
// TODO(burdon): Rename join space.
|
|
5140
5307
|
async acceptSpace(opts) {
|
|
5141
|
-
|
|
5308
|
+
log17("accept space", {
|
|
5142
5309
|
opts
|
|
5143
5310
|
}, {
|
|
5144
|
-
F:
|
|
5311
|
+
F: __dxlog_file20,
|
|
5145
5312
|
L: 280,
|
|
5146
5313
|
S: this,
|
|
5147
5314
|
C: (f, a) => f(...a)
|
|
5148
5315
|
});
|
|
5149
5316
|
invariant14(this._isOpen, "Not open.", {
|
|
5150
|
-
F:
|
|
5317
|
+
F: __dxlog_file20,
|
|
5151
5318
|
L: 281,
|
|
5152
5319
|
S: this,
|
|
5153
5320
|
A: [
|
|
@@ -5156,7 +5323,7 @@ var DataSpaceManager = class {
|
|
|
5156
5323
|
]
|
|
5157
5324
|
});
|
|
5158
5325
|
invariant14(!this._spaces.has(opts.spaceKey), "Space already exists.", {
|
|
5159
|
-
F:
|
|
5326
|
+
F: __dxlog_file20,
|
|
5160
5327
|
L: 282,
|
|
5161
5328
|
S: this,
|
|
5162
5329
|
A: [
|
|
@@ -5180,7 +5347,7 @@ var DataSpaceManager = class {
|
|
|
5180
5347
|
async admitMember(options) {
|
|
5181
5348
|
const space = this._spaceManager.spaces.get(options.spaceKey);
|
|
5182
5349
|
invariant14(space, void 0, {
|
|
5183
|
-
F:
|
|
5350
|
+
F: __dxlog_file20,
|
|
5184
5351
|
L: 302,
|
|
5185
5352
|
S: this,
|
|
5186
5353
|
A: [
|
|
@@ -5193,7 +5360,7 @@ var DataSpaceManager = class {
|
|
|
5193
5360
|
}
|
|
5194
5361
|
const credentials = await createAdmissionCredentials(this._signingContext.credentialSigner, options.identityKey, space.key, space.genesisFeedKey, options.role, space.spaceState.membershipChainHeads, options.profile, options.delegationCredentialId);
|
|
5195
5362
|
invariant14(credentials[0].credential, void 0, {
|
|
5196
|
-
F:
|
|
5363
|
+
F: __dxlog_file20,
|
|
5197
5364
|
L: 321,
|
|
5198
5365
|
S: this,
|
|
5199
5366
|
A: [
|
|
@@ -5203,7 +5370,7 @@ var DataSpaceManager = class {
|
|
|
5203
5370
|
});
|
|
5204
5371
|
const spaceMemberCredential = credentials[0].credential.credential;
|
|
5205
5372
|
invariant14(getCredentialAssertion3(spaceMemberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
|
|
5206
|
-
F:
|
|
5373
|
+
F: __dxlog_file20,
|
|
5207
5374
|
L: 323,
|
|
5208
5375
|
S: this,
|
|
5209
5376
|
A: [
|
|
@@ -5222,7 +5389,7 @@ var DataSpaceManager = class {
|
|
|
5222
5389
|
async waitUntilSpaceReady(spaceKey) {
|
|
5223
5390
|
await cancelWithContext5(this._ctx, this.updated.waitForCondition(() => {
|
|
5224
5391
|
const space = this._spaces.get(spaceKey);
|
|
5225
|
-
return !!space && space.state === SpaceState3.
|
|
5392
|
+
return !!space && space.state === SpaceState3.SPACE_READY;
|
|
5226
5393
|
}));
|
|
5227
5394
|
}
|
|
5228
5395
|
async requestSpaceAdmissionCredential(spaceKey) {
|
|
@@ -5238,10 +5405,10 @@ var DataSpaceManager = class {
|
|
|
5238
5405
|
});
|
|
5239
5406
|
}
|
|
5240
5407
|
async _constructSpace(metadata) {
|
|
5241
|
-
|
|
5408
|
+
log17("construct space", {
|
|
5242
5409
|
metadata
|
|
5243
5410
|
}, {
|
|
5244
|
-
F:
|
|
5411
|
+
F: __dxlog_file20,
|
|
5245
5412
|
L: 358,
|
|
5246
5413
|
S: this,
|
|
5247
5414
|
C: (f, a) => f(...a)
|
|
@@ -5269,25 +5436,43 @@ var DataSpaceManager = class {
|
|
|
5269
5436
|
credentialProvider: createAuthProvider(this._signingContext.credentialSigner),
|
|
5270
5437
|
credentialAuthenticator: deferFunction2(() => dataSpace.authVerifier.verifier)
|
|
5271
5438
|
},
|
|
5272
|
-
onAuthorizedConnection: (session) => {
|
|
5273
|
-
|
|
5274
|
-
|
|
5275
|
-
|
|
5276
|
-
|
|
5277
|
-
|
|
5278
|
-
|
|
5279
|
-
|
|
5280
|
-
|
|
5439
|
+
onAuthorizedConnection: (session) => queueMicrotask(async () => {
|
|
5440
|
+
try {
|
|
5441
|
+
if (!session.isOpen) {
|
|
5442
|
+
return;
|
|
5443
|
+
}
|
|
5444
|
+
session.addExtension("dxos.mesh.teleport.admission-discovery", new CredentialServerExtension(space));
|
|
5445
|
+
session.addExtension("dxos.mesh.teleport.gossip", gossip.createExtension({
|
|
5446
|
+
remotePeerId: session.remotePeerId
|
|
5447
|
+
}));
|
|
5448
|
+
session.addExtension("dxos.mesh.teleport.notarization", dataSpace.notarizationPlugin.createExtension());
|
|
5449
|
+
await this._echoHost.authorizeDevice(space.key, session.remotePeerId);
|
|
5450
|
+
if (!session.isOpen) {
|
|
5451
|
+
return;
|
|
5452
|
+
}
|
|
5453
|
+
session.addExtension("dxos.mesh.teleport.automerge", this._echoHost.createReplicationExtension());
|
|
5454
|
+
} catch (err) {
|
|
5455
|
+
log17.warn("error on authorized connection", {
|
|
5456
|
+
err
|
|
5457
|
+
}, {
|
|
5458
|
+
F: __dxlog_file20,
|
|
5459
|
+
L: 403,
|
|
5460
|
+
S: this,
|
|
5461
|
+
C: (f, a) => f(...a)
|
|
5462
|
+
});
|
|
5463
|
+
await session.close(err);
|
|
5464
|
+
}
|
|
5465
|
+
}),
|
|
5281
5466
|
onAuthFailure: () => {
|
|
5282
|
-
|
|
5283
|
-
F:
|
|
5284
|
-
L:
|
|
5467
|
+
log17.warn("auth failure", void 0, {
|
|
5468
|
+
F: __dxlog_file20,
|
|
5469
|
+
L: 408,
|
|
5285
5470
|
S: this,
|
|
5286
5471
|
C: (f, a) => f(...a)
|
|
5287
5472
|
});
|
|
5288
5473
|
},
|
|
5289
5474
|
onMemberRolesChanged: async (members) => {
|
|
5290
|
-
if (dataSpace?.state === SpaceState3.
|
|
5475
|
+
if (dataSpace?.state === SpaceState3.SPACE_READY) {
|
|
5291
5476
|
this._handleMemberRoleChanges(presence, space.protocol, members);
|
|
5292
5477
|
}
|
|
5293
5478
|
},
|
|
@@ -5300,7 +5485,7 @@ var DataSpaceManager = class {
|
|
|
5300
5485
|
dataFeed && await space.setDataFeed(dataFeed);
|
|
5301
5486
|
const dataSpace = new DataSpace({
|
|
5302
5487
|
inner: space,
|
|
5303
|
-
initialState: metadata.state === SpaceState3.
|
|
5488
|
+
initialState: metadata.state === SpaceState3.SPACE_INACTIVE ? SpaceState3.SPACE_INACTIVE : SpaceState3.SPACE_CLOSED,
|
|
5304
5489
|
metadataStore: this._metadataStore,
|
|
5305
5490
|
gossip,
|
|
5306
5491
|
presence,
|
|
@@ -5310,22 +5495,22 @@ var DataSpaceManager = class {
|
|
|
5310
5495
|
signingContext: this._signingContext,
|
|
5311
5496
|
callbacks: {
|
|
5312
5497
|
beforeReady: async () => {
|
|
5313
|
-
|
|
5498
|
+
log17("before space ready", {
|
|
5314
5499
|
space: space.key
|
|
5315
5500
|
}, {
|
|
5316
|
-
F:
|
|
5317
|
-
L:
|
|
5501
|
+
F: __dxlog_file20,
|
|
5502
|
+
L: 435,
|
|
5318
5503
|
S: this,
|
|
5319
5504
|
C: (f, a) => f(...a)
|
|
5320
5505
|
});
|
|
5321
5506
|
},
|
|
5322
5507
|
afterReady: async () => {
|
|
5323
|
-
|
|
5508
|
+
log17("after space ready", {
|
|
5324
5509
|
space: space.key,
|
|
5325
5510
|
open: this._isOpen
|
|
5326
5511
|
}, {
|
|
5327
|
-
F:
|
|
5328
|
-
L:
|
|
5512
|
+
F: __dxlog_file20,
|
|
5513
|
+
L: 438,
|
|
5329
5514
|
S: this,
|
|
5330
5515
|
C: (f, a) => f(...a)
|
|
5331
5516
|
});
|
|
@@ -5340,11 +5525,11 @@ var DataSpaceManager = class {
|
|
|
5340
5525
|
}
|
|
5341
5526
|
},
|
|
5342
5527
|
beforeClose: async () => {
|
|
5343
|
-
|
|
5528
|
+
log17("before space close", {
|
|
5344
5529
|
space: space.key
|
|
5345
5530
|
}, {
|
|
5346
|
-
F:
|
|
5347
|
-
L:
|
|
5531
|
+
F: __dxlog_file20,
|
|
5532
|
+
L: 446,
|
|
5348
5533
|
S: this,
|
|
5349
5534
|
C: (f, a) => f(...a)
|
|
5350
5535
|
});
|
|
@@ -5353,7 +5538,7 @@ var DataSpaceManager = class {
|
|
|
5353
5538
|
cache: metadata.cache
|
|
5354
5539
|
});
|
|
5355
5540
|
presence.newPeer.on((peerState) => {
|
|
5356
|
-
if (dataSpace.state === SpaceState3.
|
|
5541
|
+
if (dataSpace.state === SpaceState3.SPACE_READY) {
|
|
5357
5542
|
this._handleNewPeerConnected(space, peerState);
|
|
5358
5543
|
}
|
|
5359
5544
|
});
|
|
@@ -5375,17 +5560,17 @@ var DataSpaceManager = class {
|
|
|
5375
5560
|
return (s && member.role === SpaceMember6.Role.REMOVED !== (s.authStatus === AuthStatus.FAILURE)) ?? false;
|
|
5376
5561
|
});
|
|
5377
5562
|
sessionsToClose.forEach((session) => {
|
|
5378
|
-
void session.close().catch(
|
|
5563
|
+
void session.close().catch(log17.error);
|
|
5379
5564
|
});
|
|
5380
5565
|
closedSessions += sessionsToClose.length;
|
|
5381
5566
|
}
|
|
5382
|
-
|
|
5567
|
+
log17("processed member role changes", {
|
|
5383
5568
|
roleChangeCount: memberInfo.length,
|
|
5384
5569
|
peersOnline: presence.getPeersOnline().length,
|
|
5385
5570
|
closedSessions
|
|
5386
5571
|
}, {
|
|
5387
|
-
F:
|
|
5388
|
-
L:
|
|
5572
|
+
F: __dxlog_file20,
|
|
5573
|
+
L: 482,
|
|
5389
5574
|
S: this,
|
|
5390
5575
|
C: (f, a) => f(...a)
|
|
5391
5576
|
});
|
|
@@ -5396,20 +5581,20 @@ var DataSpaceManager = class {
|
|
|
5396
5581
|
if (role === SpaceMember6.Role.REMOVED) {
|
|
5397
5582
|
const session = peerState.peerId && space.protocol.sessions.get(peerState.peerId);
|
|
5398
5583
|
if (session != null) {
|
|
5399
|
-
|
|
5584
|
+
log17("closing a session with a removed peer", {
|
|
5400
5585
|
peerId: peerState.peerId
|
|
5401
5586
|
}, {
|
|
5402
|
-
F:
|
|
5403
|
-
L:
|
|
5587
|
+
F: __dxlog_file20,
|
|
5588
|
+
L: 496,
|
|
5404
5589
|
S: this,
|
|
5405
5590
|
C: (f, a) => f(...a)
|
|
5406
5591
|
});
|
|
5407
|
-
void session.close().catch(
|
|
5592
|
+
void session.close().catch(log17.error);
|
|
5408
5593
|
}
|
|
5409
5594
|
}
|
|
5410
5595
|
}
|
|
5411
5596
|
async _handleInvitationStatusChange(dataSpace, delegatedInvitation, isActive) {
|
|
5412
|
-
if (dataSpace?.state !== SpaceState3.
|
|
5597
|
+
if (dataSpace?.state !== SpaceState3.SPACE_READY) {
|
|
5413
5598
|
return;
|
|
5414
5599
|
}
|
|
5415
5600
|
if (isActive) {
|
|
@@ -5444,19 +5629,19 @@ var DataSpaceManager = class {
|
|
|
5444
5629
|
await Promise.all(tasks);
|
|
5445
5630
|
}
|
|
5446
5631
|
};
|
|
5447
|
-
|
|
5632
|
+
_ts_decorate6([
|
|
5448
5633
|
synchronized2
|
|
5449
5634
|
], DataSpaceManager.prototype, "open", null);
|
|
5450
|
-
|
|
5635
|
+
_ts_decorate6([
|
|
5451
5636
|
synchronized2
|
|
5452
5637
|
], DataSpaceManager.prototype, "close", null);
|
|
5453
|
-
|
|
5638
|
+
_ts_decorate6([
|
|
5454
5639
|
synchronized2
|
|
5455
5640
|
], DataSpaceManager.prototype, "createSpace", null);
|
|
5456
|
-
|
|
5641
|
+
_ts_decorate6([
|
|
5457
5642
|
synchronized2
|
|
5458
5643
|
], DataSpaceManager.prototype, "acceptSpace", null);
|
|
5459
|
-
DataSpaceManager =
|
|
5644
|
+
DataSpaceManager = _ts_decorate6([
|
|
5460
5645
|
trackLeaks2("open", "close")
|
|
5461
5646
|
], DataSpaceManager);
|
|
5462
5647
|
|
|
@@ -5467,11 +5652,11 @@ import { createAdmissionCredentials as createAdmissionCredentials2, getCredentia
|
|
|
5467
5652
|
import { raise as raise2 } from "@dxos/debug";
|
|
5468
5653
|
import { writeMessages as writeMessages4 } from "@dxos/feed-store";
|
|
5469
5654
|
import { invariant as invariant15 } from "@dxos/invariant";
|
|
5470
|
-
import { log as
|
|
5655
|
+
import { log as log18 } from "@dxos/log";
|
|
5471
5656
|
import { ApiError, SpaceNotFoundError as SpaceNotFoundError2, encodeError, IdentityNotInitializedError, AuthorizationError as AuthorizationError2 } from "@dxos/protocols";
|
|
5472
5657
|
import { SpaceMember as SpaceMember7, SpaceState as SpaceState4 } from "@dxos/protocols/proto/dxos/client/services";
|
|
5473
5658
|
import { trace as trace8 } from "@dxos/tracing";
|
|
5474
|
-
var
|
|
5659
|
+
var __dxlog_file21 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/spaces-service.ts";
|
|
5475
5660
|
var SpacesServiceImpl = class {
|
|
5476
5661
|
constructor(_identityManager, _spaceManager, _getDataSpaceManager) {
|
|
5477
5662
|
this._identityManager = _identityManager;
|
|
@@ -5490,10 +5675,10 @@ var SpacesServiceImpl = class {
|
|
|
5490
5675
|
const space = dataSpaceManager.spaces.get(spaceKey) ?? raise2(new SpaceNotFoundError2(spaceKey));
|
|
5491
5676
|
if (state) {
|
|
5492
5677
|
switch (state) {
|
|
5493
|
-
case SpaceState4.
|
|
5678
|
+
case SpaceState4.SPACE_ACTIVE:
|
|
5494
5679
|
await space.activate();
|
|
5495
5680
|
break;
|
|
5496
|
-
case SpaceState4.
|
|
5681
|
+
case SpaceState4.SPACE_INACTIVE:
|
|
5497
5682
|
await space.deactivate();
|
|
5498
5683
|
break;
|
|
5499
5684
|
default:
|
|
@@ -5515,7 +5700,7 @@ var SpacesServiceImpl = class {
|
|
|
5515
5700
|
}
|
|
5516
5701
|
const credentials = await createAdmissionCredentials2(identity.getIdentityCredentialSigner(), request.memberKey, space.key, space.genesisFeedKey, request.newRole, space.spaceState.membershipChainHeads);
|
|
5517
5702
|
invariant15(credentials[0].credential, void 0, {
|
|
5518
|
-
F:
|
|
5703
|
+
F: __dxlog_file21,
|
|
5519
5704
|
L: 102,
|
|
5520
5705
|
S: this,
|
|
5521
5706
|
A: [
|
|
@@ -5525,7 +5710,7 @@ var SpacesServiceImpl = class {
|
|
|
5525
5710
|
});
|
|
5526
5711
|
const spaceMemberCredential = credentials[0].credential.credential;
|
|
5527
5712
|
invariant15(getCredentialAssertion4(spaceMemberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
|
|
5528
|
-
F:
|
|
5713
|
+
F: __dxlog_file21,
|
|
5529
5714
|
L: 104,
|
|
5530
5715
|
S: this,
|
|
5531
5716
|
A: [
|
|
@@ -5540,10 +5725,10 @@ var SpacesServiceImpl = class {
|
|
|
5540
5725
|
const scheduler = new UpdateScheduler(ctx, async () => {
|
|
5541
5726
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
5542
5727
|
const spaces = Array.from(dataSpaceManager.spaces.values()).map((space) => this._serializeSpace(space));
|
|
5543
|
-
|
|
5544
|
-
spaces
|
|
5545
|
-
}, {
|
|
5546
|
-
F:
|
|
5728
|
+
log18("update", () => ({
|
|
5729
|
+
ids: spaces.map((space) => space.id)
|
|
5730
|
+
}), {
|
|
5731
|
+
F: __dxlog_file21,
|
|
5547
5732
|
L: 115,
|
|
5548
5733
|
S: this,
|
|
5549
5734
|
C: (f, a) => f(...a)
|
|
@@ -5635,7 +5820,7 @@ var SpacesServiceImpl = class {
|
|
|
5635
5820
|
});
|
|
5636
5821
|
} else {
|
|
5637
5822
|
invariant15(!credential.id, "Id on unsigned credentials is not allowed", {
|
|
5638
|
-
F:
|
|
5823
|
+
F: __dxlog_file21,
|
|
5639
5824
|
L: 213,
|
|
5640
5825
|
S: this,
|
|
5641
5826
|
A: [
|
|
@@ -5644,7 +5829,7 @@ var SpacesServiceImpl = class {
|
|
|
5644
5829
|
]
|
|
5645
5830
|
});
|
|
5646
5831
|
invariant15(this._identityManager.identity, "Identity is not available", {
|
|
5647
|
-
F:
|
|
5832
|
+
F: __dxlog_file21,
|
|
5648
5833
|
L: 214,
|
|
5649
5834
|
S: this,
|
|
5650
5835
|
A: [
|
|
@@ -5654,7 +5839,7 @@ var SpacesServiceImpl = class {
|
|
|
5654
5839
|
});
|
|
5655
5840
|
const signer = this._identityManager.identity.getIdentityCredentialSigner();
|
|
5656
5841
|
invariant15(credential.issuer.equals(signer.getIssuer()), void 0, {
|
|
5657
|
-
F:
|
|
5842
|
+
F: __dxlog_file21,
|
|
5658
5843
|
L: 216,
|
|
5659
5844
|
S: this,
|
|
5660
5845
|
A: [
|
|
@@ -5677,12 +5862,13 @@ var SpacesServiceImpl = class {
|
|
|
5677
5862
|
async createEpoch({ spaceKey, migration, automergeRootUrl }) {
|
|
5678
5863
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
5679
5864
|
const space = dataSpaceManager.spaces.get(spaceKey) ?? raise2(new SpaceNotFoundError2(spaceKey));
|
|
5680
|
-
const
|
|
5865
|
+
const result = await space.createEpoch({
|
|
5681
5866
|
migration,
|
|
5682
5867
|
newAutomergeRoot: automergeRootUrl
|
|
5683
5868
|
});
|
|
5684
5869
|
return {
|
|
5685
|
-
epochCredential: credential
|
|
5870
|
+
epochCredential: result?.credential,
|
|
5871
|
+
controlTimeframe: result?.timeframe
|
|
5686
5872
|
};
|
|
5687
5873
|
}
|
|
5688
5874
|
async admitContact(request) {
|
|
@@ -5703,7 +5889,7 @@ var SpacesServiceImpl = class {
|
|
|
5703
5889
|
async _joinByAdmission({ credential }) {
|
|
5704
5890
|
const assertion = getCredentialAssertion4(credential);
|
|
5705
5891
|
invariant15(assertion["@type"] === "dxos.halo.credentials.SpaceMember", "Invalid credential", {
|
|
5706
|
-
F:
|
|
5892
|
+
F: __dxlog_file21,
|
|
5707
5893
|
L: 250,
|
|
5708
5894
|
S: this,
|
|
5709
5895
|
A: [
|
|
@@ -5713,7 +5899,7 @@ var SpacesServiceImpl = class {
|
|
|
5713
5899
|
});
|
|
5714
5900
|
const myIdentity = this._identityManager.identity;
|
|
5715
5901
|
invariant15(myIdentity && credential.subject.id.equals(myIdentity.identityKey), void 0, {
|
|
5716
|
-
F:
|
|
5902
|
+
F: __dxlog_file21,
|
|
5717
5903
|
L: 252,
|
|
5718
5904
|
S: this,
|
|
5719
5905
|
A: [
|
|
@@ -5789,7 +5975,7 @@ var SpacesServiceImpl = class {
|
|
|
5789
5975
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
5790
5976
|
const identity = this._identityManager.identity?.identityKey.truncate();
|
|
5791
5977
|
if (identity) {
|
|
5792
|
-
trace8.metrics.gauge("echo.space.count", dataSpaceManager.spaces.size, {
|
|
5978
|
+
trace8.metrics.gauge("dxos.echo.space.count", dataSpaceManager.spaces.size, {
|
|
5793
5979
|
tags: {
|
|
5794
5980
|
identity
|
|
5795
5981
|
}
|
|
@@ -5800,7 +5986,7 @@ var SpacesServiceImpl = class {
|
|
|
5800
5986
|
var getChannelId = (channel) => `user-channel/${channel}`;
|
|
5801
5987
|
|
|
5802
5988
|
// packages/sdk/client-services/src/packlets/services/service-context.ts
|
|
5803
|
-
import { Trigger as
|
|
5989
|
+
import { Trigger as Trigger9 } from "@dxos/async";
|
|
5804
5990
|
import { Context as Context10, Resource as Resource3 } from "@dxos/context";
|
|
5805
5991
|
import { getCredentialAssertion as getCredentialAssertion5 } from "@dxos/credentials";
|
|
5806
5992
|
import { failUndefined as failUndefined2 } from "@dxos/debug";
|
|
@@ -5810,13 +5996,13 @@ import { FeedFactory, FeedStore } from "@dxos/feed-store";
|
|
|
5810
5996
|
import { invariant as invariant16 } from "@dxos/invariant";
|
|
5811
5997
|
import { Keyring } from "@dxos/keyring";
|
|
5812
5998
|
import { PublicKey as PublicKey12 } from "@dxos/keys";
|
|
5813
|
-
import { log as
|
|
5999
|
+
import { log as log19 } from "@dxos/log";
|
|
5814
6000
|
import { InvalidStorageVersionError, STORAGE_VERSION as STORAGE_VERSION2, trace as trace9 } from "@dxos/protocols";
|
|
5815
6001
|
import { Invitation as Invitation8 } from "@dxos/protocols/proto/dxos/client/services";
|
|
5816
6002
|
import { BlobStore } from "@dxos/teleport-extension-object-sync";
|
|
5817
6003
|
import { trace as Trace3 } from "@dxos/tracing";
|
|
5818
6004
|
import { safeInstanceof } from "@dxos/util";
|
|
5819
|
-
function
|
|
6005
|
+
function _ts_decorate7(decorators, target, key, desc) {
|
|
5820
6006
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
5821
6007
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
5822
6008
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -5826,7 +6012,7 @@ function _ts_decorate6(decorators, target, key, desc) {
|
|
|
5826
6012
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5827
6013
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
5828
6014
|
}
|
|
5829
|
-
var
|
|
6015
|
+
var __dxlog_file22 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-context.ts";
|
|
5830
6016
|
var ServiceContext = class extends Resource3 {
|
|
5831
6017
|
constructor(storage, level, networkManager, signalManager, _runtimeParams) {
|
|
5832
6018
|
super();
|
|
@@ -5835,7 +6021,7 @@ var ServiceContext = class extends Resource3 {
|
|
|
5835
6021
|
this.networkManager = networkManager;
|
|
5836
6022
|
this.signalManager = signalManager;
|
|
5837
6023
|
this._runtimeParams = _runtimeParams;
|
|
5838
|
-
this.initialized = new
|
|
6024
|
+
this.initialized = new Trigger9();
|
|
5839
6025
|
this._handlerFactories = /* @__PURE__ */ new Map();
|
|
5840
6026
|
this._instanceId = PublicKey12.random().toHex();
|
|
5841
6027
|
this.metadataStore = new MetadataStore(storage.createDirectory("metadata"));
|
|
@@ -5869,16 +6055,16 @@ var ServiceContext = class extends Resource3 {
|
|
|
5869
6055
|
}
|
|
5870
6056
|
async _open(ctx) {
|
|
5871
6057
|
await this._checkStorageVersion();
|
|
5872
|
-
|
|
5873
|
-
F:
|
|
6058
|
+
log19("opening...", void 0, {
|
|
6059
|
+
F: __dxlog_file22,
|
|
5874
6060
|
L: 149,
|
|
5875
6061
|
S: this,
|
|
5876
6062
|
C: (f, a) => f(...a)
|
|
5877
6063
|
});
|
|
5878
|
-
|
|
6064
|
+
log19.trace("dxos.sdk.service-context.open", trace9.begin({
|
|
5879
6065
|
id: this._instanceId
|
|
5880
6066
|
}), {
|
|
5881
|
-
F:
|
|
6067
|
+
F: __dxlog_file22,
|
|
5882
6068
|
L: 150,
|
|
5883
6069
|
S: this,
|
|
5884
6070
|
C: (f, a) => f(...a)
|
|
@@ -5893,32 +6079,32 @@ var ServiceContext = class extends Resource3 {
|
|
|
5893
6079
|
await this._initialize(ctx);
|
|
5894
6080
|
}
|
|
5895
6081
|
const loadedInvitations = await this.invitationsManager.loadPersistentInvitations();
|
|
5896
|
-
|
|
6082
|
+
log19("loaded persistent invitations", {
|
|
5897
6083
|
count: loadedInvitations.invitations?.length
|
|
5898
6084
|
}, {
|
|
5899
|
-
F:
|
|
6085
|
+
F: __dxlog_file22,
|
|
5900
6086
|
L: 163,
|
|
5901
6087
|
S: this,
|
|
5902
6088
|
C: (f, a) => f(...a)
|
|
5903
6089
|
});
|
|
5904
|
-
|
|
6090
|
+
log19.trace("dxos.sdk.service-context.open", trace9.end({
|
|
5905
6091
|
id: this._instanceId
|
|
5906
6092
|
}), {
|
|
5907
|
-
F:
|
|
6093
|
+
F: __dxlog_file22,
|
|
5908
6094
|
L: 165,
|
|
5909
6095
|
S: this,
|
|
5910
6096
|
C: (f, a) => f(...a)
|
|
5911
6097
|
});
|
|
5912
|
-
|
|
5913
|
-
F:
|
|
6098
|
+
log19("opened", void 0, {
|
|
6099
|
+
F: __dxlog_file22,
|
|
5914
6100
|
L: 166,
|
|
5915
6101
|
S: this,
|
|
5916
6102
|
C: (f, a) => f(...a)
|
|
5917
6103
|
});
|
|
5918
6104
|
}
|
|
5919
6105
|
async _close(ctx) {
|
|
5920
|
-
|
|
5921
|
-
F:
|
|
6106
|
+
log19("closing...", void 0, {
|
|
6107
|
+
F: __dxlog_file22,
|
|
5922
6108
|
L: 170,
|
|
5923
6109
|
S: this,
|
|
5924
6110
|
C: (f, a) => f(...a)
|
|
@@ -5934,8 +6120,8 @@ var ServiceContext = class extends Resource3 {
|
|
|
5934
6120
|
await this.echoHost.close(ctx);
|
|
5935
6121
|
await this.networkManager.close();
|
|
5936
6122
|
await this.signalManager.close();
|
|
5937
|
-
|
|
5938
|
-
F:
|
|
6123
|
+
log19("closed", void 0, {
|
|
6124
|
+
F: __dxlog_file22,
|
|
5939
6125
|
L: 182,
|
|
5940
6126
|
S: this,
|
|
5941
6127
|
C: (f, a) => f(...a)
|
|
@@ -5944,7 +6130,7 @@ var ServiceContext = class extends Resource3 {
|
|
|
5944
6130
|
async createIdentity(params = {}) {
|
|
5945
6131
|
const identity = await this.identityManager.createIdentity(params);
|
|
5946
6132
|
await this._initialize(new Context10(void 0, {
|
|
5947
|
-
F:
|
|
6133
|
+
F: __dxlog_file22,
|
|
5948
6134
|
L: 187
|
|
5949
6135
|
}));
|
|
5950
6136
|
return identity;
|
|
@@ -5952,7 +6138,7 @@ var ServiceContext = class extends Resource3 {
|
|
|
5952
6138
|
getInvitationHandler(invitation) {
|
|
5953
6139
|
const factory = this._handlerFactories.get(invitation.kind);
|
|
5954
6140
|
invariant16(factory, `Unknown invitation kind: ${invitation.kind}`, {
|
|
5955
|
-
F:
|
|
6141
|
+
F: __dxlog_file22,
|
|
5956
6142
|
L: 193,
|
|
5957
6143
|
S: this,
|
|
5958
6144
|
A: [
|
|
@@ -5973,7 +6159,7 @@ var ServiceContext = class extends Resource3 {
|
|
|
5973
6159
|
async _acceptIdentity(params) {
|
|
5974
6160
|
const identity = await this.identityManager.acceptIdentity(params);
|
|
5975
6161
|
await this._initialize(new Context10(void 0, {
|
|
5976
|
-
F:
|
|
6162
|
+
F: __dxlog_file22,
|
|
5977
6163
|
L: 209
|
|
5978
6164
|
}));
|
|
5979
6165
|
return identity;
|
|
@@ -5986,8 +6172,8 @@ var ServiceContext = class extends Resource3 {
|
|
|
5986
6172
|
}
|
|
5987
6173
|
// Called when identity is created.
|
|
5988
6174
|
async _initialize(ctx) {
|
|
5989
|
-
|
|
5990
|
-
F:
|
|
6175
|
+
log19("initializing spaces...", void 0, {
|
|
6176
|
+
F: __dxlog_file22,
|
|
5991
6177
|
L: 224,
|
|
5992
6178
|
S: this,
|
|
5993
6179
|
C: (f, a) => f(...a)
|
|
@@ -6010,7 +6196,7 @@ var ServiceContext = class extends Resource3 {
|
|
|
6010
6196
|
await this.dataSpaceManager.open();
|
|
6011
6197
|
this._handlerFactories.set(Invitation8.Kind.SPACE, (invitation) => {
|
|
6012
6198
|
invariant16(this.dataSpaceManager, "dataSpaceManager not initialized yet", {
|
|
6013
|
-
F:
|
|
6199
|
+
F: __dxlog_file22,
|
|
6014
6200
|
L: 249,
|
|
6015
6201
|
S: this,
|
|
6016
6202
|
A: [
|
|
@@ -6031,10 +6217,10 @@ var ServiceContext = class extends Resource3 {
|
|
|
6031
6217
|
return;
|
|
6032
6218
|
}
|
|
6033
6219
|
if (!this.dataSpaceManager) {
|
|
6034
|
-
|
|
6220
|
+
log19("dataSpaceManager not initialized yet, ignoring space admission", {
|
|
6035
6221
|
details: assertion
|
|
6036
6222
|
}, {
|
|
6037
|
-
F:
|
|
6223
|
+
F: __dxlog_file22,
|
|
6038
6224
|
L: 265,
|
|
6039
6225
|
S: this,
|
|
6040
6226
|
C: (f, a) => f(...a)
|
|
@@ -6042,10 +6228,10 @@ var ServiceContext = class extends Resource3 {
|
|
|
6042
6228
|
return;
|
|
6043
6229
|
}
|
|
6044
6230
|
if (this.dataSpaceManager.spaces.has(assertion.spaceKey)) {
|
|
6045
|
-
|
|
6231
|
+
log19("space already exists, ignoring space admission", {
|
|
6046
6232
|
details: assertion
|
|
6047
6233
|
}, {
|
|
6048
|
-
F:
|
|
6234
|
+
F: __dxlog_file22,
|
|
6049
6235
|
L: 269,
|
|
6050
6236
|
S: this,
|
|
6051
6237
|
C: (f, a) => f(...a)
|
|
@@ -6053,10 +6239,10 @@ var ServiceContext = class extends Resource3 {
|
|
|
6053
6239
|
return;
|
|
6054
6240
|
}
|
|
6055
6241
|
try {
|
|
6056
|
-
|
|
6242
|
+
log19("accepting space recorded in halo", {
|
|
6057
6243
|
details: assertion
|
|
6058
6244
|
}, {
|
|
6059
|
-
F:
|
|
6245
|
+
F: __dxlog_file22,
|
|
6060
6246
|
L: 274,
|
|
6061
6247
|
S: this,
|
|
6062
6248
|
C: (f, a) => f(...a)
|
|
@@ -6066,8 +6252,8 @@ var ServiceContext = class extends Resource3 {
|
|
|
6066
6252
|
genesisFeedKey: assertion.genesisFeedKey
|
|
6067
6253
|
});
|
|
6068
6254
|
} catch (err) {
|
|
6069
|
-
|
|
6070
|
-
F:
|
|
6255
|
+
log19.catch(err, void 0, {
|
|
6256
|
+
F: __dxlog_file22,
|
|
6071
6257
|
L: 280,
|
|
6072
6258
|
S: this,
|
|
6073
6259
|
C: (f, a) => f(...a)
|
|
@@ -6078,13 +6264,13 @@ var ServiceContext = class extends Resource3 {
|
|
|
6078
6264
|
await identity.space.spaceState.addCredentialProcessor(this._deviceSpaceSync);
|
|
6079
6265
|
}
|
|
6080
6266
|
};
|
|
6081
|
-
|
|
6267
|
+
_ts_decorate7([
|
|
6082
6268
|
Trace3.span()
|
|
6083
6269
|
], ServiceContext.prototype, "_open", null);
|
|
6084
|
-
|
|
6270
|
+
_ts_decorate7([
|
|
6085
6271
|
Trace3.span()
|
|
6086
6272
|
], ServiceContext.prototype, "_initialize", null);
|
|
6087
|
-
ServiceContext =
|
|
6273
|
+
ServiceContext = _ts_decorate7([
|
|
6088
6274
|
safeInstanceof("dxos.client-services.ServiceContext"),
|
|
6089
6275
|
Trace3.resource()
|
|
6090
6276
|
], ServiceContext);
|
|
@@ -6113,130 +6299,6 @@ var ServiceRegistry = class {
|
|
|
6113
6299
|
}
|
|
6114
6300
|
};
|
|
6115
6301
|
|
|
6116
|
-
// packages/sdk/client-services/src/packlets/locks/browser.ts
|
|
6117
|
-
import { asyncTimeout as asyncTimeout2, Trigger as Trigger9 } from "@dxos/async";
|
|
6118
|
-
import { RESOURCE_LOCK_TIMEOUT } from "@dxos/client-protocol";
|
|
6119
|
-
import { log as log19, logInfo } from "@dxos/log";
|
|
6120
|
-
function _ts_decorate7(decorators, target, key, desc) {
|
|
6121
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
6122
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
6123
|
-
r = Reflect.decorate(decorators, target, key, desc);
|
|
6124
|
-
else
|
|
6125
|
-
for (var i = decorators.length - 1; i >= 0; i--)
|
|
6126
|
-
if (d = decorators[i])
|
|
6127
|
-
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6128
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6129
|
-
}
|
|
6130
|
-
var __dxlog_file22 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/locks/browser.ts";
|
|
6131
|
-
var Message;
|
|
6132
|
-
(function(Message2) {
|
|
6133
|
-
Message2["ACQUIRING"] = "acquiring";
|
|
6134
|
-
})(Message || (Message = {}));
|
|
6135
|
-
var Lock = class {
|
|
6136
|
-
constructor({ lockKey, onAcquire, onRelease }) {
|
|
6137
|
-
this._broadcastChannel = new BroadcastChannel("vault-resource-lock");
|
|
6138
|
-
this._releaseTrigger = new Trigger9();
|
|
6139
|
-
this._lockKey = lockKey;
|
|
6140
|
-
this._onAcquire = onAcquire;
|
|
6141
|
-
this._onRelease = onRelease;
|
|
6142
|
-
this._broadcastChannel.onmessage = this._onMessage.bind(this);
|
|
6143
|
-
}
|
|
6144
|
-
get lockKey() {
|
|
6145
|
-
return this._lockKey;
|
|
6146
|
-
}
|
|
6147
|
-
async acquire() {
|
|
6148
|
-
this._broadcastChannel.postMessage({
|
|
6149
|
-
message: "acquiring"
|
|
6150
|
-
});
|
|
6151
|
-
try {
|
|
6152
|
-
log19("aquiring lock...", void 0, {
|
|
6153
|
-
F: __dxlog_file22,
|
|
6154
|
-
L: 42,
|
|
6155
|
-
S: this,
|
|
6156
|
-
C: (f, a) => f(...a)
|
|
6157
|
-
});
|
|
6158
|
-
await asyncTimeout2(this._requestLock(), RESOURCE_LOCK_TIMEOUT);
|
|
6159
|
-
log19("acquired lock", void 0, {
|
|
6160
|
-
F: __dxlog_file22,
|
|
6161
|
-
L: 44,
|
|
6162
|
-
S: this,
|
|
6163
|
-
C: (f, a) => f(...a)
|
|
6164
|
-
});
|
|
6165
|
-
} catch {
|
|
6166
|
-
log19("stealing lock...", void 0, {
|
|
6167
|
-
F: __dxlog_file22,
|
|
6168
|
-
L: 46,
|
|
6169
|
-
S: this,
|
|
6170
|
-
C: (f, a) => f(...a)
|
|
6171
|
-
});
|
|
6172
|
-
await this._requestLock(true);
|
|
6173
|
-
log19("stolen lock", void 0, {
|
|
6174
|
-
F: __dxlog_file22,
|
|
6175
|
-
L: 48,
|
|
6176
|
-
S: this,
|
|
6177
|
-
C: (f, a) => f(...a)
|
|
6178
|
-
});
|
|
6179
|
-
}
|
|
6180
|
-
}
|
|
6181
|
-
async release() {
|
|
6182
|
-
this._releaseTrigger.wake();
|
|
6183
|
-
}
|
|
6184
|
-
_onMessage(event) {
|
|
6185
|
-
if (event.data.message === "acquiring") {
|
|
6186
|
-
this._releaseTrigger.wake();
|
|
6187
|
-
}
|
|
6188
|
-
}
|
|
6189
|
-
async _requestLock(steal = false) {
|
|
6190
|
-
log19("requesting lock...", {
|
|
6191
|
-
steal
|
|
6192
|
-
}, {
|
|
6193
|
-
F: __dxlog_file22,
|
|
6194
|
-
L: 63,
|
|
6195
|
-
S: this,
|
|
6196
|
-
C: (f, a) => f(...a)
|
|
6197
|
-
});
|
|
6198
|
-
const acquired = new Trigger9();
|
|
6199
|
-
void navigator.locks.request(this._lockKey, {
|
|
6200
|
-
steal
|
|
6201
|
-
}, async () => {
|
|
6202
|
-
await this._onAcquire?.();
|
|
6203
|
-
acquired.wake();
|
|
6204
|
-
this._releaseTrigger = new Trigger9();
|
|
6205
|
-
await this._releaseTrigger.wait();
|
|
6206
|
-
log19("releasing lock...", void 0, {
|
|
6207
|
-
F: __dxlog_file22,
|
|
6208
|
-
L: 72,
|
|
6209
|
-
S: this,
|
|
6210
|
-
C: (f, a) => f(...a)
|
|
6211
|
-
});
|
|
6212
|
-
await this._onRelease?.();
|
|
6213
|
-
log19("released lock", void 0, {
|
|
6214
|
-
F: __dxlog_file22,
|
|
6215
|
-
L: 74,
|
|
6216
|
-
S: this,
|
|
6217
|
-
C: (f, a) => f(...a)
|
|
6218
|
-
});
|
|
6219
|
-
}).catch(async () => {
|
|
6220
|
-
await this._onRelease?.();
|
|
6221
|
-
});
|
|
6222
|
-
await acquired.wait();
|
|
6223
|
-
log19("recieved lock", {
|
|
6224
|
-
steal
|
|
6225
|
-
}, {
|
|
6226
|
-
F: __dxlog_file22,
|
|
6227
|
-
L: 81,
|
|
6228
|
-
S: this,
|
|
6229
|
-
C: (f, a) => f(...a)
|
|
6230
|
-
});
|
|
6231
|
-
}
|
|
6232
|
-
};
|
|
6233
|
-
_ts_decorate7([
|
|
6234
|
-
logInfo
|
|
6235
|
-
], Lock.prototype, "lockKey", null);
|
|
6236
|
-
var isLocked = (lockPath) => {
|
|
6237
|
-
throw new Error("Not implemented");
|
|
6238
|
-
};
|
|
6239
|
-
|
|
6240
6302
|
// packages/sdk/client-services/src/packlets/storage/storage.ts
|
|
6241
6303
|
import { InvalidConfigError } from "@dxos/protocols";
|
|
6242
6304
|
import { Runtime as Runtime2 } from "@dxos/protocols/proto/dxos/config";
|
|
@@ -6475,7 +6537,7 @@ import { Event as Event9, synchronized as synchronized3 } from "@dxos/async";
|
|
|
6475
6537
|
import { clientServiceBundle } from "@dxos/client-protocol";
|
|
6476
6538
|
import { Context as Context11 } from "@dxos/context";
|
|
6477
6539
|
import { invariant as invariant19 } from "@dxos/invariant";
|
|
6478
|
-
import { PublicKey as
|
|
6540
|
+
import { PublicKey as PublicKey16 } from "@dxos/keys";
|
|
6479
6541
|
import { log as log22 } from "@dxos/log";
|
|
6480
6542
|
import { WebsocketSignalManager } from "@dxos/messaging";
|
|
6481
6543
|
import { SwarmNetworkManager, createSimplePeerTransportFactory } from "@dxos/network-manager";
|
|
@@ -6566,57 +6628,10 @@ var DevicesServiceImpl = class {
|
|
|
6566
6628
|
}
|
|
6567
6629
|
};
|
|
6568
6630
|
|
|
6569
|
-
// packages/sdk/client-services/src/packlets/diagnostics/diagnostics-collector.ts
|
|
6570
|
-
import { ConfigResource } from "@dxos/config";
|
|
6571
|
-
import { GetDiagnosticsRequest } from "@dxos/protocols/proto/dxos/client/services";
|
|
6572
|
-
import { TRACE_PROCESSOR as TRACE_PROCESSOR2 } from "@dxos/tracing";
|
|
6573
|
-
import { jsonKeyReplacer, nonNullable } from "@dxos/util";
|
|
6574
|
-
|
|
6575
|
-
// packages/sdk/client-services/src/packlets/services/util.ts
|
|
6576
|
-
import { PublicKey as PublicKey14 } from "@dxos/keys";
|
|
6577
|
-
import { humanize } from "@dxos/util";
|
|
6578
|
-
var ClientServicesProviderResource = Symbol.for("dxos.resource.ClientServices");
|
|
6579
|
-
|
|
6580
|
-
// packages/sdk/client-services/src/packlets/diagnostics/diagnostics-collector.ts
|
|
6581
|
-
var GET_DIAGNOSTICS_RPC_TIMEOUT = 1e4;
|
|
6582
|
-
var DiagnosticsCollector = class {
|
|
6583
|
-
static {
|
|
6584
|
-
this.broadcastSender = createCollectDiagnosticsBroadcastSender();
|
|
6585
|
-
}
|
|
6586
|
-
static async collect(config = findConfigs(), services = findSystemServiceProvider(), options = {}) {
|
|
6587
|
-
const serviceDiagnostics = await services?.services?.SystemService?.getDiagnostics({
|
|
6588
|
-
keys: options.humanize ? GetDiagnosticsRequest.KEY_OPTION.HUMANIZE : options.truncate ? GetDiagnosticsRequest.KEY_OPTION.TRUNCATE : void 0
|
|
6589
|
-
}, {
|
|
6590
|
-
timeout: GET_DIAGNOSTICS_RPC_TIMEOUT
|
|
6591
|
-
});
|
|
6592
|
-
const clientDiagnostics = {
|
|
6593
|
-
config,
|
|
6594
|
-
trace: TRACE_PROCESSOR2.getDiagnostics()
|
|
6595
|
-
};
|
|
6596
|
-
const diagnostics = serviceDiagnostics != null ? {
|
|
6597
|
-
client: clientDiagnostics,
|
|
6598
|
-
services: serviceDiagnostics
|
|
6599
|
-
} : {
|
|
6600
|
-
client: clientDiagnostics,
|
|
6601
|
-
broadcast: await this.broadcastSender.broadcastDiagnosticsRequest()
|
|
6602
|
-
};
|
|
6603
|
-
return JSON.parse(JSON.stringify(diagnostics, jsonKeyReplacer(options)));
|
|
6604
|
-
}
|
|
6605
|
-
};
|
|
6606
|
-
var findSystemServiceProvider = () => {
|
|
6607
|
-
const serviceProviders = TRACE_PROCESSOR2.findResourcesByAnnotation(ClientServicesProviderResource);
|
|
6608
|
-
const providerResource = serviceProviders.find((r) => r.instance.deref()?.services?.SystemService != null);
|
|
6609
|
-
return providerResource?.instance?.deref() ?? null;
|
|
6610
|
-
};
|
|
6611
|
-
var findConfigs = () => {
|
|
6612
|
-
const configs = TRACE_PROCESSOR2.findResourcesByAnnotation(ConfigResource);
|
|
6613
|
-
return configs.map((r) => r.instance.deref()).filter(nonNullable);
|
|
6614
|
-
};
|
|
6615
|
-
|
|
6616
6631
|
// packages/sdk/client-services/src/packlets/identity/contacts-service.ts
|
|
6617
6632
|
import { EventSubscriptions as EventSubscriptions4, scheduleTask as scheduleTask7, UpdateScheduler as UpdateScheduler2 } from "@dxos/async";
|
|
6618
6633
|
import { Stream as Stream12 } from "@dxos/codec-protobuf";
|
|
6619
|
-
import { PublicKey as
|
|
6634
|
+
import { PublicKey as PublicKey14 } from "@dxos/keys";
|
|
6620
6635
|
import { ComplexMap as ComplexMap4, ComplexSet as ComplexSet6 } from "@dxos/util";
|
|
6621
6636
|
var ContactsServiceImpl = class {
|
|
6622
6637
|
constructor(_identityManager, _spaceManager, _dataSpaceManagerProvider) {
|
|
@@ -6657,7 +6672,7 @@ var ContactsServiceImpl = class {
|
|
|
6657
6672
|
});
|
|
6658
6673
|
}
|
|
6659
6674
|
return acc;
|
|
6660
|
-
}, new ComplexMap4(
|
|
6675
|
+
}, new ComplexMap4(PublicKey14.hash));
|
|
6661
6676
|
return {
|
|
6662
6677
|
contacts: [
|
|
6663
6678
|
...contacts.values()
|
|
@@ -6665,7 +6680,7 @@ var ContactsServiceImpl = class {
|
|
|
6665
6680
|
};
|
|
6666
6681
|
}
|
|
6667
6682
|
queryContacts() {
|
|
6668
|
-
const subscribedSpaceKeySet = new ComplexSet6(
|
|
6683
|
+
const subscribedSpaceKeySet = new ComplexSet6(PublicKey14.hash);
|
|
6669
6684
|
return new Stream12(({ next, ctx }) => {
|
|
6670
6685
|
const pushUpdateTask = new UpdateScheduler2(ctx, async () => {
|
|
6671
6686
|
const contacts = await this.getContacts();
|
|
@@ -6699,7 +6714,7 @@ var ContactsServiceImpl = class {
|
|
|
6699
6714
|
// packages/sdk/client-services/src/packlets/logging/logging-service.ts
|
|
6700
6715
|
import { Event as Event8 } from "@dxos/async";
|
|
6701
6716
|
import { Stream as Stream13 } from "@dxos/codec-protobuf";
|
|
6702
|
-
import { PublicKey as
|
|
6717
|
+
import { PublicKey as PublicKey15 } from "@dxos/keys";
|
|
6703
6718
|
import { getContextFromEntry, log as log21 } from "@dxos/log";
|
|
6704
6719
|
import { QueryLogsRequest } from "@dxos/protocols/proto/dxos/client/services";
|
|
6705
6720
|
import { getDebugName, jsonify, numericalValues, tracer } from "@dxos/util";
|
|
@@ -6707,7 +6722,7 @@ var LoggingServiceImpl = class {
|
|
|
6707
6722
|
constructor() {
|
|
6708
6723
|
this._logs = new Event8();
|
|
6709
6724
|
this._started = Date.now();
|
|
6710
|
-
this._sessionId =
|
|
6725
|
+
this._sessionId = PublicKey15.random().toHex();
|
|
6711
6726
|
this._logProcessor = (_config, entry2) => {
|
|
6712
6727
|
this._logs.emit(entry2);
|
|
6713
6728
|
};
|
|
@@ -7079,7 +7094,7 @@ var ClientServicesHost = class {
|
|
|
7079
7094
|
if (this._open) {
|
|
7080
7095
|
return;
|
|
7081
7096
|
}
|
|
7082
|
-
const traceId =
|
|
7097
|
+
const traceId = PublicKey16.random().toHex();
|
|
7083
7098
|
log22.trace("dxos.client-services.host.open", trace10.begin({
|
|
7084
7099
|
id: traceId
|
|
7085
7100
|
}), {
|
|
@@ -7231,7 +7246,7 @@ var ClientServicesHost = class {
|
|
|
7231
7246
|
});
|
|
7232
7247
|
}
|
|
7233
7248
|
async reset() {
|
|
7234
|
-
const traceId =
|
|
7249
|
+
const traceId = PublicKey16.random().toHex();
|
|
7235
7250
|
log22.trace("dxos.sdk.client-services-host.reset", trace10.begin({
|
|
7236
7251
|
id: traceId
|
|
7237
7252
|
}), {
|
|
@@ -7303,7 +7318,7 @@ export {
|
|
|
7303
7318
|
createDiagnostics,
|
|
7304
7319
|
createCollectDiagnosticsBroadcastSender,
|
|
7305
7320
|
createCollectDiagnosticsBroadcastHandler,
|
|
7306
|
-
|
|
7321
|
+
DiagnosticsCollector,
|
|
7307
7322
|
createAuthProvider,
|
|
7308
7323
|
TrustedKeySetAuthVerifier,
|
|
7309
7324
|
Identity,
|
|
@@ -7315,21 +7330,20 @@ export {
|
|
|
7315
7330
|
InvitationsServiceImpl,
|
|
7316
7331
|
SpaceInvitationProtocol,
|
|
7317
7332
|
InvitationsManager,
|
|
7333
|
+
Lock,
|
|
7334
|
+
isLocked,
|
|
7335
|
+
ClientRpcServer,
|
|
7318
7336
|
DataSpace,
|
|
7319
7337
|
DataSpaceManager,
|
|
7320
7338
|
SpacesServiceImpl,
|
|
7321
7339
|
ServiceContext,
|
|
7322
7340
|
ServiceRegistry,
|
|
7323
|
-
Lock,
|
|
7324
|
-
isLocked,
|
|
7325
7341
|
createStorageObjects,
|
|
7326
7342
|
createLevel,
|
|
7327
7343
|
encodeProfileArchive,
|
|
7328
7344
|
decodeProfileArchive,
|
|
7329
7345
|
exportProfileData,
|
|
7330
7346
|
importProfileData,
|
|
7331
|
-
ClientServicesHost
|
|
7332
|
-
ClientServicesProviderResource,
|
|
7333
|
-
DiagnosticsCollector
|
|
7347
|
+
ClientServicesHost
|
|
7334
7348
|
};
|
|
7335
|
-
//# sourceMappingURL=chunk-
|
|
7349
|
+
//# sourceMappingURL=chunk-UR2AY5N5.mjs.map
|