vinextauth 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- import { A as AdapterInterface } from '../types-G_m6Z3Iz.js';
1
+ import { b as AdapterInterface } from '../types-Bsno2U1C.js';
2
2
 
3
3
  interface KVNamespace {
4
4
  get(key: string, options: {
package/dist/index.d.ts CHANGED
@@ -1,15 +1,50 @@
1
- import { V as VinextAuthConfig, a as VinextAuthHandlers } from './types-G_m6Z3Iz.js';
2
- export { A as AdapterInterface, b as AdapterSession, C as CallbacksConfig, J as JWT, c as JWTCallbackParams, d as JWTConfig, O as OAuthProvider, P as PagesConfig, S as Session, e as SessionCallbackParams, f as SessionConfig, g as SessionContextValue, h as SessionStatus, i as SignInCallbackParams, j as SignInOptions, k as SignOutOptions, U as User, W as WithAuthOptions } from './types-G_m6Z3Iz.js';
1
+ import { V as VinextAuthConfig, a as VinextAuthHandlers, R as RateLimiter } from './types-Bsno2U1C.js';
2
+ export { A as AccountLinkingConfig, b as AdapterInterface, c as AdapterSession, C as CallbacksConfig, d as CredentialsConfig, e as CredentialsProvider, D as DefaultJWT, f as DefaultSession, g as DefaultUser, J as JWT, h as JWTCallbackParams, i as JWTConfig, O as OAuthProvider, P as PagesConfig, j as Provider, k as RefreshTokenCallbackParams, l as RefreshTokenCallbackResult, S as Session, m as SessionCallbackParams, n as SessionConfig, o as SessionContextValue, p as SessionStatus, q as SignInCallbackParams, r as SignInOptions, s as SignOutOptions, U as User, t as VinextAuthError, u as VinextAuthErrorCode, W as WithAuthOptions } from './types-Bsno2U1C.js';
3
3
 
4
4
  /**
5
5
  * VinextAuth — main factory function.
6
6
  *
7
- * Usage (identical to NextAuth v4):
7
+ * Generics let you type your custom session and token fields without
8
+ * module augmentation (unlike NextAuth).
9
+ *
10
+ * @example
8
11
  * ```ts
9
- * const handler = VinextAuth(authOptions)
12
+ * // With custom types — no module augmentation needed
13
+ * const handler = VinextAuth<{ role: "admin" | "user" }, { role: string }>({
14
+ * providers: [GoogleProvider({ clientId, clientSecret })],
15
+ * callbacks: {
16
+ * jwt({ token, user }) {
17
+ * if (user) token.role = user.role // TypeScript knows this!
18
+ * return token
19
+ * },
20
+ * session({ session, token }) {
21
+ * session.user.role = token.role // Fully typed
22
+ * return session
23
+ * }
24
+ * }
25
+ * })
10
26
  * export { handler as GET, handler as POST }
11
27
  * ```
12
28
  */
13
- declare function VinextAuth(config: VinextAuthConfig): VinextAuthHandlers;
29
+ declare function VinextAuth<TSession = {}, TToken = {}, TUser = {}>(config: VinextAuthConfig<TSession, TToken, TUser>): VinextAuthHandlers;
30
+
31
+ /**
32
+ * In-memory rate limiter.
33
+ * For production, use a Redis or KV-backed store via the `store` option.
34
+ *
35
+ * Automatically cleans up expired entries every 5 minutes.
36
+ */
37
+ declare class InMemoryRateLimiter implements RateLimiter {
38
+ private store;
39
+ private maxAttempts;
40
+ private windowMs;
41
+ constructor(maxAttempts?: number, windowMs?: number);
42
+ check(key: string): Promise<{
43
+ allowed: boolean;
44
+ retryAfter?: number;
45
+ }>;
46
+ reset(key: string): Promise<void>;
47
+ private cleanup;
48
+ }
14
49
 
15
- export { VinextAuth, VinextAuthConfig, VinextAuthHandlers, VinextAuth as default };
50
+ export { InMemoryRateLimiter, RateLimiter, VinextAuth, VinextAuthConfig, VinextAuthHandlers, VinextAuth as default };