Comparing version 1.0.2 to 1.1.0-rc.1
#!/usr/bin/env node | ||
import e from"node:path";import t from"node:fs";import s from"yargs";import{hideBin as r}from"yargs/helpers";import n from"express";import i from"node:http";import o from"node:https";import{randomUUID as a}from"node:crypto";import{EventEmitter as c}from"node:events";import{WebSocketServer as l}from"ws";import d from"cors";function h(e){return e&&e.__esModule?e.default:e}var g={host:"::",port:9e3,expire_timeout:5e3,alive_timeout:9e4,key:"peerjs",path:"/",concurrent_limit:5e3,allow_discovery:!1,proxied:!1,cleanup_out_msgs:1e3,corsOptions:{origin:!0}};class u{lastReadAt=(new Date).getTime();messages=[];getLastReadAt(){return this.lastReadAt}addMessage(e){this.messages.push(e)}readMessage(){if(this.messages.length>0)return this.lastReadAt=(new Date).getTime(),this.messages.shift()}getMessages(){return this.messages}}class m{clients=new Map;messageQueues=new Map;getClientsIds(){return[...this.clients.keys()]}getClientById(e){return this.clients.get(e)}getClientsIdsWithQueue(){return[...this.messageQueues.keys()]}setClient(e,t){this.clients.set(t,e)}removeClientById(e){return!!this.getClientById(e)&&(this.clients.delete(e),!0)}getMessageQueueById(e){return this.messageQueues.get(e)}addMessageToQueue(e,t){this.getMessageQueueById(e)||this.messageQueues.set(e,new u),this.getMessageQueueById(e)?.addMessage(t)}clearMessageQueue(e){this.messageQueues.delete(e)}generateClientId(e){const t=e||a;let s=t();for(;this.getClientById(s);)s=t();return s}}class p{timeoutId=null;constructor({realm:e,config:t,checkInterval:s=300,onClose:r}){this.realm=e,this.config=t,this.onClose=r,this.checkInterval=s}start(){this.timeoutId&&clearTimeout(this.timeoutId),this.timeoutId=setTimeout((()=>{this.checkConnections(),this.timeoutId=null,this.start()}),this.checkInterval)}stop(){this.timeoutId&&(clearTimeout(this.timeoutId),this.timeoutId=null)}checkConnections(){const e=this.realm.getClientsIds(),t=(new Date).getTime(),{alive_timeout:s}=this.config;for(const r of e){const e=this.realm.getClientById(r);if(!e)continue;if(!(t-e.getLastPing()<s))try{e.getSocket()?.close()}finally{this.realm.clearMessageQueue(r),this.realm.removeClientById(r),e.setSocket(null),this.onClose?.(e)}}}}let y;var I;let E;var f;(I=y||(y={})).INVALID_KEY="Invalid key provided",I.INVALID_TOKEN="Invalid token provided",I.INVALID_WS_PARAMETERS="No id, token, or key supplied to websocket server",I.CONNECTION_LIMIT_EXCEED="Server has reached its concurrent user limit",(f=E||(E={})).OPEN="OPEN",f.LEAVE="LEAVE",f.CANDIDATE="CANDIDATE",f.OFFER="OFFER",f.ANSWER="ANSWER",f.EXPIRE="EXPIRE",f.HEARTBEAT="HEARTBEAT",f.ID_TAKEN="ID-TAKEN",f.ERROR="ERROR";class S{timeoutId=null;constructor({realm:e,config:t,messageHandler:s}){this.realm=e,this.config=t,this.messageHandler=s}startMessagesExpiration(){this.timeoutId&&clearTimeout(this.timeoutId),this.timeoutId=setTimeout((()=>{this.pruneOutstanding(),this.timeoutId=null,this.startMessagesExpiration()}),this.config.cleanup_out_msgs)}stopMessagesExpiration(){this.timeoutId&&(clearTimeout(this.timeoutId),this.timeoutId=null)}pruneOutstanding(){const e=this.realm.getClientsIdsWithQueue(),t=(new Date).getTime(),s=this.config.expire_timeout,r={};for(const n of e){const e=this.realm.getMessageQueueById(n);if(!e)continue;if(t-e.getLastReadAt()<s)continue;const i=e.getMessages();for(const e of i){const t=`${e.src}_${e.dst}`;r[t]||(this.messageHandler.handle(void 0,{type:E.EXPIRE,src:e.dst,dst:e.src}),r[t]=!0)}this.realm.clearMessageQueue(n)}}}class k{socket=null;lastPing=(new Date).getTime();constructor({id:e,token:t}){this.id=e,this.token=t}getId(){return this.id}getToken(){return this.token}getSocket(){return this.socket}setSocket(e){this.socket=e}getLastPing(){return this.lastPing}setLastPing(e){this.lastPing=e}send(e){this.socket?.send(JSON.stringify(e))}}class v extends c{constructor({server:e,realm:t,config:s}){super(),this.setMaxListeners(0),this.realm=t,this.config=s;const r=this.config.path;this.path=`${r}${r.endsWith("/")?"":"/"}peerjs`;const n={path:this.path,server:e};this.socketServer=s.createWebSocketServer?s.createWebSocketServer(n):new l(n),this.socketServer.on("connection",((e,t)=>{this._onSocketConnection(e,t)})),this.socketServer.on("error",(e=>{this._onSocketError(e)}))}_onSocketConnection(e,t){e.on("error",(e=>{this._onSocketError(e)}));const{searchParams:s}=new URL(t.url??"","https://peerjs"),{id:r,token:n,key:i}=Object.fromEntries(s.entries());if(!r||!n||!i)return void this._sendErrorAndClose(e,y.INVALID_WS_PARAMETERS);if(i!==this.config.key)return void this._sendErrorAndClose(e,y.INVALID_KEY);const o=this.realm.getClientById(r);if(o)return n!==o.getToken()?(e.send(JSON.stringify({type:E.ID_TAKEN,payload:{msg:"ID is taken"}})),void e.close()):void this._configureWS(e,o);this._registerClient({socket:e,id:r,token:n})}_onSocketError(e){this.emit("error",e)}_registerClient({socket:e,id:t,token:s}){if(this.realm.getClientsIds().length>=this.config.concurrent_limit)return void this._sendErrorAndClose(e,y.CONNECTION_LIMIT_EXCEED);const r=new k({id:t,token:s});this.realm.setClient(r,t),e.send(JSON.stringify({type:E.OPEN})),this._configureWS(e,r)}_configureWS(e,t){t.setSocket(e),e.on("close",(()=>{t.getSocket()===e&&(this.realm.removeClientById(t.getId()),this.emit("close",t))})),e.on("message",(e=>{try{const s=JSON.parse(e.toString());s.src=t.getId(),this.emit("message",t,s)}catch(e){this.emit("error",e)}})),this.emit("connection",t)}_sendErrorAndClose(e,t){e.send(JSON.stringify({type:E.ERROR,payload:{msg:t}})),e.close()}}const R=e=>{if(e){const t=(new Date).getTime();e.setLastPing(t)}return!0},C=({realm:e})=>{const t=(s,r)=>{const n=r.type,i=r.src,o=r.dst,a=e.getClientById(o);if(a){const n=a.getSocket();try{if(!n)throw new Error("Peer dead");{const e=JSON.stringify(r);n.send(e)}}catch(r){n?n.close():e.removeClientById(a.getId()),t(s,{type:E.LEAVE,src:o,dst:i})}}else{![E.LEAVE,E.EXPIRE].includes(n)&&o?e.addMessageToQueue(o,r):n!==E.LEAVE||o||e.removeClientById(i)}return!0};return t};class _{handlers=new Map;registerHandler(e,t){this.handlers.has(e)||this.handlers.set(e,t)}handle(e,t){const{type:s}=t,r=this.handlers.get(s);return!!r&&r(e,t)}}class A{constructor(e,t=new _){this.handlersRegistry=t;const s=C({realm:e}),r=R,n=(e,{type:t,src:r,dst:n,payload:i})=>s(e,{type:t,src:r,dst:n,payload:i});this.handlersRegistry.registerHandler(E.HEARTBEAT,((e,t)=>r(e,t))),this.handlersRegistry.registerHandler(E.OFFER,n),this.handlersRegistry.registerHandler(E.ANSWER,n),this.handlersRegistry.registerHandler(E.CANDIDATE,n),this.handlersRegistry.registerHandler(E.LEAVE,n),this.handlersRegistry.registerHandler(E.EXPIRE,n)}handle(e,t){return this.handlersRegistry.handle(e,t)}}var O;O=JSON.parse('{"name":"PeerJS Server","description":"A server side element to broker connections between PeerJS clients.","website":"https://peerjs.com/"}');var T=({config:e,realm:t})=>{const s=n.Router();return s.get("/id",((s,r)=>{r.contentType("html"),r.send(t.generateClientId(e.generateClientId))})),s.get("/peers",((s,r)=>{if(e.allow_discovery){const e=t.getClientsIds();return r.send(e)}return r.sendStatus(401)})),s};const w=({config:e,realm:t,corsOptions:s})=>{const r=n.Router();return r.use(d(s)),r.get("/",((e,t)=>{t.send(h(O))})),r.use("/:key",T({config:e,realm:t})),r},N=({app:t,server:s,options:r})=>{const n=r,i=new m,o=new A(i),a=w({config:n,realm:i,corsOptions:r.corsOptions}),c=new S({realm:i,config:n,messageHandler:o}),l=new p({realm:i,config:n,onClose:e=>{t.emit("disconnect",e)}});t.use(r.path,a);const d={...n,path:e.posix.join(t.path(),r.path,"/")},h=new v({server:s,realm:i,config:d});h.on("connection",(e=>{const s=i.getMessageQueueById(e.getId());if(s){let t;for(;t=s.readMessage();)o.handle(e,t);i.clearMessageQueue(e.getId())}t.emit("connection",e)})),h.on("message",((e,s)=>{t.emit("message",e,s),o.handle(e,s)})),h.on("close",(e=>{t.emit("disconnect",e)})),h.on("error",(e=>{t.emit("error",e)})),c.startMessagesExpiration(),l.start()};const M=s(r(process.argv)),b=!!process.env.PORT,P=M.usage("Usage: $0").wrap(Math.min(98,M.terminalWidth())).options({expire_timeout:{demandOption:!1,alias:"t",describe:"timeout (milliseconds)",default:5e3},concurrent_limit:{demandOption:!1,alias:"c",describe:"concurrent limit",default:5e3},alive_timeout:{demandOption:!1,describe:"broken connection check timeout (milliseconds)",default:6e4},key:{demandOption:!1,alias:"k",describe:"connection key",default:"peerjs"},sslkey:{type:"string",demandOption:!1,describe:"path to SSL key"},sslcert:{type:"string",demandOption:!1,describe:"path to SSL certificate"},host:{type:"string",demandOption:!1,alias:"H",describe:"host"},port:{type:"number",demandOption:!b,alias:"p",describe:"port"},path:{type:"string",demandOption:!1,describe:"custom path",default:process.env.PEERSERVER_PATH??"/"},allow_discovery:{type:"boolean",demandOption:!1,describe:"allow discovery of peers"},proxied:{type:"boolean",demandOption:!1,describe:"Set true if PeerServer stays behind a reverse proxy",default:!1},cors:{type:"string",array:!0,describe:"Set the list of CORS origins"}}).boolean("allow_discovery").parseSync();P.port||(P.port=parseInt(process.env.PORT)),P.cors&&(P.corsOptions={origin:P.cors}),process.on("uncaughtException",(function(e){console.error("Error: "+e.toString())})),(P.sslkey??P.sslcert)&&(P.sslkey&&P.sslcert?P.ssl={key:t.readFileSync(e.resolve(P.sslkey)),cert:t.readFileSync(e.resolve(P.sslcert))}:(console.error("Warning: PeerServer will not run because either the key or the certificate has not been provided."),process.exit(1)));const D=P.path,L=function(e={},t){const s=n();let r={...g,...e};const a=r.port,c=r.host;let l;const{ssl:d,...h}=r;d&&Object.keys(d).length?(l=o.createServer(d,s),r=h):l=i.createServer(s);const u=function(e,t){const s=n(),r={...g,...t};return r.proxied&&s.set("trust proxy","false"!==r.proxied&&!!r.proxied),s.on("mount",(()=>{if(!e)throw new Error("Server is not passed to constructor - can't start PeerServer");N({app:s,server:e,options:r})})),s}(l,r);return s.use(u),l.listen(a,c,(()=>t?.(l))),u}(P,(e=>{const{address:t,port:s}=e.address();console.log("Started PeerServer on %s, port: %s, path: %s",t,s,D||"/");const r=()=>{e.close((()=>{console.log("Http server closed."),process.exit(0)}))};process.on("SIGINT",r),process.on("SIGTERM",r)}));L.on("connection",(e=>{console.log(`Client connected: ${e.getId()}`)})),L.on("disconnect",(e=>{console.log(`Client disconnected: ${e.getId()}`)})); | ||
import e from"node:path";import t from"node:fs";import s from"yargs";import{hideBin as r}from"yargs/helpers";import i from"express";import n from"node:http";import o from"node:https";import{randomUUID as a}from"node:crypto";import{EventEmitter as l}from"node:events";import{WebSocketServer as c}from"ws";import d from"cors";var h,g,u,m,p={host:"::",port:9e3,expire_timeout:5e3,alive_timeout:9e4,key:"peerjs",path:"/",concurrent_limit:5e3,allow_discovery:!1,proxied:!1,cleanup_out_msgs:1e3,corsOptions:{origin:!0}};class y{getLastReadAt(){return this.lastReadAt}addMessage(e){this.messages.push(e)}readMessage(){if(this.messages.length>0)return this.lastReadAt=new Date().getTime(),this.messages.shift()}getMessages(){return this.messages}constructor(){this.lastReadAt=new Date().getTime(),this.messages=[]}}class I{getClientsIds(){return[...this.clients.keys()]}getClientById(e){return this.clients.get(e)}getClientsIdsWithQueue(){return[...this.messageQueues.keys()]}setClient(e,t){this.clients.set(t,e)}removeClientById(e){return!!this.getClientById(e)&&(this.clients.delete(e),!0)}getMessageQueueById(e){return this.messageQueues.get(e)}addMessageToQueue(e,t){this.getMessageQueueById(e)||this.messageQueues.set(e,new y),this.getMessageQueueById(e)?.addMessage(t)}clearMessageQueue(e){this.messageQueues.delete(e)}generateClientId(e){let t=e||a,s=t();for(;this.getClientById(s);)s=t();return s}constructor(){this.clients=new Map,this.messageQueues=new Map}}class E{constructor({realm:e,config:t,checkInterval:s=300,onClose:r}){this.timeoutId=null,this.realm=e,this.config=t,this.onClose=r,this.checkInterval=s}start(){this.timeoutId&&clearTimeout(this.timeoutId),this.timeoutId=setTimeout(()=>{this.checkConnections(),this.timeoutId=null,this.start()},this.checkInterval)}stop(){this.timeoutId&&(clearTimeout(this.timeoutId),this.timeoutId=null)}checkConnections(){let e=this.realm.getClientsIds(),t=new Date().getTime(),{alive_timeout:s}=this.config;for(let r of e){let e=this.realm.getClientById(r);if(e&&!(t-e.getLastPing()<s))try{e.getSocket()?.close()}finally{this.realm.clearMessageQueue(r),this.realm.removeClientById(r),e.setSocket(null),this.onClose?.(e)}}}}(h=u||(u={})).INVALID_KEY="Invalid key provided",h.INVALID_TOKEN="Invalid token provided",h.INVALID_WS_PARAMETERS="No id, token, or key supplied to websocket server",h.CONNECTION_LIMIT_EXCEED="Server has reached its concurrent user limit",(g=m||(m={})).OPEN="OPEN",g.LEAVE="LEAVE",g.CANDIDATE="CANDIDATE",g.OFFER="OFFER",g.ANSWER="ANSWER",g.EXPIRE="EXPIRE",g.HEARTBEAT="HEARTBEAT",g.ID_TAKEN="ID-TAKEN",g.ERROR="ERROR";class f{constructor({realm:e,config:t,messageHandler:s}){this.timeoutId=null,this.realm=e,this.config=t,this.messageHandler=s}startMessagesExpiration(){this.timeoutId&&clearTimeout(this.timeoutId),this.timeoutId=setTimeout(()=>{this.pruneOutstanding(),this.timeoutId=null,this.startMessagesExpiration()},this.config.cleanup_out_msgs)}stopMessagesExpiration(){this.timeoutId&&(clearTimeout(this.timeoutId),this.timeoutId=null)}pruneOutstanding(){let e=this.realm.getClientsIdsWithQueue(),t=new Date().getTime(),s=this.config.expire_timeout,r={};for(let i of e){let e=this.realm.getMessageQueueById(i);if(!(!e||t-e.getLastReadAt()<s)){for(let t of e.getMessages()){let e=`${t.src}_${t.dst}`;r[e]||(this.messageHandler.handle(void 0,{type:m.EXPIRE,src:t.dst,dst:t.src}),r[e]=!0)}this.realm.clearMessageQueue(i)}}}}class S{constructor({id:e,token:t}){this.socket=null,this.lastPing=new Date().getTime(),this.id=e,this.token=t}getId(){return this.id}getToken(){return this.token}getSocket(){return this.socket}setSocket(e){this.socket=e}getLastPing(){return this.lastPing}setLastPing(e){this.lastPing=e}send(e){this.socket?.send(JSON.stringify(e))}}class k extends l{constructor({server:e,realm:t,config:s}){super(),this.setMaxListeners(0),this.realm=t,this.config=s;let r=this.config.path;this.path=`${r}${r.endsWith("/")?"":"/"}peerjs`;let i={path:this.path,server:e};this.socketServer=s.createWebSocketServer?s.createWebSocketServer(i):new c(i),this.socketServer.on("connection",(e,t)=>{this._onSocketConnection(e,t)}),this.socketServer.on("error",e=>{this._onSocketError(e)})}_onSocketConnection(e,t){e.on("error",e=>{this._onSocketError(e)});let{searchParams:s}=new URL(t.url??"","https://peerjs"),{id:r,token:i,key:n}=Object.fromEntries(s.entries());if(!r||!i||!n){this._sendErrorAndClose(e,u.INVALID_WS_PARAMETERS);return}if(n!==this.config.key){this._sendErrorAndClose(e,u.INVALID_KEY);return}let o=this.realm.getClientById(r);if(o){if(i!==o.getToken()){e.send(JSON.stringify({type:m.ID_TAKEN,payload:{msg:"ID is taken"}})),e.close();return}this._configureWS(e,o);return}this._registerClient({socket:e,id:r,token:i})}_onSocketError(e){this.emit("error",e)}_registerClient({socket:e,id:t,token:s}){if(this.realm.getClientsIds().length>=this.config.concurrent_limit){this._sendErrorAndClose(e,u.CONNECTION_LIMIT_EXCEED);return}let r=new S({id:t,token:s});this.realm.setClient(r,t),e.send(JSON.stringify({type:m.OPEN})),this._configureWS(e,r)}_configureWS(e,t){t.setSocket(e),e.on("close",()=>{t.getSocket()===e&&(this.realm.removeClientById(t.getId()),this.emit("close",t))}),e.on("message",e=>{try{let s=JSON.parse(e.toString());s.src=t.getId(),this.emit("message",t,s)}catch(e){this.emit("error",e)}}),this.emit("connection",t)}_sendErrorAndClose(e,t){e.send(JSON.stringify({type:m.ERROR,payload:{msg:t}})),e.close()}}let v=e=>{if(e){let t=new Date().getTime();e.setLastPing(t)}return!0},R=({realm:e})=>{let t=(s,r)=>{let i=r.type,n=r.src,o=r.dst,a=e.getClientById(o);if(a){let i=a.getSocket();try{if(i){let e=JSON.stringify(r);i.send(e)}else throw Error("Peer dead")}catch(r){i?i.close():e.removeClientById(a.getId()),t(s,{type:m.LEAVE,src:o,dst:n})}}else![m.LEAVE,m.EXPIRE].includes(i)&&o?e.addMessageToQueue(o,r):i!==m.LEAVE||o||e.removeClientById(n);return!0};return t};class C{registerHandler(e,t){this.handlers.has(e)||this.handlers.set(e,t)}handle(e,t){let{type:s}=t,r=this.handlers.get(s);return!!r&&r(e,t)}constructor(){this.handlers=new Map}}class _{constructor(e,t=new C){this.handlersRegistry=t;let s=R({realm:e}),r=(e,{type:t,src:r,dst:i,payload:n})=>s(e,{type:t,src:r,dst:i,payload:n});this.handlersRegistry.registerHandler(m.HEARTBEAT,(e,t)=>v(e,t)),this.handlersRegistry.registerHandler(m.OFFER,r),this.handlersRegistry.registerHandler(m.ANSWER,r),this.handlersRegistry.registerHandler(m.CANDIDATE,r),this.handlersRegistry.registerHandler(m.LEAVE,r),this.handlersRegistry.registerHandler(m.EXPIRE,r)}handle(e,t){return this.handlersRegistry.handle(e,t)}}var A={};A=JSON.parse('{"name":"PeerJS Server","description":"A server side element to broker connections between PeerJS clients.","website":"https://peerjs.com/"}');var O=({config:e,realm:t})=>{let s=i.Router();return s.get("/id",(s,r)=>{r.contentType("html"),r.send(t.generateClientId(e.generateClientId))}),s.get("/peers",(s,r)=>{if(e.allow_discovery){let e=t.getClientsIds();return r.send(e)}return r.sendStatus(401)}),s};let T=({config:e,realm:t,corsOptions:s})=>{let r=i.Router();return r.use(d(s)),r.get("/",(e,t)=>{var s;t.send((s=A)&&s.__esModule?s.default:s)}),r.use("/:key",O({config:e,realm:t})),r},N=({app:t,server:s,options:r})=>{let i=new I,n=new _(i),o=T({config:r,realm:i,corsOptions:r.corsOptions}),a=new f({realm:i,config:r,messageHandler:n}),l=new E({realm:i,config:r,onClose:e=>{t.emit("disconnect",e)}});t.use(r.path,o);let c=new k({server:s,realm:i,config:{...r,path:e.posix.join(t.path(),r.path,"/")}});c.on("connection",e=>{let s=i.getMessageQueueById(e.getId());if(s){let t;for(;t=s.readMessage();)n.handle(e,t);i.clearMessageQueue(e.getId())}t.emit("connection",e)}),c.on("message",(e,s)=>{t.emit("message",e,s),n.handle(e,s)}),c.on("close",e=>{t.emit("disconnect",e)}),c.on("error",e=>{t.emit("error",e)}),a.startMessagesExpiration(),l.start()},w=s(r(process.argv)),M=!!process.env.PORT,b=w.usage("Usage: $0").wrap(Math.min(98,w.terminalWidth())).options({expire_timeout:{demandOption:!1,alias:"t",describe:"timeout (milliseconds)",default:5e3},concurrent_limit:{demandOption:!1,alias:"c",describe:"concurrent limit",default:5e3},alive_timeout:{demandOption:!1,describe:"broken connection check timeout (milliseconds)",default:6e4},key:{demandOption:!1,alias:"k",describe:"connection key",default:"peerjs"},sslkey:{type:"string",demandOption:!1,describe:"path to SSL key"},sslcert:{type:"string",demandOption:!1,describe:"path to SSL certificate"},host:{type:"string",demandOption:!1,alias:"H",describe:"host"},port:{type:"number",demandOption:!M,alias:"p",describe:"port"},path:{type:"string",demandOption:!1,describe:"custom path",default:process.env.PEERSERVER_PATH??"/"},allow_discovery:{type:"boolean",demandOption:!1,describe:"allow discovery of peers"},proxied:{type:"boolean",demandOption:!1,describe:"Set true if PeerServer stays behind a reverse proxy",default:!1},cors:{type:"string",array:!0,describe:"Set the list of CORS origins"}}).boolean("allow_discovery").parseSync();b.port||(b.port=parseInt(process.env.PORT)),b.cors&&(b.corsOptions={origin:b.cors}),process.on("uncaughtException",function(e){console.error("Error: "+e.toString())}),(b.sslkey??b.sslcert)&&(b.sslkey&&b.sslcert?b.ssl={key:t.readFileSync(e.resolve(b.sslkey)),cert:t.readFileSync(e.resolve(b.sslcert))}:(console.error("Warning: PeerServer will not run because either the key or the certificate has not been provided."),process.exit(1)));let P=b.path,D=function(e={},t){let s;let r=i(),a={...p,...e},l=a.port,c=a.host,{ssl:d,...h}=a;d&&Object.keys(d).length?(s=o.createServer(d,r),a=h):s=n.createServer(r);let g=function(e,t){let s=i(),r={...p,...t};return r.proxied&&s.set("trust proxy","false"!==r.proxied&&!!r.proxied),s.on("mount",()=>{if(!e)throw Error("Server is not passed to constructor - can't start PeerServer");N({app:s,server:e,options:r})}),s}(s,a);return r.use(g),s.listen(l,c,()=>t?.(s)),g}(b,e=>{let{address:t,port:s}=e.address();console.log("Started PeerServer on %s, port: %s, path: %s",t,s,P||"/");let r=()=>{e.close(()=>{console.log("Http server closed."),process.exit(0)})};process.on("SIGINT",r),process.on("SIGTERM",r)});D.on("connection",e=>{console.log(`Client connected: ${e.getId()}`)}),D.on("disconnect",e=>{console.log(`Client disconnected: ${e.getId()}`)}); | ||
//# sourceMappingURL=peerjs.js.map |
{ | ||
"name": "peer", | ||
"version": "1.0.2", | ||
"version": "1.1.0-rc.1", | ||
"keywords": [ | ||
@@ -86,5 +86,5 @@ "peerjs", | ||
"@codedependant/semantic-release-docker": "^4.3.0", | ||
"@parcel/core": "~2.8.3", | ||
"@parcel/packager-ts": "~2.8.3", | ||
"@parcel/transformer-typescript-types": "~2.8.3", | ||
"@parcel/core": "~2.12.0", | ||
"@parcel/packager-ts": "~2.12.0", | ||
"@parcel/transformer-typescript-types": "~2.12.0", | ||
"@semantic-release/changelog": "^6.0.1", | ||
@@ -106,3 +106,3 @@ "@semantic-release/git": "^10.0.1", | ||
"mock-socket": "^9.1.5", | ||
"parcel": "~2.8.3", | ||
"parcel": "~2.12.0", | ||
"prettier": "^3.0.0", | ||
@@ -109,0 +109,0 @@ "semantic-release": "^22.0.0", |
@@ -340,5 +340,5 @@ [![Build Status](https://travis-ci.org/peers/peerjs-server.png?branch=master)](https://travis-ci.org/peers/peerjs-server) | ||
Discuss PeerJS on our Telegram chat: | ||
https://t.me/joinchat/ENhPuhTvhm8WlIxTjQf7Og | ||
Discuss PeerJS on our Discord community: | ||
https://discord.gg/Ud2PvAtK37 | ||
Please post any bugs as a Github issue. |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
229686
1221
1