@dxos/client-services 0.6.14-staging.e15392e → 0.7.0

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.
Files changed (50) hide show
  1. package/dist/lib/browser/{chunk-UNN7JEOU.mjs → chunk-GP5GD22Z.mjs} +169 -142
  2. package/dist/lib/browser/chunk-GP5GD22Z.mjs.map +7 -0
  3. package/dist/lib/browser/index.mjs +1 -1
  4. package/dist/lib/browser/meta.json +1 -1
  5. package/dist/lib/browser/testing/index.mjs +9 -2
  6. package/dist/lib/browser/testing/index.mjs.map +3 -3
  7. package/dist/lib/node/{chunk-4BJB67XI.cjs → chunk-3ERQHVZE.cjs} +177 -150
  8. package/dist/lib/node/chunk-3ERQHVZE.cjs.map +7 -0
  9. package/dist/lib/node/index.cjs +47 -47
  10. package/dist/lib/node/meta.json +1 -1
  11. package/dist/lib/node/testing/index.cjs +16 -9
  12. package/dist/lib/node/testing/index.cjs.map +3 -3
  13. package/dist/lib/node-esm/{chunk-Z3GXONTZ.mjs → chunk-UTJ4HL4J.mjs} +169 -142
  14. package/dist/lib/node-esm/chunk-UTJ4HL4J.mjs.map +7 -0
  15. package/dist/lib/node-esm/index.mjs +1 -1
  16. package/dist/lib/node-esm/meta.json +1 -1
  17. package/dist/lib/node-esm/testing/index.mjs +9 -2
  18. package/dist/lib/node-esm/testing/index.mjs.map +3 -3
  19. package/dist/types/src/packlets/devices/devices-service.d.ts +3 -1
  20. package/dist/types/src/packlets/devices/devices-service.d.ts.map +1 -1
  21. package/dist/types/src/packlets/invitations/edge-invitation-handler.d.ts +1 -0
  22. package/dist/types/src/packlets/invitations/edge-invitation-handler.d.ts.map +1 -1
  23. package/dist/types/src/packlets/invitations/invitation-host-extension.d.ts.map +1 -1
  24. package/dist/types/src/packlets/invitations/invitations-handler.d.ts.map +1 -1
  25. package/dist/types/src/packlets/invitations/invitations-manager.d.ts.map +1 -1
  26. package/dist/types/src/packlets/invitations/invitations-service.d.ts.map +1 -1
  27. package/dist/types/src/packlets/spaces/edge-feed-replicator.d.ts +1 -0
  28. package/dist/types/src/packlets/spaces/edge-feed-replicator.d.ts.map +1 -1
  29. package/dist/types/src/packlets/testing/invitation-utils.d.ts.map +1 -1
  30. package/dist/types/src/version.d.ts +1 -1
  31. package/dist/types/src/version.d.ts.map +1 -1
  32. package/package.json +38 -38
  33. package/src/packlets/devices/devices-service.ts +18 -7
  34. package/src/packlets/identity/identity.test.ts +16 -5
  35. package/src/packlets/invitations/edge-invitation-handler.ts +6 -3
  36. package/src/packlets/invitations/invitation-guest-extenstion.ts +5 -5
  37. package/src/packlets/invitations/invitation-host-extension.ts +7 -10
  38. package/src/packlets/invitations/invitations-handler.test.ts +3 -6
  39. package/src/packlets/invitations/invitations-handler.ts +34 -28
  40. package/src/packlets/invitations/invitations-manager.ts +5 -3
  41. package/src/packlets/invitations/invitations-service.ts +5 -1
  42. package/src/packlets/services/service-context.ts +2 -2
  43. package/src/packlets/services/service-host.ts +1 -1
  44. package/src/packlets/spaces/edge-feed-replicator.test.ts +12 -7
  45. package/src/packlets/spaces/edge-feed-replicator.ts +9 -5
  46. package/src/packlets/testing/invitation-utils.ts +7 -0
  47. package/src/version.ts +5 -1
  48. package/dist/lib/browser/chunk-UNN7JEOU.mjs.map +0 -7
  49. package/dist/lib/node/chunk-4BJB67XI.cjs.map +0 -7
  50. package/dist/lib/node-esm/chunk-Z3GXONTZ.mjs.map +0 -7
@@ -26,8 +26,8 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
26
26
  mod
27
27
  ));
28
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
- var chunk_4BJB67XI_exports = {};
30
- __export(chunk_4BJB67XI_exports, {
29
+ var chunk_3ERQHVZE_exports = {};
30
+ __export(chunk_3ERQHVZE_exports, {
31
31
  ClientRpcServer: () => ClientRpcServer,
32
32
  ClientServicesHost: () => ClientServicesHost,
33
33
  DataSpace: () => DataSpace,
@@ -72,7 +72,7 @@ __export(chunk_4BJB67XI_exports, {
72
72
  subscribeToSpaces: () => subscribeToSpaces,
73
73
  subscribeToSwarmInfo: () => subscribeToSwarmInfo
74
74
  });
75
- module.exports = __toCommonJS(chunk_4BJB67XI_exports);
75
+ module.exports = __toCommonJS(chunk_3ERQHVZE_exports);
76
76
  var import_async = require("@dxos/async");
77
77
  var import_codec_protobuf = require("@dxos/codec-protobuf");
78
78
  var import_feed_store = require("@dxos/feed-store");
@@ -277,6 +277,7 @@ var import_invitations5 = require("@dxos/protocols/proto/dxos/halo/invitations")
277
277
  var import_util11 = require("@dxos/util");
278
278
  var import_codec_protobuf10 = require("@dxos/codec-protobuf");
279
279
  var import_services16 = require("@dxos/protocols/proto/dxos/client/services");
280
+ var import_tracing9 = require("@dxos/tracing");
280
281
  var import_credentials18 = require("@dxos/credentials");
281
282
  var import_feed_store5 = require("@dxos/feed-store");
282
283
  var import_invariant17 = require("@dxos/invariant");
@@ -300,7 +301,7 @@ var import_log21 = require("@dxos/log");
300
301
  var import_codec_protobuf11 = require("@dxos/codec-protobuf");
301
302
  var import_debug4 = require("@dxos/debug");
302
303
  var import_rpc = require("@dxos/rpc");
303
- var import_tracing9 = require("@dxos/tracing");
304
+ var import_tracing10 = require("@dxos/tracing");
304
305
  var import_async21 = require("@dxos/async");
305
306
  var import_context15 = require("@dxos/context");
306
307
  var import_invariant20 = require("@dxos/invariant");
@@ -325,7 +326,7 @@ var import_log23 = require("@dxos/log");
325
326
  var import_protocols16 = require("@dxos/protocols");
326
327
  var import_services21 = require("@dxos/protocols/proto/dxos/client/services");
327
328
  var import_teleport_extension_object_sync = require("@dxos/teleport-extension-object-sync");
328
- var import_tracing10 = require("@dxos/tracing");
329
+ var import_tracing11 = require("@dxos/tracing");
329
330
  var import_util12 = require("@dxos/util");
330
331
  var import_credentials23 = require("@dxos/credentials");
331
332
  var import_crypto4 = require("@dxos/crypto");
@@ -360,7 +361,7 @@ var import_messaging = require("@dxos/messaging");
360
361
  var import_network_manager2 = require("@dxos/network-manager");
361
362
  var import_protocols20 = require("@dxos/protocols");
362
363
  var import_services22 = require("@dxos/protocols/proto/dxos/client/services");
363
- var import_tracing11 = require("@dxos/tracing");
364
+ var import_tracing12 = require("@dxos/tracing");
364
365
  var import_websocket_rpc = require("@dxos/websocket-rpc");
365
366
  var import_async24 = require("@dxos/async");
366
367
  var import_codec_protobuf13 = require("@dxos/codec-protobuf");
@@ -738,7 +739,7 @@ var DevtoolsServiceImpl = class {
738
739
  });
739
740
  }
740
741
  };
741
- var DXOS_VERSION = "0.6.14-staging.e15392e";
742
+ var DXOS_VERSION = "0.7.0";
742
743
  var getPlatform = () => {
743
744
  if (process.browser) {
744
745
  if (typeof window !== "undefined") {
@@ -1132,7 +1133,7 @@ var EdgeFeedReplicator = class extends import_context3.Resource {
1132
1133
  S: this,
1133
1134
  C: (f, a) => f(...a)
1134
1135
  });
1135
- this._ctx.onDispose(this._messenger.addListener((message) => {
1136
+ this._ctx.onDispose(this._messenger.onMessage((message) => {
1136
1137
  if (!message.serviceId) {
1137
1138
  return;
1138
1139
  }
@@ -1166,10 +1167,12 @@ var EdgeFeedReplicator = class extends import_context3.Resource {
1166
1167
  });
1167
1168
  this._onMessage(payload);
1168
1169
  }));
1169
- this._messenger.connected.on(this._ctx, async () => {
1170
- await this._resetConnection();
1171
- this._startReplication();
1172
- });
1170
+ this._ctx.onDispose(this._messenger.onReconnected(() => {
1171
+ (0, import_async6.scheduleMicroTask)(this._ctx, () => this._handleReconnect());
1172
+ }));
1173
+ }
1174
+ async _handleReconnect() {
1175
+ await this._resetConnection();
1173
1176
  if (this._messenger.isConnected) {
1174
1177
  this._startReplication();
1175
1178
  }
@@ -1177,7 +1180,7 @@ var EdgeFeedReplicator = class extends import_context3.Resource {
1177
1180
  async _close() {
1178
1181
  (0, import_log3.log)("close", void 0, {
1179
1182
  F: __dxlog_file5,
1180
- L: 91,
1183
+ L: 95,
1181
1184
  S: this,
1182
1185
  C: (f, a) => f(...a)
1183
1186
  });
@@ -1189,7 +1192,7 @@ var EdgeFeedReplicator = class extends import_context3.Resource {
1189
1192
  this._connectionCtx = connectionCtx;
1190
1193
  (0, import_log3.log)("connection context created", void 0, {
1191
1194
  F: __dxlog_file5,
1192
- L: 99,
1195
+ L: 103,
1193
1196
  S: this,
1194
1197
  C: (f, a) => f(...a)
1195
1198
  });
@@ -1202,7 +1205,7 @@ var EdgeFeedReplicator = class extends import_context3.Resource {
1202
1205
  async _resetConnection() {
1203
1206
  (0, import_log3.log)("resetConnection", void 0, {
1204
1207
  F: __dxlog_file5,
1205
- L: 108,
1208
+ L: 112,
1206
1209
  S: this,
1207
1210
  C: (f, a) => f(...a)
1208
1211
  });
@@ -1218,7 +1221,7 @@ var EdgeFeedReplicator = class extends import_context3.Resource {
1218
1221
  hasConnectionCtx: !!this._connectionCtx
1219
1222
  }, {
1220
1223
  F: __dxlog_file5,
1221
- L: 116,
1224
+ L: 120,
1222
1225
  S: this,
1223
1226
  C: (f, a) => f(...a)
1224
1227
  });
@@ -1235,7 +1238,7 @@ var EdgeFeedReplicator = class extends import_context3.Resource {
1235
1238
  key: feed.key
1236
1239
  }, {
1237
1240
  F: __dxlog_file5,
1238
- L: 129,
1241
+ L: 133,
1239
1242
  S: this,
1240
1243
  C: (f, a) => f(...a)
1241
1244
  });
@@ -1251,7 +1254,7 @@ var EdgeFeedReplicator = class extends import_context3.Resource {
1251
1254
  if (!this._connectionCtx) {
1252
1255
  import_log3.log.info("message dropped because connection was disposed", void 0, {
1253
1256
  F: __dxlog_file5,
1254
- L: 142,
1257
+ L: 146,
1255
1258
  S: this,
1256
1259
  C: (f, a) => f(...a)
1257
1260
  });
@@ -1265,13 +1268,13 @@ var EdgeFeedReplicator = class extends import_context3.Resource {
1265
1268
  };
1266
1269
  import_log3.log.info("sending message", logPayload, {
1267
1270
  F: __dxlog_file5,
1268
- L: 148,
1271
+ L: 152,
1269
1272
  S: this,
1270
1273
  C: (f, a) => f(...a)
1271
1274
  });
1272
1275
  (0, import_invariant2.invariant)(message.feedKey, void 0, {
1273
1276
  F: __dxlog_file5,
1274
- L: 150,
1277
+ L: 154,
1275
1278
  S: this,
1276
1279
  A: [
1277
1280
  "message.feedKey",
@@ -1283,7 +1286,7 @@ var EdgeFeedReplicator = class extends import_context3.Resource {
1283
1286
  type: message.type
1284
1287
  }, {
1285
1288
  F: __dxlog_file5,
1286
- L: 153,
1289
+ L: 157,
1287
1290
  S: this,
1288
1291
  C: (f, a) => f(...a)
1289
1292
  });
@@ -1302,7 +1305,7 @@ var EdgeFeedReplicator = class extends import_context3.Resource {
1302
1305
  if (!this._connectionCtx) {
1303
1306
  import_log3.log.warn("received message after connection context was disposed", void 0, {
1304
1307
  F: __dxlog_file5,
1305
- L: 168,
1308
+ L: 172,
1306
1309
  S: this,
1307
1310
  C: (f, a) => f(...a)
1308
1311
  });
@@ -1317,7 +1320,7 @@ var EdgeFeedReplicator = class extends import_context3.Resource {
1317
1320
  message
1318
1321
  }, {
1319
1322
  F: __dxlog_file5,
1320
- L: 174,
1323
+ L: 178,
1321
1324
  S: this,
1322
1325
  C: (f, a) => f(...a)
1323
1326
  });
@@ -1328,7 +1331,7 @@ var EdgeFeedReplicator = class extends import_context3.Resource {
1328
1331
  feedKey
1329
1332
  }, {
1330
1333
  F: __dxlog_file5,
1331
- L: 179,
1334
+ L: 183,
1332
1335
  S: this,
1333
1336
  C: (f, a) => f(...a)
1334
1337
  });
@@ -1361,7 +1364,7 @@ var EdgeFeedReplicator = class extends import_context3.Resource {
1361
1364
  blocks: message.blocks.map((b) => b.index)
1362
1365
  }, {
1363
1366
  F: __dxlog_file5,
1364
- L: 201,
1367
+ L: 205,
1365
1368
  S: this,
1366
1369
  C: (f, a) => f(...a)
1367
1370
  });
@@ -1372,7 +1375,7 @@ var EdgeFeedReplicator = class extends import_context3.Resource {
1372
1375
  feedKey
1373
1376
  }, {
1374
1377
  F: __dxlog_file5,
1375
- L: 206,
1378
+ L: 210,
1376
1379
  S: this,
1377
1380
  C: (f, a) => f(...a)
1378
1381
  });
@@ -1386,7 +1389,7 @@ var EdgeFeedReplicator = class extends import_context3.Resource {
1386
1389
  ...message
1387
1390
  }, {
1388
1391
  F: __dxlog_file5,
1389
- L: 215,
1392
+ L: 219,
1390
1393
  S: this,
1391
1394
  C: (f, a) => f(...a)
1392
1395
  });
@@ -1401,7 +1404,7 @@ var EdgeFeedReplicator = class extends import_context3.Resource {
1401
1404
  to
1402
1405
  }, {
1403
1406
  F: __dxlog_file5,
1404
- L: 222,
1407
+ L: 226,
1405
1408
  S: this,
1406
1409
  C: (f, a) => f(...a)
1407
1410
  });
@@ -1411,7 +1414,7 @@ var EdgeFeedReplicator = class extends import_context3.Resource {
1411
1414
  });
1412
1415
  (0, import_invariant2.invariant)(data instanceof Uint8Array, void 0, {
1413
1416
  F: __dxlog_file5,
1414
- L: 227,
1417
+ L: 231,
1415
1418
  S: this,
1416
1419
  A: [
1417
1420
  "data instanceof Uint8Array",
@@ -1439,7 +1442,7 @@ var EdgeFeedReplicator = class extends import_context3.Resource {
1439
1442
  blocks: blocks.length
1440
1443
  }, {
1441
1444
  F: __dxlog_file5,
1442
- L: 248,
1445
+ L: 252,
1443
1446
  S: this,
1444
1447
  C: (f, a) => f(...a)
1445
1448
  });
@@ -1461,7 +1464,7 @@ var EdgeFeedReplicator = class extends import_context3.Resource {
1461
1464
  if (!this._remoteLength.has(feed.key)) {
1462
1465
  (0, import_log3.log)("blocks not pushed because remote length is unknown", void 0, {
1463
1466
  F: __dxlog_file5,
1464
- L: 269,
1467
+ L: 273,
1465
1468
  S: this,
1466
1469
  C: (f, a) => f(...a)
1467
1470
  });
@@ -1486,7 +1489,7 @@ var EdgeFeedReplicator = class extends import_context3.Resource {
1486
1489
  if (err instanceof import_edge_client.EdgeIdentityChangedError || err instanceof import_edge_client.EdgeConnectionClosedError) {
1487
1490
  (0, import_log3.log)("resetting on reconnect", void 0, {
1488
1491
  F: __dxlog_file5,
1489
- L: 286,
1492
+ L: 290,
1490
1493
  S: this,
1491
1494
  C: (f, a) => f(...a)
1492
1495
  });
@@ -1497,7 +1500,7 @@ var EdgeFeedReplicator = class extends import_context3.Resource {
1497
1500
  }
1498
1501
  }, {
1499
1502
  F: __dxlog_file5,
1500
- L: 280
1503
+ L: 284
1501
1504
  });
1502
1505
  return connectionCtx;
1503
1506
  }
@@ -4887,6 +4890,7 @@ var tryAcquireBeforeContextDisposed = async (ctx, mutex) => {
4887
4890
  })());
4888
4891
  };
4889
4892
  var __dxlog_file16 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/edge-invitation-handler.ts";
4893
+ var MAX_RETRIES_PER_INVITATION = 5;
4890
4894
  var DEFAULT_REQUEST_RETRY_INTERVAL_MS = 3e3;
4891
4895
  var DEFAULT_REQUEST_RETRY_JITTER_MS = 500;
4892
4896
  var EdgeInvitationHandler = class {
@@ -4900,7 +4904,7 @@ var EdgeInvitationHandler = class {
4900
4904
  if (!this._client) {
4901
4905
  (0, import_log14.log)("edge disabled", void 0, {
4902
4906
  F: __dxlog_file16,
4903
- L: 65,
4907
+ L: 66,
4904
4908
  S: this,
4905
4909
  C: (f, a) => f(...a)
4906
4910
  });
@@ -4914,7 +4918,7 @@ var EdgeInvitationHandler = class {
4914
4918
  invitation
4915
4919
  }, {
4916
4920
  F: __dxlog_file16,
4917
- L: 79,
4921
+ L: 80,
4918
4922
  S: this,
4919
4923
  C: (f, a) => f(...a)
4920
4924
  });
@@ -4924,7 +4928,9 @@ var EdgeInvitationHandler = class {
4924
4928
  this._flowLock?.release();
4925
4929
  this._flowLock = void 0;
4926
4930
  });
4931
+ let requestCount = 0;
4927
4932
  const tryHandleInvitation = async () => {
4933
+ requestCount++;
4928
4934
  const admissionRequest = await protocol.createAdmissionRequest(deviceProfile);
4929
4935
  if (admissionRequest.space) {
4930
4936
  try {
@@ -4937,19 +4943,19 @@ var EdgeInvitationHandler = class {
4937
4943
  after: error.retryAfterMs ?? this._calculateNextRetryMs()
4938
4944
  }, {
4939
4945
  F: __dxlog_file16,
4940
- L: 95,
4946
+ L: 98,
4941
4947
  S: this,
4942
4948
  C: (f, a) => f(...a)
4943
4949
  });
4944
- if (error.isRetryable) {
4950
+ if (error.isRetryable && requestCount < MAX_RETRIES_PER_INVITATION) {
4945
4951
  (0, import_async16.scheduleTask)(ctx, tryHandleInvitation, error.retryAfterMs ?? this._calculateNextRetryMs());
4946
4952
  }
4947
- } else {
4953
+ } else if (requestCount < MAX_RETRIES_PER_INVITATION) {
4948
4954
  import_log14.log.info("failed to handle invitation with edge", {
4949
4955
  error
4950
4956
  }, {
4951
4957
  F: __dxlog_file16,
4952
- L: 104,
4958
+ L: 107,
4953
4959
  S: this,
4954
4960
  C: (f, a) => f(...a)
4955
4961
  });
@@ -4964,14 +4970,14 @@ var EdgeInvitationHandler = class {
4964
4970
  try {
4965
4971
  (0, import_log14.log)("edge invitation flow", void 0, {
4966
4972
  F: __dxlog_file16,
4967
- L: 120,
4973
+ L: 123,
4968
4974
  S: this,
4969
4975
  C: (f, a) => f(...a)
4970
4976
  });
4971
4977
  this._flowLock = await tryAcquireBeforeContextDisposed(ctx, guardedState.mutex);
4972
- (0, import_log14.log)("edge invitation flow acquired the lock", void 0, {
4978
+ import_log14.log.verbose("edge invitation flow acquired the lock", void 0, {
4973
4979
  F: __dxlog_file16,
4974
- L: 122,
4980
+ L: 125,
4975
4981
  S: this,
4976
4982
  C: (f, a) => f(...a)
4977
4983
  });
@@ -5004,7 +5010,7 @@ var EdgeInvitationHandler = class {
5004
5010
  async _joinSpaceByInvitation(guardedState, spaceId, request) {
5005
5011
  (0, import_invariant13.invariant)(this._client, void 0, {
5006
5012
  F: __dxlog_file16,
5007
- L: 157,
5013
+ L: 160,
5008
5014
  S: this,
5009
5015
  A: [
5010
5016
  "this._client",
@@ -5092,14 +5098,14 @@ var InvitationGuestExtension = class extends import_teleport2.RpcExtension {
5092
5098
  async onOpen(context) {
5093
5099
  await super.onOpen(context);
5094
5100
  try {
5095
- (0, import_log15.log)("guest acquire lock", void 0, {
5101
+ import_log15.log.verbose("guest acquire lock", void 0, {
5096
5102
  F: __dxlog_file17,
5097
5103
  L: 89,
5098
5104
  S: this,
5099
5105
  C: (f, a) => f(...a)
5100
5106
  });
5101
5107
  this._invitationFlowLock = await tryAcquireBeforeContextDisposed(this._ctx, this._invitationFlowMutex);
5102
- (0, import_log15.log)("guest lock acquired", void 0, {
5108
+ import_log15.log.verbose("guest lock acquired", void 0, {
5103
5109
  F: __dxlog_file17,
5104
5110
  L: 91,
5105
5111
  S: this,
@@ -5108,7 +5114,7 @@ var InvitationGuestExtension = class extends import_teleport2.RpcExtension {
5108
5114
  await (0, import_context12.cancelWithContext)(this._ctx, this.rpc.InvitationHostService.options({
5109
5115
  role: import_invitations3.InvitationOptions.Role.GUEST
5110
5116
  }));
5111
- (0, import_log15.log)("options sent", void 0, {
5117
+ import_log15.log.verbose("options sent", void 0, {
5112
5118
  F: __dxlog_file17,
5113
5119
  L: 96,
5114
5120
  S: this,
@@ -5117,7 +5123,7 @@ var InvitationGuestExtension = class extends import_teleport2.RpcExtension {
5117
5123
  await (0, import_context12.cancelWithContext)(this._ctx, this._remoteOptionsTrigger.wait({
5118
5124
  timeout: OPTIONS_TIMEOUT
5119
5125
  }));
5120
- (0, import_log15.log)("options received", void 0, {
5126
+ import_log15.log.verbose("options received", void 0, {
5121
5127
  F: __dxlog_file17,
5122
5128
  L: 98,
5123
5129
  S: this,
@@ -5151,7 +5157,7 @@ var InvitationGuestExtension = class extends import_teleport2.RpcExtension {
5151
5157
  if (this._invitationFlowLock != null) {
5152
5158
  this._invitationFlowLock.release();
5153
5159
  this._invitationFlowLock = null;
5154
- (0, import_log15.log)("invitation flow lock released", void 0, {
5160
+ import_log15.log.verbose("invitation flow lock released", void 0, {
5155
5161
  F: __dxlog_file17,
5156
5162
  L: 131,
5157
5163
  S: this,
@@ -5237,7 +5243,7 @@ var InvitationHostExtension = class extends import_teleport3.RpcExtension {
5237
5243
  authMethod: import_services14.Invitation.AuthMethod.NONE
5238
5244
  };
5239
5245
  }
5240
- (0, import_log16.log)("guest introduced themselves", {
5246
+ import_log16.log.verbose("guest introduced themselves", {
5241
5247
  guestProfile: profile
5242
5248
  }, {
5243
5249
  F: __dxlog_file18,
@@ -5272,7 +5278,7 @@ var InvitationHostExtension = class extends import_teleport3.RpcExtension {
5272
5278
  C: (f, a) => f(...a)
5273
5279
  });
5274
5280
  const invitation = this._requireActiveInvitation();
5275
- (0, import_log16.log)("received authentication request", {
5281
+ import_log16.log.verbose("received authentication request", {
5276
5282
  authCode: code
5277
5283
  }, {
5278
5284
  F: __dxlog_file18,
@@ -5400,41 +5406,39 @@ var InvitationHostExtension = class extends import_teleport3.RpcExtension {
5400
5406
  async onOpen(context) {
5401
5407
  await super.onOpen(context);
5402
5408
  try {
5403
- (0, import_log16.log)("host acquire lock", void 0, {
5409
+ import_log16.log.verbose("host acquire lock", void 0, {
5404
5410
  F: __dxlog_file18,
5405
5411
  L: 239,
5406
5412
  S: this,
5407
5413
  C: (f, a) => f(...a)
5408
5414
  });
5409
5415
  this._invitationFlowLock = await tryAcquireBeforeContextDisposed(this._ctx, this._invitationFlowMutex);
5410
- (0, import_log16.log)("host lock acquired", void 0, {
5416
+ import_log16.log.verbose("host lock acquired", void 0, {
5411
5417
  F: __dxlog_file18,
5412
5418
  L: 241,
5413
5419
  S: this,
5414
5420
  C: (f, a) => f(...a)
5415
5421
  });
5416
- const lastState = this._requireActiveInvitation().state;
5417
5422
  this._callbacks.onStateUpdate(import_services14.Invitation.State.CONNECTING);
5418
5423
  await this.rpc.InvitationHostService.options({
5419
5424
  role: import_invitations4.InvitationOptions.Role.HOST
5420
5425
  });
5421
- (0, import_log16.log)("options sent", void 0, {
5426
+ import_log16.log.verbose("options sent", void 0, {
5422
5427
  F: __dxlog_file18,
5423
- L: 245,
5428
+ L: 244,
5424
5429
  S: this,
5425
5430
  C: (f, a) => f(...a)
5426
5431
  });
5427
5432
  await (0, import_context13.cancelWithContext)(this._ctx, this._remoteOptionsTrigger.wait({
5428
5433
  timeout: OPTIONS_TIMEOUT2
5429
5434
  }));
5430
- (0, import_log16.log)("options received", void 0, {
5435
+ import_log16.log.verbose("options received", void 0, {
5431
5436
  F: __dxlog_file18,
5432
- L: 247,
5437
+ L: 246,
5433
5438
  S: this,
5434
5439
  C: (f, a) => f(...a)
5435
5440
  });
5436
5441
  if (this._remoteOptions?.role !== import_invitations4.InvitationOptions.Role.GUEST) {
5437
- this._callbacks.onStateUpdate(lastState);
5438
5442
  throw new import_protocols12.InvalidInvitationExtensionRoleError(void 0, {
5439
5443
  expected: import_invitations4.InvitationOptions.Role.GUEST,
5440
5444
  remoteOptions: this._remoteOptions,
@@ -5481,9 +5485,9 @@ var InvitationHostExtension = class extends import_teleport3.RpcExtension {
5481
5485
  if (this._invitationFlowLock != null) {
5482
5486
  this._invitationFlowLock?.release();
5483
5487
  this._invitationFlowLock = null;
5484
- (0, import_log16.log)("invitation flow lock released", void 0, {
5488
+ import_log16.log.verbose("invitation flow lock released", void 0, {
5485
5489
  F: __dxlog_file18,
5486
- L: 302,
5490
+ L: 299,
5487
5491
  S: this,
5488
5492
  C: (f, a) => f(...a)
5489
5493
  });
@@ -5677,7 +5681,7 @@ var InvitationsHandler = class {
5677
5681
  S: this,
5678
5682
  C: (f, a) => f(...a)
5679
5683
  });
5680
- metrics.increment("dxos.invitation.created");
5684
+ metrics.increment("dxos.invitation.host");
5681
5685
  const guardedState = createGuardedInvitationState(ctx, invitation, stream);
5682
5686
  const createExtension = () => {
5683
5687
  const extension = new InvitationHostExtension(guardedState.mutex, {
@@ -5685,7 +5689,9 @@ var InvitationsHandler = class {
5685
5689
  return ctx.disposed ? null : guardedState.current;
5686
5690
  },
5687
5691
  onStateUpdate: (newState) => {
5688
- guardedState.set(extension, newState);
5692
+ if (newState !== import_services11.Invitation.State.ERROR && newState !== import_services11.Invitation.State.TIMEOUT) {
5693
+ guardedState.set(extension, newState);
5694
+ }
5689
5695
  return guardedState.current;
5690
5696
  },
5691
5697
  admit: async (admissionRequest) => {
@@ -5695,14 +5701,14 @@ var InvitationsHandler = class {
5695
5701
  ...protocol.toJSON()
5696
5702
  }, {
5697
5703
  F: __dxlog_file21,
5698
- L: 105,
5704
+ L: 107,
5699
5705
  S: this,
5700
5706
  C: (f, a) => f(...a)
5701
5707
  });
5702
5708
  const deviceKey = admissionRequest.device?.deviceKey ?? admissionRequest.space?.deviceKey;
5703
5709
  (0, import_invariant12.invariant)(deviceKey, void 0, {
5704
5710
  F: __dxlog_file21,
5705
- L: 110,
5711
+ L: 112,
5706
5712
  S: this,
5707
5713
  A: [
5708
5714
  "deviceKey",
@@ -5721,7 +5727,7 @@ var InvitationsHandler = class {
5721
5727
  let admitted = false;
5722
5728
  connectionCtx.onDispose(() => {
5723
5729
  if (!admitted) {
5724
- guardedState.error(extension, new import_context10.ContextDisposedError());
5730
+ guardedState.set(extension, import_services11.Invitation.State.CONNECTING);
5725
5731
  }
5726
5732
  });
5727
5733
  (0, import_async15.scheduleTask)(connectionCtx, async () => {
@@ -5731,27 +5737,27 @@ var InvitationsHandler = class {
5731
5737
  id: traceId
5732
5738
  }), {
5733
5739
  F: __dxlog_file21,
5734
- L: 135,
5740
+ L: 137,
5735
5741
  S: this,
5736
5742
  C: (f, a) => f(...a)
5737
5743
  });
5738
- (0, import_log13.log)("connected", {
5744
+ import_log13.log.verbose("connected", {
5739
5745
  ...protocol.toJSON()
5740
5746
  }, {
5741
5747
  F: __dxlog_file21,
5742
- L: 136,
5748
+ L: 138,
5743
5749
  S: this,
5744
5750
  C: (f, a) => f(...a)
5745
5751
  });
5746
5752
  const deviceKey = await extension.completedTrigger.wait({
5747
5753
  timeout: invitation.timeout
5748
5754
  });
5749
- (0, import_log13.log)("admitted guest", {
5755
+ import_log13.log.verbose("admitted guest", {
5750
5756
  guest: deviceKey,
5751
5757
  ...protocol.toJSON()
5752
5758
  }, {
5753
5759
  F: __dxlog_file21,
5754
- L: 138,
5760
+ L: 140,
5755
5761
  S: this,
5756
5762
  C: (f, a) => f(...a)
5757
5763
  });
@@ -5761,7 +5767,7 @@ var InvitationsHandler = class {
5761
5767
  id: traceId
5762
5768
  }), {
5763
5769
  F: __dxlog_file21,
5764
- L: 141,
5770
+ L: 143,
5765
5771
  S: this,
5766
5772
  C: (f, a) => f(...a)
5767
5773
  });
@@ -5770,24 +5776,25 @@ var InvitationsHandler = class {
5770
5776
  await ctx.dispose();
5771
5777
  }
5772
5778
  } catch (err) {
5779
+ const stateChanged = guardedState.set(extension, import_services11.Invitation.State.CONNECTING);
5773
5780
  if (err instanceof import_async15.TimeoutError) {
5774
- if (guardedState.set(extension, import_services11.Invitation.State.TIMEOUT)) {
5781
+ if (stateChanged) {
5775
5782
  metrics.increment("dxos.invitation.timeout");
5776
- (0, import_log13.log)("timeout", {
5783
+ import_log13.log.verbose("timeout", {
5777
5784
  ...protocol.toJSON()
5778
5785
  }, {
5779
5786
  F: __dxlog_file21,
5780
- L: 151,
5787
+ L: 154,
5781
5788
  S: this,
5782
5789
  C: (f, a) => f(...a)
5783
5790
  });
5784
5791
  }
5785
5792
  } else {
5786
- if (guardedState.error(extension, err)) {
5793
+ if (stateChanged) {
5787
5794
  metrics.increment("dxos.invitation.failed");
5788
5795
  import_log13.log.error("failed", err, {
5789
5796
  F: __dxlog_file21,
5790
- L: 156,
5797
+ L: 159,
5791
5798
  S: this,
5792
5799
  C: (f, a) => f(...a)
5793
5800
  });
@@ -5798,7 +5805,7 @@ var InvitationsHandler = class {
5798
5805
  error: err
5799
5806
  }), {
5800
5807
  F: __dxlog_file21,
5801
- L: 159,
5808
+ L: 162,
5802
5809
  S: this,
5803
5810
  C: (f, a) => f(...a)
5804
5811
  });
@@ -5807,35 +5814,36 @@ var InvitationsHandler = class {
5807
5814
  });
5808
5815
  },
5809
5816
  onError: (err) => {
5817
+ const stateChanged = guardedState.set(extension, import_services11.Invitation.State.CONNECTING);
5810
5818
  if (err instanceof import_protocols9.InvalidInvitationExtensionRoleError) {
5811
5819
  (0, import_log13.log)("invalid role", {
5812
5820
  ...err.context
5813
5821
  }, {
5814
5822
  F: __dxlog_file21,
5815
- L: 167,
5823
+ L: 171,
5816
5824
  S: this,
5817
5825
  C: (f, a) => f(...a)
5818
5826
  });
5819
5827
  return;
5820
5828
  }
5821
5829
  if (err instanceof import_async15.TimeoutError) {
5822
- if (guardedState.set(extension, import_services11.Invitation.State.TIMEOUT)) {
5830
+ if (stateChanged) {
5823
5831
  metrics.increment("dxos.invitation.timeout");
5824
- (0, import_log13.log)("timeout", {
5832
+ import_log13.log.verbose("timeout", {
5825
5833
  err
5826
5834
  }, {
5827
5835
  F: __dxlog_file21,
5828
- L: 173,
5836
+ L: 177,
5829
5837
  S: this,
5830
5838
  C: (f, a) => f(...a)
5831
5839
  });
5832
5840
  }
5833
5841
  } else {
5834
- if (guardedState.error(extension, err)) {
5842
+ if (stateChanged) {
5835
5843
  metrics.increment("dxos.invitation.failed");
5836
5844
  import_log13.log.error("failed", err, {
5837
5845
  F: __dxlog_file21,
5838
- L: 178,
5846
+ L: 182,
5839
5847
  S: this,
5840
5848
  C: (f, a) => f(...a)
5841
5849
  });
@@ -5849,18 +5857,25 @@ var InvitationsHandler = class {
5849
5857
  if (invitation.created.getTime() + invitation.lifetime * 1e3 < Date.now()) {
5850
5858
  import_log13.log.warn("invitation has already expired", void 0, {
5851
5859
  F: __dxlog_file21,
5852
- L: 189,
5860
+ L: 193,
5853
5861
  S: this,
5854
5862
  C: (f, a) => f(...a)
5855
5863
  });
5856
- } else {
5857
- (0, import_async15.scheduleTask)(ctx, async () => {
5858
- await swarmConnection.close();
5859
- guardedState.set(null, import_services11.Invitation.State.EXPIRED);
5860
- metrics.increment("dxos.invitation.expired");
5861
- await ctx.dispose();
5862
- }, invitation.created.getTime() + invitation.lifetime * 1e3 - Date.now());
5864
+ guardedState.set(null, import_services11.Invitation.State.EXPIRED);
5865
+ void ctx.dispose().catch((err) => import_log13.log.catch(err, void 0, {
5866
+ F: __dxlog_file21,
5867
+ L: 195,
5868
+ S: this,
5869
+ C: (f, a) => f(...a)
5870
+ }));
5871
+ return;
5863
5872
  }
5873
+ (0, import_async15.scheduleTask)(ctx, async () => {
5874
+ await swarmConnection.close();
5875
+ guardedState.set(null, import_services11.Invitation.State.EXPIRED);
5876
+ metrics.increment("dxos.invitation.expired");
5877
+ await ctx.dispose();
5878
+ }, invitation.created.getTime() + invitation.lifetime * 1e3 - Date.now());
5864
5879
  }
5865
5880
  let swarmConnection;
5866
5881
  (0, import_async15.scheduleTask)(ctx, async () => {
@@ -5876,7 +5891,7 @@ var InvitationsHandler = class {
5876
5891
  type: invitation.type
5877
5892
  }, {
5878
5893
  F: __dxlog_file21,
5879
- L: 220,
5894
+ L: 226,
5880
5895
  S: this,
5881
5896
  C: (f, a) => f(...a)
5882
5897
  });
@@ -5884,7 +5899,7 @@ var InvitationsHandler = class {
5884
5899
  if (deviceProfile) {
5885
5900
  (0, import_invariant12.invariant)(invitation.kind === import_services11.Invitation.Kind.DEVICE, "deviceProfile provided for non-device invitation", {
5886
5901
  F: __dxlog_file21,
5887
- L: 229,
5902
+ L: 235,
5888
5903
  S: this,
5889
5904
  A: [
5890
5905
  "invitation.kind === Invitation.Kind.DEVICE",
@@ -5902,7 +5917,7 @@ var InvitationsHandler = class {
5902
5917
  triedPeers: triedPeersIds.size
5903
5918
  }, {
5904
5919
  F: __dxlog_file21,
5905
- L: 237,
5920
+ L: 243,
5906
5921
  S: this,
5907
5922
  C: (f, a) => f(...a)
5908
5923
  });
@@ -5924,12 +5939,12 @@ var InvitationsHandler = class {
5924
5939
  return;
5925
5940
  }
5926
5941
  connectionCtx.onDispose(async () => {
5927
- (0, import_log13.log)("extension disposed", {
5942
+ import_log13.log.verbose("extension disposed", {
5928
5943
  admitted,
5929
5944
  currentState: guardedState.current.state
5930
5945
  }, {
5931
5946
  F: __dxlog_file21,
5932
- L: 265,
5947
+ L: 271,
5933
5948
  S: this,
5934
5949
  C: (f, a) => f(...a)
5935
5950
  });
@@ -5947,7 +5962,7 @@ var InvitationsHandler = class {
5947
5962
  id: traceId
5948
5963
  }), {
5949
5964
  F: __dxlog_file21,
5950
- L: 277,
5965
+ L: 283,
5951
5966
  S: this,
5952
5967
  C: (f, a) => f(...a)
5953
5968
  });
@@ -5959,7 +5974,7 @@ var InvitationsHandler = class {
5959
5974
  ...protocol.toJSON()
5960
5975
  }, {
5961
5976
  F: __dxlog_file21,
5962
- L: 288,
5977
+ L: 294,
5963
5978
  S: this,
5964
5979
  C: (f, a) => f(...a)
5965
5980
  });
@@ -5969,7 +5984,7 @@ var InvitationsHandler = class {
5969
5984
  ...protocol.toJSON()
5970
5985
  }, {
5971
5986
  F: __dxlog_file21,
5972
- L: 292,
5987
+ L: 298,
5973
5988
  S: this,
5974
5989
  C: (f, a) => f(...a)
5975
5990
  });
@@ -5983,7 +5998,7 @@ var InvitationsHandler = class {
5983
5998
  authMethod: introductionResponse.authMethod
5984
5999
  }, {
5985
6000
  F: __dxlog_file21,
5986
- L: 300,
6001
+ L: 306,
5987
6002
  S: this,
5988
6003
  C: (f, a) => f(...a)
5989
6004
  });
@@ -6005,7 +6020,7 @@ var InvitationsHandler = class {
6005
6020
  ...protocol.toJSON()
6006
6021
  }, {
6007
6022
  F: __dxlog_file21,
6008
- L: 330,
6023
+ L: 336,
6009
6024
  S: this,
6010
6025
  C: (f, a) => f(...a)
6011
6026
  });
@@ -6018,7 +6033,7 @@ var InvitationsHandler = class {
6018
6033
  ...protocol.toJSON()
6019
6034
  }, {
6020
6035
  F: __dxlog_file21,
6021
- L: 344,
6036
+ L: 350,
6022
6037
  S: this,
6023
6038
  C: (f, a) => f(...a)
6024
6039
  });
@@ -6031,25 +6046,25 @@ var InvitationsHandler = class {
6031
6046
  id: traceId
6032
6047
  }), {
6033
6048
  F: __dxlog_file21,
6034
- L: 353,
6049
+ L: 359,
6035
6050
  S: this,
6036
6051
  C: (f, a) => f(...a)
6037
6052
  });
6038
6053
  } catch (err) {
6039
6054
  if (err instanceof import_async15.TimeoutError) {
6040
- (0, import_log13.log)("timeout", {
6055
+ import_log13.log.verbose("timeout", {
6041
6056
  ...protocol.toJSON()
6042
6057
  }, {
6043
6058
  F: __dxlog_file21,
6044
- L: 356,
6059
+ L: 362,
6045
6060
  S: this,
6046
6061
  C: (f, a) => f(...a)
6047
6062
  });
6048
6063
  guardedState.set(extension, import_services11.Invitation.State.TIMEOUT);
6049
6064
  } else {
6050
- (0, import_log13.log)("auth failed", err, {
6065
+ import_log13.log.verbose("auth failed", err, {
6051
6066
  F: __dxlog_file21,
6052
- L: 359,
6067
+ L: 365,
6053
6068
  S: this,
6054
6069
  C: (f, a) => f(...a)
6055
6070
  });
@@ -6061,7 +6076,7 @@ var InvitationsHandler = class {
6061
6076
  error: err
6062
6077
  }), {
6063
6078
  F: __dxlog_file21,
6064
- L: 363,
6079
+ L: 369,
6065
6080
  S: this,
6066
6081
  C: (f, a) => f(...a)
6067
6082
  });
@@ -6073,19 +6088,19 @@ var InvitationsHandler = class {
6073
6088
  return;
6074
6089
  }
6075
6090
  if (err instanceof import_async15.TimeoutError) {
6076
- (0, import_log13.log)("timeout", {
6091
+ import_log13.log.verbose("timeout", {
6077
6092
  ...protocol.toJSON()
6078
6093
  }, {
6079
6094
  F: __dxlog_file21,
6080
- L: 372,
6095
+ L: 378,
6081
6096
  S: this,
6082
6097
  C: (f, a) => f(...a)
6083
6098
  });
6084
6099
  guardedState.set(extension, import_services11.Invitation.State.TIMEOUT);
6085
6100
  } else {
6086
- (0, import_log13.log)("auth failed", err, {
6101
+ import_log13.log.verbose("auth failed", err, {
6087
6102
  F: __dxlog_file21,
6088
- L: 375,
6103
+ L: 381,
6089
6104
  S: this,
6090
6105
  C: (f, a) => f(...a)
6091
6106
  });
@@ -6102,7 +6117,7 @@ var InvitationsHandler = class {
6102
6117
  ...protocol.toJSON()
6103
6118
  }, {
6104
6119
  F: __dxlog_file21,
6105
- L: 387,
6120
+ L: 393,
6106
6121
  S: this,
6107
6122
  C: (f, a) => f(...a)
6108
6123
  });
@@ -6122,7 +6137,7 @@ var InvitationsHandler = class {
6122
6137
  } else {
6123
6138
  (0, import_invariant12.invariant)(invitation.swarmKey, void 0, {
6124
6139
  F: __dxlog_file21,
6125
- L: 399,
6140
+ L: 405,
6126
6141
  S: this,
6127
6142
  A: [
6128
6143
  "invitation.swarmKey",
@@ -6166,7 +6181,7 @@ var InvitationsHandler = class {
6166
6181
  for (let attempt = 1; attempt <= MAX_OTP_ATTEMPTS; attempt++) {
6167
6182
  (0, import_log13.log)("guest waiting for authentication code...", void 0, {
6168
6183
  F: __dxlog_file21,
6169
- L: 451,
6184
+ L: 457,
6170
6185
  S: this,
6171
6186
  C: (f, a) => f(...a)
6172
6187
  });
@@ -6174,7 +6189,7 @@ var InvitationsHandler = class {
6174
6189
  const authCode = await authenticated.wait(options);
6175
6190
  (0, import_log13.log)("sending authentication request", void 0, {
6176
6191
  F: __dxlog_file21,
6177
- L: 455,
6192
+ L: 461,
6178
6193
  S: this,
6179
6194
  C: (f, a) => f(...a)
6180
6195
  });
@@ -6193,7 +6208,7 @@ var InvitationsHandler = class {
6193
6208
  attempt
6194
6209
  }, {
6195
6210
  F: __dxlog_file21,
6196
- L: 466,
6211
+ L: 472,
6197
6212
  S: this,
6198
6213
  C: (f, a) => f(...a)
6199
6214
  });
@@ -6211,7 +6226,7 @@ var InvitationsHandler = class {
6211
6226
  }
6212
6227
  (0, import_log13.log)("sending authentication request", void 0, {
6213
6228
  F: __dxlog_file21,
6214
- L: 485,
6229
+ L: 491,
6215
6230
  S: this,
6216
6231
  C: (f, a) => f(...a)
6217
6232
  });
@@ -6241,7 +6256,10 @@ var InvitationsServiceImpl = class {
6241
6256
  }
6242
6257
  createInvitation(options) {
6243
6258
  return new import_codec_protobuf10.Stream(({ next, close }) => {
6244
- void this._invitationsManager.createInvitation(options).then((invitation) => invitation.subscribe(next, close, close)).catch(close);
6259
+ void this._invitationsManager.createInvitation(options).then((invitation) => {
6260
+ import_tracing9.trace.metrics.increment("dxos.invitation.created");
6261
+ invitation.subscribe(next, close, close);
6262
+ }).catch(close);
6245
6263
  });
6246
6264
  }
6247
6265
  acceptInvitation(request) {
@@ -6798,8 +6816,8 @@ var InvitationsManager = class {
6798
6816
  this._persistentInvitationsLoadedEvent.once(ctx, () => callback());
6799
6817
  }
6800
6818
  }
6801
- _createInvitation(protocol, options) {
6802
- const { invitationId = import_keys14.PublicKey.random().toHex(), type = import_services18.Invitation.Type.INTERACTIVE, authMethod = import_services18.Invitation.AuthMethod.SHARED_SECRET, state = import_services18.Invitation.State.INIT, timeout = import_client_protocol6.INVITATION_TIMEOUT, swarmKey = import_keys14.PublicKey.random(), persistent = options?.authMethod !== import_services18.Invitation.AuthMethod.KNOWN_PUBLIC_KEY, created = /* @__PURE__ */ new Date(), guestKeypair = void 0, role = import_credentials21.SpaceMember.Role.ADMIN, lifetime = 86400, multiUse = false } = options ?? {};
6819
+ _createInvitation(protocol, _options) {
6820
+ const { invitationId = import_keys14.PublicKey.random().toHex(), type = import_services18.Invitation.Type.INTERACTIVE, authMethod = import_services18.Invitation.AuthMethod.SHARED_SECRET, state = import_services18.Invitation.State.INIT, timeout = import_client_protocol6.INVITATION_TIMEOUT, swarmKey = import_keys14.PublicKey.random(), persistent = _options?.authMethod !== import_services18.Invitation.AuthMethod.KNOWN_PUBLIC_KEY, created = /* @__PURE__ */ new Date(), guestKeypair = void 0, role = import_credentials21.SpaceMember.Role.ADMIN, lifetime = 86400, multiUse = false, ...options } = _options ?? {};
6803
6821
  const authCode = options?.authCode ?? (authMethod === import_services18.Invitation.AuthMethod.SHARED_SECRET ? (0, import_credentials20.generatePasscode)(import_client_protocol6.AUTHENTICATION_CODE_LENGTH) : void 0);
6804
6822
  return {
6805
6823
  invitationId,
@@ -6816,6 +6834,7 @@ var InvitationsManager = class {
6816
6834
  role,
6817
6835
  multiUse,
6818
6836
  delegationCredentialId: options?.delegationCredentialId,
6837
+ ...options,
6819
6838
  ...protocol.getInvitationContext()
6820
6839
  };
6821
6840
  }
@@ -6828,14 +6847,14 @@ var InvitationsManager = class {
6828
6847
  }
6829
6848
  }, {
6830
6849
  F: __dxlog_file23,
6831
- L: 234
6850
+ L: 236
6832
6851
  });
6833
6852
  ctx.onDispose(() => {
6834
6853
  (0, import_log20.log)("complete", {
6835
6854
  ...handler.toJSON()
6836
6855
  }, {
6837
6856
  F: __dxlog_file23,
6838
- L: 241,
6857
+ L: 243,
6839
6858
  S: this,
6840
6859
  C: (f, a) => f(...a)
6841
6860
  });
@@ -6868,7 +6887,7 @@ var InvitationsManager = class {
6868
6887
  ...handler.toJSON()
6869
6888
  }, {
6870
6889
  F: __dxlog_file23,
6871
- L: 261,
6890
+ L: 263,
6872
6891
  S: this,
6873
6892
  C: (f, a) => f(...a)
6874
6893
  });
@@ -6879,7 +6898,7 @@ var InvitationsManager = class {
6879
6898
  } else {
6880
6899
  import_log20.log.warn("auth failed", err, {
6881
6900
  F: __dxlog_file23,
6882
- L: 264,
6901
+ L: 266,
6883
6902
  S: this,
6884
6903
  C: (f, a) => f(...a)
6885
6904
  });
@@ -6892,14 +6911,14 @@ var InvitationsManager = class {
6892
6911
  }
6893
6912
  }, {
6894
6913
  F: __dxlog_file23,
6895
- L: 258
6914
+ L: 260
6896
6915
  });
6897
6916
  ctx.onDispose(() => {
6898
6917
  (0, import_log20.log)("complete", {
6899
6918
  ...handler.toJSON()
6900
6919
  }, {
6901
6920
  F: __dxlog_file23,
6902
- L: 271,
6921
+ L: 273,
6903
6922
  S: this,
6904
6923
  C: (f, a) => f(...a)
6905
6924
  });
@@ -6944,7 +6963,7 @@ var InvitationsManager = class {
6944
6963
  } catch (err) {
6945
6964
  import_log20.log.catch(err, void 0, {
6946
6965
  F: __dxlog_file23,
6947
- L: 307,
6966
+ L: 309,
6948
6967
  S: this,
6949
6968
  C: (f, a) => f(...a)
6950
6969
  });
@@ -7015,7 +7034,7 @@ function _ts_decorate8(decorators, target, key, desc) {
7015
7034
  var ClientRpcServer = class {
7016
7035
  constructor(params) {
7017
7036
  this._handlerCache = /* @__PURE__ */ new Map();
7018
- this._callMetrics = new import_tracing9.MapCounter();
7037
+ this._callMetrics = new import_tracing10.MapCounter();
7019
7038
  const { serviceRegistry, handleCall, handleStream, ...rpcOptions } = params;
7020
7039
  this._handleCall = handleCall;
7021
7040
  this._handleStream = handleStream;
@@ -7069,13 +7088,13 @@ var ClientRpcServer = class {
7069
7088
  }
7070
7089
  };
7071
7090
  _ts_decorate8([
7072
- import_tracing9.trace.metricsCounter()
7091
+ import_tracing10.trace.metricsCounter()
7073
7092
  ], ClientRpcServer.prototype, "_callMetrics", void 0);
7074
7093
  _ts_decorate8([
7075
- import_tracing9.trace.info()
7094
+ import_tracing10.trace.info()
7076
7095
  ], ClientRpcServer.prototype, "_services", null);
7077
7096
  ClientRpcServer = _ts_decorate8([
7078
- import_tracing9.trace.resource()
7097
+ import_tracing10.trace.resource()
7079
7098
  ], ClientRpcServer);
7080
7099
  function _ts_decorate9(decorators, target, key, desc) {
7081
7100
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
@@ -7819,8 +7838,8 @@ var ServiceContext = class extends import_context16.Resource {
7819
7838
  S: this,
7820
7839
  C: (f, a) => f(...a)
7821
7840
  });
7822
- if (params?.deviceCredential) {
7823
- edgeIdentity = await (0, import_edge_client2.createChainEdgeIdentity)(identity.signer, identity.identityKey, identity.deviceKey, {
7841
+ if (params?.deviceCredential || Boolean(globalThis?.DEVICE_INVITE_INTEROP)) {
7842
+ edgeIdentity = await (0, import_edge_client2.createChainEdgeIdentity)(identity.signer, identity.identityKey, identity.deviceKey, params?.deviceCredential && {
7824
7843
  credential: params.deviceCredential
7825
7844
  }, []);
7826
7845
  } else {
@@ -7855,14 +7874,14 @@ var ServiceContext = class extends import_context16.Resource {
7855
7874
  }
7856
7875
  };
7857
7876
  _ts_decorate10([
7858
- import_tracing10.trace.span()
7877
+ import_tracing11.trace.span()
7859
7878
  ], ServiceContext.prototype, "_open", null);
7860
7879
  _ts_decorate10([
7861
- import_tracing10.trace.span()
7880
+ import_tracing11.trace.span()
7862
7881
  ], ServiceContext.prototype, "_initialize", null);
7863
7882
  ServiceContext = _ts_decorate10([
7864
7883
  (0, import_util12.safeInstanceof)("dxos.client-services.ServiceContext"),
7865
- import_tracing10.trace.resource()
7884
+ import_tracing11.trace.resource()
7866
7885
  ], ServiceContext);
7867
7886
  var ServiceRegistry = class {
7868
7887
  // prettier-ignore
@@ -8097,8 +8116,9 @@ var importProfileData = async ({ storage, level }, archive) => {
8097
8116
  };
8098
8117
  var __dxlog_file29 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/devices/devices-service.ts";
8099
8118
  var DevicesServiceImpl = class {
8100
- constructor(_identityManager) {
8119
+ constructor(_identityManager, _edgeConnection) {
8101
8120
  this._identityManager = _identityManager;
8121
+ this._edgeConnection = _edgeConnection;
8102
8122
  }
8103
8123
  async updateDevice(profile) {
8104
8124
  return this._identityManager.updateDeviceProfile(profile);
@@ -8114,7 +8134,7 @@ var DevicesServiceImpl = class {
8114
8134
  } else {
8115
8135
  (0, import_invariant25.invariant)(this._identityManager.identity?.presence, "presence not present", {
8116
8136
  F: __dxlog_file29,
8117
- L: 32,
8137
+ L: 36,
8118
8138
  S: this,
8119
8139
  A: [
8120
8140
  "this._identityManager.identity?.presence",
@@ -8125,12 +8145,19 @@ var DevicesServiceImpl = class {
8125
8145
  next({
8126
8146
  devices: Array.from(deviceKeys.entries()).map(([key, profile]) => {
8127
8147
  const isMe = this._identityManager.identity?.deviceKey.equals(key);
8128
- const peerState = peers.find((peer) => peer.identityKey.equals(key));
8148
+ let presence;
8149
+ if (isMe) {
8150
+ presence = import_services23.Device.PresenceState.ONLINE;
8151
+ } else if (profile.os?.toUpperCase() === "EDGE") {
8152
+ presence = this._edgeConnection?.isConnected ? import_services23.Device.PresenceState.ONLINE : import_services23.Device.PresenceState.OFFLINE;
8153
+ } else {
8154
+ presence = peers.some((peer) => peer.identityKey.equals(key)) ? import_services23.Device.PresenceState.ONLINE : import_services23.Device.PresenceState.OFFLINE;
8155
+ }
8129
8156
  return {
8130
8157
  deviceKey: key,
8131
8158
  kind: this._identityManager.identity?.deviceKey.equals(key) ? import_services23.DeviceKind.CURRENT : import_services23.DeviceKind.TRUSTED,
8132
8159
  profile,
8133
- presence: isMe ? import_services23.Device.PresenceState.ONLINE : peerState ? import_services23.Device.PresenceState.ONLINE : import_services23.Device.PresenceState.OFFLINE
8160
+ presence
8134
8161
  };
8135
8162
  })
8136
8163
  });
@@ -8465,7 +8492,7 @@ var ClientServicesHost = class {
8465
8492
  callbacks,
8466
8493
  runtimeParams
8467
8494
  } = {}) {
8468
- this._tracingService = import_tracing11.TRACE_PROCESSOR.createTraceSender();
8495
+ this._tracingService = import_tracing12.TRACE_PROCESSOR.createTraceSender();
8469
8496
  this._statusUpdate = new import_async23.Event();
8470
8497
  this._edgeConnection = void 0;
8471
8498
  this._edgeHttpClient = void 0;
@@ -8704,7 +8731,7 @@ var ClientServicesHost = class {
8704
8731
  IdentityService: identityService,
8705
8732
  ContactsService: new ContactsServiceImpl(this._serviceContext.identityManager, this._serviceContext.spaceManager, dataSpaceManagerProvider),
8706
8733
  InvitationsService: new InvitationsServiceImpl(this._serviceContext.invitationsManager),
8707
- DevicesService: new DevicesServiceImpl(this._serviceContext.identityManager),
8734
+ DevicesService: new DevicesServiceImpl(this._serviceContext.identityManager, this._edgeConnection),
8708
8735
  SpacesService: new SpacesServiceImpl(this._serviceContext.identityManager, this._serviceContext.spaceManager, dataSpaceManagerProvider),
8709
8736
  DataService: this._serviceContext.echoHost.dataService,
8710
8737
  QueryService: this._serviceContext.echoHost.queryService,
@@ -8828,24 +8855,24 @@ var ClientServicesHost = class {
8828
8855
  }
8829
8856
  };
8830
8857
  _ts_decorate11([
8831
- import_tracing11.trace.info()
8858
+ import_tracing12.trace.info()
8832
8859
  ], ClientServicesHost.prototype, "_opening", void 0);
8833
8860
  _ts_decorate11([
8834
- import_tracing11.trace.info()
8861
+ import_tracing12.trace.info()
8835
8862
  ], ClientServicesHost.prototype, "_open", void 0);
8836
8863
  _ts_decorate11([
8837
- import_tracing11.trace.info()
8864
+ import_tracing12.trace.info()
8838
8865
  ], ClientServicesHost.prototype, "_resetting", void 0);
8839
8866
  _ts_decorate11([
8840
8867
  import_async23.synchronized,
8841
- import_tracing11.trace.span()
8868
+ import_tracing12.trace.span()
8842
8869
  ], ClientServicesHost.prototype, "open", null);
8843
8870
  _ts_decorate11([
8844
8871
  import_async23.synchronized,
8845
- import_tracing11.trace.span()
8872
+ import_tracing12.trace.span()
8846
8873
  ], ClientServicesHost.prototype, "close", null);
8847
8874
  ClientServicesHost = _ts_decorate11([
8848
- import_tracing11.trace.resource()
8875
+ import_tracing12.trace.resource()
8849
8876
  ], ClientServicesHost);
8850
8877
  // Annotate the CommonJS export names for ESM import in node:
8851
8878
  0 && (module.exports = {
@@ -8893,4 +8920,4 @@ ClientServicesHost = _ts_decorate11([
8893
8920
  subscribeToSpaces,
8894
8921
  subscribeToSwarmInfo
8895
8922
  });
8896
- //# sourceMappingURL=chunk-4BJB67XI.cjs.map
8923
+ //# sourceMappingURL=chunk-3ERQHVZE.cjs.map