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 +43 -2
- package/dist/client.d.ts +43 -2
- package/dist/client.js +7 -1
- package/dist/client.js.map +1 -1
- package/dist/client.mjs +7 -1
- package/dist/client.mjs.map +1 -1
- package/dist/index.js +26 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +26 -3
- 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 +45 -2
- package/dist/react.js.map +1 -1
- package/dist/react.mjs +45 -2
- package/dist/react.mjs.map +1 -1
- package/dist/styles.css +14 -0
- package/dist/svelte.js +7 -1
- package/dist/svelte.js.map +1 -1
- package/dist/svelte.mjs +7 -1
- package/dist/svelte.mjs.map +1 -1
- package/dist/vue.js +7 -1
- package/dist/vue.js.map +1 -1
- package/dist/vue.mjs +7 -1
- package/dist/vue.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1249,6 +1249,8 @@ function createCauthy(given = {}) {
|
|
|
1249
1249
|
"/sign-in/mfa/push/finish",
|
|
1250
1250
|
"/me/sessions",
|
|
1251
1251
|
"/me/sessions/end",
|
|
1252
|
+
"/me/legal",
|
|
1253
|
+
"/me/legal/accept",
|
|
1252
1254
|
"/me/email",
|
|
1253
1255
|
"/me/identities",
|
|
1254
1256
|
"/me/identities/unlink",
|
|
@@ -1307,6 +1309,8 @@ function createCauthy(given = {}) {
|
|
|
1307
1309
|
passkeyOnCauthy: place.error ? true : place.data?.on_cauthy === true,
|
|
1308
1310
|
// A company's sign-in, found by the person's work address.
|
|
1309
1311
|
sso: Array.isArray(sso.data) && sso.data.some((c) => c?.discoverable === true),
|
|
1312
|
+
// The terms a sign-up accepts and the consents it answers, when the workspace asks any.
|
|
1313
|
+
...settings.data?.legal ? { legal: legalOf(settings.data.legal) } : {},
|
|
1310
1314
|
...settings.data?.captcha_enabled === true && settings.data?.captcha_site_key ? { captchaSiteKey: String(settings.data.captcha_site_key) } : {}
|
|
1311
1315
|
});
|
|
1312
1316
|
}
|
|
@@ -1467,11 +1471,15 @@ function createCauthy(given = {}) {
|
|
|
1467
1471
|
if (res.error) return problem(res.status, res.error.code, res.error.message, void 0, mine.headers);
|
|
1468
1472
|
return json(factorsOf(res.data), 200, mine.headers);
|
|
1469
1473
|
}
|
|
1470
|
-
if ((route === "/me" || route === "/me/sessions") && !post) {
|
|
1474
|
+
if ((route === "/me" || route === "/me/sessions" || route === "/me/legal") && !post) {
|
|
1471
1475
|
const mine = await signedInAs(request);
|
|
1472
1476
|
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);
|
|
1477
|
+
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
1478
|
if (res.error) return problem(res.status, res.error.code, res.error.message, void 0, mine.headers);
|
|
1479
|
+
if (route === "/me/legal") {
|
|
1480
|
+
const list = Array.isArray(res.data?.pending) ? res.data.pending : [];
|
|
1481
|
+
return json({ pending: list.map((d) => ({ kind: String(d.kind ?? ""), version: String(d.version ?? ""), url: String(d.url ?? "") })) }, 200, mine.headers);
|
|
1482
|
+
}
|
|
1475
1483
|
if (route === "/me/sessions") {
|
|
1476
1484
|
const list = Array.isArray(res.data) ? res.data : [];
|
|
1477
1485
|
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 +1605,8 @@ function createCauthy(given = {}) {
|
|
|
1597
1605
|
if (bad) return invalid(bad);
|
|
1598
1606
|
const email = String(b.email).trim();
|
|
1599
1607
|
const organization = typeof b.organization === "string" && b.organization.trim() !== "" ? { organization: { name: b.organization.trim() } } : {};
|
|
1600
|
-
const
|
|
1608
|
+
const legal = { ...b.acceptLegal === true ? { accept_legal: true } : {}, ...b.consents && typeof b.consents === "object" ? { consents: b.consents } : {} };
|
|
1609
|
+
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
1610
|
if (made.error) return problem(made.status, made.error.code, made.error.message);
|
|
1602
1611
|
if (made.data?.verification_required === true) return json({ status: "verification_required", email });
|
|
1603
1612
|
const res = await ask(request, "POST", "/v1/auth/login", { email, password: b.password });
|
|
@@ -1628,6 +1637,12 @@ function createCauthy(given = {}) {
|
|
|
1628
1637
|
}
|
|
1629
1638
|
return json({ status: "saved", account: accountOf(res.data) }, 200, h);
|
|
1630
1639
|
}
|
|
1640
|
+
if (route === "/me/legal/accept") {
|
|
1641
|
+
const kinds = Array.isArray(b.kinds) ? b.kinds.filter((k) => typeof k === "string") : [];
|
|
1642
|
+
const res = await as("/v1/auth/me/legal/accept", { kinds });
|
|
1643
|
+
if (res.error) return refused(res);
|
|
1644
|
+
return json({ status: "accepted" }, 200, mine.headers);
|
|
1645
|
+
}
|
|
1631
1646
|
if (route === "/me/password") {
|
|
1632
1647
|
const bad = checkNewPassword(b.newPassword);
|
|
1633
1648
|
if (bad) return problem(400, bad.code, bad.message, "newPassword");
|
|
@@ -1927,6 +1942,14 @@ function createCauthy(given = {}) {
|
|
|
1927
1942
|
options: { issuer, clientId, basePath, afterSignIn, afterSignOut, cookieName }
|
|
1928
1943
|
};
|
|
1929
1944
|
}
|
|
1945
|
+
function legalOf(raw) {
|
|
1946
|
+
const documents = Array.isArray(raw?.documents) ? raw.documents : [];
|
|
1947
|
+
const purposes = Array.isArray(raw?.consent_purposes) ? raw.consent_purposes : [];
|
|
1948
|
+
return {
|
|
1949
|
+
documents: documents.map((d) => ({ kind: String(d.kind ?? ""), version: String(d.version ?? ""), url: String(d.url ?? "") })),
|
|
1950
|
+
consentPurposes: purposes.map((p) => ({ key: String(p.key ?? ""), label: String(p.label ?? ""), required: p.required === true }))
|
|
1951
|
+
};
|
|
1952
|
+
}
|
|
1930
1953
|
|
|
1931
1954
|
// src/permissions.ts
|
|
1932
1955
|
function matches(entry, resource, action) {
|