@nebulr-group/bridge-svelte 0.1.0-beta.1 → 0.1.0-beta.2
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/dist/auth/route-guard.js
CHANGED
|
@@ -3,7 +3,7 @@ import { getRouteGuardConfig } from '../client/stores/config.store.js';
|
|
|
3
3
|
import { isFeatureEnabled } from '../shared/feature-flag.js';
|
|
4
4
|
import { logger } from '../shared/logger.js';
|
|
5
5
|
import { auth } from '../shared/services/auth.service.js';
|
|
6
|
-
const {
|
|
6
|
+
const { isAuthenticated, createLoginUrl } = auth;
|
|
7
7
|
function escapeRegex(text) {
|
|
8
8
|
return text.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
9
9
|
}
|
|
@@ -57,8 +57,8 @@ export function createRouteGuard() {
|
|
|
57
57
|
}
|
|
58
58
|
function shouldRedirectToLogin(pathname) {
|
|
59
59
|
const isProtected = isProtectedRoute(pathname);
|
|
60
|
-
const aubridgenticated = get(
|
|
61
|
-
if (isProtectedRoute(pathname) && !get(
|
|
60
|
+
const aubridgenticated = get(isAuthenticated);
|
|
61
|
+
if (isProtectedRoute(pathname) && !get(isAuthenticated)) {
|
|
62
62
|
logger.debug(`[route-guard] path ${pathname} is protected and user is not aubridgenticated`);
|
|
63
63
|
return true;
|
|
64
64
|
}
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
onMount(async () => {
|
|
50
50
|
logger.debug('TeamManagement onMount');
|
|
51
51
|
try {
|
|
52
|
-
if (!auth.
|
|
52
|
+
if (!auth.isAuthenticated) {
|
|
53
53
|
logger.debug('TeamManagement onMount: User is not aubridgenticated');
|
|
54
54
|
throw new Error('User must be aubridgenticated to access team management');
|
|
55
55
|
}
|
|
@@ -10,7 +10,7 @@ declare function handleCallback(code: string): Promise<void>;
|
|
|
10
10
|
declare function refreshToken(refreshToken: string): Promise<TokenSet | null>;
|
|
11
11
|
export declare const auth: {
|
|
12
12
|
token: import("svelte/store").Writable<any>;
|
|
13
|
-
|
|
13
|
+
isAuthenticated: import("svelte/store").Readable<boolean>;
|
|
14
14
|
isLoading: import("svelte/store").Writable<boolean>;
|
|
15
15
|
error: import("svelte/store").Writable<string | null>;
|
|
16
16
|
login: typeof login;
|
|
@@ -192,11 +192,11 @@ export async function maybeRefreshNow() {
|
|
|
192
192
|
return true;
|
|
193
193
|
}
|
|
194
194
|
// --- Derived values ---
|
|
195
|
-
const
|
|
195
|
+
const isAuthenticated = derived(tokenStore, $t => !!$t?.accessToken);
|
|
196
196
|
// --- Exports ---
|
|
197
197
|
export const auth = {
|
|
198
198
|
token: tokenStore,
|
|
199
|
-
|
|
199
|
+
isAuthenticated,
|
|
200
200
|
isLoading,
|
|
201
201
|
error,
|
|
202
202
|
login,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nebulr-group/bridge-svelte",
|
|
3
|
-
"version": "0.1.0-beta.
|
|
3
|
+
"version": "0.1.0-beta.2",
|
|
4
4
|
|
|
5
5
|
"description": "Bridge Svelte library, This library helps you to add bridge authentication and feature flags, and payments to your svelte application.",
|
|
6
6
|
"author": "Iman Pouya",
|