@quatrain/auth-supabase 1.1.26 → 1.1.28

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.
Files changed (2) hide show
  1. package/README.md +17 -65
  2. package/package.json +3 -3
package/README.md CHANGED
@@ -1,89 +1,41 @@
1
1
  # @quatrain/auth-supabase
2
2
 
3
- An authentication adapter for Supabase Auth. This package provides a seamless integration between Quatrain and Supabase's GoTrue-based authentication service.
3
+ The Supabase Authentication adapter for `@quatrain/auth`.
4
4
 
5
- ## Features
5
+ ## Introduction
6
6
 
7
- - Implements the `@quatrain/auth` abstract adapter.
8
- - Works with both Supabase SaaS and self-hosted instances.
9
- - Leverages Supabase's Row-Level Security (RLS) for data access.
10
- - Uses the `@supabase/supabase-js` library.
7
+ Supabase Auth provides robust user management based on PostgreSQL Row Level Security. This adapter implements the Quatrain Auth interface to verify Supabase JWTs and manage user sessions.
11
8
 
12
9
  ## Installation
13
10
 
14
11
  ```bash
15
12
  npm install @quatrain/auth-supabase @supabase/supabase-js
13
+ # or
14
+ yarn add @quatrain/auth-supabase @supabase/supabase-js
16
15
  ```
17
16
 
18
- ## Usage
17
+ ## Configuration
19
18
 
20
- ### Setup
19
+ Initialize the adapter using your Supabase project URL and service role key.
21
20
 
22
21
  ```typescript
23
22
  import { Auth } from '@quatrain/auth'
24
23
  import { SupabaseAuthAdapter } from '@quatrain/auth-supabase'
25
24
 
26
- const adapter = new SupabaseAuthAdapter({
27
- config: { supabaseUrl: '...', supabaseKey: '...' },
25
+ const supabaseAuth = new SupabaseAuthAdapter({
26
+ config: {
27
+ url: process.env.SUPABASE_URL,
28
+ key: process.env.SUPABASE_SERVICE_ROLE_KEY
29
+ }
28
30
  })
29
- Auth.addProvider(adapter, 'default', true)
30
- ```
31
-
32
- ### Register a New User
33
-
34
- ```typescript
35
- import { User } from '@quatrain/backend'
36
-
37
- const user = new User({
38
- _: {
39
- name: 'John Doe',
40
- email: 'john@example.com',
41
- phone: '+1234567890',
42
- },
43
- })
44
-
45
- const supabaseUser = await adapter.register(user, 'password123')
46
- console.log('User registered:', supabaseUser.id)
47
- ```
48
-
49
- ### Sign In
50
-
51
- ```typescript
52
- const result = await adapter.signup('john@example.com', 'password123')
53
- if (result) {
54
- console.log('Signed in:', result.user)
55
- console.log('Session token:', result.session.access_token)
56
- }
57
- ```
58
31
 
59
- ### Sign Out
60
-
61
- ```typescript
62
- const success = await adapter.signout()
63
- console.log('Signed out:', success)
64
- ```
65
-
66
- ### Update User Profile
67
-
68
- ```typescript
69
- await adapter.update(user, {
70
- email: 'newemail@example.com',
71
- phone: '+0987654321',
72
- })
32
+ Auth.addAdapter('supabase', supabaseAuth, true)
73
33
  ```
74
34
 
75
- ### Refresh Token
35
+ ## Documentation
76
36
 
77
- ```typescript
78
- const newTokens = await adapter.refreshToken(refreshToken)
79
- console.log('New access token:', newTokens.access_token)
80
- ```
37
+ For concrete examples and usage guides, please refer to the [How-To Guide](HOWTO.md).
81
38
 
82
- ### Set Custom User Claims
39
+ ## License
83
40
 
84
- ```typescript
85
- await adapter.setCustomUserClaims(userId, {
86
- role: 'admin',
87
- permissions: ['read', 'write', 'delete'],
88
- })
89
- ```
41
+ AGPL-3.0-only
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quatrain/auth-supabase",
3
- "version": "1.1.26",
3
+ "version": "1.1.28",
4
4
  "license": "AGPL-3.0-only",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -13,8 +13,8 @@
13
13
  ],
14
14
  "author": "Quatrain Développement SAS <developers@quatrain.com>",
15
15
  "dependencies": {
16
- "@quatrain/auth": "^1.1.27",
17
- "@quatrain/backend": "^1.1.33",
16
+ "@quatrain/auth": "^1.1.29",
17
+ "@quatrain/backend": "^1.1.34",
18
18
  "@supabase/supabase-js": "^2.87.3",
19
19
  "node-fetch-native": "^1.6.4"
20
20
  },