Skip to content

Commit fa8d741

Browse files
vveerrggclaude
andcommitted
docs: polish README, CHANGELOG, and package metadata
Remove duplicate Install/Quick Start section, fix scoped package references to unscoped, add repository/homepage/bugs fields, normalize author, add CHANGELOG entries for v0.4.11-0.4.16, and create example files. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent fc27f54 commit fa8d741

6 files changed

Lines changed: 182 additions & 76 deletions

File tree

CHANGELOG.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,50 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
## [0.4.16] - 2025-02-19
11+
12+
### Changed
13+
- Updated dependencies to latest within major versions
14+
15+
### Fixed
16+
- Updated exports to include validation functions
17+
18+
## [0.4.15] - 2025-02-09
19+
20+
### Changed
21+
- Bumped version for npm publish
22+
23+
### Fixed
24+
- Fixed Vite security vulnerability
25+
26+
### Refactored
27+
- Updated build configuration for better ESM/CJS compatibility
28+
29+
## [0.4.14] - 2025-01-15
30+
31+
### Added
32+
- NIP-19 support and updated dependencies
33+
34+
### Changed
35+
- Improved types and NIP support
36+
37+
## [0.4.13] - 2025-01-10
38+
39+
### Added
40+
- Improved NIP-19 documentation and exports
41+
42+
## [0.4.12] - 2025-01-05
43+
44+
### Fixed
45+
- Improved TypeScript type handling and browser compatibility
46+
- Removed unused imports
47+
48+
## [0.4.11] - 2025-01-03
49+
50+
### Changed
51+
- Updated dist files after build cleanup
52+
- Fixed linting issues and removed unused imports
53+
1054
## [0.4.10] - 2025-01-02
1155

1256
### Fixed

README.md

Lines changed: 14 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ This library provides essential cryptographic operations and utilities required
6363
- Supports both ESM and CJS formats
6464
- Cross-platform compatible (Node.js and browser environments)
6565

66-
[![npm version](https://badge.fury.io/js/%40humanjavaenterprises%2Fnostr-crypto-utils.svg)](https://www.npmjs.com/package/@humanjavaenterprises/nostr-crypto-utils)
66+
[![npm version](https://badge.fury.io/js/nostr-crypto-utils.svg)](https://www.npmjs.com/package/nostr-crypto-utils)
6767
[![TypeScript](https://img.shields.io/badge/%3C%2F%3E-TypeScript-%230074c1.svg)](http://www.typescriptlang.org/)
6868
[![MIT License](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/HumanjavaEnterprises/nostr-crypto-utils/blob/main/LICENSE)
6969
[![Documentation](https://img.shields.io/badge/docs-TypeDoc-blue.svg)](https://humanjavaenterprises.github.io/nostr-crypto-utils/)
@@ -148,7 +148,7 @@ import {
148148
naddrEncode,
149149
nrelayEncode,
150150
decode
151-
} from '@humanjavaenterprises/nostr-crypto-utils';
151+
} from 'nostr-crypto-utils';
152152

153153
// Encode a public key
154154
const npub = npubEncode('7f3b6c2444c526fc7b3a48b0a1e38fb6a5a4062d4a097c9e96feb3c1df2f36d0');
@@ -202,6 +202,7 @@ try {
202202
} catch (error) {
203203
console.error(error); // Error: Invalid hex string
204204
}
205+
```
205206

206207
### Type System
207208

@@ -448,11 +449,11 @@ These examples demonstrate real-world usage patterns from production Nostr appli
448449

449450
## Integration with nostr-nsec-seedphrase
450451

451-
This library is designed to work seamlessly with [@humanjavaenterprises/nostr-nsec-seedphrase](https://github.com/HumanjavaEnterprises/nostr-nsec-seedphrase) to provide a complete solution for Nostr key management and cryptographic operations:
452+
This library is designed to work seamlessly with [nostr-nsec-seedphrase](https://github.com/HumanjavaEnterprises/nostr-nsec-seedphrase) to provide a complete solution for Nostr key management and cryptographic operations:
452453

453454
```typescript
454-
import { generateSeedPhrase } from '@humanjavaenterprises/nostr-nsec-seedphrase';
455-
import { createTextNoteEvent, signEvent } from '@humanjavaenterprises/nostr-crypto-utils';
455+
import { generateSeedPhrase } from 'nostr-nsec-seedphrase';
456+
import { createTextNoteEvent, signEvent } from 'nostr-crypto-utils';
456457

457458
// Generate keys using nostr-nsec-seedphrase
458459
const seedPhrase = generateSeedPhrase();
@@ -481,7 +482,7 @@ You can use this library to create delegate tokens for use on web servers or oth
481482
### Basic Delegation Example
482483

483484
```typescript
484-
import { createDelegation, validateDelegation } from '@humanjavaenterprises/nostr-crypto-utils';
485+
import { createDelegation, validateDelegation } from 'nostr-crypto-utils';
485486

486487
// Create a delegation token (delegator's perspective)
487488
const delegatorKeyPair = await generateKeyPair();
@@ -510,7 +511,7 @@ const isValid = await validateDelegation({
510511
Here's how to use delegation tokens in a web server context:
511512

512513
```typescript
513-
import { createEvent, signEventWithDelegation } from '@humanjavaenterprises/nostr-crypto-utils';
514+
import { createEvent, signEventWithDelegation } from 'nostr-crypto-utils';
514515

515516
// On your server, store these securely
516517
const DELEGATE_PRIVKEY = 'nsec1...'; // Your server's private key
@@ -589,7 +590,7 @@ For more details on delegation, see the [NIP-26 specification](https://github.co
589590
Enable debug mode to get detailed logging:
590591

591592
```typescript
592-
import { setDebugLevel } from '@humanjavaenterprises/nostr-crypto-utils';
593+
import { setDebugLevel } from 'nostr-crypto-utils';
593594

594595
// Enable debug logging
595596
setDebugLevel('debug');
@@ -671,53 +672,6 @@ const testEventSigning = async (event, delegation) => {
671672

672673
For more help, join our [Discord community](https://discord.gg/nostr) or [open an issue](https://github.com/humanjavaenterprises/nostr-crypto-utils/issues).
673674

674-
## Installation
675-
676-
```bash
677-
npm install @humanjavaenterprises/nostr-crypto-utils
678-
```
679-
680-
## Quick Start
681-
682-
```typescript
683-
import { createKeyPair, createTextNoteEvent, signEvent } from '@humanjavaenterprises/nostr-crypto-utils';
684-
685-
// Generate a new key pair
686-
const keyPair = createKeyPair();
687-
688-
// Create a text note event
689-
const event = createTextNoteEvent({
690-
content: 'Hello Nostr!',
691-
pubkey: keyPair.publicKey,
692-
created_at: Math.floor(Date.now() / 1000)
693-
});
694-
695-
// Sign the event
696-
const signedEvent = signEvent(event, keyPair.privateKey);
697-
```
698-
699-
## Documentation
700-
701-
Comprehensive documentation is available at [https://humanjavaenterprises.github.io/nostr-crypto-utils/](https://humanjavaenterprises.github.io/nostr-crypto-utils/)
702-
703-
## Type Safety
704-
705-
This library is written in TypeScript and provides comprehensive type definitions for all functions and data structures. Type checking is enforced at compile time to catch potential errors early.
706-
707-
```typescript
708-
import { NostrEvent, NostrFilter, ValidationResult } from '@humanjavaenterprises/nostr-crypto-utils';
709-
710-
// All types are properly defined
711-
const filter: NostrFilter = {
712-
kinds: [NostrEventKind.TEXT_NOTE],
713-
"#t": ["nostr", "crypto"], // Filter by custom tag
714-
limit: 10
715-
};
716-
717-
// Validation results include type information
718-
const result: ValidationResult = validateEvent(event);
719-
```
720-
721675
## Contributing
722676

723677
We welcome contributions! Please see our [Contributing Guidelines](CONTRIBUTING.md) for details.
@@ -728,29 +682,14 @@ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file
728682

729683
## Changelog
730684

731-
### v0.3.0 (2024-12-28)
732-
- 🔒 Improved type safety with stricter TypeScript checks
733-
- 🐛 Fixed crypto implementation for cross-platform compatibility
734-
-Added comprehensive validation for all message types
735-
- 📝 Updated documentation with more examples
736-
737-
### v0.2.0 (2024-12-26)
738-
- 🎉 Initial public release
739-
-Added support for NIP-01 and NIP-04
740-
- 🔑 Implemented key pair generation and management
741-
- 📝 Added comprehensive documentation
685+
See [CHANGELOG.md](CHANGELOG.md) for a detailed history of changes.
742686

743687
## Support
744688

745-
- 📖 [Documentation](https://humanjavaenterprises.github.io/nostr-crypto-utils/)
746-
- 🐛 [Issue Tracker](https://github.com/humanjavaenterprises/nostr-crypto-utils/issues)
747-
- 💬 [Discussions](https://github.com/humanjavaenterprises/nostr-crypto-utils/discussions)
689+
- [Documentation](https://humanjavaenterprises.github.io/nostr-crypto-utils/)
690+
- [Issue Tracker](https://github.com/HumanjavaEnterprises/nostr-crypto-utils/issues)
691+
- [Discussions](https://github.com/HumanjavaEnterprises/nostr-crypto-utils/discussions)
748692

749693
## Related Projects
750694

751-
- [@humanjavaenterprises/nostr-nsec-seedphrase](https://github.com/HumanjavaEnterprises/nostr-nsec-seedphrase) - Generate and manage Nostr private keys using BIP-39 seed phrases
752-
753-
---
754-
<div align="center">
755-
Made with ❤️ by <a href="https://github.com/humanjavaenterprises">Humanjava Enterprises</a>
756-
</div>
695+
- [nostr-nsec-seedphrase](https://github.com/HumanjavaEnterprises/nostr-nsec-seedphrase) - Generate and manage Nostr private keys using BIP-39 seed phrases

examples/basic-usage.ts

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/**
2+
* Basic Usage Example — nostr-crypto-utils
3+
*
4+
* Demonstrates key generation, event creation, and event signing.
5+
*/
6+
import { generateKeyPair, createEvent, signEvent, verifySignature } from 'nostr-crypto-utils';
7+
8+
async function main() {
9+
// Generate a new Nostr key pair
10+
const keyPair = generateKeyPair();
11+
console.log('Public key:', keyPair.publicKey);
12+
console.log('Private key:', keyPair.privateKey);
13+
14+
// Create an unsigned text note event (kind 1)
15+
const event = createEvent({
16+
pubkey: keyPair.publicKey,
17+
kind: 1,
18+
content: 'Hello Nostr!',
19+
tags: [],
20+
created_at: Math.floor(Date.now() / 1000),
21+
});
22+
23+
// Sign the event
24+
const signedEvent = await signEvent(event, keyPair.privateKey);
25+
console.log('Signed event ID:', signedEvent.id);
26+
console.log('Signature:', signedEvent.sig);
27+
28+
// Verify the signature
29+
const isValid = await verifySignature(signedEvent);
30+
console.log('Signature valid:', isValid);
31+
}
32+
33+
main().catch(console.error);

examples/nip-04.ts

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/**
2+
* NIP-04 Example — nostr-crypto-utils
3+
*
4+
* Demonstrates encrypted direct message creation and decryption.
5+
*/
6+
import { generateKeyPair, encryptMessage, decryptMessage } from 'nostr-crypto-utils';
7+
8+
async function main() {
9+
// Generate two key pairs (sender and recipient)
10+
const sender = generateKeyPair();
11+
const recipient = generateKeyPair();
12+
13+
console.log('Sender pubkey:', sender.publicKey);
14+
console.log('Recipient pubkey:', recipient.publicKey);
15+
16+
// Encrypt a message from sender to recipient
17+
const plaintext = 'Hello, this is a secret message!';
18+
const encrypted = await encryptMessage(
19+
plaintext,
20+
recipient.publicKey,
21+
sender.privateKey,
22+
);
23+
console.log('Encrypted:', encrypted);
24+
25+
// Decrypt the message as the recipient
26+
const decrypted = await decryptMessage(
27+
encrypted,
28+
sender.publicKey,
29+
recipient.privateKey,
30+
);
31+
console.log('Decrypted:', decrypted);
32+
console.log('Match:', plaintext === decrypted);
33+
}
34+
35+
main().catch(console.error);

examples/nip-19.ts

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/**
2+
* NIP-19 Example — nostr-crypto-utils
3+
*
4+
* Demonstrates encoding and decoding of bech32-encoded Nostr entities.
5+
*/
6+
import {
7+
generateKeyPair,
8+
npubEncode,
9+
nsecEncode,
10+
noteEncode,
11+
nprofileEncode,
12+
decode,
13+
} from 'nostr-crypto-utils';
14+
15+
async function main() {
16+
const keyPair = generateKeyPair();
17+
18+
// Encode public key as npub
19+
const npub = npubEncode(keyPair.publicKey);
20+
console.log('npub:', npub);
21+
22+
// Encode private key as nsec
23+
const nsec = nsecEncode(keyPair.privateKey);
24+
console.log('nsec:', nsec);
25+
26+
// Encode an event ID as note
27+
const exampleEventId = keyPair.publicKey; // using pubkey as stand-in
28+
const note = noteEncode(exampleEventId);
29+
console.log('note:', note);
30+
31+
// Encode a profile with relay hints
32+
const nprofile = nprofileEncode(keyPair.publicKey, [
33+
'wss://relay.damus.io',
34+
'wss://nos.lol',
35+
]);
36+
console.log('nprofile:', nprofile);
37+
38+
// Decode any bech32 entity back
39+
const decoded = decode(npub);
40+
console.log('Decoded npub:', decoded);
41+
42+
const decodedProfile = decode(nprofile);
43+
console.log('Decoded nprofile:', decodedProfile);
44+
}
45+
46+
main().catch(console.error);

package.json

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
"files": [
1818
"dist",
1919
"src",
20+
"examples/**/*",
2021
"README.md",
2122
"LICENSE"
2223
],
@@ -40,8 +41,16 @@
4041
"utilities",
4142
"typescript"
4243
],
43-
"author": "Humanjava Enterprises",
44+
"author": "vveerrgg",
4445
"license": "MIT",
46+
"repository": {
47+
"type": "git",
48+
"url": "git+https://github.com/HumanjavaEnterprises/nostr-crypto-utils.git"
49+
},
50+
"bugs": {
51+
"url": "https://github.com/HumanjavaEnterprises/nostr-crypto-utils/issues"
52+
},
53+
"homepage": "https://github.com/HumanjavaEnterprises/nostr-crypto-utils#readme",
4554
"dependencies": {
4655
"@noble/curves": "^1.9.7",
4756
"@noble/hashes": "^1.8.0",

0 commit comments

Comments
 (0)