@krak-stack/auth 0.2.21 → 0.2.23

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/CHANGELOG.md CHANGED
@@ -1,5 +1,25 @@
1
1
  # @krak-stack/auth
2
2
 
3
+ ## 0.2.23
4
+
5
+ ### Patch Changes
6
+
7
+ - Add a reusable Effect Form `PasswordField` with optional recovery for existing-password prompts. Password sign-in sends recovery email for the entered address before opening the confirmation page, while account revocation, password changes, and two-factor settings send recovery email inline. Share request state, resend cooldowns, and confirmation controls across public recovery and account settings without adding router dependencies to the shared flow.
8
+
9
+ Preserve recovery confirmation across refreshes without resending email, accept plain and JSON-quoted confirmation timestamps, retain OAuth and return-destination context, and clear browser session cookies after a successful password reset. Include English and French recovery messages and regression coverage for OTP-only accounts, token reuse, and session revocation.
10
+
11
+ Use link-style Back controls above nested account-security and API-key dialog headings. Keep the active security page visible through the closing animation and reset nested state only after the dialog finishes closing, preventing the default page from flashing.
12
+
13
+ Use the registry's built-in list columns for organization and project memberships and user, organization, and admin API-key permissions, replacing custom list-summary cell renderers.
14
+
15
+ Show the account's sign-in email as its default, read-only primary contact email. Preserve it when saving contact details and exclude duplicate copies from the editable contact-email list.
16
+
17
+ ## 0.2.22
18
+
19
+ ### Patch Changes
20
+
21
+ - Update the KrakStack registry development dependency and minimum peer requirement to `0.1.48` for corrected image previews, full-width image inputs, file metadata, and non-overlapping replace/delete actions. Use compact, consistently sized icon and logo previews in account and organization forms without changing suggested upload resolutions.
22
+
3
23
  ## 0.2.21
4
24
 
5
25
  ### Patch Changes
@@ -149,8 +149,8 @@ export function AdminOrganizationForm({ organization, onClose, onSaved, }) {
149
149
  logo: assetUrl(organization?.logo, baseUrl),
150
150
  parentId: organization?.parentId ?? noParentOrganization,
151
151
  }, children: _jsxs("div", { className: "flex flex-col gap-4", children: [_jsx(form.name, { autoFocus: true, label: m.field_name }), _jsx(form.slug, { description: m.organization_slug_description, label: m.organization_slug }), _jsx(form.logo, { label: m.organization_field_logo_url, size: {
152
- width: 96,
153
- height: 96,
152
+ width: 140,
153
+ height: 40,
154
154
  suggestedWidth: 512,
155
155
  suggestedHeight: 512,
156
156
  } }), _jsx(form.parentId, { description: m.organization_parent_description, emptyLabel: m.organization_parent_empty, items: parentOptions, label: m.organization_parent, placeholder: m.organization_parent_none }), _jsx(SubmitError, { result: submitResult }), _jsx(SubmitButton, { form: form, children: m.form_submit })] }) })] }) }));
@@ -4,7 +4,7 @@ import { Cause, Effect, Schema } from "effect";
4
4
  import { Atom, AsyncResult } from "effect/reactivity";
5
5
  import { Building2, Pencil, Trash2, UserCog } from "lucide-react";
6
6
  import { useEffect, useState } from "react";
7
- import { DataTable, DataTableListSummary, } from "@krak-stack/registry/data-table";
7
+ import { DataTable, } from "@krak-stack/registry/data-table";
8
8
  import { Query } from "@krak-stack/registry/query";
9
9
  import { ErrorMessage } from "@krak-stack/registry/effect-form";
10
10
  import { AppBrand } from "@krak-stack/registry/app-brand";
@@ -309,14 +309,19 @@ const organizationColumns = (m, locale, baseUrl, impersonate, impersonateAsOrgan
309
309
  {
310
310
  field: "projects",
311
311
  headerName: m.admin_column_projects,
312
- cellRenderer: ({ data }) => (_jsx(DataTableListSummary, { emptyLabel: "-", items: (data.projects ?? []).map((project) => {
312
+ type: "list",
313
+ typeOptions: {
314
+ emptyLabel: "-",
315
+ getItems: (data) => (data.projects ?? []).map((project) => {
313
316
  const logo = assetUrl(project.logo, baseUrl);
314
317
  return {
315
318
  label: project.name,
316
319
  value: project.id,
317
320
  icon: logo ? (_jsx("img", { alt: "", className: "size-full object-cover", src: logo })) : (initials(project.name)),
318
321
  };
319
- }), display: "icon" })),
322
+ }),
323
+ display: "icon",
324
+ },
320
325
  },
321
326
  {
322
327
  field: "createdAt",
@@ -4,7 +4,7 @@ import { Atom, AsyncResult } from "effect/reactivity";
4
4
  import { Effect, Schema } from "effect";
5
5
  import { Ban, Loader2, ShieldOff, UserCog, UserIcon } from "lucide-react";
6
6
  import { useEffect, useState } from "react";
7
- import { DataTable, DataTableListSummary, } from "@krak-stack/registry/data-table";
7
+ import { DataTable, } from "@krak-stack/registry/data-table";
8
8
  import { Query } from "@krak-stack/registry/query";
9
9
  import { ErrorMessage } from "@krak-stack/registry/effect-form";
10
10
  import { AppBrand } from "@krak-stack/registry/app-brand";
@@ -242,26 +242,36 @@ const userColumns = (m, baseUrl) => [
242
242
  {
243
243
  field: "organizations",
244
244
  headerName: m.admin_column_organizations,
245
- cellRenderer: ({ data }) => (_jsx(DataTableListSummary, { emptyLabel: "-", items: data.organizations.map((organization) => {
245
+ type: "list",
246
+ typeOptions: {
247
+ emptyLabel: "-",
248
+ getItems: (data) => data.organizations.map((organization) => {
246
249
  const logo = assetUrl(organization.logo, baseUrl);
247
250
  return {
248
251
  label: organization.name,
249
252
  value: organization.id,
250
253
  icon: logo ? (_jsx("img", { alt: "", className: "size-full object-cover", src: logo })) : (initials(organization.name)),
251
254
  };
252
- }), display: "icon" })),
255
+ }),
256
+ display: "icon",
257
+ },
253
258
  },
254
259
  {
255
260
  field: "projects",
256
261
  headerName: m.admin_column_projects,
257
- cellRenderer: ({ data }) => (_jsx(DataTableListSummary, { emptyLabel: "-", items: data.projects.map((project) => {
262
+ type: "list",
263
+ typeOptions: {
264
+ emptyLabel: "-",
265
+ getItems: (data) => data.projects.map((project) => {
258
266
  const logo = assetUrl(project.logo, baseUrl);
259
267
  return {
260
268
  label: project.name,
261
269
  value: project.id,
262
270
  icon: logo ? (_jsx("img", { alt: "", className: "size-full object-cover", src: logo })) : (initials(project.name)),
263
271
  };
264
- }), display: "icon" })),
272
+ }),
273
+ display: "icon",
274
+ },
265
275
  },
266
276
  {
267
277
  field: "emailVerified",
@@ -15,6 +15,9 @@ import { Field, FieldLabel } from "@/components/ui/field";
15
15
  import { InputOTP, InputOTPGroup, InputOTPSeparator, InputOTPSlot, } from "@/components/ui/input-otp";
16
16
  import { getLastUsedLoginMethod, notifyAuthChange } from "./auth-atoms.js";
17
17
  import { authClientApi, authHttpClient } from "./auth-client-api.js";
18
+ import { PasswordField } from "./password-field.js";
19
+ import { passwordResetSearch, passwordResetConfirmation, passwordResetConfirmationSearch, passwordResetCallbackUrl, requestPasswordResetEmail, resetPasswordAndSignOut, } from "./password-reset.js";
20
+ import { PasswordResetActions, PasswordResetFeedback, usePasswordResetRequest, } from "./password-reset-flow.js";
18
21
  import { useKrakstackAuth } from "./auth-provider.js";
19
22
  import { cn } from "./utils.js";
20
23
  import { ExtraProjectPublicConfig as ExtraProjectPublicConfigSchema, } from "../extra/schema.js";
@@ -40,11 +43,17 @@ const defaultMessages = {
40
43
  field_email: "Email",
41
44
  field_password: "Password",
42
45
  forgot_password_back_to_sign_in: "Back to sign in",
46
+ forgot_password_change_email: "Change email",
43
47
  forgot_password_description: "Enter your email and we will send a reset link if an account exists.",
44
48
  forgot_password_error: "Unable to send password reset email.",
45
49
  forgot_password_submit: "Send reset link",
46
50
  forgot_password_success: "If an account exists for that email, a reset link has been sent.",
47
51
  forgot_password_title: "Reset password",
52
+ user_password_reset_title: "Check your email",
53
+ user_password_reset_sending: "Sending reset email…",
54
+ user_password_reset_resend: "Resend email",
55
+ user_password_reset_countdown: "Resend in {seconds}s",
56
+ forgot_password_success_email: "If an account exists for {email}, we’ve sent a password-reset link.",
48
57
  error_network: "We couldn't reach the server. Check your connection and try again.",
49
58
  error_rate_limited: "Too many attempts. Please wait a moment before trying again.",
50
59
  error_service_unavailable: "The authentication service is temporarily unavailable. Please try again.",
@@ -100,11 +109,17 @@ const defaultMessages = {
100
109
  field_email: "Courriel",
101
110
  field_password: "Mot de passe",
102
111
  forgot_password_back_to_sign_in: "Retour à la connexion",
112
+ forgot_password_change_email: "Modifier le courriel",
103
113
  forgot_password_description: "Saisissez votre courriel et nous enverrons un lien de réinitialisation si un compte existe.",
104
114
  forgot_password_error: "Impossible d'envoyer le courriel de réinitialisation.",
105
115
  forgot_password_submit: "Envoyer le lien",
106
116
  forgot_password_success: "Si un compte existe pour ce courriel, un lien de réinitialisation a été envoyé.",
107
117
  forgot_password_title: "Réinitialiser le mot de passe",
118
+ user_password_reset_title: "Consultez votre courriel",
119
+ user_password_reset_sending: "Envoi du courriel de réinitialisation…",
120
+ user_password_reset_resend: "Renvoyer le courriel",
121
+ user_password_reset_countdown: "Renvoyer dans {seconds} s",
122
+ forgot_password_success_email: "Si un compte existe pour {email}, nous avons envoyé un lien de réinitialisation.",
108
123
  error_network: "Impossible de joindre le serveur. Vérifiez votre connexion et réessayez.",
109
124
  error_rate_limited: "Trop de tentatives. Veuillez patienter un moment avant de réessayer.",
110
125
  error_service_unavailable: "Le service d'authentification est temporairement indisponible. Veuillez réessayer.",
@@ -234,7 +249,6 @@ const useAuthProjectConfig = (baseUrl, searchString, projectConfig) => {
234
249
  };
235
250
  const text = (value, params) => Object.entries(params ?? {}).reduce((current, [key, replacement]) => current.replace(`{${key}}`, replacement), value);
236
251
  const authLinkClassName = cn(buttonVariants({ variant: "link", size: null }), "h-auto align-baseline");
237
- const searchObject = (searchString) => Object.fromEntries(new URLSearchParams(searchString));
238
252
  const authMethodSearch = (searchString, method, email) => {
239
253
  const search = new URLSearchParams(searchString);
240
254
  search.set("method", method);
@@ -312,10 +326,23 @@ export function Signin(props) {
312
326
  }, [emailOtpResendAvailableAt]);
313
327
  const [form] = useState(() => FormReact.make(signinFormBuilder, {
314
328
  runtime: authClientApi(baseUrl).runtime,
315
- fields: { email: TextField, password: TextField, otp: OtpField },
329
+ fields: { email: TextField, password: PasswordField, otp: OtpField },
316
330
  mode: { validation: "onSubmit" },
317
331
  onSubmit: (action, { decoded: value }) => Effect.gen(function* () {
318
332
  const email = value.email.trim();
333
+ if (action.type === "resetPassword") {
334
+ yield* requestPasswordResetEmail({
335
+ baseUrl,
336
+ locale,
337
+ email,
338
+ redirectTo: passwordResetCallbackUrl(searchString, window.location.origin, email),
339
+ });
340
+ yield* Effect.promise(() => navigate({
341
+ to: "/reset-password",
342
+ search: passwordResetConfirmationSearch(searchString, email, Date.now()),
343
+ }));
344
+ return;
345
+ }
319
346
  const sendEmailOtp = authHttpClient(baseUrl, locale).pipe(Effect.flatMap((client) => client.auth.sendVerificationOtp({
320
347
  payload: { email, type: "sign-in" },
321
348
  })), Effect.tap(() => Effect.sync(() => {
@@ -473,24 +500,37 @@ export function Signin(props) {
473
500
  return;
474
501
  event.preventDefault();
475
502
  event.currentTarget.form?.requestSubmit();
476
- }, required: true })) : null, emailSubmitted && selectedAuthMethod === "password" ? (_jsxs("div", { className: "flex flex-col gap-2", children: [_jsx(form.password, { label: m.field_password, type: "password", autoFocus: true, autoComplete: "current-password", required: true }), _jsxs("div", { className: "flex flex-wrap gap-x-4 gap-y-2 text-sm", children: [_jsx(Link, { className: authLinkClassName, to: "/reset-password", search: authMethodSearch(searchString, "password", formValues.email.trim()), children: m.sign_in_forgot_password }), canChangeAuthMethod ? (_jsxs(Button, { type: "button", variant: "link", className: "h-auto px-0", onClick: switchAuthMethod, children: [_jsx(Mail, {}), m.sign_in_use_email_otp] })) : null] })] })) : null, emailSubmitted && selectedAuthMethod === "emailOtp" ? (_jsxs("div", { className: "flex flex-col gap-2", children: [_jsx(form.otp, { label: m.sign_in_email_otp_code }), _jsx("p", { className: "text-muted-foreground text-sm", children: m.sign_in_otp_expiry }), _jsxs("div", { className: "flex flex-wrap gap-x-4 gap-y-2 text-sm", children: [otpSentTo ? (_jsx(Button, { type: "button", variant: "link", className: "h-auto px-0", disabled: emailOtpResendSeconds > 0, onClick: resendEmailOtp, children: emailOtpResendSeconds > 0
503
+ }, required: true })) : null, emailSubmitted && selectedAuthMethod === "password" ? (_jsxs("div", { className: "flex flex-col gap-2", children: [_jsx(form.password, { label: m.field_password, autoFocus: true, autoComplete: "current-password", recovery: {
504
+ label: m.sign_in_forgot_password,
505
+ disabled: submitResult.waiting,
506
+ onClick: () => {
507
+ setErrorContext("resetPassword");
508
+ submit({ type: "resetPassword" });
509
+ },
510
+ }, required: true }), _jsx("div", { className: "flex flex-wrap gap-x-4 gap-y-2 text-sm", children: canChangeAuthMethod ? (_jsxs(Button, { type: "button", variant: "link", className: "h-auto px-0", onClick: switchAuthMethod, children: [_jsx(Mail, {}), m.sign_in_use_email_otp] })) : null })] })) : null, emailSubmitted && selectedAuthMethod === "emailOtp" ? (_jsxs("div", { className: "flex flex-col gap-2", children: [_jsx(form.otp, { label: m.sign_in_email_otp_code }), _jsx("p", { className: "text-muted-foreground text-sm", children: m.sign_in_otp_expiry }), _jsxs("div", { className: "flex flex-wrap gap-x-4 gap-y-2 text-sm", children: [otpSentTo ? (_jsx(Button, { type: "button", variant: "link", className: "h-auto px-0", disabled: emailOtpResendSeconds > 0, onClick: resendEmailOtp, children: emailOtpResendSeconds > 0
477
511
  ? text(m.sign_in_email_otp_resend_countdown, {
478
512
  seconds: String(emailOtpResendSeconds),
479
513
  })
480
514
  : m.sign_in_email_otp_resend })) : null, canChangeAuthMethod ? (_jsxs(Button, { type: "button", variant: "link", className: "h-auto px-0", onClick: switchAuthMethod, children: [_jsx(KeyRound, {}), m.sign_in_use_password] })) : null] })] })) : null, _jsx(AuthSubmitError, { result: submitResult, labels: m, messages: {
481
- fallback: errorContext === "sendEmailOtp"
482
- ? m.sign_in_email_otp_send_error
515
+ fallback: errorContext === "resetPassword"
516
+ ? m.forgot_password_error
517
+ : errorContext === "sendEmailOtp"
518
+ ? m.sign_in_email_otp_send_error
519
+ : errorContext === "verifyEmailOtp"
520
+ ? m.sign_in_email_otp_error
521
+ : m.sign_in_error,
522
+ badRequest: errorContext === "resetPassword"
523
+ ? m.forgot_password_error
483
524
  : errorContext === "verifyEmailOtp"
484
- ? m.sign_in_email_otp_error
485
- : m.sign_in_error,
486
- badRequest: errorContext === "verifyEmailOtp"
487
- ? m.auth_invalid_code
525
+ ? m.auth_invalid_code
526
+ : errorContext === "signIn"
527
+ ? m.sign_in_invalid_credentials
528
+ : m.sign_in_email_otp_send_error,
529
+ unauthorized: errorContext === "resetPassword"
530
+ ? m.forgot_password_error
488
531
  : errorContext === "signIn"
489
532
  ? m.sign_in_invalid_credentials
490
- : m.sign_in_email_otp_send_error,
491
- unauthorized: errorContext === "signIn"
492
- ? m.sign_in_invalid_credentials
493
- : m.sign_in_error,
533
+ : m.sign_in_error,
494
534
  } }), _jsx("div", { children: _jsxs(Button, { type: "submit", disabled: submitResult.waiting, children: [submitResult.waiting ? (_jsx(Loader2, { className: "animate-spin", "data-icon": "inline-start" })) : null, !emailSubmitted
495
535
  ? m.sign_in_continue
496
536
  : selectedAuthMethod === "emailOtp"
@@ -557,33 +597,45 @@ export function VerifyEmail(props) {
557
597
  }
558
598
  export function ForgotPassword(props) {
559
599
  const { baseUrl, locale, labels: m } = useAuthFormOptions(props);
600
+ const navigate = useNavigate();
560
601
  const searchString = useRouterState({
561
602
  select: (state) => state.location.searchStr,
562
603
  });
563
604
  const initialEmail = getSearchParam(searchString, "email")?.trim() ?? "";
564
- const [submitted, setSubmitted] = useState(false);
605
+ const confirmation = passwordResetConfirmation(searchString);
606
+ const passwordReset = usePasswordResetRequest(baseUrl, confirmation?.resetSentAt);
607
+ const resetEmailInput = (email) => ({
608
+ locale,
609
+ email,
610
+ redirectTo: passwordResetCallbackUrl(searchString, window.location.origin, email),
611
+ onSent: (sentAt) => navigate({
612
+ to: "/reset-password",
613
+ search: passwordResetConfirmationSearch(searchString, email, sentAt),
614
+ replace: true,
615
+ }),
616
+ });
617
+ const requestResetEmail = (email) => passwordReset.request(resetEmailInput(email));
565
618
  const [form] = useState(() => FormReact.make(forgotPasswordFormBuilder, {
566
619
  runtime: authClientApi(baseUrl).runtime,
567
620
  fields: { email: TextField },
568
621
  mode: { validation: "onSubmit" },
569
- onSubmit: (_, { decoded: value }) => Effect.gen(function* () {
570
- setSubmitted(false);
571
- yield* authHttpClient(baseUrl, locale).pipe(Effect.flatMap((client) => client.auth.requestPasswordReset({
572
- payload: {
573
- email: value.email.trim(),
574
- redirectTo: `${window.location.origin}/reset-password`,
575
- },
576
- })));
577
- setSubmitted(true);
578
- }),
622
+ onSubmit: (action, { decoded: value }) => action.requestEmail(value.email.trim()),
579
623
  }));
580
624
  const submit = useAtomSet(form.submit);
581
625
  const submitResult = useAtomValue(form.submit);
582
- return (_jsxs(Card, { className: "w-full max-w-md", children: [_jsxs(CardHeader, { children: [_jsx(CardTitle, { className: "text-3xl", children: m.forgot_password_title }), _jsx(CardDescription, { children: m.forgot_password_description })] }), _jsxs(CardContent, { children: [_jsx(form.Initialize, { defaultValues: { email: initialEmail }, children: _jsxs("form", { className: "flex flex-col gap-4", onSubmit: (event) => {
583
- event.preventDefault();
584
- event.stopPropagation();
585
- submit();
586
- }, children: [_jsx(form.email, { label: m.field_email, type: "email", autoComplete: "email", required: true }), _jsx(AuthSubmitError, { result: submitResult, labels: m, messages: { fallback: m.forgot_password_error } }), submitted ? (_jsx("p", { className: "bg-card text-card-foreground rounded-lg border px-4 py-3 text-sm shadow-xs", children: m.forgot_password_success })) : null, _jsxs(Button, { type: "submit", disabled: submitResult.waiting, children: [submitResult.waiting ? (_jsx(Loader2, { className: "animate-spin", "data-icon": "inline-start" })) : null, m.forgot_password_submit] })] }) }), _jsx("p", { className: "text-muted-foreground mt-6 text-center text-sm", children: _jsx(Link, { className: authLinkClassName, to: "/sign-in", search: searchObject(searchString), children: m.forgot_password_back_to_sign_in }) })] })] }));
626
+ const feedback = (_jsx(PasswordResetFeedback, { pending: passwordReset.result.waiting, sendingLabel: m.user_password_reset_sending, error: _jsx(AuthSubmitError, { result: passwordReset.result, labels: m, messages: { fallback: m.forgot_password_error } }) }));
627
+ if (confirmation) {
628
+ return (_jsxs(Card, { className: "w-full max-w-md", children: [_jsxs(CardHeader, { children: [_jsx(CardTitle, { className: "text-3xl", children: m.user_password_reset_title }), _jsx(CardDescription, { children: text(m.forgot_password_success_email, {
629
+ email: confirmation.email,
630
+ }) })] }), _jsx(CardContent, { children: _jsxs("div", { className: "flex flex-col gap-4", children: [feedback, _jsx(PasswordResetActions, { pending: passwordReset.result.waiting, resendSeconds: passwordReset.resendSeconds, onResend: () => passwordReset.send(resetEmailInput(confirmation.email)), resendLabel: m.user_password_reset_resend, countdownLabel: (seconds) => text(m.user_password_reset_countdown, {
631
+ seconds: String(seconds),
632
+ }) })] }) })] }));
633
+ }
634
+ return (_jsxs(Card, { className: "w-full max-w-md", children: [_jsxs(CardHeader, { children: [_jsx(CardTitle, { className: "text-3xl", children: m.forgot_password_title }), _jsx(CardDescription, { children: m.forgot_password_description })] }), _jsx(CardContent, { children: _jsx(form.Initialize, { defaultValues: { email: initialEmail }, children: _jsxs("form", { className: "flex flex-col gap-4", onSubmit: (event) => {
635
+ event.preventDefault();
636
+ event.stopPropagation();
637
+ submit({ requestEmail: requestResetEmail });
638
+ }, children: [_jsx(form.email, { label: m.field_email, type: "email", autoComplete: "email", required: true }), feedback, _jsxs(Button, { type: "submit", className: "self-start", disabled: submitResult.waiting || passwordReset.result.waiting, children: [submitResult.waiting || passwordReset.result.waiting ? (_jsx(Loader2, { className: "animate-spin", "data-icon": "inline-start" })) : null, m.forgot_password_submit] })] }) }, initialEmail) })] }));
587
639
  }
588
640
  export function ResetPassword(props) {
589
641
  const searchString = useRouterState({
@@ -595,18 +647,22 @@ export function ResetPassword(props) {
595
647
  function ResetPasswordForm({ token, ...props }) {
596
648
  const { baseUrl, locale, labels: m } = useAuthFormOptions(props);
597
649
  const navigate = useNavigate();
598
- const onSuccess = () => navigate({ to: "/sign-in" });
650
+ const searchString = useRouterState({
651
+ select: (state) => state.location.searchStr,
652
+ });
653
+ const onSuccess = () => navigate({ to: "/sign-in", search: passwordResetSearch(searchString) });
599
654
  const [form] = useState(() => FormReact.make(resetPasswordFormBuilder, {
600
655
  runtime: authClientApi(baseUrl).runtime,
601
- fields: { password: TextField },
656
+ fields: { password: PasswordField },
602
657
  mode: { validation: "onSubmit" },
603
658
  onSubmit: (_, { decoded: value }) => Effect.gen(function* () {
604
- yield* authHttpClient(baseUrl, locale).pipe(Effect.flatMap((client) => client.auth.resetPassword({
605
- payload: {
606
- newPassword: value.password,
607
- token,
608
- },
609
- })));
659
+ yield* resetPasswordAndSignOut({
660
+ baseUrl,
661
+ locale,
662
+ newPassword: value.password,
663
+ token,
664
+ });
665
+ notifyAuthChange();
610
666
  onSuccess();
611
667
  }),
612
668
  }));
@@ -616,7 +672,7 @@ function ResetPasswordForm({ token, ...props }) {
616
672
  event.preventDefault();
617
673
  event.stopPropagation();
618
674
  submit();
619
- }, children: [_jsx(form.password, { label: m.reset_password_new_password, type: "password", autoComplete: "new-password", minLength: 8, required: true }), _jsx(AuthSubmitError, { result: submitResult, labels: m, messages: { fallback: m.reset_password_error } }), _jsxs(Button, { type: "submit", disabled: submitResult.waiting, children: [submitResult.waiting ? (_jsx(Loader2, { className: "animate-spin", "data-icon": "inline-start" })) : null, effectFormMessages().submit] })] }) }) })] }));
675
+ }, children: [_jsx(form.password, { label: m.reset_password_new_password, autoComplete: "new-password", minLength: 8, required: true }), _jsx(AuthSubmitError, { result: submitResult, labels: m, messages: { fallback: m.reset_password_error } }), _jsxs(Button, { type: "submit", disabled: submitResult.waiting, children: [submitResult.waiting ? (_jsx(Loader2, { className: "animate-spin", "data-icon": "inline-start" })) : null, effectFormMessages().submit] })] }) }) })] }));
620
676
  }
621
677
  export function TwoFactor(props) {
622
678
  const { baseUrl, locale, labels: m } = useAuthFormOptions(props);
@@ -6,6 +6,7 @@ export { HasPermission, useHasPermission } from "./has-permission.js";
6
6
  export { ProjectAccessMatrix } from "./project-access-matrix.js";
7
7
  export { ForgotPassword, ResetPassword, Signin, TwoFactor, VerifyEmail, } from "./auth-forms.js";
8
8
  export { UserButton } from "./user-button.js";
9
+ export { PasswordField, type PasswordFieldOptions } from "./password-field.js";
9
10
  export { AdminOrganizationsTable, adminOrganizationsMessages, } from "./admin-organizations.js";
10
11
  export { AdminOrganizationForm } from "./admin-organization-form.js";
11
12
  export { AdminUsersTable, useAdminUsersTotal } from "./admin-users.js";
@@ -6,6 +6,7 @@ export { HasPermission, useHasPermission } from "./has-permission.js";
6
6
  export { ProjectAccessMatrix } from "./project-access-matrix.js";
7
7
  export { ForgotPassword, ResetPassword, Signin, TwoFactor, VerifyEmail, } from "./auth-forms.js";
8
8
  export { UserButton } from "./user-button.js";
9
+ export { PasswordField } from "./password-field.js";
9
10
  export { AdminOrganizationsTable, adminOrganizationsMessages, } from "./admin-organizations.js";
10
11
  export { AdminOrganizationForm } from "./admin-organization-form.js";
11
12
  export { AdminUsersTable, useAdminUsersTotal } from "./admin-users.js";
@@ -5,7 +5,7 @@ import { Effect, Option, Predicate, Schema } from "effect";
5
5
  import { AsyncResult, Atom } from "effect/reactivity";
6
6
  import { ArrowLeft, Building2, Check, ChevronsUpDown, Copy, KeyRound, LogOut, Mail, PencilIcon, Plus, Trash2, UserIcon, UserPlus, Users, X, } from "lucide-react";
7
7
  import { createContext, useContext, useEffect, useRef, useState, } from "react";
8
- import { DataTable, DataTableListSummary, DataTableListCell, } from "@krak-stack/registry/data-table";
8
+ import { DataTable, DataTableListCell, } from "@krak-stack/registry/data-table";
9
9
  import { CheckboxField, ImageField, SelectField, SubmitButton, SubmitError, TextAreaField, TextField, } from "@krak-stack/registry/effect-form";
10
10
  import { EditingLocaleSwitcher } from "@krak-stack/registry/editing-locale-switcher";
11
11
  import { AppBrand } from "@krak-stack/registry/app-brand";
@@ -1030,23 +1030,23 @@ function EditOrganizationSection({ header, baseUrl, editingLocale, organization,
1030
1030
  event.stopPropagation();
1031
1031
  submit();
1032
1032
  }, children: _jsxs(ScrollableDialogContent, { size: "2xl", children: [_jsx(ScrollableDialogHeader, { children: header }), _jsxs(ScrollableDialogBody, { className: "flex flex-col gap-4", padding: "form", children: [_jsxs(OrganizationFormSection, { title: m.organization_profile(), description: m.organization_translation_description(), children: [_jsxs(FieldSet, { disabled: editingLocale !== "en", className: editingLocale === "en" ? "contents" : "hidden", children: [_jsx(form.enName, { label: m.organization_translation_name() }), _jsx(form.enLogo, { label: m.organization_logo(), size: {
1033
- width: 175,
1034
- height: 50,
1033
+ width: 140,
1034
+ height: 40,
1035
1035
  suggestedWidth: 350,
1036
1036
  suggestedHeight: 100,
1037
1037
  } }), _jsx(form.enIcon, { label: m.organization_icon(), size: {
1038
- width: 96,
1039
- height: 96,
1038
+ width: 40,
1039
+ height: 40,
1040
1040
  suggestedWidth: 512,
1041
1041
  suggestedHeight: 512,
1042
1042
  } })] }), _jsxs(FieldSet, { disabled: editingLocale !== "fr", className: editingLocale === "fr" ? "contents" : "hidden", children: [_jsx(form.frName, { label: m.organization_translation_name() }), _jsx(form.frLogo, { label: m.organization_logo(), size: {
1043
- width: 175,
1044
- height: 50,
1043
+ width: 140,
1044
+ height: 40,
1045
1045
  suggestedWidth: 350,
1046
1046
  suggestedHeight: 100,
1047
1047
  } }), _jsx(form.frIcon, { label: m.organization_icon(), size: {
1048
- width: 96,
1049
- height: 96,
1048
+ width: 40,
1049
+ height: 40,
1050
1050
  suggestedWidth: 512,
1051
1051
  suggestedHeight: 512,
1052
1052
  } })] })] }), _jsx(Separator, { className: "my-2" }), _jsx(form.slug, { label: m.organization_slug(), description: m.organization_slug_identifier_description(), required: true }), _jsx(Separator, { className: "my-2" }), _jsxs(OrganizationFormSection, { title: m.organization_contact(), children: [_jsx(OrganizationContactGroup, { title: m.organization_contact_email_type(), children: _jsx(form.emails, { locale: editingLocale, messages: organizationContactFieldMessages(m) }) }), _jsx(OrganizationContactGroup, { title: m.organization_contact_phone_type(), children: _jsx(form.phones, { locale: editingLocale, messages: organizationContactFieldMessages(m) }) }), _jsx(OrganizationContactGroup, { title: m.organization_contact_website_type(), children: _jsx(form.websites, { locale: editingLocale, messages: organizationContactFieldMessages(m) }) }), _jsx(OrganizationContactGroup, { title: m.organization_contact_social_type(), children: _jsx(form.socials, { locale: editingLocale, messages: organizationContactFieldMessages(m) }) })] }), _jsx(Separator, { className: "my-2" }), _jsx(OrganizationFormSection, { title: m.organization_address(), children: _jsx(form.addresses, { locale: editingLocale, messages: organizationContactFieldMessages(m) }) })] }), _jsx(DialogFooter, { className: "-mx-6 -mb-6 border-t px-6 py-4", children: _jsxs("div", { className: "flex flex-col gap-3", children: [_jsx(SubmitError, { result: submitResult }), _jsx(SubmitButton, { form: form })] }) })] }) }) }));
@@ -1106,23 +1106,23 @@ function CreateOrganizationSection({ header, baseUrl, editingLocale, onCreated,
1106
1106
  event.stopPropagation();
1107
1107
  submit();
1108
1108
  }, children: _jsxs(ScrollableDialogContent, { size: "2xl", children: [_jsx(ScrollableDialogHeader, { children: header }), _jsxs(ScrollableDialogBody, { className: "flex flex-col gap-4", padding: "form", children: [_jsxs(OrganizationFormSection, { title: m.organization_profile(), description: m.organization_translation_description(), children: [_jsxs(FieldSet, { disabled: editingLocale !== "en", className: editingLocale === "en" ? "contents" : "hidden", children: [_jsx(form.enName, { label: m.organization_translation_name() }), _jsx(form.enLogo, { label: m.organization_logo(), size: {
1109
- width: 175,
1110
- height: 50,
1109
+ width: 140,
1110
+ height: 40,
1111
1111
  suggestedWidth: 350,
1112
1112
  suggestedHeight: 100,
1113
1113
  } }), _jsx(form.enIcon, { label: m.organization_icon(), size: {
1114
- width: 96,
1115
- height: 96,
1114
+ width: 40,
1115
+ height: 40,
1116
1116
  suggestedWidth: 512,
1117
1117
  suggestedHeight: 512,
1118
1118
  } })] }), _jsxs(FieldSet, { disabled: editingLocale !== "fr", className: editingLocale === "fr" ? "contents" : "hidden", children: [_jsx(form.frName, { label: m.organization_translation_name() }), _jsx(form.frLogo, { label: m.organization_logo(), size: {
1119
- width: 175,
1120
- height: 50,
1119
+ width: 140,
1120
+ height: 40,
1121
1121
  suggestedWidth: 350,
1122
1122
  suggestedHeight: 100,
1123
1123
  } }), _jsx(form.frIcon, { label: m.organization_icon(), size: {
1124
- width: 96,
1125
- height: 96,
1124
+ width: 40,
1125
+ height: 40,
1126
1126
  suggestedWidth: 512,
1127
1127
  suggestedHeight: 512,
1128
1128
  } })] })] }), _jsx(Separator, { className: "my-2" }), _jsx(form.slug, { label: m.organization_slug(), description: `${m.organization_slug_identifier_description()} ${m.organization_slug_description()}` }), _jsx(Separator, { className: "my-2" }), _jsxs(OrganizationFormSection, { title: m.organization_contact(), children: [_jsx(OrganizationContactGroup, { title: m.organization_contact_email_type(), children: _jsx(form.emails, { locale: editingLocale, messages: organizationContactFieldMessages(m) }) }), _jsx(OrganizationContactGroup, { title: m.organization_contact_phone_type(), children: _jsx(form.phones, { locale: editingLocale, messages: organizationContactFieldMessages(m) }) }), _jsx(OrganizationContactGroup, { title: m.organization_contact_website_type(), children: _jsx(form.websites, { locale: editingLocale, messages: organizationContactFieldMessages(m) }) }), _jsx(OrganizationContactGroup, { title: m.organization_contact_social_type(), children: _jsx(form.socials, { locale: editingLocale, messages: organizationContactFieldMessages(m) }) })] }), _jsx(Separator, { className: "my-2" }), _jsx(OrganizationFormSection, { title: m.organization_address(), children: _jsx(form.addresses, { locale: editingLocale, messages: organizationContactFieldMessages(m) }) })] }), _jsx(DialogFooter, { className: "-mx-6 -mb-6 border-t px-6 py-4", children: _jsxs("div", { className: "flex flex-col gap-3", children: [_jsx(SubmitError, { result: submitResult }), _jsx(SubmitButton, { form: form })] }) })] }) }) }));
@@ -1665,9 +1665,11 @@ const apiKeyColumns = ({ m, }) => [
1665
1665
  colId: "permissions",
1666
1666
  valueGetter: ({ data }) => data.permissions,
1667
1667
  headerName: m.user_api_key_permissions(),
1668
- cellRenderer: ({ data }) => {
1669
- const values = organizationApiKeyFormattedPermissions(data.permissions);
1670
- return (_jsx(DataTableListSummary, { emptyLabel: m.user_api_key_no_permissions(), items: values, visibleCount: 1 }));
1668
+ type: "list",
1669
+ typeOptions: {
1670
+ getItems: (data) => organizationApiKeyFormattedPermissions(data.permissions).map((label) => ({ label })),
1671
+ emptyLabel: m.user_api_key_no_permissions(),
1672
+ visibleCount: 1,
1671
1673
  },
1672
1674
  },
1673
1675
  {
@@ -0,0 +1,15 @@
1
+ import { FormReact } from "@lucas-barake/effect-form-react";
2
+ import { TextField } from "@krak-stack/registry/effect-form";
3
+ import type { ComponentProps } from "react";
4
+ export type PasswordFieldOptions = Omit<ComponentProps<typeof TextField>["props"], "type" | "autoComplete"> & ({
5
+ autoComplete: "current-password";
6
+ recovery?: {
7
+ label: string;
8
+ onClick: () => void;
9
+ disabled?: boolean;
10
+ };
11
+ } | {
12
+ autoComplete: "new-password";
13
+ recovery?: never;
14
+ });
15
+ export declare const PasswordField: FormReact.FieldComponent<string, PasswordFieldOptions>;
@@ -0,0 +1,12 @@
1
+ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { FormReact } from "@lucas-barake/effect-form-react";
3
+ import { TextField } from "@krak-stack/registry/effect-form";
4
+ import { Button } from "@/components/ui/button";
5
+ export const PasswordField = ({ field, props }) => {
6
+ const { recovery, children, ...inputProps } = props;
7
+ return (_jsx(TextField, { field: field, props: {
8
+ ...inputProps,
9
+ type: "password",
10
+ children: (_jsxs(_Fragment, { children: [children, recovery ? (_jsx(Button, { type: "button", variant: "link", className: "ms-auto h-auto p-0 text-xs", onClick: recovery.onClick, disabled: recovery.disabled, children: recovery.label })) : null] })),
11
+ } }));
12
+ };
@@ -0,0 +1,25 @@
1
+ import { Effect } from "effect";
2
+ import { type ReactNode } from "react";
3
+ import { requestPasswordResetEmail } from "./password-reset.js";
4
+ type PasswordResetRequest = Omit<Parameters<typeof requestPasswordResetEmail>[0], "baseUrl"> & {
5
+ onSent?: (sentAt: number) => void | Promise<void>;
6
+ };
7
+ export declare const usePasswordResetRequest: (baseUrl?: string, initialSentAt?: number | null) => {
8
+ send: (value: typeof import("effect/reactivity/Atom").Reset | typeof import("effect/reactivity/Atom").Interrupt | ((value: import("effect/reactivity/AsyncResult").AsyncResult<number, import("../auth/schema.js").AuthBadRequest | import("../auth/schema.js").AuthConflict | import("../auth/schema.js").AuthExpectationFailed | import("../auth/schema.js").AuthForbidden | import("../auth/schema.js").AuthInternalServerError | import("../auth/schema.js").AuthNotFound | import("../auth/schema.js").AuthTooManyRequests | import("../auth/schema.js").AuthUnauthorized | import("effect/http/HttpClientError").HttpClientError | import("effect/Schema").SchemaError>) => typeof import("effect/reactivity/Atom").Reset | typeof import("effect/reactivity/Atom").Interrupt | PasswordResetRequest) | PasswordResetRequest) => void;
9
+ request: (input: PasswordResetRequest) => Effect.Effect<number, import("../auth/schema.js").AuthBadRequest | import("../auth/schema.js").AuthConflict | import("../auth/schema.js").AuthExpectationFailed | import("../auth/schema.js").AuthForbidden | import("../auth/schema.js").AuthInternalServerError | import("../auth/schema.js").AuthNotFound | import("../auth/schema.js").AuthTooManyRequests | import("../auth/schema.js").AuthUnauthorized | import("effect/http/HttpClientError").HttpClientError | import("effect/Schema").SchemaError, never>;
10
+ result: import("effect/reactivity/AsyncResult").AsyncResult<number, import("../auth/schema.js").AuthBadRequest | import("../auth/schema.js").AuthConflict | import("../auth/schema.js").AuthExpectationFailed | import("../auth/schema.js").AuthForbidden | import("../auth/schema.js").AuthInternalServerError | import("../auth/schema.js").AuthNotFound | import("../auth/schema.js").AuthTooManyRequests | import("../auth/schema.js").AuthUnauthorized | import("effect/http/HttpClientError").HttpClientError | import("effect/Schema").SchemaError>;
11
+ resendSeconds: number;
12
+ };
13
+ export declare const PasswordResetFeedback: ({ pending, sendingLabel, error, }: {
14
+ pending: boolean;
15
+ sendingLabel: string;
16
+ error: ReactNode;
17
+ }) => import("react").JSX.Element;
18
+ export declare const PasswordResetActions: ({ pending, resendSeconds, onResend, resendLabel, countdownLabel, }: {
19
+ pending: boolean;
20
+ resendSeconds: number;
21
+ onResend: () => void;
22
+ resendLabel: string;
23
+ countdownLabel: (seconds: number) => string;
24
+ }) => import("react").JSX.Element;
25
+ export {};
@@ -0,0 +1,51 @@
1
+ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { RegistryContext, useAtomSet, useAtomValue } from "@effect/atom-react";
3
+ import { Effect } from "effect";
4
+ import { AtomRegistry } from "effect/reactivity";
5
+ import { Loader2 } from "lucide-react";
6
+ import { useContext, useEffect, useState } from "react";
7
+ import { Button } from "@/components/ui/button";
8
+ import { authClientApi } from "./auth-client-api.js";
9
+ import { PASSWORD_RESET_RESEND_COOLDOWN_MS, passwordResetResendSeconds, requestPasswordResetEmail, } from "./password-reset.js";
10
+ // The caller owns routing and confirmation visibility. A mounted flow never
11
+ // sends automatically, including when its initial timestamp came from a URL.
12
+ export const usePasswordResetRequest = (baseUrl, initialSentAt = null) => {
13
+ const [lastSentAt, setLastSentAt] = useState(null);
14
+ const [now, setNow] = useState(Date.now);
15
+ const [action] = useState(() => authClientApi(baseUrl).runtime.fn((input) => requestPasswordResetEmail({ baseUrl, ...input }).pipe(Effect.flatMap(() => Effect.sync(() => {
16
+ const sentAt = Date.now();
17
+ setLastSentAt(sentAt);
18
+ setNow(sentAt);
19
+ return sentAt;
20
+ })), Effect.tap((sentAt) => Effect.promise(async () => {
21
+ await input.onSent?.(sentAt);
22
+ })))));
23
+ const send = useAtomSet(action);
24
+ const result = useAtomValue(action);
25
+ const registry = useContext(RegistryContext);
26
+ const request = (input) => Effect.sync(() => registry.set(action, input)).pipe(Effect.flatMap(() => AtomRegistry.getResult(registry, action, { suspendOnWaiting: true })));
27
+ const sentAt = Math.max(initialSentAt ?? 0, lastSentAt ?? 0) || null;
28
+ useEffect(() => {
29
+ if (sentAt === null)
30
+ return;
31
+ const update = () => setNow(Date.now());
32
+ update();
33
+ if (Date.now() >= sentAt + PASSWORD_RESET_RESEND_COOLDOWN_MS)
34
+ return;
35
+ const timer = window.setInterval(() => {
36
+ update();
37
+ if (Date.now() >= sentAt + PASSWORD_RESET_RESEND_COOLDOWN_MS) {
38
+ window.clearInterval(timer);
39
+ }
40
+ }, 1000);
41
+ return () => window.clearInterval(timer);
42
+ }, [sentAt]);
43
+ return {
44
+ send,
45
+ request,
46
+ result,
47
+ resendSeconds: passwordResetResendSeconds(sentAt, now),
48
+ };
49
+ };
50
+ export const PasswordResetFeedback = ({ pending, sendingLabel, error, }) => pending ? (_jsx("p", { role: "status", className: "text-muted-foreground text-sm", children: sendingLabel })) : (_jsx(_Fragment, { children: error }));
51
+ export const PasswordResetActions = ({ pending, resendSeconds, onResend, resendLabel, countdownLabel, }) => (_jsx("div", { className: "flex flex-wrap gap-2", children: _jsxs(Button, { type: "button", disabled: pending || resendSeconds > 0, onClick: onResend, children: [pending ? (_jsx(Loader2, { className: "animate-spin", "data-icon": "inline-start" })) : null, resendSeconds > 0 ? countdownLabel(resendSeconds) : resendLabel] }) }));
@@ -0,0 +1,34 @@
1
+ import { Effect, Schema } from "effect";
2
+ import type { KrakstackAuthLocale } from "./auth-provider.js";
3
+ export declare const passwordResetSearch: (searchString: string) => {
4
+ [k: string]: string;
5
+ };
6
+ export declare const passwordResetConfirmationSearch: (searchString: string, email: string, sentAt: number) => {
7
+ method: string;
8
+ email: string;
9
+ resetSentAt: number;
10
+ };
11
+ export declare const passwordResetConfirmation: (searchString: string, now?: number) => {
12
+ readonly email: string;
13
+ readonly resetSentAt: number;
14
+ } | null;
15
+ export declare const passwordResetCallbackUrl: (searchString: string, origin: string, email?: string) => string;
16
+ export declare const PASSWORD_RESET_RESEND_COOLDOWN_MS = 60000;
17
+ export declare const passwordResetResendSeconds: (sentAt: number | null, now: number) => number;
18
+ export declare const requestPasswordResetEmail: ({ baseUrl, locale, email, redirectTo, }: {
19
+ baseUrl?: string | undefined;
20
+ locale: () => KrakstackAuthLocale;
21
+ email: string;
22
+ redirectTo: string;
23
+ }) => Effect.Effect<{
24
+ readonly status: boolean;
25
+ readonly message: string;
26
+ }, import("../auth/schema.js").AuthBadRequest | import("../auth/schema.js").AuthConflict | import("../auth/schema.js").AuthExpectationFailed | import("../auth/schema.js").AuthForbidden | import("../auth/schema.js").AuthInternalServerError | import("../auth/schema.js").AuthNotFound | import("../auth/schema.js").AuthTooManyRequests | import("../auth/schema.js").AuthUnauthorized | import("effect/http/HttpClientError").HttpClientError | Schema.SchemaError, never>;
27
+ export declare const resetPasswordAndSignOut: ({ baseUrl, locale, newPassword, token, }: {
28
+ baseUrl?: string | undefined;
29
+ locale: () => KrakstackAuthLocale;
30
+ newPassword: string;
31
+ token: string;
32
+ }) => Effect.Effect<{
33
+ readonly success: boolean;
34
+ }, import("../auth/schema.js").AuthBadRequest | import("../auth/schema.js").AuthConflict | import("../auth/schema.js").AuthExpectationFailed | import("../auth/schema.js").AuthForbidden | import("../auth/schema.js").AuthInternalServerError | import("../auth/schema.js").AuthNotFound | import("../auth/schema.js").AuthTooManyRequests | import("../auth/schema.js").AuthUnauthorized | import("effect/http/HttpClientError").HttpClientError | Schema.SchemaError, never>;
@@ -0,0 +1,41 @@
1
+ import { Effect, Option, Schema } from "effect";
2
+ import { authHttpClient } from "./auth-client-api.js";
3
+ import { EmailAddress } from "../schema.js";
4
+ export const passwordResetSearch = (searchString) => {
5
+ const search = new URLSearchParams(searchString);
6
+ for (const key of ["resetSentAt", "token", "error"])
7
+ search.delete(key);
8
+ return Object.fromEntries(search);
9
+ };
10
+ export const passwordResetConfirmationSearch = (searchString, email, sentAt) => ({
11
+ ...passwordResetSearch(searchString),
12
+ method: "password",
13
+ email,
14
+ resetSentAt: sentAt,
15
+ });
16
+ export const passwordResetConfirmation = (searchString, now = Date.now()) => {
17
+ const Timestamp = Schema.NumberFromString.check(Schema.isInt(), Schema.isBetween({ minimum: 1, maximum: now })).annotate({ identifier: "PasswordResetTimestamp" });
18
+ const Confirmation = Schema.Struct({
19
+ email: EmailAddress,
20
+ // Routers may JSON-quote numeric strings to preserve their string type.
21
+ resetSentAt: Schema.Union([Timestamp, Schema.fromJsonString(Timestamp)]),
22
+ }).annotate({ identifier: "PasswordResetConfirmation" });
23
+ return Option.getOrNull(Schema.decodeUnknownOption(Confirmation)(Object.fromEntries(new URLSearchParams(searchString))));
24
+ };
25
+ export const passwordResetCallbackUrl = (searchString, origin, email) => {
26
+ const url = new URL("/reset-password", origin);
27
+ url.search = new URLSearchParams(passwordResetSearch(searchString)).toString();
28
+ if (email !== undefined) {
29
+ url.searchParams.set("email", email);
30
+ url.searchParams.set("method", "password");
31
+ }
32
+ return url.href;
33
+ };
34
+ export const PASSWORD_RESET_RESEND_COOLDOWN_MS = 60_000;
35
+ export const passwordResetResendSeconds = (sentAt, now) => sentAt === null
36
+ ? 0
37
+ : Math.max(0, Math.ceil((sentAt + PASSWORD_RESET_RESEND_COOLDOWN_MS - now) / 1000));
38
+ export const requestPasswordResetEmail = ({ baseUrl, locale, email, redirectTo, }) => authHttpClient(baseUrl, locale).pipe(Effect.flatMap((client) => client.auth.requestPasswordReset({ payload: { email, redirectTo } })));
39
+ export const resetPasswordAndSignOut = ({ baseUrl, locale, newPassword, token, }) => authHttpClient(baseUrl, locale).pipe(Effect.flatMap((client) => client.auth.resetPassword({ payload: { newPassword, token } }).pipe(
40
+ // Server-side session revocation does not clear browser session cookies.
41
+ Effect.flatMap(() => client.auth.signOut({ payload: {} })))));
@@ -12,6 +12,13 @@ declare const messages: {
12
12
  readonly user_account_confirm_revoke: "Revoke account";
13
13
  readonly user_account_connected: "Connected";
14
14
  readonly user_account_current_password: "Current password";
15
+ readonly sign_in_forgot_password: "Forgot your password?";
16
+ readonly user_password_reset_title: "Check your email";
17
+ readonly user_password_reset_description: "We sent you a link to reset your password. After resetting, sign in again to continue.";
18
+ readonly user_password_reset_error: "Unable to send password reset email. Please try again.";
19
+ readonly user_password_reset_sending: "Sending reset email…";
20
+ readonly user_password_reset_resend: "Resend email";
21
+ readonly user_password_reset_countdown: "Resend in {seconds}s";
15
22
  readonly user_account_google_connect: "Set up";
16
23
  readonly user_account_google_description: "Use your Google account as a sign-in option.";
17
24
  readonly user_account_google_link_error: "Could not connect Google.";
@@ -108,6 +115,7 @@ declare const messages: {
108
115
  readonly user_contact_add_website: "Add website";
109
116
  readonly user_contact_description: "Add up to 8 public contacts of each type, separately from the email used to sign in.";
110
117
  readonly user_contact_email_type: "Email";
118
+ readonly user_contact_primary: "Primary";
111
119
  readonly user_contact_extension: "Extension";
112
120
  readonly user_contact_label: "Label";
113
121
  readonly user_contact_phone_type: "Phone";
@@ -149,6 +157,13 @@ declare const messages: {
149
157
  readonly user_account_confirm_revoke: "Révoquer le compte";
150
158
  readonly user_account_connected: "Connecté";
151
159
  readonly user_account_current_password: "Mot de passe actuel";
160
+ readonly sign_in_forgot_password: "Mot de passe oublié?";
161
+ readonly user_password_reset_title: "Consultez votre courriel";
162
+ readonly user_password_reset_description: "Nous vous avons envoyé un lien pour réinitialiser votre mot de passe. Après la réinitialisation, reconnectez-vous pour continuer.";
163
+ readonly user_password_reset_error: "Impossible d’envoyer le courriel de réinitialisation. Veuillez réessayer.";
164
+ readonly user_password_reset_sending: "Envoi du courriel de réinitialisation…";
165
+ readonly user_password_reset_resend: "Renvoyer le courriel";
166
+ readonly user_password_reset_countdown: "Renvoyer dans {seconds} s";
152
167
  readonly user_account_google_connect: "Configurer";
153
168
  readonly user_account_google_description: "Utilisez votre compte Google comme option de connexion.";
154
169
  readonly user_account_google_link_error: "Impossible de connecter Google.";
@@ -245,6 +260,7 @@ declare const messages: {
245
260
  readonly user_contact_add_website: "Ajouter un site Web";
246
261
  readonly user_contact_description: "Ajoutez jusqu’à 8 coordonnées publiques de chaque type, distinctes du courriel utilisé pour vous connecter.";
247
262
  readonly user_contact_email_type: "Courriel";
263
+ readonly user_contact_primary: "Principal";
248
264
  readonly user_contact_extension: "Poste";
249
265
  readonly user_contact_label: "Libellé";
250
266
  readonly user_contact_phone_type: "Téléphone";
@@ -288,6 +304,8 @@ type UserFormType = {
288
304
  websites: ReadonlyArray<ContactWebsiteValue>;
289
305
  socials: ReadonlyArray<ContactSocialValue>;
290
306
  };
307
+ export declare const userContactEmailDefaults: (metadata: UserMetadata, email: string) => ContactEmailValue[];
308
+ export declare const userPrimaryContactEmail: (email: string) => ContactEmailValue;
291
309
  export declare const UserContactEmailsForm: Schema.$Array<Schema.Struct<{
292
310
  readonly email: Schema.String;
293
311
  readonly translations: Schema.$Array<Schema.Struct<{
@@ -7,7 +7,7 @@ import { AsyncResult, Atom, AtomRegistry } from "effect/reactivity";
7
7
  import { ArrowLeft, Building2, KeyRound, Loader2, LogOutIcon, Mail, Pencil, Plus, ShieldCheck, StopCircle, Trash2, UserCircleIcon, Users, UserIcon, } from "lucide-react";
8
8
  import { QRCode } from "react-qr-code";
9
9
  import { createContext, useContext, useRef, useEffect, useState, } from "react";
10
- import { DataTable, DataTableListSummary, } from "@krak-stack/registry/data-table";
10
+ import { DataTable, } from "@krak-stack/registry/data-table";
11
11
  import { AppBrand } from "@krak-stack/registry/app-brand";
12
12
  import { EditingLocaleSwitcher } from "@krak-stack/registry/editing-locale-switcher";
13
13
  import { effectFormMessages, ImageField, SubmitButton, SubmitError, TextAreaField, TextField, } from "@krak-stack/registry/effect-form";
@@ -17,7 +17,11 @@ import { CopyButton } from "@krak-stack/registry/copy-button";
17
17
  import { Dialog, DialogFooter, DialogDescription, DialogHeader, DialogTitle, } from "@/components/ui/dialog";
18
18
  import { DropdownMenu, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuSeparator, DropdownMenuTrigger, } from "@/components/ui/dropdown-menu";
19
19
  import { Separator } from "@/components/ui/separator";
20
+ import { FieldLabel } from "@/components/ui/field";
21
+ import { Input } from "@/components/ui/input";
20
22
  import { authClientApi, authHttpClient } from "./auth-client-api.js";
23
+ import { PasswordField } from "./password-field.js";
24
+ import { PasswordResetActions, PasswordResetFeedback, usePasswordResetRequest, } from "./password-reset-flow.js";
21
25
  import { authSessionAtom, notifyAuthChange } from "./auth-atoms.js";
22
26
  import { useKrakstackAuth } from "./auth-provider.js";
23
27
  import { parseApiKeyReferrers } from "./api-key.js";
@@ -44,6 +48,13 @@ const messages = {
44
48
  user_account_confirm_revoke: "Revoke account",
45
49
  user_account_connected: "Connected",
46
50
  user_account_current_password: "Current password",
51
+ sign_in_forgot_password: "Forgot your password?",
52
+ user_password_reset_title: "Check your email",
53
+ user_password_reset_description: "We sent you a link to reset your password. After resetting, sign in again to continue.",
54
+ user_password_reset_error: "Unable to send password reset email. Please try again.",
55
+ user_password_reset_sending: "Sending reset email…",
56
+ user_password_reset_resend: "Resend email",
57
+ user_password_reset_countdown: "Resend in {seconds}s",
47
58
  user_account_google_connect: "Set up",
48
59
  user_account_google_description: "Use your Google account as a sign-in option.",
49
60
  user_account_google_link_error: "Could not connect Google.",
@@ -140,6 +151,7 @@ const messages = {
140
151
  user_contact_add_website: "Add website",
141
152
  user_contact_description: "Add up to 8 public contacts of each type, separately from the email used to sign in.",
142
153
  user_contact_email_type: "Email",
154
+ user_contact_primary: "Primary",
143
155
  user_contact_extension: "Extension",
144
156
  user_contact_label: "Label",
145
157
  user_contact_phone_type: "Phone",
@@ -181,6 +193,13 @@ const messages = {
181
193
  user_account_confirm_revoke: "Révoquer le compte",
182
194
  user_account_connected: "Connecté",
183
195
  user_account_current_password: "Mot de passe actuel",
196
+ sign_in_forgot_password: "Mot de passe oublié?",
197
+ user_password_reset_title: "Consultez votre courriel",
198
+ user_password_reset_description: "Nous vous avons envoyé un lien pour réinitialiser votre mot de passe. Après la réinitialisation, reconnectez-vous pour continuer.",
199
+ user_password_reset_error: "Impossible d’envoyer le courriel de réinitialisation. Veuillez réessayer.",
200
+ user_password_reset_sending: "Envoi du courriel de réinitialisation…",
201
+ user_password_reset_resend: "Renvoyer le courriel",
202
+ user_password_reset_countdown: "Renvoyer dans {seconds} s",
184
203
  user_account_google_connect: "Configurer",
185
204
  user_account_google_description: "Utilisez votre compte Google comme option de connexion.",
186
205
  user_account_google_link_error: "Impossible de connecter Google.",
@@ -277,6 +296,7 @@ const messages = {
277
296
  user_contact_add_website: "Ajouter un site Web",
278
297
  user_contact_description: "Ajoutez jusqu’à 8 coordonnées publiques de chaque type, distinctes du courriel utilisé pour vous connecter.",
279
298
  user_contact_email_type: "Courriel",
299
+ user_contact_primary: "Principal",
280
300
  user_contact_extension: "Poste",
281
301
  user_contact_label: "Libellé",
282
302
  user_contact_phone_type: "Téléphone",
@@ -360,6 +380,14 @@ const hasAdminRole = (user) => {
360
380
  const decoded = Schema.decodeUnknownOption(UserRole)(user);
361
381
  return Option.isSome(decoded) && hasRole(decoded.value.role, ["admin"]);
362
382
  };
383
+ export const userContactEmailDefaults = (metadata, email) => (metadata.emails ?? []).filter((contact) => contact.email.trim().toLowerCase() !== email.trim().toLowerCase());
384
+ export const userPrimaryContactEmail = (email) => ({
385
+ email,
386
+ translations: [
387
+ { locale: "en", label: messages.en.user_contact_primary },
388
+ { locale: "fr", label: messages.fr.user_contact_primary },
389
+ ],
390
+ });
363
391
  const changePasswordFormBuilder = FormBuilder.empty
364
392
  .addField("currentPassword", Schema.NonEmptyString)
365
393
  .addField("newPassword", Schema.NonEmptyString);
@@ -491,6 +519,8 @@ export const UserButton = ({ baseUrl, signOutRedirect = "/", side = "bottom", de
491
519
  const [totpSetup, setTotpSetup] = useState(null);
492
520
  const [managingTwoFactor, setManagingTwoFactor] = useState(false);
493
521
  const [revokingAccount, setRevokingAccount] = useState(null);
522
+ const [passwordResetVisible, setPasswordResetVisible] = useState(false);
523
+ const passwordReset = usePasswordResetRequest(resolvedBaseUrl);
494
524
  const settingsDialog = controlledDialog !== undefined ? controlledDialog : uncontrolledDialog;
495
525
  const [formError, setFormError] = useState(null);
496
526
  const shouldLoadAccounts = Boolean(session) &&
@@ -553,6 +583,20 @@ export const UserButton = ({ baseUrl, signOutRedirect = "/", side = "bottom", de
553
583
  const canManageUserSettings = !isOrganizationImpersonating;
554
584
  const canUseAdminSettings = !isOrganizationImpersonating;
555
585
  const isAdmin = hasAdminRole(session.user);
586
+ const startPasswordReset = () => {
587
+ if (passwordReset.result.waiting)
588
+ return;
589
+ if (passwordReset.resendSeconds > 0) {
590
+ setPasswordResetVisible(true);
591
+ return;
592
+ }
593
+ passwordReset.send({
594
+ locale: getLocale,
595
+ email: displayEmail,
596
+ redirectTo: `${window.location.origin}/reset-password`,
597
+ onSent: () => setPasswordResetVisible(true),
598
+ });
599
+ };
556
600
  const startSignOut = () => {
557
601
  const redirectUrl = signOutRedirect.startsWith("http")
558
602
  ? signOutRedirect
@@ -565,17 +609,23 @@ export const UserButton = ({ baseUrl, signOutRedirect = "/", side = "bottom", de
565
609
  refreshSession,
566
610
  }), children: [_jsx(StopCircle, {}), m.user_button_stop_impersonating()] })) : null, _jsx(DropdownMenuSeparator, {})] })) : null, _jsxs(DropdownMenuItem, { disabled: signOutResult.waiting, onClick: startSignOut, children: [_jsx(LogOutIcon, {}), m.user_button_logout()] }), authActionError ? (_jsx(DropdownMenuLabel, { className: "text-destructive text-xs font-normal", children: authActionError })) : null] }) })] })), _jsx(Dialog, { open: canManageUserSettings && settingsDialog === "account", onOpenChange: (open) => {
567
611
  setSettingsDialog((current) => open ? "account" : current === "account" ? null : current);
568
- }, children: _jsx(UserForm, { defaultValues: {
612
+ }, children: _jsx(UserForm, { primaryEmail: displayEmail, defaultValues: {
569
613
  name: displayName ?? "",
570
614
  image: displayImage || null,
571
- emails: Array.from(metadata.emails ?? []),
615
+ emails: userContactEmailDefaults(metadata, displayEmail),
572
616
  phones: Array.from(metadata.phones ?? []),
573
617
  websites: Array.from(metadata.websites ?? []),
574
618
  socials: Array.from(metadata.socials ?? []),
575
619
  }, error: formError, onSubmit: (values) => Effect.gen(function* () {
576
620
  setFormError(null);
577
621
  const metadata = yield* Effect.try({
578
- try: () => userMetadataFromForm(values),
622
+ try: () => userMetadataFromForm({
623
+ ...values,
624
+ emails: [
625
+ userPrimaryContactEmail(displayEmail),
626
+ ...values.emails,
627
+ ],
628
+ }),
579
629
  catch: () => new Error(m.user_contact_validation_error()),
580
630
  });
581
631
  const imageFile = isFile(values.image) ? values.image : null;
@@ -599,54 +649,68 @@ export const UserButton = ({ baseUrl, signOutRedirect = "/", side = "bottom", de
599
649
  }).pipe(Effect.tapError((error) => Effect.sync(() => setFormError(error instanceof Error
600
650
  ? error.message
601
651
  : m.user_form_update_error())))) }) }), _jsx(Dialog, { open: canManageUserSettings && settingsDialog === "security", onOpenChange: (open) => {
652
+ setSettingsDialog((current) => open ? "security" : current === "security" ? null : current);
653
+ }, onOpenChangeComplete: (open) => {
654
+ if (open)
655
+ return;
656
+ // Keep the active page intact until the exit animation has finished.
657
+ setPasswordResetVisible(false);
602
658
  setChangingPassword(false);
603
659
  setSettingPassword(false);
604
660
  setTotpSetup(null);
605
661
  setManagingTwoFactor(false);
606
662
  setRevokingAccount(null);
607
- setSettingsDialog((current) => open ? "security" : current === "security" ? null : current);
608
- }, children: _jsxs(ScrollableDialogContent, { size: "3xl", children: [_jsx(ScrollableDialogHeader, { children: _jsxs(DialogHeader, { className: "sm:flex-row sm:items-end sm:justify-between sm:gap-4", children: [_jsxs("div", { className: "flex min-w-0 flex-col gap-2", children: [_jsx(DialogTitle, { className: "text-2xl", children: changingPassword
609
- ? m.user_account_password_change_title()
610
- : settingPassword
611
- ? m.user_account_password_set()
612
- : revokingAccount
613
- ? m.user_account_revoke()
614
- : managingTwoFactor
615
- ? m.user_two_factor_title()
616
- : m.user_security_title() }), _jsx(DialogDescription, { children: changingPassword
617
- ? m.user_account_password_change_description()
618
- : settingPassword
619
- ? m.user_account_password_description()
620
- : revokingAccount
621
- ? m.user_account_revoke_description({
622
- provider: providerName(revokingAccount.providerId, m),
623
- })
624
- : managingTwoFactor
625
- ? m.user_two_factor_description()
626
- : m.user_security_description() })] }), changingPassword ||
663
+ }, children: _jsxs(ScrollableDialogContent, { size: "3xl", children: [_jsx(ScrollableDialogHeader, { children: _jsxs(DialogHeader, { className: "gap-4", children: [passwordResetVisible ||
664
+ changingPassword ||
627
665
  settingPassword ||
628
666
  revokingAccount ||
629
- managingTwoFactor ? (_jsxs(Button, { className: "mt-2 w-fit sm:mt-0", type: "button", variant: "secondary", onClick: () => {
667
+ managingTwoFactor ? (_jsxs(Button, { className: "h-auto w-fit p-0", type: "button", variant: "link", disabled: passwordResetVisible && passwordReset.result.waiting, onClick: () => {
668
+ if (passwordResetVisible) {
669
+ setPasswordResetVisible(false);
670
+ return;
671
+ }
630
672
  setChangingPassword(false);
631
673
  setSettingPassword(false);
632
674
  setTotpSetup(null);
633
675
  setManagingTwoFactor(false);
634
676
  setRevokingAccount(null);
635
- }, children: [_jsx(ArrowLeft, {}), m.user_account_back()] })) : null] }) }), _jsx(ScrollableDialogBody, { children: changingPassword ? (_jsx(ChangePasswordForm, { baseUrl: resolvedBaseUrl })) : settingPassword ? (_jsx(SetPasswordForm, { baseUrl: resolvedBaseUrl, onSaved: async () => {
636
- await accountCache.reload();
637
- setSettingPassword(false);
638
- } })) : revokingAccount ? (_jsx(RevokeAccountForm, { baseUrl: resolvedBaseUrl, account: revokingAccount, requirePassword: requiresPasswordForAccountRevoke(accountCache.accounts ?? []), onCancel: () => setRevokingAccount(null), onRevoked: async () => {
639
- await accountCache.reload();
640
- setRevokingAccount(null);
641
- } })) : totpSetup ? (_jsx(VerifyTotpSetup, { baseUrl: resolvedBaseUrl, setup: totpSetup, onVerified: async () => {
642
- await refreshSession();
643
- setTotpSetup(null);
644
- setManagingTwoFactor(false);
645
- } })) : managingTwoFactor ? (_jsx(AccountSecuritySettings, { baseUrl: resolvedBaseUrl, accountCache: accountCache, onSetup: setTotpSetup })) : (_jsxs("div", { className: "flex flex-col gap-6", children: [_jsx(ConnectedAccounts, { onChangePassword: () => setChangingPassword(true), onSetupPassword: () => setSettingPassword(true), onRevokeAccount: setRevokingAccount, baseUrl: resolvedBaseUrl, accountCache: accountCache, googleEnabled: projectConfig?.authOptions.google ?? true, currentSiteHref: currentSiteHref, navigate: navigate }), _jsx(Separator, {}), _jsxs("section", { className: "flex flex-col gap-6", children: [_jsxs("div", { className: "flex flex-wrap items-start justify-between gap-3", children: [_jsxs("div", { className: "flex flex-col gap-1.5", children: [_jsx("h2", { className: "text-sm leading-none font-medium", children: m.user_two_factor_title() }), _jsx("p", { className: "text-muted-foreground text-xs", children: m.user_two_factor_description() })] }), _jsx(Badge, { variant: hasTwoFactorEnabled(session?.user)
646
- ? "default"
647
- : "secondary", children: hasTwoFactorEnabled(session?.user)
648
- ? m.user_two_factor_enabled()
649
- : m.user_two_factor_disabled() })] }), hasTwoFactorEnabled(session?.user) ? (_jsx(AccountSecuritySettings, { baseUrl: resolvedBaseUrl, accountCache: accountCache, onSetup: setTotpSetup })) : (_jsx(Button, { type: "button", className: "self-start", onClick: () => setManagingTwoFactor(true), children: m.user_two_factor_enable_submit() }))] })] })) })] }) }), _jsx(Dialog, { open: canManageUserSettings && settingsDialog === "apiKeys", onOpenChange: (open) => {
677
+ }, children: [_jsx(ArrowLeft, {}), m.user_account_back()] })) : null, _jsxs("div", { className: "flex min-w-0 flex-col gap-2", children: [_jsx(DialogTitle, { className: "text-2xl", children: passwordResetVisible
678
+ ? m.user_password_reset_title()
679
+ : changingPassword
680
+ ? m.user_account_password_change_title()
681
+ : settingPassword
682
+ ? m.user_account_password_set()
683
+ : revokingAccount
684
+ ? m.user_account_revoke()
685
+ : managingTwoFactor
686
+ ? m.user_two_factor_title()
687
+ : m.user_security_title() }), _jsx(DialogDescription, { children: passwordResetVisible
688
+ ? m.user_password_reset_description()
689
+ : changingPassword
690
+ ? m.user_account_password_change_description()
691
+ : settingPassword
692
+ ? m.user_account_password_description()
693
+ : revokingAccount
694
+ ? m.user_account_revoke_description({
695
+ provider: providerName(revokingAccount.providerId, m),
696
+ })
697
+ : managingTwoFactor
698
+ ? m.user_two_factor_description()
699
+ : m.user_security_description() })] })] }) }), _jsxs(ScrollableDialogBody, { children: [_jsx(PasswordResetFeedback, { pending: passwordReset.result.waiting, sendingLabel: m.user_password_reset_sending(), error: AsyncResult.isFailure(passwordReset.result) ? (_jsx("p", { role: "alert", className: "text-destructive text-sm", children: m.user_password_reset_error() })) : null }), passwordResetVisible ? (_jsx(PasswordResetActions, { pending: passwordReset.result.waiting, resendSeconds: passwordReset.resendSeconds, onResend: startPasswordReset, resendLabel: m.user_password_reset_resend(), countdownLabel: (seconds) => m.user_password_reset_countdown({ seconds }) })) : changingPassword ? (_jsx(ChangePasswordForm, { baseUrl: resolvedBaseUrl, onResetPassword: startPasswordReset })) : settingPassword ? (_jsx(SetPasswordForm, { baseUrl: resolvedBaseUrl, onSaved: async () => {
700
+ await accountCache.reload();
701
+ setSettingPassword(false);
702
+ } })) : revokingAccount ? (_jsx(RevokeAccountForm, { onResetPassword: startPasswordReset, baseUrl: resolvedBaseUrl, account: revokingAccount, requirePassword: requiresPasswordForAccountRevoke(accountCache.accounts ?? []), onCancel: () => setRevokingAccount(null), onRevoked: async () => {
703
+ await accountCache.reload();
704
+ setRevokingAccount(null);
705
+ } })) : totpSetup ? (_jsx(VerifyTotpSetup, { baseUrl: resolvedBaseUrl, setup: totpSetup, onVerified: async () => {
706
+ await refreshSession();
707
+ setTotpSetup(null);
708
+ setManagingTwoFactor(false);
709
+ } })) : managingTwoFactor ? (_jsx(AccountSecuritySettings, { onResetPassword: startPasswordReset, baseUrl: resolvedBaseUrl, accountCache: accountCache, onSetup: setTotpSetup })) : (_jsxs("div", { className: "flex flex-col gap-6", children: [_jsx(ConnectedAccounts, { onChangePassword: () => setChangingPassword(true), onSetupPassword: () => setSettingPassword(true), onRevokeAccount: setRevokingAccount, baseUrl: resolvedBaseUrl, accountCache: accountCache, googleEnabled: projectConfig?.authOptions.google ?? true, currentSiteHref: currentSiteHref, navigate: navigate }), _jsx(Separator, {}), _jsxs("section", { className: "flex flex-col gap-6", children: [_jsxs("div", { className: "flex flex-wrap items-start justify-between gap-3", children: [_jsxs("div", { className: "flex flex-col gap-1.5", children: [_jsx("h2", { className: "text-sm leading-none font-medium", children: m.user_two_factor_title() }), _jsx("p", { className: "text-muted-foreground text-xs", children: m.user_two_factor_description() })] }), _jsx(Badge, { variant: hasTwoFactorEnabled(session?.user)
710
+ ? "default"
711
+ : "secondary", children: hasTwoFactorEnabled(session?.user)
712
+ ? m.user_two_factor_enabled()
713
+ : m.user_two_factor_disabled() })] }), hasTwoFactorEnabled(session?.user) ? (_jsx(AccountSecuritySettings, { onResetPassword: startPasswordReset, baseUrl: resolvedBaseUrl, accountCache: accountCache, onSetup: setTotpSetup })) : (_jsx(Button, { type: "button", className: "self-start", onClick: () => setManagingTwoFactor(true), children: m.user_two_factor_enable_submit() }))] })] }))] })] }) }), _jsx(Dialog, { open: canManageUserSettings && settingsDialog === "apiKeys", onOpenChange: (open) => {
650
714
  setSettingsDialog((current) => open ? "apiKeys" : current === "apiKeys" ? null : current);
651
715
  }, children: _jsx(ScrollableDialogContent, { size: "4xl", children: _jsx(ApiKeyManager, { baseUrl: resolvedBaseUrl, active: settingsDialog === "apiKeys", locale: auth?.locale ?? "en", permissionLabels: auth?.accessLabels ?? undefined, permissions: apiKeyPermissions ?? auth?.access?.apiKeyPermissions.user ?? {} }) }) }), isAdmin ? (_jsxs(_Fragment, { children: [_jsx(Dialog, { open: settingsDialog === "adminUsers", onOpenChange: (open) => {
652
716
  setSettingsDialog((current) => open ? "adminUsers" : current === "adminUsers" ? null : current);
@@ -712,13 +776,13 @@ function PasswordSettings({ onSetupPassword, onRevokeAccount, onChangePassword,
712
776
  ? m.user_account_password_connected_description()
713
777
  : m.user_account_password_description() })] })] }), passwordAccount ? (_jsxs("div", { className: "flex items-center gap-2", children: [_jsx(Button, { type: "button", variant: "outline", onClick: onChangePassword, children: m.user_account_change() }), _jsx(Button, { type: "button", variant: "outline", onClick: () => onRevokeAccount(passwordAccount), children: m.user_account_revoke() })] })) : (_jsx(Button, { type: "button", variant: "outline", onClick: onSetupPassword, children: m.user_account_password_setup() }))] }) })) : !accountCache.error ? (_jsx("p", { className: "text-muted-foreground text-sm", children: m.user_loading() })) : null, accountCache.error ? (_jsx("p", { className: "text-destructive text-sm", children: accountCache.error })) : null] }));
714
778
  }
715
- function ChangePasswordForm({ baseUrl }) {
779
+ function ChangePasswordForm({ baseUrl, onResetPassword, }) {
716
780
  const m = useUserButtonMessages();
717
781
  const [saved, setSaved] = useState(false);
718
782
  let reset = () => { };
719
783
  const [form] = useState(() => FormReact.make(changePasswordFormBuilder, {
720
784
  runtime: authClientApi(baseUrl).runtime,
721
- fields: { currentPassword: TextField, newPassword: TextField },
785
+ fields: { currentPassword: PasswordField, newPassword: PasswordField },
722
786
  mode: { validation: "onSubmit" },
723
787
  onSubmit: (_, { decoded }) => authHttpClient(baseUrl).pipe(Effect.tap(() => Effect.sync(() => setSaved(false))), Effect.flatMap((client) => client.auth.changePassword({
724
788
  payload: {
@@ -736,13 +800,16 @@ function ChangePasswordForm({ baseUrl }) {
736
800
  event.preventDefault();
737
801
  event.stopPropagation();
738
802
  submit();
739
- }, children: [_jsx(form.currentPassword, { label: m.user_account_current_password(), type: "password", autoComplete: "current-password", required: true }), _jsx(form.newPassword, { label: m.user_account_new_password(), type: "password", autoComplete: "new-password", required: true }), _jsx(SubmitError, { result: submitResult }), saved ? (_jsx("p", { className: "text-sm text-green-600", children: m.user_account_password_change_success() })) : null, _jsx(SubmitButton, { form: form, children: m.user_account_password_change_submit() })] }) }));
803
+ }, children: [_jsx(form.currentPassword, { label: m.user_account_current_password(), autoComplete: "current-password", recovery: {
804
+ label: m.sign_in_forgot_password(),
805
+ onClick: onResetPassword,
806
+ }, required: true }), _jsx(form.newPassword, { label: m.user_account_new_password(), autoComplete: "new-password", required: true }), _jsx(SubmitError, { result: submitResult }), saved ? (_jsx("p", { className: "text-sm text-green-600", children: m.user_account_password_change_success() })) : null, _jsx(SubmitButton, { form: form, children: m.user_account_password_change_submit() })] }) }));
740
807
  }
741
808
  function SetPasswordForm({ baseUrl, onSaved, }) {
742
809
  const m = useUserButtonMessages();
743
810
  const [form] = useState(() => FormReact.make(passwordFormBuilder(true), {
744
811
  runtime: authClientApi(baseUrl).runtime,
745
- fields: { password: TextField },
812
+ fields: { password: PasswordField },
746
813
  mode: { validation: "onSubmit" },
747
814
  onSubmit: (_, { decoded }) => authHttpClient(baseUrl).pipe(Effect.flatMap((client) => client.authExtra.setPassword({
748
815
  payload: { newPassword: decoded.password },
@@ -756,13 +823,13 @@ function SetPasswordForm({ baseUrl, onSaved, }) {
756
823
  event.preventDefault();
757
824
  event.stopPropagation();
758
825
  submit();
759
- }, children: [_jsx(form.password, { label: m.user_account_new_password(), type: "password", autoComplete: "new-password", required: true }), _jsx(SubmitError, { result: submitResult }), _jsx(SubmitButton, { form: form, children: m.user_account_password_set() })] }) }));
826
+ }, children: [_jsx(form.password, { label: m.user_account_new_password(), autoComplete: "new-password", required: true }), _jsx(SubmitError, { result: submitResult }), _jsx(SubmitButton, { form: form, children: m.user_account_password_set() })] }) }));
760
827
  }
761
- function RevokeAccountForm({ baseUrl, account, requirePassword, onCancel, onRevoked, }) {
828
+ function RevokeAccountForm({ baseUrl, onResetPassword, account, requirePassword, onCancel, onRevoked, }) {
762
829
  const m = useUserButtonMessages();
763
830
  const [form] = useState(() => FormReact.make(passwordFormBuilder(requirePassword), {
764
831
  runtime: authClientApi(baseUrl).runtime,
765
- fields: { password: TextField },
832
+ fields: { password: PasswordField },
766
833
  mode: { validation: "onSubmit" },
767
834
  onSubmit: (_, { decoded }) => Effect.gen(function* () {
768
835
  const client = yield* authHttpClient(baseUrl);
@@ -793,7 +860,10 @@ function RevokeAccountForm({ baseUrl, account, requirePassword, onCancel, onRevo
793
860
  event.preventDefault();
794
861
  event.stopPropagation();
795
862
  submit();
796
- }, children: [requirePassword ? (_jsx(form.password, { label: m.user_field_password(), type: "password", autoComplete: "current-password", required: true })) : null, _jsx(SubmitError, { result: submitResult }), _jsxs("div", { className: "flex flex-wrap gap-2", children: [_jsx(Button, { type: "button", variant: "outline", onClick: onCancel, children: m.user_account_cancel() }), requirePassword ? (_jsx(SubmitButton, { form: form, children: m.user_confirm_password() })) : (_jsxs(Button, { type: "button", disabled: submitResult.waiting, onClick: () => submit(), children: [submitResult.waiting ? (_jsx(Loader2, { "data-icon": "inline-start", className: "animate-spin" })) : null, m.user_account_confirm_revoke()] }))] })] }) }));
863
+ }, children: [requirePassword ? (_jsx(form.password, { label: m.user_field_password(), autoComplete: "current-password", recovery: {
864
+ label: m.sign_in_forgot_password(),
865
+ onClick: onResetPassword,
866
+ }, required: true })) : null, _jsx(SubmitError, { result: submitResult }), _jsxs("div", { className: "flex flex-wrap gap-2", children: [_jsx(Button, { type: "button", variant: "outline", onClick: onCancel, children: m.user_account_cancel() }), requirePassword ? (_jsx(SubmitButton, { form: form, children: m.user_confirm_password() })) : (_jsxs(Button, { type: "button", disabled: submitResult.waiting, onClick: () => submit(), children: [submitResult.waiting ? (_jsx(Loader2, { "data-icon": "inline-start", className: "animate-spin" })) : null, m.user_account_confirm_revoke()] }))] })] }) }));
797
867
  }
798
868
  const providerName = (providerId, m) => {
799
869
  if (providerId === "google")
@@ -802,7 +872,7 @@ const providerName = (providerId, m) => {
802
872
  return m.user_account_password_title();
803
873
  return providerId;
804
874
  };
805
- const UserForm = ({ defaultValues, error, onSubmit, }) => {
875
+ const UserForm = ({ defaultValues, primaryEmail, error, onSubmit, }) => {
806
876
  const auth = useKrakstackAuth();
807
877
  const m = useUserButtonMessages();
808
878
  const [editingLocale, setEditingLocale] = useState(getLocale());
@@ -826,14 +896,14 @@ const UserForm = ({ defaultValues, error, onSubmit, }) => {
826
896
  event.stopPropagation();
827
897
  submit();
828
898
  }, children: _jsxs(ScrollableDialogContent, { size: "3xl", children: [_jsx(ScrollableDialogHeader, { children: _jsxs(DialogHeader, { children: [_jsx(DialogTitle, { className: "text-2xl", children: m.user_form_title() }), _jsx(DialogDescription, { children: m.user_form_description() })] }) }), _jsxs(ScrollableDialogBody, { className: "flex flex-col gap-4", padding: "form", children: [_jsxs("div", { className: "flex flex-col gap-1.5", children: [_jsx("h2", { className: "text-sm leading-none font-medium", children: m.user_profile_title() }), _jsx("p", { className: "text-muted-foreground text-sm", children: m.user_profile_description() })] }), _jsx(form.image, { label: m.user_profile_photo_upload_label(), size: {
829
- width: 96,
830
- height: 96,
899
+ width: 40,
900
+ height: 40,
831
901
  suggestedWidth: 512,
832
902
  suggestedHeight: 512,
833
- } }), _jsx(form.name, { label: m.user_form_name_label(), autoComplete: "name", required: true }), _jsx(Separator, {}), _jsxs("div", { className: "flex flex-col gap-4", children: [_jsxs("div", { className: "flex flex-wrap items-start justify-between gap-3", children: [_jsxs("div", { className: "flex flex-col gap-1.5", children: [_jsx("h3", { className: "text-sm leading-none font-medium", children: m.user_contact_title() }), _jsx("p", { className: "text-muted-foreground text-sm", children: m.user_contact_description() })] }), _jsx(EditingLocaleSwitcher, { locale: auth?.locale, value: editingLocale, onValueChange: (value) => setEditingLocale(value === "fr" ? "fr" : "en") })] }), _jsx(UserContactGroup, { title: m.user_contact_email_type(), children: _jsx(form.emails, { locale: editingLocale, maxItems: USER_CONTACT_LIMIT, messages: userContactFieldMessages(m) }) }), _jsx(UserContactGroup, { title: m.user_contact_phone_type(), children: _jsx(form.phones, { locale: editingLocale, maxItems: USER_CONTACT_LIMIT, messages: userContactFieldMessages(m) }) }), _jsx(UserContactGroup, { title: m.user_contact_website_type(), children: _jsx(form.websites, { locale: editingLocale, maxItems: USER_CONTACT_LIMIT, messages: userContactFieldMessages(m) }) }), _jsx(UserContactGroup, { title: m.user_contact_social_type(), children: _jsx(form.socials, { locale: editingLocale, maxItems: USER_CONTACT_LIMIT, messages: userContactFieldMessages(m) }) })] })] }), _jsx(DialogFooter, { className: "-mx-6 -mb-6 border-t px-6 py-4", children: _jsxs("div", { className: "flex flex-col gap-3", children: [error && (_jsx("p", { role: "alert", className: "text-destructive text-sm", children: error })), _jsx(SubmitButton, { form: form })] }) })] }) }) }));
903
+ } }), _jsx(form.name, { label: m.user_form_name_label(), autoComplete: "name", required: true }), _jsx(Separator, {}), _jsxs("div", { className: "flex flex-col gap-4", children: [_jsxs("div", { className: "flex flex-wrap items-start justify-between gap-3", children: [_jsxs("div", { className: "flex flex-col gap-1.5", children: [_jsx("h3", { className: "text-sm leading-none font-medium", children: m.user_contact_title() }), _jsx("p", { className: "text-muted-foreground text-sm", children: m.user_contact_description() })] }), _jsx(EditingLocaleSwitcher, { locale: auth?.locale, value: editingLocale, onValueChange: (value) => setEditingLocale(value === "fr" ? "fr" : "en") })] }), _jsxs(UserContactGroup, { title: m.user_contact_email_type(), children: [_jsxs("div", { className: "bg-muted/20 rounded-lg border p-4", children: [_jsx(FieldLabel, { htmlFor: "user-primary-contact-email", children: m.user_contact_primary() }), _jsx(Input, { id: "user-primary-contact-email", className: "mt-2", type: "email", value: primaryEmail, readOnly: true })] }), _jsx(form.emails, { locale: editingLocale, maxItems: USER_CONTACT_LIMIT - 1, messages: userContactFieldMessages(m) })] }), _jsx(UserContactGroup, { title: m.user_contact_phone_type(), children: _jsx(form.phones, { locale: editingLocale, maxItems: USER_CONTACT_LIMIT, messages: userContactFieldMessages(m) }) }), _jsx(UserContactGroup, { title: m.user_contact_website_type(), children: _jsx(form.websites, { locale: editingLocale, maxItems: USER_CONTACT_LIMIT, messages: userContactFieldMessages(m) }) }), _jsx(UserContactGroup, { title: m.user_contact_social_type(), children: _jsx(form.socials, { locale: editingLocale, maxItems: USER_CONTACT_LIMIT, messages: userContactFieldMessages(m) }) })] })] }), _jsx(DialogFooter, { className: "-mx-6 -mb-6 border-t px-6 py-4", children: _jsxs("div", { className: "flex flex-col gap-3", children: [error && (_jsx("p", { role: "alert", className: "text-destructive text-sm", children: error })), _jsx(SubmitButton, { form: form })] }) })] }) }) }));
834
904
  };
835
905
  const UserContactGroup = ({ children, title, }) => (_jsxs("div", { className: "flex flex-col gap-3", children: [_jsx("h4", { className: "text-sm font-medium", children: title }), children] }));
836
- function AccountSecuritySettings({ baseUrl, accountCache, onSetup, }) {
906
+ function AccountSecuritySettings({ baseUrl, onResetPassword, accountCache, onSetup, }) {
837
907
  const m = useUserButtonMessages();
838
908
  const sessionAtom = authSessionAtom(baseUrl);
839
909
  const sessionResult = useAtomValue(sessionAtom);
@@ -850,16 +920,16 @@ function AccountSecuritySettings({ baseUrl, accountCache, onSetup, }) {
850
920
  : null;
851
921
  return (_jsxs("div", { className: "flex flex-col gap-6", children: [requirePassword === null ? (_jsx("p", { className: accountCache.error
852
922
  ? "text-destructive text-sm"
853
- : "text-muted-foreground text-sm", children: accountCache.error ?? m.user_loading() })) : twoFactorEnabled ? (_jsx(DisableTotpForm, { baseUrl: baseUrl, requirePassword: requirePassword, onDisabled: async () => {
923
+ : "text-muted-foreground text-sm", children: accountCache.error ?? m.user_loading() })) : twoFactorEnabled ? (_jsx(DisableTotpForm, { onResetPassword: onResetPassword, baseUrl: baseUrl, requirePassword: requirePassword, onDisabled: async () => {
854
924
  setMessage(m.user_two_factor_disabled_message());
855
925
  await refreshSession();
856
- } })) : (_jsx(EnableTotpForm, { baseUrl: baseUrl, requirePassword: requirePassword, onEnabled: onSetup })), message ? (_jsx("p", { className: "text-muted-foreground text-sm", children: message })) : null] }));
926
+ } })) : (_jsx(EnableTotpForm, { onResetPassword: onResetPassword, baseUrl: baseUrl, requirePassword: requirePassword, onEnabled: onSetup })), message ? (_jsx("p", { className: "text-muted-foreground text-sm", children: message })) : null] }));
857
927
  }
858
- function EnableTotpForm({ baseUrl, requirePassword, onEnabled, }) {
928
+ function EnableTotpForm({ baseUrl, onResetPassword, requirePassword, onEnabled, }) {
859
929
  const m = useUserButtonMessages();
860
930
  const [form] = useState(() => FormReact.make(passwordFormBuilder(requirePassword), {
861
931
  runtime: authClientApi(baseUrl).runtime,
862
- fields: { password: TextField },
932
+ fields: { password: PasswordField },
863
933
  mode: { validation: "onSubmit" },
864
934
  onSubmit: (_, { decoded }) => authHttpClient(baseUrl).pipe(Effect.flatMap((client) => client.auth.twoFactorEnable({
865
935
  payload: requirePassword ? { password: decoded.password } : {},
@@ -883,7 +953,10 @@ function EnableTotpForm({ baseUrl, requirePassword, onEnabled, }) {
883
953
  event.preventDefault();
884
954
  event.stopPropagation();
885
955
  submit();
886
- }, children: [requirePassword ? (_jsx(form.password, { label: m.user_field_password(), type: "password", autoComplete: "current-password", required: true })) : null, _jsx(SubmitError, { result: submitResult }), requirePassword ? (_jsx(SubmitButton, { form: form, children: m.user_confirm_password() })) : (_jsxs(Button, { type: "button", disabled: submitResult.waiting, onClick: () => submit(), children: [submitResult.waiting ? (_jsx(Loader2, { "data-icon": "inline-start", className: "animate-spin" })) : null, m.user_two_factor_enable_submit()] }))] }) }));
956
+ }, children: [requirePassword ? (_jsx(form.password, { label: m.user_field_password(), autoComplete: "current-password", recovery: {
957
+ label: m.sign_in_forgot_password(),
958
+ onClick: onResetPassword,
959
+ }, required: true })) : null, _jsx(SubmitError, { result: submitResult }), requirePassword ? (_jsx(SubmitButton, { form: form, children: m.user_confirm_password() })) : (_jsxs(Button, { type: "button", disabled: submitResult.waiting, onClick: () => submit(), children: [submitResult.waiting ? (_jsx(Loader2, { "data-icon": "inline-start", className: "animate-spin" })) : null, m.user_two_factor_enable_submit()] }))] }) }));
887
960
  }
888
961
  function VerifyTotpSetup({ baseUrl, setup, onVerified, }) {
889
962
  const m = useUserButtonMessages();
@@ -905,11 +978,11 @@ function VerifyTotpSetup({ baseUrl, setup, onVerified, }) {
905
978
  submit();
906
979
  }, children: [_jsx(form.code, { label: m.user_two_factor_code(), autoComplete: "one-time-code", inputMode: "numeric", required: true }), _jsx(SubmitError, { result: submitResult }), _jsx(SubmitButton, { form: form })] }) })] }));
907
980
  }
908
- function DisableTotpForm({ baseUrl, requirePassword, onDisabled, }) {
981
+ function DisableTotpForm({ baseUrl, onResetPassword, requirePassword, onDisabled, }) {
909
982
  const m = useUserButtonMessages();
910
983
  const [form] = useState(() => FormReact.make(passwordFormBuilder(requirePassword), {
911
984
  runtime: authClientApi(baseUrl).runtime,
912
- fields: { password: TextField },
985
+ fields: { password: PasswordField },
913
986
  mode: { validation: "onSubmit" },
914
987
  onSubmit: (_, { decoded }) => authHttpClient(baseUrl).pipe(Effect.flatMap((client) => client.auth.twoFactorDisable({
915
988
  payload: requirePassword ? { password: decoded.password } : {},
@@ -923,7 +996,10 @@ function DisableTotpForm({ baseUrl, requirePassword, onDisabled, }) {
923
996
  event.preventDefault();
924
997
  event.stopPropagation();
925
998
  submit();
926
- }, children: [requirePassword ? (_jsx(form.password, { label: m.user_field_password(), type: "password", autoComplete: "current-password", required: true })) : null, _jsx(SubmitError, { result: submitResult }), requirePassword ? (_jsx(SubmitButton, { form: form, children: m.user_confirm_password() })) : (_jsxs(Button, { type: "button", disabled: submitResult.waiting, onClick: () => submit(), children: [submitResult.waiting ? (_jsx(Loader2, { "data-icon": "inline-start", className: "animate-spin" })) : null, effectFormMessages().submit] }))] }) }));
999
+ }, children: [requirePassword ? (_jsx(form.password, { label: m.user_field_password(), autoComplete: "current-password", recovery: {
1000
+ label: m.sign_in_forgot_password(),
1001
+ onClick: onResetPassword,
1002
+ }, required: true })) : null, _jsx(SubmitError, { result: submitResult }), requirePassword ? (_jsx(SubmitButton, { form: form, children: m.user_confirm_password() })) : (_jsxs(Button, { type: "button", disabled: submitResult.waiting, onClick: () => submit(), children: [submitResult.waiting ? (_jsx(Loader2, { "data-icon": "inline-start", className: "animate-spin" })) : null, effectFormMessages().submit] }))] }) }));
927
1003
  }
928
1004
  function ApiKeyManager({ baseUrl, active, locale, permissionLabels, permissions = {}, }) {
929
1005
  const m = useUserButtonMessages();
@@ -995,7 +1071,11 @@ function ApiKeyManager({ baseUrl, active, locale, permissionLabels, permissions
995
1071
  ? cause.message
996
1072
  : m.user_api_key_delete_error()))))));
997
1073
  const deleteKey = useAtomSet(deleteKeyAction);
998
- return (_jsxs(_Fragment, { children: [_jsx(ScrollableDialogHeader, { children: _jsxs(DialogHeader, { className: "sm:flex-row sm:items-end sm:justify-between sm:gap-4", children: [_jsxs("div", { className: "flex min-w-0 flex-col gap-2", children: [_jsx(DialogTitle, { className: "text-2xl", children: editingKey
1074
+ return (_jsxs(_Fragment, { children: [_jsx(ScrollableDialogHeader, { children: _jsxs(DialogHeader, { className: "gap-4", children: [creating || editingKey ? (_jsxs(Button, { className: "h-auto w-fit p-0", onClick: () => {
1075
+ setCreating(false);
1076
+ setCreatedKey(null);
1077
+ setEditingKey(null);
1078
+ }, type: "button", variant: "link", children: [_jsx(ArrowLeft, {}), m.user_api_key_back()] })) : null, _jsxs("div", { className: "flex min-w-0 flex-col gap-2", children: [_jsx(DialogTitle, { className: "text-2xl", children: editingKey
999
1079
  ? m.user_api_key_edit_title()
1000
1080
  : createdKey
1001
1081
  ? m.user_api_key_created_title()
@@ -1007,14 +1087,10 @@ function ApiKeyManager({ baseUrl, active, locale, permissionLabels, permissions
1007
1087
  ? m.user_api_key_created_description()
1008
1088
  : creating
1009
1089
  ? m.user_api_key_create_description()
1010
- : m.user_api_keys_description() })] }), creating || editingKey ? (_jsxs(Button, { className: "mt-2 w-fit sm:mt-0", onClick: () => {
1011
- setCreating(false);
1012
- setCreatedKey(null);
1013
- setEditingKey(null);
1014
- }, type: "button", variant: "secondary", children: [_jsx(ArrowLeft, {}), m.user_api_key_back()] })) : (_jsxs(Button, { className: "mt-2 w-fit sm:mt-0", onClick: () => {
1090
+ : m.user_api_keys_description() })] }), !creating && !editingKey ? (_jsxs(Button, { className: "w-fit", onClick: () => {
1015
1091
  setCreatedKey(null);
1016
1092
  setCreating(true);
1017
- }, type: "button", children: [_jsx(Plus, {}), m.user_api_key_create_title()] }))] }) }), _jsxs(ScrollableDialogBody, { className: "flex min-w-0 flex-col gap-5", children: [creating && !createdKey ? (_jsx("section", { className: "w-full", children: _jsx(createForm.Initialize, { defaultValues: { name: "", referrers: "" }, children: _jsxs("form", { className: "flex flex-col gap-4", onSubmit: (event) => {
1093
+ }, type: "button", children: [_jsx(Plus, {}), m.user_api_key_create_title()] })) : null] }) }), _jsxs(ScrollableDialogBody, { className: "flex min-w-0 flex-col gap-5", children: [creating && !createdKey ? (_jsx("section", { className: "w-full", children: _jsx(createForm.Initialize, { defaultValues: { name: "", referrers: "" }, children: _jsxs("form", { className: "flex flex-col gap-4", onSubmit: (event) => {
1018
1094
  event.preventDefault();
1019
1095
  event.stopPropagation();
1020
1096
  submitCreateForm();
@@ -1086,9 +1162,11 @@ const apiKeyColumns = ({ m, }) => [
1086
1162
  {
1087
1163
  field: "permissions",
1088
1164
  headerName: m.user_api_key_permissions(),
1089
- cellRenderer: ({ data }) => {
1090
- const permissions = formatPermissions(data.permissions);
1091
- return (_jsx(DataTableListSummary, { emptyLabel: m.user_api_key_no_permissions(), items: permissions, visibleCount: 1 }));
1165
+ type: "list",
1166
+ typeOptions: {
1167
+ getItems: (data) => formatPermissions(data.permissions).map((label) => ({ label })),
1168
+ emptyLabel: m.user_api_key_no_permissions(),
1169
+ visibleCount: 1,
1092
1170
  },
1093
1171
  },
1094
1172
  ];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@krak-stack/auth",
3
- "version": "0.2.21",
3
+ "version": "0.2.23",
4
4
  "description": "Effect HttpApi clients and schemas for KrakStack Auth.",
5
5
  "license": "MIT",
6
6
  "files": [
@@ -76,10 +76,10 @@
76
76
  "react-qr-code": "^2.2.0"
77
77
  },
78
78
  "devDependencies": {
79
- "@krak-stack/registry": "0.1.44"
79
+ "@krak-stack/registry": "0.1.48"
80
80
  },
81
81
  "peerDependencies": {
82
- "@krak-stack/registry": "^0.1.44",
82
+ "@krak-stack/registry": "^0.1.48",
83
83
  "@tanstack/react-router": "^1.170.15",
84
84
  "effect": "^4.0.0",
85
85
  "input-otp": "^1.5.0",