clearauth 0.4.1 → 0.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +99 -1
- package/README.md +641 -0
- package/dist/auth/handler.js +2 -2
- package/dist/auth/handler.js.map +1 -1
- package/dist/createMechAuth.d.ts +2 -0
- package/dist/createMechAuth.js +3 -1
- package/dist/createMechAuth.js.map +1 -1
- package/dist/database/schema.d.ts +79 -0
- package/dist/database/schema.js +23 -0
- package/dist/database/schema.js.map +1 -1
- package/dist/device-auth/android-verifier.d.ts +115 -0
- package/dist/device-auth/android-verifier.js +221 -0
- package/dist/device-auth/android-verifier.js.map +1 -0
- package/dist/device-auth/apple-root-ca.d.ts +26 -0
- package/dist/device-auth/apple-root-ca.js +40 -0
- package/dist/device-auth/apple-root-ca.js.map +1 -0
- package/dist/device-auth/challenge.d.ts +104 -0
- package/dist/device-auth/challenge.js +199 -0
- package/dist/device-auth/challenge.js.map +1 -0
- package/dist/device-auth/device-registration.d.ts +86 -0
- package/dist/device-auth/device-registration.js +143 -0
- package/dist/device-auth/device-registration.js.map +1 -0
- package/dist/device-auth/handlers.d.ts +45 -0
- package/dist/device-auth/handlers.js +484 -0
- package/dist/device-auth/handlers.js.map +1 -0
- package/dist/device-auth/ios-verifier.d.ts +132 -0
- package/dist/device-auth/ios-verifier.js +455 -0
- package/dist/device-auth/ios-verifier.js.map +1 -0
- package/dist/device-auth/middleware.d.ts +104 -0
- package/dist/device-auth/middleware.js +200 -0
- package/dist/device-auth/middleware.js.map +1 -0
- package/dist/device-auth/signature-verifier.d.ts +200 -0
- package/dist/device-auth/signature-verifier.js +371 -0
- package/dist/device-auth/signature-verifier.js.map +1 -0
- package/dist/device-auth/types.d.ts +173 -0
- package/dist/device-auth/types.js +38 -0
- package/dist/device-auth/types.js.map +1 -0
- package/dist/device-auth/web3-verifier.d.ts +123 -0
- package/dist/device-auth/web3-verifier.js +286 -0
- package/dist/device-auth/web3-verifier.js.map +1 -0
- package/dist/device-auth.d.ts +18 -0
- package/dist/device-auth.js +19 -0
- package/dist/device-auth.js.map +1 -0
- package/dist/handler.d.ts +5 -0
- package/dist/handler.js +51 -1
- package/dist/handler.js.map +1 -1
- package/dist/index.d.ts +13 -0
- package/dist/index.js +15 -0
- package/dist/index.js.map +1 -1
- package/dist/jwt/handlers.d.ts +151 -0
- package/dist/jwt/handlers.js +367 -0
- package/dist/jwt/handlers.js.map +1 -0
- package/dist/jwt/refresh-tokens.d.ts +219 -0
- package/dist/jwt/refresh-tokens.js +318 -0
- package/dist/jwt/refresh-tokens.js.map +1 -0
- package/dist/jwt/signer.d.ts +85 -0
- package/dist/jwt/signer.js +165 -0
- package/dist/jwt/signer.js.map +1 -0
- package/dist/jwt/types.d.ts +119 -0
- package/dist/jwt/types.js +18 -0
- package/dist/jwt/types.js.map +1 -0
- package/dist/jwt.d.ts +38 -0
- package/dist/jwt.js +40 -0
- package/dist/jwt.js.map +1 -0
- package/dist/mech-sql-client.d.ts +2 -1
- package/dist/mech-sql-client.js +11 -1
- package/dist/mech-sql-client.js.map +1 -1
- package/dist/oauth/callbacks.d.ts +3 -1
- package/dist/oauth/callbacks.js +21 -9
- package/dist/oauth/callbacks.js.map +1 -1
- package/dist/password-hasher-argon2.js +15 -1
- package/dist/password-hasher-argon2.js.map +1 -1
- package/dist/types.d.ts +19 -0
- package/dist/validation.js +3 -2
- package/dist/validation.js.map +1 -1
- package/package.json +27 -6
package/CHANGELOG.md
CHANGED
|
@@ -5,7 +5,105 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
-
## [
|
|
8
|
+
## [0.6.0] - 2026-01-17
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- **Hardware-Backed Device Authentication** - Phishing-resistant authentication for Web3, iOS, and Android
|
|
13
|
+
- **Multi-Platform Support** - Unified API for Web3 wallets, iOS App Attest, and Android Play Integrity
|
|
14
|
+
- **Web3 Wallet Registration** - Hardware-backed authentication for MetaMask and Web3 wallets (EIP-191)
|
|
15
|
+
- **iOS App Attest Support** - Secure Enclave-backed key attestation and verification
|
|
16
|
+
- **Android Play Integrity Support** - Hardware-backed key attestation via Google Play Integrity API
|
|
17
|
+
- **Request Signature Middleware** - Cryptographic verification of every API request via `verifyDeviceSignature()`
|
|
18
|
+
- **Device Management API** - Endpoints for users to list, monitor, and revoke their registered devices
|
|
19
|
+
- **Device-Bound JWTs** - Optional `deviceId` claim in JWT access tokens for enhanced session security
|
|
20
|
+
- **Architecture Compatibility** - Lazy-loading native bindings to prevent crashes on mismatched architectures
|
|
21
|
+
|
|
22
|
+
**New HTTP Endpoints:**
|
|
23
|
+
- `POST /auth/challenge` - Generate one-time cryptographic challenge
|
|
24
|
+
- `POST /auth/device/register` - Register a new hardware device (Web3, iOS, or Android)
|
|
25
|
+
- `GET /auth/devices` - List all registered devices for the authenticated user (with pagination)
|
|
26
|
+
- `DELETE /auth/devices/:deviceId` - Revoke a registered device (soft-delete with audit trail)
|
|
27
|
+
|
|
28
|
+
**New Functions:**
|
|
29
|
+
- `verifyDeviceSignature()` - Middleware to verify request signatures from registered devices
|
|
30
|
+
- `listUserDevices()` / `listActiveDevices()` - Data layer functions for device management
|
|
31
|
+
- `revokeDevice()` - Soft-delete device revocation
|
|
32
|
+
- `verifyIOSAttestation()` - Complete iOS App Attest verification chain
|
|
33
|
+
- `verifyIntegrityToken()` - Google Play Integrity token verification
|
|
34
|
+
- `verifyEIP191Signature()` - Web3 personal_sign verification
|
|
35
|
+
- `generateChallenge()` / `verifyChallenge()` - Challenge-response infrastructure
|
|
36
|
+
|
|
37
|
+
**Database Schema:**
|
|
38
|
+
- Uses existing `devices` table (introduced in v0.5.0) for hardware key storage
|
|
39
|
+
- Uses existing `challenges` table (introduced in v0.5.0) for one-time challenge storage
|
|
40
|
+
- Optimized indexes for user-based device queries and revocation
|
|
41
|
+
|
|
42
|
+
**Documentation:**
|
|
43
|
+
- Comprehensive README section with multi-platform device auth guide
|
|
44
|
+
- Client SDK examples for TypeScript (Web3), Swift (iOS), and Kotlin (Android)
|
|
45
|
+
- Troubleshooting guide updated for cross-architecture native binding issues
|
|
46
|
+
|
|
47
|
+
**Testing:**
|
|
48
|
+
- 194 comprehensive tests covering all device authentication modules (added in v0.5.0-v0.6.0)
|
|
49
|
+
- Integration tests for all new HTTP endpoints
|
|
50
|
+
- Total test suite now at 518 passing tests
|
|
51
|
+
|
|
52
|
+
### Fixed
|
|
53
|
+
|
|
54
|
+
- **Cross-Architecture Native Bindings** - Implemented lazy-loading for \`@node-rs/argon2\` to prevent startup crashes when running on mismatched architectures (e.g., x64 Node on ARM64). (Fixed in #25)
|
|
55
|
+
- **Security Validation** - Hardened URL validation for device IDs to prevent path traversal and empty ID bypass. (Fixed in #25)
|
|
56
|
+
- **Error Information Leakage** - Standardized generic error messages in API responses while maintaining detailed internal logging. (Fixed in #25)
|
|
57
|
+
|
|
58
|
+
## [0.5.0] - 2026-01-15
|
|
59
|
+
|
|
60
|
+
### Added
|
|
61
|
+
|
|
62
|
+
- **JWT Bearer Token Authentication** - Complete stateless authentication for CLI tools, mobile apps, and API clients
|
|
63
|
+
- **ES256 Algorithm** - ECDSA with P-256 curve for edge-optimized signing/verification
|
|
64
|
+
- **Access Tokens** - 15-minute stateless JWT tokens (configurable TTL)
|
|
65
|
+
- **Refresh Tokens** - 30-day revocable tokens stored in database (configurable TTL)
|
|
66
|
+
- **Token Rotation** - Automatic refresh token rotation for enhanced security
|
|
67
|
+
- **Revocation Support** - Soft-delete revocation with audit trail via `revoked_at` timestamp
|
|
68
|
+
- **OAuth 2.0 Compliant** - Token responses follow RFC 6749 specification
|
|
69
|
+
- **Edge Compatible** - Web Crypto API only, works in Cloudflare Workers, Vercel Edge, browsers, Node.js
|
|
70
|
+
- **Zero Dependencies Added** - Uses existing `jose` library (6.1.3)
|
|
71
|
+
|
|
72
|
+
**New HTTP Endpoints:**
|
|
73
|
+
- `POST /auth/token` - Exchange credentials for JWT access + refresh token pair
|
|
74
|
+
- `POST /auth/refresh` - Rotate refresh token and get new access token
|
|
75
|
+
- `POST /auth/revoke` - Revoke refresh token (logout)
|
|
76
|
+
|
|
77
|
+
**New Functions:**
|
|
78
|
+
- `createAccessToken()` - Generate signed JWT access token
|
|
79
|
+
- `verifyAccessToken()` - Verify and decode JWT access token
|
|
80
|
+
- `parseBearerToken()` - Extract Bearer token from Authorization header
|
|
81
|
+
- `validateBearerToken()` - Validate Bearer token from request
|
|
82
|
+
- `createRefreshToken()` - Create revocable refresh token in database
|
|
83
|
+
- `rotateRefreshToken()` - Securely rotate refresh token
|
|
84
|
+
- `revokeRefreshToken()` - Revoke refresh token by ID
|
|
85
|
+
- `revokeAllUserRefreshTokens()` - Revoke all tokens for a user
|
|
86
|
+
- `cleanupExpiredTokens()` - Remove expired tokens from database
|
|
87
|
+
|
|
88
|
+
**Database Schema:**
|
|
89
|
+
- New `refresh_tokens` table with SHA-256 hashed tokens
|
|
90
|
+
- Migration scripts: `006_create_refresh_tokens.sql` and `rollback_006.sql`
|
|
91
|
+
- Indexes for performance: `idx_refresh_tokens_user`, `idx_refresh_tokens_expires`
|
|
92
|
+
|
|
93
|
+
**Entrypoint:**
|
|
94
|
+
- New `clearauth/jwt` submodule export for JWT-specific imports
|
|
95
|
+
- All JWT types and functions exported from main `clearauth` package
|
|
96
|
+
|
|
97
|
+
**Documentation:**
|
|
98
|
+
- Comprehensive README section with ES256 key generation instructions
|
|
99
|
+
- Usage examples for Node.js, Cloudflare Workers, CLI/mobile apps
|
|
100
|
+
- API reference table with all endpoints and functions
|
|
101
|
+
- Security considerations and best practices
|
|
102
|
+
|
|
103
|
+
**Testing:**
|
|
104
|
+
- 89 new comprehensive tests (31 signer + 36 refresh tokens + 22 handlers)
|
|
105
|
+
- 100% code coverage for all JWT modules
|
|
106
|
+
- All 320 tests passing
|
|
9
107
|
|
|
10
108
|
### Fixed
|
|
11
109
|
|