This is a projection, not a development branch. The tree above was constructed from the internal source named below under a manifest that decides which paths may leave, then scanned as a whole tree rather than as a series of patches, and only then published. Public history starts here because the history before it was not admissible, and neither was the tree. What used to stand in this repository included a rescue copy of another machine, a directory of phone handoffs, deployment wired to one house, and a submodule pointing at a forge no stranger can reach. None of that was ever the product. It stays in the private forge, which is allowed to hold the whole working organism, and this is what was deliberately sent out instead. Three mechanisms produced this tree, in decreasing order of trust. A top-level path the manifest does not name never arrives at all, which is the one that catches directories nobody has thought of yet. Named internal files inside admitted roots are dropped. A short, reviewed table replaces deployment defaults that a public build must not carry -- an endpoint aimed at one LAN, a VPN profile belonging to one phone, packaging built from one checkout path. Everything after this commit is an ordinary publication with the same three trailers, so a force push stops being routine and starts meaning that something deliberate happened. The trailers bind the projection to its source without pretending the public SHA is the private one: same lineage, different tree, and the record says so. Source-Sha: 8f27b1e76a8fef560a336aba18e6990713ff1047 Policy-Sha: 6b261d2f3e6e1fb19874846ba4bb1dfe15565d25b8618c1c1afba0419c101d27 Tree-Digest: 18ec3563c5e5ef9a414993a9f6734b251ff9ed3cd56eebdd6cac01e45c6e3067
126 lines
4.2 KiB
QML
126 lines
4.2 KiB
QML
pragma Singleton
|
|
pragma ComponentBehavior: Bound
|
|
|
|
import qs
|
|
import qs.modules.common
|
|
import qs.modules.common.functions
|
|
import Quickshell;
|
|
import Quickshell.Io;
|
|
import QtQuick;
|
|
|
|
/**
|
|
* For storing sensitive data in the keyring.
|
|
* Use this for small data only, since it stores a JSON of the contents directly and doesn't use a database.
|
|
*/
|
|
Singleton {
|
|
id: root
|
|
|
|
signal dataChanged()
|
|
|
|
property bool loaded: false
|
|
property var keyringData: ({})
|
|
|
|
property var properties: {
|
|
"application": "illogical-impulse",
|
|
"explanation": Translation.tr("For storing API keys and other sensitive information"),
|
|
}
|
|
property var propertiesAsArgs: Object.keys(root.properties).reduce(
|
|
function(arr, key) {
|
|
return arr.concat([key, root.properties[key]]);
|
|
}, []
|
|
)
|
|
property string keyringLabel: Translation.tr("%1 Safe Storage").arg("illogical-impulse")
|
|
|
|
function setNestedField(path, value) {
|
|
if (!root.keyringData) root.keyringData = {};
|
|
let keys = path;
|
|
let obj = root.keyringData;
|
|
let parents = [obj];
|
|
|
|
// Traverse and collect parent objects
|
|
for (let i = 0; i < keys.length - 1; ++i) {
|
|
if (!obj[keys[i]] || typeof obj[keys[i]] !== "object") {
|
|
obj[keys[i]] = {};
|
|
}
|
|
obj = obj[keys[i]];
|
|
parents.push(obj);
|
|
}
|
|
|
|
// Set the value at the innermost key
|
|
obj[keys[keys.length - 1]] = value;
|
|
|
|
// Reassign each parent object from the bottom up to trigger change notifications
|
|
for (let i = keys.length - 2; i >= 0; --i) {
|
|
let parent = parents[i];
|
|
let key = keys[i];
|
|
// Shallow clone to change object identity (spread replaced with Object.assign)
|
|
parent[key] = Object.assign({}, parent[key]);
|
|
}
|
|
|
|
// Finally, reassign root.keyringData to trigger top-level change
|
|
root.keyringData = Object.assign({}, root.keyringData);
|
|
|
|
saveKeyringData();
|
|
}
|
|
|
|
function fetchKeyringData() {
|
|
// console.log("[KeyringStorage] Fetching keyring data...");
|
|
// console.log("[KeyringStorage] getData command:'" + getData.command.join("' '") + "'");
|
|
getData.running = true;
|
|
}
|
|
|
|
function saveKeyringData() {
|
|
saveData.stdinEnabled = true;
|
|
saveData.running = true;
|
|
}
|
|
|
|
Process {
|
|
id: saveData
|
|
command: [
|
|
"secret-tool", "store", "--label=" + keyringLabel,
|
|
...propertiesAsArgs,
|
|
]
|
|
onRunningChanged: {
|
|
if (saveData.running) {
|
|
// console.log("[KeyringStorage] Saving with command: '" + saveData.command.join("' '") + "'");
|
|
saveData.write(JSON.stringify(root.keyringData));
|
|
root.dataChanged()
|
|
stdinEnabled = false // End input stream
|
|
}
|
|
}
|
|
}
|
|
|
|
Process {
|
|
id: getData
|
|
command: [ // We need to use echo for a newline so splitparser does parse
|
|
"bash", "-c", `${Directories.scriptPath}/keyring/try_lookup.sh 2> /dev/null`,
|
|
]
|
|
stdout: StdioCollector {
|
|
id: keyringDataOutputCollector
|
|
onStreamFinished: {
|
|
const data = keyringDataOutputCollector.text;
|
|
if (data.length === 0 || !data.startsWith("{")) return;
|
|
try {
|
|
root.keyringData = JSON.parse(data);
|
|
// console.log("[KeyringStorage] Keyring data fetched:", JSON.stringify(root.keyringData));
|
|
} catch (e) {
|
|
console.error("[KeyringStorage] Failed to get keyring data, reinitializing.");
|
|
root.keyringData = {};
|
|
saveKeyringData()
|
|
}
|
|
}
|
|
}
|
|
onExited: (exitCode, exitStatus) => {
|
|
// console.log("[KeyringStorage] Keyring data fetch process exited with code:", exitCode);
|
|
if (exitCode === 1) {
|
|
console.error("[KeyringStorage] Entry not found, initializing.");
|
|
root.keyringData = {};
|
|
saveKeyringData()
|
|
}
|
|
if (exitCode !== 2) {
|
|
root.loaded = true;
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|