55bf16c06d
Use per-project v1 history blob URLs for git-bridge GitOrigin-RevId: b68ee2129ceb57f4b7f68262c5bcbadc0952b56f
23 lines
537 B
JavaScript
23 lines
537 B
JavaScript
const { callbackify, promisify } = require('util')
|
|
const JWT = require('jsonwebtoken')
|
|
const Settings = require('settings-sharelatex')
|
|
|
|
const jwtSign = promisify(JWT.sign)
|
|
|
|
async function sign(payload, options = {}) {
|
|
const key = Settings.jwt.key
|
|
const algorithm = Settings.jwt.algorithm
|
|
if (!key || !algorithm) {
|
|
throw new Error('missing JWT configuration')
|
|
}
|
|
const token = await jwtSign(payload, key, { ...options, algorithm })
|
|
return token
|
|
}
|
|
|
|
module.exports = {
|
|
sign: callbackify(sign),
|
|
promises: {
|
|
sign
|
|
}
|
|
}
|