@dxos/edge-client 0.8.2-main.f081794 → 0.8.2-main.f11618f
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-5DDWS5EC.mjs +546 -0
- package/dist/lib/browser/chunk-5DDWS5EC.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +64 -282
- package/dist/lib/browser/index.mjs.map +4 -4
- 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-CNAHGYSS.cjs +579 -0
- package/dist/lib/node/chunk-CNAHGYSS.cjs.map +7 -0
- package/dist/lib/node/index.cjs +54 -281
- package/dist/lib/node/index.cjs.map +4 -4
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/testing/index.cjs +31 -21
- package/dist/lib/node/testing/index.cjs.map +3 -3
- package/dist/lib/node-esm/chunk-O4TFZRSP.mjs +548 -0
- package/dist/lib/node-esm/chunk-O4TFZRSP.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +64 -282
- package/dist/lib/node-esm/index.mjs.map +4 -4
- 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/edge-ws-connection.d.ts +5 -0
- package/dist/types/src/edge-ws-connection.d.ts.map +1 -1
- package/dist/types/src/edge-ws-muxer.d.ts +23 -0
- package/dist/types/src/edge-ws-muxer.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/testing/test-utils.d.ts +6 -2
- package/dist/types/src/testing/test-utils.d.ts.map +1 -1
- package/package.json +14 -14
- package/src/edge-client.ts +2 -2
- package/src/edge-ws-connection.ts +38 -15
- package/src/edge-ws-muxer.ts +187 -0
- package/src/index.ts +1 -0
- 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
|
@@ -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,34 +16,28 @@ 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, {
|
|
22
|
+
CLOUDFLARE_MESSAGE_LENGTH_LIMIT: () => import_chunk_CNAHGYSS.CLOUDFLARE_MESSAGE_LENGTH_LIMIT,
|
|
32
23
|
EdgeClient: () => EdgeClient,
|
|
33
24
|
EdgeConnectionClosedError: () => EdgeConnectionClosedError,
|
|
34
25
|
EdgeHttpClient: () => EdgeHttpClient,
|
|
35
26
|
EdgeIdentityChangedError: () => EdgeIdentityChangedError,
|
|
36
|
-
Protocol: () =>
|
|
27
|
+
Protocol: () => import_chunk_CNAHGYSS.Protocol,
|
|
28
|
+
WebSocketMuxer: () => import_chunk_CNAHGYSS.WebSocketMuxer,
|
|
37
29
|
createChainEdgeIdentity: () => createChainEdgeIdentity,
|
|
38
30
|
createDeviceEdgeIdentity: () => createDeviceEdgeIdentity,
|
|
39
31
|
createEphemeralEdgeIdentity: () => createEphemeralEdgeIdentity,
|
|
40
32
|
createStubEdgeIdentity: () => createStubEdgeIdentity,
|
|
41
33
|
createTestHaloEdgeIdentity: () => createTestHaloEdgeIdentity,
|
|
42
|
-
getTypename: () =>
|
|
34
|
+
getTypename: () => import_chunk_CNAHGYSS.getTypename,
|
|
43
35
|
handleAuthChallenge: () => handleAuthChallenge,
|
|
44
|
-
protocol: () =>
|
|
45
|
-
toUint8Array: () =>
|
|
36
|
+
protocol: () => import_chunk_CNAHGYSS.protocol,
|
|
37
|
+
toUint8Array: () => import_chunk_CNAHGYSS.toUint8Array
|
|
46
38
|
});
|
|
47
39
|
module.exports = __toCommonJS(node_exports);
|
|
48
|
-
var
|
|
40
|
+
var import_chunk_CNAHGYSS = require("./chunk-CNAHGYSS.cjs");
|
|
49
41
|
__reExport(node_exports, require("@dxos/protocols/buf/dxos/edge/messenger_pb"), module.exports);
|
|
50
42
|
var import_async = require("@dxos/async");
|
|
51
43
|
var import_context = require("@dxos/context");
|
|
@@ -53,20 +45,13 @@ var import_log = require("@dxos/log");
|
|
|
53
45
|
var import_services = require("@dxos/protocols/proto/dxos/client/services");
|
|
54
46
|
var import_invariant = require("@dxos/invariant");
|
|
55
47
|
var import_proto = require("@dxos/protocols/proto");
|
|
56
|
-
var import_isomorphic_ws = __toESM(require("isomorphic-ws"));
|
|
57
|
-
var import_async2 = require("@dxos/async");
|
|
58
|
-
var import_context2 = require("@dxos/context");
|
|
59
|
-
var import_invariant2 = require("@dxos/invariant");
|
|
60
|
-
var import_log2 = require("@dxos/log");
|
|
61
|
-
var import_buf = require("@dxos/protocols/buf");
|
|
62
|
-
var import_messenger_pb = require("@dxos/protocols/buf/dxos/edge/messenger_pb");
|
|
63
48
|
var import_credentials = require("@dxos/credentials");
|
|
64
|
-
var
|
|
49
|
+
var import_invariant2 = require("@dxos/invariant");
|
|
65
50
|
var import_keyring = require("@dxos/keyring");
|
|
66
51
|
var import_keys = require("@dxos/keys");
|
|
67
|
-
var
|
|
68
|
-
var
|
|
69
|
-
var
|
|
52
|
+
var import_async2 = require("@dxos/async");
|
|
53
|
+
var import_context2 = require("@dxos/context");
|
|
54
|
+
var import_log2 = require("@dxos/log");
|
|
70
55
|
var import_protocols = require("@dxos/protocols");
|
|
71
56
|
var __dxlog_file = "/home/runner/work/dxos/dxos/packages/core/mesh/edge-client/src/edge-identity.ts";
|
|
72
57
|
var handleAuthChallenge = async (failedResponse, identity) => {
|
|
@@ -104,220 +89,6 @@ var handleAuthChallenge = async (failedResponse, identity) => {
|
|
|
104
89
|
});
|
|
105
90
|
return import_proto.schema.getCodecForType("dxos.halo.credentials.Presentation").encode(presentation);
|
|
106
91
|
};
|
|
107
|
-
function _ts_decorate(decorators, target, key, desc) {
|
|
108
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
109
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
110
|
-
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;
|
|
111
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
112
|
-
}
|
|
113
|
-
var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/core/mesh/edge-client/src/edge-ws-connection.ts";
|
|
114
|
-
var SIGNAL_KEEPALIVE_INTERVAL = 4e3;
|
|
115
|
-
var SIGNAL_KEEPALIVE_TIMEOUT = 12e3;
|
|
116
|
-
var CLOUDFLARE_MESSAGE_LENGTH_LIMIT = 1024 * 1024;
|
|
117
|
-
var EdgeWsConnection = class extends import_context2.Resource {
|
|
118
|
-
constructor(_identity, _connectionInfo, _callbacks) {
|
|
119
|
-
super();
|
|
120
|
-
this._identity = _identity;
|
|
121
|
-
this._connectionInfo = _connectionInfo;
|
|
122
|
-
this._callbacks = _callbacks;
|
|
123
|
-
}
|
|
124
|
-
get info() {
|
|
125
|
-
return {
|
|
126
|
-
open: this.isOpen,
|
|
127
|
-
identity: this._identity.identityKey,
|
|
128
|
-
device: this._identity.peerKey
|
|
129
|
-
};
|
|
130
|
-
}
|
|
131
|
-
send(message) {
|
|
132
|
-
(0, import_invariant2.invariant)(this._ws, void 0, {
|
|
133
|
-
F: __dxlog_file2,
|
|
134
|
-
L: 54,
|
|
135
|
-
S: this,
|
|
136
|
-
A: [
|
|
137
|
-
"this._ws",
|
|
138
|
-
""
|
|
139
|
-
]
|
|
140
|
-
});
|
|
141
|
-
(0, import_log2.log)("sending...", {
|
|
142
|
-
peerKey: this._identity.peerKey,
|
|
143
|
-
payload: import_chunk_ANV2HBEH.protocol.getPayloadType(message)
|
|
144
|
-
}, {
|
|
145
|
-
F: __dxlog_file2,
|
|
146
|
-
L: 55,
|
|
147
|
-
S: this,
|
|
148
|
-
C: (f, a) => f(...a)
|
|
149
|
-
});
|
|
150
|
-
const encoded = import_buf.buf.toBinary(import_messenger_pb.MessageSchema, message);
|
|
151
|
-
if (encoded.byteLength >= CLOUDFLARE_MESSAGE_LENGTH_LIMIT) {
|
|
152
|
-
import_log2.log.error("edge message dropped due to websocket message limit", {
|
|
153
|
-
byteLength: encoded.byteLength,
|
|
154
|
-
serviceId: message.serviceId,
|
|
155
|
-
payload: import_chunk_ANV2HBEH.protocol.getPayloadType(message)
|
|
156
|
-
}, {
|
|
157
|
-
F: __dxlog_file2,
|
|
158
|
-
L: 58,
|
|
159
|
-
S: this,
|
|
160
|
-
C: (f, a) => f(...a)
|
|
161
|
-
});
|
|
162
|
-
return;
|
|
163
|
-
}
|
|
164
|
-
this._ws.send(encoded);
|
|
165
|
-
}
|
|
166
|
-
async _open() {
|
|
167
|
-
this._ws = new import_isomorphic_ws.default(this._connectionInfo.url.toString(), this._connectionInfo.protocolHeader ? [
|
|
168
|
-
this._connectionInfo.protocolHeader
|
|
169
|
-
] : []);
|
|
170
|
-
this._ws.onopen = () => {
|
|
171
|
-
if (this.isOpen) {
|
|
172
|
-
(0, import_log2.log)("connected", void 0, {
|
|
173
|
-
F: __dxlog_file2,
|
|
174
|
-
L: 76,
|
|
175
|
-
S: this,
|
|
176
|
-
C: (f, a) => f(...a)
|
|
177
|
-
});
|
|
178
|
-
this._callbacks.onConnected();
|
|
179
|
-
this._scheduleHeartbeats();
|
|
180
|
-
} else {
|
|
181
|
-
import_log2.log.verbose("connected after becoming inactive", {
|
|
182
|
-
currentIdentity: this._identity
|
|
183
|
-
}, {
|
|
184
|
-
F: __dxlog_file2,
|
|
185
|
-
L: 80,
|
|
186
|
-
S: this,
|
|
187
|
-
C: (f, a) => f(...a)
|
|
188
|
-
});
|
|
189
|
-
}
|
|
190
|
-
};
|
|
191
|
-
this._ws.onclose = (event) => {
|
|
192
|
-
if (this.isOpen) {
|
|
193
|
-
import_log2.log.warn("disconnected while being open", {
|
|
194
|
-
code: event.code,
|
|
195
|
-
reason: event.reason
|
|
196
|
-
}, {
|
|
197
|
-
F: __dxlog_file2,
|
|
198
|
-
L: 85,
|
|
199
|
-
S: this,
|
|
200
|
-
C: (f, a) => f(...a)
|
|
201
|
-
});
|
|
202
|
-
this._callbacks.onRestartRequired();
|
|
203
|
-
}
|
|
204
|
-
};
|
|
205
|
-
this._ws.onerror = (event) => {
|
|
206
|
-
if (this.isOpen) {
|
|
207
|
-
import_log2.log.warn("edge connection socket error", {
|
|
208
|
-
error: event.error,
|
|
209
|
-
info: event.message
|
|
210
|
-
}, {
|
|
211
|
-
F: __dxlog_file2,
|
|
212
|
-
L: 91,
|
|
213
|
-
S: this,
|
|
214
|
-
C: (f, a) => f(...a)
|
|
215
|
-
});
|
|
216
|
-
this._callbacks.onRestartRequired();
|
|
217
|
-
} else {
|
|
218
|
-
import_log2.log.verbose("error ignored on closed connection", {
|
|
219
|
-
error: event.error
|
|
220
|
-
}, {
|
|
221
|
-
F: __dxlog_file2,
|
|
222
|
-
L: 94,
|
|
223
|
-
S: this,
|
|
224
|
-
C: (f, a) => f(...a)
|
|
225
|
-
});
|
|
226
|
-
}
|
|
227
|
-
};
|
|
228
|
-
this._ws.onmessage = async (event) => {
|
|
229
|
-
if (!this.isOpen) {
|
|
230
|
-
import_log2.log.verbose("message ignored on closed connection", {
|
|
231
|
-
event: event.type
|
|
232
|
-
}, {
|
|
233
|
-
F: __dxlog_file2,
|
|
234
|
-
L: 102,
|
|
235
|
-
S: this,
|
|
236
|
-
C: (f, a) => f(...a)
|
|
237
|
-
});
|
|
238
|
-
return;
|
|
239
|
-
}
|
|
240
|
-
if (event.data === "__pong__") {
|
|
241
|
-
this._rescheduleHeartbeatTimeout();
|
|
242
|
-
return;
|
|
243
|
-
}
|
|
244
|
-
const data = await (0, import_chunk_ANV2HBEH.toUint8Array)(event.data);
|
|
245
|
-
if (this.isOpen) {
|
|
246
|
-
const message = import_buf.buf.fromBinary(import_messenger_pb.MessageSchema, data);
|
|
247
|
-
(0, import_log2.log)("received", {
|
|
248
|
-
from: message.source,
|
|
249
|
-
payload: import_chunk_ANV2HBEH.protocol.getPayloadType(message)
|
|
250
|
-
}, {
|
|
251
|
-
F: __dxlog_file2,
|
|
252
|
-
L: 112,
|
|
253
|
-
S: this,
|
|
254
|
-
C: (f, a) => f(...a)
|
|
255
|
-
});
|
|
256
|
-
this._callbacks.onMessage(message);
|
|
257
|
-
}
|
|
258
|
-
};
|
|
259
|
-
}
|
|
260
|
-
async _close() {
|
|
261
|
-
void this._inactivityTimeoutCtx?.dispose().catch(() => {
|
|
262
|
-
});
|
|
263
|
-
try {
|
|
264
|
-
this._ws?.close();
|
|
265
|
-
this._ws = void 0;
|
|
266
|
-
} catch (err) {
|
|
267
|
-
if (err instanceof Error && err.message.includes("WebSocket is closed before the connection is established.")) {
|
|
268
|
-
return;
|
|
269
|
-
}
|
|
270
|
-
import_log2.log.warn("Error closing websocket", {
|
|
271
|
-
err
|
|
272
|
-
}, {
|
|
273
|
-
F: __dxlog_file2,
|
|
274
|
-
L: 128,
|
|
275
|
-
S: this,
|
|
276
|
-
C: (f, a) => f(...a)
|
|
277
|
-
});
|
|
278
|
-
}
|
|
279
|
-
}
|
|
280
|
-
_scheduleHeartbeats() {
|
|
281
|
-
(0, import_invariant2.invariant)(this._ws, void 0, {
|
|
282
|
-
F: __dxlog_file2,
|
|
283
|
-
L: 133,
|
|
284
|
-
S: this,
|
|
285
|
-
A: [
|
|
286
|
-
"this._ws",
|
|
287
|
-
""
|
|
288
|
-
]
|
|
289
|
-
});
|
|
290
|
-
(0, import_async2.scheduleTaskInterval)(this._ctx, async () => {
|
|
291
|
-
this._ws?.send("__ping__");
|
|
292
|
-
}, SIGNAL_KEEPALIVE_INTERVAL);
|
|
293
|
-
this._ws.send("__ping__");
|
|
294
|
-
this._rescheduleHeartbeatTimeout();
|
|
295
|
-
}
|
|
296
|
-
_rescheduleHeartbeatTimeout() {
|
|
297
|
-
if (!this.isOpen) {
|
|
298
|
-
return;
|
|
299
|
-
}
|
|
300
|
-
void this._inactivityTimeoutCtx?.dispose();
|
|
301
|
-
this._inactivityTimeoutCtx = new import_context2.Context(void 0, {
|
|
302
|
-
F: __dxlog_file2,
|
|
303
|
-
L: 152
|
|
304
|
-
});
|
|
305
|
-
(0, import_async2.scheduleTask)(this._inactivityTimeoutCtx, () => {
|
|
306
|
-
if (this.isOpen) {
|
|
307
|
-
import_log2.log.warn("restart due to inactivity timeout", void 0, {
|
|
308
|
-
F: __dxlog_file2,
|
|
309
|
-
L: 157,
|
|
310
|
-
S: this,
|
|
311
|
-
C: (f, a) => f(...a)
|
|
312
|
-
});
|
|
313
|
-
this._callbacks.onRestartRequired();
|
|
314
|
-
}
|
|
315
|
-
}, SIGNAL_KEEPALIVE_TIMEOUT);
|
|
316
|
-
}
|
|
317
|
-
};
|
|
318
|
-
_ts_decorate([
|
|
319
|
-
import_log2.logInfo
|
|
320
|
-
], EdgeWsConnection.prototype, "info", null);
|
|
321
92
|
var EdgeConnectionClosedError = class extends Error {
|
|
322
93
|
constructor() {
|
|
323
94
|
super("Edge connection closed.");
|
|
@@ -334,13 +105,13 @@ var getEdgeUrlWithProtocol = (baseUrl, protocol2) => {
|
|
|
334
105
|
url.protocol = protocol2 + (isSecure ? "s" : "");
|
|
335
106
|
return url.toString();
|
|
336
107
|
};
|
|
337
|
-
function
|
|
108
|
+
function _ts_decorate(decorators, target, key, desc) {
|
|
338
109
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
339
110
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
340
111
|
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;
|
|
341
112
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
342
113
|
}
|
|
343
|
-
var
|
|
114
|
+
var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/core/mesh/edge-client/src/edge-client.ts";
|
|
344
115
|
var DEFAULT_TIMEOUT = 1e4;
|
|
345
116
|
var EdgeClient = class extends import_context.Resource {
|
|
346
117
|
constructor(_identity, _config) {
|
|
@@ -383,14 +154,14 @@ var EdgeClient = class extends import_context.Resource {
|
|
|
383
154
|
identity,
|
|
384
155
|
oldIdentity: this._identity
|
|
385
156
|
}, {
|
|
386
|
-
F:
|
|
157
|
+
F: __dxlog_file2,
|
|
387
158
|
L: 99,
|
|
388
159
|
S: this,
|
|
389
160
|
C: (f, a) => f(...a)
|
|
390
161
|
});
|
|
391
162
|
this._identity = identity;
|
|
392
163
|
this._closeCurrentConnection(new EdgeIdentityChangedError());
|
|
393
|
-
this._persistentLifecycle.scheduleRestart();
|
|
164
|
+
void this._persistentLifecycle.scheduleRestart();
|
|
394
165
|
}
|
|
395
166
|
}
|
|
396
167
|
onMessage(listener) {
|
|
@@ -406,7 +177,7 @@ var EdgeClient = class extends import_context.Resource {
|
|
|
406
177
|
listener();
|
|
407
178
|
} catch (error) {
|
|
408
179
|
import_log.log.catch(error, void 0, {
|
|
409
|
-
F:
|
|
180
|
+
F: __dxlog_file2,
|
|
410
181
|
L: 121,
|
|
411
182
|
S: this,
|
|
412
183
|
C: (f, a) => f(...a)
|
|
@@ -424,7 +195,7 @@ var EdgeClient = class extends import_context.Resource {
|
|
|
424
195
|
(0, import_log.log)("opening...", {
|
|
425
196
|
info: this.info
|
|
426
197
|
}, {
|
|
427
|
-
F:
|
|
198
|
+
F: __dxlog_file2,
|
|
428
199
|
L: 133,
|
|
429
200
|
S: this,
|
|
430
201
|
C: (f, a) => f(...a)
|
|
@@ -433,7 +204,7 @@ var EdgeClient = class extends import_context.Resource {
|
|
|
433
204
|
import_log.log.warn("Error while opening connection", {
|
|
434
205
|
err
|
|
435
206
|
}, {
|
|
436
|
-
F:
|
|
207
|
+
F: __dxlog_file2,
|
|
437
208
|
L: 135,
|
|
438
209
|
S: this,
|
|
439
210
|
C: (f, a) => f(...a)
|
|
@@ -447,7 +218,7 @@ var EdgeClient = class extends import_context.Resource {
|
|
|
447
218
|
(0, import_log.log)("closing...", {
|
|
448
219
|
peerKey: this._identity.peerKey
|
|
449
220
|
}, {
|
|
450
|
-
F:
|
|
221
|
+
F: __dxlog_file2,
|
|
451
222
|
L: 143,
|
|
452
223
|
S: this,
|
|
453
224
|
C: (f, a) => f(...a)
|
|
@@ -464,7 +235,7 @@ var EdgeClient = class extends import_context.Resource {
|
|
|
464
235
|
const protocolHeader = this._config.disableAuth ? void 0 : await this._createAuthHeader(path);
|
|
465
236
|
if (this._identity !== identity) {
|
|
466
237
|
(0, import_log.log)("identity changed during auth header request", void 0, {
|
|
467
|
-
F:
|
|
238
|
+
F: __dxlog_file2,
|
|
468
239
|
L: 157,
|
|
469
240
|
S: this,
|
|
470
241
|
C: (f, a) => f(...a)
|
|
@@ -477,12 +248,12 @@ var EdgeClient = class extends import_context.Resource {
|
|
|
477
248
|
url: url.toString(),
|
|
478
249
|
protocolHeader
|
|
479
250
|
}, {
|
|
480
|
-
F:
|
|
251
|
+
F: __dxlog_file2,
|
|
481
252
|
L: 163,
|
|
482
253
|
S: this,
|
|
483
254
|
C: (f, a) => f(...a)
|
|
484
255
|
});
|
|
485
|
-
const connection = new EdgeWsConnection(identity, {
|
|
256
|
+
const connection = new import_chunk_CNAHGYSS.EdgeWsConnection(identity, {
|
|
486
257
|
url,
|
|
487
258
|
protocolHeader
|
|
488
259
|
}, {
|
|
@@ -492,7 +263,7 @@ var EdgeClient = class extends import_context.Resource {
|
|
|
492
263
|
this._notifyReconnected();
|
|
493
264
|
} else {
|
|
494
265
|
import_log.log.verbose("connected callback ignored, because connection is not active", void 0, {
|
|
495
|
-
F:
|
|
266
|
+
F: __dxlog_file2,
|
|
496
267
|
L: 173,
|
|
497
268
|
S: this,
|
|
498
269
|
C: (f, a) => f(...a)
|
|
@@ -502,10 +273,10 @@ var EdgeClient = class extends import_context.Resource {
|
|
|
502
273
|
onRestartRequired: () => {
|
|
503
274
|
if (this._isActive(connection)) {
|
|
504
275
|
this._closeCurrentConnection();
|
|
505
|
-
this._persistentLifecycle.scheduleRestart();
|
|
276
|
+
void this._persistentLifecycle.scheduleRestart();
|
|
506
277
|
} else {
|
|
507
278
|
import_log.log.verbose("restart requested by inactive connection", void 0, {
|
|
508
|
-
F:
|
|
279
|
+
F: __dxlog_file2,
|
|
509
280
|
L: 181,
|
|
510
281
|
S: this,
|
|
511
282
|
C: (f, a) => f(...a)
|
|
@@ -521,7 +292,7 @@ var EdgeClient = class extends import_context.Resource {
|
|
|
521
292
|
from: message.source,
|
|
522
293
|
type: message.payload?.typeUrl
|
|
523
294
|
}, {
|
|
524
|
-
F:
|
|
295
|
+
F: __dxlog_file2,
|
|
525
296
|
L: 189,
|
|
526
297
|
S: this,
|
|
527
298
|
C: (f, a) => f(...a)
|
|
@@ -558,7 +329,7 @@ var EdgeClient = class extends import_context.Resource {
|
|
|
558
329
|
import_log.log.error("ws reconnect listener failed", {
|
|
559
330
|
err
|
|
560
331
|
}, {
|
|
561
|
-
F:
|
|
332
|
+
F: __dxlog_file2,
|
|
562
333
|
L: 225,
|
|
563
334
|
S: this,
|
|
564
335
|
C: (f, a) => f(...a)
|
|
@@ -573,9 +344,9 @@ var EdgeClient = class extends import_context.Resource {
|
|
|
573
344
|
} catch (err) {
|
|
574
345
|
import_log.log.error("ws incoming message processing failed", {
|
|
575
346
|
err,
|
|
576
|
-
payload:
|
|
347
|
+
payload: import_chunk_CNAHGYSS.protocol.getPayloadType(message)
|
|
577
348
|
}, {
|
|
578
|
-
F:
|
|
349
|
+
F: __dxlog_file2,
|
|
579
350
|
L: 235,
|
|
580
351
|
S: this,
|
|
581
352
|
C: (f, a) => f(...a)
|
|
@@ -590,7 +361,7 @@ var EdgeClient = class extends import_context.Resource {
|
|
|
590
361
|
async send(message) {
|
|
591
362
|
if (this._ready.state !== import_async.TriggerState.RESOLVED) {
|
|
592
363
|
(0, import_log.log)("waiting for websocket to become ready", void 0, {
|
|
593
|
-
F:
|
|
364
|
+
F: __dxlog_file2,
|
|
594
365
|
L: 246,
|
|
595
366
|
S: this,
|
|
596
367
|
C: (f, a) => f(...a)
|
|
@@ -620,7 +391,7 @@ var EdgeClient = class extends import_context.Resource {
|
|
|
620
391
|
status: response.status,
|
|
621
392
|
statusText: response.statusText
|
|
622
393
|
}, {
|
|
623
|
-
F:
|
|
394
|
+
F: __dxlog_file2,
|
|
624
395
|
L: 271,
|
|
625
396
|
S: this,
|
|
626
397
|
C: (f, a) => f(...a)
|
|
@@ -629,14 +400,14 @@ var EdgeClient = class extends import_context.Resource {
|
|
|
629
400
|
}
|
|
630
401
|
}
|
|
631
402
|
};
|
|
632
|
-
|
|
403
|
+
_ts_decorate([
|
|
633
404
|
import_log.logInfo
|
|
634
405
|
], EdgeClient.prototype, "info", null);
|
|
635
406
|
var encodePresentationWsAuthHeader = (encodedPresentation) => {
|
|
636
407
|
const encodedToken = Buffer.from(encodedPresentation).toString("base64").replace(/=*$/, "").replaceAll("/", "|");
|
|
637
408
|
return `base64url.bearer.authorization.dxos.org.${encodedToken}`;
|
|
638
409
|
};
|
|
639
|
-
var
|
|
410
|
+
var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/core/mesh/edge-client/src/auth.ts";
|
|
640
411
|
var createDeviceEdgeIdentity = async (signer, key) => {
|
|
641
412
|
return {
|
|
642
413
|
identityKey: key.toHex(),
|
|
@@ -680,8 +451,8 @@ var createChainEdgeIdentity = async (signer, identityKey, peerKey, chain, creden
|
|
|
680
451
|
identityKey: identityKey.toHex(),
|
|
681
452
|
peerKey: peerKey.toHex(),
|
|
682
453
|
presentCredentials: async ({ challenge }) => {
|
|
683
|
-
(0,
|
|
684
|
-
F:
|
|
454
|
+
(0, import_invariant2.invariant)(chain, void 0, {
|
|
455
|
+
F: __dxlog_file3,
|
|
685
456
|
L: 75,
|
|
686
457
|
S: void 0,
|
|
687
458
|
A: [
|
|
@@ -741,17 +512,17 @@ var createStubEdgeIdentity = () => {
|
|
|
741
512
|
}
|
|
742
513
|
};
|
|
743
514
|
};
|
|
744
|
-
var
|
|
515
|
+
var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/core/mesh/edge-client/src/edge-http-client.ts";
|
|
745
516
|
var DEFAULT_RETRY_TIMEOUT = 1500;
|
|
746
517
|
var DEFAULT_RETRY_JITTER = 500;
|
|
747
518
|
var DEFAULT_MAX_RETRIES_COUNT = 3;
|
|
748
519
|
var EdgeHttpClient = class {
|
|
749
520
|
constructor(baseUrl) {
|
|
750
521
|
this._baseUrl = getEdgeUrlWithProtocol(baseUrl, "http");
|
|
751
|
-
(0,
|
|
522
|
+
(0, import_log2.log)("created", {
|
|
752
523
|
url: this._baseUrl
|
|
753
524
|
}, {
|
|
754
|
-
F:
|
|
525
|
+
F: __dxlog_file4,
|
|
755
526
|
L: 53,
|
|
756
527
|
S: this,
|
|
757
528
|
C: (f, a) => f(...a)
|
|
@@ -883,8 +654,8 @@ var EdgeHttpClient = class {
|
|
|
883
654
|
});
|
|
884
655
|
}
|
|
885
656
|
async _call(path, args) {
|
|
886
|
-
const requestContext = args.context ?? new
|
|
887
|
-
F:
|
|
657
|
+
const requestContext = args.context ?? new import_context2.Context(void 0, {
|
|
658
|
+
F: __dxlog_file4,
|
|
888
659
|
L: 192
|
|
889
660
|
});
|
|
890
661
|
const shouldRetry = createRetryHandler(args);
|
|
@@ -896,12 +667,12 @@ var EdgeHttpClient = class {
|
|
|
896
667
|
}
|
|
897
668
|
url += `?${queryParams.toString()}`;
|
|
898
669
|
}
|
|
899
|
-
(0,
|
|
670
|
+
(0, import_log2.log)("call", {
|
|
900
671
|
method: args.method,
|
|
901
672
|
path,
|
|
902
673
|
request: args.body
|
|
903
674
|
}, {
|
|
904
|
-
F:
|
|
675
|
+
F: __dxlog_file4,
|
|
905
676
|
L: 204,
|
|
906
677
|
S: this,
|
|
907
678
|
C: (f, a) => f(...a)
|
|
@@ -920,11 +691,11 @@ var EdgeHttpClient = class {
|
|
|
920
691
|
if (body.success) {
|
|
921
692
|
return body.data;
|
|
922
693
|
}
|
|
923
|
-
(0,
|
|
694
|
+
(0, import_log2.log)("unsuccessful edge response", {
|
|
924
695
|
path,
|
|
925
696
|
body
|
|
926
697
|
}, {
|
|
927
|
-
F:
|
|
698
|
+
F: __dxlog_file4,
|
|
928
699
|
L: 223,
|
|
929
700
|
S: this,
|
|
930
701
|
C: (f, a) => f(...a)
|
|
@@ -945,11 +716,11 @@ var EdgeHttpClient = class {
|
|
|
945
716
|
processingError = import_protocols.EdgeCallFailedError.fromProcessingFailureCause(error);
|
|
946
717
|
}
|
|
947
718
|
if (processingError.isRetryable && await shouldRetry(requestContext, retryAfterHeaderValue)) {
|
|
948
|
-
(0,
|
|
719
|
+
(0, import_log2.log)("retrying edge request", {
|
|
949
720
|
path,
|
|
950
721
|
processingError
|
|
951
722
|
}, {
|
|
952
|
-
F:
|
|
723
|
+
F: __dxlog_file4,
|
|
953
724
|
L: 242,
|
|
954
725
|
S: this,
|
|
955
726
|
C: (f, a) => f(...a)
|
|
@@ -961,8 +732,8 @@ var EdgeHttpClient = class {
|
|
|
961
732
|
}
|
|
962
733
|
async _handleUnauthorized(response) {
|
|
963
734
|
if (!this._edgeIdentity) {
|
|
964
|
-
|
|
965
|
-
F:
|
|
735
|
+
import_log2.log.warn("edge unauthorized response received before identity was set", void 0, {
|
|
736
|
+
F: __dxlog_file4,
|
|
966
737
|
L: 251,
|
|
967
738
|
S: this,
|
|
968
739
|
C: (f, a) => f(...a)
|
|
@@ -971,8 +742,8 @@ var EdgeHttpClient = class {
|
|
|
971
742
|
}
|
|
972
743
|
const challenge = await handleAuthChallenge(response, this._edgeIdentity);
|
|
973
744
|
this._authHeader = encodeAuthHeader(challenge);
|
|
974
|
-
(0,
|
|
975
|
-
F:
|
|
745
|
+
(0, import_log2.log)("auth header updated", void 0, {
|
|
746
|
+
F: __dxlog_file4,
|
|
976
747
|
L: 256,
|
|
977
748
|
S: this,
|
|
978
749
|
C: (f, a) => f(...a)
|
|
@@ -993,10 +764,10 @@ var createRetryHandler = (args) => {
|
|
|
993
764
|
return false;
|
|
994
765
|
}
|
|
995
766
|
if (retryAfter) {
|
|
996
|
-
await (0,
|
|
767
|
+
await (0, import_async2.sleep)(retryAfter);
|
|
997
768
|
} else {
|
|
998
769
|
const timeout = baseTimeout + Math.random() * jitter;
|
|
999
|
-
await (0,
|
|
770
|
+
await (0, import_async2.sleep)(timeout);
|
|
1000
771
|
}
|
|
1001
772
|
return true;
|
|
1002
773
|
};
|
|
@@ -1016,11 +787,13 @@ var encodeAuthHeader = (challenge) => {
|
|
|
1016
787
|
};
|
|
1017
788
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1018
789
|
0 && (module.exports = {
|
|
790
|
+
CLOUDFLARE_MESSAGE_LENGTH_LIMIT,
|
|
1019
791
|
EdgeClient,
|
|
1020
792
|
EdgeConnectionClosedError,
|
|
1021
793
|
EdgeHttpClient,
|
|
1022
794
|
EdgeIdentityChangedError,
|
|
1023
795
|
Protocol,
|
|
796
|
+
WebSocketMuxer,
|
|
1024
797
|
createChainEdgeIdentity,
|
|
1025
798
|
createDeviceEdgeIdentity,
|
|
1026
799
|
createEphemeralEdgeIdentity,
|