@fayz-ai/auth 0.1.6 → 0.1.7
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 -0
- package/package.json +2 -2
package/README.md
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# @fayz-ai/auth
|
|
2
|
+
|
|
3
|
+
> Pluggable auth for Fayz apps — one hook, swappable adapters.
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/@fayz-ai/auth)
|
|
6
|
+
[](https://github.com/FayaLabs/fayz-sdk/blob/main/LICENSE)
|
|
7
|
+
|
|
8
|
+
Auth shouldn't be the thing that couples your app to a backend. `@fayz-ai/auth` wraps authentication behind the core `AuthAdapter` contract so a Fayz app reads the same whether it's running on Supabase in production or a mock adapter in tests and previews. One provider, one `useAuth` hook, a Zustand-backed session store — the rest is an implementation detail you can swap.
|
|
9
|
+
|
|
10
|
+
This is the auth layer for composed Fayz SaaS apps: drop in `AuthProvider`, pick an adapter, and every plugin gets a consistent user and session without knowing where it came from.
|
|
11
|
+
|
|
12
|
+
## What's inside
|
|
13
|
+
- `createSupabaseAuthAdapter` — production Supabase auth, typed via `SupabaseAuthConfig`
|
|
14
|
+
- `createMockAuthAdapter` — deterministic auth for tests, demos, and previews (`MockUser`)
|
|
15
|
+
- `AuthProvider` + `useAuth` — React context and hook for the current user and session
|
|
16
|
+
- `useAuthStore` — the underlying Zustand store (`AuthState`, `AuthStore`) for advanced access
|
|
17
|
+
|
|
18
|
+
## Install
|
|
19
|
+
```bash
|
|
20
|
+
npm install @fayz-ai/auth
|
|
21
|
+
```
|
|
22
|
+
Peer dep: `react` (^18 or ^19). Built on `@fayz-ai/core`.
|
|
23
|
+
|
|
24
|
+
## Usage
|
|
25
|
+
```tsx
|
|
26
|
+
import { AuthProvider, useAuth, createSupabaseAuthAdapter } from '@fayz-ai/auth'
|
|
27
|
+
|
|
28
|
+
const adapter = createSupabaseAuthAdapter({ url, anonKey })
|
|
29
|
+
|
|
30
|
+
function App() {
|
|
31
|
+
return (
|
|
32
|
+
<AuthProvider adapter={adapter}>
|
|
33
|
+
<Dashboard />
|
|
34
|
+
</AuthProvider>
|
|
35
|
+
)
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function Dashboard() {
|
|
39
|
+
const { user } = useAuth()
|
|
40
|
+
return <p>Hello, {user?.email}</p>
|
|
41
|
+
}
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## Part of the Fayz SDK
|
|
45
|
+
The auth seam between `@fayz-ai/core` and the multi-tenant `@fayz-ai/saas` layer.
|
|
46
|
+
|
|
47
|
+
## Roadmap & contributing
|
|
48
|
+
Built and evolving in the open. See the [Fayz SDK roadmap](../../docs/ROADMAP.md#auth) for current gaps, missing features, and good first issues.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fayz-ai/auth",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.7",
|
|
4
4
|
"description": "Fayz SDK auth — pluggable authentication adapters with React hooks",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./src/index.ts",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"@supabase/supabase-js": "^2.45.0",
|
|
26
26
|
"zustand": "^4.5.0",
|
|
27
|
-
"@fayz-ai/core": "^0.1.
|
|
27
|
+
"@fayz-ai/core": "^0.1.7"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
30
|
"@types/react": "^18.3.0",
|