forked from zoom/meetingsdk-auth-endpoint-sample
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
25 lines (19 loc) · 868 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
require('dotenv').config()
const express = require('express')
const bodyParser = require('body-parser')
const crypto = require('crypto')
const cors = require('cors')
const app = express()
const port = process.env.PORT || 4000
app.use(bodyParser.json(), cors())
app.options('*', cors());
app.post('/', (req, res) => {
const timestamp = new Date().getTime() - 30000
const msg = Buffer.from(process.env.API_KEY + req.body.meetingNumber + timestamp + req.body.role).toString('base64')
const hash = crypto.createHmac('sha256', process.env.API_SECRET).update(msg).digest('base64')
const signature = Buffer.from(`${process.env.API_KEY}.${req.body.meetingNumber}.${timestamp}.${req.body.role}.${hash}`).toString('base64')
res.json({
signature: signature
})
})
app.listen(port, () => console.log(`Zoom Web SDK Sample Signature Node.js on port ${port}!`))