@hono/auth-js 1.0.11 → 1.0.13
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/README.md +42 -67
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +27 -49
- package/dist/index.mjs +28 -50
- package/dist/react.d.mts +42 -39
- package/dist/react.d.ts +42 -39
- package/dist/react.js +235 -192
- package/dist/react.mjs +234 -192
- package/package.json +1 -1
package/dist/react.d.ts
CHANGED
|
@@ -1,14 +1,18 @@
|
|
|
1
1
|
import { BuiltInProviderType, ProviderType, RedirectableProviderType } from '@auth/core/providers';
|
|
2
2
|
import { Session } from '@auth/core/types';
|
|
3
|
-
import * as React from 'react';
|
|
3
|
+
import * as React$1 from 'react';
|
|
4
4
|
|
|
5
|
+
interface GetSessionParams {
|
|
6
|
+
event?: 'storage' | 'timer' | 'hidden' | string;
|
|
7
|
+
triggerEvent?: boolean;
|
|
8
|
+
}
|
|
5
9
|
interface AuthClientConfig {
|
|
6
10
|
baseUrl: string;
|
|
7
11
|
basePath: string;
|
|
8
|
-
credentials
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
+
credentials: RequestCredentials;
|
|
13
|
+
lastSync: number;
|
|
14
|
+
session: Session | null;
|
|
15
|
+
fetchSession: (params?: GetSessionParams) => Promise<void>;
|
|
12
16
|
}
|
|
13
17
|
interface UseSessionOptions<R extends boolean> {
|
|
14
18
|
required: R;
|
|
@@ -23,13 +27,7 @@ interface ClientSafeProvider {
|
|
|
23
27
|
callbackUrl: string;
|
|
24
28
|
}
|
|
25
29
|
interface SignInOptions extends Record<string, unknown> {
|
|
26
|
-
/**
|
|
27
|
-
* Specify to which URL the user will be redirected after signing in. Defaults to the page URL the sign-in is initiated from.
|
|
28
|
-
*
|
|
29
|
-
* [Documentation](https://next-auth.js.org/getting-started/client#specifying-a-callbackurl)
|
|
30
|
-
*/
|
|
31
30
|
callbackUrl?: string;
|
|
32
|
-
/** [Documentation](https://next-auth.js.org/getting-started/client#using-the-redirect-false-option) */
|
|
33
31
|
redirect?: boolean;
|
|
34
32
|
}
|
|
35
33
|
interface SignInResponse {
|
|
@@ -43,29 +41,16 @@ interface SignOutResponse {
|
|
|
43
41
|
url: string;
|
|
44
42
|
}
|
|
45
43
|
interface SignOutParams<R extends boolean = true> {
|
|
46
|
-
/** [Documentation](https://next-auth.js.org/getting-started/client#specifying-a-callbackurl-1) */
|
|
47
44
|
callbackUrl?: string;
|
|
48
|
-
/** [Documentation](https://next-auth.js.org/getting-started/client#using-the-redirect-false-option-1 */
|
|
49
45
|
redirect?: R;
|
|
50
46
|
}
|
|
51
47
|
interface SessionProviderProps {
|
|
52
48
|
children: React.ReactNode;
|
|
53
49
|
session?: Session | null;
|
|
54
|
-
baseUrl?: string;
|
|
55
|
-
basePath?: string;
|
|
56
50
|
refetchInterval?: number;
|
|
57
51
|
refetchOnWindowFocus?: boolean;
|
|
58
52
|
refetchWhenOffline?: false;
|
|
59
53
|
}
|
|
60
|
-
|
|
61
|
-
declare class AuthConfigManager {
|
|
62
|
-
private static instance;
|
|
63
|
-
_config: AuthClientConfig;
|
|
64
|
-
static getInstance(): AuthConfigManager;
|
|
65
|
-
setConfig(userConfig: Partial<AuthClientConfig>): void;
|
|
66
|
-
getConfig(): AuthClientConfig;
|
|
67
|
-
}
|
|
68
|
-
declare const authConfigManager: AuthConfigManager;
|
|
69
54
|
type UpdateSession = (data?: any) => Promise<Session | null>;
|
|
70
55
|
type SessionContextValue<R extends boolean = false> = R extends true ? {
|
|
71
56
|
update: UpdateSession;
|
|
@@ -84,31 +69,49 @@ type SessionContextValue<R extends boolean = false> = R extends true ? {
|
|
|
84
69
|
data: null;
|
|
85
70
|
status: 'unauthenticated' | 'loading';
|
|
86
71
|
};
|
|
87
|
-
|
|
72
|
+
type WindowProps = {
|
|
73
|
+
url: string;
|
|
74
|
+
title: string;
|
|
75
|
+
width: number;
|
|
76
|
+
height: number;
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
declare class AuthConfigManager {
|
|
80
|
+
private static instance;
|
|
81
|
+
private config;
|
|
82
|
+
private constructor();
|
|
83
|
+
private createDefaultConfig;
|
|
84
|
+
static getInstance(): AuthConfigManager;
|
|
85
|
+
setConfig(userConfig: Partial<AuthClientConfig>): void;
|
|
86
|
+
getConfig(): AuthClientConfig;
|
|
87
|
+
initializeConfig(hasInitialSession: boolean): void;
|
|
88
|
+
}
|
|
89
|
+
declare const authConfigManager: AuthConfigManager;
|
|
90
|
+
declare const SessionContext: React$1.Context<{
|
|
88
91
|
update: UpdateSession;
|
|
89
92
|
data: Session;
|
|
90
|
-
status:
|
|
93
|
+
status: "authenticated";
|
|
91
94
|
} | {
|
|
92
95
|
update: UpdateSession;
|
|
93
96
|
data: null;
|
|
94
|
-
status:
|
|
97
|
+
status: "loading" | "unauthenticated";
|
|
95
98
|
} | undefined>;
|
|
96
|
-
declare function useSession<R extends boolean>(options?: UseSessionOptions<R>): SessionContextValue<R>;
|
|
97
|
-
interface GetSessionParams {
|
|
98
|
-
event?: 'storage' | 'timer' | 'hidden' | string;
|
|
99
|
-
triggerEvent?: boolean;
|
|
100
|
-
broadcast?: boolean;
|
|
101
|
-
}
|
|
102
99
|
declare function getSession(params?: GetSessionParams): Promise<Session | null>;
|
|
103
100
|
declare function getCsrfToken(): Promise<string>;
|
|
101
|
+
declare function SessionProvider(props: SessionProviderProps): React$1.JSX.Element;
|
|
102
|
+
declare function useSession<R extends boolean>(options?: UseSessionOptions<R>): SessionContextValue<R>;
|
|
104
103
|
type ProvidersType = Record<LiteralUnion<BuiltInProviderType>, ClientSafeProvider>;
|
|
105
104
|
declare function getProviders(): Promise<ProvidersType | null>;
|
|
106
105
|
declare function signIn<P extends RedirectableProviderType | undefined = undefined>(provider?: LiteralUnion<P extends RedirectableProviderType ? P | BuiltInProviderType : BuiltInProviderType>, options?: SignInOptions, authorizationParams?: SignInAuthorizationParams): Promise<P extends RedirectableProviderType ? SignInResponse | undefined : undefined>;
|
|
107
|
-
/**
|
|
108
|
-
* Initiate a signout, by destroying the current session.
|
|
109
|
-
* Handles CSRF protection.
|
|
110
|
-
*/
|
|
111
106
|
declare function signOut<R extends boolean = true>(options?: SignOutParams<R>): Promise<R extends true ? undefined : SignOutResponse>;
|
|
112
|
-
|
|
107
|
+
interface PopupLoginOptions extends Partial<Omit<WindowProps, 'url'>> {
|
|
108
|
+
onSuccess?: () => void;
|
|
109
|
+
callbackUrl?: string;
|
|
110
|
+
}
|
|
111
|
+
declare const useOauthPopupLogin: (provider: Parameters<typeof signIn>[0], options?: PopupLoginOptions) => {
|
|
112
|
+
status: "loading" | "success" | "errored";
|
|
113
|
+
error?: string | undefined;
|
|
114
|
+
popUpSignin: () => Promise<void>;
|
|
115
|
+
};
|
|
113
116
|
|
|
114
|
-
export {
|
|
117
|
+
export { SessionContext, SessionProvider, authConfigManager, getCsrfToken, getProviders, getSession, signIn, signOut, useOauthPopupLogin, useSession };
|