Update packages/features/ee/api-keys/lib/apiKeys.ts

fix hashPart
This commit is contained in:
Alex van Andel 2023-11-09 15:43:33 +00:00 committed by GitHub
parent 6a28725f6c
commit 4e82266d59
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -17,7 +17,7 @@ export const apiKeySchema = z.string({ required_error: "No apiKey provided" }).r
return false;
}
// Extract the hash part and validate its format
const hashPart = value.slice(4); // Remove prefix
const hashPart = value.slice((process.env.API_KEY_PREFIX || "cal_").length); // Remove prefix
const hashRegex = /^[a-f0-9]{32}$/i; // Regex for a 32-character hexadecimal hash
return hashRegex.test(hashPart);