autho 0.0.7 → 0.0.9

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 ADDED
@@ -0,0 +1,21 @@
1
+ MIT License Copyright (c) 2024 Nir Adler
2
+
3
+ Permission is hereby granted, free of
4
+ charge, to any person obtaining a copy of this software and associated
5
+ documentation files (the "Software"), to deal in the Software without
6
+ restriction, including without limitation the rights to use, copy, modify, merge,
7
+ publish, distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to the
9
+ following conditions:
10
+
11
+ The above copyright notice and this permission notice
12
+ (including the next paragraph) shall be included in all copies or substantial
13
+ portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
16
+ ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO
18
+ EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
19
+ OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
package/Readme.md CHANGED
@@ -33,7 +33,9 @@ This will start the Autho CLI, where you can generate OTPs, manage passwords, an
33
33
 
34
34
  3. **Managing Passwords**: Autho provides a secure vault for storing and managing your passwords. You can add, view, update, and delete passwords using the CLI interface.
35
35
 
36
- 4. **Self-Hosting**: If you prefer self-hosting, deploy Autho on your own server by following the instructions provided in the documentation.
36
+ 4. **Secure files**: Autho offers a reliable method for encrypting and decrypting files, ensuring their security and integrity.
37
+
38
+ 5. **Self-Hosting**: If you prefer self-hosting, deploy Autho on your own server by following the instructions provided in the documentation. (TBD)
37
39
 
38
40
  ## Security Considerations
39
41
 
@@ -51,11 +53,11 @@ Autho is an open-source project, and contributions are welcome! Feel free to rep
51
53
 
52
54
  ## License
53
55
 
54
- Autho is licensed under the [MIT License](link-to-license), allowing for unrestricted use, modification, and distribution.
56
+ Autho is licensed under the [MIT License](LICENSE), allowing for unrestricted use, modification, and distribution.
55
57
 
56
58
  ## Support
57
59
 
58
- For support or inquiries, please reach out to the [official Autho community](link-to-community) for assistance.
60
+ For support or inquiries, please open an issue for assistance.
59
61
 
60
62
  ## Acknowledgments
61
63
 
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 encryptedData = _Cipher.encrypt(inputBuffer, encryptionKey);
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 encryptedData = JSON.parse(inputFileContent.toString());
57363
- const decryptedData = _Cipher.decrypt(encryptedData, encryptionKey);
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
- "-d, --dataFolder <folderPath>",
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.7",
3
+ "version": "0.0.9",
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
  }