code wiki / _hdl_build / nx_email_portal_daemon.nx

nx_email_portal_daemon.nx

buildroot/runtime/_hdl_build/nx_email_portal_daemon.nx

56025 B973 linesdepth 17pulls 55 transitivereach 1 importersview sourcekind servicetopic email
docsdependenciesstructsconstsfunctions

about

nx_email_portal_daemon.nx -- the mail.<domain> EMAIL-PORTAL daemon on the CANONICAL ecosystem auth (the SAME Modern Auth the doc portal / status use: OPAQUE-3DH + Argon2id + NO-COOKIE Ed25519 session). Replaces the demo-grade nx_email_webmail_daemon (hardcoded single mailbox, NO auth) with a real multi-user, per-domain portal: GET / -> login + register + mail SPA shell (public) POST /mail/register -> invite-gated OPAQUE self-registration (handle -> <handle>@<domain>) POST /mail/login -> handle+passphrase -> 200 {"token":...} | 401 * /mail/* (token) -> X-Nishi-Session validates -> the mailbox is derived ONLY from the session handle (per-user isolation BY CONSTRUCTION -- no request parameter can address another user's mailbox): GET /mail/inbox -> HTML fragment: newest-first message list (Subject/From, escaped) GET /mail/msg?n=K -> HTML fragment: the raw message, HTML-escaped POST /mail/del?n=K -> soft-delete (seg_store tombstone; history preserved, rule 13) POST /mail/send -> to/subject/body form: rcpt@<domain> -> REAL local delivery into the rcpt mailbox (same store the data-driven MTA delivers into, so real inbound mail appears here the moment MX/relay is armed); foreign rcpt -> appended to relay-queue@<domain> + an HONEST "QUEUED-EXTERNAL (relay not armed)" receipt -- never a fake send. GET /mail/whoami -> {"handle":...,"mailbox":...} Loopback HTTP daemon behind the SNI router's mail.<d> row (sites.elf reverse-proxies; TLS terminates at sites.elf with the per-domain wildcard). Every response carries Content-Length (the buffered-proxy contract). Pure router epd_handle = bytes-in/bytes-out (the gate drives it in-process, no socket). license_tier: ORIGINAL

dependencies 6 imports · 1 importers

nx_status_daemon.nx nx_modern_auth_flow.nx nx_syscalls.nx nx_invite_token.nx nx_opaque_login.nx nx_email_webmail.nx nx_email_portal_daemon.nx nx_email_portal_gate.nx

imports: nx_status_daemon.nxnx_modern_auth_flow.nxnx_syscalls.nxnx_invite_token.nxnx_opaque_login.nxnx_email_webmail.nx

imported by: nx_email_portal_gate.nx

call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown

main sys_write sd_atoi sd_len sys_mmap sys_mkdir nx_uas_server_keys_load_or sys_mmap ↻ sys_read_file sys_openat_rd sys_lseek sys_mmap ↻ sys_read sys_close _uas_hex_dec _uas_nib nx_csprng_fill sys_mmap ↻ nx_csprng_urandom_path sys_openat_rd ↻ sys_read ↻ sys_close ↻ nx_opq_derive_keypair sys_mmap ↻ _voprf_load_context_string u256_alloc nx_scratch nx_scratch_init sys_mmap ↻ nx_scratch_oom sys_write ↻ sys_exit sys_mmap ↻ nx_opq_hash_to_scalar sys_mmap ↻ nx_h2c_expand_message_xmd_ sys_mmap ↻ _h2c_i2osp_1 _h2c_i2osp_2 u256_alloc ↻

structs

none

consts

30const EPD_MAGIC_1024: i64 = 1024
31const EPD_MAGIC_8192: i64 = 8192
33const EPD_REQCAP: i64 = 65536
34const EPD_OUTCAP: i64 = 262144
35const EPD_BODYCAP: i64 = 131072
36const EPD_MSGCAP: i64 = 24576 // assembled outbound message cap
37const EPD_SHOWCAP: i64 = 16384 // per-message render cap (truncated view beyond)
38const EPD_INBOX_PAGE: i64 = 50 // newest-first page size

functions

42func epd_handle_ok(h: *u8, n: i64) -> i64
65func epd_hex32(src: *u8, out: *u8) -> i64
77func epd_mailmap_path(ctx: *NxAuthContext, out: *u8) -> i64
88func epd_map_put(path: *u8, hexuid: *u8, h: *u8, hn: i64) -> i64
105func epd_map_get(path: *u8, hexuid: *u8, out: *u8, cap: i64) -> i64
137func epd_ci_eq(h: *u8, hn: i64, lit: *u8) -> i64
154func epd_mailbox(h: *u8, hn: i64, domain: *u8, out: *u8) -> i64
166func epd_resp(out: *u8, status: *u8, ctype: *u8, body: *u8, blen: i64) -> i64
181func epd_qn(path: *u8, pn: i64) -> i64
called by 1: epd_handle
213func epd_shell(domain: *u8, out: *u8) -> i64
called by 1: epd_handle calls 3: sys_mmapsd_catepd_resp
243func epd_inbox_frag(prefix: *u8, mailbox: *u8, body: *u8) -> i64
285func epd_assemble(fromb: *u8, tob: *u8, tn: i64, subjb: *u8, sn: i64, bodyb: *u8, bn: i64, msg: *u8) -> i64
309func epd_qs_mailbox(ctx: *NxAuthContext, domain: *u8, path: *u8, pn: i64, now: i64, shand: *u8, shn_p: *i64, mbox: *u8) -> i64
329func epd_splice(body: *u8, b: i64, sraw: *u8, srn: i64) -> i64
337func epd_landing_mail(out: *u8, b64: *u8, b64n: i64) -> i64
347func epd_inbox_page(prefix: *u8, mbox: *u8, sraw: *u8, srn: i64, out: *u8) -> i64
391func epd_read_page(prefix: *u8, mbox: *u8, idx: i64, sraw: *u8, srn: i64, out: *u8) -> i64
416func epd_write_page(domain: *u8, sraw: *u8, srn: i64, out: *u8) -> i64
433func epd_deliver(domain: *u8, prefix: *u8, shand: *u8, tob: *u8, sub: *u8, bod: *u8, lens: *i64, rmsg: *u8) -> i64
474func epd_sent_page(rmsg: *u8, rlen: i64, sraw: *u8, srn: i64, out: *u8) -> i64
488func epd_handle(ctx: *NxAuthContext, domain: *u8, prefix: *u8, req: *u8, req_n: i64, out: *u8) -> i64
913func main(argc: i64, argv: *i64) -> i64