@lobehub/chat 1.79.6 → 1.79.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.
Files changed (74) hide show
  1. package/CHANGELOG.md +50 -0
  2. package/changelog/v1.json +18 -0
  3. package/docs/development/database-schema.dbml +119 -0
  4. package/docs/self-hosting/advanced/online-search.mdx +63 -0
  5. package/locales/ar/models.json +12 -0
  6. package/locales/ar/oauth.json +39 -0
  7. package/locales/bg-BG/models.json +12 -0
  8. package/locales/bg-BG/oauth.json +39 -0
  9. package/locales/de-DE/models.json +12 -0
  10. package/locales/de-DE/oauth.json +39 -0
  11. package/locales/en-US/models.json +12 -0
  12. package/locales/en-US/oauth.json +39 -0
  13. package/locales/es-ES/models.json +12 -0
  14. package/locales/es-ES/oauth.json +39 -0
  15. package/locales/fa-IR/models.json +12 -0
  16. package/locales/fa-IR/oauth.json +39 -0
  17. package/locales/fr-FR/models.json +12 -0
  18. package/locales/fr-FR/oauth.json +39 -0
  19. package/locales/it-IT/models.json +12 -0
  20. package/locales/it-IT/oauth.json +39 -0
  21. package/locales/ja-JP/models.json +12 -0
  22. package/locales/ja-JP/oauth.json +39 -0
  23. package/locales/ko-KR/models.json +12 -0
  24. package/locales/ko-KR/oauth.json +39 -0
  25. package/locales/nl-NL/models.json +12 -0
  26. package/locales/nl-NL/oauth.json +39 -0
  27. package/locales/pl-PL/models.json +12 -0
  28. package/locales/pl-PL/oauth.json +39 -0
  29. package/locales/pt-BR/models.json +12 -0
  30. package/locales/pt-BR/oauth.json +39 -0
  31. package/locales/ru-RU/models.json +12 -0
  32. package/locales/ru-RU/oauth.json +39 -0
  33. package/locales/tr-TR/models.json +12 -0
  34. package/locales/tr-TR/oauth.json +39 -0
  35. package/locales/vi-VN/models.json +12 -0
  36. package/locales/vi-VN/oauth.json +39 -0
  37. package/locales/zh-CN/models.json +12 -0
  38. package/locales/zh-CN/oauth.json +39 -0
  39. package/locales/zh-TW/models.json +12 -0
  40. package/locales/zh-TW/oauth.json +39 -0
  41. package/package.json +5 -2
  42. package/scripts/generate-oidc-jwk.mjs +59 -0
  43. package/scripts/migrateServerDB/index.ts +3 -1
  44. package/src/app/(backend)/oidc/[...oidc]/route.ts +270 -0
  45. package/src/app/(backend)/oidc/consent/route.ts +97 -0
  46. package/src/app/[variants]/oauth/consent/[uid]/Client.tsx +97 -0
  47. package/src/app/[variants]/oauth/consent/[uid]/failed/page.tsx +36 -0
  48. package/src/app/[variants]/oauth/consent/[uid]/page.tsx +71 -0
  49. package/src/app/[variants]/oauth/consent/[uid]/success/page.tsx +30 -0
  50. package/src/const/hotkeys.ts +2 -2
  51. package/src/const/trace.ts +1 -0
  52. package/src/database/client/migrations.json +27 -8
  53. package/src/database/migrations/0020_add_oidc.sql +124 -0
  54. package/src/database/migrations/meta/0020_snapshot.json +4975 -0
  55. package/src/database/migrations/meta/_journal.json +7 -0
  56. package/src/database/repositories/tableViewer/index.test.ts +1 -1
  57. package/src/database/schemas/index.ts +1 -0
  58. package/src/database/schemas/oidc.ts +158 -0
  59. package/src/database/server/models/__tests__/adapter.test.ts +503 -0
  60. package/src/envs/oidc.ts +18 -0
  61. package/src/libs/agent-runtime/azureOpenai/index.ts +4 -1
  62. package/src/libs/agent-runtime/utils/streams/protocol.ts +2 -4
  63. package/src/libs/oidc-provider/adapter.ts +494 -0
  64. package/src/libs/oidc-provider/config.ts +53 -0
  65. package/src/libs/oidc-provider/http-adapter.ts +279 -0
  66. package/src/libs/oidc-provider/interaction-policy.ts +37 -0
  67. package/src/libs/oidc-provider/provider.ts +260 -0
  68. package/src/locales/default/index.ts +2 -0
  69. package/src/locales/default/oauth.ts +41 -0
  70. package/src/middleware.ts +94 -6
  71. package/src/server/services/oidc/index.ts +29 -0
  72. package/src/server/services/oidc/oidcProvider.ts +27 -0
  73. package/src/store/chat/slices/aiChat/actions/memory.ts +6 -1
  74. package/src/types/hotkey.ts +54 -3
@@ -0,0 +1,36 @@
1
+ 'use client';
2
+
3
+ import { Icon } from '@lobehub/ui';
4
+ import { Button, Card, Result } from 'antd';
5
+ import { XCircle } from 'lucide-react';
6
+ import Link from 'next/link';
7
+ import React, { memo } from 'react';
8
+ import { useTranslation } from 'react-i18next';
9
+ import { Center } from 'react-layout-kit';
10
+
11
+ const FailedPage = memo(() => {
12
+ const { t } = useTranslation('oauth');
13
+
14
+ return (
15
+ <Center height="100vh">
16
+ <Card style={{ maxWidth: 500, width: '100%' }}>
17
+ <Result
18
+ extra={
19
+ <Link href="/">
20
+ <Button type="primary">{t('failed.backToHome')}</Button>
21
+ </Link>
22
+ }
23
+ icon={<Icon icon={XCircle} />}
24
+ status="error"
25
+ style={{ padding: 0 }}
26
+ subTitle={t('failed.subTitle')}
27
+ title={t('failed.title')}
28
+ />
29
+ </Card>
30
+ </Center>
31
+ );
32
+ });
33
+
34
+ FailedPage.displayName = 'FailedPage';
35
+
36
+ export default FailedPage;
@@ -0,0 +1,71 @@
1
+ import { notFound } from 'next/navigation';
2
+
3
+ import { oidcEnv } from '@/envs/oidc';
4
+ import { OIDCService } from '@/server/services/oidc';
5
+
6
+ import { ConsentClient } from './Client';
7
+
8
+ /**
9
+ * Consent 授权页面
10
+ */
11
+ const InteractionPage = async (props: { params: Promise<{ uid: string }> }) => {
12
+ if (!oidcEnv.ENABLE_OIDC) return notFound();
13
+
14
+ const params = await props.params;
15
+ const uid = params.uid;
16
+
17
+ try {
18
+ const oidcService = await OIDCService.initialize();
19
+
20
+ // 获取交互详情,传入请求和响应对象
21
+ const details = await oidcService.getInteractionDetails(uid);
22
+
23
+ // 支持 login 和 consent 类型的交互
24
+ if (details.prompt.name !== 'consent' && details.prompt.name !== 'login') {
25
+ return (
26
+ <ConsentClient
27
+ clientId=""
28
+ error={{
29
+ message: `不支持的交互类型: ${details.prompt.name}`,
30
+ title: '不支持的交互类型',
31
+ }}
32
+ scopes={[]}
33
+ uid={params.uid}
34
+ />
35
+ );
36
+ }
37
+
38
+ // 获取客户端 ID 和授权范围
39
+ const clientId = (details.params.client_id as string) || 'unknown';
40
+ const scopes = (details.params.scope as string)?.split(' ') || [];
41
+
42
+ // 渲染客户端组件,无论是 login 还是 consent 类型
43
+ return <ConsentClient clientId={clientId} scopes={scopes} uid={params.uid} />;
44
+ } catch (error) {
45
+ console.error('Error handling OIDC interaction:', error);
46
+ // 确保错误处理能正确显示
47
+ const errorMessage = error instanceof Error ? error.message : '获取授权详情时发生未知错误';
48
+ // 检查是否是 'interaction session not found' 错误,可以给用户更友好的提示
49
+ if (errorMessage.includes('interaction session not found')) {
50
+ return (
51
+ <ConsentClient
52
+ clientId=""
53
+ error={{ message: '授权会话已过期或无效,请重新发起授权流程。', title: '授权会话无效' }}
54
+ scopes={[]}
55
+ uid={params.uid} // uid 可能已失效,但仍传递给 Client
56
+ />
57
+ );
58
+ }
59
+
60
+ return (
61
+ <ConsentClient
62
+ clientId=""
63
+ error={{ message: errorMessage, title: '发生错误' }}
64
+ scopes={[]}
65
+ uid={params.uid}
66
+ />
67
+ );
68
+ }
69
+ };
70
+
71
+ export default InteractionPage;
@@ -0,0 +1,30 @@
1
+ 'use client';
2
+
3
+ import { Icon } from '@lobehub/ui';
4
+ import { Card, Result } from 'antd';
5
+ import { CheckCircle } from 'lucide-react';
6
+ import React, { memo } from 'react';
7
+ import { useTranslation } from 'react-i18next';
8
+ import { Center } from 'react-layout-kit';
9
+
10
+ const SuccessPage = memo(() => {
11
+ const { t } = useTranslation('oauth');
12
+
13
+ return (
14
+ <Center height="100vh">
15
+ <Card style={{ maxWidth: 500, width: '100%' }}>
16
+ <Result
17
+ icon={<Icon icon={CheckCircle} />}
18
+ status="success"
19
+ style={{ padding: 0 }}
20
+ subTitle={t('success.subTitle')}
21
+ title={t('success.title')}
22
+ />
23
+ </Card>
24
+ </Center>
25
+ );
26
+ });
27
+
28
+ SuccessPage.displayName = 'SuccessPage';
29
+
30
+ export default SuccessPage;
@@ -1,5 +1,3 @@
1
- import { combineKeys } from '@lobehub/ui/es/Hotkey';
2
-
3
1
  import {
4
2
  HotkeyEnum,
5
3
  HotkeyGroupEnum,
@@ -8,6 +6,8 @@ import {
8
6
  KeyEnum,
9
7
  } from '@/types/hotkey';
10
8
 
9
+ const combineKeys = (keys: string[]) => keys.join('+');
10
+
11
11
  // mod 在 Mac 上是 command 键,alt 在 Win 上是 ctrl 键
12
12
  export const HOTKEYS_REGISTRATION: HotkeyRegistration = [
13
13
  // basic
@@ -12,6 +12,7 @@ export enum TraceNameMap {
12
12
  SummaryAgentDescription = 'Summary Agent Description',
13
13
  SummaryAgentTags = 'Summary Agent Tags',
14
14
  SummaryAgentTitle = 'Summary Agent Title',
15
+ SummaryHistoryMessages = 'Summary History Messages',
15
16
  SummaryTopicTitle = 'Summary Topic Title',
16
17
  Translator = 'Translator',
17
18
  }
@@ -223,10 +223,7 @@
223
223
  "hash": "9646161fa041354714f823d726af27247bcd6e60fa3be5698c0d69f337a5700b"
224
224
  },
225
225
  {
226
- "sql": [
227
- "DROP TABLE \"user_budgets\";",
228
- "\nDROP TABLE \"user_subscriptions\";"
229
- ],
226
+ "sql": ["DROP TABLE \"user_budgets\";", "\nDROP TABLE \"user_subscriptions\";"],
230
227
  "bps": true,
231
228
  "folderMillis": 1729699958471,
232
229
  "hash": "7dad43a2a25d1aec82124a4e53f8d82f8505c3073f23606c1dc5d2a4598eacf9"
@@ -298,9 +295,7 @@
298
295
  "hash": "845a692ceabbfc3caf252a97d3e19a213bc0c433df2689900135f9cfded2cf49"
299
296
  },
300
297
  {
301
- "sql": [
302
- "ALTER TABLE \"messages\" ADD COLUMN \"reasoning\" jsonb;"
303
- ],
298
+ "sql": ["ALTER TABLE \"messages\" ADD COLUMN \"reasoning\" jsonb;"],
304
299
  "bps": true,
305
300
  "folderMillis": 1737609172353,
306
301
  "hash": "2cb36ae4fcdd7b7064767e04bfbb36ae34518ff4bb1b39006f2dd394d1893868"
@@ -429,5 +424,29 @@
429
424
  "bps": true,
430
425
  "folderMillis": 1742806552131,
431
426
  "hash": "d9032edf59f717e0e71da5a95b3545ec251c311155cafe14df01a12800a9eae0"
427
+ },
428
+ {
429
+ "sql": [
430
+ "CREATE TABLE IF NOT EXISTS \"oidc_access_tokens\" (\n\t\"id\" varchar(255) PRIMARY KEY NOT NULL,\n\t\"data\" jsonb NOT NULL,\n\t\"expires_at\" timestamp with time zone NOT NULL,\n\t\"consumed_at\" timestamp with time zone,\n\t\"user_id\" text NOT NULL,\n\t\"client_id\" varchar(255) NOT NULL,\n\t\"grant_id\" varchar(255),\n\t\"accessed_at\" timestamp with time zone DEFAULT now() NOT NULL,\n\t\"created_at\" timestamp with time zone DEFAULT now() NOT NULL,\n\t\"updated_at\" timestamp with time zone DEFAULT now() NOT NULL\n);\n",
431
+ "\nCREATE TABLE IF NOT EXISTS \"oidc_authorization_codes\" (\n\t\"id\" varchar(255) PRIMARY KEY NOT NULL,\n\t\"data\" jsonb NOT NULL,\n\t\"expires_at\" timestamp with time zone NOT NULL,\n\t\"consumed_at\" timestamp with time zone,\n\t\"user_id\" text NOT NULL,\n\t\"client_id\" varchar(255) NOT NULL,\n\t\"grant_id\" varchar(255),\n\t\"accessed_at\" timestamp with time zone DEFAULT now() NOT NULL,\n\t\"created_at\" timestamp with time zone DEFAULT now() NOT NULL,\n\t\"updated_at\" timestamp with time zone DEFAULT now() NOT NULL\n);\n",
432
+ "\nCREATE TABLE IF NOT EXISTS \"oidc_clients\" (\n\t\"id\" varchar(255) PRIMARY KEY NOT NULL,\n\t\"name\" text NOT NULL,\n\t\"description\" text,\n\t\"client_secret\" varchar(255),\n\t\"redirect_uris\" text[] NOT NULL,\n\t\"grants\" text[] NOT NULL,\n\t\"response_types\" text[] NOT NULL,\n\t\"scopes\" text[] NOT NULL,\n\t\"token_endpoint_auth_method\" varchar(20),\n\t\"application_type\" varchar(20),\n\t\"client_uri\" text,\n\t\"logo_uri\" text,\n\t\"policy_uri\" text,\n\t\"tos_uri\" text,\n\t\"is_first_party\" boolean DEFAULT false,\n\t\"accessed_at\" timestamp with time zone DEFAULT now() NOT NULL,\n\t\"created_at\" timestamp with time zone DEFAULT now() NOT NULL,\n\t\"updated_at\" timestamp with time zone DEFAULT now() NOT NULL\n);\n",
433
+ "\nCREATE TABLE IF NOT EXISTS \"oidc_consents\" (\n\t\"user_id\" text NOT NULL,\n\t\"client_id\" varchar(255) NOT NULL,\n\t\"scopes\" text[] NOT NULL,\n\t\"expires_at\" timestamp with time zone,\n\t\"accessed_at\" timestamp with time zone DEFAULT now() NOT NULL,\n\t\"created_at\" timestamp with time zone DEFAULT now() NOT NULL,\n\t\"updated_at\" timestamp with time zone DEFAULT now() NOT NULL,\n\tCONSTRAINT \"oidc_consents_user_id_client_id_pk\" PRIMARY KEY(\"user_id\",\"client_id\")\n);\n",
434
+ "\nCREATE TABLE IF NOT EXISTS \"oidc_device_codes\" (\n\t\"id\" varchar(255) PRIMARY KEY NOT NULL,\n\t\"data\" jsonb NOT NULL,\n\t\"expires_at\" timestamp with time zone NOT NULL,\n\t\"consumed_at\" timestamp with time zone,\n\t\"user_id\" text,\n\t\"client_id\" varchar(255) NOT NULL,\n\t\"grant_id\" varchar(255),\n\t\"user_code\" varchar(255),\n\t\"accessed_at\" timestamp with time zone DEFAULT now() NOT NULL,\n\t\"created_at\" timestamp with time zone DEFAULT now() NOT NULL,\n\t\"updated_at\" timestamp with time zone DEFAULT now() NOT NULL\n);\n",
435
+ "\nCREATE TABLE IF NOT EXISTS \"oidc_grants\" (\n\t\"id\" varchar(255) PRIMARY KEY NOT NULL,\n\t\"data\" jsonb NOT NULL,\n\t\"expires_at\" timestamp with time zone NOT NULL,\n\t\"consumed_at\" timestamp with time zone,\n\t\"user_id\" text NOT NULL,\n\t\"client_id\" varchar(255) NOT NULL,\n\t\"accessed_at\" timestamp with time zone DEFAULT now() NOT NULL,\n\t\"created_at\" timestamp with time zone DEFAULT now() NOT NULL,\n\t\"updated_at\" timestamp with time zone DEFAULT now() NOT NULL\n);\n",
436
+ "\nCREATE TABLE IF NOT EXISTS \"oidc_interactions\" (\n\t\"id\" varchar(255) PRIMARY KEY NOT NULL,\n\t\"data\" jsonb NOT NULL,\n\t\"expires_at\" timestamp with time zone NOT NULL,\n\t\"accessed_at\" timestamp with time zone DEFAULT now() NOT NULL,\n\t\"created_at\" timestamp with time zone DEFAULT now() NOT NULL,\n\t\"updated_at\" timestamp with time zone DEFAULT now() NOT NULL\n);\n",
437
+ "\nCREATE TABLE IF NOT EXISTS \"oidc_refresh_tokens\" (\n\t\"id\" varchar(255) PRIMARY KEY NOT NULL,\n\t\"data\" jsonb NOT NULL,\n\t\"expires_at\" timestamp with time zone NOT NULL,\n\t\"consumed_at\" timestamp with time zone,\n\t\"user_id\" text NOT NULL,\n\t\"client_id\" varchar(255) NOT NULL,\n\t\"grant_id\" varchar(255),\n\t\"accessed_at\" timestamp with time zone DEFAULT now() NOT NULL,\n\t\"created_at\" timestamp with time zone DEFAULT now() NOT NULL,\n\t\"updated_at\" timestamp with time zone DEFAULT now() NOT NULL\n);\n",
438
+ "\nCREATE TABLE IF NOT EXISTS \"oidc_sessions\" (\n\t\"id\" varchar(255) PRIMARY KEY NOT NULL,\n\t\"data\" jsonb NOT NULL,\n\t\"expires_at\" timestamp with time zone NOT NULL,\n\t\"user_id\" text NOT NULL,\n\t\"accessed_at\" timestamp with time zone DEFAULT now() NOT NULL,\n\t\"created_at\" timestamp with time zone DEFAULT now() NOT NULL,\n\t\"updated_at\" timestamp with time zone DEFAULT now() NOT NULL\n);\n",
439
+ "\nALTER TABLE \"oidc_access_tokens\" ADD CONSTRAINT \"oidc_access_tokens_user_id_users_id_fk\" FOREIGN KEY (\"user_id\") REFERENCES \"public\".\"users\"(\"id\") ON DELETE cascade ON UPDATE no action;",
440
+ "\nALTER TABLE \"oidc_authorization_codes\" ADD CONSTRAINT \"oidc_authorization_codes_user_id_users_id_fk\" FOREIGN KEY (\"user_id\") REFERENCES \"public\".\"users\"(\"id\") ON DELETE cascade ON UPDATE no action;",
441
+ "\nALTER TABLE \"oidc_consents\" ADD CONSTRAINT \"oidc_consents_user_id_users_id_fk\" FOREIGN KEY (\"user_id\") REFERENCES \"public\".\"users\"(\"id\") ON DELETE cascade ON UPDATE no action;",
442
+ "\nALTER TABLE \"oidc_consents\" ADD CONSTRAINT \"oidc_consents_client_id_oidc_clients_id_fk\" FOREIGN KEY (\"client_id\") REFERENCES \"public\".\"oidc_clients\"(\"id\") ON DELETE cascade ON UPDATE no action;",
443
+ "\nALTER TABLE \"oidc_device_codes\" ADD CONSTRAINT \"oidc_device_codes_user_id_users_id_fk\" FOREIGN KEY (\"user_id\") REFERENCES \"public\".\"users\"(\"id\") ON DELETE cascade ON UPDATE no action;",
444
+ "\nALTER TABLE \"oidc_grants\" ADD CONSTRAINT \"oidc_grants_user_id_users_id_fk\" FOREIGN KEY (\"user_id\") REFERENCES \"public\".\"users\"(\"id\") ON DELETE cascade ON UPDATE no action;",
445
+ "\nALTER TABLE \"oidc_refresh_tokens\" ADD CONSTRAINT \"oidc_refresh_tokens_user_id_users_id_fk\" FOREIGN KEY (\"user_id\") REFERENCES \"public\".\"users\"(\"id\") ON DELETE cascade ON UPDATE no action;",
446
+ "\nALTER TABLE \"oidc_sessions\" ADD CONSTRAINT \"oidc_sessions_user_id_users_id_fk\" FOREIGN KEY (\"user_id\") REFERENCES \"public\".\"users\"(\"id\") ON DELETE cascade ON UPDATE no action;\n"
447
+ ],
448
+ "bps": true,
449
+ "folderMillis": 1744458287757,
450
+ "hash": "f3a80b900906b54ba658208cd448610647fc03f1f4d51963509c07f4e53ef4de"
432
451
  }
433
- ]
452
+ ]
@@ -0,0 +1,124 @@
1
+ CREATE TABLE IF NOT EXISTS "oidc_access_tokens" (
2
+ "id" varchar(255) PRIMARY KEY NOT NULL,
3
+ "data" jsonb NOT NULL,
4
+ "expires_at" timestamp with time zone NOT NULL,
5
+ "consumed_at" timestamp with time zone,
6
+ "user_id" text NOT NULL,
7
+ "client_id" varchar(255) NOT NULL,
8
+ "grant_id" varchar(255),
9
+ "accessed_at" timestamp with time zone DEFAULT now() NOT NULL,
10
+ "created_at" timestamp with time zone DEFAULT now() NOT NULL,
11
+ "updated_at" timestamp with time zone DEFAULT now() NOT NULL
12
+ );
13
+ --> statement-breakpoint
14
+ CREATE TABLE IF NOT EXISTS "oidc_authorization_codes" (
15
+ "id" varchar(255) PRIMARY KEY NOT NULL,
16
+ "data" jsonb NOT NULL,
17
+ "expires_at" timestamp with time zone NOT NULL,
18
+ "consumed_at" timestamp with time zone,
19
+ "user_id" text NOT NULL,
20
+ "client_id" varchar(255) NOT NULL,
21
+ "grant_id" varchar(255),
22
+ "accessed_at" timestamp with time zone DEFAULT now() NOT NULL,
23
+ "created_at" timestamp with time zone DEFAULT now() NOT NULL,
24
+ "updated_at" timestamp with time zone DEFAULT now() NOT NULL
25
+ );
26
+ --> statement-breakpoint
27
+ CREATE TABLE IF NOT EXISTS "oidc_clients" (
28
+ "id" varchar(255) PRIMARY KEY NOT NULL,
29
+ "name" text NOT NULL,
30
+ "description" text,
31
+ "client_secret" varchar(255),
32
+ "redirect_uris" text[] NOT NULL,
33
+ "grants" text[] NOT NULL,
34
+ "response_types" text[] NOT NULL,
35
+ "scopes" text[] NOT NULL,
36
+ "token_endpoint_auth_method" varchar(20),
37
+ "application_type" varchar(20),
38
+ "client_uri" text,
39
+ "logo_uri" text,
40
+ "policy_uri" text,
41
+ "tos_uri" text,
42
+ "is_first_party" boolean DEFAULT false,
43
+ "accessed_at" timestamp with time zone DEFAULT now() NOT NULL,
44
+ "created_at" timestamp with time zone DEFAULT now() NOT NULL,
45
+ "updated_at" timestamp with time zone DEFAULT now() NOT NULL
46
+ );
47
+ --> statement-breakpoint
48
+ CREATE TABLE IF NOT EXISTS "oidc_consents" (
49
+ "user_id" text NOT NULL,
50
+ "client_id" varchar(255) NOT NULL,
51
+ "scopes" text[] NOT NULL,
52
+ "expires_at" timestamp with time zone,
53
+ "accessed_at" timestamp with time zone DEFAULT now() NOT NULL,
54
+ "created_at" timestamp with time zone DEFAULT now() NOT NULL,
55
+ "updated_at" timestamp with time zone DEFAULT now() NOT NULL,
56
+ CONSTRAINT "oidc_consents_user_id_client_id_pk" PRIMARY KEY("user_id","client_id")
57
+ );
58
+ --> statement-breakpoint
59
+ CREATE TABLE IF NOT EXISTS "oidc_device_codes" (
60
+ "id" varchar(255) PRIMARY KEY NOT NULL,
61
+ "data" jsonb NOT NULL,
62
+ "expires_at" timestamp with time zone NOT NULL,
63
+ "consumed_at" timestamp with time zone,
64
+ "user_id" text,
65
+ "client_id" varchar(255) NOT NULL,
66
+ "grant_id" varchar(255),
67
+ "user_code" varchar(255),
68
+ "accessed_at" timestamp with time zone DEFAULT now() NOT NULL,
69
+ "created_at" timestamp with time zone DEFAULT now() NOT NULL,
70
+ "updated_at" timestamp with time zone DEFAULT now() NOT NULL
71
+ );
72
+ --> statement-breakpoint
73
+ CREATE TABLE IF NOT EXISTS "oidc_grants" (
74
+ "id" varchar(255) PRIMARY KEY NOT NULL,
75
+ "data" jsonb NOT NULL,
76
+ "expires_at" timestamp with time zone NOT NULL,
77
+ "consumed_at" timestamp with time zone,
78
+ "user_id" text NOT NULL,
79
+ "client_id" varchar(255) NOT NULL,
80
+ "accessed_at" timestamp with time zone DEFAULT now() NOT NULL,
81
+ "created_at" timestamp with time zone DEFAULT now() NOT NULL,
82
+ "updated_at" timestamp with time zone DEFAULT now() NOT NULL
83
+ );
84
+ --> statement-breakpoint
85
+ CREATE TABLE IF NOT EXISTS "oidc_interactions" (
86
+ "id" varchar(255) PRIMARY KEY NOT NULL,
87
+ "data" jsonb NOT NULL,
88
+ "expires_at" timestamp with time zone NOT NULL,
89
+ "accessed_at" timestamp with time zone DEFAULT now() NOT NULL,
90
+ "created_at" timestamp with time zone DEFAULT now() NOT NULL,
91
+ "updated_at" timestamp with time zone DEFAULT now() NOT NULL
92
+ );
93
+ --> statement-breakpoint
94
+ CREATE TABLE IF NOT EXISTS "oidc_refresh_tokens" (
95
+ "id" varchar(255) PRIMARY KEY NOT NULL,
96
+ "data" jsonb NOT NULL,
97
+ "expires_at" timestamp with time zone NOT NULL,
98
+ "consumed_at" timestamp with time zone,
99
+ "user_id" text NOT NULL,
100
+ "client_id" varchar(255) NOT NULL,
101
+ "grant_id" varchar(255),
102
+ "accessed_at" timestamp with time zone DEFAULT now() NOT NULL,
103
+ "created_at" timestamp with time zone DEFAULT now() NOT NULL,
104
+ "updated_at" timestamp with time zone DEFAULT now() NOT NULL
105
+ );
106
+ --> statement-breakpoint
107
+ CREATE TABLE IF NOT EXISTS "oidc_sessions" (
108
+ "id" varchar(255) PRIMARY KEY NOT NULL,
109
+ "data" jsonb NOT NULL,
110
+ "expires_at" timestamp with time zone NOT NULL,
111
+ "user_id" text NOT NULL,
112
+ "accessed_at" timestamp with time zone DEFAULT now() NOT NULL,
113
+ "created_at" timestamp with time zone DEFAULT now() NOT NULL,
114
+ "updated_at" timestamp with time zone DEFAULT now() NOT NULL
115
+ );
116
+ --> statement-breakpoint
117
+ ALTER TABLE "oidc_access_tokens" ADD CONSTRAINT "oidc_access_tokens_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
118
+ ALTER TABLE "oidc_authorization_codes" ADD CONSTRAINT "oidc_authorization_codes_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
119
+ ALTER TABLE "oidc_consents" ADD CONSTRAINT "oidc_consents_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
120
+ ALTER TABLE "oidc_consents" ADD CONSTRAINT "oidc_consents_client_id_oidc_clients_id_fk" FOREIGN KEY ("client_id") REFERENCES "public"."oidc_clients"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
121
+ ALTER TABLE "oidc_device_codes" ADD CONSTRAINT "oidc_device_codes_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
122
+ ALTER TABLE "oidc_grants" ADD CONSTRAINT "oidc_grants_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
123
+ ALTER TABLE "oidc_refresh_tokens" ADD CONSTRAINT "oidc_refresh_tokens_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
124
+ ALTER TABLE "oidc_sessions" ADD CONSTRAINT "oidc_sessions_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action;