cauthy-auth 0.33.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/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
@@ -228,6 +228,8 @@ const org = await auth.system.organizations.create({ name: 'Acme' })
228
228
  await auth.system.members.add(org.id, { role: 'owner', email: 'ana@acme.com' })
229
229
  ```
230
230
 
231
+ `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`).
232
+
231
233
  Its invitations open your `pages.acceptInvite` when the application knows its public origin (`baseURL`, `CAUTHY_BASE_URL`); otherwise Cauthy's own page.
232
234
 
233
235
  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-BvvoNs2y.js';
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-BrrJsrFW.mjs';
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-BrrJsrFW.mjs';
3
- export { h as CheckRule } from './system-BrrJsrFW.mjs';
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
- /** Adds a person by their address; an address with no account gets one and its invitation. */
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-BvvoNs2y.js';
3
- export { h as CheckRule } from './system-BvvoNs2y.js';
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
- /** Adds a person by their address; an address with no account gets one and its invitation. */
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;