bwh-auth 0.6.4 → 0.7.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/LICENSE +1 -1
- package/README.md +178 -11
- package/dist/index.cjs +3133 -1737
- package/dist/index.d.cts +586 -335
- package/dist/index.d.ts +586 -335
- package/dist/index.js +3079 -1679
- package/package.json +23 -17
package/dist/index.d.cts
CHANGED
|
@@ -1,198 +1,299 @@
|
|
|
1
|
-
import * as React from
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
success?: boolean;
|
|
48
|
-
message?: string;
|
|
49
|
-
error?: string;
|
|
50
|
-
redirect?: string;
|
|
51
|
-
requires_2fa?: boolean;
|
|
52
|
-
attempt_token?: string;
|
|
53
|
-
[key: string]: unknown;
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
export interface AuthEndpointConfig {
|
|
3
|
+
csrfToken?: string;
|
|
4
|
+
login?: string;
|
|
5
|
+
signup?: string;
|
|
6
|
+
forgotPassword?: string;
|
|
7
|
+
resetPassword?: string;
|
|
8
|
+
changePassword?: string;
|
|
9
|
+
twoFactorVerify?: string;
|
|
10
|
+
twoFactorResend?: string;
|
|
11
|
+
twoFactorReport?: (token: string) => string;
|
|
12
|
+
passkeyList?: string;
|
|
13
|
+
passkeyRegisterOptions?: string;
|
|
14
|
+
passkeyRegister?: string;
|
|
15
|
+
passkeyDelete?: (id: number | string) => string;
|
|
16
|
+
passkeyAuthOptions?: string;
|
|
17
|
+
passkeyAuth?: string;
|
|
18
|
+
confirmPassword?: string;
|
|
19
|
+
passkeyConfirmOptions?: string;
|
|
20
|
+
passkeyConfirm?: string;
|
|
21
|
+
}
|
|
22
|
+
export type AuthValidationErrors = Record<string, string[]>;
|
|
23
|
+
export type AuthSignupValues = Record<string, string | boolean>;
|
|
24
|
+
export interface AuthSignupField {
|
|
25
|
+
name: string;
|
|
26
|
+
label: React.ReactNode;
|
|
27
|
+
type?: React.HTMLInputTypeAttribute;
|
|
28
|
+
placeholder?: string;
|
|
29
|
+
required?: boolean;
|
|
30
|
+
autoComplete?: string;
|
|
31
|
+
initialValue?: string | boolean;
|
|
32
|
+
minLength?: number;
|
|
33
|
+
maxLength?: number;
|
|
34
|
+
pattern?: string;
|
|
35
|
+
inputMode?: React.HTMLAttributes<HTMLInputElement>['inputMode'];
|
|
36
|
+
helpText?: React.ReactNode;
|
|
37
|
+
className?: string;
|
|
38
|
+
containerClassName?: string;
|
|
39
|
+
hiddenWhen?: (values: AuthSignupValues) => boolean;
|
|
40
|
+
}
|
|
41
|
+
export interface Passkey {
|
|
42
|
+
id: number;
|
|
43
|
+
name: string;
|
|
44
|
+
aaguid: string | null;
|
|
45
|
+
created_at: string;
|
|
46
|
+
updated_at: string;
|
|
54
47
|
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
48
|
+
export interface AuthJsonResponse {
|
|
49
|
+
success?: boolean;
|
|
50
|
+
message?: string;
|
|
51
|
+
error?: string;
|
|
52
|
+
redirect?: string;
|
|
53
|
+
requires_2fa?: boolean;
|
|
54
|
+
attempt_token?: string;
|
|
55
|
+
[key: string]: unknown;
|
|
56
|
+
}
|
|
57
|
+
/** HTTP methods the JSON auth forms may send. */
|
|
58
|
+
export type AuthFormMethod = 'POST' | 'PUT' | 'PATCH';
|
|
59
|
+
export type AuthButtonVariant = 'default' | 'destructive' | 'outline' | 'secondary' | 'ghost' | 'link';
|
|
60
|
+
export type AuthButtonSize = 'default' | 'sm' | 'lg' | 'icon' | 'icon-sm' | 'icon-lg';
|
|
61
|
+
export type AuthButtonComponentProps = React.ButtonHTMLAttributes<HTMLButtonElement> & {
|
|
62
|
+
variant?: AuthButtonVariant;
|
|
63
|
+
size?: AuthButtonSize;
|
|
60
64
|
};
|
|
61
|
-
type AuthInputComponentProps = React.InputHTMLAttributes<HTMLInputElement>;
|
|
62
|
-
type AuthLabelComponentProps = React.LabelHTMLAttributes<HTMLLabelElement>;
|
|
63
|
-
type AuthContainerComponentProps = React.HTMLAttributes<HTMLDivElement>;
|
|
64
|
-
type AuthTextareaComponentProps = React.TextareaHTMLAttributes<HTMLTextAreaElement>;
|
|
65
|
+
export type AuthInputComponentProps = React.InputHTMLAttributes<HTMLInputElement>;
|
|
66
|
+
export type AuthLabelComponentProps = React.LabelHTMLAttributes<HTMLLabelElement>;
|
|
67
|
+
export type AuthContainerComponentProps = React.HTMLAttributes<HTMLDivElement>;
|
|
68
|
+
export type AuthTextareaComponentProps = React.TextareaHTMLAttributes<HTMLTextAreaElement>;
|
|
65
69
|
/** A controlled checkbox: the app's own, e.g. a design-system `Checkbox` with `onCheckedChange`. */
|
|
66
|
-
interface AuthCheckboxComponentProps {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
+
export interface AuthCheckboxComponentProps {
|
|
71
|
+
id: string;
|
|
72
|
+
checked: boolean;
|
|
73
|
+
onCheckedChange: (checked: boolean) => void;
|
|
70
74
|
}
|
|
71
75
|
/** A small inline label, e.g. a design-system `Badge`. */
|
|
72
|
-
type AuthBadgeComponentProps = React.HTMLAttributes<HTMLSpanElement>;
|
|
73
|
-
interface AuthRadioGroupOption {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
+
export type AuthBadgeComponentProps = React.HTMLAttributes<HTMLSpanElement>;
|
|
77
|
+
export interface AuthRadioGroupOption {
|
|
78
|
+
value: string;
|
|
79
|
+
label: React.ReactNode;
|
|
76
80
|
}
|
|
77
81
|
/** A controlled set of radio options, rendered however the app renders radio groups. */
|
|
78
|
-
interface AuthRadioGroupComponentProps {
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
}
|
|
84
|
-
interface AuthComponentSet {
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
}
|
|
102
|
-
type AuthComponents = AuthComponentSet;
|
|
103
|
-
type AuthComponentOverrides = Partial<AuthComponentSet>;
|
|
104
|
-
type AuthButtonComponent = AuthComponentSet['Button'];
|
|
105
|
-
type AuthComponentSuperset = AuthComponentSet & Record<string, React.ComponentType<any>>;
|
|
106
|
-
type AuthComponentInput = AuthComponentSet | AuthComponentSuperset;
|
|
107
|
-
type AuthButtonComponentInput = Pick<AuthComponentSet, 'Button'> & Record<string, React.ComponentType<any>>;
|
|
108
|
-
|
|
82
|
+
export interface AuthRadioGroupComponentProps {
|
|
83
|
+
name: string;
|
|
84
|
+
value: string;
|
|
85
|
+
onValueChange: (value: string) => void;
|
|
86
|
+
options: AuthRadioGroupOption[];
|
|
87
|
+
}
|
|
88
|
+
export interface AuthComponentSet {
|
|
89
|
+
Button: React.ComponentType<AuthButtonComponentProps>;
|
|
90
|
+
Card: React.ComponentType<AuthContainerComponentProps>;
|
|
91
|
+
CardContent: React.ComponentType<AuthContainerComponentProps>;
|
|
92
|
+
CardDescription: React.ComponentType<AuthContainerComponentProps>;
|
|
93
|
+
CardHeader: React.ComponentType<AuthContainerComponentProps>;
|
|
94
|
+
CardTitle: React.ComponentType<AuthContainerComponentProps>;
|
|
95
|
+
Input: React.ComponentType<AuthInputComponentProps>;
|
|
96
|
+
Label: React.ComponentType<AuthLabelComponentProps>;
|
|
97
|
+
/** Optional; native elements are rendered when omitted. */
|
|
98
|
+
Textarea?: React.ComponentType<AuthTextareaComponentProps>;
|
|
99
|
+
Checkbox?: React.ComponentType<AuthCheckboxComponentProps>;
|
|
100
|
+
RadioGroup?: React.ComponentType<AuthRadioGroupComponentProps>;
|
|
101
|
+
/** Optional: the "Sensitive" badge in the scope picker. A `<span>` is rendered when omitted. */
|
|
102
|
+
Badge?: React.ComponentType<AuthBadgeComponentProps>;
|
|
103
|
+
/** Optional: the warning shown for a sensitive scope group. A styled `<p>` is rendered when omitted. */
|
|
104
|
+
Alert?: React.ComponentType<AuthContainerComponentProps>;
|
|
105
|
+
}
|
|
106
|
+
export type AuthComponents = AuthComponentSet;
|
|
107
|
+
export type AuthComponentOverrides = Partial<AuthComponentSet>;
|
|
108
|
+
export type AuthButtonComponent = AuthComponentSet['Button'];
|
|
109
|
+
export type AuthComponentSuperset = AuthComponentSet & Record<string, React.ComponentType<any>>;
|
|
110
|
+
export type AuthComponentInput = AuthComponentSet | AuthComponentSuperset;
|
|
111
|
+
export type AuthButtonComponentInput = Pick<AuthComponentSet, 'Button'> & Record<string, React.ComponentType<any>>;
|
|
112
|
+
/** Overridable copy shared by `EmailCodeForm` and `TwoFactorForm`. */
|
|
113
|
+
export interface EmailCodeFormCopy {
|
|
114
|
+
title?: React.ReactNode;
|
|
115
|
+
/** Defaults to "Enter the N-digit code sent to your email address." */
|
|
116
|
+
description?: React.ReactNode;
|
|
117
|
+
codeLabel?: React.ReactNode;
|
|
118
|
+
submitLabel?: React.ReactNode;
|
|
119
|
+
submittingLabel?: React.ReactNode;
|
|
120
|
+
resendLabel?: React.ReactNode;
|
|
121
|
+
resendingLabel?: React.ReactNode;
|
|
122
|
+
/** Shown after a resend when the server's response carries no `message`. */
|
|
123
|
+
resentMessage?: string;
|
|
124
|
+
}
|
|
125
|
+
/** What the `actions` render function receives, for app-specific actions below the form. */
|
|
126
|
+
export interface EmailCodeFormActions {
|
|
127
|
+
/** Replace the status line shown below the actions. */
|
|
128
|
+
setMessage: (message: string) => void;
|
|
129
|
+
/** True while the code or a resend request is in flight. */
|
|
130
|
+
busy: boolean;
|
|
131
|
+
}
|
|
132
|
+
export interface EmailCodeFormProps extends EmailCodeFormCopy {
|
|
133
|
+
components: AuthComponentInput;
|
|
134
|
+
/** Where the code is sent. */
|
|
135
|
+
submitUrl: string;
|
|
136
|
+
/** Builds the request body from the trimmed code. Defaults to `{ code }`. */
|
|
137
|
+
buildSubmitBody?: (code: string) => Record<string, unknown>;
|
|
138
|
+
/** HTTP method for the code request. Defaults to `POST`. */
|
|
139
|
+
method?: AuthFormMethod;
|
|
140
|
+
/** Where "Send a new code" posts. The resend button is hidden when omitted. */
|
|
141
|
+
resendUrl?: string | null;
|
|
142
|
+
/** Builds the resend request body. Defaults to `{}`. */
|
|
143
|
+
buildResendBody?: () => Record<string, unknown>;
|
|
144
|
+
csrfToken?: string;
|
|
145
|
+
/** Number of digits in the code. Defaults to 6. */
|
|
146
|
+
codeLength?: number;
|
|
147
|
+
/** Prefix for element IDs; the code input is `${idPrefix}-code`. Defaults to `email-code`. */
|
|
148
|
+
idPrefix?: string;
|
|
149
|
+
/** Content above the title, such as a logo or an explanation of why the code is needed. */
|
|
150
|
+
header?: React.ReactNode;
|
|
151
|
+
/** Render only the form and actions, without the card, title and description. */
|
|
152
|
+
unwrapped?: boolean;
|
|
153
|
+
/** Hide the resend button even when `resendUrl` is set. */
|
|
154
|
+
hideResend?: boolean;
|
|
155
|
+
/** A hint shown below the actions, e.g. a fixed test code outside production. Nothing is shown when empty. */
|
|
156
|
+
testCodeHint?: string | null;
|
|
157
|
+
/** App-specific actions rendered after the resend button. */
|
|
158
|
+
actions?: React.ReactNode | ((actions: EmailCodeFormActions) => React.ReactNode);
|
|
159
|
+
/**
|
|
160
|
+
* Formats an HTTP 429 using the `Retry-After` seconds (or `null`). Defaults to a message naming the wait;
|
|
161
|
+
* `null` passes the server's own message through.
|
|
162
|
+
*/
|
|
163
|
+
rateLimitMessage?: ((retryAfterSeconds: number | null) => string) | null;
|
|
164
|
+
onSubmitStart?: () => void;
|
|
165
|
+
/** Called with the server's response. Without it, a safe `redirect` in the response is followed. */
|
|
166
|
+
onSuccess?: (result: AuthJsonResponse) => void;
|
|
167
|
+
onError?: (message: string) => void;
|
|
168
|
+
/** Called after a successful resend, e.g. to pick up a rotated token from the response. */
|
|
169
|
+
onResend?: (result: AuthJsonResponse) => void;
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* A form for a code sent by email: sign-in verification, step-up before a sensitive
|
|
173
|
+
* action, or re-verifying an address. The endpoint and request body are the caller's;
|
|
174
|
+
* this owns the input, the busy state and a synchronous guard so two fast clicks or
|
|
175
|
+
* Enter presses send one request.
|
|
176
|
+
*/
|
|
177
|
+
export declare function EmailCodeForm({ components, submitUrl, buildSubmitBody, method, resendUrl, buildResendBody, csrfToken, codeLength, idPrefix, header, unwrapped, hideResend, testCodeHint, actions, rateLimitMessage, onSubmitStart, onSuccess, onError, onResend, title, description, codeLabel, submitLabel, submittingLabel, resendLabel, resendingLabel, resentMessage }: EmailCodeFormProps): React.JSX.Element;
|
|
109
178
|
interface AuthFormProps {
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
}
|
|
115
|
-
interface LoginRememberMeCheckboxProps {
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
}
|
|
122
|
-
interface LoginFormProps extends AuthFormProps {
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
179
|
+
endpoints?: AuthEndpointConfig;
|
|
180
|
+
components: AuthComponentInput;
|
|
181
|
+
onSuccess?: (result: AuthJsonResponse) => void;
|
|
182
|
+
onError?: (message: string) => void;
|
|
183
|
+
}
|
|
184
|
+
export interface LoginRememberMeCheckboxProps {
|
|
185
|
+
id: string;
|
|
186
|
+
checked: boolean;
|
|
187
|
+
onCheckedChange: (checked: boolean) => void;
|
|
188
|
+
'aria-labelledby'?: string;
|
|
189
|
+
'data-test'?: string;
|
|
190
|
+
}
|
|
191
|
+
export interface LoginFormProps extends AuthFormProps {
|
|
192
|
+
/** Render only the controls when the consumer owns the card and heading. */
|
|
193
|
+
unwrapped?: boolean;
|
|
194
|
+
passkeySeparator?: React.ReactNode;
|
|
195
|
+
enablePasskeys?: boolean;
|
|
196
|
+
enablePasskeyAutofill?: boolean;
|
|
197
|
+
initialEmail?: string;
|
|
198
|
+
onEmailChange?: (email: string) => void;
|
|
199
|
+
rememberMeCheckbox?: React.ComponentType<LoginRememberMeCheckboxProps>;
|
|
200
|
+
rememberMeLabel?: React.ReactNode;
|
|
201
|
+
rememberMeDataTest?: string;
|
|
202
|
+
onSubmitStart?: () => void;
|
|
203
|
+
onTwoFactorRequired?: (result: AuthJsonResponse & {
|
|
204
|
+
attempt_token?: string;
|
|
205
|
+
}) => void;
|
|
206
|
+
onPasskeySuccess?: (redirectUrl: string, result: AuthJsonResponse) => void;
|
|
138
207
|
}
|
|
139
208
|
interface SignupFormProps extends Omit<AuthFormProps, 'onSuccess'> {
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
}
|
|
150
|
-
interface
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
}
|
|
154
|
-
interface
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
209
|
+
fields?: AuthSignupField[];
|
|
210
|
+
initialValues?: AuthSignupValues;
|
|
211
|
+
errors?: AuthValidationErrors;
|
|
212
|
+
submitMode?: 'fetch' | 'native';
|
|
213
|
+
title?: React.ReactNode;
|
|
214
|
+
description?: React.ReactNode;
|
|
215
|
+
submitLabel?: React.ReactNode;
|
|
216
|
+
submittingLabel?: React.ReactNode;
|
|
217
|
+
onSuccess?: (result: AuthJsonResponse, values: AuthSignupValues) => void | Promise<void>;
|
|
218
|
+
}
|
|
219
|
+
interface PasswordFormBaseProps extends AuthFormProps {
|
|
220
|
+
onSubmitStart?: () => void;
|
|
221
|
+
submitClassName?: string;
|
|
222
|
+
}
|
|
223
|
+
export interface PasswordResetRequestFormProps extends PasswordFormBaseProps {
|
|
224
|
+
/**
|
|
225
|
+
* Called instead of navigating when the response carries a `redirect` URL, e.g. when
|
|
226
|
+
* recovery happens at an identity provider. Without it, the browser goes to that URL.
|
|
227
|
+
* Only http(s) URLs (or URLs relative to the page) are followed or passed here.
|
|
228
|
+
*/
|
|
229
|
+
onRedirect?: (url: string, result: AuthJsonResponse) => void;
|
|
230
|
+
/** Formats an HTTP 429 using the `Retry-After` seconds (or `null`). `null` passes the server's own message through. */
|
|
231
|
+
rateLimitMessage?: ((retryAfterSeconds: number | null) => string) | null;
|
|
232
|
+
}
|
|
233
|
+
export interface ResetPasswordFormProps extends PasswordFormBaseProps {
|
|
234
|
+
token?: string;
|
|
235
|
+
email?: string;
|
|
236
|
+
/** Override field IDs when the embedding page already uses the default ID. */
|
|
237
|
+
idPrefix?: string;
|
|
238
|
+
minPasswordLength?: number;
|
|
239
|
+
validatePasswordConfirmation?: boolean;
|
|
240
|
+
passwordLabel?: React.ReactNode;
|
|
241
|
+
passwordConfirmationLabel?: React.ReactNode;
|
|
242
|
+
passwordHelpText?: React.ReactNode;
|
|
243
|
+
}
|
|
244
|
+
export interface TwoFactorFormProps extends AuthFormProps, EmailCodeFormCopy {
|
|
245
|
+
attemptToken: string;
|
|
246
|
+
/**
|
|
247
|
+
* @deprecated Pass `testCodeHint` instead. When `testCodeHint` is undefined, any value other
|
|
248
|
+
* than `production` still shows the fixed test-code hint.
|
|
249
|
+
*/
|
|
250
|
+
appEnv?: string;
|
|
251
|
+
/** The hint shown below the actions, e.g. a fixed test code. `null` or `''` shows nothing and overrides `appEnv`. */
|
|
252
|
+
testCodeHint?: string | null;
|
|
253
|
+
/** Content above the title, such as a logo. */
|
|
254
|
+
header?: React.ReactNode;
|
|
255
|
+
/** Hide "Send a new code". */
|
|
256
|
+
hideResend?: boolean;
|
|
257
|
+
/** Hide "This was not me". */
|
|
258
|
+
hideReportSuspicious?: boolean;
|
|
259
|
+
reportSuspiciousLabel?: React.ReactNode;
|
|
260
|
+
/** Shown after a report when the server's response carries no `message`. */
|
|
261
|
+
reportedMessage?: string;
|
|
262
|
+
/**
|
|
263
|
+
* Formats an HTTP 429 using the `Retry-After` seconds (or `null`). By default the server's
|
|
264
|
+
* message is shown unchanged; pass a function (e.g. to match `EmailCodeForm`) to replace it.
|
|
265
|
+
*/
|
|
266
|
+
rateLimitMessage?: ((retryAfterSeconds: number | null) => string) | null;
|
|
267
|
+
onSubmitStart?: () => void;
|
|
268
|
+
onReportSuspicious?: (result: AuthJsonResponse) => void;
|
|
269
|
+
}
|
|
270
|
+
export declare function LoginForm({ endpoints, components, onSuccess, onError, initialEmail, onEmailChange, rememberMeCheckbox: RememberMeCheckbox, rememberMeLabel, rememberMeDataTest, onSubmitStart, onTwoFactorRequired, onPasskeySuccess, unwrapped, passkeySeparator, enablePasskeys, enablePasskeyAutofill }: LoginFormProps): React.JSX.Element;
|
|
271
|
+
export declare function SignupForm({ endpoints, components, onSuccess, onError, fields, initialValues, errors, submitMode, title, description, submitLabel, submittingLabel }: SignupFormProps): React.JSX.Element;
|
|
272
|
+
export declare function PasswordResetRequestForm({ endpoints, components, onSuccess, onError, onSubmitStart, submitClassName, onRedirect, rateLimitMessage }: PasswordResetRequestFormProps): React.JSX.Element;
|
|
273
|
+
export declare function ResetPasswordForm({ endpoints, components, onSuccess, onError, onSubmitStart, submitClassName, token: initialToken, email: initialEmail, idPrefix, minPasswordLength, validatePasswordConfirmation, passwordLabel, passwordConfirmationLabel, passwordHelpText }: ResetPasswordFormProps): React.JSX.Element;
|
|
274
|
+
export interface ChangePasswordFormProps extends AuthFormProps {
|
|
275
|
+
/** HTTP method for the change request. Defaults to `POST`. */
|
|
276
|
+
method?: AuthFormMethod;
|
|
277
|
+
}
|
|
278
|
+
export declare function ChangePasswordForm({ endpoints, components, onSuccess, onError, method }: ChangePasswordFormProps): React.JSX.Element;
|
|
279
|
+
export declare function TwoFactorForm({ endpoints, components, attemptToken, appEnv, testCodeHint, header, hideResend, hideReportSuspicious, reportSuspiciousLabel, reportedMessage, rateLimitMessage, onSubmitStart, onSuccess, onError, onReportSuspicious, title, ...copy }: TwoFactorFormProps): React.JSX.Element;
|
|
177
280
|
interface PasskeyLoginButtonProps {
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
}
|
|
186
|
-
declare function PasskeyLoginButton({ endpoints, components, className, disabled, remember, onSuccess, onError }: PasskeyLoginButtonProps): React.JSX.Element | null;
|
|
187
|
-
|
|
281
|
+
endpoints?: AuthEndpointConfig;
|
|
282
|
+
components: AuthButtonComponentInput;
|
|
283
|
+
className?: string;
|
|
284
|
+
disabled?: boolean;
|
|
285
|
+
remember?: boolean | (() => boolean);
|
|
286
|
+
onSuccess?: (redirectUrl: string, result: AuthJsonResponse) => void;
|
|
287
|
+
onError?: (message: string) => void;
|
|
288
|
+
}
|
|
289
|
+
export declare function PasskeyLoginButton({ endpoints, components, className, disabled, remember, onSuccess, onError }: PasskeyLoginButtonProps): React.JSX.Element | null;
|
|
188
290
|
interface PasskeySectionProps {
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
291
|
+
endpoints?: AuthEndpointConfig;
|
|
292
|
+
components: AuthComponentInput;
|
|
293
|
+
onSuccess?: (message: string) => void;
|
|
294
|
+
onError?: (field: string, message: string) => void;
|
|
193
295
|
}
|
|
194
|
-
declare function PasskeySection({ endpoints, components, onSuccess, onError }: PasskeySectionProps): React.JSX.Element;
|
|
195
|
-
|
|
296
|
+
export declare function PasskeySection({ endpoints, components, onSuccess, onError }: PasskeySectionProps): React.JSX.Element;
|
|
196
297
|
/**
|
|
197
298
|
* The sibling applications an identity provider reports for the signed-in person.
|
|
198
299
|
*
|
|
@@ -202,10 +303,10 @@ declare function PasskeySection({ endpoints, components, onSuccess, onError }: P
|
|
|
202
303
|
* What they cannot afford to do differently is decide which entries are safe to render, so
|
|
203
304
|
* that decision lives here and the transport stays the application's business.
|
|
204
305
|
*/
|
|
205
|
-
interface RelyingApplication {
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
306
|
+
export interface RelyingApplication {
|
|
307
|
+
key: string;
|
|
308
|
+
name: string;
|
|
309
|
+
url: string;
|
|
209
310
|
}
|
|
210
311
|
/**
|
|
211
312
|
* Reduce a URL from the wire to one that is safe to put in an `href`, or reject it.
|
|
@@ -221,7 +322,7 @@ interface RelyingApplication {
|
|
|
221
322
|
* provider told us something unexpected, and guessing a base for it would be inventing a
|
|
222
323
|
* destination rather than validating one.
|
|
223
324
|
*/
|
|
224
|
-
declare function safeApplicationHref(url: string): string | null;
|
|
325
|
+
export declare function safeApplicationHref(url: string): string | null;
|
|
225
326
|
/**
|
|
226
327
|
* Validate whatever the page handed over into a list that is safe to render.
|
|
227
328
|
*
|
|
@@ -229,187 +330,195 @@ declare function safeApplicationHref(url: string): string | null;
|
|
|
229
330
|
* malformed entry, or a provider that has grown a field, must not be able to take down the
|
|
230
331
|
* page it appears on. Anything that is not a well-formed list degrades to an empty menu.
|
|
231
332
|
*/
|
|
232
|
-
declare function relyingApplicationsFrom(value: unknown): RelyingApplication[];
|
|
233
|
-
|
|
234
|
-
declare function
|
|
235
|
-
declare function
|
|
236
|
-
declare function
|
|
237
|
-
declare function isAbortError(error: unknown): boolean;
|
|
333
|
+
export declare function relyingApplicationsFrom(value: unknown): RelyingApplication[];
|
|
334
|
+
export declare function getCsrfToken(explicitToken?: string): string;
|
|
335
|
+
export declare function base64urlToArrayBuffer(b64: string): ArrayBuffer;
|
|
336
|
+
export declare function arrayBufferToBase64url(buffer: ArrayBuffer): string;
|
|
337
|
+
export declare function isAbortError(error: unknown): boolean;
|
|
238
338
|
interface AuthenticateWithPasskeyOptions {
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
339
|
+
endpoints?: AuthEndpointConfig;
|
|
340
|
+
mediation?: CredentialMediationRequirement;
|
|
341
|
+
signal?: AbortSignal;
|
|
342
|
+
/** Read after the browser ceremony, immediately before the sign-in request. */
|
|
343
|
+
remember?: boolean | (() => boolean);
|
|
244
344
|
}
|
|
245
345
|
interface PasskeyAuthenticationResult {
|
|
246
|
-
|
|
247
|
-
|
|
346
|
+
redirectUrl: string;
|
|
347
|
+
result: AuthJsonResponse;
|
|
248
348
|
}
|
|
249
349
|
interface RegisterPasskeyOptions {
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
350
|
+
endpoints?: AuthEndpointConfig;
|
|
351
|
+
name?: string;
|
|
352
|
+
signal?: AbortSignal;
|
|
253
353
|
}
|
|
254
354
|
interface PasskeyRegistrationResult {
|
|
255
|
-
|
|
355
|
+
result: AuthJsonResponse;
|
|
256
356
|
}
|
|
257
|
-
declare function getDefaultPasskeyName(): string;
|
|
258
|
-
declare function isConditionalMediationAvailable(): Promise<boolean>;
|
|
259
|
-
declare function authenticateWithPasskey({ endpoints, mediation, signal, remember }?: AuthenticateWithPasskeyOptions): Promise<PasskeyAuthenticationResult>;
|
|
260
|
-
declare
|
|
261
|
-
|
|
357
|
+
export declare function getDefaultPasskeyName(): string;
|
|
358
|
+
export declare function isConditionalMediationAvailable(): Promise<boolean>;
|
|
359
|
+
export declare function authenticateWithPasskey({ endpoints, mediation, signal, remember }?: AuthenticateWithPasskeyOptions): Promise<PasskeyAuthenticationResult>;
|
|
360
|
+
export declare class PasswordConfirmationRequiredError extends Error {
|
|
361
|
+
constructor();
|
|
362
|
+
}
|
|
363
|
+
export declare function confirmPasswordForPasskey({ password, endpoints, signal }: {
|
|
364
|
+
password: string;
|
|
365
|
+
endpoints?: AuthEndpointConfig;
|
|
366
|
+
signal?: AbortSignal;
|
|
367
|
+
}): Promise<void>;
|
|
368
|
+
export declare function confirmPasskey({ endpoints, signal }?: {
|
|
369
|
+
endpoints?: AuthEndpointConfig;
|
|
370
|
+
signal?: AbortSignal;
|
|
371
|
+
}): Promise<void>;
|
|
372
|
+
export declare function registerPasskey({ endpoints, name, signal }?: RegisterPasskeyOptions): Promise<PasskeyRegistrationResult>;
|
|
262
373
|
/**
|
|
263
374
|
* Pure selection logic for the scope picker. Implications are a picker-only
|
|
264
375
|
* cascade: the credential still stores exactly the ids that end up selected,
|
|
265
376
|
* and the server never infers one scope from another.
|
|
266
377
|
*/
|
|
267
378
|
/** scope id => scope ids it needs, e.g. `{ 'billing:write': ['billing:read'] }`. */
|
|
268
|
-
type ScopeImplications = Record<string, string[]>;
|
|
379
|
+
export type ScopeImplications = Record<string, string[]>;
|
|
269
380
|
/** Transitive closure of `implications`, with self-references and cycles dropped. */
|
|
270
|
-
declare function closeImplications(implications: ScopeImplications): ScopeImplications;
|
|
381
|
+
export declare function closeImplications(implications: ScopeImplications): ScopeImplications;
|
|
271
382
|
/** Keeps only entries whose key and every requirement are offered; drops entries left empty. */
|
|
272
|
-
declare function restrictImplications(implications: ScopeImplications | undefined, offered: Set<string>): ScopeImplications;
|
|
383
|
+
export declare function restrictImplications(implications: ScopeImplications | undefined, offered: Set<string>): ScopeImplications;
|
|
273
384
|
/** Orders `ids` by `catalog`, removing duplicates and ids not in it. */
|
|
274
|
-
declare function inCatalogOrder(ids: Iterable<string>, catalog: string[]): string[];
|
|
385
|
+
export declare function inCatalogOrder(ids: Iterable<string>, catalog: string[]): string[];
|
|
275
386
|
/** Ticking: adds the ids and everything they need. */
|
|
276
|
-
declare function withScopes(selected: string[], ids: string[], closed: ScopeImplications): Set<string>;
|
|
387
|
+
export declare function withScopes(selected: string[], ids: string[], closed: ScopeImplications): Set<string>;
|
|
277
388
|
/** Unticking: removes the ids and every selected scope that needs one of them. */
|
|
278
|
-
declare function withoutScopes(selected: string[], ids: string[], closed: ScopeImplications): Set<string>;
|
|
389
|
+
export declare function withoutScopes(selected: string[], ids: string[], closed: ScopeImplications): Set<string>;
|
|
279
390
|
/** Selected scopes that need `id`, in catalog order: why `id` is ticked beyond the person's own choice. */
|
|
280
|
-
declare function neededBy(id: string, selected: string[], closed: ScopeImplications): string[];
|
|
281
|
-
declare function sameSelection(a: string[], b: string[]): boolean;
|
|
282
|
-
|
|
391
|
+
export declare function neededBy(id: string, selected: string[], closed: ScopeImplications): string[];
|
|
392
|
+
export declare function sameSelection(a: string[], b: string[]): boolean;
|
|
283
393
|
/** A named set of related scopes (`scopes` are ids from the sibling scope list). */
|
|
284
|
-
interface ApiCredentialScopeGroup {
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
394
|
+
export interface ApiCredentialScopeGroup {
|
|
395
|
+
id: string;
|
|
396
|
+
label: string;
|
|
397
|
+
description: string | null;
|
|
398
|
+
/** A sensitive group is one parent checkbox, with its scopes behind a disclosure. */
|
|
399
|
+
sensitive: boolean;
|
|
400
|
+
scopes: string[];
|
|
291
401
|
}
|
|
292
402
|
/** A one-click selection: choosing it replaces the selection with exactly `scopes`. */
|
|
293
|
-
interface ApiCredentialScopePreset {
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
}
|
|
299
|
-
interface ScopePickerProps {
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
}
|
|
310
|
-
declare function ScopePicker({ idPrefix, scopes, groups, presets, implications, selected, onChange, components }: ScopePickerProps): React.JSX.Element;
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
delete_href: string;
|
|
403
|
+
export interface ApiCredentialScopePreset {
|
|
404
|
+
id: string;
|
|
405
|
+
label: string;
|
|
406
|
+
description: string;
|
|
407
|
+
scopes: string[];
|
|
408
|
+
}
|
|
409
|
+
export interface ScopePickerProps {
|
|
410
|
+
idPrefix: string;
|
|
411
|
+
scopes: ApiCredentialScope[];
|
|
412
|
+
/** Absent or empty: a flat list, as before groups existed. */
|
|
413
|
+
groups?: ApiCredentialScopeGroup[];
|
|
414
|
+
presets?: ApiCredentialScopePreset[];
|
|
415
|
+
implications?: ScopeImplications;
|
|
416
|
+
selected: string[];
|
|
417
|
+
onChange: (next: string[]) => void;
|
|
418
|
+
components: AuthComponentInput;
|
|
419
|
+
}
|
|
420
|
+
export declare function ScopePicker({ idPrefix, scopes, groups, presets, implications, selected, onChange, components }: ScopePickerProps): React.JSX.Element;
|
|
421
|
+
export interface ApiCredentialScope {
|
|
422
|
+
id: string;
|
|
423
|
+
description: string;
|
|
424
|
+
}
|
|
425
|
+
export interface ApiCredentialToken {
|
|
426
|
+
id: string;
|
|
427
|
+
name: string;
|
|
428
|
+
scopes: string[];
|
|
429
|
+
created_at: string | null;
|
|
430
|
+
expires_at: string | null;
|
|
431
|
+
revoke_href: string;
|
|
432
|
+
/** True for a token that carries an MCP connection scope. */
|
|
433
|
+
connection?: boolean;
|
|
434
|
+
}
|
|
435
|
+
export interface ApiCredentialApp {
|
|
436
|
+
id: string;
|
|
437
|
+
name: string;
|
|
438
|
+
confidential: boolean;
|
|
439
|
+
redirect_uris: string[];
|
|
440
|
+
scopes: string[];
|
|
441
|
+
created_at: string | null;
|
|
442
|
+
delete_href: string;
|
|
334
443
|
}
|
|
335
444
|
/** The server's index response (`data`): every URL is finished; this component assembles none. */
|
|
336
|
-
interface ApiCredentialIndex {
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
}
|
|
363
|
-
type IssuedApiCredential = {
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
445
|
+
export interface ApiCredentialIndex {
|
|
446
|
+
scopes: ApiCredentialScope[];
|
|
447
|
+
token_lifetimes: string[];
|
|
448
|
+
/** Null while issuing is unavailable (the OAuth server is switched off). Revocation stays available. */
|
|
449
|
+
issue_token_href: string | null;
|
|
450
|
+
register_app_href: string | null;
|
|
451
|
+
tokens: ApiCredentialToken[];
|
|
452
|
+
apps: ApiCredentialApp[];
|
|
453
|
+
/**
|
|
454
|
+
* Grouped picker data, all optional and presentation only: the credential still
|
|
455
|
+
* stores explicit scope ids. `scope_*` serves the OAuth-app form and, unless the
|
|
456
|
+
* matching `token_*` key is present, the token form. Without groups the picker is a flat list.
|
|
457
|
+
*/
|
|
458
|
+
scope_groups?: ApiCredentialScopeGroup[];
|
|
459
|
+
scope_presets?: ApiCredentialScopePreset[];
|
|
460
|
+
/** scope id => scope ids it needs: ticking a scope ticks them, unticking one unticks what needs it. */
|
|
461
|
+
scope_implications?: ScopeImplications;
|
|
462
|
+
/** A narrower scope list for personal tokens, when the server offers one. */
|
|
463
|
+
token_scopes?: ApiCredentialScope[];
|
|
464
|
+
token_scope_groups?: ApiCredentialScopeGroup[];
|
|
465
|
+
token_scope_presets?: ApiCredentialScopePreset[];
|
|
466
|
+
token_scope_implications?: ScopeImplications;
|
|
467
|
+
/** Offered to personal tokens only: MCP connection scopes, listed after the token scopes. */
|
|
468
|
+
token_connection_scopes?: ApiCredentialScope[];
|
|
469
|
+
/** The lifetimes a token carrying a connection scope may have; replaces `token_lifetimes` for it. */
|
|
470
|
+
connection_token_lifetimes?: string[];
|
|
471
|
+
}
|
|
472
|
+
export type IssuedApiCredential = {
|
|
473
|
+
kind: 'token';
|
|
474
|
+
name: string;
|
|
475
|
+
token: string;
|
|
476
|
+
expires_at?: string;
|
|
368
477
|
} | {
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
478
|
+
kind: 'app';
|
|
479
|
+
name: string;
|
|
480
|
+
client_id: string;
|
|
481
|
+
client_secret: string | null;
|
|
373
482
|
};
|
|
374
|
-
interface ApiCredentialEndpointLink {
|
|
375
|
-
|
|
376
|
-
|
|
483
|
+
export interface ApiCredentialEndpointLink {
|
|
484
|
+
label: string;
|
|
485
|
+
url: string;
|
|
377
486
|
}
|
|
378
487
|
/**
|
|
379
488
|
* The outcome of one credential request: on success the parsed JSON body
|
|
380
489
|
* (the component reads its `data` when present), on failure the message to show.
|
|
381
490
|
*/
|
|
382
|
-
type ApiCredentialRequestResult = {
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
491
|
+
export type ApiCredentialRequestResult = {
|
|
492
|
+
ok: true;
|
|
493
|
+
status: number;
|
|
494
|
+
payload: unknown;
|
|
386
495
|
} | {
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
496
|
+
ok: false;
|
|
497
|
+
status: number;
|
|
498
|
+
message: string;
|
|
390
499
|
};
|
|
391
500
|
/**
|
|
392
501
|
* Performs one credential request in place of the built-in `fetch`, so an app
|
|
393
502
|
* can route it through its own client (session-expiry redirect, CSRF, retries).
|
|
394
503
|
*/
|
|
395
|
-
type ApiCredentialRequest = (method: 'GET' | 'POST' | 'DELETE', url: string, body?: object) => Promise<ApiCredentialRequestResult>;
|
|
396
|
-
interface ApiCredentialsSectionProps {
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
504
|
+
export type ApiCredentialRequest = (method: 'GET' | 'POST' | 'DELETE', url: string, body?: object) => Promise<ApiCredentialRequestResult>;
|
|
505
|
+
export interface ApiCredentialsSectionProps {
|
|
506
|
+
/** The credential service's index URL (GET). */
|
|
507
|
+
indexUrl: string;
|
|
508
|
+
components: AuthComponentInput;
|
|
509
|
+
/** Values a connector needs: the OpenAPI document, API base, OAuth authorize/token URLs, MCP URL. */
|
|
510
|
+
links?: ApiCredentialEndpointLink[];
|
|
511
|
+
csrfToken?: string;
|
|
512
|
+
/** Replaces the built-in `fetch` for every credential request; `csrfToken` is then the app's to send. */
|
|
513
|
+
request?: ApiCredentialRequest;
|
|
514
|
+
onSuccess?: (message: string) => void;
|
|
515
|
+
onError?: (field: string, message: string) => void;
|
|
516
|
+
/**
|
|
517
|
+
* `stacked` (default) puts the token and OAuth-app sections one under the other.
|
|
518
|
+
* `columns` lays them side by side when the container is wide enough (about 960px);
|
|
519
|
+
* narrower containers stack them.
|
|
520
|
+
*/
|
|
521
|
+
layout?: 'stacked' | 'columns';
|
|
413
522
|
}
|
|
414
523
|
/**
|
|
415
524
|
* A person's credentials for apps that use the API: personal API tokens (for
|
|
@@ -420,9 +529,151 @@ interface ApiCredentialsSectionProps {
|
|
|
420
529
|
* in this component's memory; afterwards only the lists are reloaded, so it is
|
|
421
530
|
* never part of page props or browser history.
|
|
422
531
|
*/
|
|
423
|
-
declare function ApiCredentialsSection({ indexUrl, components, links, csrfToken, request, onSuccess, onError, layout }: ApiCredentialsSectionProps): React.JSX.Element;
|
|
532
|
+
export declare function ApiCredentialsSection({ indexUrl, components, links, csrfToken, request, onSuccess, onError, layout }: ApiCredentialsSectionProps): React.JSX.Element;
|
|
424
533
|
/** PT4H → "4 hours", P30D → "30 days", P1Y → "1 year". Unknown shapes are shown as given. */
|
|
425
|
-
declare function describeDuration(spec: string): string;
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
534
|
+
export declare function describeDuration(spec: string): string;
|
|
535
|
+
/**
|
|
536
|
+
* Conditions that commonly break sign-in links and flows.
|
|
537
|
+
*
|
|
538
|
+
* - `automated`: an automated or headless browser, as used by email security scanners and
|
|
539
|
+
* link previews that open a link before the person does.
|
|
540
|
+
* - `framed`: the page is inside a frame, e.g. an email client's preview pane.
|
|
541
|
+
* - `in-app-browser`: an embedded webview inside another app, which keeps its own cookies
|
|
542
|
+
* and often cannot complete passkey or redirect-based sign-in.
|
|
543
|
+
* - `cookies-disabled`: cookies cannot be set or read, so no session can be kept.
|
|
544
|
+
* - `storage-unavailable`: site storage is blocked (a restricted or read-only context).
|
|
545
|
+
*/
|
|
546
|
+
export type AuthBrowserIssueKind = 'automated' | 'framed' | 'in-app-browser' | 'cookies-disabled' | 'storage-unavailable';
|
|
547
|
+
export interface AuthBrowserIssue {
|
|
548
|
+
kind: AuthBrowserIssueKind;
|
|
549
|
+
/** For `in-app-browser`: the host app, when recognised from the user agent. */
|
|
550
|
+
app?: string;
|
|
551
|
+
}
|
|
552
|
+
/** What detection reads. Every field is optional; a missing one is treated as "no problem". */
|
|
553
|
+
export interface AuthBrowserEnvironment {
|
|
554
|
+
userAgent?: string;
|
|
555
|
+
/** `navigator.webdriver`. */
|
|
556
|
+
webdriver?: boolean;
|
|
557
|
+
/** The page is not the top-level browsing context. */
|
|
558
|
+
framed?: boolean;
|
|
559
|
+
/** `navigator.cookieEnabled`. */
|
|
560
|
+
cookieEnabled?: boolean;
|
|
561
|
+
/** A short-lived test cookie could be written and read back. */
|
|
562
|
+
cookiesWritable?: boolean;
|
|
563
|
+
/** `localStorage` could be written. */
|
|
564
|
+
storageAvailable?: boolean;
|
|
565
|
+
/** Running as an installed home-screen web app, whose iOS user agent also lacks a "Safari/" token. */
|
|
566
|
+
standalone?: boolean;
|
|
567
|
+
}
|
|
568
|
+
/** Read the current browser's environment. Returns `{}` during server rendering. */
|
|
569
|
+
export declare function readAuthBrowserEnvironment(): AuthBrowserEnvironment;
|
|
570
|
+
/** Name the conditions in `environment` that are likely to break sign-in, most fundamental first. */
|
|
571
|
+
export declare function detectAuthBrowserIssues(environment?: AuthBrowserEnvironment): AuthBrowserIssue[];
|
|
572
|
+
export interface AuthBrowserHelpCopy {
|
|
573
|
+
title?: React.ReactNode;
|
|
574
|
+
body?: React.ReactNode;
|
|
575
|
+
}
|
|
576
|
+
/** Only `Button` is required; an `Alert` is used when given, otherwise a `<div role="status">`. */
|
|
577
|
+
export type AuthBrowserHelpComponents = Pick<AuthComponentSet, 'Button'> & Partial<Pick<AuthComponentSet, 'Alert'>>;
|
|
578
|
+
export interface AuthBrowserHelpProps {
|
|
579
|
+
components: AuthBrowserHelpComponents;
|
|
580
|
+
/** Show these instead of detecting, e.g. from a server-side user-agent check. */
|
|
581
|
+
issues?: AuthBrowserIssue[];
|
|
582
|
+
/** Detect from this environment instead of the live browser. */
|
|
583
|
+
environment?: AuthBrowserEnvironment;
|
|
584
|
+
/** Kinds never to show. */
|
|
585
|
+
ignore?: AuthBrowserIssueKind[];
|
|
586
|
+
/** Replace the title and/or body for a kind. */
|
|
587
|
+
messages?: Partial<Record<AuthBrowserIssueKind, AuthBrowserHelpCopy>>;
|
|
588
|
+
/** The address offered by "Copy link" and "Open in a new tab". Defaults to the current page. */
|
|
589
|
+
url?: string;
|
|
590
|
+
className?: string;
|
|
591
|
+
/** Called once detection has run (also with an empty list), e.g. to hold back an auto-submit. */
|
|
592
|
+
onDetect?: (issues: AuthBrowserIssue[]) => void;
|
|
593
|
+
}
|
|
594
|
+
/**
|
|
595
|
+
* Guidance for browsers and contexts that commonly break sign-in links and flows.
|
|
596
|
+
*
|
|
597
|
+
* Detection runs after mount, so server rendering and the first client render show
|
|
598
|
+
* nothing and hydrate identically. Nothing renders when no issue applies.
|
|
599
|
+
*/
|
|
600
|
+
export declare function AuthBrowserHelp({ components, issues: givenIssues, environment, ignore, messages, url, className, onDetect }: AuthBrowserHelpProps): React.JSX.Element | null;
|
|
601
|
+
/** Events auth-laravel's audit logger records (`BWH\Auth\Models\AuthAuditLog::EVENT_*`). */
|
|
602
|
+
export type AuthAuditEvent = 'login_succeeded' | 'login_failed' | 'login_blocked' | 'logged_out' | 'two_factor_challenge_created' | 'two_factor_succeeded' | 'two_factor_failed' | 'two_factor_reported_suspicious' | 'passkey_registered' | 'passkey_deleted' | 'passkey_login_succeeded' | 'passkey_login_failed' | 'password_reset_requested' | 'password_reset_completed' | 'password_changed';
|
|
603
|
+
/** One row of `GET /api/auth/audit-log`: an `auth_audit_log` record as the server serialises it. */
|
|
604
|
+
export interface AuthAuditLogEntry {
|
|
605
|
+
id: number;
|
|
606
|
+
user_id: number | null;
|
|
607
|
+
acting_user_id: number | null;
|
|
608
|
+
email: string | null;
|
|
609
|
+
/** A known `AuthAuditEvent`, or an event an application records itself. */
|
|
610
|
+
event: AuthAuditEvent | (string & {});
|
|
611
|
+
/** `password`, `passkey`, `two_factor`, another method an application records, or `null`. */
|
|
612
|
+
auth_method: string | null;
|
|
613
|
+
succeeded: boolean;
|
|
614
|
+
reason: string | null;
|
|
615
|
+
/** Text form (IPv4 or IPv6); the server stores it as binary and converts it back. */
|
|
616
|
+
ip_address: string | null;
|
|
617
|
+
user_agent: string | null;
|
|
618
|
+
session_id: string | null;
|
|
619
|
+
is_suspicious: boolean;
|
|
620
|
+
metadata: Record<string, unknown> | null;
|
|
621
|
+
/** ISO-8601 timestamps. */
|
|
622
|
+
created_at: string | null;
|
|
623
|
+
updated_at: string | null;
|
|
624
|
+
/** Not sent by auth-laravel; shown when an application adds a location to each row. */
|
|
625
|
+
location?: string | null;
|
|
626
|
+
}
|
|
627
|
+
/** The Laravel length-aware paginator body the endpoint returns. */
|
|
628
|
+
export interface AuthAuditLogPage {
|
|
629
|
+
current_page: number;
|
|
630
|
+
data: AuthAuditLogEntry[];
|
|
631
|
+
last_page: number;
|
|
632
|
+
per_page: number;
|
|
633
|
+
total: number;
|
|
634
|
+
from: number | null;
|
|
635
|
+
to: number | null;
|
|
636
|
+
next_page_url: string | null;
|
|
637
|
+
prev_page_url: string | null;
|
|
638
|
+
}
|
|
639
|
+
/** The events `SignInHistory` shows by default: sign-in attempts and their second factor. */
|
|
640
|
+
export declare const SIGN_IN_AUDIT_EVENTS: readonly AuthAuditEvent[];
|
|
641
|
+
/**
|
|
642
|
+
* Validate an audit-log response into a page that is safe to render, or `null` if it is not one.
|
|
643
|
+
* Malformed rows are dropped rather than failing the whole page.
|
|
644
|
+
*/
|
|
645
|
+
export declare function parseAuthAuditLogPage(payload: unknown): AuthAuditLogPage | null;
|
|
646
|
+
/**
|
|
647
|
+
* Performs one GET in place of the built-in `fetch`, e.g. through the app's own HTTP client.
|
|
648
|
+
* Resolve with the parsed paginator body as `payload`, or with `{ ok: false, status, message }`.
|
|
649
|
+
*/
|
|
650
|
+
export type SignInHistoryRequest = (url: string) => Promise<ApiCredentialRequestResult>;
|
|
651
|
+
/** Only `Button` is required. `Alert` (errors) and `Badge` (result and flag labels) fall back to native elements. */
|
|
652
|
+
export type SignInHistoryComponents = Pick<AuthComponentSet, 'Button'> & Partial<Pick<AuthComponentSet, 'Alert' | 'Badge'>>;
|
|
653
|
+
export interface SignInHistoryProps {
|
|
654
|
+
components: SignInHistoryComponents;
|
|
655
|
+
/** The audit-log endpoint. Defaults to auth-laravel's `/api/auth/audit-log`. */
|
|
656
|
+
url?: string;
|
|
657
|
+
/** Rows per request, 1 to 100 (the server's limit). Defaults to 20. */
|
|
658
|
+
perPage?: number;
|
|
659
|
+
/** Events to show. Defaults to `SIGN_IN_AUDIT_EVENTS`; `'all'` shows every recorded event. */
|
|
660
|
+
events?: readonly string[] | 'all';
|
|
661
|
+
/** Replaces the built-in `fetch`. */
|
|
662
|
+
request?: SignInHistoryRequest;
|
|
663
|
+
/** Formats `created_at`. Defaults to the browser's locale date and time. */
|
|
664
|
+
formatTime?: (iso: string) => string;
|
|
665
|
+
eventLabels?: Partial<Record<string, React.ReactNode>>;
|
|
666
|
+
methodLabels?: Partial<Record<string, React.ReactNode>>;
|
|
667
|
+
emptyMessage?: React.ReactNode;
|
|
668
|
+
/** Accessible name for the table. */
|
|
669
|
+
label?: string;
|
|
670
|
+
className?: string;
|
|
671
|
+
onError?: (message: string) => void;
|
|
672
|
+
}
|
|
673
|
+
/**
|
|
674
|
+
* The signed-in person's recent sign-in activity, read from auth-laravel's audit-log
|
|
675
|
+
* endpoint (`GET /api/auth/audit-log`, enabled by `bherila-auth.audit.routes_enabled`,
|
|
676
|
+
* session-authenticated). Newest first, with "Load more" for older pages.
|
|
677
|
+
*/
|
|
678
|
+
export declare function SignInHistory({ components, url, perPage, events, request, formatTime, eventLabels, methodLabels, emptyMessage, label, className, onError }: SignInHistoryProps): React.JSX.Element;
|
|
679
|
+
export {};
|