@aauth/proxy 0.1.3
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/README.md +75 -0
- package/dist/agent.d.ts +37 -0
- package/dist/agent.d.ts.map +1 -0
- package/dist/agent.js +220 -0
- package/dist/agent.js.map +1 -0
- package/dist/host.d.ts +6 -0
- package/dist/host.d.ts.map +1 -0
- package/dist/host.js +27 -0
- package/dist/host.js.map +1 -0
- package/dist/identity-local.d.ts +10 -0
- package/dist/identity-local.d.ts.map +1 -0
- package/dist/identity-local.js +70 -0
- package/dist/identity-local.js.map +1 -0
- package/dist/identity.d.ts +13 -0
- package/dist/identity.d.ts.map +1 -0
- package/dist/identity.js +11 -0
- package/dist/identity.js.map +1 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +13 -0
- package/dist/index.js.map +1 -0
- package/dist/registry.d.ts +34 -0
- package/dist/registry.d.ts.map +1 -0
- package/dist/registry.js +60 -0
- package/dist/registry.js.map +1 -0
- package/dist/resource.d.ts +38 -0
- package/dist/resource.d.ts.map +1 -0
- package/dist/resource.js +159 -0
- package/dist/resource.js.map +1 -0
- package/dist/server.d.ts +3 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +119 -0
- package/dist/server.js.map +1 -0
- package/dist/store.d.ts +28 -0
- package/dist/store.d.ts.map +1 -0
- package/dist/store.js +64 -0
- package/dist/store.js.map +1 -0
- package/dist/tools.d.ts +28 -0
- package/dist/tools.d.ts.map +1 -0
- package/dist/tools.js +253 -0
- package/dist/tools.js.map +1 -0
- package/dist/vocab/index.d.ts +6 -0
- package/dist/vocab/index.d.ts.map +1 -0
- package/dist/vocab/index.js +19 -0
- package/dist/vocab/index.js.map +1 -0
- package/dist/vocab/openapi.d.ts +43 -0
- package/dist/vocab/openapi.d.ts.map +1 -0
- package/dist/vocab/openapi.js +113 -0
- package/dist/vocab/openapi.js.map +1 -0
- package/dist/vocab/types.d.ts +47 -0
- package/dist/vocab/types.d.ts.map +1 -0
- package/dist/vocab/types.js +11 -0
- package/dist/vocab/types.js.map +1 -0
- package/package.json +59 -0
package/README.md
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
# @aauth/proxy
|
|
2
|
+
|
|
3
|
+
MCP stdio server that represents you as an agent in the [AAuth](https://github.com/DickHardt/AAuth) protocol. The LLM sees a fixed eight-tool surface; new resources and operations are surfaced through the same tools, regardless of how many you add.
|
|
4
|
+
|
|
5
|
+
Your AAuth signing key is bound to this machine via [`@aauth/local-keys`](https://www.npmjs.com/package/@aauth/local-keys) — non-extractable when a Secure Enclave, TPM, or YubiKey is available; software-backed otherwise. The agent proxy holds no upstream service credentials.
|
|
6
|
+
|
|
7
|
+
Design and protocol details: [`design.md`](./design.md).
|
|
8
|
+
|
|
9
|
+
## Prerequisites
|
|
10
|
+
|
|
11
|
+
- Node ≥ 22.
|
|
12
|
+
- An AAuth identity on this machine. If none exists, the agent proxy's MCP server still starts; the first tool call returns a bootstrap prompt that points the LLM at [`@aauth/bootstrap`](https://www.npmjs.com/package/@aauth/bootstrap). The agent proxy picks the identity up on the next call — no restart.
|
|
13
|
+
|
|
14
|
+
```sh
|
|
15
|
+
npx @aauth/bootstrap setup
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Install
|
|
19
|
+
|
|
20
|
+
### Claude Code
|
|
21
|
+
|
|
22
|
+
```json
|
|
23
|
+
{
|
|
24
|
+
"mcpServers": {
|
|
25
|
+
"aauth-proxy": { "command": "npx", "args": ["-y", "@aauth/proxy"] }
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
### Claude Desktop
|
|
31
|
+
|
|
32
|
+
Edit `~/Library/Application Support/Claude/claude_desktop_config.json` (macOS) or `%APPDATA%\Claude\claude_desktop_config.json` (Windows):
|
|
33
|
+
|
|
34
|
+
```json
|
|
35
|
+
{
|
|
36
|
+
"mcpServers": {
|
|
37
|
+
"aauth-proxy": { "command": "npx", "args": ["-y", "@aauth/proxy"] }
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
### Cursor
|
|
43
|
+
|
|
44
|
+
Settings → MCP → Add new server, then add:
|
|
45
|
+
|
|
46
|
+
```json
|
|
47
|
+
{
|
|
48
|
+
"aauth-proxy": { "command": "npx", "args": ["-y", "@aauth/proxy"] }
|
|
49
|
+
}
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### Other MCP hosts
|
|
53
|
+
|
|
54
|
+
Any stdio MCP host: `npx -y @aauth/proxy`.
|
|
55
|
+
|
|
56
|
+
## CLI flags
|
|
57
|
+
|
|
58
|
+
| Flag | Purpose |
|
|
59
|
+
|---|---|
|
|
60
|
+
| `--log` | Tee JSON-RPC frames to `~/.aauth/proxy/logs/<ISO>.jsonl` for debugging. |
|
|
61
|
+
|
|
62
|
+
## Environment variables
|
|
63
|
+
|
|
64
|
+
All optional; sensible defaults come from `@aauth/local-keys`.
|
|
65
|
+
|
|
66
|
+
| Var | Default | Purpose |
|
|
67
|
+
|---|---|---|
|
|
68
|
+
| `PROXY_REGISTRY_URL` | `https://registry.aauth.dev` | AAuth resource registry |
|
|
69
|
+
| `PROXY_PS_URL` | from local-keys | Person Server URL |
|
|
70
|
+
| `PROXY_AGENT_URL` | first configured | Agent provider URL |
|
|
71
|
+
| `PROXY_AGENT_TOKEN` + `PROXY_AGENT_PRIVATE_JWK` (or `PROXY_AGENT_KEY_FILE`) | — | Test-only software-identity override that bypasses local-keys |
|
|
72
|
+
|
|
73
|
+
## License
|
|
74
|
+
|
|
75
|
+
MIT
|
package/dist/agent.d.ts
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { fetch as signedFetch } from '@hellocoop/httpsig';
|
|
2
|
+
import type { L1Entry } from './store.js';
|
|
3
|
+
export type AgentSigningKey = Parameters<typeof signedFetch>[1]['signingKey'];
|
|
4
|
+
export interface ProxyConfig {
|
|
5
|
+
psUrl: string;
|
|
6
|
+
agentPrivateJwk: AgentSigningKey;
|
|
7
|
+
agentToken: string;
|
|
8
|
+
}
|
|
9
|
+
export interface InvokeArgs {
|
|
10
|
+
pathParams?: Record<string, string>;
|
|
11
|
+
query?: string;
|
|
12
|
+
body?: unknown;
|
|
13
|
+
contentType?: string;
|
|
14
|
+
}
|
|
15
|
+
export interface Interaction {
|
|
16
|
+
url: string;
|
|
17
|
+
code: string;
|
|
18
|
+
pollUrl: string;
|
|
19
|
+
}
|
|
20
|
+
export type InvokeResult = {
|
|
21
|
+
kind: 'result';
|
|
22
|
+
status: number;
|
|
23
|
+
body: unknown;
|
|
24
|
+
} | {
|
|
25
|
+
kind: 'interaction';
|
|
26
|
+
interaction: Interaction;
|
|
27
|
+
};
|
|
28
|
+
export type InteractionHandler = (url: string, code: string) => Promise<void> | void;
|
|
29
|
+
type Poller = (url: string) => Promise<Response>;
|
|
30
|
+
export declare function pollUntilDone(poll: Poller, locationUrl: string, timeoutMs?: number, onPoll?: (elapsedMs: number) => void | Promise<void>): Promise<Response>;
|
|
31
|
+
export declare function invokeAtResource(cfg: ProxyConfig, l1: L1Entry, operationId: string, args?: InvokeArgs): Promise<InvokeResult>;
|
|
32
|
+
export declare function invokeAtResourceComplete(cfg: ProxyConfig, l1: L1Entry, operationId: string, onInteraction: InteractionHandler, args?: InvokeArgs, maxRounds?: number, pollTimeoutMs?: number, onPoll?: (elapsedMs: number) => void | Promise<void>): Promise<{
|
|
33
|
+
status: number;
|
|
34
|
+
body: unknown;
|
|
35
|
+
}>;
|
|
36
|
+
export {};
|
|
37
|
+
//# sourceMappingURL=agent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent.d.ts","sourceRoot":"","sources":["../src/agent.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,KAAK,IAAI,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAEzD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,Y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E,WAAW,EAChB,EAAE,EAAE,OAAO,EACX,WAAW,EAAE,MAAM,EACnB,IAAI,GAAE,UAAe,GACpB,OAAO,CAAC,YAAY,CAAC,CAgGvB;AAMD,wBAAsB,wBAAwB,CAC5C,GAAG,EAAE,WAAW,EAChB,EAAE,EAAE,OAAO,EACX,WAAW,EAAE,MAAM,EACnB,aAAa,EAAE,kBAAkB,EACjC,IAAI,GAAE,UAAe,EACrB,SAAS,SAAI,EACb,aAAa,SAAU,EACvB,MAAM,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,GACnD,OAAO,CAAC;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,OAAO,CAAA;CAAE,CAAC,CAW5C"}
|
package/dist/agent.js
ADDED
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
// agent proxy — the user's AAuth agent. v0 core: the authorize-first R3 invoke flow
|
|
2
|
+
// against the resource proxy, exchanging at the PS.
|
|
3
|
+
//
|
|
4
|
+
// invoke() is non-blocking: when an interaction is required (PS consent or the
|
|
5
|
+
// resource's OAuth bootstrap) it RETURNS the interaction (url + code + poll URL)
|
|
6
|
+
// rather than completing it, so a caller — the MCP server — can surface the URL
|
|
7
|
+
// to the user. invokeComplete() drives it to completion for programmatic use,
|
|
8
|
+
// performing the interaction via a callback and polling.
|
|
9
|
+
//
|
|
10
|
+
// Built directly on @hellocoop/httpsig (the @aauth/mcp-agent package is
|
|
11
|
+
// 401-challenge-driven and has no R3/authorize-first path, mirroring the
|
|
12
|
+
// resource-side finding).
|
|
13
|
+
import { fetch as signedFetch } from '@hellocoop/httpsig';
|
|
14
|
+
import { routeOperation } from './resource.js';
|
|
15
|
+
function signWith(cfg, token) {
|
|
16
|
+
return (url, init = {}) => signedFetch(url, { ...init, signingKey: cfg.agentPrivateJwk, signatureKey: { type: 'jwt', jwt: token } });
|
|
17
|
+
}
|
|
18
|
+
function parseInteraction(requirement) {
|
|
19
|
+
if (!requirement || !requirement.includes('requirement=interaction'))
|
|
20
|
+
return undefined;
|
|
21
|
+
const url = /url="([^"]+)"/.exec(requirement)?.[1];
|
|
22
|
+
const code = /code="([^"]+)"/.exec(requirement)?.[1];
|
|
23
|
+
return url && code ? { url, code } : undefined;
|
|
24
|
+
}
|
|
25
|
+
// A per-call escalation challenge (W2): the resource returns 401 with
|
|
26
|
+
// `requirement=auth-token; resource-token="…"` for a conditional/irreversible op.
|
|
27
|
+
// The agent takes that resource token (which carries the call as r3_context) to
|
|
28
|
+
// the PS for a per-call auth token, then retries.
|
|
29
|
+
function parseAuthTokenChallenge(requirement) {
|
|
30
|
+
if (!requirement || !requirement.includes('requirement=auth-token'))
|
|
31
|
+
return undefined;
|
|
32
|
+
return /resource-token="([^"]+)"/.exec(requirement)?.[1];
|
|
33
|
+
}
|
|
34
|
+
function interactionFrom(res) {
|
|
35
|
+
const parsed = parseInteraction(res.headers.get('aauth-requirement'));
|
|
36
|
+
const pollUrl = res.headers.get('location') ?? '';
|
|
37
|
+
return parsed && pollUrl ? { ...parsed, pollUrl } : undefined;
|
|
38
|
+
}
|
|
39
|
+
async function safeBody(res) {
|
|
40
|
+
const text = await res.text();
|
|
41
|
+
try {
|
|
42
|
+
return JSON.parse(text);
|
|
43
|
+
}
|
|
44
|
+
catch {
|
|
45
|
+
return text;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
async function psMetadata(psUrl) {
|
|
49
|
+
return (await (await fetch(`${psUrl.replace(/\/$/, '')}/.well-known/aauth-person.json`)).json());
|
|
50
|
+
}
|
|
51
|
+
// POST the interaction to the PS so it can try to reach the user (live web
|
|
52
|
+
// session, registered mobile push). On 2xx the PS owns user-reach; the agent
|
|
53
|
+
// blocks on the resource pollUrl until the user completes there. On any
|
|
54
|
+
// non-2xx (including the spec-pending interaction_unavailable error — see
|
|
55
|
+
// AAuth#34) the agent falls back to driving the URL itself.
|
|
56
|
+
async function relayInteractionToPS(signAgent, endpoint, interaction) {
|
|
57
|
+
try {
|
|
58
|
+
const res = await signAgent(endpoint, {
|
|
59
|
+
method: 'POST',
|
|
60
|
+
headers: { 'content-type': 'application/json' },
|
|
61
|
+
body: JSON.stringify({
|
|
62
|
+
type: 'interaction',
|
|
63
|
+
url: interaction.url,
|
|
64
|
+
code: interaction.code,
|
|
65
|
+
}),
|
|
66
|
+
});
|
|
67
|
+
return res.ok;
|
|
68
|
+
}
|
|
69
|
+
catch {
|
|
70
|
+
return false;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
// Poll a deferred (202) Location until terminal. The poll MUST be signed — the
|
|
74
|
+
// PS pending endpoint verifies the agent signature (an unsigned poll gets 401,
|
|
75
|
+
// which would look like an instant terminal response).
|
|
76
|
+
//
|
|
77
|
+
// `onPoll` (optional) is invoked once per poll iteration with elapsed ms — a
|
|
78
|
+
// heartbeat hook for hosts that hold a request open (e.g. emit progress
|
|
79
|
+
// notifications over a long-running tool call).
|
|
80
|
+
export async function pollUntilDone(poll, locationUrl, timeoutMs = 180_000, onPoll) {
|
|
81
|
+
const start = Date.now();
|
|
82
|
+
const deadline = start + timeoutMs;
|
|
83
|
+
let res = await poll(locationUrl);
|
|
84
|
+
while (res.status === 202 && Date.now() < deadline) {
|
|
85
|
+
await onPoll?.(Date.now() - start);
|
|
86
|
+
await new Promise((r) => setTimeout(r, 1000));
|
|
87
|
+
res = await poll(locationUrl);
|
|
88
|
+
}
|
|
89
|
+
return res;
|
|
90
|
+
}
|
|
91
|
+
// Exchange a resource token at the PS for an auth token. capabilities tells the
|
|
92
|
+
// PS the agent can relay interactions to the user, so it returns a 202 consent
|
|
93
|
+
// interaction (surfaced for the caller to drive + retry) rather than requiring a
|
|
94
|
+
// registered mobile device. On PS endpoints this is a token-request parameter,
|
|
95
|
+
// not a header (the AAuth-Capabilities header is for resource requests).
|
|
96
|
+
async function exchangeAtPS(signAgent, tokenEndpoint, resourceToken) {
|
|
97
|
+
const res = await signAgent(tokenEndpoint, {
|
|
98
|
+
method: 'POST',
|
|
99
|
+
headers: { 'content-type': 'application/json' },
|
|
100
|
+
body: JSON.stringify({ resource_token: resourceToken, capabilities: ['interaction'] }),
|
|
101
|
+
});
|
|
102
|
+
if (res.status === 202) {
|
|
103
|
+
const interaction = interactionFrom(res);
|
|
104
|
+
if (interaction)
|
|
105
|
+
return { kind: 'interaction', interaction };
|
|
106
|
+
}
|
|
107
|
+
if (!res.ok)
|
|
108
|
+
return { kind: 'result', status: res.status, body: await safeBody(res) };
|
|
109
|
+
const { auth_token } = (await res.json());
|
|
110
|
+
return { kind: 'token', authToken: auth_token };
|
|
111
|
+
}
|
|
112
|
+
// Resource-parameterized invoke. The new tool surface in server.ts calls into
|
|
113
|
+
// this directly with an L1 entry from store.ts; the legacy invoke() below
|
|
114
|
+
// wraps it for cfg.resourceProxyBase-based callers (tests, demo scripts).
|
|
115
|
+
export async function invokeAtResource(cfg, l1, operationId, args = {}) {
|
|
116
|
+
const route = await routeOperation(l1, operationId, args);
|
|
117
|
+
if (route.plan.kind !== 'sync.request') {
|
|
118
|
+
return {
|
|
119
|
+
kind: 'result',
|
|
120
|
+
status: 501,
|
|
121
|
+
body: { error: `${route.plan.kind}_not_yet_supported`, opId: operationId },
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
const plan = route.plan;
|
|
125
|
+
const apiUrl = `${l1.origin}${plan.path}${plan.query ? `?${plan.query}` : ''}`;
|
|
126
|
+
const requestInit = {
|
|
127
|
+
method: plan.method,
|
|
128
|
+
...(plan.headers ? { headers: plan.headers } : {}),
|
|
129
|
+
...(plan.body !== undefined ? { body: plan.body } : {}),
|
|
130
|
+
};
|
|
131
|
+
// agent-token access mode: sign with the agent token + go. No PS exchange.
|
|
132
|
+
if (l1.access_mode === 'agent-token') {
|
|
133
|
+
const res = await signWith(cfg, cfg.agentToken)(apiUrl, requestInit);
|
|
134
|
+
return { kind: 'result', status: res.status, body: await safeBody(res) };
|
|
135
|
+
}
|
|
136
|
+
// aauth-access-token / auth-token: R3 flow.
|
|
137
|
+
if (!l1.authorization_endpoint) {
|
|
138
|
+
throw new Error(`resource ${l1.resource}: no authorization_endpoint (access_mode ${l1.access_mode} requires R3)`);
|
|
139
|
+
}
|
|
140
|
+
const signAgent = signWith(cfg, cfg.agentToken);
|
|
141
|
+
const ps = await psMetadata(cfg.psUrl);
|
|
142
|
+
// 1. authorize-first: declare the operation, get a resource token.
|
|
143
|
+
const authzRes = await signAgent(l1.authorization_endpoint, {
|
|
144
|
+
method: 'POST',
|
|
145
|
+
headers: { 'content-type': 'application/json' },
|
|
146
|
+
body: JSON.stringify({
|
|
147
|
+
r3_operations: {
|
|
148
|
+
vocabulary: route.adapter.vocabUri,
|
|
149
|
+
operations: [{ operationId }],
|
|
150
|
+
},
|
|
151
|
+
}),
|
|
152
|
+
});
|
|
153
|
+
if (!authzRes.ok)
|
|
154
|
+
return { kind: 'result', status: authzRes.status, body: await safeBody(authzRes) };
|
|
155
|
+
const { resource_token } = (await authzRes.json());
|
|
156
|
+
// 2. exchange at the PS for an auth token (surface a consent interaction if any).
|
|
157
|
+
const ex = await exchangeAtPS(signAgent, ps.token_endpoint, resource_token);
|
|
158
|
+
if (ex.kind !== 'token')
|
|
159
|
+
return ex;
|
|
160
|
+
// 3. call the resource. Writes carry the body; the agent signs over it so the
|
|
161
|
+
// proxy's content-digest check (and the r3_context it packs on escalation)
|
|
162
|
+
// match the actual call.
|
|
163
|
+
const callWith = (token) => signWith(cfg, token)(apiUrl, requestInit);
|
|
164
|
+
let apiRes = await callWith(ex.authToken);
|
|
165
|
+
// First contact: a resource-issued interaction (e.g. OAuth bootstrap). Try
|
|
166
|
+
// the PS's interaction_endpoint first so it can use its own user-reach
|
|
167
|
+
// channels (live web session, mobile push). On any non-2xx — including the
|
|
168
|
+
// spec-pending interaction_unavailable error (AAuth#34) and any PS that
|
|
169
|
+
// hasn't implemented the endpoint yet — surface the interaction so the
|
|
170
|
+
// caller can drive it (layer 2: local OS open / layer 3: text+QR).
|
|
171
|
+
if (apiRes.status === 202) {
|
|
172
|
+
const interaction = interactionFrom(apiRes);
|
|
173
|
+
if (interaction) {
|
|
174
|
+
const engaged = ps.interaction_endpoint
|
|
175
|
+
? await relayInteractionToPS(signAgent, ps.interaction_endpoint, interaction)
|
|
176
|
+
: false;
|
|
177
|
+
if (!engaged)
|
|
178
|
+
return { kind: 'interaction', interaction };
|
|
179
|
+
const poll = (url) => signWith(cfg, cfg.agentToken)(url, { method: 'GET', headers: { Prefer: 'wait=20' } });
|
|
180
|
+
const completed = await pollUntilDone(poll, interaction.pollUrl, 180_000);
|
|
181
|
+
if (completed.status === 202)
|
|
182
|
+
return { kind: 'interaction', interaction };
|
|
183
|
+
apiRes = await callWith(ex.authToken);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
// Per-call escalation (W2): a conditional/irreversible op returns a 401
|
|
187
|
+
// auth-token challenge. Take its resource token (which carries the call as
|
|
188
|
+
// r3_context) to the PS for a per-call auth token, then retry the same call.
|
|
189
|
+
// If the PS needs consent first, it returns a 202 interaction we surface.
|
|
190
|
+
const challenge = apiRes.status === 401 ? parseAuthTokenChallenge(apiRes.headers.get('aauth-requirement')) : undefined;
|
|
191
|
+
if (challenge) {
|
|
192
|
+
const stepEx = await exchangeAtPS(signAgent, ps.token_endpoint, challenge);
|
|
193
|
+
if (stepEx.kind !== 'token')
|
|
194
|
+
return stepEx;
|
|
195
|
+
apiRes = await callWith(stepEx.authToken);
|
|
196
|
+
if (apiRes.status === 202) {
|
|
197
|
+
const interaction = interactionFrom(apiRes);
|
|
198
|
+
if (interaction)
|
|
199
|
+
return { kind: 'interaction', interaction };
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
return { kind: 'result', status: apiRes.status, body: await safeBody(apiRes) };
|
|
203
|
+
}
|
|
204
|
+
// Drive invokeAtResource to completion: perform each interaction via
|
|
205
|
+
// `onInteraction`, poll until it resolves, and retry. For programmatic / test
|
|
206
|
+
// use; the MCP tool surface is non-blocking by design and surfaces interaction
|
|
207
|
+
// URLs to the LLM caller instead.
|
|
208
|
+
export async function invokeAtResourceComplete(cfg, l1, operationId, onInteraction, args = {}, maxRounds = 5, pollTimeoutMs = 180_000, onPoll) {
|
|
209
|
+
// Poll deferred URLs signed with the agent token (long-poll via Prefer: wait).
|
|
210
|
+
const poll = (url) => signWith(cfg, cfg.agentToken)(url, { method: 'GET', headers: { Prefer: 'wait=20' } });
|
|
211
|
+
for (let round = 0; round < maxRounds; round++) {
|
|
212
|
+
const result = await invokeAtResource(cfg, l1, operationId, args);
|
|
213
|
+
if (result.kind === 'result')
|
|
214
|
+
return { status: result.status, body: result.body };
|
|
215
|
+
await onInteraction(result.interaction.url, result.interaction.code);
|
|
216
|
+
await pollUntilDone(poll, result.interaction.pollUrl, pollTimeoutMs, onPoll);
|
|
217
|
+
}
|
|
218
|
+
throw new Error('invoke did not complete after interactions');
|
|
219
|
+
}
|
|
220
|
+
//# sourceMappingURL=agent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent.js","sourceRoot":"","sources":["../src/agent.ts"],"names":[],"mappings":"AAAA,oFAAoF;AACpF,oDAAoD;AACpD,EAAE;AACF,+EAA+E;AAC/E,iFAAiF;AACjF,gFAAgF;AAChF,8EAA8E;AAC9E,yDAAyD;AACzD,EAAE;AACF,wEAAwE;AACxE,yEAAyE;AACzE,0BAA0B;AAE1B,OAAO,EAAE,KAAK,IAAI,WAAW,EAAE,MAAM,oBAAoB,CAAA;AACzD,OAAO,EAAiB,cAAc,EAAa,MAAM,eAAe,CAAA;AA8BxE,SAAS,QAAQ,CAAC,GAAgB,EAAE,KAAa;IAC/C,OAAO,CAAC,GAAW,EAAE,OAA6E,EAAE,EAAE,EAAE,CACtG,WAAW,CAAC,GAAG,EAAE,EAAE,GAAG,IAAI,EAAE,UAAU,EAAE,GAAG,CAAC,eAAe,EAAE,YAAY,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,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EAA+E;IAC/E,MAAM,IAAI,GAAW,CAAC,GAAG,EAAE,EAAE,CAC3B,QAAQ,CAAC,GAAG,EAAE,GAAG,CAAC,UAAU,CAAC,CAAC,GAAG,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,MAAM,EAAE,SAAS,EAAE,EAAE,CAAC,CAAA;IACvF,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,SAAS,EAAE,KAAK,EAAE,EAAE,CAAC;QAC/C,MAAM,MAAM,GAAG,MAAM,gBAAgB,CAAC,GAAG,EAAE,EAAE,EAAE,WAAW,EAAE,IAAI,CAAC,CAAA;QACjE,IAAI,MAAM,CAAC,IAAI,KAAK,QAAQ;YAAE,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,CAAA;QACjF,MAAM,aAAa,CAAC,MAAM,CAAC,WAAW,CAAC,GAAG,EAAE,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC,CAAA;QACpE,MAAM,aAAa,CAAC,IAAI,EAAE,MAAM,CAAC,WAAW,CAAC,OAAO,EAAE,aAAa,EAAE,MAAM,CAAC,CAAA;IAC9E,CAAC;IACD,MAAM,IAAI,KAAK,CAAC,4CAA4C,CAAC,CAAA;AAC/D,CAAC"}
|
package/dist/host.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"host.d.ts","sourceRoot":"","sources":["../src/host.ts"],"names":[],"mappings":"AASA,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,EAAE,MAAM,CAAA;CACf;AAED,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,aAAa,GAAG,IAAI,CAapE"}
|
package/dist/host.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// Host normalization. The agent proxy's canonical resource identifier is the bare
|
|
2
|
+
// lowercased host (with port if non-default), e.g. `api-hubapi-com.proxy.aauth.dev`
|
|
3
|
+
// or `localhost:8787` for local dev tunnels. The origin (`https://host` or
|
|
4
|
+
// `http://host` for local) is also returned and stored on each L1 entry so the
|
|
5
|
+
// scheme survives across agent proxy restarts.
|
|
6
|
+
//
|
|
7
|
+
// Production AAuth resources are https; we allow http for local dev + the test
|
|
8
|
+
// harness.
|
|
9
|
+
export function canonicalizeHost(input) {
|
|
10
|
+
let urlStr = input.trim();
|
|
11
|
+
if (!urlStr)
|
|
12
|
+
return null;
|
|
13
|
+
if (!/^https?:\/\//i.test(urlStr))
|
|
14
|
+
urlStr = `https://${urlStr}`;
|
|
15
|
+
let url;
|
|
16
|
+
try {
|
|
17
|
+
url = new URL(urlStr);
|
|
18
|
+
}
|
|
19
|
+
catch {
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
if (url.protocol !== 'https:' && url.protocol !== 'http:')
|
|
23
|
+
return null;
|
|
24
|
+
const host = url.host.toLowerCase();
|
|
25
|
+
return { host, origin: `${url.protocol}//${host}` };
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=host.js.map
|
package/dist/host.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"host.js","sourceRoot":"","sources":["../src/host.ts"],"names":[],"mappings":"AAAA,kFAAkF;AAClF,oFAAoF;AACpF,2EAA2E;AAC3E,+EAA+E;AAC/E,+CAA+C;AAC/C,EAAE;AACF,+EAA+E;AAC/E,WAAW;AAOX,MAAM,UAAU,gBAAgB,CAAC,KAAa;IAC5C,IAAI,MAAM,GAAG,KAAK,CAAC,IAAI,EAAE,CAAA;IACzB,IAAI,CAAC,MAAM;QAAE,OAAO,IAAI,CAAA;IACxB,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,MAAM,CAAC;QAAE,MAAM,GAAG,WAAW,MAAM,EAAE,CAAA;IAC/D,IAAI,GAAQ,CAAA;IACZ,IAAI,CAAC;QACH,GAAG,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,CAAA;IACvB,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAA;IACb,CAAC;IACD,IAAI,GAAG,CAAC,QAAQ,KAAK,QAAQ,IAAI,GAAG,CAAC,QAAQ,KAAK,OAAO;QAAE,OAAO,IAAI,CAAA;IACtE,MAAM,IAAI,GAAG,GAAG,CAAC,IAAI,CAAC,WAAW,EAAE,CAAA;IACnC,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,GAAG,CAAC,QAAQ,KAAK,IAAI,EAAE,EAAE,CAAA;AACrD,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ProxyConfig } from './agent.js';
|
|
2
|
+
import type { IdentityProvider } from './identity.js';
|
|
3
|
+
export declare function loadIdentity(): ProxyConfig;
|
|
4
|
+
export declare function buildConfigFromLocalKeys(opts?: {
|
|
5
|
+
agentUrl?: string;
|
|
6
|
+
psUrl?: string;
|
|
7
|
+
local?: string;
|
|
8
|
+
}): Promise<ProxyConfig>;
|
|
9
|
+
export declare function createLocalKeysIdentityProvider(): IdentityProvider;
|
|
10
|
+
//# sourceMappingURL=identity-local.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"identity-local.d.ts","sourceRoot":"","sources":["../src/identity-local.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAmB,WAAW,EAAE,MAAM,YAAY,CAAA;AAC9D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAA;AAQrD,wBAAgB,YAAY,IAAI,WAAW,CAS1C;AAED,wBAAsB,wBAAwB,CAC5C,IAAI,GAAE;IAAE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAO,GAC/D,OAAO,CAAC,WAAW,CAAC,CAkBtB;AAWD,wBAAgB,+BAA+B,IAAI,gBAAgB,CAelE"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
// @aauth/proxy/local — the Node-only identity adapter for the stdio server.
|
|
2
|
+
//
|
|
3
|
+
// This is the only place @aauth/local-keys is imported, so the package's core
|
|
4
|
+
// entry point stays enclave-free (and bundleable for workerd). Two sources:
|
|
5
|
+
// - env: a software agent token + key (PROXY_AGENT_PRIVATE_JWK / *_KEY_FILE) —
|
|
6
|
+
// tests and simple software-only use.
|
|
7
|
+
// - @aauth/local-keys: the real path — the bootstrapped AP key (Secure Enclave
|
|
8
|
+
// / YubiKey) mints the agent token, binding a fresh software ephemeral key.
|
|
9
|
+
// That ephemeral key (returned as `signingKey`) signs HTTP requests, so
|
|
10
|
+
// the agent proxy's request-signing path is unchanged; only token minting differs.
|
|
11
|
+
import { readFileSync } from 'node:fs';
|
|
12
|
+
import { createAgentToken, getAgentConfig, listAgentProviders } from '@aauth/local-keys';
|
|
13
|
+
function required(name) {
|
|
14
|
+
const value = process.env[name];
|
|
15
|
+
if (!value)
|
|
16
|
+
throw new Error(`agent proxy: missing required env var ${name}`);
|
|
17
|
+
return value;
|
|
18
|
+
}
|
|
19
|
+
export function loadIdentity() {
|
|
20
|
+
const psUrl = required('PROXY_PS_URL');
|
|
21
|
+
const agentToken = required('PROXY_AGENT_TOKEN');
|
|
22
|
+
const jwkJson = process.env.PROXY_AGENT_PRIVATE_JWK ??
|
|
23
|
+
readFileSync(process.env.PROXY_AGENT_KEY_FILE ?? '.secrets/proxy-agent-key.json', 'utf8');
|
|
24
|
+
return { psUrl, agentToken, agentPrivateJwk: JSON.parse(jwkJson) };
|
|
25
|
+
}
|
|
26
|
+
export async function buildConfigFromLocalKeys(opts = {}) {
|
|
27
|
+
const agentUrl = opts.agentUrl ?? process.env.PROXY_AGENT_URL ?? listAgentProviders()[0];
|
|
28
|
+
if (!agentUrl) {
|
|
29
|
+
throw new Error('agent proxy: no agent configured (run @aauth/bootstrap) and no PROXY_AGENT_URL set');
|
|
30
|
+
}
|
|
31
|
+
const psUrl = opts.psUrl ?? process.env.PROXY_PS_URL ?? getAgentConfig(agentUrl)?.personServerUrl;
|
|
32
|
+
if (!psUrl)
|
|
33
|
+
throw new Error(`agent proxy: no Person Server configured for ${agentUrl}; set PROXY_PS_URL`);
|
|
34
|
+
// The AP key (enclave/yubikey) signs the agent token, binding a fresh software
|
|
35
|
+
// ephemeral key returned as signingKey.
|
|
36
|
+
const { signingKey, signatureKey } = await createAgentToken({ agentUrl, local: opts.local });
|
|
37
|
+
return {
|
|
38
|
+
psUrl,
|
|
39
|
+
agentPrivateJwk: signingKey,
|
|
40
|
+
agentToken: signatureKey.jwt,
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
// The stdio server's IdentityProvider. Resolves lazily and caches the result
|
|
44
|
+
// so the enclave signs the agent token at most once per session (the env path
|
|
45
|
+
// is likewise resolved once). When no agent provider is configured it returns
|
|
46
|
+
// `needsBootstrap` without caching, so a mid-session bootstrap is picked up on
|
|
47
|
+
// the next call without a restart.
|
|
48
|
+
//
|
|
49
|
+
// `local` becomes the local-part of the agent id (`aauth:${local}@${domain}`),
|
|
50
|
+
// sourced by the caller from the MCP client's declared name so each host on the
|
|
51
|
+
// user's machine gets a distinct identifier.
|
|
52
|
+
export function createLocalKeysIdentityProvider() {
|
|
53
|
+
let cached = null;
|
|
54
|
+
return {
|
|
55
|
+
async resolve({ local }) {
|
|
56
|
+
if (cached)
|
|
57
|
+
return { kind: 'ready', cfg: cached };
|
|
58
|
+
if (process.env.PROXY_AGENT_PRIVATE_JWK) {
|
|
59
|
+
cached = loadIdentity();
|
|
60
|
+
return { kind: 'ready', cfg: cached };
|
|
61
|
+
}
|
|
62
|
+
const agentUrl = process.env.PROXY_AGENT_URL ?? listAgentProviders()[0];
|
|
63
|
+
if (!agentUrl)
|
|
64
|
+
return { kind: 'needsBootstrap' };
|
|
65
|
+
cached = await buildConfigFromLocalKeys({ local });
|
|
66
|
+
return { kind: 'ready', cfg: cached };
|
|
67
|
+
},
|
|
68
|
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,CAAC,QAAQ;gBAAE,OAAO,EAAE,IAAI,EAAE,gBAAgB,EAAE,CAAA;YAChD,MAAM,GAAG,MAAM,wBAAwB,CAAC,EAAE,KAAK,EAAE,CAAC,CAAA;YAClD,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,CAAA;QACvC,CAAC;KACF,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { ProxyConfig } from './agent.js';
|
|
2
|
+
export type BootstrapStatus = {
|
|
3
|
+
kind: 'ready';
|
|
4
|
+
cfg: ProxyConfig;
|
|
5
|
+
} | {
|
|
6
|
+
kind: 'needsBootstrap';
|
|
7
|
+
};
|
|
8
|
+
export interface IdentityProvider {
|
|
9
|
+
resolve(ctx: {
|
|
10
|
+
local?: string;
|
|
11
|
+
}): Promise<BootstrapStatus>;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=identity.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"identity.d.ts","sourceRoot":"","sources":["../src/identity.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AAE7C,MAAM,MAAM,eAAe,GACvB;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,GAAG,EAAE,WAAW,CAAA;CAAE,GACnC;IAAE,IAAI,EAAE,gBAAgB,CAAA;CAAE,CAAA;AAE9B,MAAM,WAAW,gBAAgB;IAI/B,OAAO,CAAC,GAAG,EAAE;QAAE,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,eAAe,CAAC,CAAA;CAC3D"}
|
package/dist/identity.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// the agent proxy's runtime identity port.
|
|
2
|
+
//
|
|
3
|
+
// An IdentityProvider resolves the ProxyConfig (psUrl + agent private JWK +
|
|
4
|
+
// agent token) for the current principal. This module is transport- and
|
|
5
|
+
// platform-agnostic and MUST NOT import @aauth/local-keys (or any Node-only
|
|
6
|
+
// enclave dependency) — that keeps a workerd bundle of @aauth/proxy's core
|
|
7
|
+
// enclave-free. The stdio server's provider lives in @aauth/proxy/local
|
|
8
|
+
// (createLocalKeysIdentityProvider); other hosts (e.g. a multi-tenant server)
|
|
9
|
+
// supply their own.
|
|
10
|
+
export {};
|
|
11
|
+
//# sourceMappingURL=identity.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"identity.js","sourceRoot":"","sources":["../src/identity.ts"],"names":[],"mappings":"AAAA,2CAA2C;AAC3C,EAAE;AACF,4EAA4E;AAC5E,wEAAwE;AACxE,4EAA4E;AAC5E,2EAA2E;AAC3E,wEAAwE;AACxE,8EAA8E;AAC9E,oBAAoB"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export { invokeAtResource, invokeAtResourceComplete } from './agent.js';
|
|
2
|
+
export type { AgentSigningKey, Interaction, InteractionHandler, InvokeArgs, InvokeResult, ProxyConfig, } from './agent.js';
|
|
3
|
+
export { buildProxyTools } from './tools.js';
|
|
4
|
+
export type { ProxyDeps, InteractionContext } from './tools.js';
|
|
5
|
+
export type { BootstrapStatus, IdentityProvider } from './identity.js';
|
|
6
|
+
export { canonicalizeHost } from './host.js';
|
|
7
|
+
export type { CanonicalHost } from './host.js';
|
|
8
|
+
export { createMemoryDocCache, fetchResource, getOperationsForResource, listOperationsForResource, routeOperation, toL1Entry, } from './resource.js';
|
|
9
|
+
export type { AAuthResourceMeta, DocCache, FetchedResource, PickedVocab, RoutedOperation, } from './resource.js';
|
|
10
|
+
export { createFsRegistryCache, fetchRegistry, registryUrl } from './registry.js';
|
|
11
|
+
export type { CachedIndex, RegistryCache, RegistryEntry, RegistryIndex } from './registry.js';
|
|
12
|
+
export { createFsL1Store } from './store.js';
|
|
13
|
+
export type { AccessMode, L1Entry, L1Store } from './store.js';
|
|
14
|
+
export * from './vocab/index.js';
|
|
15
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,gBAAgB,EAAE,wBAAwB,EAAE,MAAM,YAAY,CAAA;AACvE,YAAY,EACV,eAAe,EACf,WAAW,EACX,kBAAkB,EAClB,UAAU,EACV,YAAY,EACZ,WAAW,GACZ,MAAM,YAAY,CAAA;AAEnB,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAC5C,YAAY,EAAE,SAAS,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAA;AAE/D,YAAY,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAA;AAEtE,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAA;AAC5C,YAAY,EAAE,aAAa,EAAE,MAAM,WAAW,CAAA;AAE9C,OAAO,EACL,oBAAoB,EACpB,aAAa,EACb,wBAAwB,EACxB,yBAAyB,EACzB,cAAc,EACd,SAAS,GACV,MAAM,eAAe,CAAA;AACtB,YAAY,EACV,iBAAiB,EACjB,QAAQ,EACR,eAAe,EACf,WAAW,EACX,eAAe,GAChB,MAAM,eAAe,CAAA;AAEtB,OAAO,EAAE,qBAAqB,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AACjF,YAAY,EAAE,WAAW,EAAE,aAAa,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;AAE7F,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAC5C,YAAY,EAAE,UAAU,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAA;AAE9D,cAAc,kBAAkB,CAAA"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// Public API for @aauth/proxy (core, workerd-safe — no fs/stdio/local-keys at
|
|
2
|
+
// import time). Consumers get the agent flow, the transport-agnostic tool
|
|
3
|
+
// factory, the injectable storage/identity ports, and the default filesystem
|
|
4
|
+
// adapters. The Node-only @aauth/local-keys identity adapter is exported
|
|
5
|
+
// separately from "@aauth/proxy/local".
|
|
6
|
+
export { invokeAtResource, invokeAtResourceComplete } from './agent.js';
|
|
7
|
+
export { buildProxyTools } from './tools.js';
|
|
8
|
+
export { canonicalizeHost } from './host.js';
|
|
9
|
+
export { createMemoryDocCache, fetchResource, getOperationsForResource, listOperationsForResource, routeOperation, toL1Entry, } from './resource.js';
|
|
10
|
+
export { createFsRegistryCache, fetchRegistry, registryUrl } from './registry.js';
|
|
11
|
+
export { createFsL1Store } from './store.js';
|
|
12
|
+
export * from './vocab/index.js';
|
|
13
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,0EAA0E;AAC1E,6EAA6E;AAC7E,yEAAyE;AACzE,wCAAwC;AAExC,OAAO,EAAE,gBAAgB,EAAE,wBAAwB,EAAE,MAAM,YAAY,CAAA;AAUvE,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAK5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAA;AAG5C,OAAO,EACL,oBAAoB,EACpB,aAAa,EACb,wBAAwB,EACxB,yBAAyB,EACzB,cAAc,EACd,SAAS,GACV,MAAM,eAAe,CAAA;AAStB,OAAO,EAAE,qBAAqB,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAGjF,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAG5C,cAAc,kBAAkB,CAAA"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { ProxyConfig } from './agent.js';
|
|
2
|
+
import type { AccessMode } from './store.js';
|
|
3
|
+
export interface RegistryEntry {
|
|
4
|
+
issuer: string;
|
|
5
|
+
name: string;
|
|
6
|
+
description: string;
|
|
7
|
+
access_mode: AccessMode;
|
|
8
|
+
logo_uri?: string;
|
|
9
|
+
added: string;
|
|
10
|
+
submitted_by?: {
|
|
11
|
+
agent: string;
|
|
12
|
+
ap: string;
|
|
13
|
+
user?: string;
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
export interface RegistryIndex {
|
|
17
|
+
updated: string;
|
|
18
|
+
resources: RegistryEntry[];
|
|
19
|
+
}
|
|
20
|
+
export interface CachedIndex {
|
|
21
|
+
etag?: string;
|
|
22
|
+
fetched: string;
|
|
23
|
+
index: RegistryIndex;
|
|
24
|
+
}
|
|
25
|
+
export interface RegistryCache {
|
|
26
|
+
read(): Promise<CachedIndex | undefined>;
|
|
27
|
+
write(c: CachedIndex): Promise<void>;
|
|
28
|
+
}
|
|
29
|
+
export declare function registryUrl(): string;
|
|
30
|
+
export declare function createFsRegistryCache(opts?: {
|
|
31
|
+
dir?: string;
|
|
32
|
+
}): RegistryCache;
|
|
33
|
+
export declare function fetchRegistry(cfg: ProxyConfig, cache: RegistryCache): Promise<RegistryIndex>;
|
|
34
|
+
//# sourceMappingURL=registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../src/registry.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AAC7C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAE5C,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,MAAM,CAAA;IACd,IAAI,EAAE,MAAM,CAAA;IACZ,WAAW,EAAE,MAAM,CAAA;IACnB,WAAW,EAAE,UAAU,CAAA;IACvB,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,KAAK,EAAE,MAAM,CAAA;IACb,YAAY,CAAC,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,EAAE,EAAE,MAAM,CAAC;QAAC,IA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