@tangle-network/agent-app 0.43.24 → 0.43.26
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/dist/app-auth/index.d.ts +163 -0
- package/dist/app-auth/index.js +166 -0
- package/dist/app-auth/index.js.map +1 -0
- package/dist/assets/index.d.ts +2 -2
- package/dist/assistant/index.d.ts +2 -0
- package/dist/assistant/index.js +3 -1
- package/dist/assistant/index.js.map +1 -1
- package/dist/chat-routes/index.d.ts +276 -0
- package/dist/chat-routes/index.js +564 -0
- package/dist/chat-routes/index.js.map +1 -0
- package/dist/chat-store/index.d.ts +194 -0
- package/dist/chat-store/index.js +198 -0
- package/dist/chat-store/index.js.map +1 -0
- package/dist/chunk-4TXDD6P2.js +163 -0
- package/dist/chunk-4TXDD6P2.js.map +1 -0
- package/dist/chunk-5EQCITY3.js +20 -0
- package/dist/chunk-5EQCITY3.js.map +1 -0
- package/dist/chunk-5SV5PSU7.js +80 -0
- package/dist/chunk-5SV5PSU7.js.map +1 -0
- package/dist/chunk-7LNGJDNA.js +1 -0
- package/dist/chunk-7LNGJDNA.js.map +1 -0
- package/dist/{chunk-77RLNLFP.js → chunk-ATRJULKZ.js} +41 -5
- package/dist/chunk-ATRJULKZ.js.map +1 -0
- package/dist/{chunk-VMY4TKMN.js → chunk-FCQP75JT.js} +936 -436
- package/dist/chunk-FCQP75JT.js.map +1 -0
- package/dist/chunk-I2R2XT4M.js +62 -0
- package/dist/chunk-I2R2XT4M.js.map +1 -0
- package/dist/{chunk-3PK3T4KD.js → chunk-JJGZ54EB.js} +44 -1
- package/dist/chunk-JJGZ54EB.js.map +1 -0
- package/dist/chunk-TKVJE63N.js +304 -0
- package/dist/chunk-TKVJE63N.js.map +1 -0
- package/dist/{chunk-SAOAAA3S.js → chunk-UHXQ3KNX.js} +1 -22
- package/dist/chunk-UHXQ3KNX.js.map +1 -0
- package/dist/chunk-Y4QHNQ75.js +203 -0
- package/dist/chunk-Y4QHNQ75.js.map +1 -0
- package/dist/contract-DYbTzEDf.d.ts +122 -0
- package/dist/core-7qIM7svy.d.ts +21 -0
- package/dist/index.d.ts +6 -2
- package/dist/index.js +179 -92
- package/dist/interactions/index.d.ts +141 -0
- package/dist/interactions/index.js +60 -0
- package/dist/interactions/index.js.map +1 -0
- package/dist/parts-BcbitSNp.d.ts +176 -0
- package/dist/platform/index.d.ts +2 -270
- package/dist/platform/index.js +14 -278
- package/dist/platform/index.js.map +1 -1
- package/dist/preset-cloudflare/index.d.ts +0 -10
- package/dist/preset-cloudflare/index.js +1 -1
- package/dist/profile/index.d.ts +33 -2
- package/dist/profile/index.js +37 -1
- package/dist/profile/index.js.map +1 -1
- package/dist/sandbox/index.d.ts +47 -1
- package/dist/sandbox/index.js +11 -1
- package/dist/sso-CNOsARMJ.d.ts +285 -0
- package/dist/stream/index.js +1 -1
- package/dist/teams/index.js +9 -9
- package/dist/teams/invitations-api.js +3 -3
- package/dist/web-react/index.d.ts +229 -99
- package/dist/web-react/index.js +72 -22
- package/dist/wire-BaUF66AS.d.ts +61 -0
- package/package.json +25 -1
- package/dist/chunk-3PK3T4KD.js.map +0 -1
- package/dist/chunk-77RLNLFP.js.map +0 -1
- package/dist/chunk-SAOAAA3S.js.map +0 -1
- package/dist/chunk-VMY4TKMN.js.map +0 -1
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import { Session, User, Auth, BetterAuthOptions } from 'better-auth';
|
|
2
|
+
import { A as AuthGuard, T as TangleSsoHandlers, a as TangleSsoAuthClient, b as TangleSsoAccountStore } from '../sso-CNOsARMJ.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* better-auth config factory for agent products (#188 Phase 1). Every product
|
|
6
|
+
* hand-rolls the same ~70–150 line setup — drizzle adapter over the standard
|
|
7
|
+
* users/sessions/accounts/verifications tables, email+password with Resend
|
|
8
|
+
* reset/verification mail, env-gated GitHub/Google social providers, session
|
|
9
|
+
* cookie cache, and a per-app cookie prefix — and tax additionally
|
|
10
|
+
* re-implemented better-auth's cookie signing for its Tangle SSO callback.
|
|
11
|
+
* `createAppAuth` owns that mechanism once and returns the configured
|
|
12
|
+
* better-auth instance plus the request guards products actually use.
|
|
13
|
+
*
|
|
14
|
+
* Domain stays a parameter: the drizzle db + schema, email client, provider
|
|
15
|
+
* credentials, and SSO store/client all come from the product. No product
|
|
16
|
+
* import, no engine re-implementation — the SSO path composes the existing
|
|
17
|
+
* `platform/sso` cookie minter (`createBetterAuthSessionCookieMinter`), which
|
|
18
|
+
* is byte-compatible with better-auth's own `makeSignature` contract.
|
|
19
|
+
*
|
|
20
|
+
* better-auth is an OPTIONAL peer: only this subpath imports it, so it is
|
|
21
|
+
* deliberately NOT re-exported from the root barrel.
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
/** Structural slice of a Resend-style client — no `resend` import. */
|
|
25
|
+
interface AppAuthEmailClient {
|
|
26
|
+
emails: {
|
|
27
|
+
send(message: {
|
|
28
|
+
from: string;
|
|
29
|
+
to: string;
|
|
30
|
+
subject: string;
|
|
31
|
+
html: string;
|
|
32
|
+
text?: string;
|
|
33
|
+
}): Promise<unknown>;
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
interface AppAuthEmailConfig {
|
|
37
|
+
/** A Resend-style client, or a lazy getter returning null when the API key
|
|
38
|
+
* is absent (the products' dev default — mail is skipped with a warning,
|
|
39
|
+
* sign-up itself must not crash). */
|
|
40
|
+
resend: AppAuthEmailClient | (() => AppAuthEmailClient | null);
|
|
41
|
+
/** RFC 5322 From, e.g. `'Legal Agent <noreply@legal.tangle.tools>'`. */
|
|
42
|
+
from: string;
|
|
43
|
+
/** Send a verification email on sign-up and auto-sign-in after verifying
|
|
44
|
+
* (the tax/gtm behavior). Default false (the legal behavior). */
|
|
45
|
+
verifyOnSignUp?: boolean;
|
|
46
|
+
/** Receives the "email client unavailable" warning. Default console.warn. */
|
|
47
|
+
warn?: (message: string) => void;
|
|
48
|
+
}
|
|
49
|
+
/** Env-shaped: pass the env vars straight through; the provider is registered
|
|
50
|
+
* only when BOTH values are non-empty, so unset env disables it. */
|
|
51
|
+
interface AppAuthSocialProviderConfig {
|
|
52
|
+
clientId?: string;
|
|
53
|
+
clientSecret?: string;
|
|
54
|
+
}
|
|
55
|
+
interface AppAuthSocialConfig {
|
|
56
|
+
github?: AppAuthSocialProviderConfig;
|
|
57
|
+
google?: AppAuthSocialProviderConfig;
|
|
58
|
+
}
|
|
59
|
+
/** Cross-site Tangle SSO wiring. The factory supplies the better-auth side —
|
|
60
|
+
* `setSessionCookie` via `createBetterAuthSessionCookieMinter(auth)` (signed
|
|
61
|
+
* `__Secure-`/prefixed cookie that `auth.api.getSession` accepts) — so the
|
|
62
|
+
* product no longer touches `better-auth/crypto` itself. */
|
|
63
|
+
interface AppAuthSsoConfig {
|
|
64
|
+
/** Platform wire client (authorizeUrl + exchange). */
|
|
65
|
+
client: TangleSsoAuthClient;
|
|
66
|
+
/** Product persistence: user upsert, session row, platform link. */
|
|
67
|
+
store: TangleSsoAccountStore;
|
|
68
|
+
/** Absolute callback URL registered with the platform. */
|
|
69
|
+
callbackUrl: string;
|
|
70
|
+
/** Default 'tangle_sso_state'. */
|
|
71
|
+
stateCookieName?: string;
|
|
72
|
+
/** HMAC secret for the CSRF state cookie. Default: the auth `secret`. */
|
|
73
|
+
stateSecret?: string;
|
|
74
|
+
/** Default: `baseURL` is https. Must match better-auth's own
|
|
75
|
+
* secure-cookie decision or the cookie name lookup diverges. */
|
|
76
|
+
secureCookies?: boolean;
|
|
77
|
+
sessionTtlSeconds?: number;
|
|
78
|
+
stateTtlSeconds?: number;
|
|
79
|
+
/** Post-login redirect fallback. Default '/app'. */
|
|
80
|
+
defaultRedirectPath?: string;
|
|
81
|
+
/** Default: the top-level `loginPath`. */
|
|
82
|
+
loginPath?: string;
|
|
83
|
+
/** Failure log hook (e.g. console.error). Default no-op. */
|
|
84
|
+
log?: (message: string, error?: unknown) => void;
|
|
85
|
+
}
|
|
86
|
+
interface AppAuthSchema {
|
|
87
|
+
users: unknown;
|
|
88
|
+
sessions: unknown;
|
|
89
|
+
accounts: unknown;
|
|
90
|
+
verifications: unknown;
|
|
91
|
+
}
|
|
92
|
+
interface AppAuthConfig {
|
|
93
|
+
/** Product name — used in email subjects and as the cookie-prefix default. */
|
|
94
|
+
appName: string;
|
|
95
|
+
/** Absolute origin better-auth serves from (`BETTER_AUTH_URL`). */
|
|
96
|
+
baseURL: string;
|
|
97
|
+
/** better-auth HMAC secret. Optional only because better-auth falls back to
|
|
98
|
+
* the BETTER_AUTH_SECRET env var; `sso` needs it explicitly (or
|
|
99
|
+
* `sso.stateSecret`). */
|
|
100
|
+
secret?: string;
|
|
101
|
+
trustedOrigins?: string[];
|
|
102
|
+
/**
|
|
103
|
+
* Session-cookie prefix. Default: slugified `appName`. A per-app prefix is
|
|
104
|
+
* load-bearing, not cosmetic: the platform (id.tangle.tools) mints its own
|
|
105
|
+
* better-auth cookie `Domain=.tangle.tools`-wide under the DEFAULT name, and
|
|
106
|
+
* the platform's (older) cookie wins the Cookie-header order — an app on the
|
|
107
|
+
* default prefix reads the platform's token, fails its own signature check,
|
|
108
|
+
* and every fresh login lands back on /login.
|
|
109
|
+
*/
|
|
110
|
+
cookiePrefix?: string;
|
|
111
|
+
/** Drizzle database instance; wired through better-auth's drizzle adapter
|
|
112
|
+
* together with `schema`. */
|
|
113
|
+
db?: unknown;
|
|
114
|
+
/** The product's users/sessions/accounts/verifications tables (mapped to
|
|
115
|
+
* better-auth's user/session/account/verification models). */
|
|
116
|
+
schema?: AppAuthSchema;
|
|
117
|
+
/** Drizzle dialect. Default 'sqlite' (D1). */
|
|
118
|
+
provider?: 'sqlite' | 'pg' | 'mysql';
|
|
119
|
+
/** Escape hatch: a pre-built better-auth database adapter (e.g.
|
|
120
|
+
* `memoryAdapter` in tests). Wins over `db`/`schema`. */
|
|
121
|
+
database?: BetterAuthOptions['database'];
|
|
122
|
+
/** Email+password sign-in. Default true (all current products enable it). */
|
|
123
|
+
emailAndPassword?: boolean;
|
|
124
|
+
/** Reset/verification mail. Omit to disable password reset entirely. */
|
|
125
|
+
email?: AppAuthEmailConfig;
|
|
126
|
+
social?: AppAuthSocialConfig;
|
|
127
|
+
/** Session cookie-cache TTL in seconds; `false` disables the cache.
|
|
128
|
+
* Default 300. */
|
|
129
|
+
sessionCookieCacheSeconds?: number | false;
|
|
130
|
+
/** Tangle cross-site SSO (start/callback handlers). */
|
|
131
|
+
sso?: AppAuthSsoConfig;
|
|
132
|
+
/** Where guards redirect unauthenticated page requests. Default '/login'. */
|
|
133
|
+
loginPath?: string;
|
|
134
|
+
/** Merged over the factory's `advanced` block (cookiePrefix stays unless
|
|
135
|
+
* overridden here). */
|
|
136
|
+
advanced?: BetterAuthOptions['advanced'];
|
|
137
|
+
}
|
|
138
|
+
/** The configured better-auth instance, typed at better-auth's base surface
|
|
139
|
+
* (`handler`, `api`, `$context`, `$Infer`). */
|
|
140
|
+
type AppAuthInstance = Auth;
|
|
141
|
+
/** What `getSession`/guards resolve: better-auth's base session + user rows. */
|
|
142
|
+
interface AppAuthSession {
|
|
143
|
+
session: Session;
|
|
144
|
+
user: User;
|
|
145
|
+
}
|
|
146
|
+
interface AppAuth extends AuthGuard<AppAuthSession> {
|
|
147
|
+
auth: AppAuthInstance;
|
|
148
|
+
/** `auth.api.getSession` over a `Request` — the seam the guards consume. */
|
|
149
|
+
getSession(request: Request): Promise<AppAuthSession | null>;
|
|
150
|
+
/** Tangle SSO start/callback handlers; null unless `sso` was configured. */
|
|
151
|
+
sso: TangleSsoHandlers | null;
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Build the product's better-auth instance plus the request-boundary helpers:
|
|
155
|
+
* `getSession` (Request → session|null), the `createAuthGuard` quartet
|
|
156
|
+
* (`requireUser` 302, `requireApiUser` JSON 401, `requireSession`,
|
|
157
|
+
* `getOptionalSession`), and — when `sso` is configured — the Tangle SSO
|
|
158
|
+
* start/callback handlers with the session cookie minted through better-auth's
|
|
159
|
+
* own name/attributes/signing (no `better-auth/crypto` in product code).
|
|
160
|
+
*/
|
|
161
|
+
declare function createAppAuth(config: AppAuthConfig): AppAuth;
|
|
162
|
+
|
|
163
|
+
export { type AppAuth, type AppAuthConfig, type AppAuthEmailClient, type AppAuthEmailConfig, type AppAuthInstance, type AppAuthSchema, type AppAuthSession, type AppAuthSocialConfig, type AppAuthSocialProviderConfig, type AppAuthSsoConfig, createAppAuth };
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createAuthGuard,
|
|
3
|
+
createBetterAuthSessionCookieMinter,
|
|
4
|
+
createTangleSsoHandlers
|
|
5
|
+
} from "../chunk-TKVJE63N.js";
|
|
6
|
+
import "../chunk-HFC4BTWJ.js";
|
|
7
|
+
import "../chunk-7W5XSTUF.js";
|
|
8
|
+
|
|
9
|
+
// src/app-auth/index.ts
|
|
10
|
+
import { betterAuth } from "better-auth";
|
|
11
|
+
import { drizzleAdapter } from "better-auth/adapters/drizzle";
|
|
12
|
+
var DEFAULT_STATE_COOKIE = "tangle_sso_state";
|
|
13
|
+
var DEFAULT_SESSION_COOKIE_CACHE_SECONDS = 5 * 60;
|
|
14
|
+
function slugify(name) {
|
|
15
|
+
return name.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
|
|
16
|
+
}
|
|
17
|
+
function resolveEmailClient(email) {
|
|
18
|
+
return typeof email.resend === "function" ? email.resend() : email.resend;
|
|
19
|
+
}
|
|
20
|
+
async function sendEmail(client, message) {
|
|
21
|
+
const result = await client.emails.send(message);
|
|
22
|
+
if (result && typeof result === "object" && result.error) {
|
|
23
|
+
throw new Error(`[app-auth] email send failed: ${result.error.message ?? "unknown error"}`);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
function resolveDatabase(config) {
|
|
27
|
+
if (config.database) return config.database;
|
|
28
|
+
if (config.db && config.schema) {
|
|
29
|
+
return drizzleAdapter(config.db, {
|
|
30
|
+
provider: config.provider ?? "sqlite",
|
|
31
|
+
schema: {
|
|
32
|
+
user: config.schema.users,
|
|
33
|
+
session: config.schema.sessions,
|
|
34
|
+
account: config.schema.accounts,
|
|
35
|
+
verification: config.schema.verifications
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
throw new Error(
|
|
40
|
+
"createAppAuth requires a database: pass `db` + `schema` (drizzle) or `database` (a better-auth adapter)"
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
function resolveSocialProviders(social) {
|
|
44
|
+
const providers = {};
|
|
45
|
+
if (social?.github?.clientId && social.github.clientSecret) {
|
|
46
|
+
providers.github = { clientId: social.github.clientId, clientSecret: social.github.clientSecret };
|
|
47
|
+
}
|
|
48
|
+
if (social?.google?.clientId && social.google.clientSecret) {
|
|
49
|
+
providers.google = { clientId: social.google.clientId, clientSecret: social.google.clientSecret };
|
|
50
|
+
}
|
|
51
|
+
return Object.keys(providers).length > 0 ? providers : void 0;
|
|
52
|
+
}
|
|
53
|
+
function emailAndPasswordOptions(config) {
|
|
54
|
+
const email = config.email;
|
|
55
|
+
if (!email) return { enabled: true };
|
|
56
|
+
const warn = email.warn ?? ((message) => console.warn(message));
|
|
57
|
+
return {
|
|
58
|
+
enabled: true,
|
|
59
|
+
sendResetPassword: async ({ user, url }) => {
|
|
60
|
+
const client = resolveEmailClient(email);
|
|
61
|
+
if (!client) {
|
|
62
|
+
warn("[app-auth] email client unavailable \u2014 password reset email not sent");
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
await sendEmail(client, {
|
|
66
|
+
from: email.from,
|
|
67
|
+
to: user.email,
|
|
68
|
+
subject: "Reset your password",
|
|
69
|
+
html: `<p>Click the link below to reset your password:</p><p><a href="${url}">${url}</a></p><p>This link expires in 1 hour.</p>`,
|
|
70
|
+
text: `Reset your password:
|
|
71
|
+
|
|
72
|
+
${url}
|
|
73
|
+
|
|
74
|
+
This link expires in 1 hour.`
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
function emailVerificationOptions(config) {
|
|
80
|
+
const email = config.email;
|
|
81
|
+
if (!email?.verifyOnSignUp) return void 0;
|
|
82
|
+
const warn = email.warn ?? ((message) => console.warn(message));
|
|
83
|
+
return {
|
|
84
|
+
sendOnSignUp: true,
|
|
85
|
+
autoSignInAfterVerification: true,
|
|
86
|
+
sendVerificationEmail: async ({ user, url }) => {
|
|
87
|
+
const client = resolveEmailClient(email);
|
|
88
|
+
if (!client) {
|
|
89
|
+
warn("[app-auth] email client unavailable \u2014 verification email not sent");
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
await sendEmail(client, {
|
|
93
|
+
from: email.from,
|
|
94
|
+
to: user.email,
|
|
95
|
+
subject: `Verify your ${config.appName} email`,
|
|
96
|
+
html: `<p>Verify your email to finish accessing ${config.appName}:</p><p><a href="${url}">${url}</a></p><p>This link expires in 1 hour.</p>`,
|
|
97
|
+
text: `Verify your email to finish accessing ${config.appName}:
|
|
98
|
+
|
|
99
|
+
${url}
|
|
100
|
+
|
|
101
|
+
This link expires in 1 hour.`
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
function createAppAuth(config) {
|
|
107
|
+
if (!config.appName) throw new Error("createAppAuth: appName is required");
|
|
108
|
+
if (!config.baseURL) throw new Error("createAppAuth: baseURL is required");
|
|
109
|
+
const cookiePrefix = config.cookiePrefix ?? slugify(config.appName);
|
|
110
|
+
if (!cookiePrefix) throw new Error("createAppAuth: cookiePrefix (or a slugifiable appName) is required");
|
|
111
|
+
const socialProviders = resolveSocialProviders(config.social);
|
|
112
|
+
const options = {
|
|
113
|
+
appName: config.appName,
|
|
114
|
+
baseURL: config.baseURL,
|
|
115
|
+
...config.secret ? { secret: config.secret } : {},
|
|
116
|
+
...config.trustedOrigins ? { trustedOrigins: config.trustedOrigins } : {},
|
|
117
|
+
database: resolveDatabase(config),
|
|
118
|
+
...config.emailAndPassword === false ? {} : { emailAndPassword: emailAndPasswordOptions(config) },
|
|
119
|
+
...config.email?.verifyOnSignUp ? { emailVerification: emailVerificationOptions(config) } : {},
|
|
120
|
+
...socialProviders ? { socialProviders } : {},
|
|
121
|
+
...config.sessionCookieCacheSeconds === false ? {} : {
|
|
122
|
+
session: {
|
|
123
|
+
cookieCache: {
|
|
124
|
+
enabled: true,
|
|
125
|
+
maxAge: config.sessionCookieCacheSeconds ?? DEFAULT_SESSION_COOKIE_CACHE_SECONDS
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
},
|
|
129
|
+
advanced: { cookiePrefix, ...config.advanced }
|
|
130
|
+
};
|
|
131
|
+
const auth = betterAuth(options);
|
|
132
|
+
const getSession = async (request) => {
|
|
133
|
+
const session = await auth.api.getSession({ headers: request.headers });
|
|
134
|
+
return session ?? null;
|
|
135
|
+
};
|
|
136
|
+
const loginPath = config.loginPath ?? "/login";
|
|
137
|
+
const guard = createAuthGuard({ getSession, loginPath });
|
|
138
|
+
let sso = null;
|
|
139
|
+
if (config.sso) {
|
|
140
|
+
const stateSecret = config.sso.stateSecret ?? config.secret;
|
|
141
|
+
if (!stateSecret) {
|
|
142
|
+
throw new Error(
|
|
143
|
+
"createAppAuth: sso requires `secret` (or sso.stateSecret) \u2014 the signed-state CSRF cookie needs an HMAC secret"
|
|
144
|
+
);
|
|
145
|
+
}
|
|
146
|
+
sso = createTangleSsoHandlers({
|
|
147
|
+
auth: config.sso.client,
|
|
148
|
+
store: config.sso.store,
|
|
149
|
+
stateSecret,
|
|
150
|
+
callbackUrl: config.sso.callbackUrl,
|
|
151
|
+
stateCookieName: config.sso.stateCookieName ?? DEFAULT_STATE_COOKIE,
|
|
152
|
+
setSessionCookie: createBetterAuthSessionCookieMinter(auth),
|
|
153
|
+
secureCookies: config.sso.secureCookies ?? config.baseURL.startsWith("https:"),
|
|
154
|
+
...config.sso.sessionTtlSeconds !== void 0 ? { sessionTtlSeconds: config.sso.sessionTtlSeconds } : {},
|
|
155
|
+
...config.sso.stateTtlSeconds !== void 0 ? { stateTtlSeconds: config.sso.stateTtlSeconds } : {},
|
|
156
|
+
...config.sso.defaultRedirectPath ? { defaultRedirectPath: config.sso.defaultRedirectPath } : {},
|
|
157
|
+
loginPath: config.sso.loginPath ?? loginPath,
|
|
158
|
+
...config.sso.log ? { log: config.sso.log } : {}
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
return { auth, getSession, ...guard, sso };
|
|
162
|
+
}
|
|
163
|
+
export {
|
|
164
|
+
createAppAuth
|
|
165
|
+
};
|
|
166
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/app-auth/index.ts"],"sourcesContent":["/**\n * better-auth config factory for agent products (#188 Phase 1). Every product\n * hand-rolls the same ~70–150 line setup — drizzle adapter over the standard\n * users/sessions/accounts/verifications tables, email+password with Resend\n * reset/verification mail, env-gated GitHub/Google social providers, session\n * cookie cache, and a per-app cookie prefix — and tax additionally\n * re-implemented better-auth's cookie signing for its Tangle SSO callback.\n * `createAppAuth` owns that mechanism once and returns the configured\n * better-auth instance plus the request guards products actually use.\n *\n * Domain stays a parameter: the drizzle db + schema, email client, provider\n * credentials, and SSO store/client all come from the product. No product\n * import, no engine re-implementation — the SSO path composes the existing\n * `platform/sso` cookie minter (`createBetterAuthSessionCookieMinter`), which\n * is byte-compatible with better-auth's own `makeSignature` contract.\n *\n * better-auth is an OPTIONAL peer: only this subpath imports it, so it is\n * deliberately NOT re-exported from the root barrel.\n */\n\nimport { betterAuth, type Auth, type BetterAuthOptions, type Session, type User } from 'better-auth'\nimport { drizzleAdapter } from 'better-auth/adapters/drizzle'\nimport { createAuthGuard, type AuthGuard } from '../platform/guards'\nimport {\n createBetterAuthSessionCookieMinter,\n createTangleSsoHandlers,\n type TangleSsoAccountStore,\n type TangleSsoAuthClient,\n type TangleSsoHandlers,\n} from '../platform/sso'\n\nconst DEFAULT_STATE_COOKIE = 'tangle_sso_state'\nconst DEFAULT_SESSION_COOKIE_CACHE_SECONDS = 5 * 60\n\n/** Structural slice of a Resend-style client — no `resend` import. */\nexport interface AppAuthEmailClient {\n emails: {\n send(message: {\n from: string\n to: string\n subject: string\n html: string\n text?: string\n }): Promise<unknown>\n }\n}\n\nexport interface AppAuthEmailConfig {\n /** A Resend-style client, or a lazy getter returning null when the API key\n * is absent (the products' dev default — mail is skipped with a warning,\n * sign-up itself must not crash). */\n resend: AppAuthEmailClient | (() => AppAuthEmailClient | null)\n /** RFC 5322 From, e.g. `'Legal Agent <noreply@legal.tangle.tools>'`. */\n from: string\n /** Send a verification email on sign-up and auto-sign-in after verifying\n * (the tax/gtm behavior). Default false (the legal behavior). */\n verifyOnSignUp?: boolean\n /** Receives the \"email client unavailable\" warning. Default console.warn. */\n warn?: (message: string) => void\n}\n\n/** Env-shaped: pass the env vars straight through; the provider is registered\n * only when BOTH values are non-empty, so unset env disables it. */\nexport interface AppAuthSocialProviderConfig {\n clientId?: string\n clientSecret?: string\n}\n\nexport interface AppAuthSocialConfig {\n github?: AppAuthSocialProviderConfig\n google?: AppAuthSocialProviderConfig\n}\n\n/** Cross-site Tangle SSO wiring. The factory supplies the better-auth side —\n * `setSessionCookie` via `createBetterAuthSessionCookieMinter(auth)` (signed\n * `__Secure-`/prefixed cookie that `auth.api.getSession` accepts) — so the\n * product no longer touches `better-auth/crypto` itself. */\nexport interface AppAuthSsoConfig {\n /** Platform wire client (authorizeUrl + exchange). */\n client: TangleSsoAuthClient\n /** Product persistence: user upsert, session row, platform link. */\n store: TangleSsoAccountStore\n /** Absolute callback URL registered with the platform. */\n callbackUrl: string\n /** Default 'tangle_sso_state'. */\n stateCookieName?: string\n /** HMAC secret for the CSRF state cookie. Default: the auth `secret`. */\n stateSecret?: string\n /** Default: `baseURL` is https. Must match better-auth's own\n * secure-cookie decision or the cookie name lookup diverges. */\n secureCookies?: boolean\n sessionTtlSeconds?: number\n stateTtlSeconds?: number\n /** Post-login redirect fallback. Default '/app'. */\n defaultRedirectPath?: string\n /** Default: the top-level `loginPath`. */\n loginPath?: string\n /** Failure log hook (e.g. console.error). Default no-op. */\n log?: (message: string, error?: unknown) => void\n}\n\nexport interface AppAuthSchema {\n users: unknown\n sessions: unknown\n accounts: unknown\n verifications: unknown\n}\n\nexport interface AppAuthConfig {\n /** Product name — used in email subjects and as the cookie-prefix default. */\n appName: string\n /** Absolute origin better-auth serves from (`BETTER_AUTH_URL`). */\n baseURL: string\n /** better-auth HMAC secret. Optional only because better-auth falls back to\n * the BETTER_AUTH_SECRET env var; `sso` needs it explicitly (or\n * `sso.stateSecret`). */\n secret?: string\n trustedOrigins?: string[]\n /**\n * Session-cookie prefix. Default: slugified `appName`. A per-app prefix is\n * load-bearing, not cosmetic: the platform (id.tangle.tools) mints its own\n * better-auth cookie `Domain=.tangle.tools`-wide under the DEFAULT name, and\n * the platform's (older) cookie wins the Cookie-header order — an app on the\n * default prefix reads the platform's token, fails its own signature check,\n * and every fresh login lands back on /login.\n */\n cookiePrefix?: string\n /** Drizzle database instance; wired through better-auth's drizzle adapter\n * together with `schema`. */\n db?: unknown\n /** The product's users/sessions/accounts/verifications tables (mapped to\n * better-auth's user/session/account/verification models). */\n schema?: AppAuthSchema\n /** Drizzle dialect. Default 'sqlite' (D1). */\n provider?: 'sqlite' | 'pg' | 'mysql'\n /** Escape hatch: a pre-built better-auth database adapter (e.g.\n * `memoryAdapter` in tests). Wins over `db`/`schema`. */\n database?: BetterAuthOptions['database']\n /** Email+password sign-in. Default true (all current products enable it). */\n emailAndPassword?: boolean\n /** Reset/verification mail. Omit to disable password reset entirely. */\n email?: AppAuthEmailConfig\n social?: AppAuthSocialConfig\n /** Session cookie-cache TTL in seconds; `false` disables the cache.\n * Default 300. */\n sessionCookieCacheSeconds?: number | false\n /** Tangle cross-site SSO (start/callback handlers). */\n sso?: AppAuthSsoConfig\n /** Where guards redirect unauthenticated page requests. Default '/login'. */\n loginPath?: string\n /** Merged over the factory's `advanced` block (cookiePrefix stays unless\n * overridden here). */\n advanced?: BetterAuthOptions['advanced']\n}\n\n/** The configured better-auth instance, typed at better-auth's base surface\n * (`handler`, `api`, `$context`, `$Infer`). */\nexport type AppAuthInstance = Auth\n\n/** What `getSession`/guards resolve: better-auth's base session + user rows. */\nexport interface AppAuthSession {\n session: Session\n user: User\n}\n\nexport interface AppAuth extends AuthGuard<AppAuthSession> {\n auth: AppAuthInstance\n /** `auth.api.getSession` over a `Request` — the seam the guards consume. */\n getSession(request: Request): Promise<AppAuthSession | null>\n /** Tangle SSO start/callback handlers; null unless `sso` was configured. */\n sso: TangleSsoHandlers | null\n}\n\n/** Lowercased, non-alphanumerics collapsed to '-': `'Legal Agent'` → `'legal-agent'`. */\nfunction slugify(name: string): string {\n return name\n .toLowerCase()\n .replace(/[^a-z0-9]+/g, '-')\n .replace(/^-+|-+$/g, '')\n}\n\nfunction resolveEmailClient(email: AppAuthEmailConfig): AppAuthEmailClient | null {\n return typeof email.resend === 'function' ? email.resend() : email.resend\n}\n\n/** Resend reports failures in the resolved value, not by rejecting — surface\n * them loud so better-auth's flow (and the caller's logs) see the failure. */\nasync function sendEmail(\n client: AppAuthEmailClient,\n message: { from: string; to: string; subject: string; html: string; text: string },\n): Promise<void> {\n const result = (await client.emails.send(message)) as { error?: { message?: string } | null } | null | undefined\n if (result && typeof result === 'object' && result.error) {\n throw new Error(`[app-auth] email send failed: ${result.error.message ?? 'unknown error'}`)\n }\n}\n\nfunction resolveDatabase(config: AppAuthConfig): NonNullable<BetterAuthOptions['database']> {\n if (config.database) return config.database\n if (config.db && config.schema) {\n return drizzleAdapter(config.db as Record<string, unknown>, {\n provider: config.provider ?? 'sqlite',\n schema: {\n user: config.schema.users,\n session: config.schema.sessions,\n account: config.schema.accounts,\n verification: config.schema.verifications,\n } as Record<string, unknown>,\n })\n }\n throw new Error(\n 'createAppAuth requires a database: pass `db` + `schema` (drizzle) or `database` (a better-auth adapter)',\n )\n}\n\nfunction resolveSocialProviders(social: AppAuthSocialConfig | undefined): BetterAuthOptions['socialProviders'] {\n const providers: NonNullable<BetterAuthOptions['socialProviders']> = {}\n if (social?.github?.clientId && social.github.clientSecret) {\n providers.github = { clientId: social.github.clientId, clientSecret: social.github.clientSecret }\n }\n if (social?.google?.clientId && social.google.clientSecret) {\n providers.google = { clientId: social.google.clientId, clientSecret: social.google.clientSecret }\n }\n return Object.keys(providers).length > 0 ? providers : undefined\n}\n\nfunction emailAndPasswordOptions(config: AppAuthConfig): BetterAuthOptions['emailAndPassword'] {\n const email = config.email\n if (!email) return { enabled: true }\n const warn = email.warn ?? ((message: string) => console.warn(message))\n return {\n enabled: true,\n sendResetPassword: async ({ user, url }) => {\n const client = resolveEmailClient(email)\n if (!client) {\n warn('[app-auth] email client unavailable — password reset email not sent')\n return\n }\n await sendEmail(client, {\n from: email.from,\n to: user.email,\n subject: 'Reset your password',\n html: `<p>Click the link below to reset your password:</p><p><a href=\"${url}\">${url}</a></p><p>This link expires in 1 hour.</p>`,\n text: `Reset your password:\\n\\n${url}\\n\\nThis link expires in 1 hour.`,\n })\n },\n }\n}\n\nfunction emailVerificationOptions(config: AppAuthConfig): BetterAuthOptions['emailVerification'] {\n const email = config.email\n if (!email?.verifyOnSignUp) return undefined\n const warn = email.warn ?? ((message: string) => console.warn(message))\n return {\n sendOnSignUp: true,\n autoSignInAfterVerification: true,\n sendVerificationEmail: async ({ user, url }) => {\n const client = resolveEmailClient(email)\n if (!client) {\n warn('[app-auth] email client unavailable — verification email not sent')\n return\n }\n await sendEmail(client, {\n from: email.from,\n to: user.email,\n subject: `Verify your ${config.appName} email`,\n html: `<p>Verify your email to finish accessing ${config.appName}:</p><p><a href=\"${url}\">${url}</a></p><p>This link expires in 1 hour.</p>`,\n text: `Verify your email to finish accessing ${config.appName}:\\n\\n${url}\\n\\nThis link expires in 1 hour.`,\n })\n },\n }\n}\n\n/**\n * Build the product's better-auth instance plus the request-boundary helpers:\n * `getSession` (Request → session|null), the `createAuthGuard` quartet\n * (`requireUser` 302, `requireApiUser` JSON 401, `requireSession`,\n * `getOptionalSession`), and — when `sso` is configured — the Tangle SSO\n * start/callback handlers with the session cookie minted through better-auth's\n * own name/attributes/signing (no `better-auth/crypto` in product code).\n */\nexport function createAppAuth(config: AppAuthConfig): AppAuth {\n if (!config.appName) throw new Error('createAppAuth: appName is required')\n if (!config.baseURL) throw new Error('createAppAuth: baseURL is required')\n\n const cookiePrefix = config.cookiePrefix ?? slugify(config.appName)\n if (!cookiePrefix) throw new Error('createAppAuth: cookiePrefix (or a slugifiable appName) is required')\n\n const socialProviders = resolveSocialProviders(config.social)\n const options: BetterAuthOptions = {\n appName: config.appName,\n baseURL: config.baseURL,\n ...(config.secret ? { secret: config.secret } : {}),\n ...(config.trustedOrigins ? { trustedOrigins: config.trustedOrigins } : {}),\n database: resolveDatabase(config),\n ...(config.emailAndPassword === false ? {} : { emailAndPassword: emailAndPasswordOptions(config) }),\n ...(config.email?.verifyOnSignUp ? { emailVerification: emailVerificationOptions(config) } : {}),\n ...(socialProviders ? { socialProviders } : {}),\n ...(config.sessionCookieCacheSeconds === false\n ? {}\n : {\n session: {\n cookieCache: {\n enabled: true,\n maxAge: config.sessionCookieCacheSeconds ?? DEFAULT_SESSION_COOKIE_CACHE_SECONDS,\n },\n },\n }),\n advanced: { cookiePrefix, ...config.advanced },\n }\n\n const auth: AppAuthInstance = betterAuth(options)\n\n const getSession = async (request: Request): Promise<AppAuthSession | null> => {\n const session = await auth.api.getSession({ headers: request.headers })\n return (session as AppAuthSession | null) ?? null\n }\n\n const loginPath = config.loginPath ?? '/login'\n const guard = createAuthGuard<AppAuthSession>({ getSession, loginPath })\n\n let sso: TangleSsoHandlers | null = null\n if (config.sso) {\n const stateSecret = config.sso.stateSecret ?? config.secret\n if (!stateSecret) {\n throw new Error(\n 'createAppAuth: sso requires `secret` (or sso.stateSecret) — the signed-state CSRF cookie needs an HMAC secret',\n )\n }\n sso = createTangleSsoHandlers({\n auth: config.sso.client,\n store: config.sso.store,\n stateSecret,\n callbackUrl: config.sso.callbackUrl,\n stateCookieName: config.sso.stateCookieName ?? DEFAULT_STATE_COOKIE,\n setSessionCookie: createBetterAuthSessionCookieMinter(auth),\n secureCookies: config.sso.secureCookies ?? config.baseURL.startsWith('https:'),\n ...(config.sso.sessionTtlSeconds !== undefined ? { sessionTtlSeconds: config.sso.sessionTtlSeconds } : {}),\n ...(config.sso.stateTtlSeconds !== undefined ? { stateTtlSeconds: config.sso.stateTtlSeconds } : {}),\n ...(config.sso.defaultRedirectPath ? { defaultRedirectPath: config.sso.defaultRedirectPath } : {}),\n loginPath: config.sso.loginPath ?? loginPath,\n ...(config.sso.log ? { log: config.sso.log } : {}),\n })\n }\n\n return { auth, getSession, ...guard, sso }\n}\n"],"mappings":";;;;;;;;;AAoBA,SAAS,kBAA8E;AACvF,SAAS,sBAAsB;AAU/B,IAAM,uBAAuB;AAC7B,IAAM,uCAAuC,IAAI;AA8IjD,SAAS,QAAQ,MAAsB;AACrC,SAAO,KACJ,YAAY,EACZ,QAAQ,eAAe,GAAG,EAC1B,QAAQ,YAAY,EAAE;AAC3B;AAEA,SAAS,mBAAmB,OAAsD;AAChF,SAAO,OAAO,MAAM,WAAW,aAAa,MAAM,OAAO,IAAI,MAAM;AACrE;AAIA,eAAe,UACb,QACA,SACe;AACf,QAAM,SAAU,MAAM,OAAO,OAAO,KAAK,OAAO;AAChD,MAAI,UAAU,OAAO,WAAW,YAAY,OAAO,OAAO;AACxD,UAAM,IAAI,MAAM,iCAAiC,OAAO,MAAM,WAAW,eAAe,EAAE;AAAA,EAC5F;AACF;AAEA,SAAS,gBAAgB,QAAmE;AAC1F,MAAI,OAAO,SAAU,QAAO,OAAO;AACnC,MAAI,OAAO,MAAM,OAAO,QAAQ;AAC9B,WAAO,eAAe,OAAO,IAA+B;AAAA,MAC1D,UAAU,OAAO,YAAY;AAAA,MAC7B,QAAQ;AAAA,QACN,MAAM,OAAO,OAAO;AAAA,QACpB,SAAS,OAAO,OAAO;AAAA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I,aAAa;AAAA,MACnC,GAAI,OAAO,IAAI,MAAM,EAAE,KAAK,OAAO,IAAI,IAAI,IAAI,CAAC;AAAA,IAClD,CAAC;AAAA,EACH;AAEA,SAAO,EAAE,MAAM,YAAY,GAAG,OAAO,IAAI;AAC3C;","names":[]}
|
package/dist/assets/index.d.ts
CHANGED
|
@@ -276,8 +276,8 @@ declare const ImageContentSchema: z.ZodObject<{
|
|
|
276
276
|
width: z.ZodOptional<z.ZodNumber>;
|
|
277
277
|
align: z.ZodOptional<z.ZodEnum<{
|
|
278
278
|
left: "left";
|
|
279
|
-
center: "center";
|
|
280
279
|
right: "right";
|
|
280
|
+
center: "center";
|
|
281
281
|
}>>;
|
|
282
282
|
}, z.core.$strip>, z.ZodObject<{
|
|
283
283
|
type: z.ZodLiteral<"image">;
|
|
@@ -371,8 +371,8 @@ declare const VideoContentSchema: z.ZodObject<{
|
|
|
371
371
|
width: z.ZodOptional<z.ZodNumber>;
|
|
372
372
|
align: z.ZodOptional<z.ZodEnum<{
|
|
373
373
|
left: "left";
|
|
374
|
-
center: "center";
|
|
375
374
|
right: "right";
|
|
375
|
+
center: "center";
|
|
376
376
|
}>>;
|
|
377
377
|
}, z.core.$strip>, z.ZodObject<{
|
|
378
378
|
type: z.ZodLiteral<"image">;
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
2
|
import { ReactNode } from 'react';
|
|
3
3
|
import { ToolDetailRenderers, ChatUiMessage } from '../web-react/index.js';
|
|
4
|
+
import '../contract-DYbTzEDf.js';
|
|
4
5
|
import '@tangle-network/agent-interface';
|
|
5
6
|
import '../agent-activity-C8ZG0F0M.js';
|
|
6
7
|
import '../flow-types-Cb_AblZs.js';
|
|
7
8
|
import '../sandbox-terminal-BIIC__CP.js';
|
|
8
9
|
import '../catalog/index.js';
|
|
9
10
|
import '../harness/index.js';
|
|
11
|
+
import '../wire-BaUF66AS.js';
|
|
10
12
|
|
|
11
13
|
/**
|
|
12
14
|
* Wire + UI types for the in-app assistant panel. The wire shapes mirror the
|
package/dist/assistant/index.js
CHANGED
|
@@ -3,9 +3,11 @@ import {
|
|
|
3
3
|
ChatMessages,
|
|
4
4
|
ModelPicker,
|
|
5
5
|
ProviderLogo
|
|
6
|
-
} from "../chunk-
|
|
6
|
+
} from "../chunk-FCQP75JT.js";
|
|
7
7
|
import "../chunk-65P3HJY3.js";
|
|
8
|
+
import "../chunk-5SV5PSU7.js";
|
|
8
9
|
import "../chunk-2QI7XV2T.js";
|
|
10
|
+
import "../chunk-4TXDD6P2.js";
|
|
9
11
|
import "../chunk-E7QYOOON.js";
|
|
10
12
|
|
|
11
13
|
// src/assistant/sse.ts
|