@adonisjs/http-server 5.11.0 → 6.0.0-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/README.md +15 -38
- package/build/index.d.ts +16 -0
- package/build/index.js +16 -0
- package/build/src/cookies/client.d.ts +12 -0
- package/build/src/cookies/client.js +42 -0
- package/build/src/cookies/drivers/encrypted.d.ts +4 -0
- package/build/src/cookies/drivers/encrypted.js +16 -0
- package/build/src/cookies/drivers/plain.d.ts +3 -0
- package/build/src/cookies/drivers/plain.js +13 -0
- package/build/src/cookies/drivers/signed.d.ts +4 -0
- package/build/src/cookies/drivers/signed.js +16 -0
- package/build/src/cookies/parser.d.ts +9 -0
- package/build/src/cookies/parser.js +69 -0
- package/build/src/cookies/serializer.d.ts +11 -0
- package/build/src/cookies/serializer.js +39 -0
- package/build/src/debug.d.ts +3 -0
- package/build/src/debug.js +2 -0
- package/build/src/define_config.d.ts +2 -0
- package/build/src/define_config.js +40 -0
- package/build/src/define_middleware.d.ts +4 -0
- package/build/src/define_middleware.js +6 -0
- package/build/src/exceptions/abort_exception.d.ts +5 -0
- package/build/src/exceptions/abort_exception.js +6 -0
- package/build/src/exceptions/cannot_lookup_route.d.ts +5 -0
- package/build/src/exceptions/cannot_lookup_route.js +5 -0
- package/build/src/exceptions/http_exception.d.ts +6 -0
- package/build/src/exceptions/http_exception.js +20 -0
- package/build/src/exceptions/route_not_found.d.ts +5 -0
- package/build/src/exceptions/route_not_found.js +5 -0
- package/build/src/helpers.d.ts +6 -67
- package/build/src/helpers.js +13 -168
- package/build/src/http_context/local_storage.d.ts +9 -0
- package/build/src/http_context/local_storage.js +14 -0
- package/build/src/http_context/main.d.ts +20 -0
- package/build/src/http_context/main.js +49 -0
- package/build/src/middleware/store.d.ts +11 -0
- package/build/src/middleware/store.js +33 -0
- package/build/src/qs.d.ts +7 -0
- package/build/src/qs.js +13 -0
- package/build/src/redirect.d.ts +18 -0
- package/build/src/redirect.js +80 -0
- package/build/src/request.d.ts +81 -0
- package/build/src/request.js +315 -0
- package/build/src/response.d.ts +108 -0
- package/build/src/response.js +587 -0
- package/build/src/router/brisk.d.ts +18 -0
- package/build/src/router/brisk.js +35 -0
- package/build/src/router/executor.d.ts +4 -0
- package/build/src/router/executor.js +16 -0
- package/build/src/router/group.d.ts +19 -0
- package/build/src/router/group.js +117 -0
- package/build/src/router/lookup_store/main.d.ts +17 -0
- package/build/src/router/lookup_store/main.js +37 -0
- package/build/src/router/lookup_store/route_finder.d.ts +8 -0
- package/build/src/router/lookup_store/route_finder.js +28 -0
- package/build/src/router/lookup_store/url_builder.d.ts +16 -0
- package/build/src/router/lookup_store/url_builder.js +111 -0
- package/build/src/router/main.d.ts +36 -0
- package/build/src/router/main.js +161 -0
- package/build/src/router/matchers.d.ts +14 -0
- package/build/src/router/matchers.js +15 -0
- package/build/src/router/resource.d.ts +27 -0
- package/build/src/router/resource.js +124 -0
- package/build/src/router/route.d.ts +28 -0
- package/build/src/router/route.js +135 -0
- package/build/src/router/store.d.ts +12 -0
- package/build/src/router/store.js +87 -0
- package/build/src/server/factories/final_handler.d.ts +4 -0
- package/build/src/server/factories/final_handler.js +17 -0
- package/build/src/server/factories/middleware_handler.d.ts +5 -0
- package/build/src/server/factories/middleware_handler.js +5 -0
- package/build/src/server/factories/use_return_value.d.ts +2 -0
- package/build/src/server/factories/use_return_value.js +9 -0
- package/build/src/server/factories/write_response.d.ts +2 -0
- package/build/src/server/factories/write_response.js +12 -0
- package/build/src/server/main.d.ts +23 -0
- package/build/src/server/main.js +124 -0
- package/build/src/types/base.d.ts +5 -0
- package/build/src/types/base.js +1 -0
- package/build/src/types/middleware.d.ts +14 -0
- package/build/src/types/middleware.js +1 -0
- package/build/src/types/qs.d.ts +15 -0
- package/build/src/types/qs.js +1 -0
- package/build/src/types/request.d.ts +7 -0
- package/build/src/types/request.js +1 -0
- package/build/src/types/response.d.ts +18 -0
- package/build/src/types/response.js +1 -0
- package/build/src/types/route.d.ts +74 -0
- package/build/src/types/route.js +1 -0
- package/build/src/types/server.d.ts +13 -0
- package/build/src/types/server.js +1 -0
- package/package.json +98 -96
- package/build/adonis-typings/container.d.ts +0 -24
- package/build/adonis-typings/container.js +0 -8
- package/build/adonis-typings/context.d.ts +0 -73
- package/build/adonis-typings/context.js +0 -8
- package/build/adonis-typings/cookie-client.d.ts +0 -34
- package/build/adonis-typings/cookie-client.js +0 -8
- package/build/adonis-typings/http-server.d.ts +0 -98
- package/build/adonis-typings/http-server.js +0 -8
- package/build/adonis-typings/index.d.ts +0 -16
- package/build/adonis-typings/index.js +0 -16
- package/build/adonis-typings/middleware.d.ts +0 -95
- package/build/adonis-typings/middleware.js +0 -8
- package/build/adonis-typings/request.d.ts +0 -556
- package/build/adonis-typings/request.js +0 -8
- package/build/adonis-typings/response.d.ts +0 -438
- package/build/adonis-typings/response.js +0 -8
- package/build/adonis-typings/route.d.ts +0 -559
- package/build/adonis-typings/route.js +0 -8
- package/build/exceptions.json +0 -110
- package/build/providers/HttpServerProvider.d.ts +0 -46
- package/build/providers/HttpServerProvider.js +0 -100
- package/build/src/Cookie/Client/index.d.ts +0 -39
- package/build/src/Cookie/Client/index.js +0 -108
- package/build/src/Cookie/Drivers/Encrypted.d.ts +0 -24
- package/build/src/Cookie/Drivers/Encrypted.js +0 -42
- package/build/src/Cookie/Drivers/Plain.d.ts +0 -23
- package/build/src/Cookie/Drivers/Plain.js +0 -40
- package/build/src/Cookie/Drivers/Signed.d.ts +0 -24
- package/build/src/Cookie/Drivers/Signed.js +0 -42
- package/build/src/Cookie/Parser/index.d.ts +0 -61
- package/build/src/Cookie/Parser/index.js +0 -174
- package/build/src/Cookie/Serializer/index.d.ts +0 -44
- package/build/src/Cookie/Serializer/index.js +0 -88
- package/build/src/Exceptions/HttpException.d.ts +0 -20
- package/build/src/Exceptions/HttpException.js +0 -36
- package/build/src/Exceptions/RouterException.d.ts +0 -36
- package/build/src/Exceptions/RouterException.js +0 -76
- package/build/src/HttpContext/LocalStorage/index.d.ts +0 -24
- package/build/src/HttpContext/LocalStorage/index.js +0 -28
- package/build/src/HttpContext/index.d.ts +0 -90
- package/build/src/HttpContext/index.js +0 -181
- package/build/src/MiddlewareStore/index.d.ts +0 -92
- package/build/src/MiddlewareStore/index.js +0 -133
- package/build/src/Redirect/index.d.ts +0 -71
- package/build/src/Redirect/index.js +0 -139
- package/build/src/Request/index.d.ts +0 -619
- package/build/src/Request/index.js +0 -862
- package/build/src/Response/index.d.ts +0 -412
- package/build/src/Response/index.js +0 -1010
- package/build/src/Router/BriskRoute.d.ts +0 -53
- package/build/src/Router/BriskRoute.js +0 -74
- package/build/src/Router/Group.d.ts +0 -101
- package/build/src/Router/Group.js +0 -165
- package/build/src/Router/LookupStore.d.ts +0 -122
- package/build/src/Router/LookupStore.js +0 -264
- package/build/src/Router/Matchers.d.ts +0 -31
- package/build/src/Router/Matchers.js +0 -43
- package/build/src/Router/Resource.d.ts +0 -95
- package/build/src/Router/Resource.js +0 -182
- package/build/src/Router/Route.d.ts +0 -138
- package/build/src/Router/Route.js +0 -204
- package/build/src/Router/Store.d.ts +0 -93
- package/build/src/Router/Store.js +0 -211
- package/build/src/Router/index.d.ts +0 -142
- package/build/src/Router/index.js +0 -333
- package/build/src/Server/ExceptionManager/index.d.ts +0 -49
- package/build/src/Server/ExceptionManager/index.js +0 -96
- package/build/src/Server/Hooks/index.d.ts +0 -43
- package/build/src/Server/Hooks/index.js +0 -77
- package/build/src/Server/PreCompiler/index.d.ts +0 -60
- package/build/src/Server/PreCompiler/index.js +0 -141
- package/build/src/Server/RequestHandler/index.d.ts +0 -39
- package/build/src/Server/RequestHandler/index.js +0 -87
- package/build/src/Server/index.d.ts +0 -90
- package/build/src/Server/index.js +0 -175
- package/build/standalone.d.ts +0 -14
- package/build/standalone.js +0 -23
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @adonisjs/http-server
|
|
3
|
-
*
|
|
4
|
-
* (c) Harminder Virk <virk@adonisjs.com>
|
|
5
|
-
*
|
|
6
|
-
* For the full copyright and license information, please view the LICENSE
|
|
7
|
-
* file that was distributed with this source code.
|
|
8
|
-
*/
|
|
9
|
-
import { ApplicationContract } from '@ioc:Adonis/Core/Application';
|
|
10
|
-
export default class HttpServerProvider {
|
|
11
|
-
protected application: ApplicationContract;
|
|
12
|
-
constructor(application: ApplicationContract);
|
|
13
|
-
/**
|
|
14
|
-
* Validate server config to ensure we start with sane defaults
|
|
15
|
-
*/
|
|
16
|
-
private validateServerConfig;
|
|
17
|
-
/**
|
|
18
|
-
* Register request and response bindings to the container
|
|
19
|
-
*/
|
|
20
|
-
protected registerRequestResponse(): void;
|
|
21
|
-
/**
|
|
22
|
-
* Registering middleware store to the container
|
|
23
|
-
*/
|
|
24
|
-
protected registerMiddlewareStore(): void;
|
|
25
|
-
/**
|
|
26
|
-
* Registering the HTTP context
|
|
27
|
-
*/
|
|
28
|
-
protected registerHTTPContext(): void;
|
|
29
|
-
/**
|
|
30
|
-
* Register the HTTP server
|
|
31
|
-
*/
|
|
32
|
-
protected registerHttpServer(): void;
|
|
33
|
-
/**
|
|
34
|
-
* Register the router. The router points to the instance of router used
|
|
35
|
-
* by the middleware
|
|
36
|
-
*/
|
|
37
|
-
protected registerRouter(): void;
|
|
38
|
-
/**
|
|
39
|
-
* Registers the cookie client with the container
|
|
40
|
-
*/
|
|
41
|
-
protected registerCookieClient(): void;
|
|
42
|
-
/**
|
|
43
|
-
* Registering all bindings
|
|
44
|
-
*/
|
|
45
|
-
register(): void;
|
|
46
|
-
}
|
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* @adonisjs/http-server
|
|
4
|
-
*
|
|
5
|
-
* (c) Harminder Virk <virk@adonisjs.com>
|
|
6
|
-
*
|
|
7
|
-
* For the full copyright and license information, please view the LICENSE
|
|
8
|
-
* file that was distributed with this source code.
|
|
9
|
-
*/
|
|
10
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
-
const utils_1 = require("@poppinss/utils");
|
|
12
|
-
class HttpServerProvider {
|
|
13
|
-
constructor(application) {
|
|
14
|
-
this.application = application;
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* Validate server config to ensure we start with sane defaults
|
|
18
|
-
*/
|
|
19
|
-
validateServerConfig(config) {
|
|
20
|
-
if (!config.cookie || typeof config.cookie !== 'object') {
|
|
21
|
-
throw new utils_1.Exception('Missing "cookie" config inside the "http" block in "config/app" file.');
|
|
22
|
-
}
|
|
23
|
-
if (typeof config.trustProxy !== 'function') {
|
|
24
|
-
throw new utils_1.Exception('Invalid "trustProxy" value inside the "http" block in "config/app" file.');
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* Register request and response bindings to the container
|
|
29
|
-
*/
|
|
30
|
-
registerRequestResponse() {
|
|
31
|
-
this.application.container.singleton('Adonis/Core/Request', () => {
|
|
32
|
-
return require('../src/Request').Request;
|
|
33
|
-
});
|
|
34
|
-
this.application.container.singleton('Adonis/Core/Response', () => {
|
|
35
|
-
return require('../src/Response').Response;
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Registering middleware store to the container
|
|
40
|
-
*/
|
|
41
|
-
registerMiddlewareStore() {
|
|
42
|
-
this.application.container.bind('Adonis/Core/MiddlewareStore', () => {
|
|
43
|
-
return require('../src/MiddlewareStore').MiddlewareStore;
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* Registering the HTTP context
|
|
48
|
-
*/
|
|
49
|
-
registerHTTPContext() {
|
|
50
|
-
this.application.container.bind('Adonis/Core/HttpContext', () => {
|
|
51
|
-
const { HttpContext } = require('../src/HttpContext');
|
|
52
|
-
HttpContext.app = this.application.container.resolveBinding('Adonis/Core/Application');
|
|
53
|
-
return HttpContext;
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* Register the HTTP server
|
|
58
|
-
*/
|
|
59
|
-
registerHttpServer() {
|
|
60
|
-
this.application.container.singleton('Adonis/Core/Server', () => {
|
|
61
|
-
const { Server } = require('../src/Server');
|
|
62
|
-
const Config = this.application.container.resolveBinding('Adonis/Core/Config');
|
|
63
|
-
const Encryption = this.application.container.resolveBinding('Adonis/Core/Encryption');
|
|
64
|
-
const serverConfig = Config.get('app.http', {});
|
|
65
|
-
this.validateServerConfig(serverConfig);
|
|
66
|
-
return new Server(this.application, Encryption, serverConfig);
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
/**
|
|
70
|
-
* Register the router. The router points to the instance of router used
|
|
71
|
-
* by the middleware
|
|
72
|
-
*/
|
|
73
|
-
registerRouter() {
|
|
74
|
-
this.application.container.singleton('Adonis/Core/Route', () => {
|
|
75
|
-
return this.application.container.resolveBinding('Adonis/Core/Server').router;
|
|
76
|
-
});
|
|
77
|
-
}
|
|
78
|
-
/**
|
|
79
|
-
* Registers the cookie client with the container
|
|
80
|
-
*/
|
|
81
|
-
registerCookieClient() {
|
|
82
|
-
this.application.container.singleton('Adonis/Core/CookieClient', () => {
|
|
83
|
-
const { CookieClient } = require('../src/Cookie/Client');
|
|
84
|
-
const Encryption = this.application.container.resolveBinding('Adonis/Core/Encryption');
|
|
85
|
-
return new CookieClient(Encryption);
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
/**
|
|
89
|
-
* Registering all bindings
|
|
90
|
-
*/
|
|
91
|
-
register() {
|
|
92
|
-
this.registerRequestResponse();
|
|
93
|
-
this.registerMiddlewareStore();
|
|
94
|
-
this.registerHttpServer();
|
|
95
|
-
this.registerHTTPContext();
|
|
96
|
-
this.registerRouter();
|
|
97
|
-
this.registerCookieClient();
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
exports.default = HttpServerProvider;
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
/// <reference path="../../../adonis-typings/index.d.ts" />
|
|
2
|
-
import { EncryptionContract } from '@ioc:Adonis/Core/Encryption';
|
|
3
|
-
import { CookieClientContract } from '@ioc:Adonis/Core/CookieClient';
|
|
4
|
-
/**
|
|
5
|
-
* Cookie client exposes the API to parse/set AdonisJS
|
|
6
|
-
* cookies as a client.
|
|
7
|
-
*/
|
|
8
|
-
export declare class CookieClient implements CookieClientContract {
|
|
9
|
-
private encryption;
|
|
10
|
-
constructor(encryption: EncryptionContract);
|
|
11
|
-
/**
|
|
12
|
-
* Encrypt a key value pair to be sent in the cookie header
|
|
13
|
-
*/
|
|
14
|
-
encrypt(key: string, value: any): string | null;
|
|
15
|
-
/**
|
|
16
|
-
* Sign a key value pair to be sent in the cookie header
|
|
17
|
-
*/
|
|
18
|
-
sign(key: string, value: any): string | null;
|
|
19
|
-
/**
|
|
20
|
-
* Encode a key value pair to be sent in the cookie header
|
|
21
|
-
*/
|
|
22
|
-
encode(_: string, value: any): string | null;
|
|
23
|
-
/**
|
|
24
|
-
* Unsign a signed cookie value
|
|
25
|
-
*/
|
|
26
|
-
unsign(key: string, value: string): any;
|
|
27
|
-
/**
|
|
28
|
-
* Decrypt an encrypted cookie value
|
|
29
|
-
*/
|
|
30
|
-
decrypt(key: string, value: string): any;
|
|
31
|
-
/**
|
|
32
|
-
* Decode an encoded cookie value
|
|
33
|
-
*/
|
|
34
|
-
decode(_: string, value: string): any;
|
|
35
|
-
/**
|
|
36
|
-
* Parse response cookie
|
|
37
|
-
*/
|
|
38
|
-
parse(key: string, value: any): any;
|
|
39
|
-
}
|
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*
|
|
3
|
-
* @adonisjs/http-server
|
|
4
|
-
*
|
|
5
|
-
* (c) Harminder Virk <virk@adonisjs.com>
|
|
6
|
-
*
|
|
7
|
-
* For the full copyright and license information, please view the LICENSE
|
|
8
|
-
* file that was distributed with this source code.
|
|
9
|
-
*/
|
|
10
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
11
|
-
if (k2 === undefined) k2 = k;
|
|
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);
|
|
17
|
-
}) : (function(o, m, k, k2) {
|
|
18
|
-
if (k2 === undefined) k2 = k;
|
|
19
|
-
o[k2] = m[k];
|
|
20
|
-
}));
|
|
21
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
22
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
23
|
-
}) : function(o, v) {
|
|
24
|
-
o["default"] = v;
|
|
25
|
-
});
|
|
26
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
27
|
-
if (mod && mod.__esModule) return mod;
|
|
28
|
-
var result = {};
|
|
29
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
30
|
-
__setModuleDefault(result, mod);
|
|
31
|
-
return result;
|
|
32
|
-
};
|
|
33
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
34
|
-
exports.CookieClient = void 0;
|
|
35
|
-
const PlainCookie = __importStar(require("../Drivers/Plain"));
|
|
36
|
-
const SignedCookie = __importStar(require("../Drivers/Signed"));
|
|
37
|
-
const EncryptedCookie = __importStar(require("../Drivers/Encrypted"));
|
|
38
|
-
/**
|
|
39
|
-
* Cookie client exposes the API to parse/set AdonisJS
|
|
40
|
-
* cookies as a client.
|
|
41
|
-
*/
|
|
42
|
-
class CookieClient {
|
|
43
|
-
constructor(encryption) {
|
|
44
|
-
this.encryption = encryption;
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* Encrypt a key value pair to be sent in the cookie header
|
|
48
|
-
*/
|
|
49
|
-
encrypt(key, value) {
|
|
50
|
-
return EncryptedCookie.pack(key, value, this.encryption);
|
|
51
|
-
}
|
|
52
|
-
/**
|
|
53
|
-
* Sign a key value pair to be sent in the cookie header
|
|
54
|
-
*/
|
|
55
|
-
sign(key, value) {
|
|
56
|
-
return SignedCookie.pack(key, value, this.encryption);
|
|
57
|
-
}
|
|
58
|
-
/**
|
|
59
|
-
* Encode a key value pair to be sent in the cookie header
|
|
60
|
-
*/
|
|
61
|
-
encode(_, value) {
|
|
62
|
-
return PlainCookie.pack(value);
|
|
63
|
-
}
|
|
64
|
-
/**
|
|
65
|
-
* Unsign a signed cookie value
|
|
66
|
-
*/
|
|
67
|
-
unsign(key, value) {
|
|
68
|
-
return SignedCookie.canUnpack(value) ? SignedCookie.unpack(key, value, this.encryption) : null;
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
71
|
-
* Decrypt an encrypted cookie value
|
|
72
|
-
*/
|
|
73
|
-
decrypt(key, value) {
|
|
74
|
-
return EncryptedCookie.canUnpack(value)
|
|
75
|
-
? EncryptedCookie.unpack(key, value, this.encryption)
|
|
76
|
-
: null;
|
|
77
|
-
}
|
|
78
|
-
/**
|
|
79
|
-
* Decode an encoded cookie value
|
|
80
|
-
*/
|
|
81
|
-
decode(_, value) {
|
|
82
|
-
return PlainCookie.canUnpack(value) ? PlainCookie.unpack(value) : null;
|
|
83
|
-
}
|
|
84
|
-
/**
|
|
85
|
-
* Parse response cookie
|
|
86
|
-
*/
|
|
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
|
-
}
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
exports.CookieClient = CookieClient;
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @adonisjs/http-server
|
|
3
|
-
*
|
|
4
|
-
* (c) Harminder Virk <virk@adonisjs.com>
|
|
5
|
-
*
|
|
6
|
-
* For the full copyright and license information, please view the LICENSE
|
|
7
|
-
* file that was distributed with this source code.
|
|
8
|
-
*/
|
|
9
|
-
import { EncryptionContract } from '@ioc:Adonis/Core/Encryption';
|
|
10
|
-
/**
|
|
11
|
-
* Encrypt a value to be set as cookie
|
|
12
|
-
*/
|
|
13
|
-
export declare function pack(key: string, value: any, encryption: EncryptionContract): null | string;
|
|
14
|
-
/**
|
|
15
|
-
* Returns a boolean, if the unpack method from this module can attempt
|
|
16
|
-
* to unpack encrypted value.
|
|
17
|
-
*/
|
|
18
|
-
export declare function canUnpack(encryptedValue: string): boolean;
|
|
19
|
-
/**
|
|
20
|
-
* Attempts to unpack the encrypted cookie value. Returns null, when fails to do so.
|
|
21
|
-
* Only call this method, when `canUnpack` returns true, otherwise runtime
|
|
22
|
-
* exceptions can be raised.
|
|
23
|
-
*/
|
|
24
|
-
export declare function unpack(key: string, encryptedValue: string, encryption: EncryptionContract): null | any;
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* @adonisjs/http-server
|
|
4
|
-
*
|
|
5
|
-
* (c) Harminder Virk <virk@adonisjs.com>
|
|
6
|
-
*
|
|
7
|
-
* For the full copyright and license information, please view the LICENSE
|
|
8
|
-
* file that was distributed with this source code.
|
|
9
|
-
*/
|
|
10
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
-
exports.unpack = exports.canUnpack = exports.pack = void 0;
|
|
12
|
-
/**
|
|
13
|
-
* Encrypt a value to be set as cookie
|
|
14
|
-
*/
|
|
15
|
-
function pack(key, value, encryption) {
|
|
16
|
-
if (value === undefined || value === null) {
|
|
17
|
-
return null;
|
|
18
|
-
}
|
|
19
|
-
return `e:${encryption.encrypt(value, undefined, key)}`;
|
|
20
|
-
}
|
|
21
|
-
exports.pack = pack;
|
|
22
|
-
/**
|
|
23
|
-
* Returns a boolean, if the unpack method from this module can attempt
|
|
24
|
-
* to unpack encrypted value.
|
|
25
|
-
*/
|
|
26
|
-
function canUnpack(encryptedValue) {
|
|
27
|
-
return typeof encryptedValue === 'string' && encryptedValue.substr(0, 2) === 'e:';
|
|
28
|
-
}
|
|
29
|
-
exports.canUnpack = canUnpack;
|
|
30
|
-
/**
|
|
31
|
-
* Attempts to unpack the encrypted cookie value. Returns null, when fails to do so.
|
|
32
|
-
* Only call this method, when `canUnpack` returns true, otherwise runtime
|
|
33
|
-
* exceptions can be raised.
|
|
34
|
-
*/
|
|
35
|
-
function unpack(key, encryptedValue, encryption) {
|
|
36
|
-
const value = encryptedValue.slice(2);
|
|
37
|
-
if (!value) {
|
|
38
|
-
return null;
|
|
39
|
-
}
|
|
40
|
-
return encryption.decrypt(value, key);
|
|
41
|
-
}
|
|
42
|
-
exports.unpack = unpack;
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @adonisjs/http-server
|
|
3
|
-
*
|
|
4
|
-
* (c) Harminder Virk <virk@adonisjs.com>
|
|
5
|
-
*
|
|
6
|
-
* For the full copyright and license information, please view the LICENSE
|
|
7
|
-
* file that was distributed with this source code.
|
|
8
|
-
*/
|
|
9
|
-
/**
|
|
10
|
-
* Encodes a value into a base64 url encoded string to
|
|
11
|
-
* be set as cookie
|
|
12
|
-
*/
|
|
13
|
-
export declare function pack(value: any): null | string;
|
|
14
|
-
/**
|
|
15
|
-
* Returns true when this `unpack` method of this module can attempt
|
|
16
|
-
* to unpack the encode value.
|
|
17
|
-
*/
|
|
18
|
-
export declare function canUnpack(encodedValue: string): boolean;
|
|
19
|
-
/**
|
|
20
|
-
* Attempts to unpack the value by decoding it. Make sure to call, `canUnpack`
|
|
21
|
-
* before calling this method
|
|
22
|
-
*/
|
|
23
|
-
export declare function unpack(encodedValue: string): null | any;
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* @adonisjs/http-server
|
|
4
|
-
*
|
|
5
|
-
* (c) Harminder Virk <virk@adonisjs.com>
|
|
6
|
-
*
|
|
7
|
-
* For the full copyright and license information, please view the LICENSE
|
|
8
|
-
* file that was distributed with this source code.
|
|
9
|
-
*/
|
|
10
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
-
exports.unpack = exports.canUnpack = exports.pack = void 0;
|
|
12
|
-
const helpers_1 = require("@poppinss/utils/build/helpers");
|
|
13
|
-
/**
|
|
14
|
-
* Encodes a value into a base64 url encoded string to
|
|
15
|
-
* be set as cookie
|
|
16
|
-
*/
|
|
17
|
-
function pack(value) {
|
|
18
|
-
if (value === undefined || value === null) {
|
|
19
|
-
return null;
|
|
20
|
-
}
|
|
21
|
-
return helpers_1.base64.urlEncode(new helpers_1.MessageBuilder().build(value));
|
|
22
|
-
}
|
|
23
|
-
exports.pack = pack;
|
|
24
|
-
/**
|
|
25
|
-
* Returns true when this `unpack` method of this module can attempt
|
|
26
|
-
* to unpack the encode value.
|
|
27
|
-
*/
|
|
28
|
-
function canUnpack(encodedValue) {
|
|
29
|
-
return typeof encodedValue === 'string';
|
|
30
|
-
}
|
|
31
|
-
exports.canUnpack = canUnpack;
|
|
32
|
-
/**
|
|
33
|
-
* Attempts to unpack the value by decoding it. Make sure to call, `canUnpack`
|
|
34
|
-
* before calling this method
|
|
35
|
-
*/
|
|
36
|
-
function unpack(encodedValue) {
|
|
37
|
-
const verified = new helpers_1.MessageBuilder().verify(helpers_1.base64.urlDecode(encodedValue, 'utf-8', true));
|
|
38
|
-
return verified === undefined ? null : verified;
|
|
39
|
-
}
|
|
40
|
-
exports.unpack = unpack;
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @adonisjs/http-server
|
|
3
|
-
*
|
|
4
|
-
* (c) Harminder Virk <virk@adonisjs.com>
|
|
5
|
-
*
|
|
6
|
-
* For the full copyright and license information, please view the LICENSE
|
|
7
|
-
* file that was distributed with this source code.
|
|
8
|
-
*/
|
|
9
|
-
import { EncryptionContract } from '@ioc:Adonis/Core/Encryption';
|
|
10
|
-
/**
|
|
11
|
-
* Signs a value to be shared as a cookie. The signed output has a
|
|
12
|
-
* hash to verify tampering with the original value
|
|
13
|
-
*/
|
|
14
|
-
export declare function pack(key: string, value: any, encryption: EncryptionContract): null | string;
|
|
15
|
-
/**
|
|
16
|
-
* Returns a boolean, if the unpack method from this module can attempt
|
|
17
|
-
* to unpack the signed value.
|
|
18
|
-
*/
|
|
19
|
-
export declare function canUnpack(signedValue: string): boolean;
|
|
20
|
-
/**
|
|
21
|
-
* Attempts to unpack the signed value. Make sure to call `canUnpack` before
|
|
22
|
-
* calling this method.
|
|
23
|
-
*/
|
|
24
|
-
export declare function unpack(key: string, signedValue: string, encryption: EncryptionContract): null | any;
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* @adonisjs/http-server
|
|
4
|
-
*
|
|
5
|
-
* (c) Harminder Virk <virk@adonisjs.com>
|
|
6
|
-
*
|
|
7
|
-
* For the full copyright and license information, please view the LICENSE
|
|
8
|
-
* file that was distributed with this source code.
|
|
9
|
-
*/
|
|
10
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
-
exports.unpack = exports.canUnpack = exports.pack = void 0;
|
|
12
|
-
/**
|
|
13
|
-
* Signs a value to be shared as a cookie. The signed output has a
|
|
14
|
-
* hash to verify tampering with the original value
|
|
15
|
-
*/
|
|
16
|
-
function pack(key, value, encryption) {
|
|
17
|
-
if (value === undefined || value === null) {
|
|
18
|
-
return null;
|
|
19
|
-
}
|
|
20
|
-
return `s:${encryption.verifier.sign(value, undefined, key)}`;
|
|
21
|
-
}
|
|
22
|
-
exports.pack = pack;
|
|
23
|
-
/**
|
|
24
|
-
* Returns a boolean, if the unpack method from this module can attempt
|
|
25
|
-
* to unpack the signed value.
|
|
26
|
-
*/
|
|
27
|
-
function canUnpack(signedValue) {
|
|
28
|
-
return typeof signedValue === 'string' && signedValue.substr(0, 2) === 's:';
|
|
29
|
-
}
|
|
30
|
-
exports.canUnpack = canUnpack;
|
|
31
|
-
/**
|
|
32
|
-
* Attempts to unpack the signed value. Make sure to call `canUnpack` before
|
|
33
|
-
* calling this method.
|
|
34
|
-
*/
|
|
35
|
-
function unpack(key, signedValue, encryption) {
|
|
36
|
-
const value = signedValue.slice(2);
|
|
37
|
-
if (!value) {
|
|
38
|
-
return null;
|
|
39
|
-
}
|
|
40
|
-
return encryption.verifier.unsign(value, key);
|
|
41
|
-
}
|
|
42
|
-
exports.unpack = unpack;
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @adonisjs/http-server
|
|
3
|
-
*
|
|
4
|
-
* (c) Harminder Virk <virk@adonisjs.com>
|
|
5
|
-
*
|
|
6
|
-
* For the full copyright and license information, please view the LICENSE
|
|
7
|
-
* file that was distributed with this source code.
|
|
8
|
-
*/
|
|
9
|
-
import { EncryptionContract } from '@ioc:Adonis/Core/Encryption';
|
|
10
|
-
/**
|
|
11
|
-
* Cookie parser parses the HTTP `cookie` header and collects all cookies
|
|
12
|
-
* inside an object of `key-value` pair, but doesn't attempt to decrypt
|
|
13
|
-
* or unsign or decode the individual values.
|
|
14
|
-
*
|
|
15
|
-
* The cookie values are lazily decrypted, or unsigned to avoid unncessary
|
|
16
|
-
* processing, which infact can be used as a means to burden the server
|
|
17
|
-
* by sending too many cookies which even doesn't belongs to the
|
|
18
|
-
* server.
|
|
19
|
-
*/
|
|
20
|
-
export declare class CookieParser {
|
|
21
|
-
private cookieHeader;
|
|
22
|
-
private encryption;
|
|
23
|
-
private client;
|
|
24
|
-
/**
|
|
25
|
-
* A copy of cached cookies, they are cached during a request after
|
|
26
|
-
* initial decoding, unsigning or decrypting.
|
|
27
|
-
*/
|
|
28
|
-
private cachedCookies;
|
|
29
|
-
/**
|
|
30
|
-
* An object of key-value pair collected by parsing
|
|
31
|
-
* the request cookie header.
|
|
32
|
-
*/
|
|
33
|
-
private cookies;
|
|
34
|
-
constructor(cookieHeader: string, encryption: EncryptionContract);
|
|
35
|
-
/**
|
|
36
|
-
* Parses the request `cookie` header
|
|
37
|
-
*/
|
|
38
|
-
private parse;
|
|
39
|
-
/**
|
|
40
|
-
* Attempts to decode a cookie by the name. When calling this method,
|
|
41
|
-
* you are assuming that the cookie was just encoded at the first
|
|
42
|
-
* place and not signed or encrypted.
|
|
43
|
-
*/
|
|
44
|
-
decode(key: string): any | null;
|
|
45
|
-
/**
|
|
46
|
-
* Attempts to unsign a cookie by the name. When calling this method,
|
|
47
|
-
* you are assuming that the cookie was signed at the first place.
|
|
48
|
-
*/
|
|
49
|
-
unsign(key: string): null | any;
|
|
50
|
-
/**
|
|
51
|
-
* Attempts to decrypt a cookie by the name. When calling this method,
|
|
52
|
-
* you are assuming that the cookie was encrypted at the first place.
|
|
53
|
-
*/
|
|
54
|
-
decrypt(key: string): null | any;
|
|
55
|
-
/**
|
|
56
|
-
* Returns an object of cookies key-value pair. Do note, the
|
|
57
|
-
* cookies are not decoded, unsigned or decrypted inside this
|
|
58
|
-
* list.
|
|
59
|
-
*/
|
|
60
|
-
list(): Record<string, any>;
|
|
61
|
-
}
|