Files
klz-cables.com/.pnpm-store/v10/files/5f/cabc5f0fac230aafbf609030b8d9465f4ef53b075db606ecae4de7fe198172c6858d8ef64335eb889fa200e16964cb7dc72671d0417db3ec23688762b81dc1
Marc Mintel 5397309103
Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 20s
Build & Deploy / 🧪 QA (push) Failing after 34s
Build & Deploy / 🏗️ Build (push) Has started running
Build & Deploy / 🚀 Deploy (push) Has been cancelled
Build & Deploy / 🧪 Smoke Test (push) Has been cancelled
Build & Deploy / ⚡ Lighthouse (push) Has been cancelled
Build & Deploy / 🔔 Notify (push) Has been cancelled
fix(products): fix breadcrumbs and product filtering (backport from main)
2026-02-24 16:04:21 +01:00

59 lines
1.6 KiB
Plaintext

import crypto from 'crypto';
const encryptKey = ({ req, value })=>value ? req.payload.encrypt(value) : null;
const decryptKey = ({ req, value })=>value ? req.payload.decrypt(value) : undefined;
export const apiKeyFields = [
{
name: 'enableAPIKey',
type: 'checkbox',
admin: {
components: {
Field: false
}
},
label: ({ t })=>t('authentication:enableAPIKey')
},
{
name: 'apiKey',
type: 'text',
admin: {
components: {
Field: false
}
},
hooks: {
afterRead: [
decryptKey
],
beforeChange: [
encryptKey
]
},
label: ({ t })=>t('authentication:apiKey')
},
{
name: 'apiKeyIndex',
type: 'text',
admin: {
disabled: true
},
hidden: true,
hooks: {
beforeValidate: [
({ data, req, value })=>{
if (data?.apiKey === false || data?.apiKey === null) {
return null;
}
if (data?.enableAPIKey === false || data?.enableAPIKey === null) {
return null;
}
if (data?.apiKey) {
return crypto.createHmac('sha256', req.payload.secret).update(data.apiKey).digest('hex');
}
return value;
}
]
}
}
];
//# sourceMappingURL=apiKey.js.map