@quatrain/auth-supabase 1.1.10 → 1.1.12
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.
|
@@ -10,6 +10,7 @@ export declare class SupabaseAuthAdapter extends AbstractAuthAdapter {
|
|
|
10
10
|
*/
|
|
11
11
|
register(user: User): Promise<any>;
|
|
12
12
|
getAuthToken(bearer: string): Promise<any>;
|
|
13
|
+
refreshToken(refreshToken: string): Promise<any>;
|
|
13
14
|
revokeAuthToken(token: string): Promise<void>;
|
|
14
15
|
signup(login: string, password: string): Promise<false | {
|
|
15
16
|
user: any;
|
|
@@ -1,4 +1,27 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
2
25
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
26
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
27
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -12,6 +35,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
35
|
exports.SupabaseAuthAdapter = void 0;
|
|
13
36
|
const auth_1 = require("@quatrain/auth");
|
|
14
37
|
const supabase_js_1 = require("@supabase/supabase-js");
|
|
38
|
+
const nativeFetch = __importStar(require("node-fetch-native"));
|
|
15
39
|
// Create a single supabase client for interacting with your database
|
|
16
40
|
class SupabaseAuthAdapter extends auth_1.AbstractAuthAdapter {
|
|
17
41
|
constructor(params = {}) {
|
|
@@ -60,6 +84,22 @@ class SupabaseAuthAdapter extends auth_1.AbstractAuthAdapter {
|
|
|
60
84
|
throw new Error('Unable to retrieve auth token from Supabase');
|
|
61
85
|
});
|
|
62
86
|
}
|
|
87
|
+
refreshToken(refreshToken) {
|
|
88
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
89
|
+
const url = `${this._params.config.supabaseUrl}/auth/v1/token?grant_type=refresh_token`;
|
|
90
|
+
const response = yield nativeFetch.fetch(url, {
|
|
91
|
+
method: 'POST',
|
|
92
|
+
headers: {
|
|
93
|
+
apikey: this._params.config.supabaseKey,
|
|
94
|
+
},
|
|
95
|
+
body: JSON.stringify({
|
|
96
|
+
refresh_token: refreshToken,
|
|
97
|
+
}),
|
|
98
|
+
});
|
|
99
|
+
const data = response.json();
|
|
100
|
+
return data;
|
|
101
|
+
});
|
|
102
|
+
}
|
|
63
103
|
revokeAuthToken(token) {
|
|
64
104
|
return __awaiter(this, void 0, void 0, function* () {
|
|
65
105
|
// Careful, this only delete tokens on client side, not on server side
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quatrain/auth-supabase",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.12",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
@@ -10,8 +10,9 @@
|
|
|
10
10
|
],
|
|
11
11
|
"author": "Quatrain Développement SAS <developers@quatrain.com>",
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@quatrain/auth": "^1.1.
|
|
14
|
-
"@supabase/supabase-js": "^2.45.1"
|
|
13
|
+
"@quatrain/auth": "^1.1.14",
|
|
14
|
+
"@supabase/supabase-js": "^2.45.1",
|
|
15
|
+
"node-fetch-native": "^1.6.4"
|
|
15
16
|
},
|
|
16
17
|
"devDependencies": {
|
|
17
18
|
"@tsconfig/recommended": "^1.0.1",
|
|
@@ -26,12 +27,14 @@
|
|
|
26
27
|
"typescript": "^5.1.5"
|
|
27
28
|
},
|
|
28
29
|
"scripts": {
|
|
29
|
-
"pretest": "tsc",
|
|
30
|
-
"test": "clear && firebase emulators:exec 'jest -i --verbose'",
|
|
31
30
|
"test-ci": "jest --runInBand",
|
|
32
31
|
"build": "tsc",
|
|
33
32
|
"wbuild": "tsc --watch",
|
|
34
33
|
"bump-to": "yarn version",
|
|
35
|
-
"
|
|
34
|
+
"hash": "node ../../bin/hashFolder.js",
|
|
35
|
+
"hash:persist": "yarn hash > .hash_latest.txt",
|
|
36
|
+
"hash:compare": "yarn hash > .hash_newest.txt && cmp -s .hash_latest.txt .hash_newest.txt",
|
|
37
|
+
"publish": "yarn hash:compare || yarn publish:process",
|
|
38
|
+
"publish:process": "yarn version patch && yarn build && yarn npm publish --access public && yarn hash:persist"
|
|
36
39
|
}
|
|
37
40
|
}
|