@agent-native/core 0.18.1 → 0.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -11
- package/dist/a2a/client.d.ts +7 -0
- package/dist/a2a/client.d.ts.map +1 -1
- package/dist/a2a/client.js +3 -0
- package/dist/a2a/client.js.map +1 -1
- package/dist/cli/connect.d.ts +94 -0
- package/dist/cli/connect.d.ts.map +1 -0
- package/dist/cli/connect.js +443 -0
- package/dist/cli/connect.js.map +1 -0
- package/dist/cli/index.js +16 -0
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/mcp-config-writers.d.ts +71 -0
- package/dist/cli/mcp-config-writers.d.ts.map +1 -0
- package/dist/cli/mcp-config-writers.js +210 -0
- package/dist/cli/mcp-config-writers.js.map +1 -0
- package/dist/client/AssistantChat.d.ts.map +1 -1
- package/dist/client/AssistantChat.js +11 -63
- package/dist/client/AssistantChat.js.map +1 -1
- package/dist/client/composer/PromptComposer.d.ts +6 -1
- package/dist/client/composer/PromptComposer.d.ts.map +1 -1
- package/dist/client/composer/PromptComposer.js +5 -4
- package/dist/client/composer/PromptComposer.js.map +1 -1
- package/dist/client/composer/TiptapComposer.d.ts +6 -1
- package/dist/client/composer/TiptapComposer.d.ts.map +1 -1
- package/dist/client/composer/TiptapComposer.js +20 -10
- package/dist/client/composer/TiptapComposer.js.map +1 -1
- package/dist/client/conversation/AgentConversation.d.ts +18 -0
- package/dist/client/conversation/AgentConversation.d.ts.map +1 -0
- package/dist/client/conversation/AgentConversation.js +94 -0
- package/dist/client/conversation/AgentConversation.js.map +1 -0
- package/dist/client/conversation/AgentConversation.spec.d.ts +2 -0
- package/dist/client/conversation/AgentConversation.spec.d.ts.map +1 -0
- package/dist/client/conversation/AgentConversation.spec.js +69 -0
- package/dist/client/conversation/AgentConversation.spec.js.map +1 -0
- package/dist/client/conversation/index.d.ts +4 -0
- package/dist/client/conversation/index.d.ts.map +1 -0
- package/dist/client/conversation/index.js +3 -0
- package/dist/client/conversation/index.js.map +1 -0
- package/dist/client/conversation/types.d.ts +54 -0
- package/dist/client/conversation/types.d.ts.map +1 -0
- package/dist/client/conversation/types.js +2 -0
- package/dist/client/conversation/types.js.map +1 -0
- package/dist/client/conversation/use-near-bottom-autoscroll.d.ts +15 -0
- package/dist/client/conversation/use-near-bottom-autoscroll.d.ts.map +1 -0
- package/dist/client/conversation/use-near-bottom-autoscroll.js +66 -0
- package/dist/client/conversation/use-near-bottom-autoscroll.js.map +1 -0
- package/dist/client/index.d.ts +1 -0
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js +1 -0
- package/dist/client/index.js.map +1 -1
- package/dist/client/resources/ResourceTree.d.ts.map +1 -1
- package/dist/client/resources/ResourceTree.js +2 -2
- package/dist/client/resources/ResourceTree.js.map +1 -1
- package/dist/client/resources/ResourcesPanel.d.ts.map +1 -1
- package/dist/client/resources/ResourcesPanel.js +4 -28
- package/dist/client/resources/ResourcesPanel.js.map +1 -1
- package/dist/code-agents/index.d.ts +1 -0
- package/dist/code-agents/index.d.ts.map +1 -1
- package/dist/code-agents/index.js +1 -0
- package/dist/code-agents/index.js.map +1 -1
- package/dist/code-agents/transcript-normalizer.d.ts +50 -0
- package/dist/code-agents/transcript-normalizer.d.ts.map +1 -0
- package/dist/code-agents/transcript-normalizer.js +356 -0
- package/dist/code-agents/transcript-normalizer.js.map +1 -0
- package/dist/extensions/schema.d.ts +1 -1
- package/dist/mcp/build-server.d.ts.map +1 -1
- package/dist/mcp/build-server.js +30 -0
- package/dist/mcp/build-server.js.map +1 -1
- package/dist/mcp/connect-route.d.ts +43 -0
- package/dist/mcp/connect-route.d.ts.map +1 -0
- package/dist/mcp/connect-route.js +638 -0
- package/dist/mcp/connect-route.js.map +1 -0
- package/dist/mcp/connect-store.d.ts +132 -0
- package/dist/mcp/connect-store.d.ts.map +1 -0
- package/dist/mcp/connect-store.js +434 -0
- package/dist/mcp/connect-store.js.map +1 -0
- package/dist/server/auth.d.ts +17 -0
- package/dist/server/auth.d.ts.map +1 -1
- package/dist/server/auth.js +149 -33
- package/dist/server/auth.js.map +1 -1
- package/dist/server/better-auth-instance.d.ts +43 -0
- package/dist/server/better-auth-instance.d.ts.map +1 -1
- package/dist/server/better-auth-instance.js +25 -0
- package/dist/server/better-auth-instance.js.map +1 -1
- package/dist/server/core-routes-plugin.d.ts +12 -0
- package/dist/server/core-routes-plugin.d.ts.map +1 -1
- package/dist/server/core-routes-plugin.js +42 -0
- package/dist/server/core-routes-plugin.js.map +1 -1
- package/dist/server/identity-sso-store.d.ts +86 -0
- package/dist/server/identity-sso-store.d.ts.map +1 -0
- package/dist/server/identity-sso-store.js +243 -0
- package/dist/server/identity-sso-store.js.map +1 -0
- package/dist/server/identity-sso.d.ts +78 -0
- package/dist/server/identity-sso.d.ts.map +1 -0
- package/dist/server/identity-sso.js +425 -0
- package/dist/server/identity-sso.js.map +1 -0
- package/dist/server/index.d.ts +1 -0
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/index.js +1 -0
- package/dist/server/index.js.map +1 -1
- package/dist/server/onboarding-html.d.ts.map +1 -1
- package/dist/server/onboarding-html.js +2 -1
- package/dist/server/onboarding-html.js.map +1 -1
- package/dist/sharing/schema.d.ts +1 -1
- package/docs/content/code-agents-ui.md +14 -3
- package/docs/content/cross-app-sso.md +118 -0
- package/docs/content/external-agents.md +130 -51
- package/docs/content/migration-workbench.md +1 -1
- package/package.json +2 -1
|
@@ -0,0 +1,425 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cross-app SSO ("Sign in with Agent-Native") — the CLIENT side.
|
|
3
|
+
*
|
|
4
|
+
* Each hosted `*.agent-native.com` app has its OWN Better Auth user store
|
|
5
|
+
* (a separate database per app). This module lets an app federate sign-in to
|
|
6
|
+
* an identity authority (Dispatch) so a user logged in there can land in this
|
|
7
|
+
* app without re-entering credentials.
|
|
8
|
+
*
|
|
9
|
+
* Opt-in, OFF by default, fully reversible. Everything here is gated on the
|
|
10
|
+
* single env var `AGENT_NATIVE_IDENTITY_HUB_URL`:
|
|
11
|
+
*
|
|
12
|
+
* - UNSET → `isIdentitySsoEnabled()` is false. The route handler 404s, the
|
|
13
|
+
* auth-guard bypass does not apply, and the login page renders no SSO
|
|
14
|
+
* button. Existing auth is byte-for-byte unchanged.
|
|
15
|
+
* - SET (e.g. `https://dispatch.agent-native.com`) → two routes mount:
|
|
16
|
+
* GET /_agent-native/identity/login
|
|
17
|
+
* 302 → `<HUB>/_agent-native/identity/authorize?app=<id>
|
|
18
|
+
* &redirect_uri=<thisOrigin>/_agent-native/identity/callback
|
|
19
|
+
* &state=<single-use CSRF state>`
|
|
20
|
+
* GET /_agent-native/identity/callback?token=<jwt>&state=<state>
|
|
21
|
+
* Verifies the hub-issued identity JWT (HS256 over the SHARED A2A
|
|
22
|
+
* secret — the exact verify path A2A / MCP `verifyAuth` use), checks
|
|
23
|
+
* `scope:"identity"`, `exp`, single-use CSRF `state`, and (best
|
|
24
|
+
* effort) `jti` replay, then JIT-links the verified email into this
|
|
25
|
+
* app's local Better Auth store and mints a normal framework session
|
|
26
|
+
* the SAME way the Google OAuth callback does.
|
|
27
|
+
*
|
|
28
|
+
* Crypto reuse: the hub signs with `jose.SignJWT(...).sign(A2A_SECRET)` (the
|
|
29
|
+
* existing `signA2AToken` builder). We verify with the identical
|
|
30
|
+
* `jose.jwtVerify(token, A2A_SECRET)` call `mcp/build-server.ts#verifyAuth`
|
|
31
|
+
* uses — no new crypto, no new keys.
|
|
32
|
+
*
|
|
33
|
+
* Session reuse: a NEW email is created via `auth.api.signUpEmail` — the
|
|
34
|
+
* exact Better Auth signup path `maybeAutoCreateDevSession` already uses, so
|
|
35
|
+
* the adapter creates the `user` (+ adapter-managed credential `account`)
|
|
36
|
+
* row schema-correctly and the normal `databaseHooks.user.create.after`
|
|
37
|
+
* (org auto-join, analytics) fires. The framework session is then minted via
|
|
38
|
+
* `createOAuthSession` — the literal Google-OAuth session-mint path
|
|
39
|
+
* (`addSession` + `setFrameworkSessionCookie`). An EXISTING email is never
|
|
40
|
+
* mutated: we only ADD an inert federated-provider `account` row (if absent)
|
|
41
|
+
* and mint the same framework session. Removing the env returns the app to
|
|
42
|
+
* its prior auth with no residue.
|
|
43
|
+
*/
|
|
44
|
+
import { getMethod } from "h3";
|
|
45
|
+
import * as jose from "jose";
|
|
46
|
+
import { createHash } from "node:crypto";
|
|
47
|
+
import { getBetterAuth, getBetterAuthInternalAdapter, } from "./better-auth-instance.js";
|
|
48
|
+
import { getSession, safeReturnPath, isExpectedAuthFailure } from "./auth.js";
|
|
49
|
+
import { createOAuthSession, getOrigin } from "./google-oauth.js";
|
|
50
|
+
import { getAppName } from "./app-name.js";
|
|
51
|
+
import { createSsoState, consumeSsoState, isJtiReplayed, getIdentityHubUrl, isIdentitySsoEnabled, identitySsoLoginButtonHtml, } from "./identity-sso-store.js";
|
|
52
|
+
export { getIdentityHubUrl, isIdentitySsoEnabled, identitySsoLoginButtonHtml };
|
|
53
|
+
/**
|
|
54
|
+
* The provider id recorded on the additive `account` row we link for an
|
|
55
|
+
* EXISTING local user. Must match the value the Dispatch authority agent
|
|
56
|
+
* expects to interoperate with — documented in the report so the two sides
|
|
57
|
+
* stay in sync. Inert when this provider is unused, so removing the env var
|
|
58
|
+
* leaves no behavioural residue.
|
|
59
|
+
*/
|
|
60
|
+
export const IDENTITY_SSO_PROVIDER_ID = "agent-native";
|
|
61
|
+
/**
|
|
62
|
+
* The JWT `scope` claim the hub MUST set on the identity token. The callback
|
|
63
|
+
* rejects any token whose `scope` is not exactly this value, so an A2A
|
|
64
|
+
* delegation JWT (no scope, or `scope:"mcp-connect"`) can never be replayed
|
|
65
|
+
* as an identity assertion.
|
|
66
|
+
*/
|
|
67
|
+
export const IDENTITY_SSO_SCOPE = "identity";
|
|
68
|
+
/** Identity tokens older than this are rejected even if `exp` is generous. */
|
|
69
|
+
const MAX_TOKEN_AGE_SECONDS = 10 * 60;
|
|
70
|
+
/**
|
|
71
|
+
* A stable id for THIS app, sent to the hub as `?app=` so the authority can
|
|
72
|
+
* record / display which app requested sign-in. Best-effort, non-secret,
|
|
73
|
+
* never trusted for identity. Falls back to the request host.
|
|
74
|
+
*/
|
|
75
|
+
function resolveAppId(event) {
|
|
76
|
+
const configured = process.env.AGENT_NATIVE_APP_ID?.trim() ||
|
|
77
|
+
process.env.AGENT_NATIVE_WORKSPACE_APP_ID?.trim();
|
|
78
|
+
if (configured)
|
|
79
|
+
return configured;
|
|
80
|
+
const name = getAppName();
|
|
81
|
+
if (name && name !== "app")
|
|
82
|
+
return name;
|
|
83
|
+
try {
|
|
84
|
+
const origin = getOrigin(event);
|
|
85
|
+
return new URL(origin).hostname.split(".")[0] || "app";
|
|
86
|
+
}
|
|
87
|
+
catch {
|
|
88
|
+
return "app";
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
function html(body, status = 200) {
|
|
92
|
+
return new Response(body, {
|
|
93
|
+
status,
|
|
94
|
+
headers: { "Content-Type": "text/html; charset=utf-8" },
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
function redirect(event, location) {
|
|
98
|
+
// Mirror any Set-Cookie staged on the event (e.g. the framework session
|
|
99
|
+
// cookie set by `createOAuthSession`) onto the 302. h3 v2's
|
|
100
|
+
// `prepareResponse` only merges staged Set-Cookie into a *2xx* web
|
|
101
|
+
// Response and drops them for non-2xx — so a bare
|
|
102
|
+
// `new Response("", { status: 302 })` here would silently lose the
|
|
103
|
+
// session cookie and the user would finish "Sign in with Agent-Native"
|
|
104
|
+
// still logged out. This mirrors the framework's `redirectWithStagedCookies`
|
|
105
|
+
// (auth.ts) exactly; it is a no-op when nothing is staged.
|
|
106
|
+
const headers = new Headers({ Location: location });
|
|
107
|
+
const staged = event.res?.headers?.getSetCookie?.() ?? [];
|
|
108
|
+
for (const cookie of staged)
|
|
109
|
+
headers.append("set-cookie", cookie);
|
|
110
|
+
return new Response("", { status: 302, headers });
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Minimal self-contained error page (same inline-HTML approach as the auth /
|
|
114
|
+
* connect pages). Used when the federated round-trip fails so the user gets
|
|
115
|
+
* an actionable message instead of a raw 4xx. `message` is plain text.
|
|
116
|
+
*/
|
|
117
|
+
function errorPage(message, loginPath) {
|
|
118
|
+
const safe = message
|
|
119
|
+
.replace(/&/g, "&")
|
|
120
|
+
.replace(/</g, "<")
|
|
121
|
+
.replace(/>/g, ">");
|
|
122
|
+
const safeHref = loginPath.replace(/"/g, """);
|
|
123
|
+
return html(`<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8">` +
|
|
124
|
+
`<meta name="viewport" content="width=device-width, initial-scale=1">` +
|
|
125
|
+
`<title>Sign-in failed</title>` +
|
|
126
|
+
`<style>body{font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;` +
|
|
127
|
+
`background:#09090b;color:#f4f4f5;display:flex;align-items:center;` +
|
|
128
|
+
`justify-content:center;min-height:100vh;margin:0;padding:1rem}` +
|
|
129
|
+
`.card{max-width:420px;padding:2rem;background:#141417;` +
|
|
130
|
+
`border:1px solid rgba(255,255,255,0.1);border-radius:12px;text-align:center}` +
|
|
131
|
+
`h1{font-size:1.15rem;margin:0 0 .5rem}p{color:#a1a1aa;font-size:.9rem;margin:0 0 1.25rem}` +
|
|
132
|
+
`a{color:#f4f4f5;font-weight:600;text-decoration:none;border:1px solid ` +
|
|
133
|
+
`rgba(255,255,255,0.18);border-radius:8px;padding:.6rem 1.1rem;display:inline-block}</style>` +
|
|
134
|
+
`</head><body><div class="card"><h1>Could not sign you in</h1>` +
|
|
135
|
+
`<p>${safe}</p><a href="${safeHref}">Back to sign in</a></div></body></html>`, 400);
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Derive a strong, deterministic, NEVER-exposed credential for a JIT-created
|
|
139
|
+
* SSO user. Bound to the shared A2A secret + email so it is stable across
|
|
140
|
+
* function executions but unguessable without the deployment secret. Only
|
|
141
|
+
* ever used as the `password` argument to Better Auth's own
|
|
142
|
+
* `signUpEmail` / `signInEmail` — never returned, logged, or sent anywhere.
|
|
143
|
+
*/
|
|
144
|
+
function deriveSsoCredential(email) {
|
|
145
|
+
const secret = process.env.A2A_SECRET || "";
|
|
146
|
+
// A salted SHA-256 over secret + email: stable across function executions
|
|
147
|
+
// (so the same SSO user always derives the same stand-in password) but
|
|
148
|
+
// unguessable without the deployment secret. This account's only sign-in
|
|
149
|
+
// path is the signature-verified hub token, so the value is never used by
|
|
150
|
+
// anyone but Better Auth's own signUpEmail.
|
|
151
|
+
const digest = createHash("sha256")
|
|
152
|
+
.update(`${secret}:agent-native-sso:${email}`)
|
|
153
|
+
.digest("base64url");
|
|
154
|
+
return `an-sso_${digest}`;
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* JIT-link the verified hub identity into THIS app's local Better Auth
|
|
158
|
+
* store, strictly by verified email and strictly additively.
|
|
159
|
+
*
|
|
160
|
+
* - EXISTING email → the local `user` / `session` / existing `account`
|
|
161
|
+
* rows are NEVER read-modify-written. We only ADD (if absent) one
|
|
162
|
+
* federated-provider `account` row via Better Auth's OWN
|
|
163
|
+
* `internalAdapter.linkAccount` — so id, timestamps, and schema stay
|
|
164
|
+
* adapter-correct. The row is inert (no template path reads
|
|
165
|
+
* `provider_id = "agent-native"`), so removing the env var leaves zero
|
|
166
|
+
* behavioural residue.
|
|
167
|
+
* - NEW email → created via the SAME `auth.api.signUpEmail` path the app
|
|
168
|
+
* already uses (`maybeAutoCreateDevSession` uses the identical call), so
|
|
169
|
+
* the adapter creates the `user` (+ a schema-correct credential
|
|
170
|
+
* `account`) and `databaseHooks.user.create.after` (org auto-join,
|
|
171
|
+
* analytics) fires exactly as for a normal first-time signup. Idempotent
|
|
172
|
+
* under a concurrent create (the "already exists" failure is swallowed).
|
|
173
|
+
*
|
|
174
|
+
* Returns nothing — success is implied by not throwing. Account-link
|
|
175
|
+
* failures for an existing user are swallowed (the verified email already
|
|
176
|
+
* authenticated them; the link row is bookkeeping and must never block the
|
|
177
|
+
* session).
|
|
178
|
+
*/
|
|
179
|
+
async function jitLinkIdentity(identity) {
|
|
180
|
+
const adapter = await getBetterAuthInternalAdapter();
|
|
181
|
+
// Look up the local user via Better Auth's own adapter (read-only).
|
|
182
|
+
let existing = adapter
|
|
183
|
+
? await adapter
|
|
184
|
+
.findUserByEmail(identity.email, { includeAccounts: true })
|
|
185
|
+
.catch(() => null)
|
|
186
|
+
: null;
|
|
187
|
+
if (!existing) {
|
|
188
|
+
// No local user → create via the SAME signup path the app already uses.
|
|
189
|
+
const auth = await getBetterAuth();
|
|
190
|
+
try {
|
|
191
|
+
await auth.api.signUpEmail({
|
|
192
|
+
body: {
|
|
193
|
+
email: identity.email,
|
|
194
|
+
password: deriveSsoCredential(identity.email),
|
|
195
|
+
name: identity.name || identity.email.split("@")[0] || "User",
|
|
196
|
+
},
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
catch (e) {
|
|
200
|
+
// "already exists" (concurrent create / pre-existing user the adapter
|
|
201
|
+
// lookup missed) is expected and fine — fall through to linking.
|
|
202
|
+
if (!isExpectedAuthFailure(e))
|
|
203
|
+
throw e;
|
|
204
|
+
}
|
|
205
|
+
if (adapter) {
|
|
206
|
+
existing = await adapter
|
|
207
|
+
.findUserByEmail(identity.email, { includeAccounts: true })
|
|
208
|
+
.catch(() => null);
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
// ADD the inert federated-provider link iff a local user resolved and the
|
|
212
|
+
// link is absent. Better Auth's `linkAccount` is the additive, schema-
|
|
213
|
+
// correct API — we never UPDATE/DELETE/RENAME any identity row.
|
|
214
|
+
if (adapter && existing?.user?.id) {
|
|
215
|
+
const accountId = identity.sub || identity.email;
|
|
216
|
+
const alreadyLinked = (existing.accounts ?? []).some((a) => a.providerId === IDENTITY_SSO_PROVIDER_ID && a.accountId === accountId);
|
|
217
|
+
if (!alreadyLinked) {
|
|
218
|
+
try {
|
|
219
|
+
await adapter.linkAccount({
|
|
220
|
+
userId: existing.user.id,
|
|
221
|
+
providerId: IDENTITY_SSO_PROVIDER_ID,
|
|
222
|
+
accountId,
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
catch {
|
|
226
|
+
// Inert bookkeeping row — never block sign-in on a link failure.
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* Verify the hub-issued identity JWT using the EXACT same path A2A / MCP use:
|
|
233
|
+
* `jose.jwtVerify(token, A2A_SECRET)`. `jwtVerify` enforces `exp`
|
|
234
|
+
* automatically. We additionally require:
|
|
235
|
+
* - `scope === "identity"` (so an A2A delegation token can't be replayed)
|
|
236
|
+
* - `aud` is THIS app's callback URL (so a token minted for one app cannot
|
|
237
|
+
* be replayed against another app's callback with a fresh state)
|
|
238
|
+
* - a non-empty `email` claim (the join key — comes ONLY from the verified
|
|
239
|
+
* token, never a query param)
|
|
240
|
+
* - issued no more than `MAX_TOKEN_AGE_SECONDS` ago (belt-and-braces on top
|
|
241
|
+
* of `exp` in case the hub mints long-lived tokens)
|
|
242
|
+
*
|
|
243
|
+
* Returns the verified identity, or `null` for ANY failure (bad signature,
|
|
244
|
+
* expired, wrong scope, missing email, malformed). The caller maps `null` to
|
|
245
|
+
* a generic error — it never leaks which check failed.
|
|
246
|
+
*/
|
|
247
|
+
async function verifyIdentityToken(token, expectedAudience) {
|
|
248
|
+
const secret = process.env.A2A_SECRET;
|
|
249
|
+
if (!secret || !token)
|
|
250
|
+
return null;
|
|
251
|
+
try {
|
|
252
|
+
const { payload } = await jose.jwtVerify(token, new TextEncoder().encode(secret));
|
|
253
|
+
if (payload.scope !== IDENTITY_SSO_SCOPE)
|
|
254
|
+
return null;
|
|
255
|
+
const aud = payload.aud;
|
|
256
|
+
const audienceMatches = Array.isArray(aud)
|
|
257
|
+
? aud.includes(expectedAudience)
|
|
258
|
+
: aud === expectedAudience;
|
|
259
|
+
if (!audienceMatches)
|
|
260
|
+
return null;
|
|
261
|
+
if (typeof payload.redirect_uri === "string" &&
|
|
262
|
+
payload.redirect_uri !== expectedAudience) {
|
|
263
|
+
return null;
|
|
264
|
+
}
|
|
265
|
+
const email = typeof payload.email === "string" && payload.email.includes("@")
|
|
266
|
+
? payload.email.trim().toLowerCase()
|
|
267
|
+
: null;
|
|
268
|
+
if (!email)
|
|
269
|
+
return null;
|
|
270
|
+
const iat = typeof payload.iat === "number" ? payload.iat : undefined;
|
|
271
|
+
if (iat !== undefined && Date.now() / 1000 - iat > MAX_TOKEN_AGE_SECONDS) {
|
|
272
|
+
return null;
|
|
273
|
+
}
|
|
274
|
+
const sub = typeof payload.sub === "string" && payload.sub ? payload.sub : email;
|
|
275
|
+
return {
|
|
276
|
+
email,
|
|
277
|
+
name: typeof payload.name === "string" && payload.name.trim()
|
|
278
|
+
? payload.name.trim()
|
|
279
|
+
: "",
|
|
280
|
+
orgDomain: typeof payload.org_domain === "string" && payload.org_domain
|
|
281
|
+
? payload.org_domain
|
|
282
|
+
: undefined,
|
|
283
|
+
sub,
|
|
284
|
+
jti: typeof payload.jti === "string" && payload.jti
|
|
285
|
+
? payload.jti
|
|
286
|
+
: undefined,
|
|
287
|
+
};
|
|
288
|
+
}
|
|
289
|
+
catch {
|
|
290
|
+
// Bad signature / expired / malformed — never reveal which.
|
|
291
|
+
return null;
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
// ---------------------------------------------------------------------------
|
|
295
|
+
// Route handler — single entry point; the core-routes-plugin dispatches the
|
|
296
|
+
// subpath, mirroring `handleMcpConnect`.
|
|
297
|
+
// ---------------------------------------------------------------------------
|
|
298
|
+
/**
|
|
299
|
+
* Handle a `/_agent-native/identity/*` request. `subpath` is the part after
|
|
300
|
+
* `/identity` (e.g. `/login`, `/callback`). Returns a 404 Response whenever
|
|
301
|
+
* the feature is disabled so an unset env var is a true no-op even if the
|
|
302
|
+
* route somehow gets mounted.
|
|
303
|
+
*/
|
|
304
|
+
export async function handleIdentitySso(event, subpath) {
|
|
305
|
+
const hub = getIdentityHubUrl();
|
|
306
|
+
if (!hub) {
|
|
307
|
+
return new Response("Not found", { status: 404 });
|
|
308
|
+
}
|
|
309
|
+
const method = getMethod(event);
|
|
310
|
+
const sub = ("/" + subpath.replace(/^\/+/, "").replace(/\/+$/, "")).replace(/^\/$/, "");
|
|
311
|
+
const origin = getOrigin(event);
|
|
312
|
+
const loginPath = "/_agent-native/sign-in";
|
|
313
|
+
// ---- GET /login → 302 to the hub authorize endpoint ------------------
|
|
314
|
+
if (sub === "/login") {
|
|
315
|
+
if (method !== "GET" && method !== "HEAD") {
|
|
316
|
+
return new Response("Method not allowed", { status: 405 });
|
|
317
|
+
}
|
|
318
|
+
// Already signed in here? Skip the round-trip.
|
|
319
|
+
const existing = await getSession(event).catch(() => null);
|
|
320
|
+
let returnPath = "/";
|
|
321
|
+
try {
|
|
322
|
+
const u = new URL(event.node?.req?.url ?? event.path ?? "/", "http://an.invalid");
|
|
323
|
+
returnPath = safeReturnPath(u.searchParams.get("return"));
|
|
324
|
+
}
|
|
325
|
+
catch {
|
|
326
|
+
returnPath = "/";
|
|
327
|
+
}
|
|
328
|
+
if (existing?.email) {
|
|
329
|
+
return redirect(event, returnPath);
|
|
330
|
+
}
|
|
331
|
+
let state;
|
|
332
|
+
try {
|
|
333
|
+
state = await createSsoState(returnPath === "/" ? null : returnPath);
|
|
334
|
+
}
|
|
335
|
+
catch (e) {
|
|
336
|
+
if (e?.message === "RATE_LIMITED") {
|
|
337
|
+
return errorPage("Too many sign-in attempts. Please wait a moment and try again.", loginPath);
|
|
338
|
+
}
|
|
339
|
+
return errorPage("Could not start federated sign-in. Please try again.", loginPath);
|
|
340
|
+
}
|
|
341
|
+
const redirectUri = `${origin}/_agent-native/identity/callback`;
|
|
342
|
+
const authorizeUrl = `${hub}/_agent-native/identity/authorize` +
|
|
343
|
+
`?app=${encodeURIComponent(resolveAppId(event))}` +
|
|
344
|
+
`&redirect_uri=${encodeURIComponent(redirectUri)}` +
|
|
345
|
+
`&state=${encodeURIComponent(state)}`;
|
|
346
|
+
return redirect(event, authorizeUrl);
|
|
347
|
+
}
|
|
348
|
+
// ---- GET /callback → verify token, JIT-link, mint session ------------
|
|
349
|
+
if (sub === "/callback") {
|
|
350
|
+
if (method !== "GET" && method !== "HEAD") {
|
|
351
|
+
return new Response("Method not allowed", { status: 405 });
|
|
352
|
+
}
|
|
353
|
+
let token = "";
|
|
354
|
+
let stateParam = "";
|
|
355
|
+
try {
|
|
356
|
+
const u = new URL(event.node?.req?.url ?? event.path ?? "/", "http://an.invalid");
|
|
357
|
+
token =
|
|
358
|
+
u.searchParams.get("token") || u.searchParams.get("id_token") || "";
|
|
359
|
+
stateParam = u.searchParams.get("state") || "";
|
|
360
|
+
}
|
|
361
|
+
catch {
|
|
362
|
+
return errorPage("Malformed sign-in response.", loginPath);
|
|
363
|
+
}
|
|
364
|
+
// CSRF: the state must be one we minted, unexpired, and never consumed.
|
|
365
|
+
// Consume it FIRST (single-use) so a replayed callback can't pass even
|
|
366
|
+
// with a still-valid token.
|
|
367
|
+
const stateResult = await consumeSsoState(stateParam);
|
|
368
|
+
if (!stateResult.ok) {
|
|
369
|
+
return errorPage("Your sign-in session expired or was already used. Please try again.", loginPath);
|
|
370
|
+
}
|
|
371
|
+
// Identity comes ONLY from the signature-verified token. The query
|
|
372
|
+
// `email` (if any) is never trusted.
|
|
373
|
+
const expectedAudience = `${origin}/_agent-native/identity/callback`;
|
|
374
|
+
const identity = await verifyIdentityToken(token, expectedAudience);
|
|
375
|
+
if (!identity) {
|
|
376
|
+
return errorPage("We could not verify the sign-in response. Please try again.", loginPath);
|
|
377
|
+
}
|
|
378
|
+
// Replay guard (best-effort, defence in depth on top of single-use
|
|
379
|
+
// state): reject a token whose jti we've already accepted.
|
|
380
|
+
if (await isJtiReplayed(identity.jti)) {
|
|
381
|
+
return errorPage("This sign-in link was already used. Please try again.", loginPath);
|
|
382
|
+
}
|
|
383
|
+
// JIT link STRICTLY by verified email — additive only. Existing users
|
|
384
|
+
// are never mutated; new users are created via the app's own signup
|
|
385
|
+
// path; an inert federated `account` link is added via Better Auth's
|
|
386
|
+
// own adapter API. A failure here must not leave the user signed out
|
|
387
|
+
// mid-flow, so surface a retryable error rather than a half state.
|
|
388
|
+
try {
|
|
389
|
+
await jitLinkIdentity(identity);
|
|
390
|
+
}
|
|
391
|
+
catch {
|
|
392
|
+
return errorPage("Could not finish linking your account. Please try again.", loginPath);
|
|
393
|
+
}
|
|
394
|
+
// Mint a normal framework session EXACTLY the way the Google OAuth
|
|
395
|
+
// callback does (`createOAuthSession` → addSession + framework cookie).
|
|
396
|
+
// `hasProductionSession: false` so a fresh session cookie is always set.
|
|
397
|
+
try {
|
|
398
|
+
await createOAuthSession(event, identity.email, {
|
|
399
|
+
hasProductionSession: false,
|
|
400
|
+
});
|
|
401
|
+
}
|
|
402
|
+
catch {
|
|
403
|
+
return errorPage("Signed in, but could not start your session. Please try again.", loginPath);
|
|
404
|
+
}
|
|
405
|
+
// Land the user back where they started (validated same-origin path).
|
|
406
|
+
const dest = safeReturnPath(stateResult.returnPath);
|
|
407
|
+
return redirect(event, dest);
|
|
408
|
+
}
|
|
409
|
+
return new Response("Not found", { status: 404 });
|
|
410
|
+
}
|
|
411
|
+
/**
|
|
412
|
+
* Whether the given (already base-path-stripped) request path is one of the
|
|
413
|
+
* SSO routes that must bypass the blanket auth guard. Both routes resolve /
|
|
414
|
+
* mint the browser session themselves: `/login` is the unauthenticated entry
|
|
415
|
+
* point, and `/callback` is hit by a user who is (by definition) not yet
|
|
416
|
+
* signed in to THIS app. Returns false when the feature is disabled, so the
|
|
417
|
+
* guard's behaviour is unchanged with the env unset.
|
|
418
|
+
*/
|
|
419
|
+
export function isIdentitySsoBypassPath(p) {
|
|
420
|
+
if (!isIdentitySsoEnabled())
|
|
421
|
+
return false;
|
|
422
|
+
return (p === "/_agent-native/identity/login" ||
|
|
423
|
+
p === "/_agent-native/identity/callback");
|
|
424
|
+
}
|
|
425
|
+
//# sour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BAAkB,CAAC,KAAK,EAAE,QAAQ,CAAC,KAAK,EAAE;gBAC9C,oBAAoB,EAAE,KAAK;aAC5B,CAAC,CAAC;QACL,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,SAAS,CACd,gEAAgE,EAChE,SAAS,CACV,CAAC;QACJ,CAAC;QAED,sEAAsE;QACtE,MAAM,IAAI,GAAG,cAAc,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC;QACpD,OAAO,QAAQ,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;IAC/B,CAAC;IAED,OAAO,IAAI,QAAQ,CAAC,WAAW,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC;AACpD,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,uBAAuB,CAAC,CAAS;IAC/C,IAAI,CAAC,oBAAoB,EAAE;QAAE,OAAO,KAAK,CAAC;IAC1C,OAAO,CACL,CAAC,KAAK,+BAA+B;QACrC,CAAC,KAAK,kCAAkC,CACzC,CAAC;AACJ,CAAC","sourcesContent":["/**\n * Cross-app SSO (\"Sign in with Agent-Native\") — the CLIENT side.\n *\n * Each hosted `*.agent-native.com` app has its OWN Better Auth user store\n * (a separate database per app). This module lets an app federate sign-in to\n * an identity authority (Dispatch) so a user logged in there can land in this\n * app without re-entering credentials.\n *\n * Opt-in, OFF by default, fully reversible. Everything here is gated on the\n * single env var `AGENT_NATIVE_IDENTITY_HUB_URL`:\n *\n * - UNSET → `isIdentitySsoEnabled()` is false. The route handler 404s, the\n * auth-guard bypass does not apply, and the login page renders no SSO\n * button. Existing auth is byte-for-byte unchanged.\n * - SET (e.g. `https://dispatch.agent-native.com`) → two routes mount:\n * GET /_agent-native/identity/login\n * 302 → `<HUB>/_agent-native/identity/authorize?app=<id>\n * &redirect_uri=<thisOrigin>/_agent-native/identity/callback\n * &state=<single-use CSRF state>`\n * GET /_agent-native/identity/callback?token=<jwt>&state=<state>\n * Verifies the hub-issued identity JWT (HS256 over the SHARED A2A\n * secret — the exact verify path A2A / MCP `verifyAuth` use), checks\n * `scope:\"identity\"`, `exp`, single-use CSRF `state`, and (best\n * effort) `jti` replay, then JIT-links the verified email into this\n * app's local Better Auth store and mints a normal framework session\n * the SAME way the Google OAuth callback does.\n *\n * Crypto reuse: the hub signs with `jose.SignJWT(...).sign(A2A_SECRET)` (the\n * existing `signA2AToken` builder). We verify with the identical\n * `jose.jwtVerify(token, A2A_SECRET)` call `mcp/build-server.ts#verifyAuth`\n * uses — no new crypto, no new keys.\n *\n * Session reuse: a NEW email is created via `auth.api.signUpEmail` — the\n * exact Better Auth signup path `maybeAutoCreateDevSession` already uses, so\n * the adapter creates the `user` (+ adapter-managed credential `account`)\n * row schema-correctly and the normal `databaseHooks.user.create.after`\n * (org auto-join, analytics) fires. The framework session is then minted via\n * `createOAuthSession` — the literal Google-OAuth session-mint path\n * (`addSession` + `setFrameworkSessionCookie`). An EXISTING email is never\n * mutated: we only ADD an inert federated-provider `account` row (if absent)\n * and mint the same framework session. Removing the env returns the app to\n * its prior auth with no residue.\n */\n\nimport type { H3Event } from \"h3\";\nimport { getMethod } from \"h3\";\nimport * as jose from \"jose\";\nimport { createHash } from \"node:crypto\";\nimport {\n getBetterAuth,\n getBetterAuthInternalAdapter,\n} from \"./better-auth-instance.js\";\nimport { getSession, safeReturnPath, isExpectedAuthFailure } from \"./auth.js\";\nimport { createOAuthSession, getOrigin } from \"./google-oauth.js\";\nimport { getAppName } from \"./app-name.js\";\nimport {\n createSsoState,\n consumeSsoState,\n isJtiReplayed,\n getIdentityHubUrl,\n isIdentitySsoEnabled,\n identitySsoLoginButtonHtml,\n} from \"./identity-sso-store.js\";\n\nexport { getIdentityHubUrl, isIdentitySsoEnabled, identitySsoLoginButtonHtml };\n\n/**\n * The provider id recorded on the additive `account` row we link for an\n * EXISTING local user. Must match the value the Dispatch authority agent\n * expects to interoperate with — documented in the report so the two sides\n * stay in sync. Inert when this provider is unused, so removing the env var\n * leaves no behavioural residue.\n */\nexport const IDENTITY_SSO_PROVIDER_ID = \"agent-native\";\n\n/**\n * The JWT `scope` claim the hub MUST set on the identity token. The callback\n * rejects any token whose `scope` is not exactly this value, so an A2A\n * delegation JWT (no scope, or `scope:\"mcp-connect\"`) can never be replayed\n * as an identity assertion.\n */\nexport const IDENTITY_SSO_SCOPE = \"identity\";\n\n/** Identity tokens older than this are rejected even if `exp` is generous. */\nconst MAX_TOKEN_AGE_SECONDS = 10 * 60;\n\n/**\n * A stable id for THIS app, sent to the hub as `?app=` so the authority can\n * record / display which app requested sign-in. Best-effort, non-secret,\n * never trusted for identity. Falls back to the request host.\n */\nfunction resolveAppId(event: H3Event): string {\n const configured =\n process.env.AGENT_NATIVE_APP_ID?.trim() ||\n process.env.AGENT_NATIVE_WORKSPACE_APP_ID?.trim();\n if (configured) return configured;\n const name = getAppName();\n if (name && name !== \"app\") return name;\n try {\n const origin = getOrigin(event);\n return new URL(origin).hostname.split(\".\")[0] || \"app\";\n } catch {\n return \"app\";\n }\n}\n\nfunction html(body: string, status = 200): Response {\n return new Response(body, {\n status,\n headers: { \"Content-Type\": \"text/html; charset=utf-8\" },\n });\n}\n\nfunction redirect(event: H3Event, location: string): Response {\n // Mirror any Set-Cookie staged on the event (e.g. the framework session\n // cookie set by `createOAuthSession`) onto the 302. h3 v2's\n // `prepareResponse` only merges staged Set-Cookie into a *2xx* web\n // Response and drops them for non-2xx — so a bare\n // `new Response(\"\", { status: 302 })` here would silently lose the\n // session cookie and the user would finish \"Sign in with Agent-Native\"\n // still logged out. This mirrors the framework's `redirectWithStagedCookies`\n // (auth.ts) exactly; it is a no-op when nothing is staged.\n const headers = new Headers({ Location: location });\n const staged = (event as any).res?.headers?.getSetCookie?.() ?? [];\n for (const cookie of staged) headers.append(\"set-cookie\", cookie);\n return new Response(\"\", { status: 302, headers });\n}\n\n/**\n * Minimal self-contained error page (same inline-HTML approach as the auth /\n * connect pages). Used when the federated round-trip fails so the user gets\n * an actionable message instead of a raw 4xx. `message` is plain text.\n */\nfunction errorPage(message: string, loginPath: string): Response {\n const safe = message\n .replace(/&/g, \"&\")\n .replace(/</g, \"<\")\n .replace(/>/g, \">\");\n const safeHref = loginPath.replace(/\"/g, \""\");\n return html(\n `<!DOCTYPE html><html lang=\"en\"><head><meta charset=\"UTF-8\">` +\n `<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">` +\n `<title>Sign-in failed</title>` +\n `<style>body{font-family:-apple-system,BlinkMacSystemFont,\"Segoe UI\",sans-serif;` +\n `background:#09090b;color:#f4f4f5;display:flex;align-items:center;` +\n `justify-content:center;min-height:100vh;margin:0;padding:1rem}` +\n `.card{max-width:420px;padding:2rem;background:#141417;` +\n `border:1px solid rgba(255,255,255,0.1);border-radius:12px;text-align:center}` +\n `h1{font-size:1.15rem;margin:0 0 .5rem}p{color:#a1a1aa;font-size:.9rem;margin:0 0 1.25rem}` +\n `a{color:#f4f4f5;font-weight:600;text-decoration:none;border:1px solid ` +\n `rgba(255,255,255,0.18);border-radius:8px;padding:.6rem 1.1rem;display:inline-block}</style>` +\n `</head><body><div class=\"card\"><h1>Could not sign you in</h1>` +\n `<p>${safe}</p><a href=\"${safeHref}\">Back to sign in</a></div></body></html>`,\n 400,\n );\n}\n\n/**\n * Derive a strong, deterministic, NEVER-exposed credential for a JIT-created\n * SSO user. Bound to the shared A2A secret + email so it is stable across\n * function executions but unguessable without the deployment secret. Only\n * ever used as the `password` argument to Better Auth's own\n * `signUpEmail` / `signInEmail` — never returned, logged, or sent anywhere.\n */\nfunction deriveSsoCredential(email: string): string {\n const secret = process.env.A2A_SECRET || \"\";\n // A salted SHA-256 over secret + email: stable across function executions\n // (so the same SSO user always derives the same stand-in password) but\n // unguessable without the deployment secret. This account's only sign-in\n // path is the signature-verified hub token, so the value is never used by\n // anyone but Better Auth's own signUpEmail.\n const digest = createHash(\"sha256\")\n .update(`${secret}:agent-native-sso:${email}`)\n .digest(\"base64url\");\n return `an-sso_${digest}`;\n}\n\n/**\n * JIT-link the verified hub identity into THIS app's local Better Auth\n * store, strictly by verified email and strictly additively.\n *\n * - EXISTING email → the local `user` / `session` / existing `account`\n * rows are NEVER read-modify-written. We only ADD (if absent) one\n * federated-provider `account` row via Better Auth's OWN\n * `internalAdapter.linkAccount` — so id, timestamps, and schema stay\n * adapter-correct. The row is inert (no template path reads\n * `provider_id = \"agent-native\"`), so removing the env var leaves zero\n * behavioural residue.\n * - NEW email → created via the SAME `auth.api.signUpEmail` path the app\n * already uses (`maybeAutoCreateDevSession` uses the identical call), so\n * the adapter creates the `user` (+ a schema-correct credential\n * `account`) and `databaseHooks.user.create.after` (org auto-join,\n * analytics) fires exactly as for a normal first-time signup. Idempotent\n * under a concurrent create (the \"already exists\" failure is swallowed).\n *\n * Returns nothing — success is implied by not throwing. Account-link\n * failures for an existing user are swallowed (the verified email already\n * authenticated them; the link row is bookkeeping and must never block the\n * session).\n */\nasync function jitLinkIdentity(identity: VerifiedIdentity): Promise<void> {\n const adapter = await getBetterAuthInternalAdapter();\n\n // Look up the local user via Better Auth's own adapter (read-only).\n let existing = adapter\n ? await adapter\n .findUserByEmail(identity.email, { includeAccounts: true })\n .catch(() => null)\n : null;\n\n if (!existing) {\n // No local user → create via the SAME signup path the app already uses.\n const auth = await getBetterAuth();\n try {\n await auth.api.signUpEmail({\n body: {\n email: identity.email,\n password: deriveSsoCredential(identity.email),\n name: identity.name || identity.email.split(\"@\")[0] || \"User\",\n },\n });\n } catch (e) {\n // \"already exists\" (concurrent create / pre-existing user the adapter\n // lookup missed) is expected and fine — fall through to linking.\n if (!isExpectedAuthFailure(e)) throw e;\n }\n if (adapter) {\n existing = await adapter\n .findUserByEmail(identity.email, { includeAccounts: true })\n .catch(() => null);\n }\n }\n\n // ADD the inert federated-provider link iff a local user resolved and the\n // link is absent. Better Auth's `linkAccount` is the additive, schema-\n // correct API — we never UPDATE/DELETE/RENAME any identity row.\n if (adapter && existing?.user?.id) {\n const accountId = identity.sub || identity.email;\n const alreadyLinked = (existing.accounts ?? []).some(\n (a) =>\n a.providerId === IDENTITY_SSO_PROVIDER_ID && a.accountId === accountId,\n );\n if (!alreadyLinked) {\n try {\n await adapter.linkAccount({\n userId: existing.user.id,\n providerId: IDENTITY_SSO_PROVIDER_ID,\n accountId,\n });\n } catch {\n // Inert bookkeeping row — never block sign-in on a link failure.\n }\n }\n }\n}\n\ninterface VerifiedIdentity {\n email: string;\n name: string;\n orgDomain?: string;\n sub: string;\n jti?: string;\n}\n\n/**\n * Verify the hub-issued identity JWT using the EXACT same path A2A / MCP use:\n * `jose.jwtVerify(token, A2A_SECRET)`. `jwtVerify` enforces `exp`\n * automatically. We additionally require:\n * - `scope === \"identity\"` (so an A2A delegation token can't be replayed)\n * - `aud` is THIS app's callback URL (so a token minted for one app cannot\n * be replayed against another app's callback with a fresh state)\n * - a non-empty `email` claim (the join key — comes ONLY from the verified\n * token, never a query param)\n * - issued no more than `MAX_TOKEN_AGE_SECONDS` ago (belt-and-braces on top\n * of `exp` in case the hub mints long-lived tokens)\n *\n * Returns the verified identity, or `null` for ANY failure (bad signature,\n * expired, wrong scope, missing email, malformed). The caller maps `null` to\n * a generic error — it never leaks which check failed.\n */\nasync function verifyIdentityToken(\n token: string,\n expectedAudience: string,\n): Promise<VerifiedIdentity | null> {\n const secret = process.env.A2A_SECRET;\n if (!secret || !token) return null;\n try {\n const { payload } = await jose.jwtVerify(\n token,\n new TextEncoder().encode(secret),\n );\n if (payload.scope !== IDENTITY_SSO_SCOPE) return null;\n const aud = payload.aud;\n const audienceMatches = Array.isArray(aud)\n ? aud.includes(expectedAudience)\n : aud === expectedAudience;\n if (!audienceMatches) return null;\n if (\n typeof payload.redirect_uri === \"string\" &&\n payload.redirect_uri !== expectedAudience\n ) {\n return null;\n }\n const email =\n typeof payload.email === \"string\" && payload.email.includes(\"@\")\n ? payload.email.trim().toLowerCase()\n : null;\n if (!email) return null;\n const iat = typeof payload.iat === \"number\" ? payload.iat : undefined;\n if (iat !== undefined && Date.now() / 1000 - iat > MAX_TOKEN_AGE_SECONDS) {\n return null;\n }\n const sub =\n typeof payload.sub === \"string\" && payload.sub ? payload.sub : email;\n return {\n email,\n name:\n typeof payload.name === \"string\" && payload.name.trim()\n ? payload.name.trim()\n : \"\",\n orgDomain:\n typeof payload.org_domain === \"string\" && payload.org_domain\n ? payload.org_domain\n : undefined,\n sub,\n jti:\n typeof payload.jti === \"string\" && payload.jti\n ? payload.jti\n : undefined,\n };\n } catch {\n // Bad signature / expired / malformed — never reveal which.\n return null;\n }\n}\n\n// ---------------------------------------------------------------------------\n// Route handler — single entry point; the core-routes-plugin dispatches the\n// subpath, mirroring `handleMcpConnect`.\n// ---------------------------------------------------------------------------\n\n/**\n * Handle a `/_agent-native/identity/*` request. `subpath` is the part after\n * `/identity` (e.g. `/login`, `/callback`). Returns a 404 Response whenever\n * the feature is disabled so an unset env var is a true no-op even if the\n * route somehow gets mounted.\n */\nexport async function handleIdentitySso(\n event: H3Event,\n subpath: string,\n): Promise<Response> {\n const hub = getIdentityHubUrl();\n if (!hub) {\n return new Response(\"Not found\", { status: 404 });\n }\n\n const method = getMethod(event);\n const sub = (\"/\" + subpath.replace(/^\\/+/, \"\").replace(/\\/+$/, \"\")).replace(\n /^\\/$/,\n \"\",\n );\n const origin = getOrigin(event);\n const loginPath = \"/_agent-native/sign-in\";\n\n // ---- GET /login → 302 to the hub authorize endpoint ------------------\n if (sub === \"/login\") {\n if (method !== \"GET\" && method !== \"HEAD\") {\n return new Response(\"Method not allowed\", { status: 405 });\n }\n // Already signed in here? Skip the round-trip.\n const existing = await getSession(event).catch(() => null);\n let returnPath = \"/\";\n try {\n const u = new URL(\n (event as any).node?.req?.url ?? event.path ?? \"/\",\n \"http://an.invalid\",\n );\n returnPath = safeReturnPath(u.searchParams.get(\"return\"));\n } catch {\n returnPath = \"/\";\n }\n if (existing?.email) {\n return redirect(event, returnPath);\n }\n\n let state: string;\n try {\n state = await createSsoState(returnPath === \"/\" ? null : returnPath);\n } catch (e: any) {\n if (e?.message === \"RATE_LIMITED\") {\n return errorPage(\n \"Too many sign-in attempts. Please wait a moment and try again.\",\n loginPath,\n );\n }\n return errorPage(\n \"Could not start federated sign-in. Please try again.\",\n loginPath,\n );\n }\n\n const redirectUri = `${origin}/_agent-native/identity/callback`;\n const authorizeUrl =\n `${hub}/_agent-native/identity/authorize` +\n `?app=${encodeURIComponent(resolveAppId(event))}` +\n `&redirect_uri=${encodeURIComponent(redirectUri)}` +\n `&state=${encodeURIComponent(state)}`;\n return redirect(event, authorizeUrl);\n }\n\n // ---- GET /callback → verify token, JIT-link, mint session ------------\n if (sub === \"/callback\") {\n if (method !== \"GET\" && method !== \"HEAD\") {\n return new Response(\"Method not allowed\", { status: 405 });\n }\n\n let token = \"\";\n let stateParam = \"\";\n try {\n const u = new URL(\n (event as any).node?.req?.url ?? event.path ?? \"/\",\n \"http://an.invalid\",\n );\n token =\n u.searchParams.get(\"token\") || u.searchParams.get(\"id_token\") || \"\";\n stateParam = u.searchParams.get(\"state\") || \"\";\n } catch {\n return errorPage(\"Malformed sign-in response.\", loginPath);\n }\n\n // CSRF: the state must be one we minted, unexpired, and never consumed.\n // Consume it FIRST (single-use) so a replayed callback can't pass even\n // with a still-valid token.\n const stateResult = await consumeSsoState(stateParam);\n if (!stateResult.ok) {\n return errorPage(\n \"Your sign-in session expired or was already used. Please try again.\",\n loginPath,\n );\n }\n\n // Identity comes ONLY from the signature-verified token. The query\n // `email` (if any) is never trusted.\n const expectedAudience = `${origin}/_agent-native/identity/callback`;\n const identity = await verifyIdentityToken(token, expectedAudience);\n if (!identity) {\n return errorPage(\n \"We could not verify the sign-in response. Please try again.\",\n loginPath,\n );\n }\n\n // Replay guard (best-effort, defence in depth on top of single-use\n // state): reject a token whose jti we've already accepted.\n if (await isJtiReplayed(identity.jti)) {\n return errorPage(\n \"This sign-in link was already used. Please try again.\",\n loginPath,\n );\n }\n\n // JIT link STRICTLY by verified email — additive only. Existing users\n // are never mutated; new users are created via the app's own signup\n // path; an inert federated `account` link is added via Better Auth's\n // own adapter API. A failure here must not leave the user signed out\n // mid-flow, so surface a retryable error rather than a half state.\n try {\n await jitLinkIdentity(identity);\n } catch {\n return errorPage(\n \"Could not finish linking your account. Please try again.\",\n loginPath,\n );\n }\n\n // Mint a normal framework session EXACTLY the way the Google OAuth\n // callback does (`createOAuthSession` → addSession + framework cookie).\n // `hasProductionSession: false` so a fresh session cookie is always set.\n try {\n await createOAuthSession(event, identity.email, {\n hasProductionSession: false,\n });\n } catch {\n return errorPage(\n \"Signed in, but could not start your session. Please try again.\",\n loginPath,\n );\n }\n\n // Land the user back where they started (validated same-origin path).\n const dest = safeReturnPath(stateResult.returnPath);\n return redirect(event, dest);\n }\n\n return new Response(\"Not found\", { status: 404 });\n}\n\n/**\n * Whether the given (already base-path-stripped) request path is one of the\n * SSO routes that must bypass the blanket auth guard. Both routes resolve /\n * mint the browser session themselves: `/login` is the unauthenticated entry\n * point, and `/callback` is hit by a user who is (by definition) not yet\n * signed in to THIS app. Returns false when the feature is disabled, so the\n * guard's behaviour is unchanged with the env unset.\n */\nexport function isIdentitySsoBypassPath(p: string): boolean {\n if (!isIdentitySsoEnabled()) return false;\n return (\n p === \"/_agent-native/identity/login\" ||\n p === \"/_agent-native/identity/callback\"\n );\n}\n"]}
|
package/dist/server/index.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ export { buildDeepLink, toAbsoluteOpenUrl, toDesktopOpenUrl, OPEN_ROUTE_SUBPATH,
|
|
|
4
4
|
export { createOpenRouteHandler, type OpenRouteOptions } from "./open-route.js";
|
|
5
5
|
export { createSSEHandler, type SSEHandlerOptions } from "./sse.js";
|
|
6
6
|
export { mountAuthMiddleware, autoMountAuth, getSession, addSession, removeSession, getSessionEmail, runAuthGuard, setDesktopExchange, setDesktopExchangeError, safeReturnPath, type DesktopExchangeErrorPayload, type AuthSession, type AuthOptions, } from "./auth.js";
|
|
7
|
+
export { handleIdentitySso, getIdentityHubUrl, isIdentitySsoEnabled, isIdentitySsoBypassPath, identitySsoLoginButtonHtml, IDENTITY_SSO_PROVIDER_ID, IDENTITY_SSO_SCOPE, } from "./identity-sso.js";
|
|
7
8
|
export { requireEnvKey, type MissingKeyResponse } from "./missing-key.js";
|
|
8
9
|
export { verifyCaptcha, type CaptchaVerifyResult } from "./captcha.js";
|
|
9
10
|
export { createProductionAgentHandler, type ActionEntry, type ScriptEntry, type ProductionAgentOptions, type ActionTool, type ScriptTool, type AgentMessage, type AgentChatRequest, type AgentChatEvent, type AgentChatAttachment, type AgentChatReference, type MentionProvider, type MentionProviderItem, type AgentLoopFinalResponseGuard, type AgentLoopFinalResponseGuardContext, type AgentLoopFinalResponseGuardResult, type AgentLoopToolCallSummary, type AgentLoopToolResultSummary, } from "../agent/index.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/server/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACZ,aAAa,EACb,KAAK,mBAAmB,EACxB,KAAK,YAAY,GAClB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AACvD,OAAO,EACL,aAAa,EACb,iBAAiB,EACjB,gBAAgB,EAChB,kBAAkB,EAClB,gBAAgB,EAChB,KAAK,aAAa,GACnB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,sBAAsB,EAAE,KAAK,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAChF,OAAO,EAAE,gBAAgB,EAAE,KAAK,iBAAiB,EAAE,MAAM,UAAU,CAAC;AACpE,OAAO,EACL,mBAAmB,EACnB,aAAa,EACb,UAAU,EACV,UAAU,EACV,aAAa,EACb,eAAe,EACf,YAAY,EACZ,kBAAkB,EAClB,uBAAuB,EACvB,cAAc,EACd,KAAK,2BAA2B,EAChC,KAAK,WAAW,EAChB,KAAK,WAAW,GACjB,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,aAAa,EAAE,KAAK,kBAAkB,EAAE,MAAM,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KAAK,aAAa,EAClB,KAAK,QAAQ,GACd,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AACzE,OAAO,EACL,wBAAwB,EACxB,oBAAoB,EACpB,yBAAyB,GAC1B,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,mBAAmB,EACnB,qBAAqB,EACrB,KAAK,qBAAqB,EAC1B,KAAK,YAAY,IAAI,2BAA2B,GACjD,MAAM,wBAAwB,CAAC;AAUhC,MAAM,MAAM,cAAc,GAAG,CAAC,QAAQ,EAAE,GAAG,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;AACrE,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,cAAc,GAAG,cAAc,CAErE"}
|
package/dist/server/index.js
CHANGED
|
@@ -4,6 +4,7 @@ export { buildDeepLink, toAbsoluteOpenUrl, toDesktopOpenUrl, OPEN_ROUTE_SUBPATH,
|
|
|
4
4
|
export { createOpenRouteHandler } from "./open-route.js";
|
|
5
5
|
export { createSSEHandler } from "./sse.js";
|
|
6
6
|
export { mountAuthMiddleware, autoMountAuth, getSession, addSession, removeSession, getSessionEmail, runAuthGuard, setDesktopExchange, setDesktopExchangeError, safeReturnPath, } from "./auth.js";
|
|
7
|
+
export { handleIdentitySso, getIdentityHubUrl, isIdentitySsoEnabled, isIdentitySsoBypassPath, identitySsoLoginButtonHtml, IDENTITY_SSO_PROVIDER_ID, IDENTITY_SSO_SCOPE, } from "./identity-sso.js";
|
|
7
8
|
export { requireEnvKey } from "./missing-key.js";
|
|
8
9
|
export { verifyCaptcha } from "./captcha.js";
|
|
9
10
|
export { createProductionAgentHandler, } from "../agent/index.js";
|
package/dist/server/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/server/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACZ,aAAa,GAGd,MAA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wB,EACxB,wBAAwB,EACxB,2BAA2B,EAC3B,yBAAyB,EACzB,wBAAwB,EACxB,uBAAuB,EACvB,wBAAwB,EACxB,aAAa,GACd,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,yBAAyB,EACzB,yBAAyB,EACzB,6BAA6B,EAC7B,gCAAgC,EAChC,eAAe,GAEhB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EACL,SAAS,EACT,iBAAiB,EACjB,gBAAgB,GAGjB,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,WAAW,EACX,WAAW,EACX,SAAS,GAIV,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AACzE,OAAO,EACL,wBAAwB,EACxB,oBAAoB,EACpB,yBAAyB,GAC1B,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,mBAAmB,EACnB,qBAAqB,GAGtB,MAAM,wBAAwB,CAAC;AAWhC,MAAM,UAAU,iBAAiB,CAAC,GAAmB;IACnD,OAAO,GAAG,CAAC;AACb,CAAC","sourcesContent":["export {\n createServer,\n upsertEnvFile,\n type CreateServerOptions,\n type EnvKeyConfig,\n} from \"./create-server.js\";\n\nexport { readBody, streamFile } from \"./h3-helpers.js\";\nexport {\n buildDeepLink,\n toAbsoluteOpenUrl,\n toDesktopOpenUrl,\n OPEN_ROUTE_SUBPATH,\n DESKTOP_OPEN_URL,\n type DeepLinkInput,\n} from \"./deep-link.js\";\nexport { createOpenRouteHandler, type OpenRouteOptions } from \"./open-route.js\";\nexport { createSSEHandler, type SSEHandlerOptions } from \"./sse.js\";\nexport {\n mountAuthMiddleware,\n autoMountAuth,\n getSession,\n addSession,\n removeSession,\n getSessionEmail,\n runAuthGuard,\n setDesktopExchange,\n setDesktopExchangeError,\n safeReturnPath,\n type DesktopExchangeErrorPayload,\n type AuthSession,\n type AuthOptions,\n} from \"./auth.js\";\nexport { requireEnvKey, type MissingKeyResponse } from \"./missing-key.js\";\nexport { verifyCaptcha, type CaptchaVerifyResult } from \"./captcha.js\";\nexport {\n createProductionAgentHandler,\n type ActionEntry,\n type ScriptEntry,\n type ProductionAgentOptions,\n type ActionTool,\n type ScriptTool,\n type AgentMessage,\n type AgentChatRequest,\n type AgentChatEvent,\n type AgentChatAttachment,\n type AgentChatReference,\n type MentionProvider,\n type MentionProviderItem,\n type AgentLoopFinalResponseGuard,\n type AgentLoopFinalResponseGuardContext,\n type AgentLoopFinalResponseGuardResult,\n type AgentLoopToolCallSummary,\n type AgentLoopToolResultSummary,\n} from \"../agent/index.js\";\nexport {\n actionsToEngineTools,\n getOwnerActiveApiKey,\n runAgentLoop,\n} from \"../agent/production-agent.js\";\nexport {\n getStoredModelForEngine,\n resolveEngine,\n} from \"../agent/engine/index.js\";\nexport { createDevScriptRegistry } from \"../scripts/dev/index.js\";\n\nexport {\n createPollHandler,\n recordChange,\n getVersion,\n getChangesSince,\n getPollEmitter,\n canSeeChangeForUser,\n POLL_CHANGE_EVENT,\n} from \"./poll.js\";\nexport { createPollEventsHandler } from \"./poll-events.js\";\nexport { createAuthPlugin, defaultAuthPlugin } from \"./auth-plugin.js\";\nexport {\n initServerSentry,\n isServerSentryEnabled,\n setSentryUserForRequest,\n captureRouteError,\n type RouteErrorContext,\n} from \"./sentry.js\";\nexport {\n captureError,\n captureServerError,\n registerErrorCaptureProvider,\n type CaptureErrorContext,\n type CaptureErrorProvider,\n} from \"./capture-error.js\";\nexport { createSentryPlugin, defaultSentryPlugin } from \"./sentry-plugin.js\";\n// Re-export the org plugin so the auto-discovery's DEFAULT_PLUGIN_REGISTRY\n// (which references \"defaultOrgPlugin\" from @agent-native/core/server) can\n// resolve it during the deploy build worker-entry generation.\nexport { createOrgPlugin, defaultOrgPlugin } from \"../org/plugin.js\";\nexport {\n createGoogleAuthPlugin,\n type GoogleAuthPluginOptions,\n} from \"./google-auth-plugin.js\";\nexport type { GoogleAuthMode } from \"./google-auth-mode.js\";\nexport {\n createAgentChatPlugin,\n defaultAgentChatPlugin,\n type AgentChatPluginOptions,\n} from \"./agent-chat-plugin.js\";\nexport {\n configureAgentNativeEmbeddedEnvironment,\n createAgentNativeEmbeddedAuthOptions,\n createAgentNativeEmbeddedPlugin,\n mountAgentNativeEmbedded,\n normalizeAgentNativeEmbeddedSession,\n type AgentNativeEmbeddedAuthOptions,\n type AgentNativeEmbeddedGetSession,\n type AgentNativeEmbeddedHostSession,\n type AgentNativeEmbeddedPluginOptions,\n} from \"./embedded.js\";\nexport {\n createThread,\n getThread,\n listThreads,\n updateThreadData,\n deleteThread,\n setThreadScope,\n type ChatThread,\n type ChatThreadScope,\n type ChatThreadSummary,\n type ListThreadsOptions,\n} from \"../chat-threads/store.js\";\nexport {\n createResourcesPlugin,\n defaultResourcesPlugin,\n} from \"./resources-plugin.js\";\nexport {\n createCoreRoutesPlugin,\n defaultCoreRoutesPlugin,\n FRAMEWORK_ROUTE_PREFIX,\n type CoreRoutesPluginOptions,\n} from \"./core-routes-plugin.js\";\nexport {\n createBrowserSessionActionEntries,\n type CreateBrowserSessionActionEntriesOptions,\n} from \"../browser-sessions/actions.js\";\nexport {\n DEFAULT_BROWSER_SESSION_REQUEST_POLL_MS,\n DEFAULT_BROWSER_SESSION_REQUEST_TIMEOUT_MS,\n DEFAULT_BROWSER_SESSION_TTL_MS,\n callBrowserSession,\n claimBrowserSessionRequest,\n completeBrowserSessionRequest,\n createBrowserSessionRequest,\n disconnectBrowserSession,\n getBrowserSession,\n getBrowserSessionRequest,\n listBrowserSessions,\n registerBrowserSession,\n waitForBrowserSessionRequest,\n} from \"../browser-sessions/store.js\";\nexport {\n mountBrowserSessionRoutes,\n type MountBrowserSessionRoutesOptions,\n} from \"../browser-sessions/routes.js\";\nexport type {\n AgentNativeBrowserSession,\n AgentNativeBrowserSessionAction,\n AgentNativeBrowserSessionRecord,\n AgentNativeBrowserSessionRequest,\n AgentNativeBrowserSessionRequestStatus,\n AgentNativeBrowserSessionRequestType,\n CreateAgentNativeBrowserSessionRequestInput,\n RegisterAgentNativeBrowserSessionInput,\n} from \"../browser-sessions/types.js\";\nexport {\n createTerminalPlugin,\n defaultTerminalPlugin,\n type TerminalPluginOptions,\n} from \"../terminal/terminal-plugin.js\";\nexport {\n createCollabPlugin,\n type CollabPluginOptions,\n} from \"./collab-plugin.js\";\n\nexport {\n spawnTask,\n getTask,\n getTaskByThread,\n listTasks,\n sendToTask,\n markTaskErrored,\n type AgentTask,\n type SpawnTaskOptions,\n} from \"./agent-teams.js\";\nexport { isOAuthConnected, getOAuthAccounts } from \"./oauth-helpers.js\";\nexport { wrapWithAnalytics } from \"./analytics.js\";\nexport {\n getH3App,\n awaitBootstrap,\n type H3AppShim,\n} from \"./framework-request-handler.js\";\nexport {\n autoDiscoverActions,\n autoDiscoverScripts,\n loadActionsFromStaticRegistry,\n mergeCoreSharingActions,\n registerPackageActions,\n} from \"./action-discovery.js\";\nexport {\n mountActionRoutes,\n type MountActionRoutesOptions,\n} from \"./action-routes.js\";\nexport {\n runWithRequestContext,\n hasRequestContext,\n getRequestContext,\n getRequestUserEmail,\n getRequestUserName,\n getRequestOrgId,\n getRequestTimezone,\n getRequestRunContext,\n getCredentialContext,\n isIntegrationCallerRequest,\n type RequestContext,\n type RequestRunContext,\n} from \"./request-context.js\";\nexport { formatDateInTimezone, todayInTimezone } from \"./date-utils.js\";\n\nexport {\n createOnboardingPlugin,\n defaultOnboardingPlugin,\n} from \"../onboarding/plugin.js\";\n\nexport {\n registerFileUploadProvider,\n unregisterFileUploadProvider,\n listFileUploadProviders,\n getActiveFileUploadProvider,\n uploadFile,\n builderFileUploadProvider,\n type FileUploadInput,\n type FileUploadProvider,\n type FileUploadResult,\n} from \"../file-upload/index.js\";\n\nexport {\n createIntegrationsPlugin,\n defaultIntegrationsPlugin,\n enqueueRemoteCommand,\n slackAdapter,\n telegramAdapter,\n whatsappAdapter,\n emailAdapter,\n type PlatformAdapter,\n type IncomingMessage,\n type OutgoingMessage,\n type IntegrationStatus,\n type IntegrationsPluginOptions,\n} from \"../integrations/index.js\";\n\nexport {\n isElectron,\n isMobile,\n getOrigin,\n getAppBasePath,\n getAppUrl,\n resolveOAuthRedirectUri,\n isAllowedOAuthRedirectUri,\n encodeOAuthState,\n decodeOAuthState,\n resolveOAuthOwner,\n createOAuthSession,\n oauthCallbackResponse,\n oauthErrorPage,\n oauthDesktopExchangePage,\n type OAuthStatePayload,\n type OAuthOwnerResult,\n type OAuthSessionResult,\n} from \"./google-oauth.js\";\n\nexport {\n FeatureNotConfiguredError,\n hasBuilderPrivateKey,\n isBuilderEnvManaged,\n getBuilderProxyOrigin,\n getBuilderImageGenerationBaseUrl,\n getBuilderAuthHeader,\n resolveBuilderPrivateKey,\n resolveBuilderAuthHeader,\n resolveHasBuilderPrivateKey,\n resolveBuilderCredentials,\n resolveBuilderCredential,\n writeBuilderCredentials,\n deleteBuilderCredentials,\n resolveSecret,\n} from \"./credential-provider.js\";\nexport {\n getBuilderBranchProjectId,\n isBuilderBranchingEnabled,\n resolveBuilderBranchProjectId,\n resolveIsBuilderBranchingEnabled,\n runBuilderAgent,\n type RunBuilderAgentResult,\n} from \"./builder-browser.js\";\n\nexport {\n sendEmail,\n isEmailConfigured,\n getEmailProvider,\n type EmailProvider,\n type SendEmailArgs,\n} from \"./email.js\";\nexport {\n renderEmail,\n emailStrong,\n emailLink,\n type RenderEmailArgs,\n type RenderedEmail,\n type EmailCta,\n} from \"./email-template.js\";\nexport { getAppProductionUrl, getFirstPartyProdUrl } from \"./app-url.js\";\nexport {\n getConfiguredAppBasePath,\n normalizeAppBasePath,\n withConfiguredAppBasePath,\n} from \"./app-base-path.js\";\nexport {\n signShortLivedToken,\n verifyShortLivedToken,\n type ShortLivedTokenClaims,\n type VerifyResult as ShortLivedTokenVerifyResult,\n} from \"./short-lived-token.js\";\n\n// SSR handler is NOT re-exported here — it uses a virtual module\n// (virtual:react-router/server-build) that only exists at Vite dev/build time.\n// Including it in this barrel would break the esbuild CF Pages bundler.\n// Templates import directly: import { ssrHandler } from \"@agent-native/core/server/ssr-handler\"\n\n// Nitro plugin helper — re-exported so templates don't need nitro as a direct dependency.\n// defineNitroPlugin is an identity function; this typed wrapper lets templates use it\n// without resolving `nitro/runtime` (which requires Nitro's virtual modules at runtime).\nexport type NitroPluginDef = (nitroApp: any) => void | Promise<void>;\nexport function defineNitroPlugin(def: NitroPluginDef): NitroPluginDef {\n return def;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/server/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACZ,aAAa,GAGd,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AACvD,OAAO,EACL,aAAa,EACb,iBAAiB,EACjB,gBAAgB,EAChB,kBAAkB,EAClB,gBAAgB,GAEjB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,sBAAsB,EAAyB,MAAM,iBAAiB,CAAC;AAChF,OAAO,EAAE,gBAAgB,EAA0B,MAAM,UAAU,CAAC;AACpE,OAAO,EACL,mBAAmB,EACnB,aAAa,EACb,UAAU,EACV,UAAU,EACV,aAAa,EACb,eAAe,EACf,YAAY,EACZ,kBAAkB,EAClB,uBAAuB,EACvB,cAAc,GAIf,MAAM,WAAW,CAAC;AACnB,OAAO,EACL,iBAAiB,EACjB,iBAAiB,EACjB,oBAAoB,EACpB,uBAAuB,EACvB,0BAA0B,EAC1B,wBAAwB,EACxB,kBAAkB,GACnB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,aAAa,EAA2B,MAAM,kBAAkB,CAAC;AAC1E,OAAO,EAAE,aAAa,EAA4B,MAAM,cAAc,CAAC;AACvE,OAAO,EACL,4BAA4B,GAkB7B,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,oBAAoB,EACpB,oBAAoB,EACpB,YAAY,GACb,MAAM,8BAA8B,CAAC;AACtC,OAAO,EACL,uBAAuB,EACvB,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ateServerOptions,\n type EnvKeyConfig,\n} from \"./create-server.js\";\n\nexport { readBody, streamFile } from \"./h3-helpers.js\";\nexport {\n buildDeepLink,\n toAbsoluteOpenUrl,\n toDesktopOpenUrl,\n OPEN_ROUTE_SUBPATH,\n DESKTOP_OPEN_URL,\n type DeepLinkInput,\n} from \"./deep-link.js\";\nexport { createOpenRouteHandler, type OpenRouteOptions } from \"./open-route.js\";\nexport { createSSEHandler, type SSEHandlerOptions } from \"./sse.js\";\nexport {\n mountAuthMiddleware,\n autoMountAuth,\n getSession,\n addSession,\n removeSession,\n getSessionEmail,\n runAuthGuard,\n setDesktopExchange,\n setDesktopExchangeError,\n safeReturnPath,\n type DesktopExchangeErrorPayload,\n type AuthSession,\n type AuthOptions,\n} from \"./auth.js\";\nexport {\n handleIdentitySso,\n getIdentityHubUrl,\n isIdentitySsoEnabled,\n isIdentitySsoBypassPath,\n identitySsoLoginButtonHtml,\n IDENTITY_SSO_PROVIDER_ID,\n IDENTITY_SSO_SCOPE,\n} from \"./identity-sso.js\";\nexport { requireEnvKey, type MissingKeyResponse } from \"./missing-key.js\";\nexport { verifyCaptcha, type CaptchaVerifyResult } from \"./captcha.js\";\nexport {\n createProductionAgentHandler,\n type ActionEntry,\n type ScriptEntry,\n type ProductionAgentOptions,\n type ActionTool,\n type ScriptTool,\n type AgentMessage,\n type AgentChatRequest,\n type AgentChatEvent,\n type AgentChatAttachment,\n type AgentChatReference,\n type MentionProvider,\n type MentionProviderItem,\n type AgentLoopFinalResponseGuard,\n type AgentLoopFinalResponseGuardContext,\n type AgentLoopFinalResponseGuardResult,\n type AgentLoopToolCallSummary,\n type AgentLoopToolResultSummary,\n} from \"../agent/index.js\";\nexport {\n actionsToEngineTools,\n getOwnerActiveApiKey,\n runAgentLoop,\n} from \"../agent/production-agent.js\";\nexport {\n getStoredModelForEngine,\n resolveEngine,\n} from \"../agent/engine/index.js\";\nexport { createDevScriptRegistry } from \"../scripts/dev/index.js\";\n\nexport {\n createPollHandler,\n recordChange,\n getVersion,\n getChangesSince,\n getPollEmitter,\n canSeeChangeForUser,\n POLL_CHANGE_EVENT,\n} from \"./poll.js\";\nexport { createPollEventsHandler } from \"./poll-events.js\";\nexport { createAuthPlugin, defaultAuthPlugin } from \"./auth-plugin.js\";\nexport {\n initServerSentry,\n isServerSentryEnabled,\n setSentryUserForRequest,\n captureRouteError,\n type RouteErrorContext,\n} from \"./sentry.js\";\nexport {\n captureError,\n captureServerError,\n registerErrorCaptureProvider,\n type CaptureErrorContext,\n type CaptureErrorProvider,\n} from \"./capture-error.js\";\nexport { createSentryPlugin, defaultSentryPlugin } from \"./sentry-plugin.js\";\n// Re-export the org plugin so the auto-discovery's DEFAULT_PLUGIN_REGISTRY\n// (which references \"defaultOrgPlugin\" from @agent-native/core/server) can\n// resolve it during the deploy build worker-entry generation.\nexport { createOrgPlugin, defaultOrgPlugin } from \"../org/plugin.js\";\nexport {\n createGoogleAuthPlugin,\n type GoogleAuthPluginOptions,\n} from \"./google-auth-plugin.js\";\nexport type { GoogleAuthMode } from \"./google-auth-mode.js\";\nexport {\n createAgentChatPlugin,\n defaultAgentChatPlugin,\n type AgentChatPluginOptions,\n} from \"./agent-chat-plugin.js\";\nexport {\n configureAgentNativeEmbeddedEnvironment,\n createAgentNativeEmbeddedAuthOptions,\n createAgentNativeEmbeddedPlugin,\n mountAgentNativeEmbedded,\n normalizeAgentNativeEmbeddedSession,\n type AgentNativeEmbeddedAuthOptions,\n type AgentNativeEmbeddedGetSession,\n type AgentNativeEmbeddedHostSession,\n type AgentNativeEmbeddedPluginOptions,\n} from \"./embedded.js\";\nexport {\n createThread,\n getThread,\n listThreads,\n updateThreadData,\n deleteThread,\n setThreadScope,\n type ChatThread,\n type ChatThreadScope,\n type ChatThreadSummary,\n type ListThreadsOptions,\n} from \"../chat-threads/store.js\";\nexport {\n createResourcesPlugin,\n defaultResourcesPlugin,\n} from \"./resources-plugin.js\";\nexport {\n createCoreRoutesPlugin,\n defaultCoreRoutesPlugin,\n FRAMEWORK_ROUTE_PREFIX,\n type CoreRoutesPluginOptions,\n} from \"./core-routes-plugin.js\";\nexport {\n createBrowserSessionActionEntries,\n type CreateBrowserSessionActionEntriesOptions,\n} from \"../browser-sessions/actions.js\";\nexport {\n DEFAULT_BROWSER_SESSION_REQUEST_POLL_MS,\n DEFAULT_BROWSER_SESSION_REQUEST_TIMEOUT_MS,\n DEFAULT_BROWSER_SESSION_TTL_MS,\n callBrowserSession,\n claimBrowserSessionRequest,\n completeBrowserSessionRequest,\n createBrowserSessionRequest,\n disconnectBrowserSession,\n getBrowserSession,\n getBrowserSessionRequest,\n listBrowserSessions,\n registerBrowserSession,\n waitForBrowserSessionRequest,\n} from \"../browser-sessions/store.js\";\nexport {\n mountBrowserSessionRoutes,\n type MountBrowserSessionRoutesOptions,\n} from \"../browser-sessions/routes.js\";\nexport type {\n AgentNativeBrowserSession,\n AgentNativeBrowserSessionAction,\n AgentNativeBrowserSessionRecord,\n AgentNativeBrowserSessionRequest,\n AgentNativeBrowserSessionRequestStatus,\n AgentNativeBrowserSessionRequestType,\n CreateAgentNativeBrowserSessionRequestInput,\n RegisterAgentNativeBrowserSessionInput,\n} from \"../browser-sessions/types.js\";\nexport {\n createTerminalPlugin,\n defaultTerminalPlugin,\n type TerminalPluginOptions,\n} from \"../terminal/terminal-plugin.js\";\nexport {\n createCollabPlugin,\n type CollabPluginOptions,\n} from \"./collab-plugin.js\";\n\nexport {\n spawnTask,\n getTask,\n getTaskByThread,\n listTasks,\n sendToTask,\n markTaskErrored,\n type AgentTask,\n type SpawnTaskOptions,\n} from \"./agent-teams.js\";\nexport { isOAuthConnected, getOAuthAccounts } from \"./oauth-helpers.js\";\nexport { wrapWithAnalytics } from \"./analytics.js\";\nexport {\n getH3App,\n awaitBootstrap,\n type H3AppShim,\n} from \"./framework-request-handler.js\";\nexport {\n autoDiscoverActions,\n autoDiscoverScripts,\n loadActionsFromStaticRegistry,\n mergeCoreSharingActions,\n registerPackageActions,\n} from \"./action-discovery.js\";\nexport {\n mountActionRoutes,\n type MountActionRoutesOptions,\n} from \"./action-routes.js\";\nexport {\n runWithRequestContext,\n hasRequestContext,\n getRequestContext,\n getRequestUserEmail,\n getRequestUserName,\n getRequestOrgId,\n getRequestTimezone,\n getRequestRunContext,\n getCredentialContext,\n isIntegrationCallerRequest,\n type RequestContext,\n type RequestRunContext,\n} from \"./request-context.js\";\nexport { formatDateInTimezone, todayInTimezone } from \"./date-utils.js\";\n\nexport {\n createOnboardingPlugin,\n defaultOnboardingPlugin,\n} from \"../onboarding/plugin.js\";\n\nexport {\n registerFileUploadProvider,\n unregisterFileUploadProvider,\n listFileUploadProviders,\n getActiveFileUploadProvider,\n uploadFile,\n builderFileUploadProvider,\n type FileUploadInput,\n type FileUploadProvider,\n type FileUploadResult,\n} from \"../file-upload/index.js\";\n\nexport {\n createIntegrationsPlugin,\n defaultIntegrationsPlugin,\n enqueueRemoteCommand,\n slackAdapter,\n telegramAdapter,\n whatsappAdapter,\n emailAdapter,\n type PlatformAdapter,\n type IncomingMessage,\n type OutgoingMessage,\n type IntegrationStatus,\n type IntegrationsPluginOptions,\n} from \"../integrations/index.js\";\n\nexport {\n isElectron,\n isMobile,\n getOrigin,\n getAppBasePath,\n getAppUrl,\n resolveOAuthRedirectUri,\n isAllowedOAuthRedirectUri,\n encodeOAuthState,\n decodeOAuthState,\n resolveOAuthOwner,\n createOAuthSession,\n oauthCallbackResponse,\n oauthErrorPage,\n oauthDesktopExchangePage,\n type OAuthStatePayload,\n type OAuthOwnerResult,\n type OAuthSessionResult,\n} from \"./google-oauth.js\";\n\nexport {\n FeatureNotConfiguredError,\n hasBuilderPrivateKey,\n isBuilderEnvManaged,\n getBuilderProxyOrigin,\n getBuilderImageGenerationBaseUrl,\n getBuilderAuthHeader,\n resolveBuilderPrivateKey,\n resolveBuilderAuthHeader,\n resolveHasBuilderPrivateKey,\n resolveBuilderCredentials,\n resolveBuilderCredential,\n writeBuilderCredentials,\n deleteBuilderCredentials,\n resolveSecret,\n} from \"./credential-provider.js\";\nexport {\n getBuilderBranchProjectId,\n isBuilderBranchingEnabled,\n resolveBuilderBranchProjectId,\n resolveIsBuilderBranchingEnabled,\n runBuilderAgent,\n type RunBuilderAgentResult,\n} from \"./builder-browser.js\";\n\nexport {\n sendEmail,\n isEmailConfigured,\n getEmailProvider,\n type EmailProvider,\n type SendEmailArgs,\n} from \"./email.js\";\nexport {\n renderEmail,\n emailStrong,\n emailLink,\n type RenderEmailArgs,\n type RenderedEmail,\n type EmailCta,\n} from \"./email-template.js\";\nexport { getAppProductionUrl, getFirstPartyProdUrl } from \"./app-url.js\";\nexport {\n getConfiguredAppBasePath,\n normalizeAppBasePath,\n withConfiguredAppBasePath,\n} from \"./app-base-path.js\";\nexport {\n signShortLivedToken,\n verifyShortLivedToken,\n type ShortLivedTokenClaims,\n type VerifyResult as ShortLivedTokenVerifyResult,\n} from \"./short-lived-token.js\";\n\n// SSR handler is NOT re-exported here — it uses a virtual module\n// (virtual:react-router/server-build) that only exists at Vite dev/build time.\n// Including it in this barrel would break the esbuild CF Pages bundler.\n// Templates import directly: import { ssrHandler } from \"@agent-native/core/server/ssr-handler\"\n\n// Nitro plugin helper — re-exported so templates don't need nitro as a direct dependency.\n// defineNitroPlugin is an identity function; this typed wrapper lets templates use it\n// without resolving `nitro/runtime` (which requires Nitro's virtual modules at runtime).\nexport type NitroPluginDef = (nitroApp: any) => void | Promise<void>;\nexport function defineNitroPlugin(def: NitroPluginDef): NitroPluginDef {\n return def;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"onboarding-html.d.ts","sourceRoot":"","sources":["../../src/server/onboarding-html.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,EAEL,KAAK,cAAc,EACpB,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"onboarding-html.d.ts","sourceRoot":"","sources":["../../src/server/onboarding-html.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,EAEL,KAAK,cAAc,EACpB,MAAM,uBAAuB,CAAC;AAoC/B,MAAM,WAAW,qBAAqB;IACpC;;;;OAIG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;;;OAIG;IACH,SAAS,CAAC,EAAE;QACV,OAAO,EAAE,MAAM,CAAC;QAChB,OAAO,EAAE,MAAM,CAAC;QAChB,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;QACpB,eAAe,CAAC,EAAE,MAAM,CAAC;KAC1B,CAAC;IACF;;;;OAIG;IACH,kBAAkB,CAAC,EAAE;QACnB,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,KAAK,EAAE,MAAM,CAAC;QACd,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;QACxB,aAAa,CAAC,EAAE,MAAM,CAAC;QACvB,WAAW,CAAC,EAAE,MAAM,CAAC;KACtB,CAAC;IACF;;;;OAIG;IACH,cAAc,CAAC,EAAE,cAAc,CAAC;CACjC;AAED,wBAAgB,iBAAiB,CAAC,IAAI,GAAE,qBAA0B,GAAG,MAAM,CA+qD1E;AAED,kDAAkD;AAClD,eAAO,MAAM,eAAe,QAAsB,CAAC;AAEnD;;;;GAIG;AACH,wBAAgB,oBAAoB,IAAI,MAAM,CA0G7C"}
|