@lithia-js/better-auth 1.0.0-canary.8

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 lithiajs
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,60 @@
1
+ <div align="center">
2
+ <a href="https://github.com/lithia-framework/lithia">
3
+ <img alt="Lithia logo" src="https://raw.githubusercontent.com/lithia-framework/lithia/canary/.github/assets/logo.svg" height="128">
4
+ </a>
5
+ <h1>Lithia</h1>
6
+ <p><strong>The Node.js framework that makes API development feel like magic</strong></p>
7
+
8
+ <a href="https://www.npmjs.com/package/lithia"><img alt="NPM version" src="https://img.shields.io/npm/v/lithia.svg?style=for-the-badge&labelColor=000000"></a>
9
+ <a href="https://github.com/lithia-framework/lithia/blob/main/LICENSE"><img alt="License" src="https://img.shields.io/npm/l/lithia.svg?style=for-the-badge&labelColor=000000"></a>
10
+ <a href="https://opencollective.com/lithiajs"><img alt="Support Lithia" src="https://img.shields.io/badge/Support%20Lithia-blueviolet.svg?style=for-the-badge&logo=OpenCollective&labelColor=000000&logoWidth=20"></a>
11
+
12
+ </div>
13
+
14
+ ## Getting Started
15
+
16
+ Lithia is a next-generation Node.js framework that enables you to build powerful APIs with file-based routing, built-in WebSocket support, and a beautiful development interface.
17
+
18
+ - Visit our [Learn Lithia](https://lithiajs.com/docs) guide to get started.
19
+ - Check out the [Examples](https://github.com/lithia-framework/lithia/tree/main/examples) to see Lithia in action.
20
+
21
+ ## Documentation
22
+
23
+ Visit [https://lithiajs.com/docs](https://lithiajs.com/docs) to view the full documentation.
24
+
25
+ ## Community
26
+
27
+ The Lithia community can be found on [GitHub Discussions](https://github.com/lithia-framework/lithia/discussions) where you can ask questions, voice ideas, and share your projects with other people.
28
+
29
+ ## Contributing
30
+
31
+ Contributions to Lithia are welcome and highly appreciated. However, before you jump right into it, we would like you to review our [Contribution Guidelines](CONTRIBUTING.md) to make sure you have a smooth experience contributing to Lithia.
32
+
33
+ ---
34
+
35
+ ## Support the Project
36
+
37
+ If Lithia makes your life easier, consider supporting it:
38
+
39
+ - **Star** this repository
40
+ - **Share** on social media
41
+ - **Sponsor** via [OpenCollective](https://opencollective.com/lithiajs)
42
+ - **Report bugs** and suggest improvements
43
+
44
+ ---
45
+
46
+ ## License
47
+
48
+ Lithia is [MIT licensed](LICENSE). Free for personal and commercial use.
49
+
50
+ ---
51
+
52
+ <div align="center">
53
+ <p><strong>Built with ❤️ by the Lithia community</strong></p>
54
+ <p>
55
+ <a href="https://github.com/lithia-framework/lithia">GitHub</a> •
56
+ <a href="https://lithiajs.com">Documentation</a> •
57
+ <a href="https://opencollective.com/lithiajs">OpenCollective</a> •
58
+ <a href="https://github.com/lithia-framework/lithia/discussions">Discussions</a>
59
+ </p>
60
+ </div>
@@ -0,0 +1,3 @@
1
+ import { type RouteHandler } from "@lithia-js/core/server";
2
+ import type { Auth } from "better-auth/types";
3
+ export declare function handleAuth(auth: Auth): RouteHandler;
package/dist/index.mjs ADDED
@@ -0,0 +1,37 @@
1
+ import { RouteNotFoundError } from "@lithia-js/core/server";
2
+ export function handleAuth(auth) {
3
+ return async (req, res) => {
4
+ if (!["POST", "GET"].includes(req.method)) {
5
+ res.status(405).send("Method Not Allowed");
6
+ return;
7
+ }
8
+ const body = await req.body();
9
+ const headers = new Headers();
10
+ Object.entries(req.headers).forEach(([key, value]) => {
11
+ if (value)
12
+ headers.append(key, value.toString());
13
+ });
14
+ if (body && Object.keys(body).length > 0) {
15
+ headers.set("Content-Type", "application/json");
16
+ }
17
+ const authReq = new Request(`http://internal${req.pathname}`, {
18
+ method: req.method,
19
+ headers,
20
+ body: body && Object.keys(body).length > 0 ? JSON.stringify(body) : undefined,
21
+ });
22
+ const authRes = await auth.handler(authReq);
23
+ authRes.headers.forEach((value, key) => {
24
+ if (!["transfer-encoding", "content-length"].includes(key.toLowerCase())) {
25
+ res.setHeader(key, value);
26
+ }
27
+ });
28
+ if (authRes.status === 404) {
29
+ throw new RouteNotFoundError(req.pathname);
30
+ }
31
+ const text = authRes.body
32
+ ? await new Response(authRes.body).text()
33
+ : undefined;
34
+ res.status(authRes.status).send(text);
35
+ };
36
+ }
37
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","sourceRoot":"","sources":["../src/index.mts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAG/E,MAAM,UAAU,UAAU,CAAC,IAAU;IACpC,OAAO,KAAK,EAAE,GAAG,EAAE,GAAG,EAAE,EAAE;QACzB,IAAI,CAAC,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC;YAC3C,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IA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ACF,CAAC,CAAC,CAAC;QAEH,IAAI,OAAO,CAAC,MAAM,KAAK,GAAG,EAAE,CAAC;YAC5B,MAAM,IAAI,kBAAkB,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QAC5C,CAAC;QAED,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI;YACxB,CAAC,CAAC,MAAM,IAAI,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE;YACzC,CAAC,CAAC,SAAS,CAAC;QAEb,GAAG,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACvC,CAAC,CAAC;AACH,CAAC"}
package/package.json ADDED
@@ -0,0 +1,43 @@
1
+ {
2
+ "name": "@lithia-js/better-auth",
3
+ "version": "1.0.0-canary.8",
4
+ "private": false,
5
+ "type": "module",
6
+ "author": "Lucas Arch <luketsx@icloud.com>",
7
+ "homepage": "https://lithiajs.com",
8
+ "license": "MIT",
9
+ "main": "dist/index.mjs",
10
+ "types": "dist/index.d.mts",
11
+ "module": "dist/index.mjs",
12
+ "exports": {
13
+ ".": {
14
+ "types": "./dist/index.d.mts",
15
+ "default": "./dist/index.mjs"
16
+ }
17
+ },
18
+ "files": [
19
+ "dist"
20
+ ],
21
+ "dependencies": {
22
+ "better-auth": "^1.4.17",
23
+ "@lithia-js/core": "1.0.0-canary.8"
24
+ },
25
+ "engines": {
26
+ "node": ">=20"
27
+ },
28
+ "publishConfig": {
29
+ "registry": "https://registry.npmjs.org/",
30
+ "access": "public",
31
+ "provenance": true
32
+ },
33
+ "repository": {
34
+ "type": "git",
35
+ "url": "git+https://github.com/lithia-framework/lithia.git"
36
+ },
37
+ "bugs": {
38
+ "url": "https://github.com/lithia-framework/lithia/issues"
39
+ },
40
+ "scripts": {
41
+ "build": "tsc -p tsconfig.build.json"
42
+ }
43
+ }