mirror of
https://codeberg.org/timelimit/timelimit-server.git
synced 2025-10-03 09:49:32 +02:00
Adjust test script for missing tokgen package
This commit is contained in:
parent
17c224b4f3
commit
b31b42046b
1 changed files with 4 additions and 14 deletions
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* server component for the TimeLimit App
|
* server component for the TimeLimit App
|
||||||
* Copyright (C) 2019 - 2021 Jonas Lochmann
|
* Copyright (C) 2019 - 2022 Jonas Lochmann
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU Affero General Public License as
|
* it under the terms of the GNU Affero General Public License as
|
||||||
|
@ -15,19 +15,9 @@
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const TokenGenerator = require('tokgen')
|
const { randomBytes } = require('crypto')
|
||||||
|
|
||||||
const tokenGenerator = new TokenGenerator({
|
function generateToken() { return randomBytes(32).toString('hex') }
|
||||||
length: 32,
|
function generateShortToken() { return randomBytes(8).toString('hex') }
|
||||||
chars: 'a-zA-Z0-9'
|
|
||||||
})
|
|
||||||
|
|
||||||
const shortTokenGenerator = new TokenGenerator({
|
|
||||||
length: 8,
|
|
||||||
chars: 'a-zA-Z0-9'
|
|
||||||
})
|
|
||||||
|
|
||||||
function generateToken() { return tokenGenerator.generate() }
|
|
||||||
function generateShortToken() { return shortTokenGenerator.generate() }
|
|
||||||
|
|
||||||
module.exports = { generateToken, generateShortToken }
|
module.exports = { generateToken, generateShortToken }
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue