@nebulr-group/bridge-svelte 0.1.0-beta.2 → 0.1.0
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
|
@@ -57,12 +57,12 @@ export function createRouteGuard() {
|
|
|
57
57
|
}
|
|
58
58
|
function shouldRedirectToLogin(pathname) {
|
|
59
59
|
const isProtected = isProtectedRoute(pathname);
|
|
60
|
-
const
|
|
60
|
+
const authenticated = get(isAuthenticated);
|
|
61
61
|
if (isProtectedRoute(pathname) && !get(isAuthenticated)) {
|
|
62
|
-
logger.debug(`[route-guard] path ${pathname} is protected and user is not
|
|
62
|
+
logger.debug(`[route-guard] path ${pathname} is protected and user is not authenticated`);
|
|
63
63
|
return true;
|
|
64
64
|
}
|
|
65
|
-
logger.debug(`[route-guard] path ${pathname} is ${isProtected ? 'protected' : 'public'} and user ${
|
|
65
|
+
logger.debug(`[route-guard] path ${pathname} is ${isProtected ? 'protected' : 'public'} and user ${authenticated ? 'authenticated' : 'not authenticated'}`);
|
|
66
66
|
return false;
|
|
67
67
|
}
|
|
68
68
|
async function checkRouteRestrictions(pathname) {
|
|
@@ -20,7 +20,7 @@ export async function bridgeBootstrap(url, config, routeConfig = { rules: [], de
|
|
|
20
20
|
try {
|
|
21
21
|
await handleCallback(code);
|
|
22
22
|
// Redirect bridge user to bridge home page after bridge callback is handled
|
|
23
|
-
|
|
23
|
+
redirect(303, '/');
|
|
24
24
|
}
|
|
25
25
|
catch (err) {
|
|
26
26
|
logger.error('Auth callback error:', err);
|
|
@@ -40,10 +40,10 @@ export async function bridgeBootstrap(url, config, routeConfig = { rules: [], de
|
|
|
40
40
|
const decision = await guard.getNavigationDecision(url.pathname);
|
|
41
41
|
logger.debug('[bridgeBootstrap] navigation decision', decision);
|
|
42
42
|
if (decision.type === 'login') {
|
|
43
|
-
|
|
43
|
+
redirect(303, auth.createLoginUrl());
|
|
44
44
|
}
|
|
45
45
|
if (decision.type === 'redirect' && url.pathname !== decision.to) {
|
|
46
|
-
|
|
46
|
+
redirect(303, decision.to);
|
|
47
47
|
}
|
|
48
48
|
logger.debug('[bridgeBootstrap] in bridge end');
|
|
49
49
|
}
|
|
@@ -50,8 +50,8 @@
|
|
|
50
50
|
logger.debug('TeamManagement onMount');
|
|
51
51
|
try {
|
|
52
52
|
if (!auth.isAuthenticated) {
|
|
53
|
-
logger.debug('TeamManagement onMount: User is not
|
|
54
|
-
throw new Error('User must be
|
|
53
|
+
logger.debug('TeamManagement onMount: User is not authenticated');
|
|
54
|
+
throw new Error('User must be authenticated to access team management');
|
|
55
55
|
}
|
|
56
56
|
const token = auth.getToken();
|
|
57
57
|
// Get bridge access token from your auth store
|
|
@@ -49,7 +49,7 @@ function createLoginUrl(options = {}) {
|
|
|
49
49
|
const config = getConfig();
|
|
50
50
|
const redirectUri = options.redirectUri ?? config.callbackUrl;
|
|
51
51
|
const base = `${config.authBaseUrl}/url/login/${config.appId}`;
|
|
52
|
-
return redirectUri ? `${base}?redirect_uri=${encodeURIComponent(redirectUri)}` : base;
|
|
52
|
+
return redirectUri ? `${base}?cv_env=bridge&redirect_uri=${encodeURIComponent(redirectUri)}` : base;
|
|
53
53
|
}
|
|
54
54
|
async function handleCallback(code) {
|
|
55
55
|
const config = getConfig();
|
|
@@ -59,7 +59,7 @@ async function handleCallback(code) {
|
|
|
59
59
|
headers: { 'Content-Type': 'application/json' },
|
|
60
60
|
body: JSON.stringify({
|
|
61
61
|
code,
|
|
62
|
-
...(config.callbackUrl ? { redirect_uri: config.callbackUrl } : {})
|
|
62
|
+
...(config.callbackUrl ? { redirect_uri: config.callbackUrl, redirectUri: config.callbackUrl } : {})
|
|
63
63
|
})
|
|
64
64
|
});
|
|
65
65
|
if (!response.ok) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nebulr-group/bridge-svelte",
|
|
3
|
-
"version": "0.1.0
|
|
3
|
+
"version": "0.1.0",
|
|
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",
|