@spidy092/auth-client 2.0.4 → 2.0.6
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/api.js +2 -1
- package/package.json +1 -1
- package/token.js +32 -32
package/api.js
CHANGED
|
@@ -12,7 +12,8 @@ api.interceptors.request.use((config) => {
|
|
|
12
12
|
const runtimeConfig = getConfig();
|
|
13
13
|
|
|
14
14
|
if (!config.baseURL) {
|
|
15
|
-
|
|
15
|
+
|
|
16
|
+
config.baseURL = runtimeConfig?.authBaseUrl || 'http://auth.local.test:4000/auth';
|
|
16
17
|
}
|
|
17
18
|
|
|
18
19
|
if (!config.headers) {
|
package/package.json
CHANGED
package/token.js
CHANGED
|
@@ -46,44 +46,44 @@ function readAccessToken() {
|
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
// ========== REFRESH TOKEN (KEEP SIMPLE) ==========
|
|
49
|
-
export function setRefreshToken(token) {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
49
|
+
// export function setRefreshToken(token) {
|
|
50
|
+
// if (!token) {
|
|
51
|
+
// clearRefreshToken();
|
|
52
|
+
// return;
|
|
53
|
+
// }
|
|
54
54
|
|
|
55
|
-
|
|
55
|
+
// const expires = new Date(Date.now() + COOKIE_MAX_AGE * 1000);
|
|
56
56
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
}
|
|
57
|
+
// try {
|
|
58
|
+
// document.cookie = `${REFRESH_COOKIE}=${encodeURIComponent(token)}; Path=/; SameSite=Lax${secureAttribute()}; Expires=${expires.toUTCString()}`;
|
|
59
|
+
// } catch (err) {
|
|
60
|
+
// console.warn('Could not set refresh token:', err);
|
|
61
|
+
// }
|
|
62
|
+
// }
|
|
63
63
|
|
|
64
|
-
export function getRefreshToken() {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
64
|
+
// export function getRefreshToken() {
|
|
65
|
+
// try {
|
|
66
|
+
// const match = document.cookie
|
|
67
|
+
// ?.split('; ')
|
|
68
|
+
// ?.find((row) => row.startsWith(`${REFRESH_COOKIE}=`));
|
|
69
69
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
70
|
+
// if (match) {
|
|
71
|
+
// return decodeURIComponent(match.split('=')[1]);
|
|
72
|
+
// }
|
|
73
|
+
// } catch (err) {
|
|
74
|
+
// console.warn('Could not read refresh token:', err);
|
|
75
|
+
// }
|
|
76
76
|
|
|
77
|
-
|
|
78
|
-
}
|
|
77
|
+
// return null;
|
|
78
|
+
// }
|
|
79
79
|
|
|
80
|
-
export function clearRefreshToken() {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
}
|
|
80
|
+
// export function clearRefreshToken() {
|
|
81
|
+
// try {
|
|
82
|
+
// document.cookie = `${REFRESH_COOKIE}=; Path=/; SameSite=Lax${secureAttribute()}; Expires=Thu, 01 Jan 1970 00:00:00 GMT`;
|
|
83
|
+
// } catch (err) {
|
|
84
|
+
// console.warn('Could not clear refresh token:', err);
|
|
85
|
+
// }
|
|
86
|
+
// }
|
|
87
87
|
|
|
88
88
|
// ========== ACCESS TOKEN FUNCTIONS ==========
|
|
89
89
|
function decode(token) {
|