@kyro-cms/core 0.9.4 → 0.9.6
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/api-handler-graphql.cjs +10 -10
- package/dist/api-handler-graphql.js +6 -6
- package/dist/api-handler-trpc.cjs +8 -8
- package/dist/api-handler-trpc.js +6 -6
- package/dist/api-handler.cjs +9 -9
- package/dist/api-handler.js +6 -6
- package/dist/{chunk-YFAVQQTU.js → chunk-AX2TZRQJ.js} +3 -3
- package/dist/{chunk-YFAVQQTU.js.map → chunk-AX2TZRQJ.js.map} +1 -1
- package/dist/{chunk-5H3MWQJS.js → chunk-CMXVTUYV.js} +12 -12
- package/dist/chunk-CMXVTUYV.js.map +1 -0
- package/dist/{chunk-E2763JUP.cjs → chunk-DRVOUQMT.cjs} +27 -27
- package/dist/chunk-DRVOUQMT.cjs.map +1 -0
- package/dist/{chunk-4M7X5HAB.cjs → chunk-FKKQUMXR.cjs} +109 -3
- package/dist/chunk-FKKQUMXR.cjs.map +1 -0
- package/dist/{chunk-PV2I2KMI.cjs → chunk-HVCUIII2.cjs} +21 -75
- package/dist/chunk-HVCUIII2.cjs.map +1 -0
- package/dist/{chunk-CJONKRHJ.js → chunk-NZEUU7QB.js} +108 -3
- package/dist/chunk-NZEUU7QB.js.map +1 -0
- package/dist/{chunk-NWUEVLQT.cjs → chunk-OZ3CCTTA.cjs} +5 -5
- package/dist/{chunk-NWUEVLQT.cjs.map → chunk-OZ3CCTTA.cjs.map} +1 -1
- package/dist/chunk-PONTBXR5.js +842 -0
- package/dist/chunk-PONTBXR5.js.map +1 -0
- package/dist/{chunk-CNKT4PME.cjs → chunk-QVJNSAQL.cjs} +71 -149
- package/dist/chunk-QVJNSAQL.cjs.map +1 -0
- package/dist/{chunk-OHC6UHFY.js → chunk-QX3WNQ7V.js} +18 -72
- package/dist/chunk-QX3WNQ7V.js.map +1 -0
- package/dist/chunk-RRKCIAPU.cjs +848 -0
- package/dist/chunk-RRKCIAPU.cjs.map +1 -0
- package/dist/{chunk-NI5D3F7H.cjs → chunk-U3VVLYXG.cjs} +55 -7
- package/dist/chunk-U3VVLYXG.cjs.map +1 -0
- package/dist/{chunk-IPTZM3VE.js → chunk-VLK5SJRI.js} +56 -134
- package/dist/chunk-VLK5SJRI.js.map +1 -0
- package/dist/{chunk-NFKRKH3P.js → chunk-X4BPPD6K.js} +52 -4
- package/dist/chunk-X4BPPD6K.js.map +1 -0
- package/dist/graphql/index.cjs +8 -4
- package/dist/graphql/index.d.cts +4 -1
- package/dist/graphql/index.d.ts +4 -1
- package/dist/graphql/index.js +2 -2
- package/dist/index.cjs +59 -59
- package/dist/index.js +7 -7
- package/dist/integration.cjs +2 -2
- package/dist/integration.js +1 -1
- package/dist/rest/index.cjs +4 -4
- package/dist/rest/index.js +2 -2
- package/dist/trpc/index.cjs +11 -11
- package/dist/trpc/index.js +2 -2
- package/package.json +2 -2
- package/dist/chunk-3HR772HI.cjs +0 -555
- package/dist/chunk-3HR772HI.cjs.map +0 -1
- package/dist/chunk-4M7X5HAB.cjs.map +0 -1
- package/dist/chunk-5H3MWQJS.js.map +0 -1
- package/dist/chunk-CJONKRHJ.js.map +0 -1
- package/dist/chunk-CNKT4PME.cjs.map +0 -1
- package/dist/chunk-E2763JUP.cjs.map +0 -1
- package/dist/chunk-IPTZM3VE.js.map +0 -1
- package/dist/chunk-L5UKKZQN.js +0 -552
- package/dist/chunk-L5UKKZQN.js.map +0 -1
- package/dist/chunk-NFKRKH3P.js.map +0 -1
- package/dist/chunk-NI5D3F7H.cjs.map +0 -1
- package/dist/chunk-OHC6UHFY.js.map +0 -1
- package/dist/chunk-PV2I2KMI.cjs.map +0 -1
|
@@ -3,7 +3,7 @@ import { usersCollection } from './chunk-XEB7PH2E.js';
|
|
|
3
3
|
import { SQLiteAuthAdapter } from './chunk-Q72BOAPK.js';
|
|
4
4
|
import { createAuditContext } from './chunk-P2YW545G.js';
|
|
5
5
|
import { WEBHOOK_EVENTS } from './chunk-3UK5XBVJ.js';
|
|
6
|
-
import { API_KEY_COLLECTION, generateApiKey, generateApiKeyPrefix,
|
|
6
|
+
import { API_KEY_COLLECTION, generateApiKey, generateApiKeyPrefix, checkCollectionAccess, checkGlobalAccess, extractApiKeyFromRequest, validateApiKey, createApiKeyContext } from './chunk-NZEUU7QB.js';
|
|
7
7
|
import { genId, DrizzleAdapter } from './chunk-V7KZQIZ6.js';
|
|
8
8
|
import { PostgresAuthAdapter } from './chunk-CJX74IYK.js';
|
|
9
9
|
import { MongoDBAdapter } from './chunk-PQ72Z6WC.js';
|
|
@@ -3535,105 +3535,27 @@ function buildConflictResponse(expectedUpdatedAt, currentDoc) {
|
|
|
3535
3535
|
}
|
|
3536
3536
|
};
|
|
3537
3537
|
}
|
|
3538
|
-
async function
|
|
3539
|
-
const
|
|
3540
|
-
|
|
3541
|
-
|
|
3542
|
-
|
|
3543
|
-
|
|
3544
|
-
|
|
3545
|
-
|
|
3546
|
-
|
|
3547
|
-
};
|
|
3548
|
-
|
|
3549
|
-
if (accessRule) {
|
|
3550
|
-
const allowed = await evaluateAccess(accessRule, {
|
|
3551
|
-
req,
|
|
3552
|
-
user: ctxUser,
|
|
3553
|
-
tenantID: ctxTenantID
|
|
3554
|
-
});
|
|
3555
|
-
if (allowed === false) {
|
|
3556
|
-
return { allowed: false, error: "Access denied", status: 403 };
|
|
3557
|
-
}
|
|
3558
|
-
} else if (!ctxUser) {
|
|
3559
|
-
const allowed = enablePublicAccess && isDefaultAllowed;
|
|
3560
|
-
if (!allowed) {
|
|
3561
|
-
return {
|
|
3562
|
-
allowed: false,
|
|
3563
|
-
error: "Authentication required",
|
|
3564
|
-
status: 401
|
|
3565
|
-
};
|
|
3566
|
-
}
|
|
3567
|
-
}
|
|
3568
|
-
if (apiKeyContext?.permissions?.length > 0) {
|
|
3569
|
-
const resource = collection.slug;
|
|
3570
|
-
const action = operation === "read" ? "read" : operation === "create" ? "create" : "update";
|
|
3571
|
-
const permission = `${resource}:${action}`;
|
|
3572
|
-
if (!hasApiKeyPermission(apiKeyContext.permissions, permission) && !hasApiKeyPermission(apiKeyContext.permissions, `${resource}:admin`)) {
|
|
3573
|
-
return {
|
|
3574
|
-
allowed: false,
|
|
3575
|
-
error: `Missing permission: ${permission}`,
|
|
3576
|
-
status: 403
|
|
3577
|
-
};
|
|
3578
|
-
}
|
|
3579
|
-
}
|
|
3580
|
-
if (ctxUser && !(apiKeyContext?.permissions?.length > 0)) {
|
|
3581
|
-
const resource = collection.slug;
|
|
3582
|
-
const action = operation === "read" ? "read" : operation === "create" ? "create" : operation === "update" ? "update" : "delete";
|
|
3583
|
-
const permission = `${resource}:${action}`;
|
|
3584
|
-
let rbacAllowed = false;
|
|
3585
|
-
if (ctxUser.role) {
|
|
3586
|
-
const userHasPermission = hasPermission(
|
|
3587
|
-
{ id: ctxUser.id, email: ctxUser.email, role: ctxUser.role },
|
|
3588
|
-
permission
|
|
3589
|
-
);
|
|
3590
|
-
if (userHasPermission) {
|
|
3591
|
-
rbacAllowed = true;
|
|
3592
|
-
} else {
|
|
3593
|
-
const adminPermission = hasPermission(
|
|
3594
|
-
{ id: ctxUser.id, email: ctxUser.email, role: ctxUser.role },
|
|
3595
|
-
`${resource}:admin`
|
|
3596
|
-
);
|
|
3597
|
-
if (adminPermission) rbacAllowed = true;
|
|
3598
|
-
}
|
|
3599
|
-
}
|
|
3600
|
-
if (!rbacAllowed && !isDefaultAllowed && !accessRule) {
|
|
3601
|
-
return {
|
|
3602
|
-
allowed: false,
|
|
3603
|
-
error: `Missing RBAC permission: ${permission}`,
|
|
3604
|
-
status: 403
|
|
3605
|
-
};
|
|
3606
|
-
}
|
|
3607
|
-
}
|
|
3608
|
-
return { allowed: true };
|
|
3538
|
+
async function checkCollectionAccess2(collection, operation, req, ctxUser, ctxTenantID, apiKeyContext, enablePublicAccess = true, defaultCollectionAccess = "none") {
|
|
3539
|
+
const result = await checkCollectionAccess(collection, operation, {
|
|
3540
|
+
user: ctxUser,
|
|
3541
|
+
req,
|
|
3542
|
+
tenantID: ctxTenantID,
|
|
3543
|
+
apiKey: apiKeyContext
|
|
3544
|
+
}, {
|
|
3545
|
+
enablePublicAccess,
|
|
3546
|
+
defaultAccess: defaultCollectionAccess
|
|
3547
|
+
});
|
|
3548
|
+
return result;
|
|
3609
3549
|
}
|
|
3610
|
-
async function
|
|
3611
|
-
const
|
|
3612
|
-
|
|
3613
|
-
|
|
3614
|
-
|
|
3615
|
-
|
|
3616
|
-
|
|
3617
|
-
|
|
3618
|
-
|
|
3619
|
-
return { allowed: false, error: "Access denied", status: 403 };
|
|
3620
|
-
}
|
|
3621
|
-
} else if (!ctxUser) {
|
|
3622
|
-
const accessLevels = {
|
|
3623
|
-
none: false,
|
|
3624
|
-
read: operation === "read",
|
|
3625
|
-
update: operation === "read" || operation === "update"
|
|
3626
|
-
};
|
|
3627
|
-
const allowed = enablePublicAccess && accessLevels[operation === "read" ? "read" : "admin"];
|
|
3628
|
-
if (!allowed) {
|
|
3629
|
-
return {
|
|
3630
|
-
allowed: false,
|
|
3631
|
-
error: "Authentication required",
|
|
3632
|
-
status: 401
|
|
3633
|
-
};
|
|
3634
|
-
}
|
|
3635
|
-
}
|
|
3636
|
-
return { allowed: true };
|
|
3550
|
+
async function checkGlobalAccess2(global, operation, req, ctxUser, ctxTenantID, enablePublicAccess = true) {
|
|
3551
|
+
const result = await checkGlobalAccess(global, operation, {
|
|
3552
|
+
user: ctxUser,
|
|
3553
|
+
req,
|
|
3554
|
+
tenantID: ctxTenantID
|
|
3555
|
+
}, {
|
|
3556
|
+
enablePublicAccess
|
|
3557
|
+
});
|
|
3558
|
+
return result;
|
|
3637
3559
|
}
|
|
3638
3560
|
async function resolveAuthContext(req, authMw, staticUser, staticTenantID) {
|
|
3639
3561
|
if (staticUser) {
|
|
@@ -3805,7 +3727,7 @@ function createHonoApp(options) {
|
|
|
3805
3727
|
const globals = {};
|
|
3806
3728
|
for (const col of registry.getCollections()) {
|
|
3807
3729
|
const permissions = {
|
|
3808
|
-
read: (await
|
|
3730
|
+
read: (await checkCollectionAccess2(
|
|
3809
3731
|
col,
|
|
3810
3732
|
"read",
|
|
3811
3733
|
c.req.raw,
|
|
@@ -3815,7 +3737,7 @@ function createHonoApp(options) {
|
|
|
3815
3737
|
enablePublicAccess,
|
|
3816
3738
|
defaultCollectionAccess
|
|
3817
3739
|
)).allowed,
|
|
3818
|
-
create: (await
|
|
3740
|
+
create: (await checkCollectionAccess2(
|
|
3819
3741
|
col,
|
|
3820
3742
|
"create",
|
|
3821
3743
|
c.req.raw,
|
|
@@ -3825,7 +3747,7 @@ function createHonoApp(options) {
|
|
|
3825
3747
|
enablePublicAccess,
|
|
3826
3748
|
defaultCollectionAccess
|
|
3827
3749
|
)).allowed,
|
|
3828
|
-
update: (await
|
|
3750
|
+
update: (await checkCollectionAccess2(
|
|
3829
3751
|
col,
|
|
3830
3752
|
"update",
|
|
3831
3753
|
c.req.raw,
|
|
@@ -3835,7 +3757,7 @@ function createHonoApp(options) {
|
|
|
3835
3757
|
enablePublicAccess,
|
|
3836
3758
|
defaultCollectionAccess
|
|
3837
3759
|
)).allowed,
|
|
3838
|
-
delete: (await
|
|
3760
|
+
delete: (await checkCollectionAccess2(
|
|
3839
3761
|
col,
|
|
3840
3762
|
"delete",
|
|
3841
3763
|
c.req.raw,
|
|
@@ -3850,7 +3772,7 @@ function createHonoApp(options) {
|
|
|
3850
3772
|
}
|
|
3851
3773
|
for (const globalConfig of registry.getGlobals()) {
|
|
3852
3774
|
const permissions = {
|
|
3853
|
-
read: (await
|
|
3775
|
+
read: (await checkGlobalAccess2(
|
|
3854
3776
|
globalConfig,
|
|
3855
3777
|
"read",
|
|
3856
3778
|
c.req.raw,
|
|
@@ -3858,7 +3780,7 @@ function createHonoApp(options) {
|
|
|
3858
3780
|
ctxTenantID,
|
|
3859
3781
|
enablePublicAccess
|
|
3860
3782
|
)).allowed,
|
|
3861
|
-
update: (await
|
|
3783
|
+
update: (await checkGlobalAccess2(
|
|
3862
3784
|
globalConfig,
|
|
3863
3785
|
"update",
|
|
3864
3786
|
c.req.raw,
|
|
@@ -3889,7 +3811,7 @@ function createHonoApp(options) {
|
|
|
3889
3811
|
user,
|
|
3890
3812
|
tenantID
|
|
3891
3813
|
);
|
|
3892
|
-
const access = await
|
|
3814
|
+
const access = await checkCollectionAccess2(
|
|
3893
3815
|
usersCollection2,
|
|
3894
3816
|
"read",
|
|
3895
3817
|
c.req.raw,
|
|
@@ -3953,7 +3875,7 @@ function createHonoApp(options) {
|
|
|
3953
3875
|
user,
|
|
3954
3876
|
tenantID
|
|
3955
3877
|
);
|
|
3956
|
-
const access = await
|
|
3878
|
+
const access = await checkCollectionAccess2(
|
|
3957
3879
|
usersCollection2,
|
|
3958
3880
|
"create",
|
|
3959
3881
|
c.req.raw,
|
|
@@ -4007,7 +3929,7 @@ function createHonoApp(options) {
|
|
|
4007
3929
|
user,
|
|
4008
3930
|
tenantID
|
|
4009
3931
|
);
|
|
4010
|
-
const access = await
|
|
3932
|
+
const access = await checkCollectionAccess2(
|
|
4011
3933
|
usersCollection2,
|
|
4012
3934
|
"update",
|
|
4013
3935
|
c.req.raw,
|
|
@@ -4076,7 +3998,7 @@ function createHonoApp(options) {
|
|
|
4076
3998
|
user,
|
|
4077
3999
|
tenantID
|
|
4078
4000
|
);
|
|
4079
|
-
const access = await
|
|
4001
|
+
const access = await checkCollectionAccess2(
|
|
4080
4002
|
usersCollection2,
|
|
4081
4003
|
"delete",
|
|
4082
4004
|
c.req.raw,
|
|
@@ -4125,7 +4047,7 @@ function createHonoApp(options) {
|
|
|
4125
4047
|
);
|
|
4126
4048
|
const auditLogsCollection = registry.getCollection("audit_logs");
|
|
4127
4049
|
if (auditLogsCollection) {
|
|
4128
|
-
const access = await
|
|
4050
|
+
const access = await checkCollectionAccess2(
|
|
4129
4051
|
auditLogsCollection,
|
|
4130
4052
|
"read",
|
|
4131
4053
|
c.req.raw,
|
|
@@ -4800,7 +4722,7 @@ function createHonoApp(options) {
|
|
|
4800
4722
|
);
|
|
4801
4723
|
for (const collection of registry.getCollections()) {
|
|
4802
4724
|
if (!targetCollections.includes(collection.slug)) continue;
|
|
4803
|
-
const access = await
|
|
4725
|
+
const access = await checkCollectionAccess2(
|
|
4804
4726
|
collection,
|
|
4805
4727
|
"read",
|
|
4806
4728
|
c.req.raw,
|
|
@@ -5159,7 +5081,7 @@ function createHonoApp(options) {
|
|
|
5159
5081
|
tenantID: ctxTenantID,
|
|
5160
5082
|
apiKeyContext
|
|
5161
5083
|
} = await resolveAuthContext(c.req.raw, authMw, user, tenantID);
|
|
5162
|
-
const access = await
|
|
5084
|
+
const access = await checkCollectionAccess2(
|
|
5163
5085
|
collection,
|
|
5164
5086
|
"read",
|
|
5165
5087
|
c.req.raw,
|
|
@@ -5207,7 +5129,7 @@ function createHonoApp(options) {
|
|
|
5207
5129
|
tenantID: ctxTenantID,
|
|
5208
5130
|
apiKeyContext
|
|
5209
5131
|
} = await resolveAuthContext(c.req.raw, authMw, user, tenantID);
|
|
5210
|
-
const access = await
|
|
5132
|
+
const access = await checkCollectionAccess2(
|
|
5211
5133
|
collection,
|
|
5212
5134
|
"read",
|
|
5213
5135
|
c.req.raw,
|
|
@@ -5261,7 +5183,7 @@ function createHonoApp(options) {
|
|
|
5261
5183
|
tenantID: ctxTenantID,
|
|
5262
5184
|
apiKeyContext
|
|
5263
5185
|
} = await resolveAuthContext(c.req.raw, authMw, user, tenantID);
|
|
5264
|
-
const access = await
|
|
5186
|
+
const access = await checkCollectionAccess2(
|
|
5265
5187
|
collection,
|
|
5266
5188
|
"update",
|
|
5267
5189
|
c.req.raw,
|
|
@@ -5321,7 +5243,7 @@ function createHonoApp(options) {
|
|
|
5321
5243
|
tenantID: ctxTenantID,
|
|
5322
5244
|
apiKeyContext
|
|
5323
5245
|
} = await resolveAuthContext(c.req.raw, authMw, user, tenantID);
|
|
5324
|
-
const access = await
|
|
5246
|
+
const access = await checkCollectionAccess2(
|
|
5325
5247
|
collection,
|
|
5326
5248
|
"update",
|
|
5327
5249
|
c.req.raw,
|
|
@@ -5356,7 +5278,7 @@ function createHonoApp(options) {
|
|
|
5356
5278
|
tenantID: ctxTenantID,
|
|
5357
5279
|
apiKeyContext
|
|
5358
5280
|
} = await resolveAuthContext(c.req.raw, authMw, user, tenantID);
|
|
5359
|
-
const access = await
|
|
5281
|
+
const access = await checkCollectionAccess2(
|
|
5360
5282
|
collection,
|
|
5361
5283
|
"read",
|
|
5362
5284
|
c.req.raw,
|
|
@@ -5406,7 +5328,7 @@ function createHonoApp(options) {
|
|
|
5406
5328
|
tenantID: ctxTenantID,
|
|
5407
5329
|
apiKeyContext
|
|
5408
5330
|
} = await resolveAuthContext(c.req.raw, authMw, user, tenantID);
|
|
5409
|
-
const access = await
|
|
5331
|
+
const access = await checkCollectionAccess2(
|
|
5410
5332
|
collection,
|
|
5411
5333
|
"create",
|
|
5412
5334
|
c.req.raw,
|
|
@@ -5530,7 +5452,7 @@ function createHonoApp(options) {
|
|
|
5530
5452
|
tenantID: ctxTenantID,
|
|
5531
5453
|
apiKeyContext
|
|
5532
5454
|
} = await resolveAuthContext(c.req.raw, authMw, user, tenantID);
|
|
5533
|
-
const access = await
|
|
5455
|
+
const access = await checkCollectionAccess2(
|
|
5534
5456
|
collection,
|
|
5535
5457
|
"update",
|
|
5536
5458
|
c.req.raw,
|
|
@@ -5695,7 +5617,7 @@ function createHonoApp(options) {
|
|
|
5695
5617
|
tenantID: ctxTenantID,
|
|
5696
5618
|
apiKeyContext
|
|
5697
5619
|
} = await resolveAuthContext(c.req.raw, authMw, user, tenantID);
|
|
5698
|
-
const access = await
|
|
5620
|
+
const access = await checkCollectionAccess2(
|
|
5699
5621
|
collection,
|
|
5700
5622
|
"delete",
|
|
5701
5623
|
c.req.raw,
|
|
@@ -5785,7 +5707,7 @@ function createHonoApp(options) {
|
|
|
5785
5707
|
tenantID: ctxTenantID,
|
|
5786
5708
|
apiKeyContext
|
|
5787
5709
|
} = await resolveAuthContext(c.req.raw, authMw, user, tenantID);
|
|
5788
|
-
const access = await
|
|
5710
|
+
const access = await checkCollectionAccess2(
|
|
5789
5711
|
collection,
|
|
5790
5712
|
"create",
|
|
5791
5713
|
c.req.raw,
|
|
@@ -5833,7 +5755,7 @@ function createHonoApp(options) {
|
|
|
5833
5755
|
tenantID: ctxTenantID,
|
|
5834
5756
|
apiKeyContext
|
|
5835
5757
|
} = await resolveAuthContext(c.req.raw, authMw, user, tenantID);
|
|
5836
|
-
const access = await
|
|
5758
|
+
const access = await checkCollectionAccess2(
|
|
5837
5759
|
collection,
|
|
5838
5760
|
"update",
|
|
5839
5761
|
c.req.raw,
|
|
@@ -5877,7 +5799,7 @@ function createHonoApp(options) {
|
|
|
5877
5799
|
tenantID: ctxTenantID,
|
|
5878
5800
|
apiKeyContext
|
|
5879
5801
|
} = await resolveAuthContext(c.req.raw, authMw, user, tenantID);
|
|
5880
|
-
const access = await
|
|
5802
|
+
const access = await checkCollectionAccess2(
|
|
5881
5803
|
collection,
|
|
5882
5804
|
"update",
|
|
5883
5805
|
c.req.raw,
|
|
@@ -5924,7 +5846,7 @@ function createHonoApp(options) {
|
|
|
5924
5846
|
tenantID: ctxTenantID,
|
|
5925
5847
|
apiKeyContext
|
|
5926
5848
|
} = await resolveAuthContext(c.req.raw, authMw, user, tenantID);
|
|
5927
|
-
const access = await
|
|
5849
|
+
const access = await checkCollectionAccess2(
|
|
5928
5850
|
collection,
|
|
5929
5851
|
"update",
|
|
5930
5852
|
c.req.raw,
|
|
@@ -6009,7 +5931,7 @@ function createHonoApp(options) {
|
|
|
6009
5931
|
tenantID: ctxTenantID,
|
|
6010
5932
|
apiKeyContext
|
|
6011
5933
|
} = await resolveAuthContext(c.req.raw, authMw, user, tenantID);
|
|
6012
|
-
const access = await
|
|
5934
|
+
const access = await checkCollectionAccess2(
|
|
6013
5935
|
collection,
|
|
6014
5936
|
"update",
|
|
6015
5937
|
c.req.raw,
|
|
@@ -6059,7 +5981,7 @@ function createHonoApp(options) {
|
|
|
6059
5981
|
app.get(basePath, async (c) => {
|
|
6060
5982
|
try {
|
|
6061
5983
|
const { user: ctxUser, tenantID: ctxTenantID } = await resolveAuthContext(c.req.raw, authMw, user, tenantID);
|
|
6062
|
-
const access = await
|
|
5984
|
+
const access = await checkGlobalAccess2(
|
|
6063
5985
|
globalConfig,
|
|
6064
5986
|
"read",
|
|
6065
5987
|
c.req.raw,
|
|
@@ -6103,7 +6025,7 @@ function createHonoApp(options) {
|
|
|
6103
6025
|
const upsertGlobal = async (c) => {
|
|
6104
6026
|
try {
|
|
6105
6027
|
const { user: ctxUser, tenantID: ctxTenantID } = await resolveAuthContext(c.req.raw, authMw, user, tenantID);
|
|
6106
|
-
const access = await
|
|
6028
|
+
const access = await checkGlobalAccess2(
|
|
6107
6029
|
globalConfig,
|
|
6108
6030
|
"update",
|
|
6109
6031
|
c.req.raw,
|
|
@@ -6238,7 +6160,7 @@ function createHonoApp(options) {
|
|
|
6238
6160
|
app.post(`${basePath}/publish`, async (c) => {
|
|
6239
6161
|
try {
|
|
6240
6162
|
const { user: ctxUser, tenantID: ctxTenantID } = await resolveAuthContext(c.req.raw, authMw, user, tenantID);
|
|
6241
|
-
const access = await
|
|
6163
|
+
const access = await checkGlobalAccess2(globalConfig, "update", c.req.raw, ctxUser, ctxTenantID, enablePublicAccess);
|
|
6242
6164
|
if (!access.allowed) return c.json({ error: access.error }, 403);
|
|
6243
6165
|
const collectionSlug = `_globals_${slug}`;
|
|
6244
6166
|
const originalDoc = await db.findOne({
|
|
@@ -6288,7 +6210,7 @@ function createHonoApp(options) {
|
|
|
6288
6210
|
app.post(`${basePath}/unpublish`, async (c) => {
|
|
6289
6211
|
try {
|
|
6290
6212
|
const { user: ctxUser, tenantID: ctxTenantID } = await resolveAuthContext(c.req.raw, authMw, user, tenantID);
|
|
6291
|
-
const access = await
|
|
6213
|
+
const access = await checkGlobalAccess2(globalConfig, "update", c.req.raw, ctxUser, ctxTenantID, enablePublicAccess);
|
|
6292
6214
|
if (!access.allowed) return c.json({ error: access.error }, 403);
|
|
6293
6215
|
const doc = await db.update({
|
|
6294
6216
|
collection: `_globals_${slug}`,
|
|
@@ -6304,7 +6226,7 @@ function createHonoApp(options) {
|
|
|
6304
6226
|
app.get(`${basePath}/versions`, async (c) => {
|
|
6305
6227
|
try {
|
|
6306
6228
|
const { user: ctxUser, tenantID: ctxTenantID } = await resolveAuthContext(c.req.raw, authMw, user, tenantID);
|
|
6307
|
-
const access = await
|
|
6229
|
+
const access = await checkGlobalAccess2(globalConfig, "read", c.req.raw, ctxUser, ctxTenantID, enablePublicAccess);
|
|
6308
6230
|
if (!access.allowed) return c.json({ error: access.error }, 403);
|
|
6309
6231
|
const limit = parseInt(c.req.query("limit") || "10");
|
|
6310
6232
|
const page = parseInt(c.req.query("page") || "1");
|
|
@@ -6324,7 +6246,7 @@ function createHonoApp(options) {
|
|
|
6324
6246
|
try {
|
|
6325
6247
|
const versionId = c.req.param("versionId");
|
|
6326
6248
|
const { user: ctxUser, tenantID: ctxTenantID } = await resolveAuthContext(c.req.raw, authMw, user, tenantID);
|
|
6327
|
-
const access = await
|
|
6249
|
+
const access = await checkGlobalAccess2(globalConfig, "read", c.req.raw, ctxUser, ctxTenantID, enablePublicAccess);
|
|
6328
6250
|
if (!access.allowed) return c.json({ error: access.error }, 403);
|
|
6329
6251
|
const version = await db.findVersionByID({
|
|
6330
6252
|
collection: `_globals_${slug}`,
|
|
@@ -6341,7 +6263,7 @@ function createHonoApp(options) {
|
|
|
6341
6263
|
try {
|
|
6342
6264
|
const versionId = c.req.param("versionId");
|
|
6343
6265
|
const { user: ctxUser, tenantID: ctxTenantID } = await resolveAuthContext(c.req.raw, authMw, user, tenantID);
|
|
6344
|
-
const access = await
|
|
6266
|
+
const access = await checkGlobalAccess2(globalConfig, "update", c.req.raw, ctxUser, ctxTenantID, enablePublicAccess);
|
|
6345
6267
|
if (!access.allowed) return c.json({ error: access.error }, 403);
|
|
6346
6268
|
const collectionSlug = `_globals_${slug}`;
|
|
6347
6269
|
const version = await db.findVersionByID({
|
|
@@ -6369,7 +6291,7 @@ function createHonoApp(options) {
|
|
|
6369
6291
|
app.post(`${basePath}/test`, async (c) => {
|
|
6370
6292
|
try {
|
|
6371
6293
|
const { user: ctxUser, tenantID: ctxTenantID } = await resolveAuthContext(c.req.raw, authMw, user, tenantID);
|
|
6372
|
-
const access = await
|
|
6294
|
+
const access = await checkGlobalAccess2(
|
|
6373
6295
|
globalConfig,
|
|
6374
6296
|
"update",
|
|
6375
6297
|
c.req.raw,
|
|
@@ -6462,5 +6384,5 @@ function createRESTAPI(registry, db, options) {
|
|
|
6462
6384
|
}
|
|
6463
6385
|
|
|
6464
6386
|
export { AuditLogger, AuthRoutes, InMemoryAuditLogger, InMemoryRateLimiter, MediaService, createAuditContext2 as createAuditContext, createCloudinaryStorage, createFtpStorage, createHonoApp, createLocalStorage, createRESTAPI, createS3Storage, getAppSecret, getDefaultRegistry, getEncryptionKey, getSessionConfig, init_secret, loadSecrets, resolveProvider, setDbAdapter };
|
|
6465
|
-
//# sourceMappingURL=chunk-
|
|
6466
|
-
//# sourceMappingURL=chunk-
|
|
6387
|
+
//# sourceMappingURL=chunk-VLK5SJRI.js.map
|
|
6388
|
+
//# sourceMappingURL=chunk-VLK5SJRI.js.map
|