chemicaljs 1.8.6 → 1.9.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.
@@ -304,45 +304,6 @@ window.chemical.decode = async function (url, config) {
304
304
  }
305
305
  };
306
306
 
307
- function checkWhitelist(entries, filter) {
308
- let matched = false;
309
- for (let entry of entries) {
310
- if (filter(entry)) {
311
- matched = true;
312
- break;
313
- }
314
- }
315
- return !matched;
316
- }
317
-
318
- function checkBlacklist(entries, filter) {
319
- for (let entry of entries) {
320
- if (filter(entry)) return true;
321
- }
322
- return false;
323
- }
324
-
325
- window.chemical.blocked = function (url) {
326
- let parsedURL;
327
- try {
328
- parsedURL = new URL(url);
329
- } catch {
330
- return false;
331
- }
332
-
333
- if (hostnameWhitelist.length) {
334
- return check_whitelist(hostnameWhitelist, (entry) =>
335
- entry.test(parsedURL.hostname)
336
- );
337
- } else if (hostnameBlacklist.length) {
338
- return checkBlacklist(hostnameBlacklist, (entry) =>
339
- entry.test(parsedURL.hostname)
340
- );
341
- } else {
342
- return false;
343
- }
344
- };
345
-
346
307
  function getTransport(transport) {
347
308
  switch (transport) {
348
309
  default:
package/index.js CHANGED
@@ -44,12 +44,16 @@ class ChemicalServer {
44
44
  options.uv = true;
45
45
  }
46
46
 
47
- if (options.scramjet == undefined) {
48
- options.scramjet = true;
47
+ if (options.experimental == undefined) {
48
+ options.experimental = {}
49
49
  }
50
50
 
51
- if (options.meteor == undefined) {
52
- options.meteor = true;
51
+ if (options.experimental.scramjet == undefined) {
52
+ options.experimental.scramjet = false;
53
+ }
54
+
55
+ if (options.experimental.meteor == undefined) {
56
+ options.experimental.meteor = false;
53
57
  }
54
58
 
55
59
  if (options.rammerhead == undefined) {
@@ -95,12 +99,12 @@ class ChemicalServer {
95
99
  "const uvEnabled = " + String(this.options.uv) + ";\n" + chemicalMain;
96
100
  chemicalMain =
97
101
  "const scramjetEnabled = " +
98
- String(this.options.scramjet) +
102
+ String(this.options.experimental.scramjet) +
99
103
  ";\n" +
100
104
  chemicalMain;
101
105
  chemicalMain =
102
106
  "const meteorEnabled = " +
103
- String(this.options.meteor) +
107
+ String(this.options.experimental.meteor) +
104
108
  ";\n" +
105
109
  chemicalMain;
106
110
  chemicalMain =
@@ -108,20 +112,6 @@ class ChemicalServer {
108
112
  String(this.options.rammerhead) +
109
113
  ";\n" +
110
114
  chemicalMain;
111
- chemicalMain =
112
- "const hostnameBlacklist = [" +
113
- (this.options.hostname_blacklist
114
- ? this.options.hostname_blacklist.join(", ")
115
- : "") +
116
- "];\n" +
117
- chemicalMain;
118
- chemicalMain =
119
- "const hostnameWhitelist = [" +
120
- (this.options.hostname_whitelist
121
- ? this.options.hostname_whitelist.join(", ")
122
- : "") +
123
- "];\n" +
124
- chemicalMain;
125
115
 
126
116
  chemicalMain = "(async () => {\n" + chemicalMain + "\n})();";
127
117
 
@@ -138,12 +128,12 @@ class ChemicalServer {
138
128
  "const uvEnabled = " + String(this.options.uv) + ";\n" + chemicalSW;
139
129
  chemicalSW =
140
130
  "const scramjetEnabled = " +
141
- String(this.options.scramjet) +
131
+ String(this.options.experimental.scramjet) +
142
132
  ";\n" +
143
133
  chemicalSW;
144
134
  chemicalSW =
145
135
  "const meteorEnabled = " +
146
- String(this.options.meteor) +
136
+ String(this.options.experimental.meteor) +
147
137
  ";\n" +
148
138
  chemicalSW;
149
139
  chemicalSW =
@@ -163,14 +153,14 @@ class ChemicalServer {
163
153
  this.app.use("/uv/", express.static(resolve(__dirname, "config/uv")));
164
154
  this.app.use("/uv/", express.static(uvPath));
165
155
  }
166
- if (this.options.scramjet) {
156
+ if (this.options.experimental.scramjet) {
167
157
  this.app.use(
168
158
  "/scramjet/",
169
159
  express.static(resolve(__dirname, "config/scramjet"))
170
160
  );
171
161
  this.app.use("/scramjet/", express.static(scramjetPath));
172
162
  }
173
- if (this.options.meteor) {
163
+ if (this.options.experimental.meteor) {
174
164
  this.app.use(
175
165
  "/meteor/",
176
166
  express.static(resolve(__dirname, "config/meteor"))
@@ -186,11 +176,10 @@ class ChemicalServer {
186
176
  });
187
177
  this.server.on("upgrade", (req, socket, head) => {
188
178
  if (req.url && req.url.endsWith("/wisp/")) {
189
- if (this.options.hostname_blacklist) {
190
- wisp.options.hostname_blacklist = this.options.hostname_blacklist;
191
- }
192
- if (this.options.hostname_whitelist) {
193
- wisp.options.hostname_whitelist = this.options.hostname_whitelist;
179
+ if (this.options.wispOptions) {
180
+ for (let option in this.options.wispOptions) {
181
+ wisp.options[option] = this.options.wispOptions[option]
182
+ }
194
183
  }
195
184
  wisp.routeRequest(req, socket, head);
196
185
  } else if (this.options.rammerhead && shouldRouteRh(req)) {
@@ -221,12 +210,16 @@ const ChemicalVitePlugin = (options) => ({
221
210
  options.uv = true;
222
211
  }
223
212
 
224
- if (options.scramjet == undefined) {
225
- options.scramjet = true;
213
+ if (options.experimental == undefined) {
214
+ options.experimental = {}
226
215
  }
227
216
 
228
- if (options.meteor == undefined) {
229
- options.meteor = true;
217
+ if (options.experimental.scramjet == undefined) {
218
+ options.experimental.scramjet = false;
219
+ }
220
+
221
+ if (options.experimental.meteor == undefined) {
222
+ options.experimental.meteor = false;
230
223
  }
231
224
 
232
225
  if (options.rammerhead == undefined) {
@@ -262,12 +255,12 @@ const ChemicalVitePlugin = (options) => ({
262
255
  "const uvEnabled = " + String(options.uv) + ";\n" + chemicalMain;
263
256
  chemicalMain =
264
257
  "const scramjetEnabled = " +
265
- String(options.scramjet) +
258
+ String(options.experimental.scramjet) +
266
259
  ";\n" +
267
260
  chemicalMain;
268
261
  chemicalMain =
269
262
  "const meteorEnabled = " +
270
- String(options.meteor) +
263
+ String(options.experimental.meteor) +
271
264
  ";\n" +
272
265
  chemicalMain;
273
266
  chemicalMain =
@@ -275,20 +268,6 @@ const ChemicalVitePlugin = (options) => ({
275
268
  String(options.rammerhead) +
276
269
  ";\n" +
277
270
  chemicalMain;
278
- chemicalMain =
279
- "const hostnameBlacklist = [" +
280
- (options.hostname_blacklist
281
- ? options.hostname_blacklist.join(", ")
282
- : "") +
283
- "];\n" +
284
- chemicalMain;
285
- chemicalMain =
286
- "const hostnameWhitelist = [" +
287
- (options.hostname_whitelist
288
- ? options.hostname_whitelist.join(", ")
289
- : "") +
290
- "];\n" +
291
- chemicalMain;
292
271
 
293
272
  chemicalMain = "(async () => {\n" + chemicalMain + "\n})();";
294
273
 
@@ -305,11 +284,11 @@ const ChemicalVitePlugin = (options) => ({
305
284
  "const uvEnabled = " + String(options.uv) + ";\n" + chemicalSW;
306
285
  chemicalSW =
307
286
  "const scramjetEnabled = " +
308
- String(options.scramjet) +
287
+ String(options.experimental.scramjet) +
309
288
  ";\n" +
310
289
  chemicalSW;
311
290
  chemicalSW =
312
- "const meteorEnabled = " + String(options.meteor) + ";\n" + chemicalSW;
291
+ "const meteorEnabled = " + String(options.experimental.meteor) + ";\n" + chemicalSW;
313
292
  chemicalSW =
314
293
  "const rammerheadEnabled = " +
315
294
  String(options.rammerhead) +
@@ -327,14 +306,14 @@ const ChemicalVitePlugin = (options) => ({
327
306
  app.use("/uv/", express.static(resolve(__dirname, "config/uv")));
328
307
  app.use("/uv/", express.static(uvPath));
329
308
  }
330
- if (options.scramjet) {
309
+ if (options.experimental.scramjet) {
331
310
  app.use(
332
311
  "/scramjet/",
333
312
  express.static(resolve(__dirname, "config/scramjet"))
334
313
  );
335
314
  app.use("/scramjet/", express.static(scramjetPath));
336
315
  }
337
- if (options.meteor) {
316
+ if (options.experimental.meteor) {
338
317
  app.use("/meteor/", express.static(resolve(__dirname, "config/meteor")));
339
318
  app.use("/meteor/", express.static(meteorPath));
340
319
  }
@@ -357,11 +336,10 @@ const ChemicalVitePlugin = (options) => ({
357
336
 
358
337
  server.httpServer.on("upgrade", (req, socket, head) => {
359
338
  if (req.url && req.url.endsWith("/wisp/")) {
360
- if (options.hostname_blacklist) {
361
- wisp.options.hostname_blacklist = options.hostname_blacklist;
362
- }
363
- if (options.hostname_whitelist) {
364
- wisp.options.hostname_whitelist = options.hostname_whitelist;
339
+ if (options.wispOptions) {
340
+ for (let option in options.wispOptions) {
341
+ wisp.options[option] = options.wispOptions[option]
342
+ }
365
343
  }
366
344
  wisp.routeRequest(req, socket, head);
367
345
  } else if (options.rammerhead && shouldRouteRh(req)) {
@@ -402,12 +380,16 @@ class ChemicalBuild {
402
380
  options.uv = true;
403
381
  }
404
382
 
405
- if (options.scramjet == undefined) {
406
- options.scramjet = true;
383
+ if (options.experimental == undefined) {
384
+ options.experimental = {}
385
+ }
386
+
387
+ if (options.experimental.scramjet == undefined) {
388
+ options.experimental.scramjet = false;
407
389
  }
408
390
 
409
- if (options.meteor == undefined) {
410
- options.meteor = true;
391
+ if (options.experimental.meteor == undefined) {
392
+ options.experimental.meteor = false;
411
393
  }
412
394
 
413
395
  if (options.rammerhead == undefined) {
@@ -453,12 +435,12 @@ class ChemicalBuild {
453
435
  "const uvEnabled = " + String(this.options.uv) + ";\n" + chemicalMain;
454
436
  chemicalMain =
455
437
  "const scramjetEnabled = " +
456
- String(this.options.scramjet) +
438
+ String(this.options.experimental.scramjet) +
457
439
  ";\n" +
458
440
  chemicalMain;
459
441
  chemicalMain =
460
442
  "const meteorEnabled = " +
461
- String(this.options.meteor) +
443
+ String(this.options.experimental.meteor) +
462
444
  ";\n" +
463
445
  chemicalMain;
464
446
  chemicalMain =
@@ -466,20 +448,6 @@ class ChemicalBuild {
466
448
  String(this.options.rammerhead) +
467
449
  ";\n" +
468
450
  chemicalMain;
469
- chemicalMain =
470
- "const hostnameBlacklist = [" +
471
- (this.options.hostname_blacklist
472
- ? this.options.hostname_blacklist.join(", ")
473
- : "") +
474
- "];\n" +
475
- chemicalMain;
476
- chemicalMain =
477
- "const hostnameWhitelist = [" +
478
- (this.options.hostname_whitelist
479
- ? this.options.hostname_whitelist.join(", ")
480
- : "") +
481
- "];\n" +
482
- chemicalMain;
483
451
 
484
452
  chemicalMain = "(async () => {\n" + chemicalMain + "\n})();";
485
453
 
@@ -494,12 +462,12 @@ class ChemicalBuild {
494
462
  "const uvEnabled = " + String(this.options.uv) + ";\n" + chemicalSW;
495
463
  chemicalSW =
496
464
  "const scramjetEnabled = " +
497
- String(this.options.scramjet) +
465
+ String(this.options.experimental.scramjet) +
498
466
  ";\n" +
499
467
  chemicalSW;
500
468
  chemicalSW =
501
469
  "const meteorEnabled = " +
502
- String(this.options.meteor) +
470
+ String(this.options.experimental.meteor) +
503
471
  ";\n" +
504
472
  chemicalSW;
505
473
  chemicalSW =
@@ -527,7 +495,7 @@ class ChemicalBuild {
527
495
  resolve(this.options.path, "uv/uv.config.js")
528
496
  );
529
497
  }
530
- if (this.options.scramjet) {
498
+ if (this.options.experimental.scramjet) {
531
499
  cpSync(scramjetPath, resolve(this.options.path, "scramjet"), {
532
500
  recursive: true,
533
501
  });
@@ -536,7 +504,7 @@ class ChemicalBuild {
536
504
  resolve(this.options.path, "scramjet/scramjet.config.js")
537
505
  );
538
506
  }
539
- if (this.options.meteor) {
507
+ if (this.options.experimental.meteor) {
540
508
  cpSync(meteorPath, resolve(this.options.path, "meteor"), {
541
509
  recursive: true,
542
510
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "chemicaljs",
3
- "version": "1.8.6",
3
+ "version": "1.9.0",
4
4
  "description": "Easily create your own web proxy with no experience required.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -18,7 +18,7 @@
18
18
  "@mercuryworkshop/epoxy-transport": "^2.1.11",
19
19
  "@mercuryworkshop/libcurl-transport": "^1.3.10",
20
20
  "@mercuryworkshop/scramjet": "^1.0.2",
21
- "@mercuryworkshop/wisp-js": "^0.3.0",
21
+ "@mercuryworkshop/wisp-js": "^0.3.1",
22
22
  "@rubynetwork/rammerhead": "^1.3.2",
23
23
  "@titaniumnetwork-dev/ultraviolet": "^3.2.7",
24
24
  "express": "^4.21.0",