@keystrokehq/platform 0.0.146 → 0.0.147
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/run.cjs +1 -1
- package/dist/run.mjs +1 -1
- package/dist/{start-Btbz1V6t.cjs → start-BHOssHdU.cjs} +28 -15
- package/dist/start-BHOssHdU.cjs.map +1 -0
- package/dist/{start-DtoXNgY3.mjs → start-C-an8T-8.mjs} +28 -15
- package/dist/start-C-an8T-8.mjs.map +1 -0
- package/dist/start.cjs +1 -1
- package/dist/start.mjs +1 -1
- package/package.json +1 -1
- package/dist/start-Btbz1V6t.cjs.map +0 -1
- package/dist/start-DtoXNgY3.mjs.map +0 -1
package/dist/run.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const require_config = require("./config.cjs");
|
|
2
|
-
const require_start = require("./start-
|
|
2
|
+
const require_start = require("./start-BHOssHdU.cjs");
|
|
3
3
|
//#region src/run.ts
|
|
4
4
|
async function main() {
|
|
5
5
|
await require_start.startPlatformServer(require_config.definePlatformConfig());
|
package/dist/run.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { definePlatformConfig } from "./config.mjs";
|
|
2
|
-
import { t as startPlatformServer } from "./start-
|
|
2
|
+
import { t as startPlatformServer } from "./start-C-an8T-8.mjs";
|
|
3
3
|
//#region src/run.ts
|
|
4
4
|
async function main() {
|
|
5
5
|
await startPlatformServer(definePlatformConfig());
|
|
@@ -1710,13 +1710,25 @@ const organizationRoleGrants = {
|
|
|
1710
1710
|
admin: [organizationActions.update],
|
|
1711
1711
|
builder: []
|
|
1712
1712
|
};
|
|
1713
|
-
const userActions = {
|
|
1714
|
-
|
|
1713
|
+
const userActions = {
|
|
1714
|
+
manage: "users:manage",
|
|
1715
|
+
invite: "users:invite"
|
|
1716
|
+
};
|
|
1717
|
+
const userGrants = [userActions.manage, userActions.invite];
|
|
1715
1718
|
const userRoleGrants = {
|
|
1716
|
-
owner: [userActions.manage],
|
|
1717
|
-
admin: [userActions.manage],
|
|
1718
|
-
builder: []
|
|
1719
|
+
owner: [userActions.manage, userActions.invite],
|
|
1720
|
+
admin: [userActions.manage, userActions.invite],
|
|
1721
|
+
builder: [userActions.invite]
|
|
1722
|
+
};
|
|
1723
|
+
/** Role ceiling: which roles each inviter may grant. Owner is never invitable (shared schema). */
|
|
1724
|
+
const invitableRolesByRole = {
|
|
1725
|
+
owner: ["admin", "builder"],
|
|
1726
|
+
admin: ["admin", "builder"],
|
|
1727
|
+
builder: ["builder"]
|
|
1719
1728
|
};
|
|
1729
|
+
function canInviteRole(inviter, invited) {
|
|
1730
|
+
return invitableRolesByRole[inviter].includes(invited);
|
|
1731
|
+
}
|
|
1720
1732
|
[...organizationGrants, ...userGrants];
|
|
1721
1733
|
function mergeRoleGrants(role) {
|
|
1722
1734
|
return [...organizationRoleGrants[role], ...userRoleGrants[role]];
|
|
@@ -1739,12 +1751,11 @@ function authorize(action) {
|
|
|
1739
1751
|
};
|
|
1740
1752
|
}
|
|
1741
1753
|
//#endregion
|
|
1742
|
-
//#region src/auth/
|
|
1743
|
-
|
|
1744
|
-
function requireOrgAdmin() {
|
|
1754
|
+
//#region src/auth/authorize-payload.ts
|
|
1755
|
+
function authorizePayload(schema, allow) {
|
|
1745
1756
|
return async (c, next) => {
|
|
1746
|
-
const
|
|
1747
|
-
if (!
|
|
1757
|
+
const parsed = schema.safeParse(await c.req.json().catch(() => null));
|
|
1758
|
+
if (parsed.success && !allow({ orgRole: c.get("organization").role }, parsed.data)) return c.json(require_dist.ErrorResponseSchema.parse({ error: "Forbidden" }), 403);
|
|
1748
1759
|
await next();
|
|
1749
1760
|
};
|
|
1750
1761
|
}
|
|
@@ -2946,8 +2957,10 @@ function mountAccountRoutes(options) {
|
|
|
2946
2957
|
orgScoped.use("/*", requireOrganization());
|
|
2947
2958
|
projectScoped.use("/*", protect);
|
|
2948
2959
|
projectScoped.use("/*", requireOrganization());
|
|
2949
|
-
const orgAdmin = requireOrgAdmin();
|
|
2950
2960
|
const requireOrgUpdate = authorize(organizationActions.update);
|
|
2961
|
+
const requireUserManage = authorize(userActions.manage);
|
|
2962
|
+
const requireUserInvite = authorize(userActions.invite);
|
|
2963
|
+
const requireInvitableRole = authorizePayload(require_dist.InviteOrganizationMembersRequestSchema, (ctx, body) => canInviteRole(ctx.orgRole, body.role));
|
|
2951
2964
|
const requireOrgParam = requireOrganizationParam();
|
|
2952
2965
|
account.get("/organizations", handler$37);
|
|
2953
2966
|
account.get("/organizations/slug-available", handler$36);
|
|
@@ -2966,9 +2979,9 @@ function mountAccountRoutes(options) {
|
|
|
2966
2979
|
account.get("/users/me/preferences", handler$39);
|
|
2967
2980
|
account.patch("/users/me/preferences", handler$38);
|
|
2968
2981
|
orgScoped.get("/members", handler$6);
|
|
2969
|
-
orgScoped.post("/members/invitations",
|
|
2970
|
-
orgScoped.patch("/members/:userId",
|
|
2971
|
-
orgScoped.delete("/members/:userId",
|
|
2982
|
+
orgScoped.post("/members/invitations", requireUserInvite, requireInvitableRole, handler$5);
|
|
2983
|
+
orgScoped.patch("/members/:userId", requireUserManage, handler$4);
|
|
2984
|
+
orgScoped.delete("/members/:userId", requireUserManage, handler$3);
|
|
2972
2985
|
const withOrgDb = withOrganizationProjectDatabase();
|
|
2973
2986
|
orgScoped.get("/agents", withOrgDb, handler$27);
|
|
2974
2987
|
orgScoped.get("/agents/:agentId", withOrgDb, handler$26);
|
|
@@ -3967,4 +3980,4 @@ Object.defineProperty(exports, "startPlatformServer", {
|
|
|
3967
3980
|
}
|
|
3968
3981
|
});
|
|
3969
3982
|
|
|
3970
|
-
//# sourceMappingURL=start-
|
|
3983
|
+
//# sourceMappingURL=start-BHOssHdU.cjs.map
|