first commit
This commit is contained in:
10
calcom/packages/features/ee/api-keys/lib/apiKeys.ts
Normal file
10
calcom/packages/features/ee/api-keys/lib/apiKeys.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
import { randomBytes, createHash } from "crypto";
|
||||
|
||||
// Hash the API key to check against when veriying it. so we don't have to store the key in plain text.
|
||||
export const hashAPIKey = (apiKey: string): string => createHash("sha256").update(apiKey).digest("hex");
|
||||
|
||||
// Generate a random API key. Prisma already makes sure it's unique. So no need to add salts like with passwords.
|
||||
export const generateUniqueAPIKey = (apiKey = randomBytes(16).toString("hex")) => [
|
||||
hashAPIKey(apiKey),
|
||||
apiKey,
|
||||
];
|
||||
Reference in New Issue
Block a user