@swf2es/desktop 0.0.0-stage → 0.1.15
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/LICENSE +202 -0
- package/README.md +135 -2
- package/dist/launch/electron.d.ts +14 -0
- package/dist/launch/electron.d.ts.map +1 -0
- package/dist/launch/electron.js +40 -0
- package/dist/launch/electron.js.map +1 -0
- package/dist/launch/launch.d.ts +3 -0
- package/dist/launch/launch.d.ts.map +1 -0
- package/dist/launch/launch.js +69 -0
- package/dist/launch/launch.js.map +1 -0
- package/dist/main/addresses.d.ts +7 -0
- package/dist/main/addresses.d.ts.map +1 -0
- package/dist/main/addresses.js +155 -0
- package/dist/main/addresses.js.map +1 -0
- package/dist/main/air.d.ts +71 -0
- package/dist/main/air.d.ts.map +1 -0
- package/dist/main/air.js +216 -0
- package/dist/main/air.js.map +1 -0
- package/dist/main/connections.d.ts +38 -0
- package/dist/main/connections.d.ts.map +1 -0
- package/dist/main/connections.js +103 -0
- package/dist/main/connections.js.map +1 -0
- package/dist/main/decompress.d.ts +51 -0
- package/dist/main/decompress.d.ts.map +1 -0
- package/dist/main/decompress.js +184 -0
- package/dist/main/decompress.js.map +1 -0
- package/dist/main/files.d.ts +9 -0
- package/dist/main/files.d.ts.map +1 -0
- package/dist/main/files.js +120 -0
- package/dist/main/files.js.map +1 -0
- package/dist/main/main.d.ts +2 -0
- package/dist/main/main.d.ts.map +1 -0
- package/dist/main/main.js +1009 -0
- package/dist/main/main.js.map +1 -0
- package/dist/main/network.d.ts +182 -0
- package/dist/main/network.d.ts.map +1 -0
- package/dist/main/network.js +909 -0
- package/dist/main/network.js.map +1 -0
- package/dist/main/policy.d.ts +103 -0
- package/dist/main/policy.d.ts.map +1 -0
- package/dist/main/policy.js +481 -0
- package/dist/main/policy.js.map +1 -0
- package/dist/main/protocol.d.ts +14 -0
- package/dist/main/protocol.d.ts.map +1 -0
- package/dist/main/protocol.js +216 -0
- package/dist/main/protocol.js.map +1 -0
- package/dist/main/sandbox.d.ts +67 -0
- package/dist/main/sandbox.d.ts.map +1 -0
- package/dist/main/sandbox.js +182 -0
- package/dist/main/sandbox.js.map +1 -0
- package/dist/main/settings.d.ts +37 -0
- package/dist/main/settings.d.ts.map +1 -0
- package/dist/main/settings.js +88 -0
- package/dist/main/settings.js.map +1 -0
- package/dist/main/sockets.d.ts +10 -0
- package/dist/main/sockets.d.ts.map +1 -0
- package/dist/main/sockets.js +71 -0
- package/dist/main/sockets.js.map +1 -0
- package/dist/preload/preload.cjs +91 -0
- package/dist/preload/preload.cjs.map +1 -0
- package/dist/preload/preload.d.cts +2 -0
- package/dist/preload/preload.d.cts.map +1 -0
- package/dist/preload/prompt.cjs +12 -0
- package/dist/preload/prompt.cjs.map +1 -0
- package/dist/preload/prompt.d.cts +2 -0
- package/dist/preload/prompt.d.cts.map +1 -0
- package/dist/renderer/air.d.ts +14 -0
- package/dist/renderer/air.d.ts.map +1 -0
- package/dist/renderer/air.js +83 -0
- package/dist/renderer/air.js.map +1 -0
- package/dist/renderer/files.d.ts +4 -0
- package/dist/renderer/files.d.ts.map +1 -0
- package/dist/renderer/files.js +58 -0
- package/dist/renderer/files.js.map +1 -0
- package/dist/renderer/index.d.ts +7 -0
- package/dist/renderer/index.d.ts.map +1 -0
- package/dist/renderer/index.js +126 -0
- package/dist/renderer/index.js.map +1 -0
- package/dist/renderer/network.d.ts +6 -0
- package/dist/renderer/network.d.ts.map +1 -0
- package/dist/renderer/network.js +39 -0
- package/dist/renderer/network.js.map +1 -0
- package/dist/renderer/open-url.d.ts +10 -0
- package/dist/renderer/open-url.d.ts.map +1 -0
- package/dist/renderer/open-url.js +38 -0
- package/dist/renderer/open-url.js.map +1 -0
- package/dist/renderer/sockets.d.ts +4 -0
- package/dist/renderer/sockets.d.ts.map +1 -0
- package/dist/renderer/sockets.js +36 -0
- package/dist/renderer/sockets.js.map +1 -0
- package/dist/renderer/stage3d.d.ts +3 -0
- package/dist/renderer/stage3d.d.ts.map +1 -0
- package/dist/renderer/stage3d.js +26 -0
- package/dist/renderer/stage3d.js.map +1 -0
- package/dist/shared/api.d.ts +205 -0
- package/dist/shared/api.d.ts.map +1 -0
- package/dist/shared/api.js +5 -0
- package/dist/shared/api.js.map +1 -0
- package/package.json +46 -3
- package/src/launch/electron.ts +44 -0
- package/src/launch/launch.ts +72 -0
- package/src/launch/tsconfig.json +14 -0
- package/src/main/addresses.ts +184 -0
- package/src/main/air.ts +275 -0
- package/src/main/connections.ts +125 -0
- package/src/main/decompress.ts +219 -0
- package/src/main/files.ts +147 -0
- package/src/main/main.ts +1180 -0
- package/src/main/network.ts +1205 -0
- package/src/main/policy.ts +630 -0
- package/src/main/protocol.ts +237 -0
- package/src/main/sandbox.ts +213 -0
- package/src/main/settings.ts +117 -0
- package/src/main/sockets.ts +81 -0
- package/src/main/tsconfig.json +15 -0
- package/src/preload/preload.cts +110 -0
- package/src/preload/prompt.cts +11 -0
- package/src/preload/tsconfig.json +12 -0
- package/src/renderer/air.ts +100 -0
- package/src/renderer/files.ts +65 -0
- package/src/renderer/index.ts +145 -0
- package/src/renderer/network.ts +56 -0
- package/src/renderer/open-url.ts +50 -0
- package/src/renderer/sockets.ts +42 -0
- package/src/renderer/stage3d.ts +27 -0
- package/src/renderer/tsconfig.json +17 -0
- package/src/shared/api.ts +204 -0
- package/src/shared/tsconfig.json +11 -0
- package/static/icon.png +0 -0
- package/static/index.html +22 -0
- package/static/open-url.html +21 -0
- package/static/style.css +96 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"addresses.js","sourceRoot":"","sources":["../../src/main/addresses.ts"],"names":[],"mappings":"AAAA,wEAAwE;AACxE,uEAAuE;AACvE,0EAA0E;AAC1E,0EAA0E;AAC1E,yEAAyE;AACzE,uEAAuE;AACvE,+DAA+D;AAC/D,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAI1C,iGAAiG;AACjG,MAAM,CAAC,MAAM,IAAI,GA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l's way: the descriptor, the application's directory, the arguments. */
|
|
3
|
+
export interface AirCommand {
|
|
4
|
+
descriptor: string;
|
|
5
|
+
root: string | null;
|
|
6
|
+
arguments: string[];
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* The AIR application `argv` names, from `cwd`: a descriptor (`.xml`), the
|
|
10
|
+
* directory its content is under if one follows, and what follows `--`.
|
|
11
|
+
*/
|
|
12
|
+
export declare function airCommand(argv: string[], cwd: string): AirCommand | null;
|
|
13
|
+
/** What opening `command` plays: the content SWF's path, its launch, and its window's title and size. */
|
|
14
|
+
export declare function airLaunch(command: AirCommand, currentDirectory: string, userData: string, directories: {
|
|
15
|
+
documents: string;
|
|
16
|
+
desktop: string;
|
|
17
|
+
cache: string;
|
|
18
|
+
}): {
|
|
19
|
+
content: string;
|
|
20
|
+
/** The content's path under the application's directory, "/"-separated, as its app:/ URL has it. */
|
|
21
|
+
relative: string;
|
|
22
|
+
launch: AirLaunch;
|
|
23
|
+
title: string;
|
|
24
|
+
width: number | null;
|
|
25
|
+
height: number | null;
|
|
26
|
+
};
|
|
27
|
+
/** What is at `path`, as File reads it; null where nothing is. */
|
|
28
|
+
export declare function statOf(path: string): AirFileStat | null;
|
|
29
|
+
/** The names in the directory at `path`; null where it is none. */
|
|
30
|
+
export declare function listOf(path: string): string[] | null;
|
|
31
|
+
/** The bytes of the file at `path`, as FileStream's open reads them at once; null where none can be read. */
|
|
32
|
+
export declare function readOf(path: string): Uint8Array | null;
|
|
33
|
+
/** How the main process encrypts what it keeps: Electron's safeStorage where the system offers it. */
|
|
34
|
+
export interface Cipher {
|
|
35
|
+
encrypt(text: string): Uint8Array;
|
|
36
|
+
decrypt(data: Uint8Array): string;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* An AIR application's EncryptedLocalStore items, as AIR keeps them for
|
|
40
|
+
* it apart from its files: in one file at `path`, beside its storage
|
|
41
|
+
* directory, of the items' bytes by name, encrypted whole by `cipher`
|
|
42
|
+
* where one is given, as Electron's safeStorage encrypts by the system's
|
|
43
|
+
* keychain. Its first byte says which: "E" encrypted, "P" plain. Written
|
|
44
|
+
* whole as each item changes, through a file beside it renamed over it.
|
|
45
|
+
*/
|
|
46
|
+
export declare class EncryptedItems {
|
|
47
|
+
private readonly path;
|
|
48
|
+
private readonly cipher;
|
|
49
|
+
private readonly items;
|
|
50
|
+
constructor(path: string, cipher: Cipher | null);
|
|
51
|
+
get(name: string): Uint8Array | null;
|
|
52
|
+
set(name: string, bytes: Uint8Array): void;
|
|
53
|
+
remove(name: string): void;
|
|
54
|
+
reset(): void;
|
|
55
|
+
/** What the file holds; nothing where there is none, or it cannot be read, as by another keychain. */
|
|
56
|
+
private load;
|
|
57
|
+
private save;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Writes `bytes` into the file at `path` from `offset`, which is then
|
|
61
|
+
* `length` long, made with its directories where it is not: FileStream's
|
|
62
|
+
* writes. False where it cannot be written.
|
|
63
|
+
*/
|
|
64
|
+
export declare function writeOf(path: string, bytes: Uint8Array, offset: number, length: number): boolean;
|
|
65
|
+
/** Makes the directory at `path` and those it is in; false where it cannot. */
|
|
66
|
+
export declare function createDirectoryOf(path: string): boolean;
|
|
67
|
+
/** Removes the file or directory at `path`, with all in it; false where it cannot. */
|
|
68
|
+
export declare function removeOf(path: string): boolean;
|
|
69
|
+
/** Moves what is at `from` to `to`, its directories made; false where it cannot. */
|
|
70
|
+
export declare function moveOf(from: string, to: string): boolean;
|
|
71
|
+
//# sourceMappingURL=air.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"air.d.ts","sourceRoot":"","sources":["../../src/main/air.ts"],"names":[],"mappings":"AAuBA,OAAO,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAE/D,wGAAwG;AACxG,MAAM,WAAW,UAAU;IACzB,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,MAAM,GAAG,IAAI,CA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,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI,EAI9C;IAED,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,GAAG,IAAI,CAEnC;IAED,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,GAAG,IAAI,CAGzC;IAED,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAIzB;IAED,KAAK,IAAI,IAAI,CAGZ;IAED,sGAAsG;IACtG,OAAO,CAAC,IAAI;IAwBZ,OAAO,CAAC,IAAI;CAcb;AAED;;;;GAIG;AACH,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAahG;AAED,+EAA+E;AAC/E,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAEvD;AAED,sFAAsF;AACtF,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAE9C;AAED,oFAAoF;AACpF,wBAAgB,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,OAAO,CAexD"}
|
package/dist/main/air.js
ADDED
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
// An AIR application opened by its descriptor, as adl runs one
|
|
2
|
+
// (`adl app.xml [root-dir] [-- arguments...]`): its launch, which the page
|
|
3
|
+
// plays it with, and the file system its File reads and writes, while it
|
|
4
|
+
// plays.
|
|
5
|
+
// Apart from Electron, so that node tests it (tests/desktop/air.test.ts).
|
|
6
|
+
import { closeSync, cpSync, ftruncateSync, lstatSync, mkdirSync, openSync, readdirSync, readFileSync, renameSync, rmSync, statSync, writeFileSync, writeSync, } from "node:fs";
|
|
7
|
+
import { homedir } from "node:os";
|
|
8
|
+
import { basename, dirname, join, resolve, sep } from "node:path";
|
|
9
|
+
import { readAirDescriptor } from "@swf2es/format";
|
|
10
|
+
/**
|
|
11
|
+
* The AIR application `argv` names, from `cwd`: a descriptor (`.xml`), the
|
|
12
|
+
* directory its content is under if one follows, and what follows `--`.
|
|
13
|
+
*/
|
|
14
|
+
export function airCommand(argv, cwd) {
|
|
15
|
+
const end = argv.indexOf("--");
|
|
16
|
+
const own = (end < 0 ? argv : argv.slice(0, end)).filter((a) => !a.startsWith("-"));
|
|
17
|
+
const at = own.findIndex((a) => /\.xml$/i.test(a));
|
|
18
|
+
if (at < 0) {
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
const next = own[at + 1];
|
|
22
|
+
const root = next && statSync(resolve(cwd, next), { throwIfNoEntry: false })?.isDirectory();
|
|
23
|
+
return {
|
|
24
|
+
descriptor: resolve(cwd, own[at]),
|
|
25
|
+
root: root ? resolve(cwd, next) : null,
|
|
26
|
+
arguments: end < 0 ? [] : argv.slice(end + 1),
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
/** What opening `command` plays: the content SWF's path, its launch, and its window's title and size. */
|
|
30
|
+
export function airLaunch(command, currentDirectory, userData, directories) {
|
|
31
|
+
const xml = readFileSync(command.descriptor, "utf8");
|
|
32
|
+
const descriptor = readAirDescriptor(xml);
|
|
33
|
+
const application = command.root ?? dirname(command.descriptor);
|
|
34
|
+
// Each application's own, as AIR keeps one under the user's data by its id.
|
|
35
|
+
const applicationStorage = join(userData, "air", descriptor.id.replace(/[^\w.-]/g, "_"), "Local Store");
|
|
36
|
+
mkdirSync(applicationStorage, { recursive: true });
|
|
37
|
+
return {
|
|
38
|
+
content: resolve(application, ...descriptor.content.split("/")),
|
|
39
|
+
relative: descriptor.content,
|
|
40
|
+
launch: {
|
|
41
|
+
descriptor: xml,
|
|
42
|
+
id: descriptor.id,
|
|
43
|
+
arguments: command.arguments,
|
|
44
|
+
currentDirectory,
|
|
45
|
+
separator: sep,
|
|
46
|
+
directories: { application, applicationStorage, user: homedir(), ...directories },
|
|
47
|
+
},
|
|
48
|
+
title: descriptor.title ?? basename(descriptor.content),
|
|
49
|
+
width: descriptor.width,
|
|
50
|
+
height: descriptor.height,
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
/** What is at `path`, as File reads it; null where nothing is. */
|
|
54
|
+
export function statOf(path) {
|
|
55
|
+
try {
|
|
56
|
+
const s = statSync(path);
|
|
57
|
+
const link = lstatSync(path).isSymbolicLink();
|
|
58
|
+
return {
|
|
59
|
+
directory: s.isDirectory(),
|
|
60
|
+
size: s.isDirectory() ? 0 : s.size,
|
|
61
|
+
modified: s.mtimeMs,
|
|
62
|
+
created: s.birthtimeMs || s.ctimeMs,
|
|
63
|
+
// A dot file is hidden where Windows' attribute is not at hand, as on macOS and Linux.
|
|
64
|
+
hidden: basename(path).startsWith("."),
|
|
65
|
+
symbolicLink: link,
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
catch {
|
|
69
|
+
return null;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
/** The names in the directory at `path`; null where it is none. */
|
|
73
|
+
export function listOf(path) {
|
|
74
|
+
try {
|
|
75
|
+
return readdirSync(path);
|
|
76
|
+
}
|
|
77
|
+
catch {
|
|
78
|
+
return null;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
/** The bytes of the file at `path`, as FileStream's open reads them at once; null where none can be read. */
|
|
82
|
+
export function readOf(path) {
|
|
83
|
+
try {
|
|
84
|
+
return new Uint8Array(readFileSync(path));
|
|
85
|
+
}
|
|
86
|
+
catch {
|
|
87
|
+
return null;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* An AIR application's EncryptedLocalStore items, as AIR keeps them for
|
|
92
|
+
* it apart from its files: in one file at `path`, beside its storage
|
|
93
|
+
* directory, of the items' bytes by name, encrypted whole by `cipher`
|
|
94
|
+
* where one is given, as Electron's safeStorage encrypts by the system's
|
|
95
|
+
* keychain. Its first byte says which: "E" encrypted, "P" plain. Written
|
|
96
|
+
* whole as each item changes, through a file beside it renamed over it.
|
|
97
|
+
*/
|
|
98
|
+
export class EncryptedItems {
|
|
99
|
+
path;
|
|
100
|
+
cipher;
|
|
101
|
+
items;
|
|
102
|
+
constructor(path, cipher) {
|
|
103
|
+
this.path = path;
|
|
104
|
+
this.cipher = cipher;
|
|
105
|
+
this.items = this.load();
|
|
106
|
+
}
|
|
107
|
+
get(name) {
|
|
108
|
+
return this.items.get(name) ?? null;
|
|
109
|
+
}
|
|
110
|
+
set(name, bytes) {
|
|
111
|
+
this.items.set(name, new Uint8Array(bytes));
|
|
112
|
+
this.save();
|
|
113
|
+
}
|
|
114
|
+
remove(name) {
|
|
115
|
+
if (this.items.delete(name)) {
|
|
116
|
+
this.save();
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
reset() {
|
|
120
|
+
this.items.clear();
|
|
121
|
+
this.save();
|
|
122
|
+
}
|
|
123
|
+
/** What the file holds; nothing where there is none, or it cannot be read, as by another keychain. */
|
|
124
|
+
load() {
|
|
125
|
+
const items = new Map();
|
|
126
|
+
let text;
|
|
127
|
+
try {
|
|
128
|
+
const data = readFileSync(this.path);
|
|
129
|
+
if (data[0] === 0x45 && this.cipher) {
|
|
130
|
+
text = this.cipher.decrypt(new Uint8Array(data.subarray(1)));
|
|
131
|
+
}
|
|
132
|
+
else if (data[0] === 0x50) {
|
|
133
|
+
text = data.subarray(1).toString("utf8");
|
|
134
|
+
}
|
|
135
|
+
else {
|
|
136
|
+
return items;
|
|
137
|
+
}
|
|
138
|
+
const saved = JSON.parse(text);
|
|
139
|
+
for (const [name, base64] of Object.entries(saved)) {
|
|
140
|
+
items.set(name, new Uint8Array(Buffer.from(base64, "base64")));
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
catch {
|
|
144
|
+
// None yet, or unreadable: an empty store, as AIR's after a reset.
|
|
145
|
+
}
|
|
146
|
+
return items;
|
|
147
|
+
}
|
|
148
|
+
save() {
|
|
149
|
+
const saved = {};
|
|
150
|
+
for (const [name, bytes] of this.items) {
|
|
151
|
+
saved[name] = Buffer.from(bytes).toString("base64");
|
|
152
|
+
}
|
|
153
|
+
const text = JSON.stringify(saved);
|
|
154
|
+
const data = this.cipher
|
|
155
|
+
? Buffer.concat([Buffer.from("E"), this.cipher.encrypt(text)])
|
|
156
|
+
: Buffer.concat([Buffer.from("P"), Buffer.from(text, "utf8")]);
|
|
157
|
+
mkdirSync(dirname(this.path), { recursive: true });
|
|
158
|
+
writeFileSync(`${this.path}.new`, data);
|
|
159
|
+
renameSync(`${this.path}.new`, this.path);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Writes `bytes` into the file at `path` from `offset`, which is then
|
|
164
|
+
* `length` long, made with its directories where it is not: FileStream's
|
|
165
|
+
* writes. False where it cannot be written.
|
|
166
|
+
*/
|
|
167
|
+
export function writeOf(path, bytes, offset, length) {
|
|
168
|
+
return attempt(() => {
|
|
169
|
+
mkdirSync(dirname(path), { recursive: true });
|
|
170
|
+
// "a+" would only append; "r+" needs the file there, which "a" makes without emptying it.
|
|
171
|
+
closeSync(openSync(path, "a"));
|
|
172
|
+
const fd = openSync(path, "r+");
|
|
173
|
+
try {
|
|
174
|
+
writeSync(fd, bytes, 0, bytes.length, offset);
|
|
175
|
+
ftruncateSync(fd, length);
|
|
176
|
+
}
|
|
177
|
+
finally {
|
|
178
|
+
closeSync(fd);
|
|
179
|
+
}
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
/** Makes the directory at `path` and those it is in; false where it cannot. */
|
|
183
|
+
export function createDirectoryOf(path) {
|
|
184
|
+
return attempt(() => mkdirSync(path, { recursive: true }));
|
|
185
|
+
}
|
|
186
|
+
/** Removes the file or directory at `path`, with all in it; false where it cannot. */
|
|
187
|
+
export function removeOf(path) {
|
|
188
|
+
return attempt(() => rmSync(path, { recursive: true }));
|
|
189
|
+
}
|
|
190
|
+
/** Moves what is at `from` to `to`, its directories made; false where it cannot. */
|
|
191
|
+
export function moveOf(from, to) {
|
|
192
|
+
return attempt(() => {
|
|
193
|
+
mkdirSync(dirname(to), { recursive: true });
|
|
194
|
+
try {
|
|
195
|
+
renameSync(from, to);
|
|
196
|
+
}
|
|
197
|
+
catch (e) {
|
|
198
|
+
// Onto another disk, which a rename cannot reach.
|
|
199
|
+
if (e.code !== "EXDEV") {
|
|
200
|
+
throw e;
|
|
201
|
+
}
|
|
202
|
+
cpSync(from, to, { recursive: true });
|
|
203
|
+
rmSync(from, { recursive: true });
|
|
204
|
+
}
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
function attempt(change) {
|
|
208
|
+
try {
|
|
209
|
+
change();
|
|
210
|
+
return true;
|
|
211
|
+
}
|
|
212
|
+
catch {
|
|
213
|
+
return false;
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
//# sourceMappingURL=air.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"air.js","sourceRoot":"","sources":["../../src/main/air.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,2EAA2E;AAC3E,yEAAyE;AACzE,SAAS;AACT,0EAA0E;AAC1E,OAAO,EACL,SAAS,EACT,MAAM,EACN,aAAa,EACb,SAAS,EACT,SAAS,EACT,QAAQ,EACR,WAAW,EACX,YAAY,EACZ,UAAU,EACV,MAAM,EACN,QAAQ,EACR,aAAa,EACb,SAAS,GACV,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAClE,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAUnD;;;GAGG;AACH,MAAM,UAAU,UAAU,CAAC,IAAc,EAAE,GAAW;IACpD,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IAC/B,MAAM,GAAG,GAAG,CAAC,GAAG,G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AAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;YACtC,MAAM,CAAC,IAAI,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QACpC,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC;AAED,SAAS,OAAO,CAAC,MAAkB;IACjC,IAAI,CAAC;QACH,MAAM,EAAE,CAAC;QACT,OAAO,IAAI,CAAC;IACd,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { SocketEvent } from "../shared/api.js";
|
|
2
|
+
/**
|
|
3
|
+
* The bytes a connection may hold unsent. A peer that stops reading would
|
|
4
|
+
* otherwise have the main process buffer all a SWF writes: 100 writes of
|
|
5
|
+
* 8 MB took it from 238 to 1038 MB. Past this the connection fails, as
|
|
6
|
+
* Flash's did when a write could not go.
|
|
7
|
+
*/
|
|
8
|
+
export declare const MAX_BUFFERED: number;
|
|
9
|
+
/** Whether the page asked for a host name of DNS's length and a TCP port. */
|
|
10
|
+
export declare function validEndpoint(host: unknown, port: unknown): host is string;
|
|
11
|
+
export declare class Connections {
|
|
12
|
+
private readonly sockets;
|
|
13
|
+
private readonly tell;
|
|
14
|
+
/** `tell` carries each connection's events to its page. */
|
|
15
|
+
constructor(tell: (id: number, event: SocketEvent) => void);
|
|
16
|
+
get size(): number;
|
|
17
|
+
/** Counts closeAll's: a connection decided on before one belongs to a page that is gone. */
|
|
18
|
+
generation: number;
|
|
19
|
+
/**
|
|
20
|
+
* Connect `id` to `host`:`port`, each checked, as the page asks, at `address` where the host's
|
|
21
|
+
* was pinned (a remote SWF's socket policy came from there); a refusal is an error, then a close.
|
|
22
|
+
*/
|
|
23
|
+
connect(id: number, host: unknown, port: unknown, address?: string): void;
|
|
24
|
+
/**
|
|
25
|
+
* Write `bytes`, unless the peer has left more than MAX_BUFFERED unread: then the connection
|
|
26
|
+
* fails.
|
|
27
|
+
*/
|
|
28
|
+
send(id: number, bytes: Uint8Array): void;
|
|
29
|
+
/** Refuse `id`, as a server that took no connection: an error, then a close. */
|
|
30
|
+
refuse(id: number): void;
|
|
31
|
+
close(id: number): void;
|
|
32
|
+
/**
|
|
33
|
+
* Close every connection without a word: the page that held them is gone, and the next numbers
|
|
34
|
+
* its own from 1.
|
|
35
|
+
*/
|
|
36
|
+
closeAll(): void;
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=connections.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"connections.d.ts","sourceRoot":"","sources":["../../src/main/connections.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAKpD;;;;;GAKG;AACH,eAAO,MAAM,YAAY,QAAkB,CAAC;AAI5C,6EAA6E;AAC7E,wBAAgB,aAAa,CAAC,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,GAAG,IAAI,IAAI,MAAM,CAU1E;AAED,qBAAa,WAAW;IACtB,OAAO,CAAC,QAAQ,CAAC,OAAO,CAA6B;IACrD,OAAO,CAAC,QAAQ,CAAC,IAAI,CAA2C;IAEhE,2DAA2D;IAC3D,YAAY,IAAI,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,WAAW,KAAK,IAAI,EAEzD;IAED,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED,4FAA4F;IAC5F,UAAU,SAAK;IAEf;;;OAGG;IACH,OAAO,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CA2BxE;IAED;;;OAGG;IACH,IAAI,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,GAAG,IAAI,CAaxC;IAED,gFAAgF;IAChF,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,CAGvB;IAED,KAAK,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,CAEtB;IAED;;;OAGG;IACH,QAAQ,IAAI,IAAI,CASf;CACF"}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
// One page's flash.net.Socket connections, made with node:net: what the
|
|
2
|
+
// socket bridge (sockets.ts) holds for each page, apart from Electron so
|
|
3
|
+
// that node runs it in the tests (tests/desktop/connections.test.ts).
|
|
4
|
+
import { connect } from "node:net";
|
|
5
|
+
/** As many as a page may hold open at once; past it a connection is refused. */
|
|
6
|
+
const MAX_OPEN = 64;
|
|
7
|
+
/**
|
|
8
|
+
* The bytes a connection may hold unsent. A peer that stops reading would
|
|
9
|
+
* otherwise have the main process buffer all a SWF writes: 100 writes of
|
|
10
|
+
* 8 MB took it from 238 to 1038 MB. Past this the connection fails, as
|
|
11
|
+
* Flash's did when a write could not go.
|
|
12
|
+
*/
|
|
13
|
+
export const MAX_BUFFERED = 4 * 1024 * 1024;
|
|
14
|
+
const SOCKET_ERROR = "Error #2031: Socket Error.";
|
|
15
|
+
/** Whether the page asked for a host name of DNS's length and a TCP port. */
|
|
16
|
+
export function validEndpoint(host, port) {
|
|
17
|
+
return (typeof host === "string" &&
|
|
18
|
+
host.length > 0 &&
|
|
19
|
+
host.length <= 255 &&
|
|
20
|
+
typeof port === "number" &&
|
|
21
|
+
Number.isInteger(port) &&
|
|
22
|
+
port > 0 &&
|
|
23
|
+
port < 65536);
|
|
24
|
+
}
|
|
25
|
+
export class Connections {
|
|
26
|
+
sockets = new Map();
|
|
27
|
+
tell;
|
|
28
|
+
/** `tell` carries each connection's events to its page. */
|
|
29
|
+
constructor(tell) {
|
|
30
|
+
this.tell = tell;
|
|
31
|
+
}
|
|
32
|
+
get size() {
|
|
33
|
+
return this.sockets.size;
|
|
34
|
+
}
|
|
35
|
+
/** Counts closeAll's: a connection decided on before one belongs to a page that is gone. */
|
|
36
|
+
generation = 0;
|
|
37
|
+
/**
|
|
38
|
+
* Connect `id` to `host`:`port`, each checked, as the page asks, at `address` where the host's
|
|
39
|
+
* was pinned (a remote SWF's socket policy came from there); a refusal is an error, then a close.
|
|
40
|
+
*/
|
|
41
|
+
connect(id, host, port, address) {
|
|
42
|
+
if (!validEndpoint(host, port) || this.sockets.has(id) || this.sockets.size >= MAX_OPEN) {
|
|
43
|
+
this.refuse(id);
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
const socket = connect({ host: address ?? host, port: port });
|
|
47
|
+
this.sockets.set(id, socket);
|
|
48
|
+
socket.on("connect", () => this.tell(id, {
|
|
49
|
+
type: "open",
|
|
50
|
+
localAddress: socket.localAddress ?? "",
|
|
51
|
+
localPort: socket.localPort ?? 0,
|
|
52
|
+
remoteAddress: socket.remoteAddress ?? "",
|
|
53
|
+
remotePort: socket.remotePort ?? 0,
|
|
54
|
+
}));
|
|
55
|
+
socket.on("data", (bytes) => this.tell(id, { type: "data", bytes: new Uint8Array(bytes) }));
|
|
56
|
+
socket.on("error", () => this.tell(id, { type: "error", message: SOCKET_ERROR }));
|
|
57
|
+
socket.on("close", () => {
|
|
58
|
+
// Only the socket under this id: a page that reused it has another by now.
|
|
59
|
+
if (this.sockets.get(id) === socket) {
|
|
60
|
+
this.sockets.delete(id);
|
|
61
|
+
}
|
|
62
|
+
this.tell(id, { type: "close" });
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Write `bytes`, unless the peer has left more than MAX_BUFFERED unread: then the connection
|
|
67
|
+
* fails.
|
|
68
|
+
*/
|
|
69
|
+
send(id, bytes) {
|
|
70
|
+
const socket = this.sockets.get(id);
|
|
71
|
+
if (!socket || socket.destroyed) {
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
if (socket.writableLength + bytes.length > MAX_BUFFERED) {
|
|
75
|
+
this.tell(id, { type: "error", message: SOCKET_ERROR });
|
|
76
|
+
socket.destroy();
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
socket.write(bytes);
|
|
80
|
+
}
|
|
81
|
+
/** Refuse `id`, as a server that took no connection: an error, then a close. */
|
|
82
|
+
refuse(id) {
|
|
83
|
+
this.tell(id, { type: "error", message: SOCKET_ERROR });
|
|
84
|
+
this.tell(id, { type: "close" });
|
|
85
|
+
}
|
|
86
|
+
close(id) {
|
|
87
|
+
this.sockets.get(id)?.destroy();
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Close every connection without a word: the page that held them is gone, and the next numbers
|
|
91
|
+
* its own from 1.
|
|
92
|
+
*/
|
|
93
|
+
closeAll() {
|
|
94
|
+
for (const socket of this.sockets.values()) {
|
|
95
|
+
socket.removeAllListeners();
|
|
96
|
+
socket.on("error", () => { });
|
|
97
|
+
socket.destroy();
|
|
98
|
+
}
|
|
99
|
+
this.sockets.clear();
|
|
100
|
+
this.generation++;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
//# sourceMappingURL=connections.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"connections.js","sourceRoot":"","sources":["../../src/main/connections.ts"],"names":[],"mappings":"AAAA,wEAAwE;AACxE,yEAAyE;AACzE,sEAAsE;AACtE,OAAO,EAAE,OAAO,EAAe,MAAM,UAAU,CAAC;AAGhD,gFAAgF;AAChF,MAAM,QAAQ,GAAG,EAAE,CAAC;AAEpB;;;;;GAKG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,GAAG,IAAI,GAAG,IAAI,CAAC;AAE5C,MAAM,YAAY,GAAG,4BAA4B,CAAC;AAElD,6EAA6E;AAC7E,MAAM,UAAU,aAAa,CAAC,IAAa,EAAE,IAAa;IACxD,OAAO,CACL,OAAO,IAAI,KAAK,QAAQ;QACxB,IAAI,CAAC,MAAM,GAAG,CAAC;QACf,IAAI,CAAC,MAAM,IAAI,GAAG;QAClB,OAAO,IAAI,KAAK,QAAQ;QACxB,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC;QACtB,IAAI,GAAG,CAAC;QACR,IAAI,GAAG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AAE,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,CAAC,CAAC;QACxD,IAAI,CAAC,IAAI,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC;IACnC,CAAC;IAED,KAAK,CAAC,EAAU;QACd,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC;IAClC,CAAC;IAED;;;OAGG;IACH,QAAQ;QACN,KAAK,MAAM,MAAM,IAAI,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC;YAC3C,MAAM,CAAC,kBAAkB,EAAE,CAAC;YAC5B,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;YAC7B,MAAM,CAAC,OAAO,EAAE,CAAC;QACnB,CAAC;QAED,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;QACrB,IAAI,CAAC,UAAU,EAAE,CAAC;IACpB,CAAC;CACF"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/** What a server may send compressed, unasked, that is decompressed; any other goes as it came. */
|
|
2
|
+
export declare const DECODED: Set<string>;
|
|
3
|
+
/** The longest gzip header read, its name and comment included. */
|
|
4
|
+
export declare const GZIP_HEADER_MAX: number;
|
|
5
|
+
/**
|
|
6
|
+
* A gzip header read as its bytes come: kept in an array that doubles as
|
|
7
|
+
* it fills, and parsed on from where the last chunk left off, so that a
|
|
8
|
+
* header sent a byte at a time costs no more than one sent whole. One
|
|
9
|
+
* whose end lies past GZIP_HEADER_MAX is refused, however it is chunked.
|
|
10
|
+
*/
|
|
11
|
+
export declare class GzipHeader {
|
|
12
|
+
private bytes;
|
|
13
|
+
private length;
|
|
14
|
+
/** Where parsing goes on from, and in which part: fixed bytes, extra, name, comment, CRC. */
|
|
15
|
+
private at;
|
|
16
|
+
private part;
|
|
17
|
+
/** What came so far. */
|
|
18
|
+
get buffered(): Uint8Array;
|
|
19
|
+
/** Add `chunk`: the header's length once whole, 0 while more is needed, -1 if it is none. */
|
|
20
|
+
add(chunk: Uint8Array): number;
|
|
21
|
+
private parse;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Decompresses one body of gzip, deflate or br, choosing its inflater
|
|
25
|
+
* once its first bytes are in: gzip's header is read here and its deflate
|
|
26
|
+
* stream inflated raw, so that what follows the stream (its footer, and
|
|
27
|
+
* whatever a server put after it) is ignored, as Chromium ignores it;
|
|
28
|
+
* deflate is zlib's stream or a raw one, as its first two bytes tell.
|
|
29
|
+
*/
|
|
30
|
+
export declare class Decompressor {
|
|
31
|
+
/** The first bytes, while they do not yet tell deflate's kind (no more than two). */
|
|
32
|
+
private head;
|
|
33
|
+
private gzip;
|
|
34
|
+
private inflater;
|
|
35
|
+
/** Called once the inflater wants more after a write said to wait. */
|
|
36
|
+
onDrain: () => void;
|
|
37
|
+
private readonly coding;
|
|
38
|
+
private readonly data;
|
|
39
|
+
private readonly done;
|
|
40
|
+
private readonly failed;
|
|
41
|
+
constructor(coding: string, data: (chunk: Buffer) => void, done: () => void, failed: () => void);
|
|
42
|
+
/** Whether more may be written now. */
|
|
43
|
+
write(chunk: Buffer): boolean;
|
|
44
|
+
end(): void;
|
|
45
|
+
destroy(): void;
|
|
46
|
+
/** Make the inflater once the bytes so far tell which (`last`: no more come); false: failed. */
|
|
47
|
+
private choose;
|
|
48
|
+
/** Inflate with `inflater` from `first` on. */
|
|
49
|
+
private start;
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=decompress.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"decompress.d.ts","sourceRoot":"","sources":["../../src/main/decompress.ts"],"names":[],"mappings":"AAMA,mGAAmG;AACnG,eAAO,MAAM,OAAO,aAA+C,CAAC;AAEpE,mEAAmE;AACnE,eAAO,MAAM,eAAe,QAAY,CAAC;AAEzC;;;;;GAKG;AACH,qBAAa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