@dxos/client-services 0.5.9-main.2dbe289 → 0.5.9-main.405fda7
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-QWL2M4EU.mjs → chunk-NBUF5LMA.mjs} +743 -605
- package/dist/lib/browser/chunk-NBUF5LMA.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-NPYJIVOX.cjs → chunk-CMHCDXY6.cjs} +959 -825
- package/dist/lib/node/chunk-CMHCDXY6.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.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 +9 -5
- package/src/packlets/testing/test-builder.ts +12 -10
- package/src/version.ts +1 -1
- package/dist/lib/browser/chunk-QWL2M4EU.mjs.map +0 -7
- package/dist/lib/node/chunk-NPYJIVOX.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.405fda7";
|
|
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,10 +4048,10 @@ 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:
|
|
4054
|
+
F: __dxlog_file16,
|
|
3932
4055
|
L: 143,
|
|
3933
4056
|
S: this,
|
|
3934
4057
|
C: (f, a) => f(...a)
|
|
@@ -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
|
}
|
|
@@ -4270,8 +4396,8 @@ var DataSpace = class {
|
|
|
4270
4396
|
newRoot.documentId
|
|
4271
4397
|
]);
|
|
4272
4398
|
invariant13(typeof newRoot.url === "string" && newRoot.url.length > 0, void 0, {
|
|
4273
|
-
F:
|
|
4274
|
-
L:
|
|
4399
|
+
F: __dxlog_file16,
|
|
4400
|
+
L: 460,
|
|
4275
4401
|
S: this,
|
|
4276
4402
|
A: [
|
|
4277
4403
|
"typeof newRoot.url === 'string' && newRoot.url.length > 0",
|
|
@@ -4281,16 +4407,16 @@ var DataSpace = class {
|
|
|
4281
4407
|
epoch = {
|
|
4282
4408
|
previousId: this._automergeSpaceState.lastEpoch?.id,
|
|
4283
4409
|
number: (this._automergeSpaceState.lastEpoch?.subject.assertion.number ?? -1) + 1,
|
|
4284
|
-
timeframe: this._automergeSpaceState.lastEpoch?.subject.assertion.timeframe ?? new
|
|
4410
|
+
timeframe: this._automergeSpaceState.lastEpoch?.subject.assertion.timeframe ?? new Timeframe3(),
|
|
4285
4411
|
automergeRoot: newRoot.url
|
|
4286
4412
|
};
|
|
4287
4413
|
}
|
|
4288
4414
|
break;
|
|
4289
4415
|
case CreateEpochRequest.Migration.FRAGMENT_AUTOMERGE_ROOT:
|
|
4290
4416
|
{
|
|
4291
|
-
|
|
4292
|
-
F:
|
|
4293
|
-
L:
|
|
4417
|
+
log13.info("Fragmenting", void 0, {
|
|
4418
|
+
F: __dxlog_file16,
|
|
4419
|
+
L: 472,
|
|
4294
4420
|
S: this,
|
|
4295
4421
|
C: (f, a) => f(...a)
|
|
4296
4422
|
});
|
|
@@ -4301,8 +4427,8 @@ var DataSpace = class {
|
|
|
4301
4427
|
const properties = findPropertiesObject(rootHandle.docSync());
|
|
4302
4428
|
const otherObjects = objects.filter(([key]) => key !== properties?.[0]);
|
|
4303
4429
|
invariant13(properties, "Properties not found", {
|
|
4304
|
-
F:
|
|
4305
|
-
L:
|
|
4430
|
+
F: __dxlog_file16,
|
|
4431
|
+
L: 482,
|
|
4306
4432
|
S: this,
|
|
4307
4433
|
A: [
|
|
4308
4434
|
"properties",
|
|
@@ -4317,8 +4443,8 @@ var DataSpace = class {
|
|
|
4317
4443
|
};
|
|
4318
4444
|
const newRoot = this._echoHost.automergeRepo.create(newSpaceDoc);
|
|
4319
4445
|
invariant13(typeof newRoot.url === "string" && newRoot.url.length > 0, void 0, {
|
|
4320
|
-
F:
|
|
4321
|
-
L:
|
|
4446
|
+
F: __dxlog_file16,
|
|
4447
|
+
L: 487,
|
|
4322
4448
|
S: this,
|
|
4323
4449
|
A: [
|
|
4324
4450
|
"typeof newRoot.url === 'string' && newRoot.url.length > 0",
|
|
@@ -4341,7 +4467,7 @@ var DataSpace = class {
|
|
|
4341
4467
|
epoch = {
|
|
4342
4468
|
previousId: this._automergeSpaceState.lastEpoch?.id,
|
|
4343
4469
|
number: (this._automergeSpaceState.lastEpoch?.subject.assertion.number ?? -1) + 1,
|
|
4344
|
-
timeframe: this._automergeSpaceState.lastEpoch?.subject.assertion.timeframe ?? new
|
|
4470
|
+
timeframe: this._automergeSpaceState.lastEpoch?.subject.assertion.timeframe ?? new Timeframe3(),
|
|
4345
4471
|
automergeRoot: newRoot.url
|
|
4346
4472
|
};
|
|
4347
4473
|
}
|
|
@@ -4349,8 +4475,8 @@ var DataSpace = class {
|
|
|
4349
4475
|
case CreateEpochRequest.Migration.REPLACE_AUTOMERGE_ROOT:
|
|
4350
4476
|
{
|
|
4351
4477
|
invariant13(options.newAutomergeRoot, void 0, {
|
|
4352
|
-
F:
|
|
4353
|
-
L:
|
|
4478
|
+
F: __dxlog_file16,
|
|
4479
|
+
L: 517,
|
|
4354
4480
|
S: this,
|
|
4355
4481
|
A: [
|
|
4356
4482
|
"options.newAutomergeRoot",
|
|
@@ -4360,7 +4486,7 @@ var DataSpace = class {
|
|
|
4360
4486
|
epoch = {
|
|
4361
4487
|
previousId: this._automergeSpaceState.lastEpoch?.id,
|
|
4362
4488
|
number: (this._automergeSpaceState.lastEpoch?.subject.assertion.number ?? -1) + 1,
|
|
4363
|
-
timeframe: this._automergeSpaceState.lastEpoch?.subject.assertion.timeframe ?? new
|
|
4489
|
+
timeframe: this._automergeSpaceState.lastEpoch?.subject.assertion.timeframe ?? new Timeframe3(),
|
|
4364
4490
|
automergeRoot: options.newAutomergeRoot
|
|
4365
4491
|
};
|
|
4366
4492
|
}
|
|
@@ -4380,7 +4506,7 @@ var DataSpace = class {
|
|
|
4380
4506
|
})
|
|
4381
4507
|
}
|
|
4382
4508
|
});
|
|
4383
|
-
await this.inner.controlPipeline.state.waitUntilTimeframe(new
|
|
4509
|
+
await this.inner.controlPipeline.state.waitUntilTimeframe(new Timeframe3([
|
|
4384
4510
|
[
|
|
4385
4511
|
receipt.feedKey,
|
|
4386
4512
|
receipt.seq
|
|
@@ -4389,25 +4515,30 @@ var DataSpace = class {
|
|
|
4389
4515
|
await this._echoHost.updateIndexes();
|
|
4390
4516
|
}
|
|
4391
4517
|
async activate() {
|
|
4392
|
-
if (
|
|
4518
|
+
if (![
|
|
4519
|
+
SpaceState2.CLOSED,
|
|
4520
|
+
SpaceState2.INACTIVE
|
|
4521
|
+
].includes(this._state)) {
|
|
4393
4522
|
return;
|
|
4394
4523
|
}
|
|
4395
|
-
await this._metadataStore.setSpaceState(this.key,
|
|
4524
|
+
await this._metadataStore.setSpaceState(this.key, SpaceState2.ACTIVE);
|
|
4396
4525
|
await this._open();
|
|
4397
4526
|
this.initializeDataPipelineAsync();
|
|
4398
4527
|
}
|
|
4399
4528
|
async deactivate() {
|
|
4400
|
-
if (this._state ===
|
|
4529
|
+
if (this._state === SpaceState2.INACTIVE) {
|
|
4401
4530
|
return;
|
|
4402
4531
|
}
|
|
4403
|
-
await this._metadataStore.setSpaceState(this.key,
|
|
4404
|
-
|
|
4405
|
-
|
|
4406
|
-
|
|
4407
|
-
|
|
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]
|
|
4408
4539
|
}, {
|
|
4409
|
-
F:
|
|
4410
|
-
L:
|
|
4540
|
+
F: __dxlog_file16,
|
|
4541
|
+
L: 571,
|
|
4411
4542
|
S: this,
|
|
4412
4543
|
C: (f, a) => f(...a)
|
|
4413
4544
|
});
|
|
@@ -4425,7 +4556,7 @@ _ts_decorate4([
|
|
|
4425
4556
|
], DataSpace.prototype, "key", null);
|
|
4426
4557
|
_ts_decorate4([
|
|
4427
4558
|
trace6.info({
|
|
4428
|
-
enum:
|
|
4559
|
+
enum: SpaceState2
|
|
4429
4560
|
})
|
|
4430
4561
|
], DataSpace.prototype, "state", null);
|
|
4431
4562
|
_ts_decorate4([
|
|
@@ -4477,24 +4608,27 @@ var findPropertiesObject = (spaceDoc) => {
|
|
|
4477
4608
|
|
|
4478
4609
|
// packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts
|
|
4479
4610
|
import { Event as Event7, synchronized as synchronized2, trackLeaks as trackLeaks2 } from "@dxos/async";
|
|
4611
|
+
import { PropertiesType } from "@dxos/client-protocol";
|
|
4480
4612
|
import { cancelWithContext as cancelWithContext5, Context as Context9 } from "@dxos/context";
|
|
4481
|
-
import { getCredentialAssertion as
|
|
4613
|
+
import { getCredentialAssertion as getCredentialAssertion3 } from "@dxos/credentials";
|
|
4482
4614
|
import { AuthStatus } from "@dxos/echo-pipeline";
|
|
4615
|
+
import { encodeReference } from "@dxos/echo-protocol";
|
|
4616
|
+
import { generateEchoId, getTypeReference } from "@dxos/echo-schema";
|
|
4483
4617
|
import { invariant as invariant14 } from "@dxos/invariant";
|
|
4484
4618
|
import { PublicKey as PublicKey11 } from "@dxos/keys";
|
|
4485
|
-
import { log as
|
|
4619
|
+
import { log as log14 } from "@dxos/log";
|
|
4486
4620
|
import { trace as Trace2 } from "@dxos/protocols";
|
|
4487
|
-
import { Invitation as Invitation7, SpaceState as
|
|
4621
|
+
import { Invitation as Invitation7, SpaceState as SpaceState3 } from "@dxos/protocols/proto/dxos/client/services";
|
|
4488
4622
|
import { SpaceMember as SpaceMember6 } from "@dxos/protocols/proto/dxos/halo/credentials";
|
|
4489
4623
|
import { Gossip as Gossip2, Presence as Presence2 } from "@dxos/teleport-extension-gossip";
|
|
4490
4624
|
import { trace as trace7 } from "@dxos/tracing";
|
|
4491
|
-
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";
|
|
4492
4626
|
|
|
4493
4627
|
// packages/sdk/client-services/src/packlets/spaces/genesis.ts
|
|
4494
4628
|
import { createCredential } from "@dxos/credentials";
|
|
4495
4629
|
import { failUndefined } from "@dxos/debug";
|
|
4496
4630
|
import { AdmittedFeed as AdmittedFeed4, SpaceMember as SpaceMember5 } from "@dxos/protocols/proto/dxos/halo/credentials";
|
|
4497
|
-
import { Timeframe as
|
|
4631
|
+
import { Timeframe as Timeframe4 } from "@dxos/timeframe";
|
|
4498
4632
|
var spaceGenesis = async (keyring, signingContext, space, automergeRoot) => {
|
|
4499
4633
|
const credentials = [
|
|
4500
4634
|
await createCredential({
|
|
@@ -4544,7 +4678,7 @@ var spaceGenesis = async (keyring, signingContext, space, automergeRoot) => {
|
|
|
4544
4678
|
"@type": "dxos.halo.credentials.Epoch",
|
|
4545
4679
|
number: 0,
|
|
4546
4680
|
previousId: void 0,
|
|
4547
|
-
timeframe: new
|
|
4681
|
+
timeframe: new Timeframe4(),
|
|
4548
4682
|
snapshotCid: void 0,
|
|
4549
4683
|
automergeRoot
|
|
4550
4684
|
}
|
|
@@ -4571,11 +4705,12 @@ function _ts_decorate5(decorators, target, key, desc) {
|
|
|
4571
4705
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
4572
4706
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4573
4707
|
}
|
|
4574
|
-
var
|
|
4708
|
+
var __dxlog_file17 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts";
|
|
4575
4709
|
var PRESENCE_ANNOUNCE_INTERVAL = 1e4;
|
|
4576
4710
|
var PRESENCE_OFFLINE_TIMEOUT = 2e4;
|
|
4711
|
+
var DEFAULT_SPACE_KEY = "__DEFAULT__";
|
|
4577
4712
|
var DataSpaceManager = class {
|
|
4578
|
-
constructor(_spaceManager, _metadataStore, _keyring, _signingContext, _feedStore, _echoHost, _invitationsManager,
|
|
4713
|
+
constructor(_spaceManager, _metadataStore, _keyring, _signingContext, _feedStore, _echoHost, _invitationsManager, _params) {
|
|
4579
4714
|
this._spaceManager = _spaceManager;
|
|
4580
4715
|
this._metadataStore = _metadataStore;
|
|
4581
4716
|
this._keyring = _keyring;
|
|
@@ -4583,14 +4718,12 @@ var DataSpaceManager = class {
|
|
|
4583
4718
|
this._feedStore = _feedStore;
|
|
4584
4719
|
this._echoHost = _echoHost;
|
|
4585
4720
|
this._invitationsManager = _invitationsManager;
|
|
4721
|
+
this._params = _params;
|
|
4586
4722
|
this._ctx = new Context9();
|
|
4587
4723
|
this.updated = new Event7();
|
|
4588
4724
|
this._spaces = new ComplexMap3(PublicKey11.hash);
|
|
4589
4725
|
this._isOpen = false;
|
|
4590
4726
|
this._instanceId = PublicKey11.random().toHex();
|
|
4591
|
-
const { spaceMemberPresenceAnnounceInterval = PRESENCE_ANNOUNCE_INTERVAL, spaceMemberPresenceOfflineTimeout = PRESENCE_OFFLINE_TIMEOUT } = params ?? {};
|
|
4592
|
-
this._spaceMemberPresenceAnnounceInterval = spaceMemberPresenceAnnounceInterval;
|
|
4593
|
-
this._spaceMemberPresenceOfflineTimeout = spaceMemberPresenceOfflineTimeout;
|
|
4594
4727
|
trace7.diagnostic({
|
|
4595
4728
|
id: "spaces",
|
|
4596
4729
|
name: "Spaces",
|
|
@@ -4602,7 +4735,7 @@ var DataSpaceManager = class {
|
|
|
4602
4735
|
const properties = rootDoc && findPropertiesObject(rootDoc);
|
|
4603
4736
|
return {
|
|
4604
4737
|
key: space.key.toHex(),
|
|
4605
|
-
state:
|
|
4738
|
+
state: SpaceState3[space.state],
|
|
4606
4739
|
name: properties?.[1].data.name ?? null,
|
|
4607
4740
|
inlineObjects: rootDoc ? Object.keys(rootDoc.objects ?? {}).length : null,
|
|
4608
4741
|
linkedObjects: rootDoc ? Object.keys(rootDoc.links ?? {}).length : null,
|
|
@@ -4619,46 +4752,46 @@ var DataSpaceManager = class {
|
|
|
4619
4752
|
return this._spaces;
|
|
4620
4753
|
}
|
|
4621
4754
|
async open() {
|
|
4622
|
-
|
|
4623
|
-
F:
|
|
4624
|
-
L:
|
|
4755
|
+
log14("open", void 0, {
|
|
4756
|
+
F: __dxlog_file17,
|
|
4757
|
+
L: 140,
|
|
4625
4758
|
S: this,
|
|
4626
4759
|
C: (f, a) => f(...a)
|
|
4627
4760
|
});
|
|
4628
|
-
|
|
4761
|
+
log14.trace("dxos.echo.data-space-manager.open", Trace2.begin({
|
|
4629
4762
|
id: this._instanceId
|
|
4630
4763
|
}), {
|
|
4631
|
-
F:
|
|
4632
|
-
L:
|
|
4764
|
+
F: __dxlog_file17,
|
|
4765
|
+
L: 141,
|
|
4633
4766
|
S: this,
|
|
4634
4767
|
C: (f, a) => f(...a)
|
|
4635
4768
|
});
|
|
4636
|
-
|
|
4769
|
+
log14("metadata loaded", {
|
|
4637
4770
|
spaces: this._metadataStore.spaces.length
|
|
4638
4771
|
}, {
|
|
4639
|
-
F:
|
|
4640
|
-
L:
|
|
4772
|
+
F: __dxlog_file17,
|
|
4773
|
+
L: 142,
|
|
4641
4774
|
S: this,
|
|
4642
4775
|
C: (f, a) => f(...a)
|
|
4643
4776
|
});
|
|
4644
4777
|
await forEachAsync(this._metadataStore.spaces, async (spaceMetadata) => {
|
|
4645
4778
|
try {
|
|
4646
|
-
|
|
4779
|
+
log14("load space", {
|
|
4647
4780
|
spaceMetadata
|
|
4648
4781
|
}, {
|
|
4649
|
-
F:
|
|
4650
|
-
L:
|
|
4782
|
+
F: __dxlog_file17,
|
|
4783
|
+
L: 146,
|
|
4651
4784
|
S: this,
|
|
4652
4785
|
C: (f, a) => f(...a)
|
|
4653
4786
|
});
|
|
4654
4787
|
await this._constructSpace(spaceMetadata);
|
|
4655
4788
|
} catch (err) {
|
|
4656
|
-
|
|
4789
|
+
log14.error("Error loading space", {
|
|
4657
4790
|
spaceMetadata,
|
|
4658
4791
|
err
|
|
4659
4792
|
}, {
|
|
4660
|
-
F:
|
|
4661
|
-
L:
|
|
4793
|
+
F: __dxlog_file17,
|
|
4794
|
+
L: 149,
|
|
4662
4795
|
S: this,
|
|
4663
4796
|
C: (f, a) => f(...a)
|
|
4664
4797
|
});
|
|
@@ -4666,24 +4799,19 @@ var DataSpaceManager = class {
|
|
|
4666
4799
|
});
|
|
4667
4800
|
this._isOpen = true;
|
|
4668
4801
|
this.updated.emit();
|
|
4669
|
-
|
|
4670
|
-
if (space.state !== SpaceState2.INACTIVE) {
|
|
4671
|
-
space.initializeDataPipelineAsync();
|
|
4672
|
-
}
|
|
4673
|
-
}
|
|
4674
|
-
log13.trace("dxos.echo.data-space-manager.open", Trace2.end({
|
|
4802
|
+
log14.trace("dxos.echo.data-space-manager.open", Trace2.end({
|
|
4675
4803
|
id: this._instanceId
|
|
4676
4804
|
}), {
|
|
4677
|
-
F:
|
|
4678
|
-
L:
|
|
4805
|
+
F: __dxlog_file17,
|
|
4806
|
+
L: 156,
|
|
4679
4807
|
S: this,
|
|
4680
4808
|
C: (f, a) => f(...a)
|
|
4681
4809
|
});
|
|
4682
4810
|
}
|
|
4683
4811
|
async close() {
|
|
4684
|
-
|
|
4685
|
-
F:
|
|
4686
|
-
L:
|
|
4812
|
+
log14("close", void 0, {
|
|
4813
|
+
F: __dxlog_file17,
|
|
4814
|
+
L: 161,
|
|
4687
4815
|
S: this,
|
|
4688
4816
|
C: (f, a) => f(...a)
|
|
4689
4817
|
});
|
|
@@ -4692,14 +4820,15 @@ var DataSpaceManager = class {
|
|
|
4692
4820
|
for (const space of this._spaces.values()) {
|
|
4693
4821
|
await space.close();
|
|
4694
4822
|
}
|
|
4823
|
+
this._spaces.clear();
|
|
4695
4824
|
}
|
|
4696
4825
|
/**
|
|
4697
4826
|
* Creates a new space writing the genesis credentials to the control feed.
|
|
4698
4827
|
*/
|
|
4699
4828
|
async createSpace() {
|
|
4700
4829
|
invariant14(this._isOpen, "Not open.", {
|
|
4701
|
-
F:
|
|
4702
|
-
L:
|
|
4830
|
+
F: __dxlog_file17,
|
|
4831
|
+
L: 175,
|
|
4703
4832
|
S: this,
|
|
4704
4833
|
A: [
|
|
4705
4834
|
"this._isOpen",
|
|
@@ -4714,24 +4843,25 @@ var DataSpaceManager = class {
|
|
|
4714
4843
|
genesisFeedKey: controlFeedKey,
|
|
4715
4844
|
controlFeedKey,
|
|
4716
4845
|
dataFeedKey,
|
|
4717
|
-
state:
|
|
4846
|
+
state: SpaceState3.ACTIVE
|
|
4718
4847
|
};
|
|
4719
|
-
|
|
4848
|
+
log14("creating space...", {
|
|
4720
4849
|
spaceKey
|
|
4721
4850
|
}, {
|
|
4722
|
-
F:
|
|
4723
|
-
L:
|
|
4851
|
+
F: __dxlog_file17,
|
|
4852
|
+
L: 187,
|
|
4724
4853
|
S: this,
|
|
4725
4854
|
C: (f, a) => f(...a)
|
|
4726
4855
|
});
|
|
4727
4856
|
const root = await this._echoHost.createSpaceRoot(spaceKey);
|
|
4728
4857
|
const space = await this._constructSpace(metadata);
|
|
4858
|
+
await space.open();
|
|
4729
4859
|
const credentials = await spaceGenesis(this._keyring, this._signingContext, space.inner, root.url);
|
|
4730
4860
|
await this._metadataStore.addSpace(metadata);
|
|
4731
4861
|
const memberCredential = credentials[1];
|
|
4732
|
-
invariant14(
|
|
4733
|
-
F:
|
|
4734
|
-
L:
|
|
4862
|
+
invariant14(getCredentialAssertion3(memberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
|
|
4863
|
+
F: __dxlog_file17,
|
|
4864
|
+
L: 197,
|
|
4735
4865
|
S: this,
|
|
4736
4866
|
A: [
|
|
4737
4867
|
"getCredentialAssertion(memberCredential)['@type'] === 'dxos.halo.credentials.SpaceMember'",
|
|
@@ -4743,19 +4873,63 @@ var DataSpaceManager = class {
|
|
|
4743
4873
|
this.updated.emit();
|
|
4744
4874
|
return space;
|
|
4745
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
|
+
}
|
|
4746
4920
|
// TODO(burdon): Rename join space.
|
|
4747
4921
|
async acceptSpace(opts) {
|
|
4748
|
-
|
|
4922
|
+
log14("accept space", {
|
|
4749
4923
|
opts
|
|
4750
4924
|
}, {
|
|
4751
|
-
F:
|
|
4752
|
-
L:
|
|
4925
|
+
F: __dxlog_file17,
|
|
4926
|
+
L: 249,
|
|
4753
4927
|
S: this,
|
|
4754
4928
|
C: (f, a) => f(...a)
|
|
4755
4929
|
});
|
|
4756
4930
|
invariant14(this._isOpen, "Not open.", {
|
|
4757
|
-
F:
|
|
4758
|
-
L:
|
|
4931
|
+
F: __dxlog_file17,
|
|
4932
|
+
L: 250,
|
|
4759
4933
|
S: this,
|
|
4760
4934
|
A: [
|
|
4761
4935
|
"this._isOpen",
|
|
@@ -4763,8 +4937,8 @@ var DataSpaceManager = class {
|
|
|
4763
4937
|
]
|
|
4764
4938
|
});
|
|
4765
4939
|
invariant14(!this._spaces.has(opts.spaceKey), "Space already exists.", {
|
|
4766
|
-
F:
|
|
4767
|
-
L:
|
|
4940
|
+
F: __dxlog_file17,
|
|
4941
|
+
L: 251,
|
|
4768
4942
|
S: this,
|
|
4769
4943
|
A: [
|
|
4770
4944
|
"!this._spaces.has(opts.spaceKey)",
|
|
@@ -4778,6 +4952,7 @@ var DataSpaceManager = class {
|
|
|
4778
4952
|
dataTimeframe: opts.dataTimeframe
|
|
4779
4953
|
};
|
|
4780
4954
|
const space = await this._constructSpace(metadata);
|
|
4955
|
+
await space.open();
|
|
4781
4956
|
await this._metadataStore.addSpace(metadata);
|
|
4782
4957
|
space.initializeDataPipelineAsync();
|
|
4783
4958
|
this.updated.emit();
|
|
@@ -4791,15 +4966,15 @@ var DataSpaceManager = class {
|
|
|
4791
4966
|
async waitUntilSpaceReady(spaceKey) {
|
|
4792
4967
|
await cancelWithContext5(this._ctx, this.updated.waitForCondition(() => {
|
|
4793
4968
|
const space = this._spaces.get(spaceKey);
|
|
4794
|
-
return !!space && space.state ===
|
|
4969
|
+
return !!space && space.state === SpaceState3.READY;
|
|
4795
4970
|
}));
|
|
4796
4971
|
}
|
|
4797
4972
|
async _constructSpace(metadata) {
|
|
4798
|
-
|
|
4973
|
+
log14("construct space", {
|
|
4799
4974
|
metadata
|
|
4800
4975
|
}, {
|
|
4801
|
-
F:
|
|
4802
|
-
L:
|
|
4976
|
+
F: __dxlog_file17,
|
|
4977
|
+
L: 285,
|
|
4803
4978
|
S: this,
|
|
4804
4979
|
C: (f, a) => f(...a)
|
|
4805
4980
|
});
|
|
@@ -4807,8 +4982,8 @@ var DataSpaceManager = class {
|
|
|
4807
4982
|
localPeerId: this._signingContext.deviceKey
|
|
4808
4983
|
});
|
|
4809
4984
|
const presence = new Presence2({
|
|
4810
|
-
announceInterval: this.
|
|
4811
|
-
offlineTimeout: this.
|
|
4985
|
+
announceInterval: this._params?.spaceMemberPresenceAnnounceInterval ?? PRESENCE_ANNOUNCE_INTERVAL,
|
|
4986
|
+
offlineTimeout: this._params?.spaceMemberPresenceOfflineTimeout ?? PRESENCE_OFFLINE_TIMEOUT,
|
|
4812
4987
|
identityKey: this._signingContext.identityKey,
|
|
4813
4988
|
gossip
|
|
4814
4989
|
});
|
|
@@ -4835,15 +5010,15 @@ var DataSpaceManager = class {
|
|
|
4835
5010
|
session.addExtension("dxos.mesh.teleport.automerge", this._echoHost.createReplicationExtension());
|
|
4836
5011
|
},
|
|
4837
5012
|
onAuthFailure: () => {
|
|
4838
|
-
|
|
4839
|
-
F:
|
|
4840
|
-
L:
|
|
5013
|
+
log14.warn("auth failure", void 0, {
|
|
5014
|
+
F: __dxlog_file17,
|
|
5015
|
+
L: 322,
|
|
4841
5016
|
S: this,
|
|
4842
5017
|
C: (f, a) => f(...a)
|
|
4843
5018
|
});
|
|
4844
5019
|
},
|
|
4845
5020
|
onMemberRolesChanged: async (members) => {
|
|
4846
|
-
if (dataSpace?.state ===
|
|
5021
|
+
if (dataSpace?.state === SpaceState3.READY) {
|
|
4847
5022
|
this._handleMemberRoleChanges(presence, space.protocol, members);
|
|
4848
5023
|
}
|
|
4849
5024
|
},
|
|
@@ -4856,7 +5031,7 @@ var DataSpaceManager = class {
|
|
|
4856
5031
|
dataFeed && await space.setDataFeed(dataFeed);
|
|
4857
5032
|
const dataSpace = new DataSpace({
|
|
4858
5033
|
inner: space,
|
|
4859
|
-
initialState: metadata.state ===
|
|
5034
|
+
initialState: metadata.state === SpaceState3.INACTIVE ? SpaceState3.INACTIVE : SpaceState3.CLOSED,
|
|
4860
5035
|
metadataStore: this._metadataStore,
|
|
4861
5036
|
gossip,
|
|
4862
5037
|
presence,
|
|
@@ -4866,22 +5041,22 @@ var DataSpaceManager = class {
|
|
|
4866
5041
|
signingContext: this._signingContext,
|
|
4867
5042
|
callbacks: {
|
|
4868
5043
|
beforeReady: async () => {
|
|
4869
|
-
|
|
5044
|
+
log14("before space ready", {
|
|
4870
5045
|
space: space.key
|
|
4871
5046
|
}, {
|
|
4872
|
-
F:
|
|
4873
|
-
L:
|
|
5047
|
+
F: __dxlog_file17,
|
|
5048
|
+
L: 349,
|
|
4874
5049
|
S: this,
|
|
4875
5050
|
C: (f, a) => f(...a)
|
|
4876
5051
|
});
|
|
4877
5052
|
},
|
|
4878
5053
|
afterReady: async () => {
|
|
4879
|
-
|
|
5054
|
+
log14("after space ready", {
|
|
4880
5055
|
space: space.key,
|
|
4881
5056
|
open: this._isOpen
|
|
4882
5057
|
}, {
|
|
4883
|
-
F:
|
|
4884
|
-
L:
|
|
5058
|
+
F: __dxlog_file17,
|
|
5059
|
+
L: 352,
|
|
4885
5060
|
S: this,
|
|
4886
5061
|
C: (f, a) => f(...a)
|
|
4887
5062
|
});
|
|
@@ -4896,11 +5071,11 @@ var DataSpaceManager = class {
|
|
|
4896
5071
|
}
|
|
4897
5072
|
},
|
|
4898
5073
|
beforeClose: async () => {
|
|
4899
|
-
|
|
5074
|
+
log14("before space close", {
|
|
4900
5075
|
space: space.key
|
|
4901
5076
|
}, {
|
|
4902
|
-
F:
|
|
4903
|
-
L:
|
|
5077
|
+
F: __dxlog_file17,
|
|
5078
|
+
L: 360,
|
|
4904
5079
|
S: this,
|
|
4905
5080
|
C: (f, a) => f(...a)
|
|
4906
5081
|
});
|
|
@@ -4909,13 +5084,10 @@ var DataSpaceManager = class {
|
|
|
4909
5084
|
cache: metadata.cache
|
|
4910
5085
|
});
|
|
4911
5086
|
presence.newPeer.on((peerState) => {
|
|
4912
|
-
if (dataSpace.state ===
|
|
5087
|
+
if (dataSpace.state === SpaceState3.READY) {
|
|
4913
5088
|
this._handleNewPeerConnected(space, peerState);
|
|
4914
5089
|
}
|
|
4915
5090
|
});
|
|
4916
|
-
if (metadata.state !== SpaceState2.INACTIVE) {
|
|
4917
|
-
await dataSpace.open();
|
|
4918
|
-
}
|
|
4919
5091
|
if (metadata.controlTimeframe) {
|
|
4920
5092
|
dataSpace.inner.controlPipeline.state.setTargetTimeframe(metadata.controlTimeframe);
|
|
4921
5093
|
}
|
|
@@ -4934,17 +5106,17 @@ var DataSpaceManager = class {
|
|
|
4934
5106
|
return (s && member.role === SpaceMember6.Role.REMOVED !== (s.authStatus === AuthStatus.FAILURE)) ?? false;
|
|
4935
5107
|
});
|
|
4936
5108
|
sessionsToClose.forEach((session) => {
|
|
4937
|
-
void session.close().catch(
|
|
5109
|
+
void session.close().catch(log14.error);
|
|
4938
5110
|
});
|
|
4939
5111
|
closedSessions += sessionsToClose.length;
|
|
4940
5112
|
}
|
|
4941
|
-
|
|
5113
|
+
log14("processed member role changes", {
|
|
4942
5114
|
roleChangeCount: memberInfo.length,
|
|
4943
5115
|
peersOnline: presence.getPeersOnline().length,
|
|
4944
5116
|
closedSessions
|
|
4945
5117
|
}, {
|
|
4946
|
-
F:
|
|
4947
|
-
L:
|
|
5118
|
+
F: __dxlog_file17,
|
|
5119
|
+
L: 396,
|
|
4948
5120
|
S: this,
|
|
4949
5121
|
C: (f, a) => f(...a)
|
|
4950
5122
|
});
|
|
@@ -4955,20 +5127,20 @@ var DataSpaceManager = class {
|
|
|
4955
5127
|
if (role === SpaceMember6.Role.REMOVED) {
|
|
4956
5128
|
const session = peerState.peerId && space.protocol.sessions.get(peerState.peerId);
|
|
4957
5129
|
if (session != null) {
|
|
4958
|
-
|
|
5130
|
+
log14("closing a session with a removed peer", {
|
|
4959
5131
|
peerId: peerState.peerId
|
|
4960
5132
|
}, {
|
|
4961
|
-
F:
|
|
4962
|
-
L:
|
|
5133
|
+
F: __dxlog_file17,
|
|
5134
|
+
L: 410,
|
|
4963
5135
|
S: this,
|
|
4964
5136
|
C: (f, a) => f(...a)
|
|
4965
5137
|
});
|
|
4966
|
-
void session.close().catch(
|
|
5138
|
+
void session.close().catch(log14.error);
|
|
4967
5139
|
}
|
|
4968
5140
|
}
|
|
4969
5141
|
}
|
|
4970
5142
|
async _handleInvitationStatusChange(dataSpace, delegatedInvitation, isActive) {
|
|
4971
|
-
if (dataSpace?.state !==
|
|
5143
|
+
if (dataSpace?.state !== SpaceState3.READY) {
|
|
4972
5144
|
return;
|
|
4973
5145
|
}
|
|
4974
5146
|
if (isActive) {
|
|
@@ -5022,15 +5194,15 @@ DataSpaceManager = _ts_decorate5([
|
|
|
5022
5194
|
// packages/sdk/client-services/src/packlets/spaces/spaces-service.ts
|
|
5023
5195
|
import { EventSubscriptions as EventSubscriptions2, UpdateScheduler, scheduleTask as scheduleTask6 } from "@dxos/async";
|
|
5024
5196
|
import { Stream as Stream10 } from "@dxos/codec-protobuf";
|
|
5025
|
-
import { createAdmissionCredentials as createAdmissionCredentials2, getCredentialAssertion as
|
|
5197
|
+
import { createAdmissionCredentials as createAdmissionCredentials2, getCredentialAssertion as getCredentialAssertion4 } from "@dxos/credentials";
|
|
5026
5198
|
import { raise as raise2 } from "@dxos/debug";
|
|
5027
5199
|
import { writeMessages as writeMessages3 } from "@dxos/feed-store";
|
|
5028
5200
|
import { invariant as invariant15 } from "@dxos/invariant";
|
|
5029
|
-
import { log as
|
|
5201
|
+
import { log as log15 } from "@dxos/log";
|
|
5030
5202
|
import { ApiError, SpaceNotFoundError as SpaceNotFoundError2, encodeError, IdentityNotInitializedError, AuthorizationError as AuthorizationError2 } from "@dxos/protocols";
|
|
5031
|
-
import { SpaceMember as SpaceMember7, SpaceState as
|
|
5203
|
+
import { SpaceMember as SpaceMember7, SpaceState as SpaceState4 } from "@dxos/protocols/proto/dxos/client/services";
|
|
5032
5204
|
import { trace as trace8 } from "@dxos/tracing";
|
|
5033
|
-
var
|
|
5205
|
+
var __dxlog_file18 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/spaces-service.ts";
|
|
5034
5206
|
var SpacesServiceImpl = class {
|
|
5035
5207
|
constructor(_identityManager, _spaceManager, _getDataSpaceManager) {
|
|
5036
5208
|
this._identityManager = _identityManager;
|
|
@@ -5049,10 +5221,10 @@ var SpacesServiceImpl = class {
|
|
|
5049
5221
|
const space = dataSpaceManager.spaces.get(spaceKey) ?? raise2(new SpaceNotFoundError2(spaceKey));
|
|
5050
5222
|
if (state) {
|
|
5051
5223
|
switch (state) {
|
|
5052
|
-
case
|
|
5224
|
+
case SpaceState4.ACTIVE:
|
|
5053
5225
|
await space.activate();
|
|
5054
5226
|
break;
|
|
5055
|
-
case
|
|
5227
|
+
case SpaceState4.INACTIVE:
|
|
5056
5228
|
await space.deactivate();
|
|
5057
5229
|
break;
|
|
5058
5230
|
default:
|
|
@@ -5074,7 +5246,7 @@ var SpacesServiceImpl = class {
|
|
|
5074
5246
|
}
|
|
5075
5247
|
const credentials = await createAdmissionCredentials2(identity.getIdentityCredentialSigner(), request.memberKey, space.key, space.genesisFeedKey, request.newRole, space.spaceState.membershipChainHeads);
|
|
5076
5248
|
invariant15(credentials[0].credential, void 0, {
|
|
5077
|
-
F:
|
|
5249
|
+
F: __dxlog_file18,
|
|
5078
5250
|
L: 97,
|
|
5079
5251
|
S: this,
|
|
5080
5252
|
A: [
|
|
@@ -5083,8 +5255,8 @@ var SpacesServiceImpl = class {
|
|
|
5083
5255
|
]
|
|
5084
5256
|
});
|
|
5085
5257
|
const spaceMemberCredential = credentials[0].credential.credential;
|
|
5086
|
-
invariant15(
|
|
5087
|
-
F:
|
|
5258
|
+
invariant15(getCredentialAssertion4(spaceMemberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
|
|
5259
|
+
F: __dxlog_file18,
|
|
5088
5260
|
L: 99,
|
|
5089
5261
|
S: this,
|
|
5090
5262
|
A: [
|
|
@@ -5099,10 +5271,10 @@ var SpacesServiceImpl = class {
|
|
|
5099
5271
|
const scheduler = new UpdateScheduler(ctx, async () => {
|
|
5100
5272
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
5101
5273
|
const spaces = Array.from(dataSpaceManager.spaces.values()).map((space) => this._serializeSpace(space));
|
|
5102
|
-
|
|
5274
|
+
log15("update", {
|
|
5103
5275
|
spaces
|
|
5104
5276
|
}, {
|
|
5105
|
-
F:
|
|
5277
|
+
F: __dxlog_file18,
|
|
5106
5278
|
L: 110,
|
|
5107
5279
|
S: this,
|
|
5108
5280
|
C: (f, a) => f(...a)
|
|
@@ -5186,7 +5358,7 @@ var SpacesServiceImpl = class {
|
|
|
5186
5358
|
});
|
|
5187
5359
|
} else {
|
|
5188
5360
|
invariant15(!credential.id, "Id on unsigned credentials is not allowed", {
|
|
5189
|
-
F:
|
|
5361
|
+
F: __dxlog_file18,
|
|
5190
5362
|
L: 198,
|
|
5191
5363
|
S: this,
|
|
5192
5364
|
A: [
|
|
@@ -5195,7 +5367,7 @@ var SpacesServiceImpl = class {
|
|
|
5195
5367
|
]
|
|
5196
5368
|
});
|
|
5197
5369
|
invariant15(this._identityManager.identity, "Identity is not available", {
|
|
5198
|
-
F:
|
|
5370
|
+
F: __dxlog_file18,
|
|
5199
5371
|
L: 199,
|
|
5200
5372
|
S: this,
|
|
5201
5373
|
A: [
|
|
@@ -5205,7 +5377,7 @@ var SpacesServiceImpl = class {
|
|
|
5205
5377
|
});
|
|
5206
5378
|
const signer = this._identityManager.identity.getIdentityCredentialSigner();
|
|
5207
5379
|
invariant15(credential.issuer.equals(signer.getIssuer()), void 0, {
|
|
5208
|
-
F:
|
|
5380
|
+
F: __dxlog_file18,
|
|
5209
5381
|
L: 201,
|
|
5210
5382
|
S: this,
|
|
5211
5383
|
A: [
|
|
@@ -5295,8 +5467,8 @@ var getChannelId = (channel) => `user-channel/${channel}`;
|
|
|
5295
5467
|
|
|
5296
5468
|
// packages/sdk/client-services/src/packlets/services/service-context.ts
|
|
5297
5469
|
import { Trigger as Trigger7 } from "@dxos/async";
|
|
5298
|
-
import { Context as Context10, Resource } from "@dxos/context";
|
|
5299
|
-
import { getCredentialAssertion as
|
|
5470
|
+
import { Context as Context10, Resource as Resource2 } from "@dxos/context";
|
|
5471
|
+
import { getCredentialAssertion as getCredentialAssertion5 } from "@dxos/credentials";
|
|
5300
5472
|
import { failUndefined as failUndefined2 } from "@dxos/debug";
|
|
5301
5473
|
import { EchoHost } from "@dxos/echo-db";
|
|
5302
5474
|
import { MetadataStore, SnapshotStore, SpaceManager, valueEncoding } from "@dxos/echo-pipeline";
|
|
@@ -5304,7 +5476,7 @@ import { FeedFactory, FeedStore } from "@dxos/feed-store";
|
|
|
5304
5476
|
import { invariant as invariant16 } from "@dxos/invariant";
|
|
5305
5477
|
import { Keyring } from "@dxos/keyring";
|
|
5306
5478
|
import { PublicKey as PublicKey12 } from "@dxos/keys";
|
|
5307
|
-
import { log as
|
|
5479
|
+
import { log as log16 } from "@dxos/log";
|
|
5308
5480
|
import { InvalidStorageVersionError, STORAGE_VERSION as STORAGE_VERSION2, trace as trace9 } from "@dxos/protocols";
|
|
5309
5481
|
import { Invitation as Invitation8 } from "@dxos/protocols/proto/dxos/client/services";
|
|
5310
5482
|
import { BlobStore } from "@dxos/teleport-extension-object-sync";
|
|
@@ -5320,8 +5492,8 @@ function _ts_decorate6(decorators, target, key, desc) {
|
|
|
5320
5492
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5321
5493
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
5322
5494
|
}
|
|
5323
|
-
var
|
|
5324
|
-
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 {
|
|
5325
5497
|
constructor(storage, level, networkManager, signalManager, _runtimeParams) {
|
|
5326
5498
|
super();
|
|
5327
5499
|
this.storage = storage;
|
|
@@ -5355,8 +5527,7 @@ var ServiceContext = class extends Resource {
|
|
|
5355
5527
|
});
|
|
5356
5528
|
this.identityManager = new IdentityManager(this.metadataStore, this.keyring, this.feedStore, this.spaceManager, this._runtimeParams);
|
|
5357
5529
|
this.echoHost = new EchoHost({
|
|
5358
|
-
kv: this.level
|
|
5359
|
-
storage: this.storage
|
|
5530
|
+
kv: this.level
|
|
5360
5531
|
});
|
|
5361
5532
|
this.invitations = new InvitationsHandler(this.networkManager, _runtimeParams?.invitationConnectionDefaultParams);
|
|
5362
5533
|
this.invitationsManager = new InvitationsManager(this.invitations, (invitation) => this.getInvitationHandler(invitation), this.metadataStore);
|
|
@@ -5364,17 +5535,17 @@ var ServiceContext = class extends Resource {
|
|
|
5364
5535
|
}
|
|
5365
5536
|
async _open(ctx) {
|
|
5366
5537
|
await this._checkStorageVersion();
|
|
5367
|
-
|
|
5368
|
-
F:
|
|
5369
|
-
L:
|
|
5538
|
+
log16("opening...", void 0, {
|
|
5539
|
+
F: __dxlog_file19,
|
|
5540
|
+
L: 149,
|
|
5370
5541
|
S: this,
|
|
5371
5542
|
C: (f, a) => f(...a)
|
|
5372
5543
|
});
|
|
5373
|
-
|
|
5544
|
+
log16.trace("dxos.sdk.service-context.open", trace9.begin({
|
|
5374
5545
|
id: this._instanceId
|
|
5375
5546
|
}), {
|
|
5376
|
-
F:
|
|
5377
|
-
L:
|
|
5547
|
+
F: __dxlog_file19,
|
|
5548
|
+
L: 150,
|
|
5378
5549
|
S: this,
|
|
5379
5550
|
C: (f, a) => f(...a)
|
|
5380
5551
|
});
|
|
@@ -5388,33 +5559,33 @@ var ServiceContext = class extends Resource {
|
|
|
5388
5559
|
await this._initialize(ctx);
|
|
5389
5560
|
}
|
|
5390
5561
|
const loadedInvitations = await this.invitationsManager.loadPersistentInvitations();
|
|
5391
|
-
|
|
5562
|
+
log16("loaded persistent invitations", {
|
|
5392
5563
|
count: loadedInvitations.invitations?.length
|
|
5393
5564
|
}, {
|
|
5394
|
-
F:
|
|
5395
|
-
L:
|
|
5565
|
+
F: __dxlog_file19,
|
|
5566
|
+
L: 163,
|
|
5396
5567
|
S: this,
|
|
5397
5568
|
C: (f, a) => f(...a)
|
|
5398
5569
|
});
|
|
5399
|
-
|
|
5570
|
+
log16.trace("dxos.sdk.service-context.open", trace9.end({
|
|
5400
5571
|
id: this._instanceId
|
|
5401
5572
|
}), {
|
|
5402
|
-
F:
|
|
5403
|
-
L:
|
|
5573
|
+
F: __dxlog_file19,
|
|
5574
|
+
L: 165,
|
|
5404
5575
|
S: this,
|
|
5405
5576
|
C: (f, a) => f(...a)
|
|
5406
5577
|
});
|
|
5407
|
-
|
|
5408
|
-
F:
|
|
5409
|
-
L:
|
|
5578
|
+
log16("opened", void 0, {
|
|
5579
|
+
F: __dxlog_file19,
|
|
5580
|
+
L: 166,
|
|
5410
5581
|
S: this,
|
|
5411
5582
|
C: (f, a) => f(...a)
|
|
5412
5583
|
});
|
|
5413
5584
|
}
|
|
5414
5585
|
async _close(ctx) {
|
|
5415
|
-
|
|
5416
|
-
F:
|
|
5417
|
-
L:
|
|
5586
|
+
log16("closing...", void 0, {
|
|
5587
|
+
F: __dxlog_file19,
|
|
5588
|
+
L: 170,
|
|
5418
5589
|
S: this,
|
|
5419
5590
|
C: (f, a) => f(...a)
|
|
5420
5591
|
});
|
|
@@ -5429,9 +5600,9 @@ var ServiceContext = class extends Resource {
|
|
|
5429
5600
|
await this.echoHost.close(ctx);
|
|
5430
5601
|
await this.networkManager.close();
|
|
5431
5602
|
await this.signalManager.close();
|
|
5432
|
-
|
|
5433
|
-
F:
|
|
5434
|
-
L:
|
|
5603
|
+
log16("closed", void 0, {
|
|
5604
|
+
F: __dxlog_file19,
|
|
5605
|
+
L: 182,
|
|
5435
5606
|
S: this,
|
|
5436
5607
|
C: (f, a) => f(...a)
|
|
5437
5608
|
});
|
|
@@ -5444,8 +5615,8 @@ var ServiceContext = class extends Resource {
|
|
|
5444
5615
|
getInvitationHandler(invitation) {
|
|
5445
5616
|
const factory = this._handlerFactories.get(invitation.kind);
|
|
5446
5617
|
invariant16(factory, `Unknown invitation kind: ${invitation.kind}`, {
|
|
5447
|
-
F:
|
|
5448
|
-
L:
|
|
5618
|
+
F: __dxlog_file19,
|
|
5619
|
+
L: 193,
|
|
5449
5620
|
S: this,
|
|
5450
5621
|
A: [
|
|
5451
5622
|
"factory",
|
|
@@ -5475,9 +5646,9 @@ var ServiceContext = class extends Resource {
|
|
|
5475
5646
|
}
|
|
5476
5647
|
// Called when identity is created.
|
|
5477
5648
|
async _initialize(ctx) {
|
|
5478
|
-
|
|
5479
|
-
F:
|
|
5480
|
-
L:
|
|
5649
|
+
log16("initializing spaces...", void 0, {
|
|
5650
|
+
F: __dxlog_file19,
|
|
5651
|
+
L: 224,
|
|
5481
5652
|
S: this,
|
|
5482
5653
|
C: (f, a) => f(...a)
|
|
5483
5654
|
});
|
|
@@ -5499,8 +5670,8 @@ var ServiceContext = class extends Resource {
|
|
|
5499
5670
|
await this.dataSpaceManager.open();
|
|
5500
5671
|
this._handlerFactories.set(Invitation8.Kind.SPACE, (invitation) => {
|
|
5501
5672
|
invariant16(this.dataSpaceManager, "dataSpaceManager not initialized yet", {
|
|
5502
|
-
F:
|
|
5503
|
-
L:
|
|
5673
|
+
F: __dxlog_file19,
|
|
5674
|
+
L: 249,
|
|
5504
5675
|
S: this,
|
|
5505
5676
|
A: [
|
|
5506
5677
|
"this.dataSpaceManager",
|
|
@@ -5512,7 +5683,7 @@ var ServiceContext = class extends Resource {
|
|
|
5512
5683
|
this.initialized.wake();
|
|
5513
5684
|
this._deviceSpaceSync = {
|
|
5514
5685
|
processCredential: async (credential) => {
|
|
5515
|
-
const assertion =
|
|
5686
|
+
const assertion = getCredentialAssertion5(credential);
|
|
5516
5687
|
if (assertion["@type"] !== "dxos.halo.credentials.SpaceMember") {
|
|
5517
5688
|
return;
|
|
5518
5689
|
}
|
|
@@ -5520,33 +5691,33 @@ var ServiceContext = class extends Resource {
|
|
|
5520
5691
|
return;
|
|
5521
5692
|
}
|
|
5522
5693
|
if (!this.dataSpaceManager) {
|
|
5523
|
-
|
|
5694
|
+
log16("dataSpaceManager not initialized yet, ignoring space admission", {
|
|
5524
5695
|
details: assertion
|
|
5525
5696
|
}, {
|
|
5526
|
-
F:
|
|
5527
|
-
L:
|
|
5697
|
+
F: __dxlog_file19,
|
|
5698
|
+
L: 265,
|
|
5528
5699
|
S: this,
|
|
5529
5700
|
C: (f, a) => f(...a)
|
|
5530
5701
|
});
|
|
5531
5702
|
return;
|
|
5532
5703
|
}
|
|
5533
5704
|
if (this.dataSpaceManager.spaces.has(assertion.spaceKey)) {
|
|
5534
|
-
|
|
5705
|
+
log16("space already exists, ignoring space admission", {
|
|
5535
5706
|
details: assertion
|
|
5536
5707
|
}, {
|
|
5537
|
-
F:
|
|
5538
|
-
L:
|
|
5708
|
+
F: __dxlog_file19,
|
|
5709
|
+
L: 269,
|
|
5539
5710
|
S: this,
|
|
5540
5711
|
C: (f, a) => f(...a)
|
|
5541
5712
|
});
|
|
5542
5713
|
return;
|
|
5543
5714
|
}
|
|
5544
5715
|
try {
|
|
5545
|
-
|
|
5716
|
+
log16("accepting space recorded in halo", {
|
|
5546
5717
|
details: assertion
|
|
5547
5718
|
}, {
|
|
5548
|
-
F:
|
|
5549
|
-
L:
|
|
5719
|
+
F: __dxlog_file19,
|
|
5720
|
+
L: 274,
|
|
5550
5721
|
S: this,
|
|
5551
5722
|
C: (f, a) => f(...a)
|
|
5552
5723
|
});
|
|
@@ -5555,9 +5726,9 @@ var ServiceContext = class extends Resource {
|
|
|
5555
5726
|
genesisFeedKey: assertion.genesisFeedKey
|
|
5556
5727
|
});
|
|
5557
5728
|
} catch (err) {
|
|
5558
|
-
|
|
5559
|
-
F:
|
|
5560
|
-
L:
|
|
5729
|
+
log16.catch(err, void 0, {
|
|
5730
|
+
F: __dxlog_file19,
|
|
5731
|
+
L: 280,
|
|
5561
5732
|
S: this,
|
|
5562
5733
|
C: (f, a) => f(...a)
|
|
5563
5734
|
});
|
|
@@ -5605,7 +5776,7 @@ var ServiceRegistry = class {
|
|
|
5605
5776
|
// packages/sdk/client-services/src/packlets/locks/browser.ts
|
|
5606
5777
|
import { asyncTimeout as asyncTimeout3, Trigger as Trigger8 } from "@dxos/async";
|
|
5607
5778
|
import { RESOURCE_LOCK_TIMEOUT } from "@dxos/client-protocol";
|
|
5608
|
-
import { log as
|
|
5779
|
+
import { log as log17, logInfo } from "@dxos/log";
|
|
5609
5780
|
function _ts_decorate7(decorators, target, key, desc) {
|
|
5610
5781
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
5611
5782
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
@@ -5616,7 +5787,7 @@ function _ts_decorate7(decorators, target, key, desc) {
|
|
|
5616
5787
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5617
5788
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
5618
5789
|
}
|
|
5619
|
-
var
|
|
5790
|
+
var __dxlog_file20 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/locks/browser.ts";
|
|
5620
5791
|
var Message;
|
|
5621
5792
|
(function(Message2) {
|
|
5622
5793
|
Message2["ACQUIRING"] = "acquiring";
|
|
@@ -5638,29 +5809,29 @@ var Lock = class {
|
|
|
5638
5809
|
message: "acquiring"
|
|
5639
5810
|
});
|
|
5640
5811
|
try {
|
|
5641
|
-
|
|
5642
|
-
F:
|
|
5812
|
+
log17("aquiring lock...", void 0, {
|
|
5813
|
+
F: __dxlog_file20,
|
|
5643
5814
|
L: 42,
|
|
5644
5815
|
S: this,
|
|
5645
5816
|
C: (f, a) => f(...a)
|
|
5646
5817
|
});
|
|
5647
5818
|
await asyncTimeout3(this._requestLock(), RESOURCE_LOCK_TIMEOUT);
|
|
5648
|
-
|
|
5649
|
-
F:
|
|
5819
|
+
log17("acquired lock", void 0, {
|
|
5820
|
+
F: __dxlog_file20,
|
|
5650
5821
|
L: 44,
|
|
5651
5822
|
S: this,
|
|
5652
5823
|
C: (f, a) => f(...a)
|
|
5653
5824
|
});
|
|
5654
5825
|
} catch {
|
|
5655
|
-
|
|
5656
|
-
F:
|
|
5826
|
+
log17("stealing lock...", void 0, {
|
|
5827
|
+
F: __dxlog_file20,
|
|
5657
5828
|
L: 46,
|
|
5658
5829
|
S: this,
|
|
5659
5830
|
C: (f, a) => f(...a)
|
|
5660
5831
|
});
|
|
5661
5832
|
await this._requestLock(true);
|
|
5662
|
-
|
|
5663
|
-
F:
|
|
5833
|
+
log17("stolen lock", void 0, {
|
|
5834
|
+
F: __dxlog_file20,
|
|
5664
5835
|
L: 48,
|
|
5665
5836
|
S: this,
|
|
5666
5837
|
C: (f, a) => f(...a)
|
|
@@ -5676,10 +5847,10 @@ var Lock = class {
|
|
|
5676
5847
|
}
|
|
5677
5848
|
}
|
|
5678
5849
|
async _requestLock(steal = false) {
|
|
5679
|
-
|
|
5850
|
+
log17("requesting lock...", {
|
|
5680
5851
|
steal
|
|
5681
5852
|
}, {
|
|
5682
|
-
F:
|
|
5853
|
+
F: __dxlog_file20,
|
|
5683
5854
|
L: 63,
|
|
5684
5855
|
S: this,
|
|
5685
5856
|
C: (f, a) => f(...a)
|
|
@@ -5692,15 +5863,15 @@ var Lock = class {
|
|
|
5692
5863
|
acquired.wake();
|
|
5693
5864
|
this._releaseTrigger = new Trigger8();
|
|
5694
5865
|
await this._releaseTrigger.wait();
|
|
5695
|
-
|
|
5696
|
-
F:
|
|
5866
|
+
log17("releasing lock...", void 0, {
|
|
5867
|
+
F: __dxlog_file20,
|
|
5697
5868
|
L: 72,
|
|
5698
5869
|
S: this,
|
|
5699
5870
|
C: (f, a) => f(...a)
|
|
5700
5871
|
});
|
|
5701
5872
|
await this._onRelease?.();
|
|
5702
|
-
|
|
5703
|
-
F:
|
|
5873
|
+
log17("released lock", void 0, {
|
|
5874
|
+
F: __dxlog_file20,
|
|
5704
5875
|
L: 74,
|
|
5705
5876
|
S: this,
|
|
5706
5877
|
C: (f, a) => f(...a)
|
|
@@ -5709,10 +5880,10 @@ var Lock = class {
|
|
|
5709
5880
|
await this._onRelease?.();
|
|
5710
5881
|
});
|
|
5711
5882
|
await acquired.wait();
|
|
5712
|
-
|
|
5883
|
+
log17("recieved lock", {
|
|
5713
5884
|
steal
|
|
5714
5885
|
}, {
|
|
5715
|
-
F:
|
|
5886
|
+
F: __dxlog_file20,
|
|
5716
5887
|
L: 81,
|
|
5717
5888
|
S: this,
|
|
5718
5889
|
C: (f, a) => f(...a)
|
|
@@ -5802,19 +5973,16 @@ var createLevel = async (config) => {
|
|
|
5802
5973
|
|
|
5803
5974
|
// packages/sdk/client-services/src/packlets/services/service-host.ts
|
|
5804
5975
|
import { Event as Event9, synchronized as synchronized3 } from "@dxos/async";
|
|
5805
|
-
import { clientServiceBundle
|
|
5976
|
+
import { clientServiceBundle } from "@dxos/client-protocol";
|
|
5806
5977
|
import { Context as Context11 } from "@dxos/context";
|
|
5807
|
-
import { encodeReference } from "@dxos/echo-protocol";
|
|
5808
|
-
import { getTypeReference } from "@dxos/echo-schema";
|
|
5809
5978
|
import { invariant as invariant18 } from "@dxos/invariant";
|
|
5810
5979
|
import { PublicKey as PublicKey16 } from "@dxos/keys";
|
|
5811
|
-
import { log as
|
|
5980
|
+
import { log as log19 } from "@dxos/log";
|
|
5812
5981
|
import { WebsocketSignalManager } from "@dxos/messaging";
|
|
5813
5982
|
import { SwarmNetworkManager, createSimplePeerTransportFactory } from "@dxos/network-manager";
|
|
5814
5983
|
import { trace as trace10 } from "@dxos/protocols";
|
|
5815
5984
|
import { SystemStatus } from "@dxos/protocols/proto/dxos/client/services";
|
|
5816
5985
|
import { TRACE_PROCESSOR as TRACE_PROCESSOR3, trace as Trace4 } from "@dxos/tracing";
|
|
5817
|
-
import { assignDeep as assignDeep2 } from "@dxos/util";
|
|
5818
5986
|
import { WebsocketRpcClient } from "@dxos/websocket-rpc";
|
|
5819
5987
|
|
|
5820
5988
|
// packages/sdk/client-services/src/packlets/devices/devices-service.ts
|
|
@@ -5822,7 +5990,7 @@ import { EventSubscriptions as EventSubscriptions3 } from "@dxos/async";
|
|
|
5822
5990
|
import { Stream as Stream11 } from "@dxos/codec-protobuf";
|
|
5823
5991
|
import { invariant as invariant17 } from "@dxos/invariant";
|
|
5824
5992
|
import { Device as Device2, DeviceKind as DeviceKind2 } from "@dxos/protocols/proto/dxos/client/services";
|
|
5825
|
-
var
|
|
5993
|
+
var __dxlog_file21 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/devices/devices-service.ts";
|
|
5826
5994
|
var DevicesServiceImpl = class {
|
|
5827
5995
|
constructor(_identityManager) {
|
|
5828
5996
|
this._identityManager = _identityManager;
|
|
@@ -5840,7 +6008,7 @@ var DevicesServiceImpl = class {
|
|
|
5840
6008
|
});
|
|
5841
6009
|
} else {
|
|
5842
6010
|
invariant17(this._identityManager.identity?.presence, "presence not present", {
|
|
5843
|
-
F:
|
|
6011
|
+
F: __dxlog_file21,
|
|
5844
6012
|
L: 32,
|
|
5845
6013
|
S: this,
|
|
5846
6014
|
A: [
|
|
@@ -5950,7 +6118,7 @@ var findConfigs = () => {
|
|
|
5950
6118
|
import { Event as Event8 } from "@dxos/async";
|
|
5951
6119
|
import { Stream as Stream12 } from "@dxos/codec-protobuf";
|
|
5952
6120
|
import { PublicKey as PublicKey15 } from "@dxos/keys";
|
|
5953
|
-
import { getContextFromEntry, log as
|
|
6121
|
+
import { getContextFromEntry, log as log18 } from "@dxos/log";
|
|
5954
6122
|
import { QueryLogsRequest } from "@dxos/protocols/proto/dxos/client/services";
|
|
5955
6123
|
import { getDebugName, jsonify, numericalValues, tracer } from "@dxos/util";
|
|
5956
6124
|
var LoggingServiceImpl = class {
|
|
@@ -5963,11 +6131,11 @@ var LoggingServiceImpl = class {
|
|
|
5963
6131
|
};
|
|
5964
6132
|
}
|
|
5965
6133
|
async open() {
|
|
5966
|
-
|
|
6134
|
+
log18.runtimeConfig.processors.push(this._logProcessor);
|
|
5967
6135
|
}
|
|
5968
6136
|
async close() {
|
|
5969
|
-
const index =
|
|
5970
|
-
|
|
6137
|
+
const index = log18.runtimeConfig.processors.findIndex((processor) => processor === this._logProcessor);
|
|
6138
|
+
log18.runtimeConfig.processors.splice(index, 1);
|
|
5971
6139
|
}
|
|
5972
6140
|
async controlMetrics({ reset, record }) {
|
|
5973
6141
|
if (reset) {
|
|
@@ -6171,7 +6339,7 @@ function _ts_decorate8(decorators, target, key, desc) {
|
|
|
6171
6339
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6172
6340
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6173
6341
|
}
|
|
6174
|
-
var
|
|
6342
|
+
var __dxlog_file22 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-host.ts";
|
|
6175
6343
|
var ClientServicesHost = class {
|
|
6176
6344
|
constructor({
|
|
6177
6345
|
config,
|
|
@@ -6191,7 +6359,7 @@ var ClientServicesHost = class {
|
|
|
6191
6359
|
this._storage = storage;
|
|
6192
6360
|
this._level = level;
|
|
6193
6361
|
this._callbacks = callbacks;
|
|
6194
|
-
this._runtimeParams = runtimeParams;
|
|
6362
|
+
this._runtimeParams = runtimeParams ?? {};
|
|
6195
6363
|
if (config) {
|
|
6196
6364
|
this.initialize({
|
|
6197
6365
|
config,
|
|
@@ -6260,24 +6428,24 @@ var ClientServicesHost = class {
|
|
|
6260
6428
|
*/
|
|
6261
6429
|
initialize({ config, ...options }) {
|
|
6262
6430
|
invariant18(!this._open, "service host is open", {
|
|
6263
|
-
F:
|
|
6264
|
-
L:
|
|
6431
|
+
F: __dxlog_file22,
|
|
6432
|
+
L: 186,
|
|
6265
6433
|
S: this,
|
|
6266
6434
|
A: [
|
|
6267
6435
|
"!this._open",
|
|
6268
6436
|
"'service host is open'"
|
|
6269
6437
|
]
|
|
6270
6438
|
});
|
|
6271
|
-
|
|
6272
|
-
F:
|
|
6273
|
-
L:
|
|
6439
|
+
log19("initializing...", void 0, {
|
|
6440
|
+
F: __dxlog_file22,
|
|
6441
|
+
L: 187,
|
|
6274
6442
|
S: this,
|
|
6275
6443
|
C: (f, a) => f(...a)
|
|
6276
6444
|
});
|
|
6277
6445
|
if (config) {
|
|
6278
6446
|
invariant18(!this._config, "config already set", {
|
|
6279
|
-
F:
|
|
6280
|
-
L:
|
|
6447
|
+
F: __dxlog_file22,
|
|
6448
|
+
L: 190,
|
|
6281
6449
|
S: this,
|
|
6282
6450
|
A: [
|
|
6283
6451
|
"!this._config",
|
|
@@ -6290,9 +6458,9 @@ var ClientServicesHost = class {
|
|
|
6290
6458
|
}
|
|
6291
6459
|
}
|
|
6292
6460
|
if (!options.signalManager) {
|
|
6293
|
-
|
|
6294
|
-
F:
|
|
6295
|
-
L:
|
|
6461
|
+
log19.warn("running signaling without telemetry metadata.", void 0, {
|
|
6462
|
+
F: __dxlog_file22,
|
|
6463
|
+
L: 198,
|
|
6296
6464
|
S: this,
|
|
6297
6465
|
C: (f, a) => f(...a)
|
|
6298
6466
|
});
|
|
@@ -6302,8 +6470,8 @@ var ClientServicesHost = class {
|
|
|
6302
6470
|
}), signalManager = new WebsocketSignalManager(this._config?.get("runtime.services.signaling") ?? []) } = options;
|
|
6303
6471
|
this._signalManager = signalManager;
|
|
6304
6472
|
invariant18(!this._networkManager, "network manager already set", {
|
|
6305
|
-
F:
|
|
6306
|
-
L:
|
|
6473
|
+
F: __dxlog_file22,
|
|
6474
|
+
L: 209,
|
|
6307
6475
|
S: this,
|
|
6308
6476
|
A: [
|
|
6309
6477
|
"!this._networkManager",
|
|
@@ -6315,9 +6483,9 @@ var ClientServicesHost = class {
|
|
|
6315
6483
|
transportFactory,
|
|
6316
6484
|
signalManager
|
|
6317
6485
|
});
|
|
6318
|
-
|
|
6319
|
-
F:
|
|
6320
|
-
L:
|
|
6486
|
+
log19("initialized", void 0, {
|
|
6487
|
+
F: __dxlog_file22,
|
|
6488
|
+
L: 216,
|
|
6321
6489
|
S: this,
|
|
6322
6490
|
C: (f, a) => f(...a)
|
|
6323
6491
|
});
|
|
@@ -6327,17 +6495,17 @@ var ClientServicesHost = class {
|
|
|
6327
6495
|
return;
|
|
6328
6496
|
}
|
|
6329
6497
|
const traceId = PublicKey16.random().toHex();
|
|
6330
|
-
|
|
6498
|
+
log19.trace("dxos.client-services.host.open", trace10.begin({
|
|
6331
6499
|
id: traceId
|
|
6332
6500
|
}), {
|
|
6333
|
-
F:
|
|
6334
|
-
L:
|
|
6501
|
+
F: __dxlog_file22,
|
|
6502
|
+
L: 227,
|
|
6335
6503
|
S: this,
|
|
6336
6504
|
C: (f, a) => f(...a)
|
|
6337
6505
|
});
|
|
6338
6506
|
invariant18(this._config, "config not set", {
|
|
6339
|
-
F:
|
|
6340
|
-
L:
|
|
6507
|
+
F: __dxlog_file22,
|
|
6508
|
+
L: 229,
|
|
6341
6509
|
S: this,
|
|
6342
6510
|
A: [
|
|
6343
6511
|
"this._config",
|
|
@@ -6345,8 +6513,8 @@ var ClientServicesHost = class {
|
|
|
6345
6513
|
]
|
|
6346
6514
|
});
|
|
6347
6515
|
invariant18(this._storage, "storage not set", {
|
|
6348
|
-
F:
|
|
6349
|
-
L:
|
|
6516
|
+
F: __dxlog_file22,
|
|
6517
|
+
L: 230,
|
|
6350
6518
|
S: this,
|
|
6351
6519
|
A: [
|
|
6352
6520
|
"this._storage",
|
|
@@ -6354,8 +6522,8 @@ var ClientServicesHost = class {
|
|
|
6354
6522
|
]
|
|
6355
6523
|
});
|
|
6356
6524
|
invariant18(this._signalManager, "signal manager not set", {
|
|
6357
|
-
F:
|
|
6358
|
-
L:
|
|
6525
|
+
F: __dxlog_file22,
|
|
6526
|
+
L: 231,
|
|
6359
6527
|
S: this,
|
|
6360
6528
|
A: [
|
|
6361
6529
|
"this._signalManager",
|
|
@@ -6363,8 +6531,8 @@ var ClientServicesHost = class {
|
|
|
6363
6531
|
]
|
|
6364
6532
|
});
|
|
6365
6533
|
invariant18(this._networkManager, "network manager not set", {
|
|
6366
|
-
F:
|
|
6367
|
-
L:
|
|
6534
|
+
F: __dxlog_file22,
|
|
6535
|
+
L: 232,
|
|
6368
6536
|
S: this,
|
|
6369
6537
|
A: [
|
|
6370
6538
|
"this._networkManager",
|
|
@@ -6372,11 +6540,11 @@ var ClientServicesHost = class {
|
|
|
6372
6540
|
]
|
|
6373
6541
|
});
|
|
6374
6542
|
this._opening = true;
|
|
6375
|
-
|
|
6543
|
+
log19("opening...", {
|
|
6376
6544
|
lockKey: this._resourceLock?.lockKey
|
|
6377
6545
|
}, {
|
|
6378
|
-
F:
|
|
6379
|
-
L:
|
|
6546
|
+
F: __dxlog_file22,
|
|
6547
|
+
L: 235,
|
|
6380
6548
|
S: this,
|
|
6381
6549
|
C: (f, a) => f(...a)
|
|
6382
6550
|
});
|
|
@@ -6387,9 +6555,10 @@ var ClientServicesHost = class {
|
|
|
6387
6555
|
await this._level.open();
|
|
6388
6556
|
await this._loggingService.open();
|
|
6389
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));
|
|
6390
6559
|
this._serviceRegistry.setServices({
|
|
6391
6560
|
SystemService: this._systemService,
|
|
6392
|
-
IdentityService:
|
|
6561
|
+
IdentityService: identityService,
|
|
6393
6562
|
InvitationsService: new InvitationsServiceImpl(this._serviceContext.invitationsManager),
|
|
6394
6563
|
DevicesService: new DevicesServiceImpl(this._serviceContext.identityManager),
|
|
6395
6564
|
SpacesService: new SpacesServiceImpl(this._serviceContext.identityManager, this._serviceContext.spaceManager, async () => {
|
|
@@ -6409,6 +6578,7 @@ var ClientServicesHost = class {
|
|
|
6409
6578
|
})
|
|
6410
6579
|
});
|
|
6411
6580
|
await this._serviceContext.open(ctx);
|
|
6581
|
+
await identityService.open();
|
|
6412
6582
|
const devtoolsProxy = this._config?.get("runtime.client.devtoolsProxy");
|
|
6413
6583
|
if (devtoolsProxy) {
|
|
6414
6584
|
this._devtoolsProxy = new WebsocketRpcClient({
|
|
@@ -6424,18 +6594,18 @@ var ClientServicesHost = class {
|
|
|
6424
6594
|
this._open = true;
|
|
6425
6595
|
this._statusUpdate.emit();
|
|
6426
6596
|
const deviceKey = this._serviceContext.identityManager.identity?.deviceKey;
|
|
6427
|
-
|
|
6597
|
+
log19("opened", {
|
|
6428
6598
|
deviceKey
|
|
6429
6599
|
}, {
|
|
6430
|
-
F:
|
|
6600
|
+
F: __dxlog_file22,
|
|
6431
6601
|
L: 314,
|
|
6432
6602
|
S: this,
|
|
6433
6603
|
C: (f, a) => f(...a)
|
|
6434
6604
|
});
|
|
6435
|
-
|
|
6605
|
+
log19.trace("dxos.client-services.host.open", trace10.end({
|
|
6436
6606
|
id: traceId
|
|
6437
6607
|
}), {
|
|
6438
|
-
F:
|
|
6608
|
+
F: __dxlog_file22,
|
|
6439
6609
|
L: 315,
|
|
6440
6610
|
S: this,
|
|
6441
6611
|
C: (f, a) => f(...a)
|
|
@@ -6446,10 +6616,10 @@ var ClientServicesHost = class {
|
|
|
6446
6616
|
return;
|
|
6447
6617
|
}
|
|
6448
6618
|
const deviceKey = this._serviceContext.identityManager.identity?.deviceKey;
|
|
6449
|
-
|
|
6619
|
+
log19("closing...", {
|
|
6450
6620
|
deviceKey
|
|
6451
6621
|
}, {
|
|
6452
|
-
F:
|
|
6622
|
+
F: __dxlog_file22,
|
|
6453
6623
|
L: 326,
|
|
6454
6624
|
S: this,
|
|
6455
6625
|
C: (f, a) => f(...a)
|
|
@@ -6464,10 +6634,10 @@ var ClientServicesHost = class {
|
|
|
6464
6634
|
await this._level?.close();
|
|
6465
6635
|
this._open = false;
|
|
6466
6636
|
this._statusUpdate.emit();
|
|
6467
|
-
|
|
6637
|
+
log19("closed", {
|
|
6468
6638
|
deviceKey
|
|
6469
6639
|
}, {
|
|
6470
|
-
F:
|
|
6640
|
+
F: __dxlog_file22,
|
|
6471
6641
|
L: 335,
|
|
6472
6642
|
S: this,
|
|
6473
6643
|
C: (f, a) => f(...a)
|
|
@@ -6475,32 +6645,32 @@ var ClientServicesHost = class {
|
|
|
6475
6645
|
}
|
|
6476
6646
|
async reset() {
|
|
6477
6647
|
const traceId = PublicKey16.random().toHex();
|
|
6478
|
-
|
|
6648
|
+
log19.trace("dxos.sdk.client-services-host.reset", trace10.begin({
|
|
6479
6649
|
id: traceId
|
|
6480
6650
|
}), {
|
|
6481
|
-
F:
|
|
6651
|
+
F: __dxlog_file22,
|
|
6482
6652
|
L: 340,
|
|
6483
6653
|
S: this,
|
|
6484
6654
|
C: (f, a) => f(...a)
|
|
6485
6655
|
});
|
|
6486
|
-
|
|
6487
|
-
F:
|
|
6656
|
+
log19.info("resetting...", void 0, {
|
|
6657
|
+
F: __dxlog_file22,
|
|
6488
6658
|
L: 342,
|
|
6489
6659
|
S: this,
|
|
6490
6660
|
C: (f, a) => f(...a)
|
|
6491
6661
|
});
|
|
6492
6662
|
await this._serviceContext?.close();
|
|
6493
6663
|
await this._storage.reset();
|
|
6494
|
-
|
|
6495
|
-
F:
|
|
6664
|
+
log19.info("reset", void 0, {
|
|
6665
|
+
F: __dxlog_file22,
|
|
6496
6666
|
L: 345,
|
|
6497
6667
|
S: this,
|
|
6498
6668
|
C: (f, a) => f(...a)
|
|
6499
6669
|
});
|
|
6500
|
-
|
|
6670
|
+
log19.trace("dxos.sdk.client-services-host.reset", trace10.end({
|
|
6501
6671
|
id: traceId
|
|
6502
6672
|
}), {
|
|
6503
|
-
F:
|
|
6673
|
+
F: __dxlog_file22,
|
|
6504
6674
|
L: 346,
|
|
6505
6675
|
S: this,
|
|
6506
6676
|
C: (f, a) => f(...a)
|
|
@@ -6510,38 +6680,6 @@ var ClientServicesHost = class {
|
|
|
6510
6680
|
async _createIdentity(params) {
|
|
6511
6681
|
const identity = await this._serviceContext.createIdentity(params);
|
|
6512
6682
|
await this._serviceContext.initialized.wait();
|
|
6513
|
-
const space = await this._serviceContext.dataSpaceManager.createSpace();
|
|
6514
|
-
const automergeIndex = space.automergeSpaceState.rootUrl;
|
|
6515
|
-
invariant18(automergeIndex, void 0, {
|
|
6516
|
-
F: __dxlog_file21,
|
|
6517
|
-
L: 358,
|
|
6518
|
-
S: this,
|
|
6519
|
-
A: [
|
|
6520
|
-
"automergeIndex",
|
|
6521
|
-
""
|
|
6522
|
-
]
|
|
6523
|
-
});
|
|
6524
|
-
const document = this._serviceContext.echoHost.automergeRepo.find(automergeIndex);
|
|
6525
|
-
await document.whenReady();
|
|
6526
|
-
const properties = {
|
|
6527
|
-
system: {
|
|
6528
|
-
type: encodeReference(getTypeReference(PropertiesType))
|
|
6529
|
-
},
|
|
6530
|
-
data: {
|
|
6531
|
-
[defaultKey]: identity.identityKey.toHex()
|
|
6532
|
-
},
|
|
6533
|
-
meta: {
|
|
6534
|
-
keys: []
|
|
6535
|
-
}
|
|
6536
|
-
};
|
|
6537
|
-
const propertiesId = PublicKey16.random().toHex();
|
|
6538
|
-
document.change((doc) => {
|
|
6539
|
-
assignDeep2(doc, [
|
|
6540
|
-
"objects",
|
|
6541
|
-
propertiesId
|
|
6542
|
-
], properties);
|
|
6543
|
-
});
|
|
6544
|
-
await this._serviceContext.echoHost.flush();
|
|
6545
6683
|
return identity;
|
|
6546
6684
|
}
|
|
6547
6685
|
};
|
|
@@ -6604,4 +6742,4 @@ export {
|
|
|
6604
6742
|
ClientServicesProviderResource,
|
|
6605
6743
|
DiagnosticsCollector
|
|
6606
6744
|
};
|
|
6607
|
-
//# sourceMappingURL=chunk-
|
|
6745
|
+
//# sourceMappingURL=chunk-NBUF5LMA.mjs.map
|