cauthy-auth 0.31.0 → 0.33.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +59 -2
- package/dist/react.d.mts +329 -30
- package/dist/react.d.ts +329 -30
- package/dist/react.js +617 -290
- package/dist/react.js.map +1 -1
- package/dist/react.mjs +615 -298
- package/dist/react.mjs.map +1 -1
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -56,6 +56,7 @@ export const auth = createCauthy({ pages: { signIn: '/sign-in', resetPassword: '
|
|
|
56
56
|
```tsx
|
|
57
57
|
import { AcceptInvite, ResetPassword, VerifyEmail } from 'cauthy-auth/react'
|
|
58
58
|
<AcceptInvite links={{ signIn: '/sign-in' }} returnTo="/" /> // "You've been invited to Acme", a password, signed in
|
|
59
|
+
<AcceptInvite onSaved={(e) => track(e.kind)} /> // 'invitation.accepted', with the address
|
|
59
60
|
|
|
60
61
|
const { invitation, acceptInvitation } = useAuth() // or with your own form
|
|
61
62
|
```
|
|
@@ -65,8 +66,19 @@ The forms follow what the workspace turned on in Cauthy's dashboard: each provid
|
|
|
65
66
|
And the person's account, in your application: name, password, second step, sessions.
|
|
66
67
|
|
|
67
68
|
```tsx
|
|
68
|
-
import { Account } from 'cauthy-auth/react'
|
|
69
|
+
import { Account, AccountPasskeys } from 'cauthy-auth/react'
|
|
69
70
|
<Account /> // or: const { account } = useAuth()
|
|
71
|
+
<Account sections={['profile', 'password', 'sessions']} onSaved={(e) => toast(e.kind)} />
|
|
72
|
+
<AccountPasskeys /> // each part on its own card
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
`sections` lists the parts shown, in that order: `profile`, `email`, `password`, `linked`, `secondStep`, `phone`, `passkeys`, `agents`, `sessions` (default: all). Each is also its own component: `AccountProfile`, `AccountEmail`, `AccountPassword`, `AccountLinked`, `AccountSecondStep`, `AccountPhone`, `AccountPasskeys`, `AccountAgents`, `AccountSessions`. `onSaved` is called after every change saved, with `{ kind, ... }`: `profile.saved`, `email.change_requested`, `password.changed`, `identity.linked`, `identity.unlinked`, `mfa.enabled`, `mfa.disabled`, `recovery_codes.regenerated`, `phone.added`, `phone.removed`, `passkey.added`, `passkey.removed`, `agent.disconnected`, `sessions.ended`.
|
|
76
|
+
|
|
77
|
+
The legal documents a signed-in person still owes (a new version of the terms), with the action that accepts them. It shows nothing when nothing is owed:
|
|
78
|
+
|
|
79
|
+
```tsx
|
|
80
|
+
import { PendingTerms } from 'cauthy-auth/react'
|
|
81
|
+
<PendingTerms onSuccess={() => refresh()} /> // or: account.legal(), account.acceptLegal()
|
|
70
82
|
```
|
|
71
83
|
|
|
72
84
|
And the person's organizations, run by their own members: the people of one, and the organization itself. Cauthy decides each change by the person's role in the system's catalog, with their own session:
|
|
@@ -74,6 +86,13 @@ And the person's organizations, run by their own members: the people of one, and
|
|
|
74
86
|
```tsx
|
|
75
87
|
import { OrganizationMembers } from 'cauthy-auth/react'
|
|
76
88
|
<OrganizationMembers organizationId={org.id} /> // shows only what the person's role allows
|
|
89
|
+
<OrganizationMembers
|
|
90
|
+
organizationId={org.id}
|
|
91
|
+
roles={(role) => role !== 'billing'} // the roles offered when adding or changing one
|
|
92
|
+
hide={['archive', 'delete']} // never offered: 'archive', 'delete', 'rename', 'leave'
|
|
93
|
+
roleLabel={(c) => t(`roles.${c.role}`)} // a role's name wherever one shows. Default: the catalog's
|
|
94
|
+
onSaved={(e) => toast(e.kind)} // member.added, member.role_changed, member.removed, member.left,
|
|
95
|
+
/> // member.invited_again, organization.renamed, .archived, .deleted
|
|
77
96
|
|
|
78
97
|
const { organizations } = useAuth()
|
|
79
98
|
const [org] = await organizations.list() // org.can: { readMembers, manageMembers, removeMembers, update, archive, delete }
|
|
@@ -155,7 +174,45 @@ The ready-made forms wear the look set for your application in Cauthy's dashboar
|
|
|
155
174
|
import 'cauthy-auth/styles.css'
|
|
156
175
|
```
|
|
157
176
|
|
|
158
|
-
Or draw them with your own `components` and `classNames`, and pass `unstyled`.
|
|
177
|
+
Or draw them with your own `components` and `classNames`, and pass `unstyled`. Every part the forms draw can be yours; a part not given is drawn as before. With every part given and `unstyled`, the forms add no element of their own but lists:
|
|
178
|
+
|
|
179
|
+
```tsx
|
|
180
|
+
<SignIn unstyled components={{ Form, Button, Input, Checkbox, Select, Field, Text, Badge, Link, Divider, Alert, Confirm }} />
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
`Form` is every element the forms put around their parts: each form and each of its steps, and each part of `<Account />` and `<OrganizationMembers />`. Give it your design system's stack and the gaps between fields and buttons are yours, with no CSS on the page:
|
|
184
|
+
|
|
185
|
+
```tsx
|
|
186
|
+
const Form: AuthComponents['Form'] = ({ as, children, ...rest }) =>
|
|
187
|
+
as === 'form' ? <Stack as="form" gap={3} {...rest}>{children}</Stack> : <Stack gap={3} {...rest}>{children}</Stack>
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
`Button` is told what kind of button it is: `primary` sends the form; `secondary` is any other way (a provider, a passkey, a sign-in link, SSO, cancel, send again); `danger` removes, leaves, deletes, disconnects, signs out everywhere or turns the second step off. `loading` is true on the one button whose action is under way; every button is `disabled` meanwhile.
|
|
191
|
+
|
|
192
|
+
| Part | Is given |
|
|
193
|
+
| --- | --- |
|
|
194
|
+
| `Form` | `as` (`form` or `div`), `onSubmit`, `noValidate`, `aria-busy`, `className`, `section`, `children`. Render a `<form>` for `as="form"`, for Enter to send it. `section` names each part of `<Account />` (`profile`, `passkeys`… as in `AccountSection`) and of `<OrganizationMembers />` (`members`, `add-member`, `organization`, `rename`), to draw each as a card |
|
|
195
|
+
| `Button` | `type`, `variant` (`primary`, `secondary`, `danger`), `loading`, `disabled`, `className`, `onClick`, `children` |
|
|
196
|
+
| `Input` | `id`, `name`, `type`, `value`, `autoComplete`, `required`, `className`, `aria-invalid`, `aria-describedby`, `onChange(e)` |
|
|
197
|
+
| `Checkbox` | `id`, `name`, `checked`, `required`, `disabled`, `className`, `onChange(checked)`, `children` (its label) |
|
|
198
|
+
| `Select` | `id`, `name`, `value`, `options: { value, label }[]`, `disabled`, `className`, `aria-label`, `onChange(value)` |
|
|
199
|
+
| `Field` | `id`, `label`, `aside`, `help`, `error`, `required`, `className`, `children` (the control). Give the help the id `${id}-hint` and the error `${id}-error` |
|
|
200
|
+
| `Text` | `as` (`p`, `span`, `h2`), `tone` (`muted`, `danger`, `success`), `size` (`sm`, `md`, `lg`), `children` |
|
|
201
|
+
| `Badge` | `tone` (`neutral`, `success`, `warning`, `danger`), `children` |
|
|
202
|
+
| `Link` | `href`, `onClick`, `newTab`, `children` |
|
|
203
|
+
| `Divider` | `label` |
|
|
204
|
+
| `Alert` | `tone` (`danger`, `info`, `success`), `children`. Announce it: `role="alert"` or `role="status"` |
|
|
205
|
+
| `Confirm` | A function, `({ title, body, confirmLabel, cancelLabel, danger }) => Promise<boolean>`: your own dialog before removing a member, leaving, archiving or deleting. Without it, the question shows inline |
|
|
206
|
+
|
|
207
|
+
A form checks every field before it sends anything: each one wrong shows its error at once, in the order they are drawn, and the first takes the focus. `<SignUp />` draws its fields once the workspace has said what it asks (a company's name, the legal boxes), so nothing moves as they come.
|
|
208
|
+
|
|
209
|
+
What Cauthy mails from these forms (a sign-in link, a new password, a confirmation) goes in the page's language (`<html lang>`). Give `<CauthyProvider locale>` your application's own instead, or a function for a person who can change it:
|
|
210
|
+
|
|
211
|
+
```tsx
|
|
212
|
+
<CauthyProvider locale={() => i18n.language}>
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
`texts` changes any sentence. Its keys are stable: `email`, `password`, `name`, `code`, `signIn`, `signUp`, `continueWith`, `orWithEmail`, `forgotPassword`, `noAccount`, `createAccount`, `company`, `iAccept`, `and`, `termsOfService`, `privacyPolicy`, `haveAccount`, `sendLink`, `linkSent`, `codeHelp`, `codeHelpPhone`, `codeHelpEmail`, `sendEmailAgain`, `sendCodeSms`, `sendCodeWhatsapp`, `codeSent`, `pushSend`, `pushPick`, `pushWaiting`, `phone`, `phoneHelp`, `phoneOn`, `phoneOff`, `addPhone`, `removePhone`, `bySms`, `byWhatsapp`, `channel`, `verify`, `checkEmail`, `backToSignIn`, `emailMeALink`, `usePasskey`, `codeFromMail`, `signInLinkSent`, `newPassword`, `savePassword`, `passwordChanged`, `confirming`, `emailConfirmed`, `invitedTo`, `invitedToOrganization`, `invitedAs`, `choosePassword`, `acceptInvite`, `openingInvitation`, `invitationInvalid`, `profile`, `save`, `saved`, `currentPassword`, `changePassword`, `passwordChangedHere`, `secondStep`, `secondStepOn`, `secondStepOff`, `turnOn`, `turnOff`, `addToApp`, `openInApp`, `recoveryCodes`, `newRecoveryCodes`, `keepCodes`, `passkeys`, `managePasskeys`, `passkeysHelp`, `noPasskeys`, `passkeyName`, `addPasskey` (unused), `addPasskeyDevice`, `addSecurityKey`, `passkeyKinds`, `removePasskey`, `passkeyAdded`, `passkeyUnnamed`, `sessions`, `signOutEverywhere`, `agents`, `agentsHelp`, `disconnect`, `anAgent`, `unknownDevice`, `emailAddress`, `newEmail`, `changeEmail`, `emailSent`, `linkedAccounts`, `noLinkedAccounts`, `linkWith`, `unlink`, `linked`, `ssoOnly`, `members`, `membersHidden`, `organizationMissing`, `memberYou`, `memberInvited`, `memberManager`, `memberRole`, `memberAdd`, `memberAdded`, `memberRemove`, `memberRemoveConfirm`, `memberLeave`, `memberLeaveConfirm`, `memberInviteAgain`, `memberInvitationSent`, `organization`, `organizationRename`, `organizationRenamed`, `organizationArchive`, `organizationArchiveConfirm`, `organizationArchived`, `organizationDelete`, `organizationDeleteConfirm`, `organizationDeleted`, `yes`, `cancel`, `termsChanged`, `termsChangedHelp`, `acceptTerms`, and `errors` by error code. Built in: English and Spanish (`locale`). The dashboard can start the look from your stylesheet (shadcn/ui and Tailwind, Stackmyth, or variables of your own); `npx cauthy-auth theme --css src/app/globals.css` reads it the same way from a terminal.
|
|
159
216
|
|
|
160
217
|
Connect your application to Cauthy in one step, from Cauthy's dashboard ("Connect a System") or from a terminal. In the application's folder, `init` reads its framework (Next.js, TanStack Start, React Router or Remix, SvelteKit, Vite + React, Express, Hono, Fastify), makes the client, writes every variable to its env file, `CAUTHY_SECRET` included, and lays down the route and a sign-in page, never over a file that is there:
|
|
161
218
|
|
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. */
|
|
@@ -1180,6 +1180,8 @@ interface AuthTexts {
|
|
|
1180
1180
|
removePhone: string;
|
|
1181
1181
|
bySms: string;
|
|
1182
1182
|
byWhatsapp: string;
|
|
1183
|
+
/** The label of the channel phone codes go by, where the application draws it as a select. */
|
|
1184
|
+
channel: string;
|
|
1183
1185
|
verify: string;
|
|
1184
1186
|
checkEmail: string;
|
|
1185
1187
|
backToSignIn: string;
|
|
@@ -1271,6 +1273,9 @@ interface AuthTexts {
|
|
|
1271
1273
|
organizationDeleted: string;
|
|
1272
1274
|
yes: string;
|
|
1273
1275
|
cancel: string;
|
|
1276
|
+
termsChanged: string;
|
|
1277
|
+
termsChangedHelp: string;
|
|
1278
|
+
acceptTerms: string;
|
|
1274
1279
|
/** By error code; one missing shows what the server said. */
|
|
1275
1280
|
errors: Record<string, string>;
|
|
1276
1281
|
}
|
|
@@ -1313,34 +1318,175 @@ interface AuthFormProps {
|
|
|
1313
1318
|
*/
|
|
1314
1319
|
workspaceLook?: boolean;
|
|
1315
1320
|
/**
|
|
1316
|
-
* The application's own
|
|
1317
|
-
*
|
|
1321
|
+
* The application's own parts, to draw the form with: its form layout,
|
|
1322
|
+
* button, input, checkbox, select, field, text, badge, link, divider, alert
|
|
1323
|
+
* and confirmation. A part not given is drawn as before; with every part given
|
|
1324
|
+
* and `unstyled`, the form adds no element that carries a look of its own.
|
|
1318
1325
|
*/
|
|
1319
|
-
components?:
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1326
|
+
components?: AuthComponents;
|
|
1327
|
+
}
|
|
1328
|
+
/**
|
|
1329
|
+
* What the application's button is given: what a `<button>` would be, and
|
|
1330
|
+
* what kind of button it is. `primary` sends the form; `secondary` is any
|
|
1331
|
+
* other action (a provider, a passkey, a sign-in link, cancel, send again);
|
|
1332
|
+
* `danger` removes, leaves, deletes, disconnects or turns something off.
|
|
1333
|
+
* `loading` is true on the one button whose action is under way; every
|
|
1334
|
+
* button is `disabled` meanwhile, as before.
|
|
1335
|
+
*/
|
|
1336
|
+
interface AuthButtonProps {
|
|
1337
|
+
type: 'submit' | 'button';
|
|
1338
|
+
disabled?: boolean;
|
|
1339
|
+
className?: string;
|
|
1340
|
+
onClick?: () => void;
|
|
1341
|
+
children: ReactNode;
|
|
1342
|
+
variant?: 'primary' | 'secondary' | 'danger';
|
|
1343
|
+
loading?: boolean;
|
|
1344
|
+
}
|
|
1345
|
+
/**
|
|
1346
|
+
* What the application's form layout is given: every element the forms put
|
|
1347
|
+
* around their parts — a whole form, each step of it, each part of the
|
|
1348
|
+
* account and members screens — so its own stack lays them out. `as` says
|
|
1349
|
+
* which element it stands for: a `form` sends with `onSubmit` (render a
|
|
1350
|
+
* `<form>` with it for Enter to submit), a `div` only groups.
|
|
1351
|
+
*/
|
|
1352
|
+
interface AuthFormLayoutProps {
|
|
1353
|
+
as: 'form' | 'div';
|
|
1354
|
+
onSubmit?: (e: FormEvent) => void;
|
|
1355
|
+
noValidate?: boolean;
|
|
1356
|
+
'aria-busy'?: boolean;
|
|
1357
|
+
className?: string;
|
|
1358
|
+
/**
|
|
1359
|
+
* Which part of `<Account />` or `<OrganizationMembers />` this is, for an
|
|
1360
|
+
* application that draws each as a card: an `AccountSection`
|
|
1361
|
+
* (`profile`, `passkeys`…), or `members`, `add-member`, `organization`
|
|
1362
|
+
* and `rename` (the form inside `organization`). Not set on a whole form.
|
|
1363
|
+
*/
|
|
1364
|
+
section?: string;
|
|
1365
|
+
children: ReactNode;
|
|
1366
|
+
}
|
|
1367
|
+
/** What the application's input is given: what an `<input>` would be. */
|
|
1368
|
+
interface AuthInputProps {
|
|
1369
|
+
id: string;
|
|
1370
|
+
name: string;
|
|
1371
|
+
type: string;
|
|
1372
|
+
value: string;
|
|
1373
|
+
autoComplete?: string;
|
|
1374
|
+
required?: boolean;
|
|
1375
|
+
className?: string;
|
|
1376
|
+
'aria-invalid'?: boolean;
|
|
1377
|
+
'aria-describedby'?: string;
|
|
1378
|
+
onChange: (e: {
|
|
1379
|
+
target: {
|
|
1331
1380
|
value: string;
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1381
|
+
};
|
|
1382
|
+
}) => void;
|
|
1383
|
+
}
|
|
1384
|
+
/** A box to tick: the legal documents and each consent of a sign-up. `children` is its label. */
|
|
1385
|
+
interface AuthCheckboxProps {
|
|
1386
|
+
id: string;
|
|
1387
|
+
name: string;
|
|
1388
|
+
checked: boolean;
|
|
1389
|
+
required?: boolean;
|
|
1390
|
+
disabled?: boolean;
|
|
1391
|
+
className?: string;
|
|
1392
|
+
onChange: (checked: boolean) => void;
|
|
1393
|
+
children: ReactNode;
|
|
1394
|
+
}
|
|
1395
|
+
/** One choice of a few: a member's role, the channel of phone codes. Without a visible label it carries `aria-label`. */
|
|
1396
|
+
interface AuthSelectProps {
|
|
1397
|
+
id: string;
|
|
1398
|
+
name: string;
|
|
1399
|
+
value: string;
|
|
1400
|
+
options: {
|
|
1401
|
+
value: string;
|
|
1402
|
+
label: string;
|
|
1403
|
+
}[];
|
|
1404
|
+
disabled?: boolean;
|
|
1405
|
+
className?: string;
|
|
1406
|
+
'aria-label'?: string;
|
|
1407
|
+
onChange: (value: string) => void;
|
|
1408
|
+
}
|
|
1409
|
+
/**
|
|
1410
|
+
* A label, its control (`children`) and what is said under it. The control's
|
|
1411
|
+
* `aria-describedby` names `${id}-hint` and `${id}-error`: give the help and
|
|
1412
|
+
* the error those ids for a screen reader to read them with it.
|
|
1413
|
+
*/
|
|
1414
|
+
interface AuthFieldProps {
|
|
1415
|
+
id: string;
|
|
1416
|
+
label: ReactNode;
|
|
1417
|
+
children: ReactNode;
|
|
1418
|
+
/** Beside the label: "Forgot your password?". */
|
|
1419
|
+
aside?: ReactNode;
|
|
1420
|
+
/** What the field takes (a new password's rule). Not given while there is an error. */
|
|
1421
|
+
help?: ReactNode;
|
|
1422
|
+
error?: ReactNode;
|
|
1423
|
+
required?: boolean;
|
|
1424
|
+
className?: string;
|
|
1425
|
+
}
|
|
1426
|
+
/** A sentence of the form: help, a state, the footer (`size: 'sm'`), a section's heading (`as: 'h2'`). */
|
|
1427
|
+
interface AuthTextProps {
|
|
1428
|
+
as?: 'p' | 'span' | 'h2';
|
|
1429
|
+
tone?: 'muted' | 'danger' | 'success';
|
|
1430
|
+
size?: 'sm' | 'md' | 'lg';
|
|
1431
|
+
children: ReactNode;
|
|
1432
|
+
}
|
|
1433
|
+
/** A short mark beside a name: "you", "invited", a role, a passkey's kind. */
|
|
1434
|
+
interface AuthBadgeProps {
|
|
1435
|
+
tone?: 'neutral' | 'success' | 'warning' | 'danger';
|
|
1436
|
+
children: ReactNode;
|
|
1437
|
+
}
|
|
1438
|
+
/** A link: to another screen, or a legal document (`newTab`). */
|
|
1439
|
+
interface AuthLinkProps {
|
|
1440
|
+
href?: string;
|
|
1441
|
+
onClick?: () => void;
|
|
1442
|
+
newTab?: boolean;
|
|
1443
|
+
children: ReactNode;
|
|
1444
|
+
}
|
|
1445
|
+
/** The line between the providers and the address: "or with your email". */
|
|
1446
|
+
interface AuthDividerProps {
|
|
1447
|
+
label?: ReactNode;
|
|
1448
|
+
}
|
|
1449
|
+
/**
|
|
1450
|
+
* What went wrong (`danger`), what was done (`success`) or what to know
|
|
1451
|
+
* (`info`). The built-in one is announced: `role="alert"` for danger,
|
|
1452
|
+
* `role="status"` otherwise; the application's should be too.
|
|
1453
|
+
*/
|
|
1454
|
+
interface AuthAlertProps {
|
|
1455
|
+
tone: 'danger' | 'info' | 'success';
|
|
1456
|
+
children: ReactNode;
|
|
1457
|
+
}
|
|
1458
|
+
/** What a confirmation asks: removing a member, leaving, archiving or deleting the organization. */
|
|
1459
|
+
interface AuthConfirmOptions {
|
|
1460
|
+
title: string;
|
|
1461
|
+
body?: string;
|
|
1462
|
+
confirmLabel: string;
|
|
1463
|
+
cancelLabel: string;
|
|
1464
|
+
danger?: boolean;
|
|
1465
|
+
}
|
|
1466
|
+
/** The parts a form may be drawn with. See `AuthFormProps.components`. */
|
|
1467
|
+
interface AuthComponents {
|
|
1468
|
+
/**
|
|
1469
|
+
* Every element around the form's parts: the form itself, each step, each
|
|
1470
|
+
* part of the account and members screens. Not given: the `form`, `div` or
|
|
1471
|
+
* `section` the forms have always drawn.
|
|
1472
|
+
*/
|
|
1473
|
+
Form?: ComponentType<AuthFormLayoutProps>;
|
|
1474
|
+
Button?: ComponentType<AuthButtonProps>;
|
|
1475
|
+
Input?: ComponentType<AuthInputProps>;
|
|
1476
|
+
Checkbox?: ComponentType<AuthCheckboxProps>;
|
|
1477
|
+
Select?: ComponentType<AuthSelectProps>;
|
|
1478
|
+
Field?: ComponentType<AuthFieldProps>;
|
|
1479
|
+
Text?: ComponentType<AuthTextProps>;
|
|
1480
|
+
Badge?: ComponentType<AuthBadgeProps>;
|
|
1481
|
+
Link?: ComponentType<AuthLinkProps>;
|
|
1482
|
+
Divider?: ComponentType<AuthDividerProps>;
|
|
1483
|
+
Alert?: ComponentType<AuthAlertProps>;
|
|
1484
|
+
/**
|
|
1485
|
+
* Asks before something that cannot be undone, and answers whether to go
|
|
1486
|
+
* on: the application's own dialog. Not given: the question shows inline,
|
|
1487
|
+
* with a yes and a cancel button. Never the browser's own dialog.
|
|
1488
|
+
*/
|
|
1489
|
+
Confirm?: (options: AuthConfirmOptions) => Promise<boolean>;
|
|
1344
1490
|
}
|
|
1345
1491
|
declare function SignIn(props: AuthFormProps): react.JSX.Element;
|
|
1346
1492
|
interface GoogleOneTapProps {
|
|
@@ -1371,12 +1517,84 @@ declare function VerifyEmail(props: AuthFormProps): react.JSX.Element;
|
|
|
1371
1517
|
* `returnTo`. The invitation is good until it is accepted: reading it, or a
|
|
1372
1518
|
* password refused, does not spend it.
|
|
1373
1519
|
*/
|
|
1374
|
-
|
|
1520
|
+
/** What `<AcceptInvite />` tells the application once the invitation is accepted. */
|
|
1521
|
+
type AcceptInviteEvent = {
|
|
1522
|
+
kind: 'invitation.accepted';
|
|
1523
|
+
email: string;
|
|
1524
|
+
organization?: string;
|
|
1525
|
+
};
|
|
1526
|
+
interface AcceptInviteProps extends AuthFormProps {
|
|
1527
|
+
/** Called once the invitation is accepted, before the second step when the account owes one. */
|
|
1528
|
+
onSaved?: (event: AcceptInviteEvent) => void;
|
|
1529
|
+
}
|
|
1530
|
+
declare function AcceptInvite(props: AcceptInviteProps): react.JSX.Element;
|
|
1531
|
+
interface PendingTermsProps extends Omit<AuthFormProps, 'links' | 'returnTo' | 'createAccounts'> {
|
|
1532
|
+
/** Called once the person accepted. Nothing else happens: the application decides what follows. */
|
|
1533
|
+
onSuccess?: () => void;
|
|
1534
|
+
}
|
|
1535
|
+
/**
|
|
1536
|
+
* The legal documents the signed-in person still owes (a new version of the
|
|
1537
|
+
* terms, say), linked, with the action that accepts them. It shows nothing
|
|
1538
|
+
* while it reads them, when nothing is owed, and once they are accepted.
|
|
1539
|
+
* Nothing stops the person meanwhile: the application decides what waits.
|
|
1540
|
+
*/
|
|
1541
|
+
declare function PendingTerms(props: PendingTermsProps): react.JSX.Element | null;
|
|
1542
|
+
/** The parts of `<Account />`, by name: what `sections` lists. */
|
|
1543
|
+
type AccountSection = 'profile' | 'email' | 'password' | 'linked' | 'secondStep' | 'phone' | 'passkeys' | 'agents' | 'sessions';
|
|
1544
|
+
/**
|
|
1545
|
+
* What `<Account />` tells the application after each change it saved, for
|
|
1546
|
+
* the application's own toast or its own data to follow.
|
|
1547
|
+
*/
|
|
1548
|
+
type AccountEvent = {
|
|
1549
|
+
kind: 'profile.saved';
|
|
1550
|
+
name: string;
|
|
1551
|
+
} | {
|
|
1552
|
+
kind: 'email.change_requested';
|
|
1553
|
+
email: string;
|
|
1554
|
+
} | {
|
|
1555
|
+
kind: 'password.changed';
|
|
1556
|
+
} | {
|
|
1557
|
+
kind: 'identity.linked';
|
|
1558
|
+
provider: string;
|
|
1559
|
+
} | {
|
|
1560
|
+
kind: 'identity.unlinked';
|
|
1561
|
+
provider: string;
|
|
1562
|
+
} | {
|
|
1563
|
+
kind: 'mfa.enabled';
|
|
1564
|
+
} | {
|
|
1565
|
+
kind: 'mfa.disabled';
|
|
1566
|
+
} | {
|
|
1567
|
+
kind: 'recovery_codes.regenerated';
|
|
1568
|
+
} | {
|
|
1569
|
+
kind: 'phone.added';
|
|
1570
|
+
channel: 'sms' | 'whatsapp';
|
|
1571
|
+
} | {
|
|
1572
|
+
kind: 'phone.removed';
|
|
1573
|
+
} | {
|
|
1574
|
+
kind: 'passkey.added';
|
|
1575
|
+
id: string;
|
|
1576
|
+
} | {
|
|
1577
|
+
kind: 'passkey.removed';
|
|
1578
|
+
id: string;
|
|
1579
|
+
} | {
|
|
1580
|
+
kind: 'agent.disconnected';
|
|
1581
|
+
id: string;
|
|
1582
|
+
} | {
|
|
1583
|
+
kind: 'sessions.ended';
|
|
1584
|
+
};
|
|
1375
1585
|
interface AccountProps extends Omit<AuthFormProps, 'links' | 'returnTo' | 'onSuccess'> {
|
|
1376
1586
|
/** Called after "sign out everywhere". Default: go to `/`. */
|
|
1377
1587
|
onSignedOut?: () => void;
|
|
1378
1588
|
/** The moment of a session, as the application writes dates. Default: the browser's own way, in the reader's time zone. */
|
|
1379
1589
|
formatDate?: (iso: string) => string;
|
|
1590
|
+
/**
|
|
1591
|
+
* The parts shown, in this order. Default: all of them, as listed in
|
|
1592
|
+
* `AccountSection`. A part with nothing to show (the password of an account
|
|
1593
|
+
* without one, agents when none is connected) stays out either way.
|
|
1594
|
+
*/
|
|
1595
|
+
sections?: AccountSection[];
|
|
1596
|
+
/** Called after every change saved, with what changed. */
|
|
1597
|
+
onSaved?: (event: AccountEvent) => void;
|
|
1380
1598
|
}
|
|
1381
1599
|
/**
|
|
1382
1600
|
* The signed-in person's account, in the application: their name, their
|
|
@@ -1384,11 +1602,84 @@ interface AccountProps extends Omit<AuthFormProps, 'links' | 'returnTo' | 'onSuc
|
|
|
1384
1602
|
* its own. Like the other forms, it carries no styles.
|
|
1385
1603
|
*/
|
|
1386
1604
|
declare function Account(props: AccountProps): react.JSX.Element;
|
|
1605
|
+
/** What each part of the account screen takes, shown on its own: `<Account />`'s props but `sections`. */
|
|
1606
|
+
type AccountPartProps = Omit<AccountProps, 'sections'>;
|
|
1607
|
+
/** The person's name. */
|
|
1608
|
+
declare function AccountProfile(props: AccountPartProps): react.JSX.Element;
|
|
1609
|
+
/** Changing the address: a link goes to the new one. */
|
|
1610
|
+
declare function AccountEmail(props: AccountPartProps): react.JSX.Element;
|
|
1611
|
+
/** Changing the password, for an account that has one. */
|
|
1612
|
+
declare function AccountPassword(props: AccountPartProps): react.JSX.Element;
|
|
1613
|
+
/** The providers the account signs in with. */
|
|
1614
|
+
declare function AccountLinked(props: AccountPartProps): react.JSX.Element;
|
|
1615
|
+
/** The second step with an authenticator app, and the recovery codes. */
|
|
1616
|
+
declare function AccountSecondStep(props: AccountPartProps): react.JSX.Element;
|
|
1617
|
+
/** The phone codes go to, where the workspace sends them. */
|
|
1618
|
+
declare function AccountPhone(props: AccountPartProps): react.JSX.Element;
|
|
1619
|
+
/** The account's passkeys. */
|
|
1620
|
+
declare function AccountPasskeys(props: AccountPartProps): react.JSX.Element;
|
|
1621
|
+
/** The AI agents the person connected, when there is one. */
|
|
1622
|
+
declare function AccountAgents(props: AccountPartProps): react.JSX.Element;
|
|
1623
|
+
/** Where the person is signed in, and "sign out everywhere". */
|
|
1624
|
+
declare function AccountSessions(props: AccountPartProps): react.JSX.Element;
|
|
1625
|
+
/** An action `<OrganizationMembers hide={...} />` never offers. */
|
|
1626
|
+
type OrganizationMembersAction = 'archive' | 'delete' | 'rename' | 'leave';
|
|
1627
|
+
/**
|
|
1628
|
+
* What `<OrganizationMembers />` tells the application after each change it
|
|
1629
|
+
* saved, for the application's own toast or its own data to follow.
|
|
1630
|
+
*/
|
|
1631
|
+
type OrganizationMembersEvent = {
|
|
1632
|
+
kind: 'member.added';
|
|
1633
|
+
organizationId: string;
|
|
1634
|
+
userId: string;
|
|
1635
|
+
email: string;
|
|
1636
|
+
role: string;
|
|
1637
|
+
} | {
|
|
1638
|
+
kind: 'member.role_changed';
|
|
1639
|
+
organizationId: string;
|
|
1640
|
+
userId: string;
|
|
1641
|
+
role: string;
|
|
1642
|
+
previousRole: string;
|
|
1643
|
+
} | {
|
|
1644
|
+
kind: 'member.removed';
|
|
1645
|
+
organizationId: string;
|
|
1646
|
+
userId: string;
|
|
1647
|
+
} | {
|
|
1648
|
+
kind: 'member.left';
|
|
1649
|
+
organizationId: string;
|
|
1650
|
+
userId: string;
|
|
1651
|
+
} | {
|
|
1652
|
+
kind: 'member.invited_again';
|
|
1653
|
+
organizationId: string;
|
|
1654
|
+
userId: string;
|
|
1655
|
+
} | {
|
|
1656
|
+
kind: 'organization.renamed';
|
|
1657
|
+
organizationId: string;
|
|
1658
|
+
name: string;
|
|
1659
|
+
} | {
|
|
1660
|
+
kind: 'organization.archived';
|
|
1661
|
+
organizationId: string;
|
|
1662
|
+
} | {
|
|
1663
|
+
kind: 'organization.deleted';
|
|
1664
|
+
organizationId: string;
|
|
1665
|
+
};
|
|
1387
1666
|
interface OrganizationMembersProps extends Omit<AuthFormProps, 'links' | 'returnTo' | 'onSuccess' | 'createAccounts'> {
|
|
1388
1667
|
/** The organization, by the id Cauthy gave it. */
|
|
1389
1668
|
organizationId: string;
|
|
1390
1669
|
/** The moment of a membership, as the application writes dates. Default: the browser's own way. */
|
|
1391
1670
|
formatDate?: (iso: string) => string;
|
|
1671
|
+
/**
|
|
1672
|
+
* The roles offered when adding a member or changing one's role: those for
|
|
1673
|
+
* which it answers true. A member already holding another role keeps it,
|
|
1674
|
+
* and it shows. Default: every role the person may give.
|
|
1675
|
+
*/
|
|
1676
|
+
roles?: (role: string, choice: OrganizationRoleChoice) => boolean;
|
|
1677
|
+
/** Actions never offered, whatever the person's role allows. */
|
|
1678
|
+
hide?: OrganizationMembersAction[];
|
|
1679
|
+
/** A role's name wherever one shows: a member's, the role choices, adding one. Default: the name the catalog gives it. */
|
|
1680
|
+
roleLabel?: (choice: OrganizationRoleChoice) => string;
|
|
1681
|
+
/** Called after every change saved, with what changed. */
|
|
1682
|
+
onSaved?: (event: OrganizationMembersEvent) => void;
|
|
1392
1683
|
}
|
|
1393
1684
|
/**
|
|
1394
1685
|
* The people of one of the signed-in person's organizations, administered
|
|
@@ -1432,8 +1723,16 @@ interface CauthyProviderProps {
|
|
|
1432
1723
|
* out when the server did not look.
|
|
1433
1724
|
*/
|
|
1434
1725
|
initialSession?: PublicSession | null;
|
|
1726
|
+
/**
|
|
1727
|
+
* The language the person reads, for what Cauthy mails them from
|
|
1728
|
+
* `useAuth()` and the ready-made forms (a sign-in link, a new password, a
|
|
1729
|
+
* confirmation): a tag like `es` or `es-CO`, or a function that answers it
|
|
1730
|
+
* when the person can change it. Default: the page's own (`<html lang>`),
|
|
1731
|
+
* else the browser's.
|
|
1732
|
+
*/
|
|
1733
|
+
locale?: string | (() => string | undefined);
|
|
1435
1734
|
}
|
|
1436
|
-
declare function CauthyProvider({ children, basePath, initialSession }: CauthyProviderProps): react.JSX.Element;
|
|
1735
|
+
declare function CauthyProvider({ children, basePath, initialSession, locale }: CauthyProviderProps): react.JSX.Element;
|
|
1437
1736
|
declare function useSession(): SessionContext;
|
|
1438
1737
|
/**
|
|
1439
1738
|
* The application's own sign-in screens: the functions a form calls.
|
|
@@ -1446,4 +1745,4 @@ declare function useSession(): SessionContext;
|
|
|
1446
1745
|
*/
|
|
1447
1746
|
declare function useAuth(): AuthClient & Pick<SessionContext, 'session' | 'status' | 'refresh'>;
|
|
1448
1747
|
|
|
1449
|
-
export { AcceptInvite, Account, type AccountClient, type Account$1 as AccountDetails, type AccountProps, type AccountSession, type AuthClient, type AuthError, type AuthFormProps, type AuthMethods, type AuthResult, type AuthTexts, CauthyProvider, type CauthyProviderProps, type ConnectedAgent, ForgotPassword, GoogleOneTap, type GoogleOneTapProps, type Invitation, type JsonValue, type LinkedIdentity, OrganizationMembers, type OrganizationMembersProps, type OrganizationPerson, type OrganizationRoleChoice, type OrganizationSeat, type OrganizationsClient, type Passkey, type PasskeyKind, 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 };
|
|
1748
|
+
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 };
|