@superforge/infra 0.4.0 → 0.5.0
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 +49 -26
- package/output/agents.d.ts +2 -2
- package/output/agents.js +3 -2
- package/output/choose.d.ts +1 -1
- package/output/choose.js +3 -3
- package/output/client.d.ts +1 -1
- package/output/client.js +1 -1
- package/output/contract/agents.d.ts +3 -12
- package/output/contract/agents.js +10 -2
- package/output/contract/all.d.ts +6 -0
- package/output/contract/all.js +9 -0
- package/output/contract/index.d.ts +5 -6
- package/output/contract/index.js +16 -11
- package/output/contract/login.d.ts +3 -7
- package/output/contract/login.js +5 -3
- package/output/index.d.ts +4 -5
- package/output/index.js +14 -15
- package/output/infra.d.ts +1 -1
- package/output/stand-in.d.ts +11 -6
- package/output/stand-in.js +11 -6
- package/output/version.d.ts +2 -2
- package/output/version.js +1 -1
- package/package.json +4 -7
package/README.md
CHANGED
|
@@ -7,14 +7,14 @@ for. It's the one way an app reaches Infra: a typed client, the stand-in
|
|
|
7
7
|
an app's tests and a fresh dev server use in its place, and the choice
|
|
8
8
|
between them. Infra's own API reference, each call with its fields and
|
|
9
9
|
errors, isn't public: an agent reads it with the Superforge MCP's
|
|
10
|
-
`read_infra_docs`. Everything an app calls is below
|
|
11
|
-
answer is a zod schema in `@superforge/infra/contract`.
|
|
10
|
+
`read_infra_docs`. Everything an app calls is below.
|
|
12
11
|
|
|
13
12
|
```bash
|
|
14
|
-
pnpm add @superforge/infra
|
|
13
|
+
pnpm add @superforge/infra
|
|
15
14
|
```
|
|
16
15
|
|
|
17
|
-
It needs Node 22 or later
|
|
16
|
+
It needs Node 22 or later. It brings its own zod 4, so an app can be on any
|
|
17
|
+
zod, and move to the next one without waiting for the package.
|
|
18
18
|
|
|
19
19
|
## Using it
|
|
20
20
|
|
|
@@ -119,19 +119,20 @@ that passes on what it was sent can't reach another of Infra's addresses.
|
|
|
119
119
|
- **`APP_PATHS`** (`{ oauth: "/oauth", allow: "/connect" }`) is where the
|
|
120
120
|
app answers Claude's login; an app that keeps it elsewhere gives
|
|
121
121
|
`chooseInfra` its own `paths`.
|
|
122
|
-
- **`
|
|
123
|
-
|
|
122
|
+
- **`AGENT_SCOPES`** (`["read", "act"]`) is what someone lets Claude do.
|
|
123
|
+
An app that checks scopes with zod builds its own list from it,
|
|
124
|
+
`z.enum(AGENT_SCOPES)`, with its own zod.
|
|
124
125
|
|
|
125
126
|
### `infraClient`
|
|
126
127
|
|
|
127
128
|
`infraClient({ key, url?, send?, paths? })` is the real Infra, which
|
|
128
129
|
`chooseInfra` makes; an app calls it itself only to point a test at a fake
|
|
129
|
-
of Infra (`send` is `fetch`, or the test's own; `url` is
|
|
130
|
-
|
|
130
|
+
of Infra (`send` is `fetch`, or the test's own; `url` is Infra's own
|
|
131
|
+
address unless set).
|
|
131
132
|
|
|
132
133
|
### The stand-in, for tests
|
|
133
134
|
|
|
134
|
-
`standInInfra({
|
|
135
|
+
`standInInfra({ domains? })` is Infra's test mode in
|
|
135
136
|
memory: login sends nothing and answers the code and the link, which
|
|
136
137
|
verify as Infra's do (once each, for 15 minutes, a code for five tries),
|
|
137
138
|
and links, as Infra's do, only to this computer and the project's
|
|
@@ -144,11 +145,22 @@ app's tests use it, so they never reach Infra.
|
|
|
144
145
|
|
|
145
146
|
### The contract
|
|
146
147
|
|
|
147
|
-
`@superforge/infra/contract
|
|
148
|
-
|
|
149
|
-
call's
|
|
150
|
-
`
|
|
151
|
-
|
|
148
|
+
`@superforge/infra/contract` is Infra's contract with nothing of Node's, so
|
|
149
|
+
a page can import it: the constants and types every call is made of, every
|
|
150
|
+
reason a call is refused, Infra's (`INFRA_ERRORS`) and the package's own
|
|
151
|
+
(`CLIENT_ERRORS`), and the zod schemas of what Infra is sent (`login_start`,
|
|
152
|
+
`login_verify`, `filed_comment`, `agent_allow`, `connections_query`), which
|
|
153
|
+
Infra checks with, with the two answers Infra's own server ties itself to
|
|
154
|
+
(`started_login`, `verified_login`). The package itself exports the same
|
|
155
|
+
constants and types, and no schema.
|
|
156
|
+
|
|
157
|
+
A schema here is made with the package's own zod: parse with it as it is,
|
|
158
|
+
and never put it inside a schema of the app's own, which may be another
|
|
159
|
+
zod's and then fails. Build the app's own from the constants instead.
|
|
160
|
+
|
|
161
|
+
Every name either entry exports is a promise: from 1.0.0 on, taking one
|
|
162
|
+
away is a major. So they export only what an app or Infra's server uses;
|
|
163
|
+
the rest is the package's own.
|
|
152
164
|
|
|
153
165
|
## When something goes wrong
|
|
154
166
|
|
|
@@ -181,11 +193,14 @@ should only learn that login isn't working.
|
|
|
181
193
|
|
|
182
194
|
## What every call tells Infra
|
|
183
195
|
|
|
184
|
-
Every call, Claude's OAuth calls passed through
|
|
185
|
-
`Infra-Client: @superforge/infra/<version
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
196
|
+
Every call, Claude's OAuth calls passed through and the fetch of Infra's
|
|
197
|
+
public keys included, carries `Infra-Client: @superforge/infra/<version>`
|
|
198
|
+
(`CLIENT_HEADER`, in the contract), so Infra knows which version each app
|
|
199
|
+
is on. That release is the version Infra answers the call as: once Infra
|
|
200
|
+
changes an answer, a release from before the change still gets the shape
|
|
201
|
+
it reads. A call that names no release, like one from a terminal, is
|
|
202
|
+
answered as the oldest release Infra still answers. The version is written
|
|
203
|
+
in `source/version.ts`, which a test checks against `package.json`.
|
|
189
204
|
|
|
190
205
|
## Releases
|
|
191
206
|
|
|
@@ -208,6 +223,13 @@ renames or drops one an app's release calls, so a release keeps working
|
|
|
208
223
|
until the app takes the next. Until 1.0.0 it keeps no older shapes: an app
|
|
209
224
|
takes the latest release.
|
|
210
225
|
|
|
226
|
+
A release reads what Infra adds without breaking: a field it doesn't know
|
|
227
|
+
is dropped, a 429's `limit` is read as any name, and a request's or a
|
|
228
|
+
connection's `scopes` keep only the scopes the release knows. A refusal
|
|
229
|
+
whose `reason` it doesn't know is `unavailable`, with Infra's `message`.
|
|
230
|
+
`mode` and a login's `channel` stay closed lists: an app only meets a new
|
|
231
|
+
one once it asks for it.
|
|
232
|
+
|
|
211
233
|
## Working on it
|
|
212
234
|
|
|
213
235
|
```bash
|
|
@@ -220,13 +242,14 @@ checkout at this folder (`pnpm add @superforge/infra@link:<path to this
|
|
|
220
242
|
folder>`), and back to the released version before its PR: a `link:` is
|
|
221
243
|
this computer's alone, and CI can't install it.
|
|
222
244
|
|
|
223
|
-
- `source/index.ts`: everything the package exports.
|
|
224
|
-
- `source/contract/`: Infra's contract,
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
`
|
|
229
|
-
|
|
245
|
+
- `source/index.ts`: everything the package exports, by name.
|
|
246
|
+
- `source/contract/`: Infra's contract, with nothing of Node's: every
|
|
247
|
+
call's request and answer as zod schemas, which Infra checks what it's
|
|
248
|
+
sent with, and every reason it refuses one (`errors.ts`), a file per
|
|
249
|
+
area: `login.ts`, `comments.ts`, `agents.ts`, `project.ts` and
|
|
250
|
+
`people.ts` (`user_id`, the app's ID for one of its people).
|
|
251
|
+
`index.ts` is what `@superforge/infra/contract` exports, by name;
|
|
252
|
+
`all.ts` is all of it, which only the package itself imports.
|
|
230
253
|
- `source/infra.ts`: `Infra`, what an app asks of it, and its results.
|
|
231
254
|
- `source/client.ts`: Infra over HTTP with a project's key, its answers
|
|
232
255
|
parsed with the contract and every one logged. No call is retried: a
|
package/output/agents.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type JWTVerifyGetKey } from "jose";
|
|
2
|
-
import { type AppPaths, type KeyMode, type OAuthCall } from "./contract/
|
|
2
|
+
import { type AppPaths, type KeyMode, type OAuthCall } from "./contract/all.js";
|
|
3
3
|
import type { AgentToken, AgentTokenRefused, InfraUnavailable } from "./infra.js";
|
|
4
4
|
import type { AsyncOperationResult } from "./results.js";
|
|
5
5
|
/**
|
|
@@ -70,7 +70,7 @@ export declare function passOAuth({ url, key, send, paths, request, call, origin
|
|
|
70
70
|
export declare function unavailableOAuth(message: string): Response;
|
|
71
71
|
/**
|
|
72
72
|
* Where a token's signature is checked: Infra's published public keys,
|
|
73
|
-
* fetched with `send
|
|
73
|
+
* fetched with `send`, saying which release asks, as every call does
|
|
74
74
|
*/
|
|
75
75
|
export declare function infraKeys(url: string, send?: typeof fetch): JWTVerifyGetKey;
|
|
76
76
|
/**
|
package/output/agents.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createRemoteJWKSet, customFetch, errors, jwtVerify } from "jose";
|
|
2
|
-
import { AGENT_SCOPES, APP_ORIGIN_HEADER, agent_authorized, agent_claims, authorize_refused, CLIENT_HEADER, infra_failure, isLoopbackHost } from "./contract/
|
|
2
|
+
import { AGENT_SCOPES, APP_ORIGIN_HEADER, agent_authorized, agent_claims, authorize_refused, CLIENT_HEADER, infra_failure, isLoopbackHost } from "./contract/all.js";
|
|
3
3
|
import { CALL_TIMEOUT, SECOND } from "./primitives.js";
|
|
4
4
|
import { CLIENT } from "./version.js";
|
|
5
5
|
// Claude logging in to an app's own MCP, through Infra: Infra is the OAuth
|
|
@@ -211,10 +211,11 @@ export function unavailableOAuth(message) {
|
|
|
211
211
|
}
|
|
212
212
|
/**
|
|
213
213
|
* Where a token's signature is checked: Infra's published public keys,
|
|
214
|
-
* fetched with `send
|
|
214
|
+
* fetched with `send`, saying which release asks, as every call does
|
|
215
215
|
*/
|
|
216
216
|
export function infraKeys(url, send = fetch) {
|
|
217
217
|
return createRemoteJWKSet(new URL("/.well-known/jwks.json", new URL(url).origin), {
|
|
218
|
+
headers: { [CLIENT_HEADER]: CLIENT },
|
|
218
219
|
timeoutDuration: 10 * SECOND,
|
|
219
220
|
cooldownDuration: 30 * SECOND,
|
|
220
221
|
[customFetch]: send
|
package/output/choose.d.ts
CHANGED
package/output/choose.js
CHANGED
|
@@ -4,8 +4,8 @@ import { parseEnv } from "node:util";
|
|
|
4
4
|
import { z } from "zod";
|
|
5
5
|
import { unavailableOAuth } from "./agents.js";
|
|
6
6
|
import { INFRA_URL, infraClient } from "./client.js";
|
|
7
|
-
import { APP_PATHS, KEY_BODY, KEY_PREFIXES } from "./contract/
|
|
8
|
-
import {
|
|
7
|
+
import { APP_PATHS, KEY_BODY, KEY_PREFIXES } from "./contract/all.js";
|
|
8
|
+
import { standInWith } from "./stand-in.js";
|
|
9
9
|
// Which Infra the server calls, by what it runs as and the keys it has:
|
|
10
10
|
//
|
|
11
11
|
// | Runs as | Has | Calls |
|
|
@@ -101,7 +101,7 @@ export function chooseInfra({ development, environment, checkout, domains = [],
|
|
|
101
101
|
console.info("Infra: no test key, so login uses the stand-in, which emails nothing");
|
|
102
102
|
}
|
|
103
103
|
return {
|
|
104
|
-
infra:
|
|
104
|
+
infra: standInWith({
|
|
105
105
|
waiting: devServerLogins(),
|
|
106
106
|
logs: true,
|
|
107
107
|
domains
|
package/output/client.d.ts
CHANGED
package/output/client.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { checkToken, infraKeys, passOAuth } from "./agents.js";
|
|
2
|
-
import { AGENT_ID, APP_PATHS, agent_connections, agent_ended, agent_redirect, agent_refused, agent_request, CLIENT_HEADER, comment_refused, infra_failure, infra_project, kept_comment, start_refused, started_login, verified_login, verify_refused } from "./contract/
|
|
2
|
+
import { AGENT_ID, APP_PATHS, agent_connections, agent_ended, agent_redirect, agent_refused, agent_request, CLIENT_HEADER, comment_refused, infra_failure, infra_project, kept_comment, start_refused, started_login, verified_login, verify_refused } from "./contract/all.js";
|
|
3
3
|
import { CALL_TIMEOUT } from "./primitives.js";
|
|
4
4
|
import { CLIENT } from "./version.js";
|
|
5
5
|
/** Infra's API, which a project's keys call */
|
|
@@ -103,10 +103,7 @@ export declare const agent_request: z.ZodObject<{
|
|
|
103
103
|
request: z.ZodObject<{
|
|
104
104
|
id: z.ZodString;
|
|
105
105
|
client_name: z.ZodString;
|
|
106
|
-
scopes: z.ZodArray<z.
|
|
107
|
-
read: "read";
|
|
108
|
-
act: "act";
|
|
109
|
-
}>>;
|
|
106
|
+
scopes: z.ZodPipe<z.ZodArray<z.ZodString>, z.ZodTransform<("read" | "act")[], string[]>>;
|
|
110
107
|
resource: z.ZodString;
|
|
111
108
|
expires_at: z.ZodPipe<z.ZodISODateTime, z.ZodTransform<Date, string>>;
|
|
112
109
|
}, z.core.$strip>;
|
|
@@ -134,10 +131,7 @@ export declare const agent_connection: z.ZodObject<{
|
|
|
134
131
|
id: z.ZodString;
|
|
135
132
|
user_id: z.ZodString;
|
|
136
133
|
client_name: z.ZodString;
|
|
137
|
-
scopes: z.ZodArray<z.
|
|
138
|
-
read: "read";
|
|
139
|
-
act: "act";
|
|
140
|
-
}>>;
|
|
134
|
+
scopes: z.ZodPipe<z.ZodArray<z.ZodString>, z.ZodTransform<("read" | "act")[], string[]>>;
|
|
141
135
|
resource: z.ZodString;
|
|
142
136
|
last_used_at: z.ZodPipe<z.ZodISODateTime, z.ZodTransform<Date, string>>;
|
|
143
137
|
created_at: z.ZodPipe<z.ZodISODateTime, z.ZodTransform<Date, string>>;
|
|
@@ -149,10 +143,7 @@ export declare const agent_connections: z.ZodObject<{
|
|
|
149
143
|
id: z.ZodString;
|
|
150
144
|
user_id: z.ZodString;
|
|
151
145
|
client_name: z.ZodString;
|
|
152
|
-
scopes: z.ZodArray<z.
|
|
153
|
-
read: "read";
|
|
154
|
-
act: "act";
|
|
155
|
-
}>>;
|
|
146
|
+
scopes: z.ZodPipe<z.ZodArray<z.ZodString>, z.ZodTransform<("read" | "act")[], string[]>>;
|
|
156
147
|
resource: z.ZodString;
|
|
157
148
|
last_used_at: z.ZodPipe<z.ZodISODateTime, z.ZodTransform<Date, string>>;
|
|
158
149
|
created_at: z.ZodPipe<z.ZodISODateTime, z.ZodTransform<Date, string>>;
|
|
@@ -12,6 +12,14 @@ import { key_mode } from "./project.js";
|
|
|
12
12
|
/** What someone on the app's team lets Claude do through its MCP */
|
|
13
13
|
export const AGENT_SCOPES = ["read", "act"];
|
|
14
14
|
export const agent_scope = z.enum(AGENT_SCOPES);
|
|
15
|
+
/**
|
|
16
|
+
* Scopes as an answer carries them: whatever Infra says, keeping the ones
|
|
17
|
+
* this release knows, as the token check does. Infra may add a scope, and
|
|
18
|
+
* a release that can't read it would find the whole answer unreadable.
|
|
19
|
+
*/
|
|
20
|
+
const known_scopes = z
|
|
21
|
+
.array(z.string())
|
|
22
|
+
.transform((scopes) => AGENT_SCOPES.filter((scope) => scopes.includes(scope)));
|
|
15
23
|
/**
|
|
16
24
|
* The header the app's server sends Claude's OAuth calls on with: where
|
|
17
25
|
* Claude reached the app, `https://example.com`, its tokens' issuer.
|
|
@@ -47,7 +55,7 @@ export const agent_request = z.object({
|
|
|
47
55
|
request: z.object({
|
|
48
56
|
id: z.string(),
|
|
49
57
|
client_name: z.string(),
|
|
50
|
-
scopes:
|
|
58
|
+
scopes: known_scopes,
|
|
51
59
|
// The address Claude asked to use, which its tokens are good for:
|
|
52
60
|
// the app's MCP
|
|
53
61
|
resource: z.string(),
|
|
@@ -72,7 +80,7 @@ export const agent_connection = z.object({
|
|
|
72
80
|
id: z.string(),
|
|
73
81
|
user_id: z.string(),
|
|
74
82
|
client_name: z.string(),
|
|
75
|
-
scopes:
|
|
83
|
+
scopes: known_scopes,
|
|
76
84
|
resource: z.string(),
|
|
77
85
|
// When Claude last refreshed it, to within about ten minutes
|
|
78
86
|
last_used_at: z.iso
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// Every schema and constant of Infra's contract, public or not, which the
|
|
2
|
+
// package itself reads Infra's answers with. Only the package imports this
|
|
3
|
+
// file: what an app or Infra's server may import is index.ts.
|
|
4
|
+
export * from "./agents.js";
|
|
5
|
+
export * from "./comments.js";
|
|
6
|
+
export * from "./errors.js";
|
|
7
|
+
export * from "./login.js";
|
|
8
|
+
export * from "./people.js";
|
|
9
|
+
export * from "./project.js";
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
3
|
-
export
|
|
4
|
-
export
|
|
5
|
-
export
|
|
6
|
-
export * from "./project.js";
|
|
1
|
+
export { AGENT_ID, AGENT_SCOPES, type AgentAllow, type AgentConnection, type AgentRefused, type AgentRequest, type AgentScope, APP_ORIGIN_HEADER, APP_PATHS, type AppPaths, agent_allow, connections_query, OAUTH_CALLS, type OAuthCall } from "./agents.js";
|
|
2
|
+
export { COMMENT_BODY_LIMIT, type CommentRefused, type FiledComment, filed_comment, type KeptComment, LONGEST_COMMENT } from "./comments.js";
|
|
3
|
+
export { CLIENT_ERRORS, type ClientErrorReason, INFRA_ERRORS, type InfraErrorReason, type InfraIssue } from "./errors.js";
|
|
4
|
+
export { LOGIN_CHANNELS, type LoginChannel, type LoginProof, type LoginStart, login_start, login_verify, type StartedLogin, type StartRefused, started_login, type VerifiedLogin, type VerifyRefused, verified_login } from "./login.js";
|
|
5
|
+
export { CLIENT_HEADER, type InfraProject, isLoopbackHost, KEY_BODY, KEY_MODES, KEY_PREFIXES, type KeyMode, LOOPBACK_HOSTNAMES, PROJECT_ID_PREFIX } from "./project.js";
|
package/output/contract/index.js
CHANGED
|
@@ -1,11 +1,16 @@
|
|
|
1
|
-
// Infra's contract
|
|
2
|
-
// every
|
|
3
|
-
//
|
|
4
|
-
// runs in Node alone, so a page can import it
|
|
5
|
-
//
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
// Infra's contract, as `@superforge/infra/contract` exports it: the
|
|
2
|
+
// constants and types every call is made of, the schemas of what Infra is
|
|
3
|
+
// sent, which Infra checks with, and the two answers Infra's own server
|
|
4
|
+
// ties itself to. Nothing here runs in Node alone, so a page can import it
|
|
5
|
+
// too. Infra's README has the calls.
|
|
6
|
+
//
|
|
7
|
+
// Every name here is a promise: from 1.0.0 on, taking one away is a major.
|
|
8
|
+
// So a name is here only when an app or Infra's server needs it; the rest
|
|
9
|
+
// of contract/ is the package's own (all.ts). A schema here is made with
|
|
10
|
+
// the package's own zod: parse with it as it is, and never put it inside a
|
|
11
|
+
// schema of an app's, which may be another zod's.
|
|
12
|
+
export { AGENT_ID, AGENT_SCOPES, APP_ORIGIN_HEADER, APP_PATHS, agent_allow, connections_query, OAUTH_CALLS } from "./agents.js";
|
|
13
|
+
export { COMMENT_BODY_LIMIT, filed_comment, LONGEST_COMMENT } from "./comments.js";
|
|
14
|
+
export { CLIENT_ERRORS, INFRA_ERRORS } from "./errors.js";
|
|
15
|
+
export { LOGIN_CHANNELS, login_start, login_verify, started_login, verified_login } from "./login.js";
|
|
16
|
+
export { CLIENT_HEADER, isLoopbackHost, KEY_BODY, KEY_MODES, KEY_PREFIXES, LOOPBACK_HOSTNAMES, PROJECT_ID_PREFIX } from "./project.js";
|
|
@@ -51,23 +51,19 @@ export declare const start_refused: z.ZodUnion<readonly [z.ZodPipe<z.ZodObject<{
|
|
|
51
51
|
error: z.ZodObject<{
|
|
52
52
|
reason: z.ZodLiteral<"rate-limited">;
|
|
53
53
|
message: z.ZodString;
|
|
54
|
-
limit: z.
|
|
55
|
-
project: "project";
|
|
56
|
-
address: "address";
|
|
57
|
-
network: "network";
|
|
58
|
-
}>;
|
|
54
|
+
limit: z.ZodString;
|
|
59
55
|
retry_after: z.ZodNumber;
|
|
60
56
|
}, z.core.$strip>;
|
|
61
57
|
}, z.core.$strip>, z.ZodTransform<{
|
|
62
58
|
reason: "rate-limited";
|
|
63
59
|
message: string;
|
|
64
|
-
limit:
|
|
60
|
+
limit: string;
|
|
65
61
|
retry_after: number;
|
|
66
62
|
}, {
|
|
67
63
|
error: {
|
|
68
64
|
reason: "rate-limited";
|
|
69
65
|
message: string;
|
|
70
|
-
limit:
|
|
66
|
+
limit: string;
|
|
71
67
|
retry_after: number;
|
|
72
68
|
};
|
|
73
69
|
}>>, z.ZodPipe<z.ZodObject<{
|
package/output/contract/login.js
CHANGED
|
@@ -65,10 +65,12 @@ export const started_login = z.object({
|
|
|
65
65
|
});
|
|
66
66
|
/** Why `login/start` sent nothing */
|
|
67
67
|
export const start_refused = z.union([
|
|
68
|
-
// Over one of Infra's limits: this address (one a minute, five
|
|
69
|
-
// hour), the person's network, or the project's
|
|
68
|
+
// Over one of Infra's limits: today this address (one a minute, five
|
|
69
|
+
// an hour), the person's network, or the project's. Read as any name,
|
|
70
|
+
// since Infra may add a limit, and a release that can't read its name
|
|
71
|
+
// would answer "login isn't working" in place of "try again soon".
|
|
70
72
|
refusal("rate-limited", {
|
|
71
|
-
limit: z.
|
|
73
|
+
limit: z.string(),
|
|
72
74
|
retry_after: z.number()
|
|
73
75
|
}),
|
|
74
76
|
// The message didn't go out, and nothing was counted
|
package/output/index.d.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { requestOrigin } from "./agents.js";
|
|
2
2
|
export { chooseInfra, type InfraChoice } from "./choose.js";
|
|
3
|
-
export {
|
|
4
|
-
export
|
|
3
|
+
export { infraClient } from "./client.js";
|
|
4
|
+
export { AGENT_SCOPES, type AgentAllow, type AgentConnection, type AgentRefused, type AgentRequest, type AgentScope, APP_PATHS, type AppPaths, type ClientErrorReason, type CommentRefused, type FiledComment, type InfraErrorReason, type InfraIssue, type InfraProject, type KeptComment, type KeyMode, type LoginChannel, type LoginProof, type LoginStart, OAUTH_CALLS, type OAuthCall, type StartedLogin, type StartRefused, type VerifiedLogin, type VerifyRefused } from "./contract/index.js";
|
|
5
5
|
export type { AgentToken, AgentTokenRefused, Infra, InfraUnavailable } from "./infra.js";
|
|
6
6
|
export type { AsyncOperationResult, OperationResult } from "./results.js";
|
|
7
|
-
export { standInAgentToken, standInInfra
|
|
8
|
-
export { PACKAGE_VERSION } from "./version.js";
|
|
7
|
+
export { standInAgentToken, standInInfra } from "./stand-in.js";
|
package/output/index.js
CHANGED
|
@@ -1,19 +1,18 @@
|
|
|
1
1
|
// @superforge/infra: Superforge Infra, the backend services Foundation and
|
|
2
2
|
// Skylevel apps run on, as an app's server calls it. README.md has how an
|
|
3
|
-
// app uses it.
|
|
4
|
-
//
|
|
5
|
-
//
|
|
6
|
-
//
|
|
7
|
-
//
|
|
8
|
-
|
|
9
|
-
//
|
|
10
|
-
|
|
11
|
-
// the
|
|
3
|
+
// app uses it.
|
|
4
|
+
//
|
|
5
|
+
// Every name here is a promise: from 1.0.0 on, taking one away is a major.
|
|
6
|
+
// So the package exports what an app calls, its constants and its types,
|
|
7
|
+
// and no zod schema: those are at `@superforge/infra/contract` alone
|
|
8
|
+
// (contract/index.ts), made with the package's own zod.
|
|
9
|
+
// Where a request reached the app, which every token Claude holds is bound to
|
|
10
|
+
export { requestOrigin } from "./agents.js";
|
|
11
|
+
// Calling Infra: the real one over HTTP with a project's key, chosen by
|
|
12
|
+
// how the server runs and the keys it has, or the stand-in, Infra's test
|
|
13
|
+
// mode in memory, which an app's tests use
|
|
12
14
|
export { chooseInfra } from "./choose.js";
|
|
13
|
-
export {
|
|
14
|
-
//
|
|
15
|
-
|
|
16
|
-
export * from "./contract/index.js";
|
|
15
|
+
export { infraClient } from "./client.js";
|
|
16
|
+
// The constants and types of Infra's contract an app calls with
|
|
17
|
+
export { AGENT_SCOPES, APP_PATHS, OAUTH_CALLS } from "./contract/index.js";
|
|
17
18
|
export { standInAgentToken, standInInfra } from "./stand-in.js";
|
|
18
|
-
// Which release this is, which every call tells Infra in `Infra-Client`
|
|
19
|
-
export { PACKAGE_VERSION } from "./version.js";
|
package/output/infra.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { AgentAllow, AgentConnection, AgentRefused, AgentRequest, CommentRefused, FiledComment, InfraProject, KeptComment, LoginProof, LoginStart, OAuthCall, StartedLogin, StartRefused, VerifiedLogin, VerifyRefused } from "./contract/
|
|
1
|
+
import type { AgentAllow, AgentConnection, AgentRefused, AgentRequest, CommentRefused, FiledComment, InfraProject, KeptComment, LoginProof, LoginStart, OAuthCall, StartedLogin, StartRefused, VerifiedLogin, VerifyRefused } from "./contract/all.js";
|
|
2
2
|
import type { AsyncOperationResult } from "./results.js";
|
|
3
3
|
/** What an app asks of Infra, whichever answers: the real one or the stand-in */
|
|
4
4
|
export type Infra = {
|
package/output/stand-in.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type AgentScope } from "./contract/
|
|
1
|
+
import { type AgentScope } from "./contract/all.js";
|
|
2
2
|
import type { Infra } from "./infra.js";
|
|
3
3
|
/** A login the stand-in sent, waiting to be verified, by its address */
|
|
4
4
|
export type WaitingLogin = {
|
|
@@ -23,12 +23,17 @@ export type WaitingLogin = {
|
|
|
23
23
|
* always its words, which aren't contract. Like Infra, it links only to
|
|
24
24
|
* this computer and the project's `domains`, over https, and answers
|
|
25
25
|
* `with_link: false` for any other host.
|
|
26
|
-
*
|
|
27
|
-
* `waiting` is where it keeps what it sent, by address: its own, or one
|
|
28
|
-
* that outlives a dev server's reloads. With `logs`, as a dev server has
|
|
29
|
-
* it, each comment is logged, since nothing keeps it.
|
|
30
26
|
*/
|
|
31
|
-
export declare function standInInfra({
|
|
27
|
+
export declare function standInInfra({ domains }?: {
|
|
28
|
+
domains?: string[];
|
|
29
|
+
}): Infra;
|
|
30
|
+
/**
|
|
31
|
+
* The stand-in as the package itself makes it, a dev server's in
|
|
32
|
+
* choose.ts: `waiting` is where it keeps what it sent, by address, its own
|
|
33
|
+
* or one that outlives a dev server's reloads. With `logs`, as a dev
|
|
34
|
+
* server has it, each comment is logged, since nothing keeps it.
|
|
35
|
+
*/
|
|
36
|
+
export declare function standInWith({ waiting, logs, domains }?: {
|
|
32
37
|
waiting?: Map<string, WaitingLogin>;
|
|
33
38
|
logs?: boolean;
|
|
34
39
|
domains?: string[];
|
package/output/stand-in.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createLocalJWKSet, exportJWK, generateKeyPair, SignJWT } from "jose";
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
import { checkToken, unavailableOAuth } from "./agents.js";
|
|
4
|
-
import { COMMENT_BODY_LIMIT, filed_comment, isLoopbackHost, login_start, login_verify } from "./contract/
|
|
4
|
+
import { COMMENT_BODY_LIMIT, filed_comment, isLoopbackHost, login_start, login_verify } from "./contract/all.js";
|
|
5
5
|
import { MINUTE, randomToken } from "./primitives.js";
|
|
6
6
|
// How Infra treats a code: it works for 15 minutes and five tries, and a
|
|
7
7
|
// new one for the same address replaces it, link and all
|
|
@@ -22,12 +22,17 @@ const ATTEMPTS = 5;
|
|
|
22
22
|
* always its words, which aren't contract. Like Infra, it links only to
|
|
23
23
|
* this computer and the project's `domains`, over https, and answers
|
|
24
24
|
* `with_link: false` for any other host.
|
|
25
|
-
*
|
|
26
|
-
* `waiting` is where it keeps what it sent, by address: its own, or one
|
|
27
|
-
* that outlives a dev server's reloads. With `logs`, as a dev server has
|
|
28
|
-
* it, each comment is logged, since nothing keeps it.
|
|
29
25
|
*/
|
|
30
|
-
export function standInInfra({
|
|
26
|
+
export function standInInfra({ domains = [] } = {}) {
|
|
27
|
+
return standInWith({ domains });
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* The stand-in as the package itself makes it, a dev server's in
|
|
31
|
+
* choose.ts: `waiting` is where it keeps what it sent, by address, its own
|
|
32
|
+
* or one that outlives a dev server's reloads. With `logs`, as a dev
|
|
33
|
+
* server has it, each comment is logged, since nothing keeps it.
|
|
34
|
+
*/
|
|
35
|
+
export function standInWith({ waiting = new Map(), logs = false, domains = [] } = {}) {
|
|
31
36
|
return {
|
|
32
37
|
async project() {
|
|
33
38
|
return {
|
package/output/version.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/** The package's version, as package.json says it */
|
|
2
|
-
export declare const PACKAGE_VERSION = "0.
|
|
2
|
+
export declare const PACKAGE_VERSION = "0.5.0";
|
|
3
3
|
/** What it says: the package and its version, `@superforge/infra/<version>` */
|
|
4
|
-
export declare const CLIENT = "@superforge/infra/0.
|
|
4
|
+
export declare const CLIENT = "@superforge/infra/0.5.0";
|
package/output/version.js
CHANGED
|
@@ -5,6 +5,6 @@
|
|
|
5
5
|
// package away from its package.json; a test checks the two agree, so a
|
|
6
6
|
// release that bumps one and not the other fails `pnpm check`.
|
|
7
7
|
/** The package's version, as package.json says it */
|
|
8
|
-
export const PACKAGE_VERSION = "0.
|
|
8
|
+
export const PACKAGE_VERSION = "0.5.0";
|
|
9
9
|
/** What it says: the package and its version, `@superforge/infra/<version>` */
|
|
10
10
|
export const CLIENT = `@superforge/infra/${PACKAGE_VERSION}`;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@superforge/infra",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "Superforge Infra, the backend services Foundation and Skylevel apps run on, as an app's server calls it",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -37,17 +37,14 @@
|
|
|
37
37
|
"prepublishOnly": "pnpm check"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"jose": "^6.2.15"
|
|
41
|
-
|
|
42
|
-
"peerDependencies": {
|
|
43
|
-
"zod": "^4.6.7"
|
|
40
|
+
"jose": "^6.2.15",
|
|
41
|
+
"zod": "^4.0.0"
|
|
44
42
|
},
|
|
45
43
|
"devDependencies": {
|
|
46
44
|
"@biomejs/biome": "^2.6.2",
|
|
47
45
|
"@types/node": "^22.10.2",
|
|
48
46
|
"hono": "^4.13.13",
|
|
49
47
|
"typescript": "^6.0.2",
|
|
50
|
-
"vitest": "^5.0.5"
|
|
51
|
-
"zod": "^4.6.7"
|
|
48
|
+
"vitest": "^5.0.5"
|
|
52
49
|
}
|
|
53
50
|
}
|