@krutai/auth 0.1.2 → 0.1.4

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.
package/AI_REFERENCE.md CHANGED
@@ -1,33 +1,53 @@
1
- # @krutai/auth - AI Assistant Reference Guide
1
+ # @krutai/auth AI Assistant Reference Guide
2
2
 
3
3
  ## Package Overview
4
4
 
5
- `@krutai/auth` is an authentication package for KrutAI that wraps Better Auth with mandatory API key validation. This package requires users to provide a valid API key to access authentication features.
5
+ - **Name**: `@krutai/auth`
6
+ - **Version**: `0.1.4`
7
+ - **Purpose**: Authentication package for KrutAI — wraps Better Auth with mandatory API key validation
8
+ - **Entry**: `src/index.ts` → `dist/index.{js,mjs,d.ts}`
9
+ - **Build**: `tsup` (CJS + ESM, `better-auth` bundled, `krutai` external peer dep)
6
10
 
7
- ## Installation
11
+ ## Dependency Architecture
8
12
 
9
- ```bash
10
- npm install @krutai/auth
11
13
  ```
14
+ @krutai/auth@0.1.4
15
+ ├── peerDependency: krutai >=0.1.2 ← auto-installed, provides API validation
16
+ ├── dependency: better-sqlite3 ← auto-installed
17
+ └── bundled: better-auth ← included in dist (noExternal)
18
+ ```
19
+
20
+ > **Important for AI**: The validator (`validateApiKeyFormat`, `ApiKeyValidationError`, etc.) is NOT defined in this package. It is imported from `krutai` and re-exported. Do NOT add a local `validator.ts` here.
12
21
 
13
- ## Core Concepts
22
+ ## File Structure
23
+
24
+ ```
25
+ packages/auth/
26
+ ├── src/
27
+ │ ├── index.ts # Barrel export — re-exports from krutai for validator
28
+ │ ├── client.ts # KrutAuth class
29
+ │ ├── types.ts # KrutAuthConfig, AuthSession, BetterAuthOptions
30
+ │ ├── react.ts # createAuthClient (better-auth/react)
31
+ │ └── next-js.ts # toNextJsHandler (better-auth/next-js)
32
+ ├── package.json
33
+ ├── tsconfig.json
34
+ └── tsup.config.ts
35
+ ```
14
36
 
15
- ### API Key Requirement
16
- - **MANDATORY**: All users must provide a valid API key
17
- - API key is validated on initialization (can be disabled with `validateOnInit: false`)
18
- - Throws `ApiKeyValidationError` if API key is missing or invalid
37
+ ## Sub-path Exports
19
38
 
20
- ### Better Auth Integration
21
- - Wraps the Better Auth library
22
- - Provides access to full Better Auth API via `getBetterAuth()`
23
- - See Better Auth docs: https://www.better-auth.com/docs
39
+ | Import | File | Purpose |
40
+ |---|---|---|
41
+ | `@krutai/auth` | `dist/index.js` | Server-side: `betterAuth`, `KrutAuth`, validator re-exports |
42
+ | `@krutai/auth/react` | `dist/react.js` | Client-side: `createAuthClient`, hooks |
43
+ | `@krutai/auth/next-js` | `dist/next-js.js` | Next.js handler: `toNextJsHandler` |
24
44
 
25
45
  ## Main Exports
26
46
 
27
47
  ### Classes
28
48
 
29
49
  #### `KrutAuth`
30
- Main authentication client class.
50
+ Main authentication client.
31
51
 
32
52
  **Constructor:**
33
53
  ```typescript
@@ -35,13 +55,11 @@ new KrutAuth(config: KrutAuthConfig)
35
55
  ```
36
56
 
37
57
  **Methods:**
38
- - `initialize(): Promise<void>` - Validates API key and initializes Better Auth
39
- - `getBetterAuth(): ReturnType<typeof betterAuth>` - Returns Better Auth instance
40
- - `isInitialized(): boolean` - Check if initialized
41
- - `getApiKey(): string` - Get the API key
42
- - `signIn()` - Convenience method (returns Better Auth instance)
43
- - `signOut()` - Convenience method (returns Better Auth instance)
44
- - `getSession()` - Convenience method (returns Better Auth instance)
58
+ - `initialize(): Promise<void>` validates API key + initializes Better Auth
59
+ - `getBetterAuth()` returns the Better Auth instance
60
+ - `isInitialized(): boolean`
61
+ - `getApiKey(): string`
62
+ - `signIn()`, `signOut()`, `getSession()` convenience wrappers
45
63
 
46
64
  ### Types
47
65
 
@@ -58,185 +76,115 @@ interface KrutAuthConfig {
58
76
  #### `AuthSession`
59
77
  ```typescript
60
78
  interface AuthSession {
61
- user: {
62
- id: string;
63
- email: string;
64
- name?: string;
65
- [key: string]: unknown;
66
- };
67
- session: {
68
- id: string;
69
- expiresAt: Date;
70
- [key: string]: unknown;
71
- };
79
+ user: { id: string; email: string; name?: string; [key: string]: unknown };
80
+ session: { id: string; expiresAt: Date; [key: string]: unknown };
72
81
  }
73
82
  ```
74
83
 
75
- ### Errors
84
+ ### Validator Re-exports (from `krutai`)
76
85
 
77
- #### `ApiKeyValidationError`
78
- Thrown when API key validation fails.
86
+ ```typescript
87
+ // These are re-exported from krutai — NOT defined here
88
+ export { validateApiKeyFormat, validateApiKeyWithService, createApiKeyChecker, ApiKeyValidationError } from 'krutai';
89
+ ```
79
90
 
80
- **Common causes:**
81
- - API key is missing or empty
82
- - API key is too short (< 10 characters)
83
- - API key validation fails against backend
91
+ ### Other Re-exports
92
+
93
+ ```typescript
94
+ export { betterAuth } from 'better-auth';
95
+ ```
84
96
 
85
97
  ## Usage Examples
86
98
 
87
- ### Example 1: Basic Usage with Async Validation
99
+ ### Example 1: Basic Server Setup
100
+ ```typescript
101
+ import { betterAuth } from '@krutai/auth';
88
102
 
103
+ export const auth = betterAuth({
104
+ database: { /* config */ },
105
+ });
106
+ ```
107
+
108
+ ### Example 2: KrutAuth with API Key
89
109
  ```typescript
90
110
  import { KrutAuth } from '@krutai/auth';
91
111
 
92
112
  const auth = new KrutAuth({
93
- apiKey: 'your-api-key-here',
113
+ apiKey: process.env.KRUTAI_API_KEY!,
94
114
  betterAuthOptions: {
95
- database: {
96
- // your database config
97
- }
98
- }
115
+ database: { provider: 'postgres', url: process.env.DATABASE_URL },
116
+ emailAndPassword: { enabled: true },
117
+ },
99
118
  });
100
119
 
101
- // Initialize and validate API key
102
120
  await auth.initialize();
103
-
104
- // Get Better Auth instance
105
121
  const betterAuth = auth.getBetterAuth();
106
122
  ```
107
123
 
108
- ### Example 2: Skip Async Validation
109
-
124
+ ### Example 3: Skip Async Validation
110
125
  ```typescript
111
- import { KrutAuth } from '@krutai/auth';
112
-
113
126
  const auth = new KrutAuth({
114
- apiKey: 'your-api-key-here',
127
+ apiKey: process.env.KRUTAI_API_KEY!,
115
128
  validateOnInit: false,
116
- betterAuthOptions: {
117
- // config
118
- }
129
+ betterAuthOptions: { /* config */ },
119
130
  });
120
-
121
131
  // No need to call initialize()
122
132
  const betterAuth = auth.getBetterAuth();
123
133
  ```
124
134
 
125
- ### Example 3: Error Handling
126
-
135
+ ### Example 4: Error Handling
127
136
  ```typescript
128
137
  import { KrutAuth, ApiKeyValidationError } from '@krutai/auth';
129
138
 
130
139
  try {
131
- const auth = new KrutAuth({
132
- apiKey: 'invalid-key'
133
- });
140
+ const auth = new KrutAuth({ apiKey: 'bad' });
134
141
  await auth.initialize();
135
- } catch (error) {
136
- if (error instanceof ApiKeyValidationError) {
137
- console.error('API key validation failed:', error.message);
142
+ } catch (e) {
143
+ if (e instanceof ApiKeyValidationError) {
144
+ console.error('Invalid API key:', e.message);
138
145
  }
139
146
  }
140
147
  ```
141
148
 
142
- ### Example 4: Using Better Auth Features
143
-
149
+ ### Example 5: Next.js Route Handler
144
150
  ```typescript
145
- import { KrutAuth } from '@krutai/auth';
146
-
147
- const auth = new KrutAuth({
148
- apiKey: process.env.KRUTAI_API_KEY!,
149
- betterAuthOptions: {
150
- database: {
151
- provider: 'postgres',
152
- url: process.env.DATABASE_URL
153
- },
154
- emailAndPassword: {
155
- enabled: true
156
- }
157
- }
158
- });
159
-
160
- await auth.initialize();
161
-
162
- // Access full Better Auth API
163
- const betterAuth = auth.getBetterAuth();
151
+ // app/api/auth/[...all]/route.ts
152
+ import { auth } from '@/lib/auth';
153
+ import { toNextJsHandler } from '@krutai/auth/next-js';
164
154
 
165
- // Use Better Auth methods directly
166
- // See: https://www.better-auth.com/docs
167
- ```
168
-
169
- ## Common Patterns
170
-
171
- ### Pattern 1: Environment Variable API Key
172
-
173
- ```typescript
174
- const auth = new KrutAuth({
175
- apiKey: process.env.KRUTAI_API_KEY || '',
176
- betterAuthOptions: {
177
- // config
178
- }
179
- });
155
+ export const { GET, POST } = toNextJsHandler(auth);
180
156
  ```
181
157
 
182
- ### Pattern 2: Singleton Instance
183
-
158
+ ### Example 6: React Client
184
159
  ```typescript
185
- // auth.ts
186
- let authInstance: KrutAuth | null = null;
187
-
188
- export async function getAuth(): Promise<KrutAuth> {
189
- if (!authInstance) {
190
- authInstance = new KrutAuth({
191
- apiKey: process.env.KRUTAI_API_KEY!,
192
- betterAuthOptions: {
193
- // config
194
- }
195
- });
196
- await authInstance.initialize();
197
- }
198
- return authInstance;
199
- }
200
- ```
201
-
202
- ### Pattern 3: Conditional Initialization
160
+ import { createAuthClient } from '@krutai/auth/react';
203
161
 
204
- ```typescript
205
- const auth = new KrutAuth({
206
- apiKey: process.env.KRUTAI_API_KEY!,
207
- validateOnInit: process.env.NODE_ENV === 'production'
162
+ export const authClient = createAuthClient({
163
+ baseURL: process.env.NEXT_PUBLIC_APP_URL ?? 'http://localhost:3000',
208
164
  });
209
-
210
- if (process.env.NODE_ENV === 'production') {
211
- await auth.initialize();
212
- }
165
+ export const { signIn, signUp, signOut, useSession } = authClient;
213
166
  ```
214
167
 
215
- ## TypeScript Support
168
+ ## tsup Configuration Notes
216
169
 
217
- Full TypeScript support with exported types:
218
-
219
- ```typescript
220
- import type {
221
- KrutAuthConfig,
222
- AuthSession,
223
- BetterAuthOptions
224
- } from '@krutai/auth';
225
- ```
170
+ - `better-auth` `noExternal` (bundled into dist)
171
+ - `krutai` → external (peer dep, NOT bundled)
172
+ - `react`, `react-dom`, `next`, `better-sqlite3` → external
226
173
 
227
174
  ## Important Notes
228
175
 
229
- 1. **API Key is Required**: The package will not work without a valid API key
230
- 2. **Better Auth Wrapper**: This is a wrapper around Better Auth, not a replacement
231
- 3. **Validation**: By default, API key is validated on `initialize()` call
232
- 4. **Error Handling**: Always catch `ApiKeyValidationError` for proper error handling
176
+ 1. **Validator lives in `krutai`**: Never add a local `validator.ts` import from `krutai`
177
+ 2. **`krutai` must be external in tsup**: Do NOT add it to `noExternal`
178
+ 3. **`krutai` in devDependencies**: Needed for local TypeScript compilation during development
179
+ 4. **API key validation**: Format check is synchronous (constructor), service check is async (`initialize()`)
233
180
 
234
181
  ## Related Packages
235
182
 
236
- - `krutai` - Main KrutAI package with core utilities
237
- - Future packages: `@krutai/analytics`, `@krutai/roles`, `@krutai/llm`
183
+ - `krutai` Core utilities and API validation (peer dep)
184
+ - `@krutai/rbac` Role-Based Access Control
238
185
 
239
186
  ## Links
240
187
 
241
- - Better Auth Documentation: https://www.better-auth.com/docs
242
- - GitHub Repository: https://github.com/yourusername/krut_packages
188
+ - Better Auth Docs: https://www.better-auth.com/docs
189
+ - GitHub: https://github.com/AccountantAIOrg/krut_packages
190
+ - npm: https://www.npmjs.com/package/@krutai/auth
package/README.md CHANGED
@@ -1,14 +1,15 @@
1
1
  # @krutai/auth
2
2
 
3
- Authentication package for KrutAI powered by [Krut AI](https://www.krut.ai/).
3
+ Authentication package for KrutAI powered by [Better Auth](https://www.better-auth.com/).
4
4
 
5
5
  ## Features
6
6
 
7
- - 🔐 **API Key Protection** - Requires valid API key for access
8
- - 🚀 **Better Auth Integration** - Built on top of Better Auth
9
- - 📦 **TypeScript First** - Full type safety and IntelliSense support
10
- - 🎯 **Simple API** - Easy to use authentication client
11
- - ⚡ **Dual Format** - Supports both ESM and CommonJS
7
+ - 🔐 **API Key Protection** Requires a valid KrutAI API key (validated via `krutai`)
8
+ - 🚀 **Better Auth Integration** Built on top of Better Auth
9
+ - 📦 **Auto-installs `krutai`** The core `krutai` package is installed automatically as a peer dependency
10
+ - 🎯 **Next.js Ready** — First-class support via `@krutai/auth/next-js`
11
+ - ⚡ **Dual Format** Supports both ESM and CommonJS
12
+ - 🔷 **TypeScript First** — Full type safety and IntelliSense
12
13
 
13
14
  ## Installation
14
15
 
@@ -16,190 +17,119 @@ Authentication package for KrutAI powered by [Krut AI](https://www.krut.ai/).
16
17
  npm install @krutai/auth
17
18
  ```
18
19
 
19
- > **Note:** Installing `@krutai/auth` automatically installs the parent `krutai` package, which provides centralized API key validation for all KrutAI packages.
20
+ > **Note:** `krutai` is automatically installed as a peer dependency. `better-sqlite3` is included as a dependency and `better-auth` is bundled no additional packages required.
20
21
 
21
22
  ## Quick Start
22
23
 
23
- ### Basic Usage
24
+ ### Server-side setup (Next.js)
24
25
 
25
26
  ```typescript
26
- import { KrutAuth } from '@krutai/auth';
27
+ // lib/auth.ts
28
+ import { betterAuth } from "@krutai/auth";
27
29
 
28
- // Initialize with your API key
29
- const auth = new KrutAuth({
30
- apiKey: 'your-krutai-api-key',
31
- betterAuthOptions: {
32
- // Better Auth configuration
33
- database: {
34
- // Your database configuration
35
- },
30
+ export const auth = betterAuth({
31
+ database: {
32
+ // your database config
36
33
  },
37
34
  });
38
-
39
- // Initialize the client (validates API key)
40
- await auth.initialize();
41
-
42
- // Use authentication features
43
- const session = await auth.getSession();
44
35
  ```
45
36
 
46
- ### Without Async Initialization
47
-
48
- If you want to skip async validation on initialization:
37
+ ### API Route handler
49
38
 
50
39
  ```typescript
51
- const auth = new KrutAuth({
52
- apiKey: 'your-krutai-api-key',
53
- validateOnInit: false,
54
- betterAuthOptions: {
55
- // Better Auth configuration
56
- },
57
- });
58
-
59
- // No need to call initialize()
60
- const betterAuth = auth.getBetterAuth();
61
- ```
62
-
63
- ## API Reference
64
-
65
- ### `KrutAuth`
40
+ // app/api/auth/[...all]/route.ts
41
+ import { auth } from "@/lib/auth";
42
+ import { toNextJsHandler } from "@krutai/auth/next-js";
66
43
 
67
- Main authentication client class.
68
-
69
- #### Constructor
70
-
71
- ```typescript
72
- new KrutAuth(config: KrutAuthConfig)
44
+ export const { GET, POST } = toNextJsHandler(auth);
73
45
  ```
74
46
 
75
- **Parameters:**
76
-
77
- - `config.apiKey` (required): Your KrutAI API key
78
- - `config.betterAuthOptions` (optional): Better Auth configuration options
79
- - `config.validateOnInit` (optional): Whether to validate API key on initialization (default: `true`)
80
- - `config.validationEndpoint` (optional): Custom API validation endpoint
81
-
82
- **Throws:**
83
-
84
- - `ApiKeyValidationError` if the API key format is invalid
85
-
86
- #### Methods
87
-
88
- ##### `initialize()`
89
-
90
- Validates the API key and initializes the Better Auth instance.
47
+ ### Client-side (React / Next.js)
91
48
 
92
49
  ```typescript
93
- await auth.initialize();
94
- ```
50
+ // lib/auth-client.ts
51
+ import { createAuthClient } from "@krutai/auth/react";
95
52
 
96
- **Returns:** `Promise<void>`
97
-
98
- **Throws:** `ApiKeyValidationError` if validation fails
99
-
100
- ##### `getBetterAuth()`
101
-
102
- Gets the underlying Better Auth instance for advanced usage.
53
+ export const authClient = createAuthClient({
54
+ baseURL: process.env.NEXT_PUBLIC_APP_URL ?? "http://localhost:3000",
55
+ });
103
56
 
104
- ```typescript
105
- const betterAuth = auth.getBetterAuth();
57
+ export const { signIn, signUp, signOut, useSession } = authClient;
106
58
  ```
107
59
 
108
- **Returns:** `BetterAuth`
109
-
110
- **Throws:** `Error` if not initialized
111
-
112
- ##### `isInitialized()`
113
-
114
- Checks if the client is initialized.
60
+ ### With API Key Validation
115
61
 
116
62
  ```typescript
117
- const ready = auth.isInitialized();
118
- ```
119
-
120
- **Returns:** `boolean`
63
+ import { KrutAuth } from "@krutai/auth";
121
64
 
122
- ##### `getApiKey()`
123
-
124
- Gets the API key (useful for making authenticated requests).
65
+ const auth = new KrutAuth({
66
+ apiKey: "your-krutai-api-key",
67
+ betterAuthOptions: {
68
+ database: { /* your database config */ },
69
+ },
70
+ });
125
71
 
126
- ```typescript
127
- const apiKey = auth.getApiKey();
72
+ await auth.initialize();
128
73
  ```
129
74
 
130
- **Returns:** `string`
75
+ ## Exports
131
76
 
132
- ## Architecture
77
+ | Import path | What it provides |
78
+ |---|---|
79
+ | `@krutai/auth` | `betterAuth`, `KrutAuth`, validator re-exports from `krutai` |
80
+ | `@krutai/auth/react` | `createAuthClient`, `useSession`, etc. |
81
+ | `@krutai/auth/next-js` | `toNextJsHandler` |
133
82
 
134
- ### Dependency on Parent Package
83
+ ## API Reference
135
84
 
136
- `@krutai/auth` depends on the parent `krutai` package for API key validation:
85
+ ### `KrutAuth`
137
86
 
138
- ```
139
- @krutai/auth
140
- └── krutai (parent)
141
- └── Provides: validateApiKeyFormat, validateApiKeyWithService, etc.
142
- ```
87
+ #### Constructor options
143
88
 
144
- **Benefits:**
145
- - ✅ All `@krutai/*` packages use the same validation logic from `krutai`
146
- -No code duplication across packages
147
- - Consistent API key handling
148
- - Centralized validation updates benefit all packages
89
+ | Option | Type | Required | Description |
90
+ |---|---|---|---|
91
+ | `apiKey` | `string` | | Your KrutAI API key |
92
+ | `betterAuthOptions` | `object` | — | Better Auth configuration |
93
+ | `validateOnInit` | `boolean` | | Validate API key on init (default: `true`) |
94
+ | `validationEndpoint` | `string` | — | Custom validation endpoint |
149
95
 
150
- You can also use the validation utilities directly:
96
+ #### Methods
151
97
 
152
- ```typescript
153
- import { validateApiKeyFormat, ApiKeyValidationError } from '@krutai/auth';
154
- // or
155
- import { validateApiKeyFormat, ApiKeyValidationError } from 'krutai';
156
- ```
98
+ - `initialize()` — Validates API key and sets up Better Auth
99
+ - `getBetterAuth()` Returns the underlying Better Auth instance
100
+ - `isInitialized()` — Returns `boolean`
101
+ - `getApiKey()` Returns the API key string
157
102
 
158
103
  ## Error Handling
159
104
 
160
- The package throws `ApiKeyValidationError` (from parent `krutai` package) when:
161
-
162
- - API key is not provided
163
- - API key is empty or invalid format
164
- - API key validation fails (if `validateOnInit` is `true`)
165
-
166
105
  ```typescript
167
- import { KrutAuth, ApiKeyValidationError } from '@krutai/auth';
106
+ import { KrutAuth, ApiKeyValidationError } from "@krutai/auth";
168
107
 
169
108
  try {
170
- const auth = new KrutAuth({
171
- apiKey: 'invalid-key',
172
- });
109
+ const auth = new KrutAuth({ apiKey: "invalid" });
173
110
  await auth.initialize();
174
111
  } catch (error) {
175
112
  if (error instanceof ApiKeyValidationError) {
176
- console.error('API key validation failed:', error.message);
113
+ console.error("API key validation failed:", error.message);
177
114
  }
178
115
  }
179
116
  ```
180
117
 
181
- ## Better Auth Integration
118
+ > `ApiKeyValidationError` is re-exported from `krutai` — the single source of truth for API validation across the KrutAI ecosystem.
182
119
 
183
- This package wraps [Better Auth](https://www.better-auth.com/) and adds API key validation. You can access the full Better Auth API through the `getBetterAuth()` method:
120
+ ## Architecture
184
121
 
185
- ```typescript
186
- const auth = new KrutAuth({ apiKey: 'your-key' });
187
- await auth.initialize();
122
+ `@krutai/auth` depends on `krutai` (auto-installed as a peer dependency) for API key validation. `better-auth` is bundled into the output and `better-sqlite3` is auto-installed as a dependency.
188
123
 
189
- const betterAuth = auth.getBetterAuth();
190
- // Use Better Auth features directly
124
+ ```
125
+ @krutai/auth@0.1.4
126
+ ├── peerDependency: krutai >=0.1.2 (auto-installed)
127
+ ├── dependency: better-sqlite3
128
+ └── bundled: better-auth
191
129
  ```
192
130
 
193
131
  For Better Auth documentation, visit: https://www.better-auth.com/docs
194
132
 
195
- ## TypeScript Support
196
-
197
- Full TypeScript support with exported types:
198
-
199
- ```typescript
200
- import type { KrutAuthConfig, AuthSession, BetterAuthOptions } from '@krutai/auth';
201
- ```
202
-
203
133
  ## License
204
134
 
205
135
  MIT
package/dist/index.d.mts CHANGED
@@ -1,6 +1,7 @@
1
1
  import * as better_auth from 'better-auth';
2
2
  import { BetterAuthOptions, betterAuth } from 'better-auth';
3
3
  export { BetterAuthOptions, betterAuth } from 'better-auth';
4
+ export { ApiKeyValidationError, createApiKeyChecker, validateApiKeyFormat, validateApiKeyWithService } from 'krutai';
4
5
 
5
6
  /**
6
7
  * Configuration options for KrutAuth
@@ -121,50 +122,10 @@ declare class KrutAuth {
121
122
  getSession(): Promise<better_auth.Auth<better_auth.BetterAuthOptions>>;
122
123
  }
123
124
 
124
- /**
125
- * API Key Validation Module
126
- *
127
- * Centralized API key validation for @krutai/auth.
128
- * This is bundled directly into @krutai/auth so no separate `krutai` package install is needed.
129
- */
130
- /**
131
- * Custom error for API key validation failures
132
- */
133
- declare class ApiKeyValidationError extends Error {
134
- constructor(message: string);
135
- }
136
- /**
137
- * Validates the format of an API key
138
- * @param apiKey - The API key to validate
139
- * @throws {ApiKeyValidationError} If the API key format is invalid
140
- */
141
- declare function validateApiKeyFormat(apiKey: string): void;
142
- /**
143
- * Validates an API key with the KrutAI service
144
- * @param apiKey - The API key to validate
145
- * @returns Promise that resolves to true if valid, false otherwise
146
- */
147
- declare function validateApiKeyWithService(apiKey: string): Promise<boolean>;
148
- /**
149
- * Creates a validated API key checker function
150
- * @param apiKey - The API key to validate
151
- * @returns A function that checks if the API key is valid
152
- */
153
- declare function createApiKeyChecker(apiKey: string): {
154
- /**
155
- * Validates the API key (cached after first call)
156
- */
157
- validate(): Promise<boolean>;
158
- /**
159
- * Resets the validation cache
160
- */
161
- reset(): void;
162
- };
163
-
164
125
  /**
165
126
  * @krutai/auth - Authentication package for KrutAI
166
127
  *
167
- * Everything is bundled no need to separately install `krutai` or `better-auth`.
128
+ * Requires `krutai` as a peer dependency (installed automatically).
168
129
  *
169
130
  * @example Server-side (Next.js API route / server component)
170
131
  * ```typescript
@@ -189,4 +150,4 @@ declare function createApiKeyChecker(apiKey: string): {
189
150
 
190
151
  declare const VERSION = "0.1.2";
191
152
 
192
- export { ApiKeyValidationError, type AuthSession, KrutAuth, type KrutAuthConfig, VERSION, createApiKeyChecker, validateApiKeyFormat, validateApiKeyWithService };
153
+ export { type AuthSession, KrutAuth, type KrutAuthConfig, VERSION };