@gjermundgaraba/clankercreds 0.1.0 → 0.1.1
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/main.mjs +7 -2
- package/package.json +1 -1
package/dist/main.mjs
CHANGED
|
@@ -527,11 +527,16 @@ const removeGh = (configHome) => {
|
|
|
527
527
|
//#endregion
|
|
528
528
|
//#region src/state.ts
|
|
529
529
|
const stateDirectory = (home) => join(home, ".local/state/clankercreds");
|
|
530
|
+
/** clankerbox writes it for every machine: the same across stop and start, new for every fork and restore. */
|
|
531
|
+
const clankerboxMachineId = "/var/lib/clankerbox/machine-id";
|
|
530
532
|
/**
|
|
531
|
-
* A label for the audit log
|
|
533
|
+
* A label for the audit log. On a clankerbox machine it is the machine's own ID, so a fork
|
|
534
|
+
* reports as itself. Elsewhere it is generated on the machine on first use, and must never be
|
|
532
535
|
* created during an image build, or every machine from that image would share it.
|
|
533
536
|
*/
|
|
534
|
-
const clientId = (home) => {
|
|
537
|
+
const clientId = (home, machineIdFile = clankerboxMachineId) => {
|
|
538
|
+
const machine = readText(machineIdFile)?.trim();
|
|
539
|
+
if (machine !== void 0 && /^[A-Za-z0-9_-]{1,62}$/.test(machine)) return `m_${machine}`;
|
|
535
540
|
const file = join(stateDirectory(home), "client-id");
|
|
536
541
|
const existing = readText(file)?.trim();
|
|
537
542
|
if (existing !== void 0 && existing !== "") return existing;
|
package/package.json
CHANGED