2 commits in all time
Mar 19, 2026 12:09 – Jun 17, 2026 12:09 UTC
SIWE / EIP-4361 conformance fixes for SIWBB challenge construction
Three behavioural fixes + one new field, all backwards-compatible with the SIWBB-aware parser path: 1. Not Before line previously emitted a trailing `\n` that broke the Resources parser when both fields were present (a blank line shifted resource indices). Removed the trailing newline; this matches EIP-4361 §3 which has no trailing newline on optional key-value lines. Existing messages without Resources are unaffected. 2. Added optional `requestId` field on `ChallengeParams<T>` and emit it as `Request ID: <value>` between Not Before and Resources, in the field order EIP-4361 §3 specifies. The parser (constructChallengeObjectFromString) now also reads it back. SIWE- aware integrations that supply a Request ID for server-side correlation now Just Work; existing callers that omit it get the same message they did before. 3. Construction now hard-fails on the cheap-to-detect EIP-4361 violations: statements containing embedded newlines (the parser cannot recover line offsets) and nonces shorter than 8 alphanumeric characters. These are caller bugs that previously produced messages strict SIWE libraries reject; fail-fast is better than fail-late at verification time. The BitBadges-specific `Asset Ownership Requirements:` extension stays exactly as-is. It sits after Resources, so strict SIWE parsers treat it as part of the last resource line and ignore it; our parser reads it through the dedicated `parseChallengeAssets` path. Documented this explicitly so future maintainers don't try to "clean it up". Tests: 7 specs covering Request ID emission position, the Not Before trailing-newline regression, statement and nonce validation, full construct→parse round-trips, and AOG-extension preservation. Test infrastructure: added jest + ts-jest (no native deps) and a minimal config that targets src/**/*.spec.ts and excludes the UI tree. Refs bitbadges-autopilot#0359. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
e539bc8e
feat/siwe-conformance
6/4,995 ++ 2,471 --