@every-app/sdk 0.3.0-rc.10 → 0.3.0-rc.11
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 +62 -64
- package/dist/cloudflare/catalogSettings.generated.d.ts +7 -4
- package/dist/cloudflare/catalogSettings.generated.d.ts.map +1 -1
- package/dist/cloudflare/catalogSettings.generated.js +7 -6
- package/dist/cloudflare/index.d.ts +1 -1
- package/dist/cloudflare/index.d.ts.map +1 -1
- package/dist/cloudflare/worker.d.ts +35 -1
- package/dist/cloudflare/worker.d.ts.map +1 -1
- package/dist/cloudflare/worker.js +31 -4
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/internal/aiDefault.d.ts +4 -3
- package/dist/internal/aiDefault.d.ts.map +1 -1
- package/dist/internal/aiDefault.js +6 -5
- package/dist/internal/aiProviders.d.ts.map +1 -1
- package/dist/internal/aiProviders.js +2 -2
- package/dist/internal/capabilities.d.ts +97 -481
- package/dist/internal/capabilities.d.ts.map +1 -1
- package/dist/internal/capabilities.js +47 -548
- 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/events.d.ts +52 -1
- package/dist/internal/events.d.ts.map +1 -1
- package/dist/internal/events.js +65 -3
- package/dist/internal/oauthBuiltIns.d.ts +101 -0
- package/dist/internal/oauthBuiltIns.d.ts.map +1 -0
- package/dist/internal/oauthBuiltIns.js +122 -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 +14 -15
- package/dist/internal/oauthPresets.d.ts.map +1 -1
- package/dist/internal/oauthPresets.js +42 -853
- 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 +72 -71
- package/dist/internal/oauthSpec.d.ts.map +1 -1
- package/dist/internal/oauthSpec.js +178 -447
- package/dist/internal/protocol.d.ts +42 -13
- package/dist/internal/protocol.d.ts.map +1 -1
- package/dist/internal/protocol.js +45 -7
- package/dist/internal/providerRegistry.d.ts +1 -61
- package/dist/internal/providerRegistry.d.ts.map +1 -1
- package/dist/internal/providerRegistry.js +8 -115
- package/dist/internal/providerSpec.d.ts.map +1 -1
- package/dist/internal/providerSpec.js +14 -36
- package/dist/internal/remoteMcp.d.ts.map +1 -1
- package/dist/internal/remoteMcp.js +1 -5
- package/dist/internal/tools.d.ts +5 -4
- package/dist/internal/tools.d.ts.map +1 -1
- package/dist/internal/tools.js +4 -3
- package/dist/manifest.d.ts +34 -5
- package/dist/manifest.d.ts.map +1 -1
- package/dist/manifest.js +1 -1
- package/dist/server/attribution.d.ts +9 -0
- 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/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 +15 -6
- package/dist/server/everyApp.d.ts.map +1 -1
- package/dist/server/everyApp.js +12 -3
- package/dist/server/index.d.ts +4 -3
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/index.js +2 -2
- package/dist/server/integrationFetch.d.ts +59 -71
- package/dist/server/integrationFetch.d.ts.map +1 -1
- package/dist/server/integrationFetch.js +117 -392
- package/dist/server/tools.d.ts +7 -2
- package/dist/server/tools.d.ts.map +1 -1
- package/dist/server/tools.js +2 -1
- package/dist/server/toolsEndpoint.d.ts +3 -1
- package/dist/server/toolsEndpoint.d.ts.map +1 -1
- package/dist/server/toolsEndpoint.js +9 -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/package.json +1 -1
- package/dist/server/authorizeUrl.d.ts +0 -43
- package/dist/server/authorizeUrl.d.ts.map +0 -1
- package/dist/server/authorizeUrl.js +0 -106
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"remoteMcp.d.ts","sourceRoot":"","sources":["../../src/internal/remoteMcp.ts"],"names":[],"mappings":"AAyBA,OAAO,EAAiC,KAAK,QAAQ,EAAE,MAAM,YAAY,CAAC;AAE1E,eAAO,MAAM,qBAAqB,yDAMxB,CAAC;AACX,MAAM,MAAM,iBAAiB,GAAG,CAAC,OAAO,qBAAqB,CAAC,CAAC,MAAM,CAAC,CAAC;AAEvE;;;;;GAKG;AACH,MAAM,MAAM,aAAa,GACrB;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE;AAClB,uCAAuC;GACrC;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE;AACpC,mCAAmC;GACjC;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE;AACrE,6EAA6E;GAC3E;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GACjC;IAAE,IAAI,EAAE,OAAO,CAAA;CAAE,CAAC;AAEtB;;;;GAIG;AACH,eAAO,MAAM,wBAAwB,2CAI3B,CAAC;AACX,MAAM,MAAM,oBAAoB,GAAG,CAAC,OAAO,wBAAwB,CAAC,CAAC,MAAM,CAAC,CAAC;AAE7E,8EAA8E;AAC9E,MAAM,WAAW,qBAAqB;IACpC,IAAI,CAAC,EAAE,QAAQ,CAAC;IAChB,6EAA6E;IAC7E,OAAO,CAAC,EAAE,O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E,IAAI,EAAE,QAAQ,CAAC;IAAC,MAAM,EAAE,oBAAoB,CAAA;CAAE,CAWlD;AAED,2DAA2D;AAC3D,wBAAgB,iBAAiB,CAC/B,KAAK,EAAE,IAAI,CAAC,cAAc,EAAE,OAAO,CAAC,EACpC,YAAY,EAAE,MAAM,GACnB,OAAO,CAET;AAED;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAenE;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAClC,IAAI,EAAE,aAAa,EACnB,KAAK,EAAE,MAAM,GACZ,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAYxB;AASD,2DAA2D;AAC3D,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,aAAa,GAAG,MAAM,CAa9D"}
|
|
@@ -147,11 +147,7 @@ export function reservedUpstreamHosts() {
|
|
|
147
147
|
hosts.add(host);
|
|
148
148
|
}
|
|
149
149
|
else if (capability.mode === "oauth_client") {
|
|
150
|
-
|
|
151
|
-
if ("host" in endpoint && typeof endpoint.host === "string") {
|
|
152
|
-
hosts.add(endpoint.host);
|
|
153
|
-
}
|
|
154
|
-
}
|
|
150
|
+
hosts.add(new URL(capability.flow.tokenUrl).hostname);
|
|
155
151
|
}
|
|
156
152
|
}
|
|
157
153
|
return [...hosts].sort();
|
package/dist/internal/tools.d.ts
CHANGED
|
@@ -4,7 +4,8 @@
|
|
|
4
4
|
* gateway's service binding and never public:
|
|
5
5
|
*
|
|
6
6
|
* POST /__everyapp/tools/list x-everyapp-system JWT (purpose "tools.list")
|
|
7
|
-
* POST /__everyapp/tools/call x-everyapp-identity JWT, chan "mcp"
|
|
7
|
+
* POST /__everyapp/tools/call x-everyapp-identity JWT, chan "mcp" or
|
|
8
|
+
* "agent" + tc claim
|
|
8
9
|
*
|
|
9
10
|
* MCP itself (protocol eras, headers, envelopes) stays in the gateway; apps
|
|
10
11
|
* only ever speak this small versioned JSON shape. Both sides import the
|
|
@@ -16,7 +17,7 @@ export declare const TOOLS_LIST_PATH = "/__everyapp/tools/list";
|
|
|
16
17
|
export declare const TOOLS_CALL_PATH = "/__everyapp/tools/call";
|
|
17
18
|
export declare const TOOL_RISKS: readonly ["read", "write", "destructive"];
|
|
18
19
|
export type ToolRisk = (typeof TOOL_RISKS)[number];
|
|
19
|
-
/** Scopes the gateway mints on `chan: "mcp"`
|
|
20
|
+
/** Scopes the gateway mints on tool-call identities (`chan: "mcp"` or `"agent"`), one per risk. */
|
|
20
21
|
export declare const MCP_READ_SCOPE = "mcp:read";
|
|
21
22
|
export declare const MCP_WRITE_SCOPE = "mcp:write";
|
|
22
23
|
/** Never minted in v1: destructive tools are hidden until approvals exist. */
|
|
@@ -24,7 +25,7 @@ export declare const MCP_DESTRUCTIVE_SCOPE = "mcp:destructive";
|
|
|
24
25
|
/** Local tool names: lowercase snake_case, at most 48 characters. */
|
|
25
26
|
export declare const TOOL_NAME_PATTERN: RegExp;
|
|
26
27
|
export declare function isToolRisk(value: unknown): value is ToolRisk;
|
|
27
|
-
/** The exact scope a
|
|
28
|
+
/** The exact scope a tool-call identity must carry to call a tool. */
|
|
28
29
|
export declare function requiredScopeForRisk(risk: ToolRisk): string;
|
|
29
30
|
export interface ToolAnnotationsV1 {
|
|
30
31
|
idempotentHint?: boolean;
|
|
@@ -55,7 +56,7 @@ export interface ToolsListResponseV1 {
|
|
|
55
56
|
/** Tools the SDK left out because it can't describe them, and why. */
|
|
56
57
|
warnings?: string[];
|
|
57
58
|
}
|
|
58
|
-
/** The `tc` identity claim: binds a `chan: "mcp"`
|
|
59
|
+
/** The `tc` identity claim: binds a tool-call token (`chan: "mcp"` or `"agent"`) to one call. */
|
|
59
60
|
export interface ToolCallClaim {
|
|
60
61
|
id: string;
|
|
61
62
|
name: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../../src/internal/tools.ts"],"names":[],"mappings":"AAAA
|
|
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AM,CAAC,EAAE,WAAW,EAAE,CAAC;CACxB;AAED,MAAM,WAAW,kBAAkB;IACjC,CAAC,EAAE,CAAC,CAAC;IACL,0EAA0E;IAC1E,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,gBAAgB,CAAC;CAC1B;AAED,MAAM,WAAW,oBAAoB;IACnC,CAAC,EAAE,CAAC,CAAC;IACL,KAAK,EAAE,YAAY,CAAC;CACrB;AAED,MAAM,MAAM,mBAAmB,GAAG,kBAAkB,GAAG,oBAAoB,CAAC;AAE5E;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAEpD;AAaD;;;;GAIG;AACH,wBAAsB,WAAW,CAAC,OAAO,EAAE;IACzC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,KAAK,EAAE,SAAS,gBAAgB,EAAE,CAAC;CACpC,GAAG,OAAO,CAAC,MAAM,CAAC,CAUlB"}
|
package/dist/internal/tools.js
CHANGED
|
@@ -4,7 +4,8 @@
|
|
|
4
4
|
* gateway's service binding and never public:
|
|
5
5
|
*
|
|
6
6
|
* POST /__everyapp/tools/list x-everyapp-system JWT (purpose "tools.list")
|
|
7
|
-
* POST /__everyapp/tools/call x-everyapp-identity JWT, chan "mcp"
|
|
7
|
+
* POST /__everyapp/tools/call x-everyapp-identity JWT, chan "mcp" or
|
|
8
|
+
* "agent" + tc claim
|
|
8
9
|
*
|
|
9
10
|
* MCP itself (protocol eras, headers, envelopes) stays in the gateway; apps
|
|
10
11
|
* only ever speak this small versioned JSON shape. Both sides import the
|
|
@@ -15,7 +16,7 @@ export const TOOLS_PATH_PREFIX = "/__everyapp/tools";
|
|
|
15
16
|
export const TOOLS_LIST_PATH = `${TOOLS_PATH_PREFIX}/list`;
|
|
16
17
|
export const TOOLS_CALL_PATH = `${TOOLS_PATH_PREFIX}/call`;
|
|
17
18
|
export const TOOL_RISKS = ["read", "write", "destructive"];
|
|
18
|
-
/** Scopes the gateway mints on `chan: "mcp"`
|
|
19
|
+
/** Scopes the gateway mints on tool-call identities (`chan: "mcp"` or `"agent"`), one per risk. */
|
|
19
20
|
export const MCP_READ_SCOPE = "mcp:read";
|
|
20
21
|
export const MCP_WRITE_SCOPE = "mcp:write";
|
|
21
22
|
/** Never minted in v1: destructive tools are hidden until approvals exist. */
|
|
@@ -26,7 +27,7 @@ export function isToolRisk(value) {
|
|
|
26
27
|
return (typeof value === "string" &&
|
|
27
28
|
TOOL_RISKS.includes(value));
|
|
28
29
|
}
|
|
29
|
-
/** The exact scope a
|
|
30
|
+
/** The exact scope a tool-call identity must carry to call a tool. */
|
|
30
31
|
export function requiredScopeForRisk(risk) {
|
|
31
32
|
switch (risk) {
|
|
32
33
|
case "read":
|
package/dist/manifest.d.ts
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
* Types only, and a leaf module: `cloudflare.config.ts` imports the manifest,
|
|
13
13
|
* and the Cloudflare Vite plugin hides from the Worker every file the config
|
|
14
14
|
* imports. The rules beyond the shape (which ids exist, which names are
|
|
15
|
-
* reserved, which
|
|
15
|
+
* reserved, which scopes a provider takes) are the CLI's: `everyapp deploy`
|
|
16
16
|
* and `everyapp dev` validate the manifest and say what is wrong. The
|
|
17
17
|
* perimeter's schema (`@every-app/perimeter/manifest`) is held to this type
|
|
18
18
|
* by a test there.
|
|
@@ -104,12 +104,31 @@ export interface EveryAppResources {
|
|
|
104
104
|
readonly name: string;
|
|
105
105
|
readonly dataset?: string;
|
|
106
106
|
}[];
|
|
107
|
+
readonly artifacts?: readonly {
|
|
108
|
+
readonly name: string;
|
|
109
|
+
}[];
|
|
107
110
|
}
|
|
108
|
-
/**
|
|
109
|
-
|
|
111
|
+
/**
|
|
112
|
+
* One capability the Gateway serves the app with: an API-key provider or
|
|
113
|
+
* a service, by `access`; an OAuth provider, by the provider's own scopes.
|
|
114
|
+
*/
|
|
115
|
+
export type EveryAppCapabilityEntry = EveryAppKeyCapabilityEntry | EveryAppOAuthCapabilityEntry;
|
|
116
|
+
/** A provider whose key the Gateway holds, or a Gateway service. */
|
|
117
|
+
export interface EveryAppKeyCapabilityEntry extends EveryAppSettingNeed {
|
|
110
118
|
readonly access: "read" | "write";
|
|
111
|
-
|
|
112
|
-
|
|
119
|
+
readonly scopes?: never;
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* An OAuth provider (`google-workspace`, `github`): the provider's own
|
|
123
|
+
* scope strings the app needs, short (`gmail.modify`) or in full. A person
|
|
124
|
+
* connects in the app for exactly these; the Gateway adds the scopes that
|
|
125
|
+
* name the account, and refuses a token that carries more.
|
|
126
|
+
*/
|
|
127
|
+
export interface EveryAppOAuthCapabilityEntry extends EveryAppSettingNeed {
|
|
128
|
+
readonly scopes: readonly string[];
|
|
129
|
+
/** Why the app needs it, shown where people connect. At most 200 characters. */
|
|
130
|
+
readonly why: string;
|
|
131
|
+
readonly access?: never;
|
|
113
132
|
}
|
|
114
133
|
/**
|
|
115
134
|
* One of the app's plain settings: a value that isn't a secret and
|
|
@@ -228,6 +247,16 @@ export interface EveryAppManifest {
|
|
|
228
247
|
readonly by: "gateway" | "app";
|
|
229
248
|
readonly why: string;
|
|
230
249
|
};
|
|
250
|
+
/**
|
|
251
|
+
* The Gateway events the app receives at `everyApp(handler, { events: {
|
|
252
|
+
* on } })`: types or patterns from `member.*` (but `member.password_reset`),
|
|
253
|
+
* `group.*`, `app.*`, `mcp_app.*`, `connection.*` and `tool.*`, for the
|
|
254
|
+
* app's own organization. Anything else is refused at deploy.
|
|
255
|
+
*/
|
|
256
|
+
readonly events?: {
|
|
257
|
+
readonly subscribe: readonly string[];
|
|
258
|
+
readonly why: string;
|
|
259
|
+
};
|
|
231
260
|
}
|
|
232
261
|
/**
|
|
233
262
|
* Type `everyapp.config.ts` without widening it: the literal binding names
|
package/dist/manifest.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"manifest.d.ts","sourceRoot":"","sources":["../src/manifest.ts"],"names":[],"m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C;QACtC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;KACtB,CAAC;CACH;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,KAAK,CAAC,CAAC,SAAS,gBAAgB,EAC7D,QAAQ,EAAE,CAAC,GACV,CAAC,CAEH"}
|
package/dist/manifest.js
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
* Types only, and a leaf module: `cloudflare.config.ts` imports the manifest,
|
|
13
13
|
* and the Cloudflare Vite plugin hides from the Worker every file the config
|
|
14
14
|
* imports. The rules beyond the shape (which ids exist, which names are
|
|
15
|
-
* reserved, which
|
|
15
|
+
* reserved, which scopes a provider takes) are the CLI's: `everyapp deploy`
|
|
16
16
|
* and `everyapp dev` validate the manifest and say what is wrong. The
|
|
17
17
|
* perimeter's schema (`@every-app/perimeter/manifest`) is held to this type
|
|
18
18
|
* by a test there.
|
|
@@ -12,10 +12,19 @@
|
|
|
12
12
|
* checks is active and has a live member. An organization's own app may
|
|
13
13
|
* leave it out (the gateway knows its organization) and may only name
|
|
14
14
|
* its own.
|
|
15
|
+
* - `{ background: true, organizationId, userId }`: a call to an OAuth
|
|
16
|
+
* provider's API (`integrationFetch`) on the connection member `userId`
|
|
17
|
+
* made in this app, at any time, even while serving another person's
|
|
18
|
+
* request: the call carries that member (`x-everyapp-user`) and never
|
|
19
|
+
* the identity of the person being served. Only an organization's own
|
|
20
|
+
* app may name a member, and only one who may still open the app. No
|
|
21
|
+
* identity for the member reaches the app. Other gateway calls ignore
|
|
22
|
+
* `userId`.
|
|
15
23
|
*/
|
|
16
24
|
export type GatewayCallFor = Request | {
|
|
17
25
|
background: true;
|
|
18
26
|
organizationId?: string;
|
|
27
|
+
userId?: string;
|
|
19
28
|
};
|
|
20
29
|
/**
|
|
21
30
|
* A gateway call that doesn't say whom it is for where it must: from a
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"attribution.d.ts","sourceRoot":"","sources":["../../src/server/attribution.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"attribution.d.ts","sourceRoot":"","sources":["../../src/server/attribution.ts"],"names":[],"mappings":"AAQA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,MAAM,cAAc,GACtB,OAAO,GACP;IAAE,UAAU,EAAE,IAAI,CAAC;IAAC,cAAc,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAEnE;;;GAGG;AACH,qBAAa,gBAAiB,SAAQ,KAAK;IACzC,QAAQ,CAAC,IAAI,0BAA0B;gBAC3B,OAAO,EAAE,MAAM;CAI5B;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,CAC5B,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,cAAc,GAAG,SAAS,EAClC,IAAI,EAAE,MAAM,GACX,cAAc,GAAG,SAAS,CAI5B;AAmCD;;;GAGG;AACH,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,OAAO,EAChB,MAAM,EAAE,cAAc,GAAG,SAAS,GACjC,IAAI,CAYN;AASD,0EAA0E;AAC1E,wBAAgB,SAAS,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,OAAO,CAO1D"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IDENTITY_HEADER, ORG_HEADER, SHARED_ENV } from "../internal/index.js";
|
|
1
|
+
import { IDENTITY_HEADER, ORG_HEADER, SHARED_ENV, USER_HEADER, } from "../internal/index.js";
|
|
2
2
|
import { attributionFromContext } from "./context.js";
|
|
3
3
|
/**
|
|
4
4
|
* A gateway call that doesn't say whom it is for where it must: from a
|
|
@@ -28,6 +28,9 @@ function checkAttribution(env, target, what) {
|
|
|
28
28
|
if (target === null || typeof target !== "object" || !target.background) {
|
|
29
29
|
throw new AttributionError(`${what}: \`for\` is the inbound Request or { background: true, organizationId }.`);
|
|
30
30
|
}
|
|
31
|
+
if (target.userId !== undefined && !nonEmpty(target.userId)) {
|
|
32
|
+
throw new AttributionError(`${what}: { background: true, userId } needs a non-empty user id.`);
|
|
33
|
+
}
|
|
31
34
|
if (target.organizationId !== undefined &&
|
|
32
35
|
!nonEmpty(target.organizationId)) {
|
|
33
36
|
throw new AttributionError(`${what}: { background: true, organizationId } needs a non-empty organization id.`);
|
|
@@ -46,6 +49,7 @@ function checkAttribution(env, target, what) {
|
|
|
46
49
|
export function applyAttribution(headers, target) {
|
|
47
50
|
headers.delete(IDENTITY_HEADER);
|
|
48
51
|
headers.delete(ORG_HEADER);
|
|
52
|
+
headers.delete(USER_HEADER);
|
|
49
53
|
if (target === undefined)
|
|
50
54
|
return;
|
|
51
55
|
if (isRequest(target)) {
|
|
@@ -56,6 +60,8 @@ export function applyAttribution(headers, target) {
|
|
|
56
60
|
}
|
|
57
61
|
if (target.organizationId)
|
|
58
62
|
headers.set(ORG_HEADER, target.organizationId);
|
|
63
|
+
if (target.userId)
|
|
64
|
+
headers.set(USER_HEADER, target.userId.trim());
|
|
59
65
|
}
|
|
60
66
|
function isSharedWorker(env) {
|
|
61
67
|
const value = env[SHARED_ENV];
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import type { ConnectionAccount } from "../internal/index.js";
|
|
2
1
|
export interface ConnectUrlOptions {
|
|
3
|
-
/** The Worker env: `GATEWAY_URL
|
|
2
|
+
/** The Worker env: `GATEWAY_URL` and the app's id, which every deployed Worker and `everyapp dev` set. */
|
|
4
3
|
env: object;
|
|
5
4
|
/** The OAuth provider's id (`google-workspace`, `github`). */
|
|
6
5
|
provider: string;
|
|
@@ -9,13 +8,9 @@ export interface ConnectUrlOptions {
|
|
|
9
8
|
* a path on the Gateway. Absent: Settings → Connected accounts.
|
|
10
9
|
*/
|
|
11
10
|
returnTo?: string;
|
|
12
|
-
/** Whose connection to make: the person's (default) or the organization's (owner or admin). */
|
|
13
|
-
account?: ConnectionAccount;
|
|
14
|
-
/** Scope sets to ask for; absent: the union every active app that lists the provider declares. */
|
|
15
|
-
sets?: readonly string[];
|
|
16
11
|
}
|
|
17
|
-
/** The path of the connect page for `provider` on the Gateway. */
|
|
12
|
+
/** The path of the connect page for `provider` on the Gateway, without the app. */
|
|
18
13
|
export declare function connectPath(provider: string): string;
|
|
19
|
-
/** The absolute URL that
|
|
20
|
-
export declare function connectUrl({ env, provider, returnTo,
|
|
14
|
+
/** The absolute URL that connects the person to `provider` in this app. */
|
|
15
|
+
export declare function connectUrl({ env, provider, returnTo, }: ConnectUrlOptions): string;
|
|
21
16
|
//# sourceMappingURL=connectUrl.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connectUrl.d.ts","sourceRoot":"","sources":["../../src/server/connectUrl.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"connectUrl.d.ts","sourceRoot":"","sources":["../../src/server/connectUrl.ts"],"names":[],"mappings":"AAaA,MAAM,WAAW,iBAAiB;IAChC,0GAA0G;IAC1G,GAAG,EAAE,MAAM,CAAC;IACZ,8DAA8D;IAC9D,QAAQ,EAAE,MAAM,CAAC;IACjB;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,mFAAmF;AACnF,wBAAgB,WAAW,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAEpD;AAED,2EAA2E;AAC3E,wBAAgB,UAAU,CAAC,EACzB,GAAG,EACH,QAAQ,EACR,QAAQ,GACT,EAAE,iBAAiB,GAAG,MAAM,CAwB5B"}
|
|
@@ -1,19 +1,21 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Where an app sends a person to connect an OAuth provider the Gateway
|
|
3
|
-
* runs the flow for (docs/design/2026-
|
|
4
|
-
* `<gateway>/connect/<id>?return=<back here
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* the
|
|
8
|
-
*
|
|
3
|
+
* runs the flow for (docs/design/2026-11-oauth-simplify.md):
|
|
4
|
+
* `<gateway>/connect/<id>?app=<this app>&return=<back here>`. A
|
|
5
|
+
* connection belongs to one person and one app: the Gateway checks the
|
|
6
|
+
* session and that the person may open the app, asks the provider for
|
|
7
|
+
* exactly the scopes the app's `everyapp.config.ts` lists (plus the ones
|
|
8
|
+
* that name the account), finishes on its own callback and sends the
|
|
9
|
+
* browser back to `returnTo`, which must be a path on the Gateway or an
|
|
10
|
+
* https URL on one of its app hosts (in local dev also localhost).
|
|
9
11
|
*/
|
|
10
|
-
import { ConfigurationError } from "../internal/index.js";
|
|
11
|
-
/** The path of the connect page for `provider` on the Gateway. */
|
|
12
|
+
import { APP_ID_ENV, ConfigurationError } from "../internal/index.js";
|
|
13
|
+
/** The path of the connect page for `provider` on the Gateway, without the app. */
|
|
12
14
|
export function connectPath(provider) {
|
|
13
15
|
return `/connect/${encodeURIComponent(provider)}`;
|
|
14
16
|
}
|
|
15
|
-
/** The absolute URL that
|
|
16
|
-
export function connectUrl({ env, provider, returnTo,
|
|
17
|
+
/** The absolute URL that connects the person to `provider` in this app. */
|
|
18
|
+
export function connectUrl({ env, provider, returnTo, }) {
|
|
17
19
|
const values = env;
|
|
18
20
|
const gateway = values["GATEWAY_URL"];
|
|
19
21
|
if (typeof gateway !== "string" || !gateway.trim()) {
|
|
@@ -26,12 +28,13 @@ export function connectUrl({ env, provider, returnTo, account, sets, }) {
|
|
|
26
28
|
catch {
|
|
27
29
|
throw new ConfigurationError(`GATEWAY_URL isn't a URL: ${gateway}`);
|
|
28
30
|
}
|
|
31
|
+
const app = values[APP_ID_ENV];
|
|
32
|
+
if (typeof app !== "string" || !app.trim()) {
|
|
33
|
+
throw new ConfigurationError(`connectUrl() needs ${APP_ID_ENV} in the Worker env: a connection belongs to one app, and the deploy and everyapp dev set it.`);
|
|
34
|
+
}
|
|
29
35
|
const url = new URL(connectPath(provider), base.origin);
|
|
36
|
+
url.searchParams.set("app", app.trim());
|
|
30
37
|
if (returnTo)
|
|
31
38
|
url.searchParams.set("return", returnTo);
|
|
32
|
-
if (account)
|
|
33
|
-
url.searchParams.set("account", account);
|
|
34
|
-
if (sets && sets.length > 0)
|
|
35
|
-
url.searchParams.set("sets", sets.join(","));
|
|
36
39
|
return url.toString();
|
|
37
40
|
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The app side of the `app` event sink (docs/design/2026-11-birds-decisions/app-event-sink.md).
|
|
3
|
+
*
|
|
4
|
+
* `everyApp()` answers the reserved `POST /__everyapp/events` here, before
|
|
5
|
+
* any app code runs and whether or not the app passed `events`:
|
|
6
|
+
*
|
|
7
|
+
* - the request needs the Gateway's system token for this app (purpose
|
|
8
|
+
* `events.deliver`), whose `bh` claim is the SHA-256 of this exact body,
|
|
9
|
+
* so a token opens one delivery and nothing else;
|
|
10
|
+
* - the envelope must name the organization this Worker serves
|
|
11
|
+
* (`EVERY_APP_ORG_ID`), when it is pinned;
|
|
12
|
+
* - only then is `events.on` called, under `withOrganization()`, so every
|
|
13
|
+
* Gateway call it makes is that organization's background work.
|
|
14
|
+
*
|
|
15
|
+
* The perimeter refuses the path from outside and strips inbound
|
|
16
|
+
* `x-everyapp-*` headers, so only the Gateway's event bus reaches it, over
|
|
17
|
+
* the service binding.
|
|
18
|
+
*/
|
|
19
|
+
import { type AppEventEnvelope, type RequestIdentityOptions } from "../internal/index.js";
|
|
20
|
+
import type { ExecutionContextLike } from "./everyApp.js";
|
|
21
|
+
/** One event the Gateway delivered: the webhook envelope, plus the delivery's id and attempt. */
|
|
22
|
+
export interface AppEvent extends AppEventEnvelope {
|
|
23
|
+
delivery: {
|
|
24
|
+
id: string;
|
|
25
|
+
attempt: number;
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
export type AppEventHandler<TEnv = unknown> = (event: AppEvent, env: TEnv, ctx: ExecutionContextLike) => unknown | Promise<unknown>;
|
|
29
|
+
/**
|
|
30
|
+
* `everyApp(handler, { events: { on } })`. `on` is one function for every
|
|
31
|
+
* event, or one per exact type (`"member.removed"`). An event with no
|
|
32
|
+
* handler is acknowledged and dropped. A handler that throws answers 500,
|
|
33
|
+
* and the Gateway retries the delivery with its usual backoff.
|
|
34
|
+
*/
|
|
35
|
+
export interface AppEventsOptions<TEnv = unknown> {
|
|
36
|
+
on: AppEventHandler<TEnv> | Partial<Record<string, AppEventHandler<TEnv>>>;
|
|
37
|
+
}
|
|
38
|
+
export interface EventsEndpointOptions {
|
|
39
|
+
events?: AppEventsOptions<never>;
|
|
40
|
+
/** How to verify the Gateway's token (keys, issuer, audience, dev opt-in). */
|
|
41
|
+
identity: RequestIdentityOptions;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Answer a request to the reserved events path, or return null for any
|
|
45
|
+
* other path so the app's own handler runs.
|
|
46
|
+
*/
|
|
47
|
+
export declare function handleEventsRequest(request: Request, env: unknown, ctx: ExecutionContextLike, options: EventsEndpointOptions): Promise<Response | null>;
|
|
48
|
+
//# sourceMappingURL=eventsEndpoint.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"eventsEndpoint.d.ts","sourceRoot":"","sources":["../../src/server/eventsEndpoint.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,OAAO,EASL,KAAK,gBAAgB,EACrB,KAAK,sBAAsB,EAC5B,MAAM,sBAAsB,CAAC;AAE9B,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AAE1D,iGAAiG;AACjG,MAAM,WAAW,QAAS,SAAQ,gBAAgB;IAChD,QAAQ,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;CAC3C;AAED,MAAM,MAAM,eAAe,CAAC,IAAI,GAAG,OAAO,IAAI,CAC5C,KAAK,EAAE,QAAQ,EACf,GAAG,EAAE,IAAI,EACT,GAAG,EAAE,oBAAoB,KACtB,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;AAEhC;;;;;GAKG;AACH,MAAM,WAAW,gBAAgB,CAAC,IAAI,GAAG,OAAO;IAC9C,EAAE,EAAE,eAAe,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;CAC5E;AAED,MAAM,WAAW,qBAAqB;IACpC,MAAM,CAAC,EAAE,gBAAgB,CAAC,KAAK,CAAC,CAAC;IACjC,8EAA8E;IAC9E,QAAQ,EAAE,sBAAsB,CAAC;CAClC;AAwCD;;;GAGG;AACH,wBAAsB,mBAAmB,CACvC,OAAO,EAAE,OAAO,EAChB,GAAG,EAAE,OAAO,EACZ,GAAG,EAAE,oBAAoB,EACzB,OAAO,EAAE,qBAAqB,GAC7B,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC,CA4F1B"}
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The app side of the `app` event sink (docs/design/2026-11-birds-decisions/app-event-sink.md).
|
|
3
|
+
*
|
|
4
|
+
* `everyApp()` answers the reserved `POST /__everyapp/events` here, before
|
|
5
|
+
* any app code runs and whether or not the app passed `events`:
|
|
6
|
+
*
|
|
7
|
+
* - the request needs the Gateway's system token for this app (purpose
|
|
8
|
+
* `events.deliver`), whose `bh` claim is the SHA-256 of this exact body,
|
|
9
|
+
* so a token opens one delivery and nothing else;
|
|
10
|
+
* - the envelope must name the organization this Worker serves
|
|
11
|
+
* (`EVERY_APP_ORG_ID`), when it is pinned;
|
|
12
|
+
* - only then is `events.on` called, under `withOrganization()`, so every
|
|
13
|
+
* Gateway call it makes is that organization's background work.
|
|
14
|
+
*
|
|
15
|
+
* The perimeter refuses the path from outside and strips inbound
|
|
16
|
+
* `x-everyapp-*` headers, so only the Gateway's event bus reaches it, over
|
|
17
|
+
* the service binding.
|
|
18
|
+
*/
|
|
19
|
+
import { APP_EVENTS_PATH, ConfigurationError, EVENT_HEADERS, IdentityError, SYSTEM_HEADER, bodyHash, resolveVerifyOptions, verifySystemJwt, } from "../internal/index.js";
|
|
20
|
+
import { withOrganization } from "./context.js";
|
|
21
|
+
/** The most body the endpoint reads: an envelope's data is at most 16 KiB. */
|
|
22
|
+
const MAX_BODY_BYTES = 64 * 1024;
|
|
23
|
+
function answer(status, body) {
|
|
24
|
+
return Response.json(body, {
|
|
25
|
+
status,
|
|
26
|
+
headers: { "cache-control": "no-store" },
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
function isEnvelope(value) {
|
|
30
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
31
|
+
return false;
|
|
32
|
+
}
|
|
33
|
+
const v = value;
|
|
34
|
+
const org = v.organization;
|
|
35
|
+
return (typeof v.id === "string" &&
|
|
36
|
+
typeof v.type === "string" &&
|
|
37
|
+
typeof v.version === "number" &&
|
|
38
|
+
typeof v.time === "string" &&
|
|
39
|
+
!!org &&
|
|
40
|
+
typeof org === "object" &&
|
|
41
|
+
typeof org.id === "string" &&
|
|
42
|
+
!!v.data &&
|
|
43
|
+
typeof v.data === "object" &&
|
|
44
|
+
!Array.isArray(v.data));
|
|
45
|
+
}
|
|
46
|
+
function handlerFor(on, type) {
|
|
47
|
+
if (typeof on === "function")
|
|
48
|
+
return on;
|
|
49
|
+
return Object.prototype.hasOwnProperty.call(on, type) ? on[type] : undefined;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Answer a request to the reserved events path, or return null for any
|
|
53
|
+
* other path so the app's own handler runs.
|
|
54
|
+
*/
|
|
55
|
+
export async function handleEventsRequest(request, env, ctx, options) {
|
|
56
|
+
const { pathname } = new URL(request.url);
|
|
57
|
+
if (pathname !== APP_EVENTS_PATH)
|
|
58
|
+
return null;
|
|
59
|
+
if (request.method !== "POST") {
|
|
60
|
+
return answer(405, { error: "method_not_allowed" });
|
|
61
|
+
}
|
|
62
|
+
let verify;
|
|
63
|
+
try {
|
|
64
|
+
verify = resolveVerifyOptions(options.identity);
|
|
65
|
+
}
|
|
66
|
+
catch (error) {
|
|
67
|
+
if (error instanceof ConfigurationError) {
|
|
68
|
+
console.error(error);
|
|
69
|
+
return answer(500, { error: "misconfigured", message: error.message });
|
|
70
|
+
}
|
|
71
|
+
throw error;
|
|
72
|
+
}
|
|
73
|
+
let claims;
|
|
74
|
+
try {
|
|
75
|
+
claims = await verifySystemJwt(request.headers.get(SYSTEM_HEADER) ?? "", {
|
|
76
|
+
...verify,
|
|
77
|
+
purpose: "events.deliver",
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
catch (error) {
|
|
81
|
+
if (error instanceof IdentityError) {
|
|
82
|
+
return answer(401, { error: "unauthenticated", message: error.message });
|
|
83
|
+
}
|
|
84
|
+
throw error;
|
|
85
|
+
}
|
|
86
|
+
const declared = Number(request.headers.get("content-length") ?? "0");
|
|
87
|
+
if (declared > MAX_BODY_BYTES) {
|
|
88
|
+
return answer(413, { error: "too_large" });
|
|
89
|
+
}
|
|
90
|
+
const body = await request.text();
|
|
91
|
+
if (body.length > MAX_BODY_BYTES) {
|
|
92
|
+
return answer(413, { error: "too_large" });
|
|
93
|
+
}
|
|
94
|
+
// The token was minted for this exact body: another body, even one the
|
|
95
|
+
// Gateway sent, is refused.
|
|
96
|
+
if (claims.bh !== (await bodyHash(body))) {
|
|
97
|
+
return answer(401, {
|
|
98
|
+
error: "unauthenticated",
|
|
99
|
+
message: "the token was minted for another delivery",
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
let parsed;
|
|
103
|
+
try {
|
|
104
|
+
parsed = JSON.parse(body);
|
|
105
|
+
}
|
|
106
|
+
catch {
|
|
107
|
+
parsed = undefined;
|
|
108
|
+
}
|
|
109
|
+
if (!isEnvelope(parsed)) {
|
|
110
|
+
return answer(400, { error: "invalid_request" });
|
|
111
|
+
}
|
|
112
|
+
const pinned = options.identity.organizationId;
|
|
113
|
+
if (pinned && parsed.organization.id !== pinned) {
|
|
114
|
+
return answer(403, {
|
|
115
|
+
error: "forbidden",
|
|
116
|
+
message: `the event is for organization "${parsed.organization.id}", and this Worker serves "${pinned}"`,
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
if (!options.events) {
|
|
120
|
+
// The manifest subscribes, but the Worker passes no `events` to
|
|
121
|
+
// everyApp(): say so, and let the Gateway retry once it does.
|
|
122
|
+
return answer(404, {
|
|
123
|
+
error: "no_handler",
|
|
124
|
+
message: "everyApp() was given no events: { on }",
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
const handler = handlerFor(options.events.on, parsed.type);
|
|
128
|
+
if (!handler)
|
|
129
|
+
return answer(200, { ok: true, handled: false });
|
|
130
|
+
const event = {
|
|
131
|
+
...parsed,
|
|
132
|
+
delivery: {
|
|
133
|
+
id: request.headers.get(EVENT_HEADERS.delivery) ?? "",
|
|
134
|
+
attempt: Number(request.headers.get(EVENT_HEADERS.attempt) ?? "0") || 0,
|
|
135
|
+
},
|
|
136
|
+
};
|
|
137
|
+
try {
|
|
138
|
+
await withOrganization(parsed.organization.id, () => handler(event, env, ctx));
|
|
139
|
+
}
|
|
140
|
+
catch (error) {
|
|
141
|
+
console.error(error);
|
|
142
|
+
return answer(500, { error: "handler_failed" });
|
|
143
|
+
}
|
|
144
|
+
return answer(200, { ok: true, handled: true });
|
|
145
|
+
}
|
|
@@ -13,7 +13,8 @@
|
|
|
13
13
|
* `everyapp.config.ts` (the Cloudflare Vite plugin hides every file
|
|
14
14
|
* `cloudflare.config.ts` imports from the Worker in dev).
|
|
15
15
|
* It also answers the gateway's internal tools contract
|
|
16
|
-
* (`/__everyapp/tools/*`) for the app's `defineTools()` catalog
|
|
16
|
+
* (`/__everyapp/tools/*`) for the app's `defineTools()` catalog, and the
|
|
17
|
+
* event sink's deliveries (`/__everyapp/events`) for `events: { on }`.
|
|
17
18
|
*
|
|
18
19
|
* Around the handler and around each tool call it opens the request
|
|
19
20
|
* context (context.ts): `currentUser()` reads the user anywhere below, and
|
|
@@ -25,9 +26,10 @@
|
|
|
25
26
|
* framework sets could never come back, and one named like the Gateway's
|
|
26
27
|
* session cookie would lock the person out of the app host.
|
|
27
28
|
*/
|
|
28
|
-
import { ConfigurationError, IdentityError, isAdmin, type EveryAppUser, type IdentityResult, type OrgRole } from "../internal/index.js";
|
|
29
|
+
import { ConfigurationError, IdentityError, isAdmin, isAgentCall, type EveryAppUser, type IdentityResult, type OrgRole } from "../internal/index.js";
|
|
29
30
|
import type { ToolSet } from "./tools.js";
|
|
30
|
-
|
|
31
|
+
import { type AppEventsOptions } from "./eventsEndpoint.js";
|
|
32
|
+
export { ConfigurationError, IdentityError, isAdmin, isAgentCall };
|
|
31
33
|
export type { EveryAppUser, IdentityResult, OrgRole };
|
|
32
34
|
/**
|
|
33
35
|
* The runtime's `ExecutionContext`, which `everyApp()` passes to the handler
|
|
@@ -40,7 +42,7 @@ export interface EveryAppManifestLike {
|
|
|
40
42
|
id: string;
|
|
41
43
|
[key: string]: unknown;
|
|
42
44
|
}
|
|
43
|
-
export interface EveryAppOptions {
|
|
45
|
+
export interface EveryAppOptions<TEnv = Record<string, unknown>> {
|
|
44
46
|
/** Optional expected issuer (gateway URL). Defaults to env.EVERYAPP_IDENTITY_ISSUER when set. */
|
|
45
47
|
issuer?: string;
|
|
46
48
|
/** Env var holding the public key set. Defaults to EVERYAPP_IDENTITY_PUBLIC_KEYS. */
|
|
@@ -57,6 +59,13 @@ export interface EveryAppOptions {
|
|
|
57
59
|
* and serves them to MCP clients; see `defineTools`.
|
|
58
60
|
*/
|
|
59
61
|
tools?: ToolSet;
|
|
62
|
+
/**
|
|
63
|
+
* The Gateway's events this app subscribes to (`events.subscribe` in its
|
|
64
|
+
* manifest), delivered to `on` over the service binding: one function, or
|
|
65
|
+
* one per type. The SDK verifies the Gateway's `events.deliver` token
|
|
66
|
+
* before `on` runs.
|
|
67
|
+
*/
|
|
68
|
+
events?: AppEventsOptions<TEnv>;
|
|
60
69
|
/** Override for tests. */
|
|
61
70
|
now?: number;
|
|
62
71
|
}
|
|
@@ -91,11 +100,11 @@ export declare function requireEveryAppUser(request: Request | Headers, env: obj
|
|
|
91
100
|
export declare function requireCurrentUser(): EveryAppUser;
|
|
92
101
|
export declare function hasScope(user: EveryAppUser, scope: string): boolean;
|
|
93
102
|
/** Wrap a Worker fetch handler with Every App identity verification. */
|
|
94
|
-
export declare function everyApp<TEnv = Record<string, unknown>, TCtx extends ExecutionContextLike = ExecutionContext>(handler: EveryAppHandler<TEnv, TCtx>, options?: EveryAppOptions): EveryAppExport<TEnv, TCtx>;
|
|
103
|
+
export declare function everyApp<TEnv = Record<string, unknown>, TCtx extends ExecutionContextLike = ExecutionContext>(handler: EveryAppHandler<TEnv, TCtx>, options?: EveryAppOptions<TEnv>): EveryAppExport<TEnv, TCtx>;
|
|
95
104
|
/**
|
|
96
105
|
* @deprecated Drop the manifest: the app id now comes from
|
|
97
106
|
* `env.EVERYAPP_APP_ID` and the audience from `env.EVERYAPP_AUDIENCE`.
|
|
98
107
|
* When passed, it must match the app id.
|
|
99
108
|
*/
|
|
100
|
-
export declare function everyApp<TEnv = Record<string, unknown>, TCtx extends ExecutionContextLike = ExecutionContext>(handler: EveryAppHandler<TEnv, TCtx>, manifest: EveryAppManifestLike | undefined, options?: EveryAppOptions): EveryAppExport<TEnv, TCtx>;
|
|
109
|
+
export declare function everyApp<TEnv = Record<string, unknown>, TCtx extends ExecutionContextLike = ExecutionContext>(handler: EveryAppHandler<TEnv, TCtx>, manifest: EveryAppManifestLike | undefined, options?: EveryAppOptions<TEnv>): EveryAppExport<TEnv, TCtx>;
|
|
101
110
|
//# sourceMappingURL=everyApp.d.ts.map
|