You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
feat(nip98): verify the Authorization header against its request - #1355
Ansh-699's nip98::verify implementation, cherry-picked with -x from their fork commit d9d1966 (Ansh-699/nostream#2), authored by them.
Fills the Phase 1 stub: ports verifyNip98Auth from src/utils/nip98.ts with the capture's check order and reasons (CoreError::InvalidNip98), adds PayloadPolicy, hash_payload, is_nostr_authorization_header, 24 unit tests, and the crate-map and NIP-parity rows. The event field schema is split out of validate_event_value as decode_event_fields, unchanged in behaviour.
Replay stays with the admin job (ADR 0010). No caller of verify exists yet, so no call site moves.
cargo test -p nostream-core green; --lib nip98 runs 24 tests
Based on rewrite/main at 77e882ac; the cherry-pick is clean because the stub blob is identical to the fork's base ead3997
Contribution screening
The diff touches only .changeset/, crates/nostream-core/{error,lib,messages,nip98}.rs and docs/rewrite/{crate-map,nip-parity}.md: no workflow, dependency, build-script or install-time change
No hidden Unicode tag characters, no NUL bytes, no CR line endings; the only non-ASCII is em/en dashes in prose
The comment's prose was screened by the immune system: clear, level 5, P(manipulation) 0.02
Summary by CodeRabbit
New Features
Added NIP-98 authorization header verification, including checks for event validity, signatures, timestamps, and URL and method matching.
Added configurable payload verification, with options to ignore payload checks, verify a provided payload tag, or require a tag for non-empty request bodies.
Invalid or malformed authorization headers and mismatched claims now return verification errors with a specific reason.
Ports verifyNip98Auth (src/utils/nip98.ts) in place of the Phase 1 stub, in the capture's check order and with its reasons, through CoreError::InvalidNip98. The crate map and the NIP parity table no longer list the verifier as a stub. Replay stays with the admin job (ADR 0010).
Refs #1215
(cherry picked from commit d9d1966)
No actionable comments were generated in the recent review.
Walkthrough
The core crate now verifies NIP-98 Authorization headers, checks event and request claims, and applies configurable payload checks. The change also separates event field decoding from event refinements and adds verifier tests and documentation updates.
Changes: NIP-98 Verification
Layer / File(s)
Summary
Event field decoding and errors crates/nostream-core/src/error.rs, crates/nostream-core/src/messages.rs
Adds CoreError::InvalidNip98 and a field-only event decoder. validate_event_value applies event refinements after decoding.
Header verification and validation crates/nostream-core/src/nip98.rs, .changeset/nip98-verify.md, crates/nostream-core/src/lib.rs, docs/rewrite/crate-map.md, docs/rewrite/nip-parity.md
Implements header, event, request-tag, and optional payload verification. Adds tests and updates crate and rewrite documentation about verification and replay-claim ownership.
sequenceDiagram
participant Caller
participant verify
participant decode_header
participant decode_event_fields
Caller->>verify: Header, request data, payload policy, skew, and current time
verify->>decode_header: Decode Authorization header
verify->>decode_event_fields: Validate decoded event fields
verify-->>Caller: Verified HttpAuth claims or InvalidNip98 error
Loading
Possibly related issues
cameri/nostream#1215: This PR adds NIP-98 verifier unit tests, including wrong URL-tag and stale timestamp checks.
cameri/nostream#670: This PR adds the NIP-98 verification function that an admin authentication flow could use, but does not add that flow.
cameri/nostream#719: This PR adds the verifier and payload policy that an upload integration could use, but does not change the media pipeline.
Merge Risk: Minimal · up to 04761
This adds NIP-98 Authorization header verification to the core crate. Nothing calls it yet, so there is no production impact today. Existing event validation behaves as before, and no merge-blocking risk was found.
Pre-merge checks: 4
Check name
Status
Explanation
Description Check
Check skipped - CodeRabbit’s high-level summary is enabled.
Title check
The title states the main change: the NIP-98 Authorization header is now verified against its request. The raw summary confirms the verify stub was replaced with header, URL, method, timestamp, and pa…
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Full details: Title check
Explanation
The title states the main change: the NIP-98 Authorization header is now verified against its request. The raw summary confirms the verify stub was replaced with header, URL, method, timestamp, and payload checks, so the title matches the changeset.
Finishing Touches
Generate unit tests (beta)
Commit to this branch
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
A rabbit checks the header’s sign, Then tests each tag and date in line. A payload hash may join the show, While empty bodies pass or go. The claims return, the errors speak, And carrots wait beside the sheet.
Recent review info
Automatic approval policy
Commit: 047619d272bb.
Setting
Effective value
Source
Automatic approvals
Enabled
Global configuration
Merge risk
Minimal
Global configuration
Security risk
Not set
Global configuration
Not set means no limit was configured after inheritance. Use @coderabbitai configuration to inspect the resolved settings and their sources.
Run configuration
Source mode: Auto
Repository: Unavailable
Branch: Unavailable
File: No configuration file from this repository applied
Commit: Unavailable
Layers: Organization UI
Review profile: CHILL
Plan: Advanced
Run ID: 04acac65-c985-487e-8c93-68800061f3f2
Commits
Reviewing files that changed from the base of the PR and between 77e882a and 047619d.
Files selected for processing: 7
.changeset/nip98-verify.md
crates/nostream-core/src/error.rs
crates/nostream-core/src/lib.rs
crates/nostream-core/src/messages.rs
crates/nostream-core/src/nip98.rs
docs/rewrite/crate-map.md
docs/rewrite/nip-parity.md
Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.
Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.
[Low impact] The PR appears safe to merge; no actionable issues were found.
Summary
Implements nip98::verify with header decoding, event checks, signature checks, and request binding.
The core crate now checks NIP-98 headers against their HTTP request.
Review used source inspection; tests were not run.
Diagram
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[Authorization header] --> B[Check shape, size, encoding and JSON]
B --> C[Check event fields and kind]
C --> D[Check time window]
D --> E[Check event ID and signature]
E --> F[Match URL and method]
F --> G[Apply payload policy]
G --> H[Return HttpAuth]
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
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
Ansh-699's
nip98::verifyimplementation, cherry-picked with-xfrom their fork commitd9d1966(Ansh-699/nostream#2), authored by them.Fills the Phase 1 stub: ports
verifyNip98Authfromsrc/utils/nip98.tswith the capture's check order and reasons (CoreError::InvalidNip98), addsPayloadPolicy,hash_payload,is_nostr_authorization_header, 24 unit tests, and the crate-map and NIP-parity rows. The event field schema is split out ofvalidate_event_valueasdecode_event_fields, unchanged in behaviour.Replay stays with the admin job (ADR 0010). No caller of
verifyexists yet, so no call site moves.Refs #1215.
Verification
cargo fmt --all -- --checkcleancargo clippy -p nostream-core --all-targets -- -D warningscleancargo test -p nostream-coregreen;--lib nip98runs 24 testsrewrite/mainat77e882ac; the cherry-pick is clean because the stub blob is identical to the fork's baseead3997Contribution screening
.changeset/,crates/nostream-core/{error,lib,messages,nip98}.rsanddocs/rewrite/{crate-map,nip-parity}.md: no workflow, dependency, build-script or install-time changeclear, level 5, P(manipulation) 0.02Summary by CodeRabbit