@swf2es/desktop 0.1.19 → 0.1.21
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/README.md +13 -8
- package/dist/main/air-bridge.d.ts +7 -0
- package/dist/main/air-bridge.d.ts.map +1 -0
- package/dist/main/air-bridge.js +166 -0
- package/dist/main/air-bridge.js.map +1 -0
- package/dist/main/dialogs.d.ts +18 -0
- package/dist/main/dialogs.d.ts.map +1 -0
- package/dist/main/dialogs.js +128 -0
- package/dist/main/dialogs.js.map +1 -0
- package/dist/main/main.js +24 -789
- package/dist/main/main.js.map +1 -1
- package/dist/main/menu.d.ts +2 -0
- package/dist/main/menu.d.ts.map +1 -0
- package/dist/main/menu.js +80 -0
- package/dist/main/menu.js.map +1 -0
- package/dist/main/network-rules.d.ts +35 -0
- package/dist/main/network-rules.d.ts.map +1 -0
- package/dist/main/network-rules.js +167 -0
- package/dist/main/network-rules.js.map +1 -0
- package/dist/main/network-types.d.ts +131 -0
- package/dist/main/network-types.d.ts.map +1 -0
- package/dist/main/network-types.js +21 -0
- package/dist/main/network-types.js.map +1 -0
- package/dist/main/network.d.ts +1 -113
- package/dist/main/network.d.ts.map +1 -1
- package/dist/main/network.js +8 -181
- package/dist/main/network.js.map +1 -1
- package/dist/main/open.d.ts +55 -0
- package/dist/main/open.d.ts.map +1 -0
- package/dist/main/open.js +256 -0
- package/dist/main/open.js.map +1 -0
- package/dist/main/permissions.d.ts +17 -0
- package/dist/main/permissions.d.ts.map +1 -0
- package/dist/main/permissions.js +113 -0
- package/dist/main/permissions.js.map +1 -0
- package/dist/main/settings.d.ts +8 -1
- package/dist/main/settings.d.ts.map +1 -1
- package/dist/main/settings.js +9 -4
- package/dist/main/settings.js.map +1 -1
- package/dist/main/state.d.ts +17 -0
- package/dist/main/state.d.ts.map +1 -0
- package/dist/main/state.js +30 -0
- package/dist/main/state.js.map +1 -0
- package/dist/main/switches.d.ts +25 -0
- package/dist/main/switches.d.ts.map +1 -0
- package/dist/main/switches.js +69 -0
- package/dist/main/switches.js.map +1 -0
- package/dist/renderer/index.js +11 -8
- package/dist/renderer/index.js.map +1 -1
- package/package.json +7 -7
- package/src/main/air-bridge.ts +185 -0
- package/src/main/dialogs.ts +147 -0
- package/src/main/main.ts +52 -938
- package/src/main/menu.ts +84 -0
- package/src/main/network-rules.ts +199 -0
- package/src/main/network-types.ts +150 -0
- package/src/main/network.ts +30 -337
- package/src/main/open.ts +302 -0
- package/src/main/permissions.ts +135 -0
- package/src/main/settings.ts +16 -5
- package/src/main/state.ts +44 -0
- package/src/main/switches.ts +87 -0
- package/src/renderer/index.ts +18 -7
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
// What plays, and opening it: a SWF by its path or its URL, or an AIR
|
|
2
|
+
// application by its descriptor, from the command line, the menu, a
|
|
3
|
+
// dialog or a drop; and closing it. Only this module changes what plays;
|
|
4
|
+
// the others read it.
|
|
5
|
+
import { statSync } from "node:fs";
|
|
6
|
+
import { open as openFile, realpath } from "node:fs/promises";
|
|
7
|
+
import { basename, dirname, join, resolve } from "node:path";
|
|
8
|
+
import { fileAttributes } from "@swf2es/format";
|
|
9
|
+
import { app, dialog, safeStorage } from "electron";
|
|
10
|
+
import { airLaunch, EncryptedItems } from "./air.js";
|
|
11
|
+
import { refuse } from "./dialogs.js";
|
|
12
|
+
import { buildMenu } from "./menu.js";
|
|
13
|
+
import { listening, sandbox, settings, TITLE, window } from "./state.js";
|
|
14
|
+
import { network } from "./switches.js";
|
|
15
|
+
/** What the network judges the movie playing as; null for none, or one without networking. */
|
|
16
|
+
export let networkMovie = null;
|
|
17
|
+
export let current = null;
|
|
18
|
+
/** The servers the SWF playing was allowed, or denied, a socket to until it closes: "host:port". */
|
|
19
|
+
export let allowedOnce = new Set();
|
|
20
|
+
export let deniedOnce = new Set();
|
|
21
|
+
/** The longest URL a SWF is opened by. */
|
|
22
|
+
const MAX_URL = 8192;
|
|
23
|
+
/** The AIR application playing, as its command line asked for it; null for none. */
|
|
24
|
+
export let air = null;
|
|
25
|
+
/** The EncryptedLocalStore of the AIR application playing, if one is. */
|
|
26
|
+
export let encryptedItems = null;
|
|
27
|
+
/**
|
|
28
|
+
* `text` as the URL of a remote SWF: http or https, with a host and no
|
|
29
|
+
* credentials, its fragment dropped; null if it is not one.
|
|
30
|
+
*/
|
|
31
|
+
export function remoteUrl(text) {
|
|
32
|
+
if (text.length > MAX_URL) {
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
let url;
|
|
36
|
+
try {
|
|
37
|
+
url = new URL(text.trim());
|
|
38
|
+
}
|
|
39
|
+
catch {
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
if ((url.protocol !== "http:" && url.protocol !== "https:") || !url.hostname) {
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
if (url.username || url.password) {
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
48
|
+
url.hash = "";
|
|
49
|
+
return url;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* The SWF named on a command line, from `cwd`: the last argument after the
|
|
53
|
+
* app's own that is an http or https URL or names a .swf file there is.
|
|
54
|
+
* Chromium's and Electron's switches may take values of their own
|
|
55
|
+
* (`--switch value`), so the first argument that is not a switch could be one.
|
|
56
|
+
*/
|
|
57
|
+
export function movieFromArguments(argv, cwd = process.cwd()) {
|
|
58
|
+
const named = argv
|
|
59
|
+
.slice(process.defaultApp ? 2 : 1)
|
|
60
|
+
.filter((a) => !a.startsWith("-"))
|
|
61
|
+
.map((a) => remoteUrl(a)?.href ?? (/\.swf$/i.test(a) ? resolve(cwd, a) : null))
|
|
62
|
+
.filter((a) => a !== null);
|
|
63
|
+
return (named.reverse().find((a) => remoteUrl(a) || statSync(a, { throwIfNoEntry: false })?.isFile()) ??
|
|
64
|
+
null);
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* How much of a SWF the main process reads to choose its sandbox: far more than FileAttributes
|
|
68
|
+
* takes compressed.
|
|
69
|
+
*/
|
|
70
|
+
const START = 64 * 1024;
|
|
71
|
+
const USE_NETWORK = 0x01;
|
|
72
|
+
/**
|
|
73
|
+
* The first `length` bytes of the file at `path`, or as many as it has, at least `least`; null
|
|
74
|
+
* otherwise.
|
|
75
|
+
*/
|
|
76
|
+
export async function readStart(path, length, least = 8) {
|
|
77
|
+
try {
|
|
78
|
+
const file = await openFile(path);
|
|
79
|
+
try {
|
|
80
|
+
const bytes = new Uint8Array(length);
|
|
81
|
+
const { bytesRead } = await file.read(bytes, 0, length, 0);
|
|
82
|
+
return bytesRead >= Math.min(least, length) ? bytes.subarray(0, bytesRead) : null;
|
|
83
|
+
}
|
|
84
|
+
finally {
|
|
85
|
+
await file.close();
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
catch {
|
|
89
|
+
return null;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
/** Open what the recent list, the command line or a reload names: a URL, a SWF's path or a descriptor's. */
|
|
93
|
+
export function openEntry(entry) {
|
|
94
|
+
if (remoteUrl(entry)) {
|
|
95
|
+
return openUrl(entry);
|
|
96
|
+
}
|
|
97
|
+
// A descriptor reopened from the recent list or a reload, with the arguments it was run with.
|
|
98
|
+
if (/\.xml$/i.test(entry)) {
|
|
99
|
+
return openAir(air?.descriptor === entry ? air : { descriptor: entry, root: null, arguments: [] }, process.cwd());
|
|
100
|
+
}
|
|
101
|
+
return open(entry);
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Run the AIR application `command` names, as adl does: its content SWF in
|
|
105
|
+
* the window, at the descriptor's size, in AIR's application sandbox, with
|
|
106
|
+
* its launch (shared/api.ts AirLaunch), from `cwd`.
|
|
107
|
+
*/
|
|
108
|
+
export async function openAir(command, cwd) {
|
|
109
|
+
const name = basename(command.descriptor);
|
|
110
|
+
let opened;
|
|
111
|
+
try {
|
|
112
|
+
opened = airLaunch(command, cwd, app.getPath("userData"), {
|
|
113
|
+
documents: app.getPath("documents"),
|
|
114
|
+
desktop: app.getPath("desktop"),
|
|
115
|
+
cache: app.getPath("temp"),
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
catch (error) {
|
|
119
|
+
refuse(`${name} could not be opened.`, String(error));
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
const head = await readStart(opened.content, START);
|
|
123
|
+
const signature = head ? String.fromCharCode(...head.subarray(0, 3)) : "";
|
|
124
|
+
if (!head || (signature !== "FWS" && signature !== "CWS" && signature !== "ZWS")) {
|
|
125
|
+
refuse(`${name}'s content is not a SWF.`, opened.content);
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
const content = await realpath(opened.content);
|
|
129
|
+
sandbox.playApplication(content);
|
|
130
|
+
air = command;
|
|
131
|
+
// Beside its storage directory, by its id, as AIR keeps it; encrypted by the system's keychain where it has one.
|
|
132
|
+
encryptedItems = new EncryptedItems(join(dirname(opened.launch.directories.applicationStorage), "EncryptedLocalStore"), safeStorage.isEncryptionAvailable()
|
|
133
|
+
? {
|
|
134
|
+
encrypt: (text) => new Uint8Array(safeStorage.encryptString(text)),
|
|
135
|
+
decrypt: (data) => safeStorage.decryptString(Buffer.from(data)),
|
|
136
|
+
}
|
|
137
|
+
: null);
|
|
138
|
+
if (window && opened.width && opened.height) {
|
|
139
|
+
window.setSize(opened.width, opened.height);
|
|
140
|
+
}
|
|
141
|
+
// Played from app:/, as AIR plays it: its relative URLs, and loaderInfo.url, are the application's.
|
|
142
|
+
const url = `app:/${opened.relative
|
|
143
|
+
.split("/")
|
|
144
|
+
.filter((s) => s !== "")
|
|
145
|
+
.map(encodeURIComponent)
|
|
146
|
+
.join("/")}`;
|
|
147
|
+
show(command.descriptor, { url, name: opened.title, sandbox: "application", air: opened.launch }, { kind: "application" });
|
|
148
|
+
}
|
|
149
|
+
/** Play `movie` in the window, in place of what plays: what the user opened, as `entry`. */
|
|
150
|
+
function show(entry, movie, onNetwork) {
|
|
151
|
+
current = { path: entry, movie };
|
|
152
|
+
playOnNetwork(onNetwork);
|
|
153
|
+
allowedOnce = new Set();
|
|
154
|
+
deniedOnce = new Set();
|
|
155
|
+
settings.opened(entry);
|
|
156
|
+
buildMenu();
|
|
157
|
+
if (window) {
|
|
158
|
+
// An AIR application's window is its own: its title alone, as adl shows it.
|
|
159
|
+
window.setTitle(movie.air ? movie.name : `${movie.name} — ${TITLE}`);
|
|
160
|
+
if (listening) {
|
|
161
|
+
window.webContents.send("desktop:open", movie);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Play the SWF at `text`, an http or https URL, in Flash's remote sandbox:
|
|
167
|
+
* no local file, and the network as its origin's (network.ts). The page
|
|
168
|
+
* fetches it through the main process like anything it loads.
|
|
169
|
+
*/
|
|
170
|
+
export async function openUrl(text) {
|
|
171
|
+
const url = remoteUrl(text);
|
|
172
|
+
if (!url) {
|
|
173
|
+
refuse("Only an http or https URL opens.", text.slice(0, 200));
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
176
|
+
const last = url.pathname.split("/").pop() ?? "";
|
|
177
|
+
let name;
|
|
178
|
+
try {
|
|
179
|
+
name = decodeURIComponent(last) || url.host;
|
|
180
|
+
}
|
|
181
|
+
catch {
|
|
182
|
+
name = last;
|
|
183
|
+
}
|
|
184
|
+
air = null;
|
|
185
|
+
sandbox.playRemote(url.href);
|
|
186
|
+
show(url.href, { url: url.href, name, sandbox: "remote" }, { kind: "remote", url: url.href });
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Open the file the user chose in the dialog, dropped on the window or
|
|
190
|
+
* opened with the app: an AIR application's descriptor (`.xml`) runs the
|
|
191
|
+
* application, anything else is played as a SWF.
|
|
192
|
+
*/
|
|
193
|
+
export async function openChosen(path) {
|
|
194
|
+
if (!/\.xml$/i.test(path)) {
|
|
195
|
+
return open(path);
|
|
196
|
+
}
|
|
197
|
+
// An application has an installed program's reach, which a file chosen in
|
|
198
|
+
// passing should not get unasked: asked once, until it leaves the recent list.
|
|
199
|
+
if (window && !settings.settings.recent.includes(path)) {
|
|
200
|
+
const { response } = await dialog.showMessageBox(window, {
|
|
201
|
+
type: "question",
|
|
202
|
+
message: `Run ${basename(path)} as an AIR application?`,
|
|
203
|
+
detail: "An AIR application reads and writes your files and reaches the network unasked, as an installed program does. Run only one you trust.",
|
|
204
|
+
buttons: ["Run", "Cancel"],
|
|
205
|
+
defaultId: 1,
|
|
206
|
+
cancelId: 1,
|
|
207
|
+
});
|
|
208
|
+
if (response !== 0) {
|
|
209
|
+
return;
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
// Run from its own directory, with no arguments, as one started by its icon is.
|
|
213
|
+
return openAir({ descriptor: path, root: null, arguments: [] }, dirname(path));
|
|
214
|
+
}
|
|
215
|
+
/** Play the SWF at `path` in the window, in place of what plays, in its sandbox. */
|
|
216
|
+
async function open(path) {
|
|
217
|
+
const name = basename(path);
|
|
218
|
+
// Its start alone: the main process never decompresses a SWF whole, whose
|
|
219
|
+
// header may name 4 GB. FileAttributes, the first tag, lies in it.
|
|
220
|
+
const head = await readStart(path, START);
|
|
221
|
+
const signature = head ? String.fromCharCode(...head.subarray(0, 3)) : "";
|
|
222
|
+
if (!head || (signature !== "FWS" && signature !== "CWS" && signature !== "ZWS")) {
|
|
223
|
+
refuse(`${name} is not a SWF.`, path);
|
|
224
|
+
return;
|
|
225
|
+
}
|
|
226
|
+
const useNetwork = (fileAttributes(head) & USE_NETWORK) !== 0;
|
|
227
|
+
let url;
|
|
228
|
+
try {
|
|
229
|
+
air = null;
|
|
230
|
+
url = sandbox.play(path, useNetwork);
|
|
231
|
+
}
|
|
232
|
+
catch (error) {
|
|
233
|
+
// Gone, or unreadable, since it was read.
|
|
234
|
+
refuse(`${name} could not be opened.`, String(error));
|
|
235
|
+
return;
|
|
236
|
+
}
|
|
237
|
+
app.addRecentDocument(path);
|
|
238
|
+
show(path, { url, name, sandbox: useNetwork ? "localWithNetwork" : "localWithFile" }, useNetwork ? { kind: "local" } : null);
|
|
239
|
+
}
|
|
240
|
+
/** Judge requests for `movie` from now on: the last one's are aborted. */
|
|
241
|
+
function playOnNetwork(movie) {
|
|
242
|
+
networkMovie = movie;
|
|
243
|
+
network.play(movie);
|
|
244
|
+
}
|
|
245
|
+
export function closeMovie() {
|
|
246
|
+
current = null;
|
|
247
|
+
air = null;
|
|
248
|
+
sandbox.stop();
|
|
249
|
+
playOnNetwork(null);
|
|
250
|
+
buildMenu();
|
|
251
|
+
window?.setTitle(TITLE);
|
|
252
|
+
if (listening) {
|
|
253
|
+
window?.webContents.send("desktop:close");
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
//# sourceMappingURL=open.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"open.js","sourceRoot":"","sources":["../../src/main/open.ts"],"names":[],"mappings":"AAAA,sEAAsE;AACtE,oEAAoE;AACpE,yEAAyE;AACzE,sBAAsB;AACtB,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACnC,OAAO,EAAE,IAAI,IAAI,QAAQ,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC9D,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC7D,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAEpD,OAAO,EAAmB,SAAS,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AACtE,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAEtC,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AACzE,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;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C,KAAK,CAAC,CAAC;IAE9D,IAAI,GAAW,CAAC;IAChB,IAAI,CAAC;QACH,GAAG,GAAG,IAAI,CAAC;QACX,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;IACvC,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,0CAA0C;QAC1C,MAAM,CAAC,GAAG,IAAI,uBAAuB,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;QACtD,OAAO;IACT,CAAC;IAED,GAAG,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC;IAC5B,IAAI,CACF,IAAI,EACJ,EAAE,GAAG,EAAE,IAAI,EAAE,OAAO,EAAE,UAAU,CAAC,CAAC,CAAC,kBAAkB,CAAC,CAAC,CAAC,eAAe,EAAE,EACzE,UAAU,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,IAAI,CACtC,CAAC;AACJ,CAAC;AAED,0EAA0E;AAC1E,SAAS,aAAa,CAAC,KAAmB;IACxC,YAAY,GAAG,KAAK,CAAC;IACrB,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AACtB,CAAC;AAED,MAAM,UAAU,UAAU;IACxB,OAAO,GAAG,IAAI,CAAC;IACf,GAAG,GAAG,IAAI,CAAC;IACX,OAAO,CAAC,IAAI,EAAE,CAAC;IACf,aAAa,CAAC,IAAI,CAAC,CAAC;IACpB,SAAS,EAAE,CAAC;IACZ,MAAM,EAAE,QAAQ,CAAC,KAAK,CAAC,CAAC;IACxB,IAAI,SAAS,EAAE,CAAC;QACd,MAAM,EAAE,WAAW,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;IAC5C,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Whether the SWF playing may connect a socket to `host`:`port`, and where
|
|
3
|
+
* to: only with the network, and only as the user allows, once or always
|
|
4
|
+
* for that SWF, when it first asks for that server; and for a remote SWF,
|
|
5
|
+
* as that server's socket policy allows, at the address it came from.
|
|
6
|
+
* Denied where no one can be asked.
|
|
7
|
+
*/
|
|
8
|
+
export declare function permitSocket(host: string, port: number): Promise<{
|
|
9
|
+
address?: string;
|
|
10
|
+
} | null>;
|
|
11
|
+
/**
|
|
12
|
+
* Whether what plays may open a WebSocket to `url`: an AIR application,
|
|
13
|
+
* unasked and anywhere, as AIR's application sandbox connects and as its
|
|
14
|
+
* sockets do here. air.net.WebSocket is AIR's alone, so nothing else has one.
|
|
15
|
+
*/
|
|
16
|
+
export declare function permitWebSocket(url: string): boolean;
|
|
17
|
+
//# sourceMappingURL=permissions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"permissions.d.ts","sourceRoot":"","sources":["../../src/main/permissions.ts"],"names":[],"mappings":"AAWA;;;;;;GAMG;AACH,wBAAsB,YAAY,CAChC,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,GACX,OAAO,CAAC;IAAE,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAAC,CA4BtC;AAoED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAYpD"}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
// Whether the SWF playing may open a socket or a WebSocket, and where to:
|
|
2
|
+
// the user asked once a server, and a remote SWF's socket policy.
|
|
3
|
+
import { dialog } from "electron";
|
|
4
|
+
import { allowedOnce, current, deniedOnce, networkMovie } from "./open.js";
|
|
5
|
+
import { sandbox, settings, window } from "./state.js";
|
|
6
|
+
import { network, proxiedWebSockets, proxy } from "./switches.js";
|
|
7
|
+
import { hasWebSocket } from "./websocket-connections.js";
|
|
8
|
+
/** The prompts on screen, by "host:port": a second connection there waits on the first's answer. */
|
|
9
|
+
const asking = new Map();
|
|
10
|
+
/**
|
|
11
|
+
* Whether the SWF playing may connect a socket to `host`:`port`, and where
|
|
12
|
+
* to: only with the network, and only as the user allows, once or always
|
|
13
|
+
* for that SWF, when it first asks for that server; and for a remote SWF,
|
|
14
|
+
* as that server's socket policy allows, at the address it came from.
|
|
15
|
+
* Denied where no one can be asked.
|
|
16
|
+
*/
|
|
17
|
+
export async function permitSocket(host, port) {
|
|
18
|
+
// AIR's application sandbox connects where it likes, unasked, with no socket policy.
|
|
19
|
+
if (sandbox.application) {
|
|
20
|
+
return {};
|
|
21
|
+
}
|
|
22
|
+
const playing = current;
|
|
23
|
+
const swf = sandbox.swf;
|
|
24
|
+
const endpoint = `${host}:${port}`;
|
|
25
|
+
if (!playing || !swf || !sandbox.networkAllowed()) {
|
|
26
|
+
process.stderr.write(`swf2es: no socket to ${endpoint}: the SWF has no network\n`);
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
if (!(await allowedByUser(playing, swf, endpoint))) {
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
if (networkMovie?.kind !== "remote") {
|
|
33
|
+
return {};
|
|
34
|
+
}
|
|
35
|
+
try {
|
|
36
|
+
return { address: await network.socketAddress(host, port) };
|
|
37
|
+
}
|
|
38
|
+
catch (error) {
|
|
39
|
+
process.stderr.write(`swf2es: no socket to ${endpoint}: ${error.message}\n`);
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
/** Whether the user allows the SWF playing a socket to `endpoint`, asked once a server. */
|
|
44
|
+
async function allowedByUser(playing, swf, endpoint) {
|
|
45
|
+
if (settings.socketAllowed(swf, endpoint) || allowedOnce.has(endpoint)) {
|
|
46
|
+
return true;
|
|
47
|
+
}
|
|
48
|
+
if (deniedOnce.has(endpoint)) {
|
|
49
|
+
return false;
|
|
50
|
+
}
|
|
51
|
+
let answer = asking.get(endpoint);
|
|
52
|
+
if (!answer) {
|
|
53
|
+
answer = askForSocket(playing.movie.name, swf, endpoint).finally(() => asking.delete(endpoint));
|
|
54
|
+
asking.set(endpoint, answer);
|
|
55
|
+
}
|
|
56
|
+
return (await answer) && current === playing;
|
|
57
|
+
}
|
|
58
|
+
async function askForSocket(name, swf, endpoint) {
|
|
59
|
+
if (!window) {
|
|
60
|
+
return false;
|
|
61
|
+
}
|
|
62
|
+
const playing = current;
|
|
63
|
+
let response;
|
|
64
|
+
try {
|
|
65
|
+
({ response } = await dialog.showMessageBox(window, {
|
|
66
|
+
type: "question",
|
|
67
|
+
message: `${name} asks to connect to ${endpoint}.`,
|
|
68
|
+
detail: "A socket lets the SWF send that server whatever it has. " +
|
|
69
|
+
"Allow it only for a server you trust.",
|
|
70
|
+
buttons: ["Allow Once", "Always Allow for This SWF", "Deny"],
|
|
71
|
+
defaultId: 2,
|
|
72
|
+
cancelId: 2,
|
|
73
|
+
noLink: true,
|
|
74
|
+
}));
|
|
75
|
+
}
|
|
76
|
+
catch {
|
|
77
|
+
return false;
|
|
78
|
+
}
|
|
79
|
+
if (current !== playing) {
|
|
80
|
+
return false;
|
|
81
|
+
}
|
|
82
|
+
switch (response) {
|
|
83
|
+
case 0:
|
|
84
|
+
allowedOnce.add(endpoint);
|
|
85
|
+
return true;
|
|
86
|
+
case 1:
|
|
87
|
+
if (!settings.allowSocket(swf, endpoint)) {
|
|
88
|
+
allowedOnce.add(endpoint);
|
|
89
|
+
}
|
|
90
|
+
return true;
|
|
91
|
+
default:
|
|
92
|
+
deniedOnce.add(endpoint);
|
|
93
|
+
return false;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Whether what plays may open a WebSocket to `url`: an AIR application,
|
|
98
|
+
* unasked and anywhere, as AIR's application sandbox connects and as its
|
|
99
|
+
* sockets do here. air.net.WebSocket is AIR's alone, so nothing else has one.
|
|
100
|
+
*/
|
|
101
|
+
export function permitWebSocket(url) {
|
|
102
|
+
if (sandbox.application && hasWebSocket() && (!proxy || proxiedWebSockets)) {
|
|
103
|
+
return true;
|
|
104
|
+
}
|
|
105
|
+
const why = !sandbox.application
|
|
106
|
+
? "only an AIR application has one"
|
|
107
|
+
: !hasWebSocket()
|
|
108
|
+
? "this Electron has no WebSocket client"
|
|
109
|
+
: "this Electron's WebSocket cannot go through the proxy";
|
|
110
|
+
process.stderr.write(`swf2es: no WebSocket to ${url.slice(0, 2048)}: ${why}\n`);
|
|
111
|
+
return false;
|
|
112
|
+
}
|
|
113
|
+
//# sourceMappingURL=permissions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"permissions.js","sourceRoot":"","sources":["../../src/main/permissions.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,kEAAkE;AAClE,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAC3E,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AACvD,OAAO,EAAE,OAAO,EAAE,iBAAiB,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAClE,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAE1D,oGAAoG;AACpG,MAAM,MAAM,GAAG,IAAI,GAAG,EAA4B,CAAC;AAEnD;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAChC,IAAY,EACZ,IAAY;IAEZ,qFAAqF;IACrF,IAAI,OAAO,CAAC,WAAW,EAAE,CAAC;QACxB,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,MAAM,OAAO,GAAG,OAAO,CAAC;IACxB,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC;IACxB,MAAM,QAAQ,GAAG,GAAG,IAAI,IAAI,IAAI,EAAE,CAAC;IACnC,IAAI,CAAC,OAAO,IAAI,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC,cAAc,EAAE,EAAE,CAAC;QAClD,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,wBAAwB,QAAQ,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H,MAAM,UAAU,eAAe,CAAC,GAAW;IACzC,IAAI,OAAO,CAAC,WAAW,IAAI,YAAY,EAAE,IAAI,CAAC,CAAC,KAAK,IAAI,iBAAiB,CAAC,EAAE,CAAC;QAC3E,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM,GAAG,GAAG,CAAC,OAAO,CAAC,WAAW;QAC9B,CAAC,CAAC,iCAAiC;QACnC,CAAC,CAAC,CAAC,YAAY,EAAE;YACf,CAAC,CAAC,uCAAuC;YACzC,CAAC,CAAC,uDAAuD,CAAC;IAC9D,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,2BAA2B,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,CAAC;IAChF,OAAO,KAAK,CAAC;AACf,CAAC"}
|
package/dist/main/settings.d.ts
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import type { LibraryName, LibraryState } from "../shared/api.js";
|
|
2
2
|
export interface Settings {
|
|
3
|
-
|
|
3
|
+
/**
|
|
4
|
+
* Stage3D as the View menu last set it; absent until it does, which is on. Not `stage3D`, the
|
|
5
|
+
* key of the opt-in this replaced: every write saved that one, its `false` along with any other
|
|
6
|
+
* change, so a stored `false` there does not tell a user's choice from the old default.
|
|
7
|
+
*/
|
|
8
|
+
stage3DChoice?: boolean;
|
|
4
9
|
playerglobal?: string;
|
|
5
10
|
/** Most recent first. */
|
|
6
11
|
recent: string[];
|
|
@@ -20,6 +25,8 @@ export declare class SettingsFile {
|
|
|
20
25
|
setLibrary(name: LibraryName, path: string): boolean;
|
|
21
26
|
/** Back to the library the app ships; whether that was saved. */
|
|
22
27
|
clearLibrary(name: LibraryName): boolean;
|
|
28
|
+
/** Whether SWFs get a Context3D: on unless the user turned it off. */
|
|
29
|
+
get stage3D(): boolean;
|
|
23
30
|
setStage3D(enabled: boolean): boolean;
|
|
24
31
|
/** `path` opened: first in the recent list. */
|
|
25
32
|
opened(path: string): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"settings.d.ts","sourceRoot":"","sources":["../../src/main/settings.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"settings.d.ts","sourceRoot":"","sources":["../../src/main/settings.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAElE,MAAM,WAAW,QAAQ;IACvB;;;;OAIG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,yBAAyB;IACzB,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;CACnC;AAOD,qBAAa,YAAY;IACvB,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAS;IAC9B,OAAO,CAAC,OAAO,CAAW;IAE1B,YAAY,SAAS,EAAE,MAAM,EAG5B;IAED,IAAI,QAAQ,IAAI,QAAQ,CAAC,QAAQ,CAAC,CAEjC;IAED,iGAAiG;IACjG,SAAS,IAAI,YAAY,CAExB;IAED,8DAA8D;IAC9D,UAAU,CAAC,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAEnD;IAED,iEAAiE;IACjE,YAAY,CAAC,IAAI,EAAE,WAAW,GAAG,OAAO,CAEvC;IAED,sEAAsE;IACtE,IAAI,OAAO,IAAI,OAAO,CAErB;IAED,UAAU,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAEpC;IAED,+CAA+C;IAC/C,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAIzB;IAED,2EAA2E;IAC3E,aAAa,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAEpD;IAED,8EAA8E;IAC9E,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAGlD;IAED,WAAW,IAAI,IAAI,CAElB;IAED,OAAO,CAAC,KAAK;IAIb,OAAO,CAAC,IAAI;IAoBZ;;;OAGG;IACH,OAAO,CAAC,MAAM;CAgBf"}
|
package/dist/main/settings.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// What the app remembers between runs, in settings.json under its user
|
|
2
|
-
// data: a playerglobal.abc the user chose,
|
|
2
|
+
// data: a playerglobal.abc the user chose, the SWFs opened last, and
|
|
3
|
+
// Stage3D turned off or on from the View menu.
|
|
3
4
|
import { randomUUID } from "node:crypto";
|
|
4
5
|
import { existsSync, mkdirSync, readFileSync, renameSync, rmSync, writeFileSync } from "node:fs";
|
|
5
6
|
import { dirname, join } from "node:path";
|
|
@@ -27,8 +28,12 @@ export class SettingsFile {
|
|
|
27
28
|
clearLibrary(name) {
|
|
28
29
|
return this.update({ [name]: undefined });
|
|
29
30
|
}
|
|
31
|
+
/** Whether SWFs get a Context3D: on unless the user turned it off. */
|
|
32
|
+
get stage3D() {
|
|
33
|
+
return this.current.stage3DChoice ?? true;
|
|
34
|
+
}
|
|
30
35
|
setStage3D(enabled) {
|
|
31
|
-
return this.update({
|
|
36
|
+
return this.update({ stage3DChoice: enabled });
|
|
32
37
|
}
|
|
33
38
|
/** `path` opened: first in the recent list. */
|
|
34
39
|
opened(path) {
|
|
@@ -56,7 +61,7 @@ export class SettingsFile {
|
|
|
56
61
|
const read = JSON.parse(readFileSync(this.path, "utf8"));
|
|
57
62
|
const text = (value) => (typeof value === "string" ? value : undefined);
|
|
58
63
|
return {
|
|
59
|
-
|
|
64
|
+
stage3DChoice: typeof read.stage3DChoice === "boolean" ? read.stage3DChoice : undefined,
|
|
60
65
|
playerglobal: text(read.playerglobal),
|
|
61
66
|
recent: strings(read.recent),
|
|
62
67
|
sockets: Object.fromEntries(Object.entries(typeof read.sockets === "object" && read.sockets !== null ? read.sockets : {}).map(([swf, endpoints]) => [swf, strings(endpoints)])),
|
|
@@ -64,7 +69,7 @@ export class SettingsFile {
|
|
|
64
69
|
}
|
|
65
70
|
catch {
|
|
66
71
|
// None yet, or unreadable: start again rather than refuse to start.
|
|
67
|
-
return {
|
|
72
|
+
return { recent: [], sockets: {} };
|
|
68
73
|
}
|
|
69
74
|
}
|
|
70
75
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"settings.js","sourceRoot":"","sources":["../../src/main/settings.ts"],"names":[],"mappings":"AAAA,uEAAuE;AACvE,qEAAqE;AACrE,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACjG,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"settings.js","sourceRoot":"","sources":["../../src/main/settings.ts"],"names":[],"mappings":"AAAA,uEAAuE;AACvE,qEAAqE;AACrE,+CAA+C;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACjG,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAmB1C,MAAM,MAAM,GAAG,EAAE,CAAC;AAElB,MAAM,OAAO,GAAG,CAAC,KAAc,EAAY,EAAE,CAC3C,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAe,EAAE,CAAC,OAAO,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;AAEtF,MAAM,OAAO,YAAY;IACN,IAAI,CAAS;IACtB,OAAO,CAAW;IAE1B,YAAY,SAAiB;QAC3B,IAAI,CAA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AAC;YACf,OAAO,CAAC,KAAK,CAAC,iCAAiC,IAAI,CAAC,IAAI,KAAK,KAAK,EAAE,CAAC,CAAC;YACtE,MAAM,CAAC,SAAS,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;YACnC,OAAO,KAAK,CAAC;QACf,CAAC;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { BrowserWindow, IpcMainEvent, IpcMainInvokeEvent } from "electron";
|
|
2
|
+
import { Sandbox } from "./sandbox.ts";
|
|
3
|
+
import type { SettingsFile } from "./settings.ts";
|
|
4
|
+
export declare const TITLE = "swf2es";
|
|
5
|
+
export declare const sandbox: Sandbox;
|
|
6
|
+
export declare let settings: SettingsFile;
|
|
7
|
+
export declare let window: BrowserWindow | null;
|
|
8
|
+
/**
|
|
9
|
+
* The page has asked to start and listens for what opens: until then, start() hands it the movie.
|
|
10
|
+
*/
|
|
11
|
+
export declare let listening: boolean;
|
|
12
|
+
export declare function setWindow(created: BrowserWindow | null): void;
|
|
13
|
+
export declare function setSettings(read: SettingsFile): void;
|
|
14
|
+
export declare function setListening(now: boolean): void;
|
|
15
|
+
/** Whether a message comes from the window's own page, on swf2es://app/. */
|
|
16
|
+
export declare function trusted(event: IpcMainEvent | IpcMainInvokeEvent): boolean;
|
|
17
|
+
//# sourceMappingURL=state.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"state.d.ts","sourceRoot":"","sources":["../../src/main/state.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAEhF,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAElD,eAAO,MAAM,KAAK,WAAW,CAAC;AAE9B,eAAO,MAAM,OAAO,SAAgB,CAAC;AACrC,eAAO,IAAI,QAAQ,EAAE,YAAY,CAAC;AAClC,eAAO,IAAI,MAAM,EAAE,aAAa,GAAG,IAAW,CAAC;AAC/C;;GAEG;AACH,eAAO,IAAI,SAAS,SAAQ,CAAC;AAE7B,wBAAgB,SAAS,CAAC,OAAO,EAAE,aAAa,GAAG,IAAI,GAAG,IAAI,CAE7D;AAED,wBAAgB,WAAW,CAAC,IAAI,EAAE,YAAY,GAAG,IAAI,CAEpD;AAED,wBAAgB,YAAY,CAAC,GAAG,EAAE,OAAO,GAAG,IAAI,CAE/C;AAED,4EAA4E;AAC5E,wBAAgB,OAAO,CAAC,KAAK,EAAE,YAAY,GAAG,kBAAkB,GAAG,OAAO,CAUzE"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { APP_ORIGIN } from "./protocol.js";
|
|
2
|
+
import { Sandbox } from "./sandbox.js";
|
|
3
|
+
export const TITLE = "swf2es";
|
|
4
|
+
export const sandbox = new Sandbox();
|
|
5
|
+
export let settings;
|
|
6
|
+
export let window = null;
|
|
7
|
+
/**
|
|
8
|
+
* The page has asked to start and listens for what opens: until then, start() hands it the movie.
|
|
9
|
+
*/
|
|
10
|
+
export let listening = false;
|
|
11
|
+
export function setWindow(created) {
|
|
12
|
+
window = created;
|
|
13
|
+
}
|
|
14
|
+
export function setSettings(read) {
|
|
15
|
+
settings = read;
|
|
16
|
+
}
|
|
17
|
+
export function setListening(now) {
|
|
18
|
+
listening = now;
|
|
19
|
+
}
|
|
20
|
+
/** Whether a message comes from the window's own page, on swf2es://app/. */
|
|
21
|
+
export function trusted(event) {
|
|
22
|
+
const frame = event.senderFrame;
|
|
23
|
+
return (window !== null &&
|
|
24
|
+
event.sender === window.webContents &&
|
|
25
|
+
frame !== null &&
|
|
26
|
+
frame.parent === null &&
|
|
27
|
+
// Node's URL gives a scheme it does not know no origin: compare the text.
|
|
28
|
+
frame.url.startsWith(`${APP_ORIGIN}/`));
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=state.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"state.js","sourceRoot":"","sources":["../../src/main/state.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAGvC,MAAM,CAAC,MAAM,KAAK,GAAG,QAAQ,CAAC;AAE9B,MAAM,CAAC,MAAM,OAAO,GAAG,IAAI,OAAO,EAAE,CAAC;AACrC,MAAM,CAAC,IAAI,QAAsB,CAAC;AAClC,MAAM,CAAC,IAAI,MAAM,GAAyB,IAAI,CAAC;AAC/C;;GAEG;AACH,MAAM,CAAC,IAAI,SAAS,GAAG,KAAK,CAAC;AAE7B,MAAM,UAAU,SAAS,CAAC,OAA6B;IACrD,MAAM,GAAG,OAAO,CAAC;AACnB,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,IAAkB;IAC5C,QAAQ,GAAG,IAAI,CAAC;AAClB,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,GAAY;IACvC,SAAS,GAAG,GAAG,CAAC;AAClB,CAAC;AAED,4EAA4E;AAC5E,MAAM,UAAU,OAAO,CAAC,KAAwC;IAC9D,MAAM,KAAK,GAAG,KAAK,CAAC,WAAW,CAAC;IAChC,OAAO,CACL,MAAM,KAAK,IAAI;QACf,KAAK,CAAC,MAAM,KAAK,MAAM,CAAC,WAAW;QACnC,KAAK,KAAK,IAAI;QACd,KAAK,CAAC,MAAM,KAAK,IAAI;QACrB,0EAA0E;QAC1E,KAAK,CAAC,GAAG,CAAC,UAAU,CAAC,GAAG,UAAU,GAAG,CAAC,CACvC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Network } from "./network.ts";
|
|
2
|
+
import { type Opener } from "./websocket-connections.ts";
|
|
3
|
+
/** --trace: what the page logs, a SWF's trace() among it, goes to the terminal. */
|
|
4
|
+
export declare const trace: boolean;
|
|
5
|
+
export declare const logSockets: boolean;
|
|
6
|
+
export declare const netLog: ((line: string) => boolean) | null;
|
|
7
|
+
/**
|
|
8
|
+
* --proxy=<url>: what the SWF's requests, sockets and WebSockets go
|
|
9
|
+
* through. For this run alone, never kept, and said aloud, without its
|
|
10
|
+
* credentials. One that does not parse stops the app rather than letting
|
|
11
|
+
* it run without.
|
|
12
|
+
*/
|
|
13
|
+
export declare const proxied: {
|
|
14
|
+
proxy: import("./proxy.ts").ProxyConfig;
|
|
15
|
+
} | {
|
|
16
|
+
error: string;
|
|
17
|
+
} | null;
|
|
18
|
+
export declare const proxy: import("./proxy.ts").ProxyConfig | null;
|
|
19
|
+
/** What --log-network adds to a line of a connection that went through the proxy. */
|
|
20
|
+
export declare const via: string;
|
|
21
|
+
export declare const warn: (message: string) => boolean;
|
|
22
|
+
export declare const network: Network;
|
|
23
|
+
export declare const proxiedWebSockets: unknown;
|
|
24
|
+
export declare const webSocketOpen: Opener | undefined;
|
|
25
|
+
//# sourceMappingURL=switches.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"switches.d.ts","sourceRoot":"","sources":["../../src/main/switches.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAGvC,OAAO,EAEL,KAAK,MAAM,EAIZ,MAAM,4BAA4B,CAAC;AAEpC,mFAAmF;AACnF,eAAO,MAAM,KAAK,SAAmC,CAAC;AAGtD,eAAO,MAAM,UAAU,SAAyC,CAAC;AAEjE,eAAO,MAAM,MAAM,UAAuB,MAAM,oBAA6C,CAAC;AAoB9F;;;;;GAKG;AACH,eAAO,MAAM,OAAO;;;;QAAuC,CAAC;AAM5D,eAAO,MAAM,KAAK,yCAAyB,CAAC;AAO5C,qFAAqF;AACrF,eAAO,MAAM,GAAG,QAA4B,CAAC;AAC7C,eAAO,MAAM,IAAI,YAAa,MAAM,YAAiD,CAAC;AACtF,eAAO,MAAM,OAAO,SAAqD,CAAC;AAU1E,eAAO,MAAM,iBAAiB,SAAgE,CAAC;AAE/F,eAAO,MAAM,aAAa,EAAE,MAAM,GAAG,SAQtB,CAAC"}
|