cauthy-auth 0.30.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.
Files changed (46) hide show
  1. package/README.md +50 -5
  2. package/dist/{cauthy-BXgsZ-Um.d.mts → cauthy-2jtP2LVQ.d.mts} +1 -1
  3. package/dist/{cauthy-CHENs452.d.ts → cauthy-CKfvvv_i.d.ts} +1 -1
  4. package/dist/cli.js +8 -5
  5. package/dist/client.d.mts +47 -6
  6. package/dist/client.d.ts +47 -6
  7. package/dist/client.js +16 -2
  8. package/dist/client.js.map +1 -1
  9. package/dist/client.mjs +16 -2
  10. package/dist/client.mjs.map +1 -1
  11. package/dist/express.d.mts +2 -2
  12. package/dist/express.d.ts +2 -2
  13. package/dist/fastify.d.mts +2 -2
  14. package/dist/fastify.d.ts +2 -2
  15. package/dist/hono.d.mts +2 -2
  16. package/dist/hono.d.ts +2 -2
  17. package/dist/index.d.mts +2 -2
  18. package/dist/index.d.ts +2 -2
  19. package/dist/index.js +64 -21
  20. package/dist/index.js.map +1 -1
  21. package/dist/index.mjs +64 -21
  22. package/dist/index.mjs.map +1 -1
  23. package/dist/next.d.mts +2 -2
  24. package/dist/next.d.ts +2 -2
  25. package/dist/react.d.mts +339 -31
  26. package/dist/react.d.ts +339 -31
  27. package/dist/react.js +616 -225
  28. package/dist/react.js.map +1 -1
  29. package/dist/react.mjs +610 -230
  30. package/dist/react.mjs.map +1 -1
  31. package/dist/styles.css +8 -0
  32. package/dist/svelte.d.mts +2 -2
  33. package/dist/svelte.d.ts +2 -2
  34. package/dist/svelte.js +16 -2
  35. package/dist/svelte.js.map +1 -1
  36. package/dist/svelte.mjs +16 -2
  37. package/dist/svelte.mjs.map +1 -1
  38. package/dist/{system-0mHrdAgO.d.mts → system-BrrJsrFW.d.mts} +14 -0
  39. package/dist/{system-BIYbS7h2.d.ts → system-BvvoNs2y.d.ts} +14 -0
  40. package/dist/vue.d.mts +2 -2
  41. package/dist/vue.d.ts +2 -2
  42. package/dist/vue.js +16 -2
  43. package/dist/vue.js.map +1 -1
  44. package/dist/vue.mjs +16 -2
  45. package/dist/vue.mjs.map +1 -1
  46. package/package.json +2 -1
@@ -56,11 +56,17 @@ interface CauthyOptions {
56
56
  * signIn where `<SignIn />` is: a sign-in link opens it
57
57
  * resetPassword where `<ResetPassword />` is
58
58
  * verifyEmail where `<VerifyEmail />` is
59
+ * acceptInvite where `<AcceptInvite />` is: an invitation opens it
60
+ *
61
+ * An invitation sent by `auth.system.members.add` or `auth.system.invite`
62
+ * opens `acceptInvite` only when the application knows its public origin
63
+ * (`baseURL`): that call has no request to read it from.
59
64
  */
60
65
  pages?: {
61
66
  signIn?: string;
62
67
  resetPassword?: string;
63
68
  verifyEmail?: string;
69
+ acceptInvite?: string;
64
70
  };
65
71
  /**
66
72
  * The address of the person a request comes from, passed on to Cauthy so
@@ -448,6 +454,14 @@ interface SystemOptions {
448
454
  key?: SystemKey;
449
455
  /** The application's system, which `check` asks about. Default: `CAUTHY_SYSTEM`. */
450
456
  system?: string;
457
+ /**
458
+ * The application's own page for accepting an invitation, as an absolute
459
+ * address (`https://app.example.com/accept-invite`, where `<AcceptInvite />`
460
+ * is). The invitations `members.add` and `invite` send open it; without it,
461
+ * they open Cauthy's own page. Cauthy follows it only on an origin the
462
+ * client registered to be sent back to. Default: `CAUTHY_ACCEPT_INVITE_URL`.
463
+ */
464
+ acceptInviteUrl?: string;
451
465
  fetch?: typeof fetch;
452
466
  }
453
467
  /** Cauthy refused a request of the application's own. */
@@ -56,11 +56,17 @@ interface CauthyOptions {
56
56
  * signIn where `<SignIn />` is: a sign-in link opens it
57
57
  * resetPassword where `<ResetPassword />` is
58
58
  * verifyEmail where `<VerifyEmail />` is
59
+ * acceptInvite where `<AcceptInvite />` is: an invitation opens it
60
+ *
61
+ * An invitation sent by `auth.system.members.add` or `auth.system.invite`
62
+ * opens `acceptInvite` only when the application knows its public origin
63
+ * (`baseURL`): that call has no request to read it from.
59
64
  */
60
65
  pages?: {
61
66
  signIn?: string;
62
67
  resetPassword?: string;
63
68
  verifyEmail?: string;
69
+ acceptInvite?: string;
64
70
  };
65
71
  /**
66
72
  * The address of the person a request comes from, passed on to Cauthy so
@@ -448,6 +454,14 @@ interface SystemOptions {
448
454
  key?: SystemKey;
449
455
  /** The application's system, which `check` asks about. Default: `CAUTHY_SYSTEM`. */
450
456
  system?: string;
457
+ /**
458
+ * The application's own page for accepting an invitation, as an absolute
459
+ * address (`https://app.example.com/accept-invite`, where `<AcceptInvite />`
460
+ * is). The invitations `members.add` and `invite` send open it; without it,
461
+ * they open Cauthy's own page. Cauthy follows it only on an origin the
462
+ * client registered to be sent back to. Default: `CAUTHY_ACCEPT_INVITE_URL`.
463
+ */
464
+ acceptInviteUrl?: string;
451
465
  fetch?: typeof fetch;
452
466
  }
453
467
  /** Cauthy refused a request of the application's own. */
package/dist/vue.d.mts CHANGED
@@ -1,8 +1,8 @@
1
1
  import { ShallowRef, Plugin } from 'vue';
2
2
  import { SessionStore, SessionState, SessionStoreOptions, AuthClient } from './client.mjs';
3
3
  export { Account, AccountSession, AuthError, AuthMethods, AuthResult, Passkey, PasskeyKind, SSOConnection } from './client.mjs';
4
- import { q as PublicSession } from './system-0mHrdAgO.mjs';
5
- export { P as PermissionOf, m as Policy, R as RoleOf, s as SessionOrganization, u as SessionUser, y as can, B as definePolicy } from './system-0mHrdAgO.mjs';
4
+ import { q as PublicSession } from './system-BrrJsrFW.mjs';
5
+ export { P as PermissionOf, m as Policy, R as RoleOf, s as SessionOrganization, u as SessionUser, y as can, B as definePolicy } from './system-BrrJsrFW.mjs';
6
6
  import './theme.mjs';
7
7
  import './validate-sEXG82po.mjs';
8
8
  import 'jose';
package/dist/vue.d.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  import { ShallowRef, Plugin } from 'vue';
2
2
  import { SessionStore, SessionState, SessionStoreOptions, AuthClient } from './client.js';
3
3
  export { Account, AccountSession, AuthError, AuthMethods, AuthResult, Passkey, PasskeyKind, SSOConnection } from './client.js';
4
- import { q as PublicSession } from './system-BIYbS7h2.js';
5
- export { P as PermissionOf, m as Policy, R as RoleOf, s as SessionOrganization, u as SessionUser, y as can, B as definePolicy } from './system-BIYbS7h2.js';
4
+ import { q as PublicSession } from './system-BvvoNs2y.js';
5
+ export { P as PermissionOf, m as Policy, R as RoleOf, s as SessionOrganization, u as SessionUser, y as can, B as definePolicy } from './system-BvvoNs2y.js';
6
6
  import './theme.js';
7
7
  import './validate-sEXG82po.js';
8
8
  import 'jose';
package/dist/vue.js CHANGED
@@ -375,11 +375,11 @@ function createAuthClient(options = {}) {
375
375
  if (res.ok) {
376
376
  const m = await res.json();
377
377
  if (m.password) policy = passwordPolicyOf(m.password);
378
- return { providers: [], signUp: true, magicLink: false, passkey: false, ...m, ...policy ? { password: policy } : {}, passkeyHere: m.passkeyHere === true, passkeyOnCauthy: m.passkeyOnCauthy ?? m.passkey === true, sso: m.sso === true };
378
+ return { providers: [], signUp: true, magicLink: false, passkey: false, ...m, ...policy ? { password: policy } : {}, passwordSignIn: m.passwordSignIn !== false, passkeyHere: m.passkeyHere === true, passkeyOnCauthy: m.passkeyOnCauthy ?? m.passkey === true, sso: m.sso === true };
379
379
  }
380
380
  } catch {
381
381
  }
382
- return { providers: [], signUp: true, magicLink: false, passkey: false, passkeyHere: false, passkeyOnCauthy: false, sso: false };
382
+ return { providers: [], signUp: true, passwordSignIn: true, magicLink: false, passkey: false, passkeyHere: false, passkeyOnCauthy: false, sso: false };
383
383
  }
384
384
  async function ceremony(begin, finish, form, run, more = {}) {
385
385
  const begun = await post(begin, form, null);
@@ -526,6 +526,20 @@ function createAuthClient(options = {}) {
526
526
  forgotPassword: (f) => post("/forgot-password", { email: f.email }, checkEmail(f.email), f.captchaToken),
527
527
  resetPassword: (f) => post("/reset-password", { token: f.token, password: f.password }, checkNewPassword(f.password, policy)),
528
528
  verifyEmail: (f) => post("/verify-email", { token: f.token }, null),
529
+ async invitation(token) {
530
+ const bad = { ok: false, error: { code: "invalid_token", message: "This invitation is not valid, or it has expired." } };
531
+ if (typeof token !== "string" || token.trim() === "") return bad;
532
+ try {
533
+ const res = await doFetch(`${base}/invitation?token=${encodeURIComponent(token.trim())}`, { credentials: "same-origin", headers: { accept: "application/json" } });
534
+ const body = await res.json().catch(() => null);
535
+ if (res.ok && body?.invitation) return { ok: true, status: "ok", invitation: body.invitation };
536
+ const e = body?.error;
537
+ return { ok: false, error: e && typeof e.code === "string" ? { code: e.code, message: String(e.message ?? "") } : UNAVAILABLE };
538
+ } catch {
539
+ return { ok: false, error: UNAVAILABLE };
540
+ }
541
+ },
542
+ acceptInvitation: (token, password) => post("/invitation/accept", { token, password }, checkNewPassword(password, policy)),
529
543
  signOut: () => post("/sign-out", {}, null),
530
544
  organizations: {
531
545
  async list(system) {