mirror of
https://github.com/profullstack/logicsrc.git
synced 2026-12-01 09:24:46 +00:00
Add one-click unlock for all granted vaults
This commit is contained in:
parent
0cf528fd07
commit
186399607c
4 changed files with 315 additions and 4 deletions
|
|
@ -31,6 +31,36 @@ node -p 'require(require("os").homedir()+"/.config/logicsrc/identity.json").keys
|
|||
</div>
|
||||
</details>`;
|
||||
|
||||
/** Dashboard control for opening every vault granted to the signed-in person. */
|
||||
export function bulkUnlockCard() {
|
||||
return `<section class="card" id="vault-bulk" style="margin-bottom:22px">
|
||||
<div class="card-head"><span class="h">Unlock all vaults</span><span class="pill">one key · all teams</span></div>
|
||||
<div class="card-body">
|
||||
<p class="dim" style="margin-top:0;font-size:.88rem">Unlock every team vault granted to your account in one go. Your identity key and decrypted values stay in this browser tab; nothing is saved on this device or sent to the server.</p>
|
||||
<div class="notice warn" style="margin-bottom:12px">This loads all accessible secrets into this tab's memory. Values stay masked until you reveal them.</div>
|
||||
<form data-role="bulk-unlock" autocomplete="off">
|
||||
<label class="field"><span>Your identity secret key or identity.json</span>
|
||||
<input type="password" name="key" placeholder="paste once to open all granted vaults" spellcheck="false" autocomplete="off" required></label>
|
||||
<button class="btn acid" style="font-size:1rem;padding:12px 22px">Unlock all vaults</button>
|
||||
</form>
|
||||
<div data-role="bulk-running" hidden>
|
||||
<p data-role="bulk-progress" class="mono dim" aria-live="polite"></p>
|
||||
<button class="btn danger" type="button" data-action="bulk-stop">Stop and lock</button>
|
||||
</div>
|
||||
<div data-role="bulk-results" hidden>
|
||||
<p data-role="bulk-summary" class="dim" aria-live="polite"></p>
|
||||
<label class="field"><span>Search team, vault, or secret name</span>
|
||||
<input type="search" data-role="bulk-search" placeholder="e.g. NPM_TOKEN" autocomplete="off"></label>
|
||||
<div class="table-scroll"><table><thead><tr><th>Team</th><th>Vault</th><th>Secret</th><th>Value</th><th></th></tr></thead><tbody data-role="bulk-rows"></tbody></table></div>
|
||||
<button class="btn compact" type="button" data-action="bulk-more" hidden>Show more</button>
|
||||
<button class="btn danger" type="button" data-action="bulk-lock" style="margin-top:12px">Lock all and clear</button>
|
||||
</div>
|
||||
<p data-role="bulk-status" class="mono" style="font-size:.82rem;margin-bottom:0;color:var(--danger,#c23a3a)" aria-live="polite"></p>
|
||||
${KEY_HELP}
|
||||
</div>
|
||||
</section>`;
|
||||
}
|
||||
|
||||
function keyCard({ publicKey, hasGrant, grantCommand }) {
|
||||
if (!publicKey) {
|
||||
// No identity registered yet: offer to make one here. Only in this state --
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ import { requireAuth, csrfInput, getCeremony, setCeremony, clearCeremony } from
|
|||
import { ApiKeyError, createApiKey, keyCoversVault, listApiKeys, machineKeyOptions, revokeApiKey } from "../lib/apikey.mjs";
|
||||
import { requestOrigin } from "../lib/origin.mjs";
|
||||
import { CLI_HINT } from "../lib/cli-hint.mjs";
|
||||
import { vaultPageBody } from "../lib/vault-page.mjs";
|
||||
import { bulkUnlockCard, vaultPageBody } from "../lib/vault-page.mjs";
|
||||
import { keyFingerprint } from "../lib/keyfp.mjs";
|
||||
import { teamAudit } from "./credshare.mjs";
|
||||
import { config } from "../config.mjs";
|
||||
|
|
@ -119,12 +119,18 @@ export async function dashboardHandler(req, res) {
|
|||
${ok ? `<div class="notice ok">${esc(ok)}${rotation ? " Vault grants were revoked; rotate affected vault keys before re-adding this person." : ""}</div>` : ""}
|
||||
${err ? `<div class="notice err">${esc(err)}</div>` : ""}
|
||||
${CLI_HINT(requestOrigin(req, config.origin))}
|
||||
${bulkUnlockCard()}
|
||||
${cards || `<div class="card"><div class="card-body dim">You're not on any teams yet. Create one below or accept an invite.</div></div>`}
|
||||
<div class="card" style="margin-top:22px"><div class="card-head"><span class="h">New team</span></div>
|
||||
<div class="card-body"><form method="post" action="/teams" style="display:flex;gap:8px">${csrfInput(req)}
|
||||
<input name="slug" placeholder="team-slug" required style="flex:1"><button class="btn acid">Create team</button></form></div></div>
|
||||
</main>${footer}`;
|
||||
res.type("html").send(page({ title: "LogicSRC ▸ teams", body, head: `<script src="/pins.js" defer></script>` }));
|
||||
res.set("Cache-Control", "no-store");
|
||||
res.type("html").send(page({
|
||||
title: "LogicSRC ▸ teams",
|
||||
body: `${body}<script src="/vendor/libsodium.js" defer></script><script src="/vendor/libsodium-wrappers.js" defer></script><script src="/vault-bulk.js" defer></script>`,
|
||||
head: `<script src="/pins.js" defer></script>`
|
||||
}));
|
||||
}
|
||||
|
||||
pagesRouter.get("/dashboard", requireAuth, dashboardHandler);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue