Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

hone-auth

Auth service for Hone sync. Perry-compiled native binary (2.8 MB) with Fastify + MySQL.

Endpoints

EndpointMethodPurpose
/auth/infoGETDiscovery — returns available auth methods
/auth/login?email=...GETCreates magic link, sends email
/auth/verify?token=...&deviceName=...&platform=...GETVerifies magic link, creates user + device, returns device token
/auth/validate?token=...GETValidates a device token (returns userId + tier)
/auth/me?token=...GETReturns user profile
/projects?token=...GETLists user’s registered projects
/projects/register?token=...&projectKey=...&name=...&roomId=...GETRegisters project for sync
/devices?token=...GETLists user’s registered devices
/healthGETHealth check
  1. Create a 64-char random hex token, store in the magic_links table with a 15-minute expiry.
  2. If SMTP is configured, send the link via email. Otherwise, the token is logged server-side (dev mode).
  3. On verify: validate the link (not already used, not expired), mark it as used, find or create the user, create a device record, and generate a device token.

Device Token Format

userId:deviceId:timestamp.hash

The hash is a double-djb2 HMAC:

djb2(String(djb2(secret + "|" + payload)) + "|" + secret + "|" + payload)

Database Schema

MySQL database on webserver.skelpo.net (user: hone). Tables:

  • users
  • devices
  • magic_links
  • projects
  • subscriptions

All identifiers use camelCase.

Configuration

File: auth.conf

DB_HOST=webserver.skelpo.net
DB_USER=hone
DB_PASS=<password>
DB_NAME=hone
PORT=8445
AUTH_SECRET=<shared-secret>
AUTH_BASE_URL=https://auth.hone.codes
SMTP_HOST=smtp.sendgrid.net
SMTP_PORT=587
SMTP_USER=apikey
SMTP_PASS=<sendgrid-key>
SMTP_FROM=Hone <noreply@hone.dev>

Build

cd hone-auth && perry compile src/app.ts --output hone-auth