Track HiveGrid Cloud planning reference
This commit is contained in:
1 parent
b3d5ea6764
commit
e341c5938a
5784 files changed
+1104929
-3
No files matched your search
@@ -0,0 +1,20 @@
|
||||
import { createHash } from "node:crypto";
|
||||
|
||||
const SENSITIVE_API_LOG_PARAM_PATTERN = /authorization|cookie|password|secret|token|api[-_]?key|key|email|session|jwt|code/i;
|
||||
const SECRET_LIKE_API_LOG_VALUE_PATTERN = /\bBearer\s+\S+|\b(?:sk|pk|rk)_(?:live|test)_[A-Za-z0-9_]+|[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}/i;
|
||||
|
||||
export function getApiKeyLookupCacheKey(key: string) {
|
||||
const digest = createHash("sha256").update(key).digest("hex");
|
||||
return `apiKeyHash:${digest}`;
|
||||
}
|
||||
|
||||
export function serializeApiLogSearchParams(request: Request) {
|
||||
const searchParams = new URL(request.url).searchParams;
|
||||
searchParams.delete("entity");
|
||||
searchParams.delete("id");
|
||||
const entries = Array.from(searchParams.entries()).map(([key, value]) => [
|
||||
key,
|
||||
SENSITIVE_API_LOG_PARAM_PATTERN.test(key) || SECRET_LIKE_API_LOG_VALUE_PATTERN.test(value) ? "[REDACTED]" : value,
|
||||
]);
|
||||
return JSON.stringify(Object.fromEntries(entries));
|
||||
}
|
||||
Reference in new issue
Block a user