cauthy-auth 0.28.0 → 0.30.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/README.md +52 -1
- package/dist/{cauthy-XkIbG5gE.d.mts → cauthy-BXgsZ-Um.d.mts} +19 -1
- package/dist/{cauthy-DGAy45G2.d.ts → cauthy-CHENs452.d.ts} +19 -1
- package/dist/cli.js +155 -54
- package/dist/client.d.mts +47 -7
- package/dist/client.d.ts +47 -7
- package/dist/client.js +23 -1
- package/dist/client.js.map +1 -1
- package/dist/client.mjs +23 -1
- package/dist/client.mjs.map +1 -1
- package/dist/express.d.mts +2 -2
- package/dist/express.d.ts +2 -2
- package/dist/fastify.d.mts +2 -2
- package/dist/fastify.d.ts +2 -2
- package/dist/hono.d.mts +2 -2
- package/dist/hono.d.ts +2 -2
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +352 -131
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +350 -131
- package/dist/index.mjs.map +1 -1
- package/dist/next.d.mts +2 -2
- package/dist/next.d.ts +2 -2
- package/dist/react.d.mts +214 -18
- package/dist/react.d.ts +214 -18
- package/dist/react.js +129 -32
- package/dist/react.js.map +1 -1
- package/dist/react.mjs +129 -32
- package/dist/react.mjs.map +1 -1
- package/dist/svelte.d.mts +2 -2
- package/dist/svelte.d.ts +2 -2
- package/dist/svelte.js +37 -2
- package/dist/svelte.js.map +1 -1
- package/dist/svelte.mjs +37 -2
- package/dist/svelte.mjs.map +1 -1
- package/dist/{system-BxMsSIu1.d.mts → system-0mHrdAgO.d.mts} +312 -112
- package/dist/{system-DTIeDXDP.d.ts → system-BIYbS7h2.d.ts} +312 -112
- package/dist/vue.d.mts +2 -2
- package/dist/vue.d.ts +2 -2
- package/dist/vue.js +37 -2
- package/dist/vue.js.map +1 -1
- package/dist/vue.mjs +37 -2
- package/dist/vue.mjs.map +1 -1
- package/package.json +1 -1
package/dist/client.js
CHANGED
|
@@ -294,6 +294,12 @@ function checkOrganization(value, required = false) {
|
|
|
294
294
|
if (v.length > MAX_ORGANIZATION) return { field: "organization", code: "too_long", message: `Use at most ${MAX_ORGANIZATION} characters.` };
|
|
295
295
|
return null;
|
|
296
296
|
}
|
|
297
|
+
function checkOrganizationName(value) {
|
|
298
|
+
const v = typeof value === "string" ? value.trim() : "";
|
|
299
|
+
if (v === "") return { field: "name", code: "required", message: "Enter the organization's name." };
|
|
300
|
+
if (v.length > MAX_ORGANIZATION) return { field: "name", code: "too_long", message: `Use at most ${MAX_ORGANIZATION} characters.` };
|
|
301
|
+
return null;
|
|
302
|
+
}
|
|
297
303
|
function checkCode(value) {
|
|
298
304
|
const v = typeof value === "string" ? value.trim() : "";
|
|
299
305
|
if (v === "") return { field: "code", code: "required", message: "Enter the code." };
|
|
@@ -654,7 +660,23 @@ function createAuthClient(options = {}) {
|
|
|
654
660
|
add: (id, f) => post("/me/organizations/members/add", { organizationId: id, email: f.email, role: f.role, name: f.name ?? "", locale: f.locale ?? "" }, checkEmail(f.email)),
|
|
655
661
|
setRole: (id, userId, role) => post("/me/organizations/members/role", { organizationId: id, userId, role }, null),
|
|
656
662
|
remove: (id, userId) => post("/me/organizations/members/remove", { organizationId: id, userId }, null),
|
|
657
|
-
inviteAgain: (id, userId, f = {}) => post("/me/organizations/members/invite", { organizationId: id, userId, locale: f.locale ?? "" }, null)
|
|
663
|
+
inviteAgain: (id, userId, f = {}) => post("/me/organizations/members/invite", { organizationId: id, userId, locale: f.locale ?? "" }, null),
|
|
664
|
+
rename: (id, name) => post("/me/organizations/rename", { organizationId: id, name }, checkOrganizationName(name)),
|
|
665
|
+
archive: (id) => post("/me/organizations/archive", { organizationId: id }, null),
|
|
666
|
+
delete: (id) => post("/me/organizations/delete", { organizationId: id }, null),
|
|
667
|
+
async check(q) {
|
|
668
|
+
const organizationId = typeof q.organization === "string" ? q.organization : q.organization?.id ?? "";
|
|
669
|
+
const r = await post("/me/organizations/check", {
|
|
670
|
+
organizationId,
|
|
671
|
+
resource: q.resource,
|
|
672
|
+
action: q.action,
|
|
673
|
+
...q.attributes !== void 0 ? { attributes: q.attributes } : {},
|
|
674
|
+
...q.resourceId !== void 0 ? { resourceId: q.resourceId } : {},
|
|
675
|
+
...q.ownerId !== void 0 ? { ownerId: q.ownerId } : {}
|
|
676
|
+
}, null);
|
|
677
|
+
if (!r.ok) return { allowed: false, reason: r.error.message, error: r.error };
|
|
678
|
+
return { allowed: r.allowed === true, reason: String(r.reason ?? ""), ...r.rule ? { rule: r.rule } : {} };
|
|
679
|
+
}
|
|
658
680
|
},
|
|
659
681
|
account: {
|
|
660
682
|
async get() {
|