@dxos/edge-client 0.8.4-main.9be5663bfe → 0.8.4-main.abd8ff62ef
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/neutral/{chunk-VESGVCLQ.mjs → chunk-ZIQ5T3A7.mjs} +6 -40
- package/dist/lib/neutral/{chunk-VESGVCLQ.mjs.map → chunk-ZIQ5T3A7.mjs.map} +2 -2
- package/dist/lib/neutral/edge-ws-muxer.mjs +1 -1
- package/dist/lib/neutral/index.mjs +76 -321
- package/dist/lib/neutral/index.mjs.map +3 -3
- package/dist/lib/neutral/meta.json +1 -1
- package/dist/lib/neutral/testing/index.mjs +6 -31
- package/dist/lib/neutral/testing/index.mjs.map +2 -2
- package/dist/types/src/auth.d.ts.map +1 -1
- package/dist/types/src/edge-client.d.ts.map +1 -1
- package/dist/types/src/edge-http-client.d.ts +17 -2
- 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.map +1 -1
- package/dist/types/src/edge-ws-muxer.d.ts.map +1 -1
- package/dist/types/src/errors.d.ts.map +1 -1
- package/dist/types/src/http-client.d.ts +2 -2
- package/dist/types/src/http-client.d.ts.map +1 -1
- package/dist/types/src/protocol.d.ts +1 -1
- package/dist/types/src/protocol.d.ts.map +1 -1
- package/dist/types/src/testing/test-server.d.ts.map +1 -1
- package/dist/types/src/testing/test-utils.d.ts.map +1 -1
- package/dist/types/src/utils.d.ts +1 -1
- package/dist/types/src/utils.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +16 -23
- package/src/edge-client.ts +5 -18
- package/src/edge-http-client.ts +33 -14
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
getTypename,
|
|
7
7
|
protocol,
|
|
8
8
|
toUint8Array
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-ZIQ5T3A7.mjs";
|
|
10
10
|
|
|
11
11
|
// src/index.ts
|
|
12
12
|
export * from "@dxos/protocols/buf/dxos/edge/messenger_pb";
|
|
@@ -60,15 +60,7 @@ var createChainEdgeIdentity = async (signer, identityKey, peerKey, chain, creden
|
|
|
60
60
|
identityKey: identityKey.toHex(),
|
|
61
61
|
peerKey: peerKey.toHex(),
|
|
62
62
|
presentCredentials: async ({ challenge }) => {
|
|
63
|
-
invariant(chain, void 0, {
|
|
64
|
-
F: __dxlog_file,
|
|
65
|
-
L: 75,
|
|
66
|
-
S: void 0,
|
|
67
|
-
A: [
|
|
68
|
-
"chain",
|
|
69
|
-
""
|
|
70
|
-
]
|
|
71
|
-
});
|
|
63
|
+
invariant(chain, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 56, S: void 0, A: ["chain", ""] });
|
|
72
64
|
return signPresentation({
|
|
73
65
|
presentation: {
|
|
74
66
|
credentials: credentialsToSign
|
|
@@ -123,47 +115,22 @@ var createStubEdgeIdentity = () => {
|
|
|
123
115
|
};
|
|
124
116
|
|
|
125
117
|
// src/edge-client.ts
|
|
126
|
-
import { propagation } from "@opentelemetry/api";
|
|
127
118
|
import { Event, PersistentLifecycle, Trigger, TriggerState, scheduleMicroTask, scheduleTaskInterval as scheduleTaskInterval2 } from "@dxos/async";
|
|
119
|
+
import { TRACE_SPAN_ATTRIBUTE } from "@dxos/context";
|
|
128
120
|
import { Resource as Resource2 } from "@dxos/context";
|
|
129
121
|
import { log as log2, logInfo as logInfo2 } from "@dxos/log";
|
|
130
122
|
import { EdgeStatus } from "@dxos/protocols/proto/dxos/client/services";
|
|
131
|
-
import { TRACE_PROCESSOR, TRACE_SPAN_ATTRIBUTE } from "@dxos/tracing";
|
|
132
123
|
|
|
133
124
|
// src/edge-identity.ts
|
|
134
125
|
import { invariant as invariant2 } from "@dxos/invariant";
|
|
135
126
|
import { schema } from "@dxos/protocols/proto";
|
|
136
127
|
var __dxlog_file2 = "/__w/dxos/dxos/packages/core/mesh/edge-client/src/edge-identity.ts";
|
|
137
128
|
var handleAuthChallenge = async (failedResponse, identity) => {
|
|
138
|
-
invariant2(failedResponse.status === 401, void 0, {
|
|
139
|
-
F: __dxlog_file2,
|
|
140
|
-
L: 21,
|
|
141
|
-
S: void 0,
|
|
142
|
-
A: [
|
|
143
|
-
"failedResponse.status === 401",
|
|
144
|
-
""
|
|
145
|
-
]
|
|
146
|
-
});
|
|
129
|
+
invariant2(failedResponse.status === 401, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 7, S: void 0, A: ["failedResponse.status === 401", ""] });
|
|
147
130
|
const headerValue = failedResponse.headers.get("Www-Authenticate");
|
|
148
|
-
invariant2(headerValue?.startsWith("VerifiablePresentation challenge="), void 0, {
|
|
149
|
-
F: __dxlog_file2,
|
|
150
|
-
L: 24,
|
|
151
|
-
S: void 0,
|
|
152
|
-
A: [
|
|
153
|
-
"headerValue?.startsWith('VerifiablePresentation challenge=')",
|
|
154
|
-
""
|
|
155
|
-
]
|
|
156
|
-
});
|
|
131
|
+
invariant2(headerValue?.startsWith("VerifiablePresentation challenge="), void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 9, S: void 0, A: ["headerValue?.startsWith('VerifiablePresentation challenge=')", ""] });
|
|
157
132
|
const challenge = headerValue?.slice("VerifiablePresentation challenge=".length);
|
|
158
|
-
invariant2(challenge, void 0, {
|
|
159
|
-
F: __dxlog_file2,
|
|
160
|
-
L: 27,
|
|
161
|
-
S: void 0,
|
|
162
|
-
A: [
|
|
163
|
-
"challenge",
|
|
164
|
-
""
|
|
165
|
-
]
|
|
166
|
-
});
|
|
133
|
+
invariant2(challenge, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 11, S: void 0, A: ["challenge", ""] });
|
|
167
134
|
const presentation = await identity.presentCredentials({
|
|
168
135
|
challenge: Buffer.from(challenge, "base64")
|
|
169
136
|
});
|
|
@@ -179,13 +146,13 @@ import { log, logInfo } from "@dxos/log";
|
|
|
179
146
|
import { EdgeWebsocketProtocol } from "@dxos/protocols";
|
|
180
147
|
import { buf } from "@dxos/protocols/buf";
|
|
181
148
|
import { MessageSchema } from "@dxos/protocols/buf/dxos/edge/messenger_pb";
|
|
149
|
+
var __dxlog_file3 = "/__w/dxos/dxos/packages/core/mesh/edge-client/src/edge-ws-connection.ts";
|
|
182
150
|
function _ts_decorate(decorators, target, key, desc) {
|
|
183
151
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
184
152
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
185
153
|
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;
|
|
186
154
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
187
155
|
}
|
|
188
|
-
var __dxlog_file3 = "/__w/dxos/dxos/packages/core/mesh/edge-client/src/edge-ws-connection.ts";
|
|
189
156
|
var SIGNAL_KEEPALIVE_INTERVAL = 4e3;
|
|
190
157
|
var SIGNAL_KEEPALIVE_TIMEOUT = 12e3;
|
|
191
158
|
var EdgeWsConnection = class extends Resource {
|
|
@@ -237,33 +204,12 @@ var EdgeWsConnection = class extends Resource {
|
|
|
237
204
|
return this._messagesReceived;
|
|
238
205
|
}
|
|
239
206
|
send(message) {
|
|
240
|
-
invariant3(this._ws, void 0, {
|
|
241
|
-
|
|
242
|
-
L: 93,
|
|
243
|
-
S: this,
|
|
244
|
-
A: [
|
|
245
|
-
"this._ws",
|
|
246
|
-
""
|
|
247
|
-
]
|
|
248
|
-
});
|
|
249
|
-
invariant3(this._wsMuxer, void 0, {
|
|
250
|
-
F: __dxlog_file3,
|
|
251
|
-
L: 94,
|
|
252
|
-
S: this,
|
|
253
|
-
A: [
|
|
254
|
-
"this._wsMuxer",
|
|
255
|
-
""
|
|
256
|
-
]
|
|
257
|
-
});
|
|
207
|
+
invariant3(this._ws, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 72, S: this, A: ["this._ws", ""] });
|
|
208
|
+
invariant3(this._wsMuxer, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 73, S: this, A: ["this._wsMuxer", ""] });
|
|
258
209
|
log("sending...", {
|
|
259
210
|
peerKey: this._identity.peerKey,
|
|
260
211
|
payload: protocol.getPayloadType(message)
|
|
261
|
-
}, {
|
|
262
|
-
F: __dxlog_file3,
|
|
263
|
-
L: 95,
|
|
264
|
-
S: this,
|
|
265
|
-
C: (f, a) => f(...a)
|
|
266
|
-
});
|
|
212
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 74, S: this });
|
|
267
213
|
this._messagesSent++;
|
|
268
214
|
if (this._ws?.protocol.includes(EdgeWebsocketProtocol.V0)) {
|
|
269
215
|
const binary = buf.toBinary(MessageSchema, message);
|
|
@@ -272,12 +218,7 @@ var EdgeWsConnection = class extends Resource {
|
|
|
272
218
|
byteLength: binary.byteLength,
|
|
273
219
|
serviceId: message.serviceId,
|
|
274
220
|
payload: protocol.getPayloadType(message)
|
|
275
|
-
}, {
|
|
276
|
-
F: __dxlog_file3,
|
|
277
|
-
L: 100,
|
|
278
|
-
S: this,
|
|
279
|
-
C: (f, a) => f(...a)
|
|
280
|
-
});
|
|
221
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 82, S: this });
|
|
281
222
|
return;
|
|
282
223
|
}
|
|
283
224
|
this._recordBytes(binary.byteLength, 0);
|
|
@@ -285,12 +226,7 @@ var EdgeWsConnection = class extends Resource {
|
|
|
285
226
|
} else {
|
|
286
227
|
const binary = buf.toBinary(MessageSchema, message);
|
|
287
228
|
this._recordBytes(binary.byteLength, 0);
|
|
288
|
-
this._wsMuxer.send(message).catch((e) => log.catch(e, void 0, {
|
|
289
|
-
F: __dxlog_file3,
|
|
290
|
-
L: 113,
|
|
291
|
-
S: this,
|
|
292
|
-
C: (f, a) => f(...a)
|
|
293
|
-
}));
|
|
229
|
+
this._wsMuxer.send(message).catch((e) => log.catch(e, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 95, S: this }));
|
|
294
230
|
}
|
|
295
231
|
}
|
|
296
232
|
async _open() {
|
|
@@ -309,12 +245,7 @@ var EdgeWsConnection = class extends Resource {
|
|
|
309
245
|
this._wsMuxer = muxer;
|
|
310
246
|
this._ws.onopen = () => {
|
|
311
247
|
if (this.isOpen) {
|
|
312
|
-
log("connected", void 0, {
|
|
313
|
-
F: __dxlog_file3,
|
|
314
|
-
L: 131,
|
|
315
|
-
S: this,
|
|
316
|
-
C: (f, a) => f(...a)
|
|
317
|
-
});
|
|
248
|
+
log("connected", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 114, S: this });
|
|
318
249
|
this._openTimestamp = Date.now();
|
|
319
250
|
this._callbacks.onConnected();
|
|
320
251
|
this._scheduleHeartbeats();
|
|
@@ -322,12 +253,7 @@ var EdgeWsConnection = class extends Resource {
|
|
|
322
253
|
} else {
|
|
323
254
|
log.verbose("connected after becoming inactive", {
|
|
324
255
|
currentIdentity: this._identity
|
|
325
|
-
}, {
|
|
326
|
-
F: __dxlog_file3,
|
|
327
|
-
L: 137,
|
|
328
|
-
S: this,
|
|
329
|
-
C: (f, a) => f(...a)
|
|
330
|
-
});
|
|
256
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 120, S: this });
|
|
331
257
|
}
|
|
332
258
|
};
|
|
333
259
|
this._ws.onclose = (event) => {
|
|
@@ -335,12 +261,7 @@ var EdgeWsConnection = class extends Resource {
|
|
|
335
261
|
log.warn("server disconnected", {
|
|
336
262
|
code: event.code,
|
|
337
263
|
reason: event.reason
|
|
338
|
-
}, {
|
|
339
|
-
F: __dxlog_file3,
|
|
340
|
-
L: 142,
|
|
341
|
-
S: this,
|
|
342
|
-
C: (f, a) => f(...a)
|
|
343
|
-
});
|
|
264
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 127, S: this });
|
|
344
265
|
this._callbacks.onRestartRequired();
|
|
345
266
|
muxer.destroy();
|
|
346
267
|
}
|
|
@@ -350,34 +271,19 @@ var EdgeWsConnection = class extends Resource {
|
|
|
350
271
|
log.warn("edge connection socket error", {
|
|
351
272
|
error: event.error,
|
|
352
273
|
info: event.message
|
|
353
|
-
}, {
|
|
354
|
-
F: __dxlog_file3,
|
|
355
|
-
L: 149,
|
|
356
|
-
S: this,
|
|
357
|
-
C: (f, a) => f(...a)
|
|
358
|
-
});
|
|
274
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 137, S: this });
|
|
359
275
|
this._callbacks.onRestartRequired();
|
|
360
276
|
} else {
|
|
361
277
|
log.verbose("error ignored on closed connection", {
|
|
362
278
|
error: event.error
|
|
363
|
-
}, {
|
|
364
|
-
F: __dxlog_file3,
|
|
365
|
-
L: 152,
|
|
366
|
-
S: this,
|
|
367
|
-
C: (f, a) => f(...a)
|
|
368
|
-
});
|
|
279
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 143, S: this });
|
|
369
280
|
}
|
|
370
281
|
};
|
|
371
282
|
this._ws.onmessage = async (event) => {
|
|
372
283
|
if (!this.isOpen) {
|
|
373
284
|
log.verbose("message ignored on closed connection", {
|
|
374
285
|
event: event.type
|
|
375
|
-
}, {
|
|
376
|
-
F: __dxlog_file3,
|
|
377
|
-
L: 160,
|
|
378
|
-
S: this,
|
|
379
|
-
C: (f, a) => f(...a)
|
|
380
|
-
});
|
|
286
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 152, S: this });
|
|
381
287
|
return;
|
|
382
288
|
}
|
|
383
289
|
this._lastReceivedMessageTimestamp = Date.now();
|
|
@@ -400,12 +306,7 @@ var EdgeWsConnection = class extends Resource {
|
|
|
400
306
|
log("received", {
|
|
401
307
|
from: message.source,
|
|
402
308
|
payload: protocol.getPayloadType(message)
|
|
403
|
-
}, {
|
|
404
|
-
F: __dxlog_file3,
|
|
405
|
-
L: 186,
|
|
406
|
-
S: this,
|
|
407
|
-
C: (f, a) => f(...a)
|
|
408
|
-
});
|
|
309
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 175, S: this });
|
|
409
310
|
this._callbacks.onMessage(message);
|
|
410
311
|
}
|
|
411
312
|
};
|
|
@@ -424,24 +325,11 @@ var EdgeWsConnection = class extends Resource {
|
|
|
424
325
|
}
|
|
425
326
|
log.warn("error closing websocket", {
|
|
426
327
|
err
|
|
427
|
-
}, {
|
|
428
|
-
F: __dxlog_file3,
|
|
429
|
-
L: 204,
|
|
430
|
-
S: this,
|
|
431
|
-
C: (f, a) => f(...a)
|
|
432
|
-
});
|
|
328
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 194, S: this });
|
|
433
329
|
}
|
|
434
330
|
}
|
|
435
331
|
_scheduleHeartbeats() {
|
|
436
|
-
invariant3(this._ws, void 0, {
|
|
437
|
-
F: __dxlog_file3,
|
|
438
|
-
L: 209,
|
|
439
|
-
S: this,
|
|
440
|
-
A: [
|
|
441
|
-
"this._ws",
|
|
442
|
-
""
|
|
443
|
-
]
|
|
444
|
-
});
|
|
332
|
+
invariant3(this._ws, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 200, S: this, A: ["this._ws", ""] });
|
|
445
333
|
scheduleTaskInterval(this._ctx, async () => {
|
|
446
334
|
this._pingTimestamp = Date.now();
|
|
447
335
|
this._ws?.send("__ping__");
|
|
@@ -455,21 +343,13 @@ var EdgeWsConnection = class extends Resource {
|
|
|
455
343
|
return;
|
|
456
344
|
}
|
|
457
345
|
void this._inactivityTimeoutCtx?.dispose();
|
|
458
|
-
this._inactivityTimeoutCtx = new Context(void 0, {
|
|
459
|
-
F: __dxlog_file3,
|
|
460
|
-
L: 230
|
|
461
|
-
});
|
|
346
|
+
this._inactivityTimeoutCtx = new Context(void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 216 });
|
|
462
347
|
scheduleTask(this._inactivityTimeoutCtx, () => {
|
|
463
348
|
if (this.isOpen) {
|
|
464
349
|
if (Date.now() - this._lastReceivedMessageTimestamp > SIGNAL_KEEPALIVE_TIMEOUT) {
|
|
465
350
|
log.warn("restart due to inactivity timeout", {
|
|
466
351
|
lastReceivedMessageTimestamp: this._lastReceivedMessageTimestamp
|
|
467
|
-
}, {
|
|
468
|
-
F: __dxlog_file3,
|
|
469
|
-
L: 236,
|
|
470
|
-
S: this,
|
|
471
|
-
C: (f, a) => f(...a)
|
|
472
|
-
});
|
|
352
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 220, S: this });
|
|
473
353
|
this._callbacks.onRestartRequired();
|
|
474
354
|
} else {
|
|
475
355
|
this._rescheduleHeartbeatTimeout();
|
|
@@ -544,13 +424,13 @@ var getEdgeUrlWithProtocol = (baseUrl, protocol2) => {
|
|
|
544
424
|
};
|
|
545
425
|
|
|
546
426
|
// src/edge-client.ts
|
|
427
|
+
var __dxlog_file4 = "/__w/dxos/dxos/packages/core/mesh/edge-client/src/edge-client.ts";
|
|
547
428
|
function _ts_decorate2(decorators, target, key, desc) {
|
|
548
429
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
549
430
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
550
431
|
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;
|
|
551
432
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
552
433
|
}
|
|
553
|
-
var __dxlog_file4 = "/__w/dxos/dxos/packages/core/mesh/edge-client/src/edge-client.ts";
|
|
554
434
|
var DEFAULT_TIMEOUT = 1e4;
|
|
555
435
|
var STATUS_REFRESH_INTERVAL = 1e3;
|
|
556
436
|
var EdgeClient = class extends Resource2 {
|
|
@@ -602,12 +482,7 @@ var EdgeClient = class extends Resource2 {
|
|
|
602
482
|
log2("Edge identity changed", {
|
|
603
483
|
identity,
|
|
604
484
|
oldIdentity: this._identity
|
|
605
|
-
}, {
|
|
606
|
-
F: __dxlog_file4,
|
|
607
|
-
L: 124,
|
|
608
|
-
S: this,
|
|
609
|
-
C: (f, a) => f(...a)
|
|
610
|
-
});
|
|
485
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file4, L: 74, S: this });
|
|
611
486
|
this._identity = identity;
|
|
612
487
|
this._closeCurrentConnection(new EdgeIdentityChangedError());
|
|
613
488
|
void this._persistentLifecycle.scheduleRestart();
|
|
@@ -619,12 +494,7 @@ var EdgeClient = class extends Resource2 {
|
|
|
619
494
|
*/
|
|
620
495
|
async send(ctx, message) {
|
|
621
496
|
if (this._ready.state !== TriggerState.RESOLVED) {
|
|
622
|
-
log2("waiting for websocket", void 0, {
|
|
623
|
-
F: __dxlog_file4,
|
|
624
|
-
L: 137,
|
|
625
|
-
S: this,
|
|
626
|
-
C: (f, a) => f(...a)
|
|
627
|
-
});
|
|
497
|
+
log2("waiting for websocket", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file4, L: 88, S: this });
|
|
628
498
|
await this._ready.wait({
|
|
629
499
|
timeout: this._config.timeout ?? DEFAULT_TIMEOUT
|
|
630
500
|
});
|
|
@@ -635,15 +505,12 @@ var EdgeClient = class extends Resource2 {
|
|
|
635
505
|
if (message.source && (message.source.peerKey !== this._identity.peerKey || message.source.identityKey !== this.identityKey)) {
|
|
636
506
|
throw new EdgeIdentityChangedError();
|
|
637
507
|
}
|
|
638
|
-
const
|
|
639
|
-
|
|
640
|
-
if (otlpContext) {
|
|
641
|
-
const activeSpan = {};
|
|
642
|
-
propagation.inject(otlpContext, activeSpan);
|
|
508
|
+
const traceCtx = ctx.getAttribute(TRACE_SPAN_ATTRIBUTE);
|
|
509
|
+
if (traceCtx) {
|
|
643
510
|
message.traceContext = {
|
|
644
511
|
$typeName: "dxos.edge.messenger.TraceContext",
|
|
645
|
-
traceparent:
|
|
646
|
-
tracestate:
|
|
512
|
+
traceparent: traceCtx.traceparent,
|
|
513
|
+
tracestate: traceCtx.tracestate
|
|
647
514
|
};
|
|
648
515
|
}
|
|
649
516
|
this._currentConnection.send(message);
|
|
@@ -660,12 +527,7 @@ var EdgeClient = class extends Resource2 {
|
|
|
660
527
|
try {
|
|
661
528
|
listener();
|
|
662
529
|
} catch (error) {
|
|
663
|
-
log2.catch(error, void 0, {
|
|
664
|
-
F: __dxlog_file4,
|
|
665
|
-
L: 189,
|
|
666
|
-
S: this,
|
|
667
|
-
C: (f, a) => f(...a)
|
|
668
|
-
});
|
|
530
|
+
log2.catch(error, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file4, L: 123, S: this });
|
|
669
531
|
}
|
|
670
532
|
}
|
|
671
533
|
});
|
|
@@ -678,21 +540,11 @@ var EdgeClient = class extends Resource2 {
|
|
|
678
540
|
async _open() {
|
|
679
541
|
log2("opening...", {
|
|
680
542
|
info: this.info
|
|
681
|
-
}, {
|
|
682
|
-
F: __dxlog_file4,
|
|
683
|
-
L: 202,
|
|
684
|
-
S: this,
|
|
685
|
-
C: (f, a) => f(...a)
|
|
686
|
-
});
|
|
543
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file4, L: 133, S: this });
|
|
687
544
|
this._persistentLifecycle.open().catch((err) => {
|
|
688
545
|
log2.warn("Error while opening connection", {
|
|
689
546
|
err
|
|
690
|
-
}, {
|
|
691
|
-
F: __dxlog_file4,
|
|
692
|
-
L: 204,
|
|
693
|
-
S: this,
|
|
694
|
-
C: (f, a) => f(...a)
|
|
695
|
-
});
|
|
547
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file4, L: 137, S: this });
|
|
696
548
|
});
|
|
697
549
|
scheduleTaskInterval2(this._ctx, async () => {
|
|
698
550
|
if (!this._currentConnection) {
|
|
@@ -707,12 +559,7 @@ var EdgeClient = class extends Resource2 {
|
|
|
707
559
|
async _close() {
|
|
708
560
|
log2("closing...", {
|
|
709
561
|
peerKey: this._identity.peerKey
|
|
710
|
-
}, {
|
|
711
|
-
F: __dxlog_file4,
|
|
712
|
-
L: 224,
|
|
713
|
-
S: this,
|
|
714
|
-
C: (f, a) => f(...a)
|
|
715
|
-
});
|
|
562
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file4, L: 152, S: this });
|
|
716
563
|
this._closeCurrentConnection();
|
|
717
564
|
await this._persistentLifecycle.close();
|
|
718
565
|
}
|
|
@@ -724,12 +571,7 @@ var EdgeClient = class extends Resource2 {
|
|
|
724
571
|
const path = `/ws/${identity.identityKey}/${identity.peerKey}`;
|
|
725
572
|
const protocolHeader = this._config.disableAuth ? void 0 : await this._createAuthHeader(path);
|
|
726
573
|
if (this._identity !== identity) {
|
|
727
|
-
log2("identity changed during auth header request", void 0, {
|
|
728
|
-
F: __dxlog_file4,
|
|
729
|
-
L: 238,
|
|
730
|
-
S: this,
|
|
731
|
-
C: (f, a) => f(...a)
|
|
732
|
-
});
|
|
574
|
+
log2("identity changed during auth header request", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file4, L: 166, S: this });
|
|
733
575
|
return void 0;
|
|
734
576
|
}
|
|
735
577
|
const restartRequired = new Trigger();
|
|
@@ -737,12 +579,7 @@ var EdgeClient = class extends Resource2 {
|
|
|
737
579
|
log2("Opening websocket", {
|
|
738
580
|
url: url.toString(),
|
|
739
581
|
protocolHeader
|
|
740
|
-
}, {
|
|
741
|
-
F: __dxlog_file4,
|
|
742
|
-
L: 244,
|
|
743
|
-
S: this,
|
|
744
|
-
C: (f, a) => f(...a)
|
|
745
|
-
});
|
|
582
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file4, L: 171, S: this });
|
|
746
583
|
const connection = new EdgeWsConnection(identity, {
|
|
747
584
|
url,
|
|
748
585
|
protocolHeader,
|
|
@@ -755,12 +592,7 @@ var EdgeClient = class extends Resource2 {
|
|
|
755
592
|
this._ready.wake();
|
|
756
593
|
this._notifyReconnected();
|
|
757
594
|
} else {
|
|
758
|
-
log2.verbose("connected callback ignored, because connection is not active", void 0, {
|
|
759
|
-
F: __dxlog_file4,
|
|
760
|
-
L: 258,
|
|
761
|
-
S: this,
|
|
762
|
-
C: (f, a) => f(...a)
|
|
763
|
-
});
|
|
595
|
+
log2.verbose("connected callback ignored, because connection is not active", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file4, L: 187, S: this });
|
|
764
596
|
}
|
|
765
597
|
},
|
|
766
598
|
onRestartRequired: () => {
|
|
@@ -768,12 +600,7 @@ var EdgeClient = class extends Resource2 {
|
|
|
768
600
|
this._closeCurrentConnection();
|
|
769
601
|
void this._persistentLifecycle.scheduleRestart();
|
|
770
602
|
} else {
|
|
771
|
-
log2.verbose("restart requested by inactive connection", void 0, {
|
|
772
|
-
F: __dxlog_file4,
|
|
773
|
-
L: 266,
|
|
774
|
-
S: this,
|
|
775
|
-
C: (f, a) => f(...a)
|
|
776
|
-
});
|
|
603
|
+
log2.verbose("restart requested by inactive connection", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file4, L: 195, S: this });
|
|
777
604
|
}
|
|
778
605
|
restartRequired.wake();
|
|
779
606
|
},
|
|
@@ -784,12 +611,7 @@ var EdgeClient = class extends Resource2 {
|
|
|
784
611
|
log2.verbose("ignored a message on inactive connection", {
|
|
785
612
|
from: message.source,
|
|
786
613
|
type: message.payload?.typeUrl
|
|
787
|
-
}, {
|
|
788
|
-
F: __dxlog_file4,
|
|
789
|
-
L: 274,
|
|
790
|
-
S: this,
|
|
791
|
-
C: (f, a) => f(...a)
|
|
792
|
-
});
|
|
614
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file4, L: 203, S: this });
|
|
793
615
|
}
|
|
794
616
|
}
|
|
795
617
|
});
|
|
@@ -821,12 +643,7 @@ var EdgeClient = class extends Resource2 {
|
|
|
821
643
|
} catch (err) {
|
|
822
644
|
log2.error("ws reconnect listener failed", {
|
|
823
645
|
err
|
|
824
|
-
}, {
|
|
825
|
-
F: __dxlog_file4,
|
|
826
|
-
L: 309,
|
|
827
|
-
S: this,
|
|
828
|
-
C: (f, a) => f(...a)
|
|
829
|
-
});
|
|
646
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file4, L: 238, S: this });
|
|
830
647
|
}
|
|
831
648
|
}
|
|
832
649
|
}
|
|
@@ -838,12 +655,7 @@ var EdgeClient = class extends Resource2 {
|
|
|
838
655
|
log2.error("ws incoming message processing failed", {
|
|
839
656
|
err,
|
|
840
657
|
payload: protocol.getPayloadType(message)
|
|
841
|
-
}, {
|
|
842
|
-
F: __dxlog_file4,
|
|
843
|
-
L: 319,
|
|
844
|
-
S: this,
|
|
845
|
-
C: (f, a) => f(...a)
|
|
846
|
-
});
|
|
658
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file4, L: 249, S: this });
|
|
847
659
|
}
|
|
848
660
|
}
|
|
849
661
|
}
|
|
@@ -859,12 +671,7 @@ var EdgeClient = class extends Resource2 {
|
|
|
859
671
|
log2.warn("no auth challenge from edge", {
|
|
860
672
|
status: response.status,
|
|
861
673
|
statusText: response.statusText
|
|
862
|
-
}, {
|
|
863
|
-
F: __dxlog_file4,
|
|
864
|
-
L: 331,
|
|
865
|
-
S: this,
|
|
866
|
-
C: (f, a) => f(...a)
|
|
867
|
-
});
|
|
674
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file4, L: 265, S: this });
|
|
868
675
|
return void 0;
|
|
869
676
|
}
|
|
870
677
|
}
|
|
@@ -881,15 +688,14 @@ var encodePresentationWsAuthHeader = (encodedPresentation) => {
|
|
|
881
688
|
// src/edge-http-client.ts
|
|
882
689
|
import * as FetchHttpClient from "@effect/platform/FetchHttpClient";
|
|
883
690
|
import * as HttpClient from "@effect/platform/HttpClient";
|
|
884
|
-
import { propagation as propagation2 } from "@opentelemetry/api";
|
|
885
691
|
import * as Effect2 from "effect/Effect";
|
|
886
692
|
import * as Function from "effect/Function";
|
|
887
693
|
import { sleep } from "@dxos/async";
|
|
694
|
+
import { TRACE_SPAN_ATTRIBUTE as TRACE_SPAN_ATTRIBUTE2 } from "@dxos/context";
|
|
888
695
|
import { runAndForwardErrors } from "@dxos/effect";
|
|
889
696
|
import { invariant as invariant4 } from "@dxos/invariant";
|
|
890
697
|
import { log as log4 } from "@dxos/log";
|
|
891
698
|
import { EDGE_CLIENT_TAG_HEADER, EdgeAuthChallengeError, EdgeCallFailedError } from "@dxos/protocols";
|
|
892
|
-
import { TRACE_PROCESSOR as TRACE_PROCESSOR2, TRACE_SPAN_ATTRIBUTE as TRACE_SPAN_ATTRIBUTE2 } from "@dxos/tracing";
|
|
893
699
|
import { createUrl } from "@dxos/util";
|
|
894
700
|
|
|
895
701
|
// src/http-client.ts
|
|
@@ -923,12 +729,7 @@ var withRetryConfig = (effect) => Effect.gen(function* () {
|
|
|
923
729
|
var withLogging = (effect) => effect.pipe(Effect.tap((res) => {
|
|
924
730
|
log3.info("response", {
|
|
925
731
|
status: res.status
|
|
926
|
-
}, {
|
|
927
|
-
F: __dxlog_file5,
|
|
928
|
-
L: 66,
|
|
929
|
-
S: void 0,
|
|
930
|
-
C: (f, a) => f(...a)
|
|
931
|
-
});
|
|
732
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file5, L: 31, S: void 0 });
|
|
932
733
|
}));
|
|
933
734
|
var encodeAuthHeader = (challenge) => {
|
|
934
735
|
const encodedChallenge = Buffer.from(challenge).toString("base64");
|
|
@@ -954,12 +755,7 @@ var EdgeHttpClient = class {
|
|
|
954
755
|
this._clientTag = options?.clientTag;
|
|
955
756
|
log4("created", {
|
|
956
757
|
url: this._baseUrl
|
|
957
|
-
}, {
|
|
958
|
-
F: __dxlog_file6,
|
|
959
|
-
L: 121,
|
|
960
|
-
S: this,
|
|
961
|
-
C: (f, a) => f(...a)
|
|
962
|
-
});
|
|
758
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file6, L: 32, S: this });
|
|
963
759
|
}
|
|
964
760
|
get baseUrl() {
|
|
965
761
|
return this._baseUrl;
|
|
@@ -1057,15 +853,7 @@ var EdgeHttpClient = class {
|
|
|
1057
853
|
//
|
|
1058
854
|
async queryQueue(ctx, subspaceTag, spaceId, query, args) {
|
|
1059
855
|
const queueId = query.queueIds?.[0];
|
|
1060
|
-
invariant4(queueId, "queueId required", {
|
|
1061
|
-
F: __dxlog_file6,
|
|
1062
|
-
L: 244,
|
|
1063
|
-
S: this,
|
|
1064
|
-
A: [
|
|
1065
|
-
"queueId",
|
|
1066
|
-
"'queueId required'"
|
|
1067
|
-
]
|
|
1068
|
-
});
|
|
856
|
+
invariant4(queueId, "queueId required", { "~LogMeta": "~LogMeta", F: __dxlog_file6, L: 132, S: this, A: ["queueId", "'queueId required'"] });
|
|
1069
857
|
return this._call(ctx, createUrl(new URL(`/spaces/${subspaceTag}/${spaceId}/queue/${queueId}/query`, this.baseUrl), {
|
|
1070
858
|
after: query.after,
|
|
1071
859
|
before: query.before,
|
|
@@ -1187,6 +975,19 @@ var EdgeHttpClient = class {
|
|
|
1187
975
|
});
|
|
1188
976
|
}
|
|
1189
977
|
//
|
|
978
|
+
// Registry
|
|
979
|
+
//
|
|
980
|
+
/**
|
|
981
|
+
* Fetches the hydrated plugin directory from the Edge registry service.
|
|
982
|
+
* Unauthenticated; safe to call without an identity.
|
|
983
|
+
*/
|
|
984
|
+
async getRegistryPlugins(ctx, args) {
|
|
985
|
+
return this._call(ctx, new URL("/registry/plugins", this.baseUrl), {
|
|
986
|
+
...args,
|
|
987
|
+
method: "GET"
|
|
988
|
+
});
|
|
989
|
+
}
|
|
990
|
+
//
|
|
1190
991
|
// Import/Export space.
|
|
1191
992
|
//
|
|
1192
993
|
async importBundle(ctx, spaceId, body, args) {
|
|
@@ -1215,12 +1016,7 @@ var EdgeHttpClient = class {
|
|
|
1215
1016
|
log4("fetch", {
|
|
1216
1017
|
url,
|
|
1217
1018
|
request: args.body
|
|
1218
|
-
}, {
|
|
1219
|
-
F: __dxlog_file6,
|
|
1220
|
-
L: 461,
|
|
1221
|
-
S: this,
|
|
1222
|
-
C: (f, a) => f(...a)
|
|
1223
|
-
});
|
|
1019
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file6, L: 290, S: this });
|
|
1224
1020
|
const traceHeaders = getTraceHeaders(ctx);
|
|
1225
1021
|
let handledAuth = false;
|
|
1226
1022
|
const tryCount = 1;
|
|
@@ -1238,24 +1034,11 @@ var EdgeHttpClient = class {
|
|
|
1238
1034
|
url,
|
|
1239
1035
|
tryCount,
|
|
1240
1036
|
authHeader: !!this._authHeader
|
|
1241
|
-
}, {
|
|
1242
|
-
F: __dxlog_file6,
|
|
1243
|
-
L: 478,
|
|
1244
|
-
S: this,
|
|
1245
|
-
C: (f, a) => f(...a)
|
|
1246
|
-
});
|
|
1037
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file6, L: 307, S: this });
|
|
1247
1038
|
const response = await fetch(url, request);
|
|
1248
1039
|
if (response.ok) {
|
|
1249
1040
|
const body2 = await response.clone().json();
|
|
1250
|
-
invariant4(body2, "Expected body to be present", {
|
|
1251
|
-
F: __dxlog_file6,
|
|
1252
|
-
L: 483,
|
|
1253
|
-
S: this,
|
|
1254
|
-
A: [
|
|
1255
|
-
"body",
|
|
1256
|
-
"'Expected body to be present'"
|
|
1257
|
-
]
|
|
1258
|
-
});
|
|
1041
|
+
invariant4(body2, "Expected body to be present", { "~LogMeta": "~LogMeta", F: __dxlog_file6, L: 315, S: this, A: ["body", "'Expected body to be present'"] });
|
|
1259
1042
|
if (!("success" in body2)) {
|
|
1260
1043
|
return body2;
|
|
1261
1044
|
}
|
|
@@ -1268,29 +1051,13 @@ var EdgeHttpClient = class {
|
|
|
1268
1051
|
continue;
|
|
1269
1052
|
}
|
|
1270
1053
|
const body = response.headers.get("Content-Type") === "application/json" ? await response.clone().json() : void 0;
|
|
1271
|
-
invariant4(!body?.success, "Expected body to not be a failure response or undefined.", {
|
|
1272
|
-
F: __dxlog_file6,
|
|
1273
|
-
L: 499,
|
|
1274
|
-
S: this,
|
|
1275
|
-
A: [
|
|
1276
|
-
"!body?.success",
|
|
1277
|
-
"'Expected body to not be a failure response or undefined.'"
|
|
1278
|
-
]
|
|
1279
|
-
});
|
|
1054
|
+
invariant4(!body?.success, "Expected body to not be a failure response or undefined.", { "~LogMeta": "~LogMeta", F: __dxlog_file6, L: 328, S: this, A: ["!body?.success", "'Expected body to not be a failure response or undefined.'"] });
|
|
1280
1055
|
if (body?.data?.type === "auth_challenge" && typeof body?.data?.challenge === "string") {
|
|
1281
1056
|
processingError = new EdgeAuthChallengeError(body.data.challenge, body.data);
|
|
1282
1057
|
} else if (body?.success === false) {
|
|
1283
1058
|
processingError = EdgeCallFailedError.fromUnsuccessfulResponse(response, body);
|
|
1284
1059
|
} else {
|
|
1285
|
-
invariant4(!response.ok, "Expected response to not be ok.", {
|
|
1286
|
-
F: __dxlog_file6,
|
|
1287
|
-
L: 506,
|
|
1288
|
-
S: this,
|
|
1289
|
-
A: [
|
|
1290
|
-
"!response.ok",
|
|
1291
|
-
"'Expected response to not be ok.'"
|
|
1292
|
-
]
|
|
1293
|
-
});
|
|
1060
|
+
invariant4(!response.ok, "Expected response to not be ok.", { "~LogMeta": "~LogMeta", F: __dxlog_file6, L: 334, S: this, A: ["!response.ok", "'Expected response to not be ok.'"] });
|
|
1294
1061
|
processingError = await EdgeCallFailedError.fromHttpFailure(response);
|
|
1295
1062
|
}
|
|
1296
1063
|
} catch (error) {
|
|
@@ -1300,12 +1067,7 @@ var EdgeHttpClient = class {
|
|
|
1300
1067
|
log4.verbose("retrying edge request", {
|
|
1301
1068
|
url,
|
|
1302
1069
|
processingError
|
|
1303
|
-
}, {
|
|
1304
|
-
F: __dxlog_file6,
|
|
1305
|
-
L: 514,
|
|
1306
|
-
S: this,
|
|
1307
|
-
C: (f, a) => f(...a)
|
|
1308
|
-
});
|
|
1070
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file6, L: 341, S: this });
|
|
1309
1071
|
} else {
|
|
1310
1072
|
throw processingError;
|
|
1311
1073
|
}
|
|
@@ -1313,12 +1075,7 @@ var EdgeHttpClient = class {
|
|
|
1313
1075
|
}
|
|
1314
1076
|
async _handleUnauthorized(response) {
|
|
1315
1077
|
if (!this._edgeIdentity) {
|
|
1316
|
-
log4.warn("unauthorized response received before identity was set", void 0, {
|
|
1317
|
-
F: __dxlog_file6,
|
|
1318
|
-
L: 523,
|
|
1319
|
-
S: this,
|
|
1320
|
-
C: (f, a) => f(...a)
|
|
1321
|
-
});
|
|
1078
|
+
log4.warn("unauthorized response received before identity was set", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file6, L: 352, S: this });
|
|
1322
1079
|
throw await EdgeCallFailedError.fromHttpFailure(response);
|
|
1323
1080
|
}
|
|
1324
1081
|
const challenge = await handleAuthChallenge(response, this._edgeIdentity);
|
|
@@ -1337,12 +1094,7 @@ var createRequest = ({ method, body, json = true }, authHeader, traceHeaders, cl
|
|
|
1337
1094
|
if (typeof requestBody === "string" && requestBody.length > WARNING_BODY_SIZE) {
|
|
1338
1095
|
log4.warn("Request with large body", {
|
|
1339
1096
|
bodySize: requestBody.length
|
|
1340
|
-
}, {
|
|
1341
|
-
F: __dxlog_file6,
|
|
1342
|
-
L: 549,
|
|
1343
|
-
S: void 0,
|
|
1344
|
-
C: (f, a) => f(...a)
|
|
1345
|
-
});
|
|
1097
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file6, L: 369, S: void 0 });
|
|
1346
1098
|
}
|
|
1347
1099
|
if (authHeader) {
|
|
1348
1100
|
headers["Authorization"] = authHeader;
|
|
@@ -1360,14 +1112,17 @@ var createRequest = ({ method, body, json = true }, authHeader, traceHeaders, cl
|
|
|
1360
1112
|
};
|
|
1361
1113
|
};
|
|
1362
1114
|
var getTraceHeaders = (ctx) => {
|
|
1363
|
-
const
|
|
1364
|
-
|
|
1365
|
-
if (!otlpContext) {
|
|
1115
|
+
const traceCtx = ctx.getAttribute(TRACE_SPAN_ATTRIBUTE2);
|
|
1116
|
+
if (!traceCtx) {
|
|
1366
1117
|
return void 0;
|
|
1367
1118
|
}
|
|
1368
|
-
const headers = {
|
|
1369
|
-
|
|
1370
|
-
|
|
1119
|
+
const headers = {
|
|
1120
|
+
traceparent: traceCtx.traceparent
|
|
1121
|
+
};
|
|
1122
|
+
if (traceCtx.tracestate) {
|
|
1123
|
+
headers.tracestate = traceCtx.tracestate;
|
|
1124
|
+
}
|
|
1125
|
+
return headers;
|
|
1371
1126
|
};
|
|
1372
1127
|
var createRetryHandler = ({ retry: retry2 }) => {
|
|
1373
1128
|
if (!retry2 || retry2.count < 1) {
|