opentunnel-cli 1.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.
Files changed (55) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +284 -0
  3. package/dist/cli/index.d.ts +3 -0
  4. package/dist/cli/index.d.ts.map +1 -0
  5. package/dist/cli/index.js +1357 -0
  6. package/dist/cli/index.js.map +1 -0
  7. package/dist/client/NgrokClient.d.ts +40 -0
  8. package/dist/client/NgrokClient.d.ts.map +1 -0
  9. package/dist/client/NgrokClient.js +155 -0
  10. package/dist/client/NgrokClient.js.map +1 -0
  11. package/dist/client/TunnelClient.d.ts +47 -0
  12. package/dist/client/TunnelClient.d.ts.map +1 -0
  13. package/dist/client/TunnelClient.js +435 -0
  14. package/dist/client/TunnelClient.js.map +1 -0
  15. package/dist/client/index.d.ts +3 -0
  16. package/dist/client/index.d.ts.map +1 -0
  17. package/dist/client/index.js +8 -0
  18. package/dist/client/index.js.map +1 -0
  19. package/dist/dns/CloudflareDNS.d.ts +45 -0
  20. package/dist/dns/CloudflareDNS.d.ts.map +1 -0
  21. package/dist/dns/CloudflareDNS.js +286 -0
  22. package/dist/dns/CloudflareDNS.js.map +1 -0
  23. package/dist/dns/DuckDNS.d.ts +20 -0
  24. package/dist/dns/DuckDNS.d.ts.map +1 -0
  25. package/dist/dns/DuckDNS.js +109 -0
  26. package/dist/dns/DuckDNS.js.map +1 -0
  27. package/dist/dns/index.d.ts +3 -0
  28. package/dist/dns/index.d.ts.map +1 -0
  29. package/dist/dns/index.js +9 -0
  30. package/dist/dns/index.js.map +1 -0
  31. package/dist/index.d.ts +7 -0
  32. package/dist/index.d.ts.map +1 -0
  33. package/dist/index.js +35 -0
  34. package/dist/index.js.map +1 -0
  35. package/dist/server/CertManager.d.ts +54 -0
  36. package/dist/server/CertManager.d.ts.map +1 -0
  37. package/dist/server/CertManager.js +414 -0
  38. package/dist/server/CertManager.js.map +1 -0
  39. package/dist/server/TunnelServer.d.ts +42 -0
  40. package/dist/server/TunnelServer.d.ts.map +1 -0
  41. package/dist/server/TunnelServer.js +790 -0
  42. package/dist/server/TunnelServer.js.map +1 -0
  43. package/dist/server/index.d.ts +3 -0
  44. package/dist/server/index.d.ts.map +1 -0
  45. package/dist/server/index.js +48 -0
  46. package/dist/server/index.js.map +1 -0
  47. package/dist/shared/types.d.ts +147 -0
  48. package/dist/shared/types.d.ts.map +1 -0
  49. package/dist/shared/types.js +3 -0
  50. package/dist/shared/types.js.map +1 -0
  51. package/dist/shared/utils.d.ts +29 -0
  52. package/dist/shared/utils.d.ts.map +1 -0
  53. package/dist/shared/utils.js +135 -0
  54. package/dist/shared/utils.js.map +1 -0
  55. package/package.json +66 -0
@@ -0,0 +1,286 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.CloudflareDNS = void 0;
7
+ const cloudflare_1 = __importDefault(require("cloudflare"));
8
+ const utils_1 = require("../shared/utils");
9
+ class CloudflareDNS {
10
+ constructor(apiToken, domain, basePath = "op") {
11
+ this.name = "Cloudflare";
12
+ this.zoneId = null;
13
+ this.serverIP = null;
14
+ this.recordCache = new Map(); // subdomain -> recordId
15
+ this.client = new cloudflare_1.default({ apiToken });
16
+ this.domain = domain;
17
+ this.basePath = basePath;
18
+ this.logger = new utils_1.Logger("CloudflareDNS");
19
+ }
20
+ async initialize() {
21
+ try {
22
+ // Find zone ID for the domain
23
+ this.zoneId = await this.findZoneId();
24
+ if (!this.zoneId) {
25
+ this.logger.error(`Zone not found for domain: ${this.domain}`);
26
+ return false;
27
+ }
28
+ // Get server's public IP
29
+ this.serverIP = await this.getPublicIP();
30
+ this.logger.info(`Initialized for ${this.domain} (Zone: ${this.zoneId.slice(0, 8)}...)`);
31
+ this.logger.info(`Server IP: ${this.serverIP}`);
32
+ return true;
33
+ }
34
+ catch (err) {
35
+ this.logger.error(`Initialization failed: ${err.message}`);
36
+ return false;
37
+ }
38
+ }
39
+ async findZoneId() {
40
+ try {
41
+ const zones = await this.client.zones.list();
42
+ // Find zone that matches the domain
43
+ for (const zone of zones.result || []) {
44
+ if (this.domain === zone.name || this.domain.endsWith(`.${zone.name}`)) {
45
+ return zone.id;
46
+ }
47
+ }
48
+ return null;
49
+ }
50
+ catch (err) {
51
+ this.logger.error(`Failed to list zones: ${err.message}`);
52
+ return null;
53
+ }
54
+ }
55
+ async getPublicIP() {
56
+ return new Promise((resolve, reject) => {
57
+ const https = require("https");
58
+ https.get("https://api.ipify.org", (res) => {
59
+ let data = "";
60
+ res.on("data", (chunk) => (data += chunk));
61
+ res.on("end", () => resolve(data.trim()));
62
+ }).on("error", reject);
63
+ });
64
+ }
65
+ /**
66
+ * Create or update a DNS A record for a subdomain
67
+ * Full record will be: subdomain.basePath.domain (e.g., myapp.op.example.com)
68
+ */
69
+ async updateRecord(subdomain, ip) {
70
+ if (!this.zoneId) {
71
+ this.logger.error("Not initialized - call initialize() first");
72
+ return false;
73
+ }
74
+ const targetIP = ip || this.serverIP;
75
+ if (!targetIP) {
76
+ this.logger.error("No IP address available");
77
+ return false;
78
+ }
79
+ // Full record name: subdomain.op.domain.com
80
+ const recordName = `${subdomain}.${this.basePath}.${this.domain}`;
81
+ try {
82
+ // Check if record already exists
83
+ const existingRecord = await this.findRecord(recordName);
84
+ if (existingRecord) {
85
+ // Update existing record
86
+ if (existingRecord.content === targetIP) {
87
+ this.logger.info(`Record ${recordName} already points to ${targetIP}`);
88
+ return true;
89
+ }
90
+ await this.client.dns.records.update(existingRecord.id, {
91
+ zone_id: this.zoneId,
92
+ type: "A",
93
+ name: recordName,
94
+ content: targetIP,
95
+ ttl: 60, // 1 minute TTL for quick updates
96
+ proxied: false,
97
+ });
98
+ this.logger.info(`Updated ${recordName} -> ${targetIP}`);
99
+ }
100
+ else {
101
+ // Create new record
102
+ const result = await this.client.dns.records.create({
103
+ zone_id: this.zoneId,
104
+ type: "A",
105
+ name: recordName,
106
+ content: targetIP,
107
+ ttl: 60,
108
+ proxied: false,
109
+ });
110
+ this.recordCache.set(subdomain, result.id);
111
+ this.logger.info(`Created ${recordName} -> ${targetIP}`);
112
+ }
113
+ return true;
114
+ }
115
+ catch (err) {
116
+ this.logger.error(`Failed to update record ${recordName}: ${err.message}`);
117
+ return false;
118
+ }
119
+ }
120
+ /**
121
+ * Delete a DNS record for a subdomain
122
+ */
123
+ async deleteRecord(subdomain) {
124
+ if (!this.zoneId) {
125
+ this.logger.error("Not initialized - call initialize() first");
126
+ return false;
127
+ }
128
+ const recordName = `${subdomain}.${this.basePath}.${this.domain}`;
129
+ try {
130
+ const existingRecord = await this.findRecord(recordName);
131
+ if (!existingRecord) {
132
+ this.logger.info(`Record ${recordName} does not exist`);
133
+ return true;
134
+ }
135
+ await this.client.dns.records.delete(existingRecord.id, {
136
+ zone_id: this.zoneId,
137
+ });
138
+ this.recordCache.delete(subdomain);
139
+ this.logger.info(`Deleted ${recordName}`);
140
+ return true;
141
+ }
142
+ catch (err) {
143
+ this.logger.error(`Failed to delete record ${recordName}: ${err.message}`);
144
+ return false;
145
+ }
146
+ }
147
+ /**
148
+ * Find an existing DNS record by name
149
+ */
150
+ async findRecord(name) {
151
+ if (!this.zoneId)
152
+ return null;
153
+ try {
154
+ const records = await this.client.dns.records.list({
155
+ zone_id: this.zoneId,
156
+ name: { exact: name },
157
+ type: "A",
158
+ });
159
+ if (records.result && records.result.length > 0) {
160
+ const record = records.result[0];
161
+ return {
162
+ id: record.id,
163
+ name: record.name,
164
+ type: record.type,
165
+ content: record.content,
166
+ };
167
+ }
168
+ return null;
169
+ }
170
+ catch {
171
+ return null;
172
+ }
173
+ }
174
+ /**
175
+ * Ensure wildcard record exists (*.op.domain.com)
176
+ * This is a fallback for subdomains not explicitly created
177
+ */
178
+ async ensureWildcardRecord() {
179
+ if (!this.zoneId || !this.serverIP) {
180
+ return false;
181
+ }
182
+ const wildcardName = `*.${this.basePath}.${this.domain}`;
183
+ try {
184
+ const existingRecord = await this.findRecord(wildcardName);
185
+ if (existingRecord) {
186
+ if (existingRecord.content === this.serverIP) {
187
+ this.logger.info(`Wildcard record already exists: ${wildcardName}`);
188
+ return true;
189
+ }
190
+ // Update to current IP
191
+ await this.client.dns.records.update(existingRecord.id, {
192
+ zone_id: this.zoneId,
193
+ type: "A",
194
+ name: wildcardName,
195
+ content: this.serverIP,
196
+ ttl: 300,
197
+ proxied: false,
198
+ });
199
+ this.logger.info(`Updated wildcard record: ${wildcardName} -> ${this.serverIP}`);
200
+ }
201
+ else {
202
+ await this.client.dns.records.create({
203
+ zone_id: this.zoneId,
204
+ type: "A",
205
+ name: wildcardName,
206
+ content: this.serverIP,
207
+ ttl: 300,
208
+ proxied: false,
209
+ });
210
+ this.logger.info(`Created wildcard record: ${wildcardName} -> ${this.serverIP}`);
211
+ }
212
+ return true;
213
+ }
214
+ catch (err) {
215
+ this.logger.error(`Failed to create wildcard record: ${err.message}`);
216
+ return false;
217
+ }
218
+ }
219
+ /**
220
+ * Ensure base domain record exists (op.domain.com)
221
+ */
222
+ async ensureBaseRecord() {
223
+ if (!this.zoneId || !this.serverIP) {
224
+ return false;
225
+ }
226
+ const baseName = `${this.basePath}.${this.domain}`;
227
+ try {
228
+ const existingRecord = await this.findRecord(baseName);
229
+ if (existingRecord) {
230
+ if (existingRecord.content === this.serverIP) {
231
+ this.logger.info(`Base record already exists: ${baseName}`);
232
+ return true;
233
+ }
234
+ await this.client.dns.records.update(existingRecord.id, {
235
+ zone_id: this.zoneId,
236
+ type: "A",
237
+ name: baseName,
238
+ content: this.serverIP,
239
+ ttl: 300,
240
+ proxied: false,
241
+ });
242
+ this.logger.info(`Updated base record: ${baseName} -> ${this.serverIP}`);
243
+ }
244
+ else {
245
+ await this.client.dns.records.create({
246
+ zone_id: this.zoneId,
247
+ type: "A",
248
+ name: baseName,
249
+ content: this.serverIP,
250
+ ttl: 300,
251
+ proxied: false,
252
+ });
253
+ this.logger.info(`Created base record: ${baseName} -> ${this.serverIP}`);
254
+ }
255
+ return true;
256
+ }
257
+ catch (err) {
258
+ this.logger.error(`Failed to create base record: ${err.message}`);
259
+ return false;
260
+ }
261
+ }
262
+ /**
263
+ * Setup all necessary DNS records for the tunnel server
264
+ * Creates: op.domain.com and *.op.domain.com
265
+ */
266
+ async setupDNS() {
267
+ this.logger.info("Setting up DNS records...");
268
+ const baseSuccess = await this.ensureBaseRecord();
269
+ const wildcardSuccess = await this.ensureWildcardRecord();
270
+ if (baseSuccess && wildcardSuccess) {
271
+ this.logger.info("DNS setup complete!");
272
+ this.logger.info(` Base: ${this.basePath}.${this.domain}`);
273
+ this.logger.info(` Wildcard: *.${this.basePath}.${this.domain}`);
274
+ return true;
275
+ }
276
+ return false;
277
+ }
278
+ getZoneId() {
279
+ return this.zoneId;
280
+ }
281
+ getServerIP() {
282
+ return this.serverIP;
283
+ }
284
+ }
285
+ exports.CloudflareDNS = CloudflareDNS;
286
+ //# sourceMappingURL=CloudflareDNS.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CloudflareDNS.js","sourceRoot":"","sources":["../../src/dns/CloudflareDNS.ts"],"names":[],"mappings":";;;;;;AAAA,4DAAoC;AAEpC,2CAAyC;AASzC,MAAa,aAAa;IAUtB,YAAY,QAAgB,EAAE,MAAc,EAAE,WAAmB,IAAI;QAT9D,SAAI,GAAG,YAAY,CAAC;QAGnB,WAAM,GAAkB,IAAI,CAAC;QAG7B,aAAQ,GAAkB,IAAI,CAAC;QAC/B,gBAAW,GAAwB,IAAI,GAAG,EAAE,CAAC,CAAC,wBAAwB;QAG1E,IAAI,CAAC,MAAM,GAAG,IAAI,oBAAU,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC;QAC3C,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,MAAM,GAAG,IAAI,cAAM,CAAC,eAAe,CAA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C,IAAI,CAAC,wBAAwB,QAAQ,OAAO,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC;YAC7E,CAAC;YAED,OAAO,IAAI,CAAC;QAChB,CAAC;QAAC,OAAO,GAAQ,EAAE,CAAC;YAChB,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,iCAAiC,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC;YAClE,OAAO,KAAK,CAAC;QACjB,CAAC;IACL,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,QAAQ;QACV,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,2BAA2B,CAAC,CAAC;QAE9C,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC,gBAAgB,EAAE,CAAC;QAClD,MAAM,eAAe,GAAG,MAAM,IAAI,CAAC,oBAAoB,EAAE,CAAC;QAE1D,IAAI,WAAW,IAAI,eAAe,EAAE,CAAC;YACjC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAC;YACxC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,eAAe,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC;YAChE,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,iBAAiB,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC;YAClE,OAAO,IAAI,CAAC;QAChB,CAAC;QAED,OAAO,KAAK,CAAC;IACjB,CAAC;IAED,SAAS;QACL,OAAO,IAAI,CAAC,MAAM,CAAC;IACvB,CAAC;IAED,WAAW;QACP,OAAO,IAAI,CAAC,QAAQ,CAAC;IACzB,CAAC;CACJ;AAnTD,sCAmTC"}
@@ -0,0 +1,20 @@
1
+ import { DnsProvider } from "../shared/types";
2
+ export declare class DuckDNS implements DnsProvider {
3
+ name: string;
4
+ private token;
5
+ private logger;
6
+ constructor(token: string);
7
+ updateRecord(subdomain: string, ip: string): Promise<boolean>;
8
+ deleteRecord(subdomain: string): Promise<boolean>;
9
+ getPublicIP(): Promise<string>;
10
+ }
11
+ export declare class CustomDNS implements DnsProvider {
12
+ name: string;
13
+ private apiUrl;
14
+ private apiKey;
15
+ private logger;
16
+ constructor(apiUrl: string, apiKey: string);
17
+ updateRecord(subdomain: string, ip: string): Promise<boolean>;
18
+ deleteRecord(subdomain: string): Promise<boolean>;
19
+ }
20
+ //# sourceMappingURL=DuckDNS.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DuckDNS.d.ts","sourceRoot":"","sources":["../../src/dns/DuckDNS.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAG9C,qBAAa,OAAQ,YAAW,WAAW;IAChC,IAAI,SAAa;IACxB,OAAO,CAAC,KAAK,CAAS;IACtB,OAAO,CAAC,MAAM,CAAS;gBAEX,KAAK,EAAE,MAAM;IAKnB,YAAY,CAAC,SAAS,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAoB7D,YAAY,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAKjD,WAAW,IAAI,OAAO,CAAC,MAAM,CAAC;CASvC;AAED,qBAAa,SAAU,YAAW,WAAW;IAClC,IAAI,SAAe;IAC1B,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,MAAM,CAAS;gBAEX,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;IAMpC,YAAY,CAAC,SAAS,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IA6B7D,YAAY,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;CAwB1D"}
@@ -0,0 +1,109 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.CustomDNS = exports.DuckDNS = void 0;
7
+ const https_1 = __importDefault(require("https"));
8
+ const utils_1 = require("../shared/utils");
9
+ class DuckDNS {
10
+ constructor(token) {
11
+ this.name = "DuckDNS";
12
+ this.token = token;
13
+ this.logger = new utils_1.Logger("DuckDNS");
14
+ }
15
+ async updateRecord(subdomain, ip) {
16
+ return new Promise((resolve) => {
17
+ const url = `https://www.duckdns.org/update?domains=${subdomain}&token=${this.token}&ip=${ip}`;
18
+ https_1.default.get(url, (res) => {
19
+ let data = "";
20
+ res.on("data", (chunk) => (data += chunk));
21
+ res.on("end", () => {
22
+ const success = data.trim() === "OK";
23
+ if (success)
24
+ this.logger.info(`Updated ${subdomain} to ${ip}`);
25
+ else
26
+ this.logger.error(`Failed to update ${subdomain}: ${data}`);
27
+ resolve(success);
28
+ });
29
+ }).on("error", (err) => {
30
+ this.logger.error(`Request failed: ${err.message}`);
31
+ resolve(false);
32
+ });
33
+ });
34
+ }
35
+ async deleteRecord(subdomain) {
36
+ // DuckDNS doesn't support deleting records, just clear the IP
37
+ return this.updateRecord(subdomain, "");
38
+ }
39
+ async getPublicIP() {
40
+ return new Promise((resolve, reject) => {
41
+ https_1.default.get("https://api.ipify.org", (res) => {
42
+ let data = "";
43
+ res.on("data", (chunk) => (data += chunk));
44
+ res.on("end", () => resolve(data.trim()));
45
+ }).on("error", reject);
46
+ });
47
+ }
48
+ }
49
+ exports.DuckDNS = DuckDNS;
50
+ class CustomDNS {
51
+ constructor(apiUrl, apiKey) {
52
+ this.name = "CustomDNS";
53
+ this.apiUrl = apiUrl;
54
+ this.apiKey = apiKey;
55
+ this.logger = new utils_1.Logger("CustomDNS");
56
+ }
57
+ async updateRecord(subdomain, ip) {
58
+ try {
59
+ const url = new URL(this.apiUrl);
60
+ const postData = JSON.stringify({ subdomain, ip, apiKey: this.apiKey });
61
+ return new Promise((resolve) => {
62
+ const req = https_1.default.request({
63
+ hostname: url.hostname,
64
+ port: url.port || 443,
65
+ path: url.pathname,
66
+ method: "POST",
67
+ headers: {
68
+ "Content-Type": "application/json",
69
+ "Content-Length": Buffer.byteLength(postData),
70
+ "Authorization": `Bearer ${this.apiKey}`,
71
+ },
72
+ }, (res) => {
73
+ resolve(res.statusCode === 200);
74
+ });
75
+ req.on("error", () => resolve(false));
76
+ req.write(postData);
77
+ req.end();
78
+ });
79
+ }
80
+ catch {
81
+ return false;
82
+ }
83
+ }
84
+ async deleteRecord(subdomain) {
85
+ try {
86
+ const url = new URL(this.apiUrl);
87
+ return new Promise((resolve) => {
88
+ const req = https_1.default.request({
89
+ hostname: url.hostname,
90
+ port: url.port || 443,
91
+ path: `${url.pathname}/${subdomain}`,
92
+ method: "DELETE",
93
+ headers: {
94
+ "Authorization": `Bearer ${this.apiKey}`,
95
+ },
96
+ }, (res) => {
97
+ resolve(res.statusCode === 200);
98
+ });
99
+ req.on("error", () => resolve(false));
100
+ req.end();
101
+ });
102
+ }
103
+ catch {
104
+ return false;
105
+ }
106
+ }
107
+ }
108
+ exports.CustomDNS = CustomDNS;
109
+ //# sourceMappingURL=DuckDNS.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DuckDNS.js","sourceRoot":"","sources":["../../src/dns/DuckDNS.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAE1B,2CAAyC;AAEzC,MAAa,OAAO;IAKhB,YAAY,KAAa;QAJlB,SAAI,GAAG,SAAS,CAAC;QAKpB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,MAAM,GAAG,IAAI,cAAM,CAAC,SAAS,CAAC,CAAC;IACxC,CAAC;IAED,KAAK,CAAC,YAAY,CAAC,SAAiB,EAAE,EAAU;QAC5C,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;YAC3B,MAAM,GAAG,GAAG,0CAA0C,SAAS,UAAU,IAAI,CAAC,KAAK,OAAO,EAAE,EAAE,CAAC;YAE/F,eAAK,C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J;AAjED,8BAiEC"}
@@ -0,0 +1,3 @@
1
+ export { DuckDNS, CustomDNS } from "./DuckDNS";
2
+ export { CloudflareDNS } from "./CloudflareDNS";
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/dns/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC"}
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CloudflareDNS = exports.CustomDNS = exports.DuckDNS = void 0;
4
+ var DuckDNS_1 = require("./DuckDNS");
5
+ Object.defineProperty(exports, "DuckDNS", { enumerable: true, get: function () { return DuckDNS_1.DuckDNS; } });
6
+ Object.defineProperty(exports, "CustomDNS", { enumerable: true, get: function () { return DuckDNS_1.CustomDNS; } });
7
+ var CloudflareDNS_1 = require("./CloudflareDNS");
8
+ Object.defineProperty(exports, "CloudflareDNS", { enumerable: true, get: function () { return CloudflareDNS_1.CloudflareDNS; } });
9
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/dns/index.ts"],"names":[],"mappings":";;;AAAA,qCAA+C;AAAtC,kGAAA,OAAO,OAAA;AAAE,oGAAA,SAAS,OAAA;AAC3B,iDAAgD;AAAvC,8GAAA,aAAa,OAAA"}
@@ -0,0 +1,7 @@
1
+ export { TunnelServer } from "./server/TunnelServer";
2
+ export { TunnelClient } from "./client/TunnelClient";
3
+ export { NgrokClient } from "./client/NgrokClient";
4
+ export { DuckDNS, CustomDNS, CloudflareDNS } from "./dns";
5
+ export * from "./shared/types";
6
+ export * from "./shared/utils";
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAGrD,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAGnD,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAG1D,cAAc,gBAAgB,CAAC;AAG/B,cAAc,gBAAgB,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.CloudflareDNS = exports.CustomDNS = exports.DuckDNS = exports.NgrokClient = exports.TunnelClient = exports.TunnelServer = void 0;
18
+ // Server
19
+ var TunnelServer_1 = require("./server/TunnelServer");
20
+ Object.defineProperty(exports, "TunnelServer", { enumerable: true, get: function () { return TunnelServer_1.TunnelServer; } });
21
+ // Clients
22
+ var TunnelClient_1 = require("./client/TunnelClient");
23
+ Object.defineProperty(exports, "TunnelClient", { enumerable: true, get: function () { return TunnelClient_1.TunnelClient; } });
24
+ var NgrokClient_1 = require("./client/NgrokClient");
25
+ Object.defineProperty(exports, "NgrokClient", { enumerable: true, get: function () { return NgrokClient_1.NgrokClient; } });
26
+ // DNS Providers
27
+ var dns_1 = require("./dns");
28
+ Object.defineProperty(exports, "DuckDNS", { enumerable: true, get: function () { return dns_1.DuckDNS; } });
29
+ Object.defineProperty(exports, "CustomDNS", { enumerable: true, get: function () { return dns_1.CustomDNS; } });
30
+ Object.defineProperty(exports, "CloudflareDNS", { enumerable: true, get: function () { return dns_1.CloudflareDNS; } });
31
+ // Types
32
+ __exportStar(require("./shared/types"), exports);
33
+ // Utilities
34
+ __exportStar(require("./shared/utils"), exports);
35
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,SAAS;AACT,sDAAqD;AAA5C,4GAAA,YAAY,OAAA;AAErB,UAAU;AACV,sDAAqD;AAA5C,4GAAA,YAAY,OAAA;AACrB,oDAAmD;AAA1C,0GAAA,WAAW,OAAA;AAEpB,gBAAgB;AAChB,6BAA0D;AAAjD,8FAAA,OAAO,OAAA;AAAE,gGAAA,SAAS,OAAA;AAAE,oGAAA,aAAa,OAAA;AAE1C,QAAQ;AACR,iDAA+B;AAE/B,YAAY;AACZ,iDAA+B"}
@@ -0,0 +1,54 @@
1
+ import * as http from "http";
2
+ interface CertificateInfo {
3
+ cert: string;
4
+ key: string;
5
+ expiresAt: Date;
6
+ domains: string[];
7
+ }
8
+ export declare class CertManager {
9
+ private certsDir;
10
+ private logger;
11
+ private accountKey;
12
+ private client;
13
+ private pendingChallenges;
14
+ private pendingDnsChallenges;
15
+ private isProduction;
16
+ private email;
17
+ private cloudflare;
18
+ private cloudflareZoneId;
19
+ constructor(options: {
20
+ certsDir?: string;
21
+ email?: string;
22
+ production?: boolean;
23
+ cloudflareToken?: string;
24
+ });
25
+ initialize(): Promise<void>;
26
+ findCloudflareZone(domain: string): Promise<string | null>;
27
+ getCertificate(domains: string[]): Promise<CertificateInfo | null>;
28
+ requestCertificate(domains: string[]): Promise<CertificateInfo>;
29
+ private createDnsChallenge;
30
+ private removeDnsChallenge;
31
+ handleChallengeRequest(token: string): string | null;
32
+ createChallengeServer(): http.Server;
33
+ hasCertificate(domain: string): boolean;
34
+ loadCertificate(domain: string): {
35
+ cert: string;
36
+ key: string;
37
+ } | null;
38
+ hasCloudflare(): boolean;
39
+ /**
40
+ * Generate a self-signed certificate for local/development use.
41
+ * No external dependencies required.
42
+ */
43
+ generateSelfSignedCertificate(domain: string, options?: {
44
+ validDays?: number;
45
+ organization?: string;
46
+ }): CertificateInfo;
47
+ /**
48
+ * Get or generate a self-signed certificate for the given domain.
49
+ * This is the main entry point for automatic local HTTPS.
50
+ */
51
+ getOrCreateSelfSignedCert(domain: string): CertificateInfo;
52
+ }
53
+ export {};
54
+ //# sourceMappingURL=CertManager.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CertManager.d.ts","sourceRoot":"","sources":["../../src/server/CertManager.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAK7B,UAAU,eAAe;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,SAAS,EAAE,IAAI,CAAC;IAChB,OAAO,EAAE,MAAM,EAAE,CAAC;CACrB;AAYD,qBAAa,WAAW;IACpB,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,UAAU,CAAiC;IACnD,OAAO,CAAC,MAAM,CAA4B;IAC1C,OAAO,CAAC,iBAAiB,CAA4C;IACrE,OAAO,CAAC,oBAAoB,CAAwC;IACpE,OAAO,CAAC,YAAY,CAAU;IAC9B,OAAO,CAAC,KAAK,CAAS;IACtB,OAAO,CAAC,UAAU,CAA2B;IAC7C,OAAO,CAAC,gBAAgB,CAAuB;gBAEnC,OAAO,EAAE;QACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,UAAU,CAAC,EAAE,O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