@mercuryworkshop/scramjet 2.0.0-alpha → 2.0.2-alpha

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 (61) hide show
  1. package/dist/a68dd7a5344f1722.wasm +0 -0
  2. package/dist/c34a4f083a11eae2.wasm +0 -0
  3. package/dist/scramjet.js +33 -0
  4. package/dist/scramjet.js.map +1 -0
  5. package/dist/scramjet.mjs +33 -0
  6. package/dist/scramjet.mjs.map +1 -0
  7. package/dist/scramjet.wasm +0 -0
  8. package/dist/scramjet_bundled.js +33 -0
  9. package/dist/scramjet_bundled.js.map +1 -0
  10. package/dist/scramjet_bundled.mjs +33 -0
  11. package/dist/scramjet_bundled.mjs.map +1 -0
  12. package/dist/types/client/client.d.ts +91 -0
  13. package/dist/types/client/entry.d.ts +5 -0
  14. package/dist/types/client/events.d.ts +38 -0
  15. package/dist/types/client/helpers.d.ts +1 -0
  16. package/dist/types/client/index.d.ts +7 -0
  17. package/dist/types/client/location.d.ts +2 -0
  18. package/dist/types/client/shared/eval.d.ts +3 -0
  19. package/dist/types/client/shared/sourcemaps.d.ts +19 -0
  20. package/dist/types/client/shared/wrap.d.ts +4 -0
  21. package/dist/types/client/singletonbox.d.ts +14 -0
  22. package/dist/types/fetch/index.d.ts +80 -0
  23. package/dist/types/index.d.ts +9 -0
  24. package/dist/types/index.js +26 -0
  25. package/dist/types/index.js.map +1 -0
  26. package/dist/types/shared/cookie.d.ts +18 -0
  27. package/dist/types/shared/headers.d.ts +13 -0
  28. package/dist/types/shared/htmlRules.d.ts +6 -0
  29. package/dist/types/shared/index.d.ts +23 -0
  30. package/dist/types/shared/rewriters/css.d.ts +4 -0
  31. package/dist/types/shared/rewriters/html.d.ts +6 -0
  32. package/dist/types/shared/rewriters/index.d.ts +6 -0
  33. package/dist/types/shared/rewriters/js.d.ts +11 -0
  34. package/dist/types/shared/rewriters/url.d.ts +11 -0
  35. package/dist/types/shared/rewriters/wasm.d.ts +8 -0
  36. package/dist/types/shared/rewriters/worker.d.ts +3 -0
  37. package/dist/types/shared/security/index.d.ts +1 -0
  38. package/dist/types/shared/security/siteTests.d.ts +1 -0
  39. package/dist/types/symbols.d.ts +7 -0
  40. package/dist/types/types.d.ts +115 -0
  41. package/lib/index.d.ts +5 -0
  42. package/package.json +96 -84
  43. package/LICENSE +0 -661
  44. package/README.md +0 -65
  45. package/dist/06813b79f94926ac.wasm +0 -0
  46. package/dist/09d5a95846afcaf1.wasm +0 -0
  47. package/dist/507621c43f70fc86.wasm +0 -0
  48. package/dist/63d477311eb50f38.wasm +0 -0
  49. package/dist/70102b41994b76de.wasm +0 -0
  50. package/dist/a31cde01c0b49ef3.wasm +0 -0
  51. package/dist/b4f3c1c0e4a92823.wasm +0 -0
  52. package/dist/d864ec42994880cb.wasm +0 -0
  53. package/dist/dbbe994629c3010c.wasm +0 -0
  54. package/dist/scramjet.all.js +0 -194
  55. package/dist/scramjet.all.js.map +0 -1
  56. package/dist/scramjet.bundle.js +0 -194
  57. package/dist/scramjet.bundle.js.map +0 -1
  58. package/dist/scramjet.sync.js +0 -2
  59. package/dist/scramjet.sync.js.map +0 -1
  60. package/dist/scramjet.wasm.wasm +0 -0
  61. package/lib/noop.js +0 -0
@@ -0,0 +1,18 @@
1
+ export type Cookie = {
2
+ name: string;
3
+ value: string;
4
+ path?: string;
5
+ expires?: string;
6
+ maxAge?: number;
7
+ domain?: string;
8
+ secure?: boolean;
9
+ httpOnly?: boolean;
10
+ sameSite?: "strict" | "lax" | "none";
11
+ };
12
+ export declare class CookieJar {
13
+ private cookies;
14
+ setCookies(cookies: string[], url: URL): void;
15
+ getCookies(url: URL, fromJs: boolean): string;
16
+ load(cookies: string): null;
17
+ dump(): string;
18
+ }
@@ -0,0 +1,13 @@
1
+ import { RawHeaders } from "@mercuryworkshop/proxy-transports";
2
+ export declare class ScramjetHeaders {
3
+ headers: {};
4
+ set(key: string, v: string): void;
5
+ get(key: string): string | null;
6
+ delete(key: string): void;
7
+ has(key: string): boolean;
8
+ toRawHeaders(): RawHeaders;
9
+ toNativeHeaders(): Headers;
10
+ static fromRawHeaders(raw: RawHeaders): ScramjetHeaders;
11
+ static fromNativeHeaders(native: Headers): ScramjetHeaders;
12
+ clone(): ScramjetHeaders;
13
+ }
@@ -0,0 +1,6 @@
1
+ import { URLMeta } from "./rewriters/url";
2
+ import { ScramjetContext } from "../shared";
3
+ export declare const htmlRules: {
4
+ [key: string]: "*" | string[] | ((...any: any[]) => string | null);
5
+ fn: (value: string, context: ScramjetContext, meta: URLMeta) => string | null;
6
+ }[];
@@ -0,0 +1,23 @@
1
+ import { ScramjetConfig, ScramjetFlags, ScramjetVersionInfo } from "../types";
2
+ import DomHandler, { Element } from "domhandler";
3
+ import { URLMeta } from "./rewriters/url";
4
+ import { CookieJar } from "./cookie";
5
+ export * from "./cookie";
6
+ export * from "./headers";
7
+ export * from "./htmlRules";
8
+ export * from "./rewriters";
9
+ export * from "./security";
10
+ export declare function flagEnabled(flag: keyof ScramjetFlags, context: ScramjetContext, url: URL): boolean;
11
+ export type ScramjetInterface = {
12
+ codecEncode: (input: string) => string;
13
+ codecDecode: (input: string) => string;
14
+ getInjectScripts(meta: URLMeta, handler: DomHandler, script: (src: string) => Element): Element[];
15
+ getWorkerInjectScripts?(meta: URLMeta, type: "module" | "regular", script: (src: string) => string): string;
16
+ };
17
+ export type ScramjetContext = {
18
+ config: ScramjetConfig;
19
+ prefix: URL;
20
+ interface: ScramjetInterface;
21
+ cookieJar: CookieJar;
22
+ };
23
+ export declare const versionInfo: ScramjetVersionInfo;
@@ -0,0 +1,4 @@
1
+ import { URLMeta } from "./url";
2
+ import { ScramjetContext } from "../../shared";
3
+ export declare function rewriteCss(css: string, context: ScramjetContext, meta: URLMeta): string;
4
+ export declare function unrewriteCss(css: string): string;
@@ -0,0 +1,6 @@
1
+ import { DomHandler } from "domhandler";
2
+ import { URLMeta } from "./url";
3
+ import { ScramjetContext } from "../../shared";
4
+ export declare function rewriteHtml(html: string, context: ScramjetContext, meta: URLMeta, fromTop?: boolean, preRewrite?: (handler: DomHandler) => void, postRewrite?: (handler: DomHandler) => void): string;
5
+ export declare function unrewriteHtml(html: string): string;
6
+ export declare function rewriteSrcset(srcset: string, context: ScramjetContext, meta: URLMeta): string;
@@ -0,0 +1,6 @@
1
+ export * from "./css";
2
+ export * from "./html";
3
+ export * from "./js";
4
+ export * from "./url";
5
+ export * from "./worker";
6
+ export * from "./wasm";
@@ -0,0 +1,11 @@
1
+ import { ScramjetContext } from "../../shared";
2
+ import { URLMeta } from "./url";
3
+ type RewriterResult = {
4
+ js: string | Uint8Array;
5
+ map: Uint8Array | null;
6
+ tag: string;
7
+ errors: string[];
8
+ };
9
+ export declare function rewriteJsInner(js: string | Uint8Array, url: string | null, context: ScramjetContext, meta: URLMeta, module?: boolean): RewriterResult;
10
+ export declare function rewriteJs(js: string | Uint8Array, url: string | null, context: ScramjetContext, meta: URLMeta, module?: boolean): string | Uint8Array;
11
+ export {};
@@ -0,0 +1,11 @@
1
+ import { ScramjetContext } from "../../shared";
2
+ export type URLMeta = {
3
+ origin: URL;
4
+ base: URL;
5
+ topFrameName?: string;
6
+ parentFrameName?: string;
7
+ };
8
+ export declare function rewriteBlob(url: string, context: ScramjetContext, meta: URLMeta): string;
9
+ export declare function unrewriteBlob(url: string, context: ScramjetContext, meta: URLMeta): string;
10
+ export declare function rewriteUrl(url: string | URL, context: ScramjetContext, meta: URLMeta): string;
11
+ export declare function unrewriteUrl(url: string | URL, context: ScramjetContext): string;
@@ -0,0 +1,8 @@
1
+ import { Rewriter } from "../../../rewriter/wasm/out/wasm.js";
2
+ import type { JsRewriterOutput } from "../../../rewriter/wasm/out/wasm.js";
3
+ import { ScramjetContext } from "../../shared";
4
+ export type { JsRewriterOutput, Rewriter };
5
+ import { URLMeta } from "./url";
6
+ export declare function setWasm(u8: Uint8Array | ArrayBuffer): void;
7
+ export declare const textDecoder: TextDecoder;
8
+ export declare function getRewriter(context: ScramjetContext, meta: URLMeta): [Rewriter, () => void];
@@ -0,0 +1,3 @@
1
+ import { ScramjetContext } from "../../shared";
2
+ import { URLMeta } from "./url";
3
+ export declare function rewriteWorkers(context: ScramjetContext, js: string | Uint8Array, type: "module" | "regular", url: string, meta: URLMeta): string;
@@ -0,0 +1 @@
1
+ export * from "./siteTests";
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,7 @@
1
+ /**
2
+ * @fileoverview
3
+ * See `types.ts` for context on these symbols.
4
+ */
5
+ export declare const SCRAMJETCLIENTNAME = "scramjet client global";
6
+ export declare const SCRAMJETCLIENT: unique symbol;
7
+ export declare const SCRAMJETFRAME: unique symbol;
@@ -0,0 +1,115 @@
1
+ import { ScramjetClient } from "./client/index";
2
+ import { SCRAMJETCLIENT } from "./symbols";
3
+ import { DBSchema } from "idb";
4
+ /**
5
+ * Version information for the current Scramjet build.
6
+ * Contains both the semantic version string and the git commit hash for build identification.
7
+ */
8
+ export interface ScramjetVersionInfo {
9
+ /** The semantic version */
10
+ version: string;
11
+ /** The git commit hash that this build was created from */
12
+ build: string;
13
+ /** The date of the build */
14
+ date: string;
15
+ }
16
+ /**
17
+ * Scramjet Feature Flags, configured at build time
18
+ */
19
+ export type ScramjetFlags = {
20
+ syncxhr: boolean;
21
+ strictRewrites: boolean;
22
+ rewriterLogs: boolean;
23
+ captureErrors: boolean;
24
+ cleanErrors: boolean;
25
+ scramitize: boolean;
26
+ sourcemaps: boolean;
27
+ destructureRewrites: boolean;
28
+ allowInvalidJs: boolean;
29
+ allowFailedIntercepts: boolean;
30
+ debugTrampolines: boolean;
31
+ encapsulateWorkers: boolean;
32
+ };
33
+ export interface ScramjetConfig {
34
+ globals: {
35
+ wrapfn: string;
36
+ wrappropertybase: string;
37
+ wrappropertyfn: string;
38
+ cleanrestfn: string;
39
+ importfn: string;
40
+ rewritefn: string;
41
+ metafn: string;
42
+ wrappostmessagefn: string;
43
+ pushsourcemapfn: string;
44
+ trysetfn: string;
45
+ templocid: string;
46
+ tempunusedid: string;
47
+ };
48
+ maskedfiles: string[];
49
+ flags: ScramjetFlags;
50
+ siteFlags: Record<string, Partial<ScramjetFlags>>;
51
+ }
52
+ /**
53
+ * The config for Scramjet initialization.
54
+ */
55
+ export interface ScramjetInitConfig extends Omit<ScramjetConfig, "codec" | "flags"> {
56
+ flags: Partial<ScramjetFlags>;
57
+ codec: {
58
+ encode: (url: string) => string;
59
+ decode: (url: string) => string;
60
+ };
61
+ }
62
+ declare global {
63
+ interface Window {
64
+ WASM: string;
65
+ REAL_WASM: Uint8Array;
66
+ /**
67
+ * The scramjet client belonging to a window.
68
+ */
69
+ [SCRAMJETCLIENT]: ScramjetClient;
70
+ }
71
+ interface HTMLDocument {
72
+ /**
73
+ * Should be the same as window.
74
+ */
75
+ [SCRAMJETCLIENT]: ScramjetClient;
76
+ }
77
+ interface HTMLIFrameElement {
78
+ }
79
+ }
80
+ export type SiteDirective = "same-origin" | "same-site" | "cross-site" | "none";
81
+ export interface RedirectTracker {
82
+ originalReferrer: string;
83
+ mostRestrictiveSite: SiteDirective;
84
+ referrerPolicy: string;
85
+ chainStarted: number;
86
+ }
87
+ export interface ReferrerPolicyData {
88
+ policy: string;
89
+ referrer: string;
90
+ }
91
+ export interface ScramjetDB extends DBSchema {
92
+ config: {
93
+ key: string;
94
+ value: ScramjetConfig;
95
+ };
96
+ cookies: {
97
+ key: string;
98
+ value: any;
99
+ };
100
+ redirectTrackers: {
101
+ key: string;
102
+ value: RedirectTracker;
103
+ };
104
+ referrerPolicies: {
105
+ key: string;
106
+ value: ReferrerPolicyData;
107
+ };
108
+ publicSuffixList: {
109
+ key: string;
110
+ value: {
111
+ data: string[];
112
+ expiry: number;
113
+ };
114
+ };
115
+ }
package/lib/index.d.ts CHANGED
@@ -1,3 +1,8 @@
1
+ /**
2
+ * @fileoverview
3
+ * Scramjet path export for routing functionality
4
+ */
5
+
1
6
  declare const scramjetPath: string;
2
7
 
3
8
  export { scramjetPath };
package/package.json CHANGED
@@ -1,85 +1,97 @@
1
1
  {
2
- "name": "@mercuryworkshop/scramjet",
3
- "version": "2.0.0-alpha",
4
- "description": "An experimental web proxy that aims to be the successor to Ultraviolet",
5
- "type": "module",
6
- "repository": {
7
- "type": "git",
8
- "url": "https://github.com/MercuryWorkshop/scramjet"
9
- },
10
- "scripts": {
11
- "build": "rspack build --mode production",
12
- "rewriter:build": "cd rewriter/wasm/ && bash build.sh && cd ../../",
13
- "dev": "node server.js",
14
- "dev:debug": "DEBUG=1 node server.js",
15
- "prepack": "RELEASE=1 npm run rewriter:build && tsc && tsc-alias && npm run build",
16
- "pub": "npm publish --no-git-checks --access public",
17
- "format": "prettier --write .",
18
- "lint": "eslint ./src/",
19
- "lint:fix": "eslint ./src/ --fix",
20
- "test": "npx playwright test",
21
- "preinstall": "npx only-allow pnpm"
22
- },
23
- "exports": {
24
- ".": {
25
- "types": "./lib/types.d.ts",
26
- "default": "./lib/noop.js"
27
- },
28
- "./path": {
29
- "types": "./lib/index.d.ts",
30
- "default": "./lib/index.cjs"
31
- },
32
- "./bundled": {
33
- "types": "./dist/types/index.d.ts",
34
- "default": "./dist/scramjet.bundle.js"
35
- }
36
- },
37
- "files": [
38
- "dist/*.js",
39
- "dist/*.js.map",
40
- "dist/*.wasm",
41
- "lib"
42
- ],
43
- "keywords": [],
44
- "author": "",
45
- "license": "MIT",
46
- "devDependencies": {
47
- "@eslint/eslintrc": "^3.3.1",
48
- "@eslint/js": "^9.32.0",
49
- "@estruyf/github-actions-reporter": "^1.10.0",
50
- "@fastify/static": "^8.2.0",
51
- "@mercuryworkshop/bare-as-module3": "^2.2.5",
52
- "@mercuryworkshop/epoxy-transport": "^2.1.28",
53
- "@mercuryworkshop/libcurl-transport": "^1.5.0",
54
- "@mercuryworkshop/wisp-js": "^0.3.3",
55
- "@nebula-services/bare-server-node": "^2.0.4",
56
- "@playwright/test": "^1.54.2",
57
- "@rsdoctor/rspack-plugin": "^1.1.5",
58
- "@rspack/cli": "^1.4.8",
59
- "@rspack/core": "^1.4.8",
60
- "@types/eslint": "^9.6.1",
61
- "@types/estree": "^1.0.8",
62
- "@types/node": "^24.1.0",
63
- "@types/serviceworker": "^0.0.148",
64
- "@typescript-eslint/eslint-plugin": "^8.38.0",
65
- "@typescript-eslint/parser": "^8.38.0",
66
- "dotenv": "^17.2.1",
67
- "eslint": "^9.32.0",
68
- "fastify": "^5.4.0",
69
- "playwright": "^1.54.2",
70
- "prettier": "^3.6.2",
71
- "ts-checker-rspack-plugin": "^1.1.4",
72
- "tsc-alias": "^1.8.16",
73
- "tslib": "^2.8.1",
74
- "typescript": "^5.9.2"
75
- },
76
- "dependencies": {
77
- "@mercuryworkshop/epoxy-tls": "2.1.18-1",
78
- "dom-serializer": "^2.0.0",
79
- "domhandler": "^5.0.3",
80
- "domutils": "^3.2.2",
81
- "htmlparser2": "10.0.0",
82
- "parse-domain": "^8.2.2",
83
- "set-cookie-parser": "^2.7.1"
84
- }
85
- }
2
+ "name": "@mercuryworkshop/scramjet",
3
+ "version": "2.0.2-alpha",
4
+ "description": "An experimental web proxy that aims to be the successor to Ultraviolet",
5
+ "type": "module",
6
+ "types": "./dist/types/index.d.ts",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "https://github.com/MercuryWorkshop/scramjet"
10
+ },
11
+ "exports": {
12
+ ".": {
13
+ "types": "./dist/types/index.d.ts",
14
+ "default": "./dist/scramjet.mjs"
15
+ },
16
+ "./path": {
17
+ "types": "./lib/index.d.ts",
18
+ "default": "./lib/index.cjs"
19
+ },
20
+ "./bundled": {
21
+ "types": "./dist/types/index.d.ts",
22
+ "default": "./dist/scramjet_bundled.mjs"
23
+ }
24
+ },
25
+ "files": [
26
+ "dist",
27
+ "lib"
28
+ ],
29
+ "keywords": [],
30
+ "author": "",
31
+ "license": "MIT",
32
+ "ava": {
33
+ "files": [
34
+ "tests/ci/**/*.js"
35
+ ],
36
+ "verbose": true
37
+ },
38
+ "devDependencies": {
39
+ "@eslint/eslintrc": "^3.3.1",
40
+ "@eslint/js": "^9.35.0",
41
+ "@estruyf/github-actions-reporter": "^1.10.0",
42
+ "@fastify/static": "^8.2.0",
43
+ "@mercuryworkshop/wisp-js": "^0.4.0",
44
+ "@nebula-services/bare-server-node": "^2.0.4",
45
+ "@playwright/test": "^1.55.0",
46
+ "@types/eslint": "^9.6.1",
47
+ "@types/estree": "^1.0.8",
48
+ "@types/node": "^24.3.1",
49
+ "@types/serviceworker": "^0.0.160",
50
+ "@typescript-eslint/eslint-plugin": "^8.43.0",
51
+ "@typescript-eslint/parser": "^8.43.0",
52
+ "actionlint": "^2.0.6",
53
+ "ava": "^6.4.1",
54
+ "dotenv": "^17.2.2",
55
+ "eslint": "^9.35.0",
56
+ "fastify": "^5.6.0",
57
+ "glob": "^11.0.3",
58
+ "playwright": "^1.55.0",
59
+ "prettier": "^3.6.2",
60
+ "remark": "^15.0.1",
61
+ "remark-cli": "^12.0.1",
62
+ "remark-frontmatter": "^5.0.0",
63
+ "remark-mdx": "^3.1.1",
64
+ "remark-stringify": "^11.0.0",
65
+ "ts-checker-rspack-plugin": "^1.1.5",
66
+ "tsc-alias": "^1.8.16",
67
+ "tslib": "^2.8.1",
68
+ "typescript": "^5.9.2"
69
+ },
70
+ "dependencies": {
71
+ "@mercuryworkshop/proxy-transports": "1.0.2",
72
+ "dom-serializer": "^2.0.0",
73
+ "domhandler": "^5.0.3",
74
+ "domutils": "^3.2.2",
75
+ "htmlparser2": "^10.0.0",
76
+ "idb": "^8.0.3",
77
+ "parse-domain": "^8.2.2",
78
+ "set-cookie-parser": "^2.7.1"
79
+ },
80
+ "scripts": {
81
+ "build": "cd ../.. && rspack build --mode production",
82
+ "rewriter:build": "cd rewriter/wasm/ && bash build.sh && cd ../../",
83
+ "dev": "node server.js",
84
+ "dev:debug": "DEBUG=1 node server.js",
85
+ "pub": "npm publish --no-git-checks --access public",
86
+ "format": "prettier --write .",
87
+ "format:docs": "remark \"docs/**/*.{md,mdx}\" --output",
88
+ "lint": "eslint ./src/",
89
+ "lint:fix": "eslint ./src/ --fix",
90
+ "lint:workflows": "actionlint .github/workflows/*.yml",
91
+ "lint:all": "npm run lint && npm run lint:workflows",
92
+ "test": "npm run test:package && npm run test:integration",
93
+ "test:package": "ava tests/ci/packageValidation.js",
94
+ "test:integration": "npx playwright test",
95
+ "preinstall": "npx only-allow pnpm"
96
+ }
97
+ }