@infuro/cms-core 1.0.11 → 1.0.12
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/admin.cjs +14 -7
- package/dist/admin.cjs.map +1 -1
- package/dist/admin.js +17 -10
- package/dist/admin.js.map +1 -1
- package/dist/api.cjs +29 -2
- package/dist/api.cjs.map +1 -1
- package/dist/api.d.cts +1 -1
- package/dist/api.d.ts +1 -1
- package/dist/api.js +27 -1
- package/dist/api.js.map +1 -1
- package/dist/{index-DeO4AnAj.d.ts → index-C4Yl7js9.d.ts} +8 -1
- package/dist/{index-C_CZLmHD.d.cts → index-JrST6EIC.d.cts} +8 -1
- package/dist/index.cjs +27 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +26 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -265,6 +265,13 @@ interface SettingsApiConfig extends CmsHandlersBase {
|
|
|
265
265
|
/** Groups in this list are readable without auth (GET returns all keys for the group). */
|
|
266
266
|
publicGetGroups?: string[];
|
|
267
267
|
}
|
|
268
|
+
interface GetPublicSettingsGroupConfig {
|
|
269
|
+
dataSource: DataSource;
|
|
270
|
+
entityMap: EntityMap;
|
|
271
|
+
encryptionKey?: string;
|
|
272
|
+
}
|
|
273
|
+
/** Same rows as unauthenticated GET /api/settings/:group when the group is in publicGetGroups. */
|
|
274
|
+
declare function getPublicSettingsGroup(config: GetPublicSettingsGroupConfig, group: string): Promise<Record<string, string>>;
|
|
268
275
|
declare function createSettingsApiHandlers(config: SettingsApiConfig): {
|
|
269
276
|
GET(req: Request, group: string): Promise<Response>;
|
|
270
277
|
PUT(req: Request, group: string): Promise<Response>;
|
|
@@ -359,4 +366,4 @@ declare function createStorefrontApiHandler(config: StorefrontApiConfig): {
|
|
|
359
366
|
handle(method: string, path: string[], req: Request): Promise<Response>;
|
|
360
367
|
};
|
|
361
368
|
|
|
362
|
-
export { type AnalyticsHandlerConfig as A, type BlogBySlugConfig as B, type CompanyDetails as C, type DashboardStatsConfig as D, type EmailTemplateResult as E, type ForgotPasswordConfig as F,
|
|
369
|
+
export { type AnalyticsHandlerConfig as A, type BlogBySlugConfig as B, type CompanyDetails as C, type DashboardStatsConfig as D, type EmailTemplateResult as E, type ForgotPasswordConfig as F, type GetPublicSettingsGroupConfig as G, createSetPasswordHandler as H, type InviteAcceptConfig as I, createSettingsApiHandlers as J, createStorefrontApiHandler as K, createUploadHandler as L, createUserAuthApiRouter as M, createUserAvatarHandler as N, type OrderPlacedLineItem as O, createUserProfileHandler as P, createUsersApiHandlers as Q, getCompanyDetailsFromSettings as R, type StorageService as S, type TemplateContext as T, type UploadHandlerConfig as U, getPublicSettingsGroup as V, mergeEmailLayoutCompanyDetails as W, type EmailTemplateName as a, type AuthHandlersConfig as b, type ChangePasswordConfig as c, type CmsApiHandlerConfig as d, type CmsGetter as e, type CrudHandlerOptions as f, type EntityMap as g, type FormBySlugConfig as h, type SetPasswordConfig as i, type SettingsApiConfig as j, type SocialLinkItem as k, type StorefrontApiConfig as l, type UserAuthApiConfig as m, type UserAvatarConfig as n, type UserProfileConfig as o, type UsersApiConfig as p, createAnalyticsHandlers as q, createBlogBySlugHandler as r, createChangePasswordHandler as s, createCmsApiHandler as t, createCrudByIdHandler as u, createCrudHandler as v, createDashboardStatsHandler as w, createForgotPasswordHandler as x, createFormBySlugHandler as y, createInviteAcceptHandler as z };
|
|
@@ -265,6 +265,13 @@ interface SettingsApiConfig extends CmsHandlersBase {
|
|
|
265
265
|
/** Groups in this list are readable without auth (GET returns all keys for the group). */
|
|
266
266
|
publicGetGroups?: string[];
|
|
267
267
|
}
|
|
268
|
+
interface GetPublicSettingsGroupConfig {
|
|
269
|
+
dataSource: DataSource;
|
|
270
|
+
entityMap: EntityMap;
|
|
271
|
+
encryptionKey?: string;
|
|
272
|
+
}
|
|
273
|
+
/** Same rows as unauthenticated GET /api/settings/:group when the group is in publicGetGroups. */
|
|
274
|
+
declare function getPublicSettingsGroup(config: GetPublicSettingsGroupConfig, group: string): Promise<Record<string, string>>;
|
|
268
275
|
declare function createSettingsApiHandlers(config: SettingsApiConfig): {
|
|
269
276
|
GET(req: Request, group: string): Promise<Response>;
|
|
270
277
|
PUT(req: Request, group: string): Promise<Response>;
|
|
@@ -359,4 +366,4 @@ declare function createStorefrontApiHandler(config: StorefrontApiConfig): {
|
|
|
359
366
|
handle(method: string, path: string[], req: Request): Promise<Response>;
|
|
360
367
|
};
|
|
361
368
|
|
|
362
|
-
export { type AnalyticsHandlerConfig as A, type BlogBySlugConfig as B, type CompanyDetails as C, type DashboardStatsConfig as D, type EmailTemplateResult as E, type ForgotPasswordConfig as F,
|
|
369
|
+
export { type AnalyticsHandlerConfig as A, type BlogBySlugConfig as B, type CompanyDetails as C, type DashboardStatsConfig as D, type EmailTemplateResult as E, type ForgotPasswordConfig as F, type GetPublicSettingsGroupConfig as G, createSetPasswordHandler as H, type InviteAcceptConfig as I, createSettingsApiHandlers as J, createStorefrontApiHandler as K, createUploadHandler as L, createUserAuthApiRouter as M, createUserAvatarHandler as N, type OrderPlacedLineItem as O, createUserProfileHandler as P, createUsersApiHandlers as Q, getCompanyDetailsFromSettings as R, type StorageService as S, type TemplateContext as T, type UploadHandlerConfig as U, getPublicSettingsGroup as V, mergeEmailLayoutCompanyDetails as W, type EmailTemplateName as a, type AuthHandlersConfig as b, type ChangePasswordConfig as c, type CmsApiHandlerConfig as d, type CmsGetter as e, type CrudHandlerOptions as f, type EntityMap as g, type FormBySlugConfig as h, type SetPasswordConfig as i, type SettingsApiConfig as j, type SocialLinkItem as k, type StorefrontApiConfig as l, type UserAuthApiConfig as m, type UserAvatarConfig as n, type UserProfileConfig as o, type UsersApiConfig as p, createAnalyticsHandlers as q, createBlogBySlugHandler as r, createChangePasswordHandler as s, createCmsApiHandler as t, createCrudByIdHandler as u, createCrudHandler as v, createDashboardStatsHandler as w, createForgotPasswordHandler as x, createFormBySlugHandler as y, createInviteAcceptHandler as z };
|
package/dist/index.cjs
CHANGED
|
@@ -316,6 +316,7 @@ __export(src_exports, {
|
|
|
316
316
|
getCompanyDetailsFromSettings: () => getCompanyDetailsFromSettings,
|
|
317
317
|
getNextAuthOptions: () => getNextAuthOptions,
|
|
318
318
|
getPermissionableEntityKeys: () => getPermissionableEntityKeys,
|
|
319
|
+
getPublicSettingsGroup: () => getPublicSettingsGroup,
|
|
319
320
|
getRequiredPermission: () => getRequiredPermission,
|
|
320
321
|
hasEntityPermission: () => hasEntityPermission,
|
|
321
322
|
isOpenEndpoint: () => isOpenEndpoint,
|
|
@@ -5798,6 +5799,24 @@ function simpleDecrypt(encoded, key) {
|
|
|
5798
5799
|
for (let i = 0; i < buf.length; i++) out[i] = buf[i] ^ keyBuf[i % keyBuf.length];
|
|
5799
5800
|
return out.toString("utf8");
|
|
5800
5801
|
}
|
|
5802
|
+
async function getPublicSettingsGroup(config, group) {
|
|
5803
|
+
const { dataSource, entityMap, encryptionKey } = config;
|
|
5804
|
+
const repo = dataSource.getRepository(entityMap.configs);
|
|
5805
|
+
const rows = await repo.find({ where: { settings: group, deleted: false } });
|
|
5806
|
+
const result = {};
|
|
5807
|
+
for (const row of rows) {
|
|
5808
|
+
const r = row;
|
|
5809
|
+
let val = r.value;
|
|
5810
|
+
if (r.encrypted && encryptionKey) {
|
|
5811
|
+
try {
|
|
5812
|
+
val = simpleDecrypt(val, encryptionKey);
|
|
5813
|
+
} catch {
|
|
5814
|
+
}
|
|
5815
|
+
}
|
|
5816
|
+
result[r.key] = val;
|
|
5817
|
+
}
|
|
5818
|
+
return result;
|
|
5819
|
+
}
|
|
5801
5820
|
function createSettingsApiHandlers(config) {
|
|
5802
5821
|
const { dataSource, entityMap, json, requireAuth, encryptionKey, publicGetGroups } = config;
|
|
5803
5822
|
const configRepo = () => dataSource.getRepository(entityMap.configs);
|
|
@@ -5807,6 +5826,13 @@ function createSettingsApiHandlers(config) {
|
|
|
5807
5826
|
const authErr = isPublicGroup ? null : await requireAuth(req);
|
|
5808
5827
|
const isAuthed = !authErr;
|
|
5809
5828
|
try {
|
|
5829
|
+
if (isPublicGroup) {
|
|
5830
|
+
const result2 = await getPublicSettingsGroup(
|
|
5831
|
+
{ dataSource, entityMap, encryptionKey },
|
|
5832
|
+
group
|
|
5833
|
+
);
|
|
5834
|
+
return json(result2);
|
|
5835
|
+
}
|
|
5810
5836
|
const where = { settings: group, deleted: false };
|
|
5811
5837
|
if (!isAuthed && !isPublicGroup) where.type = "public";
|
|
5812
5838
|
const rows = await configRepo().find({ where });
|
|
@@ -7464,6 +7490,7 @@ var DEFAULT_ADMIN_NAV = [
|
|
|
7464
7490
|
getCompanyDetailsFromSettings,
|
|
7465
7491
|
getNextAuthOptions,
|
|
7466
7492
|
getPermissionableEntityKeys,
|
|
7493
|
+
getPublicSettingsGroup,
|
|
7467
7494
|
getRequiredPermission,
|
|
7468
7495
|
hasEntityPermission,
|
|
7469
7496
|
isOpenEndpoint,
|