@jitar-plugins/http 0.1.0 → 0.1.1
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/dist/OriginMiddleware.js +7 -11
- package/package.json +2 -3
package/dist/OriginMiddleware.js
CHANGED
|
@@ -1,14 +1,5 @@
|
|
|
1
1
|
import { BadRequest } from 'jitar';
|
|
2
|
-
import validator from '@theshelf/validation';
|
|
3
2
|
const ORIGIN_COOKIE_NAME = 'x-client-origin';
|
|
4
|
-
const schema = {
|
|
5
|
-
origin: {
|
|
6
|
-
message: 'Invalid origin',
|
|
7
|
-
URL: {
|
|
8
|
-
required: true
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
};
|
|
12
3
|
export default class OriginMiddleware {
|
|
13
4
|
async handle(request, next) {
|
|
14
5
|
let fromCookie = true;
|
|
@@ -42,8 +33,13 @@ export default class OriginMiddleware {
|
|
|
42
33
|
}
|
|
43
34
|
}
|
|
44
35
|
#validateOriginValue(value) {
|
|
45
|
-
|
|
46
|
-
|
|
36
|
+
if (value === undefined) {
|
|
37
|
+
throw new BadRequest('Invalid origin');
|
|
38
|
+
}
|
|
39
|
+
try {
|
|
40
|
+
new URL(value);
|
|
41
|
+
}
|
|
42
|
+
catch {
|
|
47
43
|
throw new BadRequest('Invalid origin');
|
|
48
44
|
}
|
|
49
45
|
}
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jitar-plugins/http",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.1",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"repository": {
|
|
7
|
-
"url": "https://github.com/MaskingTechnology/jitar-plugins"
|
|
7
|
+
"url": "git+https://github.com/MaskingTechnology/jitar-plugins.git"
|
|
8
8
|
},
|
|
9
9
|
"scripts": {
|
|
10
10
|
"build": "tsc",
|
|
@@ -20,7 +20,6 @@
|
|
|
20
20
|
"types": "dist/index.d.ts",
|
|
21
21
|
"exports": "./dist/index.js",
|
|
22
22
|
"peerDependencies": {
|
|
23
|
-
"@theshelf/validation": "^0.1.0",
|
|
24
23
|
"jitar": "^0.10.4"
|
|
25
24
|
}
|
|
26
25
|
}
|