@based/server
Advanced tools
Comparing version 6.2.4 to 6.2.5
@@ -19,2 +19,7 @@ "use strict"; | ||
}, | ||
[types_1.BasedErrorCode.Block]: { | ||
statusCode: 429, | ||
statusMessage: 'Blocked ip', | ||
message: () => 'Blocked ip', | ||
}, | ||
[types_1.BasedErrorCode.IncorrectAccessKey]: { | ||
@@ -21,0 +26,0 @@ statusCode: 429, |
@@ -49,6 +49,6 @@ "use strict"; | ||
} | ||
if ('observableId' in payload) { | ||
else if ('observableId' in payload) { | ||
errorData.observableId = payload.observableId; | ||
} | ||
if ('channelId' in payload) { | ||
else if ('channelId' in payload) { | ||
errorData.channelId = payload.channelId; | ||
@@ -55,0 +55,0 @@ } |
@@ -20,3 +20,4 @@ import { BasedRoute } from '@based/functions'; | ||
MissingAuthStateProtocolHeader = 40030, | ||
IncorrectAccessKey = 40031 | ||
IncorrectAccessKey = 40031, | ||
Block = 90001 | ||
} | ||
@@ -54,2 +55,3 @@ type FunctionErrorProps = { | ||
[BasedErrorCode.RateLimit]: {}; | ||
[BasedErrorCode.Block]: {}; | ||
[BasedErrorCode.IncorrectAccessKey]: {}; | ||
@@ -56,0 +58,0 @@ [BasedErrorCode.MissingAuthStateProtocolHeader]: {}; |
@@ -28,3 +28,4 @@ "use strict"; | ||
BasedErrorCode[BasedErrorCode["IncorrectAccessKey"] = 40031] = "IncorrectAccessKey"; | ||
BasedErrorCode[BasedErrorCode["Block"] = 90001] = "Block"; | ||
})(BasedErrorCode = exports.BasedErrorCode || (exports.BasedErrorCode = {})); | ||
//# sourceMappingURL=types.js.map |
@@ -43,2 +43,5 @@ "use strict"; | ||
} | ||
else { | ||
this.updateConfig({}); | ||
} | ||
} | ||
@@ -45,0 +48,0 @@ updateConfig(fullConfig) { |
@@ -48,3 +48,3 @@ "use strict"; | ||
const name = channel.name; | ||
const route = (0, verifyRoute_1.verifyRoute)(server, ctx, 'channel', server.functions.route(name), name); | ||
const route = (0, verifyRoute_1.verifyRoute)(server, ctx, 'channel', server.functions.route(name), name, id); | ||
if (route === null) { | ||
@@ -51,0 +51,0 @@ return true; |
@@ -48,3 +48,3 @@ "use strict"; | ||
} | ||
const route = (0, verifyRoute_1.verifyRoute)(server, ctx, 'channel', server.functions.route(name), name); | ||
const route = (0, verifyRoute_1.verifyRoute)(server, ctx, 'channel', server.functions.route(name), name, id); | ||
const tmpRoute = route || { | ||
@@ -51,0 +51,0 @@ rateLimitTokens: 10, |
@@ -11,2 +11,4 @@ "use strict"; | ||
})(IsBlocked || (IsBlocked = {})); | ||
// TODO add tests and put on server | ||
const blockedEvents = new Set(); | ||
const drainRequestCounter = (server) => { | ||
@@ -26,2 +28,9 @@ server.requestsCounterInProgress = true; | ||
} | ||
if (blockedEvents.size) { | ||
server.emit('error', server.client.ctx, { | ||
code: error_1.BasedErrorCode.Block, | ||
blockedEvents, | ||
}); | ||
blockedEvents.clear(); | ||
} | ||
}, 30e3); | ||
@@ -78,2 +87,5 @@ }; | ||
if (server.blockedIps.has(ip)) { | ||
if (blockedEvents.size < 1e3) { | ||
blockedEvents.add(ip); | ||
} | ||
res.close(); | ||
@@ -80,0 +92,0 @@ return true; |
{ | ||
"name": "@based/server", | ||
"version": "6.2.4", | ||
"version": "6.2.5", | ||
"license": "MIT", | ||
@@ -5,0 +5,0 @@ "main": "./dist/index.js", |
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
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
379820
5740