14 lines
286 B
TypeScript
14 lines
286 B
TypeScript
import crypto from 'crypto';
|
|
|
|
import { sign } from './jwt';
|
|
|
|
export const generateResetToken = (sub: string) => {
|
|
const key = crypto.randomBytes(16).toString('hex');
|
|
const token = sign({
|
|
sub,
|
|
key,
|
|
exp: Date.now() + 24 * 60 * 60 * 1000,
|
|
});
|
|
return { key, token };
|
|
};
|