@fayz-ai/auth 0.1.6 → 0.2.0
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/LICENSE +21 -0
- package/README.md +48 -0
- package/package.json +2 -2
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Faya Labs
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
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.
|
|
3
|
+
"version": "0.2.0",
|
|
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.
|
|
27
|
+
"@fayz-ai/core": "^0.2.0"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
30
|
"@types/react": "^18.3.0",
|