@@ -8,19 +8,19 @@ const commandLineUsage = require("command-line-usage");
8
8
const express = require ( "express" ) ;
9
9
const qr = require ( "qr-image" ) ;
10
10
const socketIo = require ( "socket.io" ) ;
11
- const uuid = require ( " uuid/v4" ) ;
11
+ const { v4 : uuidv4 } = require ( ' uuid' ) ;
12
12
13
13
const states = { } ;
14
14
const multiplexes = { } ;
15
15
16
16
const createImage = async ( content ) =>
17
17
new Promise ( ( resolve , reject ) => {
18
- var chunks = [ ] ;
18
+ const chunks = [ ] ;
19
19
20
20
const stream = qr . image ( content ) ;
21
21
stream . on ( "data" , ( chunk ) => chunks . push ( chunk ) ) ;
22
22
stream . on ( "end" , ( ) => {
23
- var result = Buffer . concat ( chunks ) ;
23
+ const result = Buffer . concat ( chunks ) ;
24
24
resolve ( result . toString ( "base64" ) ) ;
25
25
} ) ;
26
26
stream . on ( "error" , reject ) ;
@@ -45,8 +45,8 @@ const initMaster = (socket, initialData, baseUrl, hashsecret) => {
45
45
}
46
46
47
47
if ( remoteId === null ) {
48
- remoteId = uuid ( ) ;
49
- multiplexId = uuid ( ) ;
48
+ remoteId = uuidv4 ( ) ;
49
+ multiplexId = uuidv4 ( ) ;
50
50
hash = mkHash ( remoteId , multiplexId , hashsecret ) ;
51
51
}
52
52
@@ -160,12 +160,12 @@ const index = async (res, path) => {
160
160
fs . promises . readdir ( path , { encoding : "utf-8" } )
161
161
. then ( files => {
162
162
const list = "<li>" +
163
- files . map ( file => '<a href="' + encodeURI ( file ) + '/">' + file . replace ( / [ \u00A0 - \u9999 < > \& ] / g, i => "&#" + i . charCodeAt ( 0 ) + ";" ) + "</a>" )
163
+ files . map ( file => '<a href="' + encodeURI ( file ) + '/">' + file . replace ( / [ \u00A0 - \u9999 < > & " ' ] / g, i => "&#" + i . charCodeAt ( 0 ) + ";" ) + "</a>" )
164
164
. join ( "</li><li>" ) +
165
165
"</li>" ;
166
166
167
167
res . set ( "Content-Type" , "text/html" ) ;
168
- res . send ( "<!DOCTYPE html><html><head><title>Directory Listing</title></head><ul>" + list + "</ul>" ) ;
168
+ res . send ( "<!DOCTYPE html><html lang='en' ><head><title>Directory Listing</title></head><ul>" + list + "</ul>" ) ;
169
169
} )
170
170
. catch ( e => {
171
171
console . warn ( "Unable to build directory listing:" , e ) ;
@@ -239,7 +239,7 @@ const parseArgs = () => {
239
239
name : "hashsecret" ,
240
240
alias : "a" ,
241
241
typeLabel : "{unterline string}" ,
242
- defaultValue : process . env . PRESENTATION_HASH_SECRET || uuid ( ) ,
242
+ defaultValue : process . env . PRESENTATION_HASH_SECRET || uuidv4 ( ) ,
243
243
description : "A secret which is used to resume a session after the presentation is reloaded (default: a random value, env: PRESENTATION_PRESENTATION_PATH)"
244
244
} ,
245
245
{
@@ -297,7 +297,9 @@ createServer(args, app).then(server => {
297
297
app . use ( prefix , express . static ( args . presentationpath ) ) ;
298
298
app . get ( prefix , ( _req , res ) => index ( res , args . presentationpath ) ) ;
299
299
300
- const io = socketIo . listen ( server , { path : args . basepath + "socket.io" , cookie : false } ) ;
300
+ console . log ( socketIo )
301
+
302
+ const io = socketIo ( server , { path : args . basepath + "socket.io" , cookie : false } ) ;
301
303
io . sockets . on ( "connection" , ( socket ) => initConnection ( socket , prefix , args . hashsecret , args . ssl !== null ) ) ;
302
304
303
305
console . log ( "Serving with prefix " + args . basepath + " on port " + args . port + ", secret: " + args . hashsecret ) ;
0 commit comments