cauthy-auth 0.32.0 → 0.34.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/next.d.mts CHANGED
@@ -1,5 +1,5 @@
1
- import { C as Cauthy } from './cauthy-2jtP2LVQ.mjs';
2
- import { S as Session } from './system-BrrJsrFW.mjs';
1
+ import { C as Cauthy } from './cauthy-C-GoRXy9.mjs';
2
+ import { S as Session } from './system-DUGV040y.mjs';
3
3
  import 'jose';
4
4
  import './theme.mjs';
5
5
 
package/dist/next.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { C as Cauthy } from './cauthy-CKfvvv_i.js';
2
- import { S as Session } from './system-BvvoNs2y.js';
1
+ import { C as Cauthy } from './cauthy-BUozWD72.js';
2
+ import { S as Session } from './system-Bz4haPrI.js';
3
3
  import 'jose';
4
4
  import './theme.js';
5
5
 
package/dist/react.d.mts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as react from 'react';
2
- import { ComponentType, ReactNode } from 'react';
2
+ import { ComponentType, FormEvent, ReactNode } from 'react';
3
3
 
4
4
  /** How an application looks on Cauthy's hosted pages. Every value is optional. */
5
5
  /** One font file the application serves: a family in one weight (or a range) and one style. */
@@ -620,7 +620,11 @@ interface OrganizationsClient {
620
620
  members(organizationId: string): Promise<OrganizationPerson[] | null>;
621
621
  /** The roles a member may be given, or null when the person may not see them. */
622
622
  roles(organizationId: string): Promise<OrganizationRoleChoice[] | null>;
623
- /** Adds a person by their address; an address with no account gets one and its invitation. */
623
+ /**
624
+ * Adds a person by their address; an address with no account gets one and
625
+ * its invitation. It only adds: a person who already belongs keeps their
626
+ * role and the result is the error `member_exists` (change it with `setRole`).
627
+ */
624
628
  add(organizationId: string, form: {
625
629
  email: string;
626
630
  role: string;
@@ -1318,20 +1322,51 @@ interface AuthFormProps {
1318
1322
  */
1319
1323
  workspaceLook?: boolean;
1320
1324
  /**
1321
- * The application's own parts, to draw the form with: its button, input,
1322
- * checkbox, select, field, text, badge, link, divider, alert and
1323
- * confirmation. A part not given is drawn as before; with every part given
1325
+ * The application's own parts, to draw the form with: its form layout,
1326
+ * button, input, checkbox, select, field, text, badge, link, divider, alert
1327
+ * and confirmation. A part not given is drawn as before; with every part given
1324
1328
  * and `unstyled`, the form adds no element that carries a look of its own.
1325
1329
  */
1326
1330
  components?: AuthComponents;
1327
1331
  }
1328
- /** What the application's button is given: what a `<button>` would be. */
1332
+ /**
1333
+ * What the application's button is given: what a `<button>` would be, and
1334
+ * what kind of button it is. `primary` sends the form; `secondary` is any
1335
+ * other action (a provider, a passkey, a sign-in link, cancel, send again);
1336
+ * `danger` removes, leaves, deletes, disconnects or turns something off.
1337
+ * `loading` is true on the one button whose action is under way; every
1338
+ * button is `disabled` meanwhile, as before.
1339
+ */
1329
1340
  interface AuthButtonProps {
1330
1341
  type: 'submit' | 'button';
1331
1342
  disabled?: boolean;
1332
1343
  className?: string;
1333
1344
  onClick?: () => void;
1334
1345
  children: ReactNode;
1346
+ variant?: 'primary' | 'secondary' | 'danger';
1347
+ loading?: boolean;
1348
+ }
1349
+ /**
1350
+ * What the application's form layout is given: every element the forms put
1351
+ * around their parts — a whole form, each step of it, each part of the
1352
+ * account and members screens — so its own stack lays them out. `as` says
1353
+ * which element it stands for: a `form` sends with `onSubmit` (render a
1354
+ * `<form>` with it for Enter to submit), a `div` only groups.
1355
+ */
1356
+ interface AuthFormLayoutProps {
1357
+ as: 'form' | 'div';
1358
+ onSubmit?: (e: FormEvent) => void;
1359
+ noValidate?: boolean;
1360
+ 'aria-busy'?: boolean;
1361
+ className?: string;
1362
+ /**
1363
+ * Which part of `<Account />` or `<OrganizationMembers />` this is, for an
1364
+ * application that draws each as a card: an `AccountSection`
1365
+ * (`profile`, `passkeys`…), or `members`, `add-member`, `organization`
1366
+ * and `rename` (the form inside `organization`). Not set on a whole form.
1367
+ */
1368
+ section?: string;
1369
+ children: ReactNode;
1335
1370
  }
1336
1371
  /** What the application's input is given: what an `<input>` would be. */
1337
1372
  interface AuthInputProps {
@@ -1434,6 +1469,12 @@ interface AuthConfirmOptions {
1434
1469
  }
1435
1470
  /** The parts a form may be drawn with. See `AuthFormProps.components`. */
1436
1471
  interface AuthComponents {
1472
+ /**
1473
+ * Every element around the form's parts: the form itself, each step, each
1474
+ * part of the account and members screens. Not given: the `form`, `div` or
1475
+ * `section` the forms have always drawn.
1476
+ */
1477
+ Form?: ComponentType<AuthFormLayoutProps>;
1437
1478
  Button?: ComponentType<AuthButtonProps>;
1438
1479
  Input?: ComponentType<AuthInputProps>;
1439
1480
  Checkbox?: ComponentType<AuthCheckboxProps>;
@@ -1639,6 +1680,8 @@ interface OrganizationMembersProps extends Omit<AuthFormProps, 'links' | 'return
1639
1680
  roles?: (role: string, choice: OrganizationRoleChoice) => boolean;
1640
1681
  /** Actions never offered, whatever the person's role allows. */
1641
1682
  hide?: OrganizationMembersAction[];
1683
+ /** A role's name wherever one shows: a member's, the role choices, adding one. Default: the name the catalog gives it. */
1684
+ roleLabel?: (choice: OrganizationRoleChoice) => string;
1642
1685
  /** Called after every change saved, with what changed. */
1643
1686
  onSaved?: (event: OrganizationMembersEvent) => void;
1644
1687
  }
@@ -1684,8 +1727,16 @@ interface CauthyProviderProps {
1684
1727
  * out when the server did not look.
1685
1728
  */
1686
1729
  initialSession?: PublicSession | null;
1730
+ /**
1731
+ * The language the person reads, for what Cauthy mails them from
1732
+ * `useAuth()` and the ready-made forms (a sign-in link, a new password, a
1733
+ * confirmation): a tag like `es` or `es-CO`, or a function that answers it
1734
+ * when the person can change it. Default: the page's own (`<html lang>`),
1735
+ * else the browser's.
1736
+ */
1737
+ locale?: string | (() => string | undefined);
1687
1738
  }
1688
- declare function CauthyProvider({ children, basePath, initialSession }: CauthyProviderProps): react.JSX.Element;
1739
+ declare function CauthyProvider({ children, basePath, initialSession, locale }: CauthyProviderProps): react.JSX.Element;
1689
1740
  declare function useSession(): SessionContext;
1690
1741
  /**
1691
1742
  * The application's own sign-in screens: the functions a form calls.
@@ -1698,4 +1749,4 @@ declare function useSession(): SessionContext;
1698
1749
  */
1699
1750
  declare function useAuth(): AuthClient & Pick<SessionContext, 'session' | 'status' | 'refresh'>;
1700
1751
 
1701
- export { AcceptInvite, type AcceptInviteEvent, type AcceptInviteProps, Account, AccountAgents, type AccountClient, type Account$1 as AccountDetails, AccountEmail, type AccountEvent, AccountLinked, type AccountPartProps, AccountPasskeys, AccountPassword, AccountPhone, AccountProfile, type AccountProps, AccountSecondStep, type AccountSection, type AccountSession, AccountSessions, type AuthAlertProps, type AuthBadgeProps, type AuthButtonProps, type AuthCheckboxProps, type AuthClient, type AuthComponents, type AuthConfirmOptions, type AuthDividerProps, type AuthError, type AuthFieldProps, type AuthFormProps, type AuthInputProps, type AuthLinkProps, type AuthMethods, type AuthResult, type AuthSelectProps, type AuthTextProps, type AuthTexts, CauthyProvider, type CauthyProviderProps, type ConnectedAgent, ForgotPassword, GoogleOneTap, type GoogleOneTapProps, type Invitation, type JsonValue, type LinkedIdentity, OrganizationMembers, type OrganizationMembersAction, type OrganizationMembersEvent, type OrganizationMembersProps, type OrganizationPerson, type OrganizationRoleChoice, type OrganizationSeat, type OrganizationsClient, type Passkey, type PasskeyKind, type PendingLegal, PendingTerms, type PendingTermsProps, type PermissionOf, type Policy, type PublicSession, ResetPassword, type RoleOf, type SSOConnection, type SecondStep, type SessionContext, type SessionOrganization, type SessionUser, SignIn, SignUp, VerifyEmail, can, canAutofillPasskeys, canUsePasskeys, createAuthClient, definePolicy, useAuth, useSession };
1752
+ export { AcceptInvite, type AcceptInviteEvent, type AcceptInviteProps, Account, AccountAgents, type AccountClient, type Account$1 as AccountDetails, AccountEmail, type AccountEvent, AccountLinked, type AccountPartProps, AccountPasskeys, AccountPassword, AccountPhone, AccountProfile, type AccountProps, AccountSecondStep, type AccountSection, type AccountSession, AccountSessions, type AuthAlertProps, type AuthBadgeProps, type AuthButtonProps, type AuthCheckboxProps, type AuthClient, type AuthComponents, type AuthConfirmOptions, type AuthDividerProps, type AuthError, type AuthFieldProps, type AuthFormLayoutProps, type AuthFormProps, type AuthInputProps, type AuthLinkProps, type AuthMethods, type AuthResult, type AuthSelectProps, type AuthTextProps, type AuthTexts, CauthyProvider, type CauthyProviderProps, type ConnectedAgent, ForgotPassword, GoogleOneTap, type GoogleOneTapProps, type Invitation, type JsonValue, type LinkedIdentity, OrganizationMembers, type OrganizationMembersAction, type OrganizationMembersEvent, type OrganizationMembersProps, type OrganizationPerson, type OrganizationRoleChoice, type OrganizationSeat, type OrganizationsClient, type Passkey, type PasskeyKind, type PendingLegal, PendingTerms, type PendingTermsProps, type PermissionOf, type Policy, type PublicSession, ResetPassword, type RoleOf, type SSOConnection, type SecondStep, type SessionContext, type SessionOrganization, type SessionUser, SignIn, SignUp, VerifyEmail, can, canAutofillPasskeys, canUsePasskeys, createAuthClient, definePolicy, useAuth, useSession };
package/dist/react.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as react from 'react';
2
- import { ComponentType, ReactNode } from 'react';
2
+ import { ComponentType, FormEvent, ReactNode } from 'react';
3
3
 
4
4
  /** How an application looks on Cauthy's hosted pages. Every value is optional. */
5
5
  /** One font file the application serves: a family in one weight (or a range) and one style. */
@@ -620,7 +620,11 @@ interface OrganizationsClient {
620
620
  members(organizationId: string): Promise<OrganizationPerson[] | null>;
621
621
  /** The roles a member may be given, or null when the person may not see them. */
622
622
  roles(organizationId: string): Promise<OrganizationRoleChoice[] | null>;
623
- /** Adds a person by their address; an address with no account gets one and its invitation. */
623
+ /**
624
+ * Adds a person by their address; an address with no account gets one and
625
+ * its invitation. It only adds: a person who already belongs keeps their
626
+ * role and the result is the error `member_exists` (change it with `setRole`).
627
+ */
624
628
  add(organizationId: string, form: {
625
629
  email: string;
626
630
  role: string;
@@ -1318,20 +1322,51 @@ interface AuthFormProps {
1318
1322
  */
1319
1323
  workspaceLook?: boolean;
1320
1324
  /**
1321
- * The application's own parts, to draw the form with: its button, input,
1322
- * checkbox, select, field, text, badge, link, divider, alert and
1323
- * confirmation. A part not given is drawn as before; with every part given
1325
+ * The application's own parts, to draw the form with: its form layout,
1326
+ * button, input, checkbox, select, field, text, badge, link, divider, alert
1327
+ * and confirmation. A part not given is drawn as before; with every part given
1324
1328
  * and `unstyled`, the form adds no element that carries a look of its own.
1325
1329
  */
1326
1330
  components?: AuthComponents;
1327
1331
  }
1328
- /** What the application's button is given: what a `<button>` would be. */
1332
+ /**
1333
+ * What the application's button is given: what a `<button>` would be, and
1334
+ * what kind of button it is. `primary` sends the form; `secondary` is any
1335
+ * other action (a provider, a passkey, a sign-in link, cancel, send again);
1336
+ * `danger` removes, leaves, deletes, disconnects or turns something off.
1337
+ * `loading` is true on the one button whose action is under way; every
1338
+ * button is `disabled` meanwhile, as before.
1339
+ */
1329
1340
  interface AuthButtonProps {
1330
1341
  type: 'submit' | 'button';
1331
1342
  disabled?: boolean;
1332
1343
  className?: string;
1333
1344
  onClick?: () => void;
1334
1345
  children: ReactNode;
1346
+ variant?: 'primary' | 'secondary' | 'danger';
1347
+ loading?: boolean;
1348
+ }
1349
+ /**
1350
+ * What the application's form layout is given: every element the forms put
1351
+ * around their parts — a whole form, each step of it, each part of the
1352
+ * account and members screens — so its own stack lays them out. `as` says
1353
+ * which element it stands for: a `form` sends with `onSubmit` (render a
1354
+ * `<form>` with it for Enter to submit), a `div` only groups.
1355
+ */
1356
+ interface AuthFormLayoutProps {
1357
+ as: 'form' | 'div';
1358
+ onSubmit?: (e: FormEvent) => void;
1359
+ noValidate?: boolean;
1360
+ 'aria-busy'?: boolean;
1361
+ className?: string;
1362
+ /**
1363
+ * Which part of `<Account />` or `<OrganizationMembers />` this is, for an
1364
+ * application that draws each as a card: an `AccountSection`
1365
+ * (`profile`, `passkeys`…), or `members`, `add-member`, `organization`
1366
+ * and `rename` (the form inside `organization`). Not set on a whole form.
1367
+ */
1368
+ section?: string;
1369
+ children: ReactNode;
1335
1370
  }
1336
1371
  /** What the application's input is given: what an `<input>` would be. */
1337
1372
  interface AuthInputProps {
@@ -1434,6 +1469,12 @@ interface AuthConfirmOptions {
1434
1469
  }
1435
1470
  /** The parts a form may be drawn with. See `AuthFormProps.components`. */
1436
1471
  interface AuthComponents {
1472
+ /**
1473
+ * Every element around the form's parts: the form itself, each step, each
1474
+ * part of the account and members screens. Not given: the `form`, `div` or
1475
+ * `section` the forms have always drawn.
1476
+ */
1477
+ Form?: ComponentType<AuthFormLayoutProps>;
1437
1478
  Button?: ComponentType<AuthButtonProps>;
1438
1479
  Input?: ComponentType<AuthInputProps>;
1439
1480
  Checkbox?: ComponentType<AuthCheckboxProps>;
@@ -1639,6 +1680,8 @@ interface OrganizationMembersProps extends Omit<AuthFormProps, 'links' | 'return
1639
1680
  roles?: (role: string, choice: OrganizationRoleChoice) => boolean;
1640
1681
  /** Actions never offered, whatever the person's role allows. */
1641
1682
  hide?: OrganizationMembersAction[];
1683
+ /** A role's name wherever one shows: a member's, the role choices, adding one. Default: the name the catalog gives it. */
1684
+ roleLabel?: (choice: OrganizationRoleChoice) => string;
1642
1685
  /** Called after every change saved, with what changed. */
1643
1686
  onSaved?: (event: OrganizationMembersEvent) => void;
1644
1687
  }
@@ -1684,8 +1727,16 @@ interface CauthyProviderProps {
1684
1727
  * out when the server did not look.
1685
1728
  */
1686
1729
  initialSession?: PublicSession | null;
1730
+ /**
1731
+ * The language the person reads, for what Cauthy mails them from
1732
+ * `useAuth()` and the ready-made forms (a sign-in link, a new password, a
1733
+ * confirmation): a tag like `es` or `es-CO`, or a function that answers it
1734
+ * when the person can change it. Default: the page's own (`<html lang>`),
1735
+ * else the browser's.
1736
+ */
1737
+ locale?: string | (() => string | undefined);
1687
1738
  }
1688
- declare function CauthyProvider({ children, basePath, initialSession }: CauthyProviderProps): react.JSX.Element;
1739
+ declare function CauthyProvider({ children, basePath, initialSession, locale }: CauthyProviderProps): react.JSX.Element;
1689
1740
  declare function useSession(): SessionContext;
1690
1741
  /**
1691
1742
  * The application's own sign-in screens: the functions a form calls.
@@ -1698,4 +1749,4 @@ declare function useSession(): SessionContext;
1698
1749
  */
1699
1750
  declare function useAuth(): AuthClient & Pick<SessionContext, 'session' | 'status' | 'refresh'>;
1700
1751
 
1701
- export { AcceptInvite, type AcceptInviteEvent, type AcceptInviteProps, Account, AccountAgents, type AccountClient, type Account$1 as AccountDetails, AccountEmail, type AccountEvent, AccountLinked, type AccountPartProps, AccountPasskeys, AccountPassword, AccountPhone, AccountProfile, type AccountProps, AccountSecondStep, type AccountSection, type AccountSession, AccountSessions, type AuthAlertProps, type AuthBadgeProps, type AuthButtonProps, type AuthCheckboxProps, type AuthClient, type AuthComponents, type AuthConfirmOptions, type AuthDividerProps, type AuthError, type AuthFieldProps, type AuthFormProps, type AuthInputProps, type AuthLinkProps, type AuthMethods, type AuthResult, type AuthSelectProps, type AuthTextProps, type AuthTexts, CauthyProvider, type CauthyProviderProps, type ConnectedAgent, ForgotPassword, GoogleOneTap, type GoogleOneTapProps, type Invitation, type JsonValue, type LinkedIdentity, OrganizationMembers, type OrganizationMembersAction, type OrganizationMembersEvent, type OrganizationMembersProps, type OrganizationPerson, type OrganizationRoleChoice, type OrganizationSeat, type OrganizationsClient, type Passkey, type PasskeyKind, type PendingLegal, PendingTerms, type PendingTermsProps, type PermissionOf, type Policy, type PublicSession, ResetPassword, type RoleOf, type SSOConnection, type SecondStep, type SessionContext, type SessionOrganization, type SessionUser, SignIn, SignUp, VerifyEmail, can, canAutofillPasskeys, canUsePasskeys, createAuthClient, definePolicy, useAuth, useSession };
1752
+ export { AcceptInvite, type AcceptInviteEvent, type AcceptInviteProps, Account, AccountAgents, type AccountClient, type Account$1 as AccountDetails, AccountEmail, type AccountEvent, AccountLinked, type AccountPartProps, AccountPasskeys, AccountPassword, AccountPhone, AccountProfile, type AccountProps, AccountSecondStep, type AccountSection, type AccountSession, AccountSessions, type AuthAlertProps, type AuthBadgeProps, type AuthButtonProps, type AuthCheckboxProps, type AuthClient, type AuthComponents, type AuthConfirmOptions, type AuthDividerProps, type AuthError, type AuthFieldProps, type AuthFormLayoutProps, type AuthFormProps, type AuthInputProps, type AuthLinkProps, type AuthMethods, type AuthResult, type AuthSelectProps, type AuthTextProps, type AuthTexts, CauthyProvider, type CauthyProviderProps, type ConnectedAgent, ForgotPassword, GoogleOneTap, type GoogleOneTapProps, type Invitation, type JsonValue, type LinkedIdentity, OrganizationMembers, type OrganizationMembersAction, type OrganizationMembersEvent, type OrganizationMembersProps, type OrganizationPerson, type OrganizationRoleChoice, type OrganizationSeat, type OrganizationsClient, type Passkey, type PasskeyKind, type PendingLegal, PendingTerms, type PendingTermsProps, type PermissionOf, type Policy, type PublicSession, ResetPassword, type RoleOf, type SSOConnection, type SecondStep, type SessionContext, type SessionOrganization, type SessionUser, SignIn, SignUp, VerifyEmail, can, canAutofillPasskeys, canUsePasskeys, createAuthClient, definePolicy, useAuth, useSession };