@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,21 +1,17 @@
1
1
  import {
2
- CLOUDFLARE_MESSAGE_LENGTH_LIMIT,
3
- EdgeWsConnection,
4
2
  Protocol,
5
- WebSocketMuxer,
6
3
  getTypename,
7
4
  protocol,
8
5
  toUint8Array
9
- } from "./chunk-5DDWS5EC.mjs";
6
+ } from "./chunk-ZWJXA37R.mjs";
10
7
 
11
8
  // packages/core/mesh/edge-client/src/index.ts
12
9
  export * from "@dxos/protocols/buf/dxos/edge/messenger_pb";
13
10
 
14
11
  // packages/core/mesh/edge-client/src/edge-client.ts
15
- import { Trigger, scheduleMicroTask, TriggerState, PersistentLifecycle, Event } from "@dxos/async";
16
- import { Resource } from "@dxos/context";
17
- import { log, logInfo } from "@dxos/log";
18
- import { EdgeStatus } from "@dxos/protocols/proto/dxos/client/services";
12
+ import { Trigger, scheduleMicroTask, TriggerState, PersistentLifecycle } from "@dxos/async";
13
+ import { Resource as Resource2 } from "@dxos/context";
14
+ import { log as log2, logInfo as logInfo2 } from "@dxos/log";
19
15
 
20
16
  // packages/core/mesh/edge-client/src/edge-identity.ts
21
17
  import { invariant } from "@dxos/invariant";
@@ -57,6 +53,229 @@ var handleAuthChallenge = async (failedResponse, identity) => {
57
53
  return schema.getCodecForType("dxos.halo.credentials.Presentation").encode(presentation);
58
54
  };
59
55
 
56
+ // packages/core/mesh/edge-client/src/edge-ws-connection.ts
57
+ import WebSocket from "isomorphic-ws";
58
+ import { scheduleTask, scheduleTaskInterval } from "@dxos/async";
59
+ import { Context, Resource } from "@dxos/context";
60
+ import { invariant as invariant2 } from "@dxos/invariant";
61
+ import { log, logInfo } from "@dxos/log";
62
+ import { buf } from "@dxos/protocols/buf";
63
+ import { MessageSchema } from "@dxos/protocols/buf/dxos/edge/messenger_pb";
64
+ function _ts_decorate(decorators, target, key, desc) {
65
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
66
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
67
+ 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;
68
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
69
+ }
70
+ var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/core/mesh/edge-client/src/edge-ws-connection.ts";
71
+ var SIGNAL_KEEPALIVE_INTERVAL = 4e3;
72
+ var SIGNAL_KEEPALIVE_TIMEOUT = 12e3;
73
+ var CLOUDFLARE_MESSAGE_LENGTH_LIMIT = 1024 * 1024;
74
+ var EdgeWsConnection = class extends Resource {
75
+ constructor(_identity, _connectionInfo, _callbacks) {
76
+ super();
77
+ this._identity = _identity;
78
+ this._connectionInfo = _connectionInfo;
79
+ this._callbacks = _callbacks;
80
+ }
81
+ get info() {
82
+ return {
83
+ open: this.isOpen,
84
+ identity: this._identity.identityKey,
85
+ device: this._identity.peerKey
86
+ };
87
+ }
88
+ send(message) {
89
+ invariant2(this._ws, void 0, {
90
+ F: __dxlog_file2,
91
+ L: 54,
92
+ S: this,
93
+ A: [
94
+ "this._ws",
95
+ ""
96
+ ]
97
+ });
98
+ log("sending...", {
99
+ peerKey: this._identity.peerKey,
100
+ payload: protocol.getPayloadType(message)
101
+ }, {
102
+ F: __dxlog_file2,
103
+ L: 55,
104
+ S: this,
105
+ C: (f, a) => f(...a)
106
+ });
107
+ const encoded = buf.toBinary(MessageSchema, message);
108
+ if (encoded.byteLength >= CLOUDFLARE_MESSAGE_LENGTH_LIMIT) {
109
+ log.error("edge message dropped due to websocket message limit", {
110
+ byteLength: encoded.byteLength,
111
+ serviceId: message.serviceId,
112
+ payload: protocol.getPayloadType(message)
113
+ }, {
114
+ F: __dxlog_file2,
115
+ L: 58,
116
+ S: this,
117
+ C: (f, a) => f(...a)
118
+ });
119
+ return;
120
+ }
121
+ this._ws.send(encoded);
122
+ }
123
+ async _open() {
124
+ this._ws = new WebSocket(this._connectionInfo.url.toString(), this._connectionInfo.protocolHeader ? [
125
+ this._connectionInfo.protocolHeader
126
+ ] : []);
127
+ this._ws.onopen = () => {
128
+ if (this.isOpen) {
129
+ log("connected", void 0, {
130
+ F: __dxlog_file2,
131
+ L: 76,
132
+ S: this,
133
+ C: (f, a) => f(...a)
134
+ });
135
+ this._callbacks.onConnected();
136
+ this._scheduleHeartbeats();
137
+ } else {
138
+ log.verbose("connected after becoming inactive", {
139
+ currentIdentity: this._identity
140
+ }, {
141
+ F: __dxlog_file2,
142
+ L: 80,
143
+ S: this,
144
+ C: (f, a) => f(...a)
145
+ });
146
+ }
147
+ };
148
+ this._ws.onclose = (event) => {
149
+ if (this.isOpen) {
150
+ log.warn("disconnected while being open", {
151
+ code: event.code,
152
+ reason: event.reason
153
+ }, {
154
+ F: __dxlog_file2,
155
+ L: 85,
156
+ S: this,
157
+ C: (f, a) => f(...a)
158
+ });
159
+ this._callbacks.onRestartRequired();
160
+ }
161
+ };
162
+ this._ws.onerror = (event) => {
163
+ if (this.isOpen) {
164
+ log.warn("edge connection socket error", {
165
+ error: event.error,
166
+ info: event.message
167
+ }, {
168
+ F: __dxlog_file2,
169
+ L: 91,
170
+ S: this,
171
+ C: (f, a) => f(...a)
172
+ });
173
+ this._callbacks.onRestartRequired();
174
+ } else {
175
+ log.verbose("error ignored on closed connection", {
176
+ error: event.error
177
+ }, {
178
+ F: __dxlog_file2,
179
+ L: 94,
180
+ S: this,
181
+ C: (f, a) => f(...a)
182
+ });
183
+ }
184
+ };
185
+ this._ws.onmessage = async (event) => {
186
+ if (!this.isOpen) {
187
+ log.verbose("message ignored on closed connection", {
188
+ event: event.type
189
+ }, {
190
+ F: __dxlog_file2,
191
+ L: 102,
192
+ S: this,
193
+ C: (f, a) => f(...a)
194
+ });
195
+ return;
196
+ }
197
+ if (event.data === "__pong__") {
198
+ this._rescheduleHeartbeatTimeout();
199
+ return;
200
+ }
201
+ const data = await toUint8Array(event.data);
202
+ if (this.isOpen) {
203
+ const message = buf.fromBinary(MessageSchema, data);
204
+ log("received", {
205
+ from: message.source,
206
+ payload: protocol.getPayloadType(message)
207
+ }, {
208
+ F: __dxlog_file2,
209
+ L: 112,
210
+ S: this,
211
+ C: (f, a) => f(...a)
212
+ });
213
+ this._callbacks.onMessage(message);
214
+ }
215
+ };
216
+ }
217
+ async _close() {
218
+ void this._inactivityTimeoutCtx?.dispose().catch(() => {
219
+ });
220
+ try {
221
+ this._ws?.close();
222
+ this._ws = void 0;
223
+ } catch (err) {
224
+ if (err instanceof Error && err.message.includes("WebSocket is closed before the connection is established.")) {
225
+ return;
226
+ }
227
+ log.warn("Error closing websocket", {
228
+ err
229
+ }, {
230
+ F: __dxlog_file2,
231
+ L: 128,
232
+ S: this,
233
+ C: (f, a) => f(...a)
234
+ });
235
+ }
236
+ }
237
+ _scheduleHeartbeats() {
238
+ invariant2(this._ws, void 0, {
239
+ F: __dxlog_file2,
240
+ L: 133,
241
+ S: this,
242
+ A: [
243
+ "this._ws",
244
+ ""
245
+ ]
246
+ });
247
+ scheduleTaskInterval(this._ctx, async () => {
248
+ this._ws?.send("__ping__");
249
+ }, SIGNAL_KEEPALIVE_INTERVAL);
250
+ this._ws.send("__ping__");
251
+ this._rescheduleHeartbeatTimeout();
252
+ }
253
+ _rescheduleHeartbeatTimeout() {
254
+ if (!this.isOpen) {
255
+ return;
256
+ }
257
+ void this._inactivityTimeoutCtx?.dispose();
258
+ this._inactivityTimeoutCtx = new Context(void 0, {
259
+ F: __dxlog_file2,
260
+ L: 152
261
+ });
262
+ scheduleTask(this._inactivityTimeoutCtx, () => {
263
+ if (this.isOpen) {
264
+ log.warn("restart due to inactivity timeout", void 0, {
265
+ F: __dxlog_file2,
266
+ L: 157,
267
+ S: this,
268
+ C: (f, a) => f(...a)
269
+ });
270
+ this._callbacks.onRestartRequired();
271
+ }
272
+ }, SIGNAL_KEEPALIVE_TIMEOUT);
273
+ }
274
+ };
275
+ _ts_decorate([
276
+ logInfo
277
+ ], EdgeWsConnection.prototype, "info", null);
278
+
60
279
  // packages/core/mesh/edge-client/src/errors.ts
61
280
  var EdgeConnectionClosedError = class extends Error {
62
281
  constructor() {
@@ -78,20 +297,19 @@ var getEdgeUrlWithProtocol = (baseUrl, protocol2) => {
78
297
  };
79
298
 
80
299
  // packages/core/mesh/edge-client/src/edge-client.ts
81
- function _ts_decorate(decorators, target, key, desc) {
300
+ function _ts_decorate2(decorators, target, key, desc) {
82
301
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
83
302
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
84
303
  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;
85
304
  return c > 3 && r && Object.defineProperty(target, key, r), r;
86
305
  }
87
- var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/core/mesh/edge-client/src/edge-client.ts";
306
+ var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/core/mesh/edge-client/src/edge-client.ts";
88
307
  var DEFAULT_TIMEOUT = 1e4;
89
- var EdgeClient = class extends Resource {
308
+ var EdgeClient = class extends Resource2 {
90
309
  constructor(_identity, _config) {
91
310
  super();
92
311
  this._identity = _identity;
93
312
  this._config = _config;
94
- this.statusChanged = new Event();
95
313
  this._persistentLifecycle = new PersistentLifecycle({
96
314
  start: async () => this._connect(),
97
315
  stop: async (state) => this._disconnect(state)
@@ -107,13 +325,12 @@ var EdgeClient = class extends Resource {
107
325
  get info() {
108
326
  return {
109
327
  open: this.isOpen,
110
- status: this.status,
111
328
  identity: this._identity.identityKey,
112
329
  device: this._identity.peerKey
113
330
  };
114
331
  }
115
- get status() {
116
- return Boolean(this._currentConnection) && this._ready.state === TriggerState.RESOLVED ? EdgeStatus.CONNECTED : EdgeStatus.NOT_CONNECTED;
332
+ get isConnected() {
333
+ return Boolean(this._currentConnection) && this._ready.state === TriggerState.RESOLVED;
117
334
  }
118
335
  get identityKey() {
119
336
  return this._identity.identityKey;
@@ -123,18 +340,18 @@ var EdgeClient = class extends Resource {
123
340
  }
124
341
  setIdentity(identity) {
125
342
  if (identity.identityKey !== this._identity.identityKey || identity.peerKey !== this._identity.peerKey) {
126
- log("Edge identity changed", {
343
+ log2("Edge identity changed", {
127
344
  identity,
128
345
  oldIdentity: this._identity
129
346
  }, {
130
- F: __dxlog_file2,
131
- L: 99,
347
+ F: __dxlog_file3,
348
+ L: 94,
132
349
  S: this,
133
350
  C: (f, a) => f(...a)
134
351
  });
135
352
  this._identity = identity;
136
353
  this._closeCurrentConnection(new EdgeIdentityChangedError());
137
- void this._persistentLifecycle.scheduleRestart();
354
+ this._persistentLifecycle.scheduleRestart();
138
355
  }
139
356
  }
140
357
  onMessage(listener) {
@@ -149,9 +366,9 @@ var EdgeClient = class extends Resource {
149
366
  try {
150
367
  listener();
151
368
  } catch (error) {
152
- log.catch(error, void 0, {
153
- F: __dxlog_file2,
154
- L: 121,
369
+ log2.catch(error, void 0, {
370
+ F: __dxlog_file3,
371
+ L: 116,
155
372
  S: this,
156
373
  C: (f, a) => f(...a)
157
374
  });
@@ -165,20 +382,20 @@ var EdgeClient = class extends Resource {
165
382
  * Open connection to messaging service.
166
383
  */
167
384
  async _open() {
168
- log("opening...", {
385
+ log2("opening...", {
169
386
  info: this.info
170
387
  }, {
171
- F: __dxlog_file2,
172
- L: 133,
388
+ F: __dxlog_file3,
389
+ L: 128,
173
390
  S: this,
174
391
  C: (f, a) => f(...a)
175
392
  });
176
393
  this._persistentLifecycle.open().catch((err) => {
177
- log.warn("Error while opening connection", {
394
+ log2.warn("Error while opening connection", {
178
395
  err
179
396
  }, {
180
- F: __dxlog_file2,
181
- L: 135,
397
+ F: __dxlog_file3,
398
+ L: 130,
182
399
  S: this,
183
400
  C: (f, a) => f(...a)
184
401
  });
@@ -188,11 +405,11 @@ var EdgeClient = class extends Resource {
188
405
  * Close connection and free resources.
189
406
  */
190
407
  async _close() {
191
- log("closing...", {
408
+ log2("closing...", {
192
409
  peerKey: this._identity.peerKey
193
410
  }, {
194
- F: __dxlog_file2,
195
- L: 143,
411
+ F: __dxlog_file3,
412
+ L: 138,
196
413
  S: this,
197
414
  C: (f, a) => f(...a)
198
415
  });
@@ -207,9 +424,9 @@ var EdgeClient = class extends Resource {
207
424
  const path = `/ws/${identity.identityKey}/${identity.peerKey}`;
208
425
  const protocolHeader = this._config.disableAuth ? void 0 : await this._createAuthHeader(path);
209
426
  if (this._identity !== identity) {
210
- log("identity changed during auth header request", void 0, {
211
- F: __dxlog_file2,
212
- L: 157,
427
+ log2("identity changed during auth header request", void 0, {
428
+ F: __dxlog_file3,
429
+ L: 152,
213
430
  S: this,
214
431
  C: (f, a) => f(...a)
215
432
  });
@@ -217,12 +434,12 @@ var EdgeClient = class extends Resource {
217
434
  }
218
435
  const restartRequired = new Trigger();
219
436
  const url = new URL(path, this._baseWsUrl);
220
- log("Opening websocket", {
437
+ log2("Opening websocket", {
221
438
  url: url.toString(),
222
439
  protocolHeader
223
440
  }, {
224
- F: __dxlog_file2,
225
- L: 163,
441
+ F: __dxlog_file3,
442
+ L: 158,
226
443
  S: this,
227
444
  C: (f, a) => f(...a)
228
445
  });
@@ -235,9 +452,9 @@ var EdgeClient = class extends Resource {
235
452
  this._ready.wake();
236
453
  this._notifyReconnected();
237
454
  } else {
238
- log.verbose("connected callback ignored, because connection is not active", void 0, {
239
- F: __dxlog_file2,
240
- L: 173,
455
+ log2.verbose("connected callback ignored, because connection is not active", void 0, {
456
+ F: __dxlog_file3,
457
+ L: 168,
241
458
  S: this,
242
459
  C: (f, a) => f(...a)
243
460
  });
@@ -246,11 +463,11 @@ var EdgeClient = class extends Resource {
246
463
  onRestartRequired: () => {
247
464
  if (this._isActive(connection)) {
248
465
  this._closeCurrentConnection();
249
- void this._persistentLifecycle.scheduleRestart();
466
+ this._persistentLifecycle.scheduleRestart();
250
467
  } else {
251
- log.verbose("restart requested by inactive connection", void 0, {
252
- F: __dxlog_file2,
253
- L: 181,
468
+ log2.verbose("restart requested by inactive connection", void 0, {
469
+ F: __dxlog_file3,
470
+ L: 176,
254
471
  S: this,
255
472
  C: (f, a) => f(...a)
256
473
  });
@@ -261,12 +478,12 @@ var EdgeClient = class extends Resource {
261
478
  if (this._isActive(connection)) {
262
479
  this._notifyMessageReceived(message);
263
480
  } else {
264
- log.verbose("ignored a message on inactive connection", {
481
+ log2.verbose("ignored a message on inactive connection", {
265
482
  from: message.source,
266
483
  type: message.payload?.typeUrl
267
484
  }, {
268
- F: __dxlog_file2,
269
- L: 189,
485
+ F: __dxlog_file3,
486
+ L: 184,
270
487
  S: this,
271
488
  C: (f, a) => f(...a)
272
489
  });
@@ -285,25 +502,22 @@ var EdgeClient = class extends Resource {
285
502
  }
286
503
  async _disconnect(state) {
287
504
  await state.close();
288
- this.statusChanged.emit(this.status);
289
505
  }
290
506
  _closeCurrentConnection(error = new EdgeConnectionClosedError()) {
291
507
  this._currentConnection = void 0;
292
508
  this._ready.throw(error);
293
509
  this._ready.reset();
294
- this.statusChanged.emit(this.status);
295
510
  }
296
511
  _notifyReconnected() {
297
- this.statusChanged.emit(this.status);
298
512
  for (const listener of this._reconnectListeners) {
299
513
  try {
300
514
  listener();
301
515
  } catch (err) {
302
- log.error("ws reconnect listener failed", {
516
+ log2.error("ws reconnect listener failed", {
303
517
  err
304
518
  }, {
305
- F: __dxlog_file2,
306
- L: 225,
519
+ F: __dxlog_file3,
520
+ L: 217,
307
521
  S: this,
308
522
  C: (f, a) => f(...a)
309
523
  });
@@ -315,12 +529,12 @@ var EdgeClient = class extends Resource {
315
529
  try {
316
530
  listener(message);
317
531
  } catch (err) {
318
- log.error("ws incoming message processing failed", {
532
+ log2.error("ws incoming message processing failed", {
319
533
  err,
320
534
  payload: protocol.getPayloadType(message)
321
535
  }, {
322
- F: __dxlog_file2,
323
- L: 235,
536
+ F: __dxlog_file3,
537
+ L: 227,
324
538
  S: this,
325
539
  C: (f, a) => f(...a)
326
540
  });
@@ -333,9 +547,9 @@ var EdgeClient = class extends Resource {
333
547
  */
334
548
  async send(message) {
335
549
  if (this._ready.state !== TriggerState.RESOLVED) {
336
- log("waiting for websocket to become ready", void 0, {
337
- F: __dxlog_file2,
338
- L: 246,
550
+ log2("waiting for websocket to become ready", void 0, {
551
+ F: __dxlog_file3,
552
+ L: 238,
339
553
  S: this,
340
554
  C: (f, a) => f(...a)
341
555
  });
@@ -360,12 +574,12 @@ var EdgeClient = class extends Resource {
360
574
  if (response.status === 401) {
361
575
  return encodePresentationWsAuthHeader(await handleAuthChallenge(response, this._identity));
362
576
  } else {
363
- log.warn("no auth challenge from edge", {
577
+ log2.warn("no auth challenge from edge", {
364
578
  status: response.status,
365
579
  statusText: response.statusText
366
580
  }, {
367
- F: __dxlog_file2,
368
- L: 271,
581
+ F: __dxlog_file3,
582
+ L: 263,
369
583
  S: this,
370
584
  C: (f, a) => f(...a)
371
585
  });
@@ -373,8 +587,8 @@ var EdgeClient = class extends Resource {
373
587
  }
374
588
  }
375
589
  };
376
- _ts_decorate([
377
- logInfo
590
+ _ts_decorate2([
591
+ logInfo2
378
592
  ], EdgeClient.prototype, "info", null);
379
593
  var encodePresentationWsAuthHeader = (encodedPresentation) => {
380
594
  const encodedToken = Buffer.from(encodedPresentation).toString("base64").replace(/=*$/, "").replaceAll("/", "|");
@@ -383,10 +597,10 @@ var encodePresentationWsAuthHeader = (encodedPresentation) => {
383
597
 
384
598
  // packages/core/mesh/edge-client/src/auth.ts
385
599
  import { createCredential, signPresentation } from "@dxos/credentials";
386
- import { invariant as invariant2 } from "@dxos/invariant";
600
+ import { invariant as invariant3 } from "@dxos/invariant";
387
601
  import { Keyring } from "@dxos/keyring";
388
602
  import { PublicKey } from "@dxos/keys";
389
- var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/core/mesh/edge-client/src/auth.ts";
603
+ var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/core/mesh/edge-client/src/auth.ts";
390
604
  var createDeviceEdgeIdentity = async (signer, key) => {
391
605
  return {
392
606
  identityKey: key.toHex(),
@@ -430,8 +644,8 @@ var createChainEdgeIdentity = async (signer, identityKey, peerKey, chain, creden
430
644
  identityKey: identityKey.toHex(),
431
645
  peerKey: peerKey.toHex(),
432
646
  presentCredentials: async ({ challenge }) => {
433
- invariant2(chain, void 0, {
434
- F: __dxlog_file3,
647
+ invariant3(chain, void 0, {
648
+ F: __dxlog_file4,
435
649
  L: 75,
436
650
  S: void 0,
437
651
  A: [
@@ -494,20 +708,20 @@ var createStubEdgeIdentity = () => {
494
708
 
495
709
  // packages/core/mesh/edge-client/src/edge-http-client.ts
496
710
  import { sleep } from "@dxos/async";
497
- import { Context } from "@dxos/context";
498
- import { log as log2 } from "@dxos/log";
711
+ import { Context as Context2 } from "@dxos/context";
712
+ import { log as log3 } from "@dxos/log";
499
713
  import { EdgeCallFailedError, EdgeAuthChallengeError } from "@dxos/protocols";
500
- var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/core/mesh/edge-client/src/edge-http-client.ts";
714
+ var __dxlog_file5 = "/home/runner/work/dxos/dxos/packages/core/mesh/edge-client/src/edge-http-client.ts";
501
715
  var DEFAULT_RETRY_TIMEOUT = 1500;
502
716
  var DEFAULT_RETRY_JITTER = 500;
503
717
  var DEFAULT_MAX_RETRIES_COUNT = 3;
504
718
  var EdgeHttpClient = class {
505
719
  constructor(baseUrl) {
506
720
  this._baseUrl = getEdgeUrlWithProtocol(baseUrl, "http");
507
- log2("created", {
721
+ log3("created", {
508
722
  url: this._baseUrl
509
723
  }, {
510
- F: __dxlog_file4,
724
+ F: __dxlog_file5,
511
725
  L: 53,
512
726
  S: this,
513
727
  C: (f, a) => f(...a)
@@ -639,8 +853,8 @@ var EdgeHttpClient = class {
639
853
  });
640
854
  }
641
855
  async _call(path, args) {
642
- const requestContext = args.context ?? new Context(void 0, {
643
- F: __dxlog_file4,
856
+ const requestContext = args.context ?? new Context2(void 0, {
857
+ F: __dxlog_file5,
644
858
  L: 192
645
859
  });
646
860
  const shouldRetry = createRetryHandler(args);
@@ -652,12 +866,12 @@ var EdgeHttpClient = class {
652
866
  }
653
867
  url += `?${queryParams.toString()}`;
654
868
  }
655
- log2("call", {
869
+ log3("call", {
656
870
  method: args.method,
657
871
  path,
658
872
  request: args.body
659
873
  }, {
660
- F: __dxlog_file4,
874
+ F: __dxlog_file5,
661
875
  L: 204,
662
876
  S: this,
663
877
  C: (f, a) => f(...a)
@@ -676,11 +890,11 @@ var EdgeHttpClient = class {
676
890
  if (body.success) {
677
891
  return body.data;
678
892
  }
679
- log2("unsuccessful edge response", {
893
+ log3("unsuccessful edge response", {
680
894
  path,
681
895
  body
682
896
  }, {
683
- F: __dxlog_file4,
897
+ F: __dxlog_file5,
684
898
  L: 223,
685
899
  S: this,
686
900
  C: (f, a) => f(...a)
@@ -701,11 +915,11 @@ var EdgeHttpClient = class {
701
915
  processingError = EdgeCallFailedError.fromProcessingFailureCause(error);
702
916
  }
703
917
  if (processingError.isRetryable && await shouldRetry(requestContext, retryAfterHeaderValue)) {
704
- log2("retrying edge request", {
918
+ log3("retrying edge request", {
705
919
  path,
706
920
  processingError
707
921
  }, {
708
- F: __dxlog_file4,
922
+ F: __dxlog_file5,
709
923
  L: 242,
710
924
  S: this,
711
925
  C: (f, a) => f(...a)
@@ -717,8 +931,8 @@ var EdgeHttpClient = class {
717
931
  }
718
932
  async _handleUnauthorized(response) {
719
933
  if (!this._edgeIdentity) {
720
- log2.warn("edge unauthorized response received before identity was set", void 0, {
721
- F: __dxlog_file4,
934
+ log3.warn("edge unauthorized response received before identity was set", void 0, {
935
+ F: __dxlog_file5,
722
936
  L: 251,
723
937
  S: this,
724
938
  C: (f, a) => f(...a)
@@ -727,8 +941,8 @@ var EdgeHttpClient = class {
727
941
  }
728
942
  const challenge = await handleAuthChallenge(response, this._edgeIdentity);
729
943
  this._authHeader = encodeAuthHeader(challenge);
730
- log2("auth header updated", void 0, {
731
- F: __dxlog_file4,
944
+ log3("auth header updated", void 0, {
945
+ F: __dxlog_file5,
732
946
  L: 256,
733
947
  S: this,
734
948
  C: (f, a) => f(...a)
@@ -771,13 +985,11 @@ var encodeAuthHeader = (challenge) => {
771
985
  return `VerifiablePresentation pb;base64,${encodedChallenge}`;
772
986
  };
773
987
  export {
774
- CLOUDFLARE_MESSAGE_LENGTH_LIMIT,
775
988
  EdgeClient,
776
989
  EdgeConnectionClosedError,
777
990
  EdgeHttpClient,
778
991
  EdgeIdentityChangedError,
779
992
  Protocol,
780
- WebSocketMuxer,
781
993
  createChainEdgeIdentity,
782
994
  createDeviceEdgeIdentity,
783
995
  createEphemeralEdgeIdentity,