@cyberia-auth/auth 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.
@@ -0,0 +1,68 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import { ReactNode } from 'react';
3
+
4
+ type AuthMode = 'register' | 'login';
5
+ type AuthUser = {
6
+ id: string;
7
+ email: string;
8
+ displayName: string;
9
+ };
10
+ type AuthResult = {
11
+ token: string;
12
+ user: AuthUser;
13
+ };
14
+ type CyberiaAuthProps = {
15
+ backendUrl?: string;
16
+ apiToken: string;
17
+ oauthRedirectUri?: string;
18
+ initialMode?: AuthMode;
19
+ hideModeSwitch?: boolean;
20
+ onAuthSuccess?: (data: AuthResult) => void;
21
+ };
22
+ declare function CyberiaAuth({ backendUrl, apiToken, oauthRedirectUri, initialMode, hideModeSwitch, onAuthSuccess, }: CyberiaAuthProps): react_jsx_runtime.JSX.Element;
23
+ type CyberiaAuthContextValue = {
24
+ isLoaded: boolean;
25
+ isSignedIn: boolean;
26
+ user: AuthUser | null;
27
+ token: string | null;
28
+ openSignIn: () => void;
29
+ openSignUp: () => void;
30
+ signOut: () => void;
31
+ setSessionFromAuth: (result: AuthResult) => void;
32
+ };
33
+ type CyberiaAuthProviderProps = {
34
+ backendUrl?: string;
35
+ apiToken: string;
36
+ oauthRedirectUri?: string;
37
+ children: ReactNode;
38
+ storageKey?: string;
39
+ };
40
+ declare function CyberiaAuthProvider({ backendUrl, apiToken, oauthRedirectUri, children, storageKey, }: CyberiaAuthProviderProps): react_jsx_runtime.JSX.Element;
41
+ declare function useCyberiaAuth(): CyberiaAuthContextValue;
42
+ declare function Show({ when, children }: {
43
+ when: 'signed-in' | 'signed-out';
44
+ children: ReactNode;
45
+ }): react_jsx_runtime.JSX.Element | null;
46
+ declare function SignedIn({ children }: {
47
+ children: ReactNode;
48
+ }): react_jsx_runtime.JSX.Element | null;
49
+ declare function SignedOut({ children }: {
50
+ children: ReactNode;
51
+ }): react_jsx_runtime.JSX.Element | null;
52
+ declare function SignInButton({ children }: {
53
+ children?: ReactNode;
54
+ }): react_jsx_runtime.JSX.Element;
55
+ declare function SignUpButton({ children }: {
56
+ children?: ReactNode;
57
+ }): react_jsx_runtime.JSX.Element;
58
+ declare function SignOutButton({ children }: {
59
+ children?: ReactNode;
60
+ }): react_jsx_runtime.JSX.Element;
61
+ declare function UserButton(): react_jsx_runtime.JSX.Element;
62
+ declare function Protect({ children, fallback, }: {
63
+ children: ReactNode;
64
+ fallback?: ReactNode;
65
+ }): react_jsx_runtime.JSX.Element | null;
66
+ declare const cyberiaAuth: typeof CyberiaAuth;
67
+
68
+ export { type AuthResult, type AuthUser, CyberiaAuth, type CyberiaAuthProps, CyberiaAuthProvider, Protect, Show, SignInButton, SignOutButton, SignUpButton, SignedIn, SignedOut, UserButton, cyberiaAuth, CyberiaAuth as default, useCyberiaAuth };
@@ -0,0 +1,68 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import { ReactNode } from 'react';
3
+
4
+ type AuthMode = 'register' | 'login';
5
+ type AuthUser = {
6
+ id: string;
7
+ email: string;
8
+ displayName: string;
9
+ };
10
+ type AuthResult = {
11
+ token: string;
12
+ user: AuthUser;
13
+ };
14
+ type CyberiaAuthProps = {
15
+ backendUrl?: string;
16
+ apiToken: string;
17
+ oauthRedirectUri?: string;
18
+ initialMode?: AuthMode;
19
+ hideModeSwitch?: boolean;
20
+ onAuthSuccess?: (data: AuthResult) => void;
21
+ };
22
+ declare function CyberiaAuth({ backendUrl, apiToken, oauthRedirectUri, initialMode, hideModeSwitch, onAuthSuccess, }: CyberiaAuthProps): react_jsx_runtime.JSX.Element;
23
+ type CyberiaAuthContextValue = {
24
+ isLoaded: boolean;
25
+ isSignedIn: boolean;
26
+ user: AuthUser | null;
27
+ token: string | null;
28
+ openSignIn: () => void;
29
+ openSignUp: () => void;
30
+ signOut: () => void;
31
+ setSessionFromAuth: (result: AuthResult) => void;
32
+ };
33
+ type CyberiaAuthProviderProps = {
34
+ backendUrl?: string;
35
+ apiToken: string;
36
+ oauthRedirectUri?: string;
37
+ children: ReactNode;
38
+ storageKey?: string;
39
+ };
40
+ declare function CyberiaAuthProvider({ backendUrl, apiToken, oauthRedirectUri, children, storageKey, }: CyberiaAuthProviderProps): react_jsx_runtime.JSX.Element;
41
+ declare function useCyberiaAuth(): CyberiaAuthContextValue;
42
+ declare function Show({ when, children }: {
43
+ when: 'signed-in' | 'signed-out';
44
+ children: ReactNode;
45
+ }): react_jsx_runtime.JSX.Element | null;
46
+ declare function SignedIn({ children }: {
47
+ children: ReactNode;
48
+ }): react_jsx_runtime.JSX.Element | null;
49
+ declare function SignedOut({ children }: {
50
+ children: ReactNode;
51
+ }): react_jsx_runtime.JSX.Element | null;
52
+ declare function SignInButton({ children }: {
53
+ children?: ReactNode;
54
+ }): react_jsx_runtime.JSX.Element;
55
+ declare function SignUpButton({ children }: {
56
+ children?: ReactNode;
57
+ }): react_jsx_runtime.JSX.Element;
58
+ declare function SignOutButton({ children }: {
59
+ children?: ReactNode;
60
+ }): react_jsx_runtime.JSX.Element;
61
+ declare function UserButton(): react_jsx_runtime.JSX.Element;
62
+ declare function Protect({ children, fallback, }: {
63
+ children: ReactNode;
64
+ fallback?: ReactNode;
65
+ }): react_jsx_runtime.JSX.Element | null;
66
+ declare const cyberiaAuth: typeof CyberiaAuth;
67
+
68
+ export { type AuthResult, type AuthUser, CyberiaAuth, type CyberiaAuthProps, CyberiaAuthProvider, Protect, Show, SignInButton, SignOutButton, SignUpButton, SignedIn, SignedOut, UserButton, cyberiaAuth, CyberiaAuth as default, useCyberiaAuth };