@aeolus-fleet/core 0.32.4 → 0.34.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/README.md +24 -0
- package/dist/adapters/cli/fleet-api.d.ts +33 -0
- package/dist/adapters/cli/fleet-api.js +64 -0
- package/dist/adapters/cli/fleet-api.js.map +1 -0
- package/dist/adapters/cli/fleet-recover-keys.d.ts +22 -0
- package/dist/adapters/cli/fleet-recover-keys.js +81 -0
- package/dist/adapters/cli/fleet-recover-keys.js.map +1 -0
- package/dist/adapters/cli/run.js +1 -1
- package/dist/adapters/cli/run.js.map +1 -1
- package/dist/adapters/crypto/age-recovery-identity.d.ts +9 -0
- package/dist/adapters/crypto/age-recovery-identity.js +45 -0
- package/dist/adapters/crypto/age-recovery-identity.js.map +1 -0
- package/dist/adapters/crypto/age-recovery-keys.d.ts +2 -0
- package/dist/adapters/crypto/age-recovery-keys.js +36 -0
- package/dist/adapters/crypto/age-recovery-keys.js.map +1 -0
- package/dist/adapters/crypto/payload-sealer.d.ts +2 -0
- package/dist/adapters/crypto/payload-sealer.js +48 -0
- package/dist/adapters/crypto/payload-sealer.js.map +1 -0
- package/dist/adapters/kms/aws-kms-key-vault.d.ts +13 -0
- package/dist/adapters/kms/aws-kms-key-vault.js +98 -0
- package/dist/adapters/kms/aws-kms-key-vault.js.map +1 -0
- package/dist/adapters/kms/company-key-vault.d.ts +9 -0
- package/dist/adapters/kms/company-key-vault.js +14 -0
- package/dist/adapters/kms/company-key-vault.js.map +1 -0
- package/dist/adapters/kms/no-key-vault.d.ts +7 -0
- package/dist/adapters/kms/no-key-vault.js +11 -0
- package/dist/adapters/kms/no-key-vault.js.map +1 -0
- package/dist/adapters/prisma/feature-flags.d.ts +7 -0
- package/dist/adapters/prisma/feature-flags.js +29 -0
- package/dist/adapters/prisma/feature-flags.js.map +1 -0
- package/dist/adapters/prisma/generated/browser.d.ts +16 -1
- package/dist/adapters/prisma/generated/client.d.ts +16 -1
- package/dist/adapters/prisma/generated/commonInputTypes.d.ts +187 -97
- package/dist/adapters/prisma/generated/enums.d.ts +5 -0
- package/dist/adapters/prisma/generated/enums.js +4 -0
- package/dist/adapters/prisma/generated/enums.js.map +1 -1
- package/dist/adapters/prisma/generated/internal/class.d.ts +22 -0
- package/dist/adapters/prisma/generated/internal/class.js +4 -4
- package/dist/adapters/prisma/generated/internal/class.js.map +1 -1
- package/dist/adapters/prisma/generated/internal/prismaNamespace.d.ts +203 -1
- package/dist/adapters/prisma/generated/internal/prismaNamespace.js +36 -2
- package/dist/adapters/prisma/generated/internal/prismaNamespace.js.map +1 -1
- package/dist/adapters/prisma/generated/internal/prismaNamespaceBrowser.d.ts +36 -0
- package/dist/adapters/prisma/generated/internal/prismaNamespaceBrowser.js +36 -2
- package/dist/adapters/prisma/generated/internal/prismaNamespaceBrowser.js.map +1 -1
- package/dist/adapters/prisma/generated/models/DataKey.d.ts +1503 -0
- package/dist/adapters/prisma/generated/models/DataKey.js +2 -0
- package/dist/adapters/prisma/generated/models/DataKey.js.map +1 -0
- package/dist/adapters/prisma/generated/models/Fleet.d.ts +2475 -2
- package/dist/adapters/prisma/generated/models/FleetFeatureFlag.d.ts +1117 -0
- package/dist/adapters/prisma/generated/models/FleetFeatureFlag.js +2 -0
- package/dist/adapters/prisma/generated/models/FleetFeatureFlag.js.map +1 -0
- package/dist/adapters/prisma/generated/models/Lease.d.ts +0 -7
- package/dist/adapters/prisma/generated/models/Message.d.ts +728 -62
- package/dist/adapters/prisma/generated/models/MessageDay.d.ts +1 -5
- package/dist/adapters/prisma/generated/models/Schedule.d.ts +657 -50
- package/dist/adapters/prisma/generated/models/Ship.d.ts +0 -3
- package/dist/adapters/prisma/generated/models.d.ts +2 -0
- package/dist/adapters/prisma/history-pruner.js +3 -2
- package/dist/adapters/prisma/history-pruner.js.map +1 -1
- package/dist/adapters/prisma/history.d.ts +2 -2
- package/dist/adapters/prisma/history.js +5 -7
- package/dist/adapters/prisma/history.js.map +1 -1
- package/dist/adapters/prisma/installation.js +14 -3
- package/dist/adapters/prisma/installation.js.map +1 -1
- package/dist/adapters/prisma/messaging.js +5 -3
- package/dist/adapters/prisma/messaging.js.map +1 -1
- package/dist/adapters/prisma/registry.js +2 -0
- package/dist/adapters/prisma/registry.js.map +1 -1
- package/dist/adapters/prisma/rows.d.ts +11 -0
- package/dist/adapters/prisma/rows.js +25 -2
- package/dist/adapters/prisma/rows.js.map +1 -1
- package/dist/adapters/prisma/schedules.d.ts +3 -0
- package/dist/adapters/prisma/schedules.js +5 -4
- package/dist/adapters/prisma/schedules.js.map +1 -1
- package/dist/adapters/prisma/sealings.d.ts +4 -0
- package/dist/adapters/prisma/sealings.js +211 -0
- package/dist/adapters/prisma/sealings.js.map +1 -0
- package/dist/adapters/prisma/unit-of-work.d.ts +4 -2
- package/dist/adapters/prisma/unit-of-work.js +4 -0
- package/dist/adapters/prisma/unit-of-work.js.map +1 -1
- package/dist/adapters/trpc/console.d.ts +13 -1
- package/dist/adapters/trpc/console.js +6 -3
- package/dist/adapters/trpc/console.js.map +1 -1
- package/dist/adapters/trpc/context.d.ts +16 -0
- package/dist/adapters/trpc/fleet.d.ts +150 -3
- package/dist/adapters/trpc/fleet.js +113 -11
- package/dist/adapters/trpc/fleet.js.map +1 -1
- package/dist/adapters/trpc/installation.d.ts +138 -2
- package/dist/adapters/trpc/installation.js +19 -3
- package/dist/adapters/trpc/installation.js.map +1 -1
- package/dist/adapters/trpc/listed-payload.d.ts +9 -0
- package/dist/adapters/trpc/listed-payload.js +8 -0
- package/dist/adapters/trpc/listed-payload.js.map +1 -0
- package/dist/adapters/trpc/router.d.ts +290 -3
- package/dist/adapters/trpc/ship-contract.js +1 -0
- package/dist/adapters/trpc/ship-contract.js.map +1 -1
- package/dist/adapters/trpc/ship.d.ts +11 -0
- package/dist/adapters/trpc/ship.js +3 -2
- package/dist/adapters/trpc/ship.js.map +1 -1
- package/dist/adapters/trpc/starting-prompt-text.js +2 -1
- package/dist/adapters/trpc/starting-prompt-text.js.map +1 -1
- package/dist/adapters/trpc/system.d.ts +10 -0
- package/dist/adapters/trpc/trpc.d.ts +15 -3
- package/dist/adapters/trpc/trpc.js +31 -6
- package/dist/adapters/trpc/trpc.js.map +1 -1
- package/dist/app.d.ts +3 -0
- package/dist/app.js +11 -1
- package/dist/app.js.map +1 -1
- package/dist/bin/aeolus-core.js +8 -1
- package/dist/bin/aeolus-core.js.map +1 -1
- package/dist/config.d.ts +11 -0
- package/dist/config.js +8 -2
- package/dist/config.js.map +1 -1
- package/dist/domain/messaging/add-to-meeting.d.ts +6 -2
- package/dist/domain/messaging/add-to-meeting.js +7 -4
- package/dist/domain/messaging/add-to-meeting.js.map +1 -1
- package/dist/domain/messaging/change-company-key.d.ts +46 -0
- package/dist/domain/messaging/change-company-key.js +74 -0
- package/dist/domain/messaging/change-company-key.js.map +1 -0
- package/dist/domain/messaging/change-meeting.d.ts +6 -2
- package/dist/domain/messaging/change-meeting.js +6 -4
- package/dist/domain/messaging/change-meeting.js.map +1 -1
- package/dist/domain/messaging/change-mic.d.ts +6 -1
- package/dist/domain/messaging/change-mic.js +6 -3
- package/dist/domain/messaging/change-mic.js.map +1 -1
- package/dist/domain/messaging/change-recovery-key.d.ts +45 -0
- package/dist/domain/messaging/change-recovery-key.js +68 -0
- package/dist/domain/messaging/change-recovery-key.js.map +1 -0
- package/dist/domain/messaging/company-key-check.d.ts +20 -0
- package/dist/domain/messaging/company-key-check.js +31 -0
- package/dist/domain/messaging/company-key-check.js.map +1 -0
- package/dist/domain/messaging/data-keys.d.ts +165 -0
- package/dist/domain/messaging/data-keys.js +275 -0
- package/dist/domain/messaging/data-keys.js.map +1 -0
- package/dist/domain/messaging/fleet-sealing.d.ts +75 -0
- package/dist/domain/messaging/fleet-sealing.js +21 -0
- package/dist/domain/messaging/fleet-sealing.js.map +1 -0
- package/dist/domain/messaging/key-unavailable.d.ts +5 -0
- package/dist/domain/messaging/key-unavailable.js +14 -0
- package/dist/domain/messaging/key-unavailable.js.map +1 -0
- package/dist/domain/messaging/key-vault.d.ts +61 -0
- package/dist/domain/messaging/key-vault.js +2 -0
- package/dist/domain/messaging/key-vault.js.map +1 -0
- package/dist/domain/messaging/meeting-notice.d.ts +15 -13
- package/dist/domain/messaging/meeting-notice.js +12 -3
- package/dist/domain/messaging/meeting-notice.js.map +1 -1
- package/dist/domain/messaging/message.d.ts +17 -4
- package/dist/domain/messaging/message.js +19 -5
- package/dist/domain/messaging/message.js.map +1 -1
- package/dist/domain/messaging/open-meeting.d.ts +8 -2
- package/dist/domain/messaging/open-meeting.js +6 -1
- package/dist/domain/messaging/open-meeting.js.map +1 -1
- package/dist/domain/messaging/payload-sealer.d.ts +39 -0
- package/dist/domain/messaging/payload-sealer.js +2 -0
- package/dist/domain/messaging/payload-sealer.js.map +1 -0
- package/dist/domain/messaging/ping-ship.d.ts +4 -1
- package/dist/domain/messaging/ping-ship.js +6 -4
- package/dist/domain/messaging/ping-ship.js.map +1 -1
- package/dist/domain/messaging/ports.d.ts +98 -1
- package/dist/domain/messaging/public.d.ts +4 -1
- package/dist/domain/messaging/public.js +2 -0
- package/dist/domain/messaging/public.js.map +1 -1
- package/dist/domain/messaging/push-receive-deliveries.d.ts +4 -0
- package/dist/domain/messaging/push-receive-deliveries.js +8 -2
- package/dist/domain/messaging/push-receive-deliveries.js.map +1 -1
- package/dist/domain/messaging/read-delivery.d.ts +6 -2
- package/dist/domain/messaging/read-delivery.js +7 -4
- package/dist/domain/messaging/read-delivery.js.map +1 -1
- package/dist/domain/messaging/read-meeting.d.ts +9 -3
- package/dist/domain/messaging/read-meeting.js +11 -4
- package/dist/domain/messaging/read-meeting.js.map +1 -1
- package/dist/domain/messaging/read-recovery-set.d.ts +34 -0
- package/dist/domain/messaging/read-recovery-set.js +43 -0
- package/dist/domain/messaging/read-recovery-set.js.map +1 -0
- package/dist/domain/messaging/read-sealing.d.ts +30 -0
- package/dist/domain/messaging/read-sealing.js +28 -0
- package/dist/domain/messaging/read-sealing.js.map +1 -0
- package/dist/domain/messaging/receive-deliveries.d.ts +18 -6
- package/dist/domain/messaging/receive-deliveries.js +18 -6
- package/dist/domain/messaging/receive-deliveries.js.map +1 -1
- package/dist/domain/messaging/receive-reply.d.ts +2 -0
- package/dist/domain/messaging/receive-reply.js +2 -1
- package/dist/domain/messaging/receive-reply.js.map +1 -1
- package/dist/domain/messaging/recover-keys.d.ts +56 -0
- package/dist/domain/messaging/recover-keys.js +83 -0
- package/dist/domain/messaging/recover-keys.js.map +1 -0
- package/dist/domain/messaging/recovery-key.d.ts +25 -0
- package/dist/domain/messaging/recovery-key.js +14 -0
- package/dist/domain/messaging/recovery-key.js.map +1 -0
- package/dist/domain/messaging/reply-to-message.d.ts +2 -0
- package/dist/domain/messaging/reply-to-message.js +4 -3
- package/dist/domain/messaging/reply-to-message.js.map +1 -1
- package/dist/domain/messaging/resend-delivery.d.ts +9 -2
- package/dist/domain/messaging/resend-delivery.js +26 -6
- package/dist/domain/messaging/resend-delivery.js.map +1 -1
- package/dist/domain/messaging/retired-participant.d.ts +5 -2
- package/dist/domain/messaging/retired-participant.js +2 -1
- package/dist/domain/messaging/retired-participant.js.map +1 -1
- package/dist/domain/messaging/rotate-data-keys.d.ts +33 -0
- package/dist/domain/messaging/rotate-data-keys.js +52 -0
- package/dist/domain/messaging/rotate-data-keys.js.map +1 -0
- package/dist/domain/messaging/schedule-message.d.ts +10 -2
- package/dist/domain/messaging/schedule-message.js +43 -15
- package/dist/domain/messaging/schedule-message.js.map +1 -1
- package/dist/domain/messaging/schedule.d.ts +18 -1
- package/dist/domain/messaging/schedule.js +15 -0
- package/dist/domain/messaging/schedule.js.map +1 -1
- package/dist/domain/messaging/seal-stored-payloads.d.ts +45 -0
- package/dist/domain/messaging/seal-stored-payloads.js +122 -0
- package/dist/domain/messaging/seal-stored-payloads.js.map +1 -0
- package/dist/domain/messaging/sealed-payload.d.ts +9 -0
- package/dist/domain/messaging/sealed-payload.js +15 -0
- package/dist/domain/messaging/sealed-payload.js.map +1 -0
- package/dist/domain/messaging/send-due-schedules.d.ts +6 -0
- package/dist/domain/messaging/send-due-schedules.js +63 -16
- package/dist/domain/messaging/send-due-schedules.js.map +1 -1
- package/dist/domain/messaging/send-message.d.ts +20 -6
- package/dist/domain/messaging/send-message.js +51 -18
- package/dist/domain/messaging/send-message.js.map +1 -1
- package/dist/domain/messaging/send-request.d.ts +4 -2
- package/dist/domain/messaging/send-request.js +3 -2
- package/dist/domain/messaging/send-request.js.map +1 -1
- package/dist/domain/messaging/turn-on-sealing.d.ts +61 -0
- package/dist/domain/messaging/turn-on-sealing.js +76 -0
- package/dist/domain/messaging/turn-on-sealing.js.map +1 -0
- package/dist/domain/registry/create-fleet.d.ts +7 -3
- package/dist/domain/registry/create-fleet.js +9 -2
- package/dist/domain/registry/create-fleet.js.map +1 -1
- package/dist/domain/registry/feature-flag.d.ts +66 -0
- package/dist/domain/registry/feature-flag.js +56 -0
- package/dist/domain/registry/feature-flag.js.map +1 -0
- package/dist/domain/registry/get-ship.d.ts +2 -0
- package/dist/domain/registry/get-ship.js +1 -0
- package/dist/domain/registry/get-ship.js.map +1 -1
- package/dist/domain/registry/installation-fleet.d.ts +3 -1
- package/dist/domain/registry/installation-fleet.js +3 -1
- package/dist/domain/registry/installation-fleet.js.map +1 -1
- package/dist/domain/registry/lease.d.ts +1 -1
- package/dist/domain/registry/lease.js +1 -1
- package/dist/domain/registry/ports.d.ts +15 -1
- package/dist/domain/registry/public.d.ts +2 -0
- package/dist/domain/registry/public.js +1 -0
- package/dist/domain/registry/public.js.map +1 -1
- package/dist/domain/registry/read-feature-flags.d.ts +16 -0
- package/dist/domain/registry/read-feature-flags.js +11 -0
- package/dist/domain/registry/read-feature-flags.js.map +1 -0
- package/dist/domain/registry/retire-ship.d.ts +6 -2
- package/dist/domain/registry/retire-ship.js +7 -4
- package/dist/domain/registry/retire-ship.js.map +1 -1
- package/dist/domain/registry/set-feature-flag.d.ts +34 -0
- package/dist/domain/registry/set-feature-flag.js +37 -0
- package/dist/domain/registry/set-feature-flag.js.map +1 -0
- package/dist/domain/shared/errors.d.ts +1 -1
- package/dist/domain/shared/errors.js.map +1 -1
- package/dist/domain/shared/history.d.ts +22 -21
- package/dist/domain/shared/plain-history.d.ts +45 -0
- package/dist/domain/shared/plain-history.js +35 -0
- package/dist/domain/shared/plain-history.js.map +1 -0
- package/dist/domain/shared/read-health.d.ts +14 -3
- package/dist/domain/shared/read-health.js +8 -4
- package/dist/domain/shared/read-health.js.map +1 -1
- package/dist/domain/shared/read-inbox-message.d.ts +7 -2
- package/dist/domain/shared/read-inbox-message.js +5 -1
- package/dist/domain/shared/read-inbox-message.js.map +1 -1
- package/dist/domain/shared/read-inbox-withdrawals.d.ts +9 -3
- package/dist/domain/shared/read-inbox-withdrawals.js +7 -3
- package/dist/domain/shared/read-inbox-withdrawals.js.map +1 -1
- package/dist/domain/shared/read-inbox.d.ts +14 -4
- package/dist/domain/shared/read-inbox.js +7 -3
- package/dist/domain/shared/read-inbox.js.map +1 -1
- package/dist/domain/shared/read-message.d.ts +11 -2
- package/dist/domain/shared/read-message.js +6 -2
- package/dist/domain/shared/read-message.js.map +1 -1
- package/dist/domain/shared/read-needs-attention.d.ts +6 -2
- package/dist/domain/shared/read-needs-attention.js +7 -5
- package/dist/domain/shared/read-needs-attention.js.map +1 -1
- package/dist/domain/shared/read-ship-messages.d.ts +10 -1
- package/dist/domain/shared/read-ship-messages.js +9 -3
- package/dist/domain/shared/read-ship-messages.js.map +1 -1
- package/dist/start.js +2 -0
- package/dist/start.js.map +1 -1
- package/dist/testing/container-images.d.ts +13 -6
- package/dist/testing/container-images.js +14 -7
- package/dist/testing/container-images.js.map +1 -1
- package/dist/wiring.d.ts +26 -0
- package/dist/wiring.js +57 -20
- package/dist/wiring.js.map +1 -1
- package/package.json +4 -2
- package/src/adapters/prisma/migrations/20261029120000_data_keys/migration.sql +23 -0
- package/src/adapters/prisma/migrations/20261029180000_sealed_messages/migration.sql +42 -0
- package/src/adapters/prisma/migrations/20261029200000_sealed_schedules/migration.sql +20 -0
- package/src/adapters/prisma/migrations/20261030090000_key_availability/migration.sql +18 -0
- package/src/adapters/prisma/migrations/20261030120000_keys_scope/migration.sql +64 -0
- package/src/adapters/prisma/migrations/20261031090000_recovery_key/migration.sql +11 -0
- package/src/adapters/prisma/migrations/20261101090000_sealing_progress/migration.sql +16 -0
- package/src/adapters/prisma/migrations/20261102090000_feature_flags/migration.sql +17 -0
- package/src/adapters/prisma/schema.prisma +104 -23
package/README.md
CHANGED
|
@@ -21,6 +21,7 @@ npx aeolus-core start
|
|
|
21
21
|
| `aeolus-core fleet:init --name "<fleet name>"` | See Server commands below |
|
|
22
22
|
| `aeolus-core sign-in` | See Server commands below |
|
|
23
23
|
| `aeolus-core operator:reset-password` | See Server commands below |
|
|
24
|
+
| `aeolus-core fleet:recover-keys --identity <file> --company-key <ARN>` | See Recovering a sealed fleet's keys below: run on the company's own computer, not the server |
|
|
24
25
|
|
|
25
26
|
Prisma Migrate holds a Postgres advisory lock while it migrates, so two processes starting at once never migrate at once: the second waits, then finds nothing left to apply. It never asks Prisma's servers for a newer version.
|
|
26
27
|
|
|
@@ -40,6 +41,8 @@ Environment variables, validated at startup (see `.env.example`):
|
|
|
40
41
|
| `TRUST_PROXY` | `false` | `true` behind a reverse proxy, so the sign-in and failed-register rate limits count per client address from `X-Forwarded-For`; without it every client behind the proxy shares one budget |
|
|
41
42
|
| `COOKIE_DOMAIN` | unset | The domain the console session cookie is set for, such as `fleet.example.com`, so a console on another host under it receives the cookie. Every host under it does, so pick the narrowest domain the console and the server share. Unset: the server's host only |
|
|
42
43
|
| `INSTALLATION_TOKEN` | unset | The token a hosting service presents to the installation procedures (at least 32 characters; see docs/architecture.md, "Installation"). Unset: they are off, as a self-hosted server needs |
|
|
44
|
+
| `KMS_REGION` | unset | The AWS KMS region of the installation's one KMS principal, which seals fleets under each company's own key (docs/decisions/0068-sealed-fleets.md). Its credentials come from the AWS SDK's own chain: `AWS_ACCESS_KEY_ID` and `AWS_SECRET_ACCESS_KEY`, or the role the server runs as. Unset: no fleet can be sealed |
|
|
45
|
+
| `KMS_ENDPOINT` | AWS's own | Another KMS endpoint, such as LocalStack's `http://localhost:4566`; needs `KMS_REGION` |
|
|
43
46
|
| `CONSOLE_ORIGIN` | `PUBLIC_URL`'s origin | The console's origin, such as `https://console.fleet.example.com`: the only origin a state-changing console call (sign-in, sign-out, a change made with the session cookie) is taken from, and the one origin allowed to call with credentials from another host (CORS). The default fits web and server behind one host. In development the console runs on `http://localhost:3000` (see `.env.example`) |
|
|
44
47
|
|
|
45
48
|
The browser calls the server's `/trpc` itself, at the address the web app runs with (`AEOLUS_SERVER_URL`, see the web README), so the console may run on another host: set `COOKIE_DOMAIN` and `CONSOLE_ORIGIN` for it. Another service the operator uses beside the console (served by its own server, under the configured cookie domain) checks a console session with `GET /trpc/console.session`, forwarding the browser's `Cookie` header: it answers `{ "fleetId": "flt_...", "expiresAt": "...", "kind": "operator" | "viewer", "scopes": [...] }`, or `UNAUTHORIZED` without a signed-in session; a viewer's scopes are `fleet:read` only, so serve it reads only. Only the cookie counts, never a crew token, and the call moves the session's expiry like any console call. A client that is no browser follows the fleet with `fleet.follow` (`fleet:read`; also `/api/v1/fleet/follow` and the MCP tool `fleet_follow`): `{ "afterSeq": n, "max": 1 to 100, "waitSeconds": 0 to 25 }`, all optional, answers `{ "events": [...], "lastSeq": n }`, the events after `afterSeq` oldest first, in the live stream's shape (never their details). Passing the answered `lastSeq` as the next `afterSeq` misses nothing across reconnects; without `afterSeq` it answers no events and the current `lastSeq`; with `waitSeconds` it waits while none has come and answers as soon as one commits. The console follows the fleet live through the `fleet.events` subscription, over a WebSocket opened on the same `/trpc` path, so a proxy in front must pass the upgrade on (Caddy does by itself). The upgrade carries the session cookie and is refused from any origin but `CONSOLE_ORIGIN`, as a state-changing call is. The ship page reads `fleet.ship`, `fleet.shipTimeline`, `fleet.shipMessages` (`{ "shipId": "shp_..." }`) and `fleet.message` (`{ "messageId": "msg_..." }`), each with `fleet:read`, which includes message payloads; a ship or message of another fleet is `NOT_FOUND`. A timeline and a message list hold the newest 200. A console call refused because the operator signed in somewhere else carries `refusal: "SIGNED_IN_ELSEWHERE"` in its error data, and a rate-limited sign-in carries `retryAt`, when the client may try again.
|
|
@@ -94,6 +97,27 @@ Run on the server, against the configured database, once it is migrated:
|
|
|
94
97
|
|
|
95
98
|
`operator:reset-password` reads its answers a line at a time from standard input, so a script can pipe them in. Like the API, the commands refuse any answer or name holding the character U+0000, naming what holds it, and change nothing. In this repository they run as `npm run fleet:init -w @aeolus-fleet/core -- --name "<fleet name>"`, `npm run sign-in -w @aeolus-fleet/core` and `npm run operator:reset-password -w @aeolus-fleet/core`, and `npm run db:migrate -w @aeolus-fleet/core` migrates.
|
|
96
99
|
|
|
100
|
+
## Recovering a sealed fleet's keys
|
|
101
|
+
|
|
102
|
+
When a sealed fleet's company key is lost and the fleet has a recovery key (decision 0068), the company runs, on its own computer with its offline key, never on the server:
|
|
103
|
+
|
|
104
|
+
```sh
|
|
105
|
+
npx aeolus-core fleet:recover-keys --identity recovery-key.txt --company-key arn:aws:kms:eu-west-1:111122223333:key/<new key id>
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
`--identity` is the age identity file holding the recovery key's private half (`AGE-SECRET-KEY-1...`); `--company-key` is the new company key, whose key policy grants the installation's principal for this fleet's id, as at turning sealing on. The command reads the fleet's recovery set (`fleet.recoverySet`), checks the identity is the fleet's recovery key, opens each data key locally and checks it against its check value, wraps each under the new key in the company's KMS for this fleet, and uploads them (`fleet.recoverKeys`). Nothing is uploaded unless every data key opened right, and the fleet changes nothing unless every wrap opens there to its key. No private key, data key or AWS credential leaves the computer, and none is printed.
|
|
109
|
+
|
|
110
|
+
It reaches the fleet over its API, and the company's KMS with the AWS SDK's own credentials on that computer (a profile, SSO or the environment), in the region the key's ARN names (else `AWS_REGION`):
|
|
111
|
+
|
|
112
|
+
| Variable | Holds |
|
|
113
|
+
| --- | --- |
|
|
114
|
+
| `AEOLUS_URL` | The fleet's address, such as `https://fleet.example.com` |
|
|
115
|
+
| `AEOLUS_CREW_TOKEN` | The crew token of a ship holding `fleet:keys` |
|
|
116
|
+
| `AEOLUS_ACCOUNT_TOKEN` | Optional, with `AEOLUS_CREW_TOKEN`: an account's token, so the account holding `fleet:keys` acts through that ship |
|
|
117
|
+
| `AEOLUS_INSTALLATION_TOKEN`, `AEOLUS_FLEET` | Instead, on a self-hosted server: the installation token and the fleet id it acts in |
|
|
118
|
+
|
|
119
|
+
It exits 0 when the keys are recovered, 1 when the fleet or the KMS refuses (a fleet sealed without a recovery key `NO_RECOVERY_KEY`, an identity or wrap that does not match `RECOVERY_KEYS_MISMATCH`, a new key not bound to the fleet `KEY_NOT_BOUND_TO_FLEET`), and 2 for wrong usage.
|
|
120
|
+
|
|
97
121
|
argo signs in to the console with the link; in Settings it can then set an email and password (at least 12 characters) to sign in with instead. Either way the session crews `argo`, which has no secret. The password is stored as an Argon2id hash. The console keeps only a session cookie (httpOnly, Secure, SameSite=Strict), valid 30 days after its last use. A wrong email and a wrong password get the same answer.
|
|
98
122
|
|
|
99
123
|
## Ships
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { type Result } from '../../domain/shared/result.js';
|
|
3
|
+
/** The environment variables a command reaches the fleet with. */
|
|
4
|
+
export declare const FLEET_API_VARIABLES: {
|
|
5
|
+
readonly url: "AEOLUS_URL";
|
|
6
|
+
readonly crewToken: "AEOLUS_CREW_TOKEN";
|
|
7
|
+
readonly accountToken: "AEOLUS_ACCOUNT_TOKEN";
|
|
8
|
+
readonly installationToken: "AEOLUS_INSTALLATION_TOKEN";
|
|
9
|
+
readonly fleet: "AEOLUS_FLEET";
|
|
10
|
+
};
|
|
11
|
+
/** The fleet refused the call: the API's code (such as `CONFLICT`) and its message. */
|
|
12
|
+
export interface FleetApiRefusal {
|
|
13
|
+
readonly kind: 'refused';
|
|
14
|
+
readonly code: string;
|
|
15
|
+
readonly message: string;
|
|
16
|
+
}
|
|
17
|
+
export interface FleetApi {
|
|
18
|
+
query<T>(procedure: string, output: z.ZodType<T>): Promise<Result<T, FleetApiRefusal>>;
|
|
19
|
+
mutation<T>(procedure: string, call: {
|
|
20
|
+
input: unknown;
|
|
21
|
+
output: z.ZodType<T>;
|
|
22
|
+
}): Promise<Result<T, FleetApiRefusal>>;
|
|
23
|
+
}
|
|
24
|
+
/** Where the fleet is and the headers that say who calls, from the environment; else what is missing. */
|
|
25
|
+
export declare function fleetApiCredentialsOf(environment: Readonly<Record<string, string | undefined>>): Result<{
|
|
26
|
+
url: string;
|
|
27
|
+
headers: Record<string, string>;
|
|
28
|
+
}, string>;
|
|
29
|
+
export declare function createFleetApi(deps: {
|
|
30
|
+
url: string;
|
|
31
|
+
headers: Readonly<Record<string, string>>;
|
|
32
|
+
fetch: typeof fetch;
|
|
33
|
+
}): FleetApi;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A command on the company's own computer calls the fleet's tRPC API, the one
|
|
3
|
+
* door (decision 0004), as any other client does, over HTTPS, with the
|
|
4
|
+
* credentials the API already takes (decision 0057): a crew token of a ship,
|
|
5
|
+
* an account's token through that ship, or the installation token with the
|
|
6
|
+
* fleet it acts in. It holds no logic of its own.
|
|
7
|
+
*/
|
|
8
|
+
import { ACCOUNT_TOKEN_HEADER, FLEET_HEADER } from '@aeolus-fleet/common';
|
|
9
|
+
import { z } from 'zod';
|
|
10
|
+
import { err, ok } from '../../domain/shared/result.js';
|
|
11
|
+
import { INSTALLATION_TOKEN_HEADER } from '../trpc/installation-token.js';
|
|
12
|
+
/** The environment variables a command reaches the fleet with. */
|
|
13
|
+
export const FLEET_API_VARIABLES = {
|
|
14
|
+
url: 'AEOLUS_URL',
|
|
15
|
+
crewToken: 'AEOLUS_CREW_TOKEN',
|
|
16
|
+
accountToken: 'AEOLUS_ACCOUNT_TOKEN',
|
|
17
|
+
installationToken: 'AEOLUS_INSTALLATION_TOKEN',
|
|
18
|
+
fleet: 'AEOLUS_FLEET',
|
|
19
|
+
};
|
|
20
|
+
const answerSchema = z.union([
|
|
21
|
+
z.object({ result: z.object({ data: z.unknown() }) }),
|
|
22
|
+
z.object({ error: z.object({ message: z.string(), data: z.object({ code: z.string() }).optional() }) }),
|
|
23
|
+
]);
|
|
24
|
+
/** Where the fleet is and the headers that say who calls, from the environment; else what is missing. */
|
|
25
|
+
export function fleetApiCredentialsOf(environment) {
|
|
26
|
+
const { url, crewToken, accountToken, installationToken, fleet } = FLEET_API_VARIABLES;
|
|
27
|
+
const fleetUrl = environment[url];
|
|
28
|
+
if (fleetUrl === undefined || fleetUrl === '') {
|
|
29
|
+
return err(`Set ${url} to the fleet's address, such as https://fleet.example.com`);
|
|
30
|
+
}
|
|
31
|
+
const headers = {};
|
|
32
|
+
const crew = environment[crewToken];
|
|
33
|
+
const account = environment[accountToken];
|
|
34
|
+
const installation = environment[installationToken];
|
|
35
|
+
const actingIn = environment[fleet];
|
|
36
|
+
if (crew !== undefined && crew !== '') {
|
|
37
|
+
headers.authorization = `Bearer ${crew}`;
|
|
38
|
+
if (account !== undefined && account !== '') {
|
|
39
|
+
headers[ACCOUNT_TOKEN_HEADER] = account;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
else if (installation !== undefined && installation !== '' && actingIn !== undefined && actingIn !== '') {
|
|
43
|
+
headers[INSTALLATION_TOKEN_HEADER] = installation;
|
|
44
|
+
headers[FLEET_HEADER] = actingIn;
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
return err(`Set ${crewToken} (a ship holding fleet:keys, with ${accountToken} for an account through it), or ${installationToken} with ${fleet} on a self-hosted server`);
|
|
48
|
+
}
|
|
49
|
+
return ok({ url: fleetUrl.replace(/\/+$/, ''), headers });
|
|
50
|
+
}
|
|
51
|
+
export function createFleetApi(deps) {
|
|
52
|
+
const answered = async (response, output) => {
|
|
53
|
+
const answer = answerSchema.parse(await response.json());
|
|
54
|
+
if ('error' in answer) {
|
|
55
|
+
return err({ kind: 'refused', code: answer.error.data?.code ?? String(response.status), message: answer.error.message });
|
|
56
|
+
}
|
|
57
|
+
return ok(output.parse(answer.result.data));
|
|
58
|
+
};
|
|
59
|
+
return {
|
|
60
|
+
query: async (procedure, output) => answered(await deps.fetch(`${deps.url}/trpc/${procedure}`, { headers: deps.headers }), output),
|
|
61
|
+
mutation: async (procedure, { input, output }) => answered(await deps.fetch(`${deps.url}/trpc/${procedure}`, { method: 'POST', headers: { ...deps.headers, 'content-type': 'application/json' }, body: JSON.stringify(input) }), output),
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=fleet-api.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fleet-api.js","sourceRoot":"","sources":["../../../src/adapters/cli/fleet-api.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAC1E,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,GAAG,EAAE,EAAE,EAAe,MAAM,+BAA+B,CAAC;AACrE,OAAO,EAAE,yBAAyB,EAAE,MAAM,+BAA+B,CAAC;AAE1E,kEAAkE;AAClE,MAAM,CAAC,MAAM,mBAAmB,GAAG;IACjC,GAAG,EAAE,YAAY;IACjB,SAAS,EAAE,mBAAmB;IAC9B,YAAY,EAAE,sBAAsB;IACpC,iBAAiB,EAAE,2BAA2B;IAC9C,KAAK,EAAE,cAAc;CACb,CAAC;AAcX,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC;IAC3B,CAAC,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,EAAE,CAAC;IACrD,CAAC,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,CAAC,CA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AAE,EAAE,EAAE,CAC/C,QAAQ,CACN,MAAM,IAAI,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,GAAG,SAAS,SAAS,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,EAAE,GAAG,IAAI,CAAC,OAAO,EAAE,cAAc,EAAE,kBAAkB,EAAE,EAAE,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,CAAC,EACpK,MAAM,CACP;KACJ,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { KeyVault } from '../../domain/messaging/key-vault.js';
|
|
2
|
+
import type { CommandIo, ExitCode } from './io.js';
|
|
3
|
+
/**
|
|
4
|
+
* `fleet:recover-keys`: recovers a sealed fleet's data keys under a new
|
|
5
|
+
* company key when the old one is lost (decision 0068, B15), run on the
|
|
6
|
+
* company's own computer, never on the server. It reads the fleet's recovery
|
|
7
|
+
* set, opens each data key with the offline recovery key's private half (an
|
|
8
|
+
* age identity file), checks it against its check value, wraps it under the
|
|
9
|
+
* new company key in the company's own KMS for this fleet, with the
|
|
10
|
+
* company's own AWS credentials, and uploads the wraps. No private key, data
|
|
11
|
+
* key or company credential leaves this computer, nor is any printed. Nothing
|
|
12
|
+
* is uploaded unless every data key opened right; the fleet changes nothing
|
|
13
|
+
* unless every wrap opens there too.
|
|
14
|
+
*/
|
|
15
|
+
export declare function fleetRecoverKeys(args: string[], deps: {
|
|
16
|
+
environment: Readonly<Record<string, string | undefined>>;
|
|
17
|
+
fetch: typeof fetch;
|
|
18
|
+
readFile: (path: string) => Promise<string>;
|
|
19
|
+
/** The company's own KMS, for the new company key, as its credentials on this computer reach it. */
|
|
20
|
+
vaultFor: (companyKey: string) => KeyVault;
|
|
21
|
+
io: CommandIo;
|
|
22
|
+
}): Promise<ExitCode>;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { parseArgs } from 'node:util';
|
|
2
|
+
import { recoverKeysOutputSchema, recoverySetOutputSchema } from '@aeolus-fleet/common';
|
|
3
|
+
import { aesGcmPayloadSealer } from '../crypto/payload-sealer.js';
|
|
4
|
+
import { recoveryIdentityOf } from '../crypto/age-recovery-identity.js';
|
|
5
|
+
import { createFleetApi, fleetApiCredentialsOf } from './fleet-api.js';
|
|
6
|
+
const USAGE = 'Usage: aeolus-core fleet:recover-keys --identity <age identity file> --company-key <new company key ARN>';
|
|
7
|
+
/**
|
|
8
|
+
* `fleet:recover-keys`: recovers a sealed fleet's data keys under a new
|
|
9
|
+
* company key when the old one is lost (decision 0068, B15), run on the
|
|
10
|
+
* company's own computer, never on the server. It reads the fleet's recovery
|
|
11
|
+
* set, opens each data key with the offline recovery key's private half (an
|
|
12
|
+
* age identity file), checks it against its check value, wraps it under the
|
|
13
|
+
* new company key in the company's own KMS for this fleet, with the
|
|
14
|
+
* company's own AWS credentials, and uploads the wraps. No private key, data
|
|
15
|
+
* key or company credential leaves this computer, nor is any printed. Nothing
|
|
16
|
+
* is uploaded unless every data key opened right; the fleet changes nothing
|
|
17
|
+
* unless every wrap opens there too.
|
|
18
|
+
*/
|
|
19
|
+
export async function fleetRecoverKeys(args, deps) {
|
|
20
|
+
const { io } = deps;
|
|
21
|
+
let identityFile;
|
|
22
|
+
let companyKey;
|
|
23
|
+
try {
|
|
24
|
+
const { values } = parseArgs({ args, options: { identity: { type: 'string' }, 'company-key': { type: 'string' } }, strict: true });
|
|
25
|
+
identityFile = values.identity;
|
|
26
|
+
companyKey = values['company-key'];
|
|
27
|
+
}
|
|
28
|
+
catch (error) {
|
|
29
|
+
io.err(`${error instanceof Error ? error.message : String(error)}\n${USAGE}`);
|
|
30
|
+
return 2;
|
|
31
|
+
}
|
|
32
|
+
if (identityFile === undefined || companyKey === undefined) {
|
|
33
|
+
io.err(USAGE);
|
|
34
|
+
return 2;
|
|
35
|
+
}
|
|
36
|
+
const credentials = fleetApiCredentialsOf(deps.environment);
|
|
37
|
+
if (!credentials.isOk) {
|
|
38
|
+
io.err(credentials.error);
|
|
39
|
+
return 2;
|
|
40
|
+
}
|
|
41
|
+
const identity = await recoveryIdentityOf(await deps.readFile(identityFile));
|
|
42
|
+
if (identity === undefined) {
|
|
43
|
+
io.err(`${identityFile} holds no single age X25519 identity (a line starting AGE-SECRET-KEY-1). Nothing changed.`);
|
|
44
|
+
return 1;
|
|
45
|
+
}
|
|
46
|
+
const api = createFleetApi({ ...credentials.value, fetch: deps.fetch });
|
|
47
|
+
const set = await api.query('fleet.recoverySet', recoverySetOutputSchema);
|
|
48
|
+
if (!set.isOk) {
|
|
49
|
+
io.err(set.error.message);
|
|
50
|
+
return 1;
|
|
51
|
+
}
|
|
52
|
+
const { fleetId, recoveryKeyFingerprint } = set.value;
|
|
53
|
+
if (identity.fingerprint !== recoveryKeyFingerprint) {
|
|
54
|
+
io.err(`${identityFile} is not this fleet's recovery key: the fleet's is ${recoveryKeyFingerprint}, this one is ${identity.fingerprint}. Nothing changed.`);
|
|
55
|
+
return 1;
|
|
56
|
+
}
|
|
57
|
+
const vault = deps.vaultFor(companyKey);
|
|
58
|
+
const dataKeys = [];
|
|
59
|
+
for (const { id, wrappedByRecoveryKey, checkValue } of set.value.dataKeys) {
|
|
60
|
+
const material = await identity.open(new Uint8Array(Buffer.from(wrappedByRecoveryKey, 'base64')));
|
|
61
|
+
if (material === undefined || !Buffer.from(aesGcmPayloadSealer.checkValue(material)).equals(Buffer.from(checkValue, 'base64'))) {
|
|
62
|
+
io.err(`Data key ${id} does not open to the key its check value names. Nothing changed.`);
|
|
63
|
+
return 1;
|
|
64
|
+
}
|
|
65
|
+
const wrapped = await vault.wrap({ fleetId, companyKey }, material);
|
|
66
|
+
material.fill(0);
|
|
67
|
+
if (!wrapped.isOk) {
|
|
68
|
+
io.err(`Your KMS did not wrap data key ${id} under ${companyKey}: ${wrapped.error.reason}. Check its key policy and your AWS credentials. Nothing changed.`);
|
|
69
|
+
return 1;
|
|
70
|
+
}
|
|
71
|
+
dataKeys.push({ id, wrappedByCompanyKey: Buffer.from(wrapped.value).toString('base64') });
|
|
72
|
+
}
|
|
73
|
+
const recovered = await api.mutation('fleet.recoverKeys', { input: { companyKey, dataKeys }, output: recoverKeysOutputSchema });
|
|
74
|
+
if (!recovered.isOk) {
|
|
75
|
+
io.err(recovered.error.message);
|
|
76
|
+
return 1;
|
|
77
|
+
}
|
|
78
|
+
io.out(`Recovered ${String(dataKeys.length)} data keys of fleet ${fleetId} under ${recovered.value.companyKey}. Every sealed payload opens again.`);
|
|
79
|
+
return 0;
|
|
80
|
+
}
|
|
81
|
+
//# sourceMappingURL=fleet-recover-keys.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fleet-recover-keys.js","sourceRoot":"","sources":["../../../src/adapters/cli/fleet-recover-keys.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAEtC,OAAO,EAAE,uBAAuB,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AAGxF,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAClE,OAAO,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAC;AACxE,OAAO,EAAE,cAAc,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AAGvE,MAAM,KAAK,GAAG,0GAA0G,CAAC;AAEzH;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CACpC,IAAc,EACd,IAOC;IAED,MAAM,EAAE,EAAE,EAAE,GAAG,IAAI,CAAC;IAEpB,IAAI,YAAgC,CAAC;IACrC,IAAI,UAA8B,CAAC;IACnC,IAAI,CAAC;QACH,MAAM,EAAE,MAAM,EAAE,GAAG,SAAS,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,QAAQ,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,aAAa,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EA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AAC;YAClB,EAAE,CAAC,GAAG,CAAC,kCAAkC,EAAE,UAAU,UAAU,KAAK,OAAO,CAAC,KAAK,CAAC,MAAM,mEAAmE,CAAC,CAAC;YAC7J,OAAO,CAAC,CAAC;QACX,CAAC;QACD,QAAQ,CAAC,IAAI,CAAC,EAAE,EAAE,EAAE,mBAAmB,EAAE,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;IAC5F,CAAC;IAED,MAAM,SAAS,GAAG,MAAM,GAAG,CAAC,QAAQ,CAAC,mBAAmB,EAAE,EAAE,KAAK,EAAE,EAAE,UAAU,EAAE,QAAQ,EAAE,EAAE,MAAM,EAAE,uBAAuB,EAAE,CAAC,CAAC;IAChI,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,CAAC;QACpB,EAAE,CAAC,GAAG,CAAC,SAAS,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QAChC,OAAO,CAAC,CAAC;IACX,CAAC;IACD,EAAE,CAAC,GAAG,CAAC,aAAa,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,uBAAuB,OAAO,UAAU,SAAS,CAAC,KAAK,CAAC,UAAU,qCAAqC,CAAC,CAAC;IACpJ,OAAO,CAAC,CAAC;AACX,CAAC"}
|
package/dist/adapters/cli/run.js
CHANGED
|
@@ -30,7 +30,7 @@ export function runCommand(args, command) {
|
|
|
30
30
|
const config = loadConfig(process.env);
|
|
31
31
|
const prisma = createPrismaClient(config.databaseUrl);
|
|
32
32
|
try {
|
|
33
|
-
return await command({ args, useCases: createUseCases({ prisma }), consoleOrigin: config.consoleOrigin, io });
|
|
33
|
+
return await command({ args, useCases: createUseCases({ prisma, hasInstallation: config.installationToken !== undefined }), consoleOrigin: config.consoleOrigin, io });
|
|
34
34
|
}
|
|
35
35
|
finally {
|
|
36
36
|
await prisma.$disconnect();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,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AC;YAAS,CAAC;QACT,EAAE,CAAC,KAAK,EAAE,CAAC;IACb,CAAC;IACD,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACrB,CAAC;AAED,qFAAqF;AACrF,MAAM,UAAU,UAAU,CACxB,IAAc,EACd,OAAiH;IAEjH,OAAO,aAAa,CAAC,KAAK,EAAE,EAAE,EAAE,EAAE;QAChC,MAAM,MAAM,GAAG,UAAU,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QACvC,MAAM,MAAM,GAAG,kBAAkB,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;QACtD,IAAI,CAAC;YACH,OAAO,MAAM,OAAO,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,cAAc,CAAC,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,CAAC,iBAAiB,KAAK,SAAS,EAAE,CAAC,EAAE,aAAa,EAAE,MAAM,CAAC,aAAa,EAAE,EAAE,EAAE,CAAC,CAAC;QACzK,CAAC;gBAAS,CAAC;YACT,MAAM,MAAM,CAAC,WAAW,EAAE,CAAC;QAC7B,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { DataKeyMaterial, WrappedDataKey } from '../../domain/messaging/key-vault.js';
|
|
2
|
+
export interface RecoveryIdentity {
|
|
3
|
+
/** The fingerprint of its public half, as the fleet names its recovery key. */
|
|
4
|
+
readonly fingerprint: string;
|
|
5
|
+
/** The data key a wrap to its public half holds; none for a wrap it does not open. */
|
|
6
|
+
open(wrapped: WrappedDataKey): Promise<DataKeyMaterial | undefined>;
|
|
7
|
+
}
|
|
8
|
+
/** The recovery identity an age identity file holds; none when it holds no single X25519 identity. */
|
|
9
|
+
export declare function recoveryIdentityOf(file: string): Promise<RecoveryIdentity | undefined>;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The private half of a recovery key (decision 0068, B15), as the company
|
|
3
|
+
* keeps it offline in an `age` identity file: read only by the recovery
|
|
4
|
+
* command on the company's own computer, never sent, printed or logged. It
|
|
5
|
+
* opens the data keys core wrapped to the recovery key's public half.
|
|
6
|
+
*/
|
|
7
|
+
import { Decrypter, identityToRecipient } from 'age-encryption';
|
|
8
|
+
import { ageRecoveryKeys } from './age-recovery-keys.js';
|
|
9
|
+
/** An X25519 identity line of an age identity file; comment lines start with `#`. */
|
|
10
|
+
const X25519_IDENTITY = /^AGE-SECRET-KEY-1[0-9A-Z]+$/;
|
|
11
|
+
/** The recovery identity an age identity file holds; none when it holds no single X25519 identity. */
|
|
12
|
+
export async function recoveryIdentityOf(file) {
|
|
13
|
+
const identities = file.split(/\r?\n/).map((line) => line.trim()).filter((line) => X25519_IDENTITY.test(line));
|
|
14
|
+
const [identity] = identities;
|
|
15
|
+
if (identity === undefined || identities.length > 1) {
|
|
16
|
+
return undefined;
|
|
17
|
+
}
|
|
18
|
+
let recipient;
|
|
19
|
+
try {
|
|
20
|
+
recipient = await identityToRecipient(identity);
|
|
21
|
+
}
|
|
22
|
+
catch {
|
|
23
|
+
// age refuses an identity whose bech32 checksum or length does not hold.
|
|
24
|
+
return undefined;
|
|
25
|
+
}
|
|
26
|
+
const recoveryKey = ageRecoveryKeys.recoveryKeyOf(recipient);
|
|
27
|
+
if (recoveryKey === undefined) {
|
|
28
|
+
return undefined;
|
|
29
|
+
}
|
|
30
|
+
return {
|
|
31
|
+
fingerprint: recoveryKey.fingerprint,
|
|
32
|
+
open: async (wrapped) => {
|
|
33
|
+
const decrypter = new Decrypter();
|
|
34
|
+
decrypter.addIdentity(identity);
|
|
35
|
+
try {
|
|
36
|
+
return new Uint8Array(await decrypter.decrypt(wrapped));
|
|
37
|
+
}
|
|
38
|
+
catch {
|
|
39
|
+
// age refuses a file not wrapped to this identity, or damaged.
|
|
40
|
+
return undefined;
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=age-recovery-identity.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"age-recovery-identity.js","sourceRoot":"","sources":["../../../src/adapters/crypto/age-recovery-identity.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,SAAS,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAGhE,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAEzD,qFAAqF;AACrF,MAAM,eAAe,GAAG,6BAA6B,CAAC;AAStD,sGAAsG;AACtG,MAAM,CAAC,KAAK,UAAU,kBAAkB,CAAC,IAAY;IACnD,MAAM,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IAC/G,MAAM,CAAC,QAAQ,CAAC,GAAG,UAAU,CAAC;IAC9B,IAAI,QAAQ,KAAK,SAAS,IAAI,UAAU,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACpD,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,IAAI,SAAiB,CAAC;IACtB,IAAI,CAAC;QACH,SAAS,GAAG,MAAM,mBAAmB,CAAC,QAAQ,CAAC,CAAC;IAClD,CAAC;IAAC,MAAM,CAAC;QACP,yEAAyE;QACzE,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,MAAM,WAAW,GAAG,eAAe,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC;IAC7D,IAAI,WAAW,KAAK,SAAS,EAAE,CAAC;QAC9B,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,OAAO;QACL,WAAW,EAAE,WAAW,CAAC,WAAW;QACpC,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE;YACtB,MAAM,SAAS,GAAG,IAAI,SAAS,EAAE,CAAC;YAClC,SAAS,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;YAChC,IAAI,CAAC;gBACH,OAAO,IAAI,UAAU,CAAC,MAAM,SAAS,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC;YAC1D,CAAC;YAAC,MAAM,CAAC;gBACP,+DAA+D;gBAC/D,OAAO,SAAS,CAAC;YACnB,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Recovery keys as `age` X25519 recipients (decision 0068, B6): a data key is
|
|
3
|
+
* wrapped to one as an age file, which the company opens on its own computer
|
|
4
|
+
* with the offline private half, with the age tool or core's CLI. Only the
|
|
5
|
+
* X25519 type is taken; a recipient is named by the SHA-256 fingerprint of its
|
|
6
|
+
* text, as ssh-keygen names a key.
|
|
7
|
+
*/
|
|
8
|
+
import { createHash } from 'node:crypto';
|
|
9
|
+
import { Encrypter } from 'age-encryption';
|
|
10
|
+
/** `age1`, then 32 bytes and a checksum in bech32's alphabet, which has no `1`, so no other recipient type (`age1pq1...`, `age1tag1...`) fits. */
|
|
11
|
+
const X25519_RECIPIENT = /^age1[qpzry9x8gf2tvdw0s3jn54khce6mua7l]{58}$/;
|
|
12
|
+
function encrypterTo(recipient) {
|
|
13
|
+
const encrypter = new Encrypter();
|
|
14
|
+
encrypter.addRecipient(recipient);
|
|
15
|
+
return encrypter;
|
|
16
|
+
}
|
|
17
|
+
function hasValidChecksum(recipient) {
|
|
18
|
+
try {
|
|
19
|
+
encrypterTo(recipient);
|
|
20
|
+
return true;
|
|
21
|
+
}
|
|
22
|
+
catch {
|
|
23
|
+
// age refuses a recipient whose bech32 checksum or length does not hold.
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
export const ageRecoveryKeys = {
|
|
28
|
+
recoveryKeyOf: (recipient) => {
|
|
29
|
+
if (!X25519_RECIPIENT.test(recipient) || !hasValidChecksum(recipient)) {
|
|
30
|
+
return undefined;
|
|
31
|
+
}
|
|
32
|
+
return { recipient, fingerprint: `SHA256:${createHash('sha256').update(recipient, 'utf8').digest('base64').replace(/=+$/, '')}` };
|
|
33
|
+
},
|
|
34
|
+
wrap: async (recoveryKey, material) => new Uint8Array(await encrypterTo(recoveryKey.recipient).encrypt(material)),
|
|
35
|
+
};
|
|
36
|
+
//# sourceMappingURL=age-recovery-keys.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"age-recovery-keys.js","sourceRoot":"","sources":["../../../src/adapters/crypto/age-recovery-keys.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAK3C,kJAAkJ;AAClJ,MAAM,gBAAgB,GAAG,8CAA8C,CAAC;AAExE,SAAS,WAAW,CAAC,SAAiB;IACpC,MAAM,SAAS,GAAG,IAAI,SAAS,EAAE,CAAC;IAClC,SAAS,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC;IAClC,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,SAAS,gBAAgB,CAAC,SAAiB;IACzC,IAAI,CAAC;QACH,WAAW,CAAC,SAAS,CAAC,CAAC;QACvB,OAAO,IAAI,CAAC;IACd,CAAC;IAAC,MAAM,CAAC;QACP,yEAAyE;QACzE,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC;AAED,MAAM,CAAC,MAAM,eAAe,GAAiB;IAC3C,aAAa,EAAE,CAAC,SAAS,EAAE,EAAE;QAC3B,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,gBAAgB,CAAC,SAAS,CAAC,EAAE,CAAC;YACtE,OAAO,SAAS,CAAC;QACnB,CAAC;QACD,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,UAAU,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC;IACpI,CAAC;IACD,IAAI,EAAE,KAAK,EAAE,WAAW,EAAE,QAAyB,EAA2B,EAAE,CAAC,IAAI,UAAU,CAAC,MAAM,WAAW,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;CAC5J,CAAC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Seals payloads with AES-256-GCM (decision 0068, B7): a random 96-bit nonce
|
|
3
|
+
* per seal, and additional data naming the version, the fleet and the row, so
|
|
4
|
+
* GCM refuses a sealed payload moved to another row or fleet.
|
|
5
|
+
*/
|
|
6
|
+
import { createCipheriv, createDecipheriv, createHmac, randomBytes } from 'node:crypto';
|
|
7
|
+
import { err, ok } from '../../domain/shared/result.js';
|
|
8
|
+
const CIPHER = 'aes-256-gcm';
|
|
9
|
+
const NONCE_BYTES = 12;
|
|
10
|
+
const TAG_BYTES = 16;
|
|
11
|
+
const VERSION = 'aeolus/v1';
|
|
12
|
+
/** The fixed text the check value signs: it proves a key without revealing it. */
|
|
13
|
+
const CHECK_TEXT = `${VERSION} check value`;
|
|
14
|
+
/** Ids never hold a NUL, so the parts cannot run into each other. */
|
|
15
|
+
function additionalDataOf(row) {
|
|
16
|
+
return Buffer.from([VERSION, row.fleetId, row.rowId].join('\0'), 'utf8');
|
|
17
|
+
}
|
|
18
|
+
function bytesOf(buffer) {
|
|
19
|
+
return new Uint8Array(buffer);
|
|
20
|
+
}
|
|
21
|
+
export const aesGcmPayloadSealer = {
|
|
22
|
+
seal: ({ key, row }, payload) => {
|
|
23
|
+
const nonce = randomBytes(NONCE_BYTES);
|
|
24
|
+
const cipher = createCipheriv(CIPHER, key.material, nonce, { authTagLength: TAG_BYTES });
|
|
25
|
+
cipher.setAAD(additionalDataOf(row));
|
|
26
|
+
const ciphertext = Buffer.concat([cipher.update(payload, 'utf8'), cipher.final(), cipher.getAuthTag()]);
|
|
27
|
+
return { dataKeyId: key.id, nonce: bytesOf(nonce), ciphertext: bytesOf(ciphertext) };
|
|
28
|
+
},
|
|
29
|
+
unseal: ({ key, row }, sealed) => {
|
|
30
|
+
const tagStart = sealed.ciphertext.length - TAG_BYTES;
|
|
31
|
+
if (tagStart < 0 || sealed.nonce.length !== NONCE_BYTES) {
|
|
32
|
+
return err({ kind: 'sealNotOpened' });
|
|
33
|
+
}
|
|
34
|
+
const decipher = createDecipheriv(CIPHER, key.material, sealed.nonce, { authTagLength: TAG_BYTES });
|
|
35
|
+
decipher.setAAD(additionalDataOf(row));
|
|
36
|
+
decipher.setAuthTag(sealed.ciphertext.subarray(tagStart));
|
|
37
|
+
try {
|
|
38
|
+
const plain = Buffer.concat([decipher.update(sealed.ciphertext.subarray(0, tagStart)), decipher.final()]);
|
|
39
|
+
return ok(plain.toString('utf8'));
|
|
40
|
+
}
|
|
41
|
+
catch {
|
|
42
|
+
// GCM's final() throws when the tag does not match: another key, another row or fleet, or damaged.
|
|
43
|
+
return err({ kind: 'sealNotOpened' });
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
checkValue: (material) => bytesOf(createHmac('sha256', material).update(CHECK_TEXT, 'utf8').digest()),
|
|
47
|
+
};
|
|
48
|
+
//# sourceMappingURL=payload-sealer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"payload-sealer.js","sourceRoot":"","sources":["../../../src/adapters/crypto/payload-sealer.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAIxF,OAAO,EAAE,GAAG,EAAE,EAAE,EAAE,MAAM,+BAA+B,CAAC;AAExD,MAAM,MAAM,GAAG,aAAa,CAAC;AAC7B,MAAM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/key-vault.js';
|
|
2
|
+
export interface AwsKmsSettings {
|
|
3
|
+
readonly region: string;
|
|
4
|
+
/** Another KMS endpoint than AWS's own for the region, such as LocalStack's. */
|
|
5
|
+
readonly endpoint?: string | undefined;
|
|
6
|
+
/** The installation principal's credentials. Unset: the AWS SDK's own chain. */
|
|
7
|
+
readonly credentials?: {
|
|
8
|
+
readonly accessKeyId: string;
|
|
9
|
+
readonly secretAccessKey: string;
|
|
10
|
+
} | undefined;
|
|
11
|
+
readonly requestTimeoutMs?: number | undefined;
|
|
12
|
+
}
|
|
13
|
+
export declare function createAwsKmsKeyVault(settings: AwsKmsSettings): KeyVault;
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The key vault on AWS KMS (decision 0068, B2): `GenerateDataKey`, `Decrypt`,
|
|
3
|
+
* `Encrypt` and `ReEncrypt`, each with the encryption context
|
|
4
|
+
* `aeolus:fleet = <fleet id>`, as the installation's one KMS principal. The
|
|
5
|
+
* principal's credentials come from the AWS SDK's own chain (environment,
|
|
6
|
+
* shared files or the role the server runs as) unless given. The KMS's
|
|
7
|
+
* refusals and silences are answers, never thrown: each becomes
|
|
8
|
+
* `keyUnavailable` with its reason.
|
|
9
|
+
*/
|
|
10
|
+
import { DecryptCommand, EncryptCommand, GenerateDataKeyCommand, KMSClient, KMSServiceException, ReEncryptCommand, } from '@aws-sdk/client-kms';
|
|
11
|
+
import { err, ok } from '../../domain/shared/result.js';
|
|
12
|
+
/** How long a call to the KMS may take before it counts as unreachable. */
|
|
13
|
+
const DEFAULT_REQUEST_TIMEOUT_MS = 5_000;
|
|
14
|
+
/** One try: a caller refused `KEY_UNAVAILABLE` tries again itself, and a send must not wait out the SDK's retries. */
|
|
15
|
+
const MAX_ATTEMPTS = 1;
|
|
16
|
+
const DATA_KEY_SPEC = 'AES_256';
|
|
17
|
+
const FLEET_CONTEXT_KEY = 'aeolus:fleet';
|
|
18
|
+
/** The KMS's error names, by the reason each gives. */
|
|
19
|
+
const REASON_BY_ERROR = {
|
|
20
|
+
AccessDeniedException: 'accessDenied',
|
|
21
|
+
DisabledException: 'disabled',
|
|
22
|
+
KMSInvalidStateException: 'disabled',
|
|
23
|
+
NotFoundException: 'notFound',
|
|
24
|
+
InvalidCiphertextException: 'invalidWrap',
|
|
25
|
+
IncorrectKeyException: 'invalidWrap',
|
|
26
|
+
DependencyTimeoutException: 'unreachable',
|
|
27
|
+
KMSInternalException: 'unreachable',
|
|
28
|
+
ThrottlingException: 'unreachable',
|
|
29
|
+
};
|
|
30
|
+
function contextOf(fleetId) {
|
|
31
|
+
return { [FLEET_CONTEXT_KEY]: fleetId };
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* The reason a failed call gives. A KMS error it does not know is a system
|
|
35
|
+
* failure and is thrown on; anything that is not a KMS answer at all (a
|
|
36
|
+
* refused connection, a timeout) means the KMS did not answer.
|
|
37
|
+
*/
|
|
38
|
+
function reasonOf(error) {
|
|
39
|
+
if (error instanceof KMSServiceException) {
|
|
40
|
+
const reason = REASON_BY_ERROR[error.name];
|
|
41
|
+
if (reason === undefined) {
|
|
42
|
+
throw error;
|
|
43
|
+
}
|
|
44
|
+
return reason;
|
|
45
|
+
}
|
|
46
|
+
return 'unreachable';
|
|
47
|
+
}
|
|
48
|
+
async function answerOf(call) {
|
|
49
|
+
try {
|
|
50
|
+
return ok(await call());
|
|
51
|
+
}
|
|
52
|
+
catch (error) {
|
|
53
|
+
return err({ kind: 'keyUnavailable', reason: reasonOf(error) });
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
function bytesOf(value) {
|
|
57
|
+
if (value === undefined) {
|
|
58
|
+
throw new Error('AWS KMS answered without the key bytes it owes.');
|
|
59
|
+
}
|
|
60
|
+
return new Uint8Array(value);
|
|
61
|
+
}
|
|
62
|
+
export function createAwsKmsKeyVault(settings) {
|
|
63
|
+
const requestTimeoutMs = settings.requestTimeoutMs ?? DEFAULT_REQUEST_TIMEOUT_MS;
|
|
64
|
+
const kms = new KMSClient({
|
|
65
|
+
region: settings.region,
|
|
66
|
+
endpoint: settings.endpoint,
|
|
67
|
+
credentials: settings.credentials,
|
|
68
|
+
maxAttempts: MAX_ATTEMPTS,
|
|
69
|
+
});
|
|
70
|
+
/** Each call whole, connection to answer, within the timeout. */
|
|
71
|
+
const inTime = () => ({ abortSignal: AbortSignal.timeout(requestTimeoutMs) });
|
|
72
|
+
return {
|
|
73
|
+
makeDataKey: (use) => answerOf(async () => {
|
|
74
|
+
const made = await kms.send(new GenerateDataKeyCommand({ KeyId: use.companyKey, KeySpec: DATA_KEY_SPEC, EncryptionContext: contextOf(use.fleetId) }), inTime());
|
|
75
|
+
return { material: bytesOf(made.Plaintext), wrapped: bytesOf(made.CiphertextBlob) };
|
|
76
|
+
}),
|
|
77
|
+
unwrap: (use, wrapped) => answerOf(async () => {
|
|
78
|
+
const opened = await kms.send(new DecryptCommand({ KeyId: use.companyKey, CiphertextBlob: wrapped, EncryptionContext: contextOf(use.fleetId) }), inTime());
|
|
79
|
+
return bytesOf(opened.Plaintext);
|
|
80
|
+
}),
|
|
81
|
+
wrap: (use, material) => answerOf(async () => {
|
|
82
|
+
const wrapped = await kms.send(new EncryptCommand({ KeyId: use.companyKey, Plaintext: material, EncryptionContext: contextOf(use.fleetId) }), inTime());
|
|
83
|
+
return bytesOf(wrapped.CiphertextBlob);
|
|
84
|
+
}),
|
|
85
|
+
rewrap: (change, wrapped) => answerOf(async () => {
|
|
86
|
+
const context = contextOf(change.fleetId);
|
|
87
|
+
const rewrapped = await kms.send(new ReEncryptCommand({
|
|
88
|
+
CiphertextBlob: wrapped,
|
|
89
|
+
SourceKeyId: change.from,
|
|
90
|
+
SourceEncryptionContext: context,
|
|
91
|
+
DestinationKeyId: change.to,
|
|
92
|
+
DestinationEncryptionContext: context,
|
|
93
|
+
}), inTime());
|
|
94
|
+
return bytesOf(rewrapped.CiphertextBlob);
|
|
95
|
+
}),
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
//# sourceMappingURL=aws-kms-key-vault.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"aws-kms-key-vault.js","sourceRoot":"","sources":["../../../src/adapters/kms/aws-kms-key-vault.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EACL,cAAc,EACd,cAAc,EACd,sBAAsB,EACtB,SAAS,EACT,mBAAmB,EACnB,gBAAgB,GACjB,MAAM,qBAAqB,CAAC;AAI7B,OAAO,EAAE,GAAG,EAAE,EAAE,EAAe,MAAM,+BAA+B,CAAC;AAErE,2EAA2E;AAC3E,MAAM,0BAA0B,GAAG,KAAK,CAAC;AACzC,sHAAsH;AACtH,MAAM,YAAY,GAAG,CAAC,CAAC;AACvB,MAAM,aAAa,GAAG,SAAS,CAAC;AAChC,MAAM,iBAAiB,GAAG,cAAc,CAAC;AAWzC,uDAAuD;AACvD,MAAM,eAAe,GAAmD;IACtE,qBAAqB,EAAE,cAAc;IACrC,iBAAiB,EAAE,UAAU;IAC7B,wBAAwB,EAAE,UAAU;IACpC,iBAAiB,EAAE,UAAU;IAC7B,0BAA0B,EAAE,aAAa;IACzC,qBAAqB,EAAE,aAAa;IACpC,0BAA0B,EAAE,aAAa;IACzC,oBAAoB,EAAE,aAAa;IACnC,mBAAmB,EAAE,aAAa;CACnC,CAAC;AAEF,SAAS,SAAS,CAAC,OAAgB;IACjC,OAAO,EAAE,CAAC,iBAAiB,CAAC,EAAE,OAAO,EAAE,CAAC;AAC1C,CAAC;AAED;;;;GAIG;AACH,SAAS,QAAQ,CAAC,KAAc;IAC9B,IAAI,KAAK,YAAY,mBAAmB,EAAE,CAAC;QACzC,MAAM,MAAM,GAAG,eAAe,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QAC3C,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;YACzB,MAAM,KAAK,CAAC;QACd,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;IACD,OAAO,aAAa,CAAC;AAC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O;gBACvB,WAAW,EAAE,MAAM,CAAC,IAAI;gBACxB,uBAAuB,EAAE,OAAO;gBAChC,gBAAgB,EAAE,MAAM,CAAC,EAAE;gBAC3B,4BAA4B,EAAE,OAAO;aACtC,CAAC,EACF,MAAM,EAAE,CACT,CAAC;YACF,OAAO,OAAO,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC;QAC3C,CAAC,CAAC;KACL,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The company's own AWS KMS, as the recovery command reaches it on the
|
|
3
|
+
* company's computer (decision 0068, B15): with the AWS SDK's own credential
|
|
4
|
+
* chain there (a profile, SSO or the environment), never the installation's
|
|
5
|
+
* principal, and in the region the key's ARN names, else `AWS_REGION`.
|
|
6
|
+
* Nothing of it is sent to Aeolus.
|
|
7
|
+
*/
|
|
8
|
+
import type { KeyVault } from '../../domain/messaging/key-vault.js';
|
|
9
|
+
export declare function companyKeyVaultFor(companyKey: string, environment: Readonly<Record<string, string | undefined>>): KeyVault;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { createAwsKmsKeyVault } from './aws-kms-key-vault.js';
|
|
2
|
+
/** `arn:<partition>:kms:<region>:<account>:key/...` or `.../alias/...`. */
|
|
3
|
+
const KMS_ARN = /^arn:[a-z-]+:kms:([a-z0-9-]+):/;
|
|
4
|
+
/** Recovery wraps a handful of data keys once: it may wait on the KMS longer than a send does. */
|
|
5
|
+
const RECOVERY_REQUEST_TIMEOUT_MS = 30_000;
|
|
6
|
+
export function companyKeyVaultFor(companyKey, environment) {
|
|
7
|
+
const region = KMS_ARN.exec(companyKey)?.[1] ?? environment.AWS_REGION ?? environment.AWS_DEFAULT_REGION;
|
|
8
|
+
if (region === undefined) {
|
|
9
|
+
// A system failure at the terminal: the command cannot reach any KMS.
|
|
10
|
+
throw new Error(`Name the new company key by its ARN, or set AWS_REGION: ${companyKey} names no region`);
|
|
11
|
+
}
|
|
12
|
+
return createAwsKmsKeyVault({ region, requestTimeoutMs: RECOVERY_REQUEST_TIMEOUT_MS });
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=company-key-vault.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"company-key-vault.js","sourceRoot":"","sources":["../../../src/adapters/kms/company-key-vault.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAE9D,2EAA2E;AAC3E,MAAM,OAAO,GAAG,gCAAgC,CAAC;AAEjD,kGAAkG;AAClG,MAAM,2BAA2B,GAAG,MAAM,CAAC;AAE3C,MAAM,UAAU,kBAAkB,CAAC,UAAkB,EAAE,WAAyD;IAC9G,MAAM,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,WAAW,CAAC,UAAU,IAAI,WAAW,CAAC,kBAAkB,CAAC;IACzG,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;QACzB,sEAAsE;QACtE,MAAM,IAAI,KAAK,CAAC,2DAA2D,UAAU,kBAAkB,CAAC,CAAC;IAC3G,CAAC;IACD,OAAO,oBAAoB,CAAC,EAAE,MAAM,EAAE,gBAAgB,EAAE,2BAA2B,EAAE,CAAC,CAAC;AACzF,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { KeyVault } from '../../domain/messaging/key-vault.js';
|
|
2
|
+
/**
|
|
3
|
+
* The key vault of an installation with no KMS configured (decision 0068):
|
|
4
|
+
* it answers no call, so no fleet can be sealed, and a fleet that is not
|
|
5
|
+
* sealed never calls it.
|
|
6
|
+
*/
|
|
7
|
+
export declare const noKeyVault: KeyVault;
|