@dxos/edge-client 0.8.2-main.f11618f → 0.8.2-staging.7ac8446

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 (44) hide show
  1. package/dist/lib/browser/chunk-ZWJXA37R.mjs +113 -0
  2. package/dist/lib/browser/chunk-ZWJXA37R.mjs.map +7 -0
  3. package/dist/lib/browser/index.mjs +299 -87
  4. package/dist/lib/browser/index.mjs.map +4 -4
  5. package/dist/lib/browser/meta.json +1 -1
  6. package/dist/lib/browser/testing/index.mjs +20 -32
  7. package/dist/lib/browser/testing/index.mjs.map +3 -3
  8. package/dist/lib/node/chunk-ANV2HBEH.cjs +136 -0
  9. package/dist/lib/node/chunk-ANV2HBEH.cjs.map +7 -0
  10. package/dist/lib/node/index.cjs +297 -76
  11. package/dist/lib/node/index.cjs.map +4 -4
  12. package/dist/lib/node/meta.json +1 -1
  13. package/dist/lib/node/testing/index.cjs +21 -31
  14. package/dist/lib/node/testing/index.cjs.map +3 -3
  15. package/dist/lib/node-esm/chunk-HNVT57AU.mjs +115 -0
  16. package/dist/lib/node-esm/chunk-HNVT57AU.mjs.map +7 -0
  17. package/dist/lib/node-esm/index.mjs +299 -87
  18. package/dist/lib/node-esm/index.mjs.map +4 -4
  19. package/dist/lib/node-esm/meta.json +1 -1
  20. package/dist/lib/node-esm/testing/index.mjs +20 -32
  21. package/dist/lib/node-esm/testing/index.mjs.map +3 -3
  22. package/dist/types/src/edge-client.d.ts +2 -7
  23. package/dist/types/src/edge-client.d.ts.map +1 -1
  24. package/dist/types/src/edge-ws-connection.d.ts +0 -5
  25. package/dist/types/src/edge-ws-connection.d.ts.map +1 -1
  26. package/dist/types/src/index.d.ts +0 -1
  27. package/dist/types/src/index.d.ts.map +1 -1
  28. package/dist/types/src/testing/test-utils.d.ts +2 -6
  29. package/dist/types/src/testing/test-utils.d.ts.map +1 -1
  30. package/package.json +14 -14
  31. package/src/edge-client.test.ts +4 -5
  32. package/src/edge-client.ts +8 -16
  33. package/src/edge-ws-connection.ts +15 -38
  34. package/src/index.ts +0 -1
  35. package/src/testing/test-utils.ts +26 -33
  36. package/dist/lib/browser/chunk-5DDWS5EC.mjs +0 -546
  37. package/dist/lib/browser/chunk-5DDWS5EC.mjs.map +0 -7
  38. package/dist/lib/node/chunk-CNAHGYSS.cjs +0 -579
  39. package/dist/lib/node/chunk-CNAHGYSS.cjs.map +0 -7
  40. package/dist/lib/node-esm/chunk-O4TFZRSP.mjs +0 -548
  41. package/dist/lib/node-esm/chunk-O4TFZRSP.mjs.map +0 -7
  42. package/dist/types/src/edge-ws-muxer.d.ts +0 -23
  43. package/dist/types/src/edge-ws-muxer.d.ts.map +0 -1
  44. package/src/edge-ws-muxer.ts +0 -187
@@ -1,7 +1,9 @@
1
1
  "use strict";
2
+ var __create = Object.create;
2
3
  var __defProp = Object.defineProperty;
3
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
5
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
6
8
  var __export = (target, all) => {
7
9
  for (var name in all)
@@ -16,42 +18,54 @@ var __copyProps = (to, from, except, desc) => {
16
18
  return to;
17
19
  };
18
20
  var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
21
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
22
+ // If the importer is in node compatibility mode or this is not an ESM
23
+ // file that has been converted to a CommonJS file using a Babel-
24
+ // compatible transform (i.e. "__esModule" has not been set), then set
25
+ // "default" to the CommonJS "module.exports" for node compatibility.
26
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
27
+ mod
28
+ ));
19
29
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
30
  var node_exports = {};
21
31
  __export(node_exports, {
22
- CLOUDFLARE_MESSAGE_LENGTH_LIMIT: () => import_chunk_CNAHGYSS.CLOUDFLARE_MESSAGE_LENGTH_LIMIT,
23
32
  EdgeClient: () => EdgeClient,
24
33
  EdgeConnectionClosedError: () => EdgeConnectionClosedError,
25
34
  EdgeHttpClient: () => EdgeHttpClient,
26
35
  EdgeIdentityChangedError: () => EdgeIdentityChangedError,
27
- Protocol: () => import_chunk_CNAHGYSS.Protocol,
28
- WebSocketMuxer: () => import_chunk_CNAHGYSS.WebSocketMuxer,
36
+ Protocol: () => import_chunk_ANV2HBEH.Protocol,
29
37
  createChainEdgeIdentity: () => createChainEdgeIdentity,
30
38
  createDeviceEdgeIdentity: () => createDeviceEdgeIdentity,
31
39
  createEphemeralEdgeIdentity: () => createEphemeralEdgeIdentity,
32
40
  createStubEdgeIdentity: () => createStubEdgeIdentity,
33
41
  createTestHaloEdgeIdentity: () => createTestHaloEdgeIdentity,
34
- getTypename: () => import_chunk_CNAHGYSS.getTypename,
42
+ getTypename: () => import_chunk_ANV2HBEH.getTypename,
35
43
  handleAuthChallenge: () => handleAuthChallenge,
36
- protocol: () => import_chunk_CNAHGYSS.protocol,
37
- toUint8Array: () => import_chunk_CNAHGYSS.toUint8Array
44
+ protocol: () => import_chunk_ANV2HBEH.protocol,
45
+ toUint8Array: () => import_chunk_ANV2HBEH.toUint8Array
38
46
  });
39
47
  module.exports = __toCommonJS(node_exports);
40
- var import_chunk_CNAHGYSS = require("./chunk-CNAHGYSS.cjs");
48
+ var import_chunk_ANV2HBEH = require("./chunk-ANV2HBEH.cjs");
41
49
  __reExport(node_exports, require("@dxos/protocols/buf/dxos/edge/messenger_pb"), module.exports);
42
50
  var import_async = require("@dxos/async");
43
51
  var import_context = require("@dxos/context");
44
52
  var import_log = require("@dxos/log");
45
- var import_services = require("@dxos/protocols/proto/dxos/client/services");
46
53
  var import_invariant = require("@dxos/invariant");
47
54
  var import_proto = require("@dxos/protocols/proto");
48
- var import_credentials = require("@dxos/credentials");
49
- var import_invariant2 = require("@dxos/invariant");
50
- var import_keyring = require("@dxos/keyring");
51
- var import_keys = require("@dxos/keys");
55
+ var import_isomorphic_ws = __toESM(require("isomorphic-ws"));
52
56
  var import_async2 = require("@dxos/async");
53
57
  var import_context2 = require("@dxos/context");
58
+ var import_invariant2 = require("@dxos/invariant");
54
59
  var import_log2 = require("@dxos/log");
60
+ var import_buf = require("@dxos/protocols/buf");
61
+ var import_messenger_pb = require("@dxos/protocols/buf/dxos/edge/messenger_pb");
62
+ var import_credentials = require("@dxos/credentials");
63
+ var import_invariant3 = require("@dxos/invariant");
64
+ var import_keyring = require("@dxos/keyring");
65
+ var import_keys = require("@dxos/keys");
66
+ var import_async3 = require("@dxos/async");
67
+ var import_context3 = require("@dxos/context");
68
+ var import_log3 = require("@dxos/log");
55
69
  var import_protocols = require("@dxos/protocols");
56
70
  var __dxlog_file = "/home/runner/work/dxos/dxos/packages/core/mesh/edge-client/src/edge-identity.ts";
57
71
  var handleAuthChallenge = async (failedResponse, identity) => {
@@ -89,6 +103,220 @@ var handleAuthChallenge = async (failedResponse, identity) => {
89
103
  });
90
104
  return import_proto.schema.getCodecForType("dxos.halo.credentials.Presentation").encode(presentation);
91
105
  };
106
+ function _ts_decorate(decorators, target, key, desc) {
107
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
108
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
109
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
110
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
111
+ }
112
+ var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/core/mesh/edge-client/src/edge-ws-connection.ts";
113
+ var SIGNAL_KEEPALIVE_INTERVAL = 4e3;
114
+ var SIGNAL_KEEPALIVE_TIMEOUT = 12e3;
115
+ var CLOUDFLARE_MESSAGE_LENGTH_LIMIT = 1024 * 1024;
116
+ var EdgeWsConnection = class extends import_context2.Resource {
117
+ constructor(_identity, _connectionInfo, _callbacks) {
118
+ super();
119
+ this._identity = _identity;
120
+ this._connectionInfo = _connectionInfo;
121
+ this._callbacks = _callbacks;
122
+ }
123
+ get info() {
124
+ return {
125
+ open: this.isOpen,
126
+ identity: this._identity.identityKey,
127
+ device: this._identity.peerKey
128
+ };
129
+ }
130
+ send(message) {
131
+ (0, import_invariant2.invariant)(this._ws, void 0, {
132
+ F: __dxlog_file2,
133
+ L: 54,
134
+ S: this,
135
+ A: [
136
+ "this._ws",
137
+ ""
138
+ ]
139
+ });
140
+ (0, import_log2.log)("sending...", {
141
+ peerKey: this._identity.peerKey,
142
+ payload: import_chunk_ANV2HBEH.protocol.getPayloadType(message)
143
+ }, {
144
+ F: __dxlog_file2,
145
+ L: 55,
146
+ S: this,
147
+ C: (f, a) => f(...a)
148
+ });
149
+ const encoded = import_buf.buf.toBinary(import_messenger_pb.MessageSchema, message);
150
+ if (encoded.byteLength >= CLOUDFLARE_MESSAGE_LENGTH_LIMIT) {
151
+ import_log2.log.error("edge message dropped due to websocket message limit", {
152
+ byteLength: encoded.byteLength,
153
+ serviceId: message.serviceId,
154
+ payload: import_chunk_ANV2HBEH.protocol.getPayloadType(message)
155
+ }, {
156
+ F: __dxlog_file2,
157
+ L: 58,
158
+ S: this,
159
+ C: (f, a) => f(...a)
160
+ });
161
+ return;
162
+ }
163
+ this._ws.send(encoded);
164
+ }
165
+ async _open() {
166
+ this._ws = new import_isomorphic_ws.default(this._connectionInfo.url.toString(), this._connectionInfo.protocolHeader ? [
167
+ this._connectionInfo.protocolHeader
168
+ ] : []);
169
+ this._ws.onopen = () => {
170
+ if (this.isOpen) {
171
+ (0, import_log2.log)("connected", void 0, {
172
+ F: __dxlog_file2,
173
+ L: 76,
174
+ S: this,
175
+ C: (f, a) => f(...a)
176
+ });
177
+ this._callbacks.onConnected();
178
+ this._scheduleHeartbeats();
179
+ } else {
180
+ import_log2.log.verbose("connected after becoming inactive", {
181
+ currentIdentity: this._identity
182
+ }, {
183
+ F: __dxlog_file2,
184
+ L: 80,
185
+ S: this,
186
+ C: (f, a) => f(...a)
187
+ });
188
+ }
189
+ };
190
+ this._ws.onclose = (event) => {
191
+ if (this.isOpen) {
192
+ import_log2.log.warn("disconnected while being open", {
193
+ code: event.code,
194
+ reason: event.reason
195
+ }, {
196
+ F: __dxlog_file2,
197
+ L: 85,
198
+ S: this,
199
+ C: (f, a) => f(...a)
200
+ });
201
+ this._callbacks.onRestartRequired();
202
+ }
203
+ };
204
+ this._ws.onerror = (event) => {
205
+ if (this.isOpen) {
206
+ import_log2.log.warn("edge connection socket error", {
207
+ error: event.error,
208
+ info: event.message
209
+ }, {
210
+ F: __dxlog_file2,
211
+ L: 91,
212
+ S: this,
213
+ C: (f, a) => f(...a)
214
+ });
215
+ this._callbacks.onRestartRequired();
216
+ } else {
217
+ import_log2.log.verbose("error ignored on closed connection", {
218
+ error: event.error
219
+ }, {
220
+ F: __dxlog_file2,
221
+ L: 94,
222
+ S: this,
223
+ C: (f, a) => f(...a)
224
+ });
225
+ }
226
+ };
227
+ this._ws.onmessage = async (event) => {
228
+ if (!this.isOpen) {
229
+ import_log2.log.verbose("message ignored on closed connection", {
230
+ event: event.type
231
+ }, {
232
+ F: __dxlog_file2,
233
+ L: 102,
234
+ S: this,
235
+ C: (f, a) => f(...a)
236
+ });
237
+ return;
238
+ }
239
+ if (event.data === "__pong__") {
240
+ this._rescheduleHeartbeatTimeout();
241
+ return;
242
+ }
243
+ const data = await (0, import_chunk_ANV2HBEH.toUint8Array)(event.data);
244
+ if (this.isOpen) {
245
+ const message = import_buf.buf.fromBinary(import_messenger_pb.MessageSchema, data);
246
+ (0, import_log2.log)("received", {
247
+ from: message.source,
248
+ payload: import_chunk_ANV2HBEH.protocol.getPayloadType(message)
249
+ }, {
250
+ F: __dxlog_file2,
251
+ L: 112,
252
+ S: this,
253
+ C: (f, a) => f(...a)
254
+ });
255
+ this._callbacks.onMessage(message);
256
+ }
257
+ };
258
+ }
259
+ async _close() {
260
+ void this._inactivityTimeoutCtx?.dispose().catch(() => {
261
+ });
262
+ try {
263
+ this._ws?.close();
264
+ this._ws = void 0;
265
+ } catch (err) {
266
+ if (err instanceof Error && err.message.includes("WebSocket is closed before the connection is established.")) {
267
+ return;
268
+ }
269
+ import_log2.log.warn("Error closing websocket", {
270
+ err
271
+ }, {
272
+ F: __dxlog_file2,
273
+ L: 128,
274
+ S: this,
275
+ C: (f, a) => f(...a)
276
+ });
277
+ }
278
+ }
279
+ _scheduleHeartbeats() {
280
+ (0, import_invariant2.invariant)(this._ws, void 0, {
281
+ F: __dxlog_file2,
282
+ L: 133,
283
+ S: this,
284
+ A: [
285
+ "this._ws",
286
+ ""
287
+ ]
288
+ });
289
+ (0, import_async2.scheduleTaskInterval)(this._ctx, async () => {
290
+ this._ws?.send("__ping__");
291
+ }, SIGNAL_KEEPALIVE_INTERVAL);
292
+ this._ws.send("__ping__");
293
+ this._rescheduleHeartbeatTimeout();
294
+ }
295
+ _rescheduleHeartbeatTimeout() {
296
+ if (!this.isOpen) {
297
+ return;
298
+ }
299
+ void this._inactivityTimeoutCtx?.dispose();
300
+ this._inactivityTimeoutCtx = new import_context2.Context(void 0, {
301
+ F: __dxlog_file2,
302
+ L: 152
303
+ });
304
+ (0, import_async2.scheduleTask)(this._inactivityTimeoutCtx, () => {
305
+ if (this.isOpen) {
306
+ import_log2.log.warn("restart due to inactivity timeout", void 0, {
307
+ F: __dxlog_file2,
308
+ L: 157,
309
+ S: this,
310
+ C: (f, a) => f(...a)
311
+ });
312
+ this._callbacks.onRestartRequired();
313
+ }
314
+ }, SIGNAL_KEEPALIVE_TIMEOUT);
315
+ }
316
+ };
317
+ _ts_decorate([
318
+ import_log2.logInfo
319
+ ], EdgeWsConnection.prototype, "info", null);
92
320
  var EdgeConnectionClosedError = class extends Error {
93
321
  constructor() {
94
322
  super("Edge connection closed.");
@@ -105,20 +333,19 @@ var getEdgeUrlWithProtocol = (baseUrl, protocol2) => {
105
333
  url.protocol = protocol2 + (isSecure ? "s" : "");
106
334
  return url.toString();
107
335
  };
108
- function _ts_decorate(decorators, target, key, desc) {
336
+ function _ts_decorate2(decorators, target, key, desc) {
109
337
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
110
338
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
111
339
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
112
340
  return c > 3 && r && Object.defineProperty(target, key, r), r;
113
341
  }
114
- var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/core/mesh/edge-client/src/edge-client.ts";
342
+ var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/core/mesh/edge-client/src/edge-client.ts";
115
343
  var DEFAULT_TIMEOUT = 1e4;
116
344
  var EdgeClient = class extends import_context.Resource {
117
345
  constructor(_identity, _config) {
118
346
  super();
119
347
  this._identity = _identity;
120
348
  this._config = _config;
121
- this.statusChanged = new import_async.Event();
122
349
  this._persistentLifecycle = new import_async.PersistentLifecycle({
123
350
  start: async () => this._connect(),
124
351
  stop: async (state) => this._disconnect(state)
@@ -134,13 +361,12 @@ var EdgeClient = class extends import_context.Resource {
134
361
  get info() {
135
362
  return {
136
363
  open: this.isOpen,
137
- status: this.status,
138
364
  identity: this._identity.identityKey,
139
365
  device: this._identity.peerKey
140
366
  };
141
367
  }
142
- get status() {
143
- return Boolean(this._currentConnection) && this._ready.state === import_async.TriggerState.RESOLVED ? import_services.EdgeStatus.CONNECTED : import_services.EdgeStatus.NOT_CONNECTED;
368
+ get isConnected() {
369
+ return Boolean(this._currentConnection) && this._ready.state === import_async.TriggerState.RESOLVED;
144
370
  }
145
371
  get identityKey() {
146
372
  return this._identity.identityKey;
@@ -154,14 +380,14 @@ var EdgeClient = class extends import_context.Resource {
154
380
  identity,
155
381
  oldIdentity: this._identity
156
382
  }, {
157
- F: __dxlog_file2,
158
- L: 99,
383
+ F: __dxlog_file3,
384
+ L: 94,
159
385
  S: this,
160
386
  C: (f, a) => f(...a)
161
387
  });
162
388
  this._identity = identity;
163
389
  this._closeCurrentConnection(new EdgeIdentityChangedError());
164
- void this._persistentLifecycle.scheduleRestart();
390
+ this._persistentLifecycle.scheduleRestart();
165
391
  }
166
392
  }
167
393
  onMessage(listener) {
@@ -177,8 +403,8 @@ var EdgeClient = class extends import_context.Resource {
177
403
  listener();
178
404
  } catch (error) {
179
405
  import_log.log.catch(error, void 0, {
180
- F: __dxlog_file2,
181
- L: 121,
406
+ F: __dxlog_file3,
407
+ L: 116,
182
408
  S: this,
183
409
  C: (f, a) => f(...a)
184
410
  });
@@ -195,8 +421,8 @@ var EdgeClient = class extends import_context.Resource {
195
421
  (0, import_log.log)("opening...", {
196
422
  info: this.info
197
423
  }, {
198
- F: __dxlog_file2,
199
- L: 133,
424
+ F: __dxlog_file3,
425
+ L: 128,
200
426
  S: this,
201
427
  C: (f, a) => f(...a)
202
428
  });
@@ -204,8 +430,8 @@ var EdgeClient = class extends import_context.Resource {
204
430
  import_log.log.warn("Error while opening connection", {
205
431
  err
206
432
  }, {
207
- F: __dxlog_file2,
208
- L: 135,
433
+ F: __dxlog_file3,
434
+ L: 130,
209
435
  S: this,
210
436
  C: (f, a) => f(...a)
211
437
  });
@@ -218,8 +444,8 @@ var EdgeClient = class extends import_context.Resource {
218
444
  (0, import_log.log)("closing...", {
219
445
  peerKey: this._identity.peerKey
220
446
  }, {
221
- F: __dxlog_file2,
222
- L: 143,
447
+ F: __dxlog_file3,
448
+ L: 138,
223
449
  S: this,
224
450
  C: (f, a) => f(...a)
225
451
  });
@@ -235,8 +461,8 @@ var EdgeClient = class extends import_context.Resource {
235
461
  const protocolHeader = this._config.disableAuth ? void 0 : await this._createAuthHeader(path);
236
462
  if (this._identity !== identity) {
237
463
  (0, import_log.log)("identity changed during auth header request", void 0, {
238
- F: __dxlog_file2,
239
- L: 157,
464
+ F: __dxlog_file3,
465
+ L: 152,
240
466
  S: this,
241
467
  C: (f, a) => f(...a)
242
468
  });
@@ -248,12 +474,12 @@ var EdgeClient = class extends import_context.Resource {
248
474
  url: url.toString(),
249
475
  protocolHeader
250
476
  }, {
251
- F: __dxlog_file2,
252
- L: 163,
477
+ F: __dxlog_file3,
478
+ L: 158,
253
479
  S: this,
254
480
  C: (f, a) => f(...a)
255
481
  });
256
- const connection = new import_chunk_CNAHGYSS.EdgeWsConnection(identity, {
482
+ const connection = new EdgeWsConnection(identity, {
257
483
  url,
258
484
  protocolHeader
259
485
  }, {
@@ -263,8 +489,8 @@ var EdgeClient = class extends import_context.Resource {
263
489
  this._notifyReconnected();
264
490
  } else {
265
491
  import_log.log.verbose("connected callback ignored, because connection is not active", void 0, {
266
- F: __dxlog_file2,
267
- L: 173,
492
+ F: __dxlog_file3,
493
+ L: 168,
268
494
  S: this,
269
495
  C: (f, a) => f(...a)
270
496
  });
@@ -273,11 +499,11 @@ var EdgeClient = class extends import_context.Resource {
273
499
  onRestartRequired: () => {
274
500
  if (this._isActive(connection)) {
275
501
  this._closeCurrentConnection();
276
- void this._persistentLifecycle.scheduleRestart();
502
+ this._persistentLifecycle.scheduleRestart();
277
503
  } else {
278
504
  import_log.log.verbose("restart requested by inactive connection", void 0, {
279
- F: __dxlog_file2,
280
- L: 181,
505
+ F: __dxlog_file3,
506
+ L: 176,
281
507
  S: this,
282
508
  C: (f, a) => f(...a)
283
509
  });
@@ -292,8 +518,8 @@ var EdgeClient = class extends import_context.Resource {
292
518
  from: message.source,
293
519
  type: message.payload?.typeUrl
294
520
  }, {
295
- F: __dxlog_file2,
296
- L: 189,
521
+ F: __dxlog_file3,
522
+ L: 184,
297
523
  S: this,
298
524
  C: (f, a) => f(...a)
299
525
  });
@@ -312,16 +538,13 @@ var EdgeClient = class extends import_context.Resource {
312
538
  }
313
539
  async _disconnect(state) {
314
540
  await state.close();
315
- this.statusChanged.emit(this.status);
316
541
  }
317
542
  _closeCurrentConnection(error = new EdgeConnectionClosedError()) {
318
543
  this._currentConnection = void 0;
319
544
  this._ready.throw(error);
320
545
  this._ready.reset();
321
- this.statusChanged.emit(this.status);
322
546
  }
323
547
  _notifyReconnected() {
324
- this.statusChanged.emit(this.status);
325
548
  for (const listener of this._reconnectListeners) {
326
549
  try {
327
550
  listener();
@@ -329,8 +552,8 @@ var EdgeClient = class extends import_context.Resource {
329
552
  import_log.log.error("ws reconnect listener failed", {
330
553
  err
331
554
  }, {
332
- F: __dxlog_file2,
333
- L: 225,
555
+ F: __dxlog_file3,
556
+ L: 217,
334
557
  S: this,
335
558
  C: (f, a) => f(...a)
336
559
  });
@@ -344,10 +567,10 @@ var EdgeClient = class extends import_context.Resource {
344
567
  } catch (err) {
345
568
  import_log.log.error("ws incoming message processing failed", {
346
569
  err,
347
- payload: import_chunk_CNAHGYSS.protocol.getPayloadType(message)
570
+ payload: import_chunk_ANV2HBEH.protocol.getPayloadType(message)
348
571
  }, {
349
- F: __dxlog_file2,
350
- L: 235,
572
+ F: __dxlog_file3,
573
+ L: 227,
351
574
  S: this,
352
575
  C: (f, a) => f(...a)
353
576
  });
@@ -361,8 +584,8 @@ var EdgeClient = class extends import_context.Resource {
361
584
  async send(message) {
362
585
  if (this._ready.state !== import_async.TriggerState.RESOLVED) {
363
586
  (0, import_log.log)("waiting for websocket to become ready", void 0, {
364
- F: __dxlog_file2,
365
- L: 246,
587
+ F: __dxlog_file3,
588
+ L: 238,
366
589
  S: this,
367
590
  C: (f, a) => f(...a)
368
591
  });
@@ -391,8 +614,8 @@ var EdgeClient = class extends import_context.Resource {
391
614
  status: response.status,
392
615
  statusText: response.statusText
393
616
  }, {
394
- F: __dxlog_file2,
395
- L: 271,
617
+ F: __dxlog_file3,
618
+ L: 263,
396
619
  S: this,
397
620
  C: (f, a) => f(...a)
398
621
  });
@@ -400,14 +623,14 @@ var EdgeClient = class extends import_context.Resource {
400
623
  }
401
624
  }
402
625
  };
403
- _ts_decorate([
626
+ _ts_decorate2([
404
627
  import_log.logInfo
405
628
  ], EdgeClient.prototype, "info", null);
406
629
  var encodePresentationWsAuthHeader = (encodedPresentation) => {
407
630
  const encodedToken = Buffer.from(encodedPresentation).toString("base64").replace(/=*$/, "").replaceAll("/", "|");
408
631
  return `base64url.bearer.authorization.dxos.org.${encodedToken}`;
409
632
  };
410
- var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/core/mesh/edge-client/src/auth.ts";
633
+ var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/core/mesh/edge-client/src/auth.ts";
411
634
  var createDeviceEdgeIdentity = async (signer, key) => {
412
635
  return {
413
636
  identityKey: key.toHex(),
@@ -451,8 +674,8 @@ var createChainEdgeIdentity = async (signer, identityKey, peerKey, chain, creden
451
674
  identityKey: identityKey.toHex(),
452
675
  peerKey: peerKey.toHex(),
453
676
  presentCredentials: async ({ challenge }) => {
454
- (0, import_invariant2.invariant)(chain, void 0, {
455
- F: __dxlog_file3,
677
+ (0, import_invariant3.invariant)(chain, void 0, {
678
+ F: __dxlog_file4,
456
679
  L: 75,
457
680
  S: void 0,
458
681
  A: [
@@ -512,17 +735,17 @@ var createStubEdgeIdentity = () => {
512
735
  }
513
736
  };
514
737
  };
515
- var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/core/mesh/edge-client/src/edge-http-client.ts";
738
+ var __dxlog_file5 = "/home/runner/work/dxos/dxos/packages/core/mesh/edge-client/src/edge-http-client.ts";
516
739
  var DEFAULT_RETRY_TIMEOUT = 1500;
517
740
  var DEFAULT_RETRY_JITTER = 500;
518
741
  var DEFAULT_MAX_RETRIES_COUNT = 3;
519
742
  var EdgeHttpClient = class {
520
743
  constructor(baseUrl) {
521
744
  this._baseUrl = getEdgeUrlWithProtocol(baseUrl, "http");
522
- (0, import_log2.log)("created", {
745
+ (0, import_log3.log)("created", {
523
746
  url: this._baseUrl
524
747
  }, {
525
- F: __dxlog_file4,
748
+ F: __dxlog_file5,
526
749
  L: 53,
527
750
  S: this,
528
751
  C: (f, a) => f(...a)
@@ -654,8 +877,8 @@ var EdgeHttpClient = class {
654
877
  });
655
878
  }
656
879
  async _call(path, args) {
657
- const requestContext = args.context ?? new import_context2.Context(void 0, {
658
- F: __dxlog_file4,
880
+ const requestContext = args.context ?? new import_context3.Context(void 0, {
881
+ F: __dxlog_file5,
659
882
  L: 192
660
883
  });
661
884
  const shouldRetry = createRetryHandler(args);
@@ -667,12 +890,12 @@ var EdgeHttpClient = class {
667
890
  }
668
891
  url += `?${queryParams.toString()}`;
669
892
  }
670
- (0, import_log2.log)("call", {
893
+ (0, import_log3.log)("call", {
671
894
  method: args.method,
672
895
  path,
673
896
  request: args.body
674
897
  }, {
675
- F: __dxlog_file4,
898
+ F: __dxlog_file5,
676
899
  L: 204,
677
900
  S: this,
678
901
  C: (f, a) => f(...a)
@@ -691,11 +914,11 @@ var EdgeHttpClient = class {
691
914
  if (body.success) {
692
915
  return body.data;
693
916
  }
694
- (0, import_log2.log)("unsuccessful edge response", {
917
+ (0, import_log3.log)("unsuccessful edge response", {
695
918
  path,
696
919
  body
697
920
  }, {
698
- F: __dxlog_file4,
921
+ F: __dxlog_file5,
699
922
  L: 223,
700
923
  S: this,
701
924
  C: (f, a) => f(...a)
@@ -716,11 +939,11 @@ var EdgeHttpClient = class {
716
939
  processingError = import_protocols.EdgeCallFailedError.fromProcessingFailureCause(error);
717
940
  }
718
941
  if (processingError.isRetryable && await shouldRetry(requestContext, retryAfterHeaderValue)) {
719
- (0, import_log2.log)("retrying edge request", {
942
+ (0, import_log3.log)("retrying edge request", {
720
943
  path,
721
944
  processingError
722
945
  }, {
723
- F: __dxlog_file4,
946
+ F: __dxlog_file5,
724
947
  L: 242,
725
948
  S: this,
726
949
  C: (f, a) => f(...a)
@@ -732,8 +955,8 @@ var EdgeHttpClient = class {
732
955
  }
733
956
  async _handleUnauthorized(response) {
734
957
  if (!this._edgeIdentity) {
735
- import_log2.log.warn("edge unauthorized response received before identity was set", void 0, {
736
- F: __dxlog_file4,
958
+ import_log3.log.warn("edge unauthorized response received before identity was set", void 0, {
959
+ F: __dxlog_file5,
737
960
  L: 251,
738
961
  S: this,
739
962
  C: (f, a) => f(...a)
@@ -742,8 +965,8 @@ var EdgeHttpClient = class {
742
965
  }
743
966
  const challenge = await handleAuthChallenge(response, this._edgeIdentity);
744
967
  this._authHeader = encodeAuthHeader(challenge);
745
- (0, import_log2.log)("auth header updated", void 0, {
746
- F: __dxlog_file4,
968
+ (0, import_log3.log)("auth header updated", void 0, {
969
+ F: __dxlog_file5,
747
970
  L: 256,
748
971
  S: this,
749
972
  C: (f, a) => f(...a)
@@ -764,10 +987,10 @@ var createRetryHandler = (args) => {
764
987
  return false;
765
988
  }
766
989
  if (retryAfter) {
767
- await (0, import_async2.sleep)(retryAfter);
990
+ await (0, import_async3.sleep)(retryAfter);
768
991
  } else {
769
992
  const timeout = baseTimeout + Math.random() * jitter;
770
- await (0, import_async2.sleep)(timeout);
993
+ await (0, import_async3.sleep)(timeout);
771
994
  }
772
995
  return true;
773
996
  };
@@ -787,13 +1010,11 @@ var encodeAuthHeader = (challenge) => {
787
1010
  };
788
1011
  // Annotate the CommonJS export names for ESM import in node:
789
1012
  0 && (module.exports = {
790
- CLOUDFLARE_MESSAGE_LENGTH_LIMIT,
791
1013
  EdgeClient,
792
1014
  EdgeConnectionClosedError,
793
1015
  EdgeHttpClient,
794
1016
  EdgeIdentityChangedError,
795
1017
  Protocol,
796
- WebSocketMuxer,
797
1018
  createChainEdgeIdentity,
798
1019
  createDeviceEdgeIdentity,
799
1020
  createEphemeralEdgeIdentity,