@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.
- package/dist/a68dd7a5344f1722.wasm +0 -0
- package/dist/c34a4f083a11eae2.wasm +0 -0
- package/dist/scramjet.js +33 -0
- package/dist/scramjet.js.map +1 -0
- package/dist/scramjet.mjs +33 -0
- package/dist/scramjet.mjs.map +1 -0
- package/dist/scramjet.wasm +0 -0
- package/dist/scramjet_bundled.js +33 -0
- package/dist/scramjet_bundled.js.map +1 -0
- package/dist/scramjet_bundled.mjs +33 -0
- package/dist/scramjet_bundled.mjs.map +1 -0
- package/dist/types/client/client.d.ts +91 -0
- package/dist/types/client/entry.d.ts +5 -0
- package/dist/types/client/events.d.ts +38 -0
- package/dist/types/client/helpers.d.ts +1 -0
- package/dist/types/client/index.d.ts +7 -0
- package/dist/types/client/location.d.ts +2 -0
- package/dist/types/client/shared/eval.d.ts +3 -0
- package/dist/types/client/shared/sourcemaps.d.ts +19 -0
- package/dist/types/client/shared/wrap.d.ts +4 -0
- package/dist/types/client/singletonbox.d.ts +14 -0
- package/dist/types/fetch/index.d.ts +80 -0
- package/dist/types/index.d.ts +9 -0
- package/dist/types/index.js +26 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/shared/cookie.d.ts +18 -0
- package/dist/types/shared/headers.d.ts +13 -0
- package/dist/types/shared/htmlRules.d.ts +6 -0
- package/dist/types/shared/index.d.ts +23 -0
- package/dist/types/shared/rewriters/css.d.ts +4 -0
- package/dist/types/shared/rewriters/html.d.ts +6 -0
- package/dist/types/shared/rewriters/index.d.ts +6 -0
- package/dist/types/shared/rewriters/js.d.ts +11 -0
- package/dist/types/shared/rewriters/url.d.ts +11 -0
- package/dist/types/shared/rewriters/wasm.d.ts +8 -0
- package/dist/types/shared/rewriters/worker.d.ts +3 -0
- package/dist/types/shared/security/index.d.ts +1 -0
- package/dist/types/shared/security/siteTests.d.ts +1 -0
- package/dist/types/symbols.d.ts +7 -0
- package/dist/types/types.d.ts +115 -0
- package/lib/index.d.ts +5 -0
- package/package.json +96 -84
- package/LICENSE +0 -661
- package/README.md +0 -65
- package/dist/06813b79f94926ac.wasm +0 -0
- package/dist/09d5a95846afcaf1.wasm +0 -0
- package/dist/507621c43f70fc86.wasm +0 -0
- package/dist/63d477311eb50f38.wasm +0 -0
- package/dist/70102b41994b76de.wasm +0 -0
- package/dist/a31cde01c0b49ef3.wasm +0 -0
- package/dist/b4f3c1c0e4a92823.wasm +0 -0
- package/dist/d864ec42994880cb.wasm +0 -0
- package/dist/dbbe994629c3010c.wasm +0 -0
- package/dist/scramjet.all.js +0 -194
- package/dist/scramjet.all.js.map +0 -1
- package/dist/scramjet.bundle.js +0 -194
- package/dist/scramjet.bundle.js.map +0 -1
- package/dist/scramjet.sync.js +0 -2
- package/dist/scramjet.sync.js.map +0 -1
- package/dist/scramjet.wasm.wasm +0 -0
- 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,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,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 @@
|
|
|
1
|
+
export * from "./siteTests";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -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
package/package.json
CHANGED
|
@@ -1,85 +1,97 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
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
|
+
}
|