@dxos/client-services 0.6.3-next.4424131 → 0.6.3-staging.75e3813
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-M47CB62R.mjs → chunk-JCYU3AYC.mjs} +573 -580
- package/dist/lib/browser/chunk-JCYU3AYC.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-WMIDDIMJ.cjs → chunk-4WZHXQZI.cjs} +655 -659
- package/dist/lib/node/chunk-4WZHXQZI.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/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/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/services/index.ts +0 -1
- package/src/packlets/services/util.ts +0 -2
- package/src/version.ts +1 -1
- package/dist/lib/browser/chunk-M47CB62R.mjs.map +0 -7
- package/dist/lib/node/chunk-WMIDDIMJ.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.75e3813";
|
|
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
|
});
|
|
@@ -1808,7 +1768,7 @@ 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
1774
|
import { InvitationOptions as InvitationOptions4 } from "@dxos/protocols/proto/dxos/halo/invitations";
|
|
@@ -1975,7 +1935,7 @@ 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
1940
|
import { AuthenticationResponse, InvitationOptions as InvitationOptions2 } from "@dxos/protocols/proto/dxos/halo/invitations";
|
|
1981
1941
|
import { RpcExtension as RpcExtension2 } from "@dxos/teleport";
|
|
@@ -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,
|
|
@@ -2443,7 +2403,7 @@ 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,
|
|
@@ -2473,7 +2433,7 @@ var InvitationsHandler = class {
|
|
|
2473
2433
|
});
|
|
2474
2434
|
guardedState.set(extension, Invitation4.State.SUCCESS);
|
|
2475
2435
|
metrics.increment("dxos.invitation.success");
|
|
2476
|
-
log10.trace("dxos.sdk.invitations-handler.host.onOpen",
|
|
2436
|
+
log10.trace("dxos.sdk.invitations-handler.host.onOpen", trace4.end({
|
|
2477
2437
|
id: traceId
|
|
2478
2438
|
}), {
|
|
2479
2439
|
F: __dxlog_file13,
|
|
@@ -2509,7 +2469,7 @@ var InvitationsHandler = class {
|
|
|
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
|
}), {
|
|
@@ -2648,7 +2608,7 @@ 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,
|
|
@@ -2728,7 +2688,7 @@ 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,
|
|
@@ -2757,7 +2717,7 @@ var InvitationsHandler = class {
|
|
|
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
|
}), {
|
|
@@ -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,115 +3690,320 @@ 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
|
-
import { invariant as invariant12 } from "@dxos/invariant";
|
|
3800
|
-
import { log as log13 } from "@dxos/log";
|
|
3801
|
-
import { CreateEpochRequest } from "@dxos/protocols/proto/dxos/client/services";
|
|
3802
|
-
var __dxlog_file16 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/epoch-migrations.ts";
|
|
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
|
|
3819
|
-
});
|
|
3820
|
-
const newRoot = context.echoHost.createDoc(rootHandle.docSync());
|
|
3821
|
-
await context.echoHost.flush();
|
|
3822
|
-
return {
|
|
3823
|
-
newRoot: newRoot.url
|
|
3824
|
-
};
|
|
3825
|
-
}
|
|
3826
|
-
case CreateEpochRequest.Migration.FRAGMENT_AUTOMERGE_ROOT: {
|
|
3827
|
-
log13.info("Fragmenting", void 0, {
|
|
3724
|
+
async acquire() {
|
|
3725
|
+
this._broadcastChannel.postMessage({
|
|
3726
|
+
message: "acquiring"
|
|
3727
|
+
});
|
|
3728
|
+
try {
|
|
3729
|
+
log13("aquiring lock...", void 0, {
|
|
3828
3730
|
F: __dxlog_file16,
|
|
3829
|
-
L:
|
|
3830
|
-
S:
|
|
3731
|
+
L: 42,
|
|
3732
|
+
S: this,
|
|
3831
3733
|
C: (f, a) => f(...a)
|
|
3832
3734
|
});
|
|
3833
|
-
|
|
3834
|
-
|
|
3835
|
-
timeout: LOAD_DOC_TIMEOUT
|
|
3836
|
-
});
|
|
3837
|
-
const objects = Object.entries(rootHandle.docSync().objects);
|
|
3838
|
-
const properties = findInlineObjectOfType(rootHandle.docSync(), TYPE_PROPERTIES);
|
|
3839
|
-
const otherObjects = objects.filter(([key]) => key !== properties?.[0]);
|
|
3840
|
-
invariant12(properties, "Properties not found", {
|
|
3735
|
+
await asyncTimeout2(this._requestLock(), RESOURCE_LOCK_TIMEOUT);
|
|
3736
|
+
log13("acquired lock", void 0, {
|
|
3841
3737
|
F: __dxlog_file16,
|
|
3738
|
+
L: 44,
|
|
3739
|
+
S: this,
|
|
3740
|
+
C: (f, a) => f(...a)
|
|
3741
|
+
});
|
|
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;
|
|
3999
|
+
const rootHandle = await context.echoHost.loadDoc(ctx, currentRootUrl, {
|
|
4000
|
+
timeout: LOAD_DOC_TIMEOUT
|
|
4001
|
+
});
|
|
4002
|
+
const objects = Object.entries(rootHandle.docSync().objects);
|
|
4003
|
+
const properties = findInlineObjectOfType(rootHandle.docSync(), TYPE_PROPERTIES);
|
|
4004
|
+
const otherObjects = objects.filter(([key]) => key !== properties?.[0]);
|
|
4005
|
+
invariant12(properties, "Properties not found", {
|
|
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();
|
|
@@ -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)
|
|
@@ -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
4577
|
this._state = SpaceState2.SPACE_CONTROL_ONLY;
|
|
4413
|
-
|
|
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)
|
|
@@ -4428,17 +4593,17 @@ var DataSpace = class {
|
|
|
4428
4593
|
async _close() {
|
|
4429
4594
|
await this._callbacks.beforeClose?.();
|
|
4430
4595
|
this._state = SpaceState2.SPACE_CLOSED;
|
|
4431
|
-
|
|
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
4648
|
this._state = SpaceState2.SPACE_ERROR;
|
|
4484
|
-
|
|
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)
|
|
@@ -4501,10 +4666,10 @@ var DataSpace = class {
|
|
|
4501
4666
|
throw new SystemError("Invalid operation");
|
|
4502
4667
|
}
|
|
4503
4668
|
this._state = SpaceState2.SPACE_INITIALIZING;
|
|
4504
|
-
|
|
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)
|
|
@@ -4518,10 +4683,10 @@ var DataSpace = class {
|
|
|
4518
4683
|
async _enterReadyState() {
|
|
4519
4684
|
await this._callbacks.beforeReady?.();
|
|
4520
4685
|
this._state = SpaceState2.SPACE_READY;
|
|
4521
|
-
|
|
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)
|
|
@@ -4647,12 +4812,12 @@ var DataSpace = class {
|
|
|
4647
4812
|
if (err instanceof ContextDisposedError3) {
|
|
4648
4813
|
return;
|
|
4649
4814
|
}
|
|
4650
|
-
|
|
4815
|
+
log16.warn("error loading automerge root doc", {
|
|
4651
4816
|
space: this.key,
|
|
4652
4817
|
rootUrl,
|
|
4653
4818
|
err
|
|
4654
4819
|
}, {
|
|
4655
|
-
F:
|
|
4820
|
+
F: __dxlog_file19,
|
|
4656
4821
|
L: 431,
|
|
4657
4822
|
S: this,
|
|
4658
4823
|
C: (f, a) => f(...a)
|
|
@@ -4739,10 +4904,10 @@ var DataSpace = class {
|
|
|
4739
4904
|
await this._close();
|
|
4740
4905
|
}
|
|
4741
4906
|
this._state = SpaceState2.SPACE_INACTIVE;
|
|
4742
|
-
|
|
4907
|
+
log16("new state", {
|
|
4743
4908
|
state: SpaceState2[this._state]
|
|
4744
4909
|
}, {
|
|
4745
|
-
F:
|
|
4910
|
+
F: __dxlog_file19,
|
|
4746
4911
|
L: 513,
|
|
4747
4912
|
S: this,
|
|
4748
4913
|
C: (f, a) => f(...a)
|
|
@@ -4750,51 +4915,51 @@ var DataSpace = class {
|
|
|
4750
4915
|
this.stateUpdate.emit();
|
|
4751
4916
|
}
|
|
4752
4917
|
};
|
|
4753
|
-
|
|
4918
|
+
_ts_decorate5([
|
|
4754
4919
|
trace6.info()
|
|
4755
4920
|
], DataSpace.prototype, "_inner", void 0);
|
|
4756
|
-
|
|
4921
|
+
_ts_decorate5([
|
|
4757
4922
|
trace6.info()
|
|
4758
4923
|
], DataSpace.prototype, "id", null);
|
|
4759
|
-
|
|
4924
|
+
_ts_decorate5([
|
|
4760
4925
|
trace6.info()
|
|
4761
4926
|
], DataSpace.prototype, "key", null);
|
|
4762
|
-
|
|
4927
|
+
_ts_decorate5([
|
|
4763
4928
|
trace6.info({
|
|
4764
4929
|
enum: SpaceState2
|
|
4765
4930
|
})
|
|
4766
4931
|
], DataSpace.prototype, "state", null);
|
|
4767
|
-
|
|
4932
|
+
_ts_decorate5([
|
|
4768
4933
|
trace6.info({
|
|
4769
4934
|
depth: null
|
|
4770
4935
|
})
|
|
4771
4936
|
], DataSpace.prototype, "_automergeInfo", null);
|
|
4772
|
-
|
|
4937
|
+
_ts_decorate5([
|
|
4773
4938
|
synchronized
|
|
4774
4939
|
], DataSpace.prototype, "open", null);
|
|
4775
|
-
|
|
4940
|
+
_ts_decorate5([
|
|
4776
4941
|
synchronized
|
|
4777
4942
|
], DataSpace.prototype, "close", null);
|
|
4778
|
-
|
|
4943
|
+
_ts_decorate5([
|
|
4779
4944
|
trace6.span({
|
|
4780
4945
|
showInBrowserTimeline: true
|
|
4781
4946
|
})
|
|
4782
4947
|
], DataSpace.prototype, "initializeDataPipeline", null);
|
|
4783
|
-
|
|
4948
|
+
_ts_decorate5([
|
|
4784
4949
|
trace6.span({
|
|
4785
4950
|
showInBrowserTimeline: true
|
|
4786
4951
|
})
|
|
4787
4952
|
], DataSpace.prototype, "_initializeAndReadControlPipeline", null);
|
|
4788
|
-
|
|
4953
|
+
_ts_decorate5([
|
|
4789
4954
|
timed(1e4)
|
|
4790
4955
|
], DataSpace.prototype, "_createWritableFeeds", null);
|
|
4791
|
-
|
|
4956
|
+
_ts_decorate5([
|
|
4792
4957
|
synchronized
|
|
4793
4958
|
], DataSpace.prototype, "activate", null);
|
|
4794
|
-
|
|
4959
|
+
_ts_decorate5([
|
|
4795
4960
|
synchronized
|
|
4796
4961
|
], DataSpace.prototype, "deactivate", null);
|
|
4797
|
-
DataSpace =
|
|
4962
|
+
DataSpace = _ts_decorate5([
|
|
4798
4963
|
trackLeaks("open", "close"),
|
|
4799
4964
|
trace6.resource()
|
|
4800
4965
|
], DataSpace);
|
|
@@ -4812,7 +4977,7 @@ import { TYPE_PROPERTIES as TYPE_PROPERTIES2, generateEchoId, getTypeReference }
|
|
|
4812
4977
|
import { writeMessages as writeMessages3 } from "@dxos/feed-store";
|
|
4813
4978
|
import { invariant as invariant14 } from "@dxos/invariant";
|
|
4814
4979
|
import { PublicKey as PublicKey11 } from "@dxos/keys";
|
|
4815
|
-
import { log as
|
|
4980
|
+
import { log as log17 } from "@dxos/log";
|
|
4816
4981
|
import { trace as Trace2, AlreadyJoinedError as AlreadyJoinedError3 } from "@dxos/protocols";
|
|
4817
4982
|
import { Invitation as Invitation7, SpaceState as SpaceState3 } from "@dxos/protocols/proto/dxos/client/services";
|
|
4818
4983
|
import { SpaceMember as SpaceMember6 } from "@dxos/protocols/proto/dxos/halo/credentials";
|
|
@@ -4891,7 +5056,7 @@ var spaceGenesis = async (keyring, signingContext, space, automergeRoot) => {
|
|
|
4891
5056
|
};
|
|
4892
5057
|
|
|
4893
5058
|
// packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts
|
|
4894
|
-
function
|
|
5059
|
+
function _ts_decorate6(decorators, target, key, desc) {
|
|
4895
5060
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4896
5061
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
4897
5062
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -4901,7 +5066,7 @@ function _ts_decorate5(decorators, target, key, desc) {
|
|
|
4901
5066
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
4902
5067
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4903
5068
|
}
|
|
4904
|
-
var
|
|
5069
|
+
var __dxlog_file20 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts";
|
|
4905
5070
|
var PRESENCE_ANNOUNCE_INTERVAL = 1e4;
|
|
4906
5071
|
var PRESENCE_OFFLINE_TIMEOUT = 2e4;
|
|
4907
5072
|
var DEFAULT_SPACE_KEY = "__DEFAULT__";
|
|
@@ -4916,7 +5081,7 @@ var DataSpaceManager = class {
|
|
|
4916
5081
|
this._invitationsManager = _invitationsManager;
|
|
4917
5082
|
this._params = _params;
|
|
4918
5083
|
this._ctx = new Context9(void 0, {
|
|
4919
|
-
F:
|
|
5084
|
+
F: __dxlog_file20,
|
|
4920
5085
|
L: 104
|
|
4921
5086
|
});
|
|
4922
5087
|
this.updated = new Event7();
|
|
@@ -4951,45 +5116,45 @@ var DataSpaceManager = class {
|
|
|
4951
5116
|
return this._spaces;
|
|
4952
5117
|
}
|
|
4953
5118
|
async open() {
|
|
4954
|
-
|
|
4955
|
-
F:
|
|
5119
|
+
log17("open", void 0, {
|
|
5120
|
+
F: __dxlog_file20,
|
|
4956
5121
|
L: 156,
|
|
4957
5122
|
S: this,
|
|
4958
5123
|
C: (f, a) => f(...a)
|
|
4959
5124
|
});
|
|
4960
|
-
|
|
5125
|
+
log17.trace("dxos.echo.data-space-manager.open", Trace2.begin({
|
|
4961
5126
|
id: this._instanceId
|
|
4962
5127
|
}), {
|
|
4963
|
-
F:
|
|
5128
|
+
F: __dxlog_file20,
|
|
4964
5129
|
L: 157,
|
|
4965
5130
|
S: this,
|
|
4966
5131
|
C: (f, a) => f(...a)
|
|
4967
5132
|
});
|
|
4968
|
-
|
|
5133
|
+
log17("metadata loaded", {
|
|
4969
5134
|
spaces: this._metadataStore.spaces.length
|
|
4970
5135
|
}, {
|
|
4971
|
-
F:
|
|
5136
|
+
F: __dxlog_file20,
|
|
4972
5137
|
L: 158,
|
|
4973
5138
|
S: this,
|
|
4974
5139
|
C: (f, a) => f(...a)
|
|
4975
5140
|
});
|
|
4976
5141
|
await forEachAsync(this._metadataStore.spaces, async (spaceMetadata) => {
|
|
4977
5142
|
try {
|
|
4978
|
-
|
|
5143
|
+
log17("load space", {
|
|
4979
5144
|
spaceMetadata
|
|
4980
5145
|
}, {
|
|
4981
|
-
F:
|
|
5146
|
+
F: __dxlog_file20,
|
|
4982
5147
|
L: 162,
|
|
4983
5148
|
S: this,
|
|
4984
5149
|
C: (f, a) => f(...a)
|
|
4985
5150
|
});
|
|
4986
5151
|
await this._constructSpace(spaceMetadata);
|
|
4987
5152
|
} catch (err) {
|
|
4988
|
-
|
|
5153
|
+
log17.error("Error loading space", {
|
|
4989
5154
|
spaceMetadata,
|
|
4990
5155
|
err
|
|
4991
5156
|
}, {
|
|
4992
|
-
F:
|
|
5157
|
+
F: __dxlog_file20,
|
|
4993
5158
|
L: 165,
|
|
4994
5159
|
S: this,
|
|
4995
5160
|
C: (f, a) => f(...a)
|
|
@@ -4998,18 +5163,18 @@ var DataSpaceManager = class {
|
|
|
4998
5163
|
});
|
|
4999
5164
|
this._isOpen = true;
|
|
5000
5165
|
this.updated.emit();
|
|
5001
|
-
|
|
5166
|
+
log17.trace("dxos.echo.data-space-manager.open", Trace2.end({
|
|
5002
5167
|
id: this._instanceId
|
|
5003
5168
|
}), {
|
|
5004
|
-
F:
|
|
5169
|
+
F: __dxlog_file20,
|
|
5005
5170
|
L: 172,
|
|
5006
5171
|
S: this,
|
|
5007
5172
|
C: (f, a) => f(...a)
|
|
5008
5173
|
});
|
|
5009
5174
|
}
|
|
5010
5175
|
async close() {
|
|
5011
|
-
|
|
5012
|
-
F:
|
|
5176
|
+
log17("close", void 0, {
|
|
5177
|
+
F: __dxlog_file20,
|
|
5013
5178
|
L: 177,
|
|
5014
5179
|
S: this,
|
|
5015
5180
|
C: (f, a) => f(...a)
|
|
@@ -5026,7 +5191,7 @@ var DataSpaceManager = class {
|
|
|
5026
5191
|
*/
|
|
5027
5192
|
async createSpace() {
|
|
5028
5193
|
invariant14(this._isOpen, "Not open.", {
|
|
5029
|
-
F:
|
|
5194
|
+
F: __dxlog_file20,
|
|
5030
5195
|
L: 191,
|
|
5031
5196
|
S: this,
|
|
5032
5197
|
A: [
|
|
@@ -5044,10 +5209,10 @@ var DataSpaceManager = class {
|
|
|
5044
5209
|
dataFeedKey,
|
|
5045
5210
|
state: SpaceState3.SPACE_ACTIVE
|
|
5046
5211
|
};
|
|
5047
|
-
|
|
5212
|
+
log17("creating space...", {
|
|
5048
5213
|
spaceKey
|
|
5049
5214
|
}, {
|
|
5050
|
-
F:
|
|
5215
|
+
F: __dxlog_file20,
|
|
5051
5216
|
L: 203,
|
|
5052
5217
|
S: this,
|
|
5053
5218
|
C: (f, a) => f(...a)
|
|
@@ -5059,7 +5224,7 @@ var DataSpaceManager = class {
|
|
|
5059
5224
|
await this._metadataStore.addSpace(metadata);
|
|
5060
5225
|
const memberCredential = credentials[1];
|
|
5061
5226
|
invariant14(getCredentialAssertion3(memberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
|
|
5062
|
-
F:
|
|
5227
|
+
F: __dxlog_file20,
|
|
5063
5228
|
L: 213,
|
|
5064
5229
|
S: this,
|
|
5065
5230
|
A: [
|
|
@@ -5087,11 +5252,11 @@ var DataSpaceManager = class {
|
|
|
5087
5252
|
return properties?.data?.[DEFAULT_SPACE_KEY] === this._signingContext.identityKey.toHex();
|
|
5088
5253
|
}
|
|
5089
5254
|
default:
|
|
5090
|
-
|
|
5255
|
+
log17.warn("unknown space version", {
|
|
5091
5256
|
version: space.databaseRoot.getVersion(),
|
|
5092
5257
|
spaceId: space.id
|
|
5093
5258
|
}, {
|
|
5094
|
-
F:
|
|
5259
|
+
F: __dxlog_file20,
|
|
5095
5260
|
L: 238,
|
|
5096
5261
|
S: this,
|
|
5097
5262
|
C: (f, a) => f(...a)
|
|
@@ -5126,7 +5291,7 @@ var DataSpaceManager = class {
|
|
|
5126
5291
|
async _getSpaceRootDocument(space) {
|
|
5127
5292
|
const automergeIndex = space.automergeSpaceState.rootUrl;
|
|
5128
5293
|
invariant14(automergeIndex, void 0, {
|
|
5129
|
-
F:
|
|
5294
|
+
F: __dxlog_file20,
|
|
5130
5295
|
L: 271,
|
|
5131
5296
|
S: this,
|
|
5132
5297
|
A: [
|
|
@@ -5140,16 +5305,16 @@ var DataSpaceManager = class {
|
|
|
5140
5305
|
}
|
|
5141
5306
|
// TODO(burdon): Rename join space.
|
|
5142
5307
|
async acceptSpace(opts) {
|
|
5143
|
-
|
|
5308
|
+
log17("accept space", {
|
|
5144
5309
|
opts
|
|
5145
5310
|
}, {
|
|
5146
|
-
F:
|
|
5311
|
+
F: __dxlog_file20,
|
|
5147
5312
|
L: 280,
|
|
5148
5313
|
S: this,
|
|
5149
5314
|
C: (f, a) => f(...a)
|
|
5150
5315
|
});
|
|
5151
5316
|
invariant14(this._isOpen, "Not open.", {
|
|
5152
|
-
F:
|
|
5317
|
+
F: __dxlog_file20,
|
|
5153
5318
|
L: 281,
|
|
5154
5319
|
S: this,
|
|
5155
5320
|
A: [
|
|
@@ -5158,7 +5323,7 @@ var DataSpaceManager = class {
|
|
|
5158
5323
|
]
|
|
5159
5324
|
});
|
|
5160
5325
|
invariant14(!this._spaces.has(opts.spaceKey), "Space already exists.", {
|
|
5161
|
-
F:
|
|
5326
|
+
F: __dxlog_file20,
|
|
5162
5327
|
L: 282,
|
|
5163
5328
|
S: this,
|
|
5164
5329
|
A: [
|
|
@@ -5182,7 +5347,7 @@ var DataSpaceManager = class {
|
|
|
5182
5347
|
async admitMember(options) {
|
|
5183
5348
|
const space = this._spaceManager.spaces.get(options.spaceKey);
|
|
5184
5349
|
invariant14(space, void 0, {
|
|
5185
|
-
F:
|
|
5350
|
+
F: __dxlog_file20,
|
|
5186
5351
|
L: 302,
|
|
5187
5352
|
S: this,
|
|
5188
5353
|
A: [
|
|
@@ -5195,7 +5360,7 @@ var DataSpaceManager = class {
|
|
|
5195
5360
|
}
|
|
5196
5361
|
const credentials = await createAdmissionCredentials(this._signingContext.credentialSigner, options.identityKey, space.key, space.genesisFeedKey, options.role, space.spaceState.membershipChainHeads, options.profile, options.delegationCredentialId);
|
|
5197
5362
|
invariant14(credentials[0].credential, void 0, {
|
|
5198
|
-
F:
|
|
5363
|
+
F: __dxlog_file20,
|
|
5199
5364
|
L: 321,
|
|
5200
5365
|
S: this,
|
|
5201
5366
|
A: [
|
|
@@ -5205,7 +5370,7 @@ var DataSpaceManager = class {
|
|
|
5205
5370
|
});
|
|
5206
5371
|
const spaceMemberCredential = credentials[0].credential.credential;
|
|
5207
5372
|
invariant14(getCredentialAssertion3(spaceMemberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
|
|
5208
|
-
F:
|
|
5373
|
+
F: __dxlog_file20,
|
|
5209
5374
|
L: 323,
|
|
5210
5375
|
S: this,
|
|
5211
5376
|
A: [
|
|
@@ -5240,10 +5405,10 @@ var DataSpaceManager = class {
|
|
|
5240
5405
|
});
|
|
5241
5406
|
}
|
|
5242
5407
|
async _constructSpace(metadata) {
|
|
5243
|
-
|
|
5408
|
+
log17("construct space", {
|
|
5244
5409
|
metadata
|
|
5245
5410
|
}, {
|
|
5246
|
-
F:
|
|
5411
|
+
F: __dxlog_file20,
|
|
5247
5412
|
L: 358,
|
|
5248
5413
|
S: this,
|
|
5249
5414
|
C: (f, a) => f(...a)
|
|
@@ -5287,10 +5452,10 @@ var DataSpaceManager = class {
|
|
|
5287
5452
|
}
|
|
5288
5453
|
session.addExtension("dxos.mesh.teleport.automerge", this._echoHost.createReplicationExtension());
|
|
5289
5454
|
} catch (err) {
|
|
5290
|
-
|
|
5455
|
+
log17.warn("error on authorized connection", {
|
|
5291
5456
|
err
|
|
5292
5457
|
}, {
|
|
5293
|
-
F:
|
|
5458
|
+
F: __dxlog_file20,
|
|
5294
5459
|
L: 403,
|
|
5295
5460
|
S: this,
|
|
5296
5461
|
C: (f, a) => f(...a)
|
|
@@ -5299,8 +5464,8 @@ var DataSpaceManager = class {
|
|
|
5299
5464
|
}
|
|
5300
5465
|
}),
|
|
5301
5466
|
onAuthFailure: () => {
|
|
5302
|
-
|
|
5303
|
-
F:
|
|
5467
|
+
log17.warn("auth failure", void 0, {
|
|
5468
|
+
F: __dxlog_file20,
|
|
5304
5469
|
L: 408,
|
|
5305
5470
|
S: this,
|
|
5306
5471
|
C: (f, a) => f(...a)
|
|
@@ -5330,21 +5495,21 @@ var DataSpaceManager = class {
|
|
|
5330
5495
|
signingContext: this._signingContext,
|
|
5331
5496
|
callbacks: {
|
|
5332
5497
|
beforeReady: async () => {
|
|
5333
|
-
|
|
5498
|
+
log17("before space ready", {
|
|
5334
5499
|
space: space.key
|
|
5335
5500
|
}, {
|
|
5336
|
-
F:
|
|
5501
|
+
F: __dxlog_file20,
|
|
5337
5502
|
L: 435,
|
|
5338
5503
|
S: this,
|
|
5339
5504
|
C: (f, a) => f(...a)
|
|
5340
5505
|
});
|
|
5341
5506
|
},
|
|
5342
5507
|
afterReady: async () => {
|
|
5343
|
-
|
|
5508
|
+
log17("after space ready", {
|
|
5344
5509
|
space: space.key,
|
|
5345
5510
|
open: this._isOpen
|
|
5346
5511
|
}, {
|
|
5347
|
-
F:
|
|
5512
|
+
F: __dxlog_file20,
|
|
5348
5513
|
L: 438,
|
|
5349
5514
|
S: this,
|
|
5350
5515
|
C: (f, a) => f(...a)
|
|
@@ -5360,10 +5525,10 @@ var DataSpaceManager = class {
|
|
|
5360
5525
|
}
|
|
5361
5526
|
},
|
|
5362
5527
|
beforeClose: async () => {
|
|
5363
|
-
|
|
5528
|
+
log17("before space close", {
|
|
5364
5529
|
space: space.key
|
|
5365
5530
|
}, {
|
|
5366
|
-
F:
|
|
5531
|
+
F: __dxlog_file20,
|
|
5367
5532
|
L: 446,
|
|
5368
5533
|
S: this,
|
|
5369
5534
|
C: (f, a) => f(...a)
|
|
@@ -5395,16 +5560,16 @@ var DataSpaceManager = class {
|
|
|
5395
5560
|
return (s && member.role === SpaceMember6.Role.REMOVED !== (s.authStatus === AuthStatus.FAILURE)) ?? false;
|
|
5396
5561
|
});
|
|
5397
5562
|
sessionsToClose.forEach((session) => {
|
|
5398
|
-
void session.close().catch(
|
|
5563
|
+
void session.close().catch(log17.error);
|
|
5399
5564
|
});
|
|
5400
5565
|
closedSessions += sessionsToClose.length;
|
|
5401
5566
|
}
|
|
5402
|
-
|
|
5567
|
+
log17("processed member role changes", {
|
|
5403
5568
|
roleChangeCount: memberInfo.length,
|
|
5404
5569
|
peersOnline: presence.getPeersOnline().length,
|
|
5405
5570
|
closedSessions
|
|
5406
5571
|
}, {
|
|
5407
|
-
F:
|
|
5572
|
+
F: __dxlog_file20,
|
|
5408
5573
|
L: 482,
|
|
5409
5574
|
S: this,
|
|
5410
5575
|
C: (f, a) => f(...a)
|
|
@@ -5416,15 +5581,15 @@ var DataSpaceManager = class {
|
|
|
5416
5581
|
if (role === SpaceMember6.Role.REMOVED) {
|
|
5417
5582
|
const session = peerState.peerId && space.protocol.sessions.get(peerState.peerId);
|
|
5418
5583
|
if (session != null) {
|
|
5419
|
-
|
|
5584
|
+
log17("closing a session with a removed peer", {
|
|
5420
5585
|
peerId: peerState.peerId
|
|
5421
5586
|
}, {
|
|
5422
|
-
F:
|
|
5587
|
+
F: __dxlog_file20,
|
|
5423
5588
|
L: 496,
|
|
5424
5589
|
S: this,
|
|
5425
5590
|
C: (f, a) => f(...a)
|
|
5426
5591
|
});
|
|
5427
|
-
void session.close().catch(
|
|
5592
|
+
void session.close().catch(log17.error);
|
|
5428
5593
|
}
|
|
5429
5594
|
}
|
|
5430
5595
|
}
|
|
@@ -5464,19 +5629,19 @@ var DataSpaceManager = class {
|
|
|
5464
5629
|
await Promise.all(tasks);
|
|
5465
5630
|
}
|
|
5466
5631
|
};
|
|
5467
|
-
|
|
5632
|
+
_ts_decorate6([
|
|
5468
5633
|
synchronized2
|
|
5469
5634
|
], DataSpaceManager.prototype, "open", null);
|
|
5470
|
-
|
|
5635
|
+
_ts_decorate6([
|
|
5471
5636
|
synchronized2
|
|
5472
5637
|
], DataSpaceManager.prototype, "close", null);
|
|
5473
|
-
|
|
5638
|
+
_ts_decorate6([
|
|
5474
5639
|
synchronized2
|
|
5475
5640
|
], DataSpaceManager.prototype, "createSpace", null);
|
|
5476
|
-
|
|
5641
|
+
_ts_decorate6([
|
|
5477
5642
|
synchronized2
|
|
5478
5643
|
], DataSpaceManager.prototype, "acceptSpace", null);
|
|
5479
|
-
DataSpaceManager =
|
|
5644
|
+
DataSpaceManager = _ts_decorate6([
|
|
5480
5645
|
trackLeaks2("open", "close")
|
|
5481
5646
|
], DataSpaceManager);
|
|
5482
5647
|
|
|
@@ -5487,11 +5652,11 @@ import { createAdmissionCredentials as createAdmissionCredentials2, getCredentia
|
|
|
5487
5652
|
import { raise as raise2 } from "@dxos/debug";
|
|
5488
5653
|
import { writeMessages as writeMessages4 } from "@dxos/feed-store";
|
|
5489
5654
|
import { invariant as invariant15 } from "@dxos/invariant";
|
|
5490
|
-
import { log as
|
|
5655
|
+
import { log as log18 } from "@dxos/log";
|
|
5491
5656
|
import { ApiError, SpaceNotFoundError as SpaceNotFoundError2, encodeError, IdentityNotInitializedError, AuthorizationError as AuthorizationError2 } from "@dxos/protocols";
|
|
5492
5657
|
import { SpaceMember as SpaceMember7, SpaceState as SpaceState4 } from "@dxos/protocols/proto/dxos/client/services";
|
|
5493
5658
|
import { trace as trace8 } from "@dxos/tracing";
|
|
5494
|
-
var
|
|
5659
|
+
var __dxlog_file21 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/spaces-service.ts";
|
|
5495
5660
|
var SpacesServiceImpl = class {
|
|
5496
5661
|
constructor(_identityManager, _spaceManager, _getDataSpaceManager) {
|
|
5497
5662
|
this._identityManager = _identityManager;
|
|
@@ -5535,7 +5700,7 @@ var SpacesServiceImpl = class {
|
|
|
5535
5700
|
}
|
|
5536
5701
|
const credentials = await createAdmissionCredentials2(identity.getIdentityCredentialSigner(), request.memberKey, space.key, space.genesisFeedKey, request.newRole, space.spaceState.membershipChainHeads);
|
|
5537
5702
|
invariant15(credentials[0].credential, void 0, {
|
|
5538
|
-
F:
|
|
5703
|
+
F: __dxlog_file21,
|
|
5539
5704
|
L: 102,
|
|
5540
5705
|
S: this,
|
|
5541
5706
|
A: [
|
|
@@ -5545,7 +5710,7 @@ var SpacesServiceImpl = class {
|
|
|
5545
5710
|
});
|
|
5546
5711
|
const spaceMemberCredential = credentials[0].credential.credential;
|
|
5547
5712
|
invariant15(getCredentialAssertion4(spaceMemberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
|
|
5548
|
-
F:
|
|
5713
|
+
F: __dxlog_file21,
|
|
5549
5714
|
L: 104,
|
|
5550
5715
|
S: this,
|
|
5551
5716
|
A: [
|
|
@@ -5560,10 +5725,10 @@ var SpacesServiceImpl = class {
|
|
|
5560
5725
|
const scheduler = new UpdateScheduler(ctx, async () => {
|
|
5561
5726
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
5562
5727
|
const spaces = Array.from(dataSpaceManager.spaces.values()).map((space) => this._serializeSpace(space));
|
|
5563
|
-
|
|
5728
|
+
log18("update", () => ({
|
|
5564
5729
|
ids: spaces.map((space) => space.id)
|
|
5565
5730
|
}), {
|
|
5566
|
-
F:
|
|
5731
|
+
F: __dxlog_file21,
|
|
5567
5732
|
L: 115,
|
|
5568
5733
|
S: this,
|
|
5569
5734
|
C: (f, a) => f(...a)
|
|
@@ -5655,7 +5820,7 @@ var SpacesServiceImpl = class {
|
|
|
5655
5820
|
});
|
|
5656
5821
|
} else {
|
|
5657
5822
|
invariant15(!credential.id, "Id on unsigned credentials is not allowed", {
|
|
5658
|
-
F:
|
|
5823
|
+
F: __dxlog_file21,
|
|
5659
5824
|
L: 213,
|
|
5660
5825
|
S: this,
|
|
5661
5826
|
A: [
|
|
@@ -5664,7 +5829,7 @@ var SpacesServiceImpl = class {
|
|
|
5664
5829
|
]
|
|
5665
5830
|
});
|
|
5666
5831
|
invariant15(this._identityManager.identity, "Identity is not available", {
|
|
5667
|
-
F:
|
|
5832
|
+
F: __dxlog_file21,
|
|
5668
5833
|
L: 214,
|
|
5669
5834
|
S: this,
|
|
5670
5835
|
A: [
|
|
@@ -5674,7 +5839,7 @@ var SpacesServiceImpl = class {
|
|
|
5674
5839
|
});
|
|
5675
5840
|
const signer = this._identityManager.identity.getIdentityCredentialSigner();
|
|
5676
5841
|
invariant15(credential.issuer.equals(signer.getIssuer()), void 0, {
|
|
5677
|
-
F:
|
|
5842
|
+
F: __dxlog_file21,
|
|
5678
5843
|
L: 216,
|
|
5679
5844
|
S: this,
|
|
5680
5845
|
A: [
|
|
@@ -5724,7 +5889,7 @@ var SpacesServiceImpl = class {
|
|
|
5724
5889
|
async _joinByAdmission({ credential }) {
|
|
5725
5890
|
const assertion = getCredentialAssertion4(credential);
|
|
5726
5891
|
invariant15(assertion["@type"] === "dxos.halo.credentials.SpaceMember", "Invalid credential", {
|
|
5727
|
-
F:
|
|
5892
|
+
F: __dxlog_file21,
|
|
5728
5893
|
L: 250,
|
|
5729
5894
|
S: this,
|
|
5730
5895
|
A: [
|
|
@@ -5734,7 +5899,7 @@ var SpacesServiceImpl = class {
|
|
|
5734
5899
|
});
|
|
5735
5900
|
const myIdentity = this._identityManager.identity;
|
|
5736
5901
|
invariant15(myIdentity && credential.subject.id.equals(myIdentity.identityKey), void 0, {
|
|
5737
|
-
F:
|
|
5902
|
+
F: __dxlog_file21,
|
|
5738
5903
|
L: 252,
|
|
5739
5904
|
S: this,
|
|
5740
5905
|
A: [
|
|
@@ -5821,7 +5986,7 @@ var SpacesServiceImpl = class {
|
|
|
5821
5986
|
var getChannelId = (channel) => `user-channel/${channel}`;
|
|
5822
5987
|
|
|
5823
5988
|
// packages/sdk/client-services/src/packlets/services/service-context.ts
|
|
5824
|
-
import { Trigger as
|
|
5989
|
+
import { Trigger as Trigger9 } from "@dxos/async";
|
|
5825
5990
|
import { Context as Context10, Resource as Resource3 } from "@dxos/context";
|
|
5826
5991
|
import { getCredentialAssertion as getCredentialAssertion5 } from "@dxos/credentials";
|
|
5827
5992
|
import { failUndefined as failUndefined2 } from "@dxos/debug";
|
|
@@ -5831,13 +5996,13 @@ import { FeedFactory, FeedStore } from "@dxos/feed-store";
|
|
|
5831
5996
|
import { invariant as invariant16 } from "@dxos/invariant";
|
|
5832
5997
|
import { Keyring } from "@dxos/keyring";
|
|
5833
5998
|
import { PublicKey as PublicKey12 } from "@dxos/keys";
|
|
5834
|
-
import { log as
|
|
5999
|
+
import { log as log19 } from "@dxos/log";
|
|
5835
6000
|
import { InvalidStorageVersionError, STORAGE_VERSION as STORAGE_VERSION2, trace as trace9 } from "@dxos/protocols";
|
|
5836
6001
|
import { Invitation as Invitation8 } from "@dxos/protocols/proto/dxos/client/services";
|
|
5837
6002
|
import { BlobStore } from "@dxos/teleport-extension-object-sync";
|
|
5838
6003
|
import { trace as Trace3 } from "@dxos/tracing";
|
|
5839
6004
|
import { safeInstanceof } from "@dxos/util";
|
|
5840
|
-
function
|
|
6005
|
+
function _ts_decorate7(decorators, target, key, desc) {
|
|
5841
6006
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
5842
6007
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
5843
6008
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -5847,7 +6012,7 @@ function _ts_decorate6(decorators, target, key, desc) {
|
|
|
5847
6012
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5848
6013
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
5849
6014
|
}
|
|
5850
|
-
var
|
|
6015
|
+
var __dxlog_file22 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-context.ts";
|
|
5851
6016
|
var ServiceContext = class extends Resource3 {
|
|
5852
6017
|
constructor(storage, level, networkManager, signalManager, _runtimeParams) {
|
|
5853
6018
|
super();
|
|
@@ -5856,7 +6021,7 @@ var ServiceContext = class extends Resource3 {
|
|
|
5856
6021
|
this.networkManager = networkManager;
|
|
5857
6022
|
this.signalManager = signalManager;
|
|
5858
6023
|
this._runtimeParams = _runtimeParams;
|
|
5859
|
-
this.initialized = new
|
|
6024
|
+
this.initialized = new Trigger9();
|
|
5860
6025
|
this._handlerFactories = /* @__PURE__ */ new Map();
|
|
5861
6026
|
this._instanceId = PublicKey12.random().toHex();
|
|
5862
6027
|
this.metadataStore = new MetadataStore(storage.createDirectory("metadata"));
|
|
@@ -5890,16 +6055,16 @@ var ServiceContext = class extends Resource3 {
|
|
|
5890
6055
|
}
|
|
5891
6056
|
async _open(ctx) {
|
|
5892
6057
|
await this._checkStorageVersion();
|
|
5893
|
-
|
|
5894
|
-
F:
|
|
6058
|
+
log19("opening...", void 0, {
|
|
6059
|
+
F: __dxlog_file22,
|
|
5895
6060
|
L: 149,
|
|
5896
6061
|
S: this,
|
|
5897
6062
|
C: (f, a) => f(...a)
|
|
5898
6063
|
});
|
|
5899
|
-
|
|
6064
|
+
log19.trace("dxos.sdk.service-context.open", trace9.begin({
|
|
5900
6065
|
id: this._instanceId
|
|
5901
6066
|
}), {
|
|
5902
|
-
F:
|
|
6067
|
+
F: __dxlog_file22,
|
|
5903
6068
|
L: 150,
|
|
5904
6069
|
S: this,
|
|
5905
6070
|
C: (f, a) => f(...a)
|
|
@@ -5914,32 +6079,32 @@ var ServiceContext = class extends Resource3 {
|
|
|
5914
6079
|
await this._initialize(ctx);
|
|
5915
6080
|
}
|
|
5916
6081
|
const loadedInvitations = await this.invitationsManager.loadPersistentInvitations();
|
|
5917
|
-
|
|
6082
|
+
log19("loaded persistent invitations", {
|
|
5918
6083
|
count: loadedInvitations.invitations?.length
|
|
5919
6084
|
}, {
|
|
5920
|
-
F:
|
|
6085
|
+
F: __dxlog_file22,
|
|
5921
6086
|
L: 163,
|
|
5922
6087
|
S: this,
|
|
5923
6088
|
C: (f, a) => f(...a)
|
|
5924
6089
|
});
|
|
5925
|
-
|
|
6090
|
+
log19.trace("dxos.sdk.service-context.open", trace9.end({
|
|
5926
6091
|
id: this._instanceId
|
|
5927
6092
|
}), {
|
|
5928
|
-
F:
|
|
6093
|
+
F: __dxlog_file22,
|
|
5929
6094
|
L: 165,
|
|
5930
6095
|
S: this,
|
|
5931
6096
|
C: (f, a) => f(...a)
|
|
5932
6097
|
});
|
|
5933
|
-
|
|
5934
|
-
F:
|
|
6098
|
+
log19("opened", void 0, {
|
|
6099
|
+
F: __dxlog_file22,
|
|
5935
6100
|
L: 166,
|
|
5936
6101
|
S: this,
|
|
5937
6102
|
C: (f, a) => f(...a)
|
|
5938
6103
|
});
|
|
5939
6104
|
}
|
|
5940
6105
|
async _close(ctx) {
|
|
5941
|
-
|
|
5942
|
-
F:
|
|
6106
|
+
log19("closing...", void 0, {
|
|
6107
|
+
F: __dxlog_file22,
|
|
5943
6108
|
L: 170,
|
|
5944
6109
|
S: this,
|
|
5945
6110
|
C: (f, a) => f(...a)
|
|
@@ -5955,8 +6120,8 @@ var ServiceContext = class extends Resource3 {
|
|
|
5955
6120
|
await this.echoHost.close(ctx);
|
|
5956
6121
|
await this.networkManager.close();
|
|
5957
6122
|
await this.signalManager.close();
|
|
5958
|
-
|
|
5959
|
-
F:
|
|
6123
|
+
log19("closed", void 0, {
|
|
6124
|
+
F: __dxlog_file22,
|
|
5960
6125
|
L: 182,
|
|
5961
6126
|
S: this,
|
|
5962
6127
|
C: (f, a) => f(...a)
|
|
@@ -5965,7 +6130,7 @@ var ServiceContext = class extends Resource3 {
|
|
|
5965
6130
|
async createIdentity(params = {}) {
|
|
5966
6131
|
const identity = await this.identityManager.createIdentity(params);
|
|
5967
6132
|
await this._initialize(new Context10(void 0, {
|
|
5968
|
-
F:
|
|
6133
|
+
F: __dxlog_file22,
|
|
5969
6134
|
L: 187
|
|
5970
6135
|
}));
|
|
5971
6136
|
return identity;
|
|
@@ -5973,7 +6138,7 @@ var ServiceContext = class extends Resource3 {
|
|
|
5973
6138
|
getInvitationHandler(invitation) {
|
|
5974
6139
|
const factory = this._handlerFactories.get(invitation.kind);
|
|
5975
6140
|
invariant16(factory, `Unknown invitation kind: ${invitation.kind}`, {
|
|
5976
|
-
F:
|
|
6141
|
+
F: __dxlog_file22,
|
|
5977
6142
|
L: 193,
|
|
5978
6143
|
S: this,
|
|
5979
6144
|
A: [
|
|
@@ -5994,7 +6159,7 @@ var ServiceContext = class extends Resource3 {
|
|
|
5994
6159
|
async _acceptIdentity(params) {
|
|
5995
6160
|
const identity = await this.identityManager.acceptIdentity(params);
|
|
5996
6161
|
await this._initialize(new Context10(void 0, {
|
|
5997
|
-
F:
|
|
6162
|
+
F: __dxlog_file22,
|
|
5998
6163
|
L: 209
|
|
5999
6164
|
}));
|
|
6000
6165
|
return identity;
|
|
@@ -6007,8 +6172,8 @@ var ServiceContext = class extends Resource3 {
|
|
|
6007
6172
|
}
|
|
6008
6173
|
// Called when identity is created.
|
|
6009
6174
|
async _initialize(ctx) {
|
|
6010
|
-
|
|
6011
|
-
F:
|
|
6175
|
+
log19("initializing spaces...", void 0, {
|
|
6176
|
+
F: __dxlog_file22,
|
|
6012
6177
|
L: 224,
|
|
6013
6178
|
S: this,
|
|
6014
6179
|
C: (f, a) => f(...a)
|
|
@@ -6031,7 +6196,7 @@ var ServiceContext = class extends Resource3 {
|
|
|
6031
6196
|
await this.dataSpaceManager.open();
|
|
6032
6197
|
this._handlerFactories.set(Invitation8.Kind.SPACE, (invitation) => {
|
|
6033
6198
|
invariant16(this.dataSpaceManager, "dataSpaceManager not initialized yet", {
|
|
6034
|
-
F:
|
|
6199
|
+
F: __dxlog_file22,
|
|
6035
6200
|
L: 249,
|
|
6036
6201
|
S: this,
|
|
6037
6202
|
A: [
|
|
@@ -6052,10 +6217,10 @@ var ServiceContext = class extends Resource3 {
|
|
|
6052
6217
|
return;
|
|
6053
6218
|
}
|
|
6054
6219
|
if (!this.dataSpaceManager) {
|
|
6055
|
-
|
|
6220
|
+
log19("dataSpaceManager not initialized yet, ignoring space admission", {
|
|
6056
6221
|
details: assertion
|
|
6057
6222
|
}, {
|
|
6058
|
-
F:
|
|
6223
|
+
F: __dxlog_file22,
|
|
6059
6224
|
L: 265,
|
|
6060
6225
|
S: this,
|
|
6061
6226
|
C: (f, a) => f(...a)
|
|
@@ -6063,10 +6228,10 @@ var ServiceContext = class extends Resource3 {
|
|
|
6063
6228
|
return;
|
|
6064
6229
|
}
|
|
6065
6230
|
if (this.dataSpaceManager.spaces.has(assertion.spaceKey)) {
|
|
6066
|
-
|
|
6231
|
+
log19("space already exists, ignoring space admission", {
|
|
6067
6232
|
details: assertion
|
|
6068
6233
|
}, {
|
|
6069
|
-
F:
|
|
6234
|
+
F: __dxlog_file22,
|
|
6070
6235
|
L: 269,
|
|
6071
6236
|
S: this,
|
|
6072
6237
|
C: (f, a) => f(...a)
|
|
@@ -6074,10 +6239,10 @@ var ServiceContext = class extends Resource3 {
|
|
|
6074
6239
|
return;
|
|
6075
6240
|
}
|
|
6076
6241
|
try {
|
|
6077
|
-
|
|
6242
|
+
log19("accepting space recorded in halo", {
|
|
6078
6243
|
details: assertion
|
|
6079
6244
|
}, {
|
|
6080
|
-
F:
|
|
6245
|
+
F: __dxlog_file22,
|
|
6081
6246
|
L: 274,
|
|
6082
6247
|
S: this,
|
|
6083
6248
|
C: (f, a) => f(...a)
|
|
@@ -6087,8 +6252,8 @@ var ServiceContext = class extends Resource3 {
|
|
|
6087
6252
|
genesisFeedKey: assertion.genesisFeedKey
|
|
6088
6253
|
});
|
|
6089
6254
|
} catch (err) {
|
|
6090
|
-
|
|
6091
|
-
F:
|
|
6255
|
+
log19.catch(err, void 0, {
|
|
6256
|
+
F: __dxlog_file22,
|
|
6092
6257
|
L: 280,
|
|
6093
6258
|
S: this,
|
|
6094
6259
|
C: (f, a) => f(...a)
|
|
@@ -6099,13 +6264,13 @@ var ServiceContext = class extends Resource3 {
|
|
|
6099
6264
|
await identity.space.spaceState.addCredentialProcessor(this._deviceSpaceSync);
|
|
6100
6265
|
}
|
|
6101
6266
|
};
|
|
6102
|
-
|
|
6267
|
+
_ts_decorate7([
|
|
6103
6268
|
Trace3.span()
|
|
6104
6269
|
], ServiceContext.prototype, "_open", null);
|
|
6105
|
-
|
|
6270
|
+
_ts_decorate7([
|
|
6106
6271
|
Trace3.span()
|
|
6107
6272
|
], ServiceContext.prototype, "_initialize", null);
|
|
6108
|
-
ServiceContext =
|
|
6273
|
+
ServiceContext = _ts_decorate7([
|
|
6109
6274
|
safeInstanceof("dxos.client-services.ServiceContext"),
|
|
6110
6275
|
Trace3.resource()
|
|
6111
6276
|
], ServiceContext);
|
|
@@ -6134,130 +6299,6 @@ var ServiceRegistry = class {
|
|
|
6134
6299
|
}
|
|
6135
6300
|
};
|
|
6136
6301
|
|
|
6137
|
-
// packages/sdk/client-services/src/packlets/locks/browser.ts
|
|
6138
|
-
import { asyncTimeout as asyncTimeout2, Trigger as Trigger9 } from "@dxos/async";
|
|
6139
|
-
import { RESOURCE_LOCK_TIMEOUT } from "@dxos/client-protocol";
|
|
6140
|
-
import { log as log19, logInfo } from "@dxos/log";
|
|
6141
|
-
function _ts_decorate7(decorators, target, key, desc) {
|
|
6142
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
6143
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
6144
|
-
r = Reflect.decorate(decorators, target, key, desc);
|
|
6145
|
-
else
|
|
6146
|
-
for (var i = decorators.length - 1; i >= 0; i--)
|
|
6147
|
-
if (d = decorators[i])
|
|
6148
|
-
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6149
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6150
|
-
}
|
|
6151
|
-
var __dxlog_file22 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/locks/browser.ts";
|
|
6152
|
-
var Message;
|
|
6153
|
-
(function(Message2) {
|
|
6154
|
-
Message2["ACQUIRING"] = "acquiring";
|
|
6155
|
-
})(Message || (Message = {}));
|
|
6156
|
-
var Lock = class {
|
|
6157
|
-
constructor({ lockKey, onAcquire, onRelease }) {
|
|
6158
|
-
this._broadcastChannel = new BroadcastChannel("vault-resource-lock");
|
|
6159
|
-
this._releaseTrigger = new Trigger9();
|
|
6160
|
-
this._lockKey = lockKey;
|
|
6161
|
-
this._onAcquire = onAcquire;
|
|
6162
|
-
this._onRelease = onRelease;
|
|
6163
|
-
this._broadcastChannel.onmessage = this._onMessage.bind(this);
|
|
6164
|
-
}
|
|
6165
|
-
get lockKey() {
|
|
6166
|
-
return this._lockKey;
|
|
6167
|
-
}
|
|
6168
|
-
async acquire() {
|
|
6169
|
-
this._broadcastChannel.postMessage({
|
|
6170
|
-
message: "acquiring"
|
|
6171
|
-
});
|
|
6172
|
-
try {
|
|
6173
|
-
log19("aquiring lock...", void 0, {
|
|
6174
|
-
F: __dxlog_file22,
|
|
6175
|
-
L: 42,
|
|
6176
|
-
S: this,
|
|
6177
|
-
C: (f, a) => f(...a)
|
|
6178
|
-
});
|
|
6179
|
-
await asyncTimeout2(this._requestLock(), RESOURCE_LOCK_TIMEOUT);
|
|
6180
|
-
log19("acquired lock", void 0, {
|
|
6181
|
-
F: __dxlog_file22,
|
|
6182
|
-
L: 44,
|
|
6183
|
-
S: this,
|
|
6184
|
-
C: (f, a) => f(...a)
|
|
6185
|
-
});
|
|
6186
|
-
} catch {
|
|
6187
|
-
log19("stealing lock...", void 0, {
|
|
6188
|
-
F: __dxlog_file22,
|
|
6189
|
-
L: 46,
|
|
6190
|
-
S: this,
|
|
6191
|
-
C: (f, a) => f(...a)
|
|
6192
|
-
});
|
|
6193
|
-
await this._requestLock(true);
|
|
6194
|
-
log19("stolen lock", void 0, {
|
|
6195
|
-
F: __dxlog_file22,
|
|
6196
|
-
L: 48,
|
|
6197
|
-
S: this,
|
|
6198
|
-
C: (f, a) => f(...a)
|
|
6199
|
-
});
|
|
6200
|
-
}
|
|
6201
|
-
}
|
|
6202
|
-
async release() {
|
|
6203
|
-
this._releaseTrigger.wake();
|
|
6204
|
-
}
|
|
6205
|
-
_onMessage(event) {
|
|
6206
|
-
if (event.data.message === "acquiring") {
|
|
6207
|
-
this._releaseTrigger.wake();
|
|
6208
|
-
}
|
|
6209
|
-
}
|
|
6210
|
-
async _requestLock(steal = false) {
|
|
6211
|
-
log19("requesting lock...", {
|
|
6212
|
-
steal
|
|
6213
|
-
}, {
|
|
6214
|
-
F: __dxlog_file22,
|
|
6215
|
-
L: 63,
|
|
6216
|
-
S: this,
|
|
6217
|
-
C: (f, a) => f(...a)
|
|
6218
|
-
});
|
|
6219
|
-
const acquired = new Trigger9();
|
|
6220
|
-
void navigator.locks.request(this._lockKey, {
|
|
6221
|
-
steal
|
|
6222
|
-
}, async () => {
|
|
6223
|
-
await this._onAcquire?.();
|
|
6224
|
-
acquired.wake();
|
|
6225
|
-
this._releaseTrigger = new Trigger9();
|
|
6226
|
-
await this._releaseTrigger.wait();
|
|
6227
|
-
log19("releasing lock...", void 0, {
|
|
6228
|
-
F: __dxlog_file22,
|
|
6229
|
-
L: 72,
|
|
6230
|
-
S: this,
|
|
6231
|
-
C: (f, a) => f(...a)
|
|
6232
|
-
});
|
|
6233
|
-
await this._onRelease?.();
|
|
6234
|
-
log19("released lock", void 0, {
|
|
6235
|
-
F: __dxlog_file22,
|
|
6236
|
-
L: 74,
|
|
6237
|
-
S: this,
|
|
6238
|
-
C: (f, a) => f(...a)
|
|
6239
|
-
});
|
|
6240
|
-
}).catch(async () => {
|
|
6241
|
-
await this._onRelease?.();
|
|
6242
|
-
});
|
|
6243
|
-
await acquired.wait();
|
|
6244
|
-
log19("recieved lock", {
|
|
6245
|
-
steal
|
|
6246
|
-
}, {
|
|
6247
|
-
F: __dxlog_file22,
|
|
6248
|
-
L: 81,
|
|
6249
|
-
S: this,
|
|
6250
|
-
C: (f, a) => f(...a)
|
|
6251
|
-
});
|
|
6252
|
-
}
|
|
6253
|
-
};
|
|
6254
|
-
_ts_decorate7([
|
|
6255
|
-
logInfo
|
|
6256
|
-
], Lock.prototype, "lockKey", null);
|
|
6257
|
-
var isLocked = (lockPath) => {
|
|
6258
|
-
throw new Error("Not implemented");
|
|
6259
|
-
};
|
|
6260
|
-
|
|
6261
6302
|
// packages/sdk/client-services/src/packlets/storage/storage.ts
|
|
6262
6303
|
import { InvalidConfigError } from "@dxos/protocols";
|
|
6263
6304
|
import { Runtime as Runtime2 } from "@dxos/protocols/proto/dxos/config";
|
|
@@ -6496,7 +6537,7 @@ import { Event as Event9, synchronized as synchronized3 } from "@dxos/async";
|
|
|
6496
6537
|
import { clientServiceBundle } from "@dxos/client-protocol";
|
|
6497
6538
|
import { Context as Context11 } from "@dxos/context";
|
|
6498
6539
|
import { invariant as invariant19 } from "@dxos/invariant";
|
|
6499
|
-
import { PublicKey as
|
|
6540
|
+
import { PublicKey as PublicKey16 } from "@dxos/keys";
|
|
6500
6541
|
import { log as log22 } from "@dxos/log";
|
|
6501
6542
|
import { WebsocketSignalManager } from "@dxos/messaging";
|
|
6502
6543
|
import { SwarmNetworkManager, createSimplePeerTransportFactory } from "@dxos/network-manager";
|
|
@@ -6587,57 +6628,10 @@ var DevicesServiceImpl = class {
|
|
|
6587
6628
|
}
|
|
6588
6629
|
};
|
|
6589
6630
|
|
|
6590
|
-
// packages/sdk/client-services/src/packlets/diagnostics/diagnostics-collector.ts
|
|
6591
|
-
import { ConfigResource } from "@dxos/config";
|
|
6592
|
-
import { GetDiagnosticsRequest } from "@dxos/protocols/proto/dxos/client/services";
|
|
6593
|
-
import { TRACE_PROCESSOR as TRACE_PROCESSOR2 } from "@dxos/tracing";
|
|
6594
|
-
import { jsonKeyReplacer, nonNullable } from "@dxos/util";
|
|
6595
|
-
|
|
6596
|
-
// packages/sdk/client-services/src/packlets/services/util.ts
|
|
6597
|
-
import { PublicKey as PublicKey14 } from "@dxos/keys";
|
|
6598
|
-
import { humanize } from "@dxos/util";
|
|
6599
|
-
var ClientServicesProviderResource = Symbol.for("dxos.resource.ClientServices");
|
|
6600
|
-
|
|
6601
|
-
// packages/sdk/client-services/src/packlets/diagnostics/diagnostics-collector.ts
|
|
6602
|
-
var GET_DIAGNOSTICS_RPC_TIMEOUT = 1e4;
|
|
6603
|
-
var DiagnosticsCollector = class {
|
|
6604
|
-
static {
|
|
6605
|
-
this.broadcastSender = createCollectDiagnosticsBroadcastSender();
|
|
6606
|
-
}
|
|
6607
|
-
static async collect(config = findConfigs(), services = findSystemServiceProvider(), options = {}) {
|
|
6608
|
-
const serviceDiagnostics = await services?.services?.SystemService?.getDiagnostics({
|
|
6609
|
-
keys: options.humanize ? GetDiagnosticsRequest.KEY_OPTION.HUMANIZE : options.truncate ? GetDiagnosticsRequest.KEY_OPTION.TRUNCATE : void 0
|
|
6610
|
-
}, {
|
|
6611
|
-
timeout: GET_DIAGNOSTICS_RPC_TIMEOUT
|
|
6612
|
-
});
|
|
6613
|
-
const clientDiagnostics = {
|
|
6614
|
-
config,
|
|
6615
|
-
trace: TRACE_PROCESSOR2.getDiagnostics()
|
|
6616
|
-
};
|
|
6617
|
-
const diagnostics = serviceDiagnostics != null ? {
|
|
6618
|
-
client: clientDiagnostics,
|
|
6619
|
-
services: serviceDiagnostics
|
|
6620
|
-
} : {
|
|
6621
|
-
client: clientDiagnostics,
|
|
6622
|
-
broadcast: await this.broadcastSender.broadcastDiagnosticsRequest()
|
|
6623
|
-
};
|
|
6624
|
-
return JSON.parse(JSON.stringify(diagnostics, jsonKeyReplacer(options)));
|
|
6625
|
-
}
|
|
6626
|
-
};
|
|
6627
|
-
var findSystemServiceProvider = () => {
|
|
6628
|
-
const serviceProviders = TRACE_PROCESSOR2.findResourcesByAnnotation(ClientServicesProviderResource);
|
|
6629
|
-
const providerResource = serviceProviders.find((r) => r.instance.deref()?.services?.SystemService != null);
|
|
6630
|
-
return providerResource?.instance?.deref() ?? null;
|
|
6631
|
-
};
|
|
6632
|
-
var findConfigs = () => {
|
|
6633
|
-
const configs = TRACE_PROCESSOR2.findResourcesByAnnotation(ConfigResource);
|
|
6634
|
-
return configs.map((r) => r.instance.deref()).filter(nonNullable);
|
|
6635
|
-
};
|
|
6636
|
-
|
|
6637
6631
|
// packages/sdk/client-services/src/packlets/identity/contacts-service.ts
|
|
6638
6632
|
import { EventSubscriptions as EventSubscriptions4, scheduleTask as scheduleTask7, UpdateScheduler as UpdateScheduler2 } from "@dxos/async";
|
|
6639
6633
|
import { Stream as Stream12 } from "@dxos/codec-protobuf";
|
|
6640
|
-
import { PublicKey as
|
|
6634
|
+
import { PublicKey as PublicKey14 } from "@dxos/keys";
|
|
6641
6635
|
import { ComplexMap as ComplexMap4, ComplexSet as ComplexSet6 } from "@dxos/util";
|
|
6642
6636
|
var ContactsServiceImpl = class {
|
|
6643
6637
|
constructor(_identityManager, _spaceManager, _dataSpaceManagerProvider) {
|
|
@@ -6678,7 +6672,7 @@ var ContactsServiceImpl = class {
|
|
|
6678
6672
|
});
|
|
6679
6673
|
}
|
|
6680
6674
|
return acc;
|
|
6681
|
-
}, new ComplexMap4(
|
|
6675
|
+
}, new ComplexMap4(PublicKey14.hash));
|
|
6682
6676
|
return {
|
|
6683
6677
|
contacts: [
|
|
6684
6678
|
...contacts.values()
|
|
@@ -6686,7 +6680,7 @@ var ContactsServiceImpl = class {
|
|
|
6686
6680
|
};
|
|
6687
6681
|
}
|
|
6688
6682
|
queryContacts() {
|
|
6689
|
-
const subscribedSpaceKeySet = new ComplexSet6(
|
|
6683
|
+
const subscribedSpaceKeySet = new ComplexSet6(PublicKey14.hash);
|
|
6690
6684
|
return new Stream12(({ next, ctx }) => {
|
|
6691
6685
|
const pushUpdateTask = new UpdateScheduler2(ctx, async () => {
|
|
6692
6686
|
const contacts = await this.getContacts();
|
|
@@ -6720,7 +6714,7 @@ var ContactsServiceImpl = class {
|
|
|
6720
6714
|
// packages/sdk/client-services/src/packlets/logging/logging-service.ts
|
|
6721
6715
|
import { Event as Event8 } from "@dxos/async";
|
|
6722
6716
|
import { Stream as Stream13 } from "@dxos/codec-protobuf";
|
|
6723
|
-
import { PublicKey as
|
|
6717
|
+
import { PublicKey as PublicKey15 } from "@dxos/keys";
|
|
6724
6718
|
import { getContextFromEntry, log as log21 } from "@dxos/log";
|
|
6725
6719
|
import { QueryLogsRequest } from "@dxos/protocols/proto/dxos/client/services";
|
|
6726
6720
|
import { getDebugName, jsonify, numericalValues, tracer } from "@dxos/util";
|
|
@@ -6728,7 +6722,7 @@ var LoggingServiceImpl = class {
|
|
|
6728
6722
|
constructor() {
|
|
6729
6723
|
this._logs = new Event8();
|
|
6730
6724
|
this._started = Date.now();
|
|
6731
|
-
this._sessionId =
|
|
6725
|
+
this._sessionId = PublicKey15.random().toHex();
|
|
6732
6726
|
this._logProcessor = (_config, entry2) => {
|
|
6733
6727
|
this._logs.emit(entry2);
|
|
6734
6728
|
};
|
|
@@ -7100,7 +7094,7 @@ var ClientServicesHost = class {
|
|
|
7100
7094
|
if (this._open) {
|
|
7101
7095
|
return;
|
|
7102
7096
|
}
|
|
7103
|
-
const traceId =
|
|
7097
|
+
const traceId = PublicKey16.random().toHex();
|
|
7104
7098
|
log22.trace("dxos.client-services.host.open", trace10.begin({
|
|
7105
7099
|
id: traceId
|
|
7106
7100
|
}), {
|
|
@@ -7252,7 +7246,7 @@ var ClientServicesHost = class {
|
|
|
7252
7246
|
});
|
|
7253
7247
|
}
|
|
7254
7248
|
async reset() {
|
|
7255
|
-
const traceId =
|
|
7249
|
+
const traceId = PublicKey16.random().toHex();
|
|
7256
7250
|
log22.trace("dxos.sdk.client-services-host.reset", trace10.begin({
|
|
7257
7251
|
id: traceId
|
|
7258
7252
|
}), {
|
|
@@ -7324,7 +7318,7 @@ export {
|
|
|
7324
7318
|
createDiagnostics,
|
|
7325
7319
|
createCollectDiagnosticsBroadcastSender,
|
|
7326
7320
|
createCollectDiagnosticsBroadcastHandler,
|
|
7327
|
-
|
|
7321
|
+
DiagnosticsCollector,
|
|
7328
7322
|
createAuthProvider,
|
|
7329
7323
|
TrustedKeySetAuthVerifier,
|
|
7330
7324
|
Identity,
|
|
@@ -7336,21 +7330,20 @@ export {
|
|
|
7336
7330
|
InvitationsServiceImpl,
|
|
7337
7331
|
SpaceInvitationProtocol,
|
|
7338
7332
|
InvitationsManager,
|
|
7333
|
+
Lock,
|
|
7334
|
+
isLocked,
|
|
7335
|
+
ClientRpcServer,
|
|
7339
7336
|
DataSpace,
|
|
7340
7337
|
DataSpaceManager,
|
|
7341
7338
|
SpacesServiceImpl,
|
|
7342
7339
|
ServiceContext,
|
|
7343
7340
|
ServiceRegistry,
|
|
7344
|
-
Lock,
|
|
7345
|
-
isLocked,
|
|
7346
7341
|
createStorageObjects,
|
|
7347
7342
|
createLevel,
|
|
7348
7343
|
encodeProfileArchive,
|
|
7349
7344
|
decodeProfileArchive,
|
|
7350
7345
|
exportProfileData,
|
|
7351
7346
|
importProfileData,
|
|
7352
|
-
ClientServicesHost
|
|
7353
|
-
ClientServicesProviderResource,
|
|
7354
|
-
DiagnosticsCollector
|
|
7347
|
+
ClientServicesHost
|
|
7355
7348
|
};
|
|
7356
|
-
//# sourceMappingURL=chunk-
|
|
7349
|
+
//# sourceMappingURL=chunk-JCYU3AYC.mjs.map
|