# ADR 0002: Provision Cosmic accounts through a separate restricted web adapter

Status: accepted for implementation; verification pending

Date: 2026-08-19

## Context

GMS v83 has no standard account-registration game opcode. The baseline Register button is inert. Cosmic can automatically create an account during a failed login, but that provides weak validation/rate-limit UX and does not satisfy a deliberate browser registration flow. Moonlight's op-101 launcher API is v214-specific, plain TCP, and relies on a different database and native launcher token flow.

The upstream repository says server behavior should remain unchanged.

## Decision

Keep the v83 game protocol and Cosmic behavior unchanged. Add a separate loopback-only web registration adapter that provisions rows through the existing Cosmic account schema with:

- strict server-side validation;
- Cosmic-compatible bcrypt;
- database uniqueness enforcement;
- generic duplicate/error responses;
- CSRF/origin enforcement and request/rate limits;
- secret-free structured audit events;
- a dedicated least-privilege database identity.

Expose the adapter only through the same-origin nginx `/mapleweb/` surface. Disable Cosmic automatic registration in production after adapter verification.

## Consequences

- The game server remains a pinned v83 authority.
- Registration can be tested independently with a disposable database.
- Passwords never need to be persisted in browser storage or passed through a v214 token mechanism.
- Database/schema compatibility must be tested at the pinned Cosmic commit and reviewed when that pin changes.
