@armco/iam-client 0.1.1

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.
@@ -0,0 +1,61 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import { ReactNode } from 'react';
3
+ import { a as StuffleIAMConfig, C as CallbackResult, S as StuffleIAMClient, U as User, L as LoginOptions, b as LogoutOptions } from './client-CTKWBZ26.js';
4
+ export { A as AuthState } from './client-CTKWBZ26.js';
5
+
6
+ interface StuffleIAMContextValue {
7
+ client: StuffleIAMClient;
8
+ isAuthenticated: boolean;
9
+ isLoading: boolean;
10
+ user: User | null;
11
+ accessToken: string | null;
12
+ error: Error | null;
13
+ login: (options?: LoginOptions) => Promise<void>;
14
+ signup: (options?: Omit<LoginOptions, 'signup'>) => Promise<void>;
15
+ logout: (options?: LogoutOptions) => Promise<void>;
16
+ handleCallback: (url?: string) => Promise<CallbackResult>;
17
+ getAccessToken: () => Promise<string | null>;
18
+ }
19
+ interface StuffleIAMProviderProps extends StuffleIAMConfig {
20
+ children: ReactNode;
21
+ /** Called after successful login callback */
22
+ onLoginSuccess?: (result: CallbackResult) => void;
23
+ /** Called on login error */
24
+ onLoginError?: (error: Error) => void;
25
+ /** Auto-handle callback on mount if URL has code/error */
26
+ autoHandleCallback?: boolean;
27
+ }
28
+ declare function StuffleIAMProvider({ children, onLoginSuccess, onLoginError, autoHandleCallback, ...config }: StuffleIAMProviderProps): react_jsx_runtime.JSX.Element;
29
+ /**
30
+ * Hook to access auth state and methods
31
+ */
32
+ declare function useAuth(): StuffleIAMContextValue;
33
+ /**
34
+ * Hook to get current user
35
+ */
36
+ declare function useUser(): User | null;
37
+ /**
38
+ * Hook to check if user is authenticated
39
+ */
40
+ declare function useIsAuthenticated(): boolean;
41
+ /**
42
+ * Hook to get access token (refreshes if needed)
43
+ */
44
+ declare function useAccessToken(): () => Promise<string | null>;
45
+ /**
46
+ * Hook to check if user has specific role(s)
47
+ */
48
+ declare function useHasRole(roles: string | string[]): boolean;
49
+ /**
50
+ * Higher-order component for protected routes
51
+ */
52
+ declare function withAuth<P extends object>(WrappedComponent: React.ComponentType<P>, options?: {
53
+ /** Component to show while loading */
54
+ LoadingComponent?: React.ComponentType;
55
+ /** Component to show if not authenticated */
56
+ UnauthorizedComponent?: React.ComponentType;
57
+ /** Required roles */
58
+ roles?: string[];
59
+ }): (props: P) => react_jsx_runtime.JSX.Element | null;
60
+
61
+ export { CallbackResult, LoginOptions, LogoutOptions, StuffleIAMConfig, StuffleIAMProvider, type StuffleIAMProviderProps, User, useAccessToken, useAuth, useHasRole, useIsAuthenticated, useUser, withAuth };