@script-bridge/server
Advanced tools
+1
-1
@@ -20,3 +20,3 @@ import { EventEmitter } from 'node:events'; | ||
| export declare class ScriptBridgeServer extends EventEmitter<ServerEvents> { | ||
| static readonly PROTOCOL_VERSION = 1; | ||
| static readonly PROTOCOL_VERSION = 2; | ||
| readonly sessions: Map<string, Session>; | ||
@@ -23,0 +23,0 @@ readonly port: number; |
+15
-3
@@ -99,4 +99,11 @@ "use strict"; | ||
| const session = this.sessions.get(body.sessionId); | ||
| if (!session) | ||
| return void res.sendStatus(400); | ||
| if (!session) { | ||
| res.json({ | ||
| type: protocol_1.PayloadType.Response, | ||
| error: true, | ||
| errorReason: protocol_1.ResponseErrorReason.InvalidSession, | ||
| message: 'Invalid session', | ||
| }); | ||
| return; | ||
| } | ||
| if (body.type === protocol_1.PayloadType.Request) { | ||
@@ -115,3 +122,8 @@ this.emit('requestReceive', body, session); | ||
| else { | ||
| res.sendStatus(400); | ||
| res.json({ | ||
| type: protocol_1.PayloadType.Response, | ||
| error: true, | ||
| errorReason: protocol_1.ResponseErrorReason.InvalidPayload, | ||
| message: 'Invalid payload type', | ||
| }); | ||
| } | ||
@@ -118,0 +130,0 @@ }); |
+1
-1
| { | ||
| "name": "@script-bridge/server", | ||
| "version": "0.1.9", | ||
| "version": "0.2.2", | ||
| "description": "two-way communication system between ScriptAPI and backend server using http request", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
22525
2.24%529
2.32%