Skip to content

Commit 3a691ef

Browse files
authored
feat: implement NIP-17 & NIP-44 v2 for Modern Direct Messages (#458)
* feat: implement NIP-17 & NIP-44 v2 for Modern Direct Messages This commit introduces comprehensive support for NIP-17 (Private Direct Messages) and NIP-44 v2 (Encrypted Payloads), establishing the modern standard for secure messaging on Nostr. Changes included: - **NIP-17 Support**: - Added new Event Kinds: Seal (13), Direct Message (14), File Message (15), and Gift Wrap (1059). - Implemented `GiftWrapEventStrategy` to handle and validate incoming Gift Wrap events. - Added repository-level protections to block direct relay publication of inner events (Kinds 13, 14, 15), mandating they be encrypted inside a Gift Wrap. - **NIP-44 v2 Crypto**: - Implemented `nip44Encrypt` and `nip44Decrypt` functions supporting ChaCha20, HKDF extraction/expansion, and MAC verification as per NIP-44 v2 specifications. - Added `validateNip44Payload` to ensure payloads adhere to the exact format requirements without needing to decrypt them. - **Cleanup**: - Removed deprecated `encryptKind4Event` (legacy NIP-04 DM algorithm) from `event.ts`. - Updated `package.json` to declare NIPs 17 and 44 in `supportedNipExtensions`. - **Tests**: - Added extensive unit tests across NIP-44 encryption logic, Event Strategies, and Message Handlers. - Resolved `sort-imports` ESLint violations in multiple handler specs. * fix: address NIP-17/NIP-44 security review findings - nip44: replace dead try/catch with explicit base64 regex + length%4 check - gift-wrap: validate recipient p tag is a 64-char lowercase hex pubkey; fix error message - mirroring worker: block inner event kinds (13/14/15) from being persisted directly
1 parent ab2dfeb commit 3a691ef

12 files changed

Lines changed: 1175 additions & 371 deletions

File tree

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,13 @@
1111
12,
1212
15,
1313
16,
14+
17,
1415
20,
1516
22,
1617
28,
1718
33,
18-
40
19+
40,
20+
44
1921
],
2022
"supportedNipExtensions": [
2123
"11a"

0 commit comments

Comments
 (0)