refactor: add BetterAuthPlugin type to loginLink and tokenExchange functions

This commit is contained in:
Rotimi Best
2026-03-16 05:25:14 +01:00
parent c23a82762d
commit 5a68d1bd7c
2 changed files with 4 additions and 2 deletions
+2 -1
View File
@@ -1,5 +1,6 @@
import * as schema from '@db/schema';
import type { BetterAuthPlugin } from 'better-auth';
import { createAuthEndpoint } from 'better-auth/api';
import { setSessionCookie as _setSessionCookie } from 'better-auth/cookies';
const setSessionCookie = _setSessionCookie as (
@@ -30,7 +31,7 @@ function getLoginLinkSecret(): Uint8Array {
return new TextEncoder().encode(secret);
}
export function loginLink() {
export function loginLink(): BetterAuthPlugin {
return {
id: 'login-link',
endpoints: {
@@ -1,5 +1,6 @@
import * as schema from '@db/schema';
import type { BetterAuthPlugin } from 'better-auth';
import { createAuthEndpoint } from 'better-auth/api';
// Session cookie helper: runtime accepts (ctx, { session, user }), typings show 1 arg
import { setSessionCookie as _setSessionCookie } from 'better-auth/cookies';
@@ -21,7 +22,7 @@ function generateToken(): string {
return Array.from(bytes, (b) => b.toString(16).padStart(2, '0')).join('');
}
export function tokenExchange() {
export function tokenExchange(): BetterAuthPlugin {
return {
id: 'token-exchange',
endpoints: {