feat(nip98): add Authorization header verifier - #722
Open
Anshumancanrock wants to merge 1 commit into
Open
Conversation
🦋 Changeset detectedLatest commit: a569fcc The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Anshumancanrock
force-pushed
the
feat/nip98-verifier
branch
from
August 8, 2026 18:17
1174513 to
eedfafa
Compare
Collaborator
There was a problem hiding this comment.
Pull request overview
Adds foundational NIP-98 support by introducing a standalone utility to verify Authorization: Nostr <base64-event> headers (kind 27235) and accompanying unit tests, plus a small unit test import cleanup.
Changes:
- Added
verifyNip98Auth()+ helpers to parse and validate NIP-98 auth headers (kind, skew window, payload binding, event id + signature). - Added a comprehensive unit test suite for NIP-98 verification behavior.
- Updated
info.spec.tsto use ES module imports (fixing the sinon redeclare issue) and extended constants for NIP-98 kind/tags.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
src/utils/nip98.ts |
New NIP-98 Authorization header verification utility. |
src/constants/base.ts |
Adds NIP-98 HTTP_AUTH kind and u/method/payload tag constants. |
test/unit/utils/nip98.spec.ts |
New unit tests covering NIP-98 parsing/validation edge cases. |
test/unit/cli/info.spec.ts |
Switches to ESM imports and reformats a stub to fix test suite issues. |
.knip.json |
Updates Knip ignore configuration for the new util file. |
.changeset/nip98-auth-verifier.md |
Adds a changeset entry for the new feature. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+174
to
+193
| if (body === undefined || policy === 'ignore') { | ||
| return undefined | ||
| } | ||
|
|
||
| const expectedPayload = hashNip98Payload(body) | ||
| const hasBody = bodyByteLength(body) > 0 | ||
|
|
||
| if (policy === 'require-when-body' && hasBody && payloadTag === undefined) { | ||
| return fail('invalid: missing payload tag') | ||
| } | ||
|
|
||
| if (payloadTag === undefined) { | ||
| return undefined | ||
| } | ||
|
|
||
| if (!isHexEqual(payloadTag.toLowerCase(), expectedPayload)) { | ||
| return fail('invalid: payload tag does not match request body') | ||
| } | ||
|
|
||
| return undefined |
Comment on lines
16
to
19
| "ignore": [ | ||
| ".nostr/**" | ||
| ".nostr/**", | ||
| "src/utils/nip98.ts" | ||
| ], |
Anshumancanrock
force-pushed
the
feat/nip98-verifier
branch
from
August 10, 2026 14:39
6bbaf90 to
a569fcc
Compare
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.
Description
First chunk of NIP-98 support. Adds a standalone verifier for
Authorization: Nostr <base64-event>headers.verifyNip98Auth()insrc/utils/nip98.ts27235, timestamp skew, exactu/method, optional bodypayloadhash, then id + sigsinonredeclare ininfo.spec.tsthat was breaking the full unit suiteMiddleware / admin API wiring comes next.
Related Issue
Part of NIP-98 admin auth work.
Motivation and Context
Need a solid crypto check we can drop into middleware later. Keeping it as a pure util makes this easy to review on its own.
Types of changes
Checklist: