@opra/core 1.0.0-alpha.17 → 1.0.0-alpha.18
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/cjs/http/utils/body-reader.js +0 -1
- package/cjs/http/utils/common.js +4 -4
- package/cjs/http/utils/concat-readable.js +1 -2
- package/cjs/http/utils/convert-to-headers.js +2 -3
- package/cjs/http/utils/convert-to-raw-headers.js +1 -2
- package/cjs/http/utils/match-known-fields.js +2 -2
- package/cjs/http/utils/wrap-exception.js +1 -2
- package/cjs/type-guards.js +4 -5
- package/esm/http/utils/body-reader.js +0 -1
- package/package.json +2 -2
- package/types/http/http-context.d.ts +2 -2
- package/types/http/impl/http-incoming.host.d.ts +1 -2
- package/types/http/impl/http-outgoing.host.d.ts +1 -1
- package/types/http/impl/multipart-reader.d.ts +0 -1
- package/types/http/impl/node-incoming-message.host.d.ts +1 -5
- package/types/http/impl/node-outgoing-message.host.d.ts +2 -5
- package/types/http/interfaces/http-incoming.interface.d.ts +1 -2
- package/types/http/interfaces/http-outgoing.interface.d.ts +1 -1
- package/types/http/interfaces/node-incoming-message.interface.d.ts +0 -2
- package/types/http/interfaces/node-outgoing-message.interface.d.ts +0 -2
- package/types/http/utils/body-reader.d.ts +0 -3
- package/types/http/utils/concat-readable.d.ts +0 -1
- package/types/http/utils/convert-to-raw-headers.d.ts +0 -1
- package/types/platform-adapter.d.ts +1 -1
package/cjs/http/utils/common.js
CHANGED
|
@@ -4,7 +4,10 @@
|
|
|
4
4
|
https://github.com/nodejs/
|
|
5
5
|
*/
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.
|
|
7
|
+
exports.validateHeaderValue = exports.validateHeaderName = void 0;
|
|
8
|
+
exports.checkIsHttpToken = checkIsHttpToken;
|
|
9
|
+
exports.hideStackFrames = hideStackFrames;
|
|
10
|
+
exports.validateString = validateString;
|
|
8
11
|
const tokenRegExp = /^[\^_`a-zA-Z\-0-9!#$%&'*+.|~]+$/;
|
|
9
12
|
const nodeInternalPrefix = '__node_internal_';
|
|
10
13
|
/**
|
|
@@ -17,7 +20,6 @@ const nodeInternalPrefix = '__node_internal_';
|
|
|
17
20
|
function checkIsHttpToken(val) {
|
|
18
21
|
return typeof val === 'string' && tokenRegExp.exec(val) !== null;
|
|
19
22
|
}
|
|
20
|
-
exports.checkIsHttpToken = checkIsHttpToken;
|
|
21
23
|
const headerCharRegex = /[^\t\x20-\x7e\x80-\xff]/;
|
|
22
24
|
/**
|
|
23
25
|
* True if val contains an invalid field-vchar
|
|
@@ -44,7 +46,6 @@ function hideStackFrames(fn) {
|
|
|
44
46
|
Object.defineProperty(fn, 'name', { __proto__: null, value: hidden });
|
|
45
47
|
return fn;
|
|
46
48
|
}
|
|
47
|
-
exports.hideStackFrames = hideStackFrames;
|
|
48
49
|
exports.validateHeaderName = hideStackFrames((name, label) => {
|
|
49
50
|
// noinspection SuspiciousTypeOfGuard
|
|
50
51
|
if (typeof name !== 'string' || !name || !checkIsHttpToken(name)) {
|
|
@@ -64,4 +65,3 @@ function validateString(value, name) {
|
|
|
64
65
|
throw new TypeError(`Invalid ${name ? name + ' ' : ''}argument. Value must be a string`);
|
|
65
66
|
}
|
|
66
67
|
}
|
|
67
|
-
exports.validateString = validateString;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.concatReadable =
|
|
3
|
+
exports.concatReadable = concatReadable;
|
|
4
4
|
const stream_1 = require("stream");
|
|
5
5
|
function concatReadable(...streams) {
|
|
6
6
|
const out = new stream_1.PassThrough();
|
|
@@ -17,4 +17,3 @@ function concatReadable(...streams) {
|
|
|
17
17
|
pipeNext();
|
|
18
18
|
return out;
|
|
19
19
|
}
|
|
20
|
-
exports.concatReadable = concatReadable;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.convertToHeaders = convertToHeaders;
|
|
4
|
+
exports.convertToHeadersDistinct = convertToHeadersDistinct;
|
|
4
5
|
const match_known_fields_js_1 = require("./match-known-fields.js");
|
|
5
6
|
function convertToHeaders(src, dst, joinDuplicateHeaders) {
|
|
6
7
|
for (let n = 0; n < src.length; n += 2) {
|
|
@@ -8,7 +9,6 @@ function convertToHeaders(src, dst, joinDuplicateHeaders) {
|
|
|
8
9
|
}
|
|
9
10
|
return dst;
|
|
10
11
|
}
|
|
11
|
-
exports.convertToHeaders = convertToHeaders;
|
|
12
12
|
function convertToHeadersDistinct(src, dst) {
|
|
13
13
|
const count = src.length % 2;
|
|
14
14
|
for (let n = 0; n < count; n += 2) {
|
|
@@ -16,7 +16,6 @@ function convertToHeadersDistinct(src, dst) {
|
|
|
16
16
|
}
|
|
17
17
|
return dst;
|
|
18
18
|
}
|
|
19
|
-
exports.convertToHeadersDistinct = convertToHeadersDistinct;
|
|
20
19
|
function addHeaderLine(field, value, dest, joinDuplicateHeaders) {
|
|
21
20
|
if (value == null)
|
|
22
21
|
return;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.convertToRawHeaders =
|
|
3
|
+
exports.convertToRawHeaders = convertToRawHeaders;
|
|
4
4
|
const match_known_fields_js_1 = require("./match-known-fields.js");
|
|
5
5
|
function convertToRawHeaders(src) {
|
|
6
6
|
return Object.entries(src).reduce((a, [field, v]) => {
|
|
@@ -21,4 +21,3 @@ function convertToRawHeaders(src) {
|
|
|
21
21
|
return a;
|
|
22
22
|
}, []);
|
|
23
23
|
}
|
|
24
|
-
exports.convertToRawHeaders = convertToRawHeaders;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.ARRAY_FIELD = exports.SEMICOLON_DELIMITED_FIELD = exports.COMMA_DELIMITED_FIELD = exports.NO_DUPLICATES_FIELD = void 0;
|
|
4
|
+
exports.matchKnownFields = matchKnownFields;
|
|
4
5
|
const common_1 = require("@opra/common");
|
|
5
6
|
exports.NO_DUPLICATES_FIELD = 0;
|
|
6
7
|
exports.COMMA_DELIMITED_FIELD = 1;
|
|
@@ -46,4 +47,3 @@ function matchKnownFields(field) {
|
|
|
46
47
|
const x = KNOWN_FIELDS[field.toLowerCase()];
|
|
47
48
|
return x ? x : [field, exports.COMMA_DELIMITED_FIELD];
|
|
48
49
|
}
|
|
49
|
-
exports.matchKnownFields = matchKnownFields;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.wrapException =
|
|
3
|
+
exports.wrapException = wrapException;
|
|
4
4
|
const common_1 = require("@opra/common");
|
|
5
5
|
function wrapException(error) {
|
|
6
6
|
if (error instanceof common_1.OpraHttpError)
|
|
@@ -31,4 +31,3 @@ function wrapException(error) {
|
|
|
31
31
|
return new common_1.InternalServerError(error);
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
|
-
exports.wrapException = wrapException;
|
package/cjs/type-guards.js
CHANGED
|
@@ -1,23 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.isNodeIncomingMessage = isNodeIncomingMessage;
|
|
4
|
+
exports.isHttpIncoming = isHttpIncoming;
|
|
5
|
+
exports.isNodeOutgoingMessage = isNodeOutgoingMessage;
|
|
6
|
+
exports.isHttpOutgoing = isHttpOutgoing;
|
|
4
7
|
const common_1 = require("@opra/common");
|
|
5
8
|
function isNodeIncomingMessage(v) {
|
|
6
9
|
return v && typeof v.method === 'string' && Array.isArray(v.rawHeaders) && (0, common_1.isReadable)(v);
|
|
7
10
|
}
|
|
8
|
-
exports.isNodeIncomingMessage = isNodeIncomingMessage;
|
|
9
11
|
function isHttpIncoming(v) {
|
|
10
12
|
return (isNodeIncomingMessage(v) &&
|
|
11
13
|
typeof v.header === 'function' &&
|
|
12
14
|
typeof v.acceptsLanguages === 'function' &&
|
|
13
15
|
typeof v.readBody === 'function');
|
|
14
16
|
}
|
|
15
|
-
exports.isHttpIncoming = isHttpIncoming;
|
|
16
17
|
function isNodeOutgoingMessage(v) {
|
|
17
18
|
return v && typeof v.getHeaders === 'function' && (0, common_1.isStream)(v);
|
|
18
19
|
}
|
|
19
|
-
exports.isNodeOutgoingMessage = isNodeOutgoingMessage;
|
|
20
20
|
function isHttpOutgoing(v) {
|
|
21
21
|
return isNodeOutgoingMessage(v) && typeof v.clearCookie === 'function' && typeof v.cookie === 'function';
|
|
22
22
|
}
|
|
23
|
-
exports.isHttpOutgoing = isHttpOutgoing;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opra/core",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.18",
|
|
4
4
|
"description": "Opra schema package",
|
|
5
5
|
"author": "Panates",
|
|
6
6
|
"license": "MIT",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"@browsery/http-parser": "^0.5.8",
|
|
35
35
|
"@browsery/type-is": "^1.6.18-r2",
|
|
36
|
-
"@opra/common": "^1.0.0-alpha.
|
|
36
|
+
"@opra/common": "^1.0.0-alpha.18",
|
|
37
37
|
"@types/formidable": "^3.4.5",
|
|
38
38
|
"accepts": "^1.3.8",
|
|
39
39
|
"base64-stream": "^1.0.0",
|
|
@@ -2,8 +2,8 @@ import { HttpController, HttpMediaType, HttpOperation, OpraSchema } from '@opra/
|
|
|
2
2
|
import { ExecutionContext } from '../execution-context.js';
|
|
3
3
|
import type { HttpAdapter } from './http-adapter';
|
|
4
4
|
import { MultipartReader } from './impl/multipart-reader.js';
|
|
5
|
-
import type { HttpIncoming } from './interfaces/http-incoming.interface';
|
|
6
|
-
import type { HttpOutgoing } from './interfaces/http-outgoing.interface';
|
|
5
|
+
import type { HttpIncoming } from './interfaces/http-incoming.interface.js';
|
|
6
|
+
import type { HttpOutgoing } from './interfaces/http-outgoing.interface.js';
|
|
7
7
|
export declare namespace HttpContext {
|
|
8
8
|
interface Initiator extends Omit<ExecutionContext.Initiator, 'document' | 'protocol'> {
|
|
9
9
|
adapter: HttpAdapter;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
1
|
import parseRange from 'range-parser';
|
|
3
|
-
import type { HttpIncoming } from '../interfaces/http-incoming.interface';
|
|
2
|
+
import type { HttpIncoming } from '../interfaces/http-incoming.interface.js';
|
|
4
3
|
import { BodyReader } from '../utils/body-reader.js';
|
|
5
4
|
export interface HttpIncomingHost extends HttpIncoming {
|
|
6
5
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { CookieOptions, HttpOutgoing } from '../interfaces/http-outgoing.interface';
|
|
1
|
+
import type { CookieOptions, HttpOutgoing } from '../interfaces/http-outgoing.interface.js';
|
|
2
2
|
export interface HttpOutgoingHost extends HttpOutgoing {
|
|
3
3
|
}
|
|
4
4
|
export declare class HttpOutgoingHost {
|
|
@@ -1,11 +1,7 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
/// <reference types="node" />
|
|
3
|
-
/// <reference types="node" />
|
|
4
|
-
/// <reference types="node" />
|
|
5
1
|
import { HTTPParserJS } from '@browsery/http-parser';
|
|
6
2
|
import { IncomingHttpHeaders } from 'http';
|
|
7
3
|
import { Duplex, Readable } from 'stream';
|
|
8
|
-
import type { NodeIncomingMessage } from '../interfaces/node-incoming-message.interface';
|
|
4
|
+
import type { NodeIncomingMessage } from '../interfaces/node-incoming-message.interface.js';
|
|
9
5
|
export declare const CRLF: Buffer;
|
|
10
6
|
export declare const kHeaders: unique symbol;
|
|
11
7
|
export declare const kHeadersDistinct: unique symbol;
|
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
/// <reference types="node" />
|
|
3
|
-
/// <reference types="node" />
|
|
4
1
|
import { OutgoingHttpHeaders } from 'http';
|
|
5
2
|
import { Duplex } from 'stream';
|
|
6
|
-
import type { NodeIncomingMessage } from '../interfaces/node-incoming-message.interface';
|
|
7
|
-
import type { NodeOutgoingMessage } from '../interfaces/node-outgoing-message.interface';
|
|
3
|
+
import type { NodeIncomingMessage } from '../interfaces/node-incoming-message.interface.js';
|
|
4
|
+
import type { NodeOutgoingMessage } from '../interfaces/node-outgoing-message.interface.js';
|
|
8
5
|
export declare const kOutHeaders: unique symbol;
|
|
9
6
|
export declare const kOutTrailers: unique symbol;
|
|
10
7
|
declare global {
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
1
|
import { Options as RangeParserOptions, Ranges as RangeParserRanges, Result as RangeParserResult } from 'range-parser';
|
|
3
2
|
import { BodyReader } from '../utils/body-reader.js';
|
|
4
|
-
import type { HttpOutgoing } from './http-outgoing.interface';
|
|
3
|
+
import type { HttpOutgoing } from './http-outgoing.interface.js';
|
|
5
4
|
import { NodeIncomingMessage } from './node-incoming-message.interface.js';
|
|
6
5
|
/**
|
|
7
6
|
* @interface HttpIncoming
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { StrictOmit } from 'ts-gems';
|
|
2
|
-
import type { HttpIncoming } from './http-incoming.interface';
|
|
2
|
+
import type { HttpIncoming } from './http-incoming.interface.js';
|
|
3
3
|
import { NodeOutgoingMessage } from './node-outgoing-message.interface.js';
|
|
4
4
|
export interface HttpOutgoing extends StrictOmit<NodeOutgoingMessage, 'req' | 'appendHeader' | 'setHeader'> {
|
|
5
5
|
req: HttpIncoming;
|
|
@@ -4,7 +4,7 @@ import { AsyncEventEmitter } from 'strict-typed-events';
|
|
|
4
4
|
import { kAssetCache } from './constants.js';
|
|
5
5
|
import { Logger } from './helpers/logger.js';
|
|
6
6
|
import { AssetCache } from './http/impl/asset-cache.js';
|
|
7
|
-
import type { ILogger } from './interfaces/logger.interface';
|
|
7
|
+
import type { ILogger } from './interfaces/logger.interface.js';
|
|
8
8
|
/**
|
|
9
9
|
* @namespace PlatformAdapter
|
|
10
10
|
*/
|