@tekcify/auth-core-client 1.0.4 → 1.0.5
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 +16 -6
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -20,6 +20,19 @@ This package provides the foundational OAuth 2.0 functionality for Tekcify Auth,
|
|
|
20
20
|
- **OAuth Client** class for managing authentication flows
|
|
21
21
|
- **Standalone functions** for framework-agnostic usage
|
|
22
22
|
- **Type definitions** for TypeScript support
|
|
23
|
+
- **Centralized auth server URL** via `AUTH_SERVER_URL` constant
|
|
24
|
+
|
|
25
|
+
## Configuration
|
|
26
|
+
|
|
27
|
+
The package uses a centralized auth server URL that can be imported and configured:
|
|
28
|
+
|
|
29
|
+
```typescript
|
|
30
|
+
import { AUTH_SERVER_URL } from '@tekcify/auth-core-client';
|
|
31
|
+
|
|
32
|
+
console.log(AUTH_SERVER_URL);
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
The default auth server URL is `http://localhost:7002`. You can modify this constant if needed for your environment.
|
|
23
36
|
|
|
24
37
|
## Quick Start
|
|
25
38
|
|
|
@@ -69,25 +82,22 @@ const urlParams = new URLSearchParams(window.location.search);
|
|
|
69
82
|
const code = urlParams.get('code');
|
|
70
83
|
const state = urlParams.get('state');
|
|
71
84
|
|
|
72
|
-
// Verify state matches (CSRF protection)
|
|
73
85
|
if (state !== expectedState) {
|
|
74
86
|
throw new Error('Invalid state parameter');
|
|
75
87
|
}
|
|
76
88
|
|
|
77
|
-
// Retrieve the stored code verifier
|
|
78
89
|
const codeVerifier = localStorage.getItem('code_verifier');
|
|
79
90
|
|
|
80
91
|
const tokens = await exchangeCode({
|
|
81
92
|
code: code!,
|
|
82
93
|
clientId: 'your-client-id',
|
|
83
|
-
clientSecret: 'your-client-secret',
|
|
94
|
+
clientSecret: 'your-client-secret',
|
|
84
95
|
redirectUri: 'https://yourapp.com/callback',
|
|
85
96
|
codeVerifier: codeVerifier!,
|
|
86
97
|
});
|
|
87
98
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
// tokens.expiresIn - Token expiration time in seconds
|
|
99
|
+
localStorage.setItem('access_token', tokens.accessToken);
|
|
100
|
+
localStorage.setItem('refresh_token', tokens.refreshToken);
|
|
91
101
|
```
|
|
92
102
|
|
|
93
103
|
### 4. Refresh Access Token
|