@quatrain/auth-supabase 1.2.4 → 1.2.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.
@@ -1,6 +1,5 @@
1
1
  import { User } from '@quatrain/backend';
2
2
  import { AbstractAuthAdapter, AuthParameters } from '@quatrain/auth';
3
- import { ApiMiddleware } from '@quatrain/api';
4
3
  /**
5
4
  * Authentication adapter implementing the Supabase SDK ecosystem.
6
5
  * Acts as a centralized bridge handling signup, tokens, and middleware enforcement.
@@ -14,12 +13,6 @@ export declare class SupabaseAuthAdapter extends AbstractAuthAdapter {
14
13
  * @returns A constructed SupabaseAuthAdapter or null on invalid params.
15
14
  */
16
15
  static factory(config: any): SupabaseAuthAdapter | null;
17
- /**
18
- * Express middleware capturing Bearer JWT tokens to execute auth verification.
19
- *
20
- * @returns The middleware function.
21
- */
22
- middleware(): ApiMiddleware;
23
16
  constructor(params?: AuthParameters);
24
17
  /**
25
18
  * Register new user in authentication
@@ -63,31 +63,6 @@ class SupabaseAuthAdapter extends auth_1.AbstractAuthAdapter {
63
63
  return null;
64
64
  return new SupabaseAuthAdapter({ config });
65
65
  }
66
- /**
67
- * Express middleware capturing Bearer JWT tokens to execute auth verification.
68
- *
69
- * @returns The middleware function.
70
- */
71
- middleware() {
72
- return (req, res) => __awaiter(this, void 0, void 0, function* () {
73
- var _a;
74
- const bearer = (((_a = req.headers) === null || _a === void 0 ? void 0 : _a.authorization) || '').split(' ')[1] || '';
75
- if (bearer) {
76
- try {
77
- const user = yield this.getAuthToken(bearer);
78
- if (user) {
79
- return true; // Authorized
80
- }
81
- }
82
- catch (e) {
83
- auth_1.Auth.error(`[SupabaseAuthAdapter] Middleware token verification failed: ${e.message}`);
84
- }
85
- }
86
- res.setHeader('WWW-Authenticate', 'Bearer realm="Core API"');
87
- res.status(401).send('Authentication required.');
88
- return false;
89
- });
90
- }
91
66
  constructor(params = {}) {
92
67
  super(params);
93
68
  this._client = (0, supabase_js_1.createClient)(params.config.supabaseUrl, params.config.supabaseKey, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quatrain/auth-supabase",
3
- "version": "1.2.4",
3
+ "version": "1.2.5",
4
4
  "license": "AGPL-3.0-only",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -20,8 +20,8 @@
20
20
  "author": "Quatrain Développement SAS <developers@quatrain.com>",
21
21
  "dependencies": {
22
22
  "@quatrain/api": "^1.1.5",
23
- "@quatrain/auth": "^1.2.2",
24
- "@quatrain/backend": "^1.2.6",
23
+ "@quatrain/auth": "^1.2.3",
24
+ "@quatrain/backend": "^1.2.11",
25
25
  "@supabase/supabase-js": "^2.87.3",
26
26
  "node-fetch-native": "^1.6.4"
27
27
  },
@@ -5,7 +5,7 @@ import {
5
5
  AuthenticationError,
6
6
  AuthParameters,
7
7
  } from '@quatrain/auth'
8
- import { ApiMiddleware, ApiRequest, ApiResponse } from '@quatrain/api'
8
+
9
9
  import { createClient } from '@supabase/supabase-js'
10
10
  import * as nativeFetch from 'node-fetch-native'
11
11
 
@@ -28,31 +28,7 @@ export class SupabaseAuthAdapter extends AbstractAuthAdapter {
28
28
  return new SupabaseAuthAdapter({ config })
29
29
  }
30
30
 
31
- /**
32
- * Express middleware capturing Bearer JWT tokens to execute auth verification.
33
- *
34
- * @returns The middleware function.
35
- */
36
- public middleware(): ApiMiddleware {
37
- return async (req: ApiRequest, res: ApiResponse): Promise<boolean> => {
38
- const bearer = ((req.headers?.authorization as string) || '').split(' ')[1] || ''
39
-
40
- if (bearer) {
41
- try {
42
- const user = await this.getAuthToken(bearer)
43
- if (user) {
44
- return true // Authorized
45
- }
46
- } catch(e) {
47
- Auth.error(`[SupabaseAuthAdapter] Middleware token verification failed: ${(e as Error).message}`)
48
- }
49
- }
50
31
 
51
- res.setHeader('WWW-Authenticate', 'Bearer realm="Core API"')
52
- res.status(401).send('Authentication required.')
53
- return false
54
- }
55
- }
56
32
 
57
33
  constructor(params: AuthParameters = {}) {
58
34
  super(params)