first commit

This commit is contained in:
2026-04-01 15:17:46 +02:00
commit d50ab5f7bf
19 changed files with 2554 additions and 0 deletions

136
dist/server/index.d.ts vendored Normal file
View File

@@ -0,0 +1,136 @@
import * as qs from 'qs';
import * as express_serve_static_core from 'express-serve-static-core';
import * as express from 'express';
import { Request, RequestHandler, Express } from 'express';
import * as _auth_core_adapters from '@auth/core/adapters';
type CredentialUser = {
id: string;
name: string | null;
email: string | null;
image?: string | null;
passwordHash: string | null;
};
type CreateAuthModuleOptions<TAuthUser> = {
prisma: any;
clientUrl: string;
sessionCookieName: string;
sessionCookieSecure: boolean;
authUrl?: string;
authDebug?: boolean;
authSecret?: string;
trustHost?: boolean;
extraSessionCookieNames?: string[];
signInPath?: string;
authenticatedRedirectPath?: string;
googleClientId?: string;
googleClientSecret?: string;
slackClientId?: string;
slackClientSecret?: string;
findCredentialsUserByEmail: (email: string) => Promise<CredentialUser | null>;
comparePassword: (password: string, passwordHash: string) => Promise<boolean>;
sessionUserSelect: Record<string, boolean>;
mapSessionUser: (user: any) => TAuthUser;
onSessionValidated?: (user: TAuthUser) => Promise<void> | void;
};
declare function createAuthModule<TAuthUser>(options: CreateAuthModuleOptions<TAuthUser>): {
authConfig: {
adapter: _auth_core_adapters.Adapter;
trustHost: boolean;
debug: boolean;
logger: {
error(error: Error): void;
warn(code: string): void;
debug(message: string, metadata?: unknown): void;
} | undefined;
session: {
strategy: "database";
};
secret: string | undefined;
cookies: {
sessionToken: {
name: string;
options: {
httpOnly: boolean;
sameSite: "lax";
path: string;
secure: boolean;
};
};
};
providers: any[];
pages: {
signIn: string;
};
callbacks: {
redirect: ({ url, baseUrl }: {
url: string;
baseUrl: string;
}) => Promise<string>;
};
};
authHandler: (req: Request, res: express.Response, next: express.NextFunction) => Promise<void>;
requireSession: RequestHandler<express_serve_static_core.ParamsDictionary, any, any, qs.ParsedQs, Record<string, any>>;
extractSessionToken: (cookieHeader: string | undefined) => string | null;
googleAuthEnabled: boolean;
slackAuthEnabled: boolean;
};
type RegisterAuthApiRoutesOptions = {
app: Express;
prisma: any;
authHandler: RequestHandler;
requireSession: RequestHandler;
extractSessionToken: (cookieHeader: string | undefined) => string | null;
providersAvailability: Record<string, boolean>;
sessionCookieName: string;
sessionCookieSecure: boolean;
extraCookieNamesToClear?: string[];
messages?: Partial<AuthRouteMessages>;
authBasePath?: string;
authApiBasePath?: string;
mePath?: string;
normalizeEmail?: (email: string) => string;
passwordHasher?: (password: string) => Promise<string>;
passwordComparator?: (password: string, passwordHash: string) => Promise<boolean>;
passwordReset?: {
enabled: boolean;
tokenTtlMs?: number;
identifierPrefix?: string;
buildResetUrl: (token: string) => string;
sendMessage: (input: {
user: {
id: string;
email: string;
name: string | null;
passwordHash: string | null;
};
resetUrl: string;
isPasswordCreation: boolean;
expiresAt: Date;
}) => Promise<void>;
};
onUserRegistered?: (user: {
id: string;
email: string | null;
name: string | null;
}) => Promise<void> | void;
onPasswordResetConfirmed?: (user: {
id: string;
email: string | null;
name: string | null;
}) => Promise<void> | void;
};
type AuthRouteMessages = {
invalidPayload: string;
emailAlreadyUsed: string;
accountNotFound: string;
externalAccountOnly: string;
invalidPassword: string;
passwordResetUnavailable: string;
invalidResetLink: string;
expiredResetLink: string;
};
declare function registerAuthApiRoutes(options: RegisterAuthApiRoutesOptions): void;
export { createAuthModule, registerAuthApiRoutes };