sec-ry 1.1.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/dist/cli.bundle.js +7211 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +37 -0
- package/dist/cmd/changelog.d.ts +2 -0
- package/dist/cmd/changelog.js +726 -0
- package/dist/cmd/denc.d.ts +2 -0
- package/dist/cmd/denc.js +74 -0
- package/dist/cmd/enc.d.ts +2 -0
- package/dist/cmd/enc.js +225 -0
- package/dist/cmd/example.d.ts +1 -0
- package/dist/cmd/example.js +92 -0
- package/dist/cmd/fp.d.ts +2 -0
- package/dist/cmd/fp.js +29 -0
- package/dist/cmd/gen.d.ts +2 -0
- package/dist/cmd/gen.js +76 -0
- package/dist/cmd/history.d.ts +2 -0
- package/dist/cmd/history.js +25 -0
- package/dist/cmd/info.d.ts +2 -0
- package/dist/cmd/info.js +28 -0
- package/dist/cmd/root.d.ts +1 -0
- package/dist/cmd/root.js +191 -0
- package/dist/cmd/seal.d.ts +3 -0
- package/dist/cmd/seal.js +81 -0
- package/dist/cmd/upgrade.d.ts +1 -0
- package/dist/cmd/upgrade.js +44 -0
- package/dist/cmd/verify.d.ts +2 -0
- package/dist/cmd/verify.js +30 -0
- package/dist/index.d.ts +28 -0
- package/dist/index.js +27 -0
- package/dist/lib/args.d.ts +8 -0
- package/dist/lib/args.js +43 -0
- package/dist/lib/clip.d.ts +2 -0
- package/dist/lib/clip.js +39 -0
- package/dist/lib/crypto.d.ts +29 -0
- package/dist/lib/crypto.js +312 -0
- package/dist/lib/env.d.ts +13 -0
- package/dist/lib/env.js +42 -0
- package/dist/lib/errors.d.ts +1 -0
- package/dist/lib/errors.js +61 -0
- package/dist/lib/history.d.ts +9 -0
- package/dist/lib/history.js +35 -0
- package/dist/lib/password.d.ts +2 -0
- package/dist/lib/password.js +31 -0
- package/dist/lib/rc.d.ts +7 -0
- package/dist/lib/rc.js +45 -0
- package/dist/lib/ui.d.ts +21 -0
- package/dist/lib/ui.js +137 -0
- package/package.json +44 -0
package/dist/lib/ui.js
ADDED
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.QUIET = exports.BIN = exports.PKG = exports.VERSION = void 0;
|
|
4
|
+
exports.setQuiet = setQuiet;
|
|
5
|
+
exports.data = data;
|
|
6
|
+
exports.err = err;
|
|
7
|
+
exports.warn = warn;
|
|
8
|
+
exports.info = info;
|
|
9
|
+
exports.ok = ok;
|
|
10
|
+
exports.box = box;
|
|
11
|
+
exports.section = section;
|
|
12
|
+
exports.token = token;
|
|
13
|
+
exports.ms = ms;
|
|
14
|
+
exports.row = row;
|
|
15
|
+
exports.usage = usage;
|
|
16
|
+
const env_1 = require("./env");
|
|
17
|
+
const _NC = !env_1.env.hasColor;
|
|
18
|
+
const _c = _NC ? {
|
|
19
|
+
r: "", dim: "", bold: "", hi: "", cyan: "", gray: "", red: "", yellow: "", green: ""
|
|
20
|
+
} : {
|
|
21
|
+
r: "\x1b[0m",
|
|
22
|
+
dim: "\x1b[2m",
|
|
23
|
+
bold: "\x1b[1m",
|
|
24
|
+
hi: "\x1b[38;5;252m",
|
|
25
|
+
cyan: "\x1b[36m",
|
|
26
|
+
gray: "\x1b[38;5;245m",
|
|
27
|
+
red: "\x1b[31m",
|
|
28
|
+
yellow: "\x1b[33m",
|
|
29
|
+
green: "\x1b[32m",
|
|
30
|
+
};
|
|
31
|
+
exports.VERSION = require("../../package.json").version;
|
|
32
|
+
exports.PKG = "secry";
|
|
33
|
+
exports.BIN = "secry";
|
|
34
|
+
exports.QUIET = false;
|
|
35
|
+
function setQuiet(v) { exports.QUIET = v; }
|
|
36
|
+
function _ui(s) { if (exports.QUIET)
|
|
37
|
+
return; process.stderr.write(s); }
|
|
38
|
+
function data(s) { process.stdout.write(s + "\n"); }
|
|
39
|
+
function _visLen(s) {
|
|
40
|
+
return s.replace(/\x1b\[[0-9;]*m/g, "").length;
|
|
41
|
+
}
|
|
42
|
+
function _line(len = 48) {
|
|
43
|
+
return `${_c.gray}${"─".repeat(len)}${_c.r}\n`;
|
|
44
|
+
}
|
|
45
|
+
function err(msg, code = 1) {
|
|
46
|
+
process.stderr.write(`\n ${_c.red}✘${_c.r} ${msg}\n\n`);
|
|
47
|
+
process.exit(code);
|
|
48
|
+
}
|
|
49
|
+
function warn(msg) {
|
|
50
|
+
_ui(` ${_c.yellow}!${_c.r} ${_c.dim}${msg}${_c.r}\n`);
|
|
51
|
+
}
|
|
52
|
+
function info(msg) {
|
|
53
|
+
_ui(` ${_c.cyan}→${_c.r} ${_c.dim}${msg}${_c.r}\n`);
|
|
54
|
+
}
|
|
55
|
+
function ok(msg) {
|
|
56
|
+
_ui(` ${_c.green}✔${_c.r} ${msg}\n`);
|
|
57
|
+
}
|
|
58
|
+
function box(rows) {
|
|
59
|
+
if (exports.QUIET)
|
|
60
|
+
return;
|
|
61
|
+
const lw = Math.max(...rows.map((r) => r.label.length));
|
|
62
|
+
const lines = rows.map((r) => {
|
|
63
|
+
const pad = " ".repeat(lw - r.label.length + 1);
|
|
64
|
+
const vc = r.valueColor ?? _c.hi;
|
|
65
|
+
return `${_c.gray}${r.label}${_c.r}${pad}${vc}${r.value}${_c.r}`;
|
|
66
|
+
});
|
|
67
|
+
const width = Math.max(...lines.map(_visLen)) + 4;
|
|
68
|
+
const hline = (l, r) => `${_c.gray}${l}${"─".repeat(width - 2)}${r}${_c.r}\n`;
|
|
69
|
+
_ui(hline("┌", "┐"));
|
|
70
|
+
for (const l of lines) {
|
|
71
|
+
const pad = Math.max(0, width - _visLen(l) - 2);
|
|
72
|
+
_ui(`${_c.gray}│${_c.r} ${l}${" ".repeat(pad)} ${_c.gray}│${_c.r}\n`);
|
|
73
|
+
}
|
|
74
|
+
_ui(hline("└", "┘"));
|
|
75
|
+
}
|
|
76
|
+
function section(title) {
|
|
77
|
+
_ui(`\n${_line()}`);
|
|
78
|
+
_ui(` ${_c.bold}${_c.hi}${title}${_c.r}\n`);
|
|
79
|
+
_ui(`${_line()}\n`);
|
|
80
|
+
}
|
|
81
|
+
function token(t) {
|
|
82
|
+
_ui(`\n ${_c.hi}${t}${_c.r}\n\n`);
|
|
83
|
+
}
|
|
84
|
+
function ms(elapsed) {
|
|
85
|
+
_ui(` ${_c.gray}done in ${elapsed}ms${_c.r}\n\n`);
|
|
86
|
+
}
|
|
87
|
+
function row(label, value, color = _c.hi) {
|
|
88
|
+
const pad = " ".repeat(Math.max(1, 10 - label.length));
|
|
89
|
+
_ui(` ${_c.gray}${label}${_c.r}${pad}${color}${value}${_c.r}\n`);
|
|
90
|
+
}
|
|
91
|
+
function usage() {
|
|
92
|
+
const cmd = (s, desc) => ` ${_c.cyan}${exports.BIN} ${s}${_c.r}\n ${_c.gray}${" ".repeat(exports.BIN.length + 1)}${desc}${_c.r}\n`;
|
|
93
|
+
const flag = (s, desc) => ` ${_c.cyan}${s}${_c.r}\n ${" ".repeat(2)}${_c.gray}${desc}${_c.r}\n`;
|
|
94
|
+
_ui(`\n${_line()}`);
|
|
95
|
+
_ui(` ${_c.bold}${_c.cyan}${exports.PKG}${_c.r} ${_c.gray}v${exports.VERSION} ChaCha20-Poly1305 / AES-256-GCM${_c.r}\n`);
|
|
96
|
+
_ui(`${_line()}\n`);
|
|
97
|
+
_ui(` ${_c.hi}commands${_c.r}\n\n`);
|
|
98
|
+
_ui(cmd("enc <text|@file> -sw <pass>", "encrypt text or file"));
|
|
99
|
+
_ui(cmd("denc <token> -sw <pass>", "decrypt token"));
|
|
100
|
+
_ui(cmd("verify <token> -sw <pass>", "verify token integrity"));
|
|
101
|
+
_ui(cmd("fp <text> -sw <pass>", "HMAC-SHA256 fingerprint"));
|
|
102
|
+
_ui(cmd("gen [bytes]", "generate secure password"));
|
|
103
|
+
_ui(cmd("info <token>", "inspect token metadata"));
|
|
104
|
+
_ui(cmd("history", "show session history"));
|
|
105
|
+
_ui(cmd("upgrade", "check for updates"));
|
|
106
|
+
_ui(cmd("changelog", "view project changelog"));
|
|
107
|
+
_ui(`\n ${_c.hi}flags${_c.r}\n\n`);
|
|
108
|
+
_ui(flag("-sw <pass>", "password (inline, @file, or env:VAR)"));
|
|
109
|
+
_ui(flag("--expires <t>", "token expiry 30s 5m 2h 7d"));
|
|
110
|
+
_ui(flag("--clip", "copy result to clipboard"));
|
|
111
|
+
_ui(flag("--out <file>", "save decrypted output to file"));
|
|
112
|
+
_ui(flag("--quiet / -q", "suppress UI — print token only"));
|
|
113
|
+
_ui(flag("--no-color", "disable ANSI colors"));
|
|
114
|
+
_ui(flag("-v / --version", "print version"));
|
|
115
|
+
_ui(flag("-h / --help", "show this help"));
|
|
116
|
+
_ui(flag("--upper", "guarantee at least one uppercase letter"));
|
|
117
|
+
_ui(flag("--count <n>", "generate n passwords (max 20)"));
|
|
118
|
+
_ui(`\n ${_c.hi}password sources${_c.r}\n\n`);
|
|
119
|
+
_ui(` ${_c.gray}-sw mypassword${_c.r} inline\n`);
|
|
120
|
+
_ui(` ${_c.gray}-sw @~/.secrykey${_c.r} read from file ${_c.gray}(recommended)${_c.r}\n`);
|
|
121
|
+
_ui(` ${_c.gray}-sw env:RWN64_KEY${_c.r} read from env variable\n`);
|
|
122
|
+
_ui(`\n ${_c.hi}examples${_c.r}\n\n`);
|
|
123
|
+
_ui(` ${_c.gray}secry enc 'my secret' -sw mypassword${_c.r}\n`);
|
|
124
|
+
_ui(` ${_c.gray}secry enc 'expires in 1h' -sw mypassword --expires 1h${_c.r}\n`);
|
|
125
|
+
_ui(` ${_c.gray}secry enc 'silent output' -sw mypassword --quiet${_c.r}\n`);
|
|
126
|
+
_ui(` ${_c.gray}secry enc @notes.txt -sw mypassword${_c.r}\n`);
|
|
127
|
+
_ui(` ${_c.gray}secry denc 'secry:v2:...' -sw mypassword${_c.r}\n`);
|
|
128
|
+
_ui(` ${_c.gray}TOKEN=\$(secry enc 'text' -sw pass --quiet)${_c.r}\n`);
|
|
129
|
+
_ui(` ${_c.gray}secry denc "\$TOKEN" -sw pass${_c.r}\n`);
|
|
130
|
+
_ui(` ${_c.gray}secry seal 'my data' -sw mypassword${_c.r}
|
|
131
|
+
`);
|
|
132
|
+
_ui(` ${_c.gray}secry seal 'my data' -sw mypassword --quiet${_c.r}
|
|
133
|
+
`);
|
|
134
|
+
_ui(` ${_c.gray}secry changelog${_c.r}
|
|
135
|
+
`);
|
|
136
|
+
_ui(`\n${_line()}\n`);
|
|
137
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "sec-ry",
|
|
3
|
+
"version": "1.1.5",
|
|
4
|
+
"description": "ChaCha20-Poly1305 / AES-256-GCM token encryption CLI and library",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"bin": {
|
|
8
|
+
"secry": "dist/cli.js",
|
|
9
|
+
"sec": "dist/cli.js"
|
|
10
|
+
},
|
|
11
|
+
"files": [
|
|
12
|
+
"dist",
|
|
13
|
+
"README.md"
|
|
14
|
+
],
|
|
15
|
+
"scripts": {
|
|
16
|
+
"build": "tsc",
|
|
17
|
+
"build:bundle": "esbuild dist/cli.js --bundle --platform=node --outfile=dist/cli.bundle.js",
|
|
18
|
+
"build:obfuscate": "terser dist/cli.bundle.js -o dist/cli.js --compress passes=3 --mangle",
|
|
19
|
+
"prepublishOnly": "npm run build && npm run build:bundle && npm run build:obfuscate && node scripts/postbuild.js"
|
|
20
|
+
},
|
|
21
|
+
"keywords": [
|
|
22
|
+
"encryption",
|
|
23
|
+
"chacha20",
|
|
24
|
+
"aes-256-gcm",
|
|
25
|
+
"cli",
|
|
26
|
+
"token",
|
|
27
|
+
"crypto",
|
|
28
|
+
"termux"
|
|
29
|
+
],
|
|
30
|
+
"license": "MIT",
|
|
31
|
+
"engines": {
|
|
32
|
+
"node": ">=16"
|
|
33
|
+
},
|
|
34
|
+
"devDependencies": {
|
|
35
|
+
"@types/node": "^20.11.0",
|
|
36
|
+
"esbuild": "^0.27.3",
|
|
37
|
+
"terser": "^5.46.0",
|
|
38
|
+
"typescript": "^5.3.3"
|
|
39
|
+
},
|
|
40
|
+
"dependencies": {
|
|
41
|
+
"@noble/hashes": "^2.0.1",
|
|
42
|
+
"@vitalets/google-translate-api": "^9.2.1"
|
|
43
|
+
}
|
|
44
|
+
}
|