@every-app/sdk 0.3.0-rc.8 → 0.3.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 +75 -74
- package/dist/cloudflare/catalogSettings.generated.d.ts +20 -6
- package/dist/cloudflare/catalogSettings.generated.d.ts.map +1 -1
- package/dist/cloudflare/catalogSettings.generated.js +45 -14
- package/dist/cloudflare/index.d.ts +1 -1
- package/dist/cloudflare/index.d.ts.map +1 -1
- package/dist/cloudflare/sentinel.d.ts +3 -0
- package/dist/cloudflare/sentinel.d.ts.map +1 -1
- package/dist/cloudflare/sentinel.js +10 -0
- package/dist/cloudflare/worker.d.ts +67 -23
- package/dist/cloudflare/worker.d.ts.map +1 -1
- package/dist/cloudflare/worker.js +68 -32
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/internal/aiDefault.d.ts +36 -79
- package/dist/internal/aiDefault.d.ts.map +1 -1
- package/dist/internal/aiDefault.js +47 -149
- package/dist/internal/aiProviders.d.ts +1 -1
- package/dist/internal/aiProviders.d.ts.map +1 -1
- package/dist/internal/aiProviders.js +2 -2
- package/dist/internal/appSettings.d.ts +140 -89
- package/dist/internal/appSettings.d.ts.map +1 -1
- package/dist/internal/appSettings.js +264 -156
- package/dist/internal/capabilities.d.ts +145 -503
- package/dist/internal/capabilities.d.ts.map +1 -1
- package/dist/internal/capabilities.js +29 -550
- package/dist/internal/catalog/commerce.js +1 -1
- package/dist/internal/catalog/comms.d.ts +37 -0
- package/dist/internal/catalog/comms.d.ts.map +1 -1
- package/dist/internal/catalog/comms.js +43 -0
- package/dist/internal/catalog/index.d.ts +72 -0
- package/dist/internal/catalog/index.d.ts.map +1 -1
- package/dist/internal/catalog/infra.d.ts +35 -0
- package/dist/internal/catalog/infra.d.ts.map +1 -1
- package/dist/internal/catalog/infra.js +65 -0
- package/dist/internal/devProviders.d.ts +1 -19
- package/dist/internal/devProviders.d.ts.map +1 -1
- package/dist/internal/devProviders.js +7 -1
- package/dist/internal/events.d.ts +52 -1
- package/dist/internal/events.d.ts.map +1 -1
- package/dist/internal/events.js +66 -2
- package/dist/internal/gatewaySettings.d.ts +6 -16
- package/dist/internal/gatewaySettings.d.ts.map +1 -1
- package/dist/internal/gatewaySettings.js +6 -24
- package/dist/internal/index.d.ts +1 -0
- package/dist/internal/index.d.ts.map +1 -1
- package/dist/internal/index.js +1 -0
- package/dist/internal/mcpOAuth.d.ts +210 -0
- package/dist/internal/mcpOAuth.d.ts.map +1 -0
- package/dist/internal/mcpOAuth.js +735 -0
- package/dist/internal/oauthClient.d.ts +7 -47
- package/dist/internal/oauthClient.d.ts.map +1 -1
- package/dist/internal/oauthClient.js +1 -115
- package/dist/internal/oauthPresets.d.ts +356 -20
- package/dist/internal/oauthPresets.d.ts.map +1 -1
- package/dist/internal/oauthPresets.js +183 -861
- package/dist/internal/oauthScopes.d.ts +43 -155
- package/dist/internal/oauthScopes.d.ts.map +1 -1
- package/dist/internal/oauthScopes.js +82 -475
- package/dist/internal/oauthSpec.d.ts +28 -71
- package/dist/internal/oauthSpec.d.ts.map +1 -1
- package/dist/internal/oauthSpec.js +172 -448
- package/dist/internal/protocol.d.ts +39 -15
- package/dist/internal/protocol.d.ts.map +1 -1
- package/dist/internal/protocol.js +40 -7
- package/dist/internal/providerApps.d.ts +2 -2
- package/dist/internal/providerApps.js +2 -2
- package/dist/internal/providerRegistry.d.ts +5 -64
- package/dist/internal/providerRegistry.d.ts.map +1 -1
- package/dist/internal/providerRegistry.js +19 -118
- package/dist/internal/providerSpec.d.ts.map +1 -1
- package/dist/internal/providerSpec.js +14 -36
- package/dist/internal/remoteMcp.d.ts +191 -47
- package/dist/internal/remoteMcp.d.ts.map +1 -1
- package/dist/internal/remoteMcp.js +338 -133
- package/dist/internal/signInProviders.d.ts +1 -1
- package/dist/internal/signInProviders.d.ts.map +1 -1
- package/dist/internal/tools.d.ts +15 -8
- package/dist/internal/tools.d.ts.map +1 -1
- package/dist/internal/tools.js +9 -8
- package/dist/manifest.d.ts +96 -28
- package/dist/manifest.d.ts.map +1 -1
- package/dist/manifest.js +1 -1
- package/dist/server/ai.d.ts +1 -93
- package/dist/server/ai.d.ts.map +1 -1
- package/dist/server/ai.js +17 -111
- package/dist/server/attribution.d.ts +10 -1
- package/dist/server/attribution.d.ts.map +1 -1
- package/dist/server/attribution.js +7 -1
- package/dist/server/connectUrl.d.ts +4 -9
- package/dist/server/connectUrl.d.ts.map +1 -1
- package/dist/server/connectUrl.js +17 -14
- package/dist/server/context.d.ts +12 -14
- package/dist/server/context.d.ts.map +1 -1
- package/dist/server/context.js +23 -25
- package/dist/server/emit.d.ts.map +1 -1
- package/dist/server/emit.js +2 -2
- package/dist/server/env.d.ts +3 -0
- package/dist/server/env.d.ts.map +1 -1
- package/dist/server/eventsEndpoint.d.ts +48 -0
- package/dist/server/eventsEndpoint.d.ts.map +1 -0
- package/dist/server/eventsEndpoint.js +145 -0
- package/dist/server/everyApp.d.ts +16 -26
- package/dist/server/everyApp.d.ts.map +1 -1
- package/dist/server/everyApp.js +22 -46
- package/dist/server/gatewayFetch.d.ts +19 -1
- package/dist/server/gatewayFetch.d.ts.map +1 -1
- package/dist/server/gatewayFetch.js +45 -3
- package/dist/server/index.d.ts +6 -9
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/index.js +4 -8
- package/dist/server/integrationFetch.d.ts +60 -72
- package/dist/server/integrationFetch.d.ts.map +1 -1
- package/dist/server/integrationFetch.js +124 -397
- package/dist/server/listMembers.d.ts.map +1 -1
- package/dist/server/listMembers.js +2 -2
- package/dist/server/refusal.d.ts +0 -9
- package/dist/server/refusal.d.ts.map +1 -1
- package/dist/server/refusal.js +0 -22
- package/dist/server/sendEmail.d.ts.map +1 -1
- package/dist/server/sendEmail.js +2 -2
- package/dist/server/tools.d.ts +17 -6
- package/dist/server/tools.d.ts.map +1 -1
- package/dist/server/tools.js +14 -4
- package/dist/server/toolsEndpoint.d.ts +2 -1
- package/dist/server/toolsEndpoint.d.ts.map +1 -1
- package/dist/server/toolsEndpoint.js +4 -3
- package/dist/server/webhooks.d.ts +56 -0
- package/dist/server/webhooks.d.ts.map +1 -0
- package/dist/server/webhooks.js +205 -0
- package/dist/testing/index.d.ts +2 -3
- package/dist/testing/index.d.ts.map +1 -1
- package/dist/testing/index.js +2 -6
- package/package.json +6 -1
- package/dist/server/aiBinding.d.ts +0 -68
- package/dist/server/aiBinding.d.ts.map +0 -1
- package/dist/server/aiBinding.js +0 -294
- package/dist/server/authorizeUrl.d.ts +0 -43
- package/dist/server/authorizeUrl.d.ts.map +0 -1
- package/dist/server/authorizeUrl.js +0 -106
- package/dist/server/emailBinding.d.ts +0 -72
- package/dist/server/emailBinding.d.ts.map +0 -1
- package/dist/server/emailBinding.js +0 -124
- package/dist/server/fromMcpTools.d.ts +0 -89
- package/dist/server/fromMcpTools.d.ts.map +0 -1
- package/dist/server/fromMcpTools.js +0 -192
|
@@ -40,16 +40,14 @@ export declare const GATEWAY_ERROR_HEADER = "x-everyapp-error";
|
|
|
40
40
|
*/
|
|
41
41
|
export declare const ORG_HEADER = "x-everyapp-org";
|
|
42
42
|
/**
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
*
|
|
47
|
-
* `
|
|
48
|
-
*
|
|
49
|
-
*/
|
|
50
|
-
export declare const
|
|
51
|
-
/** The values {@link ACCOUNT_HEADER} may carry. */
|
|
52
|
-
export type ConnectionAccount = "user" | "organization";
|
|
43
|
+
* On background work's call to an OAuth provider's API: the member whose
|
|
44
|
+
* connection to this app the call uses. Set by `for: { background: true,
|
|
45
|
+
* userId }`; the gateway reads it on the held-token branch only, for an
|
|
46
|
+
* organization's own app, and the perimeter strips it, with every
|
|
47
|
+
* `x-everyapp-*`, from browsers. It addresses a connection; it is not a
|
|
48
|
+
* permission: connecting in the app already lets the app use it.
|
|
49
|
+
*/
|
|
50
|
+
export declare const USER_HEADER = "x-everyapp-user";
|
|
53
51
|
/** 120-second lifetime — caps revocation staleness while surviving clock skew. */
|
|
54
52
|
export declare const IDENTITY_TTL_SECONDS = 120;
|
|
55
53
|
/** System tokens are minted per call and live at most a minute. */
|
|
@@ -90,11 +88,25 @@ export declare const DEV_ORG_ID = "dev-org";
|
|
|
90
88
|
export declare const PUBLIC_MARKER_SUB = "public";
|
|
91
89
|
/** `sub` claim of gateway system tokens. */
|
|
92
90
|
export declare const SYSTEM_TOKEN_SUB = "system";
|
|
93
|
-
|
|
91
|
+
/**
|
|
92
|
+
* Linked dev (`everyapp dev --gateway`, docs/design/linked-dev.md): the
|
|
93
|
+
* dev Worker's env names the gateway-lite's loopback forwarder and the
|
|
94
|
+
* run's nonce, and the SDK builds a `{ fetch }` in place of the missing
|
|
95
|
+
* `EVERY_APP_GATEWAY` binding from them. Set by `everyAppWorker()` in a
|
|
96
|
+
* development build from the process environment `everyapp dev` starts
|
|
97
|
+
* the app with; never deployed.
|
|
98
|
+
*/
|
|
99
|
+
export declare const LINKED_DEV_URL_ENV = "EVERYAPP_LINKED_DEV_URL";
|
|
100
|
+
export declare const LINKED_DEV_NONCE_ENV = "EVERYAPP_LINKED_DEV_NONCE";
|
|
101
|
+
/** The header the forwarder requires, with the run's nonce: no simple cross-origin request can send it. */
|
|
102
|
+
export declare const LINKED_DEV_HEADER = "x-everyapp-linked-dev";
|
|
103
|
+
/** Where the gateway-lite serves the forwarder, under the app's own host. */
|
|
104
|
+
export declare const LINKED_DEV_FORWARD_PATH = "/__everyapp/gateway";
|
|
105
|
+
export type IdentityChannel = "web" | "api" | "mcp";
|
|
94
106
|
export type IdentityTokenType = "user" | "public" | "system";
|
|
95
107
|
/** What a system token may open. One purpose per token. */
|
|
96
|
-
export type SystemTokenPurpose = "tools.list";
|
|
97
|
-
/** The actor on whose behalf the request is made (user, MCP client
|
|
108
|
+
export type SystemTokenPurpose = "tools.list" | "events.deliver";
|
|
109
|
+
/** The actor on whose behalf the request is made (user, MCP client). */
|
|
98
110
|
export interface IdentityActor {
|
|
99
111
|
sub: string;
|
|
100
112
|
}
|
|
@@ -135,12 +147,15 @@ export interface EveryAppUser {
|
|
|
135
147
|
*/
|
|
136
148
|
orgName?: string;
|
|
137
149
|
channel: IdentityChannel;
|
|
138
|
-
/**
|
|
150
|
+
/**
|
|
151
|
+
* The acting principal: the user id, the credential acting for them
|
|
152
|
+
* (`pat:<id>`, `oauth:<id>`, `access:<email>`).
|
|
153
|
+
*/
|
|
139
154
|
actor: IdentityActor;
|
|
140
155
|
scopes: string[];
|
|
141
156
|
jti: string;
|
|
142
157
|
/**
|
|
143
|
-
* Set only on
|
|
158
|
+
* Set only on a tool call (`channel: "mcp"`): the one call this
|
|
144
159
|
* identity was minted for.
|
|
145
160
|
*/
|
|
146
161
|
toolCall?: ToolCallClaim;
|
|
@@ -163,6 +178,11 @@ export interface SystemClaims extends JWTPayload {
|
|
|
163
178
|
typ: "system";
|
|
164
179
|
purpose: SystemTokenPurpose;
|
|
165
180
|
jti: string;
|
|
181
|
+
/**
|
|
182
|
+
* `events.deliver` only: the SHA-256 (base64url) of the request body the
|
|
183
|
+
* token was minted for, so it opens that one delivery and nothing else.
|
|
184
|
+
*/
|
|
185
|
+
bh?: string;
|
|
166
186
|
}
|
|
167
187
|
export interface PublicMarkerClaims extends JWTPayload {
|
|
168
188
|
typ: "public";
|
|
@@ -234,7 +254,11 @@ export interface MintSystemTokenOptions {
|
|
|
234
254
|
now?: number;
|
|
235
255
|
/** Header kid. Defaults to the production kid; dev mints with the dev kid. */
|
|
236
256
|
keyId?: string;
|
|
257
|
+
/** `events.deliver`: the body's SHA-256, base64url ({@link bodyHash}). */
|
|
258
|
+
bodyHash?: string;
|
|
237
259
|
}
|
|
260
|
+
/** SHA-256 of a request body, base64url: what an `events.deliver` token's `bh` names. */
|
|
261
|
+
export declare function bodyHash(body: string): Promise<string>;
|
|
238
262
|
/**
|
|
239
263
|
* Mint the gateway's system token for `x-everyapp-system`: no user, one
|
|
240
264
|
* purpose, one app, one minute. The SDK only accepts it on the endpoint its
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"protocol.d.ts","sourceRoot":"","sources":["../../src/internal/protocol.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAwB,KAAK,UAAU,EAAE,MAAM,MAAM,CAAC;AAC7D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAEhD,eAAO,MAAM,YAAY,UAAU,CAAC;AACpC,eAAO,MAAM,eAAe,sBAAsB,CAAC;AACnD,eAAO,MAAM,mBAAmB,0BAA0B,CAAC;AAC3D;;;;GAIG;AACH,eAAO,MAAM,UAAU,kCAAkC,CAAC;AAC1D,eAAO,MAAM,eAAe,wBAAwB,CAAC;AACrD,eAAO,MAAM,aAAa,sBAAsB,CAAC;AACjD;;;;GAIG;AACH,eAAO,MAAM,aAAa,sBAAsB,CAAC;AACjD;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,qBAAqB,CAAC;AACvD;;;;;;;GAOG;AACH,eAAO,MAAM,UAAU,mBAAmB,CAAC;AAC3C;;;;;;;GAOG;AACH,eAAO,MAAM,
|
|
1
|
+
{"version":3,"file":"protocol.d.ts","sourceRoot":"","sources":["../../src/internal/protocol.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAwB,KAAK,UAAU,EAAE,MAAM,MAAM,CAAC;AAC7D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAEhD,eAAO,MAAM,YAAY,UAAU,CAAC;AACpC,eAAO,MAAM,eAAe,sBAAsB,CAAC;AACnD,eAAO,MAAM,mBAAmB,0BAA0B,CAAC;AAC3D;;;;GAIG;AACH,eAAO,MAAM,UAAU,kCAAkC,CAAC;AAC1D,eAAO,MAAM,eAAe,wBAAwB,CAAC;AACrD,eAAO,MAAM,aAAa,sBAAsB,CAAC;AACjD;;;;GAIG;AACH,eAAO,MAAM,aAAa,sBAAsB,CAAC;AACjD;;;;GAIG;AACH,eAAO,MAAM,o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BAAsB,GAC3B,OAAO,CAAC,MAAM,CAAC,CA8BjB"}
|
|
@@ -39,14 +39,14 @@ export const GATEWAY_ERROR_HEADER = "x-everyapp-error";
|
|
|
39
39
|
*/
|
|
40
40
|
export const ORG_HEADER = "x-everyapp-org";
|
|
41
41
|
/**
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
* `
|
|
47
|
-
*
|
|
42
|
+
* On background work's call to an OAuth provider's API: the member whose
|
|
43
|
+
* connection to this app the call uses. Set by `for: { background: true,
|
|
44
|
+
* userId }`; the gateway reads it on the held-token branch only, for an
|
|
45
|
+
* organization's own app, and the perimeter strips it, with every
|
|
46
|
+
* `x-everyapp-*`, from browsers. It addresses a connection; it is not a
|
|
47
|
+
* permission: connecting in the app already lets the app use it.
|
|
48
48
|
*/
|
|
49
|
-
export const
|
|
49
|
+
export const USER_HEADER = "x-everyapp-user";
|
|
50
50
|
/** 120-second lifetime — caps revocation staleness while surviving clock skew. */
|
|
51
51
|
export const IDENTITY_TTL_SECONDS = 120;
|
|
52
52
|
/** System tokens are minted per call and live at most a minute. */
|
|
@@ -87,6 +87,20 @@ export const DEV_ORG_ID = "dev-org";
|
|
|
87
87
|
export const PUBLIC_MARKER_SUB = "public";
|
|
88
88
|
/** `sub` claim of gateway system tokens. */
|
|
89
89
|
export const SYSTEM_TOKEN_SUB = "system";
|
|
90
|
+
/**
|
|
91
|
+
* Linked dev (`everyapp dev --gateway`, docs/design/linked-dev.md): the
|
|
92
|
+
* dev Worker's env names the gateway-lite's loopback forwarder and the
|
|
93
|
+
* run's nonce, and the SDK builds a `{ fetch }` in place of the missing
|
|
94
|
+
* `EVERY_APP_GATEWAY` binding from them. Set by `everyAppWorker()` in a
|
|
95
|
+
* development build from the process environment `everyapp dev` starts
|
|
96
|
+
* the app with; never deployed.
|
|
97
|
+
*/
|
|
98
|
+
export const LINKED_DEV_URL_ENV = "EVERYAPP_LINKED_DEV_URL";
|
|
99
|
+
export const LINKED_DEV_NONCE_ENV = "EVERYAPP_LINKED_DEV_NONCE";
|
|
100
|
+
/** The header the forwarder requires, with the run's nonce: no simple cross-origin request can send it. */
|
|
101
|
+
export const LINKED_DEV_HEADER = "x-everyapp-linked-dev";
|
|
102
|
+
/** Where the gateway-lite serves the forwarder, under the app's own host. */
|
|
103
|
+
export const LINKED_DEV_FORWARD_PATH = "/__everyapp/gateway";
|
|
90
104
|
/** `role` as an {@link OrgRole}: `owner` and `admin` as they are, anything else `member`. */
|
|
91
105
|
export function toOrgRole(role) {
|
|
92
106
|
return role === "owner" || role === "admin" ? role : "member";
|
|
@@ -194,6 +208,10 @@ export function assertSystemClaims(payload, purpose) {
|
|
|
194
208
|
payload.exp - payload.iat > SYSTEM_TOKEN_TTL_SECONDS) {
|
|
195
209
|
throw new ProtocolClaimsError(`system token must expire within ${SYSTEM_TOKEN_TTL_SECONDS}s of issue`);
|
|
196
210
|
}
|
|
211
|
+
if (purpose === "events.deliver" &&
|
|
212
|
+
(typeof payload.bh !== "string" || payload.bh.length === 0)) {
|
|
213
|
+
throw new ProtocolClaimsError("an events.deliver token must name the body it was minted for");
|
|
214
|
+
}
|
|
197
215
|
return payload;
|
|
198
216
|
}
|
|
199
217
|
let cachedPrivateKey = null;
|
|
@@ -255,6 +273,17 @@ export async function mintPublicMarkerJwt(privateKeyPem, opts) {
|
|
|
255
273
|
.setExpirationTime(nowSec + ttl)
|
|
256
274
|
.sign(key);
|
|
257
275
|
}
|
|
276
|
+
/** SHA-256 of a request body, base64url: what an `events.deliver` token's `bh` names. */
|
|
277
|
+
export async function bodyHash(body) {
|
|
278
|
+
const digest = new Uint8Array(await crypto.subtle.digest("SHA-256", new TextEncoder().encode(body)));
|
|
279
|
+
let binary = "";
|
|
280
|
+
for (const byte of digest)
|
|
281
|
+
binary += String.fromCharCode(byte);
|
|
282
|
+
return btoa(binary)
|
|
283
|
+
.replace(/\+/g, "-")
|
|
284
|
+
.replace(/\//g, "_")
|
|
285
|
+
.replace(/=+$/, "");
|
|
286
|
+
}
|
|
258
287
|
/**
|
|
259
288
|
* Mint the gateway's system token for `x-everyapp-system`: no user, one
|
|
260
289
|
* purpose, one app, one minute. The SDK only accepts it on the endpoint its
|
|
@@ -267,10 +296,14 @@ export async function mintSystemJwt(privateKeyPem, opts) {
|
|
|
267
296
|
}
|
|
268
297
|
const key = await loadPrivateKey(privateKeyPem);
|
|
269
298
|
const nowSec = Math.floor((opts.now ?? Date.now()) / 1000);
|
|
299
|
+
if (opts.purpose === "events.deliver" && !opts.bodyHash) {
|
|
300
|
+
throw new RangeError("an events.deliver token needs the body's hash");
|
|
301
|
+
}
|
|
270
302
|
const claims = {
|
|
271
303
|
typ: "system",
|
|
272
304
|
purpose: opts.purpose,
|
|
273
305
|
jti: crypto.randomUUID(),
|
|
306
|
+
...(opts.bodyHash ? { bh: opts.bodyHash } : {}),
|
|
274
307
|
};
|
|
275
308
|
return new SignJWT(claims)
|
|
276
309
|
.setProtectedHeader({
|
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
* serves the provider's tools on its `/mcp` under `<id>_<tool>` names, with
|
|
7
7
|
* the key never leaving the Gateway, every call attributed to the member
|
|
8
8
|
* who made it, counted and audited like an app's capability calls. The
|
|
9
|
-
*
|
|
10
|
-
* your agent" dialog
|
|
9
|
+
* MCP apps section of Admin → Apps lists it, and its row menu opens the
|
|
10
|
+
* "Use it from your agent" dialog (docs/design/2026-10-mcp-apps-ui.md).
|
|
11
11
|
*
|
|
12
12
|
* A provider app is an `apps` row of tier {@link PROVIDER_APP_TIER} with no
|
|
13
13
|
* hostname and no Worker name: the perimeter never routes it, and the
|
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
* serves the provider's tools on its `/mcp` under `<id>_<tool>` names, with
|
|
7
7
|
* the key never leaving the Gateway, every call attributed to the member
|
|
8
8
|
* who made it, counted and audited like an app's capability calls. The
|
|
9
|
-
*
|
|
10
|
-
* your agent" dialog
|
|
9
|
+
* MCP apps section of Admin → Apps lists it, and its row menu opens the
|
|
10
|
+
* "Use it from your agent" dialog (docs/design/2026-10-mcp-apps-ui.md).
|
|
11
11
|
*
|
|
12
12
|
* A provider app is an `apps` row of tier {@link PROVIDER_APP_TIER} with no
|
|
13
13
|
* hostname and no Worker name: the perimeter never routes it, and the
|
|
@@ -19,19 +19,8 @@
|
|
|
19
19
|
* an IP literal, localhost, or a `.local`, `.internal` or `.arpa` name)
|
|
20
20
|
* and not one the gateway serves itself (`refuseHost`, which knows the
|
|
21
21
|
* gateway's own host and `APP_BASE_DOMAIN`).
|
|
22
|
-
*
|
|
23
|
-
* A second kind of row, a scope-set overlay (`provider_scope_sets`,
|
|
24
|
-
* `everyapp provider scope-set add`), adds a named scope set to a
|
|
25
|
-
* built-in OAuth client that has scope sets (Google, Microsoft, Slack):
|
|
26
|
-
* its scopes, and the routes on the client's own API hosts it unlocks,
|
|
27
|
-
* checked by the rules a built-in set is checked by
|
|
28
|
-
* (`providers.scope-set-overlay-within-client`). An overlay never replaces
|
|
29
|
-
* one of the client's own sets, never names a host outside the client's
|
|
30
|
-
* `api`, and never applies to a registered row (an operator replaces the
|
|
31
|
-
* row's spec instead). Apps list an overlay set under `scopes` as they
|
|
32
|
-
* list a built-in one.
|
|
33
22
|
*/
|
|
34
|
-
import { type Capability, type CapabilityLookup
|
|
23
|
+
import { type Capability, type CapabilityLookup } from "./capabilities.js";
|
|
35
24
|
import { type RegistrableCapability } from "./providerSpec.js";
|
|
36
25
|
/** A `providers` row as the gateway or the CLI read it. */
|
|
37
26
|
export interface ProviderRow {
|
|
@@ -50,42 +39,16 @@ export interface ProviderRow {
|
|
|
50
39
|
/** When, in epoch milliseconds. */
|
|
51
40
|
addedAt?: number | null;
|
|
52
41
|
}
|
|
53
|
-
/** A `provider_scope_sets` row as the gateway or the CLI read it. */
|
|
54
|
-
export interface ScopeSetRow {
|
|
55
|
-
/** The built-in OAuth client the set belongs to (`google-workspace`). */
|
|
56
|
-
providerId: string;
|
|
57
|
-
/** The set's name, what an app lists under `scopes` (`gmail.send`). */
|
|
58
|
-
name: string;
|
|
59
|
-
/** The set's spec, as JSON text or already parsed (`parseScopeSetOverlay`'s shape). */
|
|
60
|
-
spec: unknown;
|
|
61
|
-
addedBy?: string | null;
|
|
62
|
-
addedAt?: number | null;
|
|
63
|
-
}
|
|
64
|
-
/** One overlay the registry serves, as `provider show` reports it. */
|
|
65
|
-
export interface RegisteredScopeSet {
|
|
66
|
-
providerId: string;
|
|
67
|
-
name: string;
|
|
68
|
-
set: OAuthScopeSet;
|
|
69
|
-
addedBy: string | null;
|
|
70
|
-
addedAt: number | null;
|
|
71
|
-
}
|
|
72
|
-
export type ScopeSetRefusalCode = "SCOPE_SET_INVALID" | "SCOPE_SET_PROVIDER_UNKNOWN" | "SCOPE_SET_BUILTIN";
|
|
73
|
-
/** Why an overlay row is not a scope set on this gateway. */
|
|
74
|
-
export interface ScopeSetRefusal {
|
|
75
|
-
providerId: string;
|
|
76
|
-
name: string;
|
|
77
|
-
code: ScopeSetRefusalCode;
|
|
78
|
-
message: string;
|
|
79
|
-
}
|
|
80
42
|
/**
|
|
81
43
|
* The part of a row a key is set for: its hosts, its host setting and its
|
|
82
44
|
* auth, as one canonical string (sorted keys, sorted hosts), so that
|
|
83
45
|
* replacing a row's hosts or auth changes the key and the value it held
|
|
84
46
|
* is no longer read until the operator sets it again. For an OAuth
|
|
85
47
|
* provider the client is bound to its authorize, token and revoke URLs,
|
|
86
|
-
* its API hosts, where the client goes on the token request
|
|
87
|
-
*
|
|
88
|
-
* re-points `tokenUrl`
|
|
48
|
+
* its API hosts, where the client goes on the token request, its client
|
|
49
|
+
* setting names, and its `resource` and `issuer` when it has them
|
|
50
|
+
* (`oauth.client-bound-to-endpoints`): an admin who re-points `tokenUrl`
|
|
51
|
+
* has to paste the secret again.
|
|
89
52
|
*/
|
|
90
53
|
export declare function providerBindingKey(capability: RegistrableCapability): string;
|
|
91
54
|
/** One registered row as `provider list` and `provider show` report it. */
|
|
@@ -123,12 +86,6 @@ export interface ProviderRegistry extends CapabilityLookup {
|
|
|
123
86
|
rows(): readonly RegisteredProvider[];
|
|
124
87
|
/** The rows this registry left out, each with why. */
|
|
125
88
|
readonly rejected: readonly RowRefusal[];
|
|
126
|
-
/** The scope-set overlays this registry applied to built-in clients, in row order. */
|
|
127
|
-
scopeSets(): readonly RegisteredScopeSet[];
|
|
128
|
-
/** Where a client's scope set comes from: its catalog entry, an overlay row, or nowhere. */
|
|
129
|
-
scopeSetSource(providerId: string, name: string): "catalog" | "row" | undefined;
|
|
130
|
-
/** The overlay rows this registry left out, each with why. */
|
|
131
|
-
readonly rejectedScopeSets: readonly ScopeSetRefusal[];
|
|
132
89
|
}
|
|
133
90
|
export interface ProviderRegistryOptions {
|
|
134
91
|
/**
|
|
@@ -137,8 +94,6 @@ export interface ProviderRegistryOptions {
|
|
|
137
94
|
* the rest (IP literals, localhost, `.internal`).
|
|
138
95
|
*/
|
|
139
96
|
refuseHost?: (host: string) => string | null;
|
|
140
|
-
/** The scope-set overlays (`provider_scope_sets`), applied to the catalog's OAuth clients. */
|
|
141
|
-
scopeSets?: readonly ScopeSetRow[];
|
|
142
97
|
}
|
|
143
98
|
/** The prefix a provider's own Gateway settings carry: `stripe` → `STRIPE_`, `tiktok-business` → `TIKTOK_BUSINESS_`. */
|
|
144
99
|
export declare function providerSettingPrefix(id: string): string;
|
|
@@ -194,20 +149,6 @@ export declare function resolveProviderRow(row: ProviderRow, context: {
|
|
|
194
149
|
ok: false;
|
|
195
150
|
refusal: RowRefusal;
|
|
196
151
|
};
|
|
197
|
-
/**
|
|
198
|
-
* The built-in OAuth client an overlay may extend: a catalog entry of mode
|
|
199
|
-
* `oauth_client` with a scope policy. Null for anything else (an API-key
|
|
200
|
-
* entry, a client without sets, a registered row, an unknown id).
|
|
201
|
-
*/
|
|
202
|
-
export declare function overlayableClient(providerId: string): OAuthClientCapability | null;
|
|
203
|
-
/** An overlay row's spec parsed and checked against its client: the set, or the refusal. */
|
|
204
|
-
export declare function resolveScopeSetRow(row: ScopeSetRow): {
|
|
205
|
-
ok: true;
|
|
206
|
-
set: OAuthScopeSet;
|
|
207
|
-
} | {
|
|
208
|
-
ok: false;
|
|
209
|
-
refusal: ScopeSetRefusal;
|
|
210
|
-
};
|
|
211
152
|
/**
|
|
212
153
|
* The catalog and `rows` as one registry. Rows are taken in order; a row
|
|
213
154
|
* whose settings another earlier row holds is the one refused.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"providerRegistry.d.ts","sourceRoot":"","sources":["../../src/internal/providerRegistry.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"providerRegistry.d.ts","sourceRoot":"","sources":["../../src/internal/providerRegistry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,OAAO,EAKL,KAAK,UAAU,EACf,KAAK,gBAAgB,EACtB,MAAM,mBAAmB,CAAC;AAQ3B,OAAO,EAIL,KAAK,qBAAqB,EAC3B,MAAM,mBAAmB,CAAC;AAE3B,2DAA2D;AAC3D,MAAM,WAAW,WAAW;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,gDAAgD;IAChD,IAAI,EAAE,OAAO,CAAC;IACd;;;;;OAKG;IACH,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,uGAAuG;IACvG,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,mCAAmC;IACnC,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACzB;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,kBAAkB,CAAC,UAAU,EAAE,qBAAqB,GAAG,MAAM,CAkC5E;AAoBD,2EAA2E;AAC3E,MAAM,WAAW,kBAAkB;IACjC,EAAE,EAAE,MAAM,CAAC;IACX,UAAU,EAAE,qBAAqB,CAAC;IAClC,uEAAuE;IACvE,KAAK,EAAE,OAAO,CAAC;IACf,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,O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GAAE,SAAS,WAAW,EAAO,EACjC,OAAO,GAAE,uBAA4B,GACpC,gBAAgB,CAqElB;AAED,2FAA2F;AAC3F,eAAO,MAAM,iBAAiB,EAAE,gBAAqC,CAAC"}
|
|
@@ -19,21 +19,9 @@
|
|
|
19
19
|
* an IP literal, localhost, or a `.local`, `.internal` or `.arpa` name)
|
|
20
20
|
* and not one the gateway serves itself (`refuseHost`, which knows the
|
|
21
21
|
* gateway's own host and `APP_BASE_DOMAIN`).
|
|
22
|
-
*
|
|
23
|
-
* A second kind of row, a scope-set overlay (`provider_scope_sets`,
|
|
24
|
-
* `everyapp provider scope-set add`), adds a named scope set to a
|
|
25
|
-
* built-in OAuth client that has scope sets (Google, Microsoft, Slack):
|
|
26
|
-
* its scopes, and the routes on the client's own API hosts it unlocks,
|
|
27
|
-
* checked by the rules a built-in set is checked by
|
|
28
|
-
* (`providers.scope-set-overlay-within-client`). An overlay never replaces
|
|
29
|
-
* one of the client's own sets, never names a host outside the client's
|
|
30
|
-
* `api`, and never applies to a registered row (an operator replaces the
|
|
31
|
-
* row's spec instead). Apps list an overlay set under `scopes` as they
|
|
32
|
-
* list a built-in one.
|
|
33
22
|
*/
|
|
34
23
|
import { CAPABILITIES, CAPABILITY_IDS, capabilitySettings, } from "./capabilities.js";
|
|
35
24
|
import { isDevOnlyGatewaySetting, isInstallOwnedGatewaySetting, isReservedAppSecretName, isSettableGatewaySetting, } from "./gatewaySettings.js";
|
|
36
|
-
import { parseScopeSetOverlay, withScopeSets } from "./oauthSpec.js";
|
|
37
25
|
import { isSignInSettingName } from "./signInProviders.js";
|
|
38
26
|
import { describeSpecProblems, parseProviderSpec, PROVIDER_ID, } from "./providerSpec.js";
|
|
39
27
|
/**
|
|
@@ -42,9 +30,10 @@ import { describeSpecProblems, parseProviderSpec, PROVIDER_ID, } from "./provide
|
|
|
42
30
|
* replacing a row's hosts or auth changes the key and the value it held
|
|
43
31
|
* is no longer read until the operator sets it again. For an OAuth
|
|
44
32
|
* provider the client is bound to its authorize, token and revoke URLs,
|
|
45
|
-
* its API hosts, where the client goes on the token request
|
|
46
|
-
*
|
|
47
|
-
* re-points `tokenUrl`
|
|
33
|
+
* its API hosts, where the client goes on the token request, its client
|
|
34
|
+
* setting names, and its `resource` and `issuer` when it has them
|
|
35
|
+
* (`oauth.client-bound-to-endpoints`): an admin who re-points `tokenUrl`
|
|
36
|
+
* has to paste the secret again.
|
|
48
37
|
*/
|
|
49
38
|
export function providerBindingKey(capability) {
|
|
50
39
|
if (capability.mode === "ai") {
|
|
@@ -59,13 +48,20 @@ export function providerBindingKey(capability) {
|
|
|
59
48
|
if (capability.mode === "oauth_client") {
|
|
60
49
|
return JSON.stringify({
|
|
61
50
|
kind: "oauth2-user",
|
|
62
|
-
authorizeUrl: capability.
|
|
63
|
-
tokenUrl: capability.flow
|
|
64
|
-
revokeUrl: capability.flow
|
|
65
|
-
inject: capability.
|
|
51
|
+
authorizeUrl: capability.flow.authorizeUrl,
|
|
52
|
+
tokenUrl: capability.flow.tokenUrl,
|
|
53
|
+
revokeUrl: capability.flow.revokeUrl ?? null,
|
|
54
|
+
inject: capability.flow.inject,
|
|
66
55
|
clientId: capability.secrets.clientId,
|
|
67
56
|
clientSecret: capability.secrets.clientSecret ?? null,
|
|
68
57
|
hosts: [...capability.api].sort(),
|
|
58
|
+
// Only when present, so a row without them keeps the key it was bound to.
|
|
59
|
+
...(capability.flow?.resource === undefined
|
|
60
|
+
? {}
|
|
61
|
+
: { resource: capability.flow.resource }),
|
|
62
|
+
...(capability.flow?.issuer === undefined
|
|
63
|
+
? {}
|
|
64
|
+
: { issuer: capability.flow.issuer }),
|
|
69
65
|
});
|
|
70
66
|
}
|
|
71
67
|
return JSON.stringify({
|
|
@@ -207,10 +203,10 @@ export function registrableHosts(capability) {
|
|
|
207
203
|
return [new URL(capability.origin).hostname.toLowerCase()];
|
|
208
204
|
const hosts = [...capability.api];
|
|
209
205
|
const urls = [
|
|
210
|
-
capability.
|
|
211
|
-
capability.flow
|
|
212
|
-
capability.flow
|
|
213
|
-
capability.flow
|
|
206
|
+
capability.flow.authorizeUrl,
|
|
207
|
+
capability.flow.tokenUrl,
|
|
208
|
+
capability.flow.revokeUrl,
|
|
209
|
+
capability.flow.identity?.url,
|
|
214
210
|
];
|
|
215
211
|
for (const url of urls) {
|
|
216
212
|
if (!url)
|
|
@@ -270,92 +266,12 @@ export function resolveProviderRow(row, context) {
|
|
|
270
266
|
? { ok: false, refusal }
|
|
271
267
|
: { ok: true, capability: parsed.capability };
|
|
272
268
|
}
|
|
273
|
-
/**
|
|
274
|
-
* The built-in OAuth client an overlay may extend: a catalog entry of mode
|
|
275
|
-
* `oauth_client` with a scope policy. Null for anything else (an API-key
|
|
276
|
-
* entry, a client without sets, a registered row, an unknown id).
|
|
277
|
-
*/
|
|
278
|
-
export function overlayableClient(providerId) {
|
|
279
|
-
if (!CAPABILITY_IDS.includes(providerId))
|
|
280
|
-
return null;
|
|
281
|
-
const capability = CAPABILITIES[providerId];
|
|
282
|
-
return capability.mode === "oauth_client" && capability.scopePolicy
|
|
283
|
-
? capability
|
|
284
|
-
: null;
|
|
285
|
-
}
|
|
286
|
-
/** An overlay row's spec parsed and checked against its client: the set, or the refusal. */
|
|
287
|
-
export function resolveScopeSetRow(row) {
|
|
288
|
-
const refuse = (code, message) => ({
|
|
289
|
-
ok: false,
|
|
290
|
-
refusal: { providerId: row.providerId, name: row.name, code, message },
|
|
291
|
-
});
|
|
292
|
-
const client = overlayableClient(row.providerId);
|
|
293
|
-
if (!client) {
|
|
294
|
-
return refuse("SCOPE_SET_PROVIDER_UNKNOWN", `${row.providerId} isn't a built-in OAuth client with scope sets (google-workspace, microsoft-365, slack); a registered provider's sets are in its spec`);
|
|
295
|
-
}
|
|
296
|
-
if (Object.hasOwn(client.scopePolicy.sets, row.name)) {
|
|
297
|
-
return refuse("SCOPE_SET_BUILTIN", `${row.name} is one of ${row.providerId}'s own sets; an overlay adds a set, never replaces one`);
|
|
298
|
-
}
|
|
299
|
-
let spec = row.spec;
|
|
300
|
-
if (typeof spec === "string") {
|
|
301
|
-
try {
|
|
302
|
-
spec = JSON.parse(spec);
|
|
303
|
-
}
|
|
304
|
-
catch {
|
|
305
|
-
return refuse("SCOPE_SET_INVALID", "the stored spec isn't JSON");
|
|
306
|
-
}
|
|
307
|
-
}
|
|
308
|
-
const parsed = parseScopeSetOverlay(typeof spec === "object" && spec !== null && !Array.isArray(spec)
|
|
309
|
-
? { ...spec, name: row.name }
|
|
310
|
-
: spec, { id: row.providerId, capability: client });
|
|
311
|
-
if (!parsed.ok) {
|
|
312
|
-
return refuse("SCOPE_SET_INVALID", describeSpecProblems(parsed.problems));
|
|
313
|
-
}
|
|
314
|
-
return { ok: true, set: parsed.set };
|
|
315
|
-
}
|
|
316
269
|
/**
|
|
317
270
|
* The catalog and `rows` as one registry. Rows are taken in order; a row
|
|
318
271
|
* whose settings another earlier row holds is the one refused.
|
|
319
272
|
*/
|
|
320
273
|
export function providerRegistry(rows = [], options = {}) {
|
|
321
274
|
const catalog = new Map(CAPABILITY_IDS.map((id) => [id, CAPABILITIES[id]]));
|
|
322
|
-
// Scope-set overlays on the catalog's OAuth clients, before any row is
|
|
323
|
-
// looked at: a row never shadows the catalog, with or without overlays.
|
|
324
|
-
const overlays = [];
|
|
325
|
-
const rejectedScopeSets = [];
|
|
326
|
-
const overlaySets = new Map();
|
|
327
|
-
for (const row of options.scopeSets ?? []) {
|
|
328
|
-
if (overlays.some((each) => each.providerId === row.providerId && each.name === row.name)) {
|
|
329
|
-
rejectedScopeSets.push({
|
|
330
|
-
providerId: row.providerId,
|
|
331
|
-
name: row.name,
|
|
332
|
-
code: "SCOPE_SET_INVALID",
|
|
333
|
-
message: "listed twice",
|
|
334
|
-
});
|
|
335
|
-
continue;
|
|
336
|
-
}
|
|
337
|
-
const resolved = resolveScopeSetRow(row);
|
|
338
|
-
if (!resolved.ok) {
|
|
339
|
-
rejectedScopeSets.push(resolved.refusal);
|
|
340
|
-
continue;
|
|
341
|
-
}
|
|
342
|
-
overlays.push({
|
|
343
|
-
providerId: row.providerId,
|
|
344
|
-
name: row.name,
|
|
345
|
-
set: resolved.set,
|
|
346
|
-
addedBy: row.addedBy ?? null,
|
|
347
|
-
addedAt: row.addedAt ?? null,
|
|
348
|
-
});
|
|
349
|
-
const sets = overlaySets.get(row.providerId) ?? {};
|
|
350
|
-
sets[row.name] = resolved.set;
|
|
351
|
-
overlaySets.set(row.providerId, sets);
|
|
352
|
-
}
|
|
353
|
-
for (const [id, sets] of overlaySets) {
|
|
354
|
-
const client = catalog.get(id);
|
|
355
|
-
if (client?.mode === "oauth_client") {
|
|
356
|
-
catalog.set(id, withScopeSets(client, sets));
|
|
357
|
-
}
|
|
358
|
-
}
|
|
359
275
|
const accepted = new Map();
|
|
360
276
|
const rejected = [];
|
|
361
277
|
const rowSettings = new Set();
|
|
@@ -411,21 +327,6 @@ export function providerRegistry(rows = [], options = {}) {
|
|
|
411
327
|
},
|
|
412
328
|
rows: () => [...accepted.values()],
|
|
413
329
|
rejected,
|
|
414
|
-
scopeSets: () => [...overlays],
|
|
415
|
-
scopeSetSource: (providerId, name) => {
|
|
416
|
-
if (overlays.some((each) => each.providerId === providerId && each.name === name)) {
|
|
417
|
-
return "row";
|
|
418
|
-
}
|
|
419
|
-
const capability = CAPABILITY_IDS.includes(providerId)
|
|
420
|
-
? CAPABILITIES[providerId]
|
|
421
|
-
: undefined;
|
|
422
|
-
return capability?.mode === "oauth_client" &&
|
|
423
|
-
capability.scopePolicy &&
|
|
424
|
-
Object.hasOwn(capability.scopePolicy.sets, name)
|
|
425
|
-
? "catalog"
|
|
426
|
-
: undefined;
|
|
427
|
-
},
|
|
428
|
-
rejectedScopeSets,
|
|
429
330
|
};
|
|
430
331
|
}
|
|
431
332
|
/** The catalog alone, as a registry: what every surface reads without a gateway's rows. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"providerSpec.d.ts","sourceRoot":"","sources":["../../src/internal/providerSpec.ts"],"names":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