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

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-XS3TKGM4.mjs +545 -0
  2. package/dist/lib/browser/chunk-XS3TKGM4.mjs.map +7 -0
  3. package/dist/lib/browser/index.mjs +58 -318
  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 +3 -3
  7. package/dist/lib/browser/testing/index.mjs.map +3 -3
  8. package/dist/lib/node/chunk-ZURVCY7K.cjs +577 -0
  9. package/dist/lib/node/chunk-ZURVCY7K.cjs.map +7 -0
  10. package/dist/lib/node/index.cjs +53 -322
  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 +5 -6
  14. package/dist/lib/node/testing/index.cjs.map +3 -3
  15. package/dist/lib/node-esm/chunk-HNRMNQPG.mjs +547 -0
  16. package/dist/lib/node-esm/chunk-HNRMNQPG.mjs.map +7 -0
  17. package/dist/lib/node-esm/index.mjs +58 -318
  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 +3 -3
  21. package/dist/lib/node-esm/testing/index.mjs.map +3 -3
  22. package/dist/types/src/edge-ws-connection.d.ts +4 -0
  23. package/dist/types/src/edge-ws-connection.d.ts.map +1 -1
  24. package/dist/types/src/edge-ws-muxer.d.ts +7 -19
  25. package/dist/types/src/edge-ws-muxer.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.map +1 -1
  29. package/package.json +14 -19
  30. package/src/edge-ws-connection.ts +11 -6
  31. package/src/edge-ws-muxer.ts +33 -63
  32. package/src/index.ts +0 -1
  33. package/src/testing/test-utils.ts +2 -2
  34. package/dist/lib/browser/chunk-TKYUZ5ZK.mjs +0 -302
  35. package/dist/lib/browser/chunk-TKYUZ5ZK.mjs.map +0 -7
  36. package/dist/lib/browser/edge-ws-muxer.mjs +0 -11
  37. package/dist/lib/browser/edge-ws-muxer.mjs.map +0 -7
  38. package/dist/lib/node/chunk-ZOL3YSDR.cjs +0 -322
  39. package/dist/lib/node/chunk-ZOL3YSDR.cjs.map +0 -7
  40. package/dist/lib/node/edge-ws-muxer.cjs +0 -33
  41. package/dist/lib/node/edge-ws-muxer.cjs.map +0 -7
  42. package/dist/lib/node-esm/chunk-25HGRGNZ.mjs +0 -304
  43. package/dist/lib/node-esm/chunk-25HGRGNZ.mjs.map +0 -7
  44. package/dist/lib/node-esm/edge-ws-muxer.mjs +0 -12
  45. package/dist/lib/node-esm/edge-ws-muxer.mjs.map +0 -7
  46. package/dist/types/src/edge-ws-muxer.test.d.ts +0 -2
  47. package/dist/types/src/edge-ws-muxer.test.d.ts.map +0 -1
  48. package/src/edge-ws-muxer.test.ts +0 -55
@@ -1,9 +1,7 @@
1
1
  "use strict";
2
- var __create = Object.create;
3
2
  var __defProp = Object.defineProperty;
4
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
5
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
6
  var __export = (target, all) => {
9
7
  for (var name in all)
@@ -18,37 +16,26 @@ var __copyProps = (to, from, except, desc) => {
18
16
  return to;
19
17
  };
20
18
  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
- ));
29
19
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
30
20
  var node_exports = {};
31
21
  __export(node_exports, {
32
- CLOUDFLARE_MESSAGE_MAX_BYTES: () => import_chunk_ZOL3YSDR.CLOUDFLARE_MESSAGE_MAX_BYTES,
33
- CLOUDFLARE_RPC_MAX_BYTES: () => import_chunk_ZOL3YSDR.CLOUDFLARE_RPC_MAX_BYTES,
34
22
  EdgeClient: () => EdgeClient,
35
23
  EdgeConnectionClosedError: () => EdgeConnectionClosedError,
36
24
  EdgeHttpClient: () => EdgeHttpClient,
37
25
  EdgeIdentityChangedError: () => EdgeIdentityChangedError,
38
- Protocol: () => import_chunk_ZOL3YSDR.Protocol,
39
- WebSocketMuxer: () => import_chunk_ZOL3YSDR.WebSocketMuxer,
26
+ Protocol: () => import_chunk_ZURVCY7K.Protocol,
40
27
  createChainEdgeIdentity: () => createChainEdgeIdentity,
41
28
  createDeviceEdgeIdentity: () => createDeviceEdgeIdentity,
42
29
  createEphemeralEdgeIdentity: () => createEphemeralEdgeIdentity,
43
30
  createStubEdgeIdentity: () => createStubEdgeIdentity,
44
31
  createTestHaloEdgeIdentity: () => createTestHaloEdgeIdentity,
45
- getTypename: () => import_chunk_ZOL3YSDR.getTypename,
32
+ getTypename: () => import_chunk_ZURVCY7K.getTypename,
46
33
  handleAuthChallenge: () => handleAuthChallenge,
47
- protocol: () => import_chunk_ZOL3YSDR.protocol,
48
- toUint8Array: () => import_chunk_ZOL3YSDR.toUint8Array
34
+ protocol: () => import_chunk_ZURVCY7K.protocol,
35
+ toUint8Array: () => import_chunk_ZURVCY7K.toUint8Array
49
36
  });
50
37
  module.exports = __toCommonJS(node_exports);
51
- var import_chunk_ZOL3YSDR = require("./chunk-ZOL3YSDR.cjs");
38
+ var import_chunk_ZURVCY7K = require("./chunk-ZURVCY7K.cjs");
52
39
  __reExport(node_exports, require("@dxos/protocols/buf/dxos/edge/messenger_pb"), module.exports);
53
40
  var import_async = require("@dxos/async");
54
41
  var import_context = require("@dxos/context");
@@ -56,22 +43,14 @@ var import_log = require("@dxos/log");
56
43
  var import_services = require("@dxos/protocols/proto/dxos/client/services");
57
44
  var import_invariant = require("@dxos/invariant");
58
45
  var import_proto = require("@dxos/protocols/proto");
59
- var import_isomorphic_ws = __toESM(require("isomorphic-ws"));
46
+ var import_credentials = require("@dxos/credentials");
47
+ var import_invariant2 = require("@dxos/invariant");
48
+ var import_keyring = require("@dxos/keyring");
49
+ var import_keys = require("@dxos/keys");
60
50
  var import_async2 = require("@dxos/async");
61
51
  var import_context2 = require("@dxos/context");
62
- var import_invariant2 = require("@dxos/invariant");
63
52
  var import_log2 = require("@dxos/log");
64
53
  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");
75
54
  var __dxlog_file = "/home/runner/work/dxos/dxos/packages/core/mesh/edge-client/src/edge-identity.ts";
76
55
  var handleAuthChallenge = async (failedResponse, identity) => {
77
56
  (0, import_invariant.invariant)(failedResponse.status === 401, void 0, {
@@ -108,251 +87,6 @@ var handleAuthChallenge = async (failedResponse, identity) => {
108
87
  });
109
88
  return import_proto.schema.getCodecForType("dxos.halo.credentials.Presentation").encode(presentation);
110
89
  };
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);
356
90
  var EdgeConnectionClosedError = class extends Error {
357
91
  constructor() {
358
92
  super("Edge connection closed.");
@@ -369,13 +103,13 @@ var getEdgeUrlWithProtocol = (baseUrl, protocol2) => {
369
103
  url.protocol = protocol2 + (isSecure ? "s" : "");
370
104
  return url.toString();
371
105
  };
372
- function _ts_decorate2(decorators, target, key, desc) {
106
+ function _ts_decorate(decorators, target, key, desc) {
373
107
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
374
108
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
375
109
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
376
110
  return c > 3 && r && Object.defineProperty(target, key, r), r;
377
111
  }
378
- var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/core/mesh/edge-client/src/edge-client.ts";
112
+ var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/core/mesh/edge-client/src/edge-client.ts";
379
113
  var DEFAULT_TIMEOUT = 1e4;
380
114
  var EdgeClient = class extends import_context.Resource {
381
115
  constructor(_identity, _config) {
@@ -418,7 +152,7 @@ var EdgeClient = class extends import_context.Resource {
418
152
  identity,
419
153
  oldIdentity: this._identity
420
154
  }, {
421
- F: __dxlog_file3,
155
+ F: __dxlog_file2,
422
156
  L: 99,
423
157
  S: this,
424
158
  C: (f, a) => f(...a)
@@ -441,7 +175,7 @@ var EdgeClient = class extends import_context.Resource {
441
175
  listener();
442
176
  } catch (error) {
443
177
  import_log.log.catch(error, void 0, {
444
- F: __dxlog_file3,
178
+ F: __dxlog_file2,
445
179
  L: 121,
446
180
  S: this,
447
181
  C: (f, a) => f(...a)
@@ -459,7 +193,7 @@ var EdgeClient = class extends import_context.Resource {
459
193
  (0, import_log.log)("opening...", {
460
194
  info: this.info
461
195
  }, {
462
- F: __dxlog_file3,
196
+ F: __dxlog_file2,
463
197
  L: 133,
464
198
  S: this,
465
199
  C: (f, a) => f(...a)
@@ -468,7 +202,7 @@ var EdgeClient = class extends import_context.Resource {
468
202
  import_log.log.warn("Error while opening connection", {
469
203
  err
470
204
  }, {
471
- F: __dxlog_file3,
205
+ F: __dxlog_file2,
472
206
  L: 135,
473
207
  S: this,
474
208
  C: (f, a) => f(...a)
@@ -482,7 +216,7 @@ var EdgeClient = class extends import_context.Resource {
482
216
  (0, import_log.log)("closing...", {
483
217
  peerKey: this._identity.peerKey
484
218
  }, {
485
- F: __dxlog_file3,
219
+ F: __dxlog_file2,
486
220
  L: 143,
487
221
  S: this,
488
222
  C: (f, a) => f(...a)
@@ -499,7 +233,7 @@ var EdgeClient = class extends import_context.Resource {
499
233
  const protocolHeader = this._config.disableAuth ? void 0 : await this._createAuthHeader(path);
500
234
  if (this._identity !== identity) {
501
235
  (0, import_log.log)("identity changed during auth header request", void 0, {
502
- F: __dxlog_file3,
236
+ F: __dxlog_file2,
503
237
  L: 157,
504
238
  S: this,
505
239
  C: (f, a) => f(...a)
@@ -512,12 +246,12 @@ var EdgeClient = class extends import_context.Resource {
512
246
  url: url.toString(),
513
247
  protocolHeader
514
248
  }, {
515
- F: __dxlog_file3,
249
+ F: __dxlog_file2,
516
250
  L: 163,
517
251
  S: this,
518
252
  C: (f, a) => f(...a)
519
253
  });
520
- const connection = new EdgeWsConnection(identity, {
254
+ const connection = new import_chunk_ZURVCY7K.EdgeWsConnection(identity, {
521
255
  url,
522
256
  protocolHeader
523
257
  }, {
@@ -527,7 +261,7 @@ var EdgeClient = class extends import_context.Resource {
527
261
  this._notifyReconnected();
528
262
  } else {
529
263
  import_log.log.verbose("connected callback ignored, because connection is not active", void 0, {
530
- F: __dxlog_file3,
264
+ F: __dxlog_file2,
531
265
  L: 173,
532
266
  S: this,
533
267
  C: (f, a) => f(...a)
@@ -540,7 +274,7 @@ var EdgeClient = class extends import_context.Resource {
540
274
  void this._persistentLifecycle.scheduleRestart();
541
275
  } else {
542
276
  import_log.log.verbose("restart requested by inactive connection", void 0, {
543
- F: __dxlog_file3,
277
+ F: __dxlog_file2,
544
278
  L: 181,
545
279
  S: this,
546
280
  C: (f, a) => f(...a)
@@ -556,7 +290,7 @@ var EdgeClient = class extends import_context.Resource {
556
290
  from: message.source,
557
291
  type: message.payload?.typeUrl
558
292
  }, {
559
- F: __dxlog_file3,
293
+ F: __dxlog_file2,
560
294
  L: 189,
561
295
  S: this,
562
296
  C: (f, a) => f(...a)
@@ -593,7 +327,7 @@ var EdgeClient = class extends import_context.Resource {
593
327
  import_log.log.error("ws reconnect listener failed", {
594
328
  err
595
329
  }, {
596
- F: __dxlog_file3,
330
+ F: __dxlog_file2,
597
331
  L: 225,
598
332
  S: this,
599
333
  C: (f, a) => f(...a)
@@ -608,9 +342,9 @@ var EdgeClient = class extends import_context.Resource {
608
342
  } catch (err) {
609
343
  import_log.log.error("ws incoming message processing failed", {
610
344
  err,
611
- payload: import_chunk_ZOL3YSDR.protocol.getPayloadType(message)
345
+ payload: import_chunk_ZURVCY7K.protocol.getPayloadType(message)
612
346
  }, {
613
- F: __dxlog_file3,
347
+ F: __dxlog_file2,
614
348
  L: 235,
615
349
  S: this,
616
350
  C: (f, a) => f(...a)
@@ -625,7 +359,7 @@ var EdgeClient = class extends import_context.Resource {
625
359
  async send(message) {
626
360
  if (this._ready.state !== import_async.TriggerState.RESOLVED) {
627
361
  (0, import_log.log)("waiting for websocket to become ready", void 0, {
628
- F: __dxlog_file3,
362
+ F: __dxlog_file2,
629
363
  L: 246,
630
364
  S: this,
631
365
  C: (f, a) => f(...a)
@@ -655,7 +389,7 @@ var EdgeClient = class extends import_context.Resource {
655
389
  status: response.status,
656
390
  statusText: response.statusText
657
391
  }, {
658
- F: __dxlog_file3,
392
+ F: __dxlog_file2,
659
393
  L: 271,
660
394
  S: this,
661
395
  C: (f, a) => f(...a)
@@ -664,14 +398,14 @@ var EdgeClient = class extends import_context.Resource {
664
398
  }
665
399
  }
666
400
  };
667
- _ts_decorate2([
401
+ _ts_decorate([
668
402
  import_log.logInfo
669
403
  ], EdgeClient.prototype, "info", null);
670
404
  var encodePresentationWsAuthHeader = (encodedPresentation) => {
671
405
  const encodedToken = Buffer.from(encodedPresentation).toString("base64").replace(/=*$/, "").replaceAll("/", "|");
672
406
  return `base64url.bearer.authorization.dxos.org.${encodedToken}`;
673
407
  };
674
- var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/core/mesh/edge-client/src/auth.ts";
408
+ var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/core/mesh/edge-client/src/auth.ts";
675
409
  var createDeviceEdgeIdentity = async (signer, key) => {
676
410
  return {
677
411
  identityKey: key.toHex(),
@@ -715,8 +449,8 @@ var createChainEdgeIdentity = async (signer, identityKey, peerKey, chain, creden
715
449
  identityKey: identityKey.toHex(),
716
450
  peerKey: peerKey.toHex(),
717
451
  presentCredentials: async ({ challenge }) => {
718
- (0, import_invariant3.invariant)(chain, void 0, {
719
- F: __dxlog_file4,
452
+ (0, import_invariant2.invariant)(chain, void 0, {
453
+ F: __dxlog_file3,
720
454
  L: 75,
721
455
  S: void 0,
722
456
  A: [
@@ -776,17 +510,17 @@ var createStubEdgeIdentity = () => {
776
510
  }
777
511
  };
778
512
  };
779
- var __dxlog_file5 = "/home/runner/work/dxos/dxos/packages/core/mesh/edge-client/src/edge-http-client.ts";
513
+ var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/core/mesh/edge-client/src/edge-http-client.ts";
780
514
  var DEFAULT_RETRY_TIMEOUT = 1500;
781
515
  var DEFAULT_RETRY_JITTER = 500;
782
516
  var DEFAULT_MAX_RETRIES_COUNT = 3;
783
517
  var EdgeHttpClient = class {
784
518
  constructor(baseUrl) {
785
519
  this._baseUrl = getEdgeUrlWithProtocol(baseUrl, "http");
786
- (0, import_log3.log)("created", {
520
+ (0, import_log2.log)("created", {
787
521
  url: this._baseUrl
788
522
  }, {
789
- F: __dxlog_file5,
523
+ F: __dxlog_file4,
790
524
  L: 53,
791
525
  S: this,
792
526
  C: (f, a) => f(...a)
@@ -918,8 +652,8 @@ var EdgeHttpClient = class {
918
652
  });
919
653
  }
920
654
  async _call(path, args) {
921
- const requestContext = args.context ?? new import_context3.Context(void 0, {
922
- F: __dxlog_file5,
655
+ const requestContext = args.context ?? new import_context2.Context(void 0, {
656
+ F: __dxlog_file4,
923
657
  L: 192
924
658
  });
925
659
  const shouldRetry = createRetryHandler(args);
@@ -931,12 +665,12 @@ var EdgeHttpClient = class {
931
665
  }
932
666
  url += `?${queryParams.toString()}`;
933
667
  }
934
- (0, import_log3.log)("call", {
668
+ (0, import_log2.log)("call", {
935
669
  method: args.method,
936
670
  path,
937
671
  request: args.body
938
672
  }, {
939
- F: __dxlog_file5,
673
+ F: __dxlog_file4,
940
674
  L: 204,
941
675
  S: this,
942
676
  C: (f, a) => f(...a)
@@ -955,36 +689,36 @@ var EdgeHttpClient = class {
955
689
  if (body.success) {
956
690
  return body.data;
957
691
  }
958
- (0, import_log3.log)("unsuccessful edge response", {
692
+ (0, import_log2.log)("unsuccessful edge response", {
959
693
  path,
960
694
  body
961
695
  }, {
962
- F: __dxlog_file5,
696
+ F: __dxlog_file4,
963
697
  L: 223,
964
698
  S: this,
965
699
  C: (f, a) => f(...a)
966
700
  });
967
701
  if (body.errorData?.type === "auth_challenge" && typeof body.errorData?.challenge === "string") {
968
- processingError = new import_protocols2.EdgeAuthChallengeError(body.errorData.challenge, body.errorData);
702
+ processingError = new import_protocols.EdgeAuthChallengeError(body.errorData.challenge, body.errorData);
969
703
  } else {
970
- processingError = import_protocols2.EdgeCallFailedError.fromUnsuccessfulResponse(response, body);
704
+ processingError = import_protocols.EdgeCallFailedError.fromUnsuccessfulResponse(response, body);
971
705
  }
972
706
  } else if (response.status === 401 && !handledAuth) {
973
707
  authHeader = await this._handleUnauthorized(response);
974
708
  handledAuth = true;
975
709
  continue;
976
710
  } else {
977
- processingError = import_protocols2.EdgeCallFailedError.fromHttpFailure(response);
711
+ processingError = import_protocols.EdgeCallFailedError.fromHttpFailure(response);
978
712
  }
979
713
  } catch (error) {
980
- processingError = import_protocols2.EdgeCallFailedError.fromProcessingFailureCause(error);
714
+ processingError = import_protocols.EdgeCallFailedError.fromProcessingFailureCause(error);
981
715
  }
982
716
  if (processingError.isRetryable && await shouldRetry(requestContext, retryAfterHeaderValue)) {
983
- (0, import_log3.log)("retrying edge request", {
717
+ (0, import_log2.log)("retrying edge request", {
984
718
  path,
985
719
  processingError
986
720
  }, {
987
- F: __dxlog_file5,
721
+ F: __dxlog_file4,
988
722
  L: 242,
989
723
  S: this,
990
724
  C: (f, a) => f(...a)
@@ -996,18 +730,18 @@ var EdgeHttpClient = class {
996
730
  }
997
731
  async _handleUnauthorized(response) {
998
732
  if (!this._edgeIdentity) {
999
- import_log3.log.warn("edge unauthorized response received before identity was set", void 0, {
1000
- F: __dxlog_file5,
733
+ import_log2.log.warn("edge unauthorized response received before identity was set", void 0, {
734
+ F: __dxlog_file4,
1001
735
  L: 251,
1002
736
  S: this,
1003
737
  C: (f, a) => f(...a)
1004
738
  });
1005
- throw import_protocols2.EdgeCallFailedError.fromHttpFailure(response);
739
+ throw import_protocols.EdgeCallFailedError.fromHttpFailure(response);
1006
740
  }
1007
741
  const challenge = await handleAuthChallenge(response, this._edgeIdentity);
1008
742
  this._authHeader = encodeAuthHeader(challenge);
1009
- (0, import_log3.log)("auth header updated", void 0, {
1010
- F: __dxlog_file5,
743
+ (0, import_log2.log)("auth header updated", void 0, {
744
+ F: __dxlog_file4,
1011
745
  L: 256,
1012
746
  S: this,
1013
747
  C: (f, a) => f(...a)
@@ -1028,10 +762,10 @@ var createRetryHandler = (args) => {
1028
762
  return false;
1029
763
  }
1030
764
  if (retryAfter) {
1031
- await (0, import_async3.sleep)(retryAfter);
765
+ await (0, import_async2.sleep)(retryAfter);
1032
766
  } else {
1033
767
  const timeout = baseTimeout + Math.random() * jitter;
1034
- await (0, import_async3.sleep)(timeout);
768
+ await (0, import_async2.sleep)(timeout);
1035
769
  }
1036
770
  return true;
1037
771
  };
@@ -1051,14 +785,11 @@ var encodeAuthHeader = (challenge) => {
1051
785
  };
1052
786
  // Annotate the CommonJS export names for ESM import in node:
1053
787
  0 && (module.exports = {
1054
- CLOUDFLARE_MESSAGE_MAX_BYTES,
1055
- CLOUDFLARE_RPC_MAX_BYTES,
1056
788
  EdgeClient,
1057
789
  EdgeConnectionClosedError,
1058
790
  EdgeHttpClient,
1059
791
  EdgeIdentityChangedError,
1060
792
  Protocol,
1061
- WebSocketMuxer,
1062
793
  createChainEdgeIdentity,
1063
794
  createDeviceEdgeIdentity,
1064
795
  createEphemeralEdgeIdentity,