mirror of
https://github.com/overleaf/overleaf.git
synced 2024-10-31 21:21:03 -04:00
15 lines
417 B
CoffeeScript
15 lines
417 B
CoffeeScript
crypto = require 'crypto'
|
|
|
|
module.exports = ProjectTokenGenerator =
|
|
|
|
readOnlyToken: () ->
|
|
length = 12
|
|
tokenAlpha = 'bcdfghjkmnpqrstvwxyz'
|
|
result = ''
|
|
crypto.randomBytes(length).map( (a) -> result += tokenAlpha[a % tokenAlpha.length] )
|
|
return result
|
|
|
|
readAndWriteToken: () ->
|
|
numerics = Math.random().toString().slice(2, 12)
|
|
token = ProjectTokenGenerator.readOnlyToken()
|
|
return "#{numerics}#{token}"
|