dbc9a0cd13
- Inline NextAuth v4 handler directly in `[...nextauth]/route.ts`, removing
the `@/lib/auth/nextauth` abstraction layer
- Add Google/Facebook providers with JWT/session callbacks that expose
`idToken` and `accessToken` on the session for backend exchange
- Refactor `AuthPlatform` from constructor-based to static methods
(`googleSignIn()` / `facebookSignIn()`)
- Update `auth-machine.ts` and layout comment reference to match new structure
- Align with original Dart `nextauth-helpers.{googleLogin, facebookLogin}()`
naming and keep persistence concerns (unstorage, backend, custom cookies)
out of scope for this iteration
26 lines
856 B
TypeScript
26 lines
856 B
TypeScript
import "next-auth";
|
||
|
||
/**
|
||
* 扩展 next-auth v4 的 Session 类型
|
||
*
|
||
* `src/app/api/auth/[...nextauth]/route.ts` 的 jwt/session callbacks 把
|
||
* - OAuth provider 名("google" | "facebook")
|
||
* - Google id_token
|
||
* - Facebook access_token
|
||
* 塞进了 session 对象。
|
||
*
|
||
* 这里通过 TS 声明合并暴露给 `useSession()` 消费者。
|
||
*
|
||
* 注:声明文件全局生效(`globals.d.ts` 风格)—— 不用手动 import。
|
||
*/
|
||
declare module "next-auth" {
|
||
interface Session {
|
||
/** OAuth provider 名(首次 sign-in 时由 jwt callback 注入) */
|
||
provider?: "google" | "facebook";
|
||
/** Google OAuth id_token —— 调后端 /api/auth/google-login 换业务 token */
|
||
idToken?: string;
|
||
/** Facebook OAuth access_token —— 调后端 /api/auth/facebook-login 换业务 token */
|
||
accessToken?: string;
|
||
}
|
||
}
|