mirror of
https://github.com/omnivore-app/omnivore.git
synced 2026-03-11 08:54:26 +00:00
16 lines
465 B
TypeScript
16 lines
465 B
TypeScript
import * as bcrypt from 'bcryptjs'
|
|
import * as jwt from 'jsonwebtoken'
|
|
import { env } from '../env'
|
|
import { Claims } from '../resolvers/types'
|
|
|
|
export const hashPassword = (password: string) => {
|
|
return bcrypt.hashSync(password, 10)
|
|
}
|
|
|
|
export const comparePassword = (password: string, hash: string) => {
|
|
return bcrypt.compareSync(password, hash)
|
|
}
|
|
|
|
export const generateApiKey = (claims: Claims): string => {
|
|
return jwt.sign(claims, env.server.jwtSecret)
|
|
}
|