fastify-txstate 3.1.1 → 3.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/index.js +3 -3
- package/lib-esm/index.d.ts +1 -1
- package/lib-esm/index.js +2 -0
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -90,7 +90,7 @@ class Server {
|
|
|
90
90
|
let passed = this.validOrigins[req.headers.origin];
|
|
91
91
|
if (!passed && req.headers.origin === 'null')
|
|
92
92
|
passed = process.env.NODE_ENV === 'development';
|
|
93
|
-
if (!passed) {
|
|
93
|
+
else if (!passed) {
|
|
94
94
|
const parsedOrigin = new URL(req.headers.origin);
|
|
95
95
|
if (req.hostname.replace(/:\d+$/, '') === parsedOrigin.hostname)
|
|
96
96
|
passed = true;
|
|
@@ -104,9 +104,9 @@ class Server {
|
|
|
104
104
|
passed = true;
|
|
105
105
|
}
|
|
106
106
|
}
|
|
107
|
-
if (!passed && ((_a = config.checkOrigin) === null || _a === void 0 ? void 0 : _a.call(config, req)))
|
|
108
|
-
passed = true;
|
|
109
107
|
}
|
|
108
|
+
if (!passed && ((_a = config.checkOrigin) === null || _a === void 0 ? void 0 : _a.call(config, req)))
|
|
109
|
+
passed = true;
|
|
110
110
|
if (!passed) {
|
|
111
111
|
await res.status(403).send('Origin check failed. Suspected XSRF attack.');
|
|
112
112
|
return res;
|
package/lib-esm/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { FastifyInstance, FastifyRequest, FastifyReply, FastifyServerOptions, FastifyLoggerOptions } from 'fastify';
|
|
3
3
|
import http2 from 'http2';
|
|
4
|
-
|
|
4
|
+
type ErrorHandler = (error: Error, req: FastifyRequest, res: FastifyReply) => Promise<void>;
|
|
5
5
|
export interface FastifyTxStateOptions extends Partial<FastifyServerOptions> {
|
|
6
6
|
https?: http2.SecureServerOptions;
|
|
7
7
|
validOrigins?: string[];
|
package/lib-esm/index.js
CHANGED