@adonisjs/http-server 5.5.7 → 5.7.0
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/LICENSE.md +1 -1
- package/build/adonis-typings/cookie-client.d.ts +4 -16
- package/build/adonis-typings/request.d.ts +1 -1
- package/build/adonis-typings/route.d.ts +1 -0
- package/build/src/Cookie/Client/index.d.ts +2 -3
- package/build/src/Cookie/Client/index.js +25 -38
- package/build/src/Router/Matchers.d.ts +1 -0
- package/build/src/Router/Matchers.js +4 -1
- package/build/src/Server/index.js +7 -6
- package/package.json +85 -36
package/LICENSE.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# The MIT License
|
|
2
2
|
|
|
3
|
-
Copyright
|
|
3
|
+
Copyright 2022 Harminder Virk, contributors
|
|
4
4
|
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
6
6
|
|
|
@@ -15,31 +15,19 @@ declare module '@ioc:Adonis/Core/CookieClient' {
|
|
|
15
15
|
/**
|
|
16
16
|
* Parse the set-cookie header
|
|
17
17
|
*/
|
|
18
|
-
parse(
|
|
19
|
-
name: string;
|
|
20
|
-
value: any;
|
|
21
|
-
encrypted: boolean;
|
|
22
|
-
signed: boolean;
|
|
23
|
-
path?: string;
|
|
24
|
-
expires?: Date;
|
|
25
|
-
maxAge?: number;
|
|
26
|
-
domain?: string;
|
|
27
|
-
secure?: boolean;
|
|
28
|
-
httpOnly?: boolean;
|
|
29
|
-
sameSite?: 'lax' | 'none' | 'strict';
|
|
30
|
-
}[];
|
|
18
|
+
parse(key: string, value: string): any | null;
|
|
31
19
|
/**
|
|
32
20
|
* Unsign a signed cookie value
|
|
33
21
|
*/
|
|
34
|
-
unsign(key: string, value: string): any;
|
|
22
|
+
unsign(key: string, value: string): any | null;
|
|
35
23
|
/**
|
|
36
24
|
* Decrypt an encrypted cookie value
|
|
37
25
|
*/
|
|
38
|
-
decrypt(key: string, value: string): any;
|
|
26
|
+
decrypt(key: string, value: string): any | null;
|
|
39
27
|
/**
|
|
40
28
|
* Decode an encoded cookie value
|
|
41
29
|
*/
|
|
42
|
-
decode(key: string, value: string): any;
|
|
30
|
+
decode(key: string, value: string): any | null;
|
|
43
31
|
}
|
|
44
32
|
const CookieClient: CookieClientContract;
|
|
45
33
|
export default CookieClient;
|
|
@@ -534,7 +534,7 @@ declare module '@ioc:Adonis/Core/Request' {
|
|
|
534
534
|
* Shape of the request config
|
|
535
535
|
*/
|
|
536
536
|
export type RequestConfig = {
|
|
537
|
-
forceContentNegotiationTo?: string;
|
|
537
|
+
forceContentNegotiationTo?: string | ((ctx: HttpContextContract) => string);
|
|
538
538
|
subdomainOffset: number;
|
|
539
539
|
generateRequestId: boolean;
|
|
540
540
|
allowMethodSpoofing: boolean;
|
|
@@ -33,8 +33,7 @@ export declare class CookieClient implements CookieClientContract {
|
|
|
33
33
|
*/
|
|
34
34
|
decode(_: string, value: string): any;
|
|
35
35
|
/**
|
|
36
|
-
*
|
|
37
|
-
* array of parsed cookies
|
|
36
|
+
* Parse response cookie
|
|
38
37
|
*/
|
|
39
|
-
parse(
|
|
38
|
+
parse(key: string, value: any): any;
|
|
40
39
|
}
|
|
@@ -9,7 +9,11 @@
|
|
|
9
9
|
*/
|
|
10
10
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
11
11
|
if (k2 === undefined) k2 = k;
|
|
12
|
-
Object.
|
|
12
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
13
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
14
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
15
|
+
}
|
|
16
|
+
Object.defineProperty(o, k2, desc);
|
|
13
17
|
}) : (function(o, m, k, k2) {
|
|
14
18
|
if (k2 === undefined) k2 = k;
|
|
15
19
|
o[k2] = m[k];
|
|
@@ -26,13 +30,8 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
26
30
|
__setModuleDefault(result, mod);
|
|
27
31
|
return result;
|
|
28
32
|
};
|
|
29
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
30
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
31
|
-
};
|
|
32
33
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
33
34
|
exports.CookieClient = void 0;
|
|
34
|
-
/// <reference path="../../../adonis-typings/index.ts" />
|
|
35
|
-
const set_cookie_parser_1 = __importDefault(require("set-cookie-parser"));
|
|
36
35
|
const PlainCookie = __importStar(require("../Drivers/Plain"));
|
|
37
36
|
const SignedCookie = __importStar(require("../Drivers/Signed"));
|
|
38
37
|
const EncryptedCookie = __importStar(require("../Drivers/Encrypted"));
|
|
@@ -83,39 +82,27 @@ class CookieClient {
|
|
|
83
82
|
return PlainCookie.canUnpack(value) ? PlainCookie.unpack(value) : null;
|
|
84
83
|
}
|
|
85
84
|
/**
|
|
86
|
-
*
|
|
87
|
-
* array of parsed cookies
|
|
85
|
+
* Parse response cookie
|
|
88
86
|
*/
|
|
89
|
-
parse(
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
cookie.encrypted = true;
|
|
109
|
-
return cookie;
|
|
110
|
-
}
|
|
111
|
-
/**
|
|
112
|
-
* Decode encoded cookie
|
|
113
|
-
*/
|
|
114
|
-
if (PlainCookie.canUnpack(value)) {
|
|
115
|
-
cookie.value = PlainCookie.unpack(value);
|
|
116
|
-
}
|
|
117
|
-
return cookie;
|
|
118
|
-
});
|
|
87
|
+
parse(key, value) {
|
|
88
|
+
/**
|
|
89
|
+
* Unsign signed cookie
|
|
90
|
+
*/
|
|
91
|
+
if (SignedCookie.canUnpack(value)) {
|
|
92
|
+
return SignedCookie.unpack(key, value, this.encryption);
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Decrypted encrypted cookie
|
|
96
|
+
*/
|
|
97
|
+
if (EncryptedCookie.canUnpack(value)) {
|
|
98
|
+
return EncryptedCookie.unpack(key, value, this.encryption);
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Decode encoded cookie
|
|
102
|
+
*/
|
|
103
|
+
if (PlainCookie.canUnpack(value)) {
|
|
104
|
+
return PlainCookie.unpack(value);
|
|
105
|
+
}
|
|
119
106
|
}
|
|
120
107
|
}
|
|
121
108
|
exports.CookieClient = CookieClient;
|
|
@@ -26,7 +26,10 @@ class RouteMatchers extends macroable_1.Macroable {
|
|
|
26
26
|
* Enforce value to be formatted as uuid
|
|
27
27
|
*/
|
|
28
28
|
uuid() {
|
|
29
|
-
return {
|
|
29
|
+
return {
|
|
30
|
+
match: /^[0-9a-zA-F]{8}-[0-9a-zA-F]{4}-[0-9a-zA-F]{4}-[0-9a-zA-F]{4}-[0-9a-zA-F]{12}$/,
|
|
31
|
+
cast: (value) => value.toLowerCase(),
|
|
32
|
+
};
|
|
30
33
|
}
|
|
31
34
|
/**
|
|
32
35
|
* Enforce value to be formatted as slug
|
|
@@ -153,16 +153,17 @@ class Server {
|
|
|
153
153
|
* server
|
|
154
154
|
*/
|
|
155
155
|
async handle(req, res) {
|
|
156
|
-
/*
|
|
157
|
-
* Reset accept header when `forceContentNegotiationToJSON = true`
|
|
158
|
-
*/
|
|
159
|
-
if (this.httpConfig.forceContentNegotiationTo) {
|
|
160
|
-
req.headers['accept'] = this.httpConfig.forceContentNegotiationTo;
|
|
161
|
-
}
|
|
162
156
|
const request = new Request_1.Request(req, res, this.encryption, this.httpConfig);
|
|
163
157
|
const response = new Response_1.Response(req, res, this.encryption, this.httpConfig, this.router);
|
|
164
158
|
const requestAction = this.getProfilerRow(request);
|
|
165
159
|
const ctx = this.getContext(request, response, requestAction);
|
|
160
|
+
/*
|
|
161
|
+
* Reset accept header when `forceContentNegotiationTo` is defined
|
|
162
|
+
*/
|
|
163
|
+
const accept = this.httpConfig.forceContentNegotiationTo;
|
|
164
|
+
if (accept) {
|
|
165
|
+
req.headers['accept'] = typeof accept === 'function' ? accept(ctx) : accept;
|
|
166
|
+
}
|
|
166
167
|
if (LocalStorage_1.usingAsyncLocalStorage) {
|
|
167
168
|
return LocalStorage_1.httpContextLocalStorage.run(ctx, () => this.handleRequest(ctx, requestAction, res));
|
|
168
169
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adonisjs/http-server",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.7.0",
|
|
4
4
|
"description": "AdonisJS HTTP server with support packed with Routing and Cookies",
|
|
5
5
|
"main": "build/providers/HttpServerProvider.js",
|
|
6
6
|
"files": [
|
|
@@ -14,14 +14,14 @@
|
|
|
14
14
|
"scripts": {
|
|
15
15
|
"mrm": "mrm --preset=@adonisjs/mrm-preset",
|
|
16
16
|
"pretest": "npm run lint",
|
|
17
|
-
"test": "node
|
|
18
|
-
"clean": "del build",
|
|
17
|
+
"test": "node -r ts-node/register/transpile-only bin/test.ts",
|
|
18
|
+
"clean": "del-cli build",
|
|
19
19
|
"compile": "npm run lint && npm run clean && tsc",
|
|
20
20
|
"build": "npm run compile",
|
|
21
21
|
"benchmark": "ENV_SILENT=true node build/benchmarks/index.js",
|
|
22
22
|
"build:tmp": "npm run compile",
|
|
23
23
|
"commit": "git-cz",
|
|
24
|
-
"release": "np",
|
|
24
|
+
"release": "np --message=\"chore(release): %s\"",
|
|
25
25
|
"version": "npm run build",
|
|
26
26
|
"prepublishOnly": "npm run build",
|
|
27
27
|
"lint": "eslint . --ext=.ts",
|
|
@@ -36,38 +36,44 @@
|
|
|
36
36
|
"author": "virk,adonisjs",
|
|
37
37
|
"license": "MIT",
|
|
38
38
|
"devDependencies": {
|
|
39
|
-
"@adonisjs/application": "^5.
|
|
40
|
-
"@adonisjs/encryption": "^4.0.
|
|
41
|
-
"@adonisjs/mrm-preset": "^
|
|
42
|
-
"@adonisjs/require-ts": "^2.0.
|
|
43
|
-
"@
|
|
39
|
+
"@adonisjs/application": "^5.2.0",
|
|
40
|
+
"@adonisjs/encryption": "^4.0.7",
|
|
41
|
+
"@adonisjs/mrm-preset": "^5.0.3",
|
|
42
|
+
"@adonisjs/require-ts": "^2.0.10",
|
|
43
|
+
"@japa/assert": "^1.3.0",
|
|
44
|
+
"@japa/run-failed-tests": "^1.0.5",
|
|
45
|
+
"@japa/runner": "^2.0.3",
|
|
46
|
+
"@japa/spec-reporter": "^1.1.10",
|
|
47
|
+
"@poppinss/dev-utils": "^2.0.2",
|
|
44
48
|
"@types/cookie": "^0.4.1",
|
|
45
49
|
"@types/ms": "^0.7.31",
|
|
46
|
-
"@types/node": "^
|
|
50
|
+
"@types/node": "^17.0.22",
|
|
47
51
|
"@types/pluralize": "0.0.29",
|
|
48
52
|
"@types/proxy-addr": "^2.0.0",
|
|
49
53
|
"@types/qs": "^6.9.7",
|
|
50
|
-
"@types/supertest": "^2.0.
|
|
51
|
-
"autocannon": "^7.
|
|
54
|
+
"@types/supertest": "^2.0.12",
|
|
55
|
+
"autocannon": "^7.7.2",
|
|
56
|
+
"commitizen": "^4.2.4",
|
|
52
57
|
"cross-env": "^7.0.3",
|
|
58
|
+
"cz-conventional-changelog": "^3.3.0",
|
|
53
59
|
"del-cli": "^4.0.1",
|
|
54
|
-
"eslint": "^
|
|
55
|
-
"eslint-config-prettier": "^8.
|
|
56
|
-
"eslint-plugin-adonis": "^1.
|
|
60
|
+
"eslint": "^8.11.0",
|
|
61
|
+
"eslint-config-prettier": "^8.5.0",
|
|
62
|
+
"eslint-plugin-adonis": "^2.1.0",
|
|
57
63
|
"eslint-plugin-prettier": "^4.0.0",
|
|
58
|
-
"fastify": "^3.
|
|
64
|
+
"fastify": "^3.27.4",
|
|
59
65
|
"github-label-sync": "^2.0.2",
|
|
60
|
-
"http-status-codes": "^2.
|
|
61
|
-
"husky": "^7.0.
|
|
62
|
-
"
|
|
63
|
-
"
|
|
64
|
-
"
|
|
65
|
-
"
|
|
66
|
-
"
|
|
67
|
-
"prettier": "^2.3.2",
|
|
66
|
+
"http-status-codes": "^2.2.0",
|
|
67
|
+
"husky": "^7.0.4",
|
|
68
|
+
"middie": "^6.0.0",
|
|
69
|
+
"mrm": "^4.0.0",
|
|
70
|
+
"np": "^7.6.1",
|
|
71
|
+
"pem": "^1.14.6",
|
|
72
|
+
"prettier": "^2.6.0",
|
|
68
73
|
"reflect-metadata": "^0.1.13",
|
|
69
|
-
"supertest": "^6.
|
|
70
|
-
"
|
|
74
|
+
"supertest": "^6.2.2",
|
|
75
|
+
"ts-node": "^10.7.0",
|
|
76
|
+
"typescript": "^4.6.2"
|
|
71
77
|
},
|
|
72
78
|
"peerDependencies": {
|
|
73
79
|
"@adonisjs/application": "^5.0.0",
|
|
@@ -92,23 +98,23 @@
|
|
|
92
98
|
},
|
|
93
99
|
"dependencies": {
|
|
94
100
|
"@poppinss/matchit": "^3.1.2",
|
|
95
|
-
"@poppinss/utils": "^
|
|
96
|
-
"accepts": "^1.3.
|
|
97
|
-
"co-compose": "^
|
|
98
|
-
"content-disposition": "^0.5.
|
|
99
|
-
"cookie": "^0.4.
|
|
100
|
-
"destroy": "^1.0
|
|
101
|
+
"@poppinss/utils": "^4.0.2",
|
|
102
|
+
"accepts": "^1.3.8",
|
|
103
|
+
"co-compose": "^7.0.1",
|
|
104
|
+
"content-disposition": "^0.5.4",
|
|
105
|
+
"cookie": "^0.4.2",
|
|
106
|
+
"destroy": "^1.2.0",
|
|
101
107
|
"encodeurl": "^1.0.2",
|
|
102
108
|
"etag": "^1.8.1",
|
|
103
109
|
"fresh": "^0.5.2",
|
|
104
110
|
"haye": "^3.0.0",
|
|
105
|
-
"macroable": "^
|
|
106
|
-
"mime-types": "^2.1.
|
|
111
|
+
"macroable": "^6.0.1",
|
|
112
|
+
"mime-types": "^2.1.35",
|
|
107
113
|
"ms": "^2.1.3",
|
|
108
|
-
"on-finished": "^2.
|
|
114
|
+
"on-finished": "^2.4.1",
|
|
109
115
|
"pluralize": "^8.0.0",
|
|
110
116
|
"proxy-addr": "^2.0.7",
|
|
111
|
-
"qs": "^6.10.
|
|
117
|
+
"qs": "^6.10.3",
|
|
112
118
|
"set-cookie-parser": "^2.4.8",
|
|
113
119
|
"tmp-cache": "^1.1.0",
|
|
114
120
|
"type-is": "^1.6.18",
|
|
@@ -132,5 +138,48 @@
|
|
|
132
138
|
"publishConfig": {
|
|
133
139
|
"access": "public",
|
|
134
140
|
"tag": "latest"
|
|
141
|
+
},
|
|
142
|
+
"mrmConfig": {
|
|
143
|
+
"core": true,
|
|
144
|
+
"license": "MIT",
|
|
145
|
+
"services": [
|
|
146
|
+
"github-actions"
|
|
147
|
+
],
|
|
148
|
+
"minNodeVersion": "14.15.4",
|
|
149
|
+
"probotApps": [
|
|
150
|
+
"stale",
|
|
151
|
+
"lock"
|
|
152
|
+
],
|
|
153
|
+
"runGhActionsOnWindows": false
|
|
154
|
+
},
|
|
155
|
+
"eslintConfig": {
|
|
156
|
+
"extends": [
|
|
157
|
+
"plugin:adonis/typescriptPackage",
|
|
158
|
+
"prettier"
|
|
159
|
+
],
|
|
160
|
+
"plugins": [
|
|
161
|
+
"prettier"
|
|
162
|
+
],
|
|
163
|
+
"rules": {
|
|
164
|
+
"prettier/prettier": [
|
|
165
|
+
"error",
|
|
166
|
+
{
|
|
167
|
+
"endOfLine": "auto"
|
|
168
|
+
}
|
|
169
|
+
]
|
|
170
|
+
}
|
|
171
|
+
},
|
|
172
|
+
"eslintIgnore": [
|
|
173
|
+
"build"
|
|
174
|
+
],
|
|
175
|
+
"prettier": {
|
|
176
|
+
"trailingComma": "es5",
|
|
177
|
+
"semi": false,
|
|
178
|
+
"singleQuote": true,
|
|
179
|
+
"useTabs": false,
|
|
180
|
+
"quoteProps": "consistent",
|
|
181
|
+
"bracketSpacing": true,
|
|
182
|
+
"arrowParens": "always",
|
|
183
|
+
"printWidth": 100
|
|
135
184
|
}
|
|
136
185
|
}
|