enseal 0.0.0-stage → 0.1.0

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/lib/prompt.mjs ADDED
@@ -0,0 +1,51 @@
1
+ import readline from "node:readline/promises";
2
+ import { CliError } from "./errors.mjs";
3
+
4
+ /** A visible question. */
5
+ export async function prompt(question) {
6
+ const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
7
+ try {
8
+ return (await rl.question(question)).trim();
9
+ } finally {
10
+ rl.close();
11
+ }
12
+ }
13
+
14
+ /** A hidden question: nothing is echoed. Secrets come in through here or
15
+ * through stdin — never through argv, which lands in shell history and ps. */
16
+ export function promptHidden(question) {
17
+ if (!process.stdin.isTTY) {
18
+ throw new CliError("No terminal for a hidden prompt. In scripts, pipe the secret in with `-`.", 4);
19
+ }
20
+ return new Promise((resolve, reject) => {
21
+ process.stdout.write(question);
22
+ const stdin = process.stdin;
23
+ stdin.setRawMode(true);
24
+ stdin.resume();
25
+ stdin.setEncoding("utf8");
26
+ let value = "";
27
+ const done = (fn, arg) => {
28
+ stdin.setRawMode(false);
29
+ stdin.pause();
30
+ stdin.off("data", onData);
31
+ process.stdout.write("\n");
32
+ fn(arg);
33
+ };
34
+ const onData = (chunk) => {
35
+ for (const ch of chunk) {
36
+ if (ch === "\r" || ch === "\n") return done(resolve, value);
37
+ if (ch === "\u0003") return done(reject, new CliError("Cancelled.", 4)); // ^C
38
+ if (ch === "\u007f" || ch === "\b") value = value.slice(0, -1);
39
+ else value += ch;
40
+ }
41
+ };
42
+ stdin.on("data", onData);
43
+ });
44
+ }
45
+
46
+ /** Everything piped in on stdin, for `enseal send -`. */
47
+ export async function readStdin() {
48
+ const chunks = [];
49
+ for await (const chunk of process.stdin) chunks.push(chunk);
50
+ return Buffer.concat(chunks);
51
+ }
package/package.json CHANGED
@@ -1,6 +1,19 @@
1
1
  {
2
2
  "name": "enseal",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.0",
4
+ "description": "Send secrets and files as one-time end-to-end-encrypted links from your terminal: the Enseal CLI.",
5
+ "license": "MIT",
6
+ "type": "module",
7
+ "bin": { "enseal": "bin/enseal.mjs" },
8
+ "files": ["bin", "lib", "README.md", "LICENSE"],
9
+ "engines": { "node": ">=20" },
10
+ "scripts": {
11
+ "test": "node --test test/*.test.mjs",
12
+ "prepublishOnly": "node ../scripts/build-cli.mjs && node --test test/*.test.mjs"
13
+ },
14
+ "dependencies": {
15
+ "tweetnacl": "1.0.3"
16
+ },
17
+ "keywords": ["secrets", "one-time", "encryption", "end-to-end", "credentials", "secure-send"],
18
+ "homepage": "https://enseal.app"
19
+ }