@lobehub/lobehub 2.0.0-next.175 → 2.0.0-next.177

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 (31) hide show
  1. package/.eslintrc.js +1 -0
  2. package/.github/workflows/bundle-analyzer.yml +117 -0
  3. package/CHANGELOG.md +50 -0
  4. package/changelog/v1.json +14 -0
  5. package/docs/development/database-schema.dbml +26 -0
  6. package/next.config.ts +27 -0
  7. package/package.json +3 -1
  8. package/packages/agent-runtime/package.json +4 -1
  9. package/packages/const/package.json +5 -0
  10. package/packages/database/migrations/0065_add_passkey.sql +22 -0
  11. package/packages/database/migrations/0066_add_document_fields.sql +8 -0
  12. package/packages/database/migrations/meta/0065_snapshot.json +9922 -0
  13. package/packages/database/migrations/meta/0066_snapshot.json +9962 -0
  14. package/packages/database/migrations/meta/_journal.json +14 -0
  15. package/packages/database/package.json +15 -0
  16. package/packages/database/src/core/migrations.json +54 -11
  17. package/packages/database/src/repositories/tableViewer/index.test.ts +1 -1
  18. package/packages/database/src/schemas/betterAuth.ts +40 -1
  19. package/packages/database/src/schemas/file.ts +9 -3
  20. package/packages/electron-client-ipc/package.json +3 -0
  21. package/packages/model-bank/package.json +3 -0
  22. package/packages/model-runtime/package.json +18 -1
  23. package/packages/types/package.json +11 -0
  24. package/packages/utils/package.json +24 -2
  25. package/packages/web-crawler/package.json +1 -1
  26. package/public/.well-known/apple-app-site-association +5 -0
  27. package/public/.well-known/assetlinks.json +18 -0
  28. package/src/auth.ts +69 -1
  29. package/src/libs/better-auth/email-templates/index.ts +1 -0
  30. package/src/libs/better-auth/email-templates/verification-otp.ts +106 -0
  31. package/src/libs/better-auth/utils/config.ts +20 -1
@@ -0,0 +1,106 @@
1
+ /**
2
+ * Email OTP verification template for mobile
3
+ * Sent to users when they need to verify their email using OTP code
4
+ */
5
+ export const getVerificationOTPEmailTemplate = (params: {
6
+ expiresInSeconds: number;
7
+ otp: string;
8
+ userName?: string | null;
9
+ }) => {
10
+ const { otp, userName, expiresInSeconds } = params;
11
+
12
+ // Format expiration time in a human-readable way
13
+ const expiresInMinutes = expiresInSeconds / 60;
14
+ const expirationText =
15
+ expiresInMinutes >= 1
16
+ ? `${expiresInMinutes} minute${expiresInMinutes > 1 ? 's' : ''}`
17
+ : `${expiresInSeconds} seconds`;
18
+
19
+ return {
20
+ html: `
21
+ <!DOCTYPE html>
22
+ <html lang="en">
23
+ <head>
24
+ <meta charset="utf-8">
25
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
26
+ <title>Verify your email</title>
27
+ </head>
28
+ <body style="margin: 0; padding: 0; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif; background-color: #f4f4f5; color: #1a1a1a;">
29
+ <!-- Container -->
30
+ <div style="max-width: 600px; margin: 0 auto; padding: 40px 20px;">
31
+
32
+ <!-- Logo -->
33
+ <div style="text-align: center; margin-bottom: 32px;">
34
+ <div style="display: inline-flex; align-items: center; justify-content: center; background-color: #ffffff; border-radius: 12px; padding: 8px 16px; box-shadow: 0 2px 8px rgba(0,0,0,0.04);">
35
+ <span style="font-size: 24px; line-height: 1; margin-right: 10px;">🤯</span>
36
+ <span style="font-size: 18px; font-weight: 700; color: #000000; letter-spacing: -0.5px;">LobeHub</span>
37
+ </div>
38
+ </div>
39
+
40
+ <!-- Card -->
41
+ <div style="background: #ffffff; border-radius: 20px; padding: 40px; box-shadow: 0 8px 30px rgba(0,0,0,0.04); border: 1px solid rgba(0,0,0,0.02);">
42
+
43
+ <!-- Header -->
44
+ <div style="text-align: center; margin-bottom: 32px;">
45
+ <h1 style="color: #111827; font-size: 24px; font-weight: 700; margin: 0 0 12px 0; letter-spacing: -0.5px;">
46
+ Verify your email address
47
+ </h1>
48
+ <p style="color: #6b7280; font-size: 16px; margin: 0;">
49
+ Enter this code in the app to complete verification.
50
+ </p>
51
+ </div>
52
+
53
+ <!-- Content -->
54
+ <div style="color: #374151; font-size: 16px; line-height: 1.6;">
55
+ ${userName ? `<p style="margin: 0 0 16px 0;">Hi <strong>${userName}</strong>,</p>` : ''}
56
+
57
+ <p style="margin: 0 0 24px 0;">
58
+ Thanks for creating an account with LobeHub. To verify your email address, please use the verification code below:
59
+ </p>
60
+
61
+ <!-- OTP Code Box -->
62
+ <div style="text-align: center; margin: 36px 0;">
63
+ <div style="display: inline-block; background-color: #000000; padding: 24px 48px; border-radius: 14px; box-shadow: 0 4px 12px rgba(0,0,0,0.15);">
64
+ <div style="font-size: 36px; font-weight: 700; letter-spacing: 12px; color: #ffffff; font-family: 'Courier New', Courier, monospace;">
65
+ ${otp}
66
+ </div>
67
+ </div>
68
+ </div>
69
+
70
+ <!-- Expiration Note -->
71
+ <div style="background-color: #f9fafb; border-radius: 12px; padding: 16px; margin-bottom: 24px; border: 1px solid #f3f4f6;">
72
+ <p style="color: #6b7280; font-size: 14px; margin: 0; text-align: center;">
73
+ ⏰ This code will expire in <strong>${expirationText}</strong>.
74
+ </p>
75
+ </div>
76
+
77
+ <p style="color: #6b7280; font-size: 15px; margin: 0 0 8px 0;">
78
+ If you didn't request this code, you can safely ignore this email.
79
+ </p>
80
+ </div>
81
+
82
+ <!-- Divider -->
83
+ <div style="border-top: 1px solid #e5e7eb; margin: 32px 0;"></div>
84
+
85
+ <!-- Security Note -->
86
+ <div style="text-align: center;">
87
+ <p style="color: #9ca3af; font-size: 13px; margin: 0 0 8px 0;">
88
+ 🔒 For security reasons, never share this code with anyone.
89
+ </p>
90
+ </div>
91
+ </div>
92
+
93
+ <!-- Footer -->
94
+ <div style="text-align: center; margin-top: 32px;">
95
+ <p style="color: #a1a1aa; font-size: 13px; margin: 0;">
96
+ © 2025 LobeHub. All rights reserved.
97
+ </p>
98
+ </div>
99
+ </div>
100
+ </body>
101
+ </html>
102
+ `,
103
+ subject: 'Verify Your Email - LobeHub',
104
+ text: `Your verification code is: ${otp}\n\nThis code will expire in ${expirationText}.\n\nIf you didn't request this code, you can safely ignore this email.`,
105
+ };
106
+ };
@@ -1,15 +1,24 @@
1
1
  import { authEnv } from '@/envs/auth';
2
2
  import { getRedisConfig } from '@/envs/redis';
3
3
  import { initializeRedis, isRedisEnabled } from '@/libs/redis';
4
+ import { isDev } from '@/utils/env';
4
5
 
5
6
  const APPLE_TRUSTED_ORIGIN = 'https://appleid.apple.com';
7
+ const MOBILE_APP_SCHEME = 'com.lobehub.app://';
8
+ const EXPO_DEV_SCHEME = 'exp://*/*';
6
9
 
7
10
  /**
8
11
  * Normalize a URL-like string to an origin with https fallback.
12
+ * Returns the original string if it's a custom scheme (e.g., com.lobehub.app://).
9
13
  */
10
14
  export const normalizeOrigin = (url?: string) => {
11
15
  if (!url) return undefined;
12
16
 
17
+ // Handle custom schemes (e.g., mobile app deep links)
18
+ if (url.includes('://') && !url.startsWith('http')) {
19
+ return url;
20
+ }
21
+
13
22
  try {
14
23
  const normalizedUrl = url.startsWith('http') ? url : `https://${url}`;
15
24
 
@@ -25,7 +34,14 @@ export const normalizeOrigin = (url?: string) => {
25
34
  export const getTrustedOrigins = (enabledSSOProviders: string[]) => {
26
35
  if (authEnv.AUTH_TRUSTED_ORIGINS) {
27
36
  const originsFromEnv = authEnv.AUTH_TRUSTED_ORIGINS.split(',')
28
- .map((item) => normalizeOrigin(item.trim()))
37
+ .map((item) => {
38
+ const trimmed = item.trim();
39
+ // Handle custom schemes directly
40
+ if (trimmed.includes('://') && !trimmed.startsWith('http')) {
41
+ return trimmed;
42
+ }
43
+ return normalizeOrigin(trimmed);
44
+ })
29
45
  .filter(Boolean) as string[];
30
46
 
31
47
  if (originsFromEnv.length > 0) return Array.from(new Set(originsFromEnv));
@@ -36,6 +52,9 @@ export const getTrustedOrigins = (enabledSSOProviders: string[]) => {
36
52
  normalizeOrigin(process.env.APP_URL),
37
53
  normalizeOrigin(process.env.VERCEL_BRANCH_URL),
38
54
  normalizeOrigin(process.env.VERCEL_URL),
55
+ MOBILE_APP_SCHEME,
56
+ // Add expo URL in development
57
+ ...(isDev ? [EXPO_DEV_SCHEME] : []),
39
58
  ].filter(Boolean) as string[];
40
59
 
41
60
  const baseTrustedOrigins = defaults.length > 0 ? Array.from(new Set(defaults)) : undefined;