@niledatabase/react 5.0.0-alpha.1 → 5.0.0-alpha.2
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/index.d.mts +28 -227
- package/dist/index.d.ts +28 -227
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/dist/styles.css +1 -1
- package/package.json +7 -7
package/dist/index.d.mts
CHANGED
|
@@ -2,116 +2,12 @@ import * as React$1 from 'react';
|
|
|
2
2
|
import React__default from 'react';
|
|
3
3
|
import * as _tanstack_react_query from '@tanstack/react-query';
|
|
4
4
|
import { QueryClient } from '@tanstack/react-query';
|
|
5
|
-
import
|
|
5
|
+
import * as _niledatabase_client from '@niledatabase/client';
|
|
6
|
+
import { SignInOptions, Authorizer, PartialAuthorizer, BuiltInProviderType, NileSession, NonErrorSession } from '@niledatabase/client';
|
|
7
|
+
export { Authorizer, auth, getCsrfToken, getProviders, getSession, signIn, signOut } from '@niledatabase/client';
|
|
6
8
|
import * as class_variance_authority_dist_types from 'class-variance-authority/dist/types';
|
|
7
9
|
import { VariantProps } from 'class-variance-authority';
|
|
8
10
|
|
|
9
|
-
interface SignInResponse$1 {
|
|
10
|
-
error: string | null;
|
|
11
|
-
status: number;
|
|
12
|
-
ok: boolean;
|
|
13
|
-
url: string | null;
|
|
14
|
-
}
|
|
15
|
-
type LiteralUnion<T extends U, U = string> = T | (U & Record<never, never>);
|
|
16
|
-
interface SignInOptions extends Record<string, unknown> {
|
|
17
|
-
/**
|
|
18
|
-
* Specify to which URL the user will be redirected after signing in. Defaults to the page URL the sign-in is initiated from.
|
|
19
|
-
*
|
|
20
|
-
* [Documentation](https://next-auth.js.org/getting-started/client#specifying-a-callbackurl)
|
|
21
|
-
*/
|
|
22
|
-
callbackUrl?: string;
|
|
23
|
-
/** [Documentation](https://next-auth.js.org/getting-started/client#using-the-redirect-false-option) */
|
|
24
|
-
redirect?: boolean;
|
|
25
|
-
}
|
|
26
|
-
type SignInAuthorizationParams = string | string[][] | Record<string, string> | URLSearchParams;
|
|
27
|
-
type ProviderType = 'oauth' | 'email' | 'credentials';
|
|
28
|
-
interface ClientSafeProvider {
|
|
29
|
-
id: LiteralUnion<BuiltInProviderType>;
|
|
30
|
-
name: string;
|
|
31
|
-
type: ProviderType;
|
|
32
|
-
signinUrl: string;
|
|
33
|
-
callbackUrl: string;
|
|
34
|
-
}
|
|
35
|
-
type RedirectableProviderType = 'email' | 'credentials';
|
|
36
|
-
type OAuthProviderType = 'linkedin' | 'hubspot' | 'google' | 'azure-ad' | 'slack' | 'github' | 'twitter' | 'discord';
|
|
37
|
-
type BuiltInProviderType = RedirectableProviderType | OAuthProviderType;
|
|
38
|
-
type JWT = {
|
|
39
|
-
email: string;
|
|
40
|
-
sub: string;
|
|
41
|
-
id: string;
|
|
42
|
-
iat: number;
|
|
43
|
-
exp: number;
|
|
44
|
-
jti: string;
|
|
45
|
-
loading: boolean;
|
|
46
|
-
};
|
|
47
|
-
type ActiveSession = {
|
|
48
|
-
loading: boolean;
|
|
49
|
-
id: string;
|
|
50
|
-
email: string;
|
|
51
|
-
expires: string;
|
|
52
|
-
user?: {
|
|
53
|
-
id: string;
|
|
54
|
-
name: string;
|
|
55
|
-
image: string;
|
|
56
|
-
email: string;
|
|
57
|
-
emailVerified: void | Date;
|
|
58
|
-
};
|
|
59
|
-
};
|
|
60
|
-
type NonErrorSession = JWT | ActiveSession | null | undefined;
|
|
61
|
-
type NileSession = Response | NonErrorSession;
|
|
62
|
-
type AuthState = {
|
|
63
|
-
basePath: string;
|
|
64
|
-
baseUrl: string;
|
|
65
|
-
lastSync: number;
|
|
66
|
-
getSession: (...args: any[]) => void;
|
|
67
|
-
session: NonErrorSession | undefined | null;
|
|
68
|
-
loading: boolean;
|
|
69
|
-
};
|
|
70
|
-
type ListenerParams = {
|
|
71
|
-
key: ListenerKeys;
|
|
72
|
-
next: any;
|
|
73
|
-
prev: any;
|
|
74
|
-
};
|
|
75
|
-
type Listener = (callback: ListenerParams) => void;
|
|
76
|
-
type ListenerKeys = 'basePath' | 'baseUrl' | 'lastSync' | 'getSession' | 'session' | 'loading';
|
|
77
|
-
type AuthConfig = Config & {
|
|
78
|
-
listenerKeys?: Array<ListenerKeys>;
|
|
79
|
-
};
|
|
80
|
-
type Config = {
|
|
81
|
-
basePath?: string;
|
|
82
|
-
baseUrl?: string;
|
|
83
|
-
init?: RequestInit;
|
|
84
|
-
};
|
|
85
|
-
type PartialAuthorizer = null | {
|
|
86
|
-
state?: {
|
|
87
|
-
baseUrl?: string;
|
|
88
|
-
basePath?: string;
|
|
89
|
-
session?: {
|
|
90
|
-
user?: {
|
|
91
|
-
email?: string | undefined;
|
|
92
|
-
};
|
|
93
|
-
};
|
|
94
|
-
};
|
|
95
|
-
requestInit?: RequestInit | undefined;
|
|
96
|
-
};
|
|
97
|
-
interface CtxOrReq {
|
|
98
|
-
req?: Partial<IncomingMessage> & {
|
|
99
|
-
body?: any;
|
|
100
|
-
};
|
|
101
|
-
ctx?: {
|
|
102
|
-
req: Partial<IncomingMessage> & {
|
|
103
|
-
body?: any;
|
|
104
|
-
};
|
|
105
|
-
};
|
|
106
|
-
}
|
|
107
|
-
interface SignOutParams<R extends boolean = true> {
|
|
108
|
-
callbackUrl?: string;
|
|
109
|
-
redirect?: R;
|
|
110
|
-
}
|
|
111
|
-
interface SignOutResponse {
|
|
112
|
-
url: string;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
11
|
type EmailSignInInfo = SignInOptions;
|
|
116
12
|
type SignInSuccess = (response: Response) => void;
|
|
117
13
|
type AllowedAny$3 = any;
|
|
@@ -137,103 +33,6 @@ interface ButtonProps extends React$1.ButtonHTMLAttributes<HTMLButtonElement>, V
|
|
|
137
33
|
loading?: boolean;
|
|
138
34
|
}
|
|
139
35
|
|
|
140
|
-
type WarningCode = 'NEXTAUTH_URL' | 'NO_SECRET' | 'TWITTER_OAUTH_2_BETA' | 'DEBUG_ENABLED';
|
|
141
|
-
/**
|
|
142
|
-
* Override any of the methods, and the rest will use the default logger.
|
|
143
|
-
*
|
|
144
|
-
* [Documentation](https://next-auth.js.org/configuration/options#logger)
|
|
145
|
-
*/
|
|
146
|
-
interface LoggerInstance extends Record<string, (...args: any) => any> {
|
|
147
|
-
warn: (code: WarningCode) => void;
|
|
148
|
-
error: (code: string,
|
|
149
|
-
/**
|
|
150
|
-
* Either an instance of (JSON serializable) Error
|
|
151
|
-
* or an object that contains some debug information.
|
|
152
|
-
* (Error is still available through `metadata.error`)
|
|
153
|
-
*/
|
|
154
|
-
metadata: Error | {
|
|
155
|
-
error: Error;
|
|
156
|
-
[key: string]: unknown;
|
|
157
|
-
}) => void;
|
|
158
|
-
debug: (code: string, metadata: unknown) => void;
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
type GetSessionParams = CtxOrReq & {
|
|
162
|
-
event?: 'storage' | 'timer' | 'hidden' | string;
|
|
163
|
-
triggerEvent?: boolean;
|
|
164
|
-
broadcast?: boolean;
|
|
165
|
-
baseUrl?: string;
|
|
166
|
-
init?: RequestInit;
|
|
167
|
-
};
|
|
168
|
-
declare enum State {
|
|
169
|
-
SESSION = "getSession"
|
|
170
|
-
}
|
|
171
|
-
declare class Authorizer {
|
|
172
|
-
state: AuthState;
|
|
173
|
-
logger: LoggerInstance;
|
|
174
|
-
requestInit?: RequestInit;
|
|
175
|
-
addListener: (cb: Listener) => void;
|
|
176
|
-
removeListener: (cb: Listener) => void;
|
|
177
|
-
status: null | State;
|
|
178
|
-
constructor(config?: AuthConfig);
|
|
179
|
-
sync(event?: 'storage' | 'timer' | 'hidden' | 'poll' | 'visibilitychange'): Promise<void>;
|
|
180
|
-
set baseUrl(val: string);
|
|
181
|
-
get baseUrl(): string;
|
|
182
|
-
configure(config?: Config): this;
|
|
183
|
-
sanitize(): PartialAuthorizer;
|
|
184
|
-
initialize(params?: {
|
|
185
|
-
baseUrl?: string;
|
|
186
|
-
session?: NonErrorSession | null | undefined;
|
|
187
|
-
event?: 'storage' | 'timer' | 'hidden' | 'poll' | 'visibilitychange';
|
|
188
|
-
}): Promise<void>;
|
|
189
|
-
get apiBaseUrl(): string;
|
|
190
|
-
fetchData<T = Record<string, string>>(url: string, init?: RequestInit): Promise<T | undefined>;
|
|
191
|
-
fetchFormData<T = {
|
|
192
|
-
url: string;
|
|
193
|
-
}>(url: string, init: RequestInit): Promise<{
|
|
194
|
-
data: T;
|
|
195
|
-
status: number;
|
|
196
|
-
ok: boolean;
|
|
197
|
-
url: string;
|
|
198
|
-
} | undefined>;
|
|
199
|
-
getProviders(): Promise<Record<LiteralUnion<BuiltInProviderType>, ClientSafeProvider> | undefined>;
|
|
200
|
-
getCsrfToken(): Promise<string | undefined>;
|
|
201
|
-
getSession(params?: GetSessionParams): Promise<NonErrorSession>;
|
|
202
|
-
refreshSession(): Promise<NonErrorSession>;
|
|
203
|
-
signOut<R extends boolean = true>(options?: SignOutParams<R> & {
|
|
204
|
-
baseUrl?: string;
|
|
205
|
-
auth?: Authorizer | PartialAuthorizer;
|
|
206
|
-
fetchUrl?: string;
|
|
207
|
-
basePath?: string;
|
|
208
|
-
}): Promise<R extends true ? undefined : SignOutResponse>;
|
|
209
|
-
signIn<P extends RedirectableProviderType | undefined = undefined>(provider?: LiteralUnion<P extends RedirectableProviderType ? P | BuiltInProviderType : BuiltInProviderType>, options?: SignInOptions & {
|
|
210
|
-
baseUrl?: string;
|
|
211
|
-
init?: ResponseInit;
|
|
212
|
-
fetchUrl?: string;
|
|
213
|
-
auth?: Authorizer | PartialAuthorizer;
|
|
214
|
-
}, authorizationParams?: SignInAuthorizationParams): Promise<P extends RedirectableProviderType ? SignInResponse$1 | undefined : undefined>;
|
|
215
|
-
signUp(options: {
|
|
216
|
-
baseUrl?: string;
|
|
217
|
-
init?: ResponseInit;
|
|
218
|
-
fetchUrl?: string;
|
|
219
|
-
newTenantName?: string;
|
|
220
|
-
createTenant?: string | boolean;
|
|
221
|
-
email: string;
|
|
222
|
-
password: string;
|
|
223
|
-
auth?: Authorizer | PartialAuthorizer;
|
|
224
|
-
tenantId?: string;
|
|
225
|
-
callbackUrl?: string;
|
|
226
|
-
redirect?: boolean;
|
|
227
|
-
}): Promise<any>;
|
|
228
|
-
}
|
|
229
|
-
declare const authorizer: Authorizer;
|
|
230
|
-
declare const auth: Authorizer;
|
|
231
|
-
declare const getSession: (params?: GetSessionParams) => Promise<NonErrorSession>;
|
|
232
|
-
declare const getCsrfToken: () => Promise<string | undefined>;
|
|
233
|
-
declare const getProviders: () => Promise<Record<LiteralUnion<BuiltInProviderType>, ClientSafeProvider> | undefined>;
|
|
234
|
-
declare const signOut: typeof authorizer.signOut;
|
|
235
|
-
declare const signIn: typeof authorizer.signIn;
|
|
236
|
-
|
|
237
36
|
interface SignInResponse {
|
|
238
37
|
error: string | null;
|
|
239
38
|
status: number;
|
|
@@ -278,7 +77,7 @@ declare const EmailSignInButton: {
|
|
|
278
77
|
displayName: string;
|
|
279
78
|
};
|
|
280
79
|
|
|
281
|
-
declare function useEmailSignIn(params?: Props$5): _tanstack_react_query.UseMutateFunction<Response, Error, SignInOptions, unknown>;
|
|
80
|
+
declare function useEmailSignIn(params?: Props$5): _tanstack_react_query.UseMutateFunction<Response, Error, _niledatabase_client.SignInOptions, unknown>;
|
|
282
81
|
|
|
283
82
|
/**
|
|
284
83
|
* A component for a Google login button, according to their design language.
|
|
@@ -287,46 +86,42 @@ declare function useEmailSignIn(params?: Props$5): _tanstack_react_query.UseMuta
|
|
|
287
86
|
* @returns a JSX.Element to render
|
|
288
87
|
*/
|
|
289
88
|
declare const GoogleSSOButton: {
|
|
290
|
-
({ callbackUrl, className, variant, size, buttonText, asChild, init, auth, fetchUrl, baseUrl, ...props }: ButtonProps & SSOButtonProps): React__default.JSX.Element;
|
|
89
|
+
({ callbackUrl, className, variant, size, buttonText, asChild, init, auth, fetchUrl, baseUrl, onClick, ...props }: ButtonProps & SSOButtonProps): React__default.JSX.Element;
|
|
291
90
|
displayName: string;
|
|
292
91
|
};
|
|
293
92
|
|
|
294
93
|
declare const AzureSignInButton: {
|
|
295
|
-
({ callbackUrl, className, buttonText, variant, size, init, asChild, auth, fetchUrl, baseUrl, ...props }: ButtonProps & SSOButtonProps): React__default.JSX.Element;
|
|
94
|
+
({ callbackUrl, className, buttonText, variant, size, init, asChild, auth, fetchUrl, baseUrl, onClick, ...props }: ButtonProps & SSOButtonProps): React__default.JSX.Element;
|
|
296
95
|
displayName: string;
|
|
297
96
|
};
|
|
298
97
|
|
|
299
98
|
declare const DiscordSignInButton: {
|
|
300
|
-
({ callbackUrl, className, buttonText, variant, size, asChild, init, auth, fetchUrl, baseUrl, ...props }: ButtonProps & SSOButtonProps): React__default.JSX.Element;
|
|
99
|
+
({ callbackUrl, className, buttonText, variant, size, asChild, init, auth, fetchUrl, baseUrl, onClick, ...props }: ButtonProps & SSOButtonProps): React__default.JSX.Element;
|
|
301
100
|
displayName: string;
|
|
302
101
|
};
|
|
303
102
|
|
|
304
103
|
declare const GitHubSignInButton: {
|
|
305
|
-
({ callbackUrl, className, buttonText, variant, size, init, asChild, auth, fetchUrl, baseUrl, ...props }: ButtonProps & SSOButtonProps): React__default.JSX.Element;
|
|
104
|
+
({ callbackUrl, className, buttonText, variant, size, init, asChild, auth, fetchUrl, baseUrl, onClick, ...props }: ButtonProps & SSOButtonProps): React__default.JSX.Element;
|
|
306
105
|
displayName: string;
|
|
307
106
|
};
|
|
308
107
|
|
|
309
108
|
declare const HubSpotSignInButton: {
|
|
310
|
-
({ callbackUrl, className, buttonText, variant, size, init, asChild, auth, fetchUrl, baseUrl, ...props }: ButtonProps & SSOButtonProps): React__default.JSX.Element;
|
|
109
|
+
({ callbackUrl, className, buttonText, variant, size, init, asChild, auth, fetchUrl, baseUrl, onClick, ...props }: ButtonProps & SSOButtonProps): React__default.JSX.Element;
|
|
311
110
|
displayName: string;
|
|
312
111
|
};
|
|
313
112
|
|
|
314
113
|
declare const LinkedInSignInButton: {
|
|
315
|
-
({ callbackUrl, className, buttonText, variant, size, asChild, init, auth, fetchUrl, baseUrl, ...props }: ButtonProps & SSOButtonProps): React__default.JSX.Element;
|
|
114
|
+
({ callbackUrl, className, buttonText, variant, size, asChild, init, auth, fetchUrl, baseUrl, onClick, ...props }: ButtonProps & SSOButtonProps): React__default.JSX.Element;
|
|
316
115
|
displayName: string;
|
|
317
116
|
};
|
|
318
117
|
|
|
319
118
|
declare const SlackSignInButton: {
|
|
320
|
-
({ callbackUrl, className, buttonText, variant, size, init, asChild, ...props }: ButtonProps &
|
|
321
|
-
callbackUrl?: string;
|
|
322
|
-
buttonText?: string;
|
|
323
|
-
init?: RequestInit;
|
|
324
|
-
}): React__default.JSX.Element;
|
|
119
|
+
({ callbackUrl, className, buttonText, variant, size, init, onClick, asChild, ...props }: ButtonProps & SSOButtonProps): React__default.JSX.Element;
|
|
325
120
|
displayName: string;
|
|
326
121
|
};
|
|
327
122
|
|
|
328
123
|
declare const XSignInButton: {
|
|
329
|
-
({ callbackUrl, className, buttonText, variant, size, init, asChild, auth, fetchUrl, baseUrl, ...props }: ButtonProps & SSOButtonProps): React__default.JSX.Element;
|
|
124
|
+
({ callbackUrl, className, buttonText, variant, size, init, onClick, asChild, auth, fetchUrl, baseUrl, ...props }: ButtonProps & SSOButtonProps): React__default.JSX.Element;
|
|
330
125
|
displayName: string;
|
|
331
126
|
};
|
|
332
127
|
|
|
@@ -370,8 +165,9 @@ declare function useSignUp<T extends SignUpInfo>(params: Props$4, client?: Query
|
|
|
370
165
|
|
|
371
166
|
type AllowedAny$1 = any;
|
|
372
167
|
type LoginInfo = {
|
|
373
|
-
|
|
374
|
-
|
|
168
|
+
provider: BuiltInProviderType;
|
|
169
|
+
email?: string;
|
|
170
|
+
password?: string;
|
|
375
171
|
};
|
|
376
172
|
type LoginSuccess = (response: AllowedAny$1, formValues: LoginInfo, ...args: AllowedAny$1) => void;
|
|
377
173
|
type Props$3 = ComponentFetchProps & {
|
|
@@ -379,6 +175,7 @@ type Props$3 = ComponentFetchProps & {
|
|
|
379
175
|
onSuccess?: LoginSuccess;
|
|
380
176
|
onError?: (error: Error, data: AllowedAny$1) => void;
|
|
381
177
|
callbackUrl?: string;
|
|
178
|
+
resetUrl?: string;
|
|
382
179
|
client?: QueryClient;
|
|
383
180
|
className?: string;
|
|
384
181
|
baseUrl?: string;
|
|
@@ -388,7 +185,7 @@ type Props$3 = ComponentFetchProps & {
|
|
|
388
185
|
|
|
389
186
|
declare function SigningIn({ className, ...props }: Props$3): React__default.JSX.Element;
|
|
390
187
|
|
|
391
|
-
declare function useSignIn(params?: Props$3): _tanstack_react_query.UseMutateFunction<SignInResponse
|
|
188
|
+
declare function useSignIn(params?: Props$3): _tanstack_react_query.UseMutateFunction<_niledatabase_client.SignInResponse | undefined, Error, LoginInfo, any>;
|
|
392
189
|
|
|
393
190
|
type Props$2 = ButtonProps & ComponentFetchProps & {
|
|
394
191
|
redirect?: boolean;
|
|
@@ -543,18 +340,20 @@ type Props$1 = HookProps & {
|
|
|
543
340
|
declare function UserInfo(props: Props$1): React__default.JSX.Element;
|
|
544
341
|
|
|
545
342
|
type AllowedAny = any;
|
|
546
|
-
type Params = PrefetchParams & {
|
|
343
|
+
type Params = ComponentFetchProps & PrefetchParams & {
|
|
547
344
|
beforeMutate?: (data: AllowedAny) => AllowedAny;
|
|
548
|
-
onSuccess?: (res: Response) => void;
|
|
345
|
+
onSuccess?: (res: Response | undefined) => void;
|
|
549
346
|
onError?: (error: Error, data: AllowedAny) => void;
|
|
550
347
|
callbackUrl?: string;
|
|
551
348
|
basePath?: string;
|
|
349
|
+
redirect?: boolean;
|
|
552
350
|
};
|
|
553
351
|
type MutateFnParams = {
|
|
554
|
-
email
|
|
352
|
+
email: string;
|
|
555
353
|
password?: string;
|
|
556
354
|
};
|
|
557
355
|
type Props = Params & {
|
|
356
|
+
className?: string;
|
|
558
357
|
defaultValues?: MutateFnParams & {
|
|
559
358
|
confirmPassword?: string;
|
|
560
359
|
};
|
|
@@ -562,11 +361,13 @@ type Props = Params & {
|
|
|
562
361
|
|
|
563
362
|
declare function ResetPasswordForm$1(props: Props): React__default.JSX.Element;
|
|
564
363
|
|
|
565
|
-
declare function ResetPasswordForm(params:
|
|
364
|
+
declare function ResetPasswordForm(params: Props): React__default.JSX.Element;
|
|
566
365
|
|
|
567
|
-
declare function useResetPassword(params?: Params): _tanstack_react_query.UseMutateFunction<Response, Error, MutateFnParams, unknown>;
|
|
366
|
+
declare function useResetPassword(params?: Params): _tanstack_react_query.UseMutateFunction<Response | undefined, Error, MutateFnParams, unknown>;
|
|
568
367
|
|
|
569
|
-
declare const Email: (
|
|
368
|
+
declare const Email: ({ hide }: {
|
|
369
|
+
hide?: boolean;
|
|
370
|
+
}) => React$1.JSX.Element;
|
|
570
371
|
declare const Password: () => React$1.JSX.Element;
|
|
571
372
|
|
|
572
|
-
export {
|
|
373
|
+
export { AzureSignInButton as Azure, DiscordSignInButton as Discord, Email, EmailSigningIn as EmailSignIn, EmailSignInButton, GitHubSignInButton as GitHub, GoogleSSOButton as Google, HubSpotSignInButton as HubSpot, LinkedInSignInButton as LinkedIn, Password, ResetPasswordForm as PasswordResetForm, ResetPasswordForm$1 as PasswordResetRequestForm, SessionContext, SessionProvider, SigningIn as SignInForm, SignOutButton, SigningUp as SignUpForm, SignedIn, SignedOut, SlackSignInButton as Slack, TenantSelector, UserInfo, XSignInButton as X, useEmailSignIn, useMe, useResetPassword, useSession, useSignIn, useSignUp, useTenantId, useTenants };
|