yamlock 0.1.1 → 0.1.2

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/README.md CHANGED
@@ -13,27 +13,29 @@ Value-level encryption for YAML and JSON configuration files. The name **yamlock
13
13
  - Node.js 22.x via `asdf`
14
14
  - Yarn Classic (1.x)
15
15
 
16
- ## Current status
16
+ ## Installation
17
17
 
18
- - Package metadata, linting config, and MIT license are in place.
19
- - Core crypto helpers (`encryptValue`, `decryptValue`, and supporting utils) work with per-field salts and have unit tests.
20
- - `processConfig` can walk nested objects/arrays and apply encryption/decryption to every string value.
21
- - Public API exports (`encryptValue`, `decryptValue`, `processConfig`, `getSupportedAlgorithms`) are wired and verified by tests.
22
- - Directory structure for source, CLI, tests, and examples exists.
23
- - CLI binary can encrypt/decrypt YAML and JSON files by calling `processConfig`.
18
+ ### npm
24
19
 
25
- ## Working locally
20
+ ```bash
21
+ npm install -g yamlock # CLI usage
22
+ npm install yamlock # project dependency
23
+ ```
24
+
25
+ ### Yarn Classic
26
26
 
27
- 1. Install the toolchain: `asdf install nodejs 22` and `yarn set version classic` if needed.
28
- 2. Install dependencies with `yarn install`.
29
- 3. Use the scripts below during development.
27
+ ```bash
28
+ yarn global add yamlock # CLI usage
29
+ yarn add yamlock # project dependency
30
+ ```
30
31
 
31
- ## Available scripts
32
+ ## Features
32
33
 
33
- - `yarn build` copies the current `src` tree into `dist` (temporary until a real build pipeline appears).
34
- - `yarn prepare` invokes `yarn build` automatically when installing from git.
35
- - `yarn test` runs Node built-in test runner.
36
- - `yarn lint` executes ESLint with the provided config.
34
+ - Encrypt/decrypt individual configuration values with deterministic field-path salts.
35
+ - CLI workflow that processes YAML or JSON files in place.
36
+ - Recursively lock/unlock entire objects via `processConfig`.
37
+ - Public API exports that mirror CLI behavior for programmatic use.
38
+ - Focus on Node.js 22+, ESM modules, and a lightweight dependency set (`js-yaml`).
37
39
 
38
40
  ## Usage
39
41
 
@@ -72,25 +74,19 @@ Every locked string follows the format:
72
74
  yl|<algorithm>|<salt_base64>|<iv_base64>|<data_base64>
73
75
  ```
74
76
 
75
- where the salt is derived from the full field path. Moving or renaming the field invalidates the salt, preventing accidental decryption in the wrong location.
77
+ Where:
78
+ - yl - format marker prefix
79
+ - <algorithm> - algorithm name (e.g., aes-256-cbc)
80
+ - <salt_base64> - Base64-encoded field path
81
+ - <iv_base64> - Base64-encoded initialization vector
82
+ - <data_base64> - Base64-encoded encrypted data
83
+
84
+ The salt is derived from the full field path. Moving or renaming the field invalidates the salt, preventing accidental decryption in the wrong location.
76
85
 
77
86
  ### Key rotation
78
87
 
79
88
  See [docs/key-rotation.md](docs/key-rotation.md) for a step-by-step guide to rotating `YAMLOCK_KEY` without losing data.
80
89
 
81
- ## Project structure
82
-
83
- ```txt
84
- yamlock/
85
- ├── src/ # Source files (API, CLI, utilities)
86
- ├── dist/ # Build output created by `yarn build`
87
- ├── bin/ # CLI entry point (loads dist/cli/cli.js)
88
- ├── test/ # Unit and integration suites
89
- ├── examples/ # Usage demos (TBD)
90
- ├── CHANGELOG.md # Step-by-step release history
91
- └── README.md / LICENSE
92
- ```
93
-
94
90
  ## Inspiration and motivation
95
91
 
96
92
  I have worked with Ruby on Rails apps for more than ten years and appreciated how its secret management evolved between 4.2 and 6.x. That flow influenced **yamlock**, but I also explored modern tools such as:
@@ -104,7 +100,7 @@ Each of those projects solves secure config storage differently, yet none fit my
104
100
 
105
101
  ## Contributing
106
102
 
107
- See [CONTRIBUTING.md](CONTRIBUTING.md) for development workflow, coding standards, and release instructions.
103
+ See [CONTRIBUTING.md](CONTRIBUTING.md) for development workflow, available scripts, and release instructions.
108
104
 
109
105
  ## Exit codes
110
106
 
package/bin/yamlock CHANGED
@@ -1,6 +1,34 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- import('../dist/cli/cli.js').catch((error) => {
4
- console.error('[yamlock] CLI failed to start:', error);
5
- process.exit(1);
6
- });
3
+ async function loadCliEntry() {
4
+ try {
5
+ const distModule = await import('../dist/cli/cli.js');
6
+ if (distModule.runCli) {
7
+ return distModule.runCli;
8
+ }
9
+ } catch (error) {
10
+ if (!(error.code === 'ERR_MODULE_NOT_FOUND' || (error.message && error.message.includes('dist/cli/cli.js')))) {
11
+ throw error;
12
+ }
13
+ }
14
+
15
+ try {
16
+ const srcModule = await import('../src/cli/cli.js');
17
+ if (srcModule.runCli) {
18
+ return srcModule.runCli;
19
+ }
20
+ } catch (error) {
21
+ if (!(error.code === 'ERR_MODULE_NOT_FOUND')) {
22
+ throw error;
23
+ }
24
+ }
25
+
26
+ throw new Error('CLI entry not found.');
27
+ }
28
+
29
+ loadCliEntry()
30
+ .then((runCli) => runCli(process.argv))
31
+ .catch((error) => {
32
+ console.error('[yamlock] CLI failed to start:', error);
33
+ process.exit(1);
34
+ });
package/dist/cli/cli.js CHANGED
@@ -87,8 +87,8 @@ function parseArgs(argv) {
87
87
  return result;
88
88
  }
89
89
 
90
- async function main() {
91
- const { command, file, options } = parseArgs(process.argv);
90
+ export async function runCli(argv = process.argv) {
91
+ const { command, file, options } = parseArgs(argv);
92
92
 
93
93
  if (!command || !file) {
94
94
  print(HELP_TEXT.trim());
@@ -135,5 +135,5 @@ async function main() {
135
135
  }
136
136
 
137
137
  if (import.meta.url === `file://${process.argv[1]}`) {
138
- main();
138
+ runCli();
139
139
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "yamlock",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "Value-level encryption for YAML/JSON configuration files with CLI + Node.js APIs.",
5
5
  "license": "MIT",
6
6
  "type": "module",