cauthy-auth 0.26.0 → 0.27.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/dist/client.d.mts CHANGED
@@ -110,6 +110,30 @@ interface AuthMethods {
110
110
  * found by their work address (`signIn.ssoDiscover`, `signIn.sso`).
111
111
  */
112
112
  sso: boolean;
113
+ /**
114
+ * Set when the workspace asks something of a sign-up: the legal documents
115
+ * to accept (the terms, the privacy policy: show the links and a box, send
116
+ * `acceptLegal: true`) and the consents to ask (one box each, sent as
117
+ * `consents`; a required one must be ticked). The ready-made form shows them.
118
+ */
119
+ legal?: {
120
+ documents: {
121
+ kind: string;
122
+ version: string;
123
+ url: string;
124
+ }[];
125
+ consentPurposes: {
126
+ key: string;
127
+ label: string;
128
+ required: boolean;
129
+ }[];
130
+ };
131
+ }
132
+ /** A legal document the person owes: not yet accepted in its current version. */
133
+ interface PendingLegal {
134
+ kind: string;
135
+ version: string;
136
+ url: string;
113
137
  }
114
138
  /** A company's sign-in (an SSO connection of the workspace). */
115
139
  interface SSOConnection {
@@ -290,6 +314,18 @@ interface AccountClient {
290
314
  }): Promise<AuthResult<'changed', {
291
315
  signedIn: boolean;
292
316
  }>>;
317
+ /**
318
+ * The legal documents the person has not accepted in their current version
319
+ * (a new version of the terms, say): show them and call `acceptLegal`.
320
+ * Nothing stops the person meanwhile; the application decides what waits.
321
+ */
322
+ legal(): Promise<AuthResult<'ok', {
323
+ pending: PendingLegal[];
324
+ }>>;
325
+ /** Records the person's acceptance of the documents in force (the kinds named, or every one). */
326
+ acceptLegal(form?: {
327
+ kinds?: string[];
328
+ }): Promise<AuthResult<'accepted'>>;
293
329
  mfa: {
294
330
  /** Starts turning the second step on: show `secret` (or `otpauthUri` as a QR code) to add to an authenticator app, then call `verify`. */
295
331
  setup(form: {
@@ -617,12 +653,17 @@ interface AuthClient {
617
653
  }): string;
618
654
  };
619
655
  signUp: {
620
- /** `verification_required`: the account exists and must open the link Cauthy mailed before it can sign in. */
656
+ /**
657
+ * `verification_required`: the account exists and must open the link Cauthy mailed before it can sign in.
658
+ * `acceptLegal` and `consents` answer what `methods().legal` asks; a sign-up that leaves them out is refused.
659
+ */
621
660
  email(form: {
622
661
  email: string;
623
662
  password: string;
624
663
  name?: string;
625
664
  organization?: string;
665
+ acceptLegal?: boolean;
666
+ consents?: Record<string, boolean>;
626
667
  captchaToken?: string;
627
668
  }): Promise<AuthResult<'signed_in', {
628
669
  session: PublicSession;
@@ -675,4 +716,4 @@ interface AuthClientOptions {
675
716
  }
676
717
  declare function createAuthClient(options?: AuthClientOptions): AuthClient;
677
718
 
678
- export { type Account, type AccountClient, type AccountSession, type AuthClient, type AuthClientOptions, type AuthError, AuthField, type AuthMethods, type AuthResult, type ConnectedAgent, type LinkedIdentity, type OrganizationPerson, type OrganizationRoleChoice, type OrganizationSeat, type OrganizationsClient, type Passkey, type PasskeyKind, type SSOConnection, type SecondStep, type SessionState, type SessionStore, type SessionStoreOptions, canAutofillPasskeys, canUsePasskeys, createAuthClient, createSessionStore };
719
+ export { type Account, type AccountClient, type AccountSession, type AuthClient, type AuthClientOptions, type AuthError, AuthField, type AuthMethods, type AuthResult, type ConnectedAgent, type LinkedIdentity, type OrganizationPerson, type OrganizationRoleChoice, type OrganizationSeat, type OrganizationsClient, type Passkey, type PasskeyKind, type PendingLegal, type SSOConnection, type SecondStep, type SessionState, type SessionStore, type SessionStoreOptions, canAutofillPasskeys, canUsePasskeys, createAuthClient, createSessionStore };
package/dist/client.d.ts CHANGED
@@ -110,6 +110,30 @@ interface AuthMethods {
110
110
  * found by their work address (`signIn.ssoDiscover`, `signIn.sso`).
111
111
  */
112
112
  sso: boolean;
113
+ /**
114
+ * Set when the workspace asks something of a sign-up: the legal documents
115
+ * to accept (the terms, the privacy policy: show the links and a box, send
116
+ * `acceptLegal: true`) and the consents to ask (one box each, sent as
117
+ * `consents`; a required one must be ticked). The ready-made form shows them.
118
+ */
119
+ legal?: {
120
+ documents: {
121
+ kind: string;
122
+ version: string;
123
+ url: string;
124
+ }[];
125
+ consentPurposes: {
126
+ key: string;
127
+ label: string;
128
+ required: boolean;
129
+ }[];
130
+ };
131
+ }
132
+ /** A legal document the person owes: not yet accepted in its current version. */
133
+ interface PendingLegal {
134
+ kind: string;
135
+ version: string;
136
+ url: string;
113
137
  }
114
138
  /** A company's sign-in (an SSO connection of the workspace). */
115
139
  interface SSOConnection {
@@ -290,6 +314,18 @@ interface AccountClient {
290
314
  }): Promise<AuthResult<'changed', {
291
315
  signedIn: boolean;
292
316
  }>>;
317
+ /**
318
+ * The legal documents the person has not accepted in their current version
319
+ * (a new version of the terms, say): show them and call `acceptLegal`.
320
+ * Nothing stops the person meanwhile; the application decides what waits.
321
+ */
322
+ legal(): Promise<AuthResult<'ok', {
323
+ pending: PendingLegal[];
324
+ }>>;
325
+ /** Records the person's acceptance of the documents in force (the kinds named, or every one). */
326
+ acceptLegal(form?: {
327
+ kinds?: string[];
328
+ }): Promise<AuthResult<'accepted'>>;
293
329
  mfa: {
294
330
  /** Starts turning the second step on: show `secret` (or `otpauthUri` as a QR code) to add to an authenticator app, then call `verify`. */
295
331
  setup(form: {
@@ -617,12 +653,17 @@ interface AuthClient {
617
653
  }): string;
618
654
  };
619
655
  signUp: {
620
- /** `verification_required`: the account exists and must open the link Cauthy mailed before it can sign in. */
656
+ /**
657
+ * `verification_required`: the account exists and must open the link Cauthy mailed before it can sign in.
658
+ * `acceptLegal` and `consents` answer what `methods().legal` asks; a sign-up that leaves them out is refused.
659
+ */
621
660
  email(form: {
622
661
  email: string;
623
662
  password: string;
624
663
  name?: string;
625
664
  organization?: string;
665
+ acceptLegal?: boolean;
666
+ consents?: Record<string, boolean>;
626
667
  captchaToken?: string;
627
668
  }): Promise<AuthResult<'signed_in', {
628
669
  session: PublicSession;
@@ -675,4 +716,4 @@ interface AuthClientOptions {
675
716
  }
676
717
  declare function createAuthClient(options?: AuthClientOptions): AuthClient;
677
718
 
678
- export { type Account, type AccountClient, type AccountSession, type AuthClient, type AuthClientOptions, type AuthError, AuthField, type AuthMethods, type AuthResult, type ConnectedAgent, type LinkedIdentity, type OrganizationPerson, type OrganizationRoleChoice, type OrganizationSeat, type OrganizationsClient, type Passkey, type PasskeyKind, type SSOConnection, type SecondStep, type SessionState, type SessionStore, type SessionStoreOptions, canAutofillPasskeys, canUsePasskeys, createAuthClient, createSessionStore };
719
+ export { type Account, type AccountClient, type AccountSession, type AuthClient, type AuthClientOptions, type AuthError, AuthField, type AuthMethods, type AuthResult, type ConnectedAgent, type LinkedIdentity, type OrganizationPerson, type OrganizationRoleChoice, type OrganizationSeat, type OrganizationsClient, type Passkey, type PasskeyKind, type PendingLegal, type SSOConnection, type SecondStep, type SessionState, type SessionStore, type SessionStoreOptions, canAutofillPasskeys, canUsePasskeys, createAuthClient, createSessionStore };
package/dist/client.js CHANGED
@@ -519,7 +519,7 @@ function createAuthClient(options = {}) {
519
519
  signUp: {
520
520
  email: (f) => post(
521
521
  "/sign-up/email",
522
- { email: f.email, password: f.password, name: f.name, organization: f.organization },
522
+ { email: f.email, password: f.password, name: f.name, organization: f.organization, acceptLegal: f.acceptLegal, consents: f.consents },
523
523
  firstProblem(checkName(f.name), checkEmail(f.email), checkNewPassword(f.password), checkOrganization(f.organization)),
524
524
  f.captchaToken
525
525
  )
@@ -552,6 +552,12 @@ function createAuthClient(options = {}) {
552
552
  return body && typeof body.account === "object" ? body.account : null;
553
553
  },
554
554
  update: (f) => post("/me", { name: f.name }, checkName(f.name)),
555
+ async legal() {
556
+ const body = await read("/me/legal");
557
+ if (!body) return { ok: false, error: { code: "not_signed_in", message: "Nobody is signed in." } };
558
+ return { ok: true, status: "ok", pending: Array.isArray(body.pending) ? body.pending : [] };
559
+ },
560
+ acceptLegal: (f = {}) => post("/me/legal/accept", { kinds: f.kinds ?? [] }, null),
555
561
  changePassword: (f) => {
556
562
  const bad = checkNewPassword(f.newPassword);
557
563
  return post("/me/password", { password: f.password, newPassword: f.newPassword }, bad ? { ...bad, field: "newPassword" } : null);