hivedesk 0.2.0 → 1.0.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 +111 -62
- package/FIRST-RUN.md +14 -20
- package/PROTOCOL.md +26 -6
- package/README.md +303 -233
- package/assets/banner-1.0-pt.png +0 -0
- package/assets/banner-1.0-pt.svg +6 -0
- package/assets/banner-1.0.png +0 -0
- package/assets/banner-1.0.svg +6 -0
- package/assets/banner.png +0 -0
- package/assets/banner.svg +1 -513
- package/assets/crew/designer.svg +1 -42
- package/assets/crew/dev.svg +1 -43
- package/assets/crew/mel.svg +1 -44
- package/assets/crew/qa.svg +1 -43
- package/assets/crew/writer.svg +1 -40
- package/assets/icons/1.0/achievements.svg +1 -0
- package/assets/icons/1.0/api.svg +1 -0
- package/assets/icons/1.0/auto-update.svg +1 -0
- package/assets/icons/1.0/city.svg +1 -0
- package/assets/icons/1.0/cli.svg +1 -0
- package/assets/icons/1.0/clipboard.svg +1 -0
- package/assets/icons/1.0/contact-sheet.svg +1 -0
- package/assets/icons/1.0/cpu-share.svg +1 -0
- package/assets/icons/1.0/crew.svg +1 -0
- package/assets/icons/1.0/data.svg +1 -0
- package/assets/icons/1.0/desktop.svg +1 -0
- package/assets/icons/1.0/editor.svg +1 -0
- package/assets/icons/1.0/extension.svg +1 -0
- package/assets/icons/1.0/file-send.svg +1 -0
- package/assets/icons/1.0/game.svg +1 -0
- package/assets/icons/1.0/git.svg +1 -0
- package/assets/icons/1.0/github.svg +1 -0
- package/assets/icons/1.0/gpu-share.svg +1 -0
- package/assets/icons/1.0/installer.svg +1 -0
- package/assets/icons/1.0/languages.svg +1 -0
- package/assets/icons/1.0/linkedin.svg +1 -0
- package/assets/icons/1.0/machines.svg +1 -0
- package/assets/icons/1.0/mobile.svg +1 -0
- package/assets/icons/1.0/models.svg +1 -0
- package/assets/icons/1.0/p2p-invite.svg +1 -0
- package/assets/icons/1.0/phone-remote.svg +1 -0
- package/assets/icons/1.0/playbooks.svg +1 -0
- package/assets/icons/1.0/pooled-models.svg +1 -0
- package/assets/icons/1.0/privacy.svg +1 -0
- package/assets/icons/1.0/profile.svg +1 -0
- package/assets/icons/1.0/question-card.svg +1 -0
- package/assets/icons/1.0/remote-desktop.svg +1 -0
- package/assets/icons/1.0/rotation.svg +1 -0
- package/assets/icons/1.0/security-audit.svg +1 -0
- package/assets/icons/1.0/sprite.svg +85 -0
- package/assets/icons/1.0/terminal.svg +1 -0
- package/assets/icons/1.0/tiles/achievements.svg +1 -0
- package/assets/icons/1.0/tiles/api.svg +1 -0
- package/assets/icons/1.0/tiles/auto-update.svg +1 -0
- package/assets/icons/1.0/tiles/city.svg +1 -0
- package/assets/icons/1.0/tiles/cli.svg +1 -0
- package/assets/icons/1.0/tiles/clipboard.svg +1 -0
- package/assets/icons/1.0/tiles/cpu-share.svg +1 -0
- package/assets/icons/1.0/tiles/crew.svg +1 -0
- package/assets/icons/1.0/tiles/data.svg +1 -0
- package/assets/icons/1.0/tiles/desktop.svg +1 -0
- package/assets/icons/1.0/tiles/editor.svg +1 -0
- package/assets/icons/1.0/tiles/extension.svg +1 -0
- package/assets/icons/1.0/tiles/file-send.svg +1 -0
- package/assets/icons/1.0/tiles/game.svg +1 -0
- package/assets/icons/1.0/tiles/git.svg +1 -0
- package/assets/icons/1.0/tiles/github.svg +1 -0
- package/assets/icons/1.0/tiles/gpu-share.svg +1 -0
- package/assets/icons/1.0/tiles/installer.svg +1 -0
- package/assets/icons/1.0/tiles/languages.svg +1 -0
- package/assets/icons/1.0/tiles/machines.svg +1 -0
- package/assets/icons/1.0/tiles/mobile.svg +1 -0
- package/assets/icons/1.0/tiles/models.svg +1 -0
- package/assets/icons/1.0/tiles/p2p-invite.svg +1 -0
- package/assets/icons/1.0/tiles/phone-remote.svg +1 -0
- package/assets/icons/1.0/tiles/playbooks.svg +1 -0
- package/assets/icons/1.0/tiles/pooled-models.svg +1 -0
- package/assets/icons/1.0/tiles/privacy.svg +1 -0
- package/assets/icons/1.0/tiles/profile.svg +1 -0
- package/assets/icons/1.0/tiles/question-card.svg +1 -0
- package/assets/icons/1.0/tiles/remote-desktop.svg +1 -0
- package/assets/icons/1.0/tiles/rotation.svg +1 -0
- package/assets/icons/1.0/tiles/security-audit.svg +1 -0
- package/assets/icons/1.0/tiles/terminal.svg +1 -0
- package/assets/icons/1.0/tiles/voice.svg +1 -0
- package/assets/icons/1.0/tiles/web.svg +1 -0
- package/assets/icons/1.0/voice.svg +1 -0
- package/assets/icons/1.0/web.svg +1 -0
- package/assets/icons/approval.svg +1 -1
- package/assets/icons/arrow.svg +1 -1
- package/assets/icons/chat.svg +1 -1
- package/assets/icons/check.svg +1 -1
- package/assets/icons/clock.svg +1 -1
- package/assets/icons/code.svg +1 -1
- package/assets/icons/compass.svg +1 -1
- package/assets/icons/contact-sheet.svg +1 -1
- package/assets/icons/copy.svg +1 -1
- package/assets/icons/cpu.svg +1 -1
- package/assets/icons/design.svg +1 -1
- package/assets/icons/download.svg +1 -1
- package/assets/icons/folder.svg +1 -1
- package/assets/icons/github-honey.svg +1 -1
- package/assets/icons/github.svg +1 -1
- package/assets/icons/globe.svg +1 -1
- package/assets/icons/gpu.svg +1 -1
- package/assets/icons/hire.svg +1 -1
- package/assets/icons/hive.svg +1 -1
- package/assets/icons/honey/approval.svg +1 -0
- package/assets/icons/honey/chat.svg +1 -0
- package/assets/icons/honey/code.svg +1 -0
- package/assets/icons/honey/design.svg +1 -0
- package/assets/icons/honey/github.svg +1 -0
- package/assets/icons/honey/globe.svg +1 -0
- package/assets/icons/honey/gpu.svg +1 -0
- package/assets/icons/honey/hire.svg +1 -0
- package/assets/icons/honey/hive.svg +1 -0
- package/assets/icons/honey/key.svg +1 -0
- package/assets/icons/honey/lend.svg +1 -0
- package/assets/icons/honey/lock.svg +1 -0
- package/assets/icons/honey/model.svg +1 -0
- package/assets/icons/honey/office.svg +1 -0
- package/assets/icons/honey/plan.svg +1 -0
- package/assets/icons/honey/playbook.svg +1 -0
- package/assets/icons/honey/qa.svg +1 -0
- package/assets/icons/honey/replay.svg +1 -0
- package/assets/icons/honey/sparkle.svg +1 -0
- package/assets/icons/honey/wand.svg +1 -0
- package/assets/icons/key.svg +1 -1
- package/assets/icons/lend.svg +1 -1
- package/assets/icons/linkedin-honey.svg +1 -1
- package/assets/icons/linkedin.svg +1 -1
- package/assets/icons/linux.svg +1 -1
- package/assets/icons/lock.svg +1 -1
- package/assets/icons/macos.svg +1 -1
- package/assets/icons/model.svg +1 -1
- package/assets/icons/npm.svg +1 -1
- package/assets/icons/office.svg +1 -1
- package/assets/icons/offline.svg +1 -1
- package/assets/icons/plan.svg +1 -1
- package/assets/icons/playbook.svg +1 -1
- package/assets/icons/preview.svg +1 -1
- package/assets/icons/qa.svg +1 -1
- package/assets/icons/queue.svg +1 -1
- package/assets/icons/replay.svg +1 -1
- package/assets/icons/search.svg +1 -0
- package/assets/icons/sparkle.svg +1 -1
- package/assets/icons/sprite.svg +12 -11
- package/assets/icons/star.svg +1 -1
- package/assets/icons/stop.svg +1 -1
- package/assets/icons/tag.svg +1 -1
- package/assets/icons/terminal.svg +1 -1
- package/assets/icons/wand.svg +1 -1
- package/assets/icons/windows.svg +1 -1
- package/assets/icons/words.svg +1 -1
- package/assets/icons/writer.svg +1 -1
- package/assets/icons/x.svg +1 -1
- package/assets/illustrations/1.0/hero-plain.svg +6 -0
- package/assets/illustrations/1.0/hero-pt.svg +6 -0
- package/assets/illustrations/1.0/hero.svg +6 -0
- package/assets/illustrations/1.0/how-it-works-pt.svg +6 -0
- package/assets/illustrations/1.0/how-it-works.svg +6 -0
- package/assets/illustrations/1.0/installers-pt.svg +6 -0
- package/assets/illustrations/1.0/installers.svg +6 -0
- package/assets/illustrations/1.0/p2p-gpu-pt.svg +6 -0
- package/assets/illustrations/1.0/p2p-gpu.svg +6 -0
- package/assets/illustrations/1.0/phone-remote.svg +6 -0
- package/assets/illustrations/1.0/remote-desktop-pt.svg +6 -0
- package/assets/illustrations/1.0/remote-desktop.svg +6 -0
- package/assets/illustrations/1.0/security.svg +6 -0
- package/assets/illustrations/1.0/voice-orb.svg +6 -0
- package/assets/illustrations/bee.svg +1 -27
- package/assets/illustrations/city-p2p-pt.svg +113 -0
- package/assets/illustrations/city-p2p.svg +113 -0
- package/assets/illustrations/crew.svg +1 -248
- package/assets/illustrations/first-run.svg +1 -48
- package/assets/illustrations/hardware.svg +1 -39
- package/assets/illustrations/hive-city.svg +1 -113
- package/assets/illustrations/lend.svg +1 -67
- package/assets/illustrations/privacy.svg +1 -39
- package/assets/illustrations/steps-pt.svg +1 -0
- package/assets/illustrations/steps.svg +1 -0
- package/assets/logo.svg +1 -13
- package/assets/mascot-dark.svg +1 -197
- package/assets/mascot.png +0 -0
- package/assets/mascot.svg +1 -194
- package/assets/mel-wave.svg +1 -205
- package/assets/og.svg +5 -254
- package/assets/screenshots/1.0/chat.webp +0 -0
- package/assets/screenshots/1.0/city-mobile.webp +0 -0
- package/assets/screenshots/1.0/city-room.webp +0 -0
- package/assets/screenshots/1.0/city.webp +0 -0
- package/assets/screenshots/1.0/editor.webp +0 -0
- package/assets/screenshots/1.0/machines.webp +0 -0
- package/assets/screenshots/1.0/office-mobile.webp +0 -0
- package/assets/screenshots/1.0/office.webp +0 -0
- package/assets/screenshots/1.0/profile.webp +0 -0
- package/assets/screenshots/1.0/remote.webp +0 -0
- package/assets/social-preview.png +0 -0
- package/assets/social-preview.svg +5 -254
- package/desktop/README.md +85 -10
- package/desktop/RELEASE.md +93 -0
- package/desktop/app/resources/icons/trayIconRemote.png +0 -0
- package/desktop/app/resources/icons/trayIconRemote@2x.png +0 -0
- package/desktop/controller.js +120 -5
- package/desktop/helpers/win-input.ps1 +426 -0
- package/desktop/i18n.json +480 -10
- package/desktop/icons/tray-remote.svg +5 -0
- package/desktop/installer/linux/hivedesk-linux-install.sh +124 -0
- package/desktop/installer/macos/Read me first.txt +36 -0
- package/desktop/installer/macos/background.html +43 -0
- package/desktop/installer/macos/background.png +0 -0
- package/desktop/installer/macos/background@2x.png +0 -0
- package/desktop/installer/macos/make-dmg.sh +59 -0
- package/desktop/installer/windows/Art.xaml +158 -0
- package/desktop/installer/windows/Core.cs +1019 -0
- package/desktop/installer/windows/Setup.cs +504 -0
- package/desktop/installer/windows/Theme.xaml +268 -0
- package/desktop/installer/windows/Ui.cs +1069 -0
- package/desktop/installer/windows/app.manifest +23 -0
- package/desktop/installer/windows/strings.json +1012 -0
- package/desktop/launcher/linux/hivedesk +5 -0
- package/desktop/launcher/windows/Launcher.cs +10 -0
- package/desktop/native.js +49 -0
- package/desktop/profile/avatars.json +147 -0
- package/desktop/profile/index.js +53 -0
- package/desktop/release-notes/1.0.0.json +12 -0
- package/desktop/scripts/build-setup.mjs +86 -0
- package/desktop/scripts/dmg-art.mjs +27 -0
- package/desktop/scripts/manifest.mjs +57 -0
- package/desktop/scripts/package.mjs +8 -2
- package/desktop/scripts/shell-screens.mjs +60 -0
- package/desktop/scripts/sign-release.mjs +79 -0
- package/desktop/scripts/update-keygen.mjs +48 -0
- package/desktop/shell.html +295 -1
- package/desktop/state.js +4 -2
- package/desktop/update/apply.js +268 -0
- package/desktop/update/download.js +114 -0
- package/desktop/update/guard.js +89 -0
- package/desktop/update/layout.js +52 -0
- package/desktop/update/manifest.js +120 -0
- package/desktop/update/pubkey.js +3 -0
- package/desktop/update/service.js +310 -0
- package/desktop/update/tar.js +65 -0
- package/desktop/update/version.js +43 -0
- package/desktop/zip.js +75 -1
- package/i18n/README.pt-BR.md +304 -208
- package/i18n/de.json +1553 -1
- package/i18n/en.json +1553 -1
- package/i18n/es.json +1553 -1
- package/i18n/fr.json +1553 -1
- package/i18n/it.json +1553 -1
- package/i18n/ja.json +1553 -1
- package/i18n/ko.json +1553 -1
- package/i18n/parts/city.de.json +312 -0
- package/i18n/parts/city.en.json +312 -0
- package/i18n/parts/city.es.json +312 -0
- package/i18n/parts/city.fr.json +312 -0
- package/i18n/parts/city.it.json +312 -0
- package/i18n/parts/city.ja.json +312 -0
- package/i18n/parts/city.ko.json +312 -0
- package/i18n/parts/city.pt-BR.json +312 -0
- package/i18n/parts/city.ru.json +312 -0
- package/i18n/parts/city.zh-CN.json +312 -0
- package/i18n/parts/design.de.json +132 -0
- package/i18n/parts/design.en.json +132 -0
- package/i18n/parts/design.es.json +132 -0
- package/i18n/parts/design.fr.json +132 -0
- package/i18n/parts/design.it.json +132 -0
- package/i18n/parts/design.ja.json +132 -0
- package/i18n/parts/design.ko.json +132 -0
- package/i18n/parts/design.pt-BR.json +132 -0
- package/i18n/parts/design.ru.json +132 -0
- package/i18n/parts/design.zh-CN.json +132 -0
- package/i18n/parts/domains.de.json +263 -0
- package/i18n/parts/domains.en.json +263 -0
- package/i18n/parts/domains.es.json +263 -0
- package/i18n/parts/domains.fr.json +263 -0
- package/i18n/parts/domains.it.json +263 -0
- package/i18n/parts/domains.ja.json +263 -0
- package/i18n/parts/domains.ko.json +263 -0
- package/i18n/parts/domains.pt-BR.json +263 -0
- package/i18n/parts/domains.ru.json +263 -0
- package/i18n/parts/domains.zh-CN.json +263 -0
- package/i18n/parts/s1-core.de.json +33 -0
- package/i18n/parts/s1-core.en.json +33 -0
- package/i18n/parts/s1-core.es.json +33 -0
- package/i18n/parts/s1-core.fr.json +33 -0
- package/i18n/parts/s1-core.it.json +33 -0
- package/i18n/parts/s1-core.ja.json +33 -0
- package/i18n/parts/s1-core.ko.json +33 -0
- package/i18n/parts/s1-core.pt-BR.json +33 -0
- package/i18n/parts/s1-core.ru.json +33 -0
- package/i18n/parts/s1-core.zh-CN.json +33 -0
- package/i18n/parts/s2-p2p.de.json +58 -0
- package/i18n/parts/s2-p2p.en.json +58 -0
- package/i18n/parts/s2-p2p.es.json +58 -0
- package/i18n/parts/s2-p2p.fr.json +58 -0
- package/i18n/parts/s2-p2p.it.json +58 -0
- package/i18n/parts/s2-p2p.ja.json +58 -0
- package/i18n/parts/s2-p2p.ko.json +58 -0
- package/i18n/parts/s2-p2p.pt-BR.json +58 -0
- package/i18n/parts/s2-p2p.ru.json +58 -0
- package/i18n/parts/s2-p2p.zh-CN.json +58 -0
- package/i18n/parts/s3-compute.de.json +63 -0
- package/i18n/parts/s3-compute.en.json +63 -0
- package/i18n/parts/s3-compute.es.json +63 -0
- package/i18n/parts/s3-compute.fr.json +63 -0
- package/i18n/parts/s3-compute.it.json +63 -0
- package/i18n/parts/s3-compute.ja.json +63 -0
- package/i18n/parts/s3-compute.ko.json +63 -0
- package/i18n/parts/s3-compute.pt-BR.json +63 -0
- package/i18n/parts/s3-compute.ru.json +63 -0
- package/i18n/parts/s3-compute.zh-CN.json +63 -0
- package/i18n/parts/s6-remote.de.json +169 -0
- package/i18n/parts/s6-remote.en.json +169 -0
- package/i18n/parts/s6-remote.es.json +169 -0
- package/i18n/parts/s6-remote.fr.json +169 -0
- package/i18n/parts/s6-remote.it.json +169 -0
- package/i18n/parts/s6-remote.ja.json +169 -0
- package/i18n/parts/s6-remote.ko.json +169 -0
- package/i18n/parts/s6-remote.pt-BR.json +169 -0
- package/i18n/parts/s6-remote.ru.json +169 -0
- package/i18n/parts/s6-remote.zh-CN.json +169 -0
- package/i18n/parts/s7-phone.de.json +41 -0
- package/i18n/parts/s7-phone.en.json +41 -0
- package/i18n/parts/s7-phone.es.json +41 -0
- package/i18n/parts/s7-phone.fr.json +41 -0
- package/i18n/parts/s7-phone.it.json +41 -0
- package/i18n/parts/s7-phone.ja.json +41 -0
- package/i18n/parts/s7-phone.ko.json +41 -0
- package/i18n/parts/s7-phone.pt-BR.json +41 -0
- package/i18n/parts/s7-phone.ru.json +41 -0
- package/i18n/parts/s7-phone.zh-CN.json +41 -0
- package/i18n/parts/voice.de.json +135 -0
- package/i18n/parts/voice.en.json +135 -0
- package/i18n/parts/voice.es.json +135 -0
- package/i18n/parts/voice.fr.json +135 -0
- package/i18n/parts/voice.it.json +135 -0
- package/i18n/parts/voice.ja.json +135 -0
- package/i18n/parts/voice.ko.json +135 -0
- package/i18n/parts/voice.pt-BR.json +135 -0
- package/i18n/parts/voice.ru.json +135 -0
- package/i18n/parts/voice.zh-CN.json +135 -0
- package/i18n/parts/workbench.de.json +331 -0
- package/i18n/parts/workbench.en.json +331 -0
- package/i18n/parts/workbench.es.json +331 -0
- package/i18n/parts/workbench.fr.json +331 -0
- package/i18n/parts/workbench.it.json +331 -0
- package/i18n/parts/workbench.ja.json +331 -0
- package/i18n/parts/workbench.ko.json +331 -0
- package/i18n/parts/workbench.pt-BR.json +331 -0
- package/i18n/parts/workbench.ru.json +331 -0
- package/i18n/parts/workbench.zh-CN.json +331 -0
- package/i18n/pt-BR.json +1553 -1
- package/i18n/ru.json +1553 -1
- package/i18n/zh-CN.json +1553 -1
- package/package.json +10 -2
- package/src/brain/catalog/catalog.json +15790 -0
- package/src/brain/catalog/commands.js +105 -0
- package/src/brain/catalog/consent.js +90 -0
- package/src/brain/catalog/estimate.js +90 -0
- package/src/brain/catalog/families.js +196 -0
- package/src/brain/catalog/index.js +127 -0
- package/src/brain/catalog/measured.js +27 -0
- package/src/brain/catalog/pool.js +137 -0
- package/src/brain/catalog/recommend.js +226 -0
- package/src/brain/catalog/refresh.mjs +166 -0
- package/src/brain/catalog/router.js +193 -0
- package/src/brain/hardware.js +144 -13
- package/src/brain/keys.js +3 -1
- package/src/brain/local.js +24 -2
- package/src/brain/manager.js +359 -61
- package/src/brain/models.js +71 -25
- package/src/brain/pool/index.js +208 -0
- package/src/brain/pool/lender.js +247 -0
- package/src/brain/pool/llama-release.json +86 -0
- package/src/brain/pool/p2p.js +264 -0
- package/src/brain/pool/refresh-release.mjs +53 -0
- package/src/brain/pool/release.js +94 -0
- package/src/brain/pool/session.js +76 -0
- package/src/brain/pool/tunnel.js +161 -0
- package/src/brain/rotation.js +289 -0
- package/src/brain/runtime.js +3 -1
- package/src/bus.js +10 -121
- package/src/changelog/index.js +9 -1
- package/src/city/demo.js +5 -3
- package/src/city/index.js +286 -46
- package/src/city/membership.js +347 -0
- package/src/city/state.js +156 -8
- package/src/cli.js +173 -34
- package/src/collab/index.js +10 -6
- package/src/collab/policy.js +48 -0
- package/src/compute/estimate.js +135 -0
- package/src/compute/index.js +295 -0
- package/src/compute/jobs-log.js +37 -0
- package/src/compute/probe.js +335 -0
- package/src/compute/requester.js +518 -0
- package/src/compute/scheduler.js +264 -0
- package/src/compute/share-cli.js +122 -0
- package/src/compute/share.js +178 -0
- package/src/compute/task-bridge.js +64 -0
- package/src/compute/types.js +114 -0
- package/src/compute/win-gpu.js +248 -0
- package/src/compute/wire.js +234 -0
- package/src/compute/worker.js +367 -0
- package/src/core/bus.js +254 -0
- package/src/core/city-report.js +52 -0
- package/src/core/deadline.js +78 -0
- package/src/core/demo.js +49 -0
- package/src/core/doctor-checks.js +61 -0
- package/src/core/events.js +116 -0
- package/src/core/log.js +147 -0
- package/src/core/migrate.js +145 -0
- package/src/core/origin.js +62 -0
- package/src/core/router.js +196 -0
- package/src/core/schema.js +73 -0
- package/src/core/shell.js +160 -0
- package/src/core/snapshots.js +58 -0
- package/src/core/store.js +130 -0
- package/src/crew/brief.js +2 -0
- package/src/crew/domains/attach.js +32 -0
- package/src/crew/domains/classify.js +176 -0
- package/src/crew/domains/flow.js +269 -0
- package/src/crew/domains/index.js +116 -0
- package/src/crew/domains/questions.js +551 -0
- package/src/crew/domains/security/advisories.json +35 -0
- package/src/crew/domains/security/fixes.js +98 -0
- package/src/crew/domains/security/scan.js +274 -0
- package/src/crew/domains/skeletons.js +77 -0
- package/src/crew/domains/templates/backend/README.md +27 -0
- package/src/crew/domains/templates/backend/package.json +12 -0
- package/src/crew/domains/templates/backend/src/app.js +70 -0
- package/src/crew/domains/templates/backend/src/server.js +61 -0
- package/src/crew/domains/templates/backend/test/api.test.js +47 -0
- package/src/crew/domains/templates/cli/README.md +18 -0
- package/src/crew/domains/templates/cli/bin/cli.js +48 -0
- package/src/crew/domains/templates/cli/package.json +12 -0
- package/src/crew/domains/templates/cli/src/lib.js +20 -0
- package/src/crew/domains/templates/cli/test/cli.test.js +43 -0
- package/src/crew/domains/templates/data/README.md +17 -0
- package/src/crew/domains/templates/data/bin/run.js +34 -0
- package/src/crew/domains/templates/data/data/sample.csv +7 -0
- package/src/crew/domains/templates/data/package.json +11 -0
- package/src/crew/domains/templates/data/src/csv.js +48 -0
- package/src/crew/domains/templates/data/src/report.js +39 -0
- package/src/crew/domains/templates/data/test/report.test.js +40 -0
- package/src/crew/domains/templates/desktop/README.md +17 -0
- package/src/crew/domains/templates/desktop/neutralino.config.json +34 -0
- package/src/crew/domains/templates/desktop/package.json +13 -0
- package/src/crew/domains/templates/desktop/resources/index.html +24 -0
- package/src/crew/domains/templates/desktop/resources/js/main.js +57 -0
- package/src/crew/domains/templates/desktop/resources/js/notes.js +25 -0
- package/src/crew/domains/templates/desktop/resources/styles.css +12 -0
- package/src/crew/domains/templates/desktop/test/notes.test.js +20 -0
- package/src/crew/domains/templates/extension/README.md +16 -0
- package/src/crew/domains/templates/extension/background.js +18 -0
- package/src/crew/domains/templates/extension/manifest.json +13 -0
- package/src/crew/domains/templates/extension/package.json +10 -0
- package/src/crew/domains/templates/extension/popup.css +11 -0
- package/src/crew/domains/templates/extension/popup.html +19 -0
- package/src/crew/domains/templates/extension/popup.js +34 -0
- package/src/crew/domains/templates/extension/src/notes.js +20 -0
- package/src/crew/domains/templates/extension/test/notes.test.js +25 -0
- package/src/crew/domains/templates/game/README.md +13 -0
- package/src/crew/domains/templates/game/index.html +18 -0
- package/src/crew/domains/templates/game/package.json +10 -0
- package/src/crew/domains/templates/game/src/game.js +58 -0
- package/src/crew/domains/templates/game/src/main.js +76 -0
- package/src/crew/domains/templates/game/style.css +9 -0
- package/src/crew/domains/templates/game/test/game.test.js +45 -0
- package/src/crew/domains/templates/mobile/README.md +25 -0
- package/src/crew/domains/templates/mobile/capacitor.config.json +8 -0
- package/src/crew/domains/templates/mobile/package.json +14 -0
- package/src/crew/domains/templates/mobile/test/store.test.js +27 -0
- package/src/crew/domains/templates/mobile/www/app.js +42 -0
- package/src/crew/domains/templates/mobile/www/icon.svg +1 -0
- package/src/crew/domains/templates/mobile/www/index.html +30 -0
- package/src/crew/domains/templates/mobile/www/manifest.webmanifest +12 -0
- package/src/crew/domains/templates/mobile/www/store.js +35 -0
- package/src/crew/domains/templates/mobile/www/style.css +42 -0
- package/src/crew/domains/templates/mobile/www/sw.js +16 -0
- package/src/crew/domains/text.js +34 -0
- package/src/crew/engine.js +283 -38
- package/src/crew/library/checks.js +574 -0
- package/src/crew/library/entries/app-types/appointment-booking.json +53 -0
- package/src/crew/library/entries/app-types/brick-breaker-game.json +50 -0
- package/src/crew/library/entries/app-types/budget-tracker-app.json +55 -0
- package/src/crew/library/entries/app-types/calculator-app.json +48 -0
- package/src/crew/library/entries/app-types/chat-ui-local.json +53 -0
- package/src/crew/library/entries/app-types/color-sequence-game.json +50 -0
- package/src/crew/library/entries/app-types/contact-book.json +52 -0
- package/src/crew/library/entries/app-types/countdown-to-date.json +53 -0
- package/src/crew/library/entries/app-types/crud-records-manager.json +56 -0
- package/src/crew/library/entries/app-types/currency-converter.json +50 -0
- package/src/crew/library/entries/app-types/dashboard-from-json.json +53 -0
- package/src/crew/library/entries/app-types/dice-roller.json +51 -0
- package/src/crew/library/entries/app-types/drawing-canvas.json +52 -0
- package/src/crew/library/entries/app-types/expense-splitter.json +54 -0
- package/src/crew/library/entries/app-types/flashcards-spaced-repetition.json +55 -0
- package/src/crew/library/entries/app-types/four-in-a-row-game.json +50 -0
- package/src/crew/library/entries/app-types/guess-the-number.json +50 -0
- package/src/crew/library/entries/app-types/habit-tracker.json +52 -0
- package/src/crew/library/entries/app-types/hangman-game.json +50 -0
- package/src/crew/library/entries/app-types/image-filters-canvas.json +49 -0
- package/src/crew/library/entries/app-types/inventory-tracker.json +53 -0
- package/src/crew/library/entries/app-types/kanban-board-app.json +53 -0
- package/src/crew/library/entries/app-types/loan-calculator.json +52 -0
- package/src/crew/library/entries/app-types/markdown-editor-preview.json +47 -0
- package/src/crew/library/entries/app-types/markdown-notes-app.json +53 -0
- package/src/crew/library/entries/app-types/maze-game.json +48 -0
- package/src/crew/library/entries/app-types/memory-card-game.json +52 -0
- package/src/crew/library/entries/app-types/metronome-web-audio.json +51 -0
- package/src/crew/library/entries/app-types/mines-grid-game.json +49 -0
- package/src/crew/library/entries/app-types/month-calendar.json +53 -0
- package/src/crew/library/entries/app-types/music-playlist-player.json +51 -0
- package/src/crew/library/entries/app-types/name-picker-wheel.json +52 -0
- package/src/crew/library/entries/app-types/password-generator.json +48 -0
- package/src/crew/library/entries/app-types/poll-voting.json +50 -0
- package/src/crew/library/entries/app-types/pomodoro-timer.json +54 -0
- package/src/crew/library/entries/app-types/quiz-app.json +53 -0
- package/src/crew/library/entries/app-types/reading-list.json +52 -0
- package/src/crew/library/entries/app-types/recipe-box.json +52 -0
- package/src/crew/library/entries/app-types/rock-paper-scissors.json +50 -0
- package/src/crew/library/entries/app-types/shopping-list.json +50 -0
- package/src/crew/library/entries/app-types/sliding-tiles-merge-game.json +51 -0
- package/src/crew/library/entries/app-types/snake-game.json +50 -0
- package/src/crew/library/entries/app-types/stopwatch-laps.json +50 -0
- package/src/crew/library/entries/app-types/sudoku-game.json +48 -0
- package/src/crew/library/entries/app-types/table-tennis-game.json +47 -0
- package/src/crew/library/entries/app-types/tap-to-fly-game.json +51 -0
- package/src/crew/library/entries/app-types/tic-tac-toe-game.json +49 -0
- package/src/crew/library/entries/app-types/time-tracker.json +51 -0
- package/src/crew/library/entries/app-types/tip-calculator.json +52 -0
- package/src/crew/library/entries/app-types/todo-list-app.json +52 -0
- package/src/crew/library/entries/app-types/typing-speed-test.json +51 -0
- package/src/crew/library/entries/app-types/unit-converter.json +52 -0
- package/src/crew/library/entries/app-types/weather-card-json.json +50 -0
- package/src/crew/library/entries/app-types/whack-a-mole-game.json +52 -0
- package/src/crew/library/entries/app-types/word-guess-game.json +51 -0
- package/src/crew/library/entries/backend/api-docs-markdown-contract.json +41 -0
- package/src/crew/library/entries/backend/api-etag-conditional-requests.json +41 -0
- package/src/crew/library/entries/backend/api-key-quotas-sliding-window.json +41 -0
- package/src/crew/library/entries/backend/api-resource-modeling.json +41 -0
- package/src/crew/library/entries/backend/api-tests-random-port.json +42 -0
- package/src/crew/library/entries/backend/api-versioning-policy.json +41 -0
- package/src/crew/library/entries/backend/config-environments-secret-files.json +41 -0
- package/src/crew/library/entries/backend/cors-policy-decisions.json +40 -0
- package/src/crew/library/entries/backend/health-readiness-endpoints.json +43 -0
- package/src/crew/library/entries/backend/http-error-class-handler.json +42 -0
- package/src/crew/library/entries/backend/in-process-job-queue.json +42 -0
- package/src/crew/library/entries/backend/json-body-reader-limits.json +41 -0
- package/src/crew/library/entries/backend/jwt-token-pitfalls.json +43 -0
- package/src/crew/library/entries/backend/keyset-pagination-filters.json +41 -0
- package/src/crew/library/entries/backend/legacy-password-hash-migration.json +42 -0
- package/src/crew/library/entries/backend/node-http-router-module.json +42 -0
- package/src/crew/library/entries/backend/request-id-async-context.json +40 -0
- package/src/crew/library/entries/backend/role-permission-checks.json +42 -0
- package/src/crew/library/entries/backend/route-input-schemas.json +40 -0
- package/src/crew/library/entries/backend/server-session-store.json +42 -0
- package/src/crew/library/entries/backend/shutdown-order-and-test.json +42 -0
- package/src/crew/library/entries/backend/sql-file-migrations.json +41 -0
- package/src/crew/library/entries/backend/sql-params-transactions.json +41 -0
- package/src/crew/library/entries/backend/upload-stream-to-disk.json +42 -0
- package/src/crew/library/entries/backend/webhook-receiver-hmac.json +42 -0
- package/src/crew/library/entries/data/accessible-chart-fallback.json +39 -0
- package/src/crew/library/entries/data/app-data-model-design.json +38 -0
- package/src/crew/library/entries/data/backup-restore-json.json +37 -0
- package/src/crew/library/entries/data/calendar-heatmap.json +41 -0
- package/src/crew/library/entries/data/csv-export-download.json +38 -0
- package/src/crew/library/entries/data/csv-parse-quoted.json +37 -0
- package/src/crew/library/entries/data/data-cleaning-normalize.json +37 -0
- package/src/crew/library/entries/data/dates-timezones-intl.json +37 -0
- package/src/crew/library/entries/data/dedupe-records.json +36 -0
- package/src/crew/library/entries/data/file-import-json-csv.json +42 -0
- package/src/crew/library/entries/data/form-validation-client.json +39 -0
- package/src/crew/library/entries/data/fuzzy-search-ranking.json +38 -0
- package/src/crew/library/entries/data/haversine-distance.json +39 -0
- package/src/crew/library/entries/data/histogram-binning.json +38 -0
- package/src/crew/library/entries/data/ids-random-uuid.json +36 -0
- package/src/crew/library/entries/data/intl-collator-sorting.json +37 -0
- package/src/crew/library/entries/data/join-merge-datasets.json +37 -0
- package/src/crew/library/entries/data/json-group-transform.json +38 -0
- package/src/crew/library/entries/data/list-search-filter-sort.json +39 -0
- package/src/crew/library/entries/data/localstorage-versioned-state.json +37 -0
- package/src/crew/library/entries/data/log-line-parsing.json +40 -0
- package/src/crew/library/entries/data/markdown-to-html-safe.json +36 -0
- package/src/crew/library/entries/data/money-integer-cents.json +38 -0
- package/src/crew/library/entries/data/nice-axis-ticks.json +36 -0
- package/src/crew/library/entries/data/number-currency-intl.json +37 -0
- package/src/crew/library/entries/data/offline-sync-queue.json +40 -0
- package/src/crew/library/entries/data/paginate-data.json +38 -0
- package/src/crew/library/entries/data/parse-date-strings.json +36 -0
- package/src/crew/library/entries/data/personal-data-minimization.json +41 -0
- package/src/crew/library/entries/data/pubsub-state-store.json +39 -0
- package/src/crew/library/entries/data/realistic-seed-data.json +40 -0
- package/src/crew/library/entries/data/schema-validation-handwritten.json +38 -0
- package/src/crew/library/entries/data/sparkline-inline.json +38 -0
- package/src/crew/library/entries/data/stats-summary-numbers.json +38 -0
- package/src/crew/library/entries/data/svg-bar-chart.json +39 -0
- package/src/crew/library/entries/data/svg-donut-chart.json +38 -0
- package/src/crew/library/entries/data/svg-line-chart.json +39 -0
- package/src/crew/library/entries/data/table-to-chart.json +37 -0
- package/src/crew/library/entries/data/undo-redo-history.json +36 -0
- package/src/crew/library/entries/data/validator-functions.json +37 -0
- package/src/crew/library/entries/design/brand-palette-from-one-color.json +38 -0
- package/src/crew/library/entries/design/breakpoint-strategy.json +38 -0
- package/src/crew/library/entries/design/button-hierarchy.json +38 -0
- package/src/crew/library/entries/design/color-palette-aa.json +39 -0
- package/src/crew/library/entries/design/corner-radius-system.json +35 -0
- package/src/crew/library/entries/design/dark-palette-design.json +37 -0
- package/src/crew/library/entries/design/dataviz-colors.json +37 -0
- package/src/crew/library/entries/design/design-consistency-audit.json +38 -0
- package/src/crew/library/entries/design/design-critique.json +36 -0
- package/src/crew/library/entries/design/design-tokens-css.json +37 -0
- package/src/crew/library/entries/design/elevation-shadows.json +37 -0
- package/src/crew/library/entries/design/error-offline-states-design.json +38 -0
- package/src/crew/library/entries/design/fluid-type-clamp.json +37 -0
- package/src/crew/library/entries/design/font-stack-pairing.json +38 -0
- package/src/crew/library/entries/design/form-design.json +38 -0
- package/src/crew/library/entries/design/header-logo-placement.json +38 -0
- package/src/crew/library/entries/design/icon-usage.json +37 -0
- package/src/crew/library/entries/design/image-aspect-ratio.json +38 -0
- package/src/crew/library/entries/design/layout-auto-fit-grid.json +37 -0
- package/src/crew/library/entries/design/layout-bento-grid.json +37 -0
- package/src/crew/library/entries/design/layout-centered-column.json +37 -0
- package/src/crew/library/entries/design/layout-holy-grail.json +38 -0
- package/src/crew/library/entries/design/layout-magazine.json +37 -0
- package/src/crew/library/entries/design/layout-sidebar-content.json +37 -0
- package/src/crew/library/entries/design/layout-split-hero.json +39 -0
- package/src/crew/library/entries/design/layout-sticky-footer.json +35 -0
- package/src/crew/library/entries/design/line-length-rhythm.json +39 -0
- package/src/crew/library/entries/design/loading-feedback.json +38 -0
- package/src/crew/library/entries/design/micro-interactions.json +38 -0
- package/src/crew/library/entries/design/mobile-nav-patterns.json +38 -0
- package/src/crew/library/entries/design/motion-reduced.json +38 -0
- package/src/crew/library/entries/design/multi-theme.json +38 -0
- package/src/crew/library/entries/design/semantic-color-tokens.json +38 -0
- package/src/crew/library/entries/design/spacing-scale.json +38 -0
- package/src/crew/library/entries/design/style-guide-page.json +40 -0
- package/src/crew/library/entries/design/touch-target-focus.json +36 -0
- package/src/crew/library/entries/design/typography-scale.json +38 -0
- package/src/crew/library/entries/design/ui-microcopy.json +36 -0
- package/src/crew/library/entries/design/visual-direction.json +37 -0
- package/src/crew/library/entries/design/visual-hierarchy.json +37 -0
- package/src/crew/library/entries/design/whitespace-grouping.json +37 -0
- package/src/crew/library/entries/design/wireframe-lofi.json +40 -0
- package/src/crew/library/entries/desktop/desktop-app-security.json +43 -0
- package/src/crew/library/entries/desktop/desktop-auto-update.json +40 -0
- package/src/crew/library/entries/desktop/desktop-background-tasks.json +39 -0
- package/src/crew/library/entries/desktop/desktop-clipboard-integration.json +38 -0
- package/src/crew/library/entries/desktop/desktop-command-palette-registry.json +39 -0
- package/src/crew/library/entries/desktop/desktop-file-drag-drop.json +38 -0
- package/src/crew/library/entries/desktop/desktop-global-hotkeys.json +38 -0
- package/src/crew/library/entries/desktop/desktop-high-dpi-scaling.json +41 -0
- package/src/crew/library/entries/desktop/desktop-keyboard-focus-a11y.json +40 -0
- package/src/crew/library/entries/desktop/desktop-local-logs-crash-reports.json +40 -0
- package/src/crew/library/entries/desktop/desktop-localization.json +40 -0
- package/src/crew/library/entries/desktop/desktop-menus-shortcuts.json +40 -0
- package/src/crew/library/entries/desktop/desktop-offline-local-data.json +40 -0
- package/src/crew/library/entries/desktop/desktop-open-save-dialogs.json +39 -0
- package/src/crew/library/entries/desktop/desktop-os-theme-follow.json +40 -0
- package/src/crew/library/entries/desktop/desktop-packaging-installers.json +42 -0
- package/src/crew/library/entries/desktop/desktop-print-pdf-export.json +39 -0
- package/src/crew/library/entries/desktop/desktop-safe-file-writes.json +40 -0
- package/src/crew/library/entries/desktop/desktop-settings-user-data.json +38 -0
- package/src/crew/library/entries/desktop/desktop-single-instance-windows.json +38 -0
- package/src/crew/library/entries/desktop/desktop-testing-node-test.json +39 -0
- package/src/crew/library/entries/desktop/desktop-tray-notifications.json +38 -0
- package/src/crew/library/entries/desktop/desktop-web-app-migration.json +41 -0
- package/src/crew/library/entries/desktop/desktop-window-state.json +38 -0
- package/src/crew/library/entries/desktop/neutralino-app-setup.json +39 -0
- package/src/crew/library/entries/devops/backup-restore-drill.json +41 -0
- package/src/crew/library/entries/devops/ci-matrix-os-runtime.json +38 -0
- package/src/crew/library/entries/devops/ci-secrets-environments.json +39 -0
- package/src/crew/library/entries/devops/ci-test-workflow.json +39 -0
- package/src/crew/library/entries/devops/compose-app-database.json +39 -0
- package/src/crew/library/entries/devops/containerfile-python-script.json +41 -0
- package/src/crew/library/entries/devops/cron-scheduled-tasks.json +38 -0
- package/src/crew/library/entries/devops/dependency-update-routine.json +39 -0
- package/src/crew/library/entries/devops/deploy-rollback-plan.json +39 -0
- package/src/crew/library/entries/devops/deploy-script-gotchas.json +39 -0
- package/src/crew/library/entries/devops/dockerfile-node-service.json +41 -0
- package/src/crew/library/entries/devops/dockerignore-small-images.json +37 -0
- package/src/crew/library/entries/devops/healthcheck-restart-policy.json +40 -0
- package/src/crew/library/entries/devops/incident-runbook.json +40 -0
- package/src/crew/library/entries/devops/infrastructure-as-code-basics.json +39 -0
- package/src/crew/library/entries/devops/log-rotation-setup.json +38 -0
- package/src/crew/library/entries/devops/make-targets-ci-parity.json +39 -0
- package/src/crew/library/entries/devops/release-pipeline-tags.json +38 -0
- package/src/crew/library/entries/devops/reverse-proxy-node-app.json +41 -0
- package/src/crew/library/entries/devops/semver-bump-decision.json +39 -0
- package/src/crew/library/entries/devops/static-site-deploy.json +38 -0
- package/src/crew/library/entries/devops/systemd-unit-hardening.json +38 -0
- package/src/crew/library/entries/devops/tls-certificate-renewal.json +39 -0
- package/src/crew/library/entries/devops/uptime-check-monitoring.json +38 -0
- package/src/crew/library/entries/devops/zero-downtime-deploy-systemd.json +38 -0
- package/src/crew/library/entries/games/arcade-physics-velocity-gravity.json +37 -0
- package/src/crew/library/entries/games/auto-pause-blur-visibility.json +36 -0
- package/src/crew/library/entries/games/camera-follow-scrolling.json +37 -0
- package/src/crew/library/entries/games/canvas-game-profiling.json +39 -0
- package/src/crew/library/entries/games/card-deck-shuffle-rules.json +38 -0
- package/src/crew/library/entries/games/collision-aabb-circle.json +38 -0
- package/src/crew/library/entries/games/difficulty-curve-wave-spawner.json +39 -0
- package/src/crew/library/entries/games/fixed-timestep-game-loop.json +37 -0
- package/src/crew/library/entries/games/game-audio-unlock-mixer.json +39 -0
- package/src/crew/library/entries/games/game-hud-accessibility.json +42 -0
- package/src/crew/library/entries/games/game-scene-state-machine.json +38 -0
- package/src/crew/library/entries/games/grid-pathfinding-a-star.json +38 -0
- package/src/crew/library/entries/games/high-score-table-storage.json +40 -0
- package/src/crew/library/entries/games/input-action-mapping-gamepad.json +37 -0
- package/src/crew/library/entries/games/local-multiplayer-hot-seat.json +39 -0
- package/src/crew/library/entries/games/offline-game-pwa.json +40 -0
- package/src/crew/library/entries/games/particle-effects-budget.json +38 -0
- package/src/crew/library/entries/games/platformer-jump-feel.json +38 -0
- package/src/crew/library/entries/games/puzzle-undo-move-stack.json +38 -0
- package/src/crew/library/entries/games/seeded-procedural-generation.json +38 -0
- package/src/crew/library/entries/games/sprite-sheet-animation.json +38 -0
- package/src/crew/library/entries/games/tile-map-json-levels.json +40 -0
- package/src/crew/library/entries/games/top-down-shooter-basics.json +39 -0
- package/src/crew/library/entries/games/turn-based-rules-engine-tests.json +39 -0
- package/src/crew/library/entries/games/virtual-joystick-touch-controls.json +40 -0
- package/src/crew/library/entries/git-docs/api-reference-docs.json +39 -0
- package/src/crew/library/entries/git-docs/architecture-decision-record.json +39 -0
- package/src/crew/library/entries/git-docs/atomic-commits.json +36 -0
- package/src/crew/library/entries/git-docs/branching-workflow.json +38 -0
- package/src/crew/library/entries/git-docs/bug-report.json +38 -0
- package/src/crew/library/entries/git-docs/changelog-entry.json +37 -0
- package/src/crew/library/entries/git-docs/cli-help-text.json +38 -0
- package/src/crew/library/entries/git-docs/code-comments.json +37 -0
- package/src/crew/library/entries/git-docs/commit-message.json +36 -0
- package/src/crew/library/entries/git-docs/config-reference-docs.json +40 -0
- package/src/crew/library/entries/git-docs/contributing-guide.json +40 -0
- package/src/crew/library/entries/git-docs/docstrings-public-api.json +38 -0
- package/src/crew/library/entries/git-docs/faq-doc.json +36 -0
- package/src/crew/library/entries/git-docs/feature-request.json +37 -0
- package/src/crew/library/entries/git-docs/getting-started-tutorial.json +39 -0
- package/src/crew/library/entries/git-docs/git-bisect.json +38 -0
- package/src/crew/library/entries/git-docs/git-recover-mistakes.json +36 -0
- package/src/crew/library/entries/git-docs/gitignore-setup.json +35 -0
- package/src/crew/library/entries/git-docs/license-options.json +36 -0
- package/src/crew/library/entries/git-docs/merge-conflicts.json +38 -0
- package/src/crew/library/entries/git-docs/migration-guide.json +39 -0
- package/src/crew/library/entries/git-docs/pr-description.json +37 -0
- package/src/crew/library/entries/git-docs/readme-cli.json +39 -0
- package/src/crew/library/entries/git-docs/readme-library-api.json +40 -0
- package/src/crew/library/entries/git-docs/readme-project.json +40 -0
- package/src/crew/library/entries/git-docs/release-notes.json +37 -0
- package/src/crew/library/entries/git-docs/release-tag-semver.json +37 -0
- package/src/crew/library/entries/git-docs/review-reply.json +35 -0
- package/src/crew/library/entries/git-docs/security-policy.json +37 -0
- package/src/crew/library/entries/git-docs/troubleshooting-guide.json +38 -0
- package/src/crew/library/entries/mobile/capacitor-camera-geolocation-plugins.json +39 -0
- package/src/crew/library/entries/mobile/capacitor-project-setup.json +42 -0
- package/src/crew/library/entries/mobile/mobile-app-lifecycle-events.json +39 -0
- package/src/crew/library/entries/mobile/mobile-auth-secure-token-storage.json +41 -0
- package/src/crew/library/entries/mobile/mobile-camera-photo-upload.json +40 -0
- package/src/crew/library/entries/mobile/mobile-deep-links-app-links.json +41 -0
- package/src/crew/library/entries/mobile/mobile-form-keyboards-autofill.json +41 -0
- package/src/crew/library/entries/mobile/mobile-haptics-vibration.json +39 -0
- package/src/crew/library/entries/mobile/mobile-indexeddb-storage-wrapper.json +39 -0
- package/src/crew/library/entries/mobile/mobile-manifest-icon-set.json +41 -0
- package/src/crew/library/entries/mobile/mobile-media-for-phones.json +41 -0
- package/src/crew/library/entries/mobile/mobile-offline-cache-strategies.json +40 -0
- package/src/crew/library/entries/mobile/mobile-offline-location-maps.json +41 -0
- package/src/crew/library/entries/mobile/mobile-outbox-resume-sync.json +41 -0
- package/src/crew/library/entries/mobile/mobile-push-notifications-limits.json +40 -0
- package/src/crew/library/entries/mobile/mobile-pwa-app-shell.json +41 -0
- package/src/crew/library/entries/mobile/mobile-safe-area-insets.json +41 -0
- package/src/crew/library/entries/mobile/mobile-small-screen-device-testing.json +39 -0
- package/src/crew/library/entries/mobile/mobile-startup-performance-budget.json +41 -0
- package/src/crew/library/entries/mobile/mobile-store-release-checklist.json +41 -0
- package/src/crew/library/entries/mobile/mobile-system-theme-bars.json +40 -0
- package/src/crew/library/entries/mobile/mobile-tab-bar-back-button.json +40 -0
- package/src/crew/library/entries/mobile/mobile-touch-gestures.json +40 -0
- package/src/crew/library/entries/mobile/mobile-touch-screen-reader-a11y.json +41 -0
- package/src/crew/library/entries/mobile/mobile-web-bundle-versioning.json +40 -0
- package/src/crew/library/entries/planning/acceptance-criteria.json +34 -0
- package/src/crew/library/entries/planning/change-request-midjob.json +34 -0
- package/src/crew/library/entries/planning/clarifying-questions.json +34 -0
- package/src/crew/library/entries/planning/decision-log.json +35 -0
- package/src/crew/library/entries/planning/definition-of-done.json +33 -0
- package/src/crew/library/entries/planning/estimate-tasks.json +35 -0
- package/src/crew/library/entries/planning/identify-risks.json +34 -0
- package/src/crew/library/entries/planning/milestones.json +34 -0
- package/src/crew/library/entries/planning/one-task-per-file.json +33 -0
- package/src/crew/library/entries/planning/order-by-dependencies.json +33 -0
- package/src/crew/library/entries/planning/plan-accessibility.json +34 -0
- package/src/crew/library/entries/planning/plan-browser-game.json +35 -0
- package/src/crew/library/entries/planning/plan-bug-investigation.json +36 -0
- package/src/crew/library/entries/planning/plan-data-migration.json +35 -0
- package/src/crew/library/entries/planning/plan-documentation.json +34 -0
- package/src/crew/library/entries/planning/plan-for-small-models.json +34 -0
- package/src/crew/library/entries/planning/plan-multi-page-site.json +34 -0
- package/src/crew/library/entries/planning/plan-safe-refactor.json +34 -0
- package/src/crew/library/entries/planning/plan-small-api.json +34 -0
- package/src/crew/library/entries/planning/plan-tests.json +34 -0
- package/src/crew/library/entries/planning/prioritize-must-should-could.json +34 -0
- package/src/crew/library/entries/planning/recover-failed-task.json +36 -0
- package/src/crew/library/entries/planning/requirements-from-conversation.json +34 -0
- package/src/crew/library/entries/planning/review-plan-before-work.json +35 -0
- package/src/crew/library/entries/planning/scope-first-version.json +34 -0
- package/src/crew/library/entries/planning/split-into-tasks.json +35 -0
- package/src/crew/library/entries/planning/staff-the-crew.json +35 -0
- package/src/crew/library/entries/planning/success-measures.json +34 -0
- package/src/crew/library/entries/planning/timebox-work.json +33 -0
- package/src/crew/library/entries/planning/tradeoff-table.json +33 -0
- package/src/crew/library/entries/planning/user-stories.json +34 -0
- package/src/crew/library/entries/planning/vague-request-assumptions.json +33 -0
- package/src/crew/library/entries/practices/accessibility-audit.json +43 -0
- package/src/crew/library/entries/practices/accessible-names-labels.json +40 -0
- package/src/crew/library/entries/practices/add-jsdoc-types.json +36 -0
- package/src/crew/library/entries/practices/add-unit-tests.json +38 -0
- package/src/crew/library/entries/practices/algorithm-performance.json +38 -0
- package/src/crew/library/entries/practices/api-error-format.json +37 -0
- package/src/crew/library/entries/practices/async-race-condition.json +37 -0
- package/src/crew/library/entries/practices/boundary-validation.json +38 -0
- package/src/crew/library/entries/practices/bug-fix-from-error.json +39 -0
- package/src/crew/library/entries/practices/clean-console-warnings.json +38 -0
- package/src/crew/library/entries/practices/color-contrast-fix.json +38 -0
- package/src/crew/library/entries/practices/config-management.json +39 -0
- package/src/crew/library/entries/practices/consistent-code-style.json +38 -0
- package/src/crew/library/entries/practices/content-security-policy.json +38 -0
- package/src/crew/library/entries/practices/css-layout-overflow.json +41 -0
- package/src/crew/library/entries/practices/dark-mode.json +39 -0
- package/src/crew/library/entries/practices/data-format-migration.json +37 -0
- package/src/crew/library/entries/practices/debounce-throttle.json +35 -0
- package/src/crew/library/entries/practices/debug-failing-test.json +37 -0
- package/src/crew/library/entries/practices/deprecation-compat.json +37 -0
- package/src/crew/library/entries/practices/dom-batching-reflow.json +36 -0
- package/src/crew/library/entries/practices/edge-case-tests.json +36 -0
- package/src/crew/library/entries/practices/error-handling-strategy.json +38 -0
- package/src/crew/library/entries/practices/event-listener-not-firing.json +34 -0
- package/src/crew/library/entries/practices/feature-flags.json +37 -0
- package/src/crew/library/entries/practices/file-upload-handling.json +39 -0
- package/src/crew/library/entries/practices/focus-management.json +36 -0
- package/src/crew/library/entries/practices/graceful-shutdown.json +36 -0
- package/src/crew/library/entries/practices/http-caching-headers.json +36 -0
- package/src/crew/library/entries/practices/i18n-setup.json +38 -0
- package/src/crew/library/entries/practices/injection-risks.json +37 -0
- package/src/crew/library/entries/practices/keyboard-navigation-fix.json +37 -0
- package/src/crew/library/entries/practices/log-levels-redaction.json +37 -0
- package/src/crew/library/entries/practices/memory-leak-fix.json +36 -0
- package/src/crew/library/entries/practices/minimal-dependencies.json +39 -0
- package/src/crew/library/entries/practices/minimal-reproduction.json +35 -0
- package/src/crew/library/entries/practices/modernize-legacy-js.json +39 -0
- package/src/crew/library/entries/practices/money-float-precision.json +36 -0
- package/src/crew/library/entries/practices/not-a-function-error.json +36 -0
- package/src/crew/library/entries/practices/null-undefined-access.json +35 -0
- package/src/crew/library/entries/practices/off-by-one-errors.json +37 -0
- package/src/crew/library/entries/practices/page-load-performance.json +39 -0
- package/src/crew/library/entries/practices/password-session-basics.json +37 -0
- package/src/crew/library/entries/practices/plurals-number-date-format.json +36 -0
- package/src/crew/library/entries/practices/progressive-enhancement.json +37 -0
- package/src/crew/library/entries/practices/refactor-extract-function.json +35 -0
- package/src/crew/library/entries/practices/remove-dead-code.json +35 -0
- package/src/crew/library/entries/practices/rename-for-clarity.json +35 -0
- package/src/crew/library/entries/practices/responsive-fix-375.json +40 -0
- package/src/crew/library/entries/practices/responsive-images-srcset.json +38 -0
- package/src/crew/library/entries/practices/rest-api-conventions.json +39 -0
- package/src/crew/library/entries/practices/retry-backoff.json +37 -0
- package/src/crew/library/entries/practices/rtl-support.json +37 -0
- package/src/crew/library/entries/practices/secrets-handling.json +37 -0
- package/src/crew/library/entries/practices/security-review-xss.json +40 -0
- package/src/crew/library/entries/practices/seo-basics.json +42 -0
- package/src/crew/library/entries/practices/shared-mutation-bug.json +35 -0
- package/src/crew/library/entries/practices/sitemap-robots.json +38 -0
- package/src/crew/library/entries/practices/split-large-file.json +38 -0
- package/src/crew/library/entries/practices/structured-data-jsonld.json +35 -0
- package/src/crew/library/entries/practices/structured-logging.json +37 -0
- package/src/crew/library/entries/practices/test-dom-logic-split.json +37 -0
- package/src/crew/library/entries/practices/timeouts-abort.json +35 -0
- package/src/crew/library/entries/practices/user-facing-error-messages.json +36 -0
- package/src/crew/library/entries/practices/z-index-stacking.json +36 -0
- package/src/crew/library/entries/review-qa/bug-repro-triage.json +35 -0
- package/src/crew/library/entries/review-qa/cross-browser-standards.json +36 -0
- package/src/crew/library/entries/review-qa/edge-cases-dates-timezones.json +37 -0
- package/src/crew/library/entries/review-qa/edge-cases-empty-huge-data.json +35 -0
- package/src/crew/library/entries/review-qa/edge-cases-inputs.json +34 -0
- package/src/crew/library/entries/review-qa/edge-cases-numbers-money.json +37 -0
- package/src/crew/library/entries/review-qa/edge-cases-unicode.json +37 -0
- package/src/crew/library/entries/review-qa/exploratory-charter.json +35 -0
- package/src/crew/library/entries/review-qa/form-e2e-check.json +37 -0
- package/src/crew/library/entries/review-qa/game-logic-check.json +37 -0
- package/src/crew/library/entries/review-qa/keyboard-only-qa.json +36 -0
- package/src/crew/library/entries/review-qa/link-asset-check.json +36 -0
- package/src/crew/library/entries/review-qa/performance-budget-check.json +37 -0
- package/src/crew/library/entries/review-qa/persistence-reload-check.json +37 -0
- package/src/crew/library/entries/review-qa/regression-checklist.json +35 -0
- package/src/crew/library/entries/review-qa/release-signoff.json +40 -0
- package/src/crew/library/entries/review-qa/responsive-qa-breakpoints.json +37 -0
- package/src/crew/library/entries/review-qa/review-a11y-pass.json +39 -0
- package/src/crew/library/entries/review-qa/review-copy.json +36 -0
- package/src/crew/library/entries/review-qa/review-css.json +39 -0
- package/src/crew/library/entries/review-qa/review-data-migration.json +36 -0
- package/src/crew/library/entries/review-qa/review-dependencies.json +37 -0
- package/src/crew/library/entries/review-qa/review-error-handling.json +37 -0
- package/src/crew/library/entries/review-qa/review-html.json +40 -0
- package/src/crew/library/entries/review-qa/review-i18n.json +37 -0
- package/src/crew/library/entries/review-qa/review-javascript.json +39 -0
- package/src/crew/library/entries/review-qa/review-logging.json +36 -0
- package/src/crew/library/entries/review-qa/review-node-server.json +39 -0
- package/src/crew/library/entries/review-qa/review-performance-pass.json +39 -0
- package/src/crew/library/entries/review-qa/review-pr-scope.json +35 -0
- package/src/crew/library/entries/review-qa/review-python.json +39 -0
- package/src/crew/library/entries/review-qa/review-security-pass.json +39 -0
- package/src/crew/library/entries/review-qa/review-test-quality.json +36 -0
- package/src/crew/library/entries/review-qa/screen-reader-smoke.json +36 -0
- package/src/crew/library/entries/review-qa/severity-triage.json +36 -0
- package/src/crew/library/entries/review-qa/smoke-test-release.json +35 -0
- package/src/crew/library/entries/review-qa/test-plan-api.json +36 -0
- package/src/crew/library/entries/review-qa/test-plan-form.json +35 -0
- package/src/crew/library/entries/review-qa/test-plan-game.json +35 -0
- package/src/crew/library/entries/review-qa/test-plan-web-page.json +35 -0
- package/src/crew/library/entries/review-qa/verify-acceptance-criteria.json +35 -0
- package/src/crew/library/entries/review-qa/visual-qa-spacing.json +36 -0
- package/src/crew/library/entries/roles/architect-architecture-review.json +37 -0
- package/src/crew/library/entries/roles/architect-constraints-check.json +37 -0
- package/src/crew/library/entries/roles/architect-data-flow-sketch.json +38 -0
- package/src/crew/library/entries/roles/architect-interface-contracts.json +38 -0
- package/src/crew/library/entries/roles/architect-static-site-structure.json +37 -0
- package/src/crew/library/entries/roles/designer-design-qa-pass.json +36 -0
- package/src/crew/library/entries/roles/designer-look-from-brief.json +37 -0
- package/src/crew/library/entries/roles/designer-polish-existing-page.json +36 -0
- package/src/crew/library/entries/roles/designer-token-handoff.json +37 -0
- package/src/crew/library/entries/roles/designer-visual-spec.json +37 -0
- package/src/crew/library/entries/roles/developer-few-turns.json +36 -0
- package/src/crew/library/entries/roles/developer-read-before-edit.json +36 -0
- package/src/crew/library/entries/roles/developer-self-check.json +37 -0
- package/src/crew/library/entries/roles/developer-test-mjs.json +38 -0
- package/src/crew/library/entries/roles/developer-unclear-spec.json +35 -0
- package/src/crew/library/entries/roles/ops-backup-rollback.json +36 -0
- package/src/crew/library/entries/roles/ops-environment-check.json +35 -0
- package/src/crew/library/entries/roles/ops-log-triage.json +36 -0
- package/src/crew/library/entries/roles/ops-release-checklist.json +39 -0
- package/src/crew/library/entries/roles/ops-safe-commands.json +35 -0
- package/src/crew/library/entries/roles/qa-automatic-check-results.json +35 -0
- package/src/crew/library/entries/roles/qa-check-acceptance-criteria.json +36 -0
- package/src/crew/library/entries/roles/qa-findings-format.json +34 -0
- package/src/crew/library/entries/roles/qa-recheck-fixes.json +36 -0
- package/src/crew/library/entries/roles/qa-severity-calibration.json +36 -0
- package/src/crew/library/entries/roles/reviewer-constructive-comments.json +34 -0
- package/src/crew/library/entries/roles/reviewer-diff-review.json +36 -0
- package/src/crew/library/entries/roles/reviewer-fix-round.json +36 -0
- package/src/crew/library/entries/roles/reviewer-scope-creep.json +35 -0
- package/src/crew/library/entries/roles/reviewer-verdict-rules.json +35 -0
- package/src/crew/library/entries/roles/writer-copy-from-brief.json +37 -0
- package/src/crew/library/entries/roles/writer-docs-voice.json +36 -0
- package/src/crew/library/entries/roles/writer-edit-for-clarity.json +37 -0
- package/src/crew/library/entries/roles/writer-microcopy.json +39 -0
- package/src/crew/library/entries/roles/writer-translation-ready.json +36 -0
- package/src/crew/library/entries/security/auth-session-review.json +39 -0
- package/src/crew/library/entries/security/command-injection-review.json +39 -0
- package/src/crew/library/entries/security/cookie-flags-audit.json +40 -0
- package/src/crew/library/entries/security/csp-static-site-meta.json +41 -0
- package/src/crew/library/entries/security/csrf-protection.json +41 -0
- package/src/crew/library/entries/security/dependency-advisory-offline.json +41 -0
- package/src/crew/library/entries/security/extension-permission-review.json +41 -0
- package/src/crew/library/entries/security/idor-access-review.json +41 -0
- package/src/crew/library/entries/security/input-validation-review.json +38 -0
- package/src/crew/library/entries/security/log-leak-audit.json +40 -0
- package/src/crew/library/entries/security/password-storage-audit.json +40 -0
- package/src/crew/library/entries/security/path-traversal-review.json +41 -0
- package/src/crew/library/entries/security/secret-scan-rotate.json +40 -0
- package/src/crew/library/entries/security/security-audit-report.json +43 -0
- package/src/crew/library/entries/security/security-fix-triage.json +41 -0
- package/src/crew/library/entries/security/security-headers-checklist.json +40 -0
- package/src/crew/library/entries/security/sql-injection-review.json +40 -0
- package/src/crew/library/entries/security/ssrf-url-fetcher.json +41 -0
- package/src/crew/library/entries/security/threat-model-small-app.json +41 -0
- package/src/crew/library/entries/security/tls-verification-on.json +40 -0
- package/src/crew/library/entries/security/unsafe-deserialization.json +40 -0
- package/src/crew/library/entries/security/upload-attack-review.json +39 -0
- package/src/crew/library/entries/security/weak-crypto-audit.json +40 -0
- package/src/crew/library/entries/security/webview-bridge-hardening.json +42 -0
- package/src/crew/library/entries/security/xss-context-encoding.json +41 -0
- package/src/crew/library/entries/stacks/browser-es-modules.json +40 -0
- package/src/crew/library/entries/stacks/canvas-2d-animation-loop.json +38 -0
- package/src/crew/library/entries/stacks/config-ini-yaml-parsing.json +37 -0
- package/src/crew/library/entries/stacks/css-custom-properties-theme.json +43 -0
- package/src/crew/library/entries/stacks/css-grid-flex-layout.json +43 -0
- package/src/crew/library/entries/stacks/dom-event-delegation.json +39 -0
- package/src/crew/library/entries/stacks/drag-drop-reorder-api.json +38 -0
- package/src/crew/library/entries/stacks/env-config-module.json +38 -0
- package/src/crew/library/entries/stacks/fetch-timeout-abort.json +38 -0
- package/src/crew/library/entries/stacks/geolocation-permission.json +37 -0
- package/src/crew/library/entries/stacks/html-semantic-skeleton.json +51 -0
- package/src/crew/library/entries/stacks/indexeddb-wrapper.json +36 -0
- package/src/crew/library/entries/stacks/intersection-observer-uses.json +36 -0
- package/src/crew/library/entries/stacks/json-file-database.json +40 -0
- package/src/crew/library/entries/stacks/json-schema-format.json +38 -0
- package/src/crew/library/entries/stacks/makefile-task-runner.json +37 -0
- package/src/crew/library/entries/stacks/node-child-process.json +40 -0
- package/src/crew/library/entries/stacks/node-cli-parseargs.json +40 -0
- package/src/crew/library/entries/stacks/node-cors-preflight.json +38 -0
- package/src/crew/library/entries/stacks/node-file-watcher.json +40 -0
- package/src/crew/library/entries/stacks/node-folder-batch-script.json +42 -0
- package/src/crew/library/entries/stacks/node-http-crud-api.json +45 -0
- package/src/crew/library/entries/stacks/node-rate-limit.json +40 -0
- package/src/crew/library/entries/stacks/node-readline-prompts.json +39 -0
- package/src/crew/library/entries/stacks/node-scheduled-jobs.json +39 -0
- package/src/crew/library/entries/stacks/node-server-sent-events.json +39 -0
- package/src/crew/library/entries/stacks/node-static-file-server.json +41 -0
- package/src/crew/library/entries/stacks/node-streams-large-files.json +39 -0
- package/src/crew/library/entries/stacks/node-test-suite.json +40 -0
- package/src/crew/library/entries/stacks/package-json-scripts.json +37 -0
- package/src/crew/library/entries/stacks/password-hashing-scrypt.json +40 -0
- package/src/crew/library/entries/stacks/pwa-manifest-install.json +40 -0
- package/src/crew/library/entries/stacks/python-argparse-cli.json +39 -0
- package/src/crew/library/entries/stacks/python-csv-module.json +41 -0
- package/src/crew/library/entries/stacks/python-dataclasses-models.json +39 -0
- package/src/crew/library/entries/stacks/python-http-server-api.json +38 -0
- package/src/crew/library/entries/stacks/python-logging-setup.json +39 -0
- package/src/crew/library/entries/stacks/python-pathlib-files.json +41 -0
- package/src/crew/library/entries/stacks/python-re-text-processing.json +39 -0
- package/src/crew/library/entries/stacks/python-unittest-suite.json +40 -0
- package/src/crew/library/entries/stacks/python-urllib-client.json +40 -0
- package/src/crew/library/entries/stacks/python-venv-setup-notes.json +42 -0
- package/src/crew/library/entries/stacks/regex-writing-testing.json +37 -0
- package/src/crew/library/entries/stacks/service-worker-offline.json +36 -0
- package/src/crew/library/entries/stacks/shell-script-strict.json +38 -0
- package/src/crew/library/entries/stacks/sql-portable-queries.json +39 -0
- package/src/crew/library/entries/stacks/svg-icons-handwritten.json +39 -0
- package/src/crew/library/entries/stacks/web-audio-sounds.json +37 -0
- package/src/crew/library/entries/stacks/web-component-custom-element.json +38 -0
- package/src/crew/library/entries/stacks/web-worker-offload.json +36 -0
- package/src/crew/library/entries/tools/cli-batch-plan-dry-run.json +38 -0
- package/src/crew/library/entries/tools/cli-color-no-color.json +38 -0
- package/src/crew/library/entries/tools/cli-config-precedence.json +39 -0
- package/src/crew/library/entries/tools/cli-cross-platform-paths.json +38 -0
- package/src/crew/library/entries/tools/cli-exit-codes-stderr.json +39 -0
- package/src/crew/library/entries/tools/cli-help-from-option-table.json +39 -0
- package/src/crew/library/entries/tools/cli-package-bin-shebang.json +40 -0
- package/src/crew/library/entries/tools/cli-progress-output.json +38 -0
- package/src/crew/library/entries/tools/cli-prompts-noninteractive.json +38 -0
- package/src/crew/library/entries/tools/cli-stdin-pipes.json +39 -0
- package/src/crew/library/entries/tools/cli-subcommands-parseargs.json +39 -0
- package/src/crew/library/entries/tools/cli-tests-spawn-binary.json +39 -0
- package/src/crew/library/entries/tools/ext-content-scripts-isolation.json +39 -0
- package/src/crew/library/entries/tools/ext-context-menu-items.json +37 -0
- package/src/crew/library/entries/tools/ext-csp-no-remote-code.json +39 -0
- package/src/crew/library/entries/tools/ext-keyboard-commands.json +37 -0
- package/src/crew/library/entries/tools/ext-logic-node-tests.json +39 -0
- package/src/crew/library/entries/tools/ext-messaging.json +38 -0
- package/src/crew/library/entries/tools/ext-minimal-permissions.json +38 -0
- package/src/crew/library/entries/tools/ext-mv3-skeleton.json +38 -0
- package/src/crew/library/entries/tools/ext-options-page.json +40 -0
- package/src/crew/library/entries/tools/ext-popup-ui.json +41 -0
- package/src/crew/library/entries/tools/ext-storage-quotas.json +39 -0
- package/src/crew/library/entries/tools/ext-store-review-checklist.json +39 -0
- package/src/crew/library/entries/tools/python-cli-argparse-tests.json +40 -0
- package/src/crew/library/entries/ui-components/accordion-disclosure.json +42 -0
- package/src/crew/library/entries/ui-components/alert-banner.json +41 -0
- package/src/crew/library/entries/ui-components/announcement-bar.json +41 -0
- package/src/crew/library/entries/ui-components/avatar-badge.json +40 -0
- package/src/crew/library/entries/ui-components/back-to-top-button.json +38 -0
- package/src/crew/library/entries/ui-components/breadcrumb-trail.json +38 -0
- package/src/crew/library/entries/ui-components/card-grid.json +41 -0
- package/src/crew/library/entries/ui-components/carousel-accessible.json +40 -0
- package/src/crew/library/entries/ui-components/combobox-autocomplete.json +40 -0
- package/src/crew/library/entries/ui-components/command-palette.json +41 -0
- package/src/crew/library/entries/ui-components/comment-thread.json +42 -0
- package/src/crew/library/entries/ui-components/contact-card-vcard.json +41 -0
- package/src/crew/library/entries/ui-components/context-menu.json +37 -0
- package/src/crew/library/entries/ui-components/cookie-consent-banner.json +43 -0
- package/src/crew/library/entries/ui-components/copy-to-clipboard-button.json +38 -0
- package/src/crew/library/entries/ui-components/date-time-inputs.json +39 -0
- package/src/crew/library/entries/ui-components/dropdown-menu-button.json +40 -0
- package/src/crew/library/entries/ui-components/empty-state.json +41 -0
- package/src/crew/library/entries/ui-components/faq-section-jsonld.json +37 -0
- package/src/crew/library/entries/ui-components/file-upload-dropzone.json +42 -0
- package/src/crew/library/entries/ui-components/form-layout-grid.json +42 -0
- package/src/crew/library/entries/ui-components/hero-section.json +43 -0
- package/src/crew/library/entries/ui-components/image-gallery-lightbox.json +41 -0
- package/src/crew/library/entries/ui-components/inline-validation-field.json +44 -0
- package/src/crew/library/entries/ui-components/keyboard-shortcuts-dialog.json +39 -0
- package/src/crew/library/entries/ui-components/load-more-list.json +40 -0
- package/src/crew/library/entries/ui-components/modal-dialog.json +42 -0
- package/src/crew/library/entries/ui-components/multi-step-form-wizard.json +42 -0
- package/src/crew/library/entries/ui-components/navbar-responsive.json +44 -0
- package/src/crew/library/entries/ui-components/notification-center.json +40 -0
- package/src/crew/library/entries/ui-components/off-canvas-drawer.json +42 -0
- package/src/crew/library/entries/ui-components/pagination-nav.json +39 -0
- package/src/crew/library/entries/ui-components/popover-panel.json +39 -0
- package/src/crew/library/entries/ui-components/progress-bar-spinner.json +39 -0
- package/src/crew/library/entries/ui-components/quantity-stepper-input.json +41 -0
- package/src/crew/library/entries/ui-components/radio-cards-checkbox-group.json +40 -0
- package/src/crew/library/entries/ui-components/range-slider-input.json +39 -0
- package/src/crew/library/entries/ui-components/share-button-fallback.json +39 -0
- package/src/crew/library/entries/ui-components/sidebar-nav-collapsible.json +43 -0
- package/src/crew/library/entries/ui-components/site-footer.json +43 -0
- package/src/crew/library/entries/ui-components/skeleton-loader.json +38 -0
- package/src/crew/library/entries/ui-components/sortable-data-table.json +42 -0
- package/src/crew/library/entries/ui-components/star-rating-input.json +39 -0
- package/src/crew/library/entries/ui-components/stats-counter-strip.json +40 -0
- package/src/crew/library/entries/ui-components/sticky-mobile-cta-bar.json +41 -0
- package/src/crew/library/entries/ui-components/tabs-widget.json +41 -0
- package/src/crew/library/entries/ui-components/tag-chips-input.json +42 -0
- package/src/crew/library/entries/ui-components/testimonials-block.json +40 -0
- package/src/crew/library/entries/ui-components/toast-notifications.json +41 -0
- package/src/crew/library/entries/ui-components/toggle-switch.json +38 -0
- package/src/crew/library/entries/ui-components/toolbar-buttons.json +41 -0
- package/src/crew/library/entries/ui-components/tooltip-hint.json +39 -0
- package/src/crew/library/entries/ui-components/tree-view.json +39 -0
- package/src/crew/library/entries/ui-components/vertical-timeline.json +39 -0
- package/src/crew/library/entries/ui-components/video-embed-responsive.json +40 -0
- package/src/crew/library/entries/web-pages/about-page.json +48 -0
- package/src/crew/library/entries/web-pages/agency-services-page.json +49 -0
- package/src/crew/library/entries/web-pages/animal-adoption-site.json +49 -0
- package/src/crew/library/entries/web-pages/app-promo-page.json +49 -0
- package/src/crew/library/entries/web-pages/bakery-site.json +50 -0
- package/src/crew/library/entries/web-pages/band-music-site.json +50 -0
- package/src/crew/library/entries/web-pages/blog-home.json +47 -0
- package/src/crew/library/entries/web-pages/blog-post.json +49 -0
- package/src/crew/library/entries/web-pages/cafe-site.json +49 -0
- package/src/crew/library/entries/web-pages/careers-page.json +47 -0
- package/src/crew/library/entries/web-pages/clinic-site.json +50 -0
- package/src/crew/library/entries/web-pages/community-club-site.json +47 -0
- package/src/crew/library/entries/web-pages/contact-page.json +49 -0
- package/src/crew/library/entries/web-pages/course-page.json +50 -0
- package/src/crew/library/entries/web-pages/docs-site.json +50 -0
- package/src/crew/library/entries/web-pages/event-page.json +50 -0
- package/src/crew/library/entries/web-pages/gym-fitness-site.json +50 -0
- package/src/crew/library/entries/web-pages/help-center-page.json +46 -0
- package/src/crew/library/entries/web-pages/hotel-stay-site.json +51 -0
- package/src/crew/library/entries/web-pages/html-email.json +40 -0
- package/src/crew/library/entries/web-pages/landing-page.json +49 -0
- package/src/crew/library/entries/web-pages/legal-policy-page.json +46 -0
- package/src/crew/library/entries/web-pages/link-in-bio-page.json +47 -0
- package/src/crew/library/entries/web-pages/maintenance-page.json +44 -0
- package/src/crew/library/entries/web-pages/multi-page-site.json +49 -0
- package/src/crew/library/entries/web-pages/newsletter-archive-page.json +49 -0
- package/src/crew/library/entries/web-pages/nonprofit-donation-page.json +50 -0
- package/src/crew/library/entries/web-pages/not-found-404.json +45 -0
- package/src/crew/library/entries/web-pages/one-page-scroll-site.json +47 -0
- package/src/crew/library/entries/web-pages/podcast-site.json +48 -0
- package/src/crew/library/entries/web-pages/portfolio-creative.json +48 -0
- package/src/crew/library/entries/web-pages/portfolio-developer.json +50 -0
- package/src/crew/library/entries/web-pages/pricing-page.json +48 -0
- package/src/crew/library/entries/web-pages/printable-page.json +47 -0
- package/src/crew/library/entries/web-pages/product-detail-page.json +50 -0
- package/src/crew/library/entries/web-pages/product-updates-page.json +45 -0
- package/src/crew/library/entries/web-pages/qr-menu-page.json +47 -0
- package/src/crew/library/entries/web-pages/real-estate-listing.json +51 -0
- package/src/crew/library/entries/web-pages/recipe-page.json +47 -0
- package/src/crew/library/entries/web-pages/restaurant-site.json +50 -0
- package/src/crew/library/entries/web-pages/resume-page.json +48 -0
- package/src/crew/library/entries/web-pages/salon-booking-site.json +52 -0
- package/src/crew/library/entries/web-pages/sign-in-page.json +50 -0
- package/src/crew/library/entries/web-pages/status-page.json +49 -0
- package/src/crew/library/entries/web-pages/store-catalog.json +50 -0
- package/src/crew/library/entries/web-pages/store-locator-page.json +47 -0
- package/src/crew/library/entries/web-pages/thank-you-page.json +46 -0
- package/src/crew/library/entries/web-pages/trades-business-site.json +50 -0
- package/src/crew/library/entries/web-pages/travel-guide-page.json +48 -0
- package/src/crew/library/entries/web-pages/waitlist-page.json +50 -0
- package/src/crew/library/entries/web-pages/wedding-site.json +50 -0
- package/src/crew/library/hook.js +295 -0
- package/src/crew/library/index.js +245 -0
- package/src/crew/library/select.js +366 -0
- package/src/crew/planner.js +17 -12
- package/src/crew/prompts/index.js +10 -4
- package/src/crew/prompts/roles.js +51 -0
- package/src/crew/say.js +41 -0
- package/src/crew/scheduler.js +25 -4
- package/src/crew/talk.js +192 -0
- package/src/crew/worker.js +5 -1
- package/src/crew/workers.js +16 -0
- package/src/demo.js +11 -4
- package/src/doctor.js +6 -1
- package/src/extensions/create.js +3 -1
- package/src/extensions/index.js +11 -5
- package/src/extensions/sandbox.js +81 -56
- package/src/github/git.js +114 -1
- package/src/github/index.js +7 -2
- package/src/index.js +179 -19
- package/src/lend/guard.js +115 -7
- package/src/lend/index.js +82 -12
- package/src/lend/share.js +73 -0
- package/src/p2p/audit.js +147 -0
- package/src/p2p/caps.js +193 -0
- package/src/p2p/city-port.js +92 -0
- package/src/p2p/cli.js +300 -0
- package/src/p2p/compute-link.js +101 -0
- package/src/p2p/doctor.js +233 -0
- package/src/p2p/encoding.js +50 -0
- package/src/p2p/engine.js +268 -0
- package/src/p2p/handshake.js +339 -0
- package/src/p2p/identity.js +195 -0
- package/src/p2p/invites.js +170 -0
- package/src/p2p/keyfile.js +119 -0
- package/src/p2p/messages.js +184 -0
- package/src/p2p/node.js +926 -0
- package/src/p2p/peers.js +209 -0
- package/src/p2p/pool-port.js +119 -0
- package/src/p2p/primitives.js +129 -0
- package/src/p2p/remote-port.js +265 -0
- package/src/p2p/session.js +282 -0
- package/src/p2p/transport/base.js +70 -0
- package/src/p2p/transport/browser-pipe.js +85 -0
- package/src/p2p/transport/index.js +7 -0
- package/src/p2p/transport/inproc.js +57 -0
- package/src/p2p/transport/ws-lan.js +88 -0
- package/src/p2p/workbench-port.js +116 -0
- package/src/phone/hub.js +621 -0
- package/src/phone/index.js +85 -0
- package/src/phone/pipe.js +79 -0
- package/src/phone/port.js +187 -0
- package/src/phone/store.js +123 -0
- package/src/phone/view.js +140 -0
- package/src/profile/index.js +203 -0
- package/src/profile/sanitize.js +39 -0
- package/src/remote/address.js +96 -0
- package/src/remote/clipnative.js +119 -0
- package/src/remote/clipsync.js +412 -0
- package/src/remote/desk.js +874 -0
- package/src/remote/helper.js +126 -0
- package/src/remote/index.js +242 -0
- package/src/remote/keys.js +86 -0
- package/src/remote/policy.js +135 -0
- package/src/remote/port.js +61 -0
- package/src/remote/transfer.js +412 -0
- package/src/remote/types.js +35 -0
- package/src/remote/unattended.js +99 -0
- package/src/remote/x11.js +140 -0
- package/src/replay/reduce.js +25 -3
- package/src/server.js +83 -19
- package/src/tasks/commands.js +46 -0
- package/src/tasks/crew-executor.js +134 -0
- package/src/tasks/engine.js +469 -0
- package/src/tasks/state.js +421 -0
- package/src/tools/approvals.js +12 -3
- package/src/tools/index.js +54 -6
- package/src/tools/run.js +10 -1
- package/src/tools/workspace.js +14 -1
- package/src/voice/catalog.js +111 -0
- package/src/voice/index.js +275 -0
- package/src/voice/piper.js +47 -0
- package/src/voice/reply.js +97 -0
- package/src/voice/store.js +149 -0
- package/src/voice/wav.js +59 -0
- package/src/voice/whisper.js +140 -0
- package/src/workbench/docs.js +185 -0
- package/src/workbench/fs.js +214 -0
- package/src/workbench/glob.js +102 -0
- package/src/workbench/index.js +569 -0
- package/src/workbench/match.js +103 -0
- package/src/workbench/origin.js +85 -0
- package/src/workbench/pty.js +223 -0
- package/src/workbench/scm.js +159 -0
- package/src/workbench/search-worker.js +52 -0
- package/src/workbench/search.js +216 -0
- package/src/workbench/settings.js +131 -0
- package/src/workbench/share.js +228 -0
- package/src/workbench/walk.js +57 -0
- package/themes/mel.hivedesk-theme.json +24 -24
- package/ui/changelog/changelog.css +4 -4
- package/ui/city/activity.js +140 -0
- package/ui/city/city.css +274 -131
- package/ui/city/city.js +260 -90
- package/ui/city/collab.js +4 -1
- package/ui/city/compute.js +272 -0
- package/ui/city/hub.js +91 -0
- package/ui/city/layout.js +5 -5
- package/ui/city/machines.js +135 -0
- package/ui/city/model.js +29 -6
- package/ui/city/onboarding.js +122 -0
- package/ui/city/panels.js +394 -0
- package/ui/city/peers.js +164 -0
- package/ui/city/roles.js +10 -0
- package/ui/city/scene.js +685 -869
- package/ui/city/strings.js +32 -0
- package/ui/css/hive.css +308 -376
- package/ui/css/polish.css +85 -98
- package/ui/css/tokens.css +160 -0
- package/ui/css/voice.css +35 -0
- package/ui/editor/editor.css +17 -17
- package/ui/editor/monaco.js +48 -51
- package/ui/editor/register.js +22 -9
- package/ui/editor/vendor/ts/VENDORED.txt +3 -0
- package/ui/editor/vendor/ts/tsMode.js +20 -0
- package/ui/editor/vendor/ts/tsWorker.js +51328 -0
- package/ui/favicon.svg +1 -1
- package/ui/github/github.css +4 -4
- package/ui/index.html +3 -2
- package/ui/js/actions.js +6 -3
- package/ui/js/art.js +113 -0
- package/ui/js/bees.js +60 -137
- package/ui/js/fx.js +9 -62
- package/ui/js/main.js +28 -0
- package/ui/js/onboarding-gate.js +21 -0
- package/ui/js/store.js +5 -0
- package/ui/js/topbar.js +1 -1
- package/ui/js/tour.js +15 -1
- package/ui/js/voice/audio.js +82 -0
- package/ui/js/voice/capture-worklet.js +25 -0
- package/ui/js/voice/conversation.js +177 -0
- package/ui/js/voice/engines.js +64 -0
- package/ui/js/voice/index.js +587 -164
- package/ui/js/voice/intents.js +21 -3
- package/ui/js/voice/mic.js +69 -0
- package/ui/js/voice/questions.js +110 -0
- package/ui/js/voice/sentences.js +59 -0
- package/ui/js/voice/session.js +222 -21
- package/ui/js/voice/speaker.js +129 -0
- package/ui/js/voice/turn.js +107 -0
- package/ui/js/voice/vad.js +70 -0
- package/ui/js/voice/wake.js +41 -0
- package/ui/js/widgets/activity.js +66 -0
- package/ui/js/widgets/approvals.js +3 -0
- package/ui/js/widgets/brief.js +9 -6
- package/ui/js/widgets/chat.js +43 -7
- package/ui/js/widgets/library-strings.js +173 -0
- package/ui/js/widgets/library-used.js +118 -0
- package/ui/js/widgets/library.js +143 -0
- package/ui/js/widgets/machines.js +31 -0
- package/ui/js/widgets/providers.js +1 -1
- package/ui/js/widgets/question.js +295 -0
- package/ui/js/widgets/settings.js +14 -1
- package/ui/lend/collab/client.js +1 -1
- package/ui/lend/collab/roles.js +19 -16
- package/ui/lend/core/bridge.js +18 -5
- package/ui/lend/core/frames.js +20 -0
- package/ui/lend/core/p2p-pipe.js +213 -0
- package/ui/lend/core/pairing.js +4 -2
- package/ui/lend/index.html +1 -0
- package/ui/lend/join-window.js +9 -0
- package/ui/lend/lend-screen.js +14 -1
- package/ui/lend/lend.css +23 -7
- package/ui/lend/p2p-model.js +103 -0
- package/ui/lend/p2p-screen.js +228 -0
- package/ui/lend/p2p-text.js +86 -0
- package/ui/manifest.webmanifest +2 -2
- package/ui/models/index.js +304 -0
- package/ui/models/models.css +112 -0
- package/ui/models/strings/de.json +232 -0
- package/ui/models/strings/en.json +232 -0
- package/ui/models/strings/es.json +232 -0
- package/ui/models/strings/fr.json +232 -0
- package/ui/models/strings/it.json +232 -0
- package/ui/models/strings/ja.json +232 -0
- package/ui/models/strings/ko.json +232 -0
- package/ui/models/strings/pt-BR.json +232 -0
- package/ui/models/strings/ru.json +232 -0
- package/ui/models/strings/zh-CN.json +232 -0
- package/ui/models/t.js +41 -0
- package/ui/models/window.js +432 -0
- package/ui/office/office.css +89 -91
- package/ui/office/office.js +48 -23
- package/ui/office/popout.js +1 -1
- package/ui/office/scene.js +472 -779
- package/ui/offline.html +5 -5
- package/ui/phone/bridge.js +39 -0
- package/ui/phone/core/client.js +240 -0
- package/ui/phone/core/connect.js +195 -0
- package/ui/phone/core/crypto.js +211 -0
- package/ui/phone/core/grants.js +45 -0
- package/ui/phone/core/handshake.js +353 -0
- package/ui/phone/core/invite.js +55 -0
- package/ui/phone/core/messages.js +85 -0
- package/ui/phone/core/session.js +160 -0
- package/ui/phone/desktop.js +244 -0
- package/ui/phone/phone.css +36 -0
- package/ui/phone/strings.js +45 -0
- package/ui/profile/achievements.js +96 -0
- package/ui/profile/avatars.js +68 -0
- package/ui/profile/profile.css +53 -0
- package/ui/profile/stats.js +148 -0
- package/ui/profile/ui.js +207 -0
- package/ui/remote/abr.js +73 -0
- package/ui/remote/common.js +107 -0
- package/ui/remote/digits.js +20 -0
- package/ui/remote/home.js +148 -0
- package/ui/remote/host.js +259 -0
- package/ui/remote/index.js +107 -0
- package/ui/remote/media.js +180 -0
- package/ui/remote/pipes.js +64 -0
- package/ui/remote/pointer.js +67 -0
- package/ui/remote/remote.css +88 -0
- package/ui/remote/strings.js +173 -0
- package/ui/remote/viewer.js +267 -0
- package/ui/themes/core.js +21 -21
- package/ui/themes/themes.css +19 -19
- package/ui/widget.css +13 -16
- package/ui/widget.html +3 -2
- package/ui/widget.js +2 -2
- package/ui/workbench/commands.js +141 -0
- package/ui/workbench/dialogs.js +107 -0
- package/ui/workbench/editors.js +911 -0
- package/ui/workbench/explorer.js +419 -0
- package/ui/workbench/layout.js +203 -0
- package/ui/workbench/models.js +105 -0
- package/ui/workbench/net.js +26 -0
- package/ui/workbench/problems.js +94 -0
- package/ui/workbench/quick.js +98 -0
- package/ui/workbench/scmview.js +190 -0
- package/ui/workbench/searchview.js +215 -0
- package/ui/workbench/session.js +162 -0
- package/ui/workbench/settingsview.js +89 -0
- package/ui/workbench/strings.js +26 -0
- package/ui/workbench/terminal.js +314 -0
- package/ui/workbench/theme.js +153 -0
- package/ui/workbench/util.js +128 -0
- package/ui/workbench/vendor/xterm/LICENSE +21 -0
- package/ui/workbench/vendor/xterm/VENDORED.txt +3 -0
- package/ui/workbench/vendor/xterm/addon-fit.js +2 -0
- package/ui/workbench/vendor/xterm/xterm.css +218 -0
- package/ui/workbench/vendor/xterm/xterm.js +2 -0
- package/ui/workbench/workbench.css +388 -0
- package/ui/workbench/workbench.js +712 -0
- package/ui/screenshots/city-agent-card-1440.png +0 -0
- package/ui/screenshots/city-agent-card-1920.png +0 -0
- package/ui/screenshots/city-bridge-gpu-borrow-1440.png +0 -0
- package/ui/screenshots/city-bridge-gpu-borrow-1920.png +0 -0
- package/ui/screenshots/city-friend-rising-1440.png +0 -0
- package/ui/screenshots/city-friend-rising-1920.png +0 -0
- package/ui/screenshots/city-overview-1440.png +0 -0
- package/ui/screenshots/city-overview-1920.png +0 -0
- package/ui/screenshots/city-review-room-1440.png +0 -0
- package/ui/screenshots/city-review-room-1920.png +0 -0
- package/ui/screenshots/hive-1440-de.png +0 -0
- package/ui/screenshots/hive-1440-ja.png +0 -0
- package/ui/screenshots/hive-1440-job-running.png +0 -0
- package/ui/screenshots/hive-1440-model-download.png +0 -0
- package/ui/screenshots/hive-1440-pt-BR.png +0 -0
- package/ui/screenshots/hive-1440-tooltip.png +0 -0
- package/ui/screenshots/hive-1440-tour-step1.png +0 -0
- package/ui/screenshots/hive-1440-tour-step5.png +0 -0
- package/ui/screenshots/hive-1920-context-menu.png +0 -0
- package/ui/screenshots/hive-1920-desktop-menu.png +0 -0
- package/ui/screenshots/hive-1920-hire.png +0 -0
- package/ui/screenshots/hive-1920-job-running.png +0 -0
- package/ui/screenshots/hive-1920-palette.png +0 -0
- package/ui/screenshots/hive-1920-replay.png +0 -0
- package/ui/screenshots/hive-375-phone.png +0 -0
- package/ui/screenshots/office-1440-approval.png +0 -0
- package/ui/screenshots/office-1440-celebrate.png +0 -0
- package/ui/screenshots/office-1440-working.png +0 -0
- package/ui/screenshots/office-1920-approval.png +0 -0
- package/ui/screenshots/office-1920-celebrate.png +0 -0
- package/ui/screenshots/office-1920-working.png +0 -0
- package/ui/screenshots/office-widget.png +0 -0
package/src/p2p/node.js
ADDED
|
@@ -0,0 +1,926 @@
|
|
|
1
|
+
// The P2P control plane of one engine (PLAN 1.2, 3 and 4): identity, invites, the handshakes,
|
|
2
|
+
// sessions, the join decision, capabilities and grants, the peer store and the audit log.
|
|
3
|
+
// It runs in Node only; the window renders what it reports and asks through commands.
|
|
4
|
+
//
|
|
5
|
+
// Other modules use three things:
|
|
6
|
+
// node.handle(type, fn) a handler for a message type; it runs only after the grant check
|
|
7
|
+
// node.send(peerId, type, b) send to a peer with an accepted open session
|
|
8
|
+
// node.can(peerId, cap) the active grant this engine gave that peer, or null
|
|
9
|
+
// and listen to: 'join.request', 'join.decided', 'peer.online', 'peer.offline', 'grant.created',
|
|
10
|
+
// 'grant.revoked' (also on expiry and session end: stop the work it allowed), 'held.changed',
|
|
11
|
+
// 'cap.request', 'invite.burned', 'audit'.
|
|
12
|
+
|
|
13
|
+
import { EventEmitter } from 'node:events';
|
|
14
|
+
import path from 'node:path';
|
|
15
|
+
import crypto from 'node:crypto';
|
|
16
|
+
import { AuditLog } from './audit.js';
|
|
17
|
+
import { PeerStore } from './peers.js';
|
|
18
|
+
import { InviteBook, deriveInvite, deriveAddressInvite, readWords, INVITE_ITERATIONS } from './invites.js';
|
|
19
|
+
import { deriveAddress } from '../remote/address.js';
|
|
20
|
+
import { HandshakeError, InviteGuest, InviteHost, KnownInitiator, KnownResponder, failMessage, parseHs } from './handshake.js';
|
|
21
|
+
import { SecureSession } from './session.js';
|
|
22
|
+
import { messageSpec } from './messages.js';
|
|
23
|
+
import { CAPABILITIES, CapError, findGrant, grantForWire, isActive, joinDialogToggles, makeGrant, normalizeCapability, normalizeCapList, readWireGrant } from './caps.js';
|
|
24
|
+
import { cleanName, isPeerId, loadOrCreateIdentity, publicIdentity } from './identity.js';
|
|
25
|
+
import { base32, b64u } from './encoding.js';
|
|
26
|
+
import { publicProfile } from '../profile/sanitize.js';
|
|
27
|
+
|
|
28
|
+
export const HANDSHAKE_MS = 15_000;
|
|
29
|
+
export const DECISION_MS = 5 * 60_000;
|
|
30
|
+
export const PING_MS = 5_000;
|
|
31
|
+
export const DEAD_MS = 10_000; // PLAN 8: no pong for 10 s is a disconnect
|
|
32
|
+
|
|
33
|
+
/** Incoming handshakes per minute on this machine's address (a published address must not flood the host). */
|
|
34
|
+
const ADDRESS_RATE = 10;
|
|
35
|
+
const USER = Object.freeze({ kind: 'user' });
|
|
36
|
+
const SYSTEM = Object.freeze({ kind: 'system' });
|
|
37
|
+
|
|
38
|
+
/** Waits for the next text on a connection, with a deadline. */
|
|
39
|
+
function nextText(conn, ms) {
|
|
40
|
+
return new Promise((resolve, reject) => {
|
|
41
|
+
const done = () => {
|
|
42
|
+
clearTimeout(timer);
|
|
43
|
+
conn.off('message', onMsg);
|
|
44
|
+
conn.off('close', onClose);
|
|
45
|
+
};
|
|
46
|
+
const onMsg = (t) => {
|
|
47
|
+
done();
|
|
48
|
+
resolve(t);
|
|
49
|
+
};
|
|
50
|
+
const onClose = () => {
|
|
51
|
+
done();
|
|
52
|
+
reject(new HandshakeError('closed', 'the connection closed during the handshake'));
|
|
53
|
+
};
|
|
54
|
+
const timer = setTimeout(() => {
|
|
55
|
+
done();
|
|
56
|
+
reject(new HandshakeError('timeout', 'the handshake took too long'));
|
|
57
|
+
}, ms);
|
|
58
|
+
conn.on('message', onMsg);
|
|
59
|
+
conn.on('close', onClose);
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const rid = (prefix) => prefix + base32(crypto.randomBytes(8)).slice(0, 12);
|
|
64
|
+
|
|
65
|
+
export class P2PNode extends EventEmitter {
|
|
66
|
+
/**
|
|
67
|
+
* @param {{ home: string, name?: string, now?: () => number, iterations?: number, handshakeMs?: number,
|
|
68
|
+
* decisionMs?: number, pingMs?: number, deadMs?: number, rekeyMessages?: number, rekeyMs?: number,
|
|
69
|
+
* cityId?: string, machineId?: string, viewCommands?: string[] }} o
|
|
70
|
+
*/
|
|
71
|
+
constructor(o) {
|
|
72
|
+
super();
|
|
73
|
+
this.home = o.home;
|
|
74
|
+
this.opts = o;
|
|
75
|
+
this.now = o.now || (() => Date.now());
|
|
76
|
+
this.iterations = o.iterations ?? INVITE_ITERATIONS;
|
|
77
|
+
this.handshakeMs = o.handshakeMs ?? HANDSHAKE_MS;
|
|
78
|
+
this.decisionMs = o.decisionMs ?? DECISION_MS;
|
|
79
|
+
this.pingMs = o.pingMs ?? PING_MS;
|
|
80
|
+
this.deadMs = o.deadMs ?? DEAD_MS;
|
|
81
|
+
this.viewCommands = new Set(o.viewCommands || []);
|
|
82
|
+
this.handlers = new Map();
|
|
83
|
+
this.sessions = new Map(); // sessionId -> rec
|
|
84
|
+
this.byPeer = new Map(); // peerId -> sessionId
|
|
85
|
+
this.sessionGrants = new Map(); // grantId -> grant (scope session, memory only)
|
|
86
|
+
this.joinRequests = new Map(); // requestId -> request (host side)
|
|
87
|
+
this.capRequests = new Map(); // id -> { peerId, capability, reason, at }
|
|
88
|
+
this.ended = new Set(); // grant ids whose end (expiry) was already announced
|
|
89
|
+
this.refusedAudit = new Map();
|
|
90
|
+
this.seenOnline = new Set(); // peers that had a session in this run: the next one is a resume
|
|
91
|
+
this.addressBook = new Map(); // topic -> { address, invite, hits: number[] } while listening by address
|
|
92
|
+
this.addressRate = o.addressRate ?? ADDRESS_RATE;
|
|
93
|
+
this.profile = null; // { name, avatar } this engine shows its peers (src/profile/)
|
|
94
|
+
this.peerProfiles = new Map(); // peerId -> { name, avatar } they showed us, sanitized
|
|
95
|
+
this.started = false;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/** Loads (or creates) the identity and opens the peer store and the audit log. */
|
|
99
|
+
start() {
|
|
100
|
+
if (this.started) return this;
|
|
101
|
+
const { identity, created } = loadOrCreateIdentity(this.home, { name: this.opts.name, now: this.now });
|
|
102
|
+
this.identity = identity;
|
|
103
|
+
this.audit = new AuditLog({ dir: path.join(this.home, 'audit'), now: this.now });
|
|
104
|
+
if (this.audit.repaired) this._audit({ type: 'audit.repaired', ...this.audit.repaired });
|
|
105
|
+
if (created) this._audit({ type: 'identity.created', peerId: identity.peerId });
|
|
106
|
+
this.peers = new PeerStore({ dir: path.join(this.home, 'peers'), now: this.now });
|
|
107
|
+
this.invites = new InviteBook({ now: this.now, iterations: this.iterations });
|
|
108
|
+
this.timer = setInterval(() => this.sweep(), 1000);
|
|
109
|
+
this.timer.unref?.();
|
|
110
|
+
this.started = true;
|
|
111
|
+
return this;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
_audit(entry) {
|
|
115
|
+
const rec = this.audit.append(entry);
|
|
116
|
+
this.emit('audit', rec);
|
|
117
|
+
return rec;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
info() {
|
|
121
|
+
return { ...publicIdentity(this.identity) };
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/** The name and avatar this engine shows its peers; sent to every open session and to each new one. */
|
|
125
|
+
setProfile(p) {
|
|
126
|
+
const prof = publicProfile(p, this.identity?.peerId);
|
|
127
|
+
if (Number.isFinite(p?.achievements)) prof.achievements = Math.max(0, Math.min(1000, Math.round(p.achievements)));
|
|
128
|
+
this.profile = prof;
|
|
129
|
+
for (const rec of this.sessions.values()) if (rec.online && rec.session.state === 'open') rec.session.send('profile.hello', prof);
|
|
130
|
+
return prof;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/** What a peer showed us, or null. */
|
|
134
|
+
profileOf(peerId) {
|
|
135
|
+
return this.peerProfiles.get(peerId) || this.peers?.get(peerId)?.profile || null;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
// ------------------------------------------------------------------ invites (host)
|
|
139
|
+
|
|
140
|
+
/** A new invite. Returns { inviteId, words, expiresAt, offeredCaps, rendezvous: { topic, seal } }. */
|
|
141
|
+
async createInvite({ caps = [], minutes, origin = USER } = {}) {
|
|
142
|
+
if (origin.kind !== 'user') throw new CapError('forbidden', 'only a person makes an invite');
|
|
143
|
+
const inv = await this.invites.create({ minutes, offeredCaps: caps });
|
|
144
|
+
this._audit({ type: 'invite.created', inviteId: inv.id, expiresAt: new Date(inv.expiresAt).toISOString(), offered: inv.offeredCaps.map((c) => c.name) });
|
|
145
|
+
return { inviteId: inv.id, words: [...inv.words], expiresAt: new Date(inv.expiresAt).toISOString(), offeredCaps: inv.offeredCaps, rendezvous: { topic: inv.topic, seal: b64u(inv.seal) } };
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
cancelInvite(inviteId) {
|
|
149
|
+
const inv = this.invites.cancel(inviteId);
|
|
150
|
+
if (inv) this._audit({ type: 'invite.cancelled', inviteId });
|
|
151
|
+
return !!inv;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
// ------------------------------------------------------------------ incoming connections
|
|
155
|
+
|
|
156
|
+
/** Takes an incoming connection: an invite handshake (hs.1) or a known peer reconnect (hs.k1). */
|
|
157
|
+
async accept(conn) {
|
|
158
|
+
let text;
|
|
159
|
+
try {
|
|
160
|
+
text = await nextText(conn, this.handshakeMs);
|
|
161
|
+
} catch {
|
|
162
|
+
conn.close('no handshake');
|
|
163
|
+
return null;
|
|
164
|
+
}
|
|
165
|
+
let first;
|
|
166
|
+
try {
|
|
167
|
+
first = parseHs(text);
|
|
168
|
+
} catch (err) {
|
|
169
|
+
conn.send(failMessage(err.code));
|
|
170
|
+
conn.close('bad handshake');
|
|
171
|
+
return null;
|
|
172
|
+
}
|
|
173
|
+
if (first.t === 'hs.1' && typeof first.inv === 'string' && this.addressBook.has(first.inv)) return this._hostAddress(conn, text, this.addressBook.get(first.inv));
|
|
174
|
+
if (first.t === 'hs.1') return this._hostInvite(conn, text, first);
|
|
175
|
+
if (first.t === 'hs.k1') return this._respondKnown(conn, text);
|
|
176
|
+
conn.send(failMessage('protocol'));
|
|
177
|
+
conn.close('bad handshake');
|
|
178
|
+
return null;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
async _hostInvite(conn, m1, first) {
|
|
182
|
+
let inv;
|
|
183
|
+
try {
|
|
184
|
+
inv = this.invites.take({ topic: typeof first.inv === 'string' ? first.inv : '' });
|
|
185
|
+
} catch (err) {
|
|
186
|
+
conn.send(failMessage(err.code === 'unknown' ? 'words' : err.code));
|
|
187
|
+
conn.close('no invite');
|
|
188
|
+
return null;
|
|
189
|
+
}
|
|
190
|
+
const hs = new InviteHost({ identity: this.identity, invite: inv, hostName: this.identity.name });
|
|
191
|
+
let r;
|
|
192
|
+
try {
|
|
193
|
+
conn.send(hs.onM1(m1));
|
|
194
|
+
r = hs.onM3(await nextText(conn, this.handshakeMs));
|
|
195
|
+
const known = this.peers.get(r.guest.peerId);
|
|
196
|
+
if (known?.trust === 'blocked') throw new HandshakeError('blocked', 'this peer is blocked');
|
|
197
|
+
} catch (err) {
|
|
198
|
+
this.invites.burn(inv.id, err.code);
|
|
199
|
+
this._audit({ type: 'invite.burned', inviteId: inv.id, reason: err.code || 'failed' });
|
|
200
|
+
this.emit('invite.burned', { inviteId: inv.id, reason: err.code || 'failed' });
|
|
201
|
+
// "The words did not work" on both sides, whatever the reason was here.
|
|
202
|
+
conn.send(failMessage(err.code === 'blocked' ? 'refused' : 'words'));
|
|
203
|
+
conn.close('handshake failed');
|
|
204
|
+
return null;
|
|
205
|
+
}
|
|
206
|
+
this.invites.consume(inv.id);
|
|
207
|
+
const rec = this._openSession(conn, { ...r, peerId: r.guest.peerId, accepted: false, confirmed: true });
|
|
208
|
+
// Key confirmation for the guest: the first frame it can open.
|
|
209
|
+
rec.session.send('ping', {});
|
|
210
|
+
const request = {
|
|
211
|
+
id: rid('jr_'),
|
|
212
|
+
inviteId: inv.id,
|
|
213
|
+
sessionId: rec.session.id,
|
|
214
|
+
peer: r.guest,
|
|
215
|
+
name: r.name,
|
|
216
|
+
requestedCaps: r.requestedCaps,
|
|
217
|
+
offeredCaps: inv.offeredCaps,
|
|
218
|
+
sas: r.sas,
|
|
219
|
+
createdAt: this.now(),
|
|
220
|
+
expiresAt: this.now() + this.decisionMs,
|
|
221
|
+
};
|
|
222
|
+
this.joinRequests.set(request.id, request);
|
|
223
|
+
const audit = this._audit({ type: 'join.requested', requestId: request.id, peerId: r.guest.peerId, name: r.name, requested: r.requestedCaps.map((c) => c.name) });
|
|
224
|
+
request.auditHash = audit.hash;
|
|
225
|
+
this.emit('join.request', this.joinDialog(request));
|
|
226
|
+
return rec.session;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
// ------------------------------------------------------------------ by address (remote desktop)
|
|
230
|
+
|
|
231
|
+
/** This machine's 10 digit address (src/remote/address.js), from its public key. */
|
|
232
|
+
address() {
|
|
233
|
+
return deriveAddress(this.identity.publicRaw);
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
/**
|
|
237
|
+
* Listen (or stop) for handshakes on this machine's address. Off by default. A handshake by
|
|
238
|
+
* address grants nothing: the caller gets a session in which it may ask, and only the host's
|
|
239
|
+
* click grants (the remote desktop dialog). Incoming handshakes are rate limited per address.
|
|
240
|
+
*/
|
|
241
|
+
listenAddress(on) {
|
|
242
|
+
const address = this.address();
|
|
243
|
+
const inv = deriveAddressInvite(address);
|
|
244
|
+
if (on) this.addressBook.set(inv.topic, { address, invite: { id: `ad_${address}`, topic: inv.topic, psk: inv.psk, offeredCaps: [] }, hits: [] });
|
|
245
|
+
else this.addressBook.delete(inv.topic);
|
|
246
|
+
this._audit({ type: on ? 'address.listen' : 'address.stop', address });
|
|
247
|
+
return { address, listening: !!on, rendezvous: { topic: inv.topic, seal: b64u(inv.seal) } };
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
/** The relay meeting point of an address, for the window half of browser-pipe: { topic, seal }. */
|
|
251
|
+
addressRendezvous(address) {
|
|
252
|
+
const inv = deriveAddressInvite(address);
|
|
253
|
+
return { topic: inv.topic, seal: b64u(inv.seal) };
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
async _hostAddress(conn, m1, entry) {
|
|
257
|
+
const t = this.now();
|
|
258
|
+
entry.hits = entry.hits.filter((x) => t - x < 60_000);
|
|
259
|
+
if (entry.hits.length >= this.addressRate) {
|
|
260
|
+
if (entry.hits.length === this.addressRate) this._audit({ type: 'address.rate_limited', address: entry.address });
|
|
261
|
+
entry.hits.push(t);
|
|
262
|
+
conn.send(failMessage('rate_limited'));
|
|
263
|
+
conn.close('rate limited');
|
|
264
|
+
return null;
|
|
265
|
+
}
|
|
266
|
+
entry.hits.push(t);
|
|
267
|
+
const hs = new InviteHost({ identity: this.identity, invite: { ...entry.invite, psk: Buffer.from(entry.invite.psk) }, hostName: this.identity.name });
|
|
268
|
+
let r;
|
|
269
|
+
try {
|
|
270
|
+
conn.send(hs.onM1(m1));
|
|
271
|
+
r = hs.onM3(await nextText(conn, this.handshakeMs));
|
|
272
|
+
if (this.peers.get(r.guest.peerId)?.trust === 'blocked') throw new HandshakeError('blocked', 'this peer is blocked');
|
|
273
|
+
if (r.guest.peerId === this.identity.peerId) throw new HandshakeError('protocol', 'that is this machine');
|
|
274
|
+
} catch (err) {
|
|
275
|
+
this._audit({ type: 'address.failed', reason: err.code || 'failed' });
|
|
276
|
+
conn.send(failMessage(err.code === 'blocked' ? 'refused' : 'failed'));
|
|
277
|
+
conn.close('handshake failed');
|
|
278
|
+
return null;
|
|
279
|
+
}
|
|
280
|
+
// Remembered so a grant can name it; trust is not raised: a known peer stays known, a new one unknown.
|
|
281
|
+
this.peers.upsert(r.guest, { relation: this.peers.get(r.guest.peerId)?.relation || 'remote', name: r.name });
|
|
282
|
+
const rec = this._openSession(conn, { ...r, peerId: r.guest.peerId, accepted: true, confirmed: true, via: 'address' });
|
|
283
|
+
rec.sas = r.sas;
|
|
284
|
+
rec.session.send('ping', {});
|
|
285
|
+
this._audit({ type: 'address.session', peerId: r.guest.peerId, sessionId: rec.session.id, name: r.name });
|
|
286
|
+
this._online(rec);
|
|
287
|
+
this.emit('address.session', { peerId: r.guest.peerId, sessionId: rec.session.id, name: r.name, sas: r.sas, role: 'host' });
|
|
288
|
+
return rec.session;
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
/**
|
|
292
|
+
* Dials a machine by its address over conn: the identity handshake without words. The answer
|
|
293
|
+
* must come from a key whose address is the one dialed. Resolves with { sessionId, sas, host }.
|
|
294
|
+
*/
|
|
295
|
+
async dialAddress(address, conn, { name } = {}) {
|
|
296
|
+
const inv = deriveAddressInvite(address);
|
|
297
|
+
const guest = new InviteGuest({ identity: this.identity, invite: { topic: inv.topic, psk: inv.psk }, name: name || this.identity.name, requestedCaps: [] });
|
|
298
|
+
let r;
|
|
299
|
+
try {
|
|
300
|
+
conn.send(guest.start());
|
|
301
|
+
const m2 = await nextText(conn, this.handshakeMs);
|
|
302
|
+
({ m3: guest.m3, result: r } = guest.onM2(m2));
|
|
303
|
+
if (deriveAddress(r.host.publicRaw) !== address) throw new HandshakeError('address_mismatch', 'the machine that answered does not own that address');
|
|
304
|
+
// Ten digits can be forged with enough work: the key first seen behind this address is pinned, and a
|
|
305
|
+
// different key behind it blocks the call until the person forgets the old computer on purpose.
|
|
306
|
+
const pinned = this.peers.pinnedFor(address);
|
|
307
|
+
if (pinned && pinned.identity.peerId !== r.host.peerId) {
|
|
308
|
+
throw new HandshakeError('address_key_changed', `WARNING: the computer at this address is not the one you connected to before (${pinned.identity.name || 'a known computer'}). Someone may be pretending to be it, so the call is blocked. If that computer was really reinstalled, forget it in your peers first.`);
|
|
309
|
+
}
|
|
310
|
+
if (r.host.peerId === this.identity.peerId) throw new HandshakeError('protocol', 'that is this machine');
|
|
311
|
+
if (this.peers.get(r.host.peerId)?.trust === 'blocked') throw new HandshakeError('blocked', 'you blocked this machine');
|
|
312
|
+
} catch (err) {
|
|
313
|
+
conn.send(failMessage(err.code || 'failed'));
|
|
314
|
+
conn.close('handshake failed');
|
|
315
|
+
this._audit({ type: 'address.dial.failed', address, reason: err.code || 'failed' });
|
|
316
|
+
throw err;
|
|
317
|
+
}
|
|
318
|
+
conn.send(guest.m3);
|
|
319
|
+
this.peers.upsert({ ...r.host, name: r.hostName }, { relation: this.peers.get(r.host.peerId)?.relation || 'remote', name: r.hostName });
|
|
320
|
+
const rec = this._openSession(conn, { ...r, peerId: r.host.peerId, accepted: true, confirmed: false, via: 'address' });
|
|
321
|
+
rec.sas = r.sas;
|
|
322
|
+
await new Promise((resolve, reject) => {
|
|
323
|
+
const timer = setTimeout(() => done(new HandshakeError('timeout', 'the machine did not answer')), this.handshakeMs);
|
|
324
|
+
const done = (err) => {
|
|
325
|
+
clearTimeout(timer);
|
|
326
|
+
rec.session.off('confirmed', ok);
|
|
327
|
+
rec.session.off('hsfail', onFail);
|
|
328
|
+
if (err) {
|
|
329
|
+
rec.session.close('handshake failed');
|
|
330
|
+
reject(err);
|
|
331
|
+
} else resolve();
|
|
332
|
+
};
|
|
333
|
+
const ok = () => done();
|
|
334
|
+
const onFail = (code) => done(new HandshakeError(code || 'failed', 'the machine refused the handshake'));
|
|
335
|
+
rec.session.once('confirmed', ok);
|
|
336
|
+
rec.session.on('hsfail', onFail);
|
|
337
|
+
});
|
|
338
|
+
this.peers.pinAddress(r.host.peerId, address);
|
|
339
|
+
this._audit({ type: 'address.dial', address, peerId: r.host.peerId, sessionId: rec.session.id });
|
|
340
|
+
this._online(rec);
|
|
341
|
+
this.emit('address.session', { peerId: r.host.peerId, sessionId: rec.session.id, name: r.hostName, sas: r.sas, role: 'guest' });
|
|
342
|
+
return { sessionId: rec.session.id, sas: r.sas, host: { peerId: r.host.peerId, name: r.hostName, fingerprint: r.host.fingerprint } };
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
/** The data the Accept dialog shows (PLAN 3.3 step 5). Not a single Yes button: sasMatches is required. */
|
|
346
|
+
joinDialog(req) {
|
|
347
|
+
const known = this.peers.get(req.peer.peerId);
|
|
348
|
+
return {
|
|
349
|
+
requestId: req.id,
|
|
350
|
+
peer: { peerId: req.peer.peerId, name: req.name, fingerprint: req.peer.fingerprint, knownBefore: known?.trust === 'known' },
|
|
351
|
+
sas: req.sas,
|
|
352
|
+
question: 'Do these words match on their screen?',
|
|
353
|
+
requestedCaps: req.requestedCaps,
|
|
354
|
+
toggles: joinDialogToggles(req.requestedCaps, req.offeredCaps),
|
|
355
|
+
expiresAt: new Date(req.expiresAt).toISOString(),
|
|
356
|
+
myFingerprint: this.identity.fingerprint,
|
|
357
|
+
};
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
listJoinRequests() {
|
|
361
|
+
return [...this.joinRequests.values()].map((r) => this.joinDialog(r));
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
/**
|
|
365
|
+
* The host's answer. accept needs sasMatches: true, the person's statement that the six words
|
|
366
|
+
* match on both screens. caps: [{ capability, minutes?, scope?, on? }] (the dialog toggles).
|
|
367
|
+
*/
|
|
368
|
+
answerJoin(requestId, { accept, sasMatches, caps = [], reason } = {}, origin = USER) {
|
|
369
|
+
if (origin.kind !== 'user') throw new CapError('forbidden', 'only a person answers a join request');
|
|
370
|
+
const req = this.joinRequests.get(requestId);
|
|
371
|
+
if (!req) throw new CapError('not_found', 'no such join request (it may have expired)');
|
|
372
|
+
const rec = this.sessions.get(req.sessionId);
|
|
373
|
+
if (accept && sasMatches !== true) throw new CapError('sas_unconfirmed', 'compare the six words with the other screen first');
|
|
374
|
+
this.joinRequests.delete(requestId);
|
|
375
|
+
if (!rec || rec.session.state !== 'open') {
|
|
376
|
+
this._audit({ type: 'join.lost', requestId, peerId: req.peer.peerId });
|
|
377
|
+
throw new CapError('not_found', 'the guest is gone');
|
|
378
|
+
}
|
|
379
|
+
if (!accept) {
|
|
380
|
+
const why = sasMatches === false ? 'sas_mismatch' : (typeof reason === 'string' ? reason.slice(0, 120) : 'refused');
|
|
381
|
+
rec.session.send('join.refuse', { reason: why });
|
|
382
|
+
this._audit({ type: 'join.refused', requestId, peerId: req.peer.peerId, reason: why });
|
|
383
|
+
this.emit('join.decided', { requestId, peerId: req.peer.peerId, accepted: false, reason: why });
|
|
384
|
+
setImmediate(() => rec.session.close(why));
|
|
385
|
+
return { accepted: false };
|
|
386
|
+
}
|
|
387
|
+
const peer = this.peers.upsert(req.peer, { trust: 'known', relation: 'guest', name: req.name });
|
|
388
|
+
rec.accepted = true;
|
|
389
|
+
const grants = [];
|
|
390
|
+
for (const c of caps) {
|
|
391
|
+
if (c && c.on === false) continue;
|
|
392
|
+
const g = makeGrant({ peerId: req.peer.peerId, capability: c.capability ?? c, scope: c.scope, minutes: c.minutes, sessionId: rec.session.id, trust: peer.trust, origin, now: this.now() });
|
|
393
|
+
this._storeGrant(g, rec);
|
|
394
|
+
grants.push(g);
|
|
395
|
+
}
|
|
396
|
+
const audit = this._audit({ type: 'join.accepted', requestId, peerId: req.peer.peerId, sas: true, grants: grants.map((g) => ({ id: g.id, name: g.capability.name, expiresAt: g.expiresAt, scope: g.scope })) });
|
|
397
|
+
rec.session.send('join.accept', { grants: grants.map(grantForWire), cityId: this.opts.cityId, machineId: this.opts.machineId });
|
|
398
|
+
rec.session.send('audit.ref', { entryHash: audit.hash, type: 'join.accepted' });
|
|
399
|
+
this._online(rec);
|
|
400
|
+
this.emit('join.decided', { requestId, peerId: req.peer.peerId, accepted: true, grants: grants.map(grantForWire) });
|
|
401
|
+
for (const g of grants) this.emit('grant.created', grantForWire(g));
|
|
402
|
+
return { accepted: true, grants: grants.map(grantForWire) };
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
// ------------------------------------------------------------------ joining (guest)
|
|
406
|
+
|
|
407
|
+
/**
|
|
408
|
+
* Joins with six words over conn. Resolves once the host has opened our hs.3 (or rejects with a
|
|
409
|
+
* HandshakeError: 'words' for wrong words or a burned invite). The result carries the SAS words
|
|
410
|
+
* to show, the host's fingerprint, and decision: a promise of the host's Accept or Refuse.
|
|
411
|
+
*/
|
|
412
|
+
async join(words, conn, { name, requestedCaps = [] } = {}) {
|
|
413
|
+
const w = readWords(words);
|
|
414
|
+
const d = await deriveInvite(w, this.iterations);
|
|
415
|
+
const guest = new InviteGuest({ identity: this.identity, invite: { topic: d.topic, psk: d.psk }, name: name || this.identity.name, requestedCaps });
|
|
416
|
+
let r;
|
|
417
|
+
try {
|
|
418
|
+
conn.send(guest.start());
|
|
419
|
+
const m2 = await nextText(conn, this.handshakeMs);
|
|
420
|
+
({ m3: guest.m3, result: r } = guest.onM2(m2));
|
|
421
|
+
if (this.peers.get(r.host.peerId)?.trust === 'blocked') throw new HandshakeError('blocked', 'you blocked this host');
|
|
422
|
+
} catch (err) {
|
|
423
|
+
conn.send(failMessage(err.code || 'failed'));
|
|
424
|
+
conn.close('handshake failed');
|
|
425
|
+
this._audit({ type: 'join.failed', reason: err.code || 'failed' });
|
|
426
|
+
throw err;
|
|
427
|
+
}
|
|
428
|
+
conn.send(guest.m3);
|
|
429
|
+
const rec = this._openSession(conn, { ...r, peerId: r.host.peerId, accepted: false, confirmed: false });
|
|
430
|
+
rec.joining = true;
|
|
431
|
+
rec.hostIdentity = { ...r.host, name: r.hostName };
|
|
432
|
+
// The host may answer in the same burst as its first frame: be ready for the decision now.
|
|
433
|
+
rec.decision = new Promise((resolve) => {
|
|
434
|
+
rec.decide = resolve;
|
|
435
|
+
});
|
|
436
|
+
await new Promise((resolve, reject) => {
|
|
437
|
+
const timer = setTimeout(() => fail(new HandshakeError('timeout', 'the host did not answer')), this.handshakeMs);
|
|
438
|
+
const ok = () => {
|
|
439
|
+
clearTimeout(timer);
|
|
440
|
+
rec.session.off('hsfail', onFail);
|
|
441
|
+
resolve();
|
|
442
|
+
};
|
|
443
|
+
const fail = (err) => {
|
|
444
|
+
clearTimeout(timer);
|
|
445
|
+
rec.session.off('confirmed', ok);
|
|
446
|
+
rec.session.off('hsfail', onFail);
|
|
447
|
+
rec.session.close('handshake failed');
|
|
448
|
+
reject(err);
|
|
449
|
+
};
|
|
450
|
+
const onFail = (code) => fail(new HandshakeError(code === 'refused' ? 'refused' : 'words', 'the words did not work'));
|
|
451
|
+
rec.session.once('confirmed', ok);
|
|
452
|
+
rec.session.on('hsfail', onFail);
|
|
453
|
+
}).catch((err) => {
|
|
454
|
+
this._audit({ type: 'join.failed', reason: err.code });
|
|
455
|
+
throw err;
|
|
456
|
+
});
|
|
457
|
+
this._audit({ type: 'join.sent', peerId: r.host.peerId, requested: guest.requestedCaps.map((c) => c.name) });
|
|
458
|
+
return {
|
|
459
|
+
sessionId: rec.session.id,
|
|
460
|
+
sas: r.sas,
|
|
461
|
+
host: { peerId: r.host.peerId, name: r.hostName, fingerprint: r.host.fingerprint },
|
|
462
|
+
offeredCaps: r.offeredCaps,
|
|
463
|
+
decision: rec.decision,
|
|
464
|
+
};
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
// ------------------------------------------------------------------ known peers
|
|
468
|
+
|
|
469
|
+
/** Reconnects to a known peer over conn (no words). Resolves with the session. */
|
|
470
|
+
async connect(peerId, conn) {
|
|
471
|
+
const peer = this.peers.get(peerId);
|
|
472
|
+
if (!peer) throw new HandshakeError('unknown_peer', 'not a known peer; use an invite');
|
|
473
|
+
if (peer.trust === 'blocked') throw new HandshakeError('blocked', 'this peer is blocked');
|
|
474
|
+
if (peer.trust !== 'known') throw new HandshakeError('unknown_peer', 'this peer was never accepted');
|
|
475
|
+
const hs = new KnownInitiator({ identity: this.identity, peer: { peerId, publicRaw: peer.identity.publicRaw } });
|
|
476
|
+
let r;
|
|
477
|
+
try {
|
|
478
|
+
conn.send(hs.start());
|
|
479
|
+
r = hs.onM2(await nextText(conn, this.handshakeMs));
|
|
480
|
+
} catch (err) {
|
|
481
|
+
conn.send(failMessage(err.code || 'failed'));
|
|
482
|
+
conn.close('handshake failed');
|
|
483
|
+
this._audit({ type: 'reconnect.failed', peerId, reason: err.code || 'failed' });
|
|
484
|
+
throw err;
|
|
485
|
+
}
|
|
486
|
+
const rec = this._openSession(conn, { ...r, peerId, role: peer.relation === 'guest' ? 'host' : 'guest', accepted: true, confirmed: true, via: 'known' });
|
|
487
|
+
rec.session.send('ping', {});
|
|
488
|
+
this._online(rec);
|
|
489
|
+
return rec.session;
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
_respondKnown(conn, m1) {
|
|
493
|
+
const hs = new KnownResponder({
|
|
494
|
+
identity: this.identity,
|
|
495
|
+
lookup: (id) => {
|
|
496
|
+
const p = this.peers.get(id);
|
|
497
|
+
return p ? { publicRaw: p.identity.publicRaw, trust: p.trust } : null;
|
|
498
|
+
},
|
|
499
|
+
});
|
|
500
|
+
let out;
|
|
501
|
+
try {
|
|
502
|
+
out = hs.onM1(m1);
|
|
503
|
+
} catch (err) {
|
|
504
|
+
conn.send(failMessage(err.code));
|
|
505
|
+
conn.close('handshake failed');
|
|
506
|
+
this._audit({ type: 'reconnect.refused', reason: err.code });
|
|
507
|
+
return null;
|
|
508
|
+
}
|
|
509
|
+
conn.send(out.m2);
|
|
510
|
+
const peer = this.peers.get(out.result.peer.peerId);
|
|
511
|
+
const rec = this._openSession(conn, { ...out.result, peerId: peer.identity.peerId, role: peer.relation === 'guest' ? 'host' : 'guest', accepted: true, confirmed: false, via: 'known' });
|
|
512
|
+
const timer = setTimeout(() => rec.session.state === 'open' && !rec.session.confirmed && rec.session.close('not confirmed'), this.handshakeMs);
|
|
513
|
+
timer.unref?.();
|
|
514
|
+
rec.session.once('confirmed', () => {
|
|
515
|
+
clearTimeout(timer);
|
|
516
|
+
this._online(rec);
|
|
517
|
+
});
|
|
518
|
+
return rec.session;
|
|
519
|
+
}
|
|
520
|
+
|
|
521
|
+
// ------------------------------------------------------------------ sessions
|
|
522
|
+
|
|
523
|
+
_openSession(conn, r) {
|
|
524
|
+
const session = new SecureSession({
|
|
525
|
+
id: r.sessionId,
|
|
526
|
+
peerId: r.peerId,
|
|
527
|
+
role: r.role,
|
|
528
|
+
conn,
|
|
529
|
+
sendKey: r.sendKey,
|
|
530
|
+
recvKey: r.recvKey,
|
|
531
|
+
now: this.now,
|
|
532
|
+
rekeyMessages: this.opts.rekeyMessages,
|
|
533
|
+
rekeyMs: this.opts.rekeyMs,
|
|
534
|
+
confirmed: r.confirmed,
|
|
535
|
+
});
|
|
536
|
+
conn.remote.peerId = r.peerId;
|
|
537
|
+
const rec = { session, peerId: r.peerId, accepted: r.accepted, via: r.via === 'known' ? 'known' : 'invite', grantsThere: new Map(), lastSeen: this.now(), online: false };
|
|
538
|
+
this.sessions.set(session.id, rec);
|
|
539
|
+
session.on('message', (msg, stream) => this._onMessage(rec, msg, stream));
|
|
540
|
+
session.on('refused', (x) => this.emit('frame.refused', { peerId: r.peerId, ...x }));
|
|
541
|
+
session.on('close', (reason) => this._sessionClosed(rec, reason));
|
|
542
|
+
return rec;
|
|
543
|
+
}
|
|
544
|
+
|
|
545
|
+
_online(rec) {
|
|
546
|
+
if (rec.online) return;
|
|
547
|
+
const old = this.byPeer.get(rec.peerId);
|
|
548
|
+
if (old && old !== rec.session.id) this.sessions.get(old)?.session.close('replaced by a new session');
|
|
549
|
+
this.byPeer.set(rec.peerId, rec.session.id);
|
|
550
|
+
rec.online = true;
|
|
551
|
+
this.peers.touch(rec.peerId);
|
|
552
|
+
this._audit({ type: 'session.open', peerId: rec.peerId, sessionId: rec.session.id, transport: rec.session.conn.transport });
|
|
553
|
+
// Tell the peer what it holds here (standing grants survive; session grants never do).
|
|
554
|
+
for (const g of this.grantsOf(rec.peerId, rec.session.id)) rec.session.send('cap.grant', { grant: grantForWire(g) });
|
|
555
|
+
if (this.profile) rec.session.send('profile.hello', this.profile);
|
|
556
|
+
// Liveness: a ping every pingMs, and a session that heard nothing for deadMs is closed.
|
|
557
|
+
rec.pingAt = this.now();
|
|
558
|
+
rec.keepalive = setInterval(() => {
|
|
559
|
+
if (rec.session.state !== 'open') return clearInterval(rec.keepalive);
|
|
560
|
+
if (this.now() - rec.lastSeen > this.deadMs) return rec.session.close('no answer');
|
|
561
|
+
if (this.now() - rec.pingAt >= this.pingMs) {
|
|
562
|
+
rec.pingAt = this.now();
|
|
563
|
+
rec.session.send('ping', {});
|
|
564
|
+
}
|
|
565
|
+
}, Math.min(1000, this.pingMs));
|
|
566
|
+
rec.keepalive.unref?.();
|
|
567
|
+
const resumed = this.seenOnline.has(rec.peerId);
|
|
568
|
+
this.seenOnline.add(rec.peerId);
|
|
569
|
+
this.emit('peer.online', { peerId: rec.peerId, sessionId: rec.session.id, resumed, via: rec.via });
|
|
570
|
+
}
|
|
571
|
+
|
|
572
|
+
_sessionClosed(rec, reason) {
|
|
573
|
+
clearInterval(rec.keepalive);
|
|
574
|
+
this.sessions.delete(rec.session.id);
|
|
575
|
+
rec.decide?.({ accepted: false, reason: `session closed: ${reason}` });
|
|
576
|
+
rec.decide = null;
|
|
577
|
+
for (const [id, req] of this.joinRequests) if (req.sessionId === rec.session.id) {
|
|
578
|
+
this.joinRequests.delete(id);
|
|
579
|
+
this.emit('join.gone', { requestId: id });
|
|
580
|
+
}
|
|
581
|
+
// Session grants end with their session.
|
|
582
|
+
for (const g of [...this.sessionGrants.values()]) if (g.sessionId === rec.session.id && !g.revokedAt) this._endGrant(g, 'session_ended', SYSTEM);
|
|
583
|
+
if (this.byPeer.get(rec.peerId) === rec.session.id) {
|
|
584
|
+
this.byPeer.delete(rec.peerId);
|
|
585
|
+
if (rec.online) {
|
|
586
|
+
this._audit({ type: 'session.close', peerId: rec.peerId, sessionId: rec.session.id, reason: String(reason).slice(0, 80) });
|
|
587
|
+
this.emit('peer.offline', { peerId: rec.peerId, sessionId: rec.session.id, reason });
|
|
588
|
+
}
|
|
589
|
+
}
|
|
590
|
+
}
|
|
591
|
+
|
|
592
|
+
sessionOf(peerId) {
|
|
593
|
+
const id = this.byPeer.get(peerId);
|
|
594
|
+
const rec = id && this.sessions.get(id);
|
|
595
|
+
return rec && rec.session.state === 'open' ? rec : null;
|
|
596
|
+
}
|
|
597
|
+
|
|
598
|
+
// ------------------------------------------------------------------ messages
|
|
599
|
+
|
|
600
|
+
_onMessage(rec, msg, stream) {
|
|
601
|
+
rec.lastSeen = this.now();
|
|
602
|
+
const { session } = rec;
|
|
603
|
+
const spec = messageSpec(msg.t);
|
|
604
|
+
if (!rec.accepted && !spec.pre) {
|
|
605
|
+
// Nothing but the join answer travels before the host accepted.
|
|
606
|
+
if (msg.t !== 'join.accept' && msg.t !== 'join.refuse') {
|
|
607
|
+
if (msg.t !== 'error') session.send('error', { code: 'not_accepted', message: 'the join was not accepted yet' }, { re: msg.id });
|
|
608
|
+
return;
|
|
609
|
+
}
|
|
610
|
+
}
|
|
611
|
+
switch (msg.t) {
|
|
612
|
+
case 'ping':
|
|
613
|
+
return session.send('pong', { rtt: undefined }, { re: msg.id });
|
|
614
|
+
case 'pong':
|
|
615
|
+
if (rec.pingAt) session.conn.rttMs = this.now() - rec.pingAt;
|
|
616
|
+
return;
|
|
617
|
+
case 'session.close':
|
|
618
|
+
return session.close(`closed by the peer: ${msg.body.reason}`);
|
|
619
|
+
case 'join.accept':
|
|
620
|
+
return this._joinAccepted(rec, msg);
|
|
621
|
+
case 'join.refuse':
|
|
622
|
+
if (!rec.joining) return;
|
|
623
|
+
rec.joining = false;
|
|
624
|
+
this._audit({ type: 'join.refused.by_host', peerId: rec.peerId, reason: msg.body.reason });
|
|
625
|
+
rec.decide?.({ accepted: false, reason: msg.body.reason });
|
|
626
|
+
rec.decide = null;
|
|
627
|
+
return session.close('refused');
|
|
628
|
+
case 'cap.grant': {
|
|
629
|
+
const g = readWireGrant(msg.body.grant, this.identity.peerId);
|
|
630
|
+
if (!g) return;
|
|
631
|
+
rec.grantsThere.set(g.id, g);
|
|
632
|
+
this._saveHeld(rec);
|
|
633
|
+
this.emit('held.granted', { peerId: rec.peerId, sessionId: session.id, grant: g });
|
|
634
|
+
return;
|
|
635
|
+
}
|
|
636
|
+
case 'cap.revoke': {
|
|
637
|
+
const gone = rec.grantsThere.get(msg.body.grantId);
|
|
638
|
+
if (!gone) return;
|
|
639
|
+
rec.grantsThere.delete(msg.body.grantId);
|
|
640
|
+
this._saveHeld(rec);
|
|
641
|
+
this.emit('held.revoked', { peerId: rec.peerId, grantId: msg.body.grantId, capability: gone.capability.name, reason: msg.body.reason });
|
|
642
|
+
return;
|
|
643
|
+
}
|
|
644
|
+
case 'cap.request': {
|
|
645
|
+
const id = rid('cr_');
|
|
646
|
+
const req = { id, peerId: rec.peerId, capability: msg.body.capability, reason: msg.body.reason, minutes: msg.body.minutes, at: new Date(this.now()).toISOString() };
|
|
647
|
+
this.capRequests.set(id, req);
|
|
648
|
+
while (this.capRequests.size > 50) this.capRequests.delete(this.capRequests.keys().next().value);
|
|
649
|
+
this._audit({ type: 'cap.requested', peerId: rec.peerId, capability: msg.body.capability.name });
|
|
650
|
+
this.emit('cap.request', req);
|
|
651
|
+
return;
|
|
652
|
+
}
|
|
653
|
+
case 'audit.ref':
|
|
654
|
+
this.emit('audit.ref', { peerId: rec.peerId, ...msg.body });
|
|
655
|
+
return;
|
|
656
|
+
case 'error':
|
|
657
|
+
this.emit('peer.error', { peerId: rec.peerId, re: msg.re, ...msg.body });
|
|
658
|
+
return;
|
|
659
|
+
case 'identity.rotated':
|
|
660
|
+
this.emit('identity.rotated', { peerId: rec.peerId, statement: msg.body });
|
|
661
|
+
return;
|
|
662
|
+
case 'profile.hello': {
|
|
663
|
+
// bounded and sanitized again here: a name of 32 characters, an avatar id from the allowlist, the PeerId fallback
|
|
664
|
+
const prof = publicProfile(msg.body, rec.peerId);
|
|
665
|
+
if (Number.isFinite(msg.body.achievements)) prof.achievements = msg.body.achievements;
|
|
666
|
+
this.peerProfiles.set(rec.peerId, prof);
|
|
667
|
+
this.peers.setProfile?.(rec.peerId, prof);
|
|
668
|
+
this.emit('peer.profile', { peerId: rec.peerId, profile: prof });
|
|
669
|
+
return;
|
|
670
|
+
}
|
|
671
|
+
default:
|
|
672
|
+
break;
|
|
673
|
+
}
|
|
674
|
+
let grant = null;
|
|
675
|
+
if (spec.cap) {
|
|
676
|
+
const cap = msg.t === 'city.cmd' && this.viewCommands.has(msg.body.type) ? 'city.view' : spec.cap;
|
|
677
|
+
// city.member includes everything city.view allows.
|
|
678
|
+
grant = this.can(rec.peerId, cap, session.id) || (cap === 'city.view' ? this.can(rec.peerId, 'city.member', session.id) : null);
|
|
679
|
+
if (!grant) {
|
|
680
|
+
this._auditRefused(rec.peerId, msg.t, cap);
|
|
681
|
+
// A type may answer a refusal in its own protocol (job.offer: job.reject not_granted).
|
|
682
|
+
const own = spec.refuse?.(msg.body);
|
|
683
|
+
if (own) return session.send(own[0], own[1], { re: msg.id });
|
|
684
|
+
return session.send('error', { code: 'not_granted', message: `${msg.t} needs ${cap}` }, { re: msg.id });
|
|
685
|
+
}
|
|
686
|
+
}
|
|
687
|
+
const handler = this.handlers.get(msg.t);
|
|
688
|
+
if (!handler) return session.send('error', { code: 'unsupported', message: `${msg.t} is not handled here` }, { re: msg.id });
|
|
689
|
+
const ctx = {
|
|
690
|
+
peerId: rec.peerId,
|
|
691
|
+
sessionId: session.id,
|
|
692
|
+
grant,
|
|
693
|
+
stream,
|
|
694
|
+
reply: (type, body) => session.send(type, body, { re: msg.id }),
|
|
695
|
+
};
|
|
696
|
+
Promise.resolve()
|
|
697
|
+
.then(() => handler(msg, ctx))
|
|
698
|
+
.catch((err) => session.state === 'open' && session.send('error', { code: typeof err?.code === 'string' ? err.code.slice(0, 40) : 'failed', message: String(err?.message || err).slice(0, 200) }, { re: msg.id }));
|
|
699
|
+
}
|
|
700
|
+
|
|
701
|
+
_auditRefused(peerId, type, cap) {
|
|
702
|
+
const key = `${peerId}|${type}`;
|
|
703
|
+
const last = this.refusedAudit.get(key) || 0;
|
|
704
|
+
if (this.now() - last < 10_000) return;
|
|
705
|
+
this.refusedAudit.set(key, this.now());
|
|
706
|
+
this._audit({ type: 'message.refused', peerId, message: type, capability: cap, code: 'not_granted' });
|
|
707
|
+
}
|
|
708
|
+
|
|
709
|
+
_joinAccepted(rec, msg) {
|
|
710
|
+
if (!rec.joining) return;
|
|
711
|
+
rec.joining = false;
|
|
712
|
+
rec.accepted = true;
|
|
713
|
+
const host = this.peers.upsert(rec.hostIdentity, { trust: 'known', relation: 'host' });
|
|
714
|
+
for (const raw of msg.body.grants) {
|
|
715
|
+
const g = readWireGrant(raw, this.identity.peerId);
|
|
716
|
+
if (g) rec.grantsThere.set(g.id, g);
|
|
717
|
+
}
|
|
718
|
+
if (msg.body.machineId) this.peers.setMachine(host.identity.peerId, msg.body.machineId);
|
|
719
|
+
this._saveHeld(rec);
|
|
720
|
+
this._audit({ type: 'join.accepted.by_host', peerId: rec.peerId, grants: [...rec.grantsThere.values()].map((g) => ({ id: g.id, name: g.capability.name })) });
|
|
721
|
+
this._online(rec);
|
|
722
|
+
rec.decide?.({ accepted: true, grants: [...rec.grantsThere.values()], cityId: msg.body.cityId, machineId: msg.body.machineId });
|
|
723
|
+
rec.decide = null;
|
|
724
|
+
}
|
|
725
|
+
|
|
726
|
+
_saveHeld(rec) {
|
|
727
|
+
const held = [...rec.grantsThere.values()].filter((g) => isActive(g, this.now()));
|
|
728
|
+
this.peers.setHeld(rec.peerId, held);
|
|
729
|
+
this.emit('held.changed', { peerId: rec.peerId, held });
|
|
730
|
+
}
|
|
731
|
+
|
|
732
|
+
/** A handler for a message type. One per type; it runs after the grant check. */
|
|
733
|
+
handle(type, fn) {
|
|
734
|
+
if (!messageSpec(type)) throw new TypeError(`register the message type ${type} first (messages.js registerMessage)`);
|
|
735
|
+
this.handlers.set(type, fn);
|
|
736
|
+
return () => this.handlers.get(type) === fn && this.handlers.delete(type);
|
|
737
|
+
}
|
|
738
|
+
|
|
739
|
+
/** Sends a message to a peer with an open, accepted session. Returns the message id. */
|
|
740
|
+
send(peerId, type, body = {}, opts) {
|
|
741
|
+
const rec = this.sessionOf(peerId);
|
|
742
|
+
if (!rec || !rec.accepted) throw new CapError('offline', 'no open session with this peer');
|
|
743
|
+
return rec.session.send(type, body, opts);
|
|
744
|
+
}
|
|
745
|
+
|
|
746
|
+
/** Asks a peer for a capability (asking is free; the peer rate limits it to 5 per minute). */
|
|
747
|
+
requestCapability(peerId, capability, reason = '', minutes) {
|
|
748
|
+
return this.send(peerId, 'cap.request', { capability: normalizeCapability(capability), reason: String(reason).slice(0, 200), minutes });
|
|
749
|
+
}
|
|
750
|
+
|
|
751
|
+
// ------------------------------------------------------------------ grants
|
|
752
|
+
|
|
753
|
+
_storeGrant(g, rec) {
|
|
754
|
+
if (g.scope === 'standing') this.peers.addGrant(g);
|
|
755
|
+
else this.sessionGrants.set(g.id, g);
|
|
756
|
+
if (rec) rec.session.state === 'open' && rec.accepted !== false && rec.online && rec.session.send('cap.grant', { grant: grantForWire(g) });
|
|
757
|
+
}
|
|
758
|
+
|
|
759
|
+
/** Active grants this engine gave a peer (standing ones and those of the given session). */
|
|
760
|
+
grantsOf(peerId, sessionId) {
|
|
761
|
+
const now = this.now();
|
|
762
|
+
const standing = this.peers.activeGrants(peerId, now);
|
|
763
|
+
const session = [...this.sessionGrants.values()].filter((g) => g.peerId === peerId && isActive(g, now) && (sessionId === undefined || g.sessionId === sessionId));
|
|
764
|
+
return [...standing, ...session];
|
|
765
|
+
}
|
|
766
|
+
|
|
767
|
+
/** The active grant for a capability that this engine gave the peer, or null. */
|
|
768
|
+
can(peerId, capability, sessionId) {
|
|
769
|
+
const peer = this.peers.get(peerId);
|
|
770
|
+
if (!peer || peer.trust === 'blocked') return null;
|
|
771
|
+
const sid = sessionId ?? this.byPeer.get(peerId);
|
|
772
|
+
return findGrant(this.grantsOf(peerId, sid), capability, this.now(), undefined);
|
|
773
|
+
}
|
|
774
|
+
|
|
775
|
+
/** Grants held on a remote peer (announced by it), active only. */
|
|
776
|
+
held(peerId) {
|
|
777
|
+
const now = this.now();
|
|
778
|
+
const rec = this.sessionOf(peerId);
|
|
779
|
+
const list = rec ? [...rec.grantsThere.values()] : (this.peers.get(peerId)?.held || []);
|
|
780
|
+
return list.filter((g) => isActive(g, now));
|
|
781
|
+
}
|
|
782
|
+
|
|
783
|
+
/** A person grants a capability to a known peer. */
|
|
784
|
+
grant(peerId, capability, { minutes, scope } = {}, origin = USER) {
|
|
785
|
+
if (!isPeerId(peerId)) throw new CapError('bad_request', 'bad peer id');
|
|
786
|
+
const peer = this.peers.get(peerId);
|
|
787
|
+
if (!peer) throw new CapError('not_found', 'not a known peer');
|
|
788
|
+
const rec = this.sessionOf(peerId);
|
|
789
|
+
const name = normalizeCapability(capability).name;
|
|
790
|
+
const sc = scope || (CAPABILITIES[name].standing ? 'standing' : 'session');
|
|
791
|
+
const g = makeGrant({ peerId, capability, scope: sc, minutes, sessionId: rec?.session.id, trust: peer.trust, origin, now: this.now() });
|
|
792
|
+
this._storeGrant(g, rec);
|
|
793
|
+
const a = this._audit({ type: 'grant', grantId: g.id, peerId, capability: g.capability.name, limits: g.capability.limits, scope: g.scope, expiresAt: g.expiresAt });
|
|
794
|
+
if (rec?.online) rec.session.send('audit.ref', { entryHash: a.hash, type: 'grant' });
|
|
795
|
+
this.emit('grant.created', grantForWire(g));
|
|
796
|
+
return grantForWire(g);
|
|
797
|
+
}
|
|
798
|
+
|
|
799
|
+
_findGrant(grantId) {
|
|
800
|
+
if (this.sessionGrants.has(grantId)) return this.sessionGrants.get(grantId);
|
|
801
|
+
for (const p of this.peers.list()) {
|
|
802
|
+
const g = p.grants.find((x) => x.id === grantId);
|
|
803
|
+
if (g) return g;
|
|
804
|
+
}
|
|
805
|
+
return null;
|
|
806
|
+
}
|
|
807
|
+
|
|
808
|
+
/** Revokes a grant now. The peer is told, and 'grant.revoked' lets modules stop the work it allowed. */
|
|
809
|
+
revoke(grantId, reason = 'revoked', origin = USER) {
|
|
810
|
+
if (origin.kind !== 'user' && origin.kind !== 'system') throw new CapError('forbidden', 'a peer cannot revoke here');
|
|
811
|
+
const g = this._findGrant(grantId);
|
|
812
|
+
if (!g) throw new CapError('not_found', 'no such grant');
|
|
813
|
+
if (g.revokedAt) return grantForWire(g);
|
|
814
|
+
this._endGrant(g, typeof reason === 'string' ? reason.slice(0, 120) : 'revoked', origin);
|
|
815
|
+
return grantForWire(g);
|
|
816
|
+
}
|
|
817
|
+
|
|
818
|
+
_endGrant(g, reason, origin) {
|
|
819
|
+
const ts = new Date(this.now()).toISOString();
|
|
820
|
+
// An expired grant keeps its expiresAt as the end; anything else is a revoke.
|
|
821
|
+
if (reason !== 'expired') {
|
|
822
|
+
if (g.scope === 'standing') this.peers.revokeGrant(g.id, ts);
|
|
823
|
+
g.revokedAt = ts;
|
|
824
|
+
}
|
|
825
|
+
this.ended.add(g.id);
|
|
826
|
+
const rec = this.sessionOf(g.peerId);
|
|
827
|
+
if (rec?.online) rec.session.send('cap.revoke', { grantId: g.id, reason });
|
|
828
|
+
const a = this._audit({ type: reason === 'expired' ? 'grant.expired' : 'revoke', grantId: g.id, peerId: g.peerId, capability: g.capability.name, reason, by: origin.kind });
|
|
829
|
+
if (rec?.online) rec.session.send('audit.ref', { entryHash: a.hash, type: 'revoke' });
|
|
830
|
+
this.emit('grant.revoked', { grant: grantForWire(g), reason });
|
|
831
|
+
}
|
|
832
|
+
|
|
833
|
+
/** Blocks a peer: every grant revoked, its session closed, no reconnect, no invite accepted. */
|
|
834
|
+
block(peerId, origin = USER) {
|
|
835
|
+
if (origin.kind !== 'user') throw new CapError('forbidden', 'only a person blocks a peer');
|
|
836
|
+
const peer = this.peers.get(peerId);
|
|
837
|
+
if (!peer) throw new CapError('not_found', 'not a known peer');
|
|
838
|
+
for (const g of this.grantsOf(peerId)) this._endGrant(g, 'blocked', origin);
|
|
839
|
+
this.peers.setTrust(peerId, 'blocked');
|
|
840
|
+
this._audit({ type: 'block', peerId });
|
|
841
|
+
this.emit('peer.blocked', { peerId });
|
|
842
|
+
this.sessionOf(peerId)?.session.close('blocked');
|
|
843
|
+
return true;
|
|
844
|
+
}
|
|
845
|
+
|
|
846
|
+
unblock(peerId, origin = USER) {
|
|
847
|
+
if (origin.kind !== 'user') throw new CapError('forbidden', 'only a person unblocks a peer');
|
|
848
|
+
if (!this.peers.setTrust(peerId, 'unknown')) throw new CapError('not_found', 'not a known peer');
|
|
849
|
+
this._audit({ type: 'unblock', peerId });
|
|
850
|
+
return true;
|
|
851
|
+
}
|
|
852
|
+
|
|
853
|
+
/** Forgets a peer: grants revoked, session closed, its file removed. It needs a new invite. */
|
|
854
|
+
forget(peerId, origin = USER) {
|
|
855
|
+
if (origin.kind !== 'user') throw new CapError('forbidden', 'only a person forgets a peer');
|
|
856
|
+
for (const g of this.grantsOf(peerId)) this._endGrant(g, 'forgotten', origin);
|
|
857
|
+
this.sessionOf(peerId)?.session.close('forgotten');
|
|
858
|
+
const gone = this.peers.remove(peerId);
|
|
859
|
+
if (gone) this._audit({ type: 'forget', peerId });
|
|
860
|
+
return gone;
|
|
861
|
+
}
|
|
862
|
+
|
|
863
|
+
/** Peer of PLAN section 2, for every stored peer. */
|
|
864
|
+
listPeers() {
|
|
865
|
+
return this.peers.list().map((p) => {
|
|
866
|
+
const rec = this.sessionOf(p.identity.peerId);
|
|
867
|
+
return {
|
|
868
|
+
identity: { peerId: p.identity.peerId, publicKey: p.identity.publicKey, name: p.identity.name, fingerprint: p.identity.fingerprint, createdAt: p.identity.createdAt },
|
|
869
|
+
trust: p.trust,
|
|
870
|
+
relation: p.relation,
|
|
871
|
+
firstSeen: p.firstSeen,
|
|
872
|
+
lastSeen: p.lastSeen,
|
|
873
|
+
online: !!rec?.online,
|
|
874
|
+
...(rec?.online ? { sessionId: rec.session.id, transport: rec.session.conn.transport, rttMs: rec.session.conn.rttMs } : {}),
|
|
875
|
+
grants: this.grantsOf(p.identity.peerId, rec?.session.id).map(grantForWire),
|
|
876
|
+
held: this.held(p.identity.peerId).map(grantForWire),
|
|
877
|
+
...(p.machineId ? { machineId: p.machineId } : {}),
|
|
878
|
+
...(this.profileOf(p.identity.peerId) ? { profile: this.profileOf(p.identity.peerId) } : {}),
|
|
879
|
+
};
|
|
880
|
+
});
|
|
881
|
+
}
|
|
882
|
+
|
|
883
|
+
listCapRequests() {
|
|
884
|
+
return [...this.capRequests.values()];
|
|
885
|
+
}
|
|
886
|
+
|
|
887
|
+
// ------------------------------------------------------------------ time
|
|
888
|
+
|
|
889
|
+
/** Expires grants, invites and join requests that are due. Runs every second. */
|
|
890
|
+
sweep() {
|
|
891
|
+
const now = this.now();
|
|
892
|
+
for (const inv of this.invites.sweep()) {
|
|
893
|
+
this._audit({ type: 'invite.expired', inviteId: inv.id });
|
|
894
|
+
this.emit('invite.expired', { inviteId: inv.id });
|
|
895
|
+
}
|
|
896
|
+
for (const [id, req] of this.joinRequests) if (now >= req.expiresAt) {
|
|
897
|
+
try {
|
|
898
|
+
this.answerJoin(id, { accept: false, reason: 'timeout' });
|
|
899
|
+
} catch {
|
|
900
|
+
this.joinRequests.delete(id);
|
|
901
|
+
}
|
|
902
|
+
}
|
|
903
|
+
const all = [...this.sessionGrants.values(), ...this.peers.list().flatMap((p) => p.grants)];
|
|
904
|
+
for (const g of all) {
|
|
905
|
+
if (g.revokedAt || this.ended.has(g.id) || g.expiresAt === null) continue;
|
|
906
|
+
if (Date.parse(g.expiresAt) <= now) this._endGrant(g, 'expired', SYSTEM);
|
|
907
|
+
}
|
|
908
|
+
for (const rec of this.sessions.values()) {
|
|
909
|
+
let changed = false;
|
|
910
|
+
for (const [id, g] of rec.grantsThere) if (!isActive(g, now)) {
|
|
911
|
+
rec.grantsThere.delete(id);
|
|
912
|
+
changed = true;
|
|
913
|
+
this.emit('held.revoked', { peerId: rec.peerId, grantId: id, capability: g.capability.name, reason: 'expired' });
|
|
914
|
+
}
|
|
915
|
+
if (changed) this._saveHeld(rec);
|
|
916
|
+
}
|
|
917
|
+
}
|
|
918
|
+
|
|
919
|
+
async close() {
|
|
920
|
+
clearInterval(this.timer);
|
|
921
|
+
for (const rec of [...this.sessions.values()]) rec.session.close('engine stopping');
|
|
922
|
+
this.started = false;
|
|
923
|
+
}
|
|
924
|
+
}
|
|
925
|
+
|
|
926
|
+
export { USER, SYSTEM, cleanName, normalizeCapList };
|