@famir/http-proto 0.0.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/README.md ADDED
@@ -0,0 +1,3 @@
1
+ # @famir/http-proto
2
+
3
+ Definitions for the HTTP protocol.
@@ -0,0 +1,41 @@
1
+ export declare const HTTP_TYPES_NORMAL: readonly ["normal-simple", "normal-stream-request", "normal-stream-response"];
2
+ export declare const HTTP_TYPES_WEBSOCKET: readonly ["websocket"];
3
+ export declare const HTTP_TYPES: readonly ["normal-simple", "normal-stream-request", "normal-stream-response", "websocket"];
4
+ export type HttpType = (typeof HTTP_TYPES)[number];
5
+ export declare const HTTP_METHODS: readonly ["HEAD", "GET", "POST", "PUT", "PATCH", "DELETE", "OPTIONS"];
6
+ export type HttpMethod = (typeof HTTP_METHODS)[number];
7
+ export interface HttpUrl {
8
+ protocol: string;
9
+ hostname: string;
10
+ port: string;
11
+ pathname: string;
12
+ search: string;
13
+ hash: string;
14
+ }
15
+ export type HttpHeader = string | string[];
16
+ export type HttpHeaders = Record<string, HttpHeader | undefined>;
17
+ export type HttpStrictHeaders = Record<string, HttpHeader>;
18
+ export type HttpBody = Buffer;
19
+ export type HttpText = string;
20
+ export type HttpJson = NonNullable<unknown>;
21
+ export type HttpConnection = Record<string, number | string | null | undefined>;
22
+ export type HttpPayload = Record<string, unknown>;
23
+ export type HttpError = readonly [object, ...string[]];
24
+ export type HttpQueryString = Record<string, unknown>;
25
+ export interface HttpContentType {
26
+ type: string;
27
+ parameters: Record<string, string>;
28
+ }
29
+ export type HttpCookie = string;
30
+ export type HttpCookies = Record<string, HttpCookie | undefined>;
31
+ export interface HttpSetCookie {
32
+ value: string;
33
+ expires?: number;
34
+ maxAge?: number;
35
+ path?: string;
36
+ domain?: string;
37
+ secure?: boolean;
38
+ httpOnly?: boolean;
39
+ sameSite?: string;
40
+ }
41
+ export type HttpSetCookies = Record<string, HttpSetCookie | undefined>;
@@ -0,0 +1,9 @@
1
+ export const HTTP_TYPES_NORMAL = [
2
+ 'normal-simple',
3
+ 'normal-stream-request',
4
+ 'normal-stream-response',
5
+ ];
6
+ export const HTTP_TYPES_WEBSOCKET = ['websocket'];
7
+ export const HTTP_TYPES = [...HTTP_TYPES_NORMAL, ...HTTP_TYPES_WEBSOCKET];
8
+ export const HTTP_METHODS = ['HEAD', 'GET', 'POST', 'PUT', 'PATCH', 'DELETE', 'OPTIONS'];
9
+ //# sourceMappingURL=http-proto.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"http-proto.js","sourceRoot":"","sources":["../src/http-proto.ts"],"names":[],"mappings":"AAIA,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAC/B,eAAe;IACf,uBAAuB;IACvB,wBAAwB;CAChB,CAAA;AAMV,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,WAAW,CAAU,CAAA;AAM1D,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,GAAG,iBAAiB,EAAE,GAAG,oBAAoB,CAAU,CAAA;AAWlF,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,CAAU,CAAA"}
@@ -0,0 +1,10 @@
1
+ import { JSONSchemaType } from '@famir/validator';
2
+ import { HttpConnection, HttpError, HttpHeader, HttpHeaders, HttpMethod, HttpPayload, HttpType } from './http-proto.js';
3
+ export declare const httpTypeSchema: JSONSchemaType<HttpType>;
4
+ export declare const httpMethodSchema: JSONSchemaType<HttpMethod>;
5
+ export declare const httpHeaderSchema: JSONSchemaType<HttpHeader>;
6
+ export declare const httpHeadersSchema: JSONSchemaType<HttpHeaders>;
7
+ export declare const httpConnectionSchema: JSONSchemaType<HttpConnection>;
8
+ export declare const httpPayloadSchema: JSONSchemaType<HttpPayload>;
9
+ export declare const httpErrorSchema: JSONSchemaType<HttpError>;
10
+ export declare const httpErrorsSchema: JSONSchemaType<HttpError[]>;
@@ -0,0 +1,59 @@
1
+ import { HTTP_METHODS, HTTP_TYPES, } from './http-proto.js';
2
+ export const httpTypeSchema = {
3
+ type: 'string',
4
+ enum: [...HTTP_TYPES],
5
+ };
6
+ export const httpMethodSchema = {
7
+ type: 'string',
8
+ enum: [...HTTP_METHODS],
9
+ };
10
+ export const httpHeaderSchema = {
11
+ type: ['string', 'array'],
12
+ oneOf: [
13
+ {
14
+ type: 'string',
15
+ },
16
+ {
17
+ type: 'array',
18
+ items: {
19
+ type: 'string',
20
+ },
21
+ },
22
+ ],
23
+ };
24
+ export const httpHeadersSchema = {
25
+ type: 'object',
26
+ required: [],
27
+ additionalProperties: {
28
+ ...httpHeaderSchema,
29
+ nullable: true,
30
+ },
31
+ };
32
+ export const httpConnectionSchema = {
33
+ type: 'object',
34
+ additionalProperties: {
35
+ anyOf: [{ type: 'number' }, { type: 'string' }],
36
+ },
37
+ };
38
+ export const httpPayloadSchema = {
39
+ type: 'object',
40
+ additionalProperties: true,
41
+ };
42
+ export const httpErrorSchema = {
43
+ type: 'array',
44
+ minItems: 1,
45
+ maxItems: 10,
46
+ items: [
47
+ {
48
+ type: 'object',
49
+ },
50
+ ],
51
+ additionalItems: {
52
+ type: 'string',
53
+ },
54
+ };
55
+ export const httpErrorsSchema = {
56
+ type: 'array',
57
+ items: httpErrorSchema,
58
+ };
59
+ //# sourceMappingURL=http-proto.schemas.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"http-proto.schemas.js","sourceRoot":"","sources":["../src/http-proto.schemas.ts"],"names":[],"mappings":"AACA,OAAO,EACL,YAAY,EACZ,UAAU,GAQX,MAAM,iBAAiB,CAAA;AAMxB,MAAM,CAAC,MAAM,cAAc,GAA6B;IACtD,IAAI,EAAE,QAAQ;IACd,IAAI,EAAE,CAAC,GAAG,UAAU,CAAC;CACb,CAAA;AAMV,MAAM,CAAC,MAAM,gBAAgB,GAA+B;IAC1D,IAAI,EAAE,QAAQ;IACd,IAAI,EAAE,CAAC,GAAG,YAAY,CAAC;CACf,CAAA;AAMV,MAAM,CAAC,MAAM,gBAAgB,GAA+B;IAC1D,IAAI,EAAE,CAAC,QAAQ,EAAE,OAAO,CAAC;IACzB,KAAK,EAAE;QACL;YACE,IAAI,EAAE,QAAQ;SACf;QACD;YACE,IAAI,EAAE,OAAO;YACb,KAAK,EAAE;gBACL,IAAI,EAAE,QAAQ;aACf;SACF;KACF;CACO,CAAA;AAMV,MAAM,CAAC,MAAM,iBAAiB,GAAgC;IAC5D,IAAI,EAAE,QAAQ;IACd,QAAQ,EAAE,EAAE;IACZ,oBAAoB,EAAE;QACpB,GAAG,gBAAgB;QACnB,QAAQ,EAAE,IAAI;KACf;CACO,CAAA;AAMV,MAAM,CAAC,MAAM,oBAAoB,GAAmC;IAClE,IAAI,EAAE,QAAQ;IACd,oBAAoB,EAAE;QACpB,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;KAChD;CACO,CAAA;AAMV,MAAM,CAAC,MAAM,iBAAiB,GAAgC;IAC5D,IAAI,EAAE,QAAQ;IACd,oBAAoB,EAAE,IAAI;CAClB,CAAA;AAMV,MAAM,CAAC,MAAM,eAAe,GAA8B;IACxD,IAAI,EAAE,OAAO;IACb,QAAQ,EAAE,CAAC;IACX,QAAQ,EAAE,EAAE;IACZ,KAAK,EAAE;QACL;YACE,IAAI,EAAE,QAAQ;SACf;KACF;IACD,eAAe,EAAE;QACf,IAAI,EAAE,QAAQ;KACf;CACO,CAAA;AAMV,MAAM,CAAC,MAAM,gBAAgB,GAAgC;IAC3D,IAAI,EAAE,OAAO;IACb,KAAK,EAAE,eAAe;CACd,CAAA"}
@@ -0,0 +1,2 @@
1
+ export * from './http-proto.js';
2
+ export * from './http-proto.schemas.js';
package/dist/index.js ADDED
@@ -0,0 +1,3 @@
1
+ export * from './http-proto.js';
2
+ export * from './http-proto.schemas.js';
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAA;AAC/B,cAAc,yBAAyB,CAAA"}
package/package.json ADDED
@@ -0,0 +1,43 @@
1
+ {
2
+ "name": "@famir/http-proto",
3
+ "type": "module",
4
+ "version": "0.0.1",
5
+ "description": "Famir http-proto module",
6
+ "keywords": [
7
+ "famir",
8
+ "fake-mirrors",
9
+ "man-in-the-middle",
10
+ "phishing",
11
+ "reverse-proxy",
12
+ "red-teaming"
13
+ ],
14
+ "author": "Dmitry Krutikov <d.krutikov@gmail.com>",
15
+ "license": "Apache-2.0",
16
+ "exports": {
17
+ ".": {
18
+ "types": "./dist/index.d.ts",
19
+ "default": "./dist/index.js"
20
+ }
21
+ },
22
+ "scripts": {
23
+ "format": "prettier -w \"src/**/*.ts\"",
24
+ "lint": "eslint \"src/**/*.ts\"",
25
+ "test": "node --test dist/**/*.test.js",
26
+ "build": "tsc -b",
27
+ "clean": "rimraf dist *.tsbuildinfo"
28
+ },
29
+ "files": ["dist", "README.md"],
30
+ "repository": {
31
+ "type": "git",
32
+ "url": "git+https://github.com/bitnoize/famir.git",
33
+ "directory": "packages/validator"
34
+ },
35
+ "bugs": {
36
+ "url": "https://github.com/bitnoize/famir/issues"
37
+ },
38
+ "homepage": "https://fake-mirrors.net",
39
+ "dependencies": {
40
+ "@famir/common": "*",
41
+ "@famir/validator": "*"
42
+ }
43
+ }