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/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { C as Cauthy, a as CauthyEvent, b as CauthyWebhookError, R as Resolved, V as VerifyWebhookOptions, c as createCauthy, v as verifyWebhook } from './cauthy-DGAy45G2.js';
|
|
2
2
|
export { C as CauthyApiError, a as CauthyConfigError, b as CauthyOptions, c as CauthySystem, J as JsonValue, N as NewMember, O as Organization, d as OrganizationMember, P as PermissionOf, e as Permitted, f as Policy, g as PolicyPermission, h as PolicyRole, i as PublicSession, j as PushPolicyOptions, R as RoleOf, S as Session, k as SessionOrganization, l as SessionStatus, m as SessionUser, n as SystemKey, o as SystemOptions, p as can, q as createSystem, r as definePolicy, s as policySource, t as pullPolicy, u as pushPolicy } from './system-DTIeDXDP.js';
|
|
3
3
|
export { CauthyTheme, ImportedTheme, PushThemeOptions, StackmythThemeOptions, StackmythTokens, ThemeFont, ThemeTexts, pushTheme, themeFromStackmyth, tokensFromStackmyth } from './theme.js';
|
|
4
|
-
export { A as AuthField, F as FieldProblem, M as MIN_PASSWORD, c as checkCode, a as checkEmail, b as checkName, d as checkNewPassword, e as checkPassword } from './validate-
|
|
4
|
+
export { A as AuthField, 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 { JWTVerifyGetKey } from 'jose';
|
|
6
6
|
|
|
7
7
|
interface ConnectOptions {
|
|
@@ -33,10 +33,16 @@ interface Connected {
|
|
|
33
33
|
/** Shown this once: Cauthy keeps only its hash. */
|
|
34
34
|
clientSecret: string;
|
|
35
35
|
redirectUris: string[];
|
|
36
|
+
/**
|
|
37
|
+
* The subscription to events, when `eventsUrl` was given. Its `secret` signs
|
|
38
|
+
* the HMAC header (X-Cauthy-Signature) and is shown this once; `auth.webhook`
|
|
39
|
+
* does not need it, as it verifies by Cauthy's published keys.
|
|
40
|
+
*/
|
|
36
41
|
webhook: {
|
|
37
42
|
id: string;
|
|
38
43
|
url: string;
|
|
39
44
|
events: string[];
|
|
45
|
+
secret: string;
|
|
40
46
|
} | null;
|
|
41
47
|
/**
|
|
42
48
|
* Everything the application sets: what Cauthy answered, plus CAUTHY_SECRET,
|
package/dist/index.js
CHANGED
|
@@ -543,7 +543,9 @@ function createSystem(given = {}) {
|
|
|
543
543
|
async function fail(res, what) {
|
|
544
544
|
const body = await res.json().catch(() => null);
|
|
545
545
|
const first = body?.errors?.[0];
|
|
546
|
-
|
|
546
|
+
const code = typeof body?.error === "string" ? body.error : first?.code;
|
|
547
|
+
const message = typeof body?.error === "string" ? body.error_description : first?.message;
|
|
548
|
+
throw new CauthyApiError(res.status, code ?? "error", `Cauthy refused ${what} (${res.status}): ${message ?? res.statusText}`);
|
|
547
549
|
}
|
|
548
550
|
let held;
|
|
549
551
|
let asking;
|
|
@@ -653,8 +655,8 @@ function createSystem(given = {}) {
|
|
|
653
655
|
}
|
|
654
656
|
|
|
655
657
|
// src/validate.ts
|
|
656
|
-
var MIN_PASSWORD =
|
|
657
|
-
var MAX_PASSWORD =
|
|
658
|
+
var MIN_PASSWORD = 12;
|
|
659
|
+
var MAX_PASSWORD = 128;
|
|
658
660
|
var MAX_NAME = 120;
|
|
659
661
|
var EMAIL = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
|
660
662
|
function checkEmail(value) {
|
|
@@ -1249,6 +1251,8 @@ function createCauthy(given = {}) {
|
|
|
1249
1251
|
"/sign-in/mfa/push/finish",
|
|
1250
1252
|
"/me/sessions",
|
|
1251
1253
|
"/me/sessions/end",
|
|
1254
|
+
"/me/legal",
|
|
1255
|
+
"/me/legal/accept",
|
|
1252
1256
|
"/me/email",
|
|
1253
1257
|
"/me/identities",
|
|
1254
1258
|
"/me/identities/unlink",
|
|
@@ -1307,6 +1311,8 @@ function createCauthy(given = {}) {
|
|
|
1307
1311
|
passkeyOnCauthy: place.error ? true : place.data?.on_cauthy === true,
|
|
1308
1312
|
// A company's sign-in, found by the person's work address.
|
|
1309
1313
|
sso: Array.isArray(sso.data) && sso.data.some((c) => c?.discoverable === true),
|
|
1314
|
+
// The terms a sign-up accepts and the consents it answers, when the workspace asks any.
|
|
1315
|
+
...settings.data?.legal ? { legal: legalOf(settings.data.legal) } : {},
|
|
1310
1316
|
...settings.data?.captcha_enabled === true && settings.data?.captcha_site_key ? { captchaSiteKey: String(settings.data.captcha_site_key) } : {}
|
|
1311
1317
|
});
|
|
1312
1318
|
}
|
|
@@ -1467,11 +1473,15 @@ function createCauthy(given = {}) {
|
|
|
1467
1473
|
if (res.error) return problem(res.status, res.error.code, res.error.message, void 0, mine.headers);
|
|
1468
1474
|
return json(factorsOf(res.data), 200, mine.headers);
|
|
1469
1475
|
}
|
|
1470
|
-
if ((route === "/me" || route === "/me/sessions") && !post) {
|
|
1476
|
+
if ((route === "/me" || route === "/me/sessions" || route === "/me/legal") && !post) {
|
|
1471
1477
|
const mine = await signedInAs(request);
|
|
1472
1478
|
if ("response" in mine) return mine.response;
|
|
1473
|
-
const res = await ask(request, "GET", route === "/me" ? "/v1/auth/me" : "/v1/auth/me/sessions", void 0, void 0, mine.token);
|
|
1479
|
+
const res = await ask(request, "GET", route === "/me" ? "/v1/auth/me" : route === "/me/legal" ? "/v1/auth/me/legal" : "/v1/auth/me/sessions", void 0, void 0, mine.token);
|
|
1474
1480
|
if (res.error) return problem(res.status, res.error.code, res.error.message, void 0, mine.headers);
|
|
1481
|
+
if (route === "/me/legal") {
|
|
1482
|
+
const list = Array.isArray(res.data?.pending) ? res.data.pending : [];
|
|
1483
|
+
return json({ pending: list.map((d) => ({ kind: String(d.kind ?? ""), version: String(d.version ?? ""), url: String(d.url ?? "") })) }, 200, mine.headers);
|
|
1484
|
+
}
|
|
1475
1485
|
if (route === "/me/sessions") {
|
|
1476
1486
|
const list = Array.isArray(res.data) ? res.data : [];
|
|
1477
1487
|
return json({ sessions: list.map((x) => ({ device: String(x.device ?? ""), ip: String(x.ip ?? ""), createdAt: String(x.created_at ?? ""), expiresAt: String(x.expires_at ?? "") })) }, 200, mine.headers);
|
|
@@ -1597,7 +1607,8 @@ function createCauthy(given = {}) {
|
|
|
1597
1607
|
if (bad) return invalid(bad);
|
|
1598
1608
|
const email = String(b.email).trim();
|
|
1599
1609
|
const organization = typeof b.organization === "string" && b.organization.trim() !== "" ? { organization: { name: b.organization.trim() } } : {};
|
|
1600
|
-
const
|
|
1610
|
+
const legal = { ...b.acceptLegal === true ? { accept_legal: true } : {}, ...b.consents && typeof b.consents === "object" ? { consents: b.consents } : {} };
|
|
1611
|
+
const made = await ask(request, "POST", "/v1/auth/register", { email, password: b.password, display_name: typeof b.name === "string" ? b.name.trim() : "", ...organization, ...legal }, pages.verifyEmail);
|
|
1601
1612
|
if (made.error) return problem(made.status, made.error.code, made.error.message);
|
|
1602
1613
|
if (made.data?.verification_required === true) return json({ status: "verification_required", email });
|
|
1603
1614
|
const res = await ask(request, "POST", "/v1/auth/login", { email, password: b.password });
|
|
@@ -1628,6 +1639,12 @@ function createCauthy(given = {}) {
|
|
|
1628
1639
|
}
|
|
1629
1640
|
return json({ status: "saved", account: accountOf(res.data) }, 200, h);
|
|
1630
1641
|
}
|
|
1642
|
+
if (route === "/me/legal/accept") {
|
|
1643
|
+
const kinds = Array.isArray(b.kinds) ? b.kinds.filter((k) => typeof k === "string") : [];
|
|
1644
|
+
const res = await as("/v1/auth/me/legal/accept", { kinds });
|
|
1645
|
+
if (res.error) return refused(res);
|
|
1646
|
+
return json({ status: "accepted" }, 200, mine.headers);
|
|
1647
|
+
}
|
|
1631
1648
|
if (route === "/me/password") {
|
|
1632
1649
|
const bad = checkNewPassword(b.newPassword);
|
|
1633
1650
|
if (bad) return problem(400, bad.code, bad.message, "newPassword");
|
|
@@ -1927,6 +1944,14 @@ function createCauthy(given = {}) {
|
|
|
1927
1944
|
options: { issuer, clientId, basePath, afterSignIn, afterSignOut, cookieName }
|
|
1928
1945
|
};
|
|
1929
1946
|
}
|
|
1947
|
+
function legalOf(raw) {
|
|
1948
|
+
const documents = Array.isArray(raw?.documents) ? raw.documents : [];
|
|
1949
|
+
const purposes = Array.isArray(raw?.consent_purposes) ? raw.consent_purposes : [];
|
|
1950
|
+
return {
|
|
1951
|
+
documents: documents.map((d) => ({ kind: String(d.kind ?? ""), version: String(d.version ?? ""), url: String(d.url ?? "") })),
|
|
1952
|
+
consentPurposes: purposes.map((p) => ({ key: String(p.key ?? ""), label: String(p.label ?? ""), required: p.required === true }))
|
|
1953
|
+
};
|
|
1954
|
+
}
|
|
1930
1955
|
|
|
1931
1956
|
// src/permissions.ts
|
|
1932
1957
|
function matches(entry, resource, action) {
|