P2: FURS fiscal verification (ZOI/EOR, JSON/JWS) — unit-verified, live-verify deferred#4
Merged
Merged
Conversation
TS/Effect port of the FURS JSON/JWS protocol (src/lib/furs/), cross-checked vs node-furs, jurgenwerk (Ruby), and python-furs-fiscal: - cert: load taxpayer PKCS#12 → key + identity (serial as exact BigInt; real test-cert serials exceed 2^53). - zoi: MD5(RSA-SHA256 / PKCS#1 v1.5( taxNo + dd-MM-yyyy HH:mm:ss + … )). PKCS#1 v1.5 (deterministic) + dashes date — resolves the node-furs (dots) vs python-furs (PSS) divergence toward the deterministic, 2-of-3 form. - jws: RS256 + FURS custom header (serial as exact integer literal). - messages: InvoiceRequest + immovable BusinessPremiseRequest. - client: Effect echo / registerBusinessPremise / reportInvoice (→ ZOI+EOR+printable), mutual-TLS to blagajne-test.fu.gov.si:9002. Tests: 40 pass / 1 skip (ZOI cross-validated vs independent node:crypto; JWS verifies; loads the real FURS demo test cert). tsc clean. Live test-env round-trip deferred: bun 1.3.6 doesn't present an outbound mTLS client cert, and the legacy FURS endpoint rejects modern-OpenSSL TLS from a proxied net — runtime/env, not the code. Opt-in furs-live.test.ts runs it under a Node/unproxied runtime. See ROADMAP + CLAUDE. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this adds
P2 — Slovenian FURS fiscal verification (cash-register receipts → ZOI/EOR),
src/lib/furs/. A TS/Effect port of the FURS JSON/JWS protocol, cross-checked against three reference clients:node-furs-fiscal-verification(JS),jurgenwerk/furs_fiscal_verification(Ruby, production-proven),boris-savic/python-furs-fiscal(the canonical one).Standalone & framework-agnostic, like the rest of fiscalize — the Medusa plugin track wraps it.
cert.tszoi.tsMD5(RSA-SHA256/PKCS#1 v1.5(content))+ the QR/PDF417 printable stringjws.tsmessages.tsInvoiceRequest+ immovableBusinessPremiseRequestclient.tsecho/registerBusinessPremise/reportInvoice(→ ZOI + EOR + printable), mutual-TLSDecisions / gotchas worth knowing
SHA256withRSA), python-furs uses PSS (randomized!). PKCS#1 v1.5 is deterministic (matches the spec's worked example) and is what node-furs + jurgenwerk (RubyRSA#signdefault) use — 2 of 3, and the right one. FURS doesn't recompute the ZOI, so PSS "works" too, but v1.5 is correct.dd-MM-yyyy HH:mm:ss(python + jurgenwerk agree; node-furs's dots were the outlier — and node-furs also has amd5(sig.sign)bug passing the function).6051472362733128891(> 2^53) — JSnumberwould corrupt it. Kept as an exact decimal string and emitted as a raw integer literal in the hand-built JWS header.Geslo123#(the README "SCREWFURS" in jurgenwerk is a placeholder; the real one is in its spec).Verification
bun test→ 40 pass / 1 skip / 0 fail. FURS-specific: ZOI cross-validated against an independentnode:cryptosign+MD5, deterministic; JWS signature verifies against the public key;loadP12loads the real FURS demo test cert ("TESTNO PODJETJE", DavPotRacTEST).bunx tsc --noEmitclean.A live call to
blagajne-test.fu.gov.si:9002could not be completed from the build environment:fetchtls.cert/keyandnode:httpscert/keyboth failECONNRESET(the server requires a client cert; bun never sends it).node:httpseven rejectspfx("pfx is not supported"). Real bun limitation — candidate line forbun.md(deferred, not editing the global rule here).BAD_RECORD_MAC) even withSECLEVEL=0/minVersion TLSv1— legacy server and/or this sandbox's HTTPS proxy breaking raw mTLS.The cert is valid and self-provisionable; the implementation is unit-proven. The gap is purely runtime + network.
furs-live.test.tsruns the live round-trip wherever mTLS works (setFISCALIZE_FURS_TEST_P12+FISCALIZE_FURS_TEST_PASSPHRASE); skipped by default.CLAUDE.md/ROADMAP.md. Don't schedule FURS on bun-in-sandbox. The one-shot live EOR confirmation is deferred to such a runtime (you/Nik).Also deferred (ROADMAP)
Verify FURS's response JWS signature (refs skip it); refunds/corrective receipts; movable premises (A/B/C); sales-book mode.
Rebased onto main (includes the merged #3 privacy/bunfig corrections), so the diff is P2 only.
🤖 Generated with Claude Code