@aeolus-fleet/core 0.0.0-stage → 0.18.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 +97 -2
- package/dist/adapters/cli/fleet-init.d.ts +14 -0
- package/dist/adapters/cli/fleet-init.js +68 -0
- package/dist/adapters/cli/fleet-init.js.map +1 -0
- package/dist/adapters/cli/io.d.ts +35 -0
- package/dist/adapters/cli/io.js +21 -0
- package/dist/adapters/cli/io.js.map +1 -0
- package/dist/adapters/cli/migrate.d.ts +11 -0
- package/dist/adapters/cli/migrate.js +12 -0
- package/dist/adapters/cli/migrate.js.map +1 -0
- package/dist/adapters/cli/operator-reset-password.d.ts +12 -0
- package/dist/adapters/cli/operator-reset-password.js +49 -0
- package/dist/adapters/cli/operator-reset-password.js.map +1 -0
- package/dist/adapters/cli/run.d.ts +14 -0
- package/dist/adapters/cli/run.js +40 -0
- package/dist/adapters/cli/run.js.map +1 -0
- package/dist/adapters/cli/terminal.d.ts +20 -0
- package/dist/adapters/cli/terminal.js +68 -0
- package/dist/adapters/cli/terminal.js.map +1 -0
- package/dist/adapters/crypto/passwords.d.ts +2 -0
- package/dist/adapters/crypto/passwords.js +59 -0
- package/dist/adapters/crypto/passwords.js.map +1 -0
- package/dist/adapters/crypto/secrets.d.ts +5 -0
- package/dist/adapters/crypto/secrets.js +10 -0
- package/dist/adapters/crypto/secrets.js.map +1 -0
- package/dist/adapters/http/device-label.d.ts +9 -0
- package/dist/adapters/http/device-label.js +39 -0
- package/dist/adapters/http/device-label.js.map +1 -0
- package/dist/adapters/http/rate-limiter.d.ts +21 -0
- package/dist/adapters/http/rate-limiter.js +44 -0
- package/dist/adapters/http/rate-limiter.js.map +1 -0
- package/dist/adapters/http/request-credentials.d.ts +23 -0
- package/dist/adapters/http/request-credentials.js +45 -0
- package/dist/adapters/http/request-credentials.js.map +1 -0
- package/dist/adapters/http/server.d.ts +47 -0
- package/dist/adapters/http/server.js +216 -0
- package/dist/adapters/http/server.js.map +1 -0
- package/dist/adapters/http/version.d.ts +9 -0
- package/dist/adapters/http/version.js +23 -0
- package/dist/adapters/http/version.js.map +1 -0
- package/dist/adapters/mcp/mcp-endpoint.d.ts +8 -0
- package/dist/adapters/mcp/mcp-endpoint.js +127 -0
- package/dist/adapters/mcp/mcp-endpoint.js.map +1 -0
- package/dist/adapters/prisma/client.d.ts +10 -0
- package/dist/adapters/prisma/client.js +20 -0
- package/dist/adapters/prisma/client.js.map +1 -0
- package/dist/adapters/prisma/delivery-notices.d.ts +34 -0
- package/dist/adapters/prisma/delivery-notices.js +113 -0
- package/dist/adapters/prisma/delivery-notices.js.map +1 -0
- package/dist/adapters/prisma/event-log.d.ts +11 -0
- package/dist/adapters/prisma/event-log.js +61 -0
- package/dist/adapters/prisma/event-log.js.map +1 -0
- package/dist/adapters/prisma/failure-log.d.ts +22 -0
- package/dist/adapters/prisma/failure-log.js +70 -0
- package/dist/adapters/prisma/failure-log.js.map +1 -0
- package/dist/adapters/prisma/fleet-counter.d.ts +3 -0
- package/dist/adapters/prisma/fleet-counter.js +6 -0
- package/dist/adapters/prisma/fleet-counter.js.map +1 -0
- package/dist/adapters/prisma/fleet-event-wakeups.d.ts +33 -0
- package/dist/adapters/prisma/fleet-event-wakeups.js +86 -0
- package/dist/adapters/prisma/fleet-event-wakeups.js.map +1 -0
- package/dist/adapters/prisma/generated/browser.d.ts +127 -0
- package/dist/adapters/prisma/generated/browser.js +18 -0
- package/dist/adapters/prisma/generated/browser.js.map +1 -0
- package/dist/adapters/prisma/generated/client.d.ts +146 -0
- package/dist/adapters/prisma/generated/client.js +38 -0
- package/dist/adapters/prisma/generated/client.js.map +1 -0
- package/dist/adapters/prisma/generated/commonInputTypes.d.ts +879 -0
- package/dist/adapters/prisma/generated/commonInputTypes.js +11 -0
- package/dist/adapters/prisma/generated/commonInputTypes.js.map +1 -0
- package/dist/adapters/prisma/generated/enums.d.ts +75 -0
- package/dist/adapters/prisma/generated/enums.js +73 -0
- package/dist/adapters/prisma/generated/enums.js.map +1 -0
- package/dist/adapters/prisma/generated/internal/class.d.ts +308 -0
- package/dist/adapters/prisma/generated/internal/class.js +52 -0
- package/dist/adapters/prisma/generated/internal/class.js.map +1 -0
- package/dist/adapters/prisma/generated/internal/prismaNamespace.d.ts +2131 -0
- package/dist/adapters/prisma/generated/internal/prismaNamespace.js +295 -0
- package/dist/adapters/prisma/generated/internal/prismaNamespace.js.map +1 -0
- package/dist/adapters/prisma/generated/internal/prismaNamespaceBrowser.d.ts +273 -0
- package/dist/adapters/prisma/generated/internal/prismaNamespaceBrowser.js +265 -0
- package/dist/adapters/prisma/generated/internal/prismaNamespaceBrowser.js.map +1 -0
- package/dist/adapters/prisma/generated/models/ConsoleSession.d.ts +2137 -0
- package/dist/adapters/prisma/generated/models/ConsoleSession.js +2 -0
- package/dist/adapters/prisma/generated/models/ConsoleSession.js.map +1 -0
- package/dist/adapters/prisma/generated/models/Credential.d.ts +1360 -0
- package/dist/adapters/prisma/generated/models/Credential.js +2 -0
- package/dist/adapters/prisma/generated/models/Credential.js.map +1 -0
- package/dist/adapters/prisma/generated/models/CrewRequest.d.ts +1558 -0
- package/dist/adapters/prisma/generated/models/CrewRequest.js +2 -0
- package/dist/adapters/prisma/generated/models/CrewRequest.js.map +1 -0
- package/dist/adapters/prisma/generated/models/Delivery.d.ts +2211 -0
- package/dist/adapters/prisma/generated/models/Delivery.js +2 -0
- package/dist/adapters/prisma/generated/models/Delivery.js.map +1 -0
- package/dist/adapters/prisma/generated/models/Event.d.ts +1991 -0
- package/dist/adapters/prisma/generated/models/Event.js +2 -0
- package/dist/adapters/prisma/generated/models/Event.js.map +1 -0
- package/dist/adapters/prisma/generated/models/Fleet.d.ts +3032 -0
- package/dist/adapters/prisma/generated/models/Fleet.js +2 -0
- package/dist/adapters/prisma/generated/models/Fleet.js.map +1 -0
- package/dist/adapters/prisma/generated/models/Guide.d.ts +943 -0
- package/dist/adapters/prisma/generated/models/Guide.js +2 -0
- package/dist/adapters/prisma/generated/models/Guide.js.map +1 -0
- package/dist/adapters/prisma/generated/models/GuideProgress.d.ts +1323 -0
- package/dist/adapters/prisma/generated/models/GuideProgress.js +2 -0
- package/dist/adapters/prisma/generated/models/GuideProgress.js.map +1 -0
- package/dist/adapters/prisma/generated/models/InstallationRequest.d.ts +1036 -0
- package/dist/adapters/prisma/generated/models/InstallationRequest.js +2 -0
- package/dist/adapters/prisma/generated/models/InstallationRequest.js.map +1 -0
- package/dist/adapters/prisma/generated/models/InstallationSettings.d.ts +1027 -0
- package/dist/adapters/prisma/generated/models/InstallationSettings.js +2 -0
- package/dist/adapters/prisma/generated/models/InstallationSettings.js.map +1 -0
- package/dist/adapters/prisma/generated/models/Lease.d.ts +2076 -0
- package/dist/adapters/prisma/generated/models/Lease.js +2 -0
- package/dist/adapters/prisma/generated/models/Lease.js.map +1 -0
- package/dist/adapters/prisma/generated/models/Message.d.ts +2869 -0
- package/dist/adapters/prisma/generated/models/Message.js +2 -0
- package/dist/adapters/prisma/generated/models/Message.js.map +1 -0
- package/dist/adapters/prisma/generated/models/Notice.d.ts +1068 -0
- package/dist/adapters/prisma/generated/models/Notice.js +2 -0
- package/dist/adapters/prisma/generated/models/Notice.js.map +1 -0
- package/dist/adapters/prisma/generated/models/NoticeDismissal.d.ts +1245 -0
- package/dist/adapters/prisma/generated/models/NoticeDismissal.js +2 -0
- package/dist/adapters/prisma/generated/models/NoticeDismissal.js.map +1 -0
- package/dist/adapters/prisma/generated/models/Operator.d.ts +1173 -0
- package/dist/adapters/prisma/generated/models/Operator.js +2 -0
- package/dist/adapters/prisma/generated/models/Operator.js.map +1 -0
- package/dist/adapters/prisma/generated/models/Ship.d.ts +3320 -0
- package/dist/adapters/prisma/generated/models/Ship.js +2 -0
- package/dist/adapters/prisma/generated/models/Ship.js.map +1 -0
- package/dist/adapters/prisma/generated/models/SignInTicket.d.ts +1222 -0
- package/dist/adapters/prisma/generated/models/SignInTicket.js +2 -0
- package/dist/adapters/prisma/generated/models/SignInTicket.js.map +1 -0
- package/dist/adapters/prisma/generated/models.d.ts +18 -0
- package/dist/adapters/prisma/generated/models.js +2 -0
- package/dist/adapters/prisma/generated/models.js.map +1 -0
- package/dist/adapters/prisma/history.d.ts +3 -0
- package/dist/adapters/prisma/history.js +289 -0
- package/dist/adapters/prisma/history.js.map +1 -0
- package/dist/adapters/prisma/identity.d.ts +10 -0
- package/dist/adapters/prisma/identity.js +213 -0
- package/dist/adapters/prisma/identity.js.map +1 -0
- package/dist/adapters/prisma/installation.d.ts +13 -0
- package/dist/adapters/prisma/installation.js +155 -0
- package/dist/adapters/prisma/installation.js.map +1 -0
- package/dist/adapters/prisma/messaging.d.ts +4 -0
- package/dist/adapters/prisma/messaging.js +156 -0
- package/dist/adapters/prisma/messaging.js.map +1 -0
- package/dist/adapters/prisma/migrate.d.ts +5 -0
- package/dist/adapters/prisma/migrate.js +40 -0
- package/dist/adapters/prisma/migrate.js.map +1 -0
- package/dist/adapters/prisma/receiver-wakeups.d.ts +26 -0
- package/dist/adapters/prisma/receiver-wakeups.js +79 -0
- package/dist/adapters/prisma/receiver-wakeups.js.map +1 -0
- package/dist/adapters/prisma/registry.d.ts +8 -0
- package/dist/adapters/prisma/registry.js +427 -0
- package/dist/adapters/prisma/registry.js.map +1 -0
- package/dist/adapters/prisma/rows.d.ts +58 -0
- package/dist/adapters/prisma/rows.js +408 -0
- package/dist/adapters/prisma/rows.js.map +1 -0
- package/dist/adapters/prisma/unit-of-work.d.ts +36 -0
- package/dist/adapters/prisma/unit-of-work.js +66 -0
- package/dist/adapters/prisma/unit-of-work.js.map +1 -0
- package/dist/adapters/rest/openapi.d.ts +12 -0
- package/dist/adapters/rest/openapi.js +62 -0
- package/dist/adapters/rest/openapi.js.map +1 -0
- package/dist/adapters/rest/rest-api.d.ts +8 -0
- package/dist/adapters/rest/rest-api.js +61 -0
- package/dist/adapters/rest/rest-api.js.map +1 -0
- package/dist/adapters/trpc/console.d.ts +150 -0
- package/dist/adapters/trpc/console.js +102 -0
- package/dist/adapters/trpc/console.js.map +1 -0
- package/dist/adapters/trpc/context.d.ts +201 -0
- package/dist/adapters/trpc/context.js +2 -0
- package/dist/adapters/trpc/context.js.map +1 -0
- package/dist/adapters/trpc/fleet.d.ts +637 -0
- package/dist/adapters/trpc/fleet.js +437 -0
- package/dist/adapters/trpc/fleet.js.map +1 -0
- package/dist/adapters/trpc/installation.d.ts +414 -0
- package/dist/adapters/trpc/installation.js +138 -0
- package/dist/adapters/trpc/installation.js.map +1 -0
- package/dist/adapters/trpc/router.d.ts +1263 -0
- package/dist/adapters/trpc/router.js +15 -0
- package/dist/adapters/trpc/router.js.map +1 -0
- package/dist/adapters/trpc/ship-contract.d.ts +107 -0
- package/dist/adapters/trpc/ship-contract.js +165 -0
- package/dist/adapters/trpc/ship-contract.js.map +1 -0
- package/dist/adapters/trpc/ship-protocol.d.ts +9 -0
- package/dist/adapters/trpc/ship-protocol.js +25 -0
- package/dist/adapters/trpc/ship-protocol.js.map +1 -0
- package/dist/adapters/trpc/ship.d.ts +209 -0
- package/dist/adapters/trpc/ship.js +214 -0
- package/dist/adapters/trpc/ship.js.map +1 -0
- package/dist/adapters/trpc/starting-prompt-text.d.ts +7 -0
- package/dist/adapters/trpc/starting-prompt-text.js +60 -0
- package/dist/adapters/trpc/starting-prompt-text.js.map +1 -0
- package/dist/adapters/trpc/system.d.ts +29 -0
- package/dist/adapters/trpc/system.js +15 -0
- package/dist/adapters/trpc/system.js.map +1 -0
- package/dist/adapters/trpc/trpc.d.ts +131 -0
- package/dist/adapters/trpc/trpc.js +350 -0
- package/dist/adapters/trpc/trpc.js.map +1 -0
- package/dist/app.d.ts +31 -0
- package/dist/app.js +80 -0
- package/dist/app.js.map +1 -0
- package/dist/bin/aeolus-core.d.ts +2 -0
- package/dist/bin/aeolus-core.js +45 -0
- package/dist/bin/aeolus-core.js.map +1 -0
- package/dist/config.d.ts +35 -0
- package/dist/config.js +74 -0
- package/dist/config.js.map +1 -0
- package/dist/domain/identity/authenticate.d.ts +46 -0
- package/dist/domain/identity/authenticate.js +18 -0
- package/dist/domain/identity/authenticate.js.map +1 -0
- package/dist/domain/identity/console-session.d.ts +54 -0
- package/dist/domain/identity/console-session.js +29 -0
- package/dist/domain/identity/console-session.js.map +1 -0
- package/dist/domain/identity/credential.d.ts +76 -0
- package/dist/domain/identity/credential.js +63 -0
- package/dist/domain/identity/credential.js.map +1 -0
- package/dist/domain/identity/dismiss-notice.d.ts +19 -0
- package/dist/domain/identity/dismiss-notice.js +23 -0
- package/dist/domain/identity/dismiss-notice.js.map +1 -0
- package/dist/domain/identity/get-guide.d.ts +7 -0
- package/dist/domain/identity/get-guide.js +5 -0
- package/dist/domain/identity/get-guide.js.map +1 -0
- package/dist/domain/identity/get-notices.d.ts +7 -0
- package/dist/domain/identity/get-notices.js +5 -0
- package/dist/domain/identity/get-notices.js.map +1 -0
- package/dist/domain/identity/guide.d.ts +24 -0
- package/dist/domain/identity/guide.js +3 -0
- package/dist/domain/identity/guide.js.map +1 -0
- package/dist/domain/identity/issue-sign-in-ticket.d.ts +38 -0
- package/dist/domain/identity/issue-sign-in-ticket.js +39 -0
- package/dist/domain/identity/issue-sign-in-ticket.js.map +1 -0
- package/dist/domain/identity/notice.d.ts +16 -0
- package/dist/domain/identity/notice.js +12 -0
- package/dist/domain/identity/notice.js.map +1 -0
- package/dist/domain/identity/operator-account.d.ts +28 -0
- package/dist/domain/identity/operator-account.js +21 -0
- package/dist/domain/identity/operator-account.js.map +1 -0
- package/dist/domain/identity/ports.d.ts +193 -0
- package/dist/domain/identity/ports.js +2 -0
- package/dist/domain/identity/ports.js.map +1 -0
- package/dist/domain/identity/public.d.ts +3 -0
- package/dist/domain/identity/public.js +5 -0
- package/dist/domain/identity/public.js.map +1 -0
- package/dist/domain/identity/read-account.d.ts +35 -0
- package/dist/domain/identity/read-account.js +27 -0
- package/dist/domain/identity/read-account.js.map +1 -0
- package/dist/domain/identity/read-guide.d.ts +18 -0
- package/dist/domain/identity/read-guide.js +21 -0
- package/dist/domain/identity/read-guide.js.map +1 -0
- package/dist/domain/identity/read-notices.d.ts +13 -0
- package/dist/domain/identity/read-notices.js +17 -0
- package/dist/domain/identity/read-notices.js.map +1 -0
- package/dist/domain/identity/record-guide-progress.d.ts +19 -0
- package/dist/domain/identity/record-guide-progress.js +24 -0
- package/dist/domain/identity/record-guide-progress.js.map +1 -0
- package/dist/domain/identity/redeem-sign-in-ticket.d.ts +34 -0
- package/dist/domain/identity/redeem-sign-in-ticket.js +25 -0
- package/dist/domain/identity/redeem-sign-in-ticket.js.map +1 -0
- package/dist/domain/identity/reset-operator-password.d.ts +34 -0
- package/dist/domain/identity/reset-operator-password.js +55 -0
- package/dist/domain/identity/reset-operator-password.js.map +1 -0
- package/dist/domain/identity/set-guide.d.ts +13 -0
- package/dist/domain/identity/set-guide.js +12 -0
- package/dist/domain/identity/set-guide.js.map +1 -0
- package/dist/domain/identity/set-notices.d.ts +13 -0
- package/dist/domain/identity/set-notices.js +12 -0
- package/dist/domain/identity/set-notices.js.map +1 -0
- package/dist/domain/identity/set-theme.d.ts +21 -0
- package/dist/domain/identity/set-theme.js +19 -0
- package/dist/domain/identity/set-theme.js.map +1 -0
- package/dist/domain/identity/sign-in-ticket.d.ts +21 -0
- package/dist/domain/identity/sign-in-ticket.js +5 -0
- package/dist/domain/identity/sign-in-ticket.js.map +1 -0
- package/dist/domain/identity/sign-in.d.ts +51 -0
- package/dist/domain/identity/sign-in.js +43 -0
- package/dist/domain/identity/sign-in.js.map +1 -0
- package/dist/domain/identity/sign-out.d.ts +20 -0
- package/dist/domain/identity/sign-out.js +32 -0
- package/dist/domain/identity/sign-out.js.map +1 -0
- package/dist/domain/identity/start-console-session.d.ts +27 -0
- package/dist/domain/identity/start-console-session.js +54 -0
- package/dist/domain/identity/start-console-session.js.map +1 -0
- package/dist/domain/identity/start-viewer-session.d.ts +29 -0
- package/dist/domain/identity/start-viewer-session.js +42 -0
- package/dist/domain/identity/start-viewer-session.js.map +1 -0
- package/dist/domain/messaging/acknowledge-delivery.d.ts +30 -0
- package/dist/domain/messaging/acknowledge-delivery.js +31 -0
- package/dist/domain/messaging/acknowledge-delivery.js.map +1 -0
- package/dist/domain/messaging/answer-ping.d.ts +33 -0
- package/dist/domain/messaging/answer-ping.js +37 -0
- package/dist/domain/messaging/answer-ping.js.map +1 -0
- package/dist/domain/messaging/check-inbox.d.ts +33 -0
- package/dist/domain/messaging/check-inbox.js +61 -0
- package/dist/domain/messaging/check-inbox.js.map +1 -0
- package/dist/domain/messaging/content-type.d.ts +9 -0
- package/dist/domain/messaging/content-type.js +18 -0
- package/dist/domain/messaging/content-type.js.map +1 -0
- package/dist/domain/messaging/daily-message-limit.d.ts +19 -0
- package/dist/domain/messaging/daily-message-limit.js +24 -0
- package/dist/domain/messaging/daily-message-limit.js.map +1 -0
- package/dist/domain/messaging/delivery.d.ts +116 -0
- package/dist/domain/messaging/delivery.js +201 -0
- package/dist/domain/messaging/delivery.js.map +1 -0
- package/dist/domain/messaging/dismiss-delivery.d.ts +28 -0
- package/dist/domain/messaging/dismiss-delivery.js +29 -0
- package/dist/domain/messaging/dismiss-delivery.js.map +1 -0
- package/dist/domain/messaging/inbox-wait.d.ts +8 -0
- package/dist/domain/messaging/inbox-wait.js +19 -0
- package/dist/domain/messaging/inbox-wait.js.map +1 -0
- package/dist/domain/messaging/mark-done.d.ts +45 -0
- package/dist/domain/messaging/mark-done.js +49 -0
- package/dist/domain/messaging/mark-done.js.map +1 -0
- package/dist/domain/messaging/mark-read.d.ts +27 -0
- package/dist/domain/messaging/mark-read.js +34 -0
- package/dist/domain/messaging/mark-read.js.map +1 -0
- package/dist/domain/messaging/message.d.ts +104 -0
- package/dist/domain/messaging/message.js +84 -0
- package/dist/domain/messaging/message.js.map +1 -0
- package/dist/domain/messaging/payload.d.ts +9 -0
- package/dist/domain/messaging/payload.js +16 -0
- package/dist/domain/messaging/payload.js.map +1 -0
- package/dist/domain/messaging/ping-ship.d.ts +38 -0
- package/dist/domain/messaging/ping-ship.js +42 -0
- package/dist/domain/messaging/ping-ship.js.map +1 -0
- package/dist/domain/messaging/ports.d.ts +116 -0
- package/dist/domain/messaging/ports.js +2 -0
- package/dist/domain/messaging/ports.js.map +1 -0
- package/dist/domain/messaging/receive-deliveries.d.ts +68 -0
- package/dist/domain/messaging/receive-deliveries.js +119 -0
- package/dist/domain/messaging/receive-deliveries.js.map +1 -0
- package/dist/domain/messaging/receive-max.d.ts +8 -0
- package/dist/domain/messaging/receive-max.js +17 -0
- package/dist/domain/messaging/receive-max.js.map +1 -0
- package/dist/domain/messaging/reply-to-message.d.ts +35 -0
- package/dist/domain/messaging/reply-to-message.js +49 -0
- package/dist/domain/messaging/reply-to-message.js.map +1 -0
- package/dist/domain/messaging/resend-delivery.d.ts +48 -0
- package/dist/domain/messaging/resend-delivery.js +97 -0
- package/dist/domain/messaging/resend-delivery.js.map +1 -0
- package/dist/domain/messaging/send-message.d.ts +88 -0
- package/dist/domain/messaging/send-message.js +115 -0
- package/dist/domain/messaging/send-message.js.map +1 -0
- package/dist/domain/messaging/send-request.d.ts +16 -0
- package/dist/domain/messaging/send-request.js +18 -0
- package/dist/domain/messaging/send-request.js.map +1 -0
- package/dist/domain/registry/applied-limits.d.ts +15 -0
- package/dist/domain/registry/applied-limits.js +15 -0
- package/dist/domain/registry/applied-limits.js.map +1 -0
- package/dist/domain/registry/assign-crew.d.ts +31 -0
- package/dist/domain/registry/assign-crew.js +35 -0
- package/dist/domain/registry/assign-crew.js.map +1 -0
- package/dist/domain/registry/claim-ship.d.ts +49 -0
- package/dist/domain/registry/claim-ship.js +59 -0
- package/dist/domain/registry/claim-ship.js.map +1 -0
- package/dist/domain/registry/commission-ship.d.ts +54 -0
- package/dist/domain/registry/commission-ship.js +70 -0
- package/dist/domain/registry/commission-ship.js.map +1 -0
- package/dist/domain/registry/confirm-crew-release.d.ts +28 -0
- package/dist/domain/registry/confirm-crew-release.js +28 -0
- package/dist/domain/registry/confirm-crew-release.js.map +1 -0
- package/dist/domain/registry/create-fleet.d.ts +39 -0
- package/dist/domain/registry/create-fleet.js +56 -0
- package/dist/domain/registry/create-fleet.js.map +1 -0
- package/dist/domain/registry/crew-request.d.ts +148 -0
- package/dist/domain/registry/crew-request.js +175 -0
- package/dist/domain/registry/crew-request.js.map +1 -0
- package/dist/domain/registry/delete-fleet.d.ts +46 -0
- package/dist/domain/registry/delete-fleet.js +34 -0
- package/dist/domain/registry/delete-fleet.js.map +1 -0
- package/dist/domain/registry/deregister.d.ts +32 -0
- package/dist/domain/registry/deregister.js +38 -0
- package/dist/domain/registry/deregister.js.map +1 -0
- package/dist/domain/registry/explain-crew-request.d.ts +30 -0
- package/dist/domain/registry/explain-crew-request.js +31 -0
- package/dist/domain/registry/explain-crew-request.js.map +1 -0
- package/dist/domain/registry/fleet.d.ts +12 -0
- package/dist/domain/registry/fleet.js +12 -0
- package/dist/domain/registry/fleet.js.map +1 -0
- package/dist/domain/registry/found-fleet.d.ts +32 -0
- package/dist/domain/registry/found-fleet.js +43 -0
- package/dist/domain/registry/found-fleet.js.map +1 -0
- package/dist/domain/registry/get-fleet-limits.d.ts +17 -0
- package/dist/domain/registry/get-fleet-limits.js +14 -0
- package/dist/domain/registry/get-fleet-limits.js.map +1 -0
- package/dist/domain/registry/get-installation-fleet.d.ts +15 -0
- package/dist/domain/registry/get-installation-fleet.js +12 -0
- package/dist/domain/registry/get-installation-fleet.js.map +1 -0
- package/dist/domain/registry/get-installation-settings.d.ts +7 -0
- package/dist/domain/registry/get-installation-settings.js +5 -0
- package/dist/domain/registry/get-installation-settings.js.map +1 -0
- package/dist/domain/registry/get-ship.d.ts +34 -0
- package/dist/domain/registry/get-ship.js +36 -0
- package/dist/domain/registry/get-ship.js.map +1 -0
- package/dist/domain/registry/get-starting-prompt.d.ts +24 -0
- package/dist/domain/registry/get-starting-prompt.js +46 -0
- package/dist/domain/registry/get-starting-prompt.js.map +1 -0
- package/dist/domain/registry/initialise-fleet.d.ts +28 -0
- package/dist/domain/registry/initialise-fleet.js +39 -0
- package/dist/domain/registry/initialise-fleet.js.map +1 -0
- package/dist/domain/registry/installation-fleet.d.ts +36 -0
- package/dist/domain/registry/installation-fleet.js +22 -0
- package/dist/domain/registry/installation-fleet.js.map +1 -0
- package/dist/domain/registry/installation-request.d.ts +23 -0
- package/dist/domain/registry/installation-request.js +5 -0
- package/dist/domain/registry/installation-request.js.map +1 -0
- package/dist/domain/registry/lease.d.ts +51 -0
- package/dist/domain/registry/lease.js +39 -0
- package/dist/domain/registry/lease.js.map +1 -0
- package/dist/domain/registry/leases.d.ts +66 -0
- package/dist/domain/registry/leases.js +80 -0
- package/dist/domain/registry/leases.js.map +1 -0
- package/dist/domain/registry/limits.d.ts +50 -0
- package/dist/domain/registry/limits.js +24 -0
- package/dist/domain/registry/limits.js.map +1 -0
- package/dist/domain/registry/list-fleet.d.ts +70 -0
- package/dist/domain/registry/list-fleet.js +47 -0
- package/dist/domain/registry/list-fleet.js.map +1 -0
- package/dist/domain/registry/list-fleets.d.ts +11 -0
- package/dist/domain/registry/list-fleets.js +9 -0
- package/dist/domain/registry/list-fleets.js.map +1 -0
- package/dist/domain/registry/list-installation-fleets.d.ts +15 -0
- package/dist/domain/registry/list-installation-fleets.js +15 -0
- package/dist/domain/registry/list-installation-fleets.js.map +1 -0
- package/dist/domain/registry/ping-status.d.ts +17 -0
- package/dist/domain/registry/ping-status.js +28 -0
- package/dist/domain/registry/ping-status.js.map +1 -0
- package/dist/domain/registry/pingable-ship.d.ts +22 -0
- package/dist/domain/registry/pingable-ship.js +21 -0
- package/dist/domain/registry/pingable-ship.js.map +1 -0
- package/dist/domain/registry/ports.d.ts +318 -0
- package/dist/domain/registry/ports.js +2 -0
- package/dist/domain/registry/ports.js.map +1 -0
- package/dist/domain/registry/public.d.ts +8 -0
- package/dist/domain/registry/public.js +10 -0
- package/dist/domain/registry/public.js.map +1 -0
- package/dist/domain/registry/read-assigned-crew-requests.d.ts +14 -0
- package/dist/domain/registry/read-assigned-crew-requests.js +15 -0
- package/dist/domain/registry/read-assigned-crew-requests.js.map +1 -0
- package/dist/domain/registry/recrew-ship.d.ts +33 -0
- package/dist/domain/registry/recrew-ship.js +34 -0
- package/dist/domain/registry/recrew-ship.js.map +1 -0
- package/dist/domain/registry/release-ship.d.ts +38 -0
- package/dist/domain/registry/release-ship.js +47 -0
- package/dist/domain/registry/release-ship.js.map +1 -0
- package/dist/domain/registry/remove-crew-request.d.ts +28 -0
- package/dist/domain/registry/remove-crew-request.js +36 -0
- package/dist/domain/registry/remove-crew-request.js.map +1 -0
- package/dist/domain/registry/rename-ship.d.ts +30 -0
- package/dist/domain/registry/rename-ship.js +39 -0
- package/dist/domain/registry/rename-ship.js.map +1 -0
- package/dist/domain/registry/report-crew-status.d.ts +29 -0
- package/dist/domain/registry/report-crew-status.js +30 -0
- package/dist/domain/registry/report-crew-status.js.map +1 -0
- package/dist/domain/registry/report-details.d.ts +18 -0
- package/dist/domain/registry/report-details.js +41 -0
- package/dist/domain/registry/report-details.js.map +1 -0
- package/dist/domain/registry/report-log.d.ts +21 -0
- package/dist/domain/registry/report-log.js +16 -0
- package/dist/domain/registry/report-log.js.map +1 -0
- package/dist/domain/registry/report.d.ts +30 -0
- package/dist/domain/registry/report.js +30 -0
- package/dist/domain/registry/report.js.map +1 -0
- package/dist/domain/registry/request-crew.d.ts +32 -0
- package/dist/domain/registry/request-crew.js +29 -0
- package/dist/domain/registry/request-crew.js.map +1 -0
- package/dist/domain/registry/resolve-selector.d.ts +25 -0
- package/dist/domain/registry/resolve-selector.js +32 -0
- package/dist/domain/registry/resolve-selector.js.map +1 -0
- package/dist/domain/registry/retire-ship.d.ts +42 -0
- package/dist/domain/registry/retire-ship.js +68 -0
- package/dist/domain/registry/retire-ship.js.map +1 -0
- package/dist/domain/registry/set-fleet-limits.d.ts +30 -0
- package/dist/domain/registry/set-fleet-limits.js +54 -0
- package/dist/domain/registry/set-fleet-limits.js.map +1 -0
- package/dist/domain/registry/set-installation-settings.d.ts +18 -0
- package/dist/domain/registry/set-installation-settings.js +31 -0
- package/dist/domain/registry/set-installation-settings.js.map +1 -0
- package/dist/domain/registry/ship-handle.d.ts +5 -0
- package/dist/domain/registry/ship-handle.js +20 -0
- package/dist/domain/registry/ship-handle.js.map +1 -0
- package/dist/domain/registry/ship-note.d.ts +7 -0
- package/dist/domain/registry/ship-note.js +15 -0
- package/dist/domain/registry/ship-note.js.map +1 -0
- package/dist/domain/registry/ship-report.d.ts +42 -0
- package/dist/domain/registry/ship-report.js +93 -0
- package/dist/domain/registry/ship-report.js.map +1 -0
- package/dist/domain/registry/ship.d.ts +190 -0
- package/dist/domain/registry/ship.js +334 -0
- package/dist/domain/registry/ship.js.map +1 -0
- package/dist/domain/registry/ships.d.ts +25 -0
- package/dist/domain/registry/ships.js +22 -0
- package/dist/domain/registry/ships.js.map +1 -0
- package/dist/domain/registry/starting-prompt.d.ts +32 -0
- package/dist/domain/registry/starting-prompt.js +22 -0
- package/dist/domain/registry/starting-prompt.js.map +1 -0
- package/dist/domain/registry/whoami.d.ts +20 -0
- package/dist/domain/registry/whoami.js +15 -0
- package/dist/domain/registry/whoami.js.map +1 -0
- package/dist/domain/shared/caller.d.ts +25 -0
- package/dist/domain/shared/caller.js +8 -0
- package/dist/domain/shared/caller.js.map +1 -0
- package/dist/domain/shared/clock.d.ts +4 -0
- package/dist/domain/shared/clock.js +2 -0
- package/dist/domain/shared/clock.js.map +1 -0
- package/dist/domain/shared/errors.d.ts +13 -0
- package/dist/domain/shared/errors.js +6 -0
- package/dist/domain/shared/errors.js.map +1 -0
- package/dist/domain/shared/events.d.ts +75 -0
- package/dist/domain/shared/events.js +9 -0
- package/dist/domain/shared/events.js.map +1 -0
- package/dist/domain/shared/follow-fleet.d.ts +32 -0
- package/dist/domain/shared/follow-fleet.js +65 -0
- package/dist/domain/shared/follow-fleet.js.map +1 -0
- package/dist/domain/shared/history.d.ts +124 -0
- package/dist/domain/shared/history.js +16 -0
- package/dist/domain/shared/history.js.map +1 -0
- package/dist/domain/shared/idempotency-key.d.ts +8 -0
- package/dist/domain/shared/idempotency-key.js +14 -0
- package/dist/domain/shared/idempotency-key.js.map +1 -0
- package/dist/domain/shared/notifier.d.ts +17 -0
- package/dist/domain/shared/notifier.js +2 -0
- package/dist/domain/shared/notifier.js.map +1 -0
- package/dist/domain/shared/ping.d.ts +18 -0
- package/dist/domain/shared/ping.js +8 -0
- package/dist/domain/shared/ping.js.map +1 -0
- package/dist/domain/shared/read-fleet-events.d.ts +29 -0
- package/dist/domain/shared/read-fleet-events.js +25 -0
- package/dist/domain/shared/read-fleet-events.js.map +1 -0
- package/dist/domain/shared/read-fleet-limits.d.ts +39 -0
- package/dist/domain/shared/read-fleet-limits.js +24 -0
- package/dist/domain/shared/read-fleet-limits.js.map +1 -0
- package/dist/domain/shared/read-inbox.d.ts +20 -0
- package/dist/domain/shared/read-inbox.js +16 -0
- package/dist/domain/shared/read-inbox.js.map +1 -0
- package/dist/domain/shared/read-message.d.ts +21 -0
- package/dist/domain/shared/read-message.js +18 -0
- package/dist/domain/shared/read-message.js.map +1 -0
- package/dist/domain/shared/read-needs-attention.d.ts +12 -0
- package/dist/domain/shared/read-needs-attention.js +10 -0
- package/dist/domain/shared/read-needs-attention.js.map +1 -0
- package/dist/domain/shared/read-ship-messages.d.ts +28 -0
- package/dist/domain/shared/read-ship-messages.js +30 -0
- package/dist/domain/shared/read-ship-messages.js.map +1 -0
- package/dist/domain/shared/read-ship-timeline.d.ts +18 -0
- package/dist/domain/shared/read-ship-timeline.js +16 -0
- package/dist/domain/shared/read-ship-timeline.js.map +1 -0
- package/dist/domain/shared/result.d.ts +16 -0
- package/dist/domain/shared/result.js +7 -0
- package/dist/domain/shared/result.js.map +1 -0
- package/dist/domain/shared/secrets.d.ts +26 -0
- package/dist/domain/shared/secrets.js +2 -0
- package/dist/domain/shared/secrets.js.map +1 -0
- package/dist/domain/shared/selector.d.ts +29 -0
- package/dist/domain/shared/selector.js +2 -0
- package/dist/domain/shared/selector.js.map +1 -0
- package/dist/domain/shared/unit-of-work.d.ts +13 -0
- package/dist/domain/shared/unit-of-work.js +2 -0
- package/dist/domain/shared/unit-of-work.js.map +1 -0
- package/dist/domain/shared/utc-day.d.ts +4 -0
- package/dist/domain/shared/utc-day.js +9 -0
- package/dist/domain/shared/utc-day.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/start.d.ts +6 -0
- package/dist/start.js +29 -0
- package/dist/start.js.map +1 -0
- package/dist/wiring.d.ts +158 -0
- package/dist/wiring.js +185 -0
- package/dist/wiring.js.map +1 -0
- package/package.json +61 -4
- package/prisma.config.ts +18 -0
- package/src/adapters/prisma/migrations/20260929124818_init/migration.sql +201 -0
- package/src/adapters/prisma/migrations/20260929160000_fleet_argo_console_session/migration.sql +130 -0
- package/src/adapters/prisma/migrations/20260929220017_operator_login/migration.sql +27 -0
- package/src/adapters/prisma/migrations/20260930090000_crew_token/migration.sql +5 -0
- package/src/adapters/prisma/migrations/20260930120000_send/migration.sql +30 -0
- package/src/adapters/prisma/migrations/20260930150000_receive/migration.sql +24 -0
- package/src/adapters/prisma/migrations/20261001010000_event_seq/migration.sql +34 -0
- package/src/adapters/prisma/migrations/20261001020000_console_session_end_reason/migration.sql +14 -0
- package/src/adapters/prisma/migrations/20261001030000_account_theme_session_device/migration.sql +8 -0
- package/src/adapters/prisma/migrations/20261001040000_lease_last_seen/migration.sql +2 -0
- package/src/adapters/prisma/migrations/20261002190000_lease_report/migration.sql +7 -0
- package/src/adapters/prisma/migrations/20261003140000_commission_key/migration.sql +7 -0
- package/src/adapters/prisma/migrations/20261003200000_message_model/migration.sql +5 -0
- package/src/adapters/prisma/migrations/20261003201000_lease_harness/migration.sql +2 -0
- package/src/adapters/prisma/migrations/20261004120000_operator_without_password/migration.sql +2 -0
- package/src/adapters/prisma/migrations/20261004121000_installation_requests/migration.sql +21 -0
- package/src/adapters/prisma/migrations/20261004122000_events_deleted_with_their_fleet/migration.sql +11 -0
- package/src/adapters/prisma/migrations/20261004130000_sign_in_tickets/migration.sql +16 -0
- package/src/adapters/prisma/migrations/20261004140000_fleet_limits/migration.sql +6 -0
- package/src/adapters/prisma/migrations/20261004141000_installation_settings/migration.sql +12 -0
- package/src/adapters/prisma/migrations/20261005090000_viewer_ship/migration.sql +2 -0
- package/src/adapters/prisma/migrations/20261005100000_viewer_sessions/migration.sql +20 -0
- package/src/adapters/prisma/migrations/20261005110000_notices/migration.sql +37 -0
- package/src/adapters/prisma/migrations/20261005120000_guide/migration.sql +34 -0
- package/src/adapters/prisma/migrations/20261006100000_fleet_crew_scope/migration.sql +8 -0
- package/src/adapters/prisma/migrations/20261006140000_lease_report_details/migration.sql +3 -0
- package/src/adapters/prisma/migrations/20261006160000_crew_requests/migration.sql +20 -0
- package/src/adapters/prisma/migrations/20261006180000_crew_scopes/migration.sql +9 -0
- package/src/adapters/prisma/migrations/20261006190000_crew_assignment/migration.sql +13 -0
- package/src/adapters/prisma/migrations/20261006200000_crew_request_reason/migration.sql +3 -0
- package/src/adapters/prisma/migrations/migration_lock.toml +3 -0
- package/src/adapters/prisma/schema.prisma +558 -0
package/README.md
CHANGED
|
@@ -1,3 +1,98 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @aeolus-fleet/core
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The [Aeolus](https://github.com/ThomasHendrickx/aeolus-fleet) server: one tRPC API and the fleet domain on Postgres, with its migrations.
|
|
4
|
+
|
|
5
|
+
Pre-v1: the API changes without notice until the v1 acceptance test passes.
|
|
6
|
+
|
|
7
|
+
## Running from npm
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
npm install @aeolus-fleet/core @aeolus-fleet/console
|
|
11
|
+
export DATABASE_URL=postgresql://... PUBLIC_URL=https://fleet.example.com
|
|
12
|
+
npx aeolus-core migrate
|
|
13
|
+
npx aeolus-core fleet:init --name "my fleet" # once: asks for the operator email and password
|
|
14
|
+
npx aeolus-core start
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
| Command | Does |
|
|
18
|
+
| --- | --- |
|
|
19
|
+
| `aeolus-core start` | Migrates the database, then serves the fleet until `SIGINT` or `SIGTERM` |
|
|
20
|
+
| `aeolus-core migrate` | Applies the migrations the package ships, with Prisma Migrate, and nothing else. Needs `DATABASE_URL` alone |
|
|
21
|
+
| `aeolus-core fleet:init --name "<fleet name>"` | See Server commands below |
|
|
22
|
+
| `aeolus-core operator:reset-password` | See Server commands below |
|
|
23
|
+
|
|
24
|
+
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.
|
|
25
|
+
|
|
26
|
+
On `SIGINT` or `SIGTERM` the server stops taking requests, and every receive waiting on an empty inbox answers with no deliveries at once. Idle connections close at once, and a connection whose request ends during the stop closes with its answer, so nothing holds the stop up.
|
|
27
|
+
|
|
28
|
+
## Configuration
|
|
29
|
+
|
|
30
|
+
Environment variables, validated at startup (see `.env.example`):
|
|
31
|
+
|
|
32
|
+
| Variable | Default | Meaning |
|
|
33
|
+
| --- | --- | --- |
|
|
34
|
+
| `DATABASE_URL` | required | Postgres 16 or newer, with a direct connection |
|
|
35
|
+
| `PUBLIC_URL` | required | Where ships reach the fleet (`http://` or `https://`): every starting prompt carries the fleet MCP URL under it, `<PUBLIC_URL>/mcp` |
|
|
36
|
+
| `HOST` | `127.0.0.1` | Interface to listen on |
|
|
37
|
+
| `PORT` | `4000` | Port to listen on |
|
|
38
|
+
| `LOG_LEVEL` | `info` | `fatal`, `error`, `warn`, `info`, `debug`, `trace` or `silent` |
|
|
39
|
+
| `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 |
|
|
40
|
+
| `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 |
|
|
41
|
+
| `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 |
|
|
42
|
+
| `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`) |
|
|
43
|
+
|
|
44
|
+
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.
|
|
45
|
+
|
|
46
|
+
## Server commands
|
|
47
|
+
|
|
48
|
+
Run on the server, against the configured database, once it is migrated:
|
|
49
|
+
|
|
50
|
+
| Command | Does |
|
|
51
|
+
| --- | --- |
|
|
52
|
+
| `aeolus-core fleet:init --name "<fleet name>"` | Asks for the operator email and password (twice, not shown), then creates the fleet, its operator ship `argo` and the operator account. Refuses when a fleet already exists |
|
|
53
|
+
| `aeolus-core operator:reset-password` | Asks for a new operator password (twice, not shown) and sets it. The old one stops working and every console session ends. An operator a hosting installation created has no password and is refused: they sign in only through the hosting service |
|
|
54
|
+
|
|
55
|
+
Both commands read their answers a line at a time from standard input, so a script can pipe them in. Like the API, they refuse any answer 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>"` and `npm run operator:reset-password -w @aeolus-fleet/core`, and `npm run db:migrate -w @aeolus-fleet/core` migrates.
|
|
56
|
+
|
|
57
|
+
The operator signs in to the console with that email and password; 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.
|
|
58
|
+
|
|
59
|
+
## Ships
|
|
60
|
+
|
|
61
|
+
The operator gets a ship's starting prompt from `fleet.commission`, or later from `fleet.getStartingPrompt`. It carries identity only: the fleet MCP URL (`<PUBLIC_URL>/mcp`) and the one-line command that adds it to Claude Code, the ship id and secret, how to pick the location, and `Call register.` What the ship works on, the operator adds after it.
|
|
62
|
+
|
|
63
|
+
A session crews an agent ship with `ship.register`: the ship id and secret from its starting prompt, and where it runs (`DEVICE`, `CLOUD`, `SERVER`, or `OTHER` with a description). It gets a crew token (`aeolus_ct_v1_...`) back once, and every later call carries it as `Authorization: Bearer <crew token>`; the secret works only for `register`. A second `register` fails while a session crews the ship. Failed `register` attempts (a wrong ship id or secret) are rate-limited per client address; a successful claim never counts, so one address can start many sessions. `ship.whoami` answers the caller's ship: id, fleet, name and type.
|
|
64
|
+
|
|
65
|
+
`ship.send` sends a message from the calling ship (a crew token, or the console session as `argo`); it needs the `messages:send` scope. It takes a selector (`{ "kind": "ship", "shipId": "shp_..." }`, `{ "kind": "ship", "name": "scout" }` or `{ "kind": "type", "type": "reviewer" }`), a payload (text of at most 64 KB in UTF-8, never parsed), optionally its content type (any well-formed media type, such as `text/plain` or `application/json; charset=utf-8`, passed on untouched; `text/plain` when left out), the sender's own idempotency key (1 to 256 characters) and, for a reply, `inReplyTo` (a message id of the fleet). A name is resolved to the ship's id when the message is sent; a retired or unknown ship, or a type without an active ship, is refused. It answers `{ "messageId": "msg_..." }` only once the message and its delivery are stored. A repeat of the key with the same request (selector as sent, payload, content type, `inReplyTo`; no content type is the same as `text/plain`) answers with the original id; the same key with another request is refused (`CONFLICT`). When the send commits, Postgres `NOTIFY` announces the delivery on the channel `aeolus_delivery_pending`.
|
|
66
|
+
|
|
67
|
+
`ship.receive` and `ship.ack` take the crew token only (the console session is refused) and need the `messages:receive` scope. `ship.receive` takes `{ "max": 1 to 10 }`, one when left out, and answers `{ "deliveries": [...] }`: the crew's own unacknowledged deliveries in flight first, then the oldest pending ones for its ship or its type. Each comes with its message and its sender (`deliveryId`, `messageId`, `senderShipId`, `senderName`, `senderType`, `recipient`, `payload`, `contentType`, `inReplyTo`, `sentAt`, `attempts`; the sender's name and type as they are at the receive, so a renamed sender goes by its new name) and stays in flight until acknowledged or the lease ends; the crew's next receive returns it again, counted as another claim, so a lost reply loses nothing. The fifth claim of a delivery never acknowledged makes it undeliverable instead. With nothing there, a receive waits about 25 seconds and answers with no deliveries; a delivery for its ship or type wakes it at once. `ship.ack` takes `{ "deliveryId": "dlv_..." }` and answers `{}`: only the ship holding the delivery in flight acknowledges it, and acknowledging it again is OK. `ship.pong` takes the crew token and the same scope, takes `{ "deliveryId": "dlv_..." }` of a ping the ship holds in flight and answers `{}`: it acknowledges the ping, with `answer: pong` in `DeliveryAcknowledged`, and marks the lease last seen, in one transaction; again is OK and changes nothing, and a delivery that is not a ping is refused (`CONFLICT`). `ship.report` takes the crew token and no scope: `{ "state": "working" | "blocked" | "idle", "note"?: "..." }` (one line, at most 200 characters, trimmed), answers `{}`. The report is kept with the crew's lease, so the ship's next crew starts with none, and `fleet.list` and `fleet.ship` show it (`report: { state, note, reportedAt }` or null); `ShipReported` is written only when the state or the note changes, so reporting the same again is a check-in. `ship.inbox` takes the crew token and the same scope, takes `{ "waitSeconds": 0 to 25 }`, none when left out, and answers `{ "waiting": n }`: how many deliveries the crew's next receive would hand it, its own in flight included. It claims nothing. While none waits it waits up to `waitSeconds`, woken like a receive. A mutation only so REST takes its body; it changes nothing.
|
|
68
|
+
|
|
69
|
+
A lease ends cleanly in two ways. The operator releases a crewed ship with `fleet.release` (`{ "shipId": "shp_..." }`, scope `fleet:manage`); `argo` is never released, and a ship awaiting crew gets a new starting prompt instead (`CONFLICT`). A crew ends its own lease with `ship.deregister`, which takes the crew token only and no scope. Both work in one transaction: the secret is invalidated, the lease and its crew token end, and the deliveries the lease held in flight return to pending, to the ship's inbox or its type's queue, their attempts kept, each announced on `aeolus_delivery_pending` as a send is, so a waiting receive of another ship of the type takes a returned type delivery at once. Both answer `{}`. The old crew token then fails on every call, refused as `LEASE_ENDED` with `This ship was released; this session no longer crews it.` (the `UNAUTHORIZED` code at `/trpc`, which knows only tRPC's codes), and the old secret fails on `register`; the next crew needs a new starting prompt. A receive of that crew still waiting hands out nothing: it answers empty at the end of its wait, or `LEASE_ENDED` if a delivery wakes it first.
|
|
70
|
+
|
|
71
|
+
`fleet.ping` (`{ "shipId": "shp_..." }`, `fleet:manage`) sends a crewed ship a ping: a message from argo with the content type `application/vnd.aeolus.ping` and the payload `Ping from argo: answer with pong(deliveryId).`, delivered like any other. It answers `{ "messageId": "msg_...", "sentAt": "...", "isNew": true }`. Pings never stack: while the ship's last ping is pending or in flight, it answers with that one (`isNew: false`) and stores nothing. It refuses argo (`FORBIDDEN`), a retired ship and a ship awaiting crew (`CONFLICT`). `ship.send` refuses the ping content type for every caller (`FORBIDDEN`): only `fleet.ping` sends a ping.
|
|
72
|
+
|
|
73
|
+
`fleet.rename` (`{ "shipId": "shp_...", "name": "lookout" }`, `fleet:manage`) gives any ship but argo (`FORBIDDEN`) or a retired one (`CONFLICT`) a new name, checked as at commissioning and unique among active ships (`CONFLICT` when taken), with `ShipRenamed`. Its id, history and session stay; a sender addressing the old name no longer reaches it. It answers `{}`.
|
|
74
|
+
|
|
75
|
+
The operator retires a ship for good with `fleet.retire` (`{ "shipId": "shp_..." }`, scope `fleet:manage`), crewed or not, never `argo` (`FORBIDDEN`), never twice (`CONFLICT`). In one transaction it locks the ship, invalidates its secret, ends a crewed ship's lease as a release does, abandons the deliveries pending to the ship itself (one `DeliveryAbandoned` each, with `ShipRetired`) and retires it: it is never claimed or addressed again and its name is free. Deliveries to its type stay for the other ships of the type, and an undeliverable one stays for the operator. A send racing it either commits first and is abandoned, or comes after and is refused. It answers `{ "abandonedDeliveries": n }`. `fleet.recrew` (`{ "shipId": "shp_..." }`, `fleet:manage`) gives a crewed ship whose session is gone a new crew: a release and a new starting prompt in one transaction, answering the prompt and crew line once, as `fleet.getStartingPrompt` does. `fleet.ship` counts `inFlightDeliveries` (what a release returns) and `openDeliveries` (what a retire abandons).
|
|
76
|
+
|
|
77
|
+
Needs attention: `fleet.needsAttention` (`fleet:read`) lists every undeliverable delivery of the fleet, oldest first by when it became undeliverable, each with its claims, `since` and its whole message. `fleet.dismiss` (`{ "deliveryId": "dlv_..." }`, `fleet:manage`) sets one to dismissed with `DeliveryDismissed`, and answers `{}`; again is OK. `fleet.resend` (`{ "deliveryId": "dlv_..." }`, `fleet:manage`) sends it again: a new message from the original sender, to the same ship or type, with the same payload, content type and `inReplyTo`, naming the original (`resend_of`), and dismisses the original, in one transaction. It answers `{ "messageId": "msg_..." }`; a second resend of the delivery answers the same. Any delivery not undeliverable is refused (`CONFLICT`); a selector that no longer resolves is refused as a send would be, and the original stays undeliverable.
|
|
78
|
+
|
|
79
|
+
The operator inbox: `fleet.inbox` (`{ "filter": "open" | "done" | "all" }`, `fleet:read`) lists the messages addressed to the caller itself (argo's, for the console; argo's too for a viewer session, decision 0022), newest first, each with its delivery's state, `readAt`, `doneAt`, `repliedWith` and its whole message. Only argo's console session calls the rest; any other ship is refused (`FORBIDDEN`), and a delivery not in argo's inbox is `NOT_FOUND`. `fleet.markRead` (`{ "deliveryId", "isRead" }`, `messages:receive`) marks it read (keeping the first read) or unread; read is not done, and no event is written. `fleet.markDone` (`{ "deliveryId" }`, `messages:receive`) claims and acknowledges it at once under the console session's lease; again is OK. `fleet.reply` (`{ "deliveryId", "payload", "idempotencyKey" }`, `messages:send` and `messages:receive`) sends the payload as `text/plain` from argo to the message's sender with `inReplyTo`, and marks the message done in one transaction; it answers `{ "messageId" }`, and a repeat of the key answers the same reply.
|
|
80
|
+
|
|
81
|
+
A ship reaches the same calls without installing anything, as REST under `/api/v1` or as MCP tools at `/mcp`. Both map onto the ship procedures above and hold no logic of their own; neither reads the console session cookie, so a call without a valid crew token is told to use the crew token alone, and failed `register` attempts count against one limit per client address whichever door they come through. A failure in either door, inside a procedure or not, answers only `Internal error` and the request's id. The MCP server sends the ship protocol (`adapters/trpc/ship-protocol.ts`) as its instructions when a client connects, and the OpenAPI spec's description opens with the same text: register once, at the start, and keep the crew token; then receive, ack each delivery and act only if the ack succeeded, and answer by `senderName` with `inReplyTo`; keep receiving while waiting for an answer; deregister only when the session ends for good; end the turn when the work is done and no answer is expected; and once a call answers `LEASE_ENDED`, stop calling the fleet. Each call's description states only that call's own rules, such as `inReplyTo` taking the message id and a new idempotency key for every message; no rule is stated in both.
|
|
82
|
+
|
|
83
|
+
- **REST**: `POST /api/v1/ship/register`, `GET /api/v1/ship/whoami`, and `POST /api/v1/ship/send`, `/receive`, `/ack`, `/inbox` and `/deregister`, each with a JSON body where it takes input and the crew token as `Authorization: Bearer`. A refusal answers with its code's HTTP status and `{ "code": "CONFLICT", "message": "..." }`. The OpenAPI 3.1 spec is at `/api/v1/openapi.json`, and as a readable page at `/api/v1/docs`.
|
|
84
|
+
- **MCP**: a remote MCP server over streamable HTTP, one tool per call. The connection carries no ship, so many conversations can share it (ADR 0015): every tool but `register` takes the crew token as its `crewToken` argument. A refusal is a tool error reading `CODE: message`. To add it to Claude Code, for every session on the machine: `claude mcp add --transport http --scope user aeolus <PUBLIC_URL>/mcp`.
|
|
85
|
+
|
|
86
|
+
The server listens on `aeolus_delivery_pending` over a connection of its own (named `aeolus-delivery-listener` in Postgres), which needs a direct database connection, not a transaction pooler. After a lost connection it listens again, with a delay that doubles up to 30 seconds, and every waiting receive then looks again, since notices sent meanwhile are gone.
|
|
87
|
+
|
|
88
|
+
No text input to any procedure may hold the character U+0000, which Postgres cannot store: it is refused as `BAD_REQUEST`, naming the field. A refusal answers its own code and message. A server failure answers only `Internal error` and the request's id (`data.requestId`); the server log holds the whole error, stack included, under the same id (`reqId`). No answer ever carries a stack trace.
|
|
89
|
+
|
|
90
|
+
A database error is logged by its codes only, under `database`: Prisma's code, Postgres's SQLSTATE and the driver adapter's kind, never its message or stack, since Postgres quotes values from the request in its words. The same holds for the health check, the delivery listener and the server commands.
|
|
91
|
+
|
|
92
|
+
A request Fastify refuses before any procedure runs answers in the same `{ "code", "message" }` shape: a body that is not JSON `400 BAD_REQUEST`, a body over 1 MiB `413 PAYLOAD_TOO_LARGE`, a body of another content type `415 UNSUPPORTED_MEDIA_TYPE`, and a path or method nothing serves `404 NOT_FOUND`.
|
|
93
|
+
|
|
94
|
+
The operator's account: `console.account` answers `kind: "operator"` with the signed-in operator's email, theme and this console session (`{ "device": "Mac · Chrome", "since": "..." }`; the device is worded from the sign-in's User-Agent and is also argo's lease location), or `kind: "viewer"` with the session alone for a viewer session (decision 0022). `console.setTheme` (`{ "theme": "light" | "dark" | "system" }`) stores the theme on the account, so it follows the operator to any browser; no event. Both answer only a console session (`FORBIDDEN` otherwise), and `console.setTheme` refuses a viewer session.
|
|
95
|
+
|
|
96
|
+
Last seen: every call a crew token or the console session authenticates marks its lease seen (`leases.last_seen_at`), in the statement that looks the caller up. `fleet.list` and `fleet.ship` answer `lastSeenAt` for a crewed ship (its claim until it calls again), for the viewer ship the last use of its most recent viewer session, and null otherwise. Observation only (ADR 0016): no heartbeat, nothing ends a lease because a ship went quiet. With the aeolus plugin, the watcher's inbox check keeps it fresh about every 25 s.
|
|
97
|
+
|
|
98
|
+
`GET /api/version` answers the versions this process runs, `{ "server": "0.7.0", "common": "0.7.0", "migration": "<latest applied migration>" }` (`migration: null` when the database cannot say). No authentication, no fleet data. The web app's `/version` combines it with its own.
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { InitialiseFleet } from '../../domain/registry/initialise-fleet.js';
|
|
2
|
+
import type { ListFleets } from '../../domain/registry/list-fleets.js';
|
|
3
|
+
import { type CommandIo, type ExitCode } from './io.js';
|
|
4
|
+
/**
|
|
5
|
+
* `fleet:init --name <name>`: asks for the operator's email and password, then
|
|
6
|
+
* creates the fleet, its operator ship argo and the operator account the
|
|
7
|
+
* console signs in with. Refuses when a fleet already exists, before asking
|
|
8
|
+
* anything; the use case checks again under its lock, for two runs at once.
|
|
9
|
+
*/
|
|
10
|
+
export declare function fleetInit(args: string[], deps: {
|
|
11
|
+
initialiseFleet: InitialiseFleet;
|
|
12
|
+
listFleets: ListFleets;
|
|
13
|
+
io: CommandIo;
|
|
14
|
+
}): Promise<ExitCode>;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { parseArgs } from 'node:util';
|
|
2
|
+
import { askNewPassword, nulRefusal } from './io.js';
|
|
3
|
+
const NOTHING_CREATED = 'Nothing was created.';
|
|
4
|
+
const USAGE = 'Usage: aeolus-core fleet:init --name "<fleet name>"';
|
|
5
|
+
/**
|
|
6
|
+
* `fleet:init --name <name>`: asks for the operator's email and password, then
|
|
7
|
+
* creates the fleet, its operator ship argo and the operator account the
|
|
8
|
+
* console signs in with. Refuses when a fleet already exists, before asking
|
|
9
|
+
* anything; the use case checks again under its lock, for two runs at once.
|
|
10
|
+
*/
|
|
11
|
+
export async function fleetInit(args, deps) {
|
|
12
|
+
const { io } = deps;
|
|
13
|
+
let name;
|
|
14
|
+
try {
|
|
15
|
+
({ name } = parseArgs({ args, options: { name: { type: 'string' } }, strict: true }).values);
|
|
16
|
+
}
|
|
17
|
+
catch (error) {
|
|
18
|
+
io.err(`${error instanceof Error ? error.message : String(error)}\n${USAGE}`);
|
|
19
|
+
return 2;
|
|
20
|
+
}
|
|
21
|
+
if (name === undefined) {
|
|
22
|
+
io.err(`fleet:init needs the fleet's name.\n${USAGE}`);
|
|
23
|
+
return 2;
|
|
24
|
+
}
|
|
25
|
+
const nameRefusal = nulRefusal([{ name: 'fleet name', text: name }], NOTHING_CREATED);
|
|
26
|
+
if (nameRefusal !== undefined) {
|
|
27
|
+
io.err(nameRefusal);
|
|
28
|
+
return 1;
|
|
29
|
+
}
|
|
30
|
+
if ((await deps.listFleets()).length > 0) {
|
|
31
|
+
io.err(`A fleet already exists: a fleet is initialised only once. ${NOTHING_CREATED}`);
|
|
32
|
+
return 1;
|
|
33
|
+
}
|
|
34
|
+
const email = await io.ask('Operator email: ');
|
|
35
|
+
const password = email === undefined ? { kind: 'ended' } : await askNewPassword(io, 'Operator password: ');
|
|
36
|
+
if (email === undefined || password.kind === 'ended') {
|
|
37
|
+
io.err('fleet:init needs the operator email and the password twice. Nothing was created.');
|
|
38
|
+
return 2;
|
|
39
|
+
}
|
|
40
|
+
if (password.kind === 'differ') {
|
|
41
|
+
io.err('The two passwords differ. Nothing was created.');
|
|
42
|
+
return 1;
|
|
43
|
+
}
|
|
44
|
+
const answerRefusal = nulRefusal([
|
|
45
|
+
{ name: 'operator email', text: email },
|
|
46
|
+
{ name: 'operator password', text: password.password },
|
|
47
|
+
], NOTHING_CREATED);
|
|
48
|
+
if (answerRefusal !== undefined) {
|
|
49
|
+
io.err(answerRefusal);
|
|
50
|
+
return 1;
|
|
51
|
+
}
|
|
52
|
+
const initialised = await deps.initialiseFleet({ name, email, password: password.password });
|
|
53
|
+
if (!initialised.isOk) {
|
|
54
|
+
io.err(initialised.error.message);
|
|
55
|
+
return 1;
|
|
56
|
+
}
|
|
57
|
+
const { fleetId, operatorShipId, operatorId } = initialised.value;
|
|
58
|
+
io.out([
|
|
59
|
+
`Fleet initialised: ${fleetId}`,
|
|
60
|
+
`Operator ship argo: ${operatorShipId}`,
|
|
61
|
+
`Operator account: ${operatorId}`,
|
|
62
|
+
'',
|
|
63
|
+
'Sign in to the console with the operator email and password: that crews argo.',
|
|
64
|
+
'If the password is lost, run aeolus-core operator:reset-password on the server.',
|
|
65
|
+
].join('\n'));
|
|
66
|
+
return 0;
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=fleet-init.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fleet-init.js","sourceRoot":"","sources":["../../../src/adapters/cli/fleet-init.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAItC,OAAO,EAAE,cAAc,EAAE,UAAU,EAAiC,MAAM,SAAS,CAAC;AAEpF,MAAM,eAAe,GAAG,sBAAsB,CAAC;AAE/C,MAAM,KAAK,GAAG,qDAAqD,CAAC;AAEpE;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,SAAS,CAC7B,IAAc,EACd,IAAiF;IAEjF,MAAM,EAAE,EAAE,EAAE,GAAG,IAAI,CAAC;IAEpB,IAAI,IAAwB,CAAC;IAC7B,IAAI,CAAC;QACH,CAAC,EAAE,IAAI,EAAE,GAAG,SAAS,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAA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F,OAAO,CAAC,CAAC;IACX,CAAC;IACD,IAAI,QAAQ,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;QAC/B,EAAE,CAAC,GAAG,CAAC,gDAAgD,CAAC,CAAC;QACzD,OAAO,CAAC,CAAC;IACX,CAAC;IACD,MAAM,aAAa,GAAG,UAAU,CAC9B;QACE,EAAE,IAAI,EAAE,gBAAgB,EAAE,IAAI,EAAE,KAAK,EAAE;QACvC,EAAE,IAAI,EAAE,mBAAmB,EAAE,IAAI,EAAE,QAAQ,CAAC,QAAQ,EAAE;KACvD,EACD,eAAe,CAChB,CAAC;IACF,IAAI,aAAa,KAAK,SAAS,EAAE,CAAC;QAChC,EAAE,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;QACtB,OAAO,CAAC,CAAC;IACX,CAAC;IAED,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC,eAAe,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE,QAAQ,CAAC,QAAQ,EAAE,CAAC,CAAC;IAC7F,IAAI,CAAC,WAAW,CAAC,IAAI,EAAE,CAAC;QACtB,EAAE,CAAC,GAAG,CAAC,WAAW,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QAClC,OAAO,CAAC,CAAC;IACX,CAAC;IAED,MAAM,EAAE,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,GAAG,WAAW,CAAC,KAAK,CAAC;IAClE,EAAE,CAAC,GAAG,CACJ;QACE,sBAAsB,OAAO,EAAE;QAC/B,uBAAuB,cAAc,EAAE;QACvC,qBAAqB,UAAU,EAAE;QACjC,EAAE;QACF,+EAA+E;QAC/E,iFAAiF;KAClF,CAAC,IAAI,CAAC,IAAI,CAAC,CACb,CAAC;IACF,OAAO,CAAC,CAAC;AACX,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Where a server command talks to the operator: standard output for results
|
|
3
|
+
* and questions, standard error for problems, standard input for answers.
|
|
4
|
+
*/
|
|
5
|
+
export interface CommandIo {
|
|
6
|
+
out(text: string): void;
|
|
7
|
+
err(text: string): void;
|
|
8
|
+
/** Asks and waits for one line. Undefined when the input ends first. A hidden answer is not shown as it is typed. */
|
|
9
|
+
ask(question: string, options?: {
|
|
10
|
+
isHidden?: boolean;
|
|
11
|
+
}): Promise<string | undefined>;
|
|
12
|
+
}
|
|
13
|
+
/** Exit codes: 0 done, 1 refused by the domain or the installation, 2 wrong usage. */
|
|
14
|
+
export type ExitCode = 0 | 1 | 2;
|
|
15
|
+
export type NewPassword = {
|
|
16
|
+
kind: 'given';
|
|
17
|
+
password: string;
|
|
18
|
+
} | {
|
|
19
|
+
kind: 'differ';
|
|
20
|
+
} | {
|
|
21
|
+
kind: 'ended';
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* Asks for a new password twice, without showing it. `differ` when the two
|
|
25
|
+
* answers differ, `ended` when the input ends first.
|
|
26
|
+
*/
|
|
27
|
+
export declare function askNewPassword(io: CommandIo, question: string): Promise<NewPassword>;
|
|
28
|
+
/**
|
|
29
|
+
* Postgres text can never store the character U+0000, so a command refuses
|
|
30
|
+
* it as the API does, naming what holds it. Undefined when no text does.
|
|
31
|
+
*/
|
|
32
|
+
export declare function nulRefusal(texts: readonly {
|
|
33
|
+
name: string;
|
|
34
|
+
text: string;
|
|
35
|
+
}[], outcome: string): string | undefined;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Asks for a new password twice, without showing it. `differ` when the two
|
|
3
|
+
* answers differ, `ended` when the input ends first.
|
|
4
|
+
*/
|
|
5
|
+
export async function askNewPassword(io, question) {
|
|
6
|
+
const password = await io.ask(question, { isHidden: true });
|
|
7
|
+
const repeated = await io.ask('Repeat the password: ', { isHidden: true });
|
|
8
|
+
if (password === undefined || repeated === undefined) {
|
|
9
|
+
return { kind: 'ended' };
|
|
10
|
+
}
|
|
11
|
+
return password === repeated ? { kind: 'given', password } : { kind: 'differ' };
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Postgres text can never store the character U+0000, so a command refuses
|
|
15
|
+
* it as the API does, naming what holds it. Undefined when no text does.
|
|
16
|
+
*/
|
|
17
|
+
export function nulRefusal(texts, outcome) {
|
|
18
|
+
const holding = texts.find(({ text }) => text.includes('\u0000'));
|
|
19
|
+
return holding && `The ${holding.name} cannot hold the character U+0000 (NUL). ${outcome}`;
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=io.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"io.js","sourceRoot":"","sources":["../../../src/adapters/cli/io.ts"],"names":[],"mappings":"AAgBA;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,EAAa,EAAE,QAAgB;IAClE,MAAM,QAAQ,GAAG,MAAM,EAAE,CAAC,GAAG,CAAC,QAAQ,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC;IAC5D,MAAM,QAAQ,GAAG,MAAM,EAAE,CAAC,GAAG,CAAC,uBAAuB,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC;IAC3E,IAAI,QAAQ,KAAK,SAAS,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;QACrD,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;IAC3B,CAAC;IACD,OAAO,QAAQ,KAAK,QAAQ,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;AAClF,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,UAAU,CAAC,KAAgD,EAAE,OAAe;IAC1F,MAAM,OAAO,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC;IAClE,OAAO,OAAO,IAAI,OAAO,OAAO,CAAC,IAAI,4CAA4C,OAAO,EAAE,CAAC;AAC7F,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { CommandIo, ExitCode } from './io.js';
|
|
2
|
+
/**
|
|
3
|
+
* `aeolus-core migrate`: applies the migrations this package ships. Needs
|
|
4
|
+
* DATABASE_URL alone. `start` migrates too; this runs it on its own, such as
|
|
5
|
+
* before a start in a deploy.
|
|
6
|
+
*/
|
|
7
|
+
export declare function migrate(deps: {
|
|
8
|
+
environment: Record<string, string | undefined>;
|
|
9
|
+
migrateDatabase: (databaseUrl: string) => Promise<void>;
|
|
10
|
+
io: CommandIo;
|
|
11
|
+
}): Promise<ExitCode>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { loadDatabaseUrl } from '../../config.js';
|
|
2
|
+
/**
|
|
3
|
+
* `aeolus-core migrate`: applies the migrations this package ships. Needs
|
|
4
|
+
* DATABASE_URL alone. `start` migrates too; this runs it on its own, such as
|
|
5
|
+
* before a start in a deploy.
|
|
6
|
+
*/
|
|
7
|
+
export async function migrate(deps) {
|
|
8
|
+
await deps.migrateDatabase(loadDatabaseUrl(deps.environment));
|
|
9
|
+
deps.io.out('The database is migrated.');
|
|
10
|
+
return 0;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=migrate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"migrate.js","sourceRoot":"","sources":["../../../src/adapters/cli/migrate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAGlD;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,OAAO,CAAC,IAI7B;IACC,MAAM,IAAI,CAAC,eAAe,CAAC,eAAe,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC;IAC9D,IAAI,CAAC,EAAE,CAAC,GAAG,CAAC,2BAA2B,CAAC,CAAC;IACzC,OAAO,CAAC,CAAC;AACX,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { ResetOperatorPassword } from '../../domain/identity/reset-operator-password.js';
|
|
2
|
+
import type { ListFleets } from '../../domain/registry/list-fleets.js';
|
|
3
|
+
import { type CommandIo, type ExitCode } from './io.js';
|
|
4
|
+
/**
|
|
5
|
+
* `operator:reset-password`: asks for a new operator password, sets it, and
|
|
6
|
+
* ends every console session. v1 hosts one fleet, so it acts on that one.
|
|
7
|
+
*/
|
|
8
|
+
export declare function operatorResetPassword(args: string[], deps: {
|
|
9
|
+
listFleets: ListFleets;
|
|
10
|
+
resetOperatorPassword: ResetOperatorPassword;
|
|
11
|
+
io: CommandIo;
|
|
12
|
+
}): Promise<ExitCode>;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { parseArgs } from 'node:util';
|
|
2
|
+
import { askNewPassword, nulRefusal } from './io.js';
|
|
3
|
+
const USAGE = 'Usage: aeolus-core operator:reset-password';
|
|
4
|
+
/**
|
|
5
|
+
* `operator:reset-password`: asks for a new operator password, sets it, and
|
|
6
|
+
* ends every console session. v1 hosts one fleet, so it acts on that one.
|
|
7
|
+
*/
|
|
8
|
+
export async function operatorResetPassword(args, deps) {
|
|
9
|
+
const { io } = deps;
|
|
10
|
+
try {
|
|
11
|
+
parseArgs({ args, options: {}, strict: true });
|
|
12
|
+
}
|
|
13
|
+
catch (error) {
|
|
14
|
+
io.err(`${error instanceof Error ? error.message : String(error)}\n${USAGE}`);
|
|
15
|
+
return 2;
|
|
16
|
+
}
|
|
17
|
+
const fleets = await deps.listFleets();
|
|
18
|
+
const [fleet] = fleets;
|
|
19
|
+
if (!fleet) {
|
|
20
|
+
io.err('There is no fleet yet. Run fleet:init first.');
|
|
21
|
+
return 1;
|
|
22
|
+
}
|
|
23
|
+
if (fleets.length > 1) {
|
|
24
|
+
io.err(`This installation hosts ${String(fleets.length)} fleets; operator:reset-password handles one.`);
|
|
25
|
+
return 1;
|
|
26
|
+
}
|
|
27
|
+
const password = await askNewPassword(io, 'New operator password: ');
|
|
28
|
+
if (password.kind === 'ended') {
|
|
29
|
+
io.err('operator:reset-password needs the new password twice. Nothing was changed.');
|
|
30
|
+
return 2;
|
|
31
|
+
}
|
|
32
|
+
if (password.kind === 'differ') {
|
|
33
|
+
io.err('The two passwords differ. Nothing was changed.');
|
|
34
|
+
return 1;
|
|
35
|
+
}
|
|
36
|
+
const refusal = nulRefusal([{ name: 'operator password', text: password.password }], 'Nothing was changed.');
|
|
37
|
+
if (refusal !== undefined) {
|
|
38
|
+
io.err(refusal);
|
|
39
|
+
return 1;
|
|
40
|
+
}
|
|
41
|
+
const reset = await deps.resetOperatorPassword({ fleetId: fleet.id, password: password.password });
|
|
42
|
+
if (!reset.isOk) {
|
|
43
|
+
io.err(reset.error.message);
|
|
44
|
+
return 1;
|
|
45
|
+
}
|
|
46
|
+
io.out(`The operator password for fleet ${fleet.id} is reset. Every console session has ended: sign in with the new password.`);
|
|
47
|
+
return 0;
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=operator-reset-password.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operator-reset-password.js","sourceRoot":"","sources":["../../../src/adapters/cli/operator-reset-password.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAItC,OAAO,EAAE,cAAc,EAAE,UAAU,EAAiC,MAAM,SAAS,CAAC;AAEpF,MAAM,KAAK,GAAG,4CAA4C,CAAC;AAE3D;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,qBAAqB,CACzC,IAAc,EACd,IAA6F;IAE7F,MAAM,EAAE,EAAE,EAAE,GAAG,IAAI,CAAC;IAEpB,IAAI,CAAC;QACH,SAAS,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC;IACjD,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,EAAE,CAAC,GAAG,CAAC,GAAG,K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AAI,CAAC,qBAAqB,CAAC,EAAE,OAAO,EAAE,KAAK,CAAC,EAAE,EAAE,QAAQ,EAAE,QAAQ,CAAC,QAAQ,EAAE,CAAC,CAAC;IACnG,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC;QAChB,EAAE,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QAC5B,OAAO,CAAC,CAAC;IACX,CAAC;IAED,EAAE,CAAC,GAAG,CACJ,mCAAmC,KAAK,CAAC,EAAE,4EAA4E,CACxH,CAAC;IACF,OAAO,CAAC,CAAC;AACX,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type UseCases } from '../../wiring.js';
|
|
2
|
+
import type { CommandIo, ExitCode } from './io.js';
|
|
3
|
+
/**
|
|
4
|
+
* Runs a server command at the operator's terminal and exits with its code.
|
|
5
|
+
* A bad configuration or a failed migration is told in its own words; any
|
|
6
|
+
* other failure as `describeFailure` tells it, a database error by its codes.
|
|
7
|
+
*/
|
|
8
|
+
export declare function runAtTerminal(command: (io: CommandIo) => Promise<ExitCode>): Promise<never>;
|
|
9
|
+
/** Runs a server command against the configured database and exits with its code. */
|
|
10
|
+
export declare function runCommand(args: string[], command: (run: {
|
|
11
|
+
args: string[];
|
|
12
|
+
useCases: UseCases;
|
|
13
|
+
io: CommandIo;
|
|
14
|
+
}) => Promise<ExitCode>): Promise<never>;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { ConfigError, loadConfig } from '../../config.js';
|
|
2
|
+
import { createUseCases } from '../../wiring.js';
|
|
3
|
+
import { createPrismaClient } from '../prisma/client.js';
|
|
4
|
+
import { describeFailure } from '../prisma/failure-log.js';
|
|
5
|
+
import { MigrationError } from '../prisma/migrate.js';
|
|
6
|
+
import { terminalIo } from './terminal.js';
|
|
7
|
+
/**
|
|
8
|
+
* Runs a server command at the operator's terminal and exits with its code.
|
|
9
|
+
* A bad configuration or a failed migration is told in its own words; any
|
|
10
|
+
* other failure as `describeFailure` tells it, a database error by its codes.
|
|
11
|
+
*/
|
|
12
|
+
export async function runAtTerminal(command) {
|
|
13
|
+
const io = terminalIo({ input: process.stdin, output: process.stdout, errors: process.stderr });
|
|
14
|
+
let code;
|
|
15
|
+
try {
|
|
16
|
+
code = await command(io);
|
|
17
|
+
}
|
|
18
|
+
catch (error) {
|
|
19
|
+
io.err(error instanceof ConfigError || error instanceof MigrationError ? error.message : describeFailure(error));
|
|
20
|
+
code = 1;
|
|
21
|
+
}
|
|
22
|
+
finally {
|
|
23
|
+
io.close();
|
|
24
|
+
}
|
|
25
|
+
process.exit(code);
|
|
26
|
+
}
|
|
27
|
+
/** Runs a server command against the configured database and exits with its code. */
|
|
28
|
+
export function runCommand(args, command) {
|
|
29
|
+
return runAtTerminal(async (io) => {
|
|
30
|
+
const config = loadConfig(process.env);
|
|
31
|
+
const prisma = createPrismaClient(config.databaseUrl);
|
|
32
|
+
try {
|
|
33
|
+
return await command({ args, useCases: createUseCases({ prisma }), io });
|
|
34
|
+
}
|
|
35
|
+
finally {
|
|
36
|
+
await prisma.$disconnect();
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=run.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run.js","sourceRoot":"","sources":["../../../src/adapters/cli/run.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC1D,OAAO,EAAE,cAAc,EAAiB,MAAM,iBAAiB,CAAC;AAChE,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAC3D,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEtD,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAA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{ CommandIo } from './io.js';
|
|
3
|
+
/** Where a server command reads and writes: standard input, output and error. */
|
|
4
|
+
export interface TerminalStreams {
|
|
5
|
+
input: Readable & {
|
|
6
|
+
isTTY?: boolean;
|
|
7
|
+
};
|
|
8
|
+
output: Writable;
|
|
9
|
+
errors: Writable;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* The operator's terminal for a server command. Answers are read a line at a
|
|
13
|
+
* time from standard input, so they can also be piped in. A hidden answer is
|
|
14
|
+
* not echoed on a terminal: readline's echo goes through an output that is
|
|
15
|
+
* muted while it is typed. Each question is readline's prompt, so a line
|
|
16
|
+
* redrawn after a correction keeps it.
|
|
17
|
+
*/
|
|
18
|
+
export declare function terminalIo(streams: TerminalStreams): CommandIo & {
|
|
19
|
+
close(): void;
|
|
20
|
+
};
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { createInterface } from 'node:readline';
|
|
2
|
+
import { Writable } from 'node:stream';
|
|
3
|
+
/**
|
|
4
|
+
* The operator's terminal for a server command. Answers are read a line at a
|
|
5
|
+
* time from standard input, so they can also be piped in. A hidden answer is
|
|
6
|
+
* not echoed on a terminal: readline's echo goes through an output that is
|
|
7
|
+
* muted while it is typed. Each question is readline's prompt, so a line
|
|
8
|
+
* redrawn after a correction keeps it.
|
|
9
|
+
*/
|
|
10
|
+
export function terminalIo(streams) {
|
|
11
|
+
const { input, output, errors } = streams;
|
|
12
|
+
const isTerminal = input.isTTY === true;
|
|
13
|
+
let isMuted = false;
|
|
14
|
+
let isClosed = false;
|
|
15
|
+
let reader;
|
|
16
|
+
const echo = new Writable({
|
|
17
|
+
writev: (chunks, done) => {
|
|
18
|
+
for (const { chunk } of chunks) {
|
|
19
|
+
if (!isMuted && (typeof chunk === 'string' || chunk instanceof Uint8Array)) {
|
|
20
|
+
output.write(chunk);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
done();
|
|
24
|
+
},
|
|
25
|
+
});
|
|
26
|
+
// Opened on the first question only: a command that asks nothing leaves the terminal alone.
|
|
27
|
+
function open() {
|
|
28
|
+
if (!reader) {
|
|
29
|
+
const lines = createInterface({ input, output: echo, terminal: isTerminal, historySize: 0 });
|
|
30
|
+
lines.on('close', () => {
|
|
31
|
+
isClosed = true;
|
|
32
|
+
});
|
|
33
|
+
reader = { lines, answers: lines[Symbol.asyncIterator]() };
|
|
34
|
+
}
|
|
35
|
+
return reader;
|
|
36
|
+
}
|
|
37
|
+
return {
|
|
38
|
+
out: (text) => {
|
|
39
|
+
output.write(`${text}\n`);
|
|
40
|
+
},
|
|
41
|
+
err: (text) => {
|
|
42
|
+
errors.write(`${text}\n`);
|
|
43
|
+
},
|
|
44
|
+
ask: async (question, options) => {
|
|
45
|
+
const { lines, answers } = open();
|
|
46
|
+
// Once piped input has ended, readline is closed but may still hold answers it read.
|
|
47
|
+
if (isClosed) {
|
|
48
|
+
output.write(question);
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
lines.setPrompt(question);
|
|
52
|
+
lines.prompt();
|
|
53
|
+
}
|
|
54
|
+
isMuted = options?.isHidden === true;
|
|
55
|
+
const answer = await answers.next();
|
|
56
|
+
// Nothing echoed the end of a hidden or piped answer: end its line here.
|
|
57
|
+
if (isMuted || !isTerminal) {
|
|
58
|
+
output.write('\n');
|
|
59
|
+
}
|
|
60
|
+
isMuted = false;
|
|
61
|
+
return answer.done === true ? undefined : answer.value;
|
|
62
|
+
},
|
|
63
|
+
close: () => {
|
|
64
|
+
reader?.lines.close();
|
|
65
|
+
},
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=terminal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"terminal.js","sourceRoot":"","sources":["../../../src/adapters/cli/terminal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAkB,MAAM,eAAe,CAAC;AAChE,OAAO,EAAE,QAAQ,EAAiB,MAAM,aAAa,CAAC;AAWtD;;;;;;GAM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AAC,CAAC;QAC5B,CAAC;QACD,GAAG,EAAE,CAAC,IAAI,EAAE,EAAE;YACZ,MAAM,CAAC,KAAK,CAAC,GAAG,IAAI,IAAI,CAAC,CAAC;QAC5B,CAAC;QACD,GAAG,EAAE,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,EAAE;YAC/B,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,GAAG,IAAI,EAAE,CAAC;YAClC,qFAAqF;YACrF,IAAI,QAAQ,EAAE,CAAC;gBACb,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;YACzB,CAAC;iBAAM,CAAC;gBACN,KAAK,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;gBAC1B,KAAK,CAAC,MAAM,EAAE,CAAC;YACjB,CAAC;YACD,OAAO,GAAG,OAAO,EAAE,QAAQ,KAAK,IAAI,CAAC;YACrC,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,IAAI,EAAE,CAAC;YACpC,yEAAyE;YACzE,IAAI,OAAO,IAAI,CAAC,UAAU,EAAE,CAAC;gBAC3B,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;YACrB,CAAC;YACD,OAAO,GAAG,KAAK,CAAC;YAChB,OAAO,MAAM,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;QACzD,CAAC;QACD,KAAK,EAAE,GAAG,EAAE;YACV,MAAM,EAAE,KAAK,CAAC,KAAK,EAAE,CAAC;QACxB,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { argon2, randomBytes, timingSafeEqual } from 'node:crypto';
|
|
2
|
+
import { promisify } from 'node:util';
|
|
3
|
+
/**
|
|
4
|
+
* Argon2id from Node's crypto module, stored in the PHC string format the
|
|
5
|
+
* reference implementation uses:
|
|
6
|
+
* `$argon2id$v=19$m=<KiB>,t=<passes>,p=<lanes>$<salt>$<hash>`, base64 without
|
|
7
|
+
* padding. The parameters travel in the string, so hashes made with other
|
|
8
|
+
* parameters keep verifying after these change.
|
|
9
|
+
*/
|
|
10
|
+
const deriveKey = promisify(argon2);
|
|
11
|
+
/** OWASP's baseline for Argon2id: 19 MiB of memory, two passes, one lane. */
|
|
12
|
+
const COST = { memory: 19_456, passes: 2, parallelism: 1 };
|
|
13
|
+
const SALT_BYTES = 16;
|
|
14
|
+
const HASH_BYTES = 32;
|
|
15
|
+
const ARGON2_VERSION = 19;
|
|
16
|
+
const PHC_PATTERN = /^\$argon2id\$v=19\$m=(\d+),t=(\d+),p=(\d+)\$([A-Za-z0-9+/]+)\$([A-Za-z0-9+/]+)$/;
|
|
17
|
+
function encode({ cost, salt, hash }) {
|
|
18
|
+
const unpadded = (bytes) => bytes.toString('base64').replace(/=+$/, '');
|
|
19
|
+
return `$argon2id$v=${String(ARGON2_VERSION)}$m=${String(cost.memory)},t=${String(cost.passes)},p=${String(cost.parallelism)}$${unpadded(salt)}$${unpadded(hash)}`;
|
|
20
|
+
}
|
|
21
|
+
/** Throws on anything but an Argon2id hash of version 19: a stored hash this adapter did not make is a system failure. */
|
|
22
|
+
function decode(stored) {
|
|
23
|
+
const match = PHC_PATTERN.exec(stored);
|
|
24
|
+
const [, memory, passes, parallelism, salt, hash] = match ?? [];
|
|
25
|
+
if (!memory || !passes || !parallelism || !salt || !hash) {
|
|
26
|
+
throw new Error('The stored password hash is not an Argon2id hash');
|
|
27
|
+
}
|
|
28
|
+
return {
|
|
29
|
+
cost: { memory: Number(memory), passes: Number(passes), parallelism: Number(parallelism) },
|
|
30
|
+
salt: Buffer.from(salt, 'base64'),
|
|
31
|
+
hash: Buffer.from(hash, 'base64'),
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
function derive(password, stored) {
|
|
35
|
+
const parameters = {
|
|
36
|
+
message: password,
|
|
37
|
+
nonce: stored.salt,
|
|
38
|
+
tagLength: stored.length,
|
|
39
|
+
...stored.cost,
|
|
40
|
+
};
|
|
41
|
+
return deriveKey('argon2id', parameters);
|
|
42
|
+
}
|
|
43
|
+
export const argon2idPasswordHasher = {
|
|
44
|
+
hash: async (password) => {
|
|
45
|
+
const salt = randomBytes(SALT_BYTES);
|
|
46
|
+
const hash = await derive(password, { cost: COST, salt, length: HASH_BYTES });
|
|
47
|
+
return encode({ cost: COST, salt, hash });
|
|
48
|
+
},
|
|
49
|
+
verify: async (password, passwordHash) => {
|
|
50
|
+
if (passwordHash === undefined) {
|
|
51
|
+
await derive(password, { cost: COST, salt: randomBytes(SALT_BYTES), length: HASH_BYTES });
|
|
52
|
+
return false;
|
|
53
|
+
}
|
|
54
|
+
const stored = decode(passwordHash);
|
|
55
|
+
const attempt = await derive(password, { ...stored, length: stored.hash.length });
|
|
56
|
+
return timingSafeEqual(attempt, stored.hash);
|
|
57
|
+
},
|
|
58
|
+
};
|
|
59
|
+
//# sourceMappingURL=passwords.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"passwords.js","sourceRoot":"","sources":["../../../src/adapters/crypto/passwords.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,eAAe,EAAyB,MAAM,aAAa,CAAC;AAC1F,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAItC;;;;;;GAMG;AAEH,MAAM,SAAS,GAAG,SAAS,CAAC,MAAM,CAAC,CAAC;AAEpC,6EAA6E;AAC7E,MAAM,IAAI,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,EAAE,WAAW,EAAE,CAAC,EAAE,CAAC;AAC3D,MAAM,UAAU,GAAG,EAAE,CAAC;AACtB,MAAM,UAAU,GAAG,EAAE,CAAC;AACtB,MAAM,cAAc,GAAG,EAAE,CAAC;AAE1B,MAAM,WAAW,GAAG,iFAAiF,CAAC;AAUtG,SAAS,MAAM,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAc;IAC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ash is enough. */
|
|
3
|
+
export declare const sha256Hasher: SecretHasher;
|
|
4
|
+
/** 32 random bytes from the operating system, base64url encoded (43 characters). */
|
|
5
|
+
export declare const cryptoRandomTokens: RandomTokens;
|