chore: migrating to nodejs 22
This commit is contained in:
parent
0296f86060
commit
2e31ab391f
47 changed files with 16384 additions and 11137 deletions
|
|
@ -1,8 +1,5 @@
|
|||
const _ = require('lodash/fp')
|
||||
const crypto = require('crypto')
|
||||
|
||||
const logger = require('../logger')
|
||||
|
||||
function sha256 (buf) {
|
||||
if (!buf) return null
|
||||
const hash = crypto.createHash('sha256')
|
||||
|
|
@ -12,10 +9,9 @@ function sha256 (buf) {
|
|||
}
|
||||
|
||||
const populateDeviceId = function (req, res, next) {
|
||||
const deviceId = _.isFunction(req.connection.getPeerCertificate)
|
||||
? sha256(req.connection.getPeerCertificate()?.raw)
|
||||
: null
|
||||
|
||||
const peerCert = req.socket.getPeerCertificate ? req.socket.getPeerCertificate() : null
|
||||
const deviceId = peerCert?.raw ? sha256(peerCert.raw) : null
|
||||
|
||||
if (!deviceId) return res.status(500).json({ error: 'Unable to find certificate' })
|
||||
req.deviceId = deviceId
|
||||
req.deviceTime = req.get('date')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue