@dxos/edge-client 0.6.13-main.548ca8d → 0.6.13-main.ed424a1
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/index.mjs +64 -21
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node/index.cjs +64 -21
- package/dist/lib/node/index.cjs.map +3 -3
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +64 -21
- package/dist/lib/node-esm/index.mjs.map +3 -3
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/types/src/edge-client.d.ts.map +1 -1
- package/dist/types/src/edge-http-client.d.ts +6 -2
- package/dist/types/src/edge-http-client.d.ts.map +1 -1
- package/package.json +14 -14
- package/src/edge-client.ts +6 -2
- package/src/edge-http-client.ts +18 -2
package/src/edge-http-client.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
import { sleep } from '@dxos/async';
|
|
6
6
|
import { Context } from '@dxos/context';
|
|
7
|
-
import { type SpaceId } from '@dxos/keys';
|
|
7
|
+
import { type PublicKey, type SpaceId } from '@dxos/keys';
|
|
8
8
|
import { log } from '@dxos/log';
|
|
9
9
|
import {
|
|
10
10
|
EdgeCallFailedError,
|
|
@@ -14,6 +14,9 @@ import {
|
|
|
14
14
|
type JoinSpaceRequest,
|
|
15
15
|
type JoinSpaceResponseBody,
|
|
16
16
|
EdgeAuthChallengeError,
|
|
17
|
+
type CreateAgentResponseBody,
|
|
18
|
+
type CreateAgentRequestBody,
|
|
19
|
+
type GetAgentStatusResponseBody,
|
|
17
20
|
} from '@dxos/protocols';
|
|
18
21
|
|
|
19
22
|
import { getEdgeUrlWithProtocol } from './utils';
|
|
@@ -30,6 +33,17 @@ export class EdgeHttpClient {
|
|
|
30
33
|
log('created', { url: this._baseUrl });
|
|
31
34
|
}
|
|
32
35
|
|
|
36
|
+
public createAgent(body: CreateAgentRequestBody, args?: EdgeHttpGetArgs): Promise<CreateAgentResponseBody> {
|
|
37
|
+
return this._call('/agents/create', { ...args, method: 'POST', body });
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
public getAgentStatus(
|
|
41
|
+
request: { ownerIdentityKey: PublicKey },
|
|
42
|
+
args?: EdgeHttpGetArgs,
|
|
43
|
+
): Promise<GetAgentStatusResponseBody> {
|
|
44
|
+
return this._call(`/users/${request.ownerIdentityKey.toHex()}/agent/status`, { ...args, method: 'GET' });
|
|
45
|
+
}
|
|
46
|
+
|
|
33
47
|
public getCredentialsForNotarization(spaceId: SpaceId, args?: EdgeHttpGetArgs): Promise<GetNotarizationResponseBody> {
|
|
34
48
|
return this._call(`/spaces/${spaceId}/notarization`, { ...args, method: 'GET' });
|
|
35
49
|
}
|
|
@@ -56,7 +70,7 @@ export class EdgeHttpClient {
|
|
|
56
70
|
const request = createRequest(args);
|
|
57
71
|
const url = `${this._baseUrl}${path.startsWith('/') ? path.slice(1) : path}`;
|
|
58
72
|
|
|
59
|
-
log.info('call', { method: args.method, path });
|
|
73
|
+
log.info('call', { method: args.method, path, request: args.body });
|
|
60
74
|
|
|
61
75
|
while (true) {
|
|
62
76
|
let processingError: EdgeCallFailedError;
|
|
@@ -72,6 +86,8 @@ export class EdgeHttpClient {
|
|
|
72
86
|
return body.data;
|
|
73
87
|
}
|
|
74
88
|
|
|
89
|
+
log.info('unsuccessful edge response', { path, body });
|
|
90
|
+
|
|
75
91
|
if (body.errorData?.type === 'auth_challenge' && typeof body.errorData?.challenge === 'string') {
|
|
76
92
|
processingError = new EdgeAuthChallengeError(body.errorData.challenge, body.errorData);
|
|
77
93
|
} else {
|