@vonall/auth 0.1.1 → 0.2.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/CHANGELOG.md +12 -0
- package/README.md +17 -10
- package/dist/permissions.d.ts +6 -6
- package/dist/remote/app_user.remote.js +7 -7
- package/dist/server/create.d.ts +20 -12
- package/dist/server/create.js +29 -34
- package/dist/server/index.d.ts +2 -2
- package/dist/server/index.js +2 -2
- package/dist/server/loads.js +2 -2
- package/dist/server/registry.d.ts +4 -1
- package/dist/server/registry.js +8 -1
- package/dist/testing/index.d.ts +1948 -3
- package/dist/testing/index.js +23 -13
- package/package.json +6 -8
- package/dist/client/index.d.ts +0 -24
- package/dist/client/index.js +0 -9
package/dist/testing/index.js
CHANGED
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
/** Helpers for a Product's db tests (`tests/db/fixtures.ts`) and this package's own. */
|
|
2
|
+
import { getRequestEvent } from "$app/server";
|
|
3
|
+
import { betterAuth } from "better-auth";
|
|
4
|
+
import { admin as adminPlugin } from "better-auth/plugins";
|
|
5
|
+
import { twoFactor } from "better-auth/plugins/two-factor";
|
|
6
|
+
import { sveltekitCookies } from "better-auth/svelte-kit";
|
|
2
7
|
import { createMailer } from "@vonall/mail";
|
|
8
|
+
import { ac, roles } from "../permissions.js";
|
|
3
9
|
import { authSchema } from "../schema/index.js";
|
|
4
|
-
import {
|
|
10
|
+
import { authOptions, registerAuth } from "../server/create.js";
|
|
5
11
|
import { UserRepo } from "../server/repositories/UserRepo.js";
|
|
6
12
|
/** Creates a user directly (the first one becomes admin, as in the app) and returns its id. */
|
|
7
13
|
export async function createUser(email = "user@example.com") {
|
|
@@ -9,18 +15,22 @@ export async function createUser(email = "user@example.com") {
|
|
|
9
15
|
await UserRepo.insertUser({ id, email, name: "", emailVerified: true, createdAt: new Date(), updatedAt: new Date() });
|
|
10
16
|
return id;
|
|
11
17
|
}
|
|
12
|
-
/**
|
|
18
|
+
/** The wiring with test values: every option on, mail off, unless overridden; as a Product's `src/lib/auth.ts` does it. */
|
|
13
19
|
export function testAuth(db, overrides = {}) {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
20
|
+
const auth = betterAuth({
|
|
21
|
+
...authOptions({
|
|
22
|
+
db,
|
|
23
|
+
schema: authSchema({ admin: true, mcp: true }),
|
|
24
|
+
secret: "test-secret-for-the-db-tests-only",
|
|
25
|
+
origin: "http://localhost:5173",
|
|
26
|
+
appName: "Test",
|
|
27
|
+
locale: "en-GB",
|
|
28
|
+
signupMode: "invite",
|
|
29
|
+
mailer: createMailer({ smtp: null }),
|
|
30
|
+
admin: true,
|
|
31
|
+
...overrides,
|
|
32
|
+
}),
|
|
33
|
+
plugins: [twoFactor(), adminPlugin({ ac, roles }), sveltekitCookies(getRequestEvent)],
|
|
25
34
|
});
|
|
35
|
+
return { auth, ...registerAuth(auth) };
|
|
26
36
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vonall/auth",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Accounts for a Web App Factory Product: better-auth with the hooks, the protected helpers, Einladungen, Konto, the auth pages and the settings; Admin as an option",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -37,10 +37,6 @@
|
|
|
37
37
|
"types": "./dist/server/index.d.ts",
|
|
38
38
|
"default": "./dist/server/index.js"
|
|
39
39
|
},
|
|
40
|
-
"./client": {
|
|
41
|
-
"types": "./dist/client/index.d.ts",
|
|
42
|
-
"default": "./dist/client/index.js"
|
|
43
|
-
},
|
|
44
40
|
"./remote": {
|
|
45
41
|
"types": "./dist/remote/index.d.ts",
|
|
46
42
|
"default": "./dist/remote/index.js"
|
|
@@ -52,13 +48,15 @@
|
|
|
52
48
|
},
|
|
53
49
|
"peerDependencies": {
|
|
54
50
|
"@sveltejs/kit": "^3.1.0",
|
|
55
|
-
"svelte": "^5.57.2",
|
|
56
51
|
"drizzle-orm": "^0.45.4",
|
|
52
|
+
"neverthrow": "^8.2.0",
|
|
57
53
|
"pg": "^8.23.1",
|
|
58
|
-
"
|
|
59
|
-
"
|
|
54
|
+
"svelte": "^5.57.2",
|
|
55
|
+
"zod": "^4.6.7"
|
|
60
56
|
},
|
|
61
57
|
"devDependencies": {
|
|
58
|
+
"@better-auth/mcp": "^1.7.12",
|
|
59
|
+
"@better-auth/oauth-provider": "^1.7.12",
|
|
62
60
|
"@sveltejs/kit": "^3.1.0",
|
|
63
61
|
"@sveltejs/package": "^3.0.1",
|
|
64
62
|
"@sveltejs/vite-plugin-svelte": "7.3.1",
|
package/dist/client/index.d.ts
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
/** The better-auth client for a Product's browser code; `src/lib/auth-client.ts` creates it once. */
|
|
2
|
-
import type { BetterAuthClientPlugin } from "better-auth/client";
|
|
3
|
-
import { adminClient, twoFactorClient } from "better-auth/client/plugins";
|
|
4
|
-
import { createAuthClient as createClient } from "better-auth/svelte";
|
|
5
|
-
import { ac, roles } from "../permissions.js";
|
|
6
|
-
export type CreateAuthClientOptions<P extends BetterAuthClientPlugin[] = []> = {
|
|
7
|
-
/** PUBLIC_ORIGIN. */
|
|
8
|
-
baseURL: string;
|
|
9
|
-
/** The Admin option (matches the server). */
|
|
10
|
-
admin?: boolean;
|
|
11
|
-
/** More client plugins, e.g. the MCP endpoint's (`@vonall/mcp/client`); they are part of the client's type. */
|
|
12
|
-
plugins?: P;
|
|
13
|
-
};
|
|
14
|
-
type BasePlugins = [ReturnType<typeof twoFactorClient>, ReturnType<typeof adminClient<{
|
|
15
|
-
ac: typeof ac;
|
|
16
|
-
roles: typeof roles;
|
|
17
|
-
}>>];
|
|
18
|
-
/** The client with this package's plugins and the Product's. */
|
|
19
|
-
export type AuthClient<P extends BetterAuthClientPlugin[] = []> = ReturnType<typeof createClient<{
|
|
20
|
-
baseURL: string;
|
|
21
|
-
plugins: [...BasePlugins, ...P];
|
|
22
|
-
}>>;
|
|
23
|
-
export declare function createAuthClient<P extends BetterAuthClientPlugin[] = []>({ baseURL, admin, plugins }: CreateAuthClientOptions<P>): AuthClient<P>;
|
|
24
|
-
export {};
|
package/dist/client/index.js
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { adminClient, twoFactorClient } from "better-auth/client/plugins";
|
|
2
|
-
import { createAuthClient as createClient } from "better-auth/svelte";
|
|
3
|
-
import { ac, roles } from "../permissions.js";
|
|
4
|
-
export function createAuthClient({ baseURL, admin = false, plugins }) {
|
|
5
|
-
return createClient({
|
|
6
|
-
baseURL: baseURL || "http://localhost:5173",
|
|
7
|
-
plugins: [twoFactorClient(), ...(admin ? [adminClient({ ac, roles })] : []), ...(plugins ?? [])],
|
|
8
|
-
});
|
|
9
|
-
}
|