jso-protector 0.4.3 → 0.4.5
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/CHANGELOG.md +29 -0
- package/README.md +19 -1
- package/bin/jso-protector.js +65 -10
- package/ci/verify-package.js +1 -0
- package/credentials.js +158 -0
- package/examples/README.md +1 -1
- package/package.json +2 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,34 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.4.5 - 2026-08-31
|
|
4
|
+
|
|
5
|
+
- **The first command now works without an account.** With no credentials at
|
|
6
|
+
all the CLI sends the request anonymously and the service runs it on the free
|
|
7
|
+
tier - up to 20 files and 200 KB per request, no VM protection, rate limited
|
|
8
|
+
per IP. You get real protected output instead of an error, and the run says
|
|
9
|
+
so on stderr. `javascriptobfuscator login` switches to your plan.
|
|
10
|
+
- Half-configured credentials are still an error. Only *no* credentials means
|
|
11
|
+
anonymous, so a key that stopped resolving cannot silently downgrade a paid
|
|
12
|
+
build to the free tier.
|
|
13
|
+
|
|
14
|
+
## 0.4.4 - 2026-08-31
|
|
15
|
+
|
|
16
|
+
- **`javascriptobfuscator login` saves your credentials once, for every project
|
|
17
|
+
on the machine.** Getting a first protected build used to take about seven
|
|
18
|
+
steps: install, hit the error, find the site, register, verify email, locate
|
|
19
|
+
the dashboard, copy two values, work out two platform-specific environment
|
|
20
|
+
variable names, set them, and run again - then set them again in the next
|
|
21
|
+
shell. `login` opens the dashboard, takes the two values (the password is not
|
|
22
|
+
echoed), and stores them in `~/.jso-protector/credentials.json`.
|
|
23
|
+
- `javascriptobfuscator logout` removes them.
|
|
24
|
+
- Stored credentials are resolved **last**, after an explicit flag, a project
|
|
25
|
+
config and the environment variables, so no existing CI setup changes
|
|
26
|
+
behaviour.
|
|
27
|
+
- The missing-credential errors now name `login` as the fastest fix.
|
|
28
|
+
- The store is written 0600. That is real protection on POSIX; Windows does not
|
|
29
|
+
honour the mode, so there it is only as protected as your user profile - the
|
|
30
|
+
same position as `~/.npmrc`.
|
|
31
|
+
|
|
3
32
|
## 0.4.3 - 2026-08-30
|
|
4
33
|
|
|
5
34
|
Error messages only. No behaviour changes.
|
package/README.md
CHANGED
|
@@ -336,7 +336,25 @@ Keep billing, entitlement checks, plan limits, and API secrets on the server sid
|
|
|
336
336
|
|
|
337
337
|
If the hosted API rejects a request, the CLI reports dashboard credential hints for authentication failures and account/plan/credit guidance for entitlement failures. API keys and passwords are redacted from error messages before they reach terminal logs.
|
|
338
338
|
|
|
339
|
-
|
|
339
|
+
### Sign in once
|
|
340
|
+
|
|
341
|
+
```bash
|
|
342
|
+
npx javascriptobfuscator login
|
|
343
|
+
```
|
|
344
|
+
|
|
345
|
+
This opens the dashboard, takes the API Key and API Password (the password is
|
|
346
|
+
not echoed), and stores them in `~/.jso-protector/credentials.json` for every
|
|
347
|
+
project on the machine. `npx javascriptobfuscator logout` removes them.
|
|
348
|
+
|
|
349
|
+
The store is written `0600`. That is real protection on POSIX; Windows does not
|
|
350
|
+
honour the mode, so there the file is only as protected as your user profile
|
|
351
|
+
directory - the same position as `~/.npmrc`.
|
|
352
|
+
|
|
353
|
+
### Or set them per shell
|
|
354
|
+
|
|
355
|
+
Stored credentials are read **last**, so an explicit flag, a project config, or
|
|
356
|
+
these environment variables always win - a CI setup is unaffected by whatever a
|
|
357
|
+
developer has logged in with locally.
|
|
340
358
|
|
|
341
359
|
```bash
|
|
342
360
|
set JSO_API_KEY=base64-api-key-from-dashboard
|
package/bin/jso-protector.js
CHANGED
|
@@ -29,6 +29,15 @@ const SOURCE_MAP_COMMENT_LINE_PATTERN = /^[ \t]*\/\/[#@]\s*sourceMappingURL=.*(?
|
|
|
29
29
|
const SOURCE_MAP_COMMENT_BLOCK_PATTERN = /[ \t]*\/\*[#@]\s*sourceMappingURL=[\s\S]*?\*\/[ \t]*(?:\r?\n)?/g;
|
|
30
30
|
|
|
31
31
|
const PRESET_OPTIONS = {
|
|
32
|
+
// Free tier. Exactly the transforms that are ungated server-side - anything
|
|
33
|
+
// else (compression, MoveStrings, DeepObfuscate, renaming, VM ...) requires a
|
|
34
|
+
// paid plan, so a preset containing them turns an anonymous first run into a
|
|
35
|
+
// plan-gate error instead of a protected file.
|
|
36
|
+
free: {
|
|
37
|
+
IdentityStyle: "v2abcd",
|
|
38
|
+
EncodeStrings: true,
|
|
39
|
+
ReplaceNames: true
|
|
40
|
+
},
|
|
32
41
|
standard: {
|
|
33
42
|
EncodeStrings: true,
|
|
34
43
|
MoveStrings: true,
|
|
@@ -898,6 +907,8 @@ Usage:
|
|
|
898
907
|
jso-protector --payment-page-headers-from-har reports/checkout.har --payment-page-headers-baseline reports/payment-page-headers.baseline.json --payment-page-headers-output reports/payment-page-headers.json
|
|
899
908
|
jso-protector --script-inventory-audit reports/payment-script-inventory.json --runtime-inventory-snapshot reports/runtime-inventory.json
|
|
900
909
|
jso-protector --init
|
|
910
|
+
javascriptobfuscator login Sign in once and save credentials for this machine
|
|
911
|
+
javascriptobfuscator logout Remove the saved credentials
|
|
901
912
|
|
|
902
913
|
Options:
|
|
903
914
|
--config <file> Config file path. Supports JSON, CommonJS .cjs/.js, and ESM .mjs/.js files.
|
|
@@ -2323,7 +2334,22 @@ function mergeConfig(config, args = {}) {
|
|
|
2323
2334
|
const webPreset = loadWebPreset(config, args, baseDir);
|
|
2324
2335
|
const compatibility = translateJavascriptObfuscatorConfigOptions(config);
|
|
2325
2336
|
const jsConfuserCompatibility = translateJsConfuserConfigOptions(config);
|
|
2326
|
-
|
|
2337
|
+
// Credentials saved by `javascriptobfuscator login`. Deliberately LAST in the
|
|
2338
|
+
// chain: an explicit flag, a project config, or a CI environment variable must
|
|
2339
|
+
// always win over a developer's machine-wide login.
|
|
2340
|
+
let _stored;
|
|
2341
|
+
const storedCredentials = () => {
|
|
2342
|
+
if (_stored === undefined) {
|
|
2343
|
+
try { _stored = require("../credentials.js").readStored() || {}; }
|
|
2344
|
+
catch (err) { _stored = {}; }
|
|
2345
|
+
}
|
|
2346
|
+
return _stored;
|
|
2347
|
+
};
|
|
2348
|
+
|
|
2349
|
+
const explicitPreset = args.preset || config.preset || jsConfuserCompatibility.preset || compatibility.preset || (webPreset && webPreset.preset);
|
|
2350
|
+
const noCredentials = !(args.apiKey || config.apiKey || readEnv(["JSO_API_KEY", "JAVASCRIPT_OBFUSCATOR_API_KEY"]) || storedCredentials().apiKey)
|
|
2351
|
+
&& !(args.apiPassword || config.apiPassword || readEnv(["JSO_API_PASSWORD", "JAVASCRIPT_OBFUSCATOR_API_PASSWORD"]) || storedCredentials().apiPassword);
|
|
2352
|
+
const preset = normalizePresetName(explicitPreset || (noCredentials ? "free" : "standard"));
|
|
2327
2353
|
const output = args.output || config.output || getCompatibilityDefaultOutput(args, config, baseDir) || "dist-protected";
|
|
2328
2354
|
const convenienceOptions = mapConvenienceOptions(config, args);
|
|
2329
2355
|
const options = {
|
|
@@ -2343,8 +2369,8 @@ function mergeConfig(config, args = {}) {
|
|
|
2343
2369
|
const merged = {
|
|
2344
2370
|
mode: args.mode || config.mode || readEnv(["NODE_ENV"]) || null,
|
|
2345
2371
|
endpoint: args.endpoint || config.endpoint || readEnv(["JSO_ENDPOINT", "JAVASCRIPT_OBFUSCATOR_ENDPOINT"]) || DEFAULT_ENDPOINT,
|
|
2346
|
-
apiKey: resolveEnv(args.apiKey || config.apiKey || readEnv(["JSO_API_KEY", "JAVASCRIPT_OBFUSCATOR_API_KEY"]) || ""),
|
|
2347
|
-
apiPassword: resolveEnv(args.apiPassword || config.apiPassword || readEnv(["JSO_API_PASSWORD", "JAVASCRIPT_OBFUSCATOR_API_PASSWORD"]) || ""),
|
|
2372
|
+
apiKey: resolveEnv(args.apiKey || config.apiKey || readEnv(["JSO_API_KEY", "JAVASCRIPT_OBFUSCATOR_API_KEY"]) || storedCredentials().apiKey || ""),
|
|
2373
|
+
apiPassword: resolveEnv(args.apiPassword || config.apiPassword || readEnv(["JSO_API_PASSWORD", "JAVASCRIPT_OBFUSCATOR_API_PASSWORD"]) || storedCredentials().apiPassword || ""),
|
|
2348
2374
|
projectName: config.projectName || "jso-protector",
|
|
2349
2375
|
preset,
|
|
2350
2376
|
input: args.input || config.input || "dist",
|
|
@@ -2448,7 +2474,7 @@ function loadWebPreset(config, args, baseDir) {
|
|
|
2448
2474
|
function normalizePresetName(value) {
|
|
2449
2475
|
const name = String(value || "standard").toLowerCase();
|
|
2450
2476
|
if (!Object.prototype.hasOwnProperty.call(PRESET_OPTIONS, name)) {
|
|
2451
|
-
throw new Error(`Unknown preset "${value}". Use standard, balanced, or maximum.`);
|
|
2477
|
+
throw new Error(`Unknown preset "${value}". Use free, standard, balanced, or maximum.`);
|
|
2452
2478
|
}
|
|
2453
2479
|
return name;
|
|
2454
2480
|
}
|
|
@@ -4666,9 +4692,18 @@ function normalizeName(name) {
|
|
|
4666
4692
|
return String(name || "").replace(/\\/g, "/");
|
|
4667
4693
|
}
|
|
4668
4694
|
|
|
4695
|
+
// With NO credentials at all the request is sent anonymously: the service runs
|
|
4696
|
+
// it on the free tier (20 files / 200 KB, no VM, rate limited per IP) so a first
|
|
4697
|
+
// command produces real protected output instead of an error. Half-configured is
|
|
4698
|
+
// still an error, because that is a mistake rather than a choice.
|
|
4699
|
+
function isAnonymousRun(config) {
|
|
4700
|
+
return !config.apiKey && !config.apiPassword;
|
|
4701
|
+
}
|
|
4702
|
+
|
|
4669
4703
|
function assertReady(config) {
|
|
4670
|
-
if (
|
|
4671
|
-
if (!config.
|
|
4704
|
+
if (isAnonymousRun(config)) return;
|
|
4705
|
+
if (!config.apiKey) throw new Error("Missing API key. Run `javascriptobfuscator login` to sign in and save credentials, or create a key at https://javascriptobfuscator.com/dashboard/APIKeys.aspx and set JSO_API_KEY.");
|
|
4706
|
+
if (!config.apiPassword) throw new Error("Missing API password. Run `javascriptobfuscator login` to sign in and save credentials, or copy it from https://javascriptobfuscator.com/dashboard/APIKeys.aspx and set JSO_API_PASSWORD.");
|
|
4672
4707
|
}
|
|
4673
4708
|
|
|
4674
4709
|
function sha256(value) {
|
|
@@ -4849,8 +4884,8 @@ async function runDoctor(config, args = {}) {
|
|
|
4849
4884
|
const checks = [];
|
|
4850
4885
|
const limitations = collectCompetitorLimitations(args.rawConfig && typeof args.rawConfig === "object" ? args.rawConfig : config, args);
|
|
4851
4886
|
addDoctorCheck(checks, "endpoint", isValidUrl(config.endpoint), `Endpoint: ${config.endpoint}`, "Endpoint must be a valid URL.");
|
|
4852
|
-
addDoctorCheck(checks, "apiKey", !!config.apiKey, "API key is present.", "Missing API key.
|
|
4853
|
-
addDoctorCheck(checks, "apiPassword", !!config.apiPassword, "API password is present.", "Missing API password.
|
|
4887
|
+
addDoctorCheck(checks, "apiKey", !!config.apiKey, "API key is present.", "Missing API key. Run `javascriptobfuscator login` to sign in and save credentials, or create a key at https://javascriptobfuscator.com/dashboard/APIKeys.aspx and set JSO_API_KEY.");
|
|
4888
|
+
addDoctorCheck(checks, "apiPassword", !!config.apiPassword, "API password is present.", "Missing API password. Run `javascriptobfuscator login` to sign in and save credentials, or copy it from https://javascriptobfuscator.com/dashboard/APIKeys.aspx and set JSO_API_PASSWORD.");
|
|
4854
4889
|
addDoctorCheck(checks, "preset", true, `Preset: ${config.preset}`);
|
|
4855
4890
|
addDoctorCheck(checks, "options", Object.keys(config.options || {}).length > 0, `${Object.keys(config.options || {}).length} option(s) enabled.`, "No protection options are enabled.");
|
|
4856
4891
|
|
|
@@ -7119,8 +7154,8 @@ function validateProtectionConfig(config, args = {}) {
|
|
|
7119
7154
|
}
|
|
7120
7155
|
|
|
7121
7156
|
addValidationCheck(checks, "endpoint", isValidUrl(resolved.endpoint) ? "ok" : "error", isValidUrl(resolved.endpoint) ? `Endpoint: ${resolved.endpoint}` : "Endpoint must be a valid HTTP or HTTPS URL.");
|
|
7122
|
-
addValidationCheck(checks, "apiKey", resolved.apiKey ? "ok" : "error", resolved.apiKey ? "API key is present." : "Missing API key.
|
|
7123
|
-
addValidationCheck(checks, "apiPassword", resolved.apiPassword ? "ok" : "error", resolved.apiPassword ? "API password is present." : "Missing API password.
|
|
7157
|
+
addValidationCheck(checks, "apiKey", resolved.apiKey ? "ok" : "error", resolved.apiKey ? "API key is present." : "Missing API key. Run `javascriptobfuscator login` to sign in and save credentials, or create a key at https://javascriptobfuscator.com/dashboard/APIKeys.aspx and set JSO_API_KEY.");
|
|
7158
|
+
addValidationCheck(checks, "apiPassword", resolved.apiPassword ? "ok" : "error", resolved.apiPassword ? "API password is present." : "Missing API password. Run `javascriptobfuscator login` to sign in and save credentials, or copy it from https://javascriptobfuscator.com/dashboard/APIKeys.aspx and set JSO_API_PASSWORD.");
|
|
7124
7159
|
addCredentialStorageValidation(checks, config, args);
|
|
7125
7160
|
addValidationCheck(checks, "preset", "ok", `Preset: ${resolved.preset}`);
|
|
7126
7161
|
addValidationCheck(checks, "paths", resolved.input && resolved.output ? "ok" : "error", resolved.input && resolved.output ? "Input and output paths are configured." : "Input and output paths must be configured.");
|
|
@@ -11814,6 +11849,19 @@ async function main(argv = process.argv.slice(2)) {
|
|
|
11814
11849
|
// `jso ai <subcommand>` -- intercept before parseArgs so the AI
|
|
11815
11850
|
// surface gets its own flag set without bloating the protect-side
|
|
11816
11851
|
// parser. See ai-cli.js for the subcommand definitions.
|
|
11852
|
+
// `login` / `logout` -- a user-level credential store. Intercepted here for
|
|
11853
|
+
// the same reason as `ai`: it needs no protect-side flags. See credentials.js.
|
|
11854
|
+
if (argv.length > 0 && (argv[0] === "login" || argv[0] === "logout")) {
|
|
11855
|
+
const creds = require("../credentials.js");
|
|
11856
|
+
const code = argv[0] === "login" ? await creds.login(argv.slice(1)) : creds.logout();
|
|
11857
|
+
if (code !== 0) {
|
|
11858
|
+
const err = new Error("jso " + argv[0] + " exited with code " + code);
|
|
11859
|
+
err.exitCode = code;
|
|
11860
|
+
throw err;
|
|
11861
|
+
}
|
|
11862
|
+
return;
|
|
11863
|
+
}
|
|
11864
|
+
|
|
11817
11865
|
if (argv.length > 0 && argv[0] === "ai") {
|
|
11818
11866
|
const aiCli = require("../ai-cli.js");
|
|
11819
11867
|
const code = await aiCli.main(argv.slice(1));
|
|
@@ -12263,6 +12311,13 @@ async function main(argv = process.argv.slice(2)) {
|
|
|
12263
12311
|
}
|
|
12264
12312
|
|
|
12265
12313
|
assertReady(config);
|
|
12314
|
+
// Say plainly that this run is unauthenticated. Someone whose credentials
|
|
12315
|
+
// silently stopped resolving must not think they are on their paid plan.
|
|
12316
|
+
if (isAnonymousRun(config) && !args.json) {
|
|
12317
|
+
process.stderr.write(
|
|
12318
|
+
"No credentials found - running on the free tier (up to 20 files, 200 KB per request, no VM protection)." + "\n" +
|
|
12319
|
+
"Run `javascriptobfuscator login` to use your plan." + "\n\n");
|
|
12320
|
+
}
|
|
12266
12321
|
if (!files.length) {
|
|
12267
12322
|
throw new Error("No matching input files found.");
|
|
12268
12323
|
}
|
package/ci/verify-package.js
CHANGED
package/credentials.js
ADDED
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
// User-level credential store for the CLI.
|
|
4
|
+
//
|
|
5
|
+
// Before this existed, credentials could only come from environment variables
|
|
6
|
+
// or a project-local jso.config.json. That meant a first-time user had to find
|
|
7
|
+
// the dashboard, copy two values, work out two platform-specific env var names,
|
|
8
|
+
// and set them again in every new shell. Measured against the competitor, whose
|
|
9
|
+
// package needs no account at all, that was the widest part of the gap we can
|
|
10
|
+
// actually close without changing the API's paid-only contract.
|
|
11
|
+
//
|
|
12
|
+
// The file is per-user and outside any project directory, so it is never
|
|
13
|
+
// committed by accident. It is written 0600, which is real protection on POSIX.
|
|
14
|
+
// On Windows the mode bits are not honoured - MEASURED, the file reports 666 -
|
|
15
|
+
// so there the secret is only as protected as the user profile directory's ACL.
|
|
16
|
+
// That is the same protection npm gives ~/.npmrc, and it is worth knowing rather
|
|
17
|
+
// than assuming the chmod did something.
|
|
18
|
+
|
|
19
|
+
const fs = require("fs");
|
|
20
|
+
const os = require("os");
|
|
21
|
+
const path = require("path");
|
|
22
|
+
const readline = require("readline");
|
|
23
|
+
const { spawn } = require("child_process");
|
|
24
|
+
|
|
25
|
+
const DASHBOARD_URL = "https://javascriptobfuscator.com/dashboard/APIKeys.aspx";
|
|
26
|
+
const STORE_DIR = path.join(os.homedir() || ".", ".jso-protector");
|
|
27
|
+
const STORE_FILE = path.join(STORE_DIR, "credentials.json");
|
|
28
|
+
|
|
29
|
+
function storePath() { return STORE_FILE; }
|
|
30
|
+
|
|
31
|
+
function readStored() {
|
|
32
|
+
try {
|
|
33
|
+
const raw = fs.readFileSync(STORE_FILE, "utf8");
|
|
34
|
+
const parsed = JSON.parse(raw);
|
|
35
|
+
if (!parsed || typeof parsed !== "object") return null;
|
|
36
|
+
const apiKey = typeof parsed.apiKey === "string" ? parsed.apiKey : "";
|
|
37
|
+
const apiPassword = typeof parsed.apiPassword === "string" ? parsed.apiPassword : "";
|
|
38
|
+
if (!apiKey || !apiPassword) return null;
|
|
39
|
+
return { apiKey, apiPassword, endpoint: typeof parsed.endpoint === "string" ? parsed.endpoint : "" };
|
|
40
|
+
} catch (err) {
|
|
41
|
+
// A missing store is the normal case, not an error. A corrupt one must not
|
|
42
|
+
// take down a build that has working credentials in the environment.
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function writeStored(apiKey, apiPassword, endpoint) {
|
|
48
|
+
fs.mkdirSync(STORE_DIR, { recursive: true, mode: 0o700 });
|
|
49
|
+
const body = { apiKey, apiPassword };
|
|
50
|
+
if (endpoint) body.endpoint = endpoint;
|
|
51
|
+
// Write with the restrictive mode from the start rather than chmod-ing after,
|
|
52
|
+
// so the secret is never briefly world-readable.
|
|
53
|
+
fs.writeFileSync(STORE_FILE, JSON.stringify(body, null, 2) + "\n", { encoding: "utf8", mode: 0o600 });
|
|
54
|
+
// No-op on Windows, which does not honour POSIX modes; see the header note.
|
|
55
|
+
try { fs.chmodSync(STORE_FILE, 0o600); } catch (err) { /* best effort */ }
|
|
56
|
+
return STORE_FILE;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function clearStored() {
|
|
60
|
+
try { fs.unlinkSync(STORE_FILE); return true; }
|
|
61
|
+
catch (err) { return false; }
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// A dashboard value is base64. Catching an obviously wrong paste here turns a
|
|
65
|
+
// confusing failure at protect time into an immediate, specific message.
|
|
66
|
+
function looksLikeDashboardValue(value) {
|
|
67
|
+
return typeof value === "string" && value.length >= 8 && /^[A-Za-z0-9+/=_-]+$/.test(value.trim());
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function openBrowser(url) {
|
|
71
|
+
const cmd = process.platform === "win32" ? "cmd" : (process.platform === "darwin" ? "open" : "xdg-open");
|
|
72
|
+
const args = process.platform === "win32" ? ["/c", "start", "", url] : [url];
|
|
73
|
+
try {
|
|
74
|
+
const child = spawn(cmd, args, { stdio: "ignore", detached: true });
|
|
75
|
+
child.on("error", () => {});
|
|
76
|
+
child.unref();
|
|
77
|
+
return true;
|
|
78
|
+
} catch (err) {
|
|
79
|
+
return false;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function ask(rl, question, { hidden = false } = {}) {
|
|
84
|
+
return new Promise((resolve) => {
|
|
85
|
+
if (!hidden) { rl.question(question, (answer) => resolve(answer.trim())); return; }
|
|
86
|
+
// Mute the echo so a pasted secret does not stay on screen or in a shared
|
|
87
|
+
// terminal recording.
|
|
88
|
+
const output = rl.output;
|
|
89
|
+
let muted = false;
|
|
90
|
+
const onData = (chunk) => { if (muted) return; };
|
|
91
|
+
output.write(question);
|
|
92
|
+
muted = true;
|
|
93
|
+
const origWrite = output.write.bind(output);
|
|
94
|
+
output.write = (chunk, ...rest) => { if (muted && typeof chunk === "string" && chunk !== "\n" && chunk !== "\r\n") return true; return origWrite(chunk, ...rest); };
|
|
95
|
+
rl.question("", (answer) => {
|
|
96
|
+
muted = false;
|
|
97
|
+
output.write = origWrite;
|
|
98
|
+
output.write("\n");
|
|
99
|
+
resolve(answer.trim());
|
|
100
|
+
});
|
|
101
|
+
void onData;
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
async function login(argv = []) {
|
|
106
|
+
const noBrowser = argv.includes("--no-browser");
|
|
107
|
+
const out = process.stdout;
|
|
108
|
+
|
|
109
|
+
out.write("Sign in to javascriptobfuscator.com and copy your API credentials.\n\n");
|
|
110
|
+
out.write(" " + DASHBOARD_URL + "\n\n");
|
|
111
|
+
if (!noBrowser) {
|
|
112
|
+
if (openBrowser(DASHBOARD_URL)) out.write("Opened that page in your browser.\n");
|
|
113
|
+
else out.write("Could not open a browser automatically - use the link above.\n");
|
|
114
|
+
}
|
|
115
|
+
out.write("The dashboard shows an API Key and an API Password. Both are already\n");
|
|
116
|
+
out.write("base64 encoded; paste them exactly as shown.\n\n");
|
|
117
|
+
|
|
118
|
+
if (!process.stdin.isTTY) {
|
|
119
|
+
out.write("No interactive terminal. Set JSO_API_KEY and JSO_API_PASSWORD instead,\n");
|
|
120
|
+
out.write("or run this command in a terminal.\n");
|
|
121
|
+
return 1;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
const rl = readline.createInterface({ input: process.stdin, output: process.stdout, terminal: true });
|
|
125
|
+
try {
|
|
126
|
+
const apiKey = await ask(rl, "API Key: ");
|
|
127
|
+
const apiPassword = await ask(rl, "API Password: ", { hidden: true });
|
|
128
|
+
|
|
129
|
+
if (!apiKey || !apiPassword) {
|
|
130
|
+
out.write("\nBoth values are required. Nothing was saved.\n");
|
|
131
|
+
return 1;
|
|
132
|
+
}
|
|
133
|
+
if (!looksLikeDashboardValue(apiKey) || !looksLikeDashboardValue(apiPassword)) {
|
|
134
|
+
out.write("\nThat does not look like a dashboard value. They are base64 strings -\n");
|
|
135
|
+
out.write("check you copied the value and not the label. Nothing was saved.\n");
|
|
136
|
+
return 1;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
const file = writeStored(apiKey, apiPassword, "");
|
|
140
|
+
out.write("\nSaved to " + file + "\n");
|
|
141
|
+
out.write("Every project on this machine now uses these credentials.\n");
|
|
142
|
+
out.write("Run `javascriptobfuscator --input dist --output dist-protected` to protect a build.\n");
|
|
143
|
+
out.write("Run `javascriptobfuscator logout` to remove them.\n");
|
|
144
|
+
return 0;
|
|
145
|
+
} finally {
|
|
146
|
+
rl.close();
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
function logout() {
|
|
151
|
+
const removed = clearStored();
|
|
152
|
+
process.stdout.write(removed
|
|
153
|
+
? "Removed " + STORE_FILE + "\n"
|
|
154
|
+
: "No stored credentials at " + STORE_FILE + "\n");
|
|
155
|
+
return 0;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
module.exports = { login, logout, readStored, writeStored, clearStored, storePath, looksLikeDashboardValue, DASHBOARD_URL };
|
package/examples/README.md
CHANGED
|
@@ -39,7 +39,7 @@ published as `javascriptobfuscator-com`; `jso-protector` is the former name and
|
|
|
39
39
|
is deprecated but still updated:
|
|
40
40
|
|
|
41
41
|
```bash
|
|
42
|
-
npm install --save-dev javascriptobfuscator-com@0.4.
|
|
42
|
+
npm install --save-dev javascriptobfuscator-com@0.4.5
|
|
43
43
|
```
|
|
44
44
|
|
|
45
45
|
Repository contributors can instead use the existing `file:../..` development
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "jso-protector",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.5",
|
|
4
4
|
"description": "Obfuscate and protect JavaScript in your build or CI: dependency-free CLI, Node API, and webpack/Vite/Rollup/esbuild/Next.js/Metro plugins, with one-command migration from javascript-obfuscator and JS-Confuser configs.",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE",
|
|
6
6
|
"author": "JavaScript Obfuscator",
|
|
@@ -62,6 +62,7 @@
|
|
|
62
62
|
"ai.js",
|
|
63
63
|
"browserify.d.ts",
|
|
64
64
|
"browserify.js",
|
|
65
|
+
"credentials.js",
|
|
65
66
|
"esbuild.d.ts",
|
|
66
67
|
"esbuild.js",
|
|
67
68
|
"gulp.d.ts",
|