@nauth-toolkit/client 0.2.1 → 0.2.2
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/README.md +48 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -4,14 +4,58 @@ Framework-agnostic frontend SDK for [nauth-toolkit](https://nauth.dev).
|
|
|
4
4
|
|
|
5
5
|
Handles authentication flows from the browser — signup, login, token refresh, MFA, social OAuth, session management. Works with React, Vue, Svelte, or any TypeScript/JavaScript frontend. Ships as both CJS and ESM.
|
|
6
6
|
|
|
7
|
+
**[Documentation](https://nauth.dev/docs/frontend-sdk)** · **[GitHub](https://github.com/noorixorg/nauth)**
|
|
8
|
+
|
|
9
|
+
> Part of [nauth-toolkit](https://www.npmjs.com/package/@nauth-toolkit/core). Works with any nauth-toolkit backend.
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## Install
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npm install @nauth-toolkit/client
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Quick start
|
|
20
|
+
|
|
21
|
+
```typescript
|
|
22
|
+
import { NAuthClient } from '@nauth-toolkit/client';
|
|
23
|
+
|
|
24
|
+
const auth = new NAuthClient({
|
|
25
|
+
baseUrl: 'https://api.example.com/auth',
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
// Sign up
|
|
29
|
+
await auth.signup({ email: 'user@example.com', password: 'securePass1!' });
|
|
30
|
+
|
|
31
|
+
// Log in
|
|
32
|
+
const result = await auth.login({ email: 'user@example.com', password: 'securePass1!' });
|
|
33
|
+
|
|
34
|
+
// Get current user
|
|
35
|
+
const user = auth.getUser();
|
|
36
|
+
|
|
37
|
+
// Listen for auth state changes
|
|
38
|
+
auth.on('authStateChanged', (user) => {
|
|
39
|
+
console.log('Auth state:', user);
|
|
40
|
+
});
|
|
41
|
+
```
|
|
42
|
+
|
|
7
43
|
## What's included
|
|
8
44
|
|
|
9
|
-
- **
|
|
10
|
-
- **Token management** — automatic silent refresh, storage
|
|
45
|
+
- **NAuthClient** — typed API client for all nauth-toolkit endpoints
|
|
46
|
+
- **Token management** — automatic silent refresh, pluggable storage (browser or in-memory)
|
|
11
47
|
- **MFA flows** — TOTP enrollment, SMS/email verification, passkey registration and authentication
|
|
12
48
|
- **Social OAuth** — redirect and popup flows for Google, Apple, Facebook
|
|
13
49
|
- **Session management** — list sessions, revoke sessions, device info
|
|
50
|
+
- **Challenge router** — automatic multi-step flow handling (MFA challenges, email verification)
|
|
51
|
+
- **Admin operations** — user management for admin-scoped tokens
|
|
52
|
+
|
|
53
|
+
---
|
|
54
|
+
|
|
55
|
+
## Angular
|
|
56
|
+
|
|
57
|
+
For Angular apps, use [`@nauth-toolkit/client-angular`](https://www.npmjs.com/package/@nauth-toolkit/client-angular) which wraps this SDK with Angular services, guards, and HTTP interceptors.
|
|
14
58
|
|
|
15
|
-
|
|
59
|
+
---
|
|
16
60
|
|
|
17
|
-
|
|
61
|
+
Free to use. See [license](https://nauth.dev/docs/license).
|