INTERNODE AUTH

Sovereign Technical Blueprint

Universal, framework-agnostic identity gate and authentication kernel (v2.8.0) engineered with 100% native Web Standards and Node.js 26 (>=22.5.0) stdlib. Zero third-party npm runtime dependencies (node_modules free), Rule #0 security-hardened, featuring encrypted SQLite backup/restore, step-up authentication, configurable WebAuthn user verification, dynamic theme variable injection, live telemetry streaming (SSE), and released under the MIT License.

🛡️ Rule #0: Security & Cryptographic Hardening NON-NEGOTIABLE

Every layer of Internode Auth is constructed under strict zero-trust parameters to guarantee confidentiality, integrity, and replay defense:

🔒
Persistent Sliding-Window Rate Limits: SQLite WAL-backed attempts table surviving process restarts. Prevents brute-force on passphrases, TOTP codes, and recovery codes.
🎫
Cryptographic Setup Nonces: Single-use CSPRNG tokens gate 2FA bypass and enrollment endpoints, preventing parameter tampering or unauthenticated session issuance.
🛡️
Zero-Dependency Encryption at Rest: Authenticated AES-256-GCM vault with PBKDF2-SHA512 key derivation securely wraps TOTP secret seeds, remember tokens, and credentials.
🔑
Irreversible Passphrase Hashing: PBKDF2-SHA512 with 600,000 iterations, 16-byte random salt, and constant-time comparison (crypto.timingSafeEqual).
🛡️
Double-Submit CSRF & Origin Defense: Strict validation via internode_csrf cookie and x-internode-csrf header with origin and frame-ancestors locking.
👁️
Default UI Obfuscation: Sensitive tokens, API secrets, and 2FA recovery keys are masked by default with interactive reveal toggles.
✉️
Multi-Provider Mailer & Verification: Native zero-dependency HTTPS/TLS dispatch across Resend, Google Workspace (Gmail REST), Postmark, SendGrid, Mailgun, and SMTP, with auto-detection and safe local console fallback.

🖥️ UI Architecture, Pages & Decks 4 DEDICATED PORTALS

1. Gateway & Authentication Gate (/index.html)

High-density operator gate with turnkey modal (Sign In, First-Run Bootstrap Setup, 2FA Challenge, Passkey Assertion, and Google, GitHub, Discord, Authentik, Authelia, Keycloak, Tailscale Federated SSO). Features real-time station auth telemetry and an expanded live state machine inspection drawer.

2. Sovereign Profile & Security Deck (/profile.html)

Complete operator identity control:

  • Account & Identity: Avatar customization, Display Name, Custom Gender, Timezone & Locale selector, Emergency Recovery Notification Email, Public PGP / SSH Key Vault, and arbitrary User Variables.
  • Security & 2FA: Real-time Security Fortification Score gauge (0–100%), FIDO2 / WebAuthn passkey registration, 14-day rotated Remember Me session audit, and Federated SSO linking.
  • Developer Access: High-entropy API Token minting and Scoped JWT Studio with HS256/EdDSA signing and live token decoder.

3. Admin Command Console (/admin.html)

Institutional administration plane gated via server-side session authentication. Backed by a clean, modular single-responsibility controller architecture (public/js/admin/):

  • Telemetry & Health (telemetry.js): Live SSE stream (/api/admin/telemetry/stream), activity ticker, and live event velocity graph.
  • User Directory & RBAC (users.js): Multi-user RBAC directory administration (admin vs operator), sole-admin demotion defense, and reset token monitoring.
  • NOC Audit Trail (audit.js): Full SQLite audit log table, category filtering, and real-time SSE appending.
  • WebAuthn Passkeys (passkeys.js): FIDO2 biometric and hardware passkey enrollment and revocation ceremonies.
  • Auth & SSO Gate (auth-config.js): Dynamic feature toggles and OAuth/OIDC federated SSO providers.
  • Transactional Email (mail.js): Multi-provider email management, Rule #0 secret masking, and live diagnostic dispatch.
  • Vault Governance (vault.js): Master passphrase rotation, emergency backup code generation, step-up challenge interception, and factory reset.
  • Continuous Replication (replication.js): SQLite WAL continuous replication, sequence counters, and changeset streaming.

4. Self-Service Password Reset Portal (/reset-password.html)

Cryptographic token-based passphrase recovery. Validates 32-byte CSPRNG reset tokens, checks expiration, and updates master passphrases securely.

📧 Multi-Provider Transactional Email & Verification 6 PROVIDERS + FALLBACK

Internode Auth ships with a native, zero-dependency transactional email dispatcher (src/server/mailer.js) powering self-service password recovery (/reset-password.html) and email verification lifecycle confirmations. Built exclusively with Node.js standard libraries (node:https, node:tls, node:crypto) with 0 third-party npm packages.

⚡
Resend (HTTPS REST API): High-speed cloud email delivery using native HTTPS POST to api.resend.com/emails. Configured via RESEND_API_KEY.
🌐
Google Workspace / Gmail API: Direct OAuth2 REST API delivery to Gmail (gmail.googleapis.com) using base64url RFC 2822 MIME formatting. Configured via GMAIL_ACCESS_TOKEN.
📬
Postmark: Enterprise transactional email delivery via HTTPS REST API (api.postmarkapp.com/email). Configured via POSTMARK_SERVER_TOKEN.
📨
SendGrid: High-volume transactional email delivery via SendGrid v3 Mail API (api.sendgrid.com/v3/mail/send). Configured via SENDGRID_API_KEY.
📮
Mailgun: Flexible developer email delivery using Mailgun API v3 with Basic auth. Configured via MAILGUN_API_KEY and MAILGUN_DOMAIN.
🔌
Direct Native SMTP / SMTPS: 100% native TLS socket implementation (node:tls) with AUTH LOGIN for self-hosted mail servers. Configured via SMTP_HOST, SMTP_PORT, SMTP_USER, SMTP_PASS.
🛡️ Zero-Failure Resilience & Standalone Offline Mode:
  • Automatic Detection & Priority: Auto-detects configured credentials in order of availability, or honors explicit MAIL_PROVIDER selection (resend, google, postmark, sendgrid, mailgun, smtp, console).
  • Outage Fail-Safe Fallback: If an external provider experiences downtime, transient network failure, or API errors, outgoing links automatically fall back to secure terminal logging ([HYBRID-MAILER]) so operators and users are never locked out.
  • Zero Setup Dependency: If no mail provider is configured, the station runs fully functional offline in local console mode with zero warnings or errors.

📦 Drop-In Integration Quickstart 0 RUNTIME DEPS

Embed into any project using standard Web Components or programmatic JavaScript:

Option A: Turnkey Custom Element (Web Component)
<link rel="stylesheet" href="/src/styles/internode.css">
<script type="module" src="/src/index.js"></script>

<internode-signon-gate title="Production Gate"></internode-signon-gate>
Option B: 1-Line Programmatic JavaScript Helper
import { initInternodeGate } from '/src/index.js';

const gate = initInternodeGate({
  title: 'Secure Workstation',
  onAuthenticated: (operator) => {
    console.log('Authorized operator:', operator.username, operator.role);
  }
});

📡 Auth REST API Reference NATIVE HTTP

Method Endpoint Description Auth Required
POST /api/auth/setup Initial bootstrap configuration with optional 2FA Setup Nonce
POST /api/auth/setup/skip-2fa Complete initial station bootstrap without 2FA Setup Nonce
POST /api/auth/login Sign in with username and master passphrase No
POST /api/auth/logout Terminate session and invalidate auth cookies Yes
GET /api/auth/status Verify active session, user profile, and 2FA status Yes
GET /api/auth/session Inspect active session token and expiry Yes
GET /api/auth/config Query public authentication feature & provider availability No
POST /api/auth/2fa/verify Submit 6-digit TOTP verification code In-Challenge
POST /api/auth/2fa/backup Submit and burn emergency single-use recovery code In-Challenge
POST /api/user/2fa/enroll Initiate authenticated self-service TOTP 2FA enrollment Yes
POST /api/user/2fa/confirm Confirm TOTP code, activate 2FA, and mint backup codes Yes
POST /api/user/2fa/disable Deactivate 2FA with master password and CSRF validation Yes
POST /api/auth/passkey/login-challenge Request WebAuthn authentication assertion challenge No
POST /api/auth/passkey/login-verify Verify client biometric/hardware passkey assertion In-Challenge
POST /api/auth/passkey/register-challenge Request WebAuthn credential registration options Yes
POST /api/auth/passkey/register-verify Verify and enroll WebAuthn hardware passkey Yes
GET /api/auth/passkey/status Query station passkey availability status No
POST /api/auth/password-reset/request Request password reset token via email or console No
GET /api/auth/password-reset/verify Verify validity of password reset token No
POST /api/auth/password-reset/confirm Confirm password rotation with cryptographic token No
POST /api/auth/verify-email/request Dispatch email confirmation verification link No / Yes
GET /api/auth/verify-email/confirm Confirm email verification token and update account status No
GET /api/user/profile Retrieve operator profile, email, PGP keys, timezone Yes
POST /api/user/profile Update operator profile, timezone, PGP/SSH keys, variables Yes
GET /api/user/passkey List registered passkey credentials for current user Yes
POST /api/user/passkey Update or enroll passkey credential metadata Yes
DELETE /api/user/passkey Revoke passkey credential Yes
GET /api/user/api-keys List personal scoped API keys Yes
POST /api/user/api-keys Create scoped API key (Rate limited: 10/min) Yes
DELETE /api/user/api-keys Revoke personal API key Yes
POST /api/user/jwt/mint Mint scoped HS256 / EdDSA JWT token Yes
POST /api/user/jwt/verify Validate and inspect JWT token signature Yes
GET /api/user/federated-identities List linked federated OAuth/OIDC accounts Yes
DELETE /api/user/federated-identities/:provider Unlink federated identity (with fallback defense) Yes
GET /api/admin/users List all registered sovereign users Admin
POST /api/admin/users Provision new managed operator or admin account Admin
PUT /api/admin/users/:id/role Update user role with sole-admin defense Admin
POST /api/admin/users/:id/suspend Suspend user account and invalidate active sessions Admin
POST /api/admin/users/:id/unsuspend Re-activate suspended account Admin
DELETE /api/admin/users/:id Remove user account with sole-admin defense Admin
POST /api/admin/backup-codes/generate Generate emergency recovery codes batch Admin
GET /api/admin/password-resets List pending unexpired password reset tokens Admin
GET /api/admin/replication/status SQLite continuous replication node status & LSN Admin
GET /api/admin/replication/journal Stream SQLite replication WAL changeset journal Admin
POST /api/admin/replication/apply Apply replication changeset on standby node Admin
GET /api/admin/audit/stream Real-time Server-Sent Events (SSE) audit trail feed Admin
GET /api/admin/mail/config Retrieve sanitized transactional mail configuration and active provider Admin
POST /api/admin/mail/config Persist and hot-reload mail configuration with CSRF & secret masking Admin
POST /api/admin/mail/test Dispatch live signed diagnostic test email through active pipeline Admin
POST /api/auth/reset Factory reset station and purge all SQLite state Admin Only
GET /api/settings Retrieve user preferences and theme variables Yes
POST /api/settings Save user preferences and theme variables Yes
GET /api/consent Check GDPR and telemetry consent status No
POST /api/consent Update consent preferences (Rate limited: 20/min) No