@every-app/sdk 0.2.0 → 0.3.0-rc.2

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.
Files changed (135) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +608 -2
  3. package/dist/cloudflare/index.d.ts +22 -0
  4. package/dist/cloudflare/index.d.ts.map +1 -0
  5. package/dist/cloudflare/index.js +21 -0
  6. package/dist/cloudflare/sentinel.d.ts +69 -0
  7. package/dist/cloudflare/sentinel.d.ts.map +1 -0
  8. package/dist/cloudflare/sentinel.js +50 -0
  9. package/dist/cloudflare/worker.d.ts +592 -0
  10. package/dist/cloudflare/worker.d.ts.map +1 -0
  11. package/dist/cloudflare/worker.js +817 -0
  12. package/dist/dev/index.d.ts +8 -0
  13. package/dist/dev/index.d.ts.map +1 -0
  14. package/dist/dev/index.js +7 -0
  15. package/dist/dev/keypair.d.ts +24 -0
  16. package/dist/dev/keypair.d.ts.map +1 -0
  17. package/dist/dev/keypair.js +60 -0
  18. package/dist/internal/aiProviders.d.ts +67 -0
  19. package/dist/internal/aiProviders.d.ts.map +1 -0
  20. package/dist/internal/aiProviders.js +220 -0
  21. package/dist/internal/appSettings.d.ts +237 -0
  22. package/dist/internal/appSettings.d.ts.map +1 -0
  23. package/dist/internal/appSettings.js +374 -0
  24. package/dist/internal/capabilities.d.ts +3249 -0
  25. package/dist/internal/capabilities.d.ts.map +1 -0
  26. package/dist/internal/capabilities.js +1532 -0
  27. package/dist/internal/catalog/commerce.d.ts +394 -0
  28. package/dist/internal/catalog/commerce.d.ts.map +1 -0
  29. package/dist/internal/catalog/commerce.js +477 -0
  30. package/dist/internal/catalog/comms.d.ts +338 -0
  31. package/dist/internal/catalog/comms.d.ts.map +1 -0
  32. package/dist/internal/catalog/comms.js +477 -0
  33. package/dist/internal/catalog/index.d.ts +1899 -0
  34. package/dist/internal/catalog/index.d.ts.map +1 -0
  35. package/dist/internal/catalog/index.js +19 -0
  36. package/dist/internal/catalog/inference.d.ts +356 -0
  37. package/dist/internal/catalog/inference.d.ts.map +1 -0
  38. package/dist/internal/catalog/inference.js +425 -0
  39. package/dist/internal/catalog/infra.d.ts +423 -0
  40. package/dist/internal/catalog/infra.d.ts.map +1 -0
  41. package/dist/internal/catalog/infra.js +543 -0
  42. package/dist/internal/catalog/search.d.ts +400 -0
  43. package/dist/internal/catalog/search.d.ts.map +1 -0
  44. package/dist/internal/catalog/search.js +463 -0
  45. package/dist/internal/devProviders.d.ts +49 -0
  46. package/dist/internal/devProviders.d.ts.map +1 -0
  47. package/dist/internal/devProviders.js +62 -0
  48. package/dist/internal/email.d.ts +280 -0
  49. package/dist/internal/email.d.ts.map +1 -0
  50. package/dist/internal/email.js +613 -0
  51. package/dist/internal/events.d.ts +182 -0
  52. package/dist/internal/events.d.ts.map +1 -0
  53. package/dist/internal/events.js +326 -0
  54. package/dist/internal/gatewaySettings.d.ts +83 -0
  55. package/dist/internal/gatewaySettings.d.ts.map +1 -0
  56. package/dist/internal/gatewaySettings.js +217 -0
  57. package/dist/internal/identity.d.ts +18 -3
  58. package/dist/internal/identity.d.ts.map +1 -1
  59. package/dist/internal/identity.js +53 -14
  60. package/dist/internal/index.d.ts +18 -1
  61. package/dist/internal/index.d.ts.map +1 -1
  62. package/dist/internal/index.js +18 -1
  63. package/dist/internal/members.d.ts +35 -0
  64. package/dist/internal/members.d.ts.map +1 -0
  65. package/dist/internal/members.js +7 -0
  66. package/dist/internal/oauthClient.d.ts +63 -0
  67. package/dist/internal/oauthClient.d.ts.map +1 -0
  68. package/dist/internal/oauthClient.js +194 -0
  69. package/dist/internal/oauthScopes.d.ts +117 -0
  70. package/dist/internal/oauthScopes.d.ts.map +1 -0
  71. package/dist/internal/oauthScopes.js +416 -0
  72. package/dist/internal/organizationName.d.ts +18 -0
  73. package/dist/internal/organizationName.d.ts.map +1 -0
  74. package/dist/internal/organizationName.js +24 -0
  75. package/dist/internal/protocol.d.ts +86 -2
  76. package/dist/internal/protocol.d.ts.map +1 -1
  77. package/dist/internal/protocol.js +112 -1
  78. package/dist/internal/providerApps.d.ts +75 -0
  79. package/dist/internal/providerApps.d.ts.map +1 -0
  80. package/dist/internal/providerApps.js +59 -0
  81. package/dist/internal/providerRegistry.d.ts +147 -0
  82. package/dist/internal/providerRegistry.d.ts.map +1 -0
  83. package/dist/internal/providerRegistry.js +266 -0
  84. package/dist/internal/providerSpec.d.ts +55 -0
  85. package/dist/internal/providerSpec.d.ts.map +1 -0
  86. package/dist/internal/providerSpec.js +758 -0
  87. package/dist/internal/remoteMcp.d.ts +188 -0
  88. package/dist/internal/remoteMcp.d.ts.map +1 -0
  89. package/dist/internal/remoteMcp.js +543 -0
  90. package/dist/internal/signInProviders.d.ts +104 -0
  91. package/dist/internal/signInProviders.d.ts.map +1 -0
  92. package/dist/internal/signInProviders.js +238 -0
  93. package/dist/internal/tools.d.ts +115 -0
  94. package/dist/internal/tools.d.ts.map +1 -0
  95. package/dist/internal/tools.js +80 -0
  96. package/dist/server/attribution.d.ts +39 -0
  97. package/dist/server/attribution.d.ts.map +1 -0
  98. package/dist/server/attribution.js +67 -0
  99. package/dist/server/authorizeUrl.d.ts +43 -0
  100. package/dist/server/authorizeUrl.d.ts.map +1 -0
  101. package/dist/server/authorizeUrl.js +110 -0
  102. package/dist/server/emit.d.ts +63 -0
  103. package/dist/server/emit.d.ts.map +1 -0
  104. package/dist/server/emit.js +101 -0
  105. package/dist/server/everyApp.d.ts +38 -12
  106. package/dist/server/everyApp.d.ts.map +1 -1
  107. package/dist/server/everyApp.js +92 -28
  108. package/dist/server/gatewayFetch.d.ts +24 -8
  109. package/dist/server/gatewayFetch.d.ts.map +1 -1
  110. package/dist/server/gatewayFetch.js +81 -36
  111. package/dist/server/index.d.ts +10 -1
  112. package/dist/server/index.d.ts.map +1 -1
  113. package/dist/server/index.js +8 -1
  114. package/dist/server/integrationFetch.d.ts +131 -0
  115. package/dist/server/integrationFetch.d.ts.map +1 -0
  116. package/dist/server/integrationFetch.js +526 -0
  117. package/dist/server/listMembers.d.ts +32 -0
  118. package/dist/server/listMembers.d.ts.map +1 -0
  119. package/dist/server/listMembers.js +74 -0
  120. package/dist/server/nodeServer.d.ts +48 -0
  121. package/dist/server/nodeServer.d.ts.map +1 -0
  122. package/dist/server/nodeServer.js +45 -0
  123. package/dist/server/sendEmail.d.ts +39 -0
  124. package/dist/server/sendEmail.d.ts.map +1 -0
  125. package/dist/server/sendEmail.js +114 -0
  126. package/dist/server/tools.d.ts +184 -0
  127. package/dist/server/tools.d.ts.map +1 -0
  128. package/dist/server/tools.js +347 -0
  129. package/dist/server/toolsEndpoint.d.ts +32 -0
  130. package/dist/server/toolsEndpoint.d.ts.map +1 -0
  131. package/dist/server/toolsEndpoint.js +231 -0
  132. package/package.json +19 -6
  133. package/dist/server/mcp.d.ts +0 -66
  134. package/dist/server/mcp.d.ts.map +0 -1
  135. package/dist/server/mcp.js +0 -147
@@ -0,0 +1,217 @@
1
+ /**
2
+ * The Gateway's settings and the app's own secrets, by name: the Gateway
3
+ * settings an operator changes with `everyapp secret set <NAME>` (plain
4
+ * secrets on the Gateway Worker, read on its next request), the ones the
5
+ * install writes once, and the names an app's own secret can never take.
6
+ * What an app's manifest needs of them is appSettings.ts. One registry serves
7
+ * the CLI (a Gateway name goes to the Gateway, any other to the app in the
8
+ * current directory), the manifest validator (an app's `secrets` may not
9
+ * take a Gateway name, since the app reaches those through `providers` and
10
+ * `capabilities`) and the Gateway's dev config, which a test keeps
11
+ * declaring every settable one.
12
+ */
13
+ import { CAPABILITIES, CAPABILITY_IDS, capabilitySettings, } from "./capabilities.js";
14
+ import { PLAIN_SIGN_IN_SETTINGS, SIGN_IN_GATEWAY_SETTINGS, } from "./signInProviders.js";
15
+ /**
16
+ * The Gateway's own settings: the install writes them once (`everyapp
17
+ * setup`), or an operator by hand (THIRD_PARTY_DEPLOYS), and `everyapp
18
+ * secret set` never changes them. An app's own Worker may still have a
19
+ * secret of the same name (OpenSEO's BETTER_AUTH_SECRET): the two never meet.
20
+ */
21
+ export const INSTALL_OWNED_GATEWAY_SETTINGS = [
22
+ "GATEWAY_URL",
23
+ "APP_BASE_DOMAIN",
24
+ "BETTER_AUTH_SECRET",
25
+ "JWT_PRIVATE_KEY",
26
+ "JWT_PUBLIC_KEY",
27
+ "GATEWAY_DEPLOYMENT_MODE",
28
+ "CLOUDFLARE_ACCOUNT_ID",
29
+ "THIRD_PARTY_DEPLOYS",
30
+ ];
31
+ const INSTALL_OWNED = new Set(INSTALL_OWNED_GATEWAY_SETTINGS);
32
+ export function isInstallOwnedGatewaySetting(name) {
33
+ return INSTALL_OWNED.has(name);
34
+ }
35
+ /**
36
+ * The settings the catalog's providers read (the AI providers' keys, the
37
+ * API-key providers' keys, the OAuth clients and the Mastodon instance's
38
+ * URL), in catalog order, the install's own left out: what `everyapp
39
+ * secret set` accepts because a provider reads it. A gateway's registered
40
+ * rows add theirs at run time (providerRegistry.settingNames()).
41
+ */
42
+ const PROVIDER_GATEWAY_SETTINGS = [
43
+ ...new Set(CAPABILITY_IDS.flatMap((id) => {
44
+ const capability = CAPABILITIES[id];
45
+ return capability.mode === "service"
46
+ ? []
47
+ : capabilitySettings(capability);
48
+ })),
49
+ ].filter((name) => !INSTALL_OWNED.has(name));
50
+ /** The Gateway's own optional settings `everyapp secret set` changes: nothing a provider reads. */
51
+ export const GATEWAY_OWN_SETTINGS = [
52
+ "AI_PROXY_EXTRA_ROUTES",
53
+ // Email's providers: Cloudflare's REST token, Resend's key, the choice.
54
+ "EMAIL_REST_API_TOKEN",
55
+ "RESEND_API_KEY",
56
+ "EMAIL_PROVIDER",
57
+ "EMAIL_FROM",
58
+ "EMAIL_FROM_NAME",
59
+ "MCP_OAUTH_ENABLED",
60
+ "MCP_DCR_ENABLED",
61
+ "MCP_ALLOWED_ORIGINS",
62
+ "MCP_AUDIT_RETENTION_DAYS",
63
+ "CLOUDFLARE_ACCESS_OIDC_ISSUER",
64
+ "CLOUDFLARE_ACCESS_OIDC_CLIENT_ID",
65
+ "CLOUDFLARE_ACCESS_OIDC_CLIENT_SECRET",
66
+ "CLOUDFLARE_ACCESS_OIDC_LABEL",
67
+ "CLOUDFLARE_ACCESS_TEAM_DOMAIN",
68
+ "CLOUDFLARE_ACCESS_AUD",
69
+ "CLOUDFLARE_ACCESS_APPS_AUD",
70
+ "CLOUDFLARE_ACCESS_AUTO_JOIN_DOMAINS",
71
+ "CLOUDFLARE_ACCESS_OUTER_RING_AUTO_JOIN",
72
+ "EMAIL_PASSWORD_SIGN_IN",
73
+ // "false" keeps the hosted gateway's sign-up invite-only.
74
+ "HOSTED_OPEN_SIGNUP",
75
+ // Release deployers and the hosted third-party domain. The hosted launch
76
+ // gate, THIRD_PARTY_DEPLOYS, is never set from here: it is opened by
77
+ // hand once the launch checks pass (docs/runbooks/hosted-install.md).
78
+ "CF_DEPLOY_TOKEN",
79
+ // Self-hosted browser installs are on by default; "off" opts out.
80
+ "BROWSER_APP_INSTALLS",
81
+ "DISPATCH_NAMESPACE",
82
+ "THIRD_PARTY_DOMAIN",
83
+ // "true" lets event webhooks target http: and private hosts (self-host only).
84
+ "EVENTS_ALLOW_PRIVATE_TARGETS",
85
+ ];
86
+ /**
87
+ * The Gateway's optional settings `everyapp secret set` changes: every
88
+ * setting a catalog provider reads, the Gateway's own, then the sign-in
89
+ * providers' (`<ID>_SIGNIN_<FIELD>`, ./signInProviders.ts).
90
+ */
91
+ export const SETTABLE_GATEWAY_SETTINGS = [
92
+ ...PROVIDER_GATEWAY_SETTINGS,
93
+ ...GATEWAY_OWN_SETTINGS,
94
+ ...SIGN_IN_GATEWAY_SETTINGS,
95
+ ];
96
+ const SETTABLE = new Set(SETTABLE_GATEWAY_SETTINGS);
97
+ /**
98
+ * The credential names of remote MCP apps (`everyapp mcp add <url>`,
99
+ * ./remoteMcp.ts): `<ID>_MCP_TOKEN` by default, any name ending in
100
+ * `_MCP_TOKEN` by choice. A family rather than a list, so the names a
101
+ * registry row declares at run time route to the Gateway like the fixed
102
+ * names (`everyapp secret set` reads no registry to decide), an app's own
103
+ * secret can never take one (the manifest validator refuses the family),
104
+ * and a remote server can never be given a fixed provider key.
105
+ */
106
+ export const REMOTE_MCP_SECRET_PATTERN = /^[A-Z][A-Z0-9_]*_MCP_TOKEN$/;
107
+ /** Whether `name` is a remote MCP app's credential name (`TREG_MCP_TOKEN`). */
108
+ export function isRemoteMcpSecretName(name) {
109
+ return REMOTE_MCP_SECRET_PATTERN.test(name);
110
+ }
111
+ /**
112
+ * Whether `everyapp secret set <name>` changes the Gateway: one of the
113
+ * fixed settings, or a remote MCP app's credential name.
114
+ */
115
+ export function isSettableGatewaySetting(name) {
116
+ return SETTABLE.has(name) || isRemoteMcpSecretName(name);
117
+ }
118
+ /**
119
+ * Settable Gateway settings whose value is a plain word, address, list
120
+ * or switch rather than a credential: a sender, a provider choice, a
121
+ * URL, an audience, a flag. `everyapp secret set` may show these as they
122
+ * are typed and check their shape; anything else is a credential and
123
+ * stays hidden.
124
+ */
125
+ export const PLAIN_GATEWAY_SETTINGS = [
126
+ "EMAIL_FROM",
127
+ "EMAIL_FROM_NAME",
128
+ "EMAIL_PROVIDER",
129
+ "EMAIL_PASSWORD_SIGN_IN",
130
+ "MASTODON_URL",
131
+ "AI_PROXY_EXTRA_ROUTES",
132
+ "MCP_OAUTH_ENABLED",
133
+ "MCP_DCR_ENABLED",
134
+ "MCP_ALLOWED_ORIGINS",
135
+ "MCP_AUDIT_RETENTION_DAYS",
136
+ "CLOUDFLARE_ACCESS_OIDC_ISSUER",
137
+ "CLOUDFLARE_ACCESS_OIDC_CLIENT_ID",
138
+ "CLOUDFLARE_ACCESS_OIDC_LABEL",
139
+ "CLOUDFLARE_ACCESS_TEAM_DOMAIN",
140
+ "CLOUDFLARE_ACCESS_AUD",
141
+ "CLOUDFLARE_ACCESS_APPS_AUD",
142
+ "CLOUDFLARE_ACCESS_AUTO_JOIN_DOMAINS",
143
+ "CLOUDFLARE_ACCESS_OUTER_RING_AUTO_JOIN",
144
+ "HOSTED_OPEN_SIGNUP",
145
+ "BROWSER_APP_INSTALLS",
146
+ "DISPATCH_NAMESPACE",
147
+ "THIRD_PARTY_DOMAIN",
148
+ "EVENTS_ALLOW_PRIVATE_TARGETS",
149
+ ];
150
+ const PLAIN = new Set([
151
+ ...PLAIN_GATEWAY_SETTINGS,
152
+ // The sign-in providers' ids, issuer, label and tenant; their client
153
+ // secrets are credentials.
154
+ ...PLAIN_SIGN_IN_SETTINGS,
155
+ ]);
156
+ /** Whether a settable Gateway setting's value is a plain value, not a credential. */
157
+ export function isPlainGatewaySetting(name) {
158
+ return PLAIN.has(name);
159
+ }
160
+ /**
161
+ * Settable Gateway settings only the hosted gateway reads: a self-hosted
162
+ * install never needs them, so `secret list` leaves them out there.
163
+ */
164
+ export const HOSTED_ONLY_GATEWAY_SETTINGS = [
165
+ "HOSTED_OPEN_SIGNUP",
166
+ "DISPATCH_NAMESPACE",
167
+ "THIRD_PARTY_DOMAIN",
168
+ ];
169
+ const HOSTED_ONLY = new Set(HOSTED_ONLY_GATEWAY_SETTINGS);
170
+ export function isHostedOnlyGatewaySetting(name) {
171
+ return HOSTED_ONLY.has(name);
172
+ }
173
+ /** Gateway settings for local testing only, set in the gateway's `.dev.vars`, never deployed. */
174
+ export const DEV_ONLY_GATEWAY_SETTINGS = [
175
+ "MCP_ACCESS_TOKEN_TTL",
176
+ // "true" sends the DataForSEO provider app's calls to the free sandbox.
177
+ "DATAFORSEO_SANDBOX",
178
+ ];
179
+ export function isDevOnlyGatewaySetting(name) {
180
+ return DEV_ONLY_GATEWAY_SETTINGS.includes(name);
181
+ }
182
+ /**
183
+ * Names an app's own secret can't take: the deploy sets GATEWAY_URL on
184
+ * every Worker and builds in the identity settings, the gateway binding
185
+ * and the platform's own namespaces. Checked without regard to case. The
186
+ * SDK's `everyAppWorker()` keeps the same rule as a regex (its config
187
+ * module can't import this one); a test keeps them in step.
188
+ */
189
+ const RESERVED_APP_SECRET_NAMES = new Set([
190
+ "GATEWAY_URL",
191
+ "CF_VERSION_METADATA",
192
+ ]);
193
+ const RESERVED_APP_SECRET_PREFIXES = [
194
+ "EVERYAPP_",
195
+ "EVERY_APP_",
196
+ "APP__",
197
+ ];
198
+ /** What the reserved names are, for messages. */
199
+ export const RESERVED_APP_SECRET_NAMES_TEXT = "GATEWAY_URL, CF_VERSION_METADATA and the EVERYAPP_*, EVERY_APP_* and APP__* names";
200
+ export function isReservedAppSecretName(name) {
201
+ const upper = name.toUpperCase();
202
+ return (RESERVED_APP_SECRET_NAMES.has(upper) ||
203
+ RESERVED_APP_SECRET_PREFIXES.some((prefix) => upper.startsWith(prefix)));
204
+ }
205
+ /**
206
+ * The AI provider or capability a Gateway setting belongs to: what to list
207
+ * in a manifest instead of holding the key as the app's own.
208
+ */
209
+ export function gatewaySettingOwner(name) {
210
+ for (const id of CAPABILITY_IDS) {
211
+ const capability = CAPABILITIES[id];
212
+ if (capabilitySettings(capability).includes(name)) {
213
+ return { kind: capability.mode === "ai" ? "provider" : "capability", id };
214
+ }
215
+ }
216
+ return null;
217
+ }
@@ -1,5 +1,5 @@
1
- import { APP_ID_ENV, DEV_ENV, IDENTITY_ALG, IDENTITY_DEV_KEY_ID, IDENTITY_HEADER, IDENTITY_KEY_ID, ISSUER_ENV, PUBLIC_HEADER, PUBLIC_KEYS_ENV, PUBLIC_MARKER_SUB, type EveryAppUser, type IdentityChannel } from "./protocol.js";
2
- export { APP_ID_ENV, DEV_ENV, IDENTITY_ALG, IDENTITY_DEV_KEY_ID, IDENTITY_HEADER, IDENTITY_KEY_ID, ISSUER_ENV, PUBLIC_HEADER, PUBLIC_KEYS_ENV, PUBLIC_MARKER_SUB, type EveryAppUser, type IdentityChannel, };
1
+ import { APP_ID_ENV, DEV_ENV, DEV_ISSUER, IDENTITY_ALG, IDENTITY_DEV_KEY_ID, IDENTITY_HEADER, IDENTITY_KEY_ID, ISSUER_ENV, PUBLIC_HEADER, PUBLIC_KEYS_ENV, PUBLIC_MARKER_SUB, type EveryAppUser, type IdentityChannel, type SystemClaims, type SystemTokenPurpose } from "./protocol.js";
2
+ export { APP_ID_ENV, DEV_ENV, DEV_ISSUER, IDENTITY_ALG, IDENTITY_DEV_KEY_ID, IDENTITY_HEADER, IDENTITY_KEY_ID, ISSUER_ENV, PUBLIC_HEADER, PUBLIC_KEYS_ENV, PUBLIC_MARKER_SUB, type EveryAppUser, type IdentityChannel, };
3
3
  export declare class IdentityError extends Error {
4
4
  readonly status = 401;
5
5
  constructor(message: string);
@@ -23,7 +23,7 @@ export interface VerifyOptions {
23
23
  /**
24
24
  * Accept the dev identity kid ({@link IDENTITY_DEV_KEY_ID}). Set ONLY in
25
25
  * local dev (driven by the {@link DEV_ENV} worker env var). Never true in
26
- * production.
26
+ * production. Requires `issuer` to be {@link DEV_ISSUER}.
27
27
  */
28
28
  allowDevIdentities?: boolean;
29
29
  /** Override for tests. */
@@ -35,6 +35,14 @@ export interface VerifyOptions {
35
35
  * claims).
36
36
  */
37
37
  export declare function verifyIdentityJwt(token: string, options: VerifyOptions): Promise<EveryAppUser>;
38
+ /**
39
+ * Verify the gateway's system token (the value of `x-everyapp-system`)
40
+ * fail-closed, for exactly one purpose. A user identity or public marker is
41
+ * never a system token, and a system token is never an identity.
42
+ */
43
+ export declare function verifySystemJwt(token: string, options: VerifyOptions & {
44
+ purpose: SystemTokenPurpose;
45
+ }): Promise<SystemClaims>;
38
46
  /**
39
47
  * Verify a public-route marker (the value of `x-everyapp-public`). The marker
40
48
  * is a gateway-signed, app-scoped JWT with `pub: true` and `typ: "public"` —
@@ -61,6 +69,13 @@ export interface RequestIdentityOptions {
61
69
  allowDevIdentities?: boolean;
62
70
  now?: number;
63
71
  }
72
+ /**
73
+ * The verification options for a request: keys from options or env, the
74
+ * expected issuer, and the dev-kid opt-in. Throws {@link ConfigurationError}
75
+ * when no key set is configured, or when the dev opt-in meets an issuer other
76
+ * than {@link DEV_ISSUER}.
77
+ */
78
+ export declare function resolveVerifyOptions(options: RequestIdentityOptions): VerifyOptions;
64
79
  /**
65
80
  * Resolve identity for an incoming proxied request. Public routes carry a
66
81
  * gateway-SIGNED marker in `x-everyapp-public` and resolve to
@@ -1 +1 @@
1
- {"version":3,"file":"identity.d.ts","sourceRoot":"","sources":["../../src/internal/identity.ts"],"names":[],"mappings":"AAgBA,OAAO,EACL,UAAU,EACV,OAAO,EACP,YAAY,EACZ,mBAAmB,EACnB,eAAe,EACf,eAAe,EACf,UAAU,EACV,aAAa,EACb,eAAe,EACf,iBAAiB,EAIjB,KAAK,YAAY,EACjB,KAAK,eAAe,EAErB,MAAM,eAAe,CAAC;AAEvB,OAAO,EACL,UAAU,EACV,OAAO,EACP,YAAY,EACZ,mBAAmB,EACnB,eAAe,EACf,eAAe,EACf,UAAU,EACV,aAAa,EACb,eAAe,EACf,iBAAiB,EACjB,KAAK,YAAY,EACjB,KAAK,eAAe,GACrB,CAAC;AAEF,qBAAa,aAAc,SAAQ,KAAK;IACtC,QAAQ,CAAC,MAAM,OAAO;gBACV,OAAO,EAAE,MAAM;CAI5B;AAED,qBAAa,kBAAmB,SAAQ,KAAK;IAC3C,QAAQ,CAAC,MAAM,OAAO;gBACV,OAAO,EAAE,MAAM;CAI5B;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,GAAG,MAAM,EAAE,CA8B7E;AAYD,MAAM,WAAW,aAAa;IAC5B,6CAA6C;IAC7C,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,sCAAsC;IACtC,QAAQ,EAAE,MAAM,CAAC;IACjB,uEAAuE;IACvE,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;;OAIG;IACH,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,0BAA0B;IAC1B,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED;;;;GAIG;AACH,wBAAsB,iBAAiB,CACrC,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,aAAa,GACrB,OAAO,CAAC,YAAY,CAAC,CAUvB;AAmED;;;;;;GAMG;AACH,wBAAsB,qBAAqB,CACzC,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,aAAa,GACrB,OAAO,CAAC,IAAI,CAAC,CAUf;AAED,MAAM,WAAW,cAAc;IAC7B,8DAA8D;IAC9D,IAAI,EAAE,YAAY,GAAG,IAAI,CAAC;IAC1B,mEAAmE;IACnE,QAAQ,EAAE,OAAO,CAAC;CACnB;AAED,MAAM,WAAW,sBAAsB;IACrC,QAAQ,EAAE,MAAM,CAAC;IACjB,6EAA6E;IAC7E,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IACtB,sEAAsE;IACtE,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC9B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,8EAA8E;IAC9E,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED;;;;;;;GAOG;AACH,wBAAsB,sBAAsB,CAC1C,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,sBAAsB,GAC9B,OAAO,CAAC,cAAc,CAAC,CAqCzB"}
1
+ {"version":3,"file":"identity.d.ts","sourceRoot":"","sources":["../../src/internal/identity.ts"],"names":[],"mappings":"AAgBA,OAAO,EACL,UAAU,EACV,OAAO,EACP,UAAU,EACV,YAAY,EACZ,mBAAmB,EACnB,eAAe,EACf,eAAe,EACf,UAAU,EACV,aAAa,EACb,eAAe,EACf,iBAAiB,EAKjB,KAAK,YAAY,EACjB,KAAK,eAAe,EAEpB,KAAK,YAAY,EACjB,KAAK,kBAAkB,EACxB,MAAM,eAAe,CAAC;AAEvB,OAAO,EACL,UAAU,EACV,OAAO,EACP,UAAU,EACV,YAAY,EACZ,mBAAmB,EACnB,eAAe,EACf,eAAe,EACf,UAAU,EACV,aAAa,EACb,eAAe,EACf,iBAAiB,EACjB,KAAK,YAAY,EACjB,KAAK,eAAe,GACrB,CAAC;AAEF,qBAAa,aAAc,SAAQ,KAAK;IACtC,QAAQ,CAAC,MAAM,OAAO;gBACV,OAAO,EAAE,MAAM;CAI5B;AAED,qBAAa,kBAAmB,SAAQ,KAAK;IAC3C,QAAQ,CAAC,MAAM,OAAO;gBACV,OAAO,EAAE,MAAM;CAI5B;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,GAAG,MAAM,EAAE,CA8B7E;AAYD,MAAM,WAAW,aAAa;IAC5B,6CAA6C;IAC7C,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,sCAAsC;IACtC,QAAQ,EAAE,MAAM,CAAC;IACjB,uEAAuE;IACvE,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;;OAIG;IACH,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,0BAA0B;IAC1B,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAeD;;;;GAIG;AACH,wBAAsB,iBAAiB,CACrC,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,aAAa,GACrB,OAAO,CAAC,YAAY,CAAC,CAUvB;AAED;;;;GAIG;AACH,wBAAsB,eAAe,CACnC,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,aAAa,GAAG;IAAE,OAAO,EAAE,kBAAkB,CAAA;CAAE,GACvD,OAAO,CAAC,YAAY,CAAC,CAUvB;AAoED;;;;;;GAMG;AACH,wBAAsB,qBAAqB,CACzC,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,aAAa,GACrB,OAAO,CAAC,IAAI,CAAC,CAUf;AAED,MAAM,WAAW,cAAc;IAC7B,8DAA8D;IAC9D,IAAI,EAAE,YAAY,GAAG,IAAI,CAAC;IAC1B,mEAAmE;IACnE,QAAQ,EAAE,OAAO,CAAC;CACnB;AAED,MAAM,WAAW,sBAAsB;IACrC,QAAQ,EAAE,MAAM,CAAC;IACjB,6EAA6E;IAC7E,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IACtB,sEAAsE;IACtE,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC9B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,8EAA8E;IAC9E,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,sBAAsB,GAC9B,aAAa,CAwBf;AAED;;;;;;;GAOG;AACH,wBAAsB,sBAAsB,CAC1C,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,sBAAsB,GAC9B,OAAO,CAAC,cAAc,CAAC,CAiBzB"}
@@ -9,8 +9,8 @@
9
9
  * survives verification produces a user.
10
10
  */
11
11
  import { importSPKI, jwtVerify, decodeProtectedHeader, } from "jose";
12
- import { APP_ID_ENV, DEV_ENV, IDENTITY_ALG, IDENTITY_DEV_KEY_ID, IDENTITY_HEADER, IDENTITY_KEY_ID, ISSUER_ENV, PUBLIC_HEADER, PUBLIC_KEYS_ENV, PUBLIC_MARKER_SUB, assertPublicMarkerClaims, identityClaimsToEveryAppUser, ProtocolClaimsError, } from "./protocol.js";
13
- export { APP_ID_ENV, DEV_ENV, IDENTITY_ALG, IDENTITY_DEV_KEY_ID, IDENTITY_HEADER, IDENTITY_KEY_ID, ISSUER_ENV, PUBLIC_HEADER, PUBLIC_KEYS_ENV, PUBLIC_MARKER_SUB, };
12
+ import { APP_ID_ENV, DEV_ENV, DEV_ISSUER, IDENTITY_ALG, IDENTITY_DEV_KEY_ID, IDENTITY_HEADER, IDENTITY_KEY_ID, ISSUER_ENV, PUBLIC_HEADER, PUBLIC_KEYS_ENV, PUBLIC_MARKER_SUB, assertPublicMarkerClaims, assertSystemClaims, identityClaimsToEveryAppUser, ProtocolClaimsError, } from "./protocol.js";
13
+ export { APP_ID_ENV, DEV_ENV, DEV_ISSUER, IDENTITY_ALG, IDENTITY_DEV_KEY_ID, IDENTITY_HEADER, IDENTITY_KEY_ID, ISSUER_ENV, PUBLIC_HEADER, PUBLIC_KEYS_ENV, PUBLIC_MARKER_SUB, };
14
14
  export class IdentityError extends Error {
15
15
  status = 401;
16
16
  constructor(message) {
@@ -65,6 +65,16 @@ function importKey(pem) {
65
65
  }
66
66
  return cached;
67
67
  }
68
+ /**
69
+ * The dev keypair is public (`@every-app/sdk/dev`), so the dev opt-in holds
70
+ * only for the dev issuer: a dev-kid token that names a real gateway as its
71
+ * issuer never verifies, whatever the env says.
72
+ */
73
+ function assertDevIssuer(options) {
74
+ if (options.allowDevIdentities && options.issuer !== DEV_ISSUER) {
75
+ throw new ConfigurationError(`Dev identities are accepted only from the dev issuer ${DEV_ISSUER}, not ${options.issuer ? `"${options.issuer}"` : "an unset issuer"}. ${DEV_ENV} is for \`everyapp dev\` alone.`);
76
+ }
77
+ }
68
78
  /**
69
79
  * Verify an identity JWT fail-closed. Throws {@link IdentityError} on any
70
80
  * problem (bad alg/kid, `none`, wrong key, expired, wrong audience, missing
@@ -82,11 +92,29 @@ export async function verifyIdentityJwt(token, options) {
82
92
  throw error;
83
93
  }
84
94
  }
95
+ /**
96
+ * Verify the gateway's system token (the value of `x-everyapp-system`)
97
+ * fail-closed, for exactly one purpose. A user identity or public marker is
98
+ * never a system token, and a system token is never an identity.
99
+ */
100
+ export async function verifySystemJwt(token, options) {
101
+ const payload = await verifyPinnedJwt(token, options, "system");
102
+ try {
103
+ return assertSystemClaims(payload, options.purpose);
104
+ }
105
+ catch (error) {
106
+ if (error instanceof ProtocolClaimsError) {
107
+ throw new IdentityError(error.message);
108
+ }
109
+ throw error;
110
+ }
111
+ }
85
112
  /**
86
113
  * The shared fail-closed verification core: pinned alg/kid, `none` rejected,
87
114
  * `aud` checked, multi-key (current + next). Returns the verified payload.
88
115
  */
89
116
  async function verifyPinnedJwt(token, options, expectedTyp) {
117
+ assertDevIssuer(options);
90
118
  if (!token)
91
119
  throw new IdentityError("no identity token");
92
120
  // Pin the header BEFORE attempting any signature work. This is what defeats
@@ -108,13 +136,13 @@ async function verifyPinnedJwt(token, options, expectedTyp) {
108
136
  if (!header.kid || !allowedKids.includes(header.kid)) {
109
137
  throw new IdentityError(`unexpected kid "${header.kid}"`);
110
138
  }
111
- if (expectedTyp === "user" && !options.issuer) {
139
+ if (expectedTyp !== "public" && !options.issuer) {
112
140
  throw new IdentityError(`${ISSUER_ENV} not configured — deploy with the Every App CLI or provide an explicit issuer.`);
113
141
  }
114
142
  const verifyOpts = {
115
143
  algorithms: [IDENTITY_ALG],
116
144
  audience: options.audience,
117
- requiredClaims: ["exp"],
145
+ requiredClaims: expectedTyp === "system" ? ["exp", "iat"] : ["exp"],
118
146
  ...(options.issuer ? { issuer: options.issuer } : {}),
119
147
  ...(options.now ? { currentDate: new Date(options.now) } : {}),
120
148
  };
@@ -154,23 +182,21 @@ export async function verifyPublicMarkerJwt(token, options) {
154
182
  }
155
183
  }
156
184
  /**
157
- * Resolve identity for an incoming proxied request. Public routes carry a
158
- * gateway-SIGNED marker in `x-everyapp-public` and resolve to
159
- * `{ user: null, isPublic: true }` only after the marker verifies. Everything
160
- * else requires a valid identity JWT. Throws {@link IdentityError} on any
161
- * problem — including a bare/forged public header — so a re-exposed worker
162
- * fails closed.
185
+ * The verification options for a request: keys from options or env, the
186
+ * expected issuer, and the dev-kid opt-in. Throws {@link ConfigurationError}
187
+ * when no key set is configured, or when the dev opt-in meets an issuer other
188
+ * than {@link DEV_ISSUER}.
163
189
  */
164
- export async function getIdentityFromRequest(request, options) {
190
+ export function resolveVerifyOptions(options) {
165
191
  const publicKeys = options.publicKeys ??
166
192
  parsePublicKeys(options.env?.[options.keysEnvVar ?? PUBLIC_KEYS_ENV] ?? null);
167
- // Dev identities are accepted only when the worker env opts in (everyapp dev
168
- // sets EVERYAPP_DEV in .dev.vars). Production never sets it.
193
+ // Dev identities are accepted only when the worker env opts in
194
+ // (everyAppWorker() sets EVERYAPP_DEV in development). A deploy never does.
169
195
  const devEnv = options.env?.[DEV_ENV];
170
196
  const allowDevIdentities = options.allowDevIdentities ??
171
197
  (typeof devEnv === "string" &&
172
198
  (devEnv === "1" || devEnv.toLowerCase() === "true"));
173
- const verifyOptions = {
199
+ const resolved = {
174
200
  publicKeys,
175
201
  audience: options.audience,
176
202
  issuer: options.issuer ??
@@ -178,6 +204,19 @@ export async function getIdentityFromRequest(request, options) {
178
204
  allowDevIdentities,
179
205
  now: options.now,
180
206
  };
207
+ assertDevIssuer(resolved);
208
+ return resolved;
209
+ }
210
+ /**
211
+ * Resolve identity for an incoming proxied request. Public routes carry a
212
+ * gateway-SIGNED marker in `x-everyapp-public` and resolve to
213
+ * `{ user: null, isPublic: true }` only after the marker verifies. Everything
214
+ * else requires a valid identity JWT. Throws {@link IdentityError} on any
215
+ * problem — including a bare/forged public header — so a re-exposed worker
216
+ * fails closed.
217
+ */
218
+ export async function getIdentityFromRequest(request, options) {
219
+ const verifyOptions = resolveVerifyOptions(options);
181
220
  const publicMarker = request.headers.get(PUBLIC_HEADER);
182
221
  if (publicMarker) {
183
222
  await verifyPublicMarkerJwt(publicMarker, verifyOptions);
@@ -1,3 +1,20 @@
1
1
  export * from "./protocol.js";
2
- export { ConfigurationError, IdentityError, getIdentityFromRequest, parsePublicKeys, verifyIdentityJwt, verifyPublicMarkerJwt, type IdentityResult, type RequestIdentityOptions, type VerifyOptions, } from "./identity.js";
2
+ export * from "./tools.js";
3
+ export * from "./capabilities.js";
4
+ export * from "./aiProviders.js";
5
+ export * from "./gatewaySettings.js";
6
+ export * from "./appSettings.js";
7
+ export * from "./email.js";
8
+ export * from "./members.js";
9
+ export * from "./organizationName.js";
10
+ export * from "./oauthClient.js";
11
+ export * from "./oauthScopes.js";
12
+ export * from "./providerApps.js";
13
+ export * from "./events.js";
14
+ export * from "./providerSpec.js";
15
+ export * from "./providerRegistry.js";
16
+ export * from "./remoteMcp.js";
17
+ export * from "./signInProviders.js";
18
+ export * from "./devProviders.js";
19
+ export { ConfigurationError, IdentityError, getIdentityFromRequest, parsePublicKeys, resolveVerifyOptions, verifyIdentityJwt, verifyPublicMarkerJwt, verifySystemJwt, type IdentityResult, type RequestIdentityOptions, type VerifyOptions, } from "./identity.js";
3
20
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/internal/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,OAAO,EACL,kBAAkB,EAClB,aAAa,EACb,sBAAsB,EACtB,eAAe,EACf,iBAAiB,EACjB,qBAAqB,EACrB,KAAK,cAAc,EACnB,KAAK,sBAAsB,EAC3B,KAAK,aAAa,GACnB,MAAM,eAAe,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/internal/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AACjC,cAAc,sBAAsB,CAAC;AACrC,cAAc,kBAAkB,CAAC;AACjC,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,uBAAuB,CAAC;AACtC,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,aAAa,CAAC;AAC5B,cAAc,mBAAmB,CAAC;AAClC,cAAc,uBAAuB,CAAC;AACtC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,sBAAsB,CAAC;AACrC,cAAc,mBAAmB,CAAC;AAClC,OAAO,EACL,kBAAkB,EAClB,aAAa,EACb,sBAAsB,EACtB,eAAe,EACf,oBAAoB,EACpB,iBAAiB,EACjB,qBAAqB,EACrB,eAAe,EACf,KAAK,cAAc,EACnB,KAAK,sBAAsB,EAC3B,KAAK,aAAa,GACnB,MAAM,eAAe,CAAC"}
@@ -1,2 +1,19 @@
1
1
  export * from "./protocol.js";
2
- export { ConfigurationError, IdentityError, getIdentityFromRequest, parsePublicKeys, verifyIdentityJwt, verifyPublicMarkerJwt, } from "./identity.js";
2
+ export * from "./tools.js";
3
+ export * from "./capabilities.js";
4
+ export * from "./aiProviders.js";
5
+ export * from "./gatewaySettings.js";
6
+ export * from "./appSettings.js";
7
+ export * from "./email.js";
8
+ export * from "./members.js";
9
+ export * from "./organizationName.js";
10
+ export * from "./oauthClient.js";
11
+ export * from "./oauthScopes.js";
12
+ export * from "./providerApps.js";
13
+ export * from "./events.js";
14
+ export * from "./providerSpec.js";
15
+ export * from "./providerRegistry.js";
16
+ export * from "./remoteMcp.js";
17
+ export * from "./signInProviders.js";
18
+ export * from "./devProviders.js";
19
+ export { ConfigurationError, IdentityError, getIdentityFromRequest, parsePublicKeys, resolveVerifyOptions, verifyIdentityJwt, verifyPublicMarkerJwt, verifySystemJwt, } from "./identity.js";
@@ -0,0 +1,35 @@
1
+ /**
2
+ * The `members` capability's wire contract (docs/capabilities.md "Gateway
3
+ * services"): what `GET /api/integrations/members/list` answers. The
4
+ * gateway builds it, the SDK's `listMembers()` returns it, and its local-dev
5
+ * fallback answers in the same shape. Types only.
6
+ */
7
+ /** A member's role in the organization. */
8
+ export type OrganizationMemberRole = "owner" | "admin" | "member";
9
+ /**
10
+ * One member of the organization who can open the app: not deactivated,
11
+ * and, for an organization's own app, granted it.
12
+ */
13
+ export interface OrganizationMember {
14
+ /** The user id, the identity's `sub` (`getEveryAppUser().id`). */
15
+ id: string;
16
+ email: string;
17
+ /** The display name; empty when the person set none. */
18
+ name: string;
19
+ role: OrganizationMemberRole;
20
+ }
21
+ /** What a list answers. */
22
+ export interface ListMembersResult {
23
+ members: OrganizationMember[];
24
+ }
25
+ /** `GET /api/integrations/members`: whether the app may list members. */
26
+ export interface MembersCapabilityStatus {
27
+ capability: "members";
28
+ /** The app's manifest lists `members`. */
29
+ requested: boolean;
30
+ /** Always true: the gateway needs no setting to list its own members. */
31
+ configured: true;
32
+ /** Lists would go through. */
33
+ ready: boolean;
34
+ }
35
+ //# sourceMappingURL=members.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"members.d.ts","sourceRoot":"","sources":["../../src/internal/members.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,2CAA2C;AAC3C,MAAM,MAAM,sBAAsB,GAAG,OAAO,GAAG,OAAO,GAAG,QAAQ,CAAC;AAElE;;;GAGG;AACH,MAAM,WAAW,kBAAkB;IACjC,kEAAkE;IAClE,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,wDAAwD;IACxD,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,sBAAsB,CAAC;CAC9B;AAED,2BAA2B;AAC3B,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,kBAAkB,EAAE,CAAC;CAC/B;AAED,yEAAyE;AACzE,MAAM,WAAW,uBAAuB;IACtC,UAAU,EAAE,SAAS,CAAC;IACtB,0CAA0C;IAC1C,SAAS,EAAE,OAAO,CAAC;IACnB,yEAAyE;IACzE,UAAU,EAAE,IAAI,CAAC;IACjB,8BAA8B;IAC9B,KAAK,EAAE,OAAO,CAAC;CAChB"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * The `members` capability's wire contract (docs/capabilities.md "Gateway
3
+ * services"): what `GET /api/integrations/members/list` answers. The
4
+ * gateway builds it, the SDK's `listMembers()` returns it, and its local-dev
5
+ * fallback answers in the same shape. Types only.
6
+ */
7
+ export {};
@@ -0,0 +1,63 @@
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, the secret (unless it is a public client), and a
19
+ * `hostSetting` that is an https origin when it is set at all.
20
+ */
21
+ export declare function oauthClientCredentials(capability: OAuthClientCapability, settings: CapabilitySettings): OAuthClientCredentials | null;
22
+ /** A token request: where it goes, its headers, its (buffered) body. */
23
+ export interface TokenRequest {
24
+ url: URL;
25
+ headers: Headers;
26
+ body: string | null;
27
+ }
28
+ export type InjectedTokenRequest = ({
29
+ ok: true;
30
+ } & TokenRequest) | {
31
+ ok: false;
32
+ problem: string;
33
+ };
34
+ /**
35
+ * `request` with `client` put where `rule` says (the form body, HTTP Basic,
36
+ * the query string or the JSON body), and every client credential the app
37
+ * sent removed wherever it was: the `Authorization` header, and
38
+ * `client_id`/`client_secret` (or the rule's names for them, in any case) in
39
+ * the query string and the body. Bodies are re-serialised from their parsed
40
+ * values, so a crafted body can't carry a second secret past the parser.
41
+ * Token requests are form-encoded or JSON; anything else is refused.
42
+ */
43
+ export declare function injectClientCredentials(request: TokenRequest, rule: OAuthTokenEndpoint, client: OAuthClientCredentials): InjectedTokenRequest;
44
+ /**
45
+ * The grants the gateway completes: each ends in a user's own tokens. The
46
+ * client-credentials grant, and anything else a network serves on the same
47
+ * endpoint, would mint a token for the gateway's own application instead,
48
+ * which on Meta, Discord, Twitch or Kick manages the application's
49
+ * settings, its webhooks and every tenant's tokens.
50
+ */
51
+ export declare const USER_BOUND_GRANT_TYPES: ReadonlySet<string>;
52
+ /**
53
+ * A token request's `grant_type` as the app sent it, from its body or query
54
+ * string, or null when it names none (Meta's code exchange). Never the
55
+ * request's other fields.
56
+ */
57
+ export declare function requestedGrantType(request: TokenRequest): string | null;
58
+ /**
59
+ * A token request's `grant_type` for logs: one of the known grant types,
60
+ * `other`, or null when it names none.
61
+ */
62
+ export declare function tokenGrantType(request: TokenRequest): string | null;
63
+ //# 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,EAGL,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;;;;GAIG;AACH,wBAAgB,sBAAsB,CACpC,UAAU,EAAE,qBAAqB,EACjC,QAAQ,EAAE,kBAAkB,GAC3B,sBAAsB,GAAG,IAAI,CAW/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;AAKnC;;;;;;;;GAQG;AACH,wBAAgB,uBAAuB,CACrC,OAAO,EAAE,YAAY,EACrB,IAAI,EAAE,kBAAkB,EACxB,MAAM,EAAE,sBAAsB,GAC7B,oBAAoB,CAyFtB;AAaD;;;;;;GAMG;AACH,eAAO,MAAM,sBAAsB,EAAE,WAAW,CAAC,MAAM,CAOrD,CAAC;AAEH;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,YAAY,GAAG,MAAM,GAAG,IAAI,CAUvE;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,YAAY,GAAG,MAAM,GAAG,IAAI,CAInE"}