code wiki / (root) / nx_nexus_fetch.nx

nx_nexus_fetch.nx

buildroot/runtime/nx_nexus_fetch.nx

26383 B517 linesdepth 21pulls 149 transitivereach 0 importersview sourcekind orphan library
docsdependenciesstructsconstsfunctions

about

nx_nexus_fetch.nx -- THE NEXUS MODS API DOOR (/compare/modding MD28, 2026-09-05): the modder's OWN API key, from the sovereign vault, over our own TLS, against api.nexusmods.com -- never a scraper through the mod page's Cloudflare challenge (measured 2026-09-05: nexusmods.com/skyrimspecialedition/mods/54994 answers the sovereign fetcher 403 Cf-Mitigated challenge, 8,279 B), never a bundled third-party client. THE FETCH LADDER IS THE SPINE'S OWN: nx_https_fetch_follow_hdr_best -- minimal TLS-1.3 hello, then the Chrome-JA3 hello, then TLS-1.2 -- with the api header injected into every 1.3 request. MEASURED 2026-09-06: the single-hello path (nx_https_fetch_hdr) completed the handshake with api.nexusmods.com and received ZERO application bytes (nrecs=1), which is what a fingerprint-gated CDN does to a bare client; the ladder exists for exactly that host class. THE KEY NEVER TOUCHES ARGV, STDOUT, A JOURNAL OR A LOG: it is opened by the estate's secret CLI (nx_secret get nexus_api -> /tmp/nxsecret.out, machine-bound AES-128-GCM vault), read once, used to build one request header, then the buffers are zeroed and the plaintext file is overwritten and unlinked. validate.json ECHOES the key in its body, so that body is never printed -- only the fields named below. usage: nx_nexus_fetch validate nx_nexus_fetch info <game_domain> <mod_id> nx_nexus_fetch files <game_domain> <mod_id> nx_nexus_fetch link <game_domain> <mod_id> <file_id> [nxm_key nxm_expires] nx_nexus_fetch fetch <game_domain> <mod_id> <file_id> <out-path> [nxm_key nxm_expires] exits: 0 ok | 2 usage | 3 NO-KEY (the vault could not open nexus_api) | 4 NET (the ladder returned nothing: bad url, trust, connect or every hello refused) | 5 HTTP (a status other than 200 -- the body's first bytes are printed, they carry the API's own reason) | 6 UNPARSED (200 but the named field is absent -- printed as absent, never invented) Every receipt is one line per record with key=value fields; the download receipt carries the sha256 of the bytes it wrote, sized from the file's DECLARED size_kb (an output buffer derived from the input, never a guessed cap). license_tier: ORIGINAL No hw writes (Rule 26). expect_exit: 0

dependencies 7 imports · 0 importers

nx_syscalls.nx nx_x509_trust_store.nx nx_trust_store_load_from_certdata. nx_https_fetch_follow.nx nx_tool_run.nx nx_media_state.nx nx_sha256.nx nx_nexus_fetch.nx

imports: nx_syscalls.nxnx_x509_trust_store.nxnx_trust_store_load_from_certdata.nxnx_https_fetch_follow.nxnx_tool_run.nxnx_media_state.nxnx_sha256.nx

imported by: nobody (leaf or entry point)

structs

none

consts

33const NF_API: *u8 = "https://api.nexusmods.com/v1/"
34const NF_SECRET_CLI: *u8 = "_offc/nx_secret_cli.elf"
35const NF_SECRET_NAME: *u8 = "nexus_api"
36const NF_SECRET_OUT: *u8 = "/tmp/nxsecret.out"
37const NF_CERTDATA: *u8 = "data/mozilla_certdata.txt"
38const NF_TRUST_MAX_CERTS: i64 = 512 // the fetch spine's own trust-store load parameters (nx_https_fetch.nx)
39const NF_TRUST_RESERVE: i64 = 4194304
40const NF_MAX_HOPS: i64 = 5
41const NF_OUT_CAP: i64 = 4194304 // one API body; the spine REFUSES a body that does not fit, it never truncates silently
42const NF_URL_CAP: i64 = 2048
43const NF_HDR_CAP: i64 = 2048
44const NF_KEY_CAP: i64 = 512
45const NF_CLI_CAP: i64 = 8192
46const NF_CLI_TMO_MS: i64 = 180000 // the machine-key derive is argon2id at 32 MiB, measured ~40 s on the NAS under load; a hang guard
47const NF_VAL_CAP: i64 = 65536
48const NF_SNIP: i64 = 300
49const NF_DL_HEADROOM: i64 = 1048576 // headers plus rounding above the declared size
50const NF_MODE_0644: i64 = 420
51const NF_EXIT_USAGE: i64 = 2
52const NF_EXIT_NOKEY: i64 = 3
53const NF_EXIT_NET: i64 = 4
54const NF_EXIT_HTTP: i64 = 5
55const NF_EXIT_UNPARSED: i64 = 6
56const NF_HTTP_OK: i64 = 200

functions

58func nf_slen(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n }
59func nf_puts(s: *u8) -> i64 { sys_write(1, s, nf_slen(s)); return 0 }
60func nf_putn(v: i64) -> i64
74func nf_streq(a: *u8, b: *u8) -> i64
80func nf_cat(dst: *u8, off: i64, s: *u8, cap: i64) -> i64
87func nf_catn(dst: *u8, off: i64, s: *u8, n: i64, cap: i64) -> i64
94func nf_crlf(dst: *u8, off: i64, cap: i64) -> i64
100func nf_zero(b: *u8, n: i64) -> i64 { var i: i64 = 0; while i < n { b[i] = 0 as u8; i = i + 1 } return 0 }
102func nf_is_digit(c: i64) -> i64 { if c >= 48 { if c <= 57 { return 1 } } return 0 }
106func nf_key(out: *u8, cap: i64) -> i64
149func nf_get(store: *TrustStore, tail: *u8, key: *u8, klen: i64, out: *u8, cap: i64, st: *i64) -> i64
172func nf_json_field(obj: *u8, n: i64, key: *u8, out: *u8, cap: i64) -> i64
211func nf_field_out(obj: *u8, n: i64, key: *u8, label: *u8, val: *u8, cap: i64) -> i64
222func nf_array_start(body: *u8, n: i64, key: *u8) -> i64
235func nf_http_refuse(body: *u8, n: i64, st: i64) -> i64
245func nf_call(store: *TrustStore, tail: *u8, key: *u8, klen: i64, resp: *u8, cap: i64, lenbox: *i64) -> i64
259func nf_tail3(dst: *u8, game: *u8, modid: *u8, suffix: *u8) -> i64
268func nf_validate(store: *TrustStore, key: *u8, klen: i64) -> i64
287func nf_info(store: *TrustStore, game: *u8, modid: *u8, key: *u8, klen: i64) -> i64
316func nf_files(store: *TrustStore, game: *u8, modid: *u8, key: *u8, klen: i64, want_fid: *u8, size_kb_out: *i64) -> i64
428func nf_hex(dig: *u8, out: *u8) -> i64
436func nf_fetch(store: *TrustStore, game: *u8, modid: *u8, fid: *u8, outp: *u8, nxm_key: *u8, nxm_exp: *u8, key: *u8, klen: i64) -> i64
477func nf_usage() -> i64
482func main(argc: i64, argv: *i64) -> i64