Commit Graph

19 Commits

Author SHA1 Message Date
RevIQ
c4b0509023 Implement shell completions for CLI (Workstream N-Completions)
Add `reviq completions bash/zsh` command with dynamic shell completions:

- Create bash-complete.ts entry point using stricli's proposeCompletions API
- Add completions command with bash and zsh support (fish planned)
- Extract app export to separate app.ts for shared imports
- Add @stricli/auto-complete dependency and __reviq_bash_complete bin entry

Also fix lint/type errors in api-server tests and helpers.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-09 17:11:10 +08:00
RevIQ
2655c57b9e Merge branch 'wt3': WebAuthn enhancements and virtual authenticator
- Enhanced createRegistrationOptions to look up existing users
- Added virtual-authenticator testing package
- Added WebAuthn e2e and unit tests

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-09 16:55:14 +08:00
RevIQ
bd9be3e441 Add comprehensive WebAuthn e2e/unit tests and virtual authenticator package
- Create @reviq/virtual-authenticator package with cryptographically valid
  WebAuthn credential generation for testing
- Add e2e tests for WebAuthn registration, authentication, passkey management
- Add unit tests for passkey-helpers and VirtualAuthenticator
- Add security tests for counter replay and tampered responses
- Configure test database environment in devenv.nix
- Add turbo.json test tasks and workspace configuration

Test results: 98 tests passing (54 virtual-authenticator, 25 e2e, 19 unit)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-09 16:46:02 +08:00
RevIQ
96807bdc3f Merge branch 'master' into workstream-h-v2
Resolve conflicts in router.ts by adopting master's modular architecture
for me.* procedures while keeping meGet and setupProfile inline.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-09 16:36:37 +08:00
RevIQ
073db98a91 Implement Workstream H: Auth pages with refactored components
Add 10 authentication pages for the Publisher Dashboard:
- H1: /auth/signup - Account creation with passkey/password
- H2: /auth/setup/user - Profile setup with phone validation
- H3: /auth/login - Email entry with routing logic
- H4: /auth/login/passkey - WebAuthn authentication
- H5: /auth/login/password - Password authentication
- H6: /auth/confirm - Email verification polling
- H7: /auth/trust-device - Device trust prompt
- H8: /auth/verify - Email verification callback
- H9: /auth/forgot-password - Password reset request
- H10: /auth/reset-password - New password form

New reusable components:
- LoadingButton: Button with Loader2 spinner and loading state
- ErrorAlert: Accessible error display with ARIA live region
- PasswordFormField: Composite field with label, input, strength meter
- PasswordInput: Improved with bind:value and cn() class merging

New utilities:
- validation.ts: Email, phone validation, email masking, error parsing
- auth.svelte.ts: Login flow state store for SPA mode guards

Backend updates:
- Implement me.get, me.setupProfile, me.getDeviceInfo, me.trustDevice

Dependencies added:
- @simplewebauthn/browser, libphonenumber-js, ua-parser-js
- zxcvbn, svelte-sonner, shadcn alert component

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-09 16:32:35 +08:00
RevIQ
860d791125 Implement Workstream F1: me.get and me.setupProfile procedures
- Add me.get procedure returning user profile with needsSetup flag
- Add me.setupProfile procedure for initial profile setup after signup
- Add nonEmptyString/optionalString schema helpers with tests
- Use Web Crypto API (SubtleCrypto) for Cloudflare Workers compatibility
- Use @formatjs/intl-durationformat for duration formatting
- Remove node:crypto dependency from crypto utilities

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-09 16:29:41 +08:00
RevIQ
93851afe38 Merge branch 'wt4': Add email sending and documentation
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-09 15:45:39 +08:00
RevIQ
9456a98eac Implement Workstream G: Email Service with Postmark
- Add postmark dependency and email configuration constants
- Implement sendVerificationEmail, sendPasswordResetEmail,
  sendLoginConfirmationEmail, and sendOrgInviteEmail helpers
- Add HTML + text email templates with inline CSS
- Support dev mode (EMAIL_DEV_MODE=true) for console logging
- Use URL constructor for proper URL building
- Add XSS protection with HTML escaping in templates
- Create .env file with email environment variables

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-09 15:42:33 +08:00
RevIQ
3f94a9e067 Merge branch 'wt2': Add auth procedures and password utilities
Integrates extracted auth handlers and Bun-based password hashing:
- Auth procedures moved to individual handler files
- Password hashing using Bun's argon2id (replaces scrypt)
- Password validation with zxcvbn
- Session, cookie, crypto, email, and geo utilities

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-09 15:36:32 +08:00
RevIQ
410b937f9f Implement CLI commands and admin API endpoints
- Add bootstrap command with direct DB access for initial setup
- Implement auth login/logout/status CLI commands
- Implement user create/confirm-email CLI commands
- Implement org create/list/add-site CLI commands
- Add admin.orgs.* and admin.users.* API endpoints
- Add password hashing utility with scrypt
- Add token hashing and authentication utility
- Add superuser runtime checks for admin endpoints
- Wrap multi-step operations in transactions
- Fix config file permissions (0o600) for security
- Remove token display from status command
- Add return statements to void handlers
- Add reviq CLI command to devenv

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-09 15:30:10 +08:00
RevIQ
829d365e80 Implement auth procedures with code review fixes
Add complete auth backend (Workstream D):
- Auth middleware for session/API key authentication
- Signup with password or passkey (WebAuthn)
- Login flow with device trust and email confirmation
- Password reset and email verification
- Session management and logout

Utilities created:
- cookies.ts: Cookie helpers and configuration
- crypto.ts: Token generation and hashing
- password.ts: zxcvbn validation, argon2id hashing
- geo.ts: IP/location extraction from headers
- email.ts: Stubbed email sending
- session.ts: Session creation and device trust

Code review improvements applied:
- Use ORPCError instead of Error in procedures
- Add ast-grep rule to enforce ORPCError usage
- Remove error info leakage (generic messages)
- Optimize N+1 query with JOIN in login-password
- Extract signupWithPassword/signupWithPasskey for testability
- Add 15-minute WebAuthn challenge expiry check
- Strengthen CookieOptions type definitions

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-09 15:19:15 +08:00
RevIQ
b46146faa5 Implement WebAuthn passkey authentication
Add complete WebAuthn support for passkey registration and authentication:
- Install @simplewebauthn/server for WebAuthn utilities
- Create passkey-helpers.ts with base64url/Uint8Array conversion utilities
- Create webauthn.ts with registration/authentication option generation and verification
- Create context.ts with API context types
- Implement all WebAuthn router handlers (createRegistrationOptions, verifyRegistration, createAuthenticationOptions, verifyAuthentication)
- Implement passkey management handlers (listPasskeys, createPasskey, renamePasskey, deletePasskey)
- Add WebAuthn configuration constants and environment variables

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-09 12:34:26 +08:00
RevIQ
a4dff188eb Replace z.any() with z.custom<T>() for WebAuthn types
Use proper TypeScript types from @simplewebauthn/types instead of
z.any() for WebAuthn-related schemas:
- PublicKeyCredentialCreationOptionsJSON
- PublicKeyCredentialRequestOptionsJSON
- RegistrationResponseJSON
- AuthenticationResponseJSON

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-09 12:17:29 +08:00
RevIQ
2e9ea74bc9 Connect frontend to oRPC server
- Add Vite proxy to forward /api/v1/rpc to API server (port 9861)
- Create oRPC client in src/lib/api/client.ts
- Add @orpc/client and @orpc/contract dependencies
- Add @reviq/api-contract workspace dependency
- Extract DEFAULT_PORT constant to api-server/src/constants.ts
- Change API server default port from 3001 to 9861

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-09 12:09:03 +08:00
RevIQ
8f3f711af0 Add ESLint to all packages and reorganize CLI
ESLint:
- Add @macalinao/eslint-config and eslint to all packages/apps
- Add lint scripts to all package.json files
- Create eslint.config.js for all apps
- Add lint task to turbo.json
- Add @macalinao/eslint-config and @types/bun to catalog

Biome:
- Exclude docs/ from biome checks

CLI Reorganization:
- Restructure CLI to use route maps with one command per file
- Move commands to routes/ directory structure
- Use func property instead of async loaders
- Route maps in _command.ts files for each directory

Environment:
- Use Bun.env instead of process.env for env vars
- Add DATABASE_URL and PORT to turbo.json globalEnv

Lint Fixes:
- Fix nullish coalescing operator usage
- Update deprecated Zod API (z.email() instead of .string().email())
- Fix import sorting

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-09 12:01:41 +08:00
RevIQ
aee22ae454 Update devenv and cleanup packages
- Add api-server process to devenv.nix
- Add dbmate and kysely-codegen scripts
- Configure PostgreSQL with localhost listener
- Update publisher-dashboard package to @apps/publisher-dashboard
- Fix deprecated asChild prop in mobile-nav component
- Remove unused publisher-utils package
- Update bun.lock with new dependencies

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-09 11:45:13 +08:00
RevIQ
82f39e0335 Add TanStack Query and update dashboard card styling
- Set up @tanstack/svelte-query and devtools in root layout
- Configure QueryClient with 5-minute stale time
- Update dashboard card to match Figma: regular font weight, no border
- Add .playwright-mcp to gitignore

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-08 17:27:23 +08:00
RevIQ
f8d543565c Redesign dashboard UI with mobile responsive layout
- Add Geist font family and refined OKLCH color palette
- Redesign all dashboard components with polished styling
- Implement URL-synced tabs for performance table (domain, country, source, ad-unit, key-value)
- Add mobile hamburger menu using shadcn Sheet component
- Make sidebar responsive (hidden on mobile, visible on lg+)
- Add custom shadow utilities and improved visual hierarchy
- Add sparklines with gradients to metric cards
- Redesign peak traffic chart as heatmap grid
- Add icons and hover states to frequent filters

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-07 13:59:25 +08:00
RevIQ
a1db9ca3c5 Initial commit: Publisher dashboard monorepo
Turborepo + Bun monorepo with:
- apps/publisher-dashboard: Svelte 5 SPA with SvelteKit, Tailwind CSS v4, shadcn-svelte
- packages/publisher-utils: Shared TypeScript utilities

Features:
- Performance dashboard page with metrics, charts, and data tables
- shadcn-svelte UI components with OKLCH color system
- Biome for linting/formatting with Svelte-specific overrides

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-06 17:25:21 +08:00