cauthy-auth 0.33.0 → 0.35.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 +14 -4
- package/dist/{cauthy-CKfvvv_i.d.ts → cauthy-BUozWD72.d.ts} +1 -1
- package/dist/{cauthy-2jtP2LVQ.d.mts → cauthy-C-GoRXy9.d.mts} +1 -1
- package/dist/cli.js +1 -1
- package/dist/client.d.mts +7 -3
- package/dist/client.d.ts +7 -3
- package/dist/client.js.map +1 -1
- package/dist/client.mjs.map +1 -1
- package/dist/express.d.mts +2 -2
- package/dist/express.d.ts +2 -2
- package/dist/fastify.d.mts +2 -2
- package/dist/fastify.d.ts +2 -2
- package/dist/hono.d.mts +2 -2
- package/dist/hono.d.ts +2 -2
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +3 -1
- package/dist/index.mjs.map +1 -1
- package/dist/next.d.mts +2 -2
- package/dist/next.d.ts +2 -2
- package/dist/react.d.mts +27 -9
- package/dist/react.d.ts +27 -9
- package/dist/react.js +120 -42
- package/dist/react.js.map +1 -1
- package/dist/react.mjs +120 -42
- package/dist/react.mjs.map +1 -1
- package/dist/styles.css +43 -0
- package/dist/svelte.d.mts +2 -2
- package/dist/svelte.d.ts +2 -2
- package/dist/svelte.js.map +1 -1
- package/dist/svelte.mjs.map +1 -1
- package/dist/{system-BvvoNs2y.d.ts → system-Bz4haPrI.d.ts} +10 -2
- package/dist/{system-BrrJsrFW.d.mts → system-DUGV040y.d.mts} +10 -2
- package/dist/vue.d.mts +2 -2
- package/dist/vue.d.ts +2 -2
- package/dist/vue.js.map +1 -1
- package/dist/vue.mjs.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -96,7 +96,7 @@ import { OrganizationMembers } from 'cauthy-auth/react'
|
|
|
96
96
|
|
|
97
97
|
const { organizations } = useAuth()
|
|
98
98
|
const [org] = await organizations.list() // org.can: { readMembers, manageMembers, removeMembers, update, archive, delete }
|
|
99
|
-
await organizations.add(org.id, { email: 'ana@example.com', role: 'reader' })
|
|
99
|
+
await organizations.add(org.id, { email: 'ana@example.com', role: 'reader' }) // already a member: error member_exists, role unchanged
|
|
100
100
|
await organizations.setRole(org.id, userId, 'admin')
|
|
101
101
|
await organizations.remove(org.id, userId) // anybody may remove themselves: leave
|
|
102
102
|
await organizations.rename(org.id, 'Acme Books') // r.organization
|
|
@@ -187,13 +187,21 @@ const Form: AuthComponents['Form'] = ({ as, children, ...rest }) =>
|
|
|
187
187
|
as === 'form' ? <Stack as="form" gap={3} {...rest}>{children}</Stack> : <Stack gap={3} {...rest}>{children}</Stack>
|
|
188
188
|
```
|
|
189
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
|
|
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 and field is `disabled` meanwhile, and the form carries `aria-busy`. After a sign-in, `loading` stays true until the page is left, so draw your design system's spinner whenever it is true and keep the label:
|
|
191
|
+
|
|
192
|
+
```tsx
|
|
193
|
+
const Button = ({ variant, loading, children, ...rest }: AuthButtonProps) => (
|
|
194
|
+
<MyButton tone={variant} isLoading={loading} aria-busy={loading || undefined} {...rest}>{children}</MyButton>
|
|
195
|
+
)
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
The forms stay busy from the press until the work is really over. A sign-in that leaves the form (the password, the second step, a passkey, a provider, SSO, a sign-up done, an invitation accepted) stays busy until the browser leaves the page; with `onSuccess`, return a Promise when the form stays on screen while your application moves on (`onSuccess={() => router.navigate({ to: '/' })}`), and the form waits for it, then is free again if still shown. A plain `onSuccess` keeps it busy until it unmounts. A refusal, a sign-in link sent or a sign-up that asks to confirm the address frees it; so does coming back from the browser's back-forward cache. Until the workspace says what it offers, `<SignIn />` shows its form busy with nothing to press, and `<SignUp />`, `<Account />` and `<OrganizationMembers />` say "Loading…" (`texts.loading`). The plain button draws a spinner before its label (`.cauthy-spinner` in `styles.css`, still under `prefers-reduced-motion`); with `unstyled`, it adds "…" after the label.
|
|
191
199
|
|
|
192
200
|
| Part | Is given |
|
|
193
201
|
| --- | --- |
|
|
194
202
|
| `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
203
|
| `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)` |
|
|
204
|
+
| `Input` | `id`, `name`, `type`, `value`, `autoComplete`, `required`, `disabled`, `className`, `aria-invalid`, `aria-describedby`, `onChange(e)` |
|
|
197
205
|
| `Checkbox` | `id`, `name`, `checked`, `required`, `disabled`, `className`, `onChange(checked)`, `children` (its label) |
|
|
198
206
|
| `Select` | `id`, `name`, `value`, `options: { value, label }[]`, `disabled`, `className`, `aria-label`, `onChange(value)` |
|
|
199
207
|
| `Field` | `id`, `label`, `aside`, `help`, `error`, `required`, `className`, `children` (the control). Give the help the id `${id}-hint` and the error `${id}-error` |
|
|
@@ -212,7 +220,7 @@ What Cauthy mails from these forms (a sign-in link, a new password, a confirmati
|
|
|
212
220
|
<CauthyProvider locale={() => i18n.language}>
|
|
213
221
|
```
|
|
214
222
|
|
|
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.
|
|
223
|
+
`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`, `loading`, `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.
|
|
216
224
|
|
|
217
225
|
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:
|
|
218
226
|
|
|
@@ -228,6 +236,8 @@ const org = await auth.system.organizations.create({ name: 'Acme' })
|
|
|
228
236
|
await auth.system.members.add(org.id, { role: 'owner', email: 'ana@acme.com' })
|
|
229
237
|
```
|
|
230
238
|
|
|
239
|
+
`members.add` only adds: a person who already belongs keeps their role, and it throws `CauthyApiError` with `code: 'member_exists'` (409). Change a role with `members.setRole`, or pass `onlyNew: false` to set the role of whoever is already there. `<OrganizationMembers />` and `organizations.add` never change a member's role either: they answer `member_exists` (the text is `errors.member_exists`).
|
|
240
|
+
|
|
231
241
|
Its invitations open your `pages.acceptInvite` when the application knows its public origin (`baseURL`, `CAUTHY_BASE_URL`); otherwise Cauthy's own page.
|
|
232
242
|
|
|
233
243
|
A backend that is handed a Cauthy access token checks it with Cauthy's published keys: no secret, no call per request.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { J as JsonValue, S as Session, t as SessionStatus, s as SessionOrganization, f as CheckQuestion, k as OrganizationRef, g as CheckResult, d as CauthySystem, q as PublicSession, c as CauthyOptions } from './system-
|
|
1
|
+
import { J as JsonValue, S as Session, t as SessionStatus, s as SessionOrganization, f as CheckQuestion, k as OrganizationRef, g as CheckResult, d as CauthySystem, q as PublicSession, c as CauthyOptions } from './system-Bz4haPrI.js';
|
|
2
2
|
import { JWTVerifyGetKey } from 'jose';
|
|
3
3
|
|
|
4
4
|
/** Something that happened in Cauthy, as a subscriber is told. Moments are UTC. */
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { J as JsonValue, S as Session, t as SessionStatus, s as SessionOrganization, f as CheckQuestion, k as OrganizationRef, g as CheckResult, d as CauthySystem, q as PublicSession, c as CauthyOptions } from './system-
|
|
1
|
+
import { J as JsonValue, S as Session, t as SessionStatus, s as SessionOrganization, f as CheckQuestion, k as OrganizationRef, g as CheckResult, d as CauthySystem, q as PublicSession, c as CauthyOptions } from './system-DUGV040y.mjs';
|
|
2
2
|
import { JWTVerifyGetKey } from 'jose';
|
|
3
3
|
|
|
4
4
|
/** Something that happened in Cauthy, as a subscriber is told. Moments are UTC. */
|
package/dist/cli.js
CHANGED
|
@@ -1084,7 +1084,7 @@ function createSystem(given = {}) {
|
|
|
1084
1084
|
return toMember(await data(
|
|
1085
1085
|
"POST",
|
|
1086
1086
|
`/v1/organizations/${id(orgId)}/members`,
|
|
1087
|
-
{ role: m.role, user_id: m.userId, email: m.email, name: m.name, locale: m.locale, client_id: clientId },
|
|
1087
|
+
{ role: m.role, user_id: m.userId, email: m.email, name: m.name, locale: m.locale, client_id: clientId, only_new: m.onlyNew !== false },
|
|
1088
1088
|
inviteHeaders
|
|
1089
1089
|
));
|
|
1090
1090
|
},
|
package/dist/client.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { CauthyTheme } from './theme.mjs';
|
|
2
|
-
import { q as PublicSession, f as CheckQuestion, k as OrganizationRef, g as CheckResult } from './system-
|
|
3
|
-
export { h as CheckRule } from './system-
|
|
2
|
+
import { q as PublicSession, f as CheckQuestion, k as OrganizationRef, g as CheckResult } from './system-DUGV040y.mjs';
|
|
3
|
+
export { h as CheckRule } from './system-DUGV040y.mjs';
|
|
4
4
|
import { A as AuthField, b as PasswordPolicy } from './validate-sEXG82po.mjs';
|
|
5
5
|
export { D as DEFAULT_PASSWORD_POLICY, F as FieldProblem, M as MIN_PASSWORD, P as PasswordClass, a as PasswordLocale, c as PasswordReason, d as checkCode, e as checkEmail, f as checkName, g as checkNewPassword, h as checkPassword, i as describePasswordPolicy, j as explainPasswordProblems, p as passwordPolicyOf, k as passwordProblems } from './validate-sEXG82po.mjs';
|
|
6
6
|
import 'jose';
|
|
@@ -291,7 +291,11 @@ interface OrganizationsClient {
|
|
|
291
291
|
members(organizationId: string): Promise<OrganizationPerson[] | null>;
|
|
292
292
|
/** The roles a member may be given, or null when the person may not see them. */
|
|
293
293
|
roles(organizationId: string): Promise<OrganizationRoleChoice[] | null>;
|
|
294
|
-
/**
|
|
294
|
+
/**
|
|
295
|
+
* Adds a person by their address; an address with no account gets one and
|
|
296
|
+
* its invitation. It only adds: a person who already belongs keeps their
|
|
297
|
+
* role and the result is the error `member_exists` (change it with `setRole`).
|
|
298
|
+
*/
|
|
295
299
|
add(organizationId: string, form: {
|
|
296
300
|
email: string;
|
|
297
301
|
role: string;
|
package/dist/client.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { CauthyTheme } from './theme.js';
|
|
2
|
-
import { q as PublicSession, f as CheckQuestion, k as OrganizationRef, g as CheckResult } from './system-
|
|
3
|
-
export { h as CheckRule } from './system-
|
|
2
|
+
import { q as PublicSession, f as CheckQuestion, k as OrganizationRef, g as CheckResult } from './system-Bz4haPrI.js';
|
|
3
|
+
export { h as CheckRule } from './system-Bz4haPrI.js';
|
|
4
4
|
import { A as AuthField, b as PasswordPolicy } from './validate-sEXG82po.js';
|
|
5
5
|
export { D as DEFAULT_PASSWORD_POLICY, F as FieldProblem, M as MIN_PASSWORD, P as PasswordClass, a as PasswordLocale, c as PasswordReason, d as checkCode, e as checkEmail, f as checkName, g as checkNewPassword, h as checkPassword, i as describePasswordPolicy, j as explainPasswordProblems, p as passwordPolicyOf, k as passwordProblems } from './validate-sEXG82po.js';
|
|
6
6
|
import 'jose';
|
|
@@ -291,7 +291,11 @@ interface OrganizationsClient {
|
|
|
291
291
|
members(organizationId: string): Promise<OrganizationPerson[] | null>;
|
|
292
292
|
/** The roles a member may be given, or null when the person may not see them. */
|
|
293
293
|
roles(organizationId: string): Promise<OrganizationRoleChoice[] | null>;
|
|
294
|
-
/**
|
|
294
|
+
/**
|
|
295
|
+
* Adds a person by their address; an address with no account gets one and
|
|
296
|
+
* its invitation. It only adds: a person who already belongs keeps their
|
|
297
|
+
* role and the result is the error `member_exists` (change it with `setRole`).
|
|
298
|
+
*/
|
|
295
299
|
add(organizationId: string, form: {
|
|
296
300
|
email: string;
|
|
297
301
|
role: string;
|