@dxos/edge-client 0.8.2-main.f11618f → 0.8.2-main.fbd8ed0

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 (53) 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 +316 -61
  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 +321 -57
  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 +316 -61
  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/auth.d.ts.map +1 -1
  29. package/dist/types/src/edge-http-client.d.ts +0 -1
  30. package/dist/types/src/edge-http-client.d.ts.map +1 -1
  31. package/dist/types/src/edge-identity.d.ts.map +1 -1
  32. package/dist/types/src/edge-ws-connection.d.ts +0 -4
  33. package/dist/types/src/edge-ws-connection.d.ts.map +1 -1
  34. package/dist/types/src/edge-ws-muxer.d.ts +19 -7
  35. package/dist/types/src/edge-ws-muxer.d.ts.map +1 -1
  36. package/dist/types/src/edge-ws-muxer.test.d.ts +2 -0
  37. package/dist/types/src/edge-ws-muxer.test.d.ts.map +1 -0
  38. package/dist/types/src/protocol.d.ts.map +1 -1
  39. package/dist/types/src/testing/test-utils.d.ts.map +1 -1
  40. package/dist/types/src/utils.d.ts.map +1 -1
  41. package/dist/types/tsconfig.tsbuildinfo +1 -1
  42. package/package.json +19 -14
  43. package/src/edge-http-client.ts +2 -2
  44. package/src/edge-ws-connection.ts +6 -11
  45. package/src/edge-ws-muxer.test.ts +55 -0
  46. package/src/edge-ws-muxer.ts +63 -33
  47. package/src/testing/test-utils.ts +2 -2
  48. package/dist/lib/browser/chunk-5DDWS5EC.mjs +0 -546
  49. package/dist/lib/browser/chunk-5DDWS5EC.mjs.map +0 -7
  50. package/dist/lib/node/chunk-CNAHGYSS.cjs +0 -579
  51. package/dist/lib/node/chunk-CNAHGYSS.cjs.map +0 -7
  52. package/dist/lib/node-esm/chunk-O4TFZRSP.mjs +0 -548
  53. package/dist/lib/node-esm/chunk-O4TFZRSP.mjs.map +0 -7
@@ -1,20 +1,20 @@
1
1
  import {
2
- CLOUDFLARE_MESSAGE_LENGTH_LIMIT,
3
- EdgeWsConnection,
2
+ CLOUDFLARE_MESSAGE_MAX_BYTES,
3
+ CLOUDFLARE_RPC_MAX_BYTES,
4
4
  Protocol,
5
5
  WebSocketMuxer,
6
6
  getTypename,
7
7
  protocol,
8
8
  toUint8Array
9
- } from "./chunk-5DDWS5EC.mjs";
9
+ } from "./chunk-TKYUZ5ZK.mjs";
10
10
 
11
11
  // packages/core/mesh/edge-client/src/index.ts
12
12
  export * from "@dxos/protocols/buf/dxos/edge/messenger_pb";
13
13
 
14
14
  // packages/core/mesh/edge-client/src/edge-client.ts
15
15
  import { Trigger, scheduleMicroTask, TriggerState, PersistentLifecycle, Event } from "@dxos/async";
16
- import { Resource } from "@dxos/context";
17
- 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";
18
18
  import { EdgeStatus } from "@dxos/protocols/proto/dxos/client/services";
19
19
 
20
20
  // packages/core/mesh/edge-client/src/edge-identity.ts
@@ -57,6 +57,261 @@ var handleAuthChallenge = async (failedResponse, identity) => {
57
57
  return schema.getCodecForType("dxos.halo.credentials.Presentation").encode(presentation);
58
58
  };
59
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
+
60
315
  // packages/core/mesh/edge-client/src/errors.ts
61
316
  var EdgeConnectionClosedError = class extends Error {
62
317
  constructor() {
@@ -78,15 +333,15 @@ var getEdgeUrlWithProtocol = (baseUrl, protocol2) => {
78
333
  };
79
334
 
80
335
  // packages/core/mesh/edge-client/src/edge-client.ts
81
- function _ts_decorate(decorators, target, key, desc) {
336
+ function _ts_decorate2(decorators, target, key, desc) {
82
337
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
83
338
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
84
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;
85
340
  return c > 3 && r && Object.defineProperty(target, key, r), r;
86
341
  }
87
- 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";
88
343
  var DEFAULT_TIMEOUT = 1e4;
89
- var EdgeClient = class extends Resource {
344
+ var EdgeClient = class extends Resource2 {
90
345
  constructor(_identity, _config) {
91
346
  super();
92
347
  this._identity = _identity;
@@ -123,11 +378,11 @@ var EdgeClient = class extends Resource {
123
378
  }
124
379
  setIdentity(identity) {
125
380
  if (identity.identityKey !== this._identity.identityKey || identity.peerKey !== this._identity.peerKey) {
126
- log("Edge identity changed", {
381
+ log2("Edge identity changed", {
127
382
  identity,
128
383
  oldIdentity: this._identity
129
384
  }, {
130
- F: __dxlog_file2,
385
+ F: __dxlog_file3,
131
386
  L: 99,
132
387
  S: this,
133
388
  C: (f, a) => f(...a)
@@ -149,8 +404,8 @@ var EdgeClient = class extends Resource {
149
404
  try {
150
405
  listener();
151
406
  } catch (error) {
152
- log.catch(error, void 0, {
153
- F: __dxlog_file2,
407
+ log2.catch(error, void 0, {
408
+ F: __dxlog_file3,
154
409
  L: 121,
155
410
  S: this,
156
411
  C: (f, a) => f(...a)
@@ -165,19 +420,19 @@ var EdgeClient = class extends Resource {
165
420
  * Open connection to messaging service.
166
421
  */
167
422
  async _open() {
168
- log("opening...", {
423
+ log2("opening...", {
169
424
  info: this.info
170
425
  }, {
171
- F: __dxlog_file2,
426
+ F: __dxlog_file3,
172
427
  L: 133,
173
428
  S: this,
174
429
  C: (f, a) => f(...a)
175
430
  });
176
431
  this._persistentLifecycle.open().catch((err) => {
177
- log.warn("Error while opening connection", {
432
+ log2.warn("Error while opening connection", {
178
433
  err
179
434
  }, {
180
- F: __dxlog_file2,
435
+ F: __dxlog_file3,
181
436
  L: 135,
182
437
  S: this,
183
438
  C: (f, a) => f(...a)
@@ -188,10 +443,10 @@ var EdgeClient = class extends Resource {
188
443
  * Close connection and free resources.
189
444
  */
190
445
  async _close() {
191
- log("closing...", {
446
+ log2("closing...", {
192
447
  peerKey: this._identity.peerKey
193
448
  }, {
194
- F: __dxlog_file2,
449
+ F: __dxlog_file3,
195
450
  L: 143,
196
451
  S: this,
197
452
  C: (f, a) => f(...a)
@@ -207,8 +462,8 @@ var EdgeClient = class extends Resource {
207
462
  const path = `/ws/${identity.identityKey}/${identity.peerKey}`;
208
463
  const protocolHeader = this._config.disableAuth ? void 0 : await this._createAuthHeader(path);
209
464
  if (this._identity !== identity) {
210
- log("identity changed during auth header request", void 0, {
211
- F: __dxlog_file2,
465
+ log2("identity changed during auth header request", void 0, {
466
+ F: __dxlog_file3,
212
467
  L: 157,
213
468
  S: this,
214
469
  C: (f, a) => f(...a)
@@ -217,11 +472,11 @@ var EdgeClient = class extends Resource {
217
472
  }
218
473
  const restartRequired = new Trigger();
219
474
  const url = new URL(path, this._baseWsUrl);
220
- log("Opening websocket", {
475
+ log2("Opening websocket", {
221
476
  url: url.toString(),
222
477
  protocolHeader
223
478
  }, {
224
- F: __dxlog_file2,
479
+ F: __dxlog_file3,
225
480
  L: 163,
226
481
  S: this,
227
482
  C: (f, a) => f(...a)
@@ -235,8 +490,8 @@ var EdgeClient = class extends Resource {
235
490
  this._ready.wake();
236
491
  this._notifyReconnected();
237
492
  } else {
238
- log.verbose("connected callback ignored, because connection is not active", void 0, {
239
- F: __dxlog_file2,
493
+ log2.verbose("connected callback ignored, because connection is not active", void 0, {
494
+ F: __dxlog_file3,
240
495
  L: 173,
241
496
  S: this,
242
497
  C: (f, a) => f(...a)
@@ -248,8 +503,8 @@ var EdgeClient = class extends Resource {
248
503
  this._closeCurrentConnection();
249
504
  void this._persistentLifecycle.scheduleRestart();
250
505
  } else {
251
- log.verbose("restart requested by inactive connection", void 0, {
252
- F: __dxlog_file2,
506
+ log2.verbose("restart requested by inactive connection", void 0, {
507
+ F: __dxlog_file3,
253
508
  L: 181,
254
509
  S: this,
255
510
  C: (f, a) => f(...a)
@@ -261,11 +516,11 @@ var EdgeClient = class extends Resource {
261
516
  if (this._isActive(connection)) {
262
517
  this._notifyMessageReceived(message);
263
518
  } else {
264
- log.verbose("ignored a message on inactive connection", {
519
+ log2.verbose("ignored a message on inactive connection", {
265
520
  from: message.source,
266
521
  type: message.payload?.typeUrl
267
522
  }, {
268
- F: __dxlog_file2,
523
+ F: __dxlog_file3,
269
524
  L: 189,
270
525
  S: this,
271
526
  C: (f, a) => f(...a)
@@ -299,10 +554,10 @@ var EdgeClient = class extends Resource {
299
554
  try {
300
555
  listener();
301
556
  } catch (err) {
302
- log.error("ws reconnect listener failed", {
557
+ log2.error("ws reconnect listener failed", {
303
558
  err
304
559
  }, {
305
- F: __dxlog_file2,
560
+ F: __dxlog_file3,
306
561
  L: 225,
307
562
  S: this,
308
563
  C: (f, a) => f(...a)
@@ -315,11 +570,11 @@ var EdgeClient = class extends Resource {
315
570
  try {
316
571
  listener(message);
317
572
  } catch (err) {
318
- log.error("ws incoming message processing failed", {
573
+ log2.error("ws incoming message processing failed", {
319
574
  err,
320
575
  payload: protocol.getPayloadType(message)
321
576
  }, {
322
- F: __dxlog_file2,
577
+ F: __dxlog_file3,
323
578
  L: 235,
324
579
  S: this,
325
580
  C: (f, a) => f(...a)
@@ -333,8 +588,8 @@ var EdgeClient = class extends Resource {
333
588
  */
334
589
  async send(message) {
335
590
  if (this._ready.state !== TriggerState.RESOLVED) {
336
- log("waiting for websocket to become ready", void 0, {
337
- F: __dxlog_file2,
591
+ log2("waiting for websocket to become ready", void 0, {
592
+ F: __dxlog_file3,
338
593
  L: 246,
339
594
  S: this,
340
595
  C: (f, a) => f(...a)
@@ -360,11 +615,11 @@ var EdgeClient = class extends Resource {
360
615
  if (response.status === 401) {
361
616
  return encodePresentationWsAuthHeader(await handleAuthChallenge(response, this._identity));
362
617
  } else {
363
- log.warn("no auth challenge from edge", {
618
+ log2.warn("no auth challenge from edge", {
364
619
  status: response.status,
365
620
  statusText: response.statusText
366
621
  }, {
367
- F: __dxlog_file2,
622
+ F: __dxlog_file3,
368
623
  L: 271,
369
624
  S: this,
370
625
  C: (f, a) => f(...a)
@@ -373,8 +628,8 @@ var EdgeClient = class extends Resource {
373
628
  }
374
629
  }
375
630
  };
376
- _ts_decorate([
377
- logInfo
631
+ _ts_decorate2([
632
+ logInfo2
378
633
  ], EdgeClient.prototype, "info", null);
379
634
  var encodePresentationWsAuthHeader = (encodedPresentation) => {
380
635
  const encodedToken = Buffer.from(encodedPresentation).toString("base64").replace(/=*$/, "").replaceAll("/", "|");
@@ -383,10 +638,10 @@ var encodePresentationWsAuthHeader = (encodedPresentation) => {
383
638
 
384
639
  // packages/core/mesh/edge-client/src/auth.ts
385
640
  import { createCredential, signPresentation } from "@dxos/credentials";
386
- import { invariant as invariant2 } from "@dxos/invariant";
641
+ import { invariant as invariant3 } from "@dxos/invariant";
387
642
  import { Keyring } from "@dxos/keyring";
388
643
  import { PublicKey } from "@dxos/keys";
389
- 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";
390
645
  var createDeviceEdgeIdentity = async (signer, key) => {
391
646
  return {
392
647
  identityKey: key.toHex(),
@@ -430,8 +685,8 @@ var createChainEdgeIdentity = async (signer, identityKey, peerKey, chain, creden
430
685
  identityKey: identityKey.toHex(),
431
686
  peerKey: peerKey.toHex(),
432
687
  presentCredentials: async ({ challenge }) => {
433
- invariant2(chain, void 0, {
434
- F: __dxlog_file3,
688
+ invariant3(chain, void 0, {
689
+ F: __dxlog_file4,
435
690
  L: 75,
436
691
  S: void 0,
437
692
  A: [
@@ -494,20 +749,20 @@ var createStubEdgeIdentity = () => {
494
749
 
495
750
  // packages/core/mesh/edge-client/src/edge-http-client.ts
496
751
  import { sleep } from "@dxos/async";
497
- import { Context } from "@dxos/context";
498
- import { log as log2 } from "@dxos/log";
752
+ import { Context as Context2 } from "@dxos/context";
753
+ import { log as log3 } from "@dxos/log";
499
754
  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";
755
+ var __dxlog_file5 = "/home/runner/work/dxos/dxos/packages/core/mesh/edge-client/src/edge-http-client.ts";
501
756
  var DEFAULT_RETRY_TIMEOUT = 1500;
502
757
  var DEFAULT_RETRY_JITTER = 500;
503
758
  var DEFAULT_MAX_RETRIES_COUNT = 3;
504
759
  var EdgeHttpClient = class {
505
760
  constructor(baseUrl) {
506
761
  this._baseUrl = getEdgeUrlWithProtocol(baseUrl, "http");
507
- log2("created", {
762
+ log3("created", {
508
763
  url: this._baseUrl
509
764
  }, {
510
- F: __dxlog_file4,
765
+ F: __dxlog_file5,
511
766
  L: 53,
512
767
  S: this,
513
768
  C: (f, a) => f(...a)
@@ -572,7 +827,6 @@ var EdgeHttpClient = class {
572
827
  async uploadFunction(pathParts, body, args) {
573
828
  const path = [
574
829
  "functions",
575
- pathParts.spaceId,
576
830
  ...pathParts.functionId ? [
577
831
  pathParts.functionId
578
832
  ] : []
@@ -639,8 +893,8 @@ var EdgeHttpClient = class {
639
893
  });
640
894
  }
641
895
  async _call(path, args) {
642
- const requestContext = args.context ?? new Context(void 0, {
643
- F: __dxlog_file4,
896
+ const requestContext = args.context ?? new Context2(void 0, {
897
+ F: __dxlog_file5,
644
898
  L: 192
645
899
  });
646
900
  const shouldRetry = createRetryHandler(args);
@@ -652,12 +906,12 @@ var EdgeHttpClient = class {
652
906
  }
653
907
  url += `?${queryParams.toString()}`;
654
908
  }
655
- log2("call", {
909
+ log3("call", {
656
910
  method: args.method,
657
911
  path,
658
912
  request: args.body
659
913
  }, {
660
- F: __dxlog_file4,
914
+ F: __dxlog_file5,
661
915
  L: 204,
662
916
  S: this,
663
917
  C: (f, a) => f(...a)
@@ -676,11 +930,11 @@ var EdgeHttpClient = class {
676
930
  if (body.success) {
677
931
  return body.data;
678
932
  }
679
- log2("unsuccessful edge response", {
933
+ log3("unsuccessful edge response", {
680
934
  path,
681
935
  body
682
936
  }, {
683
- F: __dxlog_file4,
937
+ F: __dxlog_file5,
684
938
  L: 223,
685
939
  S: this,
686
940
  C: (f, a) => f(...a)
@@ -701,11 +955,11 @@ var EdgeHttpClient = class {
701
955
  processingError = EdgeCallFailedError.fromProcessingFailureCause(error);
702
956
  }
703
957
  if (processingError.isRetryable && await shouldRetry(requestContext, retryAfterHeaderValue)) {
704
- log2("retrying edge request", {
958
+ log3("retrying edge request", {
705
959
  path,
706
960
  processingError
707
961
  }, {
708
- F: __dxlog_file4,
962
+ F: __dxlog_file5,
709
963
  L: 242,
710
964
  S: this,
711
965
  C: (f, a) => f(...a)
@@ -717,8 +971,8 @@ var EdgeHttpClient = class {
717
971
  }
718
972
  async _handleUnauthorized(response) {
719
973
  if (!this._edgeIdentity) {
720
- log2.warn("edge unauthorized response received before identity was set", void 0, {
721
- F: __dxlog_file4,
974
+ log3.warn("edge unauthorized response received before identity was set", void 0, {
975
+ F: __dxlog_file5,
722
976
  L: 251,
723
977
  S: this,
724
978
  C: (f, a) => f(...a)
@@ -727,8 +981,8 @@ var EdgeHttpClient = class {
727
981
  }
728
982
  const challenge = await handleAuthChallenge(response, this._edgeIdentity);
729
983
  this._authHeader = encodeAuthHeader(challenge);
730
- log2("auth header updated", void 0, {
731
- F: __dxlog_file4,
984
+ log3("auth header updated", void 0, {
985
+ F: __dxlog_file5,
732
986
  L: 256,
733
987
  S: this,
734
988
  C: (f, a) => f(...a)
@@ -771,7 +1025,8 @@ var encodeAuthHeader = (challenge) => {
771
1025
  return `VerifiablePresentation pb;base64,${encodedChallenge}`;
772
1026
  };
773
1027
  export {
774
- CLOUDFLARE_MESSAGE_LENGTH_LIMIT,
1028
+ CLOUDFLARE_MESSAGE_MAX_BYTES,
1029
+ CLOUDFLARE_RPC_MAX_BYTES,
775
1030
  EdgeClient,
776
1031
  EdgeConnectionClosedError,
777
1032
  EdgeHttpClient,