@every-app/sdk 0.3.0-rc.9 → 0.3.1
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 +79 -74
- package/dist/cloudflare/catalogSettings.generated.d.ts +19 -6
- package/dist/cloudflare/catalogSettings.generated.d.ts.map +1 -1
- package/dist/cloudflare/catalogSettings.generated.js +43 -14
- package/dist/cloudflare/index.d.ts +1 -1
- package/dist/cloudflare/index.d.ts.map +1 -1
- package/dist/cloudflare/worker.d.ts +63 -9
- package/dist/cloudflare/worker.d.ts.map +1 -1
- package/dist/cloudflare/worker.js +45 -9
- 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 +109 -503
- package/dist/internal/capabilities.d.ts.map +1 -1
- package/dist/internal/capabilities.js +30 -550
- package/dist/internal/catalog/commerce.js +1 -1
- package/dist/internal/catalog/index.d.ts +35 -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 -4
- package/dist/internal/gatewaySettings.d.ts +6 -16
- package/dist/internal/gatewaySettings.d.ts.map +1 -1
- package/dist/internal/gatewaySettings.js +5 -23
- 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 +36 -44
- package/dist/internal/oauthClient.d.ts.map +1 -1
- package/dist/internal/oauthClient.js +30 -113
- 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 +24 -14
- package/dist/internal/protocol.d.ts.map +1 -1
- package/dist/internal/protocol.js +26 -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 -40
- 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 +11 -1
- package/dist/server/attribution.d.ts.map +1 -1
- package/dist/server/attribution.js +7 -1
- package/dist/server/connectUrl.d.ts +5 -10
- package/dist/server/connectUrl.d.ts.map +1 -1
- package/dist/server/connectUrl.js +22 -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/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 +1 -1
- package/dist/server/gatewayFetch.js +1 -1
- 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 +66 -72
- package/dist/server/integrationFetch.d.ts.map +1 -1
- package/dist/server/integrationFetch.js +120 -392
- 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/tools.d.ts +18 -7
- package/dist/server/tools.d.ts.map +1 -1
- package/dist/server/tools.js +15 -5
- 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
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
2
|
+
* An OAuth provider's client as the gateway holds it in its settings
|
|
3
|
+
* (`everyapp secret set <CLIENT_ID> <CLIENT_SECRET>`); one an owner or
|
|
4
|
+
* admin pasted under Manage workspace → Providers is the gateway's own
|
|
5
|
+
* D1 row instead.
|
|
6
6
|
*/
|
|
7
|
-
import {
|
|
8
|
-
/** The largest token
|
|
7
|
+
import type { CapabilitySettings, OAuthClientCapability } from "./capabilities.js";
|
|
8
|
+
/** The largest token answer the gateway reads: real ones are a few kilobytes. */
|
|
9
9
|
export declare const OAUTH_TOKEN_BODY_LIMIT: number;
|
|
10
|
-
/** An OAuth client as the gateway
|
|
10
|
+
/** An OAuth client as the gateway holds it. */
|
|
11
11
|
export interface OAuthClientCredentials {
|
|
12
12
|
clientId: string;
|
|
13
13
|
/** Absent for a public client. */
|
|
@@ -18,44 +18,36 @@ export interface OAuthClientCredentials {
|
|
|
18
18
|
* it needs is set: the id, and the secret unless it is a public client.
|
|
19
19
|
*/
|
|
20
20
|
export declare function oauthClientCredentials(capability: OAuthClientCapability, settings: CapabilitySettings): OAuthClientCredentials | null;
|
|
21
|
-
/**
|
|
22
|
-
export
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
21
|
+
/** Where the client the gateway uses for an OAuth provider comes from. */
|
|
22
|
+
export declare enum OAuthClientSource {
|
|
23
|
+
/** The Worker's settings, set from the terminal (`everyapp secret set`, `provider add`). */
|
|
24
|
+
Env = "env",
|
|
25
|
+
/** Pasted under Manage workspace → Providers: the gateway's sealed D1 row. */
|
|
26
|
+
Pasted = "d1"
|
|
27
|
+
}
|
|
28
|
+
/** What the gateway or the CLI knows of a pasted client, never its value. */
|
|
29
|
+
export interface PastedOAuthClient {
|
|
30
|
+
/** The provider binding it was pasted for (`providerBindingKey`), or null for none recorded. */
|
|
31
|
+
boundTo: string | null;
|
|
32
|
+
hasSecret: boolean;
|
|
33
|
+
/** Whether its sealed copy opens with the gateway's secret; the CLI, which can't open it, says true. */
|
|
34
|
+
opens: boolean;
|
|
26
35
|
}
|
|
27
|
-
export type InjectedTokenRequest = ({
|
|
28
|
-
ok: true;
|
|
29
|
-
} & TokenRequest) | {
|
|
30
|
-
ok: false;
|
|
31
|
-
problem: string;
|
|
32
|
-
};
|
|
33
|
-
/**
|
|
34
|
-
* `request` with `client` put where `rule` says (the form body or HTTP
|
|
35
|
-
* Basic), and every client credential the app sent removed wherever it
|
|
36
|
-
* was: the `Authorization` header, and `client_id`/`client_secret` (in any
|
|
37
|
-
* case) in the query string and the body. The body is re-serialised from
|
|
38
|
-
* its parsed values, so a crafted body can't carry a second secret past
|
|
39
|
-
* the parser. Token requests are form-encoded; anything else is refused.
|
|
40
|
-
*/
|
|
41
|
-
export declare function injectClientCredentials(request: TokenRequest, rule: OAuthTokenEndpoint, client: OAuthClientCredentials): InjectedTokenRequest;
|
|
42
|
-
/**
|
|
43
|
-
* The grants the gateway completes: each ends in a user's own tokens. The
|
|
44
|
-
* client-credentials grant, and anything else a network serves on the same
|
|
45
|
-
* endpoint, would mint a token for the gateway's own application instead,
|
|
46
|
-
* which on many providers manages the application's settings, its
|
|
47
|
-
* webhooks and every tenant's tokens.
|
|
48
|
-
*/
|
|
49
|
-
export declare const USER_BOUND_GRANT_TYPES: ReadonlySet<string>;
|
|
50
|
-
/**
|
|
51
|
-
* A token request's `grant_type` as the app sent it, from its body or query
|
|
52
|
-
* string, or null when it names none (Slack's code exchange). Never the
|
|
53
|
-
* request's other fields.
|
|
54
|
-
*/
|
|
55
|
-
export declare function requestedGrantType(request: TokenRequest): string | null;
|
|
56
36
|
/**
|
|
57
|
-
*
|
|
58
|
-
*
|
|
37
|
+
* Which client the gateway uses for an OAuth provider, or null when it has
|
|
38
|
+
* none it may use (docs/design/2026-10-oauth-providers.md section 6): the
|
|
39
|
+
* Worker settings' while the registry may read them (`envBound`: a
|
|
40
|
+
* registered row bound to its hosts), else the pasted one while it was
|
|
41
|
+
* pasted for the provider as it is now, opens, and has its secret. One rule
|
|
42
|
+
* for every surface that asks: the gateway's client lookup, whether an app
|
|
43
|
+
* needs setup (the gate that opens it, the app lists) and the CLI's
|
|
44
|
+
* `status` and `deploy`.
|
|
59
45
|
*/
|
|
60
|
-
export declare function
|
|
46
|
+
export declare function oauthClientSource(input: {
|
|
47
|
+
capability: OAuthClientCapability;
|
|
48
|
+
/** Every setting the Worker's client needs is set (`oauthClientCredentials`). */
|
|
49
|
+
envSet: boolean;
|
|
50
|
+
envBound: boolean;
|
|
51
|
+
pasted: PastedOAuthClient | null;
|
|
52
|
+
}): OAuthClientSource | null;
|
|
61
53
|
//# sourceMappingURL=oauthClient.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"oauthClient.d.ts","sourceRoot":"","sources":["../../src/internal/oauthClient.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,
|
|
1
|
+
{"version":3,"file":"oauthClient.d.ts","sourceRoot":"","sources":["../../src/internal/oauthClient.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,KAAK,EACV,kBAAkB,EAClB,qBAAqB,EACtB,MAAM,mBAAmB,CAAC;AAG3B,iFAAiF;AACjF,eAAO,MAAM,sBAAsB,QAAY,CAAC;AAEhD,+CAA+C;AAC/C,MAAM,WAAW,sBAAsB;IACrC,QAAQ,EAAE,MAAM,CAAC;IACjB,kCAAkC;IAClC,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CACpC,UAAU,EAAE,qBAAqB,EACjC,QAAQ,EAAE,kBAAkB,GAC3B,sBAAsB,GAAG,IAAI,CAQ/B;AAED,0EAA0E;AAC1E,oBAAY,iBAAiB;IAC3B,4FAA4F;IAC5F,GAAG,QAAQ;IACX,8EAA8E;IAC9E,MAAM,OAAO;CACd;AAED,6EAA6E;AAC7E,MAAM,WAAW,iBAAiB;IAChC,gGAAgG;IAChG,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,SAAS,EAAE,OAAO,CAAC;IACnB,wGAAwG;IACxG,KAAK,EAAE,OAAO,CAAC;CAChB;AAED;;;;;;;;;GASG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE;IACvC,UAAU,EAAE,qBAAqB,CAAC;IAClC,iFAAiF;IACjF,MAAM,EAAE,OAAO,CAAC;IAChB,QAAQ,EAAE,OAAO,CAAC;IAClB,MAAM,EAAE,iBAAiB,GAAG,IAAI,CAAC;CAClC,GAAG,iBAAiB,GAAG,IAAI,CAO3B"}
|
|
@@ -1,11 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
* clients"), shared by the gateway, which puts the operator's client on an
|
|
4
|
-
* app's token request, and the SDK's local-dev fallback, which puts the
|
|
5
|
-
* developer's own on it the same way.
|
|
6
|
-
*/
|
|
7
|
-
import { base64Utf8, } from "./capabilities.js";
|
|
8
|
-
/** The largest token request body the gateway reads: real ones are a few hundred bytes. */
|
|
1
|
+
import { providerBindingKey } from "./providerRegistry.js";
|
|
2
|
+
/** The largest token answer the gateway reads: real ones are a few kilobytes. */
|
|
9
3
|
export const OAUTH_TOKEN_BODY_LIMIT = 64 * 1024;
|
|
10
4
|
/**
|
|
11
5
|
* The client `settings` hold for `capability`, or null until every setting
|
|
@@ -21,113 +15,36 @@ export function oauthClientCredentials(capability, settings) {
|
|
|
21
15
|
return null;
|
|
22
16
|
return { clientId, ...(clientSecret ? { clientSecret } : {}) };
|
|
23
17
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
18
|
+
/** Where the client the gateway uses for an OAuth provider comes from. */
|
|
19
|
+
export var OAuthClientSource;
|
|
20
|
+
(function (OAuthClientSource) {
|
|
21
|
+
/** The Worker's settings, set from the terminal (`everyapp secret set`, `provider add`). */
|
|
22
|
+
OAuthClientSource["Env"] = "env";
|
|
23
|
+
/** Pasted under Manage workspace → Providers: the gateway's sealed D1 row. */
|
|
24
|
+
OAuthClientSource["Pasted"] = "d1";
|
|
25
|
+
})(OAuthClientSource || (OAuthClientSource = {}));
|
|
29
26
|
/**
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
27
|
+
* Which client the gateway uses for an OAuth provider, or null when it has
|
|
28
|
+
* none it may use (docs/design/2026-10-oauth-providers.md section 6): the
|
|
29
|
+
* Worker settings' while the registry may read them (`envBound`: a
|
|
30
|
+
* registered row bound to its hosts), else the pasted one while it was
|
|
31
|
+
* pasted for the provider as it is now, opens, and has its secret. One rule
|
|
32
|
+
* for every surface that asks: the gateway's client lookup, whether an app
|
|
33
|
+
* needs setup (the gate that opens it, the app lists) and the CLI's
|
|
34
|
+
* `status` and `deploy`.
|
|
36
35
|
*/
|
|
37
|
-
export function
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
: []),
|
|
43
|
-
];
|
|
44
|
-
// The query keeps the app's other fields as they were sent.
|
|
45
|
-
const url = new URL(request.url);
|
|
46
|
-
url.search = url.search
|
|
47
|
-
.slice(1)
|
|
48
|
-
.split("&")
|
|
49
|
-
.filter((pair) => {
|
|
50
|
-
const [name] = new URLSearchParams(pair).keys();
|
|
51
|
-
return pair !== "" && !(name !== undefined && isCredential(name));
|
|
52
|
-
})
|
|
53
|
-
.join("&");
|
|
54
|
-
const headers = new Headers(request.headers);
|
|
55
|
-
headers.delete("authorization");
|
|
56
|
-
headers.delete("content-length");
|
|
57
|
-
if (rule.inject === "basic") {
|
|
58
|
-
headers.set("authorization", `Basic ${base64Utf8(`${client.clientId}:${client.clientSecret ?? ""}`)}`);
|
|
59
|
-
}
|
|
60
|
-
let body = request.body;
|
|
61
|
-
if (body === null || body === "") {
|
|
62
|
-
// Nothing the app sent; the form rule makes the body.
|
|
63
|
-
if (rule.inject === "form") {
|
|
64
|
-
headers.set("content-type", FORM);
|
|
65
|
-
body = new URLSearchParams(fields).toString();
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
else if (mediaType(headers.get("content-type")) === FORM) {
|
|
69
|
-
const params = new URLSearchParams(body);
|
|
70
|
-
for (const name of new Set([...params.keys()].filter(isCredential))) {
|
|
71
|
-
params.delete(name);
|
|
72
|
-
}
|
|
73
|
-
if (rule.inject === "form") {
|
|
74
|
-
for (const [name, value] of fields)
|
|
75
|
-
params.set(name, value);
|
|
76
|
-
}
|
|
77
|
-
body = params.toString();
|
|
78
|
-
}
|
|
79
|
-
else {
|
|
80
|
-
return {
|
|
81
|
-
ok: false,
|
|
82
|
-
problem: `A token request's body is form-encoded (${FORM}).`,
|
|
83
|
-
};
|
|
84
|
-
}
|
|
85
|
-
return { ok: true, url, headers, body };
|
|
86
|
-
}
|
|
87
|
-
/** The grant types logs may name; anything else is logged as `other`. */
|
|
88
|
-
const GRANT_TYPES = new Set([
|
|
89
|
-
"authorization_code",
|
|
90
|
-
"refresh_token",
|
|
91
|
-
"client_credentials",
|
|
92
|
-
"urn:ietf:params:oauth:grant-type:token-exchange",
|
|
93
|
-
]);
|
|
94
|
-
/**
|
|
95
|
-
* The grants the gateway completes: each ends in a user's own tokens. The
|
|
96
|
-
* client-credentials grant, and anything else a network serves on the same
|
|
97
|
-
* endpoint, would mint a token for the gateway's own application instead,
|
|
98
|
-
* which on many providers manages the application's settings, its
|
|
99
|
-
* webhooks and every tenant's tokens.
|
|
100
|
-
*/
|
|
101
|
-
export const USER_BOUND_GRANT_TYPES = new Set([
|
|
102
|
-
"authorization_code",
|
|
103
|
-
"refresh_token",
|
|
104
|
-
"urn:ietf:params:oauth:grant-type:token-exchange",
|
|
105
|
-
]);
|
|
106
|
-
/**
|
|
107
|
-
* A token request's `grant_type` as the app sent it, from its body or query
|
|
108
|
-
* string, or null when it names none (Slack's code exchange). Never the
|
|
109
|
-
* request's other fields.
|
|
110
|
-
*/
|
|
111
|
-
export function requestedGrantType(request) {
|
|
112
|
-
let value = null;
|
|
113
|
-
const type = mediaType(request.headers.get("content-type"));
|
|
114
|
-
if (request.body && type === FORM) {
|
|
115
|
-
value = new URLSearchParams(request.body).get("grant_type");
|
|
116
|
-
}
|
|
117
|
-
value ??= request.url.searchParams.get("grant_type");
|
|
118
|
-
return typeof value === "string" && value ? value : null;
|
|
119
|
-
}
|
|
120
|
-
/**
|
|
121
|
-
* A token request's `grant_type` for logs: one of the known grant types,
|
|
122
|
-
* `other`, or null when it names none.
|
|
123
|
-
*/
|
|
124
|
-
export function tokenGrantType(request) {
|
|
125
|
-
const value = requestedGrantType(request);
|
|
126
|
-
if (value === null)
|
|
36
|
+
export function oauthClientSource(input) {
|
|
37
|
+
if (input.envSet)
|
|
38
|
+
return input.envBound ? OAuthClientSource.Env : null;
|
|
39
|
+
const pasted = input.pasted;
|
|
40
|
+
if (!pasted || !pasted.opens)
|
|
127
41
|
return null;
|
|
128
|
-
|
|
42
|
+
if (pasted.boundTo !== providerBindingKey(input.capability))
|
|
43
|
+
return null;
|
|
44
|
+
if (input.capability.secrets.clientSecret && !pasted.hasSecret)
|
|
45
|
+
return null;
|
|
46
|
+
return OAuthClientSource.Pasted;
|
|
129
47
|
}
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
return (contentType ?? "").split(";")[0].trim().toLowerCase();
|
|
48
|
+
function settingValue(value) {
|
|
49
|
+
return typeof value === "string" && value.trim() ? value.trim() : undefined;
|
|
133
50
|
}
|