@nebulr-group/bridge-svelte 0.1.0-beta.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/LICENSE +21 -0
- package/README.md +63 -0
- package/dist/auth/route-guard.d.ts +2 -0
- package/dist/auth/route-guard.js +28 -0
- package/dist/client/BridgeBootstrap.d.ts +8 -0
- package/dist/client/BridgeBootstrap.js +105 -0
- package/dist/client/BridgeBootstrap.svelte +43 -0
- package/dist/client/BridgeBootstrap.svelte.d.ts +6 -0
- package/dist/client/components/FeatureFlag.svelte +37 -0
- package/dist/client/components/FeatureFlag.svelte.d.ts +15 -0
- package/dist/client/components/ProfileName.svelte +18 -0
- package/dist/client/components/ProfileName.svelte.d.ts +6 -0
- package/dist/client/components/developer/ApiTokenManagement.svelte +365 -0
- package/dist/client/components/developer/ApiTokenManagement.svelte.d.ts +6 -0
- package/dist/client/components/sdk-auth/ForgotPassword.svelte +170 -0
- package/dist/client/components/sdk-auth/ForgotPassword.svelte.d.ts +10 -0
- package/dist/client/components/sdk-auth/LoginForm.svelte +414 -0
- package/dist/client/components/sdk-auth/LoginForm.svelte.d.ts +25 -0
- package/dist/client/components/sdk-auth/MagicLink.svelte +92 -0
- package/dist/client/components/sdk-auth/MagicLink.svelte.d.ts +9 -0
- package/dist/client/components/sdk-auth/MfaChallenge.svelte +150 -0
- package/dist/client/components/sdk-auth/MfaChallenge.svelte.d.ts +9 -0
- package/dist/client/components/sdk-auth/MfaSetup.svelte +182 -0
- package/dist/client/components/sdk-auth/MfaSetup.svelte.d.ts +8 -0
- package/dist/client/components/sdk-auth/PasskeyLogin.svelte +99 -0
- package/dist/client/components/sdk-auth/PasskeyLogin.svelte.d.ts +10 -0
- package/dist/client/components/sdk-auth/PasskeyRequestSetupLink.svelte +83 -0
- package/dist/client/components/sdk-auth/PasskeyRequestSetupLink.svelte.d.ts +7 -0
- package/dist/client/components/sdk-auth/PasskeySetup.svelte +151 -0
- package/dist/client/components/sdk-auth/PasskeySetup.svelte.d.ts +11 -0
- package/dist/client/components/sdk-auth/SignupForm.svelte +119 -0
- package/dist/client/components/sdk-auth/SignupForm.svelte.d.ts +14 -0
- package/dist/client/components/sdk-auth/SsoButton.svelte +70 -0
- package/dist/client/components/sdk-auth/SsoButton.svelte.d.ts +13 -0
- package/dist/client/components/sdk-auth/SsoProviderIcon.svelte +56 -0
- package/dist/client/components/sdk-auth/SsoProviderIcon.svelte.d.ts +7 -0
- package/dist/client/components/sdk-auth/TenantSelector.svelte +83 -0
- package/dist/client/components/sdk-auth/TenantSelector.svelte.d.ts +11 -0
- package/dist/client/components/sdk-auth/WorkspaceSelector.svelte +108 -0
- package/dist/client/components/sdk-auth/WorkspaceSelector.svelte.d.ts +16 -0
- package/dist/client/components/sdk-auth/shared/Alert.svelte +17 -0
- package/dist/client/components/sdk-auth/shared/Alert.svelte.d.ts +9 -0
- package/dist/client/components/sdk-auth/shared/AuthFormWrapper.svelte +23 -0
- package/dist/client/components/sdk-auth/shared/AuthFormWrapper.svelte.d.ts +10 -0
- package/dist/client/components/sdk-auth/shared/Spinner.svelte +16 -0
- package/dist/client/components/sdk-auth/shared/Spinner.svelte.d.ts +7 -0
- package/dist/client/components/subscription/PlanSelector.svelte +204 -0
- package/dist/client/components/subscription/PlanSelector.svelte.d.ts +22 -0
- package/dist/client/components/team/TeamAddUserDialog.svelte +125 -0
- package/dist/client/components/team/TeamAddUserDialog.svelte.d.ts +17 -0
- package/dist/client/components/team/TeamConfirmDialog.svelte +80 -0
- package/dist/client/components/team/TeamConfirmDialog.svelte.d.ts +21 -0
- package/dist/client/components/team/TeamEditUserDialog.svelte +131 -0
- package/dist/client/components/team/TeamEditUserDialog.svelte.d.ts +19 -0
- package/dist/client/components/team/TeamManagementPanel.svelte +72 -0
- package/dist/client/components/team/TeamManagementPanel.svelte.d.ts +20 -0
- package/dist/client/components/team/TeamProfileForm.svelte +129 -0
- package/dist/client/components/team/TeamProfileForm.svelte.d.ts +7 -0
- package/dist/client/components/team/TeamUserActionsMenu.svelte +63 -0
- package/dist/client/components/team/TeamUserActionsMenu.svelte.d.ts +9 -0
- package/dist/client/components/team/TeamUserList.svelte +226 -0
- package/dist/client/components/team/TeamUserList.svelte.d.ts +7 -0
- package/dist/client/components/team/TeamWorkspaceForm.svelte +134 -0
- package/dist/client/components/team/TeamWorkspaceForm.svelte.d.ts +7 -0
- package/dist/client/stores/config.store.d.ts +6 -0
- package/dist/client/stores/config.store.js +76 -0
- package/dist/client/utils/cn.d.ts +1 -0
- package/dist/client/utils/cn.js +3 -0
- package/dist/core/bridge-instance.d.ts +52 -0
- package/dist/core/bridge-instance.js +160 -0
- package/dist/index.d.ts +34 -0
- package/dist/index.js +39 -0
- package/dist/shared/feature-flag.d.ts +6 -0
- package/dist/shared/feature-flag.js +13 -0
- package/dist/shared/logger.d.ts +18 -0
- package/dist/shared/logger.js +32 -0
- package/dist/shared/profile.d.ts +18 -0
- package/dist/shared/profile.js +25 -0
- package/dist/shared/types/config.d.ts +42 -0
- package/dist/shared/types/config.js +1 -0
- package/dist/styles.css +1089 -0
- package/package.json +86 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function cn(...classes: (string | undefined | null | false)[]): string;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Singleton BridgeAuth instance + Svelte store adapter.
|
|
3
|
+
*
|
|
4
|
+
* This is the architectural keystone of the bridge-svelte ↔ auth-core integration.
|
|
5
|
+
* It creates a single BridgeAuth instance and wires its events to Svelte stores
|
|
6
|
+
* so that consumers can keep using `$auth.isAuthenticated`, `$profileStore.profile`, etc.
|
|
7
|
+
*/
|
|
8
|
+
import { BridgeAuth, type AppConfig, type AuthState, type BridgeAuthConfig, type Plan, type Profile, type SubscriptionStatus, type TenantUser, type TokenSet } from '@nebulr-group/bridge-auth-core';
|
|
9
|
+
import { type Readable, type Writable } from 'svelte/store';
|
|
10
|
+
export declare function initBridge(config: BridgeAuthConfig): BridgeAuth;
|
|
11
|
+
export declare function getBridgeAuth(): BridgeAuth;
|
|
12
|
+
export declare function markReady(): void;
|
|
13
|
+
export declare function waitForBridge(): Promise<void>;
|
|
14
|
+
/** Token store — readable. Use `getBridgeAuth()` methods to mutate. */
|
|
15
|
+
export declare const tokenStore: Readable<TokenSet | null>;
|
|
16
|
+
/** Whether user is authenticated */
|
|
17
|
+
export declare const isAuthenticated: Readable<boolean>;
|
|
18
|
+
/** Auth loading state */
|
|
19
|
+
export declare const isLoading: Readable<boolean>;
|
|
20
|
+
/** Last auth error */
|
|
21
|
+
export declare const authError: Readable<string | null>;
|
|
22
|
+
/** Current auth state machine state */
|
|
23
|
+
export declare const authState: Readable<AuthState>;
|
|
24
|
+
/** User profile (undefined = loading, null = no profile, Profile = loaded) */
|
|
25
|
+
export declare const profileStore: Readable<Profile | null | undefined>;
|
|
26
|
+
/** Whether user has completed onboarding */
|
|
27
|
+
export declare const isOnboarded: Readable<boolean>;
|
|
28
|
+
/** Whether user has access to multiple tenants */
|
|
29
|
+
export declare const hasMultiTenantAccess: Readable<boolean>;
|
|
30
|
+
/** Tenant users for multi-tenant selection */
|
|
31
|
+
export declare const tenantUsersStore: Readable<TenantUser[]>;
|
|
32
|
+
/** Feature flags map */
|
|
33
|
+
export declare const flagsStore: Readable<Record<string, boolean>>;
|
|
34
|
+
/** Bridge ready state */
|
|
35
|
+
export declare const bridgeReadyStore: Readable<boolean>;
|
|
36
|
+
/** App-level config (SSO providers, feature flags, etc.) — loaded anonymously on init */
|
|
37
|
+
export declare const appConfigStore: Readable<AppConfig | null>;
|
|
38
|
+
interface SubscriptionState {
|
|
39
|
+
status: SubscriptionStatus | null;
|
|
40
|
+
plans: Plan[] | null;
|
|
41
|
+
loading: boolean;
|
|
42
|
+
error: string | null;
|
|
43
|
+
}
|
|
44
|
+
/** Subscription status + plan list */
|
|
45
|
+
export declare const subscriptionStore: Readable<SubscriptionState>;
|
|
46
|
+
export declare function loadSubscription(): Promise<void>;
|
|
47
|
+
/** Lazy proxy to the BridgeAuth singleton — call methods directly: `auth.getToken()`, `auth.logout()`, etc. */
|
|
48
|
+
export declare const auth: BridgeAuth;
|
|
49
|
+
export declare const _flagsWritable: Writable<Record<string, boolean>>;
|
|
50
|
+
export declare const _profileWritable: Writable<Profile | null | undefined>;
|
|
51
|
+
export declare const _errorWritable: Writable<string | null>;
|
|
52
|
+
export {};
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Singleton BridgeAuth instance + Svelte store adapter.
|
|
3
|
+
*
|
|
4
|
+
* This is the architectural keystone of the bridge-svelte ↔ auth-core integration.
|
|
5
|
+
* It creates a single BridgeAuth instance and wires its events to Svelte stores
|
|
6
|
+
* so that consumers can keep using `$auth.isAuthenticated`, `$profileStore.profile`, etc.
|
|
7
|
+
*/
|
|
8
|
+
import { BridgeAuth } from '@nebulr-group/bridge-auth-core';
|
|
9
|
+
import { derived, get, writable } from 'svelte/store';
|
|
10
|
+
import { logger } from '../shared/logger.js';
|
|
11
|
+
// ── Singleton ──────────────────────────────────────────────────────────────────
|
|
12
|
+
let _instance = null;
|
|
13
|
+
// ── Svelte stores (writable internally, exported as readable) ──────────────────
|
|
14
|
+
const _tokens = writable(null);
|
|
15
|
+
const _appConfig = writable(null);
|
|
16
|
+
const _profile = writable(undefined);
|
|
17
|
+
const _flags = writable({});
|
|
18
|
+
const _authState = writable('unauthenticated');
|
|
19
|
+
const _isLoading = writable(true);
|
|
20
|
+
const _error = writable(null);
|
|
21
|
+
const _tenantUsers = writable([]);
|
|
22
|
+
const _isAuthenticated = derived(_tokens, ($t) => !!$t?.accessToken);
|
|
23
|
+
const _isOnboarded = derived(_profile, ($p) => $p?.onboarded ?? false);
|
|
24
|
+
const _hasMultiTenantAccess = derived(_profile, ($p) => $p?.multiTenantAccess ?? false);
|
|
25
|
+
// ── Ready gate ─────────────────────────────────────────────────────────────────
|
|
26
|
+
const _ready = writable(false);
|
|
27
|
+
let _resolveReady = null;
|
|
28
|
+
const _readyPromise = new Promise((resolve) => {
|
|
29
|
+
_resolveReady = resolve;
|
|
30
|
+
});
|
|
31
|
+
// ── Init / access ──────────────────────────────────────────────────────────────
|
|
32
|
+
export function initBridge(config) {
|
|
33
|
+
if (_instance) {
|
|
34
|
+
logger.debug('[bridge-instance] already initialized, returning existing');
|
|
35
|
+
return _instance;
|
|
36
|
+
}
|
|
37
|
+
_instance = new BridgeAuth(config);
|
|
38
|
+
// Seed stores from current auth-core state
|
|
39
|
+
const existingTokens = _instance.getTokens();
|
|
40
|
+
if (existingTokens) {
|
|
41
|
+
_tokens.set(existingTokens);
|
|
42
|
+
// Fetch profile for existing tokens
|
|
43
|
+
_instance.getProfile().then((p) => _profile.set(p ?? null)).catch(() => { });
|
|
44
|
+
}
|
|
45
|
+
_authState.set(_instance.getAuthState());
|
|
46
|
+
_isLoading.set(false);
|
|
47
|
+
// Wire auth-core events → Svelte stores
|
|
48
|
+
_instance.on('auth:login', (tokens) => {
|
|
49
|
+
_tokens.set(tokens);
|
|
50
|
+
_instance.getProfile().then((p) => _profile.set(p ?? null)).catch(() => { });
|
|
51
|
+
});
|
|
52
|
+
_instance.on('auth:logout', () => {
|
|
53
|
+
_tokens.set(null);
|
|
54
|
+
_profile.set(null);
|
|
55
|
+
_flags.set({});
|
|
56
|
+
});
|
|
57
|
+
_instance.on('auth:token-refreshed', (tokens) => {
|
|
58
|
+
_tokens.set(tokens);
|
|
59
|
+
});
|
|
60
|
+
_instance.on('auth:state-change', (state) => {
|
|
61
|
+
_authState.set(state);
|
|
62
|
+
if (state === 'tenant-selection') {
|
|
63
|
+
_tenantUsers.set(_instance.getTenantUsers());
|
|
64
|
+
}
|
|
65
|
+
else if (state === 'authenticated' || state === 'unauthenticated') {
|
|
66
|
+
_tenantUsers.set([]);
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
_instance.on('auth:profile', (profile) => {
|
|
70
|
+
_profile.set(profile);
|
|
71
|
+
});
|
|
72
|
+
_instance.on('auth:workspace-changed', (tokens) => {
|
|
73
|
+
_tokens.set(tokens);
|
|
74
|
+
_flags.set({});
|
|
75
|
+
_subscriptionWritable.set({ status: null, plans: null, loading: false, error: null });
|
|
76
|
+
_instance.getProfile().then((p) => _profile.set(p ?? null)).catch(() => { });
|
|
77
|
+
});
|
|
78
|
+
_instance.on('auth:error', (err) => {
|
|
79
|
+
_error.set(err.message);
|
|
80
|
+
});
|
|
81
|
+
// Load app config anonymously (drives SSO buttons etc.)
|
|
82
|
+
_instance.getAppConfig().then((cfg) => _appConfig.set(cfg)).catch(() => { });
|
|
83
|
+
logger.debug('[bridge-instance] initialized');
|
|
84
|
+
return _instance;
|
|
85
|
+
}
|
|
86
|
+
export function getBridgeAuth() {
|
|
87
|
+
if (!_instance) {
|
|
88
|
+
throw new Error('BridgeAuth not initialized. Call initBridge() first (via bridgeConfig.initConfig).');
|
|
89
|
+
}
|
|
90
|
+
return _instance;
|
|
91
|
+
}
|
|
92
|
+
export function markReady() {
|
|
93
|
+
if (get(_ready))
|
|
94
|
+
return;
|
|
95
|
+
_ready.set(true);
|
|
96
|
+
_resolveReady?.();
|
|
97
|
+
}
|
|
98
|
+
export function waitForBridge() {
|
|
99
|
+
return _readyPromise;
|
|
100
|
+
}
|
|
101
|
+
// ── Store exports ──────────────────────────────────────────────────────────────
|
|
102
|
+
/** Token store — readable. Use `getBridgeAuth()` methods to mutate. */
|
|
103
|
+
export const tokenStore = _tokens;
|
|
104
|
+
/** Whether user is authenticated */
|
|
105
|
+
export const isAuthenticated = _isAuthenticated;
|
|
106
|
+
/** Auth loading state */
|
|
107
|
+
export const isLoading = _isLoading;
|
|
108
|
+
/** Last auth error */
|
|
109
|
+
export const authError = _error;
|
|
110
|
+
/** Current auth state machine state */
|
|
111
|
+
export const authState = _authState;
|
|
112
|
+
/** User profile (undefined = loading, null = no profile, Profile = loaded) */
|
|
113
|
+
export const profileStore = _profile;
|
|
114
|
+
/** Whether user has completed onboarding */
|
|
115
|
+
export const isOnboarded = _isOnboarded;
|
|
116
|
+
/** Whether user has access to multiple tenants */
|
|
117
|
+
export const hasMultiTenantAccess = _hasMultiTenantAccess;
|
|
118
|
+
/** Tenant users for multi-tenant selection */
|
|
119
|
+
export const tenantUsersStore = _tenantUsers;
|
|
120
|
+
/** Feature flags map */
|
|
121
|
+
export const flagsStore = _flags;
|
|
122
|
+
/** Bridge ready state */
|
|
123
|
+
export const bridgeReadyStore = _ready;
|
|
124
|
+
/** App-level config (SSO providers, feature flags, etc.) — loaded anonymously on init */
|
|
125
|
+
export const appConfigStore = _appConfig;
|
|
126
|
+
const _subscriptionWritable = writable({
|
|
127
|
+
status: null,
|
|
128
|
+
plans: null,
|
|
129
|
+
loading: false,
|
|
130
|
+
error: null,
|
|
131
|
+
});
|
|
132
|
+
/** Subscription status + plan list */
|
|
133
|
+
export const subscriptionStore = _subscriptionWritable;
|
|
134
|
+
export async function loadSubscription() {
|
|
135
|
+
_subscriptionWritable.update((s) => ({ ...s, loading: true, error: null }));
|
|
136
|
+
try {
|
|
137
|
+
const [status, plans] = await Promise.all([
|
|
138
|
+
getBridgeAuth().getSubscriptionStatus(),
|
|
139
|
+
getBridgeAuth().getPlans(),
|
|
140
|
+
]);
|
|
141
|
+
_subscriptionWritable.set({ status, plans, loading: false, error: null });
|
|
142
|
+
}
|
|
143
|
+
catch (err) {
|
|
144
|
+
const msg = err instanceof Error ? err.message : 'Failed to load subscription';
|
|
145
|
+
_subscriptionWritable.update((s) => ({ ...s, loading: false, error: msg }));
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
// ── Convenience singleton accessor ────────────────────────────────────────────
|
|
149
|
+
/** Lazy proxy to the BridgeAuth singleton — call methods directly: `auth.getToken()`, `auth.logout()`, etc. */
|
|
150
|
+
export const auth = new Proxy({}, {
|
|
151
|
+
get(_, prop) {
|
|
152
|
+
const instance = getBridgeAuth();
|
|
153
|
+
const value = instance[prop];
|
|
154
|
+
return typeof value === 'function' ? value.bind(instance) : value;
|
|
155
|
+
},
|
|
156
|
+
});
|
|
157
|
+
// ── Internal-only store writers (for use by wrapper modules) ───────────────────
|
|
158
|
+
export const _flagsWritable = _flags;
|
|
159
|
+
export const _profileWritable = _profile;
|
|
160
|
+
export const _errorWritable = _error;
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export * from './client/BridgeBootstrap.js';
|
|
2
|
+
export * from './client/stores/config.store.js';
|
|
3
|
+
export { initBridge, getBridgeAuth, markReady, waitForBridge, auth, tokenStore, isAuthenticated, isLoading, authError, authState, isOnboarded, hasMultiTenantAccess, tenantUsersStore, profileStore, flagsStore, bridgeReadyStore, appConfigStore, subscriptionStore, loadSubscription, } from './core/bridge-instance.js';
|
|
4
|
+
export { default as BridgeBootstrap, default as BridgeProvider } from './client/BridgeBootstrap.svelte';
|
|
5
|
+
export { default as ApiTokenManagement } from './client/components/developer/ApiTokenManagement.svelte';
|
|
6
|
+
export { default as FeatureFlag } from './client/components/FeatureFlag.svelte';
|
|
7
|
+
export { default as ProfileName } from './client/components/ProfileName.svelte';
|
|
8
|
+
export { default as TeamManagementPanel } from './client/components/team/TeamManagementPanel.svelte';
|
|
9
|
+
export { default as TeamUserList } from './client/components/team/TeamUserList.svelte';
|
|
10
|
+
export { default as TeamProfileForm } from './client/components/team/TeamProfileForm.svelte';
|
|
11
|
+
export { default as TeamWorkspaceForm } from './client/components/team/TeamWorkspaceForm.svelte';
|
|
12
|
+
export { default as LoginForm } from './client/components/sdk-auth/LoginForm.svelte';
|
|
13
|
+
export { default as MfaChallenge } from './client/components/sdk-auth/MfaChallenge.svelte';
|
|
14
|
+
export { default as MfaSetup } from './client/components/sdk-auth/MfaSetup.svelte';
|
|
15
|
+
export { default as TenantSelector } from './client/components/sdk-auth/TenantSelector.svelte';
|
|
16
|
+
export { default as WorkspaceSelector } from './client/components/sdk-auth/WorkspaceSelector.svelte';
|
|
17
|
+
export { default as SsoButton } from './client/components/sdk-auth/SsoButton.svelte';
|
|
18
|
+
export { default as SignupForm } from './client/components/sdk-auth/SignupForm.svelte';
|
|
19
|
+
export { default as ForgotPassword } from './client/components/sdk-auth/ForgotPassword.svelte';
|
|
20
|
+
export { default as MagicLink } from './client/components/sdk-auth/MagicLink.svelte';
|
|
21
|
+
export { default as PasskeyLogin } from './client/components/sdk-auth/PasskeyLogin.svelte';
|
|
22
|
+
export { default as PasskeyRequestSetupLink } from './client/components/sdk-auth/PasskeyRequestSetupLink.svelte';
|
|
23
|
+
export { default as PasskeySetup } from './client/components/sdk-auth/PasskeySetup.svelte';
|
|
24
|
+
export { default as PlanSelector } from './client/components/subscription/PlanSelector.svelte';
|
|
25
|
+
export * from './shared/feature-flag.js';
|
|
26
|
+
export * from './auth/route-guard.js';
|
|
27
|
+
export * from './shared/profile.js';
|
|
28
|
+
export * from './shared/types/config.js';
|
|
29
|
+
export { logger, setLoggerDebug } from './shared/logger.js';
|
|
30
|
+
export type { AuthConfigResponse, AuthResult, AuthState, BridgeAuthConfig, BridgeAuthEventName, BridgeAuthEvents, FederationConnection, MagicLinkResult, MfaResult, PasskeyAuthOptions, PasskeyRegistrationOptions, PasskeyVerificationResult, SignupResult, SsoOptions, SsoResult, TenantUser, } from '@nebulr-group/bridge-auth-core';
|
|
31
|
+
export { BridgeAuth, BridgeAuthError, HttpError, TeamService, ApiTokenService } from '@nebulr-group/bridge-auth-core';
|
|
32
|
+
export type { ApiToken, CreateApiTokenInput, CreateApiTokenResponse, } from '@nebulr-group/bridge-auth-core';
|
|
33
|
+
export type { TeamProfile, TeamProfileUpdateInput, TeamUser, TeamUserListResult, TeamUserUpdateInput, TeamWorkspace, TeamWorkspaceUpdateInput, } from '@nebulr-group/bridge-auth-core';
|
|
34
|
+
export type { Plan, PriceOfferSdk, SubscriptionStatus, CheckoutSession, Workspace, } from '@nebulr-group/bridge-auth-core';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
// Core stores and setup
|
|
2
|
+
export * from './client/BridgeBootstrap.js';
|
|
3
|
+
export * from './client/stores/config.store.js';
|
|
4
|
+
// Bridge instance (singleton + Svelte stores)
|
|
5
|
+
export { initBridge, getBridgeAuth, markReady, waitForBridge, auth, tokenStore, isAuthenticated, isLoading, authError, authState, isOnboarded, hasMultiTenantAccess, tenantUsersStore, profileStore, flagsStore, bridgeReadyStore, appConfigStore, subscriptionStore, loadSubscription, } from './core/bridge-instance.js';
|
|
6
|
+
// Components (Svelte components must have `export default`)
|
|
7
|
+
export { default as BridgeBootstrap, default as BridgeProvider } from './client/BridgeBootstrap.svelte';
|
|
8
|
+
export { default as ApiTokenManagement } from './client/components/developer/ApiTokenManagement.svelte';
|
|
9
|
+
export { default as FeatureFlag } from './client/components/FeatureFlag.svelte';
|
|
10
|
+
export { default as ProfileName } from './client/components/ProfileName.svelte';
|
|
11
|
+
export { default as TeamManagementPanel } from './client/components/team/TeamManagementPanel.svelte';
|
|
12
|
+
export { default as TeamUserList } from './client/components/team/TeamUserList.svelte';
|
|
13
|
+
export { default as TeamProfileForm } from './client/components/team/TeamProfileForm.svelte';
|
|
14
|
+
export { default as TeamWorkspaceForm } from './client/components/team/TeamWorkspaceForm.svelte';
|
|
15
|
+
// SDK Auth Components
|
|
16
|
+
export { default as LoginForm } from './client/components/sdk-auth/LoginForm.svelte';
|
|
17
|
+
export { default as MfaChallenge } from './client/components/sdk-auth/MfaChallenge.svelte';
|
|
18
|
+
export { default as MfaSetup } from './client/components/sdk-auth/MfaSetup.svelte';
|
|
19
|
+
export { default as TenantSelector } from './client/components/sdk-auth/TenantSelector.svelte';
|
|
20
|
+
export { default as WorkspaceSelector } from './client/components/sdk-auth/WorkspaceSelector.svelte';
|
|
21
|
+
export { default as SsoButton } from './client/components/sdk-auth/SsoButton.svelte';
|
|
22
|
+
export { default as SignupForm } from './client/components/sdk-auth/SignupForm.svelte';
|
|
23
|
+
export { default as ForgotPassword } from './client/components/sdk-auth/ForgotPassword.svelte';
|
|
24
|
+
export { default as MagicLink } from './client/components/sdk-auth/MagicLink.svelte';
|
|
25
|
+
export { default as PasskeyLogin } from './client/components/sdk-auth/PasskeyLogin.svelte';
|
|
26
|
+
export { default as PasskeyRequestSetupLink } from './client/components/sdk-auth/PasskeyRequestSetupLink.svelte';
|
|
27
|
+
export { default as PasskeySetup } from './client/components/sdk-auth/PasskeySetup.svelte';
|
|
28
|
+
// Subscription components
|
|
29
|
+
export { default as PlanSelector } from './client/components/subscription/PlanSelector.svelte';
|
|
30
|
+
// Feature flags
|
|
31
|
+
export * from './shared/feature-flag.js';
|
|
32
|
+
// Auth route guards
|
|
33
|
+
export * from './auth/route-guard.js';
|
|
34
|
+
// Types
|
|
35
|
+
export * from './shared/profile.js';
|
|
36
|
+
export * from './shared/types/config.js';
|
|
37
|
+
// Logger
|
|
38
|
+
export { logger, setLoggerDebug } from './shared/logger.js';
|
|
39
|
+
export { BridgeAuth, BridgeAuthError, HttpError, TeamService, ApiTokenService } from '@nebulr-group/bridge-auth-core';
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare function loadFeatureFlags(): Promise<void>;
|
|
2
|
+
export declare function isFeatureEnabled(flag: string, forceLive?: boolean): Promise<boolean>;
|
|
3
|
+
export declare const featureFlags: {
|
|
4
|
+
flags: import("svelte/store").Writable<Record<string, boolean>>;
|
|
5
|
+
refresh: typeof loadFeatureFlags;
|
|
6
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// src/lib/shared/feature-flag.ts — thin wrapper delegating to bridge-instance
|
|
2
|
+
import { getBridgeAuth, _flagsWritable, flagsStore } from '../core/bridge-instance.js';
|
|
3
|
+
export async function loadFeatureFlags() {
|
|
4
|
+
const flags = await getBridgeAuth().loadFeatureFlags();
|
|
5
|
+
_flagsWritable.set(flags);
|
|
6
|
+
}
|
|
7
|
+
export async function isFeatureEnabled(flag, forceLive = false) {
|
|
8
|
+
return getBridgeAuth().isFeatureEnabled(flag, { forceLive });
|
|
9
|
+
}
|
|
10
|
+
export const featureFlags = {
|
|
11
|
+
flags: flagsStore,
|
|
12
|
+
refresh: loadFeatureFlags
|
|
13
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
type LogMethod = (...args: unknown[]) => void;
|
|
2
|
+
export declare function setLoggerDebug(debug: boolean): void;
|
|
3
|
+
export declare const logger: {
|
|
4
|
+
readonly debug: (...args: unknown[]) => void;
|
|
5
|
+
readonly log: (...args: unknown[]) => void;
|
|
6
|
+
readonly info: (...args: unknown[]) => void;
|
|
7
|
+
readonly warn: (...args: unknown[]) => void;
|
|
8
|
+
readonly error: (...args: unknown[]) => void;
|
|
9
|
+
readonly withPrefix: (prefix: string) => {
|
|
10
|
+
readonly debug: (...args: unknown[]) => void;
|
|
11
|
+
readonly log: (...args: unknown[]) => void;
|
|
12
|
+
readonly info: (...args: unknown[]) => void;
|
|
13
|
+
readonly warn: LogMethod;
|
|
14
|
+
readonly error: LogMethod;
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
export type Logger = typeof logger;
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
let _debug = false;
|
|
2
|
+
export function setLoggerDebug(debug) {
|
|
3
|
+
_debug = debug;
|
|
4
|
+
}
|
|
5
|
+
function createPrefixed(method, prefix) {
|
|
6
|
+
return (...args) => method(prefix, ...args);
|
|
7
|
+
}
|
|
8
|
+
export const logger = {
|
|
9
|
+
debug: (...args) => {
|
|
10
|
+
if (_debug)
|
|
11
|
+
console.log(...args);
|
|
12
|
+
},
|
|
13
|
+
log: (...args) => {
|
|
14
|
+
if (_debug)
|
|
15
|
+
console.log(...args);
|
|
16
|
+
},
|
|
17
|
+
info: (...args) => {
|
|
18
|
+
if (_debug)
|
|
19
|
+
console.info(...args);
|
|
20
|
+
},
|
|
21
|
+
warn: (...args) => console.warn(...args),
|
|
22
|
+
error: (...args) => console.error(...args),
|
|
23
|
+
withPrefix(prefix) {
|
|
24
|
+
return {
|
|
25
|
+
debug: (...args) => logger.debug(prefix, ...args),
|
|
26
|
+
log: (...args) => logger.log(prefix, ...args),
|
|
27
|
+
info: (...args) => logger.info(prefix, ...args),
|
|
28
|
+
warn: createPrefixed(console.warn, prefix),
|
|
29
|
+
error: createPrefixed(console.error, prefix)
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { _errorWritable } from '../core/bridge-instance.js';
|
|
2
|
+
export type { IDToken, Profile } from '@nebulr-group/bridge-auth-core';
|
|
3
|
+
export declare const profileStore: {
|
|
4
|
+
/** User profile (undefined = loading, null = no profile, Profile = loaded) */
|
|
5
|
+
profile: import("svelte/store").Readable<import("@nebulr-group/bridge-auth-core").Profile | null | undefined>;
|
|
6
|
+
/** Last profile error */
|
|
7
|
+
error: typeof _errorWritable;
|
|
8
|
+
/** Whether user has completed onboarding */
|
|
9
|
+
isOnboarded: import("svelte/store").Readable<boolean>;
|
|
10
|
+
/** Whether user has access to multiple tenants */
|
|
11
|
+
hasMultiTenantAccess: import("svelte/store").Readable<boolean>;
|
|
12
|
+
/** Refresh profile from auth-core */
|
|
13
|
+
updateProfile: () => Promise<void>;
|
|
14
|
+
/** Synchronous access to current profile */
|
|
15
|
+
getProfile: () => import("@nebulr-group/bridge-auth-core").Profile | null;
|
|
16
|
+
/** Clear profile */
|
|
17
|
+
clear: () => void;
|
|
18
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
// src/lib/auth/profile.ts — thin wrapper delegating to bridge-instance
|
|
2
|
+
import { get } from 'svelte/store';
|
|
3
|
+
import { getBridgeAuth, profileStore as _profileReadable, _profileWritable, _errorWritable, isOnboarded, hasMultiTenantAccess, } from '../core/bridge-instance.js';
|
|
4
|
+
export const profileStore = {
|
|
5
|
+
/** User profile (undefined = loading, null = no profile, Profile = loaded) */
|
|
6
|
+
profile: _profileReadable,
|
|
7
|
+
/** Last profile error */
|
|
8
|
+
error: _errorWritable,
|
|
9
|
+
/** Whether user has completed onboarding */
|
|
10
|
+
isOnboarded,
|
|
11
|
+
/** Whether user has access to multiple tenants */
|
|
12
|
+
hasMultiTenantAccess,
|
|
13
|
+
/** Refresh profile from auth-core */
|
|
14
|
+
updateProfile: async () => {
|
|
15
|
+
const profile = await getBridgeAuth().getProfile();
|
|
16
|
+
_profileWritable.set(profile ?? null);
|
|
17
|
+
},
|
|
18
|
+
/** Synchronous access to current profile */
|
|
19
|
+
getProfile: () => get(_profileReadable) ?? null,
|
|
20
|
+
/** Clear profile */
|
|
21
|
+
clear: () => {
|
|
22
|
+
_profileWritable.set(null);
|
|
23
|
+
_errorWritable.set(null);
|
|
24
|
+
},
|
|
25
|
+
};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
export interface BridgeConfig {
|
|
2
|
+
/**
|
|
3
|
+
* Your Bridge application ID
|
|
4
|
+
* @required
|
|
5
|
+
*/
|
|
6
|
+
appId: string;
|
|
7
|
+
/**
|
|
8
|
+
* The URL to redirect to after successful login
|
|
9
|
+
* @default The current origin + '/auth/callback'
|
|
10
|
+
*/
|
|
11
|
+
callbackUrl?: string;
|
|
12
|
+
/**
|
|
13
|
+
* Root URL of the Bridge API.
|
|
14
|
+
* @default 'https://api.thebridge.dev'
|
|
15
|
+
*/
|
|
16
|
+
apiBaseUrl?: string;
|
|
17
|
+
/**
|
|
18
|
+
* Base URL of the Bridge hosted UI (cloud-views).
|
|
19
|
+
* @default 'https://auth.thebridge.dev'
|
|
20
|
+
*/
|
|
21
|
+
hostedUrl?: string;
|
|
22
|
+
/**
|
|
23
|
+
* Route to redirect to after login
|
|
24
|
+
* @default '/'
|
|
25
|
+
*/
|
|
26
|
+
defaultRedirectRoute?: string;
|
|
27
|
+
/**
|
|
28
|
+
* Route to redirect to when authentication fails
|
|
29
|
+
* @default '/login'
|
|
30
|
+
*/
|
|
31
|
+
loginRoute?: string;
|
|
32
|
+
/**
|
|
33
|
+
* Debug mode
|
|
34
|
+
* @default false
|
|
35
|
+
*/
|
|
36
|
+
debug?: boolean;
|
|
37
|
+
}
|
|
38
|
+
export interface TokenSet {
|
|
39
|
+
accessToken: string;
|
|
40
|
+
refreshToken: string;
|
|
41
|
+
idToken: string;
|
|
42
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|