feat(nip98): add Authorization header verifier - #722
Conversation
🦋 Changeset detectedLatest commit: 798292a 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 |
1174513 to
eedfafaCompareThere 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.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
6bbaf90 to
a569fccCompareUh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Use one regex for scheme+token and lower the default header cap to 2KB.
Move JSON.parse into the Authorization decoder and compare payload digests with timingSafeEqual only after an explicit hex format check.
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: