@dxos/edge-client 0.8.1 → 0.8.2-main.10c050d
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.
- package/dist/lib/browser/chunk-VHS3XEIX.mjs +297 -0
- package/dist/lib/browser/chunk-VHS3XEIX.mjs.map +7 -0
- package/dist/lib/browser/edge-ws-muxer.mjs +11 -0
- package/dist/lib/browser/edge-ws-muxer.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +95 -64
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/testing/index.mjs +32 -20
- package/dist/lib/browser/testing/index.mjs.map +3 -3
- package/dist/lib/node/chunk-XNHBUTNB.cjs +317 -0
- package/dist/lib/node/chunk-XNHBUTNB.cjs.map +7 -0
- package/dist/lib/node/edge-ws-muxer.cjs +33 -0
- package/dist/lib/node/edge-ws-muxer.cjs.map +7 -0
- package/dist/lib/node/index.cjs +107 -76
- package/dist/lib/node/index.cjs.map +3 -3
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/testing/index.cjs +32 -21
- package/dist/lib/node/testing/index.cjs.map +3 -3
- package/dist/lib/node-esm/chunk-HGQUUFIJ.mjs +299 -0
- package/dist/lib/node-esm/chunk-HGQUUFIJ.mjs.map +7 -0
- package/dist/lib/node-esm/edge-ws-muxer.mjs +12 -0
- package/dist/lib/node-esm/edge-ws-muxer.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +95 -64
- package/dist/lib/node-esm/index.mjs.map +3 -3
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/testing/index.mjs +32 -20
- package/dist/lib/node-esm/testing/index.mjs.map +3 -3
- package/dist/types/src/auth.d.ts.map +1 -1
- package/dist/types/src/edge-client.d.ts +7 -2
- package/dist/types/src/edge-client.d.ts.map +1 -1
- package/dist/types/src/edge-http-client.d.ts +0 -1
- package/dist/types/src/edge-http-client.d.ts.map +1 -1
- package/dist/types/src/edge-identity.d.ts.map +1 -1
- package/dist/types/src/edge-ws-connection.d.ts +1 -0
- package/dist/types/src/edge-ws-connection.d.ts.map +1 -1
- package/dist/types/src/edge-ws-muxer.d.ts +35 -0
- package/dist/types/src/edge-ws-muxer.d.ts.map +1 -0
- package/dist/types/src/edge-ws-muxer.test.d.ts +2 -0
- package/dist/types/src/edge-ws-muxer.test.d.ts.map +1 -0
- package/dist/types/src/index.d.ts +1 -0
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/protocol.d.ts.map +1 -1
- package/dist/types/src/testing/test-utils.d.ts +6 -2
- package/dist/types/src/testing/test-utils.d.ts.map +1 -1
- package/dist/types/src/utils.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +19 -14
- package/src/edge-client.test.ts +5 -4
- package/src/edge-client.ts +23 -15
- package/src/edge-http-client.ts +4 -4
- package/src/edge-ws-connection.ts +41 -23
- package/src/edge-ws-muxer.test.ts +55 -0
- package/src/edge-ws-muxer.ts +217 -0
- package/src/index.ts +1 -0
- package/src/protocol.ts +1 -1
- package/src/testing/test-utils.ts +33 -26
- package/dist/lib/browser/chunk-ZWJXA37R.mjs +0 -113
- package/dist/lib/browser/chunk-ZWJXA37R.mjs.map +0 -7
- package/dist/lib/node/chunk-ANV2HBEH.cjs +0 -136
- package/dist/lib/node/chunk-ANV2HBEH.cjs.map +0 -7
- package/dist/lib/node-esm/chunk-HNVT57AU.mjs +0 -115
- package/dist/lib/node-esm/chunk-HNVT57AU.mjs.map +0 -7
package/dist/lib/node/index.cjs
CHANGED
|
@@ -29,27 +29,31 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
29
29
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
30
30
|
var node_exports = {};
|
|
31
31
|
__export(node_exports, {
|
|
32
|
+
CLOUDFLARE_MESSAGE_MAX_BYTES: () => import_chunk_XNHBUTNB.CLOUDFLARE_MESSAGE_MAX_BYTES,
|
|
33
|
+
CLOUDFLARE_RPC_MAX_BYTES: () => import_chunk_XNHBUTNB.CLOUDFLARE_RPC_MAX_BYTES,
|
|
32
34
|
EdgeClient: () => EdgeClient,
|
|
33
35
|
EdgeConnectionClosedError: () => EdgeConnectionClosedError,
|
|
34
36
|
EdgeHttpClient: () => EdgeHttpClient,
|
|
35
37
|
EdgeIdentityChangedError: () => EdgeIdentityChangedError,
|
|
36
|
-
Protocol: () =>
|
|
38
|
+
Protocol: () => import_chunk_XNHBUTNB.Protocol,
|
|
39
|
+
WebSocketMuxer: () => import_chunk_XNHBUTNB.WebSocketMuxer,
|
|
37
40
|
createChainEdgeIdentity: () => createChainEdgeIdentity,
|
|
38
41
|
createDeviceEdgeIdentity: () => createDeviceEdgeIdentity,
|
|
39
42
|
createEphemeralEdgeIdentity: () => createEphemeralEdgeIdentity,
|
|
40
43
|
createStubEdgeIdentity: () => createStubEdgeIdentity,
|
|
41
44
|
createTestHaloEdgeIdentity: () => createTestHaloEdgeIdentity,
|
|
42
|
-
getTypename: () =>
|
|
45
|
+
getTypename: () => import_chunk_XNHBUTNB.getTypename,
|
|
43
46
|
handleAuthChallenge: () => handleAuthChallenge,
|
|
44
|
-
protocol: () =>
|
|
45
|
-
toUint8Array: () =>
|
|
47
|
+
protocol: () => import_chunk_XNHBUTNB.protocol,
|
|
48
|
+
toUint8Array: () => import_chunk_XNHBUTNB.toUint8Array
|
|
46
49
|
});
|
|
47
50
|
module.exports = __toCommonJS(node_exports);
|
|
48
|
-
var
|
|
51
|
+
var import_chunk_XNHBUTNB = require("./chunk-XNHBUTNB.cjs");
|
|
49
52
|
__reExport(node_exports, require("@dxos/protocols/buf/dxos/edge/messenger_pb"), module.exports);
|
|
50
53
|
var import_async = require("@dxos/async");
|
|
51
54
|
var import_context = require("@dxos/context");
|
|
52
55
|
var import_log = require("@dxos/log");
|
|
56
|
+
var import_services = require("@dxos/protocols/proto/dxos/client/services");
|
|
53
57
|
var import_invariant = require("@dxos/invariant");
|
|
54
58
|
var import_proto = require("@dxos/protocols/proto");
|
|
55
59
|
var import_isomorphic_ws = __toESM(require("isomorphic-ws"));
|
|
@@ -57,6 +61,7 @@ var import_async2 = require("@dxos/async");
|
|
|
57
61
|
var import_context2 = require("@dxos/context");
|
|
58
62
|
var import_invariant2 = require("@dxos/invariant");
|
|
59
63
|
var import_log2 = require("@dxos/log");
|
|
64
|
+
var import_protocols = require("@dxos/protocols");
|
|
60
65
|
var import_buf = require("@dxos/protocols/buf");
|
|
61
66
|
var import_messenger_pb = require("@dxos/protocols/buf/dxos/edge/messenger_pb");
|
|
62
67
|
var import_credentials = require("@dxos/credentials");
|
|
@@ -66,7 +71,7 @@ var import_keys = require("@dxos/keys");
|
|
|
66
71
|
var import_async3 = require("@dxos/async");
|
|
67
72
|
var import_context3 = require("@dxos/context");
|
|
68
73
|
var import_log3 = require("@dxos/log");
|
|
69
|
-
var
|
|
74
|
+
var import_protocols2 = require("@dxos/protocols");
|
|
70
75
|
var __dxlog_file = "/home/runner/work/dxos/dxos/packages/core/mesh/edge-client/src/edge-identity.ts";
|
|
71
76
|
var handleAuthChallenge = async (failedResponse, identity) => {
|
|
72
77
|
(0, import_invariant.invariant)(failedResponse.status === 401, void 0, {
|
|
@@ -112,13 +117,9 @@ function _ts_decorate(decorators, target, key, desc) {
|
|
|
112
117
|
var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/core/mesh/edge-client/src/edge-ws-connection.ts";
|
|
113
118
|
var SIGNAL_KEEPALIVE_INTERVAL = 4e3;
|
|
114
119
|
var SIGNAL_KEEPALIVE_TIMEOUT = 12e3;
|
|
115
|
-
var CLOUDFLARE_MESSAGE_LENGTH_LIMIT = 1024 * 1024;
|
|
116
120
|
var EdgeWsConnection = class extends import_context2.Resource {
|
|
117
121
|
constructor(_identity, _connectionInfo, _callbacks) {
|
|
118
|
-
super();
|
|
119
|
-
this._identity = _identity;
|
|
120
|
-
this._connectionInfo = _connectionInfo;
|
|
121
|
-
this._callbacks = _callbacks;
|
|
122
|
+
super(), this._identity = _identity, this._connectionInfo = _connectionInfo, this._callbacks = _callbacks;
|
|
122
123
|
}
|
|
123
124
|
get info() {
|
|
124
125
|
return {
|
|
@@ -130,47 +131,73 @@ var EdgeWsConnection = class extends import_context2.Resource {
|
|
|
130
131
|
send(message) {
|
|
131
132
|
(0, import_invariant2.invariant)(this._ws, void 0, {
|
|
132
133
|
F: __dxlog_file2,
|
|
133
|
-
L:
|
|
134
|
+
L: 52,
|
|
134
135
|
S: this,
|
|
135
136
|
A: [
|
|
136
137
|
"this._ws",
|
|
137
138
|
""
|
|
138
139
|
]
|
|
139
140
|
});
|
|
141
|
+
(0, import_invariant2.invariant)(this._wsMuxer, void 0, {
|
|
142
|
+
F: __dxlog_file2,
|
|
143
|
+
L: 53,
|
|
144
|
+
S: this,
|
|
145
|
+
A: [
|
|
146
|
+
"this._wsMuxer",
|
|
147
|
+
""
|
|
148
|
+
]
|
|
149
|
+
});
|
|
140
150
|
(0, import_log2.log)("sending...", {
|
|
141
151
|
peerKey: this._identity.peerKey,
|
|
142
|
-
payload:
|
|
152
|
+
payload: import_chunk_XNHBUTNB.protocol.getPayloadType(message)
|
|
143
153
|
}, {
|
|
144
154
|
F: __dxlog_file2,
|
|
145
|
-
L:
|
|
155
|
+
L: 54,
|
|
146
156
|
S: this,
|
|
147
157
|
C: (f, a) => f(...a)
|
|
148
158
|
});
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
159
|
+
if (this._ws?.protocol.includes(import_protocols.EdgeWebsocketProtocol.V0)) {
|
|
160
|
+
const binary = import_buf.buf.toBinary(import_messenger_pb.MessageSchema, message);
|
|
161
|
+
if (binary.length > import_chunk_XNHBUTNB.CLOUDFLARE_MESSAGE_MAX_BYTES) {
|
|
162
|
+
import_log2.log.error("Message dropped because it was too large (>1MB).", {
|
|
163
|
+
byteLength: binary.byteLength,
|
|
164
|
+
serviceId: message.serviceId,
|
|
165
|
+
payload: import_chunk_XNHBUTNB.protocol.getPayloadType(message)
|
|
166
|
+
}, {
|
|
167
|
+
F: __dxlog_file2,
|
|
168
|
+
L: 58,
|
|
169
|
+
S: this,
|
|
170
|
+
C: (f, a) => f(...a)
|
|
171
|
+
});
|
|
172
|
+
return;
|
|
173
|
+
}
|
|
174
|
+
this._ws.send(binary);
|
|
175
|
+
} else {
|
|
176
|
+
this._wsMuxer.send(message).catch((e) => import_log2.log.catch(e, void 0, {
|
|
156
177
|
F: __dxlog_file2,
|
|
157
|
-
L:
|
|
178
|
+
L: 67,
|
|
158
179
|
S: this,
|
|
159
180
|
C: (f, a) => f(...a)
|
|
160
|
-
});
|
|
161
|
-
return;
|
|
181
|
+
}));
|
|
162
182
|
}
|
|
163
|
-
this._ws.send(encoded);
|
|
164
183
|
}
|
|
165
184
|
async _open() {
|
|
185
|
+
const baseProtocols = [
|
|
186
|
+
...Object.values(import_protocols.EdgeWebsocketProtocol)
|
|
187
|
+
];
|
|
166
188
|
this._ws = new import_isomorphic_ws.default(this._connectionInfo.url.toString(), this._connectionInfo.protocolHeader ? [
|
|
189
|
+
...baseProtocols,
|
|
167
190
|
this._connectionInfo.protocolHeader
|
|
168
|
-
] : [
|
|
191
|
+
] : [
|
|
192
|
+
...baseProtocols
|
|
193
|
+
]);
|
|
194
|
+
const muxer = new import_chunk_XNHBUTNB.WebSocketMuxer(this._ws);
|
|
195
|
+
this._wsMuxer = muxer;
|
|
169
196
|
this._ws.onopen = () => {
|
|
170
197
|
if (this.isOpen) {
|
|
171
198
|
(0, import_log2.log)("connected", void 0, {
|
|
172
199
|
F: __dxlog_file2,
|
|
173
|
-
L:
|
|
200
|
+
L: 84,
|
|
174
201
|
S: this,
|
|
175
202
|
C: (f, a) => f(...a)
|
|
176
203
|
});
|
|
@@ -181,7 +208,7 @@ var EdgeWsConnection = class extends import_context2.Resource {
|
|
|
181
208
|
currentIdentity: this._identity
|
|
182
209
|
}, {
|
|
183
210
|
F: __dxlog_file2,
|
|
184
|
-
L:
|
|
211
|
+
L: 88,
|
|
185
212
|
S: this,
|
|
186
213
|
C: (f, a) => f(...a)
|
|
187
214
|
});
|
|
@@ -194,11 +221,12 @@ var EdgeWsConnection = class extends import_context2.Resource {
|
|
|
194
221
|
reason: event.reason
|
|
195
222
|
}, {
|
|
196
223
|
F: __dxlog_file2,
|
|
197
|
-
L:
|
|
224
|
+
L: 93,
|
|
198
225
|
S: this,
|
|
199
226
|
C: (f, a) => f(...a)
|
|
200
227
|
});
|
|
201
228
|
this._callbacks.onRestartRequired();
|
|
229
|
+
muxer.destroy();
|
|
202
230
|
}
|
|
203
231
|
};
|
|
204
232
|
this._ws.onerror = (event) => {
|
|
@@ -208,7 +236,7 @@ var EdgeWsConnection = class extends import_context2.Resource {
|
|
|
208
236
|
info: event.message
|
|
209
237
|
}, {
|
|
210
238
|
F: __dxlog_file2,
|
|
211
|
-
L:
|
|
239
|
+
L: 100,
|
|
212
240
|
S: this,
|
|
213
241
|
C: (f, a) => f(...a)
|
|
214
242
|
});
|
|
@@ -218,7 +246,7 @@ var EdgeWsConnection = class extends import_context2.Resource {
|
|
|
218
246
|
error: event.error
|
|
219
247
|
}, {
|
|
220
248
|
F: __dxlog_file2,
|
|
221
|
-
L:
|
|
249
|
+
L: 103,
|
|
222
250
|
S: this,
|
|
223
251
|
C: (f, a) => f(...a)
|
|
224
252
|
});
|
|
@@ -230,7 +258,7 @@ var EdgeWsConnection = class extends import_context2.Resource {
|
|
|
230
258
|
event: event.type
|
|
231
259
|
}, {
|
|
232
260
|
F: __dxlog_file2,
|
|
233
|
-
L:
|
|
261
|
+
L: 111,
|
|
234
262
|
S: this,
|
|
235
263
|
C: (f, a) => f(...a)
|
|
236
264
|
});
|
|
@@ -240,15 +268,18 @@ var EdgeWsConnection = class extends import_context2.Resource {
|
|
|
240
268
|
this._rescheduleHeartbeatTimeout();
|
|
241
269
|
return;
|
|
242
270
|
}
|
|
243
|
-
const
|
|
244
|
-
if (this.isOpen) {
|
|
245
|
-
|
|
271
|
+
const bytes = await (0, import_chunk_XNHBUTNB.toUint8Array)(event.data);
|
|
272
|
+
if (!this.isOpen) {
|
|
273
|
+
return;
|
|
274
|
+
}
|
|
275
|
+
const message = this._ws?.protocol?.includes(import_protocols.EdgeWebsocketProtocol.V0) ? import_buf.buf.fromBinary(import_messenger_pb.MessageSchema, bytes) : muxer.receiveData(bytes);
|
|
276
|
+
if (message) {
|
|
246
277
|
(0, import_log2.log)("received", {
|
|
247
278
|
from: message.source,
|
|
248
|
-
payload:
|
|
279
|
+
payload: import_chunk_XNHBUTNB.protocol.getPayloadType(message)
|
|
249
280
|
}, {
|
|
250
281
|
F: __dxlog_file2,
|
|
251
|
-
L:
|
|
282
|
+
L: 128,
|
|
252
283
|
S: this,
|
|
253
284
|
C: (f, a) => f(...a)
|
|
254
285
|
});
|
|
@@ -262,6 +293,8 @@ var EdgeWsConnection = class extends import_context2.Resource {
|
|
|
262
293
|
try {
|
|
263
294
|
this._ws?.close();
|
|
264
295
|
this._ws = void 0;
|
|
296
|
+
this._wsMuxer?.destroy();
|
|
297
|
+
this._wsMuxer = void 0;
|
|
265
298
|
} catch (err) {
|
|
266
299
|
if (err instanceof Error && err.message.includes("WebSocket is closed before the connection is established.")) {
|
|
267
300
|
return;
|
|
@@ -270,7 +303,7 @@ var EdgeWsConnection = class extends import_context2.Resource {
|
|
|
270
303
|
err
|
|
271
304
|
}, {
|
|
272
305
|
F: __dxlog_file2,
|
|
273
|
-
L:
|
|
306
|
+
L: 146,
|
|
274
307
|
S: this,
|
|
275
308
|
C: (f, a) => f(...a)
|
|
276
309
|
});
|
|
@@ -279,7 +312,7 @@ var EdgeWsConnection = class extends import_context2.Resource {
|
|
|
279
312
|
_scheduleHeartbeats() {
|
|
280
313
|
(0, import_invariant2.invariant)(this._ws, void 0, {
|
|
281
314
|
F: __dxlog_file2,
|
|
282
|
-
L:
|
|
315
|
+
L: 151,
|
|
283
316
|
S: this,
|
|
284
317
|
A: [
|
|
285
318
|
"this._ws",
|
|
@@ -299,13 +332,13 @@ var EdgeWsConnection = class extends import_context2.Resource {
|
|
|
299
332
|
void this._inactivityTimeoutCtx?.dispose();
|
|
300
333
|
this._inactivityTimeoutCtx = new import_context2.Context(void 0, {
|
|
301
334
|
F: __dxlog_file2,
|
|
302
|
-
L:
|
|
335
|
+
L: 170
|
|
303
336
|
});
|
|
304
337
|
(0, import_async2.scheduleTask)(this._inactivityTimeoutCtx, () => {
|
|
305
338
|
if (this.isOpen) {
|
|
306
339
|
import_log2.log.warn("restart due to inactivity timeout", void 0, {
|
|
307
340
|
F: __dxlog_file2,
|
|
308
|
-
L:
|
|
341
|
+
L: 175,
|
|
309
342
|
S: this,
|
|
310
343
|
C: (f, a) => f(...a)
|
|
311
344
|
});
|
|
@@ -343,30 +376,23 @@ var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/core/mesh/edge-client/
|
|
|
343
376
|
var DEFAULT_TIMEOUT = 1e4;
|
|
344
377
|
var EdgeClient = class extends import_context.Resource {
|
|
345
378
|
constructor(_identity, _config) {
|
|
346
|
-
super()
|
|
347
|
-
this._identity = _identity;
|
|
348
|
-
this._config = _config;
|
|
349
|
-
this._persistentLifecycle = new import_async.PersistentLifecycle({
|
|
379
|
+
super(), this._identity = _identity, this._config = _config, this.statusChanged = new import_async.Event(), this._persistentLifecycle = new import_async.PersistentLifecycle({
|
|
350
380
|
start: async () => this._connect(),
|
|
351
381
|
stop: async (state) => this._disconnect(state)
|
|
352
|
-
});
|
|
353
|
-
this._messageListeners = /* @__PURE__ */ new Set();
|
|
354
|
-
this._reconnectListeners = /* @__PURE__ */ new Set();
|
|
355
|
-
this._currentConnection = void 0;
|
|
356
|
-
this._ready = new import_async.Trigger();
|
|
357
|
-
this._isActive = (connection) => connection === this._currentConnection;
|
|
382
|
+
}), this._messageListeners = /* @__PURE__ */ new Set(), this._reconnectListeners = /* @__PURE__ */ new Set(), this._currentConnection = void 0, this._ready = new import_async.Trigger(), this._isActive = (connection) => connection === this._currentConnection;
|
|
358
383
|
this._baseWsUrl = getEdgeUrlWithProtocol(_config.socketEndpoint, "ws");
|
|
359
384
|
this._baseHttpUrl = getEdgeUrlWithProtocol(_config.socketEndpoint, "http");
|
|
360
385
|
}
|
|
361
386
|
get info() {
|
|
362
387
|
return {
|
|
363
388
|
open: this.isOpen,
|
|
389
|
+
status: this.status,
|
|
364
390
|
identity: this._identity.identityKey,
|
|
365
391
|
device: this._identity.peerKey
|
|
366
392
|
};
|
|
367
393
|
}
|
|
368
|
-
get
|
|
369
|
-
return Boolean(this._currentConnection) && this._ready.state === import_async.TriggerState.RESOLVED;
|
|
394
|
+
get status() {
|
|
395
|
+
return Boolean(this._currentConnection) && this._ready.state === import_async.TriggerState.RESOLVED ? import_services.EdgeStatus.CONNECTED : import_services.EdgeStatus.NOT_CONNECTED;
|
|
370
396
|
}
|
|
371
397
|
get identityKey() {
|
|
372
398
|
return this._identity.identityKey;
|
|
@@ -381,13 +407,13 @@ var EdgeClient = class extends import_context.Resource {
|
|
|
381
407
|
oldIdentity: this._identity
|
|
382
408
|
}, {
|
|
383
409
|
F: __dxlog_file3,
|
|
384
|
-
L:
|
|
410
|
+
L: 99,
|
|
385
411
|
S: this,
|
|
386
412
|
C: (f, a) => f(...a)
|
|
387
413
|
});
|
|
388
414
|
this._identity = identity;
|
|
389
415
|
this._closeCurrentConnection(new EdgeIdentityChangedError());
|
|
390
|
-
this._persistentLifecycle.scheduleRestart();
|
|
416
|
+
void this._persistentLifecycle.scheduleRestart();
|
|
391
417
|
}
|
|
392
418
|
}
|
|
393
419
|
onMessage(listener) {
|
|
@@ -404,7 +430,7 @@ var EdgeClient = class extends import_context.Resource {
|
|
|
404
430
|
} catch (error) {
|
|
405
431
|
import_log.log.catch(error, void 0, {
|
|
406
432
|
F: __dxlog_file3,
|
|
407
|
-
L:
|
|
433
|
+
L: 121,
|
|
408
434
|
S: this,
|
|
409
435
|
C: (f, a) => f(...a)
|
|
410
436
|
});
|
|
@@ -422,7 +448,7 @@ var EdgeClient = class extends import_context.Resource {
|
|
|
422
448
|
info: this.info
|
|
423
449
|
}, {
|
|
424
450
|
F: __dxlog_file3,
|
|
425
|
-
L:
|
|
451
|
+
L: 133,
|
|
426
452
|
S: this,
|
|
427
453
|
C: (f, a) => f(...a)
|
|
428
454
|
});
|
|
@@ -431,7 +457,7 @@ var EdgeClient = class extends import_context.Resource {
|
|
|
431
457
|
err
|
|
432
458
|
}, {
|
|
433
459
|
F: __dxlog_file3,
|
|
434
|
-
L:
|
|
460
|
+
L: 135,
|
|
435
461
|
S: this,
|
|
436
462
|
C: (f, a) => f(...a)
|
|
437
463
|
});
|
|
@@ -445,7 +471,7 @@ var EdgeClient = class extends import_context.Resource {
|
|
|
445
471
|
peerKey: this._identity.peerKey
|
|
446
472
|
}, {
|
|
447
473
|
F: __dxlog_file3,
|
|
448
|
-
L:
|
|
474
|
+
L: 143,
|
|
449
475
|
S: this,
|
|
450
476
|
C: (f, a) => f(...a)
|
|
451
477
|
});
|
|
@@ -462,7 +488,7 @@ var EdgeClient = class extends import_context.Resource {
|
|
|
462
488
|
if (this._identity !== identity) {
|
|
463
489
|
(0, import_log.log)("identity changed during auth header request", void 0, {
|
|
464
490
|
F: __dxlog_file3,
|
|
465
|
-
L:
|
|
491
|
+
L: 157,
|
|
466
492
|
S: this,
|
|
467
493
|
C: (f, a) => f(...a)
|
|
468
494
|
});
|
|
@@ -475,7 +501,7 @@ var EdgeClient = class extends import_context.Resource {
|
|
|
475
501
|
protocolHeader
|
|
476
502
|
}, {
|
|
477
503
|
F: __dxlog_file3,
|
|
478
|
-
L:
|
|
504
|
+
L: 163,
|
|
479
505
|
S: this,
|
|
480
506
|
C: (f, a) => f(...a)
|
|
481
507
|
});
|
|
@@ -490,7 +516,7 @@ var EdgeClient = class extends import_context.Resource {
|
|
|
490
516
|
} else {
|
|
491
517
|
import_log.log.verbose("connected callback ignored, because connection is not active", void 0, {
|
|
492
518
|
F: __dxlog_file3,
|
|
493
|
-
L:
|
|
519
|
+
L: 173,
|
|
494
520
|
S: this,
|
|
495
521
|
C: (f, a) => f(...a)
|
|
496
522
|
});
|
|
@@ -499,11 +525,11 @@ var EdgeClient = class extends import_context.Resource {
|
|
|
499
525
|
onRestartRequired: () => {
|
|
500
526
|
if (this._isActive(connection)) {
|
|
501
527
|
this._closeCurrentConnection();
|
|
502
|
-
this._persistentLifecycle.scheduleRestart();
|
|
528
|
+
void this._persistentLifecycle.scheduleRestart();
|
|
503
529
|
} else {
|
|
504
530
|
import_log.log.verbose("restart requested by inactive connection", void 0, {
|
|
505
531
|
F: __dxlog_file3,
|
|
506
|
-
L:
|
|
532
|
+
L: 181,
|
|
507
533
|
S: this,
|
|
508
534
|
C: (f, a) => f(...a)
|
|
509
535
|
});
|
|
@@ -519,7 +545,7 @@ var EdgeClient = class extends import_context.Resource {
|
|
|
519
545
|
type: message.payload?.typeUrl
|
|
520
546
|
}, {
|
|
521
547
|
F: __dxlog_file3,
|
|
522
|
-
L:
|
|
548
|
+
L: 189,
|
|
523
549
|
S: this,
|
|
524
550
|
C: (f, a) => f(...a)
|
|
525
551
|
});
|
|
@@ -538,13 +564,16 @@ var EdgeClient = class extends import_context.Resource {
|
|
|
538
564
|
}
|
|
539
565
|
async _disconnect(state) {
|
|
540
566
|
await state.close();
|
|
567
|
+
this.statusChanged.emit(this.status);
|
|
541
568
|
}
|
|
542
569
|
_closeCurrentConnection(error = new EdgeConnectionClosedError()) {
|
|
543
570
|
this._currentConnection = void 0;
|
|
544
571
|
this._ready.throw(error);
|
|
545
572
|
this._ready.reset();
|
|
573
|
+
this.statusChanged.emit(this.status);
|
|
546
574
|
}
|
|
547
575
|
_notifyReconnected() {
|
|
576
|
+
this.statusChanged.emit(this.status);
|
|
548
577
|
for (const listener of this._reconnectListeners) {
|
|
549
578
|
try {
|
|
550
579
|
listener();
|
|
@@ -553,7 +582,7 @@ var EdgeClient = class extends import_context.Resource {
|
|
|
553
582
|
err
|
|
554
583
|
}, {
|
|
555
584
|
F: __dxlog_file3,
|
|
556
|
-
L:
|
|
585
|
+
L: 225,
|
|
557
586
|
S: this,
|
|
558
587
|
C: (f, a) => f(...a)
|
|
559
588
|
});
|
|
@@ -567,10 +596,10 @@ var EdgeClient = class extends import_context.Resource {
|
|
|
567
596
|
} catch (err) {
|
|
568
597
|
import_log.log.error("ws incoming message processing failed", {
|
|
569
598
|
err,
|
|
570
|
-
payload:
|
|
599
|
+
payload: import_chunk_XNHBUTNB.protocol.getPayloadType(message)
|
|
571
600
|
}, {
|
|
572
601
|
F: __dxlog_file3,
|
|
573
|
-
L:
|
|
602
|
+
L: 235,
|
|
574
603
|
S: this,
|
|
575
604
|
C: (f, a) => f(...a)
|
|
576
605
|
});
|
|
@@ -585,7 +614,7 @@ var EdgeClient = class extends import_context.Resource {
|
|
|
585
614
|
if (this._ready.state !== import_async.TriggerState.RESOLVED) {
|
|
586
615
|
(0, import_log.log)("waiting for websocket to become ready", void 0, {
|
|
587
616
|
F: __dxlog_file3,
|
|
588
|
-
L:
|
|
617
|
+
L: 246,
|
|
589
618
|
S: this,
|
|
590
619
|
C: (f, a) => f(...a)
|
|
591
620
|
});
|
|
@@ -615,7 +644,7 @@ var EdgeClient = class extends import_context.Resource {
|
|
|
615
644
|
statusText: response.statusText
|
|
616
645
|
}, {
|
|
617
646
|
F: __dxlog_file3,
|
|
618
|
-
L:
|
|
647
|
+
L: 271,
|
|
619
648
|
S: this,
|
|
620
649
|
C: (f, a) => f(...a)
|
|
621
650
|
});
|
|
@@ -810,7 +839,6 @@ var EdgeHttpClient = class {
|
|
|
810
839
|
async uploadFunction(pathParts, body, args) {
|
|
811
840
|
const path = [
|
|
812
841
|
"functions",
|
|
813
|
-
pathParts.spaceId,
|
|
814
842
|
...pathParts.functionId ? [
|
|
815
843
|
pathParts.functionId
|
|
816
844
|
] : []
|
|
@@ -924,19 +952,19 @@ var EdgeHttpClient = class {
|
|
|
924
952
|
C: (f, a) => f(...a)
|
|
925
953
|
});
|
|
926
954
|
if (body.errorData?.type === "auth_challenge" && typeof body.errorData?.challenge === "string") {
|
|
927
|
-
processingError = new
|
|
955
|
+
processingError = new import_protocols2.EdgeAuthChallengeError(body.errorData.challenge, body.errorData);
|
|
928
956
|
} else {
|
|
929
|
-
processingError =
|
|
957
|
+
processingError = import_protocols2.EdgeCallFailedError.fromUnsuccessfulResponse(response, body);
|
|
930
958
|
}
|
|
931
959
|
} else if (response.status === 401 && !handledAuth) {
|
|
932
960
|
authHeader = await this._handleUnauthorized(response);
|
|
933
961
|
handledAuth = true;
|
|
934
962
|
continue;
|
|
935
963
|
} else {
|
|
936
|
-
processingError =
|
|
964
|
+
processingError = import_protocols2.EdgeCallFailedError.fromHttpFailure(response);
|
|
937
965
|
}
|
|
938
966
|
} catch (error) {
|
|
939
|
-
processingError =
|
|
967
|
+
processingError = import_protocols2.EdgeCallFailedError.fromProcessingFailureCause(error);
|
|
940
968
|
}
|
|
941
969
|
if (processingError.isRetryable && await shouldRetry(requestContext, retryAfterHeaderValue)) {
|
|
942
970
|
(0, import_log3.log)("retrying edge request", {
|
|
@@ -961,7 +989,7 @@ var EdgeHttpClient = class {
|
|
|
961
989
|
S: this,
|
|
962
990
|
C: (f, a) => f(...a)
|
|
963
991
|
});
|
|
964
|
-
throw
|
|
992
|
+
throw import_protocols2.EdgeCallFailedError.fromHttpFailure(response);
|
|
965
993
|
}
|
|
966
994
|
const challenge = await handleAuthChallenge(response, this._edgeIdentity);
|
|
967
995
|
this._authHeader = encodeAuthHeader(challenge);
|
|
@@ -1010,11 +1038,14 @@ var encodeAuthHeader = (challenge) => {
|
|
|
1010
1038
|
};
|
|
1011
1039
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1012
1040
|
0 && (module.exports = {
|
|
1041
|
+
CLOUDFLARE_MESSAGE_MAX_BYTES,
|
|
1042
|
+
CLOUDFLARE_RPC_MAX_BYTES,
|
|
1013
1043
|
EdgeClient,
|
|
1014
1044
|
EdgeConnectionClosedError,
|
|
1015
1045
|
EdgeHttpClient,
|
|
1016
1046
|
EdgeIdentityChangedError,
|
|
1017
1047
|
Protocol,
|
|
1048
|
+
WebSocketMuxer,
|
|
1018
1049
|
createChainEdgeIdentity,
|
|
1019
1050
|
createDeviceEdgeIdentity,
|
|
1020
1051
|
createEphemeralEdgeIdentity,
|