@dxos/client-services 0.5.9-main.bdf733d → 0.5.9-main.bfee100
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-KNGR7BYM.mjs → chunk-TZL7PJDX.mjs} +767 -605
- package/dist/lib/browser/chunk-TZL7PJDX.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +1 -1
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/packlets/testing/index.mjs +11 -11
- package/dist/lib/browser/packlets/testing/index.mjs.map +3 -3
- package/dist/lib/node/{chunk-WWHTBQNR.cjs → chunk-STUWVNPH.cjs} +982 -824
- package/dist/lib/node/chunk-STUWVNPH.cjs.map +7 -0
- package/dist/lib/node/index.cjs +42 -42
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/packlets/testing/index.cjs +17 -17
- package/dist/lib/node/packlets/testing/index.cjs.map +3 -3
- package/dist/types/src/packlets/identity/default-space-state-machine.d.ts +19 -0
- package/dist/types/src/packlets/identity/default-space-state-machine.d.ts.map +1 -0
- package/dist/types/src/packlets/identity/identity-service.d.ts +14 -7
- package/dist/types/src/packlets/identity/identity-service.d.ts.map +1 -1
- package/dist/types/src/packlets/identity/identity.d.ts +4 -1
- package/dist/types/src/packlets/identity/identity.d.ts.map +1 -1
- package/dist/types/src/packlets/services/service-context.d.ts.map +1 -1
- package/dist/types/src/packlets/services/service-host.d.ts +1 -1
- package/dist/types/src/packlets/services/service-host.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/data-space-manager.d.ts +5 -3
- package/dist/types/src/packlets/spaces/data-space-manager.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/data-space.d.ts +1 -0
- package/dist/types/src/packlets/spaces/data-space.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/spaces-service.d.ts +1 -1
- package/dist/types/src/packlets/spaces/spaces-service.d.ts.map +1 -1
- package/dist/types/src/packlets/testing/test-builder.d.ts +8 -6
- package/dist/types/src/packlets/testing/test-builder.d.ts.map +1 -1
- package/dist/types/src/version.d.ts +1 -1
- package/package.json +36 -36
- package/src/packlets/identity/default-space-state-machine.ts +44 -0
- package/src/packlets/identity/identity-service.test.ts +35 -5
- package/src/packlets/identity/identity-service.ts +50 -8
- package/src/packlets/identity/identity.ts +25 -2
- package/src/packlets/services/service-context.ts +1 -4
- package/src/packlets/services/service-host.ts +13 -40
- package/src/packlets/spaces/data-space-manager.test.ts +46 -1
- package/src/packlets/spaces/data-space-manager.ts +54 -25
- package/src/packlets/spaces/data-space.ts +24 -5
- package/src/packlets/spaces/spaces-service.ts +2 -2
- package/src/packlets/testing/test-builder.ts +12 -10
- package/src/version.ts +1 -1
- package/dist/lib/browser/chunk-KNGR7BYM.mjs.map +0 -7
- package/dist/lib/node/chunk-WWHTBQNR.cjs.map +0 -7
|
@@ -355,7 +355,7 @@ import { SpaceMember } from "@dxos/protocols/proto/dxos/client/services";
|
|
|
355
355
|
import { TRACE_PROCESSOR } from "@dxos/tracing";
|
|
356
356
|
|
|
357
357
|
// packages/sdk/client-services/src/version.ts
|
|
358
|
-
var DXOS_VERSION = "0.5.9-main.
|
|
358
|
+
var DXOS_VERSION = "0.5.9-main.bfee100";
|
|
359
359
|
|
|
360
360
|
// packages/sdk/client-services/src/packlets/services/platform.ts
|
|
361
361
|
import { Platform } from "@dxos/protocols/proto/dxos/client/services";
|
|
@@ -803,10 +803,59 @@ import { DeviceStateMachine, createCredentialSignerWithKey, createCredentialSign
|
|
|
803
803
|
import { writeMessages } from "@dxos/feed-store";
|
|
804
804
|
import { invariant as invariant2 } from "@dxos/invariant";
|
|
805
805
|
import { PublicKey as PublicKey3 } from "@dxos/keys";
|
|
806
|
-
import { log as
|
|
806
|
+
import { log as log4 } from "@dxos/log";
|
|
807
807
|
import { AdmittedFeed } from "@dxos/protocols/proto/dxos/halo/credentials";
|
|
808
|
+
import { Timeframe } from "@dxos/timeframe";
|
|
808
809
|
import { trace as trace2 } from "@dxos/tracing";
|
|
809
810
|
import { ComplexSet } from "@dxos/util";
|
|
811
|
+
|
|
812
|
+
// packages/sdk/client-services/src/packlets/identity/default-space-state-machine.ts
|
|
813
|
+
import { getCredentialAssertion } from "@dxos/credentials";
|
|
814
|
+
import { SpaceId } from "@dxos/keys";
|
|
815
|
+
import { log as log3 } from "@dxos/log";
|
|
816
|
+
var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/default-space-state-machine.ts";
|
|
817
|
+
var DefaultSpaceStateMachine = class {
|
|
818
|
+
constructor(_params) {
|
|
819
|
+
this._params = _params;
|
|
820
|
+
}
|
|
821
|
+
get spaceId() {
|
|
822
|
+
return this._spaceId;
|
|
823
|
+
}
|
|
824
|
+
async processCredential(credential) {
|
|
825
|
+
const assertion = getCredentialAssertion(credential);
|
|
826
|
+
switch (assertion["@type"]) {
|
|
827
|
+
case "dxos.halo.credentials.DefaultSpace": {
|
|
828
|
+
if (!credential.subject.id.equals(this._params.identityKey)) {
|
|
829
|
+
log3.warn("Invalid default space credential", {
|
|
830
|
+
expectedIdentity: this._params.identityKey,
|
|
831
|
+
credential
|
|
832
|
+
}, {
|
|
833
|
+
F: __dxlog_file4,
|
|
834
|
+
L: 32,
|
|
835
|
+
S: this,
|
|
836
|
+
C: (f, a) => f(...a)
|
|
837
|
+
});
|
|
838
|
+
return;
|
|
839
|
+
}
|
|
840
|
+
if (!SpaceId.isValid(assertion.spaceId)) {
|
|
841
|
+
log3.warn("Invalid default space id", {
|
|
842
|
+
id: assertion.spaceId
|
|
843
|
+
}, {
|
|
844
|
+
F: __dxlog_file4,
|
|
845
|
+
L: 36,
|
|
846
|
+
S: this,
|
|
847
|
+
C: (f, a) => f(...a)
|
|
848
|
+
});
|
|
849
|
+
return;
|
|
850
|
+
}
|
|
851
|
+
this._spaceId = assertion.spaceId;
|
|
852
|
+
break;
|
|
853
|
+
}
|
|
854
|
+
}
|
|
855
|
+
}
|
|
856
|
+
};
|
|
857
|
+
|
|
858
|
+
// packages/sdk/client-services/src/packlets/identity/identity.ts
|
|
810
859
|
function _ts_decorate2(decorators, target, key, desc) {
|
|
811
860
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
812
861
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
@@ -817,7 +866,7 @@ function _ts_decorate2(decorators, target, key, desc) {
|
|
|
817
866
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
818
867
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
819
868
|
}
|
|
820
|
-
var
|
|
869
|
+
var __dxlog_file5 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/identity.ts";
|
|
821
870
|
var Identity = class {
|
|
822
871
|
constructor({ space, signer, identityKey, deviceKey, presence }) {
|
|
823
872
|
this.stateUpdate = new Event();
|
|
@@ -826,11 +875,11 @@ var Identity = class {
|
|
|
826
875
|
this._presence = presence;
|
|
827
876
|
this.identityKey = identityKey;
|
|
828
877
|
this.deviceKey = deviceKey;
|
|
829
|
-
|
|
878
|
+
log4.trace("dxos.halo.device", {
|
|
830
879
|
deviceKey
|
|
831
880
|
}, {
|
|
832
|
-
F:
|
|
833
|
-
L:
|
|
881
|
+
F: __dxlog_file5,
|
|
882
|
+
L: 70,
|
|
834
883
|
S: this,
|
|
835
884
|
C: (f, a) => f(...a)
|
|
836
885
|
});
|
|
@@ -843,6 +892,10 @@ var Identity = class {
|
|
|
843
892
|
identityKey: this.identityKey,
|
|
844
893
|
onUpdate: () => this.stateUpdate.emit()
|
|
845
894
|
});
|
|
895
|
+
this._defaultSpaceStateMachine = new DefaultSpaceStateMachine({
|
|
896
|
+
identityKey: this.identityKey,
|
|
897
|
+
onUpdate: () => this.stateUpdate.emit()
|
|
898
|
+
});
|
|
846
899
|
this.authVerifier = new TrustedKeySetAuthVerifier({
|
|
847
900
|
trustedKeysProvider: () => new ComplexSet(PublicKey3.hash, this.authorizedDeviceKeys.keys()),
|
|
848
901
|
update: this.stateUpdate,
|
|
@@ -853,14 +906,20 @@ var Identity = class {
|
|
|
853
906
|
get authorizedDeviceKeys() {
|
|
854
907
|
return this._deviceStateMachine.authorizedDeviceKeys;
|
|
855
908
|
}
|
|
909
|
+
get defaultSpaceId() {
|
|
910
|
+
return this._defaultSpaceStateMachine.spaceId;
|
|
911
|
+
}
|
|
856
912
|
async open(ctx) {
|
|
913
|
+
await this._presence?.open();
|
|
857
914
|
await this.space.spaceState.addCredentialProcessor(this._deviceStateMachine);
|
|
858
915
|
await this.space.spaceState.addCredentialProcessor(this._profileStateMachine);
|
|
916
|
+
await this.space.spaceState.addCredentialProcessor(this._defaultSpaceStateMachine);
|
|
859
917
|
await this.space.open(ctx);
|
|
860
918
|
}
|
|
861
919
|
async close(ctx) {
|
|
862
|
-
await this._presence?.
|
|
920
|
+
await this._presence?.close();
|
|
863
921
|
await this.authVerifier.close();
|
|
922
|
+
await this.space.spaceState.removeCredentialProcessor(this._defaultSpaceStateMachine);
|
|
864
923
|
await this.space.spaceState.removeCredentialProcessor(this._profileStateMachine);
|
|
865
924
|
await this.space.spaceState.removeCredentialProcessor(this._deviceStateMachine);
|
|
866
925
|
await this.space.close();
|
|
@@ -898,8 +957,8 @@ var Identity = class {
|
|
|
898
957
|
*/
|
|
899
958
|
getIdentityCredentialSigner() {
|
|
900
959
|
invariant2(this._deviceStateMachine.deviceCredentialChain, "Device credential chain is not ready.", {
|
|
901
|
-
F:
|
|
902
|
-
L:
|
|
960
|
+
F: __dxlog_file5,
|
|
961
|
+
L: 159,
|
|
903
962
|
S: this,
|
|
904
963
|
A: [
|
|
905
964
|
"this._deviceStateMachine.deviceCredentialChain",
|
|
@@ -914,16 +973,36 @@ var Identity = class {
|
|
|
914
973
|
getDeviceCredentialSigner() {
|
|
915
974
|
return createCredentialSignerWithKey(this._signer, this.deviceKey);
|
|
916
975
|
}
|
|
976
|
+
async updateDefaultSpace(spaceId) {
|
|
977
|
+
const credential = await this.getDeviceCredentialSigner().createCredential({
|
|
978
|
+
subject: this.identityKey,
|
|
979
|
+
assertion: {
|
|
980
|
+
"@type": "dxos.halo.credentials.DefaultSpace",
|
|
981
|
+
spaceId
|
|
982
|
+
}
|
|
983
|
+
});
|
|
984
|
+
const receipt = await this.controlPipeline.writer.write({
|
|
985
|
+
credential: {
|
|
986
|
+
credential
|
|
987
|
+
}
|
|
988
|
+
});
|
|
989
|
+
await this.controlPipeline.state.waitUntilTimeframe(new Timeframe([
|
|
990
|
+
[
|
|
991
|
+
receipt.feedKey,
|
|
992
|
+
receipt.seq
|
|
993
|
+
]
|
|
994
|
+
]));
|
|
995
|
+
}
|
|
917
996
|
async admitDevice({ deviceKey, controlFeedKey, dataFeedKey }) {
|
|
918
|
-
|
|
997
|
+
log4("Admitting device:", {
|
|
919
998
|
identityKey: this.identityKey,
|
|
920
999
|
hostDevice: this.deviceKey,
|
|
921
1000
|
deviceKey,
|
|
922
1001
|
controlFeedKey,
|
|
923
1002
|
dataFeedKey
|
|
924
1003
|
}, {
|
|
925
|
-
F:
|
|
926
|
-
L:
|
|
1004
|
+
F: __dxlog_file5,
|
|
1005
|
+
L: 184,
|
|
927
1006
|
S: this,
|
|
928
1007
|
C: (f, a) => f(...a)
|
|
929
1008
|
});
|
|
@@ -981,12 +1060,12 @@ import { Context as Context3 } from "@dxos/context";
|
|
|
981
1060
|
import { createCredentialSignerWithKey as createCredentialSignerWithKey2, CredentialGenerator } from "@dxos/credentials";
|
|
982
1061
|
import { invariant as invariant3 } from "@dxos/invariant";
|
|
983
1062
|
import { PublicKey as PublicKey4 } from "@dxos/keys";
|
|
984
|
-
import { log as
|
|
1063
|
+
import { log as log5 } from "@dxos/log";
|
|
985
1064
|
import { trace as trace3 } from "@dxos/protocols";
|
|
986
1065
|
import { Device, DeviceKind } from "@dxos/protocols/proto/dxos/client/services";
|
|
987
1066
|
import { AdmittedFeed as AdmittedFeed2, DeviceType } from "@dxos/protocols/proto/dxos/halo/credentials";
|
|
988
1067
|
import { Gossip, Presence } from "@dxos/teleport-extension-gossip";
|
|
989
|
-
import { Timeframe } from "@dxos/timeframe";
|
|
1068
|
+
import { Timeframe as Timeframe2 } from "@dxos/timeframe";
|
|
990
1069
|
import { trace as Trace } from "@dxos/tracing";
|
|
991
1070
|
import { isNode, deferFunction } from "@dxos/util";
|
|
992
1071
|
function _ts_decorate3(decorators, target, key, desc) {
|
|
@@ -999,7 +1078,7 @@ function _ts_decorate3(decorators, target, key, desc) {
|
|
|
999
1078
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
1000
1079
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1001
1080
|
}
|
|
1002
|
-
var
|
|
1081
|
+
var __dxlog_file6 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/identity-manager.ts";
|
|
1003
1082
|
var DEVICE_PRESENCE_ANNOUNCE_INTERVAL = 1e4;
|
|
1004
1083
|
var DEVICE_PRESENCE_OFFLINE_TIMEOUT = 2e4;
|
|
1005
1084
|
var IdentityManager = class {
|
|
@@ -1020,19 +1099,19 @@ var IdentityManager = class {
|
|
|
1020
1099
|
}
|
|
1021
1100
|
async open(ctx) {
|
|
1022
1101
|
const traceId = PublicKey4.random().toHex();
|
|
1023
|
-
|
|
1102
|
+
log5.trace("dxos.halo.identity-manager.open", trace3.begin({
|
|
1024
1103
|
id: traceId
|
|
1025
1104
|
}), {
|
|
1026
|
-
F:
|
|
1105
|
+
F: __dxlog_file6,
|
|
1027
1106
|
L: 104,
|
|
1028
1107
|
S: this,
|
|
1029
1108
|
C: (f, a) => f(...a)
|
|
1030
1109
|
});
|
|
1031
1110
|
const identityRecord = this._metadataStore.getIdentityRecord();
|
|
1032
|
-
|
|
1111
|
+
log5("identity record", {
|
|
1033
1112
|
identityRecord
|
|
1034
1113
|
}, {
|
|
1035
|
-
F:
|
|
1114
|
+
F: __dxlog_file6,
|
|
1036
1115
|
L: 107,
|
|
1037
1116
|
S: this,
|
|
1038
1117
|
C: (f, a) => f(...a)
|
|
@@ -1041,21 +1120,21 @@ var IdentityManager = class {
|
|
|
1041
1120
|
this._identity = await this._constructIdentity(identityRecord);
|
|
1042
1121
|
await this._identity.open(ctx);
|
|
1043
1122
|
await this._identity.ready();
|
|
1044
|
-
|
|
1123
|
+
log5.trace("dxos.halo.identity", {
|
|
1045
1124
|
identityKey: identityRecord.identityKey,
|
|
1046
1125
|
displayName: this._identity.profileDocument?.displayName
|
|
1047
1126
|
}, {
|
|
1048
|
-
F:
|
|
1127
|
+
F: __dxlog_file6,
|
|
1049
1128
|
L: 112,
|
|
1050
1129
|
S: this,
|
|
1051
1130
|
C: (f, a) => f(...a)
|
|
1052
1131
|
});
|
|
1053
1132
|
this.stateUpdate.emit();
|
|
1054
1133
|
}
|
|
1055
|
-
|
|
1134
|
+
log5.trace("dxos.halo.identity-manager.open", trace3.end({
|
|
1056
1135
|
id: traceId
|
|
1057
1136
|
}), {
|
|
1058
|
-
F:
|
|
1137
|
+
F: __dxlog_file6,
|
|
1059
1138
|
L: 119,
|
|
1060
1139
|
S: this,
|
|
1061
1140
|
C: (f, a) => f(...a)
|
|
@@ -1066,7 +1145,7 @@ var IdentityManager = class {
|
|
|
1066
1145
|
}
|
|
1067
1146
|
async createIdentity({ displayName, deviceProfile } = {}) {
|
|
1068
1147
|
invariant3(!this._identity, "Identity already exists.", {
|
|
1069
|
-
F:
|
|
1148
|
+
F: __dxlog_file6,
|
|
1070
1149
|
L: 128,
|
|
1071
1150
|
S: this,
|
|
1072
1151
|
A: [
|
|
@@ -1074,8 +1153,8 @@ var IdentityManager = class {
|
|
|
1074
1153
|
"'Identity already exists.'"
|
|
1075
1154
|
]
|
|
1076
1155
|
});
|
|
1077
|
-
|
|
1078
|
-
F:
|
|
1156
|
+
log5("creating identity...", void 0, {
|
|
1157
|
+
F: __dxlog_file6,
|
|
1079
1158
|
L: 129,
|
|
1080
1159
|
S: this,
|
|
1081
1160
|
C: (f, a) => f(...a)
|
|
@@ -1096,7 +1175,7 @@ var IdentityManager = class {
|
|
|
1096
1175
|
{
|
|
1097
1176
|
const generator = new CredentialGenerator(this._keyring, identityRecord.identityKey, identityRecord.deviceKey);
|
|
1098
1177
|
invariant3(identityRecord.haloSpace.genesisFeedKey, "Genesis feed key is required.", {
|
|
1099
|
-
F:
|
|
1178
|
+
F: __dxlog_file6,
|
|
1100
1179
|
L: 148,
|
|
1101
1180
|
S: this,
|
|
1102
1181
|
A: [
|
|
@@ -1105,7 +1184,7 @@ var IdentityManager = class {
|
|
|
1105
1184
|
]
|
|
1106
1185
|
});
|
|
1107
1186
|
invariant3(identityRecord.haloSpace.dataFeedKey, "Data feed key is required.", {
|
|
1108
|
-
F:
|
|
1187
|
+
F: __dxlog_file6,
|
|
1109
1188
|
L: 149,
|
|
1110
1189
|
S: this,
|
|
1111
1190
|
A: [
|
|
@@ -1140,22 +1219,22 @@ var IdentityManager = class {
|
|
|
1140
1219
|
await this._metadataStore.setIdentityRecord(identityRecord);
|
|
1141
1220
|
this._identity = identity;
|
|
1142
1221
|
await this._identity.ready();
|
|
1143
|
-
|
|
1222
|
+
log5.trace("dxos.halo.identity", {
|
|
1144
1223
|
identityKey: identityRecord.identityKey,
|
|
1145
1224
|
displayName: this._identity.profileDocument?.displayName
|
|
1146
1225
|
}, {
|
|
1147
|
-
F:
|
|
1226
|
+
F: __dxlog_file6,
|
|
1148
1227
|
L: 191,
|
|
1149
1228
|
S: this,
|
|
1150
1229
|
C: (f, a) => f(...a)
|
|
1151
1230
|
});
|
|
1152
1231
|
this.stateUpdate.emit();
|
|
1153
|
-
|
|
1232
|
+
log5("created identity", {
|
|
1154
1233
|
identityKey: identity.identityKey,
|
|
1155
1234
|
deviceKey: identity.deviceKey,
|
|
1156
1235
|
profile: identity.profileDocument
|
|
1157
1236
|
}, {
|
|
1158
|
-
F:
|
|
1237
|
+
F: __dxlog_file6,
|
|
1159
1238
|
L: 197,
|
|
1160
1239
|
S: this,
|
|
1161
1240
|
C: (f, a) => f(...a)
|
|
@@ -1189,16 +1268,16 @@ var IdentityManager = class {
|
|
|
1189
1268
|
* Accept an existing identity. Expects its device key to be authorized (now or later).
|
|
1190
1269
|
*/
|
|
1191
1270
|
async acceptIdentity(params) {
|
|
1192
|
-
|
|
1271
|
+
log5("accepting identity", {
|
|
1193
1272
|
params
|
|
1194
1273
|
}, {
|
|
1195
|
-
F:
|
|
1274
|
+
F: __dxlog_file6,
|
|
1196
1275
|
L: 235,
|
|
1197
1276
|
S: this,
|
|
1198
1277
|
C: (f, a) => f(...a)
|
|
1199
1278
|
});
|
|
1200
1279
|
invariant3(!this._identity, "Identity already exists.", {
|
|
1201
|
-
F:
|
|
1280
|
+
F: __dxlog_file6,
|
|
1202
1281
|
L: 236,
|
|
1203
1282
|
S: this,
|
|
1204
1283
|
A: [
|
|
@@ -1222,11 +1301,11 @@ var IdentityManager = class {
|
|
|
1222
1301
|
this._identity = identity;
|
|
1223
1302
|
await this._metadataStore.setIdentityRecord(identityRecord);
|
|
1224
1303
|
await this._identity.ready();
|
|
1225
|
-
|
|
1304
|
+
log5.trace("dxos.halo.identity", {
|
|
1226
1305
|
identityKey: identityRecord.identityKey,
|
|
1227
1306
|
displayName: this._identity.profileDocument?.displayName
|
|
1228
1307
|
}, {
|
|
1229
|
-
F:
|
|
1308
|
+
F: __dxlog_file6,
|
|
1230
1309
|
L: 255,
|
|
1231
1310
|
S: this,
|
|
1232
1311
|
C: (f, a) => f(...a)
|
|
@@ -1236,11 +1315,11 @@ var IdentityManager = class {
|
|
|
1236
1315
|
...params.deviceProfile
|
|
1237
1316
|
});
|
|
1238
1317
|
this.stateUpdate.emit();
|
|
1239
|
-
|
|
1318
|
+
log5("accepted identity", {
|
|
1240
1319
|
identityKey: identity.identityKey,
|
|
1241
1320
|
deviceKey: identity.deviceKey
|
|
1242
1321
|
}, {
|
|
1243
|
-
F:
|
|
1322
|
+
F: __dxlog_file6,
|
|
1244
1323
|
L: 265,
|
|
1245
1324
|
S: this,
|
|
1246
1325
|
C: (f, a) => f(...a)
|
|
@@ -1252,7 +1331,7 @@ var IdentityManager = class {
|
|
|
1252
1331
|
*/
|
|
1253
1332
|
async updateProfile(profile) {
|
|
1254
1333
|
invariant3(this._identity, "Identity not initialized.", {
|
|
1255
|
-
F:
|
|
1334
|
+
F: __dxlog_file6,
|
|
1256
1335
|
L: 273,
|
|
1257
1336
|
S: this,
|
|
1258
1337
|
A: [
|
|
@@ -1272,7 +1351,7 @@ var IdentityManager = class {
|
|
|
1272
1351
|
credential
|
|
1273
1352
|
}
|
|
1274
1353
|
});
|
|
1275
|
-
await this._identity.controlPipeline.state.waitUntilTimeframe(new
|
|
1354
|
+
await this._identity.controlPipeline.state.waitUntilTimeframe(new Timeframe2([
|
|
1276
1355
|
[
|
|
1277
1356
|
receipt.feedKey,
|
|
1278
1357
|
receipt.seq
|
|
@@ -1283,7 +1362,7 @@ var IdentityManager = class {
|
|
|
1283
1362
|
}
|
|
1284
1363
|
async updateDeviceProfile(profile) {
|
|
1285
1364
|
invariant3(this._identity, "Identity not initialized.", {
|
|
1286
|
-
F:
|
|
1365
|
+
F: __dxlog_file6,
|
|
1287
1366
|
L: 290,
|
|
1288
1367
|
S: this,
|
|
1289
1368
|
A: [
|
|
@@ -1303,7 +1382,7 @@ var IdentityManager = class {
|
|
|
1303
1382
|
credential
|
|
1304
1383
|
}
|
|
1305
1384
|
});
|
|
1306
|
-
await this._identity.controlPipeline.state.waitUntilTimeframe(new
|
|
1385
|
+
await this._identity.controlPipeline.state.waitUntilTimeframe(new Timeframe2([
|
|
1307
1386
|
[
|
|
1308
1387
|
receipt.feedKey,
|
|
1309
1388
|
receipt.seq
|
|
@@ -1319,7 +1398,7 @@ var IdentityManager = class {
|
|
|
1319
1398
|
}
|
|
1320
1399
|
async _constructIdentity(identityRecord) {
|
|
1321
1400
|
invariant3(!this._identity, void 0, {
|
|
1322
|
-
F:
|
|
1401
|
+
F: __dxlog_file6,
|
|
1323
1402
|
L: 316,
|
|
1324
1403
|
S: this,
|
|
1325
1404
|
A: [
|
|
@@ -1327,10 +1406,10 @@ var IdentityManager = class {
|
|
|
1327
1406
|
""
|
|
1328
1407
|
]
|
|
1329
1408
|
});
|
|
1330
|
-
|
|
1409
|
+
log5("constructing identity", {
|
|
1331
1410
|
identityRecord
|
|
1332
1411
|
}, {
|
|
1333
|
-
F:
|
|
1412
|
+
F: __dxlog_file6,
|
|
1334
1413
|
L: 317,
|
|
1335
1414
|
S: this,
|
|
1336
1415
|
C: (f, a) => f(...a)
|
|
@@ -1345,7 +1424,7 @@ var IdentityManager = class {
|
|
|
1345
1424
|
gossip
|
|
1346
1425
|
});
|
|
1347
1426
|
invariant3(identityRecord.haloSpace.controlFeedKey, void 0, {
|
|
1348
|
-
F:
|
|
1427
|
+
F: __dxlog_file6,
|
|
1349
1428
|
L: 330,
|
|
1350
1429
|
S: this,
|
|
1351
1430
|
A: [
|
|
@@ -1357,7 +1436,7 @@ var IdentityManager = class {
|
|
|
1357
1436
|
writable: true
|
|
1358
1437
|
});
|
|
1359
1438
|
invariant3(identityRecord.haloSpace.dataFeedKey, void 0, {
|
|
1360
|
-
F:
|
|
1439
|
+
F: __dxlog_file6,
|
|
1361
1440
|
L: 334,
|
|
1362
1441
|
S: this,
|
|
1363
1442
|
A: [
|
|
@@ -1388,10 +1467,10 @@ var IdentityManager = class {
|
|
|
1388
1467
|
identityKey: identityRecord.identityKey,
|
|
1389
1468
|
deviceKey: identityRecord.deviceKey
|
|
1390
1469
|
});
|
|
1391
|
-
|
|
1470
|
+
log5("done", {
|
|
1392
1471
|
identityKey: identityRecord.identityKey
|
|
1393
1472
|
}, {
|
|
1394
|
-
F:
|
|
1473
|
+
F: __dxlog_file6,
|
|
1395
1474
|
L: 360,
|
|
1396
1475
|
S: this,
|
|
1397
1476
|
C: (f, a) => f(...a)
|
|
@@ -1415,8 +1494,8 @@ var IdentityManager = class {
|
|
|
1415
1494
|
}));
|
|
1416
1495
|
},
|
|
1417
1496
|
onAuthFailure: () => {
|
|
1418
|
-
|
|
1419
|
-
F:
|
|
1497
|
+
log5.warn("auth failure", void 0, {
|
|
1498
|
+
F: __dxlog_file6,
|
|
1420
1499
|
L: 385,
|
|
1421
1500
|
S: this,
|
|
1422
1501
|
C: (f, a) => f(...a)
|
|
@@ -1441,24 +1520,50 @@ IdentityManager = _ts_decorate3([
|
|
|
1441
1520
|
|
|
1442
1521
|
// packages/sdk/client-services/src/packlets/identity/identity-service.ts
|
|
1443
1522
|
import { Stream as Stream8 } from "@dxos/codec-protobuf";
|
|
1523
|
+
import { Resource } from "@dxos/context";
|
|
1444
1524
|
import { signPresentation } from "@dxos/credentials";
|
|
1445
1525
|
import { todo } from "@dxos/debug";
|
|
1446
1526
|
import { invariant as invariant4 } from "@dxos/invariant";
|
|
1447
|
-
|
|
1448
|
-
var
|
|
1449
|
-
|
|
1450
|
-
|
|
1527
|
+
import { SpaceState } from "@dxos/protocols/proto/dxos/client/services";
|
|
1528
|
+
var __dxlog_file7 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/identity-service.ts";
|
|
1529
|
+
var IdentityServiceImpl = class extends Resource {
|
|
1530
|
+
constructor(_identityManager, _keyring, _dataSpaceManagerProvider, _createIdentity, _onProfileUpdate) {
|
|
1531
|
+
super();
|
|
1451
1532
|
this._identityManager = _identityManager;
|
|
1452
1533
|
this._keyring = _keyring;
|
|
1534
|
+
this._dataSpaceManagerProvider = _dataSpaceManagerProvider;
|
|
1535
|
+
this._createIdentity = _createIdentity;
|
|
1453
1536
|
this._onProfileUpdate = _onProfileUpdate;
|
|
1454
1537
|
}
|
|
1538
|
+
async _open() {
|
|
1539
|
+
const identity = this._identityManager.identity;
|
|
1540
|
+
if (identity && !identity.defaultSpaceId) {
|
|
1541
|
+
await this._fixIdentityWithoutDefaultSpace(identity);
|
|
1542
|
+
}
|
|
1543
|
+
}
|
|
1455
1544
|
async createIdentity(request) {
|
|
1456
1545
|
await this._createIdentity({
|
|
1457
1546
|
displayName: request.profile?.displayName,
|
|
1458
1547
|
deviceProfile: request.deviceProfile
|
|
1459
1548
|
});
|
|
1549
|
+
const dataSpaceManager = this._dataSpaceManagerProvider();
|
|
1550
|
+
await this._createDefaultSpace(dataSpaceManager);
|
|
1460
1551
|
return this._getIdentity();
|
|
1461
1552
|
}
|
|
1553
|
+
async _createDefaultSpace(dataSpaceManager) {
|
|
1554
|
+
const space = await dataSpaceManager.createDefaultSpace();
|
|
1555
|
+
const identity = this._identityManager.identity;
|
|
1556
|
+
invariant4(identity, void 0, {
|
|
1557
|
+
F: __dxlog_file7,
|
|
1558
|
+
L: 54,
|
|
1559
|
+
S: this,
|
|
1560
|
+
A: [
|
|
1561
|
+
"identity",
|
|
1562
|
+
""
|
|
1563
|
+
]
|
|
1564
|
+
});
|
|
1565
|
+
await identity.updateDefaultSpace(space.id);
|
|
1566
|
+
}
|
|
1462
1567
|
async recoverIdentity(request) {
|
|
1463
1568
|
return todo();
|
|
1464
1569
|
}
|
|
@@ -1483,8 +1588,8 @@ var IdentityServiceImpl = class {
|
|
|
1483
1588
|
}
|
|
1484
1589
|
async updateProfile(profile) {
|
|
1485
1590
|
invariant4(this._identityManager.identity, "Identity not initialized.", {
|
|
1486
|
-
F:
|
|
1487
|
-
L:
|
|
1591
|
+
F: __dxlog_file7,
|
|
1592
|
+
L: 84,
|
|
1488
1593
|
S: this,
|
|
1489
1594
|
A: [
|
|
1490
1595
|
"this._identityManager.identity",
|
|
@@ -1497,8 +1602,8 @@ var IdentityServiceImpl = class {
|
|
|
1497
1602
|
}
|
|
1498
1603
|
async signPresentation({ presentation, nonce }) {
|
|
1499
1604
|
invariant4(this._identityManager.identity, "Identity not initialized.", {
|
|
1500
|
-
F:
|
|
1501
|
-
L:
|
|
1605
|
+
F: __dxlog_file7,
|
|
1606
|
+
L: 91,
|
|
1502
1607
|
S: this,
|
|
1503
1608
|
A: [
|
|
1504
1609
|
"this._identityManager.identity",
|
|
@@ -1513,13 +1618,31 @@ var IdentityServiceImpl = class {
|
|
|
1513
1618
|
nonce
|
|
1514
1619
|
});
|
|
1515
1620
|
}
|
|
1621
|
+
async _fixIdentityWithoutDefaultSpace(identity) {
|
|
1622
|
+
let hasDefaultSpace = false;
|
|
1623
|
+
const dataSpaceManager = this._dataSpaceManagerProvider();
|
|
1624
|
+
for (const space of dataSpaceManager.spaces.values()) {
|
|
1625
|
+
if (space.state === SpaceState.CLOSED) {
|
|
1626
|
+
await space.open();
|
|
1627
|
+
await space.initializeDataPipeline();
|
|
1628
|
+
}
|
|
1629
|
+
if (await dataSpaceManager.isDefaultSpace(space)) {
|
|
1630
|
+
await identity.updateDefaultSpace(space.id);
|
|
1631
|
+
hasDefaultSpace = true;
|
|
1632
|
+
break;
|
|
1633
|
+
}
|
|
1634
|
+
}
|
|
1635
|
+
if (!hasDefaultSpace) {
|
|
1636
|
+
await this._createDefaultSpace(dataSpaceManager);
|
|
1637
|
+
}
|
|
1638
|
+
}
|
|
1516
1639
|
};
|
|
1517
1640
|
|
|
1518
1641
|
// packages/sdk/client-services/src/packlets/invitations/device-invitation-protocol.ts
|
|
1519
1642
|
import { invariant as invariant5 } from "@dxos/invariant";
|
|
1520
1643
|
import { AlreadyJoinedError } from "@dxos/protocols";
|
|
1521
1644
|
import { Invitation } from "@dxos/protocols/proto/dxos/client/services";
|
|
1522
|
-
var
|
|
1645
|
+
var __dxlog_file8 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/device-invitation-protocol.ts";
|
|
1523
1646
|
var DeviceInvitationProtocol = class {
|
|
1524
1647
|
constructor(_keyring, _getIdentity, _acceptIdentity) {
|
|
1525
1648
|
this._keyring = _keyring;
|
|
@@ -1545,7 +1668,7 @@ var DeviceInvitationProtocol = class {
|
|
|
1545
1668
|
}
|
|
1546
1669
|
async admit(_, request) {
|
|
1547
1670
|
invariant5(request.device, void 0, {
|
|
1548
|
-
F:
|
|
1671
|
+
F: __dxlog_file8,
|
|
1549
1672
|
L: 50,
|
|
1550
1673
|
S: this,
|
|
1551
1674
|
A: [
|
|
@@ -1591,7 +1714,7 @@ var DeviceInvitationProtocol = class {
|
|
|
1591
1714
|
}
|
|
1592
1715
|
async accept(response, request) {
|
|
1593
1716
|
invariant5(response.device, void 0, {
|
|
1594
|
-
F:
|
|
1717
|
+
F: __dxlog_file8,
|
|
1595
1718
|
L: 95,
|
|
1596
1719
|
S: this,
|
|
1597
1720
|
A: [
|
|
@@ -1601,7 +1724,7 @@ var DeviceInvitationProtocol = class {
|
|
|
1601
1724
|
});
|
|
1602
1725
|
const { identityKey, haloSpaceKey, genesisFeedKey, controlTimeframe } = response.device;
|
|
1603
1726
|
invariant5(request.device, void 0, {
|
|
1604
|
-
F:
|
|
1727
|
+
F: __dxlog_file8,
|
|
1605
1728
|
L: 98,
|
|
1606
1729
|
S: this,
|
|
1607
1730
|
A: [
|
|
@@ -1633,7 +1756,7 @@ import { ContextDisposedError as ContextDisposedError2 } from "@dxos/context";
|
|
|
1633
1756
|
import { createKeyPair, sign } from "@dxos/crypto";
|
|
1634
1757
|
import { invariant as invariant9 } from "@dxos/invariant";
|
|
1635
1758
|
import { PublicKey as PublicKey7 } from "@dxos/keys";
|
|
1636
|
-
import { log as
|
|
1759
|
+
import { log as log9 } from "@dxos/log";
|
|
1637
1760
|
import { createTeleportProtocolFactory } from "@dxos/network-manager";
|
|
1638
1761
|
import { InvalidInvitationExtensionRoleError as InvalidInvitationExtensionRoleError3, trace as trace5 } from "@dxos/protocols";
|
|
1639
1762
|
import { Invitation as Invitation4 } from "@dxos/protocols/proto/dxos/client/services";
|
|
@@ -1645,7 +1768,7 @@ import { ComplexSet as ComplexSet3 } from "@dxos/util";
|
|
|
1645
1768
|
import { Trigger as Trigger3 } from "@dxos/async";
|
|
1646
1769
|
import { cancelWithContext as cancelWithContext2, Context as Context4 } from "@dxos/context";
|
|
1647
1770
|
import { invariant as invariant6 } from "@dxos/invariant";
|
|
1648
|
-
import { log as
|
|
1771
|
+
import { log as log6 } from "@dxos/log";
|
|
1649
1772
|
import { InvalidInvitationExtensionRoleError, schema as schema2 } from "@dxos/protocols";
|
|
1650
1773
|
import { Options } from "@dxos/protocols/proto/dxos/halo/invitations";
|
|
1651
1774
|
import { RpcExtension } from "@dxos/teleport";
|
|
@@ -1670,7 +1793,7 @@ var tryAcquireBeforeContextDisposed = async (ctx, mutex) => {
|
|
|
1670
1793
|
};
|
|
1671
1794
|
|
|
1672
1795
|
// packages/sdk/client-services/src/packlets/invitations/invitation-guest-extenstion.ts
|
|
1673
|
-
var
|
|
1796
|
+
var __dxlog_file9 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitation-guest-extenstion.ts";
|
|
1674
1797
|
var OPTIONS_TIMEOUT = 1e4;
|
|
1675
1798
|
var InvitationGuestExtension = class extends RpcExtension {
|
|
1676
1799
|
constructor(_invitationFlowMutex, _callbacks) {
|
|
@@ -1696,7 +1819,7 @@ var InvitationGuestExtension = class extends RpcExtension {
|
|
|
1696
1819
|
InvitationHostService: {
|
|
1697
1820
|
options: async (options) => {
|
|
1698
1821
|
invariant6(!this._remoteOptions, "Remote options already set.", {
|
|
1699
|
-
F:
|
|
1822
|
+
F: __dxlog_file9,
|
|
1700
1823
|
L: 63,
|
|
1701
1824
|
S: this,
|
|
1702
1825
|
A: [
|
|
@@ -1722,15 +1845,15 @@ var InvitationGuestExtension = class extends RpcExtension {
|
|
|
1722
1845
|
async onOpen(context) {
|
|
1723
1846
|
await super.onOpen(context);
|
|
1724
1847
|
try {
|
|
1725
|
-
|
|
1726
|
-
F:
|
|
1848
|
+
log6("guest acquire lock", void 0, {
|
|
1849
|
+
F: __dxlog_file9,
|
|
1727
1850
|
L: 84,
|
|
1728
1851
|
S: this,
|
|
1729
1852
|
C: (f, a) => f(...a)
|
|
1730
1853
|
});
|
|
1731
1854
|
this._invitationFlowLock = await tryAcquireBeforeContextDisposed(this._ctx, this._invitationFlowMutex);
|
|
1732
|
-
|
|
1733
|
-
F:
|
|
1855
|
+
log6("guest lock acquired", void 0, {
|
|
1856
|
+
F: __dxlog_file9,
|
|
1734
1857
|
L: 86,
|
|
1735
1858
|
S: this,
|
|
1736
1859
|
C: (f, a) => f(...a)
|
|
@@ -1738,8 +1861,8 @@ var InvitationGuestExtension = class extends RpcExtension {
|
|
|
1738
1861
|
await cancelWithContext2(this._ctx, this.rpc.InvitationHostService.options({
|
|
1739
1862
|
role: Options.Role.GUEST
|
|
1740
1863
|
}));
|
|
1741
|
-
|
|
1742
|
-
F:
|
|
1864
|
+
log6("options sent", void 0, {
|
|
1865
|
+
F: __dxlog_file9,
|
|
1743
1866
|
L: 88,
|
|
1744
1867
|
S: this,
|
|
1745
1868
|
C: (f, a) => f(...a)
|
|
@@ -1747,8 +1870,8 @@ var InvitationGuestExtension = class extends RpcExtension {
|
|
|
1747
1870
|
await cancelWithContext2(this._ctx, this._remoteOptionsTrigger.wait({
|
|
1748
1871
|
timeout: OPTIONS_TIMEOUT
|
|
1749
1872
|
}));
|
|
1750
|
-
|
|
1751
|
-
F:
|
|
1873
|
+
log6("options received", void 0, {
|
|
1874
|
+
F: __dxlog_file9,
|
|
1752
1875
|
L: 90,
|
|
1753
1876
|
S: this,
|
|
1754
1877
|
C: (f, a) => f(...a)
|
|
@@ -1781,8 +1904,8 @@ var InvitationGuestExtension = class extends RpcExtension {
|
|
|
1781
1904
|
if (this._invitationFlowLock != null) {
|
|
1782
1905
|
this._invitationFlowLock.release();
|
|
1783
1906
|
this._invitationFlowLock = null;
|
|
1784
|
-
|
|
1785
|
-
F:
|
|
1907
|
+
log6("invitation flow lock released", void 0, {
|
|
1908
|
+
F: __dxlog_file9,
|
|
1786
1909
|
L: 123,
|
|
1787
1910
|
S: this,
|
|
1788
1911
|
C: (f, a) => f(...a)
|
|
@@ -1797,12 +1920,12 @@ import { cancelWithContext as cancelWithContext3, Context as Context5 } from "@d
|
|
|
1797
1920
|
import { randomBytes, verify } from "@dxos/crypto";
|
|
1798
1921
|
import { invariant as invariant7, InvariantViolation } from "@dxos/invariant";
|
|
1799
1922
|
import { PublicKey as PublicKey5 } from "@dxos/keys";
|
|
1800
|
-
import { log as
|
|
1923
|
+
import { log as log7 } from "@dxos/log";
|
|
1801
1924
|
import { InvalidInvitationExtensionRoleError as InvalidInvitationExtensionRoleError2, schema as schema3, trace as trace4 } from "@dxos/protocols";
|
|
1802
1925
|
import { Invitation as Invitation3 } from "@dxos/protocols/proto/dxos/client/services";
|
|
1803
1926
|
import { AuthenticationResponse, Options as Options2 } from "@dxos/protocols/proto/dxos/halo/invitations";
|
|
1804
1927
|
import { RpcExtension as RpcExtension2 } from "@dxos/teleport";
|
|
1805
|
-
var
|
|
1928
|
+
var __dxlog_file10 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitation-host-extension.ts";
|
|
1806
1929
|
var OPTIONS_TIMEOUT2 = 1e4;
|
|
1807
1930
|
var MAX_OTP_ATTEMPTS = 3;
|
|
1808
1931
|
var InvitationHostExtension = class extends RpcExtension2 {
|
|
@@ -1836,7 +1959,7 @@ var InvitationHostExtension = class extends RpcExtension2 {
|
|
|
1836
1959
|
InvitationHostService: {
|
|
1837
1960
|
options: async (options) => {
|
|
1838
1961
|
invariant7(!this._remoteOptions, "Remote options already set.", {
|
|
1839
|
-
F:
|
|
1962
|
+
F: __dxlog_file10,
|
|
1840
1963
|
L: 101,
|
|
1841
1964
|
S: this,
|
|
1842
1965
|
A: [
|
|
@@ -1850,10 +1973,10 @@ var InvitationHostExtension = class extends RpcExtension2 {
|
|
|
1850
1973
|
introduce: async (request) => {
|
|
1851
1974
|
const { profile, invitationId } = request;
|
|
1852
1975
|
const traceId = PublicKey5.random().toHex();
|
|
1853
|
-
|
|
1976
|
+
log7.trace("dxos.sdk.invitation-handler.host.introduce", trace4.begin({
|
|
1854
1977
|
id: traceId
|
|
1855
1978
|
}), {
|
|
1856
|
-
F:
|
|
1979
|
+
F: __dxlog_file10,
|
|
1857
1980
|
L: 110,
|
|
1858
1981
|
S: this,
|
|
1859
1982
|
C: (f, a) => f(...a)
|
|
@@ -1861,11 +1984,11 @@ var InvitationHostExtension = class extends RpcExtension2 {
|
|
|
1861
1984
|
const invitation = this._requireActiveInvitation();
|
|
1862
1985
|
this._assertInvitationState(Invitation3.State.CONNECTED);
|
|
1863
1986
|
if (invitationId !== invitation?.invitationId) {
|
|
1864
|
-
|
|
1987
|
+
log7.warn("incorrect invitationId", {
|
|
1865
1988
|
expected: invitation.invitationId,
|
|
1866
1989
|
actual: invitationId
|
|
1867
1990
|
}, {
|
|
1868
|
-
F:
|
|
1991
|
+
F: __dxlog_file10,
|
|
1869
1992
|
L: 116,
|
|
1870
1993
|
S: this,
|
|
1871
1994
|
C: (f, a) => f(...a)
|
|
@@ -1876,10 +1999,10 @@ var InvitationHostExtension = class extends RpcExtension2 {
|
|
|
1876
1999
|
authMethod: Invitation3.AuthMethod.NONE
|
|
1877
2000
|
};
|
|
1878
2001
|
}
|
|
1879
|
-
|
|
2002
|
+
log7("guest introduced themselves", {
|
|
1880
2003
|
guestProfile: profile
|
|
1881
2004
|
}, {
|
|
1882
|
-
F:
|
|
2005
|
+
F: __dxlog_file10,
|
|
1883
2006
|
L: 125,
|
|
1884
2007
|
S: this,
|
|
1885
2008
|
C: (f, a) => f(...a)
|
|
@@ -1887,10 +2010,10 @@ var InvitationHostExtension = class extends RpcExtension2 {
|
|
|
1887
2010
|
this.guestProfile = profile;
|
|
1888
2011
|
this._callbacks.onStateUpdate(Invitation3.State.READY_FOR_AUTHENTICATION);
|
|
1889
2012
|
this._challenge = invitation.authMethod === Invitation3.AuthMethod.KNOWN_PUBLIC_KEY ? randomBytes(32) : void 0;
|
|
1890
|
-
|
|
2013
|
+
log7.trace("dxos.sdk.invitation-handler.host.introduce", trace4.end({
|
|
1891
2014
|
id: traceId
|
|
1892
2015
|
}), {
|
|
1893
|
-
F:
|
|
2016
|
+
F: __dxlog_file10,
|
|
1894
2017
|
L: 132,
|
|
1895
2018
|
S: this,
|
|
1896
2019
|
C: (f, a) => f(...a)
|
|
@@ -1902,19 +2025,19 @@ var InvitationHostExtension = class extends RpcExtension2 {
|
|
|
1902
2025
|
},
|
|
1903
2026
|
authenticate: async ({ authCode: code, signedChallenge }) => {
|
|
1904
2027
|
const traceId = PublicKey5.random().toHex();
|
|
1905
|
-
|
|
2028
|
+
log7.trace("dxos.sdk.invitation-handler.host.authenticate", trace4.begin({
|
|
1906
2029
|
id: traceId
|
|
1907
2030
|
}), {
|
|
1908
|
-
F:
|
|
2031
|
+
F: __dxlog_file10,
|
|
1909
2032
|
L: 141,
|
|
1910
2033
|
S: this,
|
|
1911
2034
|
C: (f, a) => f(...a)
|
|
1912
2035
|
});
|
|
1913
2036
|
const invitation = this._requireActiveInvitation();
|
|
1914
|
-
|
|
2037
|
+
log7("received authentication request", {
|
|
1915
2038
|
authCode: code
|
|
1916
2039
|
}, {
|
|
1917
|
-
F:
|
|
2040
|
+
F: __dxlog_file10,
|
|
1918
2041
|
L: 144,
|
|
1919
2042
|
S: this,
|
|
1920
2043
|
C: (f, a) => f(...a)
|
|
@@ -1927,8 +2050,8 @@ var InvitationHostExtension = class extends RpcExtension2 {
|
|
|
1927
2050
|
this._callbacks.onStateUpdate(Invitation3.State.AUTHENTICATING);
|
|
1928
2051
|
switch (invitation.authMethod) {
|
|
1929
2052
|
case Invitation3.AuthMethod.NONE: {
|
|
1930
|
-
|
|
1931
|
-
F:
|
|
2053
|
+
log7("authentication not required", void 0, {
|
|
2054
|
+
F: __dxlog_file10,
|
|
1932
2055
|
L: 152,
|
|
1933
2056
|
S: this,
|
|
1934
2057
|
C: (f, a) => f(...a)
|
|
@@ -1963,10 +2086,10 @@ var InvitationHostExtension = class extends RpcExtension2 {
|
|
|
1963
2086
|
break;
|
|
1964
2087
|
}
|
|
1965
2088
|
default: {
|
|
1966
|
-
|
|
2089
|
+
log7.error("invalid authentication method", {
|
|
1967
2090
|
authMethod: invitation.authMethod
|
|
1968
2091
|
}, {
|
|
1969
|
-
F:
|
|
2092
|
+
F: __dxlog_file10,
|
|
1970
2093
|
L: 190,
|
|
1971
2094
|
S: this,
|
|
1972
2095
|
C: (f, a) => f(...a)
|
|
@@ -1985,13 +2108,13 @@ var InvitationHostExtension = class extends RpcExtension2 {
|
|
|
1985
2108
|
status
|
|
1986
2109
|
};
|
|
1987
2110
|
}
|
|
1988
|
-
|
|
2111
|
+
log7.trace("dxos.sdk.invitation-handler.host.authenticate", trace4.end({
|
|
1989
2112
|
id: traceId,
|
|
1990
2113
|
data: {
|
|
1991
2114
|
status
|
|
1992
2115
|
}
|
|
1993
2116
|
}), {
|
|
1994
|
-
F:
|
|
2117
|
+
F: __dxlog_file10,
|
|
1995
2118
|
L: 202,
|
|
1996
2119
|
S: this,
|
|
1997
2120
|
C: (f, a) => f(...a)
|
|
@@ -2002,10 +2125,10 @@ var InvitationHostExtension = class extends RpcExtension2 {
|
|
|
2002
2125
|
},
|
|
2003
2126
|
admit: async (request) => {
|
|
2004
2127
|
const traceId = PublicKey5.random().toHex();
|
|
2005
|
-
|
|
2128
|
+
log7.trace("dxos.sdk.invitation-handler.host.admit", trace4.begin({
|
|
2006
2129
|
id: traceId
|
|
2007
2130
|
}), {
|
|
2008
|
-
F:
|
|
2131
|
+
F: __dxlog_file10,
|
|
2009
2132
|
L: 208,
|
|
2010
2133
|
S: this,
|
|
2011
2134
|
C: (f, a) => f(...a)
|
|
@@ -2019,10 +2142,10 @@ var InvitationHostExtension = class extends RpcExtension2 {
|
|
|
2019
2142
|
}
|
|
2020
2143
|
}
|
|
2021
2144
|
const response = await this._callbacks.admit(request);
|
|
2022
|
-
|
|
2145
|
+
log7.trace("dxos.sdk.invitation-handler.host.admit", trace4.end({
|
|
2023
2146
|
id: traceId
|
|
2024
2147
|
}), {
|
|
2025
|
-
F:
|
|
2148
|
+
F: __dxlog_file10,
|
|
2026
2149
|
L: 222,
|
|
2027
2150
|
S: this,
|
|
2028
2151
|
C: (f, a) => f(...a)
|
|
@@ -2039,15 +2162,15 @@ var InvitationHostExtension = class extends RpcExtension2 {
|
|
|
2039
2162
|
async onOpen(context) {
|
|
2040
2163
|
await super.onOpen(context);
|
|
2041
2164
|
try {
|
|
2042
|
-
|
|
2043
|
-
F:
|
|
2165
|
+
log7("host acquire lock", void 0, {
|
|
2166
|
+
F: __dxlog_file10,
|
|
2044
2167
|
L: 237,
|
|
2045
2168
|
S: this,
|
|
2046
2169
|
C: (f, a) => f(...a)
|
|
2047
2170
|
});
|
|
2048
2171
|
this._invitationFlowLock = await tryAcquireBeforeContextDisposed(this._ctx, this._invitationFlowMutex);
|
|
2049
|
-
|
|
2050
|
-
F:
|
|
2172
|
+
log7("host lock acquired", void 0, {
|
|
2173
|
+
F: __dxlog_file10,
|
|
2051
2174
|
L: 239,
|
|
2052
2175
|
S: this,
|
|
2053
2176
|
C: (f, a) => f(...a)
|
|
@@ -2057,8 +2180,8 @@ var InvitationHostExtension = class extends RpcExtension2 {
|
|
|
2057
2180
|
await this.rpc.InvitationHostService.options({
|
|
2058
2181
|
role: Options2.Role.HOST
|
|
2059
2182
|
});
|
|
2060
|
-
|
|
2061
|
-
F:
|
|
2183
|
+
log7("options sent", void 0, {
|
|
2184
|
+
F: __dxlog_file10,
|
|
2062
2185
|
L: 243,
|
|
2063
2186
|
S: this,
|
|
2064
2187
|
C: (f, a) => f(...a)
|
|
@@ -2066,8 +2189,8 @@ var InvitationHostExtension = class extends RpcExtension2 {
|
|
|
2066
2189
|
await cancelWithContext3(this._ctx, this._remoteOptionsTrigger.wait({
|
|
2067
2190
|
timeout: OPTIONS_TIMEOUT2
|
|
2068
2191
|
}));
|
|
2069
|
-
|
|
2070
|
-
F:
|
|
2192
|
+
log7("options received", void 0, {
|
|
2193
|
+
F: __dxlog_file10,
|
|
2071
2194
|
L: 245,
|
|
2072
2195
|
S: this,
|
|
2073
2196
|
C: (f, a) => f(...a)
|
|
@@ -2120,8 +2243,8 @@ var InvitationHostExtension = class extends RpcExtension2 {
|
|
|
2120
2243
|
if (this._invitationFlowLock != null) {
|
|
2121
2244
|
this._invitationFlowLock?.release();
|
|
2122
2245
|
this._invitationFlowLock = null;
|
|
2123
|
-
|
|
2124
|
-
F:
|
|
2246
|
+
log7("invitation flow lock released", void 0, {
|
|
2247
|
+
F: __dxlog_file10,
|
|
2125
2248
|
L: 300,
|
|
2126
2249
|
S: this,
|
|
2127
2250
|
C: (f, a) => f(...a)
|
|
@@ -2134,10 +2257,10 @@ var isAuthenticationRequired = (invitation) => invitation.authMethod !== Invitat
|
|
|
2134
2257
|
// packages/sdk/client-services/src/packlets/invitations/invitation-topology.ts
|
|
2135
2258
|
import { invariant as invariant8 } from "@dxos/invariant";
|
|
2136
2259
|
import { PublicKey as PublicKey6 } from "@dxos/keys";
|
|
2137
|
-
import { log as
|
|
2260
|
+
import { log as log8 } from "@dxos/log";
|
|
2138
2261
|
import { Options as Options3 } from "@dxos/protocols/proto/dxos/halo/invitations";
|
|
2139
2262
|
import { ComplexSet as ComplexSet2 } from "@dxos/util";
|
|
2140
|
-
var
|
|
2263
|
+
var __dxlog_file11 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitation-topology.ts";
|
|
2141
2264
|
var InvitationTopology = class {
|
|
2142
2265
|
constructor(_role) {
|
|
2143
2266
|
this._role = _role;
|
|
@@ -2145,7 +2268,7 @@ var InvitationTopology = class {
|
|
|
2145
2268
|
}
|
|
2146
2269
|
init(controller) {
|
|
2147
2270
|
invariant8(!this._controller, "Already initialized.", {
|
|
2148
|
-
F:
|
|
2271
|
+
F: __dxlog_file11,
|
|
2149
2272
|
L: 42,
|
|
2150
2273
|
S: this,
|
|
2151
2274
|
A: [
|
|
@@ -2157,7 +2280,7 @@ var InvitationTopology = class {
|
|
|
2157
2280
|
}
|
|
2158
2281
|
update() {
|
|
2159
2282
|
invariant8(this._controller, "Not initialized.", {
|
|
2160
|
-
F:
|
|
2283
|
+
F: __dxlog_file11,
|
|
2161
2284
|
L: 47,
|
|
2162
2285
|
S: this,
|
|
2163
2286
|
A: [
|
|
@@ -2176,11 +2299,11 @@ var InvitationTopology = class {
|
|
|
2176
2299
|
const firstUnknownPeer = candidates.find((peerId) => !this._seenPeers.has(peerId));
|
|
2177
2300
|
this._seenPeers = new ComplexSet2(PublicKey6.hash, allPeers.filter((peerId) => this._seenPeers.has(peerId)));
|
|
2178
2301
|
if (firstUnknownPeer != null) {
|
|
2179
|
-
|
|
2302
|
+
log8("invitation connect", {
|
|
2180
2303
|
ownPeerId,
|
|
2181
2304
|
remotePeerId: firstUnknownPeer
|
|
2182
2305
|
}, {
|
|
2183
|
-
F:
|
|
2306
|
+
F: __dxlog_file11,
|
|
2184
2307
|
L: 69,
|
|
2185
2308
|
S: this,
|
|
2186
2309
|
C: (f, a) => f(...a)
|
|
@@ -2191,7 +2314,7 @@ var InvitationTopology = class {
|
|
|
2191
2314
|
}
|
|
2192
2315
|
async onOffer(peer) {
|
|
2193
2316
|
invariant8(this._controller, "Not initialized.", {
|
|
2194
|
-
F:
|
|
2317
|
+
F: __dxlog_file11,
|
|
2195
2318
|
L: 76,
|
|
2196
2319
|
S: this,
|
|
2197
2320
|
A: [
|
|
@@ -2210,7 +2333,7 @@ var InvitationTopology = class {
|
|
|
2210
2333
|
};
|
|
2211
2334
|
|
|
2212
2335
|
// packages/sdk/client-services/src/packlets/invitations/invitations-handler.ts
|
|
2213
|
-
var
|
|
2336
|
+
var __dxlog_file12 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitations-handler.ts";
|
|
2214
2337
|
var MAX_DELEGATED_INVITATION_HOST_TRIES = 3;
|
|
2215
2338
|
var InvitationsHandler = class {
|
|
2216
2339
|
/**
|
|
@@ -2235,7 +2358,7 @@ var InvitationsHandler = class {
|
|
|
2235
2358
|
try {
|
|
2236
2359
|
const deviceKey = admissionRequest.device?.deviceKey ?? admissionRequest.space?.deviceKey;
|
|
2237
2360
|
invariant9(deviceKey, void 0, {
|
|
2238
|
-
F:
|
|
2361
|
+
F: __dxlog_file12,
|
|
2239
2362
|
L: 90,
|
|
2240
2363
|
S: this,
|
|
2241
2364
|
A: [
|
|
@@ -2261,18 +2384,18 @@ var InvitationsHandler = class {
|
|
|
2261
2384
|
scheduleTask3(connectionCtx, async () => {
|
|
2262
2385
|
const traceId = PublicKey7.random().toHex();
|
|
2263
2386
|
try {
|
|
2264
|
-
|
|
2387
|
+
log9.trace("dxos.sdk.invitations-handler.host.onOpen", trace5.begin({
|
|
2265
2388
|
id: traceId
|
|
2266
2389
|
}), {
|
|
2267
|
-
F:
|
|
2390
|
+
F: __dxlog_file12,
|
|
2268
2391
|
L: 115,
|
|
2269
2392
|
S: this,
|
|
2270
2393
|
C: (f, a) => f(...a)
|
|
2271
2394
|
});
|
|
2272
|
-
|
|
2395
|
+
log9("connected", {
|
|
2273
2396
|
...protocol.toJSON()
|
|
2274
2397
|
}, {
|
|
2275
|
-
F:
|
|
2398
|
+
F: __dxlog_file12,
|
|
2276
2399
|
L: 116,
|
|
2277
2400
|
S: this,
|
|
2278
2401
|
C: (f, a) => f(...a)
|
|
@@ -2280,20 +2403,20 @@ var InvitationsHandler = class {
|
|
|
2280
2403
|
const deviceKey = await extension.completedTrigger.wait({
|
|
2281
2404
|
timeout: invitation.timeout
|
|
2282
2405
|
});
|
|
2283
|
-
|
|
2406
|
+
log9("admitted guest", {
|
|
2284
2407
|
guest: deviceKey,
|
|
2285
2408
|
...protocol.toJSON()
|
|
2286
2409
|
}, {
|
|
2287
|
-
F:
|
|
2410
|
+
F: __dxlog_file12,
|
|
2288
2411
|
L: 118,
|
|
2289
2412
|
S: this,
|
|
2290
2413
|
C: (f, a) => f(...a)
|
|
2291
2414
|
});
|
|
2292
2415
|
guardedState.set(extension, Invitation4.State.SUCCESS);
|
|
2293
|
-
|
|
2416
|
+
log9.trace("dxos.sdk.invitations-handler.host.onOpen", trace5.end({
|
|
2294
2417
|
id: traceId
|
|
2295
2418
|
}), {
|
|
2296
|
-
F:
|
|
2419
|
+
F: __dxlog_file12,
|
|
2297
2420
|
L: 120,
|
|
2298
2421
|
S: this,
|
|
2299
2422
|
C: (f, a) => f(...a)
|
|
@@ -2305,10 +2428,10 @@ var InvitationsHandler = class {
|
|
|
2305
2428
|
} catch (err) {
|
|
2306
2429
|
if (err instanceof TimeoutError) {
|
|
2307
2430
|
if (guardedState.set(extension, Invitation4.State.TIMEOUT)) {
|
|
2308
|
-
|
|
2431
|
+
log9("timeout", {
|
|
2309
2432
|
...protocol.toJSON()
|
|
2310
2433
|
}, {
|
|
2311
|
-
F:
|
|
2434
|
+
F: __dxlog_file12,
|
|
2312
2435
|
L: 129,
|
|
2313
2436
|
S: this,
|
|
2314
2437
|
C: (f, a) => f(...a)
|
|
@@ -2316,19 +2439,19 @@ var InvitationsHandler = class {
|
|
|
2316
2439
|
}
|
|
2317
2440
|
} else {
|
|
2318
2441
|
if (guardedState.error(extension, err)) {
|
|
2319
|
-
|
|
2320
|
-
F:
|
|
2442
|
+
log9.error("failed", err, {
|
|
2443
|
+
F: __dxlog_file12,
|
|
2321
2444
|
L: 133,
|
|
2322
2445
|
S: this,
|
|
2323
2446
|
C: (f, a) => f(...a)
|
|
2324
2447
|
});
|
|
2325
2448
|
}
|
|
2326
2449
|
}
|
|
2327
|
-
|
|
2450
|
+
log9.trace("dxos.sdk.invitations-handler.host.onOpen", trace5.error({
|
|
2328
2451
|
id: traceId,
|
|
2329
2452
|
error: err
|
|
2330
2453
|
}), {
|
|
2331
|
-
F:
|
|
2454
|
+
F: __dxlog_file12,
|
|
2332
2455
|
L: 136,
|
|
2333
2456
|
S: this,
|
|
2334
2457
|
C: (f, a) => f(...a)
|
|
@@ -2339,10 +2462,10 @@ var InvitationsHandler = class {
|
|
|
2339
2462
|
},
|
|
2340
2463
|
onError: (err) => {
|
|
2341
2464
|
if (err instanceof InvalidInvitationExtensionRoleError3) {
|
|
2342
|
-
|
|
2465
|
+
log9("invalid role", {
|
|
2343
2466
|
...err.context
|
|
2344
2467
|
}, {
|
|
2345
|
-
F:
|
|
2468
|
+
F: __dxlog_file12,
|
|
2346
2469
|
L: 144,
|
|
2347
2470
|
S: this,
|
|
2348
2471
|
C: (f, a) => f(...a)
|
|
@@ -2351,10 +2474,10 @@ var InvitationsHandler = class {
|
|
|
2351
2474
|
}
|
|
2352
2475
|
if (err instanceof TimeoutError) {
|
|
2353
2476
|
if (guardedState.set(extension, Invitation4.State.TIMEOUT)) {
|
|
2354
|
-
|
|
2477
|
+
log9("timeout", {
|
|
2355
2478
|
err
|
|
2356
2479
|
}, {
|
|
2357
|
-
F:
|
|
2480
|
+
F: __dxlog_file12,
|
|
2358
2481
|
L: 149,
|
|
2359
2482
|
S: this,
|
|
2360
2483
|
C: (f, a) => f(...a)
|
|
@@ -2362,8 +2485,8 @@ var InvitationsHandler = class {
|
|
|
2362
2485
|
}
|
|
2363
2486
|
} else {
|
|
2364
2487
|
if (guardedState.error(extension, err)) {
|
|
2365
|
-
|
|
2366
|
-
F:
|
|
2488
|
+
log9.error("failed", err, {
|
|
2489
|
+
F: __dxlog_file12,
|
|
2367
2490
|
L: 153,
|
|
2368
2491
|
S: this,
|
|
2369
2492
|
C: (f, a) => f(...a)
|
|
@@ -2376,8 +2499,8 @@ var InvitationsHandler = class {
|
|
|
2376
2499
|
};
|
|
2377
2500
|
if (invitation.lifetime && invitation.created) {
|
|
2378
2501
|
if (invitation.created.getTime() + invitation.lifetime * 1e3 < Date.now()) {
|
|
2379
|
-
|
|
2380
|
-
F:
|
|
2502
|
+
log9.warn("invitation has already expired", void 0, {
|
|
2503
|
+
F: __dxlog_file12,
|
|
2381
2504
|
L: 164,
|
|
2382
2505
|
S: this,
|
|
2383
2506
|
C: (f, a) => f(...a)
|
|
@@ -2400,7 +2523,7 @@ var InvitationsHandler = class {
|
|
|
2400
2523
|
const { timeout = INVITATION_TIMEOUT } = invitation;
|
|
2401
2524
|
if (deviceProfile) {
|
|
2402
2525
|
invariant9(invitation.kind === Invitation4.Kind.DEVICE, "deviceProfile provided for non-device invitation", {
|
|
2403
|
-
F:
|
|
2526
|
+
F: __dxlog_file12,
|
|
2404
2527
|
L: 197,
|
|
2405
2528
|
S: this,
|
|
2406
2529
|
A: [
|
|
@@ -2413,12 +2536,12 @@ var InvitationsHandler = class {
|
|
|
2413
2536
|
const guardedState = this._createGuardedState(ctx, invitation, stream);
|
|
2414
2537
|
const shouldCancelInvitationFlow = (extension) => {
|
|
2415
2538
|
const isLockedByAnotherConnection = guardedState.mutex.isLocked() && !extension.hasFlowLock();
|
|
2416
|
-
|
|
2539
|
+
log9("should cancel invitation flow", {
|
|
2417
2540
|
isLockedByAnotherConnection,
|
|
2418
2541
|
invitationType: Invitation4.Type.DELEGATED,
|
|
2419
2542
|
triedPeers: triedPeersIds.size
|
|
2420
2543
|
}, {
|
|
2421
|
-
F:
|
|
2544
|
+
F: __dxlog_file12,
|
|
2422
2545
|
L: 205,
|
|
2423
2546
|
S: this,
|
|
2424
2547
|
C: (f, a) => f(...a)
|
|
@@ -2441,11 +2564,11 @@ var InvitationsHandler = class {
|
|
|
2441
2564
|
return;
|
|
2442
2565
|
}
|
|
2443
2566
|
connectionCtx.onDispose(async () => {
|
|
2444
|
-
|
|
2567
|
+
log9("extension disposed", {
|
|
2445
2568
|
admitted,
|
|
2446
2569
|
currentState: guardedState.current.state
|
|
2447
2570
|
}, {
|
|
2448
|
-
F:
|
|
2571
|
+
F: __dxlog_file12,
|
|
2449
2572
|
L: 233,
|
|
2450
2573
|
S: this,
|
|
2451
2574
|
C: (f, a) => f(...a)
|
|
@@ -2460,10 +2583,10 @@ var InvitationsHandler = class {
|
|
|
2460
2583
|
scheduleTask3(connectionCtx, async () => {
|
|
2461
2584
|
const traceId = PublicKey7.random().toHex();
|
|
2462
2585
|
try {
|
|
2463
|
-
|
|
2586
|
+
log9.trace("dxos.sdk.invitations-handler.guest.onOpen", trace5.begin({
|
|
2464
2587
|
id: traceId
|
|
2465
2588
|
}), {
|
|
2466
|
-
F:
|
|
2589
|
+
F: __dxlog_file12,
|
|
2467
2590
|
L: 245,
|
|
2468
2591
|
S: this,
|
|
2469
2592
|
C: (f, a) => f(...a)
|
|
@@ -2472,19 +2595,19 @@ var InvitationsHandler = class {
|
|
|
2472
2595
|
guardedState.set(extension, Invitation4.State.TIMEOUT);
|
|
2473
2596
|
extensionCtx.close();
|
|
2474
2597
|
}, timeout);
|
|
2475
|
-
|
|
2598
|
+
log9("connected", {
|
|
2476
2599
|
...protocol.toJSON()
|
|
2477
2600
|
}, {
|
|
2478
|
-
F:
|
|
2601
|
+
F: __dxlog_file12,
|
|
2479
2602
|
L: 256,
|
|
2480
2603
|
S: this,
|
|
2481
2604
|
C: (f, a) => f(...a)
|
|
2482
2605
|
});
|
|
2483
2606
|
guardedState.set(extension, Invitation4.State.CONNECTED);
|
|
2484
|
-
|
|
2607
|
+
log9("introduce", {
|
|
2485
2608
|
...protocol.toJSON()
|
|
2486
2609
|
}, {
|
|
2487
|
-
F:
|
|
2610
|
+
F: __dxlog_file12,
|
|
2488
2611
|
L: 260,
|
|
2489
2612
|
S: this,
|
|
2490
2613
|
C: (f, a) => f(...a)
|
|
@@ -2493,11 +2616,11 @@ var InvitationsHandler = class {
|
|
|
2493
2616
|
invitationId: invitation.invitationId,
|
|
2494
2617
|
...protocol.createIntroduction()
|
|
2495
2618
|
});
|
|
2496
|
-
|
|
2619
|
+
log9("introduce response", {
|
|
2497
2620
|
...protocol.toJSON(),
|
|
2498
2621
|
response: introductionResponse
|
|
2499
2622
|
}, {
|
|
2500
|
-
F:
|
|
2623
|
+
F: __dxlog_file12,
|
|
2501
2624
|
L: 265,
|
|
2502
2625
|
S: this,
|
|
2503
2626
|
C: (f, a) => f(...a)
|
|
@@ -2515,10 +2638,10 @@ var InvitationsHandler = class {
|
|
|
2515
2638
|
break;
|
|
2516
2639
|
}
|
|
2517
2640
|
}
|
|
2518
|
-
|
|
2641
|
+
log9("request admission", {
|
|
2519
2642
|
...protocol.toJSON()
|
|
2520
2643
|
}, {
|
|
2521
|
-
F:
|
|
2644
|
+
F: __dxlog_file12,
|
|
2522
2645
|
L: 291,
|
|
2523
2646
|
S: this,
|
|
2524
2647
|
C: (f, a) => f(...a)
|
|
@@ -2527,10 +2650,10 @@ var InvitationsHandler = class {
|
|
|
2527
2650
|
const admissionResponse = await extension.rpc.InvitationHostService.admit(admissionRequest);
|
|
2528
2651
|
admitted = true;
|
|
2529
2652
|
const result = await protocol.accept(admissionResponse, admissionRequest);
|
|
2530
|
-
|
|
2653
|
+
log9("admitted by host", {
|
|
2531
2654
|
...protocol.toJSON()
|
|
2532
2655
|
}, {
|
|
2533
|
-
F:
|
|
2656
|
+
F: __dxlog_file12,
|
|
2534
2657
|
L: 302,
|
|
2535
2658
|
S: this,
|
|
2536
2659
|
C: (f, a) => f(...a)
|
|
@@ -2540,28 +2663,28 @@ var InvitationsHandler = class {
|
|
|
2540
2663
|
...result,
|
|
2541
2664
|
state: Invitation4.State.SUCCESS
|
|
2542
2665
|
});
|
|
2543
|
-
|
|
2666
|
+
log9.trace("dxos.sdk.invitations-handler.guest.onOpen", trace5.end({
|
|
2544
2667
|
id: traceId
|
|
2545
2668
|
}), {
|
|
2546
|
-
F:
|
|
2669
|
+
F: __dxlog_file12,
|
|
2547
2670
|
L: 308,
|
|
2548
2671
|
S: this,
|
|
2549
2672
|
C: (f, a) => f(...a)
|
|
2550
2673
|
});
|
|
2551
2674
|
} catch (err) {
|
|
2552
2675
|
if (err instanceof TimeoutError) {
|
|
2553
|
-
|
|
2676
|
+
log9("timeout", {
|
|
2554
2677
|
...protocol.toJSON()
|
|
2555
2678
|
}, {
|
|
2556
|
-
F:
|
|
2679
|
+
F: __dxlog_file12,
|
|
2557
2680
|
L: 311,
|
|
2558
2681
|
S: this,
|
|
2559
2682
|
C: (f, a) => f(...a)
|
|
2560
2683
|
});
|
|
2561
2684
|
guardedState.set(extension, Invitation4.State.TIMEOUT);
|
|
2562
2685
|
} else {
|
|
2563
|
-
|
|
2564
|
-
F:
|
|
2686
|
+
log9("auth failed", err, {
|
|
2687
|
+
F: __dxlog_file12,
|
|
2565
2688
|
L: 314,
|
|
2566
2689
|
S: this,
|
|
2567
2690
|
C: (f, a) => f(...a)
|
|
@@ -2569,11 +2692,11 @@ var InvitationsHandler = class {
|
|
|
2569
2692
|
guardedState.error(extension, err);
|
|
2570
2693
|
}
|
|
2571
2694
|
extensionCtx.close(err);
|
|
2572
|
-
|
|
2695
|
+
log9.trace("dxos.sdk.invitations-handler.guest.onOpen", trace5.error({
|
|
2573
2696
|
id: traceId,
|
|
2574
2697
|
error: err
|
|
2575
2698
|
}), {
|
|
2576
|
-
F:
|
|
2699
|
+
F: __dxlog_file12,
|
|
2577
2700
|
L: 318,
|
|
2578
2701
|
S: this,
|
|
2579
2702
|
C: (f, a) => f(...a)
|
|
@@ -2586,18 +2709,18 @@ var InvitationsHandler = class {
|
|
|
2586
2709
|
return;
|
|
2587
2710
|
}
|
|
2588
2711
|
if (err instanceof TimeoutError) {
|
|
2589
|
-
|
|
2712
|
+
log9("timeout", {
|
|
2590
2713
|
...protocol.toJSON()
|
|
2591
2714
|
}, {
|
|
2592
|
-
F:
|
|
2715
|
+
F: __dxlog_file12,
|
|
2593
2716
|
L: 327,
|
|
2594
2717
|
S: this,
|
|
2595
2718
|
C: (f, a) => f(...a)
|
|
2596
2719
|
});
|
|
2597
2720
|
guardedState.set(extension, Invitation4.State.TIMEOUT);
|
|
2598
2721
|
} else {
|
|
2599
|
-
|
|
2600
|
-
F:
|
|
2722
|
+
log9("auth failed", err, {
|
|
2723
|
+
F: __dxlog_file12,
|
|
2601
2724
|
L: 330,
|
|
2602
2725
|
S: this,
|
|
2603
2726
|
C: (f, a) => f(...a)
|
|
@@ -2615,7 +2738,7 @@ var InvitationsHandler = class {
|
|
|
2615
2738
|
await ctx.dispose();
|
|
2616
2739
|
} else {
|
|
2617
2740
|
invariant9(invitation.swarmKey, void 0, {
|
|
2618
|
-
F:
|
|
2741
|
+
F: __dxlog_file12,
|
|
2619
2742
|
L: 345,
|
|
2620
2743
|
S: this,
|
|
2621
2744
|
A: [
|
|
@@ -2709,12 +2832,12 @@ var InvitationsHandler = class {
|
|
|
2709
2832
|
};
|
|
2710
2833
|
}
|
|
2711
2834
|
_logStateUpdate(invitation, actor, newState) {
|
|
2712
|
-
|
|
2835
|
+
log9("invitation state update", {
|
|
2713
2836
|
actor: actor?.constructor.name,
|
|
2714
2837
|
newState: stateToString(newState),
|
|
2715
2838
|
oldState: stateToString(invitation.state)
|
|
2716
2839
|
}, {
|
|
2717
|
-
F:
|
|
2840
|
+
F: __dxlog_file12,
|
|
2718
2841
|
L: 438,
|
|
2719
2842
|
S: this,
|
|
2720
2843
|
C: (f, a) => f(...a)
|
|
@@ -2731,16 +2854,16 @@ var InvitationsHandler = class {
|
|
|
2731
2854
|
}
|
|
2732
2855
|
async _handleGuestOtpAuth(extension, setState, authenticated, options) {
|
|
2733
2856
|
for (let attempt = 1; attempt <= MAX_OTP_ATTEMPTS; attempt++) {
|
|
2734
|
-
|
|
2735
|
-
F:
|
|
2857
|
+
log9("guest waiting for authentication code...", void 0, {
|
|
2858
|
+
F: __dxlog_file12,
|
|
2736
2859
|
L: 462,
|
|
2737
2860
|
S: this,
|
|
2738
2861
|
C: (f, a) => f(...a)
|
|
2739
2862
|
});
|
|
2740
2863
|
setState(Invitation4.State.READY_FOR_AUTHENTICATION);
|
|
2741
2864
|
const authCode = await authenticated.wait(options);
|
|
2742
|
-
|
|
2743
|
-
F:
|
|
2865
|
+
log9("sending authentication request", void 0, {
|
|
2866
|
+
F: __dxlog_file12,
|
|
2744
2867
|
L: 466,
|
|
2745
2868
|
S: this,
|
|
2746
2869
|
C: (f, a) => f(...a)
|
|
@@ -2756,10 +2879,10 @@ var InvitationsHandler = class {
|
|
|
2756
2879
|
if (attempt === MAX_OTP_ATTEMPTS) {
|
|
2757
2880
|
throw new Error(`Maximum retry attempts: ${MAX_OTP_ATTEMPTS}`);
|
|
2758
2881
|
} else {
|
|
2759
|
-
|
|
2882
|
+
log9("retrying invalid code", {
|
|
2760
2883
|
attempt
|
|
2761
2884
|
}, {
|
|
2762
|
-
F:
|
|
2885
|
+
F: __dxlog_file12,
|
|
2763
2886
|
L: 477,
|
|
2764
2887
|
S: this,
|
|
2765
2888
|
C: (f, a) => f(...a)
|
|
@@ -2776,8 +2899,8 @@ var InvitationsHandler = class {
|
|
|
2776
2899
|
if (introductionResponse.challenge == null) {
|
|
2777
2900
|
throw new Error("challenge missing in the introduction");
|
|
2778
2901
|
}
|
|
2779
|
-
|
|
2780
|
-
F:
|
|
2902
|
+
log9("sending authentication request", void 0, {
|
|
2903
|
+
F: __dxlog_file12,
|
|
2781
2904
|
L: 496,
|
|
2782
2905
|
S: this,
|
|
2783
2906
|
C: (f, a) => f(...a)
|
|
@@ -2898,14 +3021,14 @@ var InvitationsServiceImpl = class {
|
|
|
2898
3021
|
};
|
|
2899
3022
|
|
|
2900
3023
|
// packages/sdk/client-services/src/packlets/invitations/space-invitation-protocol.ts
|
|
2901
|
-
import { createAdmissionCredentials, createCancelDelegatedSpaceInvitationCredential, createDelegatedSpaceInvitationCredential, getCredentialAssertion } from "@dxos/credentials";
|
|
3024
|
+
import { createAdmissionCredentials, createCancelDelegatedSpaceInvitationCredential, createDelegatedSpaceInvitationCredential, getCredentialAssertion as getCredentialAssertion2 } from "@dxos/credentials";
|
|
2902
3025
|
import { writeMessages as writeMessages2 } from "@dxos/feed-store";
|
|
2903
3026
|
import { invariant as invariant10 } from "@dxos/invariant";
|
|
2904
|
-
import { log as
|
|
3027
|
+
import { log as log10 } from "@dxos/log";
|
|
2905
3028
|
import { AlreadyJoinedError as AlreadyJoinedError2, AuthorizationError, InvalidInvitationError, SpaceNotFoundError } from "@dxos/protocols";
|
|
2906
3029
|
import { Invitation as Invitation5 } from "@dxos/protocols/proto/dxos/client/services";
|
|
2907
3030
|
import { SpaceMember as SpaceMember2 } from "@dxos/protocols/proto/dxos/halo/credentials";
|
|
2908
|
-
var
|
|
3031
|
+
var __dxlog_file13 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/space-invitation-protocol.ts";
|
|
2909
3032
|
var SpaceInvitationProtocol = class {
|
|
2910
3033
|
constructor(_spaceManager, _signingContext, _keyring, _spaceKey) {
|
|
2911
3034
|
this._spaceManager = _spaceManager;
|
|
@@ -2940,7 +3063,7 @@ var SpaceInvitationProtocol = class {
|
|
|
2940
3063
|
}
|
|
2941
3064
|
async admit(invitation, request, guestProfile) {
|
|
2942
3065
|
invariant10(this._spaceKey, void 0, {
|
|
2943
|
-
F:
|
|
3066
|
+
F: __dxlog_file13,
|
|
2944
3067
|
L: 76,
|
|
2945
3068
|
S: this,
|
|
2946
3069
|
A: [
|
|
@@ -2950,7 +3073,7 @@ var SpaceInvitationProtocol = class {
|
|
|
2950
3073
|
});
|
|
2951
3074
|
const space = this._spaceManager.spaces.get(this._spaceKey);
|
|
2952
3075
|
invariant10(space, void 0, {
|
|
2953
|
-
F:
|
|
3076
|
+
F: __dxlog_file13,
|
|
2954
3077
|
L: 78,
|
|
2955
3078
|
S: this,
|
|
2956
3079
|
A: [
|
|
@@ -2959,7 +3082,7 @@ var SpaceInvitationProtocol = class {
|
|
|
2959
3082
|
]
|
|
2960
3083
|
});
|
|
2961
3084
|
invariant10(request.space, void 0, {
|
|
2962
|
-
F:
|
|
3085
|
+
F: __dxlog_file13,
|
|
2963
3086
|
L: 80,
|
|
2964
3087
|
S: this,
|
|
2965
3088
|
A: [
|
|
@@ -2971,18 +3094,18 @@ var SpaceInvitationProtocol = class {
|
|
|
2971
3094
|
if (space.inner.spaceState.getMemberRole(identityKey) !== SpaceMember2.Role.REMOVED) {
|
|
2972
3095
|
throw new AlreadyJoinedError2();
|
|
2973
3096
|
}
|
|
2974
|
-
|
|
3097
|
+
log10("writing guest credentials", {
|
|
2975
3098
|
host: this._signingContext.deviceKey,
|
|
2976
3099
|
guest: deviceKey
|
|
2977
3100
|
}, {
|
|
2978
|
-
F:
|
|
3101
|
+
F: __dxlog_file13,
|
|
2979
3102
|
L: 87,
|
|
2980
3103
|
S: this,
|
|
2981
3104
|
C: (f, a) => f(...a)
|
|
2982
3105
|
});
|
|
2983
3106
|
const credentials = await createAdmissionCredentials(this._signingContext.credentialSigner, identityKey, space.key, space.inner.genesisFeedKey, invitation.role ?? SpaceMember2.Role.ADMIN, space.inner.spaceState.membershipChainHeads, guestProfile, invitation.delegationCredentialId);
|
|
2984
3107
|
invariant10(credentials[0].credential, void 0, {
|
|
2985
|
-
F:
|
|
3108
|
+
F: __dxlog_file13,
|
|
2986
3109
|
L: 101,
|
|
2987
3110
|
S: this,
|
|
2988
3111
|
A: [
|
|
@@ -2991,8 +3114,8 @@ var SpaceInvitationProtocol = class {
|
|
|
2991
3114
|
]
|
|
2992
3115
|
});
|
|
2993
3116
|
const spaceMemberCredential = credentials[0].credential.credential;
|
|
2994
|
-
invariant10(
|
|
2995
|
-
F:
|
|
3117
|
+
invariant10(getCredentialAssertion2(spaceMemberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
|
|
3118
|
+
F: __dxlog_file13,
|
|
2996
3119
|
L: 103,
|
|
2997
3120
|
S: this,
|
|
2998
3121
|
A: [
|
|
@@ -3010,7 +3133,7 @@ var SpaceInvitationProtocol = class {
|
|
|
3010
3133
|
}
|
|
3011
3134
|
async delegate(invitation) {
|
|
3012
3135
|
invariant10(this._spaceKey, void 0, {
|
|
3013
|
-
F:
|
|
3136
|
+
F: __dxlog_file13,
|
|
3014
3137
|
L: 116,
|
|
3015
3138
|
S: this,
|
|
3016
3139
|
A: [
|
|
@@ -3020,7 +3143,7 @@ var SpaceInvitationProtocol = class {
|
|
|
3020
3143
|
});
|
|
3021
3144
|
const space = this._spaceManager.spaces.get(this._spaceKey);
|
|
3022
3145
|
invariant10(space, void 0, {
|
|
3023
|
-
F:
|
|
3146
|
+
F: __dxlog_file13,
|
|
3024
3147
|
L: 118,
|
|
3025
3148
|
S: this,
|
|
3026
3149
|
A: [
|
|
@@ -3030,7 +3153,7 @@ var SpaceInvitationProtocol = class {
|
|
|
3030
3153
|
});
|
|
3031
3154
|
if (invitation.authMethod === Invitation5.AuthMethod.KNOWN_PUBLIC_KEY) {
|
|
3032
3155
|
invariant10(invitation.guestKeypair?.publicKey, void 0, {
|
|
3033
|
-
F:
|
|
3156
|
+
F: __dxlog_file13,
|
|
3034
3157
|
L: 120,
|
|
3035
3158
|
S: this,
|
|
3036
3159
|
A: [
|
|
@@ -3039,11 +3162,11 @@ var SpaceInvitationProtocol = class {
|
|
|
3039
3162
|
]
|
|
3040
3163
|
});
|
|
3041
3164
|
}
|
|
3042
|
-
|
|
3165
|
+
log10("writing delegate space invitation", {
|
|
3043
3166
|
host: this._signingContext.deviceKey,
|
|
3044
3167
|
id: invitation.invitationId
|
|
3045
3168
|
}, {
|
|
3046
|
-
F:
|
|
3169
|
+
F: __dxlog_file13,
|
|
3047
3170
|
L: 123,
|
|
3048
3171
|
S: this,
|
|
3049
3172
|
C: (f, a) => f(...a)
|
|
@@ -3058,7 +3181,7 @@ var SpaceInvitationProtocol = class {
|
|
|
3058
3181
|
guestKey: invitation.authMethod === Invitation5.AuthMethod.KNOWN_PUBLIC_KEY ? invitation.guestKeypair.publicKey : void 0
|
|
3059
3182
|
});
|
|
3060
3183
|
invariant10(credential.credential, void 0, {
|
|
3061
|
-
F:
|
|
3184
|
+
F: __dxlog_file13,
|
|
3062
3185
|
L: 143,
|
|
3063
3186
|
S: this,
|
|
3064
3187
|
A: [
|
|
@@ -3073,7 +3196,7 @@ var SpaceInvitationProtocol = class {
|
|
|
3073
3196
|
}
|
|
3074
3197
|
async cancelDelegation(invitation) {
|
|
3075
3198
|
invariant10(this._spaceKey, void 0, {
|
|
3076
|
-
F:
|
|
3199
|
+
F: __dxlog_file13,
|
|
3077
3200
|
L: 149,
|
|
3078
3201
|
S: this,
|
|
3079
3202
|
A: [
|
|
@@ -3082,7 +3205,7 @@ var SpaceInvitationProtocol = class {
|
|
|
3082
3205
|
]
|
|
3083
3206
|
});
|
|
3084
3207
|
invariant10(invitation.type === Invitation5.Type.DELEGATED && invitation.delegationCredentialId, void 0, {
|
|
3085
|
-
F:
|
|
3208
|
+
F: __dxlog_file13,
|
|
3086
3209
|
L: 150,
|
|
3087
3210
|
S: this,
|
|
3088
3211
|
A: [
|
|
@@ -3092,7 +3215,7 @@ var SpaceInvitationProtocol = class {
|
|
|
3092
3215
|
});
|
|
3093
3216
|
const space = this._spaceManager.spaces.get(this._spaceKey);
|
|
3094
3217
|
invariant10(space, void 0, {
|
|
3095
|
-
F:
|
|
3218
|
+
F: __dxlog_file13,
|
|
3096
3219
|
L: 152,
|
|
3097
3220
|
S: this,
|
|
3098
3221
|
A: [
|
|
@@ -3100,18 +3223,18 @@ var SpaceInvitationProtocol = class {
|
|
|
3100
3223
|
""
|
|
3101
3224
|
]
|
|
3102
3225
|
});
|
|
3103
|
-
|
|
3226
|
+
log10("cancelling delegated space invitation", {
|
|
3104
3227
|
host: this._signingContext.deviceKey,
|
|
3105
3228
|
id: invitation.invitationId
|
|
3106
3229
|
}, {
|
|
3107
|
-
F:
|
|
3230
|
+
F: __dxlog_file13,
|
|
3108
3231
|
L: 154,
|
|
3109
3232
|
S: this,
|
|
3110
3233
|
C: (f, a) => f(...a)
|
|
3111
3234
|
});
|
|
3112
3235
|
const credential = await createCancelDelegatedSpaceInvitationCredential(this._signingContext.credentialSigner, space.key, invitation.delegationCredentialId);
|
|
3113
3236
|
invariant10(credential.credential, void 0, {
|
|
3114
|
-
F:
|
|
3237
|
+
F: __dxlog_file13,
|
|
3115
3238
|
L: 161,
|
|
3116
3239
|
S: this,
|
|
3117
3240
|
A: [
|
|
@@ -3150,7 +3273,7 @@ var SpaceInvitationProtocol = class {
|
|
|
3150
3273
|
}
|
|
3151
3274
|
async accept(response) {
|
|
3152
3275
|
invariant10(response.space, void 0, {
|
|
3153
|
-
F:
|
|
3276
|
+
F: __dxlog_file13,
|
|
3154
3277
|
L: 196,
|
|
3155
3278
|
S: this,
|
|
3156
3279
|
A: [
|
|
@@ -3159,9 +3282,9 @@ var SpaceInvitationProtocol = class {
|
|
|
3159
3282
|
]
|
|
3160
3283
|
});
|
|
3161
3284
|
const { credential, controlTimeframe, dataTimeframe } = response.space;
|
|
3162
|
-
const assertion =
|
|
3285
|
+
const assertion = getCredentialAssertion2(credential);
|
|
3163
3286
|
invariant10(assertion["@type"] === "dxos.halo.credentials.SpaceMember", "Invalid credential", {
|
|
3164
|
-
F:
|
|
3287
|
+
F: __dxlog_file13,
|
|
3165
3288
|
L: 199,
|
|
3166
3289
|
S: this,
|
|
3167
3290
|
A: [
|
|
@@ -3170,7 +3293,7 @@ var SpaceInvitationProtocol = class {
|
|
|
3170
3293
|
]
|
|
3171
3294
|
});
|
|
3172
3295
|
invariant10(credential.subject.id.equals(this._signingContext.identityKey), void 0, {
|
|
3173
|
-
F:
|
|
3296
|
+
F: __dxlog_file13,
|
|
3174
3297
|
L: 200,
|
|
3175
3298
|
S: this,
|
|
3176
3299
|
A: [
|
|
@@ -3202,10 +3325,10 @@ import { generatePasscode } from "@dxos/credentials";
|
|
|
3202
3325
|
import { hasInvitationExpired } from "@dxos/echo-pipeline";
|
|
3203
3326
|
import { invariant as invariant11 } from "@dxos/invariant";
|
|
3204
3327
|
import { PublicKey as PublicKey8 } from "@dxos/keys";
|
|
3205
|
-
import { log as
|
|
3328
|
+
import { log as log11 } from "@dxos/log";
|
|
3206
3329
|
import { Invitation as Invitation6 } from "@dxos/protocols/proto/dxos/client/services";
|
|
3207
3330
|
import { SpaceMember as SpaceMember3 } from "@dxos/protocols/proto/dxos/halo/credentials";
|
|
3208
|
-
var
|
|
3331
|
+
var __dxlog_file14 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitations-manager.ts";
|
|
3209
3332
|
var InvitationsManager = class {
|
|
3210
3333
|
constructor(_invitationsHandler, _getHandler, _metadataStore) {
|
|
3211
3334
|
this._invitationsHandler = _invitationsHandler;
|
|
@@ -3247,8 +3370,8 @@ var InvitationsManager = class {
|
|
|
3247
3370
|
try {
|
|
3248
3371
|
await this._persistIfRequired(handler, stream, invitation);
|
|
3249
3372
|
} catch (err) {
|
|
3250
|
-
|
|
3251
|
-
F:
|
|
3373
|
+
log11.catch(err, void 0, {
|
|
3374
|
+
F: __dxlog_file14,
|
|
3252
3375
|
L: 82,
|
|
3253
3376
|
S: this,
|
|
3254
3377
|
C: (f, a) => f(...a)
|
|
@@ -3271,7 +3394,7 @@ var InvitationsManager = class {
|
|
|
3271
3394
|
const freshInvitations = persistentInvitations.filter((invitation) => !hasInvitationExpired(invitation));
|
|
3272
3395
|
const loadTasks = freshInvitations.map((persistentInvitation) => {
|
|
3273
3396
|
invariant11(!this._createInvitations.get(persistentInvitation.invitationId), "invitation already exists", {
|
|
3274
|
-
F:
|
|
3397
|
+
F: __dxlog_file14,
|
|
3275
3398
|
L: 103,
|
|
3276
3399
|
S: this,
|
|
3277
3400
|
A: [
|
|
@@ -3289,8 +3412,8 @@ var InvitationsManager = class {
|
|
|
3289
3412
|
invitations: cInvitations.map((invitation) => invitation.get())
|
|
3290
3413
|
};
|
|
3291
3414
|
} catch (err) {
|
|
3292
|
-
|
|
3293
|
-
F:
|
|
3415
|
+
log11.catch(err, void 0, {
|
|
3416
|
+
F: __dxlog_file14,
|
|
3294
3417
|
L: 110,
|
|
3295
3418
|
S: this,
|
|
3296
3419
|
C: (f, a) => f(...a)
|
|
@@ -3321,14 +3444,14 @@ var InvitationsManager = class {
|
|
|
3321
3444
|
return invitation;
|
|
3322
3445
|
}
|
|
3323
3446
|
async authenticate({ invitationId, authCode }) {
|
|
3324
|
-
|
|
3325
|
-
F:
|
|
3447
|
+
log11("authenticating...", void 0, {
|
|
3448
|
+
F: __dxlog_file14,
|
|
3326
3449
|
L: 140,
|
|
3327
3450
|
S: this,
|
|
3328
3451
|
C: (f, a) => f(...a)
|
|
3329
3452
|
});
|
|
3330
3453
|
invariant11(invitationId, void 0, {
|
|
3331
|
-
F:
|
|
3454
|
+
F: __dxlog_file14,
|
|
3332
3455
|
L: 141,
|
|
3333
3456
|
S: this,
|
|
3334
3457
|
A: [
|
|
@@ -3338,10 +3461,10 @@ var InvitationsManager = class {
|
|
|
3338
3461
|
});
|
|
3339
3462
|
const observable = this._acceptInvitations.get(invitationId);
|
|
3340
3463
|
if (!observable) {
|
|
3341
|
-
|
|
3464
|
+
log11.warn("invalid invitation", {
|
|
3342
3465
|
invitationId
|
|
3343
3466
|
}, {
|
|
3344
|
-
F:
|
|
3467
|
+
F: __dxlog_file14,
|
|
3345
3468
|
L: 144,
|
|
3346
3469
|
S: this,
|
|
3347
3470
|
C: (f, a) => f(...a)
|
|
@@ -3351,16 +3474,16 @@ var InvitationsManager = class {
|
|
|
3351
3474
|
}
|
|
3352
3475
|
}
|
|
3353
3476
|
async cancelInvitation({ invitationId }) {
|
|
3354
|
-
|
|
3477
|
+
log11("cancelInvitation...", {
|
|
3355
3478
|
invitationId
|
|
3356
3479
|
}, {
|
|
3357
|
-
F:
|
|
3480
|
+
F: __dxlog_file14,
|
|
3358
3481
|
L: 151,
|
|
3359
3482
|
S: this,
|
|
3360
3483
|
C: (f, a) => f(...a)
|
|
3361
3484
|
});
|
|
3362
3485
|
invariant11(invitationId, void 0, {
|
|
3363
|
-
F:
|
|
3486
|
+
F: __dxlog_file14,
|
|
3364
3487
|
L: 152,
|
|
3365
3488
|
S: this,
|
|
3366
3489
|
A: [
|
|
@@ -3436,10 +3559,10 @@ var InvitationsManager = class {
|
|
|
3436
3559
|
}
|
|
3437
3560
|
});
|
|
3438
3561
|
ctx.onDispose(() => {
|
|
3439
|
-
|
|
3562
|
+
log11("complete", {
|
|
3440
3563
|
...handler.toJSON()
|
|
3441
3564
|
}, {
|
|
3442
|
-
F:
|
|
3565
|
+
F: __dxlog_file14,
|
|
3443
3566
|
L: 241,
|
|
3444
3567
|
S: this,
|
|
3445
3568
|
C: (f, a) => f(...a)
|
|
@@ -3469,10 +3592,10 @@ var InvitationsManager = class {
|
|
|
3469
3592
|
const ctx = new Context6({
|
|
3470
3593
|
onError: (err) => {
|
|
3471
3594
|
if (err instanceof TimeoutError2) {
|
|
3472
|
-
|
|
3595
|
+
log11("timeout", {
|
|
3473
3596
|
...handler.toJSON()
|
|
3474
3597
|
}, {
|
|
3475
|
-
F:
|
|
3598
|
+
F: __dxlog_file14,
|
|
3476
3599
|
L: 261,
|
|
3477
3600
|
S: this,
|
|
3478
3601
|
C: (f, a) => f(...a)
|
|
@@ -3482,8 +3605,8 @@ var InvitationsManager = class {
|
|
|
3482
3605
|
state: Invitation6.State.TIMEOUT
|
|
3483
3606
|
});
|
|
3484
3607
|
} else {
|
|
3485
|
-
|
|
3486
|
-
F:
|
|
3608
|
+
log11.warn("auth failed", err, {
|
|
3609
|
+
F: __dxlog_file14,
|
|
3487
3610
|
L: 264,
|
|
3488
3611
|
S: this,
|
|
3489
3612
|
C: (f, a) => f(...a)
|
|
@@ -3497,10 +3620,10 @@ var InvitationsManager = class {
|
|
|
3497
3620
|
}
|
|
3498
3621
|
});
|
|
3499
3622
|
ctx.onDispose(() => {
|
|
3500
|
-
|
|
3623
|
+
log11("complete", {
|
|
3501
3624
|
...handler.toJSON()
|
|
3502
3625
|
}, {
|
|
3503
|
-
F:
|
|
3626
|
+
F: __dxlog_file14,
|
|
3504
3627
|
L: 271,
|
|
3505
3628
|
S: this,
|
|
3506
3629
|
C: (f, a) => f(...a)
|
|
@@ -3544,8 +3667,8 @@ var InvitationsManager = class {
|
|
|
3544
3667
|
try {
|
|
3545
3668
|
await this._metadataStore.removeInvitation(invitation.invitationId);
|
|
3546
3669
|
} catch (err) {
|
|
3547
|
-
|
|
3548
|
-
F:
|
|
3670
|
+
log11.catch(err, void 0, {
|
|
3671
|
+
F: __dxlog_file14,
|
|
3549
3672
|
L: 307,
|
|
3550
3673
|
S: this,
|
|
3551
3674
|
C: (f, a) => f(...a)
|
|
@@ -3568,11 +3691,11 @@ import { AutomergeDocumentLoaderImpl, createIdFromSpaceKey, createMappedFeedWrit
|
|
|
3568
3691
|
import { TYPE_PROPERTIES } from "@dxos/echo-schema";
|
|
3569
3692
|
import { failedInvariant, invariant as invariant13 } from "@dxos/invariant";
|
|
3570
3693
|
import { PublicKey as PublicKey10 } from "@dxos/keys";
|
|
3571
|
-
import { log as
|
|
3694
|
+
import { log as log13 } from "@dxos/log";
|
|
3572
3695
|
import { CancelledError, SystemError } from "@dxos/protocols";
|
|
3573
|
-
import { CreateEpochRequest, SpaceState } from "@dxos/protocols/proto/dxos/client/services";
|
|
3696
|
+
import { CreateEpochRequest, SpaceState as SpaceState2 } from "@dxos/protocols/proto/dxos/client/services";
|
|
3574
3697
|
import { AdmittedFeed as AdmittedFeed3, SpaceMember as SpaceMember4 } from "@dxos/protocols/proto/dxos/halo/credentials";
|
|
3575
|
-
import { Timeframe as
|
|
3698
|
+
import { Timeframe as Timeframe3 } from "@dxos/timeframe";
|
|
3576
3699
|
import { trace as trace6 } from "@dxos/tracing";
|
|
3577
3700
|
import { ComplexSet as ComplexSet5, assignDeep } from "@dxos/util";
|
|
3578
3701
|
|
|
@@ -3619,11 +3742,11 @@ import { DeferredTask, Event as Event5, scheduleTask as scheduleTask4, sleep, Ti
|
|
|
3619
3742
|
import { Context as Context7, rejectOnDispose } from "@dxos/context";
|
|
3620
3743
|
import { invariant as invariant12 } from "@dxos/invariant";
|
|
3621
3744
|
import { PublicKey as PublicKey9 } from "@dxos/keys";
|
|
3622
|
-
import { log as
|
|
3745
|
+
import { log as log12 } from "@dxos/log";
|
|
3623
3746
|
import { schema as schema4 } from "@dxos/protocols";
|
|
3624
3747
|
import { RpcExtension as RpcExtension3 } from "@dxos/teleport";
|
|
3625
3748
|
import { ComplexMap as ComplexMap2, ComplexSet as ComplexSet4, entry } from "@dxos/util";
|
|
3626
|
-
var
|
|
3749
|
+
var __dxlog_file15 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/notarization-plugin.ts";
|
|
3627
3750
|
var DEFAULT_RETRY_TIMEOUT = 1e3;
|
|
3628
3751
|
var DEFAULT_SUCCESS_DELAY = 1e3;
|
|
3629
3752
|
var DEFAULT_NOTARIZE_TIMEOUT = 1e4;
|
|
@@ -3648,16 +3771,16 @@ var NotarizationPlugin = class {
|
|
|
3648
3771
|
* Request credentials to be notarized.
|
|
3649
3772
|
*/
|
|
3650
3773
|
async notarize({ ctx: opCtx, credentials, timeout = DEFAULT_NOTARIZE_TIMEOUT, retryTimeout = DEFAULT_RETRY_TIMEOUT, successDelay = DEFAULT_SUCCESS_DELAY }) {
|
|
3651
|
-
|
|
3774
|
+
log12("notarize", {
|
|
3652
3775
|
credentials
|
|
3653
3776
|
}, {
|
|
3654
|
-
F:
|
|
3777
|
+
F: __dxlog_file15,
|
|
3655
3778
|
L: 90,
|
|
3656
3779
|
S: this,
|
|
3657
3780
|
C: (f, a) => f(...a)
|
|
3658
3781
|
});
|
|
3659
3782
|
invariant12(credentials.every((credential) => credential.id), "Credentials must have an id", {
|
|
3660
|
-
F:
|
|
3783
|
+
F: __dxlog_file15,
|
|
3661
3784
|
L: 91,
|
|
3662
3785
|
S: this,
|
|
3663
3786
|
A: [
|
|
@@ -3668,10 +3791,10 @@ var NotarizationPlugin = class {
|
|
|
3668
3791
|
const errors = new Trigger6();
|
|
3669
3792
|
const ctx = this._ctx.derive({
|
|
3670
3793
|
onError: (err) => {
|
|
3671
|
-
|
|
3794
|
+
log12.warn("Notarization error", {
|
|
3672
3795
|
err
|
|
3673
3796
|
}, {
|
|
3674
|
-
F:
|
|
3797
|
+
F: __dxlog_file15,
|
|
3675
3798
|
L: 99,
|
|
3676
3799
|
S: this,
|
|
3677
3800
|
C: (f, a) => f(...a)
|
|
@@ -3683,11 +3806,11 @@ var NotarizationPlugin = class {
|
|
|
3683
3806
|
opCtx?.onDispose(() => ctx.dispose());
|
|
3684
3807
|
if (timeout !== 0) {
|
|
3685
3808
|
scheduleTask4(ctx, () => {
|
|
3686
|
-
|
|
3809
|
+
log12.warn("Notarization timeout", {
|
|
3687
3810
|
timeout,
|
|
3688
3811
|
peers: Array.from(this._extensions).map((extension) => extension.remotePeerId)
|
|
3689
3812
|
}, {
|
|
3690
|
-
F:
|
|
3813
|
+
F: __dxlog_file15,
|
|
3691
3814
|
L: 111,
|
|
3692
3815
|
S: this,
|
|
3693
3816
|
C: (f, a) => f(...a)
|
|
@@ -3707,10 +3830,10 @@ var NotarizationPlugin = class {
|
|
|
3707
3830
|
...this._extensions
|
|
3708
3831
|
].find((peer2) => !peersTried.has(peer2));
|
|
3709
3832
|
if (!peer) {
|
|
3710
|
-
|
|
3833
|
+
log12.info("Exhausted all peers to notarize with", {
|
|
3711
3834
|
retryIn: retryTimeout
|
|
3712
3835
|
}, {
|
|
3713
|
-
F:
|
|
3836
|
+
F: __dxlog_file15,
|
|
3714
3837
|
L: 136,
|
|
3715
3838
|
S: this,
|
|
3716
3839
|
C: (f, a) => f(...a)
|
|
@@ -3720,11 +3843,11 @@ var NotarizationPlugin = class {
|
|
|
3720
3843
|
return;
|
|
3721
3844
|
}
|
|
3722
3845
|
peersTried.add(peer);
|
|
3723
|
-
|
|
3846
|
+
log12("try notarizing", {
|
|
3724
3847
|
peer: peer.localPeerId,
|
|
3725
3848
|
credentialId: credentials.map((credential) => credential.id)
|
|
3726
3849
|
}, {
|
|
3727
|
-
F:
|
|
3850
|
+
F: __dxlog_file15,
|
|
3728
3851
|
L: 143,
|
|
3729
3852
|
S: this,
|
|
3730
3853
|
C: (f, a) => f(...a)
|
|
@@ -3732,8 +3855,8 @@ var NotarizationPlugin = class {
|
|
|
3732
3855
|
await peer.rpc.NotarizationService.notarize({
|
|
3733
3856
|
credentials: credentials.filter((credential) => !this._processedCredentials.has(credential.id))
|
|
3734
3857
|
});
|
|
3735
|
-
|
|
3736
|
-
F:
|
|
3858
|
+
log12("success", void 0, {
|
|
3859
|
+
F: __dxlog_file15,
|
|
3737
3860
|
L: 147,
|
|
3738
3861
|
S: this,
|
|
3739
3862
|
C: (f, a) => f(...a)
|
|
@@ -3741,8 +3864,8 @@ var NotarizationPlugin = class {
|
|
|
3741
3864
|
await sleep(successDelay);
|
|
3742
3865
|
} catch (err) {
|
|
3743
3866
|
if (!ctx.disposed && !err.message.includes(WRITER_NOT_SET_ERROR_CODE)) {
|
|
3744
|
-
|
|
3745
|
-
F:
|
|
3867
|
+
log12.info("error notarizing (recoverable)", err, {
|
|
3868
|
+
F: __dxlog_file15,
|
|
3746
3869
|
L: 151,
|
|
3747
3870
|
S: this,
|
|
3748
3871
|
C: (f, a) => f(...a)
|
|
@@ -3759,8 +3882,8 @@ var NotarizationPlugin = class {
|
|
|
3759
3882
|
allNotarized,
|
|
3760
3883
|
errors.wait()
|
|
3761
3884
|
]);
|
|
3762
|
-
|
|
3763
|
-
F:
|
|
3885
|
+
log12("done", void 0, {
|
|
3886
|
+
F: __dxlog_file15,
|
|
3764
3887
|
L: 162,
|
|
3765
3888
|
S: this,
|
|
3766
3889
|
C: (f, a) => f(...a)
|
|
@@ -3782,7 +3905,7 @@ var NotarizationPlugin = class {
|
|
|
3782
3905
|
}
|
|
3783
3906
|
setWriter(writer) {
|
|
3784
3907
|
invariant12(!this._writer, "Writer already set.", {
|
|
3785
|
-
F:
|
|
3908
|
+
F: __dxlog_file15,
|
|
3786
3909
|
L: 181,
|
|
3787
3910
|
S: this,
|
|
3788
3911
|
A: [
|
|
@@ -3807,7 +3930,7 @@ var NotarizationPlugin = class {
|
|
|
3807
3930
|
}
|
|
3808
3931
|
for (const credential of request.credentials ?? []) {
|
|
3809
3932
|
invariant12(credential.id, "Credential must have an id", {
|
|
3810
|
-
F:
|
|
3933
|
+
F: __dxlog_file15,
|
|
3811
3934
|
L: 200,
|
|
3812
3935
|
S: this,
|
|
3813
3936
|
A: [
|
|
@@ -3824,10 +3947,10 @@ var NotarizationPlugin = class {
|
|
|
3824
3947
|
createExtension() {
|
|
3825
3948
|
const extension = new NotarizationTeleportExtension({
|
|
3826
3949
|
onOpen: async () => {
|
|
3827
|
-
|
|
3950
|
+
log12("extension opened", {
|
|
3828
3951
|
peer: extension.localPeerId
|
|
3829
3952
|
}, {
|
|
3830
|
-
F:
|
|
3953
|
+
F: __dxlog_file15,
|
|
3831
3954
|
L: 211,
|
|
3832
3955
|
S: this,
|
|
3833
3956
|
C: (f, a) => f(...a)
|
|
@@ -3836,10 +3959,10 @@ var NotarizationPlugin = class {
|
|
|
3836
3959
|
this._extensionOpened.emit();
|
|
3837
3960
|
},
|
|
3838
3961
|
onClose: async () => {
|
|
3839
|
-
|
|
3962
|
+
log12("extension closed", {
|
|
3840
3963
|
peer: extension.localPeerId
|
|
3841
3964
|
}, {
|
|
3842
|
-
F:
|
|
3965
|
+
F: __dxlog_file15,
|
|
3843
3966
|
L: 216,
|
|
3844
3967
|
S: this,
|
|
3845
3968
|
C: (f, a) => f(...a)
|
|
@@ -3893,7 +4016,7 @@ function _ts_decorate4(decorators, target, key, desc) {
|
|
|
3893
4016
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
3894
4017
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3895
4018
|
}
|
|
3896
|
-
var
|
|
4019
|
+
var __dxlog_file16 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space.ts";
|
|
3897
4020
|
var DataSpace = class {
|
|
3898
4021
|
constructor(params) {
|
|
3899
4022
|
this._ctx = new Context8();
|
|
@@ -3901,7 +4024,7 @@ var DataSpace = class {
|
|
|
3901
4024
|
this._cache = void 0;
|
|
3902
4025
|
// TODO(dmaretskyi): Move into Space?
|
|
3903
4026
|
this._automergeSpaceState = new AutomergeSpaceState((rootUrl) => this._onNewAutomergeRoot(rootUrl));
|
|
3904
|
-
this._state =
|
|
4027
|
+
this._state = SpaceState2.CLOSED;
|
|
3905
4028
|
/**
|
|
3906
4029
|
* Error for _state === SpaceState.ERROR.
|
|
3907
4030
|
*/
|
|
@@ -3925,11 +4048,11 @@ var DataSpace = class {
|
|
|
3925
4048
|
});
|
|
3926
4049
|
this._cache = params.cache;
|
|
3927
4050
|
this._state = params.initialState;
|
|
3928
|
-
|
|
3929
|
-
state:
|
|
4051
|
+
log13("new state", {
|
|
4052
|
+
state: SpaceState2[this._state]
|
|
3930
4053
|
}, {
|
|
3931
|
-
F:
|
|
3932
|
-
L:
|
|
4054
|
+
F: __dxlog_file16,
|
|
4055
|
+
L: 143,
|
|
3933
4056
|
S: this,
|
|
3934
4057
|
C: (f, a) => f(...a)
|
|
3935
4058
|
});
|
|
@@ -3969,20 +4092,23 @@ var DataSpace = class {
|
|
|
3969
4092
|
};
|
|
3970
4093
|
}
|
|
3971
4094
|
async open() {
|
|
3972
|
-
|
|
4095
|
+
if (this._state === SpaceState2.CLOSED) {
|
|
4096
|
+
await this._open();
|
|
4097
|
+
}
|
|
3973
4098
|
}
|
|
3974
4099
|
async _open() {
|
|
4100
|
+
await this._presence.open();
|
|
3975
4101
|
await this._gossip.open();
|
|
3976
4102
|
await this._notarizationPlugin.open();
|
|
3977
4103
|
await this._inner.spaceState.addCredentialProcessor(this._notarizationPlugin);
|
|
3978
4104
|
await this._inner.spaceState.addCredentialProcessor(this._automergeSpaceState);
|
|
3979
4105
|
await this._inner.open(new Context8());
|
|
3980
|
-
this._state =
|
|
3981
|
-
|
|
3982
|
-
state:
|
|
4106
|
+
this._state = SpaceState2.CONTROL_ONLY;
|
|
4107
|
+
log13("new state", {
|
|
4108
|
+
state: SpaceState2[this._state]
|
|
3983
4109
|
}, {
|
|
3984
|
-
F:
|
|
3985
|
-
L:
|
|
4110
|
+
F: __dxlog_file16,
|
|
4111
|
+
L: 209,
|
|
3986
4112
|
S: this,
|
|
3987
4113
|
C: (f, a) => f(...a)
|
|
3988
4114
|
});
|
|
@@ -3995,12 +4121,12 @@ var DataSpace = class {
|
|
|
3995
4121
|
}
|
|
3996
4122
|
async _close() {
|
|
3997
4123
|
await this._callbacks.beforeClose?.();
|
|
3998
|
-
this._state =
|
|
3999
|
-
|
|
4000
|
-
state:
|
|
4124
|
+
this._state = SpaceState2.CLOSED;
|
|
4125
|
+
log13("new state", {
|
|
4126
|
+
state: SpaceState2[this._state]
|
|
4001
4127
|
}, {
|
|
4002
|
-
F:
|
|
4003
|
-
L:
|
|
4128
|
+
F: __dxlog_file16,
|
|
4129
|
+
L: 223,
|
|
4004
4130
|
S: this,
|
|
4005
4131
|
C: (f, a) => f(...a)
|
|
4006
4132
|
});
|
|
@@ -4011,7 +4137,7 @@ var DataSpace = class {
|
|
|
4011
4137
|
await this._inner.spaceState.removeCredentialProcessor(this._automergeSpaceState);
|
|
4012
4138
|
await this._inner.spaceState.removeCredentialProcessor(this._notarizationPlugin);
|
|
4013
4139
|
await this._notarizationPlugin.close();
|
|
4014
|
-
await this._presence.
|
|
4140
|
+
await this._presence.close();
|
|
4015
4141
|
await this._gossip.close();
|
|
4016
4142
|
}
|
|
4017
4143
|
async postMessage(channel, message) {
|
|
@@ -4030,26 +4156,26 @@ var DataSpace = class {
|
|
|
4030
4156
|
await this.initializeDataPipeline();
|
|
4031
4157
|
} catch (err) {
|
|
4032
4158
|
if (err instanceof CancelledError || err instanceof ContextDisposedError3) {
|
|
4033
|
-
|
|
4034
|
-
F:
|
|
4035
|
-
L:
|
|
4159
|
+
log13("data pipeline initialization cancelled", err, {
|
|
4160
|
+
F: __dxlog_file16,
|
|
4161
|
+
L: 256,
|
|
4036
4162
|
S: this,
|
|
4037
4163
|
C: (f, a) => f(...a)
|
|
4038
4164
|
});
|
|
4039
4165
|
return;
|
|
4040
4166
|
}
|
|
4041
|
-
|
|
4042
|
-
F:
|
|
4043
|
-
L:
|
|
4167
|
+
log13.error("Error initializing data pipeline", err, {
|
|
4168
|
+
F: __dxlog_file16,
|
|
4169
|
+
L: 260,
|
|
4044
4170
|
S: this,
|
|
4045
4171
|
C: (f, a) => f(...a)
|
|
4046
4172
|
});
|
|
4047
|
-
this._state =
|
|
4048
|
-
|
|
4049
|
-
state:
|
|
4173
|
+
this._state = SpaceState2.ERROR;
|
|
4174
|
+
log13("new state", {
|
|
4175
|
+
state: SpaceState2[this._state]
|
|
4050
4176
|
}, {
|
|
4051
|
-
F:
|
|
4052
|
-
L:
|
|
4177
|
+
F: __dxlog_file16,
|
|
4178
|
+
L: 262,
|
|
4053
4179
|
S: this,
|
|
4054
4180
|
C: (f, a) => f(...a)
|
|
4055
4181
|
});
|
|
@@ -4061,15 +4187,15 @@ var DataSpace = class {
|
|
|
4061
4187
|
});
|
|
4062
4188
|
}
|
|
4063
4189
|
async initializeDataPipeline() {
|
|
4064
|
-
if (this._state !==
|
|
4190
|
+
if (this._state !== SpaceState2.CONTROL_ONLY) {
|
|
4065
4191
|
throw new SystemError("Invalid operation");
|
|
4066
4192
|
}
|
|
4067
|
-
this._state =
|
|
4068
|
-
|
|
4069
|
-
state:
|
|
4193
|
+
this._state = SpaceState2.INITIALIZING;
|
|
4194
|
+
log13("new state", {
|
|
4195
|
+
state: SpaceState2[this._state]
|
|
4070
4196
|
}, {
|
|
4071
|
-
F:
|
|
4072
|
-
L:
|
|
4197
|
+
F: __dxlog_file16,
|
|
4198
|
+
L: 278,
|
|
4073
4199
|
S: this,
|
|
4074
4200
|
C: (f, a) => f(...a)
|
|
4075
4201
|
});
|
|
@@ -4077,19 +4203,19 @@ var DataSpace = class {
|
|
|
4077
4203
|
await sleep2(1);
|
|
4078
4204
|
this._automergeSpaceState.startProcessingRootDocs();
|
|
4079
4205
|
await cancelWithContext4(this._ctx, this.automergeSpaceState.ensureEpochInitialized());
|
|
4080
|
-
|
|
4081
|
-
F:
|
|
4082
|
-
L:
|
|
4206
|
+
log13("data pipeline ready", void 0, {
|
|
4207
|
+
F: __dxlog_file16,
|
|
4208
|
+
L: 290,
|
|
4083
4209
|
S: this,
|
|
4084
4210
|
C: (f, a) => f(...a)
|
|
4085
4211
|
});
|
|
4086
4212
|
await this._callbacks.beforeReady?.();
|
|
4087
|
-
this._state =
|
|
4088
|
-
|
|
4089
|
-
state:
|
|
4213
|
+
this._state = SpaceState2.READY;
|
|
4214
|
+
log13("new state", {
|
|
4215
|
+
state: SpaceState2[this._state]
|
|
4090
4216
|
}, {
|
|
4091
|
-
F:
|
|
4092
|
-
L:
|
|
4217
|
+
F: __dxlog_file16,
|
|
4218
|
+
L: 294,
|
|
4093
4219
|
S: this,
|
|
4094
4220
|
C: (f, a) => f(...a)
|
|
4095
4221
|
});
|
|
@@ -4103,9 +4229,9 @@ var DataSpace = class {
|
|
|
4103
4229
|
});
|
|
4104
4230
|
this.metrics.controlPipelineReady = /* @__PURE__ */ new Date();
|
|
4105
4231
|
await this._createWritableFeeds();
|
|
4106
|
-
|
|
4107
|
-
F:
|
|
4108
|
-
L:
|
|
4232
|
+
log13("writable feeds created", void 0, {
|
|
4233
|
+
F: __dxlog_file16,
|
|
4234
|
+
L: 310,
|
|
4109
4235
|
S: this,
|
|
4110
4236
|
C: (f, a) => f(...a)
|
|
4111
4237
|
});
|
|
@@ -4163,12 +4289,12 @@ var DataSpace = class {
|
|
|
4163
4289
|
}
|
|
4164
4290
|
}
|
|
4165
4291
|
_onNewAutomergeRoot(rootUrl) {
|
|
4166
|
-
|
|
4292
|
+
log13("loading automerge root doc for space", {
|
|
4167
4293
|
space: this.key,
|
|
4168
4294
|
rootUrl
|
|
4169
4295
|
}, {
|
|
4170
|
-
F:
|
|
4171
|
-
L:
|
|
4296
|
+
F: __dxlog_file16,
|
|
4297
|
+
L: 376,
|
|
4172
4298
|
S: this,
|
|
4173
4299
|
C: (f, a) => f(...a)
|
|
4174
4300
|
});
|
|
@@ -4193,12 +4319,12 @@ var DataSpace = class {
|
|
|
4193
4319
|
if (!this._echoHost.roots.has(handle.documentId)) {
|
|
4194
4320
|
await this._echoHost.openSpaceRoot(handle.url);
|
|
4195
4321
|
} else {
|
|
4196
|
-
|
|
4322
|
+
log13.warn("echo database root already exists", {
|
|
4197
4323
|
space: this.key,
|
|
4198
4324
|
rootUrl
|
|
4199
4325
|
}, {
|
|
4200
|
-
F:
|
|
4201
|
-
L:
|
|
4326
|
+
F: __dxlog_file16,
|
|
4327
|
+
L: 403,
|
|
4202
4328
|
S: this,
|
|
4203
4329
|
C: (f, a) => f(...a)
|
|
4204
4330
|
});
|
|
@@ -4207,13 +4333,13 @@ var DataSpace = class {
|
|
|
4207
4333
|
if (err instanceof ContextDisposedError3) {
|
|
4208
4334
|
return;
|
|
4209
4335
|
}
|
|
4210
|
-
|
|
4336
|
+
log13.warn("error loading automerge root doc", {
|
|
4211
4337
|
space: this.key,
|
|
4212
4338
|
rootUrl,
|
|
4213
4339
|
err
|
|
4214
4340
|
}, {
|
|
4215
|
-
F:
|
|
4216
|
-
L:
|
|
4341
|
+
F: __dxlog_file16,
|
|
4342
|
+
L: 409,
|
|
4217
4343
|
S: this,
|
|
4218
4344
|
C: (f, a) => f(...a)
|
|
4219
4345
|
});
|
|
@@ -4244,7 +4370,7 @@ var DataSpace = class {
|
|
|
4244
4370
|
epoch = {
|
|
4245
4371
|
previousId: this._automergeSpaceState.lastEpoch?.id,
|
|
4246
4372
|
number: (this._automergeSpaceState.lastEpoch?.subject.assertion.number ?? -1) + 1,
|
|
4247
|
-
timeframe: this._automergeSpaceState.lastEpoch?.subject.assertion.timeframe ?? new
|
|
4373
|
+
timeframe: this._automergeSpaceState.lastEpoch?.subject.assertion.timeframe ?? new Timeframe3(),
|
|
4248
4374
|
automergeRoot: this._automergeSpaceState.lastEpoch?.subject.assertion?.automergeRoot
|
|
4249
4375
|
};
|
|
4250
4376
|
}
|
|
@@ -4255,7 +4381,7 @@ var DataSpace = class {
|
|
|
4255
4381
|
epoch = {
|
|
4256
4382
|
previousId: this._automergeSpaceState.lastEpoch?.id,
|
|
4257
4383
|
number: (this._automergeSpaceState.lastEpoch?.subject.assertion.number ?? -1) + 1,
|
|
4258
|
-
timeframe: this._automergeSpaceState.lastEpoch?.subject.assertion.timeframe ?? new
|
|
4384
|
+
timeframe: this._automergeSpaceState.lastEpoch?.subject.assertion.timeframe ?? new Timeframe3(),
|
|
4259
4385
|
automergeRoot: document.url
|
|
4260
4386
|
};
|
|
4261
4387
|
}
|
|
@@ -4266,9 +4392,12 @@ var DataSpace = class {
|
|
|
4266
4392
|
const rootHandle = this._echoHost.automergeRepo.find(currentRootUrl);
|
|
4267
4393
|
await cancelWithContext4(this._ctx, asyncTimeout2(rootHandle.whenReady(), 1e4));
|
|
4268
4394
|
const newRoot = this._echoHost.automergeRepo.create(rootHandle.docSync());
|
|
4395
|
+
await this._echoHost.automergeRepo.flush([
|
|
4396
|
+
newRoot.documentId
|
|
4397
|
+
]);
|
|
4269
4398
|
invariant13(typeof newRoot.url === "string" && newRoot.url.length > 0, void 0, {
|
|
4270
|
-
F:
|
|
4271
|
-
L:
|
|
4399
|
+
F: __dxlog_file16,
|
|
4400
|
+
L: 460,
|
|
4272
4401
|
S: this,
|
|
4273
4402
|
A: [
|
|
4274
4403
|
"typeof newRoot.url === 'string' && newRoot.url.length > 0",
|
|
@@ -4278,16 +4407,16 @@ var DataSpace = class {
|
|
|
4278
4407
|
epoch = {
|
|
4279
4408
|
previousId: this._automergeSpaceState.lastEpoch?.id,
|
|
4280
4409
|
number: (this._automergeSpaceState.lastEpoch?.subject.assertion.number ?? -1) + 1,
|
|
4281
|
-
timeframe: this._automergeSpaceState.lastEpoch?.subject.assertion.timeframe ?? new
|
|
4410
|
+
timeframe: this._automergeSpaceState.lastEpoch?.subject.assertion.timeframe ?? new Timeframe3(),
|
|
4282
4411
|
automergeRoot: newRoot.url
|
|
4283
4412
|
};
|
|
4284
4413
|
}
|
|
4285
4414
|
break;
|
|
4286
4415
|
case CreateEpochRequest.Migration.FRAGMENT_AUTOMERGE_ROOT:
|
|
4287
4416
|
{
|
|
4288
|
-
|
|
4289
|
-
F:
|
|
4290
|
-
L:
|
|
4417
|
+
log13.info("Fragmenting", void 0, {
|
|
4418
|
+
F: __dxlog_file16,
|
|
4419
|
+
L: 472,
|
|
4291
4420
|
S: this,
|
|
4292
4421
|
C: (f, a) => f(...a)
|
|
4293
4422
|
});
|
|
@@ -4298,8 +4427,8 @@ var DataSpace = class {
|
|
|
4298
4427
|
const properties = findPropertiesObject(rootHandle.docSync());
|
|
4299
4428
|
const otherObjects = objects.filter(([key]) => key !== properties?.[0]);
|
|
4300
4429
|
invariant13(properties, "Properties not found", {
|
|
4301
|
-
F:
|
|
4302
|
-
L:
|
|
4430
|
+
F: __dxlog_file16,
|
|
4431
|
+
L: 482,
|
|
4303
4432
|
S: this,
|
|
4304
4433
|
A: [
|
|
4305
4434
|
"properties",
|
|
@@ -4314,8 +4443,8 @@ var DataSpace = class {
|
|
|
4314
4443
|
};
|
|
4315
4444
|
const newRoot = this._echoHost.automergeRepo.create(newSpaceDoc);
|
|
4316
4445
|
invariant13(typeof newRoot.url === "string" && newRoot.url.length > 0, void 0, {
|
|
4317
|
-
F:
|
|
4318
|
-
L:
|
|
4446
|
+
F: __dxlog_file16,
|
|
4447
|
+
L: 487,
|
|
4319
4448
|
S: this,
|
|
4320
4449
|
A: [
|
|
4321
4450
|
"typeof newRoot.url === 'string' && newRoot.url.length > 0",
|
|
@@ -4338,11 +4467,30 @@ var DataSpace = class {
|
|
|
4338
4467
|
epoch = {
|
|
4339
4468
|
previousId: this._automergeSpaceState.lastEpoch?.id,
|
|
4340
4469
|
number: (this._automergeSpaceState.lastEpoch?.subject.assertion.number ?? -1) + 1,
|
|
4341
|
-
timeframe: this._automergeSpaceState.lastEpoch?.subject.assertion.timeframe ?? new
|
|
4470
|
+
timeframe: this._automergeSpaceState.lastEpoch?.subject.assertion.timeframe ?? new Timeframe3(),
|
|
4342
4471
|
automergeRoot: newRoot.url
|
|
4343
4472
|
};
|
|
4344
4473
|
}
|
|
4345
4474
|
break;
|
|
4475
|
+
case CreateEpochRequest.Migration.REPLACE_AUTOMERGE_ROOT:
|
|
4476
|
+
{
|
|
4477
|
+
invariant13(options.newAutomergeRoot, void 0, {
|
|
4478
|
+
F: __dxlog_file16,
|
|
4479
|
+
L: 517,
|
|
4480
|
+
S: this,
|
|
4481
|
+
A: [
|
|
4482
|
+
"options.newAutomergeRoot",
|
|
4483
|
+
""
|
|
4484
|
+
]
|
|
4485
|
+
});
|
|
4486
|
+
epoch = {
|
|
4487
|
+
previousId: this._automergeSpaceState.lastEpoch?.id,
|
|
4488
|
+
number: (this._automergeSpaceState.lastEpoch?.subject.assertion.number ?? -1) + 1,
|
|
4489
|
+
timeframe: this._automergeSpaceState.lastEpoch?.subject.assertion.timeframe ?? new Timeframe3(),
|
|
4490
|
+
automergeRoot: options.newAutomergeRoot
|
|
4491
|
+
};
|
|
4492
|
+
}
|
|
4493
|
+
break;
|
|
4346
4494
|
}
|
|
4347
4495
|
if (!epoch) {
|
|
4348
4496
|
return;
|
|
@@ -4358,33 +4506,39 @@ var DataSpace = class {
|
|
|
4358
4506
|
})
|
|
4359
4507
|
}
|
|
4360
4508
|
});
|
|
4361
|
-
await this.inner.controlPipeline.state.waitUntilTimeframe(new
|
|
4509
|
+
await this.inner.controlPipeline.state.waitUntilTimeframe(new Timeframe3([
|
|
4362
4510
|
[
|
|
4363
4511
|
receipt.feedKey,
|
|
4364
4512
|
receipt.seq
|
|
4365
4513
|
]
|
|
4366
4514
|
]));
|
|
4515
|
+
await this._echoHost.updateIndexes();
|
|
4367
4516
|
}
|
|
4368
4517
|
async activate() {
|
|
4369
|
-
if (
|
|
4518
|
+
if (![
|
|
4519
|
+
SpaceState2.CLOSED,
|
|
4520
|
+
SpaceState2.INACTIVE
|
|
4521
|
+
].includes(this._state)) {
|
|
4370
4522
|
return;
|
|
4371
4523
|
}
|
|
4372
|
-
await this._metadataStore.setSpaceState(this.key,
|
|
4524
|
+
await this._metadataStore.setSpaceState(this.key, SpaceState2.ACTIVE);
|
|
4373
4525
|
await this._open();
|
|
4374
4526
|
this.initializeDataPipelineAsync();
|
|
4375
4527
|
}
|
|
4376
4528
|
async deactivate() {
|
|
4377
|
-
if (this._state ===
|
|
4529
|
+
if (this._state === SpaceState2.INACTIVE) {
|
|
4378
4530
|
return;
|
|
4379
4531
|
}
|
|
4380
|
-
await this._metadataStore.setSpaceState(this.key,
|
|
4381
|
-
|
|
4382
|
-
|
|
4383
|
-
|
|
4384
|
-
|
|
4532
|
+
await this._metadataStore.setSpaceState(this.key, SpaceState2.INACTIVE);
|
|
4533
|
+
if (this._state !== SpaceState2.CLOSED) {
|
|
4534
|
+
await this._close();
|
|
4535
|
+
}
|
|
4536
|
+
this._state = SpaceState2.INACTIVE;
|
|
4537
|
+
log13("new state", {
|
|
4538
|
+
state: SpaceState2[this._state]
|
|
4385
4539
|
}, {
|
|
4386
|
-
F:
|
|
4387
|
-
L:
|
|
4540
|
+
F: __dxlog_file16,
|
|
4541
|
+
L: 571,
|
|
4388
4542
|
S: this,
|
|
4389
4543
|
C: (f, a) => f(...a)
|
|
4390
4544
|
});
|
|
@@ -4402,7 +4556,7 @@ _ts_decorate4([
|
|
|
4402
4556
|
], DataSpace.prototype, "key", null);
|
|
4403
4557
|
_ts_decorate4([
|
|
4404
4558
|
trace6.info({
|
|
4405
|
-
enum:
|
|
4559
|
+
enum: SpaceState2
|
|
4406
4560
|
})
|
|
4407
4561
|
], DataSpace.prototype, "state", null);
|
|
4408
4562
|
_ts_decorate4([
|
|
@@ -4454,24 +4608,27 @@ var findPropertiesObject = (spaceDoc) => {
|
|
|
4454
4608
|
|
|
4455
4609
|
// packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts
|
|
4456
4610
|
import { Event as Event7, synchronized as synchronized2, trackLeaks as trackLeaks2 } from "@dxos/async";
|
|
4611
|
+
import { PropertiesType } from "@dxos/client-protocol";
|
|
4457
4612
|
import { cancelWithContext as cancelWithContext5, Context as Context9 } from "@dxos/context";
|
|
4458
|
-
import { getCredentialAssertion as
|
|
4613
|
+
import { getCredentialAssertion as getCredentialAssertion3 } from "@dxos/credentials";
|
|
4459
4614
|
import { AuthStatus } from "@dxos/echo-pipeline";
|
|
4615
|
+
import { encodeReference } from "@dxos/echo-protocol";
|
|
4616
|
+
import { generateEchoId, getTypeReference } from "@dxos/echo-schema";
|
|
4460
4617
|
import { invariant as invariant14 } from "@dxos/invariant";
|
|
4461
4618
|
import { PublicKey as PublicKey11 } from "@dxos/keys";
|
|
4462
|
-
import { log as
|
|
4619
|
+
import { log as log14 } from "@dxos/log";
|
|
4463
4620
|
import { trace as Trace2 } from "@dxos/protocols";
|
|
4464
|
-
import { Invitation as Invitation7, SpaceState as
|
|
4621
|
+
import { Invitation as Invitation7, SpaceState as SpaceState3 } from "@dxos/protocols/proto/dxos/client/services";
|
|
4465
4622
|
import { SpaceMember as SpaceMember6 } from "@dxos/protocols/proto/dxos/halo/credentials";
|
|
4466
4623
|
import { Gossip as Gossip2, Presence as Presence2 } from "@dxos/teleport-extension-gossip";
|
|
4467
4624
|
import { trace as trace7 } from "@dxos/tracing";
|
|
4468
|
-
import { ComplexMap as ComplexMap3, deferFunction as deferFunction2, forEachAsync } from "@dxos/util";
|
|
4625
|
+
import { assignDeep as assignDeep2, ComplexMap as ComplexMap3, deferFunction as deferFunction2, forEachAsync } from "@dxos/util";
|
|
4469
4626
|
|
|
4470
4627
|
// packages/sdk/client-services/src/packlets/spaces/genesis.ts
|
|
4471
4628
|
import { createCredential } from "@dxos/credentials";
|
|
4472
4629
|
import { failUndefined } from "@dxos/debug";
|
|
4473
4630
|
import { AdmittedFeed as AdmittedFeed4, SpaceMember as SpaceMember5 } from "@dxos/protocols/proto/dxos/halo/credentials";
|
|
4474
|
-
import { Timeframe as
|
|
4631
|
+
import { Timeframe as Timeframe4 } from "@dxos/timeframe";
|
|
4475
4632
|
var spaceGenesis = async (keyring, signingContext, space, automergeRoot) => {
|
|
4476
4633
|
const credentials = [
|
|
4477
4634
|
await createCredential({
|
|
@@ -4521,7 +4678,7 @@ var spaceGenesis = async (keyring, signingContext, space, automergeRoot) => {
|
|
|
4521
4678
|
"@type": "dxos.halo.credentials.Epoch",
|
|
4522
4679
|
number: 0,
|
|
4523
4680
|
previousId: void 0,
|
|
4524
|
-
timeframe: new
|
|
4681
|
+
timeframe: new Timeframe4(),
|
|
4525
4682
|
snapshotCid: void 0,
|
|
4526
4683
|
automergeRoot
|
|
4527
4684
|
}
|
|
@@ -4548,11 +4705,12 @@ function _ts_decorate5(decorators, target, key, desc) {
|
|
|
4548
4705
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
4549
4706
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4550
4707
|
}
|
|
4551
|
-
var
|
|
4708
|
+
var __dxlog_file17 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts";
|
|
4552
4709
|
var PRESENCE_ANNOUNCE_INTERVAL = 1e4;
|
|
4553
4710
|
var PRESENCE_OFFLINE_TIMEOUT = 2e4;
|
|
4711
|
+
var DEFAULT_SPACE_KEY = "__DEFAULT__";
|
|
4554
4712
|
var DataSpaceManager = class {
|
|
4555
|
-
constructor(_spaceManager, _metadataStore, _keyring, _signingContext, _feedStore, _echoHost, _invitationsManager,
|
|
4713
|
+
constructor(_spaceManager, _metadataStore, _keyring, _signingContext, _feedStore, _echoHost, _invitationsManager, _params) {
|
|
4556
4714
|
this._spaceManager = _spaceManager;
|
|
4557
4715
|
this._metadataStore = _metadataStore;
|
|
4558
4716
|
this._keyring = _keyring;
|
|
@@ -4560,14 +4718,12 @@ var DataSpaceManager = class {
|
|
|
4560
4718
|
this._feedStore = _feedStore;
|
|
4561
4719
|
this._echoHost = _echoHost;
|
|
4562
4720
|
this._invitationsManager = _invitationsManager;
|
|
4721
|
+
this._params = _params;
|
|
4563
4722
|
this._ctx = new Context9();
|
|
4564
4723
|
this.updated = new Event7();
|
|
4565
4724
|
this._spaces = new ComplexMap3(PublicKey11.hash);
|
|
4566
4725
|
this._isOpen = false;
|
|
4567
4726
|
this._instanceId = PublicKey11.random().toHex();
|
|
4568
|
-
const { spaceMemberPresenceAnnounceInterval = PRESENCE_ANNOUNCE_INTERVAL, spaceMemberPresenceOfflineTimeout = PRESENCE_OFFLINE_TIMEOUT } = params ?? {};
|
|
4569
|
-
this._spaceMemberPresenceAnnounceInterval = spaceMemberPresenceAnnounceInterval;
|
|
4570
|
-
this._spaceMemberPresenceOfflineTimeout = spaceMemberPresenceOfflineTimeout;
|
|
4571
4727
|
trace7.diagnostic({
|
|
4572
4728
|
id: "spaces",
|
|
4573
4729
|
name: "Spaces",
|
|
@@ -4579,7 +4735,7 @@ var DataSpaceManager = class {
|
|
|
4579
4735
|
const properties = rootDoc && findPropertiesObject(rootDoc);
|
|
4580
4736
|
return {
|
|
4581
4737
|
key: space.key.toHex(),
|
|
4582
|
-
state:
|
|
4738
|
+
state: SpaceState3[space.state],
|
|
4583
4739
|
name: properties?.[1].data.name ?? null,
|
|
4584
4740
|
inlineObjects: rootDoc ? Object.keys(rootDoc.objects ?? {}).length : null,
|
|
4585
4741
|
linkedObjects: rootDoc ? Object.keys(rootDoc.links ?? {}).length : null,
|
|
@@ -4596,46 +4752,46 @@ var DataSpaceManager = class {
|
|
|
4596
4752
|
return this._spaces;
|
|
4597
4753
|
}
|
|
4598
4754
|
async open() {
|
|
4599
|
-
|
|
4600
|
-
F:
|
|
4601
|
-
L:
|
|
4755
|
+
log14("open", void 0, {
|
|
4756
|
+
F: __dxlog_file17,
|
|
4757
|
+
L: 140,
|
|
4602
4758
|
S: this,
|
|
4603
4759
|
C: (f, a) => f(...a)
|
|
4604
4760
|
});
|
|
4605
|
-
|
|
4761
|
+
log14.trace("dxos.echo.data-space-manager.open", Trace2.begin({
|
|
4606
4762
|
id: this._instanceId
|
|
4607
4763
|
}), {
|
|
4608
|
-
F:
|
|
4609
|
-
L:
|
|
4764
|
+
F: __dxlog_file17,
|
|
4765
|
+
L: 141,
|
|
4610
4766
|
S: this,
|
|
4611
4767
|
C: (f, a) => f(...a)
|
|
4612
4768
|
});
|
|
4613
|
-
|
|
4769
|
+
log14("metadata loaded", {
|
|
4614
4770
|
spaces: this._metadataStore.spaces.length
|
|
4615
4771
|
}, {
|
|
4616
|
-
F:
|
|
4617
|
-
L:
|
|
4772
|
+
F: __dxlog_file17,
|
|
4773
|
+
L: 142,
|
|
4618
4774
|
S: this,
|
|
4619
4775
|
C: (f, a) => f(...a)
|
|
4620
4776
|
});
|
|
4621
4777
|
await forEachAsync(this._metadataStore.spaces, async (spaceMetadata) => {
|
|
4622
4778
|
try {
|
|
4623
|
-
|
|
4779
|
+
log14("load space", {
|
|
4624
4780
|
spaceMetadata
|
|
4625
4781
|
}, {
|
|
4626
|
-
F:
|
|
4627
|
-
L:
|
|
4782
|
+
F: __dxlog_file17,
|
|
4783
|
+
L: 146,
|
|
4628
4784
|
S: this,
|
|
4629
4785
|
C: (f, a) => f(...a)
|
|
4630
4786
|
});
|
|
4631
4787
|
await this._constructSpace(spaceMetadata);
|
|
4632
4788
|
} catch (err) {
|
|
4633
|
-
|
|
4789
|
+
log14.error("Error loading space", {
|
|
4634
4790
|
spaceMetadata,
|
|
4635
4791
|
err
|
|
4636
4792
|
}, {
|
|
4637
|
-
F:
|
|
4638
|
-
L:
|
|
4793
|
+
F: __dxlog_file17,
|
|
4794
|
+
L: 149,
|
|
4639
4795
|
S: this,
|
|
4640
4796
|
C: (f, a) => f(...a)
|
|
4641
4797
|
});
|
|
@@ -4643,24 +4799,19 @@ var DataSpaceManager = class {
|
|
|
4643
4799
|
});
|
|
4644
4800
|
this._isOpen = true;
|
|
4645
4801
|
this.updated.emit();
|
|
4646
|
-
|
|
4647
|
-
if (space.state !== SpaceState2.INACTIVE) {
|
|
4648
|
-
space.initializeDataPipelineAsync();
|
|
4649
|
-
}
|
|
4650
|
-
}
|
|
4651
|
-
log13.trace("dxos.echo.data-space-manager.open", Trace2.end({
|
|
4802
|
+
log14.trace("dxos.echo.data-space-manager.open", Trace2.end({
|
|
4652
4803
|
id: this._instanceId
|
|
4653
4804
|
}), {
|
|
4654
|
-
F:
|
|
4655
|
-
L:
|
|
4805
|
+
F: __dxlog_file17,
|
|
4806
|
+
L: 156,
|
|
4656
4807
|
S: this,
|
|
4657
4808
|
C: (f, a) => f(...a)
|
|
4658
4809
|
});
|
|
4659
4810
|
}
|
|
4660
4811
|
async close() {
|
|
4661
|
-
|
|
4662
|
-
F:
|
|
4663
|
-
L:
|
|
4812
|
+
log14("close", void 0, {
|
|
4813
|
+
F: __dxlog_file17,
|
|
4814
|
+
L: 161,
|
|
4664
4815
|
S: this,
|
|
4665
4816
|
C: (f, a) => f(...a)
|
|
4666
4817
|
});
|
|
@@ -4669,14 +4820,15 @@ var DataSpaceManager = class {
|
|
|
4669
4820
|
for (const space of this._spaces.values()) {
|
|
4670
4821
|
await space.close();
|
|
4671
4822
|
}
|
|
4823
|
+
this._spaces.clear();
|
|
4672
4824
|
}
|
|
4673
4825
|
/**
|
|
4674
4826
|
* Creates a new space writing the genesis credentials to the control feed.
|
|
4675
4827
|
*/
|
|
4676
4828
|
async createSpace() {
|
|
4677
4829
|
invariant14(this._isOpen, "Not open.", {
|
|
4678
|
-
F:
|
|
4679
|
-
L:
|
|
4830
|
+
F: __dxlog_file17,
|
|
4831
|
+
L: 175,
|
|
4680
4832
|
S: this,
|
|
4681
4833
|
A: [
|
|
4682
4834
|
"this._isOpen",
|
|
@@ -4691,24 +4843,25 @@ var DataSpaceManager = class {
|
|
|
4691
4843
|
genesisFeedKey: controlFeedKey,
|
|
4692
4844
|
controlFeedKey,
|
|
4693
4845
|
dataFeedKey,
|
|
4694
|
-
state:
|
|
4846
|
+
state: SpaceState3.ACTIVE
|
|
4695
4847
|
};
|
|
4696
|
-
|
|
4848
|
+
log14("creating space...", {
|
|
4697
4849
|
spaceKey
|
|
4698
4850
|
}, {
|
|
4699
|
-
F:
|
|
4700
|
-
L:
|
|
4851
|
+
F: __dxlog_file17,
|
|
4852
|
+
L: 187,
|
|
4701
4853
|
S: this,
|
|
4702
4854
|
C: (f, a) => f(...a)
|
|
4703
4855
|
});
|
|
4704
4856
|
const root = await this._echoHost.createSpaceRoot(spaceKey);
|
|
4705
4857
|
const space = await this._constructSpace(metadata);
|
|
4858
|
+
await space.open();
|
|
4706
4859
|
const credentials = await spaceGenesis(this._keyring, this._signingContext, space.inner, root.url);
|
|
4707
4860
|
await this._metadataStore.addSpace(metadata);
|
|
4708
4861
|
const memberCredential = credentials[1];
|
|
4709
|
-
invariant14(
|
|
4710
|
-
F:
|
|
4711
|
-
L:
|
|
4862
|
+
invariant14(getCredentialAssertion3(memberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
|
|
4863
|
+
F: __dxlog_file17,
|
|
4864
|
+
L: 197,
|
|
4712
4865
|
S: this,
|
|
4713
4866
|
A: [
|
|
4714
4867
|
"getCredentialAssertion(memberCredential)['@type'] === 'dxos.halo.credentials.SpaceMember'",
|
|
@@ -4720,19 +4873,63 @@ var DataSpaceManager = class {
|
|
|
4720
4873
|
this.updated.emit();
|
|
4721
4874
|
return space;
|
|
4722
4875
|
}
|
|
4876
|
+
async isDefaultSpace(space) {
|
|
4877
|
+
const rootDoc = await this._getSpaceRootDocument(space);
|
|
4878
|
+
const [_, properties] = findPropertiesObject(rootDoc.docSync()) ?? [];
|
|
4879
|
+
return properties?.data?.[DEFAULT_SPACE_KEY] === this._signingContext.identityKey.toHex();
|
|
4880
|
+
}
|
|
4881
|
+
async createDefaultSpace() {
|
|
4882
|
+
const space = await this.createSpace();
|
|
4883
|
+
const document = await this._getSpaceRootDocument(space);
|
|
4884
|
+
const properties = {
|
|
4885
|
+
system: {
|
|
4886
|
+
type: encodeReference(getTypeReference(PropertiesType))
|
|
4887
|
+
},
|
|
4888
|
+
data: {
|
|
4889
|
+
[DEFAULT_SPACE_KEY]: this._signingContext.identityKey.toHex()
|
|
4890
|
+
},
|
|
4891
|
+
meta: {
|
|
4892
|
+
keys: []
|
|
4893
|
+
}
|
|
4894
|
+
};
|
|
4895
|
+
const propertiesId = generateEchoId();
|
|
4896
|
+
document.change((doc) => {
|
|
4897
|
+
assignDeep2(doc, [
|
|
4898
|
+
"objects",
|
|
4899
|
+
propertiesId
|
|
4900
|
+
], properties);
|
|
4901
|
+
});
|
|
4902
|
+
await this._echoHost.flush();
|
|
4903
|
+
return space;
|
|
4904
|
+
}
|
|
4905
|
+
async _getSpaceRootDocument(space) {
|
|
4906
|
+
const automergeIndex = space.automergeSpaceState.rootUrl;
|
|
4907
|
+
invariant14(automergeIndex, void 0, {
|
|
4908
|
+
F: __dxlog_file17,
|
|
4909
|
+
L: 240,
|
|
4910
|
+
S: this,
|
|
4911
|
+
A: [
|
|
4912
|
+
"automergeIndex",
|
|
4913
|
+
""
|
|
4914
|
+
]
|
|
4915
|
+
});
|
|
4916
|
+
const document = this._echoHost.automergeRepo.find(automergeIndex);
|
|
4917
|
+
await document.whenReady();
|
|
4918
|
+
return document;
|
|
4919
|
+
}
|
|
4723
4920
|
// TODO(burdon): Rename join space.
|
|
4724
4921
|
async acceptSpace(opts) {
|
|
4725
|
-
|
|
4922
|
+
log14("accept space", {
|
|
4726
4923
|
opts
|
|
4727
4924
|
}, {
|
|
4728
|
-
F:
|
|
4729
|
-
L:
|
|
4925
|
+
F: __dxlog_file17,
|
|
4926
|
+
L: 249,
|
|
4730
4927
|
S: this,
|
|
4731
4928
|
C: (f, a) => f(...a)
|
|
4732
4929
|
});
|
|
4733
4930
|
invariant14(this._isOpen, "Not open.", {
|
|
4734
|
-
F:
|
|
4735
|
-
L:
|
|
4931
|
+
F: __dxlog_file17,
|
|
4932
|
+
L: 250,
|
|
4736
4933
|
S: this,
|
|
4737
4934
|
A: [
|
|
4738
4935
|
"this._isOpen",
|
|
@@ -4740,8 +4937,8 @@ var DataSpaceManager = class {
|
|
|
4740
4937
|
]
|
|
4741
4938
|
});
|
|
4742
4939
|
invariant14(!this._spaces.has(opts.spaceKey), "Space already exists.", {
|
|
4743
|
-
F:
|
|
4744
|
-
L:
|
|
4940
|
+
F: __dxlog_file17,
|
|
4941
|
+
L: 251,
|
|
4745
4942
|
S: this,
|
|
4746
4943
|
A: [
|
|
4747
4944
|
"!this._spaces.has(opts.spaceKey)",
|
|
@@ -4755,6 +4952,7 @@ var DataSpaceManager = class {
|
|
|
4755
4952
|
dataTimeframe: opts.dataTimeframe
|
|
4756
4953
|
};
|
|
4757
4954
|
const space = await this._constructSpace(metadata);
|
|
4955
|
+
await space.open();
|
|
4758
4956
|
await this._metadataStore.addSpace(metadata);
|
|
4759
4957
|
space.initializeDataPipelineAsync();
|
|
4760
4958
|
this.updated.emit();
|
|
@@ -4768,15 +4966,15 @@ var DataSpaceManager = class {
|
|
|
4768
4966
|
async waitUntilSpaceReady(spaceKey) {
|
|
4769
4967
|
await cancelWithContext5(this._ctx, this.updated.waitForCondition(() => {
|
|
4770
4968
|
const space = this._spaces.get(spaceKey);
|
|
4771
|
-
return !!space && space.state ===
|
|
4969
|
+
return !!space && space.state === SpaceState3.READY;
|
|
4772
4970
|
}));
|
|
4773
4971
|
}
|
|
4774
4972
|
async _constructSpace(metadata) {
|
|
4775
|
-
|
|
4973
|
+
log14("construct space", {
|
|
4776
4974
|
metadata
|
|
4777
4975
|
}, {
|
|
4778
|
-
F:
|
|
4779
|
-
L:
|
|
4976
|
+
F: __dxlog_file17,
|
|
4977
|
+
L: 285,
|
|
4780
4978
|
S: this,
|
|
4781
4979
|
C: (f, a) => f(...a)
|
|
4782
4980
|
});
|
|
@@ -4784,8 +4982,8 @@ var DataSpaceManager = class {
|
|
|
4784
4982
|
localPeerId: this._signingContext.deviceKey
|
|
4785
4983
|
});
|
|
4786
4984
|
const presence = new Presence2({
|
|
4787
|
-
announceInterval: this.
|
|
4788
|
-
offlineTimeout: this.
|
|
4985
|
+
announceInterval: this._params?.spaceMemberPresenceAnnounceInterval ?? PRESENCE_ANNOUNCE_INTERVAL,
|
|
4986
|
+
offlineTimeout: this._params?.spaceMemberPresenceOfflineTimeout ?? PRESENCE_OFFLINE_TIMEOUT,
|
|
4789
4987
|
identityKey: this._signingContext.identityKey,
|
|
4790
4988
|
gossip
|
|
4791
4989
|
});
|
|
@@ -4812,15 +5010,15 @@ var DataSpaceManager = class {
|
|
|
4812
5010
|
session.addExtension("dxos.mesh.teleport.automerge", this._echoHost.createReplicationExtension());
|
|
4813
5011
|
},
|
|
4814
5012
|
onAuthFailure: () => {
|
|
4815
|
-
|
|
4816
|
-
F:
|
|
4817
|
-
L:
|
|
5013
|
+
log14.warn("auth failure", void 0, {
|
|
5014
|
+
F: __dxlog_file17,
|
|
5015
|
+
L: 322,
|
|
4818
5016
|
S: this,
|
|
4819
5017
|
C: (f, a) => f(...a)
|
|
4820
5018
|
});
|
|
4821
5019
|
},
|
|
4822
5020
|
onMemberRolesChanged: async (members) => {
|
|
4823
|
-
if (dataSpace?.state ===
|
|
5021
|
+
if (dataSpace?.state === SpaceState3.READY) {
|
|
4824
5022
|
this._handleMemberRoleChanges(presence, space.protocol, members);
|
|
4825
5023
|
}
|
|
4826
5024
|
},
|
|
@@ -4833,7 +5031,7 @@ var DataSpaceManager = class {
|
|
|
4833
5031
|
dataFeed && await space.setDataFeed(dataFeed);
|
|
4834
5032
|
const dataSpace = new DataSpace({
|
|
4835
5033
|
inner: space,
|
|
4836
|
-
initialState: metadata.state ===
|
|
5034
|
+
initialState: metadata.state === SpaceState3.INACTIVE ? SpaceState3.INACTIVE : SpaceState3.CLOSED,
|
|
4837
5035
|
metadataStore: this._metadataStore,
|
|
4838
5036
|
gossip,
|
|
4839
5037
|
presence,
|
|
@@ -4843,22 +5041,22 @@ var DataSpaceManager = class {
|
|
|
4843
5041
|
signingContext: this._signingContext,
|
|
4844
5042
|
callbacks: {
|
|
4845
5043
|
beforeReady: async () => {
|
|
4846
|
-
|
|
5044
|
+
log14("before space ready", {
|
|
4847
5045
|
space: space.key
|
|
4848
5046
|
}, {
|
|
4849
|
-
F:
|
|
4850
|
-
L:
|
|
5047
|
+
F: __dxlog_file17,
|
|
5048
|
+
L: 349,
|
|
4851
5049
|
S: this,
|
|
4852
5050
|
C: (f, a) => f(...a)
|
|
4853
5051
|
});
|
|
4854
5052
|
},
|
|
4855
5053
|
afterReady: async () => {
|
|
4856
|
-
|
|
5054
|
+
log14("after space ready", {
|
|
4857
5055
|
space: space.key,
|
|
4858
5056
|
open: this._isOpen
|
|
4859
5057
|
}, {
|
|
4860
|
-
F:
|
|
4861
|
-
L:
|
|
5058
|
+
F: __dxlog_file17,
|
|
5059
|
+
L: 352,
|
|
4862
5060
|
S: this,
|
|
4863
5061
|
C: (f, a) => f(...a)
|
|
4864
5062
|
});
|
|
@@ -4873,11 +5071,11 @@ var DataSpaceManager = class {
|
|
|
4873
5071
|
}
|
|
4874
5072
|
},
|
|
4875
5073
|
beforeClose: async () => {
|
|
4876
|
-
|
|
5074
|
+
log14("before space close", {
|
|
4877
5075
|
space: space.key
|
|
4878
5076
|
}, {
|
|
4879
|
-
F:
|
|
4880
|
-
L:
|
|
5077
|
+
F: __dxlog_file17,
|
|
5078
|
+
L: 360,
|
|
4881
5079
|
S: this,
|
|
4882
5080
|
C: (f, a) => f(...a)
|
|
4883
5081
|
});
|
|
@@ -4886,13 +5084,10 @@ var DataSpaceManager = class {
|
|
|
4886
5084
|
cache: metadata.cache
|
|
4887
5085
|
});
|
|
4888
5086
|
presence.newPeer.on((peerState) => {
|
|
4889
|
-
if (dataSpace.state ===
|
|
5087
|
+
if (dataSpace.state === SpaceState3.READY) {
|
|
4890
5088
|
this._handleNewPeerConnected(space, peerState);
|
|
4891
5089
|
}
|
|
4892
5090
|
});
|
|
4893
|
-
if (metadata.state !== SpaceState2.INACTIVE) {
|
|
4894
|
-
await dataSpace.open();
|
|
4895
|
-
}
|
|
4896
5091
|
if (metadata.controlTimeframe) {
|
|
4897
5092
|
dataSpace.inner.controlPipeline.state.setTargetTimeframe(metadata.controlTimeframe);
|
|
4898
5093
|
}
|
|
@@ -4911,17 +5106,17 @@ var DataSpaceManager = class {
|
|
|
4911
5106
|
return (s && member.role === SpaceMember6.Role.REMOVED !== (s.authStatus === AuthStatus.FAILURE)) ?? false;
|
|
4912
5107
|
});
|
|
4913
5108
|
sessionsToClose.forEach((session) => {
|
|
4914
|
-
void session.close().catch(
|
|
5109
|
+
void session.close().catch(log14.error);
|
|
4915
5110
|
});
|
|
4916
5111
|
closedSessions += sessionsToClose.length;
|
|
4917
5112
|
}
|
|
4918
|
-
|
|
5113
|
+
log14("processed member role changes", {
|
|
4919
5114
|
roleChangeCount: memberInfo.length,
|
|
4920
5115
|
peersOnline: presence.getPeersOnline().length,
|
|
4921
5116
|
closedSessions
|
|
4922
5117
|
}, {
|
|
4923
|
-
F:
|
|
4924
|
-
L:
|
|
5118
|
+
F: __dxlog_file17,
|
|
5119
|
+
L: 396,
|
|
4925
5120
|
S: this,
|
|
4926
5121
|
C: (f, a) => f(...a)
|
|
4927
5122
|
});
|
|
@@ -4932,20 +5127,20 @@ var DataSpaceManager = class {
|
|
|
4932
5127
|
if (role === SpaceMember6.Role.REMOVED) {
|
|
4933
5128
|
const session = peerState.peerId && space.protocol.sessions.get(peerState.peerId);
|
|
4934
5129
|
if (session != null) {
|
|
4935
|
-
|
|
5130
|
+
log14("closing a session with a removed peer", {
|
|
4936
5131
|
peerId: peerState.peerId
|
|
4937
5132
|
}, {
|
|
4938
|
-
F:
|
|
4939
|
-
L:
|
|
5133
|
+
F: __dxlog_file17,
|
|
5134
|
+
L: 410,
|
|
4940
5135
|
S: this,
|
|
4941
5136
|
C: (f, a) => f(...a)
|
|
4942
5137
|
});
|
|
4943
|
-
void session.close().catch(
|
|
5138
|
+
void session.close().catch(log14.error);
|
|
4944
5139
|
}
|
|
4945
5140
|
}
|
|
4946
5141
|
}
|
|
4947
5142
|
async _handleInvitationStatusChange(dataSpace, delegatedInvitation, isActive) {
|
|
4948
|
-
if (dataSpace?.state !==
|
|
5143
|
+
if (dataSpace?.state !== SpaceState3.READY) {
|
|
4949
5144
|
return;
|
|
4950
5145
|
}
|
|
4951
5146
|
if (isActive) {
|
|
@@ -4999,15 +5194,15 @@ DataSpaceManager = _ts_decorate5([
|
|
|
4999
5194
|
// packages/sdk/client-services/src/packlets/spaces/spaces-service.ts
|
|
5000
5195
|
import { EventSubscriptions as EventSubscriptions2, UpdateScheduler, scheduleTask as scheduleTask6 } from "@dxos/async";
|
|
5001
5196
|
import { Stream as Stream10 } from "@dxos/codec-protobuf";
|
|
5002
|
-
import { createAdmissionCredentials as createAdmissionCredentials2, getCredentialAssertion as
|
|
5197
|
+
import { createAdmissionCredentials as createAdmissionCredentials2, getCredentialAssertion as getCredentialAssertion4 } from "@dxos/credentials";
|
|
5003
5198
|
import { raise as raise2 } from "@dxos/debug";
|
|
5004
5199
|
import { writeMessages as writeMessages3 } from "@dxos/feed-store";
|
|
5005
5200
|
import { invariant as invariant15 } from "@dxos/invariant";
|
|
5006
|
-
import { log as
|
|
5201
|
+
import { log as log15 } from "@dxos/log";
|
|
5007
5202
|
import { ApiError, SpaceNotFoundError as SpaceNotFoundError2, encodeError, IdentityNotInitializedError, AuthorizationError as AuthorizationError2 } from "@dxos/protocols";
|
|
5008
|
-
import { SpaceMember as SpaceMember7, SpaceState as
|
|
5203
|
+
import { SpaceMember as SpaceMember7, SpaceState as SpaceState4 } from "@dxos/protocols/proto/dxos/client/services";
|
|
5009
5204
|
import { trace as trace8 } from "@dxos/tracing";
|
|
5010
|
-
var
|
|
5205
|
+
var __dxlog_file18 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/spaces-service.ts";
|
|
5011
5206
|
var SpacesServiceImpl = class {
|
|
5012
5207
|
constructor(_identityManager, _spaceManager, _getDataSpaceManager) {
|
|
5013
5208
|
this._identityManager = _identityManager;
|
|
@@ -5026,10 +5221,10 @@ var SpacesServiceImpl = class {
|
|
|
5026
5221
|
const space = dataSpaceManager.spaces.get(spaceKey) ?? raise2(new SpaceNotFoundError2(spaceKey));
|
|
5027
5222
|
if (state) {
|
|
5028
5223
|
switch (state) {
|
|
5029
|
-
case
|
|
5224
|
+
case SpaceState4.ACTIVE:
|
|
5030
5225
|
await space.activate();
|
|
5031
5226
|
break;
|
|
5032
|
-
case
|
|
5227
|
+
case SpaceState4.INACTIVE:
|
|
5033
5228
|
await space.deactivate();
|
|
5034
5229
|
break;
|
|
5035
5230
|
default:
|
|
@@ -5051,7 +5246,7 @@ var SpacesServiceImpl = class {
|
|
|
5051
5246
|
}
|
|
5052
5247
|
const credentials = await createAdmissionCredentials2(identity.getIdentityCredentialSigner(), request.memberKey, space.key, space.genesisFeedKey, request.newRole, space.spaceState.membershipChainHeads);
|
|
5053
5248
|
invariant15(credentials[0].credential, void 0, {
|
|
5054
|
-
F:
|
|
5249
|
+
F: __dxlog_file18,
|
|
5055
5250
|
L: 97,
|
|
5056
5251
|
S: this,
|
|
5057
5252
|
A: [
|
|
@@ -5060,8 +5255,8 @@ var SpacesServiceImpl = class {
|
|
|
5060
5255
|
]
|
|
5061
5256
|
});
|
|
5062
5257
|
const spaceMemberCredential = credentials[0].credential.credential;
|
|
5063
|
-
invariant15(
|
|
5064
|
-
F:
|
|
5258
|
+
invariant15(getCredentialAssertion4(spaceMemberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
|
|
5259
|
+
F: __dxlog_file18,
|
|
5065
5260
|
L: 99,
|
|
5066
5261
|
S: this,
|
|
5067
5262
|
A: [
|
|
@@ -5076,10 +5271,10 @@ var SpacesServiceImpl = class {
|
|
|
5076
5271
|
const scheduler = new UpdateScheduler(ctx, async () => {
|
|
5077
5272
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
5078
5273
|
const spaces = Array.from(dataSpaceManager.spaces.values()).map((space) => this._serializeSpace(space));
|
|
5079
|
-
|
|
5274
|
+
log15("update", {
|
|
5080
5275
|
spaces
|
|
5081
5276
|
}, {
|
|
5082
|
-
F:
|
|
5277
|
+
F: __dxlog_file18,
|
|
5083
5278
|
L: 110,
|
|
5084
5279
|
S: this,
|
|
5085
5280
|
C: (f, a) => f(...a)
|
|
@@ -5163,7 +5358,7 @@ var SpacesServiceImpl = class {
|
|
|
5163
5358
|
});
|
|
5164
5359
|
} else {
|
|
5165
5360
|
invariant15(!credential.id, "Id on unsigned credentials is not allowed", {
|
|
5166
|
-
F:
|
|
5361
|
+
F: __dxlog_file18,
|
|
5167
5362
|
L: 198,
|
|
5168
5363
|
S: this,
|
|
5169
5364
|
A: [
|
|
@@ -5172,7 +5367,7 @@ var SpacesServiceImpl = class {
|
|
|
5172
5367
|
]
|
|
5173
5368
|
});
|
|
5174
5369
|
invariant15(this._identityManager.identity, "Identity is not available", {
|
|
5175
|
-
F:
|
|
5370
|
+
F: __dxlog_file18,
|
|
5176
5371
|
L: 199,
|
|
5177
5372
|
S: this,
|
|
5178
5373
|
A: [
|
|
@@ -5182,7 +5377,7 @@ var SpacesServiceImpl = class {
|
|
|
5182
5377
|
});
|
|
5183
5378
|
const signer = this._identityManager.identity.getIdentityCredentialSigner();
|
|
5184
5379
|
invariant15(credential.issuer.equals(signer.getIssuer()), void 0, {
|
|
5185
|
-
F:
|
|
5380
|
+
F: __dxlog_file18,
|
|
5186
5381
|
L: 201,
|
|
5187
5382
|
S: this,
|
|
5188
5383
|
A: [
|
|
@@ -5202,11 +5397,12 @@ var SpacesServiceImpl = class {
|
|
|
5202
5397
|
}
|
|
5203
5398
|
}
|
|
5204
5399
|
}
|
|
5205
|
-
async createEpoch({ spaceKey, migration }) {
|
|
5400
|
+
async createEpoch({ spaceKey, migration, automergeRootUrl }) {
|
|
5206
5401
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
5207
5402
|
const space = dataSpaceManager.spaces.get(spaceKey) ?? raise2(new SpaceNotFoundError2(spaceKey));
|
|
5208
5403
|
await space.createEpoch({
|
|
5209
|
-
migration
|
|
5404
|
+
migration,
|
|
5405
|
+
newAutomergeRoot: automergeRootUrl
|
|
5210
5406
|
});
|
|
5211
5407
|
}
|
|
5212
5408
|
_serializeSpace(space) {
|
|
@@ -5271,8 +5467,8 @@ var getChannelId = (channel) => `user-channel/${channel}`;
|
|
|
5271
5467
|
|
|
5272
5468
|
// packages/sdk/client-services/src/packlets/services/service-context.ts
|
|
5273
5469
|
import { Trigger as Trigger7 } from "@dxos/async";
|
|
5274
|
-
import { Context as Context10, Resource } from "@dxos/context";
|
|
5275
|
-
import { getCredentialAssertion as
|
|
5470
|
+
import { Context as Context10, Resource as Resource2 } from "@dxos/context";
|
|
5471
|
+
import { getCredentialAssertion as getCredentialAssertion5 } from "@dxos/credentials";
|
|
5276
5472
|
import { failUndefined as failUndefined2 } from "@dxos/debug";
|
|
5277
5473
|
import { EchoHost } from "@dxos/echo-db";
|
|
5278
5474
|
import { MetadataStore, SnapshotStore, SpaceManager, valueEncoding } from "@dxos/echo-pipeline";
|
|
@@ -5280,7 +5476,7 @@ import { FeedFactory, FeedStore } from "@dxos/feed-store";
|
|
|
5280
5476
|
import { invariant as invariant16 } from "@dxos/invariant";
|
|
5281
5477
|
import { Keyring } from "@dxos/keyring";
|
|
5282
5478
|
import { PublicKey as PublicKey12 } from "@dxos/keys";
|
|
5283
|
-
import { log as
|
|
5479
|
+
import { log as log16 } from "@dxos/log";
|
|
5284
5480
|
import { InvalidStorageVersionError, STORAGE_VERSION as STORAGE_VERSION2, trace as trace9 } from "@dxos/protocols";
|
|
5285
5481
|
import { Invitation as Invitation8 } from "@dxos/protocols/proto/dxos/client/services";
|
|
5286
5482
|
import { BlobStore } from "@dxos/teleport-extension-object-sync";
|
|
@@ -5296,8 +5492,8 @@ function _ts_decorate6(decorators, target, key, desc) {
|
|
|
5296
5492
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5297
5493
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
5298
5494
|
}
|
|
5299
|
-
var
|
|
5300
|
-
var ServiceContext = class extends
|
|
5495
|
+
var __dxlog_file19 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-context.ts";
|
|
5496
|
+
var ServiceContext = class extends Resource2 {
|
|
5301
5497
|
constructor(storage, level, networkManager, signalManager, _runtimeParams) {
|
|
5302
5498
|
super();
|
|
5303
5499
|
this.storage = storage;
|
|
@@ -5331,8 +5527,7 @@ var ServiceContext = class extends Resource {
|
|
|
5331
5527
|
});
|
|
5332
5528
|
this.identityManager = new IdentityManager(this.metadataStore, this.keyring, this.feedStore, this.spaceManager, this._runtimeParams);
|
|
5333
5529
|
this.echoHost = new EchoHost({
|
|
5334
|
-
kv: this.level
|
|
5335
|
-
storage: this.storage
|
|
5530
|
+
kv: this.level
|
|
5336
5531
|
});
|
|
5337
5532
|
this.invitations = new InvitationsHandler(this.networkManager, _runtimeParams?.invitationConnectionDefaultParams);
|
|
5338
5533
|
this.invitationsManager = new InvitationsManager(this.invitations, (invitation) => this.getInvitationHandler(invitation), this.metadataStore);
|
|
@@ -5340,17 +5535,17 @@ var ServiceContext = class extends Resource {
|
|
|
5340
5535
|
}
|
|
5341
5536
|
async _open(ctx) {
|
|
5342
5537
|
await this._checkStorageVersion();
|
|
5343
|
-
|
|
5344
|
-
F:
|
|
5345
|
-
L:
|
|
5538
|
+
log16("opening...", void 0, {
|
|
5539
|
+
F: __dxlog_file19,
|
|
5540
|
+
L: 149,
|
|
5346
5541
|
S: this,
|
|
5347
5542
|
C: (f, a) => f(...a)
|
|
5348
5543
|
});
|
|
5349
|
-
|
|
5544
|
+
log16.trace("dxos.sdk.service-context.open", trace9.begin({
|
|
5350
5545
|
id: this._instanceId
|
|
5351
5546
|
}), {
|
|
5352
|
-
F:
|
|
5353
|
-
L:
|
|
5547
|
+
F: __dxlog_file19,
|
|
5548
|
+
L: 150,
|
|
5354
5549
|
S: this,
|
|
5355
5550
|
C: (f, a) => f(...a)
|
|
5356
5551
|
});
|
|
@@ -5364,33 +5559,33 @@ var ServiceContext = class extends Resource {
|
|
|
5364
5559
|
await this._initialize(ctx);
|
|
5365
5560
|
}
|
|
5366
5561
|
const loadedInvitations = await this.invitationsManager.loadPersistentInvitations();
|
|
5367
|
-
|
|
5562
|
+
log16("loaded persistent invitations", {
|
|
5368
5563
|
count: loadedInvitations.invitations?.length
|
|
5369
5564
|
}, {
|
|
5370
|
-
F:
|
|
5371
|
-
L:
|
|
5565
|
+
F: __dxlog_file19,
|
|
5566
|
+
L: 163,
|
|
5372
5567
|
S: this,
|
|
5373
5568
|
C: (f, a) => f(...a)
|
|
5374
5569
|
});
|
|
5375
|
-
|
|
5570
|
+
log16.trace("dxos.sdk.service-context.open", trace9.end({
|
|
5376
5571
|
id: this._instanceId
|
|
5377
5572
|
}), {
|
|
5378
|
-
F:
|
|
5379
|
-
L:
|
|
5573
|
+
F: __dxlog_file19,
|
|
5574
|
+
L: 165,
|
|
5380
5575
|
S: this,
|
|
5381
5576
|
C: (f, a) => f(...a)
|
|
5382
5577
|
});
|
|
5383
|
-
|
|
5384
|
-
F:
|
|
5385
|
-
L:
|
|
5578
|
+
log16("opened", void 0, {
|
|
5579
|
+
F: __dxlog_file19,
|
|
5580
|
+
L: 166,
|
|
5386
5581
|
S: this,
|
|
5387
5582
|
C: (f, a) => f(...a)
|
|
5388
5583
|
});
|
|
5389
5584
|
}
|
|
5390
5585
|
async _close(ctx) {
|
|
5391
|
-
|
|
5392
|
-
F:
|
|
5393
|
-
L:
|
|
5586
|
+
log16("closing...", void 0, {
|
|
5587
|
+
F: __dxlog_file19,
|
|
5588
|
+
L: 170,
|
|
5394
5589
|
S: this,
|
|
5395
5590
|
C: (f, a) => f(...a)
|
|
5396
5591
|
});
|
|
@@ -5405,9 +5600,9 @@ var ServiceContext = class extends Resource {
|
|
|
5405
5600
|
await this.echoHost.close(ctx);
|
|
5406
5601
|
await this.networkManager.close();
|
|
5407
5602
|
await this.signalManager.close();
|
|
5408
|
-
|
|
5409
|
-
F:
|
|
5410
|
-
L:
|
|
5603
|
+
log16("closed", void 0, {
|
|
5604
|
+
F: __dxlog_file19,
|
|
5605
|
+
L: 182,
|
|
5411
5606
|
S: this,
|
|
5412
5607
|
C: (f, a) => f(...a)
|
|
5413
5608
|
});
|
|
@@ -5420,8 +5615,8 @@ var ServiceContext = class extends Resource {
|
|
|
5420
5615
|
getInvitationHandler(invitation) {
|
|
5421
5616
|
const factory = this._handlerFactories.get(invitation.kind);
|
|
5422
5617
|
invariant16(factory, `Unknown invitation kind: ${invitation.kind}`, {
|
|
5423
|
-
F:
|
|
5424
|
-
L:
|
|
5618
|
+
F: __dxlog_file19,
|
|
5619
|
+
L: 193,
|
|
5425
5620
|
S: this,
|
|
5426
5621
|
A: [
|
|
5427
5622
|
"factory",
|
|
@@ -5451,9 +5646,9 @@ var ServiceContext = class extends Resource {
|
|
|
5451
5646
|
}
|
|
5452
5647
|
// Called when identity is created.
|
|
5453
5648
|
async _initialize(ctx) {
|
|
5454
|
-
|
|
5455
|
-
F:
|
|
5456
|
-
L:
|
|
5649
|
+
log16("initializing spaces...", void 0, {
|
|
5650
|
+
F: __dxlog_file19,
|
|
5651
|
+
L: 224,
|
|
5457
5652
|
S: this,
|
|
5458
5653
|
C: (f, a) => f(...a)
|
|
5459
5654
|
});
|
|
@@ -5475,8 +5670,8 @@ var ServiceContext = class extends Resource {
|
|
|
5475
5670
|
await this.dataSpaceManager.open();
|
|
5476
5671
|
this._handlerFactories.set(Invitation8.Kind.SPACE, (invitation) => {
|
|
5477
5672
|
invariant16(this.dataSpaceManager, "dataSpaceManager not initialized yet", {
|
|
5478
|
-
F:
|
|
5479
|
-
L:
|
|
5673
|
+
F: __dxlog_file19,
|
|
5674
|
+
L: 249,
|
|
5480
5675
|
S: this,
|
|
5481
5676
|
A: [
|
|
5482
5677
|
"this.dataSpaceManager",
|
|
@@ -5488,7 +5683,7 @@ var ServiceContext = class extends Resource {
|
|
|
5488
5683
|
this.initialized.wake();
|
|
5489
5684
|
this._deviceSpaceSync = {
|
|
5490
5685
|
processCredential: async (credential) => {
|
|
5491
|
-
const assertion =
|
|
5686
|
+
const assertion = getCredentialAssertion5(credential);
|
|
5492
5687
|
if (assertion["@type"] !== "dxos.halo.credentials.SpaceMember") {
|
|
5493
5688
|
return;
|
|
5494
5689
|
}
|
|
@@ -5496,33 +5691,33 @@ var ServiceContext = class extends Resource {
|
|
|
5496
5691
|
return;
|
|
5497
5692
|
}
|
|
5498
5693
|
if (!this.dataSpaceManager) {
|
|
5499
|
-
|
|
5694
|
+
log16("dataSpaceManager not initialized yet, ignoring space admission", {
|
|
5500
5695
|
details: assertion
|
|
5501
5696
|
}, {
|
|
5502
|
-
F:
|
|
5503
|
-
L:
|
|
5697
|
+
F: __dxlog_file19,
|
|
5698
|
+
L: 265,
|
|
5504
5699
|
S: this,
|
|
5505
5700
|
C: (f, a) => f(...a)
|
|
5506
5701
|
});
|
|
5507
5702
|
return;
|
|
5508
5703
|
}
|
|
5509
5704
|
if (this.dataSpaceManager.spaces.has(assertion.spaceKey)) {
|
|
5510
|
-
|
|
5705
|
+
log16("space already exists, ignoring space admission", {
|
|
5511
5706
|
details: assertion
|
|
5512
5707
|
}, {
|
|
5513
|
-
F:
|
|
5514
|
-
L:
|
|
5708
|
+
F: __dxlog_file19,
|
|
5709
|
+
L: 269,
|
|
5515
5710
|
S: this,
|
|
5516
5711
|
C: (f, a) => f(...a)
|
|
5517
5712
|
});
|
|
5518
5713
|
return;
|
|
5519
5714
|
}
|
|
5520
5715
|
try {
|
|
5521
|
-
|
|
5716
|
+
log16("accepting space recorded in halo", {
|
|
5522
5717
|
details: assertion
|
|
5523
5718
|
}, {
|
|
5524
|
-
F:
|
|
5525
|
-
L:
|
|
5719
|
+
F: __dxlog_file19,
|
|
5720
|
+
L: 274,
|
|
5526
5721
|
S: this,
|
|
5527
5722
|
C: (f, a) => f(...a)
|
|
5528
5723
|
});
|
|
@@ -5531,9 +5726,9 @@ var ServiceContext = class extends Resource {
|
|
|
5531
5726
|
genesisFeedKey: assertion.genesisFeedKey
|
|
5532
5727
|
});
|
|
5533
5728
|
} catch (err) {
|
|
5534
|
-
|
|
5535
|
-
F:
|
|
5536
|
-
L:
|
|
5729
|
+
log16.catch(err, void 0, {
|
|
5730
|
+
F: __dxlog_file19,
|
|
5731
|
+
L: 280,
|
|
5537
5732
|
S: this,
|
|
5538
5733
|
C: (f, a) => f(...a)
|
|
5539
5734
|
});
|
|
@@ -5581,7 +5776,7 @@ var ServiceRegistry = class {
|
|
|
5581
5776
|
// packages/sdk/client-services/src/packlets/locks/browser.ts
|
|
5582
5777
|
import { asyncTimeout as asyncTimeout3, Trigger as Trigger8 } from "@dxos/async";
|
|
5583
5778
|
import { RESOURCE_LOCK_TIMEOUT } from "@dxos/client-protocol";
|
|
5584
|
-
import { log as
|
|
5779
|
+
import { log as log17, logInfo } from "@dxos/log";
|
|
5585
5780
|
function _ts_decorate7(decorators, target, key, desc) {
|
|
5586
5781
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
5587
5782
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
@@ -5592,7 +5787,7 @@ function _ts_decorate7(decorators, target, key, desc) {
|
|
|
5592
5787
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5593
5788
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
5594
5789
|
}
|
|
5595
|
-
var
|
|
5790
|
+
var __dxlog_file20 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/locks/browser.ts";
|
|
5596
5791
|
var Message;
|
|
5597
5792
|
(function(Message2) {
|
|
5598
5793
|
Message2["ACQUIRING"] = "acquiring";
|
|
@@ -5614,29 +5809,29 @@ var Lock = class {
|
|
|
5614
5809
|
message: "acquiring"
|
|
5615
5810
|
});
|
|
5616
5811
|
try {
|
|
5617
|
-
|
|
5618
|
-
F:
|
|
5812
|
+
log17("aquiring lock...", void 0, {
|
|
5813
|
+
F: __dxlog_file20,
|
|
5619
5814
|
L: 42,
|
|
5620
5815
|
S: this,
|
|
5621
5816
|
C: (f, a) => f(...a)
|
|
5622
5817
|
});
|
|
5623
5818
|
await asyncTimeout3(this._requestLock(), RESOURCE_LOCK_TIMEOUT);
|
|
5624
|
-
|
|
5625
|
-
F:
|
|
5819
|
+
log17("acquired lock", void 0, {
|
|
5820
|
+
F: __dxlog_file20,
|
|
5626
5821
|
L: 44,
|
|
5627
5822
|
S: this,
|
|
5628
5823
|
C: (f, a) => f(...a)
|
|
5629
5824
|
});
|
|
5630
5825
|
} catch {
|
|
5631
|
-
|
|
5632
|
-
F:
|
|
5826
|
+
log17("stealing lock...", void 0, {
|
|
5827
|
+
F: __dxlog_file20,
|
|
5633
5828
|
L: 46,
|
|
5634
5829
|
S: this,
|
|
5635
5830
|
C: (f, a) => f(...a)
|
|
5636
5831
|
});
|
|
5637
5832
|
await this._requestLock(true);
|
|
5638
|
-
|
|
5639
|
-
F:
|
|
5833
|
+
log17("stolen lock", void 0, {
|
|
5834
|
+
F: __dxlog_file20,
|
|
5640
5835
|
L: 48,
|
|
5641
5836
|
S: this,
|
|
5642
5837
|
C: (f, a) => f(...a)
|
|
@@ -5652,10 +5847,10 @@ var Lock = class {
|
|
|
5652
5847
|
}
|
|
5653
5848
|
}
|
|
5654
5849
|
async _requestLock(steal = false) {
|
|
5655
|
-
|
|
5850
|
+
log17("requesting lock...", {
|
|
5656
5851
|
steal
|
|
5657
5852
|
}, {
|
|
5658
|
-
F:
|
|
5853
|
+
F: __dxlog_file20,
|
|
5659
5854
|
L: 63,
|
|
5660
5855
|
S: this,
|
|
5661
5856
|
C: (f, a) => f(...a)
|
|
@@ -5668,15 +5863,15 @@ var Lock = class {
|
|
|
5668
5863
|
acquired.wake();
|
|
5669
5864
|
this._releaseTrigger = new Trigger8();
|
|
5670
5865
|
await this._releaseTrigger.wait();
|
|
5671
|
-
|
|
5672
|
-
F:
|
|
5866
|
+
log17("releasing lock...", void 0, {
|
|
5867
|
+
F: __dxlog_file20,
|
|
5673
5868
|
L: 72,
|
|
5674
5869
|
S: this,
|
|
5675
5870
|
C: (f, a) => f(...a)
|
|
5676
5871
|
});
|
|
5677
5872
|
await this._onRelease?.();
|
|
5678
|
-
|
|
5679
|
-
F:
|
|
5873
|
+
log17("released lock", void 0, {
|
|
5874
|
+
F: __dxlog_file20,
|
|
5680
5875
|
L: 74,
|
|
5681
5876
|
S: this,
|
|
5682
5877
|
C: (f, a) => f(...a)
|
|
@@ -5685,10 +5880,10 @@ var Lock = class {
|
|
|
5685
5880
|
await this._onRelease?.();
|
|
5686
5881
|
});
|
|
5687
5882
|
await acquired.wait();
|
|
5688
|
-
|
|
5883
|
+
log17("recieved lock", {
|
|
5689
5884
|
steal
|
|
5690
5885
|
}, {
|
|
5691
|
-
F:
|
|
5886
|
+
F: __dxlog_file20,
|
|
5692
5887
|
L: 81,
|
|
5693
5888
|
S: this,
|
|
5694
5889
|
C: (f, a) => f(...a)
|
|
@@ -5778,19 +5973,16 @@ var createLevel = async (config) => {
|
|
|
5778
5973
|
|
|
5779
5974
|
// packages/sdk/client-services/src/packlets/services/service-host.ts
|
|
5780
5975
|
import { Event as Event9, synchronized as synchronized3 } from "@dxos/async";
|
|
5781
|
-
import { clientServiceBundle
|
|
5976
|
+
import { clientServiceBundle } from "@dxos/client-protocol";
|
|
5782
5977
|
import { Context as Context11 } from "@dxos/context";
|
|
5783
|
-
import { encodeReference } from "@dxos/echo-protocol";
|
|
5784
|
-
import { getTypeReference } from "@dxos/echo-schema";
|
|
5785
5978
|
import { invariant as invariant18 } from "@dxos/invariant";
|
|
5786
5979
|
import { PublicKey as PublicKey16 } from "@dxos/keys";
|
|
5787
|
-
import { log as
|
|
5980
|
+
import { log as log19 } from "@dxos/log";
|
|
5788
5981
|
import { WebsocketSignalManager } from "@dxos/messaging";
|
|
5789
5982
|
import { SwarmNetworkManager, createSimplePeerTransportFactory } from "@dxos/network-manager";
|
|
5790
5983
|
import { trace as trace10 } from "@dxos/protocols";
|
|
5791
5984
|
import { SystemStatus } from "@dxos/protocols/proto/dxos/client/services";
|
|
5792
5985
|
import { TRACE_PROCESSOR as TRACE_PROCESSOR3, trace as Trace4 } from "@dxos/tracing";
|
|
5793
|
-
import { assignDeep as assignDeep2 } from "@dxos/util";
|
|
5794
5986
|
import { WebsocketRpcClient } from "@dxos/websocket-rpc";
|
|
5795
5987
|
|
|
5796
5988
|
// packages/sdk/client-services/src/packlets/devices/devices-service.ts
|
|
@@ -5798,7 +5990,7 @@ import { EventSubscriptions as EventSubscriptions3 } from "@dxos/async";
|
|
|
5798
5990
|
import { Stream as Stream11 } from "@dxos/codec-protobuf";
|
|
5799
5991
|
import { invariant as invariant17 } from "@dxos/invariant";
|
|
5800
5992
|
import { Device as Device2, DeviceKind as DeviceKind2 } from "@dxos/protocols/proto/dxos/client/services";
|
|
5801
|
-
var
|
|
5993
|
+
var __dxlog_file21 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/devices/devices-service.ts";
|
|
5802
5994
|
var DevicesServiceImpl = class {
|
|
5803
5995
|
constructor(_identityManager) {
|
|
5804
5996
|
this._identityManager = _identityManager;
|
|
@@ -5816,7 +6008,7 @@ var DevicesServiceImpl = class {
|
|
|
5816
6008
|
});
|
|
5817
6009
|
} else {
|
|
5818
6010
|
invariant17(this._identityManager.identity?.presence, "presence not present", {
|
|
5819
|
-
F:
|
|
6011
|
+
F: __dxlog_file21,
|
|
5820
6012
|
L: 32,
|
|
5821
6013
|
S: this,
|
|
5822
6014
|
A: [
|
|
@@ -5926,7 +6118,7 @@ var findConfigs = () => {
|
|
|
5926
6118
|
import { Event as Event8 } from "@dxos/async";
|
|
5927
6119
|
import { Stream as Stream12 } from "@dxos/codec-protobuf";
|
|
5928
6120
|
import { PublicKey as PublicKey15 } from "@dxos/keys";
|
|
5929
|
-
import { getContextFromEntry, log as
|
|
6121
|
+
import { getContextFromEntry, log as log18 } from "@dxos/log";
|
|
5930
6122
|
import { QueryLogsRequest } from "@dxos/protocols/proto/dxos/client/services";
|
|
5931
6123
|
import { getDebugName, jsonify, numericalValues, tracer } from "@dxos/util";
|
|
5932
6124
|
var LoggingServiceImpl = class {
|
|
@@ -5939,11 +6131,11 @@ var LoggingServiceImpl = class {
|
|
|
5939
6131
|
};
|
|
5940
6132
|
}
|
|
5941
6133
|
async open() {
|
|
5942
|
-
|
|
6134
|
+
log18.runtimeConfig.processors.push(this._logProcessor);
|
|
5943
6135
|
}
|
|
5944
6136
|
async close() {
|
|
5945
|
-
const index =
|
|
5946
|
-
|
|
6137
|
+
const index = log18.runtimeConfig.processors.findIndex((processor) => processor === this._logProcessor);
|
|
6138
|
+
log18.runtimeConfig.processors.splice(index, 1);
|
|
5947
6139
|
}
|
|
5948
6140
|
async controlMetrics({ reset, record }) {
|
|
5949
6141
|
if (reset) {
|
|
@@ -6147,7 +6339,7 @@ function _ts_decorate8(decorators, target, key, desc) {
|
|
|
6147
6339
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6148
6340
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6149
6341
|
}
|
|
6150
|
-
var
|
|
6342
|
+
var __dxlog_file22 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-host.ts";
|
|
6151
6343
|
var ClientServicesHost = class {
|
|
6152
6344
|
constructor({
|
|
6153
6345
|
config,
|
|
@@ -6167,7 +6359,7 @@ var ClientServicesHost = class {
|
|
|
6167
6359
|
this._storage = storage;
|
|
6168
6360
|
this._level = level;
|
|
6169
6361
|
this._callbacks = callbacks;
|
|
6170
|
-
this._runtimeParams = runtimeParams;
|
|
6362
|
+
this._runtimeParams = runtimeParams ?? {};
|
|
6171
6363
|
if (config) {
|
|
6172
6364
|
this.initialize({
|
|
6173
6365
|
config,
|
|
@@ -6236,24 +6428,24 @@ var ClientServicesHost = class {
|
|
|
6236
6428
|
*/
|
|
6237
6429
|
initialize({ config, ...options }) {
|
|
6238
6430
|
invariant18(!this._open, "service host is open", {
|
|
6239
|
-
F:
|
|
6240
|
-
L:
|
|
6431
|
+
F: __dxlog_file22,
|
|
6432
|
+
L: 186,
|
|
6241
6433
|
S: this,
|
|
6242
6434
|
A: [
|
|
6243
6435
|
"!this._open",
|
|
6244
6436
|
"'service host is open'"
|
|
6245
6437
|
]
|
|
6246
6438
|
});
|
|
6247
|
-
|
|
6248
|
-
F:
|
|
6249
|
-
L:
|
|
6439
|
+
log19("initializing...", void 0, {
|
|
6440
|
+
F: __dxlog_file22,
|
|
6441
|
+
L: 187,
|
|
6250
6442
|
S: this,
|
|
6251
6443
|
C: (f, a) => f(...a)
|
|
6252
6444
|
});
|
|
6253
6445
|
if (config) {
|
|
6254
6446
|
invariant18(!this._config, "config already set", {
|
|
6255
|
-
F:
|
|
6256
|
-
L:
|
|
6447
|
+
F: __dxlog_file22,
|
|
6448
|
+
L: 190,
|
|
6257
6449
|
S: this,
|
|
6258
6450
|
A: [
|
|
6259
6451
|
"!this._config",
|
|
@@ -6266,9 +6458,9 @@ var ClientServicesHost = class {
|
|
|
6266
6458
|
}
|
|
6267
6459
|
}
|
|
6268
6460
|
if (!options.signalManager) {
|
|
6269
|
-
|
|
6270
|
-
F:
|
|
6271
|
-
L:
|
|
6461
|
+
log19.warn("running signaling without telemetry metadata.", void 0, {
|
|
6462
|
+
F: __dxlog_file22,
|
|
6463
|
+
L: 198,
|
|
6272
6464
|
S: this,
|
|
6273
6465
|
C: (f, a) => f(...a)
|
|
6274
6466
|
});
|
|
@@ -6278,8 +6470,8 @@ var ClientServicesHost = class {
|
|
|
6278
6470
|
}), signalManager = new WebsocketSignalManager(this._config?.get("runtime.services.signaling") ?? []) } = options;
|
|
6279
6471
|
this._signalManager = signalManager;
|
|
6280
6472
|
invariant18(!this._networkManager, "network manager already set", {
|
|
6281
|
-
F:
|
|
6282
|
-
L:
|
|
6473
|
+
F: __dxlog_file22,
|
|
6474
|
+
L: 209,
|
|
6283
6475
|
S: this,
|
|
6284
6476
|
A: [
|
|
6285
6477
|
"!this._networkManager",
|
|
@@ -6291,9 +6483,9 @@ var ClientServicesHost = class {
|
|
|
6291
6483
|
transportFactory,
|
|
6292
6484
|
signalManager
|
|
6293
6485
|
});
|
|
6294
|
-
|
|
6295
|
-
F:
|
|
6296
|
-
L:
|
|
6486
|
+
log19("initialized", void 0, {
|
|
6487
|
+
F: __dxlog_file22,
|
|
6488
|
+
L: 216,
|
|
6297
6489
|
S: this,
|
|
6298
6490
|
C: (f, a) => f(...a)
|
|
6299
6491
|
});
|
|
@@ -6303,17 +6495,17 @@ var ClientServicesHost = class {
|
|
|
6303
6495
|
return;
|
|
6304
6496
|
}
|
|
6305
6497
|
const traceId = PublicKey16.random().toHex();
|
|
6306
|
-
|
|
6498
|
+
log19.trace("dxos.client-services.host.open", trace10.begin({
|
|
6307
6499
|
id: traceId
|
|
6308
6500
|
}), {
|
|
6309
|
-
F:
|
|
6310
|
-
L:
|
|
6501
|
+
F: __dxlog_file22,
|
|
6502
|
+
L: 227,
|
|
6311
6503
|
S: this,
|
|
6312
6504
|
C: (f, a) => f(...a)
|
|
6313
6505
|
});
|
|
6314
6506
|
invariant18(this._config, "config not set", {
|
|
6315
|
-
F:
|
|
6316
|
-
L:
|
|
6507
|
+
F: __dxlog_file22,
|
|
6508
|
+
L: 229,
|
|
6317
6509
|
S: this,
|
|
6318
6510
|
A: [
|
|
6319
6511
|
"this._config",
|
|
@@ -6321,8 +6513,8 @@ var ClientServicesHost = class {
|
|
|
6321
6513
|
]
|
|
6322
6514
|
});
|
|
6323
6515
|
invariant18(this._storage, "storage not set", {
|
|
6324
|
-
F:
|
|
6325
|
-
L:
|
|
6516
|
+
F: __dxlog_file22,
|
|
6517
|
+
L: 230,
|
|
6326
6518
|
S: this,
|
|
6327
6519
|
A: [
|
|
6328
6520
|
"this._storage",
|
|
@@ -6330,8 +6522,8 @@ var ClientServicesHost = class {
|
|
|
6330
6522
|
]
|
|
6331
6523
|
});
|
|
6332
6524
|
invariant18(this._signalManager, "signal manager not set", {
|
|
6333
|
-
F:
|
|
6334
|
-
L:
|
|
6525
|
+
F: __dxlog_file22,
|
|
6526
|
+
L: 231,
|
|
6335
6527
|
S: this,
|
|
6336
6528
|
A: [
|
|
6337
6529
|
"this._signalManager",
|
|
@@ -6339,8 +6531,8 @@ var ClientServicesHost = class {
|
|
|
6339
6531
|
]
|
|
6340
6532
|
});
|
|
6341
6533
|
invariant18(this._networkManager, "network manager not set", {
|
|
6342
|
-
F:
|
|
6343
|
-
L:
|
|
6534
|
+
F: __dxlog_file22,
|
|
6535
|
+
L: 232,
|
|
6344
6536
|
S: this,
|
|
6345
6537
|
A: [
|
|
6346
6538
|
"this._networkManager",
|
|
@@ -6348,11 +6540,11 @@ var ClientServicesHost = class {
|
|
|
6348
6540
|
]
|
|
6349
6541
|
});
|
|
6350
6542
|
this._opening = true;
|
|
6351
|
-
|
|
6543
|
+
log19("opening...", {
|
|
6352
6544
|
lockKey: this._resourceLock?.lockKey
|
|
6353
6545
|
}, {
|
|
6354
|
-
F:
|
|
6355
|
-
L:
|
|
6546
|
+
F: __dxlog_file22,
|
|
6547
|
+
L: 235,
|
|
6356
6548
|
S: this,
|
|
6357
6549
|
C: (f, a) => f(...a)
|
|
6358
6550
|
});
|
|
@@ -6363,9 +6555,10 @@ var ClientServicesHost = class {
|
|
|
6363
6555
|
await this._level.open();
|
|
6364
6556
|
await this._loggingService.open();
|
|
6365
6557
|
this._serviceContext = new ServiceContext(this._storage, this._level, this._networkManager, this._signalManager, this._runtimeParams);
|
|
6558
|
+
const identityService = new IdentityServiceImpl(this._serviceContext.identityManager, this._serviceContext.keyring, () => this._serviceContext.dataSpaceManager, (params) => this._createIdentity(params), (profile) => this._serviceContext.broadcastProfileUpdate(profile));
|
|
6366
6559
|
this._serviceRegistry.setServices({
|
|
6367
6560
|
SystemService: this._systemService,
|
|
6368
|
-
IdentityService:
|
|
6561
|
+
IdentityService: identityService,
|
|
6369
6562
|
InvitationsService: new InvitationsServiceImpl(this._serviceContext.invitationsManager),
|
|
6370
6563
|
DevicesService: new DevicesServiceImpl(this._serviceContext.identityManager),
|
|
6371
6564
|
SpacesService: new SpacesServiceImpl(this._serviceContext.identityManager, this._serviceContext.spaceManager, async () => {
|
|
@@ -6385,6 +6578,7 @@ var ClientServicesHost = class {
|
|
|
6385
6578
|
})
|
|
6386
6579
|
});
|
|
6387
6580
|
await this._serviceContext.open(ctx);
|
|
6581
|
+
await identityService.open();
|
|
6388
6582
|
const devtoolsProxy = this._config?.get("runtime.client.devtoolsProxy");
|
|
6389
6583
|
if (devtoolsProxy) {
|
|
6390
6584
|
this._devtoolsProxy = new WebsocketRpcClient({
|
|
@@ -6400,18 +6594,18 @@ var ClientServicesHost = class {
|
|
|
6400
6594
|
this._open = true;
|
|
6401
6595
|
this._statusUpdate.emit();
|
|
6402
6596
|
const deviceKey = this._serviceContext.identityManager.identity?.deviceKey;
|
|
6403
|
-
|
|
6597
|
+
log19("opened", {
|
|
6404
6598
|
deviceKey
|
|
6405
6599
|
}, {
|
|
6406
|
-
F:
|
|
6600
|
+
F: __dxlog_file22,
|
|
6407
6601
|
L: 314,
|
|
6408
6602
|
S: this,
|
|
6409
6603
|
C: (f, a) => f(...a)
|
|
6410
6604
|
});
|
|
6411
|
-
|
|
6605
|
+
log19.trace("dxos.client-services.host.open", trace10.end({
|
|
6412
6606
|
id: traceId
|
|
6413
6607
|
}), {
|
|
6414
|
-
F:
|
|
6608
|
+
F: __dxlog_file22,
|
|
6415
6609
|
L: 315,
|
|
6416
6610
|
S: this,
|
|
6417
6611
|
C: (f, a) => f(...a)
|
|
@@ -6422,10 +6616,10 @@ var ClientServicesHost = class {
|
|
|
6422
6616
|
return;
|
|
6423
6617
|
}
|
|
6424
6618
|
const deviceKey = this._serviceContext.identityManager.identity?.deviceKey;
|
|
6425
|
-
|
|
6619
|
+
log19("closing...", {
|
|
6426
6620
|
deviceKey
|
|
6427
6621
|
}, {
|
|
6428
|
-
F:
|
|
6622
|
+
F: __dxlog_file22,
|
|
6429
6623
|
L: 326,
|
|
6430
6624
|
S: this,
|
|
6431
6625
|
C: (f, a) => f(...a)
|
|
@@ -6440,10 +6634,10 @@ var ClientServicesHost = class {
|
|
|
6440
6634
|
await this._level?.close();
|
|
6441
6635
|
this._open = false;
|
|
6442
6636
|
this._statusUpdate.emit();
|
|
6443
|
-
|
|
6637
|
+
log19("closed", {
|
|
6444
6638
|
deviceKey
|
|
6445
6639
|
}, {
|
|
6446
|
-
F:
|
|
6640
|
+
F: __dxlog_file22,
|
|
6447
6641
|
L: 335,
|
|
6448
6642
|
S: this,
|
|
6449
6643
|
C: (f, a) => f(...a)
|
|
@@ -6451,32 +6645,32 @@ var ClientServicesHost = class {
|
|
|
6451
6645
|
}
|
|
6452
6646
|
async reset() {
|
|
6453
6647
|
const traceId = PublicKey16.random().toHex();
|
|
6454
|
-
|
|
6648
|
+
log19.trace("dxos.sdk.client-services-host.reset", trace10.begin({
|
|
6455
6649
|
id: traceId
|
|
6456
6650
|
}), {
|
|
6457
|
-
F:
|
|
6651
|
+
F: __dxlog_file22,
|
|
6458
6652
|
L: 340,
|
|
6459
6653
|
S: this,
|
|
6460
6654
|
C: (f, a) => f(...a)
|
|
6461
6655
|
});
|
|
6462
|
-
|
|
6463
|
-
F:
|
|
6656
|
+
log19.info("resetting...", void 0, {
|
|
6657
|
+
F: __dxlog_file22,
|
|
6464
6658
|
L: 342,
|
|
6465
6659
|
S: this,
|
|
6466
6660
|
C: (f, a) => f(...a)
|
|
6467
6661
|
});
|
|
6468
6662
|
await this._serviceContext?.close();
|
|
6469
6663
|
await this._storage.reset();
|
|
6470
|
-
|
|
6471
|
-
F:
|
|
6664
|
+
log19.info("reset", void 0, {
|
|
6665
|
+
F: __dxlog_file22,
|
|
6472
6666
|
L: 345,
|
|
6473
6667
|
S: this,
|
|
6474
6668
|
C: (f, a) => f(...a)
|
|
6475
6669
|
});
|
|
6476
|
-
|
|
6670
|
+
log19.trace("dxos.sdk.client-services-host.reset", trace10.end({
|
|
6477
6671
|
id: traceId
|
|
6478
6672
|
}), {
|
|
6479
|
-
F:
|
|
6673
|
+
F: __dxlog_file22,
|
|
6480
6674
|
L: 346,
|
|
6481
6675
|
S: this,
|
|
6482
6676
|
C: (f, a) => f(...a)
|
|
@@ -6486,38 +6680,6 @@ var ClientServicesHost = class {
|
|
|
6486
6680
|
async _createIdentity(params) {
|
|
6487
6681
|
const identity = await this._serviceContext.createIdentity(params);
|
|
6488
6682
|
await this._serviceContext.initialized.wait();
|
|
6489
|
-
const space = await this._serviceContext.dataSpaceManager.createSpace();
|
|
6490
|
-
const automergeIndex = space.automergeSpaceState.rootUrl;
|
|
6491
|
-
invariant18(automergeIndex, void 0, {
|
|
6492
|
-
F: __dxlog_file21,
|
|
6493
|
-
L: 358,
|
|
6494
|
-
S: this,
|
|
6495
|
-
A: [
|
|
6496
|
-
"automergeIndex",
|
|
6497
|
-
""
|
|
6498
|
-
]
|
|
6499
|
-
});
|
|
6500
|
-
const document = this._serviceContext.echoHost.automergeRepo.find(automergeIndex);
|
|
6501
|
-
await document.whenReady();
|
|
6502
|
-
const properties = {
|
|
6503
|
-
system: {
|
|
6504
|
-
type: encodeReference(getTypeReference(PropertiesType))
|
|
6505
|
-
},
|
|
6506
|
-
data: {
|
|
6507
|
-
[defaultKey]: identity.identityKey.toHex()
|
|
6508
|
-
},
|
|
6509
|
-
meta: {
|
|
6510
|
-
keys: []
|
|
6511
|
-
}
|
|
6512
|
-
};
|
|
6513
|
-
const propertiesId = PublicKey16.random().toHex();
|
|
6514
|
-
document.change((doc) => {
|
|
6515
|
-
assignDeep2(doc, [
|
|
6516
|
-
"objects",
|
|
6517
|
-
propertiesId
|
|
6518
|
-
], properties);
|
|
6519
|
-
});
|
|
6520
|
-
await this._serviceContext.echoHost.flush();
|
|
6521
6683
|
return identity;
|
|
6522
6684
|
}
|
|
6523
6685
|
};
|
|
@@ -6580,4 +6742,4 @@ export {
|
|
|
6580
6742
|
ClientServicesProviderResource,
|
|
6581
6743
|
DiagnosticsCollector
|
|
6582
6744
|
};
|
|
6583
|
-
//# sourceMappingURL=chunk-
|
|
6745
|
+
//# sourceMappingURL=chunk-TZL7PJDX.mjs.map
|