@vonall/auth 0.3.1 → 0.4.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 +6 -0
- package/dist/remote/app_user.remote.js +2 -3
- package/dist/remote/einladung.remote.d.ts +6 -1
- package/dist/remote/einladung.remote.js +4 -3
- package/dist/server/index.d.ts +0 -1
- package/dist/server/index.js +0 -1
- package/dist/server/repositories/UserRepo.d.ts +5 -2
- package/dist/server/repositories/UserRepo.js +5 -2
- package/dist/server/service/einladung.service.d.ts +3 -13
- package/dist/server/service/einladung.service.js +1 -11
- package/package.json +1 -1
- package/dist/server/service/konto.service.d.ts +0 -7
- package/dist/server/service/konto.service.js +0 -11
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @vonall/auth
|
|
2
2
|
|
|
3
|
+
## 0.4.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- The pass-through services are gone: `UserRepo.kontoLoeschen` replaces `KontoService.loeschen`; `EinladungRepo.listOpenBy`/`listAllOpen` replace `EinladungService.offene`/`alleOffenen`, and `EinladungService.zurueckziehen(null, id)` the admin's withdrawal; `AgentRepo` replaces `AgentService`. `@vonall/mcp`'s components use `@vonall/auth`'s `messageOf`.
|
|
8
|
+
|
|
3
9
|
## 0.3.1
|
|
4
10
|
|
|
5
11
|
### Patch Changes
|
|
@@ -5,7 +5,6 @@ import { m } from "../messages.js";
|
|
|
5
5
|
import { adminQuery, adminSchemaCommand, protectedCommand, protectedForm, protectedQuery, protectedSchemaCommand } from "../server/helpers.js";
|
|
6
6
|
import { authInstance } from "../server/registry.js";
|
|
7
7
|
import { UserRepo } from "../server/repositories/UserRepo.js";
|
|
8
|
-
import { KontoService } from "../server/service/konto.service.js";
|
|
9
8
|
import { emailSchema, nameSchema, passwordSchema } from "../types.js";
|
|
10
9
|
import { isSessionNotFresh, reauthPath } from "../util/fresh.js";
|
|
11
10
|
/** The Admin option: every account. */
|
|
@@ -80,12 +79,12 @@ export const deleteUser = adminSchemaCommand(z.object({ userId: z.string() }), a
|
|
|
80
79
|
if (userId === admin.id) {
|
|
81
80
|
throw error(400, { message: m().ownAccount, id: "own_account", timestamp: new Date().toISOString() });
|
|
82
81
|
}
|
|
83
|
-
await
|
|
82
|
+
await UserRepo.kontoLoeschen(userId);
|
|
84
83
|
await getAllUsers().refresh();
|
|
85
84
|
return { success: true };
|
|
86
85
|
});
|
|
87
86
|
/** Deletes the user's own account with all its data. */
|
|
88
87
|
export const deleteOwnAccount = protectedCommand(async (user) => {
|
|
89
|
-
await
|
|
88
|
+
await UserRepo.kontoLoeschen(user.id);
|
|
90
89
|
return { success: true };
|
|
91
90
|
});
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
/** The user's open Einladungen, and whether the server can send them by email. */
|
|
2
2
|
export declare const getOffeneEinladungen: import("$app/server").RemoteQueryFunction<void, {
|
|
3
|
-
einladungen:
|
|
3
|
+
einladungen: {
|
|
4
|
+
id: string;
|
|
5
|
+
email: string | null;
|
|
6
|
+
expiresAt: Date;
|
|
7
|
+
createdAt: Date;
|
|
8
|
+
}[];
|
|
4
9
|
mail: boolean;
|
|
5
10
|
}, void>;
|
|
6
11
|
/** Creates an Einladung; the link is returned only here. With an email, it is also sent (if mail is set up). */
|
|
@@ -3,6 +3,7 @@ import { z } from "zod";
|
|
|
3
3
|
import { m } from "../messages.js";
|
|
4
4
|
import { adminQuery, adminSchemaCommand, protectedQuery, protectedSchemaCommand } from "../server/helpers.js";
|
|
5
5
|
import { registry } from "../server/registry.js";
|
|
6
|
+
import { EinladungRepo } from "../server/repositories/EinladungRepo.js";
|
|
6
7
|
import { EinladungService } from "../server/service/einladung.service.js";
|
|
7
8
|
import { sendEinladungEmail } from "../server/service/mail.js";
|
|
8
9
|
import { emailSchema } from "../types.js";
|
|
@@ -15,7 +16,7 @@ function unwrap(result) {
|
|
|
15
16
|
}
|
|
16
17
|
/** The user's open Einladungen, and whether the server can send them by email. */
|
|
17
18
|
export const getOffeneEinladungen = protectedQuery(async (user) => {
|
|
18
|
-
return { einladungen: await
|
|
19
|
+
return { einladungen: await EinladungRepo.listOpenBy(user.id, new Date()), mail: registry().mailer.enabled };
|
|
19
20
|
});
|
|
20
21
|
/** Creates an Einladung; the link is returned only here. With an email, it is also sent (if mail is set up). */
|
|
21
22
|
export const createEinladung = protectedSchemaCommand(z.object({ email: emailSchema.nullable() }), async ({ email }, user) => {
|
|
@@ -47,10 +48,10 @@ export const withdrawEinladung = protectedSchemaCommand(z.object({ einladungId:
|
|
|
47
48
|
});
|
|
48
49
|
/** The Admin option: every open Einladung, and withdrawing any of them. */
|
|
49
50
|
export const getAlleEinladungen = adminQuery(async () => {
|
|
50
|
-
return await
|
|
51
|
+
return await EinladungRepo.listAllOpen(new Date());
|
|
51
52
|
});
|
|
52
53
|
export const adminWithdrawEinladung = adminSchemaCommand(z.object({ einladungId: z.string() }), async ({ einladungId }) => {
|
|
53
|
-
unwrap(await EinladungService.
|
|
54
|
+
unwrap(await EinladungService.zurueckziehen(null, einladungId));
|
|
54
55
|
await getAlleEinladungen().refresh();
|
|
55
56
|
await getOffeneEinladungen().refresh();
|
|
56
57
|
});
|
package/dist/server/index.d.ts
CHANGED
|
@@ -5,5 +5,4 @@ export { authInstance, registry as authRegistry, type AuthLog, type Db } from ".
|
|
|
5
5
|
export { EinladungRepo } from "./repositories/EinladungRepo.js";
|
|
6
6
|
export { UserRepo } from "./repositories/UserRepo.js";
|
|
7
7
|
export { EINLADUNG_COOKIE, EINLADUNG_GUELTIG_TAGE, EinladungService, type EinladungError } from "./service/einladung.service.js";
|
|
8
|
-
export { KontoService } from "./service/konto.service.js";
|
|
9
8
|
export { sendEinladungEmail, sendPasswordResetEmail, sendVerifyEmail } from "./service/mail.js";
|
package/dist/server/index.js
CHANGED
|
@@ -5,5 +5,4 @@ export { authInstance, registry as authRegistry } from "./registry.js";
|
|
|
5
5
|
export { EinladungRepo } from "./repositories/EinladungRepo.js";
|
|
6
6
|
export { UserRepo } from "./repositories/UserRepo.js";
|
|
7
7
|
export { EINLADUNG_COOKIE, EINLADUNG_GUELTIG_TAGE, EinladungService } from "./service/einladung.service.js";
|
|
8
|
-
export { KontoService } from "./service/konto.service.js";
|
|
9
8
|
export { sendEinladungEmail, sendPasswordResetEmail, sendVerifyEmail } from "./service/mail.js";
|
|
@@ -14,6 +14,9 @@ export declare const UserRepo: {
|
|
|
14
14
|
providerId: string;
|
|
15
15
|
updatedAt: Date;
|
|
16
16
|
}[]>;
|
|
17
|
-
/**
|
|
18
|
-
|
|
17
|
+
/**
|
|
18
|
+
* Deletes the Konto: the user with everything that belongs to them (the foreign keys of every user-owned table
|
|
19
|
+
* cascade, so a Product's own tables reference `user.id` with `onDelete: "cascade"`).
|
|
20
|
+
*/
|
|
21
|
+
kontoLoeschen(userId: string): Promise<void>;
|
|
19
22
|
};
|
|
@@ -59,8 +59,11 @@ export const UserRepo = {
|
|
|
59
59
|
.from(schema.account)
|
|
60
60
|
.where(eq(schema.account.userId, userId));
|
|
61
61
|
},
|
|
62
|
-
/**
|
|
63
|
-
|
|
62
|
+
/**
|
|
63
|
+
* Deletes the Konto: the user with everything that belongs to them (the foreign keys of every user-owned table
|
|
64
|
+
* cascade, so a Product's own tables reference `user.id` with `onDelete: "cascade"`).
|
|
65
|
+
*/
|
|
66
|
+
async kontoLoeschen(userId) {
|
|
64
67
|
const { db, schema } = registry();
|
|
65
68
|
await db.delete(schema.user).where(eq(schema.user.id, userId));
|
|
66
69
|
},
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type Result } from "neverthrow";
|
|
2
|
-
import type { EinladungInfo,
|
|
2
|
+
import type { EinladungInfo, SignupMode, SignupState } from "../../types.js";
|
|
3
3
|
export declare const EINLADUNG_GUELTIG_TAGE = 14;
|
|
4
4
|
/** The cookie that carries an Einladung's token from its link through signup (email, Google or GitHub). */
|
|
5
5
|
export declare const EINLADUNG_COOKIE = "einladung";
|
|
@@ -33,16 +33,6 @@ export declare const EinladungService: {
|
|
|
33
33
|
}>;
|
|
34
34
|
/** Uses the Einladung for the new user: marks it as taken. */
|
|
35
35
|
annehmen(userId: string, token: string, now?: Date): Promise<Result<void, EinladungError>>;
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
zurueckziehen(userId: string, einladungId: string): Promise<Result<void, EinladungError>>;
|
|
39
|
-
/** For the admin: every open Einladung, and withdrawing any of them. */
|
|
40
|
-
alleOffenen(now?: Date): Promise<{
|
|
41
|
-
id: string;
|
|
42
|
-
email: string | null;
|
|
43
|
-
inviterName: string;
|
|
44
|
-
expiresAt: Date;
|
|
45
|
-
createdAt: Date;
|
|
46
|
-
}[]>;
|
|
47
|
-
zurueckziehenAlsAdmin(einladungId: string): Promise<Result<void, EinladungError>>;
|
|
36
|
+
/** Withdraws an open Einladung of the user, or any open one when `userId` is null (the admin). */
|
|
37
|
+
zurueckziehen(userId: string | null, einladungId: string): Promise<Result<void, EinladungError>>;
|
|
48
38
|
};
|
|
@@ -59,18 +59,8 @@ export const EinladungService = {
|
|
|
59
59
|
return err(fehler.angenommen());
|
|
60
60
|
return ok(undefined);
|
|
61
61
|
},
|
|
62
|
-
|
|
63
|
-
return await EinladungRepo.listOpenBy(userId, now);
|
|
64
|
-
},
|
|
65
|
-
/** Withdraws an open Einladung of the user. */
|
|
62
|
+
/** Withdraws an open Einladung of the user, or any open one when `userId` is null (the admin). */
|
|
66
63
|
async zurueckziehen(userId, einladungId) {
|
|
67
64
|
return (await EinladungRepo.deleteOpen(einladungId, userId)) ? ok(undefined) : err(fehler.unbekannt());
|
|
68
65
|
},
|
|
69
|
-
/** For the admin: every open Einladung, and withdrawing any of them. */
|
|
70
|
-
async alleOffenen(now = new Date()) {
|
|
71
|
-
return await EinladungRepo.listAllOpen(now);
|
|
72
|
-
},
|
|
73
|
-
async zurueckziehenAlsAdmin(einladungId) {
|
|
74
|
-
return (await EinladungRepo.deleteOpen(einladungId, null)) ? ok(undefined) : err(fehler.unbekannt());
|
|
75
|
-
},
|
|
76
66
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vonall/auth",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.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": {
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
export declare const KontoService: {
|
|
2
|
-
/**
|
|
3
|
-
* Deletes the account with everything that belongs to it: the foreign keys of every user-owned table cascade, so a
|
|
4
|
-
* Product's own tables reference `user.id` with `onDelete: "cascade"`.
|
|
5
|
-
*/
|
|
6
|
-
loeschen(userId: string): Promise<void>;
|
|
7
|
-
};
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/** The user's account as a whole. */
|
|
2
|
-
import { UserRepo } from "../repositories/UserRepo.js";
|
|
3
|
-
export const KontoService = {
|
|
4
|
-
/**
|
|
5
|
-
* Deletes the account with everything that belongs to it: the foreign keys of every user-owned table cascade, so a
|
|
6
|
-
* Product's own tables reference `user.id` with `onDelete: "cascade"`.
|
|
7
|
-
*/
|
|
8
|
-
async loeschen(userId) {
|
|
9
|
-
await UserRepo.deleteUser(userId);
|
|
10
|
-
},
|
|
11
|
-
};
|