@dxos/edge-client 0.8.4-main.ead640a → 0.8.4-main.ef1bc66f44
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-IKP53CBQ.mjs → neutral/chunk-VESGVCLQ.mjs} +15 -44
- package/dist/lib/{browser/chunk-IKP53CBQ.mjs.map → neutral/chunk-VESGVCLQ.mjs.map} +2 -2
- package/dist/lib/{browser → neutral}/edge-ws-muxer.mjs +1 -1
- package/dist/lib/{browser → neutral}/index.mjs +159 -141
- package/dist/lib/neutral/index.mjs.map +7 -0
- package/dist/lib/neutral/meta.json +1 -0
- package/dist/lib/{browser → neutral}/testing/index.mjs +1 -1
- package/dist/lib/{browser → neutral}/testing/index.mjs.map +1 -1
- package/dist/types/src/edge-http-client.d.ts +13 -7
- package/dist/types/src/edge-http-client.d.ts.map +1 -1
- package/dist/types/src/http-client.d.ts.map +1 -1
- package/dist/types/src/testing/test-utils.d.ts +2 -2
- package/dist/types/src/testing/test-utils.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +25 -23
- package/src/edge-http-client.test.ts +1 -1
- package/src/edge-http-client.ts +60 -36
- package/src/http-client.test.ts +3 -2
- package/src/http-client.ts +5 -1
- package/src/testing/test-utils.ts +4 -4
- package/dist/lib/browser/index.mjs.map +0 -7
- package/dist/lib/browser/meta.json +0 -1
- package/dist/lib/node-esm/chunk-DR5YNW5K.mjs +0 -332
- package/dist/lib/node-esm/chunk-DR5YNW5K.mjs.map +0 -7
- package/dist/lib/node-esm/edge-ws-muxer.mjs +0 -12
- package/dist/lib/node-esm/edge-ws-muxer.mjs.map +0 -7
- package/dist/lib/node-esm/index.mjs +0 -1357
- package/dist/lib/node-esm/index.mjs.map +0 -7
- package/dist/lib/node-esm/meta.json +0 -1
- package/dist/lib/node-esm/testing/index.mjs +0 -186
- package/dist/lib/node-esm/testing/index.mjs.map +0 -7
- /package/dist/lib/{browser → neutral}/edge-ws-muxer.mjs.map +0 -0
package/package.json
CHANGED
|
@@ -1,31 +1,32 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/edge-client",
|
|
3
|
-
"version": "0.8.4-main.
|
|
3
|
+
"version": "0.8.4-main.ef1bc66f44",
|
|
4
4
|
"description": "EDGE Client",
|
|
5
5
|
"homepage": "https://dxos.org",
|
|
6
6
|
"bugs": "https://github.com/dxos/dxos/issues",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "https://github.com/dxos/dxos"
|
|
10
|
+
},
|
|
7
11
|
"license": "MIT",
|
|
8
12
|
"author": "DXOS.org",
|
|
9
|
-
"sideEffects":
|
|
13
|
+
"sideEffects": false,
|
|
10
14
|
"type": "module",
|
|
11
15
|
"exports": {
|
|
12
16
|
".": {
|
|
13
17
|
"source": "./src/index.ts",
|
|
14
18
|
"types": "./dist/types/src/index.d.ts",
|
|
15
|
-
"
|
|
16
|
-
"node": "./dist/lib/node-esm/index.mjs"
|
|
19
|
+
"default": "./dist/lib/neutral/index.mjs"
|
|
17
20
|
},
|
|
18
21
|
"./muxer": {
|
|
19
22
|
"source": "./src/edge-ws-muxer.ts",
|
|
20
23
|
"types": "./dist/types/src/edge-ws-muxer.d.ts",
|
|
21
|
-
"
|
|
22
|
-
"node": "./dist/lib/node-esm/edge-ws-muxer.mjs"
|
|
24
|
+
"default": "./dist/lib/neutral/edge-ws-muxer.mjs"
|
|
23
25
|
},
|
|
24
26
|
"./testing": {
|
|
25
27
|
"source": "./src/testing/index.ts",
|
|
26
28
|
"types": "./dist/types/src/testing/index.d.ts",
|
|
27
|
-
"
|
|
28
|
-
"node": "./dist/lib/node-esm/testing/index.mjs"
|
|
29
|
+
"default": "./dist/lib/neutral/testing/index.mjs"
|
|
29
30
|
}
|
|
30
31
|
},
|
|
31
32
|
"types": "dist/types/src/index.d.ts",
|
|
@@ -42,27 +43,28 @@
|
|
|
42
43
|
"README.md"
|
|
43
44
|
],
|
|
44
45
|
"dependencies": {
|
|
45
|
-
"@effect/platform": "
|
|
46
|
+
"@effect/platform": "0.94.4",
|
|
46
47
|
"isomorphic-ws": "^5.0.0",
|
|
47
48
|
"ws": "^8.14.2",
|
|
48
|
-
"@dxos/async": "0.8.4-main.
|
|
49
|
-
"@dxos/context": "0.8.4-main.
|
|
50
|
-
"@dxos/
|
|
51
|
-
"@dxos/debug": "0.8.4-main.
|
|
52
|
-
"@dxos/
|
|
53
|
-
"@dxos/
|
|
54
|
-
"@dxos/
|
|
55
|
-
"@dxos/
|
|
56
|
-
"@dxos/keys": "0.8.4-main.
|
|
57
|
-
"@dxos/
|
|
58
|
-
"@dxos/protocols": "0.8.4-main.
|
|
59
|
-
"@dxos/util": "0.8.4-main.
|
|
49
|
+
"@dxos/async": "0.8.4-main.ef1bc66f44",
|
|
50
|
+
"@dxos/context": "0.8.4-main.ef1bc66f44",
|
|
51
|
+
"@dxos/crypto": "0.8.4-main.ef1bc66f44",
|
|
52
|
+
"@dxos/debug": "0.8.4-main.ef1bc66f44",
|
|
53
|
+
"@dxos/credentials": "0.8.4-main.ef1bc66f44",
|
|
54
|
+
"@dxos/effect": "0.8.4-main.ef1bc66f44",
|
|
55
|
+
"@dxos/invariant": "0.8.4-main.ef1bc66f44",
|
|
56
|
+
"@dxos/keyring": "0.8.4-main.ef1bc66f44",
|
|
57
|
+
"@dxos/keys": "0.8.4-main.ef1bc66f44",
|
|
58
|
+
"@dxos/log": "0.8.4-main.ef1bc66f44",
|
|
59
|
+
"@dxos/protocols": "0.8.4-main.ef1bc66f44",
|
|
60
|
+
"@dxos/util": "0.8.4-main.ef1bc66f44",
|
|
61
|
+
"@dxos/node-std": "0.8.4-main.ef1bc66f44"
|
|
60
62
|
},
|
|
61
63
|
"devDependencies": {
|
|
62
|
-
"@dxos/test-utils": "0.8.4-main.
|
|
64
|
+
"@dxos/test-utils": "0.8.4-main.ef1bc66f44"
|
|
63
65
|
},
|
|
64
66
|
"peerDependencies": {
|
|
65
|
-
"effect": "
|
|
67
|
+
"effect": "3.19.16"
|
|
66
68
|
},
|
|
67
69
|
"publishConfig": {
|
|
68
70
|
"access": "public"
|
|
@@ -11,7 +11,7 @@ import { EdgeHttpClient } from './edge-http-client';
|
|
|
11
11
|
const DEV_SERVER = 'https://edge.dxos.workers.dev';
|
|
12
12
|
|
|
13
13
|
describe.skipIf(process.env.CI)('EdgeHttpClient', () => {
|
|
14
|
-
it.
|
|
14
|
+
it.skip('should get status', async ({ expect }) => {
|
|
15
15
|
const client = new EdgeHttpClient(DEV_SERVER);
|
|
16
16
|
const identity = await createEphemeralEdgeIdentity();
|
|
17
17
|
client.setIdentity(identity);
|
package/src/edge-http-client.ts
CHANGED
|
@@ -9,6 +9,8 @@ import * as Function from 'effect/Function';
|
|
|
9
9
|
|
|
10
10
|
import { sleep } from '@dxos/async';
|
|
11
11
|
import { Context } from '@dxos/context';
|
|
12
|
+
import { runAndForwardErrors } from '@dxos/effect';
|
|
13
|
+
import { invariant } from '@dxos/invariant';
|
|
12
14
|
import { type PublicKey, type SpaceId } from '@dxos/keys';
|
|
13
15
|
import { log } from '@dxos/log';
|
|
14
16
|
import {
|
|
@@ -18,11 +20,12 @@ import {
|
|
|
18
20
|
type CreateSpaceResponseBody,
|
|
19
21
|
EdgeAuthChallengeError,
|
|
20
22
|
EdgeCallFailedError,
|
|
21
|
-
type
|
|
23
|
+
type EdgeFailure,
|
|
22
24
|
type EdgeStatus,
|
|
23
25
|
type ExecuteWorkflowResponseBody,
|
|
24
26
|
type ExportBundleRequest,
|
|
25
27
|
type ExportBundleResponse,
|
|
28
|
+
type FeedProtocol,
|
|
26
29
|
type GetAgentStatusResponseBody,
|
|
27
30
|
type GetNotarizationResponseBody,
|
|
28
31
|
type ImportBundleRequest,
|
|
@@ -32,8 +35,6 @@ import {
|
|
|
32
35
|
type JoinSpaceResponseBody,
|
|
33
36
|
type ObjectId,
|
|
34
37
|
type PostNotarizationRequestBody,
|
|
35
|
-
type QueryResult,
|
|
36
|
-
type QueueQuery,
|
|
37
38
|
type RecoverIdentityRequest,
|
|
38
39
|
type RecoverIdentityResponseBody,
|
|
39
40
|
type UploadFunctionRequest,
|
|
@@ -76,13 +77,19 @@ type EdgeHttpRequestArgs = {
|
|
|
76
77
|
json?: boolean;
|
|
77
78
|
|
|
78
79
|
/**
|
|
79
|
-
*
|
|
80
|
+
* Force authentication.
|
|
81
|
+
* This should be used for requests with large bodies to avoid sending the body twice.
|
|
82
|
+
* The client will call /auth endpoint to generate the auth header.
|
|
80
83
|
*/
|
|
81
|
-
|
|
84
|
+
auth?: boolean;
|
|
82
85
|
};
|
|
83
86
|
|
|
84
|
-
export type EdgeHttpGetArgs = Pick<EdgeHttpRequestArgs, 'context' | 'retry'>;
|
|
85
|
-
export type EdgeHttpPostArgs = Pick<EdgeHttpRequestArgs, 'context' | 'retry' | 'body'>;
|
|
87
|
+
export type EdgeHttpGetArgs = Pick<EdgeHttpRequestArgs, 'context' | 'retry' | 'auth'>;
|
|
88
|
+
export type EdgeHttpPostArgs = Pick<EdgeHttpRequestArgs, 'context' | 'retry' | 'body' | 'auth'>;
|
|
89
|
+
|
|
90
|
+
export type GetCronTriggersResponse = {
|
|
91
|
+
cronIds: string[];
|
|
92
|
+
};
|
|
86
93
|
|
|
87
94
|
export class EdgeHttpClient {
|
|
88
95
|
private readonly _baseUrl: string;
|
|
@@ -115,7 +122,7 @@ export class EdgeHttpClient {
|
|
|
115
122
|
//
|
|
116
123
|
|
|
117
124
|
public async getStatus(args?: EdgeHttpGetArgs): Promise<EdgeStatus> {
|
|
118
|
-
return this._call(new URL('/status', this.baseUrl), { ...args, method: 'GET' });
|
|
125
|
+
return this._call(new URL('/status', this.baseUrl), { ...args, method: 'GET', auth: true });
|
|
119
126
|
}
|
|
120
127
|
|
|
121
128
|
//
|
|
@@ -201,10 +208,11 @@ export class EdgeHttpClient {
|
|
|
201
208
|
public async queryQueue(
|
|
202
209
|
subspaceTag: string,
|
|
203
210
|
spaceId: SpaceId,
|
|
204
|
-
query: QueueQuery,
|
|
211
|
+
query: FeedProtocol.QueueQuery,
|
|
205
212
|
args?: EdgeHttpGetArgs,
|
|
206
|
-
): Promise<QueryResult> {
|
|
207
|
-
const
|
|
213
|
+
): Promise<FeedProtocol.QueryResult> {
|
|
214
|
+
const queueId = query.queueIds?.[0];
|
|
215
|
+
invariant(queueId, 'queueId required');
|
|
208
216
|
return this._call(
|
|
209
217
|
createUrl(new URL(`/spaces/${subspaceTag}/${spaceId}/queue/${queueId}/query`, this.baseUrl), {
|
|
210
218
|
after: query.after,
|
|
@@ -266,6 +274,7 @@ export class EdgeHttpClient {
|
|
|
266
274
|
formData.append('version', body.version);
|
|
267
275
|
formData.append('ownerPublicKey', body.ownerPublicKey);
|
|
268
276
|
formData.append('entryPoint', body.entryPoint);
|
|
277
|
+
body.runtime && formData.append('runtime', body.runtime);
|
|
269
278
|
for (const [filename, content] of Object.entries(body.assets)) {
|
|
270
279
|
formData.append(
|
|
271
280
|
'assets',
|
|
@@ -316,7 +325,6 @@ export class EdgeHttpClient {
|
|
|
316
325
|
...args,
|
|
317
326
|
body: input,
|
|
318
327
|
method: 'POST',
|
|
319
|
-
rawResponse: true,
|
|
320
328
|
});
|
|
321
329
|
}
|
|
322
330
|
|
|
@@ -341,8 +349,16 @@ export class EdgeHttpClient {
|
|
|
341
349
|
// Triggers
|
|
342
350
|
//
|
|
343
351
|
|
|
344
|
-
public async getCronTriggers(spaceId: SpaceId) {
|
|
345
|
-
return this._call(new URL(`/test/functions/${spaceId}/triggers/crons`, this.baseUrl), {
|
|
352
|
+
public async getCronTriggers(spaceId: SpaceId): Promise<GetCronTriggersResponse> {
|
|
353
|
+
return this._call<GetCronTriggersResponse>(new URL(`/test/functions/${spaceId}/triggers/crons`, this.baseUrl), {
|
|
354
|
+
method: 'GET',
|
|
355
|
+
});
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
public async forceRunCronTrigger(spaceId: SpaceId, triggerId: ObjectId) {
|
|
359
|
+
return this._call(new URL(`/test/functions/${spaceId}/triggers/crons/${triggerId}/run`, this.baseUrl), {
|
|
360
|
+
method: 'POST',
|
|
361
|
+
});
|
|
346
362
|
}
|
|
347
363
|
|
|
348
364
|
//
|
|
@@ -373,7 +389,7 @@ export class EdgeHttpClient {
|
|
|
373
389
|
// Internal
|
|
374
390
|
//
|
|
375
391
|
|
|
376
|
-
private async _fetch<T>(url: URL,
|
|
392
|
+
private async _fetch<T>(url: URL, _args: EdgeHttpRequestArgs): Promise<T> {
|
|
377
393
|
return Function.pipe(
|
|
378
394
|
HttpClient.get(url),
|
|
379
395
|
withLogging,
|
|
@@ -381,58 +397,66 @@ export class EdgeHttpClient {
|
|
|
381
397
|
Effect.provide(FetchHttpClient.layer),
|
|
382
398
|
Effect.provide(HttpConfig.default),
|
|
383
399
|
Effect.withSpan('EdgeHttpClient'),
|
|
384
|
-
|
|
400
|
+
runAndForwardErrors,
|
|
385
401
|
) as T;
|
|
386
402
|
}
|
|
387
403
|
|
|
388
404
|
// TODO(burdon): Refactor with effect (see edge-http-client.test.ts).
|
|
389
405
|
private async _call<T>(url: URL, args: EdgeHttpRequestArgs): Promise<T> {
|
|
390
406
|
const shouldRetry = createRetryHandler(args);
|
|
391
|
-
const requestContext = args.context ??
|
|
407
|
+
const requestContext = args.context ?? Context.default();
|
|
392
408
|
log('fetch', { url, request: args.body });
|
|
393
409
|
|
|
394
410
|
let handledAuth = false;
|
|
411
|
+
const tryCount = 1;
|
|
395
412
|
while (true) {
|
|
396
413
|
let processingError: EdgeCallFailedError | undefined = undefined;
|
|
397
|
-
let retryAfterHeaderValue: number = Number.NaN;
|
|
398
414
|
try {
|
|
415
|
+
if (!this._authHeader && args.auth) {
|
|
416
|
+
const response = await fetch(new URL(`/auth`, this.baseUrl));
|
|
417
|
+
if (response.status === 401) {
|
|
418
|
+
this._authHeader = await this._handleUnauthorized(response);
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
|
|
399
422
|
const request = createRequest(args, this._authHeader);
|
|
423
|
+
log('call edge', { url, tryCount, authHeader: !!this._authHeader });
|
|
400
424
|
const response = await fetch(url, request);
|
|
401
|
-
retryAfterHeaderValue = Number(response.headers.get('Retry-After'));
|
|
402
|
-
if (response.ok) {
|
|
403
|
-
const body = (await response.json()) as EdgeHttpResponse<T>;
|
|
404
|
-
|
|
405
|
-
if (args.rawResponse) {
|
|
406
|
-
return body as any;
|
|
407
|
-
}
|
|
408
425
|
|
|
426
|
+
if (response.ok) {
|
|
427
|
+
const body = await response.clone().json();
|
|
428
|
+
invariant(body, 'Expected body to be present');
|
|
409
429
|
if (!('success' in body)) {
|
|
410
430
|
return body;
|
|
411
431
|
}
|
|
412
|
-
|
|
413
432
|
if (body.success) {
|
|
414
433
|
return body.data;
|
|
415
434
|
}
|
|
416
|
-
|
|
417
|
-
log.warn('unsuccessful edge response', { url, body });
|
|
418
|
-
if (body.errorData?.type === 'auth_challenge' && typeof body.errorData?.challenge === 'string') {
|
|
419
|
-
processingError = new EdgeAuthChallengeError(body.errorData.challenge, body.errorData);
|
|
420
|
-
} else if (body.errorData) {
|
|
421
|
-
processingError = EdgeCallFailedError.fromUnsuccessfulResponse(response, body);
|
|
422
|
-
}
|
|
423
435
|
} else if (response.status === 401 && !handledAuth) {
|
|
424
436
|
this._authHeader = await this._handleUnauthorized(response);
|
|
425
437
|
handledAuth = true;
|
|
426
438
|
continue;
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
const body: EdgeFailure =
|
|
442
|
+
response.headers.get('Content-Type') === 'application/json' ? await response.clone().json() : undefined;
|
|
443
|
+
|
|
444
|
+
invariant(!body?.success, 'Expected body to not be a failure response or undefined.');
|
|
445
|
+
|
|
446
|
+
if (body?.data?.type === 'auth_challenge' && typeof body?.data?.challenge === 'string') {
|
|
447
|
+
processingError = new EdgeAuthChallengeError(body.data.challenge, body.data);
|
|
448
|
+
} else if (body?.success === false) {
|
|
449
|
+
processingError = EdgeCallFailedError.fromUnsuccessfulResponse(response, body);
|
|
427
450
|
} else {
|
|
451
|
+
invariant(!response.ok, 'Expected response to not be ok.');
|
|
428
452
|
processingError = await EdgeCallFailedError.fromHttpFailure(response);
|
|
429
453
|
}
|
|
430
454
|
} catch (error: any) {
|
|
431
455
|
processingError = EdgeCallFailedError.fromProcessingFailureCause(error);
|
|
432
456
|
}
|
|
433
457
|
|
|
434
|
-
if (processingError?.isRetryable && (await shouldRetry(requestContext,
|
|
435
|
-
log('retrying edge request', { url, processingError });
|
|
458
|
+
if (processingError?.isRetryable && (await shouldRetry(requestContext, processingError.retryAfterMs))) {
|
|
459
|
+
log.verbose('retrying edge request', { url, processingError });
|
|
436
460
|
} else {
|
|
437
461
|
throw processingError!;
|
|
438
462
|
}
|
|
@@ -491,7 +515,7 @@ const createRetryHandler = ({ retry }: EdgeHttpRequestArgs) => {
|
|
|
491
515
|
const maxRetries = retry.count ?? DEFAULT_MAX_RETRIES_COUNT;
|
|
492
516
|
const baseTimeout = retry.timeout ?? DEFAULT_RETRY_TIMEOUT;
|
|
493
517
|
const jitter = retry.jitter ?? DEFAULT_RETRY_JITTER;
|
|
494
|
-
return async (ctx: Context, retryAfter
|
|
518
|
+
return async (ctx: Context, retryAfter?: number) => {
|
|
495
519
|
if (++retries > maxRetries || ctx.disposed) {
|
|
496
520
|
return false;
|
|
497
521
|
}
|
package/src/http-client.test.ts
CHANGED
|
@@ -8,6 +8,7 @@ import * as Effect from 'effect/Effect';
|
|
|
8
8
|
import * as Function from 'effect/Function';
|
|
9
9
|
import { afterEach, beforeEach, describe, it } from 'vitest';
|
|
10
10
|
|
|
11
|
+
import { runAndForwardErrors } from '@dxos/effect';
|
|
11
12
|
import { invariant } from '@dxos/invariant';
|
|
12
13
|
|
|
13
14
|
import { HttpConfig, withLogging, withRetry, withRetryConfig } from './http-client';
|
|
@@ -36,7 +37,7 @@ describe('HttpClient', () => {
|
|
|
36
37
|
withRetry(HttpClient.get(server.url)),
|
|
37
38
|
Effect.provide(FetchHttpClient.layer),
|
|
38
39
|
Effect.withSpan('EdgeHttpClient'),
|
|
39
|
-
|
|
40
|
+
runAndForwardErrors,
|
|
40
41
|
);
|
|
41
42
|
expect(result).toMatchObject({ success: true, data: { value: 100 } });
|
|
42
43
|
}
|
|
@@ -49,7 +50,7 @@ describe('HttpClient', () => {
|
|
|
49
50
|
Effect.provide(FetchHttpClient.layer),
|
|
50
51
|
Effect.provide(HttpConfig.default), // TODO(burdon): Swap out to mock.
|
|
51
52
|
Effect.withSpan('EdgeHttpClient'), // TODO(burdon): OTEL.
|
|
52
|
-
|
|
53
|
+
runAndForwardErrors,
|
|
53
54
|
);
|
|
54
55
|
expect(result).toMatchObject({ success: true, data: { value: 100 } });
|
|
55
56
|
}
|
package/src/http-client.ts
CHANGED
|
@@ -61,7 +61,11 @@ export const withRetryConfig = (
|
|
|
61
61
|
});
|
|
62
62
|
|
|
63
63
|
export const withLogging = <A extends HttpClientResponse.HttpClientResponse, E, R>(effect: Effect.Effect<A, E, R>) =>
|
|
64
|
-
effect.pipe(
|
|
64
|
+
effect.pipe(
|
|
65
|
+
Effect.tap((res) => {
|
|
66
|
+
log.info('response', { status: res.status });
|
|
67
|
+
}),
|
|
68
|
+
);
|
|
65
69
|
|
|
66
70
|
/**
|
|
67
71
|
*
|
|
@@ -16,13 +16,13 @@ import { toUint8Array } from '../protocol';
|
|
|
16
16
|
|
|
17
17
|
export const DEFAULT_PORT = 8080;
|
|
18
18
|
|
|
19
|
-
type
|
|
19
|
+
type TestEdgeWsServerProps = {
|
|
20
20
|
admitConnection?: Trigger;
|
|
21
21
|
payloadDecoder?: (payload: Uint8Array) => any;
|
|
22
22
|
messageHandler?: (payload: any) => Promise<Uint8Array | undefined>;
|
|
23
23
|
};
|
|
24
24
|
|
|
25
|
-
export const createTestEdgeWsServer = async (port = DEFAULT_PORT, params?:
|
|
25
|
+
export const createTestEdgeWsServer = async (port = DEFAULT_PORT, params?: TestEdgeWsServerProps) => {
|
|
26
26
|
const wsServer = new WebSocket.Server({
|
|
27
27
|
port,
|
|
28
28
|
verifyClient: createConnectionDelayHandler(params),
|
|
@@ -86,7 +86,7 @@ export const createTestEdgeWsServer = async (port = DEFAULT_PORT, params?: TestE
|
|
|
86
86
|
};
|
|
87
87
|
};
|
|
88
88
|
|
|
89
|
-
const createConnectionDelayHandler = (params:
|
|
89
|
+
const createConnectionDelayHandler = (params: TestEdgeWsServerProps | undefined) => {
|
|
90
90
|
return (_: any, callback: (admit: boolean) => void) => {
|
|
91
91
|
if (params?.admitConnection) {
|
|
92
92
|
log('delaying edge connection admission');
|
|
@@ -116,7 +116,7 @@ const createResponseSender = (connection: () => WebSocketMuxer) => {
|
|
|
116
116
|
};
|
|
117
117
|
};
|
|
118
118
|
|
|
119
|
-
const decodePayload = async (request: Message, params:
|
|
119
|
+
const decodePayload = async (request: Message, params: TestEdgeWsServerProps | undefined) => {
|
|
120
120
|
const requestPayload = params?.payloadDecoder
|
|
121
121
|
? params.payloadDecoder(request.payload!.value!)
|
|
122
122
|
: protocol.getPayload(request, TextMessageSchema);
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/index.ts", "../../../src/auth.ts", "../../../src/edge-client.ts", "../../../src/edge-identity.ts", "../../../src/edge-ws-connection.ts", "../../../src/errors.ts", "../../../src/utils.ts", "../../../src/edge-http-client.ts", "../../../src/http-client.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2024 DXOS.org\n//\n\nexport * from '@dxos/protocols/buf/dxos/edge/messenger_pb';\n\nexport * from './auth';\nexport * from './defs';\nexport * from './edge-client';\nexport * from './errors';\nexport * from './protocol';\nexport * from './edge-http-client';\nexport * from './edge-identity';\nexport * from './edge-ws-muxer';\nexport * from './http-client';\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport { createCredential, signPresentation } from '@dxos/credentials';\nimport { type Signer } from '@dxos/crypto';\nimport { invariant } from '@dxos/invariant';\nimport { Keyring } from '@dxos/keyring';\nimport { PublicKey } from '@dxos/keys';\nimport { type Chain, type Credential } from '@dxos/protocols/proto/dxos/halo/credentials';\n\nimport type { EdgeIdentity } from './edge-identity';\n\n/**\n * Edge identity backed by a device key without a credential chain.\n */\nexport const createDeviceEdgeIdentity = async (signer: Signer, key: PublicKey): Promise<EdgeIdentity> => {\n return {\n identityKey: key.toHex(),\n peerKey: key.toHex(),\n presentCredentials: async ({ challenge }) => {\n return signPresentation({\n presentation: {\n credentials: [\n // Verifier requires at least one credential in the presentation to establish the subject.\n await createCredential({\n assertion: {\n '@type': 'dxos.halo.credentials.Auth',\n },\n issuer: key,\n subject: key,\n signer,\n }),\n ],\n },\n signer,\n signerKey: key,\n nonce: challenge,\n });\n },\n };\n};\n\n/**\n * Edge identity backed by a chain of credentials.\n */\nexport const createChainEdgeIdentity = async (\n signer: Signer,\n identityKey: PublicKey,\n peerKey: PublicKey,\n chain: Chain | undefined,\n credentials: Credential[],\n): Promise<EdgeIdentity> => {\n const credentialsToSign =\n credentials.length > 0\n ? credentials\n : [\n await createCredential({\n assertion: {\n '@type': 'dxos.halo.credentials.Auth',\n },\n issuer: identityKey,\n subject: identityKey,\n signer,\n chain,\n signingKey: peerKey,\n }),\n ];\n\n return {\n identityKey: identityKey.toHex(),\n peerKey: peerKey.toHex(),\n presentCredentials: async ({ challenge }) => {\n // TODO: make chain required after device invitation flow update release\n invariant(chain);\n return signPresentation({\n presentation: {\n credentials: credentialsToSign,\n },\n signer,\n nonce: challenge,\n signerKey: peerKey,\n chain,\n });\n },\n };\n};\n\n/**\n * Edge identity backed by a random ephemeral key without HALO.\n */\nexport const createEphemeralEdgeIdentity = async (): Promise<EdgeIdentity> => {\n const keyring = new Keyring();\n const key = await keyring.createKey();\n return createDeviceEdgeIdentity(keyring, key);\n};\n\n/**\n * Creates a HALO chain of credentials to act as an edge identity.\n */\nexport const createTestHaloEdgeIdentity = async (\n signer: Signer,\n identityKey: PublicKey,\n deviceKey: PublicKey,\n): Promise<EdgeIdentity> => {\n const deviceAdmission = await createCredential({\n assertion: {\n '@type': 'dxos.halo.credentials.AuthorizedDevice',\n deviceKey,\n identityKey,\n },\n issuer: identityKey,\n subject: deviceKey,\n signer,\n });\n return createChainEdgeIdentity(signer, identityKey, deviceKey, { credential: deviceAdmission }, [\n await createCredential({\n assertion: {\n '@type': 'dxos.halo.credentials.Auth',\n },\n issuer: identityKey,\n subject: identityKey,\n signer,\n }),\n ]);\n};\n\nexport const createStubEdgeIdentity = (): EdgeIdentity => {\n const identityKey = PublicKey.random();\n const deviceKey = PublicKey.random();\n return {\n identityKey: identityKey.toHex(),\n peerKey: deviceKey.toHex(),\n presentCredentials: async () => {\n throw new Error('Stub identity does not support authentication.');\n },\n };\n};\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport {\n Event,\n PersistentLifecycle,\n Trigger,\n TriggerState,\n scheduleMicroTask,\n scheduleTaskInterval,\n} from '@dxos/async';\nimport { type Lifecycle, Resource } from '@dxos/context';\nimport { log, logInfo } from '@dxos/log';\nimport { type Message } from '@dxos/protocols/buf/dxos/edge/messenger_pb';\nimport { EdgeStatus } from '@dxos/protocols/proto/dxos/client/services';\n\nimport { protocol } from './defs';\nimport { type EdgeIdentity, handleAuthChallenge } from './edge-identity';\nimport { EdgeWsConnection } from './edge-ws-connection';\nimport { EdgeConnectionClosedError, EdgeIdentityChangedError } from './errors';\nimport { type Protocol } from './protocol';\nimport { getEdgeUrlWithProtocol } from './utils';\n\nconst DEFAULT_TIMEOUT = 10_000;\n\n// Refresh status every second: rtt, rate counters.\nconst STATUS_REFRESH_INTERVAL = 1000;\n\nexport type MessageListener = (message: Message) => void;\nexport type ReconnectListener = () => void;\n\nexport type MessengerConfig = {\n socketEndpoint: string;\n timeout?: number;\n protocol?: Protocol;\n disableAuth?: boolean;\n};\n\nexport interface EdgeConnection extends Required<Lifecycle> {\n statusChanged: Event<EdgeStatus>;\n get info(): any;\n get identityKey(): string;\n get peerKey(): string;\n get isOpen(): boolean;\n get status(): EdgeStatus;\n setIdentity(identity: EdgeIdentity): void;\n send(message: Message): Promise<void>;\n onMessage(listener: MessageListener): () => void;\n onReconnected(listener: ReconnectListener): () => void;\n}\n\n/**\n * Messenger client for EDGE:\n * - While open, uses PersistentLifecycle to keep an open EdgeWsConnection, reconnecting on failures.\n * - Manages identity and re-create EdgeWsConnection when identity changes.\n * - Dispatches connection state and message notifications.\n */\nexport class EdgeClient extends Resource implements EdgeConnection {\n public readonly statusChanged = new Event<EdgeStatus>();\n\n private readonly _persistentLifecycle = new PersistentLifecycle<EdgeWsConnection>({\n start: async () => this._connect(),\n stop: async (state: EdgeWsConnection) => this._disconnect(state),\n });\n\n private readonly _messageListeners = new Set<MessageListener>();\n private readonly _reconnectListeners = new Set<ReconnectListener>();\n private readonly _baseWsUrl: string;\n private readonly _baseHttpUrl: string;\n private _currentConnection?: EdgeWsConnection = undefined;\n private _ready = new Trigger();\n\n constructor(\n private _identity: EdgeIdentity,\n private readonly _config: MessengerConfig,\n ) {\n super();\n this._baseWsUrl = getEdgeUrlWithProtocol(_config.socketEndpoint, 'ws');\n this._baseHttpUrl = getEdgeUrlWithProtocol(_config.socketEndpoint, 'http');\n }\n\n @logInfo\n public get info() {\n return {\n open: this.isOpen,\n status: this.status,\n identity: this._identity.identityKey,\n device: this._identity.peerKey,\n };\n }\n\n get status(): EdgeStatus {\n return {\n state:\n Boolean(this._currentConnection) && this._ready.state === TriggerState.RESOLVED\n ? EdgeStatus.ConnectionState.CONNECTED\n : EdgeStatus.ConnectionState.NOT_CONNECTED,\n uptime: this._currentConnection?.uptime ?? 0,\n rtt: this._currentConnection?.rtt ?? 0,\n rateBytesUp: this._currentConnection?.uploadRate ?? 0,\n rateBytesDown: this._currentConnection?.downloadRate ?? 0,\n messagesSent: this._currentConnection?.messagesSent ?? 0,\n messagesReceived: this._currentConnection?.messagesReceived ?? 0,\n };\n }\n\n get identityKey() {\n return this._identity.identityKey;\n }\n\n get peerKey() {\n return this._identity.peerKey;\n }\n\n setIdentity(identity: EdgeIdentity) {\n if (identity.identityKey !== this._identity.identityKey || identity.peerKey !== this._identity.peerKey) {\n log('Edge identity changed', { identity, oldIdentity: this._identity });\n this._identity = identity;\n this._closeCurrentConnection(new EdgeIdentityChangedError());\n void this._persistentLifecycle.scheduleRestart();\n }\n }\n\n /**\n * Send message.\n * NOTE: The message is guaranteed to be delivered but the service must respond with a message to confirm processing.\n */\n public async send(message: Message) {\n if (this._ready.state !== TriggerState.RESOLVED) {\n log('waiting for websocket');\n await this._ready.wait({ timeout: this._config.timeout ?? DEFAULT_TIMEOUT });\n }\n\n if (!this._currentConnection) {\n throw new EdgeConnectionClosedError();\n }\n\n if (\n message.source &&\n (message.source.peerKey !== this._identity.peerKey || message.source.identityKey !== this.identityKey)\n ) {\n throw new EdgeIdentityChangedError();\n }\n\n this._currentConnection.send(message);\n }\n\n public onMessage(listener: MessageListener) {\n this._messageListeners.add(listener);\n return () => this._messageListeners.delete(listener);\n }\n\n public onReconnected(listener: () => void) {\n this._reconnectListeners.add(listener);\n if (this._ready.state === TriggerState.RESOLVED) {\n // Microtask so that listener is always called asynchronously, no matter the state of the ready trigger\n // at the moment of registration.\n scheduleMicroTask(this._ctx, () => {\n if (this._reconnectListeners.has(listener)) {\n try {\n listener();\n } catch (error) {\n log.catch(error);\n }\n }\n });\n }\n\n return () => this._reconnectListeners.delete(listener);\n }\n\n /**\n * Open connection to messaging service.\n */\n protected override async _open(): Promise<void> {\n log('opening...', { info: this.info });\n this._persistentLifecycle.open().catch((err) => {\n log.warn('Error while opening connection', { err });\n });\n\n // Notify about status changes (rtt, rate counters).\n scheduleTaskInterval(\n this._ctx,\n async () => {\n if (!this._currentConnection) {\n return;\n }\n this.statusChanged.emit(this.status);\n },\n STATUS_REFRESH_INTERVAL,\n );\n }\n\n /**\n * Close connection and free resources.\n */\n protected override async _close(): Promise<void> {\n log('closing...', { peerKey: this._identity.peerKey });\n this._closeCurrentConnection();\n await this._persistentLifecycle.close();\n }\n\n private async _connect(): Promise<EdgeWsConnection | undefined> {\n if (this._ctx.disposed) {\n return undefined;\n }\n\n const identity = this._identity;\n const path = `/ws/${identity.identityKey}/${identity.peerKey}`;\n const protocolHeader = this._config.disableAuth ? undefined : await this._createAuthHeader(path);\n if (this._identity !== identity) {\n log('identity changed during auth header request');\n return undefined;\n }\n\n const restartRequired = new Trigger();\n const url = new URL(path, this._baseWsUrl);\n log('Opening websocket', { url: url.toString(), protocolHeader });\n const connection = new EdgeWsConnection(\n identity,\n { url, protocolHeader },\n {\n onConnected: () => {\n if (this._isActive(connection)) {\n this._ready.wake();\n this._notifyReconnected();\n } else {\n log.verbose('connected callback ignored, because connection is not active');\n }\n },\n onRestartRequired: () => {\n if (this._isActive(connection)) {\n this._closeCurrentConnection();\n void this._persistentLifecycle.scheduleRestart();\n } else {\n log.verbose('restart requested by inactive connection');\n }\n restartRequired.wake();\n },\n onMessage: (message) => {\n if (this._isActive(connection)) {\n this._notifyMessageReceived(message);\n } else {\n log.verbose('ignored a message on inactive connection', {\n from: message.source,\n type: message.payload?.typeUrl,\n });\n }\n },\n },\n );\n this._currentConnection = connection;\n\n await connection.open();\n // Race with restartRequired so that restart is not blocked by _connect execution.\n // Wait on ready to attempt a reconnect if it times out.\n await Promise.race([this._ready.wait({ timeout: this._config.timeout ?? DEFAULT_TIMEOUT }), restartRequired]);\n return connection;\n }\n\n private async _disconnect(state: EdgeWsConnection): Promise<void> {\n await state.close();\n this.statusChanged.emit(this.status);\n }\n\n private _closeCurrentConnection(error: Error = new EdgeConnectionClosedError()): void {\n this._currentConnection = undefined;\n this._ready.throw(error);\n this._ready.reset();\n this.statusChanged.emit(this.status);\n }\n\n private _notifyReconnected(): void {\n this.statusChanged.emit(this.status);\n for (const listener of this._reconnectListeners) {\n try {\n listener();\n } catch (err) {\n log.error('ws reconnect listener failed', { err });\n }\n }\n }\n\n private _notifyMessageReceived(message: Message): void {\n for (const listener of this._messageListeners) {\n try {\n listener(message);\n } catch (err) {\n log.error('ws incoming message processing failed', { err, payload: protocol.getPayloadType(message) });\n }\n }\n }\n\n private async _createAuthHeader(path: string): Promise<string | undefined> {\n const httpUrl = new URL(path, this._baseHttpUrl);\n httpUrl.protocol = getEdgeUrlWithProtocol(this._baseWsUrl.toString(), 'http');\n const response = await fetch(httpUrl, { method: 'GET' });\n if (response.status === 401) {\n return encodePresentationWsAuthHeader(await handleAuthChallenge(response, this._identity));\n } else {\n log.warn('no auth challenge from edge', { status: response.status, statusText: response.statusText });\n return undefined;\n }\n }\n\n private _isActive = (connection: EdgeWsConnection) => connection === this._currentConnection;\n}\n\nconst encodePresentationWsAuthHeader = (encodedPresentation: Uint8Array): string => {\n // '=' and '/' characters are not allowed in the WebSocket subprotocol header.\n const encodedToken = Buffer.from(encodedPresentation).toString('base64').replace(/=*$/, '').replaceAll('/', '|');\n return `base64url.bearer.authorization.dxos.org.${encodedToken}`;\n};\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport { invariant } from '@dxos/invariant';\nimport { schema } from '@dxos/protocols/proto';\nimport { type Presentation } from '@dxos/protocols/proto/dxos/halo/credentials';\n\nexport interface EdgeIdentity {\n peerKey: string;\n identityKey: string;\n /**\n * Returns credential presentation issued by the identity key.\n * Presentation must have the provided challenge.\n * Presentation may include ServiceAccess credentials.\n */\n presentCredentials({ challenge }: { challenge: Uint8Array }): Promise<Presentation>;\n}\n\nexport const handleAuthChallenge = async (failedResponse: Response, identity: EdgeIdentity): Promise<Uint8Array> => {\n invariant(failedResponse.status === 401);\n\n const headerValue = failedResponse.headers.get('Www-Authenticate');\n invariant(headerValue?.startsWith('VerifiablePresentation challenge='));\n\n const challenge = headerValue?.slice('VerifiablePresentation challenge='.length);\n invariant(challenge);\n\n const presentation = await identity.presentCredentials({ challenge: Buffer.from(challenge, 'base64') });\n return schema.getCodecForType('dxos.halo.credentials.Presentation').encode(presentation);\n};\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport WebSocket from 'isomorphic-ws';\n\nimport { scheduleTask, scheduleTaskInterval } from '@dxos/async';\nimport { Context, Resource } from '@dxos/context';\nimport { invariant } from '@dxos/invariant';\nimport { log, logInfo } from '@dxos/log';\nimport { EdgeWebsocketProtocol } from '@dxos/protocols';\nimport { buf } from '@dxos/protocols/buf';\nimport { type Message, MessageSchema } from '@dxos/protocols/buf/dxos/edge/messenger_pb';\n\nimport { protocol } from './defs';\nimport { type EdgeIdentity } from './edge-identity';\nimport { CLOUDFLARE_MESSAGE_MAX_BYTES, WebSocketMuxer } from './edge-ws-muxer';\nimport { toUint8Array } from './protocol';\n\nconst SIGNAL_KEEPALIVE_INTERVAL = 4_000;\nconst SIGNAL_KEEPALIVE_TIMEOUT = 12_000;\n\nexport type EdgeWsConnectionCallbacks = {\n onConnected: () => void;\n onMessage: (message: Message) => void;\n onRestartRequired: () => void;\n};\n\nexport class EdgeWsConnection extends Resource {\n private _inactivityTimeoutCtx: Context | undefined;\n private _ws: WebSocket | undefined;\n private _wsMuxer: WebSocketMuxer | undefined;\n private _lastReceivedMessageTimestamp = Date.now();\n\n private _openTimestamp: number | undefined;\n\n // Latency tracking.\n private _pingTimestamp: number | undefined;\n private _rtt = 0;\n\n // Rate tracking with sliding window.\n private _uploadRate = 0;\n private _downloadRate = 0;\n private readonly _rateWindow = 10000; // 10 second sliding window.\n private readonly _rateUpdateInterval = 1000; // Update rates every second.\n private _bytesSamples: Array<{ timestamp: number; sent: number; received: number }> = [];\n\n private _messagesSent = 0;\n private _messagesReceived = 0;\n\n constructor(\n private readonly _identity: EdgeIdentity,\n private readonly _connectionInfo: { url: URL; protocolHeader?: string },\n private readonly _callbacks: EdgeWsConnectionCallbacks,\n ) {\n super();\n }\n\n @logInfo\n public get info() {\n return {\n open: this.isOpen,\n identity: this._identity.identityKey,\n device: this._identity.peerKey,\n };\n }\n\n public get rtt(): number {\n return this._rtt;\n }\n\n public get uptime(): number {\n return this._openTimestamp ? (Date.now() - this._openTimestamp) / 1000 : 0;\n }\n\n public get uploadRate(): number {\n return this._uploadRate;\n }\n\n public get downloadRate(): number {\n return this._downloadRate;\n }\n\n public get messagesSent(): number {\n return this._messagesSent;\n }\n\n public get messagesReceived(): number {\n return this._messagesReceived;\n }\n\n public send(message: Message): void {\n invariant(this._ws);\n invariant(this._wsMuxer);\n log('sending...', { peerKey: this._identity.peerKey, payload: protocol.getPayloadType(message) });\n this._messagesSent++;\n if (this._ws?.protocol.includes(EdgeWebsocketProtocol.V0)) {\n const binary = buf.toBinary(MessageSchema, message);\n if (binary.length > CLOUDFLARE_MESSAGE_MAX_BYTES) {\n log.error('Message dropped because it was too large (>1MB).', {\n byteLength: binary.byteLength,\n serviceId: message.serviceId,\n payload: protocol.getPayloadType(message),\n });\n return;\n }\n this._recordBytes(binary.byteLength, 0);\n this._ws.send(binary);\n } else {\n // For muxer, we need to track the size of the message being sent.\n const binary = buf.toBinary(MessageSchema, message);\n this._recordBytes(binary.byteLength, 0);\n this._wsMuxer.send(message).catch((e) => log.catch(e));\n }\n }\n\n protected override async _open(): Promise<void> {\n const baseProtocols = [...Object.values(EdgeWebsocketProtocol)];\n this._ws = new WebSocket(\n this._connectionInfo.url.toString(),\n this._connectionInfo.protocolHeader\n ? [...baseProtocols, this._connectionInfo.protocolHeader]\n : [...baseProtocols],\n );\n const muxer = new WebSocketMuxer(this._ws);\n this._wsMuxer = muxer;\n\n this._ws.onopen = () => {\n if (this.isOpen) {\n log('connected');\n this._openTimestamp = Date.now();\n this._callbacks.onConnected();\n this._scheduleHeartbeats();\n this._scheduleRateCalculation();\n } else {\n log.verbose('connected after becoming inactive', { currentIdentity: this._identity });\n }\n };\n this._ws.onclose = (event: WebSocket.CloseEvent) => {\n if (this.isOpen) {\n log.warn('server disconnected', { code: event.code, reason: event.reason });\n this._callbacks.onRestartRequired();\n muxer.destroy();\n }\n };\n this._ws.onerror = (event: WebSocket.ErrorEvent) => {\n if (this.isOpen) {\n log.warn('edge connection socket error', { error: event.error, info: event.message });\n this._callbacks.onRestartRequired();\n } else {\n log.verbose('error ignored on closed connection', { error: event.error });\n }\n };\n /**\n * https://developer.mozilla.org/en-US/docs/Web/API/MessageEvent/data\n */\n this._ws.onmessage = async (event: WebSocket.MessageEvent) => {\n if (!this.isOpen) {\n log.verbose('message ignored on closed connection', { event: event.type });\n return;\n }\n this._lastReceivedMessageTimestamp = Date.now();\n if (event.data === '__pong__') {\n // Calculate latency.\n if (this._pingTimestamp) {\n this._rtt = Date.now() - this._pingTimestamp;\n this._pingTimestamp = undefined;\n }\n this._rescheduleHeartbeatTimeout();\n return;\n }\n const bytes = await toUint8Array(event.data);\n this._recordBytes(0, bytes.byteLength);\n if (!this.isOpen) {\n return;\n }\n\n this._messagesReceived++;\n\n const message = this._ws?.protocol?.includes(EdgeWebsocketProtocol.V0)\n ? buf.fromBinary(MessageSchema, bytes)\n : muxer.receiveData(bytes);\n\n if (message) {\n log('received', { from: message.source, payload: protocol.getPayloadType(message) });\n this._callbacks.onMessage(message);\n }\n };\n }\n\n protected override async _close(): Promise<void> {\n void this._inactivityTimeoutCtx?.dispose().catch(() => {});\n\n try {\n this._ws?.close();\n this._ws = undefined;\n this._wsMuxer?.destroy();\n this._wsMuxer = undefined;\n } catch (err) {\n if (err instanceof Error && err.message.includes('WebSocket is closed before the connection is established.')) {\n return;\n }\n log.warn('error closing websocket', { err });\n }\n }\n\n private _scheduleHeartbeats(): void {\n invariant(this._ws);\n scheduleTaskInterval(\n this._ctx,\n async () => {\n // TODO(mykola): use RFC6455 ping/pong once implemented in the browser?\n // Cloudflare's worker responds to this `without interrupting hibernation`. https://developers.cloudflare.com/durable-objects/api/websockets/#setwebsocketautoresponse\n this._pingTimestamp = Date.now();\n this._ws?.send('__ping__');\n },\n SIGNAL_KEEPALIVE_INTERVAL,\n );\n this._pingTimestamp = Date.now();\n this._ws.send('__ping__');\n this._rescheduleHeartbeatTimeout();\n }\n\n private _rescheduleHeartbeatTimeout(): void {\n if (!this.isOpen) {\n return;\n }\n void this._inactivityTimeoutCtx?.dispose();\n this._inactivityTimeoutCtx = new Context();\n scheduleTask(\n this._inactivityTimeoutCtx,\n () => {\n if (this.isOpen) {\n if (Date.now() - this._lastReceivedMessageTimestamp > SIGNAL_KEEPALIVE_TIMEOUT) {\n log.warn('restart due to inactivity timeout', {\n lastReceivedMessageTimestamp: this._lastReceivedMessageTimestamp,\n });\n this._callbacks.onRestartRequired();\n } else {\n this._rescheduleHeartbeatTimeout();\n }\n }\n },\n SIGNAL_KEEPALIVE_TIMEOUT,\n );\n }\n\n private _recordBytes(sent: number, received: number): void {\n const now = Date.now();\n\n // Find if we have a sample for the current second.\n const currentSecond = Math.floor(now / 1000) * 1000;\n const existingSample = this._bytesSamples.find((s) => Math.floor(s.timestamp / 1000) * 1000 === currentSecond);\n\n if (existingSample) {\n existingSample.sent += sent;\n existingSample.received += received;\n } else {\n this._bytesSamples.push({ timestamp: now, sent, received });\n }\n }\n\n private _scheduleRateCalculation(): void {\n scheduleTaskInterval(\n this._ctx,\n async () => {\n this._calculateRates();\n },\n this._rateUpdateInterval,\n );\n // Calculate initial rates.\n this._calculateRates();\n }\n\n private _calculateRates(): void {\n const now = Date.now();\n const cutoff = now - this._rateWindow;\n\n // Remove old samples.\n this._bytesSamples = this._bytesSamples.filter((s) => s.timestamp > cutoff);\n\n if (this._bytesSamples.length === 0) {\n this._uploadRate = 0;\n this._downloadRate = 0;\n return;\n }\n\n // Calculate total bytes and time span.\n let totalSent = 0;\n let totalReceived = 0;\n const oldestTimestamp = Math.min(...this._bytesSamples.map((s) => s.timestamp));\n const timeSpan = (now - oldestTimestamp) / 1000; // Convert to seconds.\n\n for (const sample of this._bytesSamples) {\n totalSent += sample.sent;\n totalReceived += sample.received;\n }\n\n // Calculate rates (bytes per second).\n this._uploadRate = timeSpan > 0 ? Math.round(totalSent / timeSpan) : 0;\n this._downloadRate = timeSpan > 0 ? Math.round(totalReceived / timeSpan) : 0;\n }\n}\n", "//\n// Copyright 2024 DXOS.org\n//\n\nexport class EdgeConnectionClosedError extends Error {\n constructor() {\n super('Edge connection closed.');\n }\n}\n\nexport class EdgeIdentityChangedError extends Error {\n constructor() {\n super('Edge identity changed.');\n }\n}\n", "//\n// Copyright 2024 DXOS.org\n//\n\nexport const getEdgeUrlWithProtocol = (baseUrl: string, protocol: 'http' | 'ws') => {\n const isSecure = baseUrl.startsWith('https') || baseUrl.startsWith('wss');\n const url = new URL(baseUrl);\n url.protocol = protocol + (isSecure ? 's' : '');\n return url.toString();\n};\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport * as FetchHttpClient from '@effect/platform/FetchHttpClient';\nimport * as HttpClient from '@effect/platform/HttpClient';\nimport * as Effect from 'effect/Effect';\nimport * as Function from 'effect/Function';\n\nimport { sleep } from '@dxos/async';\nimport { Context } from '@dxos/context';\nimport { type PublicKey, type SpaceId } from '@dxos/keys';\nimport { log } from '@dxos/log';\nimport {\n type CreateAgentRequestBody,\n type CreateAgentResponseBody,\n type CreateSpaceRequest,\n type CreateSpaceResponseBody,\n EdgeAuthChallengeError,\n EdgeCallFailedError,\n type EdgeHttpResponse,\n type EdgeStatus,\n type ExecuteWorkflowResponseBody,\n type ExportBundleRequest,\n type ExportBundleResponse,\n type GetAgentStatusResponseBody,\n type GetNotarizationResponseBody,\n type ImportBundleRequest,\n type InitiateOAuthFlowRequest,\n type InitiateOAuthFlowResponse,\n type JoinSpaceRequest,\n type JoinSpaceResponseBody,\n type ObjectId,\n type PostNotarizationRequestBody,\n type QueryResult,\n type QueueQuery,\n type RecoverIdentityRequest,\n type RecoverIdentityResponseBody,\n type UploadFunctionRequest,\n type UploadFunctionResponseBody,\n} from '@dxos/protocols';\nimport { createUrl } from '@dxos/util';\n\nimport { type EdgeIdentity, handleAuthChallenge } from './edge-identity';\nimport { HttpConfig, encodeAuthHeader, withLogging, withRetryConfig } from './http-client';\nimport { getEdgeUrlWithProtocol } from './utils';\n\nconst DEFAULT_RETRY_TIMEOUT = 1500;\nconst DEFAULT_RETRY_JITTER = 500;\nconst DEFAULT_MAX_RETRIES_COUNT = 3;\nconst WARNING_BODY_SIZE = 10 * 1024 * 1024; // 10MB\n\nexport type RetryConfig = {\n /**\n * A number of call retries, not counting the initial request.\n */\n count: number;\n /**\n * Delay before retries in ms.\n */\n timeout?: number;\n /**\n * A random amount of time before retrying to help prevent large bursts of requests.\n */\n jitter?: number;\n};\n\ntype EdgeHttpRequestArgs = {\n method: string;\n context?: Context;\n retry?: RetryConfig;\n body?: any;\n /**\n * @default true\n */\n json?: boolean;\n\n /**\n * Do not expect a standard EDGE JSON response with a `success` field.\n */\n rawResponse?: boolean;\n};\n\nexport type EdgeHttpGetArgs = Pick<EdgeHttpRequestArgs, 'context' | 'retry'>;\nexport type EdgeHttpPostArgs = Pick<EdgeHttpRequestArgs, 'context' | 'retry' | 'body'>;\n\nexport class EdgeHttpClient {\n private readonly _baseUrl: string;\n\n private _edgeIdentity: EdgeIdentity | undefined;\n\n /**\n * Auth header is cached until receiving the next 401 from EDGE, at which point it gets refreshed.\n */\n private _authHeader: string | undefined;\n\n constructor(baseUrl: string) {\n this._baseUrl = getEdgeUrlWithProtocol(baseUrl, 'http');\n log('created', { url: this._baseUrl });\n }\n\n get baseUrl() {\n return this._baseUrl;\n }\n\n setIdentity(identity: EdgeIdentity): void {\n if (this._edgeIdentity?.identityKey !== identity.identityKey || this._edgeIdentity?.peerKey !== identity.peerKey) {\n this._edgeIdentity = identity;\n this._authHeader = undefined;\n }\n }\n\n //\n // Status\n //\n\n public async getStatus(args?: EdgeHttpGetArgs): Promise<EdgeStatus> {\n return this._call(new URL('/status', this.baseUrl), { ...args, method: 'GET' });\n }\n\n //\n // Agents\n //\n\n public createAgent(body: CreateAgentRequestBody, args?: EdgeHttpGetArgs): Promise<CreateAgentResponseBody> {\n return this._call(new URL('/agents/create', this.baseUrl), { ...args, method: 'POST', body });\n }\n\n public getAgentStatus(\n request: { ownerIdentityKey: PublicKey },\n args?: EdgeHttpGetArgs,\n ): Promise<GetAgentStatusResponseBody> {\n return this._call(new URL(`/users/${request.ownerIdentityKey.toHex()}/agent/status`, this.baseUrl), {\n ...args,\n method: 'GET',\n });\n }\n\n //\n // Credentials\n //\n\n public getCredentialsForNotarization(spaceId: SpaceId, args?: EdgeHttpGetArgs): Promise<GetNotarizationResponseBody> {\n return this._call(new URL(`/spaces/${spaceId}/notarization`, this.baseUrl), { ...args, method: 'GET' });\n }\n\n public async notarizeCredentials(\n spaceId: SpaceId,\n body: PostNotarizationRequestBody,\n args?: EdgeHttpGetArgs,\n ): Promise<void> {\n await this._call(new URL(`/spaces/${spaceId}/notarization`, this.baseUrl), { ...args, body, method: 'POST' });\n }\n\n //\n // Identity\n //\n\n public async recoverIdentity(\n body: RecoverIdentityRequest,\n args?: EdgeHttpGetArgs,\n ): Promise<RecoverIdentityResponseBody> {\n return this._call(new URL('/identity/recover', this.baseUrl), { ...args, body, method: 'POST' });\n }\n\n //\n // Invitations\n //\n\n public async joinSpaceByInvitation(\n spaceId: SpaceId,\n body: JoinSpaceRequest,\n args?: EdgeHttpGetArgs,\n ): Promise<JoinSpaceResponseBody> {\n return this._call(new URL(`/spaces/${spaceId}/join`, this.baseUrl), { ...args, body, method: 'POST' });\n }\n\n //\n // OAuth and credentials\n //\n\n public async initiateOAuthFlow(\n body: InitiateOAuthFlowRequest,\n args?: EdgeHttpGetArgs,\n ): Promise<InitiateOAuthFlowResponse> {\n return this._call(new URL('/oauth/initiate', this.baseUrl), { ...args, body, method: 'POST' });\n }\n\n //\n // Spaces\n //\n\n async createSpace(body: CreateSpaceRequest, args?: EdgeHttpGetArgs): Promise<CreateSpaceResponseBody> {\n return this._call(new URL('/spaces/create', this.baseUrl), { ...args, body, method: 'POST' });\n }\n\n //\n // Queues\n //\n\n public async queryQueue(\n subspaceTag: string,\n spaceId: SpaceId,\n query: QueueQuery,\n args?: EdgeHttpGetArgs,\n ): Promise<QueryResult> {\n const { queueId } = query;\n return this._call(\n createUrl(new URL(`/spaces/${subspaceTag}/${spaceId}/queue/${queueId}/query`, this.baseUrl), {\n after: query.after,\n before: query.before,\n limit: query.limit,\n reverse: query.reverse,\n objectIds: query.objectIds?.join(','),\n }),\n {\n ...args,\n method: 'GET',\n },\n );\n }\n\n public async insertIntoQueue(\n subspaceTag: string,\n spaceId: SpaceId,\n queueId: ObjectId,\n objects: unknown[],\n args?: EdgeHttpGetArgs,\n ): Promise<void> {\n return this._call(new URL(`/spaces/${subspaceTag}/${spaceId}/queue/${queueId}`, this.baseUrl), {\n ...args,\n body: { objects },\n method: 'POST',\n });\n }\n\n public async deleteFromQueue(\n subspaceTag: string,\n spaceId: SpaceId,\n queueId: ObjectId,\n objectIds: ObjectId[],\n args?: EdgeHttpGetArgs,\n ): Promise<void> {\n return this._call(\n createUrl(new URL(`/spaces/${subspaceTag}/${spaceId}/queue/${queueId}`, this.baseUrl), {\n ids: objectIds.join(','),\n }),\n {\n ...args,\n method: 'DELETE',\n },\n );\n }\n\n //\n // Functions\n //\n\n public async uploadFunction(\n pathParts: { functionId?: string },\n body: UploadFunctionRequest,\n args?: EdgeHttpGetArgs,\n ): Promise<UploadFunctionResponseBody> {\n const formData = new FormData();\n formData.append('name', body.name ?? '');\n formData.append('version', body.version);\n formData.append('ownerPublicKey', body.ownerPublicKey);\n formData.append('entryPoint', body.entryPoint);\n for (const [filename, content] of Object.entries(body.assets)) {\n formData.append(\n 'assets',\n new Blob([content as Uint8Array<ArrayBuffer>], { type: getFileMimeType(filename) }),\n filename,\n );\n }\n\n const path = ['functions', ...(pathParts.functionId ? [pathParts.functionId] : [])].join('/');\n return this._call(new URL(path, this.baseUrl), {\n ...args,\n body: formData,\n method: 'PUT',\n json: false,\n });\n }\n\n public async listFunctions(args?: EdgeHttpGetArgs): Promise<any> {\n return this._call(new URL('/functions', this.baseUrl), { ...args, method: 'GET' });\n }\n\n public async invokeFunction(\n params: {\n functionId: string;\n version?: string;\n spaceId?: SpaceId;\n cpuTimeLimit?: number;\n subrequestsLimit?: number;\n },\n input: unknown,\n args?: EdgeHttpGetArgs,\n ): Promise<any> {\n const url = new URL(`/functions/${params.functionId}`, this.baseUrl);\n if (params.version) {\n url.searchParams.set('version', params.version);\n }\n if (params.spaceId) {\n url.searchParams.set('spaceId', params.spaceId.toString());\n }\n if (params.cpuTimeLimit) {\n url.searchParams.set('cpuTimeLimit', params.cpuTimeLimit.toString());\n }\n if (params.subrequestsLimit) {\n url.searchParams.set('subrequestsLimit', params.subrequestsLimit.toString());\n }\n\n return this._call(url, {\n ...args,\n body: input,\n method: 'POST',\n rawResponse: true,\n });\n }\n\n //\n // Workflows\n //\n\n public async executeWorkflow(\n spaceId: SpaceId,\n graphId: ObjectId,\n input: any,\n args?: EdgeHttpGetArgs,\n ): Promise<ExecuteWorkflowResponseBody> {\n return this._call(new URL(`/workflows/${spaceId}/${graphId}`, this.baseUrl), {\n ...args,\n body: input,\n method: 'POST',\n });\n }\n\n //\n // Triggers\n //\n\n public async getCronTriggers(spaceId: SpaceId) {\n return this._call(new URL(`/test/functions/${spaceId}/triggers/crons`, this.baseUrl), { method: 'GET' });\n }\n\n //\n // Import/Export space.\n //\n\n public async importBundle(\n spaceId: SpaceId, //\n body: ImportBundleRequest,\n args?: EdgeHttpGetArgs,\n ): Promise<void> {\n return this._call(new URL(`/spaces/${spaceId}/import`, this.baseUrl), { ...args, body, method: 'PUT' });\n }\n\n public async exportBundle(\n spaceId: SpaceId,\n body: ExportBundleRequest,\n args?: EdgeHttpGetArgs,\n ): Promise<ExportBundleResponse> {\n return this._call(new URL(`/spaces/${spaceId}/export`, this.baseUrl), {\n ...args,\n body,\n method: 'POST',\n });\n }\n\n //\n // Internal\n //\n\n private async _fetch<T>(url: URL, args: EdgeHttpRequestArgs): Promise<T> {\n return Function.pipe(\n HttpClient.get(url),\n withLogging,\n withRetryConfig,\n Effect.provide(FetchHttpClient.layer),\n Effect.provide(HttpConfig.default),\n Effect.withSpan('EdgeHttpClient'),\n Effect.runPromise,\n ) as T;\n }\n\n // TODO(burdon): Refactor with effect (see edge-http-client.test.ts).\n private async _call<T>(url: URL, args: EdgeHttpRequestArgs): Promise<T> {\n const shouldRetry = createRetryHandler(args);\n const requestContext = args.context ?? new Context();\n log('fetch', { url, request: args.body });\n\n let handledAuth = false;\n while (true) {\n let processingError: EdgeCallFailedError | undefined = undefined;\n let retryAfterHeaderValue: number = Number.NaN;\n try {\n const request = createRequest(args, this._authHeader);\n const response = await fetch(url, request);\n retryAfterHeaderValue = Number(response.headers.get('Retry-After'));\n if (response.ok) {\n const body = (await response.json()) as EdgeHttpResponse<T>;\n\n if (args.rawResponse) {\n return body as any;\n }\n\n if (!('success' in body)) {\n return body;\n }\n\n if (body.success) {\n return body.data;\n }\n\n log.warn('unsuccessful edge response', { url, body });\n if (body.errorData?.type === 'auth_challenge' && typeof body.errorData?.challenge === 'string') {\n processingError = new EdgeAuthChallengeError(body.errorData.challenge, body.errorData);\n } else if (body.errorData) {\n processingError = EdgeCallFailedError.fromUnsuccessfulResponse(response, body);\n }\n } else if (response.status === 401 && !handledAuth) {\n this._authHeader = await this._handleUnauthorized(response);\n handledAuth = true;\n continue;\n } else {\n processingError = await EdgeCallFailedError.fromHttpFailure(response);\n }\n } catch (error: any) {\n processingError = EdgeCallFailedError.fromProcessingFailureCause(error);\n }\n\n if (processingError?.isRetryable && (await shouldRetry(requestContext, retryAfterHeaderValue))) {\n log('retrying edge request', { url, processingError });\n } else {\n throw processingError!;\n }\n }\n }\n\n private async _handleUnauthorized(response: Response): Promise<string> {\n if (!this._edgeIdentity) {\n log.warn('unauthorized response received before identity was set');\n throw await EdgeCallFailedError.fromHttpFailure(response);\n }\n\n const challenge = await handleAuthChallenge(response, this._edgeIdentity);\n return encodeAuthHeader(challenge);\n }\n}\n\nconst createRequest = (\n { method, body, json = true }: EdgeHttpRequestArgs,\n authHeader: string | undefined,\n): RequestInit => {\n let requestBody: BodyInit | undefined;\n const headers: HeadersInit = {};\n\n if (json) {\n requestBody = body && JSON.stringify(body);\n headers['Content-Type'] = 'application/json';\n } else {\n requestBody = body;\n }\n\n if (typeof requestBody === 'string' && requestBody.length > WARNING_BODY_SIZE) {\n log.warn('Request with large body', { bodySize: requestBody.length });\n }\n\n if (authHeader) {\n headers['Authorization'] = authHeader;\n }\n\n return {\n method,\n body: requestBody,\n headers,\n };\n};\n\n/**\n * @deprecated\n */\nconst createRetryHandler = ({ retry }: EdgeHttpRequestArgs) => {\n if (!retry || retry.count < 1) {\n return async () => false;\n }\n\n let retries = 0;\n const maxRetries = retry.count ?? DEFAULT_MAX_RETRIES_COUNT;\n const baseTimeout = retry.timeout ?? DEFAULT_RETRY_TIMEOUT;\n const jitter = retry.jitter ?? DEFAULT_RETRY_JITTER;\n return async (ctx: Context, retryAfter: number) => {\n if (++retries > maxRetries || ctx.disposed) {\n return false;\n }\n\n if (retryAfter) {\n await sleep(retryAfter);\n } else {\n const timeout = baseTimeout + Math.random() * jitter;\n await sleep(timeout);\n }\n\n return true;\n };\n};\n\nconst getFileMimeType = (filename: string) =>\n ['.js', '.mjs'].some((codeExtension) => filename.endsWith(codeExtension))\n ? 'application/javascript+module'\n : filename.endsWith('.wasm')\n ? 'application/wasm'\n : 'application/octet-stream';\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport type * as HttpClient from '@effect/platform/HttpClient';\nimport type * as HttpClientError from '@effect/platform/HttpClientError';\nimport type * as HttpClientResponse from '@effect/platform/HttpClientResponse';\nimport * as Context from 'effect/Context';\nimport * as Duration from 'effect/Duration';\nimport * as Effect from 'effect/Effect';\nimport * as Layer from 'effect/Layer';\nimport * as Schedule from 'effect/Schedule';\n\nimport { log } from '@dxos/log';\n\n// TODO(burdon): Factor out.\n\nexport type RetryOptions = {\n timeout: Duration.Duration;\n retryTimes: number;\n retryBaseDelay: Duration.Duration;\n};\n\n// Layer pattern.\nexport class HttpConfig extends Context.Tag('HttpConfig')<HttpConfig, RetryOptions>() {\n static default = Layer.succeed(HttpConfig, {\n timeout: Duration.millis(1_000),\n retryTimes: 3,\n retryBaseDelay: Duration.millis(1_000),\n });\n}\n\n// HOC pattern.\nexport const withRetry = (\n effect: Effect.Effect<HttpClientResponse.HttpClientResponse, HttpClientError.HttpClientError, HttpClient.HttpClient>,\n {\n timeout = Duration.millis(1_000),\n retryBaseDelay = Duration.millis(1_000),\n retryTimes = 3,\n }: Partial<RetryOptions> = {},\n) => {\n return effect.pipe(\n Effect.flatMap((res) =>\n // Treat 500 errors as retryable?\n res.status === 500 ? Effect.fail(new Error(res.status.toString())) : res.json,\n ),\n Effect.timeout(timeout),\n Effect.retry({\n schedule: Schedule.exponential(retryBaseDelay).pipe(Schedule.jittered),\n times: retryTimes,\n }),\n );\n};\n\nexport const withRetryConfig = (\n effect: Effect.Effect<HttpClientResponse.HttpClientResponse, HttpClientError.HttpClientError, HttpClient.HttpClient>,\n) =>\n Effect.gen(function* () {\n const config = yield* HttpConfig;\n return yield* withRetry(effect, config);\n });\n\nexport const withLogging = <A extends HttpClientResponse.HttpClientResponse, E, R>(effect: Effect.Effect<A, E, R>) =>\n effect.pipe(Effect.tap((res) => log.info('response', { status: res.status })));\n\n/**\n *\n */\n// TODO(burdon): Document.\nexport const encodeAuthHeader = (challenge: Uint8Array) => {\n const encodedChallenge = Buffer.from(challenge).toString('base64');\n return `VerifiablePresentation pb;base64,${encodedChallenge}`;\n};\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;AAIA,cAAc;;;ACAd,SAASA,kBAAkBC,wBAAwB;AAEnD,SAASC,iBAAiB;AAC1B,SAASC,eAAe;AACxB,SAASC,iBAAiB;;AAQnB,IAAMC,2BAA2B,OAAOC,QAAgBC,QAAAA;AAC7D,SAAO;IACLC,aAAaD,IAAIE,MAAK;IACtBC,SAASH,IAAIE,MAAK;IAClBE,oBAAoB,OAAO,EAAEC,UAAS,MAAE;AACtC,aAAOX,iBAAiB;QACtBY,cAAc;UACZC,aAAa;;YAEX,MAAMd,iBAAiB;cACrBe,WAAW;gBACT,SAAS;cACX;cACAC,QAAQT;cACRU,SAASV;cACTD;YACF,CAAA;;QAEJ;QACAA;QACAY,WAAWX;QACXY,OAAOP;MACT,CAAA;IACF;EACF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AU;AAC1C,aAAO;IACT;AAEA,QAAID,YAAY;AACd,YAAME,MAAMF,UAAAA;IACd,OAAO;AACL,YAAMH,WAAUD,cAAcO,KAAKC,OAAM,IAAKN;AAC9C,YAAMI,MAAML,QAAAA;IACd;AAEA,WAAO;EACT;AACF;AAEA,IAAM5E,kBAAkB,CAACP,aACvB;EAAC;EAAO;EAAQ2F,KAAK,CAACC,kBAAkB5F,SAAS6F,SAASD,aAAAA,CAAAA,IACtD,kCACA5F,SAAS6F,SAAS,OAAA,IAChB,qBACA;",
|
|
6
|
-
"names": ["createCredential", "signPresentation", "invariant", "Keyring", "PublicKey", "createDeviceEdgeIdentity", "signer", "key", "identityKey", "toHex", "peerKey", "presentCredentials", "challenge", "presentation", "credentials", "assertion", "issuer", "subject", "signerKey", "nonce", "createChainEdgeIdentity", "chain", "credentialsToSign", "length", "signingKey", "createEphemeralEdgeIdentity", "keyring", "createKey", "createTestHaloEdgeIdentity", "deviceKey", "deviceAdmission", "credential", "createStubEdgeIdentity", "random", "Error", "Event", "PersistentLifecycle", "Trigger", "TriggerState", "scheduleMicroTask", "scheduleTaskInterval", "Resource", "log", "logInfo", "EdgeStatus", "invariant", "schema", "handleAuthChallenge", "failedResponse", "identity", "status", "headerValue", "headers", "get", "startsWith", "challenge", "slice", "length", "presentation", "presentCredentials", "Buffer", "from", "getCodecForType", "encode", "WebSocket", "scheduleTask", "scheduleTaskInterval", "Context", "Resource", "invariant", "log", "logInfo", "EdgeWebsocketProtocol", "buf", "MessageSchema", "SIGNAL_KEEPALIVE_INTERVAL", "SIGNAL_KEEPALIVE_TIMEOUT", "EdgeWsConnection", "Resource", "info", "open", "isOpen", "identity", "_identity", "identityKey", "device", "peerKey", "rtt", "_rtt", "uptime", "_openTimestamp", "Date", "now", "uploadRate", "_uploadRate", "downloadRate", "_downloadRate", "messagesSent", "_messagesSent", "messagesReceived", "_messagesReceived", "send", "message", "invariant", "_ws", "_wsMuxer", "log", "payload", "protocol", "getPayloadType", "includes", "EdgeWebsocketProtocol", "V0", "binary", "buf", "toBinary", "MessageSchema", "length", "CLOUDFLARE_MESSAGE_MAX_BYTES", "error", "byteLength", "serviceId", "_recordBytes", "catch", "e", "_open", "baseProtocols", "Object", "values", "WebSocket", "_connectionInfo", "url", "toString", "protocolHeader", "muxer", "WebSocketMuxer", "onopen", "_callbacks", "onConnected", "_scheduleHeartbeats", "_scheduleRateCalculation", "verbose", "currentIdentity", "onclose", "event", "warn", "code", "reason", "onRestartRequired", "destroy", "onerror", "onmessage", "type", "_lastReceivedMessageTimestamp", "data", "_pingTimestamp", "undefined", "_rescheduleHeartbeatTimeout", "bytes", "toUint8Array", "fromBinary", "receiveData", "from", "source", "onMessage", "_close", "_inactivityTimeoutCtx", "dispose", "close", "err", "Error", "scheduleTaskInterval", "_ctx", "Context", "scheduleTask", "lastReceivedMessageTimestamp", "sent", "received", "currentSecond", "Math", "floor", "existingSample", "_bytesSamples", "find", "s", "timestamp", "push", "_calculateRates", "_rateUpdateInterval", "cutoff", "_rateWindow", "filter", "totalSent", "totalReceived", "oldestTimestamp", "min", "map", "timeSpan", "sample", "round", "EdgeConnectionClosedError", "Error", "EdgeIdentityChangedError", "getEdgeUrlWithProtocol", "baseUrl", "protocol", "isSecure", "startsWith", "url", "URL", "toString", "DEFAULT_TIMEOUT", "STATUS_REFRESH_INTERVAL", "EdgeClient", "Resource", "info", "open", "isOpen", "status", "identity", "_identity", "identityKey", "device", "peerKey", "state", "Boolean", "_currentConnection", "_ready", "TriggerState", "RESOLVED", "EdgeStatus", "ConnectionState", "CONNECTED", "NOT_CONNECTED", "uptime", "rtt", "rateBytesUp", "uploadRate", "rateBytesDown", "downloadRate", "messagesSent", "messagesReceived", "setIdentity", "log", "oldIdentity", "_closeCurrentConnection", "EdgeIdentityChangedError", "_persistentLifecycle", "scheduleRestart", "send", "message", "wait", "timeout", "_config", "EdgeConnectionClosedError", "source", "onMessage", "listener", "_messageListeners", "add", "delete", "onReconnected", "_reconnectListeners", "scheduleMicroTask", "_ctx", "has", "error", "catch", "_open", "err", "warn", "scheduleTaskInterval", "statusChanged", "emit", "_close", "close", "_connect", "disposed", "undefined", "path", "protocolHeader", "disableAuth", "_createAuthHeader", "restartRequired", "Trigger", "url", "URL", "_baseWsUrl", "toString", "connection", "EdgeWsConnection", "onConnected", "_isActive", "wake", "_notifyReconnected", "verbose", "onRestartRequired", "_notifyMessageReceived", "from", "type", "payload", "typeUrl", "Promise", "race", "_disconnect", "throw", "reset", "protocol", "getPayloadType", "httpUrl", "_baseHttpUrl", "getEdgeUrlWithProtocol", "response", "fetch", "method", "encodePresentationWsAuthHeader", "handleAuthChallenge", "statusText", "_define_property", "Event", "PersistentLifecycle", "start", "stop", "Set", "socketEndpoint", "encodedPresentation", "encodedToken", "Buffer", "replace", "replaceAll", "FetchHttpClient", "HttpClient", "Effect", "Function", "sleep", "Context", "log", "EdgeAuthChallengeError", "EdgeCallFailedError", "createUrl", "Context", "Duration", "Effect", "Layer", "Schedule", "log", "HttpConfig", "Tag", "_define_property", "default", "succeed", "timeout", "millis", "retryTimes", "retryBaseDelay", "withRetry", "effect", "pipe", "flatMap", "res", "status", "fail", "Error", "toString", "json", "retry", "schedule", "exponential", "jittered", "times", "withRetryConfig", "gen", "config", "withLogging", "tap", "info", "encodeAuthHeader", "challenge", "encodedChallenge", "Buffer", "from", "DEFAULT_RETRY_TIMEOUT", "DEFAULT_RETRY_JITTER", "DEFAULT_MAX_RETRIES_COUNT", "WARNING_BODY_SIZE", "EdgeHttpClient", "baseUrl", "_baseUrl", "setIdentity", "identity", "_edgeIdentity", "identityKey", "peerKey", "_authHeader", "undefined", "getStatus", "args", "_call", "URL", "method", "createAgent", "body", "getAgentStatus", "request", "ownerIdentityKey", "toHex", "getCredentialsForNotarization", "spaceId", "notarizeCredentials", "recoverIdentity", "joinSpaceByInvitation", "initiateOAuthFlow", "createSpace", "queryQueue", "subspaceTag", "query", "queueId", "createUrl", "after", "before", "limit", "reverse", "objectIds", "join", "insertIntoQueue", "objects", "deleteFromQueue", "ids", "uploadFunction", "pathParts", "formData", "FormData", "append", "name", "version", "ownerPublicKey", "entryPoint", "filename", "content", "Object", "entries", "assets", "Blob", "type", "getFileMimeType", "path", "functionId", "json", "listFunctions", "invokeFunction", "params", "input", "url", "searchParams", "set", "toString", "cpuTimeLimit", "subrequestsLimit", "rawResponse", "executeWorkflow", "graphId", "getCronTriggers", "importBundle", "exportBundle", "_fetch", "pipe", "get", "withLogging", "withRetryConfig", "provide", "layer", "HttpConfig", "default", "withSpan", "runPromise", "shouldRetry", "createRetryHandler", "requestContext", "context", "Context", "log", "handledAuth", "processingError", "retryAfterHeaderValue", "Number", "NaN", "createRequest", "response", "fetch", "headers", "ok", "success", "data", "warn", "errorData", "challenge", "EdgeAuthChallengeError", "EdgeCallFailedError", "fromUnsuccessfulResponse", "status", "_handleUnauthorized", "fromHttpFailure", "error", "fromProcessingFailureCause", "isRetryable", "handleAuthChallenge", "encodeAuthHeader", "_define_property", "getEdgeUrlWithProtocol", "authHeader", "requestBody", "JSON", "stringify", "length", "bodySize", "retry", "count", "retries", "maxRetries", "baseTimeout", "timeout", "jitter", "ctx", "retryAfter", "disposed", "sleep", "Math", "random", "some", "codeExtension", "endsWith"]
|
|
7
|
-
}
|