better-auth 0.2.3-beta.8 → 0.2.4
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/access.js +125 -1
- package/dist/adapters.d.ts +1 -2
- package/dist/adapters.js +1155 -14
- package/dist/api.js +2458 -4
- package/dist/cli.js +1010 -3
- package/dist/client/plugins.js +527 -2
- package/dist/client.js +382 -1
- package/dist/index.js +3670 -5
- package/dist/next-js.js +34 -1
- package/dist/node.js +8 -1
- package/dist/plugins.js +5529 -4
- package/dist/react.js +393 -1
- package/dist/social.js +586 -2
- package/dist/solid-start.js +13 -1
- package/dist/solid.js +389 -1
- package/dist/svelte-kit.js +34 -1
- package/dist/svelte.js +380 -1
- package/dist/utils.js +453 -2
- package/dist/vue.js +389 -1
- package/package.json +5 -3
package/dist/next-js.js
CHANGED
|
@@ -1 +1,34 @@
|
|
|
1
|
-
|
|
1
|
+
// src/integrations/next-js.ts
|
|
2
|
+
import { betterFetch } from "@better-fetch/fetch";
|
|
3
|
+
import { NextResponse } from "next/server";
|
|
4
|
+
function toNextJsHandler(auth) {
|
|
5
|
+
const handler = async (request) => {
|
|
6
|
+
return "handler" in auth ? auth.handler(request) : auth(request);
|
|
7
|
+
};
|
|
8
|
+
return {
|
|
9
|
+
GET: handler,
|
|
10
|
+
POST: handler
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
function authMiddleware(options) {
|
|
14
|
+
return async (request) => {
|
|
15
|
+
const url = new URL(request.url).origin;
|
|
16
|
+
const basePath = options?.baePath || "/api/auth";
|
|
17
|
+
const fullURL = `${url}${basePath}/session`;
|
|
18
|
+
const res = await betterFetch(fullURL, {
|
|
19
|
+
headers: request.headers
|
|
20
|
+
});
|
|
21
|
+
const session = res.data || null;
|
|
22
|
+
if (options.customRedirect) {
|
|
23
|
+
return options.customRedirect(session, request);
|
|
24
|
+
}
|
|
25
|
+
if (!session) {
|
|
26
|
+
return NextResponse.redirect(new URL(options.redirectTo || "/", url));
|
|
27
|
+
}
|
|
28
|
+
return NextResponse.next();
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
export {
|
|
32
|
+
authMiddleware,
|
|
33
|
+
toNextJsHandler
|
|
34
|
+
};
|
package/dist/node.js
CHANGED
|
@@ -1 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
// src/integrations/node.ts
|
|
2
|
+
import { toNodeHandler as toNode } from "better-call";
|
|
3
|
+
var toNodeHandler = (auth) => {
|
|
4
|
+
return "handler" in auth ? toNode(auth.handler) : toNode(auth);
|
|
5
|
+
};
|
|
6
|
+
export {
|
|
7
|
+
toNodeHandler
|
|
8
|
+
};
|