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.mjs
CHANGED
|
@@ -1201,6 +1201,8 @@ function createCauthy(given = {}) {
|
|
|
1201
1201
|
"/sign-in/mfa/push/finish",
|
|
1202
1202
|
"/me/sessions",
|
|
1203
1203
|
"/me/sessions/end",
|
|
1204
|
+
"/me/legal",
|
|
1205
|
+
"/me/legal/accept",
|
|
1204
1206
|
"/me/email",
|
|
1205
1207
|
"/me/identities",
|
|
1206
1208
|
"/me/identities/unlink",
|
|
@@ -1259,6 +1261,8 @@ function createCauthy(given = {}) {
|
|
|
1259
1261
|
passkeyOnCauthy: place.error ? true : place.data?.on_cauthy === true,
|
|
1260
1262
|
// A company's sign-in, found by the person's work address.
|
|
1261
1263
|
sso: Array.isArray(sso.data) && sso.data.some((c) => c?.discoverable === true),
|
|
1264
|
+
// The terms a sign-up accepts and the consents it answers, when the workspace asks any.
|
|
1265
|
+
...settings.data?.legal ? { legal: legalOf(settings.data.legal) } : {},
|
|
1262
1266
|
...settings.data?.captcha_enabled === true && settings.data?.captcha_site_key ? { captchaSiteKey: String(settings.data.captcha_site_key) } : {}
|
|
1263
1267
|
});
|
|
1264
1268
|
}
|
|
@@ -1419,11 +1423,15 @@ function createCauthy(given = {}) {
|
|
|
1419
1423
|
if (res.error) return problem(res.status, res.error.code, res.error.message, void 0, mine.headers);
|
|
1420
1424
|
return json(factorsOf(res.data), 200, mine.headers);
|
|
1421
1425
|
}
|
|
1422
|
-
if ((route === "/me" || route === "/me/sessions") && !post) {
|
|
1426
|
+
if ((route === "/me" || route === "/me/sessions" || route === "/me/legal") && !post) {
|
|
1423
1427
|
const mine = await signedInAs(request);
|
|
1424
1428
|
if ("response" in mine) return mine.response;
|
|
1425
|
-
const res = await ask(request, "GET", route === "/me" ? "/v1/auth/me" : "/v1/auth/me/sessions", void 0, void 0, mine.token);
|
|
1429
|
+
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);
|
|
1426
1430
|
if (res.error) return problem(res.status, res.error.code, res.error.message, void 0, mine.headers);
|
|
1431
|
+
if (route === "/me/legal") {
|
|
1432
|
+
const list = Array.isArray(res.data?.pending) ? res.data.pending : [];
|
|
1433
|
+
return json({ pending: list.map((d) => ({ kind: String(d.kind ?? ""), version: String(d.version ?? ""), url: String(d.url ?? "") })) }, 200, mine.headers);
|
|
1434
|
+
}
|
|
1427
1435
|
if (route === "/me/sessions") {
|
|
1428
1436
|
const list = Array.isArray(res.data) ? res.data : [];
|
|
1429
1437
|
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);
|
|
@@ -1549,7 +1557,8 @@ function createCauthy(given = {}) {
|
|
|
1549
1557
|
if (bad) return invalid(bad);
|
|
1550
1558
|
const email = String(b.email).trim();
|
|
1551
1559
|
const organization = typeof b.organization === "string" && b.organization.trim() !== "" ? { organization: { name: b.organization.trim() } } : {};
|
|
1552
|
-
const
|
|
1560
|
+
const legal = { ...b.acceptLegal === true ? { accept_legal: true } : {}, ...b.consents && typeof b.consents === "object" ? { consents: b.consents } : {} };
|
|
1561
|
+
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);
|
|
1553
1562
|
if (made.error) return problem(made.status, made.error.code, made.error.message);
|
|
1554
1563
|
if (made.data?.verification_required === true) return json({ status: "verification_required", email });
|
|
1555
1564
|
const res = await ask(request, "POST", "/v1/auth/login", { email, password: b.password });
|
|
@@ -1580,6 +1589,12 @@ function createCauthy(given = {}) {
|
|
|
1580
1589
|
}
|
|
1581
1590
|
return json({ status: "saved", account: accountOf(res.data) }, 200, h);
|
|
1582
1591
|
}
|
|
1592
|
+
if (route === "/me/legal/accept") {
|
|
1593
|
+
const kinds = Array.isArray(b.kinds) ? b.kinds.filter((k) => typeof k === "string") : [];
|
|
1594
|
+
const res = await as("/v1/auth/me/legal/accept", { kinds });
|
|
1595
|
+
if (res.error) return refused(res);
|
|
1596
|
+
return json({ status: "accepted" }, 200, mine.headers);
|
|
1597
|
+
}
|
|
1583
1598
|
if (route === "/me/password") {
|
|
1584
1599
|
const bad = checkNewPassword(b.newPassword);
|
|
1585
1600
|
if (bad) return problem(400, bad.code, bad.message, "newPassword");
|
|
@@ -1879,6 +1894,14 @@ function createCauthy(given = {}) {
|
|
|
1879
1894
|
options: { issuer, clientId, basePath, afterSignIn, afterSignOut, cookieName }
|
|
1880
1895
|
};
|
|
1881
1896
|
}
|
|
1897
|
+
function legalOf(raw) {
|
|
1898
|
+
const documents = Array.isArray(raw?.documents) ? raw.documents : [];
|
|
1899
|
+
const purposes = Array.isArray(raw?.consent_purposes) ? raw.consent_purposes : [];
|
|
1900
|
+
return {
|
|
1901
|
+
documents: documents.map((d) => ({ kind: String(d.kind ?? ""), version: String(d.version ?? ""), url: String(d.url ?? "") })),
|
|
1902
|
+
consentPurposes: purposes.map((p) => ({ key: String(p.key ?? ""), label: String(p.label ?? ""), required: p.required === true }))
|
|
1903
|
+
};
|
|
1904
|
+
}
|
|
1882
1905
|
|
|
1883
1906
|
// src/permissions.ts
|
|
1884
1907
|
function matches(entry, resource, action) {
|