getpatter 0.4.1 → 0.4.3
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 +185 -587
- package/dist/chunk-35EVXMGB.mjs +4472 -0
- package/dist/chunk-AFUYSNDH.mjs +31 -0
- package/dist/chunk-JO5C35FM.mjs +65 -0
- package/dist/chunk-OOIUSZB4.mjs +37 -0
- package/dist/cli.js +1139 -0
- package/dist/index.d.mts +1063 -85
- package/dist/index.d.ts +1063 -85
- package/dist/index.js +8969 -3904
- package/dist/index.mjs +2382 -3354
- package/dist/lib-4WCAS54J.mjs +830 -0
- package/dist/node-cron-373UVDIO.mjs +935 -0
- package/dist/persistence-CYIGNHSU.mjs +7 -0
- package/dist/resources/audio/NOTICE +2 -0
- package/dist/resources/audio/city-ambience.ogg +0 -0
- package/dist/resources/audio/crowded-room.ogg +0 -0
- package/dist/resources/audio/forest-ambience.ogg +0 -0
- package/dist/resources/audio/hold_music.ogg +0 -0
- package/dist/resources/audio/keyboard-typing.ogg +0 -0
- package/dist/resources/audio/keyboard-typing2.ogg +0 -0
- package/dist/resources/audio/office-ambience.ogg +0 -0
- package/dist/resources/silero_vad.onnx +0 -0
- package/dist/{test-mode-JMXZSAJS.mjs → test-mode-RH65MMSP.mjs} +2 -1
- package/dist/{tunnel-HYSU7EF2.mjs → tunnel-BL7A7GXW.mjs} +2 -1
- package/package.json +25 -8
- package/src/resources/audio/NOTICE +2 -0
- package/src/resources/audio/city-ambience.ogg +0 -0
- package/src/resources/audio/crowded-room.ogg +0 -0
- package/src/resources/audio/forest-ambience.ogg +0 -0
- package/src/resources/audio/hold_music.ogg +0 -0
- package/src/resources/audio/keyboard-typing.ogg +0 -0
- package/src/resources/audio/keyboard-typing2.ogg +0 -0
- package/src/resources/audio/office-ambience.ogg +0 -0
- package/dist/chunk-TAATEHKF.mjs +0 -396
- package/dist/chunk-VNU4GNW3.mjs +0 -45
|
@@ -0,0 +1,830 @@
|
|
|
1
|
+
import {
|
|
2
|
+
__commonJS,
|
|
3
|
+
__require
|
|
4
|
+
} from "./chunk-OOIUSZB4.mjs";
|
|
5
|
+
|
|
6
|
+
// node_modules/cloudflared/lib/constants.js
|
|
7
|
+
var require_constants = __commonJS({
|
|
8
|
+
"node_modules/cloudflared/lib/constants.js"(exports, module) {
|
|
9
|
+
"use strict";
|
|
10
|
+
var __create = Object.create;
|
|
11
|
+
var __defProp = Object.defineProperty;
|
|
12
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
13
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
14
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
15
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
16
|
+
var __export = (target, all) => {
|
|
17
|
+
for (var name in all)
|
|
18
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
19
|
+
};
|
|
20
|
+
var __copyProps = (to, from, except, desc) => {
|
|
21
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
22
|
+
for (let key of __getOwnPropNames(from))
|
|
23
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
24
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
25
|
+
}
|
|
26
|
+
return to;
|
|
27
|
+
};
|
|
28
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
29
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
30
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
31
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
32
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
33
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
34
|
+
mod
|
|
35
|
+
));
|
|
36
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
37
|
+
var constants_exports = {};
|
|
38
|
+
__export(constants_exports, {
|
|
39
|
+
CLOUDFLARED_VERSION: () => CLOUDFLARED_VERSION,
|
|
40
|
+
DEFAULT_CLOUDFLARED_BIN: () => DEFAULT_CLOUDFLARED_BIN,
|
|
41
|
+
RELEASE_BASE: () => RELEASE_BASE,
|
|
42
|
+
bin: () => bin,
|
|
43
|
+
use: () => use
|
|
44
|
+
});
|
|
45
|
+
module.exports = __toCommonJS(constants_exports);
|
|
46
|
+
var import_node_path = __toESM(__require("path"));
|
|
47
|
+
var DEFAULT_CLOUDFLARED_BIN = import_node_path.default.join(
|
|
48
|
+
__dirname,
|
|
49
|
+
"..",
|
|
50
|
+
"bin",
|
|
51
|
+
process.platform === "win32" ? "cloudflared.exe" : "cloudflared"
|
|
52
|
+
);
|
|
53
|
+
var bin = process.env.CLOUDFLARED_BIN || DEFAULT_CLOUDFLARED_BIN;
|
|
54
|
+
function use(executable) {
|
|
55
|
+
bin = executable;
|
|
56
|
+
}
|
|
57
|
+
var CLOUDFLARED_VERSION = process.env.CLOUDFLARED_VERSION || "latest";
|
|
58
|
+
var RELEASE_BASE = "https://github.com/cloudflare/cloudflared/releases/";
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
// node_modules/cloudflared/lib/error.js
|
|
63
|
+
var require_error = __commonJS({
|
|
64
|
+
"node_modules/cloudflared/lib/error.js"(exports, module) {
|
|
65
|
+
"use strict";
|
|
66
|
+
var __defProp = Object.defineProperty;
|
|
67
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
68
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
69
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
70
|
+
var __export = (target, all) => {
|
|
71
|
+
for (var name in all)
|
|
72
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
73
|
+
};
|
|
74
|
+
var __copyProps = (to, from, except, desc) => {
|
|
75
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
76
|
+
for (let key of __getOwnPropNames(from))
|
|
77
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
78
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
79
|
+
}
|
|
80
|
+
return to;
|
|
81
|
+
};
|
|
82
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
83
|
+
var error_exports = {};
|
|
84
|
+
__export(error_exports, {
|
|
85
|
+
UnsupportedError: () => UnsupportedError
|
|
86
|
+
});
|
|
87
|
+
module.exports = __toCommonJS(error_exports);
|
|
88
|
+
var UnsupportedError = class extends Error {
|
|
89
|
+
constructor(message) {
|
|
90
|
+
super(message);
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
// node_modules/cloudflared/lib/install.js
|
|
97
|
+
var require_install = __commonJS({
|
|
98
|
+
"node_modules/cloudflared/lib/install.js"(exports, module) {
|
|
99
|
+
"use strict";
|
|
100
|
+
var __create = Object.create;
|
|
101
|
+
var __defProp = Object.defineProperty;
|
|
102
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
103
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
104
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
105
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
106
|
+
var __export = (target, all) => {
|
|
107
|
+
for (var name in all)
|
|
108
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
109
|
+
};
|
|
110
|
+
var __copyProps = (to, from, except, desc) => {
|
|
111
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
112
|
+
for (let key of __getOwnPropNames(from))
|
|
113
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
114
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
115
|
+
}
|
|
116
|
+
return to;
|
|
117
|
+
};
|
|
118
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
119
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
120
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
121
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
122
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
123
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
124
|
+
mod
|
|
125
|
+
));
|
|
126
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
127
|
+
var install_exports = {};
|
|
128
|
+
__export(install_exports, {
|
|
129
|
+
install: () => install,
|
|
130
|
+
install_linux: () => install_linux,
|
|
131
|
+
install_macos: () => install_macos,
|
|
132
|
+
install_windows: () => install_windows
|
|
133
|
+
});
|
|
134
|
+
module.exports = __toCommonJS(install_exports);
|
|
135
|
+
var import_node_fs = __toESM(__require("fs"));
|
|
136
|
+
var import_node_path = __toESM(__require("path"));
|
|
137
|
+
var import_node_https = __toESM(__require("https"));
|
|
138
|
+
var import_node_child_process = __require("child_process");
|
|
139
|
+
var import_constants = require_constants();
|
|
140
|
+
var import_error = require_error();
|
|
141
|
+
var LINUX_URL = {
|
|
142
|
+
arm64: "cloudflared-linux-arm64",
|
|
143
|
+
arm: "cloudflared-linux-arm",
|
|
144
|
+
x64: "cloudflared-linux-amd64",
|
|
145
|
+
ia32: "cloudflared-linux-386"
|
|
146
|
+
};
|
|
147
|
+
var MACOS_URL = {
|
|
148
|
+
arm64: "cloudflared-darwin-arm64.tgz",
|
|
149
|
+
x64: "cloudflared-darwin-amd64.tgz"
|
|
150
|
+
};
|
|
151
|
+
var WINDOWS_URL = {
|
|
152
|
+
x64: "cloudflared-windows-amd64.exe",
|
|
153
|
+
ia32: "cloudflared-windows-386.exe"
|
|
154
|
+
};
|
|
155
|
+
function resolve_base(version) {
|
|
156
|
+
if (version === "latest") {
|
|
157
|
+
return `${import_constants.RELEASE_BASE}latest/download/`;
|
|
158
|
+
}
|
|
159
|
+
return `${import_constants.RELEASE_BASE}download/${version}/`;
|
|
160
|
+
}
|
|
161
|
+
async function install(to, version = import_constants.CLOUDFLARED_VERSION) {
|
|
162
|
+
if (process.platform === "linux") {
|
|
163
|
+
return install_linux(to, version);
|
|
164
|
+
} else if (process.platform === "darwin") {
|
|
165
|
+
return install_macos(to, version);
|
|
166
|
+
} else if (process.platform === "win32") {
|
|
167
|
+
return install_windows(to, version);
|
|
168
|
+
} else {
|
|
169
|
+
throw new import_error.UnsupportedError("Unsupported platform: " + process.platform);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
async function install_linux(to, version = import_constants.CLOUDFLARED_VERSION) {
|
|
173
|
+
const file = LINUX_URL[process.arch];
|
|
174
|
+
if (file === void 0) {
|
|
175
|
+
throw new import_error.UnsupportedError("Unsupported architecture: " + process.arch);
|
|
176
|
+
}
|
|
177
|
+
await download(resolve_base(version) + file, to);
|
|
178
|
+
import_node_fs.default.chmodSync(to, "755");
|
|
179
|
+
return to;
|
|
180
|
+
}
|
|
181
|
+
async function install_macos(to, version = import_constants.CLOUDFLARED_VERSION) {
|
|
182
|
+
let arch = process.arch;
|
|
183
|
+
if (version !== "latest" && version_number(version) < 20240802) {
|
|
184
|
+
arch = "x64";
|
|
185
|
+
}
|
|
186
|
+
const file = MACOS_URL[arch];
|
|
187
|
+
if (file === void 0) {
|
|
188
|
+
throw new import_error.UnsupportedError("Unsupported architecture: " + arch);
|
|
189
|
+
}
|
|
190
|
+
await download(resolve_base(version) + file, `${to}.tgz`);
|
|
191
|
+
process.env.VERBOSE && console.log(`Extracting to ${to}`);
|
|
192
|
+
(0, import_node_child_process.execSync)(`tar -xzf ${import_node_path.default.basename(`${to}.tgz`)}`, { cwd: import_node_path.default.dirname(to) });
|
|
193
|
+
import_node_fs.default.unlinkSync(`${to}.tgz`);
|
|
194
|
+
import_node_fs.default.renameSync(`${import_node_path.default.dirname(to)}/cloudflared`, to);
|
|
195
|
+
return to;
|
|
196
|
+
}
|
|
197
|
+
async function install_windows(to, version = import_constants.CLOUDFLARED_VERSION) {
|
|
198
|
+
const file = WINDOWS_URL[process.arch];
|
|
199
|
+
if (file === void 0) {
|
|
200
|
+
throw new import_error.UnsupportedError("Unsupported architecture: " + process.arch);
|
|
201
|
+
}
|
|
202
|
+
await download(resolve_base(version) + file, to);
|
|
203
|
+
return to;
|
|
204
|
+
}
|
|
205
|
+
function download(url, to, redirect = 0) {
|
|
206
|
+
if (redirect === 0) {
|
|
207
|
+
process.env.VERBOSE && console.log(`Downloading ${url} to ${to}`);
|
|
208
|
+
} else {
|
|
209
|
+
process.env.VERBOSE && console.log(`Redirecting to ${url}`);
|
|
210
|
+
}
|
|
211
|
+
if (!import_node_fs.default.existsSync(import_node_path.default.dirname(to))) {
|
|
212
|
+
import_node_fs.default.mkdirSync(import_node_path.default.dirname(to), { recursive: true });
|
|
213
|
+
}
|
|
214
|
+
return new Promise((resolve, reject) => {
|
|
215
|
+
const request = import_node_https.default.get(url, (res) => {
|
|
216
|
+
const redirect_code = [301, 302, 303, 307, 308];
|
|
217
|
+
if (redirect_code.includes(res.statusCode) && res.headers.location !== void 0) {
|
|
218
|
+
request.destroy();
|
|
219
|
+
const redirection = res.headers.location;
|
|
220
|
+
resolve(download(redirection, to, redirect + 1));
|
|
221
|
+
return;
|
|
222
|
+
}
|
|
223
|
+
if (res.statusCode && res.statusCode >= 200 && res.statusCode < 300) {
|
|
224
|
+
const file = import_node_fs.default.createWriteStream(to);
|
|
225
|
+
file.on("finish", () => {
|
|
226
|
+
file.close(() => resolve(to));
|
|
227
|
+
});
|
|
228
|
+
file.on("error", (err) => {
|
|
229
|
+
import_node_fs.default.unlink(to, () => reject(err));
|
|
230
|
+
});
|
|
231
|
+
res.pipe(file);
|
|
232
|
+
} else {
|
|
233
|
+
request.destroy();
|
|
234
|
+
reject(new Error(`HTTP response with status code: ${res.statusCode}`));
|
|
235
|
+
}
|
|
236
|
+
});
|
|
237
|
+
request.on("error", (err) => {
|
|
238
|
+
reject(err);
|
|
239
|
+
});
|
|
240
|
+
request.end();
|
|
241
|
+
});
|
|
242
|
+
}
|
|
243
|
+
function version_number(semver) {
|
|
244
|
+
const [major, minor, patch] = semver.split(".").map(Number);
|
|
245
|
+
return major * 1e4 + minor * 100 + patch;
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
});
|
|
249
|
+
|
|
250
|
+
// node_modules/cloudflared/lib/regex.js
|
|
251
|
+
var require_regex = __commonJS({
|
|
252
|
+
"node_modules/cloudflared/lib/regex.js"(exports, module) {
|
|
253
|
+
"use strict";
|
|
254
|
+
var __defProp = Object.defineProperty;
|
|
255
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
256
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
257
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
258
|
+
var __export = (target, all) => {
|
|
259
|
+
for (var name in all)
|
|
260
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
261
|
+
};
|
|
262
|
+
var __copyProps = (to, from, except, desc) => {
|
|
263
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
264
|
+
for (let key of __getOwnPropNames(from))
|
|
265
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
266
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
267
|
+
}
|
|
268
|
+
return to;
|
|
269
|
+
};
|
|
270
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
271
|
+
var regex_exports = {};
|
|
272
|
+
__export(regex_exports, {
|
|
273
|
+
config_regex: () => config_regex,
|
|
274
|
+
conn_regex: () => conn_regex,
|
|
275
|
+
connectorID_regex: () => connectorID_regex,
|
|
276
|
+
disconnect_regex: () => disconnect_regex,
|
|
277
|
+
index_regex: () => index_regex,
|
|
278
|
+
ip_regex: () => ip_regex,
|
|
279
|
+
location_regex: () => location_regex,
|
|
280
|
+
metrics_regex: () => metrics_regex,
|
|
281
|
+
tunnelID_regex: () => tunnelID_regex
|
|
282
|
+
});
|
|
283
|
+
module.exports = __toCommonJS(regex_exports);
|
|
284
|
+
var conn_regex = /connection[= ]([0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[0-9a-f]{4}-[0-9a-f]{12})/i;
|
|
285
|
+
var ip_regex = /ip=([0-9.]+)/;
|
|
286
|
+
var location_regex = /location=([A-Za-z0-9]+)/;
|
|
287
|
+
var index_regex = /connIndex=(\d)/;
|
|
288
|
+
var disconnect_regex = /Unregistered tunnel connection connIndex=(\d)/i;
|
|
289
|
+
var tunnelID_regex = /tunnelID=([0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[0-9a-f]{4}-[0-9a-f]{12})/i;
|
|
290
|
+
var connectorID_regex = /Connector ID: ([0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[0-9a-f]{4}-[0-9a-f]{12})/i;
|
|
291
|
+
var metrics_regex = /metrics server on ([0-9.:]+\/metrics)/;
|
|
292
|
+
var config_regex = /config="(.+[^\\])"/;
|
|
293
|
+
}
|
|
294
|
+
});
|
|
295
|
+
|
|
296
|
+
// node_modules/cloudflared/lib/handler.js
|
|
297
|
+
var require_handler = __commonJS({
|
|
298
|
+
"node_modules/cloudflared/lib/handler.js"(exports, module) {
|
|
299
|
+
"use strict";
|
|
300
|
+
var __defProp = Object.defineProperty;
|
|
301
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
302
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
303
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
304
|
+
var __export = (target, all) => {
|
|
305
|
+
for (var name in all)
|
|
306
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
307
|
+
};
|
|
308
|
+
var __copyProps = (to, from, except, desc) => {
|
|
309
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
310
|
+
for (let key of __getOwnPropNames(from))
|
|
311
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
312
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
313
|
+
}
|
|
314
|
+
return to;
|
|
315
|
+
};
|
|
316
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
317
|
+
var handler_exports = {};
|
|
318
|
+
__export(handler_exports, {
|
|
319
|
+
ConfigHandler: () => ConfigHandler,
|
|
320
|
+
ConnectionHandler: () => ConnectionHandler,
|
|
321
|
+
TryCloudflareHandler: () => TryCloudflareHandler
|
|
322
|
+
});
|
|
323
|
+
module.exports = __toCommonJS(handler_exports);
|
|
324
|
+
var import_node_stream = __require("stream");
|
|
325
|
+
var import_regex = require_regex();
|
|
326
|
+
var ConnectionHandler = class {
|
|
327
|
+
constructor(tunnel) {
|
|
328
|
+
this.connections = [];
|
|
329
|
+
this.connected_handler = (output, tunnel2) => {
|
|
330
|
+
const conn_match = output.match(import_regex.conn_regex);
|
|
331
|
+
const ip_match = output.match(import_regex.ip_regex);
|
|
332
|
+
const location_match = output.match(import_regex.location_regex);
|
|
333
|
+
const index_match = output.match(import_regex.index_regex);
|
|
334
|
+
if (conn_match && ip_match && location_match && index_match) {
|
|
335
|
+
const connection = {
|
|
336
|
+
id: conn_match[1],
|
|
337
|
+
ip: ip_match[1],
|
|
338
|
+
location: location_match[1]
|
|
339
|
+
};
|
|
340
|
+
this.connections[Number(index_match[1])] = connection;
|
|
341
|
+
tunnel2.emit("connected", connection);
|
|
342
|
+
}
|
|
343
|
+
};
|
|
344
|
+
this.disconnected_handler = (output, tunnel2) => {
|
|
345
|
+
const index_match = output.includes("terminated") ? output.match(import_regex.index_regex) : null;
|
|
346
|
+
if (index_match) {
|
|
347
|
+
const index = Number(index_match[1]);
|
|
348
|
+
if (this.connections[index]) {
|
|
349
|
+
tunnel2.emit("disconnected", this.connections[index]);
|
|
350
|
+
this.connections[index] = void 0;
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
};
|
|
354
|
+
tunnel.addHandler(this.connected_handler.bind(this));
|
|
355
|
+
tunnel.addHandler(this.disconnected_handler.bind(this));
|
|
356
|
+
}
|
|
357
|
+
};
|
|
358
|
+
var TryCloudflareHandler = class {
|
|
359
|
+
constructor(tunnel) {
|
|
360
|
+
this.url_handler = (output, tunnel2) => {
|
|
361
|
+
const url_match = output.match(/https:\/\/([a-z0-9-]+)\.trycloudflare\.com/);
|
|
362
|
+
if (url_match) {
|
|
363
|
+
tunnel2.emit("url", url_match[0]);
|
|
364
|
+
}
|
|
365
|
+
};
|
|
366
|
+
tunnel.addHandler(this.url_handler.bind(this));
|
|
367
|
+
}
|
|
368
|
+
};
|
|
369
|
+
var ConfigHandler = class extends import_node_stream.EventEmitter {
|
|
370
|
+
constructor(tunnel) {
|
|
371
|
+
super();
|
|
372
|
+
this.config_handler = (output, tunnel2) => {
|
|
373
|
+
const config_match = output.match(/\bconfig="(.+?)" version=(\d+)/);
|
|
374
|
+
if (config_match) {
|
|
375
|
+
try {
|
|
376
|
+
const config_str = config_match[1].replace(/\\"/g, '"');
|
|
377
|
+
const config = JSON.parse(config_str);
|
|
378
|
+
const version = parseInt(config_match[2], 10);
|
|
379
|
+
this.emit("config", {
|
|
380
|
+
config,
|
|
381
|
+
version
|
|
382
|
+
});
|
|
383
|
+
if (config && typeof config === "object" && "ingress" in config && Array.isArray(config.ingress)) {
|
|
384
|
+
for (const ingress of config.ingress) {
|
|
385
|
+
if ("hostname" in ingress) {
|
|
386
|
+
tunnel2.emit("url", ingress.hostname);
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
} catch (error) {
|
|
391
|
+
this.emit("error", new Error(`Failed to parse config: ${error}`));
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
};
|
|
395
|
+
tunnel.addHandler(this.config_handler.bind(this));
|
|
396
|
+
}
|
|
397
|
+
on(event, listener) {
|
|
398
|
+
return super.on(event, listener);
|
|
399
|
+
}
|
|
400
|
+
once(event, listener) {
|
|
401
|
+
return super.once(event, listener);
|
|
402
|
+
}
|
|
403
|
+
off(event, listener) {
|
|
404
|
+
return super.off(event, listener);
|
|
405
|
+
}
|
|
406
|
+
emit(event, ...args) {
|
|
407
|
+
return super.emit(event, ...args);
|
|
408
|
+
}
|
|
409
|
+
};
|
|
410
|
+
}
|
|
411
|
+
});
|
|
412
|
+
|
|
413
|
+
// node_modules/cloudflared/lib/tunnel.js
|
|
414
|
+
var require_tunnel = __commonJS({
|
|
415
|
+
"node_modules/cloudflared/lib/tunnel.js"(exports, module) {
|
|
416
|
+
"use strict";
|
|
417
|
+
var __defProp = Object.defineProperty;
|
|
418
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
419
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
420
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
421
|
+
var __export = (target, all) => {
|
|
422
|
+
for (var name in all)
|
|
423
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
424
|
+
};
|
|
425
|
+
var __copyProps = (to, from, except, desc) => {
|
|
426
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
427
|
+
for (let key of __getOwnPropNames(from))
|
|
428
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
429
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
430
|
+
}
|
|
431
|
+
return to;
|
|
432
|
+
};
|
|
433
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
434
|
+
var tunnel_exports = {};
|
|
435
|
+
__export(tunnel_exports, {
|
|
436
|
+
Tunnel: () => Tunnel,
|
|
437
|
+
build_args: () => build_args,
|
|
438
|
+
build_options: () => build_options,
|
|
439
|
+
tunnel: () => tunnel
|
|
440
|
+
});
|
|
441
|
+
module.exports = __toCommonJS(tunnel_exports);
|
|
442
|
+
var import_node_child_process = __require("child_process");
|
|
443
|
+
var import_node_events = __require("events");
|
|
444
|
+
var import_constants = require_constants();
|
|
445
|
+
var import_handler = require_handler();
|
|
446
|
+
var Tunnel = class _Tunnel extends import_node_events.EventEmitter {
|
|
447
|
+
constructor(options = ["tunnel", "--hello-world"]) {
|
|
448
|
+
super();
|
|
449
|
+
this.outputHandlers = [];
|
|
450
|
+
this.stop = this._stop.bind(this);
|
|
451
|
+
this.setupDefaultHandlers();
|
|
452
|
+
const args = Array.isArray(options) ? options : build_args(options);
|
|
453
|
+
this._process = this.createProcess(args);
|
|
454
|
+
this.setupEventHandlers();
|
|
455
|
+
}
|
|
456
|
+
get process() {
|
|
457
|
+
return this._process;
|
|
458
|
+
}
|
|
459
|
+
setupDefaultHandlers() {
|
|
460
|
+
new import_handler.ConnectionHandler(this);
|
|
461
|
+
new import_handler.TryCloudflareHandler(this);
|
|
462
|
+
}
|
|
463
|
+
/**
|
|
464
|
+
* Add a custom output handler
|
|
465
|
+
* @param handler Function to handle cloudflared output
|
|
466
|
+
*/
|
|
467
|
+
addHandler(handler) {
|
|
468
|
+
this.outputHandlers.push(handler);
|
|
469
|
+
}
|
|
470
|
+
/**
|
|
471
|
+
* Remove a previously added output handler
|
|
472
|
+
* @param handler The handler to remove
|
|
473
|
+
*/
|
|
474
|
+
removeHandler(handler) {
|
|
475
|
+
const index = this.outputHandlers.indexOf(handler);
|
|
476
|
+
if (index !== -1) {
|
|
477
|
+
this.outputHandlers.splice(index, 1);
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
processOutput(output) {
|
|
481
|
+
for (const handler of this.outputHandlers) {
|
|
482
|
+
try {
|
|
483
|
+
handler(output, this);
|
|
484
|
+
} catch (error) {
|
|
485
|
+
this.emit("error", error instanceof Error ? error : new Error(String(error)));
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
}
|
|
489
|
+
setupEventHandlers() {
|
|
490
|
+
this.on("stdout", (output) => {
|
|
491
|
+
this.processOutput(output);
|
|
492
|
+
});
|
|
493
|
+
this.on("stderr", (output) => {
|
|
494
|
+
this.processOutput(output);
|
|
495
|
+
});
|
|
496
|
+
}
|
|
497
|
+
createProcess(args) {
|
|
498
|
+
var _a, _b;
|
|
499
|
+
const child = (0, import_node_child_process.spawn)(import_constants.bin, args, { stdio: ["ignore", "pipe", "pipe"] });
|
|
500
|
+
child.on("error", (error) => this.emit("error", error));
|
|
501
|
+
child.on("exit", (code, signal) => this.emit("exit", code, signal));
|
|
502
|
+
if (process.env.VERBOSE) {
|
|
503
|
+
child.stdout.pipe(process.stdout);
|
|
504
|
+
child.stderr.pipe(process.stderr);
|
|
505
|
+
}
|
|
506
|
+
(_a = child.stdout) == null ? void 0 : _a.on("data", (data) => this.emit("stdout", data.toString()));
|
|
507
|
+
(_b = child.stderr) == null ? void 0 : _b.on("data", (data) => this.emit("stderr", data.toString()));
|
|
508
|
+
return child;
|
|
509
|
+
}
|
|
510
|
+
_stop() {
|
|
511
|
+
return this.process.kill("SIGINT");
|
|
512
|
+
}
|
|
513
|
+
on(event, listener) {
|
|
514
|
+
return super.on(event, listener);
|
|
515
|
+
}
|
|
516
|
+
once(event, listener) {
|
|
517
|
+
return super.once(event, listener);
|
|
518
|
+
}
|
|
519
|
+
off(event, listener) {
|
|
520
|
+
return super.off(event, listener);
|
|
521
|
+
}
|
|
522
|
+
emit(event, ...args) {
|
|
523
|
+
return super.emit(event, ...args);
|
|
524
|
+
}
|
|
525
|
+
/**
|
|
526
|
+
* Create a quick tunnel without a Cloudflare account.
|
|
527
|
+
* @param url The local service URL to connect to. If not provided, the hello world mode will be used.
|
|
528
|
+
* @param options The options to pass to cloudflared.
|
|
529
|
+
*/
|
|
530
|
+
static quick(url, options = {}) {
|
|
531
|
+
const args = ["tunnel"];
|
|
532
|
+
if (url) {
|
|
533
|
+
args.push("--url", url);
|
|
534
|
+
} else {
|
|
535
|
+
args.push("--hello-world");
|
|
536
|
+
}
|
|
537
|
+
args.push(...build_options(options));
|
|
538
|
+
return new _Tunnel(args);
|
|
539
|
+
}
|
|
540
|
+
/**
|
|
541
|
+
* Create a tunnel with a Cloudflare account.
|
|
542
|
+
* @param token The Cloudflare Tunnel token.
|
|
543
|
+
* @param options The options to pass to cloudflared.
|
|
544
|
+
*/
|
|
545
|
+
static withToken(token, options = {}) {
|
|
546
|
+
options["--token"] = token;
|
|
547
|
+
return new _Tunnel(build_args(options));
|
|
548
|
+
}
|
|
549
|
+
};
|
|
550
|
+
function tunnel(options = {}) {
|
|
551
|
+
return new Tunnel(options);
|
|
552
|
+
}
|
|
553
|
+
function build_args(options) {
|
|
554
|
+
const args = "--hello-world" in options ? ["tunnel"] : ["tunnel", "run"];
|
|
555
|
+
args.push(...build_options(options));
|
|
556
|
+
return args;
|
|
557
|
+
}
|
|
558
|
+
function build_options(options) {
|
|
559
|
+
const opts = [];
|
|
560
|
+
for (const [key, value] of Object.entries(options)) {
|
|
561
|
+
if (typeof value === "string") {
|
|
562
|
+
opts.push(`${key}`, value);
|
|
563
|
+
} else if (typeof value === "number") {
|
|
564
|
+
opts.push(`${key}`, value.toString());
|
|
565
|
+
} else if (typeof value === "boolean") {
|
|
566
|
+
if (value === true) {
|
|
567
|
+
opts.push(`${key}`);
|
|
568
|
+
}
|
|
569
|
+
}
|
|
570
|
+
}
|
|
571
|
+
return opts;
|
|
572
|
+
}
|
|
573
|
+
}
|
|
574
|
+
});
|
|
575
|
+
|
|
576
|
+
// node_modules/cloudflared/lib/service.js
|
|
577
|
+
var require_service = __commonJS({
|
|
578
|
+
"node_modules/cloudflared/lib/service.js"(exports, module) {
|
|
579
|
+
"use strict";
|
|
580
|
+
var __create = Object.create;
|
|
581
|
+
var __defProp = Object.defineProperty;
|
|
582
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
583
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
584
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
585
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
586
|
+
var __export = (target, all) => {
|
|
587
|
+
for (var name in all)
|
|
588
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
589
|
+
};
|
|
590
|
+
var __copyProps = (to, from, except, desc) => {
|
|
591
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
592
|
+
for (let key of __getOwnPropNames(from))
|
|
593
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
594
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
595
|
+
}
|
|
596
|
+
return to;
|
|
597
|
+
};
|
|
598
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
599
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
600
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
601
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
602
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
603
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
604
|
+
mod
|
|
605
|
+
));
|
|
606
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
607
|
+
var service_exports = {};
|
|
608
|
+
__export(service_exports, {
|
|
609
|
+
AlreadyInstalledError: () => AlreadyInstalledError2,
|
|
610
|
+
LINUX_SERVICE_PATH: () => LINUX_SERVICE_PATH,
|
|
611
|
+
MACOS_SERVICE_PATH: () => MACOS_SERVICE_PATH2,
|
|
612
|
+
NotInstalledError: () => NotInstalledError2,
|
|
613
|
+
clean: () => clean,
|
|
614
|
+
current: () => current,
|
|
615
|
+
err: () => err,
|
|
616
|
+
exists: () => exists,
|
|
617
|
+
identifier: () => identifier2,
|
|
618
|
+
install: () => install,
|
|
619
|
+
journal: () => journal,
|
|
620
|
+
log: () => log,
|
|
621
|
+
service: () => service2,
|
|
622
|
+
service_name: () => service_name,
|
|
623
|
+
uninstall: () => uninstall
|
|
624
|
+
});
|
|
625
|
+
module.exports = __toCommonJS(service_exports);
|
|
626
|
+
var import_node_os = __toESM(__require("os"));
|
|
627
|
+
var import_node_fs = __toESM(__require("fs"));
|
|
628
|
+
var import_node_child_process = __require("child_process");
|
|
629
|
+
var import_constants = require_constants();
|
|
630
|
+
var import_regex = require_regex();
|
|
631
|
+
var identifier2 = "com.cloudflare.cloudflared";
|
|
632
|
+
var service_name = "cloudflared.service";
|
|
633
|
+
var MACOS_SERVICE_PATH2 = {
|
|
634
|
+
PLIST: is_root() ? `/Library/LaunchDaemons/${identifier2}.plist` : `${import_node_os.default.homedir()}/Library/LaunchAgents/${identifier2}.plist`,
|
|
635
|
+
OUT: is_root() ? `/Library/Logs/${identifier2}.out.log` : `${import_node_os.default.homedir()}/Library/Logs/${identifier2}.out.log`,
|
|
636
|
+
ERR: is_root() ? `/Library/Logs/${identifier2}.err.log` : `${import_node_os.default.homedir()}/Library/Logs/${identifier2}.err.log`
|
|
637
|
+
};
|
|
638
|
+
var LINUX_SERVICE_PATH = {
|
|
639
|
+
SYSTEMD: `/etc/systemd/system/${service_name}`,
|
|
640
|
+
SERVICE: "/etc/init.d/cloudflared",
|
|
641
|
+
SERVICE_OUT: "/var/log/cloudflared.log",
|
|
642
|
+
SERVICE_ERR: "/var/log/cloudflared.err"
|
|
643
|
+
};
|
|
644
|
+
var service2 = { install, uninstall, exists, log, err, current, clean, journal };
|
|
645
|
+
var AlreadyInstalledError2 = class extends Error {
|
|
646
|
+
constructor() {
|
|
647
|
+
super("service is already installed");
|
|
648
|
+
}
|
|
649
|
+
};
|
|
650
|
+
var NotInstalledError2 = class extends Error {
|
|
651
|
+
constructor() {
|
|
652
|
+
super("service is not installed");
|
|
653
|
+
}
|
|
654
|
+
};
|
|
655
|
+
function install(token) {
|
|
656
|
+
if (!["darwin", "linux"].includes(process.platform)) {
|
|
657
|
+
throw new Error(`Not Implemented on platform ${process.platform}`);
|
|
658
|
+
}
|
|
659
|
+
if (exists()) {
|
|
660
|
+
throw new AlreadyInstalledError2();
|
|
661
|
+
}
|
|
662
|
+
const args = ["service", "install"];
|
|
663
|
+
if (token) {
|
|
664
|
+
args.push(token);
|
|
665
|
+
}
|
|
666
|
+
const result = (0, import_node_child_process.spawnSync)(import_constants.bin, args);
|
|
667
|
+
if (result.status !== 0) {
|
|
668
|
+
throw new Error(`service install failed: ${result.stderr.toString()}`);
|
|
669
|
+
}
|
|
670
|
+
}
|
|
671
|
+
function uninstall() {
|
|
672
|
+
if (!["darwin", "linux"].includes(process.platform)) {
|
|
673
|
+
throw new Error(`Not Implemented on platform ${process.platform}`);
|
|
674
|
+
}
|
|
675
|
+
if (!exists()) {
|
|
676
|
+
throw new NotInstalledError2();
|
|
677
|
+
}
|
|
678
|
+
const result = (0, import_node_child_process.spawnSync)(import_constants.bin, ["service", "uninstall"]);
|
|
679
|
+
if (result.status !== 0) {
|
|
680
|
+
throw new Error(`service uninstall failed: ${result.stderr.toString()}`);
|
|
681
|
+
}
|
|
682
|
+
if (process.platform === "darwin") {
|
|
683
|
+
import_node_fs.default.rmSync(MACOS_SERVICE_PATH2.OUT);
|
|
684
|
+
import_node_fs.default.rmSync(MACOS_SERVICE_PATH2.ERR);
|
|
685
|
+
} else if (process.platform === "linux" && !is_systemd()) {
|
|
686
|
+
import_node_fs.default.rmSync(LINUX_SERVICE_PATH.SERVICE_OUT);
|
|
687
|
+
import_node_fs.default.rmSync(LINUX_SERVICE_PATH.SERVICE_ERR);
|
|
688
|
+
}
|
|
689
|
+
}
|
|
690
|
+
function log() {
|
|
691
|
+
if (!exists()) {
|
|
692
|
+
throw new NotInstalledError2();
|
|
693
|
+
}
|
|
694
|
+
if (process.platform === "darwin") {
|
|
695
|
+
return import_node_fs.default.readFileSync(MACOS_SERVICE_PATH2.OUT, "utf8");
|
|
696
|
+
}
|
|
697
|
+
if (process.platform === "linux" && !is_systemd()) {
|
|
698
|
+
return import_node_fs.default.readFileSync(LINUX_SERVICE_PATH.SERVICE_OUT, "utf8");
|
|
699
|
+
}
|
|
700
|
+
throw new Error(`Not Implemented on platform ${process.platform}`);
|
|
701
|
+
}
|
|
702
|
+
function err() {
|
|
703
|
+
if (!exists()) {
|
|
704
|
+
throw new NotInstalledError2();
|
|
705
|
+
}
|
|
706
|
+
if (process.platform === "darwin") {
|
|
707
|
+
return import_node_fs.default.readFileSync(MACOS_SERVICE_PATH2.ERR, "utf8");
|
|
708
|
+
}
|
|
709
|
+
if (process.platform === "linux" && !is_systemd()) {
|
|
710
|
+
return import_node_fs.default.readFileSync(LINUX_SERVICE_PATH.SERVICE_ERR, "utf8");
|
|
711
|
+
}
|
|
712
|
+
throw new Error(`Not Implemented on platform ${process.platform}`);
|
|
713
|
+
}
|
|
714
|
+
function journal(n = 300) {
|
|
715
|
+
if (process.platform === "linux" && is_systemd()) {
|
|
716
|
+
const args = ["-u", service_name, "-o", "cat", "-n", n.toString()];
|
|
717
|
+
return (0, import_node_child_process.spawnSync)("journalctl", args).stdout.toString();
|
|
718
|
+
}
|
|
719
|
+
throw new Error(`Not Implemented on platform ${process.platform}`);
|
|
720
|
+
}
|
|
721
|
+
function current() {
|
|
722
|
+
var _a, _b, _c, _d;
|
|
723
|
+
if (!["darwin", "linux"].includes(process.platform)) {
|
|
724
|
+
throw new Error(`Not Implemented on platform ${process.platform}`);
|
|
725
|
+
}
|
|
726
|
+
if (!exists()) {
|
|
727
|
+
throw new NotInstalledError2();
|
|
728
|
+
}
|
|
729
|
+
const log2 = is_systemd() ? journal() : err();
|
|
730
|
+
let tunnelID = "";
|
|
731
|
+
let connectorID = "";
|
|
732
|
+
const connections = [];
|
|
733
|
+
let metrics = "";
|
|
734
|
+
let config = {};
|
|
735
|
+
for (const line of log2.split("\n")) {
|
|
736
|
+
try {
|
|
737
|
+
if (line.match(import_regex.tunnelID_regex)) {
|
|
738
|
+
tunnelID = ((_a = line.match(import_regex.tunnelID_regex)) == null ? void 0 : _a[1]) ?? "";
|
|
739
|
+
} else if (line.match(import_regex.connectorID_regex)) {
|
|
740
|
+
connectorID = ((_b = line.match(import_regex.connectorID_regex)) == null ? void 0 : _b[1]) ?? "";
|
|
741
|
+
} else if (line.match(import_regex.conn_regex) && line.match(import_regex.location_regex) && line.match(import_regex.ip_regex) && line.match(import_regex.index_regex)) {
|
|
742
|
+
const [, id] = line.match(import_regex.conn_regex) ?? [];
|
|
743
|
+
const [, location] = line.match(import_regex.location_regex) ?? [];
|
|
744
|
+
const [, ip] = line.match(import_regex.ip_regex) ?? [];
|
|
745
|
+
const [, idx] = line.match(import_regex.index_regex) ?? [];
|
|
746
|
+
connections[parseInt(idx)] = { id, ip, location };
|
|
747
|
+
} else if (line.match(import_regex.disconnect_regex)) {
|
|
748
|
+
const [, idx] = line.match(import_regex.disconnect_regex) ?? [];
|
|
749
|
+
if (parseInt(idx) in connections) {
|
|
750
|
+
connections[parseInt(idx)] = { id: "", ip: "", location: "" };
|
|
751
|
+
}
|
|
752
|
+
} else if (line.match(import_regex.metrics_regex)) {
|
|
753
|
+
metrics = ((_c = line.match(import_regex.metrics_regex)) == null ? void 0 : _c[1]) ?? "";
|
|
754
|
+
} else if (line.match(import_regex.config_regex)) {
|
|
755
|
+
config = JSON.parse(((_d = line.match(import_regex.config_regex)) == null ? void 0 : _d[1].replace(/\\/g, "")) ?? "{}");
|
|
756
|
+
}
|
|
757
|
+
} catch (err2) {
|
|
758
|
+
if (process.env.VERBOSE) {
|
|
759
|
+
console.error("log parsing failed", err2);
|
|
760
|
+
}
|
|
761
|
+
}
|
|
762
|
+
}
|
|
763
|
+
return { tunnelID, connectorID, connections, metrics, config };
|
|
764
|
+
}
|
|
765
|
+
function clean() {
|
|
766
|
+
if (process.platform !== "darwin") {
|
|
767
|
+
throw new Error(`Not Implemented on platform ${process.platform}`);
|
|
768
|
+
}
|
|
769
|
+
if (exists()) {
|
|
770
|
+
throw new AlreadyInstalledError2();
|
|
771
|
+
}
|
|
772
|
+
import_node_fs.default.rmSync(MACOS_SERVICE_PATH2.OUT, { force: true });
|
|
773
|
+
import_node_fs.default.rmSync(MACOS_SERVICE_PATH2.ERR, { force: true });
|
|
774
|
+
}
|
|
775
|
+
function exists() {
|
|
776
|
+
if (process.platform === "darwin") {
|
|
777
|
+
return import_node_fs.default.existsSync(MACOS_SERVICE_PATH2.PLIST);
|
|
778
|
+
} else if (process.platform === "linux") {
|
|
779
|
+
return is_systemd() ? import_node_fs.default.existsSync(LINUX_SERVICE_PATH.SYSTEMD) : import_node_fs.default.existsSync(LINUX_SERVICE_PATH.SERVICE);
|
|
780
|
+
}
|
|
781
|
+
throw new Error(`Not Implemented on platform ${process.platform}`);
|
|
782
|
+
}
|
|
783
|
+
function is_root() {
|
|
784
|
+
var _a;
|
|
785
|
+
return ((_a = process.getuid) == null ? void 0 : _a.call(process)) === 0;
|
|
786
|
+
}
|
|
787
|
+
function is_systemd() {
|
|
788
|
+
return process.platform === "linux" && import_node_fs.default.existsSync("/run/systemd/system");
|
|
789
|
+
}
|
|
790
|
+
}
|
|
791
|
+
});
|
|
792
|
+
|
|
793
|
+
// node_modules/cloudflared/lib/lib.js
|
|
794
|
+
var require_lib = __commonJS({
|
|
795
|
+
"node_modules/cloudflared/lib/lib.js"(exports, module) {
|
|
796
|
+
var __defProp = Object.defineProperty;
|
|
797
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
798
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
799
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
800
|
+
var __export = (target, all) => {
|
|
801
|
+
for (var name in all)
|
|
802
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
803
|
+
};
|
|
804
|
+
var __copyProps = (to, from, except, desc) => {
|
|
805
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
806
|
+
for (let key of __getOwnPropNames(from))
|
|
807
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
808
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
809
|
+
}
|
|
810
|
+
return to;
|
|
811
|
+
};
|
|
812
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
813
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
814
|
+
var lib_exports = {};
|
|
815
|
+
__export(lib_exports, {
|
|
816
|
+
AlreadyInstalledError: () => import_service.AlreadyInstalledError,
|
|
817
|
+
MACOS_SERVICE_PATH: () => import_service.MACOS_SERVICE_PATH,
|
|
818
|
+
NotInstalledError: () => import_service.NotInstalledError,
|
|
819
|
+
identifier: () => import_service.identifier,
|
|
820
|
+
service: () => import_service.service
|
|
821
|
+
});
|
|
822
|
+
module.exports = __toCommonJS(lib_exports);
|
|
823
|
+
__reExport(lib_exports, require_constants(), module.exports);
|
|
824
|
+
__reExport(lib_exports, require_install(), module.exports);
|
|
825
|
+
__reExport(lib_exports, require_tunnel(), module.exports);
|
|
826
|
+
var import_service = require_service();
|
|
827
|
+
__reExport(lib_exports, require_handler(), module.exports);
|
|
828
|
+
}
|
|
829
|
+
});
|
|
830
|
+
export default require_lib();
|