rvlib-shipkit 2.26.0 → 2.27.0
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/CHANGELOG.md +20 -0
- package/package.json +1 -1
- package/src/agent-time/diet.ts +77 -0
- package/src/agent-time/family.ts +72 -0
- package/src/agent-time/hooks.ts +6 -4
- package/src/agent-time/limits.ts +44 -0
- package/src/agent-time/live.ts +1 -3
- package/src/agent-time/mask.ts +96 -18
- package/src/agent-time/refused.ts +45 -0
- package/src/agent-time/render.ts +122 -21
- package/src/agent-time/report-cache.ts +57 -0
- package/src/agent-time/report.ts +314 -40
- package/src/agent-time/shape.ts +50 -3
- package/src/agent-time/store.ts +320 -99
- package/src/agent-time/timeline.ts +140 -21
- package/src/agent-time/turns.ts +18 -8
- package/src/annex/offload.ts +17 -6
- package/src/annex/tidy.ts +70 -10
- package/src/asks/ask-after.ts +40 -0
- package/src/asks/asks-queue.ts +205 -47
- package/src/assets/kit-config.ts +7 -3
- package/src/assets/kits/identity-kit.ts +289 -10
- package/src/check.ts +3 -1
- package/src/checks/SK004-gitignore-policy.check.ts +12 -5
- package/src/checks/SK013-one-way-in-policy.check.ts +8 -3
- package/src/checks/SK026-asks-autoclose.check.ts +5 -5
- package/src/checks/SK028-readme.check.ts +7 -66
- package/src/checks/SK030-cache-audit.check.ts +6 -1
- package/src/checks/SK031-trace-audit.check.ts +2 -0
- package/src/checks/SK033-global-contribution.check.ts +3 -1
- package/src/checks/SK035-public-clean.check.ts +2 -2
- package/src/checks/SK043-scratch-on-the-mac.check.ts +59 -4
- package/src/checks/SK047-login-in-description.check.ts +36 -0
- package/src/checks/SK048-one-local-file.check.ts +36 -0
- package/src/cli/cmd_Asks.ts +71 -5
- package/src/cli/cmd_Backup.ts +2 -2
- package/src/cli/cmd_Capacity.ts +2 -2
- package/src/cli/cmd_CrossRepoActivity.ts +5 -4
- package/src/cli/cmd_Db.ts +253 -0
- package/src/cli/cmd_History.ts +212 -0
- package/src/cli/cmd_Home.ts +31 -3
- package/src/cli/cmd_Hq.ts +516 -0
- package/src/cli/cmd_Machines.ts +36 -0
- package/src/cli/cmd_Media.ts +38 -6
- package/src/cli/cmd_Reflect.ts +23 -2
- package/src/cli/cmd_Review.ts +548 -116
- package/src/cli/cmd_Secret.ts +62 -12
- package/src/cli/cmd_Social.ts +83 -1
- package/src/cli/cmd_Space.ts +324 -0
- package/src/cli/cmd_Time.ts +76 -5
- package/src/cli/cmd_Tmp.ts +28 -4
- package/src/cli/cmd_Trailer.ts +14 -10
- package/src/cli/cmd_Urls.ts +56 -0
- package/src/cli/cmd_Vault.ts +583 -0
- package/src/cli/family-help.ts +4 -2
- package/src/cli/family-pages.ts +1 -1
- package/src/cli/registry.ts +24 -3
- package/src/collections/actions.ts +63 -13
- package/src/collections/collection-types.ts +23 -1
- package/src/collections/providers.ts +117 -23
- package/src/collections/review.ts +4 -4
- package/src/contracts/contract-manifests.ts +6 -5
- package/src/contracts/contract-types.ts +6 -4
- package/src/contracts/contracts-engine.ts +11 -0
- package/src/contracts/manifests/chrome-web-store.contract.ts +31 -0
- package/src/core/budget.ts +12 -17
- package/src/core/capacity.ts +27 -18
- package/src/core/check-runner.ts +7 -4
- package/src/core/layout.ts +3 -0
- package/src/core/machine-busy.ts +127 -0
- package/src/core/machine-commit.ts +6 -1
- package/src/core/machine-db.ts +368 -20
- package/src/core/machine-layout.ts +137 -0
- package/src/core/machine-read.ts +81 -0
- package/src/core/migrate-layout.ts +1 -1
- package/src/core/one-way-in-policy.ts +64 -7
- package/src/core/polling-policy.ts +27 -0
- package/src/core/retention.ts +16 -2
- package/src/core/scope.ts +107 -14
- package/src/core/slots.ts +5 -4
- package/src/drill/clean.ts +25 -1
- package/src/drill/run.ts +1 -1
- package/src/drill/seal.ts +27 -4
- package/src/home/activity-shape.ts +2 -0
- package/src/home/activity.ts +66 -3
- package/src/home/app-sign.ts +15 -4
- package/src/home/daemon-jobs.ts +149 -7
- package/src/home/database-projects.ts +111 -0
- package/src/home/database-words.ts +203 -0
- package/src/home/databases.ts +460 -0
- package/src/home/global-units.ts +6 -0
- package/src/home/gui-app/ShipkitGui.swift +122 -1
- package/src/home/gui-app.ts +6 -3
- package/src/home/home-move.ts +514 -0
- package/src/home/home-paths.ts +12 -3
- package/src/home/home-routes.ts +68 -0
- package/src/home/inbox-shape.ts +24 -14
- package/src/home/machine-fold.ts +820 -0
- package/src/home/machine-host.ts +20 -5
- package/src/home/machine-repair.ts +503 -0
- package/src/home/machine-stores.ts +66 -15
- package/src/home/machine-temp.ts +547 -86
- package/src/home/resume.ts +79 -0
- package/src/home/run-daemon.ts +25 -4
- package/src/home/run-pm.ts +18 -5
- package/src/home/serve-daemon.ts +18 -3
- package/src/home/serve-web.ts +175 -7
- package/src/home/space-job.ts +115 -0
- package/src/home/space-page.ts +257 -0
- package/src/home/space-route.ts +167 -0
- package/src/home/space-words.ts +103 -0
- package/src/home/time-page-shape.ts +202 -0
- package/src/home/time-page.ts +64 -0
- package/src/home/vault-page.ts +482 -0
- package/src/home/vault-words.ts +132 -0
- package/src/hooks/leak-guard.ts +40 -13
- package/src/hooks/one-way-in-guard.ts +17 -4
- package/src/hq/cards.ts +581 -0
- package/src/hq/door-route.ts +43 -0
- package/src/hq/door.ts +163 -0
- package/src/hq/files-send.ts +348 -0
- package/src/hq/forgotten-log.ts +35 -0
- package/src/hq/history-check.ts +255 -0
- package/src/hq/history-place.ts +146 -0
- package/src/hq/history-send.ts +487 -0
- package/src/hq/hq-db.ts +99 -0
- package/src/hq/hq-local.ts +469 -0
- package/src/hq/hq-routes.ts +196 -0
- package/src/hq/hq-store.ts +599 -0
- package/src/hq/kinds/ask.ts +147 -0
- package/src/hq/kinds/card-gone.ts +83 -0
- package/src/hq/kinds/card-msg.ts +66 -0
- package/src/hq/kinds/card.ts +99 -0
- package/src/hq/kinds/index.ts +21 -0
- package/src/hq/kinds/kind.ts +126 -0
- package/src/hq/kinds/media.ts +125 -0
- package/src/hq/kinds/prompt.ts +219 -0
- package/src/hq/kinds/reflection.ts +128 -0
- package/src/hq/kinds/report.ts +55 -0
- package/src/hq/kinds/time-day.ts +236 -0
- package/src/hq/ledger.ts +473 -0
- package/src/hq/machine-key.ts +44 -0
- package/src/hq/machine-notes.ts +131 -0
- package/src/hq/outbox.ts +372 -0
- package/src/hq/replica.ts +168 -0
- package/src/hq/repo-id.ts +4 -0
- package/src/hq/report-facts.ts +117 -0
- package/src/hq/report.ts +274 -0
- package/src/hq/switch.ts +151 -0
- package/src/hq/vault-grant.ts +92 -0
- package/src/identities/identities.ts +15 -3
- package/src/identities/steps.ts +31 -0
- package/src/ledger/db.ts +73 -26
- package/src/ledger/gate-checks.ts +6 -2
- package/src/ledger/run-log.ts +11 -3
- package/src/ledger/store.ts +26 -4
- package/src/media-store/backup/daemon.ts +25 -17
- package/src/media-store/backup/kept.ts +241 -0
- package/src/media-store/backup/restore.ts +14 -4
- package/src/media-store/backup/run.ts +11 -11
- package/src/media-store/backup/secret.ts +6 -4
- package/src/media-store/backup/snapshot.ts +4 -2
- package/src/media-store/backup/sources.ts +67 -16
- package/src/media-store/copy/config.ts +77 -0
- package/src/media-store/copy/copy.ts +194 -0
- package/src/media-store/copy/lifecycle.ts +43 -0
- package/src/media-store/copy/night.ts +90 -0
- package/src/media-store/copy/proof.ts +151 -0
- package/src/media-store/copy/snapshot.ts +152 -0
- package/src/media-store/copy/store.ts +62 -0
- package/src/media-store/copy/stream.ts +176 -0
- package/src/media-store/daemon.ts +66 -16
- package/src/media-store/db.ts +22 -11
- package/src/media-store/forget.ts +23 -3
- package/src/media-store/hand.ts +4 -3
- package/src/media-store/hq-find.ts +75 -0
- package/src/media-store/hq-send.ts +277 -0
- package/src/media-store/kind.ts +2 -0
- package/src/media-store/purge.ts +18 -15
- package/src/media-store/put.ts +24 -8
- package/src/media-store/remote.ts +16 -7
- package/src/media-store/space-listing.ts +240 -0
- package/src/media-store/space.ts +40 -21
- package/src/media-store/sync.ts +5 -5
- package/src/media-store/tidy.ts +98 -0
- package/src/media-store/upload.ts +3 -3
- package/src/media-store/webp.ts +66 -0
- package/src/messages/model.ts +16 -7
- package/src/messages/routes.ts +14 -4
- package/src/messages/score.ts +2 -2
- package/src/messages/suggest.ts +96 -0
- package/src/pages/frame-client.ts +10 -0
- package/src/plan/planner.ts +28 -17
- package/src/recordings/media-kind.ts +1 -0
- package/src/recordings/model.ts +1 -1
- package/src/recordings/recorder-app/Capture.swift +9 -7
- package/src/reflect/hq-corpus.ts +56 -0
- package/src/reflect/prompt-corpus.ts +3 -1
- package/src/reflect/transcript.ts +129 -37
- package/src/release/machine-words.ts +67 -0
- package/src/release/public-clean.ts +8 -3
- package/src/releases/from-card.ts +1 -1
- package/src/releases/routes.ts +10 -5
- package/src/releases/store.ts +10 -1
- package/src/repo-config.ts +32 -2
- package/src/review/anim.ts +2 -2
- package/src/review/auto.ts +2 -2
- package/src/review/card-db.ts +244 -0
- package/src/review/card-rows.ts +266 -0
- package/src/review/cells.ts +76 -5
- package/src/review/draft-card.ts +41 -0
- package/src/review/draft-model.ts +78 -0
- package/src/review/format.ts +29 -10
- package/src/review/gone.ts +98 -0
- package/src/review/inbox-hook.ts +4 -4
- package/src/review/marks.ts +1 -1
- package/src/review/media-kind.ts +7 -5
- package/src/review/media-read.ts +9 -7
- package/src/review/media.ts +32 -5
- package/src/review/model.ts +202 -39
- package/src/review/move.ts +491 -0
- package/src/review/notes.ts +12 -20
- package/src/review/previews.ts +15 -19
- package/src/review/project.ts +1 -1
- package/src/review/rev.ts +8 -0
- package/src/review/role.ts +1 -1
- package/src/review/routes.ts +64 -13
- package/src/review/stage-card.ts +8 -4
- package/src/review/stage-routes.ts +1 -1
- package/src/review/store.ts +529 -83
- package/src/review/thread-fold.ts +51 -0
- package/src/review/threads.ts +147 -9
- package/src/review/trailer-auto-mock.ts +63 -0
- package/src/review/trailer-card.ts +4 -4
- package/src/review/trailer-desk.ts +41 -7
- package/src/review/trailer-media.ts +1 -0
- package/src/review/trailer-model.ts +8 -0
- package/src/review/trailer-notes.ts +1 -1
- package/src/review/trailer-routes.ts +9 -1
- package/src/review/unit.ts +6 -6
- package/src/review/watchers.ts +1 -1
- package/src/rules/untrack-generated.ts +92 -8
- package/src/secrets/held.ts +16 -0
- package/src/secrets/keychain.ts +113 -0
- package/src/secrets/list.ts +16 -6
- package/src/secrets/manager.ts +24 -10
- package/src/secrets/read.ts +257 -0
- package/src/secrets/who-reads.ts +49 -0
- package/src/serve/door-forward.ts +268 -0
- package/src/serve/door-names.ts +47 -0
- package/src/serve/embed.ts +1 -1
- package/src/serve/hub-app/activity-view.tsx +56 -32
- package/src/serve/hub-app/activity.css +7 -1
- package/src/serve/hub-app/asks-page.tsx +48 -0
- package/src/serve/hub-app/asks-st.ts +25 -0
- package/src/serve/hub-app/clock-svc.ts +1 -2
- package/src/serve/hub-app/col-card.tsx +64 -13
- package/src/serve/hub-app/col-list-page.tsx +122 -0
- package/src/serve/hub-app/col-list-st.ts +103 -0
- package/src/serve/hub-app/col-tables-view.tsx +10 -41
- package/src/serve/hub-app/col-tables.ts +76 -8
- package/src/serve/hub-app/cols-svc.ts +70 -16
- package/src/serve/hub-app/database-st.ts +260 -0
- package/src/serve/hub-app/database-view.tsx +289 -0
- package/src/serve/hub-app/database.css +32 -0
- package/src/serve/hub-app/entry-bar.css +14 -0
- package/src/serve/hub-app/entry-bar.tsx +33 -0
- package/src/serve/hub-app/entry-pick.ts +31 -0
- package/src/serve/hub-app/floating.tsx +1 -0
- package/src/serve/hub-app/hash-route.ts +11 -1
- package/src/serve/hub-app/header-bar.tsx +14 -18
- package/src/serve/hub-app/home-st.ts +89 -9
- package/src/serve/hub-app/home-strip.css +5 -19
- package/src/serve/hub-app/home-strip.tsx +58 -92
- package/src/serve/hub-app/home.html +7 -0
- package/src/serve/hub-app/hub-app.tsx +31 -142
- package/src/serve/hub-app/hub-types.ts +3 -1
- package/src/serve/hub-app/hub.css +109 -23
- package/src/serve/hub-app/icons.tsx +18 -1
- package/src/serve/hub-app/identities-st.ts +56 -6
- package/src/serve/hub-app/identities-view.tsx +100 -58
- package/src/serve/hub-app/identities.css +17 -15
- package/src/serve/hub-app/identity-address.ts +5 -0
- package/src/serve/hub-app/inbox-st.ts +41 -24
- package/src/serve/hub-app/inbox-view.tsx +37 -41
- package/src/serve/hub-app/inbox.css +2 -5
- package/src/serve/hub-app/index.html +7 -0
- package/src/serve/hub-app/kept-cols.tsx +7 -0
- package/src/serve/hub-app/keys.ts +28 -15
- package/src/serve/hub-app/later.tsx +26 -0
- package/src/serve/hub-app/list-filter.tsx +14 -0
- package/src/serve/hub-app/list-walk.ts +72 -3
- package/src/serve/hub-app/machines-st.ts +251 -0
- package/src/serve/hub-app/machines-view.tsx +224 -0
- package/src/serve/hub-app/machines.css +76 -0
- package/src/serve/hub-app/md-copy.tsx +79 -0
- package/src/serve/hub-app/media-view.tsx +2 -0
- package/src/serve/hub-app/messages/messages-page.tsx +79 -7
- package/src/serve/hub-app/messages/messages-st.ts +99 -3
- package/src/serve/hub-app/messages.css +14 -0
- package/src/serve/hub-app/page-keys.ts +175 -0
- package/src/serve/hub-app/pages-frames.tsx +11 -3
- package/src/serve/hub-app/palette-st.ts +58 -11
- package/src/serve/hub-app/palette-view.tsx +3 -1
- package/src/serve/hub-app/project-list.css +54 -8
- package/src/serve/hub-app/project-list.tsx +128 -59
- package/src/serve/hub-app/projects-svc.ts +78 -7
- package/src/serve/hub-app/reader-chips.tsx +13 -0
- package/src/serve/hub-app/readme-view.tsx +2 -3
- package/src/serve/hub-app/readme.css +27 -5
- package/src/serve/hub-app/reflections-page.tsx +42 -0
- package/src/serve/hub-app/reflections-st.ts +17 -0
- package/src/serve/hub-app/releases/releases-page.tsx +25 -2
- package/src/serve/hub-app/releases/releases-st.ts +1 -1
- package/src/serve/hub-app/repo-sections.ts +9 -5
- package/src/serve/hub-app/repo-st.ts +35 -8
- package/src/serve/hub-app/review/draft-card.tsx +163 -0
- package/src/serve/hub-app/review/kit.tsx +50 -7
- package/src/serve/hub-app/review/note-place.ts +1 -1
- package/src/serve/hub-app/review/review-board.tsx +2 -2
- package/src/serve/hub-app/review/review-cells.tsx +145 -65
- package/src/serve/hub-app/review/review-kit.ts +27 -1
- package/src/serve/hub-app/review/review-list.tsx +68 -30
- package/src/serve/hub-app/review/review-page.tsx +7 -8
- package/src/serve/hub-app/review/review-st.ts +111 -24
- package/src/serve/hub-app/review/review-thread.tsx +49 -19
- package/src/serve/hub-app/review/review-views.tsx +475 -144
- package/src/serve/hub-app/review/thread-control-st.ts +115 -0
- package/src/serve/hub-app/review/thread-control.tsx +74 -0
- package/src/serve/hub-app/review/thread-st.ts +73 -26
- package/src/serve/hub-app/review/trailer-card.tsx +1 -1
- package/src/serve/hub-app/review/trailer-page.tsx +37 -16
- package/src/serve/hub-app/review/trailer-st.ts +41 -7
- package/src/serve/hub-app/review.css +267 -61
- package/src/serve/hub-app/side-lists.ts +72 -0
- package/src/serve/hub-app/sidebar.tsx +6 -3
- package/src/serve/hub-app/site/site-part.tsx +2 -8
- package/src/serve/hub-app/site/site-st.ts +4 -4
- package/src/serve/hub-app/social/comms-page.tsx +20 -5
- package/src/serve/hub-app/social/kit.tsx +30 -4
- package/src/serve/hub-app/social/post-card.tsx +139 -49
- package/src/serve/hub-app/social/serial-writes.ts +13 -0
- package/src/serve/hub-app/social/social-model.ts +11 -0
- package/src/serve/hub-app/social/social-page.tsx +94 -35
- package/src/serve/hub-app/social/social-st.ts +120 -36
- package/src/serve/hub-app/social/stage-popup.tsx +1 -1
- package/src/serve/hub-app/social/stage-st.ts +1 -1
- package/src/serve/hub-app/social/step-layout.ts +1 -1
- package/src/serve/hub-app/social.css +3 -0
- package/src/serve/hub-app/space-st.ts +209 -0
- package/src/serve/hub-app/space-view.tsx +196 -0
- package/src/serve/hub-app/space.css +27 -0
- package/src/serve/hub-app/stores/stores-page.tsx +91 -23
- package/src/serve/hub-app/stores/stores-st.ts +44 -19
- package/src/serve/hub-app/stores.css +6 -1
- package/src/serve/hub-app/theme-st.ts +22 -9
- package/src/serve/hub-app/time-charts.tsx +291 -0
- package/src/serve/hub-app/time-pages.tsx +749 -0
- package/src/serve/hub-app/time-st.ts +162 -0
- package/src/serve/hub-app/time-view.tsx +76 -0
- package/src/serve/hub-app/time.css +138 -0
- package/src/serve/hub-app/tree-build.ts +52 -42
- package/src/serve/hub-app/tree-row.tsx +4 -4
- package/src/serve/hub-app/tree-svc.ts +18 -9
- package/src/serve/hub-app/urls-svc.ts +154 -0
- package/src/serve/hub-app/urls-view.tsx +117 -0
- package/src/serve/hub-app/urls.css +30 -0
- package/src/serve/hub-app/vault-st.ts +127 -0
- package/src/serve/hub-app/vault-view.tsx +154 -0
- package/src/serve/hub-app/vault.css +38 -0
- package/src/serve/hub-app/veille/veille-st.ts +12 -10
- package/src/serve/hub-app/waiting-svc.ts +29 -0
- package/src/serve/hub-app/wikis-view.tsx +2 -2
- package/src/serve/hub-runtime.ts +15 -2
- package/src/serve/project-gutter-route.ts +27 -14
- package/src/serve/project-gutter.ts +25 -12
- package/src/serve/same-origin.ts +10 -0
- package/src/serve/serve-hub.ts +13 -4
- package/src/shipkit-files.ts +16 -2
- package/src/shipkit.ts +1 -1
- package/src/shot/shooter.ts +616 -420
- package/src/shot/shot-ask.ts +246 -155
- package/src/site/desk.ts +2 -2
- package/src/smoke/run-smoke.ts +3 -2
- package/src/social/cover.ts +202 -0
- package/src/social/discord-layout.ts +37 -13
- package/src/social/drafts.ts +3 -0
- package/src/social/load.ts +23 -2
- package/src/social/media-kind.ts +2 -1
- package/src/social/publish/discord.ts +5 -2
- package/src/social/publish/secret.ts +2 -2
- package/src/social/release-stage.ts +28 -13
- package/src/social/routes.ts +26 -1
- package/src/social/stage.ts +1 -1
- package/src/social/stats.ts +12 -9
- package/src/social/strip.ts +4 -1
- package/src/social/thumbnail.ts +255 -0
- package/src/stores/collection.ts +15 -11
- package/src/stores/desk.ts +236 -42
- package/src/stores/model.ts +72 -6
- package/src/stores/routes.ts +37 -12
- package/src/stores/unit.ts +14 -8
- package/src/suite/judge-suites.ts +41 -11
- package/src/suite/select.ts +45 -3
- package/src/suite/suite-cli.ts +16 -10
- package/src/trailer/bed.ts +1 -1
- package/src/trailer/build.ts +134 -21
- package/src/trailer/ffmpeg.ts +7 -0
- package/src/trailer/fonts.ts +3 -2
- package/src/trailer/grammar.ts +201 -2
- package/src/trailer/graph.ts +42 -5
- package/src/trailer/look.ts +21 -0
- package/src/trailer/mock.ts +154 -0
- package/src/trailer/passage.ts +65 -26
- package/src/trailer/score/heard.ts +89 -0
- package/src/trailer/score/sound.ts +14 -8
- package/src/trailer/sound/run.ts +16 -6
- package/src/trailer/stitch.ts +26 -5
- package/src/trailer/titles.ts +82 -19
- package/src/trailer/versions.ts +1 -3
- package/src/trailer/vertical.ts +3 -1
- package/src/urls/frame.ts +195 -0
- package/src/urls/routes.ts +43 -0
- package/src/urls/rows.ts +171 -0
- package/src/urls/unit.ts +73 -0
- package/src/vault/house-keys.ts +42 -0
- package/src/vault/layout.ts +50 -0
- package/src/vault/policy.ts +165 -0
- package/src/vault/vault-audit.ts +276 -0
- package/src/vault/vault-client.ts +40 -0
- package/src/vault/vault-config.ts +159 -0
- package/src/vault/vault-destroy.ts +78 -0
- package/src/vault/vault-handover.ts +305 -0
- package/src/vault/vault-http.ts +352 -0
- package/src/vault/vault-import.ts +208 -0
- package/src/vault/vault-init.ts +328 -0
- package/src/vault/vault-minter.ts +271 -0
- package/src/vault/vault-restore.ts +333 -0
- package/src/vault/vault-serve.ts +342 -0
- package/src/vault/vault-snapshot.ts +281 -0
- package/src/veille/asks.ts +1 -1
- package/src/veille/desk.ts +2 -2
|
@@ -0,0 +1,583 @@
|
|
|
1
|
+
// sk vault: the store of secrets (OpenBao) on this machine. `serve` is what pm runs, `status` anyone reads, and
|
|
2
|
+
// `init` and `key --copy` are the owner's own, refused anywhere but his terminal
|
|
3
|
+
import { Command, Option } from 'clipanion'
|
|
4
|
+
import { createInterface } from 'readline/promises'
|
|
5
|
+
import { machineName } from '../home/machine-host.ts'
|
|
6
|
+
import { pmSwitchDeps, switchProcess } from '../home/pm-switch.ts'
|
|
7
|
+
import { standFacts } from '../home/vault-page.ts'
|
|
8
|
+
import { factLine } from '../home/vault-words.ts'
|
|
9
|
+
import type { NamesAnswer } from '../home/vault-page.ts'
|
|
10
|
+
import { daemonUrl } from '../home/home-paths.ts'
|
|
11
|
+
import { ago } from '../hq/machine-notes.ts'
|
|
12
|
+
import { vaultPlace, vaultUrl } from '../vault/vault-config.ts'
|
|
13
|
+
import { waitHealth } from '../vault/vault-http.ts'
|
|
14
|
+
import { macClipboard, provePasteboard, ttyTerminal } from '../vault/vault-handover.ts'
|
|
15
|
+
import { copySealKey, initVault, notTypedByOwner, resetVault } from '../vault/vault-init.ts'
|
|
16
|
+
import { minterOf, narrowVault } from '../vault/vault-minter.ts'
|
|
17
|
+
import { chmodSync, mkdtempSync, readFileSync, rmSync } from 'fs'
|
|
18
|
+
import { tmpdir } from 'os'
|
|
19
|
+
import { join } from 'path'
|
|
20
|
+
import { notEmpty, restoreVault, snapshotOf } from '../vault/vault-restore.ts'
|
|
21
|
+
import { houseCopy } from '../media-store/copy/config.ts'
|
|
22
|
+
import { snapshotFile } from '../media-store/copy/snapshot.ts'
|
|
23
|
+
import { minterTokenFile } from '../vault/vault-config.ts'
|
|
24
|
+
import { CHANGED_KEY, DEAD_DISK_KEY, NAMES_KEY, pruneLook, PROVED_KEY, proveFromSpace, snapshotsInSpace, spaceFolderOf, proveSnapshot, SENT_KEY, sendSnapshot, snapshotHealth, takeSnapshot, vaultStamp, type ProvedRecord, type Sent } from '../vault/vault-snapshot.ts'
|
|
25
|
+
import { machineSpace } from '../media-store/space.ts'
|
|
26
|
+
import { machineGet, machineSet } from '../core/machine-db.ts'
|
|
27
|
+
import { houseRootOf } from '../home/home-start.ts'
|
|
28
|
+
import { keepCompared } from '../hq/hq-local.ts'
|
|
29
|
+
import { keychainReader } from '../secrets/keychain.ts'
|
|
30
|
+
import { secretsWhere } from '../secrets/manager.ts'
|
|
31
|
+
import { houseKeys, keyOfFrom } from '../vault/house-keys.ts'
|
|
32
|
+
import type { VaultApi } from '../vault/vault-http.ts'
|
|
33
|
+
import { compareNames, importNames, placeNames, summaryOf, withImportLock, withImportToken, type Form, type Placed } from '../vault/vault-import.ts'
|
|
34
|
+
import { baoBin, keychainSeal, NO_BAO, readMarker, recordAuditPath, serveVault, type VaultStatus } from '../vault/vault-serve.ts'
|
|
35
|
+
import { destroyInVault, revokeStrayRoots } from '../vault/vault-destroy.ts'
|
|
36
|
+
import { vaultPathFor } from '../secrets/read.ts'
|
|
37
|
+
|
|
38
|
+
/** one line typed by the owner, the echo already off (vault-handover.ts): his Enter is not echoed either, so the
|
|
39
|
+
* line ends here. Not a raw terminal: ctrl c stays a signal, which the guard of the run answers */
|
|
40
|
+
const askLine = async (question: string): Promise<string> => {
|
|
41
|
+
const rl = createInterface({ input: process.stdin, output: process.stdout, terminal: false })
|
|
42
|
+
try {
|
|
43
|
+
return await rl.question(question)
|
|
44
|
+
} finally {
|
|
45
|
+
rl.close()
|
|
46
|
+
process.stdout.write('\n')
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/** one line typed at the terminal with no echo; never printed, never in an argv */
|
|
51
|
+
export async function hiddenLine(label: string): Promise<string> {
|
|
52
|
+
const { createInterface } = await import('readline')
|
|
53
|
+
process.stderr.write(label)
|
|
54
|
+
Bun.spawnSync(['stty', '-echo'], { stdin: 'inherit' })
|
|
55
|
+
try {
|
|
56
|
+
const rl = createInterface({ input: process.stdin, terminal: false })
|
|
57
|
+
const line = await new Promise<string>((ok) => rl.once('line', ok))
|
|
58
|
+
rl.close()
|
|
59
|
+
return line
|
|
60
|
+
} finally {
|
|
61
|
+
Bun.spawnSync(['stty', 'echo'], { stdin: 'inherit' })
|
|
62
|
+
process.stderr.write('\n')
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const typedByOwner = (stderr: NodeJS.WritableStream): boolean => {
|
|
67
|
+
const why = notTypedByOwner({ env: process.env, stdinTTY: process.stdin.isTTY === true, stdoutTTY: process.stdout.isTTY === true })
|
|
68
|
+
if (why == null) return true
|
|
69
|
+
stderr.write(`FAIL: ${why}\n`)
|
|
70
|
+
return false
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export class VaultServeCommand extends Command {
|
|
74
|
+
static override paths = [['vault', 'serve']]
|
|
75
|
+
|
|
76
|
+
static override usage = Command.Usage({
|
|
77
|
+
category: 'Secrets',
|
|
78
|
+
description: 'the vault in the foreground, as pm runs it: OpenBao on loopback, its seal key from the keychain',
|
|
79
|
+
details: 'pm runs it as the global process `vault`. The seal key goes from the keychain to bao in its environment: never in a file, an argument or the log, so the vault opens after a restart with nobody typing.',
|
|
80
|
+
})
|
|
81
|
+
|
|
82
|
+
async execute(): Promise<number> {
|
|
83
|
+
return await serveVault({ printErr: (l) => this.context.stderr.write(`${l}\n`) })
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/** the prune's state, and what the next tick would delete, from the Space's own list: a look, nothing deleted */
|
|
88
|
+
async function pruneLines(): Promise<string[]> {
|
|
89
|
+
const { vaultPruneOn } = await import('../hq/switch.ts')
|
|
90
|
+
const on = vaultPruneOn()
|
|
91
|
+
const head = on ? 'the prune of old snapshots: ON (sk vault snapshot --prune off stops it)' : 'the prune of old snapshots: off, nothing leaves the Space (sk vault snapshot --prune on deletes backups for good)'
|
|
92
|
+
const { space } = await machineSpace()
|
|
93
|
+
if (space == null) return [head]
|
|
94
|
+
const rows = (await space.list(spaceFolderOf(machineName().toLowerCase())).catch(() => [])).filter((r) => r.key.endsWith('.snap'))
|
|
95
|
+
const look = pruneLook({ rows, now: Date.now(), newestNames: machineGet<Sent>(SENT_KEY)?.names ?? null, names: machineGet<Record<string, number>>(NAMES_KEY) ?? {}, keep: [machineGet<ProvedRecord>(DEAD_DISK_KEY)?.key, machineGet<ProvedRecord>(PROVED_KEY)?.key].filter((k): k is string => k != null) })
|
|
96
|
+
const would = look.refused != null ? `the next tick would delete nothing: ${look.refused}` : look.gone.length === 0 ? 'the next tick would delete nothing' : `the next tick would delete ${look.gone.length}: ${look.gone.join(', ')}`
|
|
97
|
+
return [head, `${on ? '' : 'if it were on, '}${would}${look.stays.length > 0 ? `; kept: ${look.stays.join('; ')}` : ''}`]
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/** how the vault stands, as the console prints it: the page's words (home/vault-page.ts standFacts) */
|
|
101
|
+
export function renderVaultStatus(s: VaultStatus): string[] {
|
|
102
|
+
const [head, ...rest] = standFacts(s)
|
|
103
|
+
return [head?.text ?? '', ...rest.map(factLine)]
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/** the sealed copy of this machine's vault, from what the vault job and the snapshot command recorded, and the
|
|
107
|
+
* vault's stamp now when its minter answers */
|
|
108
|
+
export async function snapshotHealthHere(now: number = Date.now()): Promise<{ lines: string[]; warn: string[] }> {
|
|
109
|
+
const minter = minterOf(vaultPlace())
|
|
110
|
+
const stamp = minter == null ? null : await vaultStamp(minter).then((x) => x.stamp, () => null)
|
|
111
|
+
return snapshotHealth({ sent: machineGet<Sent>(SENT_KEY), proved: machineGet<ProvedRecord>(PROVED_KEY), changed: machineGet<{ stamp: string; at: number }>(CHANGED_KEY), stamp, now, deadDisk: machineGet<ProvedRecord>(DEAD_DISK_KEY) })
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/** the vault's names as the home's daemon holds them, and when it listed them: null when no daemon answers or it
|
|
115
|
+
* did not read the list, so the caller reads the vault itself */
|
|
116
|
+
async function keptNames(): Promise<NamesAnswer | null> {
|
|
117
|
+
try {
|
|
118
|
+
const r = await fetch(`${daemonUrl()}/api/home/vault/names`, { signal: AbortSignal.timeout(6_000) })
|
|
119
|
+
return r.ok ? ((await r.json()) as NamesAnswer) : null
|
|
120
|
+
} catch {
|
|
121
|
+
return null
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
export class VaultStatusCommand extends Command {
|
|
126
|
+
static override paths = [['vault', 'status'], ['vault']]
|
|
127
|
+
|
|
128
|
+
static override usage = Command.Usage({
|
|
129
|
+
category: 'Secrets',
|
|
130
|
+
description: 'how the vault stands, where it lives, its copies, its names: the page /vault. Never a value',
|
|
131
|
+
details: 'The words of the home page /vault, from the same read: how it stands (up, unsealed, audit on, root tokens alive), where it lives (its address, folders, process, where its keys are, in words), its copies (the sealed snapshots and their proofs), then a count of its names; --secrets lists every name with who reads it, where it is held and when it was written. Exit 0 when the vault answers initialised and unsealed, 1 otherwise. The audit, the root tokens and the names need the minter token of this machine.',
|
|
132
|
+
examples: [['where the vault stands', 'sk vault status'], ['and every name', 'sk vault status --secrets']],
|
|
133
|
+
})
|
|
134
|
+
|
|
135
|
+
json = Option.Boolean('--json', false, { description: 'the page\'s data as one json object' })
|
|
136
|
+
secrets = Option.Boolean('--secrets', false, { description: 'every name: where it is held, who reads it, when it was written' })
|
|
137
|
+
fresh = Option.Boolean('--fresh', false, { description: 'read every name from the vault now, not the daemon\'s kept read: about 150 vault calls at 100 names' })
|
|
138
|
+
|
|
139
|
+
async execute(): Promise<number> {
|
|
140
|
+
const { namesOfAnswer, vaultDeps, vaultPage } = await import('../home/vault-page.ts')
|
|
141
|
+
// the names come from the daemon's own read when it has one (kept an hour): a status that walked them itself
|
|
142
|
+
// wrote half a megabyte into the vault's audit file at each call
|
|
143
|
+
const kept = this.fresh ? null : await keptNames().then((a) => (a == null ? null : { names: namesOfAnswer(a), at: a.at }))
|
|
144
|
+
const p = await vaultPage(await vaultDeps(houseRootOf(process.cwd()), { seal: 'lookup', ...(kept == null ? {} : { names: async () => kept.names }) }))
|
|
145
|
+
if (kept != null) p.notes.push({ text: `the names as the daemon read them ${ago(Math.max(0, Date.now() - kept.at))} ago (kept an hour; --fresh reads the vault again)`, tone: 'dim' })
|
|
146
|
+
if (this.json) this.context.stdout.write(`${JSON.stringify(p)}\n`)
|
|
147
|
+
else {
|
|
148
|
+
const { vaultLines } = await import('../home/vault-words.ts')
|
|
149
|
+
const lines = vaultLines(p, { rows: this.secrets })
|
|
150
|
+
this.context.stdout.write(`${[...lines, ...(p.here ? (await pruneLines()).slice(1).map((l) => ` ${l}`) : [])].join('\n')}\n`)
|
|
151
|
+
}
|
|
152
|
+
return p.here && p.stands[0]?.tone === 'ok' ? 0 : 1
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
export class VaultInitCommand extends Command {
|
|
157
|
+
static override paths = [['vault', 'init']]
|
|
158
|
+
|
|
159
|
+
static override usage = Command.Usage({
|
|
160
|
+
category: 'Secrets',
|
|
161
|
+
description: "the owner's one init of the vault, at its Mac's desktop: the keys go to his clipboard",
|
|
162
|
+
details: "Run it in Terminal.app at the vault Mac's own desktop, never in an agent's session nor over ssh: it refuses there. It proves the clipboard works, makes the seal key and keeps it in the login keychain, initialises the vault, enables its mounts, the audit file, the token role `node` and the minter, and revokes the root token. Then it puts the seal key and the recovery key in the clipboard as one note for your password manager, and asks for the last 4 characters of the seal key, with no echo, to prove the copy. A first ctrl c asks again, a second one within 5 s drops the note. Only then it hands the vault to pm. It runs once: `--reset` undoes an init while the vault holds no secret.",
|
|
163
|
+
examples: [
|
|
164
|
+
['the one init of this Mac', 'sk vault init'],
|
|
165
|
+
['undo an init that stopped half way, the vault holding no secret', 'sk vault init --reset'],
|
|
166
|
+
],
|
|
167
|
+
})
|
|
168
|
+
|
|
169
|
+
reset = Option.Boolean('--reset', false, { description: 'undo an init while the vault holds no secret: its data, marker, minter token and seal key' })
|
|
170
|
+
|
|
171
|
+
async execute(): Promise<number> {
|
|
172
|
+
if (!typedByOwner(this.context.stderr)) return 1
|
|
173
|
+
const bin = baoBin()
|
|
174
|
+
if (bin == null) {
|
|
175
|
+
this.context.stderr.write(`FAIL: ${NO_BAO}\n`)
|
|
176
|
+
return 1
|
|
177
|
+
}
|
|
178
|
+
const place = vaultPlace()
|
|
179
|
+
const say = (l: string): void => void this.context.stdout.write(`${l}\n`)
|
|
180
|
+
if (this.reset) return await resetVault({ place, seal: keychainSeal(place), say, bin, baoLog: `${place.dir}/reset-bao.log` })
|
|
181
|
+
return await initVault({
|
|
182
|
+
place,
|
|
183
|
+
seal: keychainSeal(place),
|
|
184
|
+
clipboard: macClipboard,
|
|
185
|
+
proveClipboard: provePasteboard,
|
|
186
|
+
terminal: ttyTerminal,
|
|
187
|
+
ask: askLine,
|
|
188
|
+
say,
|
|
189
|
+
machine: machineName(),
|
|
190
|
+
bin,
|
|
191
|
+
baoLog: `${place.dir}/init-bao.log`,
|
|
192
|
+
pin: () => {
|
|
193
|
+
if (Bun.which('brew') == null) return 'WARN brew is not here: openbao is not pinned, an upgrade would restart the vault on a new version'
|
|
194
|
+
const p = Bun.spawnSync(['brew', 'pin', 'openbao'], { stdout: 'ignore', stderr: 'pipe' })
|
|
195
|
+
return p.exitCode === 0 ? 'ok: openbao is pinned (brew pin openbao): an upgrade is a deliberate act' : `WARN brew pin openbao failed: ${p.stderr.toString().trim()}`
|
|
196
|
+
},
|
|
197
|
+
startUnderPm: async () => {
|
|
198
|
+
if ((await switchProcess('vault', 'start', pmSwitchDeps(say), 90_000)) !== 0) return false
|
|
199
|
+
return (await waitHealth(vaultUrl(place), (h) => h?.code === 200, { ms: 30_000 }))?.code === 200
|
|
200
|
+
},
|
|
201
|
+
})
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
export class VaultKeyCommand extends Command {
|
|
206
|
+
static override paths = [['vault', 'key']]
|
|
207
|
+
|
|
208
|
+
static override usage = Command.Usage({
|
|
209
|
+
category: 'Secrets',
|
|
210
|
+
description: "the vault's seal key from the keychain to the owner's clipboard, cleared in 90 s",
|
|
211
|
+
details: "Run it in Terminal.app at the vault Mac's own desktop, never in an agent's session nor over ssh: it refuses there. The key is never printed: --copy is its one form.",
|
|
212
|
+
examples: [['copy the seal key for your password manager again', 'sk vault key --copy']],
|
|
213
|
+
})
|
|
214
|
+
|
|
215
|
+
copy = Option.Boolean('--copy', false, { description: 'put the seal key in the clipboard (the one form: the key is never printed)' })
|
|
216
|
+
|
|
217
|
+
async execute(): Promise<number> {
|
|
218
|
+
if (!this.copy) {
|
|
219
|
+
this.context.stderr.write('FAIL: the seal key is never printed: sk vault key --copy puts it in your clipboard\n')
|
|
220
|
+
return 1
|
|
221
|
+
}
|
|
222
|
+
if (!typedByOwner(this.context.stderr)) return 1
|
|
223
|
+
return await copySealKey({ seal: keychainSeal(vaultPlace()), clipboard: macClipboard, say: (l) => void this.context.stdout.write(`${l}\n`), machine: machineName() })
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
export class VaultNarrowCommand extends Command {
|
|
228
|
+
static override paths = [['vault', 'narrow']]
|
|
229
|
+
|
|
230
|
+
static override usage = Command.Usage({
|
|
231
|
+
category: 'Secrets',
|
|
232
|
+
description: 'bring a vault made before to the narrow minter: it writes no policy from then on',
|
|
233
|
+
details: "A vault initialised before shipkit narrowed its minter has one that writes any `node-*` policy, so it is the vault's admin in all but name. This uses it one last time: one step token of an hour writes the node policy, revokes the old node tokens, deletes the old node policies, narrows the minter, then the role; the minter then revokes the step tokens and deletes the step policy. Each step reads where the vault stands and says what it found, so a narrow stopped anywhere finishes when it is run again. Run on the vault's machine. On a vault already narrow it says so and changes nothing. It cannot be undone by the minter it narrowed: only a root token from the recovery key could widen it again.",
|
|
234
|
+
examples: [['narrow the minter of this machine\'s vault', 'sk vault narrow']],
|
|
235
|
+
})
|
|
236
|
+
|
|
237
|
+
async execute(): Promise<number> {
|
|
238
|
+
const place = vaultPlace()
|
|
239
|
+
const recorded = recordAuditPath(place)
|
|
240
|
+
this.context.stdout.write(recorded == null ? 'found: the marker records the audit file already, or there is no marker\n' : `ok: the marker records the audit file the vault uses: ${recorded}\n`)
|
|
241
|
+
const minter = minterOf(place)
|
|
242
|
+
if (minter == null) {
|
|
243
|
+
this.context.stderr.write('FAIL: this machine holds no minter token: its vault is not initialised here (sk vault status)\n')
|
|
244
|
+
return 1
|
|
245
|
+
}
|
|
246
|
+
try {
|
|
247
|
+
return await narrowVault(minter, (l) => void this.context.stdout.write(`${l}\n`))
|
|
248
|
+
} catch (e) {
|
|
249
|
+
this.context.stderr.write(`FAIL: the narrow stopped: ${(e as Error).message}. It is safe to run it again: each step reads where the vault stands and does only what is left (sk vault status first)\n`)
|
|
250
|
+
return 1
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
/** what the import and the compare stand on: the registry's rows, the names this Mac's keychain holds, each placed */
|
|
256
|
+
async function placedHere(): Promise<{ placed: Placed[]; minter: VaultApi; url: string } | { refused: string }> {
|
|
257
|
+
const root = houseRootOf(process.cwd())
|
|
258
|
+
if (root == null) return { refused: "run it from inside the house repo or a house repo: the registry is the house's" }
|
|
259
|
+
const minter = minterOf(vaultPlace())
|
|
260
|
+
if (minter == null) return { refused: 'this machine holds no minter token: its vault is not initialised here (sk vault status)' }
|
|
261
|
+
const w = await secretsWhere(process.cwd())
|
|
262
|
+
const rows = (w.house?.creds ?? []).map((c) => ({ name: c.name, for: c.for }))
|
|
263
|
+
const placed = await placeNames({ rows, held: keychainReader().names(), keyOf: keyOfFrom(await houseKeys(root)) })
|
|
264
|
+
return { placed, minter, url: vaultUrl(vaultPlace()) }
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
const FORM_TEXT: Record<Form, string> = { plain: 'plain', hex: 'decoded from hex', refused: 'refused' }
|
|
268
|
+
|
|
269
|
+
/** one line a name: what was done, how its value came out of the keychain and its length in bytes; never a value */
|
|
270
|
+
export function importLine(r: { name: string; did: string; form: Form; bytes: number; path?: string; why?: string }): string {
|
|
271
|
+
if (r.form === 'refused') return `${r.did.padEnd(7)} ${r.name} ${r.why ?? FORM_TEXT.refused}`
|
|
272
|
+
return `${r.did.padEnd(7)} ${r.name} ${FORM_TEXT[r.form]}, ${r.bytes} bytes${r.path != null ? ` → rv/data/${r.path}` : ''}${r.why != null ? ` (${r.why})` : ''}`
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
type DoneRow = { name: string; did: string; form: Form; bytes: number; path?: string; why?: string }
|
|
276
|
+
|
|
277
|
+
/** an outcome's colour on a terminal: green for done or equal, red for what is wrong, yellow for what was left, and
|
|
278
|
+
* how late it sorts: what needs a look comes last, beside the count */
|
|
279
|
+
const OUTCOME: Record<string, { code: string; rank: number }> = {
|
|
280
|
+
same: { code: '32', rank: 0 }, ok: { code: '32', rank: 0 }, would: { code: '36', rank: 1 },
|
|
281
|
+
refused: { code: '33', rank: 2 }, absent: { code: '33', rank: 3 }, differs: { code: '31', rank: 4 }, failed: { code: '31', rank: 5 },
|
|
282
|
+
}
|
|
283
|
+
const paint = (code: string, text: string, on: boolean): string => (on ? `\x1b[${code}m${text}\x1b[0m` : text)
|
|
284
|
+
|
|
285
|
+
/** the rows as a person reads them: the quiet ones first by name, then the ones to look at; the name and what was
|
|
286
|
+
* read each in its column, the place in the vault after. With `color`, the outcome in its colour, a quiet row dim */
|
|
287
|
+
export function importRows(rows: readonly DoneRow[], color: boolean): string[] {
|
|
288
|
+
const sorted = [...rows].sort((a, b) => (OUTCOME[a.did]?.rank ?? 1) - (OUTCOME[b.did]?.rank ?? 1) || (a.name < b.name ? -1 : a.name > b.name ? 1 : 0))
|
|
289
|
+
const what = (r: DoneRow): string => (r.form === 'refused' ? (r.why ?? FORM_TEXT.refused) : `${FORM_TEXT[r.form]}, ${r.bytes} bytes`)
|
|
290
|
+
const wide = (pick: (r: DoneRow) => string, of: readonly DoneRow[]): number => of.reduce((n, r) => Math.max(n, pick(r).length), 0)
|
|
291
|
+
const did = wide((r) => r.did, sorted)
|
|
292
|
+
const name = wide((r) => r.name, sorted)
|
|
293
|
+
const read = wide(what, sorted.filter((r) => r.path != null))
|
|
294
|
+
return sorted.map((r) => {
|
|
295
|
+
const o = OUTCOME[r.did] ?? { code: '0', rank: 1 }
|
|
296
|
+
const quiet = o.rank === 0
|
|
297
|
+
const tail = r.path != null ? ` → rv/data/${r.path}` : ''
|
|
298
|
+
const why = r.form !== 'refused' && r.why != null ? ` (${r.why})` : ''
|
|
299
|
+
const rest = `${r.name.padEnd(name)} ${r.path != null ? what(r).padEnd(read) : what(r)}`
|
|
300
|
+
return `${paint(o.code, r.did.padEnd(did), color)} ${quiet ? paint('2', `${rest}${tail}${why}`, color) : `${rest}${paint('2', tail, color && tail !== '')}${why}`}`
|
|
301
|
+
})
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
/** the counts of the last line, each in its outcome's colour when it is not zero; `words` where the count reads
|
|
305
|
+
* better than the outcome's own word */
|
|
306
|
+
export function outcomeWords(counts: readonly [outcome: string, n: number, words?: string][], color: boolean): string {
|
|
307
|
+
return counts.map(([o, n, words]) => paint(OUTCOME[o]?.code ?? '0', `${n} ${words ?? o}`, color && n > 0)).join(', ')
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
/** whether this run's output is read on a terminal that takes colour */
|
|
311
|
+
const colored = (out: { isTTY?: boolean }): boolean => out.isTTY === true && process.env['NO_COLOR'] == null
|
|
312
|
+
|
|
313
|
+
/** the last line: how many names of each class, and of each outcome */
|
|
314
|
+
export function importCounts(rows: { did: string; form: Form }[]): string {
|
|
315
|
+
const by = (k: 'did' | 'form', v: string): number => rows.filter((r) => r[k] === v).length
|
|
316
|
+
const dids = ['ok', 'would', 'same', 'differs', 'refused', 'failed'].filter((d) => by('did', d) > 0).map((d) => `${by('did', d)} ${d}`)
|
|
317
|
+
return `${rows.length} names: ${by('form', 'plain')} plain, ${by('form', 'hex')} decoded from hex, ${by('form', 'refused')} refused; ${dids.join(', ') || 'nothing done'}`
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
export class VaultImportCommand extends Command {
|
|
321
|
+
static override paths = [['vault', 'import']]
|
|
322
|
+
|
|
323
|
+
static override usage = Command.Usage({
|
|
324
|
+
category: 'Secrets',
|
|
325
|
+
description: "copy this Mac's keychain secrets into the vault, the keychain only read: --dry says, --go copies",
|
|
326
|
+
details: "Each name this Mac's keychain holds is filed by its registry row: all, a repo (its id mapped to its key by this Mac's checkouts), an identity, a machine. Each value is read exact (security -g, its hex form decoded) or refused with its reason, and the line says which and its length in bytes, never the value. A name with no row, a row of several scopes, or a repo id no checkout here answers to is not imported. --go writes each new name with check and set 0 and reads it back: a byte off stops the import, names the secret, and removes nothing. A name the vault holds is compared and never overwritten. The keychain is never written, changed or deleted. Run twice, it changes nothing. One import or compare at a time. Undo: a vault row goes with a root token from the recovery key (bao kv metadata delete rv/<path>).",
|
|
327
|
+
examples: [['read and say where each name would go', 'sk vault import --dry'], ['copy them', 'sk vault import --go']],
|
|
328
|
+
})
|
|
329
|
+
|
|
330
|
+
go = Option.Boolean('--go', false, { description: 'copy, instead of saying what it would do' })
|
|
331
|
+
dry = Option.Boolean('--dry', false, { description: "read every value and say where it goes (the default): nothing goes into the vault's data; it mints and revokes one node token and holds a lock file beside the vault for the run" })
|
|
332
|
+
|
|
333
|
+
async execute(): Promise<number> {
|
|
334
|
+
if (this.go && this.dry) return (this.context.stderr.write('FAIL: --go and --dry together: pick one\n'), 1)
|
|
335
|
+
const here = await placedHere()
|
|
336
|
+
if ('refused' in here) return (this.context.stderr.write(`FAIL: ${here.refused}\n`), 1)
|
|
337
|
+
const filed = here.placed.filter((p) => p.path != null)
|
|
338
|
+
try {
|
|
339
|
+
const rows = await withImportLock(vaultPlace().dir, () => withImportToken(here.minter, here.url, machineName().toLowerCase(), filed, (vault) => importNames({ placed: here.placed, keychain: keychainReader(), vault, go: this.go })))
|
|
340
|
+
this.context.stdout.write(`${importRows(rows, colored(this.context.stdout as { isTTY?: boolean })).join('\n')}\n`)
|
|
341
|
+
this.context.stdout.write(`${importCounts(rows)}${this.go ? '' : ': nothing written (--go copies)'}\n`)
|
|
342
|
+
return rows.some((r) => r.did === 'failed' || r.did === 'differs') ? 1 : 0
|
|
343
|
+
} catch (e) {
|
|
344
|
+
this.context.stderr.write(`FAIL: ${(e as Error).message}\n`)
|
|
345
|
+
return 1
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
export class VaultCompareCommand extends Command {
|
|
351
|
+
static override paths = [['vault', 'compare']]
|
|
352
|
+
|
|
353
|
+
static override usage = Command.Usage({
|
|
354
|
+
category: 'Secrets',
|
|
355
|
+
description: "this Mac's keychain against the vault, name by name: same, differs or absent",
|
|
356
|
+
details: 'Read only on both sides. No value, part of one or hash of one is printed or kept. The counts, the names that differ and the names the keychain holds are kept for the house check and the vault page (vault-compared.json beside the hq token): names only. It reads with a node token the minter makes for this one run and revokes after it.',
|
|
357
|
+
examples: [['compare', 'sk vault compare']],
|
|
358
|
+
})
|
|
359
|
+
|
|
360
|
+
async execute(): Promise<number> {
|
|
361
|
+
const here = await placedHere()
|
|
362
|
+
if ('refused' in here) return (this.context.stderr.write(`FAIL: ${here.refused}\n`), 1)
|
|
363
|
+
const filed = here.placed.filter((p) => p.path != null)
|
|
364
|
+
try {
|
|
365
|
+
const rows = await withImportLock(vaultPlace().dir, () => withImportToken(here.minter, here.url, machineName().toLowerCase(), filed, (vault) => compareNames({ placed: here.placed, keychain: keychainReader(), vault })))
|
|
366
|
+
const color = colored(this.context.stdout as { isTTY?: boolean })
|
|
367
|
+
this.context.stdout.write(`${importRows(rows, color).join('\n')}\n`)
|
|
368
|
+
const sum = summaryOf(rows, Date.now())
|
|
369
|
+
keepCompared({ ...sum, held: [...new Set(here.placed.map((p) => p.name))].sort() })
|
|
370
|
+
this.context.stdout.write(`${outcomeWords([['same', sum.same], ['differs', sum.differs, 'differ'], ['absent', sum.absent, 'absent from the vault'], ['refused', sum.refused, 'not read or not filed'], ['failed', sum.failed]], color)}\n`)
|
|
371
|
+
if (sum.differs > 0) this.context.stdout.write('a name that differs: a read takes the vault\'s copy, and this Mac\'s keychain holds another (sk vault status --secrets says when the vault\'s was written)\n')
|
|
372
|
+
return sum.differs + sum.failed > 0 ? 1 : 0
|
|
373
|
+
} catch (e) {
|
|
374
|
+
this.context.stderr.write(`FAIL: ${(e as Error).message}\n`)
|
|
375
|
+
return 1
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
export class VaultSnapshotCommand extends Command {
|
|
381
|
+
static override paths = [['vault', 'snapshot']]
|
|
382
|
+
|
|
383
|
+
static override usage = Command.Usage({
|
|
384
|
+
category: 'Secrets',
|
|
385
|
+
description: "a sealed snapshot of this machine's vault, proved by a restore, sent to its Space",
|
|
386
|
+
details: "The minter takes the snapshot into vault/snapshots/ at 0600, the three newest kept; the vault's folder is never a source of the machine backup. It is encrypted by the vault's keyring, which the seal key wraps: a vault with another key refuses it. --prove starts a scratch vault in a temp folder on free ports with this Mac's seal key, restores the snapshot, counts its names against the live vault's, then stops and removes it. --copy proves it first, then sends it to this machine's own Space under _snapshots/vault/<machine>/<stamp>.snap, private, never signed, never in the media index, and to the second place when there is one. --prove --from-space fetches the newest the Space holds into a temp folder at 0600, restores it in a scratch vault and counts its names against the live vault's. The daemon's vault job does --copy once a day and after a change (the switch vault-snapshots, on by default).",
|
|
387
|
+
examples: [['take one, prove it, send it', 'sk vault snapshot --copy'], ['prove what the Space holds', 'sk vault snapshot --prove --from-space']],
|
|
388
|
+
})
|
|
389
|
+
|
|
390
|
+
prove = Option.Boolean('--prove', false, { description: 'restore it into a scratch vault and count its names' })
|
|
391
|
+
copy = Option.Boolean('--copy', false, { description: "prove it, then send it to this machine's Space (and the second place)" })
|
|
392
|
+
fromSpace = Option.Boolean('--from-space', false, { description: 'with --prove: the newest snapshot the Space holds, fetched back' })
|
|
393
|
+
recovery = Option.Boolean('--recovery', false, { description: 'with --prove --from-space: you type the recovery key, and the proof gets in the dead disk way' })
|
|
394
|
+
prune = Option.String('--prune', { description: 'on|off: the daily tick deletes snapshots older than 30 days FOR GOOD (off by default)' })
|
|
395
|
+
|
|
396
|
+
async execute(): Promise<number> {
|
|
397
|
+
const say = (l: string): void => void this.context.stdout.write(`${l}\n`)
|
|
398
|
+
const fail = (l: string): number => (this.context.stderr.write(`FAIL: ${l}\n`), 1)
|
|
399
|
+
if (this.prune != null) {
|
|
400
|
+
if (this.prune !== 'on' && this.prune !== 'off') return fail('--prune takes on or off')
|
|
401
|
+
const { setVaultPruneOn } = await import('../hq/switch.ts')
|
|
402
|
+
setVaultPruneOn(this.prune === 'on')
|
|
403
|
+
say(this.prune === 'on' ? 'ok: the prune is ON: the daily tick deletes from the Space, for good, every version, a sealed snapshot older than 30 days that a newer one with as many names replaces; sk vault status shows what the next tick would delete' : 'ok: the prune is off: no vault snapshot leaves the Space')
|
|
404
|
+
return 0
|
|
405
|
+
}
|
|
406
|
+
const place = vaultPlace()
|
|
407
|
+
const minter = minterOf(place)
|
|
408
|
+
if (minter == null) return fail('this machine holds no minter token: its vault is not initialised here (sk vault status)')
|
|
409
|
+
const machine = machineName().toLowerCase()
|
|
410
|
+
const minterToken = readFileSync(minterTokenFile(place), 'utf8').trim()
|
|
411
|
+
const needKey = (): { key: string; bin: string } | string => {
|
|
412
|
+
const key = keychainSeal(place).read()
|
|
413
|
+
const bin = baoBin()
|
|
414
|
+
return key == null ? 'no seal key on this Mac to open a scratch vault with' : bin == null ? NO_BAO : { key, bin }
|
|
415
|
+
}
|
|
416
|
+
if (this.fromSpace) {
|
|
417
|
+
if (!this.prove) return fail('--from-space goes with --prove: it proves what the Space holds')
|
|
418
|
+
const k = needKey()
|
|
419
|
+
if (typeof k === 'string') return fail(k)
|
|
420
|
+
const { space, why } = await machineSpace()
|
|
421
|
+
if (space == null) return fail(`no Space: ${why}`)
|
|
422
|
+
let recoveryKey: string | undefined
|
|
423
|
+
if (this.recovery) {
|
|
424
|
+
if (!typedByOwner(this.context.stderr)) return 1
|
|
425
|
+
recoveryKey = (await hiddenLine('the recovery key (from your password manager, not shown): ')).trim()
|
|
426
|
+
if (recoveryKey === '') return fail('no recovery key typed')
|
|
427
|
+
}
|
|
428
|
+
const want = (await vaultStamp(minter)).names
|
|
429
|
+
const t0 = Date.now()
|
|
430
|
+
if (recoveryKey != null) say('the key is taken. The proof takes about 10 s:')
|
|
431
|
+
const r = await proveFromSpace({ space, machine, key: k.key, bin: k.bin, sent: machineGet<Sent>(SENT_KEY), ...(recoveryKey != null ? { recoveryKey } : {}), want, say }).catch((e: Error) => e)
|
|
432
|
+
if (r instanceof Error) return fail(`the restore from the Space: ${r.message}`)
|
|
433
|
+
machineSet(PROVED_KEY, { key: r.key, at: t0, names: r.names, ms: r.ms, ...(r.sha != null ? { sha: r.sha } : {}), deadDisk: r.names != null, away: true } satisfies ProvedRecord)
|
|
434
|
+
if (r.names != null) machineSet(DEAD_DISK_KEY, { key: r.key, at: t0, names: r.names, ms: r.ms, away: true } satisfies ProvedRecord)
|
|
435
|
+
const age = `${((t0 - r.at) / 3600_000).toFixed(1)} h old`
|
|
436
|
+
say(r.names != null
|
|
437
|
+
? `ok: ${r.key}, ${r.bytes} bytes, ${age}, the bytes this machine sent: restored as a new Mac would (a scratch place, bao kept out of every folder of this Mac's homes) with the seal key, a root token made from the recovery key, ${r.names} names as the live vault, in ${r.ms} ms. The dead disk way works; the scratch vault and the file are gone`
|
|
438
|
+
: `ok: ${r.key}, ${r.bytes} bytes, ${age}, the bytes this machine sent: restored as a new Mac would (a scratch place, bao kept out of every folder of this Mac's homes) with the seal key alone, its root generation asks for one recovery share, in ${r.ms} ms. Getting in needs the recovery key: --recovery proves it`)
|
|
439
|
+
return 0
|
|
440
|
+
}
|
|
441
|
+
const stamp = await vaultStamp(minter)
|
|
442
|
+
const taken = await takeSnapshot(minter, place).catch((e: Error) => e)
|
|
443
|
+
if (taken instanceof Error) return fail(`the vault gave no snapshot: ${taken.message}`)
|
|
444
|
+
say(`ok: ${taken.file}, ${taken.bytes} bytes, ${taken.names} names in the vault`)
|
|
445
|
+
if (this.prove || this.copy) {
|
|
446
|
+
const k = needKey()
|
|
447
|
+
if (typeof k === 'string') return fail(k)
|
|
448
|
+
say('… it is restored into a scratch vault to prove it, about 10 s')
|
|
449
|
+
const proved = await proveSnapshot({ snap: new Uint8Array(await Bun.file(taken.file).arrayBuffer()), key: k.key, bin: k.bin, minterToken, want: taken.names }).catch((e: Error) => e)
|
|
450
|
+
if (proved instanceof Error) return fail(`the restore proof: ${proved.message}${this.copy ? ': nothing was sent' : ''}`)
|
|
451
|
+
say(`ok: restored into a scratch vault with this Mac's seal key: ${proved.names} names, in ${proved.ms} ms; the scratch vault is gone`)
|
|
452
|
+
}
|
|
453
|
+
if (this.copy) {
|
|
454
|
+
const { space, why } = await machineSpace()
|
|
455
|
+
if (space == null) return fail(`no Space: ${why}; the snapshot stays here`)
|
|
456
|
+
const up = await sendSnapshot({ space, file: taken.file, machine, at: Date.now() }).catch((e: Error) => e)
|
|
457
|
+
if (up instanceof Error) return fail(`the send to the Space: ${up.message}`)
|
|
458
|
+
machineSet(SENT_KEY, { ...up, stamp: stamp.stamp, names: stamp.names } satisfies Sent)
|
|
459
|
+
machineSet(NAMES_KEY, { ...(machineGet<Record<string, number>>(NAMES_KEY) ?? {}), [up.key]: taken.names })
|
|
460
|
+
say(`ok: in the Space as ${up.key}, ${up.bytes} bytes, private`)
|
|
461
|
+
const ends = await houseCopy()
|
|
462
|
+
if ('why' in ends) say(`the second place: none (${ends.why})`)
|
|
463
|
+
else {
|
|
464
|
+
const sent = await snapshotFile({ to: ends.to, file: taken.file, label: 'vault' }).catch((e: Error) => e)
|
|
465
|
+
if (sent instanceof Error) return fail(`the copy to the second place: ${sent.message}`)
|
|
466
|
+
say(`ok: in the second place as ${sent.key}, ${sent.size} bytes`)
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
return 0
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
export class VaultRestoreCommand extends Command {
|
|
474
|
+
static override paths = [['vault', 'restore']]
|
|
475
|
+
|
|
476
|
+
static override usage = Command.Usage({
|
|
477
|
+
category: 'Secrets',
|
|
478
|
+
description: 'a vault made again from a sealed snapshot, on a machine whose vault is empty: the dead disk way',
|
|
479
|
+
details: "Typed by the owner in his own Terminal, never by an agent: the seal key and the recovery key are asked with no echo (both from his password manager), never in an argv, never printed. The snapshot is a file, or with --from-space the newest under _snapshots/vault/<machine>/ of this machine's Space (--machine names the dead one). It refuses a place that holds a vault. Everything happens in <vault>.restore beside the place: bao runs there for the restore alone, tethered to this command, with the unauthenticated root generation open; a root token is made from the recovery key, a new minter token is kept, the root token is revoked, the seal key goes into this Mac's keychain, the closed config is written, and the place takes the folder in one rename. A kill at any step leaves the place empty, and the next run cleans the folder and starts again. A snapshot taken before the audit device was relative names the old machine's audit file: the restore makes its folder for the run when it may, else prints the two sudo lines to type first. Then: sk gp start vault, sk pm restart daemon (it asks a new vault token), sk vault status.",
|
|
480
|
+
examples: [['from the Space, after a dead disk', 'sk vault restore --from-space --machine old-mac'], ['from a file', 'sk vault restore ./20261119T030000Z.snap']],
|
|
481
|
+
})
|
|
482
|
+
|
|
483
|
+
file = Option.String({ required: false })
|
|
484
|
+
fromSpace = Option.Boolean('--from-space', false, { description: "the newest snapshot of this machine's Space" })
|
|
485
|
+
machine = Option.String('--machine', { description: 'the machine whose snapshots to take (default: this one)' })
|
|
486
|
+
|
|
487
|
+
async execute(): Promise<number> {
|
|
488
|
+
const fail = (l: string): number => (this.context.stderr.write(`FAIL: ${l}\n`), 1)
|
|
489
|
+
if ((this.file == null) === !this.fromSpace) return fail('name a snapshot file, or --from-space')
|
|
490
|
+
if (!typedByOwner(this.context.stderr)) return 1
|
|
491
|
+
const place = vaultPlace()
|
|
492
|
+
const busy = await notEmpty(place)
|
|
493
|
+
if (busy != null) return fail(`${busy}: nothing was changed`)
|
|
494
|
+
const bin = baoBin()
|
|
495
|
+
if (bin == null) return fail(NO_BAO)
|
|
496
|
+
let snap: Uint8Array<ArrayBuffer>
|
|
497
|
+
if (this.file != null) snap = snapshotOf(this.file)
|
|
498
|
+
else {
|
|
499
|
+
const { space, why } = await machineSpace()
|
|
500
|
+
if (space == null) return fail(`no Space: ${why}`)
|
|
501
|
+
const from = (this.machine ?? machineName()).toLowerCase()
|
|
502
|
+
const newest = (await snapshotsInSpace(space, from))[0]
|
|
503
|
+
if (newest == null) return fail(`the Space holds no snapshot under ${spaceFolderOf(from)}`)
|
|
504
|
+
const dir = mkdtempSync(join(tmpdir(), 'vault-restore-'))
|
|
505
|
+
chmodSync(dir, 0o700)
|
|
506
|
+
try {
|
|
507
|
+
await space.get(newest.key, join(dir, 's.snap'))
|
|
508
|
+
snap = snapshotOf(join(dir, 's.snap'))
|
|
509
|
+
} finally {
|
|
510
|
+
rmSync(dir, { recursive: true, force: true })
|
|
511
|
+
}
|
|
512
|
+
this.context.stdout.write(`the snapshot: ${newest.key}, ${newest.bytes} bytes\n`)
|
|
513
|
+
}
|
|
514
|
+
const sealKey = (await hiddenLine('the seal key (not shown): ')).trim()
|
|
515
|
+
const recoveryKey = (await hiddenLine('the recovery key (not shown): ')).trim()
|
|
516
|
+
this.context.stdout.write('the keys are taken. The vault starts on the snapshot, and each step says ok as it ends:\n')
|
|
517
|
+
return restoreVault({ place, snap, sealKey, recoveryKey, seal: keychainSeal(place), bin, machine: machineName(), say: (l) => void this.context.stdout.write(`${l}\n`) })
|
|
518
|
+
}
|
|
519
|
+
}
|
|
520
|
+
|
|
521
|
+
export class VaultDestroyCommand extends Command {
|
|
522
|
+
static override paths = [['vault', 'destroy']]
|
|
523
|
+
|
|
524
|
+
static override usage = Command.Usage({
|
|
525
|
+
category: 'Secrets',
|
|
526
|
+
description: "one secret destroyed for good, every version: the owner's act, the recovery key typed",
|
|
527
|
+
details: "Typed by the owner in his own Terminal, never by an agent: it refuses when no terminal holds its stdin. A node token never destroys (its policy: nothing a node does is final), and no root token is kept, so this is the one way. It asks the recovery key with no echo, stops the served vault (reads fall back to the keychain for those seconds), runs bao on the vault's data from a config of its own with the root generation open, tethered to this command, makes a root token for this one act, deletes every version and the metadata of the name, revokes the root token, stops that bao, checks the port free, and starts the served vault again. Sealed snapshots made before still hold the value: it says how old the oldest in the Space is. A keychain copy is not touched: the secret manager's rm removes it.",
|
|
528
|
+
examples: [['a leaked token, gone for good', 'sk vault destroy rv/someservice/token']],
|
|
529
|
+
})
|
|
530
|
+
|
|
531
|
+
name = Option.String({ required: true })
|
|
532
|
+
|
|
533
|
+
async execute(): Promise<number> {
|
|
534
|
+
const say = (l: string): void => void this.context.stdout.write(`${l}\n`)
|
|
535
|
+
const fail = (l: string): number => (this.context.stderr.write(`FAIL: ${l}\n`), 1)
|
|
536
|
+
if (process.stdin.isTTY !== true) return fail('sk vault destroy is typed by the owner in his own Terminal: no terminal holds its stdin, nothing was done')
|
|
537
|
+
if (!typedByOwner(this.context.stderr)) return 1
|
|
538
|
+
const place = vaultPlace()
|
|
539
|
+
const marker = readMarker(place)
|
|
540
|
+
if (marker == null) return fail('the vault is not initialised on this machine')
|
|
541
|
+
const path = vaultPathFor(await secretsWhere(process.cwd()), this.name)
|
|
542
|
+
if (path == null) return fail(`${this.name} has no place in the vault: it needs a registry row of one scope, and for a repo row this command run inside that repo`)
|
|
543
|
+
const sealKey = keychainSeal(place).read()
|
|
544
|
+
if (sealKey == null) return fail('no seal key in this Mac\'s keychain')
|
|
545
|
+
const recoveryKey = (await hiddenLine('the recovery key (from your password manager, not shown): ')).trim()
|
|
546
|
+
if (recoveryKey === '') return fail('no recovery key typed: nothing was done')
|
|
547
|
+
say('the vault stops for this act: reads fall back to the keychain for these seconds')
|
|
548
|
+
if ((await switchProcess('vault', 'stop', pmSwitchDeps(say))) !== 0) return fail('the served vault did not stop: nothing was done')
|
|
549
|
+
let code: number
|
|
550
|
+
try {
|
|
551
|
+
code = await destroyInVault({ place, path, sealKey, recoveryKey, bin: marker.baoPath, say })
|
|
552
|
+
} finally {
|
|
553
|
+
if ((await switchProcess('vault', 'start', pmSwitchDeps(say))) !== 0) this.context.stderr.write('FAIL: the served vault did not start again: sk gp start vault\n')
|
|
554
|
+
}
|
|
555
|
+
if (code !== 0) return code
|
|
556
|
+
const { space } = await machineSpace()
|
|
557
|
+
const oldest = space == null ? null : (await snapshotsInSpace(space, machineName().toLowerCase()).catch(() => [])).at(-1) ?? null
|
|
558
|
+
say(oldest == null ? 'note: sealed snapshots made before this still hold the value; the Space was not read, so their age is not known' : `note: sealed snapshots made before this still hold the value: the oldest in the Space is ${((Date.now() - oldest.at) / 86_400_000).toFixed(1)} days old (${oldest.key}). A leaked value is revoked where it was issued`)
|
|
559
|
+
say(`next: the secret manager's rm of ${this.name} removes a keychain copy, if this Mac holds one`)
|
|
560
|
+
return 0
|
|
561
|
+
}
|
|
562
|
+
}
|
|
563
|
+
|
|
564
|
+
export class VaultRevokeRootsCommand extends Command {
|
|
565
|
+
static override paths = [['vault', 'revoke-roots']]
|
|
566
|
+
|
|
567
|
+
static override usage = Command.Usage({
|
|
568
|
+
category: 'Secrets',
|
|
569
|
+
description: 'revoke the root tokens no act holds any more (a killed destroy or restore): the minter does it',
|
|
570
|
+
details: 'A destroy or a restore killed after it made its root token leaves that token alive in the vault, held by nobody: sk vault status shows it in red. This revokes every root token by its accessor, through the minter token. It refuses while an act runs (its work folder holds a live bao), since that act holds its token then.',
|
|
571
|
+
examples: [['after a killed destroy', 'sk vault revoke-roots']],
|
|
572
|
+
})
|
|
573
|
+
|
|
574
|
+
async execute(): Promise<number> {
|
|
575
|
+
const place = vaultPlace()
|
|
576
|
+
const minter = minterOf(place)
|
|
577
|
+
if (minter == null) return (this.context.stderr.write('FAIL: this machine holds no minter token\n'), 1)
|
|
578
|
+
const r = await revokeStrayRoots(place, minter).catch((e: Error) => ({ refused: e.message }))
|
|
579
|
+
if ('refused' in r) return (this.context.stderr.write(`FAIL: ${r.refused}\n`), 1)
|
|
580
|
+
this.context.stdout.write(`ok: ${r.revoked} root token${r.revoked === 1 ? '' : 's'} revoked\n`)
|
|
581
|
+
return 0
|
|
582
|
+
}
|
|
583
|
+
}
|
package/src/cli/family-help.ts
CHANGED
|
@@ -58,12 +58,14 @@ export function familyList(rows: readonly CommandRow[], bin: string, pages: Read
|
|
|
58
58
|
const self = rows.findIndex((r) => r.path === prefix)
|
|
59
59
|
const families = new Set(rows.map((r) => r.category))
|
|
60
60
|
const page = families.size === 1 ? pages?.[[...families][0]!] : undefined
|
|
61
|
+
// a command of two paths comes twice from the parser: it is one command
|
|
62
|
+
const once = [...new Map(rows.map((r) => [r.path, r])).values()]
|
|
61
63
|
return {
|
|
62
64
|
code: 0,
|
|
63
65
|
lines: [
|
|
64
66
|
// no word in common (`asks` and `ask`): the first words stand in for it
|
|
65
|
-
`${bin} ${prefix === '' ? [...new Set(rows.map((r) => firstWord(r.path)))].join(', ') : prefix}: ${count(
|
|
66
|
-
...
|
|
67
|
+
`${bin} ${prefix === '' ? [...new Set(rows.map((r) => firstWord(r.path)))].join(', ') : prefix}: ${count(once.length)}`,
|
|
68
|
+
...once.map((r) => compactLine(r, bin)),
|
|
67
69
|
`${flagsLine(bin)}${self < 0 ? '' : `; the help of ${bin} ${prefix} alone: ${bin} ${prefix} -h=${self}`}`,
|
|
68
70
|
...(page == null ? [] : [`Read first: ${pageAt(page)}`]),
|
|
69
71
|
],
|
package/src/cli/family-pages.ts
CHANGED
|
@@ -16,7 +16,7 @@ export const FAMILY_PAGES: Readonly<Record<string, string>> = {
|
|
|
16
16
|
Messages: 'tools/shipkit/messages.md',
|
|
17
17
|
Record: 'tools/shipkit/recordings.md',
|
|
18
18
|
Refactor: 'patterns/typescript/index.md',
|
|
19
|
-
Review: 'tools/shipkit/
|
|
19
|
+
Review: 'tools/shipkit/threads.md',
|
|
20
20
|
Scaffold: 'patterns/pocketbase/index.md',
|
|
21
21
|
Secrets: 'services/secrets/index.md',
|
|
22
22
|
Serve: 'tools/shipkit/home.md',
|