Skip to content

Commit 55f017a

Browse files
vveerrggclaude
andcommitted
docs: polish README, CONTRIBUTING, package metadata, and add CHANGELOG
Expand README with architecture, security, and API sections. Fix all login-utils references to auth-utils in CONTRIBUTING and package.json. Fix repository/bugs/homepage URLs, add examples to files, create CHANGELOG. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent fb659f5 commit 55f017a

4 files changed

Lines changed: 181 additions & 25 deletions

File tree

CHANGELOG.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Changelog
2+
3+
All notable changes to this project will be documented in this file.
4+
5+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7+
8+
## [Unreleased]
9+
10+
## [0.1.1] - 2025-02-19
11+
12+
### Changed
13+
- Updated dependencies and fixed TypeScript 5.9 type errors
14+
- Refactored for npm package release
15+
- Updated package descriptions to clarify step-up authentication use case
16+
17+
### Removed
18+
- Removed deprecated test-server and proof_of_concept directories
19+
20+
## [0.1.0] - 2025-01-15
21+
22+
### Added
23+
- Initial release
24+
- WebAuthn-based biometric authentication for Nostr applications
25+
- Support for TouchID/FaceID, Windows Hello, Android biometric, and security keys
26+
- NIP-19 compliant entity encoding/decoding
27+
- Nostr profile integration
28+
- Settings management via Nostr direct messages
29+
- Express.js example with WebAuthn and profile fetching
30+
- Comprehensive TypeScript type definitions

CONTRIBUTING.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
# Contributing to nostr-biometric-login-utils
1+
# Contributing to nostr-biometric-auth-utils
22

3-
Thank you for considering contributing to **nostr-biometric-login-utils**! We appreciate your help in making this biometric authentication service better.
3+
Thank you for considering contributing to **nostr-biometric-auth-utils**! We appreciate your help in making this biometric authentication service better.
44

55
## How to Contribute
66

77
### Reporting Issues
8-
If you find a bug or have a feature request, please open an issue on our [GitHub repository](https://github.com/HumanjavaEnterprises/nostr-biometric-login-utils/issues).
8+
If you find a bug or have a feature request, please open an issue on our [GitHub repository](https://github.com/HumanjavaEnterprises/nostr-biometric-auth-utils/issues).
99

1010
### Pull Requests
1111
1. Fork the repository.

README.md

Lines changed: 144 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,19 @@
11
# Nostr Biometric Authentication Utilities
22

3-
A comprehensive utility library for implementing biometric authentication in Nostr applications using WebAuthn. This library provides a flexible set of tools for adding secure biometric authentication to your Nostr-based applications.
3+
[![npm version](https://img.shields.io/npm/v/nostr-biometric-auth-utils.svg)](https://www.npmjs.com/package/nostr-biometric-auth-utils)
4+
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
5+
[![TypeScript](https://img.shields.io/badge/TypeScript-Ready-blue.svg)](https://www.typescriptlang.org/)
6+
7+
A comprehensive utility library for implementing biometric authentication in Nostr applications using WebAuthn. This library provides a flexible set of tools for adding secure biometric authentication as a step-up factor to your Nostr-based applications.
48

59
## Features
610

711
- **WebAuthn Integration**: Ready-to-use utilities for implementing WebAuthn-based biometric authentication
8-
- **Platform Support**:
12+
- **Platform Support**:
913
- TouchID/FaceID for iOS and macOS
1014
- Windows Hello
1115
- Android biometric authentication
12-
- Security Key support
16+
- Security Key support (FIDO2/U2F)
1317
- **Nostr-Specific Tools**:
1418
- Full NIP-19 compliance for entity encoding/decoding
1519
- Nostr profile integration
@@ -24,7 +28,7 @@ A comprehensive utility library for implementing biometric authentication in Nos
2428
npm install nostr-biometric-auth-utils
2529
```
2630

27-
## Usage
31+
## Quick Start
2832

2933
### Basic Authentication Flow
3034

@@ -77,30 +81,151 @@ await settings.updateSettings({
7781

7882
The library is organized into several core modules:
7983

80-
- **Client**: Main client-side implementation for managing authentication flow
81-
- **Core**:
82-
- WebAuthn implementation
83-
- TouchID/FaceID integration
84-
- Security key support
85-
- **Settings**: Nostr-based settings management
86-
- **Utils**: Helper functions for Nostr entity handling
84+
```
85+
nostr-biometric-auth-utils/
86+
├── src/
87+
│ ├── client/ # Main client-side authentication flow
88+
│ │ └── index.ts # NostrBiometricClient implementation
89+
│ ├── core/ # Core authentication implementations
90+
│ │ ├── webauthn.ts # WebAuthn registration & verification
91+
│ │ ├── touchid.ts # TouchID/FaceID integration
92+
│ │ └── security-key.ts # Hardware security key support
93+
│ ├── settings/ # Nostr-based settings management
94+
│ │ └── index.ts # SettingsManager for DM-based config
95+
│ └── utils/ # Helper functions
96+
│ └── nostr.ts # Nostr entity encoding/decoding (NIP-19)
97+
```
98+
99+
### Authentication Flow
100+
101+
```
102+
1. User provides their npub
103+
104+
v
105+
2. Magic link sent via Nostr DM
106+
107+
v
108+
3. User clicks magic link
109+
110+
v
111+
4. WebAuthn biometric challenge
112+
(TouchID / FaceID / Windows Hello / Security Key)
113+
114+
v
115+
5. Session established
116+
```
117+
118+
The flow combines Nostr's cryptographic identity with WebAuthn biometrics for two-factor authentication. The magic link verifies the user controls the Nostr key, and biometrics verify the user is physically present.
119+
120+
## API Reference
121+
122+
### NostrBiometricClient
123+
124+
The main client for managing the authentication flow.
125+
126+
```typescript
127+
const client = new NostrBiometricClient(options: ClientOptions);
128+
```
129+
130+
| Option | Type | Description |
131+
|--------|------|-------------|
132+
| `relays` | `string[]` | Nostr relay URLs to connect to |
133+
| `magicLinkExpiry` | `number` | Magic link expiry in seconds (default: 300) |
134+
| `sessionDuration` | `number` | Session duration in seconds (default: 86400) |
135+
136+
#### Methods
137+
138+
- `startAuth(npub: string)` — Begins the authentication flow for a given npub
139+
- `onStateChange(callback)` — Registers a callback for auth state transitions
140+
- `cancelAuth()` — Cancels an in-progress authentication
141+
142+
### SettingsManager
143+
144+
Manages user settings stored via Nostr direct messages.
145+
146+
```typescript
147+
const settings = new SettingsManager(nostrService, userPubkey);
148+
```
149+
150+
#### Methods
151+
152+
- `loadSettings()` — Loads the user's current settings
153+
- `updateSettings(settings)` — Updates and persists settings
154+
- `resetSettings()` — Resets settings to defaults
155+
156+
### WebAuthn Utilities
157+
158+
Low-level WebAuthn functions for custom flows.
159+
160+
```typescript
161+
import { registerCredential, verifyCredential } from 'nostr-biometric-auth-utils';
162+
163+
// Register a new biometric credential
164+
const credential = await registerCredential({
165+
rpName: 'Your App',
166+
rpId: 'your-app.com',
167+
userId: npub,
168+
userName: displayName,
169+
});
170+
171+
// Verify a credential during authentication
172+
const result = await verifyCredential({
173+
credentialId: credential.id,
174+
challenge: serverChallenge,
175+
});
176+
```
87177

88178
## Security Considerations
89179

90-
- All biometric data remains on the user's device
91-
- Implements FIDO2 WebAuthn specifications
92-
- Follows security best practices for key management
93-
- Proper error handling for all security-critical operations
180+
### Biometric Data Privacy
181+
182+
- All biometric data remains on the user's device — it is never transmitted to servers
183+
- The WebAuthn protocol only exchanges cryptographic proofs, not biometric templates
184+
- Implements FIDO2 WebAuthn specifications for maximum interoperability
185+
186+
### Key Management
187+
188+
- Nostr private keys are never handled by this library
189+
- Magic link signing uses nostr-crypto-utils for NIP-compliant operations
190+
- WebAuthn credentials are bound to the origin (domain) and cannot be phished
191+
192+
### Threat Model
193+
194+
| Threat | Mitigation |
195+
|--------|------------|
196+
| Stolen npub | Magic link requires access to Nostr DMs |
197+
| Compromised relay | Multi-relay support with verification |
198+
| Phishing | WebAuthn origin binding prevents cross-site use |
199+
| Session hijacking | Configurable session expiry with biometric re-auth |
200+
201+
### Best Practices
202+
203+
1. Always use multiple relays for magic link delivery
204+
2. Set appropriate expiry times for magic links (5-15 minutes)
205+
3. Implement session refresh with biometric re-verification
206+
4. Monitor failed authentication attempts
207+
5. Use HTTPS in production for WebAuthn origin verification
208+
209+
## Examples
210+
211+
See the `examples/` directory for complete working examples:
212+
213+
- `examples/proof_of_concept/` — Minimal Express.js server with WebAuthn flow
94214

95215
## Contributing
96216

97-
Contributions are welcome! Please read our contributing guidelines for details on our code of conduct and the process for submitting pull requests.
217+
Contributions are welcome! Please read our [Contributing Guide](CONTRIBUTING.md) for details on our code of conduct and the process for submitting pull requests.
218+
219+
## Changelog
220+
221+
See [CHANGELOG.md](CHANGELOG.md) for a detailed history of changes.
98222

99223
## License
100224

101-
This project is licensed under the MIT License - see the LICENSE file for details.
225+
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
102226

103227
## Related Projects
104228

105-
- [nostr-dm-magiclink-utils](https://github.com/HumanjavaEnterprises/nostr-dm-magiclink-utils)
106-
- [MaiQR Platform](https://github.com/HumanjavaEnterprises/MaiQR-Platform)
229+
- [nostr-crypto-utils](https://github.com/HumanjavaEnterprises/nostr-crypto-utils) — Core cryptographic utilities for Nostr
230+
- [nostr-dm-magiclink-utils](https://github.com/HumanjavaEnterprises/nostr-dm-magiclink-utils) — Magic link authentication via Nostr DMs
231+
- [nostr-auth-middleware](https://github.com/HumanjavaEnterprises/nostr-auth-middleware) — Authentication middleware for Nostr apps

package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
},
1515
"files": [
1616
"dist",
17+
"examples/**/*",
1718
"README.md",
1819
"LICENSE"
1920
],
@@ -40,12 +41,12 @@
4041
"license": "MIT",
4142
"repository": {
4243
"type": "git",
43-
"url": "git+https://github.com/HumanjavaEnterprises/nostr-biometric-login-utils.git"
44+
"url": "git+https://github.com/HumanjavaEnterprises/nostr-biometric-auth-utils.git"
4445
},
4546
"bugs": {
46-
"url": "https://github.com/HumanjavaEnterprises/nostr-biometric-login-utils/issues"
47+
"url": "https://github.com/HumanjavaEnterprises/nostr-biometric-auth-utils/issues"
4748
},
48-
"homepage": "https://github.com/HumanjavaEnterprises/nostr-biometric-login-utils#readme",
49+
"homepage": "https://github.com/HumanjavaEnterprises/nostr-biometric-auth-utils#readme",
4950
"dependencies": {
5051
"@scure/base": "^1.2.6",
5152
"@simplewebauthn/browser": "^8.3.7",

0 commit comments

Comments
 (0)