autho 0.0.7 → 0.0.8
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/build/bin.js +48 -6
- package/package.json +14 -14
package/build/bin.js
CHANGED
|
@@ -57319,7 +57319,9 @@ var Cipher = class _Cipher {
|
|
|
57319
57319
|
algorithm,
|
|
57320
57320
|
signature: _Cipher.sign(value),
|
|
57321
57321
|
encoding,
|
|
57322
|
-
authTag
|
|
57322
|
+
authTag,
|
|
57323
|
+
provider: "crypto",
|
|
57324
|
+
platform: "autho"
|
|
57323
57325
|
};
|
|
57324
57326
|
}
|
|
57325
57327
|
static decrypt({
|
|
@@ -57349,18 +57351,37 @@ var Cipher = class _Cipher {
|
|
|
57349
57351
|
}
|
|
57350
57352
|
return decrypted;
|
|
57351
57353
|
}
|
|
57354
|
+
static canDecrypt(options) {
|
|
57355
|
+
return options.platform === "autho";
|
|
57356
|
+
}
|
|
57352
57357
|
static encryptFile(inputFilePath, outputFilePath, encryptionKey) {
|
|
57353
57358
|
const inputBuffer = import_fs.default.readFileSync(inputFilePath);
|
|
57354
|
-
const
|
|
57359
|
+
const params = {
|
|
57360
|
+
value: inputBuffer,
|
|
57361
|
+
encryptionKey
|
|
57362
|
+
};
|
|
57363
|
+
const encryptedData = _Cipher.encrypt(params);
|
|
57355
57364
|
import_fs.default.writeFileSync(
|
|
57356
57365
|
outputFilePath,
|
|
57357
|
-
Buffer.from(JSON.stringify(encryptedData))
|
|
57366
|
+
Buffer.from(JSON.stringify(encryptedData)).toString("base64")
|
|
57358
57367
|
);
|
|
57359
57368
|
}
|
|
57360
57369
|
static decryptFile(inputFilePath, outputFilePath, encryptionKey) {
|
|
57361
57370
|
const inputFileContent = import_fs.default.readFileSync(inputFilePath);
|
|
57362
|
-
const
|
|
57363
|
-
|
|
57371
|
+
const decoded = Buffer.from(
|
|
57372
|
+
inputFileContent.toString("utf-8"),
|
|
57373
|
+
"base64"
|
|
57374
|
+
).toString("utf-8");
|
|
57375
|
+
const encryptedData = JSON.parse(decoded);
|
|
57376
|
+
if (!_Cipher.canDecrypt(encryptedData)) {
|
|
57377
|
+
throw new Error("Invalid file");
|
|
57378
|
+
}
|
|
57379
|
+
const params = {
|
|
57380
|
+
...encryptedData,
|
|
57381
|
+
value: encryptedData.encrypted,
|
|
57382
|
+
encryptionKey
|
|
57383
|
+
};
|
|
57384
|
+
const decryptedData = _Cipher.decrypt(params);
|
|
57364
57385
|
import_fs.default.writeFileSync(outputFilePath, decryptedData);
|
|
57365
57386
|
}
|
|
57366
57387
|
};
|
|
@@ -59508,7 +59529,7 @@ var getAuthoAbsolutePath = (path5) => {
|
|
|
59508
59529
|
return import_path.default.join(process.cwd(), path5, ".autho");
|
|
59509
59530
|
};
|
|
59510
59531
|
program2.name("autho").description("Secrets manager").version("0.0.1").option("-p, --password <password>", "Master password").option("-ph, --passwordHash <passwordHash>", "Master password hash").option("-n, --name <name>", "Collection name", "default").option(
|
|
59511
|
-
"-
|
|
59532
|
+
"-data, --dataFolder <folderPath>",
|
|
59512
59533
|
"Folder path to store secrets db",
|
|
59513
59534
|
getAuthoAbsolutePath
|
|
59514
59535
|
).action(async (args) => {
|
|
@@ -59582,6 +59603,27 @@ program2.name("autho").description("Secrets manager").version("0.0.1").option("-
|
|
|
59582
59603
|
process.exit(1);
|
|
59583
59604
|
}
|
|
59584
59605
|
});
|
|
59606
|
+
program2.command("file").description("Encrypt/Decrypt file").option("-f, --filePath <filePath>", "File path").option("-en, --encrypt", "Encrypt file", false).option("-de, --decrypt", "Decrypt file", false).option("--override", "Override original file", false).action(async (args) => {
|
|
59607
|
+
const { encrypt, decrypt, filePath, override } = args;
|
|
59608
|
+
const encryptionKey = await App.masterKey();
|
|
59609
|
+
if (!encrypt && !decrypt) {
|
|
59610
|
+
console.log("Please provide either --encrypt or --decrypt");
|
|
59611
|
+
process.exit(1);
|
|
59612
|
+
} else if (encrypt) {
|
|
59613
|
+
if (filePath.endsWith(".autho")) {
|
|
59614
|
+
console.log(".autho files are already encrypted.");
|
|
59615
|
+
process.exit(1);
|
|
59616
|
+
}
|
|
59617
|
+
console.log("Encrypting file:", filePath);
|
|
59618
|
+
const outputFilePath = override ? filePath : filePath + ".autho";
|
|
59619
|
+
Cipher.encryptFile(filePath, outputFilePath, encryptionKey);
|
|
59620
|
+
} else if (decrypt) {
|
|
59621
|
+
console.log("Decrypting file:", filePath);
|
|
59622
|
+
const outputFilePath = filePath.endsWith(".autho") ? filePath.replace(/\.autho$/, "") : filePath;
|
|
59623
|
+
Cipher.decryptFile(filePath, outputFilePath, encryptionKey);
|
|
59624
|
+
}
|
|
59625
|
+
process.exit(0);
|
|
59626
|
+
});
|
|
59585
59627
|
program2.parse();
|
|
59586
59628
|
/*! Bundled license information:
|
|
59587
59629
|
|
package/package.json
CHANGED
|
@@ -1,11 +1,24 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "autho",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.8",
|
|
4
4
|
"main": "build/bin.js",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"bin": {
|
|
7
7
|
"autho": "build/bin.js"
|
|
8
8
|
},
|
|
9
|
+
"scripts": {
|
|
10
|
+
"format": "prettier --check .",
|
|
11
|
+
"format:write": "prettier --write .",
|
|
12
|
+
"lint": "eslint .",
|
|
13
|
+
"lint:fix": "eslint --fix .",
|
|
14
|
+
"build": "esbuild packages/cli/bin.js --bundle --platform=node --target=node18 --outdir=build",
|
|
15
|
+
"pkg": "npm run pkg:linux && npm run pkg:macos && npm run pkg:win",
|
|
16
|
+
"pkg:macos-arm64": "pkg build/bin.js --output dist/autho --target node18-macos-arm64",
|
|
17
|
+
"pkg:macos": "pkg build/bin.js --output dist/autho-macos --target node18-macos-x64",
|
|
18
|
+
"pkg:linux": "pkg build/bin.js --output dist/autho-linux --target node18-linux-x64",
|
|
19
|
+
"pkg:win": "pkg build/bin.js --output dist/autho-win --target node18-win-x64",
|
|
20
|
+
"release": "gh release create v0.0.8 ./dist"
|
|
21
|
+
},
|
|
9
22
|
"keywords": [
|
|
10
23
|
"secrets",
|
|
11
24
|
"otp"
|
|
@@ -36,18 +49,5 @@
|
|
|
36
49
|
"node18-macos-x64"
|
|
37
50
|
],
|
|
38
51
|
"outputPath": "dist"
|
|
39
|
-
},
|
|
40
|
-
"scripts": {
|
|
41
|
-
"format": "prettier --check .",
|
|
42
|
-
"format:write": "prettier --write .",
|
|
43
|
-
"lint": "eslint .",
|
|
44
|
-
"lint:fix": "eslint --fix .",
|
|
45
|
-
"build": "esbuild packages/cli/bin.js --bundle --platform=node --target=node18 --outdir=build",
|
|
46
|
-
"pkg": "npm run pkg:linux && npm run pkg:macos && npm run pkg:win",
|
|
47
|
-
"pkg:macos-arm64": "pkg build/bin.js --output dist/autho --target node18-macos-arm64",
|
|
48
|
-
"pkg:macos": "pkg build/bin.js --output dist/autho-macos --target node18-macos-x64",
|
|
49
|
-
"pkg:linux": "pkg build/bin.js --output dist/autho-linux --target node18-linux-x64",
|
|
50
|
-
"pkg:win": "pkg build/bin.js --output dist/autho-win --target node18-win-x64",
|
|
51
|
-
"release": "gh release create v0.0.6 ./dist"
|
|
52
52
|
}
|
|
53
53
|
}
|