Download packages/kap-server/src/services/auth/password.ts from SaylorTwift/kimi-code: direct link, hf CLI and curl.
- Browser
- Download file 563 Bytes
-
https://huggingface.co/SaylorTwift/kimi-code/resolve/main/packages/kap-server/src/services/auth/password.ts
- Command line
-
hf download hf://SaylorTwift/kimi-code/packages/kap-server/src/services/auth/password.ts
-
curl -L -o password.ts https://huggingface.co/SaylorTwift/kimi-code/resolve/main/packages/kap-server/src/services/auth/password.ts
563 Bytes
| import bcrypt from 'bcryptjs'; | |
| const { compare, hash } = bcrypt; | |
| const BCRYPT_COST = 12; | |
| export async function resolvePasswordHash( | |
| env: NodeJS.ProcessEnv = process.env, | |
| ): Promise<string | undefined> { | |
| const plaintext = env['KIMI_CODE_PASSWORD']; | |
| if (!plaintext) { | |
| return undefined; | |
| } | |
| return hash(plaintext, BCRYPT_COST); | |
| } | |
| export async function verifyPassword( | |
| candidate: string, | |
| passwordHash: string | undefined, | |
| ): Promise<boolean> { | |
| if (passwordHash === undefined) { | |
| return false; | |
| } | |
| return compare(candidate, passwordHash); | |
| } | |