@lovable.dev/cloud-auth-js 1.1.3-dev.16 → 1.1.3-rc.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 +4 -47
- package/dist/index.cjs +5 -427
- package/dist/index.d.cts +1 -51
- package/dist/index.d.ts +1 -51
- package/dist/index.js +4 -425
- package/package.json +16 -21
- package/dist/server.cjs +0 -349
- package/dist/server.d.cts +0 -38
- package/dist/server.d.ts +0 -38
- package/dist/server.js +0 -322
package/dist/server.cjs
DELETED
|
@@ -1,349 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
|
|
20
|
-
// src/server.ts
|
|
21
|
-
var server_exports = {};
|
|
22
|
-
__export(server_exports, {
|
|
23
|
-
createAuthRouteHandler: () => createAuthRouteHandler,
|
|
24
|
-
newAuthServer: () => newAuthServer,
|
|
25
|
-
registerAuthRoutes: () => registerAuthRoutes
|
|
26
|
-
});
|
|
27
|
-
module.exports = __toCommonJS(server_exports);
|
|
28
|
-
var import_better_auth = require("better-auth");
|
|
29
|
-
var import_memory = require("better-auth/adapters/memory");
|
|
30
|
-
var import_plugins = require("better-auth/plugins");
|
|
31
|
-
var import_jose = require("jose");
|
|
32
|
-
var DEFAULT_PROVIDER_ID = "lovable";
|
|
33
|
-
var DEFAULT_SCOPES = ["openid", "offline", "email", "profile"];
|
|
34
|
-
var POPUP_MESSAGE_TYPE = "lovable:better-auth-popup-complete";
|
|
35
|
-
var POPUP_START_SUFFIX = "/lovable-popup/start";
|
|
36
|
-
var POPUP_COMPLETE_SUFFIX = "/lovable-popup/complete";
|
|
37
|
-
var globalForDb = globalThis;
|
|
38
|
-
function getMemoryDb() {
|
|
39
|
-
globalForDb.__lovableCloudAuthMemoryDb ?? (globalForDb.__lovableCloudAuthMemoryDb = {
|
|
40
|
-
user: [],
|
|
41
|
-
session: [],
|
|
42
|
-
account: [],
|
|
43
|
-
verification: []
|
|
44
|
-
});
|
|
45
|
-
return globalForDb.__lovableCloudAuthMemoryDb;
|
|
46
|
-
}
|
|
47
|
-
function getEnv() {
|
|
48
|
-
if (typeof process === "undefined")
|
|
49
|
-
return {};
|
|
50
|
-
return process.env;
|
|
51
|
-
}
|
|
52
|
-
function parseList(value) {
|
|
53
|
-
const entries = value?.split(",").map((entry) => entry.trim()).filter(Boolean);
|
|
54
|
-
return entries && entries.length > 0 ? entries : void 0;
|
|
55
|
-
}
|
|
56
|
-
function required(name, value) {
|
|
57
|
-
if (value)
|
|
58
|
-
return value;
|
|
59
|
-
throw new Error(`Missing required env var: ${name}`);
|
|
60
|
-
}
|
|
61
|
-
function resolveTrustedOrigins(options) {
|
|
62
|
-
const env = options.env ?? getEnv();
|
|
63
|
-
return options.trustedOrigins ?? parseList(env.LOVABLE_AUTH_TRUSTED_ORIGINS) ?? [];
|
|
64
|
-
}
|
|
65
|
-
function originToHost(origin) {
|
|
66
|
-
try {
|
|
67
|
-
return new URL(origin).host;
|
|
68
|
-
} catch {
|
|
69
|
-
return void 0;
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
function resolveAuthBaseURL(authBaseURL, fallbackBaseURL, trustedOrigins) {
|
|
73
|
-
if (authBaseURL !== void 0)
|
|
74
|
-
return authBaseURL;
|
|
75
|
-
const allowedHosts = trustedOrigins.map(originToHost).filter((host) => Boolean(host));
|
|
76
|
-
if (allowedHosts.length === 0)
|
|
77
|
-
return fallbackBaseURL;
|
|
78
|
-
return {
|
|
79
|
-
allowedHosts,
|
|
80
|
-
...fallbackBaseURL ? { fallback: fallbackBaseURL } : {}
|
|
81
|
-
};
|
|
82
|
-
}
|
|
83
|
-
function isDynamicAuthBaseURL(baseURL) {
|
|
84
|
-
return typeof baseURL === "object" && baseURL !== null && "allowedHosts" in baseURL;
|
|
85
|
-
}
|
|
86
|
-
function resolveDefaultCookieAttributes(isIframe, configured) {
|
|
87
|
-
return {
|
|
88
|
-
sameSite: isIframe ? "none" : "lax",
|
|
89
|
-
secure: true,
|
|
90
|
-
...configured
|
|
91
|
-
};
|
|
92
|
-
}
|
|
93
|
-
function getIdToken(tokens) {
|
|
94
|
-
if (!tokens || typeof tokens !== "object")
|
|
95
|
-
return void 0;
|
|
96
|
-
const fields = tokens;
|
|
97
|
-
if (typeof fields.idToken === "string")
|
|
98
|
-
return fields.idToken;
|
|
99
|
-
if (typeof fields.id_token === "string")
|
|
100
|
-
return fields.id_token;
|
|
101
|
-
if (typeof fields.raw?.id_token === "string")
|
|
102
|
-
return fields.raw.id_token;
|
|
103
|
-
return void 0;
|
|
104
|
-
}
|
|
105
|
-
async function fetchOpenIdConfiguration(discoveryUrl) {
|
|
106
|
-
const response = await fetch(discoveryUrl);
|
|
107
|
-
if (!response.ok)
|
|
108
|
-
throw new Error(`Failed to fetch OAuth discovery document: ${response.status}`);
|
|
109
|
-
const json = await response.json();
|
|
110
|
-
if (typeof json.issuer !== "string" || typeof json.jwks_uri !== "string") {
|
|
111
|
-
throw new Error("Invalid OAuth discovery document");
|
|
112
|
-
}
|
|
113
|
-
return { issuer: json.issuer, jwksUri: json.jwks_uri };
|
|
114
|
-
}
|
|
115
|
-
function getStringClaim(payload, name) {
|
|
116
|
-
const value = payload[name];
|
|
117
|
-
return typeof value === "string" ? value : void 0;
|
|
118
|
-
}
|
|
119
|
-
function getBooleanClaim(payload, name) {
|
|
120
|
-
const value = payload[name];
|
|
121
|
-
return typeof value === "boolean" ? value : void 0;
|
|
122
|
-
}
|
|
123
|
-
function toVerifiedIdTokenClaims(payload) {
|
|
124
|
-
const sub = getStringClaim(payload, "sub");
|
|
125
|
-
if (!sub)
|
|
126
|
-
throw new Error("Invalid id_token subject");
|
|
127
|
-
return {
|
|
128
|
-
sub,
|
|
129
|
-
email: getStringClaim(payload, "email"),
|
|
130
|
-
email_verified: getBooleanClaim(payload, "email_verified"),
|
|
131
|
-
name: getStringClaim(payload, "name"),
|
|
132
|
-
picture: getStringClaim(payload, "picture")
|
|
133
|
-
};
|
|
134
|
-
}
|
|
135
|
-
function createIdTokenVerifier(discoveryUrl, clientId) {
|
|
136
|
-
let discoveryPromise;
|
|
137
|
-
let jwks;
|
|
138
|
-
return async (idToken) => {
|
|
139
|
-
discoveryPromise ?? (discoveryPromise = fetchOpenIdConfiguration(discoveryUrl));
|
|
140
|
-
const discovery = await discoveryPromise;
|
|
141
|
-
jwks ?? (jwks = (0, import_jose.createRemoteJWKSet)(new URL(discovery.jwksUri)));
|
|
142
|
-
const { payload } = await (0, import_jose.jwtVerify)(idToken, jwks, {
|
|
143
|
-
issuer: discovery.issuer,
|
|
144
|
-
audience: clientId,
|
|
145
|
-
requiredClaims: ["sub"]
|
|
146
|
-
});
|
|
147
|
-
return toVerifiedIdTokenClaims(payload);
|
|
148
|
-
};
|
|
149
|
-
}
|
|
150
|
-
function newAuthServer(options = {}) {
|
|
151
|
-
const env = options.env ?? getEnv();
|
|
152
|
-
const tenantId = required("LOVABLE_TENANT_ID", options.tenantId ?? env.LOVABLE_TENANT_ID);
|
|
153
|
-
const clientId = required("LOVABLE_OAUTH_CLIENT_ID", options.clientId ?? env.LOVABLE_OAUTH_CLIENT_ID);
|
|
154
|
-
const clientSecret = required("LOVABLE_OAUTH_CLIENT_SECRET", options.clientSecret ?? env.LOVABLE_OAUTH_CLIENT_SECRET);
|
|
155
|
-
const oauthUpstream = options.oauthUpstream ?? `https://${tenantId}.auth.lovable.app`;
|
|
156
|
-
const trustedOrigins = resolveTrustedOrigins({ env, trustedOrigins: options.trustedOrigins });
|
|
157
|
-
const fallbackBaseURL = options.fallbackBaseURL ?? trustedOrigins[0];
|
|
158
|
-
const authOptions = options.authOptions ?? {};
|
|
159
|
-
const discoveryUrl = `${oauthUpstream}/.well-known/openid-configuration`;
|
|
160
|
-
const verifyIdToken = createIdTokenVerifier(discoveryUrl, clientId);
|
|
161
|
-
const baseURL = resolveAuthBaseURL(authOptions.baseURL, fallbackBaseURL, trustedOrigins);
|
|
162
|
-
const trustedProxyHeaders = authOptions.advanced?.trustedProxyHeaders ?? isDynamicAuthBaseURL(baseURL);
|
|
163
|
-
const defaultCookieAttributes = resolveDefaultCookieAttributes(
|
|
164
|
-
options.isIframe,
|
|
165
|
-
authOptions.advanced?.defaultCookieAttributes
|
|
166
|
-
);
|
|
167
|
-
return (0, import_better_auth.betterAuth)({
|
|
168
|
-
...authOptions,
|
|
169
|
-
...baseURL ? { baseURL } : {},
|
|
170
|
-
trustedOrigins: authOptions.trustedOrigins ?? trustedOrigins,
|
|
171
|
-
advanced: {
|
|
172
|
-
...authOptions.advanced,
|
|
173
|
-
defaultCookieAttributes,
|
|
174
|
-
trustedProxyHeaders
|
|
175
|
-
},
|
|
176
|
-
secret: authOptions.secret ?? env.LOVABLE_AUTH_SECRET ?? "dev-only-better-auth-secret",
|
|
177
|
-
database: authOptions.database ?? (0, import_memory.memoryAdapter)(getMemoryDb()),
|
|
178
|
-
session: authOptions.session ?? {
|
|
179
|
-
cookieCache: { enabled: true, maxAge: 60 * 5 }
|
|
180
|
-
},
|
|
181
|
-
plugins: [
|
|
182
|
-
(0, import_plugins.genericOAuth)({
|
|
183
|
-
config: [
|
|
184
|
-
{
|
|
185
|
-
providerId: options.providerId ?? DEFAULT_PROVIDER_ID,
|
|
186
|
-
clientId,
|
|
187
|
-
clientSecret,
|
|
188
|
-
discoveryUrl,
|
|
189
|
-
scopes: options.scopes ?? DEFAULT_SCOPES,
|
|
190
|
-
pkce: true,
|
|
191
|
-
responseType: "code",
|
|
192
|
-
authentication: "basic",
|
|
193
|
-
getUserInfo: async (tokens) => {
|
|
194
|
-
const idToken = getIdToken(tokens);
|
|
195
|
-
if (!idToken)
|
|
196
|
-
throw new Error("No id_token returned from Lovable");
|
|
197
|
-
const claims = await verifyIdToken(idToken);
|
|
198
|
-
return {
|
|
199
|
-
id: claims.sub,
|
|
200
|
-
email: claims.email ?? `${claims.sub}@users.lovable.app`,
|
|
201
|
-
emailVerified: claims.email_verified ?? false,
|
|
202
|
-
name: claims.name ?? claims.email ?? claims.sub,
|
|
203
|
-
image: claims.picture,
|
|
204
|
-
createdAt: /* @__PURE__ */ new Date(),
|
|
205
|
-
updatedAt: /* @__PURE__ */ new Date()
|
|
206
|
-
};
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
]
|
|
210
|
-
}),
|
|
211
|
-
...authOptions.plugins ?? []
|
|
212
|
-
]
|
|
213
|
-
});
|
|
214
|
-
}
|
|
215
|
-
function isLovablePopupStartRequest(request) {
|
|
216
|
-
if (request.method !== "GET")
|
|
217
|
-
return false;
|
|
218
|
-
return new URL(request.url).pathname.endsWith(POPUP_START_SUFFIX);
|
|
219
|
-
}
|
|
220
|
-
function isLovablePopupCompleteRequest(request) {
|
|
221
|
-
if (request.method !== "GET")
|
|
222
|
-
return false;
|
|
223
|
-
return new URL(request.url).pathname.endsWith(POPUP_COMPLETE_SUFFIX);
|
|
224
|
-
}
|
|
225
|
-
function popupStartAuthBasePath(pathname) {
|
|
226
|
-
return pathname.slice(0, -POPUP_START_SUFFIX.length) || "/api/auth";
|
|
227
|
-
}
|
|
228
|
-
function popupStartBooleanParam(value) {
|
|
229
|
-
if (value === null)
|
|
230
|
-
return void 0;
|
|
231
|
-
return value === "true";
|
|
232
|
-
}
|
|
233
|
-
function popupStartSignInBody(url) {
|
|
234
|
-
const scopes = url.searchParams.getAll("scope");
|
|
235
|
-
return {
|
|
236
|
-
providerId: url.searchParams.get("providerId") || DEFAULT_PROVIDER_ID,
|
|
237
|
-
callbackURL: url.searchParams.get("callbackURL") || void 0,
|
|
238
|
-
errorCallbackURL: url.searchParams.get("errorCallbackURL") || void 0,
|
|
239
|
-
newUserCallbackURL: url.searchParams.get("newUserCallbackURL") || void 0,
|
|
240
|
-
scopes: scopes.length > 0 ? scopes : void 0,
|
|
241
|
-
requestSignUp: popupStartBooleanParam(url.searchParams.get("requestSignUp")),
|
|
242
|
-
disableRedirect: true
|
|
243
|
-
};
|
|
244
|
-
}
|
|
245
|
-
function getSetCookieHeaders(headers) {
|
|
246
|
-
const getSetCookie = headers.getSetCookie;
|
|
247
|
-
if (getSetCookie)
|
|
248
|
-
return getSetCookie.call(headers);
|
|
249
|
-
const setCookie = headers.get("set-cookie");
|
|
250
|
-
return setCookie ? [setCookie] : [];
|
|
251
|
-
}
|
|
252
|
-
function getOAuthRedirectUrl(data) {
|
|
253
|
-
if (typeof data.url === "string")
|
|
254
|
-
return data.url;
|
|
255
|
-
if (typeof data.redirectURL === "string")
|
|
256
|
-
return data.redirectURL;
|
|
257
|
-
if (typeof data.redirectUrl === "string")
|
|
258
|
-
return data.redirectUrl;
|
|
259
|
-
return void 0;
|
|
260
|
-
}
|
|
261
|
-
function scriptJson(value) {
|
|
262
|
-
return JSON.stringify(value).replace(/</g, "\\u003c");
|
|
263
|
-
}
|
|
264
|
-
function handleLovablePopupComplete(request) {
|
|
265
|
-
const url = new URL(request.url);
|
|
266
|
-
const error = url.searchParams.get("error_description") || url.searchParams.get("error") || void 0;
|
|
267
|
-
const message = {
|
|
268
|
-
type: POPUP_MESSAGE_TYPE,
|
|
269
|
-
popupId: url.searchParams.get("popupId") || "",
|
|
270
|
-
...error ? { error } : {},
|
|
271
|
-
...url.searchParams.get("returnTo") ? { returnTo: url.searchParams.get("returnTo") } : {}
|
|
272
|
-
};
|
|
273
|
-
const html = `<!doctype html>
|
|
274
|
-
<html>
|
|
275
|
-
<head><meta charset="utf-8"><title>Authentication complete</title></head>
|
|
276
|
-
<body>
|
|
277
|
-
<script>
|
|
278
|
-
(() => {
|
|
279
|
-
const message = ${scriptJson(message)};
|
|
280
|
-
const targetOrigin = ${scriptJson(url.origin)};
|
|
281
|
-
if (window.opener && message.popupId) window.opener.postMessage(message, targetOrigin);
|
|
282
|
-
window.close();
|
|
283
|
-
setTimeout(() => {
|
|
284
|
-
if (!window.closed && message.returnTo) window.location.replace(message.returnTo);
|
|
285
|
-
}, 250);
|
|
286
|
-
})();
|
|
287
|
-
</script>
|
|
288
|
-
</body>
|
|
289
|
-
</html>`;
|
|
290
|
-
return new Response(html, {
|
|
291
|
-
headers: {
|
|
292
|
-
"content-type": "text/html; charset=utf-8",
|
|
293
|
-
"cache-control": "no-store"
|
|
294
|
-
}
|
|
295
|
-
});
|
|
296
|
-
}
|
|
297
|
-
async function handleLovablePopupStart(auth, request) {
|
|
298
|
-
const url = new URL(request.url);
|
|
299
|
-
const authBasePath = popupStartAuthBasePath(url.pathname);
|
|
300
|
-
const signInUrl = new URL(request.url);
|
|
301
|
-
signInUrl.pathname = `${authBasePath}/sign-in/oauth2`;
|
|
302
|
-
signInUrl.search = "";
|
|
303
|
-
const headers = new Headers(request.headers);
|
|
304
|
-
headers.set("content-type", "application/json");
|
|
305
|
-
const response = await auth.handler(
|
|
306
|
-
new Request(signInUrl.toString(), {
|
|
307
|
-
method: "POST",
|
|
308
|
-
headers,
|
|
309
|
-
body: JSON.stringify(popupStartSignInBody(url))
|
|
310
|
-
})
|
|
311
|
-
);
|
|
312
|
-
if (!response.ok)
|
|
313
|
-
return response;
|
|
314
|
-
const data = await response.json();
|
|
315
|
-
const redirectUrl = getOAuthRedirectUrl(data);
|
|
316
|
-
if (!redirectUrl)
|
|
317
|
-
return new Response("No OAuth redirect URL received", { status: 500 });
|
|
318
|
-
const redirectHeaders = new Headers({ location: redirectUrl });
|
|
319
|
-
for (const setCookie of getSetCookieHeaders(response.headers)) {
|
|
320
|
-
redirectHeaders.append("set-cookie", setCookie);
|
|
321
|
-
}
|
|
322
|
-
return new Response(null, { status: 302, headers: redirectHeaders });
|
|
323
|
-
}
|
|
324
|
-
function createAuthRouteHandler(auth = newAuthServer()) {
|
|
325
|
-
return ({ request }) => {
|
|
326
|
-
if (isLovablePopupCompleteRequest(request))
|
|
327
|
-
return handleLovablePopupComplete(request);
|
|
328
|
-
if (isLovablePopupStartRequest(request))
|
|
329
|
-
return handleLovablePopupStart(auth, request);
|
|
330
|
-
return auth.handler(request);
|
|
331
|
-
};
|
|
332
|
-
}
|
|
333
|
-
function registerAuthRoutes(options = {}) {
|
|
334
|
-
const handler = createAuthRouteHandler(options.auth ?? newAuthServer(options));
|
|
335
|
-
return {
|
|
336
|
-
server: {
|
|
337
|
-
handlers: {
|
|
338
|
-
GET: handler,
|
|
339
|
-
POST: handler
|
|
340
|
-
}
|
|
341
|
-
}
|
|
342
|
-
};
|
|
343
|
-
}
|
|
344
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
345
|
-
0 && (module.exports = {
|
|
346
|
-
createAuthRouteHandler,
|
|
347
|
-
newAuthServer,
|
|
348
|
-
registerAuthRoutes
|
|
349
|
-
});
|
package/dist/server.d.cts
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { betterAuth } from 'better-auth';
|
|
2
|
-
|
|
3
|
-
type BetterAuthOptions = Parameters<typeof betterAuth>[0];
|
|
4
|
-
type LovableAuthEnv = Record<string, string | undefined>;
|
|
5
|
-
interface BetterAuthHandler {
|
|
6
|
-
handler: (request: Request) => Response | Promise<Response>;
|
|
7
|
-
}
|
|
8
|
-
interface NewAuthServerOptions {
|
|
9
|
-
env?: LovableAuthEnv;
|
|
10
|
-
authOptions?: Partial<BetterAuthOptions>;
|
|
11
|
-
isIframe?: boolean;
|
|
12
|
-
providerId?: string;
|
|
13
|
-
tenantId?: string;
|
|
14
|
-
clientId?: string;
|
|
15
|
-
clientSecret?: string;
|
|
16
|
-
oauthUpstream?: string;
|
|
17
|
-
trustedOrigins?: string[];
|
|
18
|
-
fallbackBaseURL?: string;
|
|
19
|
-
scopes?: string[];
|
|
20
|
-
}
|
|
21
|
-
interface RegisterAuthRoutesOptions extends NewAuthServerOptions {
|
|
22
|
-
auth?: BetterAuthHandler;
|
|
23
|
-
}
|
|
24
|
-
type AuthRouteHandler = (args: {
|
|
25
|
-
request: Request;
|
|
26
|
-
}) => Response | Promise<Response>;
|
|
27
|
-
declare function newAuthServer(options?: NewAuthServerOptions): BetterAuthHandler;
|
|
28
|
-
declare function createAuthRouteHandler(auth?: BetterAuthHandler): AuthRouteHandler;
|
|
29
|
-
declare function registerAuthRoutes(options?: RegisterAuthRoutesOptions): {
|
|
30
|
-
readonly server: {
|
|
31
|
-
readonly handlers: {
|
|
32
|
-
readonly GET: AuthRouteHandler;
|
|
33
|
-
readonly POST: AuthRouteHandler;
|
|
34
|
-
};
|
|
35
|
-
};
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
export { type AuthRouteHandler, type BetterAuthHandler, type LovableAuthEnv, type NewAuthServerOptions, type RegisterAuthRoutesOptions, createAuthRouteHandler, newAuthServer, registerAuthRoutes };
|
package/dist/server.d.ts
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { betterAuth } from 'better-auth';
|
|
2
|
-
|
|
3
|
-
type BetterAuthOptions = Parameters<typeof betterAuth>[0];
|
|
4
|
-
type LovableAuthEnv = Record<string, string | undefined>;
|
|
5
|
-
interface BetterAuthHandler {
|
|
6
|
-
handler: (request: Request) => Response | Promise<Response>;
|
|
7
|
-
}
|
|
8
|
-
interface NewAuthServerOptions {
|
|
9
|
-
env?: LovableAuthEnv;
|
|
10
|
-
authOptions?: Partial<BetterAuthOptions>;
|
|
11
|
-
isIframe?: boolean;
|
|
12
|
-
providerId?: string;
|
|
13
|
-
tenantId?: string;
|
|
14
|
-
clientId?: string;
|
|
15
|
-
clientSecret?: string;
|
|
16
|
-
oauthUpstream?: string;
|
|
17
|
-
trustedOrigins?: string[];
|
|
18
|
-
fallbackBaseURL?: string;
|
|
19
|
-
scopes?: string[];
|
|
20
|
-
}
|
|
21
|
-
interface RegisterAuthRoutesOptions extends NewAuthServerOptions {
|
|
22
|
-
auth?: BetterAuthHandler;
|
|
23
|
-
}
|
|
24
|
-
type AuthRouteHandler = (args: {
|
|
25
|
-
request: Request;
|
|
26
|
-
}) => Response | Promise<Response>;
|
|
27
|
-
declare function newAuthServer(options?: NewAuthServerOptions): BetterAuthHandler;
|
|
28
|
-
declare function createAuthRouteHandler(auth?: BetterAuthHandler): AuthRouteHandler;
|
|
29
|
-
declare function registerAuthRoutes(options?: RegisterAuthRoutesOptions): {
|
|
30
|
-
readonly server: {
|
|
31
|
-
readonly handlers: {
|
|
32
|
-
readonly GET: AuthRouteHandler;
|
|
33
|
-
readonly POST: AuthRouteHandler;
|
|
34
|
-
};
|
|
35
|
-
};
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
export { type AuthRouteHandler, type BetterAuthHandler, type LovableAuthEnv, type NewAuthServerOptions, type RegisterAuthRoutesOptions, createAuthRouteHandler, newAuthServer, registerAuthRoutes };
|