configre 2.1.8 → 2.1.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/README.md +1 -1
- package/demo/config/hostname.cjs +0 -0
- package/demo/config/index.cjs +0 -0
- package/package.json +7 -6
- package/secrets/config.js +5 -1
- package/secrets/register.js +14 -1
- package/skills/configre/SKILL.md +1 -1
- package/test/secrets.test.js +49 -0
package/README.md
CHANGED
|
@@ -221,7 +221,7 @@ For an individual configuration file, sidecars live beside it: `settings.secret.
|
|
|
221
221
|
|
|
222
222
|
### Identities and registration
|
|
223
223
|
|
|
224
|
-
Automatic registration requires a Git checkout with a configured upstream
|
|
224
|
+
Automatic registration requires a Git checkout with a configured upstream and credentials that allow a non-interactive push. The branch must match its upstream before a new registration. The registration commit uses the Git identity already configured; without one, it is authored as `Configre <configre@localhost>`, and Git config is never changed. Failed registrations are retried on the next load.
|
|
225
225
|
|
|
226
226
|
Each OS user has one identity, stored at `~/.config/configre/identity.pem` and `identity.pub`, reused across projects. Authorization is per project. A service running under another OS user needs its own registration.
|
|
227
227
|
|
package/demo/config/hostname.cjs
CHANGED
|
File without changes
|
package/demo/config/index.cjs
CHANGED
|
File without changes
|
package/package.json
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "configre",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.9",
|
|
4
4
|
"description": "🔧 Effortlessly Tailor Your Settings",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
7
7
|
"node": ">=22.13.0"
|
|
8
8
|
},
|
|
9
|
+
"scripts": {
|
|
10
|
+
"test": "node --test"
|
|
11
|
+
},
|
|
9
12
|
"dependencies": {
|
|
10
13
|
"lemonlog": "^1.2.2"
|
|
11
14
|
},
|
|
@@ -47,6 +50,7 @@
|
|
|
47
50
|
"url": "https://github.com/clasen/Configre/issues"
|
|
48
51
|
},
|
|
49
52
|
"homepage": "https://github.com/clasen/Configre#readme",
|
|
53
|
+
"packageManager": "pnpm@11.9.0",
|
|
50
54
|
"files": [
|
|
51
55
|
"index.js",
|
|
52
56
|
"merge.js",
|
|
@@ -62,8 +66,5 @@
|
|
|
62
66
|
"demo/module/config/hostname.cjs",
|
|
63
67
|
"demo/secrets/demo.js",
|
|
64
68
|
"demo/secrets/config/index.cjs"
|
|
65
|
-
]
|
|
66
|
-
|
|
67
|
-
"test": "node --test"
|
|
68
|
-
}
|
|
69
|
-
}
|
|
69
|
+
]
|
|
70
|
+
}
|
package/secrets/config.js
CHANGED
package/secrets/register.js
CHANGED
|
@@ -31,6 +31,19 @@ function git(directory, args, operation, options = {}) {
|
|
|
31
31
|
return result.stdout;
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
+
function identityEnv(root) {
|
|
35
|
+
const env = {};
|
|
36
|
+
for (const role of ["AUTHOR", "COMMITTER"]) {
|
|
37
|
+
try {
|
|
38
|
+
git(root, ["var", `GIT_${role}_IDENT`], `resolving the Git ${role.toLowerCase()} identity`);
|
|
39
|
+
} catch {
|
|
40
|
+
env[`GIT_${role}_NAME`] = config.git.fallbackIdentity.name;
|
|
41
|
+
env[`GIT_${role}_EMAIL`] = config.git.fallbackIdentity.email;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return env;
|
|
45
|
+
}
|
|
46
|
+
|
|
34
47
|
function registerRecipient(paths, identity, profile) {
|
|
35
48
|
if (!/^[a-zA-Z0-9][a-zA-Z0-9._-]*$/.test(profile)) {
|
|
36
49
|
throw registrationError("requires a profile containing only letters, digits, dots, underscores or hyphens");
|
|
@@ -86,7 +99,7 @@ function registerRecipient(paths, identity, profile) {
|
|
|
86
99
|
const blob = git(root, ["hash-object", "-w", "--stdin"], "storing the public key", { input: publicKey }).trim();
|
|
87
100
|
git(root, ["update-index", "--add", "--cacheinfo", "100644", blob, relative], "adding the public key to the isolated index", { env });
|
|
88
101
|
const tree = git(root, ["write-tree"], "building the registration tree", { env }).trim();
|
|
89
|
-
const commit = git(root, ["commit-tree", tree, "-p", head, "-m", `Configre: register ${profile}`], "creating the public-key commit
|
|
102
|
+
const commit = git(root, ["commit-tree", tree, "-p", head, "-m", `Configre: register ${profile}`], "creating the public-key commit", { env: identityEnv(root) }).trim();
|
|
90
103
|
if (fs.mkdirSync(directory, { recursive: true })) {
|
|
91
104
|
log.info("Created recipients directory", directory);
|
|
92
105
|
}
|
package/skills/configre/SKILL.md
CHANGED
|
@@ -68,7 +68,7 @@ module.exports = {
|
|
|
68
68
|
3. Local: pull, run to incorporate the public key, and push the updated ciphertext.
|
|
69
69
|
4. Server: pull and restart. Later secret updates repeat the local run/push and server pull/restart.
|
|
70
70
|
|
|
71
|
-
Registration needs a branch matching its upstream
|
|
71
|
+
Registration needs a branch matching its upstream and non-interactive push access. Without a Git identity, the commit is authored as `Configre <configre@localhost>`.
|
|
72
72
|
Pending authorization or failed registration returns public settings only; malformed secrets, identities, and ciphertext stop loading.
|
|
73
73
|
Use isolated fixtures for verification unless live registration is authorized: loading can fetch, commit, and push.
|
|
74
74
|
Registration preserves unrelated changes, skips hooks, rejects key-name collisions, and retries failures on later loads.
|
package/test/secrets.test.js
CHANGED
|
@@ -837,6 +837,55 @@ test("a server publishes only its public key once and receives automatic authori
|
|
|
837
837
|
assert.equal(git(f.remote, ["rev-list", "--count", "main", "--", "config/recipients/testhost.pub"]).trim(), "1");
|
|
838
838
|
});
|
|
839
839
|
|
|
840
|
+
function isolateGitIdentity(t, f) {
|
|
841
|
+
const home = path.join(f.root, "git-home");
|
|
842
|
+
fs.mkdirSync(home);
|
|
843
|
+
const overrides = {
|
|
844
|
+
HOME: home,
|
|
845
|
+
GIT_CONFIG_GLOBAL: "/dev/null",
|
|
846
|
+
GIT_CONFIG_NOSYSTEM: "1",
|
|
847
|
+
GIT_AUTHOR_NAME: undefined,
|
|
848
|
+
GIT_AUTHOR_EMAIL: undefined,
|
|
849
|
+
GIT_COMMITTER_NAME: undefined,
|
|
850
|
+
GIT_COMMITTER_EMAIL: undefined,
|
|
851
|
+
EMAIL: undefined
|
|
852
|
+
};
|
|
853
|
+
const saved = Object.fromEntries(Object.keys(overrides).map(key => [key, process.env[key]]));
|
|
854
|
+
const apply = values => Object.entries(values).forEach(([key, value]) => {
|
|
855
|
+
if (value === undefined) delete process.env[key];
|
|
856
|
+
else process.env[key] = value;
|
|
857
|
+
});
|
|
858
|
+
apply(overrides);
|
|
859
|
+
t.after(() => apply(saved));
|
|
860
|
+
}
|
|
861
|
+
|
|
862
|
+
function publishedIdentities(f) {
|
|
863
|
+
return git(f.remote, ["log", "-1", "--format=%an <%ae>%n%cn <%ce>", "main"]).trim().split("\n");
|
|
864
|
+
}
|
|
865
|
+
|
|
866
|
+
test("registration publishes with a fallback identity when Git has no usable author identity", t => {
|
|
867
|
+
const f = gitFixture(t);
|
|
868
|
+
isolateGitIdentity(t, f);
|
|
869
|
+
git(f.checkout, ["config", "--unset", "user.name"]);
|
|
870
|
+
git(f.checkout, ["config", "--unset", "user.email"]);
|
|
871
|
+
git(f.checkout, ["config", "user.useConfigOnly", "true"]);
|
|
872
|
+
const repositoryConfig = fs.readFileSync(path.join(f.checkout, ".git", "config"), "utf8");
|
|
873
|
+
f.useHome(1);
|
|
874
|
+
assertPublicOnly(f.consumer, f.logs, /public key is published in Git/i);
|
|
875
|
+
assert.equal(git(f.remote, ["diff-tree", "--no-commit-id", "--name-only", "-r", "main"]).trim(), "config/recipients/testhost.pub");
|
|
876
|
+
assert.deepEqual(publishedIdentities(f), ["Configre <configre@localhost>", "Configre <configre@localhost>"]);
|
|
877
|
+
assert.equal(git(f.checkout, ["rev-parse", "HEAD"]), git(f.remote, ["rev-parse", "main"]));
|
|
878
|
+
assert.equal(fs.readFileSync(path.join(f.checkout, ".git", "config"), "utf8"), repositoryConfig);
|
|
879
|
+
});
|
|
880
|
+
|
|
881
|
+
test("registration keeps the identity already configured in Git", t => {
|
|
882
|
+
const f = gitFixture(t);
|
|
883
|
+
isolateGitIdentity(t, f);
|
|
884
|
+
f.useHome(1);
|
|
885
|
+
assertPublicOnly(f.consumer, f.logs, /public key is published in Git/i);
|
|
886
|
+
assert.deepEqual(publishedIdentities(f), ["Configre Test <configre-test@example.invalid>", "Configre Test <configre-test@example.invalid>"]);
|
|
887
|
+
});
|
|
888
|
+
|
|
840
889
|
test("a rejected registration push preserves the branch and staging area and can be retried", t => {
|
|
841
890
|
const f = gitFixture(t);
|
|
842
891
|
const hook = path.join(f.remote, "hooks", "pre-receive");
|