code wiki / _hdl_build / nx_library_gate_handle.nx

nx_library_gate_handle.nx

buildroot/runtime/_hdl_build/nx_library_gate_handle.nx

4114 B80 linesdepth 10pulls 17 transitivereach 1 importersview sourcekind librarytopic library
docsdependenciesstructsconstsfunctions

about

nx_library_gate_handle.nx -- the LOGIN-GATE for /library on the live sites daemon (operator 2026-06-13: login-gate FIRST, then deploy). A dynamic handler the daemon calls for GET /library (mirrors the nx_wiki_queue_handle dispatch pattern): extract the OPAQUE session token from the request "X-Nishi-Session: <hex>" header, validate it (nx_ncs_validate_token, Ed25519), and: valid -> serve the worldwide scholarly library (knowledge/library.html) as 200 (SERVED=0) absent/forged/expired -> 302 -> /wiki/login (REDIRECT=1); data NEVER served unauthenticated. Library (no main) so the daemon imports it + one dispatch line. license_tier: ORIGINAL

dependencies 3 imports · 1 importers

nx_syscalls.nx nx_ed25519_signature.nx nx_no_cookie_session.nx nx_library_gate_handle.nx nx_library_gate_test.nx

imports: nx_syscalls.nxnx_ed25519_signature.nxnx_no_cookie_session.nx

imported by: nx_library_gate_test.nx

structs

none

consts

11const LG_MAGIC_262144: i64 = 262144
12const LG_MAGIC_262143: i64 = 262143
14const LG_SERVED: i64 = 0
15const LG_REDIRECT: i64 = 1
16const LG_TOKBYTES: i64 = 152

functions

18func lg_strlen(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} return n }
called by 2: lg_containslg_app
19func lg_contains(hay: *u8, hlen: i64, needle: *u8) -> i64
called by 1: nx_library_gate_handle calls 1: lg_strlen
24func lg_hexval(c: i64) -> i64
called by 1: lg_hexdecode
31func lg_hexdecode(hay: *u8, off: i64, hlen: i64, tok: *u8) -> i64
called by 1: nx_library_gate_handle calls 1: lg_hexval
46func lg_app(dst: *u8, off: i64, s: *u8) -> i64 { var i: i64=0; while s[i]!=(0 as u8){dst[off+i]=s[i];i=i+1} return off+lg_strlen(s) }
called by 1: nx_library_gate_handle calls 1: lg_strlen
47func lg_readfile(path: *u8, buf: *u8, cap: i64) -> i64 { let fd: i64=sys_openat_rd(path); if fd<0{return 0} var tot: i64=0; var r: i64=1; while r>0 { let d: *u8=((buf as i64)+tot) as *u8; r=sys_read(fd,d,cap-tot); if r>0{tot=tot+r} } sys_close(fd); return tot }
48func lg_wn(dst: *u8, off: i64, v: i64) -> i64 { let t: *u8=sys_mmap(28); var m: i64=v; var k: i64=0; if m==0{t[0]=48;k=1} while m>0{t[k]=48+(m%10);m=m/10;k=k+1} var i: i64=0; while i<k{dst[off+i]=t[k-1-i];i=i+1} return off+k }
called by 1: nx_library_gate_handle calls 1: sys_mmap
52func nx_library_gate_handle(req: *u8, reqn: i64, server_pub_32: *u8, now: i64, libpath: *u8, out: *u8, cap: i64, out_n: *i64) -> i64