pediatric-ai-scribe-v3/src/utils
Daniel 39c1663334 feat: invite-only registration
registration_enabled was a single switch: open to anyone, or closed to
everyone. This adds the setting an operator actually wants in between — open
to people you invited.

A code is single-use, expires (7 days by default, 90 maximum), and can be
revoked or deleted. It is stored hashed with only its last four characters
kept, because an invite grants account creation and a database dump should
not hand someone a working one. The code is readable exactly once, in the
response that creates it.

The claim is a single conditional UPDATE carrying every condition, so two
registrations racing the same code cannot both succeed. It happens after the
account exists, so a code is never spent on a failed registration — and if
the race is lost, the just-created account is removed rather than left behind
as a free registration. The rejection never says which of the four reasons
applied; distinguishing them would tell someone probing codes which guesses
were closer.

Codes avoid I, L, O and U so they survive being read aloud or copied off a
screen, and matching ignores case and separators.

The sign-up field appears only when the server says a code is required. The
admin card creates, lists, revokes and deletes, and carries the toggle.

Verified against the live database: create, claim, second claim refused,
unknown code refused, revoking a used code refused, delete. 684 tests pass.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Dv6sqaY6Vq3ChZHMem3cnU
2026-09-10 23:12:07 +02:00
..
ai.js chore: log image parts attached to provider requests 2026-09-08 16:45:07 +02:00
audioBackupStore.js refactor: one place decides which bucket, on which S3, with which credentials 2026-09-10 17:09:13 +02:00
auditQueue.js Batch of security + scale fixes 2026-04-14 05:24:40 +02:00
buildId.js feat: ship reviewed prompt history, conversation limits and account protections 2026-09-07 04:01:01 +02:00
clinicalAnswer.js feat: display-only sources toggle, signed-out preview, and a composer that carries the toolbar 2026-09-10 04:12:36 +02:00
clinicalConversation.js feat: Open WebUI-style assistant workspace — 3-column layout, markdown/math/code/tables, autosave with images, translation (LibreTranslate+DeepL), citation modal, Learning Hub moved in, handoff removed 2026-09-08 18:52:35 +02:00
clinicalMcpClient.js refactor: ped-ai calls clinical_semantic_search only 2026-09-10 17:22:40 +02:00
clinicalPromptPool.js feat: improve clinical assistant prompts 2026-06-06 00:01:07 +02:00
clinicalPrompts.js fix: mobile layout regression, workspace menu in the assistant rail, prompt as principles 2026-09-09 22:24:10 +02:00
clinicalRetrieval.js refactor: retrieval is text-only; admins can add model ids discovery never returns 2026-09-09 23:35:06 +02:00
clinicalTranslation.js fix: translated answers keep their source chips; the patient take home can be translated 2026-09-09 18:40:23 +02:00
config.js Feat: admin CMS, save/resume encounters, user templates, SSHADESS, well visit notes, sick visit, ROS/PE checklists, ICD-10 diagnoses 2026-03-22 16:43:39 -04:00
crypto.js Security hardening: PHI encryption, argon2, DOMPurify, SRI 2026-04-14 02:49:38 +02:00
embeddings.js simplify speech and embeddings through litellm 2026-05-09 05:09:02 +02:00
errors.js harden logging and observability 2026-05-08 19:08:19 +02:00
extensionTransfer.js feat: ship reviewed prompt history, conversation limits and account protections 2026-09-07 04:01:01 +02:00
fileType.js Security hardening: PHI encryption, argon2, DOMPurify, SRI 2026-04-14 02:49:38 +02:00
generatedImageLinks.js feat: integrate durable image jobs/private assets into current core 2026-09-07 16:53:42 +02:00
generatedImages.js perf: store real image previews in MinIO, generated at creation and on demand 2026-09-10 06:39:30 +02:00
generatedImageStorage.js perf: store real image previews in MinIO, generated at creation and on demand 2026-09-10 06:39:30 +02:00
generationOptions.js Send reasoning options only to supported model 2026-08-27 21:25:38 +02:00
imageTool.js fix: mobile layout regression, workspace menu in the assistant rail, prompt as principles 2026-09-09 22:24:10 +02:00
litellm.js fix litellm metadata discovery auth 2026-05-09 15:15:47 +02:00
logger.js fix: correct a false Settings claim; make every test child's stdout pure TAP 2026-09-10 15:41:44 +02:00
metrics.js fix metrics route normalization 2026-05-08 20:22:14 +02:00
models.js fix: correct a false Settings claim; make every test child's stdout pure TAP 2026-09-10 15:41:44 +02:00
notify.js Add biometric auth, ntfy push notifications, mobile improvements 2026-04-11 02:35:07 +02:00
objectStorage.js refactor: one place decides which bucket, on which S3, with which credentials 2026-09-10 17:09:13 +02:00
passwords.js Security hardening: PHI encryption, argon2, DOMPurify, SRI 2026-04-14 02:49:38 +02:00
patientTakehome.js feat: patient take home (copy/export/email), composer mic dictation, voice conversation mode, provider-aware translate languages 2026-09-08 20:01:46 +02:00
platform.js Sliding 24h idle timeout (web) + persistent mobile + 2FA backup codes 2026-04-14 04:24:54 +02:00
policy.js feat: ship reviewed prompt history, conversation limits and account protections 2026-09-07 04:01:01 +02:00
promptCatalog.js feat: integrate durable image jobs/private assets into current core 2026-09-07 16:53:42 +02:00
promptRevisions.js feat: ship reviewed prompt history, conversation limits and account protections 2026-09-07 04:01:01 +02:00
prompts.js feat: ship reviewed prompt history, conversation limits and account protections 2026-09-07 04:01:01 +02:00
promptSafe.js Batch of security + scale fixes 2026-04-14 05:24:40 +02:00
redact.js harden logging and observability 2026-05-08 19:08:19 +02:00
redis.js feat: improve clinical assistant prompts 2026-06-06 00:01:07 +02:00
registrationInvites.js feat: invite-only registration 2026-09-10 23:12:07 +02:00
sessions.js Add node-pg-migrate for versioned schema changes + better mobile UA labels 2026-04-14 05:06:19 +02:00
sttProvider.js fix: patch nodemailer; Settings offers STT models the gateway really has 2026-09-10 15:54:57 +02:00
ttsProvider.js feat: ship reviewed prompt history, conversation limits and account protections 2026-09-07 04:01:01 +02:00
urlSafety.js feat: integrate durable image jobs/private assets into current core 2026-09-07 16:53:42 +02:00