@niledatabase/react 4.0.0-alpha.9 → 4.0.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/README.md +71 -111
- package/dist/index.d.mts +181 -140
- package/dist/index.d.ts +181 -140
- 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 +2 -2
- package/package.json +3 -5
package/dist/index.d.ts
CHANGED
|
@@ -1,148 +1,40 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
1
|
+
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
|
|
6
|
-
import { SignInOptions, LiteralUnion, ClientSafeProvider, SignOutParams, SignOutResponse, SignInAuthorizationParams, SignInResponse, UseSessionOptions } from 'next-auth/react';
|
|
5
|
+
import { IncomingMessage } from 'http';
|
|
7
6
|
import * as class_variance_authority_dist_types from 'class-variance-authority/dist/types';
|
|
8
7
|
import { VariantProps } from 'class-variance-authority';
|
|
9
|
-
import { CreateBasicUserRequest } from '@niledatabase/browser';
|
|
10
|
-
import { CtxOrReq } from 'next-auth/client/_utils';
|
|
11
|
-
import { BuiltInProviderType, RedirectableProviderType } from 'next-auth/providers/index';
|
|
12
8
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
type AllowedAny$3 = any;
|
|
16
|
-
type Props$5 = {
|
|
17
|
-
redirect?: boolean;
|
|
18
|
-
onSuccess?: SignInSuccess;
|
|
19
|
-
onError?: (e: Error, info: EmailSignInInfo) => void;
|
|
20
|
-
beforeMutate?: (data: AllowedAny$3) => AllowedAny$3;
|
|
21
|
-
buttonText?: string;
|
|
22
|
-
client?: QueryClient;
|
|
23
|
-
callbackUrl?: string;
|
|
24
|
-
init?: RequestInit;
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
declare function EmailSigningIn(props: Props$5): React__default.JSX.Element;
|
|
28
|
-
|
|
29
|
-
declare const buttonVariants: (props?: ({
|
|
30
|
-
variant?: "default" | "link" | "destructive" | "outline" | "secondary" | "ghost" | null | undefined;
|
|
31
|
-
size?: "default" | "sm" | "lg" | "icon" | null | undefined;
|
|
32
|
-
} & class_variance_authority_dist_types.ClassProp) | undefined) => string;
|
|
33
|
-
interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement>, VariantProps<typeof buttonVariants> {
|
|
34
|
-
asChild?: boolean;
|
|
35
|
-
loading?: boolean;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
type EmailError = void | {
|
|
39
|
-
error: string;
|
|
40
|
-
ok: boolean;
|
|
9
|
+
interface SignInResponse$1 {
|
|
10
|
+
error: string | null;
|
|
41
11
|
status: number;
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
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
|
+
*/
|
|
45
22
|
callbackUrl?: string;
|
|
23
|
+
/** [Documentation](https://next-auth.js.org/getting-started/client#using-the-redirect-false-option) */
|
|
46
24
|
redirect?: boolean;
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
*/
|
|
61
|
-
declare const EmailSignInButton: {
|
|
62
|
-
({ callbackUrl, className, variant, size, asChild, redirect, buttonText, email, onFailure, onSent, ...props }: AllProps): React__default.JSX.Element;
|
|
63
|
-
displayName: string;
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
declare function useEmailSignIn(params?: Props$5): _tanstack_react_query.UseMutateFunction<Response, Error, next_auth_react.SignInOptions, unknown>;
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* A component for a Google login button, according to their design language.
|
|
70
|
-
* This works when an identity provider is configured in the admin dashboard.
|
|
71
|
-
* @param props callbackUrl: a string to override the URL provided by the context
|
|
72
|
-
* @returns a JSX.Element to render
|
|
73
|
-
*/
|
|
74
|
-
declare const GoogleSSOButton: {
|
|
75
|
-
({ callbackUrl, className, variant, size, buttonText, asChild, init, ...props }: ButtonProps & {
|
|
76
|
-
callbackUrl?: string;
|
|
77
|
-
buttonText?: string;
|
|
78
|
-
init?: RequestInit;
|
|
79
|
-
}): React__default.JSX.Element;
|
|
80
|
-
displayName: string;
|
|
81
|
-
};
|
|
82
|
-
|
|
83
|
-
declare const AzureSignInButton: {
|
|
84
|
-
({ callbackUrl, className, buttonText, variant, size, init, asChild, ...props }: ButtonProps & {
|
|
85
|
-
callbackUrl?: string;
|
|
86
|
-
buttonText?: string;
|
|
87
|
-
init?: RequestInit;
|
|
88
|
-
}): React__default.JSX.Element;
|
|
89
|
-
displayName: string;
|
|
90
|
-
};
|
|
91
|
-
|
|
92
|
-
declare const DiscordSignInButton: {
|
|
93
|
-
({ callbackUrl, className, buttonText, variant, size, asChild, init, ...props }: ButtonProps & {
|
|
94
|
-
callbackUrl?: string;
|
|
95
|
-
buttonText?: string;
|
|
96
|
-
init?: RequestInit;
|
|
97
|
-
}): React__default.JSX.Element;
|
|
98
|
-
displayName: string;
|
|
99
|
-
};
|
|
100
|
-
|
|
101
|
-
declare const GitHubSignInButton: {
|
|
102
|
-
({ callbackUrl, className, buttonText, variant, size, init, asChild, ...props }: ButtonProps & {
|
|
103
|
-
callbackUrl?: string;
|
|
104
|
-
buttonText?: string;
|
|
105
|
-
init?: RequestInit;
|
|
106
|
-
}): React__default.JSX.Element;
|
|
107
|
-
displayName: string;
|
|
108
|
-
};
|
|
109
|
-
|
|
110
|
-
declare const HubSpotSignInButton: {
|
|
111
|
-
({ callbackUrl, className, buttonText, variant, size, init, asChild, ...props }: ButtonProps & {
|
|
112
|
-
callbackUrl?: string;
|
|
113
|
-
buttonText?: string;
|
|
114
|
-
init?: RequestInit;
|
|
115
|
-
}): React__default.JSX.Element;
|
|
116
|
-
displayName: string;
|
|
117
|
-
};
|
|
118
|
-
|
|
119
|
-
declare const LinkedInSignInButton: {
|
|
120
|
-
({ callbackUrl, className, buttonText, variant, size, asChild, init, ...props }: ButtonProps & {
|
|
121
|
-
callbackUrl?: string;
|
|
122
|
-
buttonText?: string;
|
|
123
|
-
init?: RequestInit;
|
|
124
|
-
}): React__default.JSX.Element;
|
|
125
|
-
displayName: string;
|
|
126
|
-
};
|
|
127
|
-
|
|
128
|
-
declare const SlackSignInButton: {
|
|
129
|
-
({ callbackUrl, className, buttonText, variant, size, init, asChild, ...props }: ButtonProps & {
|
|
130
|
-
callbackUrl?: string;
|
|
131
|
-
buttonText?: string;
|
|
132
|
-
init?: RequestInit;
|
|
133
|
-
}): React__default.JSX.Element;
|
|
134
|
-
displayName: string;
|
|
135
|
-
};
|
|
136
|
-
|
|
137
|
-
declare const XSignInButton: {
|
|
138
|
-
({ callbackUrl, className, buttonText, variant, size, init, asChild, ...props }: ButtonProps & {
|
|
139
|
-
callbackUrl?: string;
|
|
140
|
-
buttonText?: string;
|
|
141
|
-
init?: RequestInit;
|
|
142
|
-
}): React__default.JSX.Element;
|
|
143
|
-
displayName: string;
|
|
144
|
-
};
|
|
145
|
-
|
|
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;
|
|
146
38
|
type JWT = {
|
|
147
39
|
email: string;
|
|
148
40
|
sub: string;
|
|
@@ -202,6 +94,48 @@ type PartialAuthorizer = null | {
|
|
|
202
94
|
};
|
|
203
95
|
requestInit?: RequestInit | undefined;
|
|
204
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
|
+
type EmailSignInInfo = SignInOptions;
|
|
116
|
+
type SignInSuccess = (response: Response) => void;
|
|
117
|
+
type AllowedAny$3 = any;
|
|
118
|
+
type Props$5 = {
|
|
119
|
+
redirect?: boolean;
|
|
120
|
+
onSuccess?: SignInSuccess;
|
|
121
|
+
onError?: (e: Error, info: EmailSignInInfo) => void;
|
|
122
|
+
beforeMutate?: (data: AllowedAny$3) => AllowedAny$3;
|
|
123
|
+
buttonText?: string;
|
|
124
|
+
client?: QueryClient;
|
|
125
|
+
callbackUrl?: string;
|
|
126
|
+
init?: RequestInit;
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
declare function EmailSigningIn(props: Props$5): React__default.JSX.Element;
|
|
130
|
+
|
|
131
|
+
declare const buttonVariants: (props?: ({
|
|
132
|
+
variant?: "default" | "link" | "destructive" | "outline" | "secondary" | "ghost" | null | undefined;
|
|
133
|
+
size?: "default" | "sm" | "lg" | "icon" | null | undefined;
|
|
134
|
+
} & class_variance_authority_dist_types.ClassProp) | undefined) => string;
|
|
135
|
+
interface ButtonProps extends React$1.ButtonHTMLAttributes<HTMLButtonElement>, VariantProps<typeof buttonVariants> {
|
|
136
|
+
asChild?: boolean;
|
|
137
|
+
loading?: boolean;
|
|
138
|
+
}
|
|
205
139
|
|
|
206
140
|
type WarningCode = 'NEXTAUTH_URL' | 'NO_SECRET' | 'TWITTER_OAUTH_2_BETA' | 'DEBUG_ENABLED';
|
|
207
141
|
/**
|
|
@@ -277,7 +211,7 @@ declare class Authorizer {
|
|
|
277
211
|
init?: ResponseInit;
|
|
278
212
|
fetchUrl?: string;
|
|
279
213
|
auth?: Authorizer | PartialAuthorizer;
|
|
280
|
-
}, authorizationParams?: SignInAuthorizationParams): Promise<P extends RedirectableProviderType ? SignInResponse | undefined : undefined>;
|
|
214
|
+
}, authorizationParams?: SignInAuthorizationParams): Promise<P extends RedirectableProviderType ? SignInResponse$1 | undefined : undefined>;
|
|
281
215
|
signUp(options: {
|
|
282
216
|
baseUrl?: string;
|
|
283
217
|
init?: ResponseInit;
|
|
@@ -300,6 +234,102 @@ declare const getProviders: () => Promise<Record<LiteralUnion<BuiltInProviderTyp
|
|
|
300
234
|
declare const signOut: typeof authorizer.signOut;
|
|
301
235
|
declare const signIn: typeof authorizer.signIn;
|
|
302
236
|
|
|
237
|
+
interface SignInResponse {
|
|
238
|
+
error: string | null;
|
|
239
|
+
status: number;
|
|
240
|
+
ok: boolean;
|
|
241
|
+
url: string | null;
|
|
242
|
+
}
|
|
243
|
+
type SSOButtonProps = {
|
|
244
|
+
callbackUrl?: string;
|
|
245
|
+
buttonText?: string;
|
|
246
|
+
init?: RequestInit;
|
|
247
|
+
baseUrl?: string;
|
|
248
|
+
fetchUrl?: string;
|
|
249
|
+
auth?: Authorizer | PartialAuthorizer;
|
|
250
|
+
onClick?: (e: React.MouseEvent<HTMLButtonElement, MouseEvent>, res: SignInResponse | undefined) => void;
|
|
251
|
+
};
|
|
252
|
+
|
|
253
|
+
type EmailError = void | {
|
|
254
|
+
error: string;
|
|
255
|
+
ok: boolean;
|
|
256
|
+
status: number;
|
|
257
|
+
url: null | string;
|
|
258
|
+
};
|
|
259
|
+
type AllProps = ButtonProps & SSOButtonProps & {
|
|
260
|
+
callbackUrl?: string;
|
|
261
|
+
redirect?: boolean;
|
|
262
|
+
email: string;
|
|
263
|
+
onSent?: () => void;
|
|
264
|
+
onFailure?: (error: EmailError) => void;
|
|
265
|
+
buttonText?: string;
|
|
266
|
+
};
|
|
267
|
+
/**
|
|
268
|
+
* This works when the email identity provider is configured in the admin dashboard.
|
|
269
|
+
* @param props callbackUrl: the url to send the user to from their email
|
|
270
|
+
* @param props redirect: redirect to the default (unbranded) 'check your email' page. default is false
|
|
271
|
+
* @param props email: the email to send to
|
|
272
|
+
* @param props onSent: called if the email was sent
|
|
273
|
+
* @param props onFailure: called if there was a reportable
|
|
274
|
+
* @returns a JSX.Element to render
|
|
275
|
+
*/
|
|
276
|
+
declare const EmailSignInButton: {
|
|
277
|
+
({ callbackUrl, className, variant, size, asChild, redirect, buttonText, email, onFailure, onSent, fetchUrl, baseUrl, auth, ...props }: AllProps): React__default.JSX.Element;
|
|
278
|
+
displayName: string;
|
|
279
|
+
};
|
|
280
|
+
|
|
281
|
+
declare function useEmailSignIn(params?: Props$5): _tanstack_react_query.UseMutateFunction<Response, Error, SignInOptions, unknown>;
|
|
282
|
+
|
|
283
|
+
/**
|
|
284
|
+
* A component for a Google login button, according to their design language.
|
|
285
|
+
* This works when an identity provider is configured in the admin dashboard.
|
|
286
|
+
* @param props callbackUrl: a string to override the URL provided by the context
|
|
287
|
+
* @returns a JSX.Element to render
|
|
288
|
+
*/
|
|
289
|
+
declare const GoogleSSOButton: {
|
|
290
|
+
({ callbackUrl, className, variant, size, buttonText, asChild, init, auth, fetchUrl, baseUrl, ...props }: ButtonProps & SSOButtonProps): React__default.JSX.Element;
|
|
291
|
+
displayName: string;
|
|
292
|
+
};
|
|
293
|
+
|
|
294
|
+
declare const AzureSignInButton: {
|
|
295
|
+
({ callbackUrl, className, buttonText, variant, size, init, asChild, auth, fetchUrl, baseUrl, ...props }: ButtonProps & SSOButtonProps): React__default.JSX.Element;
|
|
296
|
+
displayName: string;
|
|
297
|
+
};
|
|
298
|
+
|
|
299
|
+
declare const DiscordSignInButton: {
|
|
300
|
+
({ callbackUrl, className, buttonText, variant, size, asChild, init, auth, fetchUrl, baseUrl, ...props }: ButtonProps & SSOButtonProps): React__default.JSX.Element;
|
|
301
|
+
displayName: string;
|
|
302
|
+
};
|
|
303
|
+
|
|
304
|
+
declare const GitHubSignInButton: {
|
|
305
|
+
({ callbackUrl, className, buttonText, variant, size, init, asChild, auth, fetchUrl, baseUrl, ...props }: ButtonProps & SSOButtonProps): React__default.JSX.Element;
|
|
306
|
+
displayName: string;
|
|
307
|
+
};
|
|
308
|
+
|
|
309
|
+
declare const HubSpotSignInButton: {
|
|
310
|
+
({ callbackUrl, className, buttonText, variant, size, init, asChild, auth, fetchUrl, baseUrl, ...props }: ButtonProps & SSOButtonProps): React__default.JSX.Element;
|
|
311
|
+
displayName: string;
|
|
312
|
+
};
|
|
313
|
+
|
|
314
|
+
declare const LinkedInSignInButton: {
|
|
315
|
+
({ callbackUrl, className, buttonText, variant, size, asChild, init, auth, fetchUrl, baseUrl, ...props }: ButtonProps & SSOButtonProps): React__default.JSX.Element;
|
|
316
|
+
displayName: string;
|
|
317
|
+
};
|
|
318
|
+
|
|
319
|
+
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;
|
|
325
|
+
displayName: string;
|
|
326
|
+
};
|
|
327
|
+
|
|
328
|
+
declare const XSignInButton: {
|
|
329
|
+
({ callbackUrl, className, buttonText, variant, size, init, asChild, auth, fetchUrl, baseUrl, ...props }: ButtonProps & SSOButtonProps): React__default.JSX.Element;
|
|
330
|
+
displayName: string;
|
|
331
|
+
};
|
|
332
|
+
|
|
303
333
|
type ComponentFetchProps = {
|
|
304
334
|
auth?: Authorizer | PartialAuthorizer;
|
|
305
335
|
init?: RequestInit;
|
|
@@ -312,6 +342,12 @@ type PrefetchParams = {
|
|
|
312
342
|
fetchUrl?: string;
|
|
313
343
|
};
|
|
314
344
|
|
|
345
|
+
interface CreateBasicUserRequest {
|
|
346
|
+
email: string;
|
|
347
|
+
password: string;
|
|
348
|
+
preferredName?: string;
|
|
349
|
+
newTenant?: string;
|
|
350
|
+
}
|
|
315
351
|
type SignUpInfo = CreateBasicUserRequest & {
|
|
316
352
|
tenantId?: string;
|
|
317
353
|
fetchUrl?: string;
|
|
@@ -353,7 +389,7 @@ type Props$3 = ComponentFetchProps & {
|
|
|
353
389
|
|
|
354
390
|
declare function SigningIn({ className, ...props }: Props$3): React__default.JSX.Element;
|
|
355
391
|
|
|
356
|
-
declare function useSignIn(params?: Props$3): _tanstack_react_query.UseMutateFunction<
|
|
392
|
+
declare function useSignIn(params?: Props$3): _tanstack_react_query.UseMutateFunction<SignInResponse$1 | undefined, Error, LoginInfo, any>;
|
|
357
393
|
|
|
358
394
|
type Props$2 = ButtonProps & ComponentFetchProps & {
|
|
359
395
|
redirect?: boolean;
|
|
@@ -417,6 +453,11 @@ declare const SessionContext: React__default.Context<{
|
|
|
417
453
|
data: null | undefined;
|
|
418
454
|
status: "unauthenticated" | "loading";
|
|
419
455
|
} | undefined>;
|
|
456
|
+
interface UseSessionOptions<R extends boolean> {
|
|
457
|
+
required: R;
|
|
458
|
+
/** Defaults to `signIn` */
|
|
459
|
+
onUnauthenticated?: () => void;
|
|
460
|
+
}
|
|
420
461
|
/**
|
|
421
462
|
* React Hook that gives you access
|
|
422
463
|
* to the logged in user's session data.
|
|
@@ -527,7 +568,7 @@ declare function ResetPasswordForm(params: Params): React__default.JSX.Element;
|
|
|
527
568
|
|
|
528
569
|
declare function useResetPassword(params?: Params): _tanstack_react_query.UseMutateFunction<Response, Error, MutateFnParams, unknown>;
|
|
529
570
|
|
|
530
|
-
declare const Email: () => React.JSX.Element;
|
|
531
|
-
declare const Password: () => React.JSX.Element;
|
|
571
|
+
declare const Email: () => React$1.JSX.Element;
|
|
572
|
+
declare const Password: () => React$1.JSX.Element;
|
|
532
573
|
|
|
533
574
|
export { type ActiveSession, type AuthConfig, type AuthState, Authorizer, AzureSignInButton as Azure, DiscordSignInButton as Discord, Email, EmailSigningIn as EmailSignIn, EmailSignInButton, GitHubSignInButton as GitHub, GoogleSSOButton as Google, HubSpotSignInButton as HubSpot, type JWT, LinkedInSignInButton as LinkedIn, type Listener, type ListenerKeys, type ListenerParams, Password, ResetPasswordForm as PasswordResetForm, ResetPasswordForm$1 as PasswordResetRequestForm, type NonErrorSession as Session, SessionContext, SessionProvider, SigningIn as SignInForm, SignOutButton, SigningUp as SignUpForm, SignedIn, SignedOut, SlackSignInButton as Slack, TenantSelector, UserInfo, XSignInButton as X, auth, getCsrfToken, getProviders, getSession, signIn, signOut, useEmailSignIn, useMe, useResetPassword, useSession, useSignIn, useSignUp, useTenantId, useTenants };
|