@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.
@@ -63,7 +63,7 @@ var createMockCredential = async ({ signer, issuer }) => (0, import_credentials.
63
63
  // packages/sdk/client-services/src/packlets/testing/invitation-utils.ts
64
64
  var import_node_assert15 = __toESM(require("node:assert"));
65
65
  var import_async24 = require("@dxos/async");
66
- var import_services13 = require("@dxos/protocols/proto/dxos/client/services");
66
+ var import_services14 = require("@dxos/protocols/proto/dxos/client/services");
67
67
 
68
68
  // packages/sdk/client-services/src/packlets/services/service-host.ts
69
69
  var import_node_assert14 = __toESM(require("node:assert"));
@@ -75,7 +75,7 @@ var import_log19 = require("@dxos/log");
75
75
  var import_messaging3 = require("@dxos/messaging");
76
76
  var import_network_manager5 = require("@dxos/network-manager");
77
77
  var import_protocols9 = require("@dxos/protocols");
78
- var import_services12 = require("@dxos/protocols/proto/dxos/client/services");
78
+ var import_services13 = require("@dxos/protocols/proto/dxos/client/services");
79
79
 
80
80
  // packages/sdk/client-services/src/packlets/devices/devices-service.ts
81
81
  var import_async = require("@dxos/async");
@@ -916,6 +916,14 @@ var IdentityManager = class {
916
916
  swarmIdentity,
917
917
  onNetworkConnection: () => {
918
918
  },
919
+ onAuthFailure: () => {
920
+ import_log3.log.warn("auth failure", {}, {
921
+ file: "identity-manager.ts",
922
+ line: 242,
923
+ scope: this,
924
+ callSite: (f, a) => f(...a)
925
+ });
926
+ },
919
927
  memberKey: identityKey
920
928
  });
921
929
  }
@@ -1045,7 +1053,7 @@ var import_keys7 = require("@dxos/keys");
1045
1053
  var import_log5 = require("@dxos/log");
1046
1054
  var import_network_manager = require("@dxos/network-manager");
1047
1055
  var import_protocols4 = require("@dxos/protocols");
1048
- var import_services3 = require("@dxos/protocols/proto/dxos/client/services");
1056
+ var import_services4 = require("@dxos/protocols/proto/dxos/client/services");
1049
1057
  var import_invitations2 = require("@dxos/protocols/proto/dxos/halo/invitations");
1050
1058
 
1051
1059
  // packages/sdk/client-services/src/packlets/invitations/invitation-extension.ts
@@ -1056,9 +1064,11 @@ var import_errors = require("@dxos/errors");
1056
1064
  var import_keys6 = require("@dxos/keys");
1057
1065
  var import_log4 = require("@dxos/log");
1058
1066
  var import_protocols3 = require("@dxos/protocols");
1067
+ var import_services3 = require("@dxos/protocols/proto/dxos/client/services");
1059
1068
  var import_invitations = require("@dxos/protocols/proto/dxos/halo/invitations");
1060
1069
  var import_teleport = require("@dxos/teleport");
1061
1070
  var OPTIONS_TIMEOUT = 1e4;
1071
+ var MAX_OTP_ATTEMPTS = 3;
1062
1072
  var InvitationHostExtension = class extends import_teleport.RpcExtension {
1063
1073
  constructor(_callbacks) {
1064
1074
  super({
@@ -1072,6 +1082,11 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
1072
1082
  this._callbacks = _callbacks;
1073
1083
  this._ctx = new import_context3.Context();
1074
1084
  this._remoteOptionsTrigger = new import_async8.Trigger();
1085
+ this.invitation = void 0;
1086
+ this.guestProfile = void 0;
1087
+ this.authenticationPassed = false;
1088
+ this.authenticationRetry = 0;
1089
+ this.completedTrigger = new import_async8.Trigger();
1075
1090
  }
1076
1091
  async getHandlers() {
1077
1092
  return {
@@ -1084,49 +1099,129 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
1084
1099
  this._remoteOptionsTrigger.wake();
1085
1100
  },
1086
1101
  introduce: async (request) => {
1102
+ const { profile, invitationId } = request;
1087
1103
  const traceId = import_keys6.PublicKey.random().toHex();
1088
1104
  import_log4.log.trace("dxos.sdk.invitation-handler.host.introduce", import_protocols3.trace.begin({
1089
1105
  id: traceId
1090
1106
  }), {
1091
1107
  file: "invitation-extension.ts",
1092
- line: 76,
1108
+ line: 98,
1093
1109
  scope: this,
1094
1110
  callSite: (f, a) => f(...a)
1095
1111
  });
1096
- const response = await this._callbacks.introduce(request);
1112
+ const invitation = await this._callbacks.resolveInvitation(request);
1113
+ if (!invitation) {
1114
+ import_log4.log.warn("invitation not found", {
1115
+ invitationId
1116
+ }, {
1117
+ file: "invitation-extension.ts",
1118
+ line: 102,
1119
+ scope: this,
1120
+ callSite: (f, a) => f(...a)
1121
+ });
1122
+ this._callbacks.onError(new Error("Invitation not found."));
1123
+ return {
1124
+ authMethod: import_services3.Invitation.AuthMethod.NONE
1125
+ };
1126
+ }
1127
+ this.invitation = invitation;
1128
+ (0, import_log4.log)("guest introduced itself", {
1129
+ guestProfile: profile
1130
+ }, {
1131
+ file: "invitation-extension.ts",
1132
+ line: 111,
1133
+ scope: this,
1134
+ callSite: (f, a) => f(...a)
1135
+ });
1136
+ this.guestProfile = profile;
1137
+ this._callbacks.onStateUpdate({
1138
+ ...this.invitation,
1139
+ state: import_services3.Invitation.State.READY_FOR_AUTHENTICATION
1140
+ });
1097
1141
  import_log4.log.trace("dxos.sdk.invitation-handler.host.introduce", import_protocols3.trace.end({
1098
1142
  id: traceId
1099
1143
  }), {
1100
1144
  file: "invitation-extension.ts",
1101
- line: 78,
1145
+ line: 118,
1102
1146
  scope: this,
1103
1147
  callSite: (f, a) => f(...a)
1104
1148
  });
1105
- return response;
1149
+ return {
1150
+ spaceKey: this.invitation.authMethod === import_services3.Invitation.AuthMethod.NONE ? this.invitation.spaceKey : void 0,
1151
+ authMethod: this.invitation.authMethod
1152
+ };
1106
1153
  },
1107
- authenticate: async (request) => {
1154
+ authenticate: async ({ authCode: code }) => {
1108
1155
  const traceId = import_keys6.PublicKey.random().toHex();
1109
1156
  import_log4.log.trace("dxos.sdk.invitation-handler.host.authenticate", import_protocols3.trace.begin({
1110
1157
  id: traceId
1111
1158
  }), {
1112
1159
  file: "invitation-extension.ts",
1113
- line: 84,
1160
+ line: 127,
1114
1161
  scope: this,
1115
1162
  callSite: (f, a) => f(...a)
1116
1163
  });
1117
- const response = await this._callbacks.authenticate(request);
1164
+ (0, import_log4.log)("received authentication request", {
1165
+ authCode: code
1166
+ }, {
1167
+ file: "invitation-extension.ts",
1168
+ line: 128,
1169
+ scope: this,
1170
+ callSite: (f, a) => f(...a)
1171
+ });
1172
+ let status = import_invitations.AuthenticationResponse.Status.OK;
1173
+ (0, import_node_assert5.default)(this.invitation, "Invitation is not set.");
1174
+ switch (this.invitation.authMethod) {
1175
+ case import_services3.Invitation.AuthMethod.NONE: {
1176
+ (0, import_log4.log)("authentication not required", {}, {
1177
+ file: "invitation-extension.ts",
1178
+ line: 134,
1179
+ scope: this,
1180
+ callSite: (f, a) => f(...a)
1181
+ });
1182
+ return {
1183
+ status: import_invitations.AuthenticationResponse.Status.OK
1184
+ };
1185
+ }
1186
+ case import_services3.Invitation.AuthMethod.SHARED_SECRET: {
1187
+ if (this.invitation.authCode) {
1188
+ if (this.authenticationRetry++ > MAX_OTP_ATTEMPTS) {
1189
+ status = import_invitations.AuthenticationResponse.Status.INVALID_OPT_ATTEMPTS;
1190
+ } else if (code !== this.invitation.authCode) {
1191
+ status = import_invitations.AuthenticationResponse.Status.INVALID_OTP;
1192
+ } else {
1193
+ this.authenticationPassed = true;
1194
+ }
1195
+ }
1196
+ break;
1197
+ }
1198
+ default: {
1199
+ import_log4.log.error("invalid authentication method", {
1200
+ authMethod: this.invitation.authMethod
1201
+ }, {
1202
+ file: "invitation-extension.ts",
1203
+ line: 152,
1204
+ scope: this,
1205
+ callSite: (f, a) => f(...a)
1206
+ });
1207
+ status = import_invitations.AuthenticationResponse.Status.INTERNAL_ERROR;
1208
+ break;
1209
+ }
1210
+ }
1118
1211
  import_log4.log.trace("dxos.sdk.invitation-handler.host.authenticate", import_protocols3.trace.end({
1119
1212
  id: traceId,
1120
1213
  data: {
1121
- ...response
1214
+ status
1122
1215
  }
1123
1216
  }), {
1124
1217
  file: "invitation-extension.ts",
1125
- line: 86,
1218
+ line: 158,
1126
1219
  scope: this,
1127
1220
  callSite: (f, a) => f(...a)
1128
1221
  });
1129
- return response;
1222
+ return {
1223
+ status
1224
+ };
1130
1225
  },
1131
1226
  admit: async (request) => {
1132
1227
  const traceId = import_keys6.PublicKey.random().toHex();
@@ -1134,20 +1229,29 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
1134
1229
  id: traceId
1135
1230
  }), {
1136
1231
  file: "invitation-extension.ts",
1137
- line: 92,
1232
+ line: 164,
1138
1233
  scope: this,
1139
1234
  callSite: (f, a) => f(...a)
1140
1235
  });
1141
- const response = await this._callbacks.admit(request);
1142
- import_log4.log.trace("dxos.sdk.invitation-handler.host.admit", import_protocols3.trace.end({
1143
- id: traceId
1144
- }), {
1145
- file: "invitation-extension.ts",
1146
- line: 94,
1147
- scope: this,
1148
- callSite: (f, a) => f(...a)
1149
- });
1150
- return response;
1236
+ try {
1237
+ (0, import_node_assert5.default)(this.invitation, "Invitation is not set.");
1238
+ if (isAuthenticationRequired(this.invitation) && !this.authenticationPassed) {
1239
+ throw new Error("Not authenticated");
1240
+ }
1241
+ const response = await this._callbacks.admit(request);
1242
+ import_log4.log.trace("dxos.sdk.invitation-handler.host.admit", import_protocols3.trace.end({
1243
+ id: traceId
1244
+ }), {
1245
+ file: "invitation-extension.ts",
1246
+ line: 175,
1247
+ scope: this,
1248
+ callSite: (f, a) => f(...a)
1249
+ });
1250
+ return response;
1251
+ } catch (err) {
1252
+ this._callbacks.onError(err);
1253
+ throw err;
1254
+ }
1151
1255
  }
1152
1256
  }
1153
1257
  };
@@ -1217,7 +1321,7 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
1217
1321
  try {
1218
1322
  (0, import_log4.log)("begin options", {}, {
1219
1323
  file: "invitation-extension.ts",
1220
- line: 178,
1324
+ line: 263,
1221
1325
  scope: this,
1222
1326
  callSite: (f, a) => f(...a)
1223
1327
  });
@@ -1229,7 +1333,7 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
1229
1333
  }));
1230
1334
  (0, import_log4.log)("end options", {}, {
1231
1335
  file: "invitation-extension.ts",
1232
- line: 181,
1336
+ line: 266,
1233
1337
  scope: this,
1234
1338
  callSite: (f, a) => f(...a)
1235
1339
  });
@@ -1243,7 +1347,7 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
1243
1347
  } catch (err) {
1244
1348
  (0, import_log4.log)("openError", err, {
1245
1349
  file: "invitation-extension.ts",
1246
- line: 191,
1350
+ line: 276,
1247
1351
  scope: this,
1248
1352
  callSite: (f, a) => f(...a)
1249
1353
  });
@@ -1253,16 +1357,16 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
1253
1357
  async onClose() {
1254
1358
  (0, import_log4.log)("onClose", {}, {
1255
1359
  file: "invitation-extension.ts",
1256
- line: 197,
1360
+ line: 282,
1257
1361
  scope: this,
1258
1362
  callSite: (f, a) => f(...a)
1259
1363
  });
1260
1364
  await this._ctx.dispose();
1261
1365
  }
1262
1366
  };
1367
+ var isAuthenticationRequired = (invitation) => invitation.authMethod !== import_services3.Invitation.AuthMethod.NONE;
1263
1368
 
1264
1369
  // packages/sdk/client-services/src/packlets/invitations/invitations-handler.ts
1265
- var MAX_OTP_ATTEMPTS = 3;
1266
1370
  var InvitationsHandler = class {
1267
1371
  /**
1268
1372
  * @internal
@@ -1272,8 +1376,8 @@ var InvitationsHandler = class {
1272
1376
  }
1273
1377
  createInvitation(protocol, options) {
1274
1378
  var _a;
1275
- const { invitationId = import_keys7.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_keys7.PublicKey.random() } = options != null ? options : {};
1276
- const authCode = (_a = options == null ? void 0 : options.authCode) != null ? _a : authMethod === import_services3.Invitation.AuthMethod.SHARED_SECRET ? (0, import_credentials8.generatePasscode)(import_client_protocol2.AUTHENTICATION_CODE_LENGTH) : void 0;
1379
+ const { invitationId = import_keys7.PublicKey.random().toHex(), type = import_services4.Invitation.Type.INTERACTIVE, authMethod = import_services4.Invitation.AuthMethod.SHARED_SECRET, state = import_services4.Invitation.State.INIT, timeout = import_client_protocol2.INVITATION_TIMEOUT, swarmKey = import_keys7.PublicKey.random() } = options != null ? options : {};
1380
+ const authCode = (_a = options == null ? void 0 : options.authCode) != null ? _a : authMethod === import_services4.Invitation.AuthMethod.SHARED_SECRET ? (0, import_credentials8.generatePasscode)(import_client_protocol2.AUTHENTICATION_CODE_LENGTH) : void 0;
1277
1381
  (0, import_node_assert6.default)(protocol);
1278
1382
  const invitation = {
1279
1383
  invitationId,
@@ -1297,99 +1401,33 @@ var InvitationsHandler = class {
1297
1401
  ...protocol.toJSON()
1298
1402
  }, {
1299
1403
  file: "invitations-handler.ts",
1300
- line: 98,
1404
+ line: 100,
1301
1405
  scope: this,
1302
1406
  callSite: (f, a) => f(...a)
1303
1407
  });
1304
1408
  stream.complete();
1305
1409
  });
1306
1410
  const createExtension = () => {
1307
- const success = new import_async9.Trigger();
1308
- let guestProfile;
1309
- let authenticationPassed = false;
1310
- let authenticationRetry = 0;
1311
1411
  const extension = new InvitationHostExtension({
1312
- introduce: async ({ profile }) => {
1313
- (0, import_log5.log)("guest introduced itself", {
1314
- guestProfile: profile,
1315
- ...protocol.toJSON()
1316
- }, {
1317
- file: "invitations-handler.ts",
1318
- line: 111,
1319
- scope: this,
1320
- callSite: (f, a) => f(...a)
1321
- });
1322
- guestProfile = profile;
1412
+ onStateUpdate: (invitation2) => {
1323
1413
  stream.next({
1324
- ...invitation,
1325
- state: import_services3.Invitation.State.READY_FOR_AUTHENTICATION
1414
+ ...invitation2,
1415
+ state: import_services4.Invitation.State.READY_FOR_AUTHENTICATION
1326
1416
  });
1327
- return {
1328
- spaceKey: authMethod === import_services3.Invitation.AuthMethod.NONE ? protocol.getInvitationContext().spaceKey : void 0,
1329
- authMethod
1330
- };
1331
1417
  },
1332
- authenticate: async ({ authCode: code }) => {
1333
- (0, import_log5.log)("received authentication request", {
1334
- authCode: code
1335
- }, {
1336
- file: "invitations-handler.ts",
1337
- line: 130,
1338
- scope: this,
1339
- callSite: (f, a) => f(...a)
1340
- });
1341
- let status = import_invitations2.AuthenticationResponse.Status.OK;
1342
- switch (invitation.authMethod) {
1343
- case import_services3.Invitation.AuthMethod.NONE: {
1344
- (0, import_log5.log)("authentication not required", {}, {
1345
- file: "invitations-handler.ts",
1346
- line: 135,
1347
- scope: this,
1348
- callSite: (f, a) => f(...a)
1349
- });
1350
- return {
1351
- status: import_invitations2.AuthenticationResponse.Status.OK
1352
- };
1353
- }
1354
- case import_services3.Invitation.AuthMethod.SHARED_SECRET: {
1355
- if (invitation.authCode) {
1356
- if (authenticationRetry++ > MAX_OTP_ATTEMPTS) {
1357
- status = import_invitations2.AuthenticationResponse.Status.INVALID_OPT_ATTEMPTS;
1358
- } else if (code !== invitation.authCode) {
1359
- status = import_invitations2.AuthenticationResponse.Status.INVALID_OTP;
1360
- } else {
1361
- authenticationPassed = true;
1362
- }
1363
- }
1364
- break;
1365
- }
1366
- default: {
1367
- import_log5.log.error("invalid authentication method", {
1368
- authMethod: invitation.authMethod
1369
- }, {
1370
- file: "invitations-handler.ts",
1371
- line: 153,
1372
- scope: this,
1373
- callSite: (f, a) => f(...a)
1374
- });
1375
- status = import_invitations2.AuthenticationResponse.Status.INTERNAL_ERROR;
1376
- break;
1377
- }
1418
+ resolveInvitation: async ({ invitationId: invitationId2 }) => {
1419
+ if (invitationId2 && invitationId2 !== invitation.invitationId) {
1420
+ return void 0;
1378
1421
  }
1379
- return {
1380
- status
1381
- };
1422
+ return invitation;
1382
1423
  },
1383
1424
  admit: async (admissionRequest) => {
1384
1425
  var _a2, _b, _c;
1385
1426
  try {
1386
- if (isAuthenticationRequired(invitation) && !authenticationPassed) {
1387
- throw new Error("Not authenticated");
1388
- }
1389
1427
  const deviceKey = (_c = (_a2 = admissionRequest.device) == null ? void 0 : _a2.deviceKey) != null ? _c : (_b = admissionRequest.space) == null ? void 0 : _b.deviceKey;
1390
1428
  (0, import_node_assert6.default)(deviceKey);
1391
- const admissionResponse = await protocol.admit(admissionRequest, guestProfile);
1392
- success.wake(deviceKey);
1429
+ const admissionResponse = await protocol.admit(admissionRequest, extension.guestProfile);
1430
+ extension.completedTrigger.wake(deviceKey);
1393
1431
  return admissionResponse;
1394
1432
  } catch (err) {
1395
1433
  stream.error(err);
@@ -1404,7 +1442,7 @@ var InvitationsHandler = class {
1404
1442
  id: traceId
1405
1443
  }), {
1406
1444
  file: "invitations-handler.ts",
1407
- line: 188,
1445
+ line: 139,
1408
1446
  scope: this,
1409
1447
  callSite: (f, a) => f(...a)
1410
1448
  });
@@ -1412,15 +1450,15 @@ var InvitationsHandler = class {
1412
1450
  ...protocol.toJSON()
1413
1451
  }, {
1414
1452
  file: "invitations-handler.ts",
1415
- line: 189,
1453
+ line: 140,
1416
1454
  scope: this,
1417
1455
  callSite: (f, a) => f(...a)
1418
1456
  });
1419
1457
  stream.next({
1420
1458
  ...invitation,
1421
- state: import_services3.Invitation.State.CONNECTED
1459
+ state: import_services4.Invitation.State.CONNECTED
1422
1460
  });
1423
- const deviceKey = await success.wait({
1461
+ const deviceKey = await extension.completedTrigger.wait({
1424
1462
  timeout
1425
1463
  });
1426
1464
  (0, import_log5.log)("admitted guest", {
@@ -1428,19 +1466,19 @@ var InvitationsHandler = class {
1428
1466
  ...protocol.toJSON()
1429
1467
  }, {
1430
1468
  file: "invitations-handler.ts",
1431
- line: 192,
1469
+ line: 143,
1432
1470
  scope: this,
1433
1471
  callSite: (f, a) => f(...a)
1434
1472
  });
1435
1473
  stream.next({
1436
1474
  ...invitation,
1437
- state: import_services3.Invitation.State.SUCCESS
1475
+ state: import_services4.Invitation.State.SUCCESS
1438
1476
  });
1439
1477
  import_log5.log.trace("dxos.sdk.invitations-handler.host.onOpen", import_protocols4.trace.end({
1440
1478
  id: traceId
1441
1479
  }), {
1442
1480
  file: "invitations-handler.ts",
1443
- line: 194,
1481
+ line: 145,
1444
1482
  scope: this,
1445
1483
  callSite: (f, a) => f(...a)
1446
1484
  });
@@ -1450,18 +1488,18 @@ var InvitationsHandler = class {
1450
1488
  ...protocol.toJSON()
1451
1489
  }, {
1452
1490
  file: "invitations-handler.ts",
1453
- line: 197,
1491
+ line: 148,
1454
1492
  scope: this,
1455
1493
  callSite: (f, a) => f(...a)
1456
1494
  });
1457
1495
  stream.next({
1458
1496
  ...invitation,
1459
- state: import_services3.Invitation.State.TIMEOUT
1497
+ state: import_services4.Invitation.State.TIMEOUT
1460
1498
  });
1461
1499
  } else {
1462
1500
  import_log5.log.error("failed", err, {
1463
1501
  file: "invitations-handler.ts",
1464
- line: 200,
1502
+ line: 151,
1465
1503
  scope: this,
1466
1504
  callSite: (f, a) => f(...a)
1467
1505
  });
@@ -1472,12 +1510,12 @@ var InvitationsHandler = class {
1472
1510
  error: err
1473
1511
  }), {
1474
1512
  file: "invitations-handler.ts",
1475
- line: 203,
1513
+ line: 154,
1476
1514
  scope: this,
1477
1515
  callSite: (f, a) => f(...a)
1478
1516
  });
1479
1517
  } finally {
1480
- if (type !== import_services3.Invitation.Type.MULTIUSE) {
1518
+ if (type !== import_services4.Invitation.Type.MULTIUSE) {
1481
1519
  await (0, import_async9.sleep)(import_client_protocol2.ON_CLOSE_DELAY);
1482
1520
  await ctx.dispose();
1483
1521
  }
@@ -1493,18 +1531,18 @@ var InvitationsHandler = class {
1493
1531
  ...protocol.toJSON()
1494
1532
  }, {
1495
1533
  file: "invitations-handler.ts",
1496
- line: 217,
1534
+ line: 168,
1497
1535
  scope: this,
1498
1536
  callSite: (f, a) => f(...a)
1499
1537
  });
1500
1538
  stream.next({
1501
1539
  ...invitation,
1502
- state: import_services3.Invitation.State.TIMEOUT
1540
+ state: import_services4.Invitation.State.TIMEOUT
1503
1541
  });
1504
1542
  } else {
1505
1543
  import_log5.log.error("failed", err, {
1506
1544
  file: "invitations-handler.ts",
1507
- line: 220,
1545
+ line: 171,
1508
1546
  scope: this,
1509
1547
  callSite: (f, a) => f(...a)
1510
1548
  });
@@ -1527,7 +1565,7 @@ var InvitationsHandler = class {
1527
1565
  ctx.onDispose(() => swarmConnection.close());
1528
1566
  stream.next({
1529
1567
  ...invitation,
1530
- state: import_services3.Invitation.State.CONNECTING
1568
+ state: import_services4.Invitation.State.CONNECTING
1531
1569
  });
1532
1570
  });
1533
1571
  const observable = new import_client_protocol2.CancellableInvitationObservable({
@@ -1536,7 +1574,7 @@ var InvitationsHandler = class {
1536
1574
  onCancel: async () => {
1537
1575
  stream.next({
1538
1576
  ...invitation,
1539
- state: import_services3.Invitation.State.CANCELLED
1577
+ state: import_services4.Invitation.State.CANCELLED
1540
1578
  });
1541
1579
  await ctx.dispose();
1542
1580
  }
@@ -1564,17 +1602,17 @@ var InvitationsHandler = class {
1564
1602
  ...protocol.toJSON()
1565
1603
  }, {
1566
1604
  file: "invitations-handler.ts",
1567
- line: 274,
1605
+ line: 225,
1568
1606
  scope: this,
1569
1607
  callSite: (f, a) => f(...a)
1570
1608
  });
1571
1609
  setState({
1572
- state: import_services3.Invitation.State.TIMEOUT
1610
+ state: import_services4.Invitation.State.TIMEOUT
1573
1611
  });
1574
1612
  } else {
1575
1613
  import_log5.log.warn("auth failed", err, {
1576
1614
  file: "invitations-handler.ts",
1577
- line: 277,
1615
+ line: 228,
1578
1616
  scope: this,
1579
1617
  callSite: (f, a) => f(...a)
1580
1618
  });
@@ -1588,7 +1626,7 @@ var InvitationsHandler = class {
1588
1626
  ...protocol.toJSON()
1589
1627
  }, {
1590
1628
  file: "invitations-handler.ts",
1591
- line: 285,
1629
+ line: 236,
1592
1630
  scope: this,
1593
1631
  callSite: (f, a) => f(...a)
1594
1632
  });
@@ -1603,11 +1641,11 @@ var InvitationsHandler = class {
1603
1641
  currentState
1604
1642
  }, {
1605
1643
  file: "invitations-handler.ts",
1606
- line: 295,
1644
+ line: 246,
1607
1645
  scope: this,
1608
1646
  callSite: (f, a) => f(...a)
1609
1647
  });
1610
- if (currentState !== import_services3.Invitation.State.SUCCESS) {
1648
+ if (currentState !== import_services4.Invitation.State.SUCCESS) {
1611
1649
  stream.error(new Error("Remote peer disconnected."));
1612
1650
  }
1613
1651
  });
@@ -1618,7 +1656,7 @@ var InvitationsHandler = class {
1618
1656
  id: traceId
1619
1657
  }), {
1620
1658
  file: "invitations-handler.ts",
1621
- line: 304,
1659
+ line: 255,
1622
1660
  scope: this,
1623
1661
  callSite: (f, a) => f(...a)
1624
1662
  });
@@ -1630,18 +1668,18 @@ var InvitationsHandler = class {
1630
1668
  ...protocol.toJSON()
1631
1669
  }, {
1632
1670
  file: "invitations-handler.ts",
1633
- line: 312,
1671
+ line: 263,
1634
1672
  scope: this,
1635
1673
  callSite: (f, a) => f(...a)
1636
1674
  });
1637
1675
  setState({
1638
- state: import_services3.Invitation.State.CONNECTED
1676
+ state: import_services4.Invitation.State.CONNECTED
1639
1677
  });
1640
1678
  (0, import_log5.log)("introduce", {
1641
1679
  ...protocol.toJSON()
1642
1680
  }, {
1643
1681
  file: "invitations-handler.ts",
1644
- line: 316,
1682
+ line: 267,
1645
1683
  scope: this,
1646
1684
  callSite: (f, a) => f(...a)
1647
1685
  });
@@ -1651,7 +1689,7 @@ var InvitationsHandler = class {
1651
1689
  response: introductionResponse
1652
1690
  }, {
1653
1691
  file: "invitations-handler.ts",
1654
- line: 320,
1692
+ line: 271,
1655
1693
  scope: this,
1656
1694
  callSite: (f, a) => f(...a)
1657
1695
  });
@@ -1663,24 +1701,24 @@ var InvitationsHandler = class {
1663
1701
  for (let attempt = 1; attempt <= MAX_OTP_ATTEMPTS; attempt++) {
1664
1702
  (0, import_log5.log)("guest waiting for authentication code...", {}, {
1665
1703
  file: "invitations-handler.ts",
1666
- line: 329,
1704
+ line: 280,
1667
1705
  scope: this,
1668
1706
  callSite: (f, a) => f(...a)
1669
1707
  });
1670
1708
  setState({
1671
- state: import_services3.Invitation.State.READY_FOR_AUTHENTICATION
1709
+ state: import_services4.Invitation.State.READY_FOR_AUTHENTICATION
1672
1710
  });
1673
1711
  const authCode = await authenticated.wait({
1674
1712
  timeout
1675
1713
  });
1676
1714
  (0, import_log5.log)("sending authentication request", {}, {
1677
1715
  file: "invitations-handler.ts",
1678
- line: 333,
1716
+ line: 284,
1679
1717
  scope: this,
1680
1718
  callSite: (f, a) => f(...a)
1681
1719
  });
1682
1720
  setState({
1683
- state: import_services3.Invitation.State.AUTHENTICATING
1721
+ state: import_services4.Invitation.State.AUTHENTICATING
1684
1722
  });
1685
1723
  const response = await extension.rpc.InvitationHostService.authenticate({
1686
1724
  authCode
@@ -1696,7 +1734,7 @@ var InvitationsHandler = class {
1696
1734
  attempt
1697
1735
  }, {
1698
1736
  file: "invitations-handler.ts",
1699
- line: 344,
1737
+ line: 295,
1700
1738
  scope: this,
1701
1739
  callSite: (f, a) => f(...a)
1702
1740
  });
@@ -1706,14 +1744,14 @@ var InvitationsHandler = class {
1706
1744
  }
1707
1745
  } else {
1708
1746
  setState({
1709
- state: import_services3.Invitation.State.READY_FOR_AUTHENTICATION
1747
+ state: import_services4.Invitation.State.READY_FOR_AUTHENTICATION
1710
1748
  });
1711
1749
  }
1712
1750
  (0, import_log5.log)("request admission", {
1713
1751
  ...protocol.toJSON()
1714
1752
  }, {
1715
1753
  file: "invitations-handler.ts",
1716
- line: 355,
1754
+ line: 306,
1717
1755
  scope: this,
1718
1756
  callSite: (f, a) => f(...a)
1719
1757
  });
@@ -1724,19 +1762,19 @@ var InvitationsHandler = class {
1724
1762
  ...protocol.toJSON()
1725
1763
  }, {
1726
1764
  file: "invitations-handler.ts",
1727
- line: 363,
1765
+ line: 314,
1728
1766
  scope: this,
1729
1767
  callSite: (f, a) => f(...a)
1730
1768
  });
1731
1769
  setState({
1732
1770
  ...result,
1733
- state: import_services3.Invitation.State.SUCCESS
1771
+ state: import_services4.Invitation.State.SUCCESS
1734
1772
  });
1735
1773
  import_log5.log.trace("dxos.sdk.invitations-handler.guest.onOpen", import_protocols4.trace.end({
1736
1774
  id: traceId
1737
1775
  }), {
1738
1776
  file: "invitations-handler.ts",
1739
- line: 365,
1777
+ line: 316,
1740
1778
  scope: this,
1741
1779
  callSite: (f, a) => f(...a)
1742
1780
  });
@@ -1746,17 +1784,17 @@ var InvitationsHandler = class {
1746
1784
  ...protocol.toJSON()
1747
1785
  }, {
1748
1786
  file: "invitations-handler.ts",
1749
- line: 368,
1787
+ line: 319,
1750
1788
  scope: this,
1751
1789
  callSite: (f, a) => f(...a)
1752
1790
  });
1753
1791
  setState({
1754
- state: import_services3.Invitation.State.TIMEOUT
1792
+ state: import_services4.Invitation.State.TIMEOUT
1755
1793
  });
1756
1794
  } else {
1757
1795
  (0, import_log5.log)("auth failed", err, {
1758
1796
  file: "invitations-handler.ts",
1759
- line: 371,
1797
+ line: 322,
1760
1798
  scope: this,
1761
1799
  callSite: (f, a) => f(...a)
1762
1800
  });
@@ -1767,7 +1805,7 @@ var InvitationsHandler = class {
1767
1805
  error: err
1768
1806
  }), {
1769
1807
  file: "invitations-handler.ts",
1770
- line: 374,
1808
+ line: 325,
1771
1809
  scope: this,
1772
1810
  callSite: (f, a) => f(...a)
1773
1811
  });
@@ -1785,17 +1823,17 @@ var InvitationsHandler = class {
1785
1823
  ...protocol.toJSON()
1786
1824
  }, {
1787
1825
  file: "invitations-handler.ts",
1788
- line: 385,
1826
+ line: 336,
1789
1827
  scope: this,
1790
1828
  callSite: (f, a) => f(...a)
1791
1829
  });
1792
1830
  setState({
1793
- state: import_services3.Invitation.State.TIMEOUT
1831
+ state: import_services4.Invitation.State.TIMEOUT
1794
1832
  });
1795
1833
  } else {
1796
1834
  (0, import_log5.log)("auth failed", err, {
1797
1835
  file: "invitations-handler.ts",
1798
- line: 388,
1836
+ line: 339,
1799
1837
  scope: this,
1800
1838
  callSite: (f, a) => f(...a)
1801
1839
  });
@@ -1818,7 +1856,7 @@ var InvitationsHandler = class {
1818
1856
  });
1819
1857
  ctx.onDispose(() => swarmConnection.close());
1820
1858
  setState({
1821
- state: import_services3.Invitation.State.CONNECTING
1859
+ state: import_services4.Invitation.State.CONNECTING
1822
1860
  });
1823
1861
  });
1824
1862
  const observable = new import_client_protocol2.AuthenticatingInvitationObservable({
@@ -1826,7 +1864,7 @@ var InvitationsHandler = class {
1826
1864
  subscriber: stream.observable,
1827
1865
  onCancel: async () => {
1828
1866
  setState({
1829
- state: import_services3.Invitation.State.CANCELLED
1867
+ state: import_services4.Invitation.State.CANCELLED
1830
1868
  });
1831
1869
  await ctx.dispose();
1832
1870
  },
@@ -1837,14 +1875,13 @@ var InvitationsHandler = class {
1837
1875
  return observable;
1838
1876
  }
1839
1877
  };
1840
- var isAuthenticationRequired = (invitation) => invitation.authMethod !== import_services3.Invitation.AuthMethod.NONE;
1841
1878
 
1842
1879
  // packages/sdk/client-services/src/packlets/invitations/invitations-service.ts
1843
1880
  var import_node_assert7 = __toESM(require("node:assert"));
1844
1881
  var import_async10 = require("@dxos/async");
1845
1882
  var import_codec_protobuf8 = require("@dxos/codec-protobuf");
1846
1883
  var import_log6 = require("@dxos/log");
1847
- var import_services4 = require("@dxos/protocols/proto/dxos/client/services");
1884
+ var import_services5 = require("@dxos/protocols/proto/dxos/client/services");
1848
1885
  var InvitationsServiceImpl = class {
1849
1886
  constructor(_invitationsHandler, _getHandler) {
1850
1887
  this._invitationsHandler = _invitationsHandler;
@@ -1959,8 +1996,8 @@ var InvitationsServiceImpl = class {
1959
1996
  return new import_codec_protobuf8.Stream(({ next, ctx }) => {
1960
1997
  this._invitationCreated.on(ctx, (invitation) => {
1961
1998
  next({
1962
- action: import_services4.QueryInvitationsResponse.Action.ADDED,
1963
- type: import_services4.QueryInvitationsResponse.Type.CREATED,
1999
+ action: import_services5.QueryInvitationsResponse.Action.ADDED,
2000
+ type: import_services5.QueryInvitationsResponse.Type.CREATED,
1964
2001
  invitations: [
1965
2002
  invitation
1966
2003
  ]
@@ -1968,8 +2005,8 @@ var InvitationsServiceImpl = class {
1968
2005
  });
1969
2006
  this._invitationAccepted.on(ctx, (invitation) => {
1970
2007
  next({
1971
- action: import_services4.QueryInvitationsResponse.Action.ADDED,
1972
- type: import_services4.QueryInvitationsResponse.Type.ACCEPTED,
2008
+ action: import_services5.QueryInvitationsResponse.Action.ADDED,
2009
+ type: import_services5.QueryInvitationsResponse.Type.ACCEPTED,
1973
2010
  invitations: [
1974
2011
  invitation
1975
2012
  ]
@@ -1977,8 +2014,8 @@ var InvitationsServiceImpl = class {
1977
2014
  });
1978
2015
  this._removedCreated.on(ctx, (invitation) => {
1979
2016
  next({
1980
- action: import_services4.QueryInvitationsResponse.Action.REMOVED,
1981
- type: import_services4.QueryInvitationsResponse.Type.CREATED,
2017
+ action: import_services5.QueryInvitationsResponse.Action.REMOVED,
2018
+ type: import_services5.QueryInvitationsResponse.Type.CREATED,
1982
2019
  invitations: [
1983
2020
  invitation
1984
2021
  ]
@@ -1986,21 +2023,21 @@ var InvitationsServiceImpl = class {
1986
2023
  });
1987
2024
  this._removedAccepted.on(ctx, (invitation) => {
1988
2025
  next({
1989
- action: import_services4.QueryInvitationsResponse.Action.REMOVED,
1990
- type: import_services4.QueryInvitationsResponse.Type.ACCEPTED,
2026
+ action: import_services5.QueryInvitationsResponse.Action.REMOVED,
2027
+ type: import_services5.QueryInvitationsResponse.Type.ACCEPTED,
1991
2028
  invitations: [
1992
2029
  invitation
1993
2030
  ]
1994
2031
  });
1995
2032
  });
1996
2033
  next({
1997
- action: import_services4.QueryInvitationsResponse.Action.ADDED,
1998
- type: import_services4.QueryInvitationsResponse.Type.CREATED,
2034
+ action: import_services5.QueryInvitationsResponse.Action.ADDED,
2035
+ type: import_services5.QueryInvitationsResponse.Type.CREATED,
1999
2036
  invitations: Array.from(this._createInvitations.values()).map((invitation) => invitation.get())
2000
2037
  });
2001
2038
  next({
2002
- action: import_services4.QueryInvitationsResponse.Action.ADDED,
2003
- type: import_services4.QueryInvitationsResponse.Type.ACCEPTED,
2039
+ action: import_services5.QueryInvitationsResponse.Action.ADDED,
2040
+ type: import_services5.QueryInvitationsResponse.Type.ACCEPTED,
2004
2041
  invitations: Array.from(this._acceptInvitations.values()).map((invitation) => invitation.get())
2005
2042
  });
2006
2043
  });
@@ -2012,7 +2049,7 @@ var import_node_assert8 = __toESM(require("node:assert"));
2012
2049
  var import_credentials9 = require("@dxos/credentials");
2013
2050
  var import_feed_store3 = require("@dxos/feed-store");
2014
2051
  var import_log7 = require("@dxos/log");
2015
- var import_services5 = require("@dxos/protocols/proto/dxos/client/services");
2052
+ var import_services6 = require("@dxos/protocols/proto/dxos/client/services");
2016
2053
  var SpaceInvitationProtocol = class {
2017
2054
  constructor(_spaceManager, _signingContext, _keyring, _spaceKey) {
2018
2055
  this._spaceManager = _spaceManager;
@@ -2028,7 +2065,7 @@ var SpaceInvitationProtocol = class {
2028
2065
  }
2029
2066
  getInvitationContext() {
2030
2067
  return {
2031
- kind: import_services5.Invitation.Kind.SPACE,
2068
+ kind: import_services6.Invitation.Kind.SPACE,
2032
2069
  spaceKey: this._spaceKey
2033
2070
  };
2034
2071
  }
@@ -2200,7 +2237,7 @@ var import_credentials13 = require("@dxos/credentials");
2200
2237
  var import_keys10 = require("@dxos/keys");
2201
2238
  var import_log11 = require("@dxos/log");
2202
2239
  var import_protocols6 = require("@dxos/protocols");
2203
- var import_services7 = require("@dxos/protocols/proto/dxos/client/services");
2240
+ var import_services8 = require("@dxos/protocols/proto/dxos/client/services");
2204
2241
  var import_teleport_extension_gossip = require("@dxos/teleport-extension-gossip");
2205
2242
  var import_util5 = require("@dxos/util");
2206
2243
 
@@ -2213,7 +2250,7 @@ var import_echo_pipeline = require("@dxos/echo-pipeline");
2213
2250
  var import_errors3 = require("@dxos/errors");
2214
2251
  var import_keys9 = require("@dxos/keys");
2215
2252
  var import_log10 = require("@dxos/log");
2216
- var import_services6 = require("@dxos/protocols/proto/dxos/client/services");
2253
+ var import_services7 = require("@dxos/protocols/proto/dxos/client/services");
2217
2254
  var import_credentials10 = require("@dxos/protocols/proto/dxos/halo/credentials");
2218
2255
  var import_util4 = require("@dxos/util");
2219
2256
 
@@ -2470,7 +2507,7 @@ var __decorate = function(decorators, target, key, desc) {
2470
2507
  var DataSpace = class DataSpace2 {
2471
2508
  constructor(params) {
2472
2509
  this._ctx = new import_context6.Context();
2473
- this._state = import_services6.SpaceState.CLOSED;
2510
+ this._state = import_services7.SpaceState.CLOSED;
2474
2511
  /**
2475
2512
  * Error for _state === SpaceState.ERROR.
2476
2513
  */
@@ -2524,11 +2561,11 @@ var DataSpace = class DataSpace2 {
2524
2561
  await this.notarizationPlugin.open();
2525
2562
  await this._notarizationPluginConsumer.open();
2526
2563
  await this._inner.open();
2527
- this._state = import_services6.SpaceState.INACTIVE;
2564
+ this._state = import_services7.SpaceState.INACTIVE;
2528
2565
  this.metrics.open = new Date();
2529
2566
  }
2530
2567
  async close() {
2531
- this._state = import_services6.SpaceState.CLOSED;
2568
+ this._state = import_services7.SpaceState.CLOSED;
2532
2569
  await this._ctx.dispose();
2533
2570
  await this.authVerifier.close();
2534
2571
  await this._inner.close();
@@ -2566,7 +2603,7 @@ var DataSpace = class DataSpace2 {
2566
2603
  scope: this,
2567
2604
  callSite: (f, a) => f(...a)
2568
2605
  });
2569
- this._state = import_services6.SpaceState.ERROR;
2606
+ this._state = import_services7.SpaceState.ERROR;
2570
2607
  this.error = err;
2571
2608
  this.stateUpdate.emit();
2572
2609
  } finally {
@@ -2576,10 +2613,10 @@ var DataSpace = class DataSpace2 {
2576
2613
  }
2577
2614
  async initializeDataPipeline() {
2578
2615
  var _a, _b, _c, _d;
2579
- if (this._state !== import_services6.SpaceState.INACTIVE) {
2616
+ if (this._state !== import_services7.SpaceState.INACTIVE) {
2580
2617
  throw new import_errors3.SystemError("Invalid operation");
2581
2618
  }
2582
- this._state = import_services6.SpaceState.INITIALIZING;
2619
+ this._state = import_services7.SpaceState.INITIALIZING;
2583
2620
  await this._inner.controlPipeline.state.waitUntilReachedTargetTimeframe({
2584
2621
  ctx: this._ctx,
2585
2622
  breakOnStall: false
@@ -2619,7 +2656,7 @@ var DataSpace = class DataSpace2 {
2619
2656
  callSite: (f, a) => f(...a)
2620
2657
  });
2621
2658
  await ((_b = (_a = this._callbacks).beforeReady) == null ? void 0 : _b.call(_a));
2622
- this._state = import_services6.SpaceState.READY;
2659
+ this._state = import_services7.SpaceState.READY;
2623
2660
  this.stateUpdate.emit();
2624
2661
  await ((_d = (_c = this._callbacks).afterReady) == null ? void 0 : _d.call(_c));
2625
2662
  }
@@ -2930,7 +2967,7 @@ var DataSpaceManager = class DataSpaceManager2 {
2930
2967
  async waitUntilSpaceReady(spaceKey) {
2931
2968
  await (0, import_context7.cancelWithContext)(this._ctx, this.updated.waitForCondition(() => {
2932
2969
  const space = this._spaces.get(spaceKey);
2933
- return !!space && space.state === import_services7.SpaceState.READY;
2970
+ return !!space && space.state === import_services8.SpaceState.READY;
2934
2971
  }));
2935
2972
  }
2936
2973
  async _constructSpace(metadata) {
@@ -2971,6 +3008,14 @@ var DataSpaceManager = class DataSpaceManager2 {
2971
3008
  session.addExtension("dxos.mesh.teleport.objectsync", space.snapshotManager.objectSync.createExtension());
2972
3009
  session.addExtension("dxos.mesh.teleport.notarization", dataSpace.notarizationPlugin.createExtension());
2973
3010
  },
3011
+ onAuthFailure: () => {
3012
+ import_log11.log.warn("auth failure", {}, {
3013
+ file: "data-space-manager.ts",
3014
+ line: 212,
3015
+ scope: this,
3016
+ callSite: (f, a) => f(...a)
3017
+ });
3018
+ },
2974
3019
  memberKey: this._signingContext.identityKey
2975
3020
  });
2976
3021
  controlFeed && space.setControlFeed(controlFeed);
@@ -2989,7 +3034,7 @@ var DataSpaceManager = class DataSpaceManager2 {
2989
3034
  space: space.key
2990
3035
  }, {
2991
3036
  file: "data-space-manager.ts",
2992
- line: 226,
3037
+ line: 229,
2993
3038
  scope: this,
2994
3039
  callSite: (f, a) => f(...a)
2995
3040
  });
@@ -3001,7 +3046,7 @@ var DataSpaceManager = class DataSpaceManager2 {
3001
3046
  open: this._isOpen
3002
3047
  }, {
3003
3048
  file: "data-space-manager.ts",
3004
- line: 233,
3049
+ line: 236,
3005
3050
  scope: this,
3006
3051
  callSite: (f, a) => f(...a)
3007
3052
  });
@@ -3046,7 +3091,7 @@ var import_debug5 = require("@dxos/debug");
3046
3091
  var import_echo_pipeline2 = require("@dxos/echo-pipeline");
3047
3092
  var import_log12 = require("@dxos/log");
3048
3093
  var import_protocols7 = require("@dxos/protocols");
3049
- var import_services8 = require("@dxos/protocols/proto/dxos/client/services");
3094
+ var import_services9 = require("@dxos/protocols/proto/dxos/client/services");
3050
3095
  var import_util6 = require("@dxos/util");
3051
3096
  var TIMEFRAME_UPDATE_DEBOUNCE_TIME = 500;
3052
3097
  var SpacesServiceImpl = class {
@@ -3187,7 +3232,7 @@ var SpacesServiceImpl = class {
3187
3232
  displayName: (_b2 = (_a2 = member.assertion.profile) == null ? void 0 : _a2.displayName) != null ? _b2 : (0, import_util6.humanize)(member.key)
3188
3233
  }
3189
3234
  },
3190
- 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
3235
+ 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
3191
3236
  };
3192
3237
  }),
3193
3238
  cache: space.cache,
@@ -3818,7 +3863,7 @@ var import_keyring = require("@dxos/keyring");
3818
3863
  var import_keys11 = require("@dxos/keys");
3819
3864
  var import_log18 = require("@dxos/log");
3820
3865
  var import_protocols8 = require("@dxos/protocols");
3821
- var import_services11 = require("@dxos/protocols/proto/dxos/client/services");
3866
+ var import_services12 = require("@dxos/protocols/proto/dxos/client/services");
3822
3867
  var ServiceContext = class {
3823
3868
  // prettier-ignore
3824
3869
  constructor(storage, networkManager, signalManager, modelFactory) {
@@ -3851,7 +3896,7 @@ var ServiceContext = class {
3851
3896
  });
3852
3897
  this.identityManager = new IdentityManager(this.metadataStore, this.keyring, this.feedStore, this.spaceManager);
3853
3898
  this.invitations = new InvitationsHandler(this.networkManager);
3854
- this._handlerFactories.set(import_services11.Invitation.Kind.DEVICE, () => new DeviceInvitationProtocol(this.keyring, () => {
3899
+ this._handlerFactories.set(import_services12.Invitation.Kind.DEVICE, () => new DeviceInvitationProtocol(this.keyring, () => {
3855
3900
  var _a;
3856
3901
  return (_a = this.identityManager.identity) != null ? _a : (0, import_debug7.failUndefined)();
3857
3902
  }, this._acceptIdentity.bind(this)));
@@ -3972,7 +4017,7 @@ var ServiceContext = class {
3972
4017
  };
3973
4018
  this.dataSpaceManager = new DataSpaceManager(this.spaceManager, this.metadataStore, this.dataServiceSubscriptions, this.keyring, signingContext, this.feedStore);
3974
4019
  await this.dataSpaceManager.open();
3975
- this._handlerFactories.set(import_services11.Invitation.Kind.SPACE, (invitation) => {
4020
+ this._handlerFactories.set(import_services12.Invitation.Kind.SPACE, (invitation) => {
3976
4021
  (0, import_node_assert13.default)(this.dataSpaceManager, "dataSpaceManager not initialized yet");
3977
4022
  return new SpaceInvitationProtocol(this.dataSpaceManager, signingContext, this.keyring, invitation.spaceKey);
3978
4023
  });
@@ -4096,12 +4141,12 @@ var ClientServicesHost = class {
4096
4141
  this._systemService = new SystemServiceImpl({
4097
4142
  config: this._config,
4098
4143
  statusUpdate: this._statusUpdate,
4099
- getCurrentStatus: () => this.isOpen ? import_services12.SystemStatus.ACTIVE : import_services12.SystemStatus.INACTIVE,
4144
+ getCurrentStatus: () => this.isOpen ? import_services13.SystemStatus.ACTIVE : import_services13.SystemStatus.INACTIVE,
4100
4145
  onUpdateStatus: async (status) => {
4101
4146
  var _a, _b;
4102
- if (!this.isOpen && status === import_services12.SystemStatus.ACTIVE) {
4147
+ if (!this.isOpen && status === import_services13.SystemStatus.ACTIVE) {
4103
4148
  await ((_a = this._resourceLock) == null ? void 0 : _a.acquire());
4104
- } else if (this.isOpen && status === import_services12.SystemStatus.INACTIVE) {
4149
+ } else if (this.isOpen && status === import_services13.SystemStatus.INACTIVE) {
4105
4150
  await ((_b = this._resourceLock) == null ? void 0 : _b.release());
4106
4151
  }
4107
4152
  },
@@ -4331,7 +4376,7 @@ var performInvitation = ({ host, guest, options, hooks }) => {
4331
4376
  hostObservable.subscribe(async (hostInvitation) => {
4332
4377
  var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
4333
4378
  switch (hostInvitation.state) {
4334
- case import_services13.Invitation.State.CONNECTING: {
4379
+ case import_services14.Invitation.State.CONNECTING: {
4335
4380
  if ((_b = (_a = hooks == null ? void 0 : hooks.host) == null ? void 0 : _a.onConnecting) == null ? void 0 : _b.call(_a, hostObservable)) {
4336
4381
  break;
4337
4382
  }
@@ -4339,29 +4384,29 @@ var performInvitation = ({ host, guest, options, hooks }) => {
4339
4384
  guestObservable.subscribe(async (guestInvitation) => {
4340
4385
  var _a2, _b2, _c2, _d2, _e2, _f2, _g2, _h2, _i2, _j2, _k2, _l2, _m2, _n2;
4341
4386
  switch (guestInvitation.state) {
4342
- case import_services13.Invitation.State.CONNECTING: {
4387
+ case import_services14.Invitation.State.CONNECTING: {
4343
4388
  if ((_b2 = (_a2 = hooks == null ? void 0 : hooks.guest) == null ? void 0 : _a2.onConnecting) == null ? void 0 : _b2.call(_a2, guestObservable)) {
4344
4389
  break;
4345
4390
  }
4346
4391
  (0, import_node_assert15.default)(hostInvitation.swarmKey.equals(guestInvitation.swarmKey));
4347
4392
  break;
4348
4393
  }
4349
- case import_services13.Invitation.State.CONNECTED: {
4394
+ case import_services14.Invitation.State.CONNECTED: {
4350
4395
  (_d2 = (_c2 = hooks == null ? void 0 : hooks.guest) == null ? void 0 : _c2.onConnected) == null ? void 0 : _d2.call(_c2, guestObservable);
4351
4396
  break;
4352
4397
  }
4353
- case import_services13.Invitation.State.READY_FOR_AUTHENTICATION: {
4398
+ case import_services14.Invitation.State.READY_FOR_AUTHENTICATION: {
4354
4399
  if ((_f2 = (_e2 = hooks == null ? void 0 : hooks.guest) == null ? void 0 : _e2.onReady) == null ? void 0 : _f2.call(_e2, guestObservable)) {
4355
4400
  break;
4356
4401
  }
4357
4402
  await guestObservable.authenticate(await authCode.wait());
4358
4403
  break;
4359
4404
  }
4360
- case import_services13.Invitation.State.AUTHENTICATING: {
4405
+ case import_services14.Invitation.State.AUTHENTICATING: {
4361
4406
  (_h2 = (_g2 = hooks == null ? void 0 : hooks.guest) == null ? void 0 : _g2.onAuthenticating) == null ? void 0 : _h2.call(_g2, guestObservable);
4362
4407
  break;
4363
4408
  }
4364
- case import_services13.Invitation.State.SUCCESS: {
4409
+ case import_services14.Invitation.State.SUCCESS: {
4365
4410
  if ((_j2 = (_i2 = hooks == null ? void 0 : hooks.guest) == null ? void 0 : _i2.onSuccess) == null ? void 0 : _j2.call(_i2, guestObservable)) {
4366
4411
  break;
4367
4412
  }
@@ -4370,7 +4415,7 @@ var performInvitation = ({ host, guest, options, hooks }) => {
4370
4415
  });
4371
4416
  break;
4372
4417
  }
4373
- case import_services13.Invitation.State.CANCELLED: {
4418
+ case import_services14.Invitation.State.CANCELLED: {
4374
4419
  if ((_l2 = (_k2 = hooks == null ? void 0 : hooks.guest) == null ? void 0 : _k2.onCancelled) == null ? void 0 : _l2.call(_k2, guestObservable)) {
4375
4420
  break;
4376
4421
  }
@@ -4379,7 +4424,7 @@ var performInvitation = ({ host, guest, options, hooks }) => {
4379
4424
  });
4380
4425
  break;
4381
4426
  }
4382
- case import_services13.Invitation.State.TIMEOUT: {
4427
+ case import_services14.Invitation.State.TIMEOUT: {
4383
4428
  if ((_n2 = (_m2 = hooks == null ? void 0 : hooks.guest) == null ? void 0 : _m2.onTimeout) == null ? void 0 : _n2.call(_m2, guestObservable)) {
4384
4429
  return;
4385
4430
  }
@@ -4399,11 +4444,11 @@ var performInvitation = ({ host, guest, options, hooks }) => {
4399
4444
  });
4400
4445
  break;
4401
4446
  }
4402
- case import_services13.Invitation.State.CONNECTED: {
4447
+ case import_services14.Invitation.State.CONNECTED: {
4403
4448
  (_d = (_c = hooks == null ? void 0 : hooks.host) == null ? void 0 : _c.onConnected) == null ? void 0 : _d.call(_c, hostObservable);
4404
4449
  break;
4405
4450
  }
4406
- case import_services13.Invitation.State.READY_FOR_AUTHENTICATION: {
4451
+ case import_services14.Invitation.State.READY_FOR_AUTHENTICATION: {
4407
4452
  if ((_f = (_e = hooks == null ? void 0 : hooks.host) == null ? void 0 : _e.onReady) == null ? void 0 : _f.call(_e, hostObservable)) {
4408
4453
  break;
4409
4454
  }
@@ -4412,11 +4457,11 @@ var performInvitation = ({ host, guest, options, hooks }) => {
4412
4457
  }
4413
4458
  break;
4414
4459
  }
4415
- case import_services13.Invitation.State.AUTHENTICATING: {
4460
+ case import_services14.Invitation.State.AUTHENTICATING: {
4416
4461
  (_h = (_g = hooks == null ? void 0 : hooks.host) == null ? void 0 : _g.onAuthenticating) == null ? void 0 : _h.call(_g, hostObservable);
4417
4462
  break;
4418
4463
  }
4419
- case import_services13.Invitation.State.SUCCESS: {
4464
+ case import_services14.Invitation.State.SUCCESS: {
4420
4465
  if ((_j = (_i = hooks == null ? void 0 : hooks.host) == null ? void 0 : _i.onSuccess) == null ? void 0 : _j.call(_i, hostObservable)) {
4421
4466
  break;
4422
4467
  }
@@ -4425,7 +4470,7 @@ var performInvitation = ({ host, guest, options, hooks }) => {
4425
4470
  });
4426
4471
  break;
4427
4472
  }
4428
- case import_services13.Invitation.State.CANCELLED: {
4473
+ case import_services14.Invitation.State.CANCELLED: {
4429
4474
  if ((_l = (_k = hooks == null ? void 0 : hooks.host) == null ? void 0 : _k.onCancelled) == null ? void 0 : _l.call(_k, hostObservable)) {
4430
4475
  break;
4431
4476
  }
@@ -4434,7 +4479,7 @@ var performInvitation = ({ host, guest, options, hooks }) => {
4434
4479
  });
4435
4480
  break;
4436
4481
  }
4437
- case import_services13.Invitation.State.TIMEOUT: {
4482
+ case import_services14.Invitation.State.TIMEOUT: {
4438
4483
  if ((_n = (_m = hooks == null ? void 0 : hooks.host) == null ? void 0 : _m.onTimeout) == null ? void 0 : _n.call(_m, hostObservable)) {
4439
4484
  break;
4440
4485
  }
@@ -4460,12 +4505,12 @@ var performInvitation = ({ host, guest, options, hooks }) => {
4460
4505
  };
4461
4506
  var createInvitation = (host, options) => {
4462
4507
  options != null ? options : options = {
4463
- authMethod: import_services13.Invitation.AuthMethod.NONE,
4508
+ authMethod: import_services14.Invitation.AuthMethod.NONE,
4464
4509
  ...options != null ? options : {}
4465
4510
  };
4466
4511
  if (host instanceof ServiceContext) {
4467
4512
  const hostHandler = host.getInvitationHandler({
4468
- kind: import_services13.Invitation.Kind.SPACE,
4513
+ kind: import_services14.Invitation.Kind.SPACE,
4469
4514
  ...options
4470
4515
  });
4471
4516
  return host.invitations.createInvitation(hostHandler, options);