Skip to content

Commit 248b513

Browse files
committed
chore(deps): upgrade better-auth from 1.3.12 to 1.4.18
1 parent ab48787 commit 248b513

File tree

7 files changed

+60
-134
lines changed

7 files changed

+60
-134
lines changed

apps/sim/app/api/auth/forget-password/route.test.ts

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ vi.mock('@/lib/core/utils/urls', () => ({
2121
function setupAuthApiMocks(
2222
options: {
2323
operations?: {
24-
forgetPassword?: { success?: boolean; error?: string }
24+
requestPasswordReset?: { success?: boolean; error?: string }
2525
resetPassword?: { success?: boolean; error?: string }
2626
}
2727
} = {}
@@ -34,7 +34,11 @@ function setupAuthApiMocks(
3434

3535
const { operations = {} } = options
3636
const defaultOperations = {
37-
forgetPassword: { success: true, error: 'Forget password error', ...operations.forgetPassword },
37+
requestPasswordReset: {
38+
success: true,
39+
error: 'Forget password error',
40+
...operations.requestPasswordReset,
41+
},
3842
resetPassword: { success: true, error: 'Reset password error', ...operations.resetPassword },
3943
}
4044

@@ -50,7 +54,7 @@ function setupAuthApiMocks(
5054
vi.doMock('@/lib/auth', () => ({
5155
auth: {
5256
api: {
53-
forgetPassword: createAuthMethod(defaultOperations.forgetPassword),
57+
requestPasswordReset: createAuthMethod(defaultOperations.requestPasswordReset),
5458
resetPassword: createAuthMethod(defaultOperations.resetPassword),
5559
},
5660
},
@@ -69,7 +73,7 @@ describe('Forget Password API Route', () => {
6973
it('should send password reset email successfully with same-origin redirectTo', async () => {
7074
setupAuthApiMocks({
7175
operations: {
72-
forgetPassword: { success: true },
76+
requestPasswordReset: { success: true },
7377
},
7478
})
7579

@@ -87,7 +91,7 @@ describe('Forget Password API Route', () => {
8791
expect(data.success).toBe(true)
8892

8993
const auth = await import('@/lib/auth')
90-
expect(auth.auth.api.forgetPassword).toHaveBeenCalledWith({
94+
expect(auth.auth.api.requestPasswordReset).toHaveBeenCalledWith({
9195
body: {
9296
email: 'test@example.com',
9397
redirectTo: 'https://app.example.com/reset',
@@ -99,7 +103,7 @@ describe('Forget Password API Route', () => {
99103
it('should reject external redirectTo URL', async () => {
100104
setupAuthApiMocks({
101105
operations: {
102-
forgetPassword: { success: true },
106+
requestPasswordReset: { success: true },
103107
},
104108
})
105109

@@ -117,13 +121,13 @@ describe('Forget Password API Route', () => {
117121
expect(data.message).toBe('Redirect URL must be a valid same-origin URL')
118122

119123
const auth = await import('@/lib/auth')
120-
expect(auth.auth.api.forgetPassword).not.toHaveBeenCalled()
124+
expect(auth.auth.api.requestPasswordReset).not.toHaveBeenCalled()
121125
})
122126

123127
it('should send password reset email without redirectTo', async () => {
124128
setupAuthApiMocks({
125129
operations: {
126-
forgetPassword: { success: true },
130+
requestPasswordReset: { success: true },
127131
},
128132
})
129133

@@ -140,7 +144,7 @@ describe('Forget Password API Route', () => {
140144
expect(data.success).toBe(true)
141145

142146
const auth = await import('@/lib/auth')
143-
expect(auth.auth.api.forgetPassword).toHaveBeenCalledWith({
147+
expect(auth.auth.api.requestPasswordReset).toHaveBeenCalledWith({
144148
body: {
145149
email: 'test@example.com',
146150
redirectTo: undefined,
@@ -163,7 +167,7 @@ describe('Forget Password API Route', () => {
163167
expect(data.message).toBe('Email is required')
164168

165169
const auth = await import('@/lib/auth')
166-
expect(auth.auth.api.forgetPassword).not.toHaveBeenCalled()
170+
expect(auth.auth.api.requestPasswordReset).not.toHaveBeenCalled()
167171
})
168172

169173
it('should handle empty email', async () => {
@@ -182,15 +186,15 @@ describe('Forget Password API Route', () => {
182186
expect(data.message).toBe('Please provide a valid email address')
183187

184188
const auth = await import('@/lib/auth')
185-
expect(auth.auth.api.forgetPassword).not.toHaveBeenCalled()
189+
expect(auth.auth.api.requestPasswordReset).not.toHaveBeenCalled()
186190
})
187191

188192
it('should handle auth service error with message', async () => {
189193
const errorMessage = 'User not found'
190194

191195
setupAuthApiMocks({
192196
operations: {
193-
forgetPassword: {
197+
requestPasswordReset: {
194198
success: false,
195199
error: errorMessage,
196200
},
@@ -222,7 +226,7 @@ describe('Forget Password API Route', () => {
222226
vi.doMock('@/lib/auth', () => ({
223227
auth: {
224228
api: {
225-
forgetPassword: vi.fn().mockRejectedValue('Unknown error'),
229+
requestPasswordReset: vi.fn().mockRejectedValue('Unknown error'),
226230
},
227231
},
228232
}))

apps/sim/app/api/auth/forget-password/route.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ export async function POST(request: NextRequest) {
4343

4444
const { email, redirectTo } = validationResult.data
4545

46-
await auth.api.forgetPassword({
46+
await auth.api.requestPasswordReset({
4747
body: {
4848
email,
4949
redirectTo,

apps/sim/app/api/auth/reset-password/route.test.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
1717
function setupAuthApiMocks(
1818
options: {
1919
operations?: {
20-
forgetPassword?: { success?: boolean; error?: string }
20+
requestPasswordReset?: { success?: boolean; error?: string }
2121
resetPassword?: { success?: boolean; error?: string }
2222
}
2323
} = {}
@@ -30,7 +30,11 @@ function setupAuthApiMocks(
3030

3131
const { operations = {} } = options
3232
const defaultOperations = {
33-
forgetPassword: { success: true, error: 'Forget password error', ...operations.forgetPassword },
33+
requestPasswordReset: {
34+
success: true,
35+
error: 'Forget password error',
36+
...operations.requestPasswordReset,
37+
},
3438
resetPassword: { success: true, error: 'Reset password error', ...operations.resetPassword },
3539
}
3640

@@ -46,7 +50,7 @@ function setupAuthApiMocks(
4650
vi.doMock('@/lib/auth', () => ({
4751
auth: {
4852
api: {
49-
forgetPassword: createAuthMethod(defaultOperations.forgetPassword),
53+
requestPasswordReset: createAuthMethod(defaultOperations.requestPasswordReset),
5054
resetPassword: createAuthMethod(defaultOperations.resetPassword),
5155
},
5256
},

apps/sim/lib/auth/auth.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,7 @@ export const auth = betterAuth({
466466
sendVerificationOnSignUp: isEmailVerificationEnabled, // Auto-send verification OTP on signup when verification is required
467467
throwOnMissingCredentials: true,
468468
throwOnInvalidCredentials: true,
469-
sendResetPassword: async ({ user, url, token }, request) => {
469+
sendResetPassword: async ({ user, url, token }, ctx) => {
470470
const username = user.name || ''
471471

472472
const html = await renderPasswordResetEmail(username, url)
@@ -542,7 +542,7 @@ export const auth = betterAuth({
542542
plugins: [
543543
nextCookies(),
544544
oneTimeToken({
545-
expiresIn: 24 * 60 * 60, // 24 hours - Socket.IO handles connection persistence with heartbeats
545+
expiresIn: 24 * 60, // 24 hours in minutes - Socket.IO handles connection persistence with heartbeats
546546
}),
547547
customSession(async ({ user, session }) => ({
548548
user,
@@ -2876,9 +2876,9 @@ export const auth = betterAuth({
28762876

28772877
return hasTeamPlan
28782878
},
2879-
organizationCreation: {
2880-
afterCreate: async ({ organization, user }) => {
2881-
logger.info('[organizationCreation.afterCreate] Organization created', {
2879+
organizationHooks: {
2880+
afterCreateOrganization: async ({ organization, member, user }) => {
2881+
logger.info('[organizationHooks.afterCreateOrganization] Organization created', {
28822882
organizationId: organization.id,
28832883
creatorId: user.id,
28842884
})

apps/sim/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@
3535
"@aws-sdk/s3-request-presigner": "^3.779.0",
3636
"@azure/communication-email": "1.0.0",
3737
"@azure/storage-blob": "12.27.0",
38-
"@better-auth/sso": "1.3.12",
39-
"@better-auth/stripe": "1.3.12",
38+
"@better-auth/sso": "1.4.18",
39+
"@better-auth/stripe": "1.4.18",
4040
"@browserbasehq/stagehand": "^3.0.5",
4141
"@cerebras/cerebras_cloud_sdk": "^1.23.0",
4242
"@e2b/code-interpreter": "^2.0.0",
@@ -82,7 +82,7 @@
8282
"@trigger.dev/sdk": "4.1.2",
8383
"@types/react-window": "2.0.0",
8484
"@types/three": "0.177.0",
85-
"better-auth": "1.3.12",
85+
"better-auth": "1.4.18",
8686
"binary-extensions": "^2.0.0",
8787
"browser-image-compression": "^2.0.2",
8888
"chalk": "5.6.2",

0 commit comments

Comments
 (0)