Skip to content

Auth Types

Auth types provide secure handling of credentials and tokens.

TypeExpands To
col.username()string(50) + pattern + min(3)
col.password_hash()string(255), hidden from API
col.token()string(64), for API keys
schemas/auth/user.js
export default table({
id: col.id(),
username: col.username(),
password_hash: col.password_hash(),
api_token: col.token(),
});

Usernames must be at least 3 characters, lowercase alphanumeric with underscores:

^[a-z0-9_]+$

This pattern enforces:

  • Lowercase letters only (a-z)
  • Numbers allowed (0-9)
  • Underscores allowed (_)
  • Minimum length of 3 characters (enforced via min constraint)
  • Maximum length of 50 characters (enforced via string length)

The password_hash column is automatically excluded from API responses. Always hash passwords before storage—never store plaintext.

64-character string suitable for API keys and session tokens. Generate using cryptographically secure random functions.