@lobehub/lobehub 2.0.0-next.139 → 2.0.0-next.140
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 +25 -0
- package/changelog/v1.json +9 -0
- package/docs/development/database-schema.dbml +39 -1
- package/package.json +1 -1
- package/packages/database/migrations/0053_better_auth_admin.sql +5 -0
- package/packages/database/migrations/0054_better_auth_two_factor.sql +47 -0
- package/packages/database/migrations/meta/0053_snapshot.json +8247 -0
- package/packages/database/migrations/meta/0054_snapshot.json +8402 -0
- package/packages/database/migrations/meta/_journal.json +14 -0
- package/packages/database/src/core/migrations.json +31 -0
- package/packages/database/src/index.ts +1 -0
- package/packages/database/src/repositories/tableViewer/index.test.ts +1 -1
- package/packages/database/src/schemas/betterAuth.ts +104 -47
- package/packages/database/src/schemas/user.ts +14 -1
- package/src/auth.ts +40 -22
- package/src/envs/auth.ts +9 -2
- package/src/libs/better-auth/auth-client.ts +2 -0
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,31 @@
|
|
|
2
2
|
|
|
3
3
|
# Changelog
|
|
4
4
|
|
|
5
|
+
## [Version 2.0.0-next.140](https://github.com/lobehub/lobe-chat/compare/v2.0.0-next.139...v2.0.0-next.140)
|
|
6
|
+
|
|
7
|
+
<sup>Released on **2025-12-01**</sup>
|
|
8
|
+
|
|
9
|
+
#### ✨ Features
|
|
10
|
+
|
|
11
|
+
- **misc**: Integrate better-auth admin plugin.
|
|
12
|
+
|
|
13
|
+
<br/>
|
|
14
|
+
|
|
15
|
+
<details>
|
|
16
|
+
<summary><kbd>Improvements and Fixes</kbd></summary>
|
|
17
|
+
|
|
18
|
+
#### What's improved
|
|
19
|
+
|
|
20
|
+
- **misc**: Integrate better-auth admin plugin, closes [#10512](https://github.com/lobehub/lobe-chat/issues/10512) ([3be78f0](https://github.com/lobehub/lobe-chat/commit/3be78f0))
|
|
21
|
+
|
|
22
|
+
</details>
|
|
23
|
+
|
|
24
|
+
<div align="right">
|
|
25
|
+
|
|
26
|
+
[](#readme-top)
|
|
27
|
+
|
|
28
|
+
</div>
|
|
29
|
+
|
|
5
30
|
## [Version 2.0.0-next.139](https://github.com/lobehub/lobe-chat/compare/v2.0.0-next.138...v2.0.0-next.139)
|
|
6
31
|
|
|
7
32
|
<sup>Released on **2025-12-01**</sup>
|
package/changelog/v1.json
CHANGED
|
@@ -151,17 +151,38 @@ table accounts {
|
|
|
151
151
|
scope text
|
|
152
152
|
updated_at timestamp [not null]
|
|
153
153
|
user_id text [not null]
|
|
154
|
+
|
|
155
|
+
indexes {
|
|
156
|
+
user_id [name: 'account_userId_idx']
|
|
157
|
+
}
|
|
154
158
|
}
|
|
155
159
|
|
|
156
160
|
table auth_sessions {
|
|
157
161
|
created_at timestamp [not null, default: `now()`]
|
|
158
162
|
expires_at timestamp [not null]
|
|
159
163
|
id text [pk, not null]
|
|
164
|
+
impersonated_by text
|
|
160
165
|
ip_address text
|
|
161
166
|
token text [not null, unique]
|
|
162
167
|
updated_at timestamp [not null]
|
|
163
168
|
user_agent text
|
|
164
169
|
user_id text [not null]
|
|
170
|
+
|
|
171
|
+
indexes {
|
|
172
|
+
user_id [name: 'auth_session_userId_idx']
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
table two_factor {
|
|
177
|
+
backup_codes text [not null]
|
|
178
|
+
id text [pk, not null]
|
|
179
|
+
secret text [not null]
|
|
180
|
+
user_id text [not null]
|
|
181
|
+
|
|
182
|
+
indexes {
|
|
183
|
+
secret [name: 'two_factor_secret_idx']
|
|
184
|
+
user_id [name: 'two_factor_user_id_idx']
|
|
185
|
+
}
|
|
165
186
|
}
|
|
166
187
|
|
|
167
188
|
table verifications {
|
|
@@ -171,6 +192,10 @@ table verifications {
|
|
|
171
192
|
identifier text [not null]
|
|
172
193
|
updated_at timestamp [not null, default: `now()`]
|
|
173
194
|
value text [not null]
|
|
195
|
+
|
|
196
|
+
indexes {
|
|
197
|
+
identifier [name: 'verification_identifier_idx']
|
|
198
|
+
}
|
|
174
199
|
}
|
|
175
200
|
|
|
176
201
|
table chat_groups {
|
|
@@ -1017,7 +1042,7 @@ table user_settings {
|
|
|
1017
1042
|
table users {
|
|
1018
1043
|
id text [pk, not null]
|
|
1019
1044
|
username text [unique]
|
|
1020
|
-
email text
|
|
1045
|
+
email text [unique]
|
|
1021
1046
|
avatar text
|
|
1022
1047
|
phone text
|
|
1023
1048
|
first_name text
|
|
@@ -1028,6 +1053,13 @@ table users {
|
|
|
1028
1053
|
email_verified boolean [not null, default: false]
|
|
1029
1054
|
email_verified_at "timestamp with time zone"
|
|
1030
1055
|
preference jsonb
|
|
1056
|
+
role text
|
|
1057
|
+
banned boolean [default: false]
|
|
1058
|
+
ban_reason text
|
|
1059
|
+
ban_expires "timestamp with time zone"
|
|
1060
|
+
two_factor_enabled boolean [default: false]
|
|
1061
|
+
phone_number text [unique]
|
|
1062
|
+
phone_number_verified boolean
|
|
1031
1063
|
accessed_at "timestamp with time zone" [not null, default: `now()`]
|
|
1032
1064
|
created_at "timestamp with time zone" [not null, default: `now()`]
|
|
1033
1065
|
updated_at "timestamp with time zone" [not null, default: `now()`]
|
|
@@ -1156,6 +1188,12 @@ table user_memories_preferences {
|
|
|
1156
1188
|
}
|
|
1157
1189
|
}
|
|
1158
1190
|
|
|
1191
|
+
ref: accounts.user_id > users.id
|
|
1192
|
+
|
|
1193
|
+
ref: auth_sessions.user_id > users.id
|
|
1194
|
+
|
|
1195
|
+
ref: two_factor.user_id > users.id
|
|
1196
|
+
|
|
1159
1197
|
ref: agents_files.file_id > files.id
|
|
1160
1198
|
|
|
1161
1199
|
ref: agents_files.agent_id > agents.id
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lobehub/lobehub",
|
|
3
|
-
"version": "2.0.0-next.
|
|
3
|
+
"version": "2.0.0-next.140",
|
|
4
4
|
"description": "LobeHub - an open-source,comprehensive AI Agent framework that supports speech synthesis, multimodal, and extensible Function Call plugin system. Supports one-click free deployment of your private ChatGPT/LLM web application.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"framework",
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
ALTER TABLE "auth_sessions" ADD COLUMN IF NOT EXISTS "impersonated_by" text;--> statement-breakpoint
|
|
2
|
+
ALTER TABLE "users" ADD COLUMN IF NOT EXISTS "role" text;--> statement-breakpoint
|
|
3
|
+
ALTER TABLE "users" ADD COLUMN IF NOT EXISTS "banned" boolean DEFAULT false;--> statement-breakpoint
|
|
4
|
+
ALTER TABLE "users" ADD COLUMN IF NOT EXISTS "ban_reason" text;--> statement-breakpoint
|
|
5
|
+
ALTER TABLE "users" ADD COLUMN IF NOT EXISTS "ban_expires" timestamp with time zone;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
CREATE TABLE IF NOT EXISTS "two_factor" (
|
|
2
|
+
"backup_codes" text NOT NULL,
|
|
3
|
+
"id" text PRIMARY KEY NOT NULL,
|
|
4
|
+
"secret" text NOT NULL,
|
|
5
|
+
"user_id" text NOT NULL
|
|
6
|
+
);
|
|
7
|
+
--> statement-breakpoint
|
|
8
|
+
ALTER TABLE "users" ADD COLUMN IF NOT EXISTS "two_factor_enabled" boolean DEFAULT false;
|
|
9
|
+
--> statement-breakpoint
|
|
10
|
+
ALTER TABLE "users" ADD COLUMN IF NOT EXISTS "phone_number" text;
|
|
11
|
+
--> statement-breakpoint
|
|
12
|
+
ALTER TABLE "users" ADD COLUMN IF NOT EXISTS "phone_number_verified" boolean;
|
|
13
|
+
--> statement-breakpoint
|
|
14
|
+
DO $$
|
|
15
|
+
BEGIN
|
|
16
|
+
IF NOT EXISTS (
|
|
17
|
+
SELECT 1 FROM pg_constraint WHERE conname = 'two_factor_user_id_users_id_fk'
|
|
18
|
+
) THEN
|
|
19
|
+
ALTER TABLE "two_factor"
|
|
20
|
+
ADD CONSTRAINT "two_factor_user_id_users_id_fk"
|
|
21
|
+
FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action;
|
|
22
|
+
END IF;
|
|
23
|
+
END $$;
|
|
24
|
+
--> statement-breakpoint
|
|
25
|
+
CREATE INDEX IF NOT EXISTS "two_factor_secret_idx" ON "two_factor" USING btree ("secret");
|
|
26
|
+
--> statement-breakpoint
|
|
27
|
+
CREATE INDEX IF NOT EXISTS "two_factor_user_id_idx" ON "two_factor" USING btree ("user_id");
|
|
28
|
+
--> statement-breakpoint
|
|
29
|
+
CREATE INDEX IF NOT EXISTS "account_userId_idx" ON "accounts" USING btree ("user_id");
|
|
30
|
+
--> statement-breakpoint
|
|
31
|
+
CREATE INDEX IF NOT EXISTS "auth_session_userId_idx" ON "auth_sessions" USING btree ("user_id");
|
|
32
|
+
--> statement-breakpoint
|
|
33
|
+
CREATE INDEX IF NOT EXISTS "verification_identifier_idx" ON "verifications" USING btree ("identifier");
|
|
34
|
+
--> statement-breakpoint
|
|
35
|
+
DO $$
|
|
36
|
+
BEGIN
|
|
37
|
+
IF NOT EXISTS (SELECT 1 FROM pg_constraint WHERE conname = 'users_email_unique') THEN
|
|
38
|
+
ALTER TABLE "users" ADD CONSTRAINT "users_email_unique" UNIQUE ("email");
|
|
39
|
+
END IF;
|
|
40
|
+
END $$;
|
|
41
|
+
--> statement-breakpoint
|
|
42
|
+
DO $$
|
|
43
|
+
BEGIN
|
|
44
|
+
IF NOT EXISTS (SELECT 1 FROM pg_constraint WHERE conname = 'users_phone_number_unique') THEN
|
|
45
|
+
ALTER TABLE "users" ADD CONSTRAINT "users_phone_number_unique" UNIQUE ("phone_number");
|
|
46
|
+
END IF;
|
|
47
|
+
END $$;
|