@quatrain/auth-supabase 1.1.15 → 1.1.17
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 +28 -0
- package/lib/SupabaseAuthAdapter.d.ts +1 -1
- package/lib/SupabaseAuthAdapter.js +13 -5
- package/package.json +2 -2
package/README.md
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# @quatrain/auth-supabase
|
|
2
|
+
|
|
3
|
+
An authentication adapter for Supabase Auth. This package provides a seamless integration between Quatrain and Supabase's GoTrue-based authentication service.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
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.
|
|
11
|
+
|
|
12
|
+
## Installation
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
npm install @quatrain/auth-supabase @supabase/supabase-js
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Usage
|
|
19
|
+
|
|
20
|
+
```typescript
|
|
21
|
+
import { Auth } from '@quatrain/auth'
|
|
22
|
+
import { SupabaseAuthAdapter } from '@quatrain/auth-supabase'
|
|
23
|
+
|
|
24
|
+
const adapter = new SupabaseAuthAdapter({
|
|
25
|
+
config: { url: '...', anonKey: '...' },
|
|
26
|
+
})
|
|
27
|
+
Auth.addAdapter(adapter, 'default', true)
|
|
28
|
+
```
|
|
@@ -11,7 +11,7 @@ export declare class SupabaseAuthAdapter extends AbstractAuthAdapter {
|
|
|
11
11
|
register(user: User, clearPassword?: string): Promise<any>;
|
|
12
12
|
getAuthToken(bearer: string): Promise<any>;
|
|
13
13
|
refreshToken(refreshToken: string): Promise<any>;
|
|
14
|
-
revokeAuthToken(token: string): Promise<
|
|
14
|
+
revokeAuthToken(token: string): Promise<false | undefined>;
|
|
15
15
|
signup(login: string, password: string): Promise<false | {
|
|
16
16
|
user: any;
|
|
17
17
|
session: any;
|
|
@@ -46,6 +46,7 @@ class SupabaseAuthAdapter extends auth_1.AbstractAuthAdapter {
|
|
|
46
46
|
persistSession: false,
|
|
47
47
|
},
|
|
48
48
|
});
|
|
49
|
+
auth_1.Auth.info(`Created Supabase client for ${params.config.supabaseUrl}`);
|
|
49
50
|
}
|
|
50
51
|
/**
|
|
51
52
|
* Register new user in authentication
|
|
@@ -106,6 +107,10 @@ class SupabaseAuthAdapter extends auth_1.AbstractAuthAdapter {
|
|
|
106
107
|
return __awaiter(this, void 0, void 0, function* () {
|
|
107
108
|
// Careful, this only delete tokens on client side, not on server side
|
|
108
109
|
const { error } = yield this.signout();
|
|
110
|
+
if (error !== null) {
|
|
111
|
+
auth_1.Auth.error(error);
|
|
112
|
+
return false;
|
|
113
|
+
}
|
|
109
114
|
});
|
|
110
115
|
}
|
|
111
116
|
signup(login, password) {
|
|
@@ -115,7 +120,7 @@ class SupabaseAuthAdapter extends auth_1.AbstractAuthAdapter {
|
|
|
115
120
|
password,
|
|
116
121
|
});
|
|
117
122
|
if (error !== null) {
|
|
118
|
-
auth_1.Auth.
|
|
123
|
+
auth_1.Auth.error(error);
|
|
119
124
|
return false;
|
|
120
125
|
}
|
|
121
126
|
return { user: data.user, session: data.session };
|
|
@@ -123,7 +128,7 @@ class SupabaseAuthAdapter extends auth_1.AbstractAuthAdapter {
|
|
|
123
128
|
}
|
|
124
129
|
signout() {
|
|
125
130
|
return __awaiter(this, void 0, void 0, function* () {
|
|
126
|
-
const {
|
|
131
|
+
const { error } = yield this._client.auth.signOut();
|
|
127
132
|
if (error !== null) {
|
|
128
133
|
auth_1.Auth.error(error);
|
|
129
134
|
return false;
|
|
@@ -137,13 +142,16 @@ class SupabaseAuthAdapter extends auth_1.AbstractAuthAdapter {
|
|
|
137
142
|
try {
|
|
138
143
|
if (Object.keys(updatable).length > 0) {
|
|
139
144
|
auth_1.Auth.info(`Updating ${updatable.displayName} Auth record`);
|
|
140
|
-
const {
|
|
145
|
+
const { error } = yield this._client.auth.admin.updateUserById(user.uid, updatable);
|
|
141
146
|
if (error !== null) {
|
|
142
|
-
auth_1.Auth.
|
|
147
|
+
auth_1.Auth.error(error);
|
|
143
148
|
}
|
|
144
149
|
}
|
|
145
150
|
}
|
|
146
|
-
catch (e) {
|
|
151
|
+
catch (e) {
|
|
152
|
+
auth_1.Auth.error(e);
|
|
153
|
+
return false;
|
|
154
|
+
}
|
|
147
155
|
});
|
|
148
156
|
}
|
|
149
157
|
delete(user) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quatrain/auth-supabase",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.17",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"author": "Quatrain Développement SAS <developers@quatrain.com>",
|
|
12
12
|
"dependencies": {
|
|
13
13
|
"@quatrain/auth": "^1.1.17",
|
|
14
|
-
"@supabase/supabase-js": "^2.
|
|
14
|
+
"@supabase/supabase-js": "^2.57.2",
|
|
15
15
|
"node-fetch-native": "^1.6.4"
|
|
16
16
|
},
|
|
17
17
|
"devDependencies": {
|