cauthy-auth 0.31.0 → 0.32.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 +40 -2
- package/dist/react.d.mts +280 -28
- package/dist/react.d.ts +280 -28
- package/dist/react.js +447 -193
- package/dist/react.js.map +1 -1
- package/dist/react.mjs +444 -200
- package/dist/react.mjs.map +1 -1
- package/package.json +2 -1
package/dist/react.d.ts
CHANGED
|
@@ -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,138 @@ 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 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
|
|
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
|
+
/** What the application's button is given: what a `<button>` would be. */
|
|
1329
|
+
interface AuthButtonProps {
|
|
1330
|
+
type: 'submit' | 'button';
|
|
1331
|
+
disabled?: boolean;
|
|
1332
|
+
className?: string;
|
|
1333
|
+
onClick?: () => void;
|
|
1334
|
+
children: ReactNode;
|
|
1335
|
+
}
|
|
1336
|
+
/** What the application's input is given: what an `<input>` would be. */
|
|
1337
|
+
interface AuthInputProps {
|
|
1338
|
+
id: string;
|
|
1339
|
+
name: string;
|
|
1340
|
+
type: string;
|
|
1341
|
+
value: string;
|
|
1342
|
+
autoComplete?: string;
|
|
1343
|
+
required?: boolean;
|
|
1344
|
+
className?: string;
|
|
1345
|
+
'aria-invalid'?: boolean;
|
|
1346
|
+
'aria-describedby'?: string;
|
|
1347
|
+
onChange: (e: {
|
|
1348
|
+
target: {
|
|
1331
1349
|
value: string;
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1350
|
+
};
|
|
1351
|
+
}) => void;
|
|
1352
|
+
}
|
|
1353
|
+
/** A box to tick: the legal documents and each consent of a sign-up. `children` is its label. */
|
|
1354
|
+
interface AuthCheckboxProps {
|
|
1355
|
+
id: string;
|
|
1356
|
+
name: string;
|
|
1357
|
+
checked: boolean;
|
|
1358
|
+
required?: boolean;
|
|
1359
|
+
disabled?: boolean;
|
|
1360
|
+
className?: string;
|
|
1361
|
+
onChange: (checked: boolean) => void;
|
|
1362
|
+
children: ReactNode;
|
|
1363
|
+
}
|
|
1364
|
+
/** One choice of a few: a member's role, the channel of phone codes. Without a visible label it carries `aria-label`. */
|
|
1365
|
+
interface AuthSelectProps {
|
|
1366
|
+
id: string;
|
|
1367
|
+
name: string;
|
|
1368
|
+
value: string;
|
|
1369
|
+
options: {
|
|
1370
|
+
value: string;
|
|
1371
|
+
label: string;
|
|
1372
|
+
}[];
|
|
1373
|
+
disabled?: boolean;
|
|
1374
|
+
className?: string;
|
|
1375
|
+
'aria-label'?: string;
|
|
1376
|
+
onChange: (value: string) => void;
|
|
1377
|
+
}
|
|
1378
|
+
/**
|
|
1379
|
+
* A label, its control (`children`) and what is said under it. The control's
|
|
1380
|
+
* `aria-describedby` names `${id}-hint` and `${id}-error`: give the help and
|
|
1381
|
+
* the error those ids for a screen reader to read them with it.
|
|
1382
|
+
*/
|
|
1383
|
+
interface AuthFieldProps {
|
|
1384
|
+
id: string;
|
|
1385
|
+
label: ReactNode;
|
|
1386
|
+
children: ReactNode;
|
|
1387
|
+
/** Beside the label: "Forgot your password?". */
|
|
1388
|
+
aside?: ReactNode;
|
|
1389
|
+
/** What the field takes (a new password's rule). Not given while there is an error. */
|
|
1390
|
+
help?: ReactNode;
|
|
1391
|
+
error?: ReactNode;
|
|
1392
|
+
required?: boolean;
|
|
1393
|
+
className?: string;
|
|
1394
|
+
}
|
|
1395
|
+
/** A sentence of the form: help, a state, the footer (`size: 'sm'`), a section's heading (`as: 'h2'`). */
|
|
1396
|
+
interface AuthTextProps {
|
|
1397
|
+
as?: 'p' | 'span' | 'h2';
|
|
1398
|
+
tone?: 'muted' | 'danger' | 'success';
|
|
1399
|
+
size?: 'sm' | 'md' | 'lg';
|
|
1400
|
+
children: ReactNode;
|
|
1401
|
+
}
|
|
1402
|
+
/** A short mark beside a name: "you", "invited", a role, a passkey's kind. */
|
|
1403
|
+
interface AuthBadgeProps {
|
|
1404
|
+
tone?: 'neutral' | 'success' | 'warning' | 'danger';
|
|
1405
|
+
children: ReactNode;
|
|
1406
|
+
}
|
|
1407
|
+
/** A link: to another screen, or a legal document (`newTab`). */
|
|
1408
|
+
interface AuthLinkProps {
|
|
1409
|
+
href?: string;
|
|
1410
|
+
onClick?: () => void;
|
|
1411
|
+
newTab?: boolean;
|
|
1412
|
+
children: ReactNode;
|
|
1413
|
+
}
|
|
1414
|
+
/** The line between the providers and the address: "or with your email". */
|
|
1415
|
+
interface AuthDividerProps {
|
|
1416
|
+
label?: ReactNode;
|
|
1417
|
+
}
|
|
1418
|
+
/**
|
|
1419
|
+
* What went wrong (`danger`), what was done (`success`) or what to know
|
|
1420
|
+
* (`info`). The built-in one is announced: `role="alert"` for danger,
|
|
1421
|
+
* `role="status"` otherwise; the application's should be too.
|
|
1422
|
+
*/
|
|
1423
|
+
interface AuthAlertProps {
|
|
1424
|
+
tone: 'danger' | 'info' | 'success';
|
|
1425
|
+
children: ReactNode;
|
|
1426
|
+
}
|
|
1427
|
+
/** What a confirmation asks: removing a member, leaving, archiving or deleting the organization. */
|
|
1428
|
+
interface AuthConfirmOptions {
|
|
1429
|
+
title: string;
|
|
1430
|
+
body?: string;
|
|
1431
|
+
confirmLabel: string;
|
|
1432
|
+
cancelLabel: string;
|
|
1433
|
+
danger?: boolean;
|
|
1434
|
+
}
|
|
1435
|
+
/** The parts a form may be drawn with. See `AuthFormProps.components`. */
|
|
1436
|
+
interface AuthComponents {
|
|
1437
|
+
Button?: ComponentType<AuthButtonProps>;
|
|
1438
|
+
Input?: ComponentType<AuthInputProps>;
|
|
1439
|
+
Checkbox?: ComponentType<AuthCheckboxProps>;
|
|
1440
|
+
Select?: ComponentType<AuthSelectProps>;
|
|
1441
|
+
Field?: ComponentType<AuthFieldProps>;
|
|
1442
|
+
Text?: ComponentType<AuthTextProps>;
|
|
1443
|
+
Badge?: ComponentType<AuthBadgeProps>;
|
|
1444
|
+
Link?: ComponentType<AuthLinkProps>;
|
|
1445
|
+
Divider?: ComponentType<AuthDividerProps>;
|
|
1446
|
+
Alert?: ComponentType<AuthAlertProps>;
|
|
1447
|
+
/**
|
|
1448
|
+
* Asks before something that cannot be undone, and answers whether to go
|
|
1449
|
+
* on: the application's own dialog. Not given: the question shows inline,
|
|
1450
|
+
* with a yes and a cancel button. Never the browser's own dialog.
|
|
1451
|
+
*/
|
|
1452
|
+
Confirm?: (options: AuthConfirmOptions) => Promise<boolean>;
|
|
1344
1453
|
}
|
|
1345
1454
|
declare function SignIn(props: AuthFormProps): react.JSX.Element;
|
|
1346
1455
|
interface GoogleOneTapProps {
|
|
@@ -1371,12 +1480,84 @@ declare function VerifyEmail(props: AuthFormProps): react.JSX.Element;
|
|
|
1371
1480
|
* `returnTo`. The invitation is good until it is accepted: reading it, or a
|
|
1372
1481
|
* password refused, does not spend it.
|
|
1373
1482
|
*/
|
|
1374
|
-
|
|
1483
|
+
/** What `<AcceptInvite />` tells the application once the invitation is accepted. */
|
|
1484
|
+
type AcceptInviteEvent = {
|
|
1485
|
+
kind: 'invitation.accepted';
|
|
1486
|
+
email: string;
|
|
1487
|
+
organization?: string;
|
|
1488
|
+
};
|
|
1489
|
+
interface AcceptInviteProps extends AuthFormProps {
|
|
1490
|
+
/** Called once the invitation is accepted, before the second step when the account owes one. */
|
|
1491
|
+
onSaved?: (event: AcceptInviteEvent) => void;
|
|
1492
|
+
}
|
|
1493
|
+
declare function AcceptInvite(props: AcceptInviteProps): react.JSX.Element;
|
|
1494
|
+
interface PendingTermsProps extends Omit<AuthFormProps, 'links' | 'returnTo' | 'createAccounts'> {
|
|
1495
|
+
/** Called once the person accepted. Nothing else happens: the application decides what follows. */
|
|
1496
|
+
onSuccess?: () => void;
|
|
1497
|
+
}
|
|
1498
|
+
/**
|
|
1499
|
+
* The legal documents the signed-in person still owes (a new version of the
|
|
1500
|
+
* terms, say), linked, with the action that accepts them. It shows nothing
|
|
1501
|
+
* while it reads them, when nothing is owed, and once they are accepted.
|
|
1502
|
+
* Nothing stops the person meanwhile: the application decides what waits.
|
|
1503
|
+
*/
|
|
1504
|
+
declare function PendingTerms(props: PendingTermsProps): react.JSX.Element | null;
|
|
1505
|
+
/** The parts of `<Account />`, by name: what `sections` lists. */
|
|
1506
|
+
type AccountSection = 'profile' | 'email' | 'password' | 'linked' | 'secondStep' | 'phone' | 'passkeys' | 'agents' | 'sessions';
|
|
1507
|
+
/**
|
|
1508
|
+
* What `<Account />` tells the application after each change it saved, for
|
|
1509
|
+
* the application's own toast or its own data to follow.
|
|
1510
|
+
*/
|
|
1511
|
+
type AccountEvent = {
|
|
1512
|
+
kind: 'profile.saved';
|
|
1513
|
+
name: string;
|
|
1514
|
+
} | {
|
|
1515
|
+
kind: 'email.change_requested';
|
|
1516
|
+
email: string;
|
|
1517
|
+
} | {
|
|
1518
|
+
kind: 'password.changed';
|
|
1519
|
+
} | {
|
|
1520
|
+
kind: 'identity.linked';
|
|
1521
|
+
provider: string;
|
|
1522
|
+
} | {
|
|
1523
|
+
kind: 'identity.unlinked';
|
|
1524
|
+
provider: string;
|
|
1525
|
+
} | {
|
|
1526
|
+
kind: 'mfa.enabled';
|
|
1527
|
+
} | {
|
|
1528
|
+
kind: 'mfa.disabled';
|
|
1529
|
+
} | {
|
|
1530
|
+
kind: 'recovery_codes.regenerated';
|
|
1531
|
+
} | {
|
|
1532
|
+
kind: 'phone.added';
|
|
1533
|
+
channel: 'sms' | 'whatsapp';
|
|
1534
|
+
} | {
|
|
1535
|
+
kind: 'phone.removed';
|
|
1536
|
+
} | {
|
|
1537
|
+
kind: 'passkey.added';
|
|
1538
|
+
id: string;
|
|
1539
|
+
} | {
|
|
1540
|
+
kind: 'passkey.removed';
|
|
1541
|
+
id: string;
|
|
1542
|
+
} | {
|
|
1543
|
+
kind: 'agent.disconnected';
|
|
1544
|
+
id: string;
|
|
1545
|
+
} | {
|
|
1546
|
+
kind: 'sessions.ended';
|
|
1547
|
+
};
|
|
1375
1548
|
interface AccountProps extends Omit<AuthFormProps, 'links' | 'returnTo' | 'onSuccess'> {
|
|
1376
1549
|
/** Called after "sign out everywhere". Default: go to `/`. */
|
|
1377
1550
|
onSignedOut?: () => void;
|
|
1378
1551
|
/** The moment of a session, as the application writes dates. Default: the browser's own way, in the reader's time zone. */
|
|
1379
1552
|
formatDate?: (iso: string) => string;
|
|
1553
|
+
/**
|
|
1554
|
+
* The parts shown, in this order. Default: all of them, as listed in
|
|
1555
|
+
* `AccountSection`. A part with nothing to show (the password of an account
|
|
1556
|
+
* without one, agents when none is connected) stays out either way.
|
|
1557
|
+
*/
|
|
1558
|
+
sections?: AccountSection[];
|
|
1559
|
+
/** Called after every change saved, with what changed. */
|
|
1560
|
+
onSaved?: (event: AccountEvent) => void;
|
|
1380
1561
|
}
|
|
1381
1562
|
/**
|
|
1382
1563
|
* The signed-in person's account, in the application: their name, their
|
|
@@ -1384,11 +1565,82 @@ interface AccountProps extends Omit<AuthFormProps, 'links' | 'returnTo' | 'onSuc
|
|
|
1384
1565
|
* its own. Like the other forms, it carries no styles.
|
|
1385
1566
|
*/
|
|
1386
1567
|
declare function Account(props: AccountProps): react.JSX.Element;
|
|
1568
|
+
/** What each part of the account screen takes, shown on its own: `<Account />`'s props but `sections`. */
|
|
1569
|
+
type AccountPartProps = Omit<AccountProps, 'sections'>;
|
|
1570
|
+
/** The person's name. */
|
|
1571
|
+
declare function AccountProfile(props: AccountPartProps): react.JSX.Element;
|
|
1572
|
+
/** Changing the address: a link goes to the new one. */
|
|
1573
|
+
declare function AccountEmail(props: AccountPartProps): react.JSX.Element;
|
|
1574
|
+
/** Changing the password, for an account that has one. */
|
|
1575
|
+
declare function AccountPassword(props: AccountPartProps): react.JSX.Element;
|
|
1576
|
+
/** The providers the account signs in with. */
|
|
1577
|
+
declare function AccountLinked(props: AccountPartProps): react.JSX.Element;
|
|
1578
|
+
/** The second step with an authenticator app, and the recovery codes. */
|
|
1579
|
+
declare function AccountSecondStep(props: AccountPartProps): react.JSX.Element;
|
|
1580
|
+
/** The phone codes go to, where the workspace sends them. */
|
|
1581
|
+
declare function AccountPhone(props: AccountPartProps): react.JSX.Element;
|
|
1582
|
+
/** The account's passkeys. */
|
|
1583
|
+
declare function AccountPasskeys(props: AccountPartProps): react.JSX.Element;
|
|
1584
|
+
/** The AI agents the person connected, when there is one. */
|
|
1585
|
+
declare function AccountAgents(props: AccountPartProps): react.JSX.Element;
|
|
1586
|
+
/** Where the person is signed in, and "sign out everywhere". */
|
|
1587
|
+
declare function AccountSessions(props: AccountPartProps): react.JSX.Element;
|
|
1588
|
+
/** An action `<OrganizationMembers hide={...} />` never offers. */
|
|
1589
|
+
type OrganizationMembersAction = 'archive' | 'delete' | 'rename' | 'leave';
|
|
1590
|
+
/**
|
|
1591
|
+
* What `<OrganizationMembers />` tells the application after each change it
|
|
1592
|
+
* saved, for the application's own toast or its own data to follow.
|
|
1593
|
+
*/
|
|
1594
|
+
type OrganizationMembersEvent = {
|
|
1595
|
+
kind: 'member.added';
|
|
1596
|
+
organizationId: string;
|
|
1597
|
+
userId: string;
|
|
1598
|
+
email: string;
|
|
1599
|
+
role: string;
|
|
1600
|
+
} | {
|
|
1601
|
+
kind: 'member.role_changed';
|
|
1602
|
+
organizationId: string;
|
|
1603
|
+
userId: string;
|
|
1604
|
+
role: string;
|
|
1605
|
+
previousRole: string;
|
|
1606
|
+
} | {
|
|
1607
|
+
kind: 'member.removed';
|
|
1608
|
+
organizationId: string;
|
|
1609
|
+
userId: string;
|
|
1610
|
+
} | {
|
|
1611
|
+
kind: 'member.left';
|
|
1612
|
+
organizationId: string;
|
|
1613
|
+
userId: string;
|
|
1614
|
+
} | {
|
|
1615
|
+
kind: 'member.invited_again';
|
|
1616
|
+
organizationId: string;
|
|
1617
|
+
userId: string;
|
|
1618
|
+
} | {
|
|
1619
|
+
kind: 'organization.renamed';
|
|
1620
|
+
organizationId: string;
|
|
1621
|
+
name: string;
|
|
1622
|
+
} | {
|
|
1623
|
+
kind: 'organization.archived';
|
|
1624
|
+
organizationId: string;
|
|
1625
|
+
} | {
|
|
1626
|
+
kind: 'organization.deleted';
|
|
1627
|
+
organizationId: string;
|
|
1628
|
+
};
|
|
1387
1629
|
interface OrganizationMembersProps extends Omit<AuthFormProps, 'links' | 'returnTo' | 'onSuccess' | 'createAccounts'> {
|
|
1388
1630
|
/** The organization, by the id Cauthy gave it. */
|
|
1389
1631
|
organizationId: string;
|
|
1390
1632
|
/** The moment of a membership, as the application writes dates. Default: the browser's own way. */
|
|
1391
1633
|
formatDate?: (iso: string) => string;
|
|
1634
|
+
/**
|
|
1635
|
+
* The roles offered when adding a member or changing one's role: those for
|
|
1636
|
+
* which it answers true. A member already holding another role keeps it,
|
|
1637
|
+
* and it shows. Default: every role the person may give.
|
|
1638
|
+
*/
|
|
1639
|
+
roles?: (role: string, choice: OrganizationRoleChoice) => boolean;
|
|
1640
|
+
/** Actions never offered, whatever the person's role allows. */
|
|
1641
|
+
hide?: OrganizationMembersAction[];
|
|
1642
|
+
/** Called after every change saved, with what changed. */
|
|
1643
|
+
onSaved?: (event: OrganizationMembersEvent) => void;
|
|
1392
1644
|
}
|
|
1393
1645
|
/**
|
|
1394
1646
|
* The people of one of the signed-in person's organizations, administered
|
|
@@ -1446,4 +1698,4 @@ declare function useSession(): SessionContext;
|
|
|
1446
1698
|
*/
|
|
1447
1699
|
declare function useAuth(): AuthClient & Pick<SessionContext, 'session' | 'status' | 'refresh'>;
|
|
1448
1700
|
|
|
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 };
|
|
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 };
|