cauthy-auth 0.26.0 → 0.27.1
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/cli.js +3 -1
- package/dist/client.d.mts +45 -4
- package/dist/client.d.ts +45 -4
- package/dist/client.js +9 -3
- package/dist/client.js.map +1 -1
- package/dist/client.mjs +9 -3
- package/dist/client.mjs.map +1 -1
- package/dist/index.d.mts +7 -1
- package/dist/index.d.ts +7 -1
- package/dist/index.js +31 -6
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +31 -6
- package/dist/index.mjs.map +1 -1
- package/dist/react.d.mts +48 -2
- package/dist/react.d.ts +48 -2
- package/dist/react.js +49 -6
- package/dist/react.js.map +1 -1
- package/dist/react.mjs +49 -6
- package/dist/react.mjs.map +1 -1
- package/dist/styles.css +14 -0
- package/dist/svelte.d.mts +1 -1
- package/dist/svelte.d.ts +1 -1
- package/dist/svelte.js +9 -3
- package/dist/svelte.js.map +1 -1
- package/dist/svelte.mjs +9 -3
- package/dist/svelte.mjs.map +1 -1
- package/dist/{validate-BTRit1O1.d.mts → validate-YbEfIzfl.d.mts} +2 -2
- package/dist/{validate-BTRit1O1.d.ts → validate-YbEfIzfl.d.ts} +2 -2
- package/dist/vue.d.mts +1 -1
- package/dist/vue.d.ts +1 -1
- package/dist/vue.js +9 -3
- package/dist/vue.js.map +1 -1
- package/dist/vue.mjs +9 -3
- package/dist/vue.mjs.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -928,7 +928,9 @@ function createSystem(given = {}) {
|
|
|
928
928
|
async function fail2(res, what) {
|
|
929
929
|
const body = await res.json().catch(() => null);
|
|
930
930
|
const first = body?.errors?.[0];
|
|
931
|
-
|
|
931
|
+
const code = typeof body?.error === "string" ? body.error : first?.code;
|
|
932
|
+
const message = typeof body?.error === "string" ? body.error_description : first?.message;
|
|
933
|
+
throw new CauthyApiError(res.status, code ?? "error", `Cauthy refused ${what} (${res.status}): ${message ?? res.statusText}`);
|
|
932
934
|
}
|
|
933
935
|
let held;
|
|
934
936
|
let asking;
|
package/dist/client.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { CauthyTheme } from './theme.mjs';
|
|
2
2
|
import { i as PublicSession } from './system-BxMsSIu1.mjs';
|
|
3
|
-
import { A as AuthField } from './validate-
|
|
4
|
-
export { F as FieldProblem, M as MIN_PASSWORD, c as checkCode, a as checkEmail, b as checkName, d as checkNewPassword, e as checkPassword } from './validate-
|
|
3
|
+
import { A as AuthField } from './validate-YbEfIzfl.mjs';
|
|
4
|
+
export { F as FieldProblem, M as MIN_PASSWORD, c as checkCode, a as checkEmail, b as checkName, d as checkNewPassword, e as checkPassword } from './validate-YbEfIzfl.mjs';
|
|
5
5
|
import 'jose';
|
|
6
6
|
|
|
7
7
|
/** Whether this browser can use a passkey at all. */
|
|
@@ -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
|
-
/**
|
|
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
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { CauthyTheme } from './theme.js';
|
|
2
2
|
import { i as PublicSession } from './system-DTIeDXDP.js';
|
|
3
|
-
import { A as AuthField } from './validate-
|
|
4
|
-
export { F as FieldProblem, M as MIN_PASSWORD, c as checkCode, a as checkEmail, b as checkName, d as checkNewPassword, e as checkPassword } from './validate-
|
|
3
|
+
import { A as AuthField } from './validate-YbEfIzfl.js';
|
|
4
|
+
export { F as FieldProblem, M as MIN_PASSWORD, c as checkCode, a as checkEmail, b as checkName, d as checkNewPassword, e as checkPassword } from './validate-YbEfIzfl.js';
|
|
5
5
|
import 'jose';
|
|
6
6
|
|
|
7
7
|
/** Whether this browser can use a passkey at all. */
|
|
@@ -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
|
-
/**
|
|
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
|
@@ -151,8 +151,8 @@ function fromWire(wire) {
|
|
|
151
151
|
}
|
|
152
152
|
|
|
153
153
|
// src/validate.ts
|
|
154
|
-
var MIN_PASSWORD =
|
|
155
|
-
var MAX_PASSWORD =
|
|
154
|
+
var MIN_PASSWORD = 12;
|
|
155
|
+
var MAX_PASSWORD = 128;
|
|
156
156
|
var MAX_NAME = 120;
|
|
157
157
|
var EMAIL = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
|
158
158
|
function checkEmail(value) {
|
|
@@ -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);
|