Gathering detailed insights and metrics for @j2blasco/ts-auth
Gathering detailed insights and metrics for @j2blasco/ts-auth
Gathering detailed insights and metrics for @j2blasco/ts-auth
Gathering detailed insights and metrics for @j2blasco/ts-auth
npm install @j2blasco/ts-auth
Typescript
Module System
Node Version
NPM Version
TypeScript (95.81%)
JavaScript (4.19%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
11 Commits
1 Branches
1 Contributors
Updated on Jul 15, 2025
Latest Version
0.1.4
Package Id
@j2blasco/ts-auth@0.1.4
Unpacked Size
130.56 kB
Size
11.78 kB
File Count
35
NPM Version
11.4.2
Node Version
20.18.1
Published on
Jul 15, 2025
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
A TypeScript authentication abstraction library that eliminates vendor lock-in and provides mock-free testing for both frontend and backend authentication systems.
Problem: Authentication providers (Firebase, Auth0, AWS Cognito) lock you into their specific APIs, making switching providers painful and testing complex.
Solution: A simple abstraction layer with complete testing implementations that work with any authentication provider.
1npm install @j2blasco/ts-auth
The library provides separate interfaces for frontend and backend concerns:
IAuthFrontend
: Client-side operations (login, signup, password reset)AuthFrontendTesting
: Complete frontend testing implementationtestAuthFrontend
: Test suite for validating frontend implementationsIAuthBackend
: Server-side operations (token validation, user management)AuthBackendTesting
: Complete backend testing implementationtestAuthBackend
: Test suite for validating backend implementations1import { IAuthFrontend, AuthFrontendTesting } from '@j2blasco/ts-auth'; 2 3// In your tests - no mocks needed! 4const auth = new AuthFrontendTesting(); 5auth.addTestUser('test@example.com', 'password123'); 6 7await auth.signInWithEmailAndPassword({ 8 email: 'test@example.com', 9 password: 'password123', 10 persistent: true 11}); 12 13// In production - implement the interface for your provider 14class FirebaseAuthFrontend implements IAuthFrontend { 15 // Implement all methods... 16}
1import { IAuthBackend, AuthBackendTesting } from '@j2blasco/ts-auth'; 2 3// In your tests 4const backendAuth = new AuthBackendTesting(); 5 6const result = await backendAuth.signUpWithEmailPassword({ 7 email: 'user@example.com', 8 password: 'password123' 9}); 10 11const uid = result.unwrap().uid; 12 13// In production - implement for your provider 14class FirebaseAuthBackend implements IAuthBackend { 15 // Implement all methods... 16}
1import { testAuthFrontend, testAuthBackend } from '@j2blasco/ts-auth'; 2 3describe('My Auth Implementation', () => { 4 // Frontend tests - comprehensive suite 5 testAuthFrontend(() => new MyFirebaseAuthFrontend()); 6 7 // Backend tests - comprehensive suite 8 testAuthBackend(new MyFirebaseAuthBackend()); 9});
src/
├── frontend/
│ ├── core/
│ │ ├── auth-frontend.interface.ts # Frontend interface definition
│ │ └── auth-frontend.generic.test.ts # Generic test suite
│ └── providers/
│ └── testing/
│ ├── auth-frontend.testing.ts # Testing implementation
│ └── auth-frontend.testing.test.ts # Implementation tests
├── backend/
│ ├── core/
│ │ ├── auth-backend.interface.ts # Backend interface definition
│ │ └── auth-backend.generic.test.ts # Generic test suite
│ └── providers/
│ └── testing/
│ ├── auth-backend.testing.ts # Testing implementation
│ └── auth-backend.testing.test.ts # Implementation tests
└── index.ts # Public exports
IAuthFrontend
)User-facing authentication operations:
authState$
- Observable authentication statesignInWithEmailAndPassword()
- User loginsignUp()
- User registrationsignOut()
- User logoutgetIdToken()
- Get current user tokenisEmailAvailable()
- Check email availabilitychangeEmail()
- Update user emaildeleteAccount()
- Delete user accounttriggerResetPasswordFlow()
- Initiate password resetrequestChangePassword()
- Complete password changeIAuthBackend
)Server-side authentication operations:
onUserCreated$
/ onUserDeleted$
- User lifecycle eventsgetUidFromIdToken()
- Validate and extract UID from tokensignInWithEmailAndPassword()
- Administrative signinsignInWithRefreshToken()
- Token refreshsignUpWithEmailPassword()
- Administrative user creationchangeEmail()
- Administrative email changechangePassword()
- Administrative password changedeleteUser()
- Administrative user deletiongetUidByEmail()
- Lookup user by emailThis library follows Test-Driven Development principles:
1git clone https://github.com/j2blasco/ts-auth.git 2cd ts-auth 3npm install
1# Run all tests 2npm test 3 4# Run frontend tests only 5npm test -- src/frontend 6 7# Run backend tests only 8npm test -- src/backend
1npm run build
git checkout -b feature/your-feature
npm test
Want to see real implementations? Check out these examples:
MIT License - see LICENSE file for details.
Built with ❤️ for developer freedom and testing sanity.
No vulnerabilities found.
No security vulnerabilities found.