@every-app/sdk 0.2.0 → 0.3.0-rc.10
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/LICENSE +21 -0
- package/README.md +609 -3
- package/dist/cloudflare/catalogSettings.generated.d.ts +81 -0
- package/dist/cloudflare/catalogSettings.generated.d.ts.map +1 -0
- package/dist/cloudflare/catalogSettings.generated.js +174 -0
- package/dist/cloudflare/index.d.ts +23 -0
- package/dist/cloudflare/index.d.ts.map +1 -0
- package/dist/cloudflare/index.js +24 -0
- package/dist/cloudflare/sentinel.d.ts +127 -0
- package/dist/cloudflare/sentinel.d.ts.map +1 -0
- package/dist/cloudflare/sentinel.js +85 -0
- package/dist/cloudflare/worker.d.ts +805 -0
- package/dist/cloudflare/worker.d.ts.map +1 -0
- package/dist/cloudflare/worker.js +997 -0
- package/dist/dev/index.d.ts +8 -0
- package/dist/dev/index.d.ts.map +1 -0
- package/dist/dev/index.js +7 -0
- package/dist/dev/keypair.d.ts +26 -0
- package/dist/dev/keypair.d.ts.map +1 -0
- package/dist/dev/keypair.js +62 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +5 -0
- package/dist/internal/aiDefault.d.ts +204 -0
- package/dist/internal/aiDefault.d.ts.map +1 -0
- package/dist/internal/aiDefault.js +334 -0
- package/dist/internal/aiProviders.d.ts +72 -0
- package/dist/internal/aiProviders.d.ts.map +1 -0
- package/dist/internal/aiProviders.js +233 -0
- package/dist/internal/appSettings.d.ts +315 -0
- package/dist/internal/appSettings.d.ts.map +1 -0
- package/dist/internal/appSettings.js +549 -0
- package/dist/internal/audit.d.ts +108 -0
- package/dist/internal/audit.d.ts.map +1 -0
- package/dist/internal/audit.js +235 -0
- package/dist/internal/capabilities.d.ts +3174 -0
- package/dist/internal/capabilities.d.ts.map +1 -0
- package/dist/internal/capabilities.js +1110 -0
- package/dist/internal/catalog/commerce.d.ts +394 -0
- package/dist/internal/catalog/commerce.d.ts.map +1 -0
- package/dist/internal/catalog/commerce.js +477 -0
- package/dist/internal/catalog/comms.d.ts +375 -0
- package/dist/internal/catalog/comms.d.ts.map +1 -0
- package/dist/internal/catalog/comms.js +520 -0
- package/dist/internal/catalog/index.d.ts +1973 -0
- package/dist/internal/catalog/index.d.ts.map +1 -0
- package/dist/internal/catalog/index.js +19 -0
- package/dist/internal/catalog/inference.d.ts +393 -0
- package/dist/internal/catalog/inference.d.ts.map +1 -0
- package/dist/internal/catalog/inference.js +460 -0
- package/dist/internal/catalog/infra.d.ts +423 -0
- package/dist/internal/catalog/infra.d.ts.map +1 -0
- package/dist/internal/catalog/infra.js +543 -0
- package/dist/internal/catalog/search.d.ts +400 -0
- package/dist/internal/catalog/search.d.ts.map +1 -0
- package/dist/internal/catalog/search.js +463 -0
- package/dist/internal/devProviders.d.ts +49 -0
- package/dist/internal/devProviders.d.ts.map +1 -0
- package/dist/internal/devProviders.js +80 -0
- package/dist/internal/email.d.ts +280 -0
- package/dist/internal/email.d.ts.map +1 -0
- package/dist/internal/email.js +613 -0
- package/dist/internal/events.d.ts +193 -0
- package/dist/internal/events.d.ts.map +1 -0
- package/dist/internal/events.js +367 -0
- package/dist/internal/gatewaySettings.d.ts +83 -0
- package/dist/internal/gatewaySettings.d.ts.map +1 -0
- package/dist/internal/gatewaySettings.js +215 -0
- package/dist/internal/identity.d.ts +57 -5
- package/dist/internal/identity.d.ts.map +1 -1
- package/dist/internal/identity.js +99 -22
- package/dist/internal/index.d.ts +22 -1
- package/dist/internal/index.d.ts.map +1 -1
- package/dist/internal/index.js +22 -1
- package/dist/internal/members.d.ts +36 -0
- package/dist/internal/members.d.ts.map +1 -0
- package/dist/internal/members.js +7 -0
- package/dist/internal/oauthClient.d.ts +61 -0
- package/dist/internal/oauthClient.d.ts.map +1 -0
- package/dist/internal/oauthClient.js +133 -0
- package/dist/internal/oauthPresets.d.ts +33 -0
- package/dist/internal/oauthPresets.d.ts.map +1 -0
- package/dist/internal/oauthPresets.js +1064 -0
- package/dist/internal/oauthScopes.d.ts +172 -0
- package/dist/internal/oauthScopes.d.ts.map +1 -0
- package/dist/internal/oauthScopes.js +510 -0
- package/dist/internal/oauthSpec.d.ts +102 -0
- package/dist/internal/oauthSpec.d.ts.map +1 -0
- package/dist/internal/oauthSpec.js +789 -0
- package/dist/internal/organizationName.d.ts +18 -0
- package/dist/internal/organizationName.d.ts.map +1 -0
- package/dist/internal/organizationName.js +24 -0
- package/dist/internal/protocol.d.ts +150 -3
- package/dist/internal/protocol.d.ts.map +1 -1
- package/dist/internal/protocol.js +163 -2
- package/dist/internal/providerApps.d.ts +75 -0
- package/dist/internal/providerApps.d.ts.map +1 -0
- package/dist/internal/providerApps.js +59 -0
- package/dist/internal/providerRegistry.d.ts +218 -0
- package/dist/internal/providerRegistry.d.ts.map +1 -0
- package/dist/internal/providerRegistry.js +432 -0
- package/dist/internal/providerSpec.d.ts +66 -0
- package/dist/internal/providerSpec.d.ts.map +1 -0
- package/dist/internal/providerSpec.js +1154 -0
- package/dist/internal/remoteMcp.d.ts +188 -0
- package/dist/internal/remoteMcp.d.ts.map +1 -0
- package/dist/internal/remoteMcp.js +543 -0
- package/dist/internal/signInProviders.d.ts +104 -0
- package/dist/internal/signInProviders.d.ts.map +1 -0
- package/dist/internal/signInProviders.js +245 -0
- package/dist/internal/tools.d.ts +115 -0
- package/dist/internal/tools.d.ts.map +1 -0
- package/dist/internal/tools.js +80 -0
- package/dist/manifest.d.ts +238 -0
- package/dist/manifest.d.ts.map +1 -0
- package/dist/manifest.js +30 -0
- package/dist/server/ai.d.ts +111 -0
- package/dist/server/ai.d.ts.map +1 -0
- package/dist/server/ai.js +145 -0
- package/dist/server/aiBinding.d.ts +68 -0
- package/dist/server/aiBinding.d.ts.map +1 -0
- package/dist/server/aiBinding.js +294 -0
- package/dist/server/attribution.d.ts +43 -0
- package/dist/server/attribution.d.ts.map +1 -0
- package/dist/server/attribution.js +75 -0
- package/dist/server/authorizeUrl.d.ts +43 -0
- package/dist/server/authorizeUrl.d.ts.map +1 -0
- package/dist/server/authorizeUrl.js +106 -0
- package/dist/server/connectUrl.d.ts +21 -0
- package/dist/server/connectUrl.d.ts.map +1 -0
- package/dist/server/connectUrl.js +37 -0
- package/dist/server/context.d.ts +68 -0
- package/dist/server/context.d.ts.map +1 -0
- package/dist/server/context.js +117 -0
- package/dist/server/emailBinding.d.ts +72 -0
- package/dist/server/emailBinding.d.ts.map +1 -0
- package/dist/server/emailBinding.js +124 -0
- package/dist/server/emit.d.ts +63 -0
- package/dist/server/emit.d.ts.map +1 -0
- package/dist/server/emit.js +101 -0
- package/dist/server/env.d.ts +44 -0
- package/dist/server/env.d.ts.map +1 -0
- package/dist/server/env.js +1 -0
- package/dist/server/everyApp.d.ts +65 -19
- package/dist/server/everyApp.d.ts.map +1 -1
- package/dist/server/everyApp.js +195 -30
- package/dist/server/fromMcpTools.d.ts +89 -0
- package/dist/server/fromMcpTools.d.ts.map +1 -0
- package/dist/server/fromMcpTools.js +192 -0
- package/dist/server/gatewayFetch.d.ts +54 -14
- package/dist/server/gatewayFetch.d.ts.map +1 -1
- package/dist/server/gatewayFetch.js +201 -37
- package/dist/server/gatewayUrl.d.ts +13 -0
- package/dist/server/gatewayUrl.d.ts.map +1 -0
- package/dist/server/gatewayUrl.js +34 -0
- package/dist/server/index.d.ts +23 -3
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/index.js +19 -2
- package/dist/server/integrationFetch.d.ts +162 -0
- package/dist/server/integrationFetch.d.ts.map +1 -0
- package/dist/server/integrationFetch.js +688 -0
- package/dist/server/listMembers.d.ts +32 -0
- package/dist/server/listMembers.d.ts.map +1 -0
- package/dist/server/listMembers.js +71 -0
- package/dist/server/nodeServer.d.ts +48 -0
- package/dist/server/nodeServer.d.ts.map +1 -0
- package/dist/server/nodeServer.js +45 -0
- package/dist/server/refusal.d.ts +55 -0
- package/dist/server/refusal.d.ts.map +1 -0
- package/dist/server/refusal.js +193 -0
- package/dist/server/sendEmail.d.ts +39 -0
- package/dist/server/sendEmail.d.ts.map +1 -0
- package/dist/server/sendEmail.js +114 -0
- package/dist/server/tools.d.ts +184 -0
- package/dist/server/tools.d.ts.map +1 -0
- package/dist/server/tools.js +347 -0
- package/dist/server/toolsEndpoint.d.ts +32 -0
- package/dist/server/toolsEndpoint.d.ts.map +1 -0
- package/dist/server/toolsEndpoint.js +237 -0
- package/dist/tanstack-start/index.d.ts +9 -0
- package/dist/tanstack-start/index.d.ts.map +1 -0
- package/dist/tanstack-start/index.js +29 -0
- package/dist/testing/index.d.ts +93 -0
- package/dist/testing/index.d.ts.map +1 -0
- package/dist/testing/index.js +156 -0
- package/package.json +42 -8
- package/dist/server/mcp.d.ts +0 -66
- package/dist/server/mcp.d.ts.map +0 -1
- package/dist/server/mcp.js +0 -147
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `oauth_client` capability's wire rules (docs/capabilities.md "OAuth
|
|
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 { type CapabilitySettings, type OAuthClientCapability, type OAuthTokenEndpoint } from "./capabilities.js";
|
|
8
|
+
/** The largest token request body the gateway reads: real ones are a few hundred bytes. */
|
|
9
|
+
export declare const OAUTH_TOKEN_BODY_LIMIT: number;
|
|
10
|
+
/** An OAuth client as the gateway (or `.dev.vars`) holds it. */
|
|
11
|
+
export interface OAuthClientCredentials {
|
|
12
|
+
clientId: string;
|
|
13
|
+
/** Absent for a public client. */
|
|
14
|
+
clientSecret?: string;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* The client `settings` hold for `capability`, or null until every setting
|
|
18
|
+
* it needs is set: the id, and the secret unless it is a public client.
|
|
19
|
+
*/
|
|
20
|
+
export declare function oauthClientCredentials(capability: OAuthClientCapability, settings: CapabilitySettings): OAuthClientCredentials | null;
|
|
21
|
+
/** A token request: where it goes, its headers, its (buffered) body. */
|
|
22
|
+
export interface TokenRequest {
|
|
23
|
+
url: URL;
|
|
24
|
+
headers: Headers;
|
|
25
|
+
body: string | null;
|
|
26
|
+
}
|
|
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
|
+
/**
|
|
57
|
+
* A token request's `grant_type` for logs: one of the known grant types,
|
|
58
|
+
* `other`, or null when it names none.
|
|
59
|
+
*/
|
|
60
|
+
export declare function tokenGrantType(request: TokenRequest): string | null;
|
|
61
|
+
//# sourceMappingURL=oauthClient.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"oauthClient.d.ts","sourceRoot":"","sources":["../../src/internal/oauthClient.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAEL,KAAK,kBAAkB,EACvB,KAAK,qBAAqB,EAC1B,KAAK,kBAAkB,EACxB,MAAM,mBAAmB,CAAC;AAE3B,2FAA2F;AAC3F,eAAO,MAAM,sBAAsB,QAAY,CAAC;AAEhD,gEAAgE;AAChE,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;AAMD,wEAAwE;AACxE,MAAM,WAAW,YAAY;IAC3B,GAAG,EAAE,GAAG,CAAC;IACT,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;CACrB;AAED,MAAM,MAAM,oBAAoB,GAC5B,CAAC;IAAE,EAAE,EAAE,IAAI,CAAA;CAAE,GAAG,YAAY,CAAC,GAC7B;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC;AAOnC;;;;;;;GAOG;AACH,wBAAgB,uBAAuB,CACrC,OAAO,EAAE,YAAY,EACrB,IAAI,EAAE,kBAAkB,EACxB,MAAM,EAAE,sBAAsB,GAC7B,oBAAoB,CAoDtB;AAUD;;;;;;GAMG;AACH,eAAO,MAAM,sBAAsB,EAAE,WAAW,CAAC,MAAM,CAIrD,CAAC;AAEH;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,YAAY,GAAG,MAAM,GAAG,IAAI,CAQvE;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,YAAY,GAAG,MAAM,GAAG,IAAI,CAInE"}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `oauth_client` capability's wire rules (docs/capabilities.md "OAuth
|
|
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. */
|
|
9
|
+
export const OAUTH_TOKEN_BODY_LIMIT = 64 * 1024;
|
|
10
|
+
/**
|
|
11
|
+
* The client `settings` hold for `capability`, or null until every setting
|
|
12
|
+
* it needs is set: the id, and the secret unless it is a public client.
|
|
13
|
+
*/
|
|
14
|
+
export function oauthClientCredentials(capability, settings) {
|
|
15
|
+
const clientId = settingValue(settings[capability.secrets.clientId]);
|
|
16
|
+
const secretName = capability.secrets.clientSecret;
|
|
17
|
+
const clientSecret = secretName
|
|
18
|
+
? settingValue(settings[secretName])
|
|
19
|
+
: undefined;
|
|
20
|
+
if (!clientId || (secretName && !clientSecret))
|
|
21
|
+
return null;
|
|
22
|
+
return { clientId, ...(clientSecret ? { clientSecret } : {}) };
|
|
23
|
+
}
|
|
24
|
+
function settingValue(value) {
|
|
25
|
+
return typeof value === "string" && value.trim() ? value.trim() : undefined;
|
|
26
|
+
}
|
|
27
|
+
const FORM = "application/x-www-form-urlencoded";
|
|
28
|
+
const isCredential = (name) => ["client_id", "client_secret"].includes(name.toLowerCase());
|
|
29
|
+
/**
|
|
30
|
+
* `request` with `client` put where `rule` says (the form body or HTTP
|
|
31
|
+
* Basic), and every client credential the app sent removed wherever it
|
|
32
|
+
* was: the `Authorization` header, and `client_id`/`client_secret` (in any
|
|
33
|
+
* case) in the query string and the body. The body is re-serialised from
|
|
34
|
+
* its parsed values, so a crafted body can't carry a second secret past
|
|
35
|
+
* the parser. Token requests are form-encoded; anything else is refused.
|
|
36
|
+
*/
|
|
37
|
+
export function injectClientCredentials(request, rule, client) {
|
|
38
|
+
const fields = [
|
|
39
|
+
["client_id", client.clientId],
|
|
40
|
+
...(client.clientSecret
|
|
41
|
+
? [["client_secret", client.clientSecret]]
|
|
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)
|
|
127
|
+
return null;
|
|
128
|
+
return GRANT_TYPES.has(value) ? value : "other";
|
|
129
|
+
}
|
|
130
|
+
/** A Content-Type's media type, lowercased and without parameters. */
|
|
131
|
+
function mediaType(contentType) {
|
|
132
|
+
return (contentType ?? "").split(";")[0].trim().toLowerCase();
|
|
133
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OAuth presets (docs/design/2026-10-oauth-providers.md section 4): ready
|
|
3
|
+
* `oauth2-user` specs, in the JSON shape `everyapp provider add` takes,
|
|
4
|
+
* for the providers people most often want a "Connect" button for. A
|
|
5
|
+
* preset becomes a `providers` row when added (`everyapp provider add
|
|
6
|
+
* --oauth github`, the Admin dialog, `everyapp_provider_add` with
|
|
7
|
+
* `preset`), so an operator may `provider show` and edit a copy; nothing
|
|
8
|
+
* here is a hidden catalog entry, and no gateway reserves a preset's
|
|
9
|
+
* setting names until it is added. Google, Microsoft and Slack are
|
|
10
|
+
* catalog clients with a `flow` and are offered in the same picker. The
|
|
11
|
+
* social networks' presets carry the tag `social`.
|
|
12
|
+
*
|
|
13
|
+
* Each preset parses with `parseProviderSpec` (oauthPresets.test.ts),
|
|
14
|
+
* names a console where the client is made, the API hosts the token is
|
|
15
|
+
* sent to, and scope sets an app declares under `scopes`. Scope strings
|
|
16
|
+
* are the providers' own, verified against their docs on 2026-10-25;
|
|
17
|
+
* the social presets' come from the catalog entries Postiz used, and
|
|
18
|
+
* none of them has been tried against a live connect yet.
|
|
19
|
+
*/
|
|
20
|
+
import { type RegistrableCapability } from "./providerSpec.js";
|
|
21
|
+
/** A preset's spec as JSON: the shape of ./oauthSpec.ts. */
|
|
22
|
+
export type OAuthPresetSpec = Readonly<Record<string, unknown>>;
|
|
23
|
+
export declare const OAUTH_PRESETS: Readonly<Record<string, OAuthPresetSpec>>;
|
|
24
|
+
/** The preset ids, in the order the picker shows them. */
|
|
25
|
+
export declare function oauthPresetIds(): string[];
|
|
26
|
+
/** A preset's parsed capability, for the picker's labels; throws for an unknown id (the test parses every preset). */
|
|
27
|
+
export declare function oauthPreset(id: string): RegistrableCapability | null;
|
|
28
|
+
/** Whether `capability` is an OAuth provider the Gateway runs the flow for. */
|
|
29
|
+
export declare function isOAuthProvider(capability: {
|
|
30
|
+
mode: string;
|
|
31
|
+
flow?: unknown;
|
|
32
|
+
} | undefined): boolean;
|
|
33
|
+
//# sourceMappingURL=oauthPresets.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"oauthPresets.d.ts","sourceRoot":"","sources":["../../src/internal/oauthPresets.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,OAAO,EAEL,KAAK,qBAAqB,EAC3B,MAAM,mBAAmB,CAAC;AAE3B,4DAA4D;AAC5D,MAAM,MAAM,eAAe,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;AAEhE,eAAO,MAAM,aAAa,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAugCnE,CAAC;AAEF,0DAA0D;AAC1D,wBAAgB,cAAc,IAAI,MAAM,EAAE,CAEzC;AAED,sHAAsH;AACtH,wBAAgB,WAAW,CAAC,EAAE,EAAE,MAAM,GAAG,qBAAqB,GAAG,IAAI,CAUpE;AAED,+EAA+E;AAC/E,wBAAgB,eAAe,CAC7B,UAAU,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,OAAO,CAAA;CAAE,GAAG,SAAS,GACvD,OAAO,CAET"}
|