@krutai/auth 0.1.7 → 0.1.8

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
@@ -3,7 +3,7 @@
3
3
  ## Package Overview
4
4
 
5
5
  - **Name**: `@krutai/auth`
6
- - **Version**: `0.1.7`
6
+ - **Version**: `0.1.8`
7
7
  - **Purpose**: Authentication package for KrutAI — wraps Better Auth with a `krutAuth` function and optional API key validation via `KrutAuth` class
8
8
  - **Entry**: `src/index.ts` → `dist/index.{js,mjs,d.ts}`
9
9
  - **Build**: `tsup` (CJS + ESM, all deps external)
@@ -11,7 +11,7 @@
11
11
  ## Dependency Architecture
12
12
 
13
13
  ```
14
- @krutai/auth@0.1.7
14
+ @krutai/auth@0.1.8
15
15
  ├── dependency: krutai ← API key validation (also peerDep)
16
16
  ├── dependency: better-auth ← auth engine (external in tsup)
17
17
  ├── dependency: better-sqlite3 ← default SQLite adapter
@@ -30,6 +30,8 @@ packages/auth/
30
30
  │ ├── types.ts # KrutAuthConfig, AuthSession, BetterAuthOptions
31
31
  │ ├── react.ts # re-exports better-auth/react (createAuthClient, hooks)
32
32
  │ └── next-js.ts # re-exports better-auth/next-js (toNextJsHandler)
33
+ ├── scripts/
34
+ │ └── migrate.js # postinstall: auto-migrates SQLite tables via better-auth
33
35
  ├── package.json
34
36
  ├── tsconfig.json
35
37
  └── tsup.config.ts
@@ -49,6 +51,8 @@ packages/auth/
49
51
 
50
52
  Drop-in replacement for `betterAuth`. Users should always use this.
51
53
 
54
+ **Always include `baseURL`** to avoid Better Auth base URL warnings:
55
+
52
56
  ```typescript
53
57
  import { krutAuth } from "@krutai/auth";
54
58
  import Database from "better-sqlite3";
@@ -56,11 +60,7 @@ import Database from "better-sqlite3";
56
60
  export const auth = krutAuth({
57
61
  database: new Database("./sqlite.db"),
58
62
  emailAndPassword: { enabled: true },
59
- user: {
60
- additionalFields: {
61
- name: { type: "string", required: true },
62
- },
63
- },
63
+ baseURL: process.env.BETTER_AUTH_BASE_URL ?? "http://localhost:3000",
64
64
  });
65
65
  ```
66
66
 
@@ -118,6 +118,7 @@ import Database from "better-sqlite3";
118
118
  export const auth = krutAuth({
119
119
  database: new Database("./sqlite.db"),
120
120
  emailAndPassword: { enabled: true },
121
+ baseURL: process.env.BETTER_AUTH_BASE_URL ?? "http://localhost:3000",
121
122
  });
122
123
  ```
123
124
 
@@ -165,6 +166,15 @@ try {
165
166
  }
166
167
  ```
167
168
 
169
+ ## Auto-Migration (postinstall)
170
+
171
+ `scripts/migrate.js` runs after `npm install` to create all required Better Auth SQLite tables automatically. This means users do NOT need to run any manual migration commands — sign-up and sign-in work out of the box.
172
+
173
+ The script:
174
+ 1. Creates `sqlite.db` in the project root (if not present)
175
+ 2. Runs `better-auth migrate` to create all required tables
176
+ 3. Skips silently if the DB already exists and tables are up to date
177
+
168
178
  ## tsup Configuration Notes
169
179
 
170
180
  - `better-auth` → **external** (real dependency, NOT bundled)
@@ -174,10 +184,11 @@ try {
174
184
 
175
185
  ## Important Notes
176
186
 
177
- 1. **Use `krutAuth` not `betterAuth`**: The public API is `krutAuth`. `betterAuth` is an internal implementation detail
178
- 2. **Validator lives in `krutai`**: Never add a local `validator.ts` import from `krutai`
179
- 3. **No `noExternal` for `better-auth` or `krutai`**: They must stay external in tsup
180
- 4. **`getBetterAuth()` returns `Auth`**: Uses the `Auth` type from `better-auth`, not `ReturnType<typeof betterAuth>`
187
+ 1. **Always set `baseURL`**: Pass `baseURL: process.env.BETTER_AUTH_BASE_URL` in `krutAuth()` options
188
+ 2. **Use `krutAuth` not `betterAuth`**: The public API is `krutAuth`. `betterAuth` is an internal implementation detail
189
+ 3. **Validator lives in `krutai`**: Never add a local `validator.ts` — import from `krutai`
190
+ 4. **No `noExternal` for `better-auth` or `krutai`**: They must stay external in tsup
191
+ 5. **`getBetterAuth()` returns `Auth`**: Uses the `Auth` type from `better-auth`, not `ReturnType<typeof betterAuth>`
181
192
 
182
193
  ## Related Packages
183
194
 
package/README.md CHANGED
@@ -7,6 +7,7 @@ Authentication package for KrutAI powered by [Better Auth](https://www.better-au
7
7
  - 🔐 **API Key Protection** — Requires a valid KrutAI API key (validated via `krutai`)
8
8
  - 🚀 **Better Auth Integration** — Built on top of Better Auth
9
9
  - 📦 **Auto-installs everything** — `krutai`, `better-auth`, `better-sqlite3` install automatically
10
+ - 🗄️ **Auto-migrates SQLite** — Database tables are created automatically on install
10
11
  - 🎯 **Next.js Ready** — First-class support via `@krutai/auth/next-js`
11
12
  - ⚡ **Dual Format** — Supports both ESM and CommonJS
12
13
  - 🔷 **TypeScript First** — Full type safety and IntelliSense
@@ -17,7 +18,7 @@ Authentication package for KrutAI powered by [Better Auth](https://www.better-au
17
18
  npm install @krutai/auth
18
19
  ```
19
20
 
20
- > **Note:** `krutai`, `better-auth`, `better-sqlite3`, and `@types/better-sqlite3` are all installed automatically.
21
+ > **Note:** `krutai`, `better-auth`, `better-sqlite3`, and `@types/better-sqlite3` are all installed automatically. SQLite tables are migrated automatically after install.
21
22
 
22
23
  ## Quick Start
23
24
 
@@ -33,17 +34,12 @@ export const auth = krutAuth({
33
34
  emailAndPassword: {
34
35
  enabled: true,
35
36
  },
36
- user: {
37
- additionalFields: {
38
- name: {
39
- type: "string",
40
- required: true,
41
- },
42
- },
43
- },
37
+ baseURL: process.env.BETTER_AUTH_BASE_URL ?? "http://localhost:3000",
44
38
  });
45
39
  ```
46
40
 
41
+ > **Required:** Set `BETTER_AUTH_BASE_URL` in your `.env` file (e.g. `http://localhost:3000` for dev, `https://yourdomain.com` for production). Without this, redirects and callbacks will not work.
42
+
47
43
  ### API Route handler
48
44
 
49
45
  ```typescript
@@ -82,6 +78,13 @@ const auth = new KrutAuth({
82
78
  await auth.initialize();
83
79
  ```
84
80
 
81
+ ## Environment Variables
82
+
83
+ | Variable | Required | Description |
84
+ |---|---|---|
85
+ | `BETTER_AUTH_BASE_URL` | ✅ | Your app's base URL (e.g. `http://localhost:3000`) |
86
+ | `BETTER_AUTH_SECRET` | recommended | Secret for signing sessions |
87
+
85
88
  ## Exports
86
89
 
87
90
  | Import path | What it provides |
@@ -137,7 +140,7 @@ try {
137
140
  ## Architecture
138
141
 
139
142
  ```
140
- @krutai/auth@0.1.7
143
+ @krutai/auth@0.1.8
141
144
  ├── dependency: krutai ← API key validation
142
145
  ├── dependency: better-auth ← auth engine
143
146
  ├── dependency: better-sqlite3 ← default database adapter
package/dist/index.d.mts CHANGED
@@ -140,6 +140,6 @@ declare class KrutAuth {
140
140
  */
141
141
  declare function krutAuth(options: BetterAuthOptions): better_auth.Auth<BetterAuthOptions>;
142
142
 
143
- declare const VERSION = "0.1.7";
143
+ declare const VERSION = "0.1.8";
144
144
 
145
145
  export { type AuthSession, KrutAuth, type KrutAuthConfig, VERSION, krutAuth };
package/dist/index.d.ts CHANGED
@@ -140,6 +140,6 @@ declare class KrutAuth {
140
140
  */
141
141
  declare function krutAuth(options: BetterAuthOptions): better_auth.Auth<BetterAuthOptions>;
142
142
 
143
- declare const VERSION = "0.1.7";
143
+ declare const VERSION = "0.1.8";
144
144
 
145
145
  export { type AuthSession, KrutAuth, type KrutAuthConfig, VERSION, krutAuth };
package/dist/index.js CHANGED
@@ -96,7 +96,7 @@ var KrutAuth = class {
96
96
  function krutAuth(options) {
97
97
  return betterAuth.betterAuth(options);
98
98
  }
99
- var VERSION = "0.1.7";
99
+ var VERSION = "0.1.8";
100
100
 
101
101
  Object.defineProperty(exports, "ApiKeyValidationError", {
102
102
  enumerable: true,
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/client.ts","../src/index.ts"],"names":["validateApiKeyFormat","validateApiKeyWithService","betterAuth"],"mappings":";;;;;;AAiCO,IAAM,WAAN,MAAe;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUlB,YAAoB,MAAA,EAAwB;AAAxB,IAAA,IAAA,CAAA,MAAA,GAAA,MAAA;AAEhB,IAAAA,2BAAA,CAAqB,OAAO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AAC1B,IAAA,OAAO,KAAK,aAAA,EAAc;AAAA,EAC9B;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,MAAM,OAAA,GAAyB;AAC3B,IAAA,OAAO,KAAK,aAAA,EAAc;AAAA,EAC9B;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,MAAM,UAAA,GAA4B;AAC9B,IAAA,OAAO,KAAK,aAAA,EAAc;AAAA,EAC9B;AACJ;ACtFO,SAAS,SAAS,OAAA,EAA4B;AACjD,EAAA,OAAOA,sBAAW,OAAO,CAAA;AAC7B;AAiBO,IAAM,OAAA,GAAU","file":"index.js","sourcesContent":["import { betterAuth } from 'better-auth';\nimport type { Auth } from 'better-auth';\nimport type { KrutAuthConfig } from './types';\n// Import validation from krutai peer dependency\nimport {\n validateApiKeyFormat,\n validateApiKeyWithService,\n} from 'krutai';\n\n/**\n * KrutAuth - Authentication client for KrutAI\n *\n * This class wraps Better Auth and adds API key validation\n * to ensure only authorized users can access authentication features.\n *\n * @example\n * ```typescript\n * import { KrutAuth } from '@krutai/auth';\n *\n * const auth = new KrutAuth({\n * apiKey: 'your-api-key-here',\n * betterAuthOptions: {\n * // Better Auth configuration\n * }\n * });\n *\n * // Initialize the client (validates API key)\n * await auth.initialize();\n *\n * // Use authentication features\n * const betterAuth = auth.getBetterAuth();\n * ```\n */\nexport class KrutAuth {\n private apiKey: string;\n private betterAuthInstance: Auth | null = null;\n private initialized = false;\n\n /**\n * Creates a new KrutAuth instance\n * @param config - Configuration options\n * @throws {ApiKeyValidationError} If API key is invalid\n */\n constructor(private config: KrutAuthConfig) {\n // Validate API key format immediately\n validateApiKeyFormat(config.apiKey);\n this.apiKey = config.apiKey;\n\n // Initialize if validation is not required on init\n if (config.validateOnInit === false) {\n this.initializeBetterAuth();\n }\n }\n\n /**\n * Initialize the authentication client\n * Validates the API key and sets up Better Auth\n * @throws {ApiKeyValidationError} If API key validation fails\n */\n async initialize(): Promise<void> {\n if (this.initialized) {\n return;\n }\n\n // Validate API key with service if needed\n if (this.config.validateOnInit !== false) {\n await validateApiKeyWithService(this.apiKey);\n }\n\n this.initializeBetterAuth();\n this.initialized = true;\n }\n\n /**\n * Initialize Better Auth instance\n * @private\n */\n private initializeBetterAuth(): void {\n this.betterAuthInstance = betterAuth({\n ...this.config.betterAuthOptions,\n });\n }\n\n /**\n * Get the Better Auth instance\n * @throws {Error} If not initialized\n */\n getBetterAuth(): Auth {\n if (!this.betterAuthInstance) {\n throw new Error(\n 'KrutAuth not initialized. Call initialize() first or set validateOnInit to false.'\n );\n }\n return this.betterAuthInstance;\n }\n\n /**\n * Check if the client is initialized\n */\n isInitialized(): boolean {\n return this.initialized;\n }\n\n /**\n * Get the API key (useful for making authenticated requests)\n * @returns The API key\n */\n getApiKey(): string {\n return this.apiKey;\n }\n\n /**\n * Sign in a user\n * This is a convenience method that wraps Better Auth\n * You can access the full Better Auth API via getBetterAuth()\n */\n async signIn(): Promise<Auth> {\n return this.getBetterAuth();\n }\n\n /**\n * Sign out the current user\n * You can access the full Better Auth API via getBetterAuth()\n */\n async signOut(): Promise<Auth> {\n return this.getBetterAuth();\n }\n\n /**\n * Get the current session\n * You can access the full Better Auth API via getBetterAuth()\n */\n async getSession(): Promise<Auth> {\n return this.getBetterAuth();\n }\n}\n","/**\n * @krutai/auth - Authentication package for KrutAI\n *\n * Requires `krutai` as a peer dependency (installed automatically).\n *\n * @example Server-side (Next.js API route / server component)\n * ```typescript\n * import { krutAuth } from \"@krutai/auth\";\n * import Database from \"better-sqlite3\";\n *\n * export const auth = krutAuth({\n * database: new Database(\"./sqlite.db\"),\n * emailAndPassword: { enabled: true },\n * });\n * ```\n *\n * @example Client-side (React / Next.js client component)\n * ```typescript\n * import { createAuthClient } from \"@krutai/auth/react\";\n *\n * export const authClient = createAuthClient({\n * baseURL: process.env.NEXT_PUBLIC_APP_URL ?? \"http://localhost:3000\",\n * });\n *\n * export const { signIn, signUp, signOut, useSession } = authClient;\n * ```\n *\n * @packageDocumentation\n */\n\nimport { betterAuth } from 'better-auth';\nimport type { BetterAuthOptions } from 'better-auth';\n\n/**\n * krutAuth — drop-in replacement for betterAuth.\n *\n * Use this instead of importing betterAuth directly.\n *\n * @example\n * ```typescript\n * import { krutAuth } from \"@krutai/auth\";\n * import Database from \"better-sqlite3\";\n *\n * export const auth = krutAuth({\n * database: new Database(\"./sqlite.db\"),\n * emailAndPassword: { enabled: true },\n * });\n * ```\n */\nexport function krutAuth(options: BetterAuthOptions) {\n return betterAuth(options);\n}\n\n// Export main KrutAuth class (API-key-protected wrapper)\nexport { KrutAuth } from './client';\n\n// Export types\nexport type { KrutAuthConfig, AuthSession, BetterAuthOptions } from './types';\n\n// Re-export validator utilities from krutai peer dependency\nexport {\n validateApiKeyFormat,\n validateApiKeyWithService,\n createApiKeyChecker,\n ApiKeyValidationError,\n} from 'krutai';\n\n// Package metadata\nexport const VERSION = '0.1.7';\n"]}
1
+ {"version":3,"sources":["../src/client.ts","../src/index.ts"],"names":["validateApiKeyFormat","validateApiKeyWithService","betterAuth"],"mappings":";;;;;;AAiCO,IAAM,WAAN,MAAe;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUlB,YAAoB,MAAA,EAAwB;AAAxB,IAAA,IAAA,CAAA,MAAA,GAAA,MAAA;AAEhB,IAAAA,2BAAA,CAAqB,OAAO,MAAM,CAAA;AAClC,IAAA,IAAA,CAAK,SAAS,MAAA,CAAO,MAAA;AAGrB,IAAA,IAAI,MAAA,CAAO,mBAAmB,KAAA,EAAO;AACjC,MAAA,IAAA,CAAK,oBAAA,EAAqB;AAAA,IAC9B;AAAA,EACJ;AAAA,EAlBQ,MAAA;AAAA,EACA,kBAAA,GAAkC,IAAA;AAAA,EAClC,WAAA,GAAc,KAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAuBtB,MAAM,UAAA,GAA4B;AAC9B,IAAA,IAAI,KAAK,WAAA,EAAa;AAClB,MAAA;AAAA,IACJ;AAGA,IAAA,IAAI,IAAA,CAAK,MAAA,C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from 'better-auth';\nimport type { KrutAuthConfig } from './types';\n// Import validation from krutai peer dependency\nimport {\n validateApiKeyFormat,\n validateApiKeyWithService,\n} from 'krutai';\n\n/**\n * KrutAuth - Authentication client for KrutAI\n *\n * This class wraps Better Auth and adds API key validation\n * to ensure only authorized users can access authentication features.\n *\n * @example\n * ```typescript\n * import { KrutAuth } from '@krutai/auth';\n *\n * const auth = new KrutAuth({\n * apiKey: 'your-api-key-here',\n * betterAuthOptions: {\n * // Better Auth configuration\n * }\n * });\n *\n * // Initialize the client (validates API key)\n * await auth.initialize();\n *\n * // Use authentication features\n * const betterAuth = auth.getBetterAuth();\n * ```\n */\nexport class KrutAuth {\n private apiKey: string;\n private betterAuthInstance: Auth | null = null;\n private initialized = false;\n\n /**\n * Creates a new KrutAuth instance\n * @param config - Configuration options\n * @throws {ApiKeyValidationError} If API key is invalid\n */\n constructor(private config: KrutAuthConfig) {\n // Validate API key format immediately\n validateApiKeyFormat(config.apiKey);\n this.apiKey = config.apiKey;\n\n // Initialize if validation is not required on init\n if (config.validateOnInit === false) {\n this.initializeBetterAuth();\n }\n }\n\n /**\n * Initialize the authentication client\n * Validates the API key and sets up Better Auth\n * @throws {ApiKeyValidationError} If API key validation fails\n */\n async initialize(): Promise<void> {\n if (this.initialized) {\n return;\n }\n\n // Validate API key with service if needed\n if (this.config.validateOnInit !== false) {\n await validateApiKeyWithService(this.apiKey);\n }\n\n this.initializeBetterAuth();\n this.initialized = true;\n }\n\n /**\n * Initialize Better Auth instance\n * @private\n */\n private initializeBetterAuth(): void {\n this.betterAuthInstance = betterAuth({\n ...this.config.betterAuthOptions,\n });\n }\n\n /**\n * Get the Better Auth instance\n * @throws {Error} If not initialized\n */\n getBetterAuth(): Auth {\n if (!this.betterAuthInstance) {\n throw new Error(\n 'KrutAuth not initialized. Call initialize() first or set validateOnInit to false.'\n );\n }\n return this.betterAuthInstance;\n }\n\n /**\n * Check if the client is initialized\n */\n isInitialized(): boolean {\n return this.initialized;\n }\n\n /**\n * Get the API key (useful for making authenticated requests)\n * @returns The API key\n */\n getApiKey(): string {\n return this.apiKey;\n }\n\n /**\n * Sign in a user\n * This is a convenience method that wraps Better Auth\n * You can access the full Better Auth API via getBetterAuth()\n */\n async signIn(): Promise<Auth> {\n return this.getBetterAuth();\n }\n\n /**\n * Sign out the current user\n * You can access the full Better Auth API via getBetterAuth()\n */\n async signOut(): Promise<Auth> {\n return this.getBetterAuth();\n }\n\n /**\n * Get the current session\n * You can access the full Better Auth API via getBetterAuth()\n */\n async getSession(): Promise<Auth> {\n return this.getBetterAuth();\n }\n}\n","/**\n * @krutai/auth - Authentication package for KrutAI\n *\n * Requires `krutai` as a peer dependency (installed automatically).\n *\n * @example Server-side (Next.js API route / server component)\n * ```typescript\n * import { krutAuth } from \"@krutai/auth\";\n * import Database from \"better-sqlite3\";\n *\n * export const auth = krutAuth({\n * database: new Database(\"./sqlite.db\"),\n * emailAndPassword: { enabled: true },\n * baseURL: process.env.BETTER_AUTH_BASE_URL ?? \"http://localhost:3000\",\n * });\n * ```\n *\n * @example Client-side (React / Next.js client component)\n * ```typescript\n * import { createAuthClient } from \"@krutai/auth/react\";\n *\n * export const authClient = createAuthClient({\n * baseURL: process.env.NEXT_PUBLIC_APP_URL ?? \"http://localhost:3000\",\n * });\n *\n * export const { signIn, signUp, signOut, useSession } = authClient;\n * ```\n *\n * @packageDocumentation\n */\n\nimport { betterAuth } from 'better-auth';\nimport type { BetterAuthOptions } from 'better-auth';\n\n/**\n * krutAuth — drop-in replacement for betterAuth.\n *\n * Use this instead of importing betterAuth directly.\n *\n * @example\n * ```typescript\n * import { krutAuth } from \"@krutai/auth\";\n * import Database from \"better-sqlite3\";\n *\n * export const auth = krutAuth({\n * database: new Database(\"./sqlite.db\"),\n * emailAndPassword: { enabled: true },\n * });\n * ```\n */\nexport function krutAuth(options: BetterAuthOptions) {\n return betterAuth(options);\n}\n\n// Export main KrutAuth class (API-key-protected wrapper)\nexport { KrutAuth } from './client';\n\n// Export types\nexport type { KrutAuthConfig, AuthSession, BetterAuthOptions } from './types';\n\n// Re-export validator utilities from krutai peer dependency\nexport {\n validateApiKeyFormat,\n validateApiKeyWithService,\n createApiKeyChecker,\n ApiKeyValidationError,\n} from 'krutai';\n\n// Package metadata\nexport const VERSION = '0.1.8';\n"]}
package/dist/index.mjs CHANGED
@@ -95,7 +95,7 @@ var KrutAuth = class {
95
95
  function krutAuth(options) {
96
96
  return betterAuth(options);
97
97
  }
98
- var VERSION = "0.1.7";
98
+ var VERSION = "0.1.8";
99
99
 
100
100
  export { KrutAuth, VERSION, krutAuth };
101
101
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/client.ts","../src/index.ts"],"names":["betterAuth"],"mappings":";;;;;AAiCO,IAAM,WAAN,MAAe;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUlB,YAAoB,MAAA,EAAwB;AAAxB,IAAA,IAAA,CAAA,MAAA,GAAA,MAAA;AAEhB,IAAA,oBAAA,CAAqB,OAAO,MAAM,CAAA;AAClC,IAAA,IAAA,CAAK,SAAS,MAAA,CAAO,MAAA;AAGrB,IAAA,IAAI,MAAA,CAAO,mBAAmB,KAAA,EAAO;AACjC,MAAA,IAAA,CAAK,oBAAA,EAAqB;AAAA,IAC9B;AAAA,EACJ;AAAA,EAlBQ,MAAA;AAAA,EACA,kBAAA,GAAkC,IAAA;AAAA,EAClC,WAAA,GAAc,KAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAuBtB,MAAM,UAAA,GAA4B;AAC9B,IAAA,IAAI,KAAK,WAAA,EAAa;AAClB,MAAA;AAAA,IACJ;AAGA,IAAA,IAAI,IAAA,CAAK,MAAA,CAAO,cAAA,KAAmB,KAAA,EAAO;AACtC,MAAA,MAAM,yBAAA,CAA0B,KAAK,MAAM,CAAA;AAAA,IAC/C;AAEA,IAAA,IAAA,CAAK,oBAAA,EAAqB;AAC1B,IAAA,IAAA,CAAK,WAAA,GAAc,IAAA;AAAA,EACvB;AAAA;AAAA;AAAA;AAAA;AAAA,EAMQ,oBAAA,GAA6B;AACjC,IAAA,IAAA,CAAK,qBAAqB,UAAA,CAAW;AAAA,MACjC,GAAG,KAAK,MAAA,CAAO;AAAA,KAClB,CAAA;AAAA,EACL;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,aAAA,GAAsB;AAClB,IAAA,IAAI,CAAC,KAAK,kBAAA,EAAoB;AAC1B,MAAA,MAAM,IAAI,KAAA;AAAA,QACN;AAAA,OACJ;AAAA,IACJ;AACA,IAAA,OAAO,IAAA,CAAK,kBAAA;AAAA,EAChB;AAAA;AAAA;AAAA;AAAA,EAKA,aAAA,GAAyB;AACrB,IAAA,OAAO,IAAA,CAAK,WAAA;AAAA,EAChB;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,SAAA,GAAoB;AAChB,IAAA,OAAO,IAAA,CAAK,MAAA;AAAA,EAChB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,MAAM,MAAA,GAAwB;AAC1B,IAAA,OAAO,KAAK,aAAA,EAAc;AAAA,EAC9B;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,MAAM,OAAA,GAAyB;AAC3B,IAAA,OAAO,KAAK,aAAA,EAAc;AAAA,EAC9B;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,MAAM,UAAA,GAA4B;AAC9B,IAAA,OAAO,KAAK,aAAA,EAAc;AAAA,EAC9B;AACJ;ACtFO,SAAS,SAAS,OAAA,EAA4B;AACjD,EAAA,OAAOA,WAAW,OAAO,CAAA;AAC7B;AAiBO,IAAM,OAAA,GAAU","file":"index.mjs","sourcesContent":["import { betterAuth } from 'better-auth';\nimport type { Auth } from 'better-auth';\nimport type { KrutAuthConfig } from './types';\n// Import validation from krutai peer dependency\nimport {\n validateApiKeyFormat,\n validateApiKeyWithService,\n} from 'krutai';\n\n/**\n * KrutAuth - Authentication client for KrutAI\n *\n * This class wraps Better Auth and adds API key validation\n * to ensure only authorized users can access authentication features.\n *\n * @example\n * ```typescript\n * import { KrutAuth } from '@krutai/auth';\n *\n * const auth = new KrutAuth({\n * apiKey: 'your-api-key-here',\n * betterAuthOptions: {\n * // Better Auth configuration\n * }\n * });\n *\n * // Initialize the client (validates API key)\n * await auth.initialize();\n *\n * // Use authentication features\n * const betterAuth = auth.getBetterAuth();\n * ```\n */\nexport class KrutAuth {\n private apiKey: string;\n private betterAuthInstance: Auth | null = null;\n private initialized = false;\n\n /**\n * Creates a new KrutAuth instance\n * @param config - Configuration options\n * @throws {ApiKeyValidationError} If API key is invalid\n */\n constructor(private config: KrutAuthConfig) {\n // Validate API key format immediately\n validateApiKeyFormat(config.apiKey);\n this.apiKey = config.apiKey;\n\n // Initialize if validation is not required on init\n if (config.validateOnInit === false) {\n this.initializeBetterAuth();\n }\n }\n\n /**\n * Initialize the authentication client\n * Validates the API key and sets up Better Auth\n * @throws {ApiKeyValidationError} If API key validation fails\n */\n async initialize(): Promise<void> {\n if (this.initialized) {\n return;\n }\n\n // Validate API key with service if needed\n if (this.config.validateOnInit !== false) {\n await validateApiKeyWithService(this.apiKey);\n }\n\n this.initializeBetterAuth();\n this.initialized = true;\n }\n\n /**\n * Initialize Better Auth instance\n * @private\n */\n private initializeBetterAuth(): void {\n this.betterAuthInstance = betterAuth({\n ...this.config.betterAuthOptions,\n });\n }\n\n /**\n * Get the Better Auth instance\n * @throws {Error} If not initialized\n */\n getBetterAuth(): Auth {\n if (!this.betterAuthInstance) {\n throw new Error(\n 'KrutAuth not initialized. Call initialize() first or set validateOnInit to false.'\n );\n }\n return this.betterAuthInstance;\n }\n\n /**\n * Check if the client is initialized\n */\n isInitialized(): boolean {\n return this.initialized;\n }\n\n /**\n * Get the API key (useful for making authenticated requests)\n * @returns The API key\n */\n getApiKey(): string {\n return this.apiKey;\n }\n\n /**\n * Sign in a user\n * This is a convenience method that wraps Better Auth\n * You can access the full Better Auth API via getBetterAuth()\n */\n async signIn(): Promise<Auth> {\n return this.getBetterAuth();\n }\n\n /**\n * Sign out the current user\n * You can access the full Better Auth API via getBetterAuth()\n */\n async signOut(): Promise<Auth> {\n return this.getBetterAuth();\n }\n\n /**\n * Get the current session\n * You can access the full Better Auth API via getBetterAuth()\n */\n async getSession(): Promise<Auth> {\n return this.getBetterAuth();\n }\n}\n","/**\n * @krutai/auth - Authentication package for KrutAI\n *\n * Requires `krutai` as a peer dependency (installed automatically).\n *\n * @example Server-side (Next.js API route / server component)\n * ```typescript\n * import { krutAuth } from \"@krutai/auth\";\n * import Database from \"better-sqlite3\";\n *\n * export const auth = krutAuth({\n * database: new Database(\"./sqlite.db\"),\n * emailAndPassword: { enabled: true },\n * });\n * ```\n *\n * @example Client-side (React / Next.js client component)\n * ```typescript\n * import { createAuthClient } from \"@krutai/auth/react\";\n *\n * export const authClient = createAuthClient({\n * baseURL: process.env.NEXT_PUBLIC_APP_URL ?? \"http://localhost:3000\",\n * });\n *\n * export const { signIn, signUp, signOut, useSession } = authClient;\n * ```\n *\n * @packageDocumentation\n */\n\nimport { betterAuth } from 'better-auth';\nimport type { BetterAuthOptions } from 'better-auth';\n\n/**\n * krutAuth — drop-in replacement for betterAuth.\n *\n * Use this instead of importing betterAuth directly.\n *\n * @example\n * ```typescript\n * import { krutAuth } from \"@krutai/auth\";\n * import Database from \"better-sqlite3\";\n *\n * export const auth = krutAuth({\n * database: new Database(\"./sqlite.db\"),\n * emailAndPassword: { enabled: true },\n * });\n * ```\n */\nexport function krutAuth(options: BetterAuthOptions) {\n return betterAuth(options);\n}\n\n// Export main KrutAuth class (API-key-protected wrapper)\nexport { KrutAuth } from './client';\n\n// Export types\nexport type { KrutAuthConfig, AuthSession, BetterAuthOptions } from './types';\n\n// Re-export validator utilities from krutai peer dependency\nexport {\n validateApiKeyFormat,\n validateApiKeyWithService,\n createApiKeyChecker,\n ApiKeyValidationError,\n} from 'krutai';\n\n// Package metadata\nexport const VERSION = '0.1.7';\n"]}
1
+ {"version":3,"sources":["../src/client.ts","../src/index.ts"],"names":["betterAu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WAAA;AAAA,EAChB;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,SAAA,GAAoB;AAChB,IAAA,OAAO,IAAA,CAAK,MAAA;AAAA,EAChB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,MAAM,MAAA,GAAwB;AAC1B,IAAA,OAAO,KAAK,aAAA,EAAc;AAAA,EAC9B;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,MAAM,OAAA,GAAyB;AAC3B,IAAA,OAAO,KAAK,aAAA,EAAc;AAAA,EAC9B;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,MAAM,UAAA,GAA4B;AAC9B,IAAA,OAAO,KAAK,aAAA,EAAc;AAAA,EAC9B;AACJ;ACrFO,SAAS,SAAS,OAAA,EAA4B;AACjD,EAAA,OAAOA,WAAW,OAAO,CAAA;AAC7B;AAiBO,IAAM,OAAA,GAAU","file":"index.mjs","sourcesContent":["import { betterAuth } from 'better-auth';\nimport type { Auth } from 'better-auth';\nimport type { KrutAuthConfig } from './types';\n// Import validation from krutai peer dependency\nimport {\n validateApiKeyFormat,\n validateApiKeyWithService,\n} from 'krutai';\n\n/**\n * KrutAuth - Authentication client for KrutAI\n *\n * This class wraps Better Auth and adds API key validation\n * to ensure only authorized users can access authentication features.\n *\n * @example\n * ```typescript\n * import { KrutAuth } from '@krutai/auth';\n *\n * const auth = new KrutAuth({\n * apiKey: 'your-api-key-here',\n * betterAuthOptions: {\n * // Better Auth configuration\n * }\n * });\n *\n * // Initialize the client (validates API key)\n * await auth.initialize();\n *\n * // Use authentication features\n * const betterAuth = auth.getBetterAuth();\n * ```\n */\nexport class KrutAuth {\n private apiKey: string;\n private betterAuthInstance: Auth | null = null;\n private initialized = false;\n\n /**\n * Creates a new KrutAuth instance\n * @param config - Configuration options\n * @throws {ApiKeyValidationError} If API key is invalid\n */\n constructor(private config: KrutAuthConfig) {\n // Validate API key format immediately\n validateApiKeyFormat(config.apiKey);\n this.apiKey = config.apiKey;\n\n // Initialize if validation is not required on init\n if (config.validateOnInit === false) {\n this.initializeBetterAuth();\n }\n }\n\n /**\n * Initialize the authentication client\n * Validates the API key and sets up Better Auth\n * @throws {ApiKeyValidationError} If API key validation fails\n */\n async initialize(): Promise<void> {\n if (this.initialized) {\n return;\n }\n\n // Validate API key with service if needed\n if (this.config.validateOnInit !== false) {\n await validateApiKeyWithService(this.apiKey);\n }\n\n this.initializeBetterAuth();\n this.initialized = true;\n }\n\n /**\n * Initialize Better Auth instance\n * @private\n */\n private initializeBetterAuth(): void {\n this.betterAuthInstance = betterAuth({\n ...this.config.betterAuthOptions,\n });\n }\n\n /**\n * Get the Better Auth instance\n * @throws {Error} If not initialized\n */\n getBetterAuth(): Auth {\n if (!this.betterAuthInstance) {\n throw new Error(\n 'KrutAuth not initialized. Call initialize() first or set validateOnInit to false.'\n );\n }\n return this.betterAuthInstance;\n }\n\n /**\n * Check if the client is initialized\n */\n isInitialized(): boolean {\n return this.initialized;\n }\n\n /**\n * Get the API key (useful for making authenticated requests)\n * @returns The API key\n */\n getApiKey(): string {\n return this.apiKey;\n }\n\n /**\n * Sign in a user\n * This is a convenience method that wraps Better Auth\n * You can access the full Better Auth API via getBetterAuth()\n */\n async signIn(): Promise<Auth> {\n return this.getBetterAuth();\n }\n\n /**\n * Sign out the current user\n * You can access the full Better Auth API via getBetterAuth()\n */\n async signOut(): Promise<Auth> {\n return this.getBetterAuth();\n }\n\n /**\n * Get the current session\n * You can access the full Better Auth API via getBetterAuth()\n */\n async getSession(): Promise<Auth> {\n return this.getBetterAuth();\n }\n}\n","/**\n * @krutai/auth - Authentication package for KrutAI\n *\n * Requires `krutai` as a peer dependency (installed automatically).\n *\n * @example Server-side (Next.js API route / server component)\n * ```typescript\n * import { krutAuth } from \"@krutai/auth\";\n * import Database from \"better-sqlite3\";\n *\n * export const auth = krutAuth({\n * database: new Database(\"./sqlite.db\"),\n * emailAndPassword: { enabled: true },\n * baseURL: process.env.BETTER_AUTH_BASE_URL ?? \"http://localhost:3000\",\n * });\n * ```\n *\n * @example Client-side (React / Next.js client component)\n * ```typescript\n * import { createAuthClient } from \"@krutai/auth/react\";\n *\n * export const authClient = createAuthClient({\n * baseURL: process.env.NEXT_PUBLIC_APP_URL ?? \"http://localhost:3000\",\n * });\n *\n * export const { signIn, signUp, signOut, useSession } = authClient;\n * ```\n *\n * @packageDocumentation\n */\n\nimport { betterAuth } from 'better-auth';\nimport type { BetterAuthOptions } from 'better-auth';\n\n/**\n * krutAuth — drop-in replacement for betterAuth.\n *\n * Use this instead of importing betterAuth directly.\n *\n * @example\n * ```typescript\n * import { krutAuth } from \"@krutai/auth\";\n * import Database from \"better-sqlite3\";\n *\n * export const auth = krutAuth({\n * database: new Database(\"./sqlite.db\"),\n * emailAndPassword: { enabled: true },\n * });\n * ```\n */\nexport function krutAuth(options: BetterAuthOptions) {\n return betterAuth(options);\n}\n\n// Export main KrutAuth class (API-key-protected wrapper)\nexport { KrutAuth } from './client';\n\n// Export types\nexport type { KrutAuthConfig, AuthSession, BetterAuthOptions } from './types';\n\n// Re-export validator utilities from krutai peer dependency\nexport {\n validateApiKeyFormat,\n validateApiKeyWithService,\n createApiKeyChecker,\n ApiKeyValidationError,\n} from 'krutai';\n\n// Package metadata\nexport const VERSION = '0.1.8';\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@krutai/auth",
3
- "version": "0.1.7",
3
+ "version": "0.1.8",
4
4
  "description": "Authentication package for KrutAI — installs krutai, better-auth, and better-sqlite3 automatically",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -24,6 +24,7 @@
24
24
  },
25
25
  "files": [
26
26
  "dist",
27
+ "scripts",
27
28
  "README.md",
28
29
  "AI_REFERENCE.md"
29
30
  ],
@@ -31,7 +32,8 @@
31
32
  "build": "tsup",
32
33
  "dev": "tsup --watch",
33
34
  "clean": "rm -rf dist *.tsbuildinfo",
34
- "typecheck": "tsc --noEmit"
35
+ "typecheck": "tsc --noEmit",
36
+ "postinstall": "node scripts/migrate.js"
35
37
  },
36
38
  "keywords": [
37
39
  "krutai",
@@ -63,4 +65,4 @@
63
65
  "url": "git+https://github.com/AccountantAIOrg/krut_packages.git",
64
66
  "directory": "packages/auth"
65
67
  }
66
- }
68
+ }
@@ -0,0 +1,53 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * @krutai/auth — postinstall migration script
4
+ *
5
+ * Automatically creates (or updates) the SQLite database tables
6
+ * required by Better Auth. Runs after `npm install @krutai/auth`.
7
+ *
8
+ * The database file is placed at the project root as `sqlite.db`.
9
+ * Set BETTER_AUTH_DB_PATH to override the location.
10
+ * Set SKIP_KRUTAI_MIGRATE=1 to skip this script entirely.
11
+ */
12
+
13
+ const { execSync } = require('child_process');
14
+ const path = require('path');
15
+ const fs = require('fs');
16
+
17
+ // Allow opt-out
18
+ if (process.env.SKIP_KRUTAI_MIGRATE === '1') {
19
+ console.log('[krutai/auth] Skipping migration (SKIP_KRUTAI_MIGRATE=1)');
20
+ process.exit(0);
21
+ }
22
+
23
+ // Determine project root (where the consuming project's package.json lives)
24
+ // When postinstall runs under node_modules/@krutai/auth, we go up 3 levels.
25
+ const projectRoot = path.resolve(__dirname, '..', '..', '..', '..');
26
+
27
+ // Fallback: if we're being run from within the monorepo itself, use cwd
28
+ const packageJson = path.join(projectRoot, 'package.json');
29
+ const root = fs.existsSync(packageJson) ? projectRoot : process.cwd();
30
+
31
+ const dbPath = process.env.BETTER_AUTH_DB_PATH ?? path.join(root, 'sqlite.db');
32
+
33
+ console.log('[krutai/auth] Running Better Auth SQLite migration...');
34
+ console.log(`[krutai/auth] Database: ${dbPath}`);
35
+
36
+ try {
37
+ // better-auth provides a CLI via `npx better-auth migrate`
38
+ // Pass the db path via env so it's picked up automatically
39
+ execSync('npx better-auth migrate --yes', {
40
+ cwd: root,
41
+ stdio: 'inherit',
42
+ env: {
43
+ ...process.env,
44
+ BETTER_AUTH_DB_PATH: dbPath,
45
+ BETTER_AUTH_DATABASE_URL: `file:${dbPath}`,
46
+ },
47
+ });
48
+ console.log('[krutai/auth] Migration complete. SQLite tables are ready.');
49
+ } catch (err) {
50
+ // Don't fail the install — the user may not have a lib/auth.ts yet
51
+ console.warn('[krutai/auth] Migration skipped or failed (this is OK if you have not created lib/auth.ts yet).');
52
+ console.warn('[krutai/auth] Run `npx better-auth migrate` manually after setting up your auth config.');
53
+ }