@dxos/edge-client 0.8.2-main.36232bc → 0.8.2-main.5885341

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 (48) hide show
  1. package/dist/lib/browser/chunk-TKYUZ5ZK.mjs +302 -0
  2. package/dist/lib/browser/chunk-TKYUZ5ZK.mjs.map +7 -0
  3. package/dist/lib/browser/edge-ws-muxer.mjs +11 -0
  4. package/dist/lib/browser/edge-ws-muxer.mjs.map +7 -0
  5. package/dist/lib/browser/index.mjs +318 -58
  6. package/dist/lib/browser/index.mjs.map +4 -4
  7. package/dist/lib/browser/meta.json +1 -1
  8. package/dist/lib/browser/testing/index.mjs +3 -3
  9. package/dist/lib/browser/testing/index.mjs.map +3 -3
  10. package/dist/lib/node/chunk-ZOL3YSDR.cjs +322 -0
  11. package/dist/lib/node/chunk-ZOL3YSDR.cjs.map +7 -0
  12. package/dist/lib/node/edge-ws-muxer.cjs +33 -0
  13. package/dist/lib/node/edge-ws-muxer.cjs.map +7 -0
  14. package/dist/lib/node/index.cjs +322 -53
  15. package/dist/lib/node/index.cjs.map +4 -4
  16. package/dist/lib/node/meta.json +1 -1
  17. package/dist/lib/node/testing/index.cjs +6 -5
  18. package/dist/lib/node/testing/index.cjs.map +3 -3
  19. package/dist/lib/node-esm/chunk-25HGRGNZ.mjs +304 -0
  20. package/dist/lib/node-esm/chunk-25HGRGNZ.mjs.map +7 -0
  21. package/dist/lib/node-esm/edge-ws-muxer.mjs +12 -0
  22. package/dist/lib/node-esm/edge-ws-muxer.mjs.map +7 -0
  23. package/dist/lib/node-esm/index.mjs +318 -58
  24. package/dist/lib/node-esm/index.mjs.map +4 -4
  25. package/dist/lib/node-esm/meta.json +1 -1
  26. package/dist/lib/node-esm/testing/index.mjs +3 -3
  27. package/dist/lib/node-esm/testing/index.mjs.map +3 -3
  28. package/dist/types/src/edge-ws-connection.d.ts +0 -4
  29. package/dist/types/src/edge-ws-connection.d.ts.map +1 -1
  30. package/dist/types/src/edge-ws-muxer.d.ts +19 -7
  31. package/dist/types/src/edge-ws-muxer.d.ts.map +1 -1
  32. package/dist/types/src/edge-ws-muxer.test.d.ts +2 -0
  33. package/dist/types/src/edge-ws-muxer.test.d.ts.map +1 -0
  34. package/dist/types/src/index.d.ts +1 -0
  35. package/dist/types/src/index.d.ts.map +1 -1
  36. package/dist/types/src/testing/test-utils.d.ts.map +1 -1
  37. package/package.json +19 -14
  38. package/src/edge-ws-connection.ts +6 -11
  39. package/src/edge-ws-muxer.test.ts +55 -0
  40. package/src/edge-ws-muxer.ts +63 -33
  41. package/src/index.ts +1 -0
  42. package/src/testing/test-utils.ts +2 -2
  43. package/dist/lib/browser/chunk-XS3TKGM4.mjs +0 -545
  44. package/dist/lib/browser/chunk-XS3TKGM4.mjs.map +0 -7
  45. package/dist/lib/node/chunk-ZURVCY7K.cjs +0 -577
  46. package/dist/lib/node/chunk-ZURVCY7K.cjs.map +0 -7
  47. package/dist/lib/node-esm/chunk-HNRMNQPG.mjs +0 -547
  48. package/dist/lib/node-esm/chunk-HNRMNQPG.mjs.map +0 -7
@@ -1,18 +1,20 @@
1
1
  import {
2
- EdgeWsConnection,
2
+ CLOUDFLARE_MESSAGE_MAX_BYTES,
3
+ CLOUDFLARE_RPC_MAX_BYTES,
3
4
  Protocol,
5
+ WebSocketMuxer,
4
6
  getTypename,
5
7
  protocol,
6
8
  toUint8Array
7
- } from "./chunk-XS3TKGM4.mjs";
9
+ } from "./chunk-TKYUZ5ZK.mjs";
8
10
 
9
11
  // packages/core/mesh/edge-client/src/index.ts
10
12
  export * from "@dxos/protocols/buf/dxos/edge/messenger_pb";
11
13
 
12
14
  // packages/core/mesh/edge-client/src/edge-client.ts
13
15
  import { Trigger, scheduleMicroTask, TriggerState, PersistentLifecycle, Event } from "@dxos/async";
14
- import { Resource } from "@dxos/context";
15
- import { log, logInfo } from "@dxos/log";
16
+ import { Resource as Resource2 } from "@dxos/context";
17
+ import { log as log2, logInfo as logInfo2 } from "@dxos/log";
16
18
  import { EdgeStatus } from "@dxos/protocols/proto/dxos/client/services";
17
19
 
18
20
  // packages/core/mesh/edge-client/src/edge-identity.ts
@@ -55,6 +57,261 @@ var handleAuthChallenge = async (failedResponse, identity) => {
55
57
  return schema.getCodecForType("dxos.halo.credentials.Presentation").encode(presentation);
56
58
  };
57
59
 
60
+ // packages/core/mesh/edge-client/src/edge-ws-connection.ts
61
+ import WebSocket from "isomorphic-ws";
62
+ import { scheduleTask, scheduleTaskInterval } from "@dxos/async";
63
+ import { Context, Resource } from "@dxos/context";
64
+ import { invariant as invariant2 } from "@dxos/invariant";
65
+ import { log, logInfo } from "@dxos/log";
66
+ import { EdgeWebsocketProtocol } from "@dxos/protocols";
67
+ import { buf } from "@dxos/protocols/buf";
68
+ import { MessageSchema } from "@dxos/protocols/buf/dxos/edge/messenger_pb";
69
+ function _ts_decorate(decorators, target, key, desc) {
70
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
71
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
72
+ 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;
73
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
74
+ }
75
+ var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/core/mesh/edge-client/src/edge-ws-connection.ts";
76
+ var SIGNAL_KEEPALIVE_INTERVAL = 4e3;
77
+ var SIGNAL_KEEPALIVE_TIMEOUT = 12e3;
78
+ var EdgeWsConnection = class extends Resource {
79
+ constructor(_identity, _connectionInfo, _callbacks) {
80
+ super();
81
+ this._identity = _identity;
82
+ this._connectionInfo = _connectionInfo;
83
+ this._callbacks = _callbacks;
84
+ }
85
+ get info() {
86
+ return {
87
+ open: this.isOpen,
88
+ identity: this._identity.identityKey,
89
+ device: this._identity.peerKey
90
+ };
91
+ }
92
+ send(message) {
93
+ invariant2(this._ws, void 0, {
94
+ F: __dxlog_file2,
95
+ L: 52,
96
+ S: this,
97
+ A: [
98
+ "this._ws",
99
+ ""
100
+ ]
101
+ });
102
+ invariant2(this._wsMuxer, void 0, {
103
+ F: __dxlog_file2,
104
+ L: 53,
105
+ S: this,
106
+ A: [
107
+ "this._wsMuxer",
108
+ ""
109
+ ]
110
+ });
111
+ log("sending...", {
112
+ peerKey: this._identity.peerKey,
113
+ payload: protocol.getPayloadType(message)
114
+ }, {
115
+ F: __dxlog_file2,
116
+ L: 54,
117
+ S: this,
118
+ C: (f, a) => f(...a)
119
+ });
120
+ if (this._ws?.protocol.includes(EdgeWebsocketProtocol.V0)) {
121
+ const binary = buf.toBinary(MessageSchema, message);
122
+ if (binary.length > CLOUDFLARE_MESSAGE_MAX_BYTES) {
123
+ log.error("Message dropped because it was too large (>1MB).", {
124
+ byteLength: binary.byteLength,
125
+ serviceId: message.serviceId,
126
+ payload: protocol.getPayloadType(message)
127
+ }, {
128
+ F: __dxlog_file2,
129
+ L: 58,
130
+ S: this,
131
+ C: (f, a) => f(...a)
132
+ });
133
+ return;
134
+ }
135
+ this._ws.send(binary);
136
+ } else {
137
+ this._wsMuxer.send(message).catch((e) => log.catch(e, void 0, {
138
+ F: __dxlog_file2,
139
+ L: 67,
140
+ S: this,
141
+ C: (f, a) => f(...a)
142
+ }));
143
+ }
144
+ }
145
+ async _open() {
146
+ const baseProtocols = [
147
+ ...Object.values(EdgeWebsocketProtocol)
148
+ ];
149
+ this._ws = new WebSocket(this._connectionInfo.url.toString(), this._connectionInfo.protocolHeader ? [
150
+ ...baseProtocols,
151
+ this._connectionInfo.protocolHeader
152
+ ] : [
153
+ ...baseProtocols
154
+ ]);
155
+ const muxer = new WebSocketMuxer(this._ws);
156
+ this._wsMuxer = muxer;
157
+ this._ws.onopen = () => {
158
+ if (this.isOpen) {
159
+ log("connected", void 0, {
160
+ F: __dxlog_file2,
161
+ L: 84,
162
+ S: this,
163
+ C: (f, a) => f(...a)
164
+ });
165
+ this._callbacks.onConnected();
166
+ this._scheduleHeartbeats();
167
+ } else {
168
+ log.verbose("connected after becoming inactive", {
169
+ currentIdentity: this._identity
170
+ }, {
171
+ F: __dxlog_file2,
172
+ L: 88,
173
+ S: this,
174
+ C: (f, a) => f(...a)
175
+ });
176
+ }
177
+ };
178
+ this._ws.onclose = (event) => {
179
+ if (this.isOpen) {
180
+ log.warn("disconnected while being open", {
181
+ code: event.code,
182
+ reason: event.reason
183
+ }, {
184
+ F: __dxlog_file2,
185
+ L: 93,
186
+ S: this,
187
+ C: (f, a) => f(...a)
188
+ });
189
+ this._callbacks.onRestartRequired();
190
+ muxer.destroy();
191
+ }
192
+ };
193
+ this._ws.onerror = (event) => {
194
+ if (this.isOpen) {
195
+ log.warn("edge connection socket error", {
196
+ error: event.error,
197
+ info: event.message
198
+ }, {
199
+ F: __dxlog_file2,
200
+ L: 100,
201
+ S: this,
202
+ C: (f, a) => f(...a)
203
+ });
204
+ this._callbacks.onRestartRequired();
205
+ } else {
206
+ log.verbose("error ignored on closed connection", {
207
+ error: event.error
208
+ }, {
209
+ F: __dxlog_file2,
210
+ L: 103,
211
+ S: this,
212
+ C: (f, a) => f(...a)
213
+ });
214
+ }
215
+ };
216
+ this._ws.onmessage = async (event) => {
217
+ if (!this.isOpen) {
218
+ log.verbose("message ignored on closed connection", {
219
+ event: event.type
220
+ }, {
221
+ F: __dxlog_file2,
222
+ L: 111,
223
+ S: this,
224
+ C: (f, a) => f(...a)
225
+ });
226
+ return;
227
+ }
228
+ if (event.data === "__pong__") {
229
+ this._rescheduleHeartbeatTimeout();
230
+ return;
231
+ }
232
+ const bytes = await toUint8Array(event.data);
233
+ if (!this.isOpen) {
234
+ return;
235
+ }
236
+ const message = this._ws?.protocol?.includes(EdgeWebsocketProtocol.V0) ? buf.fromBinary(MessageSchema, bytes) : muxer.receiveData(bytes);
237
+ if (message) {
238
+ log("received", {
239
+ from: message.source,
240
+ payload: protocol.getPayloadType(message)
241
+ }, {
242
+ F: __dxlog_file2,
243
+ L: 128,
244
+ S: this,
245
+ C: (f, a) => f(...a)
246
+ });
247
+ this._callbacks.onMessage(message);
248
+ }
249
+ };
250
+ }
251
+ async _close() {
252
+ void this._inactivityTimeoutCtx?.dispose().catch(() => {
253
+ });
254
+ try {
255
+ this._ws?.close();
256
+ this._ws = void 0;
257
+ this._wsMuxer?.destroy();
258
+ this._wsMuxer = void 0;
259
+ } catch (err) {
260
+ if (err instanceof Error && err.message.includes("WebSocket is closed before the connection is established.")) {
261
+ return;
262
+ }
263
+ log.warn("Error closing websocket", {
264
+ err
265
+ }, {
266
+ F: __dxlog_file2,
267
+ L: 146,
268
+ S: this,
269
+ C: (f, a) => f(...a)
270
+ });
271
+ }
272
+ }
273
+ _scheduleHeartbeats() {
274
+ invariant2(this._ws, void 0, {
275
+ F: __dxlog_file2,
276
+ L: 151,
277
+ S: this,
278
+ A: [
279
+ "this._ws",
280
+ ""
281
+ ]
282
+ });
283
+ scheduleTaskInterval(this._ctx, async () => {
284
+ this._ws?.send("__ping__");
285
+ }, SIGNAL_KEEPALIVE_INTERVAL);
286
+ this._ws.send("__ping__");
287
+ this._rescheduleHeartbeatTimeout();
288
+ }
289
+ _rescheduleHeartbeatTimeout() {
290
+ if (!this.isOpen) {
291
+ return;
292
+ }
293
+ void this._inactivityTimeoutCtx?.dispose();
294
+ this._inactivityTimeoutCtx = new Context(void 0, {
295
+ F: __dxlog_file2,
296
+ L: 170
297
+ });
298
+ scheduleTask(this._inactivityTimeoutCtx, () => {
299
+ if (this.isOpen) {
300
+ log.warn("restart due to inactivity timeout", void 0, {
301
+ F: __dxlog_file2,
302
+ L: 175,
303
+ S: this,
304
+ C: (f, a) => f(...a)
305
+ });
306
+ this._callbacks.onRestartRequired();
307
+ }
308
+ }, SIGNAL_KEEPALIVE_TIMEOUT);
309
+ }
310
+ };
311
+ _ts_decorate([
312
+ logInfo
313
+ ], EdgeWsConnection.prototype, "info", null);
314
+
58
315
  // packages/core/mesh/edge-client/src/errors.ts
59
316
  var EdgeConnectionClosedError = class extends Error {
60
317
  constructor() {
@@ -76,15 +333,15 @@ var getEdgeUrlWithProtocol = (baseUrl, protocol2) => {
76
333
  };
77
334
 
78
335
  // packages/core/mesh/edge-client/src/edge-client.ts
79
- function _ts_decorate(decorators, target, key, desc) {
336
+ function _ts_decorate2(decorators, target, key, desc) {
80
337
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
81
338
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
82
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;
83
340
  return c > 3 && r && Object.defineProperty(target, key, r), r;
84
341
  }
85
- 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";
86
343
  var DEFAULT_TIMEOUT = 1e4;
87
- var EdgeClient = class extends Resource {
344
+ var EdgeClient = class extends Resource2 {
88
345
  constructor(_identity, _config) {
89
346
  super();
90
347
  this._identity = _identity;
@@ -121,11 +378,11 @@ var EdgeClient = class extends Resource {
121
378
  }
122
379
  setIdentity(identity) {
123
380
  if (identity.identityKey !== this._identity.identityKey || identity.peerKey !== this._identity.peerKey) {
124
- log("Edge identity changed", {
381
+ log2("Edge identity changed", {
125
382
  identity,
126
383
  oldIdentity: this._identity
127
384
  }, {
128
- F: __dxlog_file2,
385
+ F: __dxlog_file3,
129
386
  L: 99,
130
387
  S: this,
131
388
  C: (f, a) => f(...a)
@@ -147,8 +404,8 @@ var EdgeClient = class extends Resource {
147
404
  try {
148
405
  listener();
149
406
  } catch (error) {
150
- log.catch(error, void 0, {
151
- F: __dxlog_file2,
407
+ log2.catch(error, void 0, {
408
+ F: __dxlog_file3,
152
409
  L: 121,
153
410
  S: this,
154
411
  C: (f, a) => f(...a)
@@ -163,19 +420,19 @@ var EdgeClient = class extends Resource {
163
420
  * Open connection to messaging service.
164
421
  */
165
422
  async _open() {
166
- log("opening...", {
423
+ log2("opening...", {
167
424
  info: this.info
168
425
  }, {
169
- F: __dxlog_file2,
426
+ F: __dxlog_file3,
170
427
  L: 133,
171
428
  S: this,
172
429
  C: (f, a) => f(...a)
173
430
  });
174
431
  this._persistentLifecycle.open().catch((err) => {
175
- log.warn("Error while opening connection", {
432
+ log2.warn("Error while opening connection", {
176
433
  err
177
434
  }, {
178
- F: __dxlog_file2,
435
+ F: __dxlog_file3,
179
436
  L: 135,
180
437
  S: this,
181
438
  C: (f, a) => f(...a)
@@ -186,10 +443,10 @@ var EdgeClient = class extends Resource {
186
443
  * Close connection and free resources.
187
444
  */
188
445
  async _close() {
189
- log("closing...", {
446
+ log2("closing...", {
190
447
  peerKey: this._identity.peerKey
191
448
  }, {
192
- F: __dxlog_file2,
449
+ F: __dxlog_file3,
193
450
  L: 143,
194
451
  S: this,
195
452
  C: (f, a) => f(...a)
@@ -205,8 +462,8 @@ var EdgeClient = class extends Resource {
205
462
  const path = `/ws/${identity.identityKey}/${identity.peerKey}`;
206
463
  const protocolHeader = this._config.disableAuth ? void 0 : await this._createAuthHeader(path);
207
464
  if (this._identity !== identity) {
208
- log("identity changed during auth header request", void 0, {
209
- F: __dxlog_file2,
465
+ log2("identity changed during auth header request", void 0, {
466
+ F: __dxlog_file3,
210
467
  L: 157,
211
468
  S: this,
212
469
  C: (f, a) => f(...a)
@@ -215,11 +472,11 @@ var EdgeClient = class extends Resource {
215
472
  }
216
473
  const restartRequired = new Trigger();
217
474
  const url = new URL(path, this._baseWsUrl);
218
- log("Opening websocket", {
475
+ log2("Opening websocket", {
219
476
  url: url.toString(),
220
477
  protocolHeader
221
478
  }, {
222
- F: __dxlog_file2,
479
+ F: __dxlog_file3,
223
480
  L: 163,
224
481
  S: this,
225
482
  C: (f, a) => f(...a)
@@ -233,8 +490,8 @@ var EdgeClient = class extends Resource {
233
490
  this._ready.wake();
234
491
  this._notifyReconnected();
235
492
  } else {
236
- log.verbose("connected callback ignored, because connection is not active", void 0, {
237
- F: __dxlog_file2,
493
+ log2.verbose("connected callback ignored, because connection is not active", void 0, {
494
+ F: __dxlog_file3,
238
495
  L: 173,
239
496
  S: this,
240
497
  C: (f, a) => f(...a)
@@ -246,8 +503,8 @@ var EdgeClient = class extends Resource {
246
503
  this._closeCurrentConnection();
247
504
  void this._persistentLifecycle.scheduleRestart();
248
505
  } else {
249
- log.verbose("restart requested by inactive connection", void 0, {
250
- F: __dxlog_file2,
506
+ log2.verbose("restart requested by inactive connection", void 0, {
507
+ F: __dxlog_file3,
251
508
  L: 181,
252
509
  S: this,
253
510
  C: (f, a) => f(...a)
@@ -259,11 +516,11 @@ var EdgeClient = class extends Resource {
259
516
  if (this._isActive(connection)) {
260
517
  this._notifyMessageReceived(message);
261
518
  } else {
262
- log.verbose("ignored a message on inactive connection", {
519
+ log2.verbose("ignored a message on inactive connection", {
263
520
  from: message.source,
264
521
  type: message.payload?.typeUrl
265
522
  }, {
266
- F: __dxlog_file2,
523
+ F: __dxlog_file3,
267
524
  L: 189,
268
525
  S: this,
269
526
  C: (f, a) => f(...a)
@@ -297,10 +554,10 @@ var EdgeClient = class extends Resource {
297
554
  try {
298
555
  listener();
299
556
  } catch (err) {
300
- log.error("ws reconnect listener failed", {
557
+ log2.error("ws reconnect listener failed", {
301
558
  err
302
559
  }, {
303
- F: __dxlog_file2,
560
+ F: __dxlog_file3,
304
561
  L: 225,
305
562
  S: this,
306
563
  C: (f, a) => f(...a)
@@ -313,11 +570,11 @@ var EdgeClient = class extends Resource {
313
570
  try {
314
571
  listener(message);
315
572
  } catch (err) {
316
- log.error("ws incoming message processing failed", {
573
+ log2.error("ws incoming message processing failed", {
317
574
  err,
318
575
  payload: protocol.getPayloadType(message)
319
576
  }, {
320
- F: __dxlog_file2,
577
+ F: __dxlog_file3,
321
578
  L: 235,
322
579
  S: this,
323
580
  C: (f, a) => f(...a)
@@ -331,8 +588,8 @@ var EdgeClient = class extends Resource {
331
588
  */
332
589
  async send(message) {
333
590
  if (this._ready.state !== TriggerState.RESOLVED) {
334
- log("waiting for websocket to become ready", void 0, {
335
- F: __dxlog_file2,
591
+ log2("waiting for websocket to become ready", void 0, {
592
+ F: __dxlog_file3,
336
593
  L: 246,
337
594
  S: this,
338
595
  C: (f, a) => f(...a)
@@ -358,11 +615,11 @@ var EdgeClient = class extends Resource {
358
615
  if (response.status === 401) {
359
616
  return encodePresentationWsAuthHeader(await handleAuthChallenge(response, this._identity));
360
617
  } else {
361
- log.warn("no auth challenge from edge", {
618
+ log2.warn("no auth challenge from edge", {
362
619
  status: response.status,
363
620
  statusText: response.statusText
364
621
  }, {
365
- F: __dxlog_file2,
622
+ F: __dxlog_file3,
366
623
  L: 271,
367
624
  S: this,
368
625
  C: (f, a) => f(...a)
@@ -371,8 +628,8 @@ var EdgeClient = class extends Resource {
371
628
  }
372
629
  }
373
630
  };
374
- _ts_decorate([
375
- logInfo
631
+ _ts_decorate2([
632
+ logInfo2
376
633
  ], EdgeClient.prototype, "info", null);
377
634
  var encodePresentationWsAuthHeader = (encodedPresentation) => {
378
635
  const encodedToken = Buffer.from(encodedPresentation).toString("base64").replace(/=*$/, "").replaceAll("/", "|");
@@ -381,10 +638,10 @@ var encodePresentationWsAuthHeader = (encodedPresentation) => {
381
638
 
382
639
  // packages/core/mesh/edge-client/src/auth.ts
383
640
  import { createCredential, signPresentation } from "@dxos/credentials";
384
- import { invariant as invariant2 } from "@dxos/invariant";
641
+ import { invariant as invariant3 } from "@dxos/invariant";
385
642
  import { Keyring } from "@dxos/keyring";
386
643
  import { PublicKey } from "@dxos/keys";
387
- var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/core/mesh/edge-client/src/auth.ts";
644
+ var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/core/mesh/edge-client/src/auth.ts";
388
645
  var createDeviceEdgeIdentity = async (signer, key) => {
389
646
  return {
390
647
  identityKey: key.toHex(),
@@ -428,8 +685,8 @@ var createChainEdgeIdentity = async (signer, identityKey, peerKey, chain, creden
428
685
  identityKey: identityKey.toHex(),
429
686
  peerKey: peerKey.toHex(),
430
687
  presentCredentials: async ({ challenge }) => {
431
- invariant2(chain, void 0, {
432
- F: __dxlog_file3,
688
+ invariant3(chain, void 0, {
689
+ F: __dxlog_file4,
433
690
  L: 75,
434
691
  S: void 0,
435
692
  A: [
@@ -492,20 +749,20 @@ var createStubEdgeIdentity = () => {
492
749
 
493
750
  // packages/core/mesh/edge-client/src/edge-http-client.ts
494
751
  import { sleep } from "@dxos/async";
495
- import { Context } from "@dxos/context";
496
- import { log as log2 } from "@dxos/log";
752
+ import { Context as Context2 } from "@dxos/context";
753
+ import { log as log3 } from "@dxos/log";
497
754
  import { EdgeCallFailedError, EdgeAuthChallengeError } from "@dxos/protocols";
498
- var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/core/mesh/edge-client/src/edge-http-client.ts";
755
+ var __dxlog_file5 = "/home/runner/work/dxos/dxos/packages/core/mesh/edge-client/src/edge-http-client.ts";
499
756
  var DEFAULT_RETRY_TIMEOUT = 1500;
500
757
  var DEFAULT_RETRY_JITTER = 500;
501
758
  var DEFAULT_MAX_RETRIES_COUNT = 3;
502
759
  var EdgeHttpClient = class {
503
760
  constructor(baseUrl) {
504
761
  this._baseUrl = getEdgeUrlWithProtocol(baseUrl, "http");
505
- log2("created", {
762
+ log3("created", {
506
763
  url: this._baseUrl
507
764
  }, {
508
- F: __dxlog_file4,
765
+ F: __dxlog_file5,
509
766
  L: 53,
510
767
  S: this,
511
768
  C: (f, a) => f(...a)
@@ -637,8 +894,8 @@ var EdgeHttpClient = class {
637
894
  });
638
895
  }
639
896
  async _call(path, args) {
640
- const requestContext = args.context ?? new Context(void 0, {
641
- F: __dxlog_file4,
897
+ const requestContext = args.context ?? new Context2(void 0, {
898
+ F: __dxlog_file5,
642
899
  L: 192
643
900
  });
644
901
  const shouldRetry = createRetryHandler(args);
@@ -650,12 +907,12 @@ var EdgeHttpClient = class {
650
907
  }
651
908
  url += `?${queryParams.toString()}`;
652
909
  }
653
- log2("call", {
910
+ log3("call", {
654
911
  method: args.method,
655
912
  path,
656
913
  request: args.body
657
914
  }, {
658
- F: __dxlog_file4,
915
+ F: __dxlog_file5,
659
916
  L: 204,
660
917
  S: this,
661
918
  C: (f, a) => f(...a)
@@ -674,11 +931,11 @@ var EdgeHttpClient = class {
674
931
  if (body.success) {
675
932
  return body.data;
676
933
  }
677
- log2("unsuccessful edge response", {
934
+ log3("unsuccessful edge response", {
678
935
  path,
679
936
  body
680
937
  }, {
681
- F: __dxlog_file4,
938
+ F: __dxlog_file5,
682
939
  L: 223,
683
940
  S: this,
684
941
  C: (f, a) => f(...a)
@@ -699,11 +956,11 @@ var EdgeHttpClient = class {
699
956
  processingError = EdgeCallFailedError.fromProcessingFailureCause(error);
700
957
  }
701
958
  if (processingError.isRetryable && await shouldRetry(requestContext, retryAfterHeaderValue)) {
702
- log2("retrying edge request", {
959
+ log3("retrying edge request", {
703
960
  path,
704
961
  processingError
705
962
  }, {
706
- F: __dxlog_file4,
963
+ F: __dxlog_file5,
707
964
  L: 242,
708
965
  S: this,
709
966
  C: (f, a) => f(...a)
@@ -715,8 +972,8 @@ var EdgeHttpClient = class {
715
972
  }
716
973
  async _handleUnauthorized(response) {
717
974
  if (!this._edgeIdentity) {
718
- log2.warn("edge unauthorized response received before identity was set", void 0, {
719
- F: __dxlog_file4,
975
+ log3.warn("edge unauthorized response received before identity was set", void 0, {
976
+ F: __dxlog_file5,
720
977
  L: 251,
721
978
  S: this,
722
979
  C: (f, a) => f(...a)
@@ -725,8 +982,8 @@ var EdgeHttpClient = class {
725
982
  }
726
983
  const challenge = await handleAuthChallenge(response, this._edgeIdentity);
727
984
  this._authHeader = encodeAuthHeader(challenge);
728
- log2("auth header updated", void 0, {
729
- F: __dxlog_file4,
985
+ log3("auth header updated", void 0, {
986
+ F: __dxlog_file5,
730
987
  L: 256,
731
988
  S: this,
732
989
  C: (f, a) => f(...a)
@@ -769,11 +1026,14 @@ var encodeAuthHeader = (challenge) => {
769
1026
  return `VerifiablePresentation pb;base64,${encodedChallenge}`;
770
1027
  };
771
1028
  export {
1029
+ CLOUDFLARE_MESSAGE_MAX_BYTES,
1030
+ CLOUDFLARE_RPC_MAX_BYTES,
772
1031
  EdgeClient,
773
1032
  EdgeConnectionClosedError,
774
1033
  EdgeHttpClient,
775
1034
  EdgeIdentityChangedError,
776
1035
  Protocol,
1036
+ WebSocketMuxer,
777
1037
  createChainEdgeIdentity,
778
1038
  createDeviceEdgeIdentity,
779
1039
  createEphemeralEdgeIdentity,