cauthy-auth 0.20.0 → 0.22.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 (43) hide show
  1. package/dist/{cauthy-Bn3iv50y.d.ts → cauthy-DGAy45G2.d.ts} +1 -1
  2. package/dist/{cauthy-C29HCvag.d.mts → cauthy-XkIbG5gE.d.mts} +1 -1
  3. package/dist/client.d.mts +111 -2
  4. package/dist/client.d.ts +111 -2
  5. package/dist/client.js +25 -0
  6. package/dist/client.js.map +1 -1
  7. package/dist/client.mjs +25 -0
  8. package/dist/client.mjs.map +1 -1
  9. package/dist/express.d.mts +2 -2
  10. package/dist/express.d.ts +2 -2
  11. package/dist/fastify.d.mts +2 -2
  12. package/dist/fastify.d.ts +2 -2
  13. package/dist/hono.d.mts +2 -2
  14. package/dist/hono.d.ts +2 -2
  15. package/dist/index.d.mts +2 -2
  16. package/dist/index.d.ts +2 -2
  17. package/dist/index.js +133 -4
  18. package/dist/index.js.map +1 -1
  19. package/dist/index.mjs +133 -4
  20. package/dist/index.mjs.map +1 -1
  21. package/dist/next.d.mts +2 -2
  22. package/dist/next.d.ts +2 -2
  23. package/dist/react.d.mts +145 -1
  24. package/dist/react.d.ts +145 -1
  25. package/dist/react.js +200 -2
  26. package/dist/react.js.map +1 -1
  27. package/dist/react.mjs +199 -2
  28. package/dist/react.mjs.map +1 -1
  29. package/dist/svelte.d.mts +2 -2
  30. package/dist/svelte.d.ts +2 -2
  31. package/dist/svelte.js +25 -0
  32. package/dist/svelte.js.map +1 -1
  33. package/dist/svelte.mjs +25 -0
  34. package/dist/svelte.mjs.map +1 -1
  35. package/dist/{system-ZD_Wa8Bm.d.mts → system-BxMsSIu1.d.mts} +2 -0
  36. package/dist/{system-DhRr_WxR.d.ts → system-DTIeDXDP.d.ts} +2 -0
  37. package/dist/vue.d.mts +2 -2
  38. package/dist/vue.d.ts +2 -2
  39. package/dist/vue.js +25 -0
  40. package/dist/vue.js.map +1 -1
  41. package/dist/vue.mjs +25 -0
  42. package/dist/vue.mjs.map +1 -1
  43. package/package.json +1 -1
package/dist/next.d.mts CHANGED
@@ -1,5 +1,5 @@
1
- import { C as Cauthy } from './cauthy-C29HCvag.mjs';
2
- import { S as Session } from './system-ZD_Wa8Bm.mjs';
1
+ import { C as Cauthy } from './cauthy-XkIbG5gE.mjs';
2
+ import { S as Session } from './system-BxMsSIu1.mjs';
3
3
  import 'jose';
4
4
  import './theme.mjs';
5
5
 
package/dist/next.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { C as Cauthy } from './cauthy-Bn3iv50y.js';
2
- import { S as Session } from './system-DhRr_WxR.js';
1
+ import { C as Cauthy } from './cauthy-DGAy45G2.js';
2
+ import { S as Session } from './system-DTIeDXDP.js';
3
3
  import 'jose';
4
4
  import './theme.js';
5
5
 
package/dist/react.d.mts CHANGED
@@ -174,6 +174,8 @@ interface SessionUser {
174
174
  emailVerifyBy?: string;
175
175
  /** The language the person reads in ("es", "en-US"), when Cauthy knows it. */
176
176
  locale?: string;
177
+ /** A guest: a visitor's session before they sign up. No email; `account.upgrade` makes it an account, keeping `id`. */
178
+ isAnonymous?: boolean;
177
179
  }
178
180
  /** A value JSON can carry. What crosses from server to browser is typed as this, never `unknown`. */
179
181
  type JsonValue = string | number | boolean | null | JsonValue[] | {
@@ -328,6 +330,82 @@ interface ConnectedAgent {
328
330
  connectedAt: string;
329
331
  lastUsedAt: string;
330
332
  }
333
+ /** An organization the person belongs to, with what their role lets them do with its people. */
334
+ interface OrganizationSeat {
335
+ id: string;
336
+ /** The client system it is of (`pondari`). */
337
+ system: string;
338
+ name: string;
339
+ kind: string;
340
+ /** The person's role in it. */
341
+ role: string;
342
+ /** Cauthy's member powers, from the system's catalog: cauthy:members read and manage. */
343
+ can: {
344
+ readMembers: boolean;
345
+ manageMembers: boolean;
346
+ };
347
+ }
348
+ /** A person of an organization, as a member who may see them reads it. */
349
+ interface OrganizationPerson {
350
+ userId: string;
351
+ email: string;
352
+ name: string;
353
+ role: string;
354
+ /** The account's: `active`, `suspended`… A disabled member is still listed. */
355
+ status: string;
356
+ /** Invited and not yet accepted. */
357
+ invited: boolean;
358
+ /** Manages the organization's members. */
359
+ manager: boolean;
360
+ /** The signed-in person. */
361
+ you: boolean;
362
+ /** UTC, ISO 8601. */
363
+ since: string;
364
+ }
365
+ /** A role of the organization's system, as the catalog names it. */
366
+ interface OrganizationRoleChoice {
367
+ role: string;
368
+ name: string;
369
+ description: string;
370
+ /** Holding it manages the organization's members. */
371
+ manager: boolean;
372
+ }
373
+ /**
374
+ * The signed-in person's organizations, and their people. Seeing them needs
375
+ * cauthy:members read in the person's role; changing them needs manage. Cauthy
376
+ * decides, with the person's own session: the application authorizes nothing.
377
+ */
378
+ interface OrganizationsClient {
379
+ /** The organizations the person belongs to; one system's only with `system`. */
380
+ list(system?: string): Promise<OrganizationSeat[]>;
381
+ /** The people of one, or null when the person may not see them. */
382
+ members(organizationId: string): Promise<OrganizationPerson[] | null>;
383
+ /** The roles a member may be given, or null when the person may not see them. */
384
+ roles(organizationId: string): Promise<OrganizationRoleChoice[] | null>;
385
+ /** Adds a person by their address; an address with no account gets one and its invitation. */
386
+ add(organizationId: string, form: {
387
+ email: string;
388
+ role: string;
389
+ name?: string;
390
+ locale?: string;
391
+ }): Promise<AuthResult<'added', {
392
+ member: OrganizationPerson;
393
+ }>>;
394
+ setRole(organizationId: string, userId: string, role: string): Promise<AuthResult<'changed', {
395
+ userId: string;
396
+ role: string;
397
+ }>>;
398
+ /** Removes a member; the person themself may always leave. */
399
+ remove(organizationId: string, userId: string): Promise<AuthResult<'removed', {
400
+ userId: string;
401
+ }>>;
402
+ /** Sends a member's invitation again. */
403
+ inviteAgain(organizationId: string, userId: string, form?: {
404
+ locale?: string;
405
+ }): Promise<AuthResult<'sent', {
406
+ userId: string;
407
+ }>>;
408
+ }
331
409
  interface AccountSession {
332
410
  /** "Mac · Chrome", or "" when the browser did not say. */
333
411
  device: string;
@@ -450,6 +528,26 @@ interface AccountClient {
450
528
  unlink(provider: string): Promise<AuthResult<'unlinked', {
451
529
  provider: string;
452
530
  }>>;
531
+ /**
532
+ * A guest becomes an account of their own with an address and a password —
533
+ * the same id, so what they did stays theirs. `email_taken`: the address has
534
+ * an account already; offer to sign in with it.
535
+ */
536
+ upgrade(form: {
537
+ email: string;
538
+ password: string;
539
+ name?: string;
540
+ }): Promise<AuthResult<'signed_in', {
541
+ session: PublicSession;
542
+ }>>;
543
+ /** Where a guest goes to become the account of a provider's address (Google…). */
544
+ upgradeUrl(provider: string, options?: {
545
+ returnTo?: string;
546
+ }): string;
547
+ /** Sends a guest to `upgradeUrl`; they come back signed in as the account. */
548
+ upgradeWith(provider: string, options?: {
549
+ returnTo?: string;
550
+ }): void;
453
551
  /** Where the account is signed in. */
454
552
  sessions(): Promise<AccountSession[]>;
455
553
  /** Signs the account out everywhere, here too. */
@@ -483,6 +581,17 @@ interface AccountClient {
483
581
  }
484
582
  interface AuthClient {
485
583
  signIn: {
584
+ /**
585
+ * A guest session, before the visitor signs up: the application keeps what
586
+ * they do under `session.user.id`, and `account.upgrade` (or
587
+ * `account.upgradeWith`) makes it their account, same id. Only where the
588
+ * workspace allows guests (`anonymous_disabled` otherwise).
589
+ */
590
+ anonymously(form?: {
591
+ captchaToken?: string;
592
+ }): Promise<AuthResult<'signed_in', {
593
+ session: PublicSession;
594
+ }>>;
486
595
  /** With address and password. `mfa_required`: ask for the code and call `signIn.mfa`. */
487
596
  email(form: {
488
597
  email: string;
@@ -658,6 +767,8 @@ interface AuthClient {
658
767
  signOut(): Promise<AuthResult<'signed_out'>>;
659
768
  /** The signed-in person's own account. */
660
769
  account: AccountClient;
770
+ /** The signed-in person's organizations, and their people. */
771
+ organizations: OrganizationsClient;
661
772
  /** Who is signed in, or null. */
662
773
  getSession(): Promise<PublicSession | null>;
663
774
  methods(): Promise<AuthMethods>;
@@ -770,6 +881,23 @@ interface AuthTexts {
770
881
  unlink: string;
771
882
  linked: string;
772
883
  ssoOnly: string;
884
+ members: string;
885
+ membersHidden: string;
886
+ organizationMissing: string;
887
+ memberYou: string;
888
+ memberInvited: string;
889
+ memberManager: string;
890
+ memberRole: string;
891
+ memberAdd: string;
892
+ memberAdded: string;
893
+ memberRemove: string;
894
+ memberRemoveConfirm: string;
895
+ memberLeave: string;
896
+ memberLeaveConfirm: string;
897
+ memberInviteAgain: string;
898
+ memberInvitationSent: string;
899
+ yes: string;
900
+ cancel: string;
773
901
  /** By error code; one missing shows what the server said. */
774
902
  errors: Record<string, string>;
775
903
  }
@@ -875,6 +1003,22 @@ interface AccountProps extends Omit<AuthFormProps, 'links' | 'returnTo' | 'onSuc
875
1003
  * its own. Like the other forms, it carries no styles.
876
1004
  */
877
1005
  declare function Account(props: AccountProps): react.JSX.Element;
1006
+ interface OrganizationMembersProps extends Omit<AuthFormProps, 'links' | 'returnTo' | 'onSuccess' | 'createAccounts'> {
1007
+ /** The organization, by the id Cauthy gave it. */
1008
+ organizationId: string;
1009
+ /** The moment of a membership, as the application writes dates. Default: the browser's own way. */
1010
+ formatDate?: (iso: string) => string;
1011
+ }
1012
+ /**
1013
+ * The people of one of the signed-in person's organizations, administered
1014
+ * from the application. What it offers follows the person's role in the
1015
+ * system's catalog: cauthy:members read lists the people; manage adds them by
1016
+ * address (one with no account is invited), changes their role, sends an
1017
+ * invitation again and removes them. Anybody may leave. Cauthy checks each
1018
+ * change with the person's own session; the application authorizes nothing.
1019
+ * Like the other forms, it carries no styles.
1020
+ */
1021
+ declare function OrganizationMembers(props: OrganizationMembersProps): react.JSX.Element;
878
1022
 
879
1023
  interface SessionContext {
880
1024
  /** The signed-in person and their organizations, or null. */
@@ -919,4 +1063,4 @@ declare function useSession(): SessionContext;
919
1063
  */
920
1064
  declare function useAuth(): AuthClient & Pick<SessionContext, 'session' | 'status' | 'refresh'>;
921
1065
 
922
- export { 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 JsonValue, type LinkedIdentity, 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 };
1066
+ export { 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 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 };
package/dist/react.d.ts CHANGED
@@ -174,6 +174,8 @@ interface SessionUser {
174
174
  emailVerifyBy?: string;
175
175
  /** The language the person reads in ("es", "en-US"), when Cauthy knows it. */
176
176
  locale?: string;
177
+ /** A guest: a visitor's session before they sign up. No email; `account.upgrade` makes it an account, keeping `id`. */
178
+ isAnonymous?: boolean;
177
179
  }
178
180
  /** A value JSON can carry. What crosses from server to browser is typed as this, never `unknown`. */
179
181
  type JsonValue = string | number | boolean | null | JsonValue[] | {
@@ -328,6 +330,82 @@ interface ConnectedAgent {
328
330
  connectedAt: string;
329
331
  lastUsedAt: string;
330
332
  }
333
+ /** An organization the person belongs to, with what their role lets them do with its people. */
334
+ interface OrganizationSeat {
335
+ id: string;
336
+ /** The client system it is of (`pondari`). */
337
+ system: string;
338
+ name: string;
339
+ kind: string;
340
+ /** The person's role in it. */
341
+ role: string;
342
+ /** Cauthy's member powers, from the system's catalog: cauthy:members read and manage. */
343
+ can: {
344
+ readMembers: boolean;
345
+ manageMembers: boolean;
346
+ };
347
+ }
348
+ /** A person of an organization, as a member who may see them reads it. */
349
+ interface OrganizationPerson {
350
+ userId: string;
351
+ email: string;
352
+ name: string;
353
+ role: string;
354
+ /** The account's: `active`, `suspended`… A disabled member is still listed. */
355
+ status: string;
356
+ /** Invited and not yet accepted. */
357
+ invited: boolean;
358
+ /** Manages the organization's members. */
359
+ manager: boolean;
360
+ /** The signed-in person. */
361
+ you: boolean;
362
+ /** UTC, ISO 8601. */
363
+ since: string;
364
+ }
365
+ /** A role of the organization's system, as the catalog names it. */
366
+ interface OrganizationRoleChoice {
367
+ role: string;
368
+ name: string;
369
+ description: string;
370
+ /** Holding it manages the organization's members. */
371
+ manager: boolean;
372
+ }
373
+ /**
374
+ * The signed-in person's organizations, and their people. Seeing them needs
375
+ * cauthy:members read in the person's role; changing them needs manage. Cauthy
376
+ * decides, with the person's own session: the application authorizes nothing.
377
+ */
378
+ interface OrganizationsClient {
379
+ /** The organizations the person belongs to; one system's only with `system`. */
380
+ list(system?: string): Promise<OrganizationSeat[]>;
381
+ /** The people of one, or null when the person may not see them. */
382
+ members(organizationId: string): Promise<OrganizationPerson[] | null>;
383
+ /** The roles a member may be given, or null when the person may not see them. */
384
+ roles(organizationId: string): Promise<OrganizationRoleChoice[] | null>;
385
+ /** Adds a person by their address; an address with no account gets one and its invitation. */
386
+ add(organizationId: string, form: {
387
+ email: string;
388
+ role: string;
389
+ name?: string;
390
+ locale?: string;
391
+ }): Promise<AuthResult<'added', {
392
+ member: OrganizationPerson;
393
+ }>>;
394
+ setRole(organizationId: string, userId: string, role: string): Promise<AuthResult<'changed', {
395
+ userId: string;
396
+ role: string;
397
+ }>>;
398
+ /** Removes a member; the person themself may always leave. */
399
+ remove(organizationId: string, userId: string): Promise<AuthResult<'removed', {
400
+ userId: string;
401
+ }>>;
402
+ /** Sends a member's invitation again. */
403
+ inviteAgain(organizationId: string, userId: string, form?: {
404
+ locale?: string;
405
+ }): Promise<AuthResult<'sent', {
406
+ userId: string;
407
+ }>>;
408
+ }
331
409
  interface AccountSession {
332
410
  /** "Mac · Chrome", or "" when the browser did not say. */
333
411
  device: string;
@@ -450,6 +528,26 @@ interface AccountClient {
450
528
  unlink(provider: string): Promise<AuthResult<'unlinked', {
451
529
  provider: string;
452
530
  }>>;
531
+ /**
532
+ * A guest becomes an account of their own with an address and a password —
533
+ * the same id, so what they did stays theirs. `email_taken`: the address has
534
+ * an account already; offer to sign in with it.
535
+ */
536
+ upgrade(form: {
537
+ email: string;
538
+ password: string;
539
+ name?: string;
540
+ }): Promise<AuthResult<'signed_in', {
541
+ session: PublicSession;
542
+ }>>;
543
+ /** Where a guest goes to become the account of a provider's address (Google…). */
544
+ upgradeUrl(provider: string, options?: {
545
+ returnTo?: string;
546
+ }): string;
547
+ /** Sends a guest to `upgradeUrl`; they come back signed in as the account. */
548
+ upgradeWith(provider: string, options?: {
549
+ returnTo?: string;
550
+ }): void;
453
551
  /** Where the account is signed in. */
454
552
  sessions(): Promise<AccountSession[]>;
455
553
  /** Signs the account out everywhere, here too. */
@@ -483,6 +581,17 @@ interface AccountClient {
483
581
  }
484
582
  interface AuthClient {
485
583
  signIn: {
584
+ /**
585
+ * A guest session, before the visitor signs up: the application keeps what
586
+ * they do under `session.user.id`, and `account.upgrade` (or
587
+ * `account.upgradeWith`) makes it their account, same id. Only where the
588
+ * workspace allows guests (`anonymous_disabled` otherwise).
589
+ */
590
+ anonymously(form?: {
591
+ captchaToken?: string;
592
+ }): Promise<AuthResult<'signed_in', {
593
+ session: PublicSession;
594
+ }>>;
486
595
  /** With address and password. `mfa_required`: ask for the code and call `signIn.mfa`. */
487
596
  email(form: {
488
597
  email: string;
@@ -658,6 +767,8 @@ interface AuthClient {
658
767
  signOut(): Promise<AuthResult<'signed_out'>>;
659
768
  /** The signed-in person's own account. */
660
769
  account: AccountClient;
770
+ /** The signed-in person's organizations, and their people. */
771
+ organizations: OrganizationsClient;
661
772
  /** Who is signed in, or null. */
662
773
  getSession(): Promise<PublicSession | null>;
663
774
  methods(): Promise<AuthMethods>;
@@ -770,6 +881,23 @@ interface AuthTexts {
770
881
  unlink: string;
771
882
  linked: string;
772
883
  ssoOnly: string;
884
+ members: string;
885
+ membersHidden: string;
886
+ organizationMissing: string;
887
+ memberYou: string;
888
+ memberInvited: string;
889
+ memberManager: string;
890
+ memberRole: string;
891
+ memberAdd: string;
892
+ memberAdded: string;
893
+ memberRemove: string;
894
+ memberRemoveConfirm: string;
895
+ memberLeave: string;
896
+ memberLeaveConfirm: string;
897
+ memberInviteAgain: string;
898
+ memberInvitationSent: string;
899
+ yes: string;
900
+ cancel: string;
773
901
  /** By error code; one missing shows what the server said. */
774
902
  errors: Record<string, string>;
775
903
  }
@@ -875,6 +1003,22 @@ interface AccountProps extends Omit<AuthFormProps, 'links' | 'returnTo' | 'onSuc
875
1003
  * its own. Like the other forms, it carries no styles.
876
1004
  */
877
1005
  declare function Account(props: AccountProps): react.JSX.Element;
1006
+ interface OrganizationMembersProps extends Omit<AuthFormProps, 'links' | 'returnTo' | 'onSuccess' | 'createAccounts'> {
1007
+ /** The organization, by the id Cauthy gave it. */
1008
+ organizationId: string;
1009
+ /** The moment of a membership, as the application writes dates. Default: the browser's own way. */
1010
+ formatDate?: (iso: string) => string;
1011
+ }
1012
+ /**
1013
+ * The people of one of the signed-in person's organizations, administered
1014
+ * from the application. What it offers follows the person's role in the
1015
+ * system's catalog: cauthy:members read lists the people; manage adds them by
1016
+ * address (one with no account is invited), changes their role, sends an
1017
+ * invitation again and removes them. Anybody may leave. Cauthy checks each
1018
+ * change with the person's own session; the application authorizes nothing.
1019
+ * Like the other forms, it carries no styles.
1020
+ */
1021
+ declare function OrganizationMembers(props: OrganizationMembersProps): react.JSX.Element;
878
1022
 
879
1023
  interface SessionContext {
880
1024
  /** The signed-in person and their organizations, or null. */
@@ -919,4 +1063,4 @@ declare function useSession(): SessionContext;
919
1063
  */
920
1064
  declare function useAuth(): AuthClient & Pick<SessionContext, 'session' | 'status' | 'refresh'>;
921
1065
 
922
- export { 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 JsonValue, type LinkedIdentity, 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 };
1066
+ export { 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 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 };