feat: add local auth billing and usage management

This commit is contained in:
inman committed 2026-08-12 12:13:06 +08:00
1 parent f642b5e71f
commit 196fdde83f
119 files changed
+15695 -2650

No files matched your search

+3 -2
View File
@@ -1,7 +1,7 @@
import { createPublicKey, createVerify } from "node:crypto";
import type { JsonWebKey as CryptoJsonWebKey, KeyObject } from "node:crypto";
import { getAuthRuntimeConfig, type AuthRuntimeConfig } from "@/lib/auth/config";
import type { AuthSession, AuthUser } from "@/lib/auth/session";
import type { AuthMode, AuthSession, AuthUser } from "@/lib/auth/session";
export type AuthTokenClaims = {
iss?: string;
@@ -76,7 +76,7 @@ export function createSessionFromClaims(
claims: AuthTokenClaims,
config: AuthRuntimeConfig,
tokenResponseExpiresIn?: number,
token?: { accessToken?: string; tokenType?: string }
token?: { accessToken?: string; tokenType?: string; authMode?: AuthMode }
): AuthSession {
const now = Math.floor(Date.now() / 1000);
const jwtExpiry = numberClaim(claims.exp);
@@ -84,6 +84,7 @@ export function createSessionFromClaims(
const expiresAt = Math.min(jwtExpiry || responseExpiry || now, responseExpiry || jwtExpiry || now);
return {
version: 1,
authMode: token?.authMode === "admin" ? "admin" : "user",
user: userFromClaims(claims, config),
issuedAt: now,
expiresAt,