@gasket/plugin-https-proxy 7.3.11 → 7.4.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/cjs/actions.cjs +39 -0
- package/cjs/{create.js → create.cjs} +0 -1
- package/cjs/{index.js → index.cjs} +5 -57
- package/package.json +10 -12
- package/cjs/actions.js +0 -106
- package/cjs/index.d.ts +0 -34
package/cjs/actions.cjs
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
Object.defineProperty(exports, "__esModule", {
|
|
2
|
+
value: true
|
|
3
|
+
});
|
|
4
|
+
function _export(target, all) {
|
|
5
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: all[name]
|
|
8
|
+
});
|
|
9
|
+
}
|
|
10
|
+
_export(exports, {
|
|
11
|
+
actions: function() {
|
|
12
|
+
return actions;
|
|
13
|
+
},
|
|
14
|
+
startProxyServer: function() {
|
|
15
|
+
return startProxyServer;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
const _httpproxy = /*#__PURE__*/ _interop_require_default(require("http-proxy"));
|
|
19
|
+
function _interop_require_default(obj) {
|
|
20
|
+
return obj && obj.__esModule ? obj : {
|
|
21
|
+
default: obj
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
async function startProxyServer(gasket) {
|
|
25
|
+
await gasket.isReady;
|
|
26
|
+
await gasket.exec('prebootHttpsProxy');
|
|
27
|
+
const { httpsProxy } = gasket.config;
|
|
28
|
+
const { logger } = gasket;
|
|
29
|
+
const opts = await gasket.execWaterfall('httpsProxy', httpsProxy);
|
|
30
|
+
const { protocol = 'http', hostname = 'localhost', port = 8080, ...proxyOpts } = opts;
|
|
31
|
+
const server = _httpproxy.default.createServer(proxyOpts).on('error', (err)=>{
|
|
32
|
+
logger.error('Request failed to proxy:', err);
|
|
33
|
+
}).listen(port);
|
|
34
|
+
logger.info(`Proxy server started: ${protocol}://${hostname}:${port}`);
|
|
35
|
+
return server;
|
|
36
|
+
}
|
|
37
|
+
const actions = {
|
|
38
|
+
startProxyServer
|
|
39
|
+
};
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
/// <reference types="create-gasket-app" />
|
|
2
2
|
/// <reference types="@gasket/plugin-metadata" />
|
|
3
|
-
"use strict";
|
|
4
3
|
Object.defineProperty(exports, "__esModule", {
|
|
5
4
|
value: true
|
|
6
5
|
});
|
|
@@ -10,66 +9,14 @@ Object.defineProperty(exports, /** @type {import('@gasket/core').Plugin} */ "def
|
|
|
10
9
|
return _default;
|
|
11
10
|
}
|
|
12
11
|
});
|
|
13
|
-
const _create = /*#__PURE__*/ _interop_require_default(require("./create.
|
|
14
|
-
const _actions = require("./actions.
|
|
12
|
+
const _create = /*#__PURE__*/ _interop_require_default(require("./create.cjs"));
|
|
13
|
+
const _actions = require("./actions.cjs");
|
|
15
14
|
const _module = require("module");
|
|
16
|
-
function _define_property(obj, key, value) {
|
|
17
|
-
if (key in obj) {
|
|
18
|
-
Object.defineProperty(obj, key, {
|
|
19
|
-
value: value,
|
|
20
|
-
enumerable: true,
|
|
21
|
-
configurable: true,
|
|
22
|
-
writable: true
|
|
23
|
-
});
|
|
24
|
-
} else {
|
|
25
|
-
obj[key] = value;
|
|
26
|
-
}
|
|
27
|
-
return obj;
|
|
28
|
-
}
|
|
29
15
|
function _interop_require_default(obj) {
|
|
30
16
|
return obj && obj.__esModule ? obj : {
|
|
31
17
|
default: obj
|
|
32
18
|
};
|
|
33
19
|
}
|
|
34
|
-
function _object_spread(target) {
|
|
35
|
-
for(var i = 1; i < arguments.length; i++){
|
|
36
|
-
var source = arguments[i] != null ? arguments[i] : {};
|
|
37
|
-
var ownKeys = Object.keys(source);
|
|
38
|
-
if (typeof Object.getOwnPropertySymbols === "function") {
|
|
39
|
-
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
40
|
-
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
41
|
-
}));
|
|
42
|
-
}
|
|
43
|
-
ownKeys.forEach(function(key) {
|
|
44
|
-
_define_property(target, key, source[key]);
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
return target;
|
|
48
|
-
}
|
|
49
|
-
function ownKeys(object, enumerableOnly) {
|
|
50
|
-
var keys = Object.keys(object);
|
|
51
|
-
if (Object.getOwnPropertySymbols) {
|
|
52
|
-
var symbols = Object.getOwnPropertySymbols(object);
|
|
53
|
-
if (enumerableOnly) {
|
|
54
|
-
symbols = symbols.filter(function(sym) {
|
|
55
|
-
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
keys.push.apply(keys, symbols);
|
|
59
|
-
}
|
|
60
|
-
return keys;
|
|
61
|
-
}
|
|
62
|
-
function _object_spread_props(target, source) {
|
|
63
|
-
source = source != null ? source : {};
|
|
64
|
-
if (Object.getOwnPropertyDescriptors) {
|
|
65
|
-
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
|
66
|
-
} else {
|
|
67
|
-
ownKeys(Object(source)).forEach(function(key) {
|
|
68
|
-
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
return target;
|
|
72
|
-
}
|
|
73
20
|
const require1 = (0, _module.createRequire)(require("url").pathToFileURL(__filename).toString());
|
|
74
21
|
const pkgJson = require1('../package.json');
|
|
75
22
|
const { name, version, description } = pkgJson;
|
|
@@ -81,7 +28,8 @@ const _default = {
|
|
|
81
28
|
hooks: {
|
|
82
29
|
create: _create.default,
|
|
83
30
|
metadata (gasket, meta) {
|
|
84
|
-
return
|
|
31
|
+
return {
|
|
32
|
+
...meta,
|
|
85
33
|
actions: [
|
|
86
34
|
{
|
|
87
35
|
name: 'startProxyServer',
|
|
@@ -110,7 +58,7 @@ const _default = {
|
|
|
110
58
|
type: 'object'
|
|
111
59
|
}
|
|
112
60
|
]
|
|
113
|
-
}
|
|
61
|
+
};
|
|
114
62
|
}
|
|
115
63
|
}
|
|
116
64
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gasket/plugin-https-proxy",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.4.0",
|
|
4
4
|
"description": "Adds support for running an https proxy",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
@@ -12,8 +12,8 @@
|
|
|
12
12
|
".": {
|
|
13
13
|
"types": "./lib/index.d.ts",
|
|
14
14
|
"import": "./lib/index.js",
|
|
15
|
-
"require": "./cjs/index.
|
|
16
|
-
"default": "./cjs/index.
|
|
15
|
+
"require": "./cjs/index.cjs",
|
|
16
|
+
"default": "./cjs/index.cjs"
|
|
17
17
|
},
|
|
18
18
|
"./package.json": "./package.json"
|
|
19
19
|
},
|
|
@@ -35,8 +35,6 @@
|
|
|
35
35
|
"http-proxy": "^1.18.1"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
|
-
"@swc/cli": "^0.6.0",
|
|
39
|
-
"@swc/core": "^1.10.18",
|
|
40
38
|
"@types/jest": "^29.5.14",
|
|
41
39
|
"@types/node": "^20.17.19",
|
|
42
40
|
"eslint": "^8.57.1",
|
|
@@ -46,11 +44,12 @@
|
|
|
46
44
|
"eslint-plugin-unicorn": "^55.0.0",
|
|
47
45
|
"typescript": "^5.8.2",
|
|
48
46
|
"vitest": "^3.2.0",
|
|
49
|
-
"@gasket/core": "7.
|
|
50
|
-
"@gasket/
|
|
51
|
-
"@gasket/plugin-logger": "7.3.
|
|
52
|
-
"@gasket/plugin-metadata": "7.
|
|
53
|
-
"create-gasket-app": "7.4.
|
|
47
|
+
"@gasket/core": "^7.6.0",
|
|
48
|
+
"@gasket/cjs": "^7.0.0",
|
|
49
|
+
"@gasket/plugin-logger": "^7.3.5",
|
|
50
|
+
"@gasket/plugin-metadata": "^7.5.0",
|
|
51
|
+
"create-gasket-app": "^7.4.9",
|
|
52
|
+
"@gasket/plugin-https": "^7.3.8"
|
|
54
53
|
},
|
|
55
54
|
"eslintConfig": {
|
|
56
55
|
"extends": [
|
|
@@ -83,11 +82,10 @@
|
|
|
83
82
|
"cjs"
|
|
84
83
|
],
|
|
85
84
|
"scripts": {
|
|
86
|
-
"build": "
|
|
85
|
+
"build": "gasket-cjs ./lib",
|
|
87
86
|
"build:watch": "pnpm run build --watch",
|
|
88
87
|
"lint": "eslint .",
|
|
89
88
|
"lint:fix": "pnpm run lint --fix",
|
|
90
|
-
"postbuild": "node -e \"require('fs').writeFileSync('cjs/package.json', '{}')\"",
|
|
91
89
|
"posttest": "pnpm run lint && pnpm run typecheck",
|
|
92
90
|
"test": "vitest --watch=false",
|
|
93
91
|
"test:coverage": "pnpm run test --coverage",
|
package/cjs/actions.js
DELETED
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
function _export(target, all) {
|
|
6
|
-
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
get: all[name]
|
|
9
|
-
});
|
|
10
|
-
}
|
|
11
|
-
_export(exports, {
|
|
12
|
-
actions: function() {
|
|
13
|
-
return actions;
|
|
14
|
-
},
|
|
15
|
-
startProxyServer: function() {
|
|
16
|
-
return startProxyServer;
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
|
-
const _httpproxy = /*#__PURE__*/ _interop_require_default(require("http-proxy"));
|
|
20
|
-
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
21
|
-
try {
|
|
22
|
-
var info = gen[key](arg);
|
|
23
|
-
var value = info.value;
|
|
24
|
-
} catch (error) {
|
|
25
|
-
reject(error);
|
|
26
|
-
return;
|
|
27
|
-
}
|
|
28
|
-
if (info.done) {
|
|
29
|
-
resolve(value);
|
|
30
|
-
} else {
|
|
31
|
-
Promise.resolve(value).then(_next, _throw);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
function _async_to_generator(fn) {
|
|
35
|
-
return function() {
|
|
36
|
-
var self = this, args = arguments;
|
|
37
|
-
return new Promise(function(resolve, reject) {
|
|
38
|
-
var gen = fn.apply(self, args);
|
|
39
|
-
function _next(value) {
|
|
40
|
-
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
41
|
-
}
|
|
42
|
-
function _throw(err) {
|
|
43
|
-
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
44
|
-
}
|
|
45
|
-
_next(undefined);
|
|
46
|
-
});
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
function _interop_require_default(obj) {
|
|
50
|
-
return obj && obj.__esModule ? obj : {
|
|
51
|
-
default: obj
|
|
52
|
-
};
|
|
53
|
-
}
|
|
54
|
-
function _object_without_properties(source, excluded) {
|
|
55
|
-
if (source == null) return {};
|
|
56
|
-
var target = _object_without_properties_loose(source, excluded);
|
|
57
|
-
var key, i;
|
|
58
|
-
if (Object.getOwnPropertySymbols) {
|
|
59
|
-
var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
|
|
60
|
-
for(i = 0; i < sourceSymbolKeys.length; i++){
|
|
61
|
-
key = sourceSymbolKeys[i];
|
|
62
|
-
if (excluded.indexOf(key) >= 0) continue;
|
|
63
|
-
if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
|
|
64
|
-
target[key] = source[key];
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
return target;
|
|
68
|
-
}
|
|
69
|
-
function _object_without_properties_loose(source, excluded) {
|
|
70
|
-
if (source == null) return {};
|
|
71
|
-
var target = {};
|
|
72
|
-
var sourceKeys = Object.keys(source);
|
|
73
|
-
var key, i;
|
|
74
|
-
for(i = 0; i < sourceKeys.length; i++){
|
|
75
|
-
key = sourceKeys[i];
|
|
76
|
-
if (excluded.indexOf(key) >= 0) continue;
|
|
77
|
-
target[key] = source[key];
|
|
78
|
-
}
|
|
79
|
-
return target;
|
|
80
|
-
}
|
|
81
|
-
function startProxyServer(gasket) {
|
|
82
|
-
return _startProxyServer.apply(this, arguments);
|
|
83
|
-
}
|
|
84
|
-
function _startProxyServer() {
|
|
85
|
-
_startProxyServer = _async_to_generator(function*(gasket) {
|
|
86
|
-
yield gasket.isReady;
|
|
87
|
-
yield gasket.exec('prebootHttpsProxy');
|
|
88
|
-
const { httpsProxy } = gasket.config;
|
|
89
|
-
const { logger } = gasket;
|
|
90
|
-
const opts = yield gasket.execWaterfall('httpsProxy', httpsProxy);
|
|
91
|
-
const { protocol = 'http', hostname = 'localhost', port = 8080 } = opts, proxyOpts = _object_without_properties(opts, [
|
|
92
|
-
"protocol",
|
|
93
|
-
"hostname",
|
|
94
|
-
"port"
|
|
95
|
-
]);
|
|
96
|
-
const server = _httpproxy.default.createServer(proxyOpts).on('error', (err)=>{
|
|
97
|
-
logger.error('Request failed to proxy:', err);
|
|
98
|
-
}).listen(port);
|
|
99
|
-
logger.info(`Proxy server started: ${protocol}://${hostname}:${port}`);
|
|
100
|
-
return server;
|
|
101
|
-
});
|
|
102
|
-
return _startProxyServer.apply(this, arguments);
|
|
103
|
-
}
|
|
104
|
-
const actions = {
|
|
105
|
-
startProxyServer
|
|
106
|
-
};
|
package/cjs/index.d.ts
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import type { Plugin, MaybeAsync } from '@gasket/core';
|
|
2
|
-
import type { ServerOptions as ProxyServerOptions } from 'http-proxy';
|
|
3
|
-
import ProxyServer from 'http-proxy';
|
|
4
|
-
import type { RequireAtLeastOne } from '@gasket/plugin-https';
|
|
5
|
-
|
|
6
|
-
interface BaseHttpsProxyConfig extends ProxyServerOptions {
|
|
7
|
-
protocol?: string;
|
|
8
|
-
/** defaults to 'localhost' */
|
|
9
|
-
hostname?: string;
|
|
10
|
-
/** defaults to 8080 */
|
|
11
|
-
port?: number;
|
|
12
|
-
target?: string;
|
|
13
|
-
forward?: string;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
declare module '@gasket/core' {
|
|
17
|
-
export type HttpsProxyConfig = RequireAtLeastOne<BaseHttpsProxyConfig, 'target' | 'forward'>;
|
|
18
|
-
|
|
19
|
-
export interface GasketConfig {
|
|
20
|
-
httpsProxy?: HttpsProxyConfig
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export interface HookExecTypes {
|
|
24
|
-
prebootHttpsProxy(): MaybeAsync<void>;
|
|
25
|
-
httpsProxy(proxyConfig: HttpsProxyConfig): MaybeAsync<HttpsProxyConfig>,
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export interface GasketActions {
|
|
29
|
-
startProxyServer: () => Promise<ProxyServer>;
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
declare const plugin: Plugin;
|
|
34
|
-
export default plugin;
|