@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,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,28 +18,37 @@ 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,
32
+ CLOUDFLARE_MESSAGE_MAX_BYTES: () => import_chunk_ZOL3YSDR.CLOUDFLARE_MESSAGE_MAX_BYTES,
33
+ CLOUDFLARE_RPC_MAX_BYTES: () => import_chunk_ZOL3YSDR.CLOUDFLARE_RPC_MAX_BYTES,
23
34
  EdgeClient: () => EdgeClient,
24
35
  EdgeConnectionClosedError: () => EdgeConnectionClosedError,
25
36
  EdgeHttpClient: () => EdgeHttpClient,
26
37
  EdgeIdentityChangedError: () => EdgeIdentityChangedError,
27
- Protocol: () => import_chunk_CNAHGYSS.Protocol,
28
- WebSocketMuxer: () => import_chunk_CNAHGYSS.WebSocketMuxer,
38
+ Protocol: () => import_chunk_ZOL3YSDR.Protocol,
39
+ WebSocketMuxer: () => import_chunk_ZOL3YSDR.WebSocketMuxer,
29
40
  createChainEdgeIdentity: () => createChainEdgeIdentity,
30
41
  createDeviceEdgeIdentity: () => createDeviceEdgeIdentity,
31
42
  createEphemeralEdgeIdentity: () => createEphemeralEdgeIdentity,
32
43
  createStubEdgeIdentity: () => createStubEdgeIdentity,
33
44
  createTestHaloEdgeIdentity: () => createTestHaloEdgeIdentity,
34
- getTypename: () => import_chunk_CNAHGYSS.getTypename,
45
+ getTypename: () => import_chunk_ZOL3YSDR.getTypename,
35
46
  handleAuthChallenge: () => handleAuthChallenge,
36
- protocol: () => import_chunk_CNAHGYSS.protocol,
37
- toUint8Array: () => import_chunk_CNAHGYSS.toUint8Array
47
+ protocol: () => import_chunk_ZOL3YSDR.protocol,
48
+ toUint8Array: () => import_chunk_ZOL3YSDR.toUint8Array
38
49
  });
39
50
  module.exports = __toCommonJS(node_exports);
40
- var import_chunk_CNAHGYSS = require("./chunk-CNAHGYSS.cjs");
51
+ var import_chunk_ZOL3YSDR = require("./chunk-ZOL3YSDR.cjs");
41
52
  __reExport(node_exports, require("@dxos/protocols/buf/dxos/edge/messenger_pb"), module.exports);
42
53
  var import_async = require("@dxos/async");
43
54
  var import_context = require("@dxos/context");
@@ -45,14 +56,22 @@ var import_log = require("@dxos/log");
45
56
  var import_services = require("@dxos/protocols/proto/dxos/client/services");
46
57
  var import_invariant = require("@dxos/invariant");
47
58
  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");
59
+ var import_isomorphic_ws = __toESM(require("isomorphic-ws"));
52
60
  var import_async2 = require("@dxos/async");
53
61
  var import_context2 = require("@dxos/context");
62
+ var import_invariant2 = require("@dxos/invariant");
54
63
  var import_log2 = require("@dxos/log");
55
64
  var import_protocols = require("@dxos/protocols");
65
+ var import_buf = require("@dxos/protocols/buf");
66
+ var import_messenger_pb = require("@dxos/protocols/buf/dxos/edge/messenger_pb");
67
+ var import_credentials = require("@dxos/credentials");
68
+ var import_invariant3 = require("@dxos/invariant");
69
+ var import_keyring = require("@dxos/keyring");
70
+ var import_keys = require("@dxos/keys");
71
+ var import_async3 = require("@dxos/async");
72
+ var import_context3 = require("@dxos/context");
73
+ var import_log3 = require("@dxos/log");
74
+ var import_protocols2 = require("@dxos/protocols");
56
75
  var __dxlog_file = "/home/runner/work/dxos/dxos/packages/core/mesh/edge-client/src/edge-identity.ts";
57
76
  var handleAuthChallenge = async (failedResponse, identity) => {
58
77
  (0, import_invariant.invariant)(failedResponse.status === 401, void 0, {
@@ -89,6 +108,251 @@ var handleAuthChallenge = async (failedResponse, identity) => {
89
108
  });
90
109
  return import_proto.schema.getCodecForType("dxos.halo.credentials.Presentation").encode(presentation);
91
110
  };
111
+ function _ts_decorate(decorators, target, key, desc) {
112
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
113
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
114
+ 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;
115
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
116
+ }
117
+ var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/core/mesh/edge-client/src/edge-ws-connection.ts";
118
+ var SIGNAL_KEEPALIVE_INTERVAL = 4e3;
119
+ var SIGNAL_KEEPALIVE_TIMEOUT = 12e3;
120
+ var EdgeWsConnection = class extends import_context2.Resource {
121
+ constructor(_identity, _connectionInfo, _callbacks) {
122
+ super();
123
+ this._identity = _identity;
124
+ this._connectionInfo = _connectionInfo;
125
+ this._callbacks = _callbacks;
126
+ }
127
+ get info() {
128
+ return {
129
+ open: this.isOpen,
130
+ identity: this._identity.identityKey,
131
+ device: this._identity.peerKey
132
+ };
133
+ }
134
+ send(message) {
135
+ (0, import_invariant2.invariant)(this._ws, void 0, {
136
+ F: __dxlog_file2,
137
+ L: 52,
138
+ S: this,
139
+ A: [
140
+ "this._ws",
141
+ ""
142
+ ]
143
+ });
144
+ (0, import_invariant2.invariant)(this._wsMuxer, void 0, {
145
+ F: __dxlog_file2,
146
+ L: 53,
147
+ S: this,
148
+ A: [
149
+ "this._wsMuxer",
150
+ ""
151
+ ]
152
+ });
153
+ (0, import_log2.log)("sending...", {
154
+ peerKey: this._identity.peerKey,
155
+ payload: import_chunk_ZOL3YSDR.protocol.getPayloadType(message)
156
+ }, {
157
+ F: __dxlog_file2,
158
+ L: 54,
159
+ S: this,
160
+ C: (f, a) => f(...a)
161
+ });
162
+ if (this._ws?.protocol.includes(import_protocols.EdgeWebsocketProtocol.V0)) {
163
+ const binary = import_buf.buf.toBinary(import_messenger_pb.MessageSchema, message);
164
+ if (binary.length > import_chunk_ZOL3YSDR.CLOUDFLARE_MESSAGE_MAX_BYTES) {
165
+ import_log2.log.error("Message dropped because it was too large (>1MB).", {
166
+ byteLength: binary.byteLength,
167
+ serviceId: message.serviceId,
168
+ payload: import_chunk_ZOL3YSDR.protocol.getPayloadType(message)
169
+ }, {
170
+ F: __dxlog_file2,
171
+ L: 58,
172
+ S: this,
173
+ C: (f, a) => f(...a)
174
+ });
175
+ return;
176
+ }
177
+ this._ws.send(binary);
178
+ } else {
179
+ this._wsMuxer.send(message).catch((e) => import_log2.log.catch(e, void 0, {
180
+ F: __dxlog_file2,
181
+ L: 67,
182
+ S: this,
183
+ C: (f, a) => f(...a)
184
+ }));
185
+ }
186
+ }
187
+ async _open() {
188
+ const baseProtocols = [
189
+ ...Object.values(import_protocols.EdgeWebsocketProtocol)
190
+ ];
191
+ this._ws = new import_isomorphic_ws.default(this._connectionInfo.url.toString(), this._connectionInfo.protocolHeader ? [
192
+ ...baseProtocols,
193
+ this._connectionInfo.protocolHeader
194
+ ] : [
195
+ ...baseProtocols
196
+ ]);
197
+ const muxer = new import_chunk_ZOL3YSDR.WebSocketMuxer(this._ws);
198
+ this._wsMuxer = muxer;
199
+ this._ws.onopen = () => {
200
+ if (this.isOpen) {
201
+ (0, import_log2.log)("connected", void 0, {
202
+ F: __dxlog_file2,
203
+ L: 84,
204
+ S: this,
205
+ C: (f, a) => f(...a)
206
+ });
207
+ this._callbacks.onConnected();
208
+ this._scheduleHeartbeats();
209
+ } else {
210
+ import_log2.log.verbose("connected after becoming inactive", {
211
+ currentIdentity: this._identity
212
+ }, {
213
+ F: __dxlog_file2,
214
+ L: 88,
215
+ S: this,
216
+ C: (f, a) => f(...a)
217
+ });
218
+ }
219
+ };
220
+ this._ws.onclose = (event) => {
221
+ if (this.isOpen) {
222
+ import_log2.log.warn("disconnected while being open", {
223
+ code: event.code,
224
+ reason: event.reason
225
+ }, {
226
+ F: __dxlog_file2,
227
+ L: 93,
228
+ S: this,
229
+ C: (f, a) => f(...a)
230
+ });
231
+ this._callbacks.onRestartRequired();
232
+ muxer.destroy();
233
+ }
234
+ };
235
+ this._ws.onerror = (event) => {
236
+ if (this.isOpen) {
237
+ import_log2.log.warn("edge connection socket error", {
238
+ error: event.error,
239
+ info: event.message
240
+ }, {
241
+ F: __dxlog_file2,
242
+ L: 100,
243
+ S: this,
244
+ C: (f, a) => f(...a)
245
+ });
246
+ this._callbacks.onRestartRequired();
247
+ } else {
248
+ import_log2.log.verbose("error ignored on closed connection", {
249
+ error: event.error
250
+ }, {
251
+ F: __dxlog_file2,
252
+ L: 103,
253
+ S: this,
254
+ C: (f, a) => f(...a)
255
+ });
256
+ }
257
+ };
258
+ this._ws.onmessage = async (event) => {
259
+ if (!this.isOpen) {
260
+ import_log2.log.verbose("message ignored on closed connection", {
261
+ event: event.type
262
+ }, {
263
+ F: __dxlog_file2,
264
+ L: 111,
265
+ S: this,
266
+ C: (f, a) => f(...a)
267
+ });
268
+ return;
269
+ }
270
+ if (event.data === "__pong__") {
271
+ this._rescheduleHeartbeatTimeout();
272
+ return;
273
+ }
274
+ const bytes = await (0, import_chunk_ZOL3YSDR.toUint8Array)(event.data);
275
+ if (!this.isOpen) {
276
+ return;
277
+ }
278
+ const message = this._ws?.protocol?.includes(import_protocols.EdgeWebsocketProtocol.V0) ? import_buf.buf.fromBinary(import_messenger_pb.MessageSchema, bytes) : muxer.receiveData(bytes);
279
+ if (message) {
280
+ (0, import_log2.log)("received", {
281
+ from: message.source,
282
+ payload: import_chunk_ZOL3YSDR.protocol.getPayloadType(message)
283
+ }, {
284
+ F: __dxlog_file2,
285
+ L: 128,
286
+ S: this,
287
+ C: (f, a) => f(...a)
288
+ });
289
+ this._callbacks.onMessage(message);
290
+ }
291
+ };
292
+ }
293
+ async _close() {
294
+ void this._inactivityTimeoutCtx?.dispose().catch(() => {
295
+ });
296
+ try {
297
+ this._ws?.close();
298
+ this._ws = void 0;
299
+ this._wsMuxer?.destroy();
300
+ this._wsMuxer = void 0;
301
+ } catch (err) {
302
+ if (err instanceof Error && err.message.includes("WebSocket is closed before the connection is established.")) {
303
+ return;
304
+ }
305
+ import_log2.log.warn("Error closing websocket", {
306
+ err
307
+ }, {
308
+ F: __dxlog_file2,
309
+ L: 146,
310
+ S: this,
311
+ C: (f, a) => f(...a)
312
+ });
313
+ }
314
+ }
315
+ _scheduleHeartbeats() {
316
+ (0, import_invariant2.invariant)(this._ws, void 0, {
317
+ F: __dxlog_file2,
318
+ L: 151,
319
+ S: this,
320
+ A: [
321
+ "this._ws",
322
+ ""
323
+ ]
324
+ });
325
+ (0, import_async2.scheduleTaskInterval)(this._ctx, async () => {
326
+ this._ws?.send("__ping__");
327
+ }, SIGNAL_KEEPALIVE_INTERVAL);
328
+ this._ws.send("__ping__");
329
+ this._rescheduleHeartbeatTimeout();
330
+ }
331
+ _rescheduleHeartbeatTimeout() {
332
+ if (!this.isOpen) {
333
+ return;
334
+ }
335
+ void this._inactivityTimeoutCtx?.dispose();
336
+ this._inactivityTimeoutCtx = new import_context2.Context(void 0, {
337
+ F: __dxlog_file2,
338
+ L: 170
339
+ });
340
+ (0, import_async2.scheduleTask)(this._inactivityTimeoutCtx, () => {
341
+ if (this.isOpen) {
342
+ import_log2.log.warn("restart due to inactivity timeout", void 0, {
343
+ F: __dxlog_file2,
344
+ L: 175,
345
+ S: this,
346
+ C: (f, a) => f(...a)
347
+ });
348
+ this._callbacks.onRestartRequired();
349
+ }
350
+ }, SIGNAL_KEEPALIVE_TIMEOUT);
351
+ }
352
+ };
353
+ _ts_decorate([
354
+ import_log2.logInfo
355
+ ], EdgeWsConnection.prototype, "info", null);
92
356
  var EdgeConnectionClosedError = class extends Error {
93
357
  constructor() {
94
358
  super("Edge connection closed.");
@@ -105,13 +369,13 @@ var getEdgeUrlWithProtocol = (baseUrl, protocol2) => {
105
369
  url.protocol = protocol2 + (isSecure ? "s" : "");
106
370
  return url.toString();
107
371
  };
108
- function _ts_decorate(decorators, target, key, desc) {
372
+ function _ts_decorate2(decorators, target, key, desc) {
109
373
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
110
374
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
111
375
  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
376
  return c > 3 && r && Object.defineProperty(target, key, r), r;
113
377
  }
114
- var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/core/mesh/edge-client/src/edge-client.ts";
378
+ var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/core/mesh/edge-client/src/edge-client.ts";
115
379
  var DEFAULT_TIMEOUT = 1e4;
116
380
  var EdgeClient = class extends import_context.Resource {
117
381
  constructor(_identity, _config) {
@@ -154,7 +418,7 @@ var EdgeClient = class extends import_context.Resource {
154
418
  identity,
155
419
  oldIdentity: this._identity
156
420
  }, {
157
- F: __dxlog_file2,
421
+ F: __dxlog_file3,
158
422
  L: 99,
159
423
  S: this,
160
424
  C: (f, a) => f(...a)
@@ -177,7 +441,7 @@ var EdgeClient = class extends import_context.Resource {
177
441
  listener();
178
442
  } catch (error) {
179
443
  import_log.log.catch(error, void 0, {
180
- F: __dxlog_file2,
444
+ F: __dxlog_file3,
181
445
  L: 121,
182
446
  S: this,
183
447
  C: (f, a) => f(...a)
@@ -195,7 +459,7 @@ var EdgeClient = class extends import_context.Resource {
195
459
  (0, import_log.log)("opening...", {
196
460
  info: this.info
197
461
  }, {
198
- F: __dxlog_file2,
462
+ F: __dxlog_file3,
199
463
  L: 133,
200
464
  S: this,
201
465
  C: (f, a) => f(...a)
@@ -204,7 +468,7 @@ var EdgeClient = class extends import_context.Resource {
204
468
  import_log.log.warn("Error while opening connection", {
205
469
  err
206
470
  }, {
207
- F: __dxlog_file2,
471
+ F: __dxlog_file3,
208
472
  L: 135,
209
473
  S: this,
210
474
  C: (f, a) => f(...a)
@@ -218,7 +482,7 @@ var EdgeClient = class extends import_context.Resource {
218
482
  (0, import_log.log)("closing...", {
219
483
  peerKey: this._identity.peerKey
220
484
  }, {
221
- F: __dxlog_file2,
485
+ F: __dxlog_file3,
222
486
  L: 143,
223
487
  S: this,
224
488
  C: (f, a) => f(...a)
@@ -235,7 +499,7 @@ var EdgeClient = class extends import_context.Resource {
235
499
  const protocolHeader = this._config.disableAuth ? void 0 : await this._createAuthHeader(path);
236
500
  if (this._identity !== identity) {
237
501
  (0, import_log.log)("identity changed during auth header request", void 0, {
238
- F: __dxlog_file2,
502
+ F: __dxlog_file3,
239
503
  L: 157,
240
504
  S: this,
241
505
  C: (f, a) => f(...a)
@@ -248,12 +512,12 @@ var EdgeClient = class extends import_context.Resource {
248
512
  url: url.toString(),
249
513
  protocolHeader
250
514
  }, {
251
- F: __dxlog_file2,
515
+ F: __dxlog_file3,
252
516
  L: 163,
253
517
  S: this,
254
518
  C: (f, a) => f(...a)
255
519
  });
256
- const connection = new import_chunk_CNAHGYSS.EdgeWsConnection(identity, {
520
+ const connection = new EdgeWsConnection(identity, {
257
521
  url,
258
522
  protocolHeader
259
523
  }, {
@@ -263,7 +527,7 @@ var EdgeClient = class extends import_context.Resource {
263
527
  this._notifyReconnected();
264
528
  } else {
265
529
  import_log.log.verbose("connected callback ignored, because connection is not active", void 0, {
266
- F: __dxlog_file2,
530
+ F: __dxlog_file3,
267
531
  L: 173,
268
532
  S: this,
269
533
  C: (f, a) => f(...a)
@@ -276,7 +540,7 @@ var EdgeClient = class extends import_context.Resource {
276
540
  void this._persistentLifecycle.scheduleRestart();
277
541
  } else {
278
542
  import_log.log.verbose("restart requested by inactive connection", void 0, {
279
- F: __dxlog_file2,
543
+ F: __dxlog_file3,
280
544
  L: 181,
281
545
  S: this,
282
546
  C: (f, a) => f(...a)
@@ -292,7 +556,7 @@ var EdgeClient = class extends import_context.Resource {
292
556
  from: message.source,
293
557
  type: message.payload?.typeUrl
294
558
  }, {
295
- F: __dxlog_file2,
559
+ F: __dxlog_file3,
296
560
  L: 189,
297
561
  S: this,
298
562
  C: (f, a) => f(...a)
@@ -329,7 +593,7 @@ var EdgeClient = class extends import_context.Resource {
329
593
  import_log.log.error("ws reconnect listener failed", {
330
594
  err
331
595
  }, {
332
- F: __dxlog_file2,
596
+ F: __dxlog_file3,
333
597
  L: 225,
334
598
  S: this,
335
599
  C: (f, a) => f(...a)
@@ -344,9 +608,9 @@ var EdgeClient = class extends import_context.Resource {
344
608
  } catch (err) {
345
609
  import_log.log.error("ws incoming message processing failed", {
346
610
  err,
347
- payload: import_chunk_CNAHGYSS.protocol.getPayloadType(message)
611
+ payload: import_chunk_ZOL3YSDR.protocol.getPayloadType(message)
348
612
  }, {
349
- F: __dxlog_file2,
613
+ F: __dxlog_file3,
350
614
  L: 235,
351
615
  S: this,
352
616
  C: (f, a) => f(...a)
@@ -361,7 +625,7 @@ var EdgeClient = class extends import_context.Resource {
361
625
  async send(message) {
362
626
  if (this._ready.state !== import_async.TriggerState.RESOLVED) {
363
627
  (0, import_log.log)("waiting for websocket to become ready", void 0, {
364
- F: __dxlog_file2,
628
+ F: __dxlog_file3,
365
629
  L: 246,
366
630
  S: this,
367
631
  C: (f, a) => f(...a)
@@ -391,7 +655,7 @@ var EdgeClient = class extends import_context.Resource {
391
655
  status: response.status,
392
656
  statusText: response.statusText
393
657
  }, {
394
- F: __dxlog_file2,
658
+ F: __dxlog_file3,
395
659
  L: 271,
396
660
  S: this,
397
661
  C: (f, a) => f(...a)
@@ -400,14 +664,14 @@ var EdgeClient = class extends import_context.Resource {
400
664
  }
401
665
  }
402
666
  };
403
- _ts_decorate([
667
+ _ts_decorate2([
404
668
  import_log.logInfo
405
669
  ], EdgeClient.prototype, "info", null);
406
670
  var encodePresentationWsAuthHeader = (encodedPresentation) => {
407
671
  const encodedToken = Buffer.from(encodedPresentation).toString("base64").replace(/=*$/, "").replaceAll("/", "|");
408
672
  return `base64url.bearer.authorization.dxos.org.${encodedToken}`;
409
673
  };
410
- var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/core/mesh/edge-client/src/auth.ts";
674
+ var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/core/mesh/edge-client/src/auth.ts";
411
675
  var createDeviceEdgeIdentity = async (signer, key) => {
412
676
  return {
413
677
  identityKey: key.toHex(),
@@ -451,8 +715,8 @@ var createChainEdgeIdentity = async (signer, identityKey, peerKey, chain, creden
451
715
  identityKey: identityKey.toHex(),
452
716
  peerKey: peerKey.toHex(),
453
717
  presentCredentials: async ({ challenge }) => {
454
- (0, import_invariant2.invariant)(chain, void 0, {
455
- F: __dxlog_file3,
718
+ (0, import_invariant3.invariant)(chain, void 0, {
719
+ F: __dxlog_file4,
456
720
  L: 75,
457
721
  S: void 0,
458
722
  A: [
@@ -512,17 +776,17 @@ var createStubEdgeIdentity = () => {
512
776
  }
513
777
  };
514
778
  };
515
- var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/core/mesh/edge-client/src/edge-http-client.ts";
779
+ var __dxlog_file5 = "/home/runner/work/dxos/dxos/packages/core/mesh/edge-client/src/edge-http-client.ts";
516
780
  var DEFAULT_RETRY_TIMEOUT = 1500;
517
781
  var DEFAULT_RETRY_JITTER = 500;
518
782
  var DEFAULT_MAX_RETRIES_COUNT = 3;
519
783
  var EdgeHttpClient = class {
520
784
  constructor(baseUrl) {
521
785
  this._baseUrl = getEdgeUrlWithProtocol(baseUrl, "http");
522
- (0, import_log2.log)("created", {
786
+ (0, import_log3.log)("created", {
523
787
  url: this._baseUrl
524
788
  }, {
525
- F: __dxlog_file4,
789
+ F: __dxlog_file5,
526
790
  L: 53,
527
791
  S: this,
528
792
  C: (f, a) => f(...a)
@@ -587,7 +851,6 @@ var EdgeHttpClient = class {
587
851
  async uploadFunction(pathParts, body, args) {
588
852
  const path = [
589
853
  "functions",
590
- pathParts.spaceId,
591
854
  ...pathParts.functionId ? [
592
855
  pathParts.functionId
593
856
  ] : []
@@ -654,8 +917,8 @@ var EdgeHttpClient = class {
654
917
  });
655
918
  }
656
919
  async _call(path, args) {
657
- const requestContext = args.context ?? new import_context2.Context(void 0, {
658
- F: __dxlog_file4,
920
+ const requestContext = args.context ?? new import_context3.Context(void 0, {
921
+ F: __dxlog_file5,
659
922
  L: 192
660
923
  });
661
924
  const shouldRetry = createRetryHandler(args);
@@ -667,12 +930,12 @@ var EdgeHttpClient = class {
667
930
  }
668
931
  url += `?${queryParams.toString()}`;
669
932
  }
670
- (0, import_log2.log)("call", {
933
+ (0, import_log3.log)("call", {
671
934
  method: args.method,
672
935
  path,
673
936
  request: args.body
674
937
  }, {
675
- F: __dxlog_file4,
938
+ F: __dxlog_file5,
676
939
  L: 204,
677
940
  S: this,
678
941
  C: (f, a) => f(...a)
@@ -691,36 +954,36 @@ var EdgeHttpClient = class {
691
954
  if (body.success) {
692
955
  return body.data;
693
956
  }
694
- (0, import_log2.log)("unsuccessful edge response", {
957
+ (0, import_log3.log)("unsuccessful edge response", {
695
958
  path,
696
959
  body
697
960
  }, {
698
- F: __dxlog_file4,
961
+ F: __dxlog_file5,
699
962
  L: 223,
700
963
  S: this,
701
964
  C: (f, a) => f(...a)
702
965
  });
703
966
  if (body.errorData?.type === "auth_challenge" && typeof body.errorData?.challenge === "string") {
704
- processingError = new import_protocols.EdgeAuthChallengeError(body.errorData.challenge, body.errorData);
967
+ processingError = new import_protocols2.EdgeAuthChallengeError(body.errorData.challenge, body.errorData);
705
968
  } else {
706
- processingError = import_protocols.EdgeCallFailedError.fromUnsuccessfulResponse(response, body);
969
+ processingError = import_protocols2.EdgeCallFailedError.fromUnsuccessfulResponse(response, body);
707
970
  }
708
971
  } else if (response.status === 401 && !handledAuth) {
709
972
  authHeader = await this._handleUnauthorized(response);
710
973
  handledAuth = true;
711
974
  continue;
712
975
  } else {
713
- processingError = import_protocols.EdgeCallFailedError.fromHttpFailure(response);
976
+ processingError = import_protocols2.EdgeCallFailedError.fromHttpFailure(response);
714
977
  }
715
978
  } catch (error) {
716
- processingError = import_protocols.EdgeCallFailedError.fromProcessingFailureCause(error);
979
+ processingError = import_protocols2.EdgeCallFailedError.fromProcessingFailureCause(error);
717
980
  }
718
981
  if (processingError.isRetryable && await shouldRetry(requestContext, retryAfterHeaderValue)) {
719
- (0, import_log2.log)("retrying edge request", {
982
+ (0, import_log3.log)("retrying edge request", {
720
983
  path,
721
984
  processingError
722
985
  }, {
723
- F: __dxlog_file4,
986
+ F: __dxlog_file5,
724
987
  L: 242,
725
988
  S: this,
726
989
  C: (f, a) => f(...a)
@@ -732,18 +995,18 @@ var EdgeHttpClient = class {
732
995
  }
733
996
  async _handleUnauthorized(response) {
734
997
  if (!this._edgeIdentity) {
735
- import_log2.log.warn("edge unauthorized response received before identity was set", void 0, {
736
- F: __dxlog_file4,
998
+ import_log3.log.warn("edge unauthorized response received before identity was set", void 0, {
999
+ F: __dxlog_file5,
737
1000
  L: 251,
738
1001
  S: this,
739
1002
  C: (f, a) => f(...a)
740
1003
  });
741
- throw import_protocols.EdgeCallFailedError.fromHttpFailure(response);
1004
+ throw import_protocols2.EdgeCallFailedError.fromHttpFailure(response);
742
1005
  }
743
1006
  const challenge = await handleAuthChallenge(response, this._edgeIdentity);
744
1007
  this._authHeader = encodeAuthHeader(challenge);
745
- (0, import_log2.log)("auth header updated", void 0, {
746
- F: __dxlog_file4,
1008
+ (0, import_log3.log)("auth header updated", void 0, {
1009
+ F: __dxlog_file5,
747
1010
  L: 256,
748
1011
  S: this,
749
1012
  C: (f, a) => f(...a)
@@ -764,10 +1027,10 @@ var createRetryHandler = (args) => {
764
1027
  return false;
765
1028
  }
766
1029
  if (retryAfter) {
767
- await (0, import_async2.sleep)(retryAfter);
1030
+ await (0, import_async3.sleep)(retryAfter);
768
1031
  } else {
769
1032
  const timeout = baseTimeout + Math.random() * jitter;
770
- await (0, import_async2.sleep)(timeout);
1033
+ await (0, import_async3.sleep)(timeout);
771
1034
  }
772
1035
  return true;
773
1036
  };
@@ -787,7 +1050,8 @@ var encodeAuthHeader = (challenge) => {
787
1050
  };
788
1051
  // Annotate the CommonJS export names for ESM import in node:
789
1052
  0 && (module.exports = {
790
- CLOUDFLARE_MESSAGE_LENGTH_LIMIT,
1053
+ CLOUDFLARE_MESSAGE_MAX_BYTES,
1054
+ CLOUDFLARE_RPC_MAX_BYTES,
791
1055
  EdgeClient,
792
1056
  EdgeConnectionClosedError,
793
1057
  EdgeHttpClient,