bwh-auth 0.3.0 → 0.3.1

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 CHANGED
@@ -169,6 +169,21 @@ import { SignupForm, registerPasskey } from 'bwh-auth'
169
169
  />
170
170
  ```
171
171
 
172
+ Consumers can preserve app-specific login state and design-system checkboxes
173
+ without rebuilding the form:
174
+
175
+ ```tsx
176
+ <LoginForm
177
+ components={getShadcnComponents()}
178
+ initialEmail={verifiedEmail}
179
+ onEmailChange={setForgotPasswordEmail}
180
+ rememberMeCheckbox={Checkbox}
181
+ rememberMeLabel="Remember me"
182
+ rememberMeDataTest="login-remember-me"
183
+ onSubmitStart={clearLoginMessages}
184
+ />
185
+ ```
186
+
172
187
  The explicit passkey button and conditional autofill both default to the Laravel package routes:
173
188
 
174
189
  - `POST /api/passkeys/auth/options`
package/dist/index.cjs CHANGED
@@ -314,24 +314,50 @@ async function postForm(url, body, csrfToken) {
314
314
  },
315
315
  body: JSON.stringify(body)
316
316
  });
317
- const result = await response.json();
317
+ let decoded;
318
+ try {
319
+ decoded = await response.json();
320
+ } catch {
321
+ throw new AuthRequestError("The server returned an unexpected response. Please try again.", {});
322
+ }
323
+ if (decoded === null || typeof decoded !== "object" || Array.isArray(decoded)) {
324
+ throw new AuthRequestError("The server returned an unexpected response. Please try again.", {});
325
+ }
326
+ const result = decoded;
318
327
  if (!response.ok) {
319
328
  throw new AuthRequestError(result.message || result.error || "Request failed", result);
320
329
  }
321
330
  return result;
322
331
  }
332
+ function DefaultRememberMeCheckbox({ checked, onCheckedChange, ...props }) {
333
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
334
+ "input",
335
+ {
336
+ ...props,
337
+ type: "checkbox",
338
+ checked,
339
+ onChange: (event) => onCheckedChange(event.target.checked)
340
+ }
341
+ );
342
+ }
323
343
  function LoginForm({
324
344
  endpoints = {},
325
345
  components,
326
346
  onSuccess,
327
347
  onError,
348
+ initialEmail = "",
349
+ onEmailChange,
350
+ rememberMeCheckbox: RememberMeCheckbox = DefaultRememberMeCheckbox,
351
+ rememberMeLabel = "Keep me signed in",
352
+ rememberMeDataTest,
353
+ onSubmitStart,
328
354
  onTwoFactorRequired,
329
355
  onPasskeySuccess,
330
356
  enablePasskeys = false,
331
357
  enablePasskeyAutofill = enablePasskeys
332
358
  }) {
333
359
  const { Button, Card, CardContent, CardHeader, CardTitle, Input, Label } = resolveAuthComponents(components);
334
- const [email, setEmail] = React2.useState("");
360
+ const [email, setEmail] = React2.useState(initialEmail);
335
361
  const [password, setPassword] = React2.useState("");
336
362
  const [remember, setRemember] = React2.useState(false);
337
363
  const [loading, setLoading] = React2.useState(false);
@@ -375,6 +401,7 @@ function LoginForm({
375
401
  }, [enablePasskeyAutofill, onError, onPasskeySuccess, passkeyEndpoints]);
376
402
  async function onSubmit(event) {
377
403
  event.preventDefault();
404
+ onSubmitStart?.();
378
405
  setLoading(true);
379
406
  try {
380
407
  const result = await postForm(endpoints.login ?? "/login", { email, password, remember }, endpoints.csrfToken);
@@ -399,15 +426,37 @@ function LoginForm({
399
426
  /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("form", { className: "space-y-4", onSubmit: (event) => void onSubmit(event), children: [
400
427
  /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "space-y-1", children: [
401
428
  /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Label, { htmlFor: "login-email", children: "Email" }),
402
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Input, { id: "login-email", type: "email", autoComplete: conditionalPasskeyAvailable ? "username webauthn" : "email", required: true, value: email, onChange: (event) => setEmail(event.target.value) })
429
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
430
+ Input,
431
+ {
432
+ id: "login-email",
433
+ type: "email",
434
+ autoComplete: conditionalPasskeyAvailable ? "username webauthn" : "email",
435
+ required: true,
436
+ value: email,
437
+ onChange: (event) => {
438
+ setEmail(event.target.value);
439
+ onEmailChange?.(event.target.value);
440
+ }
441
+ }
442
+ )
403
443
  ] }),
404
444
  /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "space-y-1", children: [
405
445
  /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Label, { htmlFor: "login-password", children: "Password" }),
406
446
  /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Input, { id: "login-password", type: "password", autoComplete: "current-password", required: true, value: password, onChange: (event) => setPassword(event.target.value) })
407
447
  ] }),
408
- /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("label", { className: "flex items-center gap-2 text-sm", children: [
409
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("input", { type: "checkbox", checked: remember, onChange: (event) => setRemember(event.target.checked) }),
410
- "Keep me signed in"
448
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "flex items-center gap-2 text-sm", children: [
449
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
450
+ RememberMeCheckbox,
451
+ {
452
+ id: "login-remember",
453
+ "aria-labelledby": "login-remember-label",
454
+ "data-test": rememberMeDataTest,
455
+ checked: remember,
456
+ onCheckedChange: setRemember
457
+ }
458
+ ),
459
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Label, { id: "login-remember-label", htmlFor: "login-remember", children: rememberMeLabel })
411
460
  ] }),
412
461
  /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Button, { type: "submit", className: "w-full", disabled: loading, children: loading ? "Signing in..." : "Sign In" })
413
462
  ] }),
package/dist/index.d.cts CHANGED
@@ -1,4 +1,3 @@
1
- import * as react_jsx_runtime from 'react/jsx-runtime';
2
1
  import * as React from 'react';
3
2
 
4
3
  interface AuthEndpointConfig {
@@ -85,9 +84,22 @@ interface AuthFormProps {
85
84
  onSuccess?: (result: AuthJsonResponse) => void;
86
85
  onError?: (message: string) => void;
87
86
  }
87
+ interface LoginRememberMeCheckboxProps {
88
+ id: string;
89
+ checked: boolean;
90
+ onCheckedChange: (checked: boolean) => void;
91
+ 'aria-labelledby'?: string;
92
+ 'data-test'?: string;
93
+ }
88
94
  interface LoginFormProps extends AuthFormProps {
89
95
  enablePasskeys?: boolean;
90
96
  enablePasskeyAutofill?: boolean;
97
+ initialEmail?: string;
98
+ onEmailChange?: (email: string) => void;
99
+ rememberMeCheckbox?: React.ComponentType<LoginRememberMeCheckboxProps>;
100
+ rememberMeLabel?: React.ReactNode;
101
+ rememberMeDataTest?: string;
102
+ onSubmitStart?: () => void;
91
103
  onTwoFactorRequired?: (result: AuthJsonResponse & {
92
104
  attempt_token?: string;
93
105
  }) => void;
@@ -113,12 +125,12 @@ interface TwoFactorFormProps extends AuthFormProps {
113
125
  appEnv?: string;
114
126
  onReportSuspicious?: (result: AuthJsonResponse) => void;
115
127
  }
116
- declare function LoginForm({ endpoints, components, onSuccess, onError, onTwoFactorRequired, onPasskeySuccess, enablePasskeys, enablePasskeyAutofill, }: LoginFormProps): react_jsx_runtime.JSX.Element;
117
- declare function SignupForm({ endpoints, components, onSuccess, onError, fields, initialValues, errors, submitMode, title, description, submitLabel, submittingLabel, }: SignupFormProps): react_jsx_runtime.JSX.Element;
118
- declare function PasswordResetRequestForm({ endpoints, components, onSuccess, onError }: AuthFormProps): react_jsx_runtime.JSX.Element;
119
- declare function ResetPasswordForm({ endpoints, components, onSuccess, onError, token: initialToken, email: initialEmail }: ResetPasswordFormProps): react_jsx_runtime.JSX.Element;
120
- declare function ChangePasswordForm({ endpoints, components, onSuccess, onError }: AuthFormProps): react_jsx_runtime.JSX.Element;
121
- declare function TwoFactorForm({ endpoints, components, attemptToken, appEnv, onSuccess, onError, onReportSuspicious }: TwoFactorFormProps): react_jsx_runtime.JSX.Element;
128
+ declare function LoginForm({ endpoints, components, onSuccess, onError, initialEmail, onEmailChange, rememberMeCheckbox: RememberMeCheckbox, rememberMeLabel, rememberMeDataTest, onSubmitStart, onTwoFactorRequired, onPasskeySuccess, enablePasskeys, enablePasskeyAutofill, }: LoginFormProps): React.JSX.Element;
129
+ declare function SignupForm({ endpoints, components, onSuccess, onError, fields, initialValues, errors, submitMode, title, description, submitLabel, submittingLabel, }: SignupFormProps): React.JSX.Element;
130
+ declare function PasswordResetRequestForm({ endpoints, components, onSuccess, onError }: AuthFormProps): React.JSX.Element;
131
+ declare function ResetPasswordForm({ endpoints, components, onSuccess, onError, token: initialToken, email: initialEmail }: ResetPasswordFormProps): React.JSX.Element;
132
+ declare function ChangePasswordForm({ endpoints, components, onSuccess, onError }: AuthFormProps): React.JSX.Element;
133
+ declare function TwoFactorForm({ endpoints, components, attemptToken, appEnv, onSuccess, onError, onReportSuspicious }: TwoFactorFormProps): React.JSX.Element;
122
134
 
123
135
  interface PasskeyLoginButtonProps {
124
136
  endpoints?: AuthEndpointConfig;
@@ -127,7 +139,7 @@ interface PasskeyLoginButtonProps {
127
139
  onSuccess?: (redirectUrl: string, result: AuthJsonResponse) => void;
128
140
  onError?: (message: string) => void;
129
141
  }
130
- declare function PasskeyLoginButton({ endpoints, components, className, onSuccess, onError }: PasskeyLoginButtonProps): react_jsx_runtime.JSX.Element | null;
142
+ declare function PasskeyLoginButton({ endpoints, components, className, onSuccess, onError }: PasskeyLoginButtonProps): React.JSX.Element | null;
131
143
 
132
144
  interface PasskeySectionProps {
133
145
  endpoints?: AuthEndpointConfig;
@@ -135,7 +147,7 @@ interface PasskeySectionProps {
135
147
  onSuccess?: (message: string) => void;
136
148
  onError?: (field: string, message: string) => void;
137
149
  }
138
- declare function PasskeySection({ endpoints, components, onSuccess, onError }: PasskeySectionProps): react_jsx_runtime.JSX.Element;
150
+ declare function PasskeySection({ endpoints, components, onSuccess, onError }: PasskeySectionProps): React.JSX.Element;
139
151
 
140
152
  /**
141
153
  * The sibling applications an identity provider reports for the signed-in person.
@@ -201,4 +213,4 @@ declare function isConditionalMediationAvailable(): Promise<boolean>;
201
213
  declare function authenticateWithPasskey({ endpoints, mediation, signal }?: AuthenticateWithPasskeyOptions): Promise<PasskeyAuthenticationResult>;
202
214
  declare function registerPasskey({ endpoints, name, signal }?: RegisterPasskeyOptions): Promise<PasskeyRegistrationResult>;
203
215
 
204
- export { type AuthButtonComponent, type AuthButtonComponentInput, type AuthButtonComponentProps, type AuthButtonSize, type AuthButtonVariant, type AuthComponentInput, type AuthComponentOverrides, type AuthComponentSet, type AuthComponentSuperset, type AuthComponents, type AuthContainerComponentProps, type AuthEndpointConfig, type AuthInputComponentProps, type AuthJsonResponse, type AuthLabelComponentProps, type AuthSignupField, type AuthSignupValues, type AuthValidationErrors, ChangePasswordForm, LoginForm, type Passkey, PasskeyLoginButton, PasskeySection, PasswordResetRequestForm, type RelyingApplication, ResetPasswordForm, SignupForm, TwoFactorForm, arrayBufferToBase64url, authenticateWithPasskey, base64urlToArrayBuffer, getCsrfToken, getDefaultPasskeyName, isAbortError, isConditionalMediationAvailable, registerPasskey, relyingApplicationsFrom, safeApplicationHref };
216
+ export { type AuthButtonComponent, type AuthButtonComponentInput, type AuthButtonComponentProps, type AuthButtonSize, type AuthButtonVariant, type AuthComponentInput, type AuthComponentOverrides, type AuthComponentSet, type AuthComponentSuperset, type AuthComponents, type AuthContainerComponentProps, type AuthEndpointConfig, type AuthInputComponentProps, type AuthJsonResponse, type AuthLabelComponentProps, type AuthSignupField, type AuthSignupValues, type AuthValidationErrors, ChangePasswordForm, LoginForm, type LoginFormProps, type LoginRememberMeCheckboxProps, type Passkey, PasskeyLoginButton, PasskeySection, PasswordResetRequestForm, type RelyingApplication, ResetPasswordForm, SignupForm, TwoFactorForm, arrayBufferToBase64url, authenticateWithPasskey, base64urlToArrayBuffer, getCsrfToken, getDefaultPasskeyName, isAbortError, isConditionalMediationAvailable, registerPasskey, relyingApplicationsFrom, safeApplicationHref };
package/dist/index.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- import * as react_jsx_runtime from 'react/jsx-runtime';
2
1
  import * as React from 'react';
3
2
 
4
3
  interface AuthEndpointConfig {
@@ -85,9 +84,22 @@ interface AuthFormProps {
85
84
  onSuccess?: (result: AuthJsonResponse) => void;
86
85
  onError?: (message: string) => void;
87
86
  }
87
+ interface LoginRememberMeCheckboxProps {
88
+ id: string;
89
+ checked: boolean;
90
+ onCheckedChange: (checked: boolean) => void;
91
+ 'aria-labelledby'?: string;
92
+ 'data-test'?: string;
93
+ }
88
94
  interface LoginFormProps extends AuthFormProps {
89
95
  enablePasskeys?: boolean;
90
96
  enablePasskeyAutofill?: boolean;
97
+ initialEmail?: string;
98
+ onEmailChange?: (email: string) => void;
99
+ rememberMeCheckbox?: React.ComponentType<LoginRememberMeCheckboxProps>;
100
+ rememberMeLabel?: React.ReactNode;
101
+ rememberMeDataTest?: string;
102
+ onSubmitStart?: () => void;
91
103
  onTwoFactorRequired?: (result: AuthJsonResponse & {
92
104
  attempt_token?: string;
93
105
  }) => void;
@@ -113,12 +125,12 @@ interface TwoFactorFormProps extends AuthFormProps {
113
125
  appEnv?: string;
114
126
  onReportSuspicious?: (result: AuthJsonResponse) => void;
115
127
  }
116
- declare function LoginForm({ endpoints, components, onSuccess, onError, onTwoFactorRequired, onPasskeySuccess, enablePasskeys, enablePasskeyAutofill, }: LoginFormProps): react_jsx_runtime.JSX.Element;
117
- declare function SignupForm({ endpoints, components, onSuccess, onError, fields, initialValues, errors, submitMode, title, description, submitLabel, submittingLabel, }: SignupFormProps): react_jsx_runtime.JSX.Element;
118
- declare function PasswordResetRequestForm({ endpoints, components, onSuccess, onError }: AuthFormProps): react_jsx_runtime.JSX.Element;
119
- declare function ResetPasswordForm({ endpoints, components, onSuccess, onError, token: initialToken, email: initialEmail }: ResetPasswordFormProps): react_jsx_runtime.JSX.Element;
120
- declare function ChangePasswordForm({ endpoints, components, onSuccess, onError }: AuthFormProps): react_jsx_runtime.JSX.Element;
121
- declare function TwoFactorForm({ endpoints, components, attemptToken, appEnv, onSuccess, onError, onReportSuspicious }: TwoFactorFormProps): react_jsx_runtime.JSX.Element;
128
+ declare function LoginForm({ endpoints, components, onSuccess, onError, initialEmail, onEmailChange, rememberMeCheckbox: RememberMeCheckbox, rememberMeLabel, rememberMeDataTest, onSubmitStart, onTwoFactorRequired, onPasskeySuccess, enablePasskeys, enablePasskeyAutofill, }: LoginFormProps): React.JSX.Element;
129
+ declare function SignupForm({ endpoints, components, onSuccess, onError, fields, initialValues, errors, submitMode, title, description, submitLabel, submittingLabel, }: SignupFormProps): React.JSX.Element;
130
+ declare function PasswordResetRequestForm({ endpoints, components, onSuccess, onError }: AuthFormProps): React.JSX.Element;
131
+ declare function ResetPasswordForm({ endpoints, components, onSuccess, onError, token: initialToken, email: initialEmail }: ResetPasswordFormProps): React.JSX.Element;
132
+ declare function ChangePasswordForm({ endpoints, components, onSuccess, onError }: AuthFormProps): React.JSX.Element;
133
+ declare function TwoFactorForm({ endpoints, components, attemptToken, appEnv, onSuccess, onError, onReportSuspicious }: TwoFactorFormProps): React.JSX.Element;
122
134
 
123
135
  interface PasskeyLoginButtonProps {
124
136
  endpoints?: AuthEndpointConfig;
@@ -127,7 +139,7 @@ interface PasskeyLoginButtonProps {
127
139
  onSuccess?: (redirectUrl: string, result: AuthJsonResponse) => void;
128
140
  onError?: (message: string) => void;
129
141
  }
130
- declare function PasskeyLoginButton({ endpoints, components, className, onSuccess, onError }: PasskeyLoginButtonProps): react_jsx_runtime.JSX.Element | null;
142
+ declare function PasskeyLoginButton({ endpoints, components, className, onSuccess, onError }: PasskeyLoginButtonProps): React.JSX.Element | null;
131
143
 
132
144
  interface PasskeySectionProps {
133
145
  endpoints?: AuthEndpointConfig;
@@ -135,7 +147,7 @@ interface PasskeySectionProps {
135
147
  onSuccess?: (message: string) => void;
136
148
  onError?: (field: string, message: string) => void;
137
149
  }
138
- declare function PasskeySection({ endpoints, components, onSuccess, onError }: PasskeySectionProps): react_jsx_runtime.JSX.Element;
150
+ declare function PasskeySection({ endpoints, components, onSuccess, onError }: PasskeySectionProps): React.JSX.Element;
139
151
 
140
152
  /**
141
153
  * The sibling applications an identity provider reports for the signed-in person.
@@ -201,4 +213,4 @@ declare function isConditionalMediationAvailable(): Promise<boolean>;
201
213
  declare function authenticateWithPasskey({ endpoints, mediation, signal }?: AuthenticateWithPasskeyOptions): Promise<PasskeyAuthenticationResult>;
202
214
  declare function registerPasskey({ endpoints, name, signal }?: RegisterPasskeyOptions): Promise<PasskeyRegistrationResult>;
203
215
 
204
- export { type AuthButtonComponent, type AuthButtonComponentInput, type AuthButtonComponentProps, type AuthButtonSize, type AuthButtonVariant, type AuthComponentInput, type AuthComponentOverrides, type AuthComponentSet, type AuthComponentSuperset, type AuthComponents, type AuthContainerComponentProps, type AuthEndpointConfig, type AuthInputComponentProps, type AuthJsonResponse, type AuthLabelComponentProps, type AuthSignupField, type AuthSignupValues, type AuthValidationErrors, ChangePasswordForm, LoginForm, type Passkey, PasskeyLoginButton, PasskeySection, PasswordResetRequestForm, type RelyingApplication, ResetPasswordForm, SignupForm, TwoFactorForm, arrayBufferToBase64url, authenticateWithPasskey, base64urlToArrayBuffer, getCsrfToken, getDefaultPasskeyName, isAbortError, isConditionalMediationAvailable, registerPasskey, relyingApplicationsFrom, safeApplicationHref };
216
+ export { type AuthButtonComponent, type AuthButtonComponentInput, type AuthButtonComponentProps, type AuthButtonSize, type AuthButtonVariant, type AuthComponentInput, type AuthComponentOverrides, type AuthComponentSet, type AuthComponentSuperset, type AuthComponents, type AuthContainerComponentProps, type AuthEndpointConfig, type AuthInputComponentProps, type AuthJsonResponse, type AuthLabelComponentProps, type AuthSignupField, type AuthSignupValues, type AuthValidationErrors, ChangePasswordForm, LoginForm, type LoginFormProps, type LoginRememberMeCheckboxProps, type Passkey, PasskeyLoginButton, PasskeySection, PasswordResetRequestForm, type RelyingApplication, ResetPasswordForm, SignupForm, TwoFactorForm, arrayBufferToBase64url, authenticateWithPasskey, base64urlToArrayBuffer, getCsrfToken, getDefaultPasskeyName, isAbortError, isConditionalMediationAvailable, registerPasskey, relyingApplicationsFrom, safeApplicationHref };
package/dist/index.js CHANGED
@@ -261,24 +261,50 @@ async function postForm(url, body, csrfToken) {
261
261
  },
262
262
  body: JSON.stringify(body)
263
263
  });
264
- const result = await response.json();
264
+ let decoded;
265
+ try {
266
+ decoded = await response.json();
267
+ } catch {
268
+ throw new AuthRequestError("The server returned an unexpected response. Please try again.", {});
269
+ }
270
+ if (decoded === null || typeof decoded !== "object" || Array.isArray(decoded)) {
271
+ throw new AuthRequestError("The server returned an unexpected response. Please try again.", {});
272
+ }
273
+ const result = decoded;
265
274
  if (!response.ok) {
266
275
  throw new AuthRequestError(result.message || result.error || "Request failed", result);
267
276
  }
268
277
  return result;
269
278
  }
279
+ function DefaultRememberMeCheckbox({ checked, onCheckedChange, ...props }) {
280
+ return /* @__PURE__ */ jsx2(
281
+ "input",
282
+ {
283
+ ...props,
284
+ type: "checkbox",
285
+ checked,
286
+ onChange: (event) => onCheckedChange(event.target.checked)
287
+ }
288
+ );
289
+ }
270
290
  function LoginForm({
271
291
  endpoints = {},
272
292
  components,
273
293
  onSuccess,
274
294
  onError,
295
+ initialEmail = "",
296
+ onEmailChange,
297
+ rememberMeCheckbox: RememberMeCheckbox = DefaultRememberMeCheckbox,
298
+ rememberMeLabel = "Keep me signed in",
299
+ rememberMeDataTest,
300
+ onSubmitStart,
275
301
  onTwoFactorRequired,
276
302
  onPasskeySuccess,
277
303
  enablePasskeys = false,
278
304
  enablePasskeyAutofill = enablePasskeys
279
305
  }) {
280
306
  const { Button, Card, CardContent, CardHeader, CardTitle, Input, Label } = resolveAuthComponents(components);
281
- const [email, setEmail] = React2.useState("");
307
+ const [email, setEmail] = React2.useState(initialEmail);
282
308
  const [password, setPassword] = React2.useState("");
283
309
  const [remember, setRemember] = React2.useState(false);
284
310
  const [loading, setLoading] = React2.useState(false);
@@ -322,6 +348,7 @@ function LoginForm({
322
348
  }, [enablePasskeyAutofill, onError, onPasskeySuccess, passkeyEndpoints]);
323
349
  async function onSubmit(event) {
324
350
  event.preventDefault();
351
+ onSubmitStart?.();
325
352
  setLoading(true);
326
353
  try {
327
354
  const result = await postForm(endpoints.login ?? "/login", { email, password, remember }, endpoints.csrfToken);
@@ -346,15 +373,37 @@ function LoginForm({
346
373
  /* @__PURE__ */ jsxs2("form", { className: "space-y-4", onSubmit: (event) => void onSubmit(event), children: [
347
374
  /* @__PURE__ */ jsxs2("div", { className: "space-y-1", children: [
348
375
  /* @__PURE__ */ jsx2(Label, { htmlFor: "login-email", children: "Email" }),
349
- /* @__PURE__ */ jsx2(Input, { id: "login-email", type: "email", autoComplete: conditionalPasskeyAvailable ? "username webauthn" : "email", required: true, value: email, onChange: (event) => setEmail(event.target.value) })
376
+ /* @__PURE__ */ jsx2(
377
+ Input,
378
+ {
379
+ id: "login-email",
380
+ type: "email",
381
+ autoComplete: conditionalPasskeyAvailable ? "username webauthn" : "email",
382
+ required: true,
383
+ value: email,
384
+ onChange: (event) => {
385
+ setEmail(event.target.value);
386
+ onEmailChange?.(event.target.value);
387
+ }
388
+ }
389
+ )
350
390
  ] }),
351
391
  /* @__PURE__ */ jsxs2("div", { className: "space-y-1", children: [
352
392
  /* @__PURE__ */ jsx2(Label, { htmlFor: "login-password", children: "Password" }),
353
393
  /* @__PURE__ */ jsx2(Input, { id: "login-password", type: "password", autoComplete: "current-password", required: true, value: password, onChange: (event) => setPassword(event.target.value) })
354
394
  ] }),
355
- /* @__PURE__ */ jsxs2("label", { className: "flex items-center gap-2 text-sm", children: [
356
- /* @__PURE__ */ jsx2("input", { type: "checkbox", checked: remember, onChange: (event) => setRemember(event.target.checked) }),
357
- "Keep me signed in"
395
+ /* @__PURE__ */ jsxs2("div", { className: "flex items-center gap-2 text-sm", children: [
396
+ /* @__PURE__ */ jsx2(
397
+ RememberMeCheckbox,
398
+ {
399
+ id: "login-remember",
400
+ "aria-labelledby": "login-remember-label",
401
+ "data-test": rememberMeDataTest,
402
+ checked: remember,
403
+ onCheckedChange: setRemember
404
+ }
405
+ ),
406
+ /* @__PURE__ */ jsx2(Label, { id: "login-remember-label", htmlFor: "login-remember", children: rememberMeLabel })
358
407
  ] }),
359
408
  /* @__PURE__ */ jsx2(Button, { type: "submit", className: "w-full", disabled: loading, children: loading ? "Signing in..." : "Sign In" })
360
409
  ] }),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bwh-auth",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
4
4
  "description": "Shared React auth UI and browser WebAuthn helpers for BWH applications.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -32,7 +32,8 @@
32
32
  "release": "node scripts/release.mjs",
33
33
  "test": "vitest run",
34
34
  "typecheck": "tsc --noEmit",
35
- "prepare": "pnpm run build"
35
+ "prepare": "pnpm run build",
36
+ "postinstall": "node scripts/spotlight-noindex.mjs"
36
37
  },
37
38
  "peerDependencies": {
38
39
  "lucide-react": ">=0.468.0 <2.0.0",
@@ -40,13 +41,17 @@
40
41
  "react-dom": "^18.3.0 || ^19.0.0"
41
42
  },
42
43
  "devDependencies": {
43
- "@types/node": "^26.3.0",
44
- "@types/react": "^19.2.14",
45
- "@types/react-dom": "^19.2.3",
44
+ "@testing-library/dom": "^10.4.2",
45
+ "@testing-library/react": "^16.3.3",
46
+ "@types/node": "^26.4.1",
47
+ "@types/react": "^19.2.18",
48
+ "@types/react-dom": "^19.2.7",
46
49
  "esbuild": "0.28.2",
50
+ "jsdom": "^27.4.0",
47
51
  "lucide-react": "^0.577.0",
48
- "react": "^19.2.6",
49
- "react-dom": "^19.2.6",
52
+ "react": "^19.2.8",
53
+ "react-dom": "^19.2.8",
54
+ "spotlight-noindex": "1.1.1",
50
55
  "tsup": "^8.5.1",
51
56
  "typescript": "^5.9.3",
52
57
  "vitest": "^3.2.7"