refactor: add BetterAuthPlugin type to loginLink and tokenExchange functions
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
import * as schema from '@db/schema';
|
import * as schema from '@db/schema';
|
||||||
|
|
||||||
|
import type { BetterAuthPlugin } from 'better-auth';
|
||||||
import { createAuthEndpoint } from 'better-auth/api';
|
import { createAuthEndpoint } from 'better-auth/api';
|
||||||
import { setSessionCookie as _setSessionCookie } from 'better-auth/cookies';
|
import { setSessionCookie as _setSessionCookie } from 'better-auth/cookies';
|
||||||
const setSessionCookie = _setSessionCookie as (
|
const setSessionCookie = _setSessionCookie as (
|
||||||
@@ -30,7 +31,7 @@ function getLoginLinkSecret(): Uint8Array {
|
|||||||
return new TextEncoder().encode(secret);
|
return new TextEncoder().encode(secret);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function loginLink() {
|
export function loginLink(): BetterAuthPlugin {
|
||||||
return {
|
return {
|
||||||
id: 'login-link',
|
id: 'login-link',
|
||||||
endpoints: {
|
endpoints: {
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import * as schema from '@db/schema';
|
import * as schema from '@db/schema';
|
||||||
|
|
||||||
|
import type { BetterAuthPlugin } from 'better-auth';
|
||||||
import { createAuthEndpoint } from 'better-auth/api';
|
import { createAuthEndpoint } from 'better-auth/api';
|
||||||
// Session cookie helper: runtime accepts (ctx, { session, user }), typings show 1 arg
|
// Session cookie helper: runtime accepts (ctx, { session, user }), typings show 1 arg
|
||||||
import { setSessionCookie as _setSessionCookie } from 'better-auth/cookies';
|
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('');
|
return Array.from(bytes, (b) => b.toString(16).padStart(2, '0')).join('');
|
||||||
}
|
}
|
||||||
|
|
||||||
export function tokenExchange() {
|
export function tokenExchange(): BetterAuthPlugin {
|
||||||
return {
|
return {
|
||||||
id: 'token-exchange',
|
id: 'token-exchange',
|
||||||
endpoints: {
|
endpoints: {
|
||||||
|
|||||||
Reference in New Issue
Block a user