Improve API token format and enhance auth status command
- Change token format to reviq_<base58> prefix instead of raw hex - Add me.authStatus API endpoint for detailed auth information - Enhance CLI `reviq auth status` to show token details from API - Add comprehensive tests for token generation (18 tests) - Extract bootstrap logic to @reviq/db for reusability and testing - Remove default db export; callers must use createDb() directly Token changes: - New format: reviq_<base58-encoded-32-bytes> - Added parseToken() for validation - Added isValidTokenFormat() helper Auth status endpoint returns: - User profile information - Auth method (api_token or session) - Token/session details (name, expiration, last used) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -2,24 +2,35 @@
|
||||
* Database client for RevIQ Publisher Dashboard
|
||||
*
|
||||
* @module @reviq/db
|
||||
*/
|
||||
|
||||
import type { Database } from "@reviq/db-schema";
|
||||
import type { Kysely } from "kysely";
|
||||
import { createDb } from "./client.js";
|
||||
|
||||
/**
|
||||
* Default database instance
|
||||
*
|
||||
* Uses DATABASE_URL environment variable for connection
|
||||
* Usage:
|
||||
* import { createDb } from "@reviq/db";
|
||||
* const db = createDb(); // Uses DATABASE_URL env var
|
||||
* // ... use db ...
|
||||
* await db.destroy();
|
||||
*/
|
||||
export const db: Kysely<Database> = createDb();
|
||||
|
||||
/**
|
||||
* Re-export database types from db-schema
|
||||
*/
|
||||
export type { Database } from "@reviq/db-schema";
|
||||
/**
|
||||
* Export createDb for creating custom database instances
|
||||
* Export createDb for creating database instances
|
||||
* Callers should create their own database instance and pass it to functions
|
||||
*/
|
||||
export { createDb } from "./client.js";
|
||||
/**
|
||||
* Export helper functions
|
||||
*/
|
||||
export {
|
||||
type BootstrapInput,
|
||||
type BootstrapResult,
|
||||
executeBootstrap,
|
||||
} from "./helpers/execute-bootstrap.js";
|
||||
export { hashPassword } from "./helpers/password.js";
|
||||
export {
|
||||
generateToken,
|
||||
hashToken,
|
||||
parseToken,
|
||||
TOKEN_PREFIX,
|
||||
} from "./helpers/token.js";
|
||||
|
||||
Reference in New Issue
Block a user