Skip to content

fix: normalize BRC-100 bytes across wallet transports - #482

Merged
ty-everett merged 15 commits into
mainfrom
codex/fix-brc29-uint8array
Aug 15, 2026
Merged

fix: normalize BRC-100 bytes across wallet transports#482
ty-everett merged 15 commits into
mainfrom
codex/fix-brc29-uint8array

Conversation

@ty-everett

@ty-everett ty-everett commented Aug 14, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • add one public SDK byte-normalization and portable-JSON contract for BRC-100 wallet transports
  • preserve number[] and Uint8Array fast paths while supporting Buffer, cross-realm typed arrays, and historical contiguous numeric-key objects at schema-owned byte fields
  • preserve arbitrary application JSON exactly; plain numeric-key objects are never reinterpreted by generic serializers or opaque AuthSocket, remittance, relay, WAB, or application-body channels
  • apply typed recovery across BRC-29, wallet JSON/WebView, authenticated HTTP/Express, Message Box/PeerPay/PeerToken, overlay outputs, wallet relay RPCs, BTMS, Simple adapters, and Wallet Toolbox boundaries
  • keep the public normalizeWalletJsonTx helper's historical top-level-only contract
  • preserve existing React Native integrations: BRC-100 originators are no longer treated as MessageEvent.origin, schemeless domains and ports normalize correctly, originless native events work, mismatches reject and clean up, and auto-detection is bounded
  • add static boundary guards, exact JSON property testing, and a critical mutation ratchet so this regression class cannot silently recur
  • make mutation selection fail closed to all current targets when a base marker cannot be resolved

Review follow-up

The two reported blockers are fixed:

  1. {"eventName":"applicationEvent","data":{"0":1,"1":2}} now serializes and decodes unchanged. Real typed arrays still serialize as portable arrays. Historical numeric-key recovery occurs only at explicitly typed protocol fields.
  2. Existing new WalletClient('react-native', 'myapp.com') integrations no longer pass the originator into the RN event filter. Explicit RN filters accept normalized full origins and originless native dispatch; a matching-origin mismatch rejects instead of hanging. Auto-detection has bounded 1-second fast probes and retains the 200 ms XDM fallback.

The adjacent review items are also addressed: {tx:{}} and other empty/byte-like application objects remain unchanged, the exported top-level normalizeWalletJsonTx behavior is restored, stale mutation markers select every current target, and the governed marker is unique.

Release scope

Patch/minor releases are prepared for SDK 2.4.1 and the affected dependent packages already versioned in this PR. No package or image has been published by this PR.

Validation

  • repository health: 184/184 policy tests; 38 projects; 0 contract findings; 0 control errors
  • lint: zero warnings; format and strict typecheck passed across all 37 non-root projects
  • security audit: no new exception; two existing governed high advisories remain ignored by policy
  • SDK coverage: 156 suites / 5,915 tests; 94.77% statements, 87.09% branches, 95.55% lines
  • Message Box coverage: 9 suites / 212 tests
  • BTMS coverage: 4 suites / 106 tests
  • Wallet Relay coverage: 9 suites / 143 tests
  • Wallet Toolbox coverage: 216 suites / 2,023 passed + 1 governed skip
  • AuthSocket client/server, Auth Express, Simple, WAB, remittance, overlay, RN, and wallet-JSON focused regressions pass
  • affected full package suites: 8,430 passed + 1 governed skip before the additional property/RN cases; all newly added focused cases also pass
  • new sdk-brc100-json critical mutation target: 100% (19 killed / 0 survived / 0 no-coverage; 90% minimum)
  • existing affected mutation targets pass: SDK auth HTTP 84.96%, AuthSocket server 89.06%, AuthSocket client 87.69%
  • local repository patch coverage: 92.23% (475/515 changed line/branch points; 90% target)
  • SDK and Wallet Toolbox builds pass; exact SDK tarball browser contract passes locally at Vite 741,120 raw / 179,890 gzip / 145,539 Brotli, esbuild 559,731 / 162,971 / 135,298, and UMD 554,475 / 158,896 / 131,781 bytes
  • Wallet Toolbox mobile contract passes locally at Metro 1,660,192 raw / 419,050 gzip / 326,151 Brotli and Hermes 3,365,860 / 1,346,101 / 1,060,452 bytes; hosted Linux measured the reviewed Hermes gzip artifact at 1,365,319 bytes, below the narrow 1,366,000-byte cross-platform ceiling
  • clean packed Wallet Toolbox browser consumer passes with Vite/esbuild, 101 Vite modules, and no Node/server leakage; reviewed compatibility growth remains bounded by raw/gzip/Brotli ratchets
  • root byte-boundary and mutation-governance guards pass
  • git diff --check

Exact head: 48cbbccadaa682c2af9e39c2108e5f229f12bd0d

Hosted gates correctly blocked earlier revisions on five new Sonar maintainability findings and narrow portable bundle-size misses. The findings were fixed without changing compatibility behavior, and the existing browser/mobile ratchets were recalibrated to the exact reviewed artifacts with tight ceilings. The current main R1-K1 hardware-wallet merge was reconciled, its generated package ledgers were regenerated, and repository health remains clean. Hosted exact-head CI, CodeQL, Sonar, conformance, aggregate patch coverage, and the required merge gate are rerunning and must be terminal-successful before merge.

@ty-everett ty-everett changed the title fix(sdk): normalize BRC-29 wallet transaction bytes fix: normalize BRC-100 bytes across wallet transports Aug 14, 2026
@ty-everett
ty-everett marked this pull request as ready for review August 15, 2026 01:52
@sonarqubecloud

Copy link
Copy Markdown

@ty-everett
ty-everett merged commit e0838bc into main Aug 15, 2026
70 of 71 checks passed
@ty-everett
ty-everett deleted the codex/fix-brc29-uint8array branch August 15, 2026 04:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant