@dxos/client-services 0.1.46 → 0.1.47

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.
@@ -892,6 +892,14 @@ var IdentityManager = class {
892
892
  swarmIdentity,
893
893
  onNetworkConnection: () => {
894
894
  },
895
+ onAuthFailure: () => {
896
+ import_log3.log.warn("auth failure", {}, {
897
+ file: "identity-manager.ts",
898
+ line: 242,
899
+ scope: this,
900
+ callSite: (f, a) => f(...a)
901
+ });
902
+ },
895
903
  memberKey: identityKey
896
904
  });
897
905
  }
@@ -1021,7 +1029,7 @@ var import_keys6 = require("@dxos/keys");
1021
1029
  var import_log5 = require("@dxos/log");
1022
1030
  var import_network_manager = require("@dxos/network-manager");
1023
1031
  var import_protocols4 = require("@dxos/protocols");
1024
- var import_services2 = require("@dxos/protocols/proto/dxos/client/services");
1032
+ var import_services3 = require("@dxos/protocols/proto/dxos/client/services");
1025
1033
  var import_invitations2 = require("@dxos/protocols/proto/dxos/halo/invitations");
1026
1034
 
1027
1035
  // packages/sdk/client-services/src/packlets/invitations/invitation-extension.ts
@@ -1032,9 +1040,11 @@ var import_errors = require("@dxos/errors");
1032
1040
  var import_keys5 = require("@dxos/keys");
1033
1041
  var import_log4 = require("@dxos/log");
1034
1042
  var import_protocols3 = require("@dxos/protocols");
1043
+ var import_services2 = require("@dxos/protocols/proto/dxos/client/services");
1035
1044
  var import_invitations = require("@dxos/protocols/proto/dxos/halo/invitations");
1036
1045
  var import_teleport = require("@dxos/teleport");
1037
1046
  var OPTIONS_TIMEOUT = 1e4;
1047
+ var MAX_OTP_ATTEMPTS = 3;
1038
1048
  var InvitationHostExtension = class extends import_teleport.RpcExtension {
1039
1049
  constructor(_callbacks) {
1040
1050
  super({
@@ -1048,6 +1058,11 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
1048
1058
  this._callbacks = _callbacks;
1049
1059
  this._ctx = new import_context3.Context();
1050
1060
  this._remoteOptionsTrigger = new import_async7.Trigger();
1061
+ this.invitation = void 0;
1062
+ this.guestProfile = void 0;
1063
+ this.authenticationPassed = false;
1064
+ this.authenticationRetry = 0;
1065
+ this.completedTrigger = new import_async7.Trigger();
1051
1066
  }
1052
1067
  async getHandlers() {
1053
1068
  return {
@@ -1060,49 +1075,129 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
1060
1075
  this._remoteOptionsTrigger.wake();
1061
1076
  },
1062
1077
  introduce: async (request) => {
1078
+ const { profile, invitationId } = request;
1063
1079
  const traceId = import_keys5.PublicKey.random().toHex();
1064
1080
  import_log4.log.trace("dxos.sdk.invitation-handler.host.introduce", import_protocols3.trace.begin({
1065
1081
  id: traceId
1066
1082
  }), {
1067
1083
  file: "invitation-extension.ts",
1068
- line: 76,
1084
+ line: 98,
1069
1085
  scope: this,
1070
1086
  callSite: (f, a) => f(...a)
1071
1087
  });
1072
- const response = await this._callbacks.introduce(request);
1088
+ const invitation = await this._callbacks.resolveInvitation(request);
1089
+ if (!invitation) {
1090
+ import_log4.log.warn("invitation not found", {
1091
+ invitationId
1092
+ }, {
1093
+ file: "invitation-extension.ts",
1094
+ line: 102,
1095
+ scope: this,
1096
+ callSite: (f, a) => f(...a)
1097
+ });
1098
+ this._callbacks.onError(new Error("Invitation not found."));
1099
+ return {
1100
+ authMethod: import_services2.Invitation.AuthMethod.NONE
1101
+ };
1102
+ }
1103
+ this.invitation = invitation;
1104
+ (0, import_log4.log)("guest introduced itself", {
1105
+ guestProfile: profile
1106
+ }, {
1107
+ file: "invitation-extension.ts",
1108
+ line: 111,
1109
+ scope: this,
1110
+ callSite: (f, a) => f(...a)
1111
+ });
1112
+ this.guestProfile = profile;
1113
+ this._callbacks.onStateUpdate({
1114
+ ...this.invitation,
1115
+ state: import_services2.Invitation.State.READY_FOR_AUTHENTICATION
1116
+ });
1073
1117
  import_log4.log.trace("dxos.sdk.invitation-handler.host.introduce", import_protocols3.trace.end({
1074
1118
  id: traceId
1075
1119
  }), {
1076
1120
  file: "invitation-extension.ts",
1077
- line: 78,
1121
+ line: 118,
1078
1122
  scope: this,
1079
1123
  callSite: (f, a) => f(...a)
1080
1124
  });
1081
- return response;
1125
+ return {
1126
+ spaceKey: this.invitation.authMethod === import_services2.Invitation.AuthMethod.NONE ? this.invitation.spaceKey : void 0,
1127
+ authMethod: this.invitation.authMethod
1128
+ };
1082
1129
  },
1083
- authenticate: async (request) => {
1130
+ authenticate: async ({ authCode: code }) => {
1084
1131
  const traceId = import_keys5.PublicKey.random().toHex();
1085
1132
  import_log4.log.trace("dxos.sdk.invitation-handler.host.authenticate", import_protocols3.trace.begin({
1086
1133
  id: traceId
1087
1134
  }), {
1088
1135
  file: "invitation-extension.ts",
1089
- line: 84,
1136
+ line: 127,
1090
1137
  scope: this,
1091
1138
  callSite: (f, a) => f(...a)
1092
1139
  });
1093
- const response = await this._callbacks.authenticate(request);
1140
+ (0, import_log4.log)("received authentication request", {
1141
+ authCode: code
1142
+ }, {
1143
+ file: "invitation-extension.ts",
1144
+ line: 128,
1145
+ scope: this,
1146
+ callSite: (f, a) => f(...a)
1147
+ });
1148
+ let status = import_invitations.AuthenticationResponse.Status.OK;
1149
+ (0, import_node_assert5.default)(this.invitation, "Invitation is not set.");
1150
+ switch (this.invitation.authMethod) {
1151
+ case import_services2.Invitation.AuthMethod.NONE: {
1152
+ (0, import_log4.log)("authentication not required", {}, {
1153
+ file: "invitation-extension.ts",
1154
+ line: 134,
1155
+ scope: this,
1156
+ callSite: (f, a) => f(...a)
1157
+ });
1158
+ return {
1159
+ status: import_invitations.AuthenticationResponse.Status.OK
1160
+ };
1161
+ }
1162
+ case import_services2.Invitation.AuthMethod.SHARED_SECRET: {
1163
+ if (this.invitation.authCode) {
1164
+ if (this.authenticationRetry++ > MAX_OTP_ATTEMPTS) {
1165
+ status = import_invitations.AuthenticationResponse.Status.INVALID_OPT_ATTEMPTS;
1166
+ } else if (code !== this.invitation.authCode) {
1167
+ status = import_invitations.AuthenticationResponse.Status.INVALID_OTP;
1168
+ } else {
1169
+ this.authenticationPassed = true;
1170
+ }
1171
+ }
1172
+ break;
1173
+ }
1174
+ default: {
1175
+ import_log4.log.error("invalid authentication method", {
1176
+ authMethod: this.invitation.authMethod
1177
+ }, {
1178
+ file: "invitation-extension.ts",
1179
+ line: 152,
1180
+ scope: this,
1181
+ callSite: (f, a) => f(...a)
1182
+ });
1183
+ status = import_invitations.AuthenticationResponse.Status.INTERNAL_ERROR;
1184
+ break;
1185
+ }
1186
+ }
1094
1187
  import_log4.log.trace("dxos.sdk.invitation-handler.host.authenticate", import_protocols3.trace.end({
1095
1188
  id: traceId,
1096
1189
  data: {
1097
- ...response
1190
+ status
1098
1191
  }
1099
1192
  }), {
1100
1193
  file: "invitation-extension.ts",
1101
- line: 86,
1194
+ line: 158,
1102
1195
  scope: this,
1103
1196
  callSite: (f, a) => f(...a)
1104
1197
  });
1105
- return response;
1198
+ return {
1199
+ status
1200
+ };
1106
1201
  },
1107
1202
  admit: async (request) => {
1108
1203
  const traceId = import_keys5.PublicKey.random().toHex();
@@ -1110,20 +1205,29 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
1110
1205
  id: traceId
1111
1206
  }), {
1112
1207
  file: "invitation-extension.ts",
1113
- line: 92,
1208
+ line: 164,
1114
1209
  scope: this,
1115
1210
  callSite: (f, a) => f(...a)
1116
1211
  });
1117
- const response = await this._callbacks.admit(request);
1118
- import_log4.log.trace("dxos.sdk.invitation-handler.host.admit", import_protocols3.trace.end({
1119
- id: traceId
1120
- }), {
1121
- file: "invitation-extension.ts",
1122
- line: 94,
1123
- scope: this,
1124
- callSite: (f, a) => f(...a)
1125
- });
1126
- return response;
1212
+ try {
1213
+ (0, import_node_assert5.default)(this.invitation, "Invitation is not set.");
1214
+ if (isAuthenticationRequired(this.invitation) && !this.authenticationPassed) {
1215
+ throw new Error("Not authenticated");
1216
+ }
1217
+ const response = await this._callbacks.admit(request);
1218
+ import_log4.log.trace("dxos.sdk.invitation-handler.host.admit", import_protocols3.trace.end({
1219
+ id: traceId
1220
+ }), {
1221
+ file: "invitation-extension.ts",
1222
+ line: 175,
1223
+ scope: this,
1224
+ callSite: (f, a) => f(...a)
1225
+ });
1226
+ return response;
1227
+ } catch (err) {
1228
+ this._callbacks.onError(err);
1229
+ throw err;
1230
+ }
1127
1231
  }
1128
1232
  }
1129
1233
  };
@@ -1193,7 +1297,7 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
1193
1297
  try {
1194
1298
  (0, import_log4.log)("begin options", {}, {
1195
1299
  file: "invitation-extension.ts",
1196
- line: 178,
1300
+ line: 263,
1197
1301
  scope: this,
1198
1302
  callSite: (f, a) => f(...a)
1199
1303
  });
@@ -1205,7 +1309,7 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
1205
1309
  }));
1206
1310
  (0, import_log4.log)("end options", {}, {
1207
1311
  file: "invitation-extension.ts",
1208
- line: 181,
1312
+ line: 266,
1209
1313
  scope: this,
1210
1314
  callSite: (f, a) => f(...a)
1211
1315
  });
@@ -1219,7 +1323,7 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
1219
1323
  } catch (err) {
1220
1324
  (0, import_log4.log)("openError", err, {
1221
1325
  file: "invitation-extension.ts",
1222
- line: 191,
1326
+ line: 276,
1223
1327
  scope: this,
1224
1328
  callSite: (f, a) => f(...a)
1225
1329
  });
@@ -1229,16 +1333,16 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
1229
1333
  async onClose() {
1230
1334
  (0, import_log4.log)("onClose", {}, {
1231
1335
  file: "invitation-extension.ts",
1232
- line: 197,
1336
+ line: 282,
1233
1337
  scope: this,
1234
1338
  callSite: (f, a) => f(...a)
1235
1339
  });
1236
1340
  await this._ctx.dispose();
1237
1341
  }
1238
1342
  };
1343
+ var isAuthenticationRequired = (invitation) => invitation.authMethod !== import_services2.Invitation.AuthMethod.NONE;
1239
1344
 
1240
1345
  // packages/sdk/client-services/src/packlets/invitations/invitations-handler.ts
1241
- var MAX_OTP_ATTEMPTS = 3;
1242
1346
  var InvitationsHandler = class {
1243
1347
  /**
1244
1348
  * @internal
@@ -1248,8 +1352,8 @@ var InvitationsHandler = class {
1248
1352
  }
1249
1353
  createInvitation(protocol, options) {
1250
1354
  var _a;
1251
- const { invitationId = import_keys6.PublicKey.random().toHex(), type = import_services2.Invitation.Type.INTERACTIVE, authMethod = import_services2.Invitation.AuthMethod.SHARED_SECRET, state = import_services2.Invitation.State.INIT, timeout = import_client_protocol2.INVITATION_TIMEOUT, swarmKey = import_keys6.PublicKey.random() } = options != null ? options : {};
1252
- const authCode = (_a = options == null ? void 0 : options.authCode) != null ? _a : authMethod === import_services2.Invitation.AuthMethod.SHARED_SECRET ? (0, import_credentials7.generatePasscode)(import_client_protocol2.AUTHENTICATION_CODE_LENGTH) : void 0;
1355
+ const { invitationId = import_keys6.PublicKey.random().toHex(), type = import_services3.Invitation.Type.INTERACTIVE, authMethod = import_services3.Invitation.AuthMethod.SHARED_SECRET, state = import_services3.Invitation.State.INIT, timeout = import_client_protocol2.INVITATION_TIMEOUT, swarmKey = import_keys6.PublicKey.random() } = options != null ? options : {};
1356
+ const authCode = (_a = options == null ? void 0 : options.authCode) != null ? _a : authMethod === import_services3.Invitation.AuthMethod.SHARED_SECRET ? (0, import_credentials7.generatePasscode)(import_client_protocol2.AUTHENTICATION_CODE_LENGTH) : void 0;
1253
1357
  (0, import_node_assert6.default)(protocol);
1254
1358
  const invitation = {
1255
1359
  invitationId,
@@ -1273,99 +1377,33 @@ var InvitationsHandler = class {
1273
1377
  ...protocol.toJSON()
1274
1378
  }, {
1275
1379
  file: "invitations-handler.ts",
1276
- line: 98,
1380
+ line: 100,
1277
1381
  scope: this,
1278
1382
  callSite: (f, a) => f(...a)
1279
1383
  });
1280
1384
  stream.complete();
1281
1385
  });
1282
1386
  const createExtension = () => {
1283
- const success = new import_async8.Trigger();
1284
- let guestProfile;
1285
- let authenticationPassed = false;
1286
- let authenticationRetry = 0;
1287
1387
  const extension = new InvitationHostExtension({
1288
- introduce: async ({ profile }) => {
1289
- (0, import_log5.log)("guest introduced itself", {
1290
- guestProfile: profile,
1291
- ...protocol.toJSON()
1292
- }, {
1293
- file: "invitations-handler.ts",
1294
- line: 111,
1295
- scope: this,
1296
- callSite: (f, a) => f(...a)
1297
- });
1298
- guestProfile = profile;
1388
+ onStateUpdate: (invitation2) => {
1299
1389
  stream.next({
1300
- ...invitation,
1301
- state: import_services2.Invitation.State.READY_FOR_AUTHENTICATION
1390
+ ...invitation2,
1391
+ state: import_services3.Invitation.State.READY_FOR_AUTHENTICATION
1302
1392
  });
1303
- return {
1304
- spaceKey: authMethod === import_services2.Invitation.AuthMethod.NONE ? protocol.getInvitationContext().spaceKey : void 0,
1305
- authMethod
1306
- };
1307
1393
  },
1308
- authenticate: async ({ authCode: code }) => {
1309
- (0, import_log5.log)("received authentication request", {
1310
- authCode: code
1311
- }, {
1312
- file: "invitations-handler.ts",
1313
- line: 130,
1314
- scope: this,
1315
- callSite: (f, a) => f(...a)
1316
- });
1317
- let status = import_invitations2.AuthenticationResponse.Status.OK;
1318
- switch (invitation.authMethod) {
1319
- case import_services2.Invitation.AuthMethod.NONE: {
1320
- (0, import_log5.log)("authentication not required", {}, {
1321
- file: "invitations-handler.ts",
1322
- line: 135,
1323
- scope: this,
1324
- callSite: (f, a) => f(...a)
1325
- });
1326
- return {
1327
- status: import_invitations2.AuthenticationResponse.Status.OK
1328
- };
1329
- }
1330
- case import_services2.Invitation.AuthMethod.SHARED_SECRET: {
1331
- if (invitation.authCode) {
1332
- if (authenticationRetry++ > MAX_OTP_ATTEMPTS) {
1333
- status = import_invitations2.AuthenticationResponse.Status.INVALID_OPT_ATTEMPTS;
1334
- } else if (code !== invitation.authCode) {
1335
- status = import_invitations2.AuthenticationResponse.Status.INVALID_OTP;
1336
- } else {
1337
- authenticationPassed = true;
1338
- }
1339
- }
1340
- break;
1341
- }
1342
- default: {
1343
- import_log5.log.error("invalid authentication method", {
1344
- authMethod: invitation.authMethod
1345
- }, {
1346
- file: "invitations-handler.ts",
1347
- line: 153,
1348
- scope: this,
1349
- callSite: (f, a) => f(...a)
1350
- });
1351
- status = import_invitations2.AuthenticationResponse.Status.INTERNAL_ERROR;
1352
- break;
1353
- }
1394
+ resolveInvitation: async ({ invitationId: invitationId2 }) => {
1395
+ if (invitationId2 && invitationId2 !== invitation.invitationId) {
1396
+ return void 0;
1354
1397
  }
1355
- return {
1356
- status
1357
- };
1398
+ return invitation;
1358
1399
  },
1359
1400
  admit: async (admissionRequest) => {
1360
1401
  var _a2, _b, _c;
1361
1402
  try {
1362
- if (isAuthenticationRequired(invitation) && !authenticationPassed) {
1363
- throw new Error("Not authenticated");
1364
- }
1365
1403
  const deviceKey = (_c = (_a2 = admissionRequest.device) == null ? void 0 : _a2.deviceKey) != null ? _c : (_b = admissionRequest.space) == null ? void 0 : _b.deviceKey;
1366
1404
  (0, import_node_assert6.default)(deviceKey);
1367
- const admissionResponse = await protocol.admit(admissionRequest, guestProfile);
1368
- success.wake(deviceKey);
1405
+ const admissionResponse = await protocol.admit(admissionRequest, extension.guestProfile);
1406
+ extension.completedTrigger.wake(deviceKey);
1369
1407
  return admissionResponse;
1370
1408
  } catch (err) {
1371
1409
  stream.error(err);
@@ -1380,7 +1418,7 @@ var InvitationsHandler = class {
1380
1418
  id: traceId
1381
1419
  }), {
1382
1420
  file: "invitations-handler.ts",
1383
- line: 188,
1421
+ line: 139,
1384
1422
  scope: this,
1385
1423
  callSite: (f, a) => f(...a)
1386
1424
  });
@@ -1388,15 +1426,15 @@ var InvitationsHandler = class {
1388
1426
  ...protocol.toJSON()
1389
1427
  }, {
1390
1428
  file: "invitations-handler.ts",
1391
- line: 189,
1429
+ line: 140,
1392
1430
  scope: this,
1393
1431
  callSite: (f, a) => f(...a)
1394
1432
  });
1395
1433
  stream.next({
1396
1434
  ...invitation,
1397
- state: import_services2.Invitation.State.CONNECTED
1435
+ state: import_services3.Invitation.State.CONNECTED
1398
1436
  });
1399
- const deviceKey = await success.wait({
1437
+ const deviceKey = await extension.completedTrigger.wait({
1400
1438
  timeout
1401
1439
  });
1402
1440
  (0, import_log5.log)("admitted guest", {
@@ -1404,19 +1442,19 @@ var InvitationsHandler = class {
1404
1442
  ...protocol.toJSON()
1405
1443
  }, {
1406
1444
  file: "invitations-handler.ts",
1407
- line: 192,
1445
+ line: 143,
1408
1446
  scope: this,
1409
1447
  callSite: (f, a) => f(...a)
1410
1448
  });
1411
1449
  stream.next({
1412
1450
  ...invitation,
1413
- state: import_services2.Invitation.State.SUCCESS
1451
+ state: import_services3.Invitation.State.SUCCESS
1414
1452
  });
1415
1453
  import_log5.log.trace("dxos.sdk.invitations-handler.host.onOpen", import_protocols4.trace.end({
1416
1454
  id: traceId
1417
1455
  }), {
1418
1456
  file: "invitations-handler.ts",
1419
- line: 194,
1457
+ line: 145,
1420
1458
  scope: this,
1421
1459
  callSite: (f, a) => f(...a)
1422
1460
  });
@@ -1426,18 +1464,18 @@ var InvitationsHandler = class {
1426
1464
  ...protocol.toJSON()
1427
1465
  }, {
1428
1466
  file: "invitations-handler.ts",
1429
- line: 197,
1467
+ line: 148,
1430
1468
  scope: this,
1431
1469
  callSite: (f, a) => f(...a)
1432
1470
  });
1433
1471
  stream.next({
1434
1472
  ...invitation,
1435
- state: import_services2.Invitation.State.TIMEOUT
1473
+ state: import_services3.Invitation.State.TIMEOUT
1436
1474
  });
1437
1475
  } else {
1438
1476
  import_log5.log.error("failed", err, {
1439
1477
  file: "invitations-handler.ts",
1440
- line: 200,
1478
+ line: 151,
1441
1479
  scope: this,
1442
1480
  callSite: (f, a) => f(...a)
1443
1481
  });
@@ -1448,12 +1486,12 @@ var InvitationsHandler = class {
1448
1486
  error: err
1449
1487
  }), {
1450
1488
  file: "invitations-handler.ts",
1451
- line: 203,
1489
+ line: 154,
1452
1490
  scope: this,
1453
1491
  callSite: (f, a) => f(...a)
1454
1492
  });
1455
1493
  } finally {
1456
- if (type !== import_services2.Invitation.Type.MULTIUSE) {
1494
+ if (type !== import_services3.Invitation.Type.MULTIUSE) {
1457
1495
  await (0, import_async8.sleep)(import_client_protocol2.ON_CLOSE_DELAY);
1458
1496
  await ctx.dispose();
1459
1497
  }
@@ -1469,18 +1507,18 @@ var InvitationsHandler = class {
1469
1507
  ...protocol.toJSON()
1470
1508
  }, {
1471
1509
  file: "invitations-handler.ts",
1472
- line: 217,
1510
+ line: 168,
1473
1511
  scope: this,
1474
1512
  callSite: (f, a) => f(...a)
1475
1513
  });
1476
1514
  stream.next({
1477
1515
  ...invitation,
1478
- state: import_services2.Invitation.State.TIMEOUT
1516
+ state: import_services3.Invitation.State.TIMEOUT
1479
1517
  });
1480
1518
  } else {
1481
1519
  import_log5.log.error("failed", err, {
1482
1520
  file: "invitations-handler.ts",
1483
- line: 220,
1521
+ line: 171,
1484
1522
  scope: this,
1485
1523
  callSite: (f, a) => f(...a)
1486
1524
  });
@@ -1503,7 +1541,7 @@ var InvitationsHandler = class {
1503
1541
  ctx.onDispose(() => swarmConnection.close());
1504
1542
  stream.next({
1505
1543
  ...invitation,
1506
- state: import_services2.Invitation.State.CONNECTING
1544
+ state: import_services3.Invitation.State.CONNECTING
1507
1545
  });
1508
1546
  });
1509
1547
  const observable = new import_client_protocol2.CancellableInvitationObservable({
@@ -1512,7 +1550,7 @@ var InvitationsHandler = class {
1512
1550
  onCancel: async () => {
1513
1551
  stream.next({
1514
1552
  ...invitation,
1515
- state: import_services2.Invitation.State.CANCELLED
1553
+ state: import_services3.Invitation.State.CANCELLED
1516
1554
  });
1517
1555
  await ctx.dispose();
1518
1556
  }
@@ -1540,17 +1578,17 @@ var InvitationsHandler = class {
1540
1578
  ...protocol.toJSON()
1541
1579
  }, {
1542
1580
  file: "invitations-handler.ts",
1543
- line: 274,
1581
+ line: 225,
1544
1582
  scope: this,
1545
1583
  callSite: (f, a) => f(...a)
1546
1584
  });
1547
1585
  setState({
1548
- state: import_services2.Invitation.State.TIMEOUT
1586
+ state: import_services3.Invitation.State.TIMEOUT
1549
1587
  });
1550
1588
  } else {
1551
1589
  import_log5.log.warn("auth failed", err, {
1552
1590
  file: "invitations-handler.ts",
1553
- line: 277,
1591
+ line: 228,
1554
1592
  scope: this,
1555
1593
  callSite: (f, a) => f(...a)
1556
1594
  });
@@ -1564,7 +1602,7 @@ var InvitationsHandler = class {
1564
1602
  ...protocol.toJSON()
1565
1603
  }, {
1566
1604
  file: "invitations-handler.ts",
1567
- line: 285,
1605
+ line: 236,
1568
1606
  scope: this,
1569
1607
  callSite: (f, a) => f(...a)
1570
1608
  });
@@ -1579,11 +1617,11 @@ var InvitationsHandler = class {
1579
1617
  currentState
1580
1618
  }, {
1581
1619
  file: "invitations-handler.ts",
1582
- line: 295,
1620
+ line: 246,
1583
1621
  scope: this,
1584
1622
  callSite: (f, a) => f(...a)
1585
1623
  });
1586
- if (currentState !== import_services2.Invitation.State.SUCCESS) {
1624
+ if (currentState !== import_services3.Invitation.State.SUCCESS) {
1587
1625
  stream.error(new Error("Remote peer disconnected."));
1588
1626
  }
1589
1627
  });
@@ -1594,7 +1632,7 @@ var InvitationsHandler = class {
1594
1632
  id: traceId
1595
1633
  }), {
1596
1634
  file: "invitations-handler.ts",
1597
- line: 304,
1635
+ line: 255,
1598
1636
  scope: this,
1599
1637
  callSite: (f, a) => f(...a)
1600
1638
  });
@@ -1606,18 +1644,18 @@ var InvitationsHandler = class {
1606
1644
  ...protocol.toJSON()
1607
1645
  }, {
1608
1646
  file: "invitations-handler.ts",
1609
- line: 312,
1647
+ line: 263,
1610
1648
  scope: this,
1611
1649
  callSite: (f, a) => f(...a)
1612
1650
  });
1613
1651
  setState({
1614
- state: import_services2.Invitation.State.CONNECTED
1652
+ state: import_services3.Invitation.State.CONNECTED
1615
1653
  });
1616
1654
  (0, import_log5.log)("introduce", {
1617
1655
  ...protocol.toJSON()
1618
1656
  }, {
1619
1657
  file: "invitations-handler.ts",
1620
- line: 316,
1658
+ line: 267,
1621
1659
  scope: this,
1622
1660
  callSite: (f, a) => f(...a)
1623
1661
  });
@@ -1627,7 +1665,7 @@ var InvitationsHandler = class {
1627
1665
  response: introductionResponse
1628
1666
  }, {
1629
1667
  file: "invitations-handler.ts",
1630
- line: 320,
1668
+ line: 271,
1631
1669
  scope: this,
1632
1670
  callSite: (f, a) => f(...a)
1633
1671
  });
@@ -1639,24 +1677,24 @@ var InvitationsHandler = class {
1639
1677
  for (let attempt = 1; attempt <= MAX_OTP_ATTEMPTS; attempt++) {
1640
1678
  (0, import_log5.log)("guest waiting for authentication code...", {}, {
1641
1679
  file: "invitations-handler.ts",
1642
- line: 329,
1680
+ line: 280,
1643
1681
  scope: this,
1644
1682
  callSite: (f, a) => f(...a)
1645
1683
  });
1646
1684
  setState({
1647
- state: import_services2.Invitation.State.READY_FOR_AUTHENTICATION
1685
+ state: import_services3.Invitation.State.READY_FOR_AUTHENTICATION
1648
1686
  });
1649
1687
  const authCode = await authenticated.wait({
1650
1688
  timeout
1651
1689
  });
1652
1690
  (0, import_log5.log)("sending authentication request", {}, {
1653
1691
  file: "invitations-handler.ts",
1654
- line: 333,
1692
+ line: 284,
1655
1693
  scope: this,
1656
1694
  callSite: (f, a) => f(...a)
1657
1695
  });
1658
1696
  setState({
1659
- state: import_services2.Invitation.State.AUTHENTICATING
1697
+ state: import_services3.Invitation.State.AUTHENTICATING
1660
1698
  });
1661
1699
  const response = await extension.rpc.InvitationHostService.authenticate({
1662
1700
  authCode
@@ -1672,7 +1710,7 @@ var InvitationsHandler = class {
1672
1710
  attempt
1673
1711
  }, {
1674
1712
  file: "invitations-handler.ts",
1675
- line: 344,
1713
+ line: 295,
1676
1714
  scope: this,
1677
1715
  callSite: (f, a) => f(...a)
1678
1716
  });
@@ -1682,14 +1720,14 @@ var InvitationsHandler = class {
1682
1720
  }
1683
1721
  } else {
1684
1722
  setState({
1685
- state: import_services2.Invitation.State.READY_FOR_AUTHENTICATION
1723
+ state: import_services3.Invitation.State.READY_FOR_AUTHENTICATION
1686
1724
  });
1687
1725
  }
1688
1726
  (0, import_log5.log)("request admission", {
1689
1727
  ...protocol.toJSON()
1690
1728
  }, {
1691
1729
  file: "invitations-handler.ts",
1692
- line: 355,
1730
+ line: 306,
1693
1731
  scope: this,
1694
1732
  callSite: (f, a) => f(...a)
1695
1733
  });
@@ -1700,19 +1738,19 @@ var InvitationsHandler = class {
1700
1738
  ...protocol.toJSON()
1701
1739
  }, {
1702
1740
  file: "invitations-handler.ts",
1703
- line: 363,
1741
+ line: 314,
1704
1742
  scope: this,
1705
1743
  callSite: (f, a) => f(...a)
1706
1744
  });
1707
1745
  setState({
1708
1746
  ...result,
1709
- state: import_services2.Invitation.State.SUCCESS
1747
+ state: import_services3.Invitation.State.SUCCESS
1710
1748
  });
1711
1749
  import_log5.log.trace("dxos.sdk.invitations-handler.guest.onOpen", import_protocols4.trace.end({
1712
1750
  id: traceId
1713
1751
  }), {
1714
1752
  file: "invitations-handler.ts",
1715
- line: 365,
1753
+ line: 316,
1716
1754
  scope: this,
1717
1755
  callSite: (f, a) => f(...a)
1718
1756
  });
@@ -1722,17 +1760,17 @@ var InvitationsHandler = class {
1722
1760
  ...protocol.toJSON()
1723
1761
  }, {
1724
1762
  file: "invitations-handler.ts",
1725
- line: 368,
1763
+ line: 319,
1726
1764
  scope: this,
1727
1765
  callSite: (f, a) => f(...a)
1728
1766
  });
1729
1767
  setState({
1730
- state: import_services2.Invitation.State.TIMEOUT
1768
+ state: import_services3.Invitation.State.TIMEOUT
1731
1769
  });
1732
1770
  } else {
1733
1771
  (0, import_log5.log)("auth failed", err, {
1734
1772
  file: "invitations-handler.ts",
1735
- line: 371,
1773
+ line: 322,
1736
1774
  scope: this,
1737
1775
  callSite: (f, a) => f(...a)
1738
1776
  });
@@ -1743,7 +1781,7 @@ var InvitationsHandler = class {
1743
1781
  error: err
1744
1782
  }), {
1745
1783
  file: "invitations-handler.ts",
1746
- line: 374,
1784
+ line: 325,
1747
1785
  scope: this,
1748
1786
  callSite: (f, a) => f(...a)
1749
1787
  });
@@ -1761,17 +1799,17 @@ var InvitationsHandler = class {
1761
1799
  ...protocol.toJSON()
1762
1800
  }, {
1763
1801
  file: "invitations-handler.ts",
1764
- line: 385,
1802
+ line: 336,
1765
1803
  scope: this,
1766
1804
  callSite: (f, a) => f(...a)
1767
1805
  });
1768
1806
  setState({
1769
- state: import_services2.Invitation.State.TIMEOUT
1807
+ state: import_services3.Invitation.State.TIMEOUT
1770
1808
  });
1771
1809
  } else {
1772
1810
  (0, import_log5.log)("auth failed", err, {
1773
1811
  file: "invitations-handler.ts",
1774
- line: 388,
1812
+ line: 339,
1775
1813
  scope: this,
1776
1814
  callSite: (f, a) => f(...a)
1777
1815
  });
@@ -1794,7 +1832,7 @@ var InvitationsHandler = class {
1794
1832
  });
1795
1833
  ctx.onDispose(() => swarmConnection.close());
1796
1834
  setState({
1797
- state: import_services2.Invitation.State.CONNECTING
1835
+ state: import_services3.Invitation.State.CONNECTING
1798
1836
  });
1799
1837
  });
1800
1838
  const observable = new import_client_protocol2.AuthenticatingInvitationObservable({
@@ -1802,7 +1840,7 @@ var InvitationsHandler = class {
1802
1840
  subscriber: stream.observable,
1803
1841
  onCancel: async () => {
1804
1842
  setState({
1805
- state: import_services2.Invitation.State.CANCELLED
1843
+ state: import_services3.Invitation.State.CANCELLED
1806
1844
  });
1807
1845
  await ctx.dispose();
1808
1846
  },
@@ -1813,14 +1851,13 @@ var InvitationsHandler = class {
1813
1851
  return observable;
1814
1852
  }
1815
1853
  };
1816
- var isAuthenticationRequired = (invitation) => invitation.authMethod !== import_services2.Invitation.AuthMethod.NONE;
1817
1854
 
1818
1855
  // packages/sdk/client-services/src/packlets/invitations/invitations-service.ts
1819
1856
  var import_node_assert7 = __toESM(require("node:assert"));
1820
1857
  var import_async9 = require("@dxos/async");
1821
1858
  var import_codec_protobuf7 = require("@dxos/codec-protobuf");
1822
1859
  var import_log6 = require("@dxos/log");
1823
- var import_services3 = require("@dxos/protocols/proto/dxos/client/services");
1860
+ var import_services4 = require("@dxos/protocols/proto/dxos/client/services");
1824
1861
  var InvitationsServiceImpl = class {
1825
1862
  constructor(_invitationsHandler, _getHandler) {
1826
1863
  this._invitationsHandler = _invitationsHandler;
@@ -1935,8 +1972,8 @@ var InvitationsServiceImpl = class {
1935
1972
  return new import_codec_protobuf7.Stream(({ next, ctx }) => {
1936
1973
  this._invitationCreated.on(ctx, (invitation) => {
1937
1974
  next({
1938
- action: import_services3.QueryInvitationsResponse.Action.ADDED,
1939
- type: import_services3.QueryInvitationsResponse.Type.CREATED,
1975
+ action: import_services4.QueryInvitationsResponse.Action.ADDED,
1976
+ type: import_services4.QueryInvitationsResponse.Type.CREATED,
1940
1977
  invitations: [
1941
1978
  invitation
1942
1979
  ]
@@ -1944,8 +1981,8 @@ var InvitationsServiceImpl = class {
1944
1981
  });
1945
1982
  this._invitationAccepted.on(ctx, (invitation) => {
1946
1983
  next({
1947
- action: import_services3.QueryInvitationsResponse.Action.ADDED,
1948
- type: import_services3.QueryInvitationsResponse.Type.ACCEPTED,
1984
+ action: import_services4.QueryInvitationsResponse.Action.ADDED,
1985
+ type: import_services4.QueryInvitationsResponse.Type.ACCEPTED,
1949
1986
  invitations: [
1950
1987
  invitation
1951
1988
  ]
@@ -1953,8 +1990,8 @@ var InvitationsServiceImpl = class {
1953
1990
  });
1954
1991
  this._removedCreated.on(ctx, (invitation) => {
1955
1992
  next({
1956
- action: import_services3.QueryInvitationsResponse.Action.REMOVED,
1957
- type: import_services3.QueryInvitationsResponse.Type.CREATED,
1993
+ action: import_services4.QueryInvitationsResponse.Action.REMOVED,
1994
+ type: import_services4.QueryInvitationsResponse.Type.CREATED,
1958
1995
  invitations: [
1959
1996
  invitation
1960
1997
  ]
@@ -1962,21 +1999,21 @@ var InvitationsServiceImpl = class {
1962
1999
  });
1963
2000
  this._removedAccepted.on(ctx, (invitation) => {
1964
2001
  next({
1965
- action: import_services3.QueryInvitationsResponse.Action.REMOVED,
1966
- type: import_services3.QueryInvitationsResponse.Type.ACCEPTED,
2002
+ action: import_services4.QueryInvitationsResponse.Action.REMOVED,
2003
+ type: import_services4.QueryInvitationsResponse.Type.ACCEPTED,
1967
2004
  invitations: [
1968
2005
  invitation
1969
2006
  ]
1970
2007
  });
1971
2008
  });
1972
2009
  next({
1973
- action: import_services3.QueryInvitationsResponse.Action.ADDED,
1974
- type: import_services3.QueryInvitationsResponse.Type.CREATED,
2010
+ action: import_services4.QueryInvitationsResponse.Action.ADDED,
2011
+ type: import_services4.QueryInvitationsResponse.Type.CREATED,
1975
2012
  invitations: Array.from(this._createInvitations.values()).map((invitation) => invitation.get())
1976
2013
  });
1977
2014
  next({
1978
- action: import_services3.QueryInvitationsResponse.Action.ADDED,
1979
- type: import_services3.QueryInvitationsResponse.Type.ACCEPTED,
2015
+ action: import_services4.QueryInvitationsResponse.Action.ADDED,
2016
+ type: import_services4.QueryInvitationsResponse.Type.ACCEPTED,
1980
2017
  invitations: Array.from(this._acceptInvitations.values()).map((invitation) => invitation.get())
1981
2018
  });
1982
2019
  });
@@ -1988,7 +2025,7 @@ var import_node_assert8 = __toESM(require("node:assert"));
1988
2025
  var import_credentials8 = require("@dxos/credentials");
1989
2026
  var import_feed_store3 = require("@dxos/feed-store");
1990
2027
  var import_log7 = require("@dxos/log");
1991
- var import_services4 = require("@dxos/protocols/proto/dxos/client/services");
2028
+ var import_services5 = require("@dxos/protocols/proto/dxos/client/services");
1992
2029
  var SpaceInvitationProtocol = class {
1993
2030
  constructor(_spaceManager, _signingContext, _keyring, _spaceKey) {
1994
2031
  this._spaceManager = _spaceManager;
@@ -2004,7 +2041,7 @@ var SpaceInvitationProtocol = class {
2004
2041
  }
2005
2042
  getInvitationContext() {
2006
2043
  return {
2007
- kind: import_services4.Invitation.Kind.SPACE,
2044
+ kind: import_services5.Invitation.Kind.SPACE,
2008
2045
  spaceKey: this._spaceKey
2009
2046
  };
2010
2047
  }
@@ -2083,12 +2120,12 @@ var import_log19 = require("@dxos/log");
2083
2120
  var import_messaging3 = require("@dxos/messaging");
2084
2121
  var import_network_manager5 = require("@dxos/network-manager");
2085
2122
  var import_protocols9 = require("@dxos/protocols");
2086
- var import_services12 = require("@dxos/protocols/proto/dxos/client/services");
2123
+ var import_services13 = require("@dxos/protocols/proto/dxos/client/services");
2087
2124
 
2088
2125
  // packages/sdk/client-services/src/packlets/devices/devices-service.ts
2089
2126
  var import_async10 = require("@dxos/async");
2090
2127
  var import_codec_protobuf8 = require("@dxos/codec-protobuf");
2091
- var import_services5 = require("@dxos/protocols/proto/dxos/client/services");
2128
+ var import_services6 = require("@dxos/protocols/proto/dxos/client/services");
2092
2129
  var DevicesServiceImpl = class {
2093
2130
  constructor(_identityManager) {
2094
2131
  this._identityManager = _identityManager;
@@ -2111,7 +2148,7 @@ var DevicesServiceImpl = class {
2111
2148
  var _a2;
2112
2149
  return {
2113
2150
  deviceKey: key,
2114
- kind: ((_a2 = this._identityManager.identity) == null ? void 0 : _a2.deviceKey.equals(key)) ? import_services5.DeviceKind.CURRENT : import_services5.DeviceKind.TRUSTED
2151
+ kind: ((_a2 = this._identityManager.identity) == null ? void 0 : _a2.deviceKey.equals(key)) ? import_services6.DeviceKind.CURRENT : import_services6.DeviceKind.TRUSTED
2115
2152
  };
2116
2153
  })
2117
2154
  });
@@ -2235,7 +2272,7 @@ var import_credentials12 = require("@dxos/credentials");
2235
2272
  var import_keys9 = require("@dxos/keys");
2236
2273
  var import_log11 = require("@dxos/log");
2237
2274
  var import_protocols6 = require("@dxos/protocols");
2238
- var import_services7 = require("@dxos/protocols/proto/dxos/client/services");
2275
+ var import_services8 = require("@dxos/protocols/proto/dxos/client/services");
2239
2276
  var import_teleport_extension_gossip = require("@dxos/teleport-extension-gossip");
2240
2277
  var import_util5 = require("@dxos/util");
2241
2278
 
@@ -2248,7 +2285,7 @@ var import_echo_pipeline = require("@dxos/echo-pipeline");
2248
2285
  var import_errors3 = require("@dxos/errors");
2249
2286
  var import_keys8 = require("@dxos/keys");
2250
2287
  var import_log10 = require("@dxos/log");
2251
- var import_services6 = require("@dxos/protocols/proto/dxos/client/services");
2288
+ var import_services7 = require("@dxos/protocols/proto/dxos/client/services");
2252
2289
  var import_credentials9 = require("@dxos/protocols/proto/dxos/halo/credentials");
2253
2290
  var import_util4 = require("@dxos/util");
2254
2291
 
@@ -2505,7 +2542,7 @@ var __decorate = function(decorators, target, key, desc) {
2505
2542
  var DataSpace = class DataSpace2 {
2506
2543
  constructor(params) {
2507
2544
  this._ctx = new import_context6.Context();
2508
- this._state = import_services6.SpaceState.CLOSED;
2545
+ this._state = import_services7.SpaceState.CLOSED;
2509
2546
  /**
2510
2547
  * Error for _state === SpaceState.ERROR.
2511
2548
  */
@@ -2559,11 +2596,11 @@ var DataSpace = class DataSpace2 {
2559
2596
  await this.notarizationPlugin.open();
2560
2597
  await this._notarizationPluginConsumer.open();
2561
2598
  await this._inner.open();
2562
- this._state = import_services6.SpaceState.INACTIVE;
2599
+ this._state = import_services7.SpaceState.INACTIVE;
2563
2600
  this.metrics.open = new Date();
2564
2601
  }
2565
2602
  async close() {
2566
- this._state = import_services6.SpaceState.CLOSED;
2603
+ this._state = import_services7.SpaceState.CLOSED;
2567
2604
  await this._ctx.dispose();
2568
2605
  await this.authVerifier.close();
2569
2606
  await this._inner.close();
@@ -2601,7 +2638,7 @@ var DataSpace = class DataSpace2 {
2601
2638
  scope: this,
2602
2639
  callSite: (f, a) => f(...a)
2603
2640
  });
2604
- this._state = import_services6.SpaceState.ERROR;
2641
+ this._state = import_services7.SpaceState.ERROR;
2605
2642
  this.error = err;
2606
2643
  this.stateUpdate.emit();
2607
2644
  } finally {
@@ -2611,10 +2648,10 @@ var DataSpace = class DataSpace2 {
2611
2648
  }
2612
2649
  async initializeDataPipeline() {
2613
2650
  var _a, _b, _c, _d;
2614
- if (this._state !== import_services6.SpaceState.INACTIVE) {
2651
+ if (this._state !== import_services7.SpaceState.INACTIVE) {
2615
2652
  throw new import_errors3.SystemError("Invalid operation");
2616
2653
  }
2617
- this._state = import_services6.SpaceState.INITIALIZING;
2654
+ this._state = import_services7.SpaceState.INITIALIZING;
2618
2655
  await this._inner.controlPipeline.state.waitUntilReachedTargetTimeframe({
2619
2656
  ctx: this._ctx,
2620
2657
  breakOnStall: false
@@ -2654,7 +2691,7 @@ var DataSpace = class DataSpace2 {
2654
2691
  callSite: (f, a) => f(...a)
2655
2692
  });
2656
2693
  await ((_b = (_a = this._callbacks).beforeReady) == null ? void 0 : _b.call(_a));
2657
- this._state = import_services6.SpaceState.READY;
2694
+ this._state = import_services7.SpaceState.READY;
2658
2695
  this.stateUpdate.emit();
2659
2696
  await ((_d = (_c = this._callbacks).afterReady) == null ? void 0 : _d.call(_c));
2660
2697
  }
@@ -2965,7 +3002,7 @@ var DataSpaceManager = class DataSpaceManager2 {
2965
3002
  async waitUntilSpaceReady(spaceKey) {
2966
3003
  await (0, import_context7.cancelWithContext)(this._ctx, this.updated.waitForCondition(() => {
2967
3004
  const space = this._spaces.get(spaceKey);
2968
- return !!space && space.state === import_services7.SpaceState.READY;
3005
+ return !!space && space.state === import_services8.SpaceState.READY;
2969
3006
  }));
2970
3007
  }
2971
3008
  async _constructSpace(metadata) {
@@ -3006,6 +3043,14 @@ var DataSpaceManager = class DataSpaceManager2 {
3006
3043
  session.addExtension("dxos.mesh.teleport.objectsync", space.snapshotManager.objectSync.createExtension());
3007
3044
  session.addExtension("dxos.mesh.teleport.notarization", dataSpace.notarizationPlugin.createExtension());
3008
3045
  },
3046
+ onAuthFailure: () => {
3047
+ import_log11.log.warn("auth failure", {}, {
3048
+ file: "data-space-manager.ts",
3049
+ line: 212,
3050
+ scope: this,
3051
+ callSite: (f, a) => f(...a)
3052
+ });
3053
+ },
3009
3054
  memberKey: this._signingContext.identityKey
3010
3055
  });
3011
3056
  controlFeed && space.setControlFeed(controlFeed);
@@ -3024,7 +3069,7 @@ var DataSpaceManager = class DataSpaceManager2 {
3024
3069
  space: space.key
3025
3070
  }, {
3026
3071
  file: "data-space-manager.ts",
3027
- line: 226,
3072
+ line: 229,
3028
3073
  scope: this,
3029
3074
  callSite: (f, a) => f(...a)
3030
3075
  });
@@ -3036,7 +3081,7 @@ var DataSpaceManager = class DataSpaceManager2 {
3036
3081
  open: this._isOpen
3037
3082
  }, {
3038
3083
  file: "data-space-manager.ts",
3039
- line: 233,
3084
+ line: 236,
3040
3085
  scope: this,
3041
3086
  callSite: (f, a) => f(...a)
3042
3087
  });
@@ -3081,7 +3126,7 @@ var import_debug5 = require("@dxos/debug");
3081
3126
  var import_echo_pipeline2 = require("@dxos/echo-pipeline");
3082
3127
  var import_log12 = require("@dxos/log");
3083
3128
  var import_protocols7 = require("@dxos/protocols");
3084
- var import_services8 = require("@dxos/protocols/proto/dxos/client/services");
3129
+ var import_services9 = require("@dxos/protocols/proto/dxos/client/services");
3085
3130
  var import_util6 = require("@dxos/util");
3086
3131
  var TIMEFRAME_UPDATE_DEBOUNCE_TIME = 500;
3087
3132
  var SpacesServiceImpl = class {
@@ -3222,7 +3267,7 @@ var SpacesServiceImpl = class {
3222
3267
  displayName: (_b2 = (_a2 = member.assertion.profile) == null ? void 0 : _a2.displayName) != null ? _b2 : (0, import_util6.humanize)(member.key)
3223
3268
  }
3224
3269
  },
3225
- presence: ((_c2 = this._identityManager.identity) == null ? void 0 : _c2.identityKey.equals(member.key)) || space.presence.getPeersOnline().filter(({ identityKey }) => identityKey.equals(member.key)).length > 0 ? import_services8.SpaceMember.PresenceState.ONLINE : import_services8.SpaceMember.PresenceState.OFFLINE
3270
+ presence: ((_c2 = this._identityManager.identity) == null ? void 0 : _c2.identityKey.equals(member.key)) || space.presence.getPeersOnline().filter(({ identityKey }) => identityKey.equals(member.key)).length > 0 ? import_services9.SpaceMember.PresenceState.ONLINE : import_services9.SpaceMember.PresenceState.OFFLINE
3226
3271
  };
3227
3272
  }),
3228
3273
  cache: space.cache,
@@ -4046,7 +4091,7 @@ var import_keyring = require("@dxos/keyring");
4046
4091
  var import_keys10 = require("@dxos/keys");
4047
4092
  var import_log18 = require("@dxos/log");
4048
4093
  var import_protocols8 = require("@dxos/protocols");
4049
- var import_services11 = require("@dxos/protocols/proto/dxos/client/services");
4094
+ var import_services12 = require("@dxos/protocols/proto/dxos/client/services");
4050
4095
  var ServiceContext = class {
4051
4096
  // prettier-ignore
4052
4097
  constructor(storage, networkManager, signalManager, modelFactory) {
@@ -4079,7 +4124,7 @@ var ServiceContext = class {
4079
4124
  });
4080
4125
  this.identityManager = new IdentityManager(this.metadataStore, this.keyring, this.feedStore, this.spaceManager);
4081
4126
  this.invitations = new InvitationsHandler(this.networkManager);
4082
- this._handlerFactories.set(import_services11.Invitation.Kind.DEVICE, () => new DeviceInvitationProtocol(this.keyring, () => {
4127
+ this._handlerFactories.set(import_services12.Invitation.Kind.DEVICE, () => new DeviceInvitationProtocol(this.keyring, () => {
4083
4128
  var _a;
4084
4129
  return (_a = this.identityManager.identity) != null ? _a : (0, import_debug7.failUndefined)();
4085
4130
  }, this._acceptIdentity.bind(this)));
@@ -4200,7 +4245,7 @@ var ServiceContext = class {
4200
4245
  };
4201
4246
  this.dataSpaceManager = new DataSpaceManager(this.spaceManager, this.metadataStore, this.dataServiceSubscriptions, this.keyring, signingContext, this.feedStore);
4202
4247
  await this.dataSpaceManager.open();
4203
- this._handlerFactories.set(import_services11.Invitation.Kind.SPACE, (invitation) => {
4248
+ this._handlerFactories.set(import_services12.Invitation.Kind.SPACE, (invitation) => {
4204
4249
  (0, import_node_assert13.default)(this.dataSpaceManager, "dataSpaceManager not initialized yet");
4205
4250
  return new SpaceInvitationProtocol(this.dataSpaceManager, signingContext, this.keyring, invitation.spaceKey);
4206
4251
  });
@@ -4324,12 +4369,12 @@ var ClientServicesHost = class {
4324
4369
  this._systemService = new SystemServiceImpl({
4325
4370
  config: this._config,
4326
4371
  statusUpdate: this._statusUpdate,
4327
- getCurrentStatus: () => this.isOpen ? import_services12.SystemStatus.ACTIVE : import_services12.SystemStatus.INACTIVE,
4372
+ getCurrentStatus: () => this.isOpen ? import_services13.SystemStatus.ACTIVE : import_services13.SystemStatus.INACTIVE,
4328
4373
  onUpdateStatus: async (status) => {
4329
4374
  var _a, _b;
4330
- if (!this.isOpen && status === import_services12.SystemStatus.ACTIVE) {
4375
+ if (!this.isOpen && status === import_services13.SystemStatus.ACTIVE) {
4331
4376
  await ((_a = this._resourceLock) == null ? void 0 : _a.acquire());
4332
- } else if (this.isOpen && status === import_services12.SystemStatus.INACTIVE) {
4377
+ } else if (this.isOpen && status === import_services13.SystemStatus.INACTIVE) {
4333
4378
  await ((_b = this._resourceLock) == null ? void 0 : _b.release());
4334
4379
  }
4335
4380
  },